blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
e117cd6a0af36ed209e04753482edd51c8ea58d1
d7dacb8800693b89ea9255e476b80e8c0fbb69fa
/Server/ClientTest/ClientTest.cpp
2b1d4d09c2aea68adefdb3cd7879eb22976e7369
[]
no_license
ardar/ycmonitor
1dc86235d3592758f9961f67f92a802d568de825
f322e7e55782e4f91ca0a58863dfa6b20a318bb9
refs/heads/master
2020-07-01T23:06:23.677034
2013-05-31T10:38:09
2013-05-31T10:38:09
10,076,210
1
1
null
null
null
null
GB18030
C++
false
false
9,674
cpp
ClientTest.cpp
// ClientTest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "ClientTest.h" #ifdef _DEBUG #define new DEBUG_NEW #endif #define MONITOR_INI_FILE ".\\D3Client.ini" // 唯一的应用程序对象 CWinApp theApp; ID3Client* pClient = ID3Client::CreateInstance(); using namespace std; static int nImageNum = 0; vector<D3SearchItem*>* searchList = new vector<D3SearchItem*>(); vector<D3SearchItem*>* localsearchList = new vector<D3SearchItem*>(); vector<D3DepotItem*>* depotList = new vector<D3DepotItem*>(); D3Schedule schedule; void OnClientMsg(DWORD msgId, DWORD dwRequestId, WPARAM wParam, LPARAM lParam) { switch(msgId) { case D3Event_Connected: printf("connected\n"); break; case D3Event_Disconnected: printf("connected\n"); break; case D3Event_GetMoney: { INT64 nMoney = 0; if(lParam) nMoney = *(INT64*)lParam; printf("getmoney %I64d\n", nMoney); } break; case D3Event_Auth: printf("auth result %d\n", wParam); break; case D3Event_SearchItems: if (wParam==0 && lParam) { searchList->clear(); vector<D3SearchItem*>* itemList = (vector<D3SearchItem*>*)lParam; vector<D3SearchItem*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3SearchItem* pItem = *it; printf("item: %d, %I64d, %I64d, %I64d, %s %d\n", pItem->dwDataId, pItem->llBuyOut, pItem->llCurBid, pItem->llLowestPrice, pItem->info.szName, pItem->status); searchList->push_back(pItem); } } printf("search result %d\n", wParam); break; case D3Event_SearchItemsInLocal: if (wParam==0 && lParam) { localsearchList->clear(); vector<D3SearchItem*>* itemList = (vector<D3SearchItem*>*)lParam; vector<D3SearchItem*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3SearchItem* pItem = *it; printf("item: %d, %I64d, %I64d, %I64d, %s %d\n", pItem->dwDataId, pItem->llBuyOut, pItem->llCurBid, pItem->llLowestPrice, pItem->info.szName, pItem->status); localsearchList->push_back(pItem); } } printf("search local result %d\n", wParam); break; case D3Event_GetDepotItems: if (wParam==0 && lParam) { depotList->clear(); vector<D3DepotItem*>* itemList = (vector<D3DepotItem*>*)lParam; vector<D3DepotItem*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3DepotItem* pItem = *it; if(pItem->npos==15) { printf("item: pos:%d, num:%d, ppos:%d, cansel:%d, %s \n", pItem->npos, pItem->nItemNum, pItem->nPackagePos, pItem->bCanSel, pItem->info.szName); depotList->push_back(pItem); } } } printf("getdepot result %d\n", wParam); break; case D3Event_GetSellingItems: if (wParam==0 && lParam) { vector<D3SellingItem*>* itemList = (vector<D3SellingItem*>*)lParam; vector<D3SellingItem*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3SellingItem* pItem = *it; printf("item: llCurBid:%I64d, llBuyOut:%I64d, lEndTime:%d, status:%d, %s \n", pItem->llCurBid, pItem->llBuyOut, pItem->lEndTime, pItem->sellStatus, pItem->info.szName); } } printf("getselling result %d\n", wParam); break; case D3Event_GetFinishedItems: if (wParam==0 && lParam) { vector<D3CompletedItem*>* itemList = (vector<D3CompletedItem*>*)lParam; vector<D3CompletedItem*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3CompletedItem* pItem = *it; printf("item: index:%d, %s \n", pItem->nIndex, pItem->info.szName); } it = itemList->begin(); D3CompletedItem* pItem = *it; pClient->DoReceive(pItem->info); } printf("getfinished result %d\n", wParam); break; case D3Event_DoBid: printf("D3Event_DoBid result %d %d\n", wParam, lParam); break; case D3Event_DoBuyOut: printf("D3Event_DoBuyOut result %d %d\n", wParam, lParam); break; case D3Event_DoReceive: printf("D3Event_DoReceive result %d %d\n", wParam, lParam); break; case D3Event_DoSell: printf("D3Event_DoSell result %d %d\n", wParam, lParam); break; case D3Event_SaveItem: printf("saveitem result %d %d\n", wParam, lParam); break; case D3Event_GetSchedules: if (wParam==0 && lParam) { vector<D3Schedule*>* itemList = (vector<D3Schedule*>*)lParam; vector<D3Schedule*>::const_iterator it; for (it=itemList->begin();it!=itemList->end();it++) { D3Schedule* pItem = *it; printf("schedule: %d, %s : %s\n", pItem->dwScheduleId, pItem->szName, pItem->szOperationParam); } } printf("getschedule result %d %d\n", wParam, lParam); break; case D3Event_AddSchedule: printf("addschedule result %d %d\n", wParam, lParam); schedule.dwScheduleId = lParam; break; case D3Event_EditSchedule: printf("editschedule result %d %d\n", wParam, lParam); break; case D3Event_DelSchedule: printf("delschedule result %d %d\n", wParam, lParam); break; case D3Event_SwitchAccount: printf("switchacc:result:%d %d, %d" ); break; } printf("OnClientMsg:%d req:%d w:%d l:%d\n", msgId, dwRequestId, wParam, lParam); } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // 初始化 MFC 并在失败时显示错误 if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: 更改错误代码以符合您的需要 _tprintf(_T("错误: MFC 初始化失败\n")); nRetCode = 1; } else { // TODO: 在此处为应用程序的行为编写代码。 } BSHelper::GoAppRootPath(); TCHAR szMac[MAX_NAME_LENGTH]; GetPrivateProfileString("D3Client", "mac", "", szMac, MAX_NAME_LENGTH, MONITOR_INI_FILE); pClient->InitClient(szMac, MONITOR_INI_FILE, OnClientMsg); pClient->StartClient(); while(!pClient->IsConnected()) { Sleep(500); } printf("connected\n"); DWORD dwResult = pClient->Authenticate("ad","123"); printf("authresult %d\n", dwResult); pClient->GetMoney(); TCHAR sz[100]; BOOL bRunning = TRUE; while(bRunning) { scanf("%c",sz); switch(sz[0]) { case 'i': { if (searchList) { vector<D3SearchItem*>::iterator it; for(it = searchList->begin();it!=searchList->end();it++) { D3SearchItem* pItem = *it; if (pItem->status==D3emSearchItemStatus::D3SEARCHBIDED) { //pClient->DoBuyOut(pItem->info); INT64 llPrice = pItem->llCurBid>pItem->llLowestPrice ? pItem->llCurBid : pItem->llLowestPrice; llPrice += 1000; llPrice = llPrice > pItem->llBuyOut ? pItem->llBuyOut : llPrice; pClient->DoBid(pItem->info, llPrice); break; } } } } break; case 'o': { vector<D3SearchItem*>::iterator it; for(it = searchList->begin();it!=searchList->end();it++) { D3SearchItem* pItem = *it; if (pItem->status==D3emSearchItemStatus::D3SEARCHBIDED) { pClient->DoBuyOut(pItem->info); break; } } } break; case 'a': { vector<D3SearchItem*>::iterator it; for(it = searchList->begin();it!=searchList->end();it++) { D3SearchItem* pItem = *it; if (pItem->status==D3emSearchItemStatus::D3SEARCHBIDED) { pClient->SaveItemData(pItem->info, pItem->llCurBid, pItem->llBuyOut); break; } } } break; case 'e': { vector<D3DepotItem*>::iterator it; for(it = depotList->begin();it!=depotList->end();it++) { D3DepotItem* pItem = *it; if (pItem->bCanSel) { pClient->DoSell(*pItem, 20000, 200000); break; } } } break; case 'r': case 'l': { D3SearchCondition con; con.nPage = 1; con.nBuyoutTextBox = 10000; strcpy(con.szCharacterFilter, "巫醫"); strcpy(con.szPrimaryFilter, "單手"); strcpy(con.szSecondaryFilter, "所有單手類型物品"); strcpy(con.szRarityFilter, "全部"); for(int i=0;i<6;i++) { strcpy(con.szAdvancedComboBox[i],"無"); } con.nBuyoutTextBox = 2000; if (sz[0]=='r') { pClient->SearchItems(con); } else { pClient->SearchItemsInLocal(con); } }; break; case 'c': pClient->GetFinishedItems(); break; case 'd': pClient->GetDepotItems(); break; case 's': pClient->GetSellingItems(); break; case 'b': pClient->GetBiddingItems(); break; case 'm': pClient->GetMoney(); break; case 'h': { schedule.bIsEnabled = TRUE; schedule.dwBeginTime = time(0); schedule.dwEndTime = 0; schedule.dwRepeatParam = time(0)%3600 + 10; schedule.repeatType = D3Schedule::RepeatByHour; schedule.operationType = D3Schedule::ScheduleScript; schedule.szOperationParam = "收取完成物品()"; schedule.szName = "测试收取全部物品计划"; DWORD dwRequestId = pClient->AddSchedule(schedule); break; } case 'k': { schedule.bIsEnabled = TRUE; schedule.dwBeginTime = time(0); schedule.dwEndTime = time(0)+86400; schedule.dwRepeatParam = 30; schedule.repeatType = D3Schedule::RepeatByMinute; schedule.operationType = D3Schedule::ScheduleScript; schedule.szOperationParam = "搜索物品(\ \"巫醫\",\"單手\",\"所有單手類型物品\",\"全部\")"; schedule.szName = "搜索物品"; DWORD dwRequestId = pClient->EditSchedule(schedule); } case 'j': { DWORD dwRequestId = pClient->GetSchedules(); } break; case 'w': { D3GameAccount acc; strcpy_s(acc.szAccount, sizeof(acc.szAccount), "aaa"); strcpy_s(acc.szAccount, sizeof(acc.szAccount), "bbb"); pClient->SwitchAccount(acc); } break; case 'x': bRunning = FALSE; break; } Sleep(1000); }; return nRetCode; }
d2e4b48db06e41bf4b9e483cfa0a651de4d4d60e
90d88d5df9df3c6d64b3f22de38e1d7278b94ef9
/MyDataStructure/Queue.h
53f39bc51f168a4c791951e99afa6fdfd867268b
[]
no_license
wwwonekey/Data-Structures-Implemented-By-Me
0f3a80b2be84fe683e0358ac4c86e974d59f4250
33910e932e343ed2a2bb5beccf99cb4628f86e4a
refs/heads/master
2020-09-20T21:13:32.740888
2017-07-13T07:59:18
2017-07-13T07:59:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,284
h
Queue.h
// // Queue.hpp // MyDataStructure // // Created by 杜臻 on 17/3/28. // Copyright © 2017年 杜臻. All rights reserved. // #ifndef Queue_h #define Queue_h #include <stdio.h> #include <iostream> using namespace std; template<class T> class Queue { public: Queue(int MaxQueueSize); bool IsFull(); void add(const T &item); bool IsEmpty(); T *Delete(); void printQueue(); ~Queue(); private: T *queue; int front; int rear; int MaxQueueSize; }; template<class T> Queue<T>::Queue(int MaxQueueSize) { //因为预留一个空位来进行队列或者空或者满的判断 this->MaxQueueSize = MaxQueueSize + 1; this->queue = new T[this->MaxQueueSize]; this->front = 0; this->rear = 0; } template<class T> void Queue<T>::add(const T &item) { //判断是不是满了 if (((rear + 1) % MaxQueueSize) == front) { cout << "已经满了,不能再加入" << endl; return; } //如果没有满,就进行值的插入操作 queue[rear] = item; rear = (rear + 1) % MaxQueueSize; // cout << "(rear , front) = " << rear << " , " << front << endl; } template<class T> T *Queue<T>::Delete() { //首先判断是不是空的 if (rear == front) { cout << "已经空了,取不出东西了" << endl; return NULL; } //如果发现没有空,那就取出来这么一个东西 T returnValue = queue[front]; //移动头指针的位置 front = (front + 1) % MaxQueueSize; // cout << "(rear , front) = " << rear << " , " << front << endl; return &returnValue; } template<class T> bool Queue<T>::IsEmpty() { //判断现在这个队列是不是空的 return (rear == front); } template<class T> bool Queue<T>::IsFull() { //现在判断这个队列是不是满的 return ((rear + 1) % MaxQueueSize) == front; } template<class T> Queue<T>::~Queue() { delete queue; } template<class T> void Queue<T>::printQueue() { cout << "开始打印:" << endl; for (int i = front; i != rear; i = (i + 1) % MaxQueueSize) { cout << queue[i] << ";"; } cout << endl; } #endif /* Queue_hpp */
18efec0528780ce0b1db3599ece92b30f2c3a14f
0bcd128368e2de959ca648960ffd7944067fcf27
/tests/RecordingXfermodeTest.cpp
47c80122f0e36dedf0bc5d3b5981bdf912262732
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
google/skia
ac6e39179cd33cf0c8a46d29c1a70bf78b4d74ee
bf6b239838d3eb56562fffd0856f4047867ae771
refs/heads/main
2023-08-31T21:03:04.620734
2023-08-31T18:24:15
2023-08-31T20:20:26
15,773,229
8,064
1,487
BSD-3-Clause
2023-09-11T13:42:07
2014-01-09T17:09:57
C++
UTF-8
C++
false
false
6,149
cpp
RecordingXfermodeTest.cpp
/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "include/core/SkBBHFactory.h" #include "include/core/SkBitmap.h" #include "include/core/SkBlendMode.h" #include "include/core/SkCanvas.h" #include "include/core/SkImage.h" #include "include/core/SkImageInfo.h" #include "include/core/SkPaint.h" #include "include/core/SkPicture.h" #include "include/core/SkPictureRecorder.h" #include "include/core/SkRect.h" #include "include/core/SkRefCnt.h" #include "include/core/SkSamplingOptions.h" #include "include/core/SkScalar.h" #include "include/core/SkString.h" #include "include/core/SkSurface.h" #include "tests/Test.h" #include <cstring> // Verify that replay of a recording into a clipped canvas // produces the correct bitmap. // This arose from http://crbug.com/401593 which has // https://code.google.com/p/skia/issues/detail?id=1291 as its root cause. namespace { class Drawer { public: explicit Drawer() : fImageInfo(SkImageInfo::MakeN32Premul(200, 100)) { auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)); surf->getCanvas()->clear(0xffffffff); SkPaint circlePaint; circlePaint.setColor(0xff000000); surf->getCanvas()->drawCircle(50, 50, 50, circlePaint); fCircleImage = surf->makeImageSnapshot(); } const SkImageInfo& imageInfo() const { return fImageInfo; } void draw(SkCanvas* canvas, const SkRect& clipRect, SkBlendMode mode) const { SkPaint greenPaint; greenPaint.setColor(0xff008000); SkPaint blackPaint; blackPaint.setColor(0xff000000); SkPaint whitePaint; whitePaint.setColor(0xffffffff); SkPaint layerPaint; layerPaint.setColor(0xff000000); layerPaint.setBlendMode(mode); SkRect canvasRect(SkRect::MakeWH(SkIntToScalar(fImageInfo.width()), SkIntToScalar(fImageInfo.height()))); canvas->clipRect(clipRect); canvas->clear(0xff000000); canvas->saveLayer(nullptr, &blackPaint); canvas->drawRect(canvasRect, greenPaint); canvas->saveLayer(nullptr, &layerPaint); canvas->drawImageRect(fCircleImage, SkRect::MakeXYWH(20,20,60,60), SkSamplingOptions(), &blackPaint); canvas->restore(); canvas->restore(); } private: const SkImageInfo fImageInfo; sk_sp<SkImage> fCircleImage; }; class RecordingStrategy { public: virtual ~RecordingStrategy() {} virtual const SkBitmap& recordAndReplay(const Drawer& drawer, const SkRect& intoClip, SkBlendMode) = 0; }; class BitmapBackedCanvasStrategy : public RecordingStrategy { // This version just draws into a bitmap-backed canvas. public: BitmapBackedCanvasStrategy(const SkImageInfo& imageInfo) { fBitmap.allocPixels(imageInfo); } const SkBitmap& recordAndReplay(const Drawer& drawer, const SkRect& intoClip, SkBlendMode mode) override { SkCanvas canvas(fBitmap); canvas.clear(0xffffffff); // Note that the scene is drawn just into the clipped region! canvas.clipRect(intoClip); drawer.draw(&canvas, intoClip, mode); // Shouild be canvas-wide... return fBitmap; } private: SkBitmap fBitmap; }; class PictureStrategy : public RecordingStrategy { // This version draws the entire scene into an SkPictureRecorder. // Then it then replays the scene through a clip rectangle. // This backend proved to be buggy. public: PictureStrategy(const SkImageInfo& imageInfo) { fBitmap.allocPixels(imageInfo); fWidth = imageInfo.width(); fHeight = imageInfo.height(); } const SkBitmap& recordAndReplay(const Drawer& drawer, const SkRect& intoClip, SkBlendMode mode) override { SkRTreeFactory factory; SkPictureRecorder recorder; SkRect canvasRect(SkRect::MakeWH(SkIntToScalar(fWidth),SkIntToScalar(fHeight))); SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(fWidth), SkIntToScalar(fHeight), &factory); drawer.draw(canvas, canvasRect, mode); sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); SkCanvas replayCanvas(fBitmap); replayCanvas.clear(0xffffffff); replayCanvas.clipRect(intoClip); picture->playback(&replayCanvas); return fBitmap; } private: SkBitmap fBitmap; int fWidth; int fHeight; }; } // namespace DEF_TEST(SkRecordingAccuracyXfermode, reporter) { #define FINEGRAIN 0 const Drawer drawer; BitmapBackedCanvasStrategy golden(drawer.imageInfo()); PictureStrategy picture(drawer.imageInfo()); #if !FINEGRAIN unsigned numErrors = 0; SkString errors; #endif for (int iMode = 0; iMode < kSkBlendModeCount; iMode++) { const SkRect& clip = SkRect::MakeXYWH(100, 0, 100, 100); SkBlendMode mode = SkBlendMode(iMode); const SkBitmap& goldenBM = golden.recordAndReplay(drawer, clip, mode); const SkBitmap& pictureBM = picture.recordAndReplay(drawer, clip, mode); size_t pixelsSize = goldenBM.computeByteSize(); REPORTER_ASSERT(reporter, pixelsSize == pictureBM.computeByteSize()); // The pixel arrays should match. #if FINEGRAIN REPORTER_ASSERT(reporter, 0 == memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize)); #else if (0 != memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize)) { numErrors++; errors.appendf("For SkBlendMode %d %s: SkPictureRecorder bitmap is wrong\n", iMode, SkBlendMode_Name(mode)); } #endif } #if !FINEGRAIN REPORTER_ASSERT(reporter, 0 == numErrors, "%s", errors.c_str()); #endif }
fb1d299ea13012daaf1a8f4ddc4c529bf14d38e8
21b7eb6181835c0e32bc13b9e323a29b43c50e19
/CodeForces/732B.cc
a04e1d1ba21568771ab8b64990cd7c0e96bd446a
[ "Unlicense" ]
permissive
wabilin/OJSols
0d65ae9cf8ae77b5af009038c876ee284fb83814
8a9e9ca9a9c25acd81a7847c9d8e8439ef041d5f
refs/heads/master
2021-06-02T10:10:50.537486
2021-02-01T11:09:55
2021-02-01T11:09:55
71,791,712
0
0
null
null
null
null
UTF-8
C++
false
false
814
cc
732B.cc
#include <cstdio> #include <vector> void n1case(int k); int main(int argc, char** argv) { int n, k; scanf("%d %d", &n, &k); // if (n == 1) { // n1case(k); // return 0; // } // commented and AC... WTF? using namespace std; vector<int> plan(n, 0); for (int i = 0; i < n; i += 1) { scanf("%d", &plan[i]); } int added = 0; for (int i = 1; i < n; i += 1) { int planned = plan[i] + plan[i-1]; if (planned < k) { int plus = k - planned; plan[i] += plus; added += plus; } } printf("%d\n%d", added, plan[0]); for (int i = 1; i < n; i += 1) { printf(" %d", plan[i]); } printf("\n"); return 0; } void n1case(int k) { int p; scanf("%d", &p); if (k > p) printf("%d\n%d\n", k - p, k); else printf("%d\n%d\n", 0, p); }
866d172b3bec019d067e1db312645b804f3f0f67
0f835bc34c99d9a776b6ecf308d4acb723539870
/spheregenerator.h
c1299f2bba9905cf34f39010f5e4e075011242df
[]
no_license
jacobmoroni/SnowGlobe
526380a8684543cd056ec114bd0a3593228fc555
4c7c9144af2fb36d24810ec7637864e92657a769
refs/heads/master
2023-07-30T16:41:56.444181
2021-09-17T18:30:37
2021-09-17T18:30:37
407,608,664
0
0
null
null
null
null
UTF-8
C++
false
false
1,363
h
spheregenerator.h
#ifndef SPHEREGENERATOR_H #define SPHEREGENERATOR_H #include <QDialog> #include "vector.h" struct SphereGenSettings { public: int num_spheres{10}; double rad_max{1}; double rad_min{.2}; double mass_max{10}; double mass_min{2}; double cr_max{.2}; double cr_min{1}; double vel_max{6}; double vel_min{0}; }; namespace Ui { class SphereGenerator; } class SphereGenerator : public QDialog { Q_OBJECT public: explicit SphereGenerator(QWidget *parent = nullptr); ~SphereGenerator(); int getNumSpheres(); double getRadiusMax(); double getRadiusMin(); double getMassMax(); double getMassMin(); double getCoeffOfRestitutionMax(); double getCoeffOfRestitutionMin(); double getVelMax(); double getVelMin(); private slots: void on_buttonBox_accepted(); void on_buttonBox_rejected(); void on_vel_min_valueChanged(double value); void on_vel_max_valueChanged(double value); void on_cr_min_valueChanged(double value); void on_cr_max_valueChanged(double value); void on_mass_min_valueChanged(double value); void on_mass_max_valueChanged(double value); void on_radius_min_valueChanged(double value); void on_radius_max_valueChanged(double value); private: Ui::SphereGenerator *ui; SphereGenSettings m_settings; }; #endif // SPHEREGENERATOR_H
15fbf1488fb674be9ffd0fff42c05a3d515751f9
28ba55f26d0e49502a6a7dcd7ca7359f9c9eb2af
/다리 만들기(dfs 시간초과).cpp
eff5b723df43ce90204d251e4afe90bbb1a7ee1e
[]
no_license
moonshot2/BOJ
7fcea32d703064843050756af403db2043ce299d
37d38608d65a5ba332a57d6b31ef129fedf469a8
refs/heads/master
2023-06-22T20:01:13.693826
2021-07-22T06:55:24
2021-07-22T06:55:24
138,481,939
0
0
null
null
null
null
UHC
C++
false
false
1,593
cpp
다리 만들기(dfs 시간초과).cpp
#include <iostream> using namespace std; int n; int map[101][101]; bool visit[101][101]; int check[101][101]; int xy[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }; int MIN = 9876; void min(int a, int b) { if (a < b) MIN = a; else MIN = b; } void dfs(int y, int x, int cnt) { visit[y][x] = true; map[y][x] = cnt; //몇번 섬인지 표시 for (int i = 0; i < 4; i++) { int nextY = y + xy[i][1]; int nextX = x + xy[i][0]; if (0 <= nextY && nextY < n && 0 <= nextX && nextX < n) if (map[nextY][nextX] == 1 && !visit[nextY][nextX]) dfs(nextY, nextX, cnt); } } int line = 0; void find(int y, int x, int cnt, int s) { if (y >= 0 && y < n && x >= 0 && x < n) { if (map[y][x] != 0 && map[y][x] != s) { min(MIN, cnt); return; } if (map[y][x] != 0 || map[y][x] == s || check[y][x] == 1 || MIN < cnt) { return; } check[y][x] = 1; find(y, x + 1, cnt + 1, s); find(y, x - 1, cnt + 1, s); find(y + 1, x, cnt + 1, s); find(y - 1, x, cnt + 1, s); check[y][x] = 0; return; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> map[i][j]; } } int cnt = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (map[i][j] == 1 && !visit[i][j]) { dfs(i, j, cnt++); } } } for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { if (map[j][k] != 0) { find(j + 1, k, 0, map[j][k]); find(j - 1, k, 0, map[j][k]); find(j, k + 1, 0, map[j][k]); find(j, k - 1, 0, map[j][k]); } } } cout << MIN; }
e67e97a347458b6f692f6708d9904541e0a1cf53
ce5e253b71be0bb49d239114b0c02b94f715dfe8
/code/base/export/base_datatypes.h
4251cc6651f2dfb10832b030b8b3cea2f1923a5f
[]
no_license
PrabhuSammandam/JaSmartObject
fcc2516a685fc985cc35e49b8c8661536197727c
c9e6df7ed9ef9c0c6ff5c8e4c7ded9e86cc0fe0d
refs/heads/master
2021-01-22T01:47:53.503329
2018-12-21T14:37:17
2018-12-21T14:37:17
102,236,037
0
0
null
null
null
null
UTF-8
C++
false
false
469
h
base_datatypes.h
/* * base_datatypes.h * * Created on: Dec 6, 2018 * Author: psammand */ #pragma once #include <cstdint> namespace ja_iot { namespace base { struct data_buffer_t { data_buffer_t(){} data_buffer_t( uint8_t *pu8_data, uint16_t u16_data_len ) : _pu8_data{ pu8_data }, _u16_data_len{ u16_data_len } {} bool is_valid() { return ( _pu8_data != nullptr && _u16_data_len > 0 ); } uint8_t * _pu8_data = nullptr; uint16_t _u16_data_len = 0; }; } }
7f406ca1217845839f1b4a3a1515bc313377e849
ce7cd2b2f9709dbadf613583d9816c862003b38b
/SRC/engine/steperrorscaling.swg
c7ebcbf28c37519d68b69fbf5ca5364ab7a8c434
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
usnistgov/OOF3D
32b01a25154443d29d0c44d5892387e8ef6146fa
7614f8ea98a095e78c62c59e8952c0eb494aacfc
refs/heads/master
2023-05-25T13:01:20.604025
2022-02-18T20:24:54
2022-02-18T20:24:54
29,606,158
34
7
null
2015-02-06T19:56:26
2015-01-21T19:04:14
Python
UTF-8
C++
false
false
1,318
swg
steperrorscaling.swg
// -*- C++ -*- /* This software was produced by NIST, an agency of the U.S. government, * and by statute is not subject to copyright in the United States. * Recipients of this software assume all responsibilities associated * with its operation, modification and maintenance. However, to * facilitate maintenance we ask that before distributing modified * versions of this software, you first contact the authors at * oof_manager@nist.gov. */ #ifndef STEPERRORSCALING_SWG #define STEPERRORSCALING_SWG %module steperrorscaling %include "engine/typemaps.swg" %pragma(python) include="steperrorscaling.spy" %{ #include "common/doublevec.h" #include "engine/steperrorscaling.h" %} class StepErrorScaling { public: bool globalscaling(); %addmethods { double __call__(double deltat, DoubleVec &start, DoubleVec &end0, DoubleVec &end1) { return (*self)(deltat, start, end0, end1); } } }; class RelativeErrorScaling : public StepErrorScaling { public: RelativeErrorScaling(); }; class AbsoluteErrorScaling : public StepErrorScaling { public: AbsoluteErrorScaling(); }; class XOverErrorScaling : public StepErrorScaling { public: XOverErrorScaling(); }; class GlobalErrorScaling : public StepErrorScaling { public: GlobalErrorScaling(); }; #endif // STEPERRORSCALING_SWG
b7d2e15935ea17def149afd4449168e746503bfe
62b238dbe178f289c8b69375328fffd92f9fdd07
/Languages/C++/zero_sum_subarray.cpp
41c27244882cb8c515e7d2c4c71f3ce91862ca72
[ "MIT" ]
permissive
swetasingh0104/Hacktober2021
45df0558177a3378b46e72450fb4d6e7a1bfd43e
e8b896dcf1993b724a7d73e2d33cfd21d106168d
refs/heads/main
2023-08-15T13:14:35.232042
2021-10-06T16:49:42
2021-10-06T16:49:42
414,298,783
1
0
MIT
2021-10-06T16:58:25
2021-10-06T16:58:24
null
UTF-8
C++
false
false
454
cpp
zero_sum_subarray.cpp
#include <bits/stdc++.h> using namespace std; bool zerosubarray(int arr[],int n) { unordered_set<int>s; int presum=0; for(int i=0;i<n;i++) { presum+=arr[i]; if(presum==0) return true; if(s.find(presum)!=s.end()) return true; s.insert(presum); } return false; } int main() { int arr[]={-3,4,-3,4,1,-5}; int n=6; cout << zerosubarray(arr, n); return 0; }
c8d20e673d704a5299bcac4e4508f0027d1da54f
aa62761e127f1fca3fd6f9aa8b3a3ee83381d38b
/die_roll.cpp
4a49dc7aa8f868a944fa14e7e397399d4edb27d4
[]
no_license
vickymhs/CodeForces-Submissions
60487bd33e5ea2bae0c55685ad75b284a15d2cef
7406daf60c9c977ba2d4d2222e148b65fa4d41fa
refs/heads/master
2020-06-25T04:01:01.177983
2019-10-31T12:18:37
2019-10-31T12:18:37
199,194,765
0
0
null
null
null
null
UTF-8
C++
false
false
367
cpp
die_roll.cpp
#include<bits/stdc++.h> using namespace std; int main() { int y,w,d,c=0,i; cin>>y>>w; i=max(y,w); for(int j=i;j<=6;j++) c++; switch(c) { case 1:cout<<"1/6"; break; case 2:cout<<"1/3"; break; case 3:cout<<"1/2"; break; case 4:cout<<"2/3"; break; case 5:cout<<"5/6"; break; case 6:cout<<"1/1"; break; default:cout<<"0"; break; } }
b6324e17ad2655ec6dc92c227eae1bbfd327fa5d
a5a99f646e371b45974a6fb6ccc06b0a674818f2
/RecoTracker/TkDetLayers/src/PixelRod.cc
ed9ab9941190fcf1a8867d692d1b36a5122189c4
[ "Apache-2.0" ]
permissive
cms-sw/cmssw
4ecd2c1105d59c66d385551230542c6615b9ab58
19c178740257eb48367778593da55dcad08b7a4f
refs/heads/master
2023-08-23T21:57:42.491143
2023-08-22T20:22:40
2023-08-22T20:22:40
10,969,551
1,006
3,696
Apache-2.0
2023-09-14T19:14:28
2013-06-26T14:09:07
C++
UTF-8
C++
false
false
3,812
cc
PixelRod.cc
#include "PixelRod.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h" #include "TrackingTools/DetLayers/interface/DetLayerException.h" using namespace std; typedef GeometricSearchDet::DetWithState DetWithState; PixelRod::PixelRod(vector<const GeomDet*>& theInputDets) : DetRodOneR(theInputDets.begin(), theInputDets.end()) { theBinFinder = BinFinderType(theDets.begin(), theDets.end()); //--------- DEBUG INFO -------------- LogDebug("TkDetLayers") << "==== DEBUG PixelRod ====="; for (vector<const GeomDet*>::const_iterator i = theDets.begin(); i != theDets.end(); i++) { LogDebug("TkDetLayers") << "PixelRod's Det pos z,perp,eta,phi: " << (**i).position().z() << " , " << (**i).position().perp() << " , " << (**i).position().eta() << " , " << (**i).position().phi(); } LogDebug("TkDetLayers") << "==== end DEBUG PixelRod ====="; //-------------------------------------- } PixelRod::~PixelRod() {} const vector<const GeometricSearchDet*>& PixelRod::components() const { throw DetLayerException("PixelRod doesn't have GeometricSearchDet components"); } pair<bool, TrajectoryStateOnSurface> PixelRod::compatible(const TrajectoryStateOnSurface& ts, const Propagator&, const MeasurementEstimator&) const { edm::LogError("TkDetLayers") << "temporary dummy implementation of PixelRod::compatible()!!"; return pair<bool, TrajectoryStateOnSurface>(); } void PixelRod::compatibleDetsV(const TrajectoryStateOnSurface& startingState, const Propagator& prop, const MeasurementEstimator& est, std::vector<DetWithState>& result) const { typedef MeasurementEstimator::Local2DVector Local2DVector; TrajectoryStateOnSurface ts = prop.propagate(startingState, specificSurface()); if (!ts.isValid()) return; GlobalPoint startPos = ts.globalPosition(); int closest = theBinFinder.binIndex(startPos.z()); pair<bool, TrajectoryStateOnSurface> closestCompat = theCompatibilityChecker.isCompatible(theDets[closest], startingState, prop, est); if (closestCompat.first) { result.push_back(DetWithState(theDets[closest], closestCompat.second)); } else { if (!closestCompat.second.isValid()) return; // to investigate why this happens } const Plane& closestPlane(theDets[closest]->specificSurface()); Local2DVector maxDistance = est.maximalLocalDisplacement(closestCompat.second, closestPlane); float detHalfLen = theDets[closest]->surface().bounds().length() / 2.; // explore neighbours for (size_t idet = closest + 1; idet < theDets.size(); idet++) { LocalPoint nextPos(theDets[idet]->surface().toLocal(closestCompat.second.globalPosition())); if (std::abs(nextPos.y()) < detHalfLen + maxDistance.y()) { if (!add(idet, result, startingState, prop, est)) break; } else { break; } } for (int idet = closest - 1; idet >= 0; idet--) { LocalPoint nextPos(theDets[idet]->surface().toLocal(closestCompat.second.globalPosition())); if (std::abs(nextPos.y()) < detHalfLen + maxDistance.y()) { if (!add(idet, result, startingState, prop, est)) break; } else { break; } } } void PixelRod::groupedCompatibleDetsV(const TrajectoryStateOnSurface&, const Propagator&, const MeasurementEstimator&, std::vector<DetGroup>&) const { LogDebug("TkDetLayers") << "dummy implementation of PixelRod::groupedCompatibleDets()"; }
3fedffd0051f9511e76c8e76d719aadb7f3a06dd
81e132452000d7c5f7ffe9e29140f8dc1d769f4d
/project/PlatformHttpServer/main.cpp
06373901362f3cf2825f5674a0a99e72a766e969
[]
no_license
commshare/nanomsg_demo
3f1f5fbf452557ba749516ddfd8920658106b9b8
6c2094d85029e2ecf3f3af13df892df67bff9458
refs/heads/master
2020-03-30T15:25:41.099955
2017-09-08T08:09:20
2017-09-08T08:10:41
null
0
0
null
null
null
null
GB18030
C++
false
false
808
cpp
main.cpp
// PlatformHttpServer.cpp : Defines the entry point for the console application. // #include <stdio.h> #include <signal.h> #include <algorithm> #include <event2/thread.h> #include "libproperties.h" #include "http_server_business.h" #include "net.h" #include "lw_util.h" int main(int argc, char** argv) { if (argc < 2) return 0; SocketInit s; //如果要启用IOCP,创建event_base之前,必须调用evthread_use_windows_threads()函数 #ifdef WIN32 evthread_use_windows_threads(); #endif int hport = 9877; Properties Pro; if (Pro.loadFromXML(argv[1])) { std::string shport = Pro.getProperty("port", "9877"); hport = std::atoi(shport.c_str()); __create_http_service_business(hport); while (1) { lw_sleep(1); } } else { std::cout << "falue" << std::endl; } return 0; }
aa59798e3b073c39de311688c6e895de7e0e0dcc
a5c8941d7f8face4962f506a584edb0efbd16ca6
/develop/uvsecure/uvsecure-examples/tcp-secure/sighandler.cpp
c397fc1d9476cd61de814dcf13aab635cca8268b
[ "MIT" ]
permissive
motoyang/sf315
3e365bc1c9dd91d7913a65aaeccf2594e95c3eae
9ed5affd2c815068793e24932af877cc4aad86c1
refs/heads/master
2023-06-27T09:10:27.821676
2020-01-04T15:20:22
2020-01-04T15:20:22
119,141,655
1
1
MIT
2023-06-14T16:07:58
2018-01-27T07:02:33
C++
UTF-8
C++
false
false
1,253
cpp
sighandler.cpp
#include <signal.h> #include <sys/types.h> #include <unistd.h> #include <uvplus.hpp> #include "secureacceptor.h" #include "business.h" #include "sighandler.h" extern uvplus::TcpAcceptor *g_acceptor; extern Business *g_business; // -- // SIGUSR2 handler void sig12_handler(int signum, siginfo_t *info, void *myact) { LOG_INFO << "received signal: " << signum << " and tag: " << info->si_int; if (info->si_int == (int)uvplus::TcpAcceptor::NotifyTag::NT_CLOSE) { g_business->stop(); } g_acceptor->notify(info->si_int); } // SIGPIPE handler void sig13_ignore() { struct sigaction sa; sa.sa_handler = SIG_IGN; //设定接受到指定信号后的动作为忽略 sa.sa_flags = 0; if (sigemptyset(&sa.sa_mask) == -1 || //初始化信号集为空 sigaction(SIGPIPE, &sa, 0) == -1) { //屏蔽SIGPIPE信号 perror("failed to ignore SIGPIPE; sigaction"); exit(EXIT_FAILURE); } } // -- int sig_capture(int sig, sig_action action) { struct sigaction act; sigemptyset(&act.sa_mask); act.sa_sigaction = action; act.sa_flags = SA_SIGINFO; return sigaction(sig, &act, NULL); } int sig_send(pid_t pid, int sig, int tag) { union sigval mysigval; mysigval.sival_int = tag; return sigqueue(pid, sig, mysigval); }
380f17d1fdba80a5e12c2c59485943fc04d7a893
8087268aabb90ca3aa4e655b47e9d61e812a31b2
/T4/main.cpp
1fd14e63d3b731db3d59adbe4012e042c91d29f0
[]
no_license
Edson-source/Prog_II
c68547d045f5131f06f4dedbfb4c2012d79e7b23
4565c0b17a4dd905118edbd576fd49397ce631fb
refs/heads/main
2023-06-19T10:12:15.329079
2021-07-11T14:55:45
2021-07-11T14:55:45
384,952,540
0
0
null
null
null
null
UTF-8
C++
false
false
4,476
cpp
main.cpp
#include "dict.hpp" int main() { vector<Dictionary> listdict; while(true){ if(vrs) cout << "Insert an option" << endl; if(vrs) cout << "1.Insert the dictionary" << endl; if(vrs) cout << "2.Show dicitionaries (all)" << endl; if(vrs) cout << "3.Search (substring for everywhere)" << endl; if(vrs) cout << "4.insert a word (in the last dictionary)" << endl; if(vrs) cout << "5.Remove word (substring all from everywhere)" << endl; if(vrs) cout << "6.Remove duplicate (all from everywhere)" << endl; if(vrs) cout << "0.Quit" << endl; char ch; cin >> ch; // fflush(); cin.ignore(); if (ch == '1') { cout << "Enter a dictionary path:"; string path; cin >> path; Dictionary a(path); if (a.GetSize() > 0) listdict.push_back(a); } if (ch == '2') { for (size_t i = 0; i < listdict.size(); i++) { cout << "Dicitionary ID: " << i << " -> Dictionary path: "<< listdict.at(i).GetPath() << endl; for (size_t j = 0; j < listdict.at(i).GetSize(); j++) { cout << "-> " << listdict.at(i).GetWord(j) << endl; } } cout << "Loaded dicitionaries: " << listdict.size() << endl; } if (ch == '3') { if(vrs) cout << "Enter with a word to be searched" << endl; size_t i=0; string src; cin >> src; for (size_t i = 0; i < listdict.size(); i++) { for (size_t j = 0; j < listdict.at(i).GetSize(); j++) { // cout << "Dicitionary ID: " << "-> Dictionary path: "<< listdict.at(i).GetPath() << endl; bool located = listdict.at(i).GetSubStrings(src, j); if(located) cout << listdict.at(i).GetPath() << endl; } } } if (ch == '4') { cout << "Enter with a new word:"; string newWord; cin >> newWord; listdict.at(listdict.size()-1).Insert(newWord); } if (ch == '5') { if(vrs) cout << "Enter with a word to be removed" << endl; string query; cin >> query; for (size_t i = 0; i < listdict.size(); i++) { for (size_t j = 0; j < listdict.at(i).GetSize(); j++){ listdict.at(i).RemoveSubstring(query, j); } } } if (ch == '6') { if(vrs) cout << "Removing repeted substrings" << endl; vector<string> substring; vector<size_t> w; vector<size_t> v; for (size_t i = 0; i < listdict.size(); i++) { for (size_t j = 0; j < listdict.at(i).GetSize(); j++) { pair<size_t, string> p(j, listdict.at(i).GetWord(j)); substring.push_back(listdict.at(i).GetWord(j)); w.push_back(j); v.push_back(i); } // listdict.at(i).Getduplicates(substring, i); } stable_sort(substring.begin(), substring.end()); cout << "___" << endl; for (size_t i = 0; i < substring.size(); i++) { cout << "dictionary #" << v.at(i) << " " << listdict.at(v.at(i)).GetPath() << "-> word pos: " << w.at(i) << "-> words: " << substring.at(i) << endl; } size_t i=0; size_t acum[listdict.size()]; for (size_t i = 0; i < listdict.size(); i++) { acum[i]=0; } while(i < substring.size()-1) { if(substring.at(i) == substring.at(i+1)) { acum[v.at(i+1)]++; substring.erase(substring.begin() + i+1); } else i++; } for (size_t i = 0; i < substring.size(); i++) { cout << "dict pos:" << v.at(i) << "-> word pos: " << w.at(i) << "-> words: " << substring.at(i) << endl; } for (size_t i = 0; i < listdict.size(); i++) { cout << "dictionary #" << i << " " << listdict.at(i).GetPath() << "-> lost " << acum[i] << " words: " << "-> now has " << listdict.at(i).GetSize()-acum[i] << endl; } } if (ch == '0') { if(vrs) cout << "Saindo" << endl; system("pause"); break; } } /* //chamada do constructor Dictionary d1; //estatico, chama os dois Dictionary *d2 = new Dictionary; //dinamico, chama somente o constructor d1.LoadDictionary("dict.txt");//alocado estaticamente d2->LoadDictionary("dict.txt");//alocado dinamicamente //chamada do destructor delete d2; */ return 0; }
432971d1c97a56291568f8b182e81e5c02962596
ccef180ad9162d596a5c7bd9a86ec8815ec5adee
/primeField/primeP.cpp
a0d01b2f1e36fca5b57a35a8e5450928dbf49fdf
[]
no_license
chatrasen/SP_parallel_lib
68ea413655ca69cb025cefcff8ee0b4d386ef65d
7a67b4ad6d7f647678e13dc0deef0c8b1e645761
refs/heads/master
2020-03-09T01:28:00.066239
2018-04-11T07:17:39
2018-04-11T07:17:39
128,515,204
0
0
null
null
null
null
UTF-8
C++
false
false
5,076
cpp
primeP.cpp
#include <immintrin.h> #include <stdio.h> #include <stdbool.h> #include <stdint.h> #include <time.h> #include <bits/stdc++.h> using namespace std; __m256i ones = _mm256_set_epi64x(1,1,1,1); __m256i val128 = _mm256_set_epi64x(128,128,128,128); __m256i mas = _mm256_set_epi64x(-1,-1,-1,-1); __m256i ONES = _mm256_set_epi16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); void print(__m256i &a) { uint16_t *f = (uint16_t*) &a; for(int i = 0; i < 16; i++) cout<<f[i]<<" "; cout<<"\n"; } void addP(__m256i &a, __m256i &b, __m256i &result){ int * ptr; result = _mm256_add_epi64(a,b); __m256i carry = _mm256_cmpeq_epi64(_mm256_max_epu32(a, result), result); carry = _mm256_add_epi64(carry,ones); ptr = (int *)&carry; carry = _mm256_set_epi64x(ptr[2],ptr[1],ptr[0],0); result = _mm256_add_epi64(result,carry); carry = _mm256_cmpeq_epi64(_mm256_max_epu32(carry, result), result); carry = _mm256_add_epi64(carry,ones); ptr = (int *)&carry; carry = _mm256_set_epi64x(ptr[2],ptr[1],ptr[0],0); result = _mm256_add_epi64(result,carry); } void mulP(__m256i &a,__m256i &b, __m256i *result) { short int *ptr = (short int *) &a; __m256i lo[16],hi[16]; for(int i = 0; i < 16; i++) { lo[i] = _mm256_mullo_epi16(a,b); hi[i] = _mm256_mulhi_epi16(a,b); a = _mm256_set_epi16(ptr[(i)%16],ptr[(i+15)%16],ptr[(i+14)%16],ptr[(i+13)%16],ptr[(i+12)%16],ptr[(i+11)%16],ptr[(i+10)%16],ptr[(i+9)%16],ptr[(i+8)%16],ptr[(i+7)%16],ptr[(i+6)%16],ptr[(i+5)%16],ptr[(i+4)%16],ptr[(i+3)%16],ptr[(i+2)%16],ptr[(i+1)%16]); } short int *loptr[16], *hiptr[16]; for(int i = 0; i < 16; i++) { loptr[i] = (short int *) &lo[i]; hiptr[i] = (short int *) &hi[i]; } short int Mlo[31][16], Mhi[31][16], M[32][32]; memset(M,0,sizeof(M)); memset(Mlo,0,sizeof(Mlo)); memset(Mhi,0,sizeof(Mhi)); for(int x = 0; x < 31; x++) { int h = 0,i = (x < 16)?(x)%16 : (30-x)%16; int j = (x < 16)? 0 : (15-i); //cout<<"i = "<<i<<"j = "<<j<<"\n"; while(1) { Mlo[x][h] = loptr[i][j]; Mhi[x][h] = hiptr[i][j]; i = (i+2)%16; j++; h++; if( j > 15 || h > x) break; } } for(int i = 0; i < 31; i++) { int h = 0; if(i - 1 >= 0) { for(int j = 0; j < min(i,16); j++) M[i][h++] = Mhi[i-1][j]; } if(i <= 30) { for(int j = 0; j < min(i+1,16); j++) M[i][h++] = Mlo[i][j]; } } __m256i carry[2], shift_carry[2]; for(int h = 0; h <2; h++) { result[h] = _mm256_set_epi16(M[15+16*h][0],M[14+16*h][0],M[13+16*h][0],M[12+16*h][0],M[11+16*h][0],M[10+16*h][0],M[9+16*h][0],M[8+16*h][0],M[7+16*h][0],M[6+16*h][0],M[5+16*h][0],M[4+16*h][0],M[3+16*h][0],M[2+16*h][0],M[1+16*h][0],M[0+16*h][0]); carry[h] = _mm256_set_epi16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); __m256i temp,temp_carry; for(int i = 1; i < 32; i++) { temp = _mm256_set_epi16(M[15+16*h][i],M[14+16*h][i],M[13+16*h][i],M[12+16*h][i],M[11+16*h][i],M[10+16*h][i],M[9+16*h][i],M[8+16*h][i],M[7+16*h][i],M[6+16*h][i],M[5+16*h][i],M[4+16*h][i],M[3+16*h][i],M[2+16*h][i],M[1+16*h][i],M[0+16*h][i]); result[h] = _mm256_add_epi16(temp,result[h]); short int *f = (short int*) &result[h]; temp_carry = _mm256_cmpeq_epi16(_mm256_max_epi16(temp, result[h]), result[h]); temp_carry = _mm256_add_epi16(temp_carry,ONES); carry[h] = _mm256_add_epi16(carry[h],temp_carry); f = (short int*) &carry[h]; } } short int *cptr1 = (short int*) &carry[0]; short int *cptr2 = (short int*) &carry[1]; shift_carry[0] = _mm256_set_epi16(cptr1[1],cptr1[2],cptr1[3],cptr1[4],cptr1[5],cptr1[6],cptr1[7],cptr1[8],cptr1[9],cptr1[10],cptr1[11],cptr1[12],cptr1[13],cptr1[14],cptr1[15],0); short int *f = (short int*) &result[0]; f = (short int*) &shift_carry[0]; addP(result[0],shift_carry[0],result[0]); shift_carry[1] = _mm256_set_epi16(cptr2[1],cptr2[2],cptr2[3],cptr2[4],cptr2[5],cptr2[6],cptr2[7],cptr2[8],cptr2[9],cptr2[10],cptr2[11],cptr2[12],cptr2[13],cptr2[14],cptr2[15],0); addP(result[1],shift_carry[1],result[1]); } int main(){ srand((unsigned int)time(NULL)); __m256i a = _mm256_set_epi16(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2); __m256i b = _mm256_set_epi16(16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1); __m256i result[2]; __m256i temp; clock_t start,end; int i; start = clock(); for(i=0; i<1000000; i++){ addP(a,b,temp); } end = clock(); cout<<"a : "; print(a); cout<<"b : "; print(b); cout<<"result : "; print(temp); printf("addition time taken by parallel code = %.10lf\n", (double)(end-start)/CLOCKS_PER_SEC); start = clock(); for(i=0; i<1000000; i++){ mulP(a,b,result); } end = clock(); short int *f = (short int*) &a; cout<<"a : "; for(int j = 0; j < 16; j++) cout<<f[j]<<" "; cout<<"\n"; f = (short int*) &b; cout<<"b : "; for(int j = 0; j < 16; j++) cout<<f[j]<<" "; cout<<"\n"; f = (short int*) &result[0]; cout<<"result[0] : "; for(int j = 0; j < 16; j++) cout<<f[j]<<" "; cout<<"\n"; f = (short int*) &result[1]; cout<<"result[1] : "; for(int j = 0; j < 16; j++) cout<<f[j]<<" "; cout<<"\n"; printf("multiplication time taken by parallel code = %.10lf\n", (double)(end-start)/CLOCKS_PER_SEC); return 0; }
ece53fbb7568572d901b5ad54afedbadd1f24e49
17428319e1bbbbae95e6dae94b9ca7b42d59a5fd
/src/Obj/OsaekTimeCtrl/OsaekTimeCtrl.h
907929dce82855950011085485cb6540476221a9
[]
no_license
aBetschart/JudoScoreBoard
d85b6057b44ea89aeb6a532aa4f2f22164984be1
4afb40255ff5a0b9d66da1a6a3f7a6c1035c4bd9
refs/heads/master
2020-03-21T08:35:08.378177
2018-07-31T09:56:12
2018-07-31T09:56:12
138,352,480
0
0
null
null
null
null
UTF-8
C++
false
false
2,241
h
OsaekTimeCtrl.h
/////////////////////////////////////////////////////////// // OsaekTimeCtrl.h // Implementation of the Class OsaekTimeCtrl // Created on: 29-Nov-2017 14:35:09 // Original author: Aaron /////////////////////////////////////////////////////////// #if !defined(EA_66C9942B_FF0D_4316_8A7E_24DF28EB5DAF__INCLUDED_) #define EA_66C9942B_FF0D_4316_8A7E_24DF28EB5DAF__INCLUDED_ //-------------------------------------------------------------- // -- includes //-------------------------------------------------------------- #include "../OsaekTime/OsaekTime.h" #include "../../PltFrm/BtnDebounce/BtnDebounce.h" #include "../../PltFrm/Btn/Btn.h" #include "../../EvHandler/IBtnEvHandler.h" #include "../../EvHandler/IOsaekTimeEvHandler.h" //-------------------------------------------------------------- class IOsaekCtrlEvHandler; namespace Obj { class JudoDisplay; class FightCtrl; class OsaekTimeCtrl : public IOsaekTimeEvHandler, public IBtnEvHandler { public: enum OsaekCtrlEv { // Controlling events evStartBl, evStartWh, evStopBl, evStopWh, evIpponTime, evWazariTime, // Events, which trigger the event handlers evOsaekOver, evIpponTimeBl, evWazariTimeBl, evIpponTimeWh, evWazariTimeWh }; enum { nrOfEvHandlers = 1 }; OsaekTimeCtrl( JudoDisplay* displ, FightCtrl* fightCtrl ); virtual ~OsaekTimeCtrl(); void process( const OsaekCtrlEv& ev ); bool osaekomiRunning(); void registerOnEv( IOsaekCtrlEvHandler* handler ); virtual void onOsaekTimeEv( const Obj::OsaekTime::OsaekTimeEv& ev ); virtual void onButtonEv( const PltFrm::Btn::BtnInstance& btn ); protected: void notify( const OsaekCtrlEv& ev ); private: enum OsaekTimeCtrlState { stateOsaekBl, stateOsaekWh, stateStop }; OsaekTimeCtrlState mState; OsaekTime mOsaekTime; PltFrm::BtnDebounce mBtnDeb; FightCtrl* mFightCtrl; PltFrm::Btn osaekBlBtn; PltFrm::Btn osaekWhBtn; IOsaekCtrlEvHandler* evHandler[nrOfEvHandlers]; }; } // namespace Obj #endif // !defined(EA_66C9942B_FF0D_4316_8A7E_24DF28EB5DAF__INCLUDED_)
a94f70e3824c3c76301ad57e8416d62feb62b1cc
17310661cbaea41d68baea32c2a977f80f46751f
/Source/CollisionWar/SRC/Base/Widget/TemplateComboBox.h
7bbb5014d49db94a565acba908e96c18960ad80f
[]
no_license
VectorL1990/CollisionWarBackup
5540807c23193215d0a50e4826978d5f2430c243
8e263ab498f9097c57f6a1ef78719607b66cfc9f
refs/heads/main
2023-04-10T15:17:05.678311
2021-04-23T08:16:05
2021-04-23T08:16:05
357,766,090
0
0
null
2021-04-23T08:16:05
2021-04-14T03:51:57
C++
UTF-8
C++
false
false
1,308
h
TemplateComboBox.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Blueprint/UserWidget.h" #include "TextBlock.h" #include "ComboBoxString.h" #include "TemplateComboBox.generated.h" /** * */ USTRUCT(BlueprintType, Blueprintable) struct FComboBoxDefaultInfo { GENERATED_USTRUCT_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CollisionWar/Common") FString comboboxTitle; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CollisionWar/Common") FString chcomboboxTitle; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CollisionWar/Common") TArray<FString> comboboxOptions; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CollisionWar/Common") FString chcomboboxFunction; }; UCLASS() class COLLISIONWAR_API UTemplateComboBox : public UUserWidget { GENERATED_BODY() public: UFUNCTION(BlueprintNativeEvent, Category = "CollisionWar/Widget") void NotifyInitial(); UFUNCTION(BlueprintCallable, Category = "CollisionWar") void ComboSelectionChange(FString selectItem); UPROPERTY(BlueprintReadWrite, Category = "CollisionWar/Widget") UComboBoxString * m_pComboBox; UPROPERTY(BlueprintReadWrite, Category = "CollisionWar/Widget") UTextBlock* m_pCaption; FString m_function; };
93d69a3649ec49b1436f2becd4dac6d9ef50177b
7149bff09854339f72134820b966dd80f2bae5e1
/SegmentedSieve.cpp
c299abe9f052774bc68383f6256b7a2076259645
[]
no_license
mdirshad17/MATHS
14c9c07fa7bdc995c0404625d12a93898e8e6764
675bdbd9b03e3282aaa4a06edb96d49f34419982
refs/heads/main
2023-07-18T15:26:59.012899
2021-09-08T07:27:11
2021-09-08T07:27:11
381,811,875
0
0
null
null
null
null
UTF-8
C++
false
false
674
cpp
SegmentedSieve.cpp
#include <bits/stdc++.h> using namespace std; void SegmentedSieve(int l,int r) { int x=sqrt(r); vector<bool> v(x+1,true); v[0]=false; v[1]=false; for(int i=2;i<=sqrt(x);i++) { if(v[i]) for(int j=i*i;j<=x;j+=i) v[j]=false; } vector<bool> v1(r-l+1,true); for(int i=2;i<=x;i++) { if(v[i]==true) { for(int j=l;j<=r;j++) { if(j%i==0) { v1[j-l]=false; } } } } for (int i = l; i <=r; ++i) { if(v1[i-l]) { cout<<i<<" "; } } } int main() { int t; cin>>t; int l,r; while(t--) { cin>>l>>r; SegmentedSieve(l,r); cout<<endl; } return 0; }
6c59b63b44c4d025e551d2414284c06471334ed3
cf39355caa609c0f33405126beee2739aa3cb77e
/src/library/metavar_util.h
4a3b675e1be6d5575298dcbaad404292a83e8756
[ "Apache-2.0" ]
permissive
leanprover-community/lean
12b87f69d92e614daea8bcc9d4de9a9ace089d0e
cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0
refs/heads/master
2023-06-23T08:15:56.644949
2023-05-24T17:58:24
2023-05-24T17:58:24
169,960,991
457
107
Apache-2.0
2023-06-14T12:06:12
2019-02-10T09:17:48
C++
UTF-8
C++
false
false
6,930
h
metavar_util.h
/* Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include "kernel/instantiate.h" #include "library/replace_visitor.h" #include "library/delayed_abstraction.h" namespace lean { /* Helper functions for metavariable assignments. The template parameter CTX must be an object that provides the following API: bool is_mvar(level const & l) const; bool is_assigned(level const & l) const; optional<level> get_assignment(level const & l) const; void assign(level const & u, level const & v); bool is_mvar(expr const & e) const; bool is_assigned(expr const & e) const; optional<expr> get_assignment(expr const & e) const; void assign(expr const & m, expr const & v); push_delayed_abstraction bool in_tmp_mode() const; */ template<typename CTX> bool has_assigned(CTX const & ctx, level const & l) { if (!has_meta(l)) return false; bool found = false; for_each(l, [&](level const & l) { if (!has_meta(l)) return false; // stop search if (found) return false; // stop search if (ctx.is_mvar(l) && ctx.is_assigned(l)) { found = true; return false; // stop search } return true; // continue search }); return found; } template<typename CTX> bool has_assigned(CTX const & ctx, levels const & ls) { for (level const & l : ls) { if (has_assigned(ctx, l)) return true; } return false; } template<typename CTX> bool has_assigned(CTX const & ctx, expr const & e) { if (!has_expr_metavar(e) && !has_univ_metavar(e)) return false; bool found = false; for_each(e, [&](expr const & e, unsigned) { if (!has_expr_metavar(e) && !has_univ_metavar(e)) return false; // stop search if (found) return false; // stop search if ((ctx.is_mvar(e) && ctx.is_assigned(e)) || (is_constant(e) && has_assigned(ctx, const_levels(e))) || (is_sort(e) && has_assigned(ctx, sort_level(e)))) { found = true; return false; // stop search } if (is_metavar(e)) return false; // do not search type return true; // continue search }); return found; } template<typename CTX> level instantiate_mvars(CTX & ctx, level const & l) { if (!has_assigned(ctx, l)) return l; return replace(l, [&](level const & l) { if (!has_meta(l)) { return some_level(l); } else if (ctx.is_mvar(l)) { if (auto v1 = ctx.get_assignment(l)) { level v2 = instantiate_mvars(ctx, *v1); if (*v1 != v2) { if (!ctx.in_tmp_mode()) ctx.assign(l, v2); return some_level(v2); } else { return some_level(*v1); } } } return none_level(); }); } template<typename CTX> class instantiate_mvars_fn : public replace_visitor { CTX & m_ctx; bool m_postpone_push_delayed; bool m_found_delayed_abstraction{false}; level visit_level(level const & l) { return instantiate_mvars(m_ctx, l); } levels visit_levels(levels const & ls) { return map_reuse(ls, [&](level const & l) { return visit_level(l); }, [](level const & l1, level const & l2) { return is_eqp(l1, l2); }); } virtual expr visit_sort(expr const & s) override { return update_sort(s, visit_level(sort_level(s))); } virtual expr visit_constant(expr const & c) override { return update_constant(c, visit_levels(const_levels(c))); } virtual expr visit_local(expr const & e) override { return update_mlocal(e, visit(mlocal_type(e))); } virtual expr visit_meta(expr const & m) override { if (m_ctx.is_mvar(m)) { if (auto v1 = m_ctx.get_assignment(m)) { if (!has_metavar(*v1)) { return *v1; } else { expr v2 = visit(*v1); if (!m_ctx.in_tmp_mode() && v2 != *v1) m_ctx.assign(m, v2); return v2; } } else { return m; } } else { return m; } } virtual expr visit_app(expr const & e) override { buffer<expr> args; expr const & f = get_app_rev_args(e, args); if (m_ctx.is_mvar(f)) { if (auto v = m_ctx.get_assignment(f)) { expr new_app = apply_beta(*v, args.size(), args.data()); if (has_metavar(new_app)) return visit(new_app); else return new_app; } } expr new_f = visit(f); buffer<expr> new_args; bool modified = !is_eqp(new_f, f); for (expr const & arg : args) { expr new_arg = visit(arg); if (!is_eqp(arg, new_arg)) modified = true; new_args.push_back(new_arg); } if (!modified) return e; else return mk_rev_app(new_f, new_args, e.get_tag()); } virtual expr visit_macro(expr const & e) override { lean_assert(is_macro(e)); buffer<expr> new_args; for (unsigned i = 0; i < macro_num_args(e); i++) new_args.push_back(visit(macro_arg(e, i))); expr r = update_macro(e, new_args.size(), new_args.data()); if (is_delayed_abstraction(r)) { if (m_postpone_push_delayed) { m_found_delayed_abstraction = true; } else { return push_delayed_abstraction(r); } } return r; } virtual expr visit(expr const & e) override { if (!has_expr_metavar(e) && !has_univ_metavar(e)) return e; else return replace_visitor::visit(e); } public: instantiate_mvars_fn(CTX & ctx, bool postpone_push_delayed):m_ctx(ctx), m_postpone_push_delayed(postpone_push_delayed) {} expr operator()(expr const & e) { expr r = visit(e); if (m_found_delayed_abstraction) { buffer<name> ns; buffer<expr> es; r = append_delayed_abstraction(r, ns, es); } return r; } }; template<typename CTX> expr instantiate_mvars(CTX & ctx, expr const & e, bool postpone_push_delayed) { if (!has_assigned(ctx, e)) return e; expr r = instantiate_mvars_fn<CTX>(ctx, postpone_push_delayed)(e); lean_assert(!has_assigned(ctx, r)); return r; } }
aa20e44d75d71a307fb60fe4c2ee4a7f630801f0
6e6c1115d3fb51ae368382fa769d672ab94b3fcd
/JigsawPuzzle/src/puzzle_model.h
5d0d0ff83572fb3faad0b1ba2f2ca1430421da8b
[]
no_license
nanbokku/jigsawpuzzle
e642c135fb1eebbd7154f8151521905c07d9816e
2d9f20b05da2459c600931d3629f456ee4fec51b
refs/heads/master
2020-04-08T16:37:21.149537
2018-12-14T02:49:17
2018-12-14T02:49:17
159,526,823
0
0
null
null
null
null
UTF-8
C++
false
false
1,689
h
puzzle_model.h
#pragma once #include <opencv2/opencv.hpp> #include <GL/glut.h> #include "piece_creater.h" #include "piece.h" #include "subject.h" class PuzzleModel : public Subject { public: PuzzleModel(const char* frame_path, const char* file_path); PuzzleModel(const PuzzleModel& model); ~PuzzleModel(); PuzzleModel &operator=(const PuzzleModel& model); void initialize(); void initialize(const char* filePath); bool isPlaying() { return is_playing_; } void isPlaying(bool playing) { is_playing_ = playing; } char* filename() { return filename_; } void filename(const char* n) { if (filename_ != NULL) { delete filename_; filename_ = NULL; } filename_ = new char[strlen(n) + 1]; strcpy(filename_, n); } void framename(const char* n) { if (framename_ != NULL) { delete framename_; framename_ = NULL; } framename_ = new char[strlen(n) + 1]; strcpy(framename_, n); } cv::Mat frame() { return frame_; } void frame(const cv::Mat& m) { frame_ = m; } int pieceNum() { return pieces_.size(); } Piece piece(int index) { return pieces_[index]; } Piece* piece_ptr(int index) { return &pieces_[index]; } void push(const Piece& p) { pieces_.push_back(p); } int textureNum() { return texIds_.size(); } GLuint texId(int index) { return texIds_[index]; } GLuint* texId_ptr(int index) { return &(texIds_[index]); } void push(const GLuint& id) { texIds_.push_back(id); } void fit(int label); private: bool is_playing_ = false; char* filename_ = NULL; char* framename_ = NULL; cv::Mat frame_; std::vector<Piece> pieces_; std::vector<GLuint> texIds_; PieceCreater creater_; };
3306d10d8615767f2e4d4644e4b2a6cfa8bbc8ab
32bfc176a5db0d59129f3c39381c46b0a520eb86
/demos/QMPlay/src/plugins/func_associate/incl/func.cpp
16173bd2f3ae02dcf880ef497aa09d18c66d4404
[]
no_license
varzhou/Hifi-Pod
2fb4c6bd3172720f8813fbbdf48375a10598a834
eec4e27e37bc5d99b9fddb65be06ef5978da2eee
refs/heads/master
2021-05-28T18:26:14.507496
2012-09-16T05:45:28
2012-09-16T05:45:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,705
cpp
func.cpp
void opcje(QWidget*) { } void setSize( QSize s ) { QRect g; g.setX(0); g.setY(0); g.setHeight(s.height()); g.setWidth(s.width()); f1.setGeometry(g); } void Show(QWidget *w) { if(w) { w->setMinimumSize( f1.minimumSize() ); w->setMaximumSize( f1.maximumSize() ); tmpWidget = w; } f1.setParent(tmpWidget); f1.move(0,0); f1.show(); } void getOutLib(Qmp *_QLib) { QLib = _QLib; } void Init() { QMPConf = QLib->getFileName( QMP_CONF ); libExt = QLib->getFileName( OS_LIBEXT ); f1.Init(); } void closePlug() { f1.setParent(NULL); f1.close(); } void about(QWidget *w) { QMessageBox::information(w,"QMPlay","Associate with QMP!"); } void setLang( QString langfile ) { Texts.clear(); QMPset = new QSettings( langfile , QSettings::IniFormat ); QMPset->setIniCodec( "UTF-8" ); for ( int i = 0 ; i < langCount ; i++ ) Texts += QMPset->value( "QAssociate/" + QString::number(i) ).toString(); f1.ui.onRunB->setText( QMPset->value( "QAssociateWindow/0" ).toString() ); f1.ui.selAllB->setText( QMPset->value( "QAssociateWindow/1" ).toString() ); f1.ui.revSelB->setText( QMPset->value( "QAssociateWindow/2" ).toString() ); f1.ui.addB->setText( QMPset->value( "QAssociateWindow/3" ).toString() ); f1.ui.delB->setText( QMPset->value( "QAssociateWindow/4" ).toString() ); f1.ui.getExtsB->setText( QMPset->value( "QAssociateWindow/5" ).toString() ); f1.ui.clrB->setText( QMPset->value( "QAssociateWindow/6" ).toString() ); f1.ui.applyB->setText( QMPset->value( "QAssociateWindow/7" ).toString() ); f1.ui.extsList->setWhatsThis( QMPset->value( "QAssociateWindow/8" ).toString() ); f1.ui.extsE->setToolTip( QMPset->value( "QAssociateWindow/9" ).toString() ); delete QMPset; }
6ad06a2df41a13ec111509eac9320182d455f99a
334b3f43e1d2ee4c519b8d715eb146934af5a565
/src/10195.cpp
e9e22c97af5e525ff350c1be36548750549712ac
[]
no_license
cloudrick/UVaOnlineJudge
2bf423ab898f9ef554e64116549c2ed0a4ef2678
8effc51a3bb780bb04c08cb60a5a061cb5b72b0c
refs/heads/master
2021-01-17T05:04:19.884803
2017-02-24T17:32:13
2017-02-24T17:32:13
83,065,710
0
0
null
null
null
null
UTF-8
C++
false
false
368
cpp
10195.cpp
#include<stdio.h> #include<math.h> int main() { double a,b,c,s ; while(scanf("%lf%lf%lf",&a,&b,&c)==3){ if(a<=0.0||b<=0.0||c<=0.0|| a+b<=c||b+c<=a||a+c<=b){ printf("The radius of the round table is: 0.000\n") ; continue ; } s = (a+b+c)/2 ; printf("The radius of the round table is: %.3lf\n",2*sqrt(s*(s-a)*(s-b)*(s-c))/(a+b+c)) ; } return 0 ; }
13424ea5b256a263a8732ea46ed9d703bc9a2450
5db3009eb36afe7110ed5402be3a9e570c58c540
/my_plugins/YouCompleteMe/third_party/ycmd/cpp/ycm/IdentifierCompleter.h
9774c3f89ace916d273430f57d79a2bcd2ad804a
[ "GPL-3.0-only", "GPL-1.0-or-later", "MIT" ]
permissive
imfangli/vimrc
ced2c6caece1cf19421c6ea7deb017bec4ca3a27
d2d14e7d083d70cc8627ddccb5b99c53c3c38be3
refs/heads/master
2022-02-01T00:34:31.855421
2022-01-22T15:57:28
2022-01-22T15:57:28
211,766,038
2
0
MIT
2019-09-30T03:15:03
2019-09-30T03:15:02
null
UTF-8
C++
false
false
2,693
h
IdentifierCompleter.h
// Copyright (C) 2011, 2012 Google Inc. // // This file is part of ycmd. // // ycmd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ycmd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with ycmd. If not, see <http://www.gnu.org/licenses/>. #ifndef COMPLETER_H_7AR4UGXE #define COMPLETER_H_7AR4UGXE #include "IdentifierDatabase.h" #include <string> #include <vector> namespace YouCompleteMe { class Candidate; class IdentifierCompleter { public: IdentifierCompleter( const IdentifierCompleter& ) = delete; IdentifierCompleter& operator=( const IdentifierCompleter& ) = delete; YCM_EXPORT IdentifierCompleter() = default; YCM_EXPORT explicit IdentifierCompleter( std::vector< std::string > candidates ); YCM_EXPORT IdentifierCompleter( std::vector< std::string >&& candidates, const std::string &filetype, const std::string &filepath ); void AddIdentifiersToDatabase( std::vector< std::string > new_candidates, const std::string &filetype, const std::string &filepath ); // Same as above, but clears all identifiers stored for the file before adding // new identifiers. void ClearForFileAndAddIdentifiersToDatabase( std::vector< std::string > new_candidates, const std::string &filetype, const std::string &filepath ); YCM_EXPORT void AddIdentifiersToDatabaseFromTagFiles( const std::vector< std::string > &absolute_paths_to_tag_files ); void AddIdentifiersToDatabaseFromBuffer( const std::string &buffer_contents, const std::string &filetype, const std::string &filepath, bool collect_from_comments_and_strings ); // Only provided for tests! YCM_EXPORT std::vector< std::string > CandidatesForQuery( std::string&& query, const size_t max_candidates = 0 ) const; YCM_EXPORT std::vector< std::string > CandidatesForQueryAndType( std::string query, const std::string &filetype, const size_t max_candidates = 0 ) const; private: ///////////////////////////// // PRIVATE MEMBER VARIABLES ///////////////////////////// IdentifierDatabase identifier_database_; }; } // namespace YouCompleteMe #endif /* end of include guard: COMPLETER_H_7AR4UGXE */
9ffc0777408972271a199323c3dffd4967d9d101
f221c2f7a96228d73c193f8ccdc2aa361bc99067
/src/main.cpp
ed5bbc4d5a6c8f55e824d6d42669c248e423b887
[]
no_license
eullersaez/TP3_Alg1
bbaae7d281fd3b32758044362c61859687d0e495
612e8e3e31a03053d00d2f41e71dc864cc94eff6
refs/heads/main
2023-06-05T16:37:03.576033
2021-06-27T03:36:21
2021-06-27T03:36:21
380,643,040
0
0
null
null
null
null
UTF-8
C++
false
false
1,400
cpp
main.cpp
#include <iostream> #include <sstream> #include "headers/metro.h" int main(){ int N, D, T; std::string linha; //leitura da primeira linha e atribuicao dos valores nas devidas variaveis. std::getline(std::cin,linha); std::istringstream leitura_inicial(linha); leitura_inicial>>N; leitura_inicial>>D; leitura_inicial>>T; metro metro(N,D); //instanciacao e chamada do construtor da classe metro. std::getline(std::cin, linha); //leitura e atribuicao dos descontos acumulados no metro. std::istringstream d_i(linha); for(int i = 0; i < D; i++){ double desconto; d_i>>desconto; metro.insere_desconto_acumulado(i,desconto); } for(int i = 0; i < N; i++){ //leitura e atribuicao dos tempos e precos associados a cada escala. int t_i,c_i; std::getline(std::cin, linha); std::istringstream tempos_e_precos(linha); tempos_e_precos>>t_i; tempos_e_precos>>c_i; metro.insere_preco(i, c_i); metro.insere_tempo_acumulado(i,t_i); } metro.calcula_custo(T); //chamada do metodo calcula_custo() para impressao do resultado. return 0; }
8b21dbe2c788b82c636676d4baeba2318c1808b1
c3be513fad32f52a0b3726eb31cdfee262f867d8
/qmlcamera.cpp
571f7adf4508432558a3642b884b5e664fb40479
[]
no_license
vijiboy/declarative-camera
422b3f7e00b6cbfdd2cedc223eca905176b73945
48047426362dfbe428c46df575f2f7ffe6dff867
refs/heads/master
2021-03-30T18:11:04.688748
2016-02-06T18:36:46
2016-02-06T18:36:46
47,966,210
0
0
null
null
null
null
UTF-8
C++
false
false
5,718
cpp
qmlcamera.cpp
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QGuiApplication> #include <QQuickView> #include <QQmlEngine> #include <QVideoFilterRunnable> #include <QAbstractVideoFilter> #include <QQuickImageProvider> class MyFilterRunnable : public QVideoFilterRunnable { public: QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) { if (!input->isValid()) return *input; input->map(QAbstractVideoBuffer::ReadWrite); // TODO: Get the current frame updated for Demo1 using the application object instance. // DEMO ONLY CODE: Overwriting input buffer with a bigger image for demo purpose only ---- QVideoFrame *output = new QVideoFrame(input->width()*input->height()*2, QSize(input->width()*2,input->height()), input->width()*2, QVideoFrame::Format_RGB32); output->map(QAbstractVideoBuffer::ReadWrite); // Modify the frame in format of your choice finally returning in frame format // e.g. QVideoFrame to QImage or OpenCV (Cv::Mat) image to QVideoFrame // sample code below modifies few pixels of the current frame int firstU = output->width()*output->height()/2; int lastV = output->width()*output->height()/4; uchar* outputBits = output->bits(); for (int i=lastV; i<firstU; i++) outputBits[i] = 127; // graying out a strip from the image output->unmap(); // DEMO ONLY CODE ends here ----- input->unmap(); //emit finished(input); //TODO: check if this works, can help in notifying return *output; //return *input; } }; class MyFilter : public QAbstractVideoFilter { public: QVideoFilterRunnable *createFilterRunnable() { return new MyFilterRunnable; } signals: void finished(QObject *result); }; class ColorImageProvider : public QQuickImageProvider { public: ColorImageProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) { } QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) { // This method, requestPixmap is called at regular interval to refresh the GUI by returning a new QPixmap // For demo purpose we are creating a QPixmap, where a GetMyCurrentFrame API method can be called. // TODO: use the application object instance to get the actual frame for Demo 2 here. int width = 100; int height = 50; if (size) *size = QSize(width, height); QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, requestedSize.height() > 0 ? requestedSize.height() : height); pixmap.fill(QColor(id).rgba()); return pixmap; } }; int main(int argc, char* argv[]) { QGuiApplication app(argc,argv); qmlRegisterType<MyFilter>("my.uri", 1, 0, "MyFilter"); QQuickView view; QQmlEngine *engine = view.engine(); engine->addImageProvider("updatedframeprovider",new ColorImageProvider); // TODO: create/initialise the sole application object here to provide Demo1 and Demo2 frames. // TODO: access this singleton application object in the run method and requestPixMap method defined earlier. view.setResizeMode(QQuickView::SizeRootObjectToView); // Qt.quit() called in embedded .qml by default only emits // quit() signal, so do this (optionally use Qt.exit()). QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit())); view.setSource(QUrl("qrc:///declarative-camera.qml")); view.resize(800, 480); view.show(); view.setTitle("Camera Diagnostics - Demo"); return app.exec(); }
1efa0768faa82c601b0018289e5e4d17943b19a0
89bd52a9964763348915e64705947297d43c9d62
/src/Effetti Carte/Fortuna.hpp
12441a6c61465bcc17a75c0baa135cecf63d5942
[]
no_license
FrancescoCerio/Gioco-dell-oca-pazza
32a80fa1b5f2af07da476ba62ab1a04f15b5387f
c25fd4a21745d1aea820449a06a0bd0ae72d1af1
refs/heads/master
2020-03-12T22:34:24.015899
2018-07-08T14:07:23
2018-07-08T14:07:23
130,849,810
1
4
null
2018-07-08T14:09:32
2018-04-24T12:21:14
C++
UTF-8
C++
false
false
358
hpp
Fortuna.hpp
/* * Fortuna.hpp * * Created on: 01/mag/2018 * Author: polis */ #ifndef FORTUNA_H_ #define FORTUNA_H_ #include "../Carta/Carta.hpp" class Fortuna : public Carta { //sottoclasse di carta public: Fortuna(); void effetto_carta(giocatore* g[], int giocatoreCorrente, int n_giocatori, int dimT); ~Fortuna(); }; #endif /* RILANCIADADO_H_ */
34e7904b5e01a901e979856010e76356098993f9
09e5cfe06e437989a2ccf2aeecb9c73eb998a36c
/modules/cctbx_project/boost_adaptbx/tuple_conversion.h
2461e2d85fefb355efe186357d092e0233619b9b
[ "BSD-3-Clause-LBNL", "BSD-3-Clause" ]
permissive
jorgediazjr/dials-dev20191018
b81b19653624cee39207b7cefb8dfcb2e99b79eb
77d66c719b5746f37af51ad593e2941ed6fbba17
refs/heads/master
2020-08-21T02:48:54.719532
2020-01-25T01:41:37
2020-01-25T01:41:37
216,089,955
0
1
BSD-3-Clause
2020-01-25T01:41:39
2019-10-18T19:03:17
Python
UTF-8
C++
false
false
1,499
h
tuple_conversion.h
#ifndef BOOST_ADAPTBX_TUPLE_CONVERSION_H #define BOOST_ADAPTBX_TUPLE_CONVERSION_H #include <boost/python/tuple.hpp> #include <boost/python/module.hpp> #include <boost/python/refcount.hpp> #include <boost/python/to_python_converter.hpp> #include <boost/tuple/tuple.hpp> /* From a recipe given by David Abraham on C++ sig ( http://mail.python.org/pipermail/c++-sig/2006-January/010067.html ) */ namespace boost_adaptbx { namespace tuple_conversion { namespace detail { /* I don't support get_pytype here because it leads to an infinite tower of recursive calls ending up in a crash. The reason is unknown but I don't have the courage to dig into the dark magic of Boost.Python to elucidate it. Luc Bourhis */ template <class T> struct to_python { template <class Head, class Tail> static inline boost::python::tuple tuple_to_python(boost::tuples::cons<Head, Tail> const& x) { boost::python::tuple head = boost::python::make_tuple(x.get_head()); boost::python::tuple tail = tuple_to_python(x.get_tail()); return boost::python::tuple(head + tail); } static inline boost::python::tuple tuple_to_python(boost::tuples::null_type) { return boost::python::tuple(); } static PyObject * convert(T const& x) { return boost::python::incref(tuple_to_python(x).ptr()); } }; } // namespace detail template<class T> struct to_python { to_python() { boost::python::to_python_converter<T, detail::to_python<T> >(); } }; }} #endif // GUARD
b3ba2044d0f88e8213f5a32d32c77c382de92dc1
76726498127e40a9e1d9e4a2aad38613494bb7d2
/src/logistic.cpp
1741748e03acd22bb2b74eb7f88301a3ba7964f3
[]
no_license
bbbales2/math-benchmarks
ea413edbb5d481016bffcbb87cf307e043b5584b
207e6b5d29b055adcf650d297740092e96c690ec
refs/heads/master
2023-02-05T08:37:32.964850
2020-12-21T20:19:50
2020-12-21T20:19:50
294,805,502
0
2
null
null
null
null
UTF-8
C++
false
false
3,598
cpp
logistic.cpp
#include <benchmark/benchmark.h> #include <stan/math.hpp> #include <utility> #include "toss_me.hpp" #include "callback_bench_impl.hpp" template <typename T1, typename T2, typename T3> struct init { auto operator()(benchmark::State& state) { Eigen::VectorXd y_val = Eigen::VectorXd::Random(state.range(0)); Eigen::VectorXd mu_val = Eigen::VectorXd::Random(state.range(0)); Eigen::VectorXd sigma_val = stan::math::exp(Eigen::VectorXd::Random(state.range(0))); return std::make_tuple(bench_promote<T1>(y_val), bench_promote<T2>(mu_val), bench_promote<T3>(sigma_val)); } }; template <typename Vectorizer, typename... Args> static void logistic_lpdf(benchmark::State& state) { auto run = [](const auto&... args) { return logistic_lpdf(args...); }; callback_bench_impl<Vectorizer>(init<Args...>(), run, state); } template <typename Vectorizer, typename... Args> static void logistic_cdf(benchmark::State& state) { auto run = [](const auto&... args) { return logistic_cdf(args...); }; callback_bench_impl<Vectorizer>(init<Args...>(), run, state); } template <typename Vectorizer, typename... Args> static void logistic_lcdf(benchmark::State& state) { auto run = [](const auto&... args) { return logistic_lcdf(args...); }; callback_bench_impl<Vectorizer>(init<Args...>(), run, state); } template <typename Vectorizer, typename... Args> static void logistic_lccdf(benchmark::State& state) { auto run = [](const auto&... args) { return logistic_lccdf(args...); }; callback_bench_impl<Vectorizer>(init<Args...>(), run, state); } using stan::math::var; int start_val = 2; int end_val = 1024; BENCHMARK(toss_me); BENCHMARK_TEMPLATE(logistic_lpdf,non_vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lpdf,vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_cdf,non_vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_cdf,vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lcdf,non_vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lcdf,vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lccdf,non_vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lccdf,vec,var,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lpdf,non_vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lpdf,vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_cdf,non_vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_cdf,vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lcdf,non_vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lcdf,vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lccdf,non_vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_TEMPLATE(logistic_lccdf,vec,double,var,var)->RangeMultiplier(2)->Range(start_val, end_val)->UseManualTime(); BENCHMARK_MAIN();
5f9313dcdba219d0e6a77aff0e6da046ac6dc7b9
18f2227227b6ecd42155106b116db1a83880267d
/first-stage/PARSE/GotIter.h
de29eae3ff0ba2056e609758d72e336e5a92cde1
[ "Apache-2.0" ]
permissive
jordi-adell/bllip-parser
1e33415916f43564bc045839908483e4cf373bb2
460fbfadeb9b02ef965273fe62c7251c2417c1b3
refs/heads/master
2021-01-17T21:23:56.011113
2015-11-05T06:49:11
2015-11-05T06:49:11
45,034,190
0
0
null
2015-10-27T10:43:54
2015-10-27T10:43:53
null
UTF-8
C++
false
false
2,021
h
GotIter.h
/* * Copyright 1999, 2005 Brown University, Providence, RI. * * 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 GOTITER_H #define GOTITER_H #include "Edge.h" #include "Item.h" #include <vector> class GotIter { public: GotIter(Edge* edge); bool next(Item*& itm); private: Edge* whereIam; }; class LeftRightGotIter { public: LeftRightGotIter(Edge* edge); bool next(Item*& itm); Item* index(int i) const { assert(i < 845); return lrarray[i]; } int size() const { return size_; } int& pos() { return pos_; } private: void makelrgi(Edge* edge); Item* lrarray[845]; int pos_; int size_; }; class MiddleOutGotIter { public: MiddleOutGotIter(Edge* edge); bool next(Item*& itm, int& pos); int size() const { return size_; } int dir() { return dir_; } private: void makelrgi(Edge* edge); Item* lrarray[845]; int pos_; int size_; int dir_; Item* firstRight_; }; class SuccessorIter { public: SuccessorIter(Edge* edge) : edge_(edge), edgeIter( edge->sucs().begin() ) {} bool next(Edge*& itm); private: Edge* edge_; list<Edge*>::iterator edgeIter; }; class NeedmeIter { public: NeedmeIter(Item* itm); bool next(Edge*& e); private: //int stackptr; // Edge* stack[64000]; //??? was 32; vector<Edge*> stack; }; #endif /* ! GOTITER_H */
5740ed73d2a6c3ba92895d93b4c3a1d23bec7660
d996403f0c7b1321717221c99f32bc329ab4727a
/SimpleRenderer/rect.h
e158aec48da55c973bcb9794ca2f98a4b5d4173b
[]
no_license
StephenJun/UnitySimpleRenderer
54b9a843928ae3b7c649062b6f8897cbf84dce4e
a2e31935b93baf64513c3fc9488fabd0765c57ce
refs/heads/master
2021-03-04T14:58:57.801945
2019-07-25T09:13:19
2019-07-25T09:13:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
313
h
rect.h
#pragma once class Rect { public: int x; int y; int width; int height; Rect() = default; Rect(int x, int y, int width, int height) { this->x = x; this->y = y; this->width = width; this->height = height; } int xmax() { return x + width - 1; } int ymax() { return y + height - 1; } };
830eafb49ecbd229e8480a6464ac988e04f25615
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-rds/include/aws/rds/model/SourceType.h
6c913b88df3df68d9cc0f474d81247d90e0d41d3
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
759
h
SourceType.h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/rds/RDS_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace RDS { namespace Model { enum class SourceType { NOT_SET, db_instance, db_parameter_group, db_security_group, db_snapshot, db_cluster, db_cluster_snapshot, custom_engine_version, db_proxy, blue_green_deployment }; namespace SourceTypeMapper { AWS_RDS_API SourceType GetSourceTypeForName(const Aws::String& name); AWS_RDS_API Aws::String GetNameForSourceType(SourceType value); } // namespace SourceTypeMapper } // namespace Model } // namespace RDS } // namespace Aws
2b9944590f2f9c35046229579eb30e2391202ebc
b8fbe9079ce8996e739b476d226e73d4ec8e255c
/src/engine/rb_scene/janmsprite.h
4a6fc055eb45ac7815b992f84efab6f34f2cd1c3
[]
no_license
dtbinh/rush
4294f84de1b6e6cc286aaa1dd48cf12b12a467d0
ad75072777438c564ccaa29af43e2a9fd2c51266
refs/heads/master
2021-01-15T17:14:48.417847
2011-06-16T17:41:20
2011-06-16T17:41:20
41,476,633
1
0
null
2015-08-27T09:03:44
2015-08-27T09:03:44
null
UTF-8
C++
false
false
5,108
h
janmsprite.h
/***********************************************************************************/ // File: JAnmSprite.h // Date: 27.10.2005 // Author: Ruslan Shestopalyuk /***********************************************************************************/ #ifndef __JANMSPRITE_H__ #define __JANMSPRITE_H__ enum SpriteAlignment { Align_None = 0, Align_Vertical = 1, Align_XAxis = 2, Align_YAxis = 3, Align_Ground = 4, Align_Camera = 5 }; // enum SpriteAlignment enum_beg(SpriteAlignment) enum_val( "None", Align_None ), enum_val( "Vertical", Align_Vertical ), enum_val( "XAxis", Align_XAxis ), enum_val( "YAxis", Align_YAxis ), enum_val( "Ground", Align_Ground ), enum_val( "Camera", Align_Camera ) enum_end(SpriteAlignment) /***********************************************************************************/ // Class: JAnmSprite // Desc: /***********************************************************************************/ class JAnmSprite : public JAnimation { public: JAnmSprite (); virtual void Render (); virtual void Init (); virtual void ResInit (); virtual void OnPlay (); float GetRotation () const { return m_Rotation; } bool IsMirrored () const { return m_bMirrored; } bool IsBackwards () const { return m_bBackwards; } void SetRotation ( float rot ) { m_Rotation = rot; } void SetMirrored ( bool bMirrored ) { m_bMirrored = bMirrored; } void SetBackwards ( bool bBackwards ) { m_bBackwards = bBackwards; } int GetSpriteID () const { return m_PackID; } int GetFrameID () const { return m_FrameID; } float GetPosX () const { return m_Pos.x; } float GetPosY () const { return m_Pos.y; } float GetPosZ () const { return m_Pos.z; } void SetPosX ( float val ) { m_Pos.x = val; } void SetPosY ( float val ) { m_Pos.y = val; } void SetPosZ ( float val ) { m_Pos.z = val; } float GetTransparency () const; void SetTransparency ( float val ); const char* GetAttachInstance () const { return m_AttachInstance.c_str(); } const char* GetAttachBone () const { return m_AttachBone.c_str(); } void SetAttachInstance ( const char* name ); void SetAttachBone ( const char* name ); expose(JAnmSprite) { parent(JAnimation); field( "StartAngle", m_StartAngle ); field( "EndAngle", m_EndAngle ); field( "Package", m_PackageName ); field( "StartFrame", m_StartFrame ); field( "NumFrames", m_NumFrames ); field( "FPS", m_FramesPerSec ); field( "Pivot", m_Pivot ); field( "Mirrored", m_bMirrored ); field( "Backwards", m_bBackwards ); field( "AlwaysCache", m_bAlwaysCache ); field( "Filter", m_bFilter ); field( "Color", m_Color ); prop ( "Transparency", GetTransparency, SetTransparency ); field( "Screenspace", m_bScreenSpace ); field( "Scale", m_Scale ); field( "Position", m_Pos ); field( "Rotation", m_Rotation ); prop ( "PosX", GetPosX, SetPosX ); prop ( "PosY", GetPosY, SetPosY ); prop ( "PosZ", GetPosZ, SetPosZ ); field( "BlendFrames", m_bBlendFrames ); prop ( "Attachinstance", GetAttachInstance, SetAttachInstance ); prop ( "Attachbone", GetAttachBone, SetAttachBone ); field( "Align", m_Align ); } private: int GetPlayedFrame( float cTime ); float m_StartAngle; float m_EndAngle; JString m_PackageName; int m_StartFrame; int m_NumFrames; float m_FramesPerSec; Vec2 m_Pivot; Vec3 m_Pos; float m_Scale; bool m_bScreenSpace; int m_PackID; int m_FrameID; float m_Rotation; bool m_bMirrored; bool m_bBackwards; bool m_bAlwaysCache; bool m_bFilter; bool m_bBlendFrames; uint32_t m_Color; JString m_AttachInstance; JString m_AttachBone; int m_AttachInstanceID; int m_AttachBoneID; SpriteAlignment m_Align; }; // class JAnmSprite #endif //__JANMSPRITE_H__
102238ba21646006d967cb8037a2fb6613f73e20
998f8333196a3b26b07bfff764949164b78d3852
/src/DslOsdBintr.cpp
140356560297eb04567ad8e3bb20151e200b1b87
[ "MIT" ]
permissive
muhammadabdullah34907/deepstream-services-library
b778577852b8852ea3360e160bf101093cfb68bf
c598100058c4e47ceff8e5826d319c0440acde04
refs/heads/master
2022-11-21T15:50:20.064878
2020-07-01T22:28:20
2020-07-01T22:28:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,665
cpp
DslOsdBintr.cpp
/* The MIT License Copyright (c) 2019-Present, ROBERT HOWELL 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 "Dsl.h" #include "DslElementr.h" #include "DslOsdBintr.h" #include "DslPipelineBintr.h" namespace DSL { OsdBintr::OsdBintr(const char* name, boolean isClockEnabled) : Bintr(name) , m_isClockEnabled(isClockEnabled) , m_processMode(0) , m_cropLeft(0) , m_cropTop(0) , m_cropWidth(0) , m_cropHeight(0) , m_clockFont("Serif") , m_clockFontSize(12) , m_clockOffsetX(0) , m_clockOffsetY(0) , m_clockColor({}) , m_streamId(-1) { LOG_FUNC(); m_pQueue = DSL_ELEMENT_NEW(NVDS_ELEM_QUEUE, "osd_queue"); m_pVidPreConv = DSL_ELEMENT_NEW(NVDS_ELEM_VIDEO_CONV, "osd_vid_pre_conv"); // m_pConvQueue = DSL_ELEMENT_NEW(NVDS_ELEM_QUEUE, "osd_conv_queue"); m_pOsd = DSL_ELEMENT_NEW(NVDS_ELEM_OSD, "nvosd0"); m_pVidPreConv->SetAttribute("gpu-id", m_gpuId); m_pVidPreConv->SetAttribute("nvbuf-memory-type", m_nvbufMemoryType); m_pOsd->SetAttribute("gpu-id", m_gpuId); m_pOsd->SetAttribute("display-clock", m_isClockEnabled); m_pOsd->SetAttribute("clock-font", m_clockFont.c_str()); m_pOsd->SetAttribute("x-clock-offset", m_clockOffsetX); m_pOsd->SetAttribute("y-clock-offset", m_clockOffsetY); m_pOsd->SetAttribute("clock-font-size", m_clockFontSize); m_pOsd->SetAttribute("process-mode", m_processMode); // SetClockColor(m_clockColorRed, m_clockColorGreen, m_clockColorBlue); AddChild(m_pQueue); AddChild(m_pVidPreConv); // AddChild(m_pConvQueue); AddChild(m_pOsd); m_pQueue->AddGhostPadToParent("sink"); m_pOsd->AddGhostPadToParent("src"); m_pSinkPadProbe = DSL_PAD_PROBE_NEW("osd-sink-pad-probe", "sink", m_pQueue); m_pSrcPadProbe = DSL_PAD_PROBE_NEW("osd-src-pad-probe", "src", m_pOsd); } OsdBintr::~OsdBintr() { LOG_FUNC(); if (m_isLinked) { UnlinkAll(); } } bool OsdBintr::LinkAll() { LOG_FUNC(); if (m_isLinked) { LOG_ERROR("OsdBintr '" << m_name << "' is already linked"); return false; } if (!m_pQueue->LinkToSink(m_pVidPreConv) or // !m_pVidPreConv->LinkToSink(m_pConvQueue) or // !m_pConvQueue->LinkToSink(m_pOsd)) !m_pVidPreConv->LinkToSink(m_pOsd)) { return false; } m_isLinked = true; return true; } void OsdBintr::UnlinkAll() { LOG_FUNC(); if (!m_isLinked) { LOG_ERROR("OsdBintr '" << m_name << "' is not linked"); return; } m_pQueue->UnlinkFromSink(); m_pVidPreConv->UnlinkFromSink(); // m_pConvQueue->UnlinkFromSink(); m_isLinked = false; } bool OsdBintr::LinkToSource(DSL_NODETR_PTR pDemuxer) { LOG_FUNC(); std::string srcPadName = "src_" + std::to_string(m_streamId); LOG_INFO("Linking the OsdBintr '" << GetName() << "' to Pad '" << srcPadName << "' for Demuxer '" << pDemuxer->GetName() << "'"); m_pGstStaticSinkPad = gst_element_get_static_pad(GetGstElement(), "sink"); if (!m_pGstStaticSinkPad) { LOG_ERROR("Failed to get Static Sink Pad for OsdBintr '" << GetName() << "'"); return false; } GstPad* pGstRequestedSrcPad = gst_element_get_request_pad(pDemuxer->GetGstElement(), srcPadName.c_str()); if (!pGstRequestedSrcPad) { LOG_ERROR("Failed to get Requested Src Pad for Demuxer '" << pDemuxer->GetName() << "'"); return false; } m_pGstRequestedSourcePads[srcPadName] = pGstRequestedSrcPad; // Call the base class to complete the link relationship return Bintr::LinkToSource(pDemuxer); } bool OsdBintr::UnlinkFromSource() { LOG_FUNC(); // If we're not currently linked to the Demuxer if (!IsLinkedToSource()) { LOG_ERROR("OsdBintr '" << GetName() << "' is not in a Linked state"); return false; } std::string srcPadName = "src_" + std::to_string(m_streamId); LOG_INFO("Unlinking and releasing requested Src Pad for Demuxer"); gst_pad_unlink(m_pGstRequestedSourcePads[srcPadName], m_pGstStaticSinkPad); gst_element_release_request_pad(GetSource()->GetGstElement(), m_pGstRequestedSourcePads[srcPadName]); m_pGstRequestedSourcePads.erase(srcPadName); return Nodetr::UnlinkFromSource(); } bool OsdBintr::AddToParent(DSL_BASE_PTR pBranchBintr) { LOG_FUNC(); // add 'this' OSD to the Parent Pipeline return std::dynamic_pointer_cast<BranchBintr>(pBranchBintr)-> AddOsdBintr(shared_from_this()); } void OsdBintr::GetClockEnabled(boolean* enabled) { LOG_FUNC(); *enabled = m_isClockEnabled; } bool OsdBintr::SetClockEnabled(boolean enabled) { LOG_FUNC(); if (IsInUse()) { LOG_ERROR("Unable to Set the Clock Enabled attribute for OsdBintr '" << GetName() << "' as it's currently in use"); return false; } m_isClockEnabled = enabled; m_pOsd->SetAttribute("display-clock", m_isClockEnabled); return true; } void OsdBintr::GetClockOffsets(uint* offsetX, uint* offsetY) { LOG_FUNC(); *offsetX = m_clockOffsetX; *offsetY = m_clockOffsetY; } bool OsdBintr::SetClockOffsets(uint offsetX, uint offsetY) { LOG_FUNC(); if (IsInUse()) { LOG_ERROR("Unable to set Clock Offsets for OsdBintr '" << GetName() << "' as it's currently in use"); return false; } m_clockOffsetX = offsetX; m_clockOffsetY = offsetY; m_pOsd->SetAttribute("x-clock-offset", m_clockOffsetX); m_pOsd->SetAttribute("y-clock-offset", m_clockOffsetY); return true; } void OsdBintr::GetClockFont(const char** name, uint *size) { LOG_FUNC(); *size = m_clockFontSize; *name = m_clockFont.c_str(); } bool OsdBintr::SetClockFont(const char* name, uint size) { LOG_FUNC(); if (IsInUse()) { LOG_ERROR("Unable to set Clock Font for OsdBintr '" << GetName() << "' as it's currently in use"); return false; } m_clockFont.assign(name); m_clockFontSize = size; m_pOsd->SetAttribute("clock-font", m_clockFont.c_str()); m_pOsd->SetAttribute("clock-font-size", m_clockFontSize); return true; } void OsdBintr::GetClockColor(double* red, double* green, double* blue, double* alpha) { LOG_FUNC(); *red = m_clockColor.red; *green = m_clockColor.green; *blue = m_clockColor.blue; *alpha = m_clockColor.alpha; } bool OsdBintr::SetClockColor(double red, double green, double blue, double alpha) { LOG_FUNC(); if (IsInUse()) { LOG_ERROR("Unable to set Clock Color for OsdBintr '" << GetName() << "' as it's currently in use"); return false; } m_clockColor.red = red; m_clockColor.green = green; m_clockColor.blue = blue; m_clockColor.alpha = alpha; uint clkRgbaColor = ((((uint) (m_clockColor.red * 255)) & 0xFF) << 24) | ((((uint) (m_clockColor.green * 255)) & 0xFF) << 16) | ((((uint) (m_clockColor.blue * 255)) & 0xFF) << 8) | ((((uint) (m_clockColor.alpha * 255)) & 0xFF)); m_pOsd->SetAttribute("clock-color", clkRgbaColor); return true; } bool OsdBintr::SetGpuId(uint gpuId) { LOG_FUNC(); if (IsInUse()) { LOG_ERROR("Unable to set GPU ID for OsdBintr '" << GetName() << "' as it's currently in use"); return false; } m_gpuId = gpuId; LOG_DEBUG("Setting GPU ID to '" << gpuId << "' for OsdBintr '" << m_name << "'"); m_pVidPreConv->SetAttribute("gpu-id", m_gpuId); m_pOsd->SetAttribute("gpu-id", m_gpuId); return true; } void OsdBintr::GetCropSettings(uint *left, uint *top, uint *width, uint *height) { LOG_FUNC(); *left = m_cropLeft; *top = m_cropTop; *width = m_cropWidth; *height = m_cropHeight; } static GstPadProbeReturn IdlePadProbeCB(GstPad* pPad, GstPadProbeInfo* pInfo, gpointer pOsdBintr) { static_cast<OsdBintr*>(pOsdBintr)->UpdateCropSetting(); return GST_PAD_PROBE_REMOVE; } bool OsdBintr::SetCropSettings(uint left, uint top, uint width, uint height) { LOG_FUNC(); m_cropLeft = left; m_cropTop = top; m_cropWidth = width; m_cropHeight = height; if (IsLinked()) { GstPad* pStaticPad = gst_element_get_static_pad(m_pVidPreConv->GetGstElement(), "src"); if (!pStaticPad) { LOG_ERROR("Failed to get Static Pad for OsdBintr '" << GetName() << "'"); return false; } gst_pad_add_probe(pStaticPad, GST_PAD_PROBE_TYPE_IDLE, IdlePadProbeCB, this, NULL); gst_object_unref(pStaticPad); return true; } std::string pixelSet = std::to_string(m_cropLeft) + ":" + std::to_string(m_cropTop) + ":" + std::to_string(m_cropWidth) + ":" + std::to_string(m_cropHeight); m_pVidPreConv->SetAttribute("src-crop", pixelSet.c_str()); m_pVidPreConv->SetAttribute("dest-crop", pixelSet.c_str()); return true; } static GstPadProbeReturn ConsumeEosCB(GstPad* pPad, GstPadProbeInfo* pInfo, gpointer pOsdBintr) { if (GST_EVENT_TYPE(GST_PAD_PROBE_INFO_DATA(pInfo)) != GST_EVENT_EOS) { return GST_PAD_PROBE_PASS; } // remove the probe first gst_pad_remove_probe(pPad, GST_PAD_PROBE_INFO_ID(pInfo)); return GST_PAD_PROBE_DROP; } void OsdBintr::UpdateCropSetting() { GstPad* pConvStaticSrcPad = gst_element_get_static_pad(m_pVidPreConv->GetGstElement(), "src"); GstPad* pOsdStaticSinkPad = gst_element_get_static_pad(m_pOsd->GetGstElement(), "sink"); gst_pad_unlink(pConvStaticSrcPad, pOsdStaticSinkPad); std::string pixelSet = std::to_string(m_cropLeft) + ":" + std::to_string(m_cropTop) + ":" + std::to_string(m_cropWidth) + ":" + std::to_string(m_cropHeight); m_pVidPreConv->SetAttribute("src-crop", pixelSet.c_str()); m_pVidPreConv->SetAttribute("dest-crop", pixelSet.c_str()); gst_pad_add_probe(pOsdStaticSinkPad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, ConsumeEosCB, this, NULL); gst_pad_link(pConvStaticSrcPad, pOsdStaticSinkPad); gst_object_unref(pConvStaticSrcPad); gst_object_unref(pOsdStaticSinkPad); } }
520ccbd2a7ea3289d711489b7a45c09b46be3078
5330918e825f8d373d3907962ba28215182389c3
/RecoLuminosity/ROOTSchema/src/FileToolKit.cc
3a8e1a946efa8594d993f36ea3244b81b60def46
[]
no_license
perrozzi/cmg-cmssw
31103a7179222c7aa94f65e83d090a5cf2748e27
1f4cfd936da3a6ca78f25959a41620925c4907ca
refs/heads/CMG_PAT_V5_18_from-CMSSW_5_3_22
2021-01-16T23:15:58.556441
2017-05-11T22:43:15
2017-05-11T22:43:15
13,272,641
1
0
null
2017-05-11T22:43:16
2013-10-02T14:05:21
C++
UTF-8
C++
false
false
4,415
cc
FileToolKit.cc
#include "RecoLuminosity/ROOTSchema/interface/FileToolKit.h" // STL Headers #include <fstream> // Linux #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> // C #include <cerrno> #include <cstdio> #include <cstring> void FileToolKit::Tokenize(const std::string& str, std::vector< std::string >& tokens, const std::string& delimiters ) { using std::string; // Skip delimiters at beginning. string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiters, lastPos); while (string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } } int FileToolKit::MakeDir( std::string dirName, mode_t writeMode ){ using std::vector; using std::string; int errsv = 0; vector< string > tkDirName; string currentDirName = ""; Tokenize(dirName, tkDirName, "/"); if(dirName[0] == '/') currentDirName += "/"; struct stat mStat; for(unsigned int i = 0; i < tkDirName.size(); ++i ){ currentDirName += tkDirName[i]; currentDirName += "/"; errno = 0; stat( currentDirName.c_str(), &mStat ); errsv = errno; if( errsv == 2 ){ // No such file or directory errno = 0; mkdir( currentDirName.c_str(), writeMode); errsv = errno; if( errno == 0 ){ errno = 0; chmod( currentDirName.c_str(), writeMode); errsv = errno; } } } return errsv; } void FileToolKit::MakeEmptyWebPage( const std::string &fileName, const std::string &title ){ std::fstream fileStream; fileStream.open( fileName.c_str(), std::fstream::out); fileStream << "<html>" << std::endl; fileStream << "<title>" << std::endl; fileStream << title << std::endl; fileStream << "</title>" << std::endl; fileStream << "<body>" << std::endl; fileStream << "</body>" << std::endl; fileStream << "</html>" << std::endl; fileStream.close(); } void FileToolKit::InsertLineAfter( const std::string &fileName, const std::string &newLine, const std::string &searchLine){ bool bMatch = false; std::vector< std::string > fileContents; char lineBuffer[256]; std::fstream fileStream; // Read file into memory and insert new line. fileStream.open(fileName.c_str(), std::fstream::in ); while( fileStream.good() ){ fileStream.getline( lineBuffer, 256 ); fileContents.push_back( lineBuffer ); if( strcmp( lineBuffer, searchLine.c_str() ) == 0 ){ fileContents.push_back( newLine ); bMatch = true; } } fileStream.close(); // If search line was found, write file from buffer. if(bMatch){ std::fstream fileStream2; fileStream2.open( fileName.c_str(), std::fstream::out ); for(unsigned int iline = 0; iline < fileContents.size(); ++iline) fileStream2 << fileContents[iline] << std::endl; fileStream2.close(); //rename( ( fileName ).c_str(), fileName.c_str() ); } } void FileToolKit::InsertLineBefore( const std::string &fileName, const std::string &newLine, const std::string &searchLine ){ bool bMatch = false; std::vector< std::string > fileContents; char lineBuffer[256]; std::fstream fileStream; fileStream.open(fileName.c_str()); while( fileStream.good() ){ fileStream.getline( lineBuffer, 256 ); if(strcmp(lineBuffer, searchLine.c_str()) == 0){ fileContents.push_back( newLine ); bMatch = true; } fileContents.push_back( lineBuffer ); } fileStream.close(); if(bMatch){ std::fstream fileStream2; fileStream2.open( fileName.c_str(), std::fstream::out ); for(unsigned int iline = 0; iline < fileContents.size(); ++iline){ fileStream2 << fileContents[iline] << std::endl; } fileStream2.close(); //rename( (fileName ).c_str(), fileName.c_str()); } } bool FileToolKit::fileExists( const std::string &fileName){ std::fstream filestr; filestr.open (fileName.c_str(), std::fstream::in ); if (filestr.is_open()){ filestr.close(); return true; } else { return false; } }
d6981879f45d4ae1a37aa22381a84c55f40bb5a4
3b893cd712e3057712372ee72b74cf2a0a307707
/Lonely/Lonely/GameLib/Font/Font.cpp
ab63fabcb60fb8fe13842d114e4277c5e6d5312a
[]
no_license
human-osaka-game-2018/Lonely
9b80f11d06099d3c14935d9212f33084e69dad0f
b3fa7231ed0599b3e5c111d8e480bb174dd52568
refs/heads/master
2020-04-02T16:49:10.557991
2019-04-19T08:37:20
2019-04-19T08:41:00
154,630,062
0
0
null
2019-05-02T06:07:40
2018-10-25T07:42:55
C++
UTF-8
C++
false
false
1,653
cpp
Font.cpp
/** * @file Font.cpp * @brief Fontクラスのソースファイル * @author shion-sagawa */ #include "Font.h" #include "GameLib.h" Font::Font() : m_fontSize(0) , m_pFont(nullptr) { } Font::~Font() { Finalize(); } // フォントの生成 bool Font::Initialize(int size) { IDirect3DDevice9* pDevice = GameLib::Instance.GetDirect3DDevice(); if (pDevice == nullptr) return false; D3DXFONT_DESCA desc; desc.Height = size; desc.Width = size / 2; desc.Weight = 400; desc.MipLevels = D3DX_DEFAULT; desc.Italic = FALSE; desc.CharSet = SHIFTJIS_CHARSET; desc.OutputPrecision = OUT_DEFAULT_PRECIS; desc.Quality = DEFAULT_QUALITY; desc.PitchAndFamily = FIXED_PITCH | FF_MODERN; ZeroMemory(desc.FaceName, sizeof(desc.FaceName)); D3DXCreateFontIndirectA( pDevice, &desc, &m_pFont ); m_fontSize = size; return true; } // フォントの破棄 void Font::Finalize() { SAFE_RELEASE(m_pFont); m_fontSize = 0; } // フォントの高さを取得 int Font::GetHeight() { return m_fontSize; } // メッセージの表示 void Font::DrawText(int X, int Y, D3DCOLOR color, const char* pText) { if (m_pFont == nullptr) return; RECT rect; SetRect(&rect, 0, 0, 0, 0); // 描画範囲の取得 m_pFont->DrawTextA(NULL, pText, -1, &rect, DT_LEFT | DT_CALCRECT, color); // 描画 OffsetRect(&rect, X, Y); m_pFont->DrawTextA(NULL, pText, -1, &rect, DT_LEFT, color); } // メッセージの表示 void Font::DrawFormatText(int X, int Y, D3DCOLOR color, const char* pFormat, ...) { char temp[MAX_PATH]; va_list list; va_start(list, pFormat); vsprintf_s(temp, pFormat, list); va_end(list); DrawText(X, Y, color, temp); }
5885e71594ecfbf790fda7958858a857d0810c06
5a19f0763cccd59abe5617d842301e4e7fe25a13
/source/hougl/test/hou/gl/test_gl_object_handle.cpp
29d79b811dbca857c6307aba6ad90a2c2e447d53
[ "MIT" ]
permissive
DavideCorradiDev/houzi-game-engine
6bfec0a8580ff4e33defaa30b1e5b490a4224fba
d704aa9c5b024300578aafe410b7299c4af4fcec
refs/heads/master
2020-03-09T01:34:13.718230
2019-02-02T09:53:24
2019-02-02T09:53:24
128,518,126
2
0
null
null
null
null
UTF-8
C++
false
false
5,299
cpp
test_gl_object_handle.cpp
// Houzi Game Engine // Copyright (c) 2018 Davide Corradi // Licensed under the MIT license. #include "hou/gl/test_gl_single_context.hpp" #include "hou/gl/gl_context_settings.hpp" #include "hou/gl/gl_object_handle.hpp" using namespace hou; namespace { class test_gl_object_handle : public test_gl_single_context {}; class concrete_gl_object_handle : public gl::object_handle { public: concrete_gl_object_handle(GLuint name) : gl::object_handle(name) {} }; class concrete_gl_shared_object_handle : public gl::shared_object_handle { public: concrete_gl_shared_object_handle(GLuint name) : gl::shared_object_handle(name) {} }; class concrete_gl_non_shared_object_handle : public gl::non_shared_object_handle { public: concrete_gl_non_shared_object_handle(GLuint name) : gl::non_shared_object_handle(name) {} }; } // namespace TEST_F(test_gl_object_handle, creation) { concrete_gl_object_handle oh(1u); EXPECT_EQ(1u, oh.get_name()); EXPECT_NE(0u, oh.get_uid()); concrete_gl_object_handle oh2(1u); EXPECT_NE(oh.get_uid(), oh2.get_uid()); } TEST_F(test_gl_object_handle, shared_creation) { concrete_gl_shared_object_handle oh(2u); EXPECT_EQ(2u, oh.get_name()); EXPECT_NE(0u, oh.get_uid()); EXPECT_EQ( m_context.get_sharing_group_uid(), oh.get_owning_sharing_group_uid()); concrete_gl_object_handle oh2(1u); EXPECT_NE(oh.get_uid(), oh2.get_uid()); } TEST_F(test_gl_object_handle, non_shared_creation) { concrete_gl_non_shared_object_handle oh(3u); EXPECT_EQ(3u, oh.get_name()); EXPECT_NE(0u, oh.get_uid()); EXPECT_EQ(m_context.get_uid(), oh.get_owning_context_uid()); concrete_gl_object_handle oh2(1u); EXPECT_NE(oh.get_uid(), oh2.get_uid()); } TEST_F(test_gl_object_handle, move_constructor) { concrete_gl_object_handle oh_dummy(1u); concrete_gl_object_handle oh(std::move(oh_dummy)); gl::object_handle::uid_type oh_uid_ref = oh.get_uid(); EXPECT_EQ(0u, oh_dummy.get_name()); EXPECT_EQ(0u, oh_dummy.get_uid()); EXPECT_EQ(1u, oh.get_name()); EXPECT_EQ(oh_uid_ref, oh.get_uid()); } TEST_F(test_gl_object_handle, shared_move_constructor) { concrete_gl_shared_object_handle oh_dummy(1u); concrete_gl_shared_object_handle oh(std::move(oh_dummy)); gl::object_handle::uid_type oh_uid_ref = oh.get_uid(); EXPECT_EQ(0u, oh_dummy.get_name()); EXPECT_EQ(0u, oh_dummy.get_uid()); EXPECT_EQ( m_context.get_sharing_group_uid(), oh_dummy.get_owning_sharing_group_uid()); EXPECT_EQ(1u, oh.get_name()); EXPECT_EQ(oh_uid_ref, oh.get_uid()); EXPECT_EQ( m_context.get_sharing_group_uid(), oh.get_owning_sharing_group_uid()); } TEST_F(test_gl_object_handle, non_shared_move_constructor) { concrete_gl_non_shared_object_handle oh_dummy(1u); concrete_gl_non_shared_object_handle oh(std::move(oh_dummy)); gl::object_handle::uid_type oh_uid_ref = oh.get_uid(); EXPECT_EQ(0u, oh_dummy.get_name()); EXPECT_EQ(0u, oh_dummy.get_uid()); EXPECT_EQ(m_context.get_uid(), oh_dummy.get_owning_context_uid()); EXPECT_EQ(1u, oh.get_name()); EXPECT_EQ(oh_uid_ref, oh.get_uid()); EXPECT_EQ(m_context.get_uid(), oh.get_owning_context_uid()); } TEST_F(test_gl_object_handle, shared_owner_uid) { #if defined(HOU_EMSCRIPTEN) SKIP("Multiple GL contexts are not supported on Emscripten."); #endif window w("Test", vec2u(1u, 1u)); gl::context c1(get_test_default_context_settings(), w); gl::context c2(get_test_default_context_settings(), w, c1); gl::context c3(get_test_default_context_settings(), w); gl::context::set_current(c1, w); concrete_gl_shared_object_handle sh1(0u); gl::context::set_current(c2, w); concrete_gl_shared_object_handle sh2(0u); gl::context::set_current(c3, w); concrete_gl_shared_object_handle sh3(0u); EXPECT_EQ(c1.get_sharing_group_uid(), sh1.get_owning_sharing_group_uid()); EXPECT_EQ(c2.get_sharing_group_uid(), sh2.get_owning_sharing_group_uid()); EXPECT_EQ(c3.get_sharing_group_uid(), sh3.get_owning_sharing_group_uid()); EXPECT_EQ( sh1.get_owning_sharing_group_uid(), sh2.get_owning_sharing_group_uid()); EXPECT_NE( sh1.get_owning_sharing_group_uid(), sh3.get_owning_sharing_group_uid()); EXPECT_NE( sh2.get_owning_sharing_group_uid(), sh3.get_owning_sharing_group_uid()); } TEST_F(test_gl_object_handle, non_shared_owner_uid) { #if defined(HOU_EMSCRIPTEN) SKIP("Multiple GL contexts are not supported on Emscripten."); #endif window w("Test", vec2u(1u, 1u)); gl::context c1(get_test_default_context_settings(), w); gl::context c2(get_test_default_context_settings(), w, c1); gl::context c3(get_test_default_context_settings(), w); gl::context::set_current(c1, w); concrete_gl_non_shared_object_handle nsh1(0u); gl::context::set_current(c2, w); concrete_gl_non_shared_object_handle nsh2(0u); gl::context::set_current(c3, w); concrete_gl_non_shared_object_handle nsh3(0u); EXPECT_EQ(c1.get_uid(), nsh1.get_owning_context_uid()); EXPECT_EQ(c2.get_uid(), nsh2.get_owning_context_uid()); EXPECT_EQ(c3.get_uid(), nsh3.get_owning_context_uid()); EXPECT_NE(nsh1.get_owning_context_uid(), nsh2.get_owning_context_uid()); EXPECT_NE(nsh1.get_owning_context_uid(), nsh3.get_owning_context_uid()); EXPECT_NE(nsh2.get_owning_context_uid(), nsh3.get_owning_context_uid()); }
02d3a9d89382b11074aab405070221b719e8f2ec
31f0bce32e6192b22989c2d2de54f0c218eb34b9
/larreco/Genfit/TGeant3/G3Medium.cxx
84e82c0bdcd7c6f04fc0e4ee62fd8054bebcd70d
[]
no_license
Dr15Jones/larreco
7e3660ed4b8af50a91a1e98b23d84bffa059b0a8
41039550749392e0055318c62fd9b45238e0973e
refs/heads/develop
2021-01-15T14:24:38.787996
2016-05-05T15:31:47
2016-05-05T15:31:47
58,142,095
0
1
null
2016-05-05T15:42:21
2016-05-05T15:42:21
null
UTF-8
C++
false
false
2,300
cxx
G3Medium.cxx
/* ************************************************************************* * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Log: G3Medium.cxx,v $ Revision 1.3 2004/01/28 08:17:52 brun Reintroduce the Geant3 graphics classes (thanks Andreas Morsch) Revision 1.1.1.1 2002/07/24 15:56:26 rdm initial import into CVS */ // // G3 Medium Class for the G3 GUI // Author: Andreas Morsch // andreas.morsch@cern.ch // #include "larreco/Genfit/TGeant3/G3Medium.h" ClassImp(G3Medium) G3Medium::G3Medium() { // constructor fId=-1; } G3Medium::G3Medium(Int_t imed, Int_t imat, const char* name, Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin) : TNamed(name, "Medium") { // constructor fId=imed; fIdMat=imat; fIsvol=isvol; fIfield=ifield; fFieldm=fieldm; fTmaxfd=tmaxfd; fStemax=stemax; fDeemax=deemax; fEpsil=epsil; fStmin=stmin; } Int_t G3Medium::Id() { // return medium id return fId; } Float_t G3Medium::GetPar(Int_t ipar) { // Get parameter number ipar Float_t p; if (ipar < 23) { p= fPars[ipar-1]; } else if(ipar >=23 && ipar <27) { p= fPars[ipar-1+3]; } else { p= fPars[ipar-1+4]; } return p; } void G3Medium::Streamer(TBuffer &) { // dummy streamer ; }
38386a066d429ea6674e118ac7162cbff6a3f268
8beb9d2f619f5b3a9202509424d11fb9470a0751
/examples/events.cc
ac52b35bd6e9c091062a5edc7a689b39cd7693c9
[ "MIT" ]
permissive
GeeLaw/onenote-object-model
985b2d40b0ab1f4c1e5b85ae0e09ba24666092c3
63720381ab856ec31feff4848f548658331306ee
refs/heads/master
2022-12-13T04:45:53.818248
2020-09-03T19:40:06
2020-09-03T19:40:06
291,966,963
3
0
null
null
null
null
UTF-8
C++
false
false
4,692
cc
events.cc
#include"utils.hpp" using namespace OneNote15; struct MyEvents : public IOneNoteEvents { /*** IUnknown ***/ STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { wprintf(L"QueryInterface(IID = " "%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX" ")\n", riid.Data1, riid.Data2, riid.Data3, riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7]); if (!ppv) { return E_POINTER; } if (riid == IID_IOneNoteEvents) { *ppv = static_cast<IOneNoteEvents *>(this); AddRef(); return S_OK; } if (riid == IID_IDispatch) { *ppv = static_cast<IDispatch *>(this); AddRef(); return S_OK; } if (riid == IID_IUnknown) { *ppv = static_cast<IUnknown *>(this); AddRef(); return S_OK; } *ppv = NULL; return E_NOINTERFACE; } STDMETHODIMP_(ULONG) AddRef() { wprintf(L"AddRef()\n"); return ++refcount; } STDMETHODIMP_(ULONG) Release() { wprintf(L"Release()\n"); return --refcount; } /*** IDispatch ***/ STDMETHODIMP GetTypeInfoCount(UINT *pctinfo) { wprintf(L"GetTypeInfoCount()\n"); *pctinfo = 0; return E_NOTIMPL; } STDMETHODIMP GetTypeInfo(UINT uTInfo, LCID lcid, ITypeInfo **ppTInfo) { wprintf(L"GetTypeInfo()\n"); *ppTInfo = NULL; return E_NOTIMPL; } STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { wprintf(L"GetIDsOfNames()\n"); if (riid != IID_NULL) { return E_INVALIDARG; } bool unk = false; for (UINT i = 0; i != cNames; ++i) { if (StringCompareMixTwo(rgszNames[i], L"ONNAVIGATE", L"onnavigate")) { rgDispId[i] = DISPID_OnNavigate; } else if (StringCompareMixTwo(rgszNames[i], L"ONHIERARCHYCHANGE", L"onhierarchychange")) { rgDispId[i] = DISPID_OnHierarchyChange; } else { rgDispId[i] = DISPID_UNKNOWN; unk = true; } } return unk ? DISP_E_UNKNOWNNAME : S_OK; } STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { wprintf(L"Invoke(DispId = %d)\n", (int)dispIdMember); if (pVarResult) { VariantInit(pVarResult); } if (pExcepInfo) { memset(pExcepInfo, sizeof(EXCEPINFO), 0); } return S_OK; } /*** IOneNoteEvents ***/ STDMETHODIMP OnNavigate() { wprintf(L"OnNavigate()\n"); return S_OK; } STDMETHODIMP OnHierarchyChange(BSTR bstrActivePageID) { wprintf(L"OnHierarchyChange()\n"); return S_OK; } /*** C++ ***/ MyEvents(ComPtr<IApplication> const &onenote) : refcount(1), app(onenote) { } MyEvents(MyEvents &&) = delete; MyEvents &operator =(MyEvents &&) = delete; MyEvents(MyEvents const &) = delete; MyEvents &operator =(MyEvents const &) = delete; ~MyEvents() = default; private: ULONG refcount; ComPtr<IApplication> app; }; int main() { HRESULT hr; InitializeOLE init; if (!SUCCEEDED(hr = (HRESULT)init)) { wprintf(L"OleInitialize returned %08x.\n", (int)hr); return (int)hr; } ThreadTimer timer; if (!SUCCEEDED(hr = (HRESULT)timer)) { wprintf(L"SetTimer failed with HRESULT %08x.\n", (int)hr); return (int)hr; } ComPtr<IApplication> onenote; if (!SUCCEEDED(hr = CreateApplication(onenote.ppiOut()))) { wprintf(L"CoCreateInstance returned %08x.\n", (int)hr); return (int)hr; } ComPtr<IConnectionPointContainer> app; if (!SUCCEEDED(hr = onenote->QueryInterface(IID_IConnectionPointContainer, app.ppvOut()))) { wprintf(L"QueryInterface for IConnectionPointContainer returned %08x.\n", (int)hr); return (int)hr; } ComPtr<IConnectionPoint> connpoint; if (!SUCCEEDED(hr = app->FindConnectionPoint(IID_IOneNoteEvents, connpoint.ppiOut()))) { wprintf(L"FindConnectionPoint returned %08x.\n", (int)hr); return (int)hr; } MyEvents events(onenote); AdvisoryConenction advisory(connpoint, &events); /* The type library provided by OneNote is incomplete, /* and this call will fail. Applying the fixed library /* makes the call succeed, but the events are never fired. */ if (!SUCCEEDED(hr = (HRESULT)advisory)) { wprintf(L"Advise returned %08x.\n", (int)hr); return (int)hr; } bool hit; MSG msg; while (!(hit = (bool)_kbhit()) && GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (hit) { _getch(); } return 0; }
9c568b499fe11fd2254611baaa5327a2589651cf
f58ed9e8d9e01999ba1c828ff9768d17898fa461
/cpp_module_00/ex01/main.cpp
9f0a4b764ef6c243a31423d22168ce03c4b450ed
[]
no_license
oumeimatt/cpp-module
3e9748442720413dfa8959ced8745e820ddae92e
1a11f696dee68dab762d0c2f8846176fba720191
refs/heads/main
2023-09-05T03:39:27.501573
2021-11-21T21:35:58
2021-11-21T21:35:58
407,852,284
2
0
null
null
null
null
UTF-8
C++
false
false
1,359
cpp
main.cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: oel-yous <oel-yous@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/09/22 11:13:51 by oel-yous #+# #+# */ /* Updated: 2021/09/22 11:13:53 by oel-yous ### ########.fr */ /* */ /* ************************************************************************** */ #include "Phonebook.Class.hpp" int main(void) { std::string command; Phonebook Phonebook; while (1) { std::cout << "-----Please enter a command-----" << std::endl << ">"; std::getline(std::cin, command); if (!command.compare("ADD")) Phonebook.add_command(); else if (!command.compare("SEARCH")) Phonebook.search_command(); else if (!command.compare("EXIT")) break ; } }
a051835e570cf289e1b7bf23e33c4f0c27ea27f2
632a260c17d402528d2637d31e19484ed2dc7781
/src/particle_filter/SmcParticle.h
d96498ce2eaa660134d0cce10588b2303bec5bb0
[]
no_license
Mijan/LFNS
ab355b3a73d9943f66926420066068f8bfdab7a9
fa84cc7c90e9e706c006eaf8ff506dc15cba8f6e
refs/heads/publishable
2023-06-24T02:32:05.874735
2023-06-09T20:56:08
2023-06-09T20:56:08
184,099,871
0
0
null
null
null
null
UTF-8
C++
false
false
904
h
SmcParticle.h
// // Created by jan on 11/10/18. // #ifndef LFNS_SMCPARTICLE_H #define LFNS_SMCPARTICLE_H #include <vector> #include <memory> namespace particle_filter { class SmcParticle { public: SmcParticle(std::size_t state_size) : state(state_size, 0.0), time(0.0), _weight(0.0) {} SmcParticle(const std::vector<double> &state_, double t) : state(state_), time(t), _weight(0.0) {} virtual ~SmcParticle() {}; std::vector<double> state; double time; double weight() { return _weight; } void setWeight(double weight) { _weight = weight; } virtual void replaceWith(const SmcParticle &rhs) { state = rhs.state; time = rhs.time; _weight = rhs._weight; } protected: double _weight; }; typedef std::shared_ptr<SmcParticle> SmcParticle_ptr; } #endif //LFNS_SMCPARTICLE_H
41b70773d2ceeae91824da28b67c25e9872000f3
2e23464090c2c40f7748e9509073c3a59b4eeb23
/lib/jxl/patch_dictionary_internal.h
00e60b2f5c242da9b92ceab5e75882b7efe0918b
[ "Apache-2.0" ]
permissive
xann16/jpeg-xl
c696d54801beabcb6f37bf4d202c9e2e00e9b4d2
3f44ccc40341a579dd3d6d2878901ffab2137a1c
refs/heads/main
2023-07-03T17:10:31.088440
2021-08-05T11:02:17
2021-08-05T11:02:17
393,007,451
1
0
Apache-2.0
2021-08-05T10:55:37
2021-08-05T10:55:36
null
UTF-8
C++
false
false
4,447
h
patch_dictionary_internal.h
// Copyright (c) the JPEG XL Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef LIB_JXL_PATCH_DICTIONARY_INTERNAL_H_ #define LIB_JXL_PATCH_DICTIONARY_INTERNAL_H_ #include "lib/jxl/dec_patch_dictionary.h" namespace jxl { // Context numbers as specified in Section C.4.5, Listing C.2: enum Contexts { kNumRefPatchContext = 0, kReferenceFrameContext = 1, kPatchSizeContext = 2, kPatchReferencePositionContext = 3, kPatchPositionContext = 4, kPatchBlendModeContext = 5, kPatchOffsetContext = 6, kPatchCountContext = 7, kPatchAlphaChannelContext = 8, kPatchClampContext = 9, kNumPatchDictionaryContexts }; template <bool add> void PatchDictionary::Apply(Image3F* opsin, const Rect& opsin_rect, const Rect& image_rect) const { JXL_CHECK(SameSize(opsin_rect, image_rect)); size_t num = 0; for (size_t y = image_rect.y0(); y < image_rect.y0() + image_rect.ysize(); y++) { if (y + 1 >= patch_starts_.size()) continue; float* JXL_RESTRICT rows[3] = { opsin_rect.PlaneRow(opsin, 0, y - image_rect.y0()), opsin_rect.PlaneRow(opsin, 1, y - image_rect.y0()), opsin_rect.PlaneRow(opsin, 2, y - image_rect.y0()), }; for (size_t id = patch_starts_[y]; id < patch_starts_[y + 1]; id++) { num++; const PatchPosition& pos = positions_[sorted_patches_[id]]; size_t by = pos.y; size_t bx = pos.x; size_t xsize = pos.ref_pos.xsize; JXL_DASSERT(y >= by); JXL_DASSERT(y < by + pos.ref_pos.ysize); size_t iy = y - by; size_t ref = pos.ref_pos.ref; if (bx >= image_rect.x0() + image_rect.xsize()) continue; if (bx + xsize < image_rect.x0()) continue; // TODO(veluca): check that the reference frame is in XYB. const float* JXL_RESTRICT ref_rows[3] = { shared_->reference_frames[ref].frame->color()->ConstPlaneRow( 0, pos.ref_pos.y0 + iy) + pos.ref_pos.x0, shared_->reference_frames[ref].frame->color()->ConstPlaneRow( 1, pos.ref_pos.y0 + iy) + pos.ref_pos.x0, shared_->reference_frames[ref].frame->color()->ConstPlaneRow( 2, pos.ref_pos.y0 + iy) + pos.ref_pos.x0, }; // TODO(veluca): use the same code as in dec_reconstruct.cc. for (size_t ix = 0; ix < xsize; ix++) { // TODO(veluca): hoist branches and checks. // TODO(veluca): implement for extra channels. if (bx + ix < image_rect.x0()) continue; if (bx + ix >= image_rect.x0() + image_rect.xsize()) continue; for (size_t c = 0; c < 3; c++) { if (add) { if (pos.blending[0].mode == PatchBlendMode::kAdd) { rows[c][bx + ix - image_rect.x0()] += ref_rows[c][ix]; } else if (pos.blending[0].mode == PatchBlendMode::kReplace) { rows[c][bx + ix - image_rect.x0()] = ref_rows[c][ix]; } else if (pos.blending[0].mode == PatchBlendMode::kNone) { // Nothing to do. } else { // Checked in decoding code. JXL_ABORT("Blending mode %u not yet implemented", (uint32_t)pos.blending[0].mode); } } else { if (pos.blending[0].mode == PatchBlendMode::kAdd) { rows[c][bx + ix - image_rect.x0()] -= ref_rows[c][ix]; } else if (pos.blending[0].mode == PatchBlendMode::kReplace) { rows[c][bx + ix - image_rect.x0()] = 0; } else if (pos.blending[0].mode == PatchBlendMode::kNone) { // Nothing to do. } else { // Checked in decoding code. JXL_ABORT("Blending mode %u not yet implemented", (uint32_t)pos.blending[0].mode); } } } } } } } } // namespace jxl #endif // LIB_JXL_PATCH_DICTIONARY_INTERNAL_H_
1d60c4a80c4462440f08bafc47acd04662e1cd72
ed953b899b3196ef2dfd576554c7e18372c05701
/tools/pointcloud/src/octree.h
655320dc69758fa83faf24a6db0d58d18e3f17c4
[]
no_license
thomaav/slamdunk
804408c1a0c507b65c88e2b2720e29b24a360942
322d61e49b1d637afa1ccf4830b42b2b1923c372
refs/heads/master
2020-04-11T12:16:21.235642
2018-11-27T14:06:56
2018-11-27T14:06:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
612
h
octree.h
#pragma once #include <stdlib.h> struct OctreePoint { float x, y, z; }; struct OctreeBoundingBox { OctreePoint center; float radius; }; struct OctreeNode; constexpr size_t OCTREE_CHILDREN = 8; constexpr size_t OCTREE_LEAFS = (sizeof(OctreeNode *) * OCTREE_CHILDREN) / sizeof(OctreePoint); struct OctreeNode { OctreeBoundingBox box; size_t num_points; bool dirty; unsigned int buffer_id; unsigned int vao_id; union { OctreePoint leafs[OCTREE_LEAFS]; OctreeNode *children[OCTREE_CHILDREN]; }; }; struct Octree { OctreeBoundingBox box; struct OctreeNode *root; void insert(OctreePoint); };
0bdc353cf4c23e5f34cc169fa970fc63488be700
555b6971c92299b14ead2e4cfc90d499e6b971d5
/Competitive Programming/_notebook/string.cpp
7ace5d0bd59e3c4f28c80b6ded288984d489e21c
[]
no_license
M-Rodrigues/Programming
dc538cde56545c2477276093617e18385d2401cb
ebc782f721fca3a0ee81449dd78b75f7ef332f5f
refs/heads/master
2020-04-16T10:48:38.730265
2019-08-02T02:47:19
2019-08-02T02:47:19
165,517,658
0
0
null
null
null
null
UTF-8
C++
false
false
1,635
cpp
string.cpp
#include<bits/stdc++.h> using namespace std; const int N = 1e5+5; // Z-function int z[N]; void z_func(string &s) { int x, y; x = y = 0; z[0]=0; for (int i = 1; i < s.size(); i++) { z[i] = max(0,min(y-i,z[i-x])); while (z[i]+i < s.size() and s[z[i]] == s[z[i] + i]) x = i, z[i]++, y = z[i]+i; } } int a[3] = {2,5,8}; void funcao(int * v) { printf("%d\n",v[2]); } int main() { funcao(a); // Z-function string s = "atavatavatavatavg"; z_func(s); for (int i = 0; i < s.size(); i++) printf("%d ",z[i]); printf("\n"); // Buscar período int T = 0; for (int i = 0; i < s.size(); i++) if (i+z[i] == s.size() and s.size()%i == 0) { T = i; break; } if (T != s.size()) printf("Período da string: %d\n",T); else printf("A string não possui período...\n"); // String matching string ss = "ba"; string sss = ss + "$"; sss += s; z_func(sss); for (int i = 0; i < sss.size(); i++) printf("%d ",z[i]); printf("\n"); bool ok = false; for (int i = 0; i < sss.size(); i++) if (z[i] == ss.size()) { ok = true; break; } if (ok) printf("Existe substring!\n"); else printf("Não existe...\n"); // String shifting string a, b; a = "abac"; b = "acab"; string t = a + a; t = b + "$" + t; z_func(t); for (int i = 0; i < t.size(); i++) printf("%d ",z[i]); printf("\n"); ok = false; for (int i = 0; i < t.size(); i++) if (z[i] == b.size()) { ok = true; break; } if (ok) printf("Existe substring shifting!\n"); else printf("Não existe shift...\n"); return 0; }
3b7684645df8b05f2f4e022972e56dc37004c894
2d744a33e99df029c0986c1de751506c09608477
/gnui/compat/FL/GNUI_Input.H
65e24dc53294501b8d9258f6c3a1d1165216b7fa
[]
no_license
Dervish13/gnui
57475103066312950368bba60181a27d47868fda
f62042c21aad348cf669e22f16e0bf5df07e8a91
refs/heads/master
2020-05-07T15:48:11.684477
2019-09-18T20:14:19
2019-09-18T20:14:19
180,652,956
0
0
null
2019-04-10T19:48:14
2019-04-10T19:48:14
null
UTF-8
C++
false
false
799
h
GNUI_Input.H
#ifndef GNUI_Input_H #define GNUI_Input_H #include "GNUI_Widget.H" #include <gnui/Input.h> class GNUI_Input : public gnui::Input { public: GNUI_Input(int x, int y, int w, int h, const char* l=0) : gnui::Input(x,y,w,h,l) {} int wrap() const { return type() == gnui::Input::WORDWRAP; } void wrap(int b) { type(b ? gnui::Input::WORDWRAP : gnui::Input::MULTILINE);} }; enum { GNUI_NORMAL_INPUT = gnui::Input::NORMAL, GNUI_FLOAT_INPUT = 1, // probably needs the IntInput subclass! GNUI_INT_INPUT = 2, //GNUI_HIDDEN_INPUT // not in gnui.0 GNUI_MULTILINE_INPUT = gnui::Input::MULTILINE, GNUI_SECRET_INPUT = gnui::Input::SECRET, //GNUI_INPUT_TYPE = 7, //GNUI_INPUT_READONLY = 8, GNUI_INPUT_WRAP = gnui::Input::WORDWRAP, GNUI_MULTILINE_INPUT_WRAP = gnui::Input::WORDWRAP }; #endif
49d258ffee85464969adeedb0df2f56a9f61ecaa
ebacc5b1b457b08eac119e43c030281c98343aeb
/Boost_Study/FunctionAndCallback/15.cpp
316d7a70566bd486c7026e54da42a21756fd8ca5
[]
no_license
deardeng/learning
e9993eece3ed22891f2e54df7c8cf19bf1ce89f4
338d6431cb2d64b25b3d28bbdd3e47984f422ba2
refs/heads/master
2020-05-17T13:12:43.808391
2016-02-11T16:24:09
2016-02-11T16:24:09
19,692,141
1
1
null
null
null
null
UTF-8
C++
false
false
711
cpp
15.cpp
#include <iostream> #include <boost/utility/result_of.hpp> #include <boost/typeof/typeof.hpp> #include <boost/assign.hpp> #include <boost/bind.hpp> #include <boost/foreach.hpp> #include <string> #include <boost/rational.hpp> #include <boost/function.hpp> using namespace boost; using namespace boost::assign; class demo_class { private: typedef function<void(int)> func_t; func_t func; int n; public: demo_class(int i) : n(i){} template<typename CallBack> void accept(CallBack f) { func = f; } void run() { func(n); } }; void call_back_func(int i) { std::cout << "call back func: "; std::cout << i * 2 << std::endl; } int main() { demo_class dc(10); dc.accept(call_back_func); dc.run(); }
4d4444620f8f1fbee4c3f2fd0dc2e7b9126a5f0f
6f874ccb136d411c8ec7f4faf806a108ffc76837
/code/Windows-classic-samples/Samples/Win7Samples/winui/tsf/tsfmark/editsink.cpp
65e9c1d17dcf33b877d3ecdc5a1f086421b5688f
[ "MIT" ]
permissive
JetAr/ZDoc
c0f97a8ad8fd1f6a40e687b886f6c25bb89b6435
e81a3adc354ec33345e9a3303f381dcb1b02c19d
refs/heads/master
2022-07-26T23:06:12.021611
2021-07-11T13:45:57
2021-07-11T13:45:57
33,112,803
8
8
null
null
null
null
UTF-8
C++
false
false
4,468
cpp
editsink.cpp
// // editsink.cpp // // ITfTextEditSink implementation. // #include "globals.h" #include "mark.h" //+--------------------------------------------------------------------------- // // OnEndEdit // // Called by the system whenever anyone releases a write-access document lock. //---------------------------------------------------------------------------- STDAPI CMarkTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) { ITfRange *pRangeComposition; IEnumTfRanges *pEnumRanges; ITfRange *pRange; ITfContext *pCompositionContext; TF_SELECTION tfSelection; BOOL fResult; BOOL fCancelComposition; ULONG cFetched; if (_pComposition == NULL) return S_OK; // are we responsible for the edit? if (pContext->InWriteSession(_tfClientId, &fResult) == S_OK && fResult) return S_OK; // is this the context our composition lives in? if (_pComposition->GetRange(&pRangeComposition) != S_OK) return S_OK; if (pRangeComposition->GetContext(&pCompositionContext) != S_OK) goto Exit; fResult = IsEqualUnknown(pCompositionContext, pContext); pCompositionContext->Release(); if (!fResult) goto Exit; // different context fCancelComposition = FALSE; // we're composing in this context, cancel the composition if anything suspicious happened // did the selection move outside the composition? if (pEditRecord->GetSelectionStatus(&fResult) == S_OK && fResult) { if (pContext->GetSelection(ecReadOnly, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) == S_OK && cFetched == 1) { if (_pComposition->GetRange(&pRangeComposition) == S_OK) { fResult = IsRangeCovered(ecReadOnly, tfSelection.range, pRangeComposition); pRangeComposition->Release(); if (!fResult) { fCancelComposition = TRUE; } } tfSelection.range->Release(); } } if (fCancelComposition) goto CancelComposition; // did someone else edit the document text? if (pEditRecord->GetTextAndPropertyUpdates(TF_GTP_INCL_TEXT, NULL, 0, &pEnumRanges) == S_OK) { // is the enumerator empty? if (pEnumRanges->Next(1, &pRange, NULL) == S_OK) { pRange->Release(); fCancelComposition = TRUE; } pEnumRanges->Release(); } if (fCancelComposition) { CancelComposition: // we need a write edit session to cancel the composition _TerminateCompositionInContext(pContext); } Exit: pRangeComposition->Release(); return S_OK; } //+--------------------------------------------------------------------------- // // _InitTextEditSink // // Init a text edit sink on the topmost context of the document. // Always release any previous sink. //---------------------------------------------------------------------------- BOOL CMarkTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) { ITfSource *pSource; BOOL fRet; // clear out any previous sink first if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) { if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { pSource->UnadviseSink(_dwTextEditSinkCookie); pSource->Release(); } _pTextEditSinkContext->Release(); _pTextEditSinkContext = NULL; _dwTextEditSinkCookie = TF_INVALID_COOKIE; } if (pDocMgr == NULL) return TRUE; // caller just wanted to clear the previous sink // setup a new sink advised to the topmost context of the document if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) return FALSE; if (_pTextEditSinkContext == NULL) return TRUE; // empty document, no sink possible fRet = FALSE; if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) { if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) { fRet = TRUE; } else { _dwTextEditSinkCookie = TF_INVALID_COOKIE; } pSource->Release(); } if (fRet == FALSE) { _pTextEditSinkContext->Release(); _pTextEditSinkContext = NULL; } return fRet; }
116450bbdc60c50feccfffca221d5ee0cb92346b
5d1a4bb6c4e26aa5aac00337be689a25b7349f65
/diffusion3d/solver/gpu@miyagawa@pfsl.mech.tohoku.ac.jp/MySolver.h
6c141a6e3112dece24eb2b7d325c3ae81d5ba3a7
[]
no_license
tjhayasaka/pfsl-gpu-exercise
10379171dc9a7042d98ff70a90090a4baa78609d
812ebcb8f23d0cb684807b842009de021a33db70
refs/heads/master
2016-09-06T16:00:42.825772
2011-07-04T05:35:47
2011-07-04T05:35:47
1,825,792
0
0
null
null
null
null
UTF-8
C++
false
false
4,394
h
MySolver.h
// #ifndef MySolver_h__ #define MySolver_h__ 1 #include "Solver.h" #include "ArrayAccessor.h" #include <boost/scoped_array.hpp> // template <typename T> class ScopedCudaArray { public: ScopedCudaArray() : data_(NULL) { } ~ScopedCudaArray() { cudaFree(data_); data_ = NULL; } void reset(int numItems) { cudaFree(data_); data_ = NULL; cudaMalloc(&data_, sizeof(T) * numItems); assert(cudaGetLastError() == cudaSuccess); } T const *get() const { return data_; } T *get() { return data_; } void swap(ScopedCudaArray<T> &o) { std::swap(data_, o.data_); } private: T *data_; }; // template <typename Float> class MySolver : public Solver<Float> { public: MySolver(); virtual ~MySolver(); virtual void reset(Dim3 const &numNodesInGrid, Vec3<Float> const &cellSpacing); virtual void withFrontBuffer(enum Solver<Float>::BufferOpMode mode, boost::function<void (Solver<Float> const &solver, Float *buffer)> func); virtual int nextTick(Float kappa, Float dt); virtual void swapBuffers(); virtual Float const *buf_back() const { return buf_back_.get(); } virtual Float const *buf_front() const { return buf_front_.get(); } virtual int halo() const { return 0; } /* NOTE: may be inappropriate for you */ virtual Dim3 const &numNodesInGrid() const { return numNodesInGrid_; } virtual Vec3<Float> const &cellSpacing() const { return cellSpacing_; } private: Dim3 numNodesInGrid_; Vec3<Float> cellSpacing_; ScopedCudaArray<Float> buf_back_; ScopedCudaArray<Float> buf_front_; }; template <typename Float> MySolver<Float>::MySolver() : Solver<Float>(), numNodesInGrid_(0, 0, 0), cellSpacing_(0, 0, 0) { } template <typename Float> MySolver<Float>::~MySolver() { } template <typename Float> void MySolver<Float>::reset(Dim3 const &numNodesInGrid, Vec3<Float> const &cellSpacing) { numNodesInGrid_ = numNodesInGrid; cellSpacing_ = cellSpacing; buf_back_.reset(this->numTotalNodesInGridIncludingHalo()); buf_front_.reset(this->numTotalNodesInGridIncludingHalo()); } template <typename Float> void MySolver<Float>::withFrontBuffer(enum Solver<Float>::BufferOpMode mode, boost::function<void (Solver<Float> const &solver, Float *f)> func) { boost::scoped_array<Float> host_tmp_p(new Float[this->numTotalNodesInGridIncludingHalo()]); if (mode != Solver<Float>::bom_wo) { cudaMemcpy(host_tmp_p.get(), buf_front_.get(), sizeof(Float) * this->numTotalNodesInGridIncludingHalo(), cudaMemcpyDeviceToHost); assert(cudaGetLastError() == cudaSuccess); } func(*this, host_tmp_p.get()); if (mode != Solver<Float>::bom_ro) { cudaMemcpy(buf_front_.get(), host_tmp_p.get(), sizeof(Float) * this->numTotalNodesInGridIncludingHalo(), cudaMemcpyHostToDevice); assert(cudaGetLastError() == cudaSuccess); } } template <typename Float> __global__ void gpu_diffusion3d(Float *f, Float *fn, dim3 numNodesInGrid, Vec3<Float> c, Float cc) { int j,jx,jy,jz; float fcc,fce,fcw,fcn,fcs,fca,fcb; jx=blockDim.x*blockIdx.x+threadIdx.x; jy=blockDim.y*blockIdx.y+threadIdx.y; jz=blockDim.z*blockIdx.z+threadIdx.z; j=jx+numNodesInGrid.x*jy+numNodesInGrid.x*numNodesInGrid.y*jz; fcc=f[j]; if(jx==0) fcw=fcc; else fcw=f[j-1]; if(jx==numNodesInGrid.x-1) fce=fcc; else fce=f[j+1]; if(jy==0) fcs=fcc; else fcs=f[j-numNodesInGrid.x]; if(jy==numNodesInGrid.y-1) fcn=fcc; else fcn=f[j+numNodesInGrid.x]; if(jz==0) fcb=fcc; else fcb=f[j-numNodesInGrid.x*numNodesInGrid.y]; if(jz==numNodesInGrid.z-1) fca=fcc; else fca=f[j+numNodesInGrid.x*numNodesInGrid.y]; fn[j]=c.x*(fce+fcw)+c.y*(fcn+fcs)+c.z*(fca+fcb)+cc*fcc; } template <typename Float> int MySolver<Float>::nextTick(Float kappa, Float dt) { uint const nx = this->numNodesInGrid().x; uint const ny = this->numNodesInGrid().y; uint const nz = this->numNodesInGrid().z; Vec3<Float> const c = kappa * dt / (cellSpacing_ * cellSpacing_); Float const cc = Float(1.0) - (c.x + c.x + c.y + c.y + c.z + c.z); dim3 Dg(nx/32,ny/16,nz/1), Db(32,16,1); gpu_diffusion3d<Float><<< Dg, Db >>>(buf_front_.get(), buf_back_.get(), numNodesInGrid_, c, cc); cudaThreadSynchronize(); assert(cudaGetLastError() == cudaSuccess); return this->numTotalNodesInGrid() * 13; } template <typename Float> void MySolver<Float>::swapBuffers() { buf_back_.swap(buf_front_); } #endif
3a3fffe57a52d212b4b88465c9e4ad9d7c758044
c11da72ede8450aad6767eb5d9d6b00cace13042
/ViroRenderer/VROChoreographer.cpp
f5565a63d44d9478def792497119a8362672c136
[ "MIT" ]
permissive
mendix/virocore
192d1e79f5b5d36d920a4608939843c3e808c2d4
fd3cf5ac4222bb48a5b3af984f0c428ea316d762
refs/heads/master
2023-02-17T17:25:58.449812
2021-01-06T17:23:28
2021-01-06T17:23:28
258,201,318
1
2
MIT
2021-01-06T17:28:07
2020-04-23T12:54:36
C++
UTF-8
C++
false
false
20,782
cpp
VROChoreographer.cpp
// // VROChoreographer.cpp // ViroKit // // Created by Raj Advani on 8/9/17. // Copyright © 2017 Viro Media. All rights reserved. // // 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 "VROChoreographer.h" #include "VRORenderPass.h" #include "VRODriver.h" #include "VRORenderTarget.h" #include "VROImageShaderProgram.h" #include "VROImagePostProcess.h" #include "VRORenderContext.h" #include "VROMatrix4f.h" #include "VROScene.h" #include "VROEye.h" #include "VROToneMappingRenderPass.h" #include "VROGaussianBlurRenderPass.h" #include "VROPostProcessEffectFactory.h" #include "VRORenderMetadata.h" #include "VRORenderToTextureDelegate.h" #include "VROPreprocess.h" #include "VROShadowPreprocess.h" #include "VROIBLPreprocess.h" #include "VRORenderer.h" #include <vector> #pragma mark - Initialization VROChoreographer::VROChoreographer(VRORendererConfiguration config, std::shared_ptr<VRODriver> driver) : _driver(driver), _clearColor({ 0, 0, 0, 1 }), _renderTargetsChanged(false) { // Derive supported features on this GPU _mrtSupported = driver->getGPUType() != VROGPUType::Adreno330OrOlder; _hdrSupported = _mrtSupported && driver->getColorRenderingMode() != VROColorRenderingMode::NonLinear; _pbrSupported = _hdrSupported; _bloomSupported = _mrtSupported && _hdrSupported && driver->isBloomSupported(); _postProcessMaskSupported = _mrtSupported; // Enable defaults based on input flags and and support _shadowsEnabled = _mrtSupported && config.enableShadows; _hdrEnabled = _hdrSupported && config.enableHDR; _pbrEnabled = _hdrSupported && config.enablePBR; _bloomEnabled = _bloomSupported && config.enableBloom; _postProcessMaskEnabled = false; _renderToTextureDelegate = nullptr; // This is always created so that it can be configured even if HDR is off. Useful // for applications that dynamically turn HDR on and off. _gaussianBlurPass = std::make_shared<VROGaussianBlurRenderPass>(); _postProcessEffectFactory = std::make_shared<VROPostProcessEffectFactory>(); _postProcessEffectFactory->setGaussianBlurPass(_gaussianBlurPass); createRenderTargets(); } VROChoreographer::~VROChoreographer() { } void VROChoreographer::createRenderTargets() { std::shared_ptr<VRODriver> driver = _driver.lock(); if (!driver) { return; } pinfo("Creating render targets with configuration:"); pinfo("[MRT supported: %d]", _mrtSupported); pinfo("[Shadows enabled: %d]", _shadowsEnabled); pinfo("[HDR supported: %d, HDR enabled: %d]", _hdrSupported, _hdrEnabled); pinfo("[PBR supported: %d, PBR enabled: %d]", _pbrSupported, _pbrEnabled); pinfo("[Bloom supported: %d, Bloom enabled: %d]", _bloomSupported, _bloomEnabled); _blitPostProcess.reset(); _blitTarget.reset(); _rttTarget.reset(); _postProcessTargetA.reset(); _postProcessTargetB.reset(); _hdrTarget.reset(); _additiveBlendPostProcess.reset(); _toneMappingPass.reset(); _preprocesses.clear(); _gaussianBlurPass->resetRenderTargets(); VRORenderTargetType colorType = _hdrEnabled ? VRORenderTargetType::ColorTextureHDR16 : VRORenderTargetType::ColorTexture; if (_mrtSupported) { std::vector<std::string> blitSamplers = { "source_texture" }; std::vector<std::string> blitCode = { "uniform sampler2D source_texture;", "frag_color = texture(source_texture, v_texcoord);" }; std::shared_ptr<VROShaderProgram> blitShader = VROImageShaderProgram::create(blitSamplers, blitCode, driver); _blitPostProcess = driver->newImagePostProcess(blitShader); _blitTarget = driver->newRenderTarget(colorType, 1, 1, false, true); _rttTarget = driver->newRenderTarget(VRORenderTargetType::ColorTexture, 1, 1, false, true); _preprocesses.clear(); if (_shadowsEnabled) { _preprocesses.push_back(std::make_shared<VROShadowPreprocess>(driver)); } if (_pbrEnabled) { _preprocesses.push_back(std::make_shared<VROIBLPreprocess>()); } } if (_hdrEnabled) { _postProcessTargetA = driver->newRenderTarget(VRORenderTargetType::ColorTextureHDR16, 1, 1, false, false); _postProcessTargetB = driver->newRenderTarget(VRORenderTargetType::ColorTextureHDR16, 1, 1, false, false); // Configure the number of render targets. // TODO: Consider making the assignment of render target attachments more dynamic. int renderTargetNum; if (_postProcessMaskEnabled) { renderTargetNum = 4; _gaussianBlurPass->createRenderTargets(driver); } else if (_bloomEnabled) { renderTargetNum = 3; _gaussianBlurPass->createRenderTargets(driver); } else { renderTargetNum = 2; } if (_bloomEnabled) { // The HDR target includes an additional attachment to which we render a tone-mapping mask // (indicating what fragments require tone-mapping), and one to which we render bloom _hdrTarget = driver->newRenderTarget(VRORenderTargetType::ColorTextureHDR16, renderTargetNum, 1, false, true); std::vector<std::string> samplers = { "hdr_texture", "bloom_texture" }; std::vector<std::string> code = { "uniform sampler2D hdr_texture;", "uniform sampler2D bloom_texture;", // The HDR input is not premultiplied, so multiply its RGB by its alpha "highp vec4 base = texture(hdr_texture, v_texcoord);", "base.rgb *= base.a;", // The bloom input is already premultiplied (see VROGaussianBlurRenderPass) "highp vec4 bloom = texture(bloom_texture, v_texcoord);", "frag_color = base + bloom;", "frag_color.a = frag_color.a > 1.0 ? 1.0 : frag_color.a;" }; _additiveBlendPostProcess = driver->newImagePostProcess(VROImageShaderProgram::create(samplers, code, driver)); } else { // The HDR target includes an additional attachment to which we render a tone-mapping mask // (indicating what fragments require tone-mapping) _hdrTarget = driver->newRenderTarget(VRORenderTargetType::ColorTextureHDR16, renderTargetNum, 1, false, true); } bool needsSoftwareGammaPass = driver->getColorRenderingMode() == VROColorRenderingMode::LinearSoftware; _toneMappingPass = std::make_shared<VROToneMappingRenderPass>(VROToneMappingMethod::HableLuminanceOnly, needsSoftwareGammaPass, driver); driver->setHasSoftwareGammaPass(needsSoftwareGammaPass); } else { driver->setHasSoftwareGammaPass(false); } /* If a viewport has been set, set it on all render targets. */ if (_viewport) { setViewport(*_viewport, driver); } setClearColor(_clearColor, driver); } void VROChoreographer::setViewport(VROViewport viewport, std::shared_ptr<VRODriver> &driver) { _viewport = viewport; /* The display needs the full viewport, in case it's rendering to a translated half of a larger screen (e.g. as in VR). */ driver->getDisplay()->setViewport(viewport); /* The render targets use an un-translated viewport. We simply blit over the final render target to the display, which will translate it to the correct location on the display because we gave the display the fully specified viewport. */ VROViewport rtViewport = VROViewport(0, 0, viewport.getWidth(), viewport.getHeight()); /* We immediately hydrate only core render targets, and disable HDR if any of them fail. Other (non-core) render targets are only hydrated when used, in order to conserve memory. */ bool failed = false; if (_blitTarget) { _blitTarget->setViewport(rtViewport); if (!_blitTarget->hydrate()) { pwarn("Blit target creation failed"); failed = true; } } if (_rttTarget) { _rttTarget->setViewport(rtViewport); } if (_postProcessTargetA) { _postProcessTargetA->setViewport(rtViewport); } if (_postProcessTargetB) { _postProcessTargetB->setViewport(rtViewport); } if (_hdrTarget) { _hdrTarget->setViewport(rtViewport); if (!_hdrTarget->hydrate()) { pwarn("HDR render target creation failed"); failed = true; } } _gaussianBlurPass->setViewPort(viewport, driver); if (failed) { pwarn("One or more render targets failed creation: disabling HDR and retrying"); setHDREnabled(false); } } #pragma mark - Main Render Cycle void VROChoreographer::render(VROEyeType eye, std::shared_ptr<VROScene> scene, std::shared_ptr<VROScene> outgoingScene, const std::shared_ptr<VRORenderMetadata> &metadata, VRORenderContext *context, std::shared_ptr<VRODriver> &driver) { if (_renderTargetsChanged) { createRenderTargets(); _renderTargetsChanged = false; } if (eye == VROEyeType::Left || eye == VROEyeType::Monocular) { for (std::shared_ptr<VROPreprocess> &preprocess : _preprocesses) { preprocess->execute(scene, context, driver); } } renderScene(scene, outgoingScene, metadata, context, driver); } void VROChoreographer::renderScene(std::shared_ptr<VROScene> scene, std::shared_ptr<VROScene> outgoingScene, const std::shared_ptr<VRORenderMetadata> &metadata, VRORenderContext *context, std::shared_ptr<VRODriver> &driver) { VRORenderPassInputOutput inputs; if (_hdrEnabled) { if (_bloomEnabled && metadata->requiresBloomPass()) { // Render the scene + bloom to the floating point HDR MRT target inputs.outputTarget = _hdrTarget; _baseRenderPass->render(scene, outgoingScene, inputs, context, driver); // Blur the image. The finished result will reside in _blurTargetB. inputs.textures[kGaussianInput] = _hdrTarget->getTexture(2); _gaussianBlurPass->render(scene, outgoingScene, inputs, context, driver); // Additively blend the bloom back into the image, store in _blitTarget. Note we // have to set the blend mode to PremultiplyAlpha because the input texture (the blur // texture) has alpha premultiplied -- so we don't want OpenGL to multiply its colors // by alpha *again*. driver->bindRenderTarget(_blitTarget, VRORenderTargetUnbindOp::Invalidate); driver->setBlendingMode(VROBlendMode::PremultiplyAlpha); _additiveBlendPostProcess->blit({ _hdrTarget->getTexture(0), inputs.outputTarget->getTexture(0) }, driver); driver->setBlendingMode(VROBlendMode::Alpha); // Run additional post-processing on the normal HDR image bool canProcessMask = metadata->requiresPostProcessMaskPass() && _postProcessMaskEnabled; std::shared_ptr<VROTexture> postProcessMask = canProcessMask ? _hdrTarget->getTexture(3) : nullptr; std::shared_ptr<VRORenderTarget> postProcessTarget = _postProcessEffectFactory->handlePostProcessing(_blitTarget, _postProcessTargetA, _postProcessTargetB, postProcessMask, context, driver); passert (postProcessTarget->getTexture(0) != nullptr); // Blend, tone map, and gamma correct inputs.textures[kToneMappingHDRInput] = postProcessTarget->getTexture(0); inputs.textures[kToneMappingMaskInput] = _hdrTarget->getTexture(1); if (_renderToTextureDelegate) { _rttTarget->hydrate(); inputs.outputTarget = _rttTarget; _toneMappingPass->render(scene, outgoingScene, inputs, context, driver); renderToTextureAndDisplay(_rttTarget, driver); } else { inputs.outputTarget = driver->getDisplay(); _toneMappingPass->render(scene, outgoingScene, inputs, context, driver); } } else { // Render the scene to the floating point HDR target inputs.outputTarget = _hdrTarget; _baseRenderPass->render(scene, outgoingScene, inputs, context, driver); // Run additional post-processing on the HDR image bool canProcessMask = metadata->requiresPostProcessMaskPass() && _postProcessMaskEnabled; std::shared_ptr<VROTexture> postProcessMask = canProcessMask ? _hdrTarget->getTexture(3) : nullptr; std::shared_ptr<VRORenderTarget> postProcessTarget = _postProcessEffectFactory->handlePostProcessing(_hdrTarget, _postProcessTargetA, _postProcessTargetB, postProcessMask, context, driver); // Perform tone-mapping with gamma correction inputs.textures[kToneMappingHDRInput] = postProcessTarget->getTexture(0); inputs.textures[kToneMappingMaskInput] = _hdrTarget->getTexture(1); if (_renderToTextureDelegate) { _rttTarget->hydrate(); inputs.outputTarget = _rttTarget; _toneMappingPass->render(scene, outgoingScene, inputs, context, driver); renderToTextureAndDisplay(_rttTarget, driver); } else { inputs.outputTarget = driver->getDisplay(); _toneMappingPass->render(scene, outgoingScene, inputs, context, driver); } } } else if (_mrtSupported && _renderToTextureDelegate) { _rttTarget->hydrate(); inputs.outputTarget = _rttTarget; _baseRenderPass->render(scene, outgoingScene, inputs, context, driver); renderToTextureAndDisplay(_rttTarget, driver); } else { // Render to the display directly inputs.outputTarget = driver->getDisplay(); _baseRenderPass->render(scene, outgoingScene, inputs, context, driver); } } void VROChoreographer::setClearColor(VROVector4f color, std::shared_ptr<VRODriver> driver) { _clearColor = color; // Set the default clear color for the following targets driver->getDisplay()->setClearColor(color); if (_blitTarget) { _blitTarget->setClearColor(color); } if (_rttTarget) { _rttTarget->setClearColor(color); } if (_hdrTarget) { _hdrTarget->setClearColor(color); } if (_postProcessTargetA) { _postProcessTargetA->setClearColor(color); } if (_postProcessTargetB) { _postProcessTargetB->setClearColor(color); } if (_gaussianBlurPass) { _gaussianBlurPass->setClearColor(color); } } #pragma mark - Render to Texture void VROChoreographer::renderToTextureAndDisplay(std::shared_ptr<VRORenderTarget> input, std::shared_ptr<VRODriver> driver) { _renderToTextureDelegate->didRenderFrame(input, driver); // Blit direct to the display. We can't use the blitColor method here // because the display is multisampled (blitting to a multisampled buffer // is not supported). driver->bindRenderTarget(driver->getDisplay(), VRORenderTargetUnbindOp::Invalidate); _blitPostProcess->blit({ input->getTexture(0) }, driver); } std::shared_ptr<VROToneMappingRenderPass> VROChoreographer::getToneMapping() { return _toneMappingPass; } std::shared_ptr<VROPostProcessEffectFactory> VROChoreographer::getPostProcessEffectFactory(){ return _postProcessEffectFactory; } void VROChoreographer::setRenderToTextureDelegate(std::shared_ptr<VRORenderToTextureDelegate> delegate) { _renderToTextureDelegate = delegate; } #pragma mark - Renderer Settings bool VROChoreographer::setHDREnabled(bool enableHDR) { if (!enableHDR) { if (_hdrEnabled) { _hdrEnabled = false; _renderTargetsChanged = true; } return true; } else { // enableHDR if (!_hdrSupported) { return false; } else if (!_hdrEnabled) { _hdrEnabled = true; _renderTargetsChanged = true; } return true; } } bool VROChoreographer::setPBREnabled(bool enablePBR) { if (!enablePBR) { if (_pbrEnabled) { _pbrEnabled = false; _renderTargetsChanged = true; } return true; } else { // enablePBR if (!_pbrSupported) { return false; } else if (!_pbrEnabled) { _pbrEnabled = true; _renderTargetsChanged = true; } return true; } } bool VROChoreographer::setShadowsEnabled(bool enableShadows) { if (!enableShadows) { if (_shadowsEnabled) { _shadowsEnabled = false; _renderTargetsChanged = true; } return true; } else { // enableShadows if (!_mrtSupported) { return false; } else if (!_shadowsEnabled) { _shadowsEnabled = true; _renderTargetsChanged = true; } return true; } } bool VROChoreographer::setBloomEnabled(bool enableBloom) { if (!enableBloom) { if (_bloomEnabled) { _bloomEnabled = false; _renderTargetsChanged = true; } return true; } else { // enableBloom if (!_bloomSupported) { return false; } else if (!_bloomEnabled) { _bloomEnabled = true; _renderTargetsChanged = true; } return true; } } bool VROChoreographer::setPostProcessMaskEnabled(bool enablePostProcessMask) { if (!enablePostProcessMask) { if (_postProcessMaskEnabled) { _postProcessMaskEnabled = false; _renderTargetsChanged = true; } return true; } else { if (!_postProcessMaskSupported) { return false; } else if (!_postProcessMaskEnabled) { _postProcessMaskEnabled = true; _renderTargetsChanged = true; } return true; } }
001ebb84b58c917d34b0a6e5ff49970459116514
7ada3d5c958cfdaeefa3d67d0815bb027006f65f
/Engine/Engine/src/Render/Utility/MaterialLibrary.cpp
d7ccafe5ec0c3a5d0f48d5daba4b5d432a12f9f6
[]
no_license
JSpink95/cypher
55778e2db3a842b502027a8d429393837eed0bfb
d6567e685a03a033b3ab447a84ea1b999a76b3ad
refs/heads/master
2020-11-27T11:55:41.064332
2020-02-20T17:17:37
2020-02-20T17:17:37
229,427,654
0
0
null
null
null
null
UTF-8
C++
false
false
5,301
cpp
MaterialLibrary.cpp
////////////////////////////////////////////////////////////////////////// // File : MaterialLibrary.cpp // Created By : Jack Spink // Created On : [18/10/2019] ////////////////////////////////////////////////////////////////////////// #include "Render/Utility/MaterialLibrary.h" ////////////////////////////////////////////////////////////////////////// #include "Core/Utility/Console.h" #include "Core/Utility/FileVolumeManager.h" ////////////////////////////////////////////////////////////////////////// #include "Render/Platform/Material.h" ////////////////////////////////////////////////////////////////////////// #include "pugixml.hpp" ////////////////////////////////////////////////////////////////////////// #include <algorithm> ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::Initialise() { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { library->InitialiseImpl(); } } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::Reload() { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { library->ReloadImpl(); } } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::RegisterMaterial(const std::string& id, const std::string& materialPath) { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { return library->RegisterMaterialImpl(id, materialPath); } return nullptr; } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::RegisterMaterial(const std::string& id, Ref<Material> material) { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { return library->RegisterMaterialImpl(id, material); } return nullptr; } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::GetMaterialNames(std::vector<std::string>& materials) { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { library->GetMaterialNamesImpl(materials); } } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::GetMaterial(const std::string& id) { Ref<MaterialLibrary> library = GetMaterialLibrary(); if (library) { return library->GetMaterialImpl(id); } return nullptr; } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::InitialiseImpl() { // Load MaterialAssets.xml PathResult materialAssetPath = FileVolumeManager::GetRealPathFromVirtualPath("assets:\\MaterialAssets.xml"); if (materialAssetPath.valid) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(materialAssetPath.fullpath.c_str()); if (result) { pugi::xml_node root = doc.root().child("materials"); for (pugi::xml_node materialNode : root) { const char* filepath = materialNode.attribute("filepath").as_string(); LOG_INFO("Loading material('%s')\n", filepath); RegisterMaterialImpl(filepath, filepath); } } } } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::ReloadImpl() { } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::RegisterMaterialImpl(const std::string& id, const std::string& materialPath) { auto it = loadedMaterials.find(id); if (it != loadedMaterials.end()) { return it->second; } Ref<Material> loadedMaterial = Material::LoadFromFile(materialPath); loadedMaterials.insert(std::make_pair(id, loadedMaterial)); return loadedMaterial; } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::RegisterMaterialImpl(const std::string& id, Ref<Material> material) { auto it = loadedMaterials.find(id); if (it != loadedMaterials.end()) { return it->second; } loadedMaterials.insert(std::make_pair(id, material)); return material; } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::GetMaterialNamesImpl(std::vector<std::string>& materials) { std::transform(loadedMaterials.begin(), loadedMaterials.end(), std::back_inserter(materials), [](const std::pair<std::string, Ref<Material>>& it) -> std::string { return it.first; }); } ////////////////////////////////////////////////////////////////////////// Ref<Material> MaterialLibrary::GetMaterialImpl(const std::string& id) { // #hack - bit naughty, but this can add/find a material because the id is now the filepath... return RegisterMaterialImpl(id, id); } ////////////////////////////////////////////////////////////////////////// void MaterialLibrary::ReloadMaterialImpl(const std::string& id) { auto it = loadedMaterials.find(id); if (it != loadedMaterials.end()) { it->second->Reload(); } } //////////////////////////////////////////////////////////////////////////
291ea2eecf7a806a355c725595369c0b83d8db16
67108fc261b796cea22671fddceefc1ca4f47eab
/hw1_ip_filter/src/IpFilter/Boundaries.h
018bf064616b59c9ca884001a6acad137f733b82
[]
no_license
jketra/try_git
d9d8e76d01b2c4f066600ecb1ff4b55f5c4e255f
3ab5caf4bbd12dd842ce78e07dbeb19af7ce27ea
refs/heads/master
2023-08-06T04:16:08.591632
2021-09-23T22:43:08
2021-09-23T22:43:08
409,750,354
0
0
null
2021-09-23T22:43:09
2021-09-23T21:37:06
C++
UTF-8
C++
false
false
119
h
Boundaries.h
#pragma once namespace hw1 { template <typename T> struct Boundaries { T min; T max; }; } // namespace hw1
55f490658d7283daf15c747d009bf513ff34c7a5
b4638c7b7762e54b00b28a0d56c8e2282846ff52
/avogadro/rendering/glrendervisitor.cpp
18710269219e1852b606ffd26ac3b4aded319ee0
[ "BSD-3-Clause" ]
permissive
OpenChemistry/avogadrolibs
0b376e4a60432faf8521b8f9ee74109f1f3aee9d
b5239fe587c9ae1494cf1c3aca8c681a0c275bba
refs/heads/master
2023-08-28T20:30:26.963289
2023-08-10T14:54:01
2023-08-10T14:54:01
4,169,531
368
167
BSD-3-Clause
2023-09-14T19:50:37
2012-04-28T18:56:52
C++
UTF-8
C++
false
false
2,261
cpp
glrendervisitor.cpp
/****************************************************************************** This source file is part of the Avogadro project. This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ #include "glrendervisitor.h" #include "ambientocclusionspheregeometry.h" #include "curvegeometry.h" #include "cylindergeometry.h" #include "linestripgeometry.h" #include "meshgeometry.h" #include "spheregeometry.h" #include "textlabel2d.h" #include "textlabel3d.h" namespace Avogadro::Rendering { GLRenderVisitor::GLRenderVisitor(const Camera& camera_, const TextRenderStrategy* trs) : m_camera(camera_), m_textRenderStrategy(trs), m_renderPass(NotRendering) { } GLRenderVisitor::~GLRenderVisitor() { } void GLRenderVisitor::visit(Drawable& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(SphereGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(AmbientOcclusionSphereGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(CurveGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(CylinderGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(MeshGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } void GLRenderVisitor::visit(TextLabel2D& geometry) { if (geometry.renderPass() == m_renderPass) { if (m_textRenderStrategy) geometry.buildTexture(*m_textRenderStrategy); geometry.render(m_camera); } } void GLRenderVisitor::visit(TextLabel3D& geometry) { if (geometry.renderPass() == m_renderPass) { if (m_textRenderStrategy) geometry.buildTexture(*m_textRenderStrategy); geometry.render(m_camera); } } void GLRenderVisitor::visit(LineStripGeometry& geometry) { if (geometry.renderPass() == m_renderPass) geometry.render(m_camera); } } // End namespace Avogadro
a784e43e78d78f181d0d569d860969abc7c76a34
edc6c2da8ceaa6de390db6a37aee098c963967fc
/IMonitorDisplay.hpp
d4c3e851615c0b4994ce6d9b99b47306b232c008
[]
no_license
vtolochk/SysMonitor
a409108e0529c7c31c36de9b873f7a8ab59f8491
963d64257ec8cea99985ec7f4bc8aebe6c83201e
refs/heads/master
2020-03-22T00:05:21.904831
2018-07-08T16:05:13
2018-07-08T16:05:13
139,223,954
0
1
null
2018-07-01T15:35:50
2018-06-30T06:07:51
C++
UTF-8
C++
false
false
365
hpp
IMonitorDisplay.hpp
#ifndef I_MONITOR_DISPLAY_H #define I_MONITOR_DISPLAY_H #include <iostream> #include <unistd.h> #include <sys/sysctl.h> #include <time.h> #include <sstream> #include <mach/mach_host.h> #include <mach/processor_info.h> #include <vector> #include <numeric> #include <iomanip> class IMonitorDisplay { public: virtual void displayInfo(void) = 0; }; #endif
56d71934114e646497d34edb38c823a8f5015607
6a649591bcc03808e904994dc467d280e26560d4
/Source/Map/Tile.cpp
4ba357fb6149f4ac321397b44703d62b282f8686
[]
no_license
ErosPinzani/Game
d22fcbc6c0132b45d2967c9d43dde6e9b4ab6d4a
048ecb94173c26aa01de5b003ad7822c3d1af46e
refs/heads/master
2023-08-12T07:43:28.288693
2021-10-14T14:00:33
2021-10-14T14:00:33
377,490,990
0
0
null
null
null
null
UTF-8
C++
false
false
542
cpp
Tile.cpp
// // Created by erosp on 16/06/2021. // #include "../../Include/Map/Tile.h" Tile::Tile(std::string textureName, float x, float y, bool walkable, bool exit) { pos = sf::Vector2f (x, y); sprite.setPosition(pos); isWalkable = walkable; isExit = exit; if (!setUpSprite(textureName)) return; } bool Tile::setUpSprite(std::string textureName) { if (!texture.loadFromFile(textureName)) return false; sprite.setTexture(texture); sprite.setTextureRect(sf::IntRect(0, 0, 50, 50)); return true; }
51a2ecfec1b5aa9f59686631824aacff0b4d194b
e01b075a0016465a41960b6e01527b172c6d524c
/recursion/string.cpp
8d2d86cff745e0e13039e8737610b35643607604
[]
no_license
nischay123/cplusplusprograms
4f5b38f829b865cd5cecbb12720b721dc4c25f8b
3c58d86c0cb821e28e79dfdd5661297a43d44626
refs/heads/main
2023-01-28T12:35:47.597234
2020-12-12T03:19:00
2020-12-12T03:19:00
317,742,133
0
0
null
null
null
null
UTF-8
C++
false
false
531
cpp
string.cpp
#include <iostream> using namespace std; int count(char* str){ if(str[0] == '\0'){ return 0; } return 1+count(str+1); } void removex(char* str ){ char ch = str[0]; char result[100] ; if(ch == '\0'){ return ; } if(ch!='x'){ removex(str+1); }else{ int i; for(i=0;str[i]!='\0';i++){ str[i]=str[i+1]; } str[i]=str[i+1]; removex(str); } } int main(){ char str[100]; cin>>str; cout<<"length : "<<count(str); removex(str); return 0; }
f2be93ca35f73af48b1c045355402929e243bece
a8440388d84b20a4803af7115d63824cb40931b3
/Week2/Question2.cpp
7eee8ba4dde09deb6210a84beff0fe66b390ab32
[]
no_license
Vasudha-2010/DAA-
2b3a5fc9edb823aebd2ffb608470c42a7d0319b2
8d51e53d71e61bf4a7927420d840cedd8aa8a5db
refs/heads/main
2023-08-15T03:44:59.955121
2021-09-23T10:59:24
2021-09-23T10:59:24
385,831,135
0
0
null
null
null
null
UTF-8
C++
false
false
858
cpp
Question2.cpp
#include<iostream> using namespace std; void sequence(int arr[],int N) { for(int i=N-1;i>=0;i--) { int j=0; int k=i-1; while(j<k) { if(arr[i]==arr[j]+arr[k]) { cout<<"The indices are : "<<j<<" "<<k<<" "<<i; return; } else if(arr[i]>arr[j]+arr[k]) { j+=1; } else k-=1; } } cout<<"No sequence exists !"; } int main() { int t; cin>>t; while(t--) { int N; cin>>N; int arr[N]; for(int i=0;i<N;i++) { cin>>arr[i]; } sequence(arr,N); } }
392d88fc7247bf383cc9e7285af65e978b52e8f5
f810d84bc2ab193f654f139d392292668d50602e
/lab2/src/consoleLock.cpp
41e1c290588c7a0c89f55e3a6500c2fa222119bb
[]
no_license
kirsanium/vorv
1fe039ef6d19252295997133433108d7cf51b088
fd1c4507da329e78256e14f8b9f05122da716c01
refs/heads/master
2020-09-28T21:34:28.437884
2019-12-23T07:15:24
2019-12-23T07:15:24
226,870,164
0
0
null
null
null
null
UTF-8
C++
false
false
5,826
cpp
consoleLock.cpp
#include <queue> #include <vector> #include <mpi.h> #include "consts.cpp" #include "asyncRequest.cpp" using namespace std; class ConsoleLock { private: int rank, size, recipient_amount; MPI_Comm* comm; int clock = 0; int ask_timestamp; int ask_flag = 0; MPI_Request ask_request = MPI_REQUEST_NULL; MPI_Status ask_status; queue<vector<AsyncRequest*>*> recv_requests_queue; vector<int> deferred_replies; vector<AsyncRequest*> send_requests; public: ConsoleLock(int rank, int size, MPI_Comm* comm) : rank(rank), size(size), comm(comm), recipient_amount(size-1) { } void init() { MPI_Irecv(&ask_timestamp, 1, MPI_INT, MPI_ANY_SOURCE, Consts::CRITICAL_REQUEST_TAG, *comm, &ask_request); } void request() { send_to_everyone(Consts::CRITICAL_REQUEST_TAG); nonblocking_receive_from_everyone(Consts::CRITICAL_RESPONSE_TAG); } bool lock() { if (wants_output()) { handle_incoming_replies(); int replies = get_number_of_replies(); if (replies == recipient_amount) { return true; } } return false; } void exit() { vector<AsyncRequest*>* recv_requests = recv_requests_queue.front(); for (auto iter = recv_requests->begin(); iter != recv_requests->end(); ++iter) { delete(*iter); } recv_requests_queue.pop(); delete(recv_requests); if (!wants_output()) { send_all_deferred_messages(); } } void test() { MPI_Test(&ask_request, &ask_flag, &ask_status); while (ask_flag) { handle_incoming_ask(); MPI_Irecv(&ask_timestamp, 1, MPI_INT, MPI_ANY_SOURCE, Consts::CRITICAL_REQUEST_TAG, *comm, &ask_request); MPI_Test(&ask_request, &ask_flag, &ask_status); } test_all_send_requests(); } ~ConsoleLock() { MPI_Cancel(&ask_request); } int get_clock() { return clock; } private: bool wants_output() { return !recv_requests_queue.empty(); } void handle_incoming_ask() { update_clock(&clock, ask_timestamp); if (clock > ask_timestamp || !wants_output()) { send_message(&clock, ask_status.MPI_SOURCE, Consts::CRITICAL_RESPONSE_TAG); } else { deferred_replies.push_back(ask_status.MPI_SOURCE); } ask_flag = 0; ask_request = MPI_REQUEST_NULL; } void handle_incoming_replies() { vector<AsyncRequest*>* reply_requests = recv_requests_queue.front(); for (auto iter = reply_requests->begin(); iter != reply_requests->end(); ++iter) { AsyncRequest* request = *iter; if (request->flag == 0) { MPI_Test(request->request, &(request->flag), MPI_STATUS_IGNORE); if (request->flag != 0) { update_clock(&clock, *(request->clock)); } } } } int get_number_of_replies() { int replies = 0; vector<AsyncRequest*>* reply_requests = recv_requests_queue.front(); for (auto iter = reply_requests->begin(); iter != reply_requests->end(); ++iter) { AsyncRequest* request = *iter; if (request->flag != 0) { ++replies; } } return replies; } void update_clock(int* clock, int timestamp) { if (timestamp > *clock) *clock = timestamp + 1; else *clock += 1; } void send_to_everyone(int tag) { for (int i = 0; i < size; ++i) { if (i == rank) continue; send_message(&clock, i, tag); } } void nonblocking_receive_from_everyone(int tag) { vector<AsyncRequest*>* requests_vec = new vector<AsyncRequest*>; for (int i = 0; i < size; ++i) { if (i == rank) continue; AsyncRequest* request = new AsyncRequest(new MPI_Request(), new int()); MPI_Irecv(request->clock, 1, MPI_INT, i, tag, *comm, request->request); requests_vec->push_back(request); } recv_requests_queue.push(requests_vec); } void send_all_deferred_messages() { if (!deferred_replies.empty()) { for (auto iter = deferred_replies.begin(); iter != deferred_replies.end(); ++iter) { send_message(&clock, *iter, Consts::CRITICAL_RESPONSE_TAG); } // cout << "Sent " << deferred_replies.size() << " deferred messages" << endl; deferred_replies.clear(); } } void send_message(int* clock, int dest, int tag) { (*clock)++; int* payload = new int(*clock); AsyncRequest *send_request = new AsyncRequest(new MPI_Request, payload); MPI_Isend(send_request->clock, 1, MPI_INT, dest, tag, *comm, send_request->request); send_requests.push_back(send_request); } void test_all_send_requests() { // cout << "Im testing all send requests, rank " << rank << endl; auto iter = send_requests.begin(); while ( iter != send_requests.end() ) { AsyncRequest* request = *iter; // cout << "Request*: " << request << ", rank: " << rank << ", req->req: "<< request->request << endl; MPI_Test(request->request, &(request->flag), MPI_STATUS_IGNORE); if (request->flag) { delete(request); iter = send_requests.erase(iter); // cout << "iter after erase: " << *iter << endl; } else { ++iter; } } // cout << "Im finished testing all send requests, rank" << rank << endl; } };
7ee28c5d986755b1be3eb5bb7a51e66e09c263d5
68bfa9d7a6b267f52354415fc72fada1ddfdc9ab
/src/cast_core/src/MoveRandomChunkToRandomShard.cpp
949d802578e6432d7ddb721f31e052b365d3a914
[ "Apache-2.0" ]
permissive
mongodb/genny
5aa3c3be01d8bd8e5b7c9a9d019c5b206d7e97fb
788eaf26e3b8b08d76c71d54fb0013befee9b032
refs/heads/master
2023-09-06T09:25:21.933670
2023-09-05T15:59:07
2023-09-05T15:59:07
121,291,048
44
76
Apache-2.0
2023-09-14T16:50:21
2018-02-12T19:23:44
C++
UTF-8
C++
false
false
7,616
cpp
MoveRandomChunkToRandomShard.cpp
// Copyright 2021-present MongoDB Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <cast_core/actors/MoveRandomChunkToRandomShard.hpp> #include <memory> #include <yaml-cpp/yaml.h> #include <bsoncxx/json.hpp> #include <mongocxx/client.hpp> #include <mongocxx/collection.hpp> #include <mongocxx/database.hpp> #include <boost/log/trivial.hpp> #include <boost/throw_exception.hpp> #include <gennylib/Cast.hpp> #include <gennylib/MongoException.hpp> #include <gennylib/context.hpp> #include <value_generators/DocumentGenerator.hpp> #include <bsoncxx/builder/stream/document.hpp> namespace genny::actor { struct MoveRandomChunkToRandomShard::PhaseConfig { std::string collectionNamespace; PhaseConfig(PhaseContext& phaseContext, ActorId id) : collectionNamespace{phaseContext["Namespace"].to<std::string>()} {} }; void MoveRandomChunkToRandomShard::run() { for (auto&& config : _loop) { for (const auto&& _ : config) { try { auto&& configDatabase = _client->database("config"); // Get the collection uuid. bsoncxx::document::value collectionFilter = bsoncxx::builder::stream::document() << "_id" << config->collectionNamespace << bsoncxx::builder::stream::finalize; auto collectionDocOpt = configDatabase["collections"].find_one(collectionFilter.view()); // There must be a collection with the provided namespace. assert(collectionDocOpt.is_initialized()); auto uuid = collectionDocOpt.get().view()["uuid"].get_binary(); // Select a random chunk. bsoncxx::document::value uuidDoc = bsoncxx::builder::stream::document() << "uuid" << uuid << bsoncxx::builder::stream::finalize; // This is for backward compatibility, before 5.0 chunks were indexed by namespace. bsoncxx::document::value nsDoc = bsoncxx::builder::stream::document() << "ns" << config->collectionNamespace << bsoncxx::builder::stream::finalize; bsoncxx::document::value chunksFilter = bsoncxx::builder::stream::document() << "$or" << bsoncxx::builder::stream::open_array << uuidDoc.view() << nsDoc.view() << bsoncxx::builder::stream::close_array << bsoncxx::builder::stream::finalize; auto numChunks = configDatabase["chunks"].count_documents(chunksFilter.view()); // The collection must have been sharded and must have at least one chunk; boost::random::uniform_int_distribution<int64_t> chunkUniformDistribution(0, (int)numChunks - 1); mongocxx::options::find chunkFindOptions; auto chunkSort = bsoncxx::builder::stream::document() << "lastmod" << 1 << bsoncxx::builder::stream::finalize; chunkFindOptions.sort(chunkSort.view()); chunkFindOptions.skip(chunkUniformDistribution(_rng)); chunkFindOptions.limit(1); auto chunkProjection = bsoncxx::builder::stream::document() << "history" << false << bsoncxx::builder::stream::finalize; chunkFindOptions.projection(chunkProjection.view()); auto chunkCursor = configDatabase["chunks"].find(chunksFilter.view(), chunkFindOptions); assert(chunkCursor.begin() != chunkCursor.end()); bsoncxx::v_noabi::document::view chunk = *chunkCursor.begin(); // Find a destination shard different to the source. bsoncxx::document::value notEqualDoc = bsoncxx::builder::stream::document() << "$ne" << chunk["shard"].get_string() << bsoncxx::builder::stream::finalize; bsoncxx::document::value shardFilter = bsoncxx::builder::stream::document() << "_id" << notEqualDoc.view() << bsoncxx::builder::stream::finalize; auto numShards = configDatabase["shards"].count_documents(shardFilter.view()); boost::random::uniform_int_distribution<int64_t> shardUniformDistribution(0, (int)numShards - 1); mongocxx::options::find shardFindOptions; auto shardSort = bsoncxx::builder::stream::document() << "_id" << 1 << bsoncxx::builder::stream::finalize; shardFindOptions.sort(shardSort.view()); shardFindOptions.skip(shardUniformDistribution(_rng)); shardFindOptions.limit(1); auto shardCursor = configDatabase["shards"].find(shardFilter.view(), shardFindOptions); // There must be at least 1 shard, which will be the destination. assert(shardCursor.begin() != shardCursor.end()); bsoncxx::v_noabi::document::view shard = *shardCursor.begin(); bsoncxx::document::value moveChunkCmd = bsoncxx::builder::stream::document{} << "moveChunk" << config->collectionNamespace << "bounds" << bsoncxx::builder::stream::open_array << chunk["min"].get_value() << chunk["max"].get_value() << bsoncxx::builder::stream::close_array << "to" << shard["_id"].get_string() << bsoncxx::builder::stream::finalize; // This is only for better readability when logging. auto bounds = bsoncxx::builder::stream::document() << "bounds" << bsoncxx::builder::stream::open_array << chunk["min"].get_value() << chunk["max"].get_value() << bsoncxx::builder::stream::close_array << bsoncxx::builder::stream::finalize; BOOST_LOG_TRIVIAL(info) << "MoveChunkToRandomShardActor moving chunk " << bsoncxx::to_json(bounds.view()) << " from: " << chunk["shard"].get_string().value.to_string() << " to: " << shard["_id"].get_string().value.to_string(); _client->database("admin").run_command(moveChunkCmd.view()); } catch (mongocxx::operation_exception& e) { BOOST_THROW_EXCEPTION(MongoException( e, (bsoncxx::builder::stream::document() << bsoncxx::builder::stream::finalize) .view())); } } } } MoveRandomChunkToRandomShard::MoveRandomChunkToRandomShard(genny::ActorContext& context) : Actor{context}, _rng{context.workload().getRNGForThread(MoveRandomChunkToRandomShard::id())}, _client{context.client()}, _loop{context, MoveRandomChunkToRandomShard::id()} {} namespace { // // This tells the "global" cast about our actor using the defaultName() method // in the header file. // auto registerMoveRandomChunkToRandomShard = Cast::registerDefault<MoveRandomChunkToRandomShard>(); } // namespace } // namespace genny::actor
c69cadfe3f98e475f9b321f6c61c5ab2987d038d
7ec060657ad54a104c6b260abf9a4fd83b8b142c
/NeuralNetwork.h
64c023969d6de21302a61d7bdf9699f05b466e3f
[]
no_license
irwin08/NeuralNetwork
3a68b93fa67e307ff4b280f2fbaed84c44abcdb5
f30e50ec4c915061d2b166e2a210070602d5c0a5
refs/heads/master
2020-03-16T21:16:53.657032
2018-05-14T22:24:26
2018-05-14T22:24:26
132,992,507
0
0
null
null
null
null
UTF-8
C++
false
false
1,651
h
NeuralNetwork.h
#include <Eigen/Dense> #include <iostream> #include <vector> using namespace Eigen; class NeuralNetwork { public: // Takes in a vector which gives the number of neurons corresponding to a layer. // For example, a neural net with an input layer with n=3 neurons, a hidden layer with n=5 neurons and an output layer with n=3 neurons // will take the vector [3, 5, 3]. NeuralNetwork(std::vector<int> layerSizes); // assigns values to weights and biases by first looking for an already existing NN, then defaulting to random values if no NN is found. void initializeNeuralNet(); // returns the index number corresponding to the neuron activated in the output layer (starts at i=0) // NOTE: This can be generalized by returning a vector with an arbitrary number of neurons activated over some threshold instead. int getOutput(VectorXf a); // trains neural net using SGD algorithm - takes in a set of input layers to train and a set of desired outputs for said layers. void stochasticGradientDescent(std::vector<VectorXf> trainingSet, std::vector<VectorXf> trainingAnswer, float learningRate); void saveNeuralNetwork(); private: std::vector<int> _layerSizes; std::vector<MatrixXf> _weights; // weights is a vector, where each element corresponds to the relevent weight matrix for the layer. std::vector<VectorXf> _activations; // vector in which each element corresponds to the activation vector for a layer. std::vector<VectorXf> _biases; // vector in which each element corresponds to the bias vector for a layer. VectorXf sigmoid(VectorXf z); VectorXf sigmoidPrime(VectorXf z); };
b09592ed031f4f92643a07c1f947f63ff9964cc3
a6c1222139c2784c1171f66e799861f9779496a5
/Project1/helloworld.cpp
84621d28c1d4502d1467a9bdeec8e2adef27b263
[]
no_license
Anduron/FYS3150
82c819546563bcce8634a074b8469802cc3b1e2f
a7f6ad1a8cf11ebcf0209b71e8bbea1387dc2968
refs/heads/master
2020-03-27T05:01:54.390925
2018-12-14T20:50:55
2018-12-14T20:50:55
145,988,993
0
0
null
null
null
null
UTF-8
C++
false
false
274
cpp
helloworld.cpp
#include <iostream> #include <cmath> using namespace std; int main() { int r; double s; for (int i = 1; i < 10; i = i + 2) { r = i; s = sin(r); cout << "r = " << r << ", " << "s = " << s << "\n"; } cout << "Hello World" << endl; return 0; }
59fd1c7aa05d863e941540ee817fc5544a9778df
1e8636fbfcf0bf494bf4c39b6029a7ca50e9e8ad
/physics/physics.cpp
b76afaedddf619b329aa4fa408448feccbf55607
[]
no_license
dougfrazer/SDP
1db02c254f6f6d32af247ce2964b6b441eadc8be
d98150753774224d58a6e2b38d061722005a854c
refs/heads/master
2021-01-20T04:37:27.707162
2010-06-08T22:03:49
2010-06-08T22:03:49
710,413
3
0
null
null
null
null
UTF-8
C++
false
false
6,237
cpp
physics.cpp
/* * main.cpp * * Created on: Jan 19, 2009 * Author: tim */ #include <list> #include <math.h> #include "types.h" //sliding friction approx .2 //rolling friction approx .016 const double sliding_friction_constant = .2; const double rolling_friction_constant = .016; const double gravity_acceleration = 9.81; // m/s const double mass_of_ball = 10; //check these const double mass_of_cue_stick = 50; const double radius_of_ball = 27.5; //mm?? const double ratio_of_masses = mass_of_ball / mass_of_cue_stick; ////////////////////////////////////////////////////////// // Computes the cross product of two vectors ////////////////////////////////////////////////////////// vector_type crossProduct(vector_type a, vector_type b){ vector_type return_vector; return_vector.i = a.j*b.k - a.k*b.j; return_vector.j = a.k*b.i - a.i*b.k; return_vector.k = a.i*b.j - a.j*b.i; return return_vector; } vector_type addVectors(vector_type a, vector_type b){ vector_type return_vector; return_vector.i = a.i + b.i; return_vector.j = a.j + b.j; return_vector.k = a.k + b.k; return return_vector; } vector_type subtractVectors(vector_type a, vector_type b){ vector_type return_vector; return_vector.i = a.i - b.i; return_vector.j = a.j - b.j; return_vector.k = a.k - b.k; return return_vector; } ////////////////////////////////////////////////////////// // Computes the magnitude of a vector ////////////////////////////////////////////////////////// double magnitude(vector_type a){ return sqrt( pow(a.i, 2) + pow(a.j, 2) + pow(a.k, 2)); } ////////////////////////////////////////////////////////// // Applies the cue stick force to the cue ball ////////////////////////////////////////////////////////// int applyCueForce(physics_state& current_state){ list<ball>::iterator ball_iter = current_state.table.ball_positions.begin(); while(ball_iter != current_state.table.ball_positions.end() && ball_iter->type != cue){ ball_iter++; } //will we ever have to check for the end? we should always have a cue ball right? if(ball_iter == current_state.table.ball_positions.end()) return; //transfer cue stick force to cue ball double a = current_state.cue.x_offset; double b = current_state.cue.y_offset; double c = sqrt( pow(radius_of_ball,2) - pow(a,2) - pow(b,2)); double top = 2 * mass_of_ball * current_state.cue.velocity; double theta = current_state.cue.vertical_angle; double bottom = pow(a,2) + (pow(b,2) * pow(cos(theta),2)) + (pow(c,2)*pow(sin(theta),2)) - (2*b*c*cos(theta)*sin(theta)); bottom *= (5/(2*pow(radius_of_ball,2))); bottom += ratio_of_masses; bottom += 1; //force of cue impact double force = top/bottom; //linear velocity of ball ball_iter->velocity.i = 0; ball_iter->velocity.j = (-force/mass_of_ball) * cos(theta); ball_iter->velocity.k = (-force/mass_of_ball) * sin(theta); double moment_of_inertia = 2/5 * mass_of_ball * pow(radius_of_ball,2); //angular velocity of ball ball_iter->angular_velocity.i = (-c * force * sin(theta) + b * force * cos(theta)) / moment_of_inertia; ball_iter->angular_velocity.j = (a * force * sin(theta)) / moment_of_inertia; ball_iter->angular_velocity.k = (-a * force * cos(theta)) / moment_of_inertia; ball_iter->state = sliding; } ////////////////////////////////////////////////////////// // Tests whether any balls are moving ////////////////////////////////////////////////////////// bool ballsAreMoving(table_state table){ list<ball>::iterator ball_iter = table.ball_positions.begin(); while(ball_iter != table.ball_positions.end()){ if(ball_iter->state != stopped){ return true; } } return false; } typedef enum{ motionTrans, ballCollision, railCollision } event_type; typedef struct{ double time; int ball1; int ball2; event_type event; } event_time; ////////////////////////////////////////////////////////// // Finds motion transition times for all balls // returns smallest time ////////////////////////////////////////////////////////// event_time findMotionTransitions(table_state& table){ event_time smallest_time; smallest_time.event = motionsTrans; smallest_time.time = 1000000; smallest_time.ball1 = 0; list<ball>::iterator ball_iter = table.ball_positions.begin(); while(ball_iter != table.ball_positions.end()){ //transition from sliding to rolling if(ball_iter->state = sliding){ double time_start_rolling = 2 * ball_iter->force.velocity / (7 * sliding_friction_constant * gravity_acceleration); if(time_start_rolling < smallest_time.time){ smallest_time.time = time_start_rolling; smallest_time.ball1 = ball_iter->num; } } //transition from rolling to stopped else if(ball_iter->state = rolling){ double time_stop = ball_iter->force.velocity / (rolling_friction_constant * gravity_acceleration); if(time_stop < smallest_time.time){ smallest_time.time = time_stop; smallest_time.ball1 = ball_iter->num; } } } return smallest_time; } ////////////////////////////////////////////////////////// // Finds all ball-ball collision times // returns smallest time ////////////////////////////////////////////////////////// event_time findBallCollisions(table_state& table){ } ////////////////////////////////////////////////////////// // Finds all ball-rail collisions (includes pockets) // returns smallest time ////////////////////////////////////////////////////////// event_time findRailCollisions(table_state& table){ } ////////////////////////////////////////////////////////// // Moves the table to the next event // Return: time of next event (current time at end of function) ////////////////////////////////////////////////////////// double moveToNextEvent(table_state& table){ findMotionTransitions(table); findBallCollisions(table); findRailCollisions(table); } ////////////////////////////////////////////////////////// // Generates the outcome of a shot ////////////////////////////////////////////////////////// table_state generateOutcome(physics_state current_state){ applyCueForce(current_state); double time = 0; //keep looping while balls are moving while(ballsAreMoving(current_state.table)){ time = moveToNextEvent(current_state.table); } }
dc5dac4f046505aaefaf02d10d161040d05b2c80
5576fc68e5090bb2cdef1f042375c5e050da4eac
/算法导论/91/main.cpp
34cf0aa6a6496b0f65d9ed02b87848e8582b11bd
[]
no_license
xiaogang00/Algorithms
c51bad8891607a6f179981242ac58037a5d0ded1
a2f7ba31b0e09bb016185dc42ac825156db82d88
refs/heads/master
2021-01-13T14:11:26.396201
2017-10-01T04:29:58
2017-10-01T04:29:58
76,168,713
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
312
cpp
main.cpp
#include "head.h" #include "node.h" #include "queue.h" #include "makeadj.h" #include "handle.h" using namespace std; int main(int argc, char *argv[]) { handle_bfs("e:\\in3.txt",0); //º¬²âÊÔÊý¾Ý handle_dfs("e:\\in3.txt"); system("PAUSE"); return EXIT_SUCCESS; }
324abfbaf5d01cdc51651c813a060404d930aceb
31956534d3c35e4a6be018461ddb70f5b5a2faef
/rpi_robot_bringup/include/rpi_robot_bringup/basic_data.hpp
c911d9e006e20ea3dcf53300db3d3ed9a7f9dbe5
[]
no_license
tabris2015/rpi-robot-ros-foxy
86ec100167731c4323a1471fe1fd1f32c0900b1c
a9e297856d414b0550d402342a7fd51b18df320d
refs/heads/master
2023-07-03T03:03:22.939477
2021-08-09T00:56:49
2021-08-09T00:56:49
387,272,383
9
3
null
null
null
null
UTF-8
C++
false
false
75
hpp
basic_data.hpp
#ifndef BASIC_DATA_HPP #define BASIC_DATA_HPP #define BASIC_FLAG 1 #endif
e9449c175329017e5602a019e1753f8bca7ddf4a
a9bb2a9d11a57a06e25fee249a76e2ce2343ed13
/source/Planet.h
202a8bcd507f2e40926efc511678a866828ca534
[]
no_license
theomission/VirtualTerrain
f0b11e678f6d484304cfd5aa5c7221bff41024dc
ac05ee3919600dce1d002ea57d7ac97311cd6cf8
refs/heads/master
2021-01-20T16:21:33.273669
2012-08-27T08:34:12
2012-08-27T08:34:12
46,342,924
1
0
null
2015-11-17T11:31:37
2015-11-17T11:31:37
null
UTF-8
C++
false
false
487
h
Planet.h
/* * Copyright © 2012 Fabian Schuiki */ #pragma once #include "BakedScenery.h" #include "Camera.h" #include "SphericalChunk.h" #include <SFML/Graphics/Image.hpp> class ElevationProvider; class Planet { public: const double radius; vec3 camera_pos_detail, camera_pos_culling, camera_at; SphericalChunk rootChunk; ElevationProvider *elevation; BakedScenery bakedChunks[12][6]; sf::Image color; Planet(); ~Planet(); void updateDetail(Camera &camera); void draw(); };
01ba9b5484741bb3c41738cbd6de6984eec5eb96
ace9852d2b85f5fa083f18d3eb421f508d54cc9d
/include/drivers/keyboard.h
5fa54b72107a954171f26cc8c906e20762124d50
[]
no_license
zbyue/ByOS
19ef746b9a061e4b3c63621a7e62f24726b0ed30
c287356814167c3d7836f2e563bd551eca721b5a
refs/heads/main
2023-04-29T08:16:30.912024
2021-05-11T07:17:08
2021-05-11T07:17:08
321,974,153
1
0
null
null
null
null
UTF-8
C++
false
false
1,290
h
keyboard.h
#ifndef __BYOS__DRIVERS__KEYBOARD_H #define __BYOS__DRIVERS__KEYBOARD_H #include "../common/types.h" #include "../hardware/interrupts.h" #include "../hardware/port.h" #include "../drivers/driver.h" #include "../common/io.h" namespace byos { namespace drivers { class KeyboardEventHandler { public: KeyboardEventHandler(); virtual void onKeyDown(char); virtual void onKeyUp(char); }; class KeyboardDriver : public hardware::InterruptHandler, public Driver { public: KeyboardDriver(hardware::InterruptManager* manager, KeyboardEventHandler* handler); ~KeyboardDriver(); virtual void Activate() override; virtual common::uint32_t HandleInterrupt(common::uint32_t esp); private: byos::hardware::Port8Bit dataport; byos::hardware::Port8Bit commandport; KeyboardEventHandler* handler; }; class PrintKeyboardEventHandler : public KeyboardEventHandler { public: virtual void onKeyDown(char c) { char* foo = " "; foo[0] = c; byos::common::printf(foo); } }; } } #endif
1515bca1189a57e998d8cbe9237bd8909ca9d7fe
1e969d49ac0de1526c99c18c57e5ee9d19455a16
/src/plane.cpp
e41b35ff127a8219d2086c56adffd21b9d0c81e9
[]
no_license
RBoshae/BasicRayTracer
7d9b9a7f2edcd158ea674c68a43fb318c83304ed
d3cae2d6d00bfc183d54ec9afb9d07e9d634f3d4
refs/heads/master
2021-08-28T23:14:16.858669
2017-12-13T08:07:12
2017-12-13T08:07:12
112,877,544
0
0
null
null
null
null
UTF-8
C++
false
false
1,142
cpp
plane.cpp
#include "plane.h" #include "ray.h" #include <cfloat> // Intersect with the half space defined by the plane. The plane's normal // points outside. If the ray starts on the "inside" side of the plane, be sure // to record a hit with t=0 as the first entry in hits. bool Plane:: Intersection(const Ray& ray, std::vector<Hit>& hits) const { // TODO // std::cout << "x1 " << x1 << std::endl; // std::cout << "normal " << normal << std::endl; double denominator; if ((denominator = dot(normal,ray.direction)) != 0) { Hit hit; if((hit.t = -dot(normal,(ray.endpoint - x1))/(denominator)) >=0) { hit.object = this; if(hit.t >= 0) { hit.ray_exiting = false; hits.push_back(hit); return true; } } else if(-dot(normal,(ray.endpoint-x1)) != 0) { // infinite hits //std::cout << "Unhandled case in plane.cpp\n"; return false; } else { return false; } } return false; } vec3 Plane:: Normal(const vec3& point) const { return normal; } // to test code: ./ray_tracer -i tests/00.txt -s tests/00.png
5a88f326ca1b887a8a106775b7fd81e105de123b
5fc3f6f9c7bd1c8573650d8b8a08718de1e744a4
/gtaXAudio2/gtAudioSystemXAudio2.cpp
045aef0aae9e76f5e0f85e05bfc057d1a213cb4e
[ "MIT" ]
permissive
olegkyka/GoST
14eb01f2b7d0f39e9eecb64e91fb2658af25aa2b
3927eac6cf564261fb722c006384d4bc68dfb1f9
refs/heads/master
2021-04-15T15:01:33.467588
2018-03-21T13:36:22
2018-03-21T13:36:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,045
cpp
gtAudioSystemXAudio2.cpp
#include "common.h" gtAudioSystemXAudio2_7* gtAudioSystemXAudio2_7::s_instance = nullptr; gtAudioSystemXAudio2_7::gtAudioSystemXAudio2_7( void ): m_XAudio2( nullptr ), m_MasteringVoice( nullptr ), m_ReverbEffect( nullptr ), m_SubmixVoice( nullptr ) { s_instance = this; CoInitializeEx( NULL, COINIT_MULTITHREADED ); } gtAudioSystemXAudio2_7::~gtAudioSystemXAudio2_7( void ){ m_SubmixVoice->DestroyVoice(); SAFE_RELEASE( m_ReverbEffect ); m_MasteringVoice->DestroyVoice(); SAFE_RELEASE( m_XAudio2 ); CoUninitialize(); } gtAudioSystemXAudio2_7* gtAudioSystemXAudio2_7::getInstance( void ){ return s_instance; } bool gtAudioSystemXAudio2_7::checkFeature( gtAudioPluginFeatures feature ){ switch( feature ){ case gost::gtAudioPluginFeatures::streaming_audio: return true; break; case gost::gtAudioPluginFeatures::reverberation: return false; break; case gost::gtAudioPluginFeatures::pitch: return false; break; case gost::gtAudioPluginFeatures::_3D: return false; break; default: return false; break; } } u32 gtAudioSystemXAudio2_7::getSupportedExtensions( void ){ return NUM_OF_SUPPORTED_EXTENSIONS; } const s8* gtAudioSystemXAudio2_7::getSupportedExtension( u32 id ){ if( id >= NUM_OF_SUPPORTED_EXTENSIONS ) return nullptr; return Extensions[ id ]; } bool gtAudioSystemXAudio2_7::initialize( XAudioVersion version ){ m_version = version; gtString path = gtFileSystem::getSystemPath(); if( m_version == XAudioVersion::XAudio_2_7 ) path += "XAudio2_7.dll"; else if( m_version == XAudioVersion::XAudio_2_6 ) path += "XAudio2_6.dll"; m_libXAudio = LoadLibrary( (wchar_t*)path.c_str() ); if( !m_libXAudio ){ gtLogWriter::printError( u"Can not load XAudio library" ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } u32 flags = 0u; HRESULT hr = 0; if( FAILED( hr = XAudio2Create( &m_XAudio2, flags, XAUDIO2_DEFAULT_PROCESSOR ) ) ){ gtLogWriter::printError( u"Failed to init XAudio2 engine: %i", hr ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } if( FAILED( hr = m_XAudio2->CreateMasteringVoice( &m_MasteringVoice, XAUDIO2_DEFAULT_CHANNELS) ) ){ gtLogWriter::printError( u"Failed creating mastering voice: %i", hr ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } XAUDIO2_DEVICE_DETAILS deviceDetails; if( FAILED( hr = m_XAudio2->GetDeviceDetails( 0, &deviceDetails ) ) ){ gtLogWriter::printError( u"Failed get device details: %i", hr ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } if( deviceDetails.OutputFormat.Format.nChannels > OUTPUTCHANNELS ){ gtLogWriter::printError( u"Failed create audio engine" ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } DWORD channelMask = deviceDetails.OutputFormat.dwChannelMask; u32 nuofchannels = deviceDetails.OutputFormat.Format.nChannels; if( FAILED( hr = XAudio2CreateReverb( &m_ReverbEffect, 0 ) ) ){ gtLogWriter::printError( u"Can't create AudioFX: %i", hr ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { m_ReverbEffect, TRUE, 1 } }; XAUDIO2_EFFECT_CHAIN effectChain = { 1, effects }; if( FAILED( hr = m_XAudio2->CreateSubmixVoice( &m_SubmixVoice, 1, deviceDetails.OutputFormat.Format.nSamplesPerSec, 0, 0, NULL, &effectChain ) ) ){ gtLogWriter::printError( u"Can't create Submix Voice: %i", hr ); MessageBox( 0, L"See log.txt for details", L"Error", MB_OK ); return false; } XAUDIO2FX_REVERB_PARAMETERS native; ReverbConvertI3DL2ToNative( &m_PRESET_PARAMS[1], &native ); m_SubmixVoice->SetEffectParameters( 0, &native, sizeof( native ) ); //X3DAudioInitialize( channelMask, X3DAUDIO_SPEED_OF_SOUND, X3DInstance ); return true; } gtAudioStream* gtAudioSystemXAudio2_7::createStream( const gtString& fileName ){ gtAudioStreamImpl * stream = new gtAudioStreamImpl(m_XAudio2); if( !stream ){ gtLogWriter::printError( u"Can not allocate memory for stream object" ); return nullptr; } if( !stream->open( fileName ) ){ gtLogWriter::printError( u"Can not open stream" ); stream->release(); return nullptr; } return stream; } gtAudioObject* gtAudioSystemXAudio2_7::createAudioObject( const gtString& fileName, u32 sp ){ gtAudioSource* source = loadAudioSource( fileName ); if( !source ) return nullptr; return createAudioObject( source, sp ); } gtAudioObject* gtAudioSystemXAudio2_7::createAudioObject( gtAudioSource* source, u32 sp ){ GT_ASSERT1( source, "Audio source not initialized", "source != nullptr" ); if( !source ) return nullptr; gtAudioObjectImpl * audioObject = new gtAudioObjectImpl( source ); if( !audioObject ){ gtLogWriter::printWarning( u"Can not allocate memory for audio object" ); return nullptr; } if( !audioObject->init( sp ) ){ gtLogWriter::printWarning( u"Can not initialize audio object" ); audioObject->release(); return nullptr; } return audioObject; } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::setTime( f64 t ){ m_time = t; } gtAudioSource* gtAudioSystemXAudio2_7::loadAudioSource( const gtString& fileName ){ gtString realPath = gtFileSystem::getRealPath( fileName ); if( !gtFileSystem::existFile( realPath ) ){ gtLogWriter::printWarning( u"File not exist: %s", realPath.data() ); return nullptr; } gtAudioSourceImpl* source = nullptr; gtString ext = util::stringGetExtension( realPath ); util::stringToLower( ext ); gtAudioSourceInfo info; if( ext == u"wav" ){ Wave wave( realPath ); if( wave.getInfo( info ) ) source = wave.read( info ); else{ gtLogWriter::printInfo( u"Can not get audio information" ); return nullptr; } if( !source ) return nullptr; }else if( ext == u"ogg" ){ Ogg ogg( realPath ); if( ogg.getInfo( info ) ) source = ogg.read( info ); else{ gtLogWriter::printInfo( u"Can not get audio information" ); return nullptr; } if( !source ) return nullptr; }else{ gtLogWriter::printInfo( u"Unknown sound file" ); return nullptr; } return source; } /// ========================================================= /// ========================================================= /// ========================================================= /// ========================================================= gtAudioSystemXAudio2_7::gtAudioObjectImpl::gtAudioObjectImpl( gtAudioSource * src ): m_source( src ), m_volume( 1.f ), m_sourceImpl( (gtAudioSourceImpl*)src ), m_currentSourceVoice( 0u ), m_numOfPlayedSounds( 0u ) { m_callback.p_num_of_played_sounds = &m_numOfPlayedSounds; } gtAudioSystemXAudio2_7::gtAudioObjectImpl::~gtAudioObjectImpl( void ){ for( u32 i = 0u; i < m_sourceVoice.size(); ++i ){ m_sourceVoice[ i ]->Stop(); m_sourceVoice[ i ]->FlushSourceBuffers(); m_sourceVoice[ i ]->DestroyVoice(); } if( m_source ){ m_source->release(); } } bool gtAudioSystemXAudio2_7::gtAudioObjectImpl::init( u32 sp ){ // HRESULT hr; auto * asys = gtAudioSystemXAudio2_7::getInstance(); XAUDIO2_SEND_DESCRIPTOR sendDescriptors[2]; sendDescriptors[0].Flags = XAUDIO2_SEND_USEFILTER; // LPF direct-path sendDescriptors[1].Flags = XAUDIO2_SEND_USEFILTER; // LPF reverb-path -- omit for better performance at the cost of less realistic occlusion sendDescriptors[0].pOutputVoice = asys->m_MasteringVoice; sendDescriptors[1].pOutputVoice = asys->m_SubmixVoice; const XAUDIO2_VOICE_SENDS sendList = { 2, sendDescriptors }; gtAudioSourceImpl* source = (gtAudioSourceImpl*)m_source; setTime( source->m_time ); WAVEFORMATEX wfex; ZeroMemory( &wfex, sizeof( wfex ) ); const gtAudioSourceInfo& info = source->getInfo(); wfex.cbSize = 0u;//source->getDataSize(); wfex.nAvgBytesPerSec = info.m_bytesPerSec; wfex.nBlockAlign = (WORD)info.m_blockAlign; wfex.nChannels = (WORD)info.m_channels; wfex.wBitsPerSample = (WORD)info.m_bitsPerSample; wfex.wFormatTag = (WORD)info.m_formatType; wfex.nSamplesPerSec = info.m_sampleRate; m_sourceMax = sp; IXAudio2SourceVoice* sv = nullptr; for( u32 i = 0u; i < m_sourceMax; ++i ){ if( FAILED( asys->m_XAudio2->CreateSourceVoice( &sv, &wfex, 0, XAUDIO2_DEFAULT_FREQ_RATIO, &m_callback, &sendList ) ) ){ gtLogWriter::printWarning( u"Can not create source voice" ); return false; } m_sourceVoice.push_back( sv ); } return true; } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::play( void ){ m_state = gtAudioState::play; if( m_numOfPlayedSounds < this->m_sourceMax ){ updateBuffer(); if( FAILED( m_sourceVoice[ m_currentSourceVoice ]->Start( 0u, XAUDIO2_COMMIT_ALL ) ) ){ gtLogWriter::printWarning( u"m_sourceVoice->Start failed" ); } ++m_currentSourceVoice; if( m_currentSourceVoice == this->m_sourceMax ) m_currentSourceVoice = 0u; ++m_numOfPlayedSounds; } } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::pause( void ){ if( m_state == gtAudioState::pause ){ gtLogWriter::printWarning( u"Can not set pause audio playback" ); return; } m_state = gtAudioState::pause; u32 sz = m_sourceVoice.size(); m_numOfPlayedSounds = 0u; for( u32 i = 0u; i < sz; ++i ) m_sourceVoice[ i ]->Stop(); } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::stop( void ){ if( m_state == gtAudioState::stop ){ gtLogWriter::printWarning( u"Can not stop audio playback" ); return; } m_state = gtAudioState::stop; u32 sz = this->m_sourceVoice.size(); m_currentSourceVoice = 0u; m_numOfPlayedSounds = 0u; for( u32 i = 0u; i < sz; ++i ){ m_sourceVoice[ i ]->Stop(); m_sourceVoice[ i ]->FlushSourceBuffers(); } } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::setVolume( f32 volume ){ m_volume = volume; u32 sz = m_sourceVoice.size(); for( u32 i = 0u; i < sz; ++i ) m_sourceVoice[ i ]->SetVolume( volume ); } f32 gtAudioSystemXAudio2_7::gtAudioObjectImpl::getVolume( void ){ return m_volume; } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::setLoop( bool loop ){ m_sourceImpl->getXAUDIO2_BUFFER().LoopCount = loop ? XAUDIO2_LOOP_INFINITE : 0; } ///??? void gtAudioSystemXAudio2_7::gtAudioObjectImpl::setAudioSource( gtAudioSource* /*source*/ ){ } gtAudioSource* gtAudioSystemXAudio2_7::gtAudioObjectImpl::getAudioSource( void ){ return m_source; } void gtAudioSystemXAudio2_7::gtAudioObjectImpl::updateBuffer( void ){ if( FAILED( m_sourceVoice[ m_currentSourceVoice ]->SubmitSourceBuffer( &m_sourceImpl->getXAUDIO2_BUFFER() ) ) ){ gtLogWriter::printWarning( u"SubmitSourceBuffer failed" ); } } /* ============================================= ============================================= ============================================= */ gtAudioSystemXAudio2_7::gtAudioStreamImpl::gtAudioStreamImpl( IXAudio2* d ): m_isOpen( false ), m_volume( 1.f ), m_sourceVoice( nullptr ), m_device( d ), m_format( AudioFileFormat::wav ) {} gtAudioSystemXAudio2_7::gtAudioStreamImpl::~gtAudioStreamImpl( void ){ close(); } bool gtAudioSystemXAudio2_7::gtAudioStreamImpl::close( void ){ m_wave.closeStream(); m_ogg.closeStream(); if( m_sourceVoice ) m_sourceVoice->DestroyVoice(); m_sourceVoice = nullptr; if( m_isOpen ){ m_isOpen = false; return true; } return false; } bool gtAudioSystemXAudio2_7::gtAudioStreamImpl::open( const gtString& fileName ){ if( !m_isOpen ){ gtString fullPath = fileName; if( !gtFileSystem::existFile( fileName ) ){ fullPath = gtFileSystem::getRealPath( fileName ); if( !gtFileSystem::existFile( fullPath ) ){ gtLogWriter::printWarning( u"Can not open file for streaming. %s", fullPath.data() ); return false; } } gtString ext = util::stringGetExtension( fullPath ); util::stringToLower( ext ); if( ext != u"wav" && ext != u"ogg" ){ gtLogWriter::printWarning( u"File format not supported. %s", fullPath.data() ); return false; } if( ext == u"ogg" ){ m_format = AudioFileFormat::ogg; m_ogg.m_fileName = fullPath; if( !m_ogg.getInfo( m_info )){ gtLogWriter::printWarning( u"Bad file. %s", fullPath.data() ); return false; } this->m_time = m_ogg.m_time; }else{ m_wave.m_fileName = fullPath; if( !m_wave.getInfo( m_info )){ gtLogWriter::printWarning( u"Bad file. %s", fullPath.data() ); return false; } //this->m_time = } WAVEFORMATEX wfex; ZeroMemory( &wfex, sizeof( wfex ) ); wfex.nAvgBytesPerSec = m_info.m_bytesPerSec; wfex.nBlockAlign = (WORD)m_info.m_blockAlign; wfex.nChannels = (WORD)m_info.m_channels; wfex.wBitsPerSample = (WORD)m_info.m_bitsPerSample; wfex.wFormatTag = (WORD)m_info.m_formatType; wfex.nSamplesPerSec = m_info.m_sampleRate; if( FAILED( m_device->CreateSourceVoice( &m_sourceVoice, &wfex, 0, 1.0f, &m_voiceContext ) ) ){ gtLogWriter::printWarning( u"Error creating source voice" ); return false; } } return true; } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::play( void ){ if( m_state != gtAudioState::play ){ m_ogg.m_playBackCommand = PlayBackCommand::PBC_NONE; m_wave.m_playBackCommand = PlayBackCommand::PBC_NONE; if( isOgg() ){ if( !m_ogg.prepareToStreaming( m_sourceVoice, &m_state)){ gtLogWriter::printWarning( u"Can not start playback [!prepareToStreaming]" ); return; }else{ gtLogWriter::printInfo( u"Starting playback %s", m_ogg.m_fileName.data() ); } }else{ if( !m_wave.prepareToStreaming( m_sourceVoice, &m_state)){ gtLogWriter::printWarning( u"Can not start playback [!prepareToStreaming]" ); return; }else{ gtLogWriter::printInfo( u"Starting playback %s", m_wave.m_fileName.data() ); } } }else{ gtLogWriter::printWarning( u"Can not start playback [m_state == play]" ); } } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::pause( void ){ if( m_state == gtAudioState::play ){ m_ogg.m_playBackCommand = PlayBackCommand::PBC_PAUSE; m_wave.m_playBackCommand = PlayBackCommand::PBC_PAUSE; }else gtLogWriter::printWarning( u"Can not pause playback [m_state != play]" ); } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::stop( void ){ if( m_state == gtAudioState::play ){ m_ogg.m_playBackCommand = PlayBackCommand::PBC_STOP; m_wave.m_playBackCommand = PlayBackCommand::PBC_STOP; }else gtLogWriter::printWarning( u"Can not stop playback [m_state != play]" ); } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::setVolume( f32 volume ){ m_volume = volume; m_sourceVoice->SetVolume( m_volume ); } f32 gtAudioSystemXAudio2_7::gtAudioStreamImpl::getVolume( void ){ return m_volume; } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::setLoop( bool loop ){ m_isLoop = loop; m_wave.m_isLoop = loop ? 1u : 0u; m_ogg.m_isLoop = loop ? 1u : 0u; } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::setPlaybackPosition( f32 position ){ f32 p = position; if( p < 0.00f ) p = 0.f; if( p > 1.00f ) p = 1.f; if( isOgg() ){ m_ogg.setPos( p ); }else{ m_wave.setPos( p ); } } f32 gtAudioSystemXAudio2_7::gtAudioStreamImpl::getPlaybackPosition( void ){ if( isOgg() ){ return m_ogg.getPos(); }else{ return m_wave.getPos(); } } void gtAudioSystemXAudio2_7::gtAudioStreamImpl::setAudioSource( gtAudioSource* /*source*/ ){} gtAudioSource* gtAudioSystemXAudio2_7::gtAudioStreamImpl::getAudioSource( void ){ return nullptr; }
1082dc054928dbe736f25e4960b829b493818633
d6e7b971f68184439f0ffff0a5dc72dadc6d71ce
/openmp/encrypt_aes_128_cbc.hpp
091b18940c91e7e01879b5c71367c8b79ffb13d1
[]
no_license
mg180/PP_CW1
0129defc86c3fb82061a19bae5b3e7f9391c632d
ef3a3f69ce2f154d6e1605f74a8ddb7d3eb9151a
refs/heads/master
2020-04-08T20:16:06.415561
2018-12-03T14:23:23
2018-12-03T14:23:23
159,691,491
0
0
null
null
null
null
UTF-8
C++
false
false
1,659
hpp
encrypt_aes_128_cbc.hpp
#include <iostream> #include <stdint.h> #include <cstring> #include <openssl/ssl.h> #include <openssl/err.h> #include <chrono> #include "utils.hpp" using namespace std; class encrypt_aes_128_cbc { private: unsigned char *plaintext; unsigned char *ciphertext; unsigned char *iv; unsigned char *key; uint16_t key_mask; // Limit the search to specific parts of the 128-bit key unsigned char ascii_start = 0; unsigned char ascii_end = 255; unsigned int distributed_batch_size = 1000000; // Used as a lookup during key generation as it is faster than continually calling the pow function const uint16_t byte_pow[16] = {0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100, 0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004, 0x0002, 0x0001,}; bool initialised = false; bool show_progress = true; bool validate_key(); uint64_t key_seq(unsigned char **keys, uint64_t length); bool next_key(); int encrypt_fast(unsigned char *key, unsigned char *input, unsigned int input_len, unsigned char *output); void handleOpenSSLErrors(void); void print_search_update(uint64_t current_iteration, uint64_t avg_ms); void print_configuration(); public: encrypt_aes_128_cbc(/* args */); ~encrypt_aes_128_cbc(); bool test_unprintable = false; // If disabled, only test printable ascii characters (A-Z, a-z, 0-9, symbols) void initialise( unsigned char *new_plaintext, unsigned char *new_ciphertext, unsigned char *new_iv, unsigned char *new_key ); int set_key_mask(uint16_t new_mask); int search_parallel(int num_mp_threads); };
b21779ee7afaf60a925111d250755b3591d3e769
d30a102c2bd54a2bdb9f6d7e51e53483d5b19bd6
/qt_fir/des_filter.cpp
915c8c12965fa0dfa1746813a6940b605b0f8397
[ "BSL-1.0" ]
permissive
kevinl8890/spuce
56f1454970a4e1877965bd965d1ceedde9f81e5c
1fb0d26e8a09f3b6a43fff9f279ca202f03b6294
refs/heads/master
2020-04-11T06:02:24.825693
2017-10-30T00:39:54
2017-10-30T00:39:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,005
cpp
des_filter.cpp
// Copyright (c) 2015 Tony Kirke. License MIT (http://www.opensource.org/licenses/mit-license.php) #include "des_filter.h" #include "make_filter.h" spuce::make_filter LPF; spuce::make_filter* pLPF = &LPF; void lpf_init(int pts) { pLPF->init(pts); } void reset() { pLPF->reset(); } void lpf_sel(const char* sel) { pLPF->sel_filter(sel); } void band_sel(const char* sel) { pLPF->sel_band(sel); } void set_center(int len) { pLPF->set_center_freq(len); } void set_filter_type(int t) { pLPF->set_filter_type(t); } int get_filter_type() { return pLPF->get_filter_type(); } double horiz_swipe(int len, bool in_passband) { return (pLPF->horiz_swipe(len, in_passband));} int get_order() { return (pLPF->get_order()); } bool is_bpf() { return (pLPF->is_bpf()); } void vertical_swipe(int len, bool in_passband, bool above_stop) { pLPF->vertical_swipe(len, in_passband, above_stop);} double update_w(double* w) { double x = pLPF->update(w); return (x); } double get_mag(double w) { return pLPF->get_mag(w);}
b13f9baedadf6fb35a1ca89cff3a61a2aca0ece8
19fd39d32e135b94b36807f8159905aa46d3752a
/src/fpga/processing/data_parallelism/sw/block_rw.cpp
df31bc25dfc693cef662ac2e625a1d8180c6ed74
[]
no_license
kayhand/sdb_fpga
48b684364c3e78550a4cc9108d633081a6a93f8b
f4492f10f8c1e05dfe9d3fcb392bd70eb4bfd5a3
refs/heads/master
2020-04-17T05:52:48.870576
2019-07-09T22:27:45
2019-07-09T22:27:45
166,301,880
0
0
null
null
null
null
UTF-8
C++
false
false
4,600
cpp
block_rw.cpp
#include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #include <iostream> #include <string> #include "afu_json_info.h" #include "block_rw.h" BLOCK_RW::BLOCK_RW(){ fpga_wrapper = NULL; csrs = NULL; column_part_pa = 0; read_buff_pa = 0; write_buff_pa = 0; } BLOCK_RW::~BLOCK_RW(){ delete csrs; delete fpga_wrapper; } void BLOCK_RW::connectToAccelerator(){ fpga_wrapper = new OPAE_SVC_WRAPPER(AFU_ACCEL_UUID); } void BLOCK_RW::connectToCSRManager(){ csrs = new CSR_MGR(*fpga_wrapper); } bool BLOCK_RW::registerReadBuffer(void*& buff, size_t nBytes){ printf("Sharing a buffer that was already created by SiliconDB!\n"); bool isOK = fpga_wrapper->prepMPFBuffer(nBytes, buff, &column_part_pa); if(isOK){ printf("First partition succesfully registered and ready to share with FPGA!\n"); for(int i = 0; i < 10; i++){ printf("buff''[%d]: %lu\n", i, ((volatile uint64_t*) buff)[i]); } printf("---------------------------\n"); for(int i = 10; i < 20; i++){ printf("buff''[%d]: %lu\n", i, ((volatile uint64_t*) buff)[i]); } printf("---------------------------\n"); for(int i = 20; i < 30; i++){ printf("buff''[%d]: %lu\n", i, ((volatile uint64_t*) buff)[i]); } return true; } else{ return false; } } bool BLOCK_RW::prepareReadBuffer(volatile void*& buff, void*& block, size_t nBytes){ buff = fpga_wrapper->allocBuffer(nBytes, &read_buff_pa); memcpy((void *) buff, (const void*) block, nBytes); if(read_buff_pa == 0){ printf("Problem with creating the buffer!\n"); return false; } else{ //printf("Column partition copied into the new buffer succesfully!\n"); /*printf("First 5 words contain the values...\n"); for(int i = 0; i < 5; i++){ printf("[%i]: %lu into %lu \n", i, ((uint64_t*) block)[i], ((volatile uint64_t*) buff)[i]); }*/ return true; } } void BLOCK_RW::prepareWriteBuffer(volatile void*& buff, size_t nBytes){ buff = fpga_wrapper->allocBuffer(nBytes, &write_buff_pa); } void BLOCK_RW::sendQueryParams(int total_cls, uint32_t pred, int bit_encoding){ printf("\n+++++++++++++++++++++++++++++++++++++++\n"); printf("State of the CSRs before query start: \n"); for(int csr_id = 0; csr_id < 8; csr_id++){ std::cout << "CSR[" << csr_id << "]: " << csrs->readCSR(csr_id) << std::endl; } printf("\n+++++++++++++++++++++++++++++++++++++++\n"); csrs->writeCSR(0, total_cls); csrs->writeCSR(1, pred); csrs->writeCSR(2, bit_encoding); } void BLOCK_RW::sendQueryParams(int total_cls, uint32_t pred){ csrs->writeCSR(0, total_cls); csrs->writeCSR(1, pred); } void BLOCK_RW::sendQueryParams(int total_cls){ csrs->writeCSR(0, total_cls); } void BLOCK_RW::registerBitMapIntoFPGA(void*& bit_map, int len){ shareBuffVA(4, intptr_t(bit_map)); int total_cls = len / 512; //d_year: 2556 / 512 total_cls = total_cls + (total_cls % 512 == 0); while((csrs->readCSR(0) < total_cls)){ } printf("All bitmap cls read by FPGA!\n"); } void BLOCK_RW::shareBuffVA(int csr_id, intptr_t buff_va){ csrs->writeCSR(csr_id, buff_va); } void BLOCK_RW::waitForProcessing(int total_cls, volatile void*& buff){ int cur_cl; int last_cl = -1; /*while((cur_cl = csrs->readCSR(0)) < total_cls){ if(cur_cl != last_cl){ printf("Last cl processed: %d\n", cur_cl); last_cl = cur_cl; if(csrs->readCSR(1)){ printf("Partition processed!\n"); break; } } }*/ while(!csrs->readCSR(1)){ } printf("Partition processed!\n"); /*while(!csrs->readCSR(2)){ } printf("Last write also done!\n");*/ } void BLOCK_RW::waitAndWriteResponse(int total_cls){ // Spin, waiting for the value in memory to change to something non-zero. struct timespec pause; // Longer when simulating pause.tv_sec = (fpga_wrapper->hwIsSimulated() ? 2 : 2); pause.tv_nsec = 2500000; int prev_cl = 0; int cur_cl = 0; while (csrs->readCSR(0) == 0) // check if partition is processed { if((cur_cl = csrs->readCSR(2)) != prev_cl){ cur_cl = csrs->readCSR(2); printf("Bit vector for CL #%d: \n", cur_cl); this->addBitResult(csrs->readCSR(3)); this->addBitResult(csrs->readCSR(4)); //this->printBitResult(csrs->readCSR(3)); //printf("\n"); prev_cl = cur_cl; } } printf("Produced %d bit results in total!\n", this->totalResults()); } void BLOCK_RW::notifyFPGA(int code){ csrs->writeCSR(6, code); // Spin, waiting for the value in memory to change to something non-zero. struct timespec pause; // Longer when simulating pause.tv_sec = 2; pause.tv_nsec = 2500000; nanosleep(&pause, NULL); }
55e734665e5a49498a29165779ce7e61fbef7840
735fc9e269eac9410bdabf1f599f954f8649cd0a
/emt/include/emt/emt_include_libevent.hpp
e619833bc61752413c9df07b099970d319aa5283
[]
no_license
dungeonsnd/lite-libs
a9df4b62c007a9800a9867b915f69883fa777b48
38f84bd1cf6f1a43836f43e57fcd1d22b18d706b
refs/heads/master
2020-04-26T11:19:38.381082
2015-11-28T03:21:16
2015-11-28T03:21:16
26,734,045
0
0
null
null
null
null
UTF-8
C++
false
false
285
hpp
emt_include_libevent.hpp
#ifndef _HEADER_FILE_EMT_INCLUDE_LIBEVENT_HPP_ #define _HEADER_FILE_EMT_INCLUDE_LIBEVENT_HPP_ #include <event2/util.h> #include <event2/event.h> #include <event2/buffer.h> #include <event2/listener.h> #include <event2/bufferevent.h> #endif // _HEADER_FILE_EMT_INCLUDE_LIBEVENT_HPP_
278645c805cb59a8a6e45723ff8fb4e4b48bd638
18cb29866271d81a2ba0f9765494ab09fa0a3daa
/Global.cpp
1df2757680b60441f0e23cd477da5128598a4f03
[]
no_license
n-agi/JihoonFlight
597784f8c7d690eb8424b28b721fc16d3769a31d
b412e8adfc162ec21de5a96930adb9f6dd707684
refs/heads/master
2021-01-13T11:18:33.363801
2017-02-09T06:21:16
2017-02-09T06:21:16
81,416,521
0
0
null
null
null
null
UTF-8
C++
false
false
1,113
cpp
Global.cpp
#include "Global.h" LPDIRECT3D9 g_pD3D; LPDIRECT3DDEVICE9 g_pd3dDevice; LPD3DXSPRITE g_pSprite; CBulletManager *BulletManager; CSceneManager *scm; map<char*,LPDIRECT3DTEXTURE9> TextureMap; CPlayer *Player; bool colCheck ( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2 ) { RECT r1,r2; RECT tmpRet; r1.left=x1; r1.right=x1+w1; r1.top=y1; r1.bottom=y1+h1; r2.left=x2; r2.right=x2+w2; r2.top=y2; r2.bottom=y2+h2; return bool(IntersectRect(&tmpRet,&r1,&r2)); } LPDIRECT3DTEXTURE9 getTexture(char *path) { if(TextureMap[path] != NULL) return TextureMap[path]; // return texture that has same path D3DXCreateTextureFromFileExA( g_pd3dDevice, path, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, NULL, NULL, NULL, &TextureMap[path] ); return TextureMap[path]; } void clearTexture() { for(auto iter=TextureMap.begin(); iter!=TextureMap.end(); iter++) { iter->second->Release(); // texture unload } TextureMap.clear(); }
4ea275c2ed0ea0dff2bf2c3833f7156ed12ae858
c7177099d63f6de64b1ede0c642887b5565838d9
/include/awkward/builder/GrowableBuffer.h
96a8abd7825266572b345ed085c06c839fe3463a
[ "BSD-3-Clause" ]
permissive
piyush-palta/awkward-1.0
c285c701bb5283348004b10be76c784d524cee5c
a4dad4996c03162db1d83f17c1c2d4adb59a1941
refs/heads/master
2021-04-20T22:27:13.832117
2020-03-21T00:46:03
2020-03-21T00:46:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,506
h
GrowableBuffer.h
// BSD 3-Clause License; see https://github.com/jpivarski/awkward-1.0/blob/master/LICENSE #ifndef AWKWARD_GROWABLEBUFFER_H_ #define AWKWARD_GROWABLEBUFFER_H_ #include <cmath> #include <cstring> #include "awkward/cpu-kernels/util.h" #include "awkward/builder/ArrayBuilderOptions.h" #include "awkward/Index.h" namespace awkward { template <typename T> class EXPORT_SYMBOL GrowableBuffer { public: static GrowableBuffer<T> empty(const ArrayBuilderOptions& options); static GrowableBuffer<T> empty(const ArrayBuilderOptions& options, int64_t minreserve); static GrowableBuffer<T> full(const ArrayBuilderOptions& options, T value, int64_t length); static GrowableBuffer<T> arange(const ArrayBuilderOptions& options, int64_t length); GrowableBuffer(const ArrayBuilderOptions& options, std::shared_ptr<T> ptr, int64_t length, int64_t reserved); GrowableBuffer(const ArrayBuilderOptions& options); const std::shared_ptr<T> ptr() const; int64_t length() const; void set_length(int64_t newlength); int64_t reserved() const; void set_reserved(int64_t minreserved); void clear(); void append(T datum); T getitem_at_nowrap(int64_t at) const; private: const ArrayBuilderOptions options_; std::shared_ptr<T> ptr_; int64_t length_; int64_t reserved_; }; } #endif // AWKWARD_GROWABLEBUFFER_H_
c4c41d8640ae7262a875b606fd7266d9f8bcc40f
3974cc24a2de64cd42f3be5f0ed68cebc1dad6b2
/DesignPatternExamples/DesignPatternExamples/main.cpp
617fc0a1a6132485488be41b6a9a94350557abe8
[]
no_license
mcwiet/design_pattern_examples
572a2e514390ec9ae3dc395c00e760f7a52258eb
609e7c874ad2aba6dd4ef9e643c93e627ebe2af2
refs/heads/master
2020-07-02T02:10:59.792159
2020-06-29T17:10:02
2020-06-29T17:10:02
201,382,111
0
0
null
null
null
null
UTF-8
C++
false
false
981
cpp
main.cpp
#include "adapter.cpp" #include "bridge.cpp" #include "command_with_undo.cpp" #include "command_without_undo.cpp" #include "composite.cpp" #include "crtp.cpp" #include "decorator.cpp" #include "facade.cpp" #include "factory.cpp" #include "factory_abstract.cpp" #include "iterator.cpp" #include "mixin.cpp" #include "null_object.cpp" #include "observer_multi_thread.cpp" #include "observer_single_thread.cpp" #include "proxy.cpp" #include "singleton.cpp" #include "state.cpp" #include "strategy.cpp" #include "template.cpp" int main() { //Adapter::Run(); //Bridge::Run(); //CommandWithUndo::Run(); //CommandWithoutUndo::Run(); //Composite::Run(); //CRTP::Run(); //Decorator::Run(); //Facade::Run(); //Factory::Run(); //FactoryAbstract::Run(); //Iterator::Run(); Mixin::Run(); //NullObject::Run(); //ObserverMultiThread::Run(); //ObserverSingleThread::Run(); //Template::Run(); //Singleton::Run(); //State::Run(); //Strategy::Run(); //Proxy::Run(); return 0; }
855b772dc01ae49458304f98f2bf8a553c442ed2
1a04dcb27a37f16fdf5200bff5dd1261e1587e19
/Arduino Code/IRTransmitter/IRTransmitter.ino
fca19eb5ae6841b51cc58dc2b72db85ac70150ea
[]
no_license
Dibz15/fancy-robot
130da1eadcf5789fabb594af3d0c51b1b5373623
87a67f05d5956ce7135707f283ddcd99ea2d7b48
refs/heads/master
2021-09-09T01:59:02.094711
2018-03-13T08:36:55
2018-03-13T08:36:55
113,124,340
0
0
null
2017-12-31T04:05:25
2017-12-05T02:59:22
Python
UTF-8
C++
false
false
585
ino
IRTransmitter.ino
//This code would generate a modulated 38kHz IR signal int count; void setup() { // put your setup code here, to run once: //pinMode(4, OUTPUT); //pin 4 is connected to base of the transistor DDRD = 0b00010000; } void loop() { for(int i=0; i < 2000; i++){ //Turn On and OFF for 0.3 seconds digitalWrite(4, HIGH); //PORTD = 0b00011000; delayMicroseconds(11.5); digitalWrite(4, LOW); //PORTD = 0x0; delayMicroseconds(11.5); } digitalWrite(4,LOW); delay(50); //turn off for 0.3 seconds }
e4c9b86bbd15a74497e1e949ce07a39b179e92d7
33aff6f40a02aaeebd0e3bf8a37cff87ba211da0
/include/face_detection_tracker.h
b8e7cd62bbe84a946d7f36a3cf82308d366dcb72
[]
no_license
maetulj/face_detection_tracker
168fb5f1353a3d2724ecda448e8e506ae68d5f6a
39bf7e87fddc19af992117502969d9b9aeafc41d
refs/heads/master
2020-06-17T08:12:20.280274
2016-12-01T02:50:20
2016-12-01T02:50:20
75,015,130
1
1
null
2016-11-30T01:08:15
2016-11-28T21:18:23
C++
UTF-8
C++
false
false
5,807
h
face_detection_tracker.h
/** * FILENAME: face_detection_tracker.h * * DESCRIPTION: * * This file includes the definition of the FaceDetectionTracker class. * This class firstly converts the sensor_msgs::Image to cv::Mat, then * it detects the faces in the given image and tracks the faces. * * * AUTHOR: maetulj * * START DATE: 28.11.2016 * */ #ifndef FACE_DETECTION_TRACKER_H #define FACE_DETECTION_TRACKER_H //C++ related includes. #include <cstdio> #include <cmath> #include <sys/stat.h> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <map> // ROS related includes. #include <ros/ros.h> #include <sensor_msgs/Image.h> #include <sensor_msgs/image_encodings.h> #include <std_msgs/String.h> #include <image_transport/image_transport.h> // OpenCV related includes. #include <cv_bridge/cv_bridge.h> #include <opencv2/contrib/contrib.hpp> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/objdetect/objdetect.hpp> // Third party includes for tracking. #include "../cf_libs/kcf/kcf_tracker.hpp" #include <perception_msgs/Rect.h> // Self defined includes. #include <perception_msgs/Rect.h> #include <faces_storage.hpp> // Debug defines. // Include this if you want to have visual output. #define DEBUG using namespace cv; /** * @brief Class for face detection and tracking. */ class FaceDetectionTracker { public: /** * @brief Constructor for the class. */ FaceDetectionTracker(); /** * @brief Destructor. */ ~FaceDetectionTracker(); /** * @brief Function for detecting and displaying the faces. * * @param[in] frame The frame */ void detectAndDisplay(cv::Mat frame); /** * @brief Track the object. */ void track(); void readCSV(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';'); void readCSVLegend(const string& filename, char separator = ';'); /** * @brief Train the face detector. */ void trainDetector(); /** * @brief Recognize the faces on the video. */ void recognizeFace(); private: // Global variables. static bool m_newImage_static; static bool m_newBB_static; // The ros node handle. ros::NodeHandle m_node; std::string m_windowName{"Face detection"}; std::string m_directory{"/home/maetulj/tiago_ws/src/face_detection_tracker/"}; // Buffer for publishers, subscibers. int m_queuesize = 2; //////////////////////////// /// Face detection part. /// //////////////////////////// // Helper member variables for image transformation. image_transport::ImageTransport m_it; image_transport::Subscriber m_imageSub; image_transport::Publisher m_imagePub; // Publisher. ros::Publisher m_perceptPub; // POinter to the cv image. cv_bridge::CvImagePtr m_cvPtr; // Name the haarcascades for frontal and profile face detection. std::string m_frontalFaceCascadeName{"haarcascade_frontalface_alt.xml"}; std::string m_profilefaceCascadeName{"haarcascade_profileface.xml"}; // Cascade classifiers. cv::CascadeClassifier m_frontalfaceCascade; cv::CascadeClassifier m_profilefaceCascade; // Variable to hold the detection rectangle. perception_msgs::Rect m_msgRect; /** * @brief Callback for the sensor_msgs::Image. * * @param[in] msg The image in a form of a sensor_msgs::Image. */ void imageCallback(const sensor_msgs::ImageConstPtr &msg); // Detected faces. std::vector<Rect> m_faces; // TO BE IMPLEMENTED! // Save detected faces in a storage class. // std::vector<FacesStorage> m_storeFaces; // Point in the upper left corner. cv::Point m_p1; // Point in the lower right corner. cv::Point m_p2; // Height and width of the bounding box. int m_width; int m_height; ////////////////////// /// Tracking part. /// ////////////////////// // Cv Bridge variables for transforming sensor_msgs::Image into cv::Mat cv_bridge::CvImagePtr m_inImg; perception_msgs::Rect m_inBb; perception_msgs::Rect m_outBb; // local variables cv::Mat img; cv::Rect bb; // Detected face number to track. int i = 0; // Declare and initialize subscribers, rgb image and the 2D region to track. ros::Subscriber rgbimgSub; // Face detection subscriber. ros::Subscriber bbSub; //Declare and initialize publishers, 2D region tracked region. ros::Publisher bbPub; // Tracker parameters. cf_tracking::KcfParameters m_paras; std::vector<cf_tracking::KcfTracker*> vKCF; // Declare tracker. cf_tracking::KcfTracker *cKCF; // The tracker is running. bool tracking = false; // If the tracker is on frame. bool targetOnFrame = false; /** * @brief Callback function for gettint sensor image. * * @param[in] _img The image */ void callbackimage(const sensor_msgs::ImageConstPtr &_img); /** * @brief Callback for perception rectangle. * * @param[in] _bb Bounding box. */ void callbackbb(const perception_msgs::RectConstPtr &_bb); ///////////////////////// /// Recognizing part. /// ///////////////////////// // These vectors hold the images and corresponding labels: vector<Mat> m_images; vector<int> m_labels; // Hold the legend for labels. std::map<int, std::string> m_labelLegend; int m_imWidth; int m_imHeight; Ptr<FaceRecognizer> m_model; // The tracked person label. int m_trackedPersonId; int m_trackedPerson; }; #endif // FACE_DETECTION_TRACKER_H
90891212496748187dc9c9f1ac34f285baa065fe
45a28e75a81d37676bee100c15ac57166a268156
/proj/Textino/源码/OOP-Proj-TextEditor/PlainTextEdit.cpp
2308c0ea9814b229c51029e518675f714cfb2e95
[]
no_license
VickeyZ/OOP
41394dce2fbd0a315e5f97f2e7bdd755494745ba
0d96636a2cfacc15b8d1ab503cc479a15f277d5a
refs/heads/main
2023-03-16T17:35:42.451620
2021-03-11T04:33:59
2021-03-11T04:33:59
346,578,085
0
0
null
null
null
null
UTF-8
C++
false
false
414
cpp
PlainTextEdit.cpp
#include"PlainTextEdit.h" #include<QKeyEvent> // QPlainTextEdit 重载 PlainTextEdit::PlainTextEdit(QWidget* parent):QPlainTextEdit(parent) { setFocusPolicy(Qt::StrongFocus); } void PlainTextEdit::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Tab){ this->insertPlainText(" "); } else { QPlainTextEdit::keyPressEvent(event); } }
a6c368240be603c93bc422f56f4cfb2fb5de2394
60a15a584b00895e47628c5a485bd1f14cfeebbe
/controls/BCGControlBar/BCGMainClientAreaWnd.h
edd7b2578e2ccdba6ae13b74d20d06225b4a3758
[]
no_license
fcccode/vt5
ce4c1d8fe819715f2580586c8113cfedf2ab44ac
c88049949ebb999304f0fc7648f3d03f6501c65b
refs/heads/master
2020-09-27T22:56:55.348501
2019-06-17T20:39:46
2019-06-17T20:39:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,166
h
BCGMainClientAreaWnd.h
//******************************************************************************* // COPYRIGHT NOTES // --------------- // This source code is a part of BCGControlBar library. // You may use, compile or redistribute it as part of your application // for free. You cannot redistribute it as a part of a software development // library without the agreement of the author. If the sources are // distributed along with the application, you should leave the original // copyright notes in the source code without any changes. // This code can be used WITHOUT ANY WARRANTIES on your own risk. // // For the latest updates to this library, check my site: // http://welcome.to/bcgsoft // // Stas Levin <bcgsoft@yahoo.com> //******************************************************************************* #if !defined(AFX_BCGMAINCLIENTAREAWND_H__08B9EC05_DCE3_11D1_A64F_00A0C93A70EC__INCLUDED_) #define AFX_BCGMAINCLIENTAREAWND_H__08B9EC05_DCE3_11D1_A64F_00A0C93A70EC__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // BCGMainClientAreaWnd.h : header file // class CBCGMDIFrameWnd; ///////////////////////////////////////////////////////////////////////////// // CBCGMainClientAreaWnd window //!!! andy modification - 2.06.99 #include "bcgcontrolbar.h" class BCGCONTROLBARDLLEXPORT CBCGMainClientAreaWnd : public CWnd ///end modification { // Construction public: CBCGMainClientAreaWnd(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CBCGMainClientAreaWnd) //}}AFX_VIRTUAL // Implementation public: virtual ~CBCGMainClientAreaWnd(); // Generated message map functions protected: //{{AFX_MSG(CBCGMainClientAreaWnd) afx_msg BOOL OnEraseBkgnd(CDC* pDC); //}}AFX_MSG afx_msg LRESULT OnSetMenu (WPARAM wp, LPARAM); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #endif // !defined(AFX_BCGMAINCLIENTAREAWND_H__08B9EC05_DCE3_11D1_A64F_00A0C93A70EC__INCLUDED_)
6d67b5e06e415084ddeae2cf4595bb71a1966d3e
87e76cd4ee1ccf29ae3b0e37500cdd4664103e27
/InfaArrayWrite.cpp
4eac98db416afa336045b897fa5d60ab8ed0120d
[]
no_license
Admiree/PROC
cd856f78434a16ae67e48752e75802b63df06efa
056609832ca08ddc8f9d8f5db9c9a221fbd32a7e
refs/heads/master
2020-12-30T15:41:34.545525
2017-05-25T08:39:15
2017-05-25T08:39:15
91,162,251
0
1
null
null
null
null
WINDOWS-1251
C++
false
false
1,327
cpp
InfaArrayWrite.cpp
#include "stdafx.h" #include <fstream> #include "array.h" #include "def.h" using namespace std; namespace arrays { int CalculationSum(array &array); int CalculationSum(masOne &masOne); int CalculationSum(masDouble &masDouble); int CalculationSum(masTriangle &masTriangle); void OutMasDouble(masDouble &masDouble, ofstream &ofst); void OutMasOne(masOne &masOne, ofstream &ofst); void OutMasTriangle(masTriangle &masTriangle, ofstream &ofst); void InfaArrayWrite(array &outarray, ofstream &ofst) { switch (outarray.key) { case array::key::Mas_one: { OutMasOne(outarray.masOne, ofst); CheckOutputFile(ofst); ofst << "Сумма элементов = " << CalculationSum(outarray.masOne) << endl; break; } case array::key::Mas_double: { OutMasDouble(outarray.masDouble, ofst); ofst << "Сумма элементов = " << CalculationSum(outarray.masDouble) << endl; break; } case array::key::Mas_triangle: { OutMasTriangle(outarray.masTriangle, ofst); ofst << "Сумма элементов = " << CalculationSum(outarray.masTriangle) << endl; break; } default: ofst << "Incorrect array!" << endl; } string pro[3] = { "Построчно", "По столбцам", "Одномерный массив" }; ofst << pro[outarray.p].c_str()<<"\n"; } }
8a1571ee51553374cbe8ded9c9b376e41f039f57
b0d48471d4ee6774d07e1e163a85e68c1d80cd17
/include/datahandler.h
2f614453990368b07ed2530510e8e6dc057bb827
[]
no_license
ThomasMKarl/QtKanji
7c83da34bb5328cab38da076daf658dd977d4950
609539df92e6b2aa9206d61e78fc50fa7cc062dd
refs/heads/main
2023-08-31T09:33:36.627003
2021-11-03T01:34:21
2021-11-03T01:34:21
332,829,875
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
h
datahandler.h
#ifndef DATAHANDLER_H #define DATAHANDLER_H #include "helper.h" namespace QtKanji { struct Boxes { Boxes() = default; bool hideImi{false}; bool hideKun{false}; bool hideOn{false}; SharedCheckbox imiBox{}, kunBox{}, onBox{}; }; class DataHandler { public: DataHandler() = default; explicit DataHandler(unsigned int lowerLimit_, unsigned int upperLimit_, unsigned int lowerLection_, unsigned int upperLection_, bool fromFuriToKanji_, bool fromJapToEng_) : lowerLimit(lowerLimit_), upperLimit(upperLimit_), lowerLection(lowerLection_), upperLection(upperLection_), fromFuriToKanji(fromFuriToKanji_), fromJapToEng(fromJapToEng_) { } unsigned int lowerLimit{1}; unsigned int upperLimit{NUMBER_OF_KANJI}; unsigned int lowerLection{1}; unsigned int upperLection{25}; bool fromFuriToKanji{true}; bool fromJapToEng{true}; std::string pathToKanjiCardboxData{"kanjiCardbox.dat"}; std::string pathToExampleCardboxData{"exampleCardbox.dat"}; std::string pathToWordCardboxData{"wordCardbox.dat"}; Uints indexInKanjiCardbox{}; Uints indexInExampleCardbox{}; Uints indexInWordCardbox{}; Examples examples{}; Examples words{}; Flashcard flashcard{}; bool getFromFuriToKanji() const { return fromFuriToKanji; } bool getFromJapToEng() const { return fromJapToEng; } Error computeExampleData(bool randomize); Error computeWordData(bool randomize); Error computeKanjiData(unsigned int Id); Error computeKanjiCardboxData(); void setKanjiData(unsigned int ID); unsigned int computeRandomId(bool fromCardbox, unsigned int removeFlag); unsigned int searchKanjiId(QString kanji); Error printExamples(); private: Uints indexKanjiContainer{}; Uints indexExampleContainer{}; Uints indexWordContainer{}; }; }; // namespace QtKanji #endif
38f8fb91ca7a4e4a79a5234d040a13befbfdf1e7
0c268ff10b68c4a24023ca646bb46c5a125eb84c
/HDU_MultiSchool/day4/g.cpp
2785bc4e1686a48eb1d02b570fb253bd1404c0af
[]
no_license
TzeHimSung/AcmDailyTraining
497b9fb77c282f2f240634050e38f395cf1bedbc
2a69fa38118e43cbeca44cb99369e6e094663ec8
refs/heads/master
2023-03-21T21:39:02.752317
2021-03-14T03:41:00
2021-03-14T03:41:00
159,670,822
0
0
null
null
null
null
UTF-8
C++
false
false
815
cpp
g.cpp
/* basic header */ #include <bits/stdc++.h> /* define */ #define ll long long #define dou double #define pb emplace_back #define mp make_pair #define sot(a,b) sort(a+1,a+1+b) #define rep1(i,a,b) for(int i=a;i<=b;++i) #define rep0(i,a,b) for(int i=a;i<b;++i) #define eps 1e-8 #define int_inf 0x3f3f3f3f #define ll_inf 0x7f7f7f7f7f7f7f7f #define lson (curpos<<1) #define rson (curpos<<1|1) /* namespace */ using namespace std; /* header end */ const int maxn = 20; int main() { int t; scanf("%d", &t); while (t--) { int ans = 0, a[maxn]; rep0(i, 0, 16) { scanf("%d", &a[i]); if (!a[i]) ans += i / 4 + 1 + i % 4 + 1, a[i] = 16; rep1(j, 0, i) if (a[j] > a[i]) ans++; } if (ans & 1) puts("No"); else puts("Yes"); } return 0; }
689a39ba7c53af9f691fb40d837f59a36bdb4725
6dd898a5205fcf09ca4a8e42ec7a93faaca873ac
/factirial.cpp
b28e12522b40c85c3ffcabe90bfbeb71ebdf12e0
[]
no_license
gauravdubey101/Ds_algo_question_for_placement
eb43f0aa7850a21e1bde1ecdfd9c3faa9b657e32
05c962c040635e6a181aeb2a0812a78144f80959
refs/heads/main
2023-03-05T23:10:06.247257
2021-02-15T18:04:10
2021-02-15T18:04:10
308,065,856
0
0
null
null
null
null
UTF-8
C++
false
false
572
cpp
factirial.cpp
#include<bits/stdc++.h> using namespace std; //learning function //to check prime bool isPrime(int n){ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } int main(){ // int n1,n2; // cin>>n1>>n2; // int fact =1; // // for(int i=1;i<=n1;i++){ // fact = fact*i; // // } // cout <<fact<<endl; // int factd=1; // for(int i=1;i<=n2;i++){ // factd = factd*i; // } // cout<<factd; //prime numbers int a,b; cin>>a>>b; for(int i=a;i<=b;i++){ if(isPrime(i)){ cout<<i<<"prime"<<endl; }else{ cout<<i<<"notPrime"<<endl; } } }
39fd6c2f975b1e6f7a9778a856fdbff5580aec8e
e8d82adb77b43b883bc938c25d1981a118774c23
/Minion.h
59e92b0c3488864d194184078054251d124edaab
[]
no_license
warmshowers1/galaga_remake
9f7214782647d73bcda5f508fb22c649dc8e570f
a74214c9eaec083e35726d910afa144440074eec
refs/heads/main
2023-01-23T16:24:42.320966
2020-12-10T07:10:23
2020-12-10T07:10:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
335
h
Minion.h
#ifndef Minion_h #define Minion_h #include "Alien.h" #if defined WIN32 #include <freeglut.h> #include "../windows/SOIL.h" #elif defined __APPLE__ #include <GLUT/glut.h> #include "SOIL.h" #else #include <GL/freeglut.h> #include "SOIL.h" #endif class Minion: public Alien{ public: Minion(float, float, float, float); }; #endif
5655db85ab7e667dd328e462271788a680f897f5
1fc1c628992be7cc95bc49b428594caf57e0b049
/cpp files/Tree/Binary Search/two sums best.cpp
5d22ab73c7cd5c62dd1ab61bf1906c9246fa6966
[]
no_license
av1shek/DSA-NITW
8150b5646956177fa965a18b2c474db863687705
fe8219c145fccfaedf0a59867c7d4cc7fb70bdf1
refs/heads/master
2023-05-13T21:43:16.393840
2021-06-03T09:02:17
2021-06-03T09:02:17
373,443,487
0
0
null
null
null
null
UTF-8
C++
false
false
3,304
cpp
two sums best.cpp
#include<bits/stdc++.h> using namespace std; typedef struct bstnode *bstptr; void takeInput(bstptr &); /// takes input till -1 void insert(bstptr &, int); /// insert a integer value void insertNode(bstptr &, bstptr); /// insert a node to with some data value void printInorder(bstptr); /// print left, self , right bstptr findbstNode(bstptr, int); /// return a node whose data value is same as value passed else null struct bstnode { struct bstnode *lchild; int data; struct bstnode *rchild; bstnode() { lchild = NULL; rchild = NULL; } bstnode(int k) { lchild = NULL; data = k; rchild = NULL; } }; void insert(bstptr &T, int k) { if(T==NULL) T = new bstnode(k); else if(k > T->data) insert(T->rchild, k); else if(k < T->data) insert(T->lchild, k); return; } void printInorder(bstptr T) { if(T == NULL) return; printInorder(T->lchild); cout<<T->data<<" "; printInorder(T->rchild); return; } void takeInput(bstptr &T) { while(true) { int temp; cin>>temp; if(temp == -1) break; insert(T, temp); } } bstptr findbstNode(bstptr T, int k) { if(T==NULL || T->data==k) return T; if(k > T->data) return findbstNode(T->rchild, k); if(k < T->data) return findbstNode(T->lchild, k); return NULL; } bool findtwosums(bstptr T, int k, int val) { stack<bstptr> stk1, stk2; bstptr cur1 = T; bstptr cur2 = T; int lo = 0, hi = 0; while(cur1) stk1.push(cur1), lo = cur1->data, cur1 = cur1->lchild; while( (lo < val) && cur1 ) { while(cur1) stk1.push(cur1), lo = cur1->data, cur1 = cur1->lchild; lo = stk1.top()->data, cur1 = stk1.top()->rchild, stk1.pop(); } cout<<"check -------------- val = "<<val<<" lo = "<<lo<<endl; while(cur2) stk2.push(cur2), hi = cur2->data, cur2 = cur2->rchild; while (lo < hi) { int sum = lo + hi; if (sum < k) { while(cur1) stk1.push(cur1), lo = cur1->data, cur1 = cur1->lchild; lo = stk1.top()->data, cur1 = stk1.top()->rchild, stk1.pop(); } else if (sum > k) { while(cur2) stk2.push(cur2), hi = cur2->data, cur2 = cur2->rchild; hi = stk2.top()->data, cur2= stk2.top()->lchild, stk2.pop(); } else { cout<<val<<" "<<lo<<" "<<hi<<endl; while(cur1) stk1.push(cur1), lo = cur1->data, cur1 = cur1->lchild; lo = stk1.top()->data, cur1 = stk1.top()->rchild, stk1.pop(); while(cur2) stk2.push(cur2), hi = cur2->data, cur2 = cur2->rchild; hi = stk2.top()->data, cur2= stk2.top()->lchild, stk2.pop(); } } return false; } void findthreesums(bstptr T, bstptr head, int k) { if(T==NULL) return; findthreesums(T->lchild, head, k); if(k - T->data > T->data) findtwosums(head, k - T->data, T->data); findthreesums(T->rchild, head, k); return; } int main() { bstptr T = NULL; takeInput(T); int k; cin>>k; findthreesums(T, T, k); return 0; }
05a5084925ea70f665dd2997f6a3b87f83131f50
a03abde36205d8d1c690a949cd2f16962b37687d
/A2/graph.h
ed7d9f9893a09f1863d6f9e4613953bc53efecc1
[]
no_license
chitraa-ramachandran/vertex-cover-probelm
e02eb86027b58b085058276d3eb83fc426759894
d5ac3357dff8a592a16b7246fbc82f7687e2f431
refs/heads/master
2022-11-12T19:34:46.833700
2020-07-06T06:23:47
2020-07-06T06:23:47
277,454,779
0
0
null
null
null
null
UTF-8
C++
false
false
430
h
graph.h
#include <vector> using namespace std; class graph { #define INDEFINITE (~(0x1<<31)) private: unsigned int vertices_number; vector<vector<unsigned int>> adjaceny_matrix; vector<unsigned> edge; public: void initialize_graph(unsigned int no_of_vertices); void clear_all_edges(); void edge_construction(unsigned int vertices_1, unsigned int vertices_2); void bellman_ford(unsigned int src_node, unsigned int dest_node); };
7c5bdd7ca40d5cbc611b59e612eba0cc802f7bd7
19f1daea6861f2e4f08c76f07ac0f84306d240c8
/Tools/MiscUtils/include/Tools/MiscUtils/ConcurrentQueue.h
ac30d1004a7ac5d9034980369a8dbb0202129bf8
[]
no_license
erdoukki/PraeTor
e1ded122c51c45fdacf1f8733173ae509bcdd106
42173cfa97612c05a99b9913929e13f5f549e126
refs/heads/master
2021-12-23T16:29:22.260165
2017-11-18T11:22:16
2017-11-18T11:22:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,410
h
ConcurrentQueue.h
#ifndef TOOLS_MISCUTILS_CONCURRENTQUEUE_H_ #define TOOLS_MISCUTILS_CONCURRENTQUEUE_H_ #include <queue> #include <boost/thread/mutex.hpp> #include <boost/thread/condition.hpp> namespace Tools { namespace MiscUtils { /** * @brief Многопоточная очередь * @tparam T - тип данных очереди * * Класс реализует многопоточную очередь данных. * Для межпоточной синхронизации используется boost::mutex, boost::condition * * <b>thread-safe</b> */ template<typename T> class ConcurrentQueue { public: /** * Помещает данные в очередь * @param data */ void push(T const& data) { boost::mutex::scoped_lock lock(m_mutex); m_queue.push(data); lock.unlock(); m_condition.notify_one(); } /** @return true - если очерьедь пустая, иначе false */ bool isEmpty() const { boost::mutex::scoped_lock lock(m_mutex); return m_queue.empty(); } /** @return количество элементов в очереди */ size_t getSize() const { return m_queue.size(); } /** * Извлекает данные из очереди * @param value - извлекаемые данные * @return true - если данные извлеклись, иначе false */ bool tryPop(T& value) { boost::mutex::scoped_lock lock(m_mutex); if (m_queue.empty()) { return false; } value = m_queue.front(); m_queue.pop(); return true; } /** * Ожидает данные и извлекает их из очереди * @param value - извлекаемые данные */ void waitAndPop(T& value) { boost::mutex::scoped_lock lock(m_mutex); while (m_queue.empty()) { m_condition.wait(lock); } value = m_queue.front(); m_queue.pop(); } private: /** Очередь данных */ std::queue<T> m_queue; /** Мьютекс */ mutable boost::mutex m_mutex; /** Условная переменная ожидания */ boost::condition m_condition; }; } /* namespace MiscUtils */ } /* namespace Tools */ #endif /* CONCURRENTQUEUE_H_ */
b3bcc46566ca5a884dd45bef3b57a356c64b7e7a
130caa2001baed165203ab3e73751c218a52c4b1
/ex680_valid_palindrome_II/solution.cpp
30e127bd1fbab8a068ccfae4bd1a80a0aca2e285
[]
no_license
blenz3/leetcode
b3a29e42e64847c0eee91a2aa2cdfe2716af49f2
f99def4b16e29b08b0b4af1004c7e53113ff9325
refs/heads/master
2022-07-17T06:01:38.536254
2022-07-11T00:51:12
2022-07-11T00:51:12
185,082,578
0
0
null
null
null
null
UTF-8
C++
false
false
916
cpp
solution.cpp
class Solution { public: bool validPalindrome(string s) { if (s.length() < 2) return true; int start = 0, end = s.length() - 1; while (start <= end) { // Once we encounter a bad character continue to attempt to // scan for a palindrome with the exclusion of the first // character and then a separate scan excluding the last if (s[start] != s[end]) { return checkPalindromeRange(s, start + 1, end) || checkPalindromeRange(s, start, end - 1); } start++, end--; } return true; } bool checkPalindromeRange(const std::string& s, int start, int end) { while (start <= end) { if (s[start] != s[end]) return false; start++, end--; } return true; } };
65d9d27bd573fb1041803679e8124e51c56bd0aa
4bfe0eec8feae8d59ef9d623501fd00ac0fa5db3
/control-server/src/cloud_ws.cpp
a06c46180bd1cdc1d68904a4f635c5ee4737d0ec
[ "MIT" ]
permissive
wozio/home-system
8b23d175a554aed060bb0b3cba97fcb02e4fac80
16b3673a00aa67f1a85d724ada13b03db6f5c146
refs/heads/master
2021-05-22T08:49:47.026886
2015-12-28T08:01:31
2015-12-28T08:01:31
17,995,115
0
0
null
null
null
null
UTF-8
C++
false
false
2,360
cpp
cloud_ws.cpp
#include "cloud_ws.h" #include "logger.h" #include "cloud_client.h" #include "Poco/Net/HTTPSClientSession.h" #include "Poco/Net/HTTPClientSession.h" #include "Poco/Net/NetException.h" #include "Poco/Net/SSLException.h" #include "Poco/Net/SSLManager.h" #include "Poco/Net/KeyConsoleHandler.h" #include "Poco/Net/PrivateKeyPassphraseHandler.h" #include "Poco/Net/InvalidCertificateHandler.h" #include "Poco/Net/AcceptCertificateHandler.h" #include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPResponse.h" #include <memory> using namespace Poco::Net; using namespace Poco; using namespace std; namespace home_system { cloud_ws::cloud_ws(const std::string& host, int port, const std::string& uri, bool no_ssl) : host_(host), port_(port), uri_(uri), no_ssl_(no_ssl), logged_(false) { if (!no_ssl_) Poco::Net::initializeSSL(); timer_.set_from_now(1000, [this](){ this->connect(); }); } cloud_ws::~cloud_ws() { timer_.cancel(); if (!no_ssl_) Poco::Net::uninitializeSSL(); } void cloud_ws::connect() { if (!logged_) LOGINFO("Connecting to cloud server"); try { unique_ptr<HTTPClientSession> cs; if (!no_ssl_) { SharedPtr<PrivateKeyPassphraseHandler> pConsoleHandler = new KeyConsoleHandler(false); SharedPtr<InvalidCertificateHandler> pInvalidCertHandler = new AcceptCertificateHandler(false); Context::Ptr pContext = new Context(Context::CLIENT_USE, "", Context::VERIFY_NONE, 9, true); SSLManager::instance().initializeClient(pConsoleHandler, pInvalidCertHandler, pContext); cs.reset(new HTTPSClientSession(host_, port_)); } else { cs.reset(new HTTPClientSession(host_, port_)); } // TODO: add proxy handling as below but from system or from command line params //cs->setProxy("172.23.0.100", 8080); HTTPRequest request(HTTPRequest::HTTP_GET, uri_, HTTPMessage::HTTP_1_1); HTTPResponse response; ws_t ws(new WebSocket(*cs, request, response)); shared_ptr<cloud_client> h(new cloud_client(ws, [this](){ timer_.set_from_now(1000, [this](){ connect(); }); })); h->init(); logged_ = false; } catch (Exception &e) { if (!logged_) { LOGERROR("Error: " << e.displayText()); logged_ = true; } timer_.set_from_now(1000, [this](){ this->connect(); }); } } }
d4bb3c9fa6cd62f88b983586cd2f367dc131a971
60743a4f6b7d99cd9c16f67b096f8fcd8168801e
/src/ds/splay.cpp
38366e22154a2ef981951db5d4b04b1378f4e203
[]
no_license
alex4814/algo-template
d4383e07ba45254143752f691692ccbea7b55011
90850cec16216174c3397a35b23e21fa0bb8ebcf
refs/heads/master
2020-05-20T13:39:32.139731
2014-09-13T14:12:08
2014-09-13T14:12:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,405
cpp
splay.cpp
/* An implementation of top-down splaying D. Sleator <sleator@cs.cmu.edu> March 1992 */ #include <stdlib.h> #include <stdio.h> int size; /* number of nodes in the tree */ /* Not actually needed for any of the operations */ typedef struct tree_node Tree; struct tree_node { Tree * left, * right; int item; }; Tree * splay (int i, Tree * t) { /* Simple top down splay, not requiring i to be in the tree t. */ /* What it does is described above. */ Tree N, *l, *r, *y; if (t == NULL) return t; N.left = N.right = NULL; l = r = &N; for (;;) { if (i < t->item) { if (t->left == NULL) { break; } if (i < t->left->item) { y = t->left; /* rotate right */ t->left = y->right; y->right = t; t = y; if (t->left == NULL) { break; } } r->left = t; /* link right */ r = t; t = t->left; } else if (i > t->item) { if (t->right == NULL) { break; } if (i > t->right->item) { y = t->right; /* rotate left */ t->right = y->left; y->left = t; t = y; if (t->right == NULL) { break; } } l->right = t; /* link left */ l = t; t = t->right; } else { break; } } l->right = t->left; /* assemble */ r->left = t->right; t->left = N.right; t->right = N.left; return t; } /* Here is how sedgewick would have written this. */ /* It does the same thing. */ Tree * sedgewickized_splay (int i, Tree * t) { Tree N, *l, *r, *y; if (t == NULL) { return t; } N.left = N.right = NULL; l = r = &N; for (;;) { if (i < t->item) { if (t->left != NULL && i < t->left->item) { y = t->left; t->left = y->right; y->right = t; t = y; } if (t->left == NULL) { break; } r->left = t; r = t; t = t->left; } else if (i > t->item) { if (t->right != NULL && i > t->right->item) { y = t->right; t->right = y->left; y->left = t; t = y; } if (t->right == NULL) { break; } l->right = t; l = t; t = t->right; } else { break; } } l->right=t->left; r->left=t->right; t->left=N.right; t->right=N.left; return t; } Tree * insert(int i, Tree * t) { /* Insert i into the tree t, unless it's already there. */ /* Return a pointer to the resulting tree. */ Tree * new; new = (Tree *) malloc (sizeof (Tree)); if (new == NULL) { printf("Ran out of space\n"); exit(1); } new->item = i; if (t == NULL) { new->left = new->right = NULL; size = 1; return new; } t = splay(i,t); if (i < t->item) { new->left = t->left; new->right = t; t->left = NULL; size ++; return new; } else if (i > t->item) { new->right = t->right; new->left = t; t->right = NULL; size++; return new; } else { /* We get here if it's already in the tree */ /* Don't add it again */ free(new); return t; } } Tree * delete(int i, Tree * t) { /* Deletes i from the tree if it's there. */ /* Return a pointer to the resulting tree. */ Tree * x; if (t==NULL) { return NULL; } t = splay(i,t); if (i == t->item) { /* found it */ if (t->left == NULL) { x = t->right; } else { x = splay(i, t->left); x->right = t->right; } size--; free(t); return x; } return t; /* It wasn't there */ } int main(int argv, char *argc[]) { /* A sample use of these functions. Start with the empty tree, */ /* insert some stuff into it, and then delete it */ Tree * root; int i; root = NULL; /* the empty tree */ size = 0; for (i = 0; i < 1024; i++) { root = insert((541*i) & (1023), root); } printf("size = %d\n", size); for (i = 0; i < 1024; i++) { root = delete((541*i) & (1023), root); } printf("size = %d\n", size); }
39db352ee89a7cd8ce6bef1464a6bab76d82c8bb
88fecb26c8842adc18d7945db24efa609f639b82
/vec3dT/vec3dT_test.cpp
a99c4b1d03497ff261c9509cefef6dd9d663bfd7
[]
no_license
dzyubaira/dzyuba_i_i
a651543d4ce11066f0c3698acffa1568c7a04ce2
cfa111acbc4cfc178d8c3820b6a14cefd9bf3ff4
refs/heads/master
2021-09-13T10:47:58.269498
2018-04-28T16:23:58
2018-04-28T16:23:58
104,768,981
0
0
null
null
null
null
UTF-8
C++
false
false
881
cpp
vec3dT_test.cpp
#include <iostream> #include <sstream> #include "vec3dT.h" int main() { using namespace std; Vec3dT<double> z; Vec3dT<double> a(2.5, 3.6, 4.6); cout << "a = " << a << endl; Vec3dT<int> aa(3, 8, 9); cout << "aa = " << aa << endl; Vec3dT<double> b(a); cout << "b(a) = " << b << endl; Vec3dT<double> c = b; cout << "c = b" << endl << "c = " << c << endl; Vec3dT<double> d(3.7, 8.4, 8.9); cout << "d = " << d << endl; if (b == c) cout << "b == c" << endl; if (c != d) cout << "c != d" << endl; c += d; cout << "c += d = " << c << endl; c -= d; cout << "c -= d = " << c << endl; int e = 3; cout << "e = " << e << endl; c *= e; cout << "c *= e = " << c << endl; c /= e; cout << "c /= e = " << c << endl; c *= d; cout << "c *= d = " << c << endl; double l = length(c); cout << "length(c) = " << l << endl; return 0; }
a26d7a82b6a7dbfe23420353186ae4297644f996
c64bb008b5bf80cd2ab4437c8aba75cb44ff8b60
/source/TaskManagerPrefs.cpp
d8c3bd366edc0c5278a9f715ca0e9db36510bcc9
[ "Apache-2.0" ]
permissive
HaikuArchives/TaskManager
37e2e7f18e06f0bb21e75d2f85afb67409d0af80
4fd44eaa83d99e9314fe8f3ae10f1e9b99ea3291
refs/heads/master
2021-03-12T20:05:39.195433
2020-02-09T20:38:59
2020-02-09T20:38:59
14,735,001
5
5
NOASSERTION
2020-02-09T20:39:00
2013-11-27T02:10:14
C++
UTF-8
C++
false
false
5,773
cpp
TaskManagerPrefs.cpp
/* * Copyright 2000 by Thomas Krammer * * 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 "pch.h" #include "common.h" #include "TaskManagerPrefs.h" // ====== globals ====== const char * const PREF_MAIN_WINDOW_RECT = "MainWindowRect"; const char * const PREF_PULSE_RATE = "PulseRate"; const char * const PREF_SHOW_DESKBAR_REPLICANT = "ShowDeskbarRep"; const char * const PREF_COLUMN_WIDTH_PREFIX = "ColumnWidth_"; const char * const PREF_COLUMN_DISPLAY_ORDER = "ColumnDisplayOrder"; const char * const PREF_COLUMN_VISIBLE_PREFIX = "ColumnVisible_"; const char * const PREF_SORT_KEY_INFO = "SortKeyInfo"; const char * const PREF_SHOW_KILL_WARNING = "ShowKillWarning"; const char * const PREF_SHOW_SYSTEM_KILL_WARNING = "ShowSystemKillWarning"; const char * const PREF_HIDE_DESKBAR_REPLICANT_ON_CLOSE = "HideDeskbarRepOnClose"; const char * const PREF_HIDE_SYSTEM_TEAMS = "HideSystemTeams"; const char * const PREF_SHOW_IN_ALL_WORKSPACES = "ShowInAllWorkspaces"; const char * const PREF_ADD_PERFORMANCE_WINDOW_RECT = "AddPreformanceWindowRect"; const char * const PREF_PERFORMANCE_LEGEND_BAR_WIDTH = "PerfLegendBarWidth"; const char * const PREF_LANGUAGE = "Language"; const char * const PREF_SELECTED_TAB = "SelectedTab"; // ====== CTaskManagerPrefs ====== CTaskManagerPrefs::CTaskManagerPrefs() : CFilePreferences("TaskMgr_settings") { } BRect CTaskManagerPrefs::MainWindowRect() { BRect rect; Read(PREF_MAIN_WINDOW_RECT, rect, BRect(100,100, 400, 400)); return rect; } void CTaskManagerPrefs::SetMainWindowRect(BRect rect) { Write(PREF_MAIN_WINDOW_RECT, rect); } BRect CTaskManagerPrefs::AddPreformanceWindowRect(BRect defaultRect) { BRect rect; Read(PREF_ADD_PERFORMANCE_WINDOW_RECT, rect, defaultRect); return rect; } void CTaskManagerPrefs::SetAddPreformanceWindowRect(BRect rect) { Write(PREF_ADD_PERFORMANCE_WINDOW_RECT, rect); } bigtime_t CTaskManagerPrefs::PulseRate() { bigtime_t pulse; Read(PREF_PULSE_RATE, pulse, NORMAL_PULSE_RATE); return pulse; } void CTaskManagerPrefs::SetPulseRate(bigtime_t pulse) { Write(PREF_PULSE_RATE, pulse); } bool CTaskManagerPrefs::ShowDeskbarReplicant() { bool show; Read(PREF_SHOW_DESKBAR_REPLICANT, show); return show; } void CTaskManagerPrefs::SetShowDeskbarReplicant(bool show) { Write(PREF_SHOW_DESKBAR_REPLICANT, show); } float CTaskManagerPrefs::PerformanceLegendBarWidth(float defaultValue) { float value; Read(PREF_PERFORMANCE_LEGEND_BAR_WIDTH, value, defaultValue); return value; } void CTaskManagerPrefs::SetPerformanceLegendBarWidth(float width) { Write(PREF_PERFORMANCE_LEGEND_BAR_WIDTH, width); } bool CTaskManagerPrefs::ShowInAllWorkspaces() { bool show; Read(PREF_SHOW_IN_ALL_WORKSPACES, show, false); return show; } void CTaskManagerPrefs::SetShowInAllWorkspaces(bool show) { Write(PREF_SHOW_IN_ALL_WORKSPACES, show); } bool CTaskManagerPrefs::HideSystemTeams() { bool hideSystemTeams; Read(PREF_HIDE_SYSTEM_TEAMS, hideSystemTeams, false); return hideSystemTeams; } bool CTaskManagerPrefs::HideDeskbarReplicantOnClose() { bool hideDeskbarRep; Read(PREF_HIDE_DESKBAR_REPLICANT_ON_CLOSE, hideDeskbarRep, true); return hideDeskbarRep; } float CTaskManagerPrefs::ColumnWidth(int32 columnNum, float defaultValue) { char name[255]; sprintf(name, "%s%ld", PREF_COLUMN_WIDTH_PREFIX, columnNum); float width; Read(name, width, defaultValue); return width; } void CTaskManagerPrefs::SetColumnWidth(int32 columnNum, float width) { char name[255]; sprintf(name, "%s%ld", PREF_COLUMN_WIDTH_PREFIX, columnNum); Write(name, width); } bool CTaskManagerPrefs::ColumnVisible(int32 columnNum, bool defaultValue) { char name[255]; sprintf(name, "%s%ld", PREF_COLUMN_VISIBLE_PREFIX, columnNum); bool visible; Read(name, visible, defaultValue); return visible; } void CTaskManagerPrefs::SetColumnVisible(int32 columnNum, bool visible) { char name[255]; sprintf(name, "%s%ld", PREF_COLUMN_VISIBLE_PREFIX, columnNum); Write(name, visible); } sort_key_info *CTaskManagerPrefs::SortKeyInfo() { int32 num = SortKeyInfoCount(); sort_key_info *sortInfo = new sort_key_info [num]; Read(PREF_SORT_KEY_INFO, (void *)sortInfo, sizeof(sort_key_info), num); return sortInfo; } int32 CTaskManagerPrefs::SortKeyInfoCount() { return (int32)(DataSize(PREF_SORT_KEY_INFO) / sizeof(sort_key_info)); } void CTaskManagerPrefs::SetSortKeyInfo(sort_key_info *sortKeys, int32 num) { Write(PREF_SORT_KEY_INFO, (void *)sortKeys, sizeof(sort_key_info), num); } int32 *CTaskManagerPrefs::ColumnDisplayOrder(int32 numColumns) { int32 *dispOrder = new int32 [numColumns]; // initalize array for(int i=0 ; i<numColumns ; i++) dispOrder[i] = i; Read(PREF_COLUMN_DISPLAY_ORDER, (void *)dispOrder, sizeof(int32), numColumns); return dispOrder; } void CTaskManagerPrefs::SetColumnDisplayOrder(int32 *displayOrder, int32 numColumns) { Write(PREF_COLUMN_DISPLAY_ORDER, (void *)displayOrder, sizeof(int32), numColumns); } void CTaskManagerPrefs::SetLanguage(const char *language) { Write(PREF_LANGUAGE, language); } BString CTaskManagerPrefs::Language() { BString language; Read(PREF_LANGUAGE, language, "English"); return language; }
b222a50522f0102868a5d075332d688f72e393f6
7f47f6d46c359626b7359eb7ea5cbfaf9e375a48
/project/main.cpp
390578f3c67db3f2bf239f2d3698c1e7c9035fb5
[]
no_license
TheCharmingSociopath/C--Compiler
25f1c1f2fb35ff15f26c8be5c65ab4e6b9ba53df
522e6bf76483c19a565f9cec63d8b210c5217989
refs/heads/master
2023-02-18T17:25:58.339405
2021-01-21T06:02:08
2021-01-21T06:02:08
331,529,503
0
0
null
null
null
null
UTF-8
C++
false
false
1,049
cpp
main.cpp
#include <iostream> #include "ExprLexer.cpp" #include "ExprParser.cpp" #include "antlr4-runtime.h" #include "ExprBuildASTVisitor.h" #include "SemanticCheckVisitor.h" #include "IRVisitor.h" using namespace std; using namespace antlr4; int main(int argc, const char* argv[]) { std::ifstream stream; cout << "Processing input file " << argv[1] << endl; stream.open(argv[1]); ANTLRInputStream input(stream); ExprLexer lexer(&input); CommonTokenStream tokens(&lexer); ExprParser parser(&tokens); ExprParser::ProgContext* ctx = parser.prog(); SymbolTable *symbolTable = new SymbolTable(); ExprVisitor* visitor = new ExprBuildASTVisitor(); ASTProg* program_root = visitor->visitProg(ctx); SemanticCheckVisitor* scv = new SemanticCheckVisitor(symbolTable); scv->visit(*program_root); cout << "======================= IR ==================" << endl; IRVisitor *irv = new IRVisitor(); irv->visit(*program_root); TheModule->print(llvm::errs(), nullptr); return 0; }
d916456b96ed7605546294b95addbab6c19ac501
0ff9c8800b1d2601a453dcfef875603abfae5613
/tests/cpp/core/StreamImageTests.cpp
3a08d7d9837cf49d71573e9676fedbe984eff78f
[ "BSD-2-Clause" ]
permissive
Aeroglyphic/Tide
283680d250a908446100cabe6c2a07585f8ac563
a10f402bdff751886ffeb79b20d27162e42b6d57
refs/heads/master
2020-03-28T16:37:22.979564
2018-09-13T13:41:20
2018-09-13T13:54:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,851
cpp
StreamImageTests.cpp
/*********************************************************************/ /* Copyright (c) 2017-2018, EPFL/Blue Brain Project */ /* Raphael Dumusc <raphael.dumusc@epfl.ch> */ /* 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. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ /* AUSTIN ``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 UNIVERSITY OF TEXAS AT */ /* AUSTIN 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. */ /* */ /* The views and conclusions contained in the software and */ /* documentation are those of the authors and should not be */ /* interpreted as representing official policies, either expressed */ /* or implied, of Ecole polytechnique federale de Lausanne. */ /*********************************************************************/ #define BOOST_TEST_MODULE StreamImageTests #include <boost/test/unit_test.hpp> #include "data/StreamImage.h" #include <deflect/server/Frame.h> #include <deflect/server/TileDecoder.h> namespace { const std::vector<uint8_t> expectedRGBA(8 * 8 * 4, 17); const std::vector<uint8_t> expectedY(8 * 8, 92); const std::vector<uint8_t> expectedU(8 * 8, 28); const std::vector<uint8_t> expectedV(8 * 8, 79); } deflect::server::FramePtr createRgbaTestFrame(const QSize& size) { deflect::server::FramePtr frame(new deflect::server::Frame); deflect::server::Tile tile; tile.x = 10; tile.y = -20; tile.width = size.width(); tile.height = size.height(); tile.format = deflect::Format::rgba; tile.imageData.append(QByteArray(size.width() * size.height() * 4, 17)); frame->tiles.push_back(tile); return frame; } deflect::server::FramePtr createYuvTestFrame(const QSize& size, const int subsamp) { deflect::server::FramePtr frame(new deflect::server::Frame); deflect::server::Tile tile; tile.x = 10; tile.y = -20; tile.width = size.width(); tile.height = size.height(); tile.format = deflect::Format::yuv444; if (subsamp == 1) tile.format = deflect::Format::yuv422; else if (subsamp == 2) tile.format = deflect::Format::yuv420; const auto ySize = size.width() * size.height(); const auto uvSize = ySize >> subsamp; tile.imageData.append(QByteArray(ySize, 92)); // Y tile.imageData.append(QByteArray(uvSize, 28)); // U tile.imageData.append(QByteArray(uvSize, 79)); // V frame->tiles.push_back(tile); return frame; } BOOST_AUTO_TEST_CASE(testStreamImageRGBA) { StreamImage image(createRgbaTestFrame({8, 8}), 0); BOOST_CHECK_EQUAL(image.getPosition(), QPoint(10, -20)); BOOST_CHECK_EQUAL(image.getWidth(), 8); BOOST_CHECK_EQUAL(image.getHeight(), 8); const auto data = image.getData(0); const auto size = image.getDataSize(0); BOOST_CHECK(image.getColorSpace() == ColorSpace::undefined); BOOST_CHECK(image.getRowOrder() == deflect::RowOrder::top_down); BOOST_CHECK_EQUAL(size, 8 * 8 * 4); BOOST_CHECK_EQUAL_COLLECTIONS(data, data + size, expectedRGBA.data(), expectedRGBA.data() + size); BOOST_CHECK_EQUAL(image.getTextureSize(0), QSize(8, 8)); } BOOST_AUTO_TEST_CASE(testStreamImageYUV) { for (int subsamp = 0; subsamp <= 2; ++subsamp) { StreamImage image(createYuvTestFrame({8, 8}, subsamp), 0); const auto y = image.getData(0); const auto u = image.getData(1); const auto v = image.getData(2); const auto imageSizeY = image.getTextureSize(0); const auto imageSizeU = image.getTextureSize(1); const auto imageSizeV = image.getTextureSize(2); const auto ySize = imageSizeY.width() * imageSizeY.height(); const auto uSize = imageSizeU.width() * imageSizeU.height(); const auto vSize = imageSizeV.width() * imageSizeV.height(); BOOST_CHECK_EQUAL(image.getPosition(), QPoint(10, -20)); BOOST_CHECK_EQUAL(image.getWidth(), 8); BOOST_CHECK_EQUAL(image.getHeight(), 8); BOOST_CHECK(image.getColorSpace() == ColorSpace::yCbCrJpeg); BOOST_CHECK(image.getRowOrder() == deflect::RowOrder::top_down); BOOST_CHECK_EQUAL(image.getDataSize(0), 8 * 8); BOOST_CHECK_EQUAL(image.getDataSize(1), 8 * 8 >> subsamp); BOOST_CHECK_EQUAL(image.getDataSize(2), 8 * 8 >> subsamp); BOOST_CHECK_EQUAL(ySize, 8 * 8); BOOST_CHECK_EQUAL(uSize, 8 * 8 >> subsamp); BOOST_CHECK_EQUAL(vSize, 8 * 8 >> subsamp); BOOST_CHECK_EQUAL_COLLECTIONS(y, y + ySize, expectedY.data(), expectedY.data() + ySize); BOOST_CHECK_EQUAL_COLLECTIONS(u, u + uSize, expectedU.data(), expectedU.data() + uSize); BOOST_CHECK_EQUAL_COLLECTIONS(v, v + vSize, expectedV.data(), expectedV.data() + vSize); } }
7ebe0a7517683aee412a337c1a9b2f86b787ef81
3391892861a1e1e71af6e414bcdb9fc0df66c62e
/src/game/world/animations/aspects/update_slide_ceiling_sky_aspect.cpp
551885d760b0ae5bd4c676a17b2d2ffdce39fba0
[ "Apache-2.0" ]
permissive
jdmclark/gorc
a21208b1d03a85fc5a99fdd51fdad27446cc4767
a03d6a38ab7684860c418dd3d2e77cbe6a6d9fc8
refs/heads/develop
2021-01-21T05:01:26.609783
2020-12-21T00:26:22
2020-12-21T02:34:31
10,290,074
103
10
Apache-2.0
2020-12-21T02:34:33
2013-05-25T21:27:37
C++
UTF-8
C++
false
false
548
cpp
update_slide_ceiling_sky_aspect.cpp
#include "update_slide_ceiling_sky_aspect.hpp" #include "game/constants.hpp" gorc::game::world::animations::aspects::update_slide_ceiling_sky_aspect::update_slide_ceiling_sky_aspect(entity_component_system<thing_id>& cs, level_model& model) : inner_join_aspect(cs), model(model) { return; } void gorc::game::world::animations::aspects::update_slide_ceiling_sky_aspect::update(time_delta t, thing_id, components::slide_ceiling_sky& anim) { model.header.ceiling_sky_offset += anim.speed * static_cast<float>(t.count() * rate_factor); }
b2bea2684470e1fdb2c557f3ffe4a7dd09ba7d0f
750321143f90c971a309d2fe4e861d2b9a1ed9bf
/bt/bt.ino
b5f630f0d83cdd0990211c8766b97e9ce26eb598
[]
no_license
xrisk/Arduino
e4fd438d0ec2b219ca5791005d1a00b2780aa77a
227a263d1ab7312833a2065f12511899e1f7342d
refs/heads/master
2021-07-22T22:20:55.760500
2019-07-24T18:50:17
2019-07-24T18:50:17
102,395,473
0
0
null
null
null
null
UTF-8
C++
false
false
486
ino
bt.ino
#include <SoftwareSerial.h> int tx = 5; int rx = 4; int key_pin = 3; SoftwareSerial swserial(tx, rx); void setup() { Serial.begin(9600); swserial.begin(9600); pinMode(key_pin, OUTPUT); digitalWrite(key_pin, HIGH); swserial.write("AT"); delay(200); // swserial.write("AT+VERSION?"); } void loop() { while (swserial.available() > 0) Serial.write(swserial.read()); while (Serial.available() > 0) swserial.write(Serial.read()); }
7aac3cbeda988f4bdb2cbe5a117969cb4ccc850f
b42002c5c1d2ba115b07c9a848ec02e976cb0315
/src/motionplan/src/motionPlan_test.cpp
ec0e71c6d3dab382e77329e3e881fbe8728da075
[]
no_license
gywhitel/RGBD_LeapMotion_UR-roboticArm
a0929c85ee36045da6440d1a708bcbebe7f652f6
a54e248fab9168560371deeb17b6ab4868c7c673
refs/heads/master
2020-05-14T23:03:36.571867
2019-05-11T03:13:41
2019-05-11T03:13:41
181,990,350
0
0
null
null
null
null
UTF-8
C++
false
false
1,618
cpp
motionPlan_test.cpp
#include <pluginlib/class_loader.h> #include <ros/ros.h> // MoveIt! #include <moveit/move_group_interface/move_group_interface.h> #include <moveit/planning_scene_interface/planning_scene_interface.h> #include <moveit_msgs/AttachedCollisionObject.h> #include <moveit_msgs/CollisionObject.h> /* #include <moveit/robot_model_loader/robot_model_loader.h> #include <moveit/planning_interface/planning_interface.h> #include <moveit/planning_scene/planning_scene.h> #include <moveit/kinematic_constraints/utils.h> #include <moveit_msgs/DisplayTrajectory.h> #include <moveit_msgs/PlanningScene.h> */ #include <boost/scoped_ptr.hpp> int main(int argc, char **argv) { ros::init (argc, argv, "motionPlan_test"); ros::AsyncSpinner spinner(1); spinner.start(); ros::NodeHandle node_handle("~"); //================== moveit::planning_interface::PlanningSceneInterface current_scene; sleep(5.0); moveit_msgs::CollisionObject cylinder; cylinder.id = "floor_cylinder"; shape_msgs::SolidPrimitive primitve; primitve.type = primitve.BOX; primitve.dimensions.resize(3); primitve.dimensions[0]=1.2; primitve.dimensions[1]=-0.4; primitve.dimensions[1]=1.2; geometry_msgs::Pose pose; pose.orientation.w =1.0; pose.position.x =0.0; pose.position.y =0.0; pose.position.z =0.0; cylinder.primitives.push_back(primitve); cylinder.primitive_poses.push_back(pose); cylinder.operation=cylinder.ADD; std::vector<moveit_msgs::CollisionObject> collision_objects; collision_objects.push_back(cylinder); current_scene.addCollisionObjects(collision_objects); ros::shutdown(); return 0; }
c8dcf708b802481596166ca0d1f5bfa8204460ca
11e97f87deb25babb4a32c80941e7ff4e476c92a
/SSE/HRL_630P/Motion/Sequence.h
72fa775254337f7bcd9a3b8be66b0b0f746bcd53
[]
no_license
xhyangxianjun/Builder6-program
b9d03d98658db5a5a8cf1586210a373bc391dc48
a12d811d7a5fa3dba6d3e8c05989a41cb89783de
refs/heads/master
2022-04-03T00:25:47.274355
2019-09-19T08:26:56
2019-09-19T08:26:56
null
0
0
null
null
null
null
UHC
C++
false
false
5,089
h
Sequence.h
//--------------------------------------------------------------------------- #ifndef SequenceH #define SequenceH //--------------------------------------------------------------------------- #include "Timer.h" #include "SMInterfaceUnit.h" #include "PartInterface.h" #include "UtilDefine.h" //#include <Grids.hpp> class CSequence { private: /* Member Var. */ //Timer. m_tmMain CDelayTimer m_tmToStop ; CDelayTimer m_tmToStrt ; CDelayTimer m_tmFlickOn ; CDelayTimer m_tmFlickOff ; CDelayTimer m_tmCloseDoor ; CDelayTimer m_tmTemp ; enum EN_SEQ_STEP { scIdle = 0 , scToStartCon = 10 , scToStart = 11 , scRun = 12 , scToStopCon = 13 , scToStop = 14 , MAX_SEQ_CYCLE }; //Vars. bool m_bBtnReset ; //Button Input. bool m_bBtnStart ; bool m_bBtnStop ; bool m_bBtnAir ; bool m_bInspDispr ; bool m_bInspUnkwn ; bool m_bRun ; //Run Flag. (Latched) bool m_bReqStop ; bool m_bFlick ; //Flicking Flags. EN_SEQ_STEP m_iStep ; //Sequence Step. EN_SEQ_STAT m_iSeqStat ; //Current Sequence Status. bool r1 , r2 , r3 ,r4 ,r5; protected: //Check Button. void __fastcall UpdateButton (void); public: //Var. DWORD dwUD_Strt[20]; //Scan Time DWORD dwUP_Scan[20]; //Property. __property bool _bBtnReset = { write = m_bBtnReset }; __property bool _bBtnStart = { write = m_bBtnStart }; __property bool _bBtnStop = { write = m_bBtnStop }; __property bool _bBtnAir = { write = m_bBtnAir }; __property bool _bRun = { read = m_bRun }; __property bool _bReqStop = { read = m_bReqStop }; __property bool _bFlick = { read = m_bFlick }; __property bool _bInspDispr= { read = m_bInspDispr ,write = m_bInspDispr }; __property bool _bInspUnkwn= { read = m_bInspUnkwn ,write = m_bInspUnkwn }; __property EN_SEQ_STEP _iStep = { read = m_iStep }; __property EN_SEQ_STAT _iSeqStat = { read = m_iSeqStat }; public: __fastcall CSequence(void); __fastcall ~CSequence(void); //Init. void __fastcall Init (void); void __fastcall Close(void); //void __fastcall Reset(void); //Functions. //Inspection Machine Status. bool __fastcall InspectMainAir (void); bool __fastcall InspectTemp (void); bool __fastcall InspectEmergency (void); bool __fastcall InspectLightGrid (void); bool __fastcall InspectDoor (void); bool __fastcall InspectActuator (void); bool __fastcall InspectMotor (void); bool __fastcall InspectHomeEnd (void); bool __fastcall InspectCrash (void); bool __fastcall InspectStripDispr (void); bool __fastcall InspectStripUnknown(void); bool __fastcall InspectOverLoad (void); //Running acions. //bool __fastcall ToStartCon (void); //Clear data to start. //bool __fastcall ToStopCon (void); //Check condition to stop the cycle. (Check iStepIndex number) //bool __fastcall ToStart (void); //Functions when start cycle running. //bool __fastcall ToStop (void); //Functions when stop the cycle. //bool __fastcall AutoRun (void); //Auto Run. public: //인터페이스 상속.================================================== void Reset (); //리셑 버튼 눌렀을때 타는 함수. //Running Functions. bool ToStopCon (); //스탑을 하기 위한 조건을 보는 함수. bool ToStartCon(); //스타트를 하기 위한 조건을 보는 함수. bool ToStart (); //스타트를 하기 위한 함수. bool ToStop (); //스탑을 하기 위한 함수. bool Autorun (); //오토런닝시에 계속 타는 함수. //====================================================================== CPartInterface * m_pPart[MAX_PART] ; //Real Time Update. void __fastcall UpdateSeqState (void); void __fastcall Update (void); }; //--------------------------------------------------------------------------- extern CSequence SEQ; //--------------------------------------------------------------------------- #endif
4a9edb52b091fb5af93dc3d0bdd68ee7bc5bcc22
106a1bc787732f1fd53e984897c781262ce66ed3
/src/Lib/Mat.hpp
3b9bd78f02479d918f7cf4a4905b6046d8109094
[]
no_license
Panzerschrek/Sazava
364d79e797bbfba7ef395b46b31d008b348710d7
58215172d727f52206e9b8086838c2dd99a70da5
refs/heads/master
2023-04-07T03:15:53.574226
2021-04-11T08:18:15
2021-04-11T08:18:15
338,530,042
1
0
null
null
null
null
UTF-8
C++
false
false
1,010
hpp
Mat.hpp
#pragma once #include "Vec.hpp" namespace SZV { class m_Mat3 { public: // TODO - add other stuff. void MakeIdentity(); m_Mat3 GetInverseMatrix() const; float value[9]; }; class m_Mat4 { public: m_Mat4 operator* (const m_Mat4& m) const; m_Mat4& operator*=(const m_Mat4& m); m_Vec3 operator* (const m_Vec3& v) const; void MakeIdentity(); void Transpose(); void Inverse(); void Translate(const m_Vec3& v); void Scale(float scale); void Scale(const m_Vec3& scale); void RotateX(float angle); void RotateY(float angle); void RotateZ(float angle); void PerspectiveProjection(float aspect, float fov_y, float z_near, float z_far); void AxonometricProjection(float scale_x, float scale_y, float z_near, float z_far); /*True matrix - this 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ /*OpenGL matrix 0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15 */ float value[16]; }; m_Vec3 operator*(const m_Vec3& v, const m_Mat4& m); } // namespace SZV
82e02a8e89f71ed5f3b346fc392bbaf14dac221c
50b452728fcc521cd8e82ca1377bd1f6a7fa60ec
/CavemanNinja/GravityPlayerComponent.h
6f679430b7d0214dc3430d51f37b7264a17c3275
[]
no_license
DorianHawkmoon/Caveman-Ninja
a7c6e8f38363278127a8c3a4af6e0e79265fa7e6
c39dbd8be2234722bad3f2e5e53981d83ec3022c
refs/heads/master
2021-01-10T17:10:45.342359
2016-04-11T00:41:40
2016-04-11T00:41:40
49,627,241
0
0
null
null
null
null
UTF-8
C++
false
false
504
h
GravityPlayerComponent.h
#pragma once #ifndef GRAVITY_COMPONENT_H #define GRAVITY_COMPONENT_H #include "GravityComponent.h" #include "Application.h" #include "ModuleAudio.h" class GravityPlayerComponent : public GravityComponent { public: GravityPlayerComponent(const std::string& nameComponent, Collider *collider): GravityComponent(nameComponent,collider){} virtual ~GravityPlayerComponent(){} protected: unsigned int soundGround; virtual void loadSound(); virtual void playSound(); }; #endif // !GRAVITY_COMPONENT_H
79835870e8974bb09801322e9a6d20518e2c45b8
1f7684c30812f2657bfe6e83bf2fc32765158586
/name-surfer/linked_list.h
f3f3c1af4f0f0c88e14404b08f3c08cd0051921c
[]
no_license
s-sandra/c-code
3d70de20a936074ff0aa379e9e470270d1957352
e465fee9400c0015c14017913c3bdcffdccfff84
refs/heads/master
2020-06-12T23:29:54.645939
2019-07-06T00:49:21
2019-07-06T00:49:21
194,461,156
0
0
null
null
null
null
UTF-8
C++
false
false
865
h
linked_list.h
/// The specification of a template class of a linked list of type NODETYPE. #ifndef linked_list_H #define linked_list_H #include "single_node.h" #include <iostream> #include <string> using namespace std; template <class NODETYPE> class linked_list{ public: linked_list(); ~linked_list(); linked_list(linked_list<NODETYPE>& originalList); bool InsertRear(NODETYPE value); bool InsertFront(NODETYPE value); bool InsertInOrder(NODETYPE value); bool Remove(NODETYPE& value); bool RemoveFront(NODETYPE& value); bool RemoveRear(NODETYPE& value); void Search(NODETYPE& value); bool IsEmpty() const; void PrintAll(); private: ListNode<NODETYPE>* first; ListNode<NODETYPE>* current; ListNode<NODETYPE>* last; }; #include "linked_list.cpp" #endif
944cc623c0fd0d9ca669fafd0f2cda9c95d91595
7860b98a78e2a3b6799476204695ad04315be9fa
/chrone_rendering_engine/src/renderer/CommandBufferFunc.cpp
dfbec9e2bebf994851b5f65161378d13b1b6699c
[ "Unlicense" ]
permissive
Eszrah/chrone-rendering_engine
84510eb77f857818a6e26bdc72825c4f8236381e
f19f4ac41ed62d3ab371bf386f5834142ecc4c6a
refs/heads/master
2020-03-09T02:49:31.447376
2019-03-26T23:13:33
2019-03-26T23:13:33
128,549,683
0
0
null
null
null
null
UTF-8
C++
false
false
1,206
cpp
CommandBufferFunc.cpp
#include "renderer/CommandBufferFunc.h" #include "renderer/CommandBuffer.h" #include "renderer/RenderCommand.h" #include "renderer/ResourceHandle.h" #include "chrone-memory/include/LinearMemoryMapperFunc.h" using namespace chrone::memory; namespace chrone::rendering { void CommandBufferFunc::CmdCreateBuffer( ResourceCommandBuffer& cmdBuffer, CmdBufferCreateInfo const& cmd) { CommandBufferMemoryMapper& memoryMapper{ cmdBuffer.memoryMapper }; const Uint32 queueFamilyIndexCountSize{ cmd.createInfo.queueFamilyIndexCount * sizeof(uint32_t) }; const Uint32 iAllocationSize{ sizeof(CmdBufferCreateInfo) + queueFamilyIndexCountSize + sizeof(HBuffer)}; Char* memory{ LinearMemoryMapperFunc::MapMemory(memoryMapper, iAllocationSize) }; CommandHeader* header{ reinterpret_cast<CommandHeader*>(memory) }; memory += sizeof(CommandHeader); HBuffer* hBuffer{ reinterpret_cast<HBuffer*>(memory) }; memory += sizeof(HBuffer); CmdBufferCreateInfo* cmdMem{ reinterpret_cast<CmdBufferCreateInfo*>(memory) }; memcpy(cmdMem, &cmd, sizeof(CmdBufferCreateInfo)); memcpy(&cmdMem->createInfo.queueFamilyIndexCount, &cmd.createInfo.queueFamilyIndexCount, queueFamilyIndexCountSize); } }