hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
021fb6c7214211444391a14816e0e053e3d5bed9
273
cpp
C++
458.cpp
shaonsani/UVA_Solving
ee916a2938ea81b3676baf4c8150b1b42c9ab5a5
[ "MIT" ]
null
null
null
458.cpp
shaonsani/UVA_Solving
ee916a2938ea81b3676baf4c8150b1b42c9ab5a5
[ "MIT" ]
null
null
null
458.cpp
shaonsani/UVA_Solving
ee916a2938ea81b3676baf4c8150b1b42c9ab5a5
[ "MIT" ]
null
null
null
#include<string.h> #include<stdio.h> int main() { char shane[1000]; while(gets(shane)) { int ln=strlen(shane); for(int i=0; i<ln; i++) { printf("%c",shane[i]-7); } printf("\n"); } return 0; }
10.5
36
0.428571
shaonsani
022199c499118b21ed6130a0c0b9cd3df0713900
2,182
hh
C++
src/maze/MazeVertex2D.hh
huzjkevin/portal_maze_zgl
efb32b1c3430f20638c1401095999ecb4d0af5aa
[ "MIT" ]
null
null
null
src/maze/MazeVertex2D.hh
huzjkevin/portal_maze_zgl
efb32b1c3430f20638c1401095999ecb4d0af5aa
[ "MIT" ]
null
null
null
src/maze/MazeVertex2D.hh
huzjkevin/portal_maze_zgl
efb32b1c3430f20638c1401095999ecb4d0af5aa
[ "MIT" ]
null
null
null
#pragma once #include "../forward.hh" class MazeVertex2D { private: glm::vec2 location; std::vector<int32_t> faces; std::vector<int32_t> incoming; std::vector<int32_t> outgoing; public: MazeVertex2D(glm::vec2 loc) : location(loc), faces(), incoming(), outgoing() {} MazeVertex2D(glm::vec2 loc, size_t n) : location(loc), faces(), incoming(), outgoing() { faces.reserve(n); incoming.reserve(n); outgoing.reserve(n); } virtual ~MazeVertex2D() {} glm::vec2 getLocation() const { return location; } void setLocation(glm::vec2 loc) { location = loc; } size_t getFaceCount() const { return faces.size(); } int32_t getFace(size_t index) const { return faces[index]; } void addFace(int32_t face) { faces.push_back(face); } void insertFace(size_t index, int32_t face) { faces.insert(faces.begin() + index, face); } void removeFace(size_t index) { faces.erase(faces.begin() + index); } void clearFaces() { faces.clear(); } size_t getIncomingCount() const { return incoming.size(); } int32_t getIncomingEdge(size_t index) const { return incoming[index]; } void addIncomingEdge(int32_t edge) { incoming.push_back(edge); } void insertIncomingEdge(size_t index, int32_t edge) { incoming.insert(incoming.begin() + index, edge); } void removeIncomingEdge(size_t index) { incoming.erase(incoming.begin() + index); } void clearIncoming() { incoming.clear(); } size_t getOutgoingCount() const { return outgoing.size(); } int32_t getOutgoingEdge(size_t index) const { return outgoing[index]; } void addOutgoingEdge(int32_t edge) { outgoing.push_back(edge); } void insertOutgoingEdge(size_t index, int32_t edge) { outgoing.insert(outgoing.begin() + index, edge); } void removeOutgoingEdge(size_t index) { outgoing.erase(outgoing.begin() + index); } void clearOutgoing() { outgoing.clear(); } void shrink_to_fit() { faces.shrink_to_fit(); incoming.shrink_to_fit(); outgoing.shrink_to_fit(); } bool isValid() const { return ((faces.size() == incoming.size()) && (incoming.size() == outgoing.size())); } };
33.060606
112
0.666361
huzjkevin
0227a436bda3c1cf6e430927e538ffa32e1606df
15,323
cpp
C++
src/game/client/rtl_support.cpp
MJavad/teeworlds
f3f48e294cdda1b0830ae4af2e3493a2404719ae
[ "Zlib" ]
1
2016-02-07T00:09:31.000Z
2016-02-07T00:09:31.000Z
src/game/client/rtl_support.cpp
MJavad/teeworlds
f3f48e294cdda1b0830ae4af2e3493a2404719ae
[ "Zlib" ]
null
null
null
src/game/client/rtl_support.cpp
MJavad/teeworlds
f3f48e294cdda1b0830ae4af2e3493a2404719ae
[ "Zlib" ]
null
null
null
// (c) MJavad // Fix for rtl languages (for now supports Persian and Arabic with LTR base) #include <base/system.h> #include "rtl_support.h" void CRTLFix::FixString(char *pDst, const char *pSrc, int DstSize, bool FullRTL, int *pCursor, int *pFixedLen) { int Cursor = -1; int Size = 0; int Char; char Buf[4]; CChar Str[MAX_RTL_FIX_SRT_LEN]; // Fill the buffer with pSrc and set the Cursor const char *pTmpSrc = pSrc; while((Char = str_utf8_decode(&pTmpSrc)) && Size < MAX_RTL_FIX_SRT_LEN-1) // max size is MAX_RTL_FIX_SRT_LEN-1 if(Char != -1) { if(Cursor == -1 && pCursor && *pCursor < pTmpSrc-pSrc) Cursor = Size; Str[Size].Type = GetLinkType(Char); Str[Size++].Char = Char; } if(Cursor == -1 && pCursor && *pCursor < pTmpSrc-pSrc) Cursor = Size; // Unusual things if(Size == 0 || DstSize < 2) { if(DstSize > 0) *pDst = 0; return; } if(Size == 1) { int s = str_utf8_encode(Buf, Str[0].Char); if(FullRTL) if(Cursor == 0) *pCursor = s; else *pCursor = 0; else if(Cursor == 0) *pCursor = 0; else *pCursor = s; if(s > DstSize) s = DstSize-1; mem_copy(pDst, Buf, s); pDst[s] = 0; return; } // Process the buffer // Step 1: Skip NO_BREAK chars and set PrevType and NextType Str[0].PrevType = LTR; Str[Size].Type = LTR; int *TypeToFill = 0; int *TypeToFill2 = 0; int *CharToFill = 0; int PrevType; for(int i = 0; i < Size; i++) { int t = Str[i].Type; int c = Str[i].Char; if(c == ARABIC_TATWEEL) { Str[i+1].PrevType = DUAL; Str[i].Type = NONE; } if(t == NO_BREAK) continue; if(CharToFill && Cursor != i) { for(int j = 0; j < ARABIC_ALEF_CHARS_N; j++) if(c == ARABIC_ALEF_CHARS[j]) { *CharToFill = ARABIC_LAMALEF_CHARS[j]; *TypeToFill2 = BEFORE; PrevType = BEFORE; Str[i].Char = 0; break; } CharToFill = 0; } if(!Str[i].Char) continue; if(TypeToFill) { *TypeToFill = t; TypeToFill = 0; Str[i].PrevType = PrevType; } int nt = Str[i+1].Type; if(nt == NO_BREAK || c == ARABIC_LAM) { if(c == ARABIC_LAM) { CharToFill = &Str[i].Char; TypeToFill2 = &Str[i].Type; } TypeToFill = &Str[i].NextType; PrevType = t; } else { Str[i].NextType = nt; Str[i+1].PrevType = t; // i+1 exists because max size is MAX_RTL_FIX_SRT_LEN-1 } } if(TypeToFill) *TypeToFill = 0; // Step 2: Link chars (the HARD part!) and set the Cursor (ALL PARTS have copyright and too much time spent on them) int c; int t; int pt; int nt; int s; int RIndex = 0; int NIndex = 0; int LIndex = 0; int RCursor = -1; int NCursor = -1; int LCursor = -1; const int MaxSize = MAX_RTL_FIX_SRT_LEN*8; // Make sure we never reach the end (4 = max utf8 int char size, 2 = for 2 sides buffers) char RBuf[MaxSize]; // RTL buffer char NBuf[MaxSize]; // NO_DIR buffer (2 sides) char LBuf[MaxSize]; // LTR buffer char *pDstMax = pDst+DstSize-1; char *pOldDst = pDst; for(int i = 0; i < Size; i++) { t = Str[i].Type; c = Str[i].Char; if(!c) continue; if(FullRTL) // i need a rest :) { switch(t) { case LTR: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { LCursor = LIndex+NCursor; NCursor = 0; } mem_copy(LBuf+LIndex, NBuf, NIndex); LIndex += NIndex; NIndex = 0; } if(Cursor == i) LCursor = LIndex; mem_copy(LBuf+LIndex, Buf, s); LIndex += s; break; case NUMBER: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { LCursor = LIndex+NCursor; NCursor = 0; } mem_copy(LBuf+LIndex, NBuf, NIndex); LIndex += NIndex; NIndex = 0; } if(Cursor == i) LCursor = LIndex; mem_copy(LBuf+LIndex, Buf, s); LIndex += s; break; case NO_DIR: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case NONE: c = GetLinked(c); s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case BEFORE: c = GetLinked(c); if(Str[i].PrevType == DUAL) c += FINAL; s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case DUAL: c = GetLinked(c); pt = Str[i].PrevType; nt = Str[i].NextType; if(pt == DUAL) if(nt == BEFORE || nt == DUAL) c += MEDIAL; else c += FINAL; else if(nt == BEFORE || nt == DUAL) c += INITIAL; s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case NO_BREAK: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; } } else { switch(t) { case LTR: if(RIndex) { if(RCursor != -1) { *pCursor = pDst-pOldDst+RIndex-RCursor; RCursor = -1; Cursor = -1; } mem_copy(pDst, RBuf+MaxSize-RIndex, RIndex); pDst += RIndex; RIndex = 0; } if(NIndex) { if(NCursor != -1) { *pCursor = pDst-pOldDst+NCursor; NCursor = -1; Cursor = -1; } mem_copy(pDst, NBuf, NIndex); pDst += NIndex; NIndex = 0; } if(LIndex) { if(LCursor != -1) { *pCursor = pDst-pOldDst+NCursor; LCursor = -1; Cursor = -1; } mem_copy(pDst, LBuf, LIndex); pDst += LIndex; LIndex = 0; } s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst) break; if(Cursor == i) { *pCursor = pDst-pOldDst; Cursor = -1; } mem_copy(pDst, Buf, s); pDst += s; break; case NUMBER: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(RIndex) { if(Cursor == i) LCursor = LIndex; mem_copy(LBuf+LIndex, Buf, s); LIndex += s; } else { if(Cursor == i) { *pCursor = pDst-pOldDst; Cursor = -1; } mem_copy(pDst, Buf, s); pDst += s; } break; case NO_DIR: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(RIndex) { if(LIndex) { if(LCursor != -1) { NCursor = NIndex+LCursor; LCursor = 0; } mem_copy(NBuf+NIndex, LBuf, LIndex); mem_copy(NBuf+MaxSize-NIndex-LIndex, LBuf, LIndex); NIndex += LIndex; LIndex = 0; } if(Cursor == i) NCursor = NIndex; mem_copy(NBuf+NIndex, Buf, s); mem_copy(NBuf+MaxSize-NIndex-s, Buf, s); NIndex += s; } else { if(Cursor == i) { *pCursor = pDst-pOldDst; Cursor = -1; } mem_copy(pDst, Buf, s); pDst += s; } break; case NONE: c = GetLinked(c); s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case BEFORE: c = GetLinked(c); if(Str[i].PrevType == DUAL) c += FINAL; s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case DUAL: c = GetLinked(c); pt = Str[i].PrevType; nt = Str[i].NextType; if(pt == DUAL) if(nt == BEFORE || nt == DUAL) c += MEDIAL; else c += FINAL; else if(nt == BEFORE || nt == DUAL) c += INITIAL; s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; case NO_BREAK: s = str_utf8_encode(Buf, c); if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; if(NIndex) { if(NCursor != -1) { RCursor = RIndex+NCursor; NCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-NIndex, NBuf+MaxSize-NIndex, NIndex); RIndex += NIndex; NIndex = 0; } if(LIndex) { if(LCursor != -1) { RCursor = RIndex+LIndex-LCursor; LCursor = 0; } mem_copy(RBuf+MaxSize-RIndex-LIndex, LBuf, LIndex); RIndex += LIndex; LIndex = 0; } if(Cursor == i) RCursor = RIndex; mem_copy(RBuf+MaxSize-RIndex-s, Buf, s); RIndex += s; break; } } if(s > pDstMax-pDst-RIndex-NIndex-LIndex) break; } if(FullRTL) { if(NIndex) { if(NCursor != -1) { *pCursor = pDst-pOldDst+NIndex-NCursor; Cursor = -1; } mem_copy(pDst, NBuf+MaxSize-NIndex, NIndex); pDst += NIndex; } if(LIndex) { if(LCursor != -1) { *pCursor = pDst-pOldDst+LCursor; Cursor = -1; } mem_copy(pDst, LBuf, LIndex); pDst += LIndex; } if(RIndex) { if(RCursor != -1) { *pCursor = pDst-pOldDst+RIndex-RCursor; Cursor = -1; } mem_copy(pDst, RBuf+MaxSize-RIndex, RIndex); pDst += RIndex; } if(Cursor != -1) *pCursor = 0; } else { if(RIndex) { if(RCursor != -1) { *pCursor = pDst-pOldDst+RIndex-RCursor; Cursor = -1; } mem_copy(pDst, RBuf+MaxSize-RIndex, RIndex); pDst += RIndex; } if(NIndex) { if(NCursor != -1) { *pCursor = pDst-pOldDst+NCursor; Cursor = -1; } mem_copy(pDst, NBuf, NIndex); pDst += NIndex; } if(LIndex) { if(LCursor != -1) { *pCursor = pDst-pOldDst+LCursor; Cursor = -1; } mem_copy(pDst, LBuf, LIndex); pDst += LIndex; } if(Cursor != -1) *pCursor = pDst-pOldDst; } *pDst = 0; // null-terminate the string *pFixedLen = pDst-pOldDst+1; } int CRTLFix::GetLinkType(int Char) { for(int i = 0; i < RTL_RANGE_N*2; i+=2) if(Char >= RTL_RANGE[i] && Char <= RTL_RANGE[i+1]) { // Sorted by usage (better performence) if(Char >= ARABIC_CHARS_RANGE[0] && Char <= ARABIC_CHARS_RANGE[1]) return ARABIC_CHARS_TYPE[Char-ARABIC_CHARS_RANGE[0]]; for(int i = 0; i < PERSIAN_CHARS_N; i++) if(Char == PERSIAN_CHARS[i]) return PERSIAN_CHARS_TYPE[i]; for(int i = 0; i < RTL_CHARS_N; i++) if(Char == RTL_CHARS[i]) return NONE; for(int i = 0; i < RTL_CHARS_RANGE_N*2; i+=2) if(Char >= RTL_CHARS_RANGE[i] && Char <= RTL_CHARS_RANGE[i+1]) return NONE; } for(int i = 0; i < NUMBERS_RANGE_N*2; i+=2) if(Char >= NUMBERS_RANGE[i] && Char <= NUMBERS_RANGE[i+1]) return NUMBER; for(int i = 0; i < NO_DIR_CHARS_RANGE_N*2; i+=2) if(Char >= NO_DIR_CHARS_RANGE[i] && Char <= NO_DIR_CHARS_RANGE[i+1]) return NO_DIR; for(int i = 0; i < NO_DIR_CHARS_N; i++) if(Char == NO_DIR_CHARS[i]) return NO_DIR; for(int i = 0; i < NO_BREAK_CHARS_RANGE_N*2; i+=2) if(Char >= NO_BREAK_CHARS_RANGE[i] && Char <= NO_BREAK_CHARS_RANGE[i+1]) return NO_BREAK; for(int i = 0; i < NO_BREAK_CHARS_N; i++) if(Char == NO_BREAK_CHARS[i]) return NO_BREAK; return LTR; } int CRTLFix::GetLinked(int Char) { if(Char >= ARABIC_CHARS_RANGE[0] && Char <= ARABIC_CHARS_RANGE[1]) return ARABIC_CHARS_LINK[Char-ARABIC_CHARS_RANGE[0]]; for(int i = 0; i < PERSIAN_CHARS_N; i++) if(Char == PERSIAN_CHARS[i]) return PERSIAN_CHARS_LINK[i]; // Retrun others as the same (also LAMALEF) return Char; }
19.746134
133
0.551132
MJavad
02302a3cca90b859ba1e67ca915527d4c1720e32
2,725
hpp
C++
pf_driver/include/pf_driver/pf/r2000/pfsdp_2000.hpp
eurogroep/ROS_driver
1e14af5bdd5778b405ae4bea2d00083a6306a1e7
[ "Apache-2.0" ]
17
2019-09-24T17:17:08.000Z
2021-01-16T22:11:30.000Z
pf_driver/include/pf_driver/pf/r2000/pfsdp_2000.hpp
eurogroep/ROS_driver
1e14af5bdd5778b405ae4bea2d00083a6306a1e7
[ "Apache-2.0" ]
32
2019-09-27T22:51:59.000Z
2021-02-09T14:06:22.000Z
pf_driver/include/pf_driver/pf/r2000/pfsdp_2000.hpp
eurogroep/ROS_driver
1e14af5bdd5778b405ae4bea2d00083a6306a1e7
[ "Apache-2.0" ]
10
2019-10-14T07:28:25.000Z
2021-01-12T06:42:54.000Z
#pragma once #include "pf_driver/pf/pfsdp_protocol.hpp" class PFSDP_2000 : public PFSDPBase { public: PFSDP_2000(const std::string& host) : PFSDPBase(host) { } virtual std::string get_product() { return get_parameter_str("product"); } virtual ScanParameters get_scan_parameters(int start_angle) { auto resp = get_parameter("angular_fov", "radial_range_min", "radial_range_max", "scan_frequency"); params.angular_fov = to_float(resp["angular_fov"]) * M_PI / 180.0; params.radial_range_max = to_float(resp["radial_range_max"]); params.radial_range_min = to_float(resp["radial_range_min"]); params.angle_min = start_angle / 10000.0f * M_PI / 180.0; params.angle_max = params.angle_min + params.angular_fov; params.scan_freq = to_float(resp["scan_frequency"]); return params; } virtual void handle_reconfig(pf_driver::PFDriverR2000Config& config, uint32_t level) { if (level == 1) { set_parameter({ KV("ip_mode", config.ip_mode) }); } else if (level == 2) { set_parameter({ KV("ip_address", config.ip_address) }); } else if (level == 3) { set_parameter({ KV("subnet_mask", config.subnet_mask) }); } else if (level == 4) { set_parameter({ KV("gateway", config.gateway) }); } else if (level == 5) { set_parameter({ KV("scan_frequency", config.scan_frequency) }); } else if (level == 6) { set_parameter({ KV("scan_direction", config.scan_direction) }); } else if (level == 7) { set_parameter({ KV("samples_per_scan", config.samples_per_scan) }); } else if (level == 8) { set_parameter({ KV("hmi_display_mode", config.hmi_display_mode) }); } else if (level == 9) { set_parameter({ KV("hmi_language", config.hmi_language) }); } else if (level == 10) { set_parameter({ KV("hmi_button_lock", config.hmi_button_lock) }); } else if (level == 11) { set_parameter({ KV("hmi_parameter_lock", config.hmi_parameter_lock) }); } else if (level == 12) { set_parameter({ KV("hmi_static_text_1", config.hmi_static_text_1) }); } else if (level == 13) { set_parameter({ KV("hmi_static_text_2", config.hmi_static_text_2) }); } else if (level == 14) { set_parameter({ KV("locator_indication", config.locator_indication) }); } else if (level == 15) { set_parameter({ KV("operating_mode", config.operating_mode) }); } else if (level == 25) { set_parameter({ KV("user_tag", config.user_tag) }); } else if (level == 26) { set_parameter({ KV("user_notes", config.user_notes) }); } } };
26.980198
103
0.618716
eurogroep
0233c89eaa06fbbe6a42a9ad0f324c86ea5e544f
7,517
cpp
C++
decoder/source/ocsd_lib_dcd_register.cpp
rossburton/OpenCSD
01d44a34f8fc057f4b041c01f8d9502d77fe612f
[ "BSD-3-Clause" ]
84
2015-08-07T09:40:59.000Z
2022-03-14T09:04:33.000Z
decoder/source/ocsd_lib_dcd_register.cpp
rossburton/OpenCSD
01d44a34f8fc057f4b041c01f8d9502d77fe612f
[ "BSD-3-Clause" ]
41
2016-07-28T09:14:06.000Z
2022-03-04T10:47:42.000Z
decoder/source/ocsd_lib_dcd_register.cpp
rossburton/OpenCSD
01d44a34f8fc057f4b041c01f8d9502d77fe612f
[ "BSD-3-Clause" ]
37
2016-06-08T15:40:47.000Z
2022-02-18T09:29:35.000Z
/* * \file ocsd_lib_dcd_register.cpp * \brief OpenCSD : Library decoder register object * * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved. */ /* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "common/ocsd_lib_dcd_register.h" // include built-in decode manager headers #include "opencsd/etmv4/trc_dcd_mngr_etmv4i.h" #include "opencsd/etmv3/trc_dcd_mngr_etmv3.h" #include "opencsd/ptm/trc_dcd_mngr_ptm.h" #include "opencsd/stm/trc_dcd_mngr_stm.h" #include "opencsd/ete/trc_dcd_mngr_ete.h" // create array of built-in decoders to register with library static built_in_decoder_info_t sBuiltInArray[] = { CREATE_BUILTIN_ENTRY(DecoderMngrEtmV4I,OCSD_BUILTIN_DCD_ETMV4I), CREATE_BUILTIN_ENTRY(DecoderMngrEtmV3, OCSD_BUILTIN_DCD_ETMV3), CREATE_BUILTIN_ENTRY(DecoderMngrPtm, OCSD_BUILTIN_DCD_PTM), CREATE_BUILTIN_ENTRY(DecoderMngrStm, OCSD_BUILTIN_DCD_STM), CREATE_BUILTIN_ENTRY(DecoderMngrETE, OCSD_BUILTIN_DCD_ETE) //{ 0, 0, 0} }; #define NUM_BUILTINS sizeof(sBuiltInArray) / sizeof(built_in_decoder_info_t) OcsdLibDcdRegister *OcsdLibDcdRegister::m_p_libMngr = 0; bool OcsdLibDcdRegister::m_b_registeredBuiltins = false; ocsd_trace_protocol_t OcsdLibDcdRegister::m_nextCustomProtocolID = OCSD_PROTOCOL_CUSTOM_0; OcsdLibDcdRegister *OcsdLibDcdRegister::getDecoderRegister() { if(m_p_libMngr == 0) m_p_libMngr = new (std::nothrow) OcsdLibDcdRegister(); return m_p_libMngr; } const ocsd_trace_protocol_t OcsdLibDcdRegister::getNextCustomProtocolID() { ocsd_trace_protocol_t ret = m_nextCustomProtocolID; if(m_nextCustomProtocolID < OCSD_PROTOCOL_END) m_nextCustomProtocolID = (ocsd_trace_protocol_t)(((int)m_nextCustomProtocolID)+1); return ret; } void OcsdLibDcdRegister::releaseLastCustomProtocolID() { if(m_nextCustomProtocolID > OCSD_PROTOCOL_CUSTOM_0) m_nextCustomProtocolID = (ocsd_trace_protocol_t)(((int)m_nextCustomProtocolID)-1); } OcsdLibDcdRegister::OcsdLibDcdRegister() { m_iter = m_decoder_mngrs.begin(); m_pLastTypedDecoderMngr = 0; } OcsdLibDcdRegister::~OcsdLibDcdRegister() { m_decoder_mngrs.clear(); m_typed_decoder_mngrs.clear(); m_pLastTypedDecoderMngr = 0; } const ocsd_err_t OcsdLibDcdRegister::registerDecoderTypeByName(const std::string &name, IDecoderMngr *p_decoder_fact) { if(isRegisteredDecoder(name)) return OCSD_ERR_DCDREG_NAME_REPEAT; m_decoder_mngrs.emplace(std::pair<const std::string, IDecoderMngr *>(name,p_decoder_fact)); m_typed_decoder_mngrs.emplace(std::pair<const ocsd_trace_protocol_t, IDecoderMngr *>(p_decoder_fact->getProtocolType(),p_decoder_fact)); return OCSD_OK; } void OcsdLibDcdRegister::registerBuiltInDecoders() { bool memFail = false; for(unsigned i = 0; i < NUM_BUILTINS; i++) { if(sBuiltInArray[i].PFn) { sBuiltInArray[i].pMngr = sBuiltInArray[i].PFn( sBuiltInArray[i].name); if(!sBuiltInArray[i].pMngr) memFail=true; } } m_b_registeredBuiltins = !memFail; } void OcsdLibDcdRegister::deregisterAllDecoders() { if(m_b_registeredBuiltins) { for(unsigned i = 0; i < NUM_BUILTINS; i++) delete sBuiltInArray[i].pMngr; m_b_registeredBuiltins = false; } if(m_p_libMngr) { m_p_libMngr->deRegisterCustomDecoders(); delete m_p_libMngr; m_p_libMngr = 0; } } void OcsdLibDcdRegister::deRegisterCustomDecoders() { std::map<const ocsd_trace_protocol_t, IDecoderMngr *>::const_iterator iter = m_typed_decoder_mngrs.begin(); while(iter != m_typed_decoder_mngrs.end()) { IDecoderMngr *pMngr = iter->second; if(pMngr->getProtocolType() >= OCSD_PROTOCOL_CUSTOM_0) delete pMngr; iter++; } } const ocsd_err_t OcsdLibDcdRegister::getDecoderMngrByName(const std::string &name, IDecoderMngr **p_decoder_mngr) { if(!m_b_registeredBuiltins) { registerBuiltInDecoders(); if(!m_b_registeredBuiltins) return OCSD_ERR_MEM; } std::map<const std::string, IDecoderMngr *>::const_iterator iter = m_decoder_mngrs.find(name); if(iter == m_decoder_mngrs.end()) return OCSD_ERR_DCDREG_NAME_UNKNOWN; *p_decoder_mngr = iter->second; return OCSD_OK; } const ocsd_err_t OcsdLibDcdRegister::getDecoderMngrByType(const ocsd_trace_protocol_t decoderType, IDecoderMngr **p_decoder_mngr) { if(!m_b_registeredBuiltins) { registerBuiltInDecoders(); if(!m_b_registeredBuiltins) return OCSD_ERR_MEM; } if (m_pLastTypedDecoderMngr && (m_pLastTypedDecoderMngr->getProtocolType() == decoderType)) *p_decoder_mngr = m_pLastTypedDecoderMngr; else { std::map<const ocsd_trace_protocol_t, IDecoderMngr *>::const_iterator iter = m_typed_decoder_mngrs.find(decoderType); if (iter == m_typed_decoder_mngrs.end()) return OCSD_ERR_DCDREG_TYPE_UNKNOWN; *p_decoder_mngr = m_pLastTypedDecoderMngr = iter->second; } return OCSD_OK; } const bool OcsdLibDcdRegister::isRegisteredDecoder(const std::string &name) { std::map<const std::string, IDecoderMngr *>::const_iterator iter = m_decoder_mngrs.find(name); if(iter != m_decoder_mngrs.end()) return true; return false; } const bool OcsdLibDcdRegister::isRegisteredDecoderType(const ocsd_trace_protocol_t decoderType) { std::map<const ocsd_trace_protocol_t, IDecoderMngr *>::const_iterator iter = m_typed_decoder_mngrs.find(decoderType); if(iter != m_typed_decoder_mngrs.end()) return true; return false; } const bool OcsdLibDcdRegister::getFirstNamedDecoder(std::string &name) { m_iter = m_decoder_mngrs.begin(); return getNextNamedDecoder(name); } const bool OcsdLibDcdRegister::getNextNamedDecoder(std::string &name) { if(m_iter == m_decoder_mngrs.end()) return false; name = m_iter->first; m_iter++; return true; } /* End of File ocsd_lib_dcd_register.cpp */
34.640553
140
0.734336
rossburton
0234509f4bebea5c15b364b764c28e97751ec9e2
294
hpp
C++
llarp/util/types.hpp
wratc/loki-network
0d6d0ec7b27f80c2836eb5d4c4f6e7b1974dd178
[ "Zlib" ]
3
2018-11-17T07:38:39.000Z
2021-04-29T23:39:47.000Z
llarp/util/types.hpp
wratc/loki-network
0d6d0ec7b27f80c2836eb5d4c4f6e7b1974dd178
[ "Zlib" ]
1
2020-03-28T08:59:56.000Z
2020-03-28T08:59:56.000Z
llarp/util/types.hpp
wratc/loki-network
0d6d0ec7b27f80c2836eb5d4c4f6e7b1974dd178
[ "Zlib" ]
2
2021-01-28T05:36:14.000Z
2021-01-28T05:47:53.000Z
#ifndef LLARP_TYPES_H #define LLARP_TYPES_H #include <cstdint> #include <string> #include <chrono> using byte_t = uint8_t; using llarp_proto_version_t = std::uint8_t; using llarp_time_t = std::chrono::milliseconds; namespace llarp { using namespace std::literals; } #endif
16.333333
47
0.727891
wratc
0234d71b4a8a80d0a0535f80aa5fff6623c8a64f
758
cpp
C++
3460.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
3460.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
3460.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
#include <vector> #include <iostream> #include <algorithm> #include <string> using namespace std; vector<int> arr; vector<int> store; vector<int> print; // 13 6 3 1 // 1 0 1 void bin(int num) { while (num != 1) { store.push_back(num % 2); num /= 2; } store.push_back(1); } int main() { int t, n; cin >> t; for (int i = 0; i < t; i++) { cin >> n; arr.push_back(n); } for (int i = 0; i < t; i++) { bin(arr[i]); for (int j = 0; j < store.size(); j++) { if (store[j] == 1) print.push_back(j); } sort(print.begin(), print.end()); for (int j = 0; j < print.size(); j++) { cout << print[j] << " "; } cout << endl; store.erase(store.begin(), store.end()); print.erase(print.begin(), print.end()); } return 0; }
17.227273
42
0.538259
jaemin2682
0236631824373a53b19380e800f17bd37505e892
2,193
cpp
C++
GameEngine/src/AssetLoader.cpp
ManFabv/BattleCitySFMLClone
d7deb02b1735b8e969ce84e90a3b48a987adf483
[ "MIT" ]
null
null
null
GameEngine/src/AssetLoader.cpp
ManFabv/BattleCitySFMLClone
d7deb02b1735b8e969ce84e90a3b48a987adf483
[ "MIT" ]
null
null
null
GameEngine/src/AssetLoader.cpp
ManFabv/BattleCitySFMLClone
d7deb02b1735b8e969ce84e90a3b48a987adf483
[ "MIT" ]
null
null
null
#include "GameEngine/AssetLoader.h" #include "GameEngine/FilePathHelper.h" using namespace GameEngine::DataUtils; AssetLoader::AssetLoader(const std::string& root_folder, const std::string& textures_folder, const std::string& fonts_folder, const std::string& sounds_folder) { ChangeLookupPath(root_folder, textures_folder, fonts_folder, sounds_folder); } AssetLoader::~AssetLoader() { m_textures.clear(); m_fonts.clear(); m_sounds.clear(); } void AssetLoader::ChangeLookupPath(const std::string& root_folder, const std::string& textures_folder, const std::string& fonts_folder, const std::string& sounds_folder) { m_root_folder = root_folder; m_textures_folder = textures_folder; m_fonts_folder = fonts_folder; m_sounds_folder = sounds_folder; } const sf::Texture& AssetLoader::GetTexture(const std::string& asset_name) { std::map<std::string, sf::Texture*>::iterator asset_found = m_textures.find(asset_name); if (asset_found != m_textures.end()) { return (*asset_found->second); } else { sf::Texture* asset = new sf::Texture(); asset->loadFromFile(GetLookupPath(m_textures_folder, asset_name)); m_textures[asset_name] = asset; return *asset; } } const sf::Font& AssetLoader::GetFont(const std::string& asset_name) { std::map<std::string, sf::Font*>::iterator asset_found = m_fonts.find(asset_name); if (asset_found != m_fonts.end()) { return (*asset_found->second); } else { sf::Font* asset = new sf::Font(); asset->loadFromFile(GetLookupPath(m_fonts_folder, asset_name)); m_fonts[asset_name] = asset; return *asset; } } const sf::SoundBuffer& AssetLoader::GetSound(const std::string& asset_name) { std::map<std::string, sf::SoundBuffer*>::iterator asset_found = m_sounds.find(asset_name); if (asset_found != m_sounds.end()) { return (*asset_found->second); } else { sf::SoundBuffer* asset = new sf::SoundBuffer(); asset->loadFromFile(GetLookupPath(m_sounds_folder, asset_name)); m_sounds[asset_name] = asset; return *asset; } } const std::string AssetLoader::GetLookupPath(const std::string& asset_folder, const std::string& asset_name) { return FilePathHelper::GeneratePath(m_root_folder, asset_folder, asset_name); }
27.074074
169
0.742362
ManFabv
0236913fb50c3b21ae4e7e11e474350c9658ab1c
1,346
cpp
C++
test/ContainerVectors.cpp
foldedwave/Instil
9e5f29b6e04a739135c0dd62e796f689fff1bc35
[ "MIT" ]
null
null
null
test/ContainerVectors.cpp
foldedwave/Instil
9e5f29b6e04a739135c0dd62e796f689fff1bc35
[ "MIT" ]
null
null
null
test/ContainerVectors.cpp
foldedwave/Instil
9e5f29b6e04a739135c0dd62e796f689fff1bc35
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include <functional> // for __base, function #include "Instil/Container.h" // for Container, Container<>::build #include "Instil/Scope.h" // for Scope, Singleton, Transient #include "TestTypes/Interfaces/ISimple.h" #include "TestTypes/Interfaces/IWrapMultiple.h" #include "TestTypes/Simple.h" #include "TestTypes/SimpleAlternate.h" #include "TestTypes/WrapMultiple.h" #include <utility> #include <memory> using Instil::Container; using Instil::Scope; TEST(Container, VectorContainsCorrectObjects) { auto wrapMulti = Container<IWrapMultiple>::Get(); EXPECT_EQ(wrapMulti->Call(), "WrapMultiple::Call()"); EXPECT_EQ(wrapMulti->CallChildren(), "Simple::Call()/SimpleAlternate::Call()/"); } TEST(Container, VectorObjectReferenceCountsAreCorrect) { auto wrapMulti = Container<IWrapMultiple>::Get(); EXPECT_EQ(wrapMulti.use_count(), 2); EXPECT_EQ(wrapMulti->GetAll()[0].use_count(), 3); EXPECT_EQ(wrapMulti->GetAll()[1].use_count(), 3); } int main(int argc, char **argv) { Container<ISimple>::For<Simple>::Register(Scope::Singleton); Container<ISimple>::For<SimpleAlternate>::Register(Scope::Singleton); Container<IWrapMultiple>::For<WrapMultiple, std::vector<ISimple>>::Register(Scope::Singleton); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
29.911111
98
0.725854
foldedwave
02395814f4f1287f2a4fc449c8143b05dd5d8b54
3,750
cpp
C++
src/Config.cpp
nizikawa-worms/wkTestStuff
832f4f1f721e40f0d63e1d8176eeb95ec00f59dd
[ "WTFPL" ]
2
2022-01-12T22:48:39.000Z
2022-01-13T17:06:30.000Z
src/Config.cpp
nizikawa-worms/wkTestStuff
832f4f1f721e40f0d63e1d8176eeb95ec00f59dd
[ "WTFPL" ]
null
null
null
src/Config.cpp
nizikawa-worms/wkTestStuff
832f4f1f721e40f0d63e1d8176eeb95ec00f59dd
[ "WTFPL" ]
null
null
null
#include <windows.h> #include "Config.h" #include "Utils.h" #include "WaLibc.h" #include "Debugf.h" #include <filesystem> namespace fs = std::filesystem; void Config::readConfig() { char wabuff[MAX_PATH]; GetModuleFileNameA(0, (LPSTR)&wabuff, sizeof(wabuff)); waDir = fs::path(wabuff).parent_path(); auto inipath = (waDir / iniFile).string(); moduleEnabled = GetPrivateProfileIntA("general", "EnableModule", 1, inipath.c_str()); useOffsetCache = GetPrivateProfileIntA("general", "UseOffsetCache", 1, inipath.c_str()); ignoreVersionCheck = GetPrivateProfileIntA("general", "IgnoreVersionCheck", 0, inipath.c_str()); devConsoleEnabled = GetPrivateProfileIntA("debug", "EnableDevConsole", 0, inipath.c_str()); char buff[128]; GetPrivateProfileStringA("WeaponPanel", "Transparency", "off", buff, sizeof(buff), inipath.c_str()); panelTransparency = buff; } bool Config::isDevConsoleEnabled() { return devConsoleEnabled; } bool Config::isModuleEnabled() { return moduleEnabled; } //StepS tools typedef unsigned long long QWORD; #define MAKELONGLONG(lo,hi) ((LONGLONG(DWORD(lo) & 0xffffffff)) | LONGLONG(DWORD(hi) & 0xffffffff) << 32 ) #define QV(V1, V2, V3, V4) MAKEQWORD(V4, V3, V2, V1) #define MAKEQWORD(LO2, HI2, LO1, HI1) MAKELONGLONG(MAKELONG(LO2,HI2),MAKELONG(LO1,HI1)) QWORD GetModuleVersion(HMODULE hModule) { char WApath[MAX_PATH]; DWORD h; GetModuleFileNameA(hModule,WApath,MAX_PATH); DWORD Size = GetFileVersionInfoSizeA(WApath,&h); if(Size) { void* Buf = malloc(Size); GetFileVersionInfoA(WApath,h,Size,Buf); VS_FIXEDFILEINFO *Info; DWORD Is; if(VerQueryValueA(Buf, "\\", (LPVOID*)&Info, (PUINT)&Is)) { if(Info->dwSignature==0xFEEF04BD) { return MAKELONGLONG(Info->dwFileVersionLS, Info->dwFileVersionMS); } } free(Buf); } return 0; } int Config::waVersionCheck() { if(ignoreVersionCheck) return 1; auto version = GetModuleVersion((HMODULE)0); char versionstr[64]; _snprintf_s(versionstr, _TRUNCATE, "Detected game version: %u.%u.%u.%u", PWORD(&version)[3], PWORD(&version)[2], PWORD(&version)[1], PWORD(&version)[0]); debugf("%s\n", versionstr); std::string tversion = getFullStr(); char buff[512]; if (version < QV(3,8,0,0)) { _snprintf_s(buff, _TRUNCATE, "wkTestStuff is not compatible with WA versions older than 3.8.0.0.\n\n%s", versionstr); MessageBoxA(0, buff, tversion.c_str(), MB_OK | MB_ICONERROR); return 0; } if (version >= QV(3,9,0,0)) { _snprintf_s(buff, _TRUNCATE, "wkTestStuff is not compatible with WA versions 3.9.x.x and newer.\n\n%s", versionstr); MessageBoxA(0, buff, tversion.c_str(), MB_OK | MB_ICONERROR); return 0; } if(version == QV(3,8,0,0) || version == QV(3,8,1,0)) { return 1; } _snprintf_s(buff, _TRUNCATE, "wkTestStuff is not designed to work with your WA version and may malfunction.\n\nTo disable this warning set IgnoreVersionCheck=1 in wkTestStuff.ini file.\n\n%s", versionstr); return MessageBoxA(0, buff, tversion.c_str(), MB_OKCANCEL | MB_ICONWARNING) == IDOK; } std::string Config::getModuleStr() { return "wkTestStuff"; } std::string Config::getVersionStr() { return "v0.2.0"; } std::string Config::getBuildStr() { return __DATE__ " " __TIME__; } std::string Config::getFullStr() { return getModuleStr() + " " + getVersionStr() + " (build: " + getBuildStr() + ")"; } const std::filesystem::path &Config::getWaDir() { return waDir; } bool Config::isUseOffsetCache() { return useOffsetCache; } std::string Config::getWaVersionAsString() { char buff[32]; auto version = GetModuleVersion(0); sprintf_s(buff, "%u.%u.%u.%u", PWORD(&version)[3], PWORD(&version)[2], PWORD(&version)[1], PWORD(&version)[0]); return buff; } const std::string &Config::getPanelTransparency() { return panelTransparency; }
30.241935
206
0.7072
nizikawa-worms
023ac061b967191564bae3d57c6d879a0b3b736d
439
cpp
C++
simulation.cpp
rightson/des-barbershop
0b06f1db85383f6dce97780b45f8392d462a48c3
[ "MIT" ]
null
null
null
simulation.cpp
rightson/des-barbershop
0b06f1db85383f6dce97780b45f8392d462a48c3
[ "MIT" ]
null
null
null
simulation.cpp
rightson/des-barbershop
0b06f1db85383f6dce97780b45f8392d462a48c3
[ "MIT" ]
null
null
null
#include "simulation.h" simulation::simulation() : time(0), eventQueue() { } void simulation::scheduleEvent(event* newEvent) { eventQueue.push(newEvent); } void simulation::run() { while (!eventQueue.empty()) { event* nextEvent = eventQueue.top(); eventQueue.pop(); time = nextEvent->time; printf("\nTIME = %u\n", time); nextEvent->processEvent(); delete nextEvent; } }
19.086957
49
0.596811
rightson
023add0afc6996bc57ea318dcd2504a15e7f42b3
4,792
hpp
C++
src/hydro/hydro_diffusion/hydro_diffusion.hpp
michaelp4/myathena
099facbec579f9a94c27053aa4b32d435172217f
[ "BSD-3-Clause" ]
2
2019-03-04T21:11:21.000Z
2019-03-04T21:14:14.000Z
src/hydro/hydro_diffusion/hydro_diffusion.hpp
michaelp4/myathena
099facbec579f9a94c27053aa4b32d435172217f
[ "BSD-3-Clause" ]
null
null
null
src/hydro/hydro_diffusion/hydro_diffusion.hpp
michaelp4/myathena
099facbec579f9a94c27053aa4b32d435172217f
[ "BSD-3-Clause" ]
2
2019-02-26T18:49:13.000Z
2019-07-22T17:04:41.000Z
#ifndef HYDRO_HYDRO_DIFFUSION_HYDRO_DIFFUSION_HPP_ #define HYDRO_HYDRO_DIFFUSION_HYDRO_DIFFUSION_HPP_ //======================================================================================== // Athena++ astrophysical MHD code // Copyright(C) 2014 James M. Stone <jmstone@princeton.edu> and other code contributors // Licensed under the 3-clause BSD License, see LICENSE file for details //======================================================================================== //! \file hydro_diffusion.hpp // \brief defines class HydroDiffusion // Contains data and functions that implement the diffusion processes // Athena headers #include "../../athena.hpp" #include "../../athena_arrays.hpp" // Forward declarations class Hydro; class ParameterInput; class Coordinates; class HydroDiffusion; void ConstViscosity(HydroDiffusion *phdif, MeshBlock *pmb, const AthenaArray<Real> &w, const AthenaArray<Real> &bc, int is, int ie, int js, int je, int ks, int ke); void ConstConduction(HydroDiffusion *phdif, MeshBlock *pmb, const AthenaArray<Real> &w, const AthenaArray<Real> &bc, int is, int ie, int js, int je, int ks, int ke); enum {ISO=0, ANI=1}; //! \class HydroDiffusion // \brief data and functions for physical diffusion processes in the hydro class HydroDiffusion { public: HydroDiffusion(Hydro *phyd, ParameterInput *pin); ~HydroDiffusion(); // data bool hydro_diffusion_defined; Real nu_iso, nu_aniso; // viscosity coeff AthenaArray<Real> visflx[3]; // viscous stress tensor AthenaArray<Real> nu; // viscosity array Real kappa_iso, kappa_aniso; // thermal conduction coeff AthenaArray<Real> cndflx[3]; // thermal stress tensor AthenaArray<Real> kappa; // conduction array // functions void CalcHydroDiffusionFlux(const AthenaArray<Real> &p, const AthenaArray<Real> &c, AthenaArray<Real> *flx); void AddHydroDiffusionFlux(AthenaArray<Real> *flx_src, AthenaArray<Real> *flx_des); void AddHydroDiffusionEnergyFlux(AthenaArray<Real> *flux_src, AthenaArray<Real> *flux_des); void ClearHydroFlux(AthenaArray<Real> *flx); void SetHydroDiffusivity(AthenaArray<Real> &w, AthenaArray<Real> &bc); void NewHydroDiffusionDt(Real &dt_vis, Real &dt_cnd); // viscosity void ViscousFlux_iso(const AthenaArray<Real> &p,const AthenaArray<Real> &c, AthenaArray<Real> *flx); void ViscousFlux_aniso(const AthenaArray<Real> &p,const AthenaArray<Real> &c, AthenaArray<Real> *flx); // thermal conduction void ThermalFlux_iso(const AthenaArray<Real> &p,const AthenaArray<Real> &c, AthenaArray<Real> *flx); void ThermalFlux_aniso(const AthenaArray<Real> &p,const AthenaArray<Real> &c, AthenaArray<Real> *flx); private: MeshBlock *pmb_; // ptr to meshblock containing this HydroDiffusion Hydro *pmy_hydro_; // ptr to Hydro containing this HydroDiffusion Coordinates *pco_; // ptr to coordinates class AthenaArray<Real> divv_; // divergence of velocity AthenaArray<Real> x1area_,x2area_,x2area_p1_,x3area_,x3area_p1_; AthenaArray<Real> vol_; AthenaArray<Real> fx_,fy_,fz_; AthenaArray<Real> dx1_,dx2_,dx3_; AthenaArray<Real> nu_tot_,kappa_tot_; // functions pointer to calculate spatial dependent coefficients ViscosityCoeff_t CalcViscCoeff_; ConductionCoeff_t CalcCondCoeff_; // auxiliary functions to calculate viscous flux void Divv(const AthenaArray<Real> &prim, AthenaArray<Real> &divv); void FaceXdx(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceXdy(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceXdz(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceYdx(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceYdy(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceYdz(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceZdx(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceZdy(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); void FaceZdz(const int k, const int j, const int il, const int iu, const AthenaArray<Real> &prim, AthenaArray<Real> &len); }; #endif // HYDRO_HYDRO_DIFFUSION_HYDRO_DIFFUSION_HPP_
43.963303
90
0.690526
michaelp4
023df82b648a7601543726a434c83efbfbf31b5b
922
cpp
C++
tutorials/embree_tests/common/algorithms/parallel_for.cpp
aumuell/embree
d7157470e089098b9c7323f608835ed50453e606
[ "Apache-2.0" ]
1,700
2015-01-02T15:40:58.000Z
2022-03-30T19:58:13.000Z
tutorials/embree_tests/common/algorithms/parallel_for.cpp
aumuell/embree
d7157470e089098b9c7323f608835ed50453e606
[ "Apache-2.0" ]
338
2015-01-06T08:47:31.000Z
2022-03-21T14:32:34.000Z
tutorials/embree_tests/common/algorithms/parallel_for.cpp
aumuell/embree
d7157470e089098b9c7323f608835ed50453e606
[ "Apache-2.0" ]
346
2015-01-13T09:44:09.000Z
2022-03-31T23:27:37.000Z
// Copyright 2009-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #include "../../../external/catch.hpp" #include "../common/algorithms/parallel_for.h" #include <atomic> using namespace embree; namespace parallel_for_unit_test { TEST_CASE("Test parallel_for", "[parallel_for") { bool passed = true; const size_t M = 10; for (size_t N=10; N<10000000; N=size_t(2.1*N)) { /* sequentially calculate sum of squares */ size_t sum0 = 0; for (size_t i=0; i<N; i++) { sum0 += i*i; } /* parallel calculation of sum of squares */ for (size_t m=0; m<M; m++) { std::atomic<size_t> sum1(0); parallel_for( size_t(0), size_t(N), size_t(1024), [&](const range<size_t>& r) { size_t s = 0; for (size_t i=r.begin(); i<r.end(); i++) s += i*i; sum1 += s; }); passed = sum0 == sum1; } } REQUIRE(passed); } }
20.488889
83
0.574837
aumuell
0243d954e54b6e1c24a634b71b944dc9ae67a9d9
1,248
cpp
C++
Luogu/p4551.cpp
Tunghohin/Competitive_coding
879238605d5525cda9fd0cfa1155ba67959179a6
[ "MIT" ]
2
2021-09-06T08:34:00.000Z
2021-11-22T14:52:41.000Z
Luogu/p4551.cpp
Tunghohin/Competitive_coding
879238605d5525cda9fd0cfa1155ba67959179a6
[ "MIT" ]
null
null
null
Luogu/p4551.cpp
Tunghohin/Competitive_coding
879238605d5525cda9fd0cfa1155ba67959179a6
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; const int N = 1000010; int prefix_xor[N]; int trie_01[6 * N][2], idx = 0; struct edge { int to, val, next; }e[N * 2]; int head[N], tot = 0; void add_edge(int from, int to, int val) { e[++tot].to = to; e[tot].val = val; e[tot].next = head[from]; head[from] = tot; } void dfs(int u, int from) { for (int i = head[u]; i; i = e[i].next) { int j = e[i].to; if (j == from) continue; prefix_xor[j] = prefix_xor[u] ^ e[i].val; dfs(j, u); } } void insert(int x) { int p = 0; for (int i = 30; i >= 0; i--) { int &u = trie_01[p][x >> i & 1]; if (!u) u = ++idx; p = u; } } int query(int x) { int p = 0, res = 0; for (int i = 30; i >= 0; i--) { int s = x >> i & 1; if (trie_01[p][s ^ 1]) { res += 1 << i; p = trie_01[p][s ^ 1]; } else p = trie_01[p][s]; } return res; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int n; cin >> n; for (int i = 1; i < n; i++) { int a, b, v; cin >> a >> b >> v; add_edge(a, b, v), add_edge(b, a, v); } dfs(1, 0); for (int i = 1; i <= n; i++) insert(prefix_xor[i]); int res = 0; for (int i = 1; i <= n; i++) res = max(res, query(prefix_xor[i])); cout << res << '\n'; }
14.181818
67
0.502404
Tunghohin
02485a0b8abf380d139de41c0c5b7a1a21787e89
390
cpp
C++
Teste e exercicios/Salario/main.cpp
Lu1zReis/exercicios-cpp
81fabe4080d75ad88e25f4d3cda9fd5df31cbfa0
[ "MIT" ]
null
null
null
Teste e exercicios/Salario/main.cpp
Lu1zReis/exercicios-cpp
81fabe4080d75ad88e25f4d3cda9fd5df31cbfa0
[ "MIT" ]
null
null
null
Teste e exercicios/Salario/main.cpp
Lu1zReis/exercicios-cpp
81fabe4080d75ad88e25f4d3cda9fd5df31cbfa0
[ "MIT" ]
null
null
null
#include <iostream> #include <iomanip> using namespace std; int main() { cout.precision(2); char vedendor[] = {}; double vendido, comissao, porcentagem, dinheiro; cin >> vedendor; cin >> vendido; cin >> comissao; porcentagem = comissao * 0.15; dinheiro = porcentagem + vendido; cout << "TOTAL = R$ " << fixed << dinheiro << endl; return 0; }
15.6
55
0.597436
Lu1zReis
0250f6b51cc69708684f4bd9255828a8e6dee3d9
4,067
cpp
C++
src/timer.cpp
jake-stewart/grid
a46c1c14550df85d05cbb0cb6bbca8e84cb72e21
[ "MIT" ]
3
2021-07-28T13:49:28.000Z
2021-12-07T15:48:19.000Z
src/timer.cpp
jake-stewart/grid
a46c1c14550df85d05cbb0cb6bbca8e84cb72e21
[ "MIT" ]
null
null
null
src/timer.cpp
jake-stewart/grid
a46c1c14550df85d05cbb0cb6bbca8e84cb72e21
[ "MIT" ]
1
2021-08-12T04:44:46.000Z
2021-08-12T04:44:46.000Z
#include "grid.h" #include <thread> #include <math.h> #include <iostream> #include <chrono> #include <mutex> void Grid::drawCellQueue() { for (auto cell: _cell_draw_queue) { int chunk_idx_x = floor(cell.x / (float)CHUNK_SIZE); int chunk_idx_y = floor(cell.y / (float)CHUNK_SIZE); uint64_t chunk_idx = (uint64_t)chunk_idx_x << 32 | (uint32_t)chunk_idx_y; auto chunk = _chunks[!_buffer_idx].find(chunk_idx); if (chunk == _chunks[!_buffer_idx].end()) { auto pixels = _chunks[!_buffer_idx][chunk_idx].pixels; for (int i = 0; i < CHUNK_SIZE * CHUNK_SIZE * 4; i += 4) { pixels[i] = _background_color.r; pixels[i + 1] = _background_color.g; pixels[i + 2] = _background_color.b; pixels[i + 3] = 255; } } int pixel_y = cell.y % CHUNK_SIZE; if (pixel_y < 0) pixel_y += CHUNK_SIZE; int pixel_x = cell.x % CHUNK_SIZE; if (pixel_x < 0) pixel_x += CHUNK_SIZE; int pixel_idx = (pixel_y * CHUNK_SIZE + pixel_x) * 4; auto pixels = _chunks[!_buffer_idx][chunk_idx].pixels; pixels[pixel_idx] = cell.color.r; pixels[pixel_idx + 1] = cell.color.g; pixels[pixel_idx + 2] = cell.color.b; pixels[pixel_idx + 3] = 255; } _cell_draw_queue.clear(); } void Grid::startThread() { if (!_thread_active) { _thread_state = inactive; _thread_active = true; _thread = std::thread(&Grid::threadFunc, this); } } void Grid::endThread() { if (_thread_active) { _thread_active = false; _thread_state = joining; _cv.notify_one(); _thread.join(); } } void Grid::threadFunc() { while (true) { { // wait for thread to be triggered std::unique_lock<std::mutex> lock(_mutex); if (!_thread_active) return; _thread_state = inactive; while (_thread_state == inactive) { _cv.wait(lock); } } // run the thread onTimerEvent(_n_iterations); { // wait for main thread to have swapped buffer std::unique_lock<std::mutex> lock(_mutex); if (!_thread_active) return; _thread_state = swapping; while (_thread_state == swapping) { _cv.wait(lock); } } if (!_thread_active) return; // duplicate the new cells onto the buffer drawCellQueue(); } _thread_state = joining; } void Grid::startTimer() { if (_timer_active) return; _old_chunk_render_left = _chunk_render_left; _old_chunk_render_right = _chunk_render_right; _old_chunk_render_top = _chunk_render_top; _old_chunk_render_bottom = _chunk_render_bottom; finishAnimations(); _timer_active = true; _timer.restart(); } void Grid::setTimer(float timer_interval) { _timer_interval = timer_interval; _timer.restart(); } void Grid::stopTimer() { if (!_timer_active) return; _timer_active = false; } void Grid::incrementTimer() { if (!_timer_active) return; if (_chunk_queue.size()) return; if (_timer.getElapsedTime().asSeconds() < _timer_interval) return; if (_thread_state != inactive) { return; } std::unique_lock<std::mutex> lock(_mutex); _old_chunk_render_left = _chunk_render_left; _old_chunk_render_right = _chunk_render_right; _old_chunk_render_top = _chunk_render_top; _old_chunk_render_bottom = _chunk_render_bottom; _n_iterations = (_timer_interval == 0) ? 10000 : round(_timer.getElapsedTime().asSeconds() / _timer_interval); _timer.restart(); _thread_state = active; _cv.notify_one(); }
25.578616
82
0.562577
jake-stewart
025244b20cc5b62271fd34b136276c60a958a35f
1,012
cpp
C++
2M3/Source/Common/Managers/Signature.cpp
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
null
null
null
2M3/Source/Common/Managers/Signature.cpp
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
45
2020-10-08T13:32:36.000Z
2020-12-17T14:41:40.000Z
2M3/Source/Common/Managers/Signature.cpp
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
3
2020-10-02T09:02:20.000Z
2020-11-07T00:14:13.000Z
#include "Common/Managers/Signature.h" thread_local std::size_t Signature::registeredComponentsCount = 0; thread_local std::unordered_map<std::size_t, std::size_t> Signature::idToBitIndexMap; /** * Constructs an empty signature (00000...). */ Signature::Signature() : bitset() {} /** * Operator overload to perform a logic AND operation between two signatures. * @param signature The second signature to perform the operation on. */ Signature Signature::operator&(const Signature& signature) const { Signature result; result.bitset = bitset & signature.bitset; return result; } /** * Operator overload to check if two signatures are the same. * @param signature The second signature to perform the operation on. */ bool Signature::operator==(const Signature& signature) const { return bitset == signature.bitset; } /** * Operator overload to extract the bitset in an ostream object. */ std::ostream& operator<<(std::ostream& os, const Signature& signature) { return os << signature.bitset; }
25.948718
85
0.741107
simatic
0256415dd015ddfc7dfa99736fc9604144c421c7
44,630
cc
C++
keynote-protos/gen/KNCommandArchives.sos.pb.cc
eth-siplab/SVG2Keynote-lib
b7e6dfe5084911dac1fa6261a14254bfbbd8065b
[ "MIT" ]
4
2021-11-24T14:27:32.000Z
2022-03-14T07:52:44.000Z
keynote-protos/gen/KNCommandArchives.sos.pb.cc
eth-siplab/SVG2Keynote-lib
b7e6dfe5084911dac1fa6261a14254bfbbd8065b
[ "MIT" ]
null
null
null
keynote-protos/gen/KNCommandArchives.sos.pb.cc
eth-siplab/SVG2Keynote-lib
b7e6dfe5084911dac1fa6261a14254bfbbd8065b
[ "MIT" ]
null
null
null
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: KNCommandArchives.sos.proto #include "KNCommandArchives.sos.pb.h" #include <algorithm> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG namespace KNSOS { constexpr InducedVerifyDocumentWithServerCommandArchive::InducedVerifyDocumentWithServerCommandArchive( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : slide_node_id_list_() , template_slide_node_id_list_() , super_(nullptr) , slide_node_id_list_undefined_(false) , template_slide_node_id_list_undefined_(false){} struct InducedVerifyDocumentWithServerCommandArchiveDefaultTypeInternal { constexpr InducedVerifyDocumentWithServerCommandArchiveDefaultTypeInternal() : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} ~InducedVerifyDocumentWithServerCommandArchiveDefaultTypeInternal() {} union { InducedVerifyDocumentWithServerCommandArchive _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT InducedVerifyDocumentWithServerCommandArchiveDefaultTypeInternal _InducedVerifyDocumentWithServerCommandArchive_default_instance_; constexpr InducedVerifyDrawableZOrdersWithServerCommandArchive::InducedVerifyDrawableZOrdersWithServerCommandArchive( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : super_(nullptr){} struct InducedVerifyDrawableZOrdersWithServerCommandArchiveDefaultTypeInternal { constexpr InducedVerifyDrawableZOrdersWithServerCommandArchiveDefaultTypeInternal() : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} ~InducedVerifyDrawableZOrdersWithServerCommandArchiveDefaultTypeInternal() {} union { InducedVerifyDrawableZOrdersWithServerCommandArchive _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT InducedVerifyDrawableZOrdersWithServerCommandArchiveDefaultTypeInternal _InducedVerifyDrawableZOrdersWithServerCommandArchive_default_instance_; constexpr CommandSlideReapplyTemplateSlideArchive::CommandSlideReapplyTemplateSlideArchive( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : super_(nullptr){} struct CommandSlideReapplyTemplateSlideArchiveDefaultTypeInternal { constexpr CommandSlideReapplyTemplateSlideArchiveDefaultTypeInternal() : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} ~CommandSlideReapplyTemplateSlideArchiveDefaultTypeInternal() {} union { CommandSlideReapplyTemplateSlideArchive _instance; }; }; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CommandSlideReapplyTemplateSlideArchiveDefaultTypeInternal _CommandSlideReapplyTemplateSlideArchive_default_instance_; } // namespace KNSOS static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_KNCommandArchives_2esos_2eproto[3]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_KNCommandArchives_2esos_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_KNCommandArchives_2esos_2eproto = nullptr; const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_KNCommandArchives_2esos_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, _has_bits_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, super_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, slide_node_id_list_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, slide_node_id_list_undefined_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, template_slide_node_id_list_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDocumentWithServerCommandArchive, template_slide_node_id_list_undefined_), 0, ~0u, 1, ~0u, 2, PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive, _has_bits_), PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive, super_), 0, PROTOBUF_FIELD_OFFSET(::KNSOS::CommandSlideReapplyTemplateSlideArchive, _has_bits_), PROTOBUF_FIELD_OFFSET(::KNSOS::CommandSlideReapplyTemplateSlideArchive, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::KNSOS::CommandSlideReapplyTemplateSlideArchive, super_), 0, }; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 10, sizeof(::KNSOS::InducedVerifyDocumentWithServerCommandArchive)}, { 15, 21, sizeof(::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive)}, { 22, 28, sizeof(::KNSOS::CommandSlideReapplyTemplateSlideArchive)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::KNSOS::_InducedVerifyDocumentWithServerCommandArchive_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::KNSOS::_InducedVerifyDrawableZOrdersWithServerCommandArchive_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::KNSOS::_CommandSlideReapplyTemplateSlideArchive_default_instance_), }; const char descriptor_table_protodef_KNCommandArchives_2esos_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\033KNCommandArchives.sos.proto\022\005KNSOS\032\034TS" "ACommandArchives.sos.proto\032\021TSKArchives." "proto\032\021TSPMessages.proto\"\377\001\n-InducedVeri" "fyDocumentWithServerCommandArchive\022\"\n\005su" "per\030\001 \002(\0132\023.TSK.CommandArchive\022%\n\022slide_" "node_id_list\030\002 \003(\0132\t.TSP.UUID\022$\n\034slide_n" "ode_id_list_undefined\030\003 \001(\010\022.\n\033template_" "slide_node_id_list\030\004 \003(\0132\t.TSP.UUID\022-\n%t" "emplate_slide_node_id_list_undefined\030\005 \001" "(\010\"\203\001\n4InducedVerifyDrawableZOrdersWithS" "erverCommandArchive\022K\n\005super\030\001 \002(\0132<.TSA" "SOS.InducedVerifyDrawableZOrdersWithServ" "erCommandArchive\"]\n\'CommandSlideReapplyT" "emplateSlideArchive\0222\n\005super\030\001 \002(\0132#.TSA" "SOS.CommandReapplyMasterArchive" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_KNCommandArchives_2esos_2eproto_deps[3] = { &::descriptor_table_TSACommandArchives_2esos_2eproto, &::descriptor_table_TSKArchives_2eproto, &::descriptor_table_TSPMessages_2eproto, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_KNCommandArchives_2esos_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_KNCommandArchives_2esos_2eproto = { false, false, 591, descriptor_table_protodef_KNCommandArchives_2esos_2eproto, "KNCommandArchives.sos.proto", &descriptor_table_KNCommandArchives_2esos_2eproto_once, descriptor_table_KNCommandArchives_2esos_2eproto_deps, 3, 3, schemas, file_default_instances, TableStruct_KNCommandArchives_2esos_2eproto::offsets, file_level_metadata_KNCommandArchives_2esos_2eproto, file_level_enum_descriptors_KNCommandArchives_2esos_2eproto, file_level_service_descriptors_KNCommandArchives_2esos_2eproto, }; PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_KNCommandArchives_2esos_2eproto_getter() { return &descriptor_table_KNCommandArchives_2esos_2eproto; } // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_KNCommandArchives_2esos_2eproto(&descriptor_table_KNCommandArchives_2esos_2eproto); namespace KNSOS { // =================================================================== class InducedVerifyDocumentWithServerCommandArchive::_Internal { public: using HasBits = decltype(std::declval<InducedVerifyDocumentWithServerCommandArchive>()._has_bits_); static const ::TSK::CommandArchive& super(const InducedVerifyDocumentWithServerCommandArchive* msg); static void set_has_super(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_slide_node_id_list_undefined(HasBits* has_bits) { (*has_bits)[0] |= 2u; } static void set_has_template_slide_node_id_list_undefined(HasBits* has_bits) { (*has_bits)[0] |= 4u; } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; const ::TSK::CommandArchive& InducedVerifyDocumentWithServerCommandArchive::_Internal::super(const InducedVerifyDocumentWithServerCommandArchive* msg) { return *msg->super_; } void InducedVerifyDocumentWithServerCommandArchive::clear_super() { if (super_ != nullptr) super_->Clear(); _has_bits_[0] &= ~0x00000001u; } void InducedVerifyDocumentWithServerCommandArchive::clear_slide_node_id_list() { slide_node_id_list_.Clear(); } void InducedVerifyDocumentWithServerCommandArchive::clear_template_slide_node_id_list() { template_slide_node_id_list_.Clear(); } InducedVerifyDocumentWithServerCommandArchive::InducedVerifyDocumentWithServerCommandArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), slide_node_id_list_(arena), template_slide_node_id_list_(arena) { SharedCtor(); if (!is_message_owned) { RegisterArenaDtor(arena); } // @@protoc_insertion_point(arena_constructor:KNSOS.InducedVerifyDocumentWithServerCommandArchive) } InducedVerifyDocumentWithServerCommandArchive::InducedVerifyDocumentWithServerCommandArchive(const InducedVerifyDocumentWithServerCommandArchive& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _has_bits_(from._has_bits_), slide_node_id_list_(from.slide_node_id_list_), template_slide_node_id_list_(from.template_slide_node_id_list_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_super()) { super_ = new ::TSK::CommandArchive(*from.super_); } else { super_ = nullptr; } ::memcpy(&slide_node_id_list_undefined_, &from.slide_node_id_list_undefined_, static_cast<size_t>(reinterpret_cast<char*>(&template_slide_node_id_list_undefined_) - reinterpret_cast<char*>(&slide_node_id_list_undefined_)) + sizeof(template_slide_node_id_list_undefined_)); // @@protoc_insertion_point(copy_constructor:KNSOS.InducedVerifyDocumentWithServerCommandArchive) } inline void InducedVerifyDocumentWithServerCommandArchive::SharedCtor() { ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&super_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&template_slide_node_id_list_undefined_) - reinterpret_cast<char*>(&super_)) + sizeof(template_slide_node_id_list_undefined_)); } InducedVerifyDocumentWithServerCommandArchive::~InducedVerifyDocumentWithServerCommandArchive() { // @@protoc_insertion_point(destructor:KNSOS.InducedVerifyDocumentWithServerCommandArchive) if (GetArenaForAllocation() != nullptr) return; SharedDtor(); _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void InducedVerifyDocumentWithServerCommandArchive::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete super_; } void InducedVerifyDocumentWithServerCommandArchive::ArenaDtor(void* object) { InducedVerifyDocumentWithServerCommandArchive* _this = reinterpret_cast< InducedVerifyDocumentWithServerCommandArchive* >(object); (void)_this; } void InducedVerifyDocumentWithServerCommandArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { } void InducedVerifyDocumentWithServerCommandArchive::SetCachedSize(int size) const { _cached_size_.Set(size); } void InducedVerifyDocumentWithServerCommandArchive::Clear() { // @@protoc_insertion_point(message_clear_start:KNSOS.InducedVerifyDocumentWithServerCommandArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; slide_node_id_list_.Clear(); template_slide_node_id_list_.Clear(); cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(super_ != nullptr); super_->Clear(); } ::memset(&slide_node_id_list_undefined_, 0, static_cast<size_t>( reinterpret_cast<char*>(&template_slide_node_id_list_undefined_) - reinterpret_cast<char*>(&slide_node_id_list_undefined_)) + sizeof(template_slide_node_id_list_undefined_)); _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* InducedVerifyDocumentWithServerCommandArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // required .TSK.CommandArchive super = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_super(), ptr); CHK_(ptr); } else goto handle_unusual; continue; // repeated .TSP.UUID slide_node_id_list = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { ptr -= 1; do { ptr += 1; ptr = ctx->ParseMessage(_internal_add_slide_node_id_list(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // optional bool slide_node_id_list_undefined = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { _Internal::set_has_slide_node_id_list_undefined(&has_bits); slide_node_id_list_undefined_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // repeated .TSP.UUID template_slide_node_id_list = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { ptr -= 1; do { ptr += 1; ptr = ctx->ParseMessage(_internal_add_template_slide_node_id_list(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; // optional bool template_slide_node_id_list_undefined = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { _Internal::set_has_template_slide_node_id_list_undefined(&has_bits); template_slide_node_id_list_undefined_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: _has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } ::PROTOBUF_NAMESPACE_ID::uint8* InducedVerifyDocumentWithServerCommandArchive::_InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:KNSOS.InducedVerifyDocumentWithServerCommandArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // required .TSK.CommandArchive super = 1; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage( 1, _Internal::super(this), target, stream); } // repeated .TSP.UUID slide_node_id_list = 2; for (unsigned int i = 0, n = static_cast<unsigned int>(this->_internal_slide_node_id_list_size()); i < n; i++) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(2, this->_internal_slide_node_id_list(i), target, stream); } // optional bool slide_node_id_list_undefined = 3; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_slide_node_id_list_undefined(), target); } // repeated .TSP.UUID template_slide_node_id_list = 4; for (unsigned int i = 0, n = static_cast<unsigned int>(this->_internal_template_slide_node_id_list_size()); i < n; i++) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(4, this->_internal_template_slide_node_id_list(i), target, stream); } // optional bool template_slide_node_id_list_undefined = 5; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_template_slide_node_id_list_undefined(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:KNSOS.InducedVerifyDocumentWithServerCommandArchive) return target; } size_t InducedVerifyDocumentWithServerCommandArchive::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:KNSOS.InducedVerifyDocumentWithServerCommandArchive) size_t total_size = 0; // required .TSK.CommandArchive super = 1; if (_internal_has_super()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *super_); } ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // repeated .TSP.UUID slide_node_id_list = 2; total_size += 1UL * this->_internal_slide_node_id_list_size(); for (const auto& msg : this->slide_node_id_list_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .TSP.UUID template_slide_node_id_list = 4; total_size += 1UL * this->_internal_template_slide_node_id_list_size(); for (const auto& msg : this->template_slide_node_id_list_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000006u) { // optional bool slide_node_id_list_undefined = 3; if (cached_has_bits & 0x00000002u) { total_size += 1 + 1; } // optional bool template_slide_node_id_list_undefined = 5; if (cached_has_bits & 0x00000004u) { total_size += 1 + 1; } } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InducedVerifyDocumentWithServerCommandArchive::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, InducedVerifyDocumentWithServerCommandArchive::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InducedVerifyDocumentWithServerCommandArchive::GetClassData() const { return &_class_data_; } void InducedVerifyDocumentWithServerCommandArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from) { static_cast<InducedVerifyDocumentWithServerCommandArchive *>(to)->MergeFrom( static_cast<const InducedVerifyDocumentWithServerCommandArchive &>(from)); } void InducedVerifyDocumentWithServerCommandArchive::MergeFrom(const InducedVerifyDocumentWithServerCommandArchive& from) { // @@protoc_insertion_point(class_specific_merge_from_start:KNSOS.InducedVerifyDocumentWithServerCommandArchive) GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; slide_node_id_list_.MergeFrom(from.slide_node_id_list_); template_slide_node_id_list_.MergeFrom(from.template_slide_node_id_list_); cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { _internal_mutable_super()->::TSK::CommandArchive::MergeFrom(from._internal_super()); } if (cached_has_bits & 0x00000002u) { slide_node_id_list_undefined_ = from.slide_node_id_list_undefined_; } if (cached_has_bits & 0x00000004u) { template_slide_node_id_list_undefined_ = from.template_slide_node_id_list_undefined_; } _has_bits_[0] |= cached_has_bits; } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void InducedVerifyDocumentWithServerCommandArchive::CopyFrom(const InducedVerifyDocumentWithServerCommandArchive& from) { // @@protoc_insertion_point(class_specific_copy_from_start:KNSOS.InducedVerifyDocumentWithServerCommandArchive) if (&from == this) return; Clear(); MergeFrom(from); } bool InducedVerifyDocumentWithServerCommandArchive::IsInitialized() const { if (_Internal::MissingRequiredFields(_has_bits_)) return false; if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(slide_node_id_list_)) return false; if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(template_slide_node_id_list_)) return false; if (_internal_has_super()) { if (!super_->IsInitialized()) return false; } return true; } void InducedVerifyDocumentWithServerCommandArchive::InternalSwap(InducedVerifyDocumentWithServerCommandArchive* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); slide_node_id_list_.InternalSwap(&other->slide_node_id_list_); template_slide_node_id_list_.InternalSwap(&other->template_slide_node_id_list_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(InducedVerifyDocumentWithServerCommandArchive, template_slide_node_id_list_undefined_) + sizeof(InducedVerifyDocumentWithServerCommandArchive::template_slide_node_id_list_undefined_) - PROTOBUF_FIELD_OFFSET(InducedVerifyDocumentWithServerCommandArchive, super_)>( reinterpret_cast<char*>(&super_), reinterpret_cast<char*>(&other->super_)); } ::PROTOBUF_NAMESPACE_ID::Metadata InducedVerifyDocumentWithServerCommandArchive::GetMetadata() const { return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( &descriptor_table_KNCommandArchives_2esos_2eproto_getter, &descriptor_table_KNCommandArchives_2esos_2eproto_once, file_level_metadata_KNCommandArchives_2esos_2eproto[0]); } // =================================================================== class InducedVerifyDrawableZOrdersWithServerCommandArchive::_Internal { public: using HasBits = decltype(std::declval<InducedVerifyDrawableZOrdersWithServerCommandArchive>()._has_bits_); static const ::TSASOS::InducedVerifyDrawableZOrdersWithServerCommandArchive& super(const InducedVerifyDrawableZOrdersWithServerCommandArchive* msg); static void set_has_super(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; const ::TSASOS::InducedVerifyDrawableZOrdersWithServerCommandArchive& InducedVerifyDrawableZOrdersWithServerCommandArchive::_Internal::super(const InducedVerifyDrawableZOrdersWithServerCommandArchive* msg) { return *msg->super_; } void InducedVerifyDrawableZOrdersWithServerCommandArchive::clear_super() { if (super_ != nullptr) super_->Clear(); _has_bits_[0] &= ~0x00000001u; } InducedVerifyDrawableZOrdersWithServerCommandArchive::InducedVerifyDrawableZOrdersWithServerCommandArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); if (!is_message_owned) { RegisterArenaDtor(arena); } // @@protoc_insertion_point(arena_constructor:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) } InducedVerifyDrawableZOrdersWithServerCommandArchive::InducedVerifyDrawableZOrdersWithServerCommandArchive(const InducedVerifyDrawableZOrdersWithServerCommandArchive& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_super()) { super_ = new ::TSASOS::InducedVerifyDrawableZOrdersWithServerCommandArchive(*from.super_); } else { super_ = nullptr; } // @@protoc_insertion_point(copy_constructor:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) } inline void InducedVerifyDrawableZOrdersWithServerCommandArchive::SharedCtor() { super_ = nullptr; } InducedVerifyDrawableZOrdersWithServerCommandArchive::~InducedVerifyDrawableZOrdersWithServerCommandArchive() { // @@protoc_insertion_point(destructor:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) if (GetArenaForAllocation() != nullptr) return; SharedDtor(); _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void InducedVerifyDrawableZOrdersWithServerCommandArchive::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete super_; } void InducedVerifyDrawableZOrdersWithServerCommandArchive::ArenaDtor(void* object) { InducedVerifyDrawableZOrdersWithServerCommandArchive* _this = reinterpret_cast< InducedVerifyDrawableZOrdersWithServerCommandArchive* >(object); (void)_this; } void InducedVerifyDrawableZOrdersWithServerCommandArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { } void InducedVerifyDrawableZOrdersWithServerCommandArchive::SetCachedSize(int size) const { _cached_size_.Set(size); } void InducedVerifyDrawableZOrdersWithServerCommandArchive::Clear() { // @@protoc_insertion_point(message_clear_start:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(super_ != nullptr); super_->Clear(); } _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* InducedVerifyDrawableZOrdersWithServerCommandArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // required .TSASOS.InducedVerifyDrawableZOrdersWithServerCommandArchive super = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_super(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: _has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } ::PROTOBUF_NAMESPACE_ID::uint8* InducedVerifyDrawableZOrdersWithServerCommandArchive::_InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // required .TSASOS.InducedVerifyDrawableZOrdersWithServerCommandArchive super = 1; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage( 1, _Internal::super(this), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) return target; } size_t InducedVerifyDrawableZOrdersWithServerCommandArchive::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) size_t total_size = 0; // required .TSASOS.InducedVerifyDrawableZOrdersWithServerCommandArchive super = 1; if (_internal_has_super()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *super_); } ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InducedVerifyDrawableZOrdersWithServerCommandArchive::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, InducedVerifyDrawableZOrdersWithServerCommandArchive::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InducedVerifyDrawableZOrdersWithServerCommandArchive::GetClassData() const { return &_class_data_; } void InducedVerifyDrawableZOrdersWithServerCommandArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from) { static_cast<InducedVerifyDrawableZOrdersWithServerCommandArchive *>(to)->MergeFrom( static_cast<const InducedVerifyDrawableZOrdersWithServerCommandArchive &>(from)); } void InducedVerifyDrawableZOrdersWithServerCommandArchive::MergeFrom(const InducedVerifyDrawableZOrdersWithServerCommandArchive& from) { // @@protoc_insertion_point(class_specific_merge_from_start:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_super()) { _internal_mutable_super()->::TSASOS::InducedVerifyDrawableZOrdersWithServerCommandArchive::MergeFrom(from._internal_super()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void InducedVerifyDrawableZOrdersWithServerCommandArchive::CopyFrom(const InducedVerifyDrawableZOrdersWithServerCommandArchive& from) { // @@protoc_insertion_point(class_specific_copy_from_start:KNSOS.InducedVerifyDrawableZOrdersWithServerCommandArchive) if (&from == this) return; Clear(); MergeFrom(from); } bool InducedVerifyDrawableZOrdersWithServerCommandArchive::IsInitialized() const { if (_Internal::MissingRequiredFields(_has_bits_)) return false; if (_internal_has_super()) { if (!super_->IsInitialized()) return false; } return true; } void InducedVerifyDrawableZOrdersWithServerCommandArchive::InternalSwap(InducedVerifyDrawableZOrdersWithServerCommandArchive* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); swap(super_, other->super_); } ::PROTOBUF_NAMESPACE_ID::Metadata InducedVerifyDrawableZOrdersWithServerCommandArchive::GetMetadata() const { return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( &descriptor_table_KNCommandArchives_2esos_2eproto_getter, &descriptor_table_KNCommandArchives_2esos_2eproto_once, file_level_metadata_KNCommandArchives_2esos_2eproto[1]); } // =================================================================== class CommandSlideReapplyTemplateSlideArchive::_Internal { public: using HasBits = decltype(std::declval<CommandSlideReapplyTemplateSlideArchive>()._has_bits_); static const ::TSASOS::CommandReapplyMasterArchive& super(const CommandSlideReapplyTemplateSlideArchive* msg); static void set_has_super(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static bool MissingRequiredFields(const HasBits& has_bits) { return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; } }; const ::TSASOS::CommandReapplyMasterArchive& CommandSlideReapplyTemplateSlideArchive::_Internal::super(const CommandSlideReapplyTemplateSlideArchive* msg) { return *msg->super_; } void CommandSlideReapplyTemplateSlideArchive::clear_super() { if (super_ != nullptr) super_->Clear(); _has_bits_[0] &= ~0x00000001u; } CommandSlideReapplyTemplateSlideArchive::CommandSlideReapplyTemplateSlideArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { SharedCtor(); if (!is_message_owned) { RegisterArenaDtor(arena); } // @@protoc_insertion_point(arena_constructor:KNSOS.CommandSlideReapplyTemplateSlideArchive) } CommandSlideReapplyTemplateSlideArchive::CommandSlideReapplyTemplateSlideArchive(const CommandSlideReapplyTemplateSlideArchive& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_super()) { super_ = new ::TSASOS::CommandReapplyMasterArchive(*from.super_); } else { super_ = nullptr; } // @@protoc_insertion_point(copy_constructor:KNSOS.CommandSlideReapplyTemplateSlideArchive) } inline void CommandSlideReapplyTemplateSlideArchive::SharedCtor() { super_ = nullptr; } CommandSlideReapplyTemplateSlideArchive::~CommandSlideReapplyTemplateSlideArchive() { // @@protoc_insertion_point(destructor:KNSOS.CommandSlideReapplyTemplateSlideArchive) if (GetArenaForAllocation() != nullptr) return; SharedDtor(); _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void CommandSlideReapplyTemplateSlideArchive::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete super_; } void CommandSlideReapplyTemplateSlideArchive::ArenaDtor(void* object) { CommandSlideReapplyTemplateSlideArchive* _this = reinterpret_cast< CommandSlideReapplyTemplateSlideArchive* >(object); (void)_this; } void CommandSlideReapplyTemplateSlideArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { } void CommandSlideReapplyTemplateSlideArchive::SetCachedSize(int size) const { _cached_size_.Set(size); } void CommandSlideReapplyTemplateSlideArchive::Clear() { // @@protoc_insertion_point(message_clear_start:KNSOS.CommandSlideReapplyTemplateSlideArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(super_ != nullptr); super_->Clear(); } _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } const char* CommandSlideReapplyTemplateSlideArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // required .TSASOS.CommandReapplyMasterArchive super = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_super(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: _has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } ::PROTOBUF_NAMESPACE_ID::uint8* CommandSlideReapplyTemplateSlideArchive::_InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:KNSOS.CommandSlideReapplyTemplateSlideArchive) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // required .TSASOS.CommandReapplyMasterArchive super = 1; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage( 1, _Internal::super(this), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:KNSOS.CommandSlideReapplyTemplateSlideArchive) return target; } size_t CommandSlideReapplyTemplateSlideArchive::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:KNSOS.CommandSlideReapplyTemplateSlideArchive) size_t total_size = 0; // required .TSASOS.CommandReapplyMasterArchive super = 1; if (_internal_has_super()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *super_); } ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CommandSlideReapplyTemplateSlideArchive::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, CommandSlideReapplyTemplateSlideArchive::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CommandSlideReapplyTemplateSlideArchive::GetClassData() const { return &_class_data_; } void CommandSlideReapplyTemplateSlideArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from) { static_cast<CommandSlideReapplyTemplateSlideArchive *>(to)->MergeFrom( static_cast<const CommandSlideReapplyTemplateSlideArchive &>(from)); } void CommandSlideReapplyTemplateSlideArchive::MergeFrom(const CommandSlideReapplyTemplateSlideArchive& from) { // @@protoc_insertion_point(class_specific_merge_from_start:KNSOS.CommandSlideReapplyTemplateSlideArchive) GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from._internal_has_super()) { _internal_mutable_super()->::TSASOS::CommandReapplyMasterArchive::MergeFrom(from._internal_super()); } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CommandSlideReapplyTemplateSlideArchive::CopyFrom(const CommandSlideReapplyTemplateSlideArchive& from) { // @@protoc_insertion_point(class_specific_copy_from_start:KNSOS.CommandSlideReapplyTemplateSlideArchive) if (&from == this) return; Clear(); MergeFrom(from); } bool CommandSlideReapplyTemplateSlideArchive::IsInitialized() const { if (_Internal::MissingRequiredFields(_has_bits_)) return false; if (_internal_has_super()) { if (!super_->IsInitialized()) return false; } return true; } void CommandSlideReapplyTemplateSlideArchive::InternalSwap(CommandSlideReapplyTemplateSlideArchive* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); swap(super_, other->super_); } ::PROTOBUF_NAMESPACE_ID::Metadata CommandSlideReapplyTemplateSlideArchive::GetMetadata() const { return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( &descriptor_table_KNCommandArchives_2esos_2eproto_getter, &descriptor_table_KNCommandArchives_2esos_2eproto_once, file_level_metadata_KNCommandArchives_2esos_2eproto[2]); } // @@protoc_insertion_point(namespace_scope) } // namespace KNSOS PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE ::KNSOS::InducedVerifyDocumentWithServerCommandArchive* Arena::CreateMaybeMessage< ::KNSOS::InducedVerifyDocumentWithServerCommandArchive >(Arena* arena) { return Arena::CreateMessageInternal< ::KNSOS::InducedVerifyDocumentWithServerCommandArchive >(arena); } template<> PROTOBUF_NOINLINE ::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive* Arena::CreateMaybeMessage< ::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive >(Arena* arena) { return Arena::CreateMessageInternal< ::KNSOS::InducedVerifyDrawableZOrdersWithServerCommandArchive >(arena); } template<> PROTOBUF_NOINLINE ::KNSOS::CommandSlideReapplyTemplateSlideArchive* Arena::CreateMaybeMessage< ::KNSOS::CommandSlideReapplyTemplateSlideArchive >(Arena* arena) { return Arena::CreateMessageInternal< ::KNSOS::CommandSlideReapplyTemplateSlideArchive >(arena); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc>
46.153051
198
0.781515
eth-siplab
025c68e50e07febd15e6b51ae4c70359e51cc157
8,975
cpp
C++
src/editor/components/visualtablefield.cpp
ufopleds/DengueME_public
6bc4af029ba88b645fc9e6d2bb437a65c548a0de
[ "BSD-2-Clause" ]
5
2016-12-17T16:02:38.000Z
2018-12-12T21:33:04.000Z
src/editor/components/visualtablefield.cpp
ufopleds/DengueME_public
6bc4af029ba88b645fc9e6d2bb437a65c548a0de
[ "BSD-2-Clause" ]
44
2016-07-15T20:00:27.000Z
2021-03-02T02:22:53.000Z
src/editor/components/visualtablefield.cpp
ufopleds/DengueME_public
6bc4af029ba88b645fc9e6d2bb437a65c548a0de
[ "BSD-2-Clause" ]
5
2016-10-16T06:54:43.000Z
2020-03-21T20:05:38.000Z
#include "visualtablefield.h" #include "ui_visualtablefield.h" VisualTableField::VisualTableField(QWidget* parent) : Component(parent), widget(NULL), ui(new Ui::VisualTableField), type(Null) { ui->setupUi(this); menu = new QMenu(this); actionVariable = new QAction(tr("&Variable"), menu); actionVariable->setCheckable(true); menu->addAction(actionVariable); connect(actionVariable, SIGNAL(triggered()), SLOT(onActionVariable())); connect(ui->rButton, SIGNAL(clicked()), this, SLOT(useLogVariable())); connect(ui->lButton, SIGNAL(clicked()), this, SLOT(notUseLogVariable())); connect(ui->add, SIGNAL(clicked()), SLOT(add())); connect(ui->del, SIGNAL(clicked()), SLOT(del())); connect(ui->selectDefault, SIGNAL(toggled(bool)), SLOT(selectAllDefaultVars(bool))); connect(ui->selectUse, SIGNAL(toggled(bool)), SLOT(selectAllUseVars(bool))); updateMenu(); } VisualTableField::~VisualTableField() { delete ui; } void VisualTableField::selectAllDefaultVars(bool select) { if(select) ui->defaultVarList->selectAll(); else ui->defaultVarList->clearSelection(); } void VisualTableField::selectAllUseVars(bool select) { if(select) ui->useVarList->selectAll(); else ui->useVarList->clearSelection(); } void VisualTableField::useLogVariable() { QModelIndexList selection = ui->defaultVarList->selectionModel()->selectedRows(); for(int i = 0; i < selection.count(); i++) { QTableWidgetItem* label = new QTableWidgetItem (ui->defaultVarList->item(selection.at(i).row(), 1)->text()); QTableWidgetItem* id = new QTableWidgetItem (ui->defaultVarList->item(selection.at(i).row(), 0)->text()); int currentRowCount = ui->useVarList->rowCount(); ui->useVarList->insertRow(currentRowCount); ui->useVarList->setItem(currentRowCount, 1, label); ui->useVarList->setItem(currentRowCount, 0, id); } QList<QTableWidgetItem*> items = ui->defaultVarList->selectedItems(); for(int i = 0; i < items.length(); i = i + 2) { int row = items[i]->row(); if(row >= 0) { ui->defaultVarList->removeRow(row); ui->defaultVarList->setCurrentIndex(ui->defaultVarList->model()->index(row, 0)); } } ui->selectDefault->setChecked(false); } void VisualTableField::notUseLogVariable() { QModelIndexList selection = ui->useVarList->selectionModel()->selectedRows(); for(int i = 0; i < selection.count(); i++) { QTableWidgetItem* label = new QTableWidgetItem (ui->useVarList->item(selection.at(i).row(), 1)->text()); QTableWidgetItem* id = new QTableWidgetItem (ui->useVarList->item(selection.at(i).row(), 0)->text()); int currentRowCount = ui->defaultVarList->rowCount(); ui->defaultVarList->insertRow(currentRowCount); ui->defaultVarList->setItem(currentRowCount, 1, label); ui->defaultVarList->setItem(currentRowCount, 0, id); } QList<QTableWidgetItem*> items = ui->useVarList->selectedItems(); for(int i = 0; i < items.length(); i = i + 2) { int row = items[i]->row(); if(row >= 0) { ui->useVarList->removeRow(row); ui->useVarList->setCurrentIndex(ui->useVarList->model()->index(row, 0)); } } ui->selectUse->setChecked(false); } void VisualTableField::add() { QTableWidgetItem* label = new QTableWidgetItem ("New Label"); QTableWidgetItem* id = new QTableWidgetItem ("New id"); int currentRowCount = ui->defaultVarList->rowCount(); ui->defaultVarList->insertRow(currentRowCount); ui->defaultVarList->setItem(currentRowCount, 1, label); ui->defaultVarList->setItem(currentRowCount, 0, id); } void VisualTableField::del() { QModelIndex currentIndex = ui->defaultVarList->currentIndex(); ui->defaultVarList->removeRow(currentIndex.row()); QList<QTableWidgetItem*> items = ui->defaultVarList->selectedItems(); for(int i = 0; i < items.length(); i = i + 2) { int row = items[i]->row(); if(row >= 0) { ui->defaultVarList->removeRow(row); ui->defaultVarList->setCurrentIndex(ui->defaultVarList->model()->index(row, 0)); } } } QDomDocument VisualTableField::getXml() { QDomDocument ret; if(ui->useVarList->rowCount() == 0 && ui->defaultVarList->rowCount() == 0) { QDomElement opt = ret.createElement("variable"); opt.appendChild(ret.createTextNode("empty")); opt.setAttribute("output", "false"); ret.appendChild(opt); } for (int i = 0; i < ui->useVarList->rowCount(); ++i) { QDomElement opt = ret.createElement("variable"); opt.setAttribute("id", ui->useVarList->item(i, 0)->text()); opt.setAttribute("select", ui->useVarList->item(i, 0)->text()); opt.setAttribute("label", ui->useVarList->item(i, 1)->text()); opt.setAttribute("output", "true"); ret.appendChild(opt); } for (int i = 0; i < ui->defaultVarList->rowCount(); ++i) { QDomElement opt = ret.createElement("variable"); opt.setAttribute("id", ui->defaultVarList->item(i, 0)->text()); opt.setAttribute("select", ui->defaultVarList->item(i, 0)->text()); opt.setAttribute("label", ui->defaultVarList->item(i, 1)->text()); opt.setAttribute("output", "false"); ret.appendChild(opt); } return ret; } void VisualTableField::setXml(QDomElement node) { if(node.text() != "empty") { for (QDomElement opt = node; !opt.isNull(); opt = opt.nextSiblingElement("variable")) { if(opt.attribute("output") == "true") { QTableWidgetItem* label = new QTableWidgetItem (opt.attribute("label")); QTableWidgetItem* id = new QTableWidgetItem (opt.attribute("id")); int currentRowCount = ui->useVarList->rowCount(); ui->useVarList->insertRow(currentRowCount); ui->useVarList->setItem(currentRowCount, 1, label); ui->useVarList->setItem(currentRowCount, 0, id); } else { QTableWidgetItem* label = new QTableWidgetItem (opt.attribute("label")); QTableWidgetItem* id = new QTableWidgetItem (opt.attribute("id")); int currentRowCount = ui->defaultVarList->rowCount(); ui->defaultVarList->insertRow(currentRowCount); ui->defaultVarList->setItem(currentRowCount, 1, label); ui->defaultVarList->setItem(currentRowCount, 0, id); } } } } void VisualTableField::offField( bool enable) { onField(enable); } void VisualTableField::onField(bool editable) { ui->selectDefault->setChecked(false); ui->selectUse->setChecked(false); ui->selectDefault->setEnabled(editable); ui->selectUse->setEnabled(editable); ui->lButton->setEnabled(editable); ui->rButton->setEnabled(editable); ui->useVarList->setEnabled(editable); ui->defaultVarList->setEnabled(editable); } void VisualTableField::setEditMode(bool enable) { if(!enable) { ui->defaultVarList->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->useVarList->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->labelGeneral->setText(tr("Variables that will not be used:")); ui->labelToBeUse->setText(tr("Variables that will be used:")); ui->upperLabel->setText(tr("Pick variables that you want to use.")); } ui->add->setVisible(enable); ui->del->setVisible(enable); if (enable) { ui->container->setToolTip("Default value"); ui->horizontalLayout->setStretch(ui->horizontalLayout->indexOf(ui->container), 0); } else { ui->container->setToolTip(""); ui->horizontalLayout->setStretch(ui->horizontalLayout->indexOf(ui->container), 5); } } QString VisualTableField::genLua() { QString ret = ""; if(ui->useVarList->rowCount() == 0) return "false"; for (int i = 0; i < ui->useVarList->rowCount(); ++i) { ret.append(ui->useVarList->item(i, 0)->text() + ","); } ret.remove(ret.size() - 1, 1); return ret; } QString VisualTableField::genR() { QString ret = ""; if(ui->useVarList->rowCount() == 0) return "FALSE"; for (int i = 0; i < ui->useVarList->rowCount(); ++i) { ret.append(ui->useVarList->item(i, 0)->text() + ","); } ret.remove(ret.size() - 1, 1); return ret; } void VisualTableField::updateMenu() { actionVariable->setChecked(type == Variable); } void VisualTableField::setWidget(QWidget* widget) { delete this->widget; this->widget = widget; widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); widget->setMinimumWidth(160); widget->setMaximumWidth(160); ui->container->layout()->addWidget(widget); ui->container->layout()->setAlignment(widget, Qt::AlignLeft); // setTabOrder(ui->userLabel, widget); updateMenu(); } void VisualTableField::onActionVariable() { type = Variable; emit changeType("Variable"); } void VisualTableField::onActionClone() { emit clone(); } void VisualTableField::onActionDelete() { int opt = QMessageBox::question(this, tr("Remove Field"), tr("This action will remove this field. Do you want to continue?"), QMessageBox::Yes | QMessageBox::No); if(opt == QMessageBox::Yes) { emit remove(); } }
33.867925
112
0.668858
ufopleds
025dd581b3240e10ca8f965a3f533f4d625d2ee8
1,715
cpp
C++
aula15092020/turma.cpp
brashi/imd0030_t03_2020
91ad4e4510e35573703be685c24d999d3db2a4bd
[ "MIT" ]
2
2020-09-28T05:50:07.000Z
2020-11-30T20:39:00.000Z
aula15092020/turma.cpp
brashi/imd0030_t03_2020
91ad4e4510e35573703be685c24d999d3db2a4bd
[ "MIT" ]
null
null
null
aula15092020/turma.cpp
brashi/imd0030_t03_2020
91ad4e4510e35573703be685c24d999d3db2a4bd
[ "MIT" ]
3
2020-09-28T05:50:10.000Z
2020-11-03T23:27:07.000Z
#include <iostream> #include "turma.hpp" using namespace std; string Turma::getNome(){ return this->nome; } void Turma::setNome(string nome){ this->nome = nome; } string Turma::getId(){ return this->id; } void Turma::setId(string id){ this->id = id; } void Turma::listarAlunos(){ for (int i = 0; i < this->capacidade; ++i) { cout << alunos[i]->getNome() << endl; } } void Turma::addAluno(Aluno* novo){ if (capacidade < CAPACIDADE_MAX) { alunos[capacidade++] = novo; } } void Turma::removePeloNome(string nome){ bool encontrou = false; for (int i = 0; i < this->capacidade; ++i) { if (this->alunos[i]->getNome() == nome) { // É o aluno a ser removido da turma Aluno* tmp = alunos[i]; alunos[i] = alunos[i+1]; alunos[i+1] = tmp; encontrou = true; } } if (encontrou==true) { delete alunos[this->capacidade]; this->capacidade--; } } void Turma::removePeloCpf(string cpf){ bool encontrou = false; for (int i = 0; i < this->capacidade; ++i) { if (this->alunos[i]->getCpf() == cpf) { // É o aluno a ser removido da turma Aluno* tmp = alunos[i]; alunos[i] = alunos[i+1]; alunos[i+1] = tmp; encontrou = true; } } if (encontrou==true) { delete alunos[this->capacidade]; this->capacidade--; } } void Turma::removePeloEmail(string email){ bool encontrou = false; for (int i = 0; i < this->capacidade; ++i) { if (this->alunos[i]->getEmail() == email) { // É o aluno a ser removido da turma Aluno* tmp = alunos[i]; alunos[i] = alunos[i+1]; alunos[i+1] = tmp; encontrou = true; } } if (encontrou==true) { delete alunos[this->capacidade]; this->capacidade--; } } int Turma::getCapacidade(){ return this->capacidade; }
18.44086
45
0.616327
brashi
0261e68e4101668f1a82aef4d393d250eb66190d
3,668
cpp
C++
src/main.cpp
seudonym/Path-Tracing-Renderer
ba0b183eaaa05416745ab06efcf641cf37c6c75f
[ "MIT" ]
null
null
null
src/main.cpp
seudonym/Path-Tracing-Renderer
ba0b183eaaa05416745ab06efcf641cf37c6c75f
[ "MIT" ]
null
null
null
src/main.cpp
seudonym/Path-Tracing-Renderer
ba0b183eaaa05416745ab06efcf641cf37c6c75f
[ "MIT" ]
null
null
null
#include <iostream> #include "common.hpp" // ##### Path-Tracing ##### vec3 ortho(vec3 v) { return normalize( glm::abs(v.x) > glm::abs(v.z) ? vec3(-v.y, v.x, 0.0f) : vec3(0.0f, -v.z, v.y) ); } // Weighted Cosine Sampling vec3 cosine_weighted_sample() { vec2 z = rand2(); vec2 r = vec2( 2.0f * pi * z.x, glm::sqrt(z.y) ); return vec3( r.y * vec2( glm::cos(r.x), glm::sin(r.x) ), glm::sqrt(1.0f - r.y * r.y) ); } // Lambertian Probability Distribution Function float PDF(vec3 wi, vec3 wo) { return glm::max(wi.z, 0.000001f) * inverse_pi; } // Lambertian Bidirectional Reflectance Distribution Function vec3 BRDF(vec3 wi, vec3 wo) { return vec3(0.8f) * inverse_pi; } vec3 radiance(vec3 ro, vec3 rd) { vec3 rayPos = ro; vec3 rayDir = rd; vec3 attenuation = vec3(1); for(unsigned int bounces = 0; bounces < MAX_BOUNCES; bounces++) { raycast raycast_data = trace(rayPos, rayDir); if(raycast_data.expire) { break; } if(!raycast_data.hit) { return sky_radiance(rayDir) * attenuation; } rayPos += rayDir * (raycast_data.tMin - HIT_DIST); vec3 t = ortho(raycast_data.normal); vec3 b = cross(t, raycast_data.normal); mat3 surf2world = mat3(t, b, raycast_data.normal); mat3 world2surf = transpose(surf2world); vec3 wi = cosine_weighted_sample(); vec3 wo = world2surf * -rayDir; // loicvdb's magic wisdom go brrr attenuation *= BRDF(wi, wo) / PDF(wi, wo) * glm::max(wi.z, 0.0f); rayDir = surf2world * wi; } return vec3(-1); } // Blackman-Harris Pixel Filter vec2 pixel_filter(vec2 pixel_coord) { // https://en.wikipedia.org/wiki/Window_function#Blackman–Harris_window // w[n] = a0-a1*cos(2*pi*n/N)+a2*cos(4*pi*n/N)-a3*cos(6*pi*n/N) // a0 = 0.35875; a1 = 0.48829; a2 = 0.14128; a3 = 0.01168; const float a0 = 0.35875f; const float a1 = 0.48829f; const float a2 = 0.14128f; const float a3 = 0.01168f; //float n = 0.5f * random_float() + 0.5f; float n = random_float(); float w = a0 - a1 * glm::cos(2.0f * pi * n) + a2 * glm::cos(4.0f * pi * n) - a3 * glm::cos(6.0f * pi * n); return pixel_coord + (2.0f * udir2() * w); } // ##### Main ##### int main() { const unsigned int RENDER_SIZE_X = 640; const unsigned int RENDER_SIZE_Y = 480; const vec2 resolution = vec2(RENDER_SIZE_X, RENDER_SIZE_Y); std::cout << "Initializing..." << std::endl; image_buffer render_buffer; render_buffer.allocate(RENDER_SIZE_X, RENDER_SIZE_Y); std::cout << "Starting Render..." << std::endl; uvec2 pixel_coord; for(pixel_coord.x = 0; pixel_coord.x < RENDER_SIZE_X; pixel_coord.x++) { for(pixel_coord.y = 0; pixel_coord.y < RENDER_SIZE_Y; pixel_coord.y++) { vec3 color = vec3(0); unsigned int samples = 0; for(unsigned int i = 0; i < MAX_SAMPLES; i++) { init_rng( (i)*(RENDER_SIZE_X*RENDER_SIZE_Y)+(pixel_coord.x + pixel_coord.y * RENDER_SIZE_X) ); vec2 uv = 2.0f * ( ( pixel_filter( vec2(pixel_coord) ) - ( 0.5f * vec2(resolution) ) ) / glm::max(resolution.x, resolution.y) ); vec3 ro = vec3(0.0f, 0.0f, 4.0f); vec3 rd = normalize( vec3(CAMERA_FOV * uv, -1) ); vec3 c = radiance(ro, rd); if(c.r >= 0.0f && c.g >= 0.0f && c.b >= 0.0f) { color += radiance(ro, rd); samples++; } } color = samples != 0 ? color / float(samples) : color; color = clamp(1.0f - glm::exp(-glm::max(color, 0.0f) * EXPOSURE), 0.0f, 1.0f); render_buffer.buffer[pixel_coord.x + ( ( (RENDER_SIZE_Y - 1) - pixel_coord.y ) * RENDER_SIZE_X )] = color; } } std::cout << "Writing Render to Disk..." << std::endl; write_frame(render_buffer, 0); std::cout << "Cleaning Up..." << std::endl; render_buffer.cleanup(); std::cout << "Done!" << std::endl; return EXIT_SUCCESS; }
24.453333
131
0.634951
seudonym
0262c4d0e4e941ce97c3160cef98d65590699094
35,403
cpp
C++
apps/openmw/mwgui/mapwindow.cpp
Bodillium/openmw
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
[ "Unlicense" ]
null
null
null
apps/openmw/mwgui/mapwindow.cpp
Bodillium/openmw
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
[ "Unlicense" ]
null
null
null
apps/openmw/mwgui/mapwindow.cpp
Bodillium/openmw
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
[ "Unlicense" ]
null
null
null
#include "mapwindow.hpp" #include <boost/lexical_cast.hpp> #include <OgreSceneNode.h> #include <OgreVector2.h> #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwworld/player.hpp" #include "../mwworld/cellstore.hpp" #include "../mwrender/globalmap.hpp" #include "../components/esm/globalmap.hpp" #include "widgets.hpp" #include "confirmationdialog.hpp" namespace { const int widgetSize = 512; const int cellSize = 8192; enum LocalMapWidgetDepth { Local_CompassLayer = 0, Local_MarkerAboveFogLayer = 1, Local_FogLayer = 2, Local_MarkerLayer = 3, Local_MapLayer = 4 }; enum GlobalMapWidgetDepth { Global_CompassLayer = 0, Global_MarkerLayer = 1, Global_ExploreOverlayLayer = 2, Global_MapLayer = 3 }; /// @brief A widget that changes its color when hovered. class MarkerWidget: public MyGUI::Widget { MYGUI_RTTI_DERIVED(MarkerWidget) public: void setNormalColour(const MyGUI::Colour& colour) { mNormalColour = colour; setColour(colour); } void setHoverColour(const MyGUI::Colour& colour) { mHoverColour = colour; } private: MyGUI::Colour mNormalColour; MyGUI::Colour mHoverColour; void onMouseLostFocus(MyGUI::Widget* _new) { setColour(mNormalColour); } void onMouseSetFocus(MyGUI::Widget* _old) { setColour(mHoverColour); } }; } namespace MWGui { void CustomMarker::save(ESM::ESMWriter &esm) const { esm.writeHNT("POSX", mWorldX); esm.writeHNT("POSY", mWorldY); mCell.save(esm); if (!mNote.empty()) esm.writeHNString("NOTE", mNote); } void CustomMarker::load(ESM::ESMReader &esm) { esm.getHNT(mWorldX, "POSX"); esm.getHNT(mWorldY, "POSY"); mCell.load(esm); mNote = esm.getHNOString("NOTE"); } // ------------------------------------------------------ void CustomMarkerCollection::addMarker(const CustomMarker &marker, bool triggerEvent) { mMarkers.push_back(marker); if (triggerEvent) eventMarkersChanged(); } void CustomMarkerCollection::deleteMarker(const CustomMarker &marker) { std::vector<CustomMarker>::iterator it = std::find(mMarkers.begin(), mMarkers.end(), marker); if (it != mMarkers.end()) mMarkers.erase(it); else throw std::runtime_error("can't find marker to delete"); eventMarkersChanged(); } void CustomMarkerCollection::updateMarker(const CustomMarker &marker, const std::string &newNote) { std::vector<CustomMarker>::iterator it = std::find(mMarkers.begin(), mMarkers.end(), marker); if (it != mMarkers.end()) it->mNote = newNote; else throw std::runtime_error("can't find marker to update"); eventMarkersChanged(); } void CustomMarkerCollection::clear() { mMarkers.clear(); eventMarkersChanged(); } std::vector<CustomMarker>::const_iterator CustomMarkerCollection::begin() const { return mMarkers.begin(); } std::vector<CustomMarker>::const_iterator CustomMarkerCollection::end() const { return mMarkers.end(); } size_t CustomMarkerCollection::size() const { return mMarkers.size(); } // ------------------------------------------------------ LocalMapBase::LocalMapBase(CustomMarkerCollection &markers) : mCurX(0) , mCurY(0) , mInterior(false) , mFogOfWar(true) , mLocalMap(NULL) , mPrefix() , mChanged(true) , mLastDirectionX(0.0f) , mLastDirectionY(0.0f) , mCompass(NULL) , mMarkerUpdateTimer(0.0f) , mCustomMarkers(markers) { mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers); } LocalMapBase::~LocalMapBase() { mCustomMarkers.eventMarkersChanged -= MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers); } void LocalMapBase::init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass) { mLocalMap = widget; mCompass = compass; mCompass->setDepth(Local_CompassLayer); mCompass->setNeedMouseFocus(false); // create 3x3 map widgets, 512x512 each, holding a 1024x1024 texture each for (int mx=0; mx<3; ++mx) { for (int my=0; my<3; ++my) { MyGUI::ImageBox* map = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); map->setDepth(Local_MapLayer); MyGUI::ImageBox* fog = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); fog->setDepth(Local_FogLayer); map->setNeedMouseFocus(false); fog->setNeedMouseFocus(false); mMapWidgets.push_back(map); mFogWidgets.push_back(fog); } } } void LocalMapBase::setCellPrefix(const std::string& prefix) { mPrefix = prefix; mChanged = true; } bool LocalMapBase::toggleFogOfWar() { mFogOfWar = !mFogOfWar; applyFogOfWar(); return mFogOfWar; } void LocalMapBase::applyFogOfWar() { for (int mx=0; mx<3; ++mx) { for (int my=0; my<3; ++my) { std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_" + boost::lexical_cast<std::string>(mCurY + (-1*(my-1))); MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx]; fog->setImageTexture(mFogOfWar ? ((MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) ? image+"_fog" : "black.png" ) : ""); } } redraw(); } MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerPosition& markerPos) { MyGUI::IntPoint widgetPos; // normalized cell coordinates float nX,nY; markerPos.interior = mInterior; if (!mInterior) { int cellX, cellY; MWBase::Environment::get().getWorld()->positionToIndex(worldX, worldY, cellX, cellY); nX = (worldX - cellSize * cellX) / cellSize; // Image space is -Y up, cells are Y up nY = 1 - (worldY - cellSize * cellY) / cellSize; float cellDx = cellX - mCurX; float cellDy = cellY - mCurY; markerPos.cellX = cellX; markerPos.cellY = cellY; widgetPos = MyGUI::IntPoint(nX * widgetSize + (1+cellDx) * widgetSize, nY * widgetSize - (cellDy-1) * widgetSize); } else { int cellX, cellY; Ogre::Vector2 worldPos (worldX, worldY); MWBase::Environment::get().getWorld ()->worldToInteriorMapPosition (worldPos, nX, nY, cellX, cellY); markerPos.cellX = cellX; markerPos.cellY = cellY; // Image space is -Y up, cells are Y up widgetPos = MyGUI::IntPoint(nX * widgetSize + (1+(cellX-mCurX)) * widgetSize, nY * widgetSize + (1-(cellY-mCurY)) * widgetSize); } markerPos.nX = nX; markerPos.nY = nY; return widgetPos; } void LocalMapBase::updateCustomMarkers() { for (std::vector<MyGUI::Widget*>::iterator it = mCustomMarkerWidgets.begin(); it != mCustomMarkerWidgets.end(); ++it) MyGUI::Gui::getInstance().destroyWidget(*it); mCustomMarkerWidgets.clear(); for (std::vector<CustomMarker>::const_iterator it = mCustomMarkers.begin(); it != mCustomMarkers.end(); ++it) { const CustomMarker& marker = *it; if (marker.mCell.mPaged != !mInterior) continue; if (mInterior) { if (marker.mCell.mWorldspace != mPrefix) continue; } else { if (std::abs(marker.mCell.mIndex.mX - mCurX) > 1) continue; if (std::abs(marker.mCell.mIndex.mY - mCurY) > 1) continue; } MarkerPosition markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); MarkerWidget* markerWidget = mLocalMap->createWidget<MarkerWidget>("MarkerButton", widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); markerWidget->setNormalColour(MyGUI::Colour(1.0,0.3,0.3)); markerWidget->setHoverColour(MyGUI::Colour(1.0,0.5,0.5)); markerWidget->setUserData(marker); markerWidget->setNeedMouseFocus(true); customMarkerCreated(markerWidget); mCustomMarkerWidgets.push_back(markerWidget); } redraw(); } void LocalMapBase::setActiveCell(const int x, const int y, bool interior) { if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell mCurX = x; mCurY = y; mInterior = interior; mChanged = false; applyFogOfWar(); // clear all previous door markers for (std::vector<MyGUI::Widget*>::iterator it = mDoorMarkerWidgets.begin(); it != mDoorMarkerWidgets.end(); ++it) MyGUI::Gui::getInstance().destroyWidget(*it); mDoorMarkerWidgets.clear(); // Update the map textures for (int mx=0; mx<3; ++mx) { for (int my=0; my<3; ++my) { // map std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_" + boost::lexical_cast<std::string>(y + (-1*(my-1))); MyGUI::ImageBox* box = mMapWidgets[my + 3*mx]; if (MyGUI::RenderManager::getInstance().getTexture(image) != 0) box->setImageTexture(image); else box->setImageTexture("black.png"); } } MWBase::World* world = MWBase::Environment::get().getWorld(); // Retrieve the door markers we want to show std::vector<MWBase::World::DoorMarker> doors; if (interior) { MWWorld::CellStore* cell = world->getInterior (mPrefix); world->getDoorMarkers(cell, doors); } else { for (int dX=-1; dX<2; ++dX) { for (int dY=-1; dY<2; ++dY) { MWWorld::CellStore* cell = world->getExterior (mCurX+dX, mCurY+dY); world->getDoorMarkers(cell, doors); } } } // Create a widget for each marker int counter = 0; for (std::vector<MWBase::World::DoorMarker>::iterator it = doors.begin(); it != doors.end(); ++it) { MWBase::World::DoorMarker marker = *it; MarkerPosition markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(marker.x, marker.y, markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); ++counter; MarkerWidget* markerWidget = mLocalMap->createWidget<MarkerWidget>("MarkerButton", widgetCoord, MyGUI::Align::Default); markerWidget->setNormalColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}"))); markerWidget->setDepth(Local_MarkerLayer); markerWidget->setNeedMouseFocus(true); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", marker.name); // Used by tooltips to not show the tooltip if marker is hidden by fog of war markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); doorMarkerCreated(markerWidget); mDoorMarkerWidgets.push_back(markerWidget); } updateMagicMarkers(); updateCustomMarkers(); } void LocalMapBase::redraw() { // Redraw children in proper order mLocalMap->getParent()->_updateChilds(); } void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny) { MyGUI::IntPoint pos(widgetSize+nx*widgetSize-16, widgetSize+ny*widgetSize-16); pos.left += (cellX - mCurX) * widgetSize; pos.top -= (cellY - mCurY) * widgetSize; if (pos != mCompass->getPosition()) { notifyPlayerUpdate (); mCompass->setPosition(pos); MyGUI::IntPoint middle (pos.left+16, pos.top+16); MyGUI::IntCoord viewsize = mLocalMap->getCoord(); MyGUI::IntPoint viewOffset(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); mLocalMap->setViewOffset(viewOffset); } } void LocalMapBase::setPlayerDir(const float x, const float y) { if (x == mLastDirectionX && y == mLastDirectionY) return; notifyPlayerUpdate (); MyGUI::ISubWidget* main = mCompass->getSubWidgetMain(); MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>(); rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); float angle = std::atan2(x,y); rotatingSubskin->setAngle(angle); mLastDirectionX = x; mLastDirectionY = y; } void LocalMapBase::addDetectionMarkers(int type) { std::vector<MWWorld::Ptr> markers; MWBase::World* world = MWBase::Environment::get().getWorld(); world->listDetectedReferences( world->getPlayerPtr(), markers, MWBase::World::DetectionType(type)); if (markers.empty()) return; std::string markerTexture; MyGUI::Colour markerColour; if (type == MWBase::World::Detect_Creature) { markerTexture = "textures\\menu_map_dcreature.dds"; markerColour = MyGUI::Colour(1,0,0,1); } if (type == MWBase::World::Detect_Key) { markerTexture = "textures\\menu_map_dkey.dds"; markerColour = MyGUI::Colour(0,1,0,1); } if (type == MWBase::World::Detect_Enchantment) { markerTexture = "textures\\menu_map_dmagic.dds"; markerColour = MyGUI::Colour(0,0,1,1); } int counter = 0; for (std::vector<MWWorld::Ptr>::iterator it = markers.begin(); it != markers.end(); ++it) { const ESM::Position& worldPos = it->getRefData().getPosition(); MarkerPosition markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); ++counter; MyGUI::ImageBox* markerWidget = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture(markerTexture); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); markerWidget->setColour(markerColour); mMagicMarkerWidgets.push_back(markerWidget); } } void LocalMapBase::onFrame(float dt) { mMarkerUpdateTimer += dt; if (mMarkerUpdateTimer >= 0.25) { mMarkerUpdateTimer = 0; updateMagicMarkers(); } } void LocalMapBase::updateMagicMarkers() { // clear all previous markers for (std::vector<MyGUI::Widget*>::iterator it = mMagicMarkerWidgets.begin(); it != mMagicMarkerWidgets.end(); ++it) MyGUI::Gui::getInstance().destroyWidget(*it); mMagicMarkerWidgets.clear(); addDetectionMarkers(MWBase::World::Detect_Creature); addDetectionMarkers(MWBase::World::Detect_Key); addDetectionMarkers(MWBase::World::Detect_Enchantment); // Add marker for the spot marked with Mark magic effect MWWorld::CellStore* markedCell = NULL; ESM::Position markedPosition; MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); if (markedCell && markedCell->isExterior() == !mInterior && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix))) { MarkerPosition markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); MyGUI::ImageBox* markerWidget = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture("textures\\menu_map_smark.dds"); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); mMagicMarkerWidgets.push_back(markerWidget); } redraw(); } // ------------------------------------------------------------------------------------------ MapWindow::MapWindow(CustomMarkerCollection &customMarkers, DragAndDrop* drag, const std::string& cacheDir) : WindowPinnableBase("openmw_map_window.layout") , NoDrop(drag, mMainWidget) , LocalMapBase(customMarkers) , mGlobal(false) , mGlobalMap(0) , mGlobalMapRender(0) , mEditNoteDialog() , mEventBoxGlobal(NULL) , mEventBoxLocal(NULL) , mGlobalMapImage(NULL) , mGlobalMapOverlay(NULL) { static bool registered = false; if (!registered) { MyGUI::FactoryManager::getInstance().registerFactory<MarkerWidget>("Widget"); registered = true; } mEditNoteDialog.setVisible(false); mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk); mEditNoteDialog.eventDeleteClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditDelete); setCoord(500,0,320,300); getWidget(mLocalMap, "LocalMap"); getWidget(mGlobalMap, "GlobalMap"); getWidget(mGlobalMapImage, "GlobalMapImage"); getWidget(mGlobalMapOverlay, "GlobalMapOverlay"); getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); mPlayerArrowGlobal->setDepth(Global_CompassLayer); mPlayerArrowGlobal->setNeedMouseFocus(false); mGlobalMapImage->setDepth(Global_MapLayer); mGlobalMapOverlay->setDepth(Global_ExploreOverlayLayer); mLastScrollWindowCoordinates = mLocalMap->getCoord(); mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeScrollWindowCoord); mGlobalMap->setVisible (false); getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); mButton->setCaptionWithReplacing("#{sWorld}"); getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer); getWidget(mEventBoxLocal, "EventBoxLocal"); mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); LocalMapBase::init(mLocalMap, mPlayerArrowLocal); } void MapWindow::onNoteEditOk() { if (mEditNoteDialog.getDeleteButtonShown()) mCustomMarkers.updateMarker(mEditingMarker, mEditNoteDialog.getText()); else { mEditingMarker.mNote = mEditNoteDialog.getText(); mCustomMarkers.addMarker(mEditingMarker); } mEditNoteDialog.setVisible(false); } void MapWindow::onNoteEditDelete() { ConfirmationDialog* confirmation = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); confirmation->open("#{sDeleteNote}", "#{sYes}", "#{sNo}"); confirmation->eventCancelClicked.clear(); confirmation->eventOkClicked.clear(); confirmation->eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditDeleteConfirm); } void MapWindow::onNoteEditDeleteConfirm() { mCustomMarkers.deleteMarker(mEditingMarker); mEditNoteDialog.setVisible(false); } void MapWindow::onCustomMarkerDoubleClicked(MyGUI::Widget *sender) { mEditingMarker = *sender->getUserData<CustomMarker>(); mEditNoteDialog.setText(mEditingMarker.mNote); mEditNoteDialog.showDeleteButton(true); mEditNoteDialog.setVisible(true); } void MapWindow::onMapDoubleClicked(MyGUI::Widget *sender) { MyGUI::IntPoint clickedPos = MyGUI::InputManager::getInstance().getMousePosition(); MyGUI::IntPoint widgetPos = clickedPos - mEventBoxLocal->getAbsolutePosition(); int x = int(widgetPos.left/float(widgetSize))-1; int y = (int(widgetPos.top/float(widgetSize))-1)*-1; float nX = widgetPos.left/float(widgetSize) - int(widgetPos.left/float(widgetSize)); float nY = widgetPos.top/float(widgetSize) - int(widgetPos.top/float(widgetSize)); x += mCurX; y += mCurY; Ogre::Vector2 worldPos; if (mInterior) { worldPos = MWBase::Environment::get().getWorld()->interiorMapToWorldPosition(nX, nY, x, y); } else { worldPos.x = (x + nX) * cellSize; worldPos.y = (y + (1.0-nY)) * cellSize; } mEditingMarker.mWorldX = worldPos.x; mEditingMarker.mWorldY = worldPos.y; mEditingMarker.mCell.mPaged = !mInterior; if (mInterior) mEditingMarker.mCell.mWorldspace = LocalMapBase::mPrefix; else { mEditingMarker.mCell.mWorldspace = "sys::default"; mEditingMarker.mCell.mIndex.mX = x; mEditingMarker.mCell.mIndex.mY = y; } mEditNoteDialog.setVisible(true); mEditNoteDialog.showDeleteButton(false); mEditNoteDialog.setText(""); } void MapWindow::onChangeScrollWindowCoord(MyGUI::Widget* sender) { MyGUI::IntCoord currentCoordinates = sender->getCoord(); MyGUI::IntPoint currentViewPortCenter = MyGUI::IntPoint(currentCoordinates.width / 2, currentCoordinates.height / 2); MyGUI::IntPoint lastViewPortCenter = MyGUI::IntPoint(mLastScrollWindowCoordinates.width / 2, mLastScrollWindowCoordinates.height / 2); MyGUI::IntPoint viewPortCenterDiff = currentViewPortCenter - lastViewPortCenter; mLocalMap->setViewOffset(mLocalMap->getViewOffset() + viewPortCenterDiff); mGlobalMap->setViewOffset(mGlobalMap->getViewOffset() + viewPortCenterDiff); mLastScrollWindowCoordinates = currentCoordinates; } void MapWindow::renderGlobalMap(Loading::Listener* loadingListener) { mGlobalMapRender = new MWRender::GlobalMap(""); mGlobalMapRender->render(loadingListener); mGlobalMap->setCanvasSize (mGlobalMapRender->getWidth(), mGlobalMapRender->getHeight()); mGlobalMapImage->setSize(mGlobalMapRender->getWidth(), mGlobalMapRender->getHeight()); mGlobalMapImage->setImageTexture("GlobalMap.png"); mGlobalMapOverlay->setImageTexture("GlobalMapOverlay"); } MapWindow::~MapWindow() { delete mGlobalMapRender; } void MapWindow::setCellName(const std::string& cellName) { setTitle("#{sCell=" + cellName + "}"); } void MapWindow::addVisitedLocation(const std::string& name, int x, int y) { CellId cell; cell.first = x; cell.second = y; if (mMarkers.insert(cell).second) { float worldX, worldY; mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); int markerSize = 12; int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; MyGUI::IntCoord widgetCoord( worldX * mGlobalMapRender->getWidth()+offset, worldY * mGlobalMapRender->getHeight()+offset, markerSize, markerSize); MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton", widgetCoord, MyGUI::Align::Default); markerWidget->setNeedMouseFocus(true); markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", name); markerWidget->setDepth(Global_MarkerLayer); markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); } } void MapWindow::cellExplored(int x, int y) { mQueuedToExplore.push_back(std::make_pair(x,y)); } void MapWindow::onFrame(float dt) { LocalMapBase::onFrame(dt); for (std::vector<CellId>::iterator it = mQueuedToExplore.begin(); it != mQueuedToExplore.end(); ++it) { mGlobalMapRender->exploreCell(it->first, it->second); } mQueuedToExplore.clear(); NoDrop::onFrame(dt); } void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; mLastDragPos = MyGUI::IntPoint(_left, _top); } void MapWindow::onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos; if (!mGlobal) mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff ); else mGlobalMap->setViewOffset( mGlobalMap->getViewOffset() + diff ); mLastDragPos = MyGUI::IntPoint(_left, _top); } void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender) { mGlobal = !mGlobal; mGlobalMap->setVisible(mGlobal); mLocalMap->setVisible(!mGlobal); mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); if (mGlobal) globalMapUpdatePlayer (); } void MapWindow::onPinToggled() { MWBase::Environment::get().getWindowManager()->setMinimapVisibility(!mPinned); } void MapWindow::onTitleDoubleClicked() { if (!mPinned) MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Map); } void MapWindow::open() { globalMapUpdatePlayer(); } void MapWindow::globalMapUpdatePlayer () { // For interiors, position is set by WindowManager via setGlobalMapPlayerPosition if (MWBase::Environment::get().getWorld ()->isCellExterior ()) { Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayerPtr().getRefData ().getBaseNode ()->_getDerivedPosition (); float worldX, worldY; mGlobalMapRender->worldPosToImageSpace (pos.x, pos.y, worldX, worldY); worldX *= mGlobalMapRender->getWidth(); worldY *= mGlobalMapRender->getHeight(); mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(worldX - 16, worldY - 16)); // set the view offset so that player is in the center MyGUI::IntSize viewsize = mGlobalMap->getSize(); MyGUI::IntPoint viewoffs(0.5*viewsize.width - worldX, 0.5*viewsize.height - worldY); mGlobalMap->setViewOffset(viewoffs); } } void MapWindow::notifyPlayerUpdate () { globalMapUpdatePlayer (); } void MapWindow::setGlobalMapPlayerPosition(float worldX, float worldY) { float x, y; mGlobalMapRender->worldPosToImageSpace (worldX, worldY, x, y); x *= mGlobalMapRender->getWidth(); y *= mGlobalMapRender->getHeight(); mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(x - 16, y - 16)); // set the view offset so that player is in the center MyGUI::IntSize viewsize = mGlobalMap->getSize(); MyGUI::IntPoint viewoffs(0.5*viewsize.width - x, 0.5*viewsize.height - y); mGlobalMap->setViewOffset(viewoffs); } void MapWindow::setGlobalMapPlayerDir(const float x, const float y) { MyGUI::ISubWidget* main = mPlayerArrowGlobal->getSubWidgetMain(); MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>(); rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); float angle = std::atan2(x,y); rotatingSubskin->setAngle(angle); } void MapWindow::clear() { mMarkers.clear(); mGlobalMapRender->clear(); mChanged = true; while (mEventBoxGlobal->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mEventBoxGlobal->getChildAt(0)); } void MapWindow::write(ESM::ESMWriter &writer, Loading::Listener& progress) { ESM::GlobalMap map; mGlobalMapRender->write(map); map.mMarkers = mMarkers; writer.startRecord(ESM::REC_GMAP); map.save(writer); writer.endRecord(ESM::REC_GMAP); progress.increaseProgress(); } void MapWindow::readRecord(ESM::ESMReader &reader, int32_t type) { if (type == ESM::REC_GMAP) { ESM::GlobalMap map; map.load(reader); mGlobalMapRender->read(map); for (std::set<ESM::GlobalMap::CellId>::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) { const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(it->first, it->second); if (cell && !cell->mName.empty()) addVisitedLocation(cell->mName, it->first, it->second); } } } void MapWindow::setAlpha(float alpha) { NoDrop::setAlpha(alpha); // can't allow showing map with partial transparency, as the fog of war will also go transparent // and reveal parts of the map you shouldn't be able to see for (std::vector<MyGUI::ImageBox*>::iterator it = mMapWidgets.begin(); it != mMapWidgets.end(); ++it) (*it)->setVisible(alpha == 1); } void MapWindow::customMarkerCreated(MyGUI::Widget *marker) { marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); marker->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onCustomMarkerDoubleClicked); } void MapWindow::doorMarkerCreated(MyGUI::Widget *marker) { marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); } // ------------------------------------------------------------------- EditNoteDialog::EditNoteDialog() : WindowModal("openmw_edit_note.layout") { getWidget(mOkButton, "OkButton"); getWidget(mCancelButton, "CancelButton"); getWidget(mDeleteButton, "DeleteButton"); getWidget(mTextEdit, "TextEdit"); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditNoteDialog::onCancelButtonClicked); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditNoteDialog::onOkButtonClicked); mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditNoteDialog::onDeleteButtonClicked); } void EditNoteDialog::showDeleteButton(bool show) { mDeleteButton->setVisible(show); } bool EditNoteDialog::getDeleteButtonShown() { return mDeleteButton->getVisible(); } void EditNoteDialog::setText(const std::string &text) { mTextEdit->setCaption(MyGUI::TextIterator::toTagsString(text)); } std::string EditNoteDialog::getText() { return MyGUI::TextIterator::getOnlyText(mTextEdit->getCaption()); } void EditNoteDialog::open() { WindowModal::open(); center(); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit); } void EditNoteDialog::exit() { setVisible(false); } void EditNoteDialog::onCancelButtonClicked(MyGUI::Widget *sender) { setVisible(false); } void EditNoteDialog::onOkButtonClicked(MyGUI::Widget *sender) { eventOkClicked(); } void EditNoteDialog::onDeleteButtonClicked(MyGUI::Widget *sender) { eventDeleteClicked(); } }
35.261952
143
0.598819
Bodillium
0267fe539b2a69faf045b2ed8d9c355cd706f591
16,299
cpp
C++
Tests/DataGenerators/SyntheticGenerators/OutliersDetector.cpp
H2020-InFuse/cdff
e55fd48f9a909d0c274c3dfa4fe2704bc5071542
[ "BSD-2-Clause" ]
7
2019-02-26T15:09:50.000Z
2021-09-30T07:39:01.000Z
Tests/DataGenerators/SyntheticGenerators/OutliersDetector.cpp
H2020-InFuse/cdff
e55fd48f9a909d0c274c3dfa4fe2704bc5071542
[ "BSD-2-Clause" ]
null
null
null
Tests/DataGenerators/SyntheticGenerators/OutliersDetector.cpp
H2020-InFuse/cdff
e55fd48f9a909d0c274c3dfa4fe2704bc5071542
[ "BSD-2-Clause" ]
1
2020-12-06T12:09:05.000Z
2020-12-06T12:09:05.000Z
/* -------------------------------------------------------------------------- * * (C) Copyright … * * --------------------------------------------------------------------------- */ /*! * @file OutliersDetector.cpp * @date 14/05/2018 * @author Alessandro Bianco */ /*! * @addtogroup DataGenerators * * Implementation of the OutliersDetector class. * * * @{ */ /* -------------------------------------------------------------------------- * * Includes * * -------------------------------------------------------------------------- */ #include "OutliersDetector.hpp" #include <stdlib.h> #include <time.h> #include <ctime> #include <Errors/Assert.hpp> #include <boost/make_shared.hpp> #define DELETE_IF_NOT_NULL(pointer) \ if (pointer != NULL) \ { \ delete(pointer); \ } namespace DataGenerators { /* -------------------------------------------------------------------------- * * Public Member Functions * * -------------------------------------------------------------------------- */ OutliersDetector::OutliersDetector(std::string inputCloudFilePath, std::string outliersFilePath) : originalCloud(new pcl::PointCloud<pcl::PointXYZ>), outliersCloud(new pcl::PointCloud<pcl::PointXYZRGB>), visualizer(new pcl::visualization::PCLVisualizer("Outliers Detector")) { this->inputCloudFilePath = inputCloudFilePath; this->outliersFilePath = outliersFilePath; LoadCloud(); LoadOutliers(); visualizer->registerKeyboardCallback(OutliersDetector::KeyboardButtonCallback, this); visualizer->registerPointPickingCallback(OutliersDetector::PointPickingCallback, this); pointCloudColorHandler = boost::make_shared<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> >(outliersCloud); visualizer->addPointCloud< pcl::PointXYZRGB >(outliersCloud, *pointCloudColorHandler, "outliersCloud"); detectorIsActive = true; cloudChangedSinceLastVisualization = true; focusChangedSinceLastVisualization = true; outliersBoxActive = false; } OutliersDetector::~OutliersDetector() { visualizer->close(); } void OutliersDetector::Run() { while(detectorIsActive && !visualizer->wasStopped()) { if (cloudChangedSinceLastVisualization) { std::lock_guard<std::mutex> guard(inputMutex); if (focusChangedSinceLastVisualization) { PrepareCloudToVisualize(); } DrawOutliers(); cloudChangedSinceLastVisualization = false; } visualizer->spinOnce(100); } } /* -------------------------------------------------------------------------- * * Private Member Variables * * -------------------------------------------------------------------------- */ const std::vector<cv::Scalar> OutliersDetector::COLORS_LIST = { cv::Scalar(0, 0, 255), cv::Scalar(0, 255, 0), cv::Scalar(255, 0, 0), cv::Scalar(0, 255, 255), cv::Scalar(255, 255, 0), cv::Scalar(255, 0, 255), cv::Scalar(128, 128, 255), cv::Scalar(128, 255, 128), cv::Scalar(255, 128, 128), cv::Scalar(128, 255, 255), cv::Scalar(255, 255, 128), cv::Scalar(255, 128, 255), cv::Scalar(0, 0, 128), cv::Scalar(0, 128, 0), cv::Scalar(128, 0, 0), cv::Scalar(0, 128, 128), cv::Scalar(128, 128, 0), cv::Scalar(128, 0, 128) }; /* -------------------------------------------------------------------------- * * Private Member Functions * * -------------------------------------------------------------------------- */ #define PRINT_CLOUD_LOCATION_INFO(location, center, radius) \ { \ std::stringstream locationStream; \ locationStream << location << " Center: (" << center.x << ", " << center.y << ", " << center.z << ") 3D Radius: " << radius; \ PRINT_TO_LOG(locationStream.str(), ""); \ } void OutliersDetector::LoadCloud() { pcl::io::loadPLYFile(inputCloudFilePath, *originalCloud); originalCloudSearchTree.setInputCloud(originalCloud); PRINT_TO_LOG("Number of points in source cloud: ", (originalCloud->points.size()) ); ComputeCloudCenter(originalCloud, visualizationCenter); visualizationRadius = ComputeCloudRadius(originalCloud, visualizationCenter) / 10; visualizationCircleSize = ComputeMinimumDistanceBetweenPoints(originalCloud); PRINT_TO_LOG("Minimum keypoint distance:", visualizationCircleSize); PRINT_CLOUD_LOCATION_INFO("Center-Radius:", visualizationCenter, visualizationRadius); } void OutliersDetector::PointPickingCallback(const pcl::visualization::PointPickingEvent& event, void* userdata) { ((OutliersDetector*)userdata)->PointPickingCallback(event); } void OutliersDetector::PointPickingCallback(const pcl::visualization::PointPickingEvent& event) { std::lock_guard<std::mutex> guard(inputMutex); int32_t pointIndex = event.getPointIndex(); if(pointIndex == -1) { return; } int32_t originalPointIndex = visualizedIndicesList.at(pointIndex); float x, y, z; event.getPoint(x,y,z); //Looking for the point index by mean of coordinates bool found = false; for(int pointIndexr = 0; pointIndexr < outliersCloud->points.size() && !found; pointIndexr++) { pcl::PointXYZRGB point = outliersCloud->points.at(pointIndexr); if ( point.x <= x + 0.0001 && point.x >= x - 0.0001 && point.y <= y + 0.0001 && point.y >= y - 0.0001 && point.z <= z + 0.0001 && point.z >= z - 0.0001) { found = true; int32_t verifyIndex = visualizedIndicesList.at(pointIndexr); ASSERT(verifyIndex == originalPointIndex, "The point does not match the visualization"); } } //Sometimes the point is not found. Is it a bug of PCL? In that case we ignore the input. if (!found) { return; } if (outliersBoxActive) { outliersBox.push_back(originalPointIndex); } else { outliersVector.push_back(originalPointIndex); } cloudChangedSinceLastVisualization = true; } void OutliersDetector::KeyboardButtonCallback(const pcl::visualization::KeyboardEvent& event, void* userdata) { ((OutliersDetector*)userdata)->KeyboardButtonCallback(event); } void OutliersDetector::KeyboardButtonCallback(const pcl::visualization::KeyboardEvent& event) { std::lock_guard<std::mutex> guard(inputMutex); if (!event.keyDown()) { return; } unsigned command = static_cast<unsigned>( event.getKeyCode() ); if (command == 17) //Ctrl+Q { detectorIsActive = false; } else if (command == 14) //Ctrl+N { if (outliersBoxActive && outliersBox.size() > 0) { outliersBox.pop_back(); cloudChangedSinceLastVisualization = true; } else if (!outliersBoxActive && outliersVector.size() > 0) { outliersVector.pop_back(); cloudChangedSinceLastVisualization = true; } return; } else if (command == 13) //Ctrl+M { SaveOutliers(); PRINT_TO_LOG("Data Saved", ""); } else if (command == 23) //Ctrl+W { visualizationCenter.y += visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 24) //Ctrl+X { visualizationCenter.y -= visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 1) //Ctrl+A { visualizationCenter.x -= visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 4) //Ctrl+D { visualizationCenter.x += visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 5) //Ctrl+E { visualizationCenter.z += visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 26) //Ctrl+Z { visualizationCenter.z -= visualizationRadius/2; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 15) //Ctrl+O { visualizationRadius = visualizationRadius * 1.5; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 16) //Ctrl+P { visualizationRadius = visualizationRadius / 1.5; focusChangedSinceLastVisualization = true; cloudChangedSinceLastVisualization = true; PRINT_CLOUD_LOCATION_INFO("Source", visualizationCenter, visualizationRadius); } else if (command == 6) // Ctrl+F { outliersBoxActive = true; outliersBox.clear(); PRINT_TO_LOG("Box selection is active", ""); } else if (command == 7) // Ctrl+G { std::vector<int32_t> addedOutliersList = ComputeOutliersBoxClosure(); outliersVector.insert(outliersVector.end(), addedOutliersList.begin(), addedOutliersList.end()); outliersBoxActive = false; cloudChangedSinceLastVisualization = true; outliersBox.clear(); PRINT_TO_LOG("Box selection is no longer active", ""); } else if (command == 2) //Ctrl+B { SaveOutliersAsPointCloud(); PRINT_TO_LOG("Data Saved", ""); } } #define COPY_WHITE_POINT(origin, center, displacementX, destination) \ { \ destination.x = origin.x - center.x + displacementX; \ destination.y = origin.y - center.y; \ destination.z = origin.z - center.z; \ destination.r = 255; \ destination.g = 255; \ destination.b = 255; \ } #define COPY_COLOR(point, color) \ { \ point.r = color[0]; \ point.g = color[1]; \ point.b = color[2]; \ } void OutliersDetector::PrepareCloudToVisualize() { std::vector<float> squaredDistancesVector; visualizedIndicesList.clear(); originalCloudSearchTree.radiusSearch(visualizationCenter, visualizationRadius, visualizedIndicesList, squaredDistancesVector); outliersCloud->points.resize(visualizedIndicesList.size()); focusChangedSinceLastVisualization = false; } void OutliersDetector::DrawOutliers() { const cv::Scalar& color = COLORS_LIST.at(2); const cv::Scalar& boxColor = COLORS_LIST.at(3); std::vector<int32_t> boxClosure = ComputeOutliersBoxClosure(); for(int32_t visualizedPointIndex = 0; visualizedPointIndex < visualizedIndicesList.size(); visualizedPointIndex++) { int32_t pointIndex = visualizedIndicesList.at(visualizedPointIndex); pcl::PointXYZ& point = originalCloud->points.at(pointIndex); pcl::PointXYZRGB& visualizedPoint = outliersCloud->points.at(visualizedPointIndex); COPY_WHITE_POINT(point, visualizationCenter, 0, visualizedPoint); if (std::find(outliersVector.begin(), outliersVector.end(), pointIndex) != outliersVector.end()) { COPY_COLOR(visualizedPoint, color); } if (std::find(boxClosure.begin(), boxClosure.end(), pointIndex) != boxClosure.end()) { COPY_COLOR(visualizedPoint, boxColor); } } pointCloudColorHandler = boost::make_shared<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> >(outliersCloud); visualizer->updatePointCloud< pcl::PointXYZRGB >(outliersCloud, *pointCloudColorHandler, "outliersCloud"); } void OutliersDetector::SaveOutliersAsPointCloud() { pcl::PointCloud<pcl::PointXYZ>::Ptr pclCloud(new pcl::PointCloud<pcl::PointXYZ>); for(int outlierIndex = 0; outlierIndex < outliersVector.size(); outlierIndex++) { int32_t pointIndex = outliersVector.at(outlierIndex); pcl::PointXYZ newPoint = originalCloud->points.at(pointIndex); pclCloud->points.push_back(newPoint); } std::stringstream outputFilePathStream; outputFilePathStream << outliersFilePath.substr(0, outliersFilePath.size()-4) << ".ply"; pcl::PLYWriter writer; writer.write(outputFilePathStream.str(), *pclCloud, true); } void OutliersDetector::SaveOutliers() { cv::Mat outliersMatrix(outliersVector.size(), 1, CV_32SC1); for(int outlierIndex = 0; outlierIndex < outliersVector.size(); outlierIndex++) { outliersMatrix.at<int32_t>(outlierIndex, 0) = outliersVector.at(outlierIndex); } cv::FileStorage opencvFile(outliersFilePath, cv::FileStorage::WRITE); opencvFile << "OutliersMatrix" << outliersMatrix; opencvFile.release(); } void OutliersDetector::LoadOutliers() { cv::Mat outliersMatrix; try { cv::FileStorage opencvFile(outliersFilePath, cv::FileStorage::READ); opencvFile["OutliersMatrix"] >> outliersMatrix; opencvFile.release(); } catch (...) { //If reading fails, just overwrite the file. return; } ASSERT( (outliersMatrix.rows == 0 || (outliersMatrix.type() == CV_32SC1 && outliersMatrix.cols == 1)), "Error in loaded file, invalid format"); for(int outlierIndex = 0; outlierIndex < outliersVector.size(); outlierIndex++) { int32_t outlier = outliersMatrix.at<int32_t>(outlierIndex, 0); outliersVector.push_back(outlier); } } void OutliersDetector::ComputeCloudCenter(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud, pcl::PointXYZ& center) { center.x = 0; center.y = 0; center.z = 0; for(int32_t pointIndex = 0; pointIndex < cloud->points.size(); pointIndex++) { const pcl::PointXYZ& point = cloud->points.at(pointIndex); center.x += point.x; center.y += point.y; center.z += point.z; } center.x = (center.x / (float) cloud->points.size()); center.y = (center.y / (float) cloud->points.size()); center.z = (center.z / (float) cloud->points.size()); } float OutliersDetector::ComputeCloudRadius(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud, const pcl::PointXYZ& center) { float radius = 0; for(int32_t pointIndex = 0; pointIndex < cloud->points.size(); pointIndex++) { const pcl::PointXYZ& point = cloud->points.at(pointIndex); float differenceX = point.x - center.x; float differenceY = point.y - center.y; float differenceZ = point.z - center.z; float distance = std::sqrt( differenceX*differenceX + differenceY*differenceY + differenceZ*differenceZ); if (distance > radius) { radius = distance; } } return radius; } float OutliersDetector::ComputeMinimumDistanceBetweenPoints(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud) { float minimumDistance = -1; for(int32_t point1Index = 0; point1Index < cloud->points.size()-1; point1Index++) { const pcl::PointXYZ& point1 = cloud->points.at(point1Index); const pcl::PointXYZ& point2 = cloud->points.at(point1Index+1); float differenceX = point1.x - point2.x; float differenceY = point1.y - point2.y; float differenceZ = point1.z - point2.z; float distance = std::sqrt( differenceX*differenceX + differenceY*differenceY + differenceZ*differenceZ); if (minimumDistance < 0 || distance < minimumDistance) { minimumDistance = distance; } } return minimumDistance; } std::vector<int32_t> OutliersDetector::ComputeOutliersBoxClosure() { std::vector<int32_t> closure; if (outliersBox.size() == 0) { return closure; } float minX, maxX, minY, maxY, minZ, maxZ; ComputeBoxBorders(minX, maxX, minY, maxY, minZ, maxZ); for(int pointIndex = 0; pointIndex < originalCloud->points.size(); pointIndex++) { pcl::PointXYZ point = originalCloud->points.at(pointIndex); if ( minX <= point.x && point.x <= maxX && minY <= point.y && point.y <= maxY && minZ <= point.z && point.z <= maxZ) { int copyIndex = pointIndex; closure.push_back(copyIndex); } } return closure; } void OutliersDetector::ComputeBoxBorders(float& minX, float& maxX, float& minY, float& maxY, float& minZ, float& maxZ) { if (outliersBox.size() == 0) { return; } pcl::PointXYZ startPoint = originalCloud->points.at( outliersBox.at(0) ); minX = startPoint.x; maxX = startPoint.x; minY = startPoint.y; maxY = startPoint.y; minZ = startPoint.z; maxZ = startPoint.z; for(int outlierIndex = 1; outlierIndex < outliersBox.size(); outlierIndex++) { pcl::PointXYZ point = originalCloud->points.at( outliersBox.at(outlierIndex) ); if (minX > point.x) { minX = point.x; } if (maxX < point.x) { maxX = point.x; } if (minY > point.y) { minY = point.y; } if (maxY < point.y) { maxY = point.y; } if (minZ > point.z) { minZ = point.z; } if (maxZ < point.z) { maxZ = point.z; } } } } /** @} */
29.262118
154
0.681023
H2020-InFuse
027105b5e6bb0148ebad88ea8e75cce2828ad73e
475
cpp
C++
src/week-1/PutTheChairsTheRightWay/PutTheChairsTheRightWay.cpp
CarlosVRL/How-to-win-coding-competitions
e5a1b2aa656d7f7e39ce8436d9ccd3a9f88eb2a9
[ "MIT" ]
null
null
null
src/week-1/PutTheChairsTheRightWay/PutTheChairsTheRightWay.cpp
CarlosVRL/How-to-win-coding-competitions
e5a1b2aa656d7f7e39ce8436d9ccd3a9f88eb2a9
[ "MIT" ]
null
null
null
src/week-1/PutTheChairsTheRightWay/PutTheChairsTheRightWay.cpp
CarlosVRL/How-to-win-coding-competitions
e5a1b2aa656d7f7e39ce8436d9ccd3a9f88eb2a9
[ "MIT" ]
null
null
null
/** * Put the Chairs the Right Way! */ #include <fstream> #include <iomanip> using namespace std; /** * File Management */ ifstream fin("input.txt"); ofstream fout("output.txt"); /** * Constants */ const int DIVISOR = 6; /** * Main */ int main(void) { // Solution by mid-point theorem double a, b, c, res; fin >> a >> b >> c; res = (a + b + c) / DIVISOR; fout << setprecision(15) << res << endl; return EXIT_SUCCESS; }
13.194444
44
0.549474
CarlosVRL
0271c4af8783a53710f009fa2a7ed54848b414e0
9,291
cpp
C++
dali/internal/accessibility/tizen-wayland/atspi/bridge-collection.cpp
Coquinho/dali-adaptor
a8006aea66b316a5eb710e634db30f566acda144
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
dali/internal/accessibility/tizen-wayland/atspi/bridge-collection.cpp
Coquinho/dali-adaptor
a8006aea66b316a5eb710e634db30f566acda144
[ "Apache-2.0", "BSD-3-Clause" ]
2
2020-10-19T13:45:40.000Z
2020-12-10T20:21:03.000Z
dali/internal/accessibility/tizen-wayland/atspi/bridge-collection.cpp
expertisesolutions/dali-adaptor
810bf4dea833ea7dfbd2a0c82193bc0b3b155011
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ // CLASS HEADER #include <dali/internal/accessibility/tizen-wayland/atspi/bridge-collection.h> // EXTERNAL INCLUDES #include <algorithm> #include <iostream> #include <unordered_set> #include <vector> using namespace Dali::Accessibility; void BridgeCollection::RegisterInterfaces() { DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceCollection}; AddFunctionToInterface( desc, "GetMatches", &BridgeCollection::GetMatches ); dbusServer.addInterface( "/", desc, true ); } Collection* BridgeCollection::FindSelf() const { auto s = BridgeBase::FindSelf(); assert( s ); auto s2 = dynamic_cast< Collection* >( s ); if( !s2 ) throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Collection interface"}; return s2; } enum { ATSPI_Collection_MATCH_INVALID, ATSPI_Collection_MATCH_ALL, ATSPI_Collection_MATCH_ANY, ATSPI_Collection_MATCH_NONE, ATSPI_Collection_MATCH_EMPTY, ATSPI_Collection_MATCH_LAST_DEFINED, }; struct BridgeCollection::Comparer { using Mode = MatchType; enum class CompareFuncExit { FIRST_FOUND, FIRST_NOT_FOUND }; static Mode ConvertToMatchType( int32_t mode ) { switch( mode ) { case ATSPI_Collection_MATCH_INVALID: { return Mode::INVALID; } case ATSPI_Collection_MATCH_ALL: { return Mode::ALL; } case ATSPI_Collection_MATCH_ANY: { return Mode::ANY; } case ATSPI_Collection_MATCH_NONE: { return Mode::NONE; } case ATSPI_Collection_MATCH_EMPTY: { return Mode::EMPTY; } } return Mode::INVALID; } struct ComparerInterfaces { std::unordered_set< std::string > object; std::vector< std::string > requested; Mode mode = Mode::INVALID; ComparerInterfaces( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::InterfacesMatchType >( *rule ) ) ) { requested = {std::get< Index::Interfaces >( *rule ).begin(), std::get< Index::Interfaces >( *rule ).end()}; } void Update( Accessible* obj ) { object.clear(); for( auto& q : obj->GetInterfaces() ) object.insert( std::move( q ) ); } bool RequestEmpty() const { return requested.empty(); } bool ObjectEmpty() const { return object.empty(); } bool Compare( CompareFuncExit exit ) { bool foundAny = false; for( auto& iname : requested ) { bool found = ( object.find( iname ) != object.end() ); if( found ) foundAny = true; if( found == ( exit == CompareFuncExit::FIRST_FOUND ) ) return found; } return foundAny; } }; struct ComparerAttributes { std::unordered_map< std::string, std::string > requested, object; Mode mode = Mode::INVALID; ComparerAttributes( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::AttributesMatchType >( *rule ) ) ) { requested = std::get< Index::Attributes >( *rule ); } void Update( Accessible* obj ) { object = obj->GetAttributes(); } bool RequestEmpty() const { return requested.empty(); } bool ObjectEmpty() const { return object.empty(); } bool Compare( CompareFuncExit exit ) { bool foundAny = false; for( auto& iname : requested ) { auto it = object.find( iname.first ); bool found = it != object.end() && iname.second == it->second; if( found ) foundAny = true; if( found == ( exit == CompareFuncExit::FIRST_FOUND ) ) { return found; } } return foundAny; } }; struct ComparerRoles { using Roles = BitSets< 4, Role >; Roles requested, object; Mode mode = Mode::INVALID; ComparerRoles( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::RolesMatchType >( *rule ) ) ) { requested = Roles{std::get< Index::Roles >( *rule )}; } void Update( Accessible* obj ) { object = {}; object[obj->GetRole()] = true; assert( object ); } bool RequestEmpty() const { return !requested; } bool ObjectEmpty() const { return !object; } bool Compare( CompareFuncExit exit ) { switch( mode ) { case Mode::INVALID: { return true; } case Mode::EMPTY: case Mode::ALL: { return requested == ( object & requested ); } case Mode::ANY: { return bool( object & requested ); } case Mode::NONE: { return bool( object & requested ); } } return false; } }; struct ComparerStates { States requested, object; Mode mode = Mode::INVALID; ComparerStates( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::StatesMatchType >( *rule ) ) ) { requested = States{std::get< Index::States >( *rule )}; } void Update( Accessible* obj ) { object = obj->GetStates(); } bool RequestEmpty() const { return !requested; } bool ObjectEmpty() const { return !object; } bool Compare( CompareFuncExit exit ) { switch( mode ) { case Mode::INVALID: { return true; } case Mode::EMPTY: case Mode::ALL: { return requested == ( object & requested ); } case Mode::ANY: { return bool( object & requested ); } case Mode::NONE: { return bool( object & requested ); } } return false; } }; template < typename T > bool compareFunc( T& cmp, Accessible* obj ) { if( cmp.mode == Mode::INVALID ) return true; cmp.Update( obj ); switch( cmp.mode ) { case Mode::ANY: { if( cmp.RequestEmpty() || cmp.ObjectEmpty() ) return false; break; } case Mode::ALL: { if( cmp.RequestEmpty() ) return true; if( cmp.ObjectEmpty() ) return false; break; } case Mode::NONE: { if( cmp.RequestEmpty() || cmp.ObjectEmpty() ) return true; break; } case Mode::EMPTY: { if( cmp.RequestEmpty() && cmp.ObjectEmpty() ) return true; if( cmp.RequestEmpty() || cmp.ObjectEmpty() ) return false; break; } case Mode::INVALID: { return true; } } switch( cmp.mode ) { case Mode::EMPTY: case Mode::ALL: { if( !cmp.Compare( CompareFuncExit::FIRST_NOT_FOUND ) ) return false; break; } case Mode::ANY: { if( cmp.Compare( CompareFuncExit::FIRST_FOUND ) ) return true; break; } case Mode::NONE: { if( cmp.Compare( CompareFuncExit::FIRST_FOUND ) ) return false; break; } case Mode::INVALID: { return true; } } switch( cmp.mode ) { case Mode::EMPTY: case Mode::ALL: case Mode::NONE: { return true; } case Mode::ANY: { return false; } case Mode::INVALID: { return true; } } return false; } ComparerInterfaces ci; ComparerAttributes ca; ComparerRoles cr; ComparerStates cs; Comparer( MatchRule* mr ) : ci( mr ), ca( mr ), cr( mr ), cs( mr ) {} bool operator()( Accessible* obj ) { return compareFunc( ci, obj ) && compareFunc( ca, obj ) && compareFunc( cr, obj ) && compareFunc( cs, obj ); } }; void BridgeCollection::VisitNodes( Accessible* obj, std::vector< Accessible* >& result, Comparer& cmp, size_t maxCount ) { if( result.size() >= maxCount ) return; if( cmp( obj ) ) result.emplace_back( obj ); for( auto i = 0u; i < obj->GetChildCount(); ++i ) VisitNodes( obj->GetChildAtIndex( i ), result, cmp, maxCount ); } DBus::ValueOrError< std::vector< Accessible* > > BridgeCollection::GetMatches( MatchRule rule, uint32_t sortBy, int32_t count, bool traverse ) { std::vector< Accessible* > res; auto self = BridgeBase::FindSelf(); auto matcher = Comparer{&rule}; VisitNodes( self, res, matcher, count ); switch( static_cast< SortOrder >( sortBy ) ) { case SortOrder::CANONICAL: { break; } case SortOrder::REVERSE_CANONICAL: { std::reverse( res.begin(), res.end() ); break; } default: { throw std::domain_error{"unsupported sorting order"}; } //TODO: other cases } return res; }
24.007752
142
0.575396
Coquinho
0278070adaf7b0fc95a4b86304006b473f0fe696
2,122
cpp
C++
RayEngine/Source/Linux/LinuxSensorsImpl.cpp
Mumsfilibaba/RayEngine
68496966c1d7b91bc8fbdd305226ece9b9f596b2
[ "Apache-2.0" ]
null
null
null
RayEngine/Source/Linux/LinuxSensorsImpl.cpp
Mumsfilibaba/RayEngine
68496966c1d7b91bc8fbdd305226ece9b9f596b2
[ "Apache-2.0" ]
null
null
null
RayEngine/Source/Linux/LinuxSensorsImpl.cpp
Mumsfilibaba/RayEngine
68496966c1d7b91bc8fbdd305226ece9b9f596b2
[ "Apache-2.0" ]
null
null
null
/*//////////////////////////////////////////////////////////// Copyright 2018 Alexander Dahlin 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 THIS SOFTWARE IS PROVIDED "AS IS". MEANING NO WARRANTY OR SUPPORT IS PROVIDED OF ANY KIND. In event of any damages, direct or indirect that can be traced back to the use of this software, shall no contributor be held liable. This includes computer failure and or malfunction of any kind. ////////////////////////////////////////////////////////////*/ #include "RayEngine.h" #include "../../Include/System/Sensors.h" #if defined(RE_PLATFORM_LINUX) namespace RayEngine { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Sensors::SensorSupported(SENSOR_TYPE sensor) { return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Sensors::SensorEnabled(SENSOR_TYPE sensor) { return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Sensors::EnableSensor(SENSOR_TYPE sensor) { return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Sensors::DisableSensor(SENSOR_TYPE sensor) { return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Sensors::SetRefreshRate(SENSOR_TYPE sensor, const TimeStamp& time) { return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SensorData Sensors::GetSensorValue(SENSOR_TYPE sensor) { return SensorData(); } } #endif
29.887324
126
0.404807
Mumsfilibaba
027a5f7de9c34ec37e8fcce403dd06cd092ae872
953
cpp
C++
src/pyclock.cpp
Maelic/libqi-python
d5e250a7ce1b6039bb1f57f750cab51412dfecca
[ "BSD-3-Clause" ]
7
2015-08-12T01:25:11.000Z
2021-07-15T11:08:34.000Z
src/pyclock.cpp
Maelic/libqi-python
d5e250a7ce1b6039bb1f57f750cab51412dfecca
[ "BSD-3-Clause" ]
10
2015-10-01T11:33:53.000Z
2022-03-23T10:19:33.000Z
src/pyclock.cpp
Maelic/libqi-python
d5e250a7ce1b6039bb1f57f750cab51412dfecca
[ "BSD-3-Clause" ]
7
2015-02-24T10:38:52.000Z
2022-03-14T10:18:26.000Z
/* ** Copyright (C) 2020 SoftBank Robotics Europe ** See COPYING for the license */ #include <qipython/pyclock.hpp> #include <qipython/common.hpp> #include <qi/clock.hpp> #include <pybind11/pybind11.h> namespace py = pybind11; namespace qi { namespace py { namespace { template<typename Clock> typename Clock::rep now() { return Clock::now().time_since_epoch().count(); } } // namespace void exportClock(::py::module& m) { using namespace ::py; using namespace ::py::literals; gil_scoped_acquire lock; m.def("clockNow", &now<Clock>, doc(":returns: current timestamp on qi::Clock, as a number of nanoseconds")); m.def("steadyClockNow", &now<SteadyClock>, doc(":returns: current timestamp on qi::SteadyClock, as a number of nanoseconds")); m.def("systemClockNow", &now<SystemClock>, doc(":returns: current timestamp on qi::SystemClock, as a number of nanoseconds")); } } // namespace py } // namespace qi
20.717391
91
0.690451
Maelic
027a70908b176daf768a629215c7bdc17a465655
4,310
cxx
C++
Modules/Applications/AppImageUtils/app/otbSynthetize.cxx
heralex/OTB
c52b504b64dc89c8fe9cac8af39b8067ca2c3a57
[ "Apache-2.0" ]
317
2015-01-19T08:40:58.000Z
2022-03-17T11:55:48.000Z
Modules/Applications/AppImageUtils/app/otbSynthetize.cxx
guandd/OTB
707ce4c6bb4c7186e3b102b2b00493a5050872cb
[ "Apache-2.0" ]
18
2015-07-29T14:13:45.000Z
2021-03-29T12:36:24.000Z
Modules/Applications/AppImageUtils/app/otbSynthetize.cxx
guandd/OTB
707ce4c6bb4c7186e3b102b2b00493a5050872cb
[ "Apache-2.0" ]
132
2015-02-21T23:57:25.000Z
2022-03-25T16:03:16.000Z
/* * Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "otbSynthetizeFilter.h" #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" #include "otbImageFileReader.h" #include <set> namespace otb { namespace Wrapper { /** * This application synthetizes/reduces multiple inputs into a single one. * In that particular case, for each output pixel, this application will * consider the corresponding pixels from all the input images, and keep the * first one that isn't equal to 0. * * This application is used to implement the _concatenate_ processing in * S1Tiling chain. * * \author Luc Hermitte (CS Group) * \copyright CNES * \todo find a better name for the application. Alas `otbConcatenate` is * already used... */ class Synthetize : public Application { public: using Self = Synthetize; using Pointer = itk::SmartPointer<Self>; itkNewMacro(Self); itkTypeMacro(Synthetize, otb::Wrapper::Application); private: using ReaderType = otb::ImageFileReader<FloatImageType>; void DoInit() override { SetName("Synthetize"); SetDescription("This is the Synthetize application"); SetDocLongDescription("Concatenate a list of images of the same size into a single single-channel image.\n\ It keeps the first non-null pixel value found in the input list."); SetDocLimitations("This application will break incoming pipelines."); SetDocAuthors("Luc Hermitte (CS Group)"); SetDocSeeAlso(""); AddDocTag(Tags::Manip); AddParameter(ParameterType_StringList, "il", "Input images list"); SetParameterDescription("il", "Input image list"); AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out","Output image."); AddRAMParameter(); SetDocExampleParameterValue("il", "s1a_33NWB_vv_DES_007_20200108t044150.tif s1a_33NWB_vv_DES_007_20200108t044215.tif"); SetDocExampleParameterValue("out", "s1a_33NWB_vv_DES_007_20200108txxxxxx.tif"); SetOfficialDocLink(); } void DoUpdateParameters() override {} void DoExecute() override { // Get the input image list auto inNameList = GetParameterStringList("il"); // checking the input images list validity auto const nbImages = inNameList.size(); if (nbImages == 0) { itkExceptionMacro("No input Image set...; please set at least one input image"); } auto functor = [](auto input) { assert(!input.empty()); auto const wh = std::find_if( input.begin(), input.end()-1, [](auto v){ return v != 0;}); return *wh; }; auto filter = MakeSynthetizeFilter<FloatImageType, FloatImageType>(functor); for (unsigned int i = 0; i < nbImages; i++) { // Given the explicit use of a Reader, this application cannot be used in // a in-memory pipeline auto reader = ReaderType::New(); // currentImage->SetExtendedFileName(inNameList[i]); reader->SetFileName(inNameList[i]); auto currentImage = reader->GetOutput(); currentImage->UpdateOutputInformation(); otbAppLogINFO(<< "Image #" << i + 1 << " has " << currentImage->GetNumberOfComponentsPerPixel() << " components"); filter->SetInput(i, currentImage); m_Cache.insert(reader); } SetParameterOutputImage("out", filter->GetOutput()); RegisterPipeline(); // TODO: check!! } // Needed to register the inputs handled manually // and not with a VectorImageList through GetParameterImageList std::set<ReaderType::Pointer> m_Cache; }; } // otb::Wrapper namespace } // otb namespace OTB_APPLICATION_EXPORT(otb::Wrapper::Synthetize)
31.231884
123
0.70348
heralex
027b508ad5b09750d7dfa01c659197890ea5ec44
1,151
cpp
C++
src/armnn/backends/NeonWorkloads/NeonSoftmaxFloat32Workload.cpp
KevinRodrigues05/armnn_caffe2_parser
c577f2c6a3b4ddb6ba87a882723c53a248afbeba
[ "MIT" ]
null
null
null
src/armnn/backends/NeonWorkloads/NeonSoftmaxFloat32Workload.cpp
KevinRodrigues05/armnn_caffe2_parser
c577f2c6a3b4ddb6ba87a882723c53a248afbeba
[ "MIT" ]
null
null
null
src/armnn/backends/NeonWorkloads/NeonSoftmaxFloat32Workload.cpp
KevinRodrigues05/armnn_caffe2_parser
c577f2c6a3b4ddb6ba87a882723c53a248afbeba
[ "MIT" ]
null
null
null
// // Copyright © 2017 Arm Ltd. All rights reserved. // See LICENSE file in the project root for full license information. // #include "NeonSoftmaxFloat32Workload.hpp" namespace armnn { NeonSoftmaxFloat32Workload::NeonSoftmaxFloat32Workload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) : FloatWorkload<SoftmaxQueueDescriptor>(descriptor, info) , m_SoftmaxLayer(memoryManager) { m_Data.ValidateInputsOutputs("NeonSoftmaxFloat32Workload", 1, 1); // The ArmCompute softmax layer uses 2D input/output tensors, so flatten the first three dimensions. arm_compute::ITensor& input = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); arm_compute::ITensor& output = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); m_SoftmaxLayer.configure(&input, &output, m_Data.m_Parameters.m_Beta); } void NeonSoftmaxFloat32Workload::Execute() const { ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxFloat32Workload_Execute"); m_SoftmaxLayer.run(); } } //namespace armnn
34.878788
117
0.78106
KevinRodrigues05
027bd872374b8b52a0a3a5e2f0f4a79624ed0d57
11,047
cpp
C++
fast-background/fast-background/hook.cpp
bobfast/fast
41460b9eba7b160a280fec221d704229d2681f74
[ "MIT" ]
1
2020-10-02T06:55:43.000Z
2020-10-02T06:55:43.000Z
fast-background/fast-background/hook.cpp
bobfast/fast
41460b9eba7b160a280fec221d704229d2681f74
[ "MIT" ]
3
2020-11-16T08:31:04.000Z
2021-09-02T18:51:32.000Z
fast-background/fast-background/hook.cpp
bobfast/fast
41460b9eba7b160a280fec221d704229d2681f74
[ "MIT" ]
null
null
null
#include "call_api.h" FILE* pFile; static UINT32 hook_cnt = 0; static HANDLE fm = NULL; static char* map_addr; static DWORD dwBufSize = 0; static DWORD thispid = GetCurrentProcessId(); static LPCSTR rpszDllsOut = NULL; #define NT_SUCCESS(x) ((x) >= 0) void init() { //Initialize the log file. time_t t = time(NULL); struct tm pLocal; localtime_s(&pLocal, &t); char buf[256]; sprintf_s(buf, "log-%04d-%02d-%02d-%02d-%02d-%02d.txt", pLocal.tm_year + 1900, pLocal.tm_mon + 1, pLocal.tm_mday, pLocal.tm_hour, pLocal.tm_min, pLocal.tm_sec); fopen_s(&pFile, buf, "w"); if (pFile == NULL) { exit(1); } fprintf(pFile, buf); fprintf(pFile, "\n#####Monitor Turned on.\n"); // Turn on the SeDebugPrivilege. TOKEN_PRIVILEGES tp; BOOL bResult = FALSE; HANDLE hToken = NULL; DWORD dwSize; ZeroMemory(&tp, sizeof(tp)); tp.PrivilegeCount = 1; if (OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken) && LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid)) { tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; bResult = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, &dwSize); } CloseHandle(hToken); ///////////////////////////////////////////////////////// // Getting the DLL's full path. LPCSTR rpszDllsRaw = (LPCSTR)"FAST-DLL.dll"; CHAR szDllPath[1024]; PCHAR pszFilePart = NULL; if (!GetFullPathNameA(rpszDllsRaw, ARRAYSIZE(szDllPath), szDllPath, &pszFilePart)) { return; } DWORD c = (DWORD)strlen(szDllPath) + 1; PCHAR psz = new CHAR[c]; StringCchCopyA(psz, c, szDllPath); rpszDllsOut = psz; ///////////////////////////////////////////////////////// // Making shared memory. dwBufSize = (DWORD)(strlen(rpszDllsOut) + 1) * sizeof(char); fm = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)((dwBufSize + sizeof(DWORD) + 13 * sizeof(DWORD64))), (LPCSTR)"fast-shared64"); map_addr = (char*)MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0); memcpy(map_addr, rpszDllsOut, dwBufSize); memcpy(map_addr + dwBufSize, &thispid, sizeof(DWORD)); LPVOID fp = CallVirtualAllocEx; memcpy(map_addr + dwBufSize + sizeof(DWORD), &fp, sizeof(DWORD64)); fp = CallQueueUserAPC; memcpy(map_addr + dwBufSize + sizeof(DWORD) + sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallWriteProcessMemory; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 2 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallCreateRemoteThread; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 3 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallNtMapViewOfSection; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 4 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallCreateFileMappingA; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 5 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallGetThreadContext; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 6 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallSetThreadContext; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 7 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallNtQueueApcThread; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 8 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallSetWindowLongPtrA; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 9 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallSetPropA; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 10 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallVirtualProtectEx; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 11 * sizeof(DWORD64), &fp, sizeof(DWORD64)); fp = CallSleepEx; memcpy(map_addr + dwBufSize + sizeof(DWORD) + 12 * sizeof(DWORD64), &fp, sizeof(DWORD64)); //Initial Hooking. //mon(0); } void exiting(unsigned int t_pid) { //UnHooking All. for (int i = 0; i < hook_cnt; i++) mon(1, t_pid); //Close Everything. UnmapViewOfFile(map_addr); CloseHandle(fm); fclose(pFile); } DWORD findPidByName(const char* pname) { HANDLE h; PROCESSENTRY32 procSnapshot; h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); procSnapshot.dwSize = sizeof(PROCESSENTRY32); do { if (!strcmp((const char*)procSnapshot.szExeFile, pname)) { DWORD pid = procSnapshot.th32ProcessID; CloseHandle(h); return pid; } } while (Process32Next(h, &procSnapshot)); CloseHandle(h); return 0; } void exe(char op , unsigned int t_pid) { char cmd[MSG_SIZE] = ""; sprintf_s(cmd, "/C InjDll64.exe %ud -%c FAST-DLL.dll", t_pid, op); printf("%s\n", cmd); HANDLE vh = ShellExecute(NULL, "open", "cmd.exe", cmd, ".", SW_NORMAL); //DWORD dwProcessId = findPidByName("explorer.exe"); //sprintf_s(cmd, "/C InjDll64.exe %ud -%c FAST-DLL.dll", dwProcessId, op); //printf("%s\n", cmd); // vh = ShellExecute(NULL, "open", "cmd.exe", cmd, ".", SW_NORMAL); //sprintf_s(cmd, "/C InjDll64.exe * -%c FAST-DLL.dll", op); //printf("%s\n", cmd); //vh = ShellExecute(NULL, "open", "cmd.exe", cmd, ".", SW_NORMAL); Sleep(500); //BOOL bShellExecute = FALSE; //SHELLEXECUTEINFO stShellInfo = { sizeof(SHELLEXECUTEINFO) }; //stShellInfo.lpVerb = TEXT("runas"); //stShellInfo.lpFile = TEXT("cmd.exe"); //stShellInfo.lpParameters = TEXT(cmd); //stShellInfo.nShow = SW_SHOWNORMAL; //bShellExecute = ShellExecuteEx(&stShellInfo); //WaitForSingleObject(stShellInfo.hProcess, INFINITE); } // Find injected 'FAST-DLL.dll' handle from monitored process. HMODULE findRemoteHModule(DWORD dwProcessId, const char* szdllout) { MODULEENTRY32 me = { sizeof(me) }; BOOL bMore = FALSE; HANDLE hSnapshot; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId); if (hSnapshot == (HANDLE)-1) { ; } bMore = Module32First(hSnapshot, &me); for (; bMore; bMore = Module32Next(hSnapshot, &me)) { if (!_tcsicmp((LPCTSTR)me.szExePath, szdllout)) { return (HMODULE)me.modBaseAddr; } } return NULL; } typedef NTSTATUS(NTAPI* pfnNtCreateThreadEx) ( OUT PHANDLE hThread, IN ACCESS_MASK DesiredAccess, IN PVOID ObjectAttributes, IN HANDLE ProcessHandle, IN PVOID lpStartAddress, IN PVOID lpParameter, IN ULONG Flags, IN SIZE_T StackZeroBits, IN SIZE_T SizeOfStackCommit, IN SIZE_T SizeOfStackReserve, OUT PVOID lpBytesBuffer); typedef struct _CLIENT_ID { HANDLE UniqueProcess; HANDLE UniqueThread; } CLIENT_ID, * PCLIENT_ID; typedef NTSTATUS(NTAPI* pfnRtlCreateUserThread)( IN HANDLE ProcessHandle, IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, IN BOOLEAN CreateSuspended, IN ULONG StackZeroBits OPTIONAL, IN SIZE_T StackReserve OPTIONAL, IN SIZE_T StackCommit OPTIONAL, IN PTHREAD_START_ROUTINE StartAddress, IN PVOID Parameter OPTIONAL, OUT PHANDLE ThreadHandle OPTIONAL, OUT PCLIENT_ID ClientId OPTIONAL); // main. // int CDECL mon(int isFree_, unsigned int t_pid) { // Hook/Unhook flag BOOLEAN isFree = (BOOLEAN)isFree_; ///////////////////////////////////////////////////////// Validate DLLs. (get the full path name.) HMODULE hDll = LoadLibraryExA(rpszDllsOut, NULL, DONT_RESOLVE_DLL_REFERENCES); if (hDll == NULL) { return 1; } ExportContext ec; ec.fHasOrdinal1 = FALSE; ec.nExports = 0; DetourEnumerateExports(hDll, &ec, ExportCallback); FreeLibrary(hDll); if (!ec.fHasOrdinal1) { return 1; } ///////////////////////////////////////////////////////// //HANDLE hProcess = NULL, hThread = NULL; //HMODULE hMod = NULL; //LPTHREAD_START_ROUTINE pThreadProc = NULL; //LPVOID lpMap = 0; //SIZE_T viewsize = 0; //PNtMapViewOfSection = (NTSTATUS(*)(HANDLE SectionHandle, HANDLE ProcessHandle, PVOID * BaseAddress, ULONG_PTR ZeroBits, SIZE_T CommitSize, PLARGE_INTEGER SectionOffset, PSIZE_T ViewSize, SECTION_INHERIT InheritDisposition, ULONG AllocationType, ULONG Win32Protect)) GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtMapViewOfSection"); //if (!PNtMapViewOfSection) //{ // printf("GetProcAddress(%ld) PNtMapViewOfSection failed!!! \n", GetLastError()); // return 1; //} //hMod = GetModuleHandleA("kernel32.dll"); //if (!hMod) //{ // printf("GetModuleHandleA(%ld) failed!!! \n", GetLastError()); // return 1; //} //if (!isFree) //{ // hook_cnt++; // fprintf(pFile, "Hook DLLs!\n"); // pThreadProc = (LPTHREAD_START_ROUTINE)GetProcAddress(hMod, "LoadLibraryA"); // if (!pThreadProc) // { // printf("GetProcAddress(%ld) LoadLibraryA failed!!! \n", GetLastError()); // return 1; // } //} //else //{ // if (hook_cnt > 0) // hook_cnt--; // fprintf(pFile, "UnHook DLLs!\n"); // pThreadProc = (LPTHREAD_START_ROUTINE)GetProcAddress(hMod, "FreeLibrary"); // if (!pThreadProc) // { // printf("GetProcAddress(%ld) FreeLibrary failed!!! \n", GetLastError()); // return 1; // } //} ///////////////////////////////////////////////////////// // Traversing the process list, inject the dll to processes. //HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //PROCESSENTRY32 entry = { sizeof(PROCESSENTRY32) }; //Process32First(hSnap, &entry); //do //{ // if (thispid == entry.th32ProcessID) // continue; // hProcess = OpenProcess(MAXIMUM_ALLOWED, FALSE, entry.th32ProcessID); // if (!(hProcess)) // { // printf("OpenProcess(%ld) failed!!! [%ld]\n", entry.th32ProcessID, GetLastError()); // continue; // } // printf("OpenProcess(%ld) Success!!! \n", entry.th32ProcessID); // PNtMapViewOfSection(fm, hProcess, &lpMap, 0, dwBufSize, // nullptr, &viewsize, ViewUnmap, 0, PAGE_READONLY); // pfnNtCreateThreadEx NtCreateThreadEx = (pfnNtCreateThreadEx)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtCreateThreadEx"); // //pfnRtlCreateUserThread RtlCreateUserThread = (pfnRtlCreateUserThread)GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCreateUserThread"); // if (!isFree) // { // NTSTATUS Status = NtCreateThreadEx(&hThread, 0x1FFFFF, NULL, hProcess, (LPTHREAD_START_ROUTINE)pThreadProc, lpMap, FALSE, NULL, NULL, NULL, NULL); // //NTSTATUS Status = RtlCreateUserThread(hProcess, NULL, FALSE, 0, 0, 0, pThreadProc, lpMap, &hThread, NULL); // if (!NT_SUCCESS(Status) || hThread == NULL) // { // printf("CreateRemoteThread(%ld) failed!!! [%ld]\n", entry.th32ProcessID, GetLastError()); // CloseHandle(hProcess); // continue; // } // } // else // { // HMODULE fdllpath = findRemoteHModule(entry.th32ProcessID, (const char*)rpszDllsOut); // if (fdllpath != NULL) // { // NTSTATUS Status = NtCreateThreadEx(&hThread, 0x1FFFFF, NULL, hProcess, (LPTHREAD_START_ROUTINE)pThreadProc, fdllpath, FALSE, NULL, NULL, NULL, NULL); // //NTSTATUS Status = RtlCreateUserThread(hProcess, NULL, FALSE, 0, 0, 0, pThreadProc, fdllpath, &hThread, NULL); // if (!NT_SUCCESS(Status) || hThread == NULL) // { // printf("CreateRemoteThread(%ld) failed!!! [%ld]\n", entry.th32ProcessID, GetLastError()); // CloseHandle(hProcess); // continue; // } // } // } // printf("CreateRemoteThread(%ld) Success!!! \n", entry.th32ProcessID); // CloseHandle(hThread); // hThread = NULL; // CloseHandle(hProcess); // hProcess = NULL; //} while (Process32Next(hSnap, &entry)); //CloseHandle(hSnap); if (!isFree) { exe('i', t_pid); } else { exe('e', t_pid); } return 0; }
25.810748
337
0.67421
bobfast
028643fe6641dcc026eb301d22d0937ec6e393d6
1,070
cpp
C++
Melone/Src/Melone/Renderer/Renderer.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
Melone/Src/Melone/Renderer/Renderer.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
Melone/Src/Melone/Renderer/Renderer.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
#include "mlpch.h" #include "Renderer.h" #include "Renderer2D.h" #include "Platform/OpenGL/OpenGLShader.h" namespace Melone { Renderer::SceneData* Renderer::mSceneData = new Renderer::SceneData; void Renderer::init(void) { RenderCommand::init(); Renderer2D::init(); } void Renderer::onWindowResize(const std::pair<unsigned int, unsigned int>& dimensions) { RenderCommand::setViewport(0, 0, dimensions.first, dimensions.second); } void Renderer::beginScene(OrthographicCamera& camera) { mSceneData->ViewProjectionMatrix = camera.getViewProjectionMatrix(); } void Renderer::endScene(void) { } void Renderer::submit(const std::shared_ptr<Shader>& shader, const std::shared_ptr<VAO>& VAO, const glm::mat4& transform) { shader->bind(); std::dynamic_pointer_cast<OpenGLShader>(shader)->setUniformMat4("uViewProjection", mSceneData->ViewProjectionMatrix); std::dynamic_pointer_cast<OpenGLShader>(shader)->setUniformMat4("uTransform", transform); VAO->bind(); RenderCommand::drawIndexed(VAO); } void Renderer::shutdown(void) { } }
23.26087
122
0.741121
Nightskies
028f936624616f615f6e294df203a3be3ecf395a
3,220
cpp
C++
source/MaterialXRuntime/Codegen/RtSourceCodeImpl.cpp
kohakukun/MaterialX
5b11321bfa096d20ebf60e00086bed97642d2fa8
[ "BSD-3-Clause" ]
null
null
null
source/MaterialXRuntime/Codegen/RtSourceCodeImpl.cpp
kohakukun/MaterialX
5b11321bfa096d20ebf60e00086bed97642d2fa8
[ "BSD-3-Clause" ]
null
null
null
source/MaterialXRuntime/Codegen/RtSourceCodeImpl.cpp
kohakukun/MaterialX
5b11321bfa096d20ebf60e00086bed97642d2fa8
[ "BSD-3-Clause" ]
null
null
null
// // TM & (c) 2020 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd. // All rights reserved. See LICENSE.txt for license. // #include <MaterialXRuntime/Codegen/RtSourceCodeImpl.h> #include <MaterialXRuntime/RtApi.h> #include <MaterialXRuntime/Identifiers.h> #include <MaterialXRuntime/Private/PvtPath.h> #include <MaterialXRuntime/Private/PvtPrim.h> #include <MaterialXFormat/Util.h> #include <MaterialXGenShader/ShaderGenerator.h> namespace MaterialX { DEFINE_TYPED_SCHEMA(RtSourceCodeImpl, "nodeimpl:sourcecodeimpl"); RtPrim RtSourceCodeImpl::createPrim(const RtIdentifier& typeName, const RtIdentifier& name, RtPrim parent) { PvtPrim::validateCreation(_typeInfo, typeName, name, parent.getPath()); static const RtIdentifier DEFAULT_NAME("sourcecodeimpl1"); const RtIdentifier primName = name == EMPTY_IDENTIFIER ? DEFAULT_NAME : name; PvtObjHandle primH = PvtPrim::createNew(&_typeInfo, primName, PvtObject::cast<PvtPrim>(parent)); return primH; } const RtPrimSpec& RtSourceCodeImpl::getPrimSpec() const { static const PvtPrimSpec s_primSpec; return s_primSpec; } void RtSourceCodeImpl::setFile(const string& file) { RtTypedValue* attr = prim()->createAttribute(Identifiers::FILE, RtType::STRING); attr->asString() = file; const FilePath path = RtApi::get().getSearchPath().find(file); string source = readFile(path); if (source.empty()) { throw ExceptionShaderGenError("Failed to get source code from file '" + path.asString() + "' used by implementation '" + getName().str() + "'"); } setSourceCode(source); } const string& RtSourceCodeImpl::getFile() const { RtTypedValue* attr = prim()->getAttribute(Identifiers::FILE, RtType::STRING); return attr ? attr->asString() : EMPTY_STRING; } void RtSourceCodeImpl::setSourceCode(const string& source) { RtTypedValue* attr = prim()->createAttribute(Identifiers::SOURCECODE, RtType::STRING); attr->asString() = source; } const string& RtSourceCodeImpl::getSourceCode() const { RtTypedValue* attr = prim()->getAttribute(Identifiers::SOURCECODE, RtType::STRING); return attr ? attr->asString() : EMPTY_STRING; } void RtSourceCodeImpl::setFormat(const RtIdentifier& format) { RtTypedValue* attr = prim()->createAttribute(Identifiers::FORMAT, RtType::IDENTIFIER); attr->asIdentifier() = format; } const RtIdentifier& RtSourceCodeImpl::getFormat() const { RtTypedValue* attr = prim()->getAttribute(Identifiers::FORMAT, RtType::IDENTIFIER); return attr ? attr->asIdentifier() : Identifiers::SHADER; } void RtSourceCodeImpl::setFunction(const string& source) { RtTypedValue* attr = prim()->createAttribute(Identifiers::FUNCTION, RtType::STRING); attr->asString() = source; } const string& RtSourceCodeImpl::getFunction() const { RtTypedValue* attr = prim()->getAttribute(Identifiers::FUNCTION, RtType::STRING); return attr ? attr->asString() : EMPTY_STRING; } void RtSourceCodeImpl::emitFunctionDefinition(const RtNode& /*node*/, GenContext& /*context*/, ShaderStage& /*stage*/) const { } void RtSourceCodeImpl::emitFunctionCall(const RtNode& /*node*/, GenContext& /*context*/, ShaderStage& /*stage*/) const { } }
30.961538
124
0.729814
kohakukun
0294c7b9a570dd08ab508ba543fbfa11de5b1524
24,264
hpp
C++
include/HMUI/SectionTableView.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
include/HMUI/SectionTableView.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
include/HMUI/SectionTableView.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: HMUI.TableView #include "HMUI/TableView.hpp" // Including type: HMUI.TableView/HMUI.IDataSource #include "HMUI/TableView_IDataSource.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "beatsaber-hook/shared/utils/utils.h" #include "beatsaber-hook/shared/utils/typedefs-array.hpp" // Completed includes // Begin forward declares // Forward declaring namespace: HMUI namespace HMUI { // Forward declaring type: TableCell class TableCell; } // Forward declaring namespace: System namespace System { // Forward declaring type: Action`3<T1, T2, T3> template<typename T1, typename T2, typename T3> class Action_3; // Forward declaring type: Action`2<T1, T2> template<typename T1, typename T2> class Action_2; } // Completed forward declares // Type namespace: HMUI namespace HMUI { // Forward declaring type: SectionTableView class SectionTableView; } #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(::HMUI::SectionTableView); DEFINE_IL2CPP_ARG_TYPE(::HMUI::SectionTableView*, "HMUI", "SectionTableView"); // Type namespace: HMUI namespace HMUI { // Size: 0xC8 #pragma pack(push, 1) // Autogenerated type: HMUI.SectionTableView // [TokenAttribute] Offset: FFFFFFFF class SectionTableView : public ::HMUI::TableView/*, public ::HMUI::TableView::IDataSource*/ { public: // Nested type: ::HMUI::SectionTableView::IDataSource class IDataSource; // Nested type: ::HMUI::SectionTableView::Section struct Section; // Size: 0xC #pragma pack(push, 1) // WARNING Layout: Sequential may not be correctly taken into account! // Autogenerated type: HMUI.SectionTableView/HMUI.Section // [TokenAttribute] Offset: FFFFFFFF struct Section/*, public ::System::ValueType*/ { public: public: // public System.Boolean unfolded // Size: 0x1 // Offset: 0x0 bool unfolded; // Field size check static_assert(sizeof(bool) == 0x1); // Padding between fields: unfolded and: startBaseRow char __padding0[0x3] = {}; // public System.Int32 startBaseRow // Size: 0x4 // Offset: 0x4 int startBaseRow; // Field size check static_assert(sizeof(int) == 0x4); // public System.Int32 numberOfBaseRows // Size: 0x4 // Offset: 0x8 int numberOfBaseRows; // Field size check static_assert(sizeof(int) == 0x4); public: // Creating value type constructor for type: Section constexpr Section(bool unfolded_ = {}, int startBaseRow_ = {}, int numberOfBaseRows_ = {}) noexcept : unfolded{unfolded_}, startBaseRow{startBaseRow_}, numberOfBaseRows{numberOfBaseRows_} {} // Creating interface conversion operator: operator ::System::ValueType operator ::System::ValueType() noexcept { return *reinterpret_cast<::System::ValueType*>(this); } // Get instance field reference: public System.Boolean unfolded bool& dyn_unfolded(); // Get instance field reference: public System.Int32 startBaseRow int& dyn_startBaseRow(); // Get instance field reference: public System.Int32 numberOfBaseRows int& dyn_numberOfBaseRows(); }; // HMUI.SectionTableView/HMUI.Section #pragma pack(pop) static check_size<sizeof(SectionTableView::Section), 8 + sizeof(int)> __HMUI_SectionTableView_SectionSizeCheck; static_assert(sizeof(SectionTableView::Section) == 0xC); #ifdef USE_CODEGEN_FIELDS public: #else #ifdef CODEGEN_FIELD_ACCESSIBILITY CODEGEN_FIELD_ACCESSIBILITY: #else protected: #endif #endif // private System.Boolean _unfoldSectionsByDefault // Size: 0x1 // Offset: 0xA2 bool unfoldSectionsByDefault; // Field size check static_assert(sizeof(bool) == 0x1); // Padding between fields: unfoldSectionsByDefault and: didSelectRowInSectionEvent char __padding0[0x5] = {}; // private System.Action`3<HMUI.SectionTableView,System.Int32,System.Int32> didSelectRowInSectionEvent // Size: 0x8 // Offset: 0xA8 ::System::Action_3<::HMUI::SectionTableView*, int, int>* didSelectRowInSectionEvent; // Field size check static_assert(sizeof(::System::Action_3<::HMUI::SectionTableView*, int, int>*) == 0x8); // private System.Action`2<HMUI.SectionTableView,System.Int32> didSelectHeaderEvent // Size: 0x8 // Offset: 0xB0 ::System::Action_2<::HMUI::SectionTableView*, int>* didSelectHeaderEvent; // Field size check static_assert(sizeof(::System::Action_2<::HMUI::SectionTableView*, int>*) == 0x8); // private HMUI.SectionTableView/HMUI.IDataSource _dataSource // Size: 0x8 // Offset: 0xB8 ::HMUI::SectionTableView::IDataSource* dataSource; // Field size check static_assert(sizeof(::HMUI::SectionTableView::IDataSource*) == 0x8); // private HMUI.SectionTableView/HMUI.Section[] _sections // Size: 0x8 // Offset: 0xC0 ::ArrayW<::HMUI::SectionTableView::Section> sections; // Field size check static_assert(sizeof(::ArrayW<::HMUI::SectionTableView::Section>) == 0x8); public: // Creating interface conversion operator: operator ::HMUI::TableView::IDataSource operator ::HMUI::TableView::IDataSource() noexcept { return *reinterpret_cast<::HMUI::TableView::IDataSource*>(this); } // Get instance field reference: private System.Boolean _unfoldSectionsByDefault bool& dyn__unfoldSectionsByDefault(); // Get instance field reference: private System.Action`3<HMUI.SectionTableView,System.Int32,System.Int32> didSelectRowInSectionEvent ::System::Action_3<::HMUI::SectionTableView*, int, int>*& dyn_didSelectRowInSectionEvent(); // Get instance field reference: private System.Action`2<HMUI.SectionTableView,System.Int32> didSelectHeaderEvent ::System::Action_2<::HMUI::SectionTableView*, int>*& dyn_didSelectHeaderEvent(); // Get instance field reference: private HMUI.SectionTableView/HMUI.IDataSource _dataSource ::HMUI::SectionTableView::IDataSource*& dyn__dataSource(); // Get instance field reference: private HMUI.SectionTableView/HMUI.Section[] _sections ::ArrayW<::HMUI::SectionTableView::Section>& dyn__sections(); // public HMUI.SectionTableView/HMUI.IDataSource get_dataSource() // Offset: 0x168B444 ::HMUI::SectionTableView::IDataSource* get_dataSource(); // public System.Void set_dataSource(HMUI.SectionTableView/HMUI.IDataSource value) // Offset: 0x168B44C void set_dataSource(::HMUI::SectionTableView::IDataSource* value); // public System.Void add_didSelectRowInSectionEvent(System.Action`3<HMUI.SectionTableView,System.Int32,System.Int32> value) // Offset: 0x168B1B4 void add_didSelectRowInSectionEvent(::System::Action_3<::HMUI::SectionTableView*, int, int>* value); // public System.Void remove_didSelectRowInSectionEvent(System.Action`3<HMUI.SectionTableView,System.Int32,System.Int32> value) // Offset: 0x168B258 void remove_didSelectRowInSectionEvent(::System::Action_3<::HMUI::SectionTableView*, int, int>* value); // public System.Void add_didSelectHeaderEvent(System.Action`2<HMUI.SectionTableView,System.Int32> value) // Offset: 0x168B2FC void add_didSelectHeaderEvent(::System::Action_2<::HMUI::SectionTableView*, int>* value); // public System.Void remove_didSelectHeaderEvent(System.Action`2<HMUI.SectionTableView,System.Int32> value) // Offset: 0x168B3A0 void remove_didSelectHeaderEvent(::System::Action_2<::HMUI::SectionTableView*, int>* value); // public System.Boolean IsSectionUnfolded(System.Int32 section) // Offset: 0x168B470 bool IsSectionUnfolded(int section); // public System.Single CellSize() // Offset: 0x168B4B0 float CellSize(); // public System.Int32 NumberOfCells() // Offset: 0x168B560 int NumberOfCells(); // public HMUI.TableCell CellForIdx(HMUI.TableView tableView, System.Int32 baseRow) // Offset: 0x168B5B0 ::HMUI::TableCell* CellForIdx(::HMUI::TableView* tableView, int baseRow); // public System.Void ReloadData(System.Boolean resetFoldState) // Offset: 0x168B858 void ReloadData(bool resetFoldState); // public System.Void UnfoldAllSections() // Offset: 0x168BE30 void UnfoldAllSections(); // public System.Void FoldAll() // Offset: 0x168BE90 void FoldAll(); // public System.Void UnfoldSection(System.Int32 section) // Offset: 0x168BEEC void UnfoldSection(int section); // public System.Void FoldSection(System.Int32 section) // Offset: 0x168C374 void FoldSection(int section); // public System.Void ScrollToRow(System.Int32 section, System.Int32 row, HMUI.TableView/HMUI.ScrollPositionType scrollPositionType, System.Boolean animated) // Offset: 0x168C75C void ScrollToRow(int section, int row, ::HMUI::TableView::ScrollPositionType scrollPositionType, bool animated); // public System.Void SectionAndRowForBaseRow(System.Int32 baseRow, out System.Int32 section, out System.Int32 row, out System.Boolean isSectionHeader) // Offset: 0x168B760 void SectionAndRowForBaseRow(int baseRow, ByRef<int> section, ByRef<int> row, ByRef<bool> isSectionHeader); // public System.Void .ctor() // Offset: 0x168C890 // Implemented from: HMUI.TableView // Base method: System.Void TableView::.ctor() // Base method: System.Void MonoBehaviour::.ctor() // Base method: System.Void Behaviour::.ctor() // Base method: System.Void Component::.ctor() // Base method: System.Void Object::.ctor() // Base method: System.Void Object::.ctor() template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static SectionTableView* New_ctor() { static auto ___internal__logger = ::Logger::get().WithContext("::HMUI::SectionTableView::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<SectionTableView*, creationType>())); } // public override System.Void ReloadData() // Offset: 0x168B850 // Implemented from: HMUI.TableView // Base method: System.Void TableView::ReloadData() void ReloadData(); // protected override System.Void DidSelectCellWithIdx(System.Int32 baseRow) // Offset: 0x168BD68 // Implemented from: HMUI.TableView // Base method: System.Void TableView::DidSelectCellWithIdx(System.Int32 baseRow) void DidSelectCellWithIdx(int baseRow); }; // HMUI.SectionTableView #pragma pack(pop) static check_size<sizeof(SectionTableView), 192 + sizeof(::ArrayW<::HMUI::SectionTableView::Section>)> __HMUI_SectionTableViewSizeCheck; static_assert(sizeof(SectionTableView) == 0xC8); } #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(::HMUI::SectionTableView::Section, "HMUI", "SectionTableView/Section"); #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: HMUI::SectionTableView::get_dataSource // Il2CppName: get_dataSource template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::HMUI::SectionTableView::IDataSource* (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::get_dataSource)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "get_dataSource", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::set_dataSource // Il2CppName: set_dataSource template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(::HMUI::SectionTableView::IDataSource*)>(&HMUI::SectionTableView::set_dataSource)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::GetClassFromName("HMUI", "SectionTableView/IDataSource")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "set_dataSource", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::add_didSelectRowInSectionEvent // Il2CppName: add_didSelectRowInSectionEvent template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(::System::Action_3<::HMUI::SectionTableView*, int, int>*)>(&HMUI::SectionTableView::add_didSelectRowInSectionEvent)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`3"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("HMUI", "SectionTableView"), ::il2cpp_utils::GetClassFromName("System", "Int32"), ::il2cpp_utils::GetClassFromName("System", "Int32")})->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "add_didSelectRowInSectionEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::remove_didSelectRowInSectionEvent // Il2CppName: remove_didSelectRowInSectionEvent template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(::System::Action_3<::HMUI::SectionTableView*, int, int>*)>(&HMUI::SectionTableView::remove_didSelectRowInSectionEvent)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`3"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("HMUI", "SectionTableView"), ::il2cpp_utils::GetClassFromName("System", "Int32"), ::il2cpp_utils::GetClassFromName("System", "Int32")})->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "remove_didSelectRowInSectionEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::add_didSelectHeaderEvent // Il2CppName: add_didSelectHeaderEvent template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(::System::Action_2<::HMUI::SectionTableView*, int>*)>(&HMUI::SectionTableView::add_didSelectHeaderEvent)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`2"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("HMUI", "SectionTableView"), ::il2cpp_utils::GetClassFromName("System", "Int32")})->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "add_didSelectHeaderEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::remove_didSelectHeaderEvent // Il2CppName: remove_didSelectHeaderEvent template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(::System::Action_2<::HMUI::SectionTableView*, int>*)>(&HMUI::SectionTableView::remove_didSelectHeaderEvent)> { static const MethodInfo* get() { static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`2"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("HMUI", "SectionTableView"), ::il2cpp_utils::GetClassFromName("System", "Int32")})->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "remove_didSelectHeaderEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::IsSectionUnfolded // Il2CppName: IsSectionUnfolded template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (HMUI::SectionTableView::*)(int)>(&HMUI::SectionTableView::IsSectionUnfolded)> { static const MethodInfo* get() { static auto* section = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "IsSectionUnfolded", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{section}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::CellSize // Il2CppName: CellSize template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<float (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::CellSize)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "CellSize", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::NumberOfCells // Il2CppName: NumberOfCells template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<int (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::NumberOfCells)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "NumberOfCells", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::CellForIdx // Il2CppName: CellForIdx template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::HMUI::TableCell* (HMUI::SectionTableView::*)(::HMUI::TableView*, int)>(&HMUI::SectionTableView::CellForIdx)> { static const MethodInfo* get() { static auto* tableView = &::il2cpp_utils::GetClassFromName("HMUI", "TableView")->byval_arg; static auto* baseRow = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "CellForIdx", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{tableView, baseRow}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::ReloadData // Il2CppName: ReloadData template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(bool)>(&HMUI::SectionTableView::ReloadData)> { static const MethodInfo* get() { static auto* resetFoldState = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "ReloadData", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{resetFoldState}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::UnfoldAllSections // Il2CppName: UnfoldAllSections template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::UnfoldAllSections)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "UnfoldAllSections", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::FoldAll // Il2CppName: FoldAll template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::FoldAll)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "FoldAll", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::UnfoldSection // Il2CppName: UnfoldSection template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(int)>(&HMUI::SectionTableView::UnfoldSection)> { static const MethodInfo* get() { static auto* section = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "UnfoldSection", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{section}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::FoldSection // Il2CppName: FoldSection template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(int)>(&HMUI::SectionTableView::FoldSection)> { static const MethodInfo* get() { static auto* section = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "FoldSection", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{section}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::ScrollToRow // Il2CppName: ScrollToRow template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(int, int, ::HMUI::TableView::ScrollPositionType, bool)>(&HMUI::SectionTableView::ScrollToRow)> { static const MethodInfo* get() { static auto* section = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; static auto* row = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; static auto* scrollPositionType = &::il2cpp_utils::GetClassFromName("HMUI", "TableView/ScrollPositionType")->byval_arg; static auto* animated = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "ScrollToRow", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{section, row, scrollPositionType, animated}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::SectionAndRowForBaseRow // Il2CppName: SectionAndRowForBaseRow template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(int, ByRef<int>, ByRef<int>, ByRef<bool>)>(&HMUI::SectionTableView::SectionAndRowForBaseRow)> { static const MethodInfo* get() { static auto* baseRow = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; static auto* section = &::il2cpp_utils::GetClassFromName("System", "Int32")->this_arg; static auto* row = &::il2cpp_utils::GetClassFromName("System", "Int32")->this_arg; static auto* isSectionHeader = &::il2cpp_utils::GetClassFromName("System", "Boolean")->this_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "SectionAndRowForBaseRow", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{baseRow, section, row, isSectionHeader}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead! // Writing MetadataGetter for method: HMUI::SectionTableView::ReloadData // Il2CppName: ReloadData template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)()>(&HMUI::SectionTableView::ReloadData)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "ReloadData", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: HMUI::SectionTableView::DidSelectCellWithIdx // Il2CppName: DidSelectCellWithIdx template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (HMUI::SectionTableView::*)(int)>(&HMUI::SectionTableView::DidSelectCellWithIdx)> { static const MethodInfo* get() { static auto* baseRow = &::il2cpp_utils::GetClassFromName("System", "Int32")->byval_arg; return ::il2cpp_utils::FindMethod(classof(HMUI::SectionTableView*), "DidSelectCellWithIdx", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{baseRow}); } };
58.608696
325
0.724901
RedBrumbler
029845a0e351d2002639ed9139b25b4f2e259e60
619
cpp
C++
Train/Sheet/Sheet-A/extra/extra 31 - 45/38.[Laptops].cpp
mohamedGamalAbuGalala/Practice
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
[ "MIT" ]
1
2019-12-19T06:51:20.000Z
2019-12-19T06:51:20.000Z
Train/Sheet/Sheet-A/extra/extra 31 - 45/38.[Laptops].cpp
mohamedGamalAbuGalala/Practice
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
[ "MIT" ]
null
null
null
Train/Sheet/Sheet-A/extra/extra 31 - 45/38.[Laptops].cpp
mohamedGamalAbuGalala/Practice
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; void fl() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("ot.txt", "w", stdout); #else // freopen("jumping.in", "r", stdin); // HERE #endif } #define in(n) scanf("%d",&n) //scan int #define ot(x) printf("%d", x) //output int //////////////////////////////////////////////////////////////////////////////////////////////// // snippet :: dinp , dhelp , dvec , lli , dfor , dcons , dbit int main() { // dfil fl(); //TODO int n, a, b; in(n); while(n-- and in(a) and in(b)) if(a!= b) return puts("Happy Alex"),0; puts("Poor Alex"); return 0; }
22.925926
96
0.486268
mohamedGamalAbuGalala
0298ebc1205eca8b38a70450591652ab9956a682
550
cpp
C++
python/PyPeridyno.cpp
hanxingyixue/peridyno
5c963dae20384f6af7a15866dac0d06adfcba236
[ "Apache-2.0" ]
2
2022-01-29T08:51:50.000Z
2022-02-22T12:07:09.000Z
python/PyPeridyno.cpp
hanxingyixue/peridyno
5c963dae20384f6af7a15866dac0d06adfcba236
[ "Apache-2.0" ]
null
null
null
python/PyPeridyno.cpp
hanxingyixue/peridyno
5c963dae20384f6af7a15866dac0d06adfcba236
[ "Apache-2.0" ]
null
null
null
#include "PyPeridyno.h" #include "PyGlfwGUI.h" #include "PyCore.h" #include "PyFramework.h" #include "PyParticleSystem.h" #include "PyRendering.h" #include "PyCloth.h" #include "PyQtGUI.h" #include "PyRigidBodySystem.h" // void init_GlutGUI(py::module &); // void init_Core(py::module &); PYBIND11_MODULE(PyPeridyno, m) { m.doc() = "Python binding of Peridyno"; pybind_glfw_gui(m); pybind_core(m); pybind_framework(m); pybind_particle_system(m); pybind_rendering(m); pybind_qt_gui(m); pybind_cloth(m); pybind_rigid_body_system(m); }
18.333333
40
0.729091
hanxingyixue
029a0e3a89c0e1cc5b8414ba9a27ffef8c5502e0
1,045
hpp
C++
001BlankGUI/TouchGFX/generated/gui_generated/include/gui_generated/screen1_screen/Screen1ViewBase.hpp
fjpolo/STM23F746Disco-Playground
446e8cd45b6ab3d771a782977e7630cf92a01a88
[ "MIT" ]
null
null
null
001BlankGUI/TouchGFX/generated/gui_generated/include/gui_generated/screen1_screen/Screen1ViewBase.hpp
fjpolo/STM23F746Disco-Playground
446e8cd45b6ab3d771a782977e7630cf92a01a88
[ "MIT" ]
null
null
null
001BlankGUI/TouchGFX/generated/gui_generated/include/gui_generated/screen1_screen/Screen1ViewBase.hpp
fjpolo/STM23F746Disco-Playground
446e8cd45b6ab3d771a782977e7630cf92a01a88
[ "MIT" ]
null
null
null
/*********************************************************************************/ /********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/ /*********************************************************************************/ #ifndef SCREEN1VIEWBASE_HPP #define SCREEN1VIEWBASE_HPP #include <gui/common/FrontendApplication.hpp> #include <mvp/View.hpp> #include <gui/screen1_screen/Screen1Presenter.hpp> #include <touchgfx/widgets/Box.hpp> #include <touchgfx/widgets/ToggleButton.hpp> class Screen1ViewBase : public touchgfx::View<Screen1Presenter> { public: Screen1ViewBase(); virtual ~Screen1ViewBase() {} virtual void setupScreen(); protected: FrontendApplication& application() { return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance()); } /* * Member Declarations */ touchgfx::Box __background; touchgfx::Box box1; touchgfx::ToggleButton toggleButton1; private: }; #endif // SCREEN1VIEWBASE_HPP
28.243243
89
0.578947
fjpolo
029b75d7c51c704e4316ff55176dcf0872ffb78b
7,003
cc
C++
multiscale/amsiMigration.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
multiscale/amsiMigration.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
multiscale/amsiMigration.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
#include "amsiMigration.h" #include "PCU.h" namespace amsi { #ifdef ZOLTAN int getLocalCount(void * data, int *) { return *static_cast<int*>(data); } void getWeights(void * data, int , int , ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int , float * obj_wgts, int *) { size_t int_sz= sizeof(int); char * d = static_cast<char*>(data); int offset = *static_cast<int*>((void*)d); int count = *static_cast<int*>((void*)(d+int_sz)); double * weights = static_cast<double*>((void*)(d+2*int_sz)); for(int ii = 0; ii < count; ii++) { local_ids[ii] = ii; global_ids[ii] = offset + ii; obj_wgts[ii] = weights[ii]; } } void zoltanPlan(std::vector<int> & to_serialize, std::vector<int> & send_to, int global_offset, int local_count, double * weights, Zoltan_Struct * zs) { size_t int_sz = sizeof(int); size_t dbl_ptr_sz = sizeof(double*); char * count_buffer = new char[int_sz]; memcpy(count_buffer,&local_count,int_sz); Zoltan_Set_Fn(zs, ZOLTAN_NUM_OBJ_FN_TYPE, (void(*)()) &getLocalCount, count_buffer); char * weight_buffer = new char[2*int_sz+dbl_ptr_sz]; memcpy(weight_buffer,&global_offset,int_sz); memcpy(weight_buffer+int_sz,&local_count,int_sz); memcpy(weight_buffer+2*int_sz,&weights,dbl_ptr_sz); Zoltan_Set_Fn(zs, ZOLTAN_OBJ_LIST_FN_TYPE, (void(*)()) &getWeights, weight_buffer); Zoltan_Set_Param(zs,"RETURN_LISTS","EXPORT"); Zoltan_Set_Param(zs,"OBJ_WEIGHT_DIM","1"); Zoltan_Set_Param(zs,"LB_METHOD","BLOCK"); int do_lb = 0; int num_gid_entries = 0; int num_lid_entries = 0; int num_recv = 0; int num_send = 0; ZOLTAN_ID_TYPE * recv_gids; // global object IDs to recv ZOLTAN_ID_TYPE * recv_lids; // "1 part per process" so this is not used ZOLTAN_ID_TYPE * send_gids; // global object IDS to send ZOLTAN_ID_TYPE * send_lids; // "1 part per process" so this is not used int * recv_ranks; // ranks from which to recv each object int * send_ranks; // ranks to which to send objects Zoltan_LB_Balance(zs, &do_lb, &num_gid_entries, &num_lid_entries, &num_recv, &recv_gids, &recv_lids, &recv_ranks, &num_send, &send_gids, &send_lids, &send_ranks); if(do_lb) { to_serialize.assign(send_lids,send_lids+num_send); send_to.assign(send_ranks,send_ranks+num_send); } Zoltan_LB_Free_Data(&recv_gids, &recv_lids, &recv_ranks, &send_gids, &send_lids, &send_ranks); delete [] count_buffer; delete [] weight_buffer; } #endif Migration::Migration(MPI_Comm c, int a, lb_fctn ua) : comm(c), comm_size(-1), algo(a), usr_algo(ua) { # ifdef ZOLTAN zs = Zoltan_Create(comm); # endif MPI_Comm_size(comm,&comm_size); } void Migration::plan(std::vector<int> & to_serialize, int local_size, double * local_weights) { bool dynamic = false; if(!local_weights) { dynamic = true; local_weights = new double[local_size](); for(int ii = 0; ii < local_size; ii++) local_weights[ii] = 1.0; } # ifdef ZOLTAN int offset = 0; # endif switch(algo) { case USER_ALGO: (*usr_algo)(to_serialize, send_to, comm, local_size, local_weights); break; case ZOLTAN_ALGO: # ifdef ZOLTAN MPI_Scan(&local_size,&offset,1,MPI_INT,MPI_SUM,comm); offset -= local_size; zoltanPlan(to_serialize, send_to, offset, local_size, local_weights, zs); # else std::cerr << "Zoltan load balancing specified but AMSI is not configured with ZOLTAN!" << std::endl; # endif break; default: AMSI_DEBUG(std::cout << "Migration algorithm " << algo << " not implemented, no migration will be conducted." << std::endl); case NO_ALGO: break; } if(dynamic) delete [] local_weights; } void Migration::execute(std::vector< std::vector<char> > & data) { PCU_Comm_Begin(); int send_count = send_to.size(); for(int current_send = 0; current_send < send_count; current_send++) { PCU_Comm_Write(send_to[current_send], data[current_send].data(), data[current_send].size()); } PCU_Comm_Send(); int recv_from = -1; void * recv = NULL; size_t recv_size = 0; while(PCU_Comm_Read(&recv_from,&recv,&recv_size)) { data.push_back(std::vector<char>()); data.back().resize(recv_size); memcpy(data.back().data(),recv,recv_size); recvd_from.push_back(recv_from); } } ScaleSensitiveMigration::ScaleSensitiveMigration(CommPattern * p, MPI_Comm c, int a, lb_fctn ua) : Migration(c,a,ua), cp(p), send_indices() {} void ScaleSensitiveMigration::plan(std::vector<int> & to_serialize, int local_size, double * local_weights) { Migration::plan(to_serialize,local_size,local_weights); send_indices = to_serialize; } void ScaleSensitiveMigration::execute(std::vector< std::vector<char> > & data) { assert(send_to.size() == data.size()); int rank = -1; MPI_Comm_rank(comm,&rank); size_t int_sz = sizeof(int); int send_count = send_to.size(); for(int ii = 0; ii < send_count; ii++) { std::pair<int,int> coupled_rank_index = coupledInfoByIndex(cp, RECVER, rank, send_indices[ii]); size_t data_sz = data[ii].size(); data[ii].resize(data_sz+2*int_sz); char * d = data[ii].data(); memcpy(d+data_sz,&coupled_rank_index.first,int_sz); memcpy(d+data_sz+int_sz,&coupled_rank_index.second,int_sz); } Migration::execute(data); std::vector<int> coupled_processes; std::vector<int> coupled_indices; // recv'd data for(unsigned ii = 0; ii < data.size(); ii++) { size_t data_sz = data[ii].size(); char * d = data[ii].data(); int coupled_process = *static_cast<int*>((void*)(d+data_sz-2*int_sz)); int coupled_index = *static_cast<int*>((void*)(d+data_sz-int_sz)); coupled_processes.push_back(coupled_process); coupled_indices.push_back(coupled_index); } if(data.size()) { } } }//namespace
30.714912
128
0.564901
SCOREC
029d72dd17a7b6edd05649b9f8ac91a1de107b59
1,934
hpp
C++
tests/common/include/coherence/tests/POFObjectInvocable.hpp
chpatel3/coherence-cpp-extend-client
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
[ "UPL-1.0", "Apache-2.0" ]
6
2020-07-01T21:38:30.000Z
2021-11-03T01:35:11.000Z
tests/common/include/coherence/tests/POFObjectInvocable.hpp
chpatel3/coherence-cpp-extend-client
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
[ "UPL-1.0", "Apache-2.0" ]
1
2020-07-24T17:29:22.000Z
2020-07-24T18:29:04.000Z
tests/common/include/coherence/tests/POFObjectInvocable.hpp
chpatel3/coherence-cpp-extend-client
4ea5267eae32064dff1e73339aa3fbc9347ef0f6
[ "UPL-1.0", "Apache-2.0" ]
6
2020-07-10T18:40:58.000Z
2022-02-18T01:23:40.000Z
/* * Copyright (c) 2000, 2020, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ #ifndef COH_POF_OBJECT_INVOCABLE_HPP #define COH_POF_OBJECT_INVOCABLE_HPP #include "coherence/lang.ns" #include "coherence/io/pof/PofReader.hpp" #include "coherence/io/pof/PofWriter.hpp" #include "coherence/io/pof/PortableObject.hpp" #include "coherence/net/AbstractInvocable.hpp" COH_OPEN_NAMESPACE2(coherence,tests) using coherence::io::pof::PofReader; using coherence::io::pof::PofWriter; using coherence::io::pof::PortableObject; using coherence::net::AbstractInvocable; /** * Invocable implementation that serializes and deserializes a POF object * between c++ client and server * * @author wl 2010.08.27 */ class POFObjectInvocable : public class_spec<POFObjectInvocable, extends<AbstractInvocable>, implements<PortableObject> > { friend class factory<POFObjectInvocable>; // ----- constructors --------------------------------------------------- protected: /** * Default constructor - needed for PortableObject. */ POFObjectInvocable(); /** * Create a new POFObjectInvocable instance. * * @param v the object to serialize */ POFObjectInvocable(Object::View v); // ----- PortableObject interface --------------------------------------- public: /** * {@inheritDoc} */ virtual void readExternal(PofReader::Handle hIn); /** * {@inheritDoc} */ virtual void writeExternal(PofWriter::Handle hOut) const; // ----- data members --------------------------------------------------- private: /** * The POF object. */ FinalView<Object> f_vPOFObject; }; COH_CLOSE_NAMESPACE2 #endif // COH_POF_OBJECT_INVOCABLE_HPP
24.794872
77
0.606515
chpatel3
02a6afdd5df169cbda7c945cc8466943ed1840d5
1,277
cpp
C++
code/gate-controller/gate-controller/stopwatch.cpp
micromouseonline/micromouse-timer
544974ae99cb1b9f3f789893b2f5205a4c11ab43
[ "MIT" ]
null
null
null
code/gate-controller/gate-controller/stopwatch.cpp
micromouseonline/micromouse-timer
544974ae99cb1b9f3f789893b2f5205a4c11ab43
[ "MIT" ]
null
null
null
code/gate-controller/gate-controller/stopwatch.cpp
micromouseonline/micromouse-timer
544974ae99cb1b9f3f789893b2f5205a4c11ab43
[ "MIT" ]
1
2019-12-30T02:43:56.000Z
2019-12-30T02:43:56.000Z
/* * File: stopwatch.cpp * Author: peterharrison * * Created on 14 June 2015, 09:11 */ #include "stopwatch.h" #include <Arduino.h> Stopwatch::Stopwatch() : mState(RESET), mTime(0) { reset(); } Stopwatch::~Stopwatch() = default; void Stopwatch::start() { if (mState != Stopwatch::RUNNING) { mState = Stopwatch::RUNNING; reset(); } }; void Stopwatch::stop() { if (mState == Stopwatch::RUNNING) { mState = Stopwatch::STOPPED; } // reset(); }; void Stopwatch::restart() { reset(); mState = Stopwatch::RUNNING; } uint32_t Stopwatch::time() { if (mState == Stopwatch::RUNNING) { mStopMillis = millis(); } mTime = (mStopMillis - mStartMillis) ; return mTime; } /** * * @return lap time in microseconds, reset timer */ uint32_t Stopwatch::lap() { if (mState == Stopwatch::RUNNING) { mStopMillis = millis(); mLapTime = (mStopMillis - mStartMillis) ; mStartMillis = mStopMillis; } return mLapTime; } uint32_t Stopwatch::split() { if (mState == Stopwatch::RUNNING) { mStopMillis = millis(); mSplitTime = (mStopMillis - mStartMillis) ; } return mSplitTime; } void Stopwatch::reset() { mSplitTime = 0; mLapTime = 0; mStartMillis = millis(); mStopMillis = mStartMillis; mState = RESET; };
17.736111
50
0.632733
micromouseonline
02ad47550fad80aa623345a2fd67f5492e59407a
1,598
cpp
C++
BuildingRoads.cpp
zuhaib786/CSES_SOLUTIONS
d506d25919b9ebc9b2b809e1cd5327c14872e4a9
[ "MIT" ]
1
2021-06-18T01:48:37.000Z
2021-06-18T01:48:37.000Z
BuildingRoads.cpp
zuhaib786/CSES_SOLUTIONS
d506d25919b9ebc9b2b809e1cd5327c14872e4a9
[ "MIT" ]
null
null
null
BuildingRoads.cpp
zuhaib786/CSES_SOLUTIONS
d506d25919b9ebc9b2b809e1cd5327c14872e4a9
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> #define MAX 1000000007 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin>>n>>m; vector<vector<int>>nodes(n); for(int i =0;i<m;i++) { int a, b; cin>>a>>b; nodes[a-1].push_back(b-1); nodes[b-1].push_back(a-1); } int visited[n] = {0}; vector<vector<int>>connected_components; int count = 0; for(int i = 0;i<n;i++) { if(visited[i] == 0) { count++; stack<int>s; s.push(i); vector<int>temp(1); temp[0] = i; connected_components.push_back(temp); while(s.size()!=0) { int node = s.top(); s.pop(); if(visited[node]==1) { continue; } connected_components[count-1].push_back(node); visited[node] = 1; for(int x: nodes[node]) { if(visited[x] == 0) { s.push(x); } } } } } string paths = ""; for(int i =0; i<connected_components.size()-1;i++) { paths+= to_string(connected_components[i][0]+1)+" "+to_string(connected_components[i+1][0]+1)+'\n'; } if(connected_components.size()==1) { cout<<0<<endl; return 0; } else { cout<<connected_components.size()-1<<"\n"<<paths; } return 0; }
24.212121
107
0.421777
zuhaib786
02b33ae396e1122c41cd3e46bc87d0a1d466d7d1
5,644
cpp
C++
patch/specific/drawsparks.cpp
Tonyx97/TombMP
7eb2d265df2fe7312b7ed07dd5943736340b921c
[ "MIT" ]
3
2021-10-10T11:12:03.000Z
2021-11-04T16:46:57.000Z
patch/specific/drawsparks.cpp
Tonyx97/TombMP
7eb2d265df2fe7312b7ed07dd5943736340b921c
[ "MIT" ]
null
null
null
patch/specific/drawsparks.cpp
Tonyx97/TombMP
7eb2d265df2fe7312b7ed07dd5943736340b921c
[ "MIT" ]
null
null
null
#include "standard.h" #include "global.h" #include "output.h" #include <3dsystem/hwinsert.h> #include <game/effect2.h> #include <game/effects.h> #include <specific/fn_stubs.h> #include <main.h> void S_DrawSparks() { auto [sw, sh] = g_window->get_resolution(); auto sptr = &spark[0]; for (int i = 0; i < MAX_SPARKS; ++sptr, ++i) { if (sptr->On == 0) continue; long wx, wy, wz; if (sptr->Flags & SP_FX) { auto fx = &effects[sptr->FxObj]; wx = fx->pos.x_pos + sptr->x; wy = fx->pos.y_pos + sptr->y; wz = fx->pos.z_pos + sptr->z; } else if (sptr->Flags & SP_ITEM) { auto item = &items[sptr->FxObj]; wx = item->pos.x_pos + sptr->x; wy = item->pos.y_pos + sptr->y; wz = item->pos.z_pos + sptr->z; } else { wx = sptr->x; wy = sptr->y; wz = sptr->z; } long result[XYZ], scr[3][XYZ]; mCalcPoint(wx, wy, wz, &result[0]); ProjectPCoord(result[_X], result[_Y], result[_Z], &scr[0][0], sw >> 1, sh >> 1, phd_persp); if (sptr->Flags & SP_DEF) { long w, h; if (sptr->Flags & SP_SCALE) { if (scr[0][_Z] == 0) ++scr[0][_Z]; w = ((sptr->Width * phd_persp) << sptr->Scalar) / (scr[0][_Z]); h = ((sptr->Height * phd_persp) << sptr->Scalar) / (scr[0][_Z]); if (w > sptr->Width << sptr->Scalar) w = sptr->Width << sptr->Scalar; else if (w < 4) w = 4; if (h > sptr->Height << sptr->Scalar) h = sptr->Height << sptr->Scalar; else if (h < 4) h = 4; } else { w = sptr->Width; h = sptr->Height; } auto z = scr[0][_Z] << W2V_SHIFT; if ((z < phd_znear || z > phd_zfar) || (scr[0][_X] + (w >> 1) < 0) || (scr[0][_X] - (w >> 1) > sw) || (scr[0][_Y] + (h >> 1) < 0) || (scr[0][_Y] - (h >> 1) > sh)) { continue; } if (sptr->Flags & SP_ROTATE) { long sin = m_sin(sptr->RotAng << 1), cos = m_cos(sptr->RotAng << 1), sinx1 = ((-w >> 1) * sin) >> 12, sinx2 = ((w >> 1) * sin) >> 12, siny1 = ((-h >> 1) * sin) >> 12, siny2 = ((h >> 1) * sin) >> 12, cosx1 = ((-w >> 1) * cos) >> 12, cosx2 = ((w >> 1) * cos) >> 12, cosy1 = ((-h >> 1) * cos) >> 12, cosy2 = ((h >> 1) * cos) >> 12; int x1 = sinx1 - cosy1 + scr[0][_X], x2 = sinx2 - cosy1 + scr[0][_X], x3 = sinx2 - cosy2 + scr[0][_X], x4 = sinx1 - cosy2 + scr[0][_X], y1 = cosx1 + siny1 + scr[0][_Y], y2 = cosx2 + siny1 + scr[0][_Y], y3 = cosx2 + siny2 + scr[0][_Y], y4 = cosx1 + siny2 + scr[0][_Y]; int nShade = ((sptr->R >> 3) << 10) | ((sptr->G >> 3) << 5) | ((sptr->B >> 3)); if (z > DPQ_S) { int r = sptr->R, g = sptr->G, b = sptr->B, v = 2048 - ((z - DPQ_S) >> 16); r *= v; g *= v; b *= v; r >>= 14; g >>= 14; b >>= 14; if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; nShade = r << 10 | g << 5 | b; } const int type = (sptr->TransType == COLADD || sptr->TransType == COLSUB ? DRAW_TLV_GTA : DRAW_TLV_WGT); HWI_InsertAlphaSprite_Sorted(x1, y1, z, nShade, x2, y2, z, nShade, x3, y3, z, nShade, x4, y4, z, nShade, sptr->Def, type, 0); sptr->RotAng += sptr->RotAdd; sptr->RotAng &= 4095; } else { int x1 = scr[0][_X] - (w >> 1), x2 = scr[0][_X] + (w >> 1), y1 = scr[0][_Y] - (h >> 1), y2 = scr[0][_Y] + (h >> 1); int nShade = ((sptr->R >> 3) << 10) | ((sptr->G >> 3) << 5) | ((sptr->B >> 3)); if (z > DPQ_S) { int r = sptr->R, g = sptr->G, b = sptr->B, v = 2048 - ((z - DPQ_S) >> 16); r *= v; g *= v; b *= v; r >>= 14; g >>= 14; b >>= 14; if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; nShade = r << 10 | g << 5 | b; } const int type = (sptr->TransType == COLADD || sptr->TransType == COLSUB ? DRAW_TLV_GTA : DRAW_TLV_WGT); HWI_InsertAlphaSprite_Sorted(x1, y1, z, nShade, x2, y1, z, nShade, x2, y2, z, nShade, x1, y2, z, nShade, sptr->Def, type, 0); } } else { int w, h; if (sptr->Flags & SP_SCALE) { if (scr[0][_Z] == 0) scr[0][_Z] = 1; w = ((sptr->Width * phd_persp) << sptr->Scalar) / (scr[0][_Z]); h = ((sptr->Height * phd_persp) << sptr->Scalar) / (scr[0][_Z]); if (w > sptr->Width << 2) w = sptr->Width << 2; else if (w < 1) w = 1; if (h > sptr->Height << 2) h = sptr->Height << 2; else if (h < 1) h = 1; } else { w = sptr->Width; h = sptr->Height; } auto z = scr[0][_Z] << W2V_SHIFT; if ((z < phd_znear || z > phd_zfar) || (scr[0][_X] + (w >> 1) < 0) || (scr[0][_X] - (w >> 1) > sw) || (scr[0][_Y] + (h >> 1) < 0) || (scr[0][_Y] - (h >> 1) > sh)) { continue; } int x1 = scr[0][_X] - (w >> 1), y1 = scr[0][_Y] - (h >> 1), x2 = x1 + w, y2 = y1 + h; int nShade = ((sptr->R >> 3) << 10) | ((sptr->G >> 3) << 5) | ((sptr->B >> 3)); if (z > DPQ_S) { int r = sptr->R, g = sptr->G, b = sptr->B, v = 2048 - ((z - DPQ_S) >> 16); r *= v; g *= v; b *= v; r >>= 14; g >>= 14; b >>= 14; if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; nShade = r << 10 | g << 5 | b; } const int type = (sptr->TransType == COLADD || sptr->TransType == COLSUB ? DRAW_TLV_GA : DRAW_TLV_G); HWI_InsertAlphaSprite_Sorted(x1, y1, z, nShade, x2, y1, z, nShade, x2, y2, z, nShade, x1, y2, z, nShade, nullptr, type, 0); } } }
21.460076
108
0.434444
Tonyx97
02b43dc26be586d6b14d961f780e2675d02e7e4a
13,824
inl
C++
cuj/inc/cuj/dsl/impl/arithmetic_reference.inl
AirGuanZ/cuj
81030a35e1cb8f3f2134d267d8a416aa348348cd
[ "MIT" ]
23
2021-04-24T12:08:40.000Z
2022-01-18T14:26:00.000Z
cuj/inc/cuj/dsl/impl/arithmetic_reference.inl
AirGuanZ/cuj
81030a35e1cb8f3f2134d267d8a416aa348348cd
[ "MIT" ]
null
null
null
cuj/inc/cuj/dsl/impl/arithmetic_reference.inl
AirGuanZ/cuj
81030a35e1cb8f3f2134d267d8a416aa348348cd
[ "MIT" ]
4
2021-04-24T12:08:56.000Z
2022-01-20T07:46:41.000Z
#pragma once #include <cuj/core/stat.h> #include <cuj/dsl/arithmetic.h> #include <cuj/dsl/arithmetic_reference.h> #include <cuj/dsl/function.h> CUJ_NAMESPACE_BEGIN(cuj::dsl) template<typename T> requires std::is_arithmetic_v<T> ref<num<T>>::ref(const num<T> &var) { addr_ = var.address(); } template<typename T> requires std::is_arithmetic_v<T> ref<num<T>>::ref(const ref &ref) { addr_ = ref.address(); } template<typename T> requires std::is_arithmetic_v<T> ref<num<T>>::ref(ref &&other) noexcept : addr_(std::move(other.addr_)) { } template<typename T> requires std::is_arithmetic_v<T> ref<num<T>> &ref<num<T>>::operator=( const ref &other) { core::Store store = { .dst_addr = addr_._load(), .val = other._load() }; auto func_ctx = FunctionContext::get_func_context(); func_ctx->append_statement(std::move(store)); return *this; } template<typename T> requires std::is_arithmetic_v<T> ref<num<T>> &ref<num<T>>::operator=( const num<T> &other) { core::Store store = { .dst_addr = addr_._load(), .val = other._load() }; auto func_ctx = FunctionContext::get_func_context(); func_ctx->append_statement(std::move(store)); return *this; } template<typename T> requires std::is_arithmetic_v<T> template<typename U> requires is_cuj_arithmetic_v<U> U ref<num<T>>::as() const { auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto src_type = type_ctx->get_type<num<T>>(); auto dst_type = type_ctx->get_type<U>(); core::ArithmeticCast cast = { .dst_type = dst_type , .src_type = src_type, .src_val = newRC<core::Expr>(_load()) }; return U::_from_expr(cast); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator-() const { static_assert(!std::is_same_v<T, bool>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Unary unary = { .op = core::Unary::Op::Neg, .val = newRC<core::Expr>(_load()), .val_type = type }; return num<T>::_from_expr(unary); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator+(const num<T> &rhs) const { static_assert(!std::is_same_v<T, bool>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Binary binary = { .op = core::Binary::Op::Add, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }; return num<T>::_from_expr(binary); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator-(const num<T> &rhs) const { static_assert(!std::is_same_v<T, bool>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Binary binary = { .op = core::Binary::Op::Sub, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }; return num<T>::_from_expr(binary); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator*(const num<T> &rhs) const { static_assert(!std::is_same_v<T, bool>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Binary binary = { .op = core::Binary::Op::Mul, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }; return num<T>::_from_expr(binary); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator/(const num<T> &rhs) const { static_assert(!std::is_same_v<T, bool>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Binary binary = { .op = core::Binary::Op::Div, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }; return num<T>::_from_expr(binary); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator%(const num<T> &rhs) const { static_assert(!std::is_same_v<T, bool>); static_assert(std::is_integral_v<T>); auto type_ctx = FunctionContext::get_func_context()->get_type_context(); auto type = type_ctx->get_type<num<T>>(); core::Binary binary = { .op = core::Binary::Op::Mod, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }; return num<T>::_from_expr(binary); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator==(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::Equal, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator!=(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::NotEqual, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator<(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::Less, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator<=(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::LessEqual, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator>(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::Greater, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<bool> ref<num<T>>::operator>=(const num<T> &rhs) const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<bool>::_from_expr(core::Binary{ .op = core::Binary::Op::GreaterEqual, .lhs = newRC<core::Expr>(_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator>>(const num<T> &rhs) const { static_assert(std::is_integral_v<T> && !std::is_signed_v<T>); auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Binary{ .op = core::Binary::Op::RightShift, .lhs = newRC<core::Expr>(this->_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator<<(const num<T> &rhs) const { static_assert(std::is_integral_v<T>); auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Binary{ .op = core::Binary::Op::LeftShift, .lhs = newRC<core::Expr>(this->_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator&(const num<T> &rhs) const { static_assert(std::is_integral_v<T>); auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Binary{ .op = core::Binary::Op::BitwiseAnd, .lhs = newRC<core::Expr>(this->_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator|(const num<T> &rhs) const { static_assert(std::is_integral_v<T>); auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Binary{ .op = core::Binary::Op::BitwiseOr, .lhs = newRC<core::Expr>(this->_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator^(const num<T> &rhs) const { static_assert(std::is_integral_v<T>); auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Binary{ .op = core::Binary::Op::BitwiseXOr, .lhs = newRC<core::Expr>(this->_load()), .rhs = newRC<core::Expr>(rhs._load()), .lhs_type = type, .rhs_type = type }); } template<typename T> requires std::is_arithmetic_v<T> num<T> ref<num<T>>::operator~() const { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<T>>(); return num<T>::_from_expr(core::Unary{ .op = core::Unary::Op::BitwiseNot, .val = newRC<core::Expr>(_load()), .val_type = type }); } template<typename T> requires std::is_arithmetic_v<T> ptr<num<T>> ref<num<T>>::address() const { ptr<num<T>> ret; ret = addr_; return ret; } template<typename T> requires std::is_arithmetic_v<T> core::Load ref<num<T>>::_load() const { auto type = FunctionContext::get_func_context()->get_type_context() ->get_type<num<T>>(); return core::Load{ .val_type = type, .src_addr = newRC<core::Expr>(addr_._load()) }; } template<typename T> requires std::is_arithmetic_v<T> ref<num<T>> ref<num<T>>::_from_ptr(const ptr<num<T>> &ptr) { ref ret; ret.addr_ = ptr; return ret; } template<typename T> num<T> operator+(T lhs, const ref<num<T>> &rhs) { return num(lhs) + rhs; } template<typename T> num<T> operator-(T lhs, const ref<num<T>> &rhs) { return num(lhs) - rhs; } template<typename T> num<T> operator*(T lhs, const ref<num<T>> &rhs) { return num(lhs) * rhs; } template<typename T> num<T> operator/(T lhs, const ref<num<T>> &rhs) { return num(lhs) / rhs; } template<typename T> num<T> operator%(T lhs, const ref<num<T>> &rhs) { return num(lhs) % rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator==(T lhs, const ref<num<T>> &rhs) { return num(lhs) == rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator!=(T lhs, const ref<num<T>> &rhs) { return num(lhs) != rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator<(T lhs, const ref<num<T>> &rhs) { return num(lhs) < rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator<=(T lhs, const ref<num<T>> &rhs) { return num(lhs) <= rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator>(T lhs, const ref<num<T>> &rhs) { return num(lhs) > rhs; } template<typename T> requires std::is_arithmetic_v<T> num<bool> operator>=(T lhs, const ref<num<T>> &rhs) { return num(lhs) >= rhs; } inline num<bool> operator!(const ref<num<bool>> &val) { auto type = FunctionContext::get_func_context() ->get_type_context()->get_type<num<bool>>(); return num<bool>::_from_expr(core::Unary{ .op = core::Unary::Op::Not, .val = newRC<core::Expr>(val._load()), .val_type = type }); } template<typename T> requires std::is_integral_v<T> && (!std::is_signed_v<T>) num<T> operator>>(T lhs, const ref<num<T>> &rhs) { return num(lhs) >> rhs; } template<typename T> requires std::is_integral_v<T> num<T> operator<<(T lhs, const ref<num<T>> &rhs) { return num(lhs) << rhs; } template<typename T> requires std::is_integral_v<T> num<T> operator&(T lhs, const ref<num<T>> &rhs) { return num(lhs) & rhs; } template<typename T> requires std::is_integral_v<T> num<T> operator|(T lhs, const ref<num<T>> &rhs) { return num(lhs) | rhs; } template<typename T> requires std::is_integral_v<T> num<T> operator^(T lhs, const ref<num<T>> &rhs) { return num(lhs) ^ rhs; } CUJ_NAMESPACE_END(cuj::dsl)
29.350318
77
0.607784
AirGuanZ
02bad6c11b0b60a1ba0afb53e570e334bbf2183c
7,437
hh
C++
src/ggl/chem/MoleculeComponent_GML_grammar.hh
michaelapeterka/GGL
99e585b773ad8f33e39160d2cbd71c00e036fa37
[ "MIT" ]
20
2017-05-09T15:37:04.000Z
2021-11-24T10:51:02.000Z
src/ggl/chem/MoleculeComponent_GML_grammar.hh
michaelapeterka/GGL
99e585b773ad8f33e39160d2cbd71c00e036fa37
[ "MIT" ]
2
2017-05-24T08:00:25.000Z
2017-05-24T08:01:01.000Z
src/ggl/chem/MoleculeComponent_GML_grammar.hh
michaelapeterka/GGL
99e585b773ad8f33e39160d2cbd71c00e036fa37
[ "MIT" ]
7
2017-05-29T10:55:18.000Z
2020-12-04T14:24:51.000Z
#ifndef GGL_CHEM_MOLECULECOMPONENT_GML_GRAMMAR_HH_ #define GGL_CHEM_MOLECULECOMPONENT_GML_GRAMMAR_HH_ #include <utility> #include <vector> #include <string> #include <stdexcept> #include "sgm/HashMap.hh" #if HAVE_UNORDERED_MAP > 0 #include <unordered_map> #elif HAVE_TR1_UNORDERED_MAP > 0 #include <tr1/unordered_map> #elif HAVE_GNU_HASH_MAP > 0 #include <ext/hash_map> #else #include <map> #endif // set spirit closure limit if neccessary #if !defined(BOOST_SPIRIT_CLOSURE_LIMIT) #define BOOST_SPIRIT_CLOSURE_LIMIT 5 #elif BOOST_SPIRIT_CLOSURE_LIMIT < 5 #error "GGL_CHEM_MOLECULECOMPONENT_GML_GRAMMAR : BOOST_SPIRIT_CLOSURE_LIMIT too low, has to be at least 5" #endif // set phoenix limit if neccessary #if !defined(PHOENIX_LIMIT) #define PHOENIX_LIMIT 5 #elif PHOENIX_LIMIT < 5 #error "GGL_CHEM_MOLECULECOMPONENT_GML_GRAMMAR : PHOENIX_LIMIT too low, has to be at least 5" #endif #include <boost/version.hpp> #if BOOST_VERSION >= 103800 #include <boost/spirit/include/classic.hpp> #include <boost/spirit/include/phoenix1.hpp> #include <boost/spirit/include/classic_actor.hpp> #define NS_BOOSTSPIRIT boost::spirit::classic #else #include <boost/spirit.hpp> #include <boost/spirit/phoenix.hpp> #include <boost/spirit/actor.hpp> #define NS_BOOSTSPIRIT boost::spirit #endif #include "ggl/chem/MoleculeComponent.hh" #include "sgm/Pattern.hh" #include "ggl/chem/MC_MC_Node.hh" namespace ggl { namespace chem { /*! @brief MoleculeComponent parser * * Parses a GML string representation of a * ggl::MoleculeDecomposition::MoleculeComponent object. This includes its * properties as well as the additional constraints needed for matching. * * Example : * * \verbatim ======= GRAPH IN GML ========================= molcomp [ description " '-Cl' (attached to a primary carbon with no other clorine atoms attached)" priority 4 energy -11.7 node [ id 0 label "C" ] node [ id 1 label "Cl" ] edge [ source 0 target 1 label "-" ] constrainAdj [ id 0 op = count 1 nodeLabels [ label "Cl" ] ] constrainAdj [ id 0 op = count 2 nodeLabels [ label "H" ] ] ] ============================================== \endverbatim * * @author Martin Mann (c) 2010 http://www.bioinf.uni-freiburg.de/~mmann/ * */ class MoleculeComponent_GML_grammar : public NS_BOOSTSPIRIT::grammar< MoleculeComponent_GML_grammar > { protected: //! type for mapping integers to size_t typedef #if HAVE_UNORDERED_MAP > 0 std::unordered_map<int, size_t> #elif HAVE_TR1_UNORDERED_MAP > 0 std::tr1::unordered_map<int, size_t> #else std::map<int, size_t> #endif MapIntSizeT; protected: //! The boost core graph object that is filled to represent the next //! parsed Rule. MoleculeComponent& toFill; public: //! Constructs the definitions of a GML graph grammar to parse //! a GML graph string representation and to fill the encoded graph //! into a given boost graph object. //! @param toFill the object to add nodes and edges to explicit MoleculeComponent_GML_grammar( MoleculeComponent & toFill ); //! Parses a GML string and generates a MoleculeComponent::PatternGraph object //! @param GML_string the string to parse //! @return pair.first = the graph encoding of the molecule //! pair.second = -1 if parsing was successfull, //! in error case it returns the string position that caused //! the parsing error //! @throw std::invalid_argument in case a check fails static std::pair< MoleculeComponent, int > parseGML( const std::string & GML_string ) throw (std::invalid_argument); //! The definition of the GML grammar. template <typename ScannerT> struct definition { public: //! Construction of the GML BNF grammar rules to parse a //! MoleculeComponent //! @param self access to the calling grammar definition( const MoleculeComponent_GML_grammar & self ); //! start parsing NS_BOOSTSPIRIT::rule<ScannerT> const& start() const; protected: //! the molecule component to be filled MoleculeComponent& toFill; //! Access to the node label property_map of toFill to set node labels boost::property_map< MoleculeComponent::PatternGraph, PropNodeLabel>::type nodeLabel; //! Access to the edge label property_map of g2fill to set edge labels boost::property_map< MoleculeComponent::PatternGraph, PropEdgeLabel>::type edgeLabel; //! the mapping of node IDs in the GML notation and their //! corresponding node IDs in the created pattern graph MapIntSizeT nodeMapping; //! the rules to be parsed NS_BOOSTSPIRIT::rule<ScannerT> molcomp, content, node, edge, compIDs, constrainAdjacency, constrainLabel, ringFragment; // temporary data structures int curNodeID, curEdgeFromID, curEdgeToID; std::string curNodeLabel, curEdgeLabel; std::string curRingFragmentTypeString; // temporary constraint objects MC_MC_NodeAdjacency constrAdj; char constrAdjOp, constrLabelOp; MC_MC_NodeLabel constrLabel; MoleculeComponent::RingFragmentList curRingFragmentList; enum WhatList { Fill_constrAdj_NL, Fill_constrAdj_EL, Fill_constrLabel_NL, Fill_compIDs, Fill_ringFragments }; // helper functions /*! * Resets toFill to enable the detection of missing information * within final_checks() */ void clear_toFill(void); /*! * Performs final checks on toFill to ensure that the parse was * correct * * @throw std::invalid_argument in case a check fails */ void final_checks(void) throw (std::invalid_argument); /*! * Stores a node of the MoleculeComponent pattern graph. * @throw std::invalid_argument in case a check fails */ void store_node(void) throw (std::invalid_argument); /*! * Stores an edge of the MoleculeComponent pattern graph. * @throw std::invalid_argument in case a check fails */ void store_edge(void) throw (std::invalid_argument); /*! * Stores a node adjacency constraint of the MoleculeComponent */ void store_constrAdj(void); /*! * Stores a node label constraint of the MoleculeComponent */ void store_constrLabel(void); /*! * Inserts a string into a given string set * @param list the encoding which list to be fill */ void insert_to_list( WhatList list ); }; // end of description }; // end of MoleculeComponent_GML_grammar } // namespace chem } // namespace ggl // include implementation #include "ggl/chem/MoleculeComponent_GML_grammar.icc" #endif /*GGL_CHEM_MOLECULECOMPONENT_GML_GRAMMAR_HH_*/
29.511905
107
0.63453
michaelapeterka
02c052b70607271d55f2a1c9d612cb3a89ee1362
4,701
cpp
C++
source/spitboy.cpp
JROB774/agbicjam2020
31b6dc8ef8987768bad7f7698893309662bde490
[ "MIT" ]
4
2020-10-21T04:04:27.000Z
2021-09-08T20:04:16.000Z
source/spitboy.cpp
JROB774/agbicjam2020
31b6dc8ef8987768bad7f7698893309662bde490
[ "MIT" ]
null
null
null
source/spitboy.cpp
JROB774/agbicjam2020
31b6dc8ef8987768bad7f7698893309662bde490
[ "MIT" ]
null
null
null
GLOBAL constexpr float SPITBOY_SPIT_COOLDOWN_NORMAL = 0.75f; GLOBAL constexpr float SPITBOY_SPIT_COOLDOWN_CHALLENGE = 0.5f; GLOBAL constexpr float SPITBOY_SPIT_FORCE = 225.0f; GLOBAL Image gSpitBoyImage; GLOBAL Image gSpitImage; GLOBAL Sound gSpitBoySpitSound; GLOBAL Sound gSpitBoyHitSound; INTERNAL void InitSpitBoy () { LoadImage(gSpitBoyImage, "spitboy.bmp"); LoadImage(gSpitImage, "spit.bmp" ); LoadSound(gSpitBoySpitSound, "spit.wav" ); LoadSound(gSpitBoyHitSound, "hit.wav" ); } INTERNAL void QuitSpitBoy () { FreeImage(gSpitBoyImage ); FreeImage(gSpitImage ); FreeSound(gSpitBoySpitSound); FreeSound(gSpitBoyHitSound ); } INTERNAL void CreateSpitBoy (SpitBoy& spitboy, float x, float y, bool flip) { spitboy.state = SPITBOY_STATE_IDLE; spitboy.pos.x = x, spitboy.pos.y = y; spitboy.angle = DegToRad(270); spitboy.bounds = { 4,4,16,16 }; spitboy.flip = (flip) ? FLIP_VERT : FLIP_NONE; spitboy.timer = 0.0f; LoadAnimation(spitboy.anim[SPITBOY_STATE_IDLE], "spitboy-idle.anim"); LoadAnimation(spitboy.anim[SPITBOY_STATE_SPIT], "spitboy-spit.anim"); } INTERNAL void DeleteSpitBoy (SpitBoy& spitboy) { FreeAnimation(spitboy.anim[SPITBOY_STATE_IDLE]); FreeAnimation(spitboy.anim[SPITBOY_STATE_SPIT]); } INTERNAL void UpdateSpitBoy (SpitBoy& spitboy, float dt) { float ax = spitboy.pos.x + 12; float ay = spitboy.pos.y + 12; float bx = gGameState.dog.pos.x + gGameState.dog.bounds.x + (gGameState.dog.bounds.w/2); float by = gGameState.dog.pos.y + gGameState.dog.bounds.y + (gGameState.dog.bounds.h/2); float angle = atan2(ay - by, ax - bx); spitboy.sight = EntityLineOfSight(spitboy.pos,spitboy.bounds, gGameState.dog.pos,gGameState.dog.bounds, gWorld.current_map); if (spitboy.sight) spitboy.angle = angle; if (spitboy.timer > 0.0f) spitboy.timer -= dt; else { if (!gGameState.dog.dead) { if (spitboy.sight) { Vec2 pos = { ax-(8/2)-2, ay-(8/2)-2 }; Vec2 vel = { -SPITBOY_SPIT_FORCE, 0.0f }, nvel; float spit_angle = spitboy.angle; nvel.x = vel.x * cos(spit_angle) - vel.y * sin(spit_angle); nvel.y = vel.x * sin(spit_angle) + vel.y * cos(spit_angle); spitboy.timer = (gGameState.mode == GAME_MODE_NORMAL) ? SPITBOY_SPIT_COOLDOWN_NORMAL : SPITBOY_SPIT_COOLDOWN_CHALLENGE; spitboy.spit.push_back({ pos, nvel, { 2,2,4,4 }, false }); spitboy.state = SPITBOY_STATE_SPIT; LoadAnimation(spitboy.spit.back().anim, "spit.anim"); ResetAnimation(spitboy.anim[SPITBOY_STATE_SPIT]); PlaySound(gSpitBoySpitSound); } } } for (auto& spit: spitboy.spit) { if (!spit.dead) { Vec2 contact_normal = { 0,0 }; if (EntityAndMapCollision(spit.pos,spit.bounds,spit.vel, gWorld.current_map, contact_normal, dt)) { KillSpit(spit); continue; } spit.pos.x += spit.vel.x * dt; spit.pos.y += spit.vel.y * dt; } } // Reset the animation back to idle once the spitting animation is done. if (spitboy.state == SPITBOY_STATE_SPIT) { if (IsAnimationDone(spitboy.anim[SPITBOY_STATE_SPIT])) { spitboy.state = SPITBOY_STATE_IDLE; } } } INTERNAL void RenderSpitBoy (SpitBoy& spitboy, float dt) { // Draw the spit. for (auto& spit: spitboy.spit) { if (!spit.dead) { UpdateAnimation(spit.anim, dt); DrawImage(gSpitImage, spit.pos.x-spit.bounds.x, spit.pos.y-spit.bounds.y, FLIP_NONE, GetAnimationClip(spit.anim)); } } // Draw the spit boy. UpdateAnimation(spitboy.anim[spitboy.state], dt); DrawImage(gSpitBoyImage, spitboy.pos.x-spitboy.bounds.x, spitboy.pos.y-spitboy.bounds.y, spitboy.flip, GetAnimationClip(spitboy.anim[spitboy.state])); } INTERNAL void ResetSpitBoy (SpitBoy& spitboy) { ResetAnimation(spitboy.anim[SPITBOY_STATE_SPIT]); spitboy.state = SPITBOY_STATE_IDLE; spitboy.timer = 0.0f; spitboy.angle = DegToRad(270); for (auto& spit: spitboy.spit) FreeAnimation(spit.anim); spitboy.spit.clear(); } INTERNAL void KillSpit (Spit& spit) { CreateParticles(PARTICLE_TYPE_PUFF, (int)spit.pos.x+4,(int)spit.pos.y+4,(int)spit.pos.x+4,(int)spit.pos.y+4, 1,3); CreateParticles(PARTICLE_TYPE_SPEC, (int)spit.pos.x+4,(int)spit.pos.y+4,(int)spit.pos.x+4,(int)spit.pos.y+4, 2,4, 1.5f); spit.dead = true; PlaySound(gSpitBoyHitSound); }
33.578571
154
0.637311
JROB774
02c24077e8c5684c6146e41134409c4e54901ba8
1,643
cpp
C++
UVA/124.cpp
DT3264/ProgrammingContestsSolutions
a297f2da654c2ca2815b9aa375c2b4ca0052269d
[ "MIT" ]
null
null
null
UVA/124.cpp
DT3264/ProgrammingContestsSolutions
a297f2da654c2ca2815b9aa375c2b4ca0052269d
[ "MIT" ]
null
null
null
UVA/124.cpp
DT3264/ProgrammingContestsSolutions
a297f2da654c2ca2815b9aa375c2b4ca0052269d
[ "MIT" ]
null
null
null
// Problem : 124 - Following Orders // Contest : UVa Online Judge // URL : https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=60 // Memory Limit : 32 MB // Time Limit : 3000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include<bits/stdc++.h> #define f first #define s second #define ll long long #define vi vector<int> #define pii pair<int, int> using namespace std; template<class T> using v=vector<T>; int c2i(char c){ return c-'a'; } char i2c(int i){ return i+'a'; } vi actTopo; v<vi> adjList; vi inDegree; int n; void reset(){ adjList.assign(28, {}); inDegree.assign(28, -1); n=0; } void topo(int u, int pos){ actTopo[pos]=u; if(pos==n-1){ for(auto &x : actTopo) cout << i2c(x); cout << "\n"; return; } for(auto &v : adjList[u]){ inDegree[v]--; } for(int v=0; v<27; v++){ if(inDegree[v]==0){ inDegree[v]=-1; topo(v, pos+1); inDegree[v]=0; } } for(auto &v : adjList[u]){ inDegree[v]++; } } int main(){ /*ios_base::sync_with_stdio(0); cin.tie(0);//*/ string s1, s2; int actCase=1; while(getline(cin, s1)){ getline(cin, s2); if(actCase++>1) cout << "\n"; reset(); for(int i=0; i<s1.size(); i+=2){ int u=c2i(s1[i]); inDegree[u]=0; n++; } actTopo.resize(n); for(int i=0; i<s2.size(); i+=4){ int u=c2i(s2[i]); int v=c2i(s2[i+2]); adjList[u].push_back(v); inDegree[v]++; } for(int i=0; i<27; i++){ if(inDegree[i]==0){ inDegree[i]=-1; topo(i, 0); inDegree[i]=0; } } } return 0; }
19.329412
115
0.561169
DT3264
02c4c1046a83b0ee07725f6d2aae34f2e575b2cc
823
cc
C++
net/test/webServer.cc
RaKiRaKiRa/Cyclone
0f6a9defa01c752afb1bf27aad57ed4c1a1ee1ea
[ "Apache-2.0" ]
8
2019-07-05T09:12:28.000Z
2022-03-02T11:38:10.000Z
net/test/webServer.cc
RaKiRaKiRa/Cyclone
0f6a9defa01c752afb1bf27aad57ed4c1a1ee1ea
[ "Apache-2.0" ]
null
null
null
net/test/webServer.cc
RaKiRaKiRa/Cyclone
0f6a9defa01c752afb1bf27aad57ed4c1a1ee1ea
[ "Apache-2.0" ]
5
2019-07-12T14:23:55.000Z
2022-03-02T11:38:09.000Z
/********************************************************** * Author : RaKiRaKiRa * Email : 763600693@qq.com * Create time : 2019-09-05 18:10 * Last modified : 2020-02-08 15:58 * Filename : webServer.cc * Description : **********************************************************/ #include "../Httpserver.h" #include "../EventLoop.h" #include "../base/AsyncLogging.h" #include "../base/Daemon.h" AsyncLogging *logptr = NULL; void output(const char* logline, int len) { logptr -> append(logline, len); } int main() { Daemon(); logptr = new AsyncLogging("log", 50*1024*1000); Logger::setOutput(output); logptr -> start(); setLogLevel(Logger::INFO); EventLoop loop; sockaddr_in lis = fromPort(80); httpServer myServer(&loop, lis, 2, 60); myServer.start(); loop.loop(); }
24.205882
60
0.54678
RaKiRaKiRa
02c536ef6136bcda3b12c3b0f09099025ef14721
2,592
cc
C++
src/ast/block_statement_test.cc
jhanssen/tint
30c1f25a7a4e180419444c12046348edb0f8fdd0
[ "Apache-2.0" ]
null
null
null
src/ast/block_statement_test.cc
jhanssen/tint
30c1f25a7a4e180419444c12046348edb0f8fdd0
[ "Apache-2.0" ]
null
null
null
src/ast/block_statement_test.cc
jhanssen/tint
30c1f25a7a4e180419444c12046348edb0f8fdd0
[ "Apache-2.0" ]
null
null
null
// Copyright 2020 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "src/ast/block_statement.h" #include <memory> #include <sstream> #include "src/ast/discard_statement.h" #include "src/ast/if_statement.h" #include "src/ast/test_helper.h" namespace tint { namespace ast { namespace { using BlockStatementTest = TestHelper; TEST_F(BlockStatementTest, Creation) { auto* d = create<DiscardStatement>(); auto* ptr = d; auto* b = create<BlockStatement>(StatementList{d}); ASSERT_EQ(b->size(), 1u); EXPECT_EQ((*b)[0], ptr); } TEST_F(BlockStatementTest, Creation_WithSource) { auto* b = create<BlockStatement>(Source{Source::Location{20, 2}}, ast::StatementList{}); auto src = b->source(); EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); } TEST_F(BlockStatementTest, IsBlock) { auto* b = create<BlockStatement>(ast::StatementList{}); EXPECT_TRUE(b->Is<BlockStatement>()); } TEST_F(BlockStatementTest, IsValid) { auto* b = create<BlockStatement>(ast::StatementList{ create<DiscardStatement>(), }); EXPECT_TRUE(b->IsValid()); } TEST_F(BlockStatementTest, IsValid_Empty) { auto* b = create<BlockStatement>(ast::StatementList{}); EXPECT_TRUE(b->IsValid()); } TEST_F(BlockStatementTest, IsValid_NullBodyStatement) { auto* b = create<BlockStatement>(ast::StatementList{ create<DiscardStatement>(), nullptr, }); EXPECT_FALSE(b->IsValid()); } TEST_F(BlockStatementTest, IsValid_InvalidBodyStatement) { auto* b = create<BlockStatement>( ast::StatementList{ create<IfStatement>(nullptr, create<BlockStatement>(StatementList{}), ElseStatementList{}), }); EXPECT_FALSE(b->IsValid()); } TEST_F(BlockStatementTest, ToStr) { auto* b = create<BlockStatement>(ast::StatementList{ create<DiscardStatement>(), }); std::ostringstream out; b->to_str(out, 2); EXPECT_EQ(out.str(), R"( Block{ Discard{} } )"); } } // namespace } // namespace ast } // namespace tint
25.92
79
0.688272
jhanssen
02c5c94280faab795547faba65b362b43891ccd6
2,643
cpp
C++
src/union-find/src/UnionFind.cpp
karz0n/algorithms
b2a08ba990c7e4f078eb7bf3c90d050eb38de9d8
[ "MIT" ]
1
2020-04-18T14:34:16.000Z
2020-04-18T14:34:16.000Z
src/union-find/src/UnionFind.cpp
karz0n/algorithms
b2a08ba990c7e4f078eb7bf3c90d050eb38de9d8
[ "MIT" ]
null
null
null
src/union-find/src/UnionFind.cpp
karz0n/algorithms
b2a08ba990c7e4f078eb7bf3c90d050eb38de9d8
[ "MIT" ]
null
null
null
/** * This program is free software: you can redistribute it and/or modify * it under the terms of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT WARRANTY OF ANY KIND; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MIT License for more details. */ /** * @file UnionFind.cpp * * @brief Union-find algorithm implementation * * @author Denys Asauliak * Contact: d.asauliak@gmail.com */ #include "UnionFind.hpp" #include <algorithm> #include <utility> #include <stdexcept> namespace algorithms { UnionFind::UnionFind() : _count{0} { } UnionFind::UnionFind(std::size_t count) : _count{0} { reset(count); } UnionFind::UnionFind(UnionFind&& other) noexcept : _container{std::move(other._container)} , _size{std::move(other._size)} , _count{other._count} { other._count = 0; } UnionFind& UnionFind::operator=(UnionFind&& other) { if (this != &other) { std::swap(_container, other._container); std::swap(_size, other._size); std::swap(_count, other._count); } return *this; } std::size_t UnionFind::find(std::size_t p) { #ifndef NDEBUG validate(p); #endif std::size_t root = p; // Finds root of p site while (root != _container[root]) { root = _container[root]; } // Compress the path while (p != root) { std::size_t np = _container[p]; _container[p] = root; p = np; } return root; } std::size_t UnionFind::count() const { return _count; } void UnionFind::reset(std::size_t count) { _container.resize(count); _size.resize(count); for (auto i = 0; i < count; ++i) { _container[i] = i; _size[i] = 1; } } bool UnionFind::connected(std::size_t p, std::size_t q) { return find(p) == find(q); } void UnionFind::associate(std::size_t p, std::size_t q) { std::size_t proot = find(p); std::size_t qroot = find(q); if (proot == qroot) { return; } // Make smaller root point to larger one if (_size[proot] < _size[qroot]) { _container[proot] = qroot; _size[qroot] += _size[proot]; } else { _container[qroot] = proot; _size[proot] += _size[qroot]; } _count--; } #ifndef NDEBUG void UnionFind::validate(std::size_t p) const { std::size_t size = _container.size(); if (p >= size) { throw std::out_of_range("index " + std::to_string(p) + " is not between 0 and " + std::to_string(size - 1)); } } #endif } // namespace algorithms
19.152174
87
0.608021
karz0n
02c852c25c49031ac9cb4f626db31129e7d62729
310
cpp
C++
src/homework/01_variables/main.cpp
acc-cosc-1337-spring-2022/acc-cosc-1337-spring-2022-Adrian-men
29d07a70d05fd1ad10e6b5b8ff8b457dd97e2833
[ "MIT" ]
null
null
null
src/homework/01_variables/main.cpp
acc-cosc-1337-spring-2022/acc-cosc-1337-spring-2022-Adrian-men
29d07a70d05fd1ad10e6b5b8ff8b457dd97e2833
[ "MIT" ]
null
null
null
src/homework/01_variables/main.cpp
acc-cosc-1337-spring-2022/acc-cosc-1337-spring-2022-Adrian-men
29d07a70d05fd1ad10e6b5b8ff8b457dd97e2833
[ "MIT" ]
null
null
null
//write include statements #include <iostream> //write namespace using statement for cout using std::cout; using std::cin; int main() { int num; cin >> num; int multiply_numbers(int num); return num; cout << num; int num1; num1 = 4; multiply_numbers(num1); return num1; cout<<num1; return 0; }
13.478261
42
0.683871
acc-cosc-1337-spring-2022
02ca731b66c89dc720bf429366664ef61a9a837d
2,640
hpp
C++
src/mesh/nodal_coordinates.hpp
annierhea/neon
4eb51a06bda6bbf32c54fff8f39c9e02d429cfd1
[ "MIT" ]
null
null
null
src/mesh/nodal_coordinates.hpp
annierhea/neon
4eb51a06bda6bbf32c54fff8f39c9e02d429cfd1
[ "MIT" ]
null
null
null
src/mesh/nodal_coordinates.hpp
annierhea/neon
4eb51a06bda6bbf32c54fff8f39c9e02d429cfd1
[ "MIT" ]
null
null
null
#pragma once #include "numeric/dense_matrix.hpp" #include "numeric/index_types.hpp" #include "io/json.hpp" namespace neon { /** nodal_coordinates.hpp stores the list of coordinates of a discretized geometry */ class nodal_coordinates { public: nodal_coordinates() = default; /** Construct with a list of coordinates */ explicit nodal_coordinates(matrix3x const coordinates); /** Construct with a list of coordinates in json format */ explicit nodal_coordinates(json const& mesh_file); [[nodiscard]] auto size() const { return X.cols(); } [[nodiscard]] matrix3x const& coordinates() const { return X; } /** @return the coordinates using fancy indexing */ template <typename indices_type> [[nodiscard]] auto coordinates(indices_type const local_node_view) const { return X(Eigen::placeholders::all, local_node_view); } protected: matrix3x X; //!< Reference configuration encoded as (x1, y1, z1, x2, y2, z2) }; /** * */ template <typename traits> class mesh_coordinates { /** fixed size coordinates depending on the mathematical model */ static auto constexpr fixed_size = traits::size; using coordinate_t = Eigen::Matrix<double, fixed_size, Eigen::Dynamic>; public: /** Construct with a list of coordinates */ explicit mesh_coordinates(coordinate_t const coordinates); /** Construct with a list of coordinates in json format */ explicit mesh_coordinates(json const& mesh_file); [[nodiscard]] auto size() const { return X.cols(); } [[nodiscard]] coordinate_t const& coordinates() const { return X; } /** @return the coordinates using fancy indexing */ [[nodiscard]] coordinate_t coordinates(index_view local_node_view) const { return X(Eigen::placeholders::all, local_node_view); } protected: coordinate_t X; //!< Reference configuration encoded as (x1, y1, z1, x2, y2, z2) }; template <typename traits> mesh_coordinates<traits>::mesh_coordinates(mesh_coordinates::coordinate_t coordinates) : X(coordinates) { } template <typename traits> mesh_coordinates<traits>::mesh_coordinates(json const& mesh_file) { if (mesh_file["Nodes"].is_null()) { throw std::domain_error("The mesh file is missing the \"Nodes\" field"); } auto const& input_coordinates = mesh_file["Nodes"][0]["Coordinates"]; auto const nodes = input_coordinates.size(); X.resize(fixed_size, nodes); for (std::int64_t node{0}; node < nodes; ++node) { for (auto i{0}; i < fixed_size; ++i) { X(i, node) = input_coordinates[node][i]; } } } }
26.666667
86
0.680303
annierhea
02ca886c86cfc24228bc2ac9f0fc420ac8bda190
982
hpp
C++
src/Point.hpp
kmdrGroch/math-essentials
522de57f2449bbbd5cad3cd735c55fbe000dbd55
[ "MIT" ]
null
null
null
src/Point.hpp
kmdrGroch/math-essentials
522de57f2449bbbd5cad3cd735c55fbe000dbd55
[ "MIT" ]
null
null
null
src/Point.hpp
kmdrGroch/math-essentials
522de57f2449bbbd5cad3cd735c55fbe000dbd55
[ "MIT" ]
null
null
null
#pragma once #include "preprocessor.hpp" #include "Vector2D.hpp" #include "Vector3D.hpp" #include "utils.hpp" class Point { public: double x; double y; double z; public: _CExp Point() : x(0), y(0), z(0) {} _Ex _CExp Point(double X, double Y, double Z = 0) : x(X), y(X), z(Z) {} _Ex _CExp Point(const Vector2D& v) : x(v.x), y(v.y), z(0) {} _Ex _CExp Point(const Vector3D& v) : x(v.x), y(v.y), z(v.z) {} _NoD _CExp Point operator+(const Vector3D& v) const _NoE { return Point(x + v.x, y + v.y, z + v.z); } _NoD _CExp Point operator-(const Vector3D& v) const _NoE { return Point(x - v.x, y - v.y, z - v.z); } _NoD _CExp Point operator+(const Vector2D& v) const _NoE { return Point(x + v.x, y + v.y, z); } _NoD _CExp Point operator-(const Vector2D& v) const _NoE { return Point(x - v.x, y - v.y, z); } _NoD _CExp bool operator==(const Point& p) const _NoE { return equalsEpsilon(x, p.x) && equalsEpsilon(y, p.y) && equalsEpsilon(z, p.z); } };
23.380952
72
0.61609
kmdrGroch
02cac9ab3261f69087a19304e271405a16888403
2,369
cpp
C++
source/device/Curves.cpp
xzrunner/terr
f3c03776d7a415c73c8f985132c60526e830a96a
[ "MIT" ]
null
null
null
source/device/Curves.cpp
xzrunner/terr
f3c03776d7a415c73c8f985132c60526e830a96a
[ "MIT" ]
null
null
null
source/device/Curves.cpp
xzrunner/terr
f3c03776d7a415c73c8f985132c60526e830a96a
[ "MIT" ]
null
null
null
#include "terraingraph/device/Curves.h" #include "terraingraph/DeviceHelper.h" #include "terraingraph/HeightFieldEval.h" #include "terraingraph/Context.h" #include <heightfield/HeightField.h> namespace terraingraph { namespace device { void Curves::Execute(const std::shared_ptr<dag::Context>& ctx) { auto prev_hf = DeviceHelper::GetInputHeight(*this, 0); if (!prev_hf) { return; } m_hf = std::make_shared<hf::HeightField>(*prev_hf); if (m_ctrl_pts.empty()) { return; } auto& dev = *std::static_pointer_cast<Context>(ctx)->ur_dev; int32_t min, max; CalcHeightRegion(dev, *m_hf, min, max); if (min == max) { return; } auto vals = m_hf->GetValues(dev); for (auto& v : vals) { float v01 = CalcHeight(static_cast<float>(v - min) / (max - min)); v = static_cast<int32_t>(v01 * (max - min) + min); } m_hf->SetValues(vals); } float Curves::CalcHeight(float h) const { if (m_ctrl_pts.empty()) { return h; } assert(m_type == Type::Linear); assert(h >= 0 && h <= 1); auto calc = [](const sm::vec2& begin, const sm::vec2& end, float h) -> float { assert(h >= begin.x && h <= end.x); if (begin.x == end.x) { return (begin.y + end.y) * 0.5f; } else { return (h - begin.x) / (end.x - begin.x) * (end.y - begin.y) + begin.y; } }; if (h >= 0 && h < m_ctrl_pts.front().x) { return calc(sm::vec2(0, 0), m_ctrl_pts.front(), h); } else if (h >= m_ctrl_pts.back().x) { assert(h <= 1); return calc(m_ctrl_pts.back(), sm::vec2(1, 1), h); } else { for (size_t i = 0, n = m_ctrl_pts.size(); i < n - 1; ++i) { if (h >= m_ctrl_pts[i].x && h < m_ctrl_pts[i + 1].x) { return calc(m_ctrl_pts[i], m_ctrl_pts[i + 1], h); } } } assert(0); return h; } void Curves::CalcHeightRegion(const ur::Device& dev, const hf::HeightField& hf, int32_t& min, int32_t& max) { min = std::numeric_limits<int32_t>::max(); max = -std::numeric_limits<int32_t>::max(); auto& vals = hf.GetValues(dev); for (auto& v : vals) { if (v < min) { min = v; } if (v > max) { max = v; } } } } }
23.69
83
0.52385
xzrunner
c49d543aee5845e9a85e6cbe1c58a43d9c81373f
753
cpp
C++
2021.09.22-Lesson-3/Project6/Source.cpp
021213/programming-c-eng--2021-autumn
84ff4e86e7b4ee68d5bfd83ef6388a1f3e762348
[ "Apache-2.0" ]
null
null
null
2021.09.22-Lesson-3/Project6/Source.cpp
021213/programming-c-eng--2021-autumn
84ff4e86e7b4ee68d5bfd83ef6388a1f3e762348
[ "Apache-2.0" ]
null
null
null
2021.09.22-Lesson-3/Project6/Source.cpp
021213/programming-c-eng--2021-autumn
84ff4e86e7b4ee68d5bfd83ef6388a1f3e762348
[ "Apache-2.0" ]
null
null
null
#include<iostream> using namespace std; struct Complex { //fields int re; int im; //constructor Complex() //default constructor { this->re = 0; this->im = 0; } Complex(int re, int im) //parametrized constructor { this->re = re; this->im = im; } Complex(const Complex& z) //copying constructor { this->re = z.re; this->im = z.im; } //destructor ~Complex() { } //methods void print() { cout << re; if (im < 0) { cout << " - " << -im; } else { cout << " + " << im; } cout << " * i" << endl; } }; void printComplexNumber(Complex z) { z.print(); } int main(int argc, char* argv[]) { Complex z(2, 3); printComplexNumber(z); int* a = new int[100]{ 0 }; delete[] a; return EXIT_SUCCESS; }
11.584615
51
0.555113
021213
c4a09be07aeac7f806e8761c0de0fcdcd4d57a79
1,971
cpp
C++
2019/Solutions/Day08.cpp
lukaspirkl/AdventOfCode
e7bf299cc5341b972dd30c3aa4e212da74abfb83
[ "MIT" ]
null
null
null
2019/Solutions/Day08.cpp
lukaspirkl/AdventOfCode
e7bf299cc5341b972dd30c3aa4e212da74abfb83
[ "MIT" ]
null
null
null
2019/Solutions/Day08.cpp
lukaspirkl/AdventOfCode
e7bf299cc5341b972dd30c3aa4e212da74abfb83
[ "MIT" ]
null
null
null
#include "pch.h" #include "aoc.h" #define NAME Day08__Space_Image_Format namespace { TEST(NAME, InputA) { std::string input = aoc::readInputFile("Day08.txt").str(); std::vector<std::vector<int>> layers(input.size()/(25*6), std::vector<int>(25*6)); for (size_t i = 0; i < input.size(); i++) { size_t layer = i / (25 * 6); size_t pixel = i % (25 * 6); layers[layer][pixel] = (int)input[i] - 48; //ASCII numeric character } size_t fewestZeroCount = std::numeric_limits<size_t>::max(); size_t fewestZeroLayer = 0; for (size_t i = 0; i < layers.size(); i++) { size_t zeroCount = std::count(layers[i].begin(), layers[i].end(), 0); if (fewestZeroCount > zeroCount) { fewestZeroLayer = i; fewestZeroCount = zeroCount; } } size_t oneCount = std::count(layers[fewestZeroLayer].begin(), layers[fewestZeroLayer].end(), 1); size_t twoCount = std::count(layers[fewestZeroLayer].begin(), layers[fewestZeroLayer].end(), 2); EXPECT_EQ(oneCount * twoCount, 2250); } TEST(NAME, InputB) { std::string input = aoc::readInputFile("Day08.txt").str(); std::vector<std::vector<int>> layers(input.size() / (25 * 6), std::vector<int>(25 * 6)); for (size_t i = 0; i < input.size(); i++) { size_t layer = i / (25 * 6); size_t pixel = i % (25 * 6); layers[layer][pixel] = (int)input[i] - 48; //ASCII numeric character } std::stringstream ss; for (size_t pixel = 0; pixel < 25*6; pixel++) { if (pixel % 25 == 0) { ss << '\n'; } for (size_t layer = 0; layer < layers.size(); layer++) { int color = layers[layer][pixel]; if (color == 0) { ss << ' '; break; } else if (color == 1) { ss << 'X'; break; } } } std::string expected = R"( XXXX X X XX X X X X X X X X X X XXX XXXX X X X X X X X X X X X X X X X X X X X X X X XX XX XXXX )"; EXPECT_EQ(ss.str(), expected); } }
22.397727
98
0.563166
lukaspirkl
c4a5ecd747786bf21383ad5a76bc1f7aa7d8a123
552
cpp
C++
codes/moderncpp/is_reference/is_rvalue_reference01/main.cpp
eric2003/ModernCMake
48fe5ed2f25481a7c93f86af38a692f4563afcaa
[ "MIT" ]
3
2022-01-25T07:33:43.000Z
2022-03-30T10:25:09.000Z
codes/moderncpp/is_reference/is_rvalue_reference01/main.cpp
eric2003/ModernCMake
48fe5ed2f25481a7c93f86af38a692f4563afcaa
[ "MIT" ]
null
null
null
codes/moderncpp/is_reference/is_rvalue_reference01/main.cpp
eric2003/ModernCMake
48fe5ed2f25481a7c93f86af38a692f4563afcaa
[ "MIT" ]
2
2022-01-17T13:39:12.000Z
2022-03-30T10:25:12.000Z
#include <iostream> #include <type_traits> class A {}; int main( int argc, char **argv ) { { //static_assert( std::is_rvalue_reference_v<A> ); static_assert( not std::is_rvalue_reference_v<A> ); static_assert( not std::is_rvalue_reference_v<A&> ); static_assert( std::is_rvalue_reference_v<A&&> ); static_assert( not std::is_rvalue_reference_v<int> ); static_assert( not std::is_rvalue_reference_v<int&> ); static_assert( std::is_rvalue_reference_v<int&&> ); } return 0; }
27.6
63
0.637681
eric2003
c4a5f174d7a92b2d46df84e84149afefb4802a92
23,799
cc
C++
src/gb/render/mesh_test.cc
jpursey/game-bits
2daefa2cef5601939dbea50a755b8470e38656ae
[ "MIT" ]
null
null
null
src/gb/render/mesh_test.cc
jpursey/game-bits
2daefa2cef5601939dbea50a755b8470e38656ae
[ "MIT" ]
2
2021-12-10T13:38:51.000Z
2022-02-22T16:02:24.000Z
src/gb/render/mesh_test.cc
jpursey/game-bits
2daefa2cef5601939dbea50a755b8470e38656ae
[ "MIT" ]
null
null
null
// Copyright (c) 2020 John Pursey // // Use of this source code is governed by an MIT-style License that can be found // in the LICENSE file or at https://opensource.org/licenses/MIT. #include "gb/render/mesh.h" #include "gb/render/render_test.h" #include "gb/render/test_render_buffer.h" #include "gmock/gmock.h" #include "gtest/gtest.h" namespace gb { namespace { class MeshTest : public RenderTest { protected: // A cube, CCW faces const std::vector<Vector3> kCubeVertices = { {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}, }; const std::vector<Triangle> kCubeTriangles = { {5, 1, 2}, {2, 6, 5}, {0, 4, 7}, {7, 3, 0}, {3, 7, 6}, {6, 2, 3}, {0, 1, 5}, {5, 3, 0}, {4, 5, 6}, {6, 7, 4}, {1, 0, 3}, {3, 2, 1}, }; const std::vector<uint16_t> kCubeIndices = { 5, 1, 2, 2, 6, 5, 0, 4, 7, 7, 3, 0, 3, 7, 6, 6, 2, 3, 0, 1, 5, 5, 3, 0, 4, 5, 6, 6, 7, 4, 1, 0, 3, 3, 2, 1, }; }; TEST_F(MeshTest, CreateAsResourcePtr) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); ResourcePtr<Mesh> mesh = render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 3, 1); ASSERT_NE(mesh, nullptr); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, CreateInResourceSet) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); ResourceSet resource_set; Mesh* mesh = render_system_->CreateMesh(&resource_set, material, DataVolatility::kStaticWrite, 64 * 1024 - 1, 128 * 1024); ASSERT_NE(mesh, nullptr); EXPECT_EQ(resource_set.Get<Shader>( material->GetType()->GetVertexShader()->GetResourceId()), material->GetType()->GetVertexShader()); EXPECT_EQ(resource_set.Get<Shader>( material->GetType()->GetFragmentShader()->GetResourceId()), material->GetType()->GetFragmentShader()); EXPECT_EQ( resource_set.Get<MaterialType>(material->GetType()->GetResourceId()), material->GetType()); EXPECT_EQ(resource_set.Get<Material>(material->GetResourceId()), material); EXPECT_EQ(resource_set.Get<Mesh>(mesh->GetResourceId()), mesh); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, FailCreate) { CreateSystem(); // Invalid material. EXPECT_EQ( render_system_->CreateMesh(nullptr, DataVolatility::kStaticWrite, 30, 30), nullptr); // Invalid number of vertices. auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); EXPECT_EQ( render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 0, 30), nullptr); EXPECT_EQ( render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 1, 30), nullptr); EXPECT_EQ( render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 2, 30), nullptr); EXPECT_EQ(render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 64 * 1024, 30), nullptr); // Invalid number of indices. EXPECT_EQ( render_system_->CreateMesh(nullptr, DataVolatility::kStaticWrite, 30, 0), nullptr); // Fail vertex buffer creation. state_.fail_create_vertex_buffer = true; EXPECT_EQ(render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 30, 30), nullptr); // Fail index buffer creation. state_.ResetState(); state_.fail_create_index_buffer = true; EXPECT_EQ(render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 30, 30), nullptr); EXPECT_EQ(state_.invalid_call_count, 0); } TEST_F(MeshTest, Properties) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh( material, DataVolatility::kStaticReadWrite, 30, 60); ASSERT_NE(mesh, nullptr); EXPECT_EQ(mesh->GetMaterial(), material); EXPECT_EQ(mesh->GetVolatility(), DataVolatility::kStaticReadWrite); EXPECT_EQ(mesh->GetVertexCount(), 0); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 0); EXPECT_EQ(mesh->GetTriangleCapacity(), 60); RenderBuffer* vertex_buffer = mesh->GetVertexBuffer(GetAccessToken()); ASSERT_NE(vertex_buffer, nullptr); EXPECT_EQ(vertex_buffer->GetVolatility(), DataVolatility::kStaticReadWrite); EXPECT_EQ(vertex_buffer->GetValueSize(), sizeof(Vector3)); EXPECT_EQ(vertex_buffer->GetCapacity(), 30); EXPECT_EQ(vertex_buffer->GetSize(), 0); RenderBuffer* index_buffer = mesh->GetIndexBuffer(GetAccessToken()); ASSERT_NE(index_buffer, nullptr); EXPECT_EQ(index_buffer->GetVolatility(), DataVolatility::kStaticReadWrite); EXPECT_EQ(index_buffer->GetValueSize(), sizeof(uint16_t)); EXPECT_EQ(index_buffer->GetCapacity(), 180); EXPECT_EQ(index_buffer->GetSize(), 0); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(vertex_buffer); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(index_buffer); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, SetWithTriangles) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 10, 14); ASSERT_NE(mesh, nullptr); TestRenderBuffer* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); TestRenderBuffer* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 10); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 14); ASSERT_EQ(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); ASSERT_EQ(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeTriangles.data(), kCubeTriangles.size() * sizeof(Triangle)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Explicitly grow the capacity with the same data. EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles, 15, 20)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 15); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 20); EXPECT_NE(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); EXPECT_NE(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeTriangles.data(), kCubeTriangles.size() * sizeof(Triangle)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Implicitly grow the capacity based on the actual data. std::vector<Vector3> vertices(30, Vector3{100, 100, 100}); std::vector<Triangle> triangles(40, Triangle{10, 10, 10}); EXPECT_TRUE(mesh->Set<Vector3>(vertices, triangles)); EXPECT_EQ(mesh->GetVertexCount(), 30); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 40); EXPECT_EQ(mesh->GetTriangleCapacity(), 40); EXPECT_NE(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), vertices.data(), vertices.size() * sizeof(Vector3)), 0); EXPECT_NE(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), triangles.data(), triangles.size() * sizeof(Triangle)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Shrink back to a cube. EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 40); ASSERT_EQ(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); ASSERT_EQ(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeTriangles.data(), kCubeTriangles.size() * sizeof(Triangle)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 2); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 2); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(state_.invalid_call_count, 0); } TEST_F(MeshTest, SetWithIndices) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 10, 14); ASSERT_NE(mesh, nullptr); TestRenderBuffer* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); TestRenderBuffer* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 10); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 14); ASSERT_EQ(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); ASSERT_EQ(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeIndices.data(), kCubeIndices.size() * sizeof(uint16_t)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Explicitly grow the capacity with the same data. EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices, 15, 20)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 15); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 20); EXPECT_NE(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); EXPECT_NE(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeIndices.data(), kCubeIndices.size() * sizeof(uint16_t)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Implicitly grow the capacity based on the actual data. std::vector<Vector3> vertices(30, Vector3{100, 100, 100}); std::vector<uint16_t> indices(120, 10); EXPECT_TRUE(mesh->Set<Vector3>(vertices, indices)); EXPECT_EQ(mesh->GetVertexCount(), 30); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 40); EXPECT_EQ(mesh->GetTriangleCapacity(), 40); EXPECT_NE(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); ASSERT_NE(test_vertex_buffer, nullptr); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), vertices.data(), vertices.size() * sizeof(Vector3)), 0); EXPECT_NE(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); ASSERT_NE(test_index_buffer, nullptr); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), indices.data(), indices.size() * sizeof(uint16_t)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 1); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 1); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); // Shrink back to a cube. EXPECT_TRUE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices)); EXPECT_EQ(mesh->GetVertexCount(), 8); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 12); EXPECT_EQ(mesh->GetTriangleCapacity(), 40); ASSERT_EQ(mesh->GetVertexBuffer(GetAccessToken()), test_vertex_buffer); EXPECT_EQ(test_vertex_buffer->GetSize(), mesh->GetVertexCount()); EXPECT_EQ(test_vertex_buffer->GetCapacity(), mesh->GetVertexCapacity()); EXPECT_EQ(std::memcmp(test_vertex_buffer->GetData(), kCubeVertices.data(), kCubeVertices.size() * sizeof(Vector3)), 0); ASSERT_EQ(mesh->GetIndexBuffer(GetAccessToken()), test_index_buffer); EXPECT_EQ(test_index_buffer->GetSize(), mesh->GetTriangleCount() * 3); EXPECT_EQ(test_index_buffer->GetCapacity(), mesh->GetTriangleCapacity() * 3); EXPECT_EQ(std::memcmp(test_index_buffer->GetData(), kCubeIndices.data(), kCubeIndices.size() * sizeof(uint16_t)), 0); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 2); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(test_index_buffer->GetModifyCount(), 2); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); EXPECT_EQ(state_.invalid_call_count, 0); } TEST_F(MeshTest, FailSet) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 30, 60); ASSERT_NE(mesh, nullptr); ASSERT_TRUE(mesh->Set<Vector3>({kCubeVertices.data(), 3}, {kCubeTriangles.data(), 3})); state_.vertex_buffer_config.fail_set = true; EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles)); EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices)); EXPECT_EQ(mesh->GetVertexCount(), 0); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 0); EXPECT_EQ(mesh->GetTriangleCapacity(), 60); state_.ResetState(); ASSERT_TRUE(mesh->Set<Vector3>({kCubeVertices.data(), 3}, {kCubeTriangles.data(), 3})); state_.index_buffer_config.fail_set = true; EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles)); EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices)); EXPECT_EQ(mesh->GetVertexCount(), 0); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 0); EXPECT_EQ(mesh->GetTriangleCapacity(), 60); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 4); // 4 because failing the index buffer happens second. EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 2); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, EditPreventsModification) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh( material, DataVolatility::kStaticReadWrite, 30, 60); ASSERT_NE(mesh, nullptr); auto view = mesh->Edit(); EXPECT_NE(view, nullptr); EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeTriangles)); EXPECT_FALSE(mesh->Set<Vector3>(kCubeVertices, kCubeIndices)); EXPECT_EQ(mesh->GetVertexCount(), 0); EXPECT_EQ(mesh->GetVertexCapacity(), 30); EXPECT_EQ(mesh->GetTriangleCount(), 0); EXPECT_EQ(mesh->GetTriangleCapacity(), 60); view.reset(); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, CannotEditStaticWrite) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh(material, DataVolatility::kStaticWrite, 30, 60); ASSERT_NE(mesh, nullptr); EXPECT_EQ(mesh->Edit(), nullptr); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } TEST_F(MeshTest, FailEdit) { CreateSystem(); auto material = CreateMaterial({}); EXPECT_NE(material, nullptr); auto mesh = render_system_->CreateMesh( material, DataVolatility::kStaticReadWrite, 30, 60); ASSERT_NE(mesh, nullptr); state_.vertex_buffer_config.fail_edit_begin = true; EXPECT_EQ(mesh->Edit(), nullptr); state_.ResetState(); state_.index_buffer_config.fail_edit_begin = true; EXPECT_EQ(mesh->Edit(), nullptr); state_.ResetState(); auto view = mesh->Edit(); EXPECT_NE(view, nullptr); EXPECT_EQ(mesh->Edit(), nullptr); view.reset(); EXPECT_EQ(state_.invalid_call_count, 0); auto* test_vertex_buffer = static_cast<TestRenderBuffer*>(mesh->GetVertexBuffer(GetAccessToken())); EXPECT_EQ(test_vertex_buffer->GetModifyCount(), 0); EXPECT_EQ(test_vertex_buffer->GetInvalidCallCount(), 0); auto* test_index_buffer = static_cast<TestRenderBuffer*>(mesh->GetIndexBuffer(GetAccessToken())); EXPECT_EQ(test_index_buffer->GetModifyCount(), 0); EXPECT_EQ(test_index_buffer->GetInvalidCallCount(), 0); } } // namespace } // namespace gb
42.122124
80
0.710618
jpursey
c4a6a1791786ba74da0d8e8cf4492ad7b3b57cb4
9,875
cpp
C++
src/oatpp/core/async/Coroutine.cpp
BossZou/oatpp
689d8bd8e03cc7a06aa5f273663d309888c399ed
[ "Apache-2.0" ]
null
null
null
src/oatpp/core/async/Coroutine.cpp
BossZou/oatpp
689d8bd8e03cc7a06aa5f273663d309888c399ed
[ "Apache-2.0" ]
null
null
null
src/oatpp/core/async/Coroutine.cpp
BossZou/oatpp
689d8bd8e03cc7a06aa5f273663d309888c399ed
[ "Apache-2.0" ]
null
null
null
/*************************************************************************** * * Project _____ __ ____ _ _ * ( _ ) /__\ (_ _)_| |_ _| |_ * )(_)( /(__)\ )( (_ _)(_ _) * (_____)(__)(__)(__) |_| |_| * * * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ***************************************************************************/ #include "Coroutine.hpp" namespace oatpp { namespace async { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Action Action Action::clone(const Action& action) { Action result(action.m_type); result.m_data = action.m_data; return result; } Action Action::createActionByType(v_int32 type) { return Action(type); } Action Action::createIOWaitAction(data::v_io_handle ioHandle, Action::IOEventType ioEventType) { Action result(TYPE_IO_WAIT); result.m_data.ioData.ioHandle = ioHandle; result.m_data.ioData.ioEventType = ioEventType; return result; } Action Action::createIORepeatAction(data::v_io_handle ioHandle, Action::IOEventType ioEventType) { Action result(TYPE_IO_REPEAT); result.m_data.ioData.ioHandle = ioHandle; result.m_data.ioData.ioEventType = ioEventType; return result; } Action Action::createWaitRepeatAction(v_int64 timePointMicroseconds) { Action result(TYPE_WAIT_REPEAT); result.m_data.timePointMicroseconds = timePointMicroseconds; return result; } Action Action::createWaitListAction(CoroutineWaitList* waitList) { Action result(TYPE_WAIT_LIST); result.m_data.waitList = waitList; return result; } Action::Action(AbstractCoroutine* coroutine) : m_type(TYPE_COROUTINE) { m_data.coroutine = coroutine; } Action::Action(const FunctionPtr& functionPtr) : m_type(TYPE_YIELD_TO) { m_data.fptr = functionPtr; } Action::Action(Error* error) : m_type(TYPE_ERROR) { m_data.error = error; } Action::Action(v_int32 type) : m_type(type) {} Action::Action(Action&& other) : m_type(other.m_type) , m_data(other.m_data) { other.m_type = TYPE_NONE; } Action::~Action() { free(); } void Action::free() { switch(m_type) { case TYPE_COROUTINE: delete m_data.coroutine; break; case TYPE_ERROR: delete m_data.error; break; } m_type = TYPE_NONE; } Action& Action::operator=(Action&& other) { free(); m_type = other.m_type; m_data = other.m_data; other.m_data.fptr = nullptr; return *this; } bool Action::isError() const { return m_type == TYPE_ERROR; } v_int32 Action::getType() const { return m_type; } v_int64 Action::getTimePointMicroseconds() const { return m_data.timePointMicroseconds; } oatpp::data::v_io_handle Action::getIOHandle() const { return m_data.ioData.ioHandle; } Action::IOEventType Action::getIOEventType() const { return m_data.ioData.ioEventType; } v_int32 Action::getIOEventCode() const { return m_type | m_data.ioData.ioEventType; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CoroutineStarter CoroutineStarter::CoroutineStarter(AbstractCoroutine* coroutine) : m_first(coroutine) , m_last(coroutine) {} CoroutineStarter::CoroutineStarter(CoroutineStarter&& other) : m_first(other.m_first) , m_last(other.m_last) { other.m_first = nullptr; other.m_last = nullptr; } CoroutineStarter::~CoroutineStarter() { if(m_first != nullptr) { auto curr = m_first; while(curr != nullptr) { AbstractCoroutine* next = nullptr; if(curr->m_parentReturnAction.m_type == Action::TYPE_COROUTINE) { next = curr->m_parentReturnAction.m_data.coroutine; } delete curr; curr = next; } } } /* * Move assignment operator. */ CoroutineStarter& CoroutineStarter::operator=(CoroutineStarter&& other) { m_first = other.m_first; m_last = other.m_last; other.m_first = nullptr; other.m_last = nullptr; return *this; } Action CoroutineStarter::next(Action&& action) { if(m_last == nullptr) { return std::forward<Action>(action); } m_last->m_parentReturnAction = std::forward<Action>(action); Action result = m_first; m_first = nullptr; m_last = nullptr; return result; } CoroutineStarter& CoroutineStarter::next(CoroutineStarter&& starter) { if(m_last == nullptr) { m_first = starter.m_first; m_last = starter.m_last; } else { m_last->m_parentReturnAction = starter.m_first; m_last = starter.m_last; } starter.m_first = nullptr; starter.m_last = nullptr; return *this; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CoroutineHandle CoroutineHandle::CoroutineHandle(Processor* processor, AbstractCoroutine* rootCoroutine) : _PP(processor) , _CP(rootCoroutine) , _FP(&AbstractCoroutine::act) , _SCH_A(Action::TYPE_NONE) , _ref(nullptr) {} CoroutineHandle::~CoroutineHandle() { delete _CP; } Action CoroutineHandle::takeAction(Action&& action) { //v_int32 iterations = 0; while (true) { switch (action.m_type) { case Action::TYPE_COROUTINE: { action.m_data.coroutine->m_parent = _CP; _CP = action.m_data.coroutine; _FP = &AbstractCoroutine::act; action.m_type = Action::TYPE_NONE; return std::forward<oatpp::async::Action>(action); } case Action::TYPE_FINISH: { /* Please note that savedCP->m_parentReturnAction should not be "REPEAT nor WAIT_RETRY" */ /* as funtion pointer (FP) is invalidated */ action = std::move(_CP->m_parentReturnAction); AbstractCoroutine* savedCP = _CP; _CP = _CP->m_parent; _FP = nullptr; delete savedCP; continue; } case Action::TYPE_YIELD_TO: { _FP = action.m_data.fptr; //break; return std::forward<oatpp::async::Action>(action); } // case Action::TYPE_REPEAT: { // break; // } // // case Action::TYPE_IO_REPEAT: { // break; // } case Action::TYPE_ERROR: { Action newAction = _CP->handleError(action.m_data.error); if (newAction.m_type == Action::TYPE_ERROR) { AbstractCoroutine* savedCP = _CP; _CP = _CP->m_parent; delete savedCP; if (newAction.m_data.error == action.m_data.error) { newAction.m_type = Action::TYPE_NONE; } else { action = std::move(newAction); } if(_CP == nullptr) { delete action.m_data.error; action.m_type = Action::TYPE_NONE; return std::forward<oatpp::async::Action>(action); } } else { action = std::move(newAction); } continue; } default: return std::forward<oatpp::async::Action>(action); }; // action = iterate(); // ++ iterations; } return std::forward<oatpp::async::Action>(action); } Action CoroutineHandle::iterate() { try { return _CP->call(_FP); } catch (std::exception& e) { return new Error(e.what()); } catch (...) { return new Error("[oatpp::async::CoroutineHandle::iterate()]: Error. Unknown Exception."); } } Action CoroutineHandle::iterateAndTakeAction() { return takeAction(iterate()); } bool CoroutineHandle::finished() const { return _CP == nullptr; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // AbstractCoroutine AbstractCoroutine::AbstractCoroutine() : m_parent(nullptr) , m_parentReturnAction(Action(Action::TYPE_NONE)) {} Action AbstractCoroutine::handleError(Error* error) { return Action(error); } AbstractCoroutine* AbstractCoroutine::getParent() const { return m_parent; } Action AbstractCoroutine::repeat() { return Action::createActionByType(Action::TYPE_REPEAT); } Action AbstractCoroutine::waitRepeat(const std::chrono::duration<v_int64, std::micro>& timeout) { auto startTime = std::chrono::system_clock::now(); auto end = startTime + timeout; std::chrono::microseconds ms = std::chrono::duration_cast<std::chrono::microseconds>(end.time_since_epoch()); return Action::createWaitRepeatAction(ms.count()); } CoroutineStarter AbstractCoroutine::waitFor(const std::chrono::duration<v_int64, std::micro>& timeout) { class WaitingCoroutine : public Coroutine<WaitingCoroutine> { private: std::chrono::duration<v_int64, std::micro> m_duration; bool m_wait; public: WaitingCoroutine(const std::chrono::duration<v_int64, std::micro>& duration) : m_duration(duration) , m_wait(true) {} Action act() override { if(m_wait) { m_wait = false; return waitRepeat(m_duration); } return finish(); } }; return WaitingCoroutine::start(timeout); } Action AbstractCoroutine::ioWait(data::v_io_handle ioHandle, Action::IOEventType ioEventType) { return Action::createIOWaitAction(ioHandle, ioEventType); } Action AbstractCoroutine::ioRepeat(data::v_io_handle ioHandle, Action::IOEventType ioEventType) { return Action::createIORepeatAction(ioHandle, ioEventType); } Action AbstractCoroutine::error(Error* error) { return error; } }}
25.320513
120
0.629975
BossZou
c4a775deed81174cc564526e04deaf8fbe5c2cbd
309
cpp
C++
Single Number/Soln(map).cpp
shrustimy/LeetCode_Solutions-C_Cpp
b6f7da9dbfa83f6fc13573e22c4ee4086921e148
[ "MIT" ]
null
null
null
Single Number/Soln(map).cpp
shrustimy/LeetCode_Solutions-C_Cpp
b6f7da9dbfa83f6fc13573e22c4ee4086921e148
[ "MIT" ]
null
null
null
Single Number/Soln(map).cpp
shrustimy/LeetCode_Solutions-C_Cpp
b6f7da9dbfa83f6fc13573e22c4ee4086921e148
[ "MIT" ]
null
null
null
class Solution { public: int singleNumber(vector<int>& nums) { unordered_map<int,int> map; for(auto i:nums) { map[i]++; } for(auto i:nums) { if(map[i]==1) return i; } return -1; } };
19.3125
42
0.381877
shrustimy
c4a9aa0f84ffcdd2771a7deb35c1f560fb0d3a93
3,436
cpp
C++
src/craft/fsm.cpp
azais-corentin/StillSane
5cafa1aad4964d042879ee14d80ddef71bd9f8e4
[ "MIT" ]
1
2022-03-15T18:07:37.000Z
2022-03-15T18:07:37.000Z
src/craft/fsm.cpp
azais-corentin/StillSane
5cafa1aad4964d042879ee14d80ddef71bd9f8e4
[ "MIT" ]
null
null
null
src/craft/fsm.cpp
azais-corentin/StillSane
5cafa1aad4964d042879ee14d80ddef71bd9f8e4
[ "MIT" ]
1
2022-03-20T16:09:28.000Z
2022-03-20T16:09:28.000Z
#include "fsm.hh" #include <algorithm> #include <functional> #include <iostream> #include <range/v3/action/sort.hpp> #include <range/v3/action/unique.hpp> #include <range/v3/range/conversion.hpp> #include <range/v3/view/remove_if.hpp> #include <range/v3/view/transform.hpp> #include <sol/sol.hpp> FSM::FSM(std::shared_ptr<sol::state> luaState) : mLuaState(luaState) {} bool FSM::parse(const std::vector<std::string>& transition_table) { for (std::string transition : transition_table) { mTransitions.emplace_back(transition); if (!mTransitions.back().valid()) { mValid = false; return false; } else if (mTransitions.back().initial()) { mCurrentStates.emplace_back(mTransitions.back().src_state()); } } // Remove duplicates states mCurrentStates |= ranges::actions::sort | ranges::actions::unique; if (mCurrentStates.empty()) { error("no initial state"); } mValid = true; mFinished = false; return true; } void FSM::process_event(const std::string& event) { if (!mValid) return; debug("processing event '{}'", event); std::vector<std::string> mNextStates; std::vector<std::pair<std::string, bool>> mStatesHandled = mCurrentStates | ranges::views::transform([](const std::string& s) -> std::pair<std::string, bool> { return {s, false}; }) | ranges::to<std::vector<std::pair<std::string, bool>>>; for (const auto& transition : mTransitions) { for (auto& state : mStatesHandled) { if (state.second) break; if (transition.process_event(*this, event, state.first)) { debug("processed event '{}' successfully: {} => {}", event, state.first, transition.dst_state()); state.second = true; // Set handled mNextStates.push_back(transition.dst_state()); break; } } } // Re-add unhandled states for (const auto& unhandled : mStatesHandled | ranges::views::remove_if([](const auto& state) { return state.second; })) mNextStates.push_back(unhandled.first); if (mCurrentStates.size() != mNextStates.size()) { error("mCurrentStates.size() != mNextStates.size()"); return; } mCurrentStates = mNextStates; // Remove duplicates states mCurrentStates |= ranges::actions::sort | ranges::actions::unique; if (mCurrentStates.size() == 1 && mCurrentStates.at(0) == "X") { debug("we done boys"); mFinished = true; } } bool FSM::finished() { return mFinished; } /*! * \brief FSM::execute_guard * \return true if the guard passed, false if the guard failed or there was an error */ bool FSM::execute_guard(const std::string& code) { // debug("executing guard '", code, "'"); auto result = mLuaState->safe_script(code, sol::script_pass_on_error); if (!result.valid()) { sol::error err = result; error("failed to execute guard \"{}\"\n with error: {}", code, err.what()); return false; } spdlog::debug("guard result: {}", static_cast<bool>(result)); return result; } /*! * \brief FSM::execute_action * \return true on success, false on failure */ bool FSM::execute_action(const std::string& code) { // debug("executing action '", code, "'"); auto result = mLuaState->safe_script(code, sol::script_pass_on_error); if (!result.valid()) { sol::error err = result; error("failed to execute guard: {}", err.what()); return false; } return true; }
26.430769
89
0.64319
azais-corentin
c4aa6549339ccc018ba64b24fe9e38cb471d59aa
215
cpp
C++
Society2.0/Society2.0/TrustedDevelopers.cpp
simsim314/Society2.0
a95e42122e2541b7544dd641247681996f1e625a
[ "Unlicense" ]
1
2019-07-11T13:10:43.000Z
2019-07-11T13:10:43.000Z
Society2.0/Society2.0/TrustedDevelopers.cpp
mdheller/Society2.0
a95e42122e2541b7544dd641247681996f1e625a
[ "Unlicense" ]
1
2019-02-19T12:32:52.000Z
2019-03-07T20:49:50.000Z
Society2.0/Society2.0/TrustedDevelopers.cpp
mdheller/Society2.0
a95e42122e2541b7544dd641247681996f1e625a
[ "Unlicense" ]
1
2020-01-10T12:37:30.000Z
2020-01-10T12:37:30.000Z
#include "TrustedDevelopers.h" float TrustedDevelopers::Trust(SkillPerson * developer) { return 0.0f; } TrustedDevelopers::TrustedDevelopers() { } TrustedDevelopers::~TrustedDevelopers() { }
11.944444
56
0.693023
simsim314
c4acc5a2a3755a3c4723d88002219847ce897ec1
2,863
hpp
C++
library/ATF/CCircleZoneInfo.hpp
lemkova/Yorozuya
f445d800078d9aba5de28f122cedfa03f26a38e4
[ "MIT" ]
29
2017-07-01T23:08:31.000Z
2022-02-19T10:22:45.000Z
library/ATF/CCircleZoneInfo.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
90
2017-10-18T21:24:51.000Z
2019-06-06T02:30:33.000Z
library/ATF/CCircleZoneInfo.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
44
2017-12-19T08:02:59.000Z
2022-02-24T23:15:01.000Z
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> #include <CCircleZone.hpp> START_ATF_NAMESPACE namespace Info { using CCircleZonector_CCircleZone2_ptr = void (WINAPIV*)(struct CCircleZone*); using CCircleZonector_CCircleZone2_clbk = void (WINAPIV*)(struct CCircleZone*, CCircleZonector_CCircleZone2_ptr); using CCircleZoneCreate4_ptr = bool (WINAPIV*)(struct CCircleZone*, struct CMapData*, char); using CCircleZoneCreate4_clbk = bool (WINAPIV*)(struct CCircleZone*, struct CMapData*, char, CCircleZoneCreate4_ptr); using CCircleZoneDestroy6_ptr = void (WINAPIV*)(struct CCircleZone*); using CCircleZoneDestroy6_clbk = void (WINAPIV*)(struct CCircleZone*, CCircleZoneDestroy6_ptr); using CCircleZoneGetColor8_ptr = char (WINAPIV*)(struct CCircleZone*); using CCircleZoneGetColor8_clbk = char (WINAPIV*)(struct CCircleZone*, CCircleZoneGetColor8_ptr); using CCircleZoneGetPortalInx10_ptr = int (WINAPIV*)(struct CCircleZone*); using CCircleZoneGetPortalInx10_clbk = int (WINAPIV*)(struct CCircleZone*, CCircleZoneGetPortalInx10_ptr); using CCircleZoneGoal12_ptr = char (WINAPIV*)(struct CCircleZone*, struct CMapData*, float*); using CCircleZoneGoal12_clbk = char (WINAPIV*)(struct CCircleZone*, struct CMapData*, float*, CCircleZoneGoal12_ptr); using CCircleZoneInit14_ptr = bool (WINAPIV*)(struct CCircleZone*, unsigned int, int, int, uint16_t, struct CMapData*); using CCircleZoneInit14_clbk = bool (WINAPIV*)(struct CCircleZone*, unsigned int, int, int, uint16_t, struct CMapData*, CCircleZoneInit14_ptr); using CCircleZoneIsNearPosition16_ptr = bool (WINAPIV*)(struct CCircleZone*, float*); using CCircleZoneIsNearPosition16_clbk = bool (WINAPIV*)(struct CCircleZone*, float*, CCircleZoneIsNearPosition16_ptr); using CCircleZoneSendMsgCreate18_ptr = void (WINAPIV*)(struct CCircleZone*); using CCircleZoneSendMsgCreate18_clbk = void (WINAPIV*)(struct CCircleZone*, CCircleZoneSendMsgCreate18_ptr); using CCircleZoneSendMsgGoal20_ptr = void (WINAPIV*)(struct CCircleZone*); using CCircleZoneSendMsgGoal20_clbk = void (WINAPIV*)(struct CCircleZone*, CCircleZoneSendMsgGoal20_ptr); using CCircleZoneSendMsg_FixPosition22_ptr = void (WINAPIV*)(struct CCircleZone*, int); using CCircleZoneSendMsg_FixPosition22_clbk = void (WINAPIV*)(struct CCircleZone*, int, CCircleZoneSendMsg_FixPosition22_ptr); using CCircleZonedtor_CCircleZone28_ptr = void (WINAPIV*)(struct CCircleZone*); using CCircleZonedtor_CCircleZone28_clbk = void (WINAPIV*)(struct CCircleZone*, CCircleZonedtor_CCircleZone28_ptr); }; // end namespace Info END_ATF_NAMESPACE
73.410256
151
0.754803
lemkova
c4b9d3ea2c9d7ca9eaa4f7e03198b94cec611d66
1,015
cpp
C++
Chapter 4/4.27 palindromes/4.27 palindromes/main.cpp
MarvelousAudio/CPlusPlus-How-to-program-tenth-edition
a667b080938cf964909d79b272f0d863adc300e0
[ "MIT" ]
null
null
null
Chapter 4/4.27 palindromes/4.27 palindromes/main.cpp
MarvelousAudio/CPlusPlus-How-to-program-tenth-edition
a667b080938cf964909d79b272f0d863adc300e0
[ "MIT" ]
null
null
null
Chapter 4/4.27 palindromes/4.27 palindromes/main.cpp
MarvelousAudio/CPlusPlus-How-to-program-tenth-edition
a667b080938cf964909d79b272f0d863adc300e0
[ "MIT" ]
null
null
null
// // main.cpp // 4.27 palindromes // // Created by ben haywood on 6/28/20. // Copyright © 2020 ben haywood. All rights reserved. // #include <iostream> using namespace std; int main(int argc, const char * argv[]) { // insert code here... int input = 0; bool flag = true; int tenThousands = 0; int thousands = 0; int tens = 0; int ones = 0; while (flag) { cout << "input a 5 digit number\n"; cin >> input; if ((input / 100000 < 1)) { flag = false; break; } else { cout << "MUST ENTER 5 DIGIT NUMBER!" << endl; } } ones = input % 10; tens = (input % 100) / 10; thousands = (input % 10000) / 1000; tenThousands = input / 10000; if (ones == tenThousands && thousands == tens) { cout << "Is palidrome" << endl; } else { cout << "Not palidrome" << endl; } return 0; }
17.20339
57
0.470936
MarvelousAudio
c4bf4426046c9ad3eadc6b85fa32478291cfbd27
28,665
hpp
C++
cpp/visualmesh/engine/vulkan/kernels/make_network.hpp
wongjoel/VisualMesh
98b973c6cd371aab51f2b631f75c9ac820d3b744
[ "MIT" ]
14
2018-06-22T19:46:34.000Z
2022-02-02T15:22:39.000Z
cpp/visualmesh/engine/vulkan/kernels/make_network.hpp
wongjoel/VisualMesh
98b973c6cd371aab51f2b631f75c9ac820d3b744
[ "MIT" ]
2
2020-12-12T04:51:51.000Z
2021-06-28T01:14:42.000Z
cpp/visualmesh/engine/vulkan/kernels/make_network.hpp
wongjoel/VisualMesh
98b973c6cd371aab51f2b631f75c9ac820d3b744
[ "MIT" ]
8
2018-06-11T14:54:45.000Z
2022-02-02T15:22:50.000Z
/* * Copyright (C) 2017-2020 Trent Houliston <trent@houliston.me> * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef VISUALMESH_VULKAN_KERNELS_MAKE_NETWORK_HPP #define VISUALMESH_VULKAN_KERNELS_MAKE_NETWORK_HPP #include <iostream> #include <string> #include <utility> #include <vector> #include "visualmesh/engine/vulkan/vulkan_compute.hpp" #include "visualmesh/network_structure.hpp" namespace visualmesh { namespace engine { namespace vulkan { namespace kernels { /** * @brief Given a network structure object generate the SPIRV source code for the kernels needed to execute * it * * @tparam Scalar the scalar type used for calculations and storage (normally one of float or double) * * @param structure the network structure to generate the kernels from * * @return the SPIRV source code for the kernels to be built */ template <typename Scalar, bool debug> std::vector<std::pair<uint32_t, std::vector<uint32_t>>> make_network( const NetworkStructure<Scalar>& structure) { std::vector<std::pair<uint32_t, std::vector<uint32_t>>> programs; // If our structure has no layers, return empty code if (structure.empty() || structure.front().empty()) { return programs; } // Keep track of the input and output size of each layer for building the network // The first layer input is always 4 from the image uint32_t input_dimensions = 4; uint32_t output_dimensions = 0; // First layer has 4 inputs, so that tells us how many neighbours we have (minus ourself) const uint32_t n_neighbours = (structure.front().front().weights.size() / 4) - 1; for (uint32_t conv_no = 0; conv_no < structure.size(); ++conv_no) { auto& conv = structure[conv_no]; // Initialise the program. Program::Config config; config.enable_glsl_extensions = true; config.enable_float64 = ((sizeof(Scalar) == 8) && std::is_floating_point<Scalar>::value); config.address_model = spv::AddressingModel::Logical; config.memory_model = spv::MemoryModel::GLSL450; config.enable_debug = debug; Program program(config); uint32_t uint_type = program.add_type(spv::Op::OpTypeInt, {32, 0}); uint32_t float_type = program.add_type(spv::Op::OpTypeFloat, {8 * sizeof(Scalar)}); uint32_t uvec3 = program.add_vec_type(spv::Op::OpTypeInt, {32, 0}, 3); uint32_t uint_ptr = program.add_pointer(uint_type, spv::StorageClass::Input); uint32_t uvec3_ptr = program.add_pointer(uvec3, spv::StorageClass::Input); uint32_t uint_ptr_sb = program.add_pointer(uint_type, spv::StorageClass::StorageBuffer); uint32_t float_ptr = program.add_pointer(float_type, spv::StorageClass::StorageBuffer); uint32_t float_ptr_func = program.add_pointer(float_type, spv::StorageClass::Function); // Define the GlobalInvocationID (for get_global_id(0)) uint32_t global_id = program.add_variable(uvec3_ptr, spv::StorageClass::Input); program.add_builtin_decoration(global_id, spv::BuiltIn::GlobalInvocationId); // Prepare the input/output/descriptor set variables uint32_t neighbourhood_array = program.add_array_type(uint_type); uint32_t neighbourhood_struct = program.add_struct({neighbourhood_array}); uint32_t neighbourhood_ptr = program.add_name( program.add_variable(program.add_pointer(neighbourhood_struct, spv::StorageClass::StorageBuffer), spv::StorageClass::StorageBuffer), "neighbourhood"); // The input layer is coming from the image, so the input is an fvec4 uint32_t input_array = program.add_array_type(float_type); uint32_t input_struct = program.add_struct({input_array}); uint32_t input_ptr = program.add_name( program.add_variable(program.add_pointer(input_struct, spv::StorageClass::StorageBuffer), spv::StorageClass::StorageBuffer), "input"); uint32_t output_array = program.add_array_type(float_type); uint32_t output_struct = program.add_struct({output_array}); uint32_t output_ptr = program.add_name( program.add_variable(program.add_pointer(output_struct, spv::StorageClass::StorageBuffer), spv::StorageClass::StorageBuffer), "output"); // Decorate the structs and their members. uint32_t block_decoration = program.add_decoration_group(spv::Decoration::Block); program.add_group_decoration(block_decoration, {neighbourhood_struct, input_struct, output_struct}); program.add_member_decoration(neighbourhood_struct, 0, spv::Decoration::Offset, {0}); program.add_member_decoration(input_struct, 0, spv::Decoration::Offset, {0}); program.add_member_decoration(output_struct, 0, spv::Decoration::Offset, {0}); program.add_decoration(neighbourhood_array, spv::Decoration::ArrayStride, {4}); program.add_decoration(input_array, spv::Decoration::ArrayStride, {sizeof(Scalar)}); program.add_decoration(output_array, spv::Decoration::ArrayStride, {sizeof(Scalar)}); // Set up the descriptor set for all convolutional kernels // Descriptor Set 0: {neighbourhood_ptr, input_ptr, output_ptr} program.create_descriptor_set({neighbourhood_ptr, input_ptr, output_ptr}); // Index 0 is used in every member_access call uint32_t idx0 = program.add_constant(uint_type, {0u}); // Write our Vulkan kernel definition program.begin_entry_point("conv" + std::to_string(conv_no), {global_id}); program.add_source_line(__FILE__, __LINE__, conv_no); // Pre-allocate all arrays // These array variables must be the first things in the function std::vector<uint32_t> layers; layers.push_back(program.add_name( program.add_variable( program.add_pointer( program.add_array_type( float_type, program.add_constant(uint_type, {input_dimensions * (n_neighbours + 1u)})), spv::StorageClass::Function), spv::StorageClass::Function), compose_string<debug>("in0[{}]", input_dimensions * (n_neighbours + 1)))); program.add_source_line(__FILE__, __LINE__, conv_no); for (uint32_t layer_no = 0; layer_no < conv.size(); ++layer_no) { layers.push_back(program.add_name( program.add_variable( program.add_pointer( program.add_array_type( float_type, program.add_constant(uint_type, {static_cast<uint32_t>(conv[layer_no].biases.size())})), spv::StorageClass::Function), spv::StorageClass::Function), compose_string<debug>("in{}[{}]", layer_no + 1, conv[layer_no].biases.size()))); } program.add_source_line(__FILE__, __LINE__, conv_no); // Get our kernel index // idx = get_global_id(0); program.add_source_line(__FILE__, __LINE__, conv_no); uint32_t idx = program.add_name( program.load_variable(program.member_access(global_id, {idx0}, uint_ptr), uint_type), "get_global_id"); /************************************************* * GATHER * *************************************************/ program.add_source_line(__FILE__, __LINE__, conv_no); // idx * n_neighbours is used a lot, precalculate it program.add_source_line(__FILE__, __LINE__, conv_no); uint32_t idx_dim = program.add_name( program.imul(idx, program.add_constant(uint_type, {input_dimensions}), uint_type), "input_idx"); uint32_t idx_neighbours = program.add_name( program.imul(idx, program.add_constant(uint_type, {n_neighbours}), uint_type), "neighbour_idx"); program.add_source_line(__FILE__, __LINE__, conv_no); // Read the ones for our own index for (uint32_t j = 0; j < input_dimensions; ++j) { // input[idx * input_dimensions + j] uint32_t input_val = program.add_name( program.load_variable( program.member_access( input_ptr, // idx0 = offset to struct member (only one member in struct, its at offset 0) {idx0, // idx * input_dimensions + j program.iadd(idx_dim, program.add_constant(uint_type, {j}), uint_type)}, float_ptr), float_type), compose_string<debug>("input[idx * {} + {}]", input_dimensions, j)); program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.add_name( program.member_access(layers[0], {program.add_constant(uint_type, {j})}, float_ptr_func), compose_string<debug>("in0[{}]", j)), input_val); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); // Read our neighbourhood for (uint32_t i = 0; i < n_neighbours; ++i) { // neighbour_idx is used in every iteration of the sub loop // neighbourhood[idx * n_neighbours + i] uint32_t neighbour_idx = program.add_name( program.load_variable( program.member_access( neighbourhood_ptr, // idx0 = offset to struct member (only one member in struct, its at offset 0) // idx * n_neighbours + i {idx0, program.iadd(idx_neighbours, program.add_constant(uint_type, {i}), uint_type)}, uint_ptr_sb), uint_type), compose_string<debug>("neighbourhood[idx * {} + {}]", n_neighbours, i)); program.add_source_line(__FILE__, __LINE__, conv_no); // neighbour_input_idx is used in every iteration of the sub loop // neighbourhood[idx * n_neighbours + i] * input_dimensions uint32_t neighbour_input_idx = program.add_name( program.imul(neighbour_idx, program.add_constant(uint_type, {input_dimensions}), uint_type), compose_string<debug>( "neighbourhood[idx * {} + {}] * {}", n_neighbours, i, input_dimensions)); program.add_source_line(__FILE__, __LINE__, conv_no); for (uint32_t j = 0; j < input_dimensions; ++j) { // input[neighbourhood[idx * n_neighbours + i] * input_dimensions + j] uint32_t neighbour_val = program.add_name( program.load_variable( program.member_access( input_ptr, // idx0 = offset to struct member (only one member in struct, its at offset 0) {idx0, // neighbourhood[idx * 6 + i] * conv_in_size + j program.iadd(neighbour_input_idx, program.add_constant(uint_type, {j}), uint_type)}, float_ptr), float_type), compose_string<debug>( "input[neighbourhood[idx * {} + {}] * {} + {}]", n_neighbours, i, input_dimensions, j)); program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.add_name(program.member_access( layers[0], {program.add_constant(uint_type, {(i + 1u) * input_dimensions + j})}, float_ptr_func), compose_string<debug>("in0[{}]", i + 1)), neighbour_val); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); // We have gathered which increased the size of the input input_dimensions = input_dimensions * (n_neighbours + 1); // selu constants uint32_t lambda = program.add_name( program.add_constant(float_type, {Scalar(1.0507009873554804934193349852946)}), "lambda"); uint32_t alpha = program.add_name( program.add_constant(float_type, {Scalar(1.6732632423543772848170429916717)}), "alpha"); program.add_source_line(__FILE__, __LINE__, conv_no); // Now we have to do our layer operations for (uint32_t layer_no = 0; layer_no < conv.size(); ++layer_no) { const auto& weights = conv[layer_no].weights; const auto& biases = conv[layer_no].biases; output_dimensions = biases.size(); /************************************************* * WEIGHTS + BIAS * *************************************************/ program.add_source_line(__FILE__, __LINE__, conv_no); // Perform our matrix multiplication for weights and add bias for layer for (uint32_t i = 0; i < output_dimensions; ++i) { uint32_t total_val = program.add_name(program.add_constant(float_type, {biases[i]}), compose_string<debug>("in{}[{}]_bias[{}]", layer_no, i, i)); program.add_source_line(__FILE__, __LINE__, conv_no); for (uint32_t j = 0; j < input_dimensions; ++j) { uint32_t current_val = program.add_name( program.load_variable( program.member_access( layers[layer_no], {program.add_constant(uint_type, {j})}, float_ptr_func), float_type), compose_string<debug>("in{}[{}]", layer_no, j)); program.add_source_line(__FILE__, __LINE__, conv_no); current_val = program.add_name( program.fmul( current_val, program.add_constant(float_type, {weights[j][i]}), float_type), "current_mul_weight"); program.add_source_line(__FILE__, __LINE__, conv_no); total_val = program.add_name(program.fadd(total_val, current_val, float_type), "total_peq_current"); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.add_name( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), compose_string<debug>("in{}[{}]", layer_no + 1, i)), total_val); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); /************************************************* * ACTIVATION. * *************************************************/ // Apply selu if (conv_no + 1 < structure.size() || layer_no + 1 < conv.size()) { program.add_source_line(__FILE__, __LINE__, conv_no); for (uint32_t i = 0; i < output_dimensions; ++i) { // in1[i] = lambda * (in1[i] > 0 ? in1[i] : alpha * exp(in1[i]) - alpha; uint32_t current_val = program.add_name( program.load_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), float_type), compose_string<debug>("in{}[{}]", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); // selu = alpha * exp(in1[i]) - alpha uint32_t selu = program.add_name( program.fsub(program.fmul(alpha, program.exp(current_val, float_type), float_type), alpha, float_type), compose_string<debug>("selu(in{}[{}])", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); // in1[i] = lambda * (in1[i] > 0 ? in1[i] : selu) uint32_t condition = program.add_name( program.fgeq(current_val, program.add_constant(float_type, {Scalar(0)})), compose_string<debug>("in{}[{}]_gt_0", layer_no + 1, i)); current_val = program.add_name( program.fmul( lambda, program.select(float_type, condition, current_val, selu), float_type), "lambda_selu"); program.store_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), current_val); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); } // If this is our last layer, apply softmax else { program.add_source_line(__FILE__, __LINE__, conv_no); // Apply exp to each of the elements for (uint32_t i = 0; i < output_dimensions; ++i) { // in1[i] = exp(in1[i]) uint32_t current_val = program.add_name( program.load_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), float_type), compose_string<debug>("in{}[{}]", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); current_val = program.add_name(program.exp(current_val, float_type), compose_string<debug>("exp(in{}[{}])", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), current_val); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); // Sum up all the values uint32_t exp_sum = program.add_constant(float_type, {Scalar(0)}); for (uint32_t i = 0; i < output_dimensions; ++i) { // exp_sum += in1[i] uint32_t current_val = program.add_name( program.load_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), float_type), compose_string<debug>("in{}[{}]", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); exp_sum = program.add_name(program.fadd(exp_sum, current_val, float_type), compose_string<debug>("exp_sum_plus_in{}[{}]", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); } program.add_source_line(__FILE__, __LINE__, conv_no); // Divide all the values for (uint32_t i = 0; i < output_dimensions; ++i) { // in1[i] /= exp_sum uint32_t current_val = program.add_name( program.load_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), float_type), compose_string<debug>("in{}[{}]", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); current_val = program.add_name(program.fdiv(current_val, exp_sum, float_type), compose_string<debug>("in{}[{}]_div_exp_sum", layer_no + 1, i)); program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.member_access( layers[layer_no + 1], {program.add_constant(uint_type, {i})}, float_ptr_func), current_val); program.add_source_line(__FILE__, __LINE__, conv_no); } } program.add_source_line(__FILE__, __LINE__, conv_no); // Update our input size for the next loop input_dimensions = output_dimensions; } program.add_source_line(__FILE__, __LINE__, conv_no); /************************************************* * OUTPUT * *************************************************/ // Save our value to the output uint32_t output_idx = program.add_name( program.imul(idx, program.add_constant(uint_type, {input_dimensions}), uint_type), "output_idx"); for (unsigned int i = 0; i < input_dimensions; ++i) { // output[idx * input_dimensions + i] = inN[i] uint32_t current_val = program.load_variable( program.member_access(layers.back(), {program.add_constant(uint_type, {i})}, float_ptr_func), float_type); program.add_source_line(__FILE__, __LINE__, conv_no); program.store_variable( program.member_access( output_ptr, {idx0, program.iadd(output_idx, program.add_constant(uint_type, {i}), uint_type)}, float_ptr), current_val); program.add_source_line(__FILE__, __LINE__, conv_no); } // Update our input dimensions for the next round input_dimensions = output_dimensions; program.return_function(); program.end_function(); programs.emplace_back(conv_no, program.build()); } return programs; } } // namespace kernels } // namespace vulkan } // namespace engine } // namespace visualmesh #endif // VISUALMEVULKANNCL_KERNELS_MAKE_NETWORK_HPP
55.986328
120
0.48254
wongjoel
c4c316d40c8d2fc8f2ed854948e5db1ade9c892b
7,520
hpp
C++
include/VROSC/LoopStationTrack.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
include/VROSC/LoopStationTrack.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
include/VROSC/LoopStationTrack.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: UnityEngine.Color #include "UnityEngine/Color.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "beatsaber-hook/shared/utils/utils.h" #include "beatsaber-hook/shared/utils/typedefs-string.hpp" // Completed includes // Begin forward declares // Forward declaring namespace: VROSC namespace VROSC { // Forward declaring type: LoopPlaybackConfigData class LoopPlaybackConfigData; } // Completed forward declares // Type namespace: VROSC namespace VROSC { // Forward declaring type: LoopStationTrack class LoopStationTrack; } #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(::VROSC::LoopStationTrack); DEFINE_IL2CPP_ARG_TYPE(::VROSC::LoopStationTrack*, "VROSC", "LoopStationTrack"); // Type namespace: VROSC namespace VROSC { // Size: 0x84 #pragma pack(push, 1) // Autogenerated type: VROSC.LoopStationTrack // [TokenAttribute] Offset: FFFFFFFF class LoopStationTrack : public ::Il2CppObject { public: #ifdef USE_CODEGEN_FIELDS public: #else #ifdef CODEGEN_FIELD_ACCESSIBILITY CODEGEN_FIELD_ACCESSIBILITY: #else protected: #endif #endif // public System.String TrackId // Size: 0x8 // Offset: 0x10 ::StringW TrackId; // Field size check static_assert(sizeof(::StringW) == 0x8); // public System.Int32 TrackNumber // Size: 0x4 // Offset: 0x18 int TrackNumber; // Field size check static_assert(sizeof(int) == 0x4); // Padding between fields: TrackNumber and: InstrumentName char __padding1[0x4] = {}; // public System.String InstrumentName // Size: 0x8 // Offset: 0x20 ::StringW InstrumentName; // Field size check static_assert(sizeof(::StringW) == 0x8); // public System.String PatchName // Size: 0x8 // Offset: 0x28 ::StringW PatchName; // Field size check static_assert(sizeof(::StringW) == 0x8); // public System.Single Volume // Size: 0x4 // Offset: 0x30 float Volume; // Field size check static_assert(sizeof(float) == 0x4); // public System.Single NormalizeMultiplier // Size: 0x4 // Offset: 0x34 float NormalizeMultiplier; // Field size check static_assert(sizeof(float) == 0x4); // public System.Boolean IsMuted // Size: 0x1 // Offset: 0x38 bool IsMuted; // Field size check static_assert(sizeof(bool) == 0x1); // Padding between fields: IsMuted and: BelongsToGroup char __padding6[0x7] = {}; // public System.String BelongsToGroup // Size: 0x8 // Offset: 0x40 ::StringW BelongsToGroup; // Field size check static_assert(sizeof(::StringW) == 0x8); // public System.Int32 PositionInGroup // Size: 0x4 // Offset: 0x48 int PositionInGroup; // Field size check static_assert(sizeof(int) == 0x4); // Padding between fields: PositionInGroup and: DisplayName char __padding8[0x4] = {}; // public System.String DisplayName // Size: 0x8 // Offset: 0x50 ::StringW DisplayName; // Field size check static_assert(sizeof(::StringW) == 0x8); // public System.Int32 GlobalSyncStartOffset // Size: 0x4 // Offset: 0x58 int GlobalSyncStartOffset; // Field size check static_assert(sizeof(int) == 0x4); // public System.Int32 LoopLength // Size: 0x4 // Offset: 0x5C int LoopLength; // Field size check static_assert(sizeof(int) == 0x4); // public VROSC.LoopPlaybackConfigData PlaybackConfigData // Size: 0x8 // Offset: 0x60 ::VROSC::LoopPlaybackConfigData* PlaybackConfigData; // Field size check static_assert(sizeof(::VROSC::LoopPlaybackConfigData*) == 0x8); // public VROSC.LoopPlaybackConfigData StartConfigData // Size: 0x8 // Offset: 0x68 ::VROSC::LoopPlaybackConfigData* StartConfigData; // Field size check static_assert(sizeof(::VROSC::LoopPlaybackConfigData*) == 0x8); // public System.Boolean IsPlaying // Size: 0x1 // Offset: 0x70 bool IsPlaying; // Field size check static_assert(sizeof(bool) == 0x1); // Padding between fields: IsPlaying and: Color char __padding14[0x3] = {}; // public UnityEngine.Color Color // Size: 0x10 // Offset: 0x74 ::UnityEngine::Color Color; // Field size check static_assert(sizeof(::UnityEngine::Color) == 0x10); public: // Get instance field reference: public System.String TrackId ::StringW& dyn_TrackId(); // Get instance field reference: public System.Int32 TrackNumber int& dyn_TrackNumber(); // Get instance field reference: public System.String InstrumentName ::StringW& dyn_InstrumentName(); // Get instance field reference: public System.String PatchName ::StringW& dyn_PatchName(); // Get instance field reference: public System.Single Volume float& dyn_Volume(); // Get instance field reference: public System.Single NormalizeMultiplier float& dyn_NormalizeMultiplier(); // Get instance field reference: public System.Boolean IsMuted bool& dyn_IsMuted(); // Get instance field reference: public System.String BelongsToGroup ::StringW& dyn_BelongsToGroup(); // Get instance field reference: public System.Int32 PositionInGroup int& dyn_PositionInGroup(); // Get instance field reference: public System.String DisplayName ::StringW& dyn_DisplayName(); // Get instance field reference: public System.Int32 GlobalSyncStartOffset int& dyn_GlobalSyncStartOffset(); // Get instance field reference: public System.Int32 LoopLength int& dyn_LoopLength(); // Get instance field reference: public VROSC.LoopPlaybackConfigData PlaybackConfigData ::VROSC::LoopPlaybackConfigData*& dyn_PlaybackConfigData(); // Get instance field reference: public VROSC.LoopPlaybackConfigData StartConfigData ::VROSC::LoopPlaybackConfigData*& dyn_StartConfigData(); // Get instance field reference: public System.Boolean IsPlaying bool& dyn_IsPlaying(); // Get instance field reference: public UnityEngine.Color Color ::UnityEngine::Color& dyn_Color(); // public System.Void .ctor() // Offset: 0x8A66F4 // Implemented from: System.Object // Base method: System.Void Object::.ctor() template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static LoopStationTrack* New_ctor() { static auto ___internal__logger = ::Logger::get().WithContext("::VROSC::LoopStationTrack::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<LoopStationTrack*, creationType>())); } }; // VROSC.LoopStationTrack #pragma pack(pop) static check_size<sizeof(LoopStationTrack), 116 + sizeof(::UnityEngine::Color)> __VROSC_LoopStationTrackSizeCheck; static_assert(sizeof(LoopStationTrack) == 0x84); } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: VROSC::LoopStationTrack::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead!
36.862745
116
0.696543
RedBrumbler
c4c54a72ba4365fbe347606fb71f0309c7238768
928
cpp
C++
Part I - The Basics/Chapter 4 - Computation/Exercises/ch_4_ex_6.cpp
viniciusjavs/Programming
ef1eed5c0a2782dd3ef1c0453460c93384dab41b
[ "MIT" ]
2
2021-08-19T18:27:58.000Z
2021-12-17T17:53:08.000Z
Part I - The Basics/Chapter 4 - Computation/Exercises/ch_4_ex_6.cpp
vjavs/Programming
ef1eed5c0a2782dd3ef1c0453460c93384dab41b
[ "MIT" ]
null
null
null
Part I - The Basics/Chapter 4 - Computation/Exercises/ch_4_ex_6.cpp
vjavs/Programming
ef1eed5c0a2782dd3ef1c0453460c93384dab41b
[ "MIT" ]
null
null
null
//Copyright 2016 Vinicius Sa (viniciusjavs@gmail.com) //Chapter 4, Exercise 6 /* * Program that converts a digit to its corresponding spelled-out value * and converts spelled-out numbers into their digit form. */ #include "std_lib_facilities.h" int main() { vector<string> digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; while (true) { int in_int; if (cin >> in_int) if (in_int >= 0 && in_int < 10) cout << digits[in_int] << '\n'; else cout << "Error: "<< in_int << " is out of range!\n"; else { cin.clear(); string in_str; cin >> in_str; //recupere from buffer int pos = digits.size(); //out of range for (int i = 0; i < digits.size(); ++i) if (in_str == digits[i]) pos = i; if (pos != digits.size()) cout << pos << '\n'; else cout << "Error: " << in_str << " is a unknown value\n"; } } }
25.777778
88
0.564655
viniciusjavs
c4cc28a309ef79a9d12975530aee5281f0b74982
13,241
cpp
C++
src/petuum_ps_common/comm_bus/comm_bus.cpp
ForrestGan/public
2cada36c4b523cf80f16a4f0d0fdc01166a69df1
[ "BSD-3-Clause" ]
null
null
null
src/petuum_ps_common/comm_bus/comm_bus.cpp
ForrestGan/public
2cada36c4b523cf80f16a4f0d0fdc01166a69df1
[ "BSD-3-Clause" ]
null
null
null
src/petuum_ps_common/comm_bus/comm_bus.cpp
ForrestGan/public
2cada36c4b523cf80f16a4f0d0fdc01166a69df1
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2014, Sailing Lab // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the <ORGANIZATION> nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // author: jinliang #include <stdlib.h> #include <glog/logging.h> #include <sstream> #include <string> #include <petuum_ps_common/comm_bus/comm_bus.hpp> #include <petuum_ps_common/comm_bus/zmq_util.hpp> namespace petuum { const std::string CommBus::kInProcPrefix("inproc://comm_bus"); const std::string CommBus::kInterProcPrefix("tcp://"); void CommBus::MakeInProcAddr(int32_t entity_id, std::string *result) { std::stringstream ss; ss << entity_id; *result = kInProcPrefix; *result += ":"; *result += ss.str(); } void CommBus::MakeInterProcAddr(const std::string &network_addr, std::string *result) { *result = kInterProcPrefix; *result += network_addr; } bool CommBus::IsLocalEntity(int32_t entity_id) { //VLOG(0) << "e_st_ = " << e_st_ // << " e_end_ = " << e_end_; return (e_st_ <= entity_id) && (entity_id <= e_end_); } CommBus::CommBus(int32_t e_st, int32_t e_end, int32_t num_zmq_thrs) { e_st_ = e_st; e_end_ = e_end; try { zmq_ctx_ = new zmq::context_t(num_zmq_thrs); } catch(zmq::error_t &e) { LOG(FATAL) << "Faield to create zmq context " << e.what(); } catch(...) { LOG(FATAL) << "Failed to create zmq context"; } } CommBus::~CommBus() { delete zmq_ctx_; } void CommBus::SetUpRouterSocket(zmq::socket_t *sock, int32_t id, int num_bytes_send_buff, int num_bytes_recv_buff) { int32_t my_id = ZMQUtil::EntityID2ZmqID(id); ZMQUtil::ZMQSetSockOpt(sock, ZMQ_IDENTITY, &my_id, sizeof(my_id)); int sock_mandatory = 1; ZMQUtil::ZMQSetSockOpt(sock, ZMQ_ROUTER_MANDATORY, &(sock_mandatory), sizeof(sock_mandatory)); if (num_bytes_send_buff != 0) { ZMQUtil::ZMQSetSockOpt(sock, ZMQ_SNDBUF, &(num_bytes_send_buff), sizeof(num_bytes_send_buff)); } if (num_bytes_recv_buff != 0) { ZMQUtil::ZMQSetSockOpt(sock, ZMQ_RCVBUF, &(num_bytes_recv_buff), sizeof(num_bytes_recv_buff)); } } void CommBus::ThreadRegister(const Config &config) { CHECK(NULL == thr_info_.get()) << "This thread has been initialized"; thr_info_.reset(new ThreadCommInfo()); thr_info_->entity_id_ = config.entity_id_; thr_info_->ltype_ = config.ltype_; thr_info_->num_bytes_inproc_send_buff_ = config.num_bytes_inproc_send_buff_; thr_info_->num_bytes_inproc_recv_buff_ = config.num_bytes_inproc_recv_buff_; thr_info_->num_bytes_interproc_send_buff_ = config.num_bytes_interproc_send_buff_; thr_info_->num_bytes_interproc_recv_buff_ = config.num_bytes_interproc_recv_buff_; VLOG(0) << "CommBus ThreadRegister()"; if (config.ltype_ & kInProc) { try { thr_info_->inproc_sock_.reset(new zmq::socket_t(*zmq_ctx_, ZMQ_ROUTER)); } catch(...) { LOG(FATAL) << "Failed creating router socket"; } zmq::socket_t *sock = thr_info_->inproc_sock_.get(); SetUpRouterSocket(sock, config.entity_id_, config.num_bytes_inproc_send_buff_, config.num_bytes_inproc_recv_buff_); std::string bind_addr; MakeInProcAddr(config.entity_id_, &bind_addr); ZMQUtil::ZMQBind(sock, bind_addr); } if (config.ltype_ & kInterProc) { try { thr_info_->interproc_sock_.reset( new zmq::socket_t(*zmq_ctx_, ZMQ_ROUTER)); } catch(...) { LOG(FATAL) << "Failed creating router socket"; } zmq::socket_t *sock = thr_info_->interproc_sock_.get(); SetUpRouterSocket(sock, config.entity_id_, config.num_bytes_inproc_send_buff_, config.num_bytes_inproc_recv_buff_); std::string bind_addr; MakeInterProcAddr(config.network_addr_, &bind_addr); ZMQUtil::ZMQBind(sock, bind_addr); } } void CommBus::ThreadDeregister() { thr_info_.reset(); } void CommBus::ConnectTo(int32_t entity_id, void *connect_msg, size_t size) { CHECK(IsLocalEntity(entity_id)) << "Not local entity " << entity_id; zmq::socket_t *sock = thr_info_->inproc_sock_.get(); if (sock == NULL) { try { thr_info_->inproc_sock_.reset(new zmq::socket_t(*zmq_ctx_, ZMQ_ROUTER)); } catch (...) { LOG(FATAL) << "Failed creating router socket"; } sock = thr_info_->inproc_sock_.get(); SetUpRouterSocket(sock, thr_info_->entity_id_, thr_info_->num_bytes_inproc_send_buff_, thr_info_->num_bytes_inproc_recv_buff_); } std::string connect_addr; MakeInProcAddr(entity_id, &connect_addr); int32_t zmq_id = ZMQUtil::EntityID2ZmqID(entity_id); ZMQUtil::ZMQConnectSend(sock, connect_addr, zmq_id, connect_msg, size); } void CommBus::ConnectTo(int32_t entity_id, const std::string &network_addr, void *connect_msg, size_t size) { CHECK(!IsLocalEntity(entity_id)) << "Local entity " << entity_id; zmq::socket_t *sock = thr_info_->interproc_sock_.get(); if (sock == NULL) { try { thr_info_->interproc_sock_.reset(new zmq::socket_t(*zmq_ctx_, ZMQ_ROUTER)); } catch (...) { LOG(FATAL) << "Failed creating router socket"; } sock = thr_info_->interproc_sock_.get(); SetUpRouterSocket(sock, thr_info_->entity_id_, thr_info_->num_bytes_interproc_send_buff_, thr_info_->num_bytes_interproc_recv_buff_); } std::string connect_addr; MakeInterProcAddr(network_addr, &connect_addr); int32_t zmq_id = ZMQUtil::EntityID2ZmqID(entity_id); ZMQUtil::ZMQConnectSend(sock, connect_addr, zmq_id, connect_msg, size); } size_t CommBus::Send(int32_t entity_id, const void *data, size_t len) { zmq::socket_t *sock; if (IsLocalEntity(entity_id)) { sock = thr_info_->inproc_sock_.get(); } else { sock = thr_info_->interproc_sock_.get(); } int32_t recv_id = ZMQUtil::EntityID2ZmqID(entity_id); size_t nbytes = ZMQUtil::ZMQSend(sock, recv_id, data, len, 0); return nbytes; } size_t CommBus::SendInProc(int32_t entity_id, const void *data, size_t len) { zmq::socket_t *sock = thr_info_->inproc_sock_.get(); int32_t recv_id = ZMQUtil::EntityID2ZmqID(entity_id); size_t nbytes = ZMQUtil::ZMQSend(sock, recv_id, data, len, 0); return nbytes; } size_t CommBus::SendInterProc(int32_t entity_id, const void *data, size_t len) { zmq::socket_t *sock = thr_info_->interproc_sock_.get(); int32_t recv_id = ZMQUtil::EntityID2ZmqID(entity_id); size_t nbytes = ZMQUtil::ZMQSend(sock, recv_id, data, len, 0); return nbytes; } size_t CommBus::Send(int32_t entity_id, zmq::message_t &msg) { zmq::socket_t *sock; if (IsLocalEntity(entity_id)) { sock = thr_info_->inproc_sock_.get(); } else { sock = thr_info_->interproc_sock_.get(); } int32_t recv_id = ZMQUtil::EntityID2ZmqID(entity_id); size_t nbytes = ZMQUtil::ZMQSend(sock, recv_id, msg, 0); return nbytes; } size_t CommBus::SendInProc(int32_t entity_id, zmq::message_t &msg) { zmq::socket_t *sock = thr_info_->inproc_sock_.get(); int32_t recv_id = ZMQUtil::EntityID2ZmqID(entity_id); size_t nbytes = ZMQUtil::ZMQSend(sock, recv_id, msg, 0); return nbytes; } void CommBus::Recv(int32_t *entity_id, zmq::message_t *msg) { if (thr_info_->pollitems_.get() == NULL) { thr_info_->pollitems_.reset(new zmq::pollitem_t[2]); thr_info_->pollitems_[0].socket = *(thr_info_->inproc_sock_); thr_info_->pollitems_[0].events = ZMQ_POLLIN; thr_info_->pollitems_[1].socket = *(thr_info_->interproc_sock_); thr_info_->pollitems_[1].events = ZMQ_POLLIN; } zmq::poll(thr_info_->pollitems_.get(), 2); zmq::socket_t *sock; if (thr_info_->pollitems_[0].revents) { sock = thr_info_->inproc_sock_.get(); } else { sock = thr_info_->interproc_sock_.get(); } int32_t sender_id; ZMQUtil::ZMQRecv(sock, &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); } bool CommBus::RecvAsync(int32_t *entity_id, zmq::message_t *msg) { if (thr_info_->pollitems_.get() == NULL) { thr_info_->pollitems_.reset(new zmq::pollitem_t[2]); thr_info_->pollitems_[0].socket = *(thr_info_->inproc_sock_); thr_info_->pollitems_[0].events = ZMQ_POLLIN; thr_info_->pollitems_[1].socket = *(thr_info_->interproc_sock_); thr_info_->pollitems_[1].events = ZMQ_POLLIN; } zmq::poll(thr_info_->pollitems_.get(), 2, 0); zmq::socket_t *sock; if (thr_info_->pollitems_[0].revents) { sock = thr_info_->inproc_sock_.get(); } else if (thr_info_->pollitems_[1].revents) { sock = thr_info_->interproc_sock_.get(); } else { return false; } int32_t sender_id; ZMQUtil::ZMQRecv(sock, &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); return true; } bool CommBus::RecvTimeOut(int32_t *entity_id, zmq::message_t *msg, long timeout_milli) { if (thr_info_->pollitems_.get() == NULL) { thr_info_->pollitems_.reset(new zmq::pollitem_t[2]); thr_info_->pollitems_[0].socket = *(thr_info_->inproc_sock_); thr_info_->pollitems_[0].events = ZMQ_POLLIN; thr_info_->pollitems_[1].socket = *(thr_info_->interproc_sock_); thr_info_->pollitems_[1].events = ZMQ_POLLIN; } zmq::poll(thr_info_->pollitems_.get(), 2, timeout_milli); zmq::socket_t *sock; if (thr_info_->pollitems_[0].revents) { sock = thr_info_->inproc_sock_.get(); } else if (thr_info_->pollitems_[1].revents) { sock = thr_info_->interproc_sock_.get(); } else { return false; } int32_t sender_id; ZMQUtil::ZMQRecv(sock, &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); return true; } void CommBus::RecvInProc(int32_t *entity_id, zmq::message_t *msg) { int32_t sender_id; ZMQUtil::ZMQRecv(thr_info_->inproc_sock_.get(), &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); } bool CommBus::RecvInProcAsync(int32_t *entity_id, zmq::message_t *msg) { int32_t sender_id; bool recved = ZMQUtil::ZMQRecvAsync(thr_info_->inproc_sock_.get(), &sender_id, msg); if (recved) { *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); } return recved; } bool CommBus::RecvInProcTimeOut(int32_t *entity_id, zmq::message_t *msg, long timeout_milli) { if (thr_info_->inproc_pollitem_.get() == NULL) { thr_info_->inproc_pollitem_.reset(new zmq::pollitem_t); thr_info_->inproc_pollitem_->socket = *(thr_info_->inproc_sock_); thr_info_->inproc_pollitem_->events = ZMQ_POLLIN; } zmq::poll(thr_info_->inproc_pollitem_.get(), 1, timeout_milli); zmq::socket_t *sock; if (thr_info_->inproc_pollitem_->revents) { sock = thr_info_->inproc_sock_.get(); } else { return false; } int32_t sender_id; ZMQUtil::ZMQRecv(sock, &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); return true; } void CommBus::RecvInterProc(int32_t *entity_id, zmq::message_t *msg) { int32_t sender_id; ZMQUtil::ZMQRecv(thr_info_->interproc_sock_.get(), &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); } bool CommBus::RecvInterProcAsync(int32_t *entity_id, zmq::message_t *msg) { int32_t sender_id; bool recved = ZMQUtil::ZMQRecvAsync(thr_info_->interproc_sock_.get(), &sender_id, msg); if (recved) { *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); } return recved; } bool CommBus::RecvInterProcTimeOut(int32_t *entity_id, zmq::message_t *msg, long timeout_milli) { if (thr_info_->interproc_pollitem_.get() == NULL) { thr_info_->interproc_pollitem_.reset(new zmq::pollitem_t); thr_info_->interproc_pollitem_->socket = *(thr_info_->interproc_sock_); thr_info_->interproc_pollitem_->events = ZMQ_POLLIN; } zmq::poll(thr_info_->interproc_pollitem_.get(), 1, timeout_milli); zmq::socket_t *sock; if (thr_info_->interproc_pollitem_->revents) { sock = thr_info_->interproc_sock_.get(); } else { return false; } int32_t sender_id; ZMQUtil::ZMQRecv(sock, &sender_id, msg); *entity_id = ZMQUtil::ZmqID2EntityID(sender_id); return true; } } // namespace petuum
31.52619
80
0.711502
ForrestGan
c4d169b085d06604a3a2f6aba8757a47e53b2f21
16,735
cpp
C++
test/number/Figurate.cpp
wtmitchell/project_euler
b0fd328af41901aa53f757f1dd84f44f71d7be44
[ "MIT" ]
2
2016-04-03T08:44:15.000Z
2018-10-05T02:12:19.000Z
test/number/Figurate.cpp
wtmitchell/challenge_problems
b0fd328af41901aa53f757f1dd84f44f71d7be44
[ "MIT" ]
null
null
null
test/number/Figurate.cpp
wtmitchell/challenge_problems
b0fd328af41901aa53f757f1dd84f44f71d7be44
[ "MIT" ]
null
null
null
//===-- test/util/Figureate.cpp ---------------------------------*- C++ -*-===// // // Challenge Problem solutions by Will Mitchell // // This file is distributed under the MIT License. See LICENSE for details. // //===----------------------------------------------------------------------===// #include <gtest/gtest.h> #include "number/Figurate.h" using number::isSquare; TEST(Figurate, isSquare) { // Check first 512 numbers, which is enough to go through the mod 256 // characterization twice EXPECT_TRUE(isSquare(0)); EXPECT_TRUE(isSquare(1)); EXPECT_FALSE(isSquare(2)); EXPECT_FALSE(isSquare(3)); EXPECT_TRUE(isSquare(4)); EXPECT_FALSE(isSquare(5)); EXPECT_FALSE(isSquare(6)); EXPECT_FALSE(isSquare(7)); EXPECT_FALSE(isSquare(8)); EXPECT_TRUE(isSquare(9)); EXPECT_FALSE(isSquare(10)); EXPECT_FALSE(isSquare(11)); EXPECT_FALSE(isSquare(12)); EXPECT_FALSE(isSquare(13)); EXPECT_FALSE(isSquare(14)); EXPECT_FALSE(isSquare(15)); EXPECT_TRUE(isSquare(16)); EXPECT_FALSE(isSquare(17)); EXPECT_FALSE(isSquare(18)); EXPECT_FALSE(isSquare(19)); EXPECT_FALSE(isSquare(20)); EXPECT_FALSE(isSquare(21)); EXPECT_FALSE(isSquare(22)); EXPECT_FALSE(isSquare(23)); EXPECT_FALSE(isSquare(24)); EXPECT_TRUE(isSquare(25)); EXPECT_FALSE(isSquare(26)); EXPECT_FALSE(isSquare(27)); EXPECT_FALSE(isSquare(28)); EXPECT_FALSE(isSquare(29)); EXPECT_FALSE(isSquare(30)); EXPECT_FALSE(isSquare(31)); EXPECT_FALSE(isSquare(32)); EXPECT_FALSE(isSquare(33)); EXPECT_FALSE(isSquare(34)); EXPECT_FALSE(isSquare(35)); EXPECT_TRUE(isSquare(36)); EXPECT_FALSE(isSquare(37)); EXPECT_FALSE(isSquare(38)); EXPECT_FALSE(isSquare(39)); EXPECT_FALSE(isSquare(40)); EXPECT_FALSE(isSquare(41)); EXPECT_FALSE(isSquare(42)); EXPECT_FALSE(isSquare(43)); EXPECT_FALSE(isSquare(44)); EXPECT_FALSE(isSquare(45)); EXPECT_FALSE(isSquare(46)); EXPECT_FALSE(isSquare(47)); EXPECT_FALSE(isSquare(48)); EXPECT_TRUE(isSquare(49)); EXPECT_FALSE(isSquare(50)); EXPECT_FALSE(isSquare(51)); EXPECT_FALSE(isSquare(52)); EXPECT_FALSE(isSquare(53)); EXPECT_FALSE(isSquare(54)); EXPECT_FALSE(isSquare(55)); EXPECT_FALSE(isSquare(56)); EXPECT_FALSE(isSquare(57)); EXPECT_FALSE(isSquare(58)); EXPECT_FALSE(isSquare(59)); EXPECT_FALSE(isSquare(60)); EXPECT_FALSE(isSquare(61)); EXPECT_FALSE(isSquare(62)); EXPECT_FALSE(isSquare(63)); EXPECT_TRUE(isSquare(64)); EXPECT_FALSE(isSquare(65)); EXPECT_FALSE(isSquare(66)); EXPECT_FALSE(isSquare(67)); EXPECT_FALSE(isSquare(68)); EXPECT_FALSE(isSquare(69)); EXPECT_FALSE(isSquare(70)); EXPECT_FALSE(isSquare(71)); EXPECT_FALSE(isSquare(72)); EXPECT_FALSE(isSquare(73)); EXPECT_FALSE(isSquare(74)); EXPECT_FALSE(isSquare(75)); EXPECT_FALSE(isSquare(76)); EXPECT_FALSE(isSquare(77)); EXPECT_FALSE(isSquare(78)); EXPECT_FALSE(isSquare(79)); EXPECT_FALSE(isSquare(80)); EXPECT_TRUE(isSquare(81)); EXPECT_FALSE(isSquare(82)); EXPECT_FALSE(isSquare(83)); EXPECT_FALSE(isSquare(84)); EXPECT_FALSE(isSquare(85)); EXPECT_FALSE(isSquare(86)); EXPECT_FALSE(isSquare(87)); EXPECT_FALSE(isSquare(88)); EXPECT_FALSE(isSquare(89)); EXPECT_FALSE(isSquare(90)); EXPECT_FALSE(isSquare(91)); EXPECT_FALSE(isSquare(92)); EXPECT_FALSE(isSquare(93)); EXPECT_FALSE(isSquare(94)); EXPECT_FALSE(isSquare(95)); EXPECT_FALSE(isSquare(96)); EXPECT_FALSE(isSquare(97)); EXPECT_FALSE(isSquare(98)); EXPECT_FALSE(isSquare(99)); EXPECT_TRUE(isSquare(100)); EXPECT_FALSE(isSquare(101)); EXPECT_FALSE(isSquare(102)); EXPECT_FALSE(isSquare(103)); EXPECT_FALSE(isSquare(104)); EXPECT_FALSE(isSquare(105)); EXPECT_FALSE(isSquare(106)); EXPECT_FALSE(isSquare(107)); EXPECT_FALSE(isSquare(108)); EXPECT_FALSE(isSquare(109)); EXPECT_FALSE(isSquare(110)); EXPECT_FALSE(isSquare(111)); EXPECT_FALSE(isSquare(112)); EXPECT_FALSE(isSquare(113)); EXPECT_FALSE(isSquare(114)); EXPECT_FALSE(isSquare(115)); EXPECT_FALSE(isSquare(116)); EXPECT_FALSE(isSquare(117)); EXPECT_FALSE(isSquare(118)); EXPECT_FALSE(isSquare(119)); EXPECT_FALSE(isSquare(120)); EXPECT_TRUE(isSquare(121)); EXPECT_FALSE(isSquare(122)); EXPECT_FALSE(isSquare(123)); EXPECT_FALSE(isSquare(124)); EXPECT_FALSE(isSquare(125)); EXPECT_FALSE(isSquare(126)); EXPECT_FALSE(isSquare(127)); EXPECT_FALSE(isSquare(128)); EXPECT_FALSE(isSquare(129)); EXPECT_FALSE(isSquare(130)); EXPECT_FALSE(isSquare(131)); EXPECT_FALSE(isSquare(132)); EXPECT_FALSE(isSquare(133)); EXPECT_FALSE(isSquare(134)); EXPECT_FALSE(isSquare(135)); EXPECT_FALSE(isSquare(136)); EXPECT_FALSE(isSquare(137)); EXPECT_FALSE(isSquare(138)); EXPECT_FALSE(isSquare(139)); EXPECT_FALSE(isSquare(140)); EXPECT_FALSE(isSquare(141)); EXPECT_FALSE(isSquare(142)); EXPECT_FALSE(isSquare(143)); EXPECT_TRUE(isSquare(144)); EXPECT_FALSE(isSquare(145)); EXPECT_FALSE(isSquare(146)); EXPECT_FALSE(isSquare(147)); EXPECT_FALSE(isSquare(148)); EXPECT_FALSE(isSquare(149)); EXPECT_FALSE(isSquare(150)); EXPECT_FALSE(isSquare(151)); EXPECT_FALSE(isSquare(152)); EXPECT_FALSE(isSquare(153)); EXPECT_FALSE(isSquare(154)); EXPECT_FALSE(isSquare(155)); EXPECT_FALSE(isSquare(156)); EXPECT_FALSE(isSquare(157)); EXPECT_FALSE(isSquare(158)); EXPECT_FALSE(isSquare(159)); EXPECT_FALSE(isSquare(160)); EXPECT_FALSE(isSquare(161)); EXPECT_FALSE(isSquare(162)); EXPECT_FALSE(isSquare(163)); EXPECT_FALSE(isSquare(164)); EXPECT_FALSE(isSquare(165)); EXPECT_FALSE(isSquare(166)); EXPECT_FALSE(isSquare(167)); EXPECT_FALSE(isSquare(168)); EXPECT_TRUE(isSquare(169)); EXPECT_FALSE(isSquare(170)); EXPECT_FALSE(isSquare(171)); EXPECT_FALSE(isSquare(172)); EXPECT_FALSE(isSquare(173)); EXPECT_FALSE(isSquare(174)); EXPECT_FALSE(isSquare(175)); EXPECT_FALSE(isSquare(176)); EXPECT_FALSE(isSquare(177)); EXPECT_FALSE(isSquare(178)); EXPECT_FALSE(isSquare(179)); EXPECT_FALSE(isSquare(180)); EXPECT_FALSE(isSquare(181)); EXPECT_FALSE(isSquare(182)); EXPECT_FALSE(isSquare(183)); EXPECT_FALSE(isSquare(184)); EXPECT_FALSE(isSquare(185)); EXPECT_FALSE(isSquare(186)); EXPECT_FALSE(isSquare(187)); EXPECT_FALSE(isSquare(188)); EXPECT_FALSE(isSquare(189)); EXPECT_FALSE(isSquare(190)); EXPECT_FALSE(isSquare(191)); EXPECT_FALSE(isSquare(192)); EXPECT_FALSE(isSquare(193)); EXPECT_FALSE(isSquare(194)); EXPECT_FALSE(isSquare(195)); EXPECT_TRUE(isSquare(196)); EXPECT_FALSE(isSquare(197)); EXPECT_FALSE(isSquare(198)); EXPECT_FALSE(isSquare(199)); EXPECT_FALSE(isSquare(200)); EXPECT_FALSE(isSquare(201)); EXPECT_FALSE(isSquare(202)); EXPECT_FALSE(isSquare(203)); EXPECT_FALSE(isSquare(204)); EXPECT_FALSE(isSquare(205)); EXPECT_FALSE(isSquare(206)); EXPECT_FALSE(isSquare(207)); EXPECT_FALSE(isSquare(208)); EXPECT_FALSE(isSquare(209)); EXPECT_FALSE(isSquare(210)); EXPECT_FALSE(isSquare(211)); EXPECT_FALSE(isSquare(212)); EXPECT_FALSE(isSquare(213)); EXPECT_FALSE(isSquare(214)); EXPECT_FALSE(isSquare(215)); EXPECT_FALSE(isSquare(216)); EXPECT_FALSE(isSquare(217)); EXPECT_FALSE(isSquare(218)); EXPECT_FALSE(isSquare(219)); EXPECT_FALSE(isSquare(220)); EXPECT_FALSE(isSquare(221)); EXPECT_FALSE(isSquare(222)); EXPECT_FALSE(isSquare(223)); EXPECT_FALSE(isSquare(224)); EXPECT_TRUE(isSquare(225)); EXPECT_FALSE(isSquare(226)); EXPECT_FALSE(isSquare(227)); EXPECT_FALSE(isSquare(228)); EXPECT_FALSE(isSquare(229)); EXPECT_FALSE(isSquare(230)); EXPECT_FALSE(isSquare(231)); EXPECT_FALSE(isSquare(232)); EXPECT_FALSE(isSquare(233)); EXPECT_FALSE(isSquare(234)); EXPECT_FALSE(isSquare(235)); EXPECT_FALSE(isSquare(236)); EXPECT_FALSE(isSquare(237)); EXPECT_FALSE(isSquare(238)); EXPECT_FALSE(isSquare(239)); EXPECT_FALSE(isSquare(240)); EXPECT_FALSE(isSquare(241)); EXPECT_FALSE(isSquare(242)); EXPECT_FALSE(isSquare(243)); EXPECT_FALSE(isSquare(244)); EXPECT_FALSE(isSquare(245)); EXPECT_FALSE(isSquare(246)); EXPECT_FALSE(isSquare(247)); EXPECT_FALSE(isSquare(248)); EXPECT_FALSE(isSquare(249)); EXPECT_FALSE(isSquare(250)); EXPECT_FALSE(isSquare(251)); EXPECT_FALSE(isSquare(252)); EXPECT_FALSE(isSquare(253)); EXPECT_FALSE(isSquare(254)); EXPECT_FALSE(isSquare(255)); EXPECT_TRUE(isSquare(256)); EXPECT_FALSE(isSquare(257)); EXPECT_FALSE(isSquare(258)); EXPECT_FALSE(isSquare(259)); EXPECT_FALSE(isSquare(260)); EXPECT_FALSE(isSquare(261)); EXPECT_FALSE(isSquare(262)); EXPECT_FALSE(isSquare(263)); EXPECT_FALSE(isSquare(264)); EXPECT_FALSE(isSquare(265)); EXPECT_FALSE(isSquare(266)); EXPECT_FALSE(isSquare(267)); EXPECT_FALSE(isSquare(268)); EXPECT_FALSE(isSquare(269)); EXPECT_FALSE(isSquare(270)); EXPECT_FALSE(isSquare(271)); EXPECT_FALSE(isSquare(272)); EXPECT_FALSE(isSquare(273)); EXPECT_FALSE(isSquare(274)); EXPECT_FALSE(isSquare(275)); EXPECT_FALSE(isSquare(276)); EXPECT_FALSE(isSquare(277)); EXPECT_FALSE(isSquare(278)); EXPECT_FALSE(isSquare(279)); EXPECT_FALSE(isSquare(280)); EXPECT_FALSE(isSquare(281)); EXPECT_FALSE(isSquare(282)); EXPECT_FALSE(isSquare(283)); EXPECT_FALSE(isSquare(284)); EXPECT_FALSE(isSquare(285)); EXPECT_FALSE(isSquare(286)); EXPECT_FALSE(isSquare(287)); EXPECT_FALSE(isSquare(288)); EXPECT_TRUE(isSquare(289)); EXPECT_FALSE(isSquare(290)); EXPECT_FALSE(isSquare(291)); EXPECT_FALSE(isSquare(292)); EXPECT_FALSE(isSquare(293)); EXPECT_FALSE(isSquare(294)); EXPECT_FALSE(isSquare(295)); EXPECT_FALSE(isSquare(296)); EXPECT_FALSE(isSquare(297)); EXPECT_FALSE(isSquare(298)); EXPECT_FALSE(isSquare(299)); EXPECT_FALSE(isSquare(300)); EXPECT_FALSE(isSquare(301)); EXPECT_FALSE(isSquare(302)); EXPECT_FALSE(isSquare(303)); EXPECT_FALSE(isSquare(304)); EXPECT_FALSE(isSquare(305)); EXPECT_FALSE(isSquare(306)); EXPECT_FALSE(isSquare(307)); EXPECT_FALSE(isSquare(308)); EXPECT_FALSE(isSquare(309)); EXPECT_FALSE(isSquare(310)); EXPECT_FALSE(isSquare(311)); EXPECT_FALSE(isSquare(312)); EXPECT_FALSE(isSquare(313)); EXPECT_FALSE(isSquare(314)); EXPECT_FALSE(isSquare(315)); EXPECT_FALSE(isSquare(316)); EXPECT_FALSE(isSquare(317)); EXPECT_FALSE(isSquare(318)); EXPECT_FALSE(isSquare(319)); EXPECT_FALSE(isSquare(320)); EXPECT_FALSE(isSquare(321)); EXPECT_FALSE(isSquare(322)); EXPECT_FALSE(isSquare(323)); EXPECT_TRUE(isSquare(324)); EXPECT_FALSE(isSquare(325)); EXPECT_FALSE(isSquare(326)); EXPECT_FALSE(isSquare(327)); EXPECT_FALSE(isSquare(328)); EXPECT_FALSE(isSquare(329)); EXPECT_FALSE(isSquare(330)); EXPECT_FALSE(isSquare(331)); EXPECT_FALSE(isSquare(332)); EXPECT_FALSE(isSquare(333)); EXPECT_FALSE(isSquare(334)); EXPECT_FALSE(isSquare(335)); EXPECT_FALSE(isSquare(336)); EXPECT_FALSE(isSquare(337)); EXPECT_FALSE(isSquare(338)); EXPECT_FALSE(isSquare(339)); EXPECT_FALSE(isSquare(340)); EXPECT_FALSE(isSquare(341)); EXPECT_FALSE(isSquare(342)); EXPECT_FALSE(isSquare(343)); EXPECT_FALSE(isSquare(344)); EXPECT_FALSE(isSquare(345)); EXPECT_FALSE(isSquare(346)); EXPECT_FALSE(isSquare(347)); EXPECT_FALSE(isSquare(348)); EXPECT_FALSE(isSquare(349)); EXPECT_FALSE(isSquare(350)); EXPECT_FALSE(isSquare(351)); EXPECT_FALSE(isSquare(352)); EXPECT_FALSE(isSquare(353)); EXPECT_FALSE(isSquare(354)); EXPECT_FALSE(isSquare(355)); EXPECT_FALSE(isSquare(356)); EXPECT_FALSE(isSquare(357)); EXPECT_FALSE(isSquare(358)); EXPECT_FALSE(isSquare(359)); EXPECT_FALSE(isSquare(360)); EXPECT_TRUE(isSquare(361)); EXPECT_FALSE(isSquare(362)); EXPECT_FALSE(isSquare(363)); EXPECT_FALSE(isSquare(364)); EXPECT_FALSE(isSquare(365)); EXPECT_FALSE(isSquare(366)); EXPECT_FALSE(isSquare(367)); EXPECT_FALSE(isSquare(368)); EXPECT_FALSE(isSquare(369)); EXPECT_FALSE(isSquare(370)); EXPECT_FALSE(isSquare(371)); EXPECT_FALSE(isSquare(372)); EXPECT_FALSE(isSquare(373)); EXPECT_FALSE(isSquare(374)); EXPECT_FALSE(isSquare(375)); EXPECT_FALSE(isSquare(376)); EXPECT_FALSE(isSquare(377)); EXPECT_FALSE(isSquare(378)); EXPECT_FALSE(isSquare(379)); EXPECT_FALSE(isSquare(380)); EXPECT_FALSE(isSquare(381)); EXPECT_FALSE(isSquare(382)); EXPECT_FALSE(isSquare(383)); EXPECT_FALSE(isSquare(384)); EXPECT_FALSE(isSquare(385)); EXPECT_FALSE(isSquare(386)); EXPECT_FALSE(isSquare(387)); EXPECT_FALSE(isSquare(388)); EXPECT_FALSE(isSquare(389)); EXPECT_FALSE(isSquare(390)); EXPECT_FALSE(isSquare(391)); EXPECT_FALSE(isSquare(392)); EXPECT_FALSE(isSquare(393)); EXPECT_FALSE(isSquare(394)); EXPECT_FALSE(isSquare(395)); EXPECT_FALSE(isSquare(396)); EXPECT_FALSE(isSquare(397)); EXPECT_FALSE(isSquare(398)); EXPECT_FALSE(isSquare(399)); EXPECT_TRUE(isSquare(400)); EXPECT_FALSE(isSquare(401)); EXPECT_FALSE(isSquare(402)); EXPECT_FALSE(isSquare(403)); EXPECT_FALSE(isSquare(404)); EXPECT_FALSE(isSquare(405)); EXPECT_FALSE(isSquare(406)); EXPECT_FALSE(isSquare(407)); EXPECT_FALSE(isSquare(408)); EXPECT_FALSE(isSquare(409)); EXPECT_FALSE(isSquare(410)); EXPECT_FALSE(isSquare(411)); EXPECT_FALSE(isSquare(412)); EXPECT_FALSE(isSquare(413)); EXPECT_FALSE(isSquare(414)); EXPECT_FALSE(isSquare(415)); EXPECT_FALSE(isSquare(416)); EXPECT_FALSE(isSquare(417)); EXPECT_FALSE(isSquare(418)); EXPECT_FALSE(isSquare(419)); EXPECT_FALSE(isSquare(420)); EXPECT_FALSE(isSquare(421)); EXPECT_FALSE(isSquare(422)); EXPECT_FALSE(isSquare(423)); EXPECT_FALSE(isSquare(424)); EXPECT_FALSE(isSquare(425)); EXPECT_FALSE(isSquare(426)); EXPECT_FALSE(isSquare(427)); EXPECT_FALSE(isSquare(428)); EXPECT_FALSE(isSquare(429)); EXPECT_FALSE(isSquare(430)); EXPECT_FALSE(isSquare(431)); EXPECT_FALSE(isSquare(432)); EXPECT_FALSE(isSquare(433)); EXPECT_FALSE(isSquare(434)); EXPECT_FALSE(isSquare(435)); EXPECT_FALSE(isSquare(436)); EXPECT_FALSE(isSquare(437)); EXPECT_FALSE(isSquare(438)); EXPECT_FALSE(isSquare(439)); EXPECT_FALSE(isSquare(440)); EXPECT_TRUE(isSquare(441)); EXPECT_FALSE(isSquare(442)); EXPECT_FALSE(isSquare(443)); EXPECT_FALSE(isSquare(444)); EXPECT_FALSE(isSquare(445)); EXPECT_FALSE(isSquare(446)); EXPECT_FALSE(isSquare(447)); EXPECT_FALSE(isSquare(448)); EXPECT_FALSE(isSquare(449)); EXPECT_FALSE(isSquare(450)); EXPECT_FALSE(isSquare(451)); EXPECT_FALSE(isSquare(452)); EXPECT_FALSE(isSquare(453)); EXPECT_FALSE(isSquare(454)); EXPECT_FALSE(isSquare(455)); EXPECT_FALSE(isSquare(456)); EXPECT_FALSE(isSquare(457)); EXPECT_FALSE(isSquare(458)); EXPECT_FALSE(isSquare(459)); EXPECT_FALSE(isSquare(460)); EXPECT_FALSE(isSquare(461)); EXPECT_FALSE(isSquare(462)); EXPECT_FALSE(isSquare(463)); EXPECT_FALSE(isSquare(464)); EXPECT_FALSE(isSquare(465)); EXPECT_FALSE(isSquare(466)); EXPECT_FALSE(isSquare(467)); EXPECT_FALSE(isSquare(468)); EXPECT_FALSE(isSquare(469)); EXPECT_FALSE(isSquare(470)); EXPECT_FALSE(isSquare(471)); EXPECT_FALSE(isSquare(472)); EXPECT_FALSE(isSquare(473)); EXPECT_FALSE(isSquare(474)); EXPECT_FALSE(isSquare(475)); EXPECT_FALSE(isSquare(476)); EXPECT_FALSE(isSquare(477)); EXPECT_FALSE(isSquare(478)); EXPECT_FALSE(isSquare(479)); EXPECT_FALSE(isSquare(480)); EXPECT_FALSE(isSquare(481)); EXPECT_FALSE(isSquare(482)); EXPECT_FALSE(isSquare(483)); EXPECT_TRUE(isSquare(484)); EXPECT_FALSE(isSquare(485)); EXPECT_FALSE(isSquare(486)); EXPECT_FALSE(isSquare(487)); EXPECT_FALSE(isSquare(488)); EXPECT_FALSE(isSquare(489)); EXPECT_FALSE(isSquare(490)); EXPECT_FALSE(isSquare(491)); EXPECT_FALSE(isSquare(492)); EXPECT_FALSE(isSquare(493)); EXPECT_FALSE(isSquare(494)); EXPECT_FALSE(isSquare(495)); EXPECT_FALSE(isSquare(496)); EXPECT_FALSE(isSquare(497)); EXPECT_FALSE(isSquare(498)); EXPECT_FALSE(isSquare(499)); EXPECT_FALSE(isSquare(500)); EXPECT_FALSE(isSquare(501)); EXPECT_FALSE(isSquare(502)); EXPECT_FALSE(isSquare(503)); EXPECT_FALSE(isSquare(504)); EXPECT_FALSE(isSquare(505)); EXPECT_FALSE(isSquare(506)); EXPECT_FALSE(isSquare(507)); EXPECT_FALSE(isSquare(508)); EXPECT_FALSE(isSquare(509)); EXPECT_FALSE(isSquare(510)); EXPECT_FALSE(isSquare(511)); EXPECT_FALSE(isSquare(512)); // Verify all the squares in unsigneds for (auto i = 0u; i < (1u << sizeof(unsigned) * 4) - 1; ++i) EXPECT_TRUE(isSquare(i * i)); /* // Verify all the squares in unsigned longs for (auto i = 0ul; i < (1ul << sizeof(unsigned long) * 4) - 1; ++i) EXPECT_TRUE(isSquare(i * i)); // Verify all the squares in unsigned long longs for (auto i = 0ull; i < (1ull << sizeof(unsigned long long) * 4) - 1; ++i) EXPECT_TRUE(isSquare(i * i)); */ }
30.876384
80
0.729668
wtmitchell
c4d4218ff85f2a2605c9a9c5b6257b4afad84b88
11,253
cc
C++
support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
1
2022-03-03T08:47:33.000Z
2022-03-03T08:47:33.000Z
support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
null
null
null
support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
null
null
null
#ifdef OS_AIX #include <memory.h> #endif #ifdef OS_OPENBSD #include <memory.h> #endif #ifdef OS_LINUX #include <string.h> #endif #include <sys/types.h> #include <sys/socket.h> #include <sys/uio.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdarg.h> #include <stdio.h> #include <unistd.h> #include <netz.h> #include "support.h" c_string::c_string() { data = 0; len = 0; } c_string::c_string(const c_string &cstr) { u_int str_len = cstr.get_len(); data = new string[str_len]; memcpy(data, cstr.get_data(), str_len); len = str_len; } c_string::c_string(string *format, ...) { string str[C_STRING_LEN]; va_list varg; va_start(varg, format); u_int str_len = vsnprintf(str, C_STRING_LEN, format, varg); data = new string[str_len]; memcpy(data, str, str_len); len = str_len; } c_string::~c_string() { if (data) { delete data; data = 0; len = 0; } } void c_string::clear() { if (data) { delete data; data = 0; len = 0; } } u_int c_string::add(const c_string &cstr) { u_int str_len = cstr.get_len(); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, cstr.get_data(), str_len); len += str_len; if (data) { delete tmp_data; } return str_len; } u_int c_string::add_raw(byte *str, u_int str_len) { string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, str, str_len); len += str_len; if (data) { delete tmp_data; } return str_len; } u_int c_string::add_bin(byte value) { string str[] = "%u%u%u%u%u%u%u%u"; return add_bin(str, value); } u_int c_string::add_bin(string *str, byte value) { return add(str, bits(value, 0x80), bits(value, 0x40), bits(value, 0x20), bits(value, 0x10), bits(value, 0x08), bits(value, 0x04), bits(value, 0x02), bits(value, 0x01)); } u_int c_string::add_bin(word value) { string str[] = "%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u"; return add_bin(str, value); } u_int c_string::add_bin(string *str, word value) { return add(str, bits(value, 0x8000), bits(value, 0x4000), bits(value, 0x2000), bits(value, 0x1000), bits(value, 0x0800), bits(value, 0x0400), bits(value, 0x0200), bits(value, 0x0100), bits(value, 0x0080), bits(value, 0x0040), bits(value, 0x0020), bits(value, 0x0010), bits(value, 0x0008), bits(value, 0x0004), bits(value, 0x0002), bits(value, 0x0001)); } u_int c_string::add_bin(dword value) { string str[] = "%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u" "%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u"; return add_bin(str, value); } u_int c_string::add_bin(string *str, dword value) { return add(str, bits(value, 0x80000000), bits(value, 0x40000000), bits(value, 0x20000000), bits(value, 0x10000000), bits(value, 0x08000000), bits(value, 0x04000000), bits(value, 0x02000000), bits(value, 0x01000000), bits(value, 0x00800000), bits(value, 0x00400000), bits(value, 0x00200000), bits(value, 0x00100000), bits(value, 0x00080000), bits(value, 0x00040000), bits(value, 0x00020000), bits(value, 0x00010000), bits(value, 0x00008000), bits(value, 0x00004000), bits(value, 0x00002000), bits(value, 0x00001000), bits(value, 0x00000800), bits(value, 0x00000400), bits(value, 0x00000200), bits(value, 0x00000100), bits(value, 0x00000080), bits(value, 0x00000040), bits(value, 0x00000020), bits(value, 0x00000010), bits(value, 0x00000008), bits(value, 0x00000004), bits(value, 0x00000002), bits(value, 0x00000001)); } u_int c_string::add_hex(byte value) { string str[] = "0x%02X"; return add_bin(str, value); } u_int c_string::add_hex(string *str, byte value) { return add(str, value); } u_int c_string::add_hex(word value) { string str[] = "0x%02X%02X"; return add_bin(str, value); } u_int c_string::add_hex(string *str, word value) { return add(str, bits(value, 0xFF00), bits(value, 0x00FF)); } u_int c_string::add_hex(dword value) { string str[] = "0x%02X%02X%02X%02X"; return add_bin(str, value); } u_int c_string::add_hex(string *str, dword value) { return add(str, bits(value, 0xFF000000), bits(value, 0x00FF0000), bits(value, 0x0000FF00), bits(value, 0x000000FF)); } u_int c_string::add(char c) { string *tmp_data = data; data = new string[len + 1]; memcpy(data, tmp_data, len); *(data + len) = c; len += 1; if (data) { delete tmp_data; } return len + 1; } u_int c_string::add(string *format, ...) { string str[C_STRING_LEN]; va_list varg; va_start(varg, format); u_int str_len = vsnprintf(str, C_STRING_LEN, format, varg); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, str, str_len); len += str_len; if (data) { delete tmp_data; } return str_len; } string *c_string::get_data() const { return data; } u_int c_string::get_len() const { return len; } c_string &c_string::operator=(const c_string &cstr) { u_int str_len = cstr.get_len(); if (data) { delete data; } data = new string[str_len]; memcpy(data, cstr.get_data(), str_len); len = str_len; return *this; } c_string &c_string::operator=(const string *str) { u_int str_len = strlen(str); if (data) { delete data; } data = new string[str_len]; memcpy(data, str, str_len); len = str_len; return *this; } c_string &c_string::operator+=(const c_string &cstr) { u_int str_len = cstr.get_len(); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, cstr.get_data(), str_len); len += str_len; if (data) { delete tmp_data; } return *this; } c_string &c_string::operator+=(const string *str) { u_int str_len = strlen(str); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, str, str_len); len += str_len; if (data) { delete tmp_data; } return *this; } c_string &c_string::operator<<(const c_string &cstr) { u_int str_len = cstr.get_len(); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, cstr.get_data(), str_len); len += str_len; if (data) { delete tmp_data; } return *this; } c_string &c_string::operator<<(const string *str) { u_int str_len = strlen(str); string *tmp_data = data; data = new string[len + str_len]; memcpy(data, tmp_data, len); memcpy(data + len, str, str_len); len += str_len; if (data) { delete tmp_data; } return *this; } bool c_string::operator==(const c_string &cstr) { if (cstr.get_len() != len) { return false; } for (u_int i = 0; i < len; i++) { if (cstr.get_data()[i] != data[i]) { return false; } } return true; } bool c_string::operator==(const string *str) { if (strlen(str) != len) { return false; } for (u_int i = 0; i < len; i++) { if (str[i] != data[i]) { return false; } } return true; } c_string print_line() { return c_string((char *)"----------------------------------------" "---------------------------------------\n"); } c_string print_options_string(c_string opt_cstr) { c_string output_string; string options_string[512]; for (int i = 0; i < 512; i++) { options_string[i] = 0; } memcpy(options_string, opt_cstr.get_data(), opt_cstr.get_len()); u_int cursor_pos = 13; u_int options_string_pos = 0; u_int last_break_pos = 0; output_string.add((char *)"\n\tOPTS "); while (options_string[options_string_pos]) { if (options_string[options_string_pos] == ']') { options_string[options_string_pos] = 0; if (cursor_pos + options_string_pos - last_break_pos + 1 > 79) { output_string.add((char *)"\n\t "); cursor_pos = 13; } output_string.add((char *)"%s]", options_string + last_break_pos); cursor_pos += options_string_pos - last_break_pos + 1; last_break_pos = options_string_pos + 1; } if (options_string[options_string_pos] == ',') { options_string[options_string_pos] = 0; if (cursor_pos + options_string_pos - last_break_pos + 1 > 79) { output_string.add((char *)"\n\t "); cursor_pos = 13; } output_string.add((char *)"%s,", options_string + last_break_pos); cursor_pos += options_string_pos - last_break_pos + 1; last_break_pos = options_string_pos + 1; } if (options_string[options_string_pos] == '}') { if (options_string[options_string_pos + 1] != ']') { options_string[options_string_pos] = 0; if (cursor_pos + options_string_pos - last_break_pos + 1 > 79) { output_string.add((char *)"\n\t "); cursor_pos = 13; } output_string.add((char *)"%s}", options_string + last_break_pos); cursor_pos += options_string_pos - last_break_pos + 1; last_break_pos = options_string_pos + 1; } } options_string_pos++; } output_string.add((char *)"%s", options_string + last_break_pos); return output_string; } char *argvncpy(char *str, char **argv, u_int max_len) { char **p; u_int len = 0; char *src; char *dst = str; p = argv; if (*p == 0) return str; while (*p && max_len--) len += strlen(*p++) + 1; p = argv; while ((src = *p++) != NULL) { while ((*dst++ = *src++) != '\0') ; dst[-1] = ' '; } dst[-1] = '\0'; return str; }
19.468858
82
0.528748
PariKhaleghi
c4dc0aaaa96c38ea0a26e5d4aea5749034dee5b1
2,505
cpp
C++
src/xmlsettingsdialog/itemhandlers/itemhandlertreeview.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
120
2015-01-22T14:10:39.000Z
2021-11-25T12:57:16.000Z
src/xmlsettingsdialog/itemhandlers/itemhandlertreeview.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
8
2015-02-07T19:38:19.000Z
2017-11-30T20:18:28.000Z
src/xmlsettingsdialog/itemhandlers/itemhandlertreeview.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
33
2015-02-07T16:59:55.000Z
2021-10-12T00:36:40.000Z
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2010-2011 Oleg Linkin * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt) **********************************************************************/ #include "itemhandlertreeview.h" #include <QDomElement> #include <QLabel> #include <QTreeView> #include <QGridLayout> #include <QtDebug> #include "../itemhandlerfactory.h" namespace LC { ItemHandlerTreeView::ItemHandlerTreeView (ItemHandlerFactory *factory, Util::XmlSettingsDialog *xsd) : ItemHandlerBase { xsd } , Factory_ { factory } { } bool ItemHandlerTreeView::CanHandle (const QDomElement& element) const { return element.attribute ("type") == "treeview"; } void ItemHandlerTreeView::Handle (const QDomElement& item, QWidget *pwidget) { QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ()); QTreeView *tree = new QTreeView (XSD_->GetWidget ()); tree->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); QString prop = item.attribute ("property"); tree->setObjectName (prop); tree->setHeaderHidden (item.attribute ("hideHeader") == "true"); Factory_->RegisterDatasourceSetter (prop, [this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog*) { SetDataSource (str, m); }); Propname2TreeView_ [prop] = tree; QLabel *label = new QLabel (XSD_->GetLabel (item)); label->setWordWrap (false); tree->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this)); tree->setProperty ("SearchTerms", label->text ()); int row = lay->rowCount (); lay->addWidget (label, row, 0, Qt::AlignLeft); lay->addWidget (tree, row + 1, 0, 1, -1); } QVariant ItemHandlerTreeView::GetValue (const QDomElement&, QVariant) const { return QVariant (); } void ItemHandlerTreeView::SetValue (QWidget*, const QVariant&) const { } void ItemHandlerTreeView::UpdateValue (QDomElement&, const QVariant&) const { } QVariant ItemHandlerTreeView::GetObjectValue (QObject*) const { return QVariant (); } void ItemHandlerTreeView::SetDataSource (const QString& prop, QAbstractItemModel *model) { QTreeView *tree = Propname2TreeView_ [prop]; if (!tree) { qWarning () << Q_FUNC_INFO << "listview for property" << prop << "not found"; return; } tree->setModel (model); } }
27.527473
101
0.665868
Maledictus
c4e37f9176d1b91d7ee51b1d54851693e46b976e
6,192
hxx
C++
Modules/Core/Transform/include/otbInverseLogPolarTransform.hxx
heralex/OTB
c52b504b64dc89c8fe9cac8af39b8067ca2c3a57
[ "Apache-2.0" ]
317
2015-01-19T08:40:58.000Z
2022-03-17T11:55:48.000Z
Modules/Core/Transform/include/otbInverseLogPolarTransform.hxx
guandd/OTB
707ce4c6bb4c7186e3b102b2b00493a5050872cb
[ "Apache-2.0" ]
18
2015-07-29T14:13:45.000Z
2021-03-29T12:36:24.000Z
Modules/Core/Transform/include/otbInverseLogPolarTransform.hxx
guandd/OTB
707ce4c6bb4c7186e3b102b2b00493a5050872cb
[ "Apache-2.0" ]
132
2015-02-21T23:57:25.000Z
2022-03-25T16:03:16.000Z
/* * Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * 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 otbInverseLogPolarTransform_hxx #define otbInverseLogPolarTransform_hxx #include "otbInverseLogPolarTransform.h" #include "otbMacro.h" #include "otbMath.h" namespace otb { /** * Constructor. */ template <class TScalarType> InverseLogPolarTransform<TScalarType>::InverseLogPolarTransform() : Superclass(4) { m_Center[0] = 0.0; m_Center[1] = 0.0; m_Scale[0] = 1.0; m_Scale[1] = 1.0; } /** * Destructor. */ template <class TScalarType> InverseLogPolarTransform<TScalarType>::~InverseLogPolarTransform() { } /** * Set the transform parameters through the standard interface. * \param parameters The parameters of the transform. */ template <class TScalarType> void InverseLogPolarTransform<TScalarType>::SetParameters(const ParametersType& parameters) { m_Center[0] = parameters[0]; m_Center[1] = parameters[1]; m_Scale[0] = parameters[2]; m_Scale[1] = parameters[3]; otbMsgDebugMacro(<< "Call To SetParameters: Center=" << m_Center << ", Scale=" << m_Scale); this->m_Parameters = parameters; this->Modified(); } /** * Get the transform parameters through the standard interface. * \return The parameters of the transform. */ template <class TScalarType> typename InverseLogPolarTransform<TScalarType>::ParametersType& InverseLogPolarTransform<TScalarType>::GetParameters(void) const { // Filling parameters vector this->m_Parameters[0] = m_Center[0]; this->m_Parameters[1] = m_Center[1]; this->m_Parameters[2] = m_Scale[0]; this->m_Parameters[3] = m_Scale[1]; return this->m_Parameters; } /** * Transform a point. * \param point The point to transform. * \return The transformed point. */ template <class TScalarType> typename InverseLogPolarTransform<TScalarType>::OutputPointType InverseLogPolarTransform<TScalarType>::TransformPoint(const InputPointType& point) const { OutputPointType result; double rho = std::sqrt(std::pow(point[0] - m_Center[0], 2) + std::pow(point[1] - m_Center[1], 2)); if (rho > 0) { result[0] = (1. / m_Scale[0]) * std::asin((point[1] - m_Center[1]) / rho); // degree conversion result[0] = result[0] * (180. / CONST_PI); // Deplacing the range to [0, 90], [270, 360] result[0] = result[0] > 0. ? result[0] : result[0] + 360.; // Avoiding asin indetermination if ((point[0] - m_Center[0]) >= 0) { result[0] = result[0] < 90. ? result[0] + 90. : result[0] - 90.; } result[1] = (1. / m_Scale[1]) * std::log(rho); // otbMsgDebugMacro(<<std::log(std::pow(point[0]-m_Center[0], 2)+std::pow(point[1]-m_Center[1], 2))); } else { // for rho=0, reject the point outside the angular range to avoid nan error result[0] = 400.; result[1] = 0.; } return result; } /** * Transform a vector representing a point. * \param vector The point to transform. * \return The transformed point. */ template <class TScalarType> typename InverseLogPolarTransform<TScalarType>::OutputVectorType InverseLogPolarTransform<TScalarType>::TransformVector(const InputVectorType& vector) const { OutputVectorType result; double rho = std::sqrt(std::pow(vector[0] - m_Center[0], 2) + std::pow(vector[1] - m_Center[1], 2)); if (rho > 0) { result[0] = (1 / m_Scale[0]) * std::asin((vector[1] - m_Center[1]) / rho); // degree conversion result[0] = result[0] * (180 / CONST_PI); // Deplacing the range to [0, 90], [270, 360] result[0] = result[0] > 0 ? result[0] : result[0] + 360; // Avoiding asin indetermination if ((vector[0] - m_Center[0]) >= 0) { result[0] = result[0] < 90 ? result[0] + 90 : result[0] - 90; } result[1] = (1 / m_Scale[1]) * std::log(rho); // otbMsgDebugMacro(<<std::log(std::pow(vector[0]-m_Center[0], 2)+std::pow(vector[1]-m_Center[1], 2))); } else { // for rho=0, reject the vector outside the angular range to avoid nan error result[0] = 400; result[1] = 0; } return result; } /** * Transform a vnl vector representing a vector. * \param vector The vector to transform. * \return The transformed vector. */ template <class TScalarType> typename InverseLogPolarTransform<TScalarType>::OutputVnlVectorType InverseLogPolarTransform<TScalarType>::TransformVector(const InputVnlVectorType& vector) const { OutputVnlVectorType result; double rho = std::sqrt(std::pow(vector[0], 2) + std::pow(vector[1], 2)); if (rho > 0) { result[0] = (1 / m_Scale[0]) * std::asin((vector[1] - m_Center[1]) / rho); // degree conversion result[0] = result[0] * (180 / CONST_PI); // Deplacing the range to [0, 90], [270, 360] result[0] = result[0] > 0 ? result[0] : result[0] + 360; // Avoiding std::asin indetermination if ((vector[0] - m_Center[0]) >= 0) { result[0] = result[0] < 90 ? result[0] + 90 : result[0] - 90; } result[1] = (1 / m_Scale[1]) * std::log(rho); // otbMsgDebugMacro(<<log(std::pow(vector[0]-m_Center[0], 2)+std::pow(vector[1]-m_Center[1], 2))); } else { // for rho=0, reject the vector outside the angular range to avoid nan error result[0] = 400; result[1] = 0; } return result; } /** * PrintSelf method. */ template <class TScalarType> void InverseLogPolarTransform<TScalarType>::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "Center: " << m_Center << std::endl; os << indent << "Scale: " << m_Scale << std::endl; } } // end namespace otb #endif
32.25
156
0.662145
heralex
c4e5dd2b58befcb38b63dbffe0230e53131464ff
99,147
cc
C++
Headers/CrossCheatTalkMessages.pb.cc
eacbypass/SorryHack
5d8bc1a1b7680e825abc375a0849665c24cdf70c
[ "MIT" ]
4
2021-11-25T19:13:42.000Z
2022-01-06T22:29:40.000Z
Headers/CrossCheatTalkMessages.pb.cc
eacbypass/SorryHack
5d8bc1a1b7680e825abc375a0849665c24cdf70c
[ "MIT" ]
null
null
null
Headers/CrossCheatTalkMessages.pb.cc
eacbypass/SorryHack
5d8bc1a1b7680e825abc375a0849665c24cdf70c
[ "MIT" ]
null
null
null
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: CrossCheatTalkMessages.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include "CrossCheatTalkMessages.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) namespace { const ::google::protobuf::Descriptor* VectorMsg_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* VectorMsg_reflection_ = NULL; const ::google::protobuf::Descriptor* CrossCheatInitMsg_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* CrossCheatInitMsg_reflection_ = NULL; const ::google::protobuf::Descriptor* EntityPacketMsg_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* EntityPacketMsg_reflection_ = NULL; const ::google::protobuf::Descriptor* ExploitOnMsg_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* ExploitOnMsg_reflection_ = NULL; const ::google::protobuf::Descriptor* SharedESPUpdate_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* SharedESPUpdate_reflection_ = NULL; const ::google::protobuf::Descriptor* HitBoxMsg_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* HitBoxMsg_reflection_ = NULL; const ::google::protobuf::Descriptor* OriginUpdate_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* OriginUpdate_reflection_ = NULL; const ::google::protobuf::Descriptor* HarpoonChat_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* HarpoonChat_reflection_ = NULL; const ::google::protobuf::EnumDescriptor* CrossCheatMsgType_descriptor_ = NULL; } // namespace void protobuf_AssignDesc_CrossCheatTalkMessages_2eproto() { protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "CrossCheatTalkMessages.proto"); GOOGLE_CHECK(file != NULL); VectorMsg_descriptor_ = file->message_type(0); static const int VectorMsg_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(VectorMsg, x_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(VectorMsg, y_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(VectorMsg, z_), }; VectorMsg_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( VectorMsg_descriptor_, VectorMsg::default_instance_, VectorMsg_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(VectorMsg, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(VectorMsg, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(VectorMsg)); CrossCheatInitMsg_descriptor_ = file->message_type(1); static const int CrossCheatInitMsg_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CrossCheatInitMsg, steamid_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CrossCheatInitMsg, steamindex_), }; CrossCheatInitMsg_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( CrossCheatInitMsg_descriptor_, CrossCheatInitMsg::default_instance_, CrossCheatInitMsg_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CrossCheatInitMsg, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CrossCheatInitMsg, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(CrossCheatInitMsg)); EntityPacketMsg_descriptor_ = file->message_type(2); static const int EntityPacketMsg_offsets_[9] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, x_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, y_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, z_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, steamid_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, serverindex_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, playerhealth_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, playerarmour_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, origin_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, matrixdata_), }; EntityPacketMsg_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( EntityPacketMsg_descriptor_, EntityPacketMsg::default_instance_, EntityPacketMsg_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EntityPacketMsg, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(EntityPacketMsg)); ExploitOnMsg_descriptor_ = file->message_type(3); static const int ExploitOnMsg_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExploitOnMsg, on_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExploitOnMsg, speed_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExploitOnMsg, tickstarted_), }; ExploitOnMsg_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( ExploitOnMsg_descriptor_, ExploitOnMsg::default_instance_, ExploitOnMsg_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExploitOnMsg, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExploitOnMsg, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(ExploitOnMsg)); SharedESPUpdate_descriptor_ = file->message_type(4); static const int SharedESPUpdate_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SharedESPUpdate, entinfo_), }; SharedESPUpdate_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( SharedESPUpdate_descriptor_, SharedESPUpdate::default_instance_, SharedESPUpdate_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SharedESPUpdate, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SharedESPUpdate, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(SharedESPUpdate)); HitBoxMsg_descriptor_ = file->message_type(5); static const int HitBoxMsg_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, mins_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, maxs_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, bone_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, radius_), }; HitBoxMsg_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( HitBoxMsg_descriptor_, HitBoxMsg::default_instance_, HitBoxMsg_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HitBoxMsg, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(HitBoxMsg)); OriginUpdate_descriptor_ = file->message_type(6); static const int OriginUpdate_offsets_[8] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, steamid_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, x_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, y_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, z_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, eyeangles_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, eyeposition_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, matrix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, hitboxes_), }; OriginUpdate_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( OriginUpdate_descriptor_, OriginUpdate::default_instance_, OriginUpdate_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OriginUpdate, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(OriginUpdate)); HarpoonChat_descriptor_ = file->message_type(7); static const int HarpoonChat_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, steamid_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, text_), }; HarpoonChat_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( HarpoonChat_descriptor_, HarpoonChat::default_instance_, HarpoonChat_offsets_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, _has_bits_[0]), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HarpoonChat, _unknown_fields_), -1, ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(HarpoonChat)); CrossCheatMsgType_descriptor_ = file->enum_type(0); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); inline void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_CrossCheatTalkMessages_2eproto); } void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( VectorMsg_descriptor_, &VectorMsg::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( CrossCheatInitMsg_descriptor_, &CrossCheatInitMsg::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( EntityPacketMsg_descriptor_, &EntityPacketMsg::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( ExploitOnMsg_descriptor_, &ExploitOnMsg::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( SharedESPUpdate_descriptor_, &SharedESPUpdate::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( HitBoxMsg_descriptor_, &HitBoxMsg::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( OriginUpdate_descriptor_, &OriginUpdate::default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( HarpoonChat_descriptor_, &HarpoonChat::default_instance()); } } // namespace void protobuf_ShutdownFile_CrossCheatTalkMessages_2eproto() { delete VectorMsg::default_instance_; delete VectorMsg_reflection_; delete CrossCheatInitMsg::default_instance_; delete CrossCheatInitMsg_reflection_; delete EntityPacketMsg::default_instance_; delete EntityPacketMsg_reflection_; delete ExploitOnMsg::default_instance_; delete ExploitOnMsg_reflection_; delete SharedESPUpdate::default_instance_; delete SharedESPUpdate_reflection_; delete HitBoxMsg::default_instance_; delete HitBoxMsg_reflection_; delete OriginUpdate::default_instance_; delete OriginUpdate_reflection_; delete HarpoonChat::default_instance_; delete HarpoonChat_reflection_; } void protobuf_AddDesc_CrossCheatTalkMessages_2eproto() { static bool already_here = false; if (already_here) return; already_here = true; GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\034CrossCheatTalkMessages.proto\",\n\tVector" "Msg\022\t\n\001x\030\001 \002(\002\022\t\n\001y\030\002 \002(\002\022\t\n\001z\030\003 \002(\002\"8\n\021" "CrossCheatInitMsg\022\017\n\007SteamID\030\001 \001(\r\022\022\n\nSt" "eamIndex\030\002 \001(\r\"\264\001\n\017EntityPacketMsg\022\t\n\001x\030" "\001 \002(\002\022\t\n\001y\030\002 \002(\002\022\t\n\001z\030\003 \002(\002\022\017\n\007SteamID\030\004" " \001(\r\022\023\n\013ServerIndex\030\005 \001(\r\022\024\n\014PlayerHealt" "h\030\006 \001(\r\022\024\n\014PlayerArmour\030\007 \001(\r\022\032\n\006Origin\030" "\010 \001(\0132\n.VectorMsg\022\022\n\nMatrixData\030\t \001(\t\">\n" "\014ExploitOnMsg\022\n\n\002On\030\001 \001(\010\022\r\n\005Speed\030\002 \001(\r" "\022\023\n\013TickStarted\030\003 \001(\r\"4\n\017SharedESPUpdate" "\022!\n\007EntInfo\030\001 \003(\0132\020.EntityPacketMsg\"]\n\tH" "itBoxMsg\022\030\n\004Mins\030\001 \002(\0132\n.VectorMsg\022\030\n\004Ma" "xs\030\002 \002(\0132\n.VectorMsg\022\014\n\004Bone\030\003 \002(\r\022\016\n\006Ra" "dius\030\004 \002(\002\"\256\001\n\014OriginUpdate\022\017\n\007steamID\030\001" " \002(\r\022\t\n\001x\030\002 \002(\002\022\t\n\001y\030\003 \002(\002\022\t\n\001z\030\004 \002(\002\022\035\n" "\tEyeAngles\030\005 \002(\0132\n.VectorMsg\022\037\n\013EyePosit" "ion\030\006 \002(\0132\n.VectorMsg\022\016\n\006Matrix\030\007 \001(\014\022\034\n" "\010Hitboxes\030\010 \003(\0132\n.HitBoxMsg\"I\n\013HarpoonCh" "at\022\017\n\007steamID\030\001 \002(\r\022\r\n\005index\030\002 \002(\r\022\014\n\004Na" "me\030\003 \002(\t\022\014\n\004Text\030\004 \002(\t*\225\001\n\021CrossCheatMsg" "Type\022\027\n\023k_CrossCheatInitMsg\020\001\022\025\n\021k_Entit" "yPacketMsg\020\002\022\022\n\016k_ExploitOnMsg\020\003\022\025\n\021k_Sh" "aredESPUpdate\020\004\022\022\n\016k_OriginUpdate\020\005\022\021\n\rk" "_HarpoonChat\020\006", 934); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "CrossCheatTalkMessages.proto", &protobuf_RegisterTypes); VectorMsg::default_instance_ = new VectorMsg(); CrossCheatInitMsg::default_instance_ = new CrossCheatInitMsg(); EntityPacketMsg::default_instance_ = new EntityPacketMsg(); ExploitOnMsg::default_instance_ = new ExploitOnMsg(); SharedESPUpdate::default_instance_ = new SharedESPUpdate(); HitBoxMsg::default_instance_ = new HitBoxMsg(); OriginUpdate::default_instance_ = new OriginUpdate(); HarpoonChat::default_instance_ = new HarpoonChat(); VectorMsg::default_instance_->InitAsDefaultInstance(); CrossCheatInitMsg::default_instance_->InitAsDefaultInstance(); EntityPacketMsg::default_instance_->InitAsDefaultInstance(); ExploitOnMsg::default_instance_->InitAsDefaultInstance(); SharedESPUpdate::default_instance_->InitAsDefaultInstance(); HitBoxMsg::default_instance_->InitAsDefaultInstance(); OriginUpdate::default_instance_->InitAsDefaultInstance(); HarpoonChat::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_CrossCheatTalkMessages_2eproto); } // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_CrossCheatTalkMessages_2eproto { StaticDescriptorInitializer_CrossCheatTalkMessages_2eproto() { protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); } } static_descriptor_initializer_CrossCheatTalkMessages_2eproto_; const ::google::protobuf::EnumDescriptor* CrossCheatMsgType_descriptor() { protobuf_AssignDescriptorsOnce(); return CrossCheatMsgType_descriptor_; } bool CrossCheatMsgType_IsValid(int value) { switch(value) { case 1: case 2: case 3: case 4: case 5: case 6: return true; default: return false; } } // =================================================================== #ifndef _MSC_VER const int VectorMsg::kXFieldNumber; const int VectorMsg::kYFieldNumber; const int VectorMsg::kZFieldNumber; #endif // !_MSC_VER VectorMsg::VectorMsg() : ::google::protobuf::Message() { SharedCtor(); } void VectorMsg::InitAsDefaultInstance() { } VectorMsg::VectorMsg(const VectorMsg& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void VectorMsg::SharedCtor() { _cached_size_ = 0; x_ = 0; y_ = 0; z_ = 0; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } VectorMsg::~VectorMsg() { SharedDtor(); } void VectorMsg::SharedDtor() { if (this != default_instance_) { } } void VectorMsg::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* VectorMsg::descriptor() { protobuf_AssignDescriptorsOnce(); return VectorMsg_descriptor_; } const VectorMsg& VectorMsg::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } VectorMsg* VectorMsg::default_instance_ = NULL; VectorMsg* VectorMsg::New() const { return new VectorMsg; } void VectorMsg::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { x_ = 0; y_ = 0; z_ = 0; } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool VectorMsg::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required float x = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &x_))); set_has_x(); } else { goto handle_uninterpreted; } if (input->ExpectTag(21)) goto parse_y; break; } // required float y = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_y: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &y_))); set_has_y(); } else { goto handle_uninterpreted; } if (input->ExpectTag(29)) goto parse_z; break; } // required float z = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_z: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &z_))); set_has_z(); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void VectorMsg::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required float x = 1; if (has_x()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->x(), output); } // required float y = 2; if (has_y()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->y(), output); } // required float z = 3; if (has_z()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->z(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* VectorMsg::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required float x = 1; if (has_x()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->x(), target); } // required float y = 2; if (has_y()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->y(), target); } // required float z = 3; if (has_z()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->z(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int VectorMsg::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required float x = 1; if (has_x()) { total_size += 1 + 4; } // required float y = 2; if (has_y()) { total_size += 1 + 4; } // required float z = 3; if (has_z()) { total_size += 1 + 4; } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void VectorMsg::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const VectorMsg* source = ::google::protobuf::internal::dynamic_cast_if_available<const VectorMsg*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void VectorMsg::MergeFrom(const VectorMsg& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_x()) { set_x(from.x()); } if (from.has_y()) { set_y(from.y()); } if (from.has_z()) { set_z(from.z()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void VectorMsg::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void VectorMsg::CopyFrom(const VectorMsg& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool VectorMsg::IsInitialized() const { if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false; return true; } void VectorMsg::Swap(VectorMsg* other) { if (other != this) { std::swap(x_, other->x_); std::swap(y_, other->y_); std::swap(z_, other->z_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata VectorMsg::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = VectorMsg_descriptor_; metadata.reflection = VectorMsg_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int CrossCheatInitMsg::kSteamIDFieldNumber; const int CrossCheatInitMsg::kSteamIndexFieldNumber; #endif // !_MSC_VER CrossCheatInitMsg::CrossCheatInitMsg() : ::google::protobuf::Message() { SharedCtor(); } void CrossCheatInitMsg::InitAsDefaultInstance() { } CrossCheatInitMsg::CrossCheatInitMsg(const CrossCheatInitMsg& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void CrossCheatInitMsg::SharedCtor() { _cached_size_ = 0; steamid_ = 0u; steamindex_ = 0u; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CrossCheatInitMsg::~CrossCheatInitMsg() { SharedDtor(); } void CrossCheatInitMsg::SharedDtor() { if (this != default_instance_) { } } void CrossCheatInitMsg::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CrossCheatInitMsg::descriptor() { protobuf_AssignDescriptorsOnce(); return CrossCheatInitMsg_descriptor_; } const CrossCheatInitMsg& CrossCheatInitMsg::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } CrossCheatInitMsg* CrossCheatInitMsg::default_instance_ = NULL; CrossCheatInitMsg* CrossCheatInitMsg::New() const { return new CrossCheatInitMsg; } void CrossCheatInitMsg::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { steamid_ = 0u; steamindex_ = 0u; } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool CrossCheatInitMsg::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 SteamID = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &steamid_))); set_has_steamid(); } else { goto handle_uninterpreted; } if (input->ExpectTag(16)) goto parse_SteamIndex; break; } // optional uint32 SteamIndex = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_SteamIndex: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &steamindex_))); set_has_steamindex(); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void CrossCheatInitMsg::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // optional uint32 SteamID = 1; if (has_steamid()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->steamid(), output); } // optional uint32 SteamIndex = 2; if (has_steamindex()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->steamindex(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* CrossCheatInitMsg::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // optional uint32 SteamID = 1; if (has_steamid()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->steamid(), target); } // optional uint32 SteamIndex = 2; if (has_steamindex()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->steamindex(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int CrossCheatInitMsg::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // optional uint32 SteamID = 1; if (has_steamid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->steamid()); } // optional uint32 SteamIndex = 2; if (has_steamindex()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->steamindex()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CrossCheatInitMsg::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const CrossCheatInitMsg* source = ::google::protobuf::internal::dynamic_cast_if_available<const CrossCheatInitMsg*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void CrossCheatInitMsg::MergeFrom(const CrossCheatInitMsg& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_steamid()) { set_steamid(from.steamid()); } if (from.has_steamindex()) { set_steamindex(from.steamindex()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void CrossCheatInitMsg::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void CrossCheatInitMsg::CopyFrom(const CrossCheatInitMsg& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool CrossCheatInitMsg::IsInitialized() const { return true; } void CrossCheatInitMsg::Swap(CrossCheatInitMsg* other) { if (other != this) { std::swap(steamid_, other->steamid_); std::swap(steamindex_, other->steamindex_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata CrossCheatInitMsg::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = CrossCheatInitMsg_descriptor_; metadata.reflection = CrossCheatInitMsg_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int EntityPacketMsg::kXFieldNumber; const int EntityPacketMsg::kYFieldNumber; const int EntityPacketMsg::kZFieldNumber; const int EntityPacketMsg::kSteamIDFieldNumber; const int EntityPacketMsg::kServerIndexFieldNumber; const int EntityPacketMsg::kPlayerHealthFieldNumber; const int EntityPacketMsg::kPlayerArmourFieldNumber; const int EntityPacketMsg::kOriginFieldNumber; const int EntityPacketMsg::kMatrixDataFieldNumber; #endif // !_MSC_VER EntityPacketMsg::EntityPacketMsg() : ::google::protobuf::Message() { SharedCtor(); } void EntityPacketMsg::InitAsDefaultInstance() { origin_ = const_cast< ::VectorMsg*>(&::VectorMsg::default_instance()); } EntityPacketMsg::EntityPacketMsg(const EntityPacketMsg& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void EntityPacketMsg::SharedCtor() { _cached_size_ = 0; x_ = 0; y_ = 0; z_ = 0; steamid_ = 0u; serverindex_ = 0u; playerhealth_ = 0u; playerarmour_ = 0u; origin_ = NULL; matrixdata_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EntityPacketMsg::~EntityPacketMsg() { SharedDtor(); } void EntityPacketMsg::SharedDtor() { if (matrixdata_ != &::google::protobuf::internal::kEmptyString) { delete matrixdata_; } if (this != default_instance_) { delete origin_; } } void EntityPacketMsg::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* EntityPacketMsg::descriptor() { protobuf_AssignDescriptorsOnce(); return EntityPacketMsg_descriptor_; } const EntityPacketMsg& EntityPacketMsg::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } EntityPacketMsg* EntityPacketMsg::default_instance_ = NULL; EntityPacketMsg* EntityPacketMsg::New() const { return new EntityPacketMsg; } void EntityPacketMsg::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { x_ = 0; y_ = 0; z_ = 0; steamid_ = 0u; serverindex_ = 0u; playerhealth_ = 0u; playerarmour_ = 0u; if (has_origin()) { if (origin_ != NULL) origin_->::VectorMsg::Clear(); } } if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (has_matrixdata()) { if (matrixdata_ != &::google::protobuf::internal::kEmptyString) { matrixdata_->clear(); } } } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool EntityPacketMsg::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required float x = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &x_))); set_has_x(); } else { goto handle_uninterpreted; } if (input->ExpectTag(21)) goto parse_y; break; } // required float y = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_y: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &y_))); set_has_y(); } else { goto handle_uninterpreted; } if (input->ExpectTag(29)) goto parse_z; break; } // required float z = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_z: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &z_))); set_has_z(); } else { goto handle_uninterpreted; } if (input->ExpectTag(32)) goto parse_SteamID; break; } // optional uint32 SteamID = 4; case 4: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_SteamID: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &steamid_))); set_has_steamid(); } else { goto handle_uninterpreted; } if (input->ExpectTag(40)) goto parse_ServerIndex; break; } // optional uint32 ServerIndex = 5; case 5: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_ServerIndex: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &serverindex_))); set_has_serverindex(); } else { goto handle_uninterpreted; } if (input->ExpectTag(48)) goto parse_PlayerHealth; break; } // optional uint32 PlayerHealth = 6; case 6: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_PlayerHealth: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &playerhealth_))); set_has_playerhealth(); } else { goto handle_uninterpreted; } if (input->ExpectTag(56)) goto parse_PlayerArmour; break; } // optional uint32 PlayerArmour = 7; case 7: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_PlayerArmour: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &playerarmour_))); set_has_playerarmour(); } else { goto handle_uninterpreted; } if (input->ExpectTag(66)) goto parse_Origin; break; } // optional .VectorMsg Origin = 8; case 8: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Origin: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_origin())); } else { goto handle_uninterpreted; } if (input->ExpectTag(74)) goto parse_MatrixData; break; } // optional string MatrixData = 9; case 9: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_MatrixData: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_matrixdata())); ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->matrixdata().data(), this->matrixdata().length(), ::google::protobuf::internal::WireFormat::PARSE); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void EntityPacketMsg::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required float x = 1; if (has_x()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->x(), output); } // required float y = 2; if (has_y()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->y(), output); } // required float z = 3; if (has_z()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->z(), output); } // optional uint32 SteamID = 4; if (has_steamid()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->steamid(), output); } // optional uint32 ServerIndex = 5; if (has_serverindex()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->serverindex(), output); } // optional uint32 PlayerHealth = 6; if (has_playerhealth()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->playerhealth(), output); } // optional uint32 PlayerArmour = 7; if (has_playerarmour()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->playerarmour(), output); } // optional .VectorMsg Origin = 8; if (has_origin()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 8, this->origin(), output); } // optional string MatrixData = 9; if (has_matrixdata()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->matrixdata().data(), this->matrixdata().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); ::google::protobuf::internal::WireFormatLite::WriteString( 9, this->matrixdata(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* EntityPacketMsg::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required float x = 1; if (has_x()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->x(), target); } // required float y = 2; if (has_y()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->y(), target); } // required float z = 3; if (has_z()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->z(), target); } // optional uint32 SteamID = 4; if (has_steamid()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->steamid(), target); } // optional uint32 ServerIndex = 5; if (has_serverindex()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->serverindex(), target); } // optional uint32 PlayerHealth = 6; if (has_playerhealth()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->playerhealth(), target); } // optional uint32 PlayerArmour = 7; if (has_playerarmour()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->playerarmour(), target); } // optional .VectorMsg Origin = 8; if (has_origin()) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 8, this->origin(), target); } // optional string MatrixData = 9; if (has_matrixdata()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->matrixdata().data(), this->matrixdata().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 9, this->matrixdata(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int EntityPacketMsg::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required float x = 1; if (has_x()) { total_size += 1 + 4; } // required float y = 2; if (has_y()) { total_size += 1 + 4; } // required float z = 3; if (has_z()) { total_size += 1 + 4; } // optional uint32 SteamID = 4; if (has_steamid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->steamid()); } // optional uint32 ServerIndex = 5; if (has_serverindex()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->serverindex()); } // optional uint32 PlayerHealth = 6; if (has_playerhealth()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->playerhealth()); } // optional uint32 PlayerArmour = 7; if (has_playerarmour()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->playerarmour()); } // optional .VectorMsg Origin = 8; if (has_origin()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->origin()); } } if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { // optional string MatrixData = 9; if (has_matrixdata()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->matrixdata()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EntityPacketMsg::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const EntityPacketMsg* source = ::google::protobuf::internal::dynamic_cast_if_available<const EntityPacketMsg*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void EntityPacketMsg::MergeFrom(const EntityPacketMsg& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_x()) { set_x(from.x()); } if (from.has_y()) { set_y(from.y()); } if (from.has_z()) { set_z(from.z()); } if (from.has_steamid()) { set_steamid(from.steamid()); } if (from.has_serverindex()) { set_serverindex(from.serverindex()); } if (from.has_playerhealth()) { set_playerhealth(from.playerhealth()); } if (from.has_playerarmour()) { set_playerarmour(from.playerarmour()); } if (from.has_origin()) { mutable_origin()->::VectorMsg::MergeFrom(from.origin()); } } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_matrixdata()) { set_matrixdata(from.matrixdata()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void EntityPacketMsg::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void EntityPacketMsg::CopyFrom(const EntityPacketMsg& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool EntityPacketMsg::IsInitialized() const { if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false; if (has_origin()) { if (!this->origin().IsInitialized()) return false; } return true; } void EntityPacketMsg::Swap(EntityPacketMsg* other) { if (other != this) { std::swap(x_, other->x_); std::swap(y_, other->y_); std::swap(z_, other->z_); std::swap(steamid_, other->steamid_); std::swap(serverindex_, other->serverindex_); std::swap(playerhealth_, other->playerhealth_); std::swap(playerarmour_, other->playerarmour_); std::swap(origin_, other->origin_); std::swap(matrixdata_, other->matrixdata_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata EntityPacketMsg::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = EntityPacketMsg_descriptor_; metadata.reflection = EntityPacketMsg_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int ExploitOnMsg::kOnFieldNumber; const int ExploitOnMsg::kSpeedFieldNumber; const int ExploitOnMsg::kTickStartedFieldNumber; #endif // !_MSC_VER ExploitOnMsg::ExploitOnMsg() : ::google::protobuf::Message() { SharedCtor(); } void ExploitOnMsg::InitAsDefaultInstance() { } ExploitOnMsg::ExploitOnMsg(const ExploitOnMsg& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void ExploitOnMsg::SharedCtor() { _cached_size_ = 0; on_ = false; speed_ = 0u; tickstarted_ = 0u; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ExploitOnMsg::~ExploitOnMsg() { SharedDtor(); } void ExploitOnMsg::SharedDtor() { if (this != default_instance_) { } } void ExploitOnMsg::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* ExploitOnMsg::descriptor() { protobuf_AssignDescriptorsOnce(); return ExploitOnMsg_descriptor_; } const ExploitOnMsg& ExploitOnMsg::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } ExploitOnMsg* ExploitOnMsg::default_instance_ = NULL; ExploitOnMsg* ExploitOnMsg::New() const { return new ExploitOnMsg; } void ExploitOnMsg::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { on_ = false; speed_ = 0u; tickstarted_ = 0u; } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool ExploitOnMsg::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool On = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &on_))); set_has_on(); } else { goto handle_uninterpreted; } if (input->ExpectTag(16)) goto parse_Speed; break; } // optional uint32 Speed = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_Speed: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &speed_))); set_has_speed(); } else { goto handle_uninterpreted; } if (input->ExpectTag(24)) goto parse_TickStarted; break; } // optional uint32 TickStarted = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_TickStarted: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &tickstarted_))); set_has_tickstarted(); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void ExploitOnMsg::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // optional bool On = 1; if (has_on()) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->on(), output); } // optional uint32 Speed = 2; if (has_speed()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->speed(), output); } // optional uint32 TickStarted = 3; if (has_tickstarted()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->tickstarted(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* ExploitOnMsg::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // optional bool On = 1; if (has_on()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->on(), target); } // optional uint32 Speed = 2; if (has_speed()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->speed(), target); } // optional uint32 TickStarted = 3; if (has_tickstarted()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->tickstarted(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int ExploitOnMsg::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // optional bool On = 1; if (has_on()) { total_size += 1 + 1; } // optional uint32 Speed = 2; if (has_speed()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->speed()); } // optional uint32 TickStarted = 3; if (has_tickstarted()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->tickstarted()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ExploitOnMsg::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const ExploitOnMsg* source = ::google::protobuf::internal::dynamic_cast_if_available<const ExploitOnMsg*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void ExploitOnMsg::MergeFrom(const ExploitOnMsg& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_on()) { set_on(from.on()); } if (from.has_speed()) { set_speed(from.speed()); } if (from.has_tickstarted()) { set_tickstarted(from.tickstarted()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void ExploitOnMsg::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void ExploitOnMsg::CopyFrom(const ExploitOnMsg& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool ExploitOnMsg::IsInitialized() const { return true; } void ExploitOnMsg::Swap(ExploitOnMsg* other) { if (other != this) { std::swap(on_, other->on_); std::swap(speed_, other->speed_); std::swap(tickstarted_, other->tickstarted_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata ExploitOnMsg::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = ExploitOnMsg_descriptor_; metadata.reflection = ExploitOnMsg_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int SharedESPUpdate::kEntInfoFieldNumber; #endif // !_MSC_VER SharedESPUpdate::SharedESPUpdate() : ::google::protobuf::Message() { SharedCtor(); } void SharedESPUpdate::InitAsDefaultInstance() { } SharedESPUpdate::SharedESPUpdate(const SharedESPUpdate& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void SharedESPUpdate::SharedCtor() { _cached_size_ = 0; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SharedESPUpdate::~SharedESPUpdate() { SharedDtor(); } void SharedESPUpdate::SharedDtor() { if (this != default_instance_) { } } void SharedESPUpdate::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* SharedESPUpdate::descriptor() { protobuf_AssignDescriptorsOnce(); return SharedESPUpdate_descriptor_; } const SharedESPUpdate& SharedESPUpdate::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } SharedESPUpdate* SharedESPUpdate::default_instance_ = NULL; SharedESPUpdate* SharedESPUpdate::New() const { return new SharedESPUpdate; } void SharedESPUpdate::Clear() { entinfo_.Clear(); ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool SharedESPUpdate::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .EntityPacketMsg EntInfo = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_EntInfo: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, add_entinfo())); } else { goto handle_uninterpreted; } if (input->ExpectTag(10)) goto parse_EntInfo; if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void SharedESPUpdate::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // repeated .EntityPacketMsg EntInfo = 1; for (int i = 0; i < this->entinfo_size(); i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, this->entinfo(i), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* SharedESPUpdate::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // repeated .EntityPacketMsg EntInfo = 1; for (int i = 0; i < this->entinfo_size(); i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 1, this->entinfo(i), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int SharedESPUpdate::ByteSize() const { int total_size = 0; // repeated .EntityPacketMsg EntInfo = 1; total_size += 1 * this->entinfo_size(); for (int i = 0; i < this->entinfo_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->entinfo(i)); } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SharedESPUpdate::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const SharedESPUpdate* source = ::google::protobuf::internal::dynamic_cast_if_available<const SharedESPUpdate*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void SharedESPUpdate::MergeFrom(const SharedESPUpdate& from) { GOOGLE_CHECK_NE(&from, this); entinfo_.MergeFrom(from.entinfo_); mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void SharedESPUpdate::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void SharedESPUpdate::CopyFrom(const SharedESPUpdate& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool SharedESPUpdate::IsInitialized() const { for (int i = 0; i < entinfo_size(); i++) { if (!this->entinfo(i).IsInitialized()) return false; } return true; } void SharedESPUpdate::Swap(SharedESPUpdate* other) { if (other != this) { entinfo_.Swap(&other->entinfo_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata SharedESPUpdate::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = SharedESPUpdate_descriptor_; metadata.reflection = SharedESPUpdate_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int HitBoxMsg::kMinsFieldNumber; const int HitBoxMsg::kMaxsFieldNumber; const int HitBoxMsg::kBoneFieldNumber; const int HitBoxMsg::kRadiusFieldNumber; #endif // !_MSC_VER HitBoxMsg::HitBoxMsg() : ::google::protobuf::Message() { SharedCtor(); } void HitBoxMsg::InitAsDefaultInstance() { mins_ = const_cast< ::VectorMsg*>(&::VectorMsg::default_instance()); maxs_ = const_cast< ::VectorMsg*>(&::VectorMsg::default_instance()); } HitBoxMsg::HitBoxMsg(const HitBoxMsg& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void HitBoxMsg::SharedCtor() { _cached_size_ = 0; mins_ = NULL; maxs_ = NULL; bone_ = 0u; radius_ = 0; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } HitBoxMsg::~HitBoxMsg() { SharedDtor(); } void HitBoxMsg::SharedDtor() { if (this != default_instance_) { delete mins_; delete maxs_; } } void HitBoxMsg::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* HitBoxMsg::descriptor() { protobuf_AssignDescriptorsOnce(); return HitBoxMsg_descriptor_; } const HitBoxMsg& HitBoxMsg::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } HitBoxMsg* HitBoxMsg::default_instance_ = NULL; HitBoxMsg* HitBoxMsg::New() const { return new HitBoxMsg; } void HitBoxMsg::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (has_mins()) { if (mins_ != NULL) mins_->::VectorMsg::Clear(); } if (has_maxs()) { if (maxs_ != NULL) maxs_->::VectorMsg::Clear(); } bone_ = 0u; radius_ = 0; } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool HitBoxMsg::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required .VectorMsg Mins = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_mins())); } else { goto handle_uninterpreted; } if (input->ExpectTag(18)) goto parse_Maxs; break; } // required .VectorMsg Maxs = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Maxs: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_maxs())); } else { goto handle_uninterpreted; } if (input->ExpectTag(24)) goto parse_Bone; break; } // required uint32 Bone = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_Bone: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &bone_))); set_has_bone(); } else { goto handle_uninterpreted; } if (input->ExpectTag(37)) goto parse_Radius; break; } // required float Radius = 4; case 4: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_Radius: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &radius_))); set_has_radius(); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void HitBoxMsg::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required .VectorMsg Mins = 1; if (has_mins()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, this->mins(), output); } // required .VectorMsg Maxs = 2; if (has_maxs()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 2, this->maxs(), output); } // required uint32 Bone = 3; if (has_bone()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->bone(), output); } // required float Radius = 4; if (has_radius()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->radius(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* HitBoxMsg::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required .VectorMsg Mins = 1; if (has_mins()) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 1, this->mins(), target); } // required .VectorMsg Maxs = 2; if (has_maxs()) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 2, this->maxs(), target); } // required uint32 Bone = 3; if (has_bone()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->bone(), target); } // required float Radius = 4; if (has_radius()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->radius(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int HitBoxMsg::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required .VectorMsg Mins = 1; if (has_mins()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->mins()); } // required .VectorMsg Maxs = 2; if (has_maxs()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->maxs()); } // required uint32 Bone = 3; if (has_bone()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->bone()); } // required float Radius = 4; if (has_radius()) { total_size += 1 + 4; } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void HitBoxMsg::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const HitBoxMsg* source = ::google::protobuf::internal::dynamic_cast_if_available<const HitBoxMsg*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void HitBoxMsg::MergeFrom(const HitBoxMsg& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_mins()) { mutable_mins()->::VectorMsg::MergeFrom(from.mins()); } if (from.has_maxs()) { mutable_maxs()->::VectorMsg::MergeFrom(from.maxs()); } if (from.has_bone()) { set_bone(from.bone()); } if (from.has_radius()) { set_radius(from.radius()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void HitBoxMsg::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void HitBoxMsg::CopyFrom(const HitBoxMsg& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool HitBoxMsg::IsInitialized() const { if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false; if (has_mins()) { if (!this->mins().IsInitialized()) return false; } if (has_maxs()) { if (!this->maxs().IsInitialized()) return false; } return true; } void HitBoxMsg::Swap(HitBoxMsg* other) { if (other != this) { std::swap(mins_, other->mins_); std::swap(maxs_, other->maxs_); std::swap(bone_, other->bone_); std::swap(radius_, other->radius_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata HitBoxMsg::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = HitBoxMsg_descriptor_; metadata.reflection = HitBoxMsg_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int OriginUpdate::kSteamIDFieldNumber; const int OriginUpdate::kXFieldNumber; const int OriginUpdate::kYFieldNumber; const int OriginUpdate::kZFieldNumber; const int OriginUpdate::kEyeAnglesFieldNumber; const int OriginUpdate::kEyePositionFieldNumber; const int OriginUpdate::kMatrixFieldNumber; const int OriginUpdate::kHitboxesFieldNumber; #endif // !_MSC_VER OriginUpdate::OriginUpdate() : ::google::protobuf::Message() { SharedCtor(); } void OriginUpdate::InitAsDefaultInstance() { eyeangles_ = const_cast< ::VectorMsg*>(&::VectorMsg::default_instance()); eyeposition_ = const_cast< ::VectorMsg*>(&::VectorMsg::default_instance()); } OriginUpdate::OriginUpdate(const OriginUpdate& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void OriginUpdate::SharedCtor() { _cached_size_ = 0; steamid_ = 0u; x_ = 0; y_ = 0; z_ = 0; eyeangles_ = NULL; eyeposition_ = NULL; matrix_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } OriginUpdate::~OriginUpdate() { SharedDtor(); } void OriginUpdate::SharedDtor() { if (matrix_ != &::google::protobuf::internal::kEmptyString) { delete matrix_; } if (this != default_instance_) { delete eyeangles_; delete eyeposition_; } } void OriginUpdate::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* OriginUpdate::descriptor() { protobuf_AssignDescriptorsOnce(); return OriginUpdate_descriptor_; } const OriginUpdate& OriginUpdate::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } OriginUpdate* OriginUpdate::default_instance_ = NULL; OriginUpdate* OriginUpdate::New() const { return new OriginUpdate; } void OriginUpdate::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { steamid_ = 0u; x_ = 0; y_ = 0; z_ = 0; if (has_eyeangles()) { if (eyeangles_ != NULL) eyeangles_->::VectorMsg::Clear(); } if (has_eyeposition()) { if (eyeposition_ != NULL) eyeposition_->::VectorMsg::Clear(); } if (has_matrix()) { if (matrix_ != &::google::protobuf::internal::kEmptyString) { matrix_->clear(); } } } hitboxes_.Clear(); ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool OriginUpdate::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required uint32 steamID = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &steamid_))); set_has_steamid(); } else { goto handle_uninterpreted; } if (input->ExpectTag(21)) goto parse_x; break; } // required float x = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_x: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &x_))); set_has_x(); } else { goto handle_uninterpreted; } if (input->ExpectTag(29)) goto parse_y; break; } // required float y = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_y: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &y_))); set_has_y(); } else { goto handle_uninterpreted; } if (input->ExpectTag(37)) goto parse_z; break; } // required float z = 4; case 4: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { parse_z: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &z_))); set_has_z(); } else { goto handle_uninterpreted; } if (input->ExpectTag(42)) goto parse_EyeAngles; break; } // required .VectorMsg EyeAngles = 5; case 5: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_EyeAngles: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_eyeangles())); } else { goto handle_uninterpreted; } if (input->ExpectTag(50)) goto parse_EyePosition; break; } // required .VectorMsg EyePosition = 6; case 6: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_EyePosition: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_eyeposition())); } else { goto handle_uninterpreted; } if (input->ExpectTag(58)) goto parse_Matrix; break; } // optional bytes Matrix = 7; case 7: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Matrix: DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_matrix())); } else { goto handle_uninterpreted; } if (input->ExpectTag(66)) goto parse_Hitboxes; break; } // repeated .HitBoxMsg Hitboxes = 8; case 8: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Hitboxes: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, add_hitboxes())); } else { goto handle_uninterpreted; } if (input->ExpectTag(66)) goto parse_Hitboxes; if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void OriginUpdate::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required uint32 steamID = 1; if (has_steamid()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->steamid(), output); } // required float x = 2; if (has_x()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->x(), output); } // required float y = 3; if (has_y()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->y(), output); } // required float z = 4; if (has_z()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->z(), output); } // required .VectorMsg EyeAngles = 5; if (has_eyeangles()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, this->eyeangles(), output); } // required .VectorMsg EyePosition = 6; if (has_eyeposition()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 6, this->eyeposition(), output); } // optional bytes Matrix = 7; if (has_matrix()) { ::google::protobuf::internal::WireFormatLite::WriteBytes( 7, this->matrix(), output); } // repeated .HitBoxMsg Hitboxes = 8; for (int i = 0; i < this->hitboxes_size(); i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 8, this->hitboxes(i), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* OriginUpdate::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required uint32 steamID = 1; if (has_steamid()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->steamid(), target); } // required float x = 2; if (has_x()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->x(), target); } // required float y = 3; if (has_y()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->y(), target); } // required float z = 4; if (has_z()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->z(), target); } // required .VectorMsg EyeAngles = 5; if (has_eyeangles()) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 5, this->eyeangles(), target); } // required .VectorMsg EyePosition = 6; if (has_eyeposition()) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 6, this->eyeposition(), target); } // optional bytes Matrix = 7; if (has_matrix()) { target = ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( 7, this->matrix(), target); } // repeated .HitBoxMsg Hitboxes = 8; for (int i = 0; i < this->hitboxes_size(); i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteMessageNoVirtualToArray( 8, this->hitboxes(i), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int OriginUpdate::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required uint32 steamID = 1; if (has_steamid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->steamid()); } // required float x = 2; if (has_x()) { total_size += 1 + 4; } // required float y = 3; if (has_y()) { total_size += 1 + 4; } // required float z = 4; if (has_z()) { total_size += 1 + 4; } // required .VectorMsg EyeAngles = 5; if (has_eyeangles()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->eyeangles()); } // required .VectorMsg EyePosition = 6; if (has_eyeposition()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->eyeposition()); } // optional bytes Matrix = 7; if (has_matrix()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( this->matrix()); } } // repeated .HitBoxMsg Hitboxes = 8; total_size += 1 * this->hitboxes_size(); for (int i = 0; i < this->hitboxes_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->hitboxes(i)); } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void OriginUpdate::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const OriginUpdate* source = ::google::protobuf::internal::dynamic_cast_if_available<const OriginUpdate*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void OriginUpdate::MergeFrom(const OriginUpdate& from) { GOOGLE_CHECK_NE(&from, this); hitboxes_.MergeFrom(from.hitboxes_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_steamid()) { set_steamid(from.steamid()); } if (from.has_x()) { set_x(from.x()); } if (from.has_y()) { set_y(from.y()); } if (from.has_z()) { set_z(from.z()); } if (from.has_eyeangles()) { mutable_eyeangles()->::VectorMsg::MergeFrom(from.eyeangles()); } if (from.has_eyeposition()) { mutable_eyeposition()->::VectorMsg::MergeFrom(from.eyeposition()); } if (from.has_matrix()) { set_matrix(from.matrix()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void OriginUpdate::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void OriginUpdate::CopyFrom(const OriginUpdate& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool OriginUpdate::IsInitialized() const { if ((_has_bits_[0] & 0x0000003f) != 0x0000003f) return false; if (has_eyeangles()) { if (!this->eyeangles().IsInitialized()) return false; } if (has_eyeposition()) { if (!this->eyeposition().IsInitialized()) return false; } for (int i = 0; i < hitboxes_size(); i++) { if (!this->hitboxes(i).IsInitialized()) return false; } return true; } void OriginUpdate::Swap(OriginUpdate* other) { if (other != this) { std::swap(steamid_, other->steamid_); std::swap(x_, other->x_); std::swap(y_, other->y_); std::swap(z_, other->z_); std::swap(eyeangles_, other->eyeangles_); std::swap(eyeposition_, other->eyeposition_); std::swap(matrix_, other->matrix_); hitboxes_.Swap(&other->hitboxes_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata OriginUpdate::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = OriginUpdate_descriptor_; metadata.reflection = OriginUpdate_reflection_; return metadata; } // =================================================================== #ifndef _MSC_VER const int HarpoonChat::kSteamIDFieldNumber; const int HarpoonChat::kIndexFieldNumber; const int HarpoonChat::kNameFieldNumber; const int HarpoonChat::kTextFieldNumber; #endif // !_MSC_VER HarpoonChat::HarpoonChat() : ::google::protobuf::Message() { SharedCtor(); } void HarpoonChat::InitAsDefaultInstance() { } HarpoonChat::HarpoonChat(const HarpoonChat& from) : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } void HarpoonChat::SharedCtor() { _cached_size_ = 0; steamid_ = 0u; index_ = 0u; name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); text_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } HarpoonChat::~HarpoonChat() { SharedDtor(); } void HarpoonChat::SharedDtor() { if (name_ != &::google::protobuf::internal::kEmptyString) { delete name_; } if (text_ != &::google::protobuf::internal::kEmptyString) { delete text_; } if (this != default_instance_) { } } void HarpoonChat::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* HarpoonChat::descriptor() { protobuf_AssignDescriptorsOnce(); return HarpoonChat_descriptor_; } const HarpoonChat& HarpoonChat::default_instance() { if (default_instance_ == NULL) protobuf_AddDesc_CrossCheatTalkMessages_2eproto(); return *default_instance_; } HarpoonChat* HarpoonChat::default_instance_ = NULL; HarpoonChat* HarpoonChat::New() const { return new HarpoonChat; } void HarpoonChat::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { steamid_ = 0u; index_ = 0u; if (has_name()) { if (name_ != &::google::protobuf::internal::kEmptyString) { name_->clear(); } } if (has_text()) { if (text_ != &::google::protobuf::internal::kEmptyString) { text_->clear(); } } } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); } bool HarpoonChat::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) return false ::google::protobuf::uint32 tag; while ((tag = input->ReadTag()) != 0) { switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required uint32 steamID = 1; case 1: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &steamid_))); set_has_steamid(); } else { goto handle_uninterpreted; } if (input->ExpectTag(16)) goto parse_index; break; } // required uint32 index = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { parse_index: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &index_))); set_has_index(); } else { goto handle_uninterpreted; } if (input->ExpectTag(26)) goto parse_Name; break; } // required string Name = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Name: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->name().data(), this->name().length(), ::google::protobuf::internal::WireFormat::PARSE); } else { goto handle_uninterpreted; } if (input->ExpectTag(34)) goto parse_Text; break; } // required string Text = 4; case 4: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_Text: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_text())); ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->text().data(), this->text().length(), ::google::protobuf::internal::WireFormat::PARSE); } else { goto handle_uninterpreted; } if (input->ExpectAtEnd()) return true; break; } default: { handle_uninterpreted: if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { return true; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); break; } } } return true; #undef DO_ } void HarpoonChat::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required uint32 steamID = 1; if (has_steamid()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->steamid(), output); } // required uint32 index = 2; if (has_index()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->index(), output); } // required string Name = 3; if (has_name()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->name().data(), this->name().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); ::google::protobuf::internal::WireFormatLite::WriteString( 3, this->name(), output); } // required string Text = 4; if (has_text()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->text().data(), this->text().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); ::google::protobuf::internal::WireFormatLite::WriteString( 4, this->text(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } } ::google::protobuf::uint8* HarpoonChat::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required uint32 steamID = 1; if (has_steamid()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->steamid(), target); } // required uint32 index = 2; if (has_index()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->index(), target); } // required string Name = 3; if (has_name()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->name().data(), this->name().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 3, this->name(), target); } // required string Text = 4; if (has_text()) { ::google::protobuf::internal::WireFormat::VerifyUTF8String( this->text().data(), this->text().length(), ::google::protobuf::internal::WireFormat::SERIALIZE); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 4, this->text(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; } int HarpoonChat::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required uint32 steamID = 1; if (has_steamid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->steamid()); } // required uint32 index = 2; if (has_index()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->index()); } // required string Name = 3; if (has_name()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } // required string Text = 4; if (has_text()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->text()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void HarpoonChat::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); const HarpoonChat* source = ::google::protobuf::internal::dynamic_cast_if_available<const HarpoonChat*>( &from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { MergeFrom(*source); } } void HarpoonChat::MergeFrom(const HarpoonChat& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_steamid()) { set_steamid(from.steamid()); } if (from.has_index()) { set_index(from.index()); } if (from.has_name()) { set_name(from.name()); } if (from.has_text()) { set_text(from.text()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } void HarpoonChat::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; Clear(); MergeFrom(from); } void HarpoonChat::CopyFrom(const HarpoonChat& from) { if (&from == this) return; Clear(); MergeFrom(from); } bool HarpoonChat::IsInitialized() const { if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false; return true; } void HarpoonChat::Swap(HarpoonChat* other) { if (other != this) { std::swap(steamid_, other->steamid_); std::swap(index_, other->index_); std::swap(name_, other->name_); std::swap(text_, other->text_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } } ::google::protobuf::Metadata HarpoonChat::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; metadata.descriptor = HarpoonChat_descriptor_; metadata.reflection = HarpoonChat_reflection_; return metadata; } // @@protoc_insertion_point(namespace_scope) // @@protoc_insertion_point(global_scope)
31.706748
117
0.660887
eacbypass
c4e8e5f8e9d22d255a3ba6c90b8d8d31be0901d1
432
hpp
C++
src/behavior/policy/solver_derived_policy.hpp
MarkieMark/fastrl
e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e
[ "Apache-2.0" ]
4
2019-04-19T00:11:36.000Z
2020-04-08T09:50:37.000Z
src/behavior/policy/solver_derived_policy.hpp
MarkieMark/fastrl
e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e
[ "Apache-2.0" ]
null
null
null
src/behavior/policy/solver_derived_policy.hpp
MarkieMark/fastrl
e4f0b9b60a7ecb6f13bbb79936ea82acb8adae0e
[ "Apache-2.0" ]
null
null
null
/** * Mark Benjamin 1st June 2017 */ #ifndef FASTRL_BEHAVIOR_POLICY_SOLVER_DERIVED_POLICY_HPP #define FASTRL_BEHAVIOR_POLICY_SOLVER_DERIVED_POLICY_HPP #include "policy.hpp" #include "../singleagent/MDP_solver_interface.hpp" class SolverDerivedPolicy : virtual public Policy { public: virtual void setSolver(MDPSolverInterface * solver) { throw runtime_error("SolverDerivedPolicy::setSolver() Not Implemented"); } }; #endif
27
132
0.800926
MarkieMark
c4ea0f2a64a7a2049187444b2f7b4401628480ce
1,380
cpp
C++
CrackingTheCodeInterview/03_02_constantMinPopPushStack.cpp
DanWatkins/CTCI
230572f46ddaf0945bbf735a2be717486ffea7dc
[ "Unlicense" ]
1
2016-07-21T03:24:17.000Z
2016-07-21T03:24:17.000Z
CrackingTheCodeInterview/03_02_constantMinPopPushStack.cpp
DanWatkins/BookExamples
230572f46ddaf0945bbf735a2be717486ffea7dc
[ "Unlicense" ]
null
null
null
CrackingTheCodeInterview/03_02_constantMinPopPushStack.cpp
DanWatkins/BookExamples
230572f46ddaf0945bbf735a2be717486ffea7dc
[ "Unlicense" ]
null
null
null
#include <iostream> #include <stack> template<typename T> class StackConstantPushPopMin_SpaceEfficient { public: /* * Pushes the value onto the top of the stack in O(1) */ void push(T value) { if (mNodes.size() == 0 || mNodes.top().runningMin > value) { Node n; n.values.push(value); n.runningMin = value; mNodes.push(n); } else { mNodes.top().values.push(value); } } /* * Pops the top element from the stack in O(1) * @returns the element popped */ T pop() { std::stack<T> values = mNodes.top().values; T topValue = values.top(); values.pop(); if (values.size() == 0) { mNodes.pop(); } } /* * @returns the minimum element as ordered by the < operator in O(1) */ T min() { return mNodes.top().runningMin; } private: struct Node { std::stack<T> values; T runningMin; Node() : runningMin(0) {} //wont work for things other than numbers, but that doesn't matter right now }; std::stack<Node> mNodes; }; #define myAssert(expression) if (!(expression)) \ std::cout << "Problem at line " << __LINE__ << std::endl; int main() { StackConstantPushPopMin_SpaceEfficient<int> s; s.push(3); myAssert(s.min() == 3) s.push(2); myAssert(s.min() == 2) s.push(1); myAssert(s.min() == 1) s.push(5); myAssert(s.min() == 1) s.push(0); myAssert(s.min() == 0) return 0; }
15.681818
104
0.604348
DanWatkins
c4ed39f469d68136f1bf3841e927db36cad04f57
1,195
cpp
C++
extrautils/SuffixArrayToBWT.cpp
mchaisso/mcpbblasr
6c92959ba61adfd234a4f35849490709284105de
[ "BSD-3-Clause-Clear" ]
null
null
null
extrautils/SuffixArrayToBWT.cpp
mchaisso/mcpbblasr
6c92959ba61adfd234a4f35849490709284105de
[ "BSD-3-Clause-Clear" ]
null
null
null
extrautils/SuffixArrayToBWT.cpp
mchaisso/mcpbblasr
6c92959ba61adfd234a4f35849490709284105de
[ "BSD-3-Clause-Clear" ]
null
null
null
#include "FASTAReader.hpp" #include "FASTASequence.hpp" #include "bwt/BWT.hpp" #include "suffixarray/SuffixArray.hpp" #include "suffixarray/SuffixArrayTypes.hpp" #include <fstream> #include <iostream> int main(int argc, char* argv[]) { if (argc < 4) { std::cout << "usage: sa2bwt genomeFileName suffixArray bwt [-debug]" << std::endl; std::exit(EXIT_FAILURE); } std::string genomeFileName = argv[1]; std::string suffixArrayFileName = argv[2]; std::string bwtFileName = argv[3]; int storeDebugInformation = 0; int argi = 4; while (argi < argc) { if (strcmp(argv[argi], "-debug") == 0) { storeDebugInformation = 1; } ++argi; } std::ofstream bwtOutFile; CrucialOpen(bwtFileName, bwtOutFile, std::ios::out | std::ios::binary); FASTAReader reader; reader.Init(genomeFileName); FASTASequence seq; reader.ReadAllSequencesIntoOne(seq); DNASuffixArray suffixArray; suffixArray.Read(suffixArrayFileName); Bwt<PackedDNASequence, FASTASequence> bwt; bwt.InitializeFromSuffixArray(seq, suffixArray.index, storeDebugInformation); bwt.Write(bwtOutFile); return 0; }
25.978261
90
0.665272
mchaisso
c4f14b8b50b81b93e678b25f254b854a7cd73d88
477
cpp
C++
PerceptionExample/Plugins/Developer/RiderLink/Source/RD/src/rd_framework_cpp/src/main/intern/InternScheduler.cpp
EduTeachers/UnrealEngine4-SampleCode
80e8f0fe3c2bb930856d4f6a478bf0bdc51878d5
[ "MIT" ]
4
2022-01-20T18:14:00.000Z
2022-02-24T14:45:47.000Z
PerceptionExample/Plugins/Developer/RiderLink/Source/RD/src/rd_framework_cpp/src/main/intern/InternScheduler.cpp
EduTeachers/UnrealEngine4-SampleCode
80e8f0fe3c2bb930856d4f6a478bf0bdc51878d5
[ "MIT" ]
null
null
null
PerceptionExample/Plugins/Developer/RiderLink/Source/RD/src/rd_framework_cpp/src/main/intern/InternScheduler.cpp
EduTeachers/UnrealEngine4-SampleCode
80e8f0fe3c2bb930856d4f6a478bf0bdc51878d5
[ "MIT" ]
null
null
null
#include "InternScheduler.h" #include "guards.h" namespace rd { thread_local int32_t InternScheduler::active_counts = 0; InternScheduler::InternScheduler() { out_of_order_execution = true; } void InternScheduler::queue(std::function<void()> action) { util::increment_guard<int32_t> guard(active_counts); action(); } void InternScheduler::flush() { } bool InternScheduler::is_active() const { return active_counts > 0; } } // namespace rd
16.448276
58
0.702306
EduTeachers
c4f1d68a22f0d99bb6c249ab683f5e43f8091f30
1,426
cpp
C++
mx_sensitivity/arma_mexprintf.cpp
mrcstan/Opt-IGFEM-2D
834d07727cd30cfac6368d9bb67202b8a20a4d4c
[ "NCSA" ]
null
null
null
mx_sensitivity/arma_mexprintf.cpp
mrcstan/Opt-IGFEM-2D
834d07727cd30cfac6368d9bb67202b8a20a4d4c
[ "NCSA" ]
null
null
null
mx_sensitivity/arma_mexprintf.cpp
mrcstan/Opt-IGFEM-2D
834d07727cd30cfac6368d9bb67202b8a20a4d4c
[ "NCSA" ]
null
null
null
/* Created by Marcus Tan on 1/30/2016 Copyright 2016 University of Illinois Purpose: this function use mexPrintf to print Armadillo vectors and matrices since the Armadillo member function print may not always work in Matlab */ #include "sensitivity.h" #include <cstddef> // NULL, std::#include "mex.h" #include "armadillo" #include "mex.h" namespace igfem { void arma_mexprintf(const char prefix[], const arma::vec& V) { mexPrintf("%s\n",prefix); for (std::size_t i = 0; i < V.n_elem; i++) mexPrintf("%8.4g\n",V(i)); mexPrintf("\n"); return; } void arma_mexprintf(const char prefix[], const arma::uvec& V) { mexPrintf("%s\n",prefix); for (std::size_t i = 0; i < V.n_elem; i++) mexPrintf("%i\n",V(i)); mexPrintf("\n"); return; } void arma_mexprintf(const char prefix[], const arma::mat& V) { mexPrintf("%s",prefix); for (std::size_t i = 0; i < V.n_rows; i++) { mexPrintf("\n"); for (std::size_t j = 0; j < V.n_cols; j++) { mexPrintf("%8.4g ",V(i,j)); } } mexPrintf("\n"); return; } void arma_mexprintf(const char prefix[], const arma::umat& V) { mexPrintf("%s",prefix); for (std::size_t i = 0; i < V.n_rows; i++) { mexPrintf("\n"); for (std::size_t j = 0; j < V.n_cols; j++) { mexPrintf("%i ",V(i,j)); } } mexPrintf("\n"); return; } }
22.28125
118
0.565919
mrcstan
c4f3b175c680d3fc434547f52a62fa6ed3cf467a
7,745
cpp
C++
Max_Kasumi/Max_KasumiSub32.cpp
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
106
2019-05-15T13:16:30.000Z
2022-03-29T11:18:38.000Z
Max_Kasumi/Max_KasumiSub32.cpp
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
2
2020-10-24T07:12:52.000Z
2022-03-05T10:25:51.000Z
Max_Kasumi/Max_KasumiSub32.cpp
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
20
2019-07-10T06:08:14.000Z
2022-03-13T02:35:12.000Z
#include "Max_Kasumi.h" //------------------------------------------------------------------------------------------------- static PF_Err Rev(CFsAE *ae, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; PF_PixelFloat *data = pi->data; A_long pos = 0; for (A_long y = 0; y < pi->height; y++) { for (A_long x = 0; x < pi->width; x++) { PF_FpShort r = data[pos].red; PF_FpShort g = data[pos].green; PF_FpShort b = data[pos].blue; PF_FpShort a = data[pos].alpha; if (r > 1.0) r = 1.0; if (g > 1.0) g = 1.0; if (b > 1.0) b = 1.0; if (a > 1.0) a = 1.0; data[pos].red = (PF_FpShort)(1.0 - r); data[pos].green = (PF_FpShort)(11.0 - g); data[pos].blue = (PF_FpShort)(11.0 - b); data[pos].alpha = (PF_FpShort)(11.0 - a); pos++; } pos += pi->widthOffset; } return err; } //------------------------------------------------------------------------------------------------- static PF_Err MaxHorRGB32(CFsAE *ae, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; PF_PixelFloat *data = pi->data; PF_FpShort a; PF_FpShort r, g, b, v,p; PF_FpShort r1, g1, b1, v1; PF_FpShort r2, g2, b2, v2; A_long hor; for (A_long y = 0; y < pi->height; y++) { hor = y * pi->widthTrue; for (A_long x = 0; x < pi->width; x++) { pi->scanline[x] = data[x + hor]; } for (A_long x = 0; x < pi->width; x++) { r = pi->scanline[x].red; g = pi->scanline[x].green; b = pi->scanline[x].blue; a = pi->scanline[x].alpha; v = r + g + b; r1 = r2 = r; g1 = g2 = g; b1 = b2 = b; if (x > 0) { r1 = pi->scanline[x - 1].red; g1 = pi->scanline[x - 1].green; b1 = pi->scanline[x - 1].blue; v1 = r1 + g1 + b1; } if (x < pi->width - 1) { r2 = pi->scanline[x + 1].red; g2 = pi->scanline[x + 1].green; b2 = pi->scanline[x + 1].blue; v2 = r2 + g2 + b2; } if (v1 < v2) { r1 = r2; g1 = g2; b1 = b2; v1 = v2; } if (v <v1) { p = r1 / 4; r = r + p - r * p; if (r > r1) r = r1; p = g1 / 4; g = g + p - g * p; if (g > g1) g = g1; p = b1 / 4; b = b + p - b * p; if (b > b1) b = b1; PF_PixelFloat c; c.red = (PF_FpShort)r; c.green = (PF_FpShort)g; c.blue = (PF_FpShort)b; c.alpha = a; data[x + hor] = c; } } } return err; } //------------------------------------------------------------------------------------------------- static PF_Err MaxVerRGB32(CFsAE *ae, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; PF_PixelFloat *data = pi->data; PF_FpShort a; PF_FpShort r, g, b, v, p; PF_FpShort r1, g1, b1, v1; PF_FpShort r2, g2, b2, v2; A_long hor; for (A_long x = 0; x < pi->width; x++) { hor = 0; for (A_long y = 0; y < pi->height; y++) { pi->scanline[y] = data[x + hor]; hor += pi->widthTrue; } hor = 0; for (A_long y = 0; y < pi->height; y++) { r = pi->scanline[y].red; g = pi->scanline[y].green; b = pi->scanline[y].blue; a = pi->scanline[y].alpha; v = r + g + b; r1 = r2 = r; g1 = g2 = g; b1 = b2 = b; if (y > 0) { r1 = pi->scanline[y - 1].red; g1 = pi->scanline[y - 1].green; b1 = pi->scanline[y - 1].blue; v1 = r1 + g1 + b1; } if (y < pi->height - 1) { r2 = pi->scanline[y + 1].red; g2 = pi->scanline[y + 1].green; b2 = pi->scanline[y + 1].blue; v2 = r2 + g2 + b2; } if (v1 < v2) { r1 = r2; g1 = g2; b1 = b2; v1 = v2; } if (v < v1) { p = r1 / 4; r = r + p - r * p; if (r > r1) r = r1; p = g1 / 4; g = g + p - g * p; if (g > g1) g = g1; p = b1 / 4; b = b + p - b * p; if (b > b1) b = b1; PF_PixelFloat c; c.red = (PF_FpShort)r; c.green = (PF_FpShort)g; c.blue = (PF_FpShort)b; c.alpha = a; data[x + hor] = c; } hor += pi->widthTrue; } } return err; } //------------------------------------------------------------------------------------------------- static PF_Err MaxHorA32(CFsAE *ae, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; PF_PixelFloat *data = pi->data; PF_FpShort a, p; PF_FpShort r, g, b; PF_FpShort a1, a2; A_long hor; for (A_long y = 0; y < pi->height; y++) { hor = y * pi->widthTrue; for (A_long x = 0; x < pi->width; x++) { pi->scanline[x] = data[x + hor]; } for (A_long x = 0; x < pi->width; x++) { r = pi->scanline[x].red; g = pi->scanline[x].green; b = pi->scanline[x].blue; a = pi->scanline[x].alpha; a1 = a2 = a; if (x > 0) { a1 = pi->scanline[x - 1].alpha; } if (x < pi->width - 1) { a2 = pi->scanline[x + 1].alpha; } if (a1 < a2) { a1 = a2; } if (a < a1) { p = a1 / 4; a = a + p - a * p; if (a > a1) a = a1; PF_PixelFloat c; c.red = r; c.green = g; c.blue = b; c.alpha = (PF_FpShort)a; data[x + hor] = c; } } } return err; } //------------------------------------------------------------------------------------------------- static PF_Err MaxVerA32(CFsAE *ae, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; PF_PixelFloat *data = pi->data; PF_FpShort a, p; PF_FpShort r, g, b; PF_FpShort a1, a2; A_long hor; for (A_long x = 0; x < pi->width; x++) { hor = 0; for (A_long y = 0; y < pi->height; y++) { pi->scanline[y] = data[x + hor]; hor += pi->widthTrue; } hor = 0; for (A_long y = 0; y < pi->height; y++) { r = pi->scanline[y].red; g = pi->scanline[y].green; b = pi->scanline[y].blue; a = pi->scanline[y].alpha; a1 = a2 = a; if (x > 0) { a1 = pi->scanline[y - 1].alpha; } if (x < pi->width - 1) { a2 = pi->scanline[y + 1].alpha; } if (a1 < a2) { a1 = a2; } if (a < a1) { p = a1 / 4; a = a + p - a * p; if (a > a1) a = a1; PF_PixelFloat c; c.red = r; c.green = g; c.blue = b; c.alpha = (PF_FpShort)a; data[x + hor] = c; } hor += pi->widthTrue; } } return err; } //------------------------------------------------------------------------------------------------- static PF_Err ToParam32(CFsAE *ae, ParamInfo *infoP, ParamInfo32 *pi) { PF_Err err = PF_Err_NONE; pi->width = ae->out->width(); pi->widthTrue = ae->out->widthTrue(); pi->widthOffset = ae->out->offsetWidth(); pi->height = ae->out->height(); pi->data = (PF_PixelFloat *)ae->out->data(); pi->in_data = ae->in_data; pi->bufSize = pi->width; if (pi->bufSize < pi->height) pi->bufSize = pi->height; pi->info = *infoP; return err; } //------------------------------------------------------------------------------------------------- PF_Err Exec32(CFsAE *ae, ParamInfo *infoP) { PF_Err err = PF_Err_NONE; if (ae->out->Enabled() == FALSE) { return PF_Err_INVALID_CALLBACK; } ParamInfo32 pi; ToParam32(ae, infoP, &pi); if (pi.info.max <= 0) { return err; } pi.bufH = ae->NewHandle(pi.bufSize * sizeof(PF_PixelFloat) * 2); if (pi.bufH == NULL) { err = PF_Err_OUT_OF_MEMORY; return err; } pi.scanline = *(PF_PixelFloat**)pi.bufH; ae->out->toBlackMat32(); if (pi.info.minus)Rev(ae, &pi); if ((pi.info.ch == 1) || (pi.info.ch == 2)) { for (A_long i = 0; i < pi.info.max; i++) { if ((pi.info.dir == 1) || (pi.info.dir == 2)) { MaxHorRGB32(ae, &pi); } if ((pi.info.dir == 1) || (pi.info.dir == 3)) { MaxVerRGB32(ae, &pi); } } } if ((pi.info.ch == 1) || (pi.info.ch == 3)) { for (A_long i = 0; i < pi.info.max; i++) { if ((pi.info.dir == 1) || (pi.info.dir == 2)) { MaxHorA32(ae, &pi); } if ((pi.info.dir == 1) || (pi.info.dir == 3)) { MaxVerA32(ae, &pi); } } } if (pi.info.minus)Rev(ae, &pi); ae->out->SetMatMode(MAT::blackMat); ae->out->fromBlackMat32(); if (pi.bufH != NULL) { ae->DisposeHandle(pi.bufH); pi.bufH = NULL; } return err; }
20.064767
99
0.459135
bryful
c4f93ff5ead065ccadfe7746b77b8f821794fdf6
1,187
cpp
C++
Ryukuo Suspender/main.cpp
Iciclez/ryukuo-suspender
cdcc6beede79a23e5da71813b78c41cde718453a
[ "MIT" ]
null
null
null
Ryukuo Suspender/main.cpp
Iciclez/ryukuo-suspender
cdcc6beede79a23e5da71813b78c41cde718453a
[ "MIT" ]
null
null
null
Ryukuo Suspender/main.cpp
Iciclez/ryukuo-suspender
cdcc6beede79a23e5da71813b78c41cde718453a
[ "MIT" ]
null
null
null
#include <windows.h> #include <cstdint> #include "mainwindow.hpp" #pragma comment(linker,"\"/manifestdependency:type='win32' \ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #pragma comment (lib, "Icy.lib") #pragma comment (lib, "ntdll") typedef HINSTANCE hinstance; typedef LPSTR lpstr; typedef HANDLE handle; int32_t _stdcall WinMain(hinstance inst, hinstance, lpstr, int32_t) { []() { handle process = GetCurrentProcess(); handle token = 0; if (OpenProcessToken(process, TOKEN_ADJUST_PRIVILEGES, &token)) { CloseHandle(token); CloseHandle(process); return false; } LUID luid = { 0 }; if (!LookupPrivilegeValue(0, "SeDebugPrivilege", &luid)) { CloseHandle(token); CloseHandle(process); return false; } TOKEN_PRIVILEGES privileges = { 0 }; privileges.PrivilegeCount = 1; privileges.Privileges[0].Luid = luid; privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(token, false, &privileges, 0, 0, 0); CloseHandle(token); CloseHandle(process); return true; }(); return mainwindow(inst).message_loop(); }
23.27451
76
0.714406
Iciclez
c4f98f7738a2ade6880a90a35e249a8f0bd80238
7,896
cpp
C++
src/minisef/app/legion/rendermanager.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
6
2022-01-23T09:40:33.000Z
2022-03-20T20:53:25.000Z
src/minisef/app/legion/rendermanager.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
null
null
null
src/minisef/app/legion/rendermanager.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
1
2022-02-06T21:05:23.000Z
2022-02-06T21:05:23.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: The main manager of the rendering // // $Revision: $ // $NoKeywords: $ //===========================================================================// #include "rendermanager.h" #include "legion.h" #include "uimanager.h" #include "worldmanager.h" #include "materialsystem/imaterialsystem.h" #include "tier2/tier2.h" //----------------------------------------------------------------------------- // Camera property //----------------------------------------------------------------------------- DEFINE_FIXEDSIZE_ALLOCATOR(CCameraProperty, 1, CMemoryPool::GROW_SLOW); CCameraProperty::CCameraProperty() { m_Origin.Init(); m_Angles.Init(); m_Velocity.Init(); m_AngVelocity.Init(); } void CCameraProperty::GetForward(Vector *pForward) { AngleVectors(m_Angles, pForward); } //----------------------------------------------------------------------------- // Singleton accessor //----------------------------------------------------------------------------- static CRenderManager s_RenderManager; extern CRenderManager *g_pRenderManager = &s_RenderManager; //----------------------------------------------------------------------------- // Game initialization //----------------------------------------------------------------------------- bool CRenderManager::Init() { m_bRenderWorldFullscreen = true; return true; } void CRenderManager::Shutdown() { } //----------------------------------------------------------------------------- // Level initialization //----------------------------------------------------------------------------- LevelRetVal_t CRenderManager::LevelInit(bool bFirstCall) { return FINISHED; } LevelRetVal_t CRenderManager::LevelShutdown(bool bFirstCall) { return FINISHED; } //----------------------------------------------------------------------------- // Property allocation //----------------------------------------------------------------------------- CCameraProperty *CRenderManager::CreateCameraProperty() { return new CCameraProperty; } void CRenderManager::DestroyCameraProperty(CCameraProperty *pProperty) { delete pProperty; } //----------------------------------------------------------------------------- // Sets the rectangle to draw into //----------------------------------------------------------------------------- void CRenderManager::RenderWorldFullscreen() { m_bRenderWorldFullscreen = true; } void CRenderManager::RenderWorldInRect(int x, int y, int nWidth, int nHeight) { m_bRenderWorldFullscreen = false; m_nRenderX = x; m_nRenderY = y; m_nRenderWidth = nWidth; m_nRenderHeight = nHeight; } //----------------------------------------------------------------------------- // Done completely client-side, want total smoothness, so simulate at render interval //----------------------------------------------------------------------------- void CRenderManager::UpdateLocalPlayerCamera() { float dt = IGameManager::DeltaTime(); CCameraProperty *pCamera = g_pWorldManager->GetLocalPlayer()->m_pCameraProperty; VectorMA(pCamera->m_Origin, dt, pCamera->m_Velocity, pCamera->m_Origin); VectorMA(pCamera->m_Angles, dt, pCamera->m_AngVelocity, pCamera->m_Angles); } //----------------------------------------------------------------------------- // Per-frame update //----------------------------------------------------------------------------- void CRenderManager::Update() { CMatRenderContextPtr pRenderContext(g_pMaterialSystem); if (GetLevelState() == NOT_IN_LEVEL) { g_pMaterialSystem->BeginFrame(0); pRenderContext->ClearColor4ub(76, 88, 68, 255); pRenderContext->ClearBuffers(true, true); g_pUIManager->DrawUI(); g_pMaterialSystem->EndFrame(); g_pMaterialSystem->SwapBuffers(); return; } UpdateLocalPlayerCamera(); g_pMaterialSystem->BeginFrame(0); pRenderContext->ClearColor4ub(0, 0, 0, 255); pRenderContext->ClearBuffers(true, true); RenderWorld(); g_pUIManager->DrawUI(); g_pMaterialSystem->EndFrame(); g_pMaterialSystem->SwapBuffers(); } //----------------------------------------------------------------------------- // Sets up the camera //----------------------------------------------------------------------------- void CRenderManager::SetupCameraRenderState() { CCameraProperty *pCamera = g_pWorldManager->GetLocalPlayer()->m_pCameraProperty; matrix3x4_t cameraToWorld; AngleMatrix(pCamera->m_Angles, pCamera->m_Origin, cameraToWorld); matrix3x4_t matRotate; matrix3x4_t matRotateZ; MatrixBuildRotationAboutAxis(Vector(0, 0, 1), -90, matRotateZ); MatrixMultiply(cameraToWorld, matRotateZ, matRotate); matrix3x4_t matRotateX; MatrixBuildRotationAboutAxis(Vector(1, 0, 0), 90, matRotateX); MatrixMultiply(matRotate, matRotateX, matRotate); matrix3x4_t view; MatrixInvert(matRotate, view); CMatRenderContextPtr pRenderContext(g_pMaterialSystem); pRenderContext->MatrixMode(MATERIAL_VIEW); pRenderContext->LoadMatrix(view); } //----------------------------------------------------------------------------- // Set up a projection matrix for a 90 degree fov //----------------------------------------------------------------------------- // FIXME: Better control over Z range #define ZNEAR 0.1f #define ZFAR 10000.0f void CRenderManager::SetupProjectionMatrix(int nWidth, int nHeight, float flFOV) { VMatrix proj; float flZNear = ZNEAR; float flZFar = ZFAR; float flApsectRatio = (nHeight != 0.0f) ? (float) nWidth / (float) nHeight : 100.0f; float halfWidth = tan(flFOV * M_PI / 360.0); float halfHeight = halfWidth / flApsectRatio; memset(proj.Base(), 0, sizeof(proj)); proj[0][0] = 1.0f / halfWidth; proj[1][1] = 1.0f / halfHeight; proj[2][2] = flZFar / (flZNear - flZFar); proj[3][2] = -1.0f; proj[2][3] = flZNear * flZFar / (flZNear - flZFar); CMatRenderContextPtr pRenderContext(g_pMaterialSystem); pRenderContext->MatrixMode(MATERIAL_PROJECTION); pRenderContext->LoadMatrix(proj); } //----------------------------------------------------------------------------- // Set up a orthographic projection matrix //----------------------------------------------------------------------------- void CRenderManager::SetupOrthoMatrix(int nWidth, int nHeight) { CMatRenderContextPtr pRenderContext(g_pMaterialSystem); pRenderContext->MatrixMode(MATERIAL_PROJECTION); pRenderContext->LoadIdentity(); pRenderContext->Ortho(0, 0, nWidth, nHeight, -1.0f, 1.0f); } //----------------------------------------------------------------------------- // Renders the world //----------------------------------------------------------------------------- void CRenderManager::RenderWorld() { CMatRenderContextPtr pRenderContext(g_pMaterialSystem); pRenderContext->MatrixMode(MATERIAL_PROJECTION); pRenderContext->PushMatrix(); pRenderContext->MatrixMode(MATERIAL_VIEW); pRenderContext->PushMatrix(); pRenderContext->MatrixMode(MATERIAL_MODEL); pRenderContext->PushMatrix(); pRenderContext->LoadIdentity(); if (m_bRenderWorldFullscreen) { m_nRenderX = m_nRenderY = 0; pRenderContext->GetRenderTargetDimensions(m_nRenderWidth, m_nRenderHeight); } pRenderContext->DepthRange(0, 1); pRenderContext->Viewport(m_nRenderX, m_nRenderY, m_nRenderWidth, m_nRenderHeight); SetupProjectionMatrix(m_nRenderWidth, m_nRenderHeight, 90); SetupCameraRenderState(); g_pWorldManager->DrawWorld(); pRenderContext->MatrixMode(MATERIAL_PROJECTION); pRenderContext->PopMatrix(); pRenderContext->MatrixMode(MATERIAL_VIEW); pRenderContext->PopMatrix(); pRenderContext->MatrixMode(MATERIAL_MODEL); pRenderContext->PopMatrix(); }
33.316456
88
0.542427
cstom4994
f202b24ab9f16316fbe97b80408a6fb38976ba20
13,351
cc
C++
src/utils/wrap_function.cc
elisabethrenner/py-orbit
02ccfc291157218d40450f7c75302ab93fecb69e
[ "MIT" ]
1
2018-03-22T09:12:08.000Z
2018-03-22T09:12:08.000Z
src/utils/wrap_function.cc
elisabethrenner/py-orbit
02ccfc291157218d40450f7c75302ab93fecb69e
[ "MIT" ]
null
null
null
src/utils/wrap_function.cc
elisabethrenner/py-orbit
02ccfc291157218d40450f7c75302ab93fecb69e
[ "MIT" ]
2
2019-05-16T09:34:04.000Z
2019-10-07T11:37:05.000Z
#include "orbit_mpi.hh" #include "pyORBIT_Object.hh" #include "wrap_utils.hh" #include "wrap_function.hh" #include <iostream> #include <string> #include "OU_Function.hh" using namespace OrbitUtils; using namespace wrap_orbit_utils; namespace wrap_function{ void error(const char* msg){ ORBIT_MPI_Finalize(msg); } #ifdef __cplusplus extern "C" { #endif /** Constructor for python class wrapping c++ Function instance. It never will be called directly. */ static PyObject* Function_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ pyORBIT_Object* self; self = (pyORBIT_Object *) type->tp_alloc(type, 0); self->cpp_obj = NULL; return (PyObject *) self; } /** This is implementation of the __init__ method */ static int Function_init(pyORBIT_Object *self, PyObject *args, PyObject *kwds){ self->cpp_obj = new Function(); ((Function*) self->cpp_obj)->setPyWrapper((PyObject*) self); return 0; } /** It will add (x,y) or (x,y,err) point to the Function instance */ static PyObject* Function_add(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; double x,y; double err = 0.; if(!PyArg_ParseTuple( args,"dd|d:",&x,&y,&err)) error("pyFunction add(x,y) or add(x,y,err) - parameters are needed"); else { cpp_Function->add(x,y,err); } Py_INCREF(Py_None); return Py_None; } /** It will return the number of (x,y) pairs in the Function instance */ static PyObject* Function_getSize(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int size = cpp_Function->getSize(); return Py_BuildValue("i",size); } /** It will return x for a particular index ind */ static PyObject* Function_x(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int ind = -1; if(!PyArg_ParseTuple( args,"i:",&ind)){ error("pyFunction x(index) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->x(ind)); } /** It will return y for a particular index ind */ static PyObject* Function_y(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int ind = -1; if(!PyArg_ParseTuple( args,"i:",&ind)){ error("pyFunction y(index) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->y(ind)); } /** It will return y for a particular index ind */ static PyObject* Function_err(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int ind = -1; if(!PyArg_ParseTuple( args,"i:",&ind)){ error("pyFunction err(index) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->err(ind)); } /** It will return (x,y) for a particular index ind */ static PyObject* Function_xy(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int ind = -1; if(!PyArg_ParseTuple( args,"i:",&ind)){ error("pyFunction xy(index) - parameter is needed"); } return Py_BuildValue("(dd)",cpp_Function->x(ind),cpp_Function->y(ind)); } /** It will return (x,y) for a particular index ind */ static PyObject* Function_xyErr(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int ind = -1; if(!PyArg_ParseTuple( args,"i:",&ind)){ error("pyFunction xyErr(index) - parameter is needed"); } return Py_BuildValue("(ddd)",cpp_Function->x(ind),cpp_Function->y(ind),cpp_Function->err(ind)); } /** It will return minimal x value in the Function */ static PyObject* Function_getMinX(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("d",cpp_Function->getMinX()); } /** It will return maximal x value in the Function */ static PyObject* Function_getMaxX(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("d",cpp_Function->getMaxX()); } /** It will return minimal y value in the Function */ static PyObject* Function_getMinY(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("d",cpp_Function->getMinY()); } /** It will return maximal y value in the Function */ static PyObject* Function_getMaxY(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("d",cpp_Function->getMaxY()); } /** It will remove all points in the Function */ static PyObject* Function_clean(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; cpp_Function->clean(); Py_INCREF(Py_None); return Py_None; } /** It will free the memeory and will remove all points in the Function */ static PyObject* Function_cleanMemory(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; cpp_Function->cleanMemory(); Py_INCREF(Py_None); return Py_None; } /** It will return y for a specified x value */ static PyObject* Function_getY(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; double val = 0.; if(!PyArg_ParseTuple( args,"d:",&val)){ error("pyFunction getY(x) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->getY(val)); } /** It will return x for a specified y value */ static PyObject* Function_getX(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; double val = 0.; if(!PyArg_ParseTuple( args,"d:",&val)){ error("pyFunction getX(y) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->getX(val)); } /** It will return x for a specified y value */ static PyObject* Function_getYErr(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; double val = 0.; if(!PyArg_ParseTuple( args,"d:",&val)){ error("pyFunction getYErr(y) - parameter is needed"); } return Py_BuildValue("d",cpp_Function->getYErr(val)); } /** It will set the constant step flag to 1 if it is possible */ static PyObject* Function_setConstStep(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; int inf = -1; if(!PyArg_ParseTuple( args,"i:",&inf)){ error("pyFunction setConstStep(inf) - parameter is needed"); } return Py_BuildValue("i",cpp_Function->setConstStep(inf)); } /** It will return 1 if the step is const and 0 otherwise */ static PyObject* Function_isStepConst(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("i",cpp_Function->isStepConst()); } /** It will build the reverse Function if it is possible and return 1 or 0 */ static PyObject* Function_setInverse(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; Function* rf = NULL; PyObject* pyF; int inf = -1; if(!PyArg_ParseTuple( args,"O:",&pyF)) error("pyFunction setInverse(pyFunction F) - parameter is needed"); else { PyObject* pyORBIT_Function_Type = getOrbitUtilsType("Function"); if(!PyObject_IsInstance(pyF,pyORBIT_Function_Type)){ error("pyFunction - setInverse(pyFunction F) - pyFunction parameter is needed."); } rf= (Function*) ((pyORBIT_Object*) pyF)->cpp_obj; inf = cpp_Function->setInverse(rf); } return Py_BuildValue("i",inf); } //Prints Function into the std::cout stream or file static PyObject* Function_dump(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; //if nVars == 0 print into std::cout //if nVars == 1 print into the file int nVars = PyTuple_Size(args); const char* file_name = NULL; if(nVars == 0 || nVars == 1){ if(nVars == 0){ cpp_Function->print(std::cout); } else{ if(!PyArg_ParseTuple( args,"s:dump",&file_name)){ error("pyFunction - dump(fileName) - a file name is needed"); } cpp_Function->print(file_name); } } else{ error("pyFunction. You should call dump() or dump(file_name)"); } Py_INCREF(Py_None); return Py_None; } /** It will return 1 if it is success and 0 otherwise */ static PyObject* Function_normalize(PyObject *self, PyObject *args){ Function* cpp_Function = (Function*)((pyORBIT_Object*) self)->cpp_obj; return Py_BuildValue("i",cpp_Function->normalize()); } //----------------------------------------------------- //destructor for python Function class (__del__ method). //----------------------------------------------------- static void Function_del(pyORBIT_Object* self){ //std::cerr<<"The Function __del__ has been called!"<<std::endl; delete ((Function*)self->cpp_obj); self->ob_type->tp_free((PyObject*)self); } // defenition of the methods of the python Function wrapper class // they will be vailable from python level static PyMethodDef FunctionClassMethods[] = { { "add", Function_add, METH_VARARGS,"Adds (x,y) to the Function container."}, { "getSize", Function_getSize, METH_VARARGS,"Returns the number of (x,y) in Function"}, { "x", Function_x, METH_VARARGS,"Returns x value for a point with a particular index"}, { "y", Function_y, METH_VARARGS,"Returns y value for a point with a particular index"}, { "err", Function_err, METH_VARARGS,"Returns err value for y with a particular index"}, { "xy", Function_xy, METH_VARARGS,"Returns (x,y) value for a point with a particular index"}, { "xyErr", Function_xyErr, METH_VARARGS,"Returns (x,y,err) value for a point with a particular index"}, { "getMinX", Function_getMinX, METH_VARARGS,"Returns the minimal x value in the Function"}, { "getMaxX", Function_getMaxX, METH_VARARGS,"Returns the maximal x value in the Function"}, { "getMinY", Function_getMinY, METH_VARARGS,"Returns the minimal y value in the Function"}, { "getMaxY", Function_getMaxY, METH_VARARGS,"Returns the maximal y value in the Function"}, { "clean", Function_clean, METH_VARARGS,"It will remove all points in the Function"}, { "cleanMemory", Function_cleanMemory, METH_VARARGS,"It will free the memory and remove all points in the Function"}, { "getY", Function_getY, METH_VARARGS,"Returns y for a specified x value "}, { "getX", Function_getX, METH_VARARGS,"Returns x for a specified y value "}, { "getYErr", Function_getYErr, METH_VARARGS,"Returns err for a specified y value "}, { "setConstStep", Function_setConstStep, METH_VARARGS,"It will set the constant step flag to 1 if it is possible"}, { "isStepConst", Function_isStepConst, METH_VARARGS,"It will return 1 if the step is const and 0 otherwise"}, { "setInverse", Function_setInverse, METH_VARARGS,"It will build the reverse Function if it is possible and return 1 or 0"}, { "dump", Function_dump, METH_VARARGS,"Prints Function into the std::cout stream or file"}, { "normalize", Function_normalize, METH_VARARGS,"It will return 1 if it is success and 0 otherwise"}, {NULL} }; // defenition of the memebers of the python Function wrapper class // they will be vailable from python level static PyMemberDef FunctionClassMembers [] = { {NULL} }; //new python Function wrapper type definition static PyTypeObject pyORBIT_Function_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Function", /*tp_name*/ sizeof(pyORBIT_Object), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Function_del , /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "The Function python wrapper", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ FunctionClassMethods, /* tp_methods */ FunctionClassMembers, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc) Function_init, /* tp_init */ 0, /* tp_alloc */ Function_new, /* tp_new */ }; //-------------------------------------------------- //Initialization function of the pyFunction class //-------------------------------------------------- void initFunction(PyObject* module){ if (PyType_Ready(&pyORBIT_Function_Type) < 0) return; Py_INCREF(&pyORBIT_Function_Type); PyModule_AddObject(module, "Function", (PyObject *)&pyORBIT_Function_Type); } #ifdef __cplusplus } #endif }
37.928977
131
0.664894
elisabethrenner
f20a2638bc2e1f619cb526b2de95635140520667
362
cpp
C++
Codeforces Online Judge Solve/Vus- the- Cossack- and- a -Contest.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
Codeforces Online Judge Solve/Vus- the- Cossack- and- a -Contest.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
Codeforces Online Judge Solve/Vus- the- Cossack- and- a -Contest.cpp
Remonhasan/programming-solve
5a4ac8c738dd361e1c974162e0eaebbaae72fd80
[ "Apache-2.0" ]
null
null
null
/* Author: Remon Hasan solving concept: if number of pens and notebooks are is equal or more than Number of contestant for that the answer will be true. */ #include<bits/stdc++.h> using namespace std; int main () { int N,M,K; cin>>N>>M>>K; if(M>=N && K>=N){ cout<<"Yes"<<endl; } else cout<<"No"<<endl; }
20.111111
77
0.560773
Remonhasan
f210e7699ea7c0c2e7c60cb5add15c17414e3633
1,699
cpp
C++
aws-cpp-sdk-s3control/source/model/ListStorageLensConfigurationsResult.cpp
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-02-10T08:06:54.000Z
2022-02-10T08:06:54.000Z
aws-cpp-sdk-s3control/source/model/ListStorageLensConfigurationsResult.cpp
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-s3control/source/model/ListStorageLensConfigurationsResult.cpp
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/s3control/model/ListStorageLensConfigurationsResult.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <utility> using namespace Aws::S3Control::Model; using namespace Aws::Utils::Xml; using namespace Aws::Utils; using namespace Aws; ListStorageLensConfigurationsResult::ListStorageLensConfigurationsResult() { } ListStorageLensConfigurationsResult::ListStorageLensConfigurationsResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) { *this = result; } ListStorageLensConfigurationsResult& ListStorageLensConfigurationsResult::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result) { const XmlDocument& xmlDocument = result.GetPayload(); XmlNode resultNode = xmlDocument.GetRootElement(); if(!resultNode.IsNull()) { XmlNode nextTokenNode = resultNode.FirstChild("NextToken"); if(!nextTokenNode.IsNull()) { m_nextToken = Aws::Utils::Xml::DecodeEscapedXmlText(nextTokenNode.GetText()); } XmlNode storageLensConfigurationListNode = resultNode.FirstChild("StorageLensConfiguration"); if(!storageLensConfigurationListNode.IsNull()) { XmlNode storageLensConfigurationMember = storageLensConfigurationListNode; while(!storageLensConfigurationMember.IsNull()) { m_storageLensConfigurationList.push_back(storageLensConfigurationMember); storageLensConfigurationMember = storageLensConfigurationMember.NextNode("StorageLensConfiguration"); } } } return *this; }
31.462963
140
0.774573
perfectrecall
f21231a28e08ba4d931cabf16e967100e50819fb
2,657
cpp
C++
Engine/source/gfx/gfxCubemap.cpp
fr1tz/alux3d
249a3b51751ce3184d52879b481f83eabe89e7e3
[ "MIT" ]
46
2015-01-05T17:34:43.000Z
2022-01-04T04:03:09.000Z
Engine/source/gfx/gfxCubemap.cpp
fr1tz/alux3d
249a3b51751ce3184d52879b481f83eabe89e7e3
[ "MIT" ]
10
2015-01-20T23:14:46.000Z
2019-04-05T22:04:15.000Z
Engine/source/gfx/gfxCubemap.cpp
fr1tz/terminal-overload
85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60
[ "CC-BY-4.0" ]
9
2015-08-08T18:46:06.000Z
2021-02-01T13:53:20.000Z
// Copyright information can be found in the file named COPYING // located in the root directory of this distribution. #include "gfx/gfxCubemap.h" #include "gfx/gfxDevice.h" #include "gfx/bitmap/gBitmap.h" #include "gfx/gfxTextureManager.h" GFXCubemap::~GFXCubemap() { // If we're not dynamic and we were loaded from a // file then give the texture manager a chance to // remove us from the cache. if ( mPath.isNotEmpty() ) TEXMGR->releaseCubemap( this ); } void GFXCubemap::initNormalize( U32 size ) { Point3F axis[6] = {Point3F(1.0, 0.0, 0.0), Point3F(-1.0, 0.0, 0.0), Point3F(0.0, 1.0, 0.0), Point3F( 0.0, -1.0, 0.0), Point3F(0.0, 0.0, 1.0), Point3F( 0.0, 0.0, -1.0),}; Point3F s[6] = {Point3F(0.0, 0.0, -1.0), Point3F( 0.0, 0.0, 1.0), Point3F(1.0, 0.0, 0.0), Point3F( 1.0, 0.0, 0.0), Point3F(1.0, 0.0, 0.0), Point3F(-1.0, 0.0, 0.0),}; Point3F t[6] = {Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0, 0.0), Point3F(0.0, 0.0, 1.0), Point3F(0.0, 0.0, -1.0), Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0, 0.0),}; F32 span = 2.0; F32 start = -1.0; F32 stride = span / F32(size - 1); GFXTexHandle faces[6]; for(U32 i=0; i<6; i++) { GFXTexHandle &tex = faces[i]; GBitmap *bitmap = new GBitmap(size, size); // fill in... for(U32 v=0; v<size; v++) { for(U32 u=0; u<size; u++) { Point3F vector; vector = axis[i] + ((F32(u) * stride) + start) * s[i] + ((F32(v) * stride) + start) * t[i]; vector.normalizeSafe(); vector = ((vector * 0.5) + Point3F(0.5, 0.5, 0.5)) * 255.0; vector.x = mClampF(vector.x, 0.0f, 255.0f); vector.y = mClampF(vector.y, 0.0f, 255.0f); vector.z = mClampF(vector.z, 0.0f, 255.0f); // easy way to avoid knowledge of the format (RGB, RGBA, RGBX, ...)... U8 *bits = bitmap->getAddress(u, v); bits[0] = U8(vector.x); bits[1] = U8(vector.y); bits[2] = U8(vector.z); } } tex.set(bitmap, &GFXDefaultStaticDiffuseProfile, true, "Cubemap"); } initStatic(faces); } const String GFXCubemap::describeSelf() const { // We've got nothing return String(); } bool GFXCubemapHandle::set( const String &cubemapDDS ) { /// Free the previous handle to give us /// back any texture memory when it can. free(); // Let the texture manager find this for us. StrongRefPtr<GFXCubemap>::set( TEXMGR->createCubemap( cubemapDDS ) ); return isValid(); }
29.197802
82
0.541588
fr1tz
f21a21a1ee8894e25eba10592e30dac7ab71259f
311
cpp
C++
benchmark/number_benchmark.cpp
KaungZawHtet/XMwayLoon
4dd014dc75a209c242bba5d2dc4333af63bcb405
[ "Unlicense" ]
6
2020-03-23T04:20:53.000Z
2020-05-23T00:32:36.000Z
benchmark/number_benchmark.cpp
KaungZawHtet/XMwayLoon
4dd014dc75a209c242bba5d2dc4333af63bcb405
[ "Unlicense" ]
null
null
null
benchmark/number_benchmark.cpp
KaungZawHtet/XMwayLoon
4dd014dc75a209c242bba5d2dc4333af63bcb405
[ "Unlicense" ]
null
null
null
// // Created by Kaung Zaw Htet on 2019-11-21. // #include <benchmark/benchmark.h> #include <randomizer/number_randomizer.h> static void create_BM(benchmark::State& state) { for (auto _ : state) { XMwayLoon::Randomizer::Number obj_Number; } } BENCHMARK(create_BM); BENCHMARK_MAIN();
14.136364
49
0.675241
KaungZawHtet
35ecf6649260fc9e55478b41f4b8d9334abbb0d9
2,001
cpp
C++
assignments/assignment_12/assignment_12.cpp
Katsute/Baruch-CIS-3100-Assignments
4a8b8b1546750f581f7ed7400e4efa63c3e0a6be
[ "CC0-1.0" ]
null
null
null
assignments/assignment_12/assignment_12.cpp
Katsute/Baruch-CIS-3100-Assignments
4a8b8b1546750f581f7ed7400e4efa63c3e0a6be
[ "CC0-1.0" ]
null
null
null
assignments/assignment_12/assignment_12.cpp
Katsute/Baruch-CIS-3100-Assignments
4a8b8b1546750f581f7ed7400e4efa63c3e0a6be
[ "CC0-1.0" ]
1
2022-01-12T18:17:46.000Z
2022-01-12T18:17:46.000Z
#include <iostream> #include <iomanip> #include <string> using namespace std; class Employee { private: string name, department, position; int idNumber; public: // constructor Employee(string name, int idNumber, string department, string position) { this->name = name; this->idNumber = idNumber; this->department = department; this->position = position; }; // constructor (2 args) Employee(string name, int idNumber) : Employee(name, idNumber, "", "") { }; // default constructor Employee() : Employee("", 0, "", "") { }; // get/set string getName() const { return name; }; void setName(string name) { this->name = name; }; int getID() const { return idNumber; }; void setID(int id) { this->idNumber = id; }; string getDepartment() const { return department; }; void setDeparment(string department) { this->department = department; }; string getPosition() const { return position; }; void setPosition(string position) { this->position = position; }; }; int main() { // init array Employee employees[3] = { Employee("Susan Meyers", 47889, "Accounting", "Vice President"), Employee("Mark Jones", 39119, "IT", "Programmer"), Employee("Joy Rogers", 81774, "Manufacturing", "Engineer") }; // header int col = 15; cout << left << setw(col) << "Name" << left << setw(col) << "Number" << left << setw(col) << "Department" << left << setw(col) << "Position" << endl; for (int i = 0; i < col*4; i++) cout << '-'; cout << endl; // print array for (Employee e : employees) cout << left << setw(col) << e.getName() << left << setw(col) << e.getID() << left << setw(col) << e.getDepartment() << left << setw(col) << e.getPosition() << endl; }
31.265625
83
0.536732
Katsute
35f0a26caa9e02cad54a5feb97e36e5aba6ca472
7,301
cxx
C++
xp_comm_proj/bodofrev/bodofrev.cxx
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
3
2020-08-03T08:52:20.000Z
2021-04-10T11:55:49.000Z
xp_comm_proj/bodofrev/bodofrev.cxx
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
null
null
null
xp_comm_proj/bodofrev/bodofrev.cxx
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
1
2021-06-08T18:16:45.000Z
2021-06-08T18:16:45.000Z
/* */ /* ---------------------------------------------------------------------- * modBodyOfRevolution Module * ---------------------------------------------------------------------- * Description: * * BodyOfRevolution rotates "inside" and "outside" polylines around the * "z" axis to form a "solid" body of revolution. The routine creates * surfaces and the appropriate normals for the inside, outside, and * end caps (if required). The outside polyline line is required. The * routine also calculates the mass properties for the body. The body * is generated for 360 degrees of revolution only. * * Authors: * Brian Selle, Leon Thrane, Advanced Visual Systems Inc. * Documentation written by Ian Curington * * Revision: 10th February 2000 - Paul G. Lever, IAC * Converted to IAC format. * * ---------------------------------------------------------------------- * Note: * The gen.h include file is generated by Express when the module is * compiled. It avoids including "user.h" or "express.h" directly, so * that the module may be moved across the processes by changing the V * properties in the library. * ---------------------------------------------------------------------- */ #include "xp_comm_proj/bodofrev/gen.h" #include "meshUtils.h" #include "XP_OM_CALL.h" #include <string.h> #include <math.h> // #define DEBUG int BodyOfRevolution_BodyOfRevolutionCore::update(OMevent_mask , int seq_num) { int status; // Function return status // Check for valid active status if( (int)active == 0 ) { return( XP_SUCCESS ); } if ((int)num_thetas <1) { printf( "modBodyOfRevolution: num_thetas must be greater 0\n" ); return( XP_FAILURE ); } // Store the array sizes int num_points_outside = r_outside.ret_array_size(); int num_points_inside = r_inside.ret_array_size(); // Check for some data if( num_points_outside < 2 && num_thetas > 2 ) { return( XP_SUCCESS ); } // Initialize the mass property structure mass_props_t mass_props; memset( &mass_props, 0, sizeof(mass_props_t)); mass_props_t mass_props_semi; memset( &mass_props_semi, 0, sizeof(mass_props_t)); // Define and setup the poly data structure poly_data_t data; data.body_type = kSOLID; data.num_thetas = (int)num_thetas; data.num_points_outside = num_points_outside; data.num_points_inside = num_points_inside; data.r_outside = NULL; data.z_outside = NULL; data.r_inside = NULL; data.z_inside = NULL; data.gen_first_end_cap = 1; if( (int)nose_cap_on > 0 ) { data.gen_last_end_cap = 0; } else { data.gen_last_end_cap = 1; } // Check for valid input array sizes and set body type if( num_points_outside != z_outside.ret_array_size() ) { printf( "modBodyOfRevolution: Inconsistent outside array sizes\n" ); return( XP_FAILURE ); } if( num_points_inside > 1 ) { if( num_points_inside != z_inside.ret_array_size() ) { printf( "modBodyOfRevolution: Inconsistent inside array sizes\n" ); return( XP_FAILURE ); } data.body_type = kHOLLOW; } // Initialize the field OMobj_id field_id = (OMobj_id)out.obj_id(); FUNCCALLR( "Error initializing field", MU_init_field( field_id ) ); // Get the defining outside polyline arrays from Express OMCALLFR_NONNULLPTR( "Get r_outside array pointer", data.r_outside, (float *)r_outside. ret_array_ptr( OM_GET_ARRAY_RD ), MU_free_poly_data( &data ) ); OMCALLFR_NONNULLPTR( "Get z_outside array pointer", data.z_outside, (float *)z_outside. ret_array_ptr( OM_GET_ARRAY_RD ), MU_free_poly_data( &data ) ); // Insure that the z values are always increasing for( int i = 0; i < num_points_outside - 1; i++ ) { if( data.z_outside[i] > data.z_outside[i+1] ) { printf( "modBodyOfRevolution: z_outside values must by increasing\n" ); return( XP_FAILURE ); } } // Get the defining inside polyline arrays from Express if( data.body_type == kHOLLOW ) { OMCALLFR_NONNULLPTR( "Get r_inside array pointer", data.r_inside, (float *)r_inside. ret_array_ptr( OM_GET_ARRAY_RD ), MU_free_poly_data( &data ) ); OMCALLFR_NONNULLPTR( "Get z_inside array pointer", data.z_inside, (float *)z_inside. ret_array_ptr( OM_GET_ARRAY_RD ), MU_free_poly_data( &data ) ); // Insure that the z values are always increasing for( int i = 0; i < num_points_inside - 1; i++ ) { if( data.z_inside[i] > data.z_inside[i+1] ) { printf( "modBodyOfRevolution: z_inside values must by increasing\n" ); return( XP_FAILURE ); } } } // Create the surfaces FUNCCALLFR( "Create body of revolution", MU_gen_body_of_rev( field_id, &data ), MU_free_poly_data( &data ) ); // Set up the mass properties structure mass_props.density = (float)density; mass_props_semi.density = mass_props.density; // Calculate the mass properties FUNCCALLFR( "Calculate the mass properties", MU_mass_props_body_of_rev( &data, &mass_props ), MU_free_poly_data( &data ) ); // Check if we need to add a nose cap if( nose_cap_on > 0 ) { // Define and setup the semi data structure semi_data_t semi_data; semi_data.body_type = data.body_type; semi_data.gen_end_cap = 0; float theta = atan( (data.r_outside[data.num_points_outside-2] - data.r_outside[data.num_points_outside-1]) / (data.z_outside[data.num_points_outside-1] - data.z_outside[data.num_points_outside-2]) ); semi_data.r_outside = (data.r_outside[data.num_points_outside-1] / cos(theta) ); semi_data.half_angle = (PI / 2.0) - theta; semi_data.z_offset = data.z_outside[data.num_points_outside-1]; if( data.body_type == kHOLLOW ) { float delta = semi_data.r_outside * sin(theta); semi_data.r_inside = sqrt( delta*delta + data.r_inside[data.num_points_outside-1]* data.r_inside[data.num_points_outside-1] ); } semi_data.num_thetas = data.num_thetas; semi_data.num_phis = (semi_data.num_thetas * semi_data.half_angle / (2 * PI)); semi_data.num_phis=semi_data.num_phis?semi_data.num_phis:1; #ifdef DEBUG fprintf (stderr,"semi_data.num_thetas: %i\n",semi_data.num_thetas); fprintf (stderr,"semi_data.num_phis: %i\n",semi_data.num_phis); fflush(stderr); #endif // Create the surfaces FUNCCALLFR( "Create body of revolution", MU_gen_semi_sphere( field_id, &semi_data ), MU_free_poly_data( &data ) ); // Calculate the mass properties FUNCCALLFR( "Calculate the mass properties", MU_mass_props_semi_sphere( &semi_data, &mass_props_semi ), MU_free_poly_data( &data ) ); } // Set the mass properties in Express mass = mass_props.mass + mass_props_semi.mass; zcg = ( ( mass_props.zcg * mass_props.mass + mass_props_semi.zcg * mass_props_semi.mass ) / ( mass_props.mass + mass_props_semi.mass) ); izz = mass_props.izz + mass_props_semi.izz; // Clean up MU_free_poly_data( &data ); // Successful return return( XP_SUCCESS ); } /* end of file */
31.200855
77
0.642789
avs
35f2629681ce484d3e1f10a7707765a75376ea91
844
cpp
C++
electric-bill-management-system/menu_style.cpp
philong6297/electric-bill-management-system
b82d14dc22b8fd18dda7a79989785bc788f1370b
[ "MIT" ]
null
null
null
electric-bill-management-system/menu_style.cpp
philong6297/electric-bill-management-system
b82d14dc22b8fd18dda7a79989785bc788f1370b
[ "MIT" ]
null
null
null
electric-bill-management-system/menu_style.cpp
philong6297/electric-bill-management-system
b82d14dc22b8fd18dda7a79989785bc788f1370b
[ "MIT" ]
null
null
null
/* * This is a personal academic project. Dear PVS-Studio, please check it. * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com */ #include "menu_style.h" #include "menu.h" using menu::MenuState; using menu::MenuStyle; MenuStyle MenuStyle::GetStyle(const MenuState state) { using rang::fg; static constexpr auto focus = MenuStyle{fg::yellow}; static constexpr auto inactive = MenuStyle{fg::reset}; static constexpr auto select = MenuStyle{fg::blue}; MenuStyle result{}; switch (state) { case INACTIVE: result = inactive; break; case FOCUS: result = focus; break; case SELECTED: result = select; break; default: // do nothing break; } return result; } MenuStyle MenuStyle::GetResetStyle() { using rang::fg; static constexpr auto reset = MenuStyle{fg::reset}; return reset; }
22.810811
75
0.700237
philong6297
35fb3a5eecda8aa936f2db7728a5cb8c716c7df7
6,786
cpp
C++
hardware_interface/test/test_register_joints.cpp
mattnds/ros2_control
ddf69353184165485712fa36fec485d1c8404a11
[ "Apache-2.0" ]
null
null
null
hardware_interface/test/test_register_joints.cpp
mattnds/ros2_control
ddf69353184165485712fa36fec485d1c8404a11
[ "Apache-2.0" ]
null
null
null
hardware_interface/test/test_register_joints.cpp
mattnds/ros2_control
ddf69353184165485712fa36fec485d1c8404a11
[ "Apache-2.0" ]
null
null
null
// Copyright 2020 PAL Robotics S.L. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <gmock/gmock.h> #include <string> #include <vector> #include "hardware_interface/robot_hardware.hpp" namespace hw = hardware_interface; using testing::SizeIs; using testing::IsEmpty; using testing::Each; using testing::NotNull; using testing::UnorderedElementsAre; using testing::ElementsAre; namespace { constexpr auto JOINT_NAME = "joints_1"; constexpr auto JOINT2_NAME = "neck_tilt_motor"; constexpr auto FOO_INTERFACE = "FooInterface"; constexpr auto BAR_INTERFACE = "BarInterface"; } // namespace class TestJoints : public testing::Test { class DummyRobotHardware : public hw::RobotHardware { hw::return_type init() override { return hw::return_type::OK; } hw::return_type read() override { return hw::return_type::OK; } hw::return_type write() override { return hw::return_type::OK; } }; public: TestJoints() { } protected: DummyRobotHardware robot_hw_; }; TEST_F(TestJoints, no_jointss_registered_return_empty_on_all_fronts) { EXPECT_THAT(robot_hw_.get_registered_joints(), IsEmpty()); EXPECT_THAT(robot_hw_.get_registered_joint_names(), IsEmpty()); hw::JointHandle handle{"", ""}; EXPECT_EQ(hw::return_type::ERROR, robot_hw_.get_joint_handle(handle)); } TEST_F(TestJoints, can_register_joint_interfaces) { EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); } TEST_F(TestJoints, can_not_double_register_joint_interfaces) { EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); EXPECT_EQ(hw::return_type::ERROR, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); EXPECT_EQ(hw::return_type::ERROR, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); } TEST_F(TestJoints, can_not_register_with_empty_fields) { EXPECT_EQ(hw::return_type::ERROR, robot_hw_.register_joint("", "")); EXPECT_EQ(hw::return_type::ERROR, robot_hw_.register_joint(JOINT_NAME, "")); EXPECT_EQ(hw::return_type::ERROR, robot_hw_.register_joint("", FOO_INTERFACE)); } TEST_F(TestJoints, can_not_get_non_registered_jointss_or_interfaces) { EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT2_NAME, BAR_INTERFACE)); hw::JointHandle handle1{JOINT_NAME, BAR_INTERFACE}; EXPECT_EQ(hw::return_type::ERROR, robot_hw_.get_joint_handle(handle1)); hw::JointHandle handle2{JOINT2_NAME, FOO_INTERFACE}; EXPECT_EQ(hw::return_type::ERROR, robot_hw_.get_joint_handle(handle2)); } TEST_F(TestJoints, can_get_registered_joints) { EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); EXPECT_THAT(robot_hw_.get_registered_joint_names(), ElementsAre(JOINT_NAME)); const auto registered_jointss = robot_hw_.get_registered_joints(); EXPECT_THAT(registered_jointss, SizeIs(1)); const auto & joints_handle = registered_jointss[0]; EXPECT_EQ(joints_handle.get_name(), JOINT_NAME); EXPECT_EQ(joints_handle.get_interface_name(), FOO_INTERFACE); EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); EXPECT_THAT(robot_hw_.get_registered_joint_names(), ElementsAre(JOINT_NAME)); EXPECT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT2_NAME, FOO_INTERFACE)); EXPECT_THAT( robot_hw_.get_registered_joint_names(), UnorderedElementsAre(JOINT_NAME, JOINT2_NAME)); EXPECT_THAT( robot_hw_.get_registered_joint_interface_names(JOINT_NAME), UnorderedElementsAre(FOO_INTERFACE, BAR_INTERFACE)); EXPECT_THAT( robot_hw_.get_registered_joint_interface_names(JOINT2_NAME), UnorderedElementsAre(FOO_INTERFACE)); std::vector<hw::JointHandle> handles = {{JOINT_NAME, FOO_INTERFACE}, {JOINT_NAME, BAR_INTERFACE}, {JOINT2_NAME, FOO_INTERFACE}}; for (auto & handle : handles) { EXPECT_EQ(hw::return_type::OK, robot_hw_.get_joint_handle(handle)); } } TEST_F(TestJoints, set_get_works_on_registered_jointss) { ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT2_NAME, FOO_INTERFACE)); auto joints_handles = robot_hw_.get_registered_joints(); for (auto & handle : joints_handles) { const auto new_value = handle.get_value() + 1.337; EXPECT_NO_THROW(handle.set_value(new_value)); EXPECT_DOUBLE_EQ(handle.get_value(), new_value); } std::vector<hw::JointHandle> handles = {{JOINT_NAME, FOO_INTERFACE}, {JOINT_NAME, BAR_INTERFACE}, {JOINT2_NAME, FOO_INTERFACE}}; for (auto & handle : handles) { EXPECT_ANY_THROW(handle.get_value()); EXPECT_ANY_THROW(handle.set_value(0.0)); EXPECT_EQ(hw::return_type::OK, robot_hw_.get_joint_handle(handle)); const auto new_value = handle.get_value() + 1.337; EXPECT_NO_THROW(handle.set_value(new_value)); EXPECT_DOUBLE_EQ(handle.get_value(), new_value); } } TEST_F(TestJoints, can_get_registered_joints_of_interface) { ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, FOO_INTERFACE)); ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT_NAME, BAR_INTERFACE)); ASSERT_EQ(hw::return_type::OK, robot_hw_.register_joint(JOINT2_NAME, FOO_INTERFACE)); std::vector<hw::JointHandle> handles1; ASSERT_EQ(hw::return_type::OK, robot_hw_.get_joint_handles(handles1, FOO_INTERFACE)); ASSERT_EQ(handles1.size(), 2ul); for (const auto & handle : handles1) { ASSERT_EQ(handle.get_interface_name(), FOO_INTERFACE); } std::vector<hw::JointHandle> handles2; ASSERT_EQ(hw::return_type::OK, robot_hw_.get_joint_handles(handles2, BAR_INTERFACE)); ASSERT_EQ(handles2.size(), 1ul); for (const auto & handle : handles2) { ASSERT_EQ(handle.get_interface_name(), BAR_INTERFACE); } std::vector<hw::JointHandle> handles3; ASSERT_EQ(hw::return_type::OK, robot_hw_.get_joint_handles(handles3, "NoInterface")); ASSERT_TRUE(handles3.empty()); }
35.34375
89
0.765105
mattnds
35ffaadfbc5eefecb22b43b443697c55b5b3e47a
3,785
hpp
C++
iRODS/clients/fuse/include/iFuse.Lib.RodsClientAPI.hpp
cyverse/irods
4ea33f5f0e220b6e5d257a49b45e10d07ec02d75
[ "BSD-3-Clause" ]
null
null
null
iRODS/clients/fuse/include/iFuse.Lib.RodsClientAPI.hpp
cyverse/irods
4ea33f5f0e220b6e5d257a49b45e10d07ec02d75
[ "BSD-3-Clause" ]
7
2019-12-02T17:55:49.000Z
2019-12-02T17:55:59.000Z
iRODS/clients/fuse/include/iFuse.Lib.RodsClientAPI.hpp
benlazarine/irods
83f3c4a6f8f7fc6422a1e73a297b97796a961322
[ "BSD-3-Clause" ]
1
2019-12-02T05:44:10.000Z
2019-12-02T05:44:10.000Z
/*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /*** This code is rewritten by Illyoung Choi (iychoi@email.arizona.edu) *** *** funded by iPlantCollaborative (www.iplantcollaborative.org). ***/ #ifndef IFUSE_LIB_RODSCLIENTAPI_HPP #define IFUSE_LIB_RODSCLIENTAPI_HPP #include <pthread.h> #include "rodsClient.h" #include "iFuse.Lib.Util.hpp" #define IFUSE_RODSCLIENTAPI_TIMEOUT_SEC (30) //#define IFUSE_RODSCLIENTAPI_LOG_PRINT_TIME //#define IFUSE_RODSCLIENTAPI_LOG_OUT_TO_FILE #define IFUSE_RODSCLIENTAPI_LOG_OUT_FILE_PATH "/tmp/irods_debug.out" void iFuseRodsClientInit(); void iFuseRodsClientDestroy(); int iFuseRodsClientReadMsgError(int status); #ifdef IFUSE_RODSCLIENTAPI_LOG_OUT_TO_FILE # define iFuseRodsClientLogBase iFuseRodsClientLogToFile # define iFuseRodsClientLogErrorBase iFuseRodsClientLogErrorToFile #else # define iFuseRodsClientLogBase rodsLog # define iFuseRodsClientLogErrorBase rodsLogError #endif // IFUSE_RODSCLIENTAPI_LOG_OUT_TO_FILE #ifdef IFUSE_RODSCLIENTAPI_LOG_PRINT_TIME # define iFuseRodsClientLog \ { \ char logtimes[100]; \ iFuseLibGetStrCurrentTime(logtimes); \ iFuseRodsClientLogBase(LOG_DEBUG, "%s", logtimes); \ } \ iFuseRodsClientLogBase #else # define iFuseRodsClientLog iFuseRodsClientLogBase #endif // IFUSE_RODSCLIENTAPI_LOG_PRINT_TIME #ifdef IFUSE_RODSCLIENTAPI_LOG_PRINT_TIME # define iFuseRodsClientLogError \ { \ char logtimes[100]; \ iFuseLibGetStrCurrentTime(logtimes); \ iFuseRodsClientLogBase(LOG_DEBUG, "%s", logtimes); \ } \ iFuseRodsClientLogErrorBase #else # define iFuseRodsClientLogError iFuseRodsClientLogErrorBase #endif // IFUSE_RODSCLIENTAPI_LOG_PRINT_TIME rcComm_t *iFuseRodsClientConnect(const char *rodsHost, int rodsPort, const char *userName, const char *rodsZone, int reconnFlag, rErrMsg_t *errMsg); int iFuseRodsClientLogin(rcComm_t *conn); int iFuseRodsClientDisconnect(rcComm_t *conn); int iFuseRodsClientMakeRodsPath(const char *path, char *iRodsPath); int iFuseRodsClientDataObjOpen(rcComm_t *conn, dataObjInp_t *dataObjInp); int iFuseRodsClientDataObjClose(rcComm_t *conn, openedDataObjInp_t *dataObjCloseInp); int iFuseRodsClientOpenCollection( rcComm_t *conn, char *collection, int flag, collHandle_t *collHandle ); int iFuseRodsClientCloseCollection(collHandle_t *collHandle); int iFuseRodsClientObjStat(rcComm_t *conn, dataObjInp_t *dataObjInp, rodsObjStat_t **rodsObjStatOut); int iFuseRodsClientDataObjLseek(rcComm_t *conn, openedDataObjInp_t *dataObjLseekInp, fileLseekOut_t **dataObjLseekOut); int iFuseRodsClientDataObjRead(rcComm_t *conn, openedDataObjInp_t *dataObjReadInp, bytesBuf_t *dataObjReadOutBBuf); int iFuseRodsClientDataObjWrite(rcComm_t *conn, openedDataObjInp_t *dataObjWriteInp, bytesBuf_t *dataObjWriteInpBBuf); int iFuseRodsClientDataObjCreate(rcComm_t *conn, dataObjInp_t *dataObjInp); int iFuseRodsClientDataObjUnlink(rcComm_t *conn, dataObjInp_t *dataObjUnlinkInp); int iFuseRodsClientReadCollection(rcComm_t *conn, collHandle_t *collHandle, collEnt_t *collEnt); int iFuseRodsClientCollCreate(rcComm_t *conn, collInp_t *collCreateInp); int iFuseRodsClientRmColl(rcComm_t *conn, collInp_t *rmCollInp, int vFlag); int iFuseRodsClientDataObjRename(rcComm_t *conn, dataObjCopyInp_t *dataObjRenameInp); int iFuseRodsClientDataObjTruncate(rcComm_t *conn, dataObjInp_t *dataObjInp); int iFuseRodsClientModDataObjMeta(rcComm_t *conn, modDataObjMeta_t *modDataObjMetaInp); void iFuseRodsClientLogToFile(int level, const char *formatStr, ...); void iFuseRodsClientLogErrorToFile(int level, int errCode, char *formatStr, ...); #endif /* IFUSE_LIB_RODSCLIENTAPI_HPP */
45.059524
148
0.808454
cyverse
c4014d9f0cfb8134b2679d2643772b51d9152aa9
1,058
cpp
C++
firmware/src/utils.cpp
chientung/smartplug
3247b15f4c410f0d9d0c4904277ff428485ebbf0
[ "MIT" ]
27
2018-08-28T12:37:22.000Z
2022-03-11T19:39:32.000Z
firmware/src/utils.cpp
chientung/smartplug
3247b15f4c410f0d9d0c4904277ff428485ebbf0
[ "MIT" ]
33
2018-09-10T07:26:21.000Z
2022-02-26T17:53:24.000Z
firmware/src/utils.cpp
chientung/smartplug
3247b15f4c410f0d9d0c4904277ff428485ebbf0
[ "MIT" ]
4
2019-02-01T22:38:52.000Z
2021-05-09T17:23:57.000Z
///////////////////////////////////////////////////////////////////////////// /** @file General utility functions \copyright Copyright (c) 2018 Chris Byrne. All rights reserved. Licensed under the MIT License. Refer to LICENSE file in the project root. */ ///////////////////////////////////////////////////////////////////////////// //- includes #include "utils.h" #include <IPAddress.h> using namespace utils; ///////////////////////////////////////////////////////////////////////////// /// check if an IPAddress is a valid subnet mask /// @returns true if valid bool utils::validSubnet(const IPAddress& subnet) { // convert to Little Endian so we can bit flip // 255.255.0.0 => 0xFFFF0000 uint32_t s = ( subnet[3] | (subnet[2] << 8) | (subnet[1] << 16) | (subnet[0] << 24) ); // ~ => 0x0000FFFF s = ~s; if (0 == s) return false; // +1 => 0x00010000 s += 1; // http://www.graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 return (s && !(s & (s - 1))); }
27.842105
82
0.469754
chientung
c403667bf0155d9a3eb880e82c6e02def7413d5c
3,230
cc
C++
src/cpu/thread_context.cc
volnxebec/CC_Fused
e2b805e3475bd275409379c41eaeeb1a565cbdef
[ "BSD-3-Clause" ]
11
2015-03-21T13:35:06.000Z
2022-01-27T07:31:52.000Z
src/cpu/thread_context.cc
volnxebec/CC_Fused
e2b805e3475bd275409379c41eaeeb1a565cbdef
[ "BSD-3-Clause" ]
4
2017-02-14T06:33:15.000Z
2017-05-09T13:14:15.000Z
src/cpu/thread_context.cc
volnxebec/CC_Fused
e2b805e3475bd275409379c41eaeeb1a565cbdef
[ "BSD-3-Clause" ]
4
2015-03-21T13:35:24.000Z
2020-06-30T02:09:36.000Z
/* * Copyright (c) 2006 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Kevin Lim */ #include "base/misc.hh" #include "base/trace.hh" #include "config/the_isa.hh" #include "cpu/thread_context.hh" #include "debug/Context.hh" void ThreadContext::compare(ThreadContext *one, ThreadContext *two) { DPRINTF(Context, "Comparing thread contexts\n"); // First loop through the integer registers. for (int i = 0; i < TheISA::NumIntRegs; ++i) { TheISA::IntReg t1 = one->readIntReg(i); TheISA::IntReg t2 = two->readIntReg(i); if (t1 != t2) panic("Int reg idx %d doesn't match, one: %#x, two: %#x", i, t1, t2); } // Then loop through the floating point registers. for (int i = 0; i < TheISA::NumFloatRegs; ++i) { TheISA::FloatRegBits t1 = one->readFloatRegBits(i); TheISA::FloatRegBits t2 = two->readFloatRegBits(i); if (t1 != t2) panic("Float reg idx %d doesn't match, one: %#x, two: %#x", i, t1, t2); } for (int i = 0; i < TheISA::NumMiscRegs; ++i) { TheISA::MiscReg t1 = one->readMiscRegNoEffect(i); TheISA::MiscReg t2 = two->readMiscRegNoEffect(i); if (t1 != t2) panic("Misc reg idx %d doesn't match, one: %#x, two: %#x", i, t1, t2); } if (!(one->pcState() == two->pcState())) panic("PC state doesn't match."); int id1 = one->cpuId(); int id2 = two->cpuId(); if (id1 != id2) panic("CPU ids don't match, one: %d, two: %d", id1, id2); id1 = one->contextId(); id2 = two->contextId(); if (id1 != id2) panic("Context ids don't match, one: %d, two: %d", id1, id2); }
39.876543
73
0.663467
volnxebec
c407ddf9168365e466d7bfc24b52f65edbaf0dac
3,166
hpp
C++
src/plugins/openmpt/libopenmpt/libopenmpt/libopenmpt_ext_impl.hpp
frranck/HippoPlayer
ede5c13db160b215018ca24216131414e06d5f1f
[ "Apache-2.0", "MIT" ]
1
2021-07-17T17:14:30.000Z
2021-07-17T17:14:30.000Z
src/plugins/openmpt/libopenmpt/libopenmpt/libopenmpt_ext_impl.hpp
frranck/HippoPlayer
ede5c13db160b215018ca24216131414e06d5f1f
[ "Apache-2.0", "MIT" ]
null
null
null
src/plugins/openmpt/libopenmpt/libopenmpt/libopenmpt_ext_impl.hpp
frranck/HippoPlayer
ede5c13db160b215018ca24216131414e06d5f1f
[ "Apache-2.0", "MIT" ]
null
null
null
/* * libopenmpt_ext_impl.hpp * ----------------------- * Purpose: libopenmpt extensions - implementation header * Notes : * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ #ifndef LIBOPENMPT_EXT_IMPL_HPP #define LIBOPENMPT_EXT_IMPL_HPP #include "libopenmpt_internal.h" #include "libopenmpt_impl.hpp" #include "libopenmpt_ext.hpp" using namespace OpenMPT; namespace openmpt { class module_ext_impl : public module_impl , public ext::pattern_vis , public ext::interactive /* add stuff here */ { public: module_ext_impl( callback_stream_wrapper stream, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( std::istream & stream, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( const std::vector<std::uint8_t> & data, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( const std::vector<char> & data, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( const std::uint8_t * data, std::size_t size, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( const char * data, std::size_t size, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); module_ext_impl( const void * data, std::size_t size, std::unique_ptr<log_interface> log, const std::map< std::string, std::string > & ctls ); private: /* add stuff here */ private: void ctor(); public: ~module_ext_impl(); public: void * get_interface( const std::string & interface_id ); // pattern_vis virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const; virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const; // interactive virtual void set_current_speed( std::int32_t speed ); virtual void set_current_tempo( std::int32_t tempo ); virtual void set_tempo_factor( double factor ); virtual double get_tempo_factor( ) const; virtual void set_pitch_factor( double factor ); virtual double get_pitch_factor( ) const; virtual void set_global_volume( double volume ); virtual double get_global_volume( ) const; virtual void set_channel_volume( std::int32_t channel, double volume ); virtual double get_channel_volume( std::int32_t channel ) const; virtual void set_channel_mute_status( std::int32_t channel, bool mute ); virtual bool get_channel_mute_status( std::int32_t channel ) const; virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ); virtual bool get_instrument_mute_status( std::int32_t instrument ) const; virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ); virtual void stop_note( std::int32_t channel ); /* add stuff here */ }; // class module_ext_impl } // namespace openmpt #endif // LIBOPENMPT_EXT_IMPL_HPP
28.017699
151
0.742262
frranck
c4080a92d7d60b2f5510252bcbbc1b4e6a6ec979
9,166
cpp
C++
src/lowlevel/gdeflateBatch.cpp
tabtre/nvcomp
a6e4e64a177e07cd2e5c8c5e07bb66ffefceae84
[ "BSD-3-Clause" ]
null
null
null
src/lowlevel/gdeflateBatch.cpp
tabtre/nvcomp
a6e4e64a177e07cd2e5c8c5e07bb66ffefceae84
[ "BSD-3-Clause" ]
null
null
null
src/lowlevel/gdeflateBatch.cpp
tabtre/nvcomp
a6e4e64a177e07cd2e5c8c5e07bb66ffefceae84
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of NVIDIA CORPORATION nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "nvcomp/gdeflate.h" #include "Check.h" #include "CudaUtils.h" #include "common.h" #include "nvcomp.h" #include "nvcomp.hpp" #include "type_macros.h" #include <cassert> #include <iostream> #include <list> #include <map> #include <mutex> #include <sstream> #include <vector> #ifdef ENABLE_GDEFLATE #include "gdeflate.h" #include "gdeflateKernels.h" #endif using namespace nvcomp; #ifdef ENABLE_GDEFLATE gdeflate::gdeflate_compression_algo getGdeflateEnumFromFormatOpts(nvcompBatchedGdeflateOpts_t format_opts) { gdeflate::gdeflate_compression_algo algo; switch(format_opts.algo) { case (0) : algo = gdeflate::HIGH_THROUGHPUT; break; case(1) : algo = gdeflate::HIGH_COMPRESSION; break; case(2) : algo = gdeflate::ENTROPY_ONLY; break; default : throw std::invalid_argument("Invalid format_opts.algo value (not 0, 1 or 2)"); } return algo; } #endif nvcompStatus_t nvcompBatchedGdeflateDecompressGetTempSize( const size_t num_chunks, const size_t max_uncompressed_chunk_size, size_t* const temp_bytes) { #ifdef ENABLE_GDEFLATE CHECK_NOT_NULL(temp_bytes); try { gdeflate::decompressGetTempSize(num_chunks, max_uncompressed_chunk_size, temp_bytes); } catch (const std::exception& e) { return Check::exception_to_error( e, "nvcompBatchedGdeflateDecompressGetTempSize()"); } return nvcompSuccess; #else (void)num_chunks; (void)max_uncompressed_chunk_size; (void)temp_bytes; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif } nvcompStatus_t nvcompBatchedGdeflateDecompressAsync( const void* const* device_compressed_ptrs, const size_t* device_compressed_bytes, const size_t* device_uncompressed_bytes, size_t* device_actual_uncompressed_bytes, size_t batch_size, void* const device_temp_ptr, size_t temp_bytes, void* const* device_uncompressed_ptrs, nvcompStatus_t* device_status_ptrs, cudaStream_t stream) { #ifdef ENABLE_GDEFLATE // NOTE: if we start using `max_uncompressed_chunk_bytes`, we need to check // to make sure it is not zero, as we have notified users to supply zero if // they are not finding the maximum size. try { // Use device_status_ptrs as temp space to store gdeflate statuses static_assert(sizeof(nvcompStatus_t) == sizeof(gdeflate::gdeflateStatus_t), "Mismatched sizes of nvcompStatus_t and gdeflateStatus_t"); auto device_statuses = reinterpret_cast<gdeflate::gdeflateStatus_t*>(device_status_ptrs); // Run the decompression kernel gdeflate::decompressAsync(device_compressed_ptrs, device_compressed_bytes, device_uncompressed_bytes, device_actual_uncompressed_bytes, 0, batch_size, device_temp_ptr, temp_bytes, device_uncompressed_ptrs, device_statuses, stream); // Launch a kernel to convert the output statuses if(device_status_ptrs) convertGdeflateOutputStatuses(device_status_ptrs, batch_size, stream); } catch (const std::exception& e) { return Check::exception_to_error(e, "nvcompBatchedGdeflateDecompressAsync()"); } return nvcompSuccess; #else (void)device_compressed_ptrs; (void)device_compressed_bytes; (void)device_uncompressed_bytes; (void)device_actual_uncompressed_bytes; (void)batch_size; (void)device_temp_ptr; (void)temp_bytes; (void)device_uncompressed_ptrs; (void)device_status_ptrs; (void)stream; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif } nvcompStatus_t nvcompBatchedGdeflateGetDecompressSizeAsync( const void* const* device_compressed_ptrs, const size_t* device_compressed_bytes, size_t* device_uncompressed_bytes, size_t batch_size, cudaStream_t stream) { #ifdef ENABLE_GDEFLATE try { gdeflate::getDecompressSizeAsync(device_compressed_ptrs, device_compressed_bytes, device_uncompressed_bytes, batch_size, stream); } catch (const std::exception& e) { return Check::exception_to_error(e, "nvcompBatchedGdeflateDecompressAsync()"); } return nvcompSuccess; #else (void)device_compressed_ptrs; (void)device_compressed_bytes; (void)device_uncompressed_bytes; (void)batch_size; (void)stream; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif } nvcompStatus_t nvcompBatchedGdeflateCompressGetTempSize( const size_t batch_size, const size_t max_chunk_size, nvcompBatchedGdeflateOpts_t format_opts, size_t* const temp_bytes) { #ifdef ENABLE_GDEFLATE CHECK_NOT_NULL(temp_bytes); try { gdeflate::gdeflate_compression_algo algo = getGdeflateEnumFromFormatOpts(format_opts); gdeflate::compressGetTempSize(batch_size, max_chunk_size, temp_bytes, algo); } catch (const std::exception& e) { return Check::exception_to_error( e, "nvcompBatchedGdeflateCompressGetTempSize()"); } return nvcompSuccess; #else (void)batch_size; (void)max_chunk_size; (void)format_opts; (void)temp_bytes; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif } nvcompStatus_t nvcompBatchedGdeflateCompressGetMaxOutputChunkSize( size_t max_chunk_size, nvcompBatchedGdeflateOpts_t /* format_opts */, size_t* max_compressed_size) { #ifdef ENABLE_GDEFLATE CHECK_NOT_NULL(max_compressed_size); try { gdeflate::compressGetMaxOutputChunkSize(max_chunk_size, max_compressed_size); } catch (const std::exception& e) { return Check::exception_to_error( e, "nvcompBatchedGdeflateCompressGetOutputSize()"); } return nvcompSuccess; #else (void)max_chunk_size; (void)max_compressed_size; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif } nvcompStatus_t nvcompBatchedGdeflateCompressAsync( const void* const* const device_in_ptrs, const size_t* const device_in_bytes, const size_t max_uncompressed_chunk_size, const size_t batch_size, void* const temp_ptr, const size_t temp_bytes, void* const* const device_out_ptrs, size_t* const device_out_bytes, nvcompBatchedGdeflateOpts_t format_opts, cudaStream_t stream) { #ifdef ENABLE_GDEFLATE try { gdeflate::gdeflate_compression_algo algo = getGdeflateEnumFromFormatOpts(format_opts); gdeflate::compressAsync(device_in_ptrs, device_in_bytes, max_uncompressed_chunk_size, batch_size, temp_ptr, temp_bytes, device_out_ptrs, device_out_bytes, algo, stream); } catch (const std::exception& e) { return Check::exception_to_error(e, "nvcompBatchedGdeflateCompressAsync()"); } return nvcompSuccess; #else (void)device_in_ptrs; (void)device_in_bytes; (void)max_uncompressed_chunk_size; (void)batch_size; (void)temp_ptr; (void)temp_bytes; (void)device_out_ptrs; (void)device_out_bytes; (void)format_opts; (void)stream; std::cerr << "ERROR: nvcomp configured without gdeflate support\n" << "Please check the README for configuration instructions" << std::endl; return nvcompErrorNotSupported; #endif }
33.575092
108
0.755619
tabtre
c4091e6ab84309218efce830fe579ea62f9b0cf6
1,613
cc
C++
modules/ugdk-core/src/input/joystickstatus.cc
uspgamedev/ugdk
95885a70df282a8e8e6e5c72b28a7f2f21bf7e99
[ "Zlib" ]
11
2015-03-06T13:14:32.000Z
2020-06-09T23:34:28.000Z
modules/ugdk-core/src/input/joystickstatus.cc
uspgamedev/ugdk
95885a70df282a8e8e6e5c72b28a7f2f21bf7e99
[ "Zlib" ]
62
2015-01-04T05:47:40.000Z
2018-06-15T17:00:25.000Z
modules/ugdk-core/src/input/joystickstatus.cc
uspgamedev/ugdk
95885a70df282a8e8e6e5c72b28a7f2f21bf7e99
[ "Zlib" ]
2
2017-04-05T20:35:49.000Z
2017-07-30T03:44:02.000Z
#include <ugdk/input/joystickstatus.h> #include "SDL_joystick.h" namespace ugdk { namespace input { AxisStatus::AxisStatus(int16 raw) : raw_(raw) {} int16 AxisStatus::raw() const { return raw_; } int16 AxisStatus::MaximumValue() const { return 32767; } int16 AxisStatus::MinimumValue() const { return -32768; } double AxisStatus::Percentage() const { if (raw_ < 0) { return -raw_ / static_cast<double>(MinimumValue()); } else { return raw_ / static_cast<double>(MaximumValue()); } } HatStatus::HatStatus(int raw) : raw_(raw) {} int HatStatus::raw() const { return raw_; } bool HatStatus::IsCentered() const { return raw_ == SDL_HAT_CENTERED; } bool HatStatus::IsUp() const { return raw_ == SDL_HAT_UP; } bool HatStatus::IsRight() const { return raw_ == SDL_HAT_RIGHT; } bool HatStatus::IsDown() const { return raw_ == SDL_HAT_DOWN; } bool HatStatus::IsLeft() const { return raw_ == SDL_HAT_LEFT; } bool HatStatus::IsRightUp() const { return raw_ == SDL_HAT_RIGHTUP; } bool HatStatus::IsRightDown() const { return raw_ == SDL_HAT_RIGHTDOWN; } bool HatStatus::IsLeftUp() const { return raw_ == SDL_HAT_LEFTUP; } bool HatStatus::IsLeftDown() const { return raw_ == SDL_HAT_LEFTDOWN; } bool HatStatus::HasUp() const { return (raw_ & SDL_HAT_UP) != 0; } bool HatStatus::HasRight() const { return (raw_ & SDL_HAT_RIGHT) != 0; } bool HatStatus::HasDown() const { return (raw_ & SDL_HAT_DOWN) != 0; } bool HatStatus::HasLeft() const { return (raw_ & SDL_HAT_LEFT) != 0; } } // namespace input } // namespace ugdk
20.417722
59
0.66832
uspgamedev
c40d68f10cac300def7761a90a477fff5a24448d
860
hpp
C++
impl/jamtemplate/sdl/sound.hpp
runvs/Gemga
91cd5d6d60ae8369a5a5674efebc6eb84c510a10
[ "CC0-1.0" ]
6
2021-09-05T08:31:36.000Z
2021-12-09T21:14:37.000Z
impl/jamtemplate/sdl/sound.hpp
runvs/Gemga
91cd5d6d60ae8369a5a5674efebc6eb84c510a10
[ "CC0-1.0" ]
30
2021-05-19T15:33:03.000Z
2022-03-30T19:26:37.000Z
impl/jamtemplate/sdl/sound.hpp
runvs/Gemga
91cd5d6d60ae8369a5a5674efebc6eb84c510a10
[ "CC0-1.0" ]
3
2021-05-23T16:06:01.000Z
2021-10-01T01:17:08.000Z
#ifndef GUARD_JAMTEMPLATE_SFML_SOUND_GUARD_HPP_12345 #define GUARD_JAMTEMPLATE_SFML_SOUND_GUARD_HPP_12345 #include "sound_base.hpp" #include <SDL2/SDL.h> #include <SDL2/SDL_mixer.h> #include <memory> namespace jt { class Sound : public SoundBase { private: std::shared_ptr<Mix_Chunk> m_wave { nullptr }; bool m_playing { false }; bool m_loop { false }; int m_channel { -1 }; float m_volume { 100.0f }; void doLoad(std::string const& fileName) override; bool doIsPlaying() const override; void doPlay() override; void doStop() override; float doGetVolume() const override; void doSetVolume(float newVolume) override; void doSetLoop(bool doLoop) override; bool doGetLoop(void) override; float doGetDuration() const override; float doGetPosition() const override; }; } // namespace jt #endif
22.631579
54
0.715116
runvs
c40f50444fab7caa02ac7c28f62525fcfb8692e9
2,031
hpp
C++
src/bootstrap/source/translation_unit.hpp
wexaris/ivy
9b752661c7db69296627307acc73978052c93eb4
[ "Apache-2.0" ]
2
2019-06-25T14:29:00.000Z
2019-07-22T21:58:41.000Z
src/bootstrap/source/translation_unit.hpp
wexaris/ivy
9b752661c7db69296627307acc73978052c93eb4
[ "Apache-2.0" ]
null
null
null
src/bootstrap/source/translation_unit.hpp
wexaris/ivy
9b752661c7db69296627307acc73978052c93eb4
[ "Apache-2.0" ]
null
null
null
#pragma once #include "errors/handler.hpp" #include <string> #include <vector> /* An item containing source code, usually a file. * Stores the path to the file of origin and the source. * Has a position inside the larger SourceMap. */ class TranslationUnit { private: /* The Session's ErrorHandler */ ErrorHandler* handler; /* The path to the file from which the source code has been read */ const std::string path; /* The full source code from a file */ const std::string src; /* This Translation Unit's start position in the CodeMap */ size_t start_position; /* The positions of all of the newline markers in the source code. * Used for getting positions quickly. */ std::vector<size_t> newlines; public: explicit TranslationUnit(ErrorHandler& handler, const std::string& src) : handler(&handler), src(src) {} TranslationUnit(ErrorHandler& handler, const std::string& path, const std::string& src, size_t start_pos) : handler(&handler), path(path), src(src), start_position(start_pos) {} std::string this_source_line(size_t index) const; /* Returns the line of source that the index was from. * Beginning and ending whitespace is removed. */ TextPos pos_from_index(size_t index) const; /* Returns the line of source that the index was from. * If format is enabled beginning and ending whitespace is removed and * Tab characters are replaced by four spaces. */ std::string get_line(size_t ln, bool fmt) const; /* Save a newline position. * Getting positions from an index relies on this. */ void save_newline(size_t index) { newlines.push_back(index); } /* Returns the path to Translation Unit. */ inline const std::string& filepath() const { return path; } /* A view into the file's source code. */ inline std::string_view source() const { return src; } /* Start position in the CodeMap. */ inline size_t start_pos() const { return start_position; } /* End position in the CodeMap. */ inline size_t end_pos() const { return start_position + src.length(); } };
33.85
107
0.721812
wexaris
c4123452b53dd65610b21ba3bce0692610799182
432
cpp
C++
Source/FSD/Private/AssaultRifle.cpp
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
8
2021-07-10T20:06:05.000Z
2022-03-04T19:03:50.000Z
Source/FSD/Private/AssaultRifle.cpp
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
9
2022-01-13T20:49:44.000Z
2022-03-27T22:56:48.000Z
Source/FSD/Private/AssaultRifle.cpp
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
2
2021-07-10T20:05:42.000Z
2022-03-14T17:05:35.000Z
#include "AssaultRifle.h" class AActor; class UFSDPhysicalMaterial; void AAssaultRifle::OnTimerElapsed() { } void AAssaultRifle::OnEnemyKilled(AActor* Target, UFSDPhysicalMaterial* PhysMat) { } void AAssaultRifle::Client_ResetAccuracy_Implementation() { } AAssaultRifle::AAssaultRifle() { this->KillsResetAccuracyDuration = 0.00f; this->KillsTriggersStatusEffect = false; this->KillTriggeredStatusEffect = NULL; }
20.571429
82
0.775463
Dr-Turtle
c41284d67068aabd3f56aaba34f0f2b1f7b9966a
9,031
cpp
C++
src/framework/shared/core/fxmemoryobject.cpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
994
2015-03-18T21:37:07.000Z
2019-04-26T04:04:14.000Z
src/framework/shared/core/fxmemoryobject.cpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
13
2019-06-13T15:58:03.000Z
2022-02-18T22:53:35.000Z
src/framework/shared/core/fxmemoryobject.cpp
IT-Enthusiast-Nepal/Windows-Driver-Frameworks
bfee6134f30f92a90dbf96e98d54582ecb993996
[ "MIT" ]
350
2015-03-19T04:29:46.000Z
2019-05-05T23:26:50.000Z
/*++ Copyright (c) Microsoft Corporation Module Name: FxMemoryObject.cpp Abstract: This module implements a frameworks managed FxMemoryObject Author: Environment: kernel mode only Revision History: --*/ #include "coreprivshared.hpp" extern "C" { #include "FxMemoryObject.tmh" } FxMemoryObject::FxMemoryObject( __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in size_t BufferSize ) : // intentionally do not pass IFX_TYPE_MEMORY to the base constructor // because we need to pass the interface back when converting from // handle to object and that will require a different this pointer offset // which will be handled by QueryInterface FxObject(FX_TYPE_OBJECT, ObjectSize, FxDriverGlobals), m_BufferSize(BufferSize) { // // Since we are passing the generic object type FX_TYPE_OBJECT to FxObject, // we need to figure out on our own if need to allocate a tag tracker or not. // if (IsDebug()) { AllocateTagTracker(IFX_TYPE_MEMORY); } } _Must_inspect_result_ NTSTATUS FxMemoryObject::_Create( __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject** Object ) { // // If the buffer is // a) a PAGE or larger // b) we are debugging allocations // c) less then a page and pageable // // separate the object from its memory so that we can assure // // 1) the buffer pointer is PAGE aligned // 2) the kernel's buffer overrun/underrun checking can be used // 3) for case c), that the object is non pageable while the memory pointer // it returns to the driver is pageable // // // By placing FxIsPagedPool last in the list, BufferSize < PAGE_SIZE // if (BufferSize >= PAGE_SIZE || (FxDriverGlobals->FxVerifierOn && FxDriverGlobals->FxPoolTrackingOn) || FxIsPagedPoolType(PoolType)) { return FxMemoryBufferFromPool::_Create( FxDriverGlobals, Attributes, PoolType, PoolTag, BufferSize, Object); } else { // // Before the changes for NxPool this code path assumed NonPagedPool // // To maintain compatibility with existing behavior (and add on NxPool // options we pass in PoolType to FxMemoryBuffer::_Create but // normalize NonPagedPool variants to NonPagedPool. // switch(PoolType) { case NonPagedPoolBaseMustSucceed: case NonPagedPoolBaseCacheAligned: case NonPagedPoolBaseCacheAlignedMustS: PoolType = NonPagedPool; } return FxMemoryBuffer::_Create( FxDriverGlobals, Attributes, PoolTag, BufferSize, PoolType, Object); } } _Must_inspect_result_ NTSTATUS IFxMemory::CopyFromPtr( __in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets ) { PFX_DRIVER_GLOBALS pFxDriverGlobals; pFxDriverGlobals = GetDriverGlobals(); // // We read from the supplied buffer writing to the current FxMemoryBuffer // if (GetFlags() & IFxMemoryFlagReadOnly) { // // FxMemoryBuffer is not writeable // DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE, "Target WDFMEMORY 0x%p is ReadOnly", GetHandle()); FxVerifierDbgBreakPoint(pFxDriverGlobals); return STATUS_ACCESS_VIOLATION; } return _CopyPtrToPtr( SourceBuffer, SourceBufferLength, SourceOffsets, GetBuffer(), GetBufferSize(), DestinationOffsets ); } _Must_inspect_result_ NTSTATUS IFxMemory::CopyToPtr( __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength)PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets ) /*++ Routine Description: Worker routine for the various copy APIs. Verifies that a copy will not overrun a buffer, or write into a read only memory buffer Arguments: SourceOffsets - Offsets into SourceBuffer from which the copy starts. If NULL, an offset of 0 is used. DestinationBuffer - Memory whose contents we are copying into DestinationBufferLength - Size of DestinationBuffer in bytes DestinationOffsets - Offsets into DestinationMemory from which the copy starts and indicates how many bytes to copy. If length is 0 or parameter is NULL, the entire length of DestinationMemory is used. Return Value: STATUS_BUFFER_TOO_SMALL - SourceMemory is smaller then the requested number of bytes to be copied. STATUS_INVALID_BUFFER_SIZE - DestinationMemory is not large enough to contain the number of bytes requested to be copied NTSTATUS --*/ { // // We are reading from the FxMemoryBuffer, so no need to check for ReadOnly // return _CopyPtrToPtr( GetBuffer(), GetBufferSize(), SourceOffsets, DestinationBuffer, DestinationBufferLength, DestinationOffsets ); } _Must_inspect_result_ NTSTATUS IFxMemory::_CopyPtrToPtr( __in_bcount(SourceBufferLength)PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets ) /*++ Routine Description: Worker routine for the various copy APIs. Verifies that a copy will not overrun a buffer. Arguments: SourceBuffer - Memory whose contents we are copying from. SourceBufferLength - Size of SourceBuffer in bytes SourceOffsets - Offsets into SourceBuffer from which the copy starts. If NULL, an offset of 0 is used. DestinationBuffer - Memory whose contents we are copying into DestinationBufferLength - Size of DestinationBuffer in bytes DestinationOffsets - Offsets into DestinationMemory from which the copy starts and indicates how many bytes to copy. If length is 0 or parameter is NULL, the entire length of DestinationMemory is used. Return Value: STATUS_BUFFER_TOO_SMALL - SourceMemory is smaller then the requested number of bytes to be copied. STATUS_INVALID_BUFFER_SIZE - DestinationMemory is not large enough to contain the number of bytes requested to be copied NTSTATUS --*/ { size_t srcSize, copyLength; PUCHAR pSrcBuf, pDstBuf; if (SourceBuffer == NULL) { return STATUS_INVALID_PARAMETER; } pSrcBuf = (PUCHAR) SourceBuffer; srcSize = SourceBufferLength; pDstBuf = (PUCHAR) DestinationBuffer; copyLength = DestinationBufferLength; if (SourceOffsets != NULL) { if (SourceOffsets->BufferOffset != 0) { if (SourceOffsets->BufferOffset >= srcSize) { // // Offset is beyond end of buffer // return STATUS_BUFFER_TOO_SMALL; } // // Adjust the start and source size to reflect the offset info the // source // pSrcBuf += SourceOffsets->BufferOffset; srcSize -= SourceOffsets->BufferOffset; } } if (DestinationOffsets != NULL) { if (DestinationOffsets->BufferOffset != 0) { if (DestinationOffsets->BufferOffset >= copyLength) { // // Offset is beyond end of buffer // return STATUS_INVALID_BUFFER_SIZE; } // // Adjust the start and copy length to reflect the offset info the // destination // pDstBuf += DestinationOffsets->BufferOffset; copyLength -= DestinationOffsets->BufferOffset; } // // Non zero buffer length overrides previously calculated copy length // if (DestinationOffsets->BufferLength != 0) { // // Is the desired buffer length greater than the amount of buffer // available? // if (DestinationOffsets->BufferLength > copyLength) { return STATUS_INVALID_BUFFER_SIZE; } copyLength = DestinationOffsets->BufferLength; } } // // Compare the final computed copy length against the length of the source // buffer. // if (copyLength > srcSize) { return STATUS_BUFFER_TOO_SMALL; } RtlCopyMemory(pDstBuf, pSrcBuf, copyLength); return STATUS_SUCCESS; }
28.221875
81
0.653637
IT-Enthusiast-Nepal
c414739d7eb63fdf986f35e4cab217fab92babeb
7,673
cc
C++
src/b1mapping.cc
EPTlib/b1map-sim
2f5836907b06453cd71a15c8e7a632f7327d621c
[ "MIT" ]
3
2021-03-02T19:36:56.000Z
2022-02-03T00:01:11.000Z
src/b1mapping.cc
EPTlib/b1map-sim
2f5836907b06453cd71a15c8e7a632f7327d621c
[ "MIT" ]
1
2021-06-10T13:43:00.000Z
2021-06-10T13:43:00.000Z
src/b1mapping.cc
EPTlib/b1map-sim
2f5836907b06453cd71a15c8e7a632f7327d621c
[ "MIT" ]
null
null
null
/***************************************************************************** * * Program: b1map-sim * Author: Alessandro Arduino <a.arduino@inrim.it> * * MIT License * * Copyright (c) 2020 Alessandro Arduino * Istituto Nazionale di Ricerca Metrologica (INRiM) * Strada delle cacce 91, 10135 Torino * ITALY * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * *****************************************************************************/ #include "b1map/b1mapping.h" #include <iostream> #include <random> #include "b1map/sequences.h" namespace b1map { // B1Mapping constructor B1Mapping:: B1Mapping() { return; } // B1Mapping destructor B1Mapping:: ~B1Mapping() { return; } // B1Mapping GetImg Image<std::complex<double> >& B1Mapping:: GetImg(const int d) { return imgs[d]; } // DoubleAngle constructor DoubleAngle:: DoubleAngle(const double alpha_nom, const double TR, const double TE, const Image<std::complex<double> > &b1p, const Image<std::complex<double> > &b1m, const double spoiling, const Body &body) { GREImage(&imgs[0],alpha_nom,TR,TE,b1p,b1m,spoiling,body); GREImage(&imgs[1],2.0*alpha_nom,TR,TE,b1p,b1m,spoiling,body); return; } // DoubleAngle destructor DoubleAngle:: ~DoubleAngle() { return; } // DoubleAngle Run void DoubleAngle:: Run(Image<double> *alpha_est, const double sigma) { *alpha_est = Image<double>(imgs[0].GetSize(0),imgs[0].GetSize(1),imgs[0].GetSize(2)); std::array<Image<std::complex<double> >,2>* imgs_noise; if (sigma > 0.0) { imgs_noise = new std::array<Image<std::complex<double> >,2>(); AddNoise(imgs_noise,imgs,sigma); } else { imgs_noise = &imgs; } for (int idx = 0; idx<imgs[0].GetNVox(); ++idx) { (*alpha_est)[idx] = std::acos(std::abs((*imgs_noise)[1][idx])/2.0/std::abs((*imgs_noise)[0][idx])); } if (sigma>0.0) { delete imgs_noise; } return; } // ActualFlipAngle constructor ActualFlipAngle:: ActualFlipAngle(const double alpha_nom, const double TR1, const double TR2, const double TE, const Image<std::complex<double> > &b1p, const Image<std::complex<double> > &b1m, const double spoiling, const Body &body) { AFIImage(&imgs[0],&imgs[1],alpha_nom,TR1,TR2,TE,b1p,b1m,spoiling,body); TRratio = TR2/TR1; return; } // ActualFlipAngle destructor ActualFlipAngle:: ~ActualFlipAngle() { return; } // ActualFlipAngle Run void ActualFlipAngle:: Run(Image<double> *alpha_est, const double sigma) { *alpha_est = Image<double> (imgs[0].GetSize(0),imgs[0].GetSize(1),imgs[0].GetSize(2)); std::array<Image<std::complex<double> >,2>* imgs_noise; if (sigma > 0.0) { imgs_noise = new std::array<Image<std::complex<double> >,2>(); AddNoise(imgs_noise,imgs,sigma); } else { imgs_noise = &imgs; } for (int idx = 0; idx<imgs[0].GetNVox(); ++idx) { double tmp = std::abs((*imgs_noise)[1][idx])/std::abs((*imgs_noise)[0][idx]); (*alpha_est)[idx] = std::acos((TRratio*tmp-1.0)/(TRratio-tmp)); } if (sigma>0.0) { delete imgs_noise; } return; } // BlochSiegertShift constructor BlochSiegertShift:: BlochSiegertShift(const double alpha_nom, const double TR, const double TE, const double bss_offres, const double bss_length, const Image<std::complex<double> > &b1p, const Image<std::complex<double> > &b1m, const double spoiling, const Body &body) { BSSImage(&imgs[0],alpha_nom,TR,TE,+bss_offres,bss_length,b1p,b1m,spoiling,body); BSSImage(&imgs[1],alpha_nom,TR,TE,-bss_offres,bss_length,b1p,b1m,spoiling,body); Kbs = GAMMA*GAMMA*bss_length/2.0/bss_offres; return; } // BlochSiegertShift destructor BlochSiegertShift:: ~BlochSiegertShift() { return; } // BlochSiegertShift run void BlochSiegertShift:: Run(Image<double> *alpha_est, const double sigma) { *alpha_est = Image<double>(imgs[0].GetSize(0),imgs[0].GetSize(1),imgs[0].GetSize(2)); std::array<Image<std::complex<double> >,2>* imgs_noise; if (sigma > 0.0) { imgs_noise = new std::array<Image<std::complex<double> >,2>(); AddNoise(imgs_noise,imgs,sigma); } else { imgs_noise = &imgs; } for (int idx = 0; idx<imgs[0].GetNVox(); ++idx) { (*alpha_est)[idx] = std::sqrt(std::arg((*imgs_noise)[0][idx]/(*imgs_noise)[1][idx])/2.0/Kbs); } if (sigma>0.0) { delete imgs_noise; } return; } // TRxPhaseGRE constructor TRxPhaseGRE:: TRxPhaseGRE(const double alpha_nom, const double TR, const double TE, const Image<std::complex<double> > &b1p, const Image<std::complex<double> > &b1m, const double spoiling, const Body &body) { GREImage(&imgs[0],alpha_nom,TR,TE,b1p,b1m,spoiling,body); imgs[1] = Image<std::complex<double> >(b1p.GetSize(0),b1p.GetSize(1),b1p.GetSize(2)); return; } // TRxPhaseGRE destructor TRxPhaseGRE:: ~TRxPhaseGRE() { return; } // TRxPhaseGRE Run void TRxPhaseGRE:: Run(Image<double> *alpha_est, const double sigma) { *alpha_est = Image<double>(imgs[0].GetSize(0),imgs[0].GetSize(1),imgs[0].GetSize(2)); Image<std::complex<double> >* img_noise; if (sigma > 0.0) { img_noise = new Image<std::complex<double> >; AddNoise(img_noise,imgs[0],sigma); } else { img_noise = &(imgs[0]); } for (int idx = 0; idx<imgs[0].GetNVox(); ++idx) { (*alpha_est)[idx] = std::arg((*img_noise)[idx]); } if (sigma>0.0) { delete img_noise; } return; } // Noise utils double ComputeSigma(const std::array<Image<std::complex<double> >,2> &imgs, const double noise) { std::array<double,2> sigma{0.0,0.0}; for (int d = 0; d<2; ++d) { Image<double> tmp(imgs[0].GetSize(0),imgs[0].GetSize(1),imgs[0].GetSize(2)); for (int idx = 0; idx<imgs[d].GetNVox(); ++idx) { tmp[idx] = std::abs(imgs[d][idx]); } sigma[d] = Avg(tmp.GetData())*noise; } return (sigma[0]+sigma[1])/2.0; } void AddNoise(std::array<Image<std::complex<double> >,2> *imgs_noise, const std::array<Image<std::complex<double> >,2> &imgs, const double sigma) { std::random_device generator; std::normal_distribution<double> distribution(0.0,sigma); for (int d = 0; d<2; ++d) { (*imgs_noise)[d] = Image<std::complex<double> >(imgs[d].GetSize(0),imgs[d].GetSize(1),imgs[d].GetSize(2)); for (int idx = 0; idx<imgs[d].GetNVox(); ++idx) { std::complex<double> tmp(distribution(generator),distribution(generator)); (*imgs_noise)[d][idx] = imgs[d][idx]+tmp; } } return; } void AddNoise(Image<std::complex<double> > *img_noise, const Image<std::complex<double> > &img, const double sigma) { std::random_device generator; std::normal_distribution<double> distribution(0.0,sigma); (*img_noise) = Image<std::complex<double> >(img.GetSize(0),img.GetSize(1),img.GetSize(2)); for (int idx = 0; idx<img.GetNVox(); ++idx) { std::complex<double> tmp(distribution(generator),distribution(generator)); (*img_noise)[idx] = img[idx]+tmp; } return; } } // namespace b1map
31.706612
108
0.683305
EPTlib
c4183d91d218ad359314acc571fa99c92c17d133
2,520
cpp
C++
Scene_Closing.cpp
alvieboy/demo_new_year_2019
4a6b171c66f3948680a666aef22dbb3878c63635
[ "BSD-3-Clause" ]
null
null
null
Scene_Closing.cpp
alvieboy/demo_new_year_2019
4a6b171c66f3948680a666aef22dbb3878c63635
[ "BSD-3-Clause" ]
null
null
null
Scene_Closing.cpp
alvieboy/demo_new_year_2019
4a6b171c66f3948680a666aef22dbb3878c63635
[ "BSD-3-Clause" ]
null
null
null
#include "Scene_Closing.h" #include <QDebug> #include "DrawUtils.h" #include "TextWriter.h" #include <QFile> static inline uint8_t noisy(uint8_t base) { uint32_t noise; noise = random() & 0x3F; noise += base; if (noise>0xff) noise=0xff; return noise; } static uint32_t getcolor_green(void) { return ((uint32_t)noisy(0)<<16) + ((uint32_t)noisy(0xB0)<<8) + uint32_t(noisy(0)); } static uint32_t getcolor_amber(void) { return ((uint32_t)noisy(0xB6)<<16) + ((uint32_t)noisy(0x88)<<8) + uint32_t(noisy(0)); } static uint32_t getcolor_bluish(void) { return ((uint32_t)noisy(0x00)<<16) + ((uint32_t)noisy(0x88)<<8) + uint32_t(noisy(0xb6)); } Scene_Closing::Scene_Closing(ScreenDrawer *d) { const font_t *font2 = font_find("6x10"); //"------------------\n"// t = new TextWriter("$ cat > hny.c\n" "#include <stdio.h>\n" "int main(void)\n" "{\n" " puts(\"Happy \"\n" " \"new Year!\");\n" " return 0;\n" "}\n" "^D\n" "$ gcc hny.c -o hny\n" "$ ./hny\n" "Happy new Year!\n" "$ ", &getcolor_green, BLOCKSIZE*BLOCKS_X+4, 0, font2); QObject::connect(t, SIGNAL(charTyped()), this, SLOT(charTyped())); tdrawer = new TetrisScreenDrawer(d); QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(ended())); QObject::connect(t, SIGNAL(finished()), this, SLOT(textEnded())); } void Scene_Closing::textEnded() { timer.setSingleShot(true); timer.start(4000); } void Scene_Closing::drawTo(ScreenDrawer*drawer) { // Draw Vline drawer->setVideoMode(false); uint32_t border = getcolor_amber(); drawer->drawVLine((BLOCKS_X*BLOCKSIZE)+1, 0, 128, border); drawer->drawVLine(0, 0, 128, border); drawer->drawHLine(0, 0, (BLOCKS_X*BLOCKSIZE)+1, border); drawer->drawHLine(0, 127, (BLOCKS_X*BLOCKSIZE)+1, border); tetris.game_loop(tdrawer); t->drawTo(drawer); } void Scene_Closing::start() { tetris.setup_game(); t->start(); } void Scene_Closing::reset() { } void Scene_Closing::charTyped() { } void Scene_Closing::tick() { tetris.game_event_check(tdrawer); // t->tick(); } void Scene_Closing::ended() { emit sceneFinished(); } void Scene_Closing::stop() { delete t; }
21.355932
92
0.554762
alvieboy