blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
987b8a0ddc7fc240da7cfb5d7bfebdea621e8d87
872e493bb8649ab40f94264d1d5e26e572c7946f
/MediaPlayer(Server)/musicinfo.cpp
bcdec8c6050db4dc19a483ff37857a718828bd91
[]
no_license
MasterDjefer/MediaPlayer
276e2b35cc62bd7b51dfc7d2d737b798867a5140
a2667f05d1ed292a2e846b12d3b11fc941f693fe
refs/heads/master
2020-04-17T15:03:00.961355
2019-02-02T20:06:29
2019-02-02T20:06:29
166,683,058
0
0
null
null
null
null
UTF-8
C++
false
false
308
cpp
musicinfo.cpp
#include "musicinfo.h" MusicInfo::MusicInfo(const QString data) { setData(data); } MusicInfo::~MusicInfo() { } QString MusicInfo::data() const { return mData; } void MusicInfo::setData(const QString data) { if (data == "") { mData = "none"; } else mData = data; }
4d47b20bfb7357199551cd1b9b2a16cac41df63f
3aa225685945dd4b33abdb9b76b2cac0c78d1112
/src/argparse_cf.cpp
65e194b8fac442c3e7ab539e1d2aed39e7f183c8
[ "MIT" ]
permissive
veg/tn93
0922ddd2e06263f7b2ac5e8e8e26ded23cdc70ce
03d2484b973e2ce4a3b373bc3832e2a19509ab23
refs/heads/master
2022-11-21T06:14:41.162248
2022-10-26T23:45:23
2022-10-26T23:45:23
20,779,544
13
8
MIT
2022-11-08T08:28:58
2014-06-12T19:06:35
C++
UTF-8
C++
false
false
4,985
cpp
argparse_cf.cpp
/* argument parsing ------------------------------------------------------------------------------------------------- */ #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include "argparse_cf.hpp" // some crazy shit for stringifying preprocessor directives #define STRIFY(x) #x #define TO_STR(x) STRIFY(x) namespace argparse { const char usage[] = "usage: " PROGNAME " [-h] " "[-o OUTPUT] " "[-a AMBIGS] " "[-t TYPE] " "[-d COUNTS_IN_NAME] " "[-q] " "[FASTA]\n"; const char help_msg[] = "compute per-position coverage from an MSA and report it as a JSON\n" "\n" "optional arguments:\n" " -h, --help show this help message and exit\n" " -o OUTPUT direct the output JSON to a file named OUTPUT (default=stdout)\n" " -a AMBIGS handle ambigous characters using one of the following strategies (default=" TO_STR( DEFAULT_AMBIG ) ")\n" " average: average ambiguities (e.g. a nucleotide R adds 0.5 to A and G coverage for that position);\n" " ignore: ambiguities contribute nothing to coverage counts;\n" " -t DATATYPE the type of data expected (default=" TO_STR( DEFAULT_FORMAT ) ")\n" " dna: DNA or RNA (IUPAC);\n" " protein : protein (IUPAC);\n" " -d COUNTS_IN_NAME if sequence name is of the form 'somethingCOUNTS_IN_NAMEinteger' then treat the integer as a copy number\n" " when computing coverages (a character, default=" TO_STR( COUNTS_IN_NAME ) "):\n" " -q do not report progress updates and other diagnostics to stderr \n" " FASTA read sequences to compare from this file (default=stdin)\n"; inline void help() { fprintf( stderr, "%s\n%s", usage, help_msg ); exit( 1 ); } inline void ERROR( const char * msg, ... ) { va_list args; fprintf( stderr, "%s" PROGNAME ": error: ", usage ); va_start( args, msg ); vfprintf( stderr, msg, args ); va_end( args ); fprintf( stderr, "\n" ); exit( 1 ); } const char * next_arg (int& i, const int argc, const char * argv[]) { i++; if (i == argc) ERROR ("ran out of command line arguments"); return argv[i]; } args_t::args_t( int argc, const char * argv[] ) : output( stdout ), input( stdin ), ambig( DEFAULT_AMBIG ), data ( DEFAULT_DATA ), counts_in_name ( DEFAULT_COUNTS_IN_NAME ), quiet (false) { // skip arg[0], it's just the program name for (int i = 1; i < argc; ++i ) { const char * arg = argv[i]; if ( arg[0] == '-' && arg[1] == '-' ) { if ( !strcmp( &arg[2], "help" ) ) help(); else ERROR( "unknown argument: %s", arg ); } else if ( arg[0] == '-' ) { if ( !strcmp( &arg[1], "h" ) ) help(); else if ( arg[1] == 'o' ) parse_output( next_arg (i, argc, argv) ); else if ( arg[1] == 'a') parse_ambig( next_arg (i, argc, argv) ); else if ( arg[1] == 't') parse_data ( next_arg (i, argc, argv) ); else if ( arg[1] == 'd') parse_counts_in_name( next_arg (i, argc, argv) ); else if ( arg[1] == 'q') parse_quiet ( ); else ERROR( "unknown argument: %s", arg ); } else if (i == argc-1) { parse_input (arg); } else { ERROR( "unknown argument: %s", arg ); } } } args_t::~args_t() { if ( output && output != stdout ) fclose( output ); if ( input && input != stdin) fclose (input); } void args_t::parse_output( const char * str ) { if ( str && strcmp( str, "-" ) ) output = fopen( str, "wb" ); else output = stdout; if ( output == NULL ) ERROR( "failed to open the OUTPUT file %s", str ); } void args_t::parse_input( const char * str ) { if ( str && strcmp( str, "-" ) ) input = fopen( str, "rb" ); else input = stdin; if ( input == NULL ) ERROR( "failed to open the INPUT file %s", str ); } void args_t::parse_counts_in_name ( const char * str ) { counts_in_name = str[0]; if ( ! isprint (counts_in_name)) ERROR( "count separator must be a printable character, had: %s", str ); } void args_t::parse_ambig( const char * str ) { if (!strcmp (str, "average")) { ambig = average; } else if (!strcmp (str, "ignore")) { ambig = skipover; } else { ERROR( "invalid ambiguity handling mode: %s", str ); } } void args_t::parse_data( const char * str ) { if (!strcmp (str, "dna")) { data = dna; } else if (!strcmp (str, "protein")) { data = protein; } else { ERROR( "invalid data type: %s", str ); } } void args_t::parse_quiet ( void ) { quiet = true; } }
fb994c14c78b59633a3d5efa81db939886bcedfe
37cca16f12e7b1d4d01d6f234da6d568c318abee
/src/org/mpisws/p2p/filetransfer/FileTransferImpl_Reader.hpp
52e52187732c5a5342298acdec1ca448f48bd4c6
[]
no_license
subhash1-0/thirstyCrow
e48155ce68fc886f2ee8e7802567c1149bc54206
78b7e4e3d2b9a9530ad7d66b44eacfe73ceea582
refs/heads/master
2016-09-06T21:25:54.075724
2015-09-21T17:21:15
2015-09-21T17:21:15
42,881,521
0
0
null
null
null
null
UTF-8
C++
false
false
556
hpp
FileTransferImpl_Reader.hpp
// Generated from /pastry-2.1/src/org/mpisws/p2p/filetransfer/FileTransferImpl.java #pragma once #include <fwd-pastry-2.1.hpp> #include <org/mpisws/p2p/filetransfer/fwd-pastry-2.1.hpp> #include <rice/p2p/commonapi/appsocket/fwd-pastry-2.1.hpp> #include <java/lang/Object.hpp> struct org::mpisws::p2p::filetransfer::FileTransferImpl_Reader : public virtual ::java::lang::Object { virtual bool read(::rice::p2p::commonapi::appsocket::AppSocket* socket) /* throws(IOException) */ = 0; // Generated static ::java::lang::Class *class_(); };
8719874acbea11280189e15287e48f83c0b465a4
e0654961ba79338e82a0ba03360e97ead4465285
/include/argot/gen/concept_body/detail/for.hpp
91da1ba4f43654cfa111f25198cee359185d4933
[ "BSL-1.0" ]
permissive
blockspacer/argot
68f0e2a56fb4686989b47d0ad0f6127167ea0a9a
97349baaf27659c9dc4d67cf8963b2e871eaedae
refs/heads/master
2022-11-25T02:57:08.808025
2020-08-04T21:15:00
2020-08-04T21:15:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,337
hpp
for.hpp
/*============================================================================== Copyright (c) 2017, 2018 Matt Calabrese 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 ARGOT_GEN_CONCEPT_BODY_DETAIL_FOR_HPP_ #define ARGOT_GEN_CONCEPT_BODY_DETAIL_FOR_HPP_ #include <boost/preprocessor/detail/auto_rec.hpp> // NOTE: The method of recursion with which this file is used is based on the // method of recursion using in the Chaos preprocessor library. // TODO(mattcalabrese) Finish implementing this. #define ARGOT_GEN_DETAIL_FOR_S(s, m, n, ...) \ BOOST_PP_IF(n, ARGOT_GEN_DETAIL_FOR_I, EAT)( \ BOOST_PP_INC(s), m, BOOST_PP_DEC(n), __VA_ARGS__ \ ) \ /**/ #define ARGOT_GEN_DETAIL_FOR_ID() ARGOT_GEN_DETAIL_FOR_S #define ARGOT_GEN_DETAIL_FOR_I(s, m, n, ...) \ DEFER(SCAN)(s)( \ DEFER(ARGOT_GEN_DETAIL_FOR_ID)()( \ s, m, n, __VA_ARGS__ \ ) \ ) \ DEFER(m)(s, n, __VA_ARGS__) \ /**/ // ^^^ that's it, the whole REPEAT algorithm // (recursive) usage #define A(s, n, ...) \ ( SCAN(s)(ARGOT_GEN_DETAIL_FOR_S(s, B, BOOST_PP_INC(n), __VA_ARGS__)) ) \ /**/ #define B(s, n, ...) __VA_ARGS__ #endif // ARGOT_GEN_CONCEPT_BODY_DETAIL_FOR_HPP_
b045bad940506a6223f6aebde2de76aad96ceb22
4bec0306800897b05aac563161d3147d305c1c1a
/src/people/misckeyword.h
8e7243f9230a8b732e7e89638ee4f52c4c38144d
[ "CC0-1.0", "BSD-3-Clause" ]
permissive
KDE/libkgapi
03d5d494406ff44ddb1797c2f3d6e8d9892454d8
4fbde0ea726bf3759a05298ecab9d8e40e72da8a
refs/heads/master
2023-08-24T12:26:21.881120
2023-08-08T01:52:54
2023-08-08T01:52:54
42,723,656
9
9
null
null
null
null
UTF-8
C++
false
false
2,963
h
misckeyword.h
/* * SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org> * SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@kde.org> * * SPDX-License-Identifier: LGPL-2.1-only * SPDX-License-Identifier: LGPL-3.0-only * SPDX-License-Identifier: LicenseRef-KDE-Accepted-LGPL */ #pragma once #include <QSharedDataPointer> #include "kgapipeople_export.h" #include <QString> #include <optional> class QJsonObject; class QJsonValue; class QJsonArray; namespace KGAPI2::People { class FieldMetadata; struct MiscKeywordDefinition; /** * A person's miscellaneous keyword. * * @see https://developers.google.com/people/api/rest/v1/people#misckeyword * @since 5.23.0 **/ class KGAPIPEOPLE_EXPORT MiscKeyword { public: enum class Type { TYPE_UNSPECIFIED, ///< Unspecified. OUTLOOK_BILLING_INFORMATION, ///< Outlook field for billing information. OUTLOOK_DIRECTORY_SERVER, ///< Outlook field for directory server. OUTLOOK_KEYWORD, ///< Outlook field for keyword. OUTLOOK_MILEAGE, ///< Outlook field for mileage. OUTLOOK_PRIORITY, ///< Outlook field for priority. OUTLOOK_SENSITIVITY, ///< Outlook field for sensitivity. OUTLOOK_SUBJECT, ///< Outlook field for subject. OUTLOOK_USER, ///< Outlook field for user. HOME, ///< Home. WORK, ///< Work. OTHER, ///< Other. }; /** Constructs a new MiscKeyword **/ explicit MiscKeyword(); MiscKeyword(const MiscKeywordDefinition &definition); MiscKeyword(const MiscKeyword &); MiscKeyword(MiscKeyword &&) noexcept; MiscKeyword &operator=(const MiscKeyword &); MiscKeyword &operator=(MiscKeyword &&) noexcept; /** Destructor. **/ ~MiscKeyword(); bool operator==(const MiscKeyword &) const; bool operator!=(const MiscKeyword &) const; Q_REQUIRED_RESULT static MiscKeyword fromJSON(const QJsonObject &); Q_REQUIRED_RESULT static QVector<MiscKeyword> fromJSONArray(const QJsonArray &data); Q_REQUIRED_RESULT QJsonValue toJSON() const; /** Metadata about the miscellaneous keyword. **/ Q_REQUIRED_RESULT FieldMetadata metadata() const; /** Sets value of the metadata property. **/ void setMetadata(const FieldMetadata &value); /** The value of the miscellaneous keyword. **/ Q_REQUIRED_RESULT QString value() const; /** Sets value of the value property. **/ void setValue(const QString &value); /** The miscellaneous keyword type. **/ Q_REQUIRED_RESULT MiscKeyword::Type type() const; /** Sets value of the type property. **/ void setType(MiscKeyword::Type value); /** Output only. The type of the miscellaneous keyword translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale. * **/ Q_REQUIRED_RESULT QString formattedType() const; private: class Private; QSharedDataPointer<Private> d; }; // MiscKeyword } // namespace KGAPI2::People
1067a51f8b8388e50e6b0b0684e89feb761bb7da
9b5c9c3934a60a2ecb1aa32e8797411e0b8f2986
/c++/scope_resolution.cpp
4eac52daa7b62445e1186821bfb5ec1f507f956f
[]
no_license
ishtiaqmahmood/Snippets
8da9413ac644a8544afc3a1485a59cbe8fffe324
88158582255d6bfb5fdbc4e77fac42899e038e1b
refs/heads/master
2020-06-19T19:00:02.470614
2019-07-14T12:40:14
2019-07-14T12:40:14
196,834,825
0
0
null
null
null
null
UTF-8
C++
false
false
197
cpp
scope_resolution.cpp
#include <iostream> using namespace std; int x = 10; // global variable int main() { int x = 50; cout << x << endl; cout << :: x << endl; // scope resolution operator to use global variable }
8e76e151d79c87efa144a114008801e0d7e26788
fc4a655a912ff4d9e47dce4d3a1adc6c6c5a4827
/presetAnswer.h
a798165154b496227150b43dc8ca12fb66d82bab
[]
no_license
eaglesunshine/Huawei_CodeCraft-2019
6e724432d500f7c1b46cc7e3a28c7b8db3c0aeb5
d6bfe28d87d15415f8b658e0aeddf50066cb92e7
refs/heads/master
2020-05-24T10:36:52.603025
2019-12-22T14:03:40
2019-12-22T14:03:40
187,230,789
5
0
null
2019-12-22T14:03:41
2019-05-17T14:29:17
C++
UTF-8
C++
false
false
240
h
presetAnswer.h
#pragma once #ifndef __PRESETANSWER_H__ #define __PRESETANSWER_H__ #include <vector> using namespace std; class PresetAnswer { public: int id; int ATD; vector<int> route; bool init(vector<int> carData); }; #endif
892e12b6b636513810e3aabd0166a06beb96f736
a94b7089cd3f41db625e9fdbc5b379ffe361d340
/libstreamsrv/cstreamconnection.cpp
db84b6b24a955456ac087efdeaa0952dec680b19
[]
no_license
MarcelTh/muroa
169e6275052299936987e9c4466d2d8eac0fbf09
3cd79066d4c0df173b91419fd3b80b40a90efce7
refs/heads/master
2021-01-16T21:06:30.338296
2014-02-09T13:27:00
2014-02-09T13:27:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,860
cpp
cstreamconnection.cpp
/*************************************************************************** * Copyright (C) 2005 by Martin Runge * * martin.runge@web.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "cstreamconnection.h" #include "cstreamserver.h" #include <iostream> using namespace std; CStreamConnection::CStreamConnection(CStreamServer* parent, const std::string& name, unsigned short bind_port) : m_socket(SOCK_DGRAM, bind_port ), m_name(name) { m_stream_server = parent; m_socket.setNonBlocking(0); m_socket.recordSenderWithRecv(false); } CStreamConnection::~CStreamConnection() { } /*! \fn CStreamConnection::connect(CIPv4Address* addr) */ int CStreamConnection::connect(CIPv4Address* addr) { m_client_address = *addr; return m_socket.connect(addr); } /*! \fn CStreamConnection::send(char* buffer, int len) */ int CStreamConnection::send(char* buffer, const int len) { // 1) send data away int num = m_socket.write(buffer, len); // 2) check, if there was a rtp packet sent from the client int read_num = m_socket.read(m_rtp_packet.bufferPtr(), m_rtp_packet.bufferSize()); // cerr << "m_socket.read ret " << read_num << endl; if(read_num > 0) { handleReceivedPacket(); } return num; } /*! \fn CStreamConnection::handleReceivedPacket() */ void CStreamConnection::handleReceivedPacket() { cerr << "CStreamConnection::handleReceivedPacket: received a RTP packet from the client." << endl; cerr << "RTP: payloadType = " << m_rtp_packet.payloadType() << " sessionID = " << m_rtp_packet.sessionID() << " streamID = " << m_rtp_packet.streamID() << endl; if(m_rtp_packet.payloadType() == PAYLOAD_SYNC_OBJ) { CSync tmp_sync(&m_rtp_packet); tmp_sync.deserialize(); if(tmp_sync.syncType() == SYNC_REQ_STREAM) { // the clients needs a sync object for this stream !!! CSync* session_sync_obj; session_sync_obj = m_stream_server->getSyncObj(tmp_sync.sessionId(), tmp_sync.streamId()); if(session_sync_obj != 0) { CRTPPacket packet(session_sync_obj->sessionId(), session_sync_obj->streamId(), sizeof(CSync), true); session_sync_obj->serialize(); packet.copyInPayload(session_sync_obj->getSerialisationBufferPtr(), session_sync_obj->getSerialisationBufferSize()); packet.payloadType(PAYLOAD_SYNC_OBJ); m_socket.write(packet.bufferPtr(), packet.usedBufferSize()); } } } } /*! \fn CStreamConnection::method_1() */ CIPv4Address* CStreamConnection::getClientAddress() { return &m_client_address; }
7cf96b03608b4842d8e97f60e564a5242227dbae
a73dddae190d3ddad74297bbd5e339b679c3bbdb
/tests/test_srlatch.cpp
ae7e678b6315eb3c3a41484e3f2e32f4debd56e4
[]
no_license
alejandrogallo/bitis
a2f1aa69c0edd1c846caeb3dd6dae53609e72642
1b2b7efca111fde6cefd8ed7e079698fb577a2f6
refs/heads/master
2020-08-04T02:44:48.680164
2019-10-01T01:28:51
2019-10-01T01:28:51
211,976,015
0
0
null
null
null
null
UTF-8
C++
false
false
654
cpp
test_srlatch.cpp
#include <iostream> #include <vector> #include <bitis.hpp> int main(int argc, char *argv[]) { Wire S, R, Q, _Q; std::vector<std::vector<BIT>> sequence({ {H, L}, {L, L}, {L, H}, {L, L}, {H, L}, {L, L}, }); SRLatch n(&S, &R, &Q, &_Q); std::cout << "SR Latch" << std::endl << "--------" << std::endl << "S R Q ~Q" << std::endl << "--------" << std::endl; for (auto &combination: sequence) { S.set(combination[0]); R.set(combination[1]); n(); std::cout << n.s->get() << " " << n.r->get() << " " << n.q->get() << " " << n._q->get() << std::endl; } return 0; }
5f491181e5939ac38dbfe16c0b9c25787bd3d916
03faee3398730eb8b7b94c2d124aa1b66c02893d
/OceanLight/3rd/algServer/pfr_processor/IMP_StringQueue.h
994bd9079ec1b9d58a81c45f4f4b769cd1684c67
[]
no_license
bianshifeng/OceanLight
a80829c6021662e22e987f0ddb12b3839c5c7ef2
697106f43397467966b76586862c1283d4326ed2
refs/heads/master
2021-01-13T14:05:26.721466
2017-05-03T07:48:57
2017-05-03T07:48:57
76,212,078
0
1
null
null
null
null
UTF-8
C++
false
false
908
h
IMP_StringQueue.h
#ifndef IMP_STRINGQUEUE_H #define IMP_STRINGQUEUE_H #include <QString> #include "common/IMP_Lock.h" #include <QDebug> #include "common/imp_algo_type.h" #include "IMP_pfr_path.h" #define DEFAULT_MAX_QUEUE_SIZE 15 class IMP_StringQueue { public: IMP_StringQueue(); explicit IMP_StringQueue(int maxQueueSize); ~IMP_StringQueue(); int InitQueue(); int GetQueueLen(); int IsEmpty(); int IsFull(); IMP_PFR_PATH* GetFrameAddr(); int Peek(IMP_PFR_PATH** pString); int EndPeek(); int Remove(); int ClearQueue(); IMP_PFR_PATH* FindMatchAddr(int nFrameNo); private: IMP_CriticalSection m_queueLock; IMP_PFR_PATH *m_pArray; volatile int m_peekFlag; //1:peeking using 0:not used volatile int m_queueHead; volatile int m_queueTail; int m_queueMaxSize; //队列的最大长度 int m_nQueueLen; }; #endif // IMP_STRINGQUEUE_H
0c52de34bad59645d3644cc44b695d5a1f0909f2
b5949f3787035a1f86c04ac8cbb4de1c6dc6eb0e
/ffvii/documents/akao/opcodes/old/sub_80031820.cc
88c4fb486ba650c6d49de24ca143e295b3350c56
[]
no_license
Akari1982/q-gears_reverse
a5f01df536767f810a0ed42f378ecec0cad9139e
eb526894677fc2d3a5d839e157bf607b1c682ed4
refs/heads/master
2022-05-02T22:14:42.555430
2022-04-29T13:57:40
2022-04-29T13:57:40
103,525,167
13
2
null
null
null
null
UTF-8
C++
false
false
586
cc
sub_80031820.cc
// void sub_80031820(a0: <channel structure pointer>, a1: <instrument number>); ch[0x58] = a1; ch[0xE4] = m_InstrumentIndex[a1].attack_offset; ch[0xE8] = m_InstrumentIndex[a1].loop_offset; ch[0xEC] = m_InstrumentIndex[a1].attack_mode; ch[0xF0] = m_InstrumentIndex[a1].sustain_mode; ch[0xF4] = m_InstrumentIndex[a1].release_mode; ch[0xFA] = m_InstrumentIndex[a1].attack_rate; ch[0xFC] = m_InstrumentIndex[a1].decay_rate; ch[0xFE] = m_InstrumentIndex[a1].sustain_level; ch[0x100] = m_InstrumentIndex[a1].sustain_rate; ch[0x102] = m_InstrumentIndex[a1].release_rate; ch[0xE0] |= 0x1ff80;
2504d8bf659ab59caa471c9b367e8ddc7480193e
8f40860fb0db73b655e72d162400feb93b5aa17d
/Algorithm with C++(ubuntu)/05_Link_List/main.cpp
1305f2ffccc4707a1f7689437ff35ce4ce2ad19e
[]
no_license
ChenLiCh/Program_Practice
c851ee14ac1a94ade26748fc20df21873d5a96f7
7a9c94b185b0dfda030d3e2cde8061f2a1ce320f
refs/heads/master
2022-11-06T05:10:01.313717
2020-06-26T12:16:14
2020-06-26T12:16:14
275,125,422
0
0
null
null
null
null
BIG5
C++
false
false
3,034
cpp
main.cpp
#include <iostream> #include <cstdlib> #include "ListNode.cpp" using namespace std; template <class T> void Traverse(ListNode<T> *); int main() { ListNode<int> *head = new ListNode<int>(100); head->SetLink(NULL); ListNode<int> *tail = new ListNode<int>(25); tail->SetLink(NULL); head->SetLink(tail); ListNode<int> *traverse_Node = NULL; // 印出初始link list cout << "初始 link list" << endl; traverse_Node = head; Traverse(traverse_Node); // 在 head 位置插入 cout << endl << "在 head 位置插入" << endl; ListNode<int> *new_Head = new ListNode<int>(1); new_Head->SetLink(head); head = new_Head; Traverse(head); // 在 tail 位置插入 cout << endl << "在 tail 位置插入" << endl; ListNode<int> *new_Tail = new ListNode<int>(999); tail->SetLink(new_Tail); tail = new_Tail; Traverse(head); // 在 head 和 tail 位置之外的地方插入 cout << endl << "在 head 和 tail 位置之外的地方插入" << endl; int num = 25; traverse_Node = head; while(traverse_Node->GetLink() != NULL) { if (traverse_Node->GetData() == num) break; else traverse_Node = traverse_Node->GetLink(); } ListNode<int> *new_Node = new ListNode<int>(60); new_Node->SetLink(NULL); new_Node->SetLink(traverse_Node->GetLink()); traverse_Node->SetLink(new_Node); Traverse(head); // 在 head 位置刪除 cout << endl <<"刪除 head" << endl; ListNode<int> *delete_Head = head; head = head->GetLink(); delete delete_Head; Traverse(head); // 在 tail 位置刪除 cout << endl <<"刪除 tail" << endl; ListNode<int> *delete_Tail = tail; traverse_Node = head; while(traverse_Node->GetLink() != delete_Tail) { traverse_Node = traverse_Node->GetLink(); } tail = traverse_Node; tail->SetLink(NULL); delete delete_Tail; Traverse(head); // 在 head 和 tail 位置之外的地方刪除 cout << endl <<"在 head 和 tail 位置之外的地方刪除" << endl; traverse_Node = head->GetLink(); ListNode<int> *traverse_Node_previous = head; while (traverse_Node->GetData() != num && traverse_Node->GetLink() != NULL) { traverse_Node = traverse_Node->GetLink(); traverse_Node_previous = traverse_Node_previous->GetLink(); } ListNode<int> *delete_Node = traverse_Node; traverse_Node_previous->SetLink(traverse_Node->GetLink()); delete_Node->SetLink(NULL); delete delete_Node; Traverse(head); // 釋放記憶 cout << endl << "釋放記憶體" << endl; delete head; delete tail; delete traverse_Node; delete traverse_Node_previous; system("pause"); return 0; } template <class T> void Traverse(ListNode<T> *traverse_Node) { while (traverse_Node->GetLink() != NULL) { cout << traverse_Node->GetData() << " ---> "; traverse_Node = traverse_Node->GetLink(); } cout << traverse_Node->GetData() << endl; }
87bb4977d0592c783ae809a41fbef4cc4d6263a6
ecbb80aa1397ea3a3b73be88ff64bf99f64c6543
/src/events/event_data_set_actor_possible_moves.hpp
04f25df918a7a52f2348d2a89220afe1e966c52b
[ "MIT" ]
permissive
sfod/quoridor
c402b509759753894c7618a7dd6fbae634c26465
a82b045fcf26ada34b802895f097c955103fbc14
refs/heads/master
2021-01-17T09:00:44.089074
2015-07-28T14:46:13
2015-07-28T14:46:13
13,014,379
0
0
null
null
null
null
UTF-8
C++
false
false
405
hpp
event_data_set_actor_possible_moves.hpp
#pragma once #include "event_data.hpp" class EventData_SetActorPossibleMoves : public EventDataCRTP<EventData_SetActorPossibleMoves> { public: EventData_SetActorPossibleMoves(ActorId actor_id, const std::list<Node> &possible_moves); ActorId actor_id() const; const std::list<Node> &possible_moves() const; private: ActorId actor_id_; std::list<Node> possible_moves_; };
15532576c7f6f10b4df76381efd4fe942c22e98b
e0b0f5b49a3732eeb0a7a589e277d8f0bbc355f6
/Tortugalogo2.cpp
472f9454a1d9a7f56a431d069ed5acc22c5c0e90
[]
no_license
Jacobo16/Graficodetortuga
5b8d9781878519d57f60bbe63910fc21b2a830cf
ccc0f9d5894492c750fe1a25d37c7d9198050b16
refs/heads/master
2021-05-07T09:11:20.201411
2017-11-04T18:04:17
2017-11-04T18:04:17
109,514,805
0
0
null
null
null
null
UTF-8
C++
false
false
4,660
cpp
Tortugalogo2.cpp
#include<iostream> int menu(); void mostrartablero(int tablero[][20], int rt); void avanzar(int tablero[][20], int rt, int&dir, bool&pluma, int avance, int&x, int&y); using namespace std; int main () { int coordenadax=0, coordenaday=0, opcion, avance; bool pluma=false; int direccion=2; //Inicio a la tortuga viendo a la derecha. int pizarron[20][20]={0}; do { opcion=menu(); switch(opcion) { case 1: pluma=false; cout<<"La pluma esta arriba!<<"<<endl; cout<<endl; break; case 2: pluma=true; cout<<"La pluma esta abajo!<<"<<endl; cout<<endl; break; case 3: if(direccion!=4) { direccion++; } else { direccion=1; } cout<<"La tortuga giro a la derecha"<<endl; cout<<endl; break; case 4: if(direccion!=1) { direccion--; } else { direccion=4; } cout<<"La tortuga giro a la izquierda"<<endl; cout<<endl; break; case 5: avanzar(pizarron,20,direccion,pluma,5,coordenadax, coordenaday); break; case 6: mostrartablero(pizarron,20); break; case 7: cout<<"La tortuga esta mirando al:"<<direccion<<endl; cout<<endl; case 8: cout<<"Mostrar coordenadas X:"<<coordenadax<<" Y:"<<coordenaday<<endl; cout<<endl; break; } }while(opcion!=9); return 0; } int menu() { cout<<"NOTA: 1.Norte. 2.Este. 3.Sur. 4.Oeste"<<endl; cout<<"1.Pluma arriba"<<endl; cout<<"2.Pluma abajo"<<endl; cout<<"3.Gira a la drecha"<<endl; cout<<"4.Gira a la izquierdda"<<endl; cout<<"5.avanzar"<<endl; cout<<"6.Mostrar tablero"<<endl; cout<<"7.Mostrar hacia donde mira"<<endl; cout<<"8.Mostrar posicion de la tortuga"<<endl; cout<<"8.salir"<<endl; int m; cin>>m; cout<<endl; return m; } void avanzar(int tablero[][20], int rt, int&dir, bool&pluma, int avance, int&x, int&y) { switch(dir) { case 1://Para que la tortuga avance hacia el Norte { int i=0; while(i<=avance) { if(pluma==true) tablero[x][y]=1; else tablero[x][y]=0; if(x>0) x--; i++; } if(x==0) cout<<"Haz llegado al limite"<<endl; cout<<endl; break; } case 2://Para que la tortuga avance hacia el Este { int i=0; while(i<avance) { if(pluma==true) tablero[x][y]=1; else tablero[x][y]=0; if(y<19) y++; i++; } if(y==19) cout<<"Llegaste al limite del pizarron"<<endl; cout<<endl; break; } case 3://Hacia el Sur { int i=0; while(i<avance) { if(pluma==true) tablero[x][y]=1; else tablero[x][y]=0; if(x<19) x++; i++; } if(x==19) cout<<"Llegaste al limite del pizzaron"<<endl; break; } case 4://hacia el Oeste { int i=0; while(i<=avance) { if(pluma==true) tablero[x][y]=1; else tablero[x][y]=0; if(y>0) y--; i++; } if(y==0) cout<<"Llegaste al limite"<<endl; cout<<endl; break; } } } void mostrartablero(int tablero[][20], int rt) { for(int r=0; r<20; r++) { for(int c=0; c<20; c++) { if(1==tablero[r][c]) cout<<"*"; else cout<<" "; } cout<<endl; } cout<<endl; }
6f217b1cd5e22aa3741ff8cebcbab4cd61d3a8ad
b4e16d4a79d53d094c4e4b739dd1c1503e5dd6ac
/ConsoleApplication10/TParser.h
08ceffaab8a518492fd7bc19b07eea352c3f04b1
[]
no_license
VLovchikov/Parser
a2263e720d73a7e9904e6a841a004a8dba2911b0
788cf8538cf3435f4aafb33be808f88c9b692eda
refs/heads/master
2021-09-01T06:07:16.815725
2017-12-25T08:37:26
2017-12-25T08:37:26
115,321,879
0
0
null
null
null
null
UTF-8
C++
false
false
785
h
TParser.h
#pragma once #include "TStack.h" #include <iostream> #include <string> using namespace std; class TParser { char *inf; string post; TStack <char> st_op; TStack <string> st_post; TStack <string> st_st; TStack <string> st_post1; TStack <int> st_ex; public: TParser() { throw "NOTHING TO EXECUTE"; } TParser(char *s) : st_op(100), st_post(100), st_ex(100), st_post1(100), st_st(100) { if (s == 0) throw "NOTHING TO EXECUTE"; else { inf = new char[strlen(s) + 1]; int a = 0; while (s[a] != '\0') { inf[a] = s[a]; a++; } a++; inf[a] = '\0'; } } ~TParser() {}; char *ret() { return inf; } int Priority(char ch); bool IsOperation(char ch); bool IsNumber(char ch); bool Brackets(); string Convertation(); int Calculate(); };
cedb9cebf00c2118f3100904f8f37c2b8c760b09
d70f40efc175ac12edc417e517782c226c776c70
/src/HttpResponse.cpp
89b769e5d2179e866e11aa3ca90ebb438ba75631
[ "Apache-2.0" ]
permissive
bryk/httpico
fa875d70a7b2195674225805325b1159709f7373
a46df99e9faf0b40c3261e42aa2a01c131522a37
refs/heads/master
2021-01-15T11:13:40.949865
2013-04-10T07:36:31
2013-04-10T07:36:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
933
cpp
HttpResponse.cpp
/** ========================================================================================= File name : /httpico/include/HttpResponse.cpp Copyright : Copyright © 2012 Piotr Bryk, Licensed under the Apache License, Version 2.0 ========================================================================================= */ #include "HttpResponse.hpp" #include "unistd.h" #include <sys/socket.h> #include "HttpResponseState.hpp" #include "Utils.hpp" #include "Logger.hpp" namespace Httpico { HttpResponse::HttpResponse(int sockketFd) : state(INTERNAL_SERVER_ERROR), bytesTransferred(0), socketFd_(sockketFd) { } HttpResponse::~HttpResponse() { shutdown(socketFd_, 1); close(socketFd_); } void HttpResponse::writeResponse(const Buffer &buf) { if (write(socketFd_, buf.data(), sizeof(char) * buf.size()) == -1) { Logger::getInstance().dbg("Couldn't send data to the client\n"); } bytesTransferred += buf.size(); } }
198a2d8da4dff73df1267f0921a4b6e1cad9002d
e92af86f33f4bdd457578733074d3c7f6aa7c7fb
/source/GameServer/mt_skill/mt_skill_logic.h
a235deadeff391c0e5453b26332469470729a231
[]
no_license
crazysnail/XServer
aac7e0aaa9da29c74144241e1cc926b8c76d0514
da9f9ae3842e253dcacb2b83b25c5fa56927bdd3
refs/heads/master
2022-03-25T15:52:57.238609
2019-12-04T09:25:33
2019-12-04T09:25:33
224,835,205
0
0
null
null
null
null
GB18030
C++
false
false
4,685
h
mt_skill_logic.h
#ifndef MTONLINE_GAMESERVER_MT_SKILL_LOGIC_H__ #define MTONLINE_GAMESERVER_MT_SKILL_LOGIC_H__ #include "../mt_types.h" #include <map> #include <vector> namespace Mt { class SkillEffect; struct SkillTarget; class MtSkillPositionEffect; class SkillLogicFactory : public boost::serialization::singleton<SkillLogicFactory> { public: const boost::shared_ptr<SkillEffect>& GetLogic(const std::string& name); const boost::shared_ptr<MtSkillPositionEffect>& GetPositionLogic(const std::string& name); private: const boost::shared_ptr<SkillEffect> CreateLogic(const std::string& name); const boost::shared_ptr<MtSkillPositionEffect> CreatePositionLogic(const std::string& name); std::map<std::string, boost::shared_ptr<SkillEffect>> logics_; std::map<std::string, boost::shared_ptr<MtSkillPositionEffect>> position_logics_; }; class SkillEffect : public boost::noncopyable { public: virtual void Execute(MtActorSkill* skill) = 0; }; class DirectDamage : public SkillEffect { public: virtual void Execute(MtActorSkill* skill) override; }; class CureChain : public SkillEffect { public: virtual void Execute(MtActorSkill* skill) override; }; //闪电链 class FlashChain : public DirectDamage { public: virtual void Execute(MtActorSkill* skill) override; }; class DirectCure : public SkillEffect { public: virtual void Execute(MtActorSkill* skill) override; }; /*class Dummy : public SkillExpression { public: virtual void Execute(const boost::shared_ptr<MtActor>& / *attacker* /, const std::vector<boost::shared_ptr<MtActor>>& / *targets* /, const boost::shared_ptr<MtActorSkill>& / *skill* /, zxero::int32& / *skill_normal_damage_for_buff* /, zxero::int32& / *skill_fixed_damage_for_buff* /) override; }; class CreateActor : public SkillExpression { public: virtual void Execute(const boost::shared_ptr<MtActor>& attacker, const std::vector<boost::shared_ptr<MtActor>>& targets, const boost::shared_ptr<MtActorSkill>& skill, zxero::int32& skill_normal_damage_for_buff, zxero::int32& skill_fixed_damage_for_buff) override; }; class CreateTrap : public SkillExpression //释放陷阱 { public: virtual void Execute(const boost::shared_ptr<MtActor>& attacker, const std::vector<boost::shared_ptr<MtActor>>& targets, const boost::shared_ptr<MtActorSkill>& skill, zxero::int32& skill_normal_damage_for_buff, zxero::int32& skill_fixed_damage_for_buff) override; };*/ class MtSkillPositionEffect : public boost::noncopyable { public: virtual bool Execute(MtActorSkill* skill, uint64 elapseTime) = 0; virtual void StartLogic(MtActorSkill* skill) = 0; virtual int32 TimeCost(MtActorSkill* /*skill*/) { return 0; } }; //冲锋 class MtSkillPositionCharge : public MtSkillPositionEffect { public: virtual bool Execute(MtActorSkill* skill, uint64 elapseTime) override; virtual void StartLogic(MtActorSkill* skill) override; virtual int32 TimeCost(MtActorSkill* skill) override; }; //闪现 class MtSkillPositionTeleport : public MtSkillPositionEffect { public: virtual bool Execute(MtActorSkill* skill, uint64 elapseTime) override; virtual void StartLogic(MtActorSkill* skill) override; }; //抓取 class MtSkillPositionCapture : public MtSkillPositionEffect { public: virtual bool Execute(MtActorSkill* skill, uint64 elapseTime) override; virtual void StartLogic(MtActorSkill* skill) override; }; //击飞 /*class MtSkillPositionHitOff : public MtSkillPositionEffect { public: virtual bool Execute(const boost::shared_ptr<MtActor>& attacker, const std::vector<MtActor*>& targets, const boost::shared_ptr<MtActorSkill>& skill, zxero::uint64 elapseTime) override { } virtual void StartLogic(const boost::shared_ptr<MtActor>& attacker, const std::vector<MtActor*>& targets, const boost::shared_ptr<MtActorSkill>& skill) override { std::vector<boost::shared_ptr<Packet::SkillPositionLogic>> msgs; msgs.reserve(targets.size()); for (auto& target : targets) { auto msg = boost::make_shared<Packet::SkillPositionLogic>(); msgs.push_back(msg); msg->set_type(Packet::SkillPositionLogicType::CAPTURE_LOGIC); msg->set_source_guid(target->Guid()); msg->set_target_guid(attacker->Guid()); msg->set_time_stamp(attacker->BattleGround()->TimeStamp()); auto skill_info = msg->mutable_skill_info(); skill_info->set_skill_id(skill->DbInfo()->skill_id()); skill_info->set_skill_level(skill->DbInfo()->skill_level()); } for (auto& message : msgs) { attacker->BattleGround()->BroadCastMessage(*message); } } };*/ } #endif // MTONLINE_GAMESERVER_MT_SKILL_LOGIC_H__
f049504dbb10789bdb3282583309e430cc370e1e
2d033ef3874c4ba692b703bdea7f3c5f9740a198
/STM32/libraries/STM32DAC/examples/SinGenerate.ino/SinGenerate.ino.ino
3657311d61dcc530d569824edc396303d782f09c
[]
no_license
tormodvolden/STM32GENERIC
58945685815ea8c00b309459ba88ffeb211e4d37
d869a6b07b95353c3c1d4beed640bf9dd05b3bb6
refs/heads/master
2020-04-04T02:35:29.514059
2018-10-25T05:40:37
2018-10-25T05:40:37
155,691,405
1
0
null
null
null
null
UTF-8
C++
false
false
869
ino
SinGenerate.ino.ino
/* I2S sine wave for STM32 DAC PA4_DACOUT and PA5_DACOUT are predefined instances of class STM32DAC. August 2018 ChrisMicro uses the DAC driver from huaweiwx */ #include "STM32DAC.h" #define SAMPLINGFREQUENCY 44100 #define NUMBEROFSAMPLES SAMPLINGFREQUENCY * 1 // 1 seconds #define DAC_RESOLUTION 4095 // DAC resoltion is 12 bit #define DAC_MAX_AMPLITUDE DAC_RESOLUTION/2/2; int16_t Buffer[NUMBEROFSAMPLES]; void setup() { PA4_DACOUT.Init(); for (int n = 0; n < NUMBEROFSAMPLES; n++) { const float frequency = 440; const float amplitude = DAC_MAX_AMPLITUDE; Buffer[n] = DAC_RESOLUTION/2+( sin( 2 * PI * frequency / SAMPLINGFREQUENCY * n )) * amplitude; } } void loop() { for (int n = 0; n < NUMBEROFSAMPLES; n++) { delayMicroseconds(1000000/SAMPLINGFREQUENCY-1); PA4_DACOUT = Buffer[n]; } delay(3000); }
f81c4b1aa160289d593e3920daff204bba7dea4c
7023e0bf293413d0b5a1ba97d25bb7d023a42df8
/Accelerated_C++/5.iterator/list_sort.cpp
3a3a4b3e3321442704da983931b57f08748240c6
[]
no_license
hkhl/cplusplus
dcbcb0f4bec7d3eebfd58ecc17dc9d6f4c545cf6
9c0c487b26c2b773d5308876af4ca03e8b3efba4
refs/heads/master
2020-03-08T13:06:54.914343
2018-07-04T13:19:42
2018-07-04T13:19:42
128,149,340
0
0
null
null
null
null
UTF-8
C++
false
false
1,442
cpp
list_sort.cpp
/************************************************************************* > File Name: list_sort.cpp > Author: wang > Mail: dhkhl235@gmail.com > Created Time: 2018年04月08日 星期日 22时40分35秒 ************************************************************************/ #include <iostream> #include <list> using namespace std; //list 不支持索引 bool compare(const string &a, const string &b) { return a < b; } int main() { /* list<int> ls; ls.push_back(5); ls.push_back(3); ls.push_back(2); ls.push_back(1); ls.push_back(4); //cout << ls[0] << endl; error //list 同 vector 排序不同 //sort(vector.begin(), vector.end()); ls.sort(); //排序数字. 不需要参数 list<int>::iterator iter = ls.begin(); for(; iter != ls.end(); iter++) { cout << *iter << endl; } */ list<string> lstring; lstring.push_back("dfg34d"); lstring.push_back("asdasd"); lstring.push_back("zxcassd"); lstring.push_back("sdadasd"); //cout << ls[0] << endl; error //list 同 vector 排序不同 //sort(vector.begin(), vector.end()); lstring.sort(compare); //排序数字. 不需要参数 ??compare 对否 lstring.sort(); //不需要compare也可以排序 list<string>::iterator siter = lstring.begin(); for(; siter != lstring.end(); siter++) { cout << *siter << endl; } return 0; }
42cd94518cabd5b65dc057a1b9ceacb1764a2137
46129f1b8ec08598c922f6a256c4a41e087901f8
/pcl_recorder/src/mainROS2.cpp
93c2a286e23dc7554a846000ce7bd3a7b920a4d1
[ "MIT" ]
permissive
carla-simulator/ros-bridge
bb5515d354a2b0c583ab1d171cef90f750162f28
e9063d97ff5a724f76adbb1b852dc71da1dcfeec
refs/heads/master
2023-07-19T19:11:10.707619
2022-07-22T07:37:00
2022-07-22T07:37:00
159,830,279
448
376
MIT
2023-09-06T18:19:27
2018-11-30T13:51:34
Python
UTF-8
C++
false
false
485
cpp
mainROS2.cpp
/* * Copyright (c) 2019 Intel Corporation * * This work is licensed under the terms of the MIT license. * For a copy, see <https://opensource.org/licenses/MIT>. */ #include "PclRecorderROS2.h" #include "rclcpp/rclcpp.hpp" int main(int argc, char** argv) { rclcpp::init(argc, argv); rclcpp::executors::MultiThreadedExecutor executor; auto recorder = std::make_shared<PclRecorderROS2>(); executor.add_node(recorder); executor.spin(); rclcpp::shutdown(); return 0; }
9d93a9a514f234205756f8f90124a72dfd8c6ee8
4a014f4b660fa1ed2efbb6a3b493cd9163f027a6
/Source/Gunslingers/World/UsableActor.cpp
5876f2a4f62f0bd5fe061ab1a92233beb64fde5f
[]
no_license
Rasputin170/Gunslingers
26d3d40e275a840fe6009272fdbd6f7213578b38
a8269d45b3bca4c718b7f794a95e37002f34faa1
refs/heads/master
2021-01-17T07:56:40.727017
2017-03-11T18:57:16
2017-03-11T18:57:16
83,820,666
1
1
null
null
null
null
UTF-8
C++
false
false
702
cpp
UsableActor.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Gunslingers.h" #include "UsableActor.h" AUsableActor::AUsableActor(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { MeshComp = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh")); RootComponent = MeshComp; } void AUsableActor::OnUsed(APawn* InstigatorPawn) { // Nothing to do here... } void AUsableActor::OnBeginFocus() { // Used by custom PostProcess to render outlines MeshComp->SetRenderCustomDepth(true); } void AUsableActor::OnEndFocus() { // Used by custom PostProcess to render outlines MeshComp->SetRenderCustomDepth(false); }
c886fb92ce1560c04091b17ee0ccb47c041aebee
cb60852d13eb21fab463bc1e940d5aaff7503a13
/Week_4 Basic data structures/min_queue.cpp
52408a345b7ca748de0baebe1013e83ec4b91555
[]
no_license
i-dubits/ITMO-Algorithms-course
e52f6d4fb8782615a5fbbc23da6272a3d38802e7
568fd3b45548c8e38e5bb0ce73983cfcb94375c0
refs/heads/main
2023-03-17T05:29:52.642557
2021-03-10T17:33:42
2021-03-10T17:33:42
325,635,471
0
0
null
null
null
null
UTF-8
C++
false
false
1,870
cpp
min_queue.cpp
// Ilya Dubitskiy // Week_4_task_4_ver_1 #include "stdafx.h" #include <iostream> #include <fstream> #include <time.h> #include <array> #include <string> #include <utility> #include <stack> //#include "edx-io.hpp" //using namespace std; long min(std::stack<std::pair<long, long>>& s1, std::stack<std::pair<long, long>>& s2) { long minimum = 0; if (s1.empty() || s2.empty()) minimum = s1.empty() ? s2.top().second : s1.top().second; else minimum = std::min(s1.top().second, s2.top().second); return minimum; } void push_el(std::stack<std::pair<long, long>>& s1, long new_element) { long minimum = s1.empty() ? new_element : std::min(new_element, s1.top().second); s1.push({ new_element, minimum }); } void pop_el(std::stack<std::pair<long, long>>& s1, std::stack<std::pair<long, long>>& s2) { if (s2.empty()) { while (!s1.empty()) { long element = s1.top().first; s1.pop(); long minimum = s2.empty() ? element : std::min(element, s2.top().second); s2.push({ element, minimum }); } } long remove_element = s2.top().first; s2.pop(); } int _tmain(int argc, _TCHAR* argv[]) { std::ifstream cin("input.txt"); std::ofstream cout("output.txt"); std::cin.rdbuf(cin.rdbuf()); std::cout.rdbuf(cout.rdbuf()); clock_t t; t = clock(); long number_of_oper = 0; std::cin >> number_of_oper; std::stack<std::pair<long, long>> s1, s2; std::string curr_str; char curr_oper = 0; long curr_number = 0; while (number_of_oper > 0) { std::cin >> curr_oper; if (curr_oper == '+') { std::cin >> curr_number; push_el(s1, curr_number); } else if (curr_oper == '-') { pop_el(s1, s2); } else if (curr_oper == '?') { std::cout << min(s1, s2) << "\n"; } number_of_oper--; } return 0; }
599c323537dcb8b8177fed9d9aca9007c526272f
63e7cbad2dae483d93572c27b658a395057a4b31
/src/SourceTransformTranslate.h
dfbfe73a79ab30a02f897977d9d8b462fb99f721
[]
no_license
debonet/Congealing
13c9f1100531eb9491230c7652aba17a1c589a6c
1a90ac78efb8e5dc30cc72e26c61ea6c3042eee4
refs/heads/master
2016-09-09T17:56:44.813853
2012-05-01T02:21:32
2012-05-01T02:21:32
1,536,220
1
2
null
null
null
null
UTF-8
C++
false
false
4,260
h
SourceTransformTranslate.h
// $Id$ #ifndef __SOURCETRANSFORMTRANSLATE_H__ #define __SOURCETRANSFORMTRANSLATE_H__ #include "SourceGenerics.h" #include <math.h> //============================================================================ //============================================================================ template<class DATA, int DIMENSIONALITY, class PRECISION, class SOURCE> class SourceTransformTranslateBaseOf : public SourceTransformOf<DATA, DIMENSIONALITY, PRECISION, SOURCE> { protected: typedef PointOf<DIMENSIONALITY, Real> POINT; POINT m_dpt; public: SourceTransformTranslateBaseOf() : SourceTransformOf<DATA, DIMENSIONALITY, PRECISION, SOURCE> () , m_dpt(0.) { } virtual String Describe() const { return ( _LINE + SerializationId() + LINE_ + (_INDENT + "translation by: " + m_dpt.Describe() + LINE_) + this->DescribeCommon() ); } virtual void RegisterParameters(RegistryOfParameters& reg) { RegisterPointAsParameter(reg,m_dpt); } POINT& Translate() { return m_dpt; } const POINT& Translate() const { return m_dpt; } static String SerializationId() { return String("SourceTransformTranslate(") + DIMENSIONALITY +"D)"; } void SerializeSelf(Stream &st) const { ::Serialize(st,m_dpt); } void DeserializeSelf(Stream &st) { ::Deserialize(st,m_dpt); } }; //============================================================================ //============================================================================ template<class DATA, int DIMENSIONALITY, class PRECISION, class SOURCE> class SourceTransformTranslateOf : public SourceTransformTranslateBaseOf<DATA, DIMENSIONALITY, PRECISION, SOURCE> { SourceTransformTranslateOf() : SourceTransformTranslateBaseOf<DATA, DIMENSIONALITY, PRECISION, SOURCE> () {} SourceTransformTranslateOf(SOURCE* psource) : SourceTransformTranslateBaseOf<DATA, DIMENSIONALITY, PRECISION, SOURCE> (psource) {} // TODO }; //============================================================================ //============================================================================ template<class DATA, class PRECISION, class SOURCE> class SourceTransformTranslateOf<DATA,2,PRECISION,SOURCE> : public SourceTransformTranslateBaseOf<DATA, 2, PRECISION, SOURCE> { public: SOURCE_ACTUALS_2D; inline void Get(DATA& dataOut, const PRECISION &rX, const PRECISION &rY) const { ::Get( *(this->m_psource), dataOut, (rX-this->m_dpt.X()*this->m_ptSize.X()), (rY-this->m_dpt.Y()*this->m_ptSize.Y()) ); } inline void Set(const PRECISION &rX, const PRECISION &rY, const DATA& data) { ::Set( *(this->m_psource), (rX-this->m_dpt.X()*this->m_ptSize.X()), (rY-this->m_dpt.Y()*this->m_ptSize.Y()), data ); } }; //============================================================================ // 3d //============================================================================ //============================================================================ //============================================================================ template<class DATA, class PRECISION, class SOURCE> class SourceTransformTranslateOf<DATA,3,PRECISION,SOURCE> : public SourceTransformTranslateBaseOf<DATA, 3, PRECISION, SOURCE> { public: SOURCE_ACTUALS_3D; inline void Get(DATA& dataOut, const PRECISION &rX, const PRECISION &rY, const PRECISION &rZ) const { ::Get( *(this->m_psource), dataOut, (rX-this->m_dpt.X()*this->m_ptSize.X()), (rY-this->m_dpt.Y()*this->m_ptSize.Y()), (rZ-this->m_dpt.Z()*this->m_ptSize.Z()) ); } inline void Set(const PRECISION &rX, const PRECISION &rY, const PRECISION &rZ, const DATA& data) { ::Set( *(this->m_psource), (rX-this->m_dpt.X()*this->m_ptSize.X()), (rY-this->m_dpt.Y()*this->m_ptSize.Y()), (rZ-this->m_dpt.Z()*this->m_ptSize.Z()), data ); } }; //============================================================================ // translate assistant //============================================================================ MAKE_ASSISTANT( Translate, SourceTransformTranslateOf, { psrcOut->Translate()=pt; }, const PointOf<TypeOfDimensionality(SOURCE) COMMA TypeOfPrecision(SOURCE)> &pt, ); #endif // __SOURCETRANSFORMTRANSLATE_H__
4b1c6d179d0774ce10293136c34162f6e4a63ddf
7e089d39e23b1f55329e9661f3a4ba4c5a23afbd
/src/shared/state/StaticElements.cpp
1b9ef9273cfbbeb15dbbe701a37936e47ecc50ce
[]
no_license
Lastv25/rivieremonjoux
c2c6c4c40565b4fc43b2d2833349599ae82fcf66
01f71d12750761be050b506ba65d529ef54a9cde
refs/heads/master
2021-10-11T15:36:04.042571
2019-01-18T13:48:08
2019-01-18T13:48:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
739
cpp
StaticElements.cpp
#include "StaticElements.h" #include <iostream> using namespace std; using namespace state; //Constructor StaticElements::StaticElements(bool building) : Element(staticElement){ this->building = building; } //Destructor StaticElements::~StaticElements (){ } bool StaticElements::isStatic(){ return this->staticElement; } bool StaticElements::isBuilding(){ return this->building; } // Setters and Getters bool StaticElements::getBuilding() const{ return this->building; } void StaticElements::setBuilding(bool building){ this->building=building; } bool StaticElements::getStaticElement() const{ return this->staticElement; } void StaticElements::setStaticElement(bool staticElement){ this->staticElement=staticElement; }
88c9bb5bdc9308be2db1f57d1854d55acbd6e107
397de467115775da05ae98426bca4583711df0c6
/Visual C++ Example/第17章 多媒体开发/综合实例——基于音、视频传输的远程诊断系统/VideoVoiceTrans/PlaySound.h
c59300a3832499c46be804c6709ee100e7e16d57
[ "Unlicense" ]
permissive
hyller/GladiatorLibrary
d6f6dfae0026464950f67fd97877baeeb40b6c9a
f6b0b1576afae27ecd042055db5f655ccd41710b
refs/heads/master
2023-04-27T11:26:09.118078
2022-03-31T08:22:16
2022-03-31T08:22:16
39,110,689
7
6
Unlicense
2023-04-21T20:51:57
2015-07-15T02:00:05
C
UTF-8
C++
false
false
1,905
h
PlaySound.h
// PlaySound1.h: interface for the PlaySound1 class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_PlaySound_H__676E24A1_615E_11D6_889A_000B2B0F84B6__INCLUDED_) #define AFX_PlaySound_H__676E24A1_615E_11D6_889A_000B2B0F84B6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define WM_PLAYSOUND_STARTPLAYING WM_USER+600 #define WM_PLAYSOUND_STOPPLAYING WM_USER+601 #define WM_PLAYSOUND_PLAYBLOCK WM_USER+602 #define WM_PLAYSOUND_ENDTHREAD WM_USER+603 #define SOUNDSAMPLES 1000 #define PLAYBUFFER 600 #define SAMPLEPSEC 8000 /* #ifndef WAVE_FORMAT_GSM610 #define WAVE_FORMAT_GSM610 (0x0031) #endif */ #include<afxmt.h> #include<mmsystem.h> class PlaySound1 : public CWinThread { DECLARE_DYNCREATE(PlaySound1) public: /* For GSM WAVE FORMAT uncomment this..and comment next line... struct wave { WAVEFORMATEX wfx; WORD wSamplesPerBlock; }m_WaveFormatEx; */ WAVEFORMATEX m_WaveFormatEx; BOOL Playing; HWAVEOUT m_hPlay; CStdioFile log; CDialog *dlg; PlaySound1(); PlaySound1(CDialog *dlg); virtual ~PlaySound1(); BOOL InitInstance(); int ExitInstance(); void displayError(int code,char []); void displayHeader(LPWAVEHDR lphdr); LPWAVEHDR CreateWaveHeader(CString mesg); void ProcessSoundData(short int *sound, DWORD dwSamples); void GetDevProperty(); afx_msg LRESULT OnStartPlaying(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnStopPlaying(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnEndPlaySoundData(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnWriteSoundData(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnEndThread(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() }; #endif // !defined(AFX_PlaySound_H__676E24A1_615E_11D6_889A_000B2B0F84B6__INCLUDED_)
b21ac0be72329793d060481e4b343a40ff76e291
15e6d3a00cfcc775c38d516e9729a6535ad9bd0b
/BitmapARGB.h
e68864e32bee28047d596e4befffcff7cd192802
[]
no_license
Pete87Phil/distancefieldapp
92b132430cd6d86fa9e66c4969d6f68cdcbda38d
c26ffc1fba79a86090f330c2c71846e8a574703d
refs/heads/master
2017-06-01T15:10:58.583541
2009-01-04T19:54:13
2009-01-04T19:54:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
579
h
BitmapARGB.h
#pragma once #include <windows.h> // HDC #include "Vector2.h" // CVector2 #include "ColorARGB.h" // CColorARGB #include "tga.h" // PIX_LoadTGA32 #include "RBBitmap.h" // CRBBitmap<> class CBitmapARGB : public CRBBitmap<CColorARGB> { public: CBitmapARGB( const uint32 dwWidth=0, const uint32 dwHeight=0 ); void Blit( HDC hdc, const uint32 dwX, const uint32 dwY ) const; //!< clipped void SetPixel( const CVector2I vPos, const CColorARGB value ); CColorARGB GetPixel( const CVector2I vPos ) const; bool LoadTGA( const char *szFilename ); };
7c8fd9902ccd16be7083dc1a6e11e5969d451e01
ffdc77394c5b5532b243cf3c33bd584cbdc65cb7
/mindspore/lite/src/litert/delegate/npu/npu_delegate.h
17b43a348c5aee6fc06732bc171c49cf9bab0548
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "MPL-1.0", "OpenSSL", "LGPL-3.0-only", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause-Open-MPI", "MIT", "MPL-2.0-no-copyleft-exception", "NTP", "BSD-3-Clause", "GPL-1.0-or-later", "0BSD", "MPL-2.0", "LicenseRef-scancode-f...
permissive
mindspore-ai/mindspore
ca7d5bb51a3451c2705ff2e583a740589d80393b
54acb15d435533c815ee1bd9f6dc0b56b4d4cf83
refs/heads/master
2023-07-29T09:17:11.051569
2023-07-17T13:14:15
2023-07-17T13:14:15
239,714,835
4,178
768
Apache-2.0
2023-07-26T22:31:11
2020-02-11T08:43:48
C++
UTF-8
C++
false
false
1,961
h
npu_delegate.h
/** * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_NPU_DELEGATE_H_ #define MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_NPU_DELEGATE_H_ #include <vector> #include <map> #include <string> #include "include/api/delegate.h" #include "src/litert/delegate/npu/npu_manager.h" #include "src/litert/delegate/npu/pass/npu_pass_manager.h" #include "src/litert/delegate/npu/op/npu_op.h" #include "src/litert/inner_context.h" namespace mindspore::lite { class NPUDelegate : public Delegate { public: explicit NPUDelegate(NpuDeviceInfo device_info, const std::string &cache_dir) : Delegate() { frequency_ = device_info.frequency_; cache_dir_ = cache_dir; } ~NPUDelegate() override; Status Init() override; Status Build(DelegateModel<schema::Primitive> *model) override; protected: NPUOp *GetOP(kernel::Kernel *kernel, const schema::Primitive *primitive); kernel::Kernel *CreateNPUGraph(const std::vector<NPUOp *> &ops, DelegateModel<schema::Primitive> *model, KernelIter from, KernelIter end); Status AddPasses(); NPUManager *npu_manager_ = nullptr; NPUPassManager *pass_manager_ = nullptr; std::map<schema::PrimitiveType, NPUGetOp> op_func_lists_; int frequency_ = 0; std::string cache_dir_{}; }; } // namespace mindspore::lite #endif // MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_DELEGATE_H_
6f7059fc0d947d6c5ec397fe34f7e73e15a8958b
5cad8d9664c8316cce7bc57128ca4b378a93998a
/CI/rule/pclint/pclint_include/include_linux/c++/4.8.2/gnu/java/awt/font/autofit/LatinMetrics.h
18a21db4bc3bf40d5e653addfd9f10b2fb76ccab
[ "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only", "GPL-3.0-only", "curl", "Zlib", "LicenseRef-scancode-warranty-disclaimer", "OpenSSL", "GPL-1.0-or-later", "MIT", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "BSD-3-...
permissive
huaweicloud/huaweicloud-sdk-c-obs
0c60d61e16de5c0d8d3c0abc9446b5269e7462d4
fcd0bf67f209cc96cf73197e9c0df143b1d097c4
refs/heads/master
2023-09-05T11:42:28.709499
2023-08-05T08:52:56
2023-08-05T08:52:56
163,231,391
41
21
Apache-2.0
2023-06-28T07:18:06
2018-12-27T01:15:05
C
UTF-8
C++
false
false
1,123
h
LatinMetrics.h
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef __gnu_java_awt_font_autofit_LatinMetrics__ #define __gnu_java_awt_font_autofit_LatinMetrics__ #pragma interface #include <gnu/java/awt/font/autofit/ScriptMetrics.h> #include <gcj/array.h> extern "Java" { namespace gnu { namespace java { namespace awt { namespace font { namespace autofit { class LatinAxis; class LatinMetrics; } namespace opentype { class OpenTypeFont; } } } } } } class gnu::java::awt::font::autofit::LatinMetrics : public ::gnu::java::awt::font::autofit::ScriptMetrics { public: // actually package-private LatinMetrics(); LatinMetrics(::gnu::java::awt::font::opentype::OpenTypeFont *); JArray< ::gnu::java::awt::font::autofit::LatinAxis * > * __attribute__((aligned(__alignof__( ::gnu::java::awt::font::autofit::ScriptMetrics)))) axis; jint unitsPerEm; public: static ::java::lang::Class class$; }; #endif // __gnu_java_awt_font_autofit_LatinMetrics__
8053d8975dee58424313b592cf99435749d61200
a72d01c6c8dfdd687e9cc9b9bf4f4959e9d74f5d
/ARDEN/orlando/source/hooks.cpp
a35953412ff8e5346842838a12f00f55db177677
[]
no_license
erinmaus/autonomaus
8a3619f8380eae451dc40ba507b46661c5bc8247
9653f27f6ef0bbe14371a7077744a1fd8b97ae8d
refs/heads/master
2022-10-01T01:24:23.028210
2018-05-09T21:59:26
2020-06-10T21:08:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
39,884
cpp
hooks.cpp
// This file is a part of ARDEN. It was generated during the build process. // // ARDEN is a component of [hdt], created by [bk]door.maus. #include <cstddef> #include <cstdio> #include <cstdlib> #include <windows.h> #include <wingdi.h> #include <GL/gl.h> #include "orlando/deps/MinHook.h" #include "touchstone/platform/windows.h" bool install_manual_hooks(); extern "C" void __stdcall jaqBindTexture(GLenum target, GLuint texture); extern "C" void __stdcall jaqBlendFunc(GLenum sfactor, GLenum dfactor); extern "C" void __stdcall jaqClear(GLbitfield mask); extern "C" void __stdcall jaqClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); extern "C" void __stdcall jaqClearDepth(GLdouble depth); extern "C" void __stdcall jaqClearStencil(GLint s); extern "C" void __stdcall jaqColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); extern "C" void __stdcall jaqCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); extern "C" void __stdcall jaqCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); extern "C" void __stdcall jaqCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); extern "C" void __stdcall jaqCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); extern "C" void __stdcall jaqCullFace(GLenum mode); extern "C" void __stdcall jaqDeleteTextures(GLsizei n, const GLuint * textures); extern "C" void __stdcall jaqDepthFunc(GLenum func); extern "C" void __stdcall jaqDepthMask(GLboolean flag); extern "C" void __stdcall jaqDepthRange(GLdouble near, GLdouble far); extern "C" void __stdcall jaqDisable(GLenum cap); extern "C" void __stdcall jaqDrawArrays(GLenum mode, GLint first, GLsizei count); extern "C" void __stdcall jaqDrawBuffer(GLenum buf); extern "C" void __stdcall jaqDrawElements(GLenum mode, GLsizei count, GLenum type, const void * indices); extern "C" void __stdcall jaqEnable(GLenum cap); extern "C" void __stdcall jaqFinish(); extern "C" void __stdcall jaqFlush(); extern "C" void __stdcall jaqFrontFace(GLenum mode); extern "C" void __stdcall jaqGenTextures(GLsizei n, GLuint * textures); extern "C" void __stdcall jaqGetBooleanv(GLenum pname, GLboolean * data); extern "C" void __stdcall jaqGetDoublev(GLenum pname, GLdouble * data); extern "C" GLenum __stdcall jaqGetError(); extern "C" void __stdcall jaqGetFloatv(GLenum pname, GLfloat * data); extern "C" void __stdcall jaqGetIntegerv(GLenum pname, GLint * data); extern "C" const GLubyte * __stdcall jaqGetString(GLenum name); extern "C" void __stdcall jaqGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); extern "C" void __stdcall jaqGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params); extern "C" void __stdcall jaqGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params); extern "C" void __stdcall jaqGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); extern "C" void __stdcall jaqGetTexParameteriv(GLenum target, GLenum pname, GLint * params); extern "C" void __stdcall jaqHint(GLenum target, GLenum mode); extern "C" GLboolean __stdcall jaqIsEnabled(GLenum cap); extern "C" GLboolean __stdcall jaqIsTexture(GLuint texture); extern "C" void __stdcall jaqLineWidth(GLfloat width); extern "C" void __stdcall jaqLogicOp(GLenum opcode); extern "C" void __stdcall jaqPixelStoref(GLenum pname, GLfloat param); extern "C" void __stdcall jaqPixelStorei(GLenum pname, GLint param); extern "C" void __stdcall jaqPointSize(GLfloat size); extern "C" void __stdcall jaqPolygonMode(GLenum face, GLenum mode); extern "C" void __stdcall jaqPolygonOffset(GLfloat factor, GLfloat units); extern "C" void __stdcall jaqReadBuffer(GLenum src); extern "C" void __stdcall jaqReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); extern "C" void __stdcall jaqScissor(GLint x, GLint y, GLsizei width, GLsizei height); extern "C" void __stdcall jaqStencilFunc(GLenum func, GLint ref, GLuint mask); extern "C" void __stdcall jaqStencilMask(GLuint mask); extern "C" void __stdcall jaqStencilOp(GLenum fail, GLenum zfail, GLenum zpass); extern "C" void __stdcall jaqTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); extern "C" void __stdcall jaqTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); extern "C" void __stdcall jaqTexParameterf(GLenum target, GLenum pname, GLfloat param); extern "C" void __stdcall jaqTexParameterfv(GLenum target, GLenum pname, const GLfloat * params); extern "C" void __stdcall jaqTexParameteri(GLenum target, GLenum pname, GLint param); extern "C" void __stdcall jaqTexParameteriv(GLenum target, GLenum pname, const GLint * params); extern "C" void __stdcall jaqTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); extern "C" void __stdcall jaqTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); extern "C" void __stdcall jaqViewport(GLint x, GLint y, GLsizei width, GLsizei height); extern "C" BOOL __stdcall jaqCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask); extern "C" HGLRC __stdcall jaqCreateContext(HDC hdc); extern "C" HGLRC __stdcall jaqCreateLayerContext(HDC hdc, int iLayerPlane); extern "C" BOOL __stdcall jaqDeleteContext(HGLRC hglrc); extern "C" BOOL __stdcall jaqDescribeLayerPlane(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd); extern "C" HGLRC __stdcall jaqGetCurrentContext(); extern "C" HDC __stdcall jaqGetCurrentDC(); extern "C" int __stdcall jaqGetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF* pcr); extern "C" BOOL __stdcall jaqMakeCurrent(HDC hdc, HGLRC hglrc); extern "C" BOOL __stdcall jaqRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize); extern "C" int __stdcall jaqSetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF* pcr); extern "C" BOOL __stdcall jaqShareLists(HGLRC hglrc1, HGLRC hglrc2); extern "C" BOOL __stdcall jaqSwapLayerBuffers(HDC hdc, UINT fuPlanes); extern "C" BOOL __stdcall jaqUseFontBitmapsA(HDC hdc, DWORD first, DWORD count, DWORD base); extern "C" BOOL __stdcall jaqUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD base); extern "C" BOOL __stdcall jaqUseFontOutlines(HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); static bool install_hooks() { if (MH_Initialize() != MH_OK) { std::fprintf(stderr, "Couldn't initial hook library.\n"); return false; } static LPVOID _BindTexture; if (MH_CreateHook(&glBindTexture, &jaqBindTexture, &_BindTexture) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glBindTexture"); return false; } else { touchstone::windows::register_hook("glBindTexture", _BindTexture); } if (MH_EnableHook(&glBindTexture) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glBindTexture"); return false; } static LPVOID _BlendFunc; if (MH_CreateHook(&glBlendFunc, &jaqBlendFunc, &_BlendFunc) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glBlendFunc"); return false; } else { touchstone::windows::register_hook("glBlendFunc", _BlendFunc); } if (MH_EnableHook(&glBlendFunc) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glBlendFunc"); return false; } static LPVOID _Clear; if (MH_CreateHook(&glClear, &jaqClear, &_Clear) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glClear"); return false; } else { touchstone::windows::register_hook("glClear", _Clear); } if (MH_EnableHook(&glClear) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glClear"); return false; } static LPVOID _ClearColor; if (MH_CreateHook(&glClearColor, &jaqClearColor, &_ClearColor) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glClearColor"); return false; } else { touchstone::windows::register_hook("glClearColor", _ClearColor); } if (MH_EnableHook(&glClearColor) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glClearColor"); return false; } static LPVOID _ClearDepth; if (MH_CreateHook(&glClearDepth, &jaqClearDepth, &_ClearDepth) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glClearDepth"); return false; } else { touchstone::windows::register_hook("glClearDepth", _ClearDepth); } if (MH_EnableHook(&glClearDepth) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glClearDepth"); return false; } static LPVOID _ClearStencil; if (MH_CreateHook(&glClearStencil, &jaqClearStencil, &_ClearStencil) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glClearStencil"); return false; } else { touchstone::windows::register_hook("glClearStencil", _ClearStencil); } if (MH_EnableHook(&glClearStencil) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glClearStencil"); return false; } static LPVOID _ColorMask; if (MH_CreateHook(&glColorMask, &jaqColorMask, &_ColorMask) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glColorMask"); return false; } else { touchstone::windows::register_hook("glColorMask", _ColorMask); } if (MH_EnableHook(&glColorMask) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glColorMask"); return false; } static LPVOID _CopyTexImage1D; if (MH_CreateHook(&glCopyTexImage1D, &jaqCopyTexImage1D, &_CopyTexImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glCopyTexImage1D"); return false; } else { touchstone::windows::register_hook("glCopyTexImage1D", _CopyTexImage1D); } if (MH_EnableHook(&glCopyTexImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glCopyTexImage1D"); return false; } static LPVOID _CopyTexImage2D; if (MH_CreateHook(&glCopyTexImage2D, &jaqCopyTexImage2D, &_CopyTexImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glCopyTexImage2D"); return false; } else { touchstone::windows::register_hook("glCopyTexImage2D", _CopyTexImage2D); } if (MH_EnableHook(&glCopyTexImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glCopyTexImage2D"); return false; } static LPVOID _CopyTexSubImage1D; if (MH_CreateHook(&glCopyTexSubImage1D, &jaqCopyTexSubImage1D, &_CopyTexSubImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glCopyTexSubImage1D"); return false; } else { touchstone::windows::register_hook("glCopyTexSubImage1D", _CopyTexSubImage1D); } if (MH_EnableHook(&glCopyTexSubImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glCopyTexSubImage1D"); return false; } static LPVOID _CopyTexSubImage2D; if (MH_CreateHook(&glCopyTexSubImage2D, &jaqCopyTexSubImage2D, &_CopyTexSubImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glCopyTexSubImage2D"); return false; } else { touchstone::windows::register_hook("glCopyTexSubImage2D", _CopyTexSubImage2D); } if (MH_EnableHook(&glCopyTexSubImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glCopyTexSubImage2D"); return false; } static LPVOID _CullFace; if (MH_CreateHook(&glCullFace, &jaqCullFace, &_CullFace) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glCullFace"); return false; } else { touchstone::windows::register_hook("glCullFace", _CullFace); } if (MH_EnableHook(&glCullFace) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glCullFace"); return false; } static LPVOID _DeleteTextures; if (MH_CreateHook(&glDeleteTextures, &jaqDeleteTextures, &_DeleteTextures) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDeleteTextures"); return false; } else { touchstone::windows::register_hook("glDeleteTextures", _DeleteTextures); } if (MH_EnableHook(&glDeleteTextures) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDeleteTextures"); return false; } static LPVOID _DepthFunc; if (MH_CreateHook(&glDepthFunc, &jaqDepthFunc, &_DepthFunc) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDepthFunc"); return false; } else { touchstone::windows::register_hook("glDepthFunc", _DepthFunc); } if (MH_EnableHook(&glDepthFunc) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDepthFunc"); return false; } static LPVOID _DepthMask; if (MH_CreateHook(&glDepthMask, &jaqDepthMask, &_DepthMask) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDepthMask"); return false; } else { touchstone::windows::register_hook("glDepthMask", _DepthMask); } if (MH_EnableHook(&glDepthMask) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDepthMask"); return false; } static LPVOID _DepthRange; if (MH_CreateHook(&glDepthRange, &jaqDepthRange, &_DepthRange) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDepthRange"); return false; } else { touchstone::windows::register_hook("glDepthRange", _DepthRange); } if (MH_EnableHook(&glDepthRange) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDepthRange"); return false; } static LPVOID _Disable; if (MH_CreateHook(&glDisable, &jaqDisable, &_Disable) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDisable"); return false; } else { touchstone::windows::register_hook("glDisable", _Disable); } if (MH_EnableHook(&glDisable) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDisable"); return false; } static LPVOID _DrawArrays; if (MH_CreateHook(&glDrawArrays, &jaqDrawArrays, &_DrawArrays) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDrawArrays"); return false; } else { touchstone::windows::register_hook("glDrawArrays", _DrawArrays); } if (MH_EnableHook(&glDrawArrays) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDrawArrays"); return false; } static LPVOID _DrawBuffer; if (MH_CreateHook(&glDrawBuffer, &jaqDrawBuffer, &_DrawBuffer) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDrawBuffer"); return false; } else { touchstone::windows::register_hook("glDrawBuffer", _DrawBuffer); } if (MH_EnableHook(&glDrawBuffer) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDrawBuffer"); return false; } static LPVOID _DrawElements; if (MH_CreateHook(&glDrawElements, &jaqDrawElements, &_DrawElements) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glDrawElements"); return false; } else { touchstone::windows::register_hook("glDrawElements", _DrawElements); } if (MH_EnableHook(&glDrawElements) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glDrawElements"); return false; } static LPVOID _Enable; if (MH_CreateHook(&glEnable, &jaqEnable, &_Enable) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glEnable"); return false; } else { touchstone::windows::register_hook("glEnable", _Enable); } if (MH_EnableHook(&glEnable) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glEnable"); return false; } static LPVOID _Finish; if (MH_CreateHook(&glFinish, &jaqFinish, &_Finish) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glFinish"); return false; } else { touchstone::windows::register_hook("glFinish", _Finish); } if (MH_EnableHook(&glFinish) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glFinish"); return false; } static LPVOID _Flush; if (MH_CreateHook(&glFlush, &jaqFlush, &_Flush) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glFlush"); return false; } else { touchstone::windows::register_hook("glFlush", _Flush); } if (MH_EnableHook(&glFlush) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glFlush"); return false; } static LPVOID _FrontFace; if (MH_CreateHook(&glFrontFace, &jaqFrontFace, &_FrontFace) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glFrontFace"); return false; } else { touchstone::windows::register_hook("glFrontFace", _FrontFace); } if (MH_EnableHook(&glFrontFace) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glFrontFace"); return false; } static LPVOID _GenTextures; if (MH_CreateHook(&glGenTextures, &jaqGenTextures, &_GenTextures) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGenTextures"); return false; } else { touchstone::windows::register_hook("glGenTextures", _GenTextures); } if (MH_EnableHook(&glGenTextures) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGenTextures"); return false; } static LPVOID _GetBooleanv; if (MH_CreateHook(&glGetBooleanv, &jaqGetBooleanv, &_GetBooleanv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetBooleanv"); return false; } else { touchstone::windows::register_hook("glGetBooleanv", _GetBooleanv); } if (MH_EnableHook(&glGetBooleanv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetBooleanv"); return false; } static LPVOID _GetDoublev; if (MH_CreateHook(&glGetDoublev, &jaqGetDoublev, &_GetDoublev) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetDoublev"); return false; } else { touchstone::windows::register_hook("glGetDoublev", _GetDoublev); } if (MH_EnableHook(&glGetDoublev) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetDoublev"); return false; } static LPVOID _GetError; if (MH_CreateHook(&glGetError, &jaqGetError, &_GetError) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetError"); return false; } else { touchstone::windows::register_hook("glGetError", _GetError); } if (MH_EnableHook(&glGetError) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetError"); return false; } static LPVOID _GetFloatv; if (MH_CreateHook(&glGetFloatv, &jaqGetFloatv, &_GetFloatv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetFloatv"); return false; } else { touchstone::windows::register_hook("glGetFloatv", _GetFloatv); } if (MH_EnableHook(&glGetFloatv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetFloatv"); return false; } static LPVOID _GetIntegerv; if (MH_CreateHook(&glGetIntegerv, &jaqGetIntegerv, &_GetIntegerv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetIntegerv"); return false; } else { touchstone::windows::register_hook("glGetIntegerv", _GetIntegerv); } if (MH_EnableHook(&glGetIntegerv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetIntegerv"); return false; } static LPVOID _GetString; if (MH_CreateHook(&glGetString, &jaqGetString, &_GetString) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetString"); return false; } else { touchstone::windows::register_hook("glGetString", _GetString); } if (MH_EnableHook(&glGetString) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetString"); return false; } static LPVOID _GetTexImage; if (MH_CreateHook(&glGetTexImage, &jaqGetTexImage, &_GetTexImage) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetTexImage"); return false; } else { touchstone::windows::register_hook("glGetTexImage", _GetTexImage); } if (MH_EnableHook(&glGetTexImage) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetTexImage"); return false; } static LPVOID _GetTexLevelParameterfv; if (MH_CreateHook(&glGetTexLevelParameterfv, &jaqGetTexLevelParameterfv, &_GetTexLevelParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetTexLevelParameterfv"); return false; } else { touchstone::windows::register_hook("glGetTexLevelParameterfv", _GetTexLevelParameterfv); } if (MH_EnableHook(&glGetTexLevelParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetTexLevelParameterfv"); return false; } static LPVOID _GetTexLevelParameteriv; if (MH_CreateHook(&glGetTexLevelParameteriv, &jaqGetTexLevelParameteriv, &_GetTexLevelParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetTexLevelParameteriv"); return false; } else { touchstone::windows::register_hook("glGetTexLevelParameteriv", _GetTexLevelParameteriv); } if (MH_EnableHook(&glGetTexLevelParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetTexLevelParameteriv"); return false; } static LPVOID _GetTexParameterfv; if (MH_CreateHook(&glGetTexParameterfv, &jaqGetTexParameterfv, &_GetTexParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetTexParameterfv"); return false; } else { touchstone::windows::register_hook("glGetTexParameterfv", _GetTexParameterfv); } if (MH_EnableHook(&glGetTexParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetTexParameterfv"); return false; } static LPVOID _GetTexParameteriv; if (MH_CreateHook(&glGetTexParameteriv, &jaqGetTexParameteriv, &_GetTexParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glGetTexParameteriv"); return false; } else { touchstone::windows::register_hook("glGetTexParameteriv", _GetTexParameteriv); } if (MH_EnableHook(&glGetTexParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glGetTexParameteriv"); return false; } static LPVOID _Hint; if (MH_CreateHook(&glHint, &jaqHint, &_Hint) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glHint"); return false; } else { touchstone::windows::register_hook("glHint", _Hint); } if (MH_EnableHook(&glHint) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glHint"); return false; } static LPVOID _IsEnabled; if (MH_CreateHook(&glIsEnabled, &jaqIsEnabled, &_IsEnabled) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glIsEnabled"); return false; } else { touchstone::windows::register_hook("glIsEnabled", _IsEnabled); } if (MH_EnableHook(&glIsEnabled) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glIsEnabled"); return false; } static LPVOID _IsTexture; if (MH_CreateHook(&glIsTexture, &jaqIsTexture, &_IsTexture) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glIsTexture"); return false; } else { touchstone::windows::register_hook("glIsTexture", _IsTexture); } if (MH_EnableHook(&glIsTexture) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glIsTexture"); return false; } static LPVOID _LineWidth; if (MH_CreateHook(&glLineWidth, &jaqLineWidth, &_LineWidth) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glLineWidth"); return false; } else { touchstone::windows::register_hook("glLineWidth", _LineWidth); } if (MH_EnableHook(&glLineWidth) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glLineWidth"); return false; } static LPVOID _LogicOp; if (MH_CreateHook(&glLogicOp, &jaqLogicOp, &_LogicOp) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glLogicOp"); return false; } else { touchstone::windows::register_hook("glLogicOp", _LogicOp); } if (MH_EnableHook(&glLogicOp) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glLogicOp"); return false; } static LPVOID _PixelStoref; if (MH_CreateHook(&glPixelStoref, &jaqPixelStoref, &_PixelStoref) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glPixelStoref"); return false; } else { touchstone::windows::register_hook("glPixelStoref", _PixelStoref); } if (MH_EnableHook(&glPixelStoref) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glPixelStoref"); return false; } static LPVOID _PixelStorei; if (MH_CreateHook(&glPixelStorei, &jaqPixelStorei, &_PixelStorei) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glPixelStorei"); return false; } else { touchstone::windows::register_hook("glPixelStorei", _PixelStorei); } if (MH_EnableHook(&glPixelStorei) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glPixelStorei"); return false; } static LPVOID _PointSize; if (MH_CreateHook(&glPointSize, &jaqPointSize, &_PointSize) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glPointSize"); return false; } else { touchstone::windows::register_hook("glPointSize", _PointSize); } if (MH_EnableHook(&glPointSize) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glPointSize"); return false; } static LPVOID _PolygonMode; if (MH_CreateHook(&glPolygonMode, &jaqPolygonMode, &_PolygonMode) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glPolygonMode"); return false; } else { touchstone::windows::register_hook("glPolygonMode", _PolygonMode); } if (MH_EnableHook(&glPolygonMode) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glPolygonMode"); return false; } static LPVOID _PolygonOffset; if (MH_CreateHook(&glPolygonOffset, &jaqPolygonOffset, &_PolygonOffset) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glPolygonOffset"); return false; } else { touchstone::windows::register_hook("glPolygonOffset", _PolygonOffset); } if (MH_EnableHook(&glPolygonOffset) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glPolygonOffset"); return false; } static LPVOID _ReadBuffer; if (MH_CreateHook(&glReadBuffer, &jaqReadBuffer, &_ReadBuffer) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glReadBuffer"); return false; } else { touchstone::windows::register_hook("glReadBuffer", _ReadBuffer); } if (MH_EnableHook(&glReadBuffer) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glReadBuffer"); return false; } static LPVOID _ReadPixels; if (MH_CreateHook(&glReadPixels, &jaqReadPixels, &_ReadPixels) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glReadPixels"); return false; } else { touchstone::windows::register_hook("glReadPixels", _ReadPixels); } if (MH_EnableHook(&glReadPixels) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glReadPixels"); return false; } static LPVOID _Scissor; if (MH_CreateHook(&glScissor, &jaqScissor, &_Scissor) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glScissor"); return false; } else { touchstone::windows::register_hook("glScissor", _Scissor); } if (MH_EnableHook(&glScissor) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glScissor"); return false; } static LPVOID _StencilFunc; if (MH_CreateHook(&glStencilFunc, &jaqStencilFunc, &_StencilFunc) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glStencilFunc"); return false; } else { touchstone::windows::register_hook("glStencilFunc", _StencilFunc); } if (MH_EnableHook(&glStencilFunc) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glStencilFunc"); return false; } static LPVOID _StencilMask; if (MH_CreateHook(&glStencilMask, &jaqStencilMask, &_StencilMask) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glStencilMask"); return false; } else { touchstone::windows::register_hook("glStencilMask", _StencilMask); } if (MH_EnableHook(&glStencilMask) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glStencilMask"); return false; } static LPVOID _StencilOp; if (MH_CreateHook(&glStencilOp, &jaqStencilOp, &_StencilOp) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glStencilOp"); return false; } else { touchstone::windows::register_hook("glStencilOp", _StencilOp); } if (MH_EnableHook(&glStencilOp) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glStencilOp"); return false; } static LPVOID _TexImage1D; if (MH_CreateHook(&glTexImage1D, &jaqTexImage1D, &_TexImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexImage1D"); return false; } else { touchstone::windows::register_hook("glTexImage1D", _TexImage1D); } if (MH_EnableHook(&glTexImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexImage1D"); return false; } static LPVOID _TexImage2D; if (MH_CreateHook(&glTexImage2D, &jaqTexImage2D, &_TexImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexImage2D"); return false; } else { touchstone::windows::register_hook("glTexImage2D", _TexImage2D); } if (MH_EnableHook(&glTexImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexImage2D"); return false; } static LPVOID _TexParameterf; if (MH_CreateHook(&glTexParameterf, &jaqTexParameterf, &_TexParameterf) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexParameterf"); return false; } else { touchstone::windows::register_hook("glTexParameterf", _TexParameterf); } if (MH_EnableHook(&glTexParameterf) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexParameterf"); return false; } static LPVOID _TexParameterfv; if (MH_CreateHook(&glTexParameterfv, &jaqTexParameterfv, &_TexParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexParameterfv"); return false; } else { touchstone::windows::register_hook("glTexParameterfv", _TexParameterfv); } if (MH_EnableHook(&glTexParameterfv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexParameterfv"); return false; } static LPVOID _TexParameteri; if (MH_CreateHook(&glTexParameteri, &jaqTexParameteri, &_TexParameteri) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexParameteri"); return false; } else { touchstone::windows::register_hook("glTexParameteri", _TexParameteri); } if (MH_EnableHook(&glTexParameteri) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexParameteri"); return false; } static LPVOID _TexParameteriv; if (MH_CreateHook(&glTexParameteriv, &jaqTexParameteriv, &_TexParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexParameteriv"); return false; } else { touchstone::windows::register_hook("glTexParameteriv", _TexParameteriv); } if (MH_EnableHook(&glTexParameteriv) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexParameteriv"); return false; } static LPVOID _TexSubImage1D; if (MH_CreateHook(&glTexSubImage1D, &jaqTexSubImage1D, &_TexSubImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexSubImage1D"); return false; } else { touchstone::windows::register_hook("glTexSubImage1D", _TexSubImage1D); } if (MH_EnableHook(&glTexSubImage1D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexSubImage1D"); return false; } static LPVOID _TexSubImage2D; if (MH_CreateHook(&glTexSubImage2D, &jaqTexSubImage2D, &_TexSubImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glTexSubImage2D"); return false; } else { touchstone::windows::register_hook("glTexSubImage2D", _TexSubImage2D); } if (MH_EnableHook(&glTexSubImage2D) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glTexSubImage2D"); return false; } static LPVOID _Viewport; if (MH_CreateHook(&glViewport, &jaqViewport, &_Viewport) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "glViewport"); return false; } else { touchstone::windows::register_hook("glViewport", _Viewport); } if (MH_EnableHook(&glViewport) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "glViewport"); return false; } static LPVOID _CopyContext; if (MH_CreateHook(&wglCopyContext, &jaqCopyContext, &_CopyContext) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglCopyContext"); return false; } else { touchstone::windows::register_hook("wglCopyContext", _CopyContext); } if (MH_EnableHook(&wglCopyContext) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglCopyContext"); return false; } static LPVOID _CreateContext; if (MH_CreateHook(&wglCreateContext, &jaqCreateContext, &_CreateContext) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglCreateContext"); return false; } else { touchstone::windows::register_hook("wglCreateContext", _CreateContext); } if (MH_EnableHook(&wglCreateContext) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglCreateContext"); return false; } static LPVOID _CreateLayerContext; if (MH_CreateHook(&wglCreateLayerContext, &jaqCreateLayerContext, &_CreateLayerContext) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglCreateLayerContext"); return false; } else { touchstone::windows::register_hook("wglCreateLayerContext", _CreateLayerContext); } if (MH_EnableHook(&wglCreateLayerContext) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglCreateLayerContext"); return false; } static LPVOID _DeleteContext; if (MH_CreateHook(&wglDeleteContext, &jaqDeleteContext, &_DeleteContext) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglDeleteContext"); return false; } else { touchstone::windows::register_hook("wglDeleteContext", _DeleteContext); } if (MH_EnableHook(&wglDeleteContext) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglDeleteContext"); return false; } static LPVOID _DescribeLayerPlane; if (MH_CreateHook(&wglDescribeLayerPlane, &jaqDescribeLayerPlane, &_DescribeLayerPlane) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglDescribeLayerPlane"); return false; } else { touchstone::windows::register_hook("wglDescribeLayerPlane", _DescribeLayerPlane); } if (MH_EnableHook(&wglDescribeLayerPlane) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglDescribeLayerPlane"); return false; } static LPVOID _GetCurrentContext; if (MH_CreateHook(&wglGetCurrentContext, &jaqGetCurrentContext, &_GetCurrentContext) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglGetCurrentContext"); return false; } else { touchstone::windows::register_hook("wglGetCurrentContext", _GetCurrentContext); } if (MH_EnableHook(&wglGetCurrentContext) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglGetCurrentContext"); return false; } static LPVOID _GetCurrentDC; if (MH_CreateHook(&wglGetCurrentDC, &jaqGetCurrentDC, &_GetCurrentDC) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglGetCurrentDC"); return false; } else { touchstone::windows::register_hook("wglGetCurrentDC", _GetCurrentDC); } if (MH_EnableHook(&wglGetCurrentDC) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglGetCurrentDC"); return false; } static LPVOID _GetLayerPaletteEntries; if (MH_CreateHook(&wglGetLayerPaletteEntries, &jaqGetLayerPaletteEntries, &_GetLayerPaletteEntries) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglGetLayerPaletteEntries"); return false; } else { touchstone::windows::register_hook("wglGetLayerPaletteEntries", _GetLayerPaletteEntries); } if (MH_EnableHook(&wglGetLayerPaletteEntries) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglGetLayerPaletteEntries"); return false; } static LPVOID _MakeCurrent; if (MH_CreateHook(&wglMakeCurrent, &jaqMakeCurrent, &_MakeCurrent) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglMakeCurrent"); return false; } else { touchstone::windows::register_hook("wglMakeCurrent", _MakeCurrent); } if (MH_EnableHook(&wglMakeCurrent) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglMakeCurrent"); return false; } static LPVOID _RealizeLayerPalette; if (MH_CreateHook(&wglRealizeLayerPalette, &jaqRealizeLayerPalette, &_RealizeLayerPalette) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglRealizeLayerPalette"); return false; } else { touchstone::windows::register_hook("wglRealizeLayerPalette", _RealizeLayerPalette); } if (MH_EnableHook(&wglRealizeLayerPalette) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglRealizeLayerPalette"); return false; } static LPVOID _SetLayerPaletteEntries; if (MH_CreateHook(&wglSetLayerPaletteEntries, &jaqSetLayerPaletteEntries, &_SetLayerPaletteEntries) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglSetLayerPaletteEntries"); return false; } else { touchstone::windows::register_hook("wglSetLayerPaletteEntries", _SetLayerPaletteEntries); } if (MH_EnableHook(&wglSetLayerPaletteEntries) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglSetLayerPaletteEntries"); return false; } static LPVOID _ShareLists; if (MH_CreateHook(&wglShareLists, &jaqShareLists, &_ShareLists) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglShareLists"); return false; } else { touchstone::windows::register_hook("wglShareLists", _ShareLists); } if (MH_EnableHook(&wglShareLists) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglShareLists"); return false; } static LPVOID _SwapLayerBuffers; if (MH_CreateHook(&wglSwapLayerBuffers, &jaqSwapLayerBuffers, &_SwapLayerBuffers) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglSwapLayerBuffers"); return false; } else { touchstone::windows::register_hook("wglSwapLayerBuffers", _SwapLayerBuffers); } if (MH_EnableHook(&wglSwapLayerBuffers) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglSwapLayerBuffers"); return false; } static LPVOID _UseFontBitmapsA; if (MH_CreateHook(&wglUseFontBitmapsA, &jaqUseFontBitmapsA, &_UseFontBitmapsA) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglUseFontBitmapsA"); return false; } else { touchstone::windows::register_hook("wglUseFontBitmapsA", _UseFontBitmapsA); } if (MH_EnableHook(&wglUseFontBitmapsA) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglUseFontBitmapsA"); return false; } static LPVOID _UseFontBitmapsW; if (MH_CreateHook(&wglUseFontBitmapsW, &jaqUseFontBitmapsW, &_UseFontBitmapsW) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglUseFontBitmapsW"); return false; } else { touchstone::windows::register_hook("wglUseFontBitmapsW", _UseFontBitmapsW); } if (MH_EnableHook(&wglUseFontBitmapsW) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglUseFontBitmapsW"); return false; } static LPVOID _UseFontOutlines; if (MH_CreateHook(&wglUseFontOutlines, &jaqUseFontOutlines, &_UseFontOutlines) != MH_OK) { std::fprintf(stderr, "Couldn't create '%s'.\n", "wglUseFontOutlines"); return false; } else { touchstone::windows::register_hook("wglUseFontOutlines", _UseFontOutlines); } if (MH_EnableHook(&wglUseFontOutlines) != MH_OK) { std::fprintf(stderr, "Couldn't enable '%s'.\n", "wglUseFontOutlines"); return false; } if (!install_manual_hooks()) { std::fprintf(stderr, "Couldn't install manual hooks.\n"); return false; } return true; } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: if (!install_hooks()) { std::abort(); return FALSE; } break; } return TRUE; }
0fabefb350654547e5099eda8aff70d77708a87f
445270f32d4913ce2f160282a85b30005666fb2a
/Firmware/Keil/SerialBuffered.h
fd2369a18e2f449b6d840563435dcf5a848989cb
[]
no_license
akpc806a/OpenBCI_32_STM32
2d0a170174ba1948dde0be38c8c01fe1453ca10d
7e8b2e739fe0bdec04145e21b1c27079adfa09b3
refs/heads/master
2020-06-14T03:08:13.126617
2016-12-18T03:25:59
2016-12-18T03:25:59
75,513,527
3
0
null
null
null
null
UTF-8
C++
false
false
1,641
h
SerialBuffered.h
#pragma once // This is a buffered serial reading class, using the serial interrupt introduced in mbed library version 18 on 17/11/09 // In the simplest case, construct it with a buffer size at least equal to the largest message you // expect your program to receive in one go. class SerialBuffered : public RawSerial { public: SerialBuffered( size_t bufferSize, PinName tx, PinName rx, int baud ); virtual ~SerialBuffered(); int getc(); // will block till the next character turns up, or return -1 if there is a timeout int readable(); // returns 1 if there is a character available to read, 0 otherwise void setTimeout( float seconds ); // maximum time in seconds that getc() should block // while waiting for a character // Pass -1 to disable the timeout. size_t readBytes( uint8_t *bytes, size_t requested ); // read requested bytes into a buffer, // return number actually read, // which may be less than requested if there has been a timeout private: void handleInterrupt(); uint8_t *m_buff; // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end uint16_t m_contentStart; // index of first bytes of content uint16_t m_contentEnd; // index of bytes after last byte of content uint16_t m_buffSize; float m_timeout; Timer m_timer; };
9019bd8663c8654bd2b844bce35078b3ddc24838
931a8f1634feb32916cf20ac6cd28a3ee2830ba0
/Native/System/Servers/appserver/drivers/video/mach64/mach64_accel.cpp
1d1582684fc34a2f20d64283aef6746cfab9ed07
[]
no_license
PyroOS/Pyro
2c4583bff246f80307fc722515c5e90668c00542
ea709dc1f706c4dfc182d959df14696d604572f8
refs/heads/master
2021-01-10T19:47:17.787899
2012-04-15T12:20:14
2012-04-15T12:20:14
4,031,632
6
1
null
null
null
null
UTF-8
C++
false
false
5,010
cpp
mach64_accel.cpp
#include "mach64.h" int MixFromMode( int nMode ) { switch( nMode ) { case DM_COPY: return( FRGD_MIX_S ); break; case DM_INVERT: return( FRGD_MIX_NOT_D ); break; default: return( FRGD_MIX_S ); break; } return( FRGD_MIX_S ); } //----------------------------------------------------------------------------- bool ATImach64::FillRect(SrvBitmap *pcBitmap, const IRect &cRect, const Color32_s &sColor, int nMode) { if( pcBitmap->m_bVideoMem == false || nMode != DM_COPY ) { return( DisplayDriver::FillRect(pcBitmap, cRect, sColor, nMode) ); } int dstx = cRect.left; unsigned int width = cRect.Width(); uint32 nColor; switch( pcBitmap->m_eColorSpc ) { case CS_RGB16: nColor = COL_TO_RGB16 (sColor); break; case CS_RGB32: case CS_RGBA32: nColor = COL_TO_RGB32 (sColor); break; default: return( DisplayDriver::FillRect(pcBitmap, cRect, sColor, nMode) ); } m_cLock.Lock(); wait_for_fifo(4); aty_st_le32(DP_SRC, BKGD_SRC_BKGD_CLR | FRGD_SRC_FRGD_CLR | MONO_SRC_ONE); aty_st_le32(DST_CNTL, DST_LAST_PEL | DST_Y_TOP_TO_BOTTOM | DST_X_LEFT_TO_RIGHT); aty_st_le32(DP_MIX, FRGD_MIX_S); aty_st_le32(DP_FRGD_CLR, nColor); wait_for_fifo(2); aty_st_le32(DST_Y_X, (dstx << 16) | cRect.top); aty_st_le32(DST_HEIGHT_WIDTH, (width+1 << 16) | cRect.Height()+1); wait_for_idle(); m_cLock.Unlock(); return( true ); } //----------------------------------------------------------------------------- bool ATImach64::DrawLine(SrvBitmap *psBitMap, const IRect &cClipRect, const IPoint &cPnt1, const IPoint &cPnt2, const Color32_s &sColor, int nMode) { /* based upon mach64seg.c */ if( psBitMap->m_bVideoMem == false || ( nMode != DM_COPY && nMode != DM_INVERT ) ) { return( DisplayDriver::DrawLine(psBitMap, cClipRect, cPnt1, cPnt2, sColor, nMode) ); } uint32 nColor; switch( psBitMap->m_eColorSpc ) { case CS_RGB16: nColor = COL_TO_RGB16 (sColor); break; case CS_RGB32: case CS_RGBA32: nColor = COL_TO_RGB32 (sColor); break; default: return( DisplayDriver::DrawLine(psBitMap, cClipRect, cPnt1, cPnt2, sColor, nMode) ); } int x1 = cPnt1.x; int y1 = cPnt1.y; int x2 = cPnt2.x; int y2 = cPnt2.y; register int dx, dy; register int minDelta, maxDelta; register int x_dir, y_dir, y_major; if( DisplayDriver::ClipLine( cClipRect, &x1, &y1, &x2, &y2 ) == false ) { return( false ); } /* determine x & y deltas and x & y direction bits */ if( x1 < x2 ) { dx = x2 - x1; x_dir = DST_X_LEFT_TO_RIGHT; } else { dx = x1 - x2; x_dir = 0; } if( y1 < y2 ) { dy = y2 - y1; y_dir = DST_Y_TOP_TO_BOTTOM; } else { dy = y1 - y2; y_dir = 0; } /* determine x & y min and max values; also determine y major bit */ if( dx < dy ) { minDelta = dx; maxDelta = dy; y_major = DST_Y_MAJOR; } else { minDelta = dy; maxDelta = dx; y_major = 0; } m_cLock.Lock(); wait_for_fifo(6); aty_st_le32(DP_SRC, BKGD_SRC_BKGD_CLR | FRGD_SRC_FRGD_CLR | MONO_SRC_ONE); aty_st_le32(DP_MIX, MixFromMode( nMode )); aty_st_le32(DP_FRGD_CLR, nColor); wait_for_fifo(2); aty_st_le32(DST_CNTL, (y_major | y_dir | x_dir)); aty_st_le32(DST_Y_X, (x1 << 16) | (y1 & 0x0000ffff)); aty_st_le32(DST_BRES_ERR, ((minDelta << 1) - maxDelta)); aty_st_le32(DST_BRES_INC, (minDelta << 1)); aty_st_le32(DST_BRES_DEC, (0x3ffff - ((maxDelta - minDelta) <<1))); aty_st_le32(DST_BRES_LNTH, (maxDelta + 2)); wait_for_idle(); m_cLock.Unlock(); return( true ); } //----------------------------------------------------------------------------- bool ATImach64::BltBitmap(SrvBitmap *pcDstBitMap, SrvBitmap *pcSrcBitMap, IRect cSrcRect, IRect cDstRect, int nMode, int nAlpha) { if( pcDstBitMap->m_bVideoMem == false || pcSrcBitMap->m_bVideoMem == false || ( nMode != DM_COPY && nMode != DM_INVERT ) || ( cSrcRect.Size() != cDstRect.Size() ) ) { return( DisplayDriver::BltBitmap( pcDstBitMap, pcSrcBitMap, cSrcRect, cDstRect, nMode, nAlpha ) ); } IPoint cDstPos = cDstRect.LeftTop(); int srcx = cSrcRect.left; int srcy = cSrcRect.top; int dstx = cDstPos.x; int dsty = cDstPos.y; u_int width = cSrcRect.Width(); u_int height = cSrcRect.Height(); uint32 direction = 0; if( srcy < dsty ) { dsty += height; srcy += height; } else direction |= DST_Y_TOP_TO_BOTTOM; if (srcx < dstx) { dstx += width; srcx += width; } else direction |= DST_X_LEFT_TO_RIGHT; m_cLock.Lock(); aty_st_le32(DST_CNTL, direction); wait_for_fifo(3); aty_st_le32(DP_SRC, FRGD_SRC_BLIT); aty_st_le32(DP_MIX, MixFromMode( nMode )); wait_for_fifo(4); aty_st_le32(SRC_Y_X, (srcx << 16) | srcy ); aty_st_le32(SRC_HEIGHT1_WIDTH1, (width + 1 << 16) | height + 1); aty_st_le32(DST_Y_X, (dstx << 16) | dsty); aty_st_le32(DST_HEIGHT_WIDTH, (width + 1 << 16) | height + 1); wait_for_idle(); m_cLock.Unlock(); return( true ); }
b45d593e17c6664bde6c91524738acc80807bb69
488a3c17c945f34eddc41ba0f69cd381d9f30de9
/main/zipline.ino
71d6171098ecdbd43835cce7192083408a2e43dd
[]
no_license
spectre-robot/spectre
9d7598c69b7f4b47f244bc7bf48be01287ba6cba
f2b53d08a178446bce76fb2882e84ad9b21b0fd4
refs/heads/master
2020-12-02T18:08:01.035463
2017-08-10T16:26:49
2017-08-10T16:26:49
96,480,443
2
1
null
null
null
null
UTF-8
C++
false
false
1,253
ino
zipline.ino
void findZipline() { // when the robot hits the zipline, it will do a wheelie because of torque from the normal force from the zipline while (!wheelie()) { moveLeftWheel(60); moveRightWheel(60); } stopMotors(); delay(100); undoWheelie(); stopMotors(); delay(100); LCD.clear(); LCD.home() ; LCD.setCursor(0, 0); LCD.print("left"); // align the robot to be perpendicular to the zipline. while (!wheelie) { moveLeftWheel(50); } stopMotors(); delay(100); undoWheelie(); stopMotors(); delay(100); LCD.clear(); LCD.home() ; LCD.setCursor(0, 0); LCD.print("right"); while (!wheelie) { moveRightWheel(50); } stopMotors(); delay(100); undoWheelie(); stopMotors(); delay(100); rotate(90, -1); } void makeMyDreamsComeTrue() { motor.speed(2, 255); } void zipline() { findZipline(); LCD.clear(); LCD.home() ; LCD.setCursor(0, 0); LCD.print("IM FLYING"); makeMyDreamsComeTrue(); while(!stopbutton()) { delay(10); } LCD.clear(); LCD.home() ; LCD.setCursor(0, 0); LCD.print("SAFE!!!!!"); motor.speed(2, 0); while(!startbutton()) { delay(10); } LCD.clear(); LCD.home() ; LCD.setCursor(0, 0); LCD.print("unwind"); motor.speed(2, -255); }
abe379c362d3df361867640cc2621274665fd914
e19a7a853aa2cdee3477948dae23bc1992f126fb
/test/main_bt.cpp
617116168ad8635ab629e686a4c46e6a9d6b39c9
[]
no_license
PauAnton/p3
ad3237419881330f82a9cd2a20c9c005d7d8a825
66c11a078256677da38f1662728eaea9a4da4230
refs/heads/main
2023-03-18T21:37:06.351545
2021-03-19T17:25:25
2021-03-19T17:25:25
349,245,905
0
0
null
null
null
null
UTF-8
C++
false
false
1,723
cpp
main_bt.cpp
#include <Arduino.h> #include "BluetoothSerial.h" #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif BluetoothSerial SerialBT; int LED=2; void setup() { Serial.begin(9600); SerialBT.begin("ESP32test"); //Bluetooth device name Serial.println("The device started, now you can pair it with bluetooth!"); pinMode(LED, OUTPUT); Serial.println("When connected, select an option"); Serial.println(); Serial.println("1. LED on 500ms."); Serial.println("2. LED blink 3000ms."); Serial.println("3. LED on."); Serial.println("4. LED off."); } void loop() { if (Serial.available()) { SerialBT.write(Serial.read()); } if (SerialBT.available()) { Serial.println(); char opc; opc=SerialBT.read(); Serial.print("Option "); Serial.print(opc); Serial.println(" selected"); if(opc=='1'){ digitalWrite(LED,HIGH); delay(2000); digitalWrite(LED,LOW); } else if(opc=='2'){ int i=0; while(i<6){ digitalWrite(LED,HIGH); delay(500); digitalWrite(LED,LOW); delay(500); i++;} } else if(opc=='3'){ digitalWrite(LED,HIGH); delay(500); } else if(opc=='4'){ digitalWrite(LED,LOW); delay(500); } else {Serial.println("Option does not match delimiters.");} opc=SerialBT.read(); opc=SerialBT.read(); Serial.println(); Serial.println("Select new option"); Serial.println("1. LED on 2000ms."); Serial.println("2. LED blink 3000ms."); Serial.println("3. LED on."); Serial.println("4. LED off."); } }
bc8fc12105e93c361e859d56fa57874bc4e9cfea
8b9229ba6d43c5ae3cc9816003f99d8efe3d50a4
/dp/gl/ProgramInstance.h
b48d312653c4d4cd149e4945673abaf4758c10e7
[]
no_license
JamesLinus/pipeline
02aef690636f1d215a135b971fa34a9e09a6b901
27322a5527deb69c14bd70dd99374b52709ae157
refs/heads/master
2021-01-16T22:14:56.899613
2016-03-22T10:39:59
2016-03-22T10:39:59
56,539,375
1
0
null
2016-04-18T20:22:33
2016-04-18T20:22:32
null
UTF-8
C++
false
false
9,754
h
ProgramInstance.h
// Copyright NVIDIA Corporation 2015 // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include <dp/gl/Config.h> #include <dp/gl/Program.h> #include <dp/gl/Types.h> #include <map> #if !defined(NDEBUG) #include <set> #endif namespace dp { namespace gl { namespace { template <typename T> inline void setBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, T const& value ) { DP_ASSERT( sizeOfType( uniform.type ) == sizeof(T) ); buffer->update( &value, uniform.offset, sizeof(T) ); } template <> inline void setBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, bool const& value ) { setBufferUniform<int>( buffer, uniform, value ); } template <> inline void setBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, dp::math::Mat33f const& value ) { DP_ASSERT( uniform.matrixStride == 4 * sizeof(float) ); buffer->update( &value[0], uniform.offset , 3*sizeof(float) ); buffer->update( &value[1], uniform.offset + uniform.matrixStride, 3*sizeof(float) ); buffer->update( &value[2], uniform.offset + 2*uniform.matrixStride, 3*sizeof(float) ); } template <typename T> inline void getBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, T & value ) { DP_ASSERT( sizeOfType( uniform.type ) == sizeof(T) ); void* ptr = buffer->map( GL_MAP_READ_BIT, uniform.offset, sizeof(T) ); memcpy( &value, ptr, sizeof(T) ); } template <> inline void getBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, bool & value ) { int iValue; getBufferUniform( buffer, uniform, iValue ); value = !!iValue; } template <> inline void getBufferUniform( BufferSharedPtr const& buffer, Program::Uniform const& uniform, dp::math::Mat33f & value ) { DP_ASSERT( uniform.matrixStride == 4 * sizeof(float) ); float* ptr = reinterpret_cast<float*>(buffer->map( GL_MAP_READ_BIT, uniform.offset, 12*sizeof(float) )); // 3 * (3+1) * sizeof(float) !! memcpy( &value[0], ptr, 3*sizeof(float) ); memcpy( &value[1], ptr + 4, 3*sizeof(float) ); memcpy( &value[2], ptr + 8, 3*sizeof(float) ); } } class ProgramInstance { public: struct ImageUniformData { GLenum access; TextureSharedPtr texture; }; struct SamplerUniformData { SamplerSharedPtr sampler; TextureSharedPtr texture; }; typedef std::vector<char> UniformData; public: DP_GL_API static ProgramInstanceSharedPtr create( ProgramSharedPtr const& program ); DP_GL_API virtual ~ProgramInstance(); DP_GL_API void apply() const; DP_GL_API ProgramSharedPtr const& getProgram() const; DP_GL_API void setImageUniform( std::string const& uniformName, TextureSharedPtr const& texture, GLenum access ); DP_GL_API void setImageUniform( size_t uniformIndex, TextureSharedPtr const& texture, GLenum access ); DP_GL_API ImageUniformData const& getImageUniform( std::string const& uniformName ) const; DP_GL_API ImageUniformData const& getImageUniform( size_t uniformIndex ) const; DP_GL_API void setSamplerUniform( std::string const& uniformName, TextureSharedPtr const& texture, SamplerSharedPtr const& sampler ); DP_GL_API void setSamplerUniform( size_t uniformIndex, TextureSharedPtr const& texture, SamplerSharedPtr const& sampler ); DP_GL_API SamplerUniformData const& getSamplerUniform( std::string const& uniformName ) const; DP_GL_API SamplerUniformData const& getSamplerUniform( size_t uniformIndex ) const; DP_GL_API void setShaderStorageBuffer( std::string const& ssbName, BufferSharedPtr const& buffer ); DP_GL_API void setShaderStorageBuffer( size_t ssbIndex, BufferSharedPtr const& buffer ); DP_GL_API BufferSharedPtr const& getShaderStorageBuffer( std::string const& ssbName ) const; DP_GL_API BufferSharedPtr const& getShaderStorageBuffer( size_t ssbIndex ) const; template <typename T> void setUniform( std::string const& uniformName, T const& value ); template <typename T> void setUniform( size_t uniformIndex, T const& value ); template <typename T> bool getUniform( std::string const& uniformName, T & value ) const; template <typename T> bool getUniform( size_t uniformIndex, T & value ) const; protected: DP_GL_API ProgramInstance( ProgramSharedPtr const& program ); private: ProgramSharedPtr m_program; std::map<size_t,ImageUniformData> m_imageUniforms; std::map<size_t,SamplerUniformData> m_samplerUniforms; std::vector<BufferSharedPtr> m_shaderStorageBuffers; std::vector<BufferSharedPtr> m_uniformBuffers; std::map<size_t,UniformData> m_uniforms; #if !defined(NDEBUG) std::set<size_t> m_unsetShaderStorageBlocks; std::set<size_t> m_unsetUniforms; #endif }; template <typename T> inline void ProgramInstance::setUniform( std::string const& uniformName, T const& value ) { size_t uniformIndex = m_program->getActiveUniformIndex( uniformName ); if ( uniformIndex != ~0 ) { setUniform( uniformIndex, value ); } } template <typename T> inline void ProgramInstance::setUniform( size_t uniformIndex, T const& value ) { Program::Uniform const& uniform = m_program->getActiveUniform( uniformIndex ); DP_ASSERT( !isImageType( uniform.type ) && !isSamplerType( uniform.type ) ); DP_ASSERT( TypeTraits<T>::glType() == uniform.type ); DP_ASSERT( uniform.arraySize == 1 ); if ( uniform.location != -1 ) { DP_ASSERT( uniform.blockIndex == -1 ); std::map<size_t,UniformData>::iterator it = m_uniforms.find( uniformIndex ); DP_ASSERT( ( it != m_uniforms.end() ) && ( it->second.size() == sizeOfType( uniform.type ) ) ); memcpy( it->second.data(), &value, sizeOfType( uniform.type ) ); } else { DP_ASSERT( uniform.blockIndex != -1 ); DP_ASSERT( uniform.blockIndex < m_uniformBuffers.size() ); setBufferUniform( m_uniformBuffers[uniform.blockIndex], uniform, value ); } #if !defined(NDEBUG) m_unsetUniforms.erase( uniformIndex ); #endif } template <typename T> inline bool ProgramInstance::getUniform( std::string const& uniformName, T & value ) const { size_t uniformIndex = m_program->getActiveUniformIndex( uniformName ); if ( uniformIndex != ~0 ) { return( getUniform( uniformIndex, value ) ); } return( false ); } template <typename T> inline bool ProgramInstance::getUniform( size_t uniformIndex, T & value ) const { DP_ASSERT( m_unsetUniforms.find( uniformIndex ) == m_unsetUniforms.end() ); Program::Uniform const& uniform = m_program->getActiveUniform( uniformIndex ); DP_ASSERT( !isImageType( uniform.type ) && !isSamplerType( uniform.type ) ); DP_ASSERT( TypeTraits<T>::glType() == uniform.type ); DP_ASSERT( uniform.arraySize == 1 ); if ( uniform.location != -1 ) { DP_ASSERT( uniform.blockIndex == -1 ); std::map<size_t,UniformData>::iterator it = m_uniforms.find( uniformIndex ); DP_ASSERT( ( it != m_uniforms.end() ) && ( it->second.size() == sizeOfType( uniform.type ) ) ); memcpy( &value, it->second.data(), sizeOfType( uniform.type ) ); } else { DP_ASSERT( uniform.blockIndex != -1 ); DP_ASSERT( uniform.blockIndex < m_uniformBuffers.size() ); getBufferUniform( m_uniformBuffers[uniform.blockIndex], uniform, value ); } } } // namespace gl } // namespace dp
72c9dc137d65e49809135d93f5fdfbde12460465
2760c34c99a620409b926babd1f3ee1a0998843c
/Bomberman/Bomberman/Pontan.h
dfdab4f2d1c3a1790ecc66e6cd73ad5a857fe8ab
[]
no_license
coverp/Bomberman
294d8a3288ed2a62d571db356fd461cc44b067ef
ad495e98ef0e4766ab12f2d37148e8685462e0db
refs/heads/master
2020-04-06T03:59:01.399560
2017-03-16T19:40:28
2017-03-16T19:40:28
83,081,729
0
0
null
2017-03-16T19:40:29
2017-02-24T20:52:55
C++
UTF-8
C++
false
false
158
h
Pontan.h
#pragma once #include "Enemy.h" class Pontan : public Enemy { public: Pontan(); ~Pontan(); private: bool softPass = true; void move(double speed); };
7787e7f119e849a37ee5337a3bb700c271182693
f5fd0e6c9200e3585627044f10d33fb17501d900
/motif_map.h
283b47ad359263a99b6f5941ec780515b273a64c
[ "MIT" ]
permissive
SeqOne/vt
34f6e932e6da0b837a057a7a0bd547bfb95cc25c
f1c49a74a33052d7bc84ba9a29b3a0ed1eeeb278
refs/heads/master
2020-06-09T18:15:00.810586
2020-03-31T13:29:54
2020-03-31T13:29:54
193,482,841
0
0
MIT
2020-03-31T13:29:55
2019-06-24T10:18:53
C
UTF-8
C++
false
false
2,462
h
motif_map.h
/* The MIT License Copyright (c) 2015 Adrian Tan <atks@umich.edu> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef MOTIF_MAP_H #define MOTIF_MAP_H #include <cstdint> #include <vector> #include <iostream> #define get_seqi(s, i) (((s)>>((15-(i))<<1)) & 3) #define set_seqi(s, i, b) (((b)<<((15-(i))<<1)) | (s&~(((3)<<((15-(i))<<1))))) //shift a sequence s of length l #define shift(s,l) ((((s) >> 30) << ((16-(l))<<1)) | ((s) << 2)) /** * Motif Map for the mapping functions to and from index. * * Function for canonical form too. */ class MotifMap { public: std::vector<uint32_t> len_count; uint32_t max_len; uint32_t max_index; /** * Constructor. */ MotifMap(uint32_t max_len); /** * Destructor. */ ~MotifMap(); /** * Get canonical representation. */ uint32_t canonical(uint32_t motif, uint32_t len); /** * Checks if a string is aperiodic. */ bool is_aperiodic(uint32_t motif, uint32_t len); /** * Converts index to sequence. */ uint32_t index2seq(uint32_t index); /** * Converts sequence to index. */ uint32_t seq2index(uint32_t seq, uint32_t len); /** * Prints sequence. */ void print_seq(uint32_t seq, uint32_t len); /** * Converts sequence to string. */ std::string seq2str(uint32_t seq, uint32_t len); private: }; #endif
5242c855b4f4d824f767c023f3671b884d15b946
31e17175f7f8e07c089a3c63a5028a50f4079f6f
/licenseKeyFormatting.cpp
e640f8768d831433d4aa177ef49eefc661a110e3
[]
no_license
abrilgzz/InterviewProblems
78a97dc4036b983ad6c01b22edc3647b397c9ad4
b5c7bb7eae3aa491d132ac6f6e3ec4305c80b80b
refs/heads/master
2020-04-17T06:16:04.625326
2019-08-19T00:39:37
2019-08-19T00:39:37
166,318,065
0
0
null
null
null
null
UTF-8
C++
false
false
1,488
cpp
licenseKeyFormatting.cpp
/* Abril Marina Gonzalez Ramirez August 2019 LeetCode Problem 482. License Key Formatting You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the first group which could be shorter than K, but still must contain at least one character. Furthermore, there must be a dash inserted between two groups and all lowercase letters should be converted to uppercase. Given a non-empty string S and a number K, format the string according to the rules described above. Runtime: O(n) */ class Solution { public: string licenseKeyFormatting(string S, int K) { string answer = ""; // Every (k+1)th char from the tail of the string must be '-' // Start from the end of the string for(int i=S.length()-1; i >= 0; i--){ // Ignore '-' if(S[i] != '-'){ // Check if it is a (k+1)th char from the tail if(answer.length() % (K+1) == K){ answer += '-'; } // Add to the answer string answer += toupper(S[i]); } } // Reverse final answer reverse(answer.begin(), answer.end()); return answer; } };
684f4c4c646c59f24ac78a057af0e86c193cdf7e
979f022aec7a25402fb24a1fcddacb155dfa23cf
/mystarcraft/Client/Com_Guardsearch.cpp
71c4a470f7f55ba3d4f3bc83675b788752eea4d7
[]
no_license
Kimdeokho/mystarproject
e0a2c5a53f767ede5a7c19f7bb532dee227d766e
d4828e807233e6a783e6b3a46be11efda7c2d978
refs/heads/master
2021-04-29T06:19:47.010767
2020-12-16T12:50:46
2020-12-16T12:50:46
78,000,948
0
0
null
null
null
null
UHC
C++
false
false
4,520
cpp
Com_Guardsearch.cpp
#include "StdAfx.h" #include "Com_Guardsearch.h" #include "Obj.h" #include "ObjMgr.h" #include "TimeMgr.h" #include "Area_Mgr.h" #include "MyMath.h" #include "Com_Weapon.h" #include "Com_Animation.h" #include "Com_Pathfind.h" #include "Bunker.h" #include "Dropship.h" CCom_Guardsearch::CCom_Guardsearch(const TARGET_SEARCH_TYPE esearch_type ) { m_search_type = esearch_type; } CCom_Guardsearch::~CCom_Guardsearch(void) { } void CCom_Guardsearch::Initialize(CObj* pobj /*= NULL*/) { m_ptarget = NULL; m_pobj = pobj; m_com_anim = (m_pobj->GetComponent(COM_ANIMATION)); m_com_weapon = (m_pobj->GetComponent(COM_WEAPON)); m_pattack_range = &( m_pobj->GetUnitinfo().attack_range ); m_pair_range = &( m_pobj->GetUnitinfo().air_attack_range ); m_psearch_range = &(m_pobj->GetUnitinfo().search_range); m_target_objid = -1; m_search_time = 0.f; m_btarget_search = true; m_irange = 0; Range_update(); } void CCom_Guardsearch::Update(void) { if(COLLISION == m_pobj->GetUnitinfo().state || TRANSFORMING == m_pobj->GetUnitinfo().state || false == m_pobj->GetUnitinfo().is_active) return; m_ptarget = CObjMgr::GetInstance()->obj_alivecheck(m_target_objid); if( NULL == m_ptarget) { m_bforced_target = false; m_target_objid = 0; } else { TEAM_NUMBER eteam = m_pobj->GetTeamNumber(); if(false == m_ptarget->GetUnitinfo().is_active || m_ptarget->GetUnitinfo().detect[eteam] < 1) { m_ptarget = NULL; m_target_objid = 0; } if(NULL != m_ptarget && m_obj_cnt != m_ptarget->GetObjCountNumber()) { m_ptarget = NULL; m_target_objid = 0; } } if(ORDER_USINGSKILL == m_pobj->GetUnitinfo().order) return; if(true == m_bforced_target) { //강제타겟이 있을 경우 if(CATEGORY_RESOURCE != m_ptarget->GetCategory()) { if( m_pobj->GetTeamNumber() == m_ptarget->GetTeamNumber() && ORDER_MOVE == m_pobj->GetUnitinfo().order) { } else if(ORDER_MOVE_ATTACK == m_pobj->GetUnitinfo().order) { if(CMyMath::pos_distance( (m_ptarget)->GetPos() , m_pobj->GetPos()) < (*m_pattack_range)*(*m_pattack_range)) { //공격 범위에 들어오면 m_pobj->Setdir( (m_ptarget)->GetPos() - m_pobj->GetPos()); ATTACK_SEARCH_TYPE emy_attacktype = m_pobj->GetUnitinfo().eAttackType; MOVE_TYPE etarget_movetype = m_ptarget->GetUnitinfo().eMoveType; if( ATTACK_ONLY_AIR == emy_attacktype) { if(MOVE_GROUND == etarget_movetype) return; } else if( ATTACK_ONLY_GROUND == emy_attacktype) { if(MOVE_AIR == etarget_movetype) return; } if(NULL != m_com_weapon) ((CCom_Weapon*)m_com_weapon)->fire(m_ptarget); } } } } else { if(ORDER_MOVE != m_pobj->GetUnitinfo().order) { m_search_time += GETTIME; if(true == m_btarget_search && m_search_time > 0.2f) { m_search_time = 0.f; int att_range = max(*m_pattack_range , *m_pair_range); m_ptarget = CArea_Mgr::GetInstance()->Auto_explore_target(m_pobj , m_irange , att_range , m_search_type); } if(NULL != m_ptarget) { m_target_objid = m_ptarget->GetObjNumber(); m_obj_cnt = m_ptarget->GetObjCountNumber(); } else { m_target_objid = 0; m_btarget_search = true; } } else { m_target_objid = 0; m_ptarget = NULL; m_bforced_target = false; } if(NULL != m_ptarget) { int range = 0; if( MOVE_GROUND == m_ptarget->GetUnitinfo().eMoveType) range = *m_pattack_range; else range = *m_pair_range; //원거리 if(CMyMath::pos_distance( (m_ptarget)->GetPos() , m_pobj->GetPos()) < range * range) { //공격 범위에 들어오면 m_pobj->Setdir( m_ptarget->GetPos() - m_pobj->GetPos()); if(NULL != m_com_weapon) ((CCom_Weapon*)m_com_weapon)->fire(m_ptarget); m_btarget_search = false; } else if(CMyMath::pos_distance( (m_ptarget)->GetPos() , m_pobj->GetPos()) > (*m_psearch_range)*(*m_psearch_range)) { //추적범위 밖이면 //m_pobj->SetState(IDLE); m_ptarget = NULL; m_target_objid = 0; } } else { //if(OBJ_TURRET == m_pobj->GetOBJNAME()) //if(true == ((CCom_Animation*)m_com_anim)->GetAttack_end()) // m_pobj->SetState(IDLE); } } } void CCom_Guardsearch::Range_update(void) { if(NULL != m_pattack_range && NULL != m_pair_range) { m_irange = max(*m_pattack_range , *m_psearch_range); m_irange = max(m_irange , *m_pair_range); } } void CCom_Guardsearch::Render(void) { } void CCom_Guardsearch::Release(void) { }
18433991d14829c49c77a8837a2aa20aa3bf653c
4b11e312d347bd9d59500e33eecb8d1117b9856d
/Source/DeathVein/DeathVein.cpp
718f6a122bdc60e7ed38324132417e841ca1690d
[]
no_license
Ashishgarg25/DeathVein
17051a57c0448743193a1b7033c8f3d1f816cf3b
a6b380886362c036a5245999392f7aca00ca0f32
refs/heads/master
2021-07-07T11:06:08.877951
2021-04-15T06:44:04
2021-04-15T06:44:04
233,653,602
0
0
null
null
null
null
UTF-8
C++
false
false
203
cpp
DeathVein.cpp
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. #include "DeathVein.h" #include "Modules/ModuleManager.h" IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, DeathVein, "DeathVein" );
9ad66bf5b71857354659d92af8697b62e3e86a13
e91f87b738b4b65b3a73e933dbe4226c94ead77d
/Yodle/qa-challenge.cpp
d6f54e350c738c59af2286fd0c7bc6f41c1e030d
[]
no_license
nsm-lab/JobPuzzles
052546c108e60ead024f897bd4525555eacec82a
d601d3a5016c6717eb3f05dcde4afd2342a422a5
refs/heads/master
2021-04-13T10:48:11.367454
2020-03-22T10:16:50
2020-03-22T10:16:50
249,157,078
2
0
null
null
null
null
UTF-8
C++
false
false
856
cpp
qa-challenge.cpp
// Fourth Floor #include <cstring> #include <cmath> #include <iostream> #include <algorithm> using namespace std; #define N 3 #define MAXX 1000 int coin[N + 1] = {1, 4, 5, 9}; int dp[MAXX + 1]; int greedyCoinCount(int M) { int count = 0; for (int c = N; c >= 0; c--) { int cnt = M / coin[c]; count += cnt; M -= cnt * coin[c]; } return count; } void dpCoinCount() { memset(dp, 0, sizeof dp); for (int i = 1; i <= MAXX; i++) { dp[i] = MAXX; for (int c = N; c >= 0; c--) { if (coin[c] <= i) { int temp = dp[i - coin[c]] + 1; dp[i] = min(dp[i], temp); } } } } int main() { dpCoinCount(); int wrongCount = 0; for (int i = 1; i <= MAXX; i++) { //cout << i << " " << dp[i] << " " << greedyCoinCount(i) << endl; wrongCount += (dp[i] - greedyCoinCount(i)) < 0; } cout << wrongCount << endl; return 0; }
6b24330762850e14684d2e287d2c677b4b4e90fe
61ecf0700b7d0e4616dac490efe7a274f4715e78
/pila.cpp
667cb435ea8b8814750080bafb75ca6ee9afeda2
[]
no_license
iPoe/templates
707de833edbe87e9e1c6f5cbe6861ea6eeced97a
8dc92d7bc20f6f8d71dc68ea3ac149effc4abfe8
refs/heads/master
2021-07-14T15:31:45.233004
2017-10-19T15:49:25
2017-10-19T15:49:25
106,706,424
0
0
null
null
null
null
UTF-8
C++
false
false
748
cpp
pila.cpp
#include <vector> #include <iostream> using namespace std; template <class T> class Pila: public vector<T> { public: Pila(); void adicionar(T elem); T eliminar(); void mostrar(); }; template<class T> Pila<T>::Pila():vector<T>(){} template<class T> void Pila <T>::adicionar(T elem) { this->push_back(elem); } template<class T> void Pila<T>::mostrar() { int n= this->size(); for(int i=0; i<n; i++) cout<<this->at(i)<<", "; cout<<endl; } template <class T> T Pila <T>::eliminar () { int posUltimo = this->size () - 1; T elem = this->at (posUltimo); this->pop_back(); return elem; } int main () { Pila <int> p; p.adicionar (2); p.adicionar (5); p.adicionar (7); p.mostrar (); p.eliminar (); p.mostrar (); }
dfc530e7c1b9378059cdff291d3a0a62a0131ae1
61af2d058ff5b90cbb5a00b5d662c29c8696c8cc
/BZOJ/2002.cpp
0f7d6575694fd05621032b8379d4b62087a78449
[ "MIT" ]
permissive
sshockwave/Online-Judge-Solutions
eac6963be485ab0f40002f0a85d0fd65f38d5182
9d0bc7fd68c3d1f661622929c1cb3752601881d3
refs/heads/master
2021-01-24T11:45:39.484179
2020-03-02T04:02:40
2020-03-02T04:02:40
69,444,295
7
4
null
null
null
null
UTF-8
C++
false
false
1,850
cpp
2002.cpp
#include <iostream> #include <cstdio> #include <cstring> #include <cassert> #define N 200010 #define lson(x) son[x][0] #define rson(x) son[x][1] #define LEFT 0 #define RIGHT 1 #define ROOT -1 using namespace std; inline bool is_num(char c){ return c>='0'&&c<='9'; } inline int next_int(){ int i=0;char c; while(!is_num(c=getchar())); for(;is_num(c);i=i*10-'0'+c,c=getchar()); return i; } int fa[N],son[N][2],size[N],side[N]; inline void push_up(int x){ size[x]=1; if(lson(x)){ size[x]+=size[lson(x)]; } if(rson(x)){ size[x]+=size[rson(x)]; } } inline void rotate(int x){ assert(side[x]!=ROOT); bool r=!side[x]; son[fa[x]][!r]=son[x][r]; if(~son[x][r]){ fa[son[x][r]]=fa[x]; side[son[x][r]]=!r; } son[x][r]=fa[x]; side[x]=side[fa[x]]; side[fa[x]]=r; fa[x]=fa[fa[x]]; fa[son[x][r]]=x; if(~side[x]){ son[fa[x]][side[x]]=x; } push_up(son[x][r]),push_up(x); } inline void splay(int x){ while(side[x]!=ROOT){ if(side[fa[x]]==ROOT){ rotate(x); }else if(side[fa[x]]==side[x]){ rotate(fa[x]),rotate(x); }else{ rotate(x),rotate(x); } } } inline void access(int x){ splay(x); if(~rson(x)){ side[rson(x)]=ROOT; rson(x)=-1; push_up(x); } while(~fa[x]){ splay(fa[x]); if(~rson(fa[x])){ side[rson(fa[x])]=ROOT; } side[x]=RIGHT; rson(fa[x])=x; push_up(fa[x]); rotate(x); } } int main(){ memset(side,ROOT,sizeof(side)); memset(son,-1,sizeof(son)); int n=next_int(); for(int i=0;i<n;i++){ size[i]=1; fa[i]=i+next_int(); if(fa[i]>=n){ fa[i]=-1; } } for(int tot=next_int();tot--;){ if(next_int()==1){ int x=next_int(); access(x); printf("%d\n",size[x]); }else{ int x=next_int(); access(x); if(~lson(x)){ side[lson(x)]=-1; fa[lson(x)]=-1; lson(x)=-1; push_up(x); } fa[x]=x+next_int(); if(fa[x]>=n){ fa[x]=-1; } } } }
fef664d86993f79c15b8f0d5ff11d9fc0557efda
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/media/learning/impl/learning_task_controller_helper.h
ba57eef75ecb93df652bc3bae69f5ba69015e33e
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
4,640
h
learning_task_controller_helper.h
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_LEARNING_IMPL_LEARNING_TASK_CONTROLLER_HELPER_H_ #define MEDIA_LEARNING_IMPL_LEARNING_TASK_CONTROLLER_HELPER_H_ #include <map> #include <memory> #include "base/component_export.h" #include "base/functional/callback.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/task/sequenced_task_runner.h" #include "base/threading/sequence_bound.h" #include "media/learning/common/learning_task_controller.h" #include "media/learning/impl/feature_provider.h" #include "services/metrics/public/cpp/ukm_source_id.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace media { namespace learning { class LearningTaskControllerHelperTest; // Helper class for managing LabelledExamples that are constructed // incrementally. Keeps track of in-flight examples as they're added via // BeginObservation, updated with features from a FeatureProvider, or given a // TargetValue. When examples are complete, it provides them to a callback for // further processing. // // Since both the mojo LearningTaskController and LearningTaskControllerImpl // will need to do almost exactly the same thing, this class handles the common // logic for them. class COMPONENT_EXPORT(LEARNING_IMPL) LearningTaskControllerHelper : public base::SupportsWeakPtr<LearningTaskControllerHelper> { public: // Callback to add labelled examples as training data. using AddExampleCB = base::RepeatingCallback<void(LabelledExample, ukm::SourceId)>; // TODO(liberato): Consider making the FP not optional. LearningTaskControllerHelper(const LearningTask& task, AddExampleCB add_example_cb, SequenceBoundFeatureProvider feature_provider = SequenceBoundFeatureProvider()); virtual ~LearningTaskControllerHelper(); // See LearningTaskController::BeginObservation. void BeginObservation(base::UnguessableToken id, FeatureVector features, absl::optional<ukm::SourceId> source_id); void CompleteObservation(base::UnguessableToken id, const ObservationCompletion& completion); void CancelObservation(base::UnguessableToken id); private: // Record of an example that has been started by RecordObservedFeatures, but // not finished yet. struct PendingExample { // The example we're constructing. LabelledExample example; // Has the FeatureProvider added features? bool features_done = false; // Has the client added a TargetValue? // TODO(liberato): Should it provide a weight with the target value? bool target_done = false; ukm::SourceId source_id = ukm::kInvalidSourceId; }; // [non-repeating int] = example using PendingExampleMap = std::map<base::UnguessableToken, PendingExample>; // Called on any sequence when features are ready. Will call OnFeatureReady // if called on |task_runner|, or will post to |task_runner|. static void OnFeaturesReadyTrampoline( scoped_refptr<base::SequencedTaskRunner> task_runner, base::WeakPtr<LearningTaskControllerHelper> weak_this, base::UnguessableToken id, FeatureVector features); // Called when a new feature vector has been finished by |feature_provider_|, // if needed, to actually add the example. void OnFeaturesReady(base::UnguessableToken example_id, FeatureVector features); // If |example| is finished, then send it to the LearningSession and remove it // from the map. Otherwise, do nothing. void ProcessExampleIfFinished(PendingExampleMap::iterator example); // The task we'll add examples to. LearningTask task_; // Optional feature provider. SequenceBoundFeatureProvider feature_provider_; // All outstanding PendingExamples. PendingExampleMap pending_examples_; // While the handling of |pending_examples_| is an implementation detail, we // still let tests verify the map size, to help catch cases where we forget to // remove things from the map and slowly leak memory. size_t pending_example_count_for_testing() const { return pending_examples_.size(); } scoped_refptr<base::SequencedTaskRunner> task_runner_; // Callback to which we'll send finished examples. AddExampleCB add_example_cb_; friend class LearningTaskControllerHelperTest; }; } // namespace learning } // namespace media #endif // MEDIA_LEARNING_IMPL_LEARNING_TASK_CONTROLLER_HELPER_H_
8bf42604266d808eac717dcb2589ba57b8cc4d62
32fe3b08e89267a05ab0ae8636de094e3f47f71d
/Week_06/980.unique-paths-iii.cpp
3bdd392c6669cee57c6939e0cd4f0bf85717a69e
[]
no_license
luyanfei/algorithm016
eb66e118a8fb517c95cc663f87f600cc7ff06d94
585026fb158fb6fe8737123d66447c305b1e4c51
refs/heads/master
2023-02-08T07:08:53.267872
2020-12-29T02:59:58
2020-12-29T02:59:58
293,283,847
0
0
null
2020-09-06T13:36:03
2020-09-06T13:36:02
null
UTF-8
C++
false
false
3,141
cpp
980.unique-paths-iii.cpp
/* * @lc app=leetcode.cn id=980 lang=cpp * * [980] 最短超级串 * * https://leetcode-cn.com/problems/unique-paths-iii/description/ * * algorithms * Hard (71.55%) * Total Accepted: 8.4K * Total Submissions: 11.7K * Testcase Example: '[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]' * * 在二维网格 grid 上,有 4 种类型的方格: * * * 1 表示起始方格。且只有一个起始方格。 * 2 表示结束方格,且只有一个结束方格。 * 0 表示我们可以走过的空方格。 * -1 表示我们无法跨越的障碍。 * * * 返回在四个方向(上、下、左、右)上行走时,从起始方格到结束方格的不同路径的数目。 * * 每一个无障碍方格都要通过一次,但是一条路径中不能重复通过同一个方格。 * * * * 示例 1: * * 输入:[[1,0,0,0],[0,0,0,0],[0,0,2,-1]] * 输出:2 * 解释:我们有以下两条路径: * 1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2) * 2. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2) * * 示例 2: * * 输入:[[1,0,0,0],[0,0,0,0],[0,0,0,2]] * 输出:4 * 解释:我们有以下四条路径: * 1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2),(2,3) * 2. (0,0),(0,1),(1,1),(1,0),(2,0),(2,1),(2,2),(1,2),(0,2),(0,3),(1,3),(2,3) * 3. (0,0),(1,0),(2,0),(2,1),(2,2),(1,2),(1,1),(0,1),(0,2),(0,3),(1,3),(2,3) * 4. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2),(2,3) * * 示例 3: * * 输入:[[0,1],[2,0]] * 输出:0 * 解释: * 没有一条路能完全穿过每一个空的方格一次。 * 请注意,起始和结束方格可以位于网格中的任意位置。 * * * * * 提示: * * * 1 <= grid.length * grid[0].length <= 20 * * */ class Solution { public: int uniquePathsIII(vector<vector<int>>& grid) { int height = grid.size(), width = grid[0].size(); int startx, starty, blanks = 0; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (grid[i][j] == 1) { startx = i, starty = j; blanks++; } if (grid[i][j] == 0) { blanks++; } } } vector<vector<bool>> visited(height, vector<bool>(width, false)); int pathcount = 0, blankcount = 0; function<void(int, int)> dfs = [&] (int row, int col) { if (row < 0 || row >= height || col < 0 || col >= width || visited[row][col] || grid[row][col] == -1) { return; } if (grid[row][col] == 2) { if (blankcount == blanks) pathcount++; return; } blankcount++; visited[row][col] = true; dfs(row - 1, col); dfs(row + 1, col); dfs(row, col - 1); dfs(row, col + 1); visited[row][col] = false; blankcount--; }; dfs(startx, starty); return pathcount; } };
739b95a58f4993b6b4049ae453fc22ec99b1ab3a
605af3aaf3367ec4873aa2bbfac0ef75a18cdc29
/1080 - Binary Simulation.cpp
aab2af6afa1bfaa40b32a6d8f775a890121f47af
[]
no_license
SysCall97/my-lightOj-solutions
2ad4648b41120c4e8446a992d068c7de8227dec5
7cc4a2a24ebbd308d704f800e9c9539123e41563
refs/heads/master
2023-01-03T14:29:50.944052
2020-10-27T04:53:57
2020-10-27T04:53:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,617
cpp
1080 - Binary Simulation.cpp
/*************************************************************** * Name: KAZI NUR ALAM MASHRY * * School: MAWLANA BHASHANI SCIENCE & TECHNOLOGY UNIVERSITY * * CSE (14TH BATCH) * ***************************************************************/ #include<bits/stdc++.h> #define INF 0x3f3f3f3f #define el '\n' #define x first #define y second #define pi acos(-1.0) #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define mem(x,y) memset(x , y , sizeof(x)) using namespace std; typedef long long ll; typedef pair<ll, ll> PI; const int mx=1e5; ll lazy[5*mx+10]; void update(ll startRange, ll endRange, ll node, ll b, ll e) { ll left = 2*node+1, right = left+1; if(lazy[node]>0 && b!=e) { lazy[left] += lazy[node]; lazy[right] += lazy[node]; lazy[node] = 0; } if(startRange>e || endRange<b) return; if((startRange<=b && endRange>=e)) { lazy[node]++; return; } if(b!=e) { ll mid = (b+e)/2; update(startRange, endRange, left, b, mid); update(startRange, endRange, right, mid+1, e); } return; } ll getChanges(ll pos, ll node, ll b, ll e) { if(b==e && b==pos) return lazy[node]; ll left = 2*node+1, right = left+1; if(lazy[node]>0 && b!=e) { lazy[left] += lazy[node]; lazy[right] += lazy[node]; lazy[node] = 0; } ll mid = (b+e)/2; if(b!=e) { if(b<=pos && mid>=pos) return getChanges(pos, left, b, mid); else return getChanges(pos, right, mid+1, e); } } void solve(string& str, ll pos, ll sz) { ll changes = getChanges(pos, 0, 0, sz); if(changes%2) { if(str[pos]=='1') printf("0\n"); else printf("1\n"); } else printf("%c\n", str[pos]); return; } int main() { ll t,n, i, j, sz; char ch, c; scanf("%lld", &t); for(ll C=1; C<=t; ++C) { c = getchar(); string inp; getline(cin, inp); scanf("%lld", &n); printf("Case %lld:\n", C); sz = inp.size()-1; mem(lazy, 0); for(ll x=0; x<n; ++x) { c = getchar(); scanf("%c", &ch); if(ch=='Q') { scanf("%lld", &i); solve(inp, i-1, sz); } else { scanf("%lld%lld", &i, &j); update(i-1, j-1, 0, 0, sz); } } } return 0; }
db1d3a584f8982f2cb356a39b2d74400d0d6ce56
c89384190bbfb8742e854694f8c841354916ecaf
/bt6.cpp
c368f12bbf400eefaba993fa08c37e14baa30419
[]
no_license
chungtran1803199/Tran_Minh_Chung
eeee959536f61900fb3f43ebb9edf19ab37b1d7c
1689777e612646fe534228253a75fee1bd73ea51
refs/heads/master
2020-03-14T18:23:31.322184
2018-05-01T17:11:22
2018-05-01T17:11:22
131,740,237
0
0
null
null
null
null
UTF-8
C++
false
false
1,809
cpp
bt6.cpp
#include<iostream> #include<iomanip> #include<conio.h> using namespace std; class employee{ class date{ int day, month, year; char c; public: void getdate(){ cout<<"Enter date in [12/31/97] format: "; cin >>day>>c>>month>>c>>year;} void showdate() const { cout<<setw(10)<<day<<c<<month<<c<<year;}}; int emp_num; float emp_comp; date y; char *ret; enum etype { laborer, secretary, manager, accountant, executive, researcher }; public: void putemploy(int en, float ec); void getemploy() const { cout<<setw(15)<<emp_num<<setw(25)<<emp_comp<<setw(15)<<ret; y.showdate(); cout<<endl; }}; void employee::putemploy(int en, float ec){ emp_num=en; emp_comp=ec; etype x; y.getdate(); cout<<"Enter employee type (first letter only)"<<endl <<"(laborer, secretary, manager, accountant, executive, researcher): "; switch(getche()){ case 'l': x=laborer ; break; case 's': x=secretary ; break; case 'm': x=manager ; break; case 'a': x=accountant; break; case 'e': x=executive ; break; case 'r': x=researcher;} switch(x){ case 0: ret = "laborer" ; break; case 1: ret = "secretary" ; break; case 2: ret = "manager" ; break; case 3: ret = "accountant"; break; case 4: ret = "executive" ; break; case 5: ret = "researcher"; break; default: ret = "Undefined";}} int main() { employee x[3]; int a; float b; do{ for(int i=0; i<3;){ cout<<"\nEnter the employee "<<++i<<" number : "; cin>>a; cout<<"Enter the employee "<< i<<" compensation: "; cin>>b; x[i-1].putemploy(a, b);} cout<<endl<<setw(15)<<"employees number" <<setw(25)<<"employee's compensation" <<setw(15)<<"Employee type" <<setw(15)<<"Date\n"; for(int j=0; j<3; j++) { x[j].getemploy();} cout<<"\n\n !Press c to continue or any key to exit."<<endl<<endl; }while(getch()=='c'); }
25456299c4e55b8e6f1f80190f33e0156291ba53
c6769a12358e53c52fddfdcacb78344d446b1771
/CastorTree/Analyzer/HistoRetriever.h
22b3bfd9d9169e326447e18a72ff32c1e54dad7b
[]
no_license
xueweiphy/UACastor
d8717970b9843adc79513b51ea4c8294d89e40f3
91893bfb195ecd980b2afaf28e3fa045bca35745
refs/heads/master
2020-12-25T21:13:41.178545
2012-11-06T09:57:22
2012-11-06T09:57:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
279
h
HistoRetriever.h
#ifndef HistoRetriever_h #define HistoRetriever_h #include <TString.h> #include <TObjArray.h> #include <TH1F.h> class HistoRetriever { public: HistoRetriever(); virtual ~HistoRetriever(); std::vector<TH1F*> getHistos(TString inputfile); private: }; #endif
e0693ccf13ae7ef1e06f728773d9039873794a7c
18078cd63b43d895f3e08b1f12eae019eef89303
/BattleSimulator/BattleSimulator/ability.h
14b4363e8d573857d75ee0dd0183a534f7235ec1
[]
no_license
RynsArgent/ProjectOgre
0980e42649c7591993826f8e336135e787c99971
0d0daa23c48fee6cca38fe1e11e78141745edb62
refs/heads/master
2016-09-10T21:38:16.021507
2013-10-19T05:38:54
2013-10-19T05:38:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
38,933
h
ability.h
#ifndef __ABILITY_H__ #define __ABILITY_H__ #include "pch.h" #include "action.h" #include <fstream> #include <vector> // To add an ability: // -go to pch.h and add the ability to the Skill enum // -go to ability.h and create the new derived class for the Skill // -go to ability.cpp and update the toStringSkill (NO NEED TO ATM) // -go to ability.cpp and update the getAbility to instantiate the new object for skill // -go to ability.cpp and write the logic in the execute function // Base class for abilities class Ability : public Action { protected: bool basic; // Tells whether this ability is programmed to be set as a response ability (counterattack) bool respondable; // Determines whether this ability can be followed with a counterattack bool interruptible; // Determines whether an ability can be cancelled int cost; // Can perhaps later be AP cost // Variables that depend on the unit during the execution of an ability bool cancelled; public: static string toStringSkill(Skill skill); static Ability* getAbility(Skill skill); static Skill selectSkill(Unit* unit); static bool isAbleToRespond(Battle* battle, Ability* previous, Unit* prevSource, Ability* current, Unit* curSource); Ability(const string & name, ActionType act, AbilityType type, bool basic, bool respondable, bool interruptible, int cost) : Action(name, act, type), respondable(respondable), basic(basic), interruptible(interruptible), cost(cost), cancelled(false) { } // Most abilities will have their logic implemented in this function virtual void action(Ability* previous, Unit* current, Battle* battle); bool isRespondable() const { return respondable; } void setRespondable(bool value) { respondable = value; } bool isInterruptible() const { return interruptible; } void setInterruptible(bool value) { interruptible = value; } bool isCancelled() const { return cancelled; } void setCancelled(bool value) { cancelled = value; } // This is used to check whether the unit is stunned, sleep, fleeing, ect. // Because if the unit is, the ability is probably cancelled bool checkpoint(Unit* current); virtual void print(ostream& out) const; ~Ability(); }; class NoSkill : public Ability { protected: static const ActionType ACT = ACTION_NONE; static const AbilityType TYPE = ABILITY_NONE; static const bool BASIC = true; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: NoSkill() : Ability("No Skill", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle) { } ~NoSkill() {} }; class HundredBlades : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: HundredBlades() : Ability("Hundred Blades", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~HundredBlades() {} }; class Block : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Block() : Ability("Block", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Block() {} }; class Strike : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = true; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Strike() : Ability("Strike", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Strike() {} }; class Taunt : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Taunt() : Ability("Taunt", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Taunt() {} }; class BattleShout : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: BattleShout() : Ability("Battle Shout", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~BattleShout() {} }; class Shoot : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = true; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Shoot() : Ability("Shoot", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Shoot() {} }; class Haste : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Haste() : Ability("Haste", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Haste() {} }; class Scope : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Scope() : Ability("Scope", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Scope() {} }; class TangleTrap : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: TangleTrap() : Ability("Tangle Trap", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~TangleTrap() {} }; class Mend : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Mend() : Ability("Mend", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Mend() {} }; class Heal : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Heal() : Ability("Heal", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Heal() {} }; class Cleanse : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Cleanse() : Ability("Cleanse", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Cleanse() {} }; class Dispel : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Dispel() : Ability("Dispel", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Dispel() {} }; class Regeneration : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Regeneration() : Ability("Regeneration", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Regeneration() {} }; class Blind : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Blind() : Ability("Blind", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Blind() {} }; class Flash : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Flash() : Ability("Flash", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Flash() {} }; class Barrier : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Barrier() : Ability("Barrier", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Barrier() {} }; class Polymorph : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Polymorph() : Ability("Polymorph", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Polymorph() {} }; class ArcaneBolt : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = true; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ArcaneBolt() : Ability("Arcane Bolt", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ArcaneBolt() {} }; class Fireball : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Fireball() : Ability("Fireball", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Fireball() {} }; class WaterJet : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: WaterJet() : Ability("Water Jet", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~WaterJet() {} }; class AcidDart : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: AcidDart() : Ability("Acid Dart", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~AcidDart() {} }; class FrostShard : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: FrostShard() : Ability("Frost Shard", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~FrostShard() {} }; class LightningBolt : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: LightningBolt() : Ability("Lightning Bolt", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~LightningBolt() {} }; class Slash : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Slash() : Ability("Slash", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Slash() {} }; class Provoke : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Provoke() : Ability("Provoke", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Provoke() {} }; class DemoralizingShout : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: DemoralizingShout() : Ability("Demoralizing Shout", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~DemoralizingShout() {} }; class Charge : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Charge() : Ability("Charge", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Charge() {} }; class Rally : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Rally() : Ability("Rally", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Rally() {} }; class Challenge : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Challenge() : Ability("Challenge", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Challenge() {} }; class Flurry : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Flurry() : Ability("Flurry", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Flurry() {} }; class PowerAttack : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: PowerAttack() : Ability("Power Attack", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~PowerAttack() {} }; class Lasso : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Lasso() : Ability("Lasso", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Lasso() {} }; class Piercethrough : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Piercethrough() : Ability("Piercethrough", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Piercethrough() {} }; class Feint : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Feint() : Ability("Feint", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Feint() {} }; class VenomousStrike : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: VenomousStrike() : Ability("Venomous Strike", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~VenomousStrike() {} }; class CripplingShot : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: CripplingShot() : Ability("Crippling Shot", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~CripplingShot() {} }; class ConfuseTrap : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ConfuseTrap() : Ability("Confuse Trap", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ConfuseTrap() {} }; class HuntersMark : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: HuntersMark() : Ability("Hunter's Mark", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~HuntersMark() {} }; class TranquilizingShot : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: TranquilizingShot() : Ability("Tranquilizing Shot", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~TranquilizingShot() {} }; class CharmTrap : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: CharmTrap() : Ability("Charm Trap", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~CharmTrap() {} }; class QuickNock : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: QuickNock() : Ability("Quick Nock", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~QuickNock() {} }; class RapidShot : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: RapidShot() : Ability("Rapid Shot", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~RapidShot() {} }; class Volley : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Volley() : Ability("Volley", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Volley() {} }; class Snipe : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_RANGE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Snipe() : Ability("Snipe", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Snipe() {} }; class Reformation : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = true; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Reformation() : Ability("Reformation", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Reformation() {} }; class Lullaby : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Lullaby() : Ability("Lullaby", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Lullaby() {} }; class BalladOfHeroes : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: BalladOfHeroes() : Ability("Ballad Of Heroes", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~BalladOfHeroes() {} }; class RequiemOfWar : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: RequiemOfWar() : Ability("Requiem of War", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~RequiemOfWar() {} }; class Banish : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Banish() : Ability("Banish", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Banish() {} }; class GreaterHeal : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: GreaterHeal() : Ability("Greater Heal", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~GreaterHeal() {} }; class Raise : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Raise() : Ability("Raise", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Raise() {} }; class LightningKicks : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: LightningKicks() : Ability("Lightning Kicks", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~LightningKicks() {} }; class HurricaneKick : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: HurricaneKick() : Ability("Hurricane Kick", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~HurricaneKick() {} }; class Roundhouse : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Roundhouse() : Ability("Roundhouse", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Roundhouse() {} }; class LegSweep : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MELEE; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: LegSweep() : Ability("Leg Sweep", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~LegSweep() {} }; class Blink : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Blink() : Ability("Blink", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Blink() {} }; class ArcaneMissil : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ArcaneMissil() : Ability("Arcane Missil", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ArcaneMissil() {} }; class Waterblast : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Waterblast() : Ability("Waterblast", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Waterblast() {} }; class Flamestrike : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Flamestrike() : Ability("Flamestrike", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Flamestrike() {} }; class Icicle : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Icicle() : Ability("Icicle", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Icicle() {} }; class ElectricCurtain : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ElectricCurtain() : Ability("Electric Curtain", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ElectricCurtain() {} }; class Rockslide : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = true; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Rockslide() : Ability("Rockslide", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Rockslide() {} }; class Fascination : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Fascination() : Ability("Fascination", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Fascination() {} }; class StunWave : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: StunWave() : Ability("Stun Wave", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~StunWave() {} }; class NoxiousSpores : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: NoxiousSpores() : Ability("Noxious Spores", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~NoxiousSpores() {} }; class ParalyticCloud : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ParalyticCloud() : Ability("Paralytic Cloud", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ParalyticCloud() {} }; class SleepMiasma : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: SleepMiasma() : Ability("Sleep Miasma", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~SleepMiasma() {} }; class ChillingFog : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ChillingFog() : Ability("Chilling Fog", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ChillingFog() {} }; class DisorientingMist : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: DisorientingMist() : Ability("Disorienting Mist", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~DisorientingMist() {} }; class Enervate : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Enervate() : Ability("Enervate", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Enervate() {} }; class NaturesGrasp : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_ATTACK_MAGIC; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: NaturesGrasp() : Ability("Nature's Grasp", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~NaturesGrasp() {} }; class NaturesEmbrace : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: NaturesEmbrace() : Ability("Nature's Embrace", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~NaturesEmbrace() {} }; class ManaTree : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: ManaTree() : Ability("Mana Tree", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~ManaTree() {} }; class Tranquility : public Ability { protected: static const ActionType ACT = ABILITY_STANDARD; static const AbilityType TYPE = ABILITY_SPECIAL; static const bool BASIC = false; static const bool RESPONDABLE = false; static const bool INTERRUPTIBLE = true; static const int COST = 1; public: Tranquility() : Ability("Tranquility", ACT, TYPE, BASIC, RESPONDABLE, INTERRUPTIBLE, COST) {} virtual void action(Ability* previous, Unit* current, Battle* battle); ~Tranquility() {} }; #endif
fa09da93e5fbc32264cd7aa13055dfdfdb15b17d
b246e43a0a17579c27d2ee298a7262b4ec8657d0
/include/Camera.hpp
e0cfc33079791f5057e1afa726c692210d731d81
[]
no_license
felipeluzz/CG_UFPel
3686c3ec2b922cadcab07f07036ac74094ab0b66
247a5134473e0526ee944c74b0f14bf996b786f3
refs/heads/master
2020-09-26T21:53:23.004249
2017-03-20T01:04:03
2017-03-20T01:04:03
82,872,461
0
1
null
null
null
null
ISO-8859-1
C++
false
false
2,132
hpp
Camera.hpp
#ifndef CAMERA_H #define CAMERA_H #define ANIMSTEP 40 // Include standard headers #include <stdio.h> #include <stdlib.h> #include <vector> #include <iostream> #include <algorithm> #include <string> #include <set> #include <iterator> #include <stack> #include <queue> // Include GLEW #include <GL/glew.h> // Include GLFW #include <glfw3.h> // Include AntTweakBar #include <AntTweakBar.h> // Include GLM #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtx/transform2.hpp> #include <shader.hpp> #include <texture.hpp> #include <controls.hpp> #include <objloader.hpp> #include <vboindexer.hpp> #include <glerror.hpp> #include <meshSimplification.hpp> struct transformC { double x; double y; double z; double p1; double p2; double p3; float angle; // 0: Translação | 1: Escala | 2: Rotação | 3: Look At | 4: Rotação em um ponto | 5: Linear | 6: B-Spline | 7: Bézier unsigned short transformationID; }; //Classe que contém a câmera class camera { public: GLuint ViewMatrixID; GLuint ModelMatrixID; glm::mat4 ProjectionMatrix; glm::mat4 transformation; glm::mat4 ViewMatrix; std::queue <struct transformC> transformationQueue; std::queue <struct transformC> animationQueue; int flagR = 0; public: camera(GLuint programID) { ViewMatrixID = glGetUniformLocation(programID, "V"); ModelMatrixID = glGetUniformLocation(programID, "M"); transformation = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f,0.0f,20.0f) * glm::vec3(-1)); ProjectionMatrix = getProjectionMatrix() * transformation; ViewMatrix = getViewMatrix(); } camera(float fieldOfView, float aspectRatio, float near, float far, glm::vec3 cameraPosition, glm::vec3 upVector, glm::vec3 sightDirection, GLuint programID) { ProjectionMatrix = glm::perspective(fieldOfView, aspectRatio, near, far); ViewMatrix = glm::lookAt(cameraPosition, cameraPosition + sightDirection, upVector); ViewMatrixID = glGetUniformLocation(programID, "V"); } void bind(); int setTransformation(float seconds); void addTransformation(struct transformC); int animate(); glm::vec3 NaraujoNoise(); }; #endif
07d4044d8707cdad4035874052b082cfe0c89351
3b893cd712e3057712372ee72b74cf2a0a307707
/Lonely/Lonely/Game/Scene/GameScene/UI/UIBattery.cpp
13319f2f15f8ebf009592c680a30d276933fca1e
[]
no_license
human-osaka-game-2018/Lonely
9b80f11d06099d3c14935d9212f33084e69dad0f
b3fa7231ed0599b3e5c111d8e480bb174dd52568
refs/heads/master
2020-04-02T16:49:10.557991
2019-04-19T08:37:20
2019-04-19T08:41:00
154,630,062
0
0
null
2019-05-02T06:07:40
2018-10-25T07:42:55
C++
UTF-8
C++
false
false
1,147
cpp
UIBattery.cpp
/** * @file UIBattery.cpp * @brief UIBatteryクラスのソースファイル * @author shion-sagawa */ #include "UIBattery.h" #include "GameLib.h" UIBattery::UIBattery() { Initialize(); } UIBattery::~UIBattery() { Finalize(); } //初期化する bool UIBattery::Initialize() { float WINDOW_WIDTH = static_cast<float>(WINDOW->GetWidth()); float WINDOW_HEIGHT = static_cast<float>(WINDOW->GetHeight()); //頂点情報を設定 HELPER_2D->SetVerticesFromLeftTopType(m_vertices, 150.f, WINDOW_HEIGHT - 90.f, 400.f, 35.f); return true; } //解放する void UIBattery::Finalize() { m_texture.Finalize(); } void UIBattery::Update() { } void UIBattery::Render() { IDirect3DDevice9* pDevice = GameLib::Instance.GetDirect3DDevice(); DirectX* pDirectX = GameLib::Instance.GetDirectX(); //頂点に入れるデータを設定 pDevice->SetFVF(FVF_SIMPLE_TEX_2D); //テクスチャの設定 pDevice->SetTexture(0, m_texture.GetD3DTexture()); //描画 pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, m_vertices, sizeof(Simple2DVertex)); //充電が何%かを描画する DEBUGFONT->DrawText(50, 680, 0xffffffff, "100%"); }
edcf7a612c8a44aa107efaea9c46dc549459d01d
dfcb0d2e6e2aa1dc4379eaddd6c8abfa7e482cd8
/cdk/apps/tuxbox/enigma/lib/picviewer/fb_display.cpp
4ed1c094ef74aaead0e8aa2ccf7bd324a5490955
[]
no_license
OpenPLi/OpenPLi-1
94f6ee4d22ca5184aedfb289b398723223384fce
43832e5c88a2f3dd02323911725621a2335e3afd
refs/heads/master
2021-03-22T01:27:09.930611
2018-01-27T00:00:54
2018-01-27T00:00:54
39,523,362
7
11
null
2017-07-19T18:00:01
2015-07-22T18:32:00
C++
UTF-8
C++
false
false
11,492
cpp
fb_display.cpp
#ifndef DISABLE_FILE #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <linux/fb.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #include <asm/types.h> #include <string.h> #include <errno.h> #include "fb_display.h" #include <lib/picviewer/pictureviewer.h> #include <lib/gdi/fb.h> #include <lib/system/info.h> #include <lib/base/eerror.h> /* * FrameBuffer Image Display Function * (c) smoku/2000 * */ /* Public Use Functions: * * extern void fb_display(unsigned char *rgbbuff, * int x_size, int y_size, * int x_pan, int y_pan, * int x_offs, int y_offs, * int winx, int winy); * * extern void getCurrentRes(int *x,int *y); * */ typedef unsigned int uint32_t; unsigned short red[256], green[256], blue[256], transp[256]; struct fb_cmap map332 = {0, 256, red, green, blue, transp}; unsigned short red_b[256], green_b[256], blue_b[256], transp_b[256]; struct fb_cmap map_back = {0, 256, red_b, green_b, blue_b, transp_b}; unsigned char *lfb = 0; //////////// YUV framebuffer support /////////////////// int yuv_initialized; unsigned short lut[3 * (NR_RED + NR_GREEN + NR_BLUE) ]; void build_yuv_lut(void) { int i; for (i=0; i<NR_RED; ++i) { int r = i * 256 / NR_RED; lut_r_y[i] = Y(r, 0, 0); lut_r_u[i] = U(r, 0, 0); lut_r_v[i] = V(r, 0, 0); } for (i=0; i<NR_GREEN; ++i) { int g = i * 256 / NR_GREEN; lut_g_y[i] = Y(0, g, 0); lut_g_u[i] = U(0, g, 0); lut_g_v[i] = V(0, g, 0); } for (i=0; i<NR_BLUE; ++i) { int b = i * 256 / NR_BLUE; lut_b_y[i] = Y(0, 0, b); lut_b_u[i] = U(0, 0, b); lut_b_v[i] = V(0, 0, b); } } void clear_yuv_fb() { unsigned char *dest = lfb; for (int i=0; i < 720*576; ++i) { unsigned char r = 0; unsigned char g = 0; unsigned char b = 0; dest[0] = (lut_r_y[r] + lut_g_y[g] + lut_b_y[b]) >> 8; if (i & 1) dest[720*576] = ((lut_r_u[r] + lut_g_u[g] + lut_b_u[b]) >> 8) + 128; else dest[720*576] = ((lut_r_v[r] + lut_g_v[g] + lut_b_v[b]) >> 8) + 128; ++dest; } } void blit_to_yuv_fb(int x_pos, int y_pos, int x_size, int y_size, unsigned char *source) { for (int y=y_pos; y < y_pos+y_size; ++y) { unsigned char *dest = lfb + y * 720 + x_pos; int x=x_pos; while(x < x_pos+x_size) { unsigned char r = *(source++); unsigned char g = *(source++); unsigned char b = *(source++); dest[0] = (lut_r_y[r] + lut_g_y[g] + lut_b_y[b]) >> 8; if (x & 1) dest[720*576] = ((lut_r_v[r] + lut_g_v[g] + lut_b_v[b]) >> 8) + 128; else dest[720*576] = ((lut_r_u[r] + lut_g_u[g] + lut_b_u[b]) >> 8) + 128; ++dest; ++x; } } } /////////////////// YUV end ///////////////////////////// int openFB(const char *name); //void closeFB(int fh); //void getVarScreenInfo(int fh, struct fb_var_screeninfo *var); //void setVarScreenInfo(int fh, struct fb_var_screeninfo *var); void getFixScreenInfo(struct fb_fix_screeninfo *fix); void set332map(); void blit2FB(void *fbbuff, unsigned int pic_xs, unsigned int pic_ys, unsigned int scr_xs, unsigned int scr_ys, unsigned int xp, unsigned int yp, unsigned int xoffs, unsigned int yoffs, unsigned int winx, unsigned int winy, int cpp); void clearFB(int bpp, int cpp, int trans); inline unsigned short make16color(uint32_t r, uint32_t g, uint32_t b, uint32_t rl, uint32_t ro, uint32_t gl, uint32_t go, uint32_t bl, uint32_t bo, uint32_t tl, uint32_t to); void fb_display(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, int winx, int winy) { struct fb_var_screeninfo *var; unsigned short *fbbuff = NULL; int bp = 0; if (rgbbuff == NULL) return; /* read current video mode */ var = fbClass::getInstance()->getScreenInfo(); lfb = fbClass::getInstance()->lfb; /* correct panning */ if (x_pan > x_size - (int)var->xres) x_pan = 0; if (y_pan > y_size - (int)var->yres) y_pan = 0; /* correct offset */ if (x_offs + x_size > (int)var->xres) x_offs = 0; if (y_offs + y_size > (int)var->yres) y_offs = 0; bool yuv_fb = eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM600PVR || eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM500PLUS; if (!yuv_fb || var->bits_per_pixel < 16) { /* blit buffer 2 fb */ fbbuff = (unsigned short *) convertRGB2FB(rgbbuff, x_size * y_size, var->bits_per_pixel, &bp); if (fbbuff == NULL) return; /* ClearFB if image is smaller */ if (x_size < (int)var->xres || y_size < (int)var->yres) clearFB(var->bits_per_pixel, bp, 0xFF); blit2FB(fbbuff, x_size, y_size, var->xres, var->yres, x_pan, y_pan, x_offs, y_offs, winx, winy, bp); free(fbbuff); } else { if (yuv_fb && var->bits_per_pixel == 16) { if (!yuv_initialized) { build_yuv_lut(); yuv_initialized=1; } if (x_size < (int)var->xres || y_size < (int)var->yres) clear_yuv_fb(); blit_to_yuv_fb(x_offs, y_offs, x_size, y_size, rgbbuff); } } } void getCurrentRes(int *x, int *y) { struct fb_var_screeninfo *var; if (fbClass::getInstance()) { var = fbClass::getInstance()->getScreenInfo(); *x = var->xres; *y = var->yres; } else { *x = 720; *y = 576; } } void make332map(struct fb_cmap *map) { int rs, gs, bs, i; int r = 8, g = 8, b = 4; map->start = 0; map->len = 256; map->red = red; map->green = green; map->blue = blue; map->transp = transp; rs = 256 / (r - 1); gs = 256 / (g - 1); bs = 256 / (b - 1); for (i = 0; i < 256; i++) { map->red[i] = (rs * ((i / (g * b)) % r)) << 8 ; map->green[i] = (gs * ((i / b) % g)) << 8 ; map->blue[i] = (bs * ((i) % b)) << 8; map->transp[i] = 0; } } /* void set8map(int fh, struct fb_cmap *map) { if (ioctl(fh, FBIOPUTCMAP, map) < 0) { fprintf(stderr, "Error putting colormap"); exit(1); } } void get8map(int fh, struct fb_cmap *map) { if (ioctl(fh, FBIOGETCMAP, map) < 0) { fprintf(stderr, "Error getting colormap"); exit(1); } } */ void set332map() { make332map(&map332); fbClass::getInstance()->paletteSet(&map332); } void blit2FB(void *fbbuff, unsigned int pic_xs, unsigned int pic_ys, unsigned int scr_xs, unsigned int scr_ys, unsigned int xp, unsigned int yp, unsigned int xoffs, unsigned int yoffs, unsigned int winx, unsigned int winy, int cpp) { int i, xc, yc; unsigned char *cp; unsigned short *sp; unsigned int *ip; ip = (unsigned int *) fbbuff; sp = (unsigned short *) ip; cp = (unsigned char *) sp; xc = (winx > scr_xs) ? scr_xs : winx; yc = (winy > scr_ys) ? scr_ys : winy; unsigned int stride = fbClass::getInstance()->Stride(); // eDebug("[pictview_blit2FB] cpp=%d stride=%u, pic_x=%u, pic_y=%u scr_x=%u, scr_y=%u, xp=%u, yp=%u, xoffs=%u, yoffs=%u, size=%dk\n", cpp, stride, pic_xs, pic_ys, scr_xs, scr_ys, xp, yp, xoffs, yoffs, xc*yc*cpp/1024); switch(cpp) { case 1: set332map(); for (i = 0; i < yc; i++) { memcpy(lfb + (i + yoffs) * stride + xoffs, cp + (i + yp) * pic_xs + xp, xc); } break; case 2: for (i = 0; i < yc; i++) { memcpy(lfb + (i + yoffs) * stride + xoffs * cpp, sp + (i + yp) * pic_xs + xp, xc * cpp); } break; case 4: for (i = 0; i < yc; i++) { memcpy(lfb + (i + yoffs) * stride + xoffs * cpp, ip + (i + yp) * pic_xs + xp, xc * cpp); } break; } // eDebug("[pictview_blit2FB] done"); } void clearFB(int bpp, int cpp, int trans) { int x, y; getCurrentRes(&x, &y); unsigned int stride = fbClass::getInstance()->Stride(); // eDebug("[clearFB] x=%d, y=%d, bpp=%d, cpp=%d, stride=%u", x, y, bpp, cpp, stride); switch(cpp) { case 2: { uint32_t rl, ro, gl, go, bl, bo, tl, to; unsigned int i; struct fb_var_screeninfo *var; var = fbClass::getInstance()->getScreenInfo(); rl = (var->red).length; ro = (var->red).offset; gl = (var->green).length; go = (var->green).offset; bl = (var->blue).length; bo = (var->blue).offset; tl = (var->transp).length; to = (var->transp).offset; short black = make16color(0, 0, 0, rl, ro, gl, go, bl, bo, tl, to); unsigned short *s_fbbuff = (unsigned short *) malloc(y * stride / 2 * sizeof(unsigned short)); if (s_fbbuff == NULL) { printf("Error: malloc\n"); return; } for (i = 0; i < y * stride / 2; i++) s_fbbuff[i] = black; memcpy(lfb, s_fbbuff, y*stride); free(s_fbbuff); break; } case 4: int i; __u32 *dstp = (__u32*)lfb; trans = (trans & 0xFF) << 24; for (i = 0; i < x; i++) *dstp++ = trans; __u8 *dstptr = lfb; dstptr += stride; for (i = 1; i < y; i++) { memcpy(dstptr, lfb, stride); dstptr += stride; } break; default: memset(lfb, 0, stride * y); } } inline unsigned char make8color(unsigned char r, unsigned char g, unsigned char b) { return ( (((r >> 5) & 7) << 5) | (((g >> 5) & 7) << 2) | ((b >> 6) & 3)); } inline unsigned short make15color(unsigned char r, unsigned char g, unsigned char b) { return ( (((b >> 3) & 31) << 10) | (((g >> 3) & 31) << 5) | ((r >> 3) & 31)); } inline unsigned short make16color(uint32_t r, uint32_t g, uint32_t b, uint32_t rl, uint32_t ro, uint32_t gl, uint32_t go, uint32_t bl, uint32_t bo, uint32_t tl, uint32_t to) { return ( // ((0xFF >> (8 - tl)) << to) | ((r >> (8 - rl)) << ro) | ((g >> (8 - gl)) << go) | ((b >> (8 - bl)) << bo)); } void* convertRGB2FB(unsigned char *rgbbuff, unsigned long count, int bpp, int *cpp) { unsigned long i; void *fbbuff = NULL; unsigned char *c_fbbuff; unsigned short *s_fbbuff; unsigned int *i_fbbuff; uint32_t rl, ro, gl, go, bl, bo, tl, to; struct fb_var_screeninfo *var; var = fbClass::getInstance()->getScreenInfo(); rl = (var->red).length; ro = (var->red).offset; gl = (var->green).length; go = (var->green).offset; bl = (var->blue).length; bo = (var->blue).offset; tl = (var->transp).length; to = (var->transp).offset; // eDebug("[convertRGB2FB] bpp=%d count=%lu", bpp, count); switch(bpp) { case 8: *cpp = 1; c_fbbuff = (unsigned char *) malloc(count * sizeof(unsigned char)); if (c_fbbuff == NULL) { eDebug("picviewer: convertRGB Error: malloc"); return NULL; } for (i = 0; i < count; i++) c_fbbuff[i] = make8color(rgbbuff[i * 3], rgbbuff[i * 3 + 1], rgbbuff[i * 3 + 2]); fbbuff = (void *)c_fbbuff; break; case 15: *cpp = 2; s_fbbuff = (unsigned short *)malloc(count * sizeof(unsigned short)); if (s_fbbuff == NULL) { eDebug("picviewer: convertRGB Error: malloc"); return NULL; } for (i = 0; i < count; i++) s_fbbuff[i] = make15color(rgbbuff[i * 3], rgbbuff[i * 3 + 1], rgbbuff[i * 3 + 2]); fbbuff = (void *) s_fbbuff; break; case 16: *cpp = 2; s_fbbuff = (unsigned short *)malloc(count * sizeof(unsigned short)); if (s_fbbuff == NULL) { eDebug("picviewer: convertRGB Error: malloc"); return NULL; } for (i = 0; i < count; i++) s_fbbuff[i] = make16color(rgbbuff[i * 3], rgbbuff[i * 3 + 1], rgbbuff[i * 3 + 2], rl, ro, gl, go, bl, bo, tl, to); fbbuff = (void *)s_fbbuff; break; case 24: case 32: *cpp = 4; i_fbbuff = (unsigned int *) malloc(count * sizeof(unsigned int)); if (i_fbbuff == NULL) { eDebug("picviewer: convertRGB Error: malloc"); return NULL; } for (i = 0; i < count; i++) i_fbbuff[i] = 0xFF000000 | ((rgbbuff[i * 3] << 16) & 0xFF0000) | ((rgbbuff[i * 3 + 1] << 8) & 0xFF00) | (rgbbuff[i * 3 + 2] & 0xFF); fbbuff = (void *) i_fbbuff; break; default: eDebug("[convertRGB2FB] unknown colordepth %d. Quitting", bpp); return NULL; } // eDebug("[convertRGB2FB] done"); return fbbuff; } #endif
374bf8161b2f077c9ea7671100f68e02845becd7
3fb01b66b695d57871ce33328c494669a97276e5
/src/simple_uv/md5.cpp
de0d6fb3a928f0810cfc34b10ab356db94009424
[]
no_license
HONGJICAI/coflow_in_hrrn
21cfa3265eb37fbb75e0e9a725901f5e3bdb7465
4d07edf52ad40ae2f8a2cd66556c363b36eab91e
refs/heads/master
2020-03-13T20:18:47.998815
2018-05-21T14:57:47
2018-05-21T14:57:47
131,271,237
0
0
null
null
null
null
UTF-8
C++
false
false
8,035
cpp
md5.cpp
#include <string.h> #include <stdio.h> #include "md5.h" // #define MD5_LONG unsigned long // #define MD5_CBLOCK 64 // #define MD5_LBLOCK (MD5_CBLOCK/4) // #define MD5_DIGEST_LENGTH 16 #define MD32_REG_T long #define DATA_ORDER_IS_LITTLE_ENDIAN #define INIT_DATA_A (unsigned long)0x67452301L #define INIT_DATA_B (unsigned long)0xefcdab89L #define INIT_DATA_C (unsigned long)0x98badcfeL #define INIT_DATA_D (unsigned long)0x10325476L #define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) #define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ l|=(((unsigned long)(*((c)++)))<< 8), \ l|=(((unsigned long)(*((c)++)))<<16), \ l|=(((unsigned long)(*((c)++)))<<24) ) #define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>>24)&0xff), \ l) #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ ll=(c)->A; (void)HOST_l2c(ll,(s)); \ ll=(c)->B; (void)HOST_l2c(ll,(s)); \ ll=(c)->C; (void)HOST_l2c(ll,(s)); \ ll=(c)->D; (void)HOST_l2c(ll,(s)); \ } while (0) #define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) #define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c)) #define H(b,c,d) ((b) ^ (c) ^ (d)) #define I(b,c,d) (((~(d)) | (b)) ^ (c)) #define R0(a,b,c,d,k,s,t) { \ a+=((k)+(t)+F((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; };\ #define R1(a,b,c,d,k,s,t) { \ a+=((k)+(t)+G((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; #define R2(a,b,c,d,k,s,t) { \ a+=((k)+(t)+H((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; #define R3(a,b,c,d,k,s,t) { \ a+=((k)+(t)+I((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; //typedef struct MD5state_st1 { // MD5_LONG A, B, C, D; // MD5_LONG Nl, Nh; // MD5_LONG data[MD5_LBLOCK]; // unsigned int num; //}MD5_CTX; unsigned char cleanse_ctr = 0; int MD5_Init(MD5_CTX *c) { memset(c, 0, sizeof(*c)); c->A = INIT_DATA_A; c->B = INIT_DATA_B; c->C = INIT_DATA_C; c->D = INIT_DATA_D; return 1; } void md5_block_data_order(MD5_CTX *c, const unsigned char *data_, size_t num) { const unsigned char *data = data_; register unsigned MD32_REG_T A, B, C, D, l; #ifndef MD32_XARRAY /* See comment in crypto/sha/sha_locl.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; # define X(i) XX##i #else MD5_LONG XX[MD5_LBLOCK]; # define X(i) XX[i] #endif A = c->A; B = c->B; C = c->C; D = c->D; for (; num--;) { HOST_c2l(data, l); X(0) = l; HOST_c2l(data, l); X(1) = l; /* Round 0 */ R0(A, B, C, D, X(0), 7, 0xd76aa478L); HOST_c2l(data, l); X(2) = l; R0(D, A, B, C, X(1), 12, 0xe8c7b756L); HOST_c2l(data, l); X(3) = l; R0(C, D, A, B, X(2), 17, 0x242070dbL); HOST_c2l(data, l); X(4) = l; R0(B, C, D, A, X(3), 22, 0xc1bdceeeL); HOST_c2l(data, l); X(5) = l; R0(A, B, C, D, X(4), 7, 0xf57c0fafL); HOST_c2l(data, l); X(6) = l; R0(D, A, B, C, X(5), 12, 0x4787c62aL); HOST_c2l(data, l); X(7) = l; R0(C, D, A, B, X(6), 17, 0xa8304613L); HOST_c2l(data, l); X(8) = l; R0(B, C, D, A, X(7), 22, 0xfd469501L); HOST_c2l(data, l); X(9) = l; R0(A, B, C, D, X(8), 7, 0x698098d8L); HOST_c2l(data, l); X(10) = l; R0(D, A, B, C, X(9), 12, 0x8b44f7afL); HOST_c2l(data, l); X(11) = l; R0(C, D, A, B, X(10), 17, 0xffff5bb1L); HOST_c2l(data, l); X(12) = l; R0(B, C, D, A, X(11), 22, 0x895cd7beL); HOST_c2l(data, l); X(13) = l; R0(A, B, C, D, X(12), 7, 0x6b901122L); HOST_c2l(data, l); X(14) = l; R0(D, A, B, C, X(13), 12, 0xfd987193L); HOST_c2l(data, l); X(15) = l; R0(C, D, A, B, X(14), 17, 0xa679438eL); R0(B, C, D, A, X(15), 22, 0x49b40821L); /* Round 1 */ R1(A, B, C, D, X(1), 5, 0xf61e2562L); R1(D, A, B, C, X(6), 9, 0xc040b340L); R1(C, D, A, B, X(11), 14, 0x265e5a51L); R1(B, C, D, A, X(0), 20, 0xe9b6c7aaL); R1(A, B, C, D, X(5), 5, 0xd62f105dL); R1(D, A, B, C, X(10), 9, 0x02441453L); R1(C, D, A, B, X(15), 14, 0xd8a1e681L); R1(B, C, D, A, X(4), 20, 0xe7d3fbc8L); R1(A, B, C, D, X(9), 5, 0x21e1cde6L); R1(D, A, B, C, X(14), 9, 0xc33707d6L); R1(C, D, A, B, X(3), 14, 0xf4d50d87L); R1(B, C, D, A, X(8), 20, 0x455a14edL); R1(A, B, C, D, X(13), 5, 0xa9e3e905L); R1(D, A, B, C, X(2), 9, 0xfcefa3f8L); R1(C, D, A, B, X(7), 14, 0x676f02d9L); R1(B, C, D, A, X(12), 20, 0x8d2a4c8aL); /* Round 2 */ R2(A, B, C, D, X(5), 4, 0xfffa3942L); R2(D, A, B, C, X(8), 11, 0x8771f681L); R2(C, D, A, B, X(11), 16, 0x6d9d6122L); R2(B, C, D, A, X(14), 23, 0xfde5380cL); R2(A, B, C, D, X(1), 4, 0xa4beea44L); R2(D, A, B, C, X(4), 11, 0x4bdecfa9L); R2(C, D, A, B, X(7), 16, 0xf6bb4b60L); R2(B, C, D, A, X(10), 23, 0xbebfbc70L); R2(A, B, C, D, X(13), 4, 0x289b7ec6L); R2(D, A, B, C, X(0), 11, 0xeaa127faL); R2(C, D, A, B, X(3), 16, 0xd4ef3085L); R2(B, C, D, A, X(6), 23, 0x04881d05L); R2(A, B, C, D, X(9), 4, 0xd9d4d039L); R2(D, A, B, C, X(12), 11, 0xe6db99e5L); R2(C, D, A, B, X(15), 16, 0x1fa27cf8L); R2(B, C, D, A, X(2), 23, 0xc4ac5665L); /* Round 3 */ R3(A, B, C, D, X(0), 6, 0xf4292244L); R3(D, A, B, C, X(7), 10, 0x432aff97L); R3(C, D, A, B, X(14), 15, 0xab9423a7L); R3(B, C, D, A, X(5), 21, 0xfc93a039L); R3(A, B, C, D, X(12), 6, 0x655b59c3L); R3(D, A, B, C, X(3), 10, 0x8f0ccc92L); R3(C, D, A, B, X(10), 15, 0xffeff47dL); R3(B, C, D, A, X(1), 21, 0x85845dd1L); R3(A, B, C, D, X(8), 6, 0x6fa87e4fL); R3(D, A, B, C, X(15), 10, 0xfe2ce6e0L); R3(C, D, A, B, X(6), 15, 0xa3014314L); R3(B, C, D, A, X(13), 21, 0x4e0811a1L); R3(A, B, C, D, X(4), 6, 0xf7537e82L); R3(D, A, B, C, X(11), 10, 0xbd3af235L); R3(C, D, A, B, X(2), 15, 0x2ad7d2bbL); R3(B, C, D, A, X(9), 21, 0xeb86d391L); A = c->A += A; B = c->B += B; C = c->C += C; D = c->D += D; } } int MD5_Update(MD5_CTX *c, const void *data_, size_t len) { const unsigned char *data = (unsigned char *)data_; unsigned char *p; MD5_LONG l; size_t n; if (len == 0) return 1; l = (c->Nl + (((MD5_LONG)len) << 3)) & 0xffffffffUL; if (l < c->Nl) c->Nh++; c->Nh += (MD5_LONG)(len >> 29); c->Nl = l; n = c->num; if (n != 0) { p = (unsigned char *)c->data; if (len >= MD5_CBLOCK || len + n >= MD5_CBLOCK) { memcpy(p + n, data, MD5_CBLOCK - n); md5_block_data_order(c, p, 1); n = MD5_CBLOCK - n; data += n; len -= n; c->num = 0; memset(p, 0, MD5_CBLOCK); } else { memcpy(p + n, data, len); c->num += (unsigned int)len; return 1; } } n = len / MD5_CBLOCK; if (n > 0) { md5_block_data_order(c, data, n); n *= MD5_CBLOCK; data += n; len -= n; } if (len != 0) { p = (unsigned char *)c->data; c->num = (unsigned int)len; memcpy(p, data, len); } return 1; } int MD5_Final(unsigned char *md, MD5_CTX *c) { unsigned char *p = (unsigned char *)c->data; size_t n = c->num; p[n] = 0x80; /* there is always room for one */ n++; if (n > (MD5_CBLOCK - 8)) { memset(p + n, 0, MD5_CBLOCK - n); n = 0; md5_block_data_order(c, p, 1); } memset(p + n, 0, MD5_CBLOCK - 8 - n); p += MD5_CBLOCK - 8; #if defined(DATA_ORDER_IS_BIG_ENDIAN) (void)HOST_l2c(c->Nh, p); (void)HOST_l2c(c->Nl, p); #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) (void)HOST_l2c(c->Nl, p); (void)HOST_l2c(c->Nh, p); #endif p -= MD5_CBLOCK; md5_block_data_order(c, p, 1); c->num = 0; memset(p, 0, MD5_CBLOCK); #ifndef HASH_MAKE_STRING #error "HASH_MAKE_STRING must be defined!" #else HASH_MAKE_STRING(c, md); #endif return 1; } void OPENSSL_cleanse(void *ptr, size_t len) { unsigned char *p = (unsigned char*)ptr; size_t loop = len, ctr = cleanse_ctr; while (loop--) { *(p++) = (unsigned char)ctr; ctr += (17 + ((size_t)p & 0xF)); } p = (unsigned char*)memchr(ptr, (unsigned char)ctr, len); if (p) ctr += (63 + (size_t)p); cleanse_ctr = (unsigned char)ctr; } unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) { MD5_CTX c; static unsigned char m[MD5_DIGEST_LENGTH]; if (md == NULL) md = m; if (!MD5_Init(&c)) return NULL; MD5_Update(&c, d, n); MD5_Final(md, &c); OPENSSL_cleanse(&c, sizeof(c)); return(md); }
fa2b0a809ddb898daeb707ddeac80dc70e560826
031dadfd061e09b261637fdd24e5adcdc9443e84
/src/Beam.cc
58b231812bcd896cf264ac0e45658519b5e17e6f
[ "BSD-3-Clause-LBNL" ]
permissive
LDAmorim/GPos
9bdd7db29fd007d2d920cbfc4ae0f3db02dbf7c4
4555cead437f3ca847b6b8a2ce3227a47eb25af7
refs/heads/development
2023-06-30T03:51:04.119199
2021-07-30T14:16:29
2021-07-30T14:16:29
391,080,819
4
2
NOASSERTION
2021-07-30T20:49:28
2021-07-30T13:49:54
C++
UTF-8
C++
false
false
4,150
cc
Beam.cc
/** * @file Beam.cc * @author Ligia Diana Amorim * @date 06/2021 * @copyright GPos 2021 LBNL */ #include "Beam.hpp" using CLHEP::mm; using CLHEP::MeV; using CLHEP::radian; /** * Constructor. */ Beam::Beam () { } /** * Destructor. */ Beam::~Beam () { } /** * Function to set primary particles (= events) properties according to values in input.txt. * * @param[in] in Parameters read from input.txt file. */ void Beam::set_beam (Query in){ G4int nranks = G4MPImanager::GetManager()->GetTotalSize(); beam_np = in.np/nranks; beam_type = in.type; G4double symmetry[4][2] = {{1,1},{1,-1},{-1,1},{-1,-1}}; if (in.symmetrize){ beam_np = beam_np*4; } beam_energy.reserve(beam_np); beam_position.reserve(beam_np); beam_direction.reserve(beam_np); if(beam_np >= 1){ G4double mean_arr[6] = {in.en,in.x_beam[0],in.x_beam[1],in.x_beam[2],0.0,0.0}; G4double sigma_arr[6] = {in.de*MeV,in.s_bprimary_x,in.s_bprimary_y, in.s_bprimary_z,in.s_angle_x*radian,in.s_angle_y*radian}; G4double rand_n[6]; G4double fac[3] = {0.0,0.0,1.0}; for (G4int l = 0; l < beam_np; ++l){ if (in.debug == true){ G4cout << "Randomly generated numbers:\n"; } for (G4int m = 0; m < 6;++m){ rand_n[m] = G4RandGauss::shoot(mean_arr[m],sigma_arr[m]); if (in.debug == true){ G4cout << rand_n[m] << "\n"; } } beam_energy.push_back(rand_n[0]); if (in.profile == "flat-top") { G4double beam_cz = mean_arr[3]-sigma_arr[3]/2.0; rand_n[3] = beam_cz+(G4double)l*sigma_arr[3]/(G4double)beam_np; } if (in.s_angle_x != 0.0 || in.s_angle_y != 0.0) { G4double angle_x = rand_n[4]; G4double angle_y = rand_n[5]; fac[2] = sqrt(1.0/(1.0+pow(tan(angle_x),2)+pow(tan(angle_y),2))); fac[0] = fac[2]*tan(angle_x); fac[1] = fac[2]*tan(angle_y); if (in.z_focal != 0.0) { G4double dz = in.z_focal - rand_n[3]; rand_n[1] = rand_n[1] - dz*fac[0]/fac[2]; rand_n[2] = rand_n[2] - dz*fac[1]/fac[2]; } } if (in.symmetrize){ for (G4int n = 0; n < 4;++n){ beam_position.push_back(G4ThreeVector(rand_n[1]*symmetry[n][0], rand_n[2]*symmetry[n][1], rand_n[3])); if (in.s_angle_x != 0.0 || in.s_angle_y != 0.0) { beam_direction.push_back(G4ThreeVector(fac[0]*symmetry[n][0], fac[1]*symmetry[n][1],fac[2])); } else { beam_direction.push_back(G4ThreeVector(fac[0],fac[1],fac[2])); } } } else { beam_position.push_back(G4ThreeVector(rand_n[1],rand_n[2],rand_n[3])); beam_direction.push_back(G4ThreeVector(fac[0],fac[1],fac[2])); } } } else { G4ExceptionDescription msg; msg << "\n#beam particles (np) must be at least 1.\n"; G4Exception("Beam::set_beam()", "GPos error #1.0",FatalException,msg); } } /** * Function to retrieve primary particle centroid. * * @param[in] eventID Particle (= event) identifier number. */ G4ThreeVector Beam::get_position (G4int eventID){ return beam_position[eventID]; } /** * Function to retrieve primary particle kinetic energy. * * @param[in] eventID Particle (= event) identifier number. */ G4double Beam::get_energy (G4int eventID){ return beam_energy[eventID]; } /** * Function to retrieve primary particle normalized momentum. * * @param[in] eventID Particle (= event) identifier number. */ G4ThreeVector Beam::get_direction (G4int eventID){ return beam_direction[eventID]; }
7bc4e0328508a7b98f46bbe020318190fd781967
9461e9a6de46accc82e3afc18aaa07a0238a7b0f
/mainwindow.h
559a6c0f201e1fa8643cc4689b04023c7f7ca317
[]
no_license
WGB5445/MyQT_Mplayer_Project
0677a18a6c47691a9c6ad8b7e4481cd145d12d26
82a3461c1dd18703d6ff56c3408be373dc984f77
refs/heads/master
2022-04-07T13:17:07.862638
2020-03-01T05:35:14
2020-03-01T05:35:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,340
h
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <stdio.h> #include <QPixmap> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/ipc.h> #include <sys/shm.h> #include <signal.h> #include <dirent.h> #include <QTimer> #include <stdlib.h> #include <QByteArray> #include <QDebug> #include <QVector> #include <QList> #include <algorithm> #include <numeric> #include <iostream> #include <QTextCodec> #include <QListWidgetItem> #include <QPainter> #include <exception> #include <QMenuBar> #include <QMenu> #include <QAction> #include <QDialog> #include<QDebug> #include <QMessageBox> #include <QFileDialog> #include <QMenuBar> #include <QMenu> #include <QAction> #include <QDialog> #include<QDebug> #include <QMessageBox> #include <QFileDialog> #include <ctime> struct ViewInformation { QString song; QString singer; QString album; QString nowtime; QString alltime; QString lyric; int progress; int mutehub; int hub; int NowTime; int AllTime; }; QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE extern void *MyPrint(void *arg); extern void *MyGetTimeAndBar(void *arg); extern void *MySendMsgToMplayer(void *arg); extern void SetSeekBarFindViewById(int val); extern void TotalTime(float val); extern void SetNowTimeQstring(float val); extern void SendMsgToMplayer(char *val); extern char *QStringToChar(QString val); extern pthread_mutex_t mutex; extern pthread_mutex_t mutex2; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); int imageRotate; QPixmap disc; int fd; char buf[128]; int OpenFlag; int VolueButtonFlag; int MuteFlag; pid_t pid; char MyBuff[128]; int HaveLyricFlag; int SpliderPress; int ShowAllLyric; int Frist; int Mode; QList<int> LyriclistTime; QList<int> lyriclistRow; QList<QString> LyriclistLyric; QString setnowtimeqstring ; ViewInformation viewinformation; QPixmap pixmap; friend void *MyGetTimeAndBar(void *arg); void GetLyric(); QString MyFindLyric(); void ReadDir(char *val); void Initialize(); void PrintInformation(); void SetInformation(); void SetTimeQstring(float val,QString &val1); void Lock(); void Unlock(); void SetAllLyric(); void CutSong(char *val); void closeEvent(QCloseEvent *event); void resizeEvent(QResizeEvent *); void paintEvent(QPaintEvent *); signals: public slots: void SlotMyClickedPlaying(void); void SlotMyDoubleClickedList(QListWidgetItem *item); void SlotMusicNext(void); void SlotMusicFront(void); void SlotTimeOut(void); void SlotProgressValue(int val); void SlotSliderPressed(void); void SlotSliderReleased(void); void SlotQPushButtonShowAllLyric(void); void SlotQPushButtonvolumeShow(void); void SlotQPushButtonMute(void); private slots: void on_pushButton_clicked(); void on_pushButton_3_clicked(); void on_pushButton_5_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
aebfd738a02cc64d3fc44c46034827932a4ff612
19b7a34be371d1265ee6959cb28ad13f97656cfe
/include/Tokenizer_Interface.h
73c820630e2c95a21fdc6a5dd06f6c6e2b557d30
[]
no_license
cfeyer/string-calculator-kata
7e607e67102f8523b69d1af8dfbaf0fc75278516
79dccfd48edbea6a53b8204c510d4061a2b8137d
refs/heads/master
2023-03-23T17:34:47.433623
2021-03-13T17:59:43
2021-03-13T17:59:43
347,443,610
0
0
null
null
null
null
UTF-8
C++
false
false
294
h
Tokenizer_Interface.h
#ifndef TOKENIZER_INTERFACE_H #define TOKENIZER_INTERFACE_H #include <string> #include <vector> class Tokenizer_Interface { public: virtual ~Tokenizer_Interface() {}; virtual std::vector<std::string> parse_tokens( const std::string & ) const = 0; }; #endif /*TOKENIZER_INTERFACE_H*/
7faa08e41fcc99f8a1ab78dc504d7dc4cadec21b
ed25dc3fdf080e59316c19b2fb8a1f05a49c88ef
/include/thread/dosc/bift_wai.h
866d0ba0d68d03fe5186a339e1722f02839490f1
[]
no_license
druppy/uwinf
b31f728787773deab9b32a0c3c3a1bfec6fd7f61
ef1fbab1893d4cfa55b07efe3d78ebdeda5e50b3
refs/heads/master
2020-05-22T14:33:21.444998
2015-09-26T18:46:51
2015-09-26T18:46:51
32,198,784
0
0
null
null
null
null
UTF-8
C++
false
false
1,267
h
bift_wai.h
#ifndef __BIFT_WAITTHING_H_INCLUDED #define __BIFT_WAITTHING_H_INCLUDED class BIFCLASS FThread; class BIFCLASS FThreadManager; class BIFCLASS FWaitThing { //a thing to wait for protected: FWaitThing(); virtual ~FWaitThing(); private: void AddWaiter(FThread *tp); protected: void RemoveWaiter(FThread *tp); int GenericWait(long timeout=-1); virtual FThread *WakeOneWaiter(int retcode); virtual void WakeAllWaiters(int retcode); int MoreWaiters() const; //friend void FThread::terminateThread(); //Recursive headers would be required to do the line above, so we //have to use the line below friend class FThread; private: FThread *firstWaiter; }; class BIFCLASS FExternalWaitThing : protected FWaitThing { protected: FExternalWaitThing(); ~FExternalWaitThing(); virtual void Check() =0; //check to if external event has happened virtual void Wait() =0; //wait until external event happens virtual void PollLoop(long pollEndTime) =0; //poll until timeout or event happens private: int AnyWaiters() const; friend class FThreadManager; }; #endif /* __BIFT_WAITTHING_H_INCLUDED */
5b23e6ce8e2d9fe119d400b6484f0d722da76013
5d1003e596524182f126611b837b56a91ef0b1b7
/Ardomos/ModuleClock.h
375e7dd72c0164533852cd516b8bb70e41152936
[]
no_license
hsaturn/Domosat
3d39c5e94f686b0c00174ee403f44e6914c046b6
46231d297a79fdb3bce01223ab93215485e014b4
refs/heads/master
2021-01-13T03:32:36.512359
2017-01-11T16:38:55
2017-01-11T16:38:55
77,529,811
0
0
null
2016-12-29T10:50:34
2016-12-28T12:01:31
Java
UTF-8
C++
false
false
443
h
ModuleClock.h
/* * File: ModuleClock.h * Author: hsaturn * * Created on 2 novembre 2014, 22:06 */ #ifndef MODULECLOCK_H #define MODULECLOCK_H #include <Arduino.h> #include "Module.h" class ModuleClock : public Module { public: ModuleClock():Module(MODULE_CLOCK), miMin(0), miHour(0),miDay(0){} virtual int8_t msgHandler(uint8_t iMsgType, Message* p); private: uint8_t miMin; uint8_t miHour; uint8_t miDay; }; #endif /* MODULECLOCK_H */
b2a913b3d77af1f2d95779e6586c7e8c3c497344
760458ba4a9d7e5992d67095da75805c918f5a06
/parser/antlr/calc.c++.listener/ExprBaseListener.h
4d5a31d830f8653a22f400643ecd37f16f60694d
[]
no_license
yielding/code
99e0809255f96e89f18d7dfd3492003684485167
b231e15f35c60a7b3227a57be7c110e12c5aa127
refs/heads/master
2023-08-30T23:40:21.225686
2023-08-26T04:39:46
2023-08-26T04:39:46
978,529
16
9
null
null
null
null
UTF-8
C++
false
false
2,297
h
ExprBaseListener.h
// Generated from ./Expr.g4 by ANTLR 4.13.0 #pragma once #include "antlr4-runtime.h" #include "ExprListener.h" /** * This class provides an empty implementation of ExprListener, * which can be extended to create a listener which only needs to handle a subset * of the available methods. */ class ExprBaseListener : public ExprListener { public: virtual void enterProg(ExprParser::ProgContext * /*ctx*/) override { } virtual void exitProg(ExprParser::ProgContext * /*ctx*/) override { } virtual void enterToMultOrDiv(ExprParser::ToMultOrDivContext * /*ctx*/) override { } virtual void exitToMultOrDiv(ExprParser::ToMultOrDivContext * /*ctx*/) override { } virtual void enterBinaryMinusOp(ExprParser::BinaryMinusOpContext * /*ctx*/) override { } virtual void exitBinaryMinusOp(ExprParser::BinaryMinusOpContext * /*ctx*/) override { } virtual void enterPlusOp(ExprParser::PlusOpContext * /*ctx*/) override { } virtual void exitPlusOp(ExprParser::PlusOpContext * /*ctx*/) override { } virtual void enterToAtom(ExprParser::ToAtomContext * /*ctx*/) override { } virtual void exitToAtom(ExprParser::ToAtomContext * /*ctx*/) override { } virtual void enterMultOp(ExprParser::MultOpContext * /*ctx*/) override { } virtual void exitMultOp(ExprParser::MultOpContext * /*ctx*/) override { } virtual void enterDivOp(ExprParser::DivOpContext * /*ctx*/) override { } virtual void exitDivOp(ExprParser::DivOpContext * /*ctx*/) override { } virtual void enterInt(ExprParser::IntContext * /*ctx*/) override { } virtual void exitInt(ExprParser::IntContext * /*ctx*/) override { } virtual void enterUnaryMinusOp(ExprParser::UnaryMinusOpContext * /*ctx*/) override { } virtual void exitUnaryMinusOp(ExprParser::UnaryMinusOpContext * /*ctx*/) override { } virtual void enterParenthesisOp(ExprParser::ParenthesisOpContext * /*ctx*/) override { } virtual void exitParenthesisOp(ExprParser::ParenthesisOpContext * /*ctx*/) override { } virtual void enterEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { } virtual void exitEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { } virtual void visitTerminal(antlr4::tree::TerminalNode * /*node*/) override { } virtual void visitErrorNode(antlr4::tree::ErrorNode * /*node*/) override { } };
915363b5b22ff41921c2fa55bc41e78a3e7c8640
0bfead2f80dc4021cffae29190e3c951e81b3ccc
/project_aps.cpp
1e20eceb9ca6067efca9a45af7c88f37de14a47d
[]
no_license
AshishKempwad/Suffix-tree-in-O-n-time
74c797d852bbab24483ec07bae7e221bbd5e075a
f6702ce832918366762762d02026df2bbf3c3cda
refs/heads/master
2020-09-07T04:41:06.823804
2019-11-09T15:01:34
2019-11-09T15:01:34
220,657,704
0
0
null
null
null
null
UTF-8
C++
false
false
4,122
cpp
project_aps.cpp
#include<bits/stdc++.h> using namespace std; typedef struct Suffix st_node; st_node *root; st_node *lastnew_node = NULL; st_node *active_node = NULL; int remaining = 0; // active points int active_edge = -1; int active_length = 0; int string_size = -1; //strcture of suffix struct Suffix { struct Suffix *nodes[256]; struct Suffix *suffix_link; int start; int *end; int suffix_index; }; int final_end = -1; string input; int find_length(st_node *n) { return *(n->end) - (n->start) + 1; } // constructor st_node *new_node(int start, int *end) { st_node *node = new st_node; int i; for (i = 0; i < 256; i++) { node->nodes[i] = NULL; } node->suffix_link = root; node->start = start; node->end = end; node->suffix_index = -1; return node; } int edge_length(st_node *n) { return find_length(n) ; } // 3 rules of extension void rules_of_extension(int index) { //rule 1 final_end = index; remaining++; while(remaining > 0) { if (active_length == 0) { active_edge = index; } if (!active_node->nodes[input[active_edge]]) { //rule 2 active_node->nodes[input[active_edge]] = new_node(index, &final_end); if (lastnew_node) { lastnew_node->suffix_link = active_node; lastnew_node = NULL; } } else { //rule 3 (the show stopper) st_node *next = active_node->nodes[input[active_edge]]; if (active_length >= edge_length(next)) { active_edge++; active_length--; active_node=next; continue; } if (input[next->start + active_length] == input[index]) { if(lastnew_node && active_node != root) { lastnew_node->suffix_link = active_node; lastnew_node = NULL; } active_length++; break; } int *point_of_split = NULL; point_of_split = new int; *point_of_split = next->start + active_length - 1; st_node *split = new_node(next->start, point_of_split); active_node->nodes[input[active_edge]] = split; split->nodes[input[index]] = new_node(index, &final_end); next->start += active_length; split->nodes[input[next->start]] = next; if (lastnew_node) { lastnew_node->suffix_link = split; } lastnew_node = split; } remaining--; if (active_node == root && active_length > 0) { active_length--; active_edge ++; } else if (active_node != root) { active_node = active_node->suffix_link; } } } void dfs(st_node *n, int labelHeight) { if (!n) { return; } if (n->start != -1) { for(int i=n->start;i<=*(n->end);i++) { cout<<input[i]; } } int leaf = 1; for ( int i= 0; i < 256; i++) { if (n->nodes[i]) { if (leaf == 1 && n->start != -1) { cout<< " "<<'['<<n->suffix_index<<']'<<endl; } leaf = 0; dfs(n->nodes[i], labelHeight + edge_length(n->nodes[i])); } } if (leaf == 1 && leaf!=0) { n->suffix_index = string_size - labelHeight; cout<<" "<<'['<<n->suffix_index<<']'<<endl; } } int main() { string t; cout<<"Enter the string"<<endl; cin>>t; input=t+'$'; string_size = input.size(); int rootEnd = - 1; root = new_node(-1, &rootEnd); active_node = root; for (int i=0; i<string_size; i++) { rules_of_extension(i); } dfs(root, 0); return 0; }
9c016dd54112a6af59ead86022444abc27129ca0
7a70358f01f42a600990e1bc4e55df86c5329bf1
/DCRgenerator.h
14ae52c2ef96eaf8cfa42f82f12f8bd2e5b2b031
[]
no_license
BellaHa/DeadCommunity
f2cf2e8978ef9a87ed898a01e13b28292f16c9b5
4c2aab5fda670a923d5c29fb24658496cfc4f42f
refs/heads/main
2023-02-25T12:27:14.247409
2021-01-29T07:43:59
2021-01-29T07:43:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
623
h
DCRgenerator.h
#pragma once #include "SocialGraph.h" #include "DCRgraph.h" class DCRgenerator { public: DCRgenerator(); DCRgenerator(SocialGraph* g); ~DCRgenerator(); void setSocialGraph(SocialGraph * g); DCRgraph* generateDCRgraph(); DCRgraph* generateDCRgraphMig(); DCRgraph* generateDCRgraphMigB(); private: SocialGraph *g; DCRgraph * generateDCRgraphIC(); DCRgraph * generateDCRgraphICMig(); DCRgraph * generateDCRgraphICMigB(); DCRgraph * generateDCRgraphLT(); void dfs(int u, vector<int> * reachable, map<int, vector<int>> * mapNeighbors); Common * commonInstance; };
106d524e08a934447da488f5fa1abd11cb7dd483
b906f38539e8f7fcf6c09f8ace2e8f7be6bad0be
/students/2012/kazenyuk/ast2bytecode/BytecodeInstructionPrimitives.h
d8bdbf63dd252558a11208d0f8b43c0b98e97eec
[]
no_license
nvmd/spbau-mathvm
e2095341d73de403502e55653438d68c0f6eb711
b50ce4291fe2e5077c2a2023baf23023db20c827
refs/heads/master
2021-01-13T01:27:44.439572
2013-02-04T01:22:26
2013-02-04T01:22:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,472
h
BytecodeInstructionPrimitives.h
#ifndef BYTECODEINSTRUCTIONPRIMITIVES_H_ #define BYTECODEINSTRUCTIONPRIMITIVES_H_ #include "mathvm.h" #include "ast.h" namespace mathvm_ext { using namespace mathvm; class BytecodeInstructionPrimitives { public: BytecodeInstructionPrimitives(); virtual ~BytecodeInstructionPrimitives(); // load immediate value on tos template <typename T> VarType Load(Bytecode* out, T value, VarType varType) { Instruction instr = BC_INVALID; switch (varType) { case VT_INVALID: instr = BC_INVALID; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_DLOAD; break; case VT_INT: instr = BC_ILOAD; break; case VT_STRING: instr = BC_SLOAD; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown type '" << varType << "'" << std::endl; break; } out->addInsn(instr); if (instr != BC_INVALID) { out->addTyped(value); } return varType; } VarType Add(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { if (leftType != rightType) { std::cerr << "Error: Type mismatch: left is " << typeToName(leftType) << " but right is" << typeToName(rightType) << std::endl; } Instruction instr = BC_INVALID; switch (leftType) { case VT_DOUBLE: instr = BC_DADD; break; case VT_INT: instr = BC_IADD; break; case VT_VOID: case VT_STRING: instr = BC_INVALID; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << leftType << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << leftType << "'" << std::endl; break; } out->addInsn(instr); return leftType; } VarType Sub(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { if (leftType != rightType) { std::cerr << "Error: Type mismatch: left is " << typeToName(leftType) << " but right is" << typeToName(rightType) << std::endl; } Instruction instr = BC_INVALID; switch (leftType) { case VT_DOUBLE: instr = BC_DSUB; break; case VT_INT: instr = BC_ISUB; break; case VT_VOID: case VT_STRING: instr = BC_INVALID; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << leftType << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << leftType << "'" << std::endl; break; } out->addInsn(instr); return leftType; } VarType Mul(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { if (leftType != rightType) { std::cerr << "Error: Type mismatch: left is " << typeToName(leftType) << " but right is" << typeToName(rightType) << std::endl; } Instruction instr = BC_INVALID; switch (leftType) { case VT_DOUBLE: instr = BC_DMUL; break; case VT_INT: instr = BC_IMUL; break; case VT_VOID: case VT_STRING: instr = BC_INVALID; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << leftType << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << leftType << "'" << std::endl; break; } out->addInsn(instr); return leftType; } VarType Div(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { if (leftType != rightType) { std::cerr << "Error: Type mismatch: left is " << typeToName(leftType) << " but right is" << typeToName(rightType) << std::endl; } Instruction instr = BC_INVALID; switch (leftType) { case VT_DOUBLE: instr = BC_DDIV; break; case VT_INT: instr = BC_IDIV; break; case VT_VOID: case VT_STRING: instr = BC_INVALID; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << leftType << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << leftType << "'" << std::endl; break; } out->addInsn(instr); return leftType; } VarType Mod(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { if (leftType != rightType) { std::cerr << "Error: Type mismatch: left is " << typeToName(leftType) << " but right is" << typeToName(rightType) << std::endl; } Instruction instr = BC_INVALID; switch (leftType) { case VT_INT: instr = BC_IMOD; break; case VT_VOID: case VT_DOUBLE: case VT_STRING: instr = BC_INVALID; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << leftType << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << leftType << "'" << std::endl; break; } out->addInsn(instr); return leftType; } void Pop(Bytecode* out, VarType type) { // NOTE: semantically, it should be just BC_POP, but interpreter's stack must be typed // in order to interpret (untyped) BC_POP correctly // We are using BC_STORE*VAR0 to mimic typed POP operation (VAR0 is used only to return value from the function, // therefore, its _now_ safe to use it inside the function) // const size_t DatatypeSize[] = {0, // VT_INVALID // 0, // VT_VOID // sizeof(double), // VT_DOUBLE // sizeof(int64_t), // VT_INT // sizeof(uint16_t) // VT_STRING // }; // out->addInsn(BC_POP); Instruction instr = BC_INVALID; switch (type) { case VT_INT: instr = BC_STOREIVAR0; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_STOREDVAR0; break; case VT_STRING: instr = BC_STORESVAR0; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << type << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << type << "'" << std::endl; break; } out->addInsn(instr); } VarType And(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { // TODO: only integer types must be supported, because only integers can be compared Label earlyExitLabel(out); Label exit0Label(out); Label exit1Label(out); Label exitLabel(out); out->addInsn(BC_ILOAD0); JmpEq(out, earlyExitLabel); out->addInsn(BC_ILOAD0); JmpEq(out, exit0Label); Jmp(out, exit1Label); // EarlyExit out->bind(earlyExitLabel); Pop(out, VT_INT); // Exit0 out->bind(exit0Label); out->addInsn(BC_ILOAD0); Jmp(out, exitLabel); // Exit1 out->bind(exit1Label); out->addInsn(BC_ILOAD1); // Exit out->bind(exitLabel); return VT_INT; } VarType Or(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { // TODO: only integer types must be supported, because only integers can be compared Label earlyExitLabel(out); Label exit0Label(out); Label exit1Label(out); Label exitLabel(out); out->addInsn(BC_ILOAD0); JmpNe(out, earlyExitLabel); out->addInsn(BC_ILOAD0); JmpEq(out, exit0Label); Jmp(out, exit1Label); // EarlyExit out->bind(earlyExitLabel); Pop(out, VT_INT); // Exit1 out->bind(exit1Label); out->addInsn(BC_ILOAD1); Jmp(out, exitLabel); // Exit0 out->bind(exit0Label); out->addInsn(BC_ILOAD0); // Exit out->bind(exitLabel); return VT_INT; } VarType Neg(Bytecode* out, VarType type = VT_VOID) { Instruction instr = BC_INVALID; switch (type) { case VT_DOUBLE: instr = BC_DNEG; break; case VT_INT: instr = BC_INEG; break; case VT_VOID: case VT_STRING: instr = BC_INVALID; std::cerr << "Error: Unsupported type of the argument" << std::endl; break; case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid AST var type '" << type << "'" << std::endl; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << type << "'" << std::endl; break; } out->addInsn(instr); return type; } VarType CmpEq(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPE, leftType, rightType); } VarType CmpNe(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPNE, leftType, rightType); } VarType CmpGt(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPG, leftType, rightType); } VarType CmpGe(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPGE, leftType, rightType); } VarType CmpLt(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPL, leftType, rightType); } VarType CmpLe(Bytecode* out, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { return Cmp(out, BC_IFICMPLE, leftType, rightType); } void Jmp(Bytecode* out, Label &target) { out->addBranch(BC_JA, target); } void JmpEq(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPE, target); } void JmpNe(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPNE, target); } void JmpGt(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPG, target); } void JmpGe(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPGE, target); } void JmpLt(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPL, target); } void JmpLe(Bytecode* out, Label &target, VarType leftType = VT_VOID, VarType rightType = VT_VOID) { out->addBranch(BC_IFICMPLE, target); } VarType Not(Bytecode* out, VarType type = VT_VOID) { out->addInsn(BC_ILOAD0); return CmpEq(out); } void StoreVar(Bytecode* out, uint16_t varId, VarType varType) { Instruction instr = BC_INVALID; // get value from the top of the stack and store in the VAR switch (varType) { case VT_INVALID: instr = BC_INVALID; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_STOREDVAR; break; case VT_INT: instr = BC_STOREIVAR; break; case VT_STRING: instr = BC_STORESVAR; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown type '" << varType << "'" << std::endl; break; } out->addInsn(instr); if (instr != BC_INVALID) { out->addUInt16(varId); } } // load variable on tos VarType LoadVar(Bytecode* out, uint16_t varId, VarType varType) { Instruction instr = BC_INVALID; switch (varType) { case VT_INVALID: instr = BC_INVALID; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_LOADDVAR; break; case VT_INT: instr = BC_LOADIVAR; break; case VT_STRING: instr = BC_LOADSVAR; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown type '" << varType << "'" << std::endl; break; } out->addInsn(instr); if (instr != BC_INVALID) { out->addUInt16(varId); } return varType; } void StoreCtxVar(Bytecode* out, uint16_t ctxId, uint16_t varId, VarType varType) { Instruction instr = BC_INVALID; // get value from the top of the stack and store in the VAR switch (varType) { case VT_INVALID: instr = BC_INVALID; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_STORECTXDVAR; break; case VT_INT: instr = BC_STORECTXIVAR; break; case VT_STRING: instr = BC_STORECTXSVAR; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown type '" << varType << "'" << std::endl; break; } out->addInsn(instr); if (instr != BC_INVALID) { out->addUInt16(ctxId); out->addUInt16(varId); } } // load variable on tos VarType LoadCtxVar(Bytecode* out, uint16_t ctxId, uint16_t varId, VarType varType) { Instruction instr = BC_INVALID; switch (varType) { case VT_INVALID: instr = BC_INVALID; break; case VT_VOID: instr = BC_INVALID; break; case VT_DOUBLE: instr = BC_LOADCTXDVAR; break; case VT_INT: instr = BC_LOADCTXIVAR; break; case VT_STRING: instr = BC_LOADCTXSVAR; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown type '" << varType << "'" << std::endl; break; } out->addInsn(instr); if (instr != BC_INVALID) { out->addUInt16(ctxId); out->addUInt16(varId); } return varType; } void Inc(Bytecode* out, uint16_t varId, VarType varType) { // NOTE: inc argument is already on the top of the stack // load LoadVar(out, varId, varType); // inc Add(out, varType, varType); // store back StoreVar(out, varId, varType); } void Dec(Bytecode* out, uint16_t varId, VarType varType) { // load LoadVar(out, varId, varType); // inc Sub(out, varType, varType); // store back StoreVar(out, varId, varType); } void Print(Bytecode* out, VarType type = VT_VOID) { Instruction instr = BC_INVALID; switch (type) { case VT_INVALID: instr = BC_INVALID; std::cerr << "Error: Invalid var type '" << type << "'" << std::endl; break; case VT_VOID: instr = BC_INVALID; std::cerr << "Error: Unsupported type of the argument" << std::endl; break; case VT_DOUBLE: instr = BC_DPRINT; break; case VT_INT: instr = BC_IPRINT; break; case VT_STRING: instr = BC_SPRINT; break; default: instr = BC_INVALID; std::cerr << "Error: Unknown AST var type '" << type << "'" << std::endl; break; } out->addInsn(instr); } VarType Return(Bytecode* out, VarType type = VT_VOID) { assert(type != VT_INVALID); bool valuable_return = type != VT_VOID; if (valuable_return) { // move return value to VAR0 StoreVar(out, 0, type); } // return address is on top the stack now out->addInsn(BC_RETURN); return type; } VarType Invalid(Bytecode* out) { std::cerr << "Warning: emitting BC_INVALID at " << out->current() << std::endl; out->addInsn(BC_INVALID); return VT_INVALID; } private: VarType Cmp(Bytecode* out, Instruction cmpInsn, VarType leftType, VarType rightType) { out->addInsn(cmpInsn); const uint16_t jump_offset_size = sizeof(uint16_t); out->addInt16(jump_offset_size + InsnSize[BC_ILOAD0] + InsnSize[BC_JA]); // : out->addInsn(BC_ILOAD0); // push "0" out->addInsn(BC_JA); out->addUInt16(jump_offset_size + InsnSize[BC_ILOAD1]); // : out->addInsn(BC_ILOAD1); // push "1" // out->addInsn(BC_SWAP); // out->addInsn(BC_POP); // out->addInsn(BC_SWAP); // out->addInsn(BC_POP); return VT_INT; } static const uint8_t InsnSize[]; }; } /* namespace mathvm_ext */ #endif /* BYTECODEINSTRUCTIONPRIMITIVES_H_ */
c165fb9f33044b3c6834a8af1035f71d69541b28
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/curl/gumtree/curl_new_log_5515.cpp
169ecee2de020b15850090eb14c2d4cdc7c82c9f
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
551
cpp
curl_new_log_5515.cpp
fputs( " for efficiency. Fails the transfer if the server doesn't sup-\n" " port SSL/TLS. (Added in 7.16.0)\n" "\n" " --ssl-reqd\n" " (FTP, POP3, IMAP, SMTP) Require SSL/TLS for the connection.\n" " Terminates the connection if the server doesn't support SSL/TLS.\n" " (Added in 7.20.0)\n" "\n" " This option was formerly known as --ftp-ssl-reqd (added in\n" " 7.15.5) and that can still be used but will be removed in a\n" , stdout);
bc6275927a1091a4a01f4bc9bc742d2c9cdbe8d2
b45761d13faae22f5a676a20b324fb13db5812cb
/unidade1/codigos/tiltshift.cpp
98e3002c670985ee7efbe6b1ed5fee3931a6dde2
[]
no_license
luishmv/pdi
cfa6054ea1f1ee5f615cfcb74bd76e3e1c043175
c6046b6be22706b26f6e84bd91b185abe9edb21e
refs/heads/main
2023-01-23T21:44:49.175306
2020-12-04T22:40:40
2020-12-04T22:40:40
304,092,098
0
0
null
null
null
null
UTF-8
C++
false
false
2,365
cpp
tiltshift.cpp
#include <iostream> #include <cmath> #include <opencv2/opencv.hpp> #define Max_size_name 51 using namespace cv; using namespace std; int top_slider_max = 100; int h_slider = 0, v_slider = 0, p_slider = 0; int width, height; // dimensões da imagem Mat image, blurry_image, blended; char TrackbarName[Max_size_name]; // nome das labels float l1 = 0, l2 = 0; // linhas de mudança void on_trackbar_blend(int, void *); void on_trackbar_line(int, void *); float tiltShift(const int pos); int main(int argvc, char **argv) { image = imread(argv[1]); if (!image.data) { cout << "Erro ao abrir a imagem" << endl; return 0; } width = image.rows; height = image.cols; float media[] = {0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0}; Mat mask = Mat(5, 5, CV_32F, media); scaleAdd(mask, 1 / 9.0, Mat::zeros(5, 5, CV_32F), mask); filter2D(image, blurry_image, image.depth(), mask, Point(2, 2), 0); namedWindow("addweighted", 1); sprintf(TrackbarName, "Altura:"); createTrackbar(TrackbarName, "addweighted", &h_slider, top_slider_max, on_trackbar_line); sprintf(TrackbarName, "Decaimento:"); createTrackbar(TrackbarName, "addweighted", &v_slider, top_slider_max, on_trackbar_line); sprintf(TrackbarName, "Posicão:"); createTrackbar(TrackbarName, "addweighted", &p_slider, top_slider_max, on_trackbar_line); on_trackbar_line(0, 0); waitKey(0); imwrite("./img_final.jpg", blended); return 0; } void on_trackbar_line(int, void *) { // fazer atribuições a l1,l2 e d apartir dos dados coletados por '*_slider' float h_focus = ((h_slider / 100.0) * width) / 2.0; float p_real = ((p_slider / 100.0) * width); l1 = p_real - h_focus; l2 = p_real + h_focus; on_trackbar_blend(0, 0); } void on_trackbar_blend(int, void *) { image.convertTo(image, CV_32F); blurry_image.convertTo(blurry_image, CV_32F); blurry_image.convertTo(blended, CV_32F); for (int i = 0; i < width; i++) { float pix = tiltShift(i); for (int j = 0; j < 3 * height; j++) { blended.at<float>(i, j) = image.at<float>(i, j) * pix + blurry_image.at<float>(i, j) * (1 - pix); } } blended.convertTo(blended, CV_8U); imshow("addweighted", blended); } float tiltShift(const int pos) { return 0.5 * (tanh((pos - l1) / v_slider) - tanh((pos - l2) / v_slider)); }
18abfab6f10ed544905d18cd165843c6d10d4fd1
307d3837d31f9e3728af2b62ca51ebf63fe6ec6b
/hall_of_fame/jaewon/1504_certainShortPath.cpp
857cac3a26c1fd0b36df89466c1471f100bcccb8
[]
no_license
ellynhan/challenge100-codingtest-study
905043497d154b8a7333ca536e536d013f6e7454
bcdc6d04f13b12ba80b42e066f9d244d7c2cc698
refs/heads/master
2023-09-01T14:10:13.481013
2023-08-27T14:38:52
2023-08-27T14:38:52
401,561,230
162
176
null
2023-09-09T14:56:25
2021-08-31T03:30:36
C++
UTF-8
C++
false
false
2,486
cpp
1504_certainShortPath.cpp
//0458~0555 0725~0900 #include <iostream> #include <vector> #include <queue> using namespace std; int main(){ int numOfNodes, numOfEdges; //1번부터 numOfnodes번까지 scanf("%d%d", &numOfNodes, &numOfEdges); vector<vector<int>> ways(numOfNodes,vector<int>(numOfNodes, INT32_MAX)); vector<int> startDP(numOfNodes, INT32_MAX); vector<int> wayPointDP(numOfNodes, INT32_MAX); vector<int> wayPointDP2(numOfNodes, INT32_MAX); for(int i=0; i<numOfEdges; i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); ways[a-1][b-1]=c; ways[b-1][a-1]=c; } int wayPoint[2]; //이 경로를 경유해야함 scanf("%d%d",&wayPoint[0],&wayPoint[1]); //dij priority_queue<pair<int, int>> pq; //-cost, currNode pq.push({0,0}); while(!pq.empty()){ int dist = -pq.top().first; int curr = pq.top().second; pq.pop(); if(startDP[curr] < dist)continue; startDP[curr]=min(startDP[curr],dist); for(int i=0; i<numOfNodes; i++){ if(ways[curr][i]!=INT32_MAX){ pq.push({-(dist+ways[curr][i]),i}); } } } pq.push({0,wayPoint[0]-1}); while(!pq.empty()){ int dist = -pq.top().first; int curr = pq.top().second; pq.pop(); if(wayPointDP[curr] < dist)continue; wayPointDP[curr]=min(wayPointDP[curr],dist); for(int i=0; i<numOfNodes; i++){ if(ways[curr][i]!=INT32_MAX){ pq.push({-(dist+ways[curr][i]),i}); } } } pq.push({0,wayPoint[1]-1}); while(!pq.empty()){ int dist = -pq.top().first; int curr = pq.top().second; pq.pop(); if(wayPointDP2[curr] < dist)continue; wayPointDP2[curr]=min(wayPointDP2[curr],dist); for(int i=0; i<numOfNodes; i++){ if(ways[curr][i]!=INT32_MAX){ pq.push({-(dist+ways[curr][i]),i}); } } } int case1Front = startDP[wayPoint[0]-1]; int case2Front = startDP[wayPoint[1]-1]; int case1Back = wayPointDP2[numOfNodes-1]; int case2Back = wayPointDP[numOfNodes-1]; int middle = +wayPointDP[wayPoint[1]-1]; if((case1Front==INT32_MAX||case1Back==INT32_MAX)&&(case2Front==INT32_MAX||case2Back==INT32_MAX)){ printf("%d",-1); }else if(middle == INT32_MAX){ printf("%d",-1); }else{ printf("%d",min(case1Front+case1Back, case2Front+case2Back)+middle); } }
863af2efb0b6074e98d5c5c43e8c781cb863dfed
9f9b18f28e6f6fa3399cd26063fc993d056dd0fb
/src/scene.h
aa5cf90f478911d6e8e4087faa37649715dd722a
[]
no_license
rdelcueto/LIMN-Ray
96b965f41539f1f5844fba20f75c493eb5819cd8
0feac0fdf11d232ffa53b8249982c47093e650a7
refs/heads/master
2020-05-17T12:27:13.014918
2013-01-14T00:57:21
2013-01-14T00:57:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,541
h
scene.h
/* * File: scene.h * Author: Rodrigo González del Cueto */ /* * Copyright (C) 2009 Rodrigo González del Cueto * * This file is part of Limn-Ray. * Limn-Ray 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. * * Limn-Ray 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 Limn-Ray. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SCENE_H_ #define SCENE_H_ #define INF_LIMIT std::numeric_limits<float>::infinity() #define INTERSECT_EPSILON 0.001 #define LIGHT_SCALE 10000 #include <fstream> #include <sstream> #include <iostream> #include <time.h> #include <omp.h> #include <Magick++.h> #include "primitives.cpp" #include "materials.cpp" #include "lights.cpp" #include "rays.cpp" /** * @class Scene * * @brief Main class describing a LIMN-Ray scene. * * This class is the main container of a scene, all the variables describing * a render are declared in this class together with all the functions * implementing the raytracing and lighting/shading algorithms. * */ class Scene { public: /** Number of Threads. */ int num_threads; /** String containing the output filename. */ std::string fileOut; /** Width in pixels of the rendered image. */ int image_width; /** Height in pixels of the rendered image. */ int image_height; /** Rendered image resolution Width x Height. */ int res; /** Camera up vector rotation angle. */ float cameraRollAngle; /** Camera position vector. */ float cameraPos[3]; /** Camera look at vector. */ float cameraLookAt[3]; /** Projection focal point position. */ float fPoint[3]; /** Distance from the projection plane. */ float focalLength; /** Z-Buffer's zero point. */ float focusDistance; /** Sqrt of the total samples per pixel. */ int sqrtSamplesPerPixel; /** Recursive maximum ray depth. */ int secondaryRaysDepth; /** Enable shadows flag. (0 = disabled) */ int shadows; /** Enable Z-Buffer output. (0 = disabled) */ int saveZBuffer; /** Z-Buffer normalization value. */ int zBufferMaxDepth; /** Rendered image pixel array. */ float *renderedImage; /** Z-Buffer pixel array. */ float *zBuffer; /** Scene's primitives linked list. */ PrimitiveList sceneObjects; /** Scene's materials linked list. */ MaterialList sceneMaterials; /** Scene's lights linked list. */ LightList sceneLights; /** 3x3 Ray camera rotation matrix. */ float rayTransformationMat[9]; /** * Scene class empty constructor. * Initializes all variables with non zero/NULL values. */ Scene(); /** * Initializes the scene's variables to describe the benchmarkScene * configuration. */ void benchmarkScene(); /** * This function performs the raytracer's main loop in the image array pixels. * Once all the values of a scene have been specified, by calling the render * function, the program will initialize the rendering process. * First it creates the primary rays using the Scene values, and sends them * to the raytrace() function to be processed. When the raytrace() function * returns, it loops calling buildSecondaryRays() until there are no more rays * or the #secondaryRaysDepth limit is reached. * rendering process is complete, it will output the rendered image arrays * to a PNG image file with the name #fileOut + ".png" or "image_out.png" in * case it wasn't specified at runtime. */ void render(); /** * This function performs the basic raytracing algorithm. * The render() function creates clusters of rays stored in a VisionRay array * rays and sent to this function in order to be processed. After each ray * has been processed it saves whether the ray produces a secondary ray * (reflection/refraction/transparency) and after processing all the whole * ray array it returns the number of sum of secondary rays. * * @param rays Array of rays to be processed. * @param nRays size of the rays array. * * @return The value of the sum of secondary rays produced by the rays array. */ int raytrace(VisionRay **rays, int nRays); /** * This function receives a VisionRay array, and process it to create a * second VisionRay array with the new generation of rays produces by the * old rays. * * @param oldRays Array of rays to be processed. * @param newRays Array of new generation of rays. * @param nRays size of the oldRays array. */ void buildSecondaryRays(VisionRay **oldRays, VisionRay **newRays, int nRays); /** * This function iterates through a VisionRay array and deletes the objects * stored in it. * * @param rays Array of rays to be deleted. * @param nRays size of the rays array. */ void deleteRayArray(VisionRay **rays, int nRays); /** * This function receives a ray, and checks if it intersects with any of the * objects in the scene. After going through the data structure, its gets the * first of the intersections and stores the information inside the Ray. * * If it doesn't intersect any object, it sets the ray's Ray::intersection_t value * to infinity. * * @param r Ray to be tested for intersection. */ void intersectRay(Ray *r); /** * This function receives a VisionRay after it has intersected with an object * and it calculates the resulting shading ray's assigned pixel. * * The lighting models used are the Phong diffuse light model and a specular * approximation using the halfway vector instead of actual reflection vector. * * @ param r Ray to be shaded. * @return The number of secondary rays produces by the r based on the * intersected object's material. */ int shadeRayIntersection(VisionRay *r); /** * This function outputs the Scene #renderedImage array, as well as the * #zBuffer array if enabled, into a Png image file. * * The function uses the PngWriter library to create and write the image * files. * * @param imageName The string (without extension) for the output image * filename. */ void outputImage(std::string imageName); }; #endif /* SCENE_H_ */
81302f473d4c00945ddefc80d7150b8747ca7f3e
2c7ca7e12e0f12664f4d2aedbdbf780ef7ba8892
/protobufPainter/TcpClient.h
e1807cbc803efcd67880227fd15530667e18cb77
[]
no_license
NotoriousGD/protobufPainter
e7a2cc55c0a74e4e79268489fe1901472895fc35
fda0943177af06495bc0a4407f561d64e8c4976e
refs/heads/master
2020-06-11T07:34:21.367634
2016-12-12T16:07:27
2016-12-12T16:07:27
75,732,542
0
0
null
null
null
null
UTF-8
C++
false
false
519
h
TcpClient.h
#ifndef CONNECTMODEL_H #define CONNECTMODEL_H #include <QObject> #include<QTcpSocket> #include"model.pb.h" class TcpClient : public QObject { Q_OBJECT private: QList<model*> allDots; QTcpSocket* client; QString addres; void disconnect(); public: explicit TcpClient(QObject *parent = 0); ~TcpClient(); signals: void test(); public slots: void connect(QString); void getModel(int x, int y, QString color); void send(model*); void clear(); }; #endif // CONNECTMODEL_H
17a9962849c92e1b3173a0d216de5661a07e3540
3285c1fab536f31cfa316621b3a05a27f6003ef5
/src/rstm/rstm-dev/include/common/platform.hpp
4e4a04430bbf40c9578e8e3985d70273114b0a92
[]
no_license
ucf-cs/tlds
800bd10f30ca1b6624cfbb19f46206e4f866240c
43f2e964e746b2288307629b340c039133fdbf72
refs/heads/master
2022-10-01T18:29:52.922210
2022-09-01T02:47:10
2022-09-01T02:47:10
66,377,333
21
6
null
null
null
null
UTF-8
C++
false
false
14,785
hpp
platform.hpp
/** * Copyright (C) 2011 * University of Rochester Department of Computer Science * and * Lehigh University Department of Computer Science and Engineering * * License: Modified BSD * Please see the file LICENSE.RSTM for licensing information */ /** * This file hides differences that are based on compiler, CPU, and OS. In * particular, we define: * * 1) atomic operations (cas, swap, etc, atomic 64-bit load/store) * 2) access to the tick counter * 3) clean definitions of custom compiler constructs (__builtin_expect, * alignment attributes, etc) * 4) scheduler syscalls (sleep, yield) * 5) a high-resolution timer */ #ifndef PLATFORM_HPP__ #define PLATFORM_HPP__ #include <stm/config.h> #include <stdint.h> #include <limits.h> /** * We set up a bunch of macros that we use to insulate the rest of the code * from potentially platform-dependent behavior. * * NB: This is partially keyed off of __LP64__ which isn't universally defined * for -m64 code, but it works on the platforms that we support. * * NB2: We don't really support non-gcc compatible compilers, so there isn't * any compiler logic in these ifdefs. If we begin to support the Windows * platform these will need to be more complicated */ /** * We begin by hard-coding some macros that may become platform-dependent in * the future. */ #define CACHELINE_BYTES 64 #define NORETURN __attribute__((noreturn)) #define NOINLINE __attribute__((noinline)) #define ALWAYS_INLINE __attribute__((always_inline)) #define USED __attribute__((used)) #define REGPARM(N) __attribute__((regparm(N))) /** * Pick up the BITS define from the __LP64__ token. */ #if defined(__LP64__) #define STM_BITS_64 #else #define STM_BITS_32 #endif /** * GCC's fastcall attribute causes a warning on x86_64, so we don't use it * there (it's not necessary in any case because of the native calling * convention. */ #if defined(__LP64__) && defined(STM_CPU_X86) #define GCC_FASTCALL #else #define GCC_FASTCALL __attribute__((fastcall)) #endif /** * We rely on the configured parameters here (no cross platform building yet) */ #if !defined(STM_CC_GCC) || !defined(STM_CPU_SPARC) #define TM_INLINE ALWAYS_INLINE #else #define TM_INLINE #endif #if defined(STM_CPU_X86) && !defined(STM_CC_SUN) #define TM_FASTCALL REGPARM(3) #else #define TM_FASTCALL #endif #define TM_ALIGN(N) __attribute__((aligned(N))) /** * The first task for this file is to declare atomic operations (cas, swap, * etc) and custom assembly codes, such as compiler fences, memory barriers, * and no-op instructions. This code depends on the compiler and processor. */ /** * icc is nominally an x86/x86-64 compiler that supports sync builtins, * however the stm prototype doesn't support operations on pointer types, * which we perform all the time. This header performs the fixes by #defining * the __sync builtin symbols as partial templates. */ #if defined(STM_CPU_X86) && defined(__ICC) # include "icc-sync.hpp" #endif /** * Here is the declaration of atomic operations when we're on an x86 (32bit or * 64bit) and using the GNU compiler collection. This assumes that the * compiler is recent enough that it supports the builtin __sync operations */ #if defined(STM_CPU_X86) && !defined(STM_CC_SUN) #define CFENCE __asm__ volatile ("":::"memory") #define WBR __sync_synchronize() #define cas32(p, o, n) __sync_val_compare_and_swap(p, o, n) #define cas64(p, o, n) __sync_val_compare_and_swap(p, o, n) #define casptr(p, o, n) __sync_val_compare_and_swap(p, o, n) #define bcas32(p, o, n) __sync_bool_compare_and_swap(p, o, n) #define bcas64(p, o, n) __sync_bool_compare_and_swap(p, o, n) #define bcasptr(p, o, n) __sync_bool_compare_and_swap(p, o, n) #define tas(p) __sync_lock_test_and_set(p, 1) #define nop() __asm__ volatile("nop") // NB: GCC implements test_and_set via swap #define atomicswap8(p, v) __sync_lock_test_and_set(p, v) #define atomicswap32(p, v) __sync_lock_test_and_set(p, v) #define atomicswap64(p, v) __sync_lock_test_and_set(p, v) #define atomicswapptr(p, v) __sync_lock_test_and_set(p, v) #define fai32(p) __sync_fetch_and_add(p, 1) #define fai64(p) __sync_fetch_and_add(p, 1) #define faiptr(p) __sync_fetch_and_add(p, 1) #define faa32(p, a) __sync_fetch_and_add(p, a) #define faa64(p, a) __sync_fetch_and_add(p, a) #define faaptr(p, a) __sync_fetch_and_add(p, a) #endif /** * Here is the declaration of atomic operations when we're on a sparc (32bit) * and using the GNU compiler collection. For some reason, gcc 4.3.1 __sync_* * operations can sometimes cause odd compiler crashes, so we provide our own * assembly and use it instead. * * NB: gcc doesn't provide a builtin equivalent to the SPARC swap instruction, * and thus we have to implement atomicswap ourselves. */ #if defined(STM_CPU_SPARC) && defined (STM_CC_GCC) #define CFENCE __asm__ volatile ("":::"memory") #define WBR __sync_synchronize() /** * 32-bit CAS via SPARC CAS instruction */ inline uint32_t internal_cas32(volatile uint32_t* ptr, uint32_t old, uint32_t _new) { __asm__ volatile("cas [%2], %3, %0" // instruction : "=&r"(_new) // output : "0"(_new), "r"(ptr), "r"(old) // inputs : "memory"); // side effects return _new; } /** * 64-bit CAS via SPARC CASX instruction. * * NB: This code only works correctly with -m64 specified, as otherwise GCC * refuses to use a 64-bit register to pass a value. */ inline uint64_t internal_cas64(volatile uint64_t* ptr, uint64_t old, uint64_t _new) { __asm__ volatile("casx [%2], %3, %0" // instruction : "=&r"(_new) // output : "0"(_new), "r"(ptr), "r"(old) // inputs : "memory"); // side effects return _new; } #define cas32(p, o, n) internal_cas32((uint32_t*)(p), (uint32_t)(o), (uint32_t)(n)) #ifdef STM_BITS_64 #define cas64(p, o, n) internal_cas64((uint64_t*)(p), (uint64_t)(o), (uint64_t)(n)) #define casptr(p, o, n) cas64(p, o, n) #else #define cas64(p, o, n) __sync_val_compare_and_swap(p, o, n) #define casptr(p, o, n) cas32(p, o, n) #endif #define bcas32(p, o, n) ({ o == cas32(p, (o), (n)); }) #define bcas64(p, o, n) ({ o == cas64(p, (o), (n)); }) #define bcasptr(p, o, n) ({ ((void*)o) == (void*)casptr(p, (o), (n)); }) #define tas(p) __sync_lock_test_and_set(p, 1) #define nop() __asm__ volatile("nop") // NB: SPARC swap instruction only is 32/64-bit... there is no atomicswap8 #ifdef STM_BITS_32 #define atomicswapptr(p, v) \ ({ \ __typeof((v)) v1 = v; \ __typeof((p)) p1 = p; \ __asm__ volatile("swap [%2], %0;" \ :"=r"(v1) :"0"(v1), "r"(p1):"memory"); \ v1; \ }) #else #define atomicswapptr(p, v) \ ({ \ __typeof((v)) tmp; \ while (1) { \ tmp = *(p); \ if (bcasptr((p), tmp, (v))) break; \ } \ tmp; \ }) #endif #define faa32(p,a) \ ({ __typeof(*p) _f, _e; \ do { _e = _f; } \ while ((_f = (__typeof(*p))cas32(p, _e, (_e+a))) != _e); \ _f; \ }) #define fai32(p) faa32(p,1) #define faiptr(p) __sync_fetch_and_add(p, 1) #define faa64(p, a) __sync_fetch_and_add(p, a) #define faaptr(p, a) __sync_fetch_and_add(p, a) #endif /** * Here is the declaration of atomic operations when we're using Sun Studio * 12.1. These work for x86 and SPARC, at 32-bit or 64-bit */ #if (defined(STM_CPU_X86) || defined(STM_CPU_SPARC)) && defined(STM_CC_SUN) #include <atomic.h> #define CFENCE __asm__ volatile("":::"memory") #define WBR membar_enter() #define cas32(p, o, n) atomic_cas_32(p, (o), (n)) #define cas64(p, o, n) atomic_cas_64(p, (o), (n)) #define casptr(p, o, n) atomic_cas_ptr(p, (void*)(o), (void*)(n)) #define bcas32(p, o, n) ({ o == cas32(p, (o), (n)); }) #define bcas64(p, o, n) ({ o == cas64(p, (o), (n)); }) #define bcasptr(p, o, n) ({ ((void*)o) == casptr(p, (o), (n)); }) #define tas(p) atomic_set_long_excl((volatile unsigned long*)p, 0) #define nop() __asm__ volatile("nop") #define atomicswap8(p, v) atomic_swap_8(p, v) #define atomicswap32(p, v) atomic_swap_32(p, v) #define atomicswap64(p, v) atomic_swap_64(p, v) #define atomicswapptr(p, v) atomic_swap_ptr(p, (void*)(v)) #define fai32(p) (atomic_inc_32_nv(p)-1) #define fai64(p) __sync_fetch_and_add(p, 1) #define faiptr(p) (atomic_inc_ulong_nv((volatile unsigned long*)p)-1) #define faa32(p, a) atomic_add_32(p, a) #define faa64(p, a) atomic_add_64(p, a) #define faaptr(p, a) atomic_add_long((volatile unsigned long*)p, a) // NB: must shut off 'builtin_expect' support #define __builtin_expect(a, b) a #endif /** * Now we must deal with the ability to load/store 64-bit values safely. In * 32-bit mode, this is potentially a problem, so we handle 64-bit atomic * load/store via the mvx() function. mvx() depends on the bit level and the * CPU */ #if defined(STM_BITS_64) /** * 64-bit code is easy... 64-bit accesses are atomic */ inline void mvx(const volatile uint64_t* src, volatile uint64_t* dest) { *dest = *src; } #endif #if defined(STM_BITS_32) && defined(STM_CPU_X86) /** * 32-bit on x86... cast to double */ inline void mvx(const volatile uint64_t* src, volatile uint64_t* dest) { const volatile double* srcd = (const volatile double*)src; volatile double* destd = (volatile double*)dest; *destd = *srcd; } #endif #if defined(STM_BITS_32) && defined(STM_CPU_SPARC) /** * 32-bit on SPARC... use ldx/stx */ inline void mvx(const volatile uint64_t* from, volatile uint64_t* to) { __asm__ volatile("ldx [%0], %%o4;" "stx %%o4, [%1];" :: "r"(from), "r"(to) : "o4", "memory"); } #endif /** * The next task for this file is to establish access to a high-resolution CPU * timer. The code depends on the CPU and bit level. It is identical for * 32/64-bit x86. For sparc, the code depends on if we are 32-bit or 64-bit. */ #if defined(STM_CPU_X86) /** * On x86, we use the rdtsc instruction */ inline uint64_t tick() { uint32_t tmp[2]; __asm__ ("rdtsc" : "=a" (tmp[1]), "=d" (tmp[0]) : "c" (0x10) ); return (((uint64_t)tmp[0]) << 32) | tmp[1]; } #endif #if defined(STM_CPU_SPARC) && defined(STM_BITS_64) /** * 64-bit SPARC: read the tick register into a regular (64-bit) register * * This code is based on http://blogs.sun.com/d/entry/reading_the_tick_counter and * http://sourceware.org/binutils/docs-2.20/as/Sparc_002dRegs.html */ inline uint64_t tick() { uint64_t val; __asm__ volatile("rd %%tick, %[val]" : [val] "=r" (val) : :); return val; } #endif #if defined(STM_CPU_SPARC) && defined(STM_BITS_32) /** * 32-bit SPARC: read the tick register into two 32-bit registers, then * manually combine the result * * This code is based on * http://blogs.sun.com/d/entry/reading_the_tick_counter * and * http://sourceware.org/binutils/docs-2.20/as/Sparc_002dRegs.html */ inline uint64_t tick() { uint32_t lo = 0, hi = 0; __asm__ volatile("rd %%tick, %%o2;" "srlx %%o2, 32, %[high];" "sra %%o2, 0, %[low];" : [high] "=r"(hi), [low] "=r"(lo) : : "%o2" ); uint64_t ans = hi; ans = ans << 32; ans |= lo; return ans; } #endif /** * Next, we provide a platform-independent function for sleeping for a number * of milliseconds. This code depends on the OS. * * NB: since we do not have Win32 support, this is now very easy... we just * use the usleep instruction. */ #include <unistd.h> inline void sleep_ms(uint32_t ms) { usleep(ms*1000); } /** * Now we present a clock that operates in nanoseconds, instead of in ticks, * and a function for yielding the CPU. This code also depends on the OS */ #if defined(STM_OS_LINUX) #include <stdio.h> #include <cstring> #include <assert.h> #include <pthread.h> #include <time.h> /** * Yield the CPU */ inline void yield_cpu() { pthread_yield(); } /** * The Linux clock_gettime is reasonably fast, has good resolution, and is not * affected by TurboBoost. Using MONOTONIC_RAW also means that the timer is * not subject to NTP adjustments, which is preferably since an adjustment in * mid-experiment could produce some funky results. */ inline uint64_t getElapsedTime() { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); uint64_t tt = (((long long)t.tv_sec) * 1000000000L) + ((long long)t.tv_nsec); return tt; } #endif // STM_OS_LINUX #if defined(STM_OS_SOLARIS) #include <sys/time.h> /** * Yield the CPU */ inline void yield_cpu() { yield(); } /** * We'll just use gethrtime() as our nanosecond timer */ inline uint64_t getElapsedTime() { return gethrtime(); } #endif // STM_OS_SOLARIS #if defined(STM_OS_MACOS) #include <mach/mach_time.h> #include <sched.h> /** * Yield the CPU */ inline void yield_cpu() { sched_yield(); } /** * We'll use the MACH timer as our nanosecond timer * * This code is based on code at * http://developer.apple.com/qa/qa2004/qa1398.html */ inline uint64_t getElapsedTime() { static mach_timebase_info_data_t sTimebaseInfo; if (sTimebaseInfo.denom == 0) (void)mach_timebase_info(&sTimebaseInfo); return mach_absolute_time() * sTimebaseInfo.numer / sTimebaseInfo.denom; } #endif // STM_OS_MACOS #endif // PLATFORM_HPP__
76a21132c395d7e037eaca29e135502ed2ae309e
75d19ca32d7ffbd1e9151e73b500e2b3f7e3d680
/C++11/language/lambdas/ideone_KIeyWG.cpp
c4f0b04804cf9524cfd7bbf7a0a31394b7c37c04
[ "MIT" ]
permissive
varunnagpaal/cpp
e669f664bd84e789b03d19b654dd1c252a892807
1b7e1678d05d93227caea49b5629cadd217553de
refs/heads/master
2021-06-01T11:05:27.536903
2019-10-03T05:17:38
2019-10-03T05:17:38
26,906,342
1
0
null
null
null
null
UTF-8
C++
false
false
503
cpp
ideone_KIeyWG.cpp
// lambda examples #include <iostream> #include <algorithm> #include <vector> #include <functional> int main() { std::vector<int> myvec = {2,4,1,22,14,23,14,-1,-6,90}; auto sorter = []( int const & a, int const & b){ return a<b; }; auto printer =[]( int a){ std::cout << a << ", ";}; for_each( myvec.begin(), myvec.end(), printer ); std::cout << std::endl; std::sort(myvec.begin(),myvec.end(), sorter); for_each( myvec.begin(), myvec.end(), printer ); std::cout << std::endl; return 0; }
6d588b263b1eb2fb9be6b3116dc91d3a9c6a03c3
e679ae4684fcd9fe765491242016dd2f4ca279cd
/BWT/src/BrailleTutor-0.7.1/tests/test2.cc
251ca24872aaf992f0add61edb53d177dd363284
[]
no_license
TechBridgeWorld/BrailleWritingTutor
23add5dac20238d6899a0da3ff63480576fb29f9
72d3c2d97105009587203c5ba6403861f3f22c81
refs/heads/master
2016-09-05T19:07:20.291296
2015-06-10T18:51:32
2015-06-10T18:51:32
12,303,955
1
1
null
2015-06-10T18:51:33
2013-08-22T18:01:10
C++
UTF-8
C++
false
false
6,653
cc
test2.cc
#include "Types.h" #include "IOEvent.h" #include "BrailleTutor.h" #include "ShortStylusSuppressor.h" #include <string> #include <iostream> #include <boost/thread/condition.hpp> #include <boost/thread.hpp> using namespace BrailleTutorNS; struct IOEventDemo : public IOEventHandler { // Condition variable that we use to notify main thread to quit. boost::condition &cond_quit; // IOEventParser object that we use to flush glyphs under construction. IOEventParser &iep; // The event handler virtual void operator()(std::deque<IOEvent> &events) { while(!events.empty()) { std::cout << '[' << (double) events.front().timestamp << "]\t"; // Prints out events if(events.front().type == IOEvent::STYLUS_DOWN) std::cout << "STYLUS DOWN, cell " << events.front().cell << ", dot " << (int) events.front().dot; else if(events.front().type == IOEvent::STYLUS_UP) std::cout << "STYLUS UP, cell " << events.front().cell << ", dot " << (int) events.front().dot; else if(events.front().type == IOEvent::BUTTON_DOWN) { std::cout << "BUTTON DOWN, button " << events.front().button; if(events.front().dot != INVALID_DOT) std::cout << ", dot " << (int) events.front().dot; } else if(events.front().type == IOEvent::BUTTON_UP) { std::cout << "BUTTON UP, button " << events.front().button; if(events.front().dot != INVALID_DOT) std::cout << ", dot " << (int) events.front().dot; if(events.front().button == 0) { std::cout << " (flushing glyph!) "; iep.flushGlyph(); } } else if(events.front().type == IOEvent::STYLUS) std::cout << "STYLUS, cell " << events.front().cell << ", dot " << (int) events.front().dot << ", duration " << (double) events.front().duration; else if(events.front().type == IOEvent::BUTTON) { std::cout << "BUTTON, button " << events.front().button; if(events.front().dot != INVALID_DOT) std::cout << ", dot " << (int) events.front().dot; std::cout << ", duration " << (double) events.front().duration; } else if(events.front().type == IOEvent::CELL_START) std::cout << "CELL_START, cell " << events.front().cell; else if(events.front().type == IOEvent::CELL_DONE) std::cout << "CELL_DONE, cell " << events.front().cell << ", duration " << (double) events.front().duration; else if(events.front().type == IOEvent::BUTTON_START) std::cout << "BUTTON_START"; else if(events.front().type == IOEvent::BUTTON_DONE) std::cout << "BUTTON_DONE, duration " << (double) events.front().duration; else if(events.front().type == IOEvent::CELL_DOTS) std::cout << "CELL_DOTS, cell " << events.front().cell << ", duration " << (double) events.front().duration << ", dots " << dot_string(events.front().dots); else if(events.front().type == IOEvent::BUTTON_DOTS) std::cout << "BUTTON_DOTS, duration " << (double) events.front().duration << ", dots " << dot_string(events.front().dots); else if(events.front().type == IOEvent::CELL_LETTER) { std::cout << "CELL_LETTER, cell " << events.front().cell << ", duration " << (double) events.front().duration << ", dots " << dot_string(events.front().dots) << std::flush; std::cout << ", glyph (UTF-8) \"" << (std::string) events.front().letter << "\"" << std::flush; } else if(events.front().type == IOEvent::BUTTON_LETTER) { std::cout << "BUTTON_LETTER, duration " << (double) events.front().duration << ", dots " << dot_string(events.front().dots) << std::flush; std::cout << ", glyph (UTF-8) \"" << (std::string) events.front().letter << "\"" << std::flush; } // Special event actions // Quit if the user enters the letter Q if(((events.front().type == IOEvent::BUTTON_LETTER) || (events.front().type == IOEvent::CELL_LETTER)) && (events.front().letter == "Q")) { std::cout << " QUIT!"; cond_quit.notify_one(); } std::cout << std::endl; events.pop_front(); } } // Constructor---sets references IOEventDemo(boost::condition &my_cond_quit, IOEventParser &my_iep) : cond_quit(my_cond_quit), iep(my_iep) { } }; int fakemain(int argc, char **argv) { BrailleTutor bt; boost::mutex mutex_quit; boost::condition cond_quit; std::cout << "Registering IOEventParser..." << std::endl; // The user can add the --debounce command line argument to debounce the // stylus inputs. Otherwise the BaseIOEvents are passed directly to the // IOEventParser. ShortStylusSuppressor debouncer(0.3); IOEventParser iep; if((argc > 1) && !strcmp(argv[1], "--debounce")) { std::cout << "[ DEBOUNCING ENABLED ]" << std::endl; debouncer.setBaseIOEventHandler(iep); bt.setBaseIOEventHandler(debouncer); } else bt.setBaseIOEventHandler(iep); std::cout << "Registering handler..." << std::endl; IOEventDemo demo_handler(cond_quit, iep); iep.setIOEventHandler(demo_handler); std::cout << "Subscribing to all events..." << std::endl; iep.wantEvent(IOEvent::STYLUS); iep.wantEvent(IOEvent::STYLUS_UP); iep.wantEvent(IOEvent::STYLUS_DOWN); iep.wantEvent(IOEvent::BUTTON); iep.wantEvent(IOEvent::BUTTON_UP); iep.wantEvent(IOEvent::BUTTON_DOWN); iep.wantEvent(IOEvent::CELL_START); iep.wantEvent(IOEvent::CELL_DONE); iep.wantEvent(IOEvent::BUTTON_START); iep.wantEvent(IOEvent::BUTTON_DONE); iep.wantEvent(IOEvent::CELL_DOTS); iep.wantEvent(IOEvent::CELL_LETTER); iep.wantEvent(IOEvent::BUTTON_DOTS); iep.wantEvent(IOEvent::BUTTON_LETTER); std::cout << "Initialization..." << std::endl; bt.init(); std::cout << "Detection..." << std::endl; std::string io_port; unsigned int version; bt.detect(io_port, version); std::cout << " found a version " << version << " tutor on " << io_port << std::endl; std::cout << "Punch in the letter Q to quit..." << std::endl; // Wait for the user to code 'Q" on the BT. boost::mutex::scoped_lock lock_quit(mutex_quit); cond_quit.wait(lock_quit); std::cout << "Quitting..." << std::endl; // See note in test.cc about calling exit() at the end of the program. exit(0); return 0; } int main(int argc, char **argv) { try { return fakemain(argc, argv); } catch(const BTException &e) { std::cerr << "BTException: " << e.why << std::endl; return -1; } catch(const std::string &s) { std::cerr << "String exception: " << s << std::endl; return -1; } catch(...) { std::cerr << "Some other exception happened" << std::endl; return -1; } return 0; }
8d272c2d027d01d180fbf2b9a6edeff20ead403c
d6ebbe29a5ed512889b0488620e53bc9df3ec4e1
/leetcode/03-Stacks_ and_Queues/JD0301E-ThreeInOne/ThreeInOne.cpp
f2b50f33a0f5484a1a83a0cbe9bed340cf071070
[ "MIT" ]
permissive
BinRay/Learning
ccfcfd88b4c73cf85fcdc0050b23534d16221e13
36a2380a9686e6922632e6b85ddb3d1f0903b37a
refs/heads/master
2021-07-16T20:33:38.587694
2021-03-05T08:53:29
2021-03-05T08:53:29
243,143,180
0
0
null
null
null
null
UTF-8
C++
false
false
2,952
cpp
ThreeInOne.cpp
class TripleInOne { public: TripleInOne(int stackSize) { v.resize( stackSize * 3 ); m_max = stackSize; m_index0 = 0; m_index1 = 0; m_index2 = 0; } void push(int stackNum, int value) { switch ( stackNum ){ case 0: if (m_index0 < m_max ){ v[m_index0 * 3] = value; m_index0++; } break; case 1: if (m_index1 < m_max ){ v[m_index1 * 3 + 1] = value; m_index1++; } break; case 2: if (m_index2 < m_max ){ v[m_index2 * 3 + 2] = value; m_index2++; } break; default: break; } } int pop(int stackNum) { switch ( stackNum ){ case 0: if (m_index0 > 0 ){ return v[--m_index0 * 3]; } break; case 1: if (m_index1 > 0 ){ return v[--m_index1 * 3 + 1]; } break; case 2: if (m_index2 > 0 ){ return v[--m_index2 * 3 + 2]; } break; default: break; } return -1; } int peek(int stackNum) { switch ( stackNum ){ case 0: if (m_index0 > 0 ){ return v[ (m_index0-1) * 3]; } break; case 1: if (m_index1 > 0 ){ return v[ (m_index1-1) * 3 + 1]; } break; case 2: if (m_index2 > 0 ){ return v[ (m_index2-1) * 3 + 2]; } break; default: break; } return -1; } bool isEmpty(int stackNum) { switch ( stackNum ){ case 0: if (m_index0 > 0 ){ return false; } break; case 1: if (m_index1 > 0 ){ return false; } break; case 2: if (m_index2 > 0 ){ return false; } break; default: break; } return true; } private: vector<int> v; int m_index0; int m_index1; int m_index2; int m_max; }; /** * Your TripleInOne object will be instantiated and called as such: * TripleInOne* obj = new TripleInOne(stackSize); * obj->push(stackNum,value); * int param_2 = obj->pop(stackNum); * int param_3 = obj->peek(stackNum); * bool param_4 = obj->isEmpty(stackNum); */
01751c17f5d9f2bf1037e79f9b43ae332a8bffa8
5bf722b03f711341291335c062c43f97159cc391
/src/graph-theory/destination_edge.hpp
8e8280fa2a937eebff579d49e1f8994eac07cdab
[ "MIT" ]
permissive
roma-zelinskyi/algorithms
1694d96efa253524f5637335e5c116b69671c955
cfc8a1a678186b00a47e7a33b9b6a78b7225c8c0
refs/heads/master
2023-04-12T07:23:42.481533
2021-05-17T14:17:15
2021-05-17T14:17:15
310,023,235
0
0
MIT
2020-12-29T22:40:27
2020-11-04T14:16:06
C++
UTF-8
C++
false
false
601
hpp
destination_edge.hpp
/** * Project Graph * * @author Roman Zelinskyi <lord.zelinskyi@gmail.com> */ #pragma once #include <functional> namespace cppgraph { template<class _NodeDescriptor> class DestinationEdge { public: constexpr explicit DestinationEdge(const _NodeDescriptor& to, const double w) : _to{to} , _weight{w} { } constexpr const _NodeDescriptor& to() const noexcept { return _to; } constexpr double weight() const noexcept { return _weight; } protected: _NodeDescriptor _to; double _weight; }; } // namespace cppgraph
3ddb8816b93f0a20b69821528c3da9136eddf57a
7195ef5a7df65115eef2225ca44ea85587917195
/gengine_lib/src/gphys/phys_script_registration.cpp
ad99494abadb06c90b616428cb06dcd8de233d98
[]
no_license
GuillaumeArruda/GEngine
dd4f645cc92730aa76040550d355fba5b41c6e1c
8be545426d90b57bda184864e73e1329907ace65
refs/heads/main
2023-08-08T00:33:17.431719
2023-07-19T21:25:36
2023-07-19T21:25:36
321,533,177
0
0
null
null
null
null
UTF-8
C++
false
false
446
cpp
phys_script_registration.cpp
#include "stdafx.h" #include "gcore/script/node_data_type.h" #include "gcore/resource_handle.h" #include "gphys/phys_script_registration.h" #include "gphys/resources/collision_shape.h" namespace gphys { void register_node_data_type() { gcore::node_data_type_registry& registry = gcore::node_data_type_registry::get(); registry.register_type<gcore::resource_handle<gphys::collision_shape>>("Collision Shape"); } }
b2459581a16513ebafa9da808e35ab97f0946f24
501656109d2e92441deb4cfc5ed0dccb50208935
/2014网络赛/1st/B.cpp
6d22ad6cd011c28072792a0ec608a275d2511e83
[]
no_license
ailyanlu1/Acm-icpc-6
32cb3c7c5760dd6fd2f1d641e4dd2b130e317fed
b4c86f65aeb8ce4f4949046a4d3ce9c390034f22
refs/heads/master
2020-03-23T13:55:38.122388
2014-10-01T03:11:58
2014-10-01T03:11:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,933
cpp
B.cpp
#include <iostream> #include <sstream> #include <ios> #include <iomanip> #include <functional> #include <algorithm> #include <vector> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <climits> #include <cctype> using namespace std; #define XINF INT_MAX #define INF 0x3FFFFFFF #define MP(X,Y) make_pair(X,Y) #define PB(X) push_back(X) #define REP(X,N) for(int X=0;X<N;X++) #define REP2(X,L,R) for(int X=L;X<=R;X++) #define DEP(X,R,L) for(int X=R;X>=L;X--) #define CLR(A,X) memset(A,X,sizeof(A)) #define IT iterator typedef long long ll; typedef pair<int,int> PII; typedef vector<PII> VII; typedef vector<int> VI; int block[200][200]; int n; void vprint() { for(int i=0;i<n;i++) { for(int j=0;j<n;j++) cout<<block[i][j]<<" "; cout<<endl; } } int main() { ios::sync_with_stdio(false); #ifdef LOCAL // freopen("in","r",stdin); #endif int T; cin>>T; while(T--){ int color = 0; cin>>n; ++color; for(int i=0;i<n;i++){ block[i][0] = color; } ++color; for(int i=1;i<n;i++){ block[n-1][i] = color; } block[n-2][n-1] = 2; int line,row; line = n-1; for(int k=2;k<=n-4+1;k++){ ++color; row = 0; for(int c = 0;c<n;c++){ if( block[row][line] !=0){ row -- ; line--; c--; }else{ block[row][line] = color; row++; } } } ++color; for(int i=0;;i++){ cout<<i<<" "<<line<<endl; while( block[i][line]==0){ block[i][line] = color; } break; } vprint(); } return 0; }
cb014b1db138e3c7354ef7e3ad2430fb66919db9
104d3b210b9c70505a4041f0acc11d5745b9028b
/Source/LetsGo/DiContainers/IDiContainerFactory.h
74dde66d8be87ef45fa789eb2383fd179f1e76c5
[]
no_license
lmbrmb/LetsGo
12cbf1e736836b362fe4722a1261b1c1bf7f502a
4ac0e256354179eb35774b4902d191bb523ded40
refs/heads/master
2023-06-05T18:22:01.669851
2021-06-29T08:59:31
2021-06-29T08:59:31
326,523,056
1
0
null
null
null
null
UTF-8
C++
false
false
287
h
IDiContainerFactory.h
#pragma once #include "LetsGo/Data/IUObjectRegistry.h" #include "Misc/TypeContainer.h" template <ESPMode Mode> class IDiContainerFactory { protected: ~IDiContainerFactory() = default; private: virtual TTypeContainer<Mode>* CreateContainer(IUObjectRegistry* uObjectRegistry) = 0; };
d3f7ecf5fdc4133546623278a42ffa368fcdd9d1
e8f0256d91dc62361beec505ce47be48fbac0d0d
/DataSource/owchart/include/Chart/CIndicator.h
6dee4c822dc1b71065067fd3c3218713cb6dc51c
[]
no_license
Scott3066026158/datasource
0b3feae069624cb61626c88bd9954010eb3bc095
d0275a720cf084125c90ca0a3614e2faaf1aa787
refs/heads/master
2020-06-25T18:05:27.954264
2019-07-29T05:47:26
2019-07-29T05:47:26
199,384,454
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
9,658
h
CIndicator.h
/*****************************************************************************\ * * * CIndicator.h - Indicator functions, types, and definitions * * * * Version 4.00 ¡ï¡ï¡ï¡ï¡ï * * * * Copyright (c) 2016-2016, Gaia's owchart. All rights reserved. * * * *******************************************************************************/ #ifndef __CINDICATOR_H__ #define __CINDICATOR_H__ #pragma once #define FUNCTIONID_CHUNK 40 #define FUNCTIONID_FUNCVAR 10 #define FUNCTIONID_FUNCTION 9 #define FUNCTIONID_VAR 10 #include "..\\..\\stdafx.h" #include "..\\Base\\CStr.h" #include "..\\Base\\CMathLib.h" #include "Enums.h" #include "CTable.h" #include "CDiv.h" #include "CList.h" #include "BaseShape.h" namespace OwLib { class CIndicator; class CMathElement; class CVariable { public: CVariable(); virtual ~CVariable(); BarShape *m_barShape; CandleShape *m_candleShape; wstring m_expression; int m_field; int m_fieldIndex; wstring m_fieldText; int m_functionID; wstring m_funcName; CIndicator *m_indicator; int m_line; PointShape *m_pointShape; PolylineShape *m_polylineShape; wstring m_name; CVariable **m_parameters; int m_parametersLength; CMathElement **m_splitExpression; int m_splitExpressionLength; int *m_tempFields; int m_tempFieldsLength; int *m_tempFieldsIndex; int m_tempFieldsIndexLength; TextShape *m_textShape; int m_type; double m_value; void CreateTempFields(int count); }; class CMathElement { public: CMathElement(); CMathElement(int type, double value); virtual ~CMathElement(); int m_type; double m_value; CVariable *m_var; }; class CMathElementEx : public CMathElement { public: CMathElementEx *m_next; CMathElementEx(int type, double value):CMathElement(type, value) { m_next = 0; } virtual ~CMathElementEx() { if(m_next) { delete m_next; m_next = 0; } } }; class CFunction { public: CFunction(); virtual ~CFunction(); int m_ID; wstring m_name; int m_type; public: virtual double OnCalculate(CVariable *var); }; class CVar { public: vector<wstring> *m_list; map<wstring, wstring> *m_map; double m_num; wstring m_str; int m_type; CVar *m_parent; public: CVar() { m_list = 0; m_map = 0; m_parent = 0; } virtual ~CVar() { if (m_list) { delete m_list; m_list = 0; } if (m_map) { delete m_map; m_map = 0; } m_parent = 0; } public: virtual wstring GetText(CIndicator *indicator, CVariable *name); virtual double GetValue(CIndicator *indicator, CVariable *name); virtual double OnCreate(CIndicator *indicator, CVariable *name, CVariable *value); virtual void SetValue(CIndicator *indicator, CVariable *name, CVariable *value); }; class CVarFactory { public: virtual CVar* CreateVar() { return new CVar; } }; class CIndicator { protected: CRITICAL_SECTION _csLock; map<wstring,double> m_defineParams; map<wstring,CFunction*> m_functions; map<int, CFunction*> m_functionsMap; int m_index; vector<CVariable*> m_lines; vector<_int64> m_systemColors; void *m_tag; map<wstring, CVariable*> m_tempFunctions; map<wstring, CVariable*> m_tempVariables; vector<CVariable*> m_variables; CVarFactory *m_varFactory; protected: AttachVScale m_attachVScale; int m_break; CTable *m_dataSource; CDiv *m_div; wstring m_name; double m_result; CVar m_resultVar; protected: void AnalysisVariables(wstring *sentence, int line, wstring funcName, wstring fieldText, bool isFunction); void AnalysisScriptLine(wstring line); double Calculate(CMathElement **expr, int exprLength); double CallFunction(CVariable *var); void DeleteTempVars(); void DeleteTempVars(CVariable *var); _int64 GetColor(const wstring& strColor); LPDATA GetDatas(int fieldIndex, int mafieldIndex, int index, int n); float GetLineWidth(const wstring& strLine); int GetMiddleScript(const wstring& script, vector<wstring> *lines); int GetOperator(const wstring& op); bool IsNumeric(const wstring& str); wstring Replace(const wstring& parameter); CMathElement** SplitExpression(const wstring& expression, int *sLength); wstring* SplitExpression2(const wstring& expression, int *sLength); public: CIndicator(); virtual ~CIndicator(); map<wstring ,int> m_mainVariables; map<int, CVar*> m_tempVars; virtual AttachVScale GetAttachVScale(); virtual void SetAttachVScale(AttachVScale attachVScale); virtual CTable* GetDataSource(); virtual void SetDataSource(CTable *dataSource); virtual CDiv* GetDiv(); virtual void SetDiv(CDiv *div); virtual int GetIndex(); virtual wstring GetName(); virtual void SetName(const wstring& name); virtual double GetResult(); virtual void SetScript(const wstring& script); virtual vector<_int64> GetSystemColors(); virtual void SetSystemColors(vector<_int64> systemColors); virtual void* GetTag(); virtual void SetTag(void *tag); virtual CVarFactory* GetVarFactory(); virtual void SetVarFactory(CVarFactory *varFactory); public: void AddFunction(CFunction *function); double CallFunction(wstring funcName); void Clear(); vector<CFunction*> GetFunctions(); vector<BaseShape*> GetShapes(); wstring GetText(CVariable *var); double GetValue(CVariable *var); CVariable* GetVariable(const wstring& name); void Lock(); void OnCalculate(int index); void RemoveFunction(CFunction *function); void SetSourceField(const wstring& key, int value); void SetSourceValue(int index, const wstring& key, double value); void SetVariable(CVariable *variable, CVariable *parameter); void UnLock(); protected: double ABS2(CVariable *var); double AMA(CVariable *var); double ACOS(CVariable *var); double ASIN(CVariable *var); double ATAN(CVariable *var); double AVEDEV(CVariable *var); int BARSCOUNT(CVariable *var); int BARSLAST(CVariable *var); int BETWEEN(CVariable *var); int BREAK(CVariable *var); double CEILING(CVariable *var); double CHUNK(CVariable *var); int CONTINUE(CVariable *var); double COS(CVariable *var); int COUNT(CVariable *var); int CROSS(CVariable *var); int CURRBARSCOUNT(CVariable *var); int DATE(CVariable *var); int DAY(CVariable *var); int DELETE2(CVariable *var); double DMA(CVariable *var); int DOTIMES(CVariable *var); int DOWHILE(CVariable *var); int DOWNNDAY(CVariable *var); double DRAWICON(CVariable *var); double DRAWKLINE(CVariable *var); double DRAWNULL(CVariable *var); double DRAWTEXT(CVariable *var); int EXIST(CVariable *var); double EMA(CVariable *var); int EVERY(CVariable *var); double EXPMEMA(CVariable *var); double EXP(CVariable *var); double FLOOR(CVariable *var); int FOR(CVariable *var); double FUNCTION(CVariable *var); double FUNCVAR(CVariable *var); double GET(CVariable *var); double HHV(CVariable *var); double HHVBARS(CVariable *var); int HOUR(CVariable *var); double IF(CVariable *var); double IFN(CVariable *var); double INTPART(CVariable *var); int LAST(CVariable *var); double LLV(CVariable *var); double LLVBARS(CVariable *var); double LOG(CVariable *var); double MA(CVariable *var); double MAX2(CVariable *var); double MEMA(CVariable *var); double MIN2(CVariable *var); int MINUTE(CVariable *var); double MOD(CVariable *var); int MONTH(CVariable *var); int NDAY(CVariable *var); int NOT(CVariable *var); double POLYLINE(CVariable *var); double POW(CVariable *var); int RAND(CVariable *var); double REF(CVariable *var); double RETURN(CVariable *var); double REVERSE(CVariable *var); double ROUND(CVariable *var); double SAR(CVariable *var); double SET(CVariable *var); int SIGN(CVariable *var); double SIN(CVariable *var); double SMA(CVariable *var); double SQRT(CVariable *var); double SQUARE(CVariable *var); double STD(CVariable *var); double STICKLINE(CVariable *var); double SUM(CVariable *var); double TAN(CVariable *var); int TIME(CVariable *var); int TIME2(CVariable *var); double TMA(CVariable *var); int UPNDAY(CVariable *var); double VALUEWHEN(CVariable *var); double VAR(CVariable *var); int WHILE(CVariable *var); double WMA(CVariable *var); int YEAR(CVariable *var); double ZIG(CVariable *var); public: int STR_CONTACT(CVariable *var); int STR_EQUALS(CVariable *var); int STR_FIND(CVariable *var); int STR_FINDLAST(CVariable *var); int STR_LENGTH(CVariable *var); int STR_SUBSTR(CVariable *var); int STR_REPLACE(CVariable *var); int STR_SPLIT(CVariable *var); int STR_TOLOWER(CVariable *var); int STR_TOUPPER(CVariable *var); int LIST_ADD(CVariable *var); int LIST_CLEAR(CVariable *var); int LIST_GET(CVariable *var); int LIST_INSERT(CVariable *var); int LIST_REMOVE(CVariable *var); int LIST_SIZE(CVariable *var); int MAP_CLEAR(CVariable *var); int MAP_CONTAINSKEY(CVariable *var); int MAP_GET(CVariable *var); int MAP_GETKEYS(CVariable *var); int MAP_REMOVE(CVariable *var); int MAP_SET(CVariable *var); int MAP_SIZE(CVariable *var); }; } #endif
aa778a35c53142be32d5d49ac11427450d8e9757
9461965cd31489fbdbe542561500b3e226e14ae5
/RubeGoldberg/PhysicsProject/Level.cpp
60c7e480f22e76a291d62cf057932ff8fd486335
[]
no_license
JakeEllenberg/GamePhysics
f6931f5077080c89676fc3dd9b0e2992864cfed0
f97f5da816df3f5631bd10c09fc9039bed87c91a
refs/heads/master
2020-12-24T15:32:32.420712
2015-05-01T02:24:58
2015-05-01T02:24:58
29,218,225
0
0
null
null
null
null
UTF-8
C++
false
false
7,204
cpp
Level.cpp
//====================================================================== //File: Level.h //Author: Jake Ellenberg //Created: 3/21/2015 //Purpose: Hold level data //====================================================================== #include "Level.h" #include "RodContactGenerator.h" #include "CableContactGenerator.h" #include "SpringForceGenerator.h" #include "BungeeForceGenerator.h" #include "Cube.h" #include "Tetrahedron.h" #include "Pyramid.h" #include <iostream> #include <fstream> #include "ImageHandler.h" #include "RigidSphere.h" #include "RigidBox.h" //-------------------------------------------------------------------------------- Level::Level() { } //-------------------------------------------------------------------------------- Level::~Level() { CleanUp(); } //-------------------------------------------------------------------------------- void Level::Initialize() { m_Ground = new Ground(); m_Ground->Inititalize("Sky_bot"); m_Player = new Player(); m_Player->Inititalize(1.0f, Vector3D(0,5,0), Vector3D(0,0,0), Vector3D::Zero, Vector3D::Zero, 1.0f, "Smile1"); m_Player->SetSpeed(50.0f); m_Player->SetDampening(.99f); RigidSphere* sphere = new RigidSphere(); sphere->Inititalize("Smile1", 1.0f, 1.0f, Vector3D(1, 15, 0)); RigidBox* box = new RigidBox(); box->Inititalize("Smile2", 1.0f, 1.0f, Vector3D(5, 5, 0)); RigidSphere* sphere2 = new RigidSphere(); sphere2->Inititalize("Smile3", 1.0f, 1.0f, Vector3D(-1, 10, 0)); RigidSphere* sphere3 = new RigidSphere(); sphere3->Inititalize("Smile4", 1.0f, 1.0f, Vector3D(0, 5, 1)); //sphere2->AddVelocity(Vector3D(6, 0, 0)); RigidSphere* sphere4 = new RigidSphere(); sphere4->Inititalize("Smile5", 1.0f, 1.0f, Vector3D(0, 20, -1)); RigidSphere* sphere5 = new RigidSphere(); sphere5->Inititalize("Smile1", 1.0f, 1.0f, Vector3D(0, 25, 0)); RigidSphere* sphere6 = new RigidSphere(); sphere6->Inititalize("Smile2", 1.0f, 1.0f, Vector3D(0, 30, 0)); RigidSphere* sphere7 = new RigidSphere(); sphere7->Inititalize("Smile3", 1.0f, 1.0f, Vector3D(0, 35, 0)); m_RigidRenders.push_back(sphere); m_RigidRenders.push_back(sphere2); m_RigidRenders.push_back(sphere3); m_RigidRenders.push_back(sphere4); m_RigidRenders.push_back(sphere5); m_RigidRenders.push_back(sphere6); m_RigidRenders.push_back(sphere7); m_RigidRenders.push_back(box); LoadShapes("Characters/LevelInfo.txt"); } //-------------------------------------------------------------------------------- // Text file format: // First number shape 0 - Cube 1 - Pyramid 2 - Tetrahedon // Second number shape length // Third number 0 - Collectable 1 - Ebeny // Forth Fith and Sixth number X Y Z position. void Level::LoadShapes(std::string filePath) { std::ifstream inputFile(filePath); std::string line; while (std::getline(inputFile, line)) { std::vector<int> values; size_t pos = 0; std::string token; int position = 0; while ((pos = line.find(" ")) != std::string::npos) { token = line.substr(0, pos); line.erase(0, pos + 1); int value = GetValue(token, position); if (value != -1) { values.push_back(value); } position++; } values.push_back(GetValue(line, position)); if (values.size() != 6) { return; } Shape* shapeToAdd; std::string filePath; switch (values[0]) { case 0: shapeToAdd = new Cube(); filePath = "Smile2"; break; case 1: shapeToAdd = new Pyramid(); filePath = "Smile3"; break; case 2: shapeToAdd = new Tetrahedron(); filePath = "Smile5"; break; default: continue; break; } if (values[2] == 0) { m_Collectables.push_back(shapeToAdd); } else { m_Enemies.push_back(new EnemyAI(m_Player, shapeToAdd, 5.0f)); filePath = "Smile4"; } shapeToAdd->Inititalize(Vector3D((float)values[3], (float)values[4], (float)values[5]), filePath, (float)values[1]); AddShape(shapeToAdd); } } //-------------------------------------------------------------------------------- int Level::GetValue(std::string word, int position) { std::string::size_type sz; switch (position) { case 0: if (word == "CUBE") { return 0; } else if (word == "PYRAMID") { return 1; } else if (word == "TETRAHEDRON") { return 2; } return -1; case 1: return -1; case 3: return word == "COLLECTABLE" ? 0 : 1; case 4: return -1; default: return std::stoi(word, &sz); } } //-- void Level::UpdateAI() { for each(EnemyAI* enemyAI in m_Enemies) { enemyAI->Update(); } } //-------------------------------------------------------------------------------- void Level::AddShape(Shape* shape) { std::vector<RenderObject*> objects = shape->GetRenderObjects(); m_RenderObjects.insert(m_RenderObjects.end(), objects.begin(), objects.end()); std::vector<RodContactGenerator*> rods = shape->GetRods(); m_ContactGenerators.insert(m_ContactGenerators.end(), rods.begin(), rods.end()); m_Shapes.push_back(shape); } std::vector<Shape*> Level::GetCollidingCollectables() { std::vector<Shape*> collectables; for (unsigned int i = 0; i < m_Collectables.size(); i++) { if (m_Collectables[i]->GetRenderObjects()[0]->GetPosition().CalculateDistance(m_Player->GetPosition()) < 5) { collectables.push_back(m_Collectables[i]); m_Collectables.erase(m_Collectables.begin() + i); i--; } } return collectables; } std::vector<EnemyAI*> Level::GetCollidingEnemies() { std::vector<EnemyAI*> enemies; for each(EnemyAI* enemyAI in m_Enemies) { if (!enemyAI->CheckPlayerAttached() && enemyAI->GetPlayerDistance() < 4) { enemies.push_back(enemyAI); } } return enemies; } //-------------------------------------------------------------------------------- void Level::Draw() { /* for (unsigned int i = 0; i < m_RenderObjects.size(); i++) { m_RenderObjects[i]->Draw(); } */ for (unsigned int i = 0; i < m_RigidRenders.size(); i++) { m_RigidRenders[i]->Draw(); } m_Ground->Draw(); //m_Player->Draw(); } std::vector<PhysicsObject*> Level::GetCollisionObjects() { std::vector<PhysicsObject*> collisionObjects; collisionObjects.push_back(m_Player); for each(RenderObject* object in m_RenderObjects) { collisionObjects.push_back(object); } return collisionObjects; } std::vector<ContactGenerator*> Level::GetContactGenerators() { return m_ContactGenerators; } std::map<SpringForceGenerator*, std::vector<PhysicsObject*>> Level::GetSpringForceGenerators() { return m_SpringForceGenerators; } //-------------------------------------------------------------------------------- void Level::CleanUp() { delete m_Ground; m_Ground = nullptr; delete m_Player; m_Player = nullptr; for (unsigned int i = 0; i < m_RenderObjects.size(); i++) { delete m_RenderObjects[i]; } for (unsigned int i = 0; i < m_Shapes.size(); i++) { delete m_Shapes[i]; } m_Shapes.clear(); m_RenderObjects.clear(); m_ContactGenerators.clear(); }
a27d98ab7bf9d6d3db9984258da008c1a8f8f0a3
f33ad4d971375ef588218703bb4a4f60156088de
/src/CodigosDelta/ArchivoComprimido.cpp
4ff98bdf7ded0fe2fcd778b42bd9c0b884b7ff80
[]
no_license
pellarolojuani/pruebas
b0d1a9f241b826ae809850c3769b4bf00306b8a5
4580c0a16910dc76c5e276668b0b22a7a176d382
refs/heads/master
2021-05-28T11:00:04.443312
2013-06-23T08:42:15
2013-06-23T08:42:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,751
cpp
ArchivoComprimido.cpp
/* * ArchivoGamma.cpp * * Created on: 19/06/2013 * Author: matias */ #include "ArchivoComprimido.h" #include <iostream> #include "../NombresArchivos.h" ArchivoComprimido::ArchivoComprimido() { this->abrir(); } ArchivoComprimido::~ArchivoComprimido() { this->cerrar(); } void ArchivoComprimido::abrir() { this->file.open(constantes::NombresArchivos::archivoComprimido, std::fstream::in | std::fstream::out | std::fstream::binary); } void ArchivoComprimido::cerrar() { if (file.is_open()) file.close(); } void ArchivoComprimido::setPosicion(long posicion){ file.seekp(posicion); } int ArchivoComprimido::guardarVector(std::vector<unsigned int> vector) { char* destino; int posPrincipio = file.tellp(); //Le agrego el tamaño al principio de todo vector.insert(vector.begin(),vector.size()); //Codifico el vector unsigned int bits = gamma.codificar(vector.data(), vector.size(), destino); unsigned int bytes = (bits - 1)/8 + 1; //Lo guardo al archivo file.write(destino, bytes); return posPrincipio; } std::vector<unsigned int> ArchivoComprimido::levantarVector(int posicion) { file.clear(); std::vector<unsigned int> result; this->setPosicion(posicion); //Armo un buff generoso para el primer número char* buf = new char[8]; file.read(buf, 8); file.clear(); //Leo el largo de la lista (y le agrego el 1er número, que representa el largo) int size = gamma.decodificar(buf) + 1; //Ahora leo todos los números this->setPosicion(posicion); delete[] buf; buf = new char[size * 8]; file.read(buf, size * 8); file.clear(); int* intArray = this->gamma.decodificar(buf, size); //Y los agrego al vector result = std::vector<unsigned int>(intArray + 1, intArray + size); delete[] buf; return result; }
250e13408b401ad97948a20d208d11c88cc7f81c
90ba2423edb624607c1fca5c89964b6cc3165ef8
/src/util/torus_matrix.h
d09b99e285cd81f2761ae67e44b4d8f68e9a1aa8
[ "MIT" ]
permissive
KnairdA/termlife
37e92f5e531b7adf82dffc930def291463ac700e
01f9aa0cc8d3d8f5e862f0dffa282002e5ec55de
refs/heads/master
2021-01-12T09:32:32.033706
2017-03-26T13:39:49
2017-03-26T13:39:49
76,186,947
0
0
null
null
null
null
UTF-8
C++
false
false
1,045
h
torus_matrix.h
#ifndef LIFE_SRC_UTIL_TORUS_MATRIX_ #define LIFE_SRC_UTIL_TORUS_MATRIX_ #include <array> #include <cstdint> namespace life { namespace util { template< typename TYPE, std::size_t WIDTH, std::size_t HEIGHT > class TorusMatrix { static std::size_t toMatrixColumn(const std::ptrdiff_t x) { if ( x >= 0 ) { return x % WIDTH; } else { return WIDTH - ( std::abs(x) % WIDTH ); } } static std::size_t toMatrixRow(const std::ptrdiff_t y) { if ( y >= 0 ) { return y % HEIGHT; } else { return HEIGHT - ( std::abs(y) % HEIGHT ); } } public: static const std::size_t width = WIDTH; static const std::size_t height = HEIGHT; TYPE get(const std::ptrdiff_t x, const std::ptrdiff_t y) const { return this->matrix_[toMatrixRow(y)][toMatrixColumn(x)]; } void set(const std::ptrdiff_t x, const std::ptrdiff_t y, TYPE&& value) { this->matrix_[toMatrixRow(y)][toMatrixColumn(x)] = value; } private: std::array<std::array<TYPE, WIDTH>, HEIGHT> matrix_; }; } } #endif // LIFE_SRC_UTIL_TORUS_MATRIX_
a83bd998bf53de600b7be4fe205f602362ad7f30
dd5639d2b206d5a38ecff6056a26cf185ceaf18e
/My Projects/SFML Source codes/SFML Test/SFML Test/Entity.cpp
b2c9b0514d9a390cfcebff28599d0398ab5c2e9a
[]
no_license
LeulShiferaw/resume
7a84f0cb78528011b70d01796d5fda86922ca43c
812539fe4a12329472391980b6f37d4bb440c0d1
refs/heads/master
2021-04-09T10:50:36.063786
2018-03-16T12:34:00
2018-03-16T12:34:00
125,513,147
0
0
null
null
null
null
UTF-8
C++
false
false
248
cpp
Entity.cpp
#include "Entity.hpp" void Entity::setVelocity(sf::Vector2f n) { mVelocity = n; } void Entity::setVelocity(float x, float y) { mVelocity.x = x; mVelocity.y = y; } sf::Vector2f Entity::getVelocity() const { return mVelocity; }
adb82db3a5d8bcbc33218de2012cb07f2154eedf
a0c5688b0461c9a3bbfb25902de814c42474e2db
/Self-accelerating Processing Workflows/src/ComputationalModel.cpp
bb61a585ce1507f40a44f70fa60a2a0384f3e449
[]
no_license
nirojanthiya/Self-Accelerating-Processing-Workflows-VS
36e42f5607f1160b7da220d56a9968f2457ccdb6
4e70a8c4bb8689eb9438778339ddbbc3540bde74
refs/heads/master
2023-01-11T17:46:19.186761
2020-11-12T10:37:55
2020-11-12T10:37:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,890
cpp
ComputationalModel.cpp
#include <iostream> #include <fstream> #include <string> #include <sstream> #include <ComputationalModel.h> #include <MatrixMulMLModel.h> #include <Logger.h> //for time measure #include <windows.h> #include <time.h> #include <stdio.h> //for async function #include <thread> #include <future> #include "CurrentCPULoad.cpp" using namespace std; __int64 currentTimeMillis(); bool ComputationalModel::operationalMode = false; ComputationalModel::ComputationalModel(int CPUCores_):CPUCores(CPUCores_) { obj_id = obj_id_counter(); resetFlow(); resetOperator = thread(&ComputationalModel::resetOverPeriodIfBurst, this); resetOperator.detach(); mlTrainer = thread(&ComputationalModel::checkMLModel, this); mlTrainer.detach(); mlModel = new MatrixMulMLModel(); } inline void ComputationalModel::resetFlow() { clocks = { 0, 0, 0.0, 0.0 }; countS = 1; countL = 1; alignedCount = -1; reviseCount = REVISE_COUNT_MIN; revisePeriod = REVISE_PERIOD; sampleMode = 2; processor = -1; lastProcessor = -1; // id_ = int(&*this); } ComputationalModel::~ComputationalModel(){ resetOperator.~thread(); mlTrainer.~thread(); Logger::close(); //TO DO; log present values for using next boot } // Mannual mode execution void ComputationalModel::execute(int mode) { switch (mode) { case 1: // cout << "Hello CPU" << endl; CPUImplementation(); break; case 2: // cout << "Hello GPU" << endl; GPUImplementation(); break; } } void ComputationalModel::executeAndLogging(int mode) { // first class name, object id, data and finally the execution time LARGE_INTEGER start_cover; LARGE_INTEGER stop_cover; QueryPerformanceCounter(&start_cover); switch (mode) { case 1: // cout << "Hello CPU" << endl; CPUImplementation(); break; case 2: // cout << "Hello GPU" << endl; GPUImplementation(); break; } QueryPerformanceCounter(&stop_cover); duration = stop_cover.QuadPart - start_cover.QuadPart; stringstream s; s << typeid(*this).name() << ","; int* attr = getAttributes(); for (int i = 1; i <= attr[0]; i++) { s << attr[i] << ","; } if (mode == 1) s << 0 << ","; else s << 1 << ","; s << duration << endl; logExTime(s.str()); } // Auto mode execution void ComputationalModel::execute() { switch (processor) { case 1: //cout << "Hello CPU" << endl; CPUImplementation(); countL++; break; case 2: //cout << "Hello GPU" << endl; GPUImplementation(); countL++; break; case -1: // cout << "Hello CPU" << endl; QueryPerformanceCounter(&start); CPUImplementation(); QueryPerformanceCounter(&stop); clocks.CPU += stop.QuadPart - start.QuadPart; // cout << stop.QuadPart - start.QuadPart << " clocks" << endl; if (++countS > SAMPLE_COUNT) { if (--sampleMode == 0) { if (clocks.CPU > clocks.GPU) { processor = 2; reviseCount += REVISE_COUNT_STEP * ++alignedCount; } else { processor = 1; reviseCount = REVISE_COUNT_MIN; alignedCount = 0; } lastRevisedClock.QuadPart = stop.QuadPart; } else { processor = -2; // processor = (processor - 1) % 3; countS = 1; } } return; case -2: // cout << "Hello GPU" << endl; QueryPerformanceCounter(&start); GPUImplementation(); QueryPerformanceCounter(&stop); clocks.GPU += stop.QuadPart - start.QuadPart; // cout << stop.QuadPart - start.QuadPart << " clocks" << endl; if (++countS > SAMPLE_COUNT) { if (--sampleMode == 0) { if (clocks.CPU > clocks.GPU) { processor = 2; reviseCount = REVISE_COUNT_MIN; alignedCount = 0; } else { processor = 1; reviseCount += REVISE_COUNT_STEP * ++alignedCount; } lastRevisedClock.QuadPart = stop.QuadPart; } else { processor = -1; // processor = (processor - 1) % 3; countS = 1; } } return; default: sampleMode = 2; processor = -1; } if (countL > reviseCount) { sampleMode = 2; countS = 1; countL = 1; processor = -processor; clocks = { 0, 0, 0.0, 0.0 }; // cout << endl; } } void ComputationalModel::executeAndLogging() { LARGE_INTEGER start_cover; LARGE_INTEGER stop_cover; QueryPerformanceCounter(&start_cover); switch (processor) { case 1: // cout << "Hello CPU" << endl; CPUImplementation(); break; case 2: // cout << "Hello GPU" << endl; GPUImplementation(); break; case -1: // cout << "Hello CPU" << endl; QueryPerformanceCounter(&start); CPUImplementation(); QueryPerformanceCounter(&stop); clocks.CPU += stop.QuadPart - start.QuadPart;; // cout << stop.QuadPart - start.QuadPart << " clocks" << endl; if (++countS > SAMPLE_COUNT) { if (--sampleMode == 0) { if (clocks.CPU > clocks.GPU) { processor = 2; reviseCount += REVISE_COUNT_STEP * ++alignedCount; } else { processor = 1; reviseCount = REVISE_COUNT_MIN; alignedCount = 0; } lastRevisedClock.QuadPart = stop.QuadPart; // cout << "REVISE_COUNT: " << reviseCount << endl; // cout << alignedCount << "," << clocks.CPU << "," << clocks.GPU << endl << endl; } else { processor = -2; // processor = (processor - 1) % 3; countS = 1; } } break; case -2: // cout << "Hello GPU" << endl; QueryPerformanceCounter(&start); GPUImplementation(); QueryPerformanceCounter(&stop); clocks.GPU += stop.QuadPart - start.QuadPart;; // cout << stop.QuadPart - start.QuadPart << " clocks" << endl; if (++countS > SAMPLE_COUNT) { if (--sampleMode == 0) { if (clocks.CPU > clocks.GPU) { processor = 2; reviseCount = REVISE_COUNT_MIN; alignedCount = 0; } else { processor = 1; reviseCount += REVISE_COUNT_STEP * ++alignedCount; } lastRevisedClock.QuadPart = stop.QuadPart; } else { processor = -1; // processor = (processor - 1) % 3; countS = 1; } } break; default: sampleMode = 2; processor = -1; } QueryPerformanceCounter(&stop_cover); duration = stop_cover.QuadPart - start_cover.QuadPart; stringstream s; s << typeid(*this).name() << ","; int* attr = getAttributes(); for (int i = 1; i <= attr[0]; i++) { s << attr[i] << ","; } if (processor == 1 || processor == -1) { s << 0 << ","; } else { s << 1 << ","; } s << duration << endl; logExTime(s.str()); if (processor == -2 || processor == -1) return; if (countL > reviseCount) { sampleMode = 2; countS = 1; countL = 1; processor = -processor; clocks = { 0, 0, 0.0, 0.0 }; } } void ComputationalModel::executeByML() { if (mlModel->predict(getAttributes()) == 0) { CPUImplementation(); } else { GPUImplementation(); } } void ComputationalModel::executeByMLAndLogging() { stringstream s; s << typeid(*this).name() << ","; int* attr = getAttributes(); for (int i = 1; i <= attr[0]; i++) { s << attr[i] << ","; } if (mlModel->predict(getAttributes()) == 0) { s << 0 << ","; QueryPerformanceCounter(&start); CPUImplementation(); QueryPerformanceCounter(&stop); } else { s << 1 << ","; QueryPerformanceCounter(&start); GPUImplementation(); QueryPerformanceCounter(&stop); } duration = stop.QuadPart - start.QuadPart; s << duration << endl; logExTime(s.str()); } void ComputationalModel::setProcessor(int p) { processor = p; } void ComputationalModel::prepareLogging() { } /* static method run by a thread to reset the flow if the input stream is burst and sparsed */ void ComputationalModel::resetOverPeriodIfBurst(ComputationalModel* cm) { LARGE_INTEGER now, frequency, reviseBoundary; QueryPerformanceFrequency(&frequency); reviseBoundary.QuadPart = frequency.QuadPart * cm->revisePeriod; while (true) { this_thread::sleep_for(chrono::seconds(cm->revisePeriod)); QueryPerformanceCounter(&now); if (now.QuadPart - cm->lastRevisedClock.QuadPart > reviseBoundary.QuadPart) { cm->resetFlow(); // reset the flow } } } void ComputationalModel::checkMLModel(ComputationalModel* cm) { while (true) { string file_ml = "ml_Trainer.cache"; ifstream mlTrainerReadFile(file_ml); int lastUpdatedTime=0; mlTrainerReadFile >> lastUpdatedTime; mlTrainerReadFile.close(); if (lastUpdatedTime !=0 && currentTimeMillis()-lastUpdatedTime > MONTH) { trainML(cm); } ofstream mlTrainerWriteFile(file_ml); mlTrainerWriteFile << currentTimeMillis() << endl; mlTrainerWriteFile.close(); this_thread::sleep_for(chrono::seconds(ML_TRAIN_CHECK_PERIOD)); } } void ComputationalModel::trainML(ComputationalModel* cm) { } void ComputationalModel::setOperationalMode(bool om) { operationalMode = om; } void ComputationalModel::logExTime(string str) { if (!Logger::isOpen()) { Logger::open(LOG_FILE_NAME); } Logger::write(str); } void ComputationalModel::clearLogs() { Logger::clearLogs(LOG_FILE_NAME); } __int64 currentTimeMillis() { FILETIME f; GetSystemTimeAsFileTime(&f); (long long)f.dwHighDateTime; __int64 nano = ((__int64)f.dwHighDateTime << 32LL) + (__int64)f.dwLowDateTime; return (nano - 116444736000000000LL) / 10000; }
6319dd3655f6806ba3cb622a73ae875529c79475
421f5b6d1a471a554ba99f6052ebc39a67581c96
/ACM ICPC/Practice problems/Ad Hoc/Hackerrank - Implementation/resturant.cpp
e9f671ad40bd2555e8b96ea78badd86bd1463ee2
[]
no_license
avinashw50w/practice_problems
045a2a60998dcf2920a1443319f958ede4f58385
1968132eccddb1edeb68babaa05aaa81a7c8ecf3
refs/heads/master
2022-08-31T08:39:19.934398
2022-08-10T16:11:35
2022-08-10T16:11:35
193,635,081
0
0
null
null
null
null
UTF-8
C++
false
false
796
cpp
resturant.cpp
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int t,l,b,i,j,q,r,m,arr[10000],min; scanf("%d",&t); while(t--) { scanf("%d %d",&l,&b); if(l>b) m=b; else m=l; int k=0; q=(l*b); for(i=m;i>=1;i--) { if(q%(i*i)==0){ if(l%i==0&&b%i==0) arr[k++]=q/(i*i); } } min=arr[0]; for(j=0;j<=k;j++) { if(arr[j]<min) min=arr[i]; } printf("%d\n",min); } return 0; }
aa20beaa8facfe9749eddd0ccad41ab162c1ce1b
cac5943d4339b3877a1cc3ecaf7293ab5f5c97d0
/test/homework_test/02_decisions_test/02_decisions_tests.cpp
8107dbddb8b462e0cc60987cc197f085824849b5
[ "MIT" ]
permissive
acc-cosc-1337-fall-2019/acc-cosc-1337-fall-2019-Fortress117
128aef7ffd0773f393ede8cb93e5aa48ca0ba078
76cfd56f0d4cb53bd2ce997fffb994bd30560ce2
refs/heads/master
2020-07-13T07:58:29.178211
2019-12-10T00:08:28
2019-12-10T00:08:28
205,038,730
1
0
null
null
null
null
UTF-8
C++
false
false
1,247
cpp
02_decisions_tests.cpp
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "catch.hpp" #include "../../../homework/02_decisions/decisions.h" TEST_CASE("Verify Test Configuration", "verification") { REQUIRE(true == true); } TEST_CASE("Test get grade points") { REQUIRE(get_grade_points("A") == 4); REQUIRE(get_grade_points("B") == 3); REQUIRE(get_grade_points("C") == 2); REQUIRE(get_grade_points("D") == 1); REQUIRE(get_grade_points("F") == 0); } TEST_CASE("Test Calculate GPA") { REQUIRE(calculate_gpa(12, 45) == 3.75); REQUIRE(calculate_gpa(120, 390) == 3.25); REQUIRE(calculate_gpa(90, 180) == 2.00); } TEST_CASE("Test get letter grade using if") { REQUIRE(get_letter_grade_using_if(95)=="A"); REQUIRE(get_letter_grade_using_if(85)=="B"); REQUIRE(get_letter_grade_using_if(75)=="C"); REQUIRE(get_letter_grade_using_if(65)=="D"); REQUIRE(get_letter_grade_using_if(50)=="F"); } TEST_CASE("Test get letter grade using switch") { REQUIRE(get_letter_grade_using_switch(95) == "A"); REQUIRE(get_letter_grade_using_switch(85) == "B"); REQUIRE(get_letter_grade_using_switch(75) == "C"); REQUIRE(get_letter_grade_using_switch(65) == "D"); REQUIRE(get_letter_grade_using_switch(50) == "F"); }
b3d6697e24dea84a59837853275f66f962a2cf4c
5f46975fc7a0b309bbc40f8d16ea12043025c057
/SWEA/D3/8741. 두문자어.cpp
843b9222a08e2f48dfa5b98b2f3b7d30aa2655b1
[]
no_license
HyeranShin/algorithm
b7814a57bd7e94e8b07fbc870295e5024b4182d5
dbe6dc747030be03c3bb913358a9b238dcecfcc4
refs/heads/master
2021-08-18T04:10:10.039487
2020-05-01T07:23:46
2020-05-01T07:23:46
174,467,552
0
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
8741. 두문자어.cpp
/* SWEA 8741. 두문자어 https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AW2y6n3qPXQDFATy&categoryId=AW2y6n3qPXQDFATy&categoryType=CODE */ #include <iostream> #include <ios> #define COUNT 3 using namespace std; string getResult(string words[]); int main() { cin.tie(0); ios::sync_with_stdio(); int tc; cin >> tc; for(int i=1; i<=tc; i++) { string words[COUNT]; for(int j=0; j<COUNT; j++) { string input; cin >> words[j]; } cout << '#' << i << ' ' << getResult(words) << '\n'; } return 0; } string getResult(string words[]) { string result = ""; for(int i=0; i<COUNT; i++) { result += (char)toupper(words[i][0]); } return result; }
31e5a3fae6237119d98e2c862d6391d541eca92a
eb2f8b3271e8ef9c9b092fcaeff3ff8307f7af86
/Grade 10-12/2018 autumn/NOIP/NOIP2018提高组Day2程序包/answers/GD-0328/travel/travel.cpp
1de563edbb026bf5930c3b2ca688d1dab11b55da
[]
no_license
Orion545/OI-Record
0071ecde8f766c6db1f67b9c2adf07d98fd4634f
fa7d3a36c4a184fde889123d0a66d896232ef14c
refs/heads/master
2022-01-13T19:39:22.590840
2019-05-26T07:50:17
2019-05-26T07:50:17
188,645,194
4
2
null
null
null
null
UTF-8
C++
false
false
2,051
cpp
travel.cpp
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int c2[20005],v3[20005],w,que[20005],y3,o2,i,deep[2000005],v[20005],v2[20005],cur,he,t,h[20005],u,ans[20005],r[20005],n,m; struct tt { int to,next; } e[20005]; struct ttt { int a,b; } c[20005]; bool cmp(ttt x,ttt y) { return x.b>y.b; } void add(int x,int y) { cur++; e[cur].to=y; e[cur].next=h[x]; h[x]=cur; } void dfs(int s) { v3[s]=1; u++; ans[u]=s; int p=100000000; for(i=1;i<=n;++i) if (v[i]==1) p=min(p,i); y3=h[s]; while(y3!=-1) { o2=e[y3].to;c2[o2]++; if (v[o2]) { y3=e[y3].next; continue; } v[o2]=1; y3=e[y3].next; } v[s]=2; int z=0; int y2=h[s]; while(y2!=-1) { int o=e[y2].to; if (v3[o]) { y2=e[y2].next; continue; } if (r[o]==1||o==p) { z=1; dfs(o); } y2=e[y2].next; } v3[s]=2; y3=h[s]; while(y3!=-1) { o2=e[y3].to; c2[o2]--; if (c2[o2]==0&&v[o2]!=2) v[o2]=0; if (v3[o2]) { y3=e[y3].next; continue; } r[o2]--; y3=e[y3].next; } } void bfs() { he=1; t=1; v2[1]=1; que[1]=1; deep[1]=1; while(he<=t) { w=que[he]; y3=h[w]; while(y3!=-1) { o2=e[y3].to; if (deep[o2]==0||deep[o2]>deep[w])r[o2]++; if (v2[o2]) { y3=e[y3].next; continue; } deep[o2]=deep[w]+1; t++; que[t]=o2; v2[o2]=1; y3=e[y3].next; } he++; } } int main() { freopen("travel.in","r",stdin); freopen("travel.out","w",stdout); cin>>n>>m; cur=-1; memset(h,-1,sizeof(h)); for(i=1;i<=m;++i) { scanf("%d%d",&c[i*2-1].a,&c[i*2-1].b); c[i*2].a=c[i*2-1].b; c[i*2].b=c[i*2-1].a; } sort(c+1,c+m*2+1,cmp); for(i=1;i<=m*2;++i) { add(c[i].a,c[i].b); } bfs(); ans[1]=1; // for(i=1;i<=n;++i) v[i]=1000000; dfs(1); for(i=1;i<=n;++i) printf("%d ",ans[i]); return 0; }
e5047a551b1e44740fb049f361fbe38e1c540190
bd7ed03a358dc380e03f4f4673e660776e86d6ab
/Plugins/leap-ue4-preview/Source/BodyState/Private/FBodyState.cpp
7ebae4f837b975fa93097d3c145cc600dc52b6ad
[ "MIT" ]
permissive
zhudongwork/ImsvGraphVis-
6e3cb586df45c0a2b3dcae95c642d29ebee75773
8b6894630d722a3a333f466d0b1fe0f5151aafac
refs/heads/master
2021-09-06T05:00:49.299993
2018-02-02T14:50:04
2018-02-02T14:50:04
119,993,404
1
0
null
null
null
null
UTF-8
C++
false
false
2,431
cpp
FBodyState.cpp
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #include "BodyStatePrivatePCH.h" #include "BodyStateSkeletonStorage.h" #include "FBodyState.h" #undef LOCTEXT_NAMESPACE #define LOCTEXT_NAMESPACE "BodyState" void FBodyState::StartupModule() { // This code will execute after your module is loaded into memory (but after global variables are initialized, of course.) // Custom module-specific init can go here. // IMPORTANT: This line registers our input device module with the engine. // If we do not register the input device module with the engine, // the engine won't know about our existence. Which means // CreateInputDevice never gets called, which means the engine // will never try to poll for events from our custom input device. SkeletonStorage = MakeShareable(new FBodyStateSkeletonStorage()); IModularFeatures::Get().RegisterModularFeature(IInputDeviceModule::GetModularFeatureName(), this); } void FBodyState::ShutdownModule() { SkeletonStorage->CallFunctionOnDevices([](const FBodyStateDevice& Device) { Device.InputCallbackDelegate->OnDeviceDetach(); }); SkeletonStorage->RemoveAllDevices(); // Unregister our input device module IModularFeatures::Get().UnregisterModularFeature(IInputDeviceModule::GetModularFeatureName(), this); } bool FBodyState::IsInputReady() { return bActive; } int32 FBodyState::DeviceAttached(const FBodyStateDeviceConfig& Configuration, IBodyStateInputRawInterface* InputCallbackDelegate) { //Create Device FBodyStateDevice Device; Device.Config = Configuration; Device.InputCallbackDelegate = InputCallbackDelegate; return SkeletonStorage->AddDevice(Device); } bool FBodyState::DeviceDetached(int32 DeviceID) { return SkeletonStorage->RemoveDevice(DeviceID); } UBodyStateSkeleton* FBodyState::SkeletonForDevice(int32 DeviceID) { return SkeletonStorage->SkeletonForDevice(DeviceID); } TSharedPtr< class IInputDevice > FBodyState::CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler) { UE_LOG(BodyStateLog, Log, TEXT("CreateInputDevice BodyState")); BodyStateInputDevice = MakeShareable(new FBodyStateInputDevice(InMessageHandler)); //Forward storage pointer BodyStateInputDevice->SkeletonStorage = SkeletonStorage; bActive = true; return TSharedPtr< class IInputDevice >(BodyStateInputDevice); } #undef LOCTEXT_NAMESPACE IMPLEMENT_MODULE(FBodyState, BodyState)
860635ad264b8848367d5558bf0a4690827aa773
93c093caec10a0558b6cd4a6aa63e3cd8876f3df
/include/terrain.h
930d40de9ff2c4647ea3a26ad04557315f178855
[]
no_license
lmacintyre/Coastal
7554f5728ebdd8267e1c53927617ade4a5d0e67d
c9651e38d0ca1fcd12bf539e8f2f7dd6251c6805
refs/heads/master
2020-03-28T13:43:39.170916
2018-09-14T06:25:06
2018-09-14T06:25:06
148,423,005
1
0
null
null
null
null
UTF-8
C++
false
false
783
h
terrain.h
#ifndef __TERRAIN_H__ #define __TERRAIN_H__ #include "heightmap.h" #include "renderer.h" class TerrainRenderer: public Renderer { private: Heightmap *heightmap; float x_step; float y_step; void draw_triangle(int x, int y, bool fwd); void draw_point(int x, int y); void set_color(float h); public: TerrainRenderer(Heightmap *heightmap): heightmap(heightmap) { x_step = 2.f / (heightmap->get_width()-1); y_step = 2.f / (heightmap->get_height()-1); }; void draw_targets() override; }; class Terrain { private: Heightmap *heightmap; TerrainRenderer *renderer; short chunk_number; public: Terrain(); Terrain(short chunk_number); Heightmap *get_heightmap() {return heightmap;} TerrainRenderer *get_renderer() {return renderer;} }; #endif
597f77a4da137aeaa2645fbbae18cb2349087120
eda13fd0a992bfab260a1fb08662816c0fba311e
/TextAdventure/Player.h
f87392e1f2b15b9c9c07e0846dc4c6be981ab2af
[]
no_license
psychedelicFish/textAdventure
9ee98edbe1a7ce65bdfb107d3258e09c089bbd15
746adc8393a9b7a0cec65568e3df70fe080d5eb2
refs/heads/master
2020-05-29T20:57:03.317502
2019-06-13T07:23:52
2019-06-13T07:23:52
189,364,523
0
0
null
null
null
null
UTF-8
C++
false
false
1,993
h
Player.h
#ifndef _PLAYER_H #define _PLAYER_H #include <string> #include "Inventory.h" class Enemy; class Player { public: //Character class enum - indexs the characters class enum CharacterClass { Fighter, Rouge }; //Decleration of the enum for use in code enum CharacterClass CharactersClass; //Intial stats constructor. //Parameters: name of character, Class of character Player(std::string name, int index); Player();// Default constructor. Used to Load Player stats from binary //Get values returned for use in code int GetHealth(); int GetAttack(); int GetDefence(); int GetStrength(); int GetDexterity(); int GetSpeed(); int GetExperience(); std::string getName(); //Allows the setting of attack and defence void SetAttack(); void SetDefence(); //Allows the setting of stats using experience void SetHealth(int exp); void SetStrength(int exp); void SetDexterity(int exp); void SetSpeed(int exp); //Changes Stats based on equipment void AffectDefence(int amount); void AffectAttack(int amount); void AffectSpeed(int amount); //Sets the Intial stats of the character void SetIntialStats(); //Display the important stuff void DisplayStats(); void DisplayBattleStats(); //Save out the Character void SaveAll(); void SaveStrength(); void SaveHealth(); void SaveDexterity(); void SaveSpeed(); void SaveExperience(); //Load the Character void LoadAll(); //Spend Experience void ReduceExperience(int amount); //Allows the player to take damage void TakeDamage(int dmg); //Allows the player to attack the enemy void AttackEnemy(Enemy &enemy); //Allows the player to gain experience void GainExp(int exp); //Checks to see if the player is dead. bool checkDeath(); private: //Basic Stats of the Character int Health; int Attack; int Defence; int Strength; int Dexterity; int Speed; std::string Name; //Amount of Experience character has to spend int Experience; int length; int temp; }; #endif
ce719f73418cc90bf8da3fbda57ad3eb43fc395b
c4508965574dd9161dc0a06b05fe62d6c6eec934
/src/ease/data/skip_list.hpp
d647537c175fb1c129e054cc6d7c5e6360998b3a
[]
no_license
Palmik/ease-cpp-skip-list
f30d350f524caca358b2be19285ffee93323c3cd
4efffd18cf96798f93e5f83b1a33a25e9711f5cb
refs/heads/master
2016-09-06T13:07:02.606047
2013-08-30T17:09:57
2013-08-30T17:09:57
12,489,077
1
0
null
null
null
null
UTF-8
C++
false
false
6,286
hpp
skip_list.hpp
#ifndef EASE_DATA_SKIP_LIST #define EASE_DATA_SKIP_LIST #include <functional> #include <memory> #include <random> #include <cassert> #include <cstdint> namespace ease { namespace data { namespace skip_list { typedef unsigned int u8; typedef unsigned int u16; template <typename T> class skip_list; #include "skip_list/imp/data_traits.imp.hpp" #include "skip_list/imp/data_node.imp.hpp" #include "skip_list/imp/data_iterator.imp.hpp" template <typename T> class skip_list { public: typedef T type_skip_list_traits; typedef skip_list<T> type_this; typedef typename T::type_key type_key; typedef typename T::type_value type_value; typedef typename T::type_key_comparator type_key_comparator; typedef typename T::type_value_allocator type_value_allocator; typedef std::size_t type_size; typedef skip_list_node<T> type_node; typedef skip_list_iterator < type_node , type_value* , type_value& > type_iterator; typedef typename type_iterator::type_const_iterator type_const_iterator; typedef std::reverse_iterator<type_iterator> type_reverse_iterator; typedef std::reverse_iterator<type_const_iterator> type_const_reverse_iterator; // TODO: C++11 ifdef //typedef typename std::allocator_traits<type_value_allocator>:: // template rebind_alloc<type_node > type_node_allocator; //typedef typename std::allocator_traits<type_value_allocator>:: // template rebind_alloc<type_node*> type_node_pointer_allocator; typedef typename type_value_allocator::template rebind<type_node >::other type_node_allocator; typedef typename type_value_allocator::template rebind<type_node*>::other type_node_pointer_allocator; // CONSTRUCTORs & DESTRUCTOR // IMP: fun_construct_destruct.imp.hpp skip_list ( type_key_comparator const& c = type_key_comparator() , type_value_allocator const& a = type_value_allocator() ); skip_list(type_this const& other); ~skip_list(); // MODIFIERS // IMP: fun_insert.imp.hpp std::pair<type_iterator, bool> insert_unique(type_value const& value); type_iterator insert(type_value const& value); // IMP: fun_erase.imp.hpp type_iterator erase(type_const_iterator pos); std::pair<type_iterator, type_size> erase(type_const_iterator beg, type_const_iterator end); std::pair<type_iterator, type_size> erase(type_key const& key); std::pair<type_iterator, type_size> erase_unique(type_key const& key); // IMP: fun_construct_destruct.imp.hpp void clear(); // IMP: fun_construct_destruct.imp.hpp void swap(type_this& other); // ITERATORS // IMP: fun_iterator.imp.hpp type_iterator end(); type_const_iterator end() const; type_const_iterator cend() const; type_reverse_iterator rend(); type_const_reverse_iterator rend() const; type_const_reverse_iterator crend() const; type_iterator begin(); type_const_iterator begin() const; type_const_iterator cbegin() const; type_reverse_iterator rbegin(); type_const_reverse_iterator rbegin() const; type_const_reverse_iterator crbegin() const; // LOOKUP // IMP: fun_lookup.imp.hpp type_size count(type_key const& k) const; type_iterator find(type_key const& k); type_const_iterator find(type_key const& k) const; type_iterator lower_bound(type_key const& k); type_const_iterator lower_bound(type_key const& k) const; type_iterator upper_bound(type_key const& k); type_const_iterator upper_bound(type_key const& k) const; // CAPACITY // IMP: fun_capacity.imp.hpp bool empty() const; type_size size() const; type_size max_size() const; static type_key const& key(type_value const& value) { return type_skip_list_traits::key(value); } void print_levels() { for (type_node* it = node_begin(); it != node_end(); it = it->next[0]) { printf("%d, ", it->next_size); } printf("\n"); } protected: // IMP: fun_insert_internal.imp.hpp type_node* insert_at_internal(type_value const& value, type_node** update); // IMP: fun_erase_internal.imp.hpp type_node* erase_internal(type_node** update); // IMP: fun_lookup_internal.imp.hpp type_node* lookup_internal ( type_node const* pos , type_node* (&update)[T::level_max] ) const; type_node* lookup_internal ( type_node const* pos ) const; type_node* lookup_internal ( type_key const& key , type_node* (&update)[T::level_max] ) const; type_node* lookup_internal ( type_key const& key ) const; private: // IMP: fun_memory_internal.imp.hpp type_node* create_header_node(); void delete_header_node(type_node* node); type_node* create_node(type_node* prev, u8 next_size, type_value const& key); void delete_node(type_node* node); // IMP: fun_iterator.imp.hpp type_node* node_end() const; type_node* node_begin() const; u8 random_level() const; private: static const u8 level_max = T::level_max; // ALLOCATORS type_node_allocator node_allocator_m; type_node_pointer_allocator node_pointer_allocator_m; type_value_allocator value_allocator_m; const type_key_comparator cmp_lq_m; type_node* header_node_m; u8 level_max_current_m; type_size size_m; }; // CONSTRUCTORS & DESTRUCTOR #include "skip_list/imp/fun_construct_destruct.imp.hpp" // ITERATORS #include "skip_list/imp/fun_iterator.imp.hpp" // MODIFIERS #include "skip_list/imp/fun_insert.imp.hpp" #include "skip_list/imp/fun_erase.imp.hpp" // LOOKUP #include "skip_list/imp/fun_lookup.imp.hpp" // CAPACITY #include "skip_list/imp/fun_capacity.imp.hpp" // INTERNAL #include "skip_list/imp/fun_insert_internal.imp.hpp" #include "skip_list/imp/fun_erase_internal.imp.hpp" #include "skip_list/imp/fun_lookup_internal.imp.hpp" #include "skip_list/imp/fun_memory_internal.imp.hpp" template <typename T> inline u8 skip_list<T>::random_level() const { const u8 res = T::random_level(level_max_current_m); return res; } } // namespace skip_list } // namespace data } // namespace ease #endif
4aeb8f4c5da486feabb4676102b5958eb34d8e52
495de3b72c6d931d43e70322450e97173e734ea2
/Set_DS3231_to_1_Hz_output-RDF-1.1.ino
271209503b6ced7d402bdc3b3b5a694dee585e88
[]
no_license
rdforrest/Pinger-model-submarine
d09e032f76070a314ea68839cf9fdf1f6470ebb5
4642d78c55cc959ae127060a62eca5409622ea64
refs/heads/master
2021-10-12T06:27:19.282056
2021-10-02T10:57:34
2021-10-02T10:57:34
183,627,463
0
0
null
null
null
null
UTF-8
C++
false
false
1,372
ino
Set_DS3231_to_1_Hz_output-RDF-1.1.ino
// RDF based on Adafruit library // DS3231 to Arduino connections: SDA to A4,SCL to A5, SQW to ground of LED say #include <Wire.h> #include "RTClib.h" RTC_DS3231 rtc; const byte rtcTimerIntPin = 2; volatile byte flag = false; void rtc_interrupt () { flag = true; } // end of rtc_interrupt void setup () { //Serial.begin(115200); Serial.begin(9600); while (!Serial); // for Leonardo/Micro/Zero if (! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (rtc.lostPower()) { Serial.println("RTC lost power, lets set the time!"); // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } // enable the 1 Hz output rtc.writeSqwPinMode (DS3231_SquareWave1Hz); // set up to handle interrupt from 1 Hz pin pinMode (LED_BUILTIN, OUTPUT); pinMode (rtcTimerIntPin, INPUT_PULLUP); attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE); } void loop () { if (flag) { digitalWrite(LED_BUILTIN, HIGH); // flash the led delay(100); // wait a little bit digitalWrite(LED_BUILTIN, LOW); // turn off led flag = false; // clear the flag until timer sets it again } Serial.println("Set OK"); }
e96a5e2614aaef05006b0e6a7084c276405e5444
d854e1209a2bab3a2bf96f003789252f010fa4d2
/libraries/Controller/Comm.h
ab157d357b00206de463bf2be6e8028face86cd1
[ "MIT" ]
permissive
virtdev/su
418badc807ddc6bbfd464f6f139c1b7add244974
7f08adf13d46aef9e47e42b6d56fd599103fd269
refs/heads/master
2021-01-23T02:29:05.328732
2018-01-12T08:32:37
2018-01-12T08:32:37
36,044,616
0
0
null
null
null
null
UTF-8
C++
false
false
719
h
Comm.h
#ifndef _COMM_H #define _COMM_H #include <string.h> #define COMM_DLE '@' #define COMM_STX '0' #define COMM_ETX '1' #define COMM_CHR "@@" #define COMM_HEAD "@0" #define COMM_TAIL "@1" #define COMM_RATE 9600 #define COMM_TIMEOUT 100 const int COMM_HEAD_LEN = strlen(COMM_HEAD); const int COMM_TAIL_LEN = strlen(COMM_TAIL); class Comm { public: Comm(); int get(); void setup(char *buf, int size); void put(char *buf, int length); private: int recv(); void send(char *buf, int length); void sendBytes(char *buf, int length); private: char m_ch; int m_size; int m_count; int m_start; char *m_buf; }; #endif
013b1b1dd792c69610c7303c8bafc63e25fbb5e3
93d9819473a1043f7fbc6712aff55610765fc92c
/library/TGeneralTools.h
a2bf01454077b668c4efacad720bf05832d3c4ce
[]
no_license
cckui/Borland_C_Lamp
fb9d4a94869722984e23a7dc719816bfbc25cebe
afe29e0808a450118784692e7eee971f3cb67af2
refs/heads/master
2021-01-21T18:18:16.846635
2017-05-22T08:57:56
2017-05-22T08:57:56
92,031,876
0
0
null
null
null
null
BIG5
C++
false
false
1,217
h
TGeneralTools.h
//--------------------------------------------------------------------------- //*************************************************************************** //** Create Date : 2010.10.13 Ver.:1.00_A by Cuiu_Handsome //** Function : 共用 Function ,主要繼承自 TBasetools //*************************************************************************** //--------------------------------------------------------------------------- #ifndef TGeneralToolsH #define TGeneralToolsH #include "TBasetools.h" //--------------------------------------------------------------------------- class TGeneralTools : public TBasetools { private: static TGeneralTools* _instance; // 宣告一私有指標 protected: //User declarations __fastcall TGeneralTools(void); // 將建構式及解構式移到私有區或保護區 __fastcall ~TGeneralTools(void); // 禁止外部程式直接New物件產生 public: static TGeneralTools* __fastcall getInstance(); // 提供外部一個方法Get物件實體 static void __fastcall delInstance(); // 提供外部一個方法Delete物件實體 }; //--------------------------------------------------------------------------- #endif
9cd6b095572085eba9f3245f70f085d814cff00a
baedeab76fb66de47e095719c068267b42aa5105
/init/iMouse.hpp
d0c16ead50c318e2f13227556d3b9277cfc87d65
[ "Apache-2.0" ]
permissive
vcgato29/engine-1
66b9e98d11bd9ae5e9e04a19bc778676fc0a66a5
5b16446e15e4184985328222139ab238b6ee6a90
refs/heads/master
2021-01-18T10:14:05.758917
2016-04-05T15:19:19
2016-04-05T15:19:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,704
hpp
iMouse.hpp
/*! * \file iMouse.hpp * * Basic class for setting keys */ /* * Copyright (C) 2015 EEnginE project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "defines.hpp" namespace e_engine { class INIT_API iMouse { private: unsigned short int button_state[E_MOUSE_UNKNOWN]; protected: /*! * \brief Set a mouse button to a specific state * \param _button The mouse button ID * \param _state The new mouse button state */ void setMousebuttonState( E_BUTTON _button, unsigned short int _state ) { if ( _button < 0 ) return; button_state[static_cast<unsigned int>( _button )] = _state; } public: iMouse(); virtual ~iMouse(); /*! * \brief Get the mouse button's state * \param _button The mouse button to check * \returns The mouse button state */ unsigned short int getMousebuttonState( E_BUTTON _button ) { if ( _button < 0 || _button > E_MOUSE_UNKNOWN ) { return static_cast<unsigned short int>( E_UNKNOWN ); } return button_state[static_cast<unsigned int>( _button )]; } }; } // kate: indent-mode cstyle; indent-width 3; replace-tabs on; line-numbers on;
75ee8f92f47ae01a6405344eb9df9b986476c5b1
928863f83611e4cd3256f58c0c0199b72baefabb
/3rd_party_libs/chai3d_a4/src/widgets/CBackground.h
18abddd7fdd3e4dfe302fff7c699f73e9f64e839
[ "BSD-3-Clause" ]
permissive
salisbury-robotics/jks-ros-pkg
b3c2f813885e48b1fcd732d1298027a4ee041a5c
367fc00f2a9699f33d05c7957d319a80337f1ed4
refs/heads/master
2020-03-31T01:20:29.860477
2015-09-03T22:13:17
2015-09-03T22:13:17
41,575,746
3
0
null
null
null
null
UTF-8
C++
false
false
6,208
h
CBackground.h
//=========================================================================== /* Software License Agreement (BSD License) Copyright (c) 2003-2012, CHAI3D. (www.chai3d.org) 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 CHAI3D 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. \author <http://www.chai3d.org> \author Francois Conti \version $MAJOR.$MINOR.$RELEASE $Rev: 774 $ */ //=========================================================================== //--------------------------------------------------------------------------- #ifndef CBackgroundH #define CBackgroundH //--------------------------------------------------------------------------- #include "widgets/CGenericWidget.h" #include "graphics/CImage.h" //--------------------------------------------------------------------------- //=========================================================================== /*! \file CBackground.h \brief <b> Widgets </b> \n World background. */ //=========================================================================== //=========================================================================== /*! \class cBackground \ingroup widgets \brief Implementation of a world colored background. */ //=========================================================================== class cBackground : public cGenericWidget { public: //----------------------------------------------------------------------- // CONSTRUCTOR & DESTRUCTOR: //----------------------------------------------------------------------- //! Constructor of cBackground. cBackground(); //! Destructor of cBackground. virtual ~cBackground() {}; //----------------------------------------------------------------------- // METHODS: //----------------------------------------------------------------------- //! Get width of widget. virtual double getWidth() const { return (m_widthBackground); } //! Get height of widget. virtual double getHeight() const { return (m_heightBackground); } //! Update the dimension of the background in pixel coordinates. void update(const unsigned int a_bottomLeftX, const unsigned int a_bottomLeftY, const unsigned int a_topRightX, const unsigned int a_topRightY); //! Set uniform color. void setUniformColor(cColorf a_color); //! Set a vertical gradient color background. void setVerticalLinearGradient(cColorf a_topColor, cColorf a_bottomColor); //! Set a horizontal gradient color background. void setHorizontalLinearGradient(cColorf a_leftColor, cColorf a_rightColor); //! Set a color property at each corner. void setCornerColors(cColorf a_topLeftColor, cColorf a_topRightColor, cColorf a_bottomLeftColor, cColorf a_bottomRightColor); //! Set aspect ratio property of background image. inline void setMaintainAspectRatio(bool a_maintainAspectRatio) { m_maintainAspectRatio = a_maintainAspectRatio; } //! Get aspect ratio property of background image. inline bool getMaintainAspectRatio() { return (m_maintainAspectRatio); } //! Load background image from file. bool loadFromFile(string a_filename); //! Load background image from image structure. bool loadFromImage(cImage *a_image); protected: //----------------------------------------------------------------------- // MEMBERS: //----------------------------------------------------------------------- //! Top left vertex. unsigned int m_vertexTL; //! Top right vertex. unsigned int m_vertexTR; //! Bottom left vertex. unsigned int m_vertexBL; //! Bottom right vertex. unsigned int m_vertexBR; //! Width of background. double m_widthBackground; //! Height of background. double m_heightBackground; //! If \b true then aspect ratio of background image is maintained. bool m_maintainAspectRatio; //----------------------------------------------------------------------- // METHODS: //----------------------------------------------------------------------- //! Render background in OpenGL. virtual void render(cRenderOptions& a_options); }; //--------------------------------------------------------------------------- #endif //---------------------------------------------------------------------------
9758f43c4bfe95188c1b1d8e583fcfb8f502c236
9e4c014024f90653c32b1ef4a93e829893aa4176
/build/lgraphics/api/dx9/IndexBufferRef.h
a8ee71cdc36504b945851e6352ffdba17373a7ca
[]
no_license
lcsszz/Samples
a71ba851f2a5fc75412d76b8b54d6cf1dfcebe48
0b54333952c2c502b0bac67465a873ac87a05446
refs/heads/master
2021-01-24T21:49:12.006013
2014-10-04T18:17:47
2014-10-04T18:17:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,664
h
IndexBufferRef.h
#ifndef INC_LGRAPHICS_DX9_INDEXBUFFERREF_H__ #define INC_LGRAPHICS_DX9_INDEXBUFFERREF_H__ /** @file IndexBufferRef.h @author t-sakai @date 2009/05/07 create @data 2010/01/08 add IndexBufferUPRef */ #include <lcore/NonCopyable.h> #include <lcore/smart_ptr/intrusive_ptr.h> #include "../../lgraphicscore.h" #include "Enumerations.h" struct IDirect3DIndexBuffer9; namespace lgraphics { struct Face { u16 indices_[3]; }; struct IndexBufferDesc { BufferFormat format_; ResourceType type_; u32 usage_; Pool pool_; u32 size_; }; //------------------------------------------------------------ //--- //--- IndexBufferRef //--- //------------------------------------------------------------ class IndexBufferRef { public: typedef IndexBufferDesc BufferDesc; IndexBufferRef() :buffer_(NULL) { } IndexBufferRef(const IndexBufferRef& rhs); ~IndexBufferRef() { destroy(); } IndexBufferRef& operator=(const IndexBufferRef& rhs) { IndexBufferRef tmp(rhs); tmp.swap(*this); return *this; } bool valid() const{ return (buffer_ != NULL); } void destroy(); bool lock(u32 offset, u32 size, void** data, Lock lock=Lock_None); void unlock(); // データ転送 void blit(const void* data, u32 offset, u32 size); bool getDesc(BufferDesc& desc); void attach() const; void swap(IndexBufferRef& rhs) { lcore::swap(buffer_, rhs.buffer_); } private: friend class IndexBuffer; IndexBufferRef(IDirect3DIndexBuffer9* buffer) :buffer_(buffer) { } IDirect3DIndexBuffer9 *buffer_; }; //------------------------------------------------------------ //--- //--- IndexBuffer //--- //------------------------------------------------------------ class IndexBuffer { public: static IndexBufferRef create(u32 numIndices, Pool poolType, Usage usage); }; //------------------------------------------------------------ //--- //--- IndexBufferUPRef //--- //------------------------------------------------------------ class IndexBufferUP; class IndexBufferUPRef { public: typedef IndexBufferDesc BufferDesc; IndexBufferUPRef() :buffer_(NULL) { } IndexBufferUPRef(const IndexBufferUPRef& rhs); ~IndexBufferUPRef() { destroy(); } IndexBufferUPRef& operator=(const IndexBufferUPRef& rhs) { IndexBufferUPRef tmp(rhs); tmp.swap(*this); return *this; } bool valid() const{ return (buffer_ != NULL); } void destroy(); bool getDesc(BufferDesc& desc); bool lock(void** data); bool lock(const void** data) const; void unlock(){} void unlock() const{} void swap(IndexBufferUPRef& rhs) { lcore::swap(buffer_, rhs.buffer_); } private: friend class IndexBufferUP; explicit IndexBufferUPRef(IndexBufferUP* buffer) :buffer_(buffer) { } IndexBufferUP *buffer_; }; //------------------------------------------------------------ //--- //--- IndexBufferUP //--- //------------------------------------------------------------ class IndexBufferUP : private lcore::NonCopyable<IndexBufferUP> { public: static IndexBufferUPRef create(u32 numFaces); u32 AddRef() { return (++count_); } u32 Release() { if(--count_== 0){ LIME_DELETE_NONULL this; } return count_; } bool lock(void** data) { LASSERT(data != NULL); if(buffer_ != NULL){ *data = buffer_; return true; } return false; } bool lock(const void** data) const { LASSERT(data != NULL); if(buffer_ != NULL){ *data = buffer_; return true; } return false; } void unlock(){} void unlock() const{} u32 getNumFaces() const{ return numFaces_;} void swap(IndexBufferUP& rhs) { lcore::swap(buffer_, rhs.buffer_); lcore::swap(numFaces_, rhs.numFaces_); lcore::swap(count_, rhs.count_); } private: IndexBufferUP() :buffer_(NULL) ,numFaces_(0) ,count_(0) { } IndexBufferUP(u8* buffer, u32 numFaces) :buffer_(buffer) ,numFaces_(numFaces) ,count_(0) { } ~IndexBufferUP(); u8 *buffer_; u32 numFaces_; u32 count_; }; } //--------------------------------------------------- //--- //--- lcore::swap特殊化 //--- //--------------------------------------------------- namespace lcore { template<> inline void swap<lgraphics::IndexBufferRef>(lgraphics::IndexBufferRef& l, lgraphics::IndexBufferRef& r) { l.swap(r); } template<> inline void swap<lgraphics::IndexBufferUPRef>(lgraphics::IndexBufferUPRef& l, lgraphics::IndexBufferUPRef& r) { l.swap(r); } } #endif //INC_LGRAPHICS_DX9_INDEXBUFFERREF_H__
74d8e77932d1140c6017490be54e57e0f26cd115
805ce6263988ee46ea96a79744a2b8d78b59691c
/src/LOCASModel.hh
801701f193db95ae0b7c102aa92de3c913023051
[]
no_license
RStainforth/locas-plus
0720b5439101e9e8e6d0ed2ba5ba84fe988b6919
cc7e27634159b430ae62be32036472d95ec8fd3f
refs/heads/master
2021-01-21T21:39:17.639550
2014-03-13T14:21:14
2014-03-13T14:21:14
14,236,143
0
0
null
null
null
null
UTF-8
C++
false
false
2,122
hh
LOCASModel.hh
//////////////////////////////////////////////////////////////////// /// /// FILENAME: LOCASModel.hh /// /// CLASS: LOCAS::LOCASModel /// /// BRIEF: The base class from which all models used in LOCAS /// as part of a fitting routine inherit from /// /// AUTHOR: Rob Stainforth [RPFS] <rpfs@liv.ac.uk> /// /// REVISION HISTORY:\n /// 02/2014 : RPFS - First Revision, new file. \n /// //////////////////////////////////////////////////////////////////// #ifndef _LOCASModel_ #define _LOCASModel_ #include "LOCASModelParameterStore.hh" #include "LOCASDataPoint.hh" #include <iostream> #include <string> namespace LOCAS{ class LOCASModel : public TObject { public: // The constructors LOCASModel(){ }; LOCASModel( const char* fileName ); // The destructor - delete the parameters in the model ~LOCASModel(){ if ( fParameters != NULL ) { delete[] fParameters; } } ///////////////////////////////// //////// METHODS //////// ///////////////////////////////// // Model prediction for the occupancy ratio for a datapoint virtual Float_t ModelPrediction( const LOCASDataPoint& dataPoint ){ return 0.0; } ///////////////////////////////// //////// GETTERS //////// ///////////////////////////////// std::string GetModelName() const { return fModelName; } // Return the store of parameters used in the model LOCASModelParameterStore GetModelParameterStore() const { return fModelParameterStore; } ///////////////////////////////// //////// SETTERS //////// ///////////////////////////////// void SetModelName( const std::string name ){ fModelName = name; } void SetModelParameterStore( const LOCASModelParameterStore& locasParams ); protected: std::string fModelName; // The model name LOCASModelParameterStore fModelParameterStore; // The colleciton of parameters used in the model Double_t* fParameters; // The parameter values stored in an array ClassDef( LOCASModel, 1 ); }; } #endif
4796620055a296478fc13bdf8b30002ad4258762
50a8a3fe0fdffb4141b12b0ee73363f218efc222
/src/nas/msgs/AuthenticationResponse.cpp
5ff0c2ebf4588dd0c6342da2286b0566335403a6
[]
no_license
dukl/fake_gnb
f89972ad50c6a50e620fe8590cece7200d2560da
b6f772e8fb82c61a9949a4f4c317637d97c36fb6
refs/heads/master
2022-12-07T21:55:26.285263
2020-08-27T07:11:37
2020-08-27T07:11:37
290,703,480
1
0
null
null
null
null
UTF-8
C++
false
false
3,638
cpp
AuthenticationResponse.cpp
#include "AuthenticationResponse.hpp" #include "3gpp_ts24501.hpp" #include "logger.hpp" using namespace nas; AuthenticationResponse::AuthenticationResponse() { Logger::nas_mm().debug("initiating class AuthenticationResponse"); plain_header = NULL; ie_authentication_response_parameter = NULL; ie_eap_message = NULL; } AuthenticationResponse::~AuthenticationResponse() {} void AuthenticationResponse::setHeader(uint8_t security_header_type) { plain_header = new NasMmPlainHeader(); plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_RESPONSE); } void AuthenticationResponse::setAuthentication_Response_Parameter(bstring para) { ie_authentication_response_parameter = new Authentication_Response_Parameter(0x2D, para); } bool AuthenticationResponse::getAuthenticationResponseParameter(bstring &para) { if (ie_authentication_response_parameter) { ie_authentication_response_parameter->getValue(para); return true; } else { return false; } } void AuthenticationResponse::setEAP_Message(bstring eap) { ie_eap_message = new EAP_Message(0x78, eap); } bool AuthenticationResponse::getEapMessage(bstring &eap) { if (ie_eap_message) { ie_eap_message->getValue(eap); return 0; } else { return -1; } } int AuthenticationResponse::encode2buffer(uint8_t *buf, int len) { Logger::nas_mm().debug("encoding AuthenticationResponse message"); int encoded_size = 0; if (!plain_header) { Logger::nas_mm().error("Mandontary IE missing Header"); return 0; } if (!(plain_header->encode2buffer(buf, len))) return 0; encoded_size += 3; if (!ie_authentication_response_parameter) { Logger::nas_mm().warn("IE ie_authentication_response_parameter is not avaliable"); } else { if (int size = ie_authentication_response_parameter->encode2buffer(buf + encoded_size, len - encoded_size)) { encoded_size += size; } else { Logger::nas_mm().error("encoding ie_authentication_response_parameter error"); return 0; } } if (!ie_eap_message) { Logger::nas_mm().warn("IE ie_eap_message is not avaliable"); } else { if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) { encoded_size += size; } else { Logger::nas_mm().error("encoding ie_eap_message error"); return 0; } } Logger::nas_mm().debug("encoded AuthenticationResponse message len(%d)", encoded_size); return 1; } int AuthenticationResponse::decodefrombuffer(NasMmPlainHeader * header, uint8_t *buf, int len) { Logger::nas_mm().debug("decoding AuthenticationResponse message"); int decoded_size = 3; plain_header = header; Logger::nas_mm().debug("decoded_size(%d)", decoded_size); uint8_t octet = *(buf + decoded_size); Logger::nas_mm().debug("first option iei(0x%x)", octet); while ((octet != 0x0)) { switch (octet) { case 0x2D: { Logger::nas_mm().debug("decoding iei(0x2D)"); ie_authentication_response_parameter = new Authentication_Response_Parameter(); decoded_size += ie_authentication_response_parameter->decodefrombuffer(buf + decoded_size, len - decoded_size, true); octet = *(buf + decoded_size); Logger::nas_mm().debug("next iei(0x%x)", octet); }break; case 0x78: { Logger::nas_mm().debug("decoding iei(0x78)"); ie_eap_message = new EAP_Message(); decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true); octet = *(buf + decoded_size); Logger::nas_mm().debug("next iei(0x%x)", octet); }break; } } Logger::nas_mm().debug("decoded AuthenticationResponse message len(%d)", decoded_size); }
5b440f3db84759615e63f90c5dd91918bbd5d159
ce38c8ac3af32fc95799c61fcae280159d947b81
/EzwiX/EzwiX/ModuleGameObjectManager.h
b576c342955e15ae1c10e5d2866b976eef0babfb
[ "MIT" ]
permissive
traguill/EzwiX
d243b554a75d63fb63c25c18a916cbff74331900
3002d842b7a27287af28f0db29d7d51ef04c7302
refs/heads/master
2020-04-05T13:06:28.874961
2017-07-16T10:37:28
2017-07-16T10:37:28
95,096,983
1
0
null
null
null
null
UTF-8
C++
false
false
820
h
ModuleGameObjectManager.h
#ifndef __MODULE_GAMEOBJECT_MANAGER_H__ #define __MODULE_GAMEOBJECT_MANAGER_H__ #include "Module.h" class GameObject; class ModuleGameObjectManager : public Module { public: ModuleGameObjectManager(const char* name, bool start_enabled = true); ~ModuleGameObjectManager(); bool Init(); bool CleanUp(); update_status PreUpdate(); update_status Update(); GameObject* CreateGameObject(GameObject* parent); //For external use const GameObject* GetRoot()const; void Load3DModelFile(const char* file_path); private: void PreUpdateGameObjects(GameObject* object); void UpdateGameObjects(GameObject* object); //Load 3DModels helpers GameObject* FindGameObject(const vector<GameObject*>& list, unsigned int uuid)const; private: GameObject* root = nullptr; }; #endif // !__MODULE_GAMEOBJECT_MANAGER_H__
ddd67a4fd5a178e104b316e8db9e2e775988bdf5
dbf44a1dd9978abc2e4034543e06b6dba79877da
/cacrmoving/cacrmoving/callbackfunction.cpp
ea5819df100d781582194c39574da96b8cc1427f
[]
no_license
KAsimov-/carmoving
96ded31414dfa934c6ab44ec662981f7e006b0d4
bc7061a33fad7cd390852a4095317da22924e5d4
refs/heads/master
2016-09-06T04:04:33.713923
2014-04-29T16:08:06
2014-04-29T16:08:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,332
cpp
callbackfunction.cpp
#include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <stdio.h> #include <stdlib.h> #include <cv.h> #define PI 3.141592 using namespace cv; using namespace std; Mat src; int thresh = 100; int max_thresh = 255; /// Function header /* @function main *//* int main( int argc, char** argv ) { /// Load source image and convert it to gray src = imread("C:/opencv/samples/c/pca_test1.jpg"); /// Convert image to gray and blur it cvtColor( src, src_gray, CV_BGR2GRAY ); blur( src_gray, src_gray, Size(3,3) ); /// Create Window char* source_window = "Source"; namedWindow( source_window, CV_WINDOW_AUTOSIZE ); imshow( source_window, src ); createTrackbar( " Canny thresh:", "Source", &thresh, max_thresh, thresh_callback ); thresh_callback( 0, 0 ); waitKey(0); return(0); } */ /* @function thresh_callback */ void thresh_callback(int, Mat src_gray ) { Mat canny_output; vector<vector<Point> > contours; vector<Vec4i> hierarchy; /// Detect edges using canny Canny( src_gray, canny_output, thresh, thresh*2, 3 ); /// Find contours findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) ); /// Get the moments vector<Moments> mu(contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mu[i] = moments( contours[i], false ); } /// Get the mass centers: vector<Point2f> mc( contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 ); } // Get orientation /* vector<Point3f>mo(contours.size()); */ for( int i = 0; i < contours.size(); i++ ) { double theta = 0.5*atan2(2 * mu[i].mu11,(mu[i].mu20-mu[i].mu02));////////////?????????????????? atan2(2*Ixy/(Ixx-Iyy); Scalar color = Scalar(0, 0, 1); drawContours( src_gray, contours, i, color, 2, 8, hierarchy, 0, Point() ); circle( src_gray, mc[i], 4, color, -1, 8, 0 ); //draw center line line(src_gray ,Point(mc[i].x,mc[i].y)-Point(100*cos(theta),100*sin(theta)), Point(mc[i].x, mc[i].y)+Point(100*cos(theta), 100*sin(theta)), Scalar(255,0,0),2); } /// Draw contours /// Show in a window /// Calculate the area with the moments 00 and compare with the result of the OpenCV function }
daaf22cb5cb1114df426bfba4856383921d640c3
80c3acebbf37278bf5899c207b1f32e45bd22092
/Projekt/Model/cubemap.h
a93bc013c1acf40cbc1bcda847411dfa7ce910b8
[]
no_license
Kobzol/ZPG-project
fc9d85c5b61ed0379e8fc5f08d092eadbb87b6bd
c3e423cea687be51b5472c985c519308228ca10c
refs/heads/master
2021-01-10T16:49:20.196016
2015-11-11T22:42:20
2015-11-11T22:42:20
44,061,033
1
1
null
null
null
null
UTF-8
C++
false
false
383
h
cubemap.h
#pragma once #define GLEW_STATIC #include <GL/glew.h> #include <vector> #include "../Helper/opengl_helper.h" #include "../Helper/image.h" class Cubemap { private: GLuint cubemap; public: Cubemap(); GLuint getId(); void allocate(); void bind(int unit = 0); void dispose(); void set2DImages(std::vector<Image>& images); void generateDepthMap(int width, int height); };
c906eb18d1e59462ac1baf45519a398bc27119fb
728c504665b676eb157503d26a22c7bc5d4b70c3
/src/Filter/IMSTObject.h
0dda848656f224706ef7857a7027271c64163859
[ "BSD-3-Clause" ]
permissive
fermi-lat/TkrRecon
9b8e64478e9362a0f9c505b90c7d534047f24abc
9174a0ab1310038d3956ab4dcc26e06b8a845daf
refs/heads/master
2022-02-20T03:23:49.672406
2019-08-27T17:28:49
2019-08-27T17:28:49
103,186,928
0
0
null
null
null
null
UTF-8
C++
false
false
1,915
h
IMSTObject.h
/** * @class MinSpanTree * * @brief This defines an interface to the base objects operated on by the MST and Cluster Analyses * * @author Tracy Usher * * $Header: /nfs/slac/g/glast/ground/cvs/TkrRecon/src/Filter/MinSpanTree.h,v 1.0 2010/12/16 20:44:46 usher Exp $ */ #ifndef IMSTObject_h #define IMSTObject_h #include <vector> #include <list> #include <set> #include <map> // Forward declaration class Point; // Define an interface class so we can operate on several different kinds of objects class IMSTObject { public: // Make sure destructor called... virtual ~IMSTObject() {} // Our object must be able to return the bilayer it is associated with virtual const int getBiLayer() const = 0; // And, of course, our object must be able to return its position virtual const Point& getPosition() const = 0; // Objects need to determine the distance to a neighbor virtual const double getDistanceTo(const IMSTObject&) const = 0; }; // Some typedefs which enable one to define the adjacency list for the above typedef std::pair<const IMSTObject*, const IMSTObject*> MSTObjectPair; typedef std::pair<MSTObjectPair, double> MSTObjectDistPair; typedef std::map<MSTObjectPair, double> MSTObjectToDistMap; typedef std::list<MSTObjectDistPair > MSTObjectDistPairList; typedef std::pair<const IMSTObject*, double> MSTObjectToDistPair; typedef std::pair<const IMSTObject*, MSTObjectToDistPair > MSTObjectToObjectToDistPair; typedef std::map<const IMSTObject*, double> MSTObjectDistMap; typedef std::map<const IMSTObject*, MSTObjectDistMap > MSTObjectToObjectDistMap; // More useful stuff typedef std::vector<IMSTObject*> MSTObjectVec; typedef std::set<const IMSTObject*> MSTObjectSet; #endif