hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
474d2df2309b28e66063c496b04f53530c1adac4
1,170
cpp
C++
homework/day_6/riemann_sum.cpp
msse-2021-bootcamp/team1-project
b950b01c6b74169b582c6b5dca5644a6ede90571
[ "BSD-3-Clause" ]
null
null
null
homework/day_6/riemann_sum.cpp
msse-2021-bootcamp/team1-project
b950b01c6b74169b582c6b5dca5644a6ede90571
[ "BSD-3-Clause" ]
37
2021-08-10T20:34:20.000Z
2021-08-23T16:07:31.000Z
homework/day_6/riemann_sum.cpp
msse-2021-bootcamp/team1-project
b950b01c6b74169b582c6b5dca5644a6ede90571
[ "BSD-3-Clause" ]
null
null
null
#include <iostream> double eval_integrand(double x) { return 1 / (1 + x * x); } double integration_function(int a, int b, int points){ double integeral_sum = 0; double rect_size = ((double)b-a)/points; for(int i=0; i < points; i++) { double step = eval_integrand((double)a+(rect_size/2)+(double)i*rect_size); double midpoint = (double)a+(rect_size/2)+(double)i*rect_size; std::cout << midpoint << std::endl; integeral_sum += step; } return ((double)b-a)/points * integeral_sum; } int main(void) { //std::cout << eval_integrand(1) << std::endl; std::cout << "(n=10) " << integration_function(0,1,10) << std::endl; //std::cout << "(n=50) " << integration_function(0,1,50) << std::endl; //std::cout << "(n=100) " << integration_function(0,1,100) << std::endl; //std::cout << "(n=500) " << integration_function(0,1,500) << std::endl; //std::cout << "(n=1000) " << integration_function(0,1,1000) << std::endl; //std::cout << "(n=5000) " << integration_function(0,1,5000) << std::endl; //std::cout << "(n=10000) " << integration_function(0,1,10000) << std::endl; //std::cout << "(n=50000) " << integration_function(0,1,50000) << std::endl; }
30.789474
77
0.622222
msse-2021-bootcamp
474f582ae2ed8114949a1ad4c2589f998e864f0c
2,189
hpp
C++
include/boost/tr1/memory.hpp
dstrigl/mcotf
92a9caf6173b1241a2f9ed45cd379469762b7178
[ "BSL-1.0" ]
null
null
null
include/boost/tr1/memory.hpp
dstrigl/mcotf
92a9caf6173b1241a2f9ed45cd379469762b7178
[ "BSL-1.0" ]
null
null
null
include/boost/tr1/memory.hpp
dstrigl/mcotf
92a9caf6173b1241a2f9ed45cd379469762b7178
[ "BSL-1.0" ]
null
null
null
// (C) Copyright John Maddock 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_TR1_MEMORY_HPP_INCLUDED # define BOOST_TR1_MEMORY_HPP_INCLUDED # include <boost/tr1/detail/config.hpp> # include <boost/detail/workaround.hpp> # include <memory> #ifndef BOOST_HAS_TR1_SHARED_PTR // // This header can get included by boost/shared_ptr.hpp which leads // to cyclic dependencies, the workaround is to forward declare all // the boost components, and then include the actual headers afterwards. // This is fragile, but seems to work, and doesn't require modification // of boost/shared_ptr.hpp. // namespace boost{ class bad_weak_ptr; template<class T> class weak_ptr; template<class T> class shared_ptr; template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b); template<class T> void swap(shared_ptr<T> & a, shared_ptr<T> & b); template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const & r); template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r); template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r); template<class D, class T> D * get_deleter(shared_ptr<T> const & p); template<class T> class enable_shared_from_this; namespace detail{ class shared_count; class weak_count; } } namespace std{ namespace tr1{ using ::boost::bad_weak_ptr; using ::boost::shared_ptr; #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) using ::boost::swap; #endif using ::boost::static_pointer_cast; using ::boost::dynamic_pointer_cast; using ::boost::const_pointer_cast; using ::boost::get_deleter; using ::boost::weak_ptr; using ::boost::enable_shared_from_this; } } #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #else # ifdef BOOST_HAS_INCLUDE_NEXT # include_next BOOST_TR1_HEADER(memory) # else # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(memory)) # endif #endif #endif
30.402778
88
0.728643
dstrigl
4754443389953f72ee2510aa4b3d97e499a1c220
1,768
cpp
C++
DS/queque_group.cpp
ParrySMS/Exp
78459e141308827b3e9a4ceb227808517d476a53
[ "Apache-2.0" ]
2
2019-05-09T16:35:21.000Z
2019-08-19T11:57:53.000Z
DS/queque_group.cpp
ParrySMS/Exp
78459e141308827b3e9a4ceb227808517d476a53
[ "Apache-2.0" ]
null
null
null
DS/queque_group.cpp
ParrySMS/Exp
78459e141308827b3e9a4ceb227808517d476a53
[ "Apache-2.0" ]
2
2019-03-29T05:31:55.000Z
2019-12-03T07:35:42.000Z
#include <queue> #include <map> #include <stack> #include <string> #include <math.h> #include <iostream> #include <iomanip> using namespace std; int main() { int i,t,n,value,data; int q_group_num,data_group_num; string op; map <int,int> group; map <int,int>::iterator it; // queue <int> q; queue <int> *qAr[10]; bool first = true; cin>>t; // cout<<"get t"<<endl; for(i=0; i<t; i++) { cin>>n; // cout<<"get n"<<endl; for(i=0; i<n; i++) { cin>>value; group.insert(pair<int,int>(value,t)); // cout<<"group.insert"<<endl; } } //init for(i=0; i<t; i++) { // cout<<"init"<<endl; qAr[i] = new queue <int> ; // cout<<"qAr["<<i<<"]"<<"--size:"<<qAr[i]->size()<<endl; } while(1) { cin>>op; if(op.compare("STOP") == 0) { //clear // cout<<"clean"<<endl; for(i=0; i<t; i++) { while(!qAr[i]->empty()) { // cout<<"pop"<<endl; qAr[i]->pop(); } } break; } if(op.compare("ENQUEUE") == 0) { // cout<<"get--ENQUEUE"<<endl; cin>>data; for(i=0; i<t; i++) { if(qAr[i]->empty()) { qAr[i]->push(data); // cout<<"push first"<<endl; break; } else { //check same group // cout<<"check same group"<<endl; q_group_num = group[qAr[i]->front()]; data_group_num = group[data]; if(q_group_num == data_group_num) { qAr[i]->push(data); // cout<<"push same"<<" num:"<<q_group_num<<endl; break; } // cout<<"not same group"<<endl; } } } if(op.compare("DEQUEUE") == 0) { if(first) { cout<<qAr[0]->front(); first = false; qAr[0]->pop(); } else { for(i=0; i<t; i++) { if(!qAr[i]->empty()) { cout<<" "<<qAr[i]->front(); qAr[i]->pop(); break; } } } } } return 0; }
15.508772
58
0.495475
ParrySMS
47586f654e83ab9a91981eb0969bb8038c9b2d97
1,589
cpp
C++
HALLibTest/RegisterTest/SCTest.cpp
GerdHirsch/HALLib
dd14ef56cb8dfe98c296ddf2f49412fdd7a3fb4c
[ "MIT" ]
1
2021-01-22T19:16:41.000Z
2021-01-22T19:16:41.000Z
HALLibTest/RegisterTest/SCTest.cpp
GerdHirsch/HALLib
dd14ef56cb8dfe98c296ddf2f49412fdd7a3fb4c
[ "MIT" ]
null
null
null
HALLibTest/RegisterTest/SCTest.cpp
GerdHirsch/HALLib
dd14ef56cb8dfe98c296ddf2f49412fdd7a3fb4c
[ "MIT" ]
null
null
null
/* * SCTest.cpp * * Created on: 05.01.2014 * Author: Gerd */ #include <RegisterTest/SCTest.h> namespace Mock { // SystemControl Mock Register // External Interrupts (EXT) SCTest::ExpectedType EXTINT_; SCTest::ExpectedType EXTWAKE_; SCTest::ExpectedType EXTMODE_; SCTest::ExpectedType EXTPOLAR_; // Memory Accelerator Module (MAM) (MEM?? siehe Doku) SCTest::ExpectedType MAMCR_; SCTest::ExpectedType MAMTIM_; SCTest::ExpectedType MAMMAP_; // VPB Divider (APB Divider?? Doku) SCTest::ExpectedType VPBDIV_; // Reset SCTest::ExpectedType RSIR_; // Code Security/Debugging SCTest::ExpectedType CSPR_; // System Controls and Status SCTest::ExpectedType SCS_; } // namespace Mock void SCTest::test(){ CPPUNIT_ASSERT_MESSAGE("Todo: SystemControl testen", false); } void SCTest::pClk_CClkTest(){ Mock::VPBDIV_ = 0; ExpectedType expectedCCLK = 14745600; ExpectedType expectedPCLK = 3686400; CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::CCLK()", expectedCCLK, SC::CCLK()); CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::PCLK()", expectedPCLK, SC::PCLK()); Mock::VPBDIV_ = Bit0; expectedCCLK = 14745600; expectedPCLK = 14745600; CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::CCLK()", expectedCCLK, SC::CCLK()); CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::PCLK()", expectedPCLK, SC::PCLK()); Mock::VPBDIV_ = Bit1; expectedCCLK = 14745600; expectedPCLK = 7372800; CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::CCLK()", expectedCCLK, SC::CCLK()); CPPUNIT_ASSERT_EQUAL_MESSAGE("SC::PCLK()", expectedPCLK, SC::PCLK()); }
22.380282
62
0.69163
GerdHirsch
e6e0db2e37717cc09beea7d57777c6a437ef14e3
2,296
hpp
C++
source/LibFgBase/src/FgGuiApiDialogs.hpp
maamountki/FaceGenBaseLibrary
0c647920e913354028ed09fff3293555e84d2b94
[ "MIT" ]
null
null
null
source/LibFgBase/src/FgGuiApiDialogs.hpp
maamountki/FaceGenBaseLibrary
0c647920e913354028ed09fff3293555e84d2b94
[ "MIT" ]
null
null
null
source/LibFgBase/src/FgGuiApiDialogs.hpp
maamountki/FaceGenBaseLibrary
0c647920e913354028ed09fff3293555e84d2b94
[ "MIT" ]
null
null
null
// // Copyright (c) 2015 Singular Inversions Inc. (facegen.com) // Use, modification and distribution is subject to the MIT License, // see accompanying file LICENSE.txt or facegen.com/base_library_license.txt // // Authors: Andrew Beatty // Created: Sept. 20, 2011 // #ifndef FGGUIAPIDIALOGS_HPP #define FGGUIAPIDIALOGS_HPP #include "FgGuiApiBase.hpp" #include "FgGuiApiButton.hpp" void fgGuiDialogMessage( const FgString & caption, const FgString & message); // NB Windows: // * Will sometimes return UNC path (eg. Windows Server) for network drive, rather than LFS drive letter. // * Although only extension-matching files are shown, users can (and will) type in filenames with non-matching // which dialog will then accept. FgOpt<FgString> fgGuiDialogFileLoad( const FgString & description, const FgStrs & extensions, const string & storeID=string()); // Remember different directories for same 'description' FgGuiPtr fgGuiFileLoadButton( const FgString & buttonText, const FgString & fileTypesDescription, const FgStrs & extensions, const string & storeID, FgDgn<FgString> output); // The extension should be chosen in the GUI before calling this function. // Windows will allow the user to enter a different extension of 3 characters, but extensions of different // character length (or no extension) will have the given extension appended: FgOpt<FgString> fgGuiDialogFileSave( const FgString & description, const std::string & extension); FgOpt<FgString> fgGuiDialogDirSelect(); // Arguments: true - advance progress bar, false - do not // Return: true - user cancel, false - continue typedef std::function<bool(bool)> FgFnBool2Bool; typedef std::function<void(FgFnBool2Bool)> FgFnCallback2Void; // Returns false if the computation was cancelled by the user, true otherwise: bool fgGuiDialogProgress( const FgString & title, uint progressSteps, FgFnCallback2Void actionProgress); // Uses the embedded icon for the splash screen. // Call the returned function to terminate the splash screen: std::function<void(void)> fgGuiDialogSplashScreen(); #endif
33.275362
111
0.702526
maamountki
e6e177c560967fd9754d05cf2b6ba78987ef2421
169
hpp
C++
benchsuite/utils/rand.hpp
angelicadavila/UNIZAR_PHD
532a87467ceb49d3c3851bb23e26003bfc1888d3
[ "MIT" ]
null
null
null
benchsuite/utils/rand.hpp
angelicadavila/UNIZAR_PHD
532a87467ceb49d3c3851bb23e26003bfc1888d3
[ "MIT" ]
null
null
null
benchsuite/utils/rand.hpp
angelicadavila/UNIZAR_PHD
532a87467ceb49d3c3851bb23e26003bfc1888d3
[ "MIT" ]
null
null
null
#ifndef ENGINECL_UTILS_RAND_HPP #define ENGINECL_UTILS_RAND_HPP #include <cstdlib> float random(float rand_max, float rand_min); #endif /* ENGINECL_UTILS_RAND_HPP */
16.9
39
0.810651
angelicadavila
e6e989f28ce118aa5e060f12b0cf6b563888543f
3,913
cc
C++
lib/wabt/src/stream.cc
rekhadpr/demoazure1
394d777e507b171876734d871d50e47254636b9d
[ "MIT" ]
null
null
null
lib/wabt/src/stream.cc
rekhadpr/demoazure1
394d777e507b171876734d871d50e47254636b9d
[ "MIT" ]
null
null
null
lib/wabt/src/stream.cc
rekhadpr/demoazure1
394d777e507b171876734d871d50e47254636b9d
[ "MIT" ]
null
null
null
/* * Copyright 2016 WebAssembly Community Group participants * * 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 "stream.h" #include <cassert> #include <cctype> #define DUMP_OCTETS_PER_LINE 16 #define DUMP_OCTETS_PER_GROUP 2 namespace wabt { Stream::Stream(Writer* writer, Stream* log_stream) : writer_(writer), offset_(0), result_(Result::Ok), log_stream_(log_stream) {} void Stream::AddOffset(ssize_t delta) { offset_ += delta; } void Stream::WriteDataAt(size_t at, const void* src, size_t size, const char* desc, PrintChars print_chars) { if (WABT_FAILED(result_)) return; if (log_stream_) { log_stream_->WriteMemoryDump(src, size, at, nullptr, desc, print_chars); } result_ = writer_->WriteData(at, src, size); } void Stream::WriteData(const void* src, size_t size, const char* desc, PrintChars print_chars) { WriteDataAt(offset_, src, size, desc, print_chars); offset_ += size; } void Stream::MoveData(size_t dst_offset, size_t src_offset, size_t size) { if (WABT_FAILED(result_)) return; if (log_stream_) { log_stream_->Writef( "; move data: [%" PRIzx ", %" PRIzx ") -> [%" PRIzx ", %" PRIzx ")\n", src_offset, src_offset + size, dst_offset, dst_offset + size); } result_ = writer_->MoveData(dst_offset, src_offset, size); } void Stream::Writef(const char* format, ...) { WABT_SNPRINTF_ALLOCA(buffer, length, format); WriteData(buffer, length); } void Stream::WriteMemoryDump(const void* start, size_t size, size_t offset, const char* prefix, const char* desc, PrintChars print_chars) { const uint8_t* p = static_cast<const uint8_t*>(start); const uint8_t* end = p + size; while (p < end) { const uint8_t* line = p; const uint8_t* line_end = p + DUMP_OCTETS_PER_LINE; if (prefix) Writef("%s", prefix); Writef("%07" PRIzx ": ", reinterpret_cast<intptr_t>(p) - reinterpret_cast<intptr_t>(start) + offset); while (p < line_end) { for (int i = 0; i < DUMP_OCTETS_PER_GROUP; ++i, ++p) { if (p < end) { Writef("%02x", *p); } else { WriteChar(' '); WriteChar(' '); } } WriteChar(' '); } if (print_chars == PrintChars::Yes) { WriteChar(' '); p = line; for (int i = 0; i < DUMP_OCTETS_PER_LINE && p < end; ++i, ++p) WriteChar(isprint(*p) ? *p : '.'); } /* if there are multiple lines, only print the desc on the last one */ if (p >= end && desc) Writef(" ; %s", desc); WriteChar('\n'); } } MemoryStream::MemoryStream() : Stream(&writer_) {} FileStream::FileStream(const char* filename) : Stream(&writer_), writer_(filename) {} FileStream::FileStream(FILE* file) : Stream(&writer_), writer_(file) {} // static std::unique_ptr<FileStream> FileStream::CreateStdout() { return std::unique_ptr<FileStream>(new FileStream(stdout)); } // static std::unique_ptr<FileStream> FileStream::CreateStderr() { return std::unique_ptr<FileStream>(new FileStream(stderr)); } } // namespace wabt
29.201493
78
0.600307
rekhadpr
e6f88861aafd0b1cd9a3c559f0a16dbb44adbb67
1,410
hpp
C++
Lia/irange/numeric_range_iterator.hpp
Rapptz/Lia
9c4745457e4ab517bdedd58015bf370f07b7099f
[ "MIT" ]
2
2021-04-05T23:28:12.000Z
2021-11-08T11:52:34.000Z
Lia/irange/numeric_range_iterator.hpp
Rapptz/Lia
9c4745457e4ab517bdedd58015bf370f07b7099f
[ "MIT" ]
null
null
null
Lia/irange/numeric_range_iterator.hpp
Rapptz/Lia
9c4745457e4ab517bdedd58015bf370f07b7099f
[ "MIT" ]
1
2021-06-07T18:05:04.000Z
2021-06-07T18:05:04.000Z
#ifndef LIA_IRANGE_NUMERIC_RANGE_ITERATOR_HPP #define LIA_IRANGE_NUMERIC_RANGE_ITERATOR_HPP #include "../detail/iterator.hpp" namespace lia { template<typename T, bool Infinite = false> struct numeric_range_iterator : std::iterator<std::bidirectional_iterator_tag, T> { private: T current; std::ptrdiff_t step; public: template<typename U, bool B> friend struct numeric_range; numeric_range_iterator(): current(0), step(1) {} numeric_range_iterator(T t, std::ptrdiff_t s = 1): current(t), step(s) {} T operator*() const { return current; } const T* operator->() const { return &current; } auto operator++() -> decltype(*this) { current += step; return *this; } numeric_range_iterator operator++(int) { auto copy = *this; ++(*this); return copy; } auto operator--() -> decltype(*this) { current -= step; return *this; } numeric_range_iterator operator--(int) { auto copy = *this; --(*this); return copy; } bool operator!=(const numeric_range_iterator& other) const { return Infinite ? true : other.current != current; } bool operator==(const numeric_range_iterator& other) const { return Infinite ? false : other.current == current; } }; } // lia #endif // LIA_IRANGE_NUMERIC_RANGE_ITERATOR_HPP
23.898305
83
0.624113
Rapptz
fc052b381aa3e52e847c40850ba8e07e95918749
4,704
cpp
C++
scan_all/src/scan_all.cpp
npczs/scan_all
204f48527ae7e5722dde69b1c1d36f69b053c268
[ "MIT" ]
null
null
null
scan_all/src/scan_all.cpp
npczs/scan_all
204f48527ae7e5722dde69b1c1d36f69b053c268
[ "MIT" ]
null
null
null
scan_all/src/scan_all.cpp
npczs/scan_all
204f48527ae7e5722dde69b1c1d36f69b053c268
[ "MIT" ]
null
null
null
#include "ros/ros.h" #include "sensor_msgs/LaserScan.h" #include "sensor_msgs/PointCloud2.h" #include <laser_geometry/laser_geometry.h> #include <message_filters/subscriber.h> #include <message_filters/synchronizer.h> #include <message_filters/sync_policies/approximate_time.h> #include <message_filters/time_synchronizer.h> #include <tf/transform_listener.h> #include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/point_cloud.h> #include <pcl/console/parse.h> #include <pcl/point_types.h> #include <pcl_conversions/pcl_conversions.h> #include <pcl/common/transforms.h> // pcl::transformPointCloud 用到这个头文件 #include <pcl/visualization/pcl_visualizer.h> #include <Eigen/Eigen> #include <Eigen/Dense> #include <Eigen/Geometry> #include <Eigen/Eigenvalues> laser_geometry::LaserProjection projector_; sensor_msgs::PointCloud2 cloud; sensor_msgs::PointCloud2 cloud_2; sensor_msgs::PointCloud2 cloud_all; int statue=0; Eigen::Matrix4f transform_1; //Eigen::Matrix<float, 4, 4> matrix_44; // 定义一个旋转矩阵 (见 https://en.wikipedia.org/wiki/Rotation_matrix) float theta = 3.142; // 弧度角 //transform_1 (0,1) = -sin(theta); //transform_1 (1,0) = sin (theta); //transform_1 (1,1) = cos (theta); //(行, 列) // 在 X 轴上定义一个 2.5 米的平移. //transform_1(0,3) = -0.240; //transform_1(2,3) = -0.106; //Eigen::Affine3f transform= Eigen::Affine3f::Identity(); //Eigen::Affine3f transform_2; void callback(const sensor_msgs::LaserScan::ConstPtr& scan_msg,const sensor_msgs::LaserScan::ConstPtr& scan_2_msg) { transform_1 (0,0) = cos (theta); transform_1 (0,1) = -sin(theta); transform_1 (1,0) = sin (theta); transform_1 (1,1) = cos (theta); transform_1 (0,3) = -0.240; transform_1 (2,3) = -0.106; pcl::PointCloud<pcl::PointXYZI>::Ptr scan_pcl(new pcl::PointCloud<pcl::PointXYZI>()); pcl::PointCloud<pcl::PointXYZI>::Ptr scan_pcl_2(new pcl::PointCloud<pcl::PointXYZI>()); projector_.projectLaser(*scan_msg, cloud); pcl::fromROSMsg(cloud, *scan_pcl); //std::cout<<"transfrom done"<<std::endl; projector_.projectLaser(*scan_2_msg, cloud_2); pcl::fromROSMsg(cloud_2, *scan_pcl_2); //matrix_44 << cos (theta),-sin(theta),0,-0.240,sin (theta),cos (theta),0,0,0,0,1,-0.106,0,0,0,1; //transform.translation() << -0.240, 0.0, -0.106; //transform.rotate (Eigen::AngleAxisf (3.142, Eigen::Vector3f::UnitZ())); pcl::PointCloud<pcl::PointXYZI>::Ptr transformed_cloud (new pcl::PointCloud<pcl::PointXYZI> ()); pcl::transformPointCloud (*scan_pcl_2, *transformed_cloud, transform_1); /*for(std::size_t i = 0; i < transformed_cloud->size(); ++i) { transformed_cloud->points[i].intensity = 64; } for(std::size_t i = 0; i < scan_pcl->size(); ++i) { transformed_cloud->points[i].intensity = 128; }*/ pcl::PointCloud<pcl::PointXYZI>::Ptr scan_all_pcl(new pcl::PointCloud<pcl::PointXYZI>()); *scan_all_pcl = *scan_pcl+*transformed_cloud; pcl::toROSMsg(*scan_all_pcl, cloud_all); //point_cloud_publisher_.publish(cloud_all); //publishCloudI(&point_cloud_publisher_, *scan_all_pcl); statue=1; std::cout<<statue<<std::endl; } int main(int argc, char **argv) { ros::init(argc, argv, "scan_all"); ros::NodeHandle n_; //ros::Publisher scan_all_pub = n.advertise<sensor_msgs::LaserScan>("scan_all", 1000); /*ros::Rate loop_rate(10); ros::Subscriber sub = n.subscribe("scan", 1000, Callback); ros::Subscriber sub_2 = .subscribe("scan_2", 1000, Callback);*/ ros::Publisher point_cloud_publisher_; point_cloud_publisher_ = n_.advertise<sensor_msgs::PointCloud2> ("/cloud", 10000, false); message_filters::Subscriber<sensor_msgs::LaserScan> scan_sub(n_, "scan", 1); message_filters::Subscriber<sensor_msgs::LaserScan> scan_2_sub(n_, "scan_2_filtered", 1); typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::LaserScan, sensor_msgs::LaserScan> MySyncPolicy; message_filters::Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), scan_sub, scan_2_sub); //message_filters::TimeSynchronizer<sensor_msgs::LaserScan, sensor_msgs::LaserScan> sync(scan_sub, scan_2_sub, 10); //sync.registerCallback(boost::bind(&callback, _1, _2)); ros::Rate loop_rate(30); //SubscribeAndPublish SAPObject; while (ros::ok()) { sync.registerCallback(boost::bind(&callback, _1, _2)); std::cout<<"123"<<std::endl; point_cloud_publisher_.publish(cloud_all); ros::spinOnce(); loop_rate.sleep(); } //ros::spin(); return 0; }
35.908397
119
0.677721
npczs
fc05e6c9c1d178e2c5f2819343cf20256ec67c6a
1,353
cpp
C++
maliit-plugin-chinese/plugin/plugin.cpp
webOS-ports/ime-manager
e71b9c458e4aa9203991ba84eed7104306372ce3
[ "Apache-2.0" ]
2
2018-03-22T19:04:43.000Z
2019-05-06T05:21:10.000Z
maliit-plugin-chinese/plugin/plugin.cpp
webOS-ports/ime-manager
e71b9c458e4aa9203991ba84eed7104306372ce3
[ "Apache-2.0" ]
null
null
null
maliit-plugin-chinese/plugin/plugin.cpp
webOS-ports/ime-manager
e71b9c458e4aa9203991ba84eed7104306372ce3
[ "Apache-2.0" ]
3
2018-03-22T19:04:45.000Z
2022-01-18T15:46:29.000Z
// Copyright (c) 2017-2019 LG Electronics, 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. // // SPDX-License-Identifier: Apache-2.0 #include "plugin.h" #include "inputmethod.h" #include <QtPlugin> ChinesePlugin::ChinesePlugin() : m_inputMethod(0) { allowedStates << Maliit::Hardware << Maliit::OnScreen; } QString ChinesePlugin::name() const { return QString("ChinesePlugin"); } MAbstractInputMethod *ChinesePlugin::createInputMethod(MAbstractInputMethodHost *host) { if (!m_inputMethod) m_inputMethod = new ChineseInputMethod(host); return m_inputMethod; //return new ChineseInputMethod(host); } QSet<Maliit::HandlerState> ChinesePlugin::supportedStates() const { if (m_inputMethod && !m_inputMethod->hasEnabledLanguages()) return QSet<Maliit::HandlerState>(); return allowedStates; }
28.1875
86
0.733925
webOS-ports
fc08c3697a46579af3eb2b0681d83a5b8afbe79c
2,653
hpp
C++
src/tree/segment_tree.hpp
dushivani/stlmp
0db76e421cef34dc532612acb5f85293460896b5
[ "MIT" ]
null
null
null
src/tree/segment_tree.hpp
dushivani/stlmp
0db76e421cef34dc532612acb5f85293460896b5
[ "MIT" ]
null
null
null
src/tree/segment_tree.hpp
dushivani/stlmp
0db76e421cef34dc532612acb5f85293460896b5
[ "MIT" ]
null
null
null
#include <iostream> #include <math.h> class segment_tree{ private: int *st; int *ar; int len; int sz; //size of segment tree // function to get middle of a segment int _get_mid(int start, int end){ return start + (end - start) / 2; } // util function to contruct segment tree int _construct(int *v, int start, int end, int current){ // if there is 1 element in stray, store in current // node and return if(start == end){ st[current] = v[start]; return v[start]; } // for more elements, recur for left & right subtrees // store the sum for values in this node int mid = _get_mid(start, end); st[current] = _construct(v, start, mid, current*2 + 1) + _construct(v, mid + 1, end, current*2 + 2); return st[current]; } // utility to update a value in segment tree void _update_value(int start, int end, int i, int difference, int current){ if(i<start || i>end) return; st[current] = st[current] + difference; if(end != start){ int mid = _get_mid(start, end); _update_value(start, mid, i, difference, 2*current+1); _update_value(mid+1, end, i, difference, 2*current+2); } } int _get_sum(int start, int end, int q_start, int q_end, int current){ if(q_start <= start && q_end >= end) return st[current]; // outside range if(end < q_start || start > q_end) return 0; int mid = _get_mid(start, end); return _get_sum(start, mid, q_start, q_end, 2*current+1) + _get_sum(mid+1, end, q_start, q_end, 2*current+2); } public: segment_tree(int *v, int n){ ar = new int[n]; this->len = n; for(int i=0;i<n;i++) ar[i] = v[i]; // construct tree // height of tree this->sz = 0; int h = (int)ceil(log2(n)); int max_size = 2 * (int)pow(2, h) - 1; this->sz = max_size; // allocate memory st = new int[max_size]; _construct(v, 0, n-1, 0); } // update value in void update(int i, int new_val){ if(i<0 || i>this->len-1) return; int difference = new_val - ar[i]; ar[i] = new_val; // update segment tree _update_value(0, this->len-1, i, difference, 0); } //get sum of range int get_sum(int start, int end){ if(start < 0 || end > this->len-1 || start > end) return -1; return _get_sum(0, this->len-1, start, end, 0); } int get(int n){ return st[n]; } void print(){ cout << "Printing segment tree" << endl; int n = this->sz; for(int i=0;i<n;i++) cout << st[i] << " "; cout << endl; } };
27.635417
79
0.565398
dushivani
fc0ced4d04a54b48958607a0259283e3c6222c45
24,713
cc
C++
src/engines/nvlsm.cc
umn-cris/pmemkv
efc5ccb4203ec07a0dbe7a2364b4dc4c02eccdab
[ "BSD-3-Clause" ]
null
null
null
src/engines/nvlsm.cc
umn-cris/pmemkv
efc5ccb4203ec07a0dbe7a2364b4dc4c02eccdab
[ "BSD-3-Clause" ]
null
null
null
src/engines/nvlsm.cc
umn-cris/pmemkv
efc5ccb4203ec07a0dbe7a2364b4dc4c02eccdab
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <iostream> #include "nvlsm.h" #define DO_LOG 0 #define LOG(msg) if (DO_LOG) std::cout << "[nvlsm] " << msg << "\n" namespace pmemkv { namespace nvlsm { pool<LSM_Root> pmpool; size_t pmsize; /* #####################static functions for multiple threads ####################### */ /* persist: persist a mem_table to c0 * v_nvlsm: an instance of nvlsm * */ static void persist(void * v_nvlsm) { //cout << "persisting a mem_table!" << endl; NVLsm * nvlsm = (NVLsm *) v_nvlsm; // get the targeting meta_table[0] auto meta_table = &(nvlsm->meta_table[0]); // get the queue head from mem_table auto mem_table = nvlsm->mem_table; auto run = mem_table->pop_queue(); // allocate space from NVM and copy data from mem_table persistent_ptr<PRun> p_run; int i = 0; //cout << "allocating new run" << endl; make_persistent_atomic<PRun>(pmpool, p_run); auto key_entry = p_run->key_entry; auto vals = p_run->vals; for (auto it = run->kv.begin(); it != run->kv.end(); it++) { strncpy(key_entry[i].key, it->first.c_str(), KEY_SIZE); strncpy(&vals[i * VAL_SIZE], it->second.c_str(), it->second.size()); key_entry[i].val_len = it->second.size(); key_entry[i].p_val = &vals[i * VAL_SIZE]; i++; } p_run->size = i; // add meta data to component 0 p_run.persist(); meta_table->add(p_run); delete run; if (meta_table->ranges.size() > nvlsm->com_ratio) nvlsm->compact(0); //nvlsm->compact(p_run, 0); //nvlsm->displayMeta(); //cout << "C0 has "; //meta_table->display(); //cout << endl; //cout << "persist stop" << endl; } /* ######################## Log #########################################*/ void Log::append(string str) { strncpy(ops, str.c_str(), str.size()); return; } /* ######################### CompactionUnit ############################# */ CompactionUnit::CompactionUnit(){} CompactionUnit::~CompactionUnit(){ //delete old data if (low_runs.size() == 0) return; delete_persistent_atomic<PRun>(up_run); for(int i = 0; i < low_runs.size(); i++) { delete_persistent_atomic<PRun>(low_runs[i]); } } void CompactionUnit::display() { string start_key; string end_key; KVRange range; up_run->get_range(range); cout << "up run: "; range.display(); cout << endl; cout << "low runs: "; for (auto low_run : low_runs) { low_run->get_range(range); range.display(); } cout << endl; cout << "new runs: "; for (auto new_run : new_runs) { new_run->get_range(range); range.display(); } cout << endl; return; } /* ######################## Implementations for NVLsm #################### */ NVLsm::NVLsm(const string& path, const size_t size) { run_size = RUN_SIZE; layer_depth = LAYER_DEPTH; com_ratio = COM_RATIO; // Create/Open pmem pool if (access(path.c_str(), F_OK) != 0) { LOG("Creating filesystem pool, path=" << path << ", size=" << to_string(size)); pmpool = pool<LSM_Root>::create(path.c_str(), LAYOUT, size, S_IRWXU); pmsize = size; } else { LOG("Opening filesystem pool, path=" << path); pmpool = pool<LSM_Root>::open(path.c_str(), LAYOUT); struct stat st; stat(path.c_str(), &st); pmsize = (size_t) st.st_size; } LOG("Create/open pool done"); // create the thread pool for pesisting mem_tables persist_pool = new ThreadPool(PERSIST_POOL_SIZE); if (persist_pool->initialize_threadpool() == -1) { cout << "Fail to initialize the thread pool!" << endl; exit(-1); } // create a mem_table mem_table = new MemTable(run_size); // reserve space for the meta_table of first components meta_table.emplace_back(); make_persistent_atomic<Log>(pmpool, meta_log); // create the thread pool for compacting runs compact_pool = new ThreadPool(COMPACT_POOL_SIZE); if (compact_pool->initialize_threadpool() == -1) { cout << "Fail to initialize the thread pool!" << endl; exit(-1); } LOG("Opened ok"); } NVLsm::~NVLsm() { while (mem_table->getSize() > 0) usleep(500); displayMeta(); persist_pool->destroy_threadpool(); delete_persistent_atomic<Log>(meta_log); delete mem_table; delete persist_pool; LOG("Closing persistent pool"); pmpool.close(); LOG("Closed ok"); } KVStatus NVLsm::Get(const int32_t limit, const int32_t keybytes, int32_t* valuebytes, const char* key, char* value) { LOG("Get for key=" << key); return NOT_FOUND; } KVStatus NVLsm::Get(const string& key, string* value) { LOG("Get for key=" << key.c_str()); //cout << "start to get key: " << key << endl; string val; LOG("Searching in memory buffer"); if (mem_table->search(key, val)) { value = new string(val); return OK; } for (int i = 0; i < meta_table.size(); i++) { //cout << "total " << meta_table.size() << " component"; //cout << ": searchng in compoent " << i << endl; if (i == 0) { if (meta_table[i].seq_search(key, val)) { value->append(val); //cout << "get success" << endl; return OK; } } else { if (meta_table[i].search(key, val)) { //cout << "get success" << endl; value->append(val); return OK; } } } //cout << key << " not found" << endl; return NOT_FOUND; } KVStatus NVLsm::Put(const string& key, const string& value) { LOG("Put key=" << key.c_str() << ", value.size=" << to_string(value.size())); //cout << "Put key=" << key.c_str() << ", value.size=" << to_string(value.size()) << endl;; if (mem_table->append(key, value)) { /* write buffer is filled up if queue size is larger than 4, wait */ while (mem_table->getSize() > com_ratio); mem_table->push_queue(); //cout << "memTable: " << mem_table->getSize() << endl; Task * persist_task = new Task(&persist, (void *) this); persist_pool->add_task(persist_task); //cout << "started a persist thread " << endl; } return OK; } KVStatus NVLsm::Remove(const string& key) { LOG("Remove key=" << key.c_str()); //cout << "Remove key=" << key.c_str() << endl;; return OK; } /* plan a compaction */ CompactionUnit * NVLsm::plan_compaction(size_t index) { CompactionUnit * unit = new CompactionUnit(); unit->index = index; unit->up_run = meta_table[index].getCompact(); if (meta_table.size() > index && meta_table[index + 1].getSize() > 0) { KVRange range; unit->up_run->get_range(range); meta_table[index + 1].search(range, unit->low_runs); } return unit; } void NVLsm::compact(int comp_index) { LOG("start compaction "); int comp_count = meta_table.size(); int current_size = meta_table[comp_index].getSize(); int max_size = 0; if (comp_index == 0 || comp_index == 1) max_size = com_ratio; else max_size = (int) pow(com_ratio, comp_index); if (current_size > max_size) { LOG("plan a compaction for the component" << comp_index); if (comp_count == comp_index + 1) { meta_table.emplace_back(); } auto unit = plan_compaction(comp_index); /* merge sort the runs */ merge_sort(unit); /* delete the old meta data */ //LOG("deleting old meta data"); //meta_log->append("delete old meta data"); //meta_log.persist(); if (!(meta_table[comp_index].del(unit->up_run))) { cout << "delete meta " << comp_index << " error! " << endl; unit->display(); exit(1); } if (!(meta_table[comp_index + 1].del(unit->low_runs))) { cout << "delete meta in C " << comp_index + 1 << " error! " << endl; unit->display(); exit(1); } //LOG("adding new meta data"); //meta_log->append("add new metadata"); //meta_log.persist(); if (!(meta_table[comp_index + 1].add(unit->new_runs))) { cout << "add meta in C " << comp_index + 1 << " error! " << endl; unit->display(); exit(1); } //meta_log->append("commit compaction"); //meta_log.persist(); //LOG("deleting old data"); delete unit; compact(comp_index + 1); } LOG("stop compactiom"); } void NVLsm::compact(persistent_ptr<PRun> run, int index) { LOG("start compaction "); CompactionUnit* unit = new CompactionUnit(); unit->up_run = run; KVRange kvRange; run->get_range(kvRange); meta_table[index].search(kvRange, unit->low_runs); /* merge sort the runs */ merge_sort(unit); /* delete the old meta data */ LOG("deleting old meta data"); meta_log->append("delete old meta data"); meta_log.persist(); meta_table[index].del(unit->low_runs); meta_log->append("add new metadata"); meta_log.persist(); if (!(meta_table[index].add(unit->new_runs))) { cout << "add meta in C " << index << " error! " << endl; unit->display(); exit(1); } meta_log->append("commit compaction"); meta_log.persist(); LOG("deleting old data"); delete unit; LOG("stop compactiom"); } /* copy data between PRuns */ void NVLsm::copy_kv(persistent_ptr<PRun> des_run, int des_i, persistent_ptr<PRun> src_run, int src_i) { auto des_entry = des_run->key_entry; auto des_vals = des_run->vals; auto src_entry = src_run->key_entry; auto src_vals = src_run->vals; strncpy(des_entry[des_i].key, src_entry[src_i].key, KEY_SIZE); strncpy(&des_vals[des_i * VAL_SIZE], &src_vals[src_i * VAL_SIZE], src_entry[src_i].val_len); des_entry[des_i].val_len = src_entry[src_i].val_len; des_entry[des_i].p_val = &des_vals[des_i * VAL_SIZE]; return; } /* merge_sort: merge sort the runs during a compaction */ void NVLsm::merge_sort(CompactionUnit * unit) { auto meta_up = &(meta_table[unit->index]); auto meta_low = &(meta_table[unit->index + 1]); /* acquire two locks follow the strick order to avoid deadlock */ pthread_rwlock_rdlock(&(meta_up->rwlock)); pthread_rwlock_rdlock(&(meta_low->rwlock)); //cout << "unit before compaction" << endl; //unit->display(); auto up_run = unit->up_run; auto low_runs = unit->low_runs; /* if no runs from lower component */ if (low_runs.empty()) { unit->new_runs.push_back(up_run); //cout << "unit after compaction" << endl; //unit->display(); pthread_rwlock_unlock(&(meta_up->rwlock)); pthread_rwlock_unlock(&(meta_low->rwlock)); return; } //cout << "merging step1" << endl; unit->new_runs.emplace_back(); make_persistent_atomic<PRun>(pmpool, unit->new_runs.back()); auto new_run = unit->new_runs.back(); int new_index = 0; int up_index = 0; int up_len = up_run->size; for (auto low_run : low_runs) { int low_index = 0; int low_len = low_run->size; //cout << "merging step1.5" << endl; while (low_index < low_len) { if (up_index < up_len) { /* if up run has kv pairs */ auto up_key = up_run->key_entry[up_index].key; auto low_key = low_run->key_entry[low_index].key; auto res = strncmp(up_key, low_key, KEY_SIZE); if (res <= 0) { /* up key is smaller */ copy_kv(new_run, new_index, up_run, up_index); up_index++; if (res == 0) low_index++; } else { /* low key is smaller */ copy_kv(new_run, new_index, low_run, low_index); low_index++; } } else { /* if up key has no kv pairs */ copy_kv(new_run, new_index, low_run, low_index); low_index++; } new_index++; if (new_index == RUN_SIZE) { new_run->size = RUN_SIZE; unit->new_runs.emplace_back(); make_persistent_atomic<PRun>(pmpool, unit->new_runs.back()); new_run = unit->new_runs.back(); new_index = 0; } } } //cout << "merging step2" << endl; /* run out of low but up remains */ while (up_index < up_len) { copy_kv(new_run, new_index, up_run, up_index); up_index++; new_index++; if (new_index == RUN_SIZE) { new_run->size = RUN_SIZE; unit->new_runs.emplace_back(); make_persistent_atomic<PRun>(pmpool, unit->new_runs.back()); new_run = unit->new_runs.back(); new_index = 0; } } /* run out of both up and low but new is not filled up */ if (new_index > 0 && new_index < RUN_SIZE) { new_run->size = new_index; } else if (new_index == 0) { delete_persistent_atomic<PRun>(unit->new_runs.back()); unit->new_runs.pop_back(); } //cout << "unit after compaction" << endl; //unit->display(); pthread_rwlock_unlock(&(meta_up->rwlock)); pthread_rwlock_unlock(&(meta_low->rwlock)); return; } /* display the meta tables */ void NVLsm::displayMeta() { cout << "=========== start displaying meta table ======" << endl; int index = 0; for (auto component : meta_table) { cout << " ***component " << index++ << ": "; component.display(); } cout << "=========== end displaying meta table ========" << endl; } /* ############## MemTable #################*/ MemTable::MemTable(int size) : buf_size(size) { buffer = new Run(); make_persistent_atomic<Log>(pmpool, kvlog); pthread_rwlock_init(&rwlock, NULL); } MemTable::~MemTable() { pthread_rwlock_destroy(&rwlock); delete_persistent_atomic<Log>(kvlog); delete buffer; } /* getSize: return the queue size * */ size_t MemTable::getSize() { return persist_queue.size(); } /* push_que: push the write buffer to the persist queue * and allocate a new buffer * */ void MemTable::push_queue() { persist_queue.push(buffer); //cout << "persist queue size: " << persist_queue.size() << endl; buffer = new Run(); return; } /* pop_que: pop an element from the queue head */ Run * MemTable::pop_queue() { auto head = persist_queue.front(); persist_queue.pop(); return head; } /* append kv pair to write buffer * return: true - the write buffer is filled up * false - the write buffer still has space * */ bool MemTable::append(const string & key, const string &val) { buffer->append(key, val); kvlog->append(key + val); kvlog.persist(); if (buffer->size >= RUN_SIZE) { return true; } return false; } /* search a key in the memory buffer */ bool MemTable::search(const string &key, string &val) { pthread_rwlock_rdlock(&rwlock); auto it = buffer->kv.find(key); if (it != buffer->kv.end()) { val = it->second; pthread_rwlock_unlock(&rwlock); return true; } pthread_rwlock_unlock(&rwlock); return false; } /* ################### MetaTable ##################################### */ MetaTable::MetaTable() : next_compact(0) { pthread_rwlock_init(&rwlock, NULL); } MetaTable::~MetaTable() { pthread_rwlock_destroy(&rwlock); } /* getSize: get the size of ranges */ size_t MetaTable::getSize() { return ranges.size(); } /* display: show the current elements */ void MetaTable::display() { cout << ranges.size() << endl; for (auto it : ranges) { auto meta_range = it.first; meta_range.display(); cout << "(" << it.second->size << ") "; KVRange range; it.second->get_range(range); if (!(meta_range == range)) { cout << "kvrange inconsistent! " << endl; cout << "kvrange in meta table: "; meta_range.display(); cout << endl; cout << "kvrange in run: "; range.display(); exit(1); } } cout << endl; return; } /* add: add new runs into meta_table */ bool MetaTable::add(vector<persistent_ptr<PRun>> runs) { pthread_rwlock_wrlock(&rwlock); if (runs.size() == 0) { pthread_rwlock_unlock(&rwlock); return true; } for (auto it : runs) { KVRange kvrange; it->get_range(kvrange); ranges[kvrange] = it; } pthread_rwlock_unlock(&rwlock); return true; } void MetaTable::add(persistent_ptr<PRun> run) { pthread_rwlock_wrlock(&rwlock); KVRange kvrange; run->get_range(kvrange); ranges[kvrange] = run; pthread_rwlock_unlock(&rwlock); return; } /* delete run/runs from the metadata */ bool MetaTable::del(persistent_ptr<PRun> run) { pthread_rwlock_wrlock(&rwlock); int count = 0; KVRange kvrange; run->get_range(kvrange); count += ranges.erase(kvrange); if (count != 1) { cout << "erase " << count << " out of 1" << endl; cout << "deleting range failed: "; kvrange.display(); pthread_rwlock_unlock(&rwlock); return false; } pthread_rwlock_unlock(&rwlock); return true; } bool MetaTable::del(vector<persistent_ptr<PRun>> runs) { pthread_rwlock_wrlock(&rwlock); int count = 0; for (auto run : runs) { KVRange kvrange; run->get_range(kvrange); if (ranges.erase(kvrange) != 1) { cout << "deleting range failed: "; kvrange.display(); } else { count++; } } if (count != runs.size()) { cout << "erase " << count << " out of " << runs.size() << endl; pthread_rwlock_unlock(&rwlock); return false; } pthread_rwlock_unlock(&rwlock); return true; } /* get a run for compaction */ persistent_ptr<PRun> MetaTable::getCompact() { auto it = ranges.begin(); advance(it, next_compact); auto run = it->second; next_compact++; if (next_compact == ranges.size()) next_compact = 0; return run; } /* search: get all run within a kv range and store them in runs */ void MetaTable::search(KVRange &kvrange, vector<persistent_ptr<PRun>> &runs) { //cout << "range size1: " << ranges.size() << endl; if (ranges.empty() || ranges.size() == 0) return; // binary search for component i > 1 KVRange end_range(kvrange.end_key, kvrange.end_key); //cout << "kvrange:" << kvrange.start_key << "," << kvrange.end_key << endl; //cout << "range size2: " << ranges.size() << endl; auto it_high = ranges.upper_bound(end_range); while (it_high == ranges.end() || kvrange.start_key <= it_high->first.end_key) { if (it_high == ranges.end()) { it_high--; continue; } if (kvrange.end_key >= it_high->first.start_key) runs.push_back(it_high->second); if (it_high == ranges.begin()) break; it_high--; } //cout << "search done, low_run " << runs.size() << endl; if (runs.size() > 0) reverse(runs.begin(), runs.end()); return; } /* search for a key in a component > 0 */ bool MetaTable::search(const string &key, string &val) { KVRange range(key, key); vector<persistent_ptr<PRun>> runs; pthread_rwlock_rdlock(&rwlock); search(range, runs); for (auto run : runs) { int start = 0; int end = run->size - 1; auto key_entry = run->key_entry; while (start <= end) { int mid = start + (end - start) / 2; int res = strncmp(key.c_str(), key_entry[mid].key, KEY_SIZE); if (res == 0) { val.assign(run->key_entry[mid].p_val, run->key_entry[mid].val_len); pthread_rwlock_unlock(&rwlock); return true; } else if (res < 0) { end = mid - 1; } else { start = mid + 1; } } } pthread_rwlock_unlock(&rwlock); return false; } /* search a key in component 0*/ bool MetaTable::seq_search(const string &key, string &val) { //cout << "acquiring the lock" << endl; pthread_rwlock_rdlock(&rwlock); //cout << "get the lock" << endl; for (auto range : ranges) { auto run = range.second; if (key > range.first.end_key || key < range.first.start_key) continue; int start = 0; int end = run->size - 1; auto key_entry = run->key_entry; while (start <= end) { int mid = start + (end - start) / 2; int res = strncmp(key.c_str(), key_entry[mid].key, KEY_SIZE); if (res == 0) { val.assign(&run->vals[mid], VAL_SIZE); pthread_rwlock_unlock(&rwlock); return true; } else if (res < 0) { end = mid - 1; } else { start = mid + 1; } } } pthread_rwlock_unlock(&rwlock); return false; } /* ###################### PRun ######################### */ PRun::PRun() { //make_persistent_atomic<KeyEntry[RUN_SIZE]>(pmpool, key_entry); //make_persistent_atomic<char[VAL_SIZE * RUN_SIZE]>(pmpool, vals); } PRun::~PRun() { //delete_persistent_atomic<KeyEntry[RUN_SIZE]>(key_entry); //delete_persistent_atomic<char[VAL_SIZE * RUN_SIZE]>(vals); } /* get kvrange for the current run */ void PRun::get_range(KVRange& range) { range.start_key.assign(key_entry[0].key, KEY_SIZE); range.end_key.assign(key_entry[size - 1].key, KEY_SIZE); return; } /* #################### Implementations of Run ############################### */ Run::Run() : size(0) { pthread_rwlock_init(&rwlock, NULL); } Run::~Run() { pthread_rwlock_destroy(&rwlock); } /* search: binary search kv pairs in a run */ bool Run::search(string &req_key, string &req_val) { pthread_rwlock_rdlock(&rwlock); auto it = kv.find(req_key); if (it != kv.end()) { req_val = it->second; pthread_rwlock_unlock(&rwlock); return true; } pthread_rwlock_unlock(&rwlock); return false; } /* append: append a kv pair to run * this will only be called for write buffer * */ void Run::append(const string &key, const string &val) { pthread_rwlock_wrlock(&rwlock); // put kv_pair into buffer auto it = kv.find(key); if (it == kv.end()) { size++; } kv[key] = val; // update range of buffer if (range.start_key.empty() || range.start_key > key) range.start_key.assign(key); if (range.end_key.empty() || range.end_key < key) range.end_key.assign(key); pthread_rwlock_unlock(&rwlock); } } // namespace nvlsm } // namespace pmemkv
32.559947
103
0.575527
umn-cris
fc11743da33fab8de0895a935551bbb67e59477a
49,186
cpp
C++
emp-tool/circuits/float32_add.cpp
wangxiao1254/emp-tool
d7caa06980ef8c48c429d59646775fa6de48b952
[ "MIT" ]
131
2017-03-08T12:08:56.000Z
2022-03-31T14:05:36.000Z
emp-tool/circuits/float32_add.cpp
MohammadHashemi-ai/emp-tool
44b1ddef7bf6bb8eefeede89f27084a96d1d349c
[ "MIT" ]
106
2017-05-15T18:19:29.000Z
2022-03-31T22:43:23.000Z
emp-tool/circuits/float32_add.cpp
MohammadHashemi-ai/emp-tool
44b1ddef7bf6bb8eefeede89f27084a96d1d349c
[ "MIT" ]
91
2016-10-27T11:40:46.000Z
2022-03-31T14:05:40.000Z
#include "emp-tool/circuits/float32.h" using emp::Float; using emp::Bit; Float Float::operator+(const Float& rhs) const{ Float res(*this); Bit *B = new Bit[2520]; memcpy(B, value.data(), sizeof(block)*32); memcpy(B+32, rhs.value.data(), sizeof(block)*32); uint32_t gates[] = { 30, 0, 64, 2, 62, 64, 65, 0, 65, 0, 66, 2, 29, 0, 67, 2, 61, 67, 68, 0, 68, 0, 69, 2, 61, 0, 70, 2, 67, 0, 71, 2, 70, 71, 72, 0, 72, 0, 73, 2, 28, 0, 74, 2, 73, 74, 75, 0, 60, 75, 76, 0, 76, 0, 77, 2, 69, 77, 78, 0, 78, 0, 79, 2, 62, 0, 80, 2, 30, 80, 81, 0, 81, 0, 82, 2, 79, 82, 83, 0, 83, 0, 84, 2, 66, 84, 85, 0, 25, 0, 86, 2, 57, 86, 87, 0, 87, 0, 88, 2, 57, 0, 89, 2, 86, 0, 90, 2, 89, 90, 91, 0, 91, 0, 92, 2, 24, 0, 93, 2, 92, 93, 94, 0, 94, 56, 95, 0, 95, 0, 96, 2, 88, 96, 97, 0, 97, 0, 98, 2, 58, 0, 99, 2, 26, 99, 100, 0, 100, 0, 101, 2, 59, 0, 102, 2, 27, 102, 103, 0, 103, 0, 104, 2, 101, 104, 105, 0, 105, 0, 106, 2, 106, 0, 107, 2, 98, 107, 108, 0, 108, 0, 109, 2, 27, 0, 110, 2, 59, 110, 111, 0, 111, 0, 112, 2, 109, 112, 113, 0, 26, 0, 114, 2, 104, 114, 115, 0, 58, 115, 116, 0, 116, 0, 117, 2, 113, 117, 118, 0, 118, 0, 119, 2, 81, 0, 120, 2, 73, 120, 121, 0, 60, 0, 122, 2, 28, 122, 123, 0, 123, 0, 124, 2, 121, 124, 125, 0, 119, 125, 126, 0, 126, 0, 127, 2, 106, 0, 128, 2, 125, 128, 129, 0, 56, 0, 130, 2, 24, 130, 131, 0, 131, 0, 132, 2, 92, 132, 133, 0, 129, 133, 134, 0, 50, 0, 135, 2, 18, 135, 136, 0, 136, 0, 137, 2, 51, 0, 138, 2, 19, 138, 139, 0, 139, 0, 140, 2, 137, 140, 141, 0, 141, 0, 142, 2, 142, 0, 143, 2, 134, 143, 144, 0, 53, 0, 145, 2, 21, 145, 146, 0, 146, 0, 147, 2, 52, 0, 148, 2, 20, 148, 149, 0, 149, 0, 150, 2, 147, 150, 151, 0, 54, 0, 152, 2, 22, 152, 153, 0, 153, 0, 154, 2, 55, 0, 155, 2, 23, 155, 156, 0, 156, 0, 157, 2, 154, 157, 158, 0, 158, 0, 159, 2, 159, 0, 160, 2, 151, 160, 161, 0, 161, 0, 162, 2, 162, 0, 163, 2, 144, 163, 164, 0, 49, 0, 165, 2, 17, 165, 166, 0, 166, 0, 167, 2, 15, 0, 168, 2, 47, 168, 169, 0, 169, 0, 170, 2, 13, 0, 171, 2, 45, 171, 172, 0, 172, 0, 173, 2, 45, 0, 174, 2, 13, 174, 175, 0, 175, 0, 176, 2, 12, 0, 177, 2, 176, 177, 178, 0, 44, 178, 179, 0, 179, 0, 180, 2, 173, 180, 181, 0, 181, 0, 182, 2, 46, 0, 183, 2, 14, 183, 184, 0, 184, 0, 185, 2, 47, 0, 186, 2, 15, 186, 187, 0, 187, 0, 188, 2, 185, 188, 189, 0, 189, 0, 190, 2, 190, 0, 191, 2, 182, 191, 192, 0, 192, 0, 193, 2, 170, 193, 194, 0, 14, 0, 195, 2, 188, 195, 196, 0, 46, 196, 197, 0, 197, 0, 198, 2, 9, 0, 199, 2, 41, 199, 200, 0, 200, 0, 201, 2, 41, 0, 202, 2, 9, 202, 203, 0, 203, 0, 204, 2, 8, 0, 205, 2, 204, 205, 206, 0, 40, 206, 207, 0, 207, 0, 208, 2, 201, 208, 209, 0, 209, 0, 210, 2, 42, 0, 211, 2, 10, 211, 212, 0, 212, 0, 213, 2, 43, 0, 214, 2, 11, 214, 215, 0, 215, 0, 216, 2, 213, 216, 217, 0, 217, 0, 218, 2, 218, 0, 219, 2, 210, 219, 220, 0, 220, 0, 221, 2, 11, 0, 222, 2, 43, 222, 223, 0, 223, 0, 224, 2, 221, 224, 225, 0, 10, 0, 226, 2, 216, 226, 227, 0, 42, 227, 228, 0, 228, 0, 229, 2, 225, 229, 230, 0, 230, 0, 231, 2, 44, 0, 232, 2, 12, 232, 233, 0, 233, 0, 234, 2, 176, 234, 235, 0, 190, 0, 236, 2, 235, 236, 237, 0, 231, 237, 238, 0, 238, 0, 239, 2, 198, 239, 240, 0, 218, 0, 241, 2, 237, 241, 242, 0, 40, 0, 243, 2, 8, 243, 244, 0, 244, 0, 245, 2, 204, 245, 246, 0, 5, 0, 247, 2, 37, 247, 248, 0, 248, 0, 249, 2, 37, 0, 250, 2, 5, 250, 251, 0, 251, 0, 252, 2, 4, 0, 253, 2, 252, 253, 254, 0, 36, 254, 255, 0, 255, 0, 256, 2, 249, 256, 257, 0, 257, 0, 258, 2, 38, 0, 259, 2, 6, 259, 260, 0, 260, 0, 261, 2, 39, 0, 262, 2, 7, 262, 263, 0, 263, 0, 264, 2, 261, 264, 265, 0, 265, 0, 266, 2, 266, 0, 267, 2, 258, 267, 268, 0, 268, 0, 269, 2, 7, 0, 270, 2, 39, 270, 271, 0, 271, 0, 272, 2, 269, 272, 273, 0, 6, 0, 274, 2, 264, 274, 275, 0, 275, 38, 276, 0, 276, 0, 277, 2, 35, 0, 278, 2, 3, 0, 279, 2, 279, 0, 280, 2, 278, 280, 281, 0, 281, 0, 282, 2, 34, 0, 283, 2, 2, 283, 284, 0, 284, 0, 285, 2, 282, 285, 286, 0, 1, 0, 287, 2, 33, 287, 288, 0, 288, 0, 289, 2, 33, 0, 290, 2, 1, 290, 291, 0, 291, 0, 292, 2, 0, 0, 293, 2, 292, 293, 294, 0, 32, 294, 295, 0, 295, 0, 296, 2, 289, 296, 297, 0, 297, 0, 298, 2, 286, 298, 299, 0, 299, 0, 300, 2, 35, 279, 301, 0, 301, 0, 302, 2, 300, 302, 303, 0, 2, 0, 304, 2, 282, 304, 305, 0, 34, 305, 306, 0, 306, 0, 307, 2, 303, 307, 308, 0, 308, 0, 309, 2, 266, 0, 310, 2, 309, 310, 311, 0, 36, 0, 312, 2, 4, 312, 313, 0, 313, 0, 314, 2, 252, 314, 315, 0, 311, 315, 316, 0, 316, 0, 317, 2, 277, 317, 318, 0, 273, 318, 319, 0, 319, 0, 320, 2, 246, 320, 321, 0, 242, 321, 322, 0, 322, 0, 323, 2, 240, 323, 324, 0, 194, 324, 325, 0, 325, 0, 326, 2, 167, 326, 327, 0, 48, 0, 328, 2, 16, 328, 329, 0, 329, 0, 330, 2, 327, 330, 331, 0, 164, 331, 332, 0, 332, 0, 333, 2, 127, 333, 334, 0, 21, 0, 335, 2, 53, 335, 336, 0, 336, 0, 337, 2, 20, 0, 338, 2, 147, 338, 339, 0, 52, 339, 340, 0, 340, 0, 341, 2, 337, 341, 342, 0, 342, 0, 343, 2, 159, 0, 344, 2, 343, 344, 345, 0, 345, 0, 346, 2, 23, 0, 347, 2, 55, 347, 348, 0, 348, 0, 349, 2, 346, 349, 350, 0, 22, 0, 351, 2, 157, 351, 352, 0, 352, 54, 353, 0, 353, 0, 354, 2, 17, 0, 355, 2, 49, 355, 356, 0, 356, 0, 357, 2, 16, 0, 358, 2, 167, 358, 359, 0, 48, 359, 360, 0, 360, 0, 361, 2, 357, 361, 362, 0, 362, 0, 363, 2, 142, 0, 364, 2, 363, 364, 365, 0, 365, 0, 366, 2, 19, 0, 367, 2, 51, 367, 368, 0, 368, 0, 369, 2, 366, 369, 370, 0, 18, 0, 371, 2, 140, 371, 372, 0, 372, 50, 373, 0, 373, 0, 374, 2, 370, 374, 375, 0, 375, 0, 376, 2, 162, 0, 377, 2, 376, 377, 378, 0, 378, 0, 379, 2, 354, 379, 380, 0, 350, 380, 381, 0, 381, 0, 382, 2, 382, 134, 383, 0, 383, 0, 384, 2, 334, 384, 385, 0, 85, 385, 386, 0, 386, 0, 387, 2, 56, 24, 388, 1, 387, 388, 389, 0, 56, 389, 390, 1, 390, 0, 391, 2, 24, 56, 392, 1, 387, 392, 393, 0, 24, 393, 394, 1, 391, 394, 395, 1, 347, 155, 396, 1, 387, 396, 397, 0, 347, 397, 398, 1, 398, 0, 399, 2, 155, 347, 400, 1, 387, 400, 401, 0, 155, 401, 402, 1, 399, 402, 403, 1, 399, 402, 404, 0, 403, 404, 405, 1, 405, 395, 406, 1, 405, 394, 407, 1, 395, 407, 408, 0, 394, 408, 409, 1, 89, 86, 410, 1, 387, 410, 411, 0, 89, 411, 412, 1, 86, 89, 413, 1, 387, 413, 414, 0, 86, 414, 415, 1, 415, 0, 416, 2, 412, 416, 417, 1, 409, 417, 418, 1, 409, 416, 419, 1, 417, 419, 420, 0, 416, 420, 421, 1, 99, 114, 422, 1, 387, 422, 423, 0, 99, 423, 424, 1, 114, 99, 425, 1, 387, 425, 426, 0, 114, 426, 427, 1, 427, 0, 428, 2, 424, 428, 429, 1, 421, 429, 430, 1, 421, 428, 431, 1, 429, 431, 432, 0, 428, 432, 433, 1, 102, 110, 434, 1, 387, 434, 435, 0, 102, 435, 436, 1, 110, 102, 437, 1, 387, 437, 438, 0, 110, 438, 439, 1, 439, 0, 440, 2, 436, 440, 441, 1, 433, 441, 442, 1, 433, 440, 443, 1, 441, 443, 444, 0, 440, 444, 445, 1, 122, 74, 446, 1, 387, 446, 447, 0, 122, 447, 448, 1, 74, 122, 449, 1, 387, 449, 450, 0, 74, 450, 451, 1, 451, 0, 452, 2, 448, 452, 453, 1, 445, 453, 454, 1, 445, 452, 455, 1, 453, 455, 456, 0, 452, 456, 457, 1, 70, 67, 458, 1, 387, 458, 459, 0, 70, 459, 460, 1, 67, 70, 461, 1, 387, 461, 462, 0, 67, 462, 463, 1, 463, 0, 464, 2, 460, 464, 465, 1, 457, 465, 466, 1, 457, 464, 467, 1, 465, 467, 468, 0, 464, 468, 469, 1, 62, 0, 470, 2, 470, 64, 471, 1, 387, 471, 472, 0, 470, 472, 473, 1, 470, 64, 474, 0, 474, 0, 475, 2, 473, 475, 476, 1, 469, 476, 477, 1, 31, 63, 478, 1, 387, 478, 479, 0, 31, 479, 480, 1, 480, 63, 481, 1, 481, 0, 482, 2, 480, 31, 483, 1, 483, 0, 484, 2, 482, 484, 485, 0, 387, 0, 486, 2, 10, 42, 487, 1, 486, 487, 488, 0, 10, 488, 489, 1, 402, 399, 490, 1, 490, 0, 491, 2, 11, 43, 492, 1, 486, 492, 493, 0, 11, 493, 494, 1, 489, 494, 495, 1, 491, 495, 496, 0, 489, 496, 497, 1, 406, 0, 498, 2, 41, 9, 499, 1, 387, 499, 500, 0, 41, 500, 501, 1, 491, 0, 502, 2, 8, 40, 503, 1, 486, 503, 504, 0, 8, 504, 505, 1, 501, 505, 506, 1, 502, 506, 507, 0, 501, 507, 508, 1, 497, 508, 509, 1, 498, 509, 510, 0, 497, 510, 511, 1, 15, 47, 512, 1, 486, 512, 513, 0, 15, 513, 514, 1, 14, 46, 515, 1, 486, 515, 516, 0, 14, 516, 517, 1, 514, 517, 518, 1, 502, 518, 519, 0, 514, 519, 520, 1, 45, 13, 521, 1, 387, 521, 522, 0, 45, 522, 523, 1, 12, 44, 524, 1, 486, 524, 525, 0, 12, 525, 526, 1, 523, 526, 527, 1, 502, 527, 528, 0, 523, 528, 529, 1, 520, 529, 530, 1, 498, 530, 531, 0, 520, 531, 532, 1, 511, 532, 533, 1, 418, 533, 534, 0, 511, 534, 535, 1, 430, 0, 536, 2, 7, 39, 537, 1, 486, 537, 538, 0, 7, 538, 539, 1, 6, 38, 540, 1, 486, 540, 541, 0, 6, 541, 542, 1, 539, 542, 543, 1, 502, 543, 544, 0, 539, 544, 545, 1, 5, 37, 546, 1, 486, 546, 547, 0, 5, 547, 548, 1, 4, 36, 549, 1, 486, 549, 550, 0, 4, 550, 551, 1, 548, 551, 552, 1, 502, 552, 553, 0, 548, 553, 554, 1, 545, 554, 555, 1, 498, 555, 556, 0, 545, 556, 557, 1, 418, 0, 558, 2, 283, 304, 559, 1, 387, 559, 560, 0, 283, 560, 561, 1, 278, 279, 562, 1, 387, 562, 563, 0, 278, 563, 564, 1, 561, 564, 565, 1, 491, 565, 566, 0, 561, 566, 567, 1, 290, 287, 568, 1, 387, 568, 569, 0, 290, 569, 570, 1, 32, 0, 571, 1, 387, 571, 572, 0, 32, 572, 573, 1, 573, 0, 574, 2, 570, 574, 575, 1, 502, 575, 576, 0, 570, 576, 577, 1, 567, 577, 578, 1, 498, 578, 579, 0, 567, 579, 580, 1, 580, 0, 581, 2, 557, 581, 582, 1, 558, 582, 583, 0, 557, 583, 584, 1, 535, 584, 585, 1, 536, 585, 586, 0, 535, 586, 587, 1, 19, 51, 588, 1, 486, 588, 589, 0, 19, 589, 590, 1, 18, 50, 591, 1, 486, 591, 592, 0, 18, 592, 593, 1, 590, 593, 594, 1, 502, 594, 595, 0, 590, 595, 596, 1, 49, 17, 597, 1, 387, 597, 598, 0, 49, 598, 599, 1, 16, 48, 600, 1, 486, 600, 601, 0, 16, 601, 602, 1, 599, 602, 603, 1, 502, 603, 604, 0, 599, 604, 605, 1, 596, 605, 606, 1, 498, 606, 607, 0, 596, 607, 608, 1, 53, 21, 609, 1, 387, 609, 610, 0, 53, 610, 611, 1, 20, 52, 612, 1, 486, 612, 613, 0, 20, 613, 614, 1, 611, 614, 615, 1, 502, 615, 616, 0, 611, 616, 617, 1, 22, 54, 618, 1, 486, 618, 619, 0, 22, 619, 620, 1, 620, 491, 621, 1, 620, 491, 622, 0, 621, 622, 623, 1, 617, 623, 624, 1, 406, 624, 625, 0, 617, 625, 626, 1, 608, 626, 627, 1, 418, 627, 628, 0, 608, 628, 629, 1, 430, 0, 630, 2, 629, 630, 631, 0, 587, 631, 632, 1, 442, 632, 633, 0, 587, 633, 634, 1, 477, 466, 635, 1, 477, 466, 636, 0, 635, 636, 637, 1, 637, 0, 638, 2, 454, 0, 639, 2, 638, 639, 640, 0, 634, 640, 641, 0, 402, 424, 642, 0, 412, 448, 643, 0, 642, 643, 644, 0, 436, 473, 645, 0, 460, 391, 646, 0, 645, 646, 647, 0, 644, 647, 648, 0, 648, 0, 649, 2, 475, 440, 650, 0, 650, 394, 651, 0, 452, 464, 652, 0, 428, 416, 653, 0, 652, 653, 654, 0, 651, 654, 655, 0, 398, 0, 656, 2, 655, 656, 657, 0, 657, 0, 658, 2, 649, 658, 659, 0, 485, 0, 660, 2, 660, 0, 661, 2, 659, 661, 662, 0, 662, 0, 663, 2, 485, 663, 664, 1, 641, 664, 665, 0, 485, 665, 666, 1, 659, 485, 667, 1, 659, 485, 668, 0, 667, 668, 669, 1, 666, 669, 670, 0, 670, 0, 671, 2, 0, 32, 672, 1, 387, 672, 673, 0, 0, 673, 674, 1, 671, 674, 675, 1, 442, 0, 676, 2, 430, 0, 677, 2, 558, 677, 678, 0, 502, 0, 679, 2, 406, 679, 680, 0, 680, 0, 681, 2, 678, 681, 682, 0, 682, 0, 683, 2, 683, 0, 684, 2, 676, 684, 685, 0, 685, 0, 686, 2, 573, 686, 687, 0, 687, 0, 688, 2, 676, 498, 689, 0, 689, 0, 690, 2, 494, 690, 691, 0, 691, 0, 692, 2, 501, 0, 693, 2, 692, 693, 694, 0, 694, 0, 695, 2, 558, 676, 696, 0, 696, 0, 697, 2, 442, 430, 698, 1, 442, 430, 699, 0, 698, 699, 700, 1, 700, 0, 701, 2, 701, 0, 702, 2, 697, 702, 703, 0, 695, 703, 704, 0, 704, 0, 705, 2, 688, 705, 706, 0, 418, 0, 707, 2, 701, 707, 708, 0, 708, 0, 709, 2, 570, 0, 710, 2, 709, 710, 711, 0, 711, 0, 712, 2, 536, 681, 713, 0, 713, 0, 714, 2, 678, 0, 715, 2, 714, 715, 716, 0, 716, 0, 717, 2, 676, 717, 718, 0, 718, 0, 719, 2, 719, 551, 720, 0, 720, 0, 721, 2, 712, 721, 722, 0, 536, 498, 723, 0, 723, 0, 724, 2, 590, 724, 725, 0, 725, 0, 726, 2, 599, 0, 727, 2, 726, 727, 728, 0, 728, 0, 729, 2, 678, 0, 730, 2, 442, 730, 731, 0, 729, 731, 732, 0, 732, 0, 733, 2, 722, 733, 734, 0, 706, 734, 735, 0, 498, 558, 736, 0, 611, 0, 737, 2, 736, 737, 738, 0, 738, 0, 739, 2, 430, 739, 740, 0, 740, 0, 741, 2, 523, 0, 742, 2, 741, 742, 743, 0, 683, 602, 744, 0, 744, 0, 745, 2, 717, 0, 746, 2, 614, 746, 747, 0, 747, 0, 748, 2, 745, 748, 749, 0, 743, 749, 750, 0, 750, 0, 751, 2, 442, 751, 752, 0, 752, 0, 753, 2, 502, 498, 754, 0, 701, 754, 755, 0, 755, 0, 756, 2, 709, 756, 757, 0, 561, 0, 758, 2, 757, 758, 759, 0, 759, 0, 760, 2, 753, 760, 761, 0, 558, 689, 762, 0, 762, 0, 763, 2, 702, 763, 764, 0, 764, 0, 765, 2, 765, 0, 766, 2, 539, 766, 767, 0, 767, 0, 768, 2, 702, 548, 769, 0, 769, 0, 770, 2, 768, 770, 771, 0, 564, 0, 772, 2, 701, 498, 773, 0, 773, 0, 774, 2, 709, 774, 775, 0, 772, 775, 776, 0, 776, 0, 777, 2, 771, 777, 778, 0, 761, 778, 779, 0, 735, 779, 780, 0, 418, 491, 781, 1, 418, 491, 782, 0, 781, 782, 783, 1, 783, 0, 784, 2, 784, 689, 785, 0, 785, 0, 786, 2, 786, 702, 787, 0, 787, 542, 788, 0, 788, 0, 789, 2, 676, 784, 790, 0, 790, 0, 791, 2, 505, 791, 792, 0, 765, 0, 793, 2, 792, 793, 794, 0, 794, 0, 795, 2, 789, 795, 796, 0, 558, 723, 797, 0, 797, 0, 798, 2, 514, 798, 799, 0, 442, 799, 800, 0, 800, 0, 801, 2, 703, 526, 802, 0, 502, 676, 803, 0, 803, 0, 804, 2, 689, 0, 805, 2, 804, 805, 806, 0, 802, 806, 807, 0, 807, 0, 808, 2, 801, 808, 809, 0, 502, 689, 810, 0, 810, 0, 811, 2, 489, 811, 812, 0, 812, 703, 813, 0, 813, 0, 814, 2, 809, 814, 815, 0, 796, 815, 816, 0, 502, 723, 817, 0, 817, 0, 818, 2, 593, 818, 819, 0, 819, 731, 820, 0, 820, 0, 821, 2, 430, 442, 822, 0, 784, 0, 823, 2, 620, 823, 824, 0, 822, 824, 825, 0, 825, 0, 826, 2, 821, 826, 827, 0, 784, 723, 828, 0, 828, 0, 829, 2, 517, 829, 830, 0, 442, 830, 831, 0, 831, 0, 832, 2, 827, 832, 833, 0, 833, 640, 834, 0, 816, 834, 835, 0, 780, 835, 836, 0, 836, 0, 837, 2, 837, 659, 838, 0, 838, 0, 839, 2, 839, 485, 840, 1, 660, 840, 841, 0, 529, 497, 842, 1, 498, 842, 843, 0, 529, 843, 844, 1, 508, 545, 845, 1, 498, 845, 846, 0, 508, 846, 847, 1, 844, 847, 848, 1, 558, 848, 849, 0, 844, 849, 850, 1, 567, 0, 851, 2, 851, 554, 852, 1, 406, 852, 853, 0, 851, 853, 854, 1, 577, 0, 855, 2, 406, 855, 856, 0, 854, 856, 857, 1, 558, 857, 858, 0, 854, 858, 859, 1, 850, 859, 860, 1, 536, 860, 861, 0, 850, 861, 862, 1, 617, 596, 863, 1, 498, 863, 864, 0, 617, 864, 865, 1, 605, 520, 866, 1, 498, 866, 867, 0, 605, 867, 868, 1, 865, 868, 869, 1, 558, 869, 870, 0, 865, 870, 871, 1, 623, 498, 872, 0, 418, 0, 873, 2, 872, 873, 874, 0, 871, 874, 875, 1, 430, 875, 876, 0, 871, 876, 877, 1, 862, 877, 878, 1, 442, 878, 879, 0, 862, 879, 880, 1, 880, 640, 881, 0, 485, 663, 882, 1, 881, 882, 883, 0, 485, 883, 884, 1, 884, 669, 885, 0, 885, 0, 886, 2, 841, 886, 887, 0, 501, 489, 888, 1, 491, 888, 889, 0, 501, 889, 890, 1, 505, 539, 891, 1, 502, 891, 892, 0, 505, 892, 893, 1, 890, 893, 894, 1, 498, 894, 895, 0, 890, 895, 896, 1, 523, 517, 897, 1, 491, 897, 898, 0, 523, 898, 899, 1, 494, 526, 900, 1, 491, 900, 901, 0, 494, 901, 902, 1, 899, 902, 903, 1, 498, 903, 904, 0, 899, 904, 905, 1, 896, 905, 906, 1, 418, 906, 907, 0, 896, 907, 908, 1, 561, 570, 909, 1, 502, 909, 910, 0, 561, 910, 911, 1, 911, 0, 912, 2, 491, 573, 913, 0, 912, 913, 914, 1, 498, 914, 915, 0, 912, 915, 916, 1, 542, 548, 917, 1, 502, 917, 918, 0, 542, 918, 919, 1, 551, 772, 920, 1, 502, 920, 921, 0, 551, 921, 922, 1, 919, 922, 923, 1, 498, 923, 924, 0, 919, 924, 925, 1, 916, 925, 926, 1, 418, 926, 927, 0, 916, 927, 928, 1, 908, 928, 929, 1, 536, 929, 930, 0, 908, 930, 931, 1, 620, 611, 932, 1, 502, 932, 933, 0, 620, 933, 934, 1, 590, 614, 935, 1, 491, 935, 936, 0, 590, 936, 937, 1, 934, 937, 938, 1, 498, 938, 939, 0, 934, 939, 940, 1, 593, 599, 941, 1, 502, 941, 942, 0, 593, 942, 943, 1, 602, 514, 944, 1, 502, 944, 945, 0, 602, 945, 946, 1, 943, 946, 947, 1, 498, 947, 948, 0, 943, 948, 949, 1, 940, 949, 950, 1, 558, 950, 951, 0, 940, 951, 952, 1, 502, 498, 953, 0, 953, 0, 954, 2, 418, 954, 955, 1, 418, 954, 956, 0, 955, 956, 957, 1, 957, 0, 958, 2, 952, 958, 959, 1, 430, 959, 960, 0, 952, 960, 961, 1, 931, 961, 962, 1, 442, 962, 963, 0, 931, 963, 964, 1, 964, 640, 965, 0, 485, 663, 966, 1, 965, 966, 967, 0, 485, 967, 968, 1, 968, 669, 969, 0, 969, 0, 970, 2, 887, 970, 971, 0, 971, 675, 972, 1, 971, 674, 973, 1, 675, 973, 974, 0, 674, 974, 975, 1, 902, 890, 976, 1, 498, 976, 977, 0, 902, 977, 978, 1, 946, 899, 979, 1, 498, 979, 980, 0, 946, 980, 981, 1, 978, 981, 982, 1, 418, 982, 983, 0, 978, 983, 984, 1, 893, 919, 985, 1, 498, 985, 986, 0, 893, 986, 987, 1, 912, 922, 988, 1, 406, 988, 989, 0, 912, 989, 990, 1, 987, 990, 991, 1, 558, 991, 992, 0, 987, 992, 993, 1, 984, 993, 994, 1, 536, 994, 995, 0, 984, 995, 996, 1, 502, 934, 997, 1, 498, 997, 998, 0, 502, 998, 999, 1, 937, 943, 1000, 1, 498, 1000, 1001, 0, 937, 1001, 1002, 1, 999, 1002, 1003, 1, 558, 1003, 1004, 0, 999, 1004, 1005, 1, 430, 0, 1006, 2, 1005, 1006, 1007, 0, 996, 1007, 1008, 1, 442, 1008, 1009, 0, 996, 1009, 1010, 1, 1010, 640, 1011, 0, 485, 663, 1012, 1, 1011, 1012, 1013, 0, 485, 1013, 1014, 1, 1014, 669, 1015, 0, 1015, 0, 1016, 2, 33, 1, 1017, 1, 486, 1017, 1018, 0, 33, 1018, 1019, 1, 1016, 1019, 1020, 1, 975, 1020, 1021, 1, 975, 1019, 1022, 1, 1020, 1022, 1023, 0, 1019, 1023, 1024, 1, 844, 868, 1025, 1, 418, 1025, 1026, 0, 844, 1026, 1027, 1, 854, 847, 1028, 1, 418, 1028, 1029, 0, 854, 1029, 1030, 1, 1027, 1030, 1031, 1, 536, 1031, 1032, 0, 1027, 1032, 1033, 1, 865, 872, 1034, 1, 418, 1034, 1035, 0, 865, 1035, 1036, 1, 430, 0, 1037, 2, 1036, 1037, 1038, 0, 1033, 1038, 1039, 1, 442, 1039, 1040, 0, 1033, 1040, 1041, 1, 1041, 640, 1042, 0, 485, 663, 1043, 1, 1042, 1043, 1044, 0, 485, 1044, 1045, 1, 1045, 669, 1046, 0, 1046, 0, 1047, 2, 34, 2, 1048, 1, 486, 1048, 1049, 0, 34, 1049, 1050, 1, 1047, 1050, 1051, 1, 1024, 1051, 1052, 1, 1024, 1050, 1053, 1, 1051, 1053, 1054, 0, 1050, 1054, 1055, 1, 940, 0, 1056, 2, 954, 1056, 1057, 1, 558, 1057, 1058, 0, 954, 1058, 1059, 1, 1059, 430, 1060, 1, 1059, 430, 1061, 0, 1060, 1061, 1062, 1, 949, 905, 1063, 1, 558, 1063, 1064, 0, 949, 1064, 1065, 1, 925, 896, 1066, 1, 418, 1066, 1067, 0, 925, 1067, 1068, 1, 1065, 1068, 1069, 1, 536, 1069, 1070, 0, 1065, 1070, 1071, 1, 1071, 0, 1072, 2, 1062, 1072, 1073, 1, 676, 1073, 1074, 0, 1062, 1074, 1075, 1, 1075, 0, 1076, 2, 640, 1076, 1077, 0, 485, 663, 1078, 1, 1077, 1078, 1079, 0, 485, 1079, 1080, 1, 1080, 669, 1081, 0, 1081, 0, 1082, 2, 35, 3, 1083, 1, 486, 1083, 1084, 0, 35, 1084, 1085, 1, 1082, 1085, 1086, 1, 1055, 1086, 1087, 1, 1055, 1085, 1088, 1, 1086, 1088, 1089, 0, 1085, 1089, 1090, 1, 532, 608, 1091, 1, 418, 1091, 1092, 0, 532, 1092, 1093, 1, 557, 511, 1094, 1, 418, 1094, 1095, 0, 557, 1095, 1096, 1, 1093, 1096, 1097, 1, 536, 1097, 1098, 0, 1093, 1098, 1099, 1, 626, 558, 1100, 0, 430, 0, 1101, 2, 1100, 1101, 1102, 0, 1099, 1102, 1103, 1, 442, 1103, 1104, 0, 1099, 1104, 1105, 1, 1105, 640, 1106, 0, 485, 663, 1107, 1, 1106, 1107, 1108, 0, 485, 1108, 1109, 1, 1109, 669, 1110, 0, 1110, 0, 1111, 2, 36, 4, 1112, 1, 486, 1112, 1113, 0, 36, 1113, 1114, 1, 1111, 1114, 1115, 1, 1090, 1115, 1116, 1, 1090, 1114, 1117, 1, 1115, 1117, 1118, 0, 1114, 1118, 1119, 1, 981, 1002, 1120, 1, 418, 1120, 1121, 0, 981, 1121, 1122, 1, 987, 978, 1123, 1, 418, 1123, 1124, 0, 987, 1124, 1125, 1, 1122, 1125, 1126, 1, 536, 1126, 1127, 0, 1122, 1127, 1128, 1, 418, 0, 1129, 2, 999, 1129, 1130, 0, 430, 0, 1131, 2, 1130, 1131, 1132, 0, 1128, 1132, 1133, 1, 442, 1133, 1134, 0, 1128, 1134, 1135, 1, 1135, 640, 1136, 0, 485, 663, 1137, 1, 1136, 1137, 1138, 0, 485, 1138, 1139, 1, 1139, 669, 1140, 0, 1140, 0, 1141, 2, 37, 5, 1142, 1, 486, 1142, 1143, 0, 37, 1143, 1144, 1, 1141, 1144, 1145, 1, 1119, 1145, 1146, 1, 1119, 1144, 1147, 1, 1145, 1147, 1148, 0, 1144, 1148, 1149, 1, 536, 874, 1150, 0, 1150, 0, 1151, 2, 850, 871, 1152, 1, 430, 1152, 1153, 0, 850, 1153, 1154, 1, 1154, 0, 1155, 2, 1151, 1155, 1156, 1, 676, 1156, 1157, 0, 1151, 1157, 1158, 1, 1158, 0, 1159, 2, 640, 1159, 1160, 0, 485, 663, 1161, 1, 1160, 1161, 1162, 0, 485, 1162, 1163, 1, 1163, 669, 1164, 0, 1164, 0, 1165, 2, 38, 6, 1166, 1, 486, 1166, 1167, 0, 38, 1167, 1168, 1, 1165, 1168, 1169, 1, 1149, 1169, 1170, 1, 1149, 1168, 1171, 1, 1169, 1171, 1172, 0, 1168, 1172, 1173, 1, 952, 908, 1174, 1, 536, 1174, 1175, 0, 952, 1175, 1176, 1, 958, 536, 1177, 0, 1176, 1177, 1178, 1, 442, 1178, 1179, 0, 1176, 1179, 1180, 1, 1180, 640, 1181, 0, 485, 663, 1182, 1, 1181, 1182, 1183, 0, 485, 1183, 1184, 1, 1184, 669, 1185, 0, 1185, 0, 1186, 2, 39, 7, 1187, 1, 486, 1187, 1188, 0, 39, 1188, 1189, 1, 1186, 1189, 1190, 1, 1173, 1190, 1191, 1, 1173, 1189, 1192, 1, 1190, 1192, 1193, 0, 1189, 1193, 1194, 1, 629, 535, 1195, 1, 536, 1195, 1196, 0, 629, 1196, 1197, 1, 640, 676, 1198, 0, 1197, 1198, 1199, 0, 485, 663, 1200, 1, 1199, 1200, 1201, 0, 485, 1201, 1202, 1, 1202, 669, 1203, 0, 1203, 0, 1204, 2, 40, 8, 1205, 1, 486, 1205, 1206, 0, 40, 1206, 1207, 1, 1204, 1207, 1208, 1, 1194, 1208, 1209, 1, 1194, 1207, 1210, 1, 1208, 1210, 1211, 0, 1207, 1211, 1212, 1, 1005, 984, 1213, 1, 536, 1213, 1214, 0, 1005, 1214, 1215, 1, 1215, 1198, 1216, 0, 485, 663, 1217, 1, 1216, 1217, 1218, 0, 485, 1218, 1219, 1, 1219, 669, 1220, 0, 1220, 0, 1221, 2, 41, 9, 1222, 1, 486, 1222, 1223, 0, 41, 1223, 1224, 1, 1221, 1224, 1225, 1, 1212, 1225, 1226, 1, 1212, 1224, 1227, 1, 1225, 1227, 1228, 0, 1224, 1228, 1229, 1, 1036, 1027, 1230, 1, 536, 1230, 1231, 0, 1036, 1231, 1232, 1, 1232, 1198, 1233, 0, 485, 663, 1234, 1, 1233, 1234, 1235, 0, 485, 1235, 1236, 1, 1236, 669, 1237, 0, 1237, 0, 1238, 2, 10, 42, 1239, 1, 387, 1239, 1240, 0, 10, 1240, 1241, 1, 1238, 1241, 1242, 1, 1229, 1242, 1243, 1, 1229, 1241, 1244, 1, 1242, 1244, 1245, 0, 1241, 1245, 1246, 1, 1065, 0, 1247, 2, 1247, 1059, 1248, 1, 430, 1248, 1249, 0, 1247, 1249, 1250, 1, 1250, 0, 1251, 2, 1198, 1251, 1252, 0, 485, 663, 1253, 1, 1252, 1253, 1254, 0, 485, 1254, 1255, 1, 1255, 669, 1256, 0, 1256, 0, 1257, 2, 11, 43, 1258, 1, 387, 1258, 1259, 0, 11, 1259, 1260, 1, 1257, 1260, 1261, 1, 1246, 1261, 1262, 1, 1246, 1260, 1263, 1, 1261, 1263, 1264, 0, 1260, 1264, 1265, 1, 1093, 1100, 1266, 1, 430, 1266, 1267, 0, 1093, 1267, 1268, 1, 1198, 1268, 1269, 0, 485, 663, 1270, 1, 1269, 1270, 1271, 0, 485, 1271, 1272, 1, 1272, 669, 1273, 0, 1273, 0, 1274, 2, 12, 44, 1275, 1, 387, 1275, 1276, 0, 12, 1276, 1277, 1, 1274, 1277, 1278, 1, 1265, 1278, 1279, 1, 1265, 1277, 1280, 1, 1278, 1280, 1281, 0, 1277, 1281, 1282, 1, 1130, 1122, 1283, 1, 536, 1283, 1284, 0, 1130, 1284, 1285, 1, 1285, 1198, 1286, 0, 485, 663, 1287, 1, 1286, 1287, 1288, 0, 485, 1288, 1289, 1, 1289, 669, 1290, 0, 1290, 0, 1291, 2, 13, 45, 1292, 1, 387, 1292, 1293, 0, 13, 1293, 1294, 1, 1291, 1294, 1295, 1, 1282, 1295, 1296, 1, 1282, 1294, 1297, 1, 1295, 1297, 1298, 0, 1294, 1298, 1299, 1, 877, 676, 1300, 0, 1300, 640, 1301, 0, 485, 663, 1302, 1, 1301, 1302, 1303, 0, 485, 1303, 1304, 1, 1304, 669, 1305, 0, 1305, 0, 1306, 2, 14, 46, 1307, 1, 387, 1307, 1308, 0, 14, 1308, 1309, 1, 1306, 1309, 1310, 1, 1299, 1310, 1311, 1, 1299, 1309, 1312, 1, 1310, 1312, 1313, 0, 1309, 1313, 1314, 1, 676, 640, 1315, 0, 1315, 961, 1316, 0, 485, 663, 1317, 1, 1316, 1317, 1318, 0, 485, 1318, 1319, 1, 1319, 669, 1320, 0, 1320, 0, 1321, 2, 47, 15, 1322, 1, 486, 1322, 1323, 0, 47, 1323, 1324, 1, 1321, 1324, 1325, 1, 1314, 1325, 1326, 1, 1314, 1324, 1327, 1, 1325, 1327, 1328, 0, 1324, 1328, 1329, 1, 1198, 631, 1330, 0, 485, 663, 1331, 1, 1330, 1331, 1332, 0, 485, 1332, 1333, 1, 1333, 669, 1334, 0, 1334, 0, 1335, 2, 48, 16, 1336, 1, 486, 1336, 1337, 0, 48, 1337, 1338, 1, 1335, 1338, 1339, 1, 1329, 1339, 1340, 1, 1329, 1338, 1341, 1, 1339, 1341, 1342, 0, 1338, 1342, 1343, 1, 1198, 1007, 1344, 0, 485, 663, 1345, 1, 1344, 1345, 1346, 0, 485, 1346, 1347, 1, 1347, 669, 1348, 0, 1348, 0, 1349, 2, 49, 17, 1350, 1, 486, 1350, 1351, 0, 49, 1351, 1352, 1, 1349, 1352, 1353, 1, 1343, 1353, 1354, 1, 1343, 1352, 1355, 1, 1353, 1355, 1356, 0, 1352, 1356, 1357, 1, 1198, 1038, 1358, 0, 485, 663, 1359, 1, 1358, 1359, 1360, 0, 485, 1360, 1361, 1, 1361, 669, 1362, 0, 1362, 0, 1363, 2, 50, 18, 1364, 1, 486, 1364, 1365, 0, 50, 1365, 1366, 1, 1363, 1366, 1367, 1, 1357, 1367, 1368, 1, 1357, 1366, 1369, 1, 1367, 1369, 1370, 0, 1366, 1370, 1371, 1, 1062, 0, 1372, 2, 1198, 1372, 1373, 0, 485, 663, 1374, 1, 1373, 1374, 1375, 0, 485, 1375, 1376, 1, 1376, 669, 1377, 0, 1377, 0, 1378, 2, 51, 19, 1379, 1, 486, 1379, 1380, 0, 51, 1380, 1381, 1, 1378, 1381, 1382, 1, 1371, 1382, 1383, 1, 1371, 1381, 1384, 1, 1382, 1384, 1385, 0, 1381, 1385, 1386, 1, 1198, 1102, 1387, 0, 485, 663, 1388, 1, 1387, 1388, 1389, 0, 485, 1389, 1390, 1, 1390, 669, 1391, 0, 1391, 0, 1392, 2, 52, 20, 1393, 1, 486, 1393, 1394, 0, 52, 1394, 1395, 1, 1392, 1395, 1396, 1, 1386, 1396, 1397, 1, 1386, 1395, 1398, 1, 1396, 1398, 1399, 0, 1395, 1399, 1400, 1, 1198, 1132, 1401, 0, 485, 663, 1402, 1, 1401, 1402, 1403, 0, 485, 1403, 1404, 1, 1404, 669, 1405, 0, 1405, 0, 1406, 2, 53, 21, 1407, 1, 486, 1407, 1408, 0, 53, 1408, 1409, 1, 1406, 1409, 1410, 1, 1400, 1410, 1411, 1, 1400, 1409, 1412, 1, 1410, 1412, 1413, 0, 1409, 1413, 1414, 1, 1151, 0, 1415, 2, 1198, 1415, 1416, 0, 485, 663, 1417, 1, 1416, 1417, 1418, 0, 485, 1418, 1419, 1, 1419, 669, 1420, 0, 1420, 0, 1421, 2, 54, 22, 1422, 1, 486, 1422, 1423, 0, 54, 1423, 1424, 1, 1421, 1424, 1425, 1, 1414, 1425, 1426, 1, 1414, 1424, 1427, 1, 1425, 1427, 1428, 0, 1424, 1428, 1429, 1, 1296, 0, 1430, 2, 1311, 0, 1431, 2, 1430, 1431, 1432, 0, 1326, 0, 1433, 2, 1340, 0, 1434, 2, 1433, 1434, 1435, 0, 1432, 1435, 1436, 0, 1279, 1262, 1437, 1, 1279, 1262, 1438, 0, 1437, 1438, 1439, 1, 1226, 1243, 1440, 1, 1226, 1243, 1441, 0, 1440, 1441, 1442, 1, 1439, 1442, 1443, 1, 1439, 1442, 1444, 0, 1443, 1444, 1445, 1, 1445, 0, 1446, 2, 1436, 1446, 1447, 0, 1383, 0, 1448, 2, 1397, 0, 1449, 2, 1448, 1449, 1450, 0, 1198, 1177, 1451, 0, 485, 663, 1452, 1, 1451, 1452, 1453, 0, 485, 1453, 1454, 1, 1454, 669, 1455, 0, 1455, 0, 1456, 2, 1456, 1429, 1457, 1, 1457, 0, 1458, 2, 1458, 0, 1459, 2, 1429, 1456, 1460, 1, 1429, 1456, 1461, 0, 1460, 1461, 1462, 1, 660, 1462, 1463, 1, 1463, 0, 1464, 2, 1459, 1464, 1465, 0, 1465, 0, 1466, 2, 1466, 0, 1467, 2, 1450, 1467, 1468, 0, 1368, 0, 1469, 2, 1354, 0, 1470, 2, 1469, 1470, 1471, 0, 1471, 0, 1472, 2, 1472, 0, 1473, 2, 1468, 1473, 1474, 0, 1411, 0, 1475, 2, 1426, 0, 1476, 2, 1475, 1476, 1477, 0, 1474, 1477, 1478, 0, 1478, 0, 1479, 2, 1479, 0, 1480, 2, 1447, 1480, 1481, 0, 1481, 0, 1482, 2, 1021, 1052, 1483, 1, 1021, 1052, 1484, 0, 1483, 1484, 1485, 1, 1485, 0, 1486, 2, 1087, 1116, 1487, 1, 1087, 1116, 1488, 0, 1487, 1488, 1489, 1, 1489, 0, 1490, 2, 1486, 1490, 1491, 0, 1209, 1191, 1492, 1, 1209, 1191, 1493, 0, 1492, 1493, 1494, 1, 1494, 0, 1495, 2, 1146, 1170, 1496, 1, 1146, 1170, 1497, 0, 1496, 1497, 1498, 1, 1498, 0, 1499, 2, 1495, 1499, 1500, 0, 1500, 0, 1501, 2, 1501, 0, 1502, 2, 1491, 1502, 1503, 0, 1503, 0, 1504, 2, 1445, 0, 1505, 2, 1504, 1505, 1506, 0, 1506, 1436, 1507, 0, 1507, 0, 1508, 2, 1479, 0, 1509, 2, 1508, 1509, 1510, 0, 1510, 0, 1511, 2, 886, 841, 1512, 1, 1426, 0, 1513, 2, 1397, 0, 1514, 2, 1311, 0, 1515, 2, 970, 887, 1516, 1, 1516, 0, 1517, 2, 1512, 1517, 1518, 0, 1518, 0, 1519, 2, 972, 0, 1520, 2, 1519, 1520, 1521, 0, 1521, 0, 1522, 2, 1021, 0, 1523, 2, 1522, 1523, 1524, 0, 1524, 0, 1525, 2, 1052, 0, 1526, 2, 1525, 1526, 1527, 0, 1527, 0, 1528, 2, 1087, 0, 1529, 2, 1528, 1529, 1530, 0, 1530, 0, 1531, 2, 1116, 0, 1532, 2, 1531, 1532, 1533, 0, 1533, 0, 1534, 2, 1146, 0, 1535, 2, 1534, 1535, 1536, 0, 1536, 0, 1537, 2, 1170, 0, 1538, 2, 1537, 1538, 1539, 0, 1539, 0, 1540, 2, 1191, 0, 1541, 2, 1540, 1541, 1542, 0, 1542, 0, 1543, 2, 1209, 0, 1544, 2, 1543, 1544, 1545, 0, 1545, 0, 1546, 2, 1226, 0, 1547, 2, 1546, 1547, 1548, 0, 1548, 0, 1549, 2, 1243, 0, 1550, 2, 1549, 1550, 1551, 0, 1551, 0, 1552, 2, 1262, 0, 1553, 2, 1552, 1553, 1554, 0, 1554, 0, 1555, 2, 1279, 0, 1556, 2, 1555, 1556, 1557, 0, 1557, 0, 1558, 2, 1430, 1558, 1559, 0, 1559, 0, 1560, 2, 1515, 1560, 1561, 0, 1561, 0, 1562, 2, 1433, 1562, 1563, 0, 1563, 0, 1564, 2, 1434, 1564, 1565, 0, 1565, 0, 1566, 2, 1470, 1566, 1567, 0, 1567, 0, 1568, 2, 1469, 1568, 1569, 0, 1569, 0, 1570, 2, 1448, 1570, 1571, 0, 1571, 0, 1572, 2, 1514, 1572, 1573, 0, 1573, 0, 1574, 2, 1475, 1574, 1575, 0, 1575, 0, 1576, 2, 1513, 1576, 1577, 0, 1577, 0, 1578, 2, 1459, 1578, 1579, 0, 1579, 0, 1580, 2, 1463, 0, 1581, 2, 1580, 1581, 1582, 0, 1582, 0, 1583, 2, 1583, 0, 1584, 2, 1584, 0, 1585, 2, 1512, 1585, 1586, 0, 1477, 1466, 1587, 1, 1477, 1466, 1588, 0, 1587, 1588, 1589, 1, 972, 1516, 1590, 1, 972, 1516, 1591, 0, 1590, 1591, 1592, 1, 1592, 1486, 1593, 0, 1593, 0, 1594, 2, 1594, 1490, 1595, 0, 1595, 0, 1596, 2, 1499, 1596, 1597, 0, 1597, 0, 1598, 2, 1495, 1598, 1599, 0, 1599, 0, 1600, 2, 1442, 0, 1601, 2, 1600, 1601, 1602, 0, 1602, 0, 1603, 2, 1439, 0, 1604, 2, 1603, 1604, 1605, 0, 1605, 0, 1606, 2, 1606, 1432, 1607, 0, 1607, 0, 1608, 2, 1608, 1435, 1609, 0, 1609, 0, 1610, 2, 1472, 0, 1611, 2, 1610, 1611, 1612, 0, 1612, 0, 1613, 2, 1613, 1468, 1614, 0, 1614, 0, 1615, 2, 1589, 1615, 1616, 0, 1586, 1616, 1617, 0, 1491, 1501, 1618, 1, 1491, 1501, 1619, 0, 1618, 1619, 1620, 1, 1445, 0, 1621, 2, 1620, 1621, 1622, 0, 1622, 0, 1623, 2, 1623, 1436, 1624, 0, 1624, 0, 1625, 2, 1450, 1625, 1626, 0, 1472, 0, 1627, 2, 1626, 1627, 1628, 0, 1628, 0, 1629, 2, 1466, 0, 1630, 2, 1629, 1630, 1631, 0, 1477, 1631, 1632, 0, 1632, 0, 1633, 2, 972, 1516, 1634, 1, 1584, 1634, 1635, 0, 972, 1635, 1636, 1, 1021, 1052, 1637, 1, 1583, 1637, 1638, 0, 1021, 1638, 1639, 1, 1636, 1639, 1640, 1, 1616, 1640, 1641, 0, 1636, 1641, 1642, 1, 1617, 1642, 1643, 1, 1633, 1643, 1644, 0, 1617, 1644, 1645, 1, 1511, 1645, 1646, 0, 1646, 0, 1647, 2, 1647, 0, 1648, 2, 1482, 1648, 1649, 0, 1482, 0, 1650, 2, 1512, 1516, 1651, 1, 1583, 1651, 1652, 0, 1512, 1652, 1653, 1, 1021, 972, 1654, 1, 1584, 1654, 1655, 0, 1021, 1655, 1656, 1, 1653, 1656, 1657, 1, 1616, 1657, 1658, 0, 1653, 1658, 1659, 1, 1633, 1659, 1660, 0, 1660, 0, 1661, 2, 1661, 0, 1662, 2, 1511, 1662, 1663, 0, 1663, 0, 1664, 2, 1650, 1664, 1665, 1, 1650, 1664, 1666, 0, 1665, 1666, 1667, 1, 1667, 0, 1668, 2, 1649, 1668, 1669, 1, 1649, 1668, 1670, 0, 1052, 1087, 1671, 1, 1583, 1671, 1672, 0, 1052, 1672, 1673, 1, 1616, 0, 1674, 2, 1673, 1656, 1675, 1, 1674, 1675, 1676, 0, 1673, 1676, 1677, 1, 1674, 0, 1678, 2, 1653, 1678, 1679, 0, 1677, 1679, 1680, 1, 1632, 1680, 1681, 0, 1677, 1681, 1682, 1, 1511, 1682, 1683, 0, 1683, 0, 1684, 2, 1684, 0, 1685, 2, 1482, 1685, 1686, 0, 1686, 1670, 1687, 1, 1686, 1670, 1688, 0, 1116, 1087, 1689, 1, 1584, 1689, 1690, 0, 1116, 1690, 1691, 1, 1691, 1639, 1692, 1, 1674, 1692, 1693, 0, 1691, 1693, 1694, 1, 1586, 1636, 1695, 1, 1616, 1695, 1696, 0, 1586, 1696, 1697, 1, 1694, 1697, 1698, 1, 1632, 1698, 1699, 0, 1694, 1699, 1700, 1, 1511, 1700, 1701, 0, 1701, 0, 1702, 2, 1702, 0, 1703, 2, 1482, 1703, 1704, 0, 1704, 1688, 1705, 1, 1704, 1688, 1706, 0, 1116, 1146, 1707, 1, 1583, 1707, 1708, 0, 1116, 1708, 1709, 1, 1673, 1709, 1710, 1, 1616, 1710, 1711, 0, 1673, 1711, 1712, 1, 1712, 1659, 1713, 1, 1632, 1713, 1714, 0, 1712, 1714, 1715, 1, 1511, 1715, 1716, 0, 1716, 0, 1717, 2, 1717, 0, 1718, 2, 1482, 1718, 1719, 0, 1719, 1706, 1720, 1, 1719, 1706, 1721, 0, 1633, 1617, 1722, 0, 1722, 0, 1723, 2, 1146, 1170, 1724, 1, 1583, 1724, 1725, 0, 1146, 1725, 1726, 1, 1726, 1691, 1727, 1, 1674, 1727, 1728, 0, 1726, 1728, 1729, 1, 1642, 1729, 1730, 1, 1633, 1730, 1731, 0, 1642, 1731, 1732, 1, 1732, 0, 1733, 2, 1723, 1733, 1734, 1, 1511, 1734, 1735, 0, 1723, 1735, 1736, 1, 1650, 1736, 1737, 1, 1650, 1736, 1738, 0, 1737, 1738, 1739, 1, 1739, 0, 1740, 2, 1740, 1721, 1741, 1, 1740, 1721, 1742, 0, 1633, 1679, 1743, 0, 1743, 0, 1744, 2, 1170, 1191, 1745, 1, 1583, 1745, 1746, 0, 1170, 1746, 1747, 1, 1747, 1709, 1748, 1, 1674, 1748, 1749, 0, 1747, 1749, 1750, 1, 1677, 1750, 1751, 1, 1633, 1751, 1752, 0, 1677, 1752, 1753, 1, 1753, 0, 1754, 2, 1744, 1754, 1755, 1, 1511, 1755, 1756, 0, 1744, 1756, 1757, 1, 1650, 1757, 1758, 1, 1650, 1757, 1759, 0, 1758, 1759, 1760, 1, 1760, 0, 1761, 2, 1761, 1742, 1762, 1, 1761, 1742, 1763, 0, 1191, 1209, 1764, 1, 1583, 1764, 1765, 0, 1191, 1765, 1766, 1, 1726, 1766, 1767, 1, 1616, 1767, 1768, 0, 1726, 1768, 1769, 1, 1694, 1769, 1770, 1, 1633, 1770, 1771, 0, 1694, 1771, 1772, 1, 1697, 1633, 1773, 0, 1772, 1773, 1774, 1, 1510, 1774, 1775, 0, 1772, 1775, 1776, 1, 1776, 1482, 1777, 0, 1777, 1763, 1778, 1, 1777, 1763, 1779, 0, 1226, 1209, 1780, 1, 1584, 1780, 1781, 0, 1226, 1781, 1782, 1, 1782, 1747, 1783, 1, 1674, 1783, 1784, 0, 1782, 1784, 1785, 1, 1712, 1785, 1786, 1, 1633, 1786, 1787, 0, 1712, 1787, 1788, 1, 1788, 0, 1789, 2, 1661, 1789, 1790, 1, 1511, 1790, 1791, 0, 1661, 1791, 1792, 1, 1792, 0, 1793, 2, 1793, 1779, 1794, 1, 1793, 1779, 1795, 0, 1226, 1243, 1796, 1, 1583, 1796, 1797, 0, 1226, 1797, 1798, 1, 1766, 1798, 1799, 1, 1616, 1799, 1800, 0, 1766, 1800, 1801, 1, 1729, 1801, 1802, 1, 1633, 1802, 1803, 0, 1729, 1803, 1804, 1, 1804, 1645, 1805, 1, 1510, 1805, 1806, 0, 1804, 1806, 1807, 1, 1807, 1795, 1808, 1, 1807, 1795, 1809, 0, 1243, 1262, 1810, 1, 1583, 1810, 1811, 0, 1243, 1811, 1812, 1, 1812, 1782, 1813, 1, 1674, 1813, 1814, 0, 1812, 1814, 1815, 1, 1815, 1750, 1816, 1, 1632, 1816, 1817, 0, 1815, 1817, 1818, 1, 1682, 1818, 1819, 1, 1511, 1819, 1820, 0, 1682, 1820, 1821, 1, 1821, 1809, 1822, 1, 1821, 1809, 1823, 0, 1262, 1279, 1824, 1, 1583, 1824, 1825, 0, 1262, 1825, 1826, 1, 1826, 1798, 1827, 1, 1674, 1827, 1828, 0, 1826, 1828, 1829, 1, 1769, 1829, 1830, 1, 1633, 1830, 1831, 0, 1769, 1831, 1832, 1, 1700, 1832, 1833, 1, 1511, 1833, 1834, 0, 1700, 1834, 1835, 1, 1835, 1823, 1836, 1, 1835, 1823, 1837, 0, 1279, 1296, 1838, 1, 1583, 1838, 1839, 0, 1279, 1839, 1840, 1, 1840, 1812, 1841, 1, 1674, 1841, 1842, 0, 1840, 1842, 1843, 1, 1843, 1785, 1844, 1, 1632, 1844, 1845, 0, 1843, 1845, 1846, 1, 1715, 1846, 1847, 1, 1511, 1847, 1848, 0, 1715, 1848, 1849, 1, 1849, 1837, 1850, 1, 1849, 1837, 1851, 0, 1801, 0, 1852, 2, 1430, 1515, 1853, 1, 1583, 1853, 1854, 0, 1430, 1854, 1855, 1, 1826, 0, 1856, 2, 1855, 1856, 1857, 1, 1674, 1857, 1858, 0, 1855, 1858, 1859, 1, 1852, 1859, 1860, 1, 1633, 1860, 1861, 0, 1852, 1861, 1862, 1, 1862, 1733, 1863, 1, 1510, 1863, 1864, 0, 1862, 1864, 1865, 1, 1510, 1723, 1866, 1, 1510, 1723, 1867, 0, 1866, 1867, 1868, 1, 1868, 0, 1869, 2, 1650, 1869, 1870, 0, 1870, 0, 1871, 2, 1865, 1871, 1872, 0, 1872, 0, 1873, 2, 1873, 1851, 1874, 1, 1873, 1851, 1875, 0, 1510, 1744, 1876, 1, 1510, 1744, 1877, 0, 1876, 1877, 1878, 1, 1878, 0, 1879, 2, 1650, 1879, 1880, 0, 1880, 0, 1881, 2, 1311, 1326, 1882, 1, 1583, 1882, 1883, 0, 1311, 1883, 1884, 1, 1884, 1840, 1885, 1, 1674, 1885, 1886, 0, 1884, 1886, 1887, 1, 1815, 1887, 1888, 1, 1633, 1888, 1889, 0, 1815, 1889, 1890, 1, 1890, 1753, 1891, 1, 1510, 1891, 1892, 0, 1890, 1892, 1893, 1, 1893, 0, 1894, 2, 1881, 1894, 1895, 0, 1895, 0, 1896, 2, 1896, 1875, 1897, 1, 1896, 1875, 1898, 0, 1829, 0, 1899, 2, 1434, 1433, 1900, 1, 1584, 1900, 1901, 0, 1434, 1901, 1902, 1, 1902, 1855, 1903, 1, 1674, 1903, 1904, 0, 1902, 1904, 1905, 1, 1899, 1905, 1906, 1, 1633, 1906, 1907, 0, 1899, 1907, 1908, 1, 1772, 0, 1909, 2, 1908, 1909, 1910, 1, 1510, 1910, 1911, 0, 1908, 1911, 1912, 1, 1510, 0, 1913, 2, 1773, 1913, 1914, 0, 1914, 0, 1915, 2, 1915, 0, 1916, 2, 1650, 1916, 1917, 0, 1917, 0, 1918, 2, 1912, 1918, 1919, 0, 1919, 0, 1920, 2, 1920, 1898, 1921, 1, 1920, 1898, 1922, 0, 1664, 0, 1923, 2, 1650, 1923, 1924, 0, 1924, 0, 1925, 2, 1789, 0, 1926, 2, 1510, 1926, 1927, 0, 1927, 0, 1928, 2, 1925, 1928, 1929, 0, 1470, 1434, 1930, 1, 1584, 1930, 1931, 0, 1470, 1931, 1932, 1, 1932, 0, 1933, 2, 1884, 1933, 1934, 1, 1616, 1934, 1935, 0, 1884, 1935, 1936, 1, 1843, 1936, 1937, 1, 1633, 1937, 1938, 0, 1843, 1938, 1939, 1, 1939, 0, 1940, 2, 1929, 1940, 1941, 0, 1941, 0, 1942, 2, 1942, 1922, 1943, 1, 1942, 1922, 1944, 0, 1647, 0, 1945, 2, 1650, 1945, 1946, 0, 1946, 0, 1947, 2, 1511, 0, 1948, 2, 1804, 1948, 1949, 0, 1949, 0, 1950, 2, 1947, 1950, 1951, 0, 1469, 1470, 1952, 1, 1584, 1952, 1953, 0, 1469, 1953, 1954, 1, 1954, 1902, 1955, 1, 1674, 1955, 1956, 0, 1954, 1956, 1957, 1, 1957, 1859, 1958, 1, 1632, 1958, 1959, 0, 1957, 1959, 1960, 1, 1951, 1960, 1961, 0, 1961, 0, 1962, 2, 1962, 1944, 1963, 1, 1962, 1944, 1964, 0, 1684, 0, 1965, 2, 1650, 1965, 1966, 0, 1966, 0, 1967, 2, 1510, 1818, 1968, 0, 1968, 0, 1969, 2, 1967, 1969, 1970, 0, 1448, 1469, 1971, 1, 1584, 1971, 1972, 0, 1448, 1972, 1973, 1, 1973, 1932, 1974, 1, 1674, 1974, 1975, 0, 1973, 1975, 1976, 1, 1976, 0, 1977, 2, 1887, 1977, 1978, 1, 1633, 1978, 1979, 0, 1887, 1979, 1980, 1, 1980, 0, 1981, 2, 1970, 1981, 1982, 0, 1982, 0, 1983, 2, 1983, 1964, 1984, 1, 1983, 1964, 1985, 0, 1702, 0, 1986, 2, 1650, 1986, 1987, 0, 1987, 0, 1988, 2, 1510, 1832, 1989, 0, 1989, 0, 1990, 2, 1988, 1990, 1991, 0, 1448, 1514, 1992, 1, 1583, 1992, 1993, 0, 1448, 1993, 1994, 1, 1994, 1954, 1995, 1, 1674, 1995, 1996, 0, 1994, 1996, 1997, 1, 1997, 1905, 1998, 1, 1632, 1998, 1999, 0, 1997, 1999, 2000, 1, 1991, 2000, 2001, 0, 2001, 0, 2002, 2, 2002, 1985, 2003, 1, 2002, 1985, 2004, 0, 1514, 1475, 2005, 1, 1583, 2005, 2006, 0, 1514, 2006, 2007, 1, 1973, 2007, 2008, 1, 1616, 2008, 2009, 0, 1973, 2009, 2010, 1, 1717, 0, 2011, 2, 1650, 2011, 2012, 0, 2012, 0, 2013, 2, 2010, 2013, 2014, 0, 1510, 1846, 2015, 0, 2015, 0, 2016, 2, 1632, 1936, 2017, 0, 2017, 0, 2018, 2, 2016, 2018, 2019, 0, 2014, 2019, 2020, 0, 2020, 0, 2021, 2, 2021, 2004, 2022, 1, 2021, 2004, 2023, 0, 1475, 1513, 2024, 1, 1583, 2024, 2025, 0, 1475, 2025, 2026, 1, 1994, 2026, 2027, 1, 1616, 2027, 2028, 0, 1994, 2028, 2029, 1, 1736, 0, 2030, 2, 1650, 2030, 2031, 0, 2031, 0, 2032, 2, 2029, 2032, 2033, 0, 1862, 1511, 2034, 1, 1862, 1511, 2035, 0, 2034, 2035, 2036, 1, 1957, 1633, 2037, 1, 1957, 1633, 2038, 0, 2037, 2038, 2039, 1, 2036, 2039, 2040, 0, 2033, 2040, 2041, 0, 2041, 0, 2042, 2, 2042, 2023, 2043, 1, 2042, 2023, 2044, 0, 1397, 1411, 2045, 0, 2045, 1426, 2046, 0, 1368, 1354, 2047, 0, 2047, 1383, 2048, 0, 2046, 2048, 2049, 0, 1311, 1326, 2050, 0, 2050, 1340, 2051, 0, 1279, 1262, 2052, 0, 2052, 1296, 2053, 0, 2051, 2053, 2054, 0, 2049, 2054, 2055, 0, 1170, 1146, 2056, 0, 1879, 1869, 2057, 1, 1879, 1869, 2058, 0, 2057, 2058, 2059, 1, 2059, 0, 2060, 2, 840, 660, 2061, 1, 1668, 2061, 2062, 1, 1668, 2061, 2063, 0, 2062, 2063, 2064, 1, 2064, 0, 2065, 2, 2060, 2065, 2066, 0, 2066, 0, 2067, 2, 2067, 1482, 2068, 0, 1915, 0, 2069, 2, 2068, 2069, 2070, 0, 2070, 0, 2071, 2, 2071, 0, 2072, 2, 2056, 2072, 2073, 0, 1116, 1243, 2074, 0, 1087, 2074, 2075, 0, 2073, 2075, 2076, 0, 1191, 1209, 2077, 0, 1226, 2077, 2078, 0, 1052, 972, 2079, 0, 2079, 1021, 2080, 0, 2078, 2080, 2081, 0, 2076, 2081, 2082, 0, 2055, 2082, 2083, 0, 1458, 2083, 2084, 0, 2084, 0, 2085, 2, 1463, 0, 2086, 2, 2085, 2086, 2087, 0, 2087, 0, 2088, 2, 655, 2088, 2089, 0, 2089, 0, 2090, 2, 2071, 0, 2091, 2, 2090, 2091, 2092, 0, 2092, 0, 2093, 2, 2090, 2093, 2094, 0, 394, 0, 2095, 2, 398, 2095, 2096, 0, 2092, 1808, 2097, 0, 2097, 0, 2098, 2, 1584, 399, 2099, 0, 2099, 1674, 2100, 1, 2099, 1674, 2101, 0, 2100, 2101, 2102, 1, 399, 394, 2103, 1, 2103, 0, 2104, 2, 2104, 0, 2105, 2, 1616, 2105, 2106, 0, 2106, 0, 2107, 2, 2102, 2107, 2108, 0, 2099, 2104, 2109, 1, 2099, 2104, 2110, 0, 2109, 2110, 2111, 1, 2108, 2111, 2112, 0, 2112, 1632, 2113, 1, 2113, 0, 2114, 2, 394, 399, 2115, 0, 2115, 0, 2116, 2, 415, 2116, 2117, 1, 2114, 2117, 2118, 1, 2099, 1616, 2119, 1, 2119, 0, 2120, 2, 2120, 2104, 2121, 1, 2118, 2121, 2122, 0, 2112, 0, 2123, 2, 1633, 2123, 2124, 0, 2124, 0, 2125, 2, 1633, 2117, 2126, 0, 2126, 0, 2127, 2, 2125, 2127, 2128, 0, 2112, 0, 2129, 2, 2117, 2129, 2130, 0, 2130, 0, 2131, 2, 2128, 2131, 2132, 0, 2132, 1510, 2133, 1, 2133, 0, 2134, 2, 2116, 0, 2135, 2, 416, 2135, 2136, 0, 2136, 0, 2137, 2, 427, 2137, 2138, 1, 2134, 2138, 2139, 1, 2132, 0, 2140, 2, 1511, 2140, 2141, 0, 2141, 0, 2142, 2, 1511, 2138, 2143, 0, 2143, 0, 2144, 2, 2142, 2144, 2145, 0, 2132, 0, 2146, 2, 2138, 2146, 2147, 0, 2147, 0, 2148, 2, 2145, 2148, 2149, 0, 2149, 1650, 2150, 1, 2150, 0, 2151, 2, 2137, 0, 2152, 2, 428, 2152, 2153, 0, 2153, 0, 2154, 2, 439, 2154, 2155, 1, 2151, 2155, 2156, 1, 2139, 2156, 2157, 0, 2122, 2157, 2158, 0, 2154, 0, 2159, 2, 440, 2159, 2160, 0, 2160, 0, 2161, 2, 2161, 0, 2162, 2, 452, 2162, 2163, 0, 2163, 0, 2164, 2, 2164, 0, 2165, 2, 464, 2165, 2166, 0, 475, 2166, 2167, 1, 2167, 0, 2168, 2, 2149, 0, 2169, 2, 1482, 2169, 2170, 0, 2170, 0, 2171, 2, 1482, 2155, 2172, 0, 2172, 0, 2173, 2, 2171, 2173, 2174, 0, 2149, 0, 2175, 2, 2155, 2175, 2176, 0, 2176, 0, 2177, 2, 2174, 2177, 2178, 0, 451, 2161, 2179, 1, 2179, 0, 2180, 2, 2178, 2180, 2181, 0, 464, 2164, 2182, 1, 2181, 2182, 2183, 0, 2168, 2183, 2184, 1, 2179, 2178, 2185, 1, 2185, 0, 2186, 2, 2184, 2186, 2187, 0, 399, 1583, 2188, 1, 2188, 0, 2189, 2, 2182, 2181, 2190, 1, 2189, 2190, 2191, 0, 2187, 2191, 2192, 0, 2158, 2192, 2193, 0, 2193, 0, 2194, 2, 475, 0, 2195, 2, 2168, 2195, 2196, 0, 2196, 2183, 2197, 0, 2197, 0, 2198, 2, 2194, 2198, 2199, 0, 658, 2199, 2200, 0, 475, 0, 2201, 2, 463, 2201, 2202, 0, 2096, 2202, 2203, 0, 451, 439, 2204, 0, 427, 415, 2205, 0, 2204, 2205, 2206, 0, 2203, 2206, 2207, 0, 2207, 0, 2208, 2, 2208, 2094, 2209, 0, 2200, 2209, 2210, 0, 2210, 1807, 2211, 0, 2211, 0, 2212, 2, 2098, 2212, 2213, 0, 2213, 0, 2214, 2, 2092, 1794, 2215, 0, 2215, 0, 2216, 2, 1793, 2210, 2217, 0, 2217, 0, 2218, 2, 2216, 2218, 2219, 0, 2219, 0, 2220, 2, 2092, 1778, 2221, 0, 2221, 0, 2222, 2, 2210, 1777, 2223, 0, 2223, 0, 2224, 2, 2222, 2224, 2225, 0, 2225, 0, 2226, 2, 2092, 1762, 2227, 0, 2227, 0, 2228, 2, 2210, 1761, 2229, 0, 2229, 0, 2230, 2, 2228, 2230, 2231, 0, 2231, 0, 2232, 2, 2092, 1741, 2233, 0, 2233, 0, 2234, 2, 2210, 1740, 2235, 0, 2235, 0, 2236, 2, 2234, 2236, 2237, 0, 2237, 0, 2238, 2, 2092, 1720, 2239, 0, 2239, 0, 2240, 2, 2210, 1719, 2241, 0, 2241, 0, 2242, 2, 2240, 2242, 2243, 0, 2243, 0, 2244, 2, 2092, 1705, 2245, 0, 2245, 0, 2246, 2, 2210, 1704, 2247, 0, 2247, 0, 2248, 2, 2246, 2248, 2249, 0, 2249, 0, 2250, 2, 473, 460, 2251, 1, 473, 460, 2252, 0, 2251, 2252, 2253, 1, 2253, 0, 2254, 2, 436, 448, 2255, 1, 436, 448, 2256, 0, 2255, 2256, 2257, 1, 2257, 0, 2258, 2, 2254, 2258, 2259, 0, 412, 424, 2260, 1, 412, 424, 2261, 0, 2260, 2261, 2262, 1, 2262, 0, 2263, 2, 391, 402, 2264, 1, 391, 402, 2265, 0, 2264, 2265, 2266, 1, 2266, 0, 2267, 2, 2263, 2267, 2268, 0, 2259, 2268, 2269, 0, 2269, 0, 2270, 2, 2270, 2208, 2271, 0, 2271, 0, 2272, 2, 660, 2272, 2273, 0, 2273, 0, 2274, 2, 1510, 1650, 2275, 0, 1674, 1584, 2276, 0, 2275, 2276, 2277, 0, 2277, 0, 2278, 2, 2274, 2278, 2279, 0, 480, 2279, 2280, 0, 1516, 2083, 2281, 0, 2281, 0, 2282, 2, 485, 0, 2283, 2, 2282, 2283, 2284, 0, 2284, 2088, 2285, 1, 2284, 2088, 2286, 0, 2285, 2286, 2287, 1, 2287, 0, 2288, 2, 475, 2288, 2289, 0, 2289, 0, 2290, 2, 2168, 0, 2291, 2, 2088, 2291, 2292, 0, 2292, 0, 2293, 2, 2290, 2293, 2294, 0, 2199, 0, 2295, 2, 2208, 2295, 2296, 0, 2296, 0, 2297, 2, 2277, 0, 2298, 2, 2297, 2298, 2299, 0, 2299, 2284, 2300, 0, 2184, 0, 2301, 2, 2300, 2301, 2302, 0, 2302, 0, 2303, 2, 2294, 2303, 2304, 0, 2304, 0, 2305, 2, 2092, 1687, 2306, 0, 2306, 0, 2307, 2, 2210, 1686, 2308, 0, 2308, 0, 2309, 2, 2307, 2309, 2310, 0, 2310, 0, 2311, 2, 464, 2288, 2312, 0, 2312, 0, 2313, 2, 2182, 0, 2314, 2, 2088, 2314, 2315, 0, 2315, 0, 2316, 2, 2313, 2316, 2317, 0, 2190, 0, 2318, 2, 2300, 2318, 2319, 0, 2319, 0, 2320, 2, 2317, 2320, 2321, 0, 2321, 0, 2322, 2, 452, 2288, 2323, 0, 2323, 0, 2324, 2, 2088, 2179, 2325, 0, 2325, 0, 2326, 2, 2324, 2326, 2327, 0, 2185, 2300, 2328, 0, 2328, 0, 2329, 2, 2327, 2329, 2330, 0, 2330, 0, 2331, 2, 440, 2288, 2332, 0, 2332, 0, 2333, 2, 2155, 2088, 2334, 0, 2334, 0, 2335, 2, 2333, 2335, 2336, 0, 2156, 0, 2337, 2, 2300, 2337, 2338, 0, 2338, 0, 2339, 2, 2336, 2339, 2340, 0, 2340, 0, 2341, 2, 428, 2288, 2342, 0, 2342, 0, 2343, 2, 2138, 2088, 2344, 0, 2344, 0, 2345, 2, 2343, 2345, 2346, 0, 2139, 0, 2347, 2, 2300, 2347, 2348, 0, 2348, 0, 2349, 2, 2346, 2349, 2350, 0, 2350, 0, 2351, 2, 416, 2288, 2352, 0, 2352, 0, 2353, 2, 2117, 2088, 2354, 0, 2354, 0, 2355, 2, 2353, 2355, 2356, 0, 2118, 0, 2357, 2, 2300, 2357, 2358, 0, 2358, 0, 2359, 2, 2356, 2359, 2360, 0, 2360, 0, 2361, 2, 394, 2288, 2362, 0, 2362, 0, 2363, 2, 2105, 2088, 2364, 0, 2364, 0, 2365, 2, 2363, 2365, 2366, 0, 2121, 0, 2367, 2, 2300, 2367, 2368, 0, 2368, 0, 2369, 2, 2366, 2369, 2370, 0, 2370, 0, 2371, 2, 2189, 0, 2372, 2, 2300, 2372, 2373, 0, 2373, 0, 2374, 2, 2288, 2088, 2375, 1, 398, 2375, 2376, 0, 2288, 2376, 2377, 1, 2377, 0, 2378, 2, 2374, 2378, 2379, 0, 2379, 0, 2380, 2, 1459, 1513, 2381, 1, 1584, 2381, 2382, 0, 1459, 2382, 2383, 1, 1757, 0, 2384, 2, 1650, 2384, 2385, 0, 2385, 0, 2386, 2, 2383, 2386, 2387, 0, 1977, 1632, 2388, 0, 2388, 0, 2389, 2, 2007, 1616, 2390, 1, 2007, 1616, 2391, 0, 2390, 2391, 2392, 1, 2389, 2392, 2393, 0, 1510, 1890, 2394, 0, 2394, 0, 2395, 2, 2393, 2395, 2396, 0, 2387, 2396, 2397, 0, 2397, 0, 2398, 2, 2398, 2044, 2399, 1, 2092, 2399, 2400, 0, 2400, 0, 2401, 2, 2398, 2210, 2402, 0, 2402, 0, 2403, 2, 2401, 2403, 2404, 0, 2404, 0, 2405, 2, 2092, 2043, 2406, 0, 2406, 0, 2407, 2, 2210, 2042, 2408, 0, 2408, 0, 2409, 2, 2407, 2409, 2410, 0, 2410, 0, 2411, 2, 2092, 2022, 2412, 0, 2412, 0, 2413, 2, 2210, 2021, 2414, 0, 2414, 0, 2415, 2, 2413, 2415, 2416, 0, 2416, 0, 2417, 2, 2092, 1669, 2418, 0, 2418, 0, 2419, 2, 2210, 1649, 2420, 0, 2420, 0, 2421, 2, 2419, 2421, 2422, 0, 2422, 0, 2423, 2, 2092, 2003, 2424, 0, 2424, 0, 2425, 2, 2210, 2002, 2426, 0, 2426, 0, 2427, 2, 2425, 2427, 2428, 0, 2428, 0, 2429, 2, 2092, 1984, 2430, 0, 2430, 0, 2431, 2, 2210, 1983, 2432, 0, 2432, 0, 2433, 2, 2431, 2433, 2434, 0, 2434, 0, 2435, 2, 2092, 1963, 2436, 0, 2436, 0, 2437, 2, 2210, 1962, 2438, 0, 2438, 0, 2439, 2, 2437, 2439, 2440, 0, 2440, 0, 2441, 2, 2092, 1943, 2442, 0, 2442, 0, 2443, 2, 2210, 1942, 2444, 0, 2444, 0, 2445, 2, 2443, 2445, 2446, 0, 2446, 0, 2447, 2, 2092, 1921, 2448, 0, 2448, 0, 2449, 2, 2210, 1920, 2450, 0, 2450, 0, 2451, 2, 2449, 2451, 2452, 0, 2452, 0, 2453, 2, 2092, 1897, 2454, 0, 2454, 0, 2455, 2, 2210, 1896, 2456, 0, 2456, 0, 2457, 2, 2455, 2457, 2458, 0, 2458, 0, 2459, 2, 2092, 1874, 2460, 0, 2460, 0, 2461, 2, 2210, 1873, 2462, 0, 2462, 0, 2463, 2, 2461, 2463, 2464, 0, 2464, 0, 2465, 2, 2092, 1850, 2466, 0, 2466, 0, 2467, 2, 2210, 1849, 2468, 0, 2468, 0, 2469, 2, 2467, 2469, 2470, 0, 2470, 0, 2471, 2, 2092, 1836, 2472, 0, 2472, 0, 2473, 2, 2210, 1835, 2474, 0, 2474, 0, 2475, 2, 2473, 2475, 2476, 0, 2476, 0, 2477, 2, 2092, 1822, 2478, 0, 2478, 0, 2479, 2, 2210, 1821, 2480, 0, 2480, 0, 2481, 2, 2479, 2481, 2482, 0, 2482, 0, 2483, 2, 2092, 2210, 2484, 1, 1668, 2484, 2485, 0, 2092, 2485, 2486, 1, 0, 0, 2487, 1, 2487, 2486, 2488, 1, 2487, 2423, 2489, 1, 2487, 2311, 2490, 1, 2487, 2250, 2491, 1, 2487, 2244, 2492, 1, 2487, 2238, 2493, 1, 2487, 2232, 2494, 1, 2487, 2226, 2495, 1, 2487, 2220, 2496, 1, 2487, 2214, 2497, 1, 2487, 2483, 2498, 1, 2487, 2477, 2499, 1, 2487, 2471, 2500, 1, 2487, 2465, 2501, 1, 2487, 2459, 2502, 1, 2487, 2453, 2503, 1, 2487, 2447, 2504, 1, 2487, 2441, 2505, 1, 2487, 2435, 2506, 1, 2487, 2429, 2507, 1, 2487, 2417, 2508, 1, 2487, 2411, 2509, 1, 2487, 2405, 2510, 1, 2487, 2380, 2511, 1, 2487, 2371, 2512, 1, 2487, 2361, 2513, 1, 2487, 2351, 2514, 1, 2487, 2341, 2515, 1, 2487, 2331, 2516, 1, 2487, 2322, 2517, 1, 2487, 2305, 2518, 1, 2487, 2280, 2519, 1, }; execute_circuit<uint32_t>((block*)B, gates, sizeof(gates)/sizeof(uint32_t)/4); memcpy(res.value.data(), B+2520-32, sizeof(block)*32); delete[] B; return res; }
19.897249
79
0.547676
wangxiao1254
fc14fc1be5ca69f99bdf3ec859d0f9efa0f89d7e
604
cxx
C++
test/CircularBufferTest.cxx
kb1vc/SoDaSignals
f7ae9be3e8865e24e9b61643f099b59f5a5efd1a
[ "BSD-2-Clause" ]
null
null
null
test/CircularBufferTest.cxx
kb1vc/SoDaSignals
f7ae9be3e8865e24e9b61643f099b59f5a5efd1a
[ "BSD-2-Clause" ]
null
null
null
test/CircularBufferTest.cxx
kb1vc/SoDaSignals
f7ae9be3e8865e24e9b61643f099b59f5a5efd1a
[ "BSD-2-Clause" ]
null
null
null
#include "../include/CircularBuffer.hxx" #include <iostream> template<typename T> void dumpCBuf(SoDa::CircularBuffer<T> b) { for(int i = 0; i < b.size(); i++) { std::cout << i << ": " << b[i] << "\n"; } } int main(int argc, char * argv[]) { // create a circular buffer of chars. SoDa::CircularBuffer<char> chbuf(8, '\000'); for(char c = 'a'; c < 'i'; c++) { chbuf.push(c); } dumpCBuf(chbuf); std::cout << "Push i\n"; chbuf.push('i'); dumpCBuf(chbuf); std::cout << "Push j to q\n"; for(char c = 'j'; c <= 'q'; c++) { chbuf.push(c); } dumpCBuf(chbuf); }
17.764706
46
0.536424
kb1vc
fc1894ecf2c63c99af1acbb69a72b0a20b3ba336
4,428
hpp
C++
miniFE-sycl/basic/optional/ThreadPool/src/TPI.hpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
692
2015-11-12T13:56:43.000Z
2022-03-30T03:45:59.000Z
miniFE-sycl/basic/optional/ThreadPool/src/TPI.hpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
1,096
2015-11-12T09:08:22.000Z
2022-03-31T21:48:41.000Z
miniFE-sycl/basic/optional/ThreadPool/src/TPI.hpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
224
2015-11-12T21:17:03.000Z
2022-03-30T00:57:48.000Z
/*------------------------------------------------------------------------*/ /* TPI: Thread Pool Interface */ /* Copyright (2008) Sandia Corporation */ /* */ /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ /* license for use of this work by or on behalf of the U.S. Government. */ /* */ /* This library is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU Lesser General Public License as */ /* published by the Free Software Foundation; either version 2.1 of the */ /* License, or (at your option) any later version. */ /* */ /* This library 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 */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ /* USA */ /*------------------------------------------------------------------------*/ /** * @author H. Carter Edwards <hcedwar@sandia.gov> */ #ifndef util_ThreadPool_hpp #define util_ThreadPool_hpp #include <TPI.h> namespace TPI { typedef TPI_Work Work ; //---------------------------------------------------------------------- /** Run worker.*method(work) on all threads. */ template<class Worker> int Run( Worker & worker , void (Worker::*method)(Work &) , int work_count , int lock_count = 0 ); //---------------------------------------------------------------------- inline int Lock( int n ) { return TPI_Lock( n ); } inline int Unlock( int n ) { return TPI_Unlock( n ); } /** Lock guard to insure that a lock is released * when control exists a block. * { * TPI::LockGuard local_lock( i ); * } */ class LockGuard { private: LockGuard(); LockGuard( const LockGuard & ); LockGuard & operator = ( const LockGuard & ); const int m_value ; const int m_result ; public: operator int() const { return m_result ; } explicit LockGuard( unsigned i_lock ) : m_value( i_lock ), m_result( TPI_Lock(i_lock) ) {} ~LockGuard() { TPI_Unlock( m_value ); } }; //---------------------------------------------------------------------- inline int Init( int n ) { return TPI_Init( n ); } inline int Finalize() { return TPI_Finalize(); } inline double Walltime() { return TPI_Walltime(); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- namespace { template<class Worker> class WorkerMethodHelper { private: WorkerMethodHelper(); WorkerMethodHelper( const WorkerMethodHelper & ); WorkerMethodHelper & operator = ( const WorkerMethodHelper & ); public: typedef void (Worker::*Method)( Work & ); Worker & worker ; Method method ; WorkerMethodHelper( Worker & w , Method m ) : worker(w), method(m) {} static void run( TPI_Work * work ) { try { const WorkerMethodHelper & wm = * reinterpret_cast<const WorkerMethodHelper*>(work->info); (wm.worker.*wm.method)(*work); } catch(...){} } }; } //---------------------------------------------------------------------- //---------------------------------------------------------------------- template<class Worker> inline int Run( Worker & worker, void (Worker::*method)(Work &) , int work_count , int lock_count ) { typedef WorkerMethodHelper<Worker> WM ; WM tmp( worker , method ); return TPI_Run( reinterpret_cast<TPI_work_subprogram>(& WM::run),&tmp,work_count,lock_count); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- } #endif
32.558824
95
0.467706
BeauJoh
fc1b8b35b7bf004252541f7e5231f4761118336a
5,871
cpp
C++
atto/tests/opencl/6-image-texture-gl/rop.cpp
ubikoo/libfish
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
[ "MIT" ]
null
null
null
atto/tests/opencl/6-image-texture-gl/rop.cpp
ubikoo/libfish
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
[ "MIT" ]
null
null
null
atto/tests/opencl/6-image-texture-gl/rop.cpp
ubikoo/libfish
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
[ "MIT" ]
null
null
null
/* * rop.cpp * * Copyright (c) 2020 Carlos Braga * * This program is free software; you can redistribute it and/or modify * it under the terms of the MIT License. * * See accompanying LICENSE.md or https://opensource.org/licenses/MIT. */ #include "rop.hpp" using namespace atto; /** * Rop static member variables. */ const std::string Rop::m_vertex_shader = std::string("data/image-viewer.vert"); const std::string Rop::m_fragment_shader = std::string("data/image-viewer.frag"); const std::string Rop::m_image_filename = std::string("../data/monarch_512.png"); const uint32_t Rop::m_image_channels = 4; /** * Rop::Rop * @brief Create the OpenCL/OpenGL render operator. */ Rop::Rop() { /* * Create the shader program object. */ { std::vector<GLuint> shaders{ gl::create_shader(GL_VERTEX_SHADER, m_vertex_shader), gl::create_shader(GL_FRAGMENT_SHADER, m_fragment_shader)}; m_program = gl::create_program(shaders); std::cout << gl::get_program_info(m_program) << "\n"; } /* * Load the 2d-image from the specified filename. */ { m_image = std::make_unique<gl::Image>( m_image_filename, true, m_image_channels); std::cout << m_image->infolog("Image attributes:") << "\n"; m_texture[0] = gl::create_texture2d( GL_RGBA8, /* texture internal format */ m_image->width(), /* texture width */ m_image->height(), /* texture height */ m_image->pixelformat(), /* pixel format */ GL_UNSIGNED_BYTE, /* pixel type */ m_image->bitmap()); /* pixel data */ glBindTexture(GL_TEXTURE_2D, m_texture[0]); gl::set_texture_mipmap( GL_TEXTURE_2D, GL_TRUE); /* generate mipmap */ gl::set_texture_wrap( GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, /* wrap_s */ GL_CLAMP_TO_EDGE); /* wrap_t */ gl::set_texture_filter( GL_TEXTURE_2D, GL_LINEAR, /* filter_min */ GL_LINEAR); /* filter_mag */ glBindTexture(GL_TEXTURE_2D, 0); m_texture[1] = gl::create_texture2d( GL_RGBA8, /* texture internal format */ m_image->width(), /* texture width */ m_image->height(), /* texture height */ m_image->pixelformat(), /* pixel format */ GL_UNSIGNED_BYTE, /* pixel type */ m_image->bitmap()); /* pixel data */ glBindTexture(GL_TEXTURE_2D, m_texture[1]); gl::set_texture_mipmap( GL_TEXTURE_2D, GL_TRUE); /* generate mipmap */ gl::set_texture_wrap( GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, /* wrap_s */ GL_CLAMP_TO_EDGE); /* wrap_t */ gl::set_texture_filter( GL_TEXTURE_2D, GL_LINEAR, /* filter_min */ GL_LINEAR); /* filter_mag */ glBindTexture(GL_TEXTURE_2D, 0); } /* * Create a mesh over a rectangle with screen size and * set the mesh vertex attributes in the program. */ { GLfloat aspect = (GLfloat) m_image->width() / m_image->height(); GLfloat xrange = aspect > 1.0 ? 1.0 : aspect; GLfloat yrange = aspect > 1.0 ? 1.0 / aspect : 1.0; m_mesh = gl::create_mesh_plane( m_program, /* program vertex attributes */ "quad", /* prefix name of the vertex attributes */ 2, /* n1 vertices */ 2, /* n2 vertices */ -xrange, /* xlo */ xrange, /* xhi */ -yrange, /* ylo */ yrange); /* yhi */ } } /** --------------------------------------------------------------------------- * Rop::handle * @brief Handle the event. */ void Rop::handle(const gl::Event &event) {} /** --------------------------------------------------------------------------- * Rop::draw * @brief Draw the render drawable. * Clear the OpenGL minimal buffer with a time varying minimal value. */ void Rop::draw(void *data) { GLFWwindow *window = gl::Renderer::window(); if (window == nullptr) { return; } /* * Control the polygon rasterization mode. * Specify the polygon face: GL_BACK, GL_FRONT, GL_FRONT_AND_BACK. * Specify the drawing mode: GL_POINT, GL_LINE, GL_FILL. */ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* * Control face culling. * Specify the face to cull: GL_BACK, GL_FRONT, GL_FRONT_AND_BACK. * Specify the face winding order: GL_CW, GL_CCW. * @see https://learnopengl.com/Advanced-OpenGL/Face-culling */ glDisable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); /* * Control depth testing. Comparison operators: * GL_ALWAYS, GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, * GL_GREATER, GL_NOTEQUAL, GL_GEQUAL. * @see https://learnopengl.com/Advanced-OpenGL/Depth-testing */ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); /* * Bind the shader program object. */ glUseProgram(m_program); /* * Set the texture sampler to the texture unit and bind the current * texture to its texturing target at the selected texture unit. */ GLenum texunit = 0; gl::set_uniform(m_program, "u_texsampler", GL_SAMPLER_2D, &texunit); glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, m_texture[1]); /* Draw the mesh */ m_mesh->draw(nullptr); /* Unbind the shader program object. */ glUseProgram(0); }
33.741379
81
0.548459
ubikoo
fc23adfe38b72667bd6f2184a26ade0cc9a20921
8,886
cc
C++
cpp/interface/interface.cc
yiskylee/NICE
bdd625bf431fe29919b39207ca20a06cc7399ff9
[ "MIT" ]
4
2016-04-28T14:17:58.000Z
2018-07-28T01:37:25.000Z
cpp/interface/interface.cc
yiskylee/NICE
bdd625bf431fe29919b39207ca20a06cc7399ff9
[ "MIT" ]
48
2016-05-04T12:47:02.000Z
2017-12-14T19:58:49.000Z
cpp/interface/interface.cc
yiskylee/NICE
bdd625bf431fe29919b39207ca20a06cc7399ff9
[ "MIT" ]
19
2016-05-03T14:22:42.000Z
2017-07-06T19:01:49.000Z
// The MIT License (MIT) // // Copyright (c) 2016 Northeastern University // // 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 <boost/python.hpp> #include <typeinfo> #include <memory> #include <cstring> #include <string> #include "include/matrix.h" #include "include/vector.h" #include "include/cpu_operations.h" #include "include/gpu_operations.h" #include "include/timer.h" #include "clustering/kdac_interface.h" #include "clustering/kmeans_interface.h" #include "clustering/spectral_interface.h" #include "interface/cpu_operations_interface.h" // void (Nice::KDACCPUInterface<float>::*Fit1Float) // (PyObject *, int row, int col) // = &Nice::KDACCPUInterface<float>::Fit; // void (Nice::KDACCPUInterface<float>::*Fit2Float)() // = &Nice::KDACCPUInterface<float>::Fit; // void (Nice::KDACCPUInterface<float>::*Fit3Float) // (PyObject *, int row_1, int col_1, // PyObject *, int row_2, int col_2) // = &Nice::KDACCPUInterface<float>::Fit; // // void (Nice::KDACGPUInterface<float>::*GPUFit1Float) // (PyObject *, int row, int col) // = &Nice::KDACGPUInterface<float>::Fit; // void (Nice::KDACGPUInterface<float>::*GPUFit2Float)() // = &Nice::KDACGPUInterface<float>::Fit; // void (Nice::KDACGPUInterface<float>::*GPUFit3Float) // (PyObject *, int row_1, int col_1, // // PyObject *, int row_2, int col_2) // = &Nice::KDACGPUInterface<float>::Fit; // // // void (Nice::KDACCPUInterface<double>::*Fit1Double) // (PyObject *, int row, int col) // = &Nice::KDACCPUInterface<double>::Fit; // void (Nice::KDACCPUInterface<double>::*Fit2Double)() // = &Nice::KDACCPUInterface<double>::Fit; // void (Nice::KDACCPUInterface<double>::*Fit3Double) // (PyObject *, int row_1, int col_1, // PyObject *, int row_2, int col_2) // = &Nice::KDACCPUInterface<double>::Fit; void (Nice::KDACInterface<float>::*Fit0Arg)() = &Nice::KDACInterface<float>::Fit; void (Nice::KDACInterface<float>::*Fit1Arg)(PyObject *, int, int) = &Nice::KDACInterface<float>::Fit; void (Nice::KDACInterface<float>::*Fit2Arg)(PyObject *, int, int, PyObject *, int, int) = &Nice::KDACInterface<float>::Fit; void (Nice::CPUOperationsInterface<float>::*Multiply0)(PyObject *, int, int, PyObject *, int, int, PyObject *) = &Nice::CPUOperationsInterface<float>::MultiplyMatrix; void (Nice::CPUOperationsInterface<float>::*Multiply1)(PyObject *, int, int, PyObject *, float) = &Nice::CPUOperationsInterface<float>::MultiplyMatrix; BOOST_PYTHON_MODULE(Nice4Py) { boost::python::class_<Nice::KDACInterface<float>> ("KDAC", boost::python::init<std::string>()) .def("Fit", Fit0Arg) .def("Fit", Fit1Arg) .def("Fit", Fit2Arg) .def("SetupParams", &Nice::KDACInterface<float>::SetupParams) .def("Predict", &Nice::KDACInterface<float>::Predict) .def("GetProfiler", &Nice::KDACInterface<float>::GetProfiler) .def("GetTimePerIter", &Nice::KDACInterface<float>::GetTimePerIter) .def("GetQ", &Nice::KDACInterface<float>::GetQ) .def("GetD", &Nice::KDACInterface<float>::GetD) .def("GetN", &Nice::KDACInterface<float>::GetN) .def("GetK", &Nice::KDACInterface<float>::GetK) .def("GetW", &Nice::KDACInterface<float>::GetW) .def("GetU", &Nice::KDACInterface<float>::GetU) .def("SetW", &Nice::KDACInterface<float>::SetW) .def("DiscardLastRun", &Nice::KDACInterface<float>::DiscardLastRun); boost::python::class_<Nice::CPUOperationsInterface<float>>("CPUOp") .def("GenKernelMatrix", &Nice::CPUOperationsInterface<float>::GenKernelMatrix) .staticmethod("GenKernelMatrix") .def("MultiplyMatrix", Multiply0) .def("MultiplyMatrix", Multiply1) .def("InverseMatrix", &Nice::CPUOperationsInterface<float>::InverseMatrix) .def("NormMatrix", &Nice::CPUOperationsInterface<float>::NormMatrix) .def("CenterMatrix", &Nice::CPUOperationsInterface<float>::CenterMatrix) .def("NormalizeMatrix", &Nice::CPUOperationsInterface<float>::NormalizeMatrix) .def("StandardDeviationMatrix", &Nice::CPUOperationsInterface<float>::StandardDeviationMatrix); boost::python::class_<Nice::KmeansInterface<float>> ("KMean", boost::python::init<std::string>()) .def("fit", &Nice::KmeansInterface<float>::fit) .def("getLabels", &Nice::KmeansInterface<float>::getLabels) .def("getCenters", &Nice::KmeansInterface<float>::getCenters) .def("predict", &Nice::KmeansInterface<float>::predict); boost::python::class_<Nice::SpectralInterface<float>> ("Spectral") .def("Fit", &Nice::SpectralInterface<float>::Fit) .def("GetLabels", &Nice::SpectralInterface<float>::GetLabels) .def("SetSigma", &Nice::SpectralInterface<float>::SetSigma) .def("FitPredict", &Nice::SpectralInterface<float>::FitPredict); // boost::python::class_<Nice::CpuOperationsInterface<float>::GenKernelMatrix } // //Use float by default // boost::python::class_<Nice::KDACCPUInterface<float>> // ("KDACCPU", boost::python::init<>()) // .def("Fit", Fit1Float) // .def("Fit", Fit2Float) // .def("Fit", Fit3Float) // .def("SetupParams", &Nice::KDACCPUInterface<float>::SetupParams) // .def("Predict", &Nice::KDACCPUInterface<float>::Predict) // .def("GetProfiler", &Nice::KDACCPUInterface<float>::GetProfiler) // .def("GetW", &Nice::KDACCPUInterface<float>::GetW) // .def("GetD", &Nice::KDACCPUInterface<float>::GetD) // .def("GetN", &Nice::KDACCPUInterface<float>::GetN) // .def("GetQ", &Nice::KDACCPUInterface<float>::GetQ) // .def("GetTimePerIter", &Nice::KDACCPUInterface<float>::GetTimePerIter); // // //Use float by default // boost::python::class_<Nice::KDACGPUInterface<float>> // ("KDACGPU", boost::python::init<>()) // .def("Fit", GPUFit1Float) // .def("Fit", GPUFit2Float) // .def("Fit", GPUFit3Float) // .def("SetupParams", &Nice::KDACGPUInterface<float>::SetupParams) // .def("Predict", &Nice::KDACGPUInterface<float>::Predict) // .def("GetProfiler", &Nice::KDACGPUInterface<float>::GetProfiler) // .def("GetW", &Nice::KDACGPUInterface<float>::GetW) // .def("GetD", &Nice::KDACGPUInterface<float>::GetD) // .def("GetN", &Nice::KDACGPUInterface<float>::GetN) // .def("GetQ", &Nice::KDACGPUInterface<float>::GetQ) // .def("GetTimePerIter", &Nice::KDACGPUInterface<float>::GetTimePerIter); // // // boost::python::class_<Nice::KDACCPUInterface<double>> // ("KDACDOUBLE", boost::python::init<>()) // .def("Fit", Fit1Double) // .def("Fit", Fit2Double) // .def("Fit", Fit3Double) // .def("SetupParams", &Nice::KDACCPUInterface<double>::SetupParams) // .def("Predict", &Nice::KDACCPUInterface<double>::Predict) // .def("GetProfiler", &Nice::KDACCPUInterface<double>::GetProfiler) // .def("GetW", &Nice::KDACCPUInterface<double>::GetW) // .def("GetD", &Nice::KDACCPUInterface<double>::GetD) // .def("GetN", &Nice::KDACCPUInterface<double>::GetN) // .def("GetQ", &Nice::KDACCPUInterface<double>::GetQ) // .def("GetTimePerIter", &Nice::KDACCPUInterface<double>::GetTimePerIter); //} // Explicit Instantiation // template // class Nice::KDACInterface<float>; // template // class Nice::KDACInterface<double>; // template // class Nice::KDACCPUInterface<float>; // template // class Nice::KDACCPUInterface<double>; // template // class Nice::KDACGPUInterface<float>; // template // class Nice::KDACGPUInterface<double>;
45.804124
80
0.651249
yiskylee
fc26f206c46766099a22684bcdaf164b1542a32f
17,104
hpp
C++
src/cpu/sm83_op_codes.hpp
joelghill/LameBoy
66653070f4aefc03fac651dbf741465c3bb9bd76
[ "Apache-2.0" ]
null
null
null
src/cpu/sm83_op_codes.hpp
joelghill/LameBoy
66653070f4aefc03fac651dbf741465c3bb9bd76
[ "Apache-2.0" ]
null
null
null
src/cpu/sm83_op_codes.hpp
joelghill/LameBoy
66653070f4aefc03fac651dbf741465c3bb9bd76
[ "Apache-2.0" ]
null
null
null
/** * @brief Definitions for C++ implementation of all SM83 Op Codes * */ #ifndef SM83_OP_CODES_H #define SM83_OP_CODES_H #include <iostream> #include "./sm83_state.hpp" using namespace std; /** * @brief Adds a number to a SM83 register * * @param state The SM83 state object to operate on * @param reg_getter The getter for the register value * @param reg_setter The setter for the register value * @param value The value to add to the register * @post F register is updated with CPU flags */ void AddToRegister(SM83State* state, uint8_t (SM83State::*reg_getter)(), void (SM83State::*reg_setter)(uint8_t), uint8_t value); /** * @brief Adds a number to a 16bit SM83 register * * @param state The SM83 state object to operate on * @param reg_getter The getter for the register value * @param reg_setter The setter for the register value * @param value The value to add to the register * @post F register is updated with CPU flags. H and C carry flags are updated */ void AddToRegister(SM83State* state, uint16_t (SM83State::*reg_getter)(), void (SM83State::*reg_setter)(uint16_t), uint16_t value); /** * @brief Adds a number to a value saved in a memory address * * @param state The SM83 state object to operate on * @param address The address of the value to add to * @param value The value to add to the memory value * @post F register is updated with CPU flags. H and C carry flags are updated */ void AddToMemoryLocation(SM83State* state, uint16_t address, uint8_t value); /** * @brief Subtracts a number from a SM83 register * * @param state The SM83 state object to operate on * @param reg_getter The getter for the register value * @param reg_setter The setter for the register value * @param value The value to subtract from the register * @post F register is updated with CPU flags */ void SubFromRegister(SM83State* state, uint8_t (SM83State::*reg_getter)(), void (SM83State::*reg_setter)(uint8_t), uint8_t value); /** * @brief Subtracts a number from a value stored at a memory address * * @param state The SM83 state object to operate on * @param address The address of the value to add to * @param value The value to substract from the memory value * @post F register is updated with CPU flags */ void SubFromMemoryLocation(SM83State* state, uint16_t address, uint8_t value); /** * @brief Rotates the provided register to the right * * @param state The SM83 State to operate on * @param reg_getter The getter for the register to rotate * @param reg_setter The setter for the register to rotate * @param through_carry A value indicating whether or not the carry flag rotates into the register */ void RotateRight(SM83State* state, uint8_t (SM83State::*reg_getter)(), void (SM83State::*reg_setter)(uint8_t), bool through_carry); /** * @brief Rotates the provided register to the left * * @param state The SM83 State to operate on * @param reg_getter The getter for the register to rotate * @param reg_setter The setter for the register to rotate * @param through_carry A value indicating whether or not the carry flag rotates into the register */ void RotateLeft(SM83State* state, uint8_t (SM83State::*reg_getter)(), void (SM83State::*reg_setter)(uint8_t), bool through_carry); /** * @brief NOP * * Moves the program counter forward 1 byte * * @param state The SM83 State to operate on * @return uint8_t The number of CPU cycles */ uint8_t Execute00(SM83State* state); /** * @brief LD BC, d16 - Load the immediate 2 bytes in memory after the program counter into BC * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute01(SM83State* state); /** * @brief LD DE, d16 - Load the immediate 2 bytes in memory after the program counter into DE * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute11(SM83State* state); /** * @brief LD HL, d16 - Load the immediate 2 bytes in memory after the program counter into HL * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute21(SM83State* state); /** * @brief LD SP, d16 - Load the immediate 2 bytes in memory after the program counter into SP * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute31(SM83State* state); /** * @brief LD (BC), A - Load the 8bit value stored in register A into memory at the address stored in BC * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute02(SM83State* state); /** * @brief LD (DE), A - Load the 8bit value stored in register A into memory at the address stored in DE * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute12(SM83State* state); /** * @brief LD (HL+), A - Load the 8bit value stored in register A into memory at the address stored in HL * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) * @post HL = HL + 1 */ uint8_t Execute22(SM83State* state); /** * @brief LD (HL-),A - Load the 8bit value stored in register A into memory at the address stored in HL * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) * @post HL = HL - 1 */ uint8_t Execute32(SM83State* state); /** * @brief INC BC - Increment BC by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute03(SM83State* state); /** * @brief INC DE - Increment DE by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute13(SM83State* state); /** * @brief INC HL - Increment HL by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute23(SM83State* state); /** * @brief INC SP - Increment Stack Pointer by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute33(SM83State* state); /** * @brief INC B - Increment B by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute04(SM83State* state); /** * @brief INC D - Increment D by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute14(SM83State* state); /** * @brief INC H - Increment H by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute24(SM83State* state); /** * @brief INC (HL) - Increment number stored at the address in HL by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute34(SM83State* state); /** * @brief DEC B - Decrement B by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute05(SM83State* state); /** * @brief DEC D - Decrement D by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute15(SM83State* state); /** * @brief DEC H - Decrement H by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute25(SM83State* state); /** * @brief DEC (HL) - Decrement value at the memory address stored in HL by one * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) * @post Z, H, N flags set by function. C flag unaffected. */ uint8_t Execute35(SM83State* state); /** * @brief LD B, d8 - Loads the immediate 8 bits after the PC into the B register * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute06(SM83State* state); /** * @brief LD D, d8 - Loads the immediate 8 bits after the PC into the D register * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute16(SM83State* state); /** * @brief LD H, d8 - Loads the immediate 8 bits after the PC into the H register * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute26(SM83State* state); /** * @brief LD (HL), d8 - Loads the immediate 8 bits after the PC into the memory at address HL * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute36(SM83State* state); /** * @brief RLCA - Rotates the accumulator to the left * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set to 0. C flag set by function. */ uint8_t Execute07(SM83State* state); /** * @brief RLA - Rotates the accumulator to the left through the carry flag * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set to 0. C flag set by function. */ uint8_t Execute17(SM83State* state); /** * @brief DAA - Decimal adjust accumulator. * * The DAA instruction adjusts the results of a binary addition or subtraction (as stored in the accumulator and flags) * to retroactively turn it into a BCD addition or subtraction. It does so by adding or subtracting 6 from the result's upper nybble, * lower nybble, or both. * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4). * @post F flags are set as needed */ uint8_t Execute27(SM83State* state); /** * @brief Sets the carry flag * * @param state The current state to operate on * @return uint8_t 4 * @post F flags are set as needed: - 0 0 1 */ uint8_t Execute37(SM83State* state); /** * @brief LD (a16), SP - Put the stack pointer into the next two bytes * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (20) */ uint8_t Execute08(SM83State* state); /** * @brief JR r8 - relative jump to PC + signed digit. PC=PC+/-r8 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12) */ uint8_t Execute18(SM83State* state); /** * @brief JR Z, r8 - conditional relative jump to PC + signed digit if Z is True. PC=PC+/-r8 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12/8) */ uint8_t Execute28(SM83State* state); /** * @brief JR C, r8 - conditional relative jump to PC + signed digit if C is True. PC=PC+/-r8 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (12/8) */ uint8_t Execute38(SM83State* state); /** * @brief ADD HL, BC - Add register BC to HL * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute09(SM83State* state); /** * @brief ADD HL, DE - Add register DE to HL * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute19(SM83State* state); /** * @brief ADD HL, HL - Add register HL to HL * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute29(SM83State* state); /** * @brief LD A, (BC) - Load the value at address BC into register A * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute0A(SM83State* state); /** * @brief LD A, (DE) - Load the value at address DE into register A * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute1A(SM83State* state); /** * @brief LD A,(HL+) - Load the value at address HL into register A. Increment HL * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute2A(SM83State* state); /** * @brief DEC BC - Decrement Register BC by 1 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute0B(SM83State* state); /** * @brief DEC DE - Decrement Register DE by 1 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute1B(SM83State* state); /** * @brief DEC HL - Decrement Register HL by 1 * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute2B(SM83State* state); /** * @brief INC C - Increment C by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute0C(SM83State* state); /** * @brief INC E - Increment E by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute1C(SM83State* state); /** * @brief INC L - Increment L by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute2C(SM83State* state); /** * @brief DEC C - Decrement C by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute0D(SM83State* state); /** * @brief DEC E - Decrement D by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute1D(SM83State* state); /** * @brief DEC L - Decrement L by one * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) */ uint8_t Execute2D(SM83State* state); /** * @brief LD C, d8 - Load immediate 8 bits into register C * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute0E(SM83State* state); /** * @brief LD E, d8 - Load immediate 8 bits into register E * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute1E(SM83State* state); /** * @brief LD L, d8 - Load immediate 8 bits into register L * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (8) */ uint8_t Execute2E(SM83State* state); /** * @brief RRCA - Rotates the accumulator to the right * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set to 0. C flag set by function. */ uint8_t Execute0F(SM83State* state); /** * @brief RRA - Rotates the accumulator to the right through the carry flag * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z, H, N flags set to 0. C flag set by function. */ uint8_t Execute1F(SM83State* state); /** * @brief CPL - A = A xor FF * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation (4) * @post Z N H C (- 1 1 -) */ uint8_t Execute2F(SM83State* state); /** * @brief JR NZ, r8 - Conditional relative jump if the zero flag is not set * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation. 12 if jump, 8 otherwise * @post PC = PC + r8 */ uint8_t Execute20(SM83State* state); /** * @brief JR NC, r8 - Conditional relative jump if the carry flag is not set * * @param state The current state to operate on * @return uint8_t The number of cpu cycles to perform operation. 12 if jump, 8 otherwise * @post PC = PC + r8 */ uint8_t Execute30(SM83State* state); #endif
31.851024
133
0.714745
joelghill
fc35a8035f422644adc069489a37d14ac2c7bc40
3,900
hpp
C++
logos/epoch/archiver.hpp
LogosNetwork/logos-core
6b155539a734efefb8f649a761d044b5f267a51a
[ "BSD-2-Clause" ]
3
2020-01-17T18:05:19.000Z
2021-12-29T04:21:59.000Z
logos/epoch/archiver.hpp
LogosNetwork/logos-core
6b155539a734efefb8f649a761d044b5f267a51a
[ "BSD-2-Clause" ]
null
null
null
logos/epoch/archiver.hpp
LogosNetwork/logos-core
6b155539a734efefb8f649a761d044b5f267a51a
[ "BSD-2-Clause" ]
2
2020-12-22T05:51:53.000Z
2021-06-08T00:27:46.000Z
/// /// @file /// This file contains declaration of the Archiver class - container for epoch/microblock handling related classes /// #pragma once #include <logos/microblock/microblock_handler.hpp> #include <logos/consensus/primary_delegate.hpp> #include <logos/epoch/epoch_voting_manager.hpp> #include <logos/epoch/event_proposer.hpp> #include <logos/epoch/epoch_handler.hpp> class InternalConsensus; class IRecallHandler; class MicroBlockTester; class MicroBlockMessageHandler; namespace logos { class alarm; class block_store; class IBlockCache; } class ArchiverMicroBlockHandler { public: using EpochConsensusCb = std::function<logos::process_return(std::shared_ptr<Epoch>)>; ArchiverMicroBlockHandler() = default; virtual ~ArchiverMicroBlockHandler() = default; virtual void OnApplyUpdates(const ApprovedMB &) = 0; }; /// Container for Epoch/MicroBlock handling, Event proposing, Voting manager, and /// Recall handler /// Archiver /// - starts MicroBlock and Epoch Transition timers /// - provides database update handler via IArchiverMicroBlockHandler /// - ties handlers to EventProposer; i.e. when the last MicroBlock is committed to /// the database, the archiver calls EventProposer::ProposeEpoch to start /// creation of the Epoch block /// - interfaces to VotingManager to validate delegates in the proposed Epoch block /// and fetch delegates for the proposed Epoch block /// - interfaces to recall handler to check whether a recall happened in the /// current epoch class Archiver : public ArchiverMicroBlockHandler { friend MicroBlockTester; public: /// Class constructor /// @param[in] alarm logos alarm reference /// @param[in] store logos block_store reference /// @param[in] event proposer reference /// @param[in] recall recall handler interface reference /// @param[in] block cache interface reference Archiver(logos::alarm &, BlockStore &, EventProposer &, IRecallHandler &, logos::IBlockCache &); ~Archiver() = default; /// Start archiving events /// @param internal consensus interface reference void Start(InternalConsensus&); // Stop archiving events (epoch transition event still continues) void Stop(); /// Commit micro block to the database, propose epoch /// @param block to commit void OnApplyUpdates(const ApprovedMB &block) override; /// Is Recall /// @returns true if recall bool IsRecall(); EpochHandler & GetEpochHandler(); private: static constexpr uint8_t SELECT_PRIMARY_DELEGATE = 0x1F; /// Used by MicroBlockTester to start microblock generation /// @param[in] consensus send microblock for consensus /// @param[in] last_microblock last microblock flag void Test_ProposeMicroBlock(InternalConsensus&, bool last_microblock); /// Archive MicroBlock, if a new one should be built /// This method is passed to EventProposer as a scheduled action /// @param internal consensus interface reference void ArchiveMB(InternalConsensus &); /// Should we skip building a new MB? /// This method is called by ArchiveMB /// @return true if we should skip build and proposal, either because we are behind /// or an ongoing MB consensus session is not finished bool ShouldSkipMBBuild(); EpochSeq _counter; ///< indicates the most recently BUILT MB's <epoch number, sequence number> EpochVotingManager _voting_manager; EventProposer & _event_proposer; MicroBlockHandler _micro_block_handler; EpochHandler _epoch_handler; MicroBlockMessageHandler & _mb_message_handler; IRecallHandler & _recall_handler; logos::block_store & _store; logos::IBlockCache & _block_cache; Log _log; friend class Archival_ShouldSkipMBProposal_Test; };
36.111111
123
0.717949
LogosNetwork
fc38e19fb62c2162c831c11ccc8acf439d5edc36
2,013
cc
C++
src/desugar/test-bounds-checking.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-bounds-checking.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-bounds-checking.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
// Checking bounds checking. #include <ostream> #include <string> #include <ast/all.hh> #include <ast/libast.hh> #include <bind/libbind.hh> #include <desugar/bounds-checking-visitor.hh> #include <parse/libparse.hh> #include <type/libtype.hh> using namespace ast; using namespace desugar; const char* program_name = "test-bounds-checking"; static void test_bounds_checking(ast::Ast& tree) { bind::bind(tree); type::types_check(tree); std::cout << "/* === Original tree... */\n" << tree << '\n'; BoundsCheckingVisitor bounds_checks_add; bounds_checks_add(tree); std::cout << "/* === AST with bounds checks... */\n" << *bounds_checks_add.result_get() << '\n'; delete bounds_checks_add.result_get(); std::cout << std::endl; } int main() { // Minimal built-in function requirements. std::string builtins = " primitive print_err(string: string)" " primitive exit(status: int)" " type strings = array of string" " var forty_twos := strings [42] of \"forty-two\""; // A single exp. { std::cout << "First test...\n"; Exp* tree = parse::parse(parse::Tweast() << " let" << " " << builtins << " in" << " forty_twos[0]" << " end"); test_bounds_checking(*tree); delete tree; tree = nullptr; } // Using a _main function. { std::cout << "Second test...\n"; ChunkList* tree = parse::parse(parse::Tweast() << builtins << " function _main() =" " (" " forty_twos[0];" " ()" " )"); test_bounds_checking(*tree); delete tree; tree = nullptr; } }
29.602941
76
0.474913
MrMaDGaME
fc392a57652d69714a97b7dc32dca945c00b2885
596
cpp
C++
openjudge/01/13/15.cpp
TheBadZhang/OJ
b5407f2483aa630068343b412ecaf3a9e3303f7e
[ "Apache-2.0" ]
1
2020-07-22T16:54:07.000Z
2020-07-22T16:54:07.000Z
openjudge/01/13/15.cpp
TheBadZhang/OJ
b5407f2483aa630068343b412ecaf3a9e3303f7e
[ "Apache-2.0" ]
1
2018-05-12T12:53:06.000Z
2018-05-12T12:53:06.000Z
openjudge/01/13/15.cpp
TheBadZhang/OJ
b5407f2483aa630068343b412ecaf3a9e3303f7e
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <vector> struct N { long long int n; int times; }; int main () { std::vector <N> l; long long int a; int n, max = 0, maxn; std::cin >> n; for (int b = 0; b < n; b += 1) { std::cin >> a; bool flag = true; for (int c = 0; c < l.size (); c += 1) { if (l [c].n == a) { l [c].times += 1; flag = false; } } if (flag) { l.push_back ({a, 1}); // l [l.size () - 1].times = 1; } } for (int b = 0; b < l.size (); b += 1) { if (l [b].times > max) { max = l [b].times; maxn = b; } } std::cout << l [maxn].n; return 0; }
15.282051
42
0.449664
TheBadZhang
fc39a0f65b1e21160a628e12abe4f4a3774a9bdd
24,864
cpp
C++
src/towns/crtc/crtc.cpp
Artanejp/TOWNSEMU
72ccc5588314de210cd8b77fe7f42b92ed79bed9
[ "BSD-3-Clause" ]
null
null
null
src/towns/crtc/crtc.cpp
Artanejp/TOWNSEMU
72ccc5588314de210cd8b77fe7f42b92ed79bed9
[ "BSD-3-Clause" ]
null
null
null
src/towns/crtc/crtc.cpp
Artanejp/TOWNSEMU
72ccc5588314de210cd8b77fe7f42b92ed79bed9
[ "BSD-3-Clause" ]
null
null
null
/* LICENSE>> Copyright 2020 Soji Yamakawa (CaptainYS, http://www.ysflight.com) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. << LICENSE */ #include <iostream> #include <algorithm> #include "cpputil.h" #include "crtc.h" #include "sprite.h" #include "towns.h" #include "townsdef.h" void TownsCRTC::AnalogPalette::Reset(void) { codeLatch=0; for(int i=0; i<2; ++i) { plt16[i][ 0].Set( 0, 0, 0); plt16[i][ 1].Set( 0, 0,128); plt16[i][ 2].Set(128, 0, 0); plt16[i][ 3].Set(128, 0,128); plt16[i][ 4].Set( 0,128, 0); plt16[i][ 5].Set( 0,128,128); plt16[i][ 6].Set(128,128, 0); plt16[i][ 7].Set(128,128,128); plt16[i][ 8].Set( 0, 0, 0); plt16[i][ 9].Set( 0, 0,255); plt16[i][10].Set(255, 0, 0); plt16[i][11].Set(255, 0,255); plt16[i][12].Set( 0,255, 0); plt16[i][13].Set( 0,255,255); plt16[i][14].Set(255,255, 0); plt16[i][15].Set(255,255,255); } for(int i=0; i<256; ++i) { plt256[i].Set(255,255,255); } } void TownsCRTC::AnalogPalette::Set16(unsigned int page,unsigned int component,unsigned char v) { v=v&0xF0; v|=(v>>4); plt16[page][codeLatch&0x0F].v[component]=v; } void TownsCRTC::AnalogPalette::Set256(unsigned int component,unsigned char v) { plt256[codeLatch].v[component]=v; } void TownsCRTC::AnalogPalette::SetRed(unsigned char v,unsigned int PLT) { switch(PLT) { case 0: // 16-color paletter Layer 0 Set16(0,0,v); break; case 2: // 16-color paletter Layer 1 Set16(1,0,v); break; case 1: // 256-color paletter case 3: // 256-color paletter Set256(0,v); break; } } void TownsCRTC::AnalogPalette::SetGreen(unsigned char v,unsigned int PLT) { switch(PLT) { case 0: // 16-color paletter Layer 0 Set16(0,1,v); break; case 2: // 16-color paletter Layer 1 Set16(1,1,v); break; case 1: // 256-color paletter case 3: // 256-color paletter Set256(1,v); break; } } void TownsCRTC::AnalogPalette::SetBlue(unsigned char v,unsigned int PLT) { switch(PLT) { case 0: // 16-color paletter Layer 0 Set16(0,2,v); break; case 2: // 16-color paletter Layer 1 Set16(1,2,v); break; case 1: // 256-color paletter case 3: // 256-color paletter Set256(2,v); break; } } unsigned char TownsCRTC::AnalogPalette::Get16(unsigned int page,unsigned int component) const { return plt16[page][codeLatch&0x0F][component]; } unsigned char TownsCRTC::AnalogPalette::Get256(unsigned int component) const { return plt256[codeLatch][component]; } unsigned char TownsCRTC::AnalogPalette::GetRed(unsigned int PLT) const { switch(PLT) { case 0: // 16-color paletter Layer 0 return Get16(0,0); case 2: // 16-color paletter Layer 1 return Get16(1,0); case 1: // 256-color paletter case 3: // 256-color paletter return Get256(0); } return 0; } unsigned char TownsCRTC::AnalogPalette::GetGreen(unsigned int PLT) const { switch(PLT) { case 0: // 16-color paletter Layer 0 return Get16(0,1); case 2: // 16-color paletter Layer 1 return Get16(1,1); case 1: // 256-color paletter case 3: // 256-color paletter return Get256(1); } return 0; } unsigned char TownsCRTC::AnalogPalette::GetBlue(unsigned int PLT) const { switch(PLT) { case 0: // 16-color paletter Layer 0 return Get16(0,2); case 2: // 16-color paletter Layer 1 return Get16(1,2); case 1: // 256-color paletter case 3: // 256-color paletter return Get256(2); } return 0; } //////////////////////////////////////////////////////////// void TownsCRTC::State::Reset(void) { DPMD=false; for(auto &i : FMRPalette) { i=(unsigned int)(&i-FMRPalette); } unsigned int defCRTCReg[32]= { 0x0040,0x0320,0x0000,0x0000,0x035F,0x0000,0x0010,0x0000,0x036F,0x009C,0x031C,0x009C,0x031C,0x0040,0x0360,0x0040, 0x0360,0x0000,0x009C,0x0000,0x0050,0x0000,0x009C,0x0000,0x0050,0x004A,0x0001,0x0000,0x003F,0x0003,0x0000,0x0150, }; for(int i=0; i<32; ++i) { crtcReg[i]=defCRTCReg[i]; } crtcAddrLatch=0; unsigned char defSifter[4]={0x15,0x08,0,0}; for(int i=0; i<4; ++i) { sifter[i]=defSifter[i]; } sifterAddrLatch=0; for(auto &d : mxVideoOutCtrl) { d=0; } mxVideoOutCtrlAddrLatch=0; showPage[0]=true; showPage[1]=true; palette.Reset(); } void TownsCRTC::TurnOffVSYNCIRQ(void) { state.VSYNCIRQ=false; townsPtr->pic.SetInterruptRequestBit(TOWNSIRQ_VSYNC,false); } void TownsCRTC::TurnOnVSYNCIRQ(void) { state.VSYNCIRQ=true; townsPtr->pic.SetInterruptRequestBit(TOWNSIRQ_VSYNC,true); } TownsCRTC::ScreenModeCache::ScreenModeCache() { MakeFMRCompatible(); } void TownsCRTC::ScreenModeCache::MakeFMRCompatible(void) { numLayers=2; layer[0].VRAMAddr=0; layer[0].bitsPerPixel=4; layer[0].sizeOnMonitor=Vec2i::Make(640,400); layer[0].bytesPerLine=320; layer[1].VRAMAddr=0x40000; layer[1].bitsPerPixel=4; layer[1].sizeOnMonitor=Vec2i::Make(640,400); layer[1].bytesPerLine=512; } //////////////////////////////////////////////////////////// TownsCRTC::TownsCRTC(class FMTowns *ptr,TownsSprite *spritePtr) : Device(ptr) { this->townsPtr=ptr; this->spritePtr=spritePtr; state.mxVideoOutCtrl.resize(0x10000); state.Reset(); CLKSELtoFreq[0]=28636; // 28636KHz CLKSELtoFreq[1]=24545; // 24545KHz CLKSELtoFreq[2]=25175; // 25175KHz CLKSELtoFreq[3]=21052; // 21052KHz // Tentatively cached=true; } void TownsCRTC::UpdateSpriteHardware(void) { if(true==spritePtr->SpriteActive()) { if(true==InSinglePageMode() || 16!=GetPageBitsPerPixel(1) || 512!=GetPageBytesPerLine(1)) { spritePtr->Stop(); } } } // Let's say 60 frames per sec. // 1 frame takes 16.7ms. // Horizontal Scan frequency is say 31KHz. // 1 line takes 0.032ms. // 480 lines take 15.36ms. // Then, VSYNC should be 1.34ms long. // Will take screenmode into account eventually. // Also should take HSYNC into account. bool TownsCRTC::InVSYNC(const unsigned long long int townsTime) const { auto intoFrame=townsTime%VSYNC_CYCLE; return (CRT_VERTICAL_DURATION<intoFrame); } bool TownsCRTC::InHSYNC(const unsigned long long int townsTime) const { auto intoFrame=townsTime%VSYNC_CYCLE; if(intoFrame<CRT_VERTICAL_DURATION) { auto intoLine=intoFrame%HSYNC_CYCLE; return (CRT_HORIZONTAL_DURATION<intoLine); } return false; } bool TownsCRTC::InSinglePageMode(void) const { return (0==(state.sifter[0]&0x10)); } unsigned int TownsCRTC::GetBaseClockFreq(void) const { auto CLKSEL=state.crtcReg[REG_CR1]&3; static const unsigned int freqTable[4]= { 28636300, 24545400, 25175000, 21052500, }; return freqTable[CLKSEL]; } unsigned int TownsCRTC::GetBaseClockScaler(void) const { auto SCSEL=state.crtcReg[REG_CR1]&0x0C; return (SCSEL>>1)+2; } Vec2i TownsCRTC::GetPageZoom(unsigned char page) const { Vec2i zoom; auto pageZoom=(state.crtcReg[REG_ZOOM]>>(8*page)); zoom.x()=(( pageZoom &15)+1); zoom.y()=(((pageZoom>>4)&15)+1); // I'm not sure if this logic is correct. This doesn't cover screen mode 16. if(15==GetHorizontalFrequency()) { if(true==InSinglePageMode()) { zoom[0]/=2; } else { zoom[0]/=2; zoom[1]*=2; } } return zoom; } Vec2i TownsCRTC::GetPageOriginOnMonitor(unsigned char page) const { int x0,y0; static const int reg[4]= { REG_HDS0,REG_VDS0, REG_HDS1,REG_VDS1, }; auto HDS=reg[page*2]; auto VDS=reg[page*2+1]; switch(CLKSEL()) { case 0: x0=(state.crtcReg[HDS]-0x129)>>1; y0=(state.crtcReg[VDS]-0x2a)>>1; // I'm not sure if I should divide by 2. Will need experiments. break; case 1: x0=(state.crtcReg[HDS]-0xe7)>>1; y0=(state.crtcReg[VDS]-0x2a)>>1; // I'm not sure if I should divide by 2. Will need experiments. break; case 2: x0=(state.crtcReg[HDS]-0x8a); y0=(state.crtcReg[VDS]-0x46); break; case 3: x0=(state.crtcReg[HDS]-0x9c); y0=(state.crtcReg[VDS]-0x40); break; default: x0=0; y0=0; break; } return Vec2i::Make(x0,y0); } Vec2i TownsCRTC::GetPageSizeOnMonitor(unsigned char page) const { auto KHz=GetHorizontalFrequency(); auto wid=state.crtcReg[REG_HDE0+page*2]-state.crtcReg[REG_HDS0+page*2]; auto hei=state.crtcReg[REG_VDE0+page*2]-state.crtcReg[REG_VDS0+page*2]; if(15==KHz) { wid/=2; hei*=2; } if(0==state.crtcReg[REG_FO0+4*page]) { hei/=2; } return Vec2i::Make(wid,hei); } Vec2i TownsCRTC::GetPageVRAMCoverageSize1X(unsigned char page) const { auto wid=state.crtcReg[REG_HDE0+page*2]-state.crtcReg[REG_HDS0+page*2]; auto hei=state.crtcReg[REG_VDE0+page*2]-state.crtcReg[REG_VDS0+page*2]; auto FO=state.crtcReg[REG_FO0+4*page]; if(0==FO) { hei/=2; } return Vec2i::Make(wid,hei); } unsigned int TownsCRTC::GetPageBitsPerPixel(unsigned char page) const { const unsigned int CL=(state.crtcReg[REG_CR0]>>(page*2))&3; if(true==InSinglePageMode()) { if(2==CL) { return 16; } else if(3==CL) { return 8; } } else { if(1==CL) { return 16; } else if(3==CL) { return 4; } } std::cout << __FUNCTION__ << std::endl; std::cout << "Unknown color setting." << std::endl; return 4; // What else can I do? } unsigned int TownsCRTC::GetPageVRAMAddressOffset(unsigned char page) const { // [2] pp. 145 auto FA0=state.crtcReg[REG_FA0+page*4]; switch(GetPageBitsPerPixel(page)) { case 4: return FA0*4; // 8 pixels for 1 count. case 8: return FA0*8; // 8 pixels for 1 count. case 16: return (InSinglePageMode() ? FA0*8 : FA0*4); // 4 pixels or 2 pixels depending on the single-page or 2-page mode. } return 0; } unsigned int TownsCRTC::GetPriorityPage(void) const { return state.sifter[1]&1; } unsigned int TownsCRTC::GetPageBytesPerLine(unsigned char page) const { auto FOx=state.crtcReg[REG_FO0+page*4]; auto LOx=state.crtcReg[REG_LO0+page*4]; auto numBytes=(LOx-FOx)*4; if(true==InSinglePageMode()) { numBytes*=2; } return numBytes; } void TownsCRTC::MakePageLayerInfo(Layer &layer,unsigned char page) const { page&=1; layer.bitsPerPixel=GetPageBitsPerPixel(page); layer.originOnMonitor=GetPageOriginOnMonitor(page); layer.sizeOnMonitor=GetPageSizeOnMonitor(page); layer.VRAMCoverage1X=GetPageVRAMCoverageSize1X(page); layer.zoom=GetPageZoom(page); layer.VRAMAddr=0x40000*page; layer.VRAMOffset=GetPageVRAMAddressOffset(page); layer.bytesPerLine=GetPageBytesPerLine(page); if(512==layer.bytesPerLine || 1024==layer.bytesPerLine) { layer.HScrollMask=layer.bytesPerLine-1; } else { layer.HScrollMask=0xFFFFFFFF; } if(true==InSinglePageMode() && 0==page) { layer.VScrollMask=0x7FFFF; } else { layer.VScrollMask=0x3FFFF; } } /* virtual */ void TownsCRTC::IOWriteByte(unsigned int ioport,unsigned int data) { switch(ioport) { case TOWNSIO_ANALOGPALETTE_CODE://= 0xFD90, state.palette.codeLatch=data; break; case TOWNSIO_ANALOGPALETTE_BLUE://= 0xFD92, state.palette.SetBlue(data,(state.sifter[1]>>4)&3); break; case TOWNSIO_ANALOGPALETTE_RED://= 0xFD94, state.palette.SetRed(data,(state.sifter[1]>>4)&3); break; case TOWNSIO_ANALOGPALETTE_GREEN://= 0xFD96, state.palette.SetGreen(data,(state.sifter[1]>>4)&3); break; case TOWNSIO_FMR_DIGITALPALETTE0:// 0xFD98, case TOWNSIO_FMR_DIGITALPALETTE1:// 0xFD99, case TOWNSIO_FMR_DIGITALPALETTE2:// 0xFD9A, case TOWNSIO_FMR_DIGITALPALETTE3:// 0xFD9B, case TOWNSIO_FMR_DIGITALPALETTE4:// 0xFD9C, case TOWNSIO_FMR_DIGITALPALETTE5:// 0xFD9D, case TOWNSIO_FMR_DIGITALPALETTE6:// 0xFD9E, case TOWNSIO_FMR_DIGITALPALETTE7:// 0xFD9F, state.FMRPalette[ioport&7]=(data&0x0F); state.DPMD=true; break; case TOWNSIO_CRTC_ADDRESS:// 0x440, state.crtcAddrLatch=data&0x1f; break; case TOWNSIO_CRTC_DATA_LOW:// 0x442, state.crtcReg[state.crtcAddrLatch]&=0xff00; state.crtcReg[state.crtcAddrLatch]|=(data&0xff); if(REG_HST==state.crtcAddrLatch) { townsPtr->OnCRTC_HST_Write(); } UpdateSpriteHardware(); break; case TOWNSIO_CRTC_DATA_HIGH:// 0x443, state.crtcReg[state.crtcAddrLatch]&=0x00ff; state.crtcReg[state.crtcAddrLatch]|=((data&0xff)<<8); if(REG_HST==state.crtcAddrLatch) { townsPtr->OnCRTC_HST_Write(); } UpdateSpriteHardware(); break; case TOWNSIO_VIDEO_OUT_CTRL_ADDRESS://= 0x448, state.sifterAddrLatch=(data&3); break; case TOWNSIO_VIDEO_OUT_CTRL_DATA://= 0x44A, state.sifter[state.sifterAddrLatch]=data; UpdateSpriteHardware(); break; case TOWNSIO_MX_HIRES:// 0x470, case TOWNSIO_MX_VRAMSIZE:// 0x471, break; // No write access; case TOWNSIO_MX_IMGOUT_ADDR_LOW:// 0x472, state.mxVideoOutCtrlAddrLatch=((state.mxVideoOutCtrlAddrLatch&0xff00)|(data&0xff)); break; case TOWNSIO_MX_IMGOUT_ADDR_HIGH:// 0x473, state.mxVideoOutCtrlAddrLatch=((state.mxVideoOutCtrlAddrLatch&0x00ff)|((data<<8)&0xff)); break; case TOWNSIO_MX_IMGOUT_ADDR_D0:// 0x474, std::cout << "MX-VIDOUTCONTROL8[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch) << "H]=" << cpputil::Ubtox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch]=data; break; case TOWNSIO_MX_IMGOUT_ADDR_D1:// 0x475, if(state.mxVideoOutCtrlAddrLatch+1<state.mxVideoOutCtrl.size()) { std::cout << "MX-VIDOUTCONTROL8[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch+1) << "H]=" << cpputil::Ubtox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+1]=data; } break; case TOWNSIO_MX_IMGOUT_ADDR_D2:// 0x476, if(state.mxVideoOutCtrlAddrLatch+2<state.mxVideoOutCtrl.size()) { std::cout << "MX-VIDOUTCONTROL8[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch+2) << "H]=" << cpputil::Ubtox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+2]=data; } break; case TOWNSIO_MX_IMGOUT_ADDR_D3:// 0x477, if(state.mxVideoOutCtrlAddrLatch+3<state.mxVideoOutCtrl.size()) { std::cout << "MX-VIDOUTCONTROL8[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch+3) << "H]=" << cpputil::Ubtox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+3]=data; } break; case TOWNSIO_HSYNC_VSYNC: // Also CRT Output COntrol if(InSinglePageMode()) { state.showPage[0]=(0!=((data>>2)&3)); state.showPage[1]=state.showPage[0]; } else { state.showPage[0]=(0!=((data>>2)&3)); state.showPage[1]=(0!=( data &3)); } break; case TOWNSIO_WRITE_TO_CLEAR_VSYNCIRQ: TurnOffVSYNCIRQ(); break; } } /* virtual */ void TownsCRTC::IOWriteWord(unsigned int ioport,unsigned int data) { switch(ioport) { case TOWNSIO_CRTC_ADDRESS:// 0x440, state.crtcAddrLatch=data&0x1f; break; case TOWNSIO_CRTC_DATA_LOW:// 0x442, state.crtcReg[state.crtcAddrLatch]=(data&0xffff); if(REG_HST==state.crtcAddrLatch) { townsPtr->OnCRTC_HST_Write(); } break; case TOWNSIO_CRTC_DATA_HIGH:// 0x443, break; case TOWNSIO_VIDEO_OUT_CTRL_ADDRESS://= 0x448, state.sifterAddrLatch=(data&3); break; case TOWNSIO_VIDEO_OUT_CTRL_DATA://= 0x44A, state.sifter[state.sifterAddrLatch]=data; break; case TOWNSIO_MX_HIRES:// 0x470, case TOWNSIO_MX_VRAMSIZE:// 0x471, break; // No write access; case TOWNSIO_MX_IMGOUT_ADDR_LOW:// 0x472, state.mxVideoOutCtrlAddrLatch=(data&0xffff); break; case TOWNSIO_MX_IMGOUT_ADDR_D0:// 0x474, std::cout << "MX-VIDOUTCONTROL16[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch) << "H]=" << cpputil::Ustox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch]=data; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+1]=(data>>8)&255; break; default: Device::IOWriteWord(ioport,data); // Let it write twice. break; } } /* virtual */ void TownsCRTC::IOWriteDword(unsigned int ioport,unsigned int data) { switch(ioport) { case TOWNSIO_MX_IMGOUT_ADDR_D0:// 0x474, std::cout << "MX-VIDOUTCONTROL32[" << cpputil::Ustox(state.mxVideoOutCtrlAddrLatch) << "H]=" << cpputil::Uitox(data) << "H" << std::endl; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch]=data; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+1]=(data>>8)&255; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+2]=(data>>16)&255; state.mxVideoOutCtrl[state.mxVideoOutCtrlAddrLatch+3]=(data>>24)&255; break; default: // Analog-Palette Registers allow DWORD Access. // Towns MENU V2.1 writes to palette like: // 0110:000015C4 66BA94FD MOV DX,FD94H // 0110:000015C8 EF OUT DX,EAX // 0110:000015C9 8AC4 MOV AL,AH // 0110:000015CB B292 MOV DL,92H // 0110:000015CD EE OUT DX,AL Device::IOWriteDword(ioport,data); // Let it write 4 times. break; } } /* virtual */ unsigned int TownsCRTC::IOReadByte(unsigned int ioport) { unsigned char data=0xff; switch(ioport) { case TOWNSIO_ANALOGPALETTE_CODE://= 0xFD90, data=state.palette.codeLatch; break; case TOWNSIO_ANALOGPALETTE_BLUE://= 0xFD92, data=state.palette.GetBlue((state.sifter[1]>>4)&3); break; case TOWNSIO_ANALOGPALETTE_RED://= 0xFD94, data=state.palette.GetRed((state.sifter[1]>>4)&3); break; case TOWNSIO_ANALOGPALETTE_GREEN://= 0xFD96, data=state.palette.GetGreen((state.sifter[1]>>4)&3); break; case TOWNSIO_FMR_DIGITALPALETTE0:// 0xFD98, case TOWNSIO_FMR_DIGITALPALETTE1:// 0xFD99, case TOWNSIO_FMR_DIGITALPALETTE2:// 0xFD9A, case TOWNSIO_FMR_DIGITALPALETTE3:// 0xFD9B, case TOWNSIO_FMR_DIGITALPALETTE4:// 0xFD9C, case TOWNSIO_FMR_DIGITALPALETTE5:// 0xFD9D, case TOWNSIO_FMR_DIGITALPALETTE6:// 0xFD9E, case TOWNSIO_FMR_DIGITALPALETTE7:// 0xFD9F, return state.FMRPalette[ioport&7]; break; case TOWNSIO_CRTC_ADDRESS:// 0x440, break; case TOWNSIO_CRTC_DATA_LOW:// 0x442, // It is supposed to be write-only, but // 1 bit "START" and high-byte of FR can be read. Why not make all readable then. data=state.crtcReg[state.crtcAddrLatch]&0xff; break; case TOWNSIO_VIDEO_OUT_CTRL_ADDRESS://= 0x448, Supposed to be write-only data=state.sifterAddrLatch; break; case TOWNSIO_VIDEO_OUT_CTRL_DATA://= 0x44A, Supposed to be write-only data=state.sifter[state.sifterAddrLatch]; break; case TOWNSIO_DPMD_SPRITEBUSY_SPRITEPAGE: // 044CH [2] pp.153 data=(true==state.DPMD ? 0x80 : 0); data|=(true==spritePtr->SPD0() ? 2 : 0); data|=spritePtr->WritingPage(); state.DPMD=false; break; case TOWNSIO_CRTC_DATA_HIGH:// 0x443, if(REG_FR==state.crtcAddrLatch) { const auto VSYNC=InVSYNC(townsPtr->state.townsTime); const auto HSYNC=InHSYNC(townsPtr->state.townsTime); const auto DSPTV0=!VSYNC; const auto DSPTV1=DSPTV0; const auto DSPTH0=!HSYNC; const auto DSPTH1=DSPTH0; const bool FIELD=false; // What's FIELD? const bool VIN=false; data= (true==VIN ? 0x01 : 0) |(true==HSYNC ? 0x02 : 0) |(true==VSYNC ? 0x04 : 0) |(true==FIELD ? 0x08 : 0) |(true==DSPTH0 ? 0x10 : 0) |(true==DSPTH1 ? 0x20 : 0) |(true==DSPTV0 ? 0x40 : 0) |(true==DSPTV1 ? 0x80 : 0); } else { data=(state.crtcReg[state.crtcAddrLatch]>>8)&0xff; } break; case TOWNSIO_MX_HIRES:// 0x470, data=(TOWNSTYPE_2_MX<=townsPtr->townsType ? 0x7F : 0x80); // [2] pp. 831 break; case TOWNSIO_MX_VRAMSIZE:// 0x471, data=(TOWNSTYPE_2_MX<=townsPtr->townsType ? 0x01 : 0x00); // [2] pp. 831 break; case TOWNSIO_MX_IMGOUT_ADDR_LOW:// 0x472, data=(TOWNSTYPE_2_MX<=townsPtr->townsType ? (state.mxVideoOutCtrlAddrLatch&255) : 0xff); break; case TOWNSIO_MX_IMGOUT_ADDR_HIGH:// 0x473, data=(TOWNSTYPE_2_MX<=townsPtr->townsType ? ((state.mxVideoOutCtrlAddrLatch>>8)&255) : 0xff); break; case TOWNSIO_MX_IMGOUT_ADDR_D0:// 0x474, switch(state.mxVideoOutCtrlAddrLatch) { case 0x0004: data=0; break; } break; case TOWNSIO_MX_IMGOUT_ADDR_D1:// 0x475, break; case TOWNSIO_MX_IMGOUT_ADDR_D2:// 0x476, break; case TOWNSIO_MX_IMGOUT_ADDR_D3:// 0x477, break; case TOWNSIO_HSYNC_VSYNC: data= (true==InVSYNC(townsPtr->state.townsTime) ? 1 : 0) |(true==InHSYNC(townsPtr->state.townsTime) ? 2 : 0); break; } return data; } /* virtual */ void TownsCRTC::Reset(void) { state.Reset(); } Vec2i TownsCRTC::GetRenderSize(void) const { return Vec2i::Make(640,480); } std::vector <std::string> TownsCRTC::GetStatusText(void) const { std::vector <std::string> text; std::string empty; text.push_back(empty); text.back()="Registers:"; for(int i=0; i<sizeof(state.crtcReg)/sizeof(state.crtcReg[0]); ++i) { if(0==i%16) { text.push_back(empty); text.back()+="REG"; text.back()+=cpputil::Ubtox(i); text.back()+=":"; } text.back()+=" "; text.back()+=cpputil::Ustox(state.crtcReg[i]); } text.push_back(empty); text.back()="Sifters (Isn't it Shifter?):"; for(int i=0; i<2; ++i) { text.back()+=cpputil::Ubtox(state.sifter[i]); text.back().push_back(' '); } text.back()+="PLT:"; text.back()+=cpputil::Ubtox((state.sifter[1]>>4)&3); text.back()+=" Priority:"; text.back().push_back('0'+GetPriorityPage()); text.push_back(empty); text.back()="Address Latch: "; text.back()+=cpputil::Uitox(state.crtcAddrLatch)+"H"; const unsigned int CL[2]= { (unsigned int)( state.crtcReg[REG_CR0]&3), (unsigned int)((state.crtcReg[REG_CR0]>>2)&3), }; text.push_back(empty); text.back()="CL0:"+cpputil::Itoa(CL[0])+" CL1:"+cpputil::Itoa(CL[1]); if(true==InSinglePageMode()) { text.push_back(empty); text.back()="Single-Page Mode. "; auto pageStat0=GetPageStatusText(0); text.insert(text.end(),pageStat0.begin(),pageStat0.end()); } else { text.push_back(empty); text.back()="2-Page Mode. "; auto pageStat0=GetPageStatusText(0); text.insert(text.end(),pageStat0.begin(),pageStat0.end()); auto pageStat1=GetPageStatusText(1); text.insert(text.end(),pageStat1.begin(),pageStat1.end()); } text.push_back(empty); text.back()+="16-Color Palette"; for(int page=0; page<2; ++page) { text.push_back(empty); text.back()+="Page"; text.back().push_back((char)('0'+page)); text.back().push_back(':'); for(int i=0; i<16; ++i) { text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][0]); text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][1]); text.back()+=cpputil::Ubtox(state.palette.plt16[page][i][2]); text.back().push_back(' '); } } text.push_back(empty); text.back()+="256-Color Palette"; for(int i=0; i<256; i+=16) { text.push_back(empty); for(int j=0; j<16; ++j) { text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][0]); text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][1]); text.back()+=cpputil::Ubtox(state.palette.plt256[i+j][2]); text.back().push_back(' '); } } return text; } std::vector <std::string> TownsCRTC::GetPageStatusText(int page) const { Layer layer; MakePageLayerInfo(layer,page); std::vector <std::string> text; std::string empty; text.push_back(empty); text.back()="Page "+cpputil::Itoa(page); text.push_back(empty); text.back()+="Top-Left:("+cpputil::Itoa(layer.originOnMonitor.x())+","+cpputil::Itoa(layer.originOnMonitor.y())+") "; text.back()+="Display Size:("+cpputil::Itoa(layer.sizeOnMonitor.x())+","+cpputil::Itoa(layer.sizeOnMonitor.y())+")"; text.push_back(empty); text.back()+=cpputil::Itoa(layer.bitsPerPixel)+"-bit color"; text.push_back(empty); text.back()+="VRAM Base="+cpputil::Uitox(layer.VRAMAddr); text.back()+=" Offset="+cpputil::Uitox(layer.VRAMOffset); text.push_back(empty); text.back()+="BytesPerLine="+cpputil::Uitox(layer.bytesPerLine); text.push_back(empty); text.back()+="Zoom=("+cpputil::Uitox(layer.zoom.x())+","+cpputil::Uitox(layer.zoom.y())+")"; return text; }
26.735484
755
0.688908
Artanejp
fc425f7fec53c0a7720e6a98ea7b958249f693b4
8,586
cpp
C++
contracts/eosio.system/voting.cpp
terradacs/beos-core
31e19170bcad573b1d498811284e62babd478f92
[ "MIT" ]
9
2019-04-04T18:46:14.000Z
2022-03-03T16:22:56.000Z
contracts/eosio.system/voting.cpp
terradacs/beos-core
31e19170bcad573b1d498811284e62babd478f92
[ "MIT" ]
null
null
null
contracts/eosio.system/voting.cpp
terradacs/beos-core
31e19170bcad573b1d498811284e62babd478f92
[ "MIT" ]
3
2019-03-19T17:45:08.000Z
2021-03-22T21:45:35.000Z
/** * @file * @copyright defined in eos/LICENSE.txt */ #include "eosio.system.hpp" #include <eosiolib/eosio.hpp> #include <eosiolib/crypto.h> #include <eosiolib/print.hpp> #include <eosiolib/datastream.hpp> #include <eosiolib/serialize.hpp> #include <eosiolib/multi_index.hpp> #include <eosiolib/privileged.hpp> #include <eosiolib/singleton.hpp> #include <eosiolib/transaction.hpp> #include <eosiolib/types.hpp> #include <eosio.token/eosio.token.hpp> #include <eosio.init/eosio.init.hpp> #include <beoslib/beos_privileged.hpp> #include <algorithm> #include <cmath> namespace eosiosystem { using eosio::indexed_by; using eosio::const_mem_fun; using eosio::bytes; using eosio::print; using eosio::singleton; using eosio::transaction; inline void update_producers_table(const std::vector<block_producer_voting_info>& producer_infos, producers_table& producers) { auto itr_end = producers.end(); for(const auto& pi : producer_infos) { if( pi.owner == 0 ) break; auto found = producers.find( pi.owner ); if( found != itr_end ) { producers.modify( found, 0, [&pi](auto& p) { p.total_votes = pi.total_votes; p.is_active = pi.is_active; }); } } } bool system_contract::is_allowed_vote_operation() const { //Creating votes for producers has delay. auto block_nr = get_blockchain_block_number(); eosio::beos_global_state b_state = eosio::init( N(beos.init) ).get_beos_global_state(); return block_nr > b_state.starting_block_for_initial_witness_election; } /** * This method will create a producer_config and producer_info object for 'producer' * * @pre producer is not already registered * @pre producer to register is an account * @pre authority of producer to register * */ void system_contract::regproducer( const account_name producer, const eosio::public_key& producer_key, const std::string& url, uint16_t location ) { eosio_assert( url.size() < 512, "url too long" ); eosio_assert( producer_key != eosio::public_key(), "public key should not be the default value" ); require_auth( producer ); auto prod = _producers.find( producer ); if ( prod != _producers.end() ) { _producers.modify( prod, producer, [&]( producer_info& info ){ info.producer_key = producer_key; info.is_active = true; info.url = url; info.location = location; }); } else { _producers.emplace( producer, [&]( producer_info& info ){ info.owner = producer; info.total_votes = 0; info.producer_key = producer_key; info.is_active = true; info.url = url; info.location = location; }); ++_gstate.total_producers; _global.set( _gstate, _self ); } } void system_contract::unregprod( const account_name producer ) { require_auth( producer ); const auto& prod = _producers.get( producer, "producer not found" ); _producers.modify( prod, 0, [&]( producer_info& info ){ info.deactivate(); }); } void system_contract::update_elected_producers( block_timestamp block_time ) { _gstate.last_producer_schedule_update = block_time; auto idx = _producers.get_index<N(prototalvote)>(); std::vector< std::pair<eosio::producer_key,uint16_t> > top_producers; top_producers.reserve(21); for ( auto it = idx.cbegin(); it != idx.cend() && top_producers.size() < 21 && 0 < it->total_votes && it->active(); ++it ) { top_producers.emplace_back( std::pair<eosio::producer_key,uint16_t>({{it->owner, it->producer_key}, it->location}) ); } if ( top_producers.size() < _gstate.last_producer_schedule_size ) { return; } /// sort by producer name std::sort( top_producers.begin(), top_producers.end() ); std::vector<eosio::producer_key> producers; producers.reserve(top_producers.size()); for( const auto& item : top_producers ) producers.push_back(item.first); bytes packed_schedule = pack(producers); if( set_proposed_producers( packed_schedule.data(), packed_schedule.size() ) >= 0 ) { _gstate.last_producer_schedule_size = static_cast<decltype(_gstate.last_producer_schedule_size)>( top_producers.size() ); } } double stake2vote( int64_t staked ) { /// TODO subtract 2080 brings the large numbers closer to this decade double weight = int64_t( (now() - (block_timestamp::block_timestamp_epoch / 1000)) / (seconds_per_day * 7) ) / double( 52 ); return double(staked) * std::pow( 2, weight ); } /** * @pre producers must be sorted from lowest to highest and must be registered and active * @pre if proxy is set then no producers can be voted for * @pre if proxy is set then proxy account must exist and be registered as a proxy * @pre every listed producer or proxy must have been previously registered * @pre voter must authorize this action * @pre voter must have previously staked some EOS for voting * @pre voter->staked must be up to date * * @post every producer previously voted for will have vote reduced by previous vote weight * @post every producer newly voted for will have vote increased by new vote amount * @post prior proxy will proxied_vote_weight decremented by previous vote weight * @post new proxy will proxied_vote_weight incremented by new vote weight * * If voting for a proxy, the producer votes will not change until the proxy updates their own vote. */ void system_contract::voteproducer( const account_name voter_name, const account_name proxy, const std::vector<account_name>& producers ) { require_auth( voter_name ); update_votes( voter_name, proxy, producers, true); } void system_contract::updateprods( const std::vector<block_producer_voting_info>& producer_infos ) { require_auth( _self ); update_producers_table( producer_infos, _producers ); flush_voting_stats(); } void system_contract::update_votes( const account_name voter_name, const account_name proxy, const std::vector<account_name>& producers, bool voting ) { //validate input if ( proxy ) { eosio_assert( producers.size() == 0, "cannot vote for producers and proxy at same time" ); eosio_assert( voter_name != proxy, "cannot proxy to self" ); require_recipient( proxy ); } else { eosio_assert( producers.size() <= 30, "attempt to vote for too many producers" ); for( size_t i = 1; i < producers.size(); ++i ) { eosio_assert( producers[i-1] < producers[i], "producer votes must be unique and sorted" ); } } auto producer_infos = prepare_producer_infos( _gstate.total_producers ); ::update_votes(voter_name, proxy, producers.data(), producers.size(), voting, producer_infos.data(), producer_infos.size()); update_producers_table(producer_infos, _producers); flush_voting_stats(); } /** * An account marked as a proxy can vote with the weight of other accounts which * have selected it as a proxy. Other accounts must refresh their voteproducer to * update the proxy's weight. * * @param isproxy - true if proxy wishes to vote on behalf of others, false otherwise * @pre proxy must have something staked (existing row in voters table) * @pre new state must be different than current state */ void system_contract::regproxy( const account_name proxy, bool isproxy ) { require_auth( proxy ); auto producer_infos = prepare_producer_infos( _gstate.total_producers ); ::register_voting_proxy(proxy, isproxy, producer_infos.data(), producer_infos.size()); update_producers_table(producer_infos, _producers); flush_voting_stats(); } void system_contract::update_voting_power(const account_name from, int64_t stake_delta) { auto producer_infos = prepare_producer_infos( _gstate.total_producers ); ::update_voting_power(from, stake_delta, producer_infos.data(), producer_infos.size()); update_producers_table(producer_infos, _producers); flush_voting_stats(); } } /// namespace eosiosystem
36.07563
155
0.659213
terradacs
fc43f5086b9876dd84363e87f15dd923e2330dce
2,010
cpp
C++
core/features/misc/prediction.cpp
Lucianthin/Csgo-Cheat
83ead94156f8f4fb7186265b37c7a38e1cdb2dd8
[ "MIT" ]
50
2019-06-12T19:22:28.000Z
2022-03-07T20:40:16.000Z
core/features/misc/prediction.cpp
Lucianthin/Csgo-Cheat
83ead94156f8f4fb7186265b37c7a38e1cdb2dd8
[ "MIT" ]
13
2019-06-17T15:21:28.000Z
2021-03-21T19:09:43.000Z
core/features/misc/prediction.cpp
Lucianthin/Csgo-Cheat
83ead94156f8f4fb7186265b37c7a38e1cdb2dd8
[ "MIT" ]
26
2019-06-16T19:33:12.000Z
2022-02-02T10:48:44.000Z
#include "prediction.hpp" #include "../../../dependencies/utilities/md5.hpp" #include "../../../dependencies/interfaces/interfaces.hpp" #include <iostream> #include <fstream> c_prediction engine_prediction; void c_prediction::start_prediction(c_usercmd* command) noexcept { auto local_player = reinterpret_cast<player_t*>(interfaces::entity_list->get_client_entity(interfaces::engine->get_local_player())); if (!local_player) return; if (local_player) { static bool initialized = false; if (!initialized) { prediction_random_seed = *(int**)(utilities::pattern_scan(GetModuleHandleA("client_panorama.dll"), "8B 0D ? ? ? ? BA ? ? ? ? E8 ? ? ? ? 83 C4 04") + 2); initialized = true; } *prediction_random_seed = utilities::md5::pseduo_random(command->command_number) & 0x7FFFFFFF; old_cur_time = interfaces::globals->cur_time; old_frame_time = interfaces::globals->frame_time; interfaces::globals->cur_time = local_player->get_tick_base() * interfaces::globals->interval_per_tick; //tick_base_test interfaces::globals->frame_time = interfaces::globals->interval_per_tick; interfaces::game_movement->start_track_prediction_errors(local_player); memset(&move_data, 0, sizeof(move_data)); interfaces::move_helper->set_host(local_player); interfaces::prediction->setup_move(local_player, command, interfaces::move_helper, &move_data); interfaces::game_movement->process_movement(local_player, &move_data); interfaces::prediction->finish_move(local_player, command, &move_data); } } void c_prediction::end_prediction() noexcept { auto local_player = reinterpret_cast<player_t*>(interfaces::entity_list->get_client_entity(interfaces::engine->get_local_player())); if (!local_player) return; if (local_player) { interfaces::game_movement->finish_track_prediction_errors(local_player); interfaces::move_helper->set_host(0); *prediction_random_seed = -1; interfaces::globals->cur_time = old_cur_time; interfaces::globals->frame_time = old_cur_time; } }
35.892857
155
0.760199
Lucianthin
fc48d83fa808bc931ffa58105a64e24e08fc613c
2,679
hpp
C++
boost/numeric/mtl/utility/transposed_matrix_type.hpp
lit-uriy/mtl4-mirror
37cf7c2847165d3537cbc3400cb5fde6f80e3d8b
[ "MTLL" ]
24
2019-03-26T15:25:45.000Z
2022-03-26T10:00:45.000Z
boost/numeric/mtl/utility/transposed_matrix_type.hpp
lit-uriy/mtl4-mirror
37cf7c2847165d3537cbc3400cb5fde6f80e3d8b
[ "MTLL" ]
2
2020-04-17T12:35:32.000Z
2021-03-03T15:46:25.000Z
boost/numeric/mtl/utility/transposed_matrix_type.hpp
lit-uriy/mtl4-mirror
37cf7c2847165d3537cbc3400cb5fde6f80e3d8b
[ "MTLL" ]
10
2019-12-01T13:40:30.000Z
2022-01-14T08:39:54.000Z
// Software License for MTL // // Copyright (c) 2007 The Trustees of Indiana University. // 2008 Dresden University of Technology and the Trustees of Indiana University. // 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. // All rights reserved. // Authors: Peter Gottschling and Andrew Lumsdaine // // This file is part of the Matrix Template Library // // See also license.mtl.txt in the distribution. #ifndef MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE #define MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE #include <boost/numeric/mtl/mtl_fwd.hpp> #include <boost/numeric/mtl/utility/transposed_orientation.hpp> namespace mtl { namespace traits { template <class T> struct transposed_matrix_parameter {}; template <typename O, typename I, typename D, bool S, typename ST> struct transposed_matrix_parameter<mat::parameters<O, I, D, S, ST> > { typedef mat::parameters<typename transposed_orientation<O>::type, I, D, S, ST> type; }; template <class T> struct transposed_matrix_type {}; template <typename Value, typename Parameters> struct transposed_matrix_type<mat::dense2D<Value, Parameters> > { typedef mat::dense2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; }; template <typename Value, typename Parameters> struct transposed_matrix_type<mat::compressed2D<Value, Parameters> > { typedef mat::compressed2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; }; template <typename Value, std::size_t Mask, typename Parameters> struct transposed_matrix_type<mat::morton_dense<Value, Mask, Parameters> > { typedef mat::morton_dense<Value, Mask, typename transposed_matrix_parameter<Parameters>::type> type; }; template <class T> struct transposed_sparse_matrix_type {}; template <typename Value, typename Parameters> struct transposed_sparse_matrix_type<mat::compressed2D<Value, Parameters> > { typedef mat::compressed2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; }; template <typename Matrix> struct transposed_sparse_matrix_type<mat::banded_view<Matrix> > { typedef typename transposed_sparse_matrix_type<Matrix>::type type; }; template <typename Value, typename Parameters> struct transposed_sparse_matrix_type<mat::transposed_view<mat::compressed2D<Value, Parameters> > > { typedef mat::compressed2D<Value, Parameters> type; }; template <typename Value, typename Parameters> struct transposed_sparse_matrix_type<mat::transposed_view<const mat::compressed2D<Value, Parameters> > > { typedef mat::compressed2D<Value, Parameters> type; }; }} // namespace mtl::traits #endif // MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE
32.670732
104
0.776036
lit-uriy
fc4cc9762c71cf2e7a49e9dff9d5ff2e19fe519a
11,449
hpp
C++
include/clients/common/BufferedProcess.hpp
jamesb93/flucoma-core
3e964dd569f6fff15bd5249a705dc0da8f7b2ad8
[ "BSD-3-Clause" ]
null
null
null
include/clients/common/BufferedProcess.hpp
jamesb93/flucoma-core
3e964dd569f6fff15bd5249a705dc0da8f7b2ad8
[ "BSD-3-Clause" ]
null
null
null
include/clients/common/BufferedProcess.hpp
jamesb93/flucoma-core
3e964dd569f6fff15bd5249a705dc0da8f7b2ad8
[ "BSD-3-Clause" ]
null
null
null
/* Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) Copyright 2017-2019 University of Huddersfield. Licensed under the BSD-3 License. See license.md file in the project root for full license information. This project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899). */ #pragma once #include "../common/FluidContext.hpp" #include "../common/FluidSink.hpp" #include "../common/FluidSource.hpp" #include "../common/ParameterSet.hpp" #include "../common/ParameterTrackChanges.hpp" #include "../common/ParameterTypes.hpp" #include "../../algorithms/public/STFT.hpp" #include "../../data/FluidIndex.hpp" #include "../../data/FluidTensor.hpp" #include "../../data/TensorTypes.hpp" #include <memory> namespace fluid { namespace client { template <typename T> using HostVector = FluidTensorView<T, 1>; template <typename T> using HostMatrix = FluidTensorView<T, 2>; class BufferedProcess { public: template <typename F> void process(index windowSizeIn, index windowSizeOut, index hopSize, FluidContext& c, F processFunc) { assert(windowSizeIn <= maxWindowSizeIn() && "Window in bigger than maximum"); assert(windowSizeOut <= maxWindowSizeOut() && "Window out bigger than maximum"); for (; mFrameTime < mHostSize; mFrameTime += hopSize) { RealMatrixView windowIn = mFrameIn(Slice(0), Slice(0, windowSizeIn)); RealMatrixView windowOut = mFrameOut(Slice(0), Slice(0, windowSizeOut)); mSource.pull(windowIn, mFrameTime); processFunc(windowIn, windowOut); mSink.push(windowOut, mFrameTime); if (FluidTask* t = c.task()) if (!t->processUpdate( static_cast<double>(std::min(mFrameTime + hopSize, mHostSize)), static_cast<double>(mHostSize))) break; } mFrameTime = mFrameTime < mHostSize ? mFrameTime : mFrameTime - mHostSize; } template <typename F> void processInput(index windowSize, index hopSize, FluidContext& c, F processFunc) { assert(windowSize <= maxWindowSizeIn() && "Window bigger than maximum"); for (; mFrameTime < mHostSize; mFrameTime += hopSize) { RealMatrixView windowIn = mFrameIn(Slice(0), Slice(0, windowSize)); mSource.pull(windowIn, mFrameTime); processFunc(windowIn); if (FluidTask* t = c.task()) if (!t->processUpdate( static_cast<double>(std::min(mFrameTime + hopSize, mHostSize)), static_cast<double>(mHostSize))) break; } mFrameTime = mFrameTime < mHostSize ? mFrameTime : mFrameTime - mHostSize; } template <typename F> void processOutput(index windowSizeOut, index hopSize, FluidContext& c, F processFunc) { assert(windowSizeOut <= maxWindowSizeOut() && "Window out bigger than maximum"); for (; mFrameTime < mHostSize; mFrameTime += hopSize) { RealMatrixView windowOut = mFrameOut(Slice(0), Slice(0, windowSizeOut)); processFunc(windowOut); mSink.push(windowOut, mFrameTime); if (FluidTask* t = c.task()) if (!t->processUpdate( static_cast<double>(std::min(mFrameTime + hopSize, mHostSize)), static_cast<double>(mHostSize))) break; } mFrameTime = mFrameTime < mHostSize ? mFrameTime : mFrameTime - mHostSize; } index hostSize() const noexcept { return mHostSize; } void hostSize(index size) noexcept { mHostSize = size; mSource.setHostBufferSize(size); mSink.setHostBufferSize(size); mSource.reset(); mSink.reset(); } index maxWindowSizeIn() const noexcept { return mFrameIn.cols(); } index maxWindowSizeOut() const noexcept { return mFrameOut.cols(); } void maxSize(index framesIn, index framesOut, index channelsIn, index channelsOut) { mSource.setSize(framesIn); mSource.reset(channelsIn); mSink.setSize(framesOut); mSink.reset(channelsOut); if (channelsIn > mFrameIn.rows() || framesIn > mFrameIn.cols()) mFrameIn.resize(channelsIn, framesIn); if (channelsOut > mFrameOut.rows() || framesOut > mFrameOut.cols()) mFrameOut.resize(channelsOut, framesOut); mFrameTime = 0; } template <typename T> void push(HostMatrix<T> in) { mSource.push(in); } template <typename T> void push(const std::vector<FluidTensorView<T, 1>>& in) { mSource.push(in); } template <typename T> void pull(HostMatrix<T> out) { mSink.pull(out); } index channelsIn() const noexcept { return mSource.channels(); } index channelsOut() const noexcept { return mSink.channels(); } void reset() { mSource.reset(); mSink.reset(); mFrameTime = 0; } private: index mFrameTime = 0; index mHostSize; RealMatrix mFrameIn; RealMatrix mFrameOut; FluidSource<double> mSource; FluidSink<double> mSink; }; template <typename Params, index FFTParamsIndex, bool Normalise = true> class STFTBufferedProcess { public: STFTBufferedProcess(index maxFFTSize, index channelsIn, index channelsOut) { mBufferedProcess.maxSize(maxFFTSize, maxFFTSize, channelsIn, channelsOut + Normalise); } template <typename T, typename F> void process(Params& p, const std::vector<HostVector<T>>& input, std::vector<HostVector<T>>& output, FluidContext& c, F&& processFunc) { if (!input[0].data()) return; assert(mBufferedProcess.channelsIn() == asSigned(input.size())); assert(mBufferedProcess.channelsOut() == asSigned(output.size() + Normalise)); FFTParams fftParams = setup(p, input[0].size()); index chansIn = mBufferedProcess.channelsIn(); index chansOut = mBufferedProcess.channelsOut() - Normalise; mBufferedProcess.push(input); mBufferedProcess.process( fftParams.winSize(), fftParams.winSize(), fftParams.hopSize(), c, [this, &processFunc, chansIn, chansOut](RealMatrixView in, RealMatrixView out) { for (index i = 0; i < chansIn; ++i) mSTFT->processFrame(in.row(i), mSpectrumIn.row(i)); processFunc(mSpectrumIn, mSpectrumOut(Slice(0, chansOut), Slice(0))); for (index i = 0; i < chansOut; ++i) mISTFT->processFrame(mSpectrumOut.row(i), out.row(i)); if (Normalise) { out.row(chansOut) <<= mSTFT->window(); out.row(chansOut).apply(mISTFT->window(), [](double& x, double& y) { x *= y; }); } }); RealMatrixView unnormalisedFrame = mFrameAndWindow(Slice(0), Slice(0, input[0].size())); mBufferedProcess.pull(unnormalisedFrame); for (index i = 0; i < chansOut; ++i) { if (Normalise) unnormalisedFrame.row(i).apply(unnormalisedFrame.row(chansOut), [](double& x, double g) { if (x != 0) { x /= (g > 0) ? g : 1; } }); if (output[asUnsigned(i)].data()) output[asUnsigned(i)] <<= unnormalisedFrame.row(i); } } template <typename T, typename F> void processInput(Params& p, const std::vector<HostVector<T>>& input, FluidContext& c, F&& processFunc) { if (!input[0].data()) return; assert(mBufferedProcess.channelsIn() == asSigned(input.size())); index chansIn = mBufferedProcess.channelsIn(); FFTParams fftParams = setup(p, input[0].size()); mBufferedProcess.push(input); mBufferedProcess.processInput( fftParams.winSize(), fftParams.hopSize(), c, [this, &processFunc, chansIn](RealMatrixView in) { for (index i = 0; i < chansIn; ++i) mSTFT->processFrame(in.row(i), mSpectrumIn.row(i)); processFunc(mSpectrumIn); }); } template <typename T, typename F> void processOutput(Params& p, std::vector<HostVector<T>>& output, FluidContext& c, F&& processFunc) { assert(mBufferedProcess.channelsOut() == asSigned(output.size() + Normalise)); FFTParams fftParams = setup(p, output[0].size()); index chansOut = mBufferedProcess.channelsOut() - Normalise; mBufferedProcess.processOutput( fftParams.winSize(), fftParams.hopSize(), c, [this, &processFunc, chansOut](RealMatrixView out) { processFunc(mSpectrumOut(Slice(0, chansOut), Slice(0))); for (index i = 0; i < chansOut; ++i) { mISTFT->processFrame(mSpectrumOut.row(i), out.row(i)); } if (Normalise) { out.row(chansOut) <<= mSTFT->window(); out.row(chansOut).apply(mISTFT->window(), [](double& x, double& y) { x *= y; }); } }); RealMatrixView unnormalisedFrame = mFrameAndWindow(Slice(0), Slice(0, output[0].size())); mBufferedProcess.pull(unnormalisedFrame); for (index i = 0; i < chansOut; ++i) { if (Normalise) unnormalisedFrame.row(i).apply(unnormalisedFrame.row(chansOut), [](double& x, double g) { if (x != 0) { x /= (g > 0) ? g : 1; } }); if (output[asUnsigned(i)].data()) output[asUnsigned(i)] <<= unnormalisedFrame.row(i); } } void reset() { mBufferedProcess.reset(); } private: FFTParams setup(Params& p, index hostBufferSize) { FFTParams fftParams = p.template get<FFTParamsIndex>(); bool newParams = mTrackValues.changed( fftParams.winSize(), fftParams.hopSize(), fftParams.fftSize()); if (mTrackHostVS.changed(hostBufferSize)) mBufferedProcess.hostSize(hostBufferSize); if (!mSTFT.get() || newParams) mSTFT.reset(new algorithm::STFT(fftParams.winSize(), fftParams.fftSize(), fftParams.hopSize())); if (!mISTFT.get() || newParams) mISTFT.reset(new algorithm::ISTFT( fftParams.winSize(), fftParams.fftSize(), fftParams.hopSize())); index chansIn = mBufferedProcess.channelsIn(); index chansOut = mBufferedProcess.channelsOut(); if (fftParams.frameSize() != mSpectrumIn.cols()) mSpectrumIn.resize(chansIn, fftParams.frameSize()); if (fftParams.frameSize() != mSpectrumOut.cols()) mSpectrumOut.resize(chansOut, fftParams.frameSize()); if (std::max(mBufferedProcess.maxWindowSizeIn(), hostBufferSize) > mFrameAndWindow.cols()) mFrameAndWindow.resize( chansOut, std::max(mBufferedProcess.maxWindowSizeIn(), hostBufferSize)); return fftParams; } ParameterTrackChanges<index, index, index> mTrackValues; ParameterTrackChanges<index> mTrackHostVS; RealMatrix mFrameAndWindow; ComplexMatrix mSpectrumIn; ComplexMatrix mSpectrumOut; std::unique_ptr<algorithm::STFT> mSTFT; std::unique_ptr<algorithm::ISTFT> mISTFT; BufferedProcess mBufferedProcess; }; } // namespace client } // namespace fluid
33.772861
79
0.614202
jamesb93
fc4d924bf910b268f625579acc25780542f6472f
4,205
cpp
C++
alica_tests/autogenerated/src/MultiAgentTestPlan1413200862180.cpp
Hugo-V-V/alica
8cbba9c01b52d11854ec0c5367d4a8ec4f896cfd
[ "MIT" ]
null
null
null
alica_tests/autogenerated/src/MultiAgentTestPlan1413200862180.cpp
Hugo-V-V/alica
8cbba9c01b52d11854ec0c5367d4a8ec4f896cfd
[ "MIT" ]
null
null
null
alica_tests/autogenerated/src/MultiAgentTestPlan1413200862180.cpp
Hugo-V-V/alica
8cbba9c01b52d11854ec0c5367d4a8ec4f896cfd
[ "MIT" ]
null
null
null
#include "MultiAgentTestPlan1413200862180.h" /*PROTECTED REGION ID(eph1413200862180) ENABLED START*/ // Add additional using directives here #include "TestWorldModel.h" #include <engine/AlicaEngine.h> #include <essentials/IdentifierConstPtr.h> /*PROTECTED REGION END*/ namespace alica { // Plan:MultiAgentTestPlan /** * Task: AttackTask -> EntryPoint-ID: 1413200877337 * Task: DefaultTask -> EntryPoint-ID: 1413200890537 * Task: DefaultTask -> EntryPoint-ID: 1413807260446 */ std::shared_ptr<UtilityFunction> UtilityFunction1413200862180::getUtilityFunction(Plan* plan) { /*PROTECTED REGION ID(1413200862180) ENABLED START*/ shared_ptr<UtilityFunction> defaultFunction = make_shared<DefaultUtilityFunction>(plan); return defaultFunction; /*PROTECTED REGION END*/ } /** * Outgoing transition: * - Name: 1413201370590, ConditionString: , Comment: * * Abstract plans in current state: * - Attack (1402488848841) * * Tasks in plan: * - AttackTask (1407153522080) (Entrypoint: 1413200877337)* - DefaultTask (1225112227903) (Entrypoint: 1413200890537)* - DefaultTask (1225112227903) * (Entrypoint: 1413807260446) * * States in plan: * - OtherState (1413200877336) * - State1 (1413200910490) * - State2 (1413201030936) * - NewSuccessState1 (1413201164999) * - NewSuccessState2 (1413552736921) * - Idle (1413807264574) * * Variables of preconditon: */ bool PreCondition1413201370590::evaluate(std::shared_ptr<RunningPlan> rp) { /*PROTECTED REGION ID(1413201368286) ENABLED START*/ int id8 = 8; essentials::IdentifierConstPtr agentID8 = rp->getAlicaEngine()->getID<int>(id8); if (*(rp->getOwnID()) == *agentID8) { return alicaTests::TestWorldModel::getOne()->isTransitionCondition1413201370590(); } else { return alicaTests::TestWorldModel::getTwo()->isTransitionCondition1413201370590(); } /*PROTECTED REGION END*/ } /** * Outgoing transition: * - Name: 1413201052549, ConditionString: , Comment: * * Abstract plans in current state: * - Attack (1402488848841) * * Tasks in plan: * - AttackTask (1407153522080) (Entrypoint: 1413200877337)* - DefaultTask (1225112227903) (Entrypoint: 1413200890537)* - DefaultTask (1225112227903) * (Entrypoint: 1413807260446) * * States in plan: * - OtherState (1413200877336) * - State1 (1413200910490) * - State2 (1413201030936) * - NewSuccessState1 (1413201164999) * - NewSuccessState2 (1413552736921) * - Idle (1413807264574) * * Variables of preconditon: */ bool PreCondition1413201052549::evaluate(std::shared_ptr<RunningPlan> rp) { /*PROTECTED REGION ID(1413201050743) ENABLED START*/ int id8 = 8; essentials::IdentifierConstPtr agentID8 = rp->getAlicaEngine()->getID<int>(id8); if (*(rp->getOwnID()) == *agentID8) { return alicaTests::TestWorldModel::getOne()->isTransitionCondition1413201052549(); } else { return alicaTests::TestWorldModel::getTwo()->isTransitionCondition1413201052549(); } /*PROTECTED REGION END*/ } /** * Outgoing transition: * - Name: 1413201367990, ConditionString: , Comment: * * Abstract plans in current state: * - Attack (1402488848841) * * Tasks in plan: * - AttackTask (1407153522080) (Entrypoint: 1413200877337)* - DefaultTask (1225112227903) (Entrypoint: 1413200890537)* - DefaultTask (1225112227903) * (Entrypoint: 1413807260446) * * States in plan: * - OtherState (1413200877336) * - State1 (1413200910490) * - State2 (1413201030936) * - NewSuccessState1 (1413201164999) * - NewSuccessState2 (1413552736921) * - Idle (1413807264574) * * Variables of preconditon: */ bool PreCondition1413201367990::evaluate(std::shared_ptr<RunningPlan> rp) { /*PROTECTED REGION ID(1413201367062) ENABLED START*/ int id8 = 8; essentials::IdentifierConstPtr agentID8 = rp->getAlicaEngine()->getID<int>(id8); if (*(rp->getOwnID()) == *agentID8) { return alicaTests::TestWorldModel::getOne()->isTransitionCondition1413201367990(); } else { return alicaTests::TestWorldModel::getTwo()->isTransitionCondition1413201367990(); } /*PROTECTED REGION END*/ } } // namespace alica
32.596899
155
0.706064
Hugo-V-V
fc524ede56f7fb131b040d12fcb9a88d30fb891e
2,779
cpp
C++
restbed/example/transfer_encoding_request/source/example.cpp
stevens2017/Aware
cd4754a34c809707c219a173dc1ad494e149cdb1
[ "BSD-3-Clause" ]
null
null
null
restbed/example/transfer_encoding_request/source/example.cpp
stevens2017/Aware
cd4754a34c809707c219a173dc1ad494e149cdb1
[ "BSD-3-Clause" ]
null
null
null
restbed/example/transfer_encoding_request/source/example.cpp
stevens2017/Aware
cd4754a34c809707c219a173dc1ad494e149cdb1
[ "BSD-3-Clause" ]
null
null
null
/* * Example illustrating Transfer-Encoding request processing. * * Server Usage: * ./distribution/example/transfer_encoding_request * * Client Usage: * curl -w'\n' -v -X POST --header "Transfer-Encoding: chunked" -d @distribution/resource/request.txt 'http://localhost:1984/resources' */ #include <string> #include <memory> #include <cstring> #include <cstdlib> #include <ciso646> #include <iostream> #include <restbed> using namespace std; using namespace restbed; void post_method_handler( const shared_ptr< Session > ); void read_chunk( const shared_ptr< Session >, const Bytes& ); void read_chunk_size( const shared_ptr< Session >, const Bytes& ); int main( const int, const char** ) { auto resource = make_shared< Resource >( ); resource->set_path( "/resources" ); resource->set_method_handler( "POST", post_method_handler ); auto settings = make_shared< Settings >( ); settings->set_port( 1984 ); settings->set_default_header( "Connection", "close" ); Service service; service.publish( resource ); service.start( settings ); return EXIT_SUCCESS; } void post_method_handler( const shared_ptr< Session > session ) { const auto request = session->get_request( ); if ( request->get_header( "Transfer-Encoding", String::lowercase ) == "chunked" ) { session->fetch( "\r\n", read_chunk_size ); } else if ( request->has_header( "Content-Length" ) ) { int length = request->get_header( "Content-Length", 0 ); session->fetch( length, [ ]( const shared_ptr< Session > session, const Bytes& ) { const auto request = session->get_request( ); const auto body = request->get_body( ); fprintf( stdout, "Complete body content: %.*s\n", static_cast< int >( body.size( ) ), body.data( ) ); session->close( OK ); } ); } else { session->close( BAD_REQUEST ); } } void read_chunk_size( const shared_ptr< Session > session, const Bytes& data ) { if ( not data.empty( ) ) { const string length( data.begin( ), data.end( ) ); if ( length not_eq "0\r\n" ) { const auto chunk_size = stoul( length, nullptr, 16 ) + strlen( "\r\n" ); session->fetch( chunk_size, read_chunk ); return; } } session->close( OK ); const auto request = session->get_request( ); const auto body = request->get_body( ); fprintf( stdout, "Complete body content: %.*s\n", static_cast< int >( body.size( ) ), body.data( ) ); } void read_chunk( const shared_ptr< Session > session, const Bytes& data ) { cout << "Partial body chunk: " << data.size( ) << " bytes" << endl; session->fetch( "\r\n", read_chunk_size ); }
28.357143
138
0.623965
stevens2017
fc5583923f44deb1a403652fc2a5bc291be16386
999
cpp
C++
Recursion/PascalTriangle/main.cpp
rsghotra/AbdulBari
2d2845608840ddda6e5153ec91966110ca7e25f5
[ "Apache-2.0" ]
1
2020-12-02T09:21:52.000Z
2020-12-02T09:21:52.000Z
Recursion/PascalTriangle/main.cpp
rsghotra/AbdulBari
2d2845608840ddda6e5153ec91966110ca7e25f5
[ "Apache-2.0" ]
null
null
null
Recursion/PascalTriangle/main.cpp
rsghotra/AbdulBari
2d2845608840ddda6e5153ec91966110ca7e25f5
[ "Apache-2.0" ]
null
null
null
//https://brilliant.org/wiki/pascals-triangle/#:~:text=Pascal's%20triangle%20is%20a%20triangular,Pascal%20(1623%20%2D%201662). /* Implementation of nCr i.e. Selction Formula Can be implemented usng two methods: 1. Using formula - O(n) 2. Using Pascal's Triange - O(n) */ #include <iostream> using namespace std; //helper int fact(int n) { if(n == 0) return 1; return fact(n-1) * n; } //direct formula int nCr(int n, int r) { int num, den; num = fact(n); den = fact(r) * fact(n-r); return num/den; } int nCr_pascal(int n, int r) { if( r == 0 || r == n) { return 1; } return nCr_pascal(n-1, r-1) + nCr_pascal(n-1, r); } int main() { int n, r; cout << "Choose n in nCr: " << endl; cin >> n; cout << "Choose r in nCr: " << endl; cin >> r; cout << "Total number of way to select(using formula): " << nCr(n,r); cout << "\nTotal number of ways to select(using Pascal Triangle): "<< nCr_pascal(n, r) << endl; return 0; }
20.8125
126
0.588589
rsghotra
fc58a3769983bc62f3bbfb8cd89bf64a2546f0aa
543
hh
C++
library/LayoutEmbedding/VirtualVertexAttribute.hh
jsb/LayoutEmbedding
6ef02ed0043dfabce6d593486358d6ef15cbf3ba
[ "MIT" ]
18
2021-02-18T15:35:25.000Z
2022-03-01T07:20:37.000Z
library/LayoutEmbedding/VirtualVertexAttribute.hh
jsb/LayoutEmbedding
6ef02ed0043dfabce6d593486358d6ef15cbf3ba
[ "MIT" ]
null
null
null
library/LayoutEmbedding/VirtualVertexAttribute.hh
jsb/LayoutEmbedding
6ef02ed0043dfabce6d593486358d6ef15cbf3ba
[ "MIT" ]
5
2021-02-17T14:52:42.000Z
2021-10-05T09:51:25.000Z
#pragma once #include <LayoutEmbedding/VirtualVertex.hh> #include <polymesh/pm.hh> namespace LayoutEmbedding { template <typename T> struct VirtualVertexAttribute { pm::vertex_attribute<T> v_a; pm::edge_attribute<T> e_a; VirtualVertexAttribute(const pm::Mesh& _m) : v_a(_m), e_a(_m) { } T& operator[](const VirtualVertex& _el) { if (is_real_vertex(_el)) { return v_a[real_vertex(_el)]; } else { return e_a[real_edge(_el)]; } } }; }
16.454545
48
0.587477
jsb
fc5a41759760e78ae01f846d71b447b98fb3dce5
375
cpp
C++
c10/10.42.cpp
sarthak-gupta-sg/hello-world
324f321a5454964b35b8399884d8c99971bd3425
[ "Apache-2.0" ]
null
null
null
c10/10.42.cpp
sarthak-gupta-sg/hello-world
324f321a5454964b35b8399884d8c99971bd3425
[ "Apache-2.0" ]
null
null
null
c10/10.42.cpp
sarthak-gupta-sg/hello-world
324f321a5454964b35b8399884d8c99971bd3425
[ "Apache-2.0" ]
1
2020-05-30T04:30:16.000Z
2020-05-30T04:30:16.000Z
#include <iostream> #include <algorithm> #include <list> int main() { std::list<std::string> lst { "the", "quick", "red", "fox", "jumps", "over", "the", "slow", "red", "turtle" }; //sort lst.sort(); //uniqie lst.unique(); //print for( auto const & val : lst ) { std::cout << val << " " << std::flush; } std::cout << std::endl << std::flush; return 0; }
15.625
110
0.541333
sarthak-gupta-sg
fc5b3be22422c3d0c0352f39b487e1196342b6c2
567
cpp
C++
BZOJ/3725/code.cpp
sjj118/OI-Code
964ea6e799d14010f305c7e4aee269d860a781f7
[ "MIT" ]
null
null
null
BZOJ/3725/code.cpp
sjj118/OI-Code
964ea6e799d14010f305c7e4aee269d860a781f7
[ "MIT" ]
null
null
null
BZOJ/3725/code.cpp
sjj118/OI-Code
964ea6e799d14010f305c7e4aee269d860a781f7
[ "MIT" ]
null
null
null
#include<iostream> #include<cstdio> #include<cstring> #define rep(i,x,y) for(int i=(x);i<=(y);++i) #define per(i,x,y) for(int i=(x);i>=(y);--i) using std::max; using std::min; const int N=1e6+10,inf=1e9; int n; char s[N]; bool check(int k){ char lstc='*'; int lstp=-inf; rep(i,1,n)if(s[i]!='*'){ int l=max(1,i-n+k),r=min(k,i); if(s[i]!=lstc&&l<=lstp)return 0; lstp=r;lstc=s[i]; } return 1; } int main(){ scanf("\n%s",s+1); n=strlen(s+1); int l=1,r=n; while(l<r){ int mid=(l+r)>>1; if(check(mid))r=mid;else l=mid+1; } printf("%d",l); return 0; }
17.71875
44
0.567901
sjj118
fc5d525707ccf05e4c6f3dc473a0059a48ad98b6
2,335
hh
C++
tests/unit/CXXTests/testNodeIterators.hh
jmikeowen/Spheral
3e1082a7aefd6b328bd3ae24ca1a477108cfc3c4
[ "BSD-Source-Code", "BSD-3-Clause-LBNL", "FSFAP" ]
22
2018-07-31T21:38:22.000Z
2020-06-29T08:58:33.000Z
src/CXXTests/testNodeIterators.hh
markguozhiming/spheral
bbb982102e61edb8a1d00cf780bfa571835e1b61
[ "BSD-Source-Code", "BSD-3-Clause-LBNL", "FSFAP" ]
41
2020-09-28T23:14:27.000Z
2022-03-28T17:01:33.000Z
src/CXXTests/testNodeIterators.hh
markguozhiming/spheral
bbb982102e61edb8a1d00cf780bfa571835e1b61
[ "BSD-Source-Code", "BSD-3-Clause-LBNL", "FSFAP" ]
7
2019-12-01T07:00:06.000Z
2020-09-15T21:12:39.000Z
//------------------------------------------------------------------------------ // testNodeIterators // A collection of test functions for the node iterators. // // Created by JMO, Thu Mar 25 14:21:41 2004 //------------------------------------------------------------------------------ #ifndef __Spheral_testNodeIterators_hh__ #define __Spheral_testNodeIterators_hh__ #include <string> namespace Spheral { template<typename Dimension> class DataBase; } namespace Spheral { //------------------------------------------------------------------------------ // Test global AllNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalAllNodeIterators(const DataBase<Dimension>& dataBase); //------------------------------------------------------------------------------ // Test global InternalNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalInternalNodeIterators(const DataBase<Dimension>& dataBase); //------------------------------------------------------------------------------ // Test global GhostNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalGhostNodeIterators(const DataBase<Dimension>& dataBase); //------------------------------------------------------------------------------ // Test global MasterNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalMasterNodeIterators(const DataBase<Dimension>& dataBase); //------------------------------------------------------------------------------ // Test global CoarseNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalCoarseNodeIterators(const DataBase<Dimension>& dataBase); //------------------------------------------------------------------------------ // Test global RefineNodeIterators. //------------------------------------------------------------------------------ template<typename Dimension> std::string testGlobalRefineNodeIterators(const DataBase<Dimension>& dataBase); } #endif
37.063492
80
0.421413
jmikeowen
fc667cb415c5924d057c19bbd1c09e6d8f699914
758
cpp
C++
libvast/src/data/integer.cpp
lava/vast
0bc9e3c12eb31ec50dd0270626d55e84b2255899
[ "BSD-3-Clause" ]
249
2019-08-26T01:44:45.000Z
2022-03-26T14:12:32.000Z
libvast/src/data/integer.cpp
lava/vast
0bc9e3c12eb31ec50dd0270626d55e84b2255899
[ "BSD-3-Clause" ]
586
2019-08-06T13:10:36.000Z
2022-03-31T08:31:00.000Z
libvast/src/data/integer.cpp
satta/vast
6c7587effd4265c4a5de23252bc7c7af3ef78bee
[ "BSD-3-Clause" ]
37
2019-08-16T02:01:14.000Z
2022-02-21T16:13:59.000Z
// _ _____ __________ // | | / / _ | / __/_ __/ Visibility // | |/ / __ |_\ \ / / Across // |___/_/ |_/___/ /_/ Space and Time // // SPDX-FileCopyrightText: (c) 2021 The VAST Contributors // SPDX-License-Identifier: BSD-3-Clause #include "vast/data/integer.hpp" namespace vast { integer::integer() = default; integer::integer(const integer&) = default; integer::integer(integer&&) = default; integer::integer(int64_t v) : value(v) { } integer& integer::operator=(const integer&) = default; integer& integer::operator=(integer&&) = default; bool operator==(integer lhs, integer rhs) { return lhs.value == rhs.value; } bool operator<(integer lhs, integer rhs) { return lhs.value < rhs.value; } } // namespace vast
23.6875
57
0.638522
lava
fc67d8570879f9bd7ecc4a369c5cba896e75e59f
4,779
cpp
C++
cocos2dx_playground/Classes/step_clickclick_game_Stage.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
9
2020-06-11T17:09:44.000Z
2021-12-25T00:34:33.000Z
cocos2dx_playground/Classes/step_clickclick_game_Stage.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
9
2019-12-21T15:01:01.000Z
2020-12-05T15:42:43.000Z
cocos2dx_playground/Classes/step_clickclick_game_Stage.cpp
R2Road/cocos2dx_playground
6e6f349b5c9fc702558fe8720ba9253a8ba00164
[ "Apache-2.0" ]
1
2020-09-07T01:32:16.000Z
2020-09-07T01:32:16.000Z
#include "step_clickclick_game_Stage.h" #include <algorithm> #include <cassert> #include <chrono> #include <new> #include <random> #include "cpg_Random.h" namespace { #if defined( DEBUG ) || defined( _DEBUG ) #define CHECK_ODD_NUMBER( number ) ( assert( 1 == ( ( number ) & 1 ) ) ) #define CHECK_SIZE( pivot, number ) ( assert( pivot >= number ) ) #define CHECK_LINEAR_INDEX( min_index, max_index, defendant ) ( assert( min_index <= defendant && max_index > defendant ) ) #else #define CHECK_ODD_NUMBER( number ) #define CHECK_SIZE( pivot, number ) #define CHECK_LINEAR_INDEX( min_index, max_index, defendant ) #endif } namespace step_clickclick { namespace game { Stage::Stage( const int width, const int height ) : mStageWidth( width ) , mStageHeight( height ) , mCenterX( mStageWidth / 2 ) , mCenterY( mStageWidth / 2 ) , mGridIndexConverter( mStageWidth, mStageHeight ) , mBlocks() , mActiveBlockCount( 0 ) { // // Must odd number // CHECK_ODD_NUMBER( mStageWidth ); CHECK_ODD_NUMBER( mStageHeight ); } StageUp Stage::create( const int width, const int height ) { StageUp ret( new ( std::nothrow ) Stage( width, height ) ); if( !ret ) { ret.reset(); } else { ret->init(); } return ret; } void Stage::init() { for( int ty = 0; ty < mStageHeight; ++ty ) { for( int tx = 0; tx < mStageWidth; ++tx ) { const int linear_index = mGridIndexConverter.To_Linear( tx, ty ); mBlocks.emplace_back( linear_index ); } } } void Stage::Setup( const int width, const int height, const int shuffle_limit ) { CHECK_ODD_NUMBER( width ); CHECK_ODD_NUMBER( height ); CHECK_SIZE( mStageWidth, width ); CHECK_SIZE( mStageHeight, height ); mActiveBlockCount = width * height; // // Clear // for( auto& p : mBlocks ) { p.Die(); } // // Build Block Type list // std::vector<eBlockType> block_type_list; { // Fill Block : Single block_type_list.resize( mActiveBlockCount, eBlockType::Single ); auto cur = block_type_list.begin(); // Fill Block : Same const int same_block_count = mActiveBlockCount * 0.3f; for( int i = 0; i < same_block_count; ++i ) { *cur = eBlockType::Same; ++cur; } // Fill Block : Different const int different_block_count = mActiveBlockCount * 0.2f; for( int i = 0; i < different_block_count; ++i ) { *cur = eBlockType::Different; ++cur; } // Shuffle x 2 const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::default_random_engine random_engine( seed ); for( int i = 0; shuffle_limit > i; ++i ) { std::shuffle( block_type_list.begin(), block_type_list.end(), random_engine ); } } // // Block Setup // { const int start_x = mCenterX - ( width / 2 ); const int start_y = mCenterY - ( height / 2 ); const int end_x = start_x + width; const int end_y = start_y + height; auto itr_block_type = block_type_list.cbegin(); int linear_index = 0; for( int cur_y = start_y; cur_y < end_y; ++cur_y ) { for( int cur_x = start_x; cur_x < end_x; ++cur_x ) { linear_index = mGridIndexConverter.To_Linear( cur_x, cur_y ); mBlocks[linear_index].Reset( *itr_block_type, cpg::Random::GetInt( 3, 9 ) ); ++itr_block_type; } } } } bool Stage::isIn( const int x, const int y ) const { if( 0 > y || mStageWidth <= y ) { return false; } if( 0 > x || mStageHeight <= x ) { return false; } return true; } const Block& Stage::GetBlockData( const int x, const int y ) const { return GetBlockData( mGridIndexConverter.To_Linear( x, y ) ); } const Block& Stage::GetBlockData( const int linear_index ) const { if( 0 > linear_index || static_cast<int>( mBlocks.size() ) <= linear_index ) { static const Block dummy( -1 ); return dummy; } return mBlocks[linear_index]; } void Stage::IncreaseBlockLife( const int linear_index ) { CHECK_LINEAR_INDEX( 0, static_cast<int>( mBlocks.size() ), linear_index ); mBlocks[linear_index].IncreaseLife(); } void Stage::DecreaseBlockLife( const int linear_index ) { CHECK_LINEAR_INDEX( 0, static_cast<int>( mBlocks.size() ), linear_index ); assert( mBlocks[linear_index].IsActive() ); mBlocks[linear_index].DecreaseLife(); if( 0 == mBlocks[linear_index].GetLife() ) { --mActiveBlockCount; } } void Stage::DieBlock( const int linear_index ) { CHECK_LINEAR_INDEX( 0, static_cast<int>( mBlocks.size() ), linear_index ); assert( mBlocks[linear_index].IsActive() ); mBlocks[linear_index].Die(); --mActiveBlockCount; } } }
23.312195
124
0.628793
R2Road
fc696135fa2874796da836a3194c730c0d99186b
756
cc
C++
src/file/Filename.cc
sdsnatcher73/openMSX
6de09386ff674668325ddf700b0b16334ad1d2ef
[ "Naumen", "Condor-1.1", "MS-PL" ]
320
2015-06-16T20:32:33.000Z
2022-03-26T17:03:27.000Z
src/file/Filename.cc
sdsnatcher73/openMSX
6de09386ff674668325ddf700b0b16334ad1d2ef
[ "Naumen", "Condor-1.1", "MS-PL" ]
2,592
2015-05-30T12:12:21.000Z
2022-03-31T17:16:15.000Z
src/file/Filename.cc
imulilla/openMSX_TSXadv
afffe852f73cb5f9a1f1d60f0ab9ff9a4da98c31
[ "Naumen", "Condor-1.1", "MS-PL" ]
74
2015-06-18T19:51:15.000Z
2022-03-24T15:09:33.000Z
#include "Filename.hh" #include "MSXException.hh" #include "serialize.hh" #include <cassert> namespace openmsx { void Filename::updateAfterLoadState() { if (empty()) return; if (FileOperations::exists(resolvedFilename)) return; try { resolvedFilename = FileOperations::getAbsolutePath( userFileContext().resolve(originalFilename)); } catch (MSXException&) { // nothing } } bool Filename::empty() const { assert(getOriginal().empty() == getResolved().empty()); return getOriginal().empty(); } template<typename Archive> void Filename::serialize(Archive& ar, unsigned /*version*/) { ar.serialize("original", originalFilename, "resolved", resolvedFilename); } INSTANTIATE_SERIALIZE_METHODS(Filename); } // namespace openmsx
21
59
0.723545
sdsnatcher73
fc6b697c6c6cbeb71b6a78fb5b7b5f5a556cfea5
6,187
cpp
C++
XDKSamples/System/FrontPanelDolphin/Dolphin.cpp
ComputeWorks/Xbox-ATG-Samples
6b88d6a03cf1efae7007a928713896863ec04ca5
[ "MIT" ]
298
2019-05-09T20:54:35.000Z
2022-03-31T20:10:51.000Z
XDKSamples/System/FrontPanelDolphin/Dolphin.cpp
ComputeWorks/Xbox-ATG-Samples
6b88d6a03cf1efae7007a928713896863ec04ca5
[ "MIT" ]
14
2019-07-07T15:25:15.000Z
2022-02-05T02:44:29.000Z
XDKSamples/System/FrontPanelDolphin/Dolphin.cpp
ComputeWorks/Xbox-ATG-Samples
6b88d6a03cf1efae7007a928713896863ec04ca5
[ "MIT" ]
137
2019-05-07T20:58:34.000Z
2022-03-30T08:01:34.000Z
//-------------------------------------------------------------------------------------- // Dolphin.cpp // // Advanced Technology Group (ATG) // Copyright (C) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- #include "pch.h" #include "Dolphin.h" #include "ReadData.h" using namespace DirectX; Dolphin::Dolphin() : m_world(XMMatrixIdentity()) , m_translation(0, 0, 0) , m_animationTime(0) , m_blendWeight(0) , m_primitiveType(D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) , m_vertexStride(0) , m_indexCount(0) , m_vertexFormat(DXGI_FORMAT_UNKNOWN) { m_animationTime = float(rand() % 100); } void Dolphin::Load(ID3D11Device *device, ID3D11DeviceContext *context, DirectX::EffectFactory *fxFactory) { std::unique_ptr<DirectX::Model> dolphinModel1 = Model::CreateFromSDKMESH(device, L"assets\\mesh\\Dolphin1.sdkmesh", *fxFactory); std::unique_ptr<DirectX::Model> dolphinModel2 = Model::CreateFromSDKMESH(device, L"assets\\mesh\\Dolphin2.sdkmesh", *fxFactory); std::unique_ptr<DirectX::Model> dolphinModel3 = Model::CreateFromSDKMESH(device, L"assets\\mesh\\Dolphin3.sdkmesh", *fxFactory); fxFactory->CreateTexture(L"dolphin.bmp", context, m_textureView.ReleaseAndGetAddressOf()); { auto& meshes = dolphinModel1->meshes; auto& meshParts = meshes[0]->meshParts; auto& part = *meshParts[0]; m_vb1 = part.vertexBuffer; m_ib = part.indexBuffer; m_primitiveType = part.primitiveType; m_indexCount = part.indexCount; m_vertexStride = part.vertexStride; m_vertexFormat = part.indexFormat; } { auto& meshes = dolphinModel2->meshes; auto& meshParts = meshes[0]->meshParts; auto& part = *meshParts[0]; m_vb2 = part.vertexBuffer; } { auto& meshes = dolphinModel3->meshes; auto& meshParts = meshes[0]->meshParts; auto& part = *meshParts[0]; m_vb3 = part.vertexBuffer; } { auto blob = DX::ReadData(L"DolphinVS.cso"); DX::ThrowIfFailed(device->CreateVertexShader(blob.data(), blob.size(), nullptr, m_vertexShader.ReleaseAndGetAddressOf())); const D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "POSITION", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 1, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "POSITION", 2, DXGI_FORMAT_R32G32B32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 2, DXGI_FORMAT_R32G32B32_FLOAT, 2, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 2, DXGI_FORMAT_R32G32_FLOAT, 2, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; DX::ThrowIfFailed(device->CreateInputLayout(layout, _countof(layout), blob.data(), blob.size(), m_vertexLayout.ReleaseAndGetAddressOf())); } } void Dolphin::OnDeviceLost() { m_textureView.Reset(); m_vb1.Reset(); m_vb2.Reset(); m_vb3.Reset(); m_ib.Reset(); m_inputLayout.Reset(); m_vertexShader.Reset(); m_vertexLayout.Reset(); } void Dolphin::Update(float, float elapsedTime) { // update the animation time for the dolphin m_animationTime += elapsedTime; // store the blend weight (this determines how fast the tale wags) m_blendWeight = sinf(6 * m_animationTime); // compute our rotation matrices and combine them with scale into our world matrix m_world = XMMatrixScaling(0.01f, 0.01f, 0.01f); // This rotation adds a little wiggle m_world = XMMatrixMultiply(XMMatrixRotationZ(cos(4 * m_animationTime) / 6.0f), m_world); // Translate and then rotate to make the dolphin swim in a circle m_world = XMMatrixMultiply(m_world, XMMatrixTranslation(0.0f, 0.0f, 8.0f)); m_world = XMMatrixMultiply(m_world, XMMatrixRotationY(-m_animationTime / 2.0f)); // Perturb the dolphin's position in vertical direction so that it looks more "floaty" m_world = XMMatrixMultiply(m_world, XMMatrixTranslation(0.0f, cos(4 * m_animationTime) / 3.0f, 0.0f)); } void Dolphin::Render(ID3D11DeviceContext * d3dDeviceContext, ID3D11PixelShader * pixelShader, ID3D11ShaderResourceView * causticResourceView) { unsigned int DolphinStrides[3] = { m_vertexStride, m_vertexStride, m_vertexStride }; unsigned int DolphinOffsets[3] = { 0, 0, 0 }; ID3D11Buffer *dolphinVBs[3] = { m_vb1.Get(), m_vb2.Get(), m_vb3.Get() }; ID3D11ShaderResourceView *textureResourceView = m_textureView.Get(); d3dDeviceContext->IASetInputLayout(m_vertexLayout.Get()); d3dDeviceContext->IASetVertexBuffers(0, 3, dolphinVBs, DolphinStrides, DolphinOffsets); d3dDeviceContext->IASetIndexBuffer(m_ib.Get(), m_vertexFormat, 0); d3dDeviceContext->IASetPrimitiveTopology(m_primitiveType); d3dDeviceContext->VSSetShader(m_vertexShader.Get(), NULL, 0); d3dDeviceContext->GSSetShader(NULL, NULL, 0); d3dDeviceContext->PSSetShader(pixelShader, NULL, 0); d3dDeviceContext->PSSetShaderResources(0, 1, &textureResourceView); d3dDeviceContext->PSSetShaderResources(1, 1, &causticResourceView); d3dDeviceContext->DrawIndexed(m_indexCount, 0, 0); } void Dolphin::Translate(DirectX::XMVECTOR t) { m_translation = XMVectorAdd(m_translation, t); } DirectX::XMMATRIX Dolphin::GetWorld() { // combine our existing world matrix with the translation XMMATRIX result = XMMatrixMultiply(m_world, XMMatrixTranslationFromVector(m_translation)); return result; } float Dolphin::GetBlendWeight() { return m_blendWeight; }
41.246667
147
0.659609
ComputeWorks
fc6d43f448b7a2c064e3971807a8361df4da8fef
2,176
hpp
C++
csvlib/csv/parser.hpp
dagronf/csvlib
790f48b7bc9d361508ea4b3fc3e9a2c962da0a47
[ "MIT" ]
1
2020-01-20T16:07:12.000Z
2020-01-20T16:07:12.000Z
csvlib/csv/parser.hpp
dagronf/csvlib
790f48b7bc9d361508ea4b3fc3e9a2c962da0a47
[ "MIT" ]
null
null
null
csvlib/csv/parser.hpp
dagronf/csvlib
790f48b7bc9d361508ea4b3fc3e9a2c962da0a47
[ "MIT" ]
null
null
null
// // CSVParser.hpp // // Created by Darren Ford on 7/10/18. // Copyright © 2018 Darren Ford. All rights reserved. // // MIT license // // 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. // #pragma once #include <csv/datasource/IDataSource.hpp> #include <functional> namespace csv { typedef enum State { Complete = 0, Cancelled = 1, Error = 2, } State; struct field { size_t row = 0; size_t column = 0; std::string content; }; struct record { size_t row = 0; std::vector<field> content; inline size_t size() const { return content.size(); } inline const field& operator[](const size_t offset) const { return content[offset]; } inline void clear() { content.clear(); } inline void add(const field& field) { content.push_back(field); } inline bool empty() const { for (const auto& field: content) { if (field.content.length() > 0) { return false; } } return true; } }; typedef std::function<bool(const field&)> FieldCallback; typedef std::function<bool(const record&, double progress)> RecordCallback; csv::State parse(IDataSource& parser, csv::FieldCallback emitField, csv::RecordCallback emitRecord); };
31.085714
120
0.725643
dagronf
fc7154833556969122eefefac7127319098a7a97
7,549
cpp
C++
Unreal2D/Plugins/UE2D/Source/UE2D/Private/Rendering/UE2DSpriteAtlasRenderProxy.cpp
dominiquefaure/UE2D
3d853ed072d0fa40cbf70de56caef53e04aa9d41
[ "MIT" ]
null
null
null
Unreal2D/Plugins/UE2D/Source/UE2D/Private/Rendering/UE2DSpriteAtlasRenderProxy.cpp
dominiquefaure/UE2D
3d853ed072d0fa40cbf70de56caef53e04aa9d41
[ "MIT" ]
null
null
null
Unreal2D/Plugins/UE2D/Source/UE2D/Private/Rendering/UE2DSpriteAtlasRenderProxy.cpp
dominiquefaure/UE2D
3d853ed072d0fa40cbf70de56caef53e04aa9d41
[ "MIT" ]
null
null
null
#include "UE2DSpriteAtlasRenderProxy.h" #include "UE2DSpriteDrawRecord.h" //------------------------------------------------------------------------------------------------ FUE2DSpriteAtlasRenderSceneProxy::FUE2DSpriteAtlasRenderSceneProxy( const UUE2DSpriteAtlasComponent* InComponent , uint32 InMaxSpriteNum ): FPrimitiveSceneProxy(InComponent), MaxSpriteNum( InMaxSpriteNum ), VertexFactory(GetScene().GetFeatureLevel(), "FASSpriteAtlasRenderSceneProxy") { // FPrimitiveSceneProxy bWillEverBeLit = false; bVerifyUsedMaterials = false; } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ FUE2DSpriteAtlasRenderSceneProxy::~FUE2DSpriteAtlasRenderSceneProxy() { VertexBuffers.PositionVertexBuffer.ReleaseResource(); VertexBuffers.StaticMeshVertexBuffer.ReleaseResource(); VertexBuffers.ColorVertexBuffer.ReleaseResource(); IndexBuffer.ReleaseResource(); VertexFactory.ReleaseResource(); } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ SIZE_T FUE2DSpriteAtlasRenderSceneProxy::GetTypeHash() const { static size_t UniquePointer; return reinterpret_cast<size_t>(&UniquePointer); } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ uint32 FUE2DSpriteAtlasRenderSceneProxy::GetMemoryFootprint() const { return ( sizeof( this ) + FPrimitiveSceneProxy::GetAllocatedSize() ); } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ void FUE2DSpriteAtlasRenderSceneProxy::CreateRenderThreadResources( ) { IndexBuffer.NumSprites = MaxSpriteNum; IndexBuffer.InitResource(); VertexBuffers.InitWithDummyData(&VertexFactory, MaxSpriteNum * 4 , 2); } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ FPrimitiveViewRelevance FUE2DSpriteAtlasRenderSceneProxy::GetViewRelevance( const FSceneView* View ) const { FPrimitiveViewRelevance Result; Result.bDrawRelevance = IsShown(View); Result.bRenderCustomDepth = ShouldRenderCustomDepth(); Result.bRenderInMainPass = ShouldRenderInMainPass(); Result.bUsesLightingChannels = false; Result.bOpaque = true; Result.bSeparateTranslucency = true; Result.bNormalTranslucency = false; Result.bShadowRelevance = IsShadowCast(View); Result.bDynamicRelevance = true; return Result; } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ void FUE2DSpriteAtlasRenderSceneProxy::GetDynamicMeshElements( const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector ) const { if( RenderBatch.Material == nullptr ) { return; } // to fix crash when the Material is destroyed if( RenderBatch.Material->GetFName() == TEXT("None") ) { return; } if( !RenderBatch.Material->IsValidLowLevelFast() ) { return; } const bool bWireframe = AllowDebugViewmodes() && ViewFamily.EngineShowFlags.Wireframe; FMaterialRenderProxy* MaterialProxy = NULL; if(bWireframe) { FColoredMaterialRenderProxy* WireframeMaterialInstance = new FColoredMaterialRenderProxy( GEngine->WireframeMaterial ? GEngine->WireframeMaterial->GetRenderProxy() : NULL, FLinearColor(0, 0.5f, 1.f) ); Collector.RegisterOneFrameMaterialProxy(WireframeMaterialInstance); MaterialProxy = WireframeMaterialInstance; } else { // if( RenderBatch.Material->GetName() != TEXT( "None" ) ) { MaterialProxy = RenderBatch.Material->GetRenderProxy(); } } for( int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++ ) { if( VisibilityMap & (1 << ViewIndex) ) { // Draw the mesh. FMeshBatch& Mesh = Collector.AllocateMesh(); Mesh.VertexFactory = &VertexFactory; Mesh.MaterialRenderProxy = MaterialProxy; Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative(); Mesh.CastShadow = false; Mesh.DepthPriorityGroup = SDPG_World; Mesh.Type = PT_TriangleList; Mesh.bDisableBackfaceCulling = true; Mesh.bCanApplyViewModeOverrides = false; FMeshBatchElement& BatchElement = Mesh.Elements[0]; BatchElement.IndexBuffer = &IndexBuffer; BatchElement.FirstIndex = RenderBatch.FirstIndex; BatchElement.MinVertexIndex = RenderBatch.MinVertexIndex; BatchElement.MaxVertexIndex = RenderBatch.MaxVertexIndex; BatchElement.NumPrimitives = RenderBatch.NumPrimitives; Collector.AddMesh( ViewIndex, Mesh ); #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) // Render bounds RenderBounds( Collector.GetPDI( ViewIndex ), ViewFamily.EngineShowFlags, GetBounds(), IsSelected() ); #endif } } } //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ void FUE2DSpriteAtlasRenderSceneProxy::SetDynamicData_RenderThread( const FUE2DSpriteDrawRecord& Record ) { check(IsInRenderingThread()); Record.Apply( VertexBuffers ); // Apply the values set to the RHI uint32 verticeCount = 4; { auto& VertexBuffer = VertexBuffers.PositionVertexBuffer; void* VertexBufferData = RHILockBuffer( VertexBuffer.VertexBufferRHI , 0 , verticeCount * VertexBuffer.GetStride() , RLM_WriteOnly ); FMemory::Memcpy( VertexBufferData , VertexBuffer.GetVertexData() , verticeCount * VertexBuffer.GetStride() ); RHIUnlockBuffer( VertexBuffer.VertexBufferRHI ); } { auto& VertexBuffer = VertexBuffers.ColorVertexBuffer; void* VertexBufferData = RHILockBuffer( VertexBuffer.VertexBufferRHI , 0 , VertexBuffer.GetNumVertices() * VertexBuffer.GetStride() , RLM_WriteOnly ); FMemory::Memcpy( VertexBufferData , VertexBuffer.GetVertexData() , VertexBuffer.GetNumVertices() * VertexBuffer.GetStride() ); RHIUnlockBuffer( VertexBuffer.VertexBufferRHI ); } /* { auto& ColorBuffer = VertexBuffers.ColorVertexBuffer; void* VertexBufferData = RHILockBuffer( ColorBuffer.VertexBufferRHI, 0, verticeCount * ColorBuffer.GetStride(), RLM_WriteOnly); FMemory::Memcpy(VertexBufferData, ColorBuffer.GetVertexData(), verticeCount * ColorBuffer.GetStride()); RHIUnlockBuffer( ColorBuffer.VertexBufferRHI); } */ { auto& VertexBuffer = VertexBuffers.StaticMeshVertexBuffer; void* VertexBufferData = RHILockBuffer(VertexBuffer.TexCoordVertexBuffer.VertexBufferRHI, 0, VertexBuffer.GetTexCoordSize(), RLM_WriteOnly); FMemory::Memcpy(VertexBufferData, VertexBuffer.GetTexCoordData(), VertexBuffer.GetTexCoordSize()); RHIUnlockBuffer(VertexBuffer.TexCoordVertexBuffer.VertexBufferRHI); } RenderBatch.Material = Record.Material; RenderBatch.FirstIndex = 0; RenderBatch.MaxIndex = 5; RenderBatch.NumPrimitives = 2; RenderBatch.MinVertexIndex = 0; RenderBatch.MaxVertexIndex = 3; } //------------------------------------------------------------------------------------------------
38.712821
201
0.610942
dominiquefaure
fc74bcac02f750ba02266a8783c14b7b376d3cc7
1,175
cpp
C++
Libraries/Meta/Object.cpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
3
2022-02-11T10:34:33.000Z
2022-02-24T17:44:17.000Z
Libraries/Meta/Object.cpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
null
null
null
Libraries/Meta/Object.cpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
null
null
null
// MIT Licensed (see LICENSE.md). #include "Precompiled.hpp" namespace Zero { // @TrevorS: Move this to be filled out automatically in my binding! BoundType* ObjectBindingVirtualTypeFn(const byte* memory) { const Object* object = (const Object*)memory; return object->ZilchGetDerivedType(); } ZilchDefineType(Object, builder, type) { type->GetBindingVirtualType = &ObjectBindingVirtualTypeFn; } Memory::Heap* sGeneralPool = NULL; void* Object::operator new(size_t size) { if (sGeneralPool == NULL) sGeneralPool = new Memory::Heap("System", Memory::GetRoot()); return sGeneralPool->Allocate(size); }; void Object::operator delete(void* pMem, size_t size) { sGeneralPool->Deallocate(pMem, size); } Object::~Object() { } bool Object::SetProperty(StringParam propertyName, AnyParam val) { Property* prop = ZilchVirtualTypeId(this)->GetProperty(propertyName); if (prop == nullptr) return false; prop->SetValue(this, val); return true; } Any Object::GetProperty(StringParam propertyName) { Property* prop = ZilchVirtualTypeId(this)->GetProperty(propertyName); if (prop) return prop->GetValue(this); return Any(); } } // namespace Zero
22.169811
71
0.72766
RyanTylerRae
fc76cdf84adb4d62bcfcc91580878d68cb7c9b23
682
cpp
C++
cumulative_sum/abc122_c.cpp
Takumi1122/data-structure-algorithm
6b9f26e4dbba981f034518a972ecfc698b86d837
[ "MIT" ]
null
null
null
cumulative_sum/abc122_c.cpp
Takumi1122/data-structure-algorithm
6b9f26e4dbba981f034518a972ecfc698b86d837
[ "MIT" ]
null
null
null
cumulative_sum/abc122_c.cpp
Takumi1122/data-structure-algorithm
6b9f26e4dbba981f034518a972ecfc698b86d837
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; // 'C'が右隣にあるような'A'の個数 // "TTACTTTA|C"のような「右端の'A'の右隣に'C'がある」というような'A'を除外する /* 参考リンク ABC 122 C - GeT AC https://atcoder.jp/contests/abc122/tasks/abc122_c */ int main() { int n, q; cin >> n >> q; string str; cin >> str; // 累積和 vector<int> s(n + 1, 0); rep(i, n) { if (i + 1 < n && str[i] == 'A' && str[i + 1] == 'C') s[i + 1] = s[i] + 1; else s[i + 1] = s[i]; } // クエリ rep(i, q) { int l, r; cin >> l >> r; --l, --r; // 0-indexed にする cout << s[r] - s[l] << endl; } }
17.947368
56
0.472141
Takumi1122
fc81c088aaf11772e5449746a6cbe2052a5f8660
802
cpp
C++
src/main.cpp
ToruNiina/cortex
a4933b81290bef547843ffda0a411e442ebee116
[ "MIT" ]
null
null
null
src/main.cpp
ToruNiina/cortex
a4933b81290bef547843ffda0a411e442ebee116
[ "MIT" ]
null
null
null
src/main.cpp
ToruNiina/cortex
a4933b81290bef547843ffda0a411e442ebee116
[ "MIT" ]
null
null
null
#include "cortex/cortex.hpp" #include <fstream> int main(int argc, char **argv) { if(argc == 1) { cortex::Cortex ctx; ctx.run(); } else if(argc == 2) { const std::string filename(argv[1]); std::ifstream ifs(filename); if(!ifs.good()) { std::cerr << "file open error : " + filename << std::endl; return 1; } std::string content; while(!ifs.eof()) { std::string buf; std::getline(ifs, buf); content += buf; } cortex::Instruction inst(content); cortex::Cortex ctx(inst); ctx.execute(); } else { std::cerr << "usage: cortex [source file]" << std::endl; return 1; } return 0; }
21.105263
70
0.46384
ToruNiina
fc84bac51dcd60f0039ecea8c642016c9e9d690a
11,499
cpp
C++
src/Terrain.cpp
foxostro/CheeseTesseract
737ebbd19cee8f5a196bf39a11ca793c561e56cb
[ "MIT" ]
1
2016-05-17T03:36:52.000Z
2016-05-17T03:36:52.000Z
src/Terrain.cpp
foxostro/CheeseTesseract
737ebbd19cee8f5a196bf39a11ca793c561e56cb
[ "MIT" ]
null
null
null
src/Terrain.cpp
foxostro/CheeseTesseract
737ebbd19cee8f5a196bf39a11ca793c561e56cb
[ "MIT" ]
null
null
null
#include "stdafx.h" #include "Material.h" #include "FileFuncs.h" #include "Mesh.h" #include "PhysicsEngine.h" #include "devil_wrapper.h" #include "ActionQueueRenderInstance.h" #include "GrassLayer.h" #include "TreeLayer.h" #include "Terrain.h" #include "RenderMethodTags.h" dReal heightfieldCallback(void *_heightmapData, int y, int x) { ASSERT(_heightmapData, "Parameter \"_heightmapData\" was null"); const HeightMapData &heightmapData = *reinterpret_cast<HeightMapData*>(_heightmapData); const int w = heightmapData.w; const float *heightMap = heightmapData.heightmap; ASSERT(heightMap, "\"heightMap\" was null"); return heightMap[(y*w)+x]; } Terrain::~Terrain() { delete [] heightmap.heightmap; } Terrain::Terrain(UID uid, ScopedEventHandler *parentScope) : geom(0), ScopedEventHandlerSubscriber(uid, parentScope) { clear(); } void Terrain::clear() { if (geom) { dGeomDestroy(geom); geom=0; } mesh.reset(); grassLayer.reset(); treeLayer.reset(); scaleXY=1.0f; scaleZ=1.0f; enableGrass=true; enableTrees=true; } HeightMapData Terrain::loadHeightMap(const FileName &fileName) { CHECK_GL_ERROR(); unsigned int imageName = devil_loadImage(fileName); // Get image data unsigned char *imgData = ilGetData(); int imgWidth = ilGetInteger(IL_IMAGE_WIDTH); int imgHeight = ilGetInteger(IL_IMAGE_HEIGHT); int bytesPerPixel = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); ASSERT(imgData!=0, "Failed to load heightmap: " + fileName.str()); ASSERT(imgWidth == imgHeight, "Heightmap is not square!"); const size_t rowSize = imgWidth * bytesPerPixel; const size_t imageSize = imgHeight * rowSize; float *heightmap = new float[imgWidth * imgHeight]; for (size_t y = 0; y < (size_t)(imgHeight); ++y) { unsigned char *row = imgData + (y*rowSize); for (size_t x = 0; x < rowSize; x += bytesPerPixel) { const unsigned char &red = row[x]; // Height information is stored in the RED component heightmap[y*imgWidth + x] = red / 255.0f; } } // return HeightMapData data; data.heightmap = heightmap; data.w = imgWidth; data.h = imgHeight; return data; } void Terrain::generateVertices(vector<vec3> &verticesArray, vector<vec3> &normalsArray, vector<vec2> &texcoordsArray, const int heightmapSize, const float *heightmap, const float scaleXY, const float scaleZ) { const int numVertices = heightmapSize * heightmapSize; verticesArray.resize(numVertices); normalsArray.resize(numVertices); texcoordsArray.resize(numVertices); for (int y=0; y<heightmapSize; ++y) { for (int x=0; x<heightmapSize; ++x) { const size_t idx = y*heightmapSize + x; verticesArray[idx] = vec3((float)x*scaleXY, (float)y*scaleXY, heightmap[idx]*scaleZ); normalsArray[idx] = vec3(0,0,1); // fake texcoordsArray[idx] = vec2((float)x, (float)y); } } // Generate face normals (except for edge vertices, don't care about them) for (int y=1; y<heightmapSize-1; ++y) { for (int x=1; x<heightmapSize-1; ++x) { Triangle t1 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y+1)*heightmapSize + (x-1)], verticesArray[(y+0)*heightmapSize + (x-1)] }; Triangle t2 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y+1)*heightmapSize + (x+0)], verticesArray[(y+1)*heightmapSize + (x-1)] }; Triangle t3 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y+0)*heightmapSize + (x-1)], verticesArray[(y-1)*heightmapSize + (x+0)] }; Triangle t4 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y+0)*heightmapSize + (x+1)], verticesArray[(y+1)*heightmapSize + (x+0)] }; Triangle t5 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y-1)*heightmapSize + (x+0)], verticesArray[(y-1)*heightmapSize + (x+1)] }; Triangle t6 = {verticesArray[(y+0)*heightmapSize + (x+0)], verticesArray[(y-1)*heightmapSize + (x+1)], verticesArray[(y+0)*heightmapSize + (x+1)] }; vec3 n1 = calcTriNorm(t1); vec3 n2 = calcTriNorm(t2); vec3 n3 = calcTriNorm(t3); vec3 n4 = calcTriNorm(t4); vec3 n5 = calcTriNorm(t5); vec3 n6 = calcTriNorm(t6); // Take the smooth, averaged normal of adjacent faces vec3 n = (n1 + n2 + n3 + n4 + n5 + n6) * (1.0f/6.0f); normalsArray[y*heightmapSize + x] = n; } } } vector<Face> Terrain::generateIndices(const int heightmapSize) { const int numFaces = (heightmapSize-1) * (heightmapSize-1) * 2; vector<Face> facesArray; facesArray.resize(numFaces); int idx=0; for (int y=0; y<heightmapSize-1; ++y) { for (int x=0; x<heightmapSize-1; ++x) { addTerrainQuad(x, y, heightmapSize, facesArray, idx); } } return facesArray; } shared_ptr<Mesh> Terrain::generateGeometry(const int heightmapSize, const float *heightmap, TextureFactory &textureFactory, const FileName heightmapTex, const float scaleXY, const float scaleZ) { vector<vec3> verticesArray; vector<vec3> normalsArray; vector<vec2> texcoordsArray; // Generate geometry generateVertices(verticesArray, normalsArray, texcoordsArray, heightmapSize, heightmap, scaleXY, scaleZ); vector<Face> facesArray = generateIndices(heightmapSize); shared_ptr<Mesh> mesh(new Mesh(verticesArray, normalsArray, texcoordsArray, facesArray, true)); // completely static mesh mesh->material = Material(textureFactory.load(heightmapTex)); mesh->material.shininess = 64.0f; mesh->polygonWinding = GL_CCW; return mesh; } void Terrain::create(const PropertyBag &data, shared_ptr<class Renderer> renderer, TextureFactory &textureFactory, shared_ptr<PhysicsEngine> _physicsEngine) { ASSERT(_physicsEngine, "Physics engine was null"); physicsEngine = _physicsEngine; scaleXY = data.getFloat("scaleXY"); scaleZ = data.getFloat("scaleZ"); const FileName heightmapFile = data.getFileName("heightmap"); const FileName heightmapTex = data.getFileName("material"); const FileName grassMaterial = data.getFileName("grassMaterial"); // Loads heightmap this->heightmap = loadHeightMap(heightmapFile); // Generate heightmap geometry mesh = generateGeometry(heightmap.w, heightmap.heightmap, textureFactory, heightmapTex, scaleXY, scaleZ); // Send heightmap to physics engine { tuple<dGeomID,dTriMeshDataID> result = mesh->createGeom(physicsEngine->getSpace()); geom = result.get<0>(); dGeomSetPosition(geom, 0.0f, 0.0f, 0.0f); } // Prepare a static render instance for future rendering { mesh->getGeometryChunk(renderInstance.gc); renderInstance.gc.transformation.identity(); // Stick with default render method and material settings } generateGrassLayer(renderer, textureFactory); generateTreeLayer(); } void Terrain::emitGeometry() { ActionQueueRenderInstance action1(renderInstance); sendGlobalAction(&action1); if (enableGrass) { emitGrassGeometry(); } if (enableTrees) { emitTreeGeometry(); } } tuple<float,vec3> Terrain::getElevation(const HeightMapData &heightmap, vec2 p) { // Ray cast to get all contact points with the terrain float rayLength = 100.0f; vec3 rayOrigin = vec3(p.x, p.y, rayLength); vec3 rayDirection = vec3(0,0,-1); dContactGeom contact; if (physicsEngine->rayCast(rayOrigin, rayDirection, rayLength, geom, contact)) { // Pack the results float z = (float)contact.pos[2]; vec3 n = vec3((float)contact.normal[0], (float)contact.normal[1], (float)contact.normal[2]); return make_tuple(z,n); } else { float z = 0.0f; vec3 n = vec3(0.0f, 0.0f, 1.0f); return make_tuple(z,n); } } void Terrain::addTerrainQuad(int x, int y, int heightmapSize, vector<Face> &facesArray, int &idx) { Face a; a.vertIndex[0] = a.coordIndex[0] = a.normalIndex[0] = (y+0)*heightmapSize + (x+0); a.vertIndex[1] = a.coordIndex[1] = a.normalIndex[1] = (y+0)*heightmapSize + (x+1); a.vertIndex[2] = a.coordIndex[2] = a.normalIndex[2] = (y+1)*heightmapSize + (x+0); facesArray[idx++] = a; Face b; b.vertIndex[0] = b.coordIndex[0] = b.normalIndex[0] = (y+0)*heightmapSize + (x+1); b.vertIndex[1] = b.coordIndex[1] = b.normalIndex[1] = (y+1)*heightmapSize + (x+1); b.vertIndex[2] = b.coordIndex[2] = b.normalIndex[2] = (y+1)*heightmapSize + (x+0); facesArray[idx++] = b; } void Terrain::emitGrassGeometry() { vector<ActionQueueRenderInstance> batches; vector<ActionQueueRenderInstance>::const_iterator i; ASSERT(grassLayer, "Null pointer: grassLayer"); // Get the grass batches grassLayer->emitGeometry(batches); // Send batches to the renderer for (i=batches.begin(); i!=batches.end(); ++i) { const ActionQueueRenderInstance &action = *i; sendGlobalAction(&action); } } void Terrain::emitTreeGeometry() { vector<ActionQueueTreeForRender> actions; vector<ActionQueueTreeForRender>::const_iterator i; ASSERT(treeLayer, "Null pointer: treeLayer"); // Get the tree instance data treeLayer->queueForRender(actions); // Send trees to the renderer for (i=actions.begin(); i!=actions.end(); ++i) { const ActionQueueTreeForRender &action = *i; sendGlobalAction(&action); } } void Terrain::generateTreeLayer() { treeLayer = shared_ptr<TreeLayer>(new TreeLayer()); vec2 center = vec2(heightmap.w, heightmap.h) * (scaleXY / 2); float size = heightmap.h * scaleXY; treeLayer->generate(center, size, bind(&Terrain::getElevation, this, heightmap, _1)); } void Terrain::generateGrassLayer(shared_ptr<class Renderer> renderer, TextureFactory & textureFactory) { grassLayer = shared_ptr<GrassLayer>(new GrassLayer(renderer, textureFactory)); vec2 center = vec2(heightmap.w, heightmap.h) * (scaleXY / 2); float size = heightmap.h * scaleXY; grassLayer->generate(center, size, bind(&Terrain::getElevation, this, heightmap, _1)); }
31.941667
89
0.592573
foxostro
fc88ea60224551b9c812c5e80ae7fe240ac57d69
2,536
cpp
C++
simulator/dht.cpp
tovarchristian21/Medical-Health-Records-usign-Blockchain-in-a-P2P-Network
b7d04635a92b73192c0abbb085e9ad27854c520c
[ "MIT" ]
null
null
null
simulator/dht.cpp
tovarchristian21/Medical-Health-Records-usign-Blockchain-in-a-P2P-Network
b7d04635a92b73192c0abbb085e9ad27854c520c
[ "MIT" ]
null
null
null
simulator/dht.cpp
tovarchristian21/Medical-Health-Records-usign-Blockchain-in-a-P2P-Network
b7d04635a92b73192c0abbb085e9ad27854c520c
[ "MIT" ]
null
null
null
#include "dht.h" Node::Node(int guid) { guid_m=guid; known_m=GNULL; predecessor_m=this;//(Node*)&guid_m; successor_m=nullptr; } void Node::info() { cout<<"✺ Node: "<<guid_m<<endl; if(predecessor_m) cout<<" Predecessor: "<<predecessor_m->guid_m<<endl; else cout<<" Predecessor: null"<<endl; cout<<" Known: "<<known_m<<endl; if(successor_m) cout<<" Successor: "<<successor_m->guid_m<<endl; else cout<<" Successor: null"<<endl; cout<<"\t"<<endl; } void Node::join(Node& bootstrap) { cout<<guid_m<<" joined::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"<<endl; known_m=bootstrap.guid_m; if(between(bootstrap.guid_m, guid_m,bootstrap.successor_m->guid_m) ) { successor_m=bootstrap.successor_m; } else { successor_m= bootstrap.lookup_successor(guid_m, bootstrap.successor_m); } } Node* Node::lookup_successor(int guid, Node *successor) { if( between(successor->guid_m , guid, successor->successor_m->guid_m) ) { return lookup_successor(guid, successor->successor_m); } else{ return successor; } } void Node::stabilize() { cout<<guid_m<<" stabilized::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"<<endl; if( between(successor_m->predecessor_m->guid_m, guid_m, successor_m->guid_m ) || successor_m->predecessor_m->guid_m==guid_m ) { // no actualiza sucesor } else {successor_m=successor_m->predecessor_m;} //notifica al sucesor independientemente successor_m->rectify(&guid_m); } void Node::rectify(int* guid) { //ping predecessor_m cout<<guid_m<<" rectified::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"<<endl; if( between(predecessor_m->guid_m, *guid, guid_m)) { predecessor_m=(Node*)guid; } } bool between(int n1, int n2, int n3) { if (n1<n3) return (n1<n2 && n2<n3); else return (n1<n2 || n2<n3); } void initialize(Node& n1, Node& n2) { n1.successor_m=&n2; n1.predecessor_m=&n2; n2.successor_m=&n1; n2.predecessor_m=&n1; cout<<"Chord initialized <"<<n1.guid_m<<","<<n2.guid_m<<">:::::::::::::::::::::::::::::::::::::::::::::\n"<<endl; }
24.384615
133
0.49724
tovarchristian21
fc8aa3d06a79bccf2c5d7706297ba48e9d895126
4,016
ipp
C++
implement/oglplus/enums/stencil_operation_class.ipp
Extrunder/oglplus
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
[ "BSL-1.0" ]
459
2016-03-16T04:11:37.000Z
2022-03-31T08:05:21.000Z
implement/oglplus/enums/stencil_operation_class.ipp
Extrunder/oglplus
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
[ "BSL-1.0" ]
2
2016-08-08T18:26:27.000Z
2017-05-08T23:42:22.000Z
implement/oglplus/enums/stencil_operation_class.ipp
Extrunder/oglplus
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
[ "BSL-1.0" ]
47
2016-05-31T15:55:52.000Z
2022-03-28T14:49:40.000Z
// File implement/oglplus/enums/stencil_operation_class.ipp // // Automatically generated file, DO NOT modify manually. // Edit the source 'source/enums/oglplus/stencil_operation.txt' // or the 'source/enums/make_enum.py' script instead. // // Copyright 2010-2015 Matus Chochlik. // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // namespace enums { template <typename Base, template<StencilOperation> class Transform> class EnumToClass<Base, StencilOperation, Transform> : public Base { private: Base& _base(void) { return *this; } public: #if defined GL_KEEP # if defined Keep # pragma push_macro("Keep") # undef Keep Transform<StencilOperation::Keep> Keep; # pragma pop_macro("Keep") # else Transform<StencilOperation::Keep> Keep; # endif #endif #if defined GL_ZERO # if defined Zero # pragma push_macro("Zero") # undef Zero Transform<StencilOperation::Zero> Zero; # pragma pop_macro("Zero") # else Transform<StencilOperation::Zero> Zero; # endif #endif #if defined GL_REPLACE # if defined Replace # pragma push_macro("Replace") # undef Replace Transform<StencilOperation::Replace> Replace; # pragma pop_macro("Replace") # else Transform<StencilOperation::Replace> Replace; # endif #endif #if defined GL_INCR # if defined Incr # pragma push_macro("Incr") # undef Incr Transform<StencilOperation::Incr> Incr; # pragma pop_macro("Incr") # else Transform<StencilOperation::Incr> Incr; # endif #endif #if defined GL_DECR # if defined Decr # pragma push_macro("Decr") # undef Decr Transform<StencilOperation::Decr> Decr; # pragma pop_macro("Decr") # else Transform<StencilOperation::Decr> Decr; # endif #endif #if defined GL_INVERT # if defined Invert # pragma push_macro("Invert") # undef Invert Transform<StencilOperation::Invert> Invert; # pragma pop_macro("Invert") # else Transform<StencilOperation::Invert> Invert; # endif #endif #if defined GL_INCR_WRAP # if defined IncrWrap # pragma push_macro("IncrWrap") # undef IncrWrap Transform<StencilOperation::IncrWrap> IncrWrap; # pragma pop_macro("IncrWrap") # else Transform<StencilOperation::IncrWrap> IncrWrap; # endif #endif #if defined GL_DECR_WRAP # if defined DecrWrap # pragma push_macro("DecrWrap") # undef DecrWrap Transform<StencilOperation::DecrWrap> DecrWrap; # pragma pop_macro("DecrWrap") # else Transform<StencilOperation::DecrWrap> DecrWrap; # endif #endif EnumToClass(void) { } EnumToClass(Base&& base) : Base(std::move(base)) #if defined GL_KEEP # if defined Keep # pragma push_macro("Keep") # undef Keep , Keep(_base()) # pragma pop_macro("Keep") # else , Keep(_base()) # endif #endif #if defined GL_ZERO # if defined Zero # pragma push_macro("Zero") # undef Zero , Zero(_base()) # pragma pop_macro("Zero") # else , Zero(_base()) # endif #endif #if defined GL_REPLACE # if defined Replace # pragma push_macro("Replace") # undef Replace , Replace(_base()) # pragma pop_macro("Replace") # else , Replace(_base()) # endif #endif #if defined GL_INCR # if defined Incr # pragma push_macro("Incr") # undef Incr , Incr(_base()) # pragma pop_macro("Incr") # else , Incr(_base()) # endif #endif #if defined GL_DECR # if defined Decr # pragma push_macro("Decr") # undef Decr , Decr(_base()) # pragma pop_macro("Decr") # else , Decr(_base()) # endif #endif #if defined GL_INVERT # if defined Invert # pragma push_macro("Invert") # undef Invert , Invert(_base()) # pragma pop_macro("Invert") # else , Invert(_base()) # endif #endif #if defined GL_INCR_WRAP # if defined IncrWrap # pragma push_macro("IncrWrap") # undef IncrWrap , IncrWrap(_base()) # pragma pop_macro("IncrWrap") # else , IncrWrap(_base()) # endif #endif #if defined GL_DECR_WRAP # if defined DecrWrap # pragma push_macro("DecrWrap") # undef DecrWrap , DecrWrap(_base()) # pragma pop_macro("DecrWrap") # else , DecrWrap(_base()) # endif #endif { } }; } // namespace enums
21.136842
68
0.722361
Extrunder
475fca554a27ce4827df6b0a9c4bd135f6dec188
7,787
cpp
C++
src/plugins/imagefilter_addnoise/filter.cpp
deiflou/ibp
9728f7569b59aa261dcaffc8332a1b02c2cd5fbe
[ "MIT" ]
6
2015-05-07T18:44:34.000Z
2018-12-12T15:57:40.000Z
src/plugins/imagefilter_addnoise/filter.cpp
deiflou/ibp
9728f7569b59aa261dcaffc8332a1b02c2cd5fbe
[ "MIT" ]
null
null
null
src/plugins/imagefilter_addnoise/filter.cpp
deiflou/ibp
9728f7569b59aa261dcaffc8332a1b02c2cd5fbe
[ "MIT" ]
2
2021-03-22T10:01:32.000Z
2021-12-20T05:23:46.000Z
// // MIT License // // Copyright (c) Deif Lou // // 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 <QTime> #include <math.h> #include "filter.h" #include "filterwidget.h" #include <imgproc/types.h> #include <misc/util.h> using namespace ibp::imgproc; Filter::Filter() : mAmount(0.0), mDistribution(Uniform), mColorMode(Monochromatic) { mSeed = (unsigned int)QTime::currentTime().msec(); } Filter::~Filter() { } ImageFilter *Filter::clone() { Filter * f = new Filter(); f->mAmount = mAmount; f->mDistribution = mDistribution; f->mColorMode = mColorMode; f->mSeed = mSeed; return f; } extern "C" QHash<QString, QString> getIBPPluginInfo(); QHash<QString, QString> Filter::info() { return getIBPPluginInfo(); } QImage Filter::process(const QImage &inputImage) { if (inputImage.isNull() || inputImage.format() != QImage::Format_ARGB32) return inputImage; if (qFuzzyIsNull(mAmount)) return inputImage; QImage i = QImage(inputImage.width(), inputImage.height(), QImage::Format_ARGB32); register int totalPixels = inputImage.width() * inputImage.height(); register BGRA * srcBits = (BGRA *)inputImage.bits(); register BGRA * dstBits = (BGRA *)i.bits(); register int r, g, b; register int amount = mAmount * 255 / 100; const double minus_2_times_log_of_RAND_MAX_plus_1 = -2. * log (RAND_MAX + 1.0); const double IBP_2PI_over_RAND_MAX = IBP_2PI / RAND_MAX; qsrand(mSeed); if (mColorMode == Monochromatic) { if (mDistribution == Uniform) { while (totalPixels--) { r = 2 * (long)qrand() * amount / RAND_MAX - amount; dstBits->r = IBP_clamp(0, srcBits->r + r, 255); dstBits->g = IBP_clamp(0, srcBits->g + r, 255); dstBits->b = IBP_clamp(0, srcBits->b + r, 255); dstBits->a = srcBits->a; srcBits++; dstBits++; } } else { while (totalPixels--) { r = sqrt(-2. * log(qrand() + 1) - minus_2_times_log_of_RAND_MAX_plus_1) * cos(qrand() * IBP_2PI_over_RAND_MAX) * amount; dstBits->r = IBP_clamp(0, srcBits->r + r, 255); dstBits->g = IBP_clamp(0, srcBits->g + r, 255); dstBits->b = IBP_clamp(0, srcBits->b + r, 255); dstBits->a = srcBits->a; srcBits++; dstBits++; } } } else { if (mDistribution == Uniform) { while (totalPixels--) { r = 2 * (long)qrand() * amount / RAND_MAX - amount; g = 2 * (long)qrand() * amount / RAND_MAX - amount; b = 2 * (long)qrand() * amount / RAND_MAX - amount; dstBits->r = IBP_clamp(0, srcBits->r + r, 255); dstBits->g = IBP_clamp(0, srcBits->g + g, 255); dstBits->b = IBP_clamp(0, srcBits->b + b, 255); dstBits->a = srcBits->a; srcBits++; dstBits++; } } else { while (totalPixels--) { r = sqrt(-2. * log(qrand() + 1) - minus_2_times_log_of_RAND_MAX_plus_1) * cos(qrand() * IBP_2PI_over_RAND_MAX) * amount; g = sqrt(-2. * log(qrand() + 1) - minus_2_times_log_of_RAND_MAX_plus_1) * cos(qrand() * IBP_2PI_over_RAND_MAX) * amount; b = sqrt(-2. * log(qrand() + 1) - minus_2_times_log_of_RAND_MAX_plus_1) * cos(qrand() * IBP_2PI_over_RAND_MAX) * amount; dstBits->r = IBP_clamp(0, srcBits->r + r, 255); dstBits->g = IBP_clamp(0, srcBits->g + g, 255); dstBits->b = IBP_clamp(0, srcBits->b + b, 255); dstBits->a = srcBits->a; srcBits++; dstBits++; } } } return i; } bool Filter::loadParameters(QSettings &s) { double amount; QString distributionStr, colormodeStr; Distribution distribution; ColorMode colormode; unsigned int seed; bool ok; amount = s.value("amount", 0.0).toDouble(&ok); if (!ok || amount < 0. || amount > 400.) return false; distributionStr = s.value("distribution", "uniform").toString(); if (distributionStr == "uniform") distribution = Uniform; else if (distributionStr == "gaussian") distribution = Gaussian; else return false; colormodeStr = s.value("colormode", "monochromatic").toString(); if (colormodeStr == "monochromatic") colormode = Monochromatic; else if (colormodeStr == "color") colormode = Color; else return false; seed = s.value("seed", 0).toUInt(&ok); if (!ok) return false; mSeed = seed; setAmount(amount); setDistribution(distribution); setColorMode(colormode); return true; } bool Filter::saveParameters(QSettings &s) { s.setValue("amount", mAmount); s.setValue("distribution", mDistribution == Uniform ? "uniform" : "gaussian"); s.setValue("colormode", mColorMode == Monochromatic ? "monochromatic" : "color"); s.setValue("seed", mSeed); return true; } QWidget *Filter::widget(QWidget *parent) { FilterWidget * fw = new FilterWidget(parent); fw->setAmount(mAmount); fw->setDistribution(mDistribution); fw->setColorMode(mColorMode); connect(this, SIGNAL(amountChanged(double)), fw, SLOT(setAmount(double))); connect(this, SIGNAL(distributionChanged(Filter::Distribution)), fw, SLOT(setDistribution(Filter::Distribution))); connect(this, SIGNAL(colorModeChanged(Filter::ColorMode)), fw, SLOT(setColorMode(Filter::ColorMode))); connect(fw, SIGNAL(amountChanged(double)), this, SLOT(setAmount(double))); connect(fw, SIGNAL(distributionChanged(Filter::Distribution)), this, SLOT(setDistribution(Filter::Distribution))); connect(fw, SIGNAL(colorModeChanged(Filter::ColorMode)), this, SLOT(setColorMode(Filter::ColorMode))); return fw; } void Filter::setAmount(double v) { if (qFuzzyCompare(v, mAmount)) return; mAmount = v; emit amountChanged(v); emit parametersChanged(); } void Filter::setDistribution(Filter::Distribution v) { if (v == mDistribution) return; mDistribution = v; emit distributionChanged(v); emit parametersChanged(); } void Filter::setColorMode(Filter::ColorMode v) { if (v == mColorMode) return; mColorMode = v; emit colorModeChanged(v); emit parametersChanged(); }
31.654472
106
0.598176
deiflou
47632bc98adf6613167c7027a1847ff6a8ca7de3
2,325
cpp
C++
iRODS/lib/api/src/rcDataObjRead.cpp
PlantandFoodResearch/irods
9dfe7ffe5aa0760b7493bd9392ea1270df9335d4
[ "BSD-3-Clause" ]
null
null
null
iRODS/lib/api/src/rcDataObjRead.cpp
PlantandFoodResearch/irods
9dfe7ffe5aa0760b7493bd9392ea1270df9335d4
[ "BSD-3-Clause" ]
null
null
null
iRODS/lib/api/src/rcDataObjRead.cpp
PlantandFoodResearch/irods
9dfe7ffe5aa0760b7493bd9392ea1270df9335d4
[ "BSD-3-Clause" ]
null
null
null
/** * @file rcDataObjRead.c * */ /*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /* This is script-generated code. */ /* See dataObjRead.h for a description of this API call.*/ #include "dataObjRead.hpp" /** * \fn rcDataObjRead (rcComm_t *conn, openedDataObjInp_t *dataObjReadInp, * bytesBuf_t *dataObjReadOutBBuf) * * \brief Read a chunk of data from an opened data object. * This is equivalent to read of UNIX. * * \user client * * \category data object operations * * \since 1.0 * * \author Mike Wan * \date 2007 * * \remark none * * \note none * * \usage * Read 12345 bytes from an open a data object: * \n dataObjInp_t dataObjInp; * \n openedDataObjInp_t dataObjReadInp; * \n bytesBuf_t dataObjReadOutBBuf; * \n int bytesRead; * \n bzero (&dataObjInp, sizeof (dataObjInp)); * \n bzero (&dataObjReadInp, sizeof (dataObjReadInp)); * \n rstrcpy (dataObjInp.objPath, "/myZone/home/john/myfile", MAX_NAME_LEN); * \n dataObjInp.openFlags = O_RDONLY; * \n dataObjReadInp.l1descInx = rcDataObjOpen (conn, &dataObjInp); * \n if (dataObjReadInp.l1descInx < 0) { * \n .... handle the error * \n } * \n bzero (&dataObjReadOutBBuf, sizeof (dataObjReadOutBBuf)); * \n dataObjReadInp.len = 12345; * \n bytesRead = rcDataObjRead (conn, &dataObjReadInp, &dataObjReadInpBBuf); * \n if (bytesRead < 0) { * \n .... handle the error * \n } * * \param[in] conn - A rcComm_t connection handle to the server. * \param[in] dataObjReadInp - Elements of openedDataObjInp_t used : * \li int \b l1descInx - the opened data object descriptor from * rcDataObjOpen or rcDataObjCreate. * \li int \b len - the length to read * \param[out] dataObjReadOutBBuf - A pointer to a bytesBuf_t containing the * data read. * \return integer * \retval the number of bytes read on success. * \sideeffect none * \pre none * \post none * \sa none * \bug no known bugs **/ int rcDataObjRead( rcComm_t *conn, openedDataObjInp_t *dataObjReadInp, bytesBuf_t *dataObjReadOutBBuf ) { int status; status = procApiRequest( conn, DATA_OBJ_READ_AN, dataObjReadInp, NULL, ( void ** ) NULL, dataObjReadOutBBuf ); return ( status ); }
29.807692
79
0.672258
PlantandFoodResearch
4767f06e147d7b2389e90234127a83724dea0118
35,290
cc
C++
tensorflow/core/protobuf/tensor_bundle.pb.cc
1250281649/tensorflow
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
[ "Apache-2.0" ]
null
null
null
tensorflow/core/protobuf/tensor_bundle.pb.cc
1250281649/tensorflow
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
[ "Apache-2.0" ]
2
2021-08-25T15:57:35.000Z
2022-02-10T01:09:32.000Z
tensorflow/core/protobuf/tensor_bundle.pb.cc
1250281649/tensorflow
fc6f4ec813c3514fc4a4c6a078f3f492b3ff325c
[ "Apache-2.0" ]
null
null
null
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: tensorflow/core/protobuf/tensor_bundle.proto #include "tensorflow/core/protobuf/tensor_bundle.pb.h" #include <algorithm> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fframework_2ftensor_5fshape_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_TensorShapeProto_tensorflow_2fcore_2fframework_2ftensor_5fshape_2eproto; extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fframework_2ftensor_5fslice_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_TensorSliceProto_tensorflow_2fcore_2fframework_2ftensor_5fslice_2eproto; extern PROTOBUF_INTERNAL_EXPORT_tensorflow_2fcore_2fframework_2fversions_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VersionDef_tensorflow_2fcore_2fframework_2fversions_2eproto; namespace tensorflow { class BundleHeaderProtoDefaultTypeInternal { public: ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<BundleHeaderProto> _instance; } _BundleHeaderProto_default_instance_; class BundleEntryProtoDefaultTypeInternal { public: ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<BundleEntryProto> _instance; } _BundleEntryProto_default_instance_; } // namespace tensorflow static void InitDefaultsscc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; { void* ptr = &::tensorflow::_BundleEntryProto_default_instance_; new (ptr) ::tensorflow::BundleEntryProto(); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); } ::tensorflow::BundleEntryProto::InitAsDefaultInstance(); } ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto = {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto}, { &scc_info_TensorShapeProto_tensorflow_2fcore_2fframework_2ftensor_5fshape_2eproto.base, &scc_info_TensorSliceProto_tensorflow_2fcore_2fframework_2ftensor_5fslice_2eproto.base,}}; static void InitDefaultsscc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; { void* ptr = &::tensorflow::_BundleHeaderProto_default_instance_; new (ptr) ::tensorflow::BundleHeaderProto(); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); } ::tensorflow::BundleHeaderProto::InitAsDefaultInstance(); } ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto = {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto}, { &scc_info_VersionDef_tensorflow_2fcore_2fframework_2fversions_2eproto.base,}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto[2]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto = nullptr; const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::tensorflow::BundleHeaderProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::tensorflow::BundleHeaderProto, num_shards_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleHeaderProto, endianness_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleHeaderProto, version_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, dtype_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, shape_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, shard_id_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, offset_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, size_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, crc32c_), PROTOBUF_FIELD_OFFSET(::tensorflow::BundleEntryProto, slices_), }; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, sizeof(::tensorflow::BundleHeaderProto)}, { 8, -1, sizeof(::tensorflow::BundleEntryProto)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::_BundleHeaderProto_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::tensorflow::_BundleEntryProto_default_instance_), }; const char descriptor_table_protodef_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n,tensorflow/core/protobuf/tensor_bundle" ".proto\022\ntensorflow\032,tensorflow/core/fram" "ework/tensor_shape.proto\032,tensorflow/cor" "e/framework/tensor_slice.proto\032%tensorfl" "ow/core/framework/types.proto\032(tensorflo" "w/core/framework/versions.proto\"\261\001\n\021Bund" "leHeaderProto\022\022\n\nnum_shards\030\001 \001(\005\022<\n\nend" "ianness\030\002 \001(\0162(.tensorflow.BundleHeaderP" "roto.Endianness\022\'\n\007version\030\003 \001(\0132\026.tenso" "rflow.VersionDef\"!\n\nEndianness\022\n\n\006LITTLE" "\020\000\022\007\n\003BIG\020\001\"\322\001\n\020BundleEntryProto\022#\n\005dtyp" "e\030\001 \001(\0162\024.tensorflow.DataType\022+\n\005shape\030\002" " \001(\0132\034.tensorflow.TensorShapeProto\022\020\n\010sh" "ard_id\030\003 \001(\005\022\016\n\006offset\030\004 \001(\003\022\014\n\004size\030\005 \001" "(\003\022\016\n\006crc32c\030\006 \001(\007\022,\n\006slices\030\007 \003(\0132\034.ten" "sorflow.TensorSliceProtoBl\n\023org.tensorfl" "ow.utilB\022TensorBundleProtosP\001Z<github.co" "m/tensorflow/tensorflow/tensorflow/go/co" "re/protobuf\370\001\001b\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_deps[4] = { &::descriptor_table_tensorflow_2fcore_2fframework_2ftensor_5fshape_2eproto, &::descriptor_table_tensorflow_2fcore_2fframework_2ftensor_5fslice_2eproto, &::descriptor_table_tensorflow_2fcore_2fframework_2ftypes_2eproto, &::descriptor_table_tensorflow_2fcore_2fframework_2fversions_2eproto, }; static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_sccs[2] = { &scc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base, &scc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_once; static bool descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto = { &descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_initialized, descriptor_table_protodef_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto, "tensorflow/core/protobuf/tensor_bundle.proto", 742, &descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_once, descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_sccs, descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto_deps, 2, 4, schemas, file_default_instances, TableStruct_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto::offsets, file_level_metadata_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto, 2, file_level_enum_descriptors_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto, file_level_service_descriptors_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto, }; // Force running AddDescriptors() at dynamic initialization time. static bool dynamic_init_dummy_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto = ( ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto), true); namespace tensorflow { const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* BundleHeaderProto_Endianness_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto); return file_level_enum_descriptors_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto[0]; } bool BundleHeaderProto_Endianness_IsValid(int value) { switch (value) { case 0: case 1: return true; default: return false; } } #if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) constexpr BundleHeaderProto_Endianness BundleHeaderProto::LITTLE; constexpr BundleHeaderProto_Endianness BundleHeaderProto::BIG; constexpr BundleHeaderProto_Endianness BundleHeaderProto::Endianness_MIN; constexpr BundleHeaderProto_Endianness BundleHeaderProto::Endianness_MAX; constexpr int BundleHeaderProto::Endianness_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) // =================================================================== void BundleHeaderProto::InitAsDefaultInstance() { ::tensorflow::_BundleHeaderProto_default_instance_._instance.get_mutable()->version_ = const_cast< ::tensorflow::VersionDef*>( ::tensorflow::VersionDef::internal_default_instance()); } class BundleHeaderProto::_Internal { public: static const ::tensorflow::VersionDef& version(const BundleHeaderProto* msg); }; const ::tensorflow::VersionDef& BundleHeaderProto::_Internal::version(const BundleHeaderProto* msg) { return *msg->version_; } void BundleHeaderProto::unsafe_arena_set_allocated_version( ::tensorflow::VersionDef* version) { if (GetArenaNoVirtual() == nullptr) { delete version_; } version_ = version; if (version) { } else { } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:tensorflow.BundleHeaderProto.version) } void BundleHeaderProto::clear_version() { if (GetArenaNoVirtual() == nullptr && version_ != nullptr) { delete version_; } version_ = nullptr; } BundleHeaderProto::BundleHeaderProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); // @@protoc_insertion_point(constructor:tensorflow.BundleHeaderProto) } BundleHeaderProto::BundleHeaderProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:tensorflow.BundleHeaderProto) } BundleHeaderProto::BundleHeaderProto(const BundleHeaderProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_version()) { version_ = new ::tensorflow::VersionDef(*from.version_); } else { version_ = nullptr; } ::memcpy(&num_shards_, &from.num_shards_, static_cast<size_t>(reinterpret_cast<char*>(&endianness_) - reinterpret_cast<char*>(&num_shards_)) + sizeof(endianness_)); // @@protoc_insertion_point(copy_constructor:tensorflow.BundleHeaderProto) } void BundleHeaderProto::SharedCtor() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base); ::memset(&version_, 0, static_cast<size_t>( reinterpret_cast<char*>(&endianness_) - reinterpret_cast<char*>(&version_)) + sizeof(endianness_)); } BundleHeaderProto::~BundleHeaderProto() { // @@protoc_insertion_point(destructor:tensorflow.BundleHeaderProto) SharedDtor(); } void BundleHeaderProto::SharedDtor() { GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); if (this != internal_default_instance()) delete version_; } void BundleHeaderProto::ArenaDtor(void* object) { BundleHeaderProto* _this = reinterpret_cast< BundleHeaderProto* >(object); (void)_this; } void BundleHeaderProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { } void BundleHeaderProto::SetCachedSize(int size) const { _cached_size_.Set(size); } const BundleHeaderProto& BundleHeaderProto::default_instance() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BundleHeaderProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base); return *internal_default_instance(); } void BundleHeaderProto::Clear() { // @@protoc_insertion_point(message_clear_start:tensorflow.BundleHeaderProto) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == nullptr && version_ != nullptr) { delete version_; } version_ = nullptr; ::memset(&num_shards_, 0, static_cast<size_t>( reinterpret_cast<char*>(&endianness_) - reinterpret_cast<char*>(&num_shards_)) + sizeof(endianness_)); _internal_metadata_.Clear(); } const char* BundleHeaderProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); CHK_(ptr); switch (tag >> 3) { // int32 num_shards = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { num_shards_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // .tensorflow.BundleHeaderProto.Endianness endianness = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); _internal_set_endianness(static_cast<::tensorflow::BundleHeaderProto_Endianness>(val)); } else goto handle_unusual; continue; // .tensorflow.VersionDef version = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { ptr = ctx->ParseMessage(_internal_mutable_version(), ptr); CHK_(ptr); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag & 7) == 4 || tag == 0) { ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } ::PROTOBUF_NAMESPACE_ID::uint8* BundleHeaderProto::InternalSerializeWithCachedSizesToArray( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:tensorflow.BundleHeaderProto) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; // int32 num_shards = 1; if (this->num_shards() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_num_shards(), target); } // .tensorflow.BundleHeaderProto.Endianness endianness = 2; if (this->endianness() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( 2, this->_internal_endianness(), target); } // .tensorflow.VersionDef version = 3; if (this->has_version()) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( 3, _Internal::version(this), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields(), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:tensorflow.BundleHeaderProto) return target; } size_t BundleHeaderProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:tensorflow.BundleHeaderProto) size_t total_size = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // .tensorflow.VersionDef version = 3; if (this->has_version()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *version_); } // int32 num_shards = 1; if (this->num_shards() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( this->_internal_num_shards()); } // .tensorflow.BundleHeaderProto.Endianness endianness = 2; if (this->endianness() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_endianness()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void BundleHeaderProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:tensorflow.BundleHeaderProto) GOOGLE_DCHECK_NE(&from, this); const BundleHeaderProto* source = ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<BundleHeaderProto>( &from); if (source == nullptr) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.BundleHeaderProto) ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.BundleHeaderProto) MergeFrom(*source); } } void BundleHeaderProto::MergeFrom(const BundleHeaderProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.BundleHeaderProto) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_version()) { _internal_mutable_version()->::tensorflow::VersionDef::MergeFrom(from._internal_version()); } if (from.num_shards() != 0) { _internal_set_num_shards(from._internal_num_shards()); } if (from.endianness() != 0) { _internal_set_endianness(from._internal_endianness()); } } void BundleHeaderProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:tensorflow.BundleHeaderProto) if (&from == this) return; Clear(); MergeFrom(from); } void BundleHeaderProto::CopyFrom(const BundleHeaderProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.BundleHeaderProto) if (&from == this) return; Clear(); MergeFrom(from); } bool BundleHeaderProto::IsInitialized() const { return true; } void BundleHeaderProto::InternalSwap(BundleHeaderProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(version_, other->version_); swap(num_shards_, other->num_shards_); swap(endianness_, other->endianness_); } ::PROTOBUF_NAMESPACE_ID::Metadata BundleHeaderProto::GetMetadata() const { return GetMetadataStatic(); } // =================================================================== void BundleEntryProto::InitAsDefaultInstance() { ::tensorflow::_BundleEntryProto_default_instance_._instance.get_mutable()->shape_ = const_cast< ::tensorflow::TensorShapeProto*>( ::tensorflow::TensorShapeProto::internal_default_instance()); } class BundleEntryProto::_Internal { public: static const ::tensorflow::TensorShapeProto& shape(const BundleEntryProto* msg); }; const ::tensorflow::TensorShapeProto& BundleEntryProto::_Internal::shape(const BundleEntryProto* msg) { return *msg->shape_; } void BundleEntryProto::unsafe_arena_set_allocated_shape( ::tensorflow::TensorShapeProto* shape) { if (GetArenaNoVirtual() == nullptr) { delete shape_; } shape_ = shape; if (shape) { } else { } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:tensorflow.BundleEntryProto.shape) } void BundleEntryProto::clear_shape() { if (GetArenaNoVirtual() == nullptr && shape_ != nullptr) { delete shape_; } shape_ = nullptr; } void BundleEntryProto::clear_slices() { slices_.Clear(); } BundleEntryProto::BundleEntryProto() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); // @@protoc_insertion_point(constructor:tensorflow.BundleEntryProto) } BundleEntryProto::BundleEntryProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(arena), slices_(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:tensorflow.BundleEntryProto) } BundleEntryProto::BundleEntryProto(const BundleEntryProto& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr), slices_(from.slices_) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from._internal_has_shape()) { shape_ = new ::tensorflow::TensorShapeProto(*from.shape_); } else { shape_ = nullptr; } ::memcpy(&dtype_, &from.dtype_, static_cast<size_t>(reinterpret_cast<char*>(&crc32c_) - reinterpret_cast<char*>(&dtype_)) + sizeof(crc32c_)); // @@protoc_insertion_point(copy_constructor:tensorflow.BundleEntryProto) } void BundleEntryProto::SharedCtor() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base); ::memset(&shape_, 0, static_cast<size_t>( reinterpret_cast<char*>(&crc32c_) - reinterpret_cast<char*>(&shape_)) + sizeof(crc32c_)); } BundleEntryProto::~BundleEntryProto() { // @@protoc_insertion_point(destructor:tensorflow.BundleEntryProto) SharedDtor(); } void BundleEntryProto::SharedDtor() { GOOGLE_DCHECK(GetArenaNoVirtual() == nullptr); if (this != internal_default_instance()) delete shape_; } void BundleEntryProto::ArenaDtor(void* object) { BundleEntryProto* _this = reinterpret_cast< BundleEntryProto* >(object); (void)_this; } void BundleEntryProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { } void BundleEntryProto::SetCachedSize(int size) const { _cached_size_.Set(size); } const BundleEntryProto& BundleEntryProto::default_instance() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BundleEntryProto_tensorflow_2fcore_2fprotobuf_2ftensor_5fbundle_2eproto.base); return *internal_default_instance(); } void BundleEntryProto::Clear() { // @@protoc_insertion_point(message_clear_start:tensorflow.BundleEntryProto) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; slices_.Clear(); if (GetArenaNoVirtual() == nullptr && shape_ != nullptr) { delete shape_; } shape_ = nullptr; ::memset(&dtype_, 0, static_cast<size_t>( reinterpret_cast<char*>(&crc32c_) - reinterpret_cast<char*>(&dtype_)) + sizeof(crc32c_)); _internal_metadata_.Clear(); } const char* BundleEntryProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaNoVirtual(); (void)arena; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); CHK_(ptr); switch (tag >> 3) { // .tensorflow.DataType dtype = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); _internal_set_dtype(static_cast<::tensorflow::DataType>(val)); } else goto handle_unusual; continue; // .tensorflow.TensorShapeProto shape = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { ptr = ctx->ParseMessage(_internal_mutable_shape(), ptr); CHK_(ptr); } else goto handle_unusual; continue; // int32 shard_id = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { shard_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // int64 offset = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { offset_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // int64 size = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // fixed32 crc32c = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 53)) { crc32c_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint32>(ptr); ptr += sizeof(::PROTOBUF_NAMESPACE_ID::uint32); } else goto handle_unusual; continue; // repeated .tensorflow.TensorSliceProto slices = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { ptr -= 1; do { ptr += 1; ptr = ctx->ParseMessage(_internal_add_slices(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag & 7) == 4 || tag == 0) { ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } ::PROTOBUF_NAMESPACE_ID::uint8* BundleEntryProto::InternalSerializeWithCachedSizesToArray( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:tensorflow.BundleEntryProto) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; // .tensorflow.DataType dtype = 1; if (this->dtype() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( 1, this->_internal_dtype(), target); } // .tensorflow.TensorShapeProto shape = 2; if (this->has_shape()) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( 2, _Internal::shape(this), target, stream); } // int32 shard_id = 3; if (this->shard_id() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_shard_id(), target); } // int64 offset = 4; if (this->offset() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(4, this->_internal_offset(), target); } // int64 size = 5; if (this->size() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(5, this->_internal_size(), target); } // fixed32 crc32c = 6; if (this->crc32c() != 0) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFixed32ToArray(6, this->_internal_crc32c(), target); } // repeated .tensorflow.TensorSliceProto slices = 7; for (unsigned int i = 0, n = static_cast<unsigned int>(this->_internal_slices_size()); i < n; i++) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(7, this->_internal_slices(i), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields(), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:tensorflow.BundleEntryProto) return target; } size_t BundleEntryProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:tensorflow.BundleEntryProto) size_t total_size = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // repeated .tensorflow.TensorSliceProto slices = 7; total_size += 1UL * this->_internal_slices_size(); for (const auto& msg : this->slices_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // .tensorflow.TensorShapeProto shape = 2; if (this->has_shape()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *shape_); } // .tensorflow.DataType dtype = 1; if (this->dtype() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_dtype()); } // int32 shard_id = 3; if (this->shard_id() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( this->_internal_shard_id()); } // int64 offset = 4; if (this->offset() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( this->_internal_offset()); } // int64 size = 5; if (this->size() != 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( this->_internal_size()); } // fixed32 crc32c = 6; if (this->crc32c() != 0) { total_size += 1 + 4; } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void BundleEntryProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:tensorflow.BundleEntryProto) GOOGLE_DCHECK_NE(&from, this); const BundleEntryProto* source = ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<BundleEntryProto>( &from); if (source == nullptr) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:tensorflow.BundleEntryProto) ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:tensorflow.BundleEntryProto) MergeFrom(*source); } } void BundleEntryProto::MergeFrom(const BundleEntryProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:tensorflow.BundleEntryProto) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; slices_.MergeFrom(from.slices_); if (from.has_shape()) { _internal_mutable_shape()->::tensorflow::TensorShapeProto::MergeFrom(from._internal_shape()); } if (from.dtype() != 0) { _internal_set_dtype(from._internal_dtype()); } if (from.shard_id() != 0) { _internal_set_shard_id(from._internal_shard_id()); } if (from.offset() != 0) { _internal_set_offset(from._internal_offset()); } if (from.size() != 0) { _internal_set_size(from._internal_size()); } if (from.crc32c() != 0) { _internal_set_crc32c(from._internal_crc32c()); } } void BundleEntryProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:tensorflow.BundleEntryProto) if (&from == this) return; Clear(); MergeFrom(from); } void BundleEntryProto::CopyFrom(const BundleEntryProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:tensorflow.BundleEntryProto) if (&from == this) return; Clear(); MergeFrom(from); } bool BundleEntryProto::IsInitialized() const { return true; } void BundleEntryProto::InternalSwap(BundleEntryProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); slices_.InternalSwap(&other->slices_); swap(shape_, other->shape_); swap(dtype_, other->dtype_); swap(shard_id_, other->shard_id_); swap(offset_, other->offset_); swap(size_, other->size_); swap(crc32c_, other->crc32c_); } ::PROTOBUF_NAMESPACE_ID::Metadata BundleEntryProto::GetMetadata() const { return GetMetadataStatic(); } // @@protoc_insertion_point(namespace_scope) } // namespace tensorflow PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE ::tensorflow::BundleHeaderProto* Arena::CreateMaybeMessage< ::tensorflow::BundleHeaderProto >(Arena* arena) { return Arena::CreateMessageInternal< ::tensorflow::BundleHeaderProto >(arena); } template<> PROTOBUF_NOINLINE ::tensorflow::BundleEntryProto* Arena::CreateMaybeMessage< ::tensorflow::BundleEntryProto >(Arena* arena) { return Arena::CreateMessageInternal< ::tensorflow::BundleEntryProto >(arena); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc>
40.563218
251
0.749674
1250281649
476cfa4140ebcde57181d9eed890dc82870d6084
3,207
cpp
C++
src/gui/backends/sdl_ems/sdl2_backend.cpp
xhighway999/xhfr
532864ed0d0531fbd8af38d4b0cf206dc5d0a138
[ "MIT" ]
2
2021-03-23T05:21:34.000Z
2021-07-27T08:28:08.000Z
src/gui/backends/sdl_ems/sdl2_backend.cpp
xhighway999/xhfr
532864ed0d0531fbd8af38d4b0cf206dc5d0a138
[ "MIT" ]
null
null
null
src/gui/backends/sdl_ems/sdl2_backend.cpp
xhighway999/xhfr
532864ed0d0531fbd8af38d4b0cf206dc5d0a138
[ "MIT" ]
1
2021-05-31T12:01:03.000Z
2021-05-31T12:01:03.000Z
#include "sdl2_backend.hpp" namespace xhfr { bool done = false; SDL_Window* g_Window = NULL; SDL_GLContext g_GLContext = NULL; ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); const char* glsl_version = "#version 100"; bool backend_init(const char* appName, int w, int h) { // Setup SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { printf("Error: %s\n", SDL_GetError()); return -1; } // For the browser using Emscripten, we are going to use WebGL1 with GL ES2. // See the Makefile. for requirement details. It is very likely the generated // file won't work in many browsers. Firefox is the only sure bet, but I have // successfully run this code on Chrome for Android for example. // const char* glsl_version = "#version 300 es"; SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); // Create window with graphics context SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_DisplayMode current; SDL_GetCurrentDisplayMode(0, &current); SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); g_Window = SDL_CreateWindow(appName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); g_GLContext = SDL_GL_CreateContext(g_Window); if (!g_GLContext) { fprintf(stderr, "Failed to initialize WebGL context!\n"); return 1; } return true; } void backend_render() { ImGui::Render(); ImGuiIO& io = ImGui::GetIO(); (void)io; glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); SDL_GL_SwapWindow(g_Window); } void backend_new_frame() { SDL_Event event; while (SDL_PollEvent(&event)) { ImGui_ImplSDL2_ProcessEvent(&event); if (event.type == SDL_QUIT) done = true; if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(g_Window)) done = true; } // Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(g_Window); } void backend_shutdown() { ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplSDL2_Shutdown(); SDL_GL_DeleteContext(g_GLContext); SDL_DestroyWindow(g_Window); SDL_Quit(); } bool backend_should_close() { return done; } bool backend_viewports_support() { return 0; } void backend_init_platform_impl() { ImGui_ImplSDL2_InitForOpenGL(g_Window, g_GLContext); ImGui_ImplOpenGL3_Init(glsl_version); } void backend_set_drag_drop_callback(std::function<void(DropEvent)> f) { // dragDropCallback = f; // hasDragDropCallback = true; } } // namespace xhfr
30.254717
80
0.704708
xhighway999
477017c758c87a9cead1d82b4358d805bb47f1dc
1,858
cpp
C++
libutil/cText.cpp
7-wolf/cc3172
f64b1af87e088ad8a8c0c3fd952c0abbf9346e49
[ "MIT" ]
1
2019-11-22T19:43:29.000Z
2019-11-22T19:43:29.000Z
libutil/cText.cpp
7-wolf/cc3172
f64b1af87e088ad8a8c0c3fd952c0abbf9346e49
[ "MIT" ]
null
null
null
libutil/cText.cpp
7-wolf/cc3172
f64b1af87e088ad8a8c0c3fd952c0abbf9346e49
[ "MIT" ]
3
2019-12-25T01:43:35.000Z
2020-02-26T09:59:47.000Z
#include "cText.h" #include "_ccu.h" cText* cText::create(int width /* = 0 */) { CREATE(cText, eFont::normal, width); } bool cText::init(eFont e, int width) { if (!ui::RichText::init()) { return false; } _efnt = e; ignoreContentAdaptWithSize(false); setFontSize((int)e); setFontFace(ccu::cArial); _index = width == 0 ? cc::vsSize().width : width; setContentSize(Size(_index, 0)); return true; } void cText::setString(const std::string& text) { setString("", text); } void cText::setString(const std::string& name, const std::string& text) { auto chat = cChatManager::getInstance(); chat->init(); if (name.empty()) { chat->setString(text); } else { chat->setString("[" + name + "]" + text); } setString(chat->getLines()); } void cText::setString(const cChatManager::sLines& lines) { _richElements.clear(); _formatTextDirty = true; setContentSize(Size(_index, 0)); int index = -1; forv(lines, k) { const auto& cs = lines.at(k).chars; forv(cs, i) { const auto& c = cs.at(i); cLabel* label = cLabel::create(c.text, _efnt); label->setColor(cc::to3B(c.color)); #if 0 ui::RichElementCustomNode* text = ui::RichElementCustomNode::create(++index, label->getColor(), 0xFF, label); #else ui::RichElementText* text = ui::RichElementText::create(++index, label->getColor(), 0xFF, label->getString(), ccu::cFnt, (int)_efnt); #endif pushBackElement(text); } if (k < _size_ - 1) { pushBackElement(ui::RichElementNewLine::create(++index, Color3B::WHITE, 0xFF)); } } formatText(); float w = 0, h = 0; for (const auto& node : _protectedChildren) { w = std::max(w, node->getPositionX() - node->getAnchorPointInPoints().x + node->getContentSize().width); h = std::max(h, node->getPositionY() - node->getAnchorPointInPoints().y + node->getContentSize().height); } setContentSize(Size(w, h)); }
22.938272
136
0.656082
7-wolf
47742cd4d7dda469dd762f79c2658eb7da746fdd
3,708
hh
C++
src/ECS/Join.hh
JonathanIlk/Tropical-Island-Laser-Battle
1dd7d2ce95a7b003f8cc87b2bf4bac27e026a9ed
[ "MIT" ]
1
2022-03-25T11:18:41.000Z
2022-03-25T11:18:41.000Z
src/ECS/Join.hh
JonathanIlk/Tropical-Island-Laser-Battle
1dd7d2ce95a7b003f8cc87b2bf4bac27e026a9ed
[ "MIT" ]
null
null
null
src/ECS/Join.hh
JonathanIlk/Tropical-Island-Laser-Battle
1dd7d2ce95a7b003f8cc87b2bf4bac27e026a9ed
[ "MIT" ]
null
null
null
// SPDX-License-Identifier: MIT #pragma once #include <cassert> #include <map> #include <tuple> #include <vector> #include <ECS.hh> namespace ECS { template<typename ...T> struct JoinIter; template<> struct JoinIter<> { using result = std::tuple<entity>; entity id; JoinIter(entity start = 0) : id{start} {} // returns the current entity ID. should be the same accross all items, // so all other implementations should forward the call to this one entity entityID() const {return id;} // fast-forward to the next component with ID no less than 'target', // INVALID if none exist. (note: INVALID is higher than all valid IDs) // contract: target should be no lower than entityID() // must uphold the 'all IDs are the same' rule // (e. g. by calling nested implementations) entity gallop(entity target) {return (id = target);} // iterator interface std::tuple<entity> operator*() const {return std::make_tuple(id);} void operator++() {++id;} bool operator==(const JoinIter<> &other) const {return id == other.id;} bool operator!=(const JoinIter<> &other) const {return id == other.id;} }; template<typename T, typename Tup>struct ConsTuple; template<typename T, typename ...Tail> struct ConsTuple<T, std::tuple<Tail...>>{using type = std::tuple<T, Tail...>;}; template<typename T, typename Compare, typename Alloc, typename ...Tail> struct JoinIter<std::map<entity, T, Compare, Alloc> &, Tail...> { using result = typename ConsTuple<T &, typename JoinIter<Tail...>::result>::type; using map_type = std::map<entity, T, Compare, Alloc>; JoinIter<Tail...> tail; typename map_type::iterator iter; map_type *map; JoinIter(entity start, map_type &map, Tail... tail) : tail(start, tail...), iter{map.begin()}, map{&map} {} entity entityID() const { return tail.entityID(); } entity gallop(entity target) { assert(target >= entityID()); while (true) { target = tail.gallop(target); if (target == INVALID) { iter = map->end(); return INVALID; } iter = map->upper_bound(target); if (iter != map->begin()) { --iter; if (iter->first < target) { ++iter; } else {return target;} } if (iter == map->end()) { target = INVALID; } else { entity id = iter->first; if (id == target) { return id; } else { assert(id > target); target = id; } } } } result operator*() { std::tuple<T &> res = {iter->second}; return std::tuple_cat(res, *tail); } void operator++() { if (entityID() != INVALID) { gallop(entityID() + 1); } } bool operator==(const JoinIter<map_type &, Tail...> &other) const { return entityID() == other.entityID(); } bool operator!=(const JoinIter<map_type &, Tail...> &other) const { return entityID() != other.entityID(); } }; template<typename ...T> struct Join { using iterator = JoinIter<T&...>; iterator start; Join(T&... relations) : start(0, relations...) { start.gallop(0); } iterator begin() {return start;} iterator find(entity id) { auto iter = start; iter.gallop(id); if (iter.entityID() != id) {iter.gallop(INVALID);} return iter; } iterator end() { auto iter = start; iter.gallop(INVALID); return iter; } }; }
30.393443
111
0.556365
JonathanIlk
47746f613d4e7b9fa266b6d0c0c9c800bad65ece
3,597
cpp
C++
src/dialogue_state.cpp
rcabot/codscape
5619b40d7857066818c8409d3db4371d3c8f758c
[ "Unlicense" ]
null
null
null
src/dialogue_state.cpp
rcabot/codscape
5619b40d7857066818c8409d3db4371d3c8f758c
[ "Unlicense" ]
null
null
null
src/dialogue_state.cpp
rcabot/codscape
5619b40d7857066818c8409d3db4371d3c8f758c
[ "Unlicense" ]
null
null
null
#include "dialogue_state.hpp" #include "registry.hpp" #include <sstream> dialogue_state::~dialogue_state() { } void dialogue_state::advance() { if(options_.size() > 0) return; bool pause_execution = false; do { current_line_index_++; const node& current_node{nodes_[current_node_]}; // reached the end of the current node? if(current_line_index_ >= current_node.expressions.size()) { // end dialogue and reset talking_to_name_ = ""; current_text_ = ""; registry_.player_state_machine_.set_state("neutral"); current_line_index_ = -1; options_.clear(); return; } // otherwise, execute command const expression& current_expression{current_node.expressions[current_line_index_]}; switch (current_expression.command) { case command::DISPLAY: current_text_ = current_expression.operands[0]; pause_execution = true; break; case command::GOTO_NODE: current_line_index_ = -1; current_node_ = current_expression.operands[0]; break; case command::ADD_OPTION: options_.emplace_back(current_expression.operands[0],current_expression.operands[1]); // if this option is the last statement, wait for response if(current_line_index_ == current_node.expressions.size() - 1) pause_execution = true; break; default: break; } } while(!pause_execution); } std::string dialogue_state::get_current_text() { return current_text_; } void dialogue_state::choose_option(int choice) { if(options_.size() == 0) return; current_line_index_ = -1; current_node_ = options_[choice].node; options_.clear(); advance(); } std::string dialogue_state::get_talking_to_name() { return talking_to_name_; } const std::vector<dialogue_state::option>& dialogue_state::get_options() { return options_; } void dialogue_state::start_talking_to(std::string person_name) { current_text_ = ""; talking_to_name_ = person_name; current_node_ = person_name; current_line_index_ = -1; advance(); } void dialogue_state::create_node(std::string title,std::string fulltext) { raw_text_nodes_[title] = fulltext; std::istringstream text_stream(fulltext); std::string line; while (std::getline(text_stream, line)) { // if this is a pointer to node // i.e. [[somenode]] if(line.rfind("[[",0) == 0) { auto divider_pos{line.rfind("|")}; if(divider_pos!=-1) { // assumes that the pointer has no whitespace std::vector<std::string> operands{line.substr(2,divider_pos-2),line.substr(divider_pos+1,(line.size() - (divider_pos+1)) - 2)}; nodes_[title].expressions.emplace_back(command::ADD_OPTION,operands); } else { // assumes that the pointer has no whitespace std::vector<std::string> operands{line.substr(2,line.size()-4)}; nodes_[title].expressions.emplace_back(command::GOTO_NODE,operands); } } // if this line is dialogue to be displayed else if (!line.empty()) { std::vector<std::string> operands{line}; nodes_[title].expressions.emplace_back(command::DISPLAY,operands); } } }
27.669231
143
0.598276
rcabot
4776f12a51488d28d4d5d0020b5a8c3fe39401bb
322
cpp
C++
src/main.cpp
theShmoo/aoc2020
b507c33b5ca47e0c73bd5c6b4ec9d2f087598028
[ "Unlicense" ]
null
null
null
src/main.cpp
theShmoo/aoc2020
b507c33b5ca47e0c73bd5c6b4ec9d2f087598028
[ "Unlicense" ]
null
null
null
src/main.cpp
theShmoo/aoc2020
b507c33b5ca47e0c73bd5c6b4ec9d2f087598028
[ "Unlicense" ]
null
null
null
#include "days.hpp" static constexpr days::day current_day = days::day::day_13; auto main([[maybe_unused]] int argc, [[maybe_unused]] const char **argv) -> int { spdlog::info("Advent of Code 2020"); days::solve_problem<current_day, days::part::part_1>(); days::solve_problem<current_day, days::part::part_2>(); }
26.833333
79
0.698758
theShmoo
47787f452f036c8a6a41612d5303d73b179824e3
678
cc
C++
chapter4/read_distances.cc
homuler/ppp-exercises
db83c8deb676c8d480e29d5d1ddaa155afe1b1b0
[ "Unlicense" ]
null
null
null
chapter4/read_distances.cc
homuler/ppp-exercises
db83c8deb676c8d480e29d5d1ddaa155afe1b1b0
[ "Unlicense" ]
null
null
null
chapter4/read_distances.cc
homuler/ppp-exercises
db83c8deb676c8d480e29d5d1ddaa155afe1b1b0
[ "Unlicense" ]
null
null
null
#include "external/ppp2code/file/std_lib_facilities.h" #include <limits> int main() { vector<double> distances; for (double x; cin >> x;) { distances.push_back(x); } if (distances.empty()) return 0; double sum {}; double shortest = numeric_limits<double>::max(); double longest = numeric_limits<double>::min(); for (auto x : distances) { sum += x; if (x < shortest) shortest = x; if (x > longest) longest = x; } cout << "Total distances: " << sum << endl; cout << "Shortest distance: " << shortest << endl; cout << "Longest distance: " << longest << endl; cout << "Average: " << sum / distances.size() << endl; return 0; }
20.545455
56
0.603245
homuler
477b2584967b0369f69eb20a929b4bf05d2d2a5e
301
cpp
C++
E_6_fattoriale.cpp
Blackcat12/Informatica_3
80a538c1613d3a9c89d9dda6c39053aa3d596086
[ "MIT" ]
null
null
null
E_6_fattoriale.cpp
Blackcat12/Informatica_3
80a538c1613d3a9c89d9dda6c39053aa3d596086
[ "MIT" ]
null
null
null
E_6_fattoriale.cpp
Blackcat12/Informatica_3
80a538c1613d3a9c89d9dda6c39053aa3d596086
[ "MIT" ]
null
null
null
#include<stdio.h> #include<stdlib.h> #include<math.h> /*Diego Gattari 3INA 30/12/2016 programma:media ver 1.0 */ main () { int n; int i; int fatt; scanf("%d", &n); for(i=1;n>=i;i=i+1){ fatt=n*(n-1); n--; } printf("il fattoriale e' %d \n",fatt); }
14.333333
43
0.501661
Blackcat12
477bc8cc305b55da5239a815f09634d8c58bdd47
137
cpp
C++
ch2/useHello.cpp
Cc19245/slambook_mylearn
7c589a80706d4268bf5d661a4f0f12890ec490bc
[ "MIT" ]
5,684
2016-06-27T14:00:02.000Z
2022-03-31T07:42:00.000Z
ch2/useHello.cpp
Cc19245/slambook_mylearn
7c589a80706d4268bf5d661a4f0f12890ec490bc
[ "MIT" ]
265
2016-11-08T09:00:19.000Z
2022-03-24T12:46:39.000Z
ch2/useHello.cpp
Cc19245/slambook_mylearn
7c589a80706d4268bf5d661a4f0f12890ec490bc
[ "MIT" ]
3,243
2016-07-26T12:36:15.000Z
2022-03-30T20:48:41.000Z
#include "libHelloSLAM.h" // 使用 libHelloSLAM.h 中的 printHello() 函数 int main( int argc, char** argv ) { printHello(); return 0; }
15.222222
39
0.642336
Cc19245
477c443eada63ad5b0bd048124c477a277c312ab
1,459
cpp
C++
Plugins/LeapMotion/Source/LeapMotion/Private/LeapSwipeGesture.cpp
benmadany/PaintSpace
0e32a14416f35573928d2a49670d2eefa241aab6
[ "MIT" ]
15
2016-07-24T22:57:30.000Z
2020-06-30T17:48:10.000Z
Plugins/LeapMotion/Source/LeapMotion/Private/LeapSwipeGesture.cpp
sleepfrontofmtv/leap-ue4
6eb2263dd379484235a5c78d3246050b5a2f5a3b
[ "MIT" ]
1
2017-03-30T13:41:21.000Z
2017-04-02T20:23:32.000Z
Plugins/LeapMotion/Source/LeapMotion/Private/LeapSwipeGesture.cpp
sleepfrontofmtv/leap-ue4
6eb2263dd379484235a5c78d3246050b5a2f5a3b
[ "MIT" ]
7
2016-03-25T02:31:37.000Z
2020-06-30T17:48:19.000Z
#include "LeapMotionPrivatePCH.h" #include "LeapSwipeGesture.h" class PrivateSwipeGesture { public: ~PrivateSwipeGesture() { if (!cleanupCalled) Cleanup(); } void Cleanup() { if (pointable) pointable->CleanupRootReferences(); cleanupCalled = true; } bool cleanupCalled = false; Leap::SwipeGesture gesture; ULeapPointable* pointable = NULL; }; ULeapSwipeGesture::ULeapSwipeGesture(const FObjectInitializer &init) : ULeapGesture(init), _private(new PrivateSwipeGesture()) { } ULeapSwipeGesture::~ULeapSwipeGesture() { delete _private; } void ULeapSwipeGesture::CleanupRootReferences() { ULeapGesture::CleanupRootReferences(); _private->Cleanup(); this->RemoveFromRoot(); } ULeapPointable* ULeapSwipeGesture::Pointable() { if (_private->pointable == NULL) { _private->pointable = NewObject<ULeapPointable>(this); _private->pointable->SetFlags(RF_RootSet); } _private->pointable->setPointable(_private->gesture.pointable()); return (_private->pointable); } void ULeapSwipeGesture::setGesture(const Leap::SwipeGesture &Gesture) { //Super ULeapGesture::setGesture(Gesture); _private->gesture = Gesture; Direction = convertLeapToUE(_private->gesture.direction()); Position = convertAndScaleLeapToUE(_private->gesture.position()); Speed = scaleLeapToUE(_private->gesture.speed()); StartPosition = convertAndScaleLeapToUE(_private->gesture.startPosition()); //Convenience BasicDirection = basicDirection(Direction); }
23.15873
126
0.762166
benmadany
477d8ac4bfb8d6a9f7944a89fa4c374186fd8cf7
1,891
hpp
C++
src/Resources/ImageLoader.hpp
LazyFalcon/GameConcept-v1
e0259d683bb711921d068924de1aa1c30c00db4d
[ "MIT" ]
null
null
null
src/Resources/ImageLoader.hpp
LazyFalcon/GameConcept-v1
e0259d683bb711921d068924de1aa1c30c00db4d
[ "MIT" ]
null
null
null
src/Resources/ImageLoader.hpp
LazyFalcon/GameConcept-v1
e0259d683bb711921d068924de1aa1c30c00db4d
[ "MIT" ]
null
null
null
#pragma once struct ImageData { ImageData() = default; ImageData(ImageData&&) = default; enum Datatype { Bitmap, U16, I16, U32, I32, Float }; u32 ID; u32 width; u32 height; u32 numOfChannels; u32 channels; u32 channelSize; u32 bitDepth; // image depth in bytes: 1,2,4:(u8, u16, u32/foat); bytes per channel u32 originalFormat; u32 format; // format of loaded data u32 internalFormat; // format in GPU u32 type; // data type of image, u8, hFloat, float u32 imageMagFilter; u32 imageMinFilter; u32 count; bool useMipmaps; Datatype datatype; const void *data {nullptr}; }; enum ImageDataType { R8, R16, R16F, R32, R32F, RGB8, RGBA8, RGBA16, RGBA32F, Any8, Any16 }; namespace ImageUtils { struct ImageParams { ImageDataType dataType; u32 id; u32 width; u32 height; u32 layers; u32 internalFormat; // format in GPU u32 format; // format of loaded data u32 type; // data type of image, u8, hFloat, float const void *data {nullptr}; size_t dataSize; u32 size(){ // if(not data) return 0; // TODO: improve it // else return width*height; } void clear(){ delete [] (u8*)data; } }; ImageParams loadImageToGpu(const std::string &filePath); ImageParams loadArrayToGpu(const std::vector<fs::path> &files); ImageParams loadCubemapToGpu(const std::vector<std::string> &filePathes); ImageParams loadToMemory(const std::string &filePath, ImageDataType targetType); bool saveFromMemory(const std::string &filePath, ImageDataType targetType, ImageParams image); template<typename T> bool save(const std::string &filePath, ImageDataType sourceType, ImageDataType targetType, std::vector<T> &data){ return saveFromMemory(filePath, sourceType, targetType, (u8*)data.data(), data.size()*sizeof(T)); } }
23.6375
113
0.665785
LazyFalcon
47822190fba1551a6cebe3742b3a8d47c35cbeeb
497
cpp
C++
main.cpp
SJ-magic-study/study__fopen_in_terminal
e0169a9c3db1736a5a0ed9d097ae65510602b5f6
[ "MIT" ]
null
null
null
main.cpp
SJ-magic-study/study__fopen_in_terminal
e0169a9c3db1736a5a0ed9d097ae65510602b5f6
[ "MIT" ]
null
null
null
main.cpp
SJ-magic-study/study__fopen_in_terminal
e0169a9c3db1736a5a0ed9d097ae65510602b5f6
[ "MIT" ]
null
null
null
/************************************************************ ************************************************************/ #include <stdio.h> /************************************************************ ************************************************************/ int main() { FILE* fp = NULL; // fp = fopen("../data/StoryBoard.txt", "r"); fp = fopen("data/StoryBoard.txt", "r"); if(fp == NULL){ printf("Open Error\n"); }else{ printf("Open OK\n"); fclose(fp); } return 0; }
20.708333
61
0.273642
SJ-magic-study
47909447fdbdbec397cb33621e6d0796a78115d1
3,081
cpp
C++
ut/source/test_ck_blob_tree.cpp
dicroce/cppkit
dc64dacacc54665b079836a1bc7d8fb028616ffe
[ "BSD-2-Clause-FreeBSD" ]
12
2015-03-27T21:29:02.000Z
2016-11-26T23:43:52.000Z
ut/source/test_ck_blob_tree.cpp
dicroce/cppkit
dc64dacacc54665b079836a1bc7d8fb028616ffe
[ "BSD-2-Clause-FreeBSD" ]
1
2017-01-18T00:32:12.000Z
2017-01-18T00:32:12.000Z
ut/source/test_ck_blob_tree.cpp
dicroce/cppkit
dc64dacacc54665b079836a1bc7d8fb028616ffe
[ "BSD-2-Clause-FreeBSD" ]
6
2015-02-08T13:10:27.000Z
2017-01-18T00:24:47.000Z
#include "test_ck_blob_tree.h" #include "cppkit/ck_uuid_utils.h" #include "cppkit/ck_blob_tree.h" #include "cppkit/ck_sha_256.h" using namespace std; using namespace cppkit; REGISTER_TEST_FIXTURE(test_ck_blob_tree); void test_ck_blob_tree::setup() { } void test_ck_blob_tree::teardown() { } string hasher(const uint8_t* p, size_t size) { ck_sha_256 hash; hash.update(p, size); hash.finalize(); return hash.get_as_string(); } void test_ck_blob_tree::test_basic() { vector<uint8_t> blob_1 = {1, 2, 3, 4}; auto blob_1_hash = hasher(&blob_1[0], blob_1.size()); vector<uint8_t> blob_2 = {5, 6, 7, 8}; auto blob_2_hash = hasher(&blob_2[0], blob_2.size()); vector<uint8_t> blob_3 = {9, 10, 11, 12}; auto blob_3_hash = hasher(&blob_3[0], blob_3.size()); vector<uint8_t> blob_4 = {13, 14, 15, 16}; auto blob_4_hash = hasher(&blob_4[0], blob_4.size()); ck_blob_tree rt1; rt1["hello"]["my sweeties!"][0] = make_pair(blob_1.size(), &blob_1[0]); rt1["hello"]["my sweeties!"][1] = make_pair(blob_2.size(), &blob_2[0]); rt1["hello"]["my darlings!"][0] = make_pair(blob_3.size(), &blob_3[0]); rt1["hello"]["my darlings!"][1] = make_pair(blob_4.size(), &blob_4[0]); auto buffer = ck_blob_tree::serialize(rt1, 42); uint32_t version; auto rt2 = ck_blob_tree::deserialize(&buffer[0], buffer.size(), version); RTF_ASSERT(version == 42); RTF_ASSERT(rt2["hello"]["my sweeties!"].size() == 2); auto val = rt2["hello"]["my sweeties!"][0].get(); RTF_ASSERT(hasher(val.second, val.first) == blob_1_hash); val = rt2["hello"]["my sweeties!"][1].get(); RTF_ASSERT(hasher(val.second, val.first) == blob_2_hash); val = rt2["hello"]["my darlings!"][0].get(); RTF_ASSERT(hasher(val.second, val.first) == blob_3_hash); val = rt2["hello"]["my darlings!"][1].get(); RTF_ASSERT(hasher(val.second, val.first) == blob_4_hash); } void test_ck_blob_tree::test_objects_in_array() { ck_blob_tree rt1; string b1 = "We need a nine bit byte."; string b2 = "What if a building has more doors than their are guids?"; string b3 = "If java compiles, its bug free."; string b4 = "Microsoft COM is a good idea."; rt1[0]["obj_a"] = make_pair(b1.length(), (uint8_t*)b1.c_str()); rt1[0]["obj_b"] = make_pair(b2.length(), (uint8_t*)b2.c_str()); rt1[1]["obj_a"] = make_pair(b3.length(), (uint8_t*)b3.c_str()); rt1[1]["obj_b"] = make_pair(b4.length(), (uint8_t*)b4.c_str()); auto buffer = ck_blob_tree::serialize(rt1, 42); uint32_t version; auto rt2 = ck_blob_tree::deserialize(&buffer[0], buffer.size(), version); auto val = rt2[0]["obj_a"].get(); string ab1((char*)val.second, val.first); val = rt2[0]["obj_b"].get(); string ab2((char*)val.second, val.first); val = rt2[1]["obj_a"].get(); string ab3((char*)val.second, val.first); val = rt2[1]["obj_b"].get(); string ab4((char*)val.second, val.first); RTF_ASSERT(b1 == ab1); RTF_ASSERT(b2 == ab2); RTF_ASSERT(b3 == ab3); RTF_ASSERT(b4 == ab4); }
29.912621
77
0.633561
dicroce
479262ed5dbf969194d9a1c5c08249f67b957b6e
229
cpp
C++
Source/CPP_20/Module/Module_4_SubModuleImpl.cpp
AllveGit/CPP_20_Training
c3785d07e741ed23d3ea78fa13f70e0da092cdec
[ "MIT" ]
null
null
null
Source/CPP_20/Module/Module_4_SubModuleImpl.cpp
AllveGit/CPP_20_Training
c3785d07e741ed23d3ea78fa13f70e0da092cdec
[ "MIT" ]
null
null
null
Source/CPP_20/Module/Module_4_SubModuleImpl.cpp
AllveGit/CPP_20_Training
c3785d07e741ed23d3ea78fa13f70e0da092cdec
[ "MIT" ]
null
null
null
// Implementation Unit module Module_4_SubModuleImpl; const char* GetImplPart1Str() { return "I'm SubModule Implementation Unit Part 1!"; } const char* GetImplPart2Str() { return "I'm SubModule Implementation Unit Part 2!"; }
19.083333
52
0.759825
AllveGit
4792b6ed8aebf7dc5fac219f2e3340480e63ce53
1,364
cpp
C++
leetcode/143.leetcode.2.cpp
jianershi/algorithm
c3c38723b9c5f1cc745550d89e228f92fd4abfb2
[ "MIT" ]
1
2021-01-08T06:57:49.000Z
2021-01-08T06:57:49.000Z
leetcode/143.leetcode.2.cpp
jianershi/algorithm
c3c38723b9c5f1cc745550d89e228f92fd4abfb2
[ "MIT" ]
null
null
null
leetcode/143.leetcode.2.cpp
jianershi/algorithm
c3c38723b9c5f1cc745550d89e228f92fd4abfb2
[ "MIT" ]
1
2021-01-08T06:57:52.000Z
2021-01-08T06:57:52.000Z
/** 143. Reorder List https://leetcode.com/problems/reorder-list/ official solution **/ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: void reorderList(ListNode* head) { if (!head or !head->next) return; ListNode *fast = head, *slow = head, *end; while (fast && fast->next) { fast = fast->next->next; slow = slow->next; } ListNode *secondRoot = reverseLinkedList(slow); mergeTwoLinkedList(head, secondRoot); } ListNode* reverseLinkedList(ListNode* head) { ListNode *prev = nullptr, *curr = head; while (curr) { ListNode *n = curr->next; curr->next = prev; prev = curr; curr = n; } return prev; } void mergeTwoLinkedList(ListNode* first, ListNode* second) { while (second->next) { ListNode *tmp = first->next; first->next = second; first = tmp; tmp = second->next; second->next = first; second = tmp; } } };
25.259259
64
0.507331
jianershi
4792ede425df041299bf1fb2e0e53742d253f946
1,002
cpp
C++
honours_project/components/cmp_sprite.cpp
alexbarker/soc10101_honours_project
c29c10f0e5d7bed50819c948f841dd97e7d68809
[ "MIT" ]
null
null
null
honours_project/components/cmp_sprite.cpp
alexbarker/soc10101_honours_project
c29c10f0e5d7bed50819c948f841dd97e7d68809
[ "MIT" ]
null
null
null
honours_project/components/cmp_sprite.cpp
alexbarker/soc10101_honours_project
c29c10f0e5d7bed50819c948f841dd97e7d68809
[ "MIT" ]
null
null
null
#include "cmp_sprite.h" #include "system_renderer.h" // SOC10101 - Honours Project (40 Credits) // Snake Prototype 3 // Version 0.x.x // Alexander Barker // 40333139 // Last Updated on 17th November 2018 // xxx.cpp - XXX. using namespace std; SpriteComponent::SpriteComponent(Entity* p) : Component(p), _sprite(make_shared<sf::Sprite>()) {} void SpriteComponent::update(double dt) { _sprite->setPosition(_parent->getPosition()); _sprite->setRotation(_parent->getRotation()); } void SpriteComponent::render() { Renderer::queue(_sprite.get()); } void ShapeComponent::update(double dt) { _shape->setPosition(_parent->getPosition()); _shape->setRotation(_parent->getRotation()); } void ShapeComponent::render() { Renderer::queue(_shape.get()); } sf::Shape& ShapeComponent::getShape() const { return *_shape; } ShapeComponent::ShapeComponent(Entity* p) : Component(p), _shape(make_shared<sf::CircleShape>()) {} sf::Sprite& SpriteComponent::getSprite() const { return *_sprite; }
26.368421
67
0.718563
alexbarker
479771b2e315c1b4d187b698701a17b424e15889
702
cpp
C++
ChristmasLightsController/manipulation/RandomWalk.cpp
FreeApophis/arduino-christmas-lights
b4de586a64f4b8ea540dc664839d87e6ca683986
[ "MIT" ]
null
null
null
ChristmasLightsController/manipulation/RandomWalk.cpp
FreeApophis/arduino-christmas-lights
b4de586a64f4b8ea540dc664839d87e6ca683986
[ "MIT" ]
1
2020-03-11T07:26:59.000Z
2020-03-11T07:26:59.000Z
ChristmasLightsController/manipulation/RandomWalk.cpp
FreeApophis/arduino-christmas-lights
b4de586a64f4b8ea540dc664839d87e6ca683986
[ "MIT" ]
null
null
null
#include "RandomWalk.h" auto RandomWalk(const uint8_t val, const uint8_t maxVal, const uint8_t changeAmount, const uint8_t directions) -> uint8_t { const unsigned char direction = random(directions) == 0; // direction of random walk if (direction == 0) { // decrease val by changeAmount down to a min of 0 if (val >= changeAmount) { return val - changeAmount; } else { return 0; } } if (direction == 1) { // increase val by changeAmount up to a max of maxVal if (val <= maxVal - changeAmount) { return val + changeAmount; } else { return maxVal; } } return val; }
28.08
121
0.574074
FreeApophis
479b94ea145c36cd15432ceb99024b0707e05e84
4,581
cpp
C++
Graphs/Tree/CentroidDecomp.cpp
NhatMinh0208/CP-Library
4d174b01a569106d2d7ad0fa5e3594175e97de31
[ "MIT" ]
null
null
null
Graphs/Tree/CentroidDecomp.cpp
NhatMinh0208/CP-Library
4d174b01a569106d2d7ad0fa5e3594175e97de31
[ "MIT" ]
null
null
null
Graphs/Tree/CentroidDecomp.cpp
NhatMinh0208/CP-Library
4d174b01a569106d2d7ad0fa5e3594175e97de31
[ "MIT" ]
null
null
null
/* Normie's implementation of centroid decomposition. This particular version solves a variant of 613D where you are asked to find the longest path crossing each node instead. */ // Standard library in one include. #include <bits/stdc++.h> using namespace std; // ordered_set library. #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set(el) tree<el,null_type,less<el>,rb_tree_tag,tree_order_statistics_node_update> // AtCoder library. (Comment out these two lines if you're not submitting in AtCoder.) (Or if you want to use it in other judges, run expander.py first.) //#include <atcoder/all> //using namespace atcoder; //Pragmas (Comment out these three lines if you're submitting in szkopul.) #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //File I/O. #define FILE_IN "cseq.inp" #define FILE_OUT "cseq.out" #define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout) //Fast I/O. #define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define nfio cin.tie(0);cout.tie(0) #define endl "\n" //Order checking. #define ord(a,b,c) ((a>=b)and(b>=c)) //min/max redefines, so i dont have to resolve annoying compile errors. #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) //Constants. #define MOD (ll(998244353)) #define MAX 300001 #define mag 320 //Pairs and 3-pairs. #define p1 first #define p2 second.first #define p3 second.second #define fi first #define se second #define pii(element_type) pair<element_type,element_type> #define piii(element_type) pair<element_type,pii(element_type)> //Quick power of 2. #define pow2(x) (ll(1)<<x) //Short for-loops. #define ff(i,__,___) for(int i=__;i<=___;i++) #define rr(i,__,___) for(int i=__;i>=___;i--) //Typedefs. #define bi BigInt typedef long long ll; typedef long double ld; typedef short sh; //---------END-------// struct edge { int v=0; int used=0; char c='0'; operator<(const edge& oth) { return (v<oth.v); } edge(int vv=0, int cv='0') { v=vv; c=cv; } }; vector<edge> gt[100001]; vector<edge> down[100001]; int n,m,i,j,k,t,t1,u,v,a,b,res=0; int dis[100001]; int mask[100001]; int subt[100001]; int maxx[4200000]; int fin[100001]; void get_info(int x, int d, int mk, int p) { // cout<<"get_info "<<x<<' '<<d<< ' '<<mk<<' '<<p<<endl; dis[x]=d; mask[x]=mk; subt[x]=1; down[x].clear(); for (edge g : gt[x]) if ((g.v!=p)and(g.used==0)) { down[x].push_back(g); get_info(g.v,d+1,mk^(1<<(g.c-97)),x); subt[x]+=subt[g.v]; } } int find_centroid(int x) { // cout<<"find_centroid "<<x<<endl; get_info(x,0,0,-1); int i=x; int fail=0; int maxx=0; while(true) { // cout<<"procing "<<i<<" \n"; fail=0; maxx=0; if (subt[i]*2<subt[x]) fail=1; for (auto g : down[i]) { // cout<<"childern:\n"; // cout<<g.v<<' '<<g.c<<endl; if ((maxx==0)or(subt[maxx]<subt[g.v])) maxx=g.v; if (subt[g.v]*2>subt[x]) fail=1; } if (!fail) return i; i=maxx; } } void calc(int x, int u) { fin[x]=max(fin[x],maxx[mask[x]]+dis[x]); fin[u]=max(fin[u],maxx[mask[x]]+dis[x]); for (int i=0;i<22;i++) { fin[x]=max(fin[x],maxx[mask[x]^(1<<i)]+dis[x]); fin[u]=max(fin[u],maxx[mask[x]^(1<<i)]+dis[x]); } for (edge g : down[x]) { calc(g.v,u); fin[x]=max(fin[x],fin[g.v]); } } void add(int x) { maxx[mask[x]]=max(maxx[mask[x]],dis[x]); for (edge g : down[x]) { add(g.v); } } void del(int x) { maxx[mask[x]]=-1e9; for (edge g : down[x]) { del(g.v); } } void solve(int x) { int done=0; for (edge g : gt[x]) if (g.used==0) done=1; if (!done) return; int u=find_centroid(x); // cout<<"found centroid "<<u<<" in subtree of "<<x<<endl; // actual solving lmao get_info(u,0,0,-1); for (int i=0;i<down[u].size();i++) { del(down[u][i].v); } maxx[0]=0; for (int i=0;i<down[u].size();i++) { calc(down[u][i].v,u); add(down[u][i].v); } for (int i=down[u].size()-1;i>=0;i--) { del(down[u][i].v); } maxx[0]=0; for (int i=down[u].size()-1;i>=0;i--) { calc(down[u][i].v,u); add(down[u][i].v); } // Recurse for (auto g : gt[u]) if (!g.used) { g.used=1; auto it=lower_bound(gt[g.v].begin(),gt[g.v].end(),edge(u)); it->used=1; solve(g.v); } } int main() { cin>>n; for (i=0;i<(1<<22);i++) maxx[i]=-1e9; for (i=2;i<=n;i++) { char c; cin>>u>>c; gt[i].emplace_back(u,c); gt[u].emplace_back(i,c); } for (i=1;i<=n;i++) sort(gt[i].begin(),gt[i].end()); solve(1); for (i=1;i<=n;i++) cout<<fin[i]<<' '; }
19.576923
153
0.608601
NhatMinh0208
47a0106aa17f667170e6dff3a599a6fd90c2cbb8
1,709
cpp
C++
src/lib/libmute8/test/CoreAudio/testcoreaudiodevice.cpp
pezcode/mute8
a5510f9849341e3cb4fce82a67c7c2c6c3d53d49
[ "ISC" ]
1
2019-03-05T11:59:05.000Z
2019-03-05T11:59:05.000Z
src/lib/libmute8/test/CoreAudio/testcoreaudiodevice.cpp
pezcode/mute8
a5510f9849341e3cb4fce82a67c7c2c6c3d53d49
[ "ISC" ]
null
null
null
src/lib/libmute8/test/CoreAudio/testcoreaudiodevice.cpp
pezcode/mute8
a5510f9849341e3cb4fce82a67c7c2c6c3d53d49
[ "ISC" ]
2
2019-03-05T11:59:06.000Z
2019-04-15T14:14:06.000Z
#include "testcoreaudiodevice.h" #include <impl/CoreAudio/deviceenumerator.h> #include <impl/CoreAudio/audiodevice.h> #include <algorithm> // copy_if #include <stdexcept> using namespace mute8; void TestCoreAudioDevice::initTestCase() { CoreDeviceEnumerator enumerator; enumerator.populate(); if(enumerator.count() == 0) { QSKIP("No audio devices"); } this->devices = enumerator.devices(); } // CoreAudioDevice throws on nullptr argument in its constructor void TestCoreAudioDevice::ctorThrowsOnNullPtr() const { QVERIFY_EXCEPTION_THROWN(CoreAudioDevice device(nullptr), std::invalid_argument); } // All devices have a non-empty description, adapter, name and ID void TestCoreAudioDevice::hasNamesAndId() const { for(const auto& device : this->devices) { QVERIFY(!device->getDescription().empty()); QVERIFY(!device->getAdapter().empty()); QVERIFY(!device->getName().empty()); QVERIFY(!device->getId().empty()); } } // There are no duplicate IDs in the device list void TestCoreAudioDevice::uniqueIds() const { std::vector<std::shared_ptr<mute8::IAudioDevice>> uniqueDevices; std::unique_copy(this->devices.begin(), this->devices.end(), std::back_inserter(uniqueDevices), [](const std::shared_ptr<IAudioDevice>& dev1, const std::shared_ptr<IAudioDevice>& dev2) { return dev1->getId() == dev2->getId(); }); QVERIFY(uniqueDevices.size() == this->devices.size()); } // Peak values are in the range [0, 1] void TestCoreAudioDevice::peakValidRange() const { for(const auto& device : this->devices) { float peak = device->getPeak(); QVERIFY(peak >= 0.0f && peak <= 1.0f); } }
28.966102
190
0.685196
pezcode
47a045c11105e7691ad1120146f7949e71a2929a
4,819
hpp
C++
src/Switch.System.Windows.Forms/include/Switch/System/Windows/Forms/ControlEventHandler.hpp
victor-timoshin/Switch
8e8e687a8bdc4f79d482680da3968e9b3e464b8b
[ "MIT" ]
4
2020-02-11T13:22:58.000Z
2022-02-24T00:37:43.000Z
src/Switch.System.Windows.Forms/include/Switch/System/Windows/Forms/ControlEventHandler.hpp
sgf/Switch
8e8e687a8bdc4f79d482680da3968e9b3e464b8b
[ "MIT" ]
null
null
null
src/Switch.System.Windows.Forms/include/Switch/System/Windows/Forms/ControlEventHandler.hpp
sgf/Switch
8e8e687a8bdc4f79d482680da3968e9b3e464b8b
[ "MIT" ]
2
2020-02-01T02:19:01.000Z
2021-12-30T06:44:00.000Z
/// @file /// @brief Contains Switch::System::Windows::Forms::ControlEventHandler event handler. #pragma once #include <Switch/System/EventHandler.hpp> #include "ControlEventArgs.hpp" /// @brief The Switch namespace contains all fundamental classes to access Hardware, Os, System, and more. namespace Switch { /// @brief The Switch::System namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. namespace System { /// @brief The Switch::System::Windows namespaces including animation clients, user interface controls, data binding, and type conversion. Switch::System::Windows::Forms and its child namespaces are used for developing Windows Forms applications. namespace Windows { /// @brief The Switch::System::Windows::Forms namespace contains classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows operating system, Apple macOS and Linux like Ubuntu operating system. namespace Forms { /// @brief Represents the method that will handle the ControlAdded and ControlRemoved events of the Control class. /// @par Library /// Switch.System.Windows.Forms /// @param sender The source of the event. /// @param e A ControlEventArgs that contains the event data. /// @remarks When you create a ControlEventArgs delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see Handling and Raising Events. /// @par Examples /// The following code example demonstrates the use of the ControlAdded and ControlRemoved events. The example requires that two Button controls are added to the form and connected to the addControl_Click and removeControl_Click event handling methods. /// @code /// // This example demonstrates the use of the ControlAdded and /// // ControlRemoved events. This example assumes that two Button controls /// // are added to the form and connected to the AddControlClick and /// // RemoveControlClick event-handler methods. /// void Form1Load(const object& sender, const System::EventArgs& e) { /// // Connect the ControlRemoved and ControlAdded event handlers /// // to the event-handler methods. /// // ControlRemoved and ControlAdded are not available at design time. /// ControlRemoved += new System::Windows::Forms::ControlEventHandler(*this, &Form1::ControlRemoved); /// ControlAdded += new System::Windows::Forms::ControlEventHandler(*this, &Form1::ControlAdded); /// } /// void ControlAdded(const object& sender, const System::Windows::Forms::ControlEventArgs& e) { /// MessageBox::Show("The control named " + e.Control()->Name() + " has been added to the form."); /// } /// void ControlRemoved(const object& sender, const System::Windows::Forms::ControlEventArgs& e) { /// MessageBox::Show("The control named " + e.Control()->Name() + " has been removed from the form."); /// } /// // Click event handler for a Button control. Adds a TextBox to the form. /// void AddControlClick(const object& sender, const System::EventArgs& e) { /// // Create a new TextBox control and add it to the form. /// $<TextBox> textBox1 = new TextBox(); /// textBox1->Size(Size(100, 10)); /// textBox1->Location(Point(10, 10)); /// // Name the control in order to remove it later. The name must be specified /// // if a control is added at run time. /// textBox1->Name("textBox1"); /// // Add the control to the form's control collection. /// Controls.Add(textBox1); /// } /// // Click event handler for a Button control. /// // Removes the previously added TextBox from the form. /// void RemoveControlClick(const object& sender, const System::EventArgs& e) { /// // Loop through all controls in the form's control collection. /// for ($<Control> tempCtrl : Controls) { /// // Determine whether the control is textBox1, /// // and if it is, remove it. /// if (tempCtrl->Name() == "textBox1") { /// Controls.Remove(tempCtrl); /// } /// } /// } /// @endcode using ControlEventHandler = GenericEventHandler<const ControlEventArgs&>; } } } }
66.013699
383
0.665076
victor-timoshin
47ae6d1a3e70ae36ad4345737c5b1091f8a04154
4,311
cpp
C++
Calculus/tv_auto_on_off/voxel-sdk/libvoxel/Voxel/Filter/TemporalMedianFilter.cpp
3dtof/DemoApplications
0eb35d76a72b3972d5c3eeea36274697c0ad82b3
[ "BSD-3-Clause" ]
14
2016-04-01T23:51:04.000Z
2022-03-19T04:02:43.000Z
Voxel/Filter/TemporalMedianFilter.cpp
Metrilus/voxelsdk
751641a08285c4a31e68491df8887f79e71d34d2
[ "BSD-3-Clause" ]
14
2016-05-31T05:16:52.000Z
2019-07-04T02:48:31.000Z
Voxel/Filter/TemporalMedianFilter.cpp
Metrilus/voxelsdk
751641a08285c4a31e68491df8887f79e71d34d2
[ "BSD-3-Clause" ]
14
2016-04-27T22:57:16.000Z
2022-03-29T03:48:42.000Z
#include "TemporalMedianFilter.h" #include <utility> namespace Voxel { TemporalMedianFilter::TemporalMedianFilter(uint order, float deadband): Filter("TemporalMedianFilter"), _order(order), _deadband(deadband) { _addParameters({ FilterParameterPtr(new UnsignedFilterParameter("order", "Order", "Order of the filter", _order, "", 1, 100)), FilterParameterPtr(new FloatFilterParameter("deadband", "Dead band", "Dead band", _deadband, "", 0, 1)), }); } void TemporalMedianFilter::_onSet(const FilterParameterPtr &f) { if(f->name() == "order") { if(!_get(f->name(), _order)) { logger(LOG_WARNING) << "TemporalMedianFilter: Could not get the recently updated 'order' parameter" << std::endl; } } else if(f->name() == "deadband") { if(!_get(f->name(), _deadband)) { logger(LOG_WARNING) << "TemporalMedianFilter: Could not get the recently updated 'deadband' parameter" << std::endl; } } } void TemporalMedianFilter::reset() { _history.clear(); _current.clear(); } template <typename T> bool TemporalMedianFilter::_filter(const T *in, T *out) { uint s = _size.width*_size.height; T *cur, *hist; if(_current.size() != s*sizeof(T)) { _current.resize(s*sizeof(T)); memset(_current.data(), 0, s*sizeof(T)); } cur = (T *)_current.data(); if(_history.size() < _order) { Vector<ByteType> h; h.resize(s*sizeof(T)); memcpy(h.data(), in, s*sizeof(T)); _history.push_back(std::move(h)); memcpy(cur, in, s*sizeof(T)); memcpy(out, in, s*sizeof(T)); } else { _history.pop_front(); Vector<ByteType> h; h.resize(s*sizeof(T)); memcpy(h.data(), in, s*sizeof(T)); _history.push_back(std::move(h)); for(auto i = 0; i < s; i++) { T v; _getMedian(i, v); if(v > 0 && fabs(((float)v - cur[i])/cur[i]) > _deadband) out[i] = cur[i] = v; else out[i] = cur[i]; } } return true; } template <typename T> void TemporalMedianFilter::_getMedian(IndexType offset, T &value) { Vector<T> v; v.reserve(_order); for(auto &h: _history) { T *h1 = (T *)(h.data()); if(h.size() > offset*sizeof(T)) v.push_back(h1[offset]); } std::nth_element(v.begin(), v.begin() + v.size()/2, v.end()); value = v[v.size()/2]; } bool TemporalMedianFilter::_filter(const FramePtr &in, FramePtr &out) { ToFRawFrame *tofFrame = dynamic_cast<ToFRawFrame *>(in.get()); DepthFrame *depthFrame = dynamic_cast<DepthFrame *>(in.get()); if((!tofFrame && !depthFrame) || !_prepareOutput(in, out)) { logger(LOG_ERROR) << "IIRFilter: Input frame type is not ToFRawFrame or DepthFrame or failed get the output ready" << std::endl; return false; } if(tofFrame) { _size = tofFrame->size; ToFRawFrame *o = dynamic_cast<ToFRawFrame *>(out.get()); if(!o) { logger(LOG_ERROR) << "IIRFilter: Invalid frame type. Expecting ToFRawFrame." << std::endl; return false; } //logger(LOG_INFO) << "IIRFilter: Applying filter with gain = " << _gain << " to ToFRawFrame id = " << tofFrame->id << std::endl; uint s = _size.width*_size.height; memcpy(o->ambient(), tofFrame->ambient(), s*tofFrame->ambientWordWidth()); memcpy(o->amplitude(), tofFrame->amplitude(), s*tofFrame->amplitudeWordWidth()); memcpy(o->flags(), tofFrame->flags(), s*tofFrame->flagsWordWidth()); if(tofFrame->phaseWordWidth() == 2) return _filter<uint16_t>((uint16_t *)tofFrame->phase(), (uint16_t *)o->phase()); else if(tofFrame->phaseWordWidth() == 1) return _filter<uint8_t>((uint8_t *)tofFrame->phase(), (uint8_t *)o->phase()); else if(tofFrame->phaseWordWidth() == 4) return _filter<uint32_t>((uint32_t *)tofFrame->phase(), (uint32_t *)o->phase()); else return false; } else if(depthFrame) { _size = depthFrame->size; DepthFrame *o = dynamic_cast<DepthFrame *>(out.get()); if(!o) { logger(LOG_ERROR) << "IIRFilter: Invalid frame type. Expecting DepthFrame." << std::endl; return false; } o->amplitude = depthFrame->amplitude; return _filter<float>(depthFrame->depth.data(), o->depth.data()); } else return false; } }
25.814371
139
0.609371
3dtof
47b04c38c428721bd6518f6a9b4db1aaa6f93997
10,908
cpp
C++
hazelcast/src/hazelcast/client/cluster.cpp
RikeVoltz/hazelcast-cpp-client
8bf2c22aba474503f8b49d5d6e80af072dbf4cf6
[ "Apache-2.0" ]
78
2015-10-23T13:50:12.000Z
2021-12-17T11:22:58.000Z
hazelcast/src/hazelcast/client/cluster.cpp
RikeVoltz/hazelcast-cpp-client
8bf2c22aba474503f8b49d5d6e80af072dbf4cf6
[ "Apache-2.0" ]
949
2015-10-26T12:18:38.000Z
2022-03-31T15:49:08.000Z
hazelcast/src/hazelcast/client/cluster.cpp
RikeVoltz/hazelcast-cpp-client
8bf2c22aba474503f8b49d5d6e80af072dbf4cf6
[ "Apache-2.0" ]
49
2015-10-23T13:51:52.000Z
2021-09-01T00:26:45.000Z
/* * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <functional> #include <boost/uuid/uuid_io.hpp> #include <boost/functional/hash.hpp> #include "hazelcast/client/cluster.h" #include "hazelcast/client/spi/impl/ClientClusterServiceImpl.h" #include "hazelcast/client/membership_listener.h" #include "hazelcast/client/initial_membership_event.h" #include "hazelcast/client/member.h" #include "hazelcast/client/serialization/serialization.h" #include "hazelcast/client/membership_event.h" #include "hazelcast/client/impl/vector_clock.h" #include "hazelcast/client/member_selectors.h" #include "hazelcast/client/internal/partition/strategy/StringPartitioningStrategy.h" namespace hazelcast { namespace client { cluster::cluster(spi::impl::ClientClusterServiceImpl &cluster_service) : cluster_service_(cluster_service) { } std::vector<member> cluster::get_members() { return cluster_service_.get_member_list(); } boost::uuids::uuid cluster::add_membership_listener(membership_listener &&listener) { return cluster_service_.add_membership_listener(std::move(listener)); } bool cluster::remove_membership_listener(boost::uuids::uuid registration_id) { return cluster_service_.remove_membership_listener(registration_id); } member::member() : lite_member_(false) { } member::member(address member_address, boost::uuids::uuid uuid, bool lite, std::unordered_map<std::string, std::string> attr, std::unordered_map<endpoint_qualifier, address> address_map) : address_(std::move(member_address)), uuid_(uuid), lite_member_(lite), attributes_(std::move(attr)), address_map_(std::move(address_map)) { } member::member(address member_address) : address_(member_address), lite_member_(false) { } member::member(boost::uuids::uuid uuid) : uuid_(uuid), lite_member_(false) { } const address &member::get_address() const { return address_; } boost::uuids::uuid member::get_uuid() const { return uuid_; } bool member::is_lite_member() const { return lite_member_; } const std::unordered_map<std::string, std::string> &member::get_attributes() const { return attributes_; } std::ostream &operator<<(std::ostream &out, const member &member) { const address &address = member.get_address(); out << "Member["; out << address.get_host(); out << "]"; out << ":"; out << address.get_port(); out << " - " << boost::uuids::to_string(member.get_uuid()); if (member.is_lite_member()) { out << " lite"; } return out; } const std::string *member::get_attribute(const std::string &key) const { std::unordered_map<std::string, std::string>::const_iterator it = attributes_.find(key); if (attributes_.end() != it) { return &(it->second); } else { return NULL; } } bool member::lookup_attribute(const std::string &key) const { return attributes_.find(key) != attributes_.end(); } bool member::operator<(const member &rhs) const { return uuid_ < rhs.uuid_; } const std::unordered_map<endpoint_qualifier, address> &member::address_map() const { return address_map_; } bool operator==(const member &lhs, const member &rhs) { return lhs.address_ == rhs.address_ && lhs.uuid_ == rhs.uuid_; } endpoint::endpoint(boost::uuids::uuid uuid, boost::optional<address> socket_address) : uuid_(uuid), socket_address_(std::move(socket_address)) {} boost::uuids::uuid endpoint::get_uuid() const { return uuid_; } const boost::optional<address> &endpoint::get_socket_address() const { return socket_address_; } membership_event::membership_event(cluster &cluster, const member &m, membership_event_type event_type, const std::unordered_map<boost::uuids::uuid, member, boost::hash<boost::uuids::uuid>> &members_list) : cluster_(cluster), member_(m), event_type_(event_type), members_(members_list) { } membership_event::~membership_event() = default; std::unordered_map<boost::uuids::uuid, member, boost::hash<boost::uuids::uuid>> membership_event::get_members() const { return members_; } cluster &membership_event::get_cluster() { return cluster_; } membership_event::membership_event_type membership_event::get_event_type() const { return event_type_; } const member &membership_event::get_member() const { return member_; } local_endpoint::local_endpoint(boost::uuids::uuid uuid, boost::optional<address> socket_address, std::string name, std::unordered_set<std::string> labels) : endpoint(uuid, std::move(socket_address)), name_(std::move(name)), labels_(std::move(labels)) {} const std::string &local_endpoint::get_name() const { return name_; } namespace impl { vector_clock::vector_clock() = default; vector_clock::vector_clock(const vector_clock::timestamp_vector &replica_logical_timestamps) : replica_timestamp_entries_(replica_logical_timestamps) { for (const vector_clock::timestamp_vector::value_type &replicaTimestamp : replica_logical_timestamps) { replica_timestamps_[replicaTimestamp.first] = replicaTimestamp.second; } } vector_clock::timestamp_vector vector_clock::entry_set() { return replica_timestamp_entries_; } bool vector_clock::is_after(vector_clock &other) { bool anyTimestampGreater = false; for (const vector_clock::timestamp_map::value_type &otherEntry : other.replica_timestamps_) { const auto &replicaId = otherEntry.first; int64_t otherReplicaTimestamp = otherEntry.second; std::pair<bool, int64_t> localReplicaTimestamp = get_timestamp_for_replica(replicaId); if (!localReplicaTimestamp.first || localReplicaTimestamp.second < otherReplicaTimestamp) { return false; } else if (localReplicaTimestamp.second > otherReplicaTimestamp) { anyTimestampGreater = true; } } // there is at least one local timestamp greater or local vector clock has additional timestamps return anyTimestampGreater || other.replica_timestamps_.size() < replica_timestamps_.size(); } std::pair<bool, int64_t> vector_clock::get_timestamp_for_replica(boost::uuids::uuid replica_id) { if (replica_timestamps_.count(replica_id) == 0) { return std::make_pair(false, -1); } return std::make_pair(true, replica_timestamps_[replica_id]); } } bool member_selectors::data_member_selector::select(const member &member) const { return !member.is_lite_member(); } const std::unique_ptr<member_selector> member_selectors::DATA_MEMBER_SELECTOR( new member_selectors::data_member_selector()); namespace internal { namespace partition { namespace strategy { std::string StringPartitioningStrategy::get_base_name(const std::string &name) { size_t index_of = name.find('@'); if (index_of == std::string::npos) { return name; } return name.substr(0, index_of); } std::string StringPartitioningStrategy::get_partition_key(const std::string &key) { size_t firstIndexOf = key.find('@'); if (firstIndexOf == std::string::npos) { return key; } else { return key.substr(firstIndexOf + 1); } } } } } bool operator==(const endpoint_qualifier &lhs, const endpoint_qualifier &rhs) { return lhs.type == rhs.type && lhs.identifier == rhs.identifier; } } } namespace std { std::size_t hash<hazelcast::client::member>::operator()(const hazelcast::client::member &m) const noexcept { std::size_t seed = 0; boost::hash_combine(seed, std::hash<hazelcast::client::address>()(m.get_address())); boost::hash_combine(seed, m.get_uuid()); return seed; } std::size_t hash<hazelcast::client::endpoint_qualifier>::operator()( const hazelcast::client::endpoint_qualifier &e) const noexcept { std::size_t seed = 0; boost::hash_combine(seed, e.type); boost::hash_combine(seed, e.identifier); return seed; } }
39.956044
147
0.600293
RikeVoltz
47b2ba135a0afc0940f011658599cdfa54090037
294
cpp
C++
ch03/ex3_3_3.cpp
SASUKE40/primer
08c58aeee1673d006510f3e0ec8856d94002e793
[ "MIT" ]
null
null
null
ch03/ex3_3_3.cpp
SASUKE40/primer
08c58aeee1673d006510f3e0ec8856d94002e793
[ "MIT" ]
null
null
null
ch03/ex3_3_3.cpp
SASUKE40/primer
08c58aeee1673d006510f3e0ec8856d94002e793
[ "MIT" ]
null
null
null
#include <string> #include <iostream> #include <vector> using std::string; using std::cin; using std::cout; using std::endl; using std::getline; using std::vector; int main() { vector<int> v{ 1,2,3,4,5,6,7,8,9 }; for (auto& i : v) i *= i; for (auto i : v) cout << i << endl; return 0; }
17.294118
36
0.615646
SASUKE40
47b3a130bbe55d0ef1ea387832e1496593a6f595
3,890
hpp
C++
include/fea/entity/entity.hpp
therocode/featherkit
8631c9acb0fef6c5039783173ef173ec9488f53b
[ "Zlib" ]
22
2015-01-13T10:49:38.000Z
2020-12-23T15:25:59.000Z
include/fea/entity/entity.hpp
therocode/featherkit
8631c9acb0fef6c5039783173ef173ec9488f53b
[ "Zlib" ]
27
2015-01-11T03:47:27.000Z
2015-12-10T17:52:17.000Z
include/fea/entity/entity.hpp
therocode/featherkit
8631c9acb0fef6c5039783173ef173ec9488f53b
[ "Zlib" ]
7
2015-09-18T15:06:45.000Z
2020-02-19T15:12:34.000Z
#pragma once #include <fea/config.hpp> #include <fea/entity/entitymanager.hpp> namespace fea { class FEA_API Entity { public: Entity(EntityId id, EntityManager& entityManager); template<class DataType> const DataType& getAttribute(const std::string& attribute) const; template<class DataType> DataType& getAttribute(const std::string& attribute); template<class DataType> void setAttribute(const std::string& attribute, DataType value) const; bool hasAttribute(const std::string& attribute) const; EntityId getId() const; std::unordered_set<std::string> getAttributes() const; private: EntityId mId; EntityManager& mEntityManager; }; #include <fea/entity/entity.inl> /** @addtogroup EntitySystem *@{ * @class Entity *@} *** * @class Entity * @brief Represents a single game entity. * * A game entity is no more than a collection of attributes, associated with the same entity ID. An attribute is a named value of any type. An example of an attribute would be an int named "health points" storing the value 23. An entity may have an arbitrary amount of attributes and every entity has a unique entity ID. * * Although usage may vary and is not restricted, the entities are meant to be used for ingame objects that need to store data. These could include the player, enemies, pickups, bullets, and so on. *** * @fn Entity::Entity(EntityId i, EntityManager& m) * @brief Construct an Entity. * * This sets the EntityId to the supplied ID. The entity stores the EntityManager reference internally for using when getting and setting attributes. * * Observe that entities aren't mean to be created manually, but using the EntityManager::CreateEntity function. * @param i ID of the new entity. * @param m EntityManager that the entity will use. *** * @fn const DataType& Entity::getAttribute(const std::string& attribute) const * @brief Get the value of an attribute of the entity. * * Assert/undefined behavior when the attribute does not exist or the wrong template argument is provided. * @tparam Type of the attribute to get. * @param attribute Name of the attribute to get. * @return Attribute value. *** * @fn DataType& Entity::getAttribute(const std::string& attribute) * @brief Get the value of an attribute of the entity. * * Assert/undefined behavior when the attribute does not exist or the wrong template argument is provided. * @tparam Type of the attribute to get. * @param attribute Name of the attribute to get. * @return Attribute value. *** * @fn void Entity::setAttribute(const std::string& attribute, DataType value) const * @brief Set the value of an attribute of the entity. * * Assert/undefined behavior when the attribute does not exist or the wrong template argument is provided. * @tparam Type of the attribute to set. * @param attribute Name of the attribute to set. * @param value Value to set the attribute to. *** * @fn bool Entity::hasAttribute(const std::string& attribute) const * @brief Check if the entity has an attribute. * * @param attribute Name of the attribute to check. * @return True if the attribute exists. *** * @fn EntityId Entity::getId() const * @brief Get the ID of an entity. * @return The ID. *** * @fn std::unordered_set<std::string> Entity::getAttributes() const * @brief Get a set containing all the attributes of the entity. * * Assert/undefined behavior if the entity does not exist. * @return Set with attributes. ***/ }
44.712644
326
0.658355
therocode
47c12a8ba723985e4e2df1422e0203994be08463
6,011
cpp
C++
Shader.cpp
andkrau/nuance
32b9d6b9257c6c51944727456fce2e7caf074182
[ "W3C" ]
null
null
null
Shader.cpp
andkrau/nuance
32b9d6b9257c6c51944727456fce2e7caf074182
[ "W3C" ]
null
null
null
Shader.cpp
andkrau/nuance
32b9d6b9257c6c51944727456fce2e7caf074182
[ "W3C" ]
null
null
null
#include <stdio.h> #include "Shader.h" void ShaderProgram::ShaderProgram() { hProgramObject = 0; hVertexShaderObject = 0; hFragmentShaderObject = 0; bVertexShaderObjectAttached = false; bFragmentShaderObjectAttached = false; } void ShaderProgram::~ShaderProgram() { Uninitalize(); } bool ShaderProgram::Initialize() { if(!hProgramObject) { hProgramObject = glCreateProgramObjectARB(); if(!hProgramObject) { return false; } hVertexShaderObject = glCreateShaderObject(GL_ARB_VERTEX_SHADER); hFragmentShaderObject = glCreateShaderObject(GL_ARB_FRAGMENT_SHADER); } return true; } bool ShaderProgram::Uninitalize() { if(hProgramObject) { if(hVertexShaderObject) { glDeleteObjectARB(hVertexShaderObject); } if(hVertexShaderObject) { glDeleteObjectARB(hVertexShaderObject); } glDeleteObjectARB(hProgramObject); hShaderProgram = 0; hVertexShaderProgram = 0; hFragmentShaderProgram = 0; bVertexShaderObjectAttached = false; bFragmentShaderObjectAttached = false; } return true; } bool ShaderProgram::InstallShaderSourceFromFile(uchar *filename, GLshaderType type) { FILE *inFile; uint32 length; uchar *buffer; int32 nextChar; bool bStatus = false; inFile = fopen(filename,"r"); if(inFile) { fseek(inFile,0,SEEK_END); length = ftell(inFile) + 1; buffer = new uchar[length]; fseek(inFile,0,SEEK_SET); fread(buffer,1,sizeof(buffer),inFile); if(type == GL_FRAGMENT_SHADER_ARB) { if(hFragmentShaderObject) { glShaderSourceARB(hFragmentShaderObject,1,&buffer,&length); bStatus = true; } } else if(type == GL_VERTEX_SHADER_ARB) { if(hVertexShaderObject) { glShaderSourceARB(hVertexShaderObject,1,&buffer,&length); bStatus = true; } } delete [] buffer; } return bStatus; } bool ShaderProgram::InstallShaderSourceFromMemory(uchar **sourceStrings, uint32 count, const int *lengths, GLshaderType type) { bool bStatus = false; if(type == GL_FRAGMENT_SHADER_ARB) { if(hFragmentShaderObject) { glShaderSourceARB(hFragmentShaderObject,count,sourceStrings,lengths); bStatus = true; } } else if(type == GL_VERTEX_SHADER_ARB) { if(hVertexShaderObject) { glShaderSourceARB(hVertexShaderObject,1,&buffer,&length); bStatus = true; } } return bStatus; } bool ShaderProgram::CompileShader(GLshaderType type) { bool bStatus = false; GLboolean bCompiled = GL_FALSE; if(type == GL_FRAGMENT_SHADER_ARB) { if(hFragmentShaderObject) { glCompileShaderARB(hFragmentShaderObject); glGetObjectParameterivARB(hFragmentShaderObject, GL_OBJECT_COMPILE_STATUS_ARB, &bCompiled); bStatus = bCompiled; } } else if(type == GL_VERTEX_SHADER_ARB) { if(hVertexShaderObject) { glCompileShaderARB(hVertexShaderObject); glGetObjectParameterivARB(hVertexShaderObject, GL_OBJECT_COMPILE_STATUS_ARB, &bCompiled); bStatus = bCompiled; } } return bStatus; } bool ShaderProgram::Link() { bool bStatus = false; GLboolean linked = GL_FALSE; if(!hProgramObject) { return false; } glLinkProgramARB(hProgramObject); glGetObjectParameterivARB(hProgramObject, GL_OBJECT_LINK_STATUS_ARB, &bLinked); bStatus = bLinked; return bStatus; } bool ShaderProgram::AttachShader(GLshaderType type) { bool status = false; GLboolean bCompiled = GL_FALSE; if(!hProgramObject) { return false; } if(type == GL_FRAGMENT_SHADER_ARB) { if(!hFragmentShaderObject) { return false; } if(!bFragmentShaderObjectAttached) { bFragmentShaderObjectAttached = true; glAttachObjectARB(hProgramObject,hFragmentShaderObject); } } else if(type == GL_VERTEX_SHADER_ARB) { if(!hVertexShaderObject) { return false; } if(!bVertexShaderObjectAttached) { bVertexShaderObjectAttached = true; glAttachObjectARB(hProgramObject,hVertexShaderObject); } } return true; } bool ShaderProgram::DetatchShader(GLshaderType type) { bool status = false; GLboolean bCompiled = GL_FALSE; if(!hProgramObject) { return false; } if(type == GL_FRAGMENT_SHADER_ARB) { if(!hFragmentShaderObject) { return false; } if(bFragmentShaderObjectAttached) { bFragmentShaderObjectAttached = false; glDetachObjectARB(hProgramObject,hFragmentShaderObject); } } else if(type == GL_VERTEX_SHADER_ARB) { if(!hVertexShaderObject) { return false; } if(!bVertexShaderObjectAttached) { bVertexShaderObjectAttached = false; glDetachObjectARB(hProgramObject,hVertexShaderObject); } } } bool ShaderProgram::CompileAndLinkShaders() { bool bStatus = false; if(!hProgramObject) { return false; } if(hFragmentShaderObject) { glCompileShaderARB(hFragmentShaderObject); glGetObjectParameterivARB(hFragmentShaderObject, GL_OBJECT_COMPILE_STATUS_ARB, &bCompiled); if(!bCompiled) { return false; } } if(hVertexShaderObject) { glCompileShaderARB(hVertexShaderObject); glGetObjectParameterivARB(hVertexShaderObject, GL_OBJECT_COMPILE_STATUS_ARB, &bCompiled); if(!bCompiled) { return false; } } glLinkProgramARB(hProgramObject); glGetObjectParameterivARB(hProgramObject, GL_OBJECT_LINK_STATUS_ARB, &bLinked); status = bLinked; return bStatus; } bool ShaderProgram::StartShaderProgram() { glUseProgramObjectARB(hProgramObject); } bool ShaderProgram::StopShaderProgram() { glUseProgramObjectARB(0); }
20.515358
126
0.659957
andkrau
47c15683474f85d1f2d5cca51d4a3518b0e872d8
2,253
cpp
C++
Test/pcap/pcapTest.cpp
diridari/PCAPStreamMerge
8aba6f1cf0db48d02bd0bf3cf24fedf44ee569a2
[ "MIT" ]
1
2019-01-22T01:53:10.000Z
2019-01-22T01:53:10.000Z
Test/pcap/pcapTest.cpp
diridari/PCAPStreamMerge
8aba6f1cf0db48d02bd0bf3cf24fedf44ee569a2
[ "MIT" ]
null
null
null
Test/pcap/pcapTest.cpp
diridari/PCAPStreamMerge
8aba6f1cf0db48d02bd0bf3cf24fedf44ee569a2
[ "MIT" ]
null
null
null
// // Created by basto on 9/3/17. // #include "../gtest/gtest.h" #include "../../include/IO/Writer/PCAPWriter.h" #include "../../include/PCAP.h" #include "../../include/LinuxEncalsulation.h" int8_t pcapF3[] = {0x16, (char) 0xEF, (char) 0xC4, 0x4A, (char) 0xB3, 0x45, 0x09, 0x00, 0x04, 0, 0, 0, 0x04, 0, 0, 0, 0x01, 0x02, 0x03, 0x04}; // 4byte payload int8_t encap[] = {0x16, (char) 0xEF, (char) 0xC4, 0x4A, (char) 0xB3, 0x45, 0x09, 0x00, 0x14, 0, 0, 0, 0x14, 0, 0, 0, 0x01, 0x02, 0x03, 0x04}; // 4byte payload /* * Check that the building of a pcap struct works correct */ TEST(pcap, pcapBuild) { LinuxEncalsulation::setNoEncapsulation(); pcap *p = new pcap(); LinuxEncalsulation::setNoEncapsulation(); int count = 1; while (p->append((char) pcapF3[count - 1]) != 1) { count++; } ASSERT_EQ(count, sizeof(pcapF3)); } TEST(pcap, pcapPayload) { LinuxEncalsulation::setNoEncapsulation(); pcap *p = new pcap(); LinuxEncalsulation::setNoEncapsulation(); int count = 1; while (p->append((char) pcapF3[count - 1]) != 1) { count++; } int8_t payload[] = {0x01,0x02,0x03,0x04}; ASSERT_EQ(p->pcapStruct->intSize,4); for (int i = 0; i <4 ; ++i) { ASSERT_EQ(payload[i],p->pcapStruct->payload[i]); } } TEST(pcap, AppendTooMuch) { pcap *p = new pcap(); LinuxEncalsulation::setNoEncapsulation(); for(int i = 0; i<sizeof(pcapF3)-1;i++) ASSERT_EQ(p->append(pcapF3[i]),0); ASSERT_EQ(p->append(0xFF),1); // last payload ASSERT_EQ(p->append(0xAA),-1); // to much ASSERT_EQ(p->append(0xA),-1); // to much ASSERT_EQ(p->append(0x9A),-1); // to much } TEST(pcap,encapsulation){ LinuxEncalsulation::setNoEncapsulation(true); uint8_t pcapEnd[] = {0x0,0x1,0x2,0x3,4,5,6,7,8,9,10,11,12,13,14,15}; // random struff pcap *p = new pcap(); for(int i = 0; i< sizeof(encap);i++){ ASSERT_EQ(p->append(encap[i]),0); } int i =0; while(p->append(pcapEnd[i])== 0){ i++; } int8_t payload[] = {12,13,14,15}; ASSERT_EQ(p->pcapStruct->intSize,4); for (int i = 0; i <4 ; ++i) { ASSERT_EQ(payload[i],p->pcapStruct->payload[i]); } }
25.602273
117
0.580115
diridari
47c586907b436753b39b3c2dac01b3547cc593f4
9,503
cpp
C++
src/Layers/SandboxLayer.cpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
2
2021-06-27T12:52:57.000Z
2021-08-24T21:25:57.000Z
src/Layers/SandboxLayer.cpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
null
null
null
src/Layers/SandboxLayer.cpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
null
null
null
#include "Layers/SandboxLayer.hpp" #include "Apps/Application.hpp" #include "Component/BoundingBox.hpp" #include "Component/Light.hpp" #include "Component/ShadowMap.hpp" #include "Entity/ModelEntity.hpp" #include "Entity/Cube.hpp" #include "Entity/Sphere.hpp" #include "Physics/PhysicsWorld.hpp" #include "Physics/Rigidbody.hpp" #include "Physics/SphereCollider.hpp" #include "Physics/HullCollider.hpp" #include "Graphic/Renderer.hpp" #include "Core/Math.hpp" #include "Entity/Terrain.hpp" #include "Entity/Player.hpp" #include "Utils/File.hpp" #include <iostream> namespace te { void SandboxLayer::addSphere(const glm::vec3& pos, float radius, const glm::vec3& impulse, const Ref<Material>& textures) { Ref<SceneManager<EntityBase>> scene = Application::instance().getActiveScene(); int id = scene->entities.create<Sphere>(radius, textures); EntityBase* sphere = scene->entities.get(id); sphere->add<Rigidbody>(10, true); sphere->add<SphereCollider>(glm::vec3(0), radius); sphere->component<Rigidbody>()->addImpulse(impulse); sphere->setPosition(pos); sphere->setName("Sphere"); } void SandboxLayer::addCube(const glm::vec3& pos, const glm::vec3& euler, float width, float height, float length, const glm::vec3& impulse, const Ref<Material>& textures, bool kinematic) { Ref<SceneManager<EntityBase>> scene = Application::instance().getActiveScene(); int id = scene->entities.create<Cube>(width, height, length, textures); EntityBase* cube = scene->entities.get(id); cube->add<Rigidbody>(10, kinematic); cube->add<HullCollider>(); MakeCubeCollider(*cube->component<HullCollider>().get(), width, height, length); cube->component<Rigidbody>()->addImpulse(impulse); cube->setPosition(pos); cube->setEulerAngle(euler); cube->setName("Cube"); } void SandboxLayer::addModel(const std::string& path, const glm::vec3& pos) { Ref<SceneManager<EntityBase>> scene = Application::instance().getActiveScene(); int id = scene->entities.create<ModelEntity>(); EntityBase* model = scene->entities.get(id); dynamic_cast<ModelEntity*>(model)->loadFromFile(path); model->setPosition(pos); model->setName("model"); } void SandboxLayer::loadShaders() { const char* deferredVertex = R"( #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 texCoord; void main() { texCoord = aTexCoord; gl_Position = vec4(aPos, 1.0); })"; std::string deferredFragment; fileToString("shader/light.glsl", deferredFragment); m_shader = createScope<Shader>(); m_shader->compile(deferredVertex, deferredFragment.c_str()); float quadVertices[] = { -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, }; Ref<VertexBuffer> buffer = createRef<VertexBuffer>(quadVertices, sizeof(quadVertices)); buffer->setLayout({{ShaderDataType::Float3, "aPos"}, {ShaderDataType::Float2, "aTexCoord"}}); m_quad = createScope<VertexArray>(); m_quad->addVertexBuffer(buffer); } void SandboxLayer::loadScene() { Ref<SceneManager<EntityBase>> scene = Application::instance().getActiveScene(); uint32_t lightSource = scene->entities.create<EntityBase>(); auto light = scene->entities.get(lightSource); light->setName("Directional Light"); light->add<ShadowMap>(20.f); light->setPosition(glm::vec3(0, 8, 8)); light->setEulerAngle(glm::vec3(glm::radians(45.f), glm::radians(180.f), 0)); light->add<DirectionalLight>(); light->component<DirectionalLight>()->ambient = glm::vec3(0.5f); light->component<DirectionalLight>()->diffuse = glm::vec3(1.0f); light->component<DirectionalLight>()->specular = glm::vec3(1.0f); uint32_t pointLightId = scene->entities.create<EntityBase>(); auto pointLight = scene->entities.get(pointLightId); pointLight->setName("Point Light"); pointLight->setPosition(glm::vec3(0, 8, 8)); pointLight->setEulerAngle( glm::vec3(glm::radians(90.f), glm::radians(180.f), 0)); pointLight->add<PointLight>(); pointLight->component<PointLight>()->ambient = glm::vec3(0.5f); pointLight->component<PointLight>()->diffuse = glm::vec3(1.0f); pointLight->component<PointLight>()->specular = glm::vec3(1.0f); // addModel("resources/models/backpack/backpack.obj", // glm::vec3(0.f, 6.f, 6.f)); // ground Ref<Material> groundTextures = createRef<Material>(); groundTextures->loadFromValue( glm::vec3(0), Material::TEXTURE_AMBIENT, TextureParameter(GL_MIRRORED_REPEAT, GL_LINEAR)); groundTextures->loadFromFile( "resources/terrain/sand_01_diff_4k.jpg", Material::TEXTURE_DIFFUSE, TextureParameter(GL_MIRRORED_REPEAT, GL_LINEAR)); groundTextures->loadFromFile( "resources/terrain/sand_01_spec_4k.jpg", Material::TEXTURE_SPECULAR, TextureParameter(GL_MIRRORED_REPEAT, GL_LINEAR)); scene->entities.create<Terrain>(10, 20, groundTextures); addCube(glm::vec3(0, 2, 0), glm::vec3(0), 20, 1, 20, glm::vec3(0), groundTextures, false); uint32_t playerId = scene->entities.create<Player>(); scene->entities.get(playerId)->setPosition(glm::vec3(0.f, 5.f, 0.f)); } SandboxLayer::SandboxLayer(int width, int height) : Layer("Sandbox"), m_viewWidth(width), m_viewHeight(height) {} void SandboxLayer::onAttach() { loadShaders(); loadScene(); } void SandboxLayer::onUpdate(const Time&) {} void SandboxLayer::onRender() { Ref<SceneManager<EntityBase>> scene = Application::instance().getActiveScene(); PointLight::Handle pointLight; auto view = scene->entities.getByComponents(pointLight); auto end = view.end(); uint32_t index = 0; m_shader->bind(); for (auto cur = view.begin(); cur != end; ++cur) { std::string prefix = "uPointLights[" + std::to_string(index) + "]."; m_shader->setVec3(prefix + "position", cur->getPosition()); m_shader->setVec3(prefix + "direction", cur->getFront()); m_shader->setVec3(prefix + "ambient", pointLight->ambient); m_shader->setVec3(prefix + "diffuse", pointLight->diffuse); m_shader->setVec3(prefix + "specular", pointLight->specular); m_shader->setFloat(prefix + "constant", pointLight->constant); m_shader->setFloat(prefix + "linear", pointLight->linear); m_shader->setFloat(prefix + "quadratic", pointLight->quadratic); m_shader->setFloat(prefix + "cutOff", pointLight->cutOff); m_shader->setFloat(prefix + "outerCutOff", pointLight->outerCutOff); ++index; } m_shader->setInt("uLightCount", index); glDepthMask(GL_FALSE); Renderer::beginScene(*Application::instance().getMainCamera(), Application::instance().getFramebuffer()); Renderer::clear(); Renderer::submit(*m_shader, *m_quad, GL_TRIANGLE_STRIP, false); Renderer::endScene(); glDepthMask(GL_TRUE); } void SandboxLayer::onEventPoll(const Event& event) { if (event.type == Event::KEY_PRESSED) { switch (event.key.code) { case Keyboard::T: { RandomGenerator random; Ref<Material> textures = createRef<Material>(); float r = random.rnd(0.5, 1.0); float g = random.rnd(0.5, 1.0); float b = random.rnd(0.5, 1.0); textures->loadFromValue(0.5f * glm::vec3(r, g, b), Material::TEXTURE_AMBIENT); textures->loadFromValue(glm::vec3(r, g, b), Material::TEXTURE_DIFFUSE); textures->loadFromValue(glm::vec3(0.5f), Material::TEXTURE_SPECULAR); glm::vec3 impulse(random.rnd(-25, 25), random.rnd(-25, 25), random.rnd(-25, 25)); addSphere(glm::vec3(5, 15, 0), 0.5f, impulse, textures); } break; case Keyboard::R: { RandomGenerator random; Ref<Material> textures = createRef<Material>(); float r = random.rnd(0.5, 1.0); float g = random.rnd(0.5, 1.0); float b = random.rnd(0.5, 1.0); textures->loadFromValue(0.5f * glm::vec3(r, g, b), Material::TEXTURE_AMBIENT); textures->loadFromValue(glm::vec3(r, g, b), Material::TEXTURE_DIFFUSE); textures->loadFromValue(glm::vec3(0.5f), Material::TEXTURE_SPECULAR); glm::vec3 impulse(random.rnd(-25, 25), random.rnd(-25, 25), random.rnd(-25, 25)); addCube(glm::vec3(5, 5, 0), glm::vec3(random.rnd(0.f, M_PI), random.rnd(0.f, M_PI), random.rnd(0.f, M_PI)), 1, 1, 1, impulse, textures, true); } break; default: break; } } } void SandboxLayer::onEventProcess() {} } // namespace te
40.266949
80
0.606756
xubury
47cb6d533597db346b27e62416fe36ef5371ce17
253
hpp
C++
include/3dstris/util/hash.hpp
3DStris/3DStris
a99be7997a0bdb351260aad720a79059bc09258d
[ "MIT" ]
28
2019-11-16T22:16:57.000Z
2022-01-02T02:32:10.000Z
include/3dstris/util/hash.hpp
weblate/3DStris
8f3ac84110c39200df91032338951ca66347d78c
[ "MIT" ]
47
2020-01-07T18:35:03.000Z
2021-02-14T16:21:12.000Z
include/3dstris/util/hash.hpp
weblate/3DStris
8f3ac84110c39200df91032338951ca66347d78c
[ "MIT" ]
6
2019-11-16T15:24:14.000Z
2021-05-09T02:33:55.000Z
#pragma once #include <3dstris/util/string.hpp> struct StringHash { using is_transparent = void; size_t operator()(StringView v) const; }; struct StringEq { using is_transparent = void; bool operator()(StringView lhs, StringView rhs) const; };
15.8125
55
0.735178
3DStris
47cb984d3ccca39891776f8bcf6c989b6977ff3d
1,259
cpp
C++
CityRenderingEngine/engine/rendering/Frustum.cpp
roooodcastro/city-rendering-engine
eb0f2f948ab509baf7f5e08ec05f6eb510805eac
[ "MIT" ]
2
2021-03-13T13:33:25.000Z
2021-03-13T14:19:18.000Z
CityRenderingEngine/engine/rendering/Frustum.cpp
roooodcastro/city-rendering-engine
eb0f2f948ab509baf7f5e08ec05f6eb510805eac
[ "MIT" ]
1
2020-05-23T05:48:01.000Z
2020-05-24T08:36:06.000Z
CityRenderingEngine/engine/rendering/Frustum.cpp
roooodcastro/city-rendering-engine
eb0f2f948ab509baf7f5e08ec05f6eb510805eac
[ "MIT" ]
1
2021-03-13T13:33:33.000Z
2021-03-13T13:33:33.000Z
#include "Frustum.h" Frustum::Frustum(const Matrix4 &mvp) { updateMatrix(mvp); } void Frustum::updateMatrix(const Matrix4 &mvp) { Vector3 xaxis = Vector3(mvp.values[0], mvp.values[4], mvp.values[8]); Vector3 yaxis = Vector3(mvp.values[1], mvp.values[5], mvp.values[9]); Vector3 zaxis = Vector3(mvp.values[2], mvp.values[6], mvp.values[10]); Vector3 waxis = Vector3(mvp.values[3], mvp.values[7], mvp.values[11]); // Right plane planes[0] = Plane(waxis - xaxis, (mvp.values[15] - mvp.values[12]), true); // Left plane planes[1] = Plane(waxis + xaxis, (mvp.values[15] + mvp.values[12]), true); // Bottom plane planes[2] = Plane(waxis + yaxis, (mvp.values[15] + mvp.values[13]), true); // Top plane planes[3] = Plane(waxis - yaxis, (mvp.values[15] - mvp.values[13]), true); // Far plane planes[4] = Plane(waxis - zaxis, (mvp.values[15] - mvp.values[14]), true); // Near plane planes[5] = Plane(waxis + zaxis, (mvp.values[15] + mvp.values[14]), true); } bool Frustum::isEntityInside(Entity *entity) { for (int p = 0; p < 6; p++) { if (!planes[p].isSphereInPlane(entity->getWorldPosition(), entity->getRenderRadius())) { return false; } } return true; }
37.029412
96
0.614774
roooodcastro
47d72998e96bcbf6a87956643cef4c0941e4fc6e
2,225
cc
C++
engine/gui/game/guiProgressCtrl.cc
ClayHanson/B4v21-Public-Repo
c812aa7bf2ecb267e02969c85f0c9c2a29be0d28
[ "MIT" ]
1
2020-08-18T19:45:34.000Z
2020-08-18T19:45:34.000Z
engine/gui/game/guiProgressCtrl.cc
ClayHanson/B4v21-Launcher-Public-Repo
c812aa7bf2ecb267e02969c85f0c9c2a29be0d28
[ "MIT" ]
null
null
null
engine/gui/game/guiProgressCtrl.cc
ClayHanson/B4v21-Launcher-Public-Repo
c812aa7bf2ecb267e02969c85f0c9c2a29be0d28
[ "MIT" ]
null
null
null
//----------------------------------------------------------------------------- // Torque Game Engine // Copyright (C) GarageGames.com, Inc. //----------------------------------------------------------------------------- #include "console/console.h" #include "console/consoleTypes.h" #include "dgl/dgl.h" #include "gui/game/guiProgressCtrl.h" IMPLEMENT_CONOBJECT(GuiProgressCtrl); GuiProgressCtrl::GuiProgressCtrl() { mProgress = 0.0f; mLoadAnim = 0; } const char* GuiProgressCtrl::getScriptValue() { char * ret = Con::getReturnBuffer(64); dSprintf(ret, 64, "%g", mProgress); return ret; } void GuiProgressCtrl::setScriptValue(const char *value) { //set the value if (! value) mProgress = 0.0f; else mProgress = dAtof(value); //validate the value mLoadAnim = (mProgress == -1.0f); mProgress = mClampF(mProgress, 0.f, 1.f); setUpdate(); } void GuiProgressCtrl::onPreRender() { const char * var = getVariable(); if(var) { F32 value = mClampF(dAtof(var), 0.f, 1.f); if(value != mProgress) { mProgress = value; setUpdate(); } } } #define LOAD_ANIM_FULL_LOOP_TIME 4000 #define LOAD_ANIM_BAR_WIDTH (mBounds.extent.x / 4) void GuiProgressCtrl::onRender(Point2I offset, const RectI &updateRect) { RectI ctrlRect(offset, mBounds.extent); //draw the progress if (!mLoadAnim) { S32 width = (S32)((F32)mBounds.extent.x * mProgress); if (width > 0) { RectI progressRect = ctrlRect; progressRect.extent.x = width; dglDrawRectFill(progressRect, mProfile->mFillColor); } } else { S32 time = Sim::getCurrentTime() % LOAD_ANIM_FULL_LOOP_TIME; S32 start = -LOAD_ANIM_BAR_WIDTH + S32(F32((F32)time / (F32)LOAD_ANIM_FULL_LOOP_TIME) * (F32)(mBounds.extent.x + LOAD_ANIM_BAR_WIDTH)); U32 width = LOAD_ANIM_BAR_WIDTH; if (width > 0) { RectI progressRect = ctrlRect; progressRect.point.x += start; progressRect.extent.x = width; dglDrawRectFill(progressRect, mProfile->mFillColor); } } //now draw the border if (mProfile->mBorder) dglDrawRect(ctrlRect, mProfile->mBorderColor); Parent::onRender(offset, updateRect); //render the children renderChildControls(offset, updateRect); }
23.924731
137
0.633708
ClayHanson
c5188f624ffb8abdcbe322163a39d500dc24e299
3,041
inl
C++
SoftRP/TextureUnitImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
SoftRP/TextureUnitImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
SoftRP/TextureUnitImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
#ifndef SOFTRP_TEXTURE_UNIT_IMPL_INL_ #define SOFTRP_TEXTURE_UNIT_IMPL_INL_ #include "TextureUnit.h" #include "LinearSampler.h" #include "MipMapSampler.h" #include <stdexcept> namespace SoftRP { inline void TextureUnit::setTexture(Texture2D<Math::Vector4>* texture) { m_texture = texture; } inline void TextureUnit::setMagnificationSampler(Sampler* magnificationSampler) { m_magnificationSampler = magnificationSampler; updateSwitchOverPoint(); } inline void TextureUnit::setMinificationSampler(Sampler* minificationSampler) { m_minificationSampler = minificationSampler; updateSwitchOverPoint(); } inline void TextureUnit::updateSwitchOverPoint() { /* From OpenGL specs : Finally, there is the choice of c, the minification vs. magnification switch-over point. If the magnification filter is given by LINEAR and the minification filter is given by NEAREST_MIPMAP_NEAREST or NEAREST_MIPMAP_LINEAR, then c = 0.5. This is done to ensure that a minified texture does not appear ``sharper'' than a magnified texture. Otherwise c = 0. */ if (m_magnificationSampler && m_minificationSampler) { LinearSampler* magLinear = dynamic_cast<LinearSampler*>(m_magnificationSampler); if (magLinear) { //NEAREST_MIPMAP_NEAREST MipMapPointSampler* minMipMapNearest = dynamic_cast<MipMapPointSampler*>(m_minificationSampler); if (minMipMapNearest) m_minMagSwitchOverPoint = 0.5f; else { //NEAREST_MIPMAP_LINEAR AdjMipMapPointSampler* minAdjMipMapNearest = dynamic_cast<AdjMipMapPointSampler*>(m_minificationSampler); if (minAdjMipMapNearest) m_minMagSwitchOverPoint = 0.5f; } } } m_minMagSwitchOverPoint = 0.0f; } inline void TextureUnit::setAddressModeU() { throw std::runtime_error{ "Not implemented yet" }; } inline void TextureUnit::setAddressModeV() { throw std::runtime_error{ "Not implemented yet" }; } inline Math::Vector4 TextureUnit::sample(const Math::Vector2& textCoords) const { return m_magnificationSampler->sample(*m_texture, textCoords); } inline Math::Vector4 TextureUnit::sample(const Math::Vector2& textCoords, const Math::Vector2& dtcdx, const Math::Vector2& dtcdy) const { Sampler* sampler{ nullptr }; float LOD = computeLOD(dtcdx, dtcdy); bool magnified = isMagnified(LOD); if (magnified) return m_magnificationSampler->sample(*m_texture, textCoords); else return m_minificationSampler->sample(*m_texture, textCoords, LOD); } inline float TextureUnit::computeLOD(const Math::Vector2& dtcdx, const Math::Vector2& dtcdy) const { const Math::Vector2 textureSize{ static_cast<float>(m_texture->width()), static_cast<float>(m_texture->height()) }; const float squaredLen1 = (textureSize*dtcdx).squaredLength(); const float squaredLen2 = (textureSize*dtcdy).squaredLength(); return std::log2f(std::sqrtf(std::max(squaredLen1, squaredLen2))); } inline bool TextureUnit::isMagnified(float LOD)const { return LOD <= m_minMagSwitchOverPoint + std::numeric_limits<float>::epsilon(); } } #endif
34.556818
138
0.759619
loreStefani
c51e324bdc303e1d8b0cd566ccdf5a3569e45d13
2,909
cpp
C++
inkbox/Source/Tests.cpp
bassicali/inkbox
dad235c55dd3e68d67b7d3d9de5481125da14339
[ "MIT" ]
6
2021-06-24T05:43:28.000Z
2022-02-12T03:08:27.000Z
inkbox/Source/Tests.cpp
bassicali/inkbox
dad235c55dd3e68d67b7d3d9de5481125da14339
[ "MIT" ]
null
null
null
inkbox/Source/Tests.cpp
bassicali/inkbox
dad235c55dd3e68d67b7d3d9de5481125da14339
[ "MIT" ]
2
2021-02-23T07:08:04.000Z
2021-11-29T10:56:29.000Z
#include "Tests.h" #include "Utils.h" #include <glm/mat3x3.hpp> #include <glm/mat4x4.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtx/rotate_vector.hpp> #include <glm/geometric.hpp> using namespace glm; using namespace utils; TestManager& TestManager::Get() { static TestManager mgr; return mgr; } void TestManager::Add(class TestRoutine* test) { testList.push_back(test); } void TestManager::RunTests() { if (testList.size() == 0) { LOG_INFO("No tests to run"); return; } LOG_INFO("Running %d tests", (int)testList.size()); int passed = 0; for (TestRoutine* test : testList) { bool result = test->TestFuncPtr(); LOG_INFO("%-50s %s", test->Name.c_str(), result ? "Pass" : "Fail"); passed += result; } LOG_INFO("Results: %d/%d passed", passed, (int)testList.size()); } TestRoutine::TestRoutine(const char* name, Test_Func func) : Name(name) , TestFuncPtr(func) { TestManager::Get().Add(this); } DEFN_TEST(Line_Intersects_Rectangle) { vec3 lo = vec3(0, 0, -2); vec3 ld = normalize(vec3(0, 0, 0) - lo); vec3 tl = vec3(-0.5, 0.5, 0); vec3 tr = vec3(0.5, 0.5, 0); vec3 bl = vec3(-0.5, -0.5, 0); vec3 br = vec3(0.5, -0.5, 0); vec3 x; bool intersects = LineIntersectsRect(lo, ld, tl, tr, bl, br, x); return intersects == true; } DEFN_TEST(Line_Intersects_Rectangle_Neg) { vec3 lo = vec3(-1, 0, -2); vec3 ld = normalize(vec3(-1, 0, 0) - lo); vec3 tl = vec3(-0.5, 0.5, 0); vec3 tr = vec3(0.5, 0.5, 0); vec3 bl = vec3(-0.5, -0.5, 0); vec3 br = vec3(0.5, -0.5, 0); vec3 x; bool intersects = LineIntersectsRect(lo, ld, tl, tr, bl, br, x); return intersects == false; } DEFN_TEST(Line_Intersects_Box_Shoot_From_Front) { vec3 lo = vec3(-0.25, 0, -2); vec3 ld = normalize(vec3(-0.25, 0, 0) - lo); vec3 ttl = vec3(-0.5, 0.5, 0.5); vec3 ttr = vec3(0.5, 0.5, 0.5); vec3 tbl = vec3(-0.5, 0.5, -0.5); vec3 tbr = vec3(0.5, 0.5, -0.5); vec3 btl = vec3(-0.5, -0.5, 0.5); vec3 btr = vec3(0.5, -0.5, 0.5); vec3 bbl = vec3(-0.5, -0.5, -0.5); vec3 bbr = vec3(0.5, -0.5, -0.5); vec3 i; bool intersects = LineIntersectsBox(lo, ld, ttl, ttr, tbl, tbr, btl, btr, bbl, bbr, i); return intersects == true && i.x == -0.25 && i.y == 0 && i.z == -0.5; } DEFN_TEST(Line_Intersects_Box_Shoot_From_Left) { vec3 lo = vec3(-5, 0.25, 0); vec3 ld = normalize(vec3(-4, 0.25, 0) - lo); vec3 ttl = vec3(-0.5, 0.5, 0.5); vec3 ttr = vec3(0.5, 0.5, 0.5); vec3 tbl = vec3(-0.5, 0.5, -0.5); vec3 tbr = vec3(0.5, 0.5, -0.5); vec3 btl = vec3(-0.5, -0.5, 0.5); vec3 btr = vec3(0.5, -0.5, 0.5); vec3 bbl = vec3(-0.5, -0.5, -0.5); vec3 bbr = vec3(0.5, -0.5, -0.5); vec3 i; bool intersects = LineIntersectsBox(lo, ld, ttl, ttr, tbl, tbr, btl, btr, bbl, bbr, i); return intersects == true && i.x == -0.5 && i.y == 0.25 && i.z == 0; }
23.459677
89
0.580268
bassicali
c520ba6afb849109bebde24ccbfda74f4759f697
3,145
cpp
C++
XRVessels/DeltaGliderXR1/XR1Lib/XR1AreasLEDs.cpp
dbeachy1/XRVessels
8dd2d879886154de2f31fa75393d8a6ac56a2089
[ "MIT" ]
10
2021-08-20T05:49:10.000Z
2022-01-07T13:00:20.000Z
XRVessels/DeltaGliderXR1/XR1Lib/XR1AreasLEDs.cpp
dbeachy1/XRVessels
8dd2d879886154de2f31fa75393d8a6ac56a2089
[ "MIT" ]
null
null
null
XRVessels/DeltaGliderXR1/XR1Lib/XR1AreasLEDs.cpp
dbeachy1/XRVessels
8dd2d879886154de2f31fa75393d8a6ac56a2089
[ "MIT" ]
4
2021-09-11T12:08:01.000Z
2022-02-09T00:16:19.000Z
/** XR Vessel add-ons for OpenOrbiter Space Flight Simulator Copyright (C) 2006-2021 Douglas Beachy This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Email: mailto:doug.beachy@outlook.com Web: https://www.alteaaerospace.com **/ // must be included BEFORE XR1Areas.h #include "DeltaGliderXR1.h" #include "XR1Areas.h" //------------------------------------------------------------------------- // isOn = reference to status variable: true = light on, false = light off LEDArea::LEDArea(InstrumentPanel& parentPanel, const COORD2 panelCoordinates, const int areaID, const bool& isOn) : XR1Area(parentPanel, panelCoordinates, areaID), m_isOn(isOn) { m_color = BRIGHT_GREEN; // init here for efficiency } void LEDArea::Activate() { Area::Activate(); // invoke superclass method oapiRegisterPanelArea(GetAreaID(), GetRectForSize(28, 3), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND); TriggerRedraw(); // render initial setting } bool LEDArea::Redraw2D(const int event, const SURFHANDLE surf) { if (m_isOn) { // fill the entire area oapiColourFill(surf, m_color); } return true; // must always return true so either the background or the fill area is rendered } //---------------------------------------------------------------------------------- // isOn = reference to status variable: true = light on, false = light off DoorMediumLEDArea::DoorMediumLEDArea(InstrumentPanel& parentPanel, const COORD2 panelCoordinates, const int areaID, DoorStatus& doorStatus, const bool redrawAlways) : XR1Area(parentPanel, panelCoordinates, areaID), m_doorStatus(doorStatus), m_redrawAlways(redrawAlways), m_isOn(false) { } void DoorMediumLEDArea::Activate() { Area::Activate(); // invoke superclass method // we redraw the entire texture anyway, so map as PANEL_MAP_NONE oapiRegisterPanelArea(GetAreaID(), GetRectForSize(29, 21), (m_redrawAlways ? PANEL_REDRAW_ALWAYS : PANEL_REDRAW_USER), PANEL_MOUSE_IGNORE, PANEL_MAP_NONE); m_mainSurface = CreateSurface(IDB_GREEN_LED_SMALL); TriggerRedraw(); // render initial setting } bool DoorMediumLEDArea::Redraw2D(const int event, const SURFHANDLE surf) { bool isOn = (m_doorStatus == DoorStatus::DOOR_OPEN); bool retVal = false; // always draw on panel init if ((event == PANEL_REDRAW_INIT) || (isOn != m_isOn)) { int srcX = (isOn ? 29 : 0); DeltaGliderXR1::SafeBlt(surf, m_mainSurface, 0, 0, srcX, 0, 29, 21); m_isOn = isOn; retVal = true; } return retVal; }
34.944444
166
0.687122
dbeachy1
c522a265311c032438ca7895d47e6a3516a16376
1,503
cpp
C++
1139_First_Contant/1139_First_Contant/1139_First_Contant.cpp
Iluvata/PAT-Advanced-Level-Practice
08a02e82eef30c81ed9ef8e4f327f7b2a9535582
[ "MIT" ]
2
2020-10-17T12:26:42.000Z
2021-11-12T08:47:10.000Z
1139_First_Contant/1139_First_Contant/1139_First_Contant.cpp
Iluvata/PAT-Advanced-Level-Practice
08a02e82eef30c81ed9ef8e4f327f7b2a9535582
[ "MIT" ]
1
2020-10-19T11:31:55.000Z
2020-10-19T11:31:55.000Z
1139_First_Contant/1139_First_Contant/1139_First_Contant.cpp
Iluvata/PAT-Advanced-Level-Practice
08a02e82eef30c81ed9ef8e4f327f7b2a9535582
[ "MIT" ]
1
2020-10-18T01:08:34.000Z
2020-10-18T01:08:34.000Z
// 1139_First_Contant.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include "pch.h" #include <iostream> #include <vector> #include <map> #include <string> #include <algorithm> #include <set> using namespace std; struct Contact { int f1, f2; }; bool cmp(Contact &c1, Contact &c2) { if (c1.f1 == c2.f1) { return c1.f2 < c2.f2; } return c1.f1 < c2.f1; } int main() { int n, m; cin >> n >> m; string id1, id2; map<int, map<int, bool>> adj; map<int, vector<int>> homo; for (int i = 0; i < m; ++i) { cin >> id1 >> id2; int negcnt = 0; if (id1[0] == '-') { negcnt++; id1 = id1.substr(1); } if (id2[0] == '-') { negcnt++; id2 = id2.substr(1); } int g1 = stoi(id1); int g2 = stoi(id2); adj[g1][g2] = adj[g2][g1] = true; if (negcnt % 2 == 0) { homo[g1].push_back(g2); homo[g2].push_back(g1); } } int q; cin >> q; int g1, g2; for (int i = 0; i < q; ++i) { cin >> g1 >> g2; if (g1 < 0) { g1 = -g1; } if (g2 < 0) { g2 = -g2; } vector<Contact> contacts; Contact cont; for (int j = 0; j < homo[g1].size(); ++j) { cont.f1 = homo[g1][j]; for (int k = 0; k < homo[g2].size(); ++k) { if (adj[homo[g1][j]][homo[g2][k]] && homo[g2][k] != g1 && homo[g1][j] != g2) { cont.f2 = homo[g2][k]; contacts.push_back(cont); } } } sort(contacts.begin(), contacts.end(), cmp); cout << contacts.size() << endl; for (int j = 0; j < contacts.size(); ++j) { printf("%04d %04d\n", contacts[j].f1, contacts[j].f2); } } }
18.7875
82
0.519627
Iluvata
c523a449ce0a69524ec2148cf31f4339c21c2b94
1,483
cpp
C++
IndieLib/tests/unittests/Image.cpp
DarthMike/indielib-crossplatform
473a589ae050b6d1c274cf58adf08731e63ae870
[ "Zlib" ]
29
2015-03-05T08:11:23.000Z
2020-11-11T08:27:22.000Z
IndieLib/tests/unittests/Image.cpp
PowerOlive/indielib-crossplatform
473a589ae050b6d1c274cf58adf08731e63ae870
[ "Zlib" ]
1
2019-04-03T18:59:01.000Z
2019-04-14T11:46:45.000Z
IndieLib/tests/unittests/Image.cpp
PowerOlive/indielib-crossplatform
473a589ae050b6d1c274cf58adf08731e63ae870
[ "Zlib" ]
9
2015-03-05T08:17:10.000Z
2021-08-09T07:15:37.000Z
/*********************************** The zlib License ************************************ * * Copyright (c) 2013 Indielib-crossplatform Development Team * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. * *****************************************************************************************/ #include "dependencies/unittest++/src/UnitTest++.h" #include "CIndieLib.h" #include "IND_Image.h" struct fixture { fixture() { iLib = CIndieLib::instance(); iLib->init(); testImage = IND_Image::newImage(); } ~fixture() { iLib->end(); } IND_Image* testImage; CIndieLib* iLib; }; TEST_FIXTURE(fixture,clone) { }
30.895833
91
0.62913
DarthMike
c526ded1cca2abdfba58f3b175b460c90cb4b007
2,188
cpp
C++
3030ccom/lab4.cpp
rnegron/university-projects
fb7aa7335176543c4c1c952f3acce714378a02e1
[ "MIT" ]
null
null
null
3030ccom/lab4.cpp
rnegron/university-projects
fb7aa7335176543c4c1c952f3acce714378a02e1
[ "MIT" ]
null
null
null
3030ccom/lab4.cpp
rnegron/university-projects
fb7aa7335176543c4c1c952f3acce714378a02e1
[ "MIT" ]
null
null
null
/* Raul Negron Otero 801-13-xxxx Programa: lab4.cpp Este programa le pide al usuario un numero 1 o 2. Luego le pide un valor en grados. Dependiendo de la seleccion entre 1 y 2, convierte el valor en grados a celsius o farenheit. Utiliza dos funciones separadas para cada conversion. Variables: * celsius = tipo int, contiene el valor de la conversion desde farenheit * farenheit = tipo float, contiene el valor de la conversion desde celsius * choice = tipo int, contiene la seleccion del usuario entre 2 tipos de conversion * user = tipo float, contiene el valor en grados que el usuario quiere convertir */ #include <iostream> using namespace std; int f_to_c(float farenheit) // esta funcion recibe un float como input, devuelve un int { int celsius = (farenheit - 32) * 5/9; // celsius es el valor de farenheit - 32 multiplicado por 1.8 return celsius; } float c_to_f(int celsius) // esta funcion recibe un int como input devuelve un float { float farenheit = (celsius * 9/5) + 32; // farenheit es el valor de celsius multiplicado por 1.8 + 32 return farenheit; } int main() { int choice; // la variable choice contiene el valor numerico de la opcion que el usuario quiere float user; // la variable user contiene el valor numerico de los grados que el usuario entre cout << "Hacia que estandar desea convertir? Presione 1 para convertir a Celsius, 2 para convertir a Farenheit: "; cin >> choice; // se le asigna el valor del input a la variable choice cout << "Entre su valor: "; cin >> user; // se le asigna el valor del input a la variable user if (choice == 1){ // si el usuario escojio convertir desde farenheit a celsius... // llamamos a la funcion f_to_c quien se encarga de convertir el valor y desplegamos el resultado cout << user << " grados Farenheit es " << f_to_c(user) << " grados Celsius."; cout << endl; } else { // si el usuario escojio convertir desde celsius a farenheit... // llamamos a la funcion c_to_f quien se encarga de convertir el valor y desplegamos el resultado cout << user << " grados Celsius es " << c_to_f(user) << " grados Farenheit."; cout << endl; } return 0; // el programa acabo de correr, devolvemos 0 }
45.583333
115
0.728062
rnegron
c52f280838fae108720b482e2df75af63c0f4467
1,091
cpp
C++
src/test/storage/value_column_test.cpp
lawben/DYOD_WS1718_Sprint1
3b70ac6603fe108cfe76cc81fed763c5d3c7cd84
[ "MIT" ]
null
null
null
src/test/storage/value_column_test.cpp
lawben/DYOD_WS1718_Sprint1
3b70ac6603fe108cfe76cc81fed763c5d3c7cd84
[ "MIT" ]
null
null
null
src/test/storage/value_column_test.cpp
lawben/DYOD_WS1718_Sprint1
3b70ac6603fe108cfe76cc81fed763c5d3c7cd84
[ "MIT" ]
null
null
null
#include <limits> #include <string> #include <vector> #include "../base_test.hpp" #include "gtest/gtest.h" #include "../lib/storage/value_column.hpp" namespace opossum { class StorageValueColumnTest : public BaseTest { protected: ValueColumn<int> vc_int; ValueColumn<std::string> vc_str; ValueColumn<double> vc_double; }; TEST_F(StorageValueColumnTest, GetSize) { EXPECT_EQ(vc_int.size(), 0u); EXPECT_EQ(vc_str.size(), 0u); EXPECT_EQ(vc_double.size(), 0u); } TEST_F(StorageValueColumnTest, AddValueOfSameType) { vc_int.append(3); EXPECT_EQ(vc_int.size(), 1u); vc_str.append("Hello"); EXPECT_EQ(vc_str.size(), 1u); vc_double.append(3.14); EXPECT_EQ(vc_double.size(), 1u); } TEST_F(StorageValueColumnTest, AddValueOfDifferentType) { vc_int.append(3.14); EXPECT_EQ(vc_int.size(), 1u); EXPECT_THROW(vc_int.append("Hi"), std::exception); vc_str.append(3); vc_str.append(4.44); EXPECT_EQ(vc_str.size(), 2u); vc_double.append(4); EXPECT_EQ(vc_double.size(), 1u); EXPECT_THROW(vc_double.append("Hi"), std::exception); } } // namespace opossum
21.392157
57
0.713107
lawben
c52fb59b42f696a683791f2258ccabdfbf9af07a
1,534
hh
C++
Sources/AGEngine/Render/Pipelining/Pipelines/CustomPipeline/DeferredShading.hh
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
47
2015-03-29T09:44:25.000Z
2020-11-30T10:05:56.000Z
Sources/AGEngine/Render/Pipelining/Pipelines/CustomPipeline/DeferredShading.hh
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
313
2015-01-01T18:16:30.000Z
2015-11-30T07:54:07.000Z
Sources/AGEngine/Render/Pipelining/Pipelines/CustomPipeline/DeferredShading.hh
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
9
2015-06-07T13:21:54.000Z
2020-08-25T09:50:07.000Z
#pragma once #include <Utils/Debug.hpp> #include <Utils/OpenGL.hh> #include <Render/Pipelining/Pipelines/ARenderingPipeline.hh> #include <glm/glm.hpp> #include <Render/Textures/Texture2D.hh> #include <memory> namespace AGE { class DeferredMerging; class DeferredSkyBox; class DeferredShading : public ARenderingPipeline { public: DeferredShading(glm::uvec2 const &screen_size, std::shared_ptr<PaintingManager> const &painter_manager); DeferredShading(DeferredShading &&move); virtual ~DeferredShading(); DeferredShading(DeferredShading const &) = delete; DeferredShading &operator=(DeferredShading const &) = delete; virtual void renderBegin(const DRBCameraDrawableList &infos); virtual void renderEnd(const DRBCameraDrawableList &infos); public: void setAmbient(glm::vec3 const &ambient); void setSkyboxLighting(glm::vec3 const &lighting); virtual bool isDebug() const; private: std::shared_ptr<Texture2D> _depthStencil; std::shared_ptr<Texture2D> _diffuse; std::shared_ptr<Texture2D> _normal; std::shared_ptr<Texture2D> _specular; std::shared_ptr<Texture2D> _lightAccumulation; std::shared_ptr<Texture2D> _shinyAccumulation; std::shared_ptr<Texture2D> _downSampled1; std::shared_ptr<Texture2D> _downSampled2; std::shared_ptr<Texture2D> _downSampled3; std::shared_ptr<Texture2D> _blurTmp1; std::shared_ptr<Texture2D> _blurTmp2; std::shared_ptr<Texture2D> _blurTmp3; std::shared_ptr<DeferredMerging> _deferredMerging; std::shared_ptr<DeferredSkyBox> _deferredSkybox; }; }
31.306122
106
0.782269
Another-Game-Engine
c5329fbe6573c0b574be5cb2bb91079955035caf
591
hpp
C++
rmvmath/matrix/matrix4x2/func/TMatrix4x2_func.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
rmvmath/matrix/matrix4x2/func/TMatrix4x2_func.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
rmvmath/matrix/matrix4x2/func/TMatrix4x2_func.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
// // Created by Vitali Kurlovich on 1/7/16. // #ifndef RMVECTORMATH_TMATRIX4X2_FUNC_HPP #define RMVECTORMATH_TMATRIX4X2_FUNC_HPP #include "../TMatrix4x2_def.hpp" #include "../../matrix2x4/TMatrix2x4_def.hpp" namespace rmmath { namespace matrix { template<typename T> inline TMatrix2x4 <T> transpose(const TMatrix4x2 <T> &a) { TMatrix2x4<T> result = { a.m00, a.m10, a.m20, a.m30, a.m01, a.m11, a.m21, a.m31 }; return result; } } } #endif //RMVECTORMATH_TMATRIX4X2_FUNC_HPP
19.064516
66
0.593909
vitali-kurlovich
c536d8a37743db581ee41898f91d77e0e7a2309e
524
hpp
C++
src/arithmetic/extractor/vector.hpp
r3c/tesca
e5ea2f4f2c4a35c47f38468a89f2f05038fb18d8
[ "MIT" ]
2
2016-06-01T14:44:21.000Z
2018-05-04T11:55:02.000Z
src/arithmetic/extractor/vector.hpp
r3c/tesca
e5ea2f4f2c4a35c47f38468a89f2f05038fb18d8
[ "MIT" ]
1
2021-03-21T11:36:18.000Z
2021-03-21T14:49:17.000Z
src/arithmetic/extractor/vector.hpp
r3c/tesca
e5ea2f4f2c4a35c47f38468a89f2f05038fb18d8
[ "MIT" ]
null
null
null
#ifndef __TESCA_ARITHMETIC_EXTRACTOR_VECTOR_HPP #define __TESCA_ARITHMETIC_EXTRACTOR_VECTOR_HPP #include <vector> #include "../../../lib/glay/src/glay.hpp" #include "../extractor.hpp" namespace Tesca { namespace Arithmetic { class VectorExtractor : public Extractor { public: VectorExtractor (const std::vector<Extractor const*>&); virtual ~VectorExtractor (); protected: virtual void recurse (RecurseCallback) const; Extractor const** extractors; Glay::Int32u length; }; } } #endif
18.068966
59
0.719466
r3c
c5380cd0add5ca294fa44caca233b6948593b912
1,266
hpp
C++
unit_tests/inputRe_tests.hpp
Sdc97/Rshell
37c0dd264799d199e6c0dc1f13ae1e25f9368620
[ "MIT" ]
1
2020-06-28T20:40:57.000Z
2020-06-28T20:40:57.000Z
unit_tests/inputRe_tests.hpp
Sdc97/Rshell
37c0dd264799d199e6c0dc1f13ae1e25f9368620
[ "MIT" ]
null
null
null
unit_tests/inputRe_tests.hpp
Sdc97/Rshell
37c0dd264799d199e6c0dc1f13ae1e25f9368620
[ "MIT" ]
1
2021-04-02T21:47:58.000Z
2021-04-02T21:47:58.000Z
#ifndef INPUTRE_TESTS #define INPUTRE_TESTS #include <fstream> #include "gtest/gtest.h" #include "../header/InputRe_op.hpp" #include "../header/Cmnd.hpp" TEST(InputRedirectionTestSet,inputCapital) { ofstream output; output.open("out.txt"); output <<"Professor Brian Crites" <<endl; output.close(); Cmnd* l =new Cmnd(4); Cmnd* r =new Cmnd(2); (*l)[0] =(char*)"tr"; (*l)[1] =(char*)"a-z"; (*l)[2] =(char*)"A-Z"; (*l)[3] =NULL; (*r)[0] =(char*)"out.txt"; (*r)[1] =NULL; Executable* input =new InputRe_op(); input->set_left(l); input->set_right(r); EXPECT_EQ(input->run_command(),true); } TEST(InputRedirectionTestSet,cat) { Cmnd* l =new Cmnd(2); Cmnd* r =new Cmnd(2); (*l)[0] =(char*)"cat"; (*l)[1] =NULL; (*r)[0] =(char*)"out.txt"; (*r)[1] =NULL; Executable* input =new InputRe_op(); input->set_left(l); input->set_right(r); EXPECT_EQ(input->run_command(),true); } TEST(InputRedirectionTestSet,rshell) { system("echo echo hello > out.txt; echo exit >> out.txt"); Cmnd* l =new Cmnd(2); Cmnd* r =new Cmnd(2); (*l)[0] =(char*)"./rshell"; (*l)[1] =NULL; (*r)[0] =(char*)"out.txt"; (*r)[1] =NULL; Executable* input =new InputRe_op(); input->set_left(l); input->set_right(r); EXPECT_EQ(input->run_command(),true); } #endif
19.476923
59
0.620853
Sdc97
c53ae3ada5a4c3bc10654356d20291d3302f6540
28,282
inl
C++
include/visionaray/math/simd/detail/builtin/float16.inl
tjachmann/visionaray
5f181268c8da28c7d9b397300cc9759cec2bf7b3
[ "MIT" ]
null
null
null
include/visionaray/math/simd/detail/builtin/float16.inl
tjachmann/visionaray
5f181268c8da28c7d9b397300cc9759cec2bf7b3
[ "MIT" ]
null
null
null
include/visionaray/math/simd/detail/builtin/float16.inl
tjachmann/visionaray
5f181268c8da28c7d9b397300cc9759cec2bf7b3
[ "MIT" ]
null
null
null
// This file is distributed under the MIT license. // See the LICENSE file for details. #include "../../../detail/math.h" namespace MATH_NAMESPACE { namespace simd { //------------------------------------------------------------------------------------------------- // float16 members // MATH_FUNC VSNRAY_FORCE_INLINE float16::basic_float( float x1, float x2, float x3, float x4, float x5, float x6, float x7, float x8, float x9, float x10, float x11, float x12, float x13, float x14, float x15, float x16 ) : value{ x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16 } { } MATH_FUNC VSNRAY_FORCE_INLINE float16::basic_float(float const v[16]) : value{ v[ 0], v[ 1], v[ 2], v[ 3], v[ 4], v[ 5], v[ 6], v[ 7], v[ 8], v[ 9], v[10], v[11], v[12], v[13], v[14], v[15] } { } MATH_FUNC VSNRAY_FORCE_INLINE float16::basic_float(float s) : value{s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s} { } //------------------------------------------------------------------------------------------------- // Bitwise cast // MATH_FUNC VSNRAY_FORCE_INLINE int16 reinterpret_as_int(float16 const& a) { return *reinterpret_cast<int16 const*>(&a); } //------------------------------------------------------------------------------------------------- // Static cast // MATH_FUNC VSNRAY_FORCE_INLINE int16 convert_to_int(float16 const& a) { return int16( static_cast<int>(a.value[ 0]), static_cast<int>(a.value[ 1]), static_cast<int>(a.value[ 2]), static_cast<int>(a.value[ 3]), static_cast<int>(a.value[ 4]), static_cast<int>(a.value[ 5]), static_cast<int>(a.value[ 6]), static_cast<int>(a.value[ 7]), static_cast<int>(a.value[ 8]), static_cast<int>(a.value[ 9]), static_cast<int>(a.value[10]), static_cast<int>(a.value[11]), static_cast<int>(a.value[12]), static_cast<int>(a.value[13]), static_cast<int>(a.value[14]), static_cast<int>(a.value[15]) ); } //------------------------------------------------------------------------------------------------- // select intrinsic // MATH_FUNC VSNRAY_FORCE_INLINE float16 select(mask16 const& m, float16 const& a, float16 const& b) { return float16( m.value[ 0] ? a.value[ 0] : b.value[ 0], m.value[ 1] ? a.value[ 1] : b.value[ 1], m.value[ 2] ? a.value[ 2] : b.value[ 2], m.value[ 3] ? a.value[ 3] : b.value[ 3], m.value[ 4] ? a.value[ 4] : b.value[ 4], m.value[ 5] ? a.value[ 5] : b.value[ 5], m.value[ 6] ? a.value[ 6] : b.value[ 6], m.value[ 7] ? a.value[ 7] : b.value[ 7], m.value[ 8] ? a.value[ 8] : b.value[ 8], m.value[ 9] ? a.value[ 9] : b.value[ 9], m.value[10] ? a.value[10] : b.value[10], m.value[11] ? a.value[11] : b.value[11], m.value[12] ? a.value[12] : b.value[12], m.value[13] ? a.value[13] : b.value[13], m.value[14] ? a.value[14] : b.value[14], m.value[15] ? a.value[15] : b.value[15] ); } //------------------------------------------------------------------------------------------------- // Load / store / get // //MATH_FUNC //VSNRAY_FORCE_INLINE float16 load(float const src[16]) //{ // return float16( // src[ 0], src[ 1], src[ 2], src[ 3], // src[ 4], src[ 5], src[ 6], src[ 7], // src[ 8], src[ 9], src[10], src[11], // src[12], src[13], src[14], src[15] // ); //} MATH_FUNC VSNRAY_FORCE_INLINE void store(float dst[16], float16 const& v) { dst[ 0] = v.value[ 0]; dst[ 1] = v.value[ 1]; dst[ 2] = v.value[ 2]; dst[ 3] = v.value[ 3]; dst[ 4] = v.value[ 4]; dst[ 5] = v.value[ 5]; dst[ 6] = v.value[ 6]; dst[ 7] = v.value[ 7]; dst[ 8] = v.value[ 8]; dst[ 9] = v.value[ 9]; dst[10] = v.value[10]; dst[11] = v.value[11]; dst[12] = v.value[12]; dst[13] = v.value[13]; dst[14] = v.value[14]; dst[15] = v.value[15]; } template <size_t I> MATH_FUNC VSNRAY_FORCE_INLINE float& get(float16& v) { static_assert(I < 16, "Index out of range for SIMD vector access"); return v.value[I]; } template <size_t I> MATH_FUNC VSNRAY_FORCE_INLINE float const& get(float16 const& v) { static_assert(I < 16, "Index out of range for SIMD vector access"); return v.value[I]; } MATH_FUNC VSNRAY_FORCE_INLINE float16 move_lo(float16 const& u, float16 const& v) { return float16( u.value[0], u.value[1], u.value[2], u.value[3], u.value[4], u.value[5], u.value[6], u.value[7], v.value[0], v.value[1], v.value[2], v.value[3], v.value[4], v.value[5], v.value[6], v.value[7] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 move_hi(float16 const& u, float16 const& v) { return float16( v.value[ 8], v.value[ 9], v.value[10], v.value[11], v.value[12], v.value[13], v.value[14], v.value[15], u.value[ 8], u.value[ 9], u.value[10], u.value[11], u.value[12], u.value[13], u.value[14], u.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 interleave_lo(float16 const& u, float16 const& v) { return float16( u.value[ 0], v.value[ 0], u.value[ 1], v.value[ 1], u.value[ 2], v.value[ 2], u.value[ 3], v.value[ 3], u.value[ 4], v.value[ 4], u.value[ 5], v.value[ 5], u.value[ 6], v.value[ 6], u.value[ 7], v.value[ 7] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 interleave_hi(float16 const& u, float16 const& v) { return float16( u.value[ 8], v.value[ 8], u.value[ 9], v.value[ 9], u.value[10], v.value[10], u.value[11], v.value[11], u.value[12], v.value[12], u.value[13], v.value[13], u.value[14], v.value[14], u.value[15], v.value[15] ); } //------------------------------------------------------------------------------------------------- // Basic arithmetics // MATH_FUNC VSNRAY_FORCE_INLINE float16 operator+(float16 const& v) { return float16( +v.value[ 0], +v.value[ 1], +v.value[ 2], +v.value[ 3], +v.value[ 4], +v.value[ 5], +v.value[ 6], +v.value[ 7], +v.value[ 8], +v.value[ 9], +v.value[10], +v.value[11], +v.value[12], +v.value[13], +v.value[14], +v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator-(float16 const& v) { return float16( -v.value[ 0], -v.value[ 1], -v.value[ 2], -v.value[ 3], -v.value[ 4], -v.value[ 5], -v.value[ 6], -v.value[ 7], -v.value[ 8], -v.value[ 9], -v.value[10], -v.value[11], -v.value[12], -v.value[13], -v.value[14], -v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator+(float16 const& u, float16 const& v) { return float16( u.value[ 0] + v.value[ 0], u.value[ 1] + v.value[ 1], u.value[ 2] + v.value[ 2], u.value[ 3] + v.value[ 3], u.value[ 4] + v.value[ 4], u.value[ 5] + v.value[ 5], u.value[ 6] + v.value[ 6], u.value[ 7] + v.value[ 7], u.value[ 8] + v.value[ 8], u.value[ 9] + v.value[ 9], u.value[10] + v.value[10], u.value[11] + v.value[11], u.value[12] + v.value[12], u.value[13] + v.value[13], u.value[14] + v.value[14], u.value[15] + v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator-(float16 const& u, float16 const& v) { return float16( u.value[ 0] - v.value[ 0], u.value[ 1] - v.value[ 1], u.value[ 2] - v.value[ 2], u.value[ 3] - v.value[ 3], u.value[ 4] - v.value[ 4], u.value[ 5] - v.value[ 5], u.value[ 6] - v.value[ 6], u.value[ 7] - v.value[ 7], u.value[ 8] - v.value[ 8], u.value[ 9] - v.value[ 9], u.value[10] - v.value[10], u.value[11] - v.value[11], u.value[12] - v.value[12], u.value[13] - v.value[13], u.value[14] - v.value[14], u.value[15] - v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator*(float16 const& u, float16 const& v) { return float16( u.value[ 0] * v.value[ 0], u.value[ 1] * v.value[ 1], u.value[ 2] * v.value[ 2], u.value[ 3] * v.value[ 3], u.value[ 4] * v.value[ 4], u.value[ 5] * v.value[ 5], u.value[ 6] * v.value[ 6], u.value[ 7] * v.value[ 7], u.value[ 8] * v.value[ 8], u.value[ 9] * v.value[ 9], u.value[10] * v.value[10], u.value[11] * v.value[11], u.value[12] * v.value[12], u.value[13] * v.value[13], u.value[14] * v.value[14], u.value[15] * v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator/(float16 const& u, float16 const& v) { return float16( u.value[ 0] / v.value[ 0], u.value[ 1] / v.value[ 1], u.value[ 2] / v.value[ 2], u.value[ 3] / v.value[ 3], u.value[ 4] / v.value[ 4], u.value[ 5] / v.value[ 5], u.value[ 6] / v.value[ 6], u.value[ 7] / v.value[ 7], u.value[ 8] / v.value[ 8], u.value[ 9] / v.value[ 9], u.value[10] / v.value[10], u.value[11] / v.value[11], u.value[12] / v.value[12], u.value[13] / v.value[13], u.value[14] / v.value[14], u.value[15] / v.value[15] ); } //------------------------------------------------------------------------------------------------- // Bitwise operations // MATH_FUNC VSNRAY_FORCE_INLINE float16 operator&(float16 const& u, float16 const& v) { int const* ui = reinterpret_cast<int const*>(u.value); int const* vi = reinterpret_cast<int const*>(v.value); int ri[16] = { ui[ 0] & vi[ 0], ui[ 1] & vi[ 1], ui[ 2] & vi[ 2], ui[ 3] & vi[ 3], ui[ 4] & vi[ 4], ui[ 5] & vi[ 5], ui[ 6] & vi[ 6], ui[ 7] & vi[ 7], ui[ 8] & vi[ 8], ui[ 9] & vi[ 9], ui[10] & vi[10], ui[11] & vi[11], ui[12] & vi[12], ui[13] & vi[13], ui[14] & vi[14], ui[15] & vi[15] }; return float16(reinterpret_cast<float*>(ri)); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator|(float16 const& u, float16 const& v) { int const* ui = reinterpret_cast<int const*>(u.value); int const* vi = reinterpret_cast<int const*>(v.value); int ri[16] = { ui[ 0] | vi[ 0], ui[ 1] | vi[ 1], ui[ 2] | vi[ 2], ui[ 3] | vi[ 3], ui[ 4] | vi[ 4], ui[ 5] | vi[ 5], ui[ 6] | vi[ 6], ui[ 7] | vi[ 7], ui[ 8] | vi[ 8], ui[ 9] | vi[ 9], ui[10] | vi[10], ui[11] | vi[11], ui[12] | vi[12], ui[13] | vi[13], ui[14] | vi[14], ui[15] | vi[15] }; return float16(reinterpret_cast<float*>(ri)); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator^(float16 const& u, float16 const& v) { int const* ui = reinterpret_cast<int const*>(u.value); int const* vi = reinterpret_cast<int const*>(v.value); int ri[16] = { ui[ 0] ^ vi[ 0], ui[ 1] ^ vi[ 1], ui[ 2] ^ vi[ 2], ui[ 3] ^ vi[ 3], ui[ 4] ^ vi[ 4], ui[ 5] ^ vi[ 5], ui[ 6] ^ vi[ 6], ui[ 7] ^ vi[ 7], ui[ 8] ^ vi[ 8], ui[ 9] ^ vi[ 9], ui[10] ^ vi[10], ui[11] ^ vi[11], ui[12] ^ vi[12], ui[13] ^ vi[13], ui[14] ^ vi[14], ui[15] ^ vi[15] }; return float16(reinterpret_cast<float*>(ri)); } //------------------------------------------------------------------------------------------------- // Logical operations // MATH_FUNC VSNRAY_FORCE_INLINE float16 operator&&(float16 const& u, float16 const& v) { return float16( u.value[ 0] && v.value[ 0], u.value[ 1] && v.value[ 1], u.value[ 2] && v.value[ 2], u.value[ 3] && v.value[ 3], u.value[ 4] && v.value[ 4], u.value[ 5] && v.value[ 5], u.value[ 6] && v.value[ 6], u.value[ 7] && v.value[ 7], u.value[ 8] && v.value[ 8], u.value[ 9] && v.value[ 9], u.value[10] && v.value[10], u.value[11] && v.value[11], u.value[12] && v.value[12], u.value[13] && v.value[13], u.value[14] && v.value[14], u.value[15] && v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 operator||(float16 const& u, float16 const& v) { return float16( u.value[ 0] || v.value[ 0], u.value[ 1] || v.value[ 1], u.value[ 2] || v.value[ 2], u.value[ 3] || v.value[ 3], u.value[ 4] || v.value[ 4], u.value[ 5] || v.value[ 5], u.value[ 6] || v.value[ 6], u.value[ 7] || v.value[ 7], u.value[ 8] || v.value[ 8], u.value[ 9] || v.value[ 9], u.value[10] || v.value[10], u.value[11] || v.value[11], u.value[12] || v.value[12], u.value[13] || v.value[13], u.value[14] || v.value[14], u.value[15] || v.value[15] ); } //------------------------------------------------------------------------------------------------- // Comparisons // MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator<(float16 const& u, float16 const& v) { return mask16( u.value[ 0] < v.value[ 0], u.value[ 1] < v.value[ 1], u.value[ 2] < v.value[ 2], u.value[ 3] < v.value[ 3], u.value[ 4] < v.value[ 4], u.value[ 5] < v.value[ 5], u.value[ 6] < v.value[ 6], u.value[ 7] < v.value[ 7], u.value[ 8] < v.value[ 8], u.value[ 9] < v.value[ 9], u.value[10] < v.value[10], u.value[11] < v.value[11], u.value[12] < v.value[12], u.value[13] < v.value[13], u.value[14] < v.value[14], u.value[15] < v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator>(float16 const& u, float16 const& v) { return mask16( u.value[ 0] > v.value[ 0], u.value[ 1] > v.value[ 1], u.value[ 2] > v.value[ 2], u.value[ 3] > v.value[ 3], u.value[ 4] > v.value[ 4], u.value[ 5] > v.value[ 5], u.value[ 6] > v.value[ 6], u.value[ 7] > v.value[ 7], u.value[ 8] > v.value[ 8], u.value[ 9] > v.value[ 9], u.value[10] > v.value[10], u.value[11] > v.value[11], u.value[12] > v.value[12], u.value[13] > v.value[13], u.value[14] > v.value[14], u.value[15] > v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator<=(float16 const& u, float16 const& v) { return mask16( u.value[ 0] <= v.value[ 0], u.value[ 1] <= v.value[ 1], u.value[ 2] <= v.value[ 2], u.value[ 3] <= v.value[ 3], u.value[ 4] <= v.value[ 4], u.value[ 5] <= v.value[ 5], u.value[ 6] <= v.value[ 6], u.value[ 7] <= v.value[ 7], u.value[ 8] <= v.value[ 8], u.value[ 9] <= v.value[ 9], u.value[10] <= v.value[10], u.value[11] <= v.value[11], u.value[12] <= v.value[12], u.value[13] <= v.value[13], u.value[14] <= v.value[14], u.value[15] <= v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator>=(float16 const& u, float16 const& v) { return mask16( u.value[ 0] >= v.value[ 0], u.value[ 1] >= v.value[ 1], u.value[ 2] >= v.value[ 2], u.value[ 3] >= v.value[ 3], u.value[ 4] >= v.value[ 4], u.value[ 5] >= v.value[ 5], u.value[ 6] >= v.value[ 6], u.value[ 7] >= v.value[ 7], u.value[ 8] >= v.value[ 8], u.value[ 9] >= v.value[ 9], u.value[10] >= v.value[10], u.value[11] >= v.value[11], u.value[12] >= v.value[12], u.value[13] >= v.value[13], u.value[14] >= v.value[14], u.value[15] >= v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator==(float16 const& u, float16 const& v) { return mask16( u.value[ 0] == v.value[ 0], u.value[ 1] == v.value[ 1], u.value[ 2] == v.value[ 2], u.value[ 3] == v.value[ 3], u.value[ 4] == v.value[ 4], u.value[ 5] == v.value[ 5], u.value[ 6] == v.value[ 6], u.value[ 7] == v.value[ 7], u.value[ 8] == v.value[ 8], u.value[ 9] == v.value[ 9], u.value[10] == v.value[10], u.value[11] == v.value[11], u.value[12] == v.value[12], u.value[13] == v.value[13], u.value[14] == v.value[14], u.value[15] == v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 operator!=(float16 const& u, float16 const& v) { return mask16( u.value[ 0] != v.value[ 0], u.value[ 1] != v.value[ 1], u.value[ 2] != v.value[ 2], u.value[ 3] != v.value[ 3], u.value[ 4] != v.value[ 4], u.value[ 5] != v.value[ 5], u.value[ 6] != v.value[ 6], u.value[ 7] != v.value[ 7], u.value[ 8] != v.value[ 8], u.value[ 9] != v.value[ 9], u.value[10] != v.value[10], u.value[11] != v.value[11], u.value[12] != v.value[12], u.value[13] != v.value[13], u.value[14] != v.value[14], u.value[15] != v.value[15] ); } //------------------------------------------------------------------------------------------------- // Math functions // MATH_FUNC VSNRAY_FORCE_INLINE float16 min(float16 const& u, float16 const& v) { return float16( u.value[ 0] < v.value[ 0] ? u.value[ 0] : v.value[ 0], u.value[ 1] < v.value[ 1] ? u.value[ 1] : v.value[ 1], u.value[ 2] < v.value[ 2] ? u.value[ 2] : v.value[ 2], u.value[ 3] < v.value[ 3] ? u.value[ 3] : v.value[ 3], u.value[ 4] < v.value[ 4] ? u.value[ 4] : v.value[ 4], u.value[ 5] < v.value[ 5] ? u.value[ 5] : v.value[ 5], u.value[ 6] < v.value[ 6] ? u.value[ 6] : v.value[ 6], u.value[ 7] < v.value[ 7] ? u.value[ 7] : v.value[ 7], u.value[ 8] < v.value[ 8] ? u.value[ 8] : v.value[ 8], u.value[ 9] < v.value[ 9] ? u.value[ 9] : v.value[ 9], u.value[10] < v.value[10] ? u.value[10] : v.value[10], u.value[11] < v.value[11] ? u.value[11] : v.value[11], u.value[12] < v.value[12] ? u.value[12] : v.value[12], u.value[13] < v.value[13] ? u.value[13] : v.value[13], u.value[14] < v.value[14] ? u.value[14] : v.value[14], u.value[15] < v.value[15] ? u.value[15] : v.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 max(float16 const& u, float16 const& v) { return float16( u.value[ 0] < v.value[ 0] ? v.value[ 0] : u.value[ 0], u.value[ 1] < v.value[ 1] ? v.value[ 1] : u.value[ 1], u.value[ 2] < v.value[ 2] ? v.value[ 2] : u.value[ 2], u.value[ 3] < v.value[ 3] ? v.value[ 3] : u.value[ 3], u.value[ 4] < v.value[ 4] ? v.value[ 4] : u.value[ 4], u.value[ 5] < v.value[ 5] ? v.value[ 5] : u.value[ 5], u.value[ 6] < v.value[ 6] ? v.value[ 6] : u.value[ 6], u.value[ 7] < v.value[ 7] ? v.value[ 7] : u.value[ 7], u.value[ 8] < v.value[ 8] ? v.value[ 8] : u.value[ 8], u.value[ 9] < v.value[ 9] ? v.value[ 9] : u.value[ 9], u.value[10] < v.value[10] ? v.value[10] : u.value[10], u.value[11] < v.value[11] ? v.value[11] : u.value[11], u.value[12] < v.value[12] ? v.value[12] : u.value[12], u.value[13] < v.value[13] ? v.value[13] : u.value[13], u.value[14] < v.value[14] ? v.value[14] : u.value[14], u.value[15] < v.value[15] ? v.value[15] : u.value[15] ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 saturate(float16 const& u) { return max(float16(0.0f), min(u, float16(1.0f))); } MATH_FUNC VSNRAY_FORCE_INLINE float16 abs(float16 const& u) { return float16( fabsf(u.value[ 0]), fabsf(u.value[ 1]), fabsf(u.value[ 2]), fabsf(u.value[ 3]), fabsf(u.value[ 4]), fabsf(u.value[ 5]), fabsf(u.value[ 6]), fabsf(u.value[ 7]), fabsf(u.value[ 8]), fabsf(u.value[ 9]), fabsf(u.value[10]), fabsf(u.value[11]), fabsf(u.value[12]), fabsf(u.value[13]), fabsf(u.value[14]), fabsf(u.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 round(float16 const& v) { return float16( roundf(v.value[ 0]), roundf(v.value[ 1]), roundf(v.value[ 2]), roundf(v.value[ 3]), roundf(v.value[ 4]), roundf(v.value[ 5]), roundf(v.value[ 6]), roundf(v.value[ 7]), roundf(v.value[ 8]), roundf(v.value[ 9]), roundf(v.value[10]), roundf(v.value[11]), roundf(v.value[12]), roundf(v.value[13]), roundf(v.value[14]), roundf(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 ceil(float16 const& v) { return float16( ceilf(v.value[ 0]), ceilf(v.value[ 1]), ceilf(v.value[ 2]), ceilf(v.value[ 3]), ceilf(v.value[ 4]), ceilf(v.value[ 5]), ceilf(v.value[ 6]), ceilf(v.value[ 7]), ceilf(v.value[ 8]), ceilf(v.value[ 9]), ceilf(v.value[10]), ceilf(v.value[11]), ceilf(v.value[12]), ceilf(v.value[13]), ceilf(v.value[14]), ceilf(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 floor(float16 const& v) { return float16( floorf(v.value[ 0]), floorf(v.value[ 1]), floorf(v.value[ 2]), floorf(v.value[ 3]), floorf(v.value[ 4]), floorf(v.value[ 5]), floorf(v.value[ 6]), floorf(v.value[ 7]), floorf(v.value[ 8]), floorf(v.value[ 9]), floorf(v.value[10]), floorf(v.value[11]), floorf(v.value[12]), floorf(v.value[13]), floorf(v.value[14]), floorf(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE float16 sqrt(float16 const& v) { return float16( sqrtf(v.value[ 0]), sqrtf(v.value[ 1]), sqrtf(v.value[ 2]), sqrtf(v.value[ 3]), sqrtf(v.value[ 4]), sqrtf(v.value[ 5]), sqrtf(v.value[ 6]), sqrtf(v.value[ 7]), sqrtf(v.value[ 8]), sqrtf(v.value[ 9]), sqrtf(v.value[10]), sqrtf(v.value[11]), sqrtf(v.value[12]), sqrtf(v.value[13]), sqrtf(v.value[14]), sqrtf(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 isinf(float16 const& v) { return mask16( MATH_NAMESPACE::isinf(v.value[ 0]), MATH_NAMESPACE::isinf(v.value[ 1]), MATH_NAMESPACE::isinf(v.value[ 2]), MATH_NAMESPACE::isinf(v.value[ 3]), MATH_NAMESPACE::isinf(v.value[ 4]), MATH_NAMESPACE::isinf(v.value[ 5]), MATH_NAMESPACE::isinf(v.value[ 6]), MATH_NAMESPACE::isinf(v.value[ 7]), MATH_NAMESPACE::isinf(v.value[ 8]), MATH_NAMESPACE::isinf(v.value[ 9]), MATH_NAMESPACE::isinf(v.value[10]), MATH_NAMESPACE::isinf(v.value[11]), MATH_NAMESPACE::isinf(v.value[12]), MATH_NAMESPACE::isinf(v.value[13]), MATH_NAMESPACE::isinf(v.value[14]), MATH_NAMESPACE::isinf(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 isnan(float16 const& v) { return mask16( MATH_NAMESPACE::isnan(v.value[ 0]), MATH_NAMESPACE::isnan(v.value[ 1]), MATH_NAMESPACE::isnan(v.value[ 2]), MATH_NAMESPACE::isnan(v.value[ 3]), MATH_NAMESPACE::isnan(v.value[ 4]), MATH_NAMESPACE::isnan(v.value[ 5]), MATH_NAMESPACE::isnan(v.value[ 6]), MATH_NAMESPACE::isnan(v.value[ 7]), MATH_NAMESPACE::isnan(v.value[ 8]), MATH_NAMESPACE::isnan(v.value[ 9]), MATH_NAMESPACE::isnan(v.value[10]), MATH_NAMESPACE::isnan(v.value[11]), MATH_NAMESPACE::isnan(v.value[12]), MATH_NAMESPACE::isnan(v.value[13]), MATH_NAMESPACE::isnan(v.value[14]), MATH_NAMESPACE::isnan(v.value[15]) ); } MATH_FUNC VSNRAY_FORCE_INLINE mask16 isfinite(float16 const& v) { return mask16( MATH_NAMESPACE::isfinite(v.value[ 0]), MATH_NAMESPACE::isfinite(v.value[ 1]), MATH_NAMESPACE::isfinite(v.value[ 2]), MATH_NAMESPACE::isfinite(v.value[ 3]), MATH_NAMESPACE::isfinite(v.value[ 4]), MATH_NAMESPACE::isfinite(v.value[ 5]), MATH_NAMESPACE::isfinite(v.value[ 6]), MATH_NAMESPACE::isfinite(v.value[ 7]), MATH_NAMESPACE::isfinite(v.value[ 8]), MATH_NAMESPACE::isfinite(v.value[ 9]), MATH_NAMESPACE::isfinite(v.value[10]), MATH_NAMESPACE::isfinite(v.value[11]), MATH_NAMESPACE::isfinite(v.value[12]), MATH_NAMESPACE::isfinite(v.value[13]), MATH_NAMESPACE::isfinite(v.value[14]), MATH_NAMESPACE::isfinite(v.value[15]) ); } //------------------------------------------------------------------------------------------------- // // MATH_FUNC VSNRAY_FORCE_INLINE float16 rcp(float16 const& v) { return float16(1.0f) / v; } MATH_FUNC VSNRAY_FORCE_INLINE float16 rsqrt(float16 const& v) { return float16(1.0f) / sqrt(v); } } // simd } // MATH_NAMESPACE
29.801897
99
0.43579
tjachmann
c542593328bf5f9d58bde8a4bea8c602c6fc718f
2,568
cpp
C++
src/tests/ThreadSyncConceptTest/ThreadSyncConceptTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
1
2022-02-13T11:42:50.000Z
2022-02-13T11:42:50.000Z
src/tests/ThreadSyncConceptTest/ThreadSyncConceptTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
null
null
null
src/tests/ThreadSyncConceptTest/ThreadSyncConceptTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> // Tests a concept of synchonizing messages transfer from a lot of reporter threads // to a signle collector thread #include "core/VectorHelpers.h" #include <atomic> #include <future> #include <thread> #include <mutex> #include <vector> #include <algorithm> #include <iostream> #include <set> using Elem = size_t; using Storage = std::vector<size_t>; using Exchanger = std::pair<std::mutex, Storage>; size_t collect(Exchanger &exchanger, std::atomic<bool> &stopCollecting) { // To count all unique elements std::set<Elem> localStorage; auto grabExchangerToLocal = [&localStorage](auto &exch) { std::lock_guard<std::mutex> guard(exch.first); for ( auto &&elem : exch.second ) localStorage.emplace(std::move(elem)); exch.second.clear(); }; while ( !stopCollecting ) { grabExchangerToLocal(exchanger); std::this_thread::sleep_for(std::chrono::milliseconds(1)); } // ... and once more after stop grabExchangerToLocal(exchanger); return localStorage.size(); } void report(size_t startFrom, size_t howMuch, Exchanger &exchanger) { for ( size_t i = 0; i < howMuch; ++i ) { { std::lock_guard<std::mutex> guard(exchanger.first); VectorHelpers::doubleCapacityIfNeeded(exchanger.second); exchanger.second.emplace_back(startFrom + i); } std::this_thread::yield(); } } void test(size_t reportBySingleThread, size_t reporterThreads) { Exchanger exchanger; std::atomic<bool> stopCollecting = false; auto collector = std::async(std::launch::async, collect, std::ref(exchanger), std::ref(stopCollecting)); { std::vector<std::future<void>> reporters; reporters.reserve(reporterThreads); for ( size_t i = 0; i < reporterThreads; ++i ) reporters.emplace_back(std::async( std::launch::async, report, i * reportBySingleThread, reportBySingleThread, std::ref(exchanger) )); } // <--- waiting for all reporters to finish stopCollecting = true; EXPECT_EQ(collector.get(), reportBySingleThread * reporterThreads); } TEST(ThreadSyncConceptTest, Single_repetition) { test(25'000, 4); } TEST(ThreadSyncConceptTest, GreatRandomTest) { srand(static_cast<unsigned int>(time(nullptr))); const auto repetitions = 100; for ( auto rep = 0; rep < repetitions; ++rep ) { const size_t reportBySingleThread = 1'000 + 1'000 * (rand() & 0xf); const size_t reporterThreads = 1 + rand() & 0xf; test(reportBySingleThread, reporterThreads); } } #include "main.h"
22.526316
106
0.679907
ADDubovik
c542d1a6d6fdf5a002653c05c8e76f680e472d24
196
cpp
C++
Hacks/antiafkkick.cpp
manigamer22/nagahook-priv-src
8dfe6a603fae1251312ca75e0a196c865eed72e8
[ "Unlicense" ]
1
2020-02-20T16:50:09.000Z
2020-02-20T16:50:09.000Z
Hacks/antiafkkick.cpp
officialquake/nagahook-priv-src
0e6928f7a7d7089f81bcac1065c7d7a86766e970
[ "Unlicense" ]
null
null
null
Hacks/antiafkkick.cpp
officialquake/nagahook-priv-src
0e6928f7a7d7089f81bcac1065c7d7a86766e970
[ "Unlicense" ]
2
2019-12-26T15:14:30.000Z
2019-12-28T01:26:25.000Z
#include "antiafkkick.hpp" CAfk* afk = new CAfk(); void CAfk::afkkick(CUserCmd* cmd) { if (vars.visuals.antiafkkick && cmd->command_number % 2){ cmd->buttons |= 1 << 26; } }
13.066667
61
0.591837
manigamer22
c546bc997d45aef452bcb43c163776b485c07242
22,965
cpp
C++
ui-qt/ToolLib/Logic/LogicCondJump/CondJumpWidget.cpp
qianyongjun123/FPGA-Industrial-Smart-Camera
54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32
[ "MIT" ]
1
2017-12-28T08:08:02.000Z
2017-12-28T08:08:02.000Z
ui-qt/ToolLib/Logic/LogicCondJump/CondJumpWidget.cpp
qianyongjun123/FPGA-Industrial-Smart-Camera
54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32
[ "MIT" ]
null
null
null
ui-qt/ToolLib/Logic/LogicCondJump/CondJumpWidget.cpp
qianyongjun123/FPGA-Industrial-Smart-Camera
54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32
[ "MIT" ]
3
2017-12-28T08:08:05.000Z
2021-11-12T07:59:13.000Z
#include <QDebug> #include "CondJumpWidget.h" #include "ui_CondJumpWidget.h" #include <QMessageBox> #include "LinkDataGlobal.h" #include "CondJumpListItem.h" CondJumpWidget::CondJumpWidget(QWidget *parent) : QWidget(parent), ui(new Ui::CondJumpWidget) { m_ok_io = 1; m_ng_io = 2; ui->setupUi(this); } CondJumpWidget::~CondJumpWidget() { delete ui; } /** * @brief CondJumpWidget::Init_Input_Ptr * @param ptr input结构体指针 * @param i_step_index 当前步骤号 * @param new_flag 新加步骤标志:1新加,0编辑 * @author dgq * @note 初始化设置Input结构体指针 */ void CondJumpWidget::Init_Input_Ptr(void *ptr,int i_step_index,int new_flag,void *pen_color) { pInputPara = ptr; m_step_index = i_step_index; if(pInputPara == NULL) { QMessageBox::about(this,tr(""),tr("初始化数据失败,初始化失败")); return; } if(new_flag) { Task_Step_Synthetic_Judge_Flag_Set(i_step_index,1); ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_jump_index = 0; ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_jump_index = 0; ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io = 0; ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io = 0; ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->and_or = 0; memset(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap,0,8); memset(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap,0,8); } InitData(i_step_index); } /** * @brief CondJumpWidget::Set_Parameter_To_Ram * @return 1成功,0失败 * @author dgq * @note 将界面参数写入内存 */ int CondJumpWidget::Set_Parameter_To_Ram() { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_jump_index = atoi(ui->comboBoxOKJump->currentText().toStdString().c_str()); ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_jump_index = atoi(ui->comboBoxNGJump->currentText().toStdString().c_str()); ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io = m_ok_io; ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io = m_ng_io; if(ui->radioButtonAndAll->isChecked()) { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->and_or = 0; }else { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->and_or = 1; } int cnt = ui->listWidgetAssociationStepsData->count(); if(cnt == 0) { return 0; } for(int i = 0; i < cnt;i++) { QListWidgetItem *item = ui->listWidgetAssociationStepsData->item(i); QWidget *qWidget = ui->listWidgetAssociationStepsData->itemWidget(item); QString strJumpStepName = ((CondJumpListItem*)qWidget)->GetJumpSetpName(); int iposition = strJumpStepName.indexOf('.'); int index = strJumpStepName.left(iposition).toInt(); // bitmap_set_bit(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap,index); SetCorrelationStep(1,index-1); bool bflag = ((CondJumpListItem*)qWidget)->GetCheckboxState(); if(bflag) { SetCorrelationStepNegation(index-1, 1); }else { SetCorrelationStepNegation(index-1, 0); } } return 1; } /** * @brief CondJumpWidget::InitData * @param i_step_index * @author dgq * @note 初始化界面显示 */ void CondJumpWidget::InitData(int i_step_index) { ui->comboBoxOKJump->addItem(" "); ui->comboBoxNGJump->addItem(" "); ui->cmbAssociationSteps->addItem(" "); int i_task_cnt = GetTaskStepCount(); int i = 0; for(i = 0;i < i_task_cnt;i++) { char taskName[40]; unsigned int task_type; int ret = Task_Step_Type_ID_Get(i+1,&task_type); if(ret == 0) { memset(taskName, 0, 40); int ret = Get_Task_Name(i+1, taskName); if(ret != -1) { if(i < i_step_index-1) { ui->cmbAssociationSteps->addItem(QString::number(i+1) +"."+ QString::fromUtf8(taskName)); } if(i > i_step_index - 1) { ui->comboBoxOKJump->addItem(QString::number(i+1) +"."+ QString::fromUtf8(taskName)); ui->comboBoxNGJump->addItem(QString::number(i+1) +"."+ QString::fromUtf8(taskName)); } } } int iTask = GetCorrelationStep(i); if(iTask == 0) continue; ret = Task_Step_Type_ID_Get(i+1,&task_type); if(!ret) { memset(taskName, 0, 40); int ret = Get_Task_Name(i+1, taskName); if(ret != -1) { QString strTask = QString::number(i+1) +"."+ QString::fromUtf8(taskName); int iNegation= GetCorrelationStepNegation(i); int size =ui->listWidgetAssociationStepsData->count(); CondJumpListItem *dlg = new CondJumpListItem(); QListWidgetItem* mItem = new QListWidgetItem(ui->listWidgetAssociationStepsData); dlg->SetJumpSetpName(strTask); if(iNegation > 0) dlg->SetCheckboxState(true); else dlg->SetCheckboxState(false); ui->listWidgetAssociationStepsData->setItemWidget(mItem,(QWidget*)dlg); ui->listWidgetAssociationStepsData->item(size)->setSizeHint(QSize(300,30)); } } } int i_ok_jump = ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_jump_index ; int i_ng_jump = ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_jump_index ; for( i = 0; i< ui->comboBoxOKJump->count();i++) { QString strTask_ok = ui->comboBoxOKJump->itemText(i); QString strTask_ng = ui->comboBoxNGJump->itemText(i); if(i_ok_jump == atoi(strTask_ok.toStdString().c_str())) { ui->comboBoxOKJump->setCurrentIndex(i); if(i_ok_jump > i_ng_jump) { break; } } if(i_ng_jump == atoi(strTask_ng.toStdString().c_str())) { ui->comboBoxNGJump->setCurrentIndex(i); if(i_ok_jump < i_ng_jump) { break; } } } if(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->and_or == 1) { ui->radioButtonAndAll->setChecked(false); ui->radioButtonNotAll->setChecked(true); } else { ui->radioButtonAndAll->setChecked(true); ui->radioButtonNotAll->setChecked(false); } if(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io != 0) { ui->checkBoxOKIO->setChecked(true); SetOKChecked(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io); } else { ui->radioButtonOKIO1->setEnabled(false); ui->radioButtonOKIO2->setEnabled(false); ui->radioButtonOKIO3->setEnabled(false); ui->radioButtonOKIO4->setEnabled(false); } if(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io != 0) { ui->checkBoxNGIO->setChecked(true); SetNGChecked(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io); } else { ui->radioButtonNGIO1->setEnabled(false); ui->radioButtonNGIO2->setEnabled(false); ui->radioButtonNGIO3->setEnabled(false); ui->radioButtonNGIO4->setEnabled(false); } connect(ui->comboBoxOKJump, SIGNAL(currentIndexChanged(int)), this, SLOT(OKComboBoxChangeSlot(int))); connect(ui->comboBoxNGJump, SIGNAL(currentIndexChanged(int)), this, SLOT(NGComboBoxChangeSlot(int))); connect(ui->checkBoxOKIO, &QCheckBox::released, this, &CondJumpWidget::OKCheckBoxSlot); connect(ui->checkBoxNGIO, &QCheckBox::released, this, &CondJumpWidget::NGCheckBoxSlot); connect(ui->radioButtonOKIO1, &QRadioButton::released, this, &CondJumpWidget::CheckButtonOKIO1Slot); connect(ui->radioButtonOKIO2, &QRadioButton::released, this, &CondJumpWidget::CheckButtonOKIO2Slot); connect(ui->radioButtonOKIO3, &QRadioButton::released, this, &CondJumpWidget::CheckButtonOKIO3Slot); connect(ui->radioButtonOKIO4, &QRadioButton::released, this, &CondJumpWidget::CheckButtonOKIO4Slot); connect(ui->radioButtonNGIO1, &QRadioButton::released, this, &CondJumpWidget::CheckButtonNGIO1Slot); connect(ui->radioButtonNGIO2, &QRadioButton::released, this, &CondJumpWidget::CheckButtonNGIO2Slot); connect(ui->radioButtonNGIO3, &QRadioButton::released, this, &CondJumpWidget::CheckButtonNGIO3Slot); connect(ui->radioButtonNGIO4, &QRadioButton::released, this, &CondJumpWidget::CheckButtonNGIO4Slot); } /** * @brief CondJumpWidget::OKComboBoxChangeSlot * @param index * @author dgq * @note Ok跳转步骤下拉框索引改变响应函数 */ void CondJumpWidget::OKComboBoxChangeSlot(int index) { Q_UNUSED(index); int current_index =atoi(ui->comboBoxOKJump->currentText().toStdString().c_str()); if(current_index <= m_step_index) { QMessageBox::warning(NULL, tr("Warning"), tr("跳转到本步任务或本步任务之前,有可能导致运行进入死循环!"), QMessageBox::Ok, QMessageBox::Ok); } ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_jump_index =current_index; } //ng关联数据下拉框 /** * @brief CondJumpWidget::NGComboBoxChangeSlot * @param index * @author dgq * @note NG跳转步骤下拉框索引改变响应函数 */ void CondJumpWidget::NGComboBoxChangeSlot(int index) { Q_UNUSED(index); int current_index =atoi(ui->comboBoxNGJump->currentText().toStdString().c_str()); if(current_index <= m_step_index) { QMessageBox::warning(NULL, tr("Warning"), tr("跳转到本步任务或本步任务之前,有可能导致运行进入死循环!"), QMessageBox::Ok, QMessageBox::Ok); } ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_jump_index =current_index; } /** * @brief CondJumpWidget::SetOKChecked * @param IO_index * @author dgq * @note 设置根据OK IO值选择界面显示效果 */ void CondJumpWidget::SetOKChecked(unsigned int IO_index) { if(ui->checkBoxNGIO->isChecked() == true) { ui->radioButtonNGIO1->setEnabled(true); ui->radioButtonNGIO2->setEnabled(true); ui->radioButtonNGIO3->setEnabled(true); ui->radioButtonNGIO4->setEnabled(true); } switch(IO_index) { case 1: ui->radioButtonOKIO1->setChecked(true); ui->radioButtonNGIO1->setEnabled(false); ui->radioButtonOKIO2->setChecked(false); ui->radioButtonOKIO3->setChecked(false); ui->radioButtonOKIO4->setChecked(false); break; case 2: ui->radioButtonOKIO1->setChecked(false); ui->radioButtonOKIO2->setChecked(true); ui->radioButtonNGIO2->setEnabled(false); ui->radioButtonOKIO3->setChecked(false); ui->radioButtonOKIO4->setChecked(false); break; case 4: ui->radioButtonOKIO1->setChecked(false); ui->radioButtonOKIO2->setChecked(false); ui->radioButtonOKIO3->setChecked(true); ui->radioButtonNGIO3->setEnabled(false); ui->radioButtonOKIO4->setChecked(false); break; case 8: ui->radioButtonOKIO1->setChecked(false); ui->radioButtonOKIO2->setChecked(false); ui->radioButtonOKIO3->setChecked(false); ui->radioButtonOKIO4->setChecked(true); ui->radioButtonNGIO4->setEnabled(false); break; default: ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io = 1; ui->radioButtonOKIO1->setChecked(true); ui->radioButtonNGIO1->setEnabled(false); ui->radioButtonOKIO2->setChecked(false); ui->radioButtonOKIO3->setChecked(false); ui->radioButtonOKIO4->setChecked(false); break; } } //设置根据NG IO值选择界面显示效果 /** * @brief CondJumpWidget::SetNGChecked * @param IO_index * @author dgq * @note 设置根据NG IO值选择界面显示效果 */ void CondJumpWidget::SetNGChecked(unsigned int IO_index) { if(ui->checkBoxOKIO->isChecked() == true) { ui->radioButtonOKIO1->setEnabled(true); ui->radioButtonOKIO2->setEnabled(true); ui->radioButtonOKIO3->setEnabled(true); ui->radioButtonOKIO4->setEnabled(true); } switch(IO_index) { case 1: ui->radioButtonNGIO1->setChecked(true); ui->radioButtonOKIO1->setEnabled(false); ui->radioButtonNGIO2->setChecked(false); ui->radioButtonNGIO3->setChecked(false); ui->radioButtonNGIO4->setChecked(false); break; case 2: ui->radioButtonNGIO1->setChecked(false); ui->radioButtonNGIO2->setChecked(true); ui->radioButtonOKIO2->setEnabled(false); ui->radioButtonNGIO3->setChecked(false); ui->radioButtonNGIO4->setChecked(false); break; case 4: ui->radioButtonNGIO1->setChecked(false); ui->radioButtonNGIO2->setChecked(false); ui->radioButtonNGIO3->setChecked(true); ui->radioButtonOKIO3->setEnabled(false); ui->radioButtonNGIO4->setChecked(false); break; case 8: ui->radioButtonNGIO1->setChecked(false); ui->radioButtonNGIO2->setChecked(false); ui->radioButtonNGIO3->setChecked(false); ui->radioButtonNGIO4->setChecked(true); ui->radioButtonOKIO4->setEnabled(false); break; default: ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io = 2; ui->radioButtonNGIO1->setChecked(false); ui->radioButtonNGIO2->setChecked(true); ui->radioButtonOKIO2->setEnabled(false); ui->radioButtonNGIO3->setChecked(false); ui->radioButtonNGIO4->setChecked(false); break; } } /** * @brief CondJumpWidget::OKCheckBoxSlot * @author dgq * @note OK IO跳转使能按钮点击响应函数 */ void CondJumpWidget::OKCheckBoxSlot() { if(ui->checkBoxOKIO->isChecked() == true) { ui->radioButtonOKIO1->setEnabled(true); ui->radioButtonOKIO2->setEnabled(true); ui->radioButtonOKIO3->setEnabled(true); ui->radioButtonOKIO4->setEnabled(true); switch(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io) { case 0: break; case 1: ui->radioButtonOKIO1->setEnabled(false); break; case 2: ui->radioButtonOKIO2->setEnabled(false); break; case 4: ui->radioButtonOKIO3->setEnabled(false); break; case 8: ui->radioButtonOKIO4->setEnabled(false); break; default: break; } SetOKChecked(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io); } else { ui->radioButtonOKIO1->setEnabled(false); ui->radioButtonOKIO2->setEnabled(false); ui->radioButtonOKIO3->setEnabled(false); ui->radioButtonOKIO4->setEnabled(false); if(ui->checkBoxNGIO->isChecked() == true) { ui->radioButtonNGIO1->setEnabled(true); ui->radioButtonNGIO2->setEnabled(true); ui->radioButtonNGIO3->setEnabled(true); ui->radioButtonNGIO4->setEnabled(true); } } } /** * @brief CondJumpWidget::NGCheckBoxSlot * @author dgq * @note NG IO跳转使能按钮点击响应函数 */ void CondJumpWidget::NGCheckBoxSlot() { if(ui->checkBoxNGIO->isChecked() == true) { ui->radioButtonNGIO1->setEnabled(true); ui->radioButtonNGIO2->setEnabled(true); ui->radioButtonNGIO3->setEnabled(true); ui->radioButtonNGIO4->setEnabled(true); switch(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ok_io) { case 0: break; case 1: ui->radioButtonNGIO1->setEnabled(false); break; case 2: ui->radioButtonNGIO2->setEnabled(false); break; case 4: ui->radioButtonNGIO3->setEnabled(false); break; case 8: ui->radioButtonNGIO4->setEnabled(false); break; default: break; } SetNGChecked(((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->ng_io); } else { ui->radioButtonNGIO1->setEnabled(false); ui->radioButtonNGIO2->setEnabled(false); ui->radioButtonNGIO3->setEnabled(false); ui->radioButtonNGIO4->setEnabled(false); if(ui->checkBoxOKIO->isChecked() == true) { ui->radioButtonOKIO1->setEnabled(true); ui->radioButtonOKIO2->setEnabled(true); ui->radioButtonOKIO3->setEnabled(true); ui->radioButtonOKIO4->setEnabled(true); } } } /** * @brief CondJumpWidget::CheckButtonOKIO1Slot * @author dgq * @note 选择ok时的IO端口1 */ void CondJumpWidget::CheckButtonOKIO1Slot() { if(ui->radioButtonOKIO1->isChecked() == true) { SetOKChecked(1); m_ok_io = 1; } } /** * @brief CondJumpWidget::CheckButtonOKIO2Slot * @author dgq * @note 选择ok时的IO端口2 */ void CondJumpWidget::CheckButtonOKIO2Slot() { if(ui->radioButtonOKIO2->isChecked() == true) { SetOKChecked(2); m_ok_io = 1; } } /** * @brief CondJumpWidget::CheckButtonOKIO3Slot * @author dgq * @note 选择ok时的IO端口3 */ void CondJumpWidget::CheckButtonOKIO3Slot() { if(ui->radioButtonOKIO3->isChecked() == true) { SetOKChecked(4); m_ok_io = 4; } } /** * @brief CondJumpWidget::CheckButtonOKIO4Slot * @author dgq * @note 选择ok时的IO端口4 */ void CondJumpWidget::CheckButtonOKIO4Slot() { if(ui->radioButtonOKIO4->isChecked() == true) { SetOKChecked(8); m_ok_io = 8; } } /** * @brief CondJumpWidget::CheckButtonNGIO1Slot * @author dgq * @note 选择ng时的IO端口1 */ void CondJumpWidget::CheckButtonNGIO1Slot() { if(ui->radioButtonNGIO1->isChecked() == true) { SetNGChecked(1); m_ng_io = 1; } } /** * @brief CondJumpWidget::CheckButtonNGIO2Slot * @author dgq * @note 选择ng时的IO端口2 */ void CondJumpWidget::CheckButtonNGIO2Slot() { if(ui->radioButtonNGIO2->isChecked() == true) { SetNGChecked(2); m_ng_io = 2; } } /** * @brief CondJumpWidget::CheckButtonNGIO3Slot * @author dgq * @note 选择ng时的IO端口3 */ void CondJumpWidget::CheckButtonNGIO3Slot() { if(ui->radioButtonNGIO3->isChecked() == true) { SetNGChecked(4); m_ng_io = 4; } } /** * @brief CondJumpWidget::CheckButtonNGIO4Slot * @author dgq * @note 选择ng时的IO端口4 */ void CondJumpWidget::CheckButtonNGIO4Slot() { if(ui->radioButtonNGIO4->isChecked() == true) { SetNGChecked(8); m_ng_io = 8; } } /** * @brief CondJumpWidget::on_btnAdd_clicked * @author dgq * @note 添加按钮响应函数 */ void CondJumpWidget::on_btnAdd_clicked() { if(ui->cmbAssociationSteps->currentIndex()>=1) { int size =ui->listWidgetAssociationStepsData->count(); QString strtemp = ui->cmbAssociationSteps->itemText(ui->cmbAssociationSteps->currentIndex()); if(IsTaskStepInTable(strtemp)) { QMessageBox::about(NULL,tr("提示"),tr("列表中已存在改步骤,请选择其他步骤!")); return; } CondJumpListItem *dlg = new CondJumpListItem(); QListWidgetItem* mItem = new QListWidgetItem(ui->listWidgetAssociationStepsData); dlg->SetJumpSetpName(strtemp); ui->listWidgetAssociationStepsData->setItemWidget(mItem,(QWidget*)dlg); ui->listWidgetAssociationStepsData->item(size)->setSizeHint(QSize(300,30)); }else { QMessageBox::about(NULL,tr("提示"),tr("请先选择关联步骤")); } } //判断任务号是否在列表中 /** * @brief CondJumpWidget::IsTaskStepInTable * @param StrTask * @return * @author dgq * @note 判断选择的任务是否已存在列表中 */ int CondJumpWidget::IsTaskStepInTable(QString StrTask) { int icount = ui->listWidgetAssociationStepsData->count(); int i; int isIN = 0; for(i = 0;i<icount;i++) { QListWidgetItem *item = ui->listWidgetAssociationStepsData->item(i); QWidget *qWidget = ui->listWidgetAssociationStepsData->itemWidget(item); QString strJumpStepName = ((CondJumpListItem*)qWidget)->GetJumpSetpName(); if(StrTask == strJumpStepName) { isIN = 1; break; } } return isIN; } //删除关联步骤列表中的数据 /** * @brief CondJumpWidget::on_btnDelete_clicked * @author dgq * @note 删除关联步骤列表中的数据 */ void CondJumpWidget::on_btnDelete_clicked() { if(ui->listWidgetAssociationStepsData->currentRow() < 0) { return; } QMessageBox::StandardButton rb = QMessageBox::warning(NULL, tr("警告"), tr("确定删除本行数据?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if(rb == QMessageBox::Yes) { QListWidgetItem *item1 = ui->listWidgetAssociationStepsData->item(ui->listWidgetAssociationStepsData->currentRow()); QWidget *widget = ui->listWidgetAssociationStepsData->itemWidget(item1); QString task = ((CondJumpListItem*)widget)->GetJumpSetpName(); int index = atoi(task.toStdString().c_str()); SetCorrelationStep(0,index-1); QListWidgetItem *item = ui->listWidgetAssociationStepsData->takeItem(ui->listWidgetAssociationStepsData->currentRow()); delete item; } } /********************************************** *以下函数为写bitmap专用 *********************************************/ /* * 获取关联步骤取反标志 *参数 unsigned int:对应的关联步骤-1 *返回 unsigned int:关联步骤取反标志 *@author th *@version v1.0 */ int CondJumpWidget::GetCorrelationStepNegation(unsigned int step) { int step_index = step / 32; int step_bit = step % 32; unsigned int ret = ((((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_negation[step_index] & (0x01 << step_bit)) >> step_bit); return ret; } /* * 设置关联步骤取反标志 *参数 unsigned int:对应的关联步骤-1 unsigned int:关联步骤取反标志 *返回 无 *@author th *@version v1.0 */ int CondJumpWidget::SetCorrelationStepNegation(unsigned int step,unsigned int flag) { unsigned int step_index = step /32; unsigned int step_bit = step % 32; if(1 == flag) { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_negation[step_index] |= (0x01 << step_bit); } else { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_negation[step_index] &= (~(0x01 << step_bit)); } // printf("g_tTaskParam.ParamStruct.ConditionalJumpParameter.link_step_negation[step_index] = %#x\n",g_tTaskParam.ParamStruct.ConditionalJumpParameter.link_step_negation[step_index]); } /* * 获取关联步骤BITMAP *参数 unsigned int:对应的关联步骤-1 *返回 unsigned int:BITMAP值 *@author th *@version v1.0 */ int CondJumpWidget::GetCorrelationStep(unsigned int step) { int step_index = step / 32; int step_bit = step % 32; unsigned int ret = ((((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap[step_index] & (0x01 << step_bit)) >> step_bit); // printf("ret ========= %#x\n",ret); return ret; } /* * 设置关联步骤BITMAP *参数 unsigned int:BITMAP值 unsigned int:对应的关联步骤-1 *返回 无 *@author th *@version v1.0 */ void CondJumpWidget::SetCorrelationStep(unsigned int bitmap,unsigned int step) { unsigned int step_index = step /32; unsigned int step_bit = step % 32; if(1 == bitmap) { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap[step_index] |= (0x01 << step_bit); } else { ((CONDITION_JUMP_INPUT_PARAM*)pInputPara)->link_step_bitmap[step_index] &= (~(0x01 << step_bit)); } }
29.367008
186
0.634357
qianyongjun123
c546f82fdc7c55ef0e4c500cc08a7525f4134c13
1,474
cpp
C++
UEPrototype/Source/UEPrototype/Private/Tool/ToolModuleManager.cpp
Jaeguins/Prototype
faa6b2626c3cfc187a9f4e44fef641de527fe0ca
[ "MIT" ]
null
null
null
UEPrototype/Source/UEPrototype/Private/Tool/ToolModuleManager.cpp
Jaeguins/Prototype
faa6b2626c3cfc187a9f4e44fef641de527fe0ca
[ "MIT" ]
null
null
null
UEPrototype/Source/UEPrototype/Private/Tool/ToolModuleManager.cpp
Jaeguins/Prototype
faa6b2626c3cfc187a9f4e44fef641de527fe0ca
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #include "Tool/ToolModuleManager.h" #include "UEPrototype.h" #include "VPFrameworkLibrary.h" #include "UObjectIterator.h" #include "Tool/ToolKit.h" #include "Tool/ToolManager.h" UToolModuleManager::UToolModuleManager() { // DEBUG VP_CTOR; bInitialized = false; /* 유효하지 않은 싱글톤 CDO는 더이상 초기화를 진행하지 않습니다 */ if (UVPFrameworkLibrary::IsValidSingletonCDO(this) == false) { return; } // DEBUG VP_LOG(Warning, TEXT("[DEBUG] Tool 모듈 초기화완료")); bInitialized = true; ModuleEndInitEventDispatcher.Broadcast(); } UToolModuleManager * UToolModuleManager::GetGlobalToolModuleManager() { for (const auto& it : TObjectRange<UToolModuleManager>()) { if (UVPFrameworkLibrary::IsValidSingletonCDO(it)) { return it; } } /* 반복자에서 찾지 못하면 시스템에 큰 결함이 있는 것입니다. */ VP_LOG(Error, TEXT("%s가 유효하지 않습니다"), *UToolModuleManager::StaticClass()->GetName()); return nullptr; } void UToolModuleManager::Initialized() { /* 하위 모듈들을 초기화합니다 */ ToolKit = CreateDefaultSubobject<UToolKit>(UToolKit::StaticClass()->GetFName()); ToolManager = CreateDefaultSubobject<UToolManager>(UToolManager::StaticClass()->GetFName()); if (IsValid(ToolKit) == false) { VP_LOG(Warning, TEXT("%s가 유효하지 않습니다."), *UToolKit::StaticClass()->GetName()); return; } if (IsValid(ToolManager) == false) { VP_LOG(Warning, TEXT("%s가 유효하지 않습니다."), *UToolManager::StaticClass()->GetName()); return; } }
20.191781
93
0.710991
Jaeguins
c54a7a8ce9afe45d3d08dd9484fb7d2a6bc77f98
2,219
cpp
C++
Leetcode Daily Challenge/October-2020/21. Asteroid Collision.cpp
Akshad7829/DataStructures-Algorithms
439822c6a374672d1734e2389d3fce581a35007d
[ "MIT" ]
5
2021-08-10T18:47:49.000Z
2021-08-21T15:42:58.000Z
Leetcode Daily Challenge/October-2020/21. Asteroid Collision.cpp
Akshad7829/DataStructures-Algorithms
439822c6a374672d1734e2389d3fce581a35007d
[ "MIT" ]
2
2022-02-25T13:36:46.000Z
2022-02-25T14:06:44.000Z
Leetcode Daily Challenge/October-2020/21. Asteroid Collision.cpp
Akshad7829/DataStructures-Algorithms
439822c6a374672d1734e2389d3fce581a35007d
[ "MIT" ]
1
2021-08-11T06:36:42.000Z
2021-08-11T06:36:42.000Z
/* Asteroid Collision ================== We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet. Example 1: Input: asteroids = [5,10,-5] Output: [5,10] Explanation: The 10 and -5 collide resulting in 10. The 5 and 10 never collide. Example 2: Input: asteroids = [8,-8] Output: [] Explanation: The 8 and -8 collide exploding each other. Example 3: Input: asteroids = [10,2,-5] Output: [10] Explanation: The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10. Example 4: Input: asteroids = [-2,-1,1,2] Output: [-2,-1,1,2] Explanation: The -2 and -1 are moving left, while the 1 and 2 are moving right. Asteroids moving the same direction never meet, so no asteroids will meet each other. Constraints: 1 <= asteroids <= 104 -1000 <= asteroids[i] <= 1000 asteroids[i] != 0 Hint #1 Say a row of asteroids is stable. What happens when a new asteroid is added on the right? */ class Solution { public: vector<int> asteroidCollision(vector<int> &asteroids) { stack<int> s; for (auto asteroid : asteroids) { if (s.empty() || asteroid > 0) s.push(asteroid); else { while (true) { auto el = s.top(); if (el < 0) { s.push(asteroid); break; } else if (el == -asteroid) { s.pop(); break; } else if (el > -asteroid) break; else { s.pop(); if (s.empty()) { s.push(asteroid); break; } } } } } vector<int> ans; while (s.size()) { ans.push_back(s.top()); s.pop(); } reverse(ans.begin(), ans.end()); return ans; } };
23.606383
216
0.581794
Akshad7829
c54caa28b642a5dbfa51678971f68e0b0abcb6c5
20,062
cpp
C++
SpatialGDK/Source/SpatialGDK/Private/Interop/SpatialClassInfoManager.cpp
Bowbee/GDKPrebuilt
420b3fa19fdc36755a43e655c057b5624264407a
[ "MIT" ]
363
2018-07-30T12:57:42.000Z
2022-03-25T14:30:28.000Z
SpatialGDK/Source/SpatialGDK/Private/Interop/SpatialClassInfoManager.cpp
Bowbee/GDKPrebuilt
420b3fa19fdc36755a43e655c057b5624264407a
[ "MIT" ]
1,634
2018-07-30T14:30:25.000Z
2022-03-03T01:55:15.000Z
SpatialGDK/Source/SpatialGDK/Private/Interop/SpatialClassInfoManager.cpp
Bowbee/GDKPrebuilt
420b3fa19fdc36755a43e655c057b5624264407a
[ "MIT" ]
153
2018-07-31T13:45:02.000Z
2022-03-03T05:20:24.000Z
// Copyright (c) Improbable Worlds Ltd, All Rights Reserved #include "Interop/SpatialClassInfoManager.h" #include "AssetRegistryModule.h" #include "Engine/BlueprintGeneratedClass.h" #include "Engine/Engine.h" #include "GameFramework/Actor.h" #include "Misc/MessageDialog.h" #include "Runtime/Launch/Resources/Version.h" #include "UObject/Class.h" #include "UObject/UObjectIterator.h" #if WITH_EDITOR #include "Kismet/KismetSystemLibrary.h" #endif #include "EngineClasses/SpatialNetDriver.h" #include "EngineClasses/SpatialPackageMapClient.h" #include "EngineClasses/SpatialWorldSettings.h" #include "LoadBalancing/AbstractLBStrategy.h" #include "Utils/GDKPropertyMacros.h" #include "Utils/RepLayoutUtils.h" DEFINE_LOG_CATEGORY(LogSpatialClassInfoManager); bool USpatialClassInfoManager::TryInit(USpatialNetDriver* InNetDriver) { check(InNetDriver != nullptr); NetDriver = InNetDriver; FSoftObjectPath SchemaDatabasePath = FSoftObjectPath(FPaths::SetExtension(SpatialConstants::SCHEMA_DATABASE_ASSET_PATH, TEXT(".SchemaDatabase"))); SchemaDatabase = Cast<USchemaDatabase>(SchemaDatabasePath.TryLoad()); if (SchemaDatabase == nullptr) { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("SchemaDatabase not found! Please generate schema or turn off SpatialOS networking.")); QuitGame(); return false; } return true; } bool USpatialClassInfoManager::ValidateOrExit_IsSupportedClass(const FString& PathName) { if (!IsSupportedClass(PathName)) { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Could not find class %s in schema database. Double-check whether replication is enabled for this class, the class is marked as SpatialType, and schema has been generated."), *PathName); #if !UE_BUILD_SHIPPING UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Disconnecting due to no generated schema for %s."), *PathName); QuitGame(); #endif //!UE_BUILD_SHIPPING return false; } return true; } FORCEINLINE UClass* ResolveClass(FString& ClassPath) { FSoftClassPath SoftClassPath(ClassPath); UClass* Class = SoftClassPath.ResolveClass(); if (Class == nullptr) { UE_LOG(LogSpatialClassInfoManager, Warning, TEXT("Failed to find class at path %s! Attempting to load it."), *ClassPath); Class = SoftClassPath.TryLoadClass<UObject>(); } return Class; } ERPCType GetRPCType(UFunction* RemoteFunction) { if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetMulticast)) { return ERPCType::NetMulticast; } else if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetCrossServer)) { return ERPCType::CrossServer; } else if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetReliable)) { if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetClient)) { return ERPCType::ClientReliable; } else if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetServer)) { return ERPCType::ServerReliable; } } else { if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetClient)) { return ERPCType::ClientUnreliable; } else if (RemoteFunction->HasAnyFunctionFlags(FUNC_NetServer)) { return ERPCType::ServerUnreliable; } } return ERPCType::Invalid; } void USpatialClassInfoManager::CreateClassInfoForClass(UClass* Class) { // Remove PIE prefix on class if it exists to properly look up the class. FString ClassPath = Class->GetPathName(); GEngine->NetworkRemapPath(NetDriver, ClassPath, false); TSharedRef<FClassInfo> Info = ClassInfoMap.Add(Class, MakeShared<FClassInfo>()); Info->Class = Class; // Note: we have to add Class to ClassInfoMap before quitting, as it is expected to be in there by GetOrCreateClassInfoByClass. Therefore the quitting logic cannot be moved higher up. if (!ValidateOrExit_IsSupportedClass(ClassPath)) { return; } TArray<UFunction*> RelevantClassFunctions = SpatialGDK::GetClassRPCFunctions(Class); for (UFunction* RemoteFunction : RelevantClassFunctions) { ERPCType RPCType = GetRPCType(RemoteFunction); checkf(RPCType != ERPCType::Invalid, TEXT("Could not determine RPCType for RemoteFunction: %s"), *GetPathNameSafe(RemoteFunction)); FRPCInfo RPCInfo; RPCInfo.Type = RPCType; // Index is guaranteed to be the same on Clients & Servers since we process remote functions in the same order. RPCInfo.Index = Info->RPCs.Num(); Info->RPCs.Add(RemoteFunction); Info->RPCInfoMap.Add(RemoteFunction, RPCInfo); } const bool bTrackHandoverProperties = ShouldTrackHandoverProperties(); for (TFieldIterator<GDK_PROPERTY(Property)> PropertyIt(Class); PropertyIt; ++PropertyIt) { GDK_PROPERTY(Property)* Property = *PropertyIt; if (bTrackHandoverProperties && (Property->PropertyFlags & CPF_Handover)) { for (int32 ArrayIdx = 0; ArrayIdx < PropertyIt->ArrayDim; ++ArrayIdx) { FHandoverPropertyInfo HandoverInfo; HandoverInfo.Handle = Info->HandoverProperties.Num() + 1; // 1-based index HandoverInfo.Offset = Property->GetOffset_ForGC() + Property->ElementSize * ArrayIdx; HandoverInfo.ArrayIdx = ArrayIdx; HandoverInfo.Property = Property; Info->HandoverProperties.Add(HandoverInfo); } } if (Property->PropertyFlags & CPF_AlwaysInterested) { for (int32 ArrayIdx = 0; ArrayIdx < PropertyIt->ArrayDim; ++ArrayIdx) { FInterestPropertyInfo InterestInfo; InterestInfo.Offset = Property->GetOffset_ForGC() + Property->ElementSize * ArrayIdx; InterestInfo.Property = Property; Info->InterestProperties.Add(InterestInfo); } } } if (Class->IsChildOf<AActor>()) { FinishConstructingActorClassInfo(ClassPath, Info); } else { FinishConstructingSubobjectClassInfo(ClassPath, Info); } } void USpatialClassInfoManager::FinishConstructingActorClassInfo(const FString& ClassPath, TSharedRef<FClassInfo>& Info) { ForAllSchemaComponentTypes([&](ESchemaComponentType Type) { Worker_ComponentId ComponentId = SchemaDatabase->ActorClassPathToSchema[ClassPath].SchemaComponents[Type]; if (!ShouldTrackHandoverProperties() && Type == SCHEMA_Handover) { return; } if (ComponentId != SpatialConstants::INVALID_COMPONENT_ID) { Info->SchemaComponents[Type] = ComponentId; ComponentToClassInfoMap.Add(ComponentId, Info); ComponentToOffsetMap.Add(ComponentId, 0); ComponentToCategoryMap.Add(ComponentId, (ESchemaComponentType)Type); } }); for (auto& SubobjectClassDataPair : SchemaDatabase->ActorClassPathToSchema[ClassPath].SubobjectData) { int32 Offset = SubobjectClassDataPair.Key; FActorSpecificSubobjectSchemaData SubobjectSchemaData = SubobjectClassDataPair.Value; UClass* SubobjectClass = ResolveClass(SubobjectSchemaData.ClassPath); if (SubobjectClass == nullptr) { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Failed to resolve the class for subobject %s (class path: %s) on actor class %s! This subobject will not be able to replicate in Spatial!"), *SubobjectSchemaData.Name.ToString(), *SubobjectSchemaData.ClassPath, *ClassPath); continue; } const FClassInfo& SubobjectInfo = GetOrCreateClassInfoByClass(SubobjectClass); // Make a copy of the already made FClassInfo for this specific subobject TSharedRef<FClassInfo> ActorSubobjectInfo = MakeShared<FClassInfo>(SubobjectInfo); ActorSubobjectInfo->SubobjectName = SubobjectSchemaData.Name; ForAllSchemaComponentTypes([&](ESchemaComponentType Type) { if (!ShouldTrackHandoverProperties() && Type == SCHEMA_Handover) { return; } Worker_ComponentId ComponentId = SubobjectSchemaData.SchemaComponents[Type]; if (ComponentId != 0) { ActorSubobjectInfo->SchemaComponents[Type] = ComponentId; ComponentToClassInfoMap.Add(ComponentId, ActorSubobjectInfo); ComponentToOffsetMap.Add(ComponentId, Offset); ComponentToCategoryMap.Add(ComponentId, ESchemaComponentType(Type)); } }); Info->SubobjectInfo.Add(Offset, ActorSubobjectInfo); } } void USpatialClassInfoManager::FinishConstructingSubobjectClassInfo(const FString& ClassPath, TSharedRef<FClassInfo>& Info) { for (const auto& DynamicSubobjectData : SchemaDatabase->SubobjectClassPathToSchema[ClassPath].DynamicSubobjectComponents) { // Make a copy of the already made FClassInfo for this dynamic subobject TSharedRef<FClassInfo> SpecificDynamicSubobjectInfo = MakeShared<FClassInfo>(Info.Get()); int32 Offset = DynamicSubobjectData.SchemaComponents[SCHEMA_Data]; check(Offset != SpatialConstants::INVALID_COMPONENT_ID); ForAllSchemaComponentTypes([&](ESchemaComponentType Type) { Worker_ComponentId ComponentId = DynamicSubobjectData.SchemaComponents[Type]; if (ComponentId != SpatialConstants::INVALID_COMPONENT_ID) { SpecificDynamicSubobjectInfo->SchemaComponents[Type] = ComponentId; ComponentToClassInfoMap.Add(ComponentId, SpecificDynamicSubobjectInfo); ComponentToOffsetMap.Add(ComponentId, Offset); ComponentToCategoryMap.Add(ComponentId, ESchemaComponentType(Type)); } }); Info->DynamicSubobjectInfo.Add(SpecificDynamicSubobjectInfo); } } bool USpatialClassInfoManager::ShouldTrackHandoverProperties() const { // There's currently a bug that lets handover data get sent to clients in the initial // burst of data for an entity, which leads to log spam in the SpatialReceiver. By tracking handover // properties on clients, we can prevent that spam. if (!NetDriver->IsServer()) { return true; } const USpatialGDKSettings* Settings = GetDefault<USpatialGDKSettings>(); const UAbstractLBStrategy* Strategy = NetDriver->LoadBalanceStrategy; check(Strategy != nullptr); return Strategy->RequiresHandoverData() || Settings->bEnableHandover; } void USpatialClassInfoManager::TryCreateClassInfoForComponentId(Worker_ComponentId ComponentId) { if (FString* ClassPath = SchemaDatabase->ComponentIdToClassPath.Find(ComponentId)) { if (UClass* Class = LoadObject<UClass>(nullptr, **ClassPath)) { CreateClassInfoForClass(Class); } } } bool USpatialClassInfoManager::IsSupportedClass(const FString& PathName) const { return SchemaDatabase->ActorClassPathToSchema.Contains(PathName) || SchemaDatabase->SubobjectClassPathToSchema.Contains(PathName); } const FClassInfo& USpatialClassInfoManager::GetOrCreateClassInfoByClass(UClass* Class) { if (!ClassInfoMap.Contains(Class)) { CreateClassInfoForClass(Class); } return ClassInfoMap[Class].Get(); } const FClassInfo& USpatialClassInfoManager::GetOrCreateClassInfoByObject(UObject* Object) { if (AActor* Actor = Cast<AActor>(Object)) { return GetOrCreateClassInfoByClass(Actor->GetClass()); } else { check(Object->GetTypedOuter<AActor>() != nullptr); FUnrealObjectRef ObjectRef = NetDriver->PackageMap->GetUnrealObjectRefFromObject(Object); check(ObjectRef.IsValid()); return ComponentToClassInfoMap[ObjectRef.Offset].Get(); } } const FClassInfo& USpatialClassInfoManager::GetClassInfoByComponentId(Worker_ComponentId ComponentId) { if (!ComponentToClassInfoMap.Contains(ComponentId)) { TryCreateClassInfoForComponentId(ComponentId); } TSharedRef<FClassInfo> Info = ComponentToClassInfoMap.FindChecked(ComponentId); return Info.Get(); } UClass* USpatialClassInfoManager::GetClassByComponentId(Worker_ComponentId ComponentId) { TSharedRef<FClassInfo> Info = ComponentToClassInfoMap.FindChecked(ComponentId); if (UClass* Class = Info->Class.Get()) { return Class; } else { UE_LOG(LogSpatialClassInfoManager, Warning, TEXT("Class corresponding to component %d has been unloaded! Will try to reload based on the component id."), ComponentId); // The weak pointer to the class stored in the FClassInfo will be the same as the one used as the key in ClassInfoMap, so we can use it to clean up the old entry. ClassInfoMap.Remove(Info->Class); // The old references in the other maps (ComponentToClassInfoMap etc) will be replaced by reloading the info (as a part of TryCreateClassInfoForComponentId). TryCreateClassInfoForComponentId(ComponentId); TSharedRef<FClassInfo> NewInfo = ComponentToClassInfoMap.FindChecked(ComponentId); if (UClass* NewClass = NewInfo->Class.Get()) { return NewClass; } else { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Could not reload class for component %d!"), ComponentId); } } return nullptr; } uint32 USpatialClassInfoManager::GetComponentIdForClass(const UClass& Class) const { const FString ClassPath = Class.GetPathName(); if (const FActorSchemaData* ActorSchemaData = SchemaDatabase->ActorClassPathToSchema.Find(Class.GetPathName())) { return ActorSchemaData->SchemaComponents[SCHEMA_Data]; } return SpatialConstants::INVALID_COMPONENT_ID; } TArray<Worker_ComponentId> USpatialClassInfoManager::GetComponentIdsForClassHierarchy(const UClass& BaseClass, const bool bIncludeDerivedTypes /* = true */) const { TArray<Worker_ComponentId> OutComponentIds; check(SchemaDatabase); if (bIncludeDerivedTypes) { for (TObjectIterator<UClass> It; It; ++It) { const UClass* Class = *It; check(Class); if (Class->IsChildOf(&BaseClass)) { const Worker_ComponentId ComponentId = GetComponentIdForClass(*Class); if (ComponentId != SpatialConstants::INVALID_COMPONENT_ID) { OutComponentIds.Add(ComponentId); } } } } else { const uint32 ComponentId = GetComponentIdForClass(BaseClass); if (ComponentId != SpatialConstants::INVALID_COMPONENT_ID) { OutComponentIds.Add(ComponentId); } } return OutComponentIds; } bool USpatialClassInfoManager::GetOffsetByComponentId(Worker_ComponentId ComponentId, uint32& OutOffset) { if (!ComponentToOffsetMap.Contains(ComponentId)) { TryCreateClassInfoForComponentId(ComponentId); } if (uint32* Offset = ComponentToOffsetMap.Find(ComponentId)) { OutOffset = *Offset; return true; } return false; } ESchemaComponentType USpatialClassInfoManager::GetCategoryByComponentId(Worker_ComponentId ComponentId) { if (!ComponentToCategoryMap.Contains(ComponentId)) { TryCreateClassInfoForComponentId(ComponentId); } if (ESchemaComponentType* Category = ComponentToCategoryMap.Find(ComponentId)) { return *Category; } return ESchemaComponentType::SCHEMA_Invalid; } const FRPCInfo& USpatialClassInfoManager::GetRPCInfo(UObject* Object, UFunction* Function) { check(Object != nullptr && Function != nullptr); const FClassInfo& Info = GetOrCreateClassInfoByObject(Object); const FRPCInfo* RPCInfoPtr = Info.RPCInfoMap.Find(Function); // We potentially have a parent function and need to find the child function. // This exists as it's possible in blueprints to explicitly call the parent function. if (RPCInfoPtr == nullptr) { for (auto It = Info.RPCInfoMap.CreateConstIterator(); It; ++It) { if (It.Key()->GetName() == Function->GetName()) { // Matching child function found. Use this for the remote function call. RPCInfoPtr = &It.Value(); break; } } } check(RPCInfoPtr != nullptr); return *RPCInfoPtr; } Worker_ComponentId USpatialClassInfoManager::GetComponentIdFromLevelPath(const FString& LevelPath) const { FString CleanLevelPath = UWorld::RemovePIEPrefix(LevelPath); if (const Worker_ComponentId* ComponentId = SchemaDatabase->LevelPathToComponentId.Find(CleanLevelPath)) { return *ComponentId; } return SpatialConstants::INVALID_COMPONENT_ID; } bool USpatialClassInfoManager::IsSublevelComponent(Worker_ComponentId ComponentId) const { return SchemaDatabase->LevelComponentIds.Contains(ComponentId); } const TMap<float, Worker_ComponentId>& USpatialClassInfoManager::GetNetCullDistanceToComponentIds() const { return SchemaDatabase->NetCullDistanceToComponentId; } const TArray<Worker_ComponentId>& USpatialClassInfoManager::GetComponentIdsForComponentType(const ESchemaComponentType ComponentType) const { switch (ComponentType) { case ESchemaComponentType::SCHEMA_Data: return SchemaDatabase->DataComponentIds; case ESchemaComponentType::SCHEMA_OwnerOnly: return SchemaDatabase->OwnerOnlyComponentIds; case ESchemaComponentType::SCHEMA_Handover: return SchemaDatabase->HandoverComponentIds; default: UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Component type %d not recognised."), ComponentType); checkNoEntry(); static const TArray<Worker_ComponentId> EmptyArray; return EmptyArray; } } const FClassInfo* USpatialClassInfoManager::GetClassInfoForNewSubobject(const UObject* Object, Worker_EntityId EntityId, USpatialPackageMapClient* PackageMapClient) { const FClassInfo* Info = nullptr; const FClassInfo& SubobjectInfo = GetOrCreateClassInfoByClass(Object->GetClass()); // Find the first ClassInfo relating to a dynamic subobject // which has not been used on this entity. for (const auto& DynamicSubobjectInfo : SubobjectInfo.DynamicSubobjectInfo) { if (!PackageMapClient->GetObjectFromUnrealObjectRef(FUnrealObjectRef(EntityId, DynamicSubobjectInfo->SchemaComponents[SCHEMA_Data])).IsValid()) { Info = &DynamicSubobjectInfo.Get(); break; } } // If all ClassInfos are used up, we error. if (Info == nullptr) { const AActor* Actor = Cast<AActor>(PackageMapClient->GetObjectFromEntityId(EntityId)); UE_LOG(LogSpatialPackageMap, Error, TEXT("Too many dynamic subobjects of type %s attached to Actor %s! Please increase" " the max number of dynamically attached subobjects per class in the SpatialOS runtime settings."), *Object->GetClass()->GetName(), *GetNameSafe(Actor)); } return Info; } Worker_ComponentId USpatialClassInfoManager::GetComponentIdForNetCullDistance(float NetCullDistance) const { if (const uint32* ComponentId = SchemaDatabase->NetCullDistanceToComponentId.Find(NetCullDistance)) { return *ComponentId; } return SpatialConstants::INVALID_COMPONENT_ID; } bool USpatialClassInfoManager::IsNetCullDistanceComponent(Worker_ComponentId ComponentId) const { return SchemaDatabase->NetCullDistanceComponentIds.Contains(ComponentId); } bool USpatialClassInfoManager::IsGeneratedQBIMarkerComponent(Worker_ComponentId ComponentId) const { return IsSublevelComponent(ComponentId) || IsNetCullDistanceComponent(ComponentId); } void USpatialClassInfoManager::QuitGame() { #if WITH_EDITOR // There is no C++ method to quit the current game, so using the Blueprint's QuitGame() that is calling ConsoleCommand("quit") // Note: don't use RequestExit() in Editor since it would terminate the Engine loop UKismetSystemLibrary::QuitGame(NetDriver->GetWorld(), nullptr, EQuitPreference::Quit, false); #else FGenericPlatformMisc::RequestExit(false); #endif } Worker_ComponentId USpatialClassInfoManager::ComputeActorInterestComponentId(const AActor* Actor) const { check(Actor); const AActor* ActorForRelevancy = Actor; // bAlwaysRelevant takes precedence over bNetUseOwnerRelevancy - see AActor::IsNetRelevantFor while (!ActorForRelevancy->bAlwaysRelevant && ActorForRelevancy->bNetUseOwnerRelevancy && ActorForRelevancy->GetOwner() != nullptr) { ActorForRelevancy = ActorForRelevancy->GetOwner(); } if (ActorForRelevancy->bAlwaysRelevant) { return SpatialConstants::ALWAYS_RELEVANT_COMPONENT_ID; } if (GetDefault<USpatialGDKSettings>()->bEnableNetCullDistanceInterest) { Worker_ComponentId NCDComponentId = GetComponentIdForNetCullDistance(ActorForRelevancy->NetCullDistanceSquared); if (NCDComponentId != SpatialConstants::INVALID_COMPONENT_ID) { return NCDComponentId; } const AActor* DefaultActor = ActorForRelevancy->GetClass()->GetDefaultObject<AActor>(); if (ActorForRelevancy->NetCullDistanceSquared != DefaultActor->NetCullDistanceSquared) { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Could not find Net Cull Distance Component for distance %f, processing Actor %s via %s, because its Net Cull Distance is different from its default one."), ActorForRelevancy->NetCullDistanceSquared, *Actor->GetPathName(), *ActorForRelevancy->GetPathName()); return ComputeActorInterestComponentId(DefaultActor); } else { UE_LOG(LogSpatialClassInfoManager, Error, TEXT("Could not find Net Cull Distance Component for distance %f, processing Actor %s via %s. Have you generated schema?"), ActorForRelevancy->NetCullDistanceSquared, *Actor->GetPathName(), *ActorForRelevancy->GetPathName()); } } return SpatialConstants::INVALID_COMPONENT_ID; }
33.051071
274
0.78053
Bowbee
c54e33846ba8b0c9de804d1272eac0afc7165ed7
2,309
cpp
C++
src/NetComponent.cpp
ustisha/ArduinoNet
1aca2b7e60e6035851ba446a123e9a3175fe9d8c
[ "MIT" ]
null
null
null
src/NetComponent.cpp
ustisha/ArduinoNet
1aca2b7e60e6035851ba446a123e9a3175fe9d8c
[ "MIT" ]
null
null
null
src/NetComponent.cpp
ustisha/ArduinoNet
1aca2b7e60e6035851ba446a123e9a3175fe9d8c
[ "MIT" ]
null
null
null
#include "../include/NetComponent.h" NetComponent::NetComponent(SmartNet *n, uint8_t sp, uint8_t max) : sport(sp), i(0), maxCmp(max), sleepTime(0), rcvr(new R[max]{}) { sender = n->sender; n->addNetComponent(this); } /** * Attach receiver data to network component. * @param n Network carrier. * @param r Receiver id. * @param rp Receiver port. * @param c Command to send. * @param t Timeout in seconds. */ void NetComponent::addReceiver(RadioInterface *n, uint8_t r, uint8_t rp, uint8_t c, float t) { if (i >= maxCmp) { IF_SERIAL_DEBUG(PSTR("[NetComponent::addReceiver] Receiver limit reached\n")); return; } rcvr[i].network = n; rcvr[i].receiver = r; rcvr[i].rport = rp; rcvr[i].timeout = uint32_t(t * 1000); rcvr[i].cmd = c; rcvr[i].last = millis(); IF_SERIAL_DEBUG(printf_P(PSTR("[NetComponent::addReceiver] Idx: %d\n"), i)); i++; } void NetComponent::tick(uint16_t sleep) { sleepTime += sleep; unsigned long m; m = millis() + sleepTime; for (int i = 0; i < maxCmp; i++) { if (rcvr[i].network != nullptr && (m >= (rcvr[i].last + rcvr[i].timeout) || rcvr[i].last < rcvr[i].timeout)) { rcvr[i].last += rcvr[i].timeout; IF_SERIAL_DEBUG(printf_P(PSTR("[NetComponent::tick] By timeout. Idx: %d\n"), i)); sendCommandData(rcvr[i].network, rcvr[i].receiver, rcvr[i].rport, rcvr[i].cmd); } // @todo Проверить как работает таймер при переполнении millis(); /*if (rcvr[i].receiver != 0 && millis() < rcvr[i].last) { rcvr[i].last = m; }*/ } } void NetComponent::receiveHandle(Packet *p) { if (p->getReceiverPort() == this->sport) { receiveCommandData(p); } } void NetComponent::sendPacket(RadioInterface *n, uint8_t r, uint8_t rp, uint8_t cmd, long data) const { Packet p{}; p.setSender(sender); p.setSenderPort(sport); p.setReceiver(r); p.setReceiverPort(rp); p.setCommand(cmd); p.setData(data); n->sendData(&p); }
33.463768
118
0.535297
ustisha
c54e3e441f094e8870973a721cb53765de2cfe52
793
hpp
C++
include/RED4ext/Types/generated/game/data/SimpleValueNode.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
1
2021-02-01T23:07:50.000Z
2021-02-01T23:07:50.000Z
include/RED4ext/Types/generated/game/data/SimpleValueNode.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
null
null
null
include/RED4ext/Types/generated/game/data/SimpleValueNode.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
null
null
null
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/REDhash.hpp> #include <RED4ext/Types/SimpleTypes.hpp> #include <RED4ext/Types/generated/game/data/SimpleValueNodeValueType.hpp> #include <RED4ext/Types/generated/game/data/ValueDataNode.hpp> namespace RED4ext { namespace game::data { struct SimpleValueNode : game::data::ValueDataNode { static constexpr const char* NAME = "gamedataSimpleValueNode"; static constexpr const char* ALIAS = NAME; game::data::SimpleValueNodeValueType type; // 98 uint8_t unk9C[0xA0 - 0x9C]; // 9C CString data; // A0 uint8_t unkC0[0xD0 - 0xC0]; // C0 }; RED4EXT_ASSERT_SIZE(SimpleValueNode, 0xD0); } // namespace game::data } // namespace RED4ext
28.321429
73
0.742749
Cyberpunk-Extended-Development-Team
c54f1cb28753638b457914b2b2a653e2cb2ed961
6,072
hpp
C++
include/codegen/include/UnityEngine/ParticleSystem_MainModule.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
1
2021-11-12T09:29:31.000Z
2021-11-12T09:29:31.000Z
include/codegen/include/UnityEngine/ParticleSystem_MainModule.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
null
null
null
include/codegen/include/UnityEngine/ParticleSystem_MainModule.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
2
2021-10-03T02:14:20.000Z
2021-11-12T09:29:36.000Z
// Autogenerated from CppHeaderCreator on 7/27/2020 3:10:33 PM // Created by Sc2ad // ========================================================================= #pragma once #pragma pack(push, 8) // Begin includes // Including type: System.ValueType #include "System/ValueType.hpp" // Including type: UnityEngine.ParticleSystem #include "UnityEngine/ParticleSystem.hpp" #include "utils/il2cpp-utils.hpp" // Completed includes // Begin forward declares // Completed forward declares // Type namespace: UnityEngine namespace UnityEngine { // Autogenerated type: UnityEngine.ParticleSystem/MainModule struct ParticleSystem::MainModule : public System::ValueType { public: // UnityEngine.ParticleSystem m_ParticleSystem // Offset: 0x0 UnityEngine::ParticleSystem* m_ParticleSystem; // Creating value type constructor for type: MainModule MainModule(UnityEngine::ParticleSystem* m_ParticleSystem_ = {}) : m_ParticleSystem{m_ParticleSystem_} {} // System.Void .ctor(UnityEngine.ParticleSystem particleSystem) // Offset: 0xA5BC60 static ParticleSystem::MainModule* New_ctor(UnityEngine::ParticleSystem* particleSystem); // public System.Single get_duration() // Offset: 0xA5BC68 float get_duration(); // public System.Boolean get_loop() // Offset: 0xA5BCA8 bool get_loop(); // public UnityEngine.ParticleSystem/MinMaxCurve get_startDelay() // Offset: 0xA5BCE8 UnityEngine::ParticleSystem::MinMaxCurve get_startDelay(); // public UnityEngine.ParticleSystem/MinMaxCurve get_startLifetime() // Offset: 0xA5BD54 UnityEngine::ParticleSystem::MinMaxCurve get_startLifetime(); // public System.Void set_startLifetime(UnityEngine.ParticleSystem/MinMaxCurve value) // Offset: 0xA5BDC0 void set_startLifetime(UnityEngine::ParticleSystem::MinMaxCurve value); // public UnityEngine.ParticleSystem/MinMaxCurve get_startSpeed() // Offset: 0xA5BE18 UnityEngine::ParticleSystem::MinMaxCurve get_startSpeed(); // public System.Void set_startSpeedMultiplier(System.Single value) // Offset: 0xA5BE84 void set_startSpeedMultiplier(float value); // public UnityEngine.ParticleSystem/MinMaxGradient get_startColor() // Offset: 0xA5BED4 UnityEngine::ParticleSystem::MinMaxGradient get_startColor(); // public System.Void set_startColor(UnityEngine.ParticleSystem/MinMaxGradient value) // Offset: 0xA5BF58 void set_startColor(UnityEngine::ParticleSystem::MinMaxGradient value); // public System.Int32 get_maxParticles() // Offset: 0xA5BFC0 int get_maxParticles(); // public System.Void set_maxParticles(System.Int32 value) // Offset: 0xA5C000 void set_maxParticles(int value); // static private System.Single get_duration_Injected(UnityEngine.ParticleSystem/MainModule _unity_self) // Offset: 0x1952BDC static float get_duration_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self); // static private System.Boolean get_loop_Injected(UnityEngine.ParticleSystem/MainModule _unity_self) // Offset: 0x1952C5C static bool get_loop_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self); // static private System.Void get_startDelay_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxCurve ret) // Offset: 0x1952D08 static void get_startDelay_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxCurve& ret); // static private System.Void get_startLifetime_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxCurve ret) // Offset: 0x1952DC4 static void get_startLifetime_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxCurve& ret); // static private System.Void set_startLifetime_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxCurve value) // Offset: 0x1952E64 static void set_startLifetime_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxCurve& value); // static private System.Void get_startSpeed_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxCurve ret) // Offset: 0x1952F20 static void get_startSpeed_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxCurve& ret); // static private System.Void set_startSpeedMultiplier_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, System.Single value) // Offset: 0x1952FC0 static void set_startSpeedMultiplier_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, float value); // static private System.Void get_startColor_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxGradient ret) // Offset: 0x1953094 static void get_startColor_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxGradient& ret); // static private System.Void set_startColor_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, UnityEngine.ParticleSystem/MinMaxGradient value) // Offset: 0x1953134 static void set_startColor_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, UnityEngine::ParticleSystem::MinMaxGradient& value); // static private System.Int32 get_maxParticles_Injected(UnityEngine.ParticleSystem/MainModule _unity_self) // Offset: 0x19531C4 static int get_maxParticles_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self); // static private System.Void set_maxParticles_Injected(UnityEngine.ParticleSystem/MainModule _unity_self, System.Int32 value) // Offset: 0x1953254 static void set_maxParticles_Injected(UnityEngine::ParticleSystem::MainModule& _unity_self, int value); }; // UnityEngine.ParticleSystem/MainModule } DEFINE_IL2CPP_ARG_TYPE(UnityEngine::ParticleSystem::MainModule, "UnityEngine", "ParticleSystem/MainModule"); #pragma pack(pop)
61.959184
157
0.783597
Futuremappermydud
c550c83eae675be960d46a2ca7e1702591d13d7a
2,563
hpp
C++
src/gui/cwidgets/libtree.hpp
mscatto/ocelot
6ca57f7611178dd289314a45745c041f7de2f7fd
[ "MIT" ]
1
2021-04-29T22:27:11.000Z
2021-04-29T22:27:11.000Z
src/gui/cwidgets/libtree.hpp
mscatto/ocelot
6ca57f7611178dd289314a45745c041f7de2f7fd
[ "MIT" ]
null
null
null
src/gui/cwidgets/libtree.hpp
mscatto/ocelot
6ca57f7611178dd289314a45745c041f7de2f7fd
[ "MIT" ]
null
null
null
/* * The MIT License (MIT) * Copyright (c) 2018 Matheus Scattolin Anselmo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the “Software”), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * The Software is provided “as is”, without warranty of any kind, express or * implied, including but not limited to the warranties of merchantability, * fitness for a particular purpose and noninfringement. In no event shall the * authors or copyright holders be liable for any claim, damages or other * liability, whether in an action of contract, tort or otherwise, arising from, * out of or in connection with the software or the use or other dealings in the * Software. */ #ifndef LIBTREE_HPP #define LIBTREE_HPP #include <QFrame> #include <QObject> #include <QPushButton> #include <QTreeWidget> #include <QWidget> #include "src/gui/mwindow.hpp" #include "src/gui/workbench.hpp" #include "src/gui/dialogs/tageditor.hpp" #include "src/library.hpp" #include "src/vars.hpp" class libtree : public QFrame { Q_OBJECT private: enum CLICKBEHAVIOUR { REPLACE, REPLACE_AND_PLAY, APPEND_CUR, APPEND_AND_PLAY, APPEND_OTHER, SEND_TRANSC, EDIT_TAGS, }; tageditor* tagedit; mwindow* win; workbench* wb; QMenu* ctx; QTreeWidget* tree; vars* jag; CLICKBEHAVIOUR mclick; CLICKBEHAVIOUR dclick; void init(); void showctx (const QPoint& pos); void recurtree (QTreeWidgetItem* parent, QStringList levels, QString conditions, QSqlDatabase* db); void listchildren (QTreeWidgetItem* item, QStringList* children); QStringList extract (QString vars); private slots: void tageditor_spawn(); void transc_append (bool discard = false); void transc_replace(); void refresh_config(); void doubleclick (QTreeWidgetItem* item); void middleclick (QTreeWidgetItem* item); public slots: void populate (QSqlDatabase* db); signals: void dispatch (QStringList* l); void transc_dispatch (QStringList* l, bool discard); void playlist_set (const QStringList files); public: libtree (mwindow* win, workbench* wb, vars* jag); ~libtree(); }; #endif // LIBTREE_HPP
29.45977
100
0.752243
mscatto
c556d68652b59cb6596b9630343f986e03789fbb
1,181
hpp
C++
src/framework/mtb/pal/gpio-mtb.hpp
OlafFilies/magnetic-angle-sensor
87618e9df29ab278e2af5eea7d9120769e197f9f
[ "MIT" ]
39
2019-01-08T23:35:11.000Z
2022-03-13T23:43:04.000Z
src/framework/mtb/pal/gpio-mtb.hpp
OlafFilies/magnetic-angle-sensor
87618e9df29ab278e2af5eea7d9120769e197f9f
[ "MIT" ]
16
2018-11-18T19:19:41.000Z
2022-02-14T14:09:37.000Z
src/framework/mtb/pal/gpio-mtb.hpp
OlafFilies/magnetic-angle-sensor
87618e9df29ab278e2af5eea7d9120769e197f9f
[ "MIT" ]
21
2019-01-18T01:32:47.000Z
2022-02-19T15:51:08.000Z
/** * @file gpio-mtb.hpp * @brief MTB PAL for the GPIO * @date Spt 2020 * @copyright Copyright (c) 2019-2020 Infineon Technologies AG * * SPDX-License-Identifier: MIT */ #ifndef GPIO_MTB_HPP_ #define GPIO_MTB_HPP_ #include "../../../config/tle5012-conf.hpp" #if (TLE5012_FRAMEWORK == TLE5012_FRMWK_MTB) #include "../../../pal/gpio.hpp" #include <mtb_platform.h> /** * @addtogroup mtbPal * @{ */ class GPIOMtb : virtual public GPIO { private: #define UNUSED_PIN (mtb_gpio_t)(MTB_GPIO_51 + 1) /**< Unused pin */ mtb_gpio_t pin; /**< GPIO number */ mtb_gpio_config_t config; /**< GPIO configuration */ VLogic_t logic; /**< Pin logic */ public: GPIOMtb(); GPIOMtb(mtb_gpio_t pin, mtb_gpio_config_t config, VLogic_t logic); ~GPIOMtb(); Error_t init(); Error_t deinit(); VLevel_t read(); Error_t write(VLevel_t level); Error_t enable(); Error_t disable(); }; /** @} */ #endif /** TLE5012_FRAMEWORK **/ #endif /** GPIO_MTB_HPP_ **/
23.156863
93
0.545301
OlafFilies