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
98d631886c96bc4bfb3e2cfde0eac6aed47a4fec
1b2a105edbcf263743004401290973794a50ac75
/nanosizer/data.h
be0f5e39af4029619dd6a277fd3070919799b9fa
[]
no_license
tphinkle/nanoIV
5e00eca020b8cf1d2f16cc47e252f224f6d67b26
2960c87db1d725bca57c8cf4469dcc798bb8247c
refs/heads/master
2021-01-10T02:45:38.071152
2016-12-21T14:54:13
2016-12-21T14:54:13
54,065,654
1
2
null
null
null
null
UTF-8
C++
false
false
180
h
data.h
#ifndef DATA_H #define DATA_H #include "ivsweep.h" #include <string> #include <vector> #include <iostream> class Data { public: Data(); }; #endif // DATA_H
06df6ad3b7456a7c261a8f7a06809673dcaa42ff
a4d8cb480cbdb196e79ce482f5f9221fc74855e2
/2011/201102/20110210_point.cpp
e123bf69c8ef37193927aaebf8ede127b750cab1
[]
no_license
bonly/exercise
96cd21e5aa65e2f4c8ba18adda63c28a5634c033
dccf193a401c386719b8dcd7440d1f3bb74cb693
refs/heads/master
2020-05-06T13:51:29.957349
2018-02-10T16:14:52
2018-02-10T16:14:52
3,512,855
1
0
null
null
null
null
UTF-8
C++
false
false
207
cpp
20110210_point.cpp
#include <cstdio> int main(){ unsigned int ary[3]={3, 4, 5}; unsigned int *p = ary; printf("p:%d\n", *p); printf("p1: %d\n", ++*p); p = ary; printf("p2: %d\n", *(p+2)); return 0; }
3938d5917a637ae4005d24c95480492855c1adf2
c6ed9aa97166d4778b89321b580af80c543bacc9
/icpc/meetings.c++
7835fe81be24d9a89eb0094f23f4b45868147534
[]
no_license
bradyz/sandbox
381bcaf2f3719dee142a00858f7062aeff98d1ab
ff90335b918886d5b5956c6c6546dbfde5e7f5b3
refs/heads/master
2021-01-23T09:03:54.697325
2018-02-27T20:47:48
2018-02-27T20:47:48
21,292,856
10
0
null
2015-09-03T16:53:15
2014-06-28T00:29:18
Python
UTF-8
C++
false
false
696
meetings.c++
#include <iostream> #include <algorithm> using namespace std; int T; int N, M; int number[100001]; int allowed[100001]; int main () { cin >> T; for (int t = 0; t < T; ++t) { cin >> N >> M; for (int i = 0; i < N; ++i) cin >> number[i]; for (int i = 0; i < M; ++i) cin >> allowed[i]; sort(number, number+N); sort(allowed, allowed+M); int i = 0; int j = 0; int result = 0; while (i < N && j < M) { if (number[i] <= allowed[j]) { result += 1; i += 1; } j += 1; } cout << result << endl; } return 0; }
903887aeebdd9d0c67ec03e33a66995f16351fb5
ae6dbcfd6a333bf598b871e15a7741fef81f964f
/Projects/Dms/Workshare.Interop.RightClick/Workshare.Interop.RightClick.cpp
d92c37f0271da1ef77f39b6525c9e9734ee440eb
[]
no_license
xeon2007/WSProf
7d431ec6a23071dde25226437583141f68ff6f85
d02c386118bbd45237f6defa14106be8fd989cd0
refs/heads/master
2016-11-03T17:25:02.997045
2015-12-08T22:04:14
2015-12-08T22:04:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,724
cpp
Workshare.Interop.RightClick.cpp
// This is the main DLL file. #include "stdafx.h" #include <msclr/marshal.h> #include "Workshare.Interop.RightClick.h" #include "RightClick.h" using namespace Workshare::Interop::RightClick; using namespace msclr::interop; bool RightClick::InvokeConvertToPdf(System::Collections::Generic::List<WSDocNonCom1^>^ documents){ CRightClick a; return a.Invoke_ConvertToPdf(Convert(documents)); } bool RightClick::InvokeCombine(System::Collections::Generic::List<Workshare::Interop::RightClick::WSDocNonCom1^>^ documents){ CRightClick a; return a.Invoke_PDFCombine(Convert(documents)); } bool RightClick::InvokeCompare(System::Collections::Generic::List<Workshare::Interop::RightClick::WSDocNonCom1^>^ documents) { CRightClick a; return a.Invoke_CompareWithDeltaview(Convert(documents)); } bool RightClick::InvokeOpenPDFInWord(System::Collections::Generic::List<Workshare::Interop::RightClick::WSDocNonCom1^>^ documents) { CRightClick a; return a.Invoke_OpenPDFinWord(Convert(documents)); } bool RightClick::CanOpenPdfInWord() { CRightClick a; return a.CanOpenPdfInWord(); } bool RightClick::CanCompare() { CRightClick a; return a.CanUseDeltaview(); } bool RightClick::CanCombine() { CRightClick a; return a.CanCombineToPdf(); } bool RightClick::CanConvertToPdf() { CRightClick a; return a.CanConvertToPDF(); } std::vector<WSDocNonCom> RightClick::Convert(System::Collections::Generic::List<WSDocNonCom1^>^ documents){ marshal_context context; std::vector<WSDocNonCom> wsDocuments; for(int i =0;i<documents->Count;i++){ WSDocNonCom1^ doc=documents[i]; WSDocNonCom wsDoc; wsDoc.SetDocId(context.marshal_as<const wchar_t *>(doc->DocId)); wsDocuments.push_back(wsDoc); } return wsDocuments; }
3d7b51d6d64fb9f6fffec084d23a85cbcefc7640
67d6d516ef784bfe0f42f2751eb9ca346cfc8473
/teensymodsynth/Master.cpp
c8aa0bf0e6bf9c009b7f6d36a22867550226a289
[]
no_license
deusletum/polymod
4368a67b9ef1c3ce4cb4045e0c2203da0b7b4256
97ea78fee4fddce7149df1956cbd7bf17304f6bc
refs/heads/master
2020-06-16T22:31:31.671937
2018-10-22T13:10:11
2018-10-22T13:10:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
457
cpp
Master.cpp
#include "Arduino.h" #include "Master.h" Master::Master() { note = 20; gate = false; sockets[4].setInput(_main, 0); sockets[6].setOutput(_keyboardCV, 0); sockets[7].setOutput(_keyboardGate, 0); } AudioAmplifier& Master::getMainOutput() { return _main; } void Master::update() { _keyboardGate.amplitude(gate?1:0); _keyboardCV.amplitude(((float) (note-20)) * 1/8/12); float vol = controls[0].getSmoothedValue(); _main.gain(vol*vol); }
2e3f149900c7aa43bc63e485cb71e26ca4b35e4b
b9264aa2552272b19ca393ba818f9dcb8d91da10
/hashmap/lib/seqan3/include/seqan3/core/detail/is_class_template_declarable.hpp
d9e8a13e3edf6ce3f182436609e9eb100274bd44
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-public-domain", "CC0-1.0", "CC-BY-4.0", "MIT" ]
permissive
eaasna/low-memory-prefilter
c29b3aeb76f70afc4f26da3d9f063b0bc2e251e0
efa20dc8a95ce688d2a9d08773d120dff4cccbb6
refs/heads/master
2023-07-04T16:45:05.817237
2021-08-12T12:01:11
2021-08-12T12:01:11
383,427,746
0
0
BSD-3-Clause
2021-07-06T13:24:31
2021-07-06T10:22:54
C++
UTF-8
C++
false
false
2,779
hpp
is_class_template_declarable.hpp
// ----------------------------------------------------------------------------------------------------- // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file * \brief Provides a type trait for verifying valid template declarations. * \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de> */ #pragma once #include <seqan3/std/type_traits> #include <seqan3/core/platform.hpp> namespace seqan3::detail { /*!\addtogroup core * \{ */ /*!\brief An unary type trait that tests whether a template class can be declared with the given template type * parameters. * \implements seqan3::unary_type_trait * \tparam query_t The type of the template class to test. * \tparam args_t The template parameter pack to instantiate the template class with. * * \details * * Note, this unary type trait can be used in a seqan3::detail::lazy_conditional expression to check if instantiating * a template class with specific template arguments would result in a valid template declaration. Thus, the template * parameters of the checked class must be constrained accordingly. It is, however, not possible to test if the * the resulting type is incomplete or not, such that it can not be tested if an instance of the class template with * the given template arguments can be actually created. * * ### Example * * \include test/snippet/core/detail/is_class_template_declarable_with.cpp */ template <template <typename ...> typename query_t, typename ...args_t> struct is_class_template_declarable_with : //!\cond public std::false_type //!\endcond {}; //!\cond template <template <typename ...> typename query_t, typename ...args_t> requires requires { typename std::type_identity<query_t<args_t...>>::type; } struct is_class_template_declarable_with<query_t, args_t...> : public std::true_type {}; //!\endcond /*!\brief Helper variable template for seqan3::detail::is_class_template_declarable_with. * \tparam query_t The type of the template class to test. * \tparam args_t The template parameter pack to instantiate the template class with. * \relates seqan3::detail::is_class_template_declarable_with */ template <template <typename ...> typename query_t, typename ...args_t> inline constexpr bool is_class_template_declarable_with_v = is_class_template_declarable_with<query_t, args_t...>::value; //!\} } // namespace seqan3::detail
722f40a8cc7132942feead99f98b1b5b8cd128a0
e3d45e816524fb74fe5f5f513f3d5f170a0a8abb
/preprocess/human/hg19/prog/anno/code/aseq/file/create_anno.cpp
127aabea8ed55687a14ca4af0349a72a60bb90f2
[ "MIT" ]
permissive
RJiangLab/OpenAnnotate
8bed938bf2596a41e47e27585b47924d51720942
7e8ac0ceaae7b13220718255542ba5f715e7520d
refs/heads/main
2023-04-03T08:04:37.226083
2021-04-12T14:11:33
2021-04-12T14:11:33
357,101,322
1
1
null
null
null
null
UTF-8
C++
false
false
28,642
cpp
create_anno.cpp
#include <cstdio> #include <cstdlib> #include <string> #include <vector> #include <queue> #include <map> #include <set> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <pthread.h> #include <dirent.h> #include <unistd.h> #include <memory.h> #include <malloc.h> #include <lz4.h> #include <lz4hc.h> #include <bzlib.h> #include <zlib.h> #include <lzma.h> using namespace std; #define CHECK_COMPRESS #define CM_LZ4 1 #define CM_BZ2 2 #define CM_LZ4Z 1 #define CM_BZ2Z 2 #define CM_ZLIB 3 #define CM_LZMA 4 #define LPBK 1000 #define BLEN 1000000 #define EPBK 871 #define PPBK 100 #define PPBN 10000000 #define BPBN (PPBN/PPBK) #define NTHREAD 16 #define fseek fseeko64 #define ftell ftello64 typedef char BYTE; typedef char CHAR; typedef size_t SIZE; typedef int8_t SI08; typedef int16_t SI16; typedef int32_t SI32; typedef int64_t SI64; typedef u_int8_t UI08; typedef u_int16_t UI16; typedef u_int32_t UI32; typedef u_int64_t UI64; // int LZ4_compress_HC(const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel); // int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); // int lz4_compress(const BYTE * ubuf, BYTE * cbuf, int ulen, int clen) { #if 0 return LZ4_compress_HC(ubuf, cbuf, ulen, clen, 9); #else return LZ4_compress_default(ubuf, cbuf, ulen, clen); #endif } // int LZ4_decompress_safe(const char* source, char* dest, int compressedSize, int maxDecompressedSize); // int LZ4_decompress_fast(const char* source, char* dest, int originalSize); // int lz4_decompress(const BYTE * cbuf, BYTE * ubuf, int clen, int ulen) { #if 0 return LZ4_decompress_safe(cbuf, ubuf, clen, ulen); #else return (LZ4_decompress_fast(cbuf, ubuf, ulen) == clen) ? ulen : -1; #endif } // int BZ2_bzBuffToBuffCompress( // char* dest, // unsigned int* destLen, // char* source, // unsigned int sourceLen, // int blockSize100k, // int verbosity, // int workFactor // ); // int bz2_compress(const BYTE * ubuf, BYTE * cbuf, int ulen, int clen) { unsigned int dlen = clen; return (BZ2_bzBuffToBuffCompress((char*)cbuf, &dlen, (char*)(*(&ubuf)), ulen, 9, 0, 0) == BZ_OK) ? dlen : -1; } // int BZ2_bzBuffToBuffDecompress( // char* dest, // unsigned int* destLen, // char* source, // unsigned int sourceLen, // int small, // int verbosity // ); // int bz2_decompress(const BYTE * cbuf, BYTE * ubuf, int clen, int ulen) { unsigned int dlen = ulen; return (BZ2_bzBuffToBuffDecompress((char*)ubuf, &dlen, (char*)(*(&cbuf)), clen, 0, 0) == BZ_OK) ? dlen : -1; } // int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); // int compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); // int zlib_compress(const BYTE * ubuf, BYTE * cbuf, int ulen, int clen) { uLongf dlen = clen; #if 0 return (compress ((Bytef*)cbuf, &dlen, (const Bytef*)ubuf, (uLong)ulen) == Z_OK) ? dlen : -1; #else return (compress2((Bytef*)cbuf, &dlen, (const Bytef*)ubuf, (uLong)ulen, 9) == Z_OK) ? dlen : -1; #endif } // int uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); // int zlib_decompress(const BYTE * cbuf, BYTE * ubuf, int clen, int ulen) { uLongf dlen = ulen; return (uncompress((Bytef*)ubuf, &dlen, (const Bytef*)cbuf, (uLong)clen) == Z_OK) ? dlen : -1; } // int lzma_easy_buffer_encode( // uint32_t preset, lzma_check check, // const lzma_allocator *allocator, // const uint8_t *in, size_t in_size, // uint8_t *out, size_t *out_pos, size_t out_size); // int lzma_compress(const BYTE * ubuf, BYTE * cbuf, int ulen, int clen) { lzma_check check = LZMA_CHECK_CRC64; uint32_t preset = 6; size_t out_pos = 0; return (lzma_easy_buffer_encode(preset, check, NULL, (const uint8_t*)ubuf, (size_t)ulen, (uint8_t*)cbuf, &out_pos, (size_t)clen) == LZMA_OK) ? out_pos : -1; } // int lzma_stream_buffer_decode( // uint64_t *memlimit, uint32_t flags, // const lzma_allocator *allocator, // const uint8_t *in, size_t *in_pos, size_t in_size, // uint8_t *out, size_t *out_pos, size_t out_size); // int lzma_decompress(const BYTE * cbuf, BYTE * ubuf, int clen, int ulen) { uint64_t memlimit = UINT64_MAX; uint32_t flags = 0; size_t in_pos = 0; size_t out_pos = 0; return (lzma_stream_buffer_decode(&memlimit, flags, NULL, (const uint8_t*)cbuf, &in_pos, (size_t)clen, (uint8_t*)ubuf, &out_pos, (size_t)ulen) == LZMA_OK) ? out_pos : -1; } int compress(const BYTE * ubuf, BYTE * cbuf, int ulen, int clen, int method) { if(method == CM_LZ4){ return lz4_compress (ubuf, cbuf, ulen, clen); } else if(method == CM_BZ2){ return bz2_compress(ubuf, cbuf, ulen, clen); } else if(method == CM_ZLIB){ return zlib_compress(ubuf, cbuf, ulen, clen); } else if(method == CM_LZMA){ return lzma_compress(ubuf, cbuf, ulen, clen); } return (-1); } int decompress(const BYTE * cbuf, BYTE * ubuf, int clen, int ulen, int method) { if(method == CM_LZ4){ return lz4_decompress (cbuf, ubuf, clen, ulen); } else if(method == CM_BZ2){ return bz2_decompress(cbuf, ubuf, clen, ulen); } else if(method == CM_ZLIB){ return zlib_decompress(cbuf, ubuf, clen, ulen); } else if(method == CM_LZMA){ return lzma_decompress(cbuf, ubuf, clen, ulen); } return (-1); } struct HEAD { union { struct { CHAR title[15]; BYTE cmethod; UI32 tmstamp; UI32 version; UI32 bingrps; UI32 grprows; UI32 grpcols; UI32 grpbcks; UI32 bckrows; UI32 bckcols; UI32 cellsize; UI64 indexpos[8]; }; BYTE dummy[256]; }; }; struct BEDLINE { int nchr; int nbeg; int nend; }; struct BEDBLOCK { int index; int nrows; int ncols; }; struct BINBLOCK { int index; int group; int ntype; int chrom; int nsize; }; class IOpts; class IPipe; class IAnno; class IOpts { public: virtual const char * operator [] (const char *) = 0; virtual const char * operator [] (int) = 0; public: virtual void ParseCmd(int argc, char * argv[]) = 0; virtual void ParseIni(const char *) = 0; }; class IPipe { public: virtual void* Alloc(int ) = 0; virtual void Free(void*) = 0; virtual void Push(void*) = 0; virtual void* Pop() = 0; virtual void Attach(IAnno*, bool = true) = 0; virtual void Detach(IAnno*, bool = true) = 0; virtual int Size(bool = true) = 0; }; class IAnno { public: virtual int Run(void*, void*) = 0; virtual int Wait(void**) = 0; virtual void Attach(IPipe*, bool = true) = 0; virtual void Detach(bool = true) = 0; }; class TOpts : public IOpts { public: TOpts() { } ~TOpts() { } public: virtual const char * operator [] (const char * key) { map<string, string>::iterator it = sopt.find(string(key)); return it != sopt.end() ? it->second.c_str() : NULL; } virtual const char * operator [] (int key) { map<int, string>::iterator it = iopt.find(key); return it != iopt.end() ? it->second.c_str() : NULL; } public: virtual void ParseCmd(int argc, char * argv[]) { } virtual void ParseIni(const char *) { } public: void SetOpt(const char * key, const char * val) { if(key) { sopt[string(key)] = string(val); } } void SetOpt(int key, const char * val) { iopt[key] = string(val); } public: void SetOpt(const char * key, int val) { if(key) { char buf[16]; sprintf(buf, "%d", val); sopt[string(key)] = string(buf); } } void SetOpt(int key, int val) { char buf[16]; sprintf(buf, "%d", val); iopt[key] = string(buf); } public: const char * GetOpt(const char * key) { map<string, string>::iterator it = sopt.find(string(key)); return it != sopt.end() ? it->second.c_str() : NULL; } const char * GetOpt(int key) { map<int, string>::iterator it = iopt.find(key); return it != iopt.end() ? it->second.c_str() : NULL; } private: map<string, string> sopt; map<int, string> iopt; }; class TAnnoOpts : public TOpts { public: TAnnoOpts() { LoadDefault(); } ~TAnnoOpts() { } public: void LoadDefault() { SetOpt("data-path", "data"); SetOpt("thread-number", 16); SetOpt("block-rows", LPBK); SetOpt("block-cols", EPBK); } }; class TPipe : public IPipe { public: TPipe() { pthread_mutex_init(&pipelock, NULL); } ~TPipe() { } public: int Size(bool head = true) { pthread_mutex_lock(&pipelock); int size = (int)(head?headpool:tailpool).size(); pthread_mutex_unlock(&pipelock); return size; } void Attach(IAnno * anno, bool head = true){ pthread_mutex_lock (&pipelock); vector<IAnno*>& pool = head ? headpool : tailpool; vector<IAnno*>::iterator it = pool.begin(); while(it != pool.end() && *it != anno) it++; if(it == pool.end()) pool.push_back(anno); pthread_mutex_unlock(&pipelock); } void Detach(IAnno * anno, bool head = true){ pthread_mutex_lock(&pipelock); vector<IAnno*>& pool = head ? headpool : tailpool; for(int i = 0; i < pool.size(); i++){ if(pool[i] == anno){ pool.erase(pool.begin()+i--); } } pthread_mutex_unlock(&pipelock); } private: vector<IAnno*> tailpool; vector<IAnno*> headpool; pthread_mutex_t pipelock; }; class TPoolPipe : public TPipe { public: TPoolPipe(int pipelong) : poolsize(pipelong) { pthread_mutex_init(&poollock, NULL); pthread_cond_init (&poolaval, NULL); } public: ~TPoolPipe() { for(set<void*>::iterator it = memblock.begin(); it != memblock.end(); it++){ if(*it) free(*it); } } public: virtual void * Alloc(int size) { void * data = NULL; pthread_mutex_lock(&poollock); if(pooldata.size() == 0 && memblock.size() < poolsize){ memblock.insert(data=malloc(size)); pooldata.push_back(data); } while(pooldata.size() == 0){ pthread_cond_wait(&poolaval, &poollock); } data = pooldata.back(); pooldata.pop_back(); if(malloc_usable_size(data) < size) { memblock.erase(data); memblock.insert(data=realloc(data, size)); } memset(data, 0, size); pthread_mutex_unlock(&poollock); return data; } virtual void Free(void * data) { pthread_mutex_lock(&poollock); if(memblock.find(data) != memblock.end()) { pooldata.push_back(data); } pthread_cond_signal(&poolaval); pthread_mutex_unlock(&poollock); } private: int poolsize; set<void*> memblock; vector<void*> pooldata; pthread_mutex_t poollock; pthread_cond_t poolaval; }; class TQueuePipe : public TPoolPipe { public: TQueuePipe(int poollong) : TPoolPipe(poollong) { pthread_mutex_init(&queuelock, NULL); pthread_cond_init (&queueaval, NULL); } ~TQueuePipe() { } public: virtual void Push(void * data) { pthread_mutex_lock(&queuelock); queuedata.push(data); pthread_cond_signal (&queueaval); pthread_mutex_unlock(&queuelock); } virtual void * Pop() { void * data = NULL; pthread_mutex_lock(&queuelock); while(queuedata.empty()){ pthread_cond_wait(&queueaval, &queuelock); } data = queuedata.front(); queuedata.pop(); pthread_mutex_unlock(&queuelock); return data; } private: queue<void*> queuedata; pthread_mutex_t queuelock; pthread_cond_t queueaval; }; class TAnno : public IAnno { public: TAnno() : threadid(0), args(NULL), ipipe(NULL), opipe(NULL) { nid = nthread++; } ~TAnno() { } public: virtual int Run(void * opts, void * args) { this->opts = (IOpts*)opts; this->args = args; return pthread_create(&this->threadid, NULL, &ThreadProc, (void*)this); } virtual int Wait(void ** rets) { void * rett; return pthread_join(threadid, rets?rets:&rett); } virtual void Attach(IPipe * pipe, bool in = true) { (in?ipipe=pipe:opipe=pipe)->Attach((IAnno*)this,in); } virtual void Detach(bool in = true) { (in?ipipe:opipe)->Detach((IAnno*)this,in); (in?ipipe=NULL:opipe=NULL); } protected: virtual void Init(){ // fprintf(stdout, "[%02d][Print] Started.\n", nid); } virtual void * Main(void * args){ return (void*) NULL; } virtual void Exit(){ if(ipipe) Detach(true); if(opipe) Detach(false); // fprintf(stdout, "[%02d][Print] Exiting.\n", nid); } protected: pthread_t threadid; IPipe * ipipe; IPipe * opipe; IOpts * opts; void * args; int nid; private: static int nthread; private: static void* ThreadProc(void * args) { void * rets = NULL; TAnno * that = (TAnno*) args; that->Init(); rets = that->Main(that->args); that->Exit(); return rets; } }; int TAnno::nthread = 0; class TAnnoLoad : public TAnno { public: TAnnoLoad() { } ~TAnnoLoad() { } protected: virtual void * Main(void * args){ const char * sbed = (*opts)["input-file"]; gzFile gbed = NULL; if( sbed){ gbed = gzopen(sbed, "rb"); } else { fprintf(stderr, "[%02d][Error] Null input file name.\n", nid); } char sbuf[1024]; char schr[16]; int lpbk = LPBK; int size = sizeof(BEDBLOCK)+lpbk*sizeof(int)*3; int rpbk = 10; int cidx = 0; int crow = 0; int cchr = 0; int nchr = 0; int nbeg = 0; int nend = 0; BEDLINE * lbed = NULL; BEDBLOCK * pbed = NULL; for(int nrow = 0; gbed && !gzeof(gbed); nrow = 0) { if((pbed=(BEDBLOCK*)opipe->Alloc(size)) == NULL) { fprintf(stderr, "[%02d][Error] Unable to allocate bed block.\n", nid); break; } lbed=(BEDLINE *)(pbed+1); if(cchr != nchr) { // fprintf(stdout, "[%02d][Print] New row [%4d\t%02d\t%9d\t%9d].\n", nid, nrow, nchr, nbeg, nend); lbed[nrow ].nchr = cchr = nchr; lbed[nrow ].nbeg = nbeg; lbed[nrow++].nend = nend; } while(nrow < rpbk && cchr==nchr && gzgets(gbed, sbuf, sizeof(sbuf)/sizeof(sbuf[0])) > 0){ crow++; if(sscanf(sbuf, "chr%s%d%d", schr, &nbeg, &nend) ==3){ nchr = (*schr=='X'?23:(*schr=='Y'?24:(*schr=='M'?25:atoi(schr)))); } if(cchr == nchr) { // fprintf(stdout, "[%02d][Print] New row [%4d\t%02d\t%9d\t%9d].\n", nid, nrow, nchr, nbeg, nend); lbed[nrow ].nchr = nchr; lbed[nrow ].nbeg = nbeg; lbed[nrow++].nend = nend; } } if( nrow) { pbed->index = cidx++; pbed->nrows = nrow; pbed->ncols = 3; opipe->Push(pbed); } else { opipe->Free(pbed); } if(rpbk < lpbk) rpbk *= 2; if(rpbk > lpbk) rpbk = lpbk; } for(int i = 0, I = atoi((*opts)["thread-number"]); i < I; i++){ opipe->Push(NULL); } if(gbed){ gzclose(gbed); } return (void*) NULL; } }; class TAnnoSave : public TAnno { public: TAnnoSave() { } ~TAnnoSave() { } private: struct BININFO { int cidx; vector<BINBLOCK*> vbin; BININFO() { cidx = 0; } }; typedef map<int,BININFO*> IMAP; typedef map<int,FILE*> FMAP; IMAP imap; FMAP fmap; protected: virtual void * Main(void * args) { int tnum = atoi((*opts)["thread-number"]); for(int t = tnum, b = 0, r = 0; t > 0 || r > 0; b++){ // fprintf(stdout, "[%02d][Print] Received bin block [%d].\n", nid, b); BINBLOCK * pbin = (BINBLOCK*)ipipe->Pop(); if(pbin != NULL) { BININFO * pinf = RegisterBlock(pbin); if(pinf != NULL){ SaveBlock(pinf); r = RemainBlock(); } } else { t--; } } FileClose(); } private: BININFO * RegisterBlock(BINBLOCK * pbin) { int group = pbin->group; int ntype = pbin->ntype; int binid = group*10 + ntype; if( imap.find(binid) == imap.end()) { imap[binid] = new BININFO; } BININFO * pinfo = imap[binid]; pinfo->vbin.push_back(pbin); return pinfo; } int RemainBlock() { int remain = 0; for(IMAP::iterator it = imap.begin(); it != imap.end(); it++){ BININFO * pinfo = it->second; remain += pinfo ? pinfo->vbin.size() : 0; } return remain; } void SaveBlock(BININFO * pinf) { vector<BINBLOCK*> & vbin = pinf->vbin; int & cidx = pinf->cidx; for(int i = 0; i < vbin.size(); i++){ BINBLOCK * pbin = vbin[i]; if(pbin && pbin->index == cidx) { // fprintf(stdout, "[%02d][Print] Saving bin block [%d].\n", nid, cidx); SaveBlock(pbin); cidx++; vbin.erase(vbin.begin()+i); i = -1; } } } void SaveBlock(BINBLOCK * pbin) { FILE * fbin = FileOpen(pbin); if(fbin != NULL) { int nsize = pbin->nsize; int nsave = fwrite(pbin+1, 1, nsize, fbin); if( nsave != nsize) { fprintf(stderr, "[%02d][Error] Unable to write bin block.\n", nid); } } ipipe->Free(pbin); } FILE * FileOpen(BINBLOCK * pbin) { FILE * file = NULL; int nfid = FileID(pbin); FMAP::iterator it = fmap.find(nfid); if(it == fmap.end()) { string name = FileName(pbin); MakePath(name.c_str()); if((file=fopen(name.c_str(), "wb")) != NULL) { fmap[nfid] = file; } else { fprintf(stderr, "[%02d][Error] Unable to open file [%X\t%s].\n", nid, nfid, name.c_str()); } } else { file = fmap[nfid]; } return file; } string FileName(BINBLOCK * pbin) { char stxt[1024] = {0}; const char * home = (*opts)["output-path"]; const char * ndir[] = {"fgrc", "bgrc", "peak", "spot", "open"}; const char * name[] = {"foreread", "backread", "peakopen", "spotopen", "readopen"}; const char * nsuf[] = {"bin", "txt.gz"}; int ntype = pbin->ntype; int group = pbin->group; int chrom = pbin->chrom; if( ntype == 0) { sprintf(stxt, "%s/%s/%02d.%s", home, ndir[group], chrom, nsuf[ntype]); } else if (ntype == 1) { sprintf(stxt, "%s/%s/%s.%s", home, "anno", name[group], nsuf[ntype]); } return string(stxt); } int FileID(BINBLOCK * pbin) { int group = pbin->group; int ntype = pbin->ntype; int chrom = ntype==0 ? pbin->chrom : 0; return (group<<16) | (ntype<<8) | chrom; } void FileClose() { for(FMAP::iterator it = fmap.begin(); it != fmap.end(); it++){ FILE * file = it->second; if(file) { fclose(file); it->second = NULL; } } } int MakePath(const char * file) { int nret = 1; string path = file; for(int p=1; (p=path.find_first_of('/',p)) != string::npos; p++) { string dirname = path.substr(0, p); DIR * diropen = opendir(dirname.c_str()); if(diropen == NULL) { nret = nret && (mkdir(dirname.c_str(),0755)==0); } else { closedir(diropen); } } return nret; } }; class TAnnoWork : public TAnno { public: TAnnoWork() : head(NULL), bidx(NULL), bubk(NULL), bcbk(NULL), fbin(NULL), cbin( -1), cgrp( -1), cbck( -1), info(NULL), fgrc(NULL), bgrc(NULL), peak(NULL), spot(NULL), open(NULL) { lpbk = LPBK; epbk = EPBK; blen = BLEN; ilen = sizeof(BEDLINE); dlen = sizeof(int)*epbk; ppbn = PPBN; bpbn = BPBN; ppbk = PPBK; bpun = sizeof(int); } ~TAnnoWork() { if(fbin) fclose(fbin); if(head) free(head); if(bidx) free(bidx); if(bubk) free(bubk); if(bcbk) free(bcbk); if(braw) free(braw); if(bzip) free(bzip); if(fgrc) free(fgrc); if(bgrc) free(bgrc); if(peak) free(peak); if(spot) free(spot); if(open) free(open); } protected: virtual void * Main(void * args){ for(BEDBLOCK * pbed; (pbed=(BEDBLOCK*)ipipe->Pop()) != NULL; ) { // fprintf(stdout, "[%02d][Print] Received bed block [%d].\n", nid, pbed->index); InitBlock(pbed); CalcBlock(); FormatBlock(); ipipe->Free(pbed); } opipe->Push(NULL); } private: void InitBlock(BEDBLOCK * pbed) { nidx = pbed->index; nrow = pbed->nrows; ncol = epbk; memcpy(info=(int*)(info?info:malloc(lpbk*ilen)), pbed+1, nrow*ilen); for(int g = 0; g < 5; g++) { memset(data[g]=(data[g]?data[g]:malloc(lpbk*dlen)), 0, lpbk*dlen); } if(braw == NULL) braw = malloc(lpbk*(ilen+dlen)*2); if(bzip == NULL) bzip = malloc(lpbk*(ilen+dlen)*2); } void CalcBlock() { for(int tgrp = 0; tgrp < 4; tgrp++){ for(int trow = 0; trow < nrow; trow++){ CalcRow(tgrp, trow); } } } void CalcRow(int tgrp, int trow) { int nchr = info[trow*3+0]; int nbeg = info[trow*3+1]; int nend = info[trow*3+2]; nbeg = tgrp == 1 ? (nbeg+nend)/2 : nbeg; nend = tgrp == 1 ? (nbeg+1) : nend; int nlen = nend - nbeg; // fprintf(stdout, "[%02d][Print] Calc row [%d\t%4d\t%02d\t%9d\t%9d].\n", nid, tgrp, trow, nchr, nbeg, nend); for(int npos = nbeg; npos < nend; npos++){ void * pvec = LoadVector(nchr, npos, tgrp); int * ivec = (int*) pvec; float * fvec = (float*)pvec; int * fgrc = this->fgrc + trow*epbk; int * bgrc = this->bgrc + trow*epbk; float * peak = this->peak + trow*epbk; float * spot = this->spot + trow*epbk; float * open = this->open + trow*epbk; for(int e = 0; e < epbk; e++){ if(tgrp == 0) { fgrc[e] += ivec[e]; open[e] = 1.0 * fgrc[e] / nlen; } else if(tgrp == 1) { bgrc[e] = ivec[e]; open[e] /= 1.0 * (bgrc[e]>0?bgrc[e]:1) / blen; open[e] = open[e] > 1E-4 ? open[e] : 0.0; } else if(tgrp == 2) { peak[e] = max(peak[e], fvec[e]); peak[e] = peak[e] > 1E-4 ? peak[e] : 0.0; } else if(tgrp == 3) { spot[e] = max(spot[e], fvec[e]); spot[e] = spot[e] > 1E-4 ? spot[e] : 0.0; } } } this->nchr = nchr; } void FormatBlock() { for(int tgrp = 0; tgrp < 5; tgrp++){ BINBLOCK * pbin = NULL; if((pbin=(BINBLOCK*)opipe->Alloc(sizeof(BINBLOCK)+lpbk*(ilen+dlen))) != NULL) { FormatBin(pbin, tgrp); opipe->Push(pbin); } else { fprintf(stderr, "[%02d][Error] Unable to allocate bin block.\n", nid); } int size = FormatTxt(tgrp); if((pbin =(BINBLOCK*)opipe->Alloc(sizeof(BINBLOCK)+size)) != NULL) { memcpy(pbin, bzip, sizeof(BINBLOCK)+size); opipe->Push(pbin); } else { fprintf(stderr, "[%02d][Error] Unable to allocate txt block.\n", nid); } } } void FormatBin(BINBLOCK * pbin, int tgrp) { pbin->index = nidx; pbin->group = tgrp; pbin->chrom = nchr; pbin->ntype = 0; pbin->nsize = nrow*(ilen+dlen); for(int trow = 0; trow < nrow; trow++) { int * thisinfo = ((int*)(pbin+1)) + trow*(3+epbk) + 0; int * thisdata = ((int*)(pbin+1)) + trow*(0+epbk) + 3; int * thatinfo = ((int*)(info )) + trow*(3); int * thatdata = ((int*)(data[tgrp])) + trow*epbk; memcpy(thisinfo, thatinfo, sizeof(int)*3); memcpy(thisdata, thatdata, sizeof(int)*epbk); } } int FormatTxt(int tgrp) { BINBLOCK * ptxt = (BINBLOCK*) braw; char * btxt = (char*)(ptxt+1); ptxt->index = nidx; ptxt->group = tgrp; ptxt->chrom = nchr; ptxt->ntype = 1; ptxt->nsize = 0; int & p = ptxt->nsize; for(int trow = 0; trow < nrow; trow++) { int * info = ((int*)(this->info )) + trow*3; int * data = ((int*)(this->data[tgrp])) + trow*epbk; int nchr = info[0]; if(nchr < 23) p += sprintf(btxt+p, "chr%d", nchr); else p += sprintf(btxt+p, "chr%s", nchr==23?"X":(nchr==24?"Y":"M")); p += sprintf(btxt+p, "\t%d", info[1]); p += sprintf(btxt+p, "\t%d", info[2]); for(int e = 0; e < epbk; e++){ if(tgrp < 2) p += sprintf(btxt+p, "\t%d", ((int*) data)[e]); else p += sprintf(btxt+p, "\t%.4g", ((float*)data)[e]); } p += sprintf(btxt+p, "\n"); } return CompressTxt(); } int CompressTxt() { BINBLOCK * praw = (BINBLOCK*)braw; z_stream gzsm = {0}; z_stream * gzip = &gzsm; gzip->zalloc = Z_NULL; gzip->zfree = Z_NULL; gzip->opaque = Z_NULL; gzip->next_in = (Bytef*)(praw+1); gzip->avail_in = praw->nsize; deflateInit2(gzip, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 9, Z_DEFAULT_STRATEGY); int clen = (int)deflateBound(gzip, praw->nsize); if( bzip == NULL) { bzip = malloc(clen+sizeof(BINBLOCK)); } else if( malloc_usable_size(bzip) < clen) { bzip = realloc(bzip, clen+sizeof(BINBLOCK)); } BINBLOCK * pzip = (BINBLOCK*)bzip; gzip->next_out = (Bytef*)(pzip+1); gzip->avail_out = clen; if( deflate(gzip, Z_FINISH) == Z_STREAM_END) { memcpy(pzip, praw, sizeof(BINBLOCK)); pzip->nsize = clen - gzip->avail_out; } else { fprintf(stderr, "[%02d][Error] Deflate faild.\n", nid); } deflateEnd(gzip); return pzip->nsize; } void * LoadVector(int nchr, int npos, int ngrp) { int tgrp = ngrp; int tbin = nchr*100 + npos/ppbn; int tbck = npos%ppbn/ppbk; int trow = npos%ppbk; if( tbin != cbin){ LoadHead(tbin); } if( tgrp != cgrp){ LoadGroup(tgrp); } if( tbck != cbck){ LoadBlock(tbck); } return bubk+trow*epbk*bpun; } void LoadHead(int tbin) { char sbin[1024] = {0}; sprintf(sbin, "%s/%04d", (*opts)["data-path"], tbin); if( fbin ) fclose(fbin); if((fbin = fopen (sbin, "rb")) != NULL) { if(head == NULL) { head = (HEAD*)malloc(sizeof(HEAD)); } if(head == NULL) { fprintf(stderr, "[%02d][Error] Unable to allocate memory for head [%s].\n", nid, sbin); } if(fseek(fbin,-sizeof(HEAD),SEEK_END)==0 && fread(head,sizeof(HEAD),1,fbin)==1) { cbin = tbin; cgrp = -1; } else { fprintf(stderr, "[%02d][Error] Unable to read head for bin file [%s].\n", nid, sbin); } } else { fprintf(stderr, "[%02d][Error] Unable to open bin file [%s].\n", nid, sbin); } } void LoadGroup(int tgrp) { int ppbk = PPBK; int epbk = EPBK; int bpun = sizeof(int); int bpbn = BPBN; if( bidx == NULL) { bidx = (UI64*)malloc((bpbn+1)*sizeof(UI64)); } if( bcbk == NULL) { bcbk = (BYTE*)malloc(max((int)(bpbn*sizeof(UI64)),ppbk*epbk*bpun)); } if( fbin && head && bidx && bcbk){ BYTE cmtd = head->cmethod; UI64 ipos = head->indexpos[tgrp]; UI32 clen = head->indexpos[tgrp+1] - ipos; UI32 ulen =(bpbn+1)*sizeof(UI64); if(fseek(fbin,ipos,SEEK_SET)==0 && fread(bcbk,clen,1,fbin)==1){ if(decompress((BYTE*)bcbk,(BYTE*)bidx,clen,ulen,cmtd) == ulen){ cgrp = tgrp; cbck = -1; } else { fprintf(stderr, "[%02d][Error] Unable to decompress index [%d].\n", nid, tgrp); } } else { fprintf(stderr, "[%02d][Error] Unable to read index [%d].\n", nid, tgrp); } } else { fprintf(stderr, "[%02d][Error] Empty fbin or head [%d].\n", nid, tgrp); } } void LoadBlock(int tbck) { int ppbk = PPBK; int epbk = EPBK; int bpun = sizeof(int); int bpbn = BPBN; if( bubk == NULL) { bubk = (BYTE*)malloc(ppbk*epbk*bpun+1024); } if( bcbk == NULL) { bcbk = (BYTE*)malloc(max((int)(bpbn*sizeof(UI64)),ppbk*epbk*bpun)); } if( fbin && bidx && bubk && bcbk){ BYTE cmtd = head->cmethod; UI64 ipos = bidx[tbck]; UI32 clen = bidx[tbck+1] - ipos; UI32 ulen = ppbk*epbk*bpun; if(fseek(fbin,ipos,SEEK_SET)==0 && fread(bcbk,clen,1,fbin)==1){ if(decompress((BYTE*)bcbk,(BYTE*)bubk,clen,ulen,cmtd) == ulen){ cbck = tbck; } else { fprintf(stderr, "[%02d][Error] Unable to decompress data block [%d].\n", nid, tbck); } } else { fprintf(stderr, "[%02d][Error] Unable to read block [%d].\n", nid, tbck); } } else { fprintf(stderr, "[%02d][Error] Unable to read bin file.\n", nid); } } private: struct { FILE * fbin; HEAD * head; UI64 * bidx; BYTE * bubk; BYTE * bcbk; int cgrp; int cbin; int cbck; }; struct { int lpbk; int epbk; int blen; int ilen; int dlen; int ppbn; int bpbn; int ppbk; int bpun; }; struct { int nidx; int nchr; int nrow; int ncol; int * info; union { struct{ int * fgrc; int * bgrc; float * peak; float * spot; float * open; }; void * data[5]; }; void * braw; void * bzip; }; }; int create_anno(int argc, char * argv[]) { IOpts * iopts = new TAnnoOpts; TOpts * topts = (TOpts*)iopts; // topts->SetOpt("input-file", "/data/encode/human/dseq/peak/hg19/ENCFF001SOF/ENCFF001SOF.bed.gz"); // topts->SetOpt("output-path", "/tmp/test"); topts->SetOpt("input-file", argv[1]); topts->SetOpt("output-path", argv[2]); int nwork = atoi((*iopts)["thread-number"])+2; IPipe * ipipe = new TQueuePipe( 50); IPipe * opipe = new TQueuePipe(512); IAnno** panno = new IAnno*[nwork]; for(int i = 0; i < 1; i++){ panno[i] = new TAnnoLoad; panno[i]->Attach(ipipe, false); } for(int i = 1; i < 2; i++){ panno[i] = new TAnnoSave; panno[i]->Attach(opipe, true); } for(int i = 2; i < nwork; i++){ panno[i] = new TAnnoWork; panno[i]->Attach(ipipe, true); panno[i]->Attach(opipe, false); } for(int i = 0; i < nwork; i++){ panno[i]->Run(iopts, NULL); } for(int i = 0; i < nwork; i++){ panno[i]->Wait(NULL); } for(int i = 0; i < nwork; i++){ delete panno[i]; } delete iopts; delete ipipe; delete opipe; return EXIT_SUCCESS; } int main(int argc, char * argv[]) { if(0) for(int i = 0; i < argc; i++){ fprintf(stdout, "%d\t%s\n", i, argv[i]); } if(argc < 3){ fprintf(stderr, "[Error] Incorrect input arguments.\n"); } else { return create_anno(argc, argv); } return EXIT_FAILURE; }
396a4591dd24926b0b9e9839ed8d6eb79f8f052e
c85a8f88fc89ec4c72bb42a6c21f1456567fd9bb
/projects/temp/NetKernel/src/MemoryPool.h
d27605afad0061eec9e600d1564113ff5822aaa3
[]
no_license
Bia10/clrn
e7f24f617513399b89ee17bc318697f8fe148d63
4d036069018da734f9e68b38e7d86e43c3ae19c1
refs/heads/master
2016-09-01T07:03:28.081683
2013-07-08T17:40:28
2013-07-08T17:40:28
50,362,475
2
0
null
null
null
null
UTF-8
C++
false
false
957
h
MemoryPool.h
/* * MemoryPool.h * * Created on: Feb 4, 2012 * Author: clrn */ #ifndef MEMORYPOOL_H_ #define MEMORYPOOL_H_ #include <memory> #include <list> namespace net { #pragma pack (push, 1) //! Transaction Id struct CTransactionId { unsigned char GUID[16]; std::size_t nId; const bool operator < (const CTransactionId& that) const; void Generate(); }; #pragma pack (pop) //! Class for memory management class CMemoryPool { public: //! Buffer type struct Buffer { void* pData; std::size_t nSize; }; CMemoryPool(); ~CMemoryPool(); //! Allocate buffer const Buffer Allocate(const std::size_t nSize); //! Free transaction buffer void Free(const CTransactionId& Id); //! Read handler void ReadHandler(const std::size_t nReaded, std::list< CTransactionId >& Completed); private: //! Implementation class CImpl; const std::auto_ptr< CImpl > m_pImpl; }; } /* namespace net */ #endif /* MEMORYPOOL_H_ */
1ab3b6d9b92600a10db60bc2b4cd9855614fbb5c
8d0e09c2ed566d3f1ae26b9fda3f4d5bf2781266
/zrobione/dodawanie_liczb_calkowitych.cpp
fa2baee2a04e74afd38c8b34b3c0caf2b683fd2f
[]
no_license
ljadanowski/spoj
9ae2144cf45990eaf9ae3c33ee91a6d8ade1efb2
06369740289f06ed9cb3223f412b353c22d8e02f
refs/heads/master
2021-01-18T08:06:30.839653
2015-02-15T12:31:31
2015-02-15T12:31:31
29,289,630
0
0
null
null
null
null
UTF-8
C++
false
false
175
cpp
dodawanie_liczb_calkowitych.cpp
#include <iostream> using namespace std; int main() { int n = 3, liczba, wynik = 0; while(n--) { cin >> liczba; wynik += liczba; } cout << wynik << endl; }
4f2006a808797f6699c78ef3c629335d5509a2b3
884863a85640fb3dc56add3bc41449cdeec2fdf4
/cpp_project/ict1009_macbuild/Child.cpp
2990a54ed8254696f4ee84d309b0068f9438392e
[]
no_license
thomaslwk/ICT1009
a258c34c5bb03b216761aee29a3c74cd0d5322af
67dbedacf8d8a31e30e0586204c03e5d6bdfbfda
refs/heads/main
2023-04-01T11:56:11.115991
2021-04-16T08:10:07
2021-04-16T08:10:07
347,320,501
0
0
null
null
null
null
UTF-8
C++
false
false
3,189
cpp
Child.cpp
#ifndef CHILD_CPP #define CHILD_CPP // Declaration #include "Child.h" #include "X_MEN.h" #include <time.h> Child::Child(Male father, Female mother){ /* ************************************** */ /* ****** Normal Child Constructor ****** */ /* ************************************** */ /********************************************************** * Random Number function to randomize feature inheritance * to either be from father or mother ************************************************************/ srand(time(NULL)); int e = rand() % 2; if (e == 0) { Eyes::setPart(father.getEye()); this->speak_eye = "\nI have my father's eyes."; } else { Eyes::setPart(mother.getEye()); this->speak_eye = "\nI have my mother's eyes."; } int n = rand() % 2; if (n == 0) { Nose::setPart(father.getNose()); this->speak_nose = "\nI have my father's nose."; } else { Nose::setPart(mother.getNose()); this->speak_nose = "\nI have my mother's nose."; } int m = rand() % 2; if (m == 0) { Mouth::setPart(father.getMouth()); this->speak_mouth = "\nI have my father's mouth."; } else { Mouth::setPart(mother.getMouth()); this->speak_mouth = "\nI have my mother's mouth."; } }; Child::Child(Male father, Female mother, X_MEN x){ /* ************************************** */ /* ****** Normal Child Constructor ****** */ /* ************************************** */ // Set child to have mutant gene this->Mutation_file = x.getX_Gene(); /********************************************************** * Random Number function to randomize feature inheritance * to either be from father or mother ************************************************************/ srand(time(NULL)); int e = rand() % 2; if (e == 0) { Eyes::setPart(father.getEye()); this->speak_eye = "\nI have my father's eyes."; } else { Eyes::setPart(mother.getEye()); this->speak_eye = "\nI have my mother's eyes."; } int n = rand() % 2; if (n == 0) { Nose::setPart(father.getNose()); this->speak_nose = "\nI have my father's nose."; } else { Nose::setPart(mother.getNose()); this->speak_nose = "\nI have my mother's nose."; } int m = rand() % 2; if (m == 0) { Mouth::setPart(father.getMouth()); this->speak_mouth = "\nI have my father's mouth."; } else { Mouth::setPart(mother.getMouth()); this->speak_mouth = "\nI have my mother's mouth."; } } /* ********************************************* */ /* ****** Getter Methods for child object ****** */ /* ********************************************* */ // Return eyes std::string Child::getEye(){ return Eyes::getPart(); } // Return nose std::string Child::getNose(){ return Nose::getPart(); } // Return mouth std::string Child::getMouth(){ return Mouth::getPart(); } // Return speach std::string Child::talk(){ speak_file += speak_eye + speak_nose + speak_mouth; return speak_file; } #endif
81a48c5d6d30776c7a4700dd9f47d2f5c51795c3
268d653ef182223f50604868d27505834376aa83
/List/List/ElementsMenu.cpp
bc0ed1dbcfd10ab96c51699ec88ed666f3bb9e90
[]
no_license
kunansy/List
80b114084940f48fe242718a928225a91f66e097
f6a9fc4064d693860995380a513f7a6b9631d8f6
refs/heads/master
2023-01-23T03:39:12.725320
2020-08-11T07:58:13
2020-08-11T07:58:13
286,681,459
0
0
null
null
null
null
UTF-8
C++
false
false
311
cpp
ElementsMenu.cpp
#pragma once #ifndef _ELEMENTS_MENU_H #define _ELEMENTS_MENU_H #include "Menu.h" namespace MENU { void ElementsMenu() { std::cout << "1.Add" << std::endl; std::cout << "2.Remove" << std::endl; std::cout << "3.Remove from index" << std::endl; std::cout << "4.Exit" << std::endl; } } #endif
8e847bf82d577d51eb3747a2ad8ab8d17921fa46
722648b125fe313a40d2739d75c15789e263e6d1
/tests/TestSafeDartSafeConfiguration/tst_testsafedartsafeconfiguration.cpp
5d553e452e608308bde1e25ef22e96a5331cbd75
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-us-govt-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
naushad-rahman/SAFE-DART
20d78d6a14aab7a9f57d05f310a4bdd3205ddba4
41d75c1c116c29d68455942df74a4a9205a0e444
refs/heads/master
2020-07-15T05:44:26.449765
2017-12-01T16:28:55
2017-12-01T16:28:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,289
cpp
tst_testsafedartsafeconfiguration.cpp
/* ********************************************************************** ** ** Developed for NASA Glenn Research Center ** By: Flight Software Branch (LSS) ** ** Project: Flow Boiling and Condensation Experiment (FBCE) ** Candidate for GOTS reuse once FBCE has completed V&V testing ** ** Filename: tst_testsafedartsafeconfiguration.cpp ** File Date: 20160928 ** ** Authors ** ** Author: Jordan R. Higgins (JRH) ** ** Version and Traceability ** ** Subversion: @version $Id$ ** ** Revision History: ** <Date> <Name of Change Agent> ** Description: ** - Bulleted list of changes. ** ** Copyright © 2017 United States Government as represented by NASA Glenn Research Center. ** No copyright is claimed in the United States under Title 17, U.S.Code. All Other Rights Reserved. ** See LICENSE.txt in the root of the repository for more details. ** ********************************************************************** */ #include <QCoreApplication> #include <QFileInfo> #include <QUuid> #include <QtTest> #include <safeconfiguration.h> class OpenSafeConfiguration : public SafeConfiguration { public: OpenSafeConfiguration(QObject *parent = 0) : SafeConfiguration(parent) { } using SafeConfiguration::_file; using SettingsConfiguration::_settings; }; class TestSafeDartSafeConfiguration : public QObject { Q_OBJECT private slots: void testSettings(); }; void TestSafeDartSafeConfiguration::testSettings() { QString file = QUuid::createUuid().toString(); SafeConfiguration::setFile(file); OpenSafeConfiguration configuration(this); QVERIFY2(configuration.parent() == this, "SafeConfiguration did not set parent."); QVERIFY2(configuration._settings != nullptr, "SafeConfiguration did not set QSettings."); QVERIFY2(QFileInfo(configuration._settings->fileName()) == QFileInfo(file), "SafeConfiguration did not set QSettings with correct file name."); QVERIFY2(configuration._settings->format() == QSettings::IniFormat, "SafeConfiguration did not set QSettings with correct format."); QVERIFY2(configuration._settings->group() == "", "SafeConfiguration did not set QSettings with correct group."); } QTEST_GUILESS_MAIN(TestSafeDartSafeConfiguration) #include "tst_testsafedartsafeconfiguration.moc"
771093efbd43615f0bc15698b24e9f005fe6ba6d
6b6898f071e049962b762fb672b27aecbee62075
/src/parse.cc
6651777820b2141bb068318f7185769533fc642a
[]
no_license
jsternberg/neat-backup
970f010f8f6fde2e8b7d00f52b854dc9f54d1a7c
7a7ad5c864dd4283d1630cf666c3186689798c6f
refs/heads/master
2023-06-01T03:40:52.031887
2013-01-19T18:44:04
2013-01-19T18:44:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,368
cc
parse.cc
#include "ast.h" #include "lexer.h" #include "parse.h" #include "scope.h" #include "util.h" #include <memory> #include <string> #include <vector> using namespace std; void Messages::Error(const string& msg) { msgs_.push_back(Message(msg, Message::ERROR)); } void Messages::Warning(const string& msg) { msgs_.push_back(Message(msg, Message::WARNING)); } void Messages::Info(const string& msg) { msgs_.push_back(Message(msg, Message::INFO)); } size_t Messages::Count(Message::Level level) const { size_t count = 0; for (auto& msg : msgs_) { if (msg.level() <= level) ++count; } return count; } namespace { /** Get precedence value of an operator token. A higher number has a higher precedence and will be grouped together first. If a number has the same precedence value, then the grouping may be from left-to-right or right-to-left. If the number returned is even, then the grouping is left-to-right. If the number returned is odd, then the grouping is right-to-left. */ int GetTokPrecedence(const Lexer::Token& token) { if (token.type_ != Lexer::Token::OPER) return -1; char ch1 = token.val_[0]; char ch2 = token.val_.size() > 1 ? token.val_[1] : 0; switch (ch1) { case '+': switch (ch2) { case 0: return 20; case '=': return 5; default: return -1; } case '-': switch (ch2) { case 0: return 20; case '=': return 5; default: return -1; } case '*': switch (ch2) { case 0: return 40; case '=': return 5; default: return -1; } case '/': switch (ch2) { case 0: return 40; case '=': return 5; default: return -1; } case '=': switch (ch2) { case 0: return 5; case '=': return 10; default: return -1; } default: return -1; } } struct FileParser { FileParser(llvm::LLVMContext& ctx, Messages& errs, const string& filename, const string& contents) : ctx_(ctx), filename_(filename), lexer_(contents), errs_(errs) {} unique_ptr<ast::TopLevel> Parse(); unique_ptr<ast::TopLevel> TopLevel(); unique_ptr<ast::TopLevel> Function(); unique_ptr<ast::Statement> Statement(); unique_ptr<ast::Statement> Var(); unique_ptr<ast::Statement> If(); unique_ptr<ast::Statement> While(); unique_ptr<ast::Statement> Return(); unique_ptr<ast::Statement> Break(); unique_ptr<ast::Statement> Continue(); unique_ptr<ast::Expression> Primary(); unique_ptr<ast::Expression> PrimaryRHS(unique_ptr<ast::Expression> LHS); unique_ptr<ast::Expression> Expression(); unique_ptr<ast::Expression> BinOpRHS(int prec, unique_ptr<ast::Expression> LHS); bool ExpectToken(Lexer::Token::Type type, llvm::StringRef val); bool ExpectToken(Lexer::Token::Type type); void Error(const string& msg); llvm::Type *TranslateType(llvm::StringRef type) { using llvm::Type; if (type == "void") return Type::getVoidTy(ctx_); else if (type == "int") return Type::getInt32Ty(ctx_); else if (type == "float") return Type::getFloatTy(ctx_); else if (type == "double") return Type::getDoubleTy(ctx_); else return NULL; } llvm::LLVMContext& ctx_; string filename_; Lexer lexer_; Messages& errs_; }; unique_ptr<ast::TopLevel> FileParser::Parse() { lexer_.ReadToken(); auto program = unique_ptr<ast::Program>(new ast::Program()); unique_ptr<ast::TopLevel> stmt = NULL; while ((stmt = TopLevel()) != NULL) { program->Append(move(stmt)); } return lexer_.ExpectToken(Lexer::Token::TEOF) ? move(program) : NULL; } unique_ptr<ast::TopLevel> FileParser::TopLevel() { unique_ptr<ast::TopLevel> stmt = Function(); if (stmt) return stmt; return NULL; } unique_ptr<ast::TopLevel> FileParser::Function() { if (!lexer_.ExpectToken(Lexer::Token::FN)) return NULL; Lexer::Token t = lexer_.PeekToken(); auto f = unique_ptr<ast::Function>(new ast::Function(t.val_)); lexer_.ReadToken(); if (lexer_.ExpectToken(Lexer::Token::PAREN, "(")) { bool need_comma = false; for (;;) { if (need_comma) { if (!lexer_.ExpectToken(Lexer::Token::OPER, ",")) break; } t = lexer_.PeekToken(); if (t.type_ != Lexer::Token::IDENT) break; lexer_.ReadToken(); llvm::StringRef name; if (lexer_.ExpectToken(Lexer::Token::COLON)) { name = t.val_; t = lexer_.PeekToken(); if (t.type_ != Lexer::Token::IDENT) return NULL; lexer_.ReadToken(); } llvm::Type *type = TranslateType(t.val_); if (!type) return NULL; f->name_args_.push_back(name); f->type_args_.push_back(type); need_comma = true; } if (!ExpectToken(Lexer::Token::PAREN, ")")) return NULL; } if (lexer_.ExpectToken(Lexer::Token::ARROW)) { t = lexer_.PeekToken(); f->rettype_ = TranslateType(t.val_); if (!f->rettype_) return NULL; lexer_.ReadToken(); } if (!lexer_.ExpectToken(Lexer::Token::BRACKET, "{")) return NULL; unique_ptr<ast::Statement> stmt = NULL; while ((stmt = Statement()) != NULL) { f->Append(move(stmt)); } if (!ExpectToken(Lexer::Token::BRACKET, "}")) return NULL; return move(f); } unique_ptr<ast::Statement> FileParser::Statement() { unique_ptr<ast::Statement> stmt = NULL; for (;;) { stmt = If(); if (stmt) return stmt; stmt = While(); if (stmt) return stmt; stmt = Var(); if (stmt) break; stmt = Return(); if (stmt) break; stmt = Break(); if (stmt) break; stmt = Continue(); if (stmt) break; { auto expr = Expression(); if (expr) { stmt = unique_ptr<ast::Statement>(new ast::ExpressionStatement(move(expr))); break; } } return NULL; } if (!ExpectToken(Lexer::Token::SEMICOLON)) return NULL; return stmt; } unique_ptr<ast::Statement> FileParser::Var() { if (!lexer_.ExpectToken(Lexer::Token::VAR)) return NULL; Lexer::Token ident = lexer_.PeekToken(); if (ident.type_ != Lexer::Token::IDENT) return NULL; lexer_.ReadToken(); if (!ExpectToken(Lexer::Token::OPER, "=")) return NULL; auto expr = Expression(); if (!expr) return NULL; return unique_ptr<ast::Statement>(new ast::VariableAssignment(ident.val_, move(expr))); } unique_ptr<ast::Statement> FileParser::If() { if (!lexer_.ExpectToken(Lexer::Token::IF)) return NULL; auto if_ = unique_ptr<ast::If>(new ast::If(Expression())); if (!ExpectToken(Lexer::Token::BRACKET, "{")) return NULL; unique_ptr<ast::Statement> stmt = NULL; while ((stmt = Statement()) != NULL) { if_->AppendThen(move(stmt)); } if (!ExpectToken(Lexer::Token::BRACKET, "}")) return NULL; if (lexer_.ExpectToken(Lexer::Token::ELSE)) { if (!ExpectToken(Lexer::Token::BRACKET, "{")) return NULL; while ((stmt = Statement()) != NULL) { if_->AppendElse(move(stmt)); } if (!ExpectToken(Lexer::Token::BRACKET, "}")) return NULL; } return move(if_); } unique_ptr<ast::Statement> FileParser::While() { if (!lexer_.ExpectToken(Lexer::Token::WHILE)) return NULL; auto while_ = unique_ptr<ast::While>(new ast::While(Expression())); if (!ExpectToken(Lexer::Token::BRACKET, "{")) return NULL; unique_ptr<ast::Statement> stmt = NULL; while ((stmt = Statement()) != NULL) { while_->Append(move(stmt)); } if (!ExpectToken(Lexer::Token::BRACKET, "}")) return NULL; return move(while_); } unique_ptr<ast::Statement> FileParser::Return() { if (!lexer_.ExpectToken(Lexer::Token::RETURN)) return NULL; return unique_ptr<ast::Statement>(new ast::Return(Expression())); } unique_ptr<ast::Statement> FileParser::Break() { if (!lexer_.ExpectToken(Lexer::Token::BREAK)) return nullptr; return unique_ptr<ast::Statement>(new ast::Break); } unique_ptr<ast::Statement> FileParser::Continue() { if (!lexer_.ExpectToken(Lexer::Token::CONTINUE)) return nullptr; return unique_ptr<ast::Statement>(new ast::Continue); } unique_ptr<ast::Expression> FileParser::Primary() { Lexer::Token t = lexer_.PeekToken(); switch (t.type_) { case Lexer::Token::OPER: lexer_.ReadToken(); return unique_ptr<ast::Expression>(new ast::UnaryOperation(t.val_, Primary())); case Lexer::Token::PAREN: { if (t.val_ != "(") return NULL; lexer_.ReadToken(); auto expr = Expression(); if (!expr || !ExpectToken(Lexer::Token::PAREN, ")")) return NULL; return expr; } case Lexer::Token::INT: lexer_.ReadToken(); return PrimaryRHS(unique_ptr<ast::Expression>(new ast::IntegerLiteral(atoi(t.val_.str().c_str())))); case Lexer::Token::IDENT: lexer_.ReadToken(); return PrimaryRHS(unique_ptr<ast::Expression>(new ast::Variable(t.val_))); default: return NULL; } } unique_ptr<ast::Expression> FileParser::PrimaryRHS(unique_ptr<ast::Expression> LHS) { for (;;) { Lexer::Token t = lexer_.PeekToken(); switch (t.type_) { case Lexer::Token::PAREN: { if (t.val_ == "(") { lexer_.ReadToken(); auto function = unique_ptr<ast::CallOperation>(new ast::CallOperation(move(LHS))); bool need_comma = false; for (;;) { if (lexer_.ExpectToken(Lexer::Token::PAREN, ")")) break; if (need_comma) { if (!ExpectToken(Lexer::Token::OPER, ",")) return NULL; } need_comma = true; function->args_.push_back(Expression()); } LHS = move(function); break; } return LHS; } default: return LHS; } } } unique_ptr<ast::Expression> FileParser::Expression() { auto LHS = Primary(); if (!LHS) return NULL; return BinOpRHS(0, move(LHS)); } unique_ptr<ast::Expression> FileParser::BinOpRHS(int prec, unique_ptr<ast::Expression> LHS) { for (;;) { Lexer::Token t = lexer_.PeekToken(); int tok_prec = GetTokPrecedence(t); if (tok_prec < prec) return LHS; llvm::StringRef binop = t.val_; lexer_.ReadToken(); auto RHS = Primary(); if (!RHS) return NULL; t = lexer_.PeekToken(); int next_prec = GetTokPrecedence(t); if (tok_prec < next_prec || (tok_prec == next_prec && tok_prec % 2)) { RHS = BinOpRHS(tok_prec, move(RHS)); if (!RHS) return NULL; } LHS = unique_ptr<ast::Expression>(new ast::BinaryOperation(binop, move(LHS), move(RHS))); } } bool FileParser::ExpectToken(Lexer::Token::Type type, llvm::StringRef val) { if (!lexer_.ExpectToken(type, val)) { Error("unexpected token"); return false; } return true; } bool FileParser::ExpectToken(Lexer::Token::Type type) { if (!lexer_.ExpectToken(type)) { Error("unexpected token"); return false; } return true; } void FileParser::Error(const string& msg) { char buf[4096]; Lexer::LineInfo info = lexer_.GetLineInfo(); snprintf(buf, 4096, "%s:%lu:%lu: error: %s", filename_.c_str(), info.line_, info.col_, msg.c_str()); errs_.Error(buf); } } unique_ptr<Messages> Parser::Parse(const string& contents, const string& name) { auto msgs = unique_ptr<Messages>(new Messages); FileParser parser(ctx_, *msgs, name, contents); auto ast = parser.Parse(); if (!ast) return msgs; auto scope = shared_ptr<Scope>(new Scope); ast->Codegen(module_, scope); return msgs; } unique_ptr<Messages> Parser::ParseFile(const string& path) { string contents = ReadFile(path); return Parse(contents, path); }
a2580c3fb087a039eed6123af3a11aa0e54aaeb6
8a35e9a3fed8208ced7160fa8e7feb6658369e96
/PetitMoteur3D/header/PM3D/BlocRollerDynamic.h
642aa654a61890a6fe1febac36dc853f44affc3e
[]
no_license
mmartindev/PM3D
df5598be59a6e8c2927d958de3d3f2090c8482d4
13aa5b0937d8508e9761e95fd67f750e977788fd
refs/heads/master
2023-09-05T13:55:55.923764
2021-11-17T21:33:48
2021-11-17T21:33:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,629
h
BlocRollerDynamic.h
#pragma once #include "Objet3DDynamic.h" #include <DirectXMath.h> #include <d3d11.h> #include "tools.h" #include "chargeur.h" #include "PxPhysicsAPI.h" using namespace DirectX; namespace PM3D { class CDispositifD3D11; class BlocRollerDynamic : public Objet3DDynamic { public: BlocRollerDynamic(Scene* _scene, physx::PxTransform _position, const float _radius, CDispositifD3D11* _pDispositif, const std::vector<IChargeur*> chargeurs); // Destructeur virtual ~BlocRollerDynamic(); virtual void Anime(float tempsEcoule) override; physx::PxRigidActor* getBody() { return body_; } float getVitesseMax() { return vitesseMax_; } void setVitesseMax(float _vitesse) { vitesseMax_ = _vitesse; } int getNbBonus() { return nbBonus_; } void addBonus() { if (nbBonus_ < 5) { nbBonus_++; } } void suppBonus() { if (nbBonus_ > 0) { nbBonus_--; } } void resetBonus() { nbBonus_=0; } float getVitesseBonusMax() { return vitesseBonusMax_; } bool isContact() { return contact_; } bool isTrigger() { return trigger_; } void updateContact(bool _contact) { contact_ = _contact; } void updateTrigger(bool _trigger) { trigger_ = _trigger; } private: static physx::PxRigidDynamic* createRigidBody(Scene* _scene, physx::PxTransform _position, const float _radius); float radius_; float vitesseMax_; float vitesseMin_; static const float vitesseMaxDefault_; static const float vitesseMinDefault_; static const float vitesseBonusMax_; int nbBonus_{}; bool contact_ = false; bool trigger_ = false; float totalTempsEcoule{}; }; } // namespace PM3D
a6d8db6718cf42d834634dd226ca29dc60bee85d
0c082ffb855abb05be2674b3e152cae669800548
/C++/Book-C++程序设计 课程代码4737/Chapter02/Example_02_10/Example_02_10.cpp
7b5371164dd824406a7b2a5090a8a7dd3a94562e
[]
no_license
JosephWong1993/Taught-MySelf
ea85a8bc497551ca8b19c32f8313c74c9a20a2e7
471d98c474e326b341cd3f2dc3e4654b2158e50f
refs/heads/master
2023-03-30T03:04:08.925802
2021-04-08T12:34:48
2021-04-08T12:34:48
293,128,932
2
1
null
2020-12-07T16:05:20
2020-09-05T18:04:31
C#
GB18030
C++
false
false
400
cpp
Example_02_10.cpp
/* 演示使用complex和string对象及初始化的例子 */ #include<iostream> #include<complex> #include<string> using namespace std; void main() { complex<int> num1(2, 3); complex<float> num2(3.5, 4.5); string str1("real is "); string str2 = "image is "; cout << str1 << num1.real() << ',' << str2 << num1.imag() << endl; cout << str1 << num2.real() << ',' << str2 << num2.imag() << endl; }
b0b7ff3caf37bd9627c94e43bcad58207243d5a6
f896cda82989fe9940828a6f07b07d3dd9499f04
/empresa.h
ef2600a00aceb1bdc3b15495c46db9899a38b80b
[]
no_license
marianafcosta/FEUP-AEDA
cf99bfbcf2a4c3850d4082f92897f2192b8f2c0b
76d930edcf68c264aead0c01b5271402bf36b5c5
refs/heads/master
2021-09-03T05:15:08.875069
2018-01-05T22:29:23
2018-01-05T22:29:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,174
h
empresa.h
#ifndef EMPRESA_H_ #define EMPRESA_H_ #include <vector> #include <string> #include <fstream> #include <sstream> #include <algorithm> #include <unordered_set> #include "cliente.h" #include "fornecedor.h" #include "reservas.h" #include "oferta.h" #include "BST.h" using namespace std; struct clientesInativosHash { int operator() (const clientesInativos& cl) const { return cl.getNome().at(0) * 23; // Random Hash function. Better than returning 0, am i right? :D } bool operator() (const clientesInativos& cl1, const clientesInativos& cl2) const { return (cl1.getNIF() == cl2.getNIF()); } }; typedef priority_queue<Oferta> HEAP_OFT; typedef unordered_set<clientesInativos, clientesInativosHash, clientesInativosHash> HashTabclientesInativos; class Empresa { private: vector<Fornecedor> fornecedores; vector<Cliente*> clientes; Data data_atual; HashTabclientesInativos ClientesInativos; //priority_queue<Oferta> cruzeiros_populares; HEAP_OFT cruzeiros_populares; BST<Reserva> reservas; string fichFornecedores; string fichOfertas; string fichClientes; string fichClientesReg; string fichReservas; string nome; public: /** * @brief Construtor de uma empresa * @param fichFornecedores ficheiro com os clientes * @param fichOferta ficheiro com as ofertas * @param fichClientes ficheiro com os clientes * @param fichClientesReg ficheiro com os clientes registados * @param data atual */ Empresa(string fichFornecedores, string fichOfertas, string fichClientes, string fichClientesReg, string fichReservas, Data data_Atual); // alterei /** * @brief Construtor de uma empresa * @param nome * @param fornecedores * @param clientes */ Empresa(string nome, vector<Fornecedor> fornecedores, vector<Cliente*> clientes); /** * @brief Adiciona um fornecedor * @param fornecedor */ void addFornecedor(Fornecedor fornecedorNew); HEAP_OFT getCruzeiros() const; /** * @brief Adiciona um cliente * @param cliente */ void addCliente(Cliente * clienteNew); /** * @brief Adiciona uma oferta a um fornecedor * @param NIF */ void addOfertas(unsigned int NIF); void removeFornecedor(unsigned long fornecedorRemoveNIF); void removeCliente(unsigned long clienteRemoveNIF); void removerOferta(Oferta o1); bool compareData(Data data_cliente); // alterei Cliente * getCliente() const; /** * @brief Devolve um vetor com fornecedores */ vector<Fornecedor> getFornecedores() const; /** * @brief Devolve o nome da empresa */ string getNome () const; void setData_atual(int dia, int mes);// acrescentei /** * @brief Carrega os fornecedores a partir de um ficheiro * @param fichFornecedor ficheiro a utilizar */ void carregaFornecedores(string fichFornecedor); //extrai o conteudo do ficheiro de fornecedores /** * @brief Carrega as ofertas a partir de um ficheiro * @param ficheiro_oferta ficheiro a utilizar */ void carregaOferta( string ficheiro_oferta);//extrai o conteudo do ficheiro de ofertas /** * @brief Carrega os clientes a partir de um ficheiro * @param fichClientes ficheiro a utilizar */ void carregaClientes(string fichClientes); /** * @brief Carrega os clientes registados a partir de um ficheiro * @param fichClientes ficheiro a utilizar */ void carregaClientesReg(string fichClientesR); void carregaReservas(string ficheiro_reservas); /** * @brief Imprime as ofertas de um fornecedor * @param NIF do fornecedor */ void visualizaOfertas(unsigned long NIF); /** * @brief Guarda os fornecedores num ficheiro * @param fichFornecedor ficheiro a utilizar */ void guardaFornecedores(string fichFornecedores); //guarda o que esta no vetor no ficheiro de texto /** * @brief Guarda as ofertas num ficheiro * @param fichOfertas ficheiro a utilizar */ void guardaOfertas(string fichOfertas); // "" /** * @brief Guarda os clientes num ficheiro * @param fichClientesR ficheiro a utilizar * @param fichClientes ficheiro a utilizar */ void guardaClientes(string fichClientesR, string fichClientes); /** * @brief Imprime os lucros dos fornecedores */ void printLucrosTotais() const; /** * @brief Imprime os clientes */ void printClientes() const; /** * @brief Imprime os fornecedores */ void printFornecedores() const; /** * @brief Verifica se o fornecedor existe ou nao * @param NIF do fornecedor * @return true se existir, false caso contrario */ bool checkFornecedorNIFBool(unsigned long NIF); /** * @brief Remove reserva de um determinado cliente * @param clienteNif NIF do cliente * @param reserva numero da reserva a cancelar */ void removeReserva(unsigned long clienteNIF, unsigned int reserva); /** * @brief Imprime ofertas com um determinado destino * @param destino */ bool printOfertasByDestino(string destino) const; /** * @brief Imprime ofertas com uma determinada data * @param data */ bool printOfertasByData(Data data) const; /** * @brief Imprime todas as ofertas disponiveis */ void printOfertas() const; /** * @brief Verifica se o cliente existe ou nao e atribui o apontador correspondente a c1 * @param NIF do cliente * @return true se existir, false caso contrario */ bool checkClienteNIF(unsigned long NIF, Cliente **c1); /** * @brief Verifica se o cliente existe ou nao e atribui o apontador correspondente a f1 * @param NIF do fornecedor * @return true se existir, false caso contrario */ bool checkFornecedorNIF(unsigned long NIF, Fornecedor **f1); //verifica se existe o fornecedor com o NIF especificado e atribui o apontador correspondente a f1 /** * @brief Verifica se o cliente existe ou nao, atira uma excecao caso exista * @param NIF do fornecedor */ void checkFornecedorNIF(unsigned long NIF); // so verifica se o fornecedor em questao existe, atira uma excecao se for esse o caso void showPontosCliente(Cliente *c1); /** * @brief Atribui uma oferta a um cliente * @param fornecedorNif * @param clienteNif * @param numeroOferta */ void atribuiReserva(unsigned long fornecedorNif, unsigned long clienteNIF, int numeroOferta, Data dataReserva); /** * @brief Remove um fornecedor * @param NIF do fornecedor */ void removerFornecedor(unsigned long NIF); /** * @brief Imprime as reservas de um cliente * @param NIF do cliente */ void printReservasByCliente(unsigned long NIF) const; //BST e reservas // void inicializaBST(); //depois de as reservas serem carregadas, esta funcao e chamada void printFaturas(); //percorre a bst e imprime as "faturas" uma a uma bool is_reservas_empty(); void guardaReservas(string fichReservas); int procurar_reservas_nif_cliente(unsigned long nif); int procurar_reservas_nif_fornecedor(unsigned long nif); //priority queue int Descontos(); void inicializa_queue(); void atualiza_queue(int nif); // hash void changeClienteMorada(int nif_cli, string newMorada); void PrintClientesInativos(); void colocaClientesInativos(); }; ///////////////////////// /////// EXCECOES //////// ///////////////////////// class ClienteExistente { public: unsigned int NIF; ClienteExistente(unsigned int NIF) {this->NIF=NIF;} unsigned int getNIF() const {return NIF;} }; class FornecedorExistente { public: unsigned int NIF; FornecedorExistente(unsigned int NIF) {this->NIF=NIF;} unsigned int getNIF() const {return NIF;} }; class ClienteInexistente { public: unsigned int NIF; ClienteInexistente(unsigned int NIF) {this->NIF=NIF;} unsigned int getNIF() const {return NIF;} }; class FornecedorInexistente { public: unsigned int NIF; FornecedorInexistente(unsigned int NIF) {this->NIF=NIF;} unsigned int getNIF() const {return NIF;} }; class CruzeiroCheio { public: CruzeiroCheio() {}; }; class ReservaJaFeita { public: ReservaJaFeita() {}; }; class NotANumber { public: NotANumber() {} }; class IndexOutOfBounds { public: IndexOutOfBounds() {} }; #endif /* EMPRESA_H_ */
1799008f7ec19d5d2a5df068b7375346e8fc6137
f19bed7ec0c77861d7891a9ce11fbb29bcb0afaa
/sth_useful/prime.cpp
d17cba721a0aab7ea86b7235dd7f2bbdf86c2c44
[]
no_license
guozhen-dev/NOIP
e896ec2635e819fff71a3cce905409b0afca2a24
6b668f387fb856e3063e94053b8eedcde0d2537d
refs/heads/master
2021-09-27T20:23:15.800095
2018-11-11T14:45:22
2018-11-11T14:45:22
137,905,173
1
0
null
null
null
null
UTF-8
C++
false
false
490
cpp
prime.cpp
#include<bits/stdc++.h> using namespace std; int prime[10000007]; int M , N; int x ; int main(){ scanf("%d%d",&N,&M); for(register int i = 0 ;i <= N ; i++ ){ prime[i]=1; } prime[0] = prime[1] = 0; for(register int i = 2 ; i < N+5 ; i++){ if(!prime[i]) continue; for(register int j = 2 ; j*i <= N ; j++){ prime[i*j] = 0; } } for (register int i = 0 ; i < M ; i++){ scanf("%d",&x); if ( prime[x] ) puts("Yes"); else puts("No"); } return 0; }
8605d27d375dd21654a793a0ea891b0fbf822c46
ae37c91b4b79578dbe1e132d67183876ec7f8371
/TestCase/Client/Client.cpp
5c2e5d7d5261d16829007f89f00a1bffc20bf72c
[]
no_license
shuguohui/DistributedTask
06bbf7270281c7c0062d04ad31e96133104b5820
5e828c8ab34e39143cba0009a4a44077cf9969cd
refs/heads/master
2021-01-10T03:16:30.541548
2015-10-21T11:30:05
2015-10-21T11:30:05
44,220,146
1
0
null
null
null
null
GB18030
C++
false
false
3,104
cpp
Client.cpp
#include <SDKDDKVer.h> #include <stdio.h> #include <tchar.h> #include <Core/IDisposable.h> #include <Core/Ptr.h> #include <Core/Task.h> #include <Core/ConnectionInfo.h> #include <Task/Manager.h> #include <Task/Client.h> #include "Task/Worker.h" #include <iostream> #include <vector> using namespace DT; int main() { Ptr<ConnectionInfo> ptrConnInfo = ConnectionInfo::Create(); ptrConnInfo->SetType(ConnectionInfo::MYSQL); ptrConnInfo->SetServer(L"localhost"); ptrConnInfo->SetPortNumber(3306); ptrConnInfo->SetUser(L"root"); ptrConnInfo->SetPassword(L"666666"); ptrConnInfo->SetDatabase(L"TASK"); ptrConnInfo->SetTimeout(60); /*{ std::vector<std::wstring> keys; Ptr<Worker> ptrWorker = Worker::Create(ptrConnInfo); Ptr<IDataCursor> ptrCursor = ptrWorker->ReadDataCursor(L"天安门",keys); if(NULL == ptrCursor) return 0; while(ptrCursor->Next()) { std::wstring key; const void* pBuffer = NULL; unsigned int nBufferLen = 0; ptrCursor->GetKeyValue(&key,&pBuffer,&nBufferLen); keys.push_back(key); } ptrCursor = NULL; }*/ Ptr<Manager> ptrManager = Manager::Create(ptrConnInfo); ptrManager->DropRepository(); ptrManager->CreateRepository(); ptrManager = NULL; Ptr<Client> ptrClient = Client::Create(ptrConnInfo); if(NULL == ptrClient) { std::cout << "open failed!" << std::endl; return 0; } std::vector<std::wstring> ns = ptrClient->GetNameSpaces(); bool bHasNS = false; std::wstring strNS = L"天安门"; std::wstring strFunc = L"test"; bool b; for (std::vector<std::wstring>::const_iterator citer = ns.begin(); citer != ns.end(); ++citer) { if(_wcsicmp(citer->c_str(),strNS.c_str()) == 0) { bHasNS = true; break; } } if(!bHasNS) { b = ptrClient->CreateNameSpace(strNS); if(!b) { std::cout << "CreateNameSpace failed!" << std::endl; return 0; } } //创建任务 std::vector<Ptr<Task> > tasks; wchar_t sz[1024]; for (int i = 0;i < 10000;i++) { swprintf(sz,L"TASK_%d",i); Ptr<Task> task = Task::Create(); task->SetFunctionName(strFunc); task->SetData((unsigned char*)sz,wcslen(sz) * sizeof(wchar_t)); if((i % 100) == 0) task->SetTaskLevel(2); else if((i % 76) == 0) task->SetTaskLevel(1); tasks.push_back(task); } ptrClient->CreateTasks(tasks,strNS); //开始检查任务完成情况 std::vector<std::wstring> keys; while(true) { int nFinished; int nTotal; ptrClient->GetTaskStatus(strFunc,strNS,nFinished,nTotal); std::cout << "Task Status: " << nFinished << " / " << nTotal << std::endl; if(keys.size() < 1000) { Ptr<Worker> ptrWorker = Worker::Create(ptrClient->GetConnectionInfo()->Clone()); keys.clear(); Ptr<IDataCursor> ptrCursor = ptrWorker->ReadDataCursor(strNS,keys); if(NULL == ptrCursor) return 0; while(ptrCursor->Next()) { std::wstring key; const void* pBuffer = NULL; unsigned int nBufferLen = 0; ptrCursor->GetKeyValue(&key,&pBuffer,&nBufferLen); keys.push_back(key); } ptrCursor = NULL; } std::cout << "key count " << keys.size() << std::endl; Sleep(5000); } return 0; }
ead6598d6a4232f91a4debdb7f897c69957396fd
a4c42b0917816cb11659d3481d6ca25ac0408ae3
/프로그래밍 실습/report2(20171119까지)/러시아워1/main.cpp
c3750139bbd2f7f24da066a11f88ac6bf6da642b
[]
no_license
RohJaeHak/C-Language
50f6a3b96dad42998a88afd5f1574bd126dc66ff
5db88b9c221b26396e8a782eb961010268760fb8
refs/heads/master
2021-04-26T23:02:09.560781
2018-03-06T04:09:33
2018-03-06T04:09:33
123,918,223
0
0
null
null
null
null
UHC
C++
false
false
2,688
cpp
main.cpp
#include<stdio.h> #define deep 100 char ans[100][deep][3]={}; int ansCnt=0; char RMapGet[20][6]; char Map[6][6]; int ImporCar; int ScanMap() { char ExNum[10]={}; printf("문제를 골라 주세요(1~10) >> ");scanf("%s",ExNum); sprintf(ExNum,"%s%s",ExNum,".txt"); //파일 이름 합치기 //printf("%s",ExNum); FILE* f; //파일 열기 f = fopen(ExNum,"rt"); if(f == NULL){ printf("실패\n"); return 0; } int line=0; while(true){ fgets(RMapGet[line],255,f); if(feof(f) != 0){ // 파일을 끝까지 읽었는지 체크합니다. break; } line++; //printf("%d--\n",line); } fclose(f); return line; } void MakeMap(int line){ int flag = 0; for(int i=0;i<line;i++){ if(RMapGet[i][3] == 'V'){ for(int j=0;j<2+flag;j++){ Map[RMapGet[i][2]-'0'+j][RMapGet[i][1]-'0'] = RMapGet[i][0]; } } else if(RMapGet[i][3] == 'H'){ for(int j=0;j<2+flag;j++){ Map[RMapGet[i][2]-'0' ][RMapGet[i][1]-'0'+j] = RMapGet[i][0]; } } if(RMapGet[i][0] == 'X') { flag =1; ImporCar = i; } } } void ShowMap(){ for(int i=0;i<6;i++,printf("\n")){ for(int j=0;j<6;j++,printf(" ")){ if(Map[i][j] == NULL){ printf("."); } else{ printf("%c",Map[i][j]); } } } } void ShowLoad(){ } void solve(int cnt,int line) { if(cnt>=deep){ return; } else if(RMapGet[ImporCar][1]==4){ ShowLoad(); ansCnt++; return; } int flag=0; for(int i=0;j<line;j++){ for(int j=-5;j!=0 && j<=5;j++){ if(RMapGet[i][3] == 'V'){ if(0<=RMapGet[i][2]-'0'+j && RMapGet[i][2]-'0'+j+2+flag<6) { ans[ansCnt][cnt][0]=RMapGet[i][0]; if(j>0){ ans[ansCnt][cnt][1]=j+'0'-1; } else if(j<0){ ans[ansCnt][cnt][1]=j+10+'0'; } } } else if(RMapGet[i][3] == 'H'){ if(0<=RMapGet[i][1]-'0'+j && RMapGet[i][1]-'0'+j+2+flag<6) { ans[ansCnt][cnt][0]=RMapGet[i][0]; if(j>0){ ans[ansCnt][cnt][1]=j+'0'-1; } else if(j<0){ ans[ansCnt][cnt][1]=j+10+'0'; } } } if(RMapGet[i][0] == 'X'){ flag = 1; } } } } int main(){ int line = ScanMap(); if(line !=0){ printf("%s\n",RMapGet[4]); MakeMap(line); } ShowMap(); }
1405173359b62fb32866980c1ac30b3fa7baf49e
55c9f597b86065d649931c3e9c91e1f2aebfb711
/salaries_test.cpp
ce336312c14be83686021237c4064167b10e2fa3
[]
no_license
thejasonhsu/Exercises
5071985ea703ba98f6e314d583399f07f9eb2ab8
ae70833eca4af53808056cf30422f4edb1b1643f
refs/heads/master
2020-05-24T15:48:36.453096
2018-10-16T06:12:36
2018-10-16T06:12:36
33,386,071
0
0
null
null
null
null
UTF-8
C++
false
false
3,289
cpp
salaries_test.cpp
// Company Salaries // Jason Hsu #include <iostream> #include <sstream> #include <string> #include <cstring> #include <cstdlib> #include <stdlib.h> #include <fstream> //read file as input using namespace std; bool readFile(int &count); void highsalary(int count); double totalsalary(int count); struct employee { string firstname; string lastname; int salary; }; employee *allemployee = NULL; int main() { bool isGoodData = false; cout << "Welcome to the employee program." << endl; int count=0; while (!isGoodData) isGoodData = readFile(count); cout << "(1) Find employee with highest salary" << endl; cout << "(2) Find employee with lowest salary" << endl; cout << "(3) Calculate average salary" << endl; cout << "(4) Calculate total salary" << endl; cout << "(5) Exit" << endl; int ans; highsalary(count); double tsalary = totalsalary(count); cout << "Enter a choice: "; cin >> ans; while (ans != 5) { switch (ans) { case 1: cout << allemployee[count - 1].firstname << " " << allemployee[count - 1].lastname << " has the highest salary of " << allemployee[count - 1].salary << "." << endl; break; case 2: cout << allemployee[0].firstname << " " << allemployee[0].lastname << " has the lowest salary of " << allemployee[0].salary << "." << endl; break; case 3: cout << "The average salary is " << tsalary / count << "." << endl; break; case 4: cout << "The total salary is " << tsalary << "." << endl; break; } cout << "Enter a choice: "; cin >> ans; } if (ans == 5 ) { cout << "Thank you for using the employee program." << endl; return 0; } } //readFile function; re-prompts user to input if input is invalid bool readFile(int &count) { char filename[100]; ifstream fin; cout << "Enter the input file: "; cin >> filename; //no longer limits the input to be input.txt only fin.open(filename); if (fin.fail()) { cout << "Failed to open file. " << endl; return false; } char buf[100]; string input; getline(fin, input); while (input != "" && !fin.fail()) { getline(fin, input); count++; } if (allemployee != NULL) //check if bad input is in memory delete[] allemployee; allemployee = new employee[count]; fin.close(); fin.open(filename); int i=0; while (!fin.fail()) { if (!(fin >> allemployee[i].firstname >> allemployee[i].lastname >> allemployee[i].salary)) { cout << "ERROR -- BAD DATA" << endl; return false; } fin.ignore(100, '\n'); i++; } return true; } void highsalary(int count) //bubblesort the salaries { for (int i = 0; i < count; i++) { for (int j = 0; j < count - 1; j++) { if (allemployee[j].salary > allemployee[j + 1].salary) { int temp = allemployee[j].salary; allemployee[j].salary = allemployee[j + 1].salary; allemployee[j + 1].salary = temp; string tempName = allemployee[j].firstname; allemployee[j].firstname = allemployee[j + 1].firstname; allemployee[j + 1].firstname = tempName; tempName = allemployee[j].lastname; allemployee[j].lastname = allemployee[j + 1].lastname; allemployee[j + 1].lastname = tempName; } } } } double totalsalary(int count) { double totalsalary=0; for (int i=0; i < count; i++) { totalsalary += allemployee[i].salary; } return totalsalary; }
20db04adbe4415cabc762f5673ac774530d64984
5c241cf0ccc8158b0c4ce0dcbf5db46bc2bb825e
/warning.h
95027f7da220989ffb34a6d82eaf319a0a31877f
[ "Apache-2.0", "GPL-1.0-or-later" ]
permissive
yanxx297/d-s-se-directed-tests
75dd2ab2be20db0ccedfa8b7e7980db44a89c453
7104647e90ad925bde18a2bd22afc33fa09d2135
refs/heads/master
2020-09-10T17:45:44.991701
2019-07-31T21:29:14
2019-07-31T21:29:14
221,784,713
0
0
Apache-2.0
2019-11-14T20:51:44
2019-11-14T20:51:44
null
UTF-8
C++
false
false
3,250
h
warning.h
#ifndef __WARNING_H__ #define __WARNING_H__ extern addr_t current_instruction; addr_t last_program_instruction(); void __enter_function(addr_t caller, const std::string); void __exit_function(); void __warning(addr_t, addr_t); #define WARNING(msg, ...) { \ if (current_instruction != 0) { \ fprintf(DEBUG_FILE, "%s ### %.8x ### %.8x\n", msg, \ current_instruction, last_program_instruction()); \ if (strstr(msg, "Write out of bounds")) { \ __warning(current_instruction, last_program_instruction()); \ } \ } \ } #include "types.h" #include <iostream> #include <fstream> #include <map> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/set.hpp> #include <boost/serialization/map.hpp> class Warning { private: std::set<addr_t> slice; addr_t addr; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & slice; ar & addr; (void)version; } public: Warning() {}; Warning(addr_t a) { addr = a; } void addToSlice(addr_t b) { slice.insert(b); } addr_t getAddress() const { return addr; } typedef std::set<addr_t>::const_iterator slice_iterator; slice_iterator slice_begin() const { return slice.begin(); } slice_iterator slice_end() const { return slice.end(); } bool slice_find(addr_t b) const { return slice.find(b) != slice.end(); } size_t getSliceSize() const { return slice.size(); } }; struct warningcmp { bool operator()(const Warning *w1, const Warning *w2) const { return w1->getAddress() < w2->getAddress(); } }; typedef std::set<Warning *, warningcmp> warnings_t; #include <errno.h> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/filter/bzip2.hpp> inline void serialize(const char *f, const warnings_t &ww) { std::ofstream ofs(f, std::ios::out|std::ios::binary|std::ios::trunc); boost::iostreams::filtering_streambuf<boost::iostreams::output> out; out.push(boost::iostreams::bzip2_compressor()); out.push(ofs); boost::archive::binary_oarchive oa(out); oa << ww; } inline void unserialize(const char *f, warnings_t &ww) { try { std::ifstream ifs(f, std::ios::in|std::ios::binary); if (!ifs.is_open()) { fprintf(stderr, "Failed to open %s: %s\n", f, strerror(errno)); exit(1); } boost::iostreams::filtering_streambuf<boost::iostreams::input> in; in.push(boost::iostreams::bzip2_decompressor()); in.push(ifs); boost::archive::binary_iarchive ia(in); ia >> ww; } catch (boost::iostreams::bzip2_error) { std::ifstream ifs(f, std::ios::in|std::ios::binary); if (!ifs.is_open()) { fprintf(stderr, "Failed to open %s: %s\n", f, strerror(errno)); exit(1); } boost::archive::binary_iarchive ia(ifs); ia >> ww; } } #endif // Local Variables: // mode: c++ // c-basic-offset: 4 // compile-command: "dchroot -c typeinfer -d make" // End:
b6d62235850fc07e919b526106b63e66acc06d4a
5a5d9b63600efa72ad6fd49cbc2df7c284cf562c
/calculator.cpp
7078374c8b1f500dd0e30348e2859f06d3043968
[]
no_license
vpsiddhant/Compiler
8816d9a5ab4e4f2e9c9001c257f5a689adaf58e6
5b5a5bab5a952db14b4b867fd92b7989f0837abf
refs/heads/master
2021-01-21T12:30:45.204947
2017-09-03T16:35:08
2017-09-03T16:35:08
102,074,483
0
0
null
null
null
null
UTF-8
C++
false
false
1,199
cpp
calculator.cpp
#include<iostream> #include<string.h> #define EOF "EOF" #define INTEGER "INTEGER" #define PLUS "PLUS" //THIS IS MADE TO TO CHECK WHETHER THE CHARACTER IS A NUMBER OR NOT bool isNumber(char value) { int number; number = value; for( int i = 0; i < 10; i ++) { if ( number == 48 + i) { return true; } } return false; } class Token { public: std::string type; char value; void set_token(char); }; void Token::set_token(char value1) { value = value1; if( value == '+') { type = PLUS; } else if( isNumber(value) ) { type = INTEGER; } else if( value == '\0') { type = EOF; } else { std::cout << "Error in input"; return; } } class Interpretor { public: //int pos; std::string text; //Token token; Interpretor(std::string); }; Interpretor::Interpretor(std::string input) { std::string null; null = "\0"; input = input + null; Token * obj; obj = new Token [input.size()]; for(int i = 0; i < input.size(); i++ ) { obj[i].set_token(input[i]); } std::cout << obj[0].type; } int main() { std::string input; std::cout << "Enter a string\n"; std::cin >> input; Interpretor obj(input); return 0; }
3fadb30724cd97209f79f8d90da7bedabc15ae70
786de89be635eb21295070a6a3452f3a7fe6712c
/H5DataTypes/tags/V00-05-14/include/ControlDataConfigV2.h
e60bc819cb57cc0e6658019d672bad3bbe786f31
[]
no_license
connectthefuture/psdmrepo
85267cfe8d54564f99e17035efe931077c8f7a37
f32870a987a7493e7bf0f0a5c1712a5a030ef199
refs/heads/master
2021-01-13T03:26:35.494026
2015-09-03T22:22:11
2015-09-03T22:22:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,041
h
ControlDataConfigV2.h
#ifndef H5DATATYPES_CONTROLDATACONFIGV2_H #define H5DATATYPES_CONTROLDATACONFIGV2_H //-------------------------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Class ControlDataConfigV2. // //------------------------------------------------------------------------ //----------------- // C/C++ Headers -- //----------------- //---------------------- // Base Class Headers -- //---------------------- //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "H5DataTypes/XtcClockTime.h" #include "hdf5pp/Group.h" #include "pdsdata/psddl/control.ddl.h" //------------------------------------ // Collaborating Class Declarations -- //------------------------------------ // --------------------- // -- Class Interface -- // --------------------- namespace H5DataTypes { // // Helper type for Pds::ControlData::PVControl // class ControlDataPVLabelV1 { public: ControlDataPVLabelV1 () {} ControlDataPVLabelV1 ( const Pds::ControlData::PVLabel& pconfig ) ; static hdf5pp::Type stored_type() ; static hdf5pp::Type native_type() ; private: char name[Pds::ControlData::PVLabel::NameSize]; char value[Pds::ControlData::PVLabel::ValueSize]; }; // // Helper type for Pds::ControlData::ConfigV2 // class ControlDataConfigV2 { public: typedef Pds::ControlData::ConfigV2 XtcType ; ControlDataConfigV2 () {} ControlDataConfigV2 ( const XtcType& data ) ; static hdf5pp::Type stored_type() ; static hdf5pp::Type native_type() ; // store single config object at specified location static void store( const XtcType& config, hdf5pp::Group location ) ; static size_t xtcSize( const XtcType& xtc ) { return xtc._sizeof() ; } private: uint8_t uses_duration; uint8_t uses_events; XtcClockTime duration; uint32_t events; uint32_t npvControls; uint32_t npvMonitors; uint32_t npvLabels; }; } // namespace H5DataTypes #endif // H5DATATYPES_CONTROLDATACONFIGV2_H
02c800ca9b7987de8a15b62f46d4c0aa612bbcc2
31ac07ecd9225639bee0d08d00f037bd511e9552
/externals/OCCTLib/inc/GeomFill_SectionPlacement.hxx
eddca7c9089fed53f2e23ee6f50cb02fac740c6b
[]
no_license
litao1009/SimpleRoom
4520e0034e4f90b81b922657b27f201842e68e8e
287de738c10b86ff8f61b15e3b8afdfedbcb2211
refs/heads/master
2021-01-20T19:56:39.507899
2016-07-29T08:01:57
2016-07-29T08:01:57
64,462,604
1
0
null
null
null
null
UTF-8
C++
false
false
3,931
hxx
GeomFill_SectionPlacement.hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _GeomFill_SectionPlacement_HeaderFile #define _GeomFill_SectionPlacement_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_DefineAlloc_HeaderFile #include <Standard_DefineAlloc.hxx> #endif #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _Standard_Boolean_HeaderFile #include <Standard_Boolean.hxx> #endif #ifndef _gp_Ax1_HeaderFile #include <gp_Ax1.hxx> #endif #ifndef _Standard_Real_HeaderFile #include <Standard_Real.hxx> #endif #ifndef _Handle_GeomFill_LocationLaw_HeaderFile #include <Handle_GeomFill_LocationLaw.hxx> #endif #ifndef _GeomAdaptor_Curve_HeaderFile #include <GeomAdaptor_Curve.hxx> #endif #ifndef _Handle_Geom_Curve_HeaderFile #include <Handle_Geom_Curve.hxx> #endif #ifndef _Extrema_ExtPC_HeaderFile #include <Extrema_ExtPC.hxx> #endif #ifndef _gp_Pnt_HeaderFile #include <gp_Pnt.hxx> #endif #ifndef _Handle_Geom_Geometry_HeaderFile #include <Handle_Geom_Geometry.hxx> #endif #ifndef _Handle_Adaptor3d_HCurve_HeaderFile #include <Handle_Adaptor3d_HCurve.hxx> #endif class GeomFill_LocationLaw; class Geom_Curve; class StdFail_NotDone; class Geom_Geometry; class Adaptor3d_HCurve; class gp_Trsf; class gp_Mat; class gp_Vec; //! To place section in sweep Function <br> class GeomFill_SectionPlacement { public: DEFINE_STANDARD_ALLOC Standard_EXPORT GeomFill_SectionPlacement(const Handle(GeomFill_LocationLaw)& L,const Handle(Geom_Geometry)& Section); //! To change the section Law <br> Standard_EXPORT void SetLocation(const Handle(GeomFill_LocationLaw)& L) ; Standard_EXPORT void Perform(const Standard_Real Tol) ; Standard_EXPORT void Perform(const Handle(Adaptor3d_HCurve)& Path,const Standard_Real Tol) ; Standard_EXPORT void Perform(const Standard_Real ParamOnPath,const Standard_Real Tol) ; Standard_EXPORT Standard_Boolean IsDone() const; Standard_EXPORT Standard_Real ParameterOnPath() const; Standard_EXPORT Standard_Real ParameterOnSection() const; Standard_EXPORT Standard_Real Distance() const; Standard_EXPORT Standard_Real Angle() const; Standard_EXPORT gp_Trsf Transformation(const Standard_Boolean WithTranslation,const Standard_Boolean WithCorrection = Standard_False) const; //! Compute the Section, in the coordinate syteme given by <br> //! the Location Law. <br> //! If <WithTranslation> contact beetween <br> //! <Section> and <Path> is forced. <br> Standard_EXPORT Handle_Geom_Curve Section(const Standard_Boolean WithTranslation) const; //! Compute the Section, in the coordinate syteme given by <br> //! the Location Law. <br> //! To have the Normal to section equal to the Location <br> //! Law Normal. If <WithTranslation> contact beetween <br> //! <Section> and <Path> is forced. <br> Standard_EXPORT Handle_Geom_Curve ModifiedSection(const Standard_Boolean WithTranslation) const; protected: private: Standard_EXPORT void SectionAxis(const gp_Mat& M,gp_Vec& T,gp_Vec& N,gp_Vec& BN) const; Standard_EXPORT Standard_Boolean Choix(const Standard_Real Dist,const Standard_Real Angle) const; Standard_Boolean done; Standard_Boolean isplan; gp_Ax1 TheAxe; Standard_Real Gabarit; Handle_GeomFill_LocationLaw myLaw; GeomAdaptor_Curve myAdpSection; Handle_Geom_Curve mySection; Standard_Real SecParam; Standard_Real PathParam; Standard_Real Dist; Standard_Real AngleMax; Extrema_ExtPC myExt; Standard_Boolean myIsPoint; gp_Pnt myPoint; }; // other Inline functions and methods (like "C++: function call" methods) #endif
f05dc0605abab0c9636332820aaf0fad8f8dff5e
4c3b3961b7b68ca9f36d2616f26120694ed7f08a
/xuetangx/algorithm/week2/Recode-K-Queue.cpp
25f211efd0c944beb6df23e26f9c8be51c01dc92
[]
no_license
moyin1004/learning
a459d35871997183d0088a258ac4f3ea9984327a
29b4e3f28e1e7887fe66e417c5ace55b47ef43ea
refs/heads/master
2023-08-31T03:54:39.073635
2023-08-22T16:15:45
2023-08-22T16:15:45
169,972,332
6
1
null
null
null
null
UTF-8
C++
false
false
3,168
cpp
Recode-K-Queue.cpp
#include <cassert> #include <iostream> #include <bits/stdc++.h> #include <fstream> using namespace std; struct Node { long long count; vector<int> next; }; struct Data { int pos; int count; }; vector<Node> Tree; deque<int> Q[2]; bool cmp(Data &lhs, Data &rhs) { return lhs.count < rhs.count; } void increase(int root) { } void cul(Node &node, int index) { int pos = Q[index].front(); node.count += Tree[pos].count; node.next.push_back(pos); Q[index].pop_front(); } void findMin(int num) { if (num <= 1) return ; Node node = {0}; long long sum = 0; for (int i = 0; i < num; ++i) { // 取最小的num个 if (!Q[0].empty() && !Q[1].empty() && Tree[Q[0].front()].count >= Tree[Q[1].front()].count) { cul(node, 1); } else if (!Q[0].empty() && !Q[1].empty() && Tree[Q[0].front()].count < Tree[Q[1].front()].count){ cul(node, 0); } else if (!Q[0].empty() && Q[1].empty()) { cul(node, 0); } else if (Q[0].empty() && !Q[1].empty()) { cul(node, 1); } else { assert(0); } } Tree.push_back(node); Q[1].push_back(Tree.size() - 1); } void push(int pos, int index) { int num = Tree[pos].next.size(); for (int i = 0; i < num; ++i) { Q[index].push_back(Tree[pos].next[i]); } } void print(int root, int k) { long long sum = 0; int level = 1; Q[0].clear(); Q[1].clear(); push(root, 0); for (int i = 0; i < k; ++i) { Tree[root].next[i]; } int index = 0; // 层级交替 while (!Q[0].empty() || !Q[1].empty()) { int num = Q[index].size(); for (int i = 0; i < num; ++i) { int pos = Q[index].front(); Q[index].pop_front(); if (Tree[pos].next.empty()) { sum += level * Tree[pos].count; } else { push(pos, 1 - index); } } index = !index; ++level; } cout << sum << endl; } int main() { int n, k; //ifstream ifs("sample2.in"); //ifs >> n >> k; cin >> n >> k; vector<Data> vec; int max = 0, min = 0; for (int i = 0; i < n; ++i) { int temp = 0; //ifs >> temp; cin >> temp; Node node = {temp}; Tree.push_back(node); Data data = {i, temp}; vec.push_back(data); } sort(vec.begin(), vec.end(), cmp); for (auto it = vec.begin(); it != vec.end(); ++it) { Q[0].push_back(it->pos); } if (k >= n) { long long sum = 0; for (int i = 0; i < n; ++i) { sum += Tree[i].count; } cout << sum << endl; } int start = n % (k - 1); // 计算最深层结点数 if (start == 0) { findMin(k - 1); } else { findMin(start); } while (Q[0].size() + Q[1].size() > 1) { findMin(k); } int root = 0; if (!Q[0].empty()) { root = Q[0].front(); } if (!Q[1].empty()) { root = Q[1].front(); } print(root, k); return 0; }
cf2cc9ad5704f60b79e6e71218b150cace5e7bcd
2d1f82fe5c4818ef1da82d911d0ed81a0b41ec85
/codeforces/R565/CF1176F.cpp
527b0e067cc56fcc9472940bd4553502ac32b0af
[]
no_license
OrigenesZhang/-1s
d12bad12dee37d4bb168647d7b888e2e198e8e56
08a88e4bb84b67a44eead1b034a42f5338aad592
refs/heads/master
2020-12-31T00:43:17.972520
2020-12-23T14:56:38
2020-12-23T14:56:38
80,637,191
4
1
null
null
null
null
UTF-8
C++
false
false
2,646
cpp
CF1176F.cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++) #define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--) #define REP(i, n) FOR(i, 0, (n)-1) #define sqr(x) ((x) * (x)) #define all(x) (x).begin(), (x).end() #define reset(x, y) memset(x, y, sizeof(x)) #define uni(x) (x).erase(unique(all(x)), (x).end()); #define BUG(x) cerr << #x << " = " << (x) << endl #define pb push_back #define eb emplace_back #define mp make_pair #define _1 first #define _2 second #define chkmin(a, b) a = min(a, b) #define chkmax(a, b) a = max(a, b) const int maxn = 212345; bool vis[maxn][10]; ll dp[maxn][10]; int n; int main() { scanf("%d", &n); vis[0][0] = true; FOR(i, 1, n) { int k, c, d; priority_queue<int, vector<int>, greater<>> tab[4]; scanf("%d", &k); while (k--) { scanf("%d%d", &c, &d); tab[c].emplace(d); if (c == 1) { if (tab[1].size() > 3) tab[1].pop(); } else { if (tab[c].size() > 1) tab[c].pop(); } } // sel 0 REP(j, 10) if (vis[i - 1][j]) { dp[i][j] = dp[i - 1][j]; vis[i][j] = true; } vector<int> lis[4]; // sel 1 int now = -1; FOR(j, 1, 3) while (!tab[j].empty()) { lis[j].eb(tab[j].top()); chkmax(now, tab[j].top()); tab[j].pop(); } REP(j, 10) if (vis[i - 1][j]) { if (j != 9) { vis[i][j + 1] = true; chkmax(dp[i][j + 1], dp[i - 1][j] + now); } else { vis[i][0] = true; chkmax(dp[i][0], dp[i - 1][j] + 2 * now); } } // sel 2 vector<int> tmp; for (auto it : lis[1]) tmp.eb(it); for (auto it : lis[2]) tmp.eb(it); sort(all(tmp), greater<>()); if (tmp.size() >= 2) { REP(j, 8) if (vis[i - 1][j]) { vis[i][j + 2] = true; chkmax(dp[i][j + 2], dp[i - 1][j] + tmp[0] + tmp[1]); } FOR(j, 8, 9) if (vis[i - 1][j]) { vis[i][(j + 2) % 10] = true; chkmax(dp[i][(j + 2) % 10], dp[i - 1][j] + 2 * ll(tmp[0]) + tmp[1]); } } // sel 3 tmp.clear(); for (auto it : lis[1]) tmp.eb(it); sort(all(tmp), greater<>()); if (tmp.size() == 3) { REP(j, 7) if (vis[i - 1][j]) { vis[i][j + 3] = true; chkmax(dp[i][j + 3], dp[i - 1][j] + ll(tmp[0]) + tmp[1] + tmp[2]); } FOR(j, 7, 9) if (vis[i - 1][j]) { vis[i][(j + 3) % 10] = true; chkmax(dp[i][(j + 3) % 10], dp[i - 1][j] + 2 * ll(tmp[0]) + tmp[1] + tmp[2]); } } } ll ans = 0; REP(j, 10) if (vis[n][j]) chkmax(ans, dp[n][j]); printf("%lld", ans); }
cf5b6a72b431d4e361fd6b049c12b4343d431d8b
bcc3881198d01d2916aa18822ef481b87e5f81b1
/examples/test/server.cpp
f8272280f2f461762f8ffab0b420f5d2fd986087
[]
no_license
GodZza/accumulation-dev
70e7b6417abcc1704c342ebbd5f564bdcc2f49ee
fc8f37d9a36a6cb298cf7183d62c85d2d5a3eac1
refs/heads/master
2021-01-24T21:20:10.988181
2013-10-31T08:40:51
2013-10-31T08:40:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
515
cpp
server.cpp
#include <iostream> using namespace std; #include "thread.h" #include "wrap_server.h" class MyServer : public WrapServer { void onConnected(int) { cout << "enter" << endl; } void onDisconnected(int) { cout << "onDisconnected" << endl; } void onRecvdata(int index, const char* data, int len) { sendTo(index, data, len); } int check(const char* buffer, int len) { return len; } }; int main() { MyServer m; m.create("127.0.0.1", 4002, 1, 1024); while(true) { m.poll(1); } return 0; }
9bcc69128933e8f8908487867483318d56cf7fe9
fad392b7b1533103a0ddcc18e059fcd2e85c0fda
/install/px4_msgs/include/px4_msgs/msg/trajectory_waypoint__traits.hpp
9449e8c381482aad67e87397ed3fadc9b412dbab
[]
no_license
adamdai/px4_ros_com_ros2
bee6ef27559a3a157d10c250a45818a5c75f2eff
bcd7a1bd13c318d69994a64215f256b9ec7ae2bb
refs/heads/master
2023-07-24T18:09:24.817561
2021-08-23T21:47:18
2021-08-23T21:47:18
399,255,215
0
0
null
null
null
null
UTF-8
C++
false
false
116
hpp
trajectory_waypoint__traits.hpp
/home/navlab-tx2-4/px4_ros_com_ros2/build/px4_msgs/rosidl_generator_cpp/px4_msgs/msg/trajectory_waypoint__traits.hpp
554060011bf5f69c36d808b5a7e1e7d6be078bd2
987425005f1abd95a749394716559375818a695a
/中国石油大学OJ训练赛/3-p-08/C.cpp
e734f1e8c113a7e2a8ed78b874975c498d3d4d5e
[]
no_license
duny31030/My_road_of_ACM
b01db0334f33ce7f26a9fe83bd9e0646bba49a28
2de8c8f2d402dfc36f635174104a4923e03030b3
refs/heads/master
2020-03-10T04:32:24.505006
2019-01-03T07:31:27
2019-01-03T07:31:27
129,194,697
1
0
null
null
null
null
UTF-8
C++
false
false
2,119
cpp
C.cpp
/* * ========================================================================= * * Filename: C.cpp * * Link: * * Version: 1.0 * Created: 2018/08/03 12时09分26秒 * Revision: none * Compiler: g++ * * Author: 杜宁元 (https://duny31030.github.io/), duny31030@126.com * Organization: QLU_浪在ACM * * ========================================================================= */ #include <stdio.h> #include <iostream> #include <queue> #include <algorithm> #include <string.h> using namespace std; #define clr(a, x) memset(a, x, sizeof(a)) #define rep(i,a,n) for(int i=a;i<=n;i++) #define pre(i,a,n) for(int i=a;i>=n;i--) #define ll long long #define max3(a,b,c) fmax(a,fmax(b,c)) #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); const double eps = 1e-6; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const int MAXN = 1e6+10; struct node { int from,to,w; }e[MAXN]; int dis[MAXN],head[MAXN]; bool vis[MAXN]; int tot,k,a,b,c; void add(int u,int v,int w) { e[tot].to = v; e[tot].w = w; e[tot].from = head[u]; head[u] = tot++; } void spfa() { queue<int> q; vis[1] = 1; q.push(1); dis[1] = 0; while(!q.empty()) { int u = q.front(); q.pop(); vis[u] = 0; for(int i = head[u];i != -1;i = e[i].from) { int v = e[i].to; if(dis[v] > dis[u]+e[i].w) { dis[v] = dis[u]+e[i].w; if(!vis[v]) { vis[v] = 1; q.push(v); } } } } } int main() { ios #ifdef ONLINE_JUDGE #else freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); #endif tot = 1; clr(vis,0); clr(head,-1); fill(dis,dis+MAXN,INF); scanf("%d",&k); rep(i,0,k-1) { a = i; b = (i+1)%k; c = i*10%k; add(a,b,1); add(a,c,0); } spfa(); printf("%d\n",dis[0]+1); fclose(stdin); // fclose(stdout); return 0; }
e014a1c00fdf835244199cf59d52d44ee779b93f
89f65521a57fa636ef25051a490bff473e90db96
/Math/quatf.cpp
04852186d863c16ef1101db742b5448b3a870196
[]
no_license
astephens4/Iriss
b54c496483ec581344641d7f8f41755d61cdb3fa
c74325448092073832d197a2f89eb4c4e89ec168
refs/heads/master
2021-01-13T02:06:40.591212
2014-04-13T17:19:21
2014-04-13T17:19:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,514
cpp
quatf.cpp
#include "Math/quatf.hpp" #include "Utils/FloatEquals.hpp" #include "Utils/Angle.hpp" #include "Math/vec3.hpp" namespace Math { bool quatf::normOnWrite = false; quatf::quatf() : Tuple<float,4>() { this->m_data[0] = 0; this->m_data[1] = 0; this->m_data[2] = 0; this->m_data[3] = 1; } quatf::quatf(float x, float y, float z, float w) { // Change to compare with constants::EPS if(Utils::FloatEquals(x, 0.0f) && Utils::FloatEquals(y, 0.0f) && Utils::FloatEquals(z, 0.0f) && Utils::FloatEquals(w, 0.0f)) { throw std::logic_error("Degenerate quaternion of 0 + 0i + 0j + 0k is not allowed"); } this->m_data[0] = x; this->m_data[1] = y; this->m_data[2] = z; this->m_data[3] = w; if(this->normOnWrite) this->norm(); } quatf::quatf(const Utils::Angle& angle, vec3f axis) { axis.norm(); this->m_data[0] = axis.x()*std::sin(angle.asRadians()/2.0f); this->m_data[1] = axis.y()*std::sin(angle.asRadians()/2.0f); this->m_data[2] = axis.z()*std::sin(angle.asRadians()/2.0f); this->m_data[3] = std::cos(angle.asRadians()/2.0f); if(this->normOnWrite) this->norm(); } quatf::quatf(const Utils::Angle& angle1, vec3f axis1, const Utils::Angle& angle2, vec3f axis2, const Utils::Angle& angle3, vec3f axis3) { *this = quatf(angle1, axis1); *this *= quatf(angle2, axis2); *this *= quatf(angle3, axis3); if(this->normOnWrite) this->norm(); } quatf::quatf(const quatf& other) : Tuple<float,4>(other) { if(this->normOnWrite) this->norm(); } quatf::quatf(float* data) : Tuple<float,4>(data) { if(this->normOnWrite) this->norm(); } /** * Get the magnitude (length) of this vector. */ float quatf::mag() const { float ret = float(this->m_data[0]*this->m_data[0]); ret = ret + float(this->m_data[1]*this->m_data[1]); ret = ret + float(this->m_data[2]*this->m_data[2]); ret = ret + float(this->m_data[3]*this->m_data[3]); return std::sqrt(ret); } const quatf& quatf::scale(float val) { for(unsigned int i = 0; i < 4; ++i) this->m_data[i] *= val; return *this; } const quatf& quatf::operator=(quatf rhs) { float tmp; for(unsigned int i = 0; i < 4; ++i) { tmp = rhs.m_data[i]; rhs.m_data[i] = this->m_data[i]; this->m_data[i] = tmp; } if(quatf::normOnWrite) return this->norm(); else return *this; } /** * Normalize this vector. Returns a reference to this * so it can return a value for use in functions. */ const quatf& quatf::norm() { float m = this->mag(); m = 1.0f/m; return this->scale(m); } quatf quatf::conj() const { return quatf(-x(), -y(), -z(), w()); } void quatf::alwaysNormed(bool normOnWrite) { quatf::normOnWrite = normOnWrite; } quatf quatf::operator+(const quatf& rhs) const { return quatf(x() + rhs.x(), y() + rhs.y(), z() + rhs.z(), w() + rhs.w()); } quatf quatf::operator-(const quatf& rhs) const { return quatf(x() - rhs.x(), y() - rhs.y(), z() - rhs.z(), w() - rhs.w()); } /** * (w0 + x0i + y0j + z0k)*(w1 + x1i + y1j + z1k) * w0*w1 + (w0*x1)i + (w0*y1)j + (w0*z1)k + * -x0*x1 + (x0*w1)i - (x0*z1)j + (x0*y1)k + * -y0*y1 + (y0*z1)i + (y0*w1)j - (y0*x1)k + * -z0*z1 - (z0*y1)i + (z0*x1)j + (z0*w1)k * * (w0*w1 - x0*x1 - y0*y1 - z0*z1) + * (w0*x1 + x0*w1 + y0*z1 - z0*y1)i + * (w0*y1 - x0*z1 + y0*w1 + z0*x1)j + * (w0*zi + x0*y1 - y0*x1 + z0*w1)k */ quatf quatf::operator*(const quatf& rhs) const { float w = this->m_data[3]*rhs.m_data[3] - this->m_data[2]*rhs.m_data[2] - this->m_data[1]*rhs.m_data[1] - this->m_data[0]*rhs.m_data[0]; float x = this->m_data[3]*rhs.m_data[0] + this->m_data[0]*rhs.m_data[3] + this->m_data[1]*rhs.m_data[2] - this->m_data[2]*rhs.m_data[1]; float y = this->m_data[3]*rhs.m_data[1] - this->m_data[0]*rhs.m_data[2] + this->m_data[1]*rhs.m_data[3] + this->m_data[2]*rhs.m_data[0]; float z = this->m_data[3]*rhs.m_data[2] + this->m_data[0]*rhs.m_data[1] - this->m_data[1]*rhs.m_data[0] + this->m_data[2]*rhs.m_data[3]; return quatf(x, y, z, w); } const quatf& quatf::operator+=(const quatf& rhs) { *this = *this + rhs; return *this; } const quatf& quatf::operator-=(const quatf& rhs) { *this = *this - rhs; return *this; } const quatf& quatf::operator*=(const quatf& rhs) { *this = *this * rhs; return *this; } } // end namespace Math
493b43738a76397537ab1f212afc2971c884cfe1
d59bb395221463a6d352139773e527b7d695a59c
/project/ccollisionmessage.cpp
a1434f3a4f07e9b09f0a8cd174f797208860472a
[]
no_license
BackupTheBerlios/bos-ssracer
451765f7ad25a709813ed04564a9778f67a18f15
4d6b9560b67ce411f2cc814835d775f1edf1b99f
refs/heads/master
2016-09-16T12:30:08.125143
2004-04-13T15:08:18
2004-04-13T15:08:18
40,249,470
0
0
null
null
null
null
UTF-8
C++
false
false
1,661
cpp
ccollisionmessage.cpp
#include "ccollisionmessage.h" #include "macros.h" #include "DXUtil.h" CCollisionMessage::CCollisionMessage() { m_E = NULL; m_vColPoint = NULL; m_vNormal = NULL; m_vReverse = NULL; m_vPushForce = NULL; m_vCenterToCenter = NULL; m_Plane = NULL; m_icollision_type = REFLECTIVE; m_nMessageType = COLLISION_MESSAGE; } CCollisionMessage::~CCollisionMessage() { SAFE_DELETE(m_E); SAFE_DELETE(m_vColPoint); SAFE_DELETE(m_vNormal); SAFE_DELETE(m_vReverse); SAFE_DELETE(m_vPushForce); SAFE_DELETE(m_vCenterToCenter); SAFE_DELETE(m_Plane); } int CCollisionMessage::SetEntity(CEntity* E) { if (!E) return NULL_POINTER; m_E = E; return OK; } int CCollisionMessage::SetColPoint(Vector3f* ColPoint) { if (!ColPoint) return NULL_POINTER; m_vColPoint = ColPoint; return OK; } int CCollisionMessage::SetNormal(Vector3f* Normal) { if (!Normal) return NULL_POINTER; m_vNormal = Normal; return OK; } int CCollisionMessage::SetReverse(Vector3f* Reverse) { if (!Reverse) return NULL_POINTER; m_vReverse = Reverse; return OK; } int CCollisionMessage::SetPlane(Rectangle3f* Plane) { if (!Plane) return NULL_POINTER; m_Plane = Plane; return OK; } int CCollisionMessage::SetCollisionType(int type) { if (type != REFLECTIVE && type != PUSHED && type != SPHERE_TO_SPHERE) return INVALID_COLLISION_TYPE; m_icollision_type = type; return OK; } int CCollisionMessage::SetPushForce(Vector3f* PushForce) { if (!PushForce) return NULL_POINTER; m_vPushForce = PushForce; return OK; } int CCollisionMessage::SetCenterToCenter(Vector3f* CenterToCenter) { if (!CenterToCenter) return NULL_POINTER; m_vCenterToCenter = CenterToCenter; return OK; }
7adcfa93e75944afc22fc365867443820a74dd98
89763de6db360662c3c9cdda76cecf0c68458e04
/Netbeans/Kuis2-Struktur Data/main.cpp
3eeb4e7a66bcbba3a9e2d3d7e93cfd235d311901
[]
no_license
bukhari-inst/learn_data_structure
c12194400e18f73b21ef9cdf241c6992c41795f6
4025dfb77b0feda2977c44f3eab1d4fa8c497e3b
refs/heads/master
2022-10-23T11:36:28.998909
2020-06-16T04:41:30
2020-06-16T04:41:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,128
cpp
main.cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.cpp * Author: Bukhori * * Created on September 16, 2019, 9:47 AM */ #include <iostream> using namespace std; /* * */ int main(int argc, char** argv) { int input, p, l, t, max, maks, min = 0; cout << "masukkan jumlah balok : "; cin >> input; cout << endl; int data[input]; for (int i = 0; i < input; i++) { cout << "masukkan Ukuran balok ke-" << i + 1 << " : " << endl; cin >> p; cin >> l; cin >> t; data[i] = p + l + t; } maks = data[0]; for (int i = 0; i < input; i++) { if (data[i] > maks) { max = data[i]; maks = max - 1; } } cout << "Tinggi Maksimum adalah : " << maks << endl; min = data[0]; for (int i = 0; i < input; i++) { if (data[i] < min) { min = data[i]; } } cout << "Tinggi Minimum adalah : " << min << endl; return 0; }
e10a5316ae3cfaa41a1e3f5f2644057393af630d
e261ecbf1b16d922a7c6a07b589fa8283ea6efa7
/Module6Assignment1.cpp
ad2ac30f1c7e7dec2e0c4cd3679561e06de282bd
[]
no_license
tacallegari/COP2222
aa7dde7143246ffd416d62dcdad761d46311e44e
c7afbf8c010fe19bf77ff760d25e4bb0bed7f2d3
refs/heads/main
2023-01-28T20:37:18.221379
2020-12-10T20:32:03
2020-12-10T20:32:03
320,381,568
0
0
null
null
null
null
UTF-8
C++
false
false
753
cpp
Module6Assignment1.cpp
// Tahlia Callegari // 2428774 //COP2222 Fall 2020 #include "CruiseShip.h" #include "CargoShip.h" #include "Ship.h" #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { //Declare constant const int SIZE = 3; //Create ships array of Ship pointers and //initialized each element with an object //of each class Ship* ships[SIZE] = { new Ship("Nuestra Senora de Atocha", "1621"), new CargoShip("Esmeralda", "1957", 26947), new CruiseShip("Achille Lauro", "1947", 869) }; //Displays each ship for (int i = 0; i < SIZE; i++) { ships[i]->print(); //Overrides print() function each element } return 0; }
9f5d80fc044164d29cd1a571304a352be3d462c2
4b19135464a032c1d5271cd1ae58afb21df38584
/Samples/C++/Direct3D/EffectEdit/EffectEdit.cpp
286804d67f82ab2607a8e225fe3896da68a7aea8
[]
no_license
sjk7/DX90SDK
f47cebbba53133923880004bc6e3a33cff1fe895
dd155425badb2cd3993c27f869efc007764e599b
refs/heads/master
2021-08-26T07:47:03.826451
2021-08-12T05:03:03
2021-08-12T05:03:03
253,911,891
3
1
null
null
null
null
UTF-8
C++
false
false
13,660
cpp
EffectEdit.cpp
// EffectEdit.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "EffectEdit.h" #include "MainFrm.h" #include "EffectDoc.h" #include "UIElements.h" #include "RenderView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CEffectEditCommandLineInfo CEffectEditCommandLineInfo::CEffectEditCommandLineInfo() { m_bUseExternalEditor = FALSE; } void CEffectEditCommandLineInfo::ParseParam(const TCHAR* pszParam,BOOL bFlag,BOOL bLast) { TCHAR* pstrExtEd = TEXT("ee"); if( bFlag && CompareString( LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, pszParam, -1, pstrExtEd, -1 ) == CSTR_EQUAL ) m_bUseExternalEditor = TRUE; else CCommandLineInfo::ParseParam( pszParam, bFlag, bLast ); } ///////////////////////////////////////////////////////////////////////////// // CEffectEditDocManager::DoPromptFileName - overridden to allow modification // of initial dir BOOL CEffectEditDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate) { CFileDialog dlgFile(bOpenFileDialog); CString title; VERIFY(title.LoadString(nIDSTitle)); dlgFile.m_ofn.Flags |= lFlags; TCHAR strMedia[MAX_PATH]; BOOL bDefaultToMediaDir = AfxGetApp()->GetProfileInt( TEXT("Settings"), TEXT("DefaultToDXSDKMediaDir"), TRUE ); if( bDefaultToMediaDir ) { DXUtil_GetDXSDKMediaPathCch( strMedia, MAX_PATH ); dlgFile.m_ofn.lpstrInitialDir = strMedia; TCHAR strMedia2[MAX_PATH]; lstrcpy( strMedia2, strMedia ); _tcsncat( strMedia2, TEXT("EffectEdit"), MAX_PATH ); strMedia2[MAX_PATH-1] = 0; DWORD dw; dw = GetFileAttributes( strMedia2 ); if( dw != ((DWORD)-1) && (dw & FILE_ATTRIBUTE_DIRECTORY) != 0 ) dlgFile.m_ofn.lpstrInitialDir = strMedia2; } CString strFilter; // Can't do the usual _AfxAppendFilterSuffix thing because that function // is local to docmgr.cpp strFilter += TEXT("Effect Files (*.fx)"); strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.fx"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; // append the "*.*" all files filter CString allFilter; VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.*"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); INT_PTR nResult = dlgFile.DoModal(); fileName.ReleaseBuffer(); return nResult == IDOK; }; ///////////////////////////////////////////////////////////////////////////// // CEffectEditApp BEGIN_MESSAGE_MAP(CEffectEditApp, CWinApp) //{{AFX_MSG_MAP(CEffectEditApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_VIEW_CHOOSEFONT, OnViewChooseFont) ON_COMMAND(ID_VIEW_TABS, OnViewTabOptions) ON_COMMAND(ID_FILE_DEFAULTTODXSDKMEDIAFOLDER, OnFileDefaultToDxsdkMediaFolder) ON_UPDATE_COMMAND_UI(ID_FILE_DEFAULTTODXSDKMEDIAFOLDER, OnUpdateFileDefaultToDxsdkMediaFolder) //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEffectEditApp construction CEffectEditApp::CEffectEditApp() { m_bRenderContinuously = true; m_bAppActivated = false; } ///////////////////////////////////////////////////////////////////////////// // The one and only CEffectEditApp object CEffectEditApp theApp; ///////////////////////////////////////////////////////////////////////////// // CEffectEditApp initialization BOOL CEffectEditApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #if(_MFC_VER < 0x0700) #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif // Change the registry key under which our settings are stored. SetRegistryKey(_T("Microsoft")); LoadStdProfileSettings(8); // Load standard INI file options (including MRU) if( !AfxInitRichEdit() ) return FALSE; // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. m_pDocManager = new CEffectEditDocManager; CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CEffectDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CRenderView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CEffectEditCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; if( cmdInfo.UseExternalEditor() ) m_pMainWnd->PostMessage(WM_COMMAND, ID_EDIT_USEEXTERNALEDITOR ); return TRUE; } void CEffectEditApp::OnFileDefaultToDxsdkMediaFolder() { BOOL bDefaultToMediaDir = GetProfileInt( TEXT("Settings"), TEXT("DefaultToDXSDKMediaDir"), TRUE ); bDefaultToMediaDir = !bDefaultToMediaDir; WriteProfileInt( TEXT("Settings"), TEXT("DefaultToDXSDKMediaDir"), bDefaultToMediaDir ); } void CEffectEditApp::OnUpdateFileDefaultToDxsdkMediaFolder(CCmdUI* pCmdUI) { BOOL bDefaultToMediaDir = GetProfileInt( TEXT("Settings"), TEXT("DefaultToDXSDKMediaDir"), TRUE ); pCmdUI->SetCheck( bDefaultToMediaDir ); } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; CEdit m_edtHelp; CString m_strVersion; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { TCHAR szFile[MAX_PATH]; CString strVersion; UINT cb; DWORD dwHandle; BYTE FileVersionBuffer[1024]; VS_FIXEDFILEINFO* pVersion = NULL; GetModuleFileName(NULL, szFile, MAX_PATH); cb = GetFileVersionInfoSize(szFile, &dwHandle/*ignored*/); if (cb > 0) { if (cb > sizeof(FileVersionBuffer)) cb = sizeof(FileVersionBuffer); if (GetFileVersionInfo(szFile, 0, cb, FileVersionBuffer)) { pVersion = NULL; if (VerQueryValue(FileVersionBuffer, "\\", (VOID**)&pVersion, &cb) && pVersion != NULL) { strVersion.Format("Version %d.%02d.%02d.%04d", HIWORD(pVersion->dwFileVersionMS), LOWORD(pVersion->dwFileVersionMS), HIWORD(pVersion->dwFileVersionLS), LOWORD(pVersion->dwFileVersionLS)); } } } //{{AFX_DATA_INIT(CAboutDlg) m_strVersion = strVersion; //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) DDX_Control(pDX, IDC_HELP_EDITBOX, m_edtHelp); DDX_Text(pDX, IDC_VERSION, m_strVersion); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() // App command to run the dialog void CEffectEditApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CEffectEditApp message handlers BOOL CEffectEditApp::OnIdle(LONG lCount) { if( m_bRenderContinuously ) { CWinApp::OnIdle(lCount); if( !m_bAppActivated ) Sleep(50); m_pMainWnd->SendMessage(WM_COMMAND, ID_VIEW_RENDER); return TRUE; // always request more time } else { return CWinApp::OnIdle(lCount); } } void CEffectEditApp::ActivateTextView() { ((CMainFrame*)m_pMainWnd)->ActivateTextView(); } void CEffectEditApp::ActivateErrorsView() { ((CMainFrame*)m_pMainWnd)->ActivateErrorsView(); } void CEffectEditApp::ActivateOptionsView() { ((CMainFrame*)m_pMainWnd)->ActivateOptionsView(); } void CEffectEditApp::SelectLine(int iLine) { ((CMainFrame*)m_pMainWnd)->SelectLine(iLine); } void CEffectEditApp::OnViewChooseFont() { CFontDialog fontDialog; DWORD dwFontSize = GetProfileInt( TEXT("Settings"), TEXT("FontSize"), 9 ); CString strFontName = GetProfileString( TEXT("Settings"), TEXT("FontName"), TEXT("Courier") ); HDC hdc = GetDC(NULL); fontDialog.m_lf.lfHeight = -MulDiv(dwFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC( NULL, hdc ); fontDialog.m_lf.lfWeight = FW_NORMAL; lstrcpy( fontDialog.m_lf.lfFaceName, strFontName ); fontDialog.m_cf.Flags |= CF_INITTOLOGFONTSTRUCT; fontDialog.m_cf.Flags &= ~CF_EFFECTS; if( IDOK == fontDialog.DoModal() ) { CFont font; if( NULL != font.CreateFontIndirect(&fontDialog.m_lf) ) { font.DeleteObject(); int newSize = fontDialog.GetSize() / 10; CString strNewFontName = fontDialog.GetFaceName(); WriteProfileInt( TEXT("Settings"), TEXT("FontSize"), newSize ); WriteProfileString( TEXT("Settings"), TEXT("FontName"), strNewFontName ); ((CMainFrame*)m_pMainWnd)->TextViewUpdateFont(); } } } void CEffectEditApp::OnViewTabOptions() { CTabOptionsDialog tabDialog; BOOL bKeepTabs = GetProfileInt( TEXT("Settings"), TEXT("Keep Tabs"), FALSE ); INT numSpaces = GetProfileInt( TEXT("Settings"), TEXT("Num Spaces"), 4 ); tabDialog.m_numSpaces = numSpaces; if( bKeepTabs ) tabDialog.m_TabsOrSpacesRadio = 0; else tabDialog.m_TabsOrSpacesRadio = 1; if( IDOK == tabDialog.DoModal() ) { numSpaces = tabDialog.m_numSpaces; if( tabDialog.m_TabsOrSpacesRadio == 0 ) bKeepTabs = TRUE; else bKeepTabs = FALSE; WriteProfileInt( TEXT("Settings"), TEXT("Keep Tabs"), bKeepTabs ); WriteProfileInt( TEXT("Settings"), TEXT("Num Spaces"), numSpaces ); } } ///////////////////////////////////////////////////////////////////////////// // CTabOptionsDialog dialog CTabOptionsDialog::CTabOptionsDialog(CWnd* pParent /*=NULL*/) : CDialog(CTabOptionsDialog::IDD, pParent) { //{{AFX_DATA_INIT(CTabOptionsDialog) m_numSpaces = 0; m_TabsOrSpacesRadio = -1; //}}AFX_DATA_INIT } void CTabOptionsDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTabOptionsDialog) DDX_Text(pDX, IDC_NUMSPACES, m_numSpaces); DDV_MinMaxUInt(pDX, m_numSpaces, 1, 8); DDX_Radio(pDX, IDC_TABS, m_TabsOrSpacesRadio); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CTabOptionsDialog, CDialog) //{{AFX_MSG_MAP(CTabOptionsDialog) // NOTE: the ClassWizard will add message map macros here //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTabOptionsDialog message handlers BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); bool bSuccess = false; HMODULE hModule = NULL; HRSRC rsrc; HGLOBAL hgData; LPVOID pvData; DWORD cbData; rsrc = FindResource( hModule, MAKEINTRESOURCE(IDR_HELP_TXT), "TEXT" ); if( rsrc != NULL ) { cbData = SizeofResource( hModule, rsrc ); if( cbData > 0 ) { hgData = LoadResource( hModule, rsrc ); if( hgData != NULL ) { pvData = LockResource( hgData ); if( pvData != NULL ) { TCHAR* strBuffer = (TCHAR*)pvData; strBuffer[cbData/sizeof(TCHAR)] = 0; m_edtHelp.SetWindowText( strBuffer ); bSuccess = true; } } } } if( !bSuccess ) { CString sz( "Error: Could not open help.txt" ); m_edtHelp.SetWindowText( sz ); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
c16a94c28c0a754b9d8070422aed131b8c8d2f36
bec43fb187e4753da2fd7dac75bbfb040787ce06
/HackerRank/matrix_rotation.cc
efe8ae4b1cedb381a093ba6d57bd683512fdbe6d
[]
no_license
ajaysharma388/Online-Platform-s-Compitetive-Coding
27d090548af5f8c5522d5f43c1a358220c783455
1795766d42866545f0aa4dcab34fac07b83f5cb4
refs/heads/master
2020-07-19T12:55:15.095628
2020-07-12T18:33:14
2020-07-12T18:33:14
206,453,053
1
0
null
null
null
null
UTF-8
C++
false
false
1,424
cc
matrix_rotation.cc
#include <bits/stdc++.h> using namespace std; #define ll long long int #define endl "\n" void matrixRotation(int**a,int m,int n){ int x=0,y=0; while(x<n/2 && y<n/2){ int i=x,j=y; int t=a[i][j]; for(;j<n-1-y;++j){ a[i][j] = a[i][j+1]; // first Line } for(;i<m-1-x;++i){ a[i][j] = a[i+1][j]; // last col. } for(;j>y;--j){ a[i][j] = a[i][j-1]; } for(i=m-1-x;i>x;--i){ a[i][j] = a[i-1][j]; } x++;y++; a[x][j]=t; } } int main(){ #ifndef ONLINE_JUGDE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt","w",stderr); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); int m,n,r; cin >> m >> n >> r; int **arr = new int*[m]; for(int i=0;i<m;++i){ arr[i] = new int[n]; } for(int i=0;i<m;++i){ for(int j=0;j<n;++j){ cin >> arr[i][j]; } } for (int i = 0; i < r; ++i){ matrixRotation(arr,m,n); } for(int i=0;i<m;++i){ for(int j=0;j<n;++j){ cout << arr[i][j] <<" "; } cout<<endl; } return 0; } // Sample Input : // 4 4 2 // 1 2 3 4 // 5 6 7 8 // 9 10 11 12 // 13 14 15 16 // 5 4 7 // 1 2 3 4 // 7 8 9 10 // 13 14 15 16 // 19 20 21 22 // 25 26 27 28 // Sample Output : // 3 4 8 12 // 2 11 10 16 // 1 7 6 15 // 5 9 13 14 // 28 27 26 25 // 22 9 15 19 // 16 8 21 13 // 10 14 20 7 // 4 3 2 1
c46c3ff4f4febcec2355f99452ed98e12569bfd8
05f6102345a169cd94bf91a464968436bbc1dcbd
/Source/Headers/mvector.h
3875ea20284a6e31746ed17def34c3fc419d240d
[]
no_license
HammerFall42/Computer-graphics-project
9001add53e79282372e5a1b83eac794e616350a8
b50216e1bab1f9403d9dedba502d29d7380f3bfb
refs/heads/main
2023-07-07T16:52:07.931718
2021-08-25T08:48:20
2021-08-25T08:48:20
359,179,279
0
0
null
null
null
null
UTF-8
C++
false
false
670
h
mvector.h
#ifndef MVECTOR_H #define MVECTOR_H #include <stdlib.h> #include <stdarg.h> #include <string> #include <memory> #include "error.h" using namespace std; template <typename ValueType> class MVector { public: MVector(); MVector(size_t size); MVector(const MVector<ValueType>&mvector); ~MVector(); ValueType& operator[](size_t index); MVector<ValueType>& operator=(const MVector<ValueType>& mvector); void push_back(ValueType element); void del(size_t index); void clear() {vsize = 0;} void reverse(); size_t size() {return vsize;} private: ValueType *p; size_t vsize; size_t allocated; }; #endif // MVECTOR_H
fea54f07ca251d7329b907fbe068d615039e50f2
23b7057146d3db771411b8b9acb6731f619bea6a
/VoiceManager/VoiceManager.h
51960d418a32ecadc509055e233c95539c7a2895
[]
no_license
leozlee/All-practice
105d8090bb6c7cbd49b7f47813cdcdc24049e1cb
d5d87ab71ce4ad2a7c64dae1e1241ee538ff220b
refs/heads/master
2021-08-18T17:29:59.051918
2017-11-23T13:26:37
2017-11-23T13:26:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,050
h
VoiceManager.h
#ifndef _VOICEMANAGER_H__ #define _VOICEMANAGER_H__ #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <stdlib.h> #include <stdio.h> #include <linux/soundcard.h> #define VOICE_FILE_PATH "/home/opt/data/voice" enum VoiceSignalId { NO_SIGNAL = 0, //无语音信号 TURN_ON_DEVICE, //开机语音提示 WARNING_DANGER, //报警:danger WARNING_DILONG_ONCE, //报警:长滴声1声 WARNING_DILONG_3TIMES, //报警:长滴声3声 WARNING_DISHORT, //报警:短滴声1声 WARNING_DIHIT, //报警:超短滴1声 WARNING_OVERSPEED, //超速语音报警 }; class CVoiceManager { public: CVoiceManager(); ~CVoiceManager(); static CVoiceManager* GetInstance(); bool HasInstance(); void Destory(); int TestSound(char *filename); bool AudioPlay(const char *path,int nSampleRate,int nChannels,int fmt); bool VoiceInit(); private: int mFd; static CVoiceManager* mInstance; }; #endif
ed653fd35e92846669ade8870086a3636df5097a
728c178b9a919a05ad9656cba63ce22e5ee789b9
/bot/inc/vec.h
6ebe77c873fd7032135ef5faade1851b665a7662
[ "MIT" ]
permissive
analog-hors/lemon-tea
d692a5ff354a34828ab9efaab0704ee6a07f3a0d
a5b903e9f6567c64755e406d4b3033e9a2b3564e
refs/heads/main
2023-07-26T10:12:15.415373
2021-09-08T02:48:31
2021-09-08T02:48:31
404,173,224
0
0
null
null
null
null
UTF-8
C++
false
false
1,898
h
vec.h
#ifndef VEC_H #define VEC_H #include <stdio.h> #include <stdlib.h> /* A very UNSAFE fixed-size vector for very special personal situations Use with CAUTIONS, can causes UNDEFINED BEHAVIORS */ template <typename T> class vec { public: vec(); ~vec(); public: T* pointer = nullptr; // This shouldn't be tampered unless must int max_size = 0; // This shouldn't be tampered unless must int size = 0; // This shouldn't be tampered unless must T& operator [] (const int& index) { return pointer[index]; }; void init(int max); // Must call this once right after create vec void add(const T& element); // There will be 1 copy maked if use this void pop(); void clear(); // This won't free memory void erase(int index); // This won't free memory void free(); // This will free memory }; template<typename T> inline vec<T>::vec() { pointer = nullptr; max_size = 0; size = 0; } template<typename T> inline vec<T>::~vec() { free(); } template<typename T> inline void vec<T>::init(int max) { if (pointer != nullptr) return; //pointer = (T*)malloc(max * sizeof(T)); pointer = new T[max]; size = 0; max_size = max; } template<typename T> inline void vec<T>::add(const T& element) { ++size; size = std::min(size, max_size); pointer[size - 1] = element; } template<typename T> inline void vec<T>::pop() { --size; size = std::max(size, 0); } template<typename T> inline void vec<T>::clear() { size = 0; } template<typename T> inline void vec<T>::erase(int index) { if (size <= 0) return; if (index < 0 || index >= size) return; for (int i = index; i < size - 1; ++i) { pointer[index] = pointer[index + 1]; } pop(); } template<typename T> inline void vec<T>::free() { if (pointer == nullptr) return; //free(pointer); delete[] pointer; pointer = nullptr; } #endif // VEC_H
d15506f58914acf0ceea71fc2642d8a4cac7d8fe
56f94a39753404fa344dcc9d5edcfb82c1fe4d00
/linked_list.h
7e909479d75286d6b4ce2cd58fa916b4d22a382e
[]
no_license
SmallE0529/Linked_List_Cpp
12c89cc9d9706af30192a46af3adb5a62b5b5047
7de27e7ad3d0983ffe353ae8a93e5a0b12d83548
refs/heads/master
2023-06-16T06:51:38.584541
2021-07-12T08:45:24
2021-07-12T08:45:24
380,315,324
0
0
null
null
null
null
UTF-8
C++
false
false
941
h
linked_list.h
#ifndef __LINKED_LIST_H__ #define __LINKED_LIST_H__ #include <iostream> class linked_list; class node { public: int data; node *next; node() { data = 0; next = nullptr; }; node(int _data) { data = _data; next = nullptr; }; node(int _data, node *_next) { data = _data; next = _next; }; friend class linked_list; }; class linked_list { public: node *_head; int _size; linked_list() { _head = nullptr; _size = 0; }; void push_front(int _data); void push_back(int _data); void insert_node(int _data, int idx); void delete_node(int idx); void reverse_list(); void clear_list(); bool is_empty(); void print_list(); }; #endif
3a915c7e9838a6949d816722901b31a3f33fb93b
53aa038d1d0c0d94348504e0ed1901d406f16b2b
/MM_EMJGameProject/Plugins/Wwise/Source/AudiokineticTools/Private/AssetManagement/SanitizeWwiseObjectPathCommandlet.cpp
8b70701c09f1f86d49f3768c4ae8026c3feb7494
[ "MIT" ]
permissive
MicosMacosGames/EpicMegaJam_MicosMacos
40506af190826d02d92cde0b0f9f6bc4244b6564
1db45728a88c7af25ce2e6d0de23bf54c1f05bc6
refs/heads/main
2023-01-27T22:27:28.225705
2020-12-11T16:00:00
2020-12-11T16:00:00
318,859,265
1
0
null
null
null
null
UTF-8
C++
false
false
1,923
cpp
SanitizeWwiseObjectPathCommandlet.cpp
#include "AssetManagement/SanitizeWwiseObjectPathCommandlet.h" #if WITH_EDITOR #include "AssetRegistry/Public/AssetRegistryModule.h" #include "AssetTools/Public/AssetToolsModule.h" #include "AkMediaAsset.h" #include "AkAudioType.h" #include "AkAssetBase.h" #include "AkUnrealHelper.h" #include "UnrealEd/Public/ObjectTools.h" #define LOCTEXT_NAMESPACE "AkAudio" #endif USanitizeWwiseObjectPathCommandlet::USanitizeWwiseObjectPathCommandlet() { IsClient = false; IsEditor = true; IsServer = false; LogToConsole = true; } int32 USanitizeWwiseObjectPathCommandlet::Main(const FString& Params) { int32 ReturnCode = 0; #if WITH_EDITOR FSlateApplication::Create(); FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools"); AssetRegistryModule.Get().ScanPathsSynchronous({ AkUnrealHelper::GetBaseAssetPackagePath() }); TArray<FAssetRenameData> assetsToRename; TArray<FAssetData> allAssets; AssetRegistryModule.Get().GetAssetsByClass(UAkMediaAsset::StaticClass()->GetFName(), allAssets, true); AssetRegistryModule.Get().GetAssetsByClass(UAkAssetPlatformData::StaticClass()->GetFName(), allAssets, true); AssetRegistryModule.Get().GetAssetsByClass(UAkAudioType::StaticClass()->GetFName(), allAssets, true); for (auto& assetData : allAssets) { auto oldPackagePath = assetData.ObjectPath.ToString(); auto sanitizedPackagePath = ObjectTools::SanitizeObjectPath(oldPackagePath); if (oldPackagePath != sanitizedPackagePath) { assetData.GetAsset(); assetsToRename.Emplace(FSoftObjectPath(oldPackagePath), FSoftObjectPath(sanitizedPackagePath)); } } if (assetsToRename.Num() > 0) { if (!AssetToolsModule.Get().RenameAssets(assetsToRename)) { ReturnCode = 1; } } #endif return ReturnCode; } #undef LOCTEXT_NAMESPACE
a3ab9d15c2dfc25dbf5c5df2ca35ca3ef928b4c2
e6bf052e2788a816d099aa67329a5bf5c83578cf
/2012/1B/1B-A.cpp
9564e75f5ab2259f7d4d83c5ab434977efb80e3e
[]
no_license
jpborsi/learn-cpp-codejam
f88576ea03532dd90c2fbe6fd694ba4f407058dd
5c2bc0dcd27a57271aef1eff737e5bf944fe0d3e
refs/heads/master
2023-03-21T16:47:50.223289
2021-03-07T12:45:12
2021-03-07T12:45:12
61,922,994
0
1
null
null
null
null
UTF-8
C++
false
false
2,149
cpp
1B-A.cpp
//2012 Round 1B, Problem A //Safety in Numbers //https://code.google.com/codejam/contest/1836486/dashboard /* Input: The first line of the input gives the number of test cases, T. T test cases follow, one per line. Each line starts with an integer N, the number of contestants, followed by a space, followed by N integers s0, s1, ..., sN-1, separated by single spaces. The integer si is the point value assigned to contestant i by the judges. */ /* Output: For each test case, output one line containing "Case #x: " followed by N real numbers: mis. The value x is the case number (starting from 1). The value mi is the smallest percentage of audience votes required for contestant i to definitely avoid elimination. Answers within an absolute or relative error of 10-5 of the correct answer will be accepted. */ #include <iostream> #include <vector> #include <algorithm> using namespace std; void print_solution(int N, vector<int> scores){ int j = 0; for(int i : scores){ j+=i; } vector<int> sortedScores = scores; sort(sortedScores.begin(),sortedScores.end()); reverse(sortedScores.begin(),sortedScores.end()); int numberOfSafePeople = 0; int threshold = 2*j; int total_points = 2*j; for(int i : sortedScores){ //cout << total_points << " " << N << " " << numberOfSafePeople << endl; //cout << i << " > " << 1.0*total_points/(N-numberOfSafePeople) << endl; if(i > 1.0*total_points/(N-numberOfSafePeople)){ numberOfSafePeople++; total_points-=i; threshold = i; }else{ break; } } int numberOfBottomFeeders = N-numberOfSafePeople; double percents[N]; for(int i = 0; i < scores.size(); i++){ if(scores[i]>=threshold){ percents[i] = 0.0; }else{ percents[i] = 100*(1.0*total_points/numberOfBottomFeeders - 1.0*scores[i])/j; } } char result[12]; for(double d : percents){ sprintf(result,"%.6f ",d); cout << result; } cout << endl; } int main(){ int T, N, tmp; vector<int> scores; cin >> T; for(int i = 1; i <= T;i++){ cin >> N; scores.clear(); for(int j=0;j<N;j++){ cin >> tmp; scores.push_back(tmp); } cout << "Case #" << i << ": "; print_solution(N,scores); } }
e7868fa4c8ea588338c3a66d2c511ff7d57da36d
664c300d81027c3866ea43f91bb45a5b0d69a818
/src/sqlite.h
082a4c128575b6aee80017c136d590a0fa7ffd81
[]
no_license
choury/fmdisk
5c58850208100ac7ef21ee37a675239146945187
a2544689a9adb41d4197a5eefdc677a40698ff82
refs/heads/master
2020-04-01T18:30:11.319789
2020-02-02T09:07:39
2020-02-02T09:07:39
153,496,560
1
0
null
null
null
null
UTF-8
C++
false
false
608
h
sqlite.h
#ifndef SQLITE_H__ #define SQLITE_H__ #include "utils.h" int sqlinit(); void sqldeinit(); void save_file_to_db(const std::string& path, const filemeta& meta, const std::vector<filekey>& fblocks); void load_file_from_db(const std::string& path, filemeta& meta, std::vector<filekey>& fblocks); int delete_file_from_db(const std::string& path); void save_entry_to_db(const filekey& fileat, const filemeta& meta); int load_entry_from_db(const std::string& path, std::vector<filemeta>& flist); int delete_entry_from_db(const std::string& path); int delete_entry_prefix_from_db(const std::string& path); #endif
84b0ac970fa65282307010045163e1444edcd789
17fb717579a13aeadb8883e18007ebea9f6b7201
/library/cgp/display/drawable/mesh_drawable/mesh_drawable.cpp
22ecb097e5278aa84a1fe22c5bd42af9c7cde282
[]
no_license
vbonczak/graphviz
3f79336c85fa914f57695f1c3dac279672115687
7a7ad23bd6aef9c7739c7ff8c2f8059f2f86cc61
refs/heads/main
2023-08-23T21:20:12.007548
2021-11-05T16:52:24
2021-11-05T16:52:24
421,956,622
0
0
null
null
null
null
UTF-8
C++
false
false
5,106
cpp
mesh_drawable.cpp
#include "mesh_drawable.hpp" #include "cgp/base/base.hpp" namespace cgp { GLuint mesh_drawable::default_shader = 0; GLuint mesh_drawable::default_texture = 0; mesh_drawable::mesh_drawable() :vbo(), vao(0), number_triangles(0), shader(0), texture(0), transform(), anisotropic_scale({ 1,1,1 }), shading(), name("uninitialized") {} static void warning_initialize(std::string const previous_name, std::string const current_name) { std::string warning="\n"; warning += " > The original mesh_drawable is called [" + previous_name + "]\n"; warning += " > The current mesh_drawble is called [" + current_name + "]\n"; warning += "In normal condition, you should avoid initializing mesh_drawble without clearing the previous one - the allocated memory on the GPU is going to be lost.\n"; warning += " - If you want to clear the memory, please call mesh_drawable.clear() before calling a new initialization\n"; warning += " - If the vbo is shared between several instances of mesh_drawable and you don't want to clear this memory, you can create a new default mesh_drawable() before applying the initialization.\n"; warning_cgp("Calling mesh_drawable.initialize() on a structure mesh_drawable with non zero VBOs", warning); } mesh_drawable& mesh_drawable::initialize(mesh const& data_to_send, std::string const& object_name, GLuint shader_arg, GLuint texture_arg) { // Error detection before sending the data to avoid unexpected behavior // *********************************************************************** // opengl_check; // Check if this mesh_drawable is already initialized if (vbo.size() != 0 || vao != 0) warning_initialize(name, object_name); if (data_to_send.position.size() == 0) { warning_cgp("Warning try to generate mesh_drawable ["+name+"] with 0 vertex",""); return *this; } // Sanity check before sending mesh data to GPU assert_cgp(mesh_check(data_to_send), "Cannot send this mesh data to GPU in initializing mesh_drawable with name ["+name+"]"); // Variable initialization // *********************************************************************** // name = object_name; shader = shader_arg; texture = texture_arg; transform = affine_rts(); shading = shading_parameters_phong(); // Send the data to the GPU // ******************************************** // // Fill VBOs opengl_create_gl_buffer_data(GL_ARRAY_BUFFER, vbo["position"], data_to_send.position, GL_DYNAMIC_DRAW); opengl_create_gl_buffer_data(GL_ARRAY_BUFFER, vbo["normal"], data_to_send.normal, GL_DYNAMIC_DRAW); opengl_create_gl_buffer_data(GL_ARRAY_BUFFER, vbo["color"], data_to_send.color, GL_DYNAMIC_DRAW); opengl_create_gl_buffer_data(GL_ARRAY_BUFFER, vbo["uv"], data_to_send.uv, GL_DYNAMIC_DRAW); opengl_create_gl_buffer_data(GL_ELEMENT_ARRAY_BUFFER, vbo["index"], data_to_send.connectivity, GL_DYNAMIC_DRAW); // Store number of triangles number_triangles = static_cast<GLuint>(data_to_send.connectivity.size()); // Generate VAO glGenVertexArrays(1,&vao); opengl_check glBindVertexArray(vao); opengl_check opengl_set_vertex_attribute(vbo["position"], 0, 3, GL_FLOAT); opengl_set_vertex_attribute(vbo["normal"], 1, 3, GL_FLOAT); opengl_set_vertex_attribute(vbo["color"], 2, 3, GL_FLOAT); opengl_set_vertex_attribute(vbo["uv"], 3, 2, GL_FLOAT); glBindVertexArray(0); opengl_check return *this; } mesh_drawable& mesh_drawable::update_position(buffer<vec3> const& new_position) { glBindBuffer(GL_ARRAY_BUFFER,vbo["position"]); opengl_check; glBufferSubData(GL_ARRAY_BUFFER,0,size_in_memory(new_position),ptr(new_position)); opengl_check; return *this; } mesh_drawable& mesh_drawable::update_normal(buffer<vec3> const& new_normals) { glBindBuffer(GL_ARRAY_BUFFER,vbo["normal"]); opengl_check; glBufferSubData(GL_ARRAY_BUFFER,0,size_in_memory(new_normals),ptr(new_normals)); opengl_check; return *this; } mesh_drawable& mesh_drawable::update_color(buffer<vec3> const& new_color) { glBindBuffer(GL_ARRAY_BUFFER,vbo["color"]); opengl_check; glBufferSubData(GL_ARRAY_BUFFER,0,size_in_memory(new_color),ptr(new_color)); opengl_check; return *this; } mesh_drawable& mesh_drawable::update_uv(buffer<vec2> const& new_uv) { glBindBuffer(GL_ARRAY_BUFFER,vbo["uv"]); opengl_check; glBufferSubData(GL_ARRAY_BUFFER,0,size_in_memory(new_uv),ptr(new_uv)); opengl_check; return *this; } mesh_drawable& mesh_drawable::clear() { for(auto& buffer : vbo) glDeleteBuffers(1, &(buffer.second) ); vbo.clear(); glDeleteVertexArrays(1, &vao); vao = 0; opengl_check; number_triangles = 0; shader = 0; texture = 0; transform = affine_rts(); anisotropic_scale = { 1,1,1 }; shading = shading_parameters_phong(); name = "uninitialized"; return *this; } mat4 mesh_drawable::model_matrix() const { mat4 const model = transform.matrix() * mat4::diagonal(anisotropic_scale); return model; } }
e4a0a536a14f110b4d31212a8d4b0a015215d272
4f4ddc396fa1dfc874780895ca9b8ee4f7714222
/src/xtp/Samples/ShortcutBar/ShortcutBar/ShortcutPaneFolders.cpp
d432f98f77b3847106f84c7c421c09666a145591
[]
no_license
UtsavChokshiCNU/GenSym-Test2
3214145186d032a6b5a7486003cef40787786ba0
a48c806df56297019cfcb22862dd64609fdd8711
refs/heads/master
2021-01-23T23:14:03.559378
2017-09-09T14:20:09
2017-09-09T14:20:09
102,960,203
3
5
null
null
null
null
UTF-8
C++
false
false
3,727
cpp
ShortcutPaneFolders.cpp
// ShortcutPaneFolders.cpp: implementation of the CShortcutPaneFolders class. // // This file is a part of the XTREME TOOLKIT PRO MFC class library. // (c)1998-2011 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "shortcutbar.h" #include "ShortcutPaneFolders.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif static UINT treeIcons[] = { IDI_INBOX , IDI_SEARCH , IDI_SENT_ITEMS , IDI_OUTBOX , IDI_OUTLOOK_TODAY , IDI_DELETED_ITEMS , IDI_DRAFTS , IDI_ARCHIVE , IDI_CALENDAR , IDI_CONTACTS }; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CShortcutPaneFolders::CShortcutPaneFolders() { m_ilTreeIcons.Create(16, 16, ILC_MASK|ILC_COLOR32, 1, 1); for (int i = 0; i < _countof(treeIcons); i++) { HICON hIcon = AfxGetApp()->LoadIcon(treeIcons[i]); ASSERT(hIcon); m_ilTreeIcons.Add (hIcon); } } CShortcutPaneFolders::~CShortcutPaneFolders() { } BOOL CShortcutPaneFolders::Create(LPCTSTR lpszCaption, CXTPShortcutBar* pParent) { if (!CXTPShortcutBarPane::Create(lpszCaption, pParent)) return FALSE; VERIFY(m_wndTreeFolders.Create(WS_VISIBLE|TVS_HASBUTTONS|TVS_LINESATROOT, CXTPEmptyRect(), this, 0)); m_wndTreeFolders.SetImageList(&m_ilTreeIcons, TVSIL_NORMAL); HTREEITEM hItem = m_wndTreeFolders.InsertItem (_T("Personal"), 4, 4); m_wndTreeFolders.InsertItem (_T("Deleted Items"), 5, 5, hItem); m_wndTreeFolders.InsertItem (_T("Inbox"), 0, 0, hItem); m_wndTreeFolders.InsertItem (_T("Sent Items"), 2, 2, hItem); m_wndTreeFolders.InsertItem (_T("Outbox"), 3, 3, hItem); m_wndTreeFolders.InsertItem (_T("Calendar"), 8, 8, hItem); m_wndTreeFolders.InsertItem (_T("Unread Mail"), 1, 1, hItem); m_wndTreeFolders.InsertItem (_T("Drafts"), 6, 6, hItem); m_wndTreeFolders.InsertItem(_T("Contacts"), 9, 9, hItem); HTREEITEM hItemSearch = m_wndTreeFolders.InsertItem (_T("Search Folders"), 1, 1, hItem); m_wndTreeFolders.InsertItem (_T("For Follow Up"), 1, 1, hItemSearch); m_wndTreeFolders.InsertItem (_T("Large Mail"), 1, 1, hItemSearch); m_wndTreeFolders.InsertItem (_T("Unread Mail"), 1, 1, hItemSearch); m_wndTreeFolders.Expand(hItem, TVE_EXPAND); hItem = m_wndTreeFolders.InsertItem (_T("Archive Folders"), 7, 7); m_wndTreeFolders.InsertItem (_T("Deleted Items"), 5, 5, hItem); m_wndTreeFolders.InsertItem (_T("Search Folders"), 1, 1, hItem); AddItem(_T("All Folders"), &m_wndTreeFolders, 115); return TRUE; } void CShortcutPaneFolders::SetFlatStyle(BOOL bFlatStyle) { CXTPShortcutBarPane::SetFlatStyle(bFlatStyle); ShowCaption(!bFlatStyle); COLORREF clrBackground = GetBackgroundColor(); COLORREF clrTextColor = GetTextColor(); m_wndTreeFolders.SendMessage(TVM_SETBKCOLOR, 0, clrBackground); m_wndTreeFolders.SendMessage(TVM_SETTEXTCOLOR, 0, clrTextColor); RecalcLayout(); }
2cf4c2f8e6a0da43c1da0bb9a16f7d5ec2f14ba3
c04d4dc09e6d1b0862fb2b3d7f9de7ec19633a1f
/Source/Plot/ThreeDim/TDLinePlot/TDLinePlot.h
339ff885c5dda9a89fb0ae07a79a0a1d74c82f59
[ "MIT" ]
permissive
Ben20013/CChart
6d4e7eb46ea37e870b27e702b0bde68acf8661da
436b97ca803d6c911d954437b1674b2537577654
refs/heads/master
2023-07-11T16:31:06.821801
2020-10-08T13:16:09
2020-10-08T13:16:09
null
0
0
null
null
null
null
GB18030
C++
false
false
2,472
h
TDLinePlot.h
/*============================================================================*/ /* */ /* C O P Y R I G H T */ /* */ /* (C) Copyright 2019 by */ /* Yang Guojun */ /* All Rights Reserved */ /* */ /* The author assumes no responsibility for the use or reliability of */ /* his software. */ /* */ /*============================================================================*/ //////////////////////////////////////////////////////////////////////////////// // 版权申明 // // 版权所有(C)2006-2019,杨国君 // // 保留全部权利 // //////////////////////////////////////////////////////////////////////////////// /* ############################################################################################################################## */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Three Dimension plot use the OpenGL API to draw on the screen #pragma once #include <windows.h> #include "gl/gl.h" #include "../../Basic/CChartNameSpace.h" #include "../../Basic/XYPlot.h" Declare_Namespace_CChart enum { kTDPlotScatter, kTDPlotConnected, kTDPlotBezier, kTDPlotCount }; class CTDLinePlot : public CXYPlot { public: CTDLinePlot(); ~CTDLinePlot(); void SetDefaults(); // bool m_bAutoDataColor; // int m_nModeOfSetColors; GLfloat m_fvLineColor1[4]; GLfloat m_fvLineColor2[4]; public: // bool IsAutoDataColorGeneral(){return m_bAutoDataColor;} // void SetAutoDataColorGerneral(bool bAuto){m_bAutoDataColor = bAuto;} // int GetModeOfSetColors(){return m_nModeOfSetColors;} // void SetModeOnSetColors(int nMode){m_nModeOfSetColors = nMode;} }; Declare_Namespace_End
391a061adab6d05fbab1badae6e5cb2e038682e8
1f40abf77c33ebb9f276f34421ad98e198427186
/tools/output/stubs/System/Log/FramePrefixer_generated.cpp
bb9a6dcfd2be5185a2973589fc144c2508b7b478
[]
no_license
fzn7/rts
ff0f1f17bc01fe247ea9e6b761738f390ece112e
b63d3f8a72329ace0058fa821f8dd9a2ece1300d
refs/heads/master
2021-09-04T14:09:26.159157
2018-01-19T09:25:56
2018-01-19T09:25:56
103,816,815
0
2
null
2018-05-22T10:37:40
2017-09-17T09:17:14
C++
UTF-8
C++
false
false
825
cpp
FramePrefixer_generated.cpp
#include <iostream> /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ /** * This eventually prefixes log records with the current frame number. */ #include "System/maindefines.h" #include <cstdarg> #include <cstring> #ifdef __cplusplus extern "C" { #endif // GlobalSynced makes sure this can not be dangling static int* frameNumRef = NULL; void log_framePrefixer_setFrameNumReference(int* frameNumReference) { frameNumRef = frameNumReference; } size_t log_framePrefixer_createPrefix(char* result, size_t resultSize) { if (frameNumRef == NULL) { if (resultSize > 0) { result[0] = '\0'; return 1; } return 0; } return (SNPRINTF(result, resultSize, "[f=%07d] ", *frameNumRef)); } #ifdef __cplusplus } // extern "C" #endif
37a6f2e7eebd792d56e0852eb27c6f924564d1c9
43fe4d201f86a83f87589b8f519cd066a94fe7a5
/srcs/julius-sp/JspSocket.h
d61acfda65922208cf88df75f8fb2aea3d0f46a8
[]
no_license
Aharobot/SIGServer
b7ddcfe5627efe5b975a2f30a310b2bf5547b21b
7b7657afe21573e4f08baa24ff8e2fac6a60b7e0
refs/heads/master
2021-01-22T00:13:10.628330
2014-10-31T20:22:31
2014-10-31T20:22:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,417
h
JspSocket.h
#ifndef _JSP_SOCKET_H_ #define _JSP_SOCKET_H_ #include "JspPacket.h" #include <string> namespace Jsp { // ---------------------------------------------------- // ---------------------------------------------------- class Socket { public: // ---------------------------------------------------- // ---------------------------------------------------- Socket(); // ---------------------------------------------------- // ---------------------------------------------------- ~Socket(); // ---------------------------------------------------- /// /// // ---------------------------------------------------- bool connect(const char *hostname, int port); // ---------------------------------------------------- /// /// // ---------------------------------------------------- bool bind(int port); // ---------------------------------------------------- /// /// // ---------------------------------------------------- bool accept(Jsp::Socket &newSock, std::string &hostName); // ---------------------------------------------------- // ---------------------------------------------------- void close(); // ---------------------------------------------------- /// // ---------------------------------------------------- int socket() { return m_sock; } // ---------------------------------------------------- /// // ---------------------------------------------------- bool connected() { return (m_sock < 0) ? false : true; } // ---------------------------------------------------- /// /// // ---------------------------------------------------- int sendData(char *p, int len); // ---------------------------------------------------- /// /// // ---------------------------------------------------- int recvData(char *p, int bufLen, int &recvLen); // ---------------------------------------------------- /// /// // ---------------------------------------------------- bool sendWaveFile(const char *waveFile); // ---------------------------------------------------- /// /// /// /// // ---------------------------------------------------- char *getTextData(char *buf, int buflen); // ---------------------------------------------------- /// /// /// /// // ---------------------------------------------------- int recvPacket(Jsp::Packet **ppPacket); private: int m_sock; }; }; #endif
477d41c158bacec5e138f3929f4958bed387a654
634d076e7df8e8127cfb7a77100879756b0246b1
/src/examples/basic/SkinDlg.h
e1d2a5ee1deb1a7956ea84dbdded1edff19349cd
[]
no_license
kevinzhwl/nxuiengine
f5c6412a209f501d0f1f0166f2975fa616fed319
cacaa906e899bdd95aa3424177a1821ec9936dde
refs/heads/master
2021-01-19T18:55:39.466875
2014-05-25T11:26:46
2014-05-25T11:26:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
712
h
SkinDlg.h
#pragma once #include "resource.h" class CSkinDlg : public CDialogImpl<CSkinDlg> { public: enum { IDD = IDD_DIALOG1}; CSkinDlg(void); ~CSkinDlg(void); BEGIN_MSG_MAP(CSkinDlg) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_ID_HANDLER(IDCANCEL, OnClose) COMMAND_ID_HANDLER(IDOK, OnOK) END_MSG_MAP() LRESULT OnLButtonDown(UINT uMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnInitDialog(UINT uMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled); LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); };
19aa6ec73ead6c65fc6de17ba25585194faa1b7d
58a0ba5ee99ec7a0bba36748ba96a557eb798023
/CodeForces/Complete/1100-1199/1121A-TechnogobletOfFire.cpp
04742acb77775abcebe06e83b41242d74c4f0da7
[ "MIT" ]
permissive
adityanjr/code-DS-ALGO
5bdd503fb5f70d459c8e9b8e58690f9da159dd53
1c104c33d2f56fe671d586b702528a559925f875
refs/heads/master
2022-10-22T21:22:09.640237
2022-10-18T15:38:46
2022-10-18T15:38:46
217,567,198
40
54
MIT
2022-10-18T15:38:47
2019-10-25T15:50:28
C++
UTF-8
C++
false
false
511
cpp
1121A-TechnogobletOfFire.cpp
#include <cstdio> #include <vector> int main(){ long n, m, k; scanf("%ld %ld %ld", &n, &m, &k); std::vector<long> pow(n + 1), sc(n + 1), best(m + 1, 0); for(long p = 1; p <= n; p++){scanf("%ld", &pow[p]);} for(long p = 1; p <= n; p++){ scanf("%ld", &sc[p]); best[sc[p]] = (best[sc[p]] > pow[p]) ? best[sc[p]] : pow[p]; } long cnt(0); for(long p = 0; p < k; p++){long x; scanf("%ld", &x); cnt += (pow[x] < best[sc[x]]);} printf("%ld\n", cnt); return 0; }
46614560156b1cab053c463dbda7744216cde0d8
4c6237dccf0d88085e1477c2678509cd75919fa0
/src/common/graycode_pattern.h
46702984907dd2ba82fce105fda2e73f009a0bd9
[ "BSD-3-Clause" ]
permissive
tomka/copo-tracer
7ebd4670067bf404b19990bcd83db55384e7b87a
7a272acbf19acef9eea8330e503ad95e371bd9b3
refs/heads/master
2021-01-10T19:43:35.757275
2010-10-04T15:35:33
2010-10-04T15:35:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,638
h
graycode_pattern.h
// Copyright: The original source code was provided by Sören König (Soeren.Koenig // AT tu-dresden.de). You are free to modify and/or redistribute that code in // terms of the BSD license. #ifndef GRAYCODE_PATTERN #define GRAYCODE_PATTERN #include "progress.h" #include "math_utils.h" #include "mat.h" #include "image_utils.h" //resx column resolution of projector image //resy row resolution of projector //returns a graycode sequence of rgb images encoding the columns of the projector image //the size of the sequence depends on resx inline rgb_image_sequence create_column_graycode_sequence(int resx, int resy) { rgb_image_sequence pattern_sequence; int n = (int)ceil(ld((float)resx)); for(int b = 0; b < n; b++) { rgb_image pattern(resx,resy); for(int x = 0; x < resx; x++) { bool bit = get_ith_bit_of_x(binary_2_gray(x),b); for(int y = 0; y < resy; y++) { if(bit) pattern(x,y).set(255,255,255); else pattern(x,y).set(0,0,0); } } pattern_sequence.push_back(pattern); } return pattern_sequence; } //resx column resolution of projector image //resy row resolution of projector //returns a graycode sequence of rgb images encoding the rows of the projector image //the size of the sequence depends on resy inline rgb_image_sequence create_row_graycode_sequence(int resx, int resy) { rgb_image_sequence pattern_sequence; int n = (int)ceil(ld((float)resy)); for(int b = 0; b < n; b++) { rgb_image pattern(resx,resy); for(int y = 0; y < resy; y++) { bool bit = get_ith_bit_of_x(binary_2_gray(y),b); for(int x = 0; x < resx; x++) { if(bit) pattern(x,y).set(255,255,255); else pattern(x,y).set(0,0,0); } } pattern_sequence.push_back(pattern); } return pattern_sequence; } //compute correspondence map by decoding a graycode sequence using I_ambient and I_white inline float_image reconstruct_from_graycode(const float_image& I_ambient, const float_image& I_white, const rgb_image_sequence& graycode_sequence) { std::cout << "start decoding graycode...\n"; int n = graycode_sequence.size(); int resx = I_ambient.w(); int resy = I_ambient.h(); float_image I_mean = I_ambient + 0.5f*I_white; float_image u(resx,resy); for(int y = 0;progress((float)y,(float)resy),y < resy; y++) { for(int x = 0; x < resx; x++) { //read graycode int gccode = 0; for(int b = 0; b < n; b++) set_ith_bit_of_x(gccode,b,rgb_2_gray(uchar_2_float(graycode_sequence[b](x,y))) > I_mean(x,y)); //decode u(x,y) = (float)gray_2_binary(gccode); } } std::cout << "decoding graycode complete\n"; return u; } #endif
a1d4865ea5fcd6b3e518fb941e85c7230171c604
76a3c1db4d55592487c0a2e020e7c4035f3904d4
/Algorithms/Divide and Conquer/Merge_Sort.cpp
762669a551bd693772abf6d617d3251f631cd72f
[ "MIT" ]
permissive
Vortez2471/HacktoberFestContribute
5351a02aaac15c6441938e2e7fa6a55a80b075dc
3caac558cc8507373f9a4132f31864798882cb84
refs/heads/master
2020-08-09T04:39:08.773727
2019-10-09T19:13:07
2019-10-09T19:13:07
214,000,075
0
0
MIT
2019-10-09T19:13:09
2019-10-09T18:57:58
C++
UTF-8
C++
false
false
737
cpp
Merge_Sort.cpp
// Merge sort by recursion average time complexity->O(nlogn) #include<bits/stdc++.h> using namespace std; void merge(int arr[],int s,int e) { int mid=(s+e)/2; int i=s; int j=mid+1; int k=s; int temp[100]; while(i<=mid&&j<=e) { if(arr[i]<arr[j]) temp[k++]=arr[i++]; else temp[k++]=arr[j++]; } while(i<=mid) temp[k++]=arr[i++]; while(j<=e) temp[k++]=arr[j++]; for(int i=s;i<=e;i++) arr[i]=temp[i]; } void mergesort(int arr[],int s,int e) { if(s==e) return; int mid=(s+e)/2; mergesort(arr,s,mid); mergesort(arr,mid+1,e); merge(arr,s,e); } int main() { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; mergesort(arr,0,n-1); for(int i=0;i<n;i++) cout<<arr[i]<<" "; }
41a32a78a718d8dac2d9783e57a1e66e0627151f
d3b39332633b8d6a1ef462686ac569d453edb175
/player.h
61808c9a5a014f2812c5fde2430d8549834d5928
[]
no_license
MarioMartinezA/Pacman
3f5d4adca98a73a47aad745a18fb7208e42b80f2
43d2c033df43fff5ca596f413b3cf642e46a8dbf
refs/heads/master
2016-09-14T01:32:27.307837
2016-05-24T17:03:56
2016-05-24T17:03:56
59,591,643
0
0
null
null
null
null
UTF-8
C++
false
false
3,872
h
player.h
//************************************************************************** // player.h // Class Name: Player // // Summary: Constructs the Pac-Man player object for the game which the user // will control during the game. Pac-Man is able to move throughout the // board using the up, down, left, and right arrow keys. // // Author: Mario // Created: 24 April 2016 // Summary of Modifications: // //************************************************************************** #pragma once #ifndef PLAYER_H #define PLAYER_H #include "character.h" class Player : public Character //Player inherits from the Character class { private: int direction; int movementSpeed; int counterWalking; bool isAlive; bool upKeyPressed; bool downKeyPressed; bool leftKeyPressed; bool rightKeyPressed; int lives; public: Player(); //************************************************************************** // Summary: Constructs the default Pac-Man character that the user will // be able to control during the game. // Precondition: The gameboard is constructed. // Postcondition: the Player object is created and is set to appear at its // default position on the gameboard. //************************************************************************** // void update(); //************************************************************************** // Summary: This method updates the Player and its respective rectangle // while the Player is being controlled by the user. // Precondition: The Player object is constructed and is able to be controlled // by the user using the keyboard arrow keys. // Postcondition: The Player's position is updated throughout the board. //************************************************************************** // void updateMovement(); //************************************************************************** // Summary: Allows for the Player object to move depending on which key // the user is pressing. // Precondition: The object is created and able to change position on the // gameboard. // Postcondition: The Player object moves throughout the board in accordance // with which key is pressed by the user. //************************************************************************** // int getDirection()const { return direction; } //************************************************************************** // Summary: Returns the current direction of Pac-Man. // Precondition: The Player object is created and the user is able to control // the Player's movements. // Postcondition: Returns the integer value for direction. //************************************************************************** // void setLives(int lives) { this->lives = lives; } //************************************************************************** // Summary: Sets the number of lives the Player has. // Precondition: The Player object is created and is still alive. // Postcondition: The number of lives for the Player is set. //************************************************************************** // int getLives()const { return lives; } //************************************************************************** // Summary: Returns the number of lives the Player object as at any given time. // Precondition: The object is created and has lives. // Postcondition: The number of lives is returned. //************************************************************************** // void playerDeath(); //************************************************************************** // Summary: Causes the player to cease movement once a life is lost. // Precondition: The object has collided with an object of the Ghost class. // Postcondition: The player stops moveing and dies. //************************************************************************** // }; #endif
09b21f7e0c2c37d0d2b6fea406f3df60a3bdad01
f04fc12f8426bb074f97e85917cec99ebcce9313
/widgets/fullscreen_widget.h
ee7a76cc6a37e1d2f2efa792efcc034012bce59f
[]
no_license
UrekMazin0/makaka_make_gif_qt_cpp
8321dbbfed37c1a2f2b6f12ba97738f30a278800
4ff11d8e74d287ead7b27296ee0ed8e3f639094f
refs/heads/main
2023-07-10T13:59:44.150203
2021-08-15T09:29:16
2021-08-15T09:29:16
322,869,772
1
0
null
null
null
null
UTF-8
C++
false
false
983
h
fullscreen_widget.h
#ifndef FULLSCREEN_WIDGET_H #define FULLSCREEN_WIDGET_H #include <QWidget> #include <QRubberBand> #include <QPoint> #include <QMouseEvent> #include <QPixmap> #include <QScreen> #include <QLabel> #include <QShortcut> #include <QPalette> #include <QRect> class FullScreen_Widget : public QWidget { Q_OBJECT public: explicit FullScreen_Widget(QWidget *parent = nullptr); void show_screenshot(QPixmap input); QRect rubberBand_rect; private: QRubberBand * rubberBand; QPoint rubberBand_point; QPixmap ScreenShot; QLabel * mainLabel; QShortcut * key_Esc; QShortcut * key_Enter; QPalette rubberBand_palette; signals: void signalEsc(); void signalEnter(); protected slots: void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void slotShortcutEsc(); void slotShortcutEnter(); }; #endif // FULLSCREEN_WIDGET_H
9c32afdb235544df3257a59c5c982bd1ec956459
21afc8455a6d396e0247dec0705b16019d2f6b51
/Uebungen (alles andere)/sternchen.cpp
735a509d930813cb627b416af6928ca979150515
[]
no_license
Yleisnero/ProgrammingStuff
8bc903b5b435fe772cab05993048acf475f142b3
1a12edb688ecb6133466c9864536447da7a4c9d1
refs/heads/master
2021-06-24T18:55:51.434666
2019-04-05T07:21:32
2019-04-05T07:21:32
130,868,727
1
1
null
null
null
null
UTF-8
C++
false
false
262
cpp
sternchen.cpp
#include "std_lib_facilities.h" void sterne(int anzahl){ for(int i = 1; i < anzahl+1; i++){ for(int j = 1; j < anzahl+1; j++){ if(j <= i){ cout << j; }else{ cout << '*'; } } cout << endl; } } int main(){ sterne(7); return 0; }
02326cb189db21dc70c7eb8c3560cf53d382208d
d1f382dd8090791eca8813bc61d4829c43349a0e
/level3/12904.cpp
f5955b0954f1283eaaaefedb958e46087ae434c5
[]
no_license
kangyeop/algorithm
0f12ac33acbfc6a7c20db300d51a1a22c0b0429b
d39587ad2b0832d86efcec70a1f2a4f5ec557cc9
refs/heads/master
2023-04-24T09:54:21.300288
2021-05-07T06:11:44
2021-05-07T06:11:44
308,500,889
2
0
null
null
null
null
UTF-8
C++
false
false
750
cpp
12904.cpp
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int solution(string s) { int answer = 0; int n = s.size(); vector<vector<int>> arr; arr.assign(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) { arr[i][i] = 1; answer = 1; } for (int i = 0; i < n - 1; i++) { if (s[i] == s[i + 1]) { arr[i][i + 1] = 1; answer = 2; } } for (int i = 3; i <= n; i++) { for (int j = 0; j < n - i + 1; j++) { int k = j + i - 1; if (s[j] == s[k] && arr[j + 1][k - 1]) { arr[j][k] = 1; answer = max(answer, i); } } } return answer; }
eb4c26a61fdf3d253128140d04a61d72f400c6ad
be1eb8259efefefdb17b396f5023fbee98f637cc
/LCFunction/LCFunctionValueMap.cpp
6b50a04ce9a337d89bd1be2ab01a59c43f28e991
[]
no_license
AOE-khkhan/LOCOInterpolate
e212496f5b7007989ba2c1b471b0f5490fe20894
7e7210c7be198f27c39b48d3306159446b4cdf1c
refs/heads/master
2021-09-21T11:11:18.909324
2018-08-24T22:20:51
2018-08-24T22:20:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
530
cpp
LCFunctionValueMap.cpp
#include <iostream> #include "LCFunctionValueMap.h" #include "LCRealFunctionValueMap.h" #include "LCRealFunctionValue.h" #include "LCError.h" #include <ctime> LCFunctionValueMap::LCFunctionValueMap() { } LCError LCFunctionValueMap::newMapFromShapePair(LCFunctionValue *sourceShape, LCFunctionValue *targetShape, LCFunctionValueMap **result) { LCError err; if (dynamic_cast<LCRealFunctionValue*>(sourceShape)) { *result = new LCRealFunctionValueMap(); return err; } return LCError("Shape info type not specified"); }
2328feaa7c96db2712f6fb0e10294f18bdd394e2
ec85f724a5ebb25fccc0445c060a775a93262607
/Soccer/Soccer/main.cpp
40a834b7ba46e9da547cc6e0105428c94a4d46e4
[]
no_license
artemon87/C-
3f921660d9779fd3880890912b932868ce461644
0a9808ac14a6e765faf191e6d6c2726e6bf45e84
refs/heads/master
2021-01-19T04:46:06.371767
2017-04-06T06:32:23
2017-04-06T06:32:23
87,394,405
0
0
null
null
null
null
UTF-8
C++
false
false
615
cpp
main.cpp
// // main.cpp // Soccer // // Created by Artem Kovtunenko on 10/5/14. // Copyright (c) 2014 Artem Kovtunenko. All rights reserved. // #include <iostream> #include "Player.h" #include "PlayerAgent.h" using namespace std; int main() { // insert code here... PlayerAgent artem("Artem", "Kovtunenko", 16); //artem.setAgentID(); int id=artem.getAgentID(); cout<<"ID : "<<id<<endl; artem.lucky(); cout<<artem.getFirstName()<<endl; PlayerAgent max; max.setPlayer("Max", "Kovt", 7); int temp=max.getNumber(); cout<<"Max's number: "<<temp<<endl; return 0; }
368421815272772b36e5a49583a2d5ea503974fa
62ddf1369f0be56e1eca4642655e0dbf2581320f
/Render.cpp
adaca70836061aca93c50440ba6c37b8a792ee01
[]
no_license
eherrerad94/PaintOpenGL
5f1bc4f03061e09c6c6a74c3d3918337ae40a454
c782be044d7b0650b302fb71104239e31d85a4d0
refs/heads/master
2021-05-31T23:09:35.280074
2016-04-07T23:14:02
2016-04-07T23:14:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,558
cpp
Render.cpp
#include "Render.h" #include <GL/glut.h> #include <iostream> #include <string> #include <sstream> #include <stdlib.h> #include <stdio.h> #include <math.h> using namespace std; Render::Render() { wh = 600; ww = 800; wx1 = 800; wy1 = 600; size = 1; vertices = 5; fill = 0; flag = 0; a1 = a2 = a3 = b1 = b2 = b3 = 0; punteada = false; r = 255; g = 255; b = 255; } int Render::get_wh() { return wh; } int Render::get_ww() { return ww; } void Render::reset() { a1 = a2 = a3 = b1 = b2 = b3 = 0; } void Render::set_ww(int ww) { this->ww = ww; } void Render::set_wh(int wh) { this->wh = wh; } void Render::loop() { glutMainLoop(); } void Render::palette(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) /* to draw the COLOR PALETTE */ { glBegin(GL_QUADS); glVertex2f(x1, y1); glVertex2f(x2, y2); glVertex2f(x3, y3); glVertex2f(x4, y4); glEnd(); } void Render::edgedetect(float x1, float y1, float x2, float y2, int *le, int *re) { float mx, x, temp; if((y2-y1)<0) { temp=y1; y1=y2; y2=temp; temp=x1; x1=x2; x2=temp; } if((y2-y1)!=0) mx=(x2-x1)/(y2-y1); else mx=x2-x1; x=x1; for(int i=y1;i<=y2;i++) { if(x<(float)le[i]) le[i]=(int)x; if(x>(float)re[i]) re[i]=(int)x; x+=mx; } } /* Llenar poligono mediante algoritmo de scaneo de linea*/ void Render::scanfill(int num1, int num2) { int le[1000], re[1000]; int p, q; int bottom, top; for(p=0;p<wh;p++) { le[p]=ww; re[p]=0; } for(p=num1;p<num2;p++) { edgedetect(a[p][0], a[p][1], a[p+1][0], a[p+1][1], le, re); } edgedetect(a[num2][0], a[num2][1], a[num1][0], a[num1][1], le, re); for(q=0;q<wh;q++) le[q]=le[q]+1; bottom=0; while(re[bottom]<le[bottom]) bottom++; bottom++; top=wh-1; while(re[top]<le[top]) top--; for(q=bottom;q<top;q++) { if(le[q]<=re[q]) { for(p=(int)le[q];p<(int)re[q];p++) draw_pixel(p, q); } } } void Render::eraser(int x, int y) { y = wh-y; set_color(255, 255, 255); if(x>wh/10+1 && wh/10<y && y<wh-31) { glBegin(GL_POLYGON); glVertex2f(x, y); glVertex2f(x+5, y); glVertex2f(x+5, y+5); glVertex2f(x, y+5); glEnd(); glFlush(); } } void Render::paint(int x, int y) { y = wh-y; if(x>wh/10+1 && wh/10<y && y<wh-31) { glBegin(GL_POLYGON); glVertex2f(x, y); glVertex2f(x+4+size, y); glVertex2f(x+4+size, y+4+size); glVertex2f(x, y+4+size); glEnd(); glFlush(); } } void Render::detect_point(int num1, int num2, int x, int y) { int le[1000], re[1000]; int p, q; for(p=0;p<wh;p++) { le[p]=ww; re[p]=0; } for(p=num1;p<num2;p++) { edgedetect(a[p][0], a[p][1], a[p+1][0], a[p+1][1], le, re); } edgedetect(a[num2][0], a[num2][1], a[num1][0], a[num1][1], le, re); for(q=0;q<wh;q++) { if(le[q]<=re[q]) { for(p=(int)le[q];p<(int)re[q];p++) { if(x==p && y==q) flag=num1; } } } } void Render::set_color(float r, float g, float b) { r = r / 255; g = g / 255; b = b / 255; glColor3f(r, g, b); } void Render::set_color_background(float r, float g, float b, float a) { r = r / 255; g = g / 255; b = b / 255; a = a / 255; glClearColor(r,g,b,a); glClear(GL_COLOR_BUFFER_BIT); } void Render::set_font(void *font) { currentFont=font; } void Render::drawstring(float x,float y,float z,string s, float r, float g, float b) { glRasterPos3f(x,y,z); for (string::iterator i = s.begin(); i != s.end(); ++i) { glutBitmapCharacter(currentFont,*i); } set_color(r,g,b); } void Render::draw_toolbar() { set_color(207, 219, 173); glPointSize(1); glLineWidth(1); glRectf(0,wh/10+1,wh/10,wh-(wh/20)-1); /* dibujar barra de herramientas */ glRectf(0, 0, ww, wh/10); /* dibujar area de color */ glRectf(0,wh-(wh/20), ww, wh); /* dibujar area de menu*/ } void Render::draw_palette() { set_color(0, 0, 0); palette(6*wh/60+1, wh/60, 6*wh/60+1, wh/20-1, 8*wh/60-1, wh/20-1, 8*wh/60-1, wh/60); set_color(255, 255, 255); palette(6*wh/60+1, wh/20+1, 6*wh/60+1, wh/12, 8*wh/60-1, wh/12, 8*wh/60-1, wh/20+1); set_color(239, 223, 132); palette(8*wh/60+1, wh/60, 8*wh/60+1, wh/20-1, 10*wh/60-1, wh/20-1, 10*wh/60-1, wh/60); set_color(232, 99, 113); palette(8*wh/60+1, wh/20+1, 8*wh/60+1, wh/12, 10*wh/60-1, wh/12, 10*wh/60-1, wh/20+1); set_color(80, 186, 188); palette(10*wh/60+1, wh/60, 10*wh/60+1, wh/20-1, 12*wh/60-1, wh/20-1, 12*wh/60-1, wh/60); set_color(161, 185, 196); palette(10*wh/60+1, wh/20+1, 10*wh/60+1, wh/12, 12*wh/60-1, wh/12, 12*wh/60-1, wh/20+1); set_color(241, 144, 86); palette(12*wh/60+1, wh/60, 12*wh/60+1, wh/20-1, 14*wh/60-1, wh/20-1, 14*wh/60-1, wh/60); set_color(180, 231, 254); palette(12*wh/60+1, wh/20+1, 12*wh/60+1, wh/12, 14*wh/60-1, wh/12, 14*wh/60-1, wh/20+1); set_color(203, 143, 244); palette(14*wh/60+1, wh/60, 14*wh/60+1, wh/20-1, 16*wh/60-1, wh/20-1, 16*wh/60-1, wh/60); set_color(51, 255, 90); palette(14*wh/60+1, wh/20+1, 14*wh/60+1, wh/12, 16*wh/60-1, wh/12, 16*wh/60-1, wh/20+1); set_color(254, 139, 180); palette(16*wh/60+1, wh/60, 16*wh/60+1, wh/20-1, 18*wh/60-1, wh/20-1, 18*wh/60-1, wh/60); set_color(248, 214, 36); palette(16*wh/60+1, wh/20+1, 16*wh/60+1, wh/12, 18*wh/60-1, wh/12, 18*wh/60-1, wh/20+1); set_color(248, 85, 94); palette(18*wh/60+1, wh/60, 18*wh/60+1, wh/20-1, 20*wh/60-1, wh/20-1, 20*wh/60-1, wh/60); set_color(76, 106, 141); palette(18*wh/60+1, wh/20+1, 18*wh/60+1, wh/12, 20*wh/60-1, wh/12, 20*wh/60-1, wh/20+1); set_color(188, 217, 85); palette(20*wh/60+1, wh/60, 20*wh/60+1, wh/20-1, 22*wh/60-1, wh/20-1, 22*wh/60-1, wh/60); set_color(248, 214, 139); palette(20*wh/60+1, wh/20+1, 20*wh/60+1, wh/12, 22*wh/60-1, wh/12, 22*wh/60-1, wh/20+1); set_color(255, 171, 69); palette(22*wh/60+1, wh/60, 22*wh/60+1, wh/20-1, 24*wh/60-1, wh/20-1, 24*wh/60-1, wh/60); set_color(152, 102, 41); palette(22*wh/60+1, wh/20+1, 22*wh/60+1, wh/12, 24*wh/60-1, wh/12, 24*wh/60-1, wh/20+1); } void Render::draw_circle(float p, float q, float r) { float d = 1-r; float x = 0; float y = r; while(y>x) { plotpixels(p, q, x, y); if(d<0) d+=2*x+3; else { d+=2*(x-y)+5; --y; } ++x; } plotpixels(p, q, x, y); } void Render::plotpixels(float p, float q, float x, float y) { draw_pixel(x+p, y+q); draw_pixel(-x+p, y+q); draw_pixel(x+p, -y+q); draw_pixel(-x+p, -y+q); draw_pixel(y+p, x+q); draw_pixel(-y+p, x+q); draw_pixel(y+p, -x+q); draw_pixel(-y+p, -x+q); } void Render::plotpixels1(float p, float q, float x, float y) { draw_pixel1(x+p, y+q); draw_pixel1(-x+p, y+q); draw_pixel1(x+p, -y+q); draw_pixel1(-x+p, -y+q); draw_pixel1(y+p, x+q); draw_pixel1(-y+p, x+q); draw_pixel1(y+p, -x+q); draw_pixel1(-y+p, -x+q); } void Render::draw_toolbox() { set_color(208, 210, 198); glBegin(GL_QUADS); glVertex2f(2, wh-(wh/20)-1); glVertex2f(wh/10-2, wh-(wh/20)-1); glVertex2f(wh/10-2,7*wh/20); glVertex2f(2, 7*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(2, wh-(wh/20)-1); glVertex2f(wh/10-2, wh-(wh/20)-1); glVertex2f(wh/10-2,7*wh/20); glVertex2f(2, 7*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(wh/20, wh-(wh/20)-1); glVertex2f(wh/20, 11*wh/20); glVertex2f(2, 18*wh/20); glVertex2f(wh/10-2, 18*wh/20); glVertex2f(2, 17*wh/20); glVertex2f(wh/10-2, 17*wh/20); glVertex2f(2, 16*wh/20); glVertex2f(wh/10-2, 16*wh/20); glVertex2f(2, 15*wh/20); glVertex2f(wh/10-2, 15*wh/20); glVertex2f(2, 14*wh/20); glVertex2f(wh/10-2, 14*wh/20); glVertex2f(2, 13*wh/20); glVertex2f(wh/10-2, 13*wh/20); glVertex2f(2, 12*wh/20); glVertex2f(wh/10-2, 12*wh/20); glVertex2f(2, 11*wh/20); glVertex2f(wh/10-2, 11*wh/20); glVertex2f(2, 10*wh/20); glVertex2f(wh/10-2, 10*wh/20); glVertex2f(2, 9*wh/20); glVertex2f(wh/10-2, 9*wh/20); glVertex2f(2, 8*wh/20); glVertex2f(wh/10-2, 8*wh/20); glEnd(); } void Render::draw_pixel(float x, float y) { if(x>wh/10+1 && wh/10<y && y<wh-31) { if(fill==1) glPointSize(2); else glPointSize(size); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); } } void Render::draw_pixel1(float x, float y) { set_color(115, 29, 29); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); } void Render::drawpoint(int x, int y) { y=wh-y; if(x>wh/10+1 && wh/10<y && y<wh-31) { glPointSize(size); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); glFlush(); } } void Render::draw_btn_line() { glBegin(GL_LINES); glVertex2f(4*wh/60, 18.8*wh/20); glVertex2f(5*wh/60, 18.2*wh/20); glEnd(); } void Render::draw_btn_circle() { float p = 9*wh/120; float q = 16.5*wh/20; float r = wh/60; int d = 1-(int)r; int x = 0; int y = (int)r; while(y>x) { plotpixels1(p, q, x, y); if(d<0) d+=2*x+3; else { d+=2*(x-y)+5; --y; } ++x; } plotpixels1(p, q, x, y); } void Render::draw_btn_triangle() { set_color(242, 93, 80); glBegin(GL_TRIANGLE_FAN); glVertex2f(wh/40, 17.8*wh/20); glVertex2f(wh/120, 17.2*wh/20); glVertex2f(5*wh/120, 17.2*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(wh/40, 17.8*wh/20); glVertex2f(wh/120, 17.2*wh/20); glVertex2f(5*wh/120, 17.2*wh/20); glEnd(); } void Render::draw_btn_rectangle() { set_color(67, 202, 217); glBegin(GL_TRIANGLE_FAN); glVertex2f(7*wh/120, 17.8*wh/20); glVertex2f(11*wh/120-2, 17.8*wh/20); glVertex2f(11*wh/120-2, 17.2*wh/20); glVertex2f(7*wh/120, 17.2*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(7*wh/120, 17.8*wh/20); glVertex2f(11*wh/120-2, 17.8*wh/20); glVertex2f(11*wh/120-2, 17.2*wh/20); glVertex2f(7*wh/120, 17.2*wh/20); glEnd(); } void Render::draw_btn_pencil() { set_color(0, 0, 0); glBegin(GL_TRIANGLES); glVertex2f(3*wh/120-1, 18.10*wh/20); glVertex2f(wh/60+2, 18.3*wh/20); glVertex2f(2*wh/60-4, 18.3*wh/20); glEnd(); set_color(229, 225, 14); glBegin(GL_QUADS); glVertex2f(wh/60+2, 18.3*wh/20); glVertex2f(wh/60+2, 18.8*wh/20); glVertex2f(2*wh/60-4, 18.8*wh/20); glVertex2f(2*wh/60-4, 18.3*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(wh/60+2, 18.3*wh/20); glVertex2f(wh/60+2, 18.8*wh/20); glVertex2f(2*wh/60-4, 18.8*wh/20); glVertex2f(2*wh/60-4, 18.3*wh/20); glEnd(); } void Render::draw_btn_pencil2() { set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(wh/120, 16.2*wh/20); glVertex2f(5*wh/120, 16.2*wh/20); glVertex2f(5*wh/120, 16.4*wh/20); glVertex2f(3*wh/120, 16.4*wh/20); glVertex2f(4*wh/120, 16.8*wh/20); glVertex2f(2*wh/120, 16.8*wh/20); glEnd(); } void Render::draw_btn_eraser() { set_color(120, 125, 217); glBegin(GL_QUADS); glVertex2f(3.2*wh/60, 15.7*wh/20); glVertex2f(5.1*wh/60, 15.7*wh/20); glVertex2f(5.5*wh/60, 15.3*wh/20); glVertex2f(3.6*wh/60, 15.3*wh/20); glEnd(); set_color(242, 153, 177); glBegin(GL_QUADS); glVertex2f(4.2*wh/60, 15.7*wh/20); glVertex2f(5.1*wh/60, 15.7*wh/20); glVertex2f(5.5*wh/60, 15.3*wh/20); glVertex2f(4.6*wh/60, 15.3*wh/20); glEnd(); } void Render::draw_btn_brush() { glPointSize(1); set_color(242, 110, 68); glBegin(GL_QUADS); glVertex2f(7*wh/120, 14.45*wh/20); glVertex2f(10*wh/120, 14.45*wh/20); glVertex2f(10*wh/120, 14.55*wh/20); glVertex2f(7*wh/120, 14.55*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(10*wh/120, 14.45*wh/20); glVertex2f(11*wh/120, 14.4*wh/20); glVertex2f(10*wh/120, 14.55*wh/20); glVertex2f(11*wh/120, 14.6*wh/20); glVertex2f(10*wh/120, 14.47*wh/20); glVertex2f(11*wh/120, 14.47*wh/20); glVertex2f(10*wh/120, 14.53*wh/20); glVertex2f(11*wh/120, 14.53*wh/20); glEnd(); } void Render::draw_btn_fill_color() { set_color(229, 196, 74); glBegin(GL_QUADS); glVertex2f(2*wh/120, 14.6*wh/20); glVertex2f(3*wh/120+1, 14.2*wh/20); glVertex2f(5*wh/120-2, 14.35*wh/20); glVertex2f(4*wh/120-4, 14.75*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(2*wh/120, 14.6*wh/20); glVertex2f(3*wh/120+1, 14.2*wh/20); glVertex2f(5*wh/120-2, 14.35*wh/20); glVertex2f(4*wh/120-4, 14.75*wh/20); glEnd(); set_color(0, 0, 0); glPointSize(3); glBegin(GL_POINTS); glVertex2f(2*wh/120-2, 14.6*wh/20-2); glEnd(); glPointSize(1.5); glBegin(GL_POINTS); glVertex2f(2*wh/120-2, 14.6*wh/20-6); glEnd(); } void Render::draw_btn_air_brush() { for(int i=0;i<40;i++) { int j=rand()%15; int k=rand()%15; glBegin(GL_POINTS); glVertex2f(wh/120+j,15.8*wh/20-k); glEnd(); } } void Render::draw_btn_increment() { set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(3.3*wh/120, 13.2*wh/20); glVertex2f(3.3*wh/120, 13.85*wh/20); glEnd(); set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(1.3*wh/120, 13.5*wh/20); glVertex2f(5.3*wh/120, 13.5*wh/20); glEnd(); } void Render::draw_btn_decrement() { set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(7.3*wh/120, 13.5*wh/20); glVertex2f(10.5*wh/120, 13.5*wh/20); glEnd(); } void Render::draw_btn_solid_line() { set_color(0, 0, 0); glBegin(GL_TRIANGLE_FAN); glVertex2f(1.3*wh/120, 12.5*wh/20); glVertex2f(5.3*wh/120, 12.5*wh/20); glVertex2f(5.3*wh/120, 12.55*wh/20); glVertex2f(1.3*wh/120, 12.55*wh/20); glEnd(); } void Render::draw_btn_dotted_line() { set_color(0, 0, 0); glBegin(GL_LINES); glVertex2f(7.3*wh/120, 12.5*wh/20); glVertex2f(8.1*wh/120, 12.5*wh/20); glVertex2f(8.4*wh/120, 12.5*wh/20); glVertex2f(9.0*wh/120, 12.5*wh/20); glVertex2f(9.3*wh/120, 12.5*wh/20); glVertex2f(9.9*wh/120, 12.5*wh/20); glVertex2f(10.2*wh/120, 12.5*wh/20); glVertex2f(10.8*wh/120, 12.5*wh/20); glEnd(); } void Render::draw_btn_vertex_increment() { set_color(0, 0, 0); glBegin(GL_TRIANGLE_FAN); glVertex2f(1.3*wh/120, 11.4*wh/20); glVertex2f(3.1*wh/120, 11.7*wh/20); glVertex2f(4.9*wh/120, 11.4*wh/20); glEnd(); } void Render::draw_btn_vertex_decrement() { set_color(0, 0, 0); glBegin(GL_TRIANGLE_FAN); glVertex2f(7.0*wh/120, 11.7*wh/20); glVertex2f(9.0*wh/120, 11.4*wh/20); glVertex2f(10.6*wh/120, 11.7*wh/20); glEnd(); } void Render::draw_btn_show_size() { drawstring(1.1*wh/120, 10.4*wh/20, 0.0, "size: ",0,0,0); } void Render::draw_btn_show_vertex() { drawstring(1.3*wh/120, 9.4*wh/20, 0.0, "lados: ",0,0,0); } void Render::draw_btn_poligono() { regularPolygon(6.0*wh/120, 8.5*wh/20,10); } void Render::draw_btn_background() { palette(wh/30, 10.8*wh/30,2*wh/30, 10.8*wh/30, 2*wh/30, 11.8*wh/30, wh/30, 11.8*wh/30); } void Render::regularPolygon(int x, int y, int radius) { double PI = 3.14; int xa[vertices],ya[vertices]; double alfa = (2 * PI )/vertices; for (int a=0 ; a<vertices ; a++) { xa[a] = x + (radius * cos((a-1)*alfa)); ya[a] = y + (radius * sin((a-1)*alfa)); } for(int a=0;a<vertices;a++) { if(a==vertices-1) { glBegin(GL_LINES); glVertex2f(xa[a],ya[a]); glVertex2f(xa[0],ya[0]); glEnd(); } else { glBegin(GL_LINES); glVertex2f(xa[a],ya[a]); glVertex2f(xa[a+1],ya[a+1]); glEnd(); } } } void Render::draw_size() { string s; stringstream out; out << size; s = out.str(); drawstring(7.0*wh/120, 10.4*wh/20, 0.0, s,0,0,0); } void Render::draw_vertex() { string ss; stringstream out2; out2 << vertices; ss = out2.str(); drawstring(8.0*wh/120, 9.4*wh/20, 0.0, ss,0,0,0); } void Render::increment_vertex() { if(vertices == 8) vertices = 8; else vertices++; } void Render::decrement_vertex() { if(vertices == 5) vertices = 5; else vertices--; } void Render::increment_size() { size++; } void Render::decrement_size() { if(size == 1) size = 1; else size--; } /* void Render::draw_lines(float a1, float a2, bool punteada) { if(punteada) { glLineStipple(3,0xeeee); glEnable(GL_LINE_STIPPLE); glLineWidth(size); glBegin(GL_LINE_STRIP); glVertex2f(a2, b2); glVertex2f(a1, b1); glEnd(); } else { glLineWidth(size); glBegin(GL_LINES); glVertex2f(a2, b2); glVertex2f(a1, b1); glEnd(); } reset(); } void Render::draw_triangle(float a1, float a2, float a3, float b1, float b2, float b3, int m) { glLineWidth(size); glBegin(GL_LINE_LOOP); glVertex2f(a3, b3); glVertex2f(a2, b2); glVertex2f(a1, b1); glEnd(); m++; a[m][0]=a3; a[m][1]=b3; m++; a[m][0]=a2; a[m][1]=b2; m++; a[m][0]=a1; a[m][1]=b1; m++; a[m][0]='$'; a[m][1]='$'; reset(); } void Render::draw_rectangle(float a1, float a2, float b1, float b2, int m) { glLineWidth(size); glBegin(GL_LINE_LOOP); glVertex2f(a2, b2); glVertex2f(a1, b2); glVertex2f(a1, b1); glVertex2f(a2, b1); glEnd(); m++; a[m][0]=a2; a[m][1]=b2; m++; a[m][0]=a1; a[m][1]=b2; m++; a[m][0]=a1; a[m][1]=b1; m++; a[m][0]=a2; a[m][1]=b1; m++; a[m][0]='$'; a[m][1]='$'; reset(); } */ void Render::lineaPunteada(bool punteada) { this->punteada = punteada; cout << punteada << endl; }
8edf4583e58852b131f231e8d89ddcd755c66b31
bd57e8411bfd1dd07d0b7b09d2e80029b1af4066
/SCRambl/Configuration.cpp
a878b57cd61073f988592a2974d9e05fa2061733
[ "MIT" ]
permissive
indirivacua/SCRambl
a80d8b911cc177ee5f70ec01b8605ec96d5c5860
cf6eb64272b4126094c77a720c2402ed47822a50
refs/heads/master
2021-12-08T04:23:30.100043
2016-02-09T01:24:05
2016-02-09T01:24:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,143
cpp
Configuration.cpp
#include "stdafx.h" #include "Configuration.h" #include <memory> namespace SCRambl { /* XMLObject */ void* XMLObject::LoadXML(XMLNode node, void* theptr) { if (m_Func) m_Func(node, theptr); return theptr; } /* XMLConfig */ void XMLConfig::LoadChildXML(XMLRange root, void* ptr) { if (m_Objects.empty()) return; for (auto node : root) { auto it = m_Objects.find(node.Name()); if (it != m_Objects.end()) { auto& obj = it->second; auto new_ptr = obj.LoadXML(node, ptr); obj.LoadChildXML(node.Children(), new_ptr); continue; } } } XMLConfig* XMLConfig::AddClass(const std::string& name) { auto pr = m_Objects.emplace(name, XMLObject()); return pr.second ? &pr.first->second : nullptr; } /* XMLConfiguration */ void XMLConfiguration::LoadXML(XMLNode main_node) { if (!m_Objects.empty()) { for (auto node : main_node) { auto it = m_Objects.find(node.Name()); if (it != m_Objects.end()) { auto& obj = it->second; obj.LoadChildXML(node.Children(), obj.LoadXML(node)); continue; } } } } XMLConfiguration::XMLConfiguration(std::string name) : m_Name(name) { } }
cbf840a26146c5c0e1be9373a310edbe85f8d2a1
34ff67fc6de3bf288d2b421756a0e25bd0afa713
/fhwa2_gui/src/fhwa2_displays_panel.h
4714f46f9b680dc046c6b802ddb7046c2e780d00
[]
no_license
GAVLab/fhwa2_viz
77e68fa032f8ea2095e5e8cbdeb643f9e451775a
66a8c98230c5a9b48de687cc3d73b80b0846a54c
refs/heads/master
2016-09-10T03:26:56.051265
2012-12-10T03:53:39
2012-12-10T03:53:39
4,350,836
1
0
null
null
null
null
UTF-8
C++
false
false
603
h
fhwa2_displays_panel.h
#ifndef FHWA2_MENU_PANEL_H #define FHWA2_MENU_PANEL_H #include <string> #include <ros/ros.h> #include <rviz/panel.h> #include <rviz/displays_panel.h> class QComboBox; namespace fhwa2_gui { class FHWA2DisplaysPanel : public rviz::Panel { Q_OBJECT public: FHWA2DisplaysPanel( QWidget* parent = 0); // virtual ~FHWA2DisplaysPanel(); protected Q_SLOTS: // receives from void updateTargetSensor(QString sensor); protected: rviz::DisplaysPanel* displays_panel_; std::string target_sensor_; QComboBox* target_selector_; }; }; // end namespace #endif // FHWA2_MENU_PANEL_H
c79134ee1450ebf55ec0a237036c59121b32f833
d8c3f0fb09a1cf987150c08a66685b3b303a3ce4
/debug.h
8ace393b2a98f545013259056dcf2a3b6fbc41de
[]
no_license
arbll/BzBot
8735299add3b081582c02fd5d4d894b37f68b002
6bbe82d60f78673e0d9608d6671665664d1652d9
refs/heads/master
2021-05-07T15:56:17.913067
2017-10-27T13:50:48
2017-10-27T13:54:37
108,551,652
1
2
null
null
null
null
UTF-8
C++
false
false
2,248
h
debug.h
#pragma once #include "stdafx.h" #include <iostream> #define BO_DEBUG 1 #if _DEBUG #define WDEBUG_PREFIX(t, f) std::wcout << __FUNCTION__ << "() : " << L##f << std::endl; #define WDEBUG(f) std::wcout << L##f << std::endl; #define WDEBUG0(t, f) WDEBUG_PREFIX(t, f) #define WDEBUG1(t, f, c1) WDEBUG_PREFIX(t, f), c1) #define WDEBUG2(t, f, c1, c2) WDEBUG_PREFIX(t, f), c1, c2) #define WDEBUG3(t, f, c1, c2, c3) WDEBUG_PREFIX(t, f), c1, c2, c3) #define WDEBUG4(t, f, c1, c2, c3, c4) WDEBUG_PREFIX(t, f), c1, c2, c3, c4) #define WDEBUG5(t, f, c1, c2, c3, c4, c5) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5) #define WDEBUG6(t, f, c1, c2, c3, c4, c5, c6) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6) #define WDEBUG7(t, f, c1, c2, c3, c4, c5, c6, c7) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6, c7) #define WDEBUG8(t, f, c1, c2, c3, c4, c5, c6, c7, c8) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6, c7, c8) #define WDEBUG9(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6, c7, c8, c9) #define WDEBUG10(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) #define WDEBUG11(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) WDEBUG_PREFIX(t, f), c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) namespace DebugClient { enum { WDDT_INFO, WDDT_WARNING, WDDT_ERROR }; }; #else # define WDEBUG(t) # define WDEBUG0(t, f) # define WDEBUG1(t, f, c1) # define WDEBUG2(t, f, c1, c2) # define WDEBUG3(t, f, c1, c2, c3) # define WDEBUG4(t, f, c1, c2, c3, c4) # define WDEBUG5(t, f, c1, c2, c3, c4, c5) # define WDEBUG6(t, f, c1, c2, c3, c4, c5, c6) # define WDEBUG7(t, f, c1, c2, c3, c4, c5, c6, c7) # define WDEBUG8(t, f, c1, c2, c3, c4, c5, c6, c7, c8) # define WDEBUG9(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9) # define WDEBUG10(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) # define WDEBUG11(t, f, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) #endif
351a873cbe607633335ce6fbb64c8b92f13bf927
612d853f1040052cc8c238f8c42cff3f24d6464d
/Stegosaurus_CPP_Implementation.cpp
d1af31bbdaa0e6597a458231c119fc5b6888aeab
[]
no_license
MSK998/Stegosaurus_CPP_Implementation
df5dab9618acb4c98f5c3bd26590458a9b9c1281
1c16c8e20a42139eb9565ff28e321bb5239e478e
refs/heads/master
2022-12-23T10:19:01.306617
2020-09-20T23:11:23
2020-09-20T23:11:23
296,316,957
0
0
null
null
null
null
UTF-8
C++
false
false
9,377
cpp
Stegosaurus_CPP_Implementation.cpp
// Stegosaurus_CPP_Implementation.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <iterator> #include <sstream> #include <boost/gil.hpp> #include <boost/gil/extension/io/png.hpp> #include <boost/gil/extension/numeric/sampler.hpp> #include <boost/gil/extension/numeric/resample.hpp> #include <boost/coroutine2/all.hpp> #include "interleaved_ptr.hpp" #include <bitset> namespace gil = boost::gil; /// <summary> /// This method will take a string and convert it into a vector of binary characters. /// </summary> /// /// <param name="data"> /// The typed message. /// </param> /// /// <returns> /// A binary representation of the typed message. /// </returns> std::string EncodeMessage(std::string data) { std::vector<std::string>::iterator characterIterator; std::vector<std::string> generatedData; std::string binaryString; // Loops through the data to convert to a vector of 8 bit binary codes. for (char& _char : data) { generatedData.push_back(std::bitset<8>(_char).to_string()); } // Loops through the vector to convert binary into string. for (characterIterator = generatedData.begin(); characterIterator != generatedData.end(); characterIterator++) { binaryString.append(*characterIterator); } // Returns the binary string return binaryString; } /// <summary> /// Takes a binary string and converts it to ASCII text. /// </summary> /// /// <param name="data"> /// The constructed binary string extracted from the pixel values. /// </param> /// /// <returns> /// Decoded message as string. /// </returns> std::string DecodeMessage(std::string data) { std::stringstream sstream(data); std::string message; while (sstream.good()) { std::bitset<8> bits; // Shifts bits into the bitset. sstream >> bits; // Converts the bits to ASCII characters. char c = char(bits.to_ulong()); // Constructs the characters into a message. message += c; } // Returns the full message. return message; } /// <summary> /// Will change the pixel component value that has been passed to the desired /// odd(representing binary value of '1') or even(representing binary value of '0') value. /// </summary> /// /// <param name="bitValue"> /// Is a '1' or '0' based on the binaryString index value. /// </param> /// /// <param name="pixelValue"> /// The original component value of the pixel. /// </param> /// /// <returns> /// The new odd or even value based on the bitValue. /// </returns> int OddEven(int bitValue, int pixelValue) { int newValue; // If bit value is 0 and the pixel value is odd then decrement pixel component value by 1. if (bitValue == '0' && (pixelValue % 2 != 0)) { newValue = pixelValue - 1; return (newValue); } // If bit value is 1 and the pixel value is even then decrement pixel component value by 1. else if (bitValue == '1' && pixelValue % 2 == 0) { newValue = pixelValue - 1; return (newValue); } // If nothing needs to be done then return the same value. else { newValue = pixelValue; return newValue; } } /// <summary> /// Will encode an rgb8_image_t pixels with the message, using the blue component as a control. /// </summary> /// /// <param name="image"> /// The original image that has been opened and passed into the rgb8_image_t variable. /// </param> /// /// <param name="message"> /// The typed message that the user wants to encode. /// </param> /// /// <returns> /// A modified image with the message encoded within the pixel components. /// </returns> gil::rgb8_image_t EncodeImage(gil::rgb8_image_t image, std::string message) { // Gets the binary string. std::string binaryString = EncodeMessage(message); std::string::iterator binaryStringIterator; // See what the binary string is. std::cout << binaryString << std::endl; // Set the iterator to the beginning of the string. binaryStringIterator = binaryString.begin(); // Creating a view of the image. gil::rgb8_view_t imageView = view(image); auto v = gil::view(image); auto b = v.begin(); // Boolean to check for when the message has been iterated through. bool messageDone = false; while (b != v.end()) { // While there are still pixels in the image. // Set the current pixel to a new pixel object. gil::rgb8_pixel_t pixel = *b; // Set the R value appropriately. pixel[0] = OddEven(*binaryStringIterator, (int)pixel[0]); // See the binary value that was just set. std::cout << (int)pixel[0] % 2 << std::endl; // Move onto the next binary value in the string. std::advance(binaryStringIterator, 1); pixel[1] = OddEven(*binaryStringIterator, (int)pixel[1]); std::cout << (int)pixel[1] % 2 << std::endl; std::advance(binaryStringIterator, 1); // If the end of the message has been reached. if (binaryStringIterator == binaryString.end()) { // If the G value is even, change it to odd to indicate message is done. if ((int)pixel[2] % 2 == 0) { pixel[2] = (int)pixel[2] - 1; std::cout << (int)pixel[2] % 2 << std::endl; // Place the pixel into the image. *b = pixel; // Break out of loops. break; } } else { // Otherwise check if the value is odd, if it is make it even // to indicate that the message is not complete. if ((int)pixel[2] % 2 != 0) { std::cout << (int)pixel[2] % 2 << std::endl; pixel[2] = (int)pixel[2] - 1; } } // Place the modified pixel into the image. *b = pixel; // Increment to the next pixel. b++; } // Return the modified image. return image; } /// <summary> /// Is the initiator method to encode the image with a message. /// </summary> void Encode() { std::string imgpath; // Test image: C:\Users\mwsco\source\repos\Stegosaurus_CPP_Implementation\test.png std::cout << "Please enter the full filepath, with extension:" << std::endl; // Set the image path. std::cin >> imgpath; gil::rgb8_image_t image; // Read the image into an image object. gil::read_image(imgpath, image, gil::png_tag{}); std::string message; std::cout << "Please type a message to be converted into binary code" << std::endl; // Set the message that the user wants to encode. std::cin >> message; // If the message is empty throw error. if (message.empty()) { throw std::invalid_argument("The message can't be nothing."); } // Creates a new image object by calling the EncodeImage method to modify the pixels. gil::rgb8_image_t encodedImage = EncodeImage(image, message); // Save modified image. gil::write_view("encode_out.png", view(encodedImage), gil::png_tag{}); } /// <summary> /// Will scan through the supplied image and construct a binary string /// this string will then get passed to the DecodeMessage to be parsed into ASCII /// </summary> void Decode() { std::string imgpath; std::string data; // Test image: C:\Users\mwsco\source\repos\Stegosaurus_CPP_Implementation\encode_out.png std::cout << "Please enter the full filepath, with extension:" << std::endl; std::cin >> imgpath; gil::rgb8_image_t image; // Reads the image. gil::read_image(imgpath, image, gil::png_tag{}); // Views the image. gil::rgb8_view_t imageView = view(image); auto v = gil::view(image); auto b = v.begin(); bool messageDone = false; // While there are still pixels to iterate. while (b != v.end()) { // Set the current pixel to a pixel object. gil::rgb8_pixel_t pixel = *b; // For every R and G value. for (int i = 0; i < 2; i++) { // Determine the binary value based on whether odd('1') or even ('0') if ((int)pixel[i] % 2 == 0) { data.push_back('0'); } else { data.push_back('1'); } } // If the B value is odd then the message is complete. if ((int)pixel[2] % 2 != 0) { break; } // Increment to the next pixel. b++; } // Display the message and the binary that has been harvested from the pixel components. std::cout << DecodeMessage(data) << std::endl; std::cout << data << std::endl; } int main() { int a; std::cout << ":: Welcome to Stegosaurus C++ Edition ::" << std::endl << "1. Encode \n2. Decode" << std::endl; // Get the option from user. std::cin >> a; // Pass off to Encode method. if (a == 1) { std::cout << "You picked Encode!" << std::endl; Encode(); return 0; } // Pass off to Decode method. else if (a == 2){ std::cout << "You picked Decode!" << std::endl; Decode(); return 0; } // If the user types an invalid option then end the program. else { std::cout << "Invalid Number!" << std::endl; return 0; } }
f52125832b5973c4b1e37449457416ab6bbbb933
a7428b9985feb5d837b776e669aadc074ae37e16
/UnfoldingUtils.h
86c8dae41bd2dd19e5bf408014beccc30ef4c172
[]
no_license
andrewadare/unfolding
e4396a609f4c16c4c472b4a77e7737378fc38db8
bf9fbc5b15af09f311e53490e931c06cad84807b
refs/heads/master
2021-01-23T11:40:23.487041
2014-05-28T15:36:52
2014-05-28T15:36:52
5,968,551
1
1
null
null
null
null
UTF-8
C++
false
false
11,818
h
UnfoldingUtils.h
#ifndef UnfoldingUtils_h #define UnfoldingUtils_h class TH1; class TH1D; class TH2; class TH2D; class TH3; class TH3D; class TString; class TGraph; class TCanvas; class TF1; #include "TMatrixD.h" #include "TVectorD.h" class SVDResult // Output from SVDAnalysis(). { public: SVDResult(); virtual ~SVDResult() {} TH1D *sigma; // Singular value spectrum. TH1D *UTb; // Left sing. vectors * b. TH1D *UTbAbs; // |U'*b| (mainly for plotting) TH1D *coeff; // SV coefficients uTb/sigma TH2D *U; // Left sing. vectors ClassDef(SVDResult, 1); }; class GSVDResult // Output from GSVDAnalysis(). { public: GSVDResult(); virtual ~GSVDResult() {} int n; // Column count of A (or L) int m; // Row count of A int p; // Row count of L double lambda; // Regularization parameter used TVectorD alpha; // alpha(i<n-p) = 1, else C(n-p,n-p)..C(n,n). TVectorD beta; // beta(i<n-p) = 0, else S(n-p,n-p)..S(n,n). TVectorD gamma; // alpha/beta. Valid for gamma(i >= n-p). TVectorD f; // Tik. filter factors. Size n. f(i<n-p) = 1. TVectorD UTb; // Left sing. vectors * b. (n) TVectorD coeff; // GSV coeffs uT*b/alpha. (n) TVectorD regc; // Regularized (filtered) coeffs. (n) TMatrixD X; // Columns = GSVD basis vectors (n x n) TMatrixD U; // Columns = left sing. vectors of A (m x m) TMatrixD V; // Columns = left sing. vectors of L (p x p) TMatrixD L; // Smoothing matrix used (p x n) TMatrixD A; // Coefficient matrix used (m x n) TMatrixD Ap; // A^#: regularized inverse of A (n x m) TMatrixD covw; // Covariance matrix of wreg Ap * Ap' (n x n) TMatrixD covx; // xini * covw * xini (n x n) TMatrixD covxInv; // Hocker eq. 53 (n x n) TMatrixD covb; // Either fMatb or I (m x m) TVectorD b; // Measured RHS vector used (m) TVectorD bInc; // Incompatible b component (I-UU')b (m x m) TVectorD breg; // Refolded solution TH2D *UHist; // Left sing. vectors TH2D *XHist; // GSVD basis vectors // Solution for this lambda TH1D *wregHist; // scaled result w^lambda TH1D *xregHist; // xini_j * w^lambda_j (solution) TH1D *bregHist; // Refolded distribution A*xreg // Abs. values (for visual analysis) TH1D *UTbAbs; // Vector of |U'_i*b| values TH1D *coeffAbs; // Vector of |U'_i*b|/alpha_i values TH1D *regcAbs; // Regularized (filtered) coeffs. ClassDef(GSVDResult, 1); }; class UnfoldingResult { public: UnfoldingResult(); virtual ~UnfoldingResult() {} // Solution matrix (for iterative methods, or reg. parameter scan). // Sequence of results stored in a TH2. Results are slices along x. // Bin k along y is the kth solution. TMatrixD WReg; TMatrixD XReg; TMatrixD WRegErr; TMatrixD XRegErr; // Covariance matrices of w and x (for single best solution) TMatrixD wCov; TMatrixD xCov; TH3D *hwCov; TH3D *hxCov; TH2D *WRegHist; TH2D *XRegHist; TGraph *LCurve; // Parametric curve of ||Lx||_2 vs. ||Ax-b||_2. TMatrixD F; // filter factors vs. iteration number // Summed Tikhonov Filter factors vs. lambda // Optimal point is smallest lambda where // sum(f_i) >= # significant GSVD U'b coeffs. TGraph *FilterSum; double lambdaStf; int kStf; // Optimal point index on curve TH1D *hStf; // Curvature of L-Curve TGraph *LCurvature; double lambdaLcv; int kLcv; // Optimal point index on curve TH1D *hLcv; // Best unfolding result (according to L-Curve) // Generalized cross-validation curve, // and best lambda & iteration / index TGraph *GcvCurve; double lambdaGcv; int kGcv; TH1D *hGcv; // Best unfolding result (according to GCV) // Mean of global correlation coefficients TGraph *RhoCurve; double lambdaRho; int kRho; TH1D *hRho; // Best unfolding result (according to GCV) ClassDef(UnfoldingResult, 1); }; class UnfoldingUtils { public: // Class administration UnfoldingUtils(); UnfoldingUtils(TH2D *hA, TH1D *hMeas, TH2D *hMeasCov = 0, TH1D *hXini = 0, TH1D *hXtrue = 0, TH1D *hEff = 0); virtual ~UnfoldingUtils() {} bool BinningOk(); TH1D *XHist(TVectorD &x, TString base, int k, double xMin, double xMax, double normto, TString opt=""); TGraph *LogCurvature(TGraph *g, const TVectorD &tVec, int &kMax); // log curvature of parametric curve g(t). kMax is point index of greatest curvature. TMatrixD RegularizedInverseResponse(GSVDResult *gsvd, double lambda); // A^# TMatrixD LMatrix(const int n, const int kind, double eps = 1.e-5); // Matrix to define smoothing seminorm void SetTH1Props(TH1 *h, Int_t linecolor, Int_t fillcolor, Int_t markercolor, Int_t markerstyle, Double_t markersize); // Unfolding methods: // Preconditioned Conjugate Gradients for Least Squares UnfoldingResult *UnfoldPCGLS(const int nIterations, int lMatrixType = k2DerivBCR, TString opt = "", const GSVDResult *gsvd = 0, const TH2 *hA = 0, const TH1 *hb = 0, const TH1 *hXini = 0); UnfoldingResult *UnfoldPCGLS(const int nIterations, TMatrixD &L, TString opt = "", const GSVDResult *gsvd = 0, const TH2 *hA = 0, const TH1 *hb = 0, const TH1 *hXini = 0); TH1D *UnfoldTLS(); // Richardson-Lucy algorithm UnfoldingResult *UnfoldRichardsonLucy(const int nIterations); // Regularized Hocker/Kartvilishveli SVD algorithm TH1D *UnfoldSVD(double lambda, TObjArray *output = 0, TString opt = "", /*"BC0", "BCR"*/ TH2 *hA = 0, TH1 *hb = 0, TH1 *hXini = 0); // Regularized chi squared minimization algorithm UnfoldingResult *UnfoldChiSqMin(TVectorD &regWts, TString opt = ""); // General-form Tikhonov solver based on generalized SVD UnfoldingResult *UnfoldTikhonovGSVD(GSVDResult *gsvd, TVectorD &lambda, TString opt = ""); // Support functions for chi squared minimization method double SmoothingNorm(TVectorD &x, int regtype); double Curvature(TVectorD &x); double RegChi2(const double *pars); // Analysis methods TGraph *ResidualNorm(TObjArray *hists, double stepSize = 1.); SVDResult *SVDAnalysis(TH2 *hA=0, TH1 *hb=0, TString opt=""); GSVDResult *GSVDAnalysis(TMatrixD &L, double lambda=0, TH2 *hA=0, TH1 *hb=0, TString opt=""); TCanvas *DrawSVDPlot(SVDResult*, double ymin, double ymax, TString opt=""); TCanvas *DrawGSVDPlot(GSVDResult *, double ymin, double ymax, TString opt=""); TH2D *UnfoldCovMatrix(int nTrials, int algo, double regPar, TString opt, TObjArray *bHists = 0); // Set and get methods void SetTrueRange(double x1, double x2); void SetMeasRange(double x1, double x2); void SetVerbosity(int val) { fVerbosity = val; } void SetRegType(int val) { fRegType = val; } void SetRegWeight(double val) { fRegWeight = val; } void SetLMatrix(TMatrixD &L) { fMatL.ResizeTo(L); fMatL = L; } void SetPrior(TH1D *h); void SetSmoothingWeights(TVectorD &wts) { fSmoothingWeight = wts; } Double_t GetTrueX1() const { return fTrueX1; } Double_t GetTrueX2() const { return fTrueX2; } Double_t GetMeasX1() const { return fMeasX1; } Double_t GetMeasX2() const { return fMeasX2; } Double_t GetbErrNorm(); Double_t GetbErrMean(); Double_t GetbErrRMS(); Int_t GetM() const { return fM; // Number of measured bins } Int_t GetNMeasBins() const { return fM; // Number of measured bins } Int_t GetN() const { return fN; // Number of true/generated bins } Int_t GetNTrueBins() const { return fN; // Number of true/generated bins } TMatrixD GetA(TString opt = ""); // "^", "~", or "" TVectorD Getb(TString opt = ""); // "~" or "" TMatrixD GetbCovariance() const { return fMatB; // Error matrix of b } TMatrixD GetbBinv() const { return fMatBinv; // Inverse error matrix of b } TMatrixD GetLMatrix() const { return fMatL; } TVectorD GetxTrue() const { return fVecXtrue; // b, scaled by its error } TH2D *GetAProbHist() const { return fHistAProb; } TH2D *GetAHist() const { return fHistA; } TH2D *GetATildeHist() const { return fHistATilde; } TH2D *GetBCovHist() const { return fHistMeasCov; } TH1D *GetbTildeHist() const { return fHistbTilde; } TH1D *GetXiniHist() const { return fHistXini; } TH1D *GetXTrueHist(); TH1D *GetEffHist() const { return fHistEff; } TH1D *GetPrior() const { return fHistPrior; } // Smoothing matrix types (& descriptions of W = Null(L)) enum LType {kUnitMatrix, // n x n, W=0 k1DerivNoBC, // n-1 x n, W=const k2DerivNoBC, // n-2 x n, W=const, linear k1DerivBC0, // n+1 x n, W=0 k2DerivBC0, // n x n, W=0 k1DerivBCR, // n-1 x n, W=const k2DerivBCR }; // n x n, W=const // Regularization types enum RegType {kNoReg, // add zero to chi squared k2Norm, // L_2 norm ||x||_2 = sqrt(x*x). kTotCurv }; // From 2nd derivative enum UnfoldingAlgo {kSVDAlgo, kGSVDAlgo, kRichLucyAlgo, kChi2MinAlgo, kPCGLSAlgo }; TString Algorithm(const int alg); // Pass in UnfoldingAlgo type protected: void ComputeRescaledSystem(); int fVerbosity; bool fTilde; Int_t fM, fN; Double_t fMeasX1, fMeasX2, fTrueX1, fTrueX2; Double_t fRegWeight; // For chi^2 method Int_t fRegType; // For chi^2 method TH2D *fHistAProb; // aka Ahat TH2D *fHistA; TH2D *fHistATilde; TH1D *fHistMeas; TH2D *fHistMeasCov; TH1D *fHistbTilde; TH1D *fHistXini; TH1D *fHistXtrue; TH1D *fHistEff; TH1D *fHistPrior; // Implemented for R-L and chi^2 TMatrixD fMatA; // Transfer matrix TMatrixD fMatAhat; // Probability matrix (column sums = 1.0) TMatrixD fMatATilde; // Covariance-preconditioned matrix TMatrixD fMatL; // Smoothing matrix TMatrixD fMatB; // Data covariance matrix TMatrixD fMatBinv; // Data covariance matrix inverse TVectorD fVecb; // Measurement TVectorD fVecbErr; // Measurement errors TVectorD fVecbTilde; // Meas. points / errors TVectorD fVecXtrue; // True solution (for test problems) TVectorD fVecXini; // Model truth distribution TVectorD fSmoothingWeight; ClassDef(UnfoldingUtils, 1); }; #endif
93d196c768bf1d99084b358bfb3eaaba5624a8b4
8fdab174252614c3d0eea09a4bd7aa262c087fd1
/cpp/IntroToDesignPatternsCppQt/ch02/qfraction/fraction.cpp
8e09d3500a812a0625bd0627639ce4ac95ab7971
[]
no_license
idreesdb/Tutorials
a5190c72ad9ad25d9e8302c01357939bd62b75d8
754cd20250b7f826caf76a1d3c188826a4babbd3
refs/heads/master
2021-01-17T07:37:01.623156
2016-05-27T14:03:28
2016-05-27T14:03:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
319
cpp
fraction.cpp
#include <QString> #include "fraction.h" void Fraction::set(int nn, int nd) { m_numerator = nn; m_demoninator = nd; } double Fraction::toDouble() const { return 1.0 * m_numerator / m_demoninator; } QString Fraction::toString() const { return QString("%1 / %2").arg(m_numerator).arg(m_demoninator); }
185fa64b8f5501f71cf383a24a559891169135d2
1e49d897c11ca25eb635c413f99d57a0fdb144e0
/2016/Array-template.cpp
cd0460e8b91ca48808d0045173a047e2526499d7
[]
no_license
FeridAdashov/C-and-CPP
4295074021b6314e7893819756af5f854331ef6f
1ecd2a81587c1851bf9d5004f5c8b3f109be3f9a
refs/heads/master
2020-04-06T19:33:00.825018
2018-11-15T16:43:30
2018-11-15T16:43:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
352
cpp
Array-template.cpp
#include <iostream> using namespace std; template<class T = int, int n = 1> class array{ T ary[n]; public: T& operator[](int); }; template<class T, int n> T& array<T, n>::operator[](int i){ if(i < 0 || i >= n) printf("Out of index!\n"); return ary[i]; } int main() { array<int, 5> ob; array<> ob1; ob[0] = 7; cout << ob[0]; return 0; }
ba606cdacfc2acca4688b6decfc51f6232b8386e
6a7d4ed5d9fae1311b7b768cae72e70b8c452c28
/FatImage.h
cc32c0da8762ce1ea32be667e19ec9fa27fbd8c7
[]
no_license
iceonepiece/LIA_ME_TO_THE_MOON
45dfe85426b65e3089ee24dff386f915c90124e7
a851a64d0f4a8b1770498f0acd37c466eee52606
refs/heads/master
2016-09-06T09:05:36.265974
2015-07-15T06:38:16
2015-07-15T06:38:16
39,120,644
0
0
null
null
null
null
UTF-8
C++
false
false
369
h
FatImage.h
#ifndef FATIMAGE_H #define FATIMAGE_H #include "DataImage.h" #include "Blob.h" class FatImage : public DataImage { public: FatImage(std::string name, int type, std::string location, std::string note); ~FatImage(); bool load( Message& message ); std::vector<Blob> list_blob; cv::Mat mat_blob; float minBlobSize; float maxBlobSize; }; #endif // FATIMAGE_H
b59957071d6421a7ff4da2e0903d5bb445778bed
69e1199b2daffa17e4842e94a54be152df540828
/杨老师系统/梅花桩.cpp
3f8c757c2f5186ee46d0907046199a721f259a0d
[]
no_license
shaobozhong/myAcmCodes
8c63e7992d0975626e6e583a49e59fe03f73017c
55b31b8a4600fd3084795f71ac0d244cbdc58800
refs/heads/master
2023-08-04T20:05:29.165456
2023-07-26T03:19:52
2023-07-26T03:19:52
21,147,335
0
1
null
2023-07-26T03:19:53
2014-06-24T00:49:13
null
UTF-8
C++
false
false
882
cpp
梅花桩.cpp
#include<iostream> #include<cmath> using namespace std; double a[100001][5]; int main() { int n; int i,j,k; double max1,tmp1,tmp2; max1=0; scanf("%d",&n); scanf("%lf%lf%lf%lf%lf",&a[0][0],&a[0][1],&a[0][2],&a[0][3],&a[0][4]); scanf("%lf%lf%lf%lf%lf",&a[1][0],&a[1][1],&a[1][2],&a[1][3],&a[1][4]); max1=0; for(k=0;k<5;++k) { max1+=abs(a[1][k]-a[0][k]); } for(i=2;i<n;++i) { scanf("%lf%lf%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2],&a[i][3],&a[i][4]); tmp1=0; for(k=0;k<5;++k) { tmp1+=abs(a[i][k]-a[0][k]); } if (tmp1>max1) max1=tmp1; tmp2=0; for(k=0;k<5;++k) { tmp2+=abs(a[i][k]-a[1][k]); } if (tmp2>max1) max1=tmp2; if (max1==tmp1) { for(k=0;k<5;++k) { a[1][k]=a[i][k]; } } else if (max1==tmp2) { for(k=0;k<5;++k) { a[0][k]=a[i][k]; } } } printf("%.2lf\n",max1); return 0; }
261027a5938c11f11771476b52c0009cf677e867
a961cc13da1493521bc233f69d041a5380240875
/src/ExprLib/forloops.cc
cba1df9fc57fbeaa974622042493ce856212a19b
[ "Apache-2.0" ]
permissive
gianricardo/smart
5efda6a3ac87f4885b014ac52d813cd0f54954e1
962396af991d8f0c28f7ee1756758b145b75aa3b
refs/heads/master
2023-03-09T03:46:51.165195
2021-02-25T15:17:14
2021-02-25T15:17:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,825
cc
forloops.cc
#include "forloops.h" #include "exprman.h" #include "iterators.h" #include "../Streams/streams.h" #include "../Options/options.h" #include "result.h" #include <stdlib.h> // ****************************************************************** // * * // * forstmt class * // * * // ****************************************************************** /** A statement used for for-loops. Multiple dimensions can be handled in a single statement. */ class forstmt : public expr { iterator** index; int dimension; expr* block; public: forstmt(const char *fn, int l, iterator** i, int d, expr* b); virtual ~forstmt(); virtual bool Print(OutputStream &s, int) const; virtual void Compute(traverse_data &x); virtual void Traverse(traverse_data &x); protected: void Compute(int d, traverse_data &x); void Traverse(int d, traverse_data &x); void ShowAssignments(OutputStream &s) const; inline void DebugIteration(const char* msg) const { if (!expr_debug.startReport()) return; expr_debug.report() << msg; for (int i=0; i<dimension; i++) { if (i) expr_debug.report() << ", "; index[i]->ShowAssignment(expr_debug.report()); } expr_debug.report() << "\n"; expr_debug.stopIO(); } }; // ****************************************************************** // * forstmt methods * // ****************************************************************** forstmt::forstmt(const char *fn, int l, iterator** i, int d, expr* b) : expr(fn, l, STMT) { index = i; dimension = d; block = b; if (block) { traverse_data x(traverse_data::Block); block->Traverse(x); } } forstmt::~forstmt() { #ifdef DEBUG_MEM printf("destroying forstmt: 0x%x\n", unsigned(this)); printf("\tblock: 0x%x\n", unsigned(block)); printf("\tindex: 0x%x\n", unsigned(index)); #endif Delete(block); for (int j=0; j<dimension; j++) Delete(index[j]); free(index); } bool forstmt::Print(OutputStream &s, int w) const { s.Pad(' ', w); s.Put("for ("); index[0]->PrintAll(s); int d; for (d=1; d<dimension; d++) { s.Put(", "); index[d]->PrintAll(s); } s.Put(") {\n"); block->Print(s, w+2); s.Pad(' ', w); s.Put("}\n"); return true; } void forstmt::Compute(traverse_data &x) { DCASSERT(x.answer); DCASSERT(0==x.aggregate); if (x.stopExecution()) return; Compute(0, x); } void forstmt::Traverse(traverse_data &x) { switch (x.which) { case traverse_data::PreCompute: case traverse_data::Guess: case traverse_data::Update: case traverse_data::Affix: Traverse(0, x); return; // symbols? substitute? default: block->Traverse(x); }; } void forstmt::Compute(int d, traverse_data &x) { if (d>=dimension) { // execute block DebugIteration("for loop: executing with "); block->Compute(x); } else { // Loop this dimension index[d]->ComputeCurrent(x); if (!index[d]->FirstIndex()) return; // empty loop do { Compute(d+1, x); } while (index[d]->NextValue()); index[d]->DoneCurrent(); } } void forstmt::Traverse(int d, traverse_data &x) { if (d>=dimension) { // execute block block->Traverse(x); } else { // Loop this dimension index[d]->ComputeCurrent(x); if (!index[d]->FirstIndex()) return; // empty loop do { Traverse(d+1, x); } while (index[d]->NextValue()); index[d]->DoneCurrent(); } } void forstmt::ShowAssignments(OutputStream &s) const { } // ****************************************************************** // * * // * exprman methods * // * * // ****************************************************************** symbol* exprman::makeIterator(const char* fn, int ln, const type* t, char* name, expr* vals) const { if (isError(vals) || 0==t) { free(name); Delete(vals); return 0; } DCASSERT(!isDefault(vals)); if (0==t->getSetOfThis()) { if (startError()) { causedBy(fn, ln); cerr() << "Illegal type for iterator " << name; stopIO(); } Delete(vals); free(name); return 0; } symbol* s; if (0==vals) { if (startWarning()) { causedBy(fn, ln); warn() << "Empty set for iterator " << name; stopIO(); } s = new iterator(fn, ln, t, name, vals); } else { const type* vt = vals->Type(); DCASSERT(vt); // Check that the set type matches the iterator. if (getPromoteDistance(vt, t->getSetOfThis()) < 0) { if (startError()) { causedBy(fn, ln); cerr() << "Type mismatch: iterator " << name; cerr() << " expects set of type " << t->getName(); stopIO(); } Delete(vals); free(name); return 0; } vals = makeTypecast(fn, ln, t->getSetOfThis(), vals); s = new iterator(fn, ln, t, name, vals); } // if getPromoteDistance if (s->OK()) return s; Delete(s); return 0; } expr* exprman::makeForLoop(const char* fn, int ln, symbol** iters, int dim, expr* stmt) const { if (!isOrdinary(stmt)) { return Share(stmt); } DCASSERT(stmt->Type() == findType("void")); #ifdef DEVELOPMENT_CODE for (int i=0; i<dim; i++) { iterator* foo = dynamic_cast <iterator*> (iters[i]); DCASSERT(foo); } #endif expr* x = new forstmt(fn, ln, (iterator**) iters, dim, stmt); if (x->OK()) return x; if (x->hadError()) { Delete(x); return makeError(); } Delete(x); return 0; }
9cb9bade7f413062b7149c35849bb67aa868e144
7e3196622bbabe41639aec9735c44625f48fcaaa
/app/src/db/card.cpp
eaec6bfde18664367724ad780aaf8f95e0e0b5a6
[]
no_license
ifeherva/HearthDuster
3931591877c5fa3e645d3bdfe83f129c0aa6c7c9
a1dd2ae1df7f0e7568abeb0a1a9e7ed5a1a0c222
refs/heads/master
2021-01-20T06:00:10.645153
2017-12-18T06:32:13
2017-12-18T06:32:13
89,833,838
4
0
null
null
null
null
UTF-8
C++
false
false
4,835
cpp
card.cpp
// // card.cpp // card // // Created by Istvan Fehervari on 01/05/2017. // Copyright © 2017 com.ifehervari. All rights reserved. // #include "card.h" #include <map> Card::Card(const QString& id) : id(id) {} QString ReadStringValue(const QJsonValue& value, QString defaultValue = "") { if (value == QJsonValue::Undefined || !value.isString()) return defaultValue; return value.toString(); } int ReadIntValue(const QJsonValue& value, int defaultValue = 0) { if (value == QJsonValue::Undefined || !value.isDouble()) return defaultValue; return value.toDouble(); } bool ReadBoolValue(const QJsonValue& value, bool defaultValue = 0) { if (value == QJsonValue::Undefined || !value.isBool()) return defaultValue; return value.toBool(); } std::map<QString, CardClass> cardClassMap = {{"NEUTRAL", CLASS_NEUTRAL}, {"WARRIOR", CLASS_WARRIOR}, {"DRUID", CLASS_DRUID}, {"PRIEST", CLASS_PRIEST}, {"HUNTER", CLASS_HUNTER}, {"MAGE", CLASS_MAGE}, {"WARLOCK", CLASS_WARLOCK}, {"PALADIN", CLASS_PALADIN}, {"SHAMAN", CLASS_SHAMAN}, {"ROGUE", CLASS_ROGUE}, {"DREAM", CLASS_DREAM}, {"DEATHKNIGHT", CLASS_DEATHKNIGHT}}; CardClass ReadCardClassValue(const QJsonValue& value, CardClass defaultValue = CLASS_NEUTRAL) { QString sValue = ReadStringValue(value, "NEUTRAL"); if (!cardClassMap.count(sValue)) { return defaultValue; } return cardClassMap[sValue]; } std::map<QString, CardRarity> cardRarityMap = {{"FREE", RARITY_FREE}, {"COMMON", RARITY_COMMON}, {"RARE", RARITY_RARE}, {"EPIC", RARITY_EPIC}, {"LEGENDARY", RARITY_LEGENDARY}}; CardRarity ReadCardRarityValue(const QJsonValue& value, CardRarity defaultValue = RARITY_FREE) { QString sValue = ReadStringValue(value, "FREE"); if (!cardRarityMap.count(sValue)) { return defaultValue; } return cardRarityMap[sValue]; } std::map<QString, CardType> cardTypeMap = {{"INVALID", TYPE_INVALID}, {"MINION", TYPE_MINION}, {"SPELL", TYPE_SPELL}, {"WEAPON", TYPE_WEAPON}, {"ENCHANTMENT", TYPE_ENCHANTMENT}, {"HERO", TYPE_HERO}, {"HERO_POWER", TYPE_HERO_POWER}}; CardType ReadCardTypeValue(const QJsonValue& value, CardType defaultValue = TYPE_INVALID) { QString sValue = ReadStringValue(value, "INVALID"); if (!cardTypeMap.count(sValue)) { return defaultValue; } return cardTypeMap[sValue]; } Card* CardFactory::FromJson(const QJsonObject& jsonobject) { auto cardId = ReadStringValue(jsonobject["id"], ""); if (cardId == "") { return NULL; } Card* card = new Card(cardId); card->name = ReadStringValue(jsonobject["name"], ""); card->artist = ReadStringValue(jsonobject["artist"], ""); card->flavor = ReadStringValue(jsonobject["flavor"], ""); card->set = ReadStringValue(jsonobject["set"], ""); card->text = ReadStringValue(jsonobject["text"], ""); card->attack = ReadIntValue(jsonobject["attack"], 0); card->health = ReadIntValue(jsonobject["health"], 0); card->cost = ReadIntValue(jsonobject["cost"], 0); card->dbfId = ReadIntValue(jsonobject["dbfId"], 0); card->cardClass = ReadCardClassValue(jsonobject["cardClass"]); card->playerClass = ReadCardClassValue(jsonobject["playerClass"]); card->collectible = ReadBoolValue(jsonobject["collectible"], false); card->elite = ReadBoolValue(jsonobject["elite"], false); card->rarity = ReadCardRarityValue(jsonobject["rarity"], RARITY_FREE); card->type = ReadCardTypeValue(jsonobject["type"]); switch (card->type) { case TYPE_MINION: case TYPE_WEAPON: card->shortDescription = QString::number(card->cost) + " mana " + QString::number(card->attack)+"/"+QString::number(card->health)+"\n"+card->text; break; case TYPE_SPELL: card->shortDescription = QString::number(card->cost) + " mana\n" + card->text; break; default: card->shortDescription = ""; break; } return card; }
832f959fcc474159d4f9fabd7ee76f94225f6950
e3f9cc9e59c4c7a9d108dfe1d63d8de7961b2633
/irrlichtFWD.h
68ae110a1009e6aa63ea5f5378ad76268869c6eb
[]
no_license
rna88/show2d
5a7d408857868c460eb9ad3018593eacc84ac10f
76b655b98ea7c2a7fb93c2fc0e75a1680b0af72d
refs/heads/master
2021-01-17T12:57:16.433820
2016-07-04T08:42:36
2016-07-04T08:42:36
57,185,764
0
0
null
null
null
null
UTF-8
C++
false
false
306
h
irrlichtFWD.h
// Forward declarations for irrlicht types. namespace irr { namespace scene { class ISceneManager; }; namespace gui { class IGUIEnvironment; }; namespace video { class IVideoDriver; }; struct SIrrlichtCreationParameters; class IEventReceiver; class IrrlichtDevice; };
2cffeb906be364c1261c477edd9776d991bd8d92
d9650c98ac86f00e3fc75153781863ce69d3580f
/CarouselMap/AutoGdiPlus.h
b76c2875f2f9189574526c6ec794f0cd85e0c09f
[]
no_license
asdlei99/CarouselMap
56bca3fc0dfdc7e4c723f759302da2613e6e8015
1f3f26953e6abd3a832eb1283f337b5868f42497
refs/heads/master
2022-02-20T14:48:23.636289
2019-05-27T07:39:49
2019-05-27T07:39:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
166
h
AutoGdiPlus.h
#pragma once typedef unsigned long ULONG_PTR; class CAutoGdiPlus { public: CAutoGdiPlus(); ~CAutoGdiPlus(); private: ULONG_PTR m_gdiplusToken;; };
a09ba77e41adc0ab7b5d5f6b8d5f54f8468efa6c
46bcf9ac359166bf9d4df624e1df4aca77586140
/链表以及关于链表的问题集/约瑟夫环.cpp
ced47cb2a16cfeb36d6d3f8f8175c7e152c8c354
[]
no_license
shulincome/-
32344b04b655f94399a3012d43098a0ca2c4a701
922282b345fa5ad17dfff34e7cba206e5f923134
refs/heads/master
2020-10-01T13:35:22.117610
2019-12-12T07:53:45
2019-12-12T07:53:45
227,548,201
1
0
null
null
null
null
UTF-8
C++
false
false
858
cpp
约瑟夫环.cpp
struct ListNode *GetJosephusPosition(){ struct ListNode *p, *q; int N, M; printf("Enter N(number of players): "); scanf("%d",&N); printf("Enter M(every M-th player gets eliminate): "); scanf("%d",&M); //创建包含所有参与游戏者的循环链表 p = q = (struct ListNode *)(malloc(sizeof(struct ListNode))); p->data = 1; for(i=2;i<=N;i++){ p->next = (struct ListNode *)(malloc(sizeof(struct ListNode))); p = p->next; p->dta = i; } //通过让最后一个结点的指针域指向第一个结点得到循环链表 p->next = q; //淘汰第M个玩家直到至多剩下一位玩家为止 for(int count=M;count > 1; count--){ for(i=0;i<M;i++){ p=p->next; } p->next = p->next->next; } printf("Last player left standing(Josephus Position) is %d.\n",p->data); }
14e5030cd413c5b577195ef7fa5b84cb0b3e910c
f84fd1d0404aa79bb53c68186c426df84c97f966
/inc/grafy_klasy.h
dbfe5f4a60417d43d3cce9dec9e8b83734ddb573
[]
no_license
Coloboty/grafy
fc82bfdc06e93d0f958099f06026b73e8dda47a0
f2a41c8e2fa7fa65617e1670299c45881a895c47
refs/heads/master
2020-05-07T18:30:59.226427
2019-05-14T08:45:30
2019-05-14T08:45:30
180,769,838
0
0
null
null
null
null
UTF-8
C++
false
false
1,058
h
grafy_klasy.h
#ifndef GRAFY_KLASY_H #define GRAFY_KLASY_H template <typename T, typename K> class wierzcholek{ private: T wartosc; uint klucz; public: wierzcholek(T w, uint k){ wartosc= w; klucz= k; } wierzcholek(){ wartosc= 0; klucz= 0; } void zmienWartosc(T nowa) {wartosc= nowa;} T dajWartosc(void) {return wartosc;} void zmienKlucz(uint k) {klucz= k;} uint dajKlucz(void) {return klucz;} }; /* ----------------------------- */ template <typename T, typename K> class krawedz{ private: K wartosc; wierzcholek<T, K> *w1, *w2; public: krawedz(K w, wierzcholek<T, K> *w_1, wierzcholek<T, K> *w_2){ wartosc= w; w1= w_1; w2= w_2; } krawedz(){ wartosc= 0; w1= nullptr; w2= nullptr; } void zmienWartosc(K nowa) {wartosc= nowa;} K dajWartosc(void) {return wartosc;} void zmienW1(wierzcholek<T, K> *w) {w1= w;} wierzcholek<T, K> *dajW1(void) {return w1;} void zmienW2(wierzcholek<T, K> *w) {w2= w;} wierzcholek<T, K> *dajW2(void) {return w2;} }; #endif
979635e7ece689e8f9eacff9b8a395c68afb43ab
2184a4ac13e77febd996cff7712b8f499b848469
/ABC/175/D.cpp
2a54d21da24682fe911a3ba2a53cf9931806b8bb
[]
no_license
hiro-tacky/practice
41b7305139182d037ed5a5d42729638a7ded59c2
1ae6ad5348e5dfc61657162f5b2ce7a3f6b219e5
refs/heads/master
2021-10-20T23:35:21.007510
2021-10-13T06:03:48
2021-10-13T06:03:48
230,712,389
0
0
null
null
null
null
UTF-8
C++
false
false
1,247
cpp
D.cpp
// 173 #include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <queue> #include <iomanip> #include <climits> #include <string> #include <cmath> using namespace std; using ll = long long int; #define NUM 1000000007 int main(){ ll n, k, sum, rem, div, ans = LLONG_MIN, tmp; cin >> n >> k; vector<ll> p(n), c(n); for(int i=0;i<n; i++){ cin >> tmp; p.at(i) = tmp-1; } for(int i=0; i<n; i++){ cin >> c.at(i); } sum = accumulate(c.begin(), c.end(), 0); div = k/n; rem = k%n; for(int i=0; i<n; i++){ ll max_buf = LLONG_MIN, buf = 0; int current = i; if(div > 0){ for(int j=0; j<n; j++){ current = p.at(current); buf += c.at(current); if (max_buf < buf) max_buf = buf; } buf += sum*(div-1); if (max_buf < buf) max_buf = buf; } current = i; for(int j=0; j<rem; j++){ current = p.at(current); buf += c.at(current); if (max_buf < buf) max_buf = buf; } if (ans < max_buf) ans = max_buf; } cout << ans << endl; return 0; }
67ec4348df638e8a2480e1a7629866a43efed695
95a4f3e7370e1a1a6ce34d1a2be97ad2aef5cf5a
/whether_save.cpp
43a11e49e2531547cc757d4857bf95886a35b2bc
[]
no_license
typenameChen/subway
b9ef2a5313a8e9155fd8e9c93acde89b2db2cc0f
aa1a0927a6c20dc6d0fdad2d7b46df4063a05f84
refs/heads/master
2020-04-11T02:50:58.169065
2018-12-17T03:06:07
2018-12-17T03:06:07
161,458,451
1
0
null
null
null
null
UTF-8
C++
false
false
610
cpp
whether_save.cpp
//站点信息保存提示框 #include "whether_save.h" #include "ui_whether_save.h" WHETHER_SAVE::WHETHER_SAVE(QWidget *parent,const QString&head,const QString&question) : QDialog(parent), ui(new Ui::WHETHER_SAVE) { ui->setupUi(this); setWindowTitle(head); ui->label_question->setText(question); } WHETHER_SAVE::~WHETHER_SAVE() { delete ui; } void WHETHER_SAVE::on_pushButton_save_clicked() { emit SignalSave(); } void WHETHER_SAVE::on_pushButton_dontsave_clicked() { emit SignalDontSave(); } void WHETHER_SAVE::on_pushButton_cancel_clicked() { emit SignalCancel(); }
062088fee5a1eba2ad50c0ced6f4d39638ba3d58
ca34eac4babf8c07f7f3dd3ce75d3be9791f366d
/Source/ShooterGame/Private/Tests/ShooterTestControllerListenServerClient.cpp
b60cf8884b3ef44b64b12c6d27c52000510c0776
[ "MIT" ]
permissive
cqcallaw/shootergame
f6c04bbcade7f96a22aff834b7d86c228ac71b7f
7d93f7d3333f2882ba67ba15da71a3f9325958aa
refs/heads/master
2021-07-08T14:18:33.600615
2021-05-21T16:52:04
2021-05-21T16:52:04
244,085,258
5
3
null
null
null
null
UTF-8
C++
false
false
413
cpp
ShooterTestControllerListenServerClient.cpp
// Copyright Epic Games, Inc.All Rights Reserved. #include "Tests/ShooterTestControllerListenServerClient.h" #include "Online/ShooterGameSession.h" void UShooterTestControllerListenServerClient::OnTick(float TimeDelta) { Super::OnTick(TimeDelta); if (bIsLoggedIn && !bIsSearchingForGame && !bFoundGame) { StartSearchingForGame(); } if (bIsSearchingForGame && !bFoundGame) { UpdateSearchStatus(); } }
2e6dc0bfc4de24020379e7592b3f179414fb374b
5ffe8ebcf9028339da74ec6bf980f704fb48340c
/code/src/fritzwilke06/main_statistics.h
ce4db7bf335988f8753ab62cc9d249a9b0d90f19
[]
no_license
atollk/master-thesis
fca0c1c2fae0e825d72c620d35a0632b68189a01
94bba4a57e52886d5584fc57f5497553ccc52754
refs/heads/master
2021-10-15T08:16:47.879055
2019-02-05T13:35:48
2019-02-05T13:35:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
622
h
main_statistics.h
#pragma once #include "../construction_main.h" #include "../automaton/hoa/hoa_io.h" #include <iostream> namespace tollk { struct FritzWilkeOptions : public BaseOptions { bool reset_at_sccs = false; }; class FritzWilkeConstructionExecutor : public ConstructionExecutor { private: std::unique_ptr<args::Flag> resetAtSCCsFlag; public: void InitializeFlags(args::ArgumentParser* argParser) override; std::unique_ptr<BaseOptions> ParseFlags() const override; std::string ConstructionName() const override; automaton::DPA PerformConstruction(const BaseOptions& options) const override; }; }
6bcb93722d7e9d1ddaae040ebf73f8c09e613fb6
6cbf92604990543c8b1ccd29d48314918279c4cb
/project3/codegen.hpp
b8bd1ffc3b8211595f2ff6cf7c9baedc7a3996c9
[]
no_license
tim124058/compiler_project
1eeac46ade43899cf595c4b829041d9880994782
77179975936cdc6560db70d15990b666512d0364
refs/heads/master
2021-06-19T00:42:36.678641
2017-06-21T14:33:46
2017-06-21T14:33:46
91,955,657
8
3
null
null
null
null
UTF-8
C++
false
false
1,496
hpp
codegen.hpp
#ifndef _CODEGEN_H_ #define _CODEGEN_H_ #include <iostream> #include <fstream> #include <stdio.h> #include <stack> #include "symbols.hpp" using namespace std; extern string outName; extern ofstream out; struct LabelStruct{ int LC; // The labelCount at that time int Max; // number of Label required for the statement LabelStruct(int lc,int max); int FOR_FLAG; }; // manage all label index class LabelManager{ private: int labelCount; public: stack<LabelStruct> lmStack; LabelManager(); void pushNLabel(int); void popLabel(); int takeLabel(int); int getLable(); void addFLAG(); int getFLAG(); }; void genProgramStart(); void genMainStart(); void genFuncStart(idInfo); void genVoidFuncEnd(); void genCompoundEnd(); void genCallFunc(idInfo); void genGlobalVar(string name,int value); void genGlobalVarNoInit(string name); void genLocalVar(int index,int value); void genPrintStart(); void genPrintStr(); void genPrintInt(); void genPrintlnStr(); void genPrintlnInt(); void genConstStr(string); void genConstInt(int); void genGetGlobalVar(string s); void genGetLocalVar(int index); void genSetGlobalVar(string s); void genSetLocalVar(int index); void genOperator(char op); enum condition{ IFLT, IFGT, IFLE, IFGE, IFEQ, IFNE }; void genCondOp(int op); void genIfStart(); void genElse(); void genIfEnd(); void genIfElseEnd(); void genForStart(); void genForStart2(); void genForCond(); void genForBody(); void genForEnd(); void genReturn(); void geniReturn(); #endif
8fd4718355ebf886e8f91436505b2ef199e40718
09b99d752bdfdc560c4cb85cc78291eaf06db96a
/Source/WTF/wtf/gobject/GMainLoopSource.cpp
e37569fd1f5a310b413fe5325ece9ef0b2b0591b
[]
no_license
ispras/webkit-aotc
a6ddf37737d9f4081d83171bcd5e0ecea7152eed
8df45c237ab14520cc448106e762b1943411e2d9
refs/heads/aotc
2023-03-04T03:40:55.915838
2016-12-14T12:28:32
2016-12-14T12:28:32
72,722,479
18
3
null
2018-09-12T00:17:43
2016-11-03T08:07:38
null
UTF-8
C++
false
false
8,677
cpp
GMainLoopSource.cpp
/* * Copyright (C) 2014 Igalia S.L. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #if USE(GLIB) #include "GMainLoopSource.h" #include <gio/gio.h> namespace WTF { GMainLoopSource& GMainLoopSource::createAndDeleteOnDestroy() { return *new GMainLoopSource(DeleteOnDestroy); } GMainLoopSource::GMainLoopSource() : m_deleteOnDestroy(DoNotDeleteOnDestroy) , m_status(Ready) { } GMainLoopSource::GMainLoopSource(DeleteOnDestroyType deleteOnDestroy) : m_deleteOnDestroy(deleteOnDestroy) , m_status(Ready) { } GMainLoopSource::~GMainLoopSource() { cancel(); } bool GMainLoopSource::isScheduled() const { return m_status == Scheduled; } bool GMainLoopSource::isActive() const { return m_status != Ready; } void GMainLoopSource::cancel() { if (!m_source) return; GRefPtr<GSource> source; m_source.swap(source); if (m_cancellable) g_cancellable_cancel(m_cancellable.get()); g_source_destroy(source.get()); destroy(); } void GMainLoopSource::reset() { m_status = Ready; m_source = nullptr; m_cancellable = nullptr; m_voidCallback = nullptr; m_boolCallback = nullptr; m_destroyCallback = nullptr; } void GMainLoopSource::scheduleIdleSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context) { ASSERT(m_status == Ready); m_status = Scheduled; m_source = adoptGRef(g_idle_source_new()); g_source_set_name(m_source.get(), name); if (priority != G_PRIORITY_DEFAULT_IDLE) g_source_set_priority(m_source.get(), priority); g_source_set_callback(m_source.get(), sourceFunction, this, nullptr); g_source_attach(m_source.get(), context); } void GMainLoopSource::schedule(const char* name, std::function<void ()> function, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_voidCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context); } void GMainLoopSource::schedule(const char* name, std::function<bool ()> function, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_boolCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context); } void GMainLoopSource::schedule(const char* name, std::function<bool (GIOCondition)> function, GSocket* socket, GIOCondition condition, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); ASSERT(m_status == Ready); m_status = Scheduled; m_socketCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); m_cancellable = adoptGRef(g_cancellable_new()); m_source = adoptGRef(g_socket_create_source(socket, condition, m_cancellable.get())); g_source_set_name(m_source.get(), name); g_source_set_callback(m_source.get(), reinterpret_cast<GSourceFunc>(socketSourceCallback), this, nullptr); g_source_attach(m_source.get(), context); } void GMainLoopSource::scheduleTimeoutSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context) { ASSERT(m_status == Ready); m_status = Scheduled; ASSERT(m_source); g_source_set_name(m_source.get(), name); if (priority != G_PRIORITY_DEFAULT) g_source_set_priority(m_source.get(), priority); g_source_set_callback(m_source.get(), sourceFunction, this, nullptr); g_source_attach(m_source.get(), context); } void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()> function, std::chrono::milliseconds delay, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_source = adoptGRef(g_timeout_source_new(delay.count())); m_voidCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context); } void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()> function, std::chrono::milliseconds delay, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_source = adoptGRef(g_timeout_source_new(delay.count())); m_boolCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context); } void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()> function, std::chrono::seconds delay, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_source = adoptGRef(g_timeout_source_new_seconds(delay.count())); m_voidCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context); } void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()> function, std::chrono::seconds delay, int priority, std::function<void ()> destroyFunction, GMainContext* context) { cancel(); m_source = adoptGRef(g_timeout_source_new_seconds(delay.count())); m_boolCallback = std::move(function); m_destroyCallback = std::move(destroyFunction); scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context); } void GMainLoopSource::voidCallback() { if (!m_source) return; ASSERT(m_voidCallback); ASSERT(m_status == Scheduled); m_status = Dispatched; GSource* source = m_source.get(); m_voidCallback(); if (source == m_source.get()) destroy(); } bool GMainLoopSource::boolCallback() { if (!m_source) return false; ASSERT(m_boolCallback); ASSERT(m_status == Scheduled); m_status = Dispatched; GSource* source = m_source.get(); bool retval = m_boolCallback(); if (!retval && source == m_source.get()) destroy(); return retval; } bool GMainLoopSource::socketCallback(GIOCondition condition) { if (!m_source) return false; ASSERT(m_socketCallback); ASSERT(m_status == Scheduled); m_status = Dispatched; if (g_cancellable_is_cancelled(m_cancellable.get())) { destroy(); return false; } GSource* source = m_source.get(); bool retval = m_socketCallback(condition); if (!retval && source == m_source.get()) destroy(); return retval; } void GMainLoopSource::destroy() { auto destroyCallback = std::move(m_destroyCallback); auto deleteOnDestroy = m_deleteOnDestroy; reset(); if (destroyCallback) destroyCallback(); if (deleteOnDestroy == DoNotDeleteOnDestroy) return; delete this; } gboolean GMainLoopSource::voidSourceCallback(GMainLoopSource* source) { source->voidCallback(); return G_SOURCE_REMOVE; } gboolean GMainLoopSource::boolSourceCallback(GMainLoopSource* source) { return source->boolCallback() == Continue; } gboolean GMainLoopSource::socketSourceCallback(GSocket*, GIOCondition condition, GMainLoopSource* source) { return source->socketCallback(condition) == Continue; } } // namespace WTF #endif // USE(GLIB)
076967245d1cec9978f5538e6164e297a341dc8c
415a38e9d832fb6c7cf09a22323fe95fdc182f0d
/midsem_lab/last year end/question_3.cpp
1dd9a8049439af36fc24a24b4cb08d3dcd5ea8a3
[]
no_license
gurkirat007/nitw-lab-folder
07bf859e725da863d21a4f9cb1ddf68c1240b892
5deb5971e5c5385cc2759484897b266d1a29cdd4
refs/heads/master
2023-04-09T06:36:48.309220
2021-04-28T08:29:32
2021-04-28T08:29:32
362,392,499
0
0
null
null
null
null
UTF-8
C++
false
false
484
cpp
question_3.cpp
//incomplete #include <iostream> using namespace std; int main(void){ int n; int rotation_factor; cin>>rotation_factor>>n; if(n%2 != 1){ cout<<"invalid"<<endl; return 1; } int matrix[n][n]; int transformed_matrix[n][n]; for(int i = 0; i<n; i++){ for(int j = 0; j<n; j++){ cin>>matrix[i][j]; } } for(int i = 0; i<n; i++){ for(int j = 0; j<n; j++){ if(i % 2 == 0){ transformed_matrix[i][j] = matrix[i-rotation_factor][j] } else { } } } }
90647c7d0fbaf2d875a8b597b4f0d6d715802132
fd7ed208359ad08fa6bb716e1b008aa4e39e7efe
/labs/J70_State/cpp/complete/src/Warehouse.hpp
a8d7c1d6fbff618f0d1897d315064505a8ecdd92
[ "MIT" ]
permissive
Meera94/design_patterns
54ca8f2796d5c878487c82f5d758b5811d3bcef2
bf9f599149359921c8171b82d102a2f2904f915e
refs/heads/main
2023-07-02T04:02:11.116457
2021-08-09T14:49:44
2021-08-09T14:49:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
176
hpp
Warehouse.hpp
#include "Order.hpp" #include "OrderStatus.hpp" class Warehouse { public: static Order fill(Order o) { o.status=o.status->next(OrderStatuses::filled); return o; } };
89df0f57e596f82bf063fb27eb45c6fefad1805d
a6b3e3e818bc5c1efef9bf992bfc583de87d2595
/d04/ex03/AMateria.cpp
48fb4d52bb5265c09baa4aea77c321e956bdf4f4
[]
no_license
gloomikon/Piscine_CPP
4d66d65b5d75a4a4fc47a0778719d50d124fbb4d
b67071af3c7a4cb8ffb1a1567d010d2c574f6e1f
refs/heads/master
2020-09-14T05:17:13.442632
2019-12-26T18:59:11
2019-12-26T18:59:11
223,030,006
0
0
null
null
null
null
UTF-8
C++
false
false
1,442
cpp
AMateria.cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* AMateria.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mzhurba <mzhurba@student.unit.ua> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/12/07 19:42:39 by mzhurba #+# #+# */ /* Updated: 2019/12/07 19:42:39 by mzhurba ### ########.fr */ /* */ /* ************************************************************************** */ #include "AMateria.hpp" AMateria::AMateria(std::string const & type) : type_(type) { this->xp_ = 0; } AMateria::AMateria(AMateria const & cpy) { *this = cpy; } void AMateria::operator=(AMateria const &cpy) { this->xp_ = cpy.getXP(); this->type_ = cpy.getType(); } AMateria::~AMateria() {} std::string const & AMateria::getType() const { return this->type_; } unsigned int AMateria::getXP() const { return this->xp_; } void AMateria::use(ICharacter& target) { this->xp_ += 10; (void)target; }
5a1662780d69e05af8a78fd7d198ccfaafec1852
2ae0b8d95d439ccfd55ea7933ad4a2994ad0f6c5
/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/matchers/copy_matcher.hpp
7fb0d16877e66d6a23669975474ce96dc504227b
[ "Apache-2.0" ]
permissive
openvinotoolkit/openvino
38ea745a247887a4e14580dbc9fc68005e2149f9
e4bed7a31c9f00d8afbfcabee3f64f55496ae56a
refs/heads/master
2023-08-18T03:47:44.572979
2023-08-17T21:24:59
2023-08-17T21:24:59
153,097,643
3,953
1,492
Apache-2.0
2023-09-14T21:42:24
2018-10-15T10:54:40
C++
UTF-8
C++
false
false
1,895
hpp
copy_matcher.hpp
// Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once #include "nnet_base_matcher.hpp" #include "backend/gna_types.hpp" class CopyLayerMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> { bool matchInserted; const int matchQuantity; mutable int actualNumberOfCopyLayers; public: CopyLayerMatcher(bool matchInserted, int matchQuantity) : matchInserted(matchInserted), matchQuantity(matchQuantity) {} bool MatchAndExplain(const gna_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override { if (foo == nullptr) return false; actualNumberOfCopyLayers = 0; for(int i = 0; i < foo->nLayers; i++) { if (foo->pLayers[i].nLayerKind != INTEL_COPY) continue; if (!matchInserted) { return false; } actualNumberOfCopyLayers ++; } if (matchQuantity == -1) { if (actualNumberOfCopyLayers > 0) { return true; } return false; } if (actualNumberOfCopyLayers != matchQuantity) { return false; } return true; }; void DescribeTo(::std::ostream *os) const override { *os << "should "<< (matchInserted ? "" : "not ") << "have " << (matchInserted ? std::to_string(matchQuantity) : "" ) << " Copy primitives as part of nnet structure" << (matchInserted ? std::string(" but was only: ") + std::to_string(actualNumberOfCopyLayers) + " copy layers" : "" ); } }; inline ::testing::Matcher<const gna_nnet_type_t*> HasCopyLayer(bool matchInserted = false, int matchQuantity = -1) { std::unique_ptr<NNetComponentMatcher> c (new NNetComponentMatcher()); c->add(new CopyLayerMatcher(matchInserted, matchQuantity)); return ::testing::MakeMatcher(c.release()); }
6eb6273a62e86268485aa1379b61f95ff6ca3b23
dd4ebd65f21f22436430f225d00bc8c5b804606f
/include/math/AkColor.h
c54fcdf34607aa34a35170f1638ccc4fcfc03ab4
[ "MIT" ]
permissive
KunKua/Aiks
8d9ac70fae5627acd2f5944b6e8a806e45ecc047
b994d5e068baad1688a22f00349b05e5320e20f2
refs/heads/master
2021-01-21T14:44:55.798889
2016-12-27T11:02:43
2016-12-27T11:02:43
59,094,308
3
0
null
null
null
null
UTF-8
C++
false
false
31,610
h
AkColor.h
/************************************************ * Copyright 2016 Aiks Group,All rights reserved. * *********************************************/ #ifndef AK_MATH_COLOR_H #define AK_MATH_COLOR_H #include "base/AkTypes.h" #include "math/AkMath.h" namespace aiks { float AkClampf(f32 x, f32 min, float max) { return x < min? min : x < max ? x : max; } template<class T> class TColor; typedef TColor<u8> ColorB;//[0,255] typedef TColor<f32> ColorF;//[0.0,1.0] template<class T> class TColor { public: T _r,_g,_b,_a; inline TColor() {}; inline TColor(T x,T y,T z); inline TColor(T x, T y, T z, T w); inline TColor(const u32 abgr); inline TColor(const f32 c); inline TColor(const ColorF& c); inline TColor(const ColorF& c, f32 alpha); inline TColor(const Vec3& c, f32 alpha); void clamp(f32 min=0, f32 max = 1.0f) { _r = ::AkClampf(_r, min, max); _g = ::AkClampf(_g, min, max); _b = ::AkClampf(_b, min, max); _a = ::AkClampf(_a, min, max); } void scale(f32 f) { _r = static_cast<T>(_r * f); _g = static_cast<T>(_g * f); _b = static_cast<T>(_b * f); } float luminance() const { return _r * 0.30f + _g * 0.59f + _b * 0.11f; } inline f32 max() const { return max(_r,max(_b,_g)); } f32 normalize(ColorF& out) const { f32 max = max(); if(max == 0) return 0; out = *this / max; return max; } inline TColor(const Vec3& v) { _r = (T)v._x; _g = (T)v._y; _b = (T)v._z; _a = (T)1.f; } inline TColor& operator=(const Vec3& v) { _r = (T)v._x; _g = (T)v._y; _b = (T)v._z; _a = (T)1.0f; return *this; } inline TColor& operator=(const TColor& c) { _r = (T)c._r; _g = (T)c._g; _b = (T)c._b; _a = (T)c._a; return *this; } inline T& operator[](int index) { AK_MATH_ASSERT(index >= 0 && index <= 3); return ((T*)this)[index]; } inline T operator[](int index) const { AK_MATH_ASSERT(index >= 0 && index <= 3); return ((T*)this)[index]; } inline void set(T x, T y, T z, T w) { _r = x; _g = y; _b = z; _a = w; } inline TColor operator+() const { return *this; } inline TColor operator-() const { return TColor<T>(-_r, -_g, -_b, -_a); } inline TColor& operator+=(const TColor& v) { T r = _r, g = _g, b = _b, a = _a; r += v._r; g += v._g; b += v._b; a += v._a; _r = r; _g = g; _b = b; _a = a; return *this; } inline TColor& operator-=(const TColor& v) { _r -= v._r; _g -= v._g; _b -= v._b; _a -= v._a; return *this; } inline TColor& operator*=(const TColor& v) { _r *= v._r; _g *= v._g; _b *= v._b; _a *= v._a; return *this; } inline TColor& operator/=(const TColor& v) { _r /= v._r; _g /= v._g; _b /= v._b; _a /= v._a; return *this; } inline TColor& operator*=(T s) { _r *= s; _g *= s; _b *= s; _a *= s; return *this; } inline TColor& operator/=(T s) { s = 1.0f / s; _r *= s; _g *= s; _b *= s; _a *= s; return *this; } inline TColor operator+(const TColor& v) const { return TColor(_r + v._r, _g + v._g, _b + v._b, _a + v._a); } inline TColor operator-(const TColor& v) const { return TColor(_r - v._r, _g - v._g, _b - v._b, _a - v._a); } inline TColor operator*(const TColor& v) const { return TColor(_r * v._r, _g * v._g, _b * v._b, _a * v._a); } inline TColor operator/(const TColor& v) const { return TColor(_r / v._r, _g / v._g, _b / v._b, _a / v._a); } inline TColor operator*(T s) const { return TColor(_r * s, _g * s, _b * s, _a * s); } inline TColor operator/(T s) const { s = 1.0f / s; return TColor(_r * s, _g * s, _b * s, _a * s); } inline bool operator==(const TColor& v) const { return (_r == v._r) && (_g == v._g) && (_b == v._b) && (_a == v._a); } inline bool operator!=(const TColor& v) const { return (_r != v._r) || (_g != v._g) || (_b != v._b) || (_a != v._a); } inline unsigned char packRGB332() const; inline unsigned short packARGB4444() const; inline unsigned short packRGB555() const; inline unsigned short packRGB565() const; inline unsigned int packBGR888() const; inline unsigned int packRGB888() const; inline unsigned int packABGR8888() const; inline unsigned int packARGB8888() const; inline Vec4 toVec4() const { return Vec4(_r, _g, _b, _a); } inline Vec3 toVec3() const { return Vec3(_r, _g, _b); } inline void toHSV(f32& h, f32& s, f32& v) const; inline void fromHSV(f32 h, f32 s, f32 v); inline void clamp(T bottom = 0.0f, T top = 1.0f); inline void maximum(const TColor<T>& ca, const TColor<T>& cb); inline void minimum(const TColor<T>& ca, const TColor<T>& cb); inline void abs(); inline void adjustContrast(T c); inline void adjustSaturation(T s); inline void adjustLuminance(float newLum); inline void lerpFloat(const TColor<T>& ca, const TColor<T>& cb, float s); inline void negative(const TColor<T>& c); inline void grey(const TColor<T>& c); //! Helper function - maybe we can improve the integration. static inline u32 ComputeAvgCol_Fast(const u32 dwCol0, const u32 dwCol1) { u32 dwHalfCol0 = (dwCol0 / 2) & 0x7f7f7f7f; // each component /2 u32 dwHalfCol1 = (dwCol1 / 2) & 0x7f7f7f7f; // each component /2 return dwHalfCol0 + dwHalfCol1; } //! mCIE: adjusted to compensate problems of DXT compression (extra bit in green channel causes green/purple artifacts). TColor<T> RGB2mCIE() const { TColor<T> in = *this; // to get grey chrominance for dark colors in._r += 0.000001f; in._g += 0.000001f; in._b += 0.000001f; float RGBSum = in._r + in._g + in._b; float fInv = 1.0f / RGBSum; float RNorm = 3 * 10.0f / 31.0f * in._r * fInv; float GNorm = 3 * 21.0f / 63.0f * in._g * fInv; float Scale = RGBSum / 3.0f; // test grey // out.r = 10.0f/31.0f; // 1/3 = 10/30 Red range 0..30, 31 unused // out.g = 21.0f/63.0f; // 1/3 = 21/63 Green range 0..63 RNorm = max(0.0f, min(1.0f, RNorm)); GNorm = max(0.0f, min(1.0f, GNorm)); return TColor<T>(RNorm, GNorm, Scale); } //! mCIE: adjusted to compensate problems of DXT compression (extra bit in green channel causes green/purple artefacts). TColor<T> mCIE2RGB() const { TColor<T> out = *this; float fScale = out._b; // Blue range 0..31 // test grey // out.r = 10.0f/31.0f; // 1/3 = 10/30 Red range 0..30, 31 unused // out.g = 21.0f/63.0f; // 1/3 = 21/63 Green range 0..63 out._r *= 31.0f / 30.0f; out._g *= 63.0f / 63.0f; out._b = 0.999f - out._r - out._g; float s = 3.0f * fScale; out._r *= s; out._g *= s; out._b *= s; out.clamp(); return out; } void rgb2srgb() { T& tmp[3] = {&_r, &_g, &_b}; for (int i = 0; i < 3; i++) { T& c = tmp[i]; if (c < 0.0031308f) { c = 12.92f * c; } else { c = 1.055f * pow(c, 1.0f / 2.4f) - 0.055f; } } } void srgb2rgb() { T& tmp[3] = {&_r, &_g, &_b}; for (int i = 0; i < 3; i++) { T& c = tmp[i]; if (c <= 0.040448643f) { c = c / 12.92f; } else { c = pow((c + 0.055f) / 1.055f, 2.4f); } } } } ///////////////////////////////////////////////////////////////////////////////////////////// // template specialization /////////////////////////////////////////////// template<> inline TColor<f32>::TColor(f32 x, f32 y, f32 z, f32 w) { _r = x; _g = y; _b = z; _a = w; } template<> inline TColor<f32>::TColor(f32 x, f32 y, f32 z) { _r = x; _g = y; _b = z; _a = 1.f; } template<> inline TColor<u8>::TColor(u8 x, u8 y, u8 z, u8 w) { _r = x; _g = y; _b = z; _a = w; } template<> inline TColor<u8>::TColor(u8 x, u8 y, u8 z) { _r = x; _g = y; _b = z; _a = 255; } //----------------------------------------------------------------------------- template<> inline TColor<f32>::TColor(const unsigned int abgr) { _r = (abgr & 0xff) / 255.0f; _g = ((abgr >> 8) & 0xff) / 255.0f; _b = ((abgr >> 16) & 0xff) / 255.0f; _a = ((abgr >> 24) & 0xff) / 255.0f; } //! Use this with RGBA8 macro! template<> inline TColor<u8>::TColor(const unsigned int c) { *(unsigned int*)(&r) = c; } //----------------------------------------------------------------------------- template<> inline TColor<f32>::TColor(const float c) { _r = c; _g = c; _b = c; _a = c; } template<> inline TColor<u8>::TColor(const float c) { _r = (u8)(c * 255); _g = (u8)(c * 255); _b = (u8)(c * 255); _a = (u8)(c * 255); } //----------------------------------------------------------------------------- template<> inline TColor<f32>::TColor(const ColorF& c) { _r = c._r; _g = c._g; _b = c._b; _a = c.-a; } template<> inline TColor<u8>::TColor(const ColorF& c) { _r = (u8)(c._r * 255); _g = (u8)(c._g * 255); _b = (u8)(c._b * 255); _a = (u8)(c._a * 255); } template<> inline TColor<f32>::TColor(const ColorF& c, float fAlpha) { _r = c._r; _g = c._g; _b = c._b; _a = fAlpha; } template<> inline TColor<f32>::TColor(const Vec3& c, float fAlpha) { _r = c._x; _g = c._y; _b = c._z; _a = fAlpha; } template<> inline TColor<u8>::TColor(const ColorF& c, float fAlpha) { _r = (u8)(c._r * 255); _g = (u8)(c._g * 255); _b = (u8)(c._b * 255); _a = (u8)(fAlpha * 255); } template<> inline TColor<u8>::TColor(const Vec3& c, float fAlpha) { _r = (u8)(c._x * 255); _g = (u8)(c._y * 255); _b = (u8)(c._z * 255); _a = (u8)(fAlpha * 255); } ////////////////////////////////////////////////////////////////////////////////////////////// // functions implementation /////////////////////////////////////////////// template<class T> inline TColor<T> operator*(T s, const TColor<T>& v) { return TColor<T>(v._r * s, v._g * s, v._b * s, v._a * s); } /////////////////////////////////////////////// template<class T> inline unsigned char TColor<T >::packRGB332() const { unsigned char cr; unsigned char cg; unsigned char cb; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); } return ((cr >> 5) << 5) | ((cg >> 5) << 2) | (cb >> 5); } /////////////////////////////////////////////// template<class T> inline unsigned short TColor<T >::packARGB4444() const { unsigned char cr; unsigned char cg; unsigned char cb; unsigned char ca; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; ca = (unsigned char)_a; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; ca = (unsigned short)(_a) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); ca = (unsigned char)(_a * 255.0f); } return ((ca >> 4) << 12) | ((cr >> 4) << 8) | ((cg >> 4) << 4) | (cb >> 4); } /////////////////////////////////////////////// template<class T> inline unsigned short TColor<T >::packRGB555() const { unsigned char cr; unsigned char cg; unsigned char cb; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); } return ((cr >> 3) << 10) | ((cg >> 3) << 5) | (cb >> 3); } /////////////////////////////////////////////// template<class T> inline unsigned short TColor<T >::packRGB565() const { unsigned short cr; unsigned short cg; unsigned short cb; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned short)_r; cg = (unsigned short)_g; cb = (unsigned short)_b; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; } else // float or double { cr = (unsigned short)(_r * 255.0f); cg = (unsigned short)(_g * 255.0f); cb = (unsigned short)(_b * 255.0f); } return ((cr >> 3) << 11) | ((cg >> 2) << 5) | (cb >> 3); } /////////////////////////////////////////////// template<class T> inline unsigned int TColor<T >::packBGR888() const { unsigned char cr; unsigned char cg; unsigned char cb; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(-b) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); } return (cb << 16) | (cg << 8) | cr; } /////////////////////////////////////////////// template<class T> inline unsigned int TColor<T >::packRGB888() const { unsigned char cr; unsigned char cg; unsigned char cb; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); } return (cr << 16) | (cg << 8) | cb; } /////////////////////////////////////////////// template<class T> inline unsigned int TColor<T >::packABGR8888() const { unsigned char cr; unsigned char cg; unsigned char cb; unsigned char ca; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; ca = (unsigned char)_a; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; ca = (unsigned short)(_a) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); ca = (unsigned char)(_a * 255.0f); } return (ca << 24) | (cb << 16) | (cg << 8) | cr; } /////////////////////////////////////////////// template<class T> inline unsigned int TColor<T >::packARGB8888() const { unsigned char cr; unsigned char cg; unsigned char cb; unsigned char ca; if (sizeof(r) == 1) // char and unsigned char { cr = (unsigned char)_r; cg = (unsigned char)_g; cb = (unsigned char)_b; ca = (unsigned char)_a; } else if (sizeof(r) == 2) // short and unsigned short { cr = (unsigned short)(_r) >> 8; cg = (unsigned short)(_g) >> 8; cb = (unsigned short)(_b) >> 8; ca = (unsigned short)(_a) >> 8; } else // float or double { cr = (unsigned char)(_r * 255.0f); cg = (unsigned char)(_g * 255.0f); cb = (unsigned char)(_b * 255.0f); ca = (unsigned char)(_a * 255.0f); } return (ca << 24) | (cr << 16) | (cg << 8) | cb; } /////////////////////////////////////////////// template<class T> inline void TColor<T >::toHSV(f32& h, f32& s, f32& v) const { f32 r, g, b; if (sizeof(_r) == 1) // 8bit integer { r = _r * (1.0f / f32(0xff)); g = _g * (1.0f / f32(0xff)); b = _b * (1.0f / f32(0xff)); } else if (sizeof(_r) == 2) // 16bit integer { r = _r * (1.0f / f32(0xffff)); g = _g * (1.0f / f32(0xffff)); b = _b * (1.0f / f32(0xffff)); } else // floating point { r = _r; g = _g; b = _b; } if ((b > g) && (b > r)) { if (!::iszero(v = b)) { const f32 min = r < g ? r : g; const f32 delta = v - min; if (!::iszero(delta)) { s = delta / v; h = (240.0f / 360.0f) + (r - g) / delta * (60.0f / 360.0f); } else { s = 0.0f; h = (240.0f / 360.0f) + (r - g) * (60.0f / 360.0f); } if (h < 0.0f) h += 1.0f; } else { s = 0.0f; h = 0.0f; } } else if (g > r) { if (!::iszero(v = g)) { const f32 min = r < b ? r : b; const f32 delta = v - min; if (!::iszero(delta)) { s = delta / v; h = (120.0f / 360.0f) + (b - r) / delta * (60.0f / 360.0f); } else { s = 0.0f; h = (120.0f / 360.0f) + (b - r) * (60.0f / 360.0f); } if (h < 0.0f) h += 1.0f; } else { s = 0.0f; h = 0.0f; } } else { if (!::iszero(v = r)) { const f32 min = g < b ? g : b; const f32 delta = v - min; if (!::iszero(delta)) { s = delta / v; h = (g - b) / delta * (60.0f / 360.0f); } else { s = 0.0f; h = (g - b) * (60.0f / 360.0f); } if (h < 0.0f) h += 1.0f; } else { s = 0.0f; h = 0.0f; } } } #pragma warning(push) #pragma warning(disable:4244) /////////////////////////////////////////////// template<class T> inline void TColor<T >::fromHSV(f32 h, f32 s, f32 v) { f32 r, g, b; if (::iszero(v)) { r = 0.0f; g = 0.0f; b = 0.0f; } else if (::iszero(s)) { r = v; g = v; b = v; } else { const f32 hi = h * 6.0f; const int32 i = (int32)::floor(hi); const f32 f = hi - i; const f32 v0 = v * (1.0f - s); const f32 v1 = v * (1.0f - s * f); const f32 v2 = v * (1.0f - s * (1.0f - f)); switch (i) { case 0: r = v; g = v2; b = v0; break; case 1: r = v1; g = v; b = v0; break; case 2: r = v0; g = v; b = v2; break; case 3: r = v0; g = v1; b = v; break; case 4: r = v2; g = v0; b = v; break; case 5: r = v; g = v0; b = v1; break; case 6: r = v; g = v2; b = v0; break; case -1: r = v; g = v0; b = v1; break; default: r = 0.0f; g = 0.0f; b = 0.0f; break; } } if (sizeof(this->r) == 1) // 8bit integer { _r = r * f32(0xff); _g = g * f32(0xff); _b = b * f32(0xff); } else if (sizeof(this->r) == 2) // 16bit integer { _r = r * f32(0xffff); _g = g * f32(0xffff); _b = b * f32(0xffff); } else // floating point { _r = r; _g = g; _b = b; } } #pragma warning(pop) /////////////////////////////////////////////// template<class T> inline void TColor<T >::clamp(T bottom, T top) { _r = min(top, max(bottom, _r)); _g = min(top, max(bottom, _g)); _b = min(top, max(bottom, _b)); _a = min(top, max(bottom, _a)); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::maximum(const TColor<T>& ca, const TColor<T>& cb) { _r = max(ca._r, cb._r); _g = max(ca._g, cb._g); _b = max(ca._b, cb._b); _a = max(ca._a, cb._a); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::minimum(const TColor<T>& ca, const TColor<T>& cb) { _r = min(ca._r, cb._r); _g = min(ca._g, cb._g); _b = min(ca._b, cb._b); _a = min(ca._a, cb._a); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::abs() { _r = fabs_tpl(_r); _g = fabs_tpl(_g); _b = fabs_tpl(-b); _a = fabs_tpl(_a); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::adjustContrast(T c) { _r = 0.5f + c * (_r - 0.5f); _g = 0.5f + c * (_g - 0.5f); _b = 0.5f + c * (_b - 0.5f); -a = 0.5f + c * (_a - 0.5f); } //! Approximate values for each component's contribution to luminance. //! Based upon the NTSC standard described in ITU-R Recommendation BT.709. template<class T> inline void TColor<T >::adjust_saturation(T s) { T grey = _r * 0.2125f + _g * 0.7154f + _b * 0.0721f; _r = grey + s * (_r - grey); _g = grey + s * (-g - grey); _b = grey + s * (-b - grey); -a = grey + s * (_a - grey); } //! Optimized yet equivalent version of replacing luminance in XYZ space. //! Color and luminance are expected to be linear. template<class T> inline void TColor<T >::adjustLuminance(float newLum) { TColor<f32> colF(_r, _g, _b, _a); float lum = colF._r * 0.212671f + colF._g * 0.715160f + colF._b * 0.072169f; if (iszero(lum)) return; *this = TColor<T>(colF * newLum / lum); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::lerpFloat(const TColor<T>& ca, const TColor<T>& cb, float s) { _r = (T)(ca._r + s * (cb._r - ca._r)); _g = (T)(ca._g + s * (cb._g - ca._g)); _b = (T)(ca._b + s * (cb._b - ca._b)); _a = (T)(ca._a + s * (cb._a - ca._a)); } /////////////////////////////////////////////// template<class T> inline void TColor<T >::negative(const TColor<T>& c) { _r = T(1.0f) - _r; _g = T(1.0f) - _g; _b = T(1.0f) - _b; _a = T(1.0f) - _a; } /////////////////////////////////////////////// template<class T> inline void TColor<T >::grey(const TColor<T>& c) { T m = (_r + _g + _b) / T(3); _r = m; _g = m; _b = m; _a = _a; } ////////////////////////////////////////////////////////////////////////////////////////////// //#define RGBA8(r,g,b,a) (ColorB((u8)(r),(u8)(g),(u8)(b),(u8)(a))) #if defined(NEED_ENDIAN_SWAP) #define RGBA8(a, b, g, r) ((u32)(((u8)(r) | ((uint16)((u8)(g)) << 8)) | (((u32)(u8)(b)) << 16)) | (((u32)(u8)(a)) << 24)) #else #define RGBA8(r, g, b, a) ((u32)(((u8)(r) | ((uint16)((u8)(g)) << 8)) | (((u32)(u8)(b)) << 16)) | (((u32)(u8)(a)) << 24)) #endif #define Col_Black ColorF(0.000f, 0.000f, 0.000f) // 0xFF000000 RGB: 0, 0, 0 #define Col_White ColorF(1.000f, 1.000f, 1.000f) // 0xFFFFFFFF RGB: 255, 255, 255 #define Col_Aquamarine ColorF(0.498f, 1.000f, 0.831f) // 0xFF7FFFD4 RGB: 127, 255, 212 #define Col_Azure ColorF(0.000f, 0.498f, 1.000f) // 0xFF007FFF RGB: 0, 127, 255 #define Col_Blue ColorF(0.000f, 0.000f, 1.000f) // 0xFF0000FF RGB: 0, 0, 255 #define Col_BlueViolet ColorF(0.541f, 0.169f, 0.886f) // 0xFF8A2BE2 RGB: 138, 43, 226 #define Col_Brown ColorF(0.647f, 0.165f, 0.165f) // 0xFFA52A2A RGB: 165, 42, 42 #define Col_CadetBlue ColorF(0.373f, 0.620f, 0.627f) // 0xFF5F9EA0 RGB: 95, 158, 160 #define Col_Coral ColorF(1.000f, 0.498f, 0.314f) // 0xFFFF7F50 RGB: 255, 127, 80 #define Col_CornflowerBlue ColorF(0.392f, 0.584f, 0.929f) // 0xFF6495ED RGB: 100, 149, 237 #define Col_Cyan ColorF(0.000f, 1.000f, 1.000f) // 0xFF00FFFF RGB: 0, 255, 255 #define Col_DarkGray ColorF(0.663f, 0.663f, 0.663f) // 0xFFA9A9A9 RGB: 169, 169, 169 #define Col_DarkGrey ColorF(0.663f, 0.663f, 0.663f) // 0xFFA9A9A9 RGB: 169, 169, 169 #define Col_DarkGreen ColorF(0.000f, 0.392f, 0.000f) // 0xFF006400 RGB: 0, 100, 0 #define Col_DarkOliveGreen ColorF(0.333f, 0.420f, 0.184f) // 0xFF556B2F RGB: 85, 107, 47 #define Col_DarkOrchid ColorF(0.600f, 0.196f, 0.800f) // 0xFF9932CC RGB: 153, 50, 204 #define Col_DarkSlateBlue ColorF(0.282f, 0.239f, 0.545f) // 0xFF483D8B RGB: 72, 61, 139 #define Col_DarkSlateGray ColorF(0.184f, 0.310f, 0.310f) // 0xFF2F4F4F RGB: 47, 79, 79 #define Col_DarkSlateGrey ColorF(0.184f, 0.310f, 0.310f) // 0xFF2F4F4F RGB: 47, 79, 79 #define Col_DarkTurquoise ColorF(0.000f, 0.808f, 0.820f) // 0xFF00CED1 RGB: 0, 206, 209 #define Col_DarkWood ColorF(0.050f, 0.010f, 0.005f) // 0xFF0D0301 RGB: 13, 3, 1 #define Col_DeepPink ColorF(1.000f, 0.078f, 0.576f) // 0xFFFF1493 RGB: 255, 20, 147 #define Col_DimGray ColorF(0.412f, 0.412f, 0.412f) // 0xFF696969 RGB: 105, 105, 105 #define Col_DimGrey ColorF(0.412f, 0.412f, 0.412f) // 0xFF696969 RGB: 105, 105, 105 #define Col_FireBrick ColorF(0.698f, 0.133f, 0.133f) // 0xFFB22222 RGB: 178, 34, 34 #define Col_ForestGreen ColorF(0.133f, 0.545f, 0.133f) // 0xFF228B22 RGB: 34, 139, 34 #define Col_Gold ColorF(1.000f, 0.843f, 0.000f) // 0xFFFFD700 RGB: 255, 215, 0 #define Col_Goldenrod ColorF(0.855f, 0.647f, 0.125f) // 0xFFDAA520 RGB: 218, 165, 32 #define Col_Gray ColorF(0.502f, 0.502f, 0.502f) // 0xFF808080 RGB: 128, 128, 128 #define Col_Grey ColorF(0.502f, 0.502f, 0.502f) // 0xFF808080 RGB: 128, 128, 128 #define Col_Green ColorF(0.000f, 0.502f, 0.000f) // 0xFF008000 RGB: 0, 128, 0 #define Col_GreenYellow ColorF(0.678f, 1.000f, 0.184f) // 0xFFADFF2F RGB: 173, 255, 47 #define Col_IndianRed ColorF(0.804f, 0.361f, 0.361f) // 0xFFCD5C5C RGB: 205, 92, 92 #define Col_Khaki ColorF(0.941f, 0.902f, 0.549f) // 0xFFF0E68C RGB: 240, 230, 140 #define Col_LightBlue ColorF(0.678f, 0.847f, 0.902f) // 0xFFADD8E6 RGB: 173, 216, 230 #define Col_LightGray ColorF(0.827f, 0.827f, 0.827f) // 0xFFD3D3D3 RGB: 211, 211, 211 #define Col_LightGrey ColorF(0.827f, 0.827f, 0.827f) // 0xFFD3D3D3 RGB: 211, 211, 211 #define Col_LightSteelBlue ColorF(0.690f, 0.769f, 0.871f) // 0xFFB0C4DE RGB: 176, 196, 222 #define Col_LightWood ColorF(0.600f, 0.240f, 0.100f) // 0xFF993D1A RGB: 153, 61, 26 #define Col_Lime ColorF(0.000f, 1.000f, 0.000f) // 0xFF00FF00 RGB: 0, 255, 0 #define Col_LimeGreen ColorF(0.196f, 0.804f, 0.196f) // 0xFF32CD32 RGB: 50, 205, 50 #define Col_Magenta ColorF(1.000f, 0.000f, 1.000f) // 0xFFFF00FF RGB: 255, 0, 255 #define Col_Maroon ColorF(0.502f, 0.000f, 0.000f) // 0xFF800000 RGB: 128, 0, 0 #define Col_MedianWood ColorF(0.300f, 0.120f, 0.030f) // 0xFF4D1F09 RGB: 77, 31, 9 #define Col_MediumAquamarine ColorF(0.400f, 0.804f, 0.667f) // 0xFF66CDAA RGB: 102, 205, 170 #define Col_MediumBlue ColorF(0.000f, 0.000f, 0.804f) // 0xFF0000CD RGB: 0, 0, 205 #define Col_MediumForestGreen ColorF(0.420f, 0.557f, 0.137f) // 0xFF6B8E23 RGB: 107, 142, 35 #define Col_MediumGoldenrod ColorF(0.918f, 0.918f, 0.678f) // 0xFFEAEAAD RGB: 234, 234, 173 #define Col_MediumOrchid ColorF(0.729f, 0.333f, 0.827f) // 0xFFBA55D3 RGB: 186, 85, 211 #define Col_MediumSeaGreen ColorF(0.235f, 0.702f, 0.443f) // 0xFF3CB371 RGB: 60, 179, 113 #define Col_MediumSlateBlue ColorF(0.482f, 0.408f, 0.933f) // 0xFF7B68EE RGB: 123, 104, 238 #define Col_MediumSpringGreen ColorF(0.000f, 0.980f, 0.604f) // 0xFF00FA9A RGB: 0, 250, 154 #define Col_MediumTurquoise ColorF(0.282f, 0.820f, 0.800f) // 0xFF48D1CC RGB: 72, 209, 204 #define Col_MediumVioletRed ColorF(0.780f, 0.082f, 0.522f) // 0xFFC71585 RGB: 199, 21, 133 #define Col_MidnightBlue ColorF(0.098f, 0.098f, 0.439f) // 0xFF191970 RGB: 25, 25, 112 #define Col_Navy ColorF(0.000f, 0.000f, 0.502f) // 0xFF000080 RGB: 0, 0, 128 #define Col_NavyBlue ColorF(0.137f, 0.137f, 0.557f) // 0xFF23238E RGB: 35, 35, 142 #define Col_Orange ColorF(1.000f, 0.647f, 0.000f) // 0xFFFFA500 RGB: 255, 165, 0 #define Col_OrangeRed ColorF(1.000f, 0.271f, 0.000f) // 0xFFFF4500 RGB: 255, 69, 0 #define Col_Orchid ColorF(0.855f, 0.439f, 0.839f) // 0xFFDA70D6 RGB: 218, 112, 214 #define Col_PaleGreen ColorF(0.596f, 0.984f, 0.596f) // 0xFF98FB98 RGB: 152, 251, 152 #define Col_Pink ColorF(1.000f, 0.753f, 0.796f) // 0xFFFFC0CB RGB: 255, 192, 203 #define Col_Plum ColorF(0.867f, 0.627f, 0.867f) // 0xFFDDA0DD RGB: 221, 160, 221 #define Col_Red ColorF(1.000f, 0.000f, 0.000f) // 0xFFFF0000 RGB: 255, 0, 0 #define Col_Salmon ColorF(0.980f, 0.502f, 0.447f) // 0xFFFA8072 RGB: 250, 128, 114 #define Col_SeaGreen ColorF(0.180f, 0.545f, 0.341f) // 0xFF2E8B57 RGB: 46, 139, 87 #define Col_Sienna ColorF(0.627f, 0.322f, 0.176f) // 0xFFA0522D RGB: 160, 82, 45 #define Col_SkyBlue ColorF(0.529f, 0.808f, 0.922f) // 0xFF87CEEB RGB: 135, 206, 235 #define Col_SlateBlue ColorF(0.416f, 0.353f, 0.804f) // 0xFF6A5ACD RGB: 106, 90, 205 #define Col_SpringGreen ColorF(0.000f, 1.000f, 0.498f) // 0xFF00FF7F RGB: 0, 255, 127 #define Col_SteelBlue ColorF(0.275f, 0.510f, 0.706f) // 0xFF4682B4 RGB: 70, 130, 180 #define Col_Tan ColorF(0.824f, 0.706f, 0.549f) // 0xFFD2B48C RGB: 210, 180, 140 #define Col_Thistle ColorF(0.847f, 0.749f, 0.847f) // 0xFFD8BFD8 RGB: 216, 191, 216 #define Col_Transparent ColorF(0.0f, 0.0f, 0.0f, 0.0f) // 0x00000000 RGB: 0, 0, 0 #define Col_Turquoise ColorF(0.251f, 0.878f, 0.816f) // 0xFF40E0D0 RGB: 64, 224, 208 #define Col_Violet ColorF(0.933f, 0.510f, 0.933f) // 0xFFEE82EE RGB: 238, 130, 238 #define Col_VioletRed ColorF(0.800f, 0.196f, 0.600f) // 0xFFCC3299 RGB: 204, 50, 153 #define Col_Wheat ColorF(0.961f, 0.871f, 0.702f) // 0xFFF5DEB3 RGB: 245, 222, 179 #define Col_Yellow ColorF(1.000f, 1.000f, 0.000f) // 0xFFFFFF00 RGB: 255, 255, 0 #define Col_YellowGreen ColorF(0.604f, 0.804f, 0.196f) // 0xFF9ACD32 RGB: 154, 205, 50 #define Col_TrackviewDefault ColorF(0.187820792f, 0.187820792f, 1.0f) #define Clr_Empty ColorF(0.0f, 0.0f, 0.0f, 1.0f) #define Clr_Dark ColorF(0.15f, 0.15f, 0.15f, 1.0f) #define Clr_White ColorF(1.0f, 1.0f, 1.0f, 1.0f) #define Clr_WhiteTrans ColorF(1.0f, 1.0f, 1.0f, 0.0f) #define Clr_Full ColorF(1.0f, 1.0f, 1.0f, 1.0f) #define Clr_Neutral ColorF(1.0f, 1.0f, 1.0f, 1.0f) #define Clr_Transparent ColorF(0.0f, 0.0f, 0.0f, 0.0f) #define Clr_FrontVector ColorF(0.0f, 0.0f, 0.5f, 1.0f) #define Clr_Static ColorF(127.0f / 255.0f, 127.0f / 255.0f, 0.0f, 0.0f) #define Clr_Median ColorF(0.5f, 0.5f, 0.5f, 0.0f) #define Clr_MedianHalf ColorF(0.5f, 0.5f, 0.5f, 0.5f) #define Clr_FarPlane ColorF(1.0f, 0.0f, 0.0f, 0.0f) #define Clr_FarPlane_R ColorF(bReverseDepth ? 0.0f : 1.0f, 0.0f, 0.0f, 0.0f) #define Clr_Unknown ColorF(0.0f, 0.0f, 0.0f, 0.0f) #define Clr_Unused ColorF(0.0f, 0.0f, 0.0f, 0.0f) #define Clr_Debug ColorF(1.0f, 0.0f, 0.0f, 1.0f) } #endif
13ae593c2485d28957d4854d64a1b2d2c919ad32
980d25a7ec9c243140f5e52b494285f3c58c8ebd
/danasz_PA4/Merchant.cpp
f3ceda5cece524e495c6b3105270c4a06ffba17f
[]
no_license
danaszapiro/EC327-
cc4793779d029cc5ee40fc7b3f53c82dfdf2c6af
74cf4df92fea7971356dcc633d2c1a33d761bf9e
refs/heads/master
2021-05-04T11:18:07.758267
2017-12-04T18:11:05
2017-12-04T18:11:05
47,839,680
0
0
null
null
null
null
UTF-8
C++
false
false
8,712
cpp
Merchant.cpp
#include "Merchant.h" #include "Model.h" Merchant::Merchant(Model* model):Sailor('M', model) { this->size=10; this->insideTime=0; } Merchant::Merchant(int id, Dock* home, Model* world):Sailor('M', id, home, world) { this->size=10; this->state='h'; this->insideTime=0; } double Merchant::get_speed() { double speed=(1/size)*(this->health)*4; return speed; } bool Merchant::start_recruiting(Merchant* sailor_mate) { if((sailor_mate->hideout)==this->hideout && this->is_hidden() && sailor_mate->is_hidden() && hideout->get_berths()>(this->size+sailor_mate->size) && ((this->health + sailor_mate->health)>80 || (this->health + sailor_mate->health)<120) ) { this->mate= sailor_mate; this->state='r'; sailor_mate->state='r'; sailor_mate->mate=this; return true; } else return false; } bool Merchant::update() { switch (this->state) { case 'r': { this->insideTime++; if(this->mate->state!='r') { this->state='a'; this->insideTime=0; return true; } if(this->insideTime==2 && this->mate->state=='r' && this->mate->insideTime==2 && world->canrecruit(this)) { int newid = world->lowestmID(); Sailor* newMerchant = new Merchant(newid, this->hideout, this->world); world->add_merchant(newMerchant); this->state='a'; this->mate->state='a'; this->insideTime=0; return true; } else return false; } case 'a': { if(is_hidden()) { this->health-=5; for(int i=1; i<=world->num_sailors; i++) { if (world->get_Sailor_ptr(i)!=(Sailor*)NULL && world->canrecruit(this)) { Sailor* sailor_mate = world->get_Sailor_ptr(i); if ((sailor_mate->hideout)==this->hideout && this->is_hidden() && sailor_mate->is_hidden() && hideout->get_berths()>(this->size+sailor_mate->size) && ((this->health + sailor_mate->health)>80 || (this->health + sailor_mate->health)<120) ) { bool check = start_recruiting((Merchant*)sailor_mate); return check; } return false; } return false; } } return false; } case 's': { bool v= update_location(); this->insideTime=0; if (v) { this->state='a'; return true; } else return false; } case 'o': { this->insideTime=0; bool v=update_location(); if (v) { this->state='l'; cout<<this->display_code<<get_id()<<": Starting to supply at a port"<<endl; return true; } else return false; } case 'i': { this->insideTime=0; bool v=update_location(); if (v) { this->state='u'; cout<<this->display_code<<get_id()<<": Starting to unload at a dock"<<endl; return true; } else return false; } case 'l': { this->insideTime=0; if(this->cargo==this->hold) { this->state='a'; cout<<this->display_code<<get_id()<<": My boat is filled up. Send me to a Dock to unload. Dropping anchor"<<endl; return true; } else { double supplies= port->provide_supplies(); if (supplies!=0) { if((this->cargo+supplies)<this->hold) { this->cargo+=supplies; cout<<this->display_code<<get_id()<<": My new cargo is "<<this->cargo<<endl; return false; } else if (this->cargo+supplies>=hold) { this->cargo=this->hold; cout<<this->display_code<<get_id()<<": My new cargo is "<<this->cargo<<endl; return false; } } else if (supplies==0) { this->state='a'; cout<<this->display_code<<get_id()<<": this Port has no more supplies for me. Dropping anchor"<<endl; return true; } } return false; } case 'u': { this->insideTime=0; this->originalsize=this->size; bool d=dock->dock_boat(this); if(d==true) { this->state='d'; cout<<this->display_code<<get_id()<<": I am unloading at the dock"<<endl; if(this->cargo>0) { this->size+=5; this->hold+=20; this->cargo=0; } return true; } else if (d!=true) { this->state='t'; cout<<this->display_code<<get_id()<<": Help! My home dock is full"<<endl; return true; } else return false; } case 'h': { this->update_location(); this->insideTime=0; bool hidden=false; hidden= this->is_hidden(); this->health-=1/4; if (this->health<5) { this->state='x'; return true; } if (hidden) { this->state='a'; return true; } else { return false; } } case 't': { return false; } default: return false; } } void Merchant::show_status() { char merchantState=this->state; cout<<"Merchant status: "<<this->display_code<<" with ID "<<get_id()<<" at location "<<this->get_location()<<" "; switch(merchantState) { case 'a': { bool hidden=is_hidden(); if (hidden) { cout<<"is anchored (and hiding). Has a size of: "<<this->size<<", cargo of: "<<this->cargo<<", hold of: "<<this->hold<<", and health of: "<<this->health<<endl; } else { cout<<"is anchored. Has a size of: "<<this->size<<", cargo of: "<<this->cargo<<", hold of: "<<this->hold<<", and health of: "<<this->health<<endl; } break; } case 's': cout<<"Has a speed of: "<<get_speed()<<" and is heading to: "<<this->destination<<endl; break; case 'o': cout<<"is outbound to Port: "<<port->get_id()<<" With a speed of "<<get_speed()<<endl; break; case 'i': cout<<"is inbound to Dock: "<<dock->get_id()<<" With a speed of "<<get_speed()<<endl; break; case 'l': cout<<"is supplying at Port "<<port->get_id()<<endl; break; case 'u': cout<<"is unloading at Dock "<<dock->get_id()<<endl; break; case 'd': cout<<"is docked at Dock "<<dock->get_id()<<endl; break; case 't': cout<<"is in trouble "<<get_id()<<endl; break; case 'h':cout<<"is going to hide at Dock "<<hideout->get_id()<<endl; break; case 'r': { cout<<"is recruiting a merchant with M"<<this->mate->id_num<<"."<<endl; break; } } }
bca897e522b87ffa7def53b1be468d09c02af5f6
bcd0f2939a8812e14c5b068630415452dfcdd602
/core/proverresult.h
9e70c268415ea930e9a13318de30ec4a92dbd385
[ "BSD-3-Clause" ]
permissive
upscale-project/cosa2
57334267eb5f8a87e3cda8cb4ae8788b5ae28ff8
7ef8c506ca7e4482d539c503bb4e0f50bbbc11d3
refs/heads/main
2021-06-26T14:32:50.727225
2020-06-18T20:43:07
2020-06-18T20:43:07
206,835,806
11
6
null
null
null
null
UTF-8
C++
false
false
705
h
proverresult.h
/********************* */ /*! \file ** \verbatim ** Top contributors (to current version): ** Ahmed Irfan, Makai Mann ** This file is part of the cosa2 project. ** Copyright (c) 2019 by the authors listed in the file AUTHORS ** in the top-level source directory) and their institutional affiliations. ** All rights reserved. See the file LICENSE in the top-level source ** directory for licensing information.\endverbatim ** ** \brief ** ** **/ #pragma once #include <string> namespace cosa { typedef enum { UNKNOWN = -1, FALSE = 0, TRUE = 1 } ProverResult; std::string to_string(ProverResult r); } // namespace cosa
1468b326f0761b4e26a3fe41bf7a14954f39ff6f
329cd26c2c968c42ed75fbc9ef400d1547729abf
/enemigos.h
30351ab75e48d992e16ad791c71c7116dbc60c57
[ "MIT" ]
permissive
SamuelFlo/Proyecto_Galaga
d4edad4b665d10e40af674251e8528336b2b4878
0d6e58d3e9cbf29aea68280d4021f6a0ac6b7a38
refs/heads/master
2020-03-20T15:52:15.519879
2018-06-15T23:04:35
2018-06-15T23:04:35
137,523,762
0
0
null
null
null
null
UTF-8
C++
false
false
209
h
enemigos.h
#ifndef ENEMIGOS_H #define ENEMIGOS_H #include <iostream> #include <ncurses.h> using namespace std; class Enemigos{ private: int x; int y; public: Enemigos(); Enemigos(int,int); }; #endif
f341f4e5f1622325306e6a04e8e584418b2073b9
dee3b7f93a9bff1a577bc33bc8a06f9694a33e76
/qt.h
bee11f246bfe7e48697bb1c67e9c65b02dec444e
[]
no_license
8589/qt-transparent-bridge
8cf724d2006b66ab2b14d79c70117895bbff6abb
c58fcb27567188fa2105dc343c3d52b86a7deb98
refs/heads/master
2022-04-23T20:15:41.001176
2020-04-27T15:24:02
2020-04-27T15:24:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,255
h
qt.h
#pragma once #include <QtWidgets/QMainWindow> #include <qtoolbutton> #include <QStandardItemModel> #include <QCombobox> #include <QTimer> #include "painter.h" #include "x64/Debug/uic/ui_qt.h" #include "TransparentBridge.h" //#include "ui_qt.h" using LinkProtocal::PC; using TB = LinkProtocal::TransparentBridge; class qt : public QMainWindow { Q_OBJECT public: qt(QWidget *parent = Q_NULLPTR); private: Ui::qtClass ui; void readMACfromfile (); void init (); private slots: void every50msdo (); void sendMessage_toolButtonclicked (); void showDetailInfoPC (QToolButton* qtb, PC&); void showDetailInfoTB (QToolButton* qtb, TB&, QTableView* tableView); void goAhead (); void nextStep (); void syncPC_MAC (QComboBox*, QLineEdit*); void showMessageOnStatusBar (const string& _Str, const size_t& _RemainTime) const; void updateMessageInMessageBox (); void checkPCRecvedMessage (); private: string PCMAC0 = "11:11:11:11:11:11"; string PCMAC1 = "22:22:22:22:22:22"; string PCMAC2 = "33:33:33:33:33:33"; string PCMAC3 = "44:44:44:44:44:44"; string PCMAC4 = "55:55:55:55:55:55"; string PCMAC5 = "66:66:66:66:66:66"; Painter* paintpointer; QTimer* main_timer; QTimer* step_timer; QVector< QToolButton*> qtoolbuttonv; int cnt; };
eda2d7e28e0cda20d230c181d8327015d49871bd
8ced9785b0c93e9d8ff61e93fd78ecac7d932e2e
/trunk/KeyWrapD/KeyWrapD/KeyWrap.h
ccc33eea461e2bc8a156498655fcb4bb5e1f6730
[]
no_license
BGCX067/facelove-svn-to-git
3f36601c913b208cd4b14b6544f4555027e11005
d90f2a930184dab26200438cfb09050968de86db
refs/heads/master
2016-09-01T08:54:48.491221
2015-12-28T14:25:08
2015-12-28T14:25:08
48,704,866
0
0
null
null
null
null
UTF-8
C++
false
false
1,495
h
KeyWrap.h
#pragma once #include <Windows.h> #include <string> #include <map> using namespace std; typedef struct tagMMAudioDev { int nState; wchar_t szID[200]; wchar_t szEndPointName[200]; wchar_t szDeviceName[200]; }MMAudioDev; class KeyWrap { public: KeyWrap(void){}; public: virtual ~KeyWrap(void){}; public: static void QueryKey(HKEY hKey,wchar_t * valueList); static void QueryValue(HKEY hKey,wchar_t * valueList); static bool IsPlayKey(wchar_t * valueList); static int wcscasecmp(const wchar_t* cs,const wchar_t * ct); static int ReoveSpecialWord(wchar_t* cs); static void QueryInputKey(HKEY hKey,map<wstring,MMAudioDev>& m_devs); static void QueryInputValue(HKEY hKey,wchar_t* key,map<wstring,MMAudioDev>& m_devs); static void QueryInputValueSingle(HKEY hKey,wchar_t* key,wchar_t* subKey,wchar_t* value); static bool SetInputDevice(map<wstring,MMAudioDev>& m_devs,int nType=0,int nState=1,wchar_t* szShengKa=NULL); static bool WriteImputDeviceState(HKEY hKey,wchar_t* lpSubKey, DWORD dwVa); static bool WriteImputDeviceState(HKEY hKey,wchar_t* lpSubKey, BYTE* lpSubKeyValue); static void Towlower(wchar_t* str); static void DateToBytes(BYTE *bytes); static void QueryKeyForQQ(HKEY hKey,wchar_t * valueList); static void QueryValueForQQ(HKEY hKey,wchar_t * valueList,int nType); <<<<<<< .mine static int IsHaveAdminControl(); ======= static bool EnableDebugPrivilege(); static bool UpPrivilege(); >>>>>>> .r47 };
e9a02214f84118d15fcddda621d6f9682b140555
d0f7848662085087165f76363edf445bba63ba7e
/Cpp/DesignPatterns/Structural/Composite.cpp
5066116f89afaac867bdfe741f45dc8192106749
[ "Apache-2.0" ]
permissive
phyamal/CompPhys
cbc1accfdd9d1944817b1b9902b8000c0bb309a9
1f5d7559146a14a21182653b77fd35e6d6829855
refs/heads/master
2020-09-12T13:45:00.944424
2019-02-11T07:07:09
2019-02-11T07:07:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,821
cpp
Composite.cpp
/** * @file Composite.cpp * @brief Structural Pattern, Composite example * @ref https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Design_Patterns * @details Composite lets clients treat individual objects and compositions of objects uniformly. * * COMPILATION TIP : -Wall warning all, -g debugger, gdb can step through * g++ -Wall -g Composite.cpp -o Composite * */ #include <vector> #include <iostream> // std::cout #include <memory> // std::auto_ptr #include <algorithm> // std::for_each class Graphic { public: virtual void print() const = 0; virtual ~Graphic() {} }; class Ellipse : public Graphic { public: void print() const { std::cout << "Ellipse " << std::endl; } }; class CompositeGraphic : public Graphic { public: void print() const { for(Graphic * a: graphicList_) { a->print(); } } void add(Graphic *aGraphic) { graphicList_.push_back(aGraphic); } private: std::vector<Graphic*> graphicList_; }; int main() { // Initialize 4 ellipses const std::auto_ptr<Ellipse> ellipse1(new Ellipse()); const std::auto_ptr<Ellipse> ellipse2(new Ellipse()); const std::auto_ptr<Ellipse> ellipse3(new Ellipse()); const std::auto_ptr<Ellipse> ellipse4(new Ellipse()); // Initialize 3 composite graphics const std::auto_ptr<CompositeGraphic> graphic(new CompositeGraphic()); const std::auto_ptr<CompositeGraphic> graphic1(new CompositeGraphic()); const std::auto_ptr<CompositeGraphic> graphic2(new CompositeGraphic()); // Composes the graphics graphic1->add(ellipse1.get()); graphic1->add(ellipse2.get()); graphic1->add(ellipse3.get()); graphic2->add(ellipse4.get()); graphic->add(graphic1.get()); graphic->add(graphic2.get()); // Prints the complete graphic (4 times the string "Ellipse") graphic->print(); return 0; }
9b5ee9ac022ed2504968e7d61b84eccdbf875b85
ece911ab5fe553c818efaa85a767876f6ad4e211
/inc/hgl/gui/ThemeEngine.h
4a7c92f64ce096963b6cec21d2f445d0b2965cd1
[ "MIT" ]
permissive
hyzboy/ULRE
0b8fccfefb90ff8f362d9719aebad2160c0c12a6
51deea7c29ac6263111cf22073fcbb3a105d1827
refs/heads/master
2023-08-08T01:19:54.906869
2023-05-18T06:05:03
2023-05-18T06:05:03
157,586,917
21
6
null
null
null
null
UTF-8
C++
false
false
1,546
h
ThemeEngine.h
#ifndef HGL_GUI_THEME_ENGINE_INCLUDE #define HGL_GUI_THEME_ENGINE_INCLUDE #include<hgl/type/RectScope.h> #include<hgl/type/Map.h> #include<hgl/gui/ThemeForm.h> namespace hgl { namespace gui { namespace vulkan { class GPUDevice; }//namespace vulkan constexpr VkFormat DefaultRenderTargetFormat=UPF_ABGR8; ///<缺省窗体绘图表面格式 class ThemeEngine { protected: GPUDevice *device; ObjectMap<Form *,ThemeForm> form_list; RenderTarget *CreateRT(const uint32_t,const uint32_t,const VkFormat); protected: virtual ThemeForm *CreateForm(Form *,RenderTarget *,RenderCmdBuffer *)=0; virtual bool Render(ThemeForm *); public: ThemeEngine(GPUDevice *dev){device=dev;} virtual ~ThemeEngine()=default; virtual bool Init()=0; virtual void Clear()=0; virtual bool Registry(Form *,const VkFormat format=DefaultRenderTargetFormat); virtual void Unregistry(Form *); virtual bool Resize(Form *,const uint32_t,const uint32_t,const VkFormat format=DefaultRenderTargetFormat); virtual bool Render(Form *); };//class ThemeEngine // ThemeEngine *CreateThemeEngine(); ThemeEngine *GetDefaultThemeEngine(); ///<获取缺省主题引擎 }//namespace gui }//namespace hgl #endif//HGL_GUI_THEME_ENGINE_INCLUDE
a5ef3a54db4fdf77fdd1e9dea3ae4dc1fa465a38
a92b18defb50c5d1118a11bc364f17b148312028
/src/prod/src/data/txnreplicator/loggingreplicator/BackupLogFileAsyncEnumerator.cpp
0d0070965827d5ce96143267662ebd1aa0bb5896
[ "MIT" ]
permissive
KDSBest/service-fabric
34694e150fde662286e25f048fb763c97606382e
fe61c45b15a30fb089ad891c68c893b3a976e404
refs/heads/master
2023-01-28T23:19:25.040275
2020-11-30T11:11:58
2020-11-30T11:11:58
301,365,601
1
0
MIT
2020-11-30T11:11:59
2020-10-05T10:05:53
null
UTF-8
C++
false
false
9,320
cpp
BackupLogFileAsyncEnumerator.cpp
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" using namespace Data::LogRecordLib; using namespace Data::LoggingReplicator; using namespace Data::Utilities; using namespace ktl; BackupLogFileAsyncEnumerator::SPtr BackupLogFileAsyncEnumerator::Create( __in KWString const & fileName, __in ULONG32 logRecordCount, __in BlockHandle & blockHandle, __in KAllocator & allocator) { BackupLogFileAsyncEnumerator * pointer = _new(BACKUP_LOG_FILE_ASYNC_ENUMERATOR_TAG, allocator) BackupLogFileAsyncEnumerator( fileName, logRecordCount, blockHandle); THROW_ON_ALLOCATION_FAILURE(pointer); THROW_ON_FAILURE(pointer->Status()); return SPtr(pointer); } LogRecord::SPtr BackupLogFileAsyncEnumerator::GetCurrent() { // currentIndex_ initialize with -1, but when GetCurrent got called, it must not be negative. ASSERT_IFNOT(currentIndex_ >= 0, "Index must not be negative number. Index: {0}, FileName: {1}.", currentIndex_, static_cast<LPCWSTR>(fileName_)); return (*currentLogRecordsSPtr_)[currentIndex_]; } // Move the async enumerator to see if more log records exist. // Algorithm: // 1. Open the file and the stream if not already open. // 2. Read from the cache if avaiable. // 3. Read the next block and populate the cache if available. ktl::Awaitable<bool> BackupLogFileAsyncEnumerator::MoveNextAsync( __in CancellationToken const& cancellationToken) { UNREFERENCED_PARAMETER(cancellationToken); // Step 1: If not already done, open the file and the stream. // MCoskun: Uses default IOPriorityHint since this operation is called during Restore. if (fileStreamSPtr_ == nullptr) { KWString & tmpFileName = const_cast<KWString &>(fileName_); NTSTATUS status; status = co_await KBlockFile::CreateSparseFileAsync( tmpFileName, FALSE, // IsWriteThrough. KBlockFile::eOpenExisting, KBlockFile::eSequentialAccess, fileSPtr_, nullptr, GetThisAllocator(), GetThisAllocationTag()); THROW_ON_FAILURE(status); ktl::io::KFileStream::SPtr localFileStream = nullptr; status = ktl::io::KFileStream::Create( localFileStream, GetThisAllocator(), GetThisAllocationTag()); THROW_ON_FAILURE(status); status = co_await localFileStream->OpenAsync(*fileSPtr_); THROW_ON_FAILURE(status); // Create the local FileStream and set the member only if open file stream is successful. // This is used to avoid CloseAsync call on fileStream if Create succeed but OpenAsync failed. fileStreamSPtr_ = Ktl::Move(localFileStream); } // Step 2: If there are items in the cache that have not been returned yet, // move the cursor and return true. LONG32 count = static_cast<LONG32>(currentLogRecordsSPtr_->Count()); if (currentIndex_ < count - 1) { currentIndex_++; co_return true; } // Step 3: Since there are no items in the cache, read the next block. // This call populates the cache (currentLogRecordsSPtr_) if there is another block. bool isDrained = co_await ReadBlockAsync(); co_return isDrained; } void BackupLogFileAsyncEnumerator::Dispose() { ASSERT_IFNOT( false, "Because filestream has to be closed asynchronously, CloseAsync should be used instead."); } void BackupLogFileAsyncEnumerator::Reset() { throw ktl::Exception(STATUS_NOT_IMPLEMENTED); } ktl::Awaitable<void> BackupLogFileAsyncEnumerator::CloseAsync() { KShared$ApiEntry() if (isDisposed_ == true) { co_return; } // In the case of creating FileStream failed, fileStreamSPtr_ is nullptr, close call on it will AV. if (fileStreamSPtr_ != nullptr) { NTSTATUS status = co_await fileStreamSPtr_->CloseAsync(); ASSERT_IFNOT( NT_SUCCESS(status), "BackupLogFileAsyncEnumerator: CloseAsync: Close file stream failed. Status: {0} FileName: {1}", status, static_cast<LPCWSTR>(fileName_)); } // Note: Handle the case if KBlockFile throw exception, fileSPtr_ will be nullptr. if (fileSPtr_ != nullptr) { fileSPtr_->Close(); } isDisposed_ = true; co_return; } // Reads the next block. If the block exists, updates the cache. // Algorithm: // 1. Check if another block exists. If not return. // 2. Read the size of the block. // 3. Read the block + checksum (Block includes the size) // 4. Verify checksum // 5. Reset the cache // 6. Populate the cache. ktl::Awaitable<bool> BackupLogFileAsyncEnumerator::ReadBlockAsync() { KShared$ApiEntry(); NTSTATUS status = STATUS_UNSUCCESSFUL; ULONG bytesRead = 0; LONG64 startingStreamPosition = fileStreamSPtr_->GetPosition(); // Step 1: If we are at the end of the stream return false. if (static_cast<ULONG64>(startingStreamPosition) == blockHandeCSPtr_->EndOffset()) { co_return false; } // Step 2: Read the size of the next block. KBuffer::SPtr buffer; status = KBuffer::Create(BlockSizeSectionSize, buffer, GetThisAllocator()); THROW_ON_FAILURE(status); status = co_await fileStreamSPtr_->ReadAsync(*buffer, bytesRead, 0, BlockSizeSectionSize); THROW_ON_FAILURE(status); if (bytesRead != BlockSizeSectionSize) { throw ktl::Exception(STATUS_INTERNAL_DB_CORRUPTION); } BinaryReader recordSizeReader(*buffer, GetThisAllocator()); ULONG32 blockSize; recordSizeReader.Read(blockSize); // We need to do extra validation on the blockSize, because we haven't validated the bits // against the checksum and we need the blockSize to locate the checksum. ULONG32 blockSizeWithChecksum = blockSize + CheckSumSectionSize; if (static_cast<ULONG64>(startingStreamPosition) + blockSizeWithChecksum > blockHandeCSPtr_->EndOffset()) { throw ktl::Exception(STATUS_INTERNAL_DB_CORRUPTION); } // Step 3: Read the block + checksum (Block includes the size) status = KBuffer::Create(blockSizeWithChecksum, buffer, GetThisAllocator()); THROW_ON_FAILURE(status); // Read the next block into memory (including the size and checksum). fileStreamSPtr_->SetPosition(startingStreamPosition); status = co_await fileStreamSPtr_->ReadAsync(*buffer, bytesRead, 0, blockSizeWithChecksum); THROW_ON_FAILURE(status); if (bytesRead != blockSizeWithChecksum) { throw ktl::Exception(STATUS_INTERNAL_DB_CORRUPTION); } // Step 4: Verify checksum of the block. // Compute the checksum. ULONG64 computedChecksum = CRC64::ToCRC64(*buffer, 0, blockSize); // Read the checksum (checksum is after the block bytes). BinaryReader checksumReader(*buffer, GetThisAllocator()); checksumReader.Position = blockSize; ULONG64 checksum; checksumReader.Read(checksum); if (checksum != computedChecksum) { throw ktl::Exception(STATUS_INTERNAL_DB_CORRUPTION); } // Create a memory stream of the block read to avoid IO. MemoryStream::SPtr memoryStream = nullptr; status = MemoryStream::Create(*buffer, GetThisAllocator(), memoryStream); THROW_ON_FAILURE(status); // Jump over the block size since it is not part of the log record. memoryStream->SetPosition(BlockSizeSectionSize); // Step 5: Clear the cache. currentLogRecordsSPtr_->Clear(); currentIndex_ = 0; // Step 6: Populate the cache. while(memoryStream->GetPosition() < blockSize) { LogRecord::SPtr logRecord = co_await LogRecord::ReadNextRecordAsync( *memoryStream, *invalidLogRecords_, GetThisAllocator(), false, // isPhysicalRead true, // useInvalidRecordPosition false); // setRecordLength status = currentLogRecordsSPtr_->Append(logRecord); THROW_ON_FAILURE(status); } co_return true; } BackupLogFileAsyncEnumerator::BackupLogFileAsyncEnumerator( __in KWString const & fileName, __in ULONG32 logRecordCount, __in BlockHandle & blockHandle) noexcept : KObject<BackupLogFileAsyncEnumerator>() , KShared<BackupLogFileAsyncEnumerator>() , fileName_(fileName) , logRecordCount_(logRecordCount) , blockHandeCSPtr_(&blockHandle) , invalidLogRecords_(InvalidLogRecords::Create(GetThisAllocator())) { if (NT_SUCCESS(invalidLogRecords_->Status()) == false) { SetConstructorStatus(invalidLogRecords_->Status()); return; } currentLogRecordsSPtr_ = _new(GetThisAllocationTag(), GetThisAllocator())KSharedArray<LogRecord::SPtr>; if (currentLogRecordsSPtr_ == nullptr) { SetConstructorStatus(STATUS_INSUFFICIENT_RESOURCES); return; } SetConstructorStatus(currentLogRecordsSPtr_->Status()); } BackupLogFileAsyncEnumerator::~BackupLogFileAsyncEnumerator() { ASSERT_IFNOT(isDisposed_ == true, "BackupLogFileAsyncEnumerator must be disposed,"); }
ca0cf30c9991ac26488e4c15b1bbec172748bdf8
3e7934b8d594bbca1370a14f353ab9a285c82719
/Controller/DemoPlayerController.cpp
a98ef8fd7d5241672847a40546c9a85b84d62abe
[]
no_license
jotaro124/Unreal-Portfolio
781da8b99ab596c5ccc3a38abd124eec8ec31971
875a9f43d9d91826eed863d2202cb51e176115e4
refs/heads/main
2023-03-04T21:02:39.628384
2021-02-20T07:57:21
2021-02-20T07:57:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,778
cpp
DemoPlayerController.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "DemoPlayerController.h" #include "../UI/MainUserWidget.h" #include "../State/DemoGameStateBase.h" #include "../State/DemoPlayerState.h" #include "../Character/Player/PlayerCharacter.h" #include "Perception/AIPerceptionStimuliSourceComponent.h" ADemoPlayerController::ADemoPlayerController() { static ConstructorHelpers::FClassFinder<UMainUserWidget> MAIN_USER_WG( TEXT("/Game/Demo/UI/MainWidget")); if (MAIN_USER_WG.Succeeded()) { MainUserWidgetClass = MAIN_USER_WG.Class; } TeamId = FGenericTeamId(10); } void ADemoPlayerController::PostInitializeComponents() { Super::PostInitializeComponents(); } void ADemoPlayerController::OnPossess(APawn* aPawn) { Super::OnPossess(aPawn); } void ADemoPlayerController::MainUserWidgetBindTeamPlayerState(ADemoPlayerState* State) { if (!MainUserWidget) { InitializeMainWidget(); } MainUserWidget->AddBindingTeamPlayerState(State); } void ADemoPlayerController::InitializeMainWidget() { MainUserWidget = CreateWidget<UMainUserWidget>(this, MainUserWidgetClass); MainUserWidget->AddToViewport(); ADemoGameStateBase* DemoGameState = GetWorld()->GetGameState<ADemoGameStateBase>(); MainUserWidget->BindGameState(DemoGameState); ADemoPlayerState* DemoPlayerState = GetPlayerState<ADemoPlayerState>(); MainUserWidget->BindPlayerState(DemoPlayerState); APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(GetCharacter()); if (PlayerCharacter) { MainUserWidget->BindCharacterState(PlayerCharacter); } } void ADemoPlayerController::BeginPlay() { Super::BeginPlay(); if (!MainUserWidget) { InitializeMainWidget(); } } FGenericTeamId ADemoPlayerController::GetGenericTeamId() const { return TeamId; }
a7b867b7783cd7dea89d23d17bbe51f7b3e84260
a5f3b0001cdb692aeffc444a16f79a0c4422b9d0
/main/svl/source/svdde/ddeimp.hxx
92d576efc9066ce872f082272301991a70d56ba2
[ "Apache-2.0", "CPL-1.0", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "Zlib", "LZMA-exception", "LGPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-philippe-de-muyter", "OFL-1.1", "LGPL-2.1-only", "MPL-1.1", "X11", "LGPL-2.1-or-later", "GPL-2.0-only", "OpenSSL", "LicenseRef-scancode-cpl-0.5", "GPL-1.0-or-later", "NPL-1.1", "MIT", "MPL-2.0", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference", "MPL-1.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "BSL-1.0", "LicenseRef-scancode-docbook", "LicenseRef-scancode-mit-old-style", "Python-2.0", "BSD-3-Clause", "IJG", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-or-later", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown", "BSD-2-Clause", "Autoconf-exception-generic", "PSF-2.0", "NTP", "LicenseRef-scancode-python-cwi", "Afmparse", "W3C", "W3C-19980720", "curl", "LicenseRef-scancode-x11-xconsortium-veillard", "Bitstream-Vera", "HPND-sell-variant", "ICU" ]
permissive
apache/openoffice
b9518e36d784898c6c2ea3ebd44458a5e47825bb
681286523c50f34f13f05f7b87ce0c70e28295de
refs/heads/trunk
2023-08-30T15:25:48.357535
2023-08-28T19:50:26
2023-08-28T19:50:26
14,357,669
907
379
Apache-2.0
2023-08-16T20:49:37
2013-11-13T08:00:13
C++
UTF-8
C++
false
false
3,997
hxx
ddeimp.hxx
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 _DDEIMP_HXX #define _DDEIMP_HXX #ifdef OS2 #include "ddemlos2.h" #define WORD sal_uInt16 #define DWORD sal_uLong #define LPBYTE sal_uInt8* #define LPWORD sal_uInt16* #define LPDWORD sal_uLong* #define LPCTSTR PCSZ #else #include <tools/prewin.h> #include <ddeml.h> #include <tools/postwin.h> #include "ddewrap.hxx" /* extern "C" { #define sal_Bool WIN_BOOL #define sal_uInt8 WIN_BYTE #undef sal_Bool #undef sal_uInt8 }; */ #endif #include <tools/string.hxx> #include <tools/list.hxx> #include <tools/shl.hxx> class DdeService; class DdeTopic; class DdeItem; class DdeTopics; class DdeItems; // ---------------- // - Conversation - // ---------------- struct Conversation { HCONV hConv; DdeTopic* pTopic; }; DECLARE_LIST( ConvList, Conversation* ); // --------------- // - DdeInternal - // --------------- class DdeInternal { public: #ifdef WNT static HDDEDATA CALLBACK CliCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK SvrCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK InfCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); #else #if defined ( MTW ) || ( defined ( GCC ) && defined ( OS2 )) || defined( ICC ) static HDDEDATA CALLBACK __EXPORT CliCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK __EXPORT SvrCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK __EXPORT InfCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); #else static HDDEDATA CALLBACK _export CliCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK _export SvrCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); static HDDEDATA CALLBACK _export InfCallback ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); #endif #endif static DdeService* FindService( HSZ ); static DdeTopic* FindTopic( DdeService&, HSZ ); static DdeItem* FindItem( DdeTopic&, HSZ ); }; // ------------- // - DdeString - // ------------- class DdeString : public String { protected: HSZ hString; DWORD hInst; public: DdeString( DWORD, const sal_Unicode* ); DdeString( DWORD, const String& ); ~DdeString(); int operator==( HSZ ); operator HSZ(); }; // -------------- // - DdeDataImp - // -------------- struct DdeDataImp { HDDEDATA hData; LPBYTE pData; long nData; sal_uLong nFmt; }; class DdeConnections; class DdeServices; struct DdeInstData { sal_uInt16 nRefCount; DdeConnections* pConnections; // Server HCONV hCurConvSvr; DWORD hDdeInstSvr; short nInstanceSvr; DdeServices* pServicesSvr; // Client DWORD hDdeInstCli; short nInstanceCli; }; #ifndef SHL_SVDDE #define SHL_SVDDE SHL_SHL2 #endif inline DdeInstData* ImpGetInstData() { return (DdeInstData*)(*GetAppData( SHL_SVDDE )); } DdeInstData* ImpInitInstData(); void ImpDeinitInstData(); #endif // _DDEIMP_HXX
0c9ae8a4045e38ad954c27c6c719efc63c0d33b6
dd80a584130ef1a0333429ba76c1cee0eb40df73
/frameworks/rs/cpu_ref/linkloader/include/impl/ELFSectionProgBits.hxx
434e5b540bb0b9400472f0a9a4841aa574d0a6e8
[ "MIT" ]
permissive
karunmatharu/Android-4.4-Pay-by-Data
466f4e169ede13c5835424c78e8c30ce58f885c1
fcb778e92d4aad525ef7a995660580f948d40bc9
refs/heads/master
2021-03-24T13:33:01.721868
2017-02-18T17:48:49
2017-02-18T17:48:49
81,847,777
0
2
MIT
2020-03-09T00:02:12
2017-02-13T16:47:00
null
UTF-8
C++
false
false
2,538
hxx
ELFSectionProgBits.hxx
/* * Copyright 2011, The Android Open Source 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. */ #ifndef ELF_SECTION_PROGBITS_HXX #define ELF_SECTION_PROGBITS_HXX #include "ELFTypes.h" #include "StubLayout.h" #include <llvm/Support/Format.h> #include <llvm/Support/raw_ostream.h> #include "utils/raw_ostream.h" #include <string.h> template <unsigned Bitwidth> template <typename Archiver> ELFSectionProgBits<Bitwidth> * ELFSectionProgBits<Bitwidth>::read(Archiver &AR, ELFObjectTy *owner, ELFSectionHeaderTy const *sh) { int machine = owner->getHeader()->getMachine(); ELFSectionProgBits *secp = new ELFSectionProgBits(machine); llvm::OwningPtr<ELFSectionProgBits> result(secp); size_t max_num_stubs = 0; // Align section boundary to 4 bytes. size_t section_size = (sh->getSize() + 3) / 4 * 4; size_t alloc_size = section_size; StubLayout *stubs = result->getStubLayout(); if (stubs) { // Compute the maximal possible numbers of stubs std::string reltab_name(".rel" + std::string(sh->getName())); ELFSectionRelTableTy const *reltab = static_cast<ELFSectionRelTableTy *>( owner->getSectionByName(reltab_name.c_str())); if (reltab) { // If we have relocation table, then get the approximation of // maximum numbers of stubs. max_num_stubs = reltab->getMaxNumStubs(owner); } // Compute the stub table size size_t stub_table_size = stubs->calcStubTableSize(max_num_stubs); // Allocate PROGBITS section with stubs table alloc_size += stub_table_size; } // Allocate text section if (!result->chunk.allocate(alloc_size)) { return NULL; } if (stubs) { stubs->initStubTable(result->chunk.getBuffer() + section_size, max_num_stubs); } result->sh = sh; if (!result->serialize(AR)) { // Unable to read the progbits section. return NULL; } return result.take(); } #endif // ELF_SECTION_PROGBITS_HXX
929e44a84849463731ffbfc3efc97104d4408e96
029ddd7dd2235d729a95e508344392a5aa607a4a
/POSGSOFT/Asistente.h
0380047757a56ded32e4e5cab45e07c4efb6e4ca
[]
no_license
EdinsonPedroza/POO2021-1ESPB
6e1c2218da56c4b75eb1eb0363dce697d86b765d
45353d1d009b99e667f8b39e3e414da776e13eeb
refs/heads/master
2023-03-19T12:04:27.248053
2021-03-23T06:47:57
2021-03-23T06:47:57
339,280,672
0
0
null
null
null
null
UTF-8
C++
false
false
1,159
h
Asistente.h
#ifndef POSGSOFT_ASISTENTE_H #define POSGSOFT_ASISTENTE_H #include "Persona.h" #include <vector> #include <string> #include "Acta.h" using namespace std; class Asistente: public Persona{ private: vector<int>numeroActa; vector<string>estudiante; vector<string>nombreTrabajo; vector<string>jurado; vector<string>director; vector<int>idEstudiante; vector<string>idJurado; vector<int>idDirector; vector<string>criterios; vector<double>notas; vector<string>comentarios; vector<string>comentariosAdicionales; vector<double>promedio; vector<int>aprobacion; vector<string> fecha; vector<string>tipoTrabajo; public: Asistente(); void crearNuevaActa(); void mostrarActa(); void recibirDatos(string, string, vector<string>, int, int, int, vector<string>, int, vector<string>, vector<double>, vector<double>, vector<string>, vector<string>, string, string, double, string, string, string); }; #endif //POSGSOFT_ASISTENTE_H
e41a45bfdd940ae526743133a7015d5f8f4c2f24
e3330b6c36a721ae951d1971057656ec06853100
/main.cpp
ed641f6b309511b34061893a6a3f976715e71e43
[]
no_license
rayouyang/130a
2bdf29ff20ec55f6be6706f76a8a0e1164a5104c
d8f58ebd713ffb1a665deabd981c9e120f5887f8
refs/heads/master
2020-12-24T15:31:22.447211
2015-12-15T21:26:58
2015-12-15T21:26:58
39,754,452
0
0
null
null
null
null
UTF-8
C++
false
false
5,076
cpp
main.cpp
// // main.cpp // 130aProject // // Created by Ray Ouyang on 7/5/15. // Copyright (c) 2015 Ray Ouyang. All rights reserved. // #include <iostream> #include <string.h> #include <stdlib.h> #include <stdio.h> #include "Trie.h" #include "Node.h" using namespace std; int main(void) { string oper,s,t; int x; // ... Trie Mango; cin >> Mango.useSLL >> Mango.useWBLT; while(1 == 1) { cin >> oper; if (oper == "Quit") {// delete everything then end program break; } else if (oper == "Insert") { cin >> s >> x; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.Insert(cstr, x); } else if (oper == "Delete") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.Delete(cstr); } else if (oper == "DeleteGT") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.DeleteGT(cstr); } else if (oper == "DeleteAll") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.DeleteAll(cstr); } else if (oper == "DeleteElem") { cin >> s >> x; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.DeleteElem(cstr, x); } else if (oper == "DeleteGEElem") { cin >> s >> x; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.DeleteGEElem(cstr, x); } else if (oper == "DeleteMin") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.DeleteMin(cstr); } else if (oper == "PrintMax") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); int m = Mango.PrintMax(cstr); if(m != -1) cout << m << endl; } else if (oper == "PrintMin") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); int m = Mango.PrintMin(cstr); if(m != -1) cout << m << endl; } else if(oper == "Create"){ cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); Mango.Create(cstr); } else if (oper == "Check") {cin >> s; int count(0); int count1(0); char cstr[s.size()+1]; strcpy(cstr, s.c_str()); MultiSet* k = Mango.GetMultiSet(cstr); if(k){ bool j = k->Check(&count); if(j){ cout << "True "<< count; }else{ cout << "False "<< count; } if(k->WhoAmI() == 3){ count1 = 1; }else{ count1 = 2; } cout << " " << count1 << endl; } } else if (oper == "CountN") { int count = 0; Mango.CountN(&count, Mango.GetRoot()); cout << count << endl; } else if (oper == "CountNT") { int count = 0; Mango.CountNT(&count, Mango.GetRoot()); cout << count << endl; } else if (oper == "CountNT") { int count = 0; Mango.CountNT(&count, Mango.GetRoot()); cout << count << endl; } else if (oper == "PrintNumGT") { cin >> s; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); int count = 0; Mango.PrintNumGT(cstr, &count); cout << count << endl; } else if (oper == "CheckTrie") { int count = 0; Mango.CheckTrie(&count); if(count != 0){ cout << "True " << count << endl; }else{ cout << "False " << count << endl; } } else if (oper == "Merge") { cin >> s >> t; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); char cstr1[t.size()+1]; strcpy(cstr1, t.c_str()); Mango.Merge(cstr,cstr1); } else if (oper == "PrintNum") { cin >> s; int count; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); count = Mango.PrintNum(cstr); if(count != -1){ cout << count << endl; } } else if (oper == "PrintCount") { cin >> s >> x; int count; char cstr[s.size()+1]; strcpy(cstr, s.c_str()); count = Mango.PrintCount(cstr, x); if(count != -1){ cout << count << endl; } } // .. } }
2ec86ee22d3330b5ea6baa8398cb7456bbf5f9a7
d41973fab9da00ad56f557f5caac0da259c225ba
/Assignment_07/Assign_07_02 - Reverse/Assign_07_02 - Reverse/Assign_07_02 - Reverse.cpp
c94e2a56941e69b64f298af60d73d88fa56a6439
[]
no_license
taquayle/ITAD123
d4505785db492982032f849ff18e3a4bb01030ff
8d4f5455864a69d0e5b1b01bca7040599748efcb
refs/heads/master
2020-04-06T06:23:29.701233
2017-02-23T09:23:33
2017-02-23T09:23:33
82,909,047
0
0
null
null
null
null
WINDOWS-1258
C++
false
false
1,687
cpp
Assign_07_02 - Reverse.cpp
// Assign_07_02 - Reverse.cpp : Defines the entry point for the console application. /* Reverse Function Write a program that reverses in memory an array of integers given by the user. The program should ask the user to enter the size of the array, dynamically allocate memory for it and populate the array with the data provided by the user. Implement function void reverse ( int* array, int size). The function gets pointer to the array as a parameter and reverses the order of elements using pointers “head” and “tail” to move through the array. Use this function to reverse an array given by the user. Output the original array and the reversed array, after the function worked on it. */ // Tyler Quayle - SIN: 950416426 #include "stdafx.h" #include <iostream> using namespace std; void reverse(int*, int); int main() { int arraySize; int *numArray; cout << "Enter size of array: "; cin >> arraySize; numArray = new int[arraySize]; for(int i = 0; i < arraySize; i++) { cout << "Enter number for array position " << i << ": "; cin >> *(numArray+i); } cout << "\nArray Forwards\n\n"; for(int i = 0; i < arraySize; i++) cout << " " << *(numArray+i); reverse(numArray, arraySize); cout << "\n\nArray Reversed\n\n"; for(int i = 0; i < arraySize; i++) cout << " " << *(numArray+i); cout << endl << endl; delete [] numArray; system("pause"); return 0; } void reverse(int* nArray, int size) { int *tempArray = new int[size]; int tempPos = size; for(int i = 0; i < size; i++) *(tempArray + i) = *(nArray + --tempPos); for(int i = 0; i < size; i++) *(nArray + i) = *(tempArray + i); delete [] tempArray; }
48dd9ff4e06f5beff3263ad8ff34903b110b1dac
ba6720e2613d5d6bfa66a924581ccbbe44575d43
/weapon.cpp
afcf328c7344166f76efa63d7c0e5753a8ead355
[]
no_license
michael0udee/WarGame
4a614107484347b722e4722083de70b71e20ceaa
611ff14f4811cbce3fb9b5b2e3ab277fd5b44938
refs/heads/master
2020-04-19T14:50:03.977961
2019-01-30T15:47:24
2019-01-30T15:47:24
168,255,468
0
0
null
null
null
null
UTF-8
C++
false
false
4,054
cpp
weapon.cpp
#include "weapon.h" #include "scenegui.h" #include <QtCore/QtMath> #include <QTimer> #include <QDebug> WeaponFire::WeaponFire() { timer = new QTimer(); } WeaponFire::~WeaponFire() { qDebug() << "Delete fire!"; } void WeaponFire::setTargetPosition(QPoint targetPos) { this->targetPos = targetPos; } void WeaponFire::setSound(bool soundOn) { if(soundOn) { // play sound QSound::play(soundSrc); } } void WeaponFire::boomFrame() { currentFrame.rx() += pxy; if(currentFrame.x() >= m*pxy && currentFrame.y() >= m*pxy) { boomTimer->stop(); this->setObjectToDelete(); return; } if (currentFrame.x() >= m*pxy ) { currentFrame.rx() = 0; currentFrame.ry() += pxy; } this->update(-pxy/2,-pxy/2,pxy,pxy); } void WeaponFire::setBoom() { objectLive = 0; timer->stop(); boomTimer = new QTimer(); connect(boomTimer,SIGNAL(timeout()),this,SLOT(boomFrame())); boomTimer->start(20); } void WeaponFire::stopTimer() { timer->stop(); } void WeaponFire::move() { int STEP_SIZE = 30; double theta = rotation()-90; // -90 double dy = STEP_SIZE * qSin(qDegreesToRadians(theta)); double dx = STEP_SIZE * qCos(qDegreesToRadians(theta)); // move the weapon fire position = QPoint(position.x() + dx, position.y() + dy); setPosition(position); //qDebug() << "WeaponFire pos: " << position; } void WeaponFire::exec() { timer->start(time_coeff); } //----------PPSzBullet----------------- PPSzBullet::PPSzBullet() { setSprite(":/images/images/bullet.png", 10, 10); soundSrc = ":/music/music/PPSzBullet.wav"; time_coeff = 50; connect(timer,SIGNAL(timeout()),this,SLOT(updateBullet())); } void PPSzBullet::updateBullet() { move(); } //----------GRENADE---------------- Grenade::Grenade() { setSprite(":/images/images/grenade.png", 10, 10); boomImage = QPixmap(":/images/images/grenadeBoom.png"); soundSrc = ":/music/music/grenade.wav"; time_coeff = 70; objectLive = 30; pxy = 128, m = 4; connect(timer,SIGNAL(timeout()),this,SLOT(updateGrenade())); currentFrame = QPoint(0,0); } void Grenade::updateGrenade() { int d = sqrt(pow(x()-targetPos.x(),2)+pow(y()-targetPos.y(),2)); if(y() > scene()->height()/3 && d > 80) move(); else objectLive--; if(this->getLive() <= 0) { setBoom(); setPixmap(QPixmap(pxy,pxy)); } } void Grenade::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { if(this->getLive() <= 0) { painter->drawPixmap(-pxy/2, -pxy/2, boomImage, currentFrame.x(), currentFrame.y(), pxy, pxy); } else painter->drawImage(0, 0, sprite, 0, 0, sprite.width(), sprite.height()); Q_UNUSED(option); Q_UNUSED(widget); } QRectF Grenade::boundingRect() const { return QRectF(-pxy/2, -pxy/2, pxy, pxy); } //--------MOLOTOV-COCKTAIL-------- MolotovCocktail::MolotovCocktail() { setSprite(":/images/images/molotov-cocktail.png", 20, 20); boomImage = QPixmap(":/images/images/mCocktailBoom.png"); soundSrc = ":/music/music/molotovCocktail.wav"; time_coeff = 80; objectLive = 2; pxy = 128, m = 8; connect(timer,SIGNAL(timeout()),this,SLOT(updateMCocktail())); currentFrame = QPoint(0,0); } void MolotovCocktail::updateMCocktail() { int d = sqrt(pow(x()-targetPos.x(),2)+pow(y()-targetPos.y(),2)); if(y() > scene()->height()/2 && d > 60) move(); else objectLive--; if(this->getLive() <= 0) setBoom(); } void MolotovCocktail::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { if(this->getLive() <= 0){ painter->drawPixmap(-pxy/2, -pxy/2, boomImage, currentFrame.x(), currentFrame.y(), pxy, pxy); } else painter->drawImage(0, 0, sprite, 0, 0, sprite.width(), sprite.height()); Q_UNUSED(option); Q_UNUSED(widget); } QRectF MolotovCocktail::boundingRect() const { return QRectF(-pxy/2, -pxy/2, pxy, pxy); }
b3f09cd7c172368c5e6d5f2101f4f19f70a12bb6
296ee7f58031d7c22fb92790b2cda5e881b5301a
/1st year/2nd semester/OOP/Final_Exam_Practice/Application/Source/main.cpp
25fe4269c431c12a5bc5eb07985c95dd22419768
[]
no_license
arazi47/university-projects
6cf7adb1fade977580e51d3842162eb033769088
4ebd70c857fac2565b44f6e40904cba209a138a1
refs/heads/master
2023-01-08T10:28:23.846702
2020-05-05T08:54:37
2020-05-05T08:54:37
105,974,765
0
2
null
2022-12-27T14:41:06
2017-10-06T06:43:06
HTML
UTF-8
C++
false
false
448
cpp
main.cpp
#include "MainWindow.h" #include <QApplication> #include "QuizSession.h" #include "presenterwnd.h" #include "participantwnd.h" #include "Repository.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); //MainWindow w; //w.show(); QuizSession qs; Repository repo(qs); PresenterWnd pwnd(qs); pwnd.show(); for (const auto &plr : repo.getPlayers()) { plr->show(); } return a.exec(); }