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 108 | 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 67k ⌀ | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0780d8cca617283b7fd75912dcc29c9459a28f07 | 2,744 | cpp | C++ | core_ui/sim/accelerometer_widget.cpp | Siddhant-K-code/darwin | 86781c9dabeceda7f8666bb1bb4b5ca7d725d81d | [
"Apache-2.0"
] | 94 | 2018-11-24T20:07:07.000Z | 2022-03-13T01:34:45.000Z | core_ui/sim/accelerometer_widget.cpp | JJ/darwin | d5519b6d542c179cbc0f6575dcfce25e68e2f1df | [
"Apache-2.0"
] | 3 | 2020-11-21T04:49:43.000Z | 2021-02-09T18:15:23.000Z | core_ui/sim/accelerometer_widget.cpp | JJ/darwin | d5519b6d542c179cbc0f6575dcfce25e68e2f1df | [
"Apache-2.0"
] | 18 | 2018-11-24T20:07:21.000Z | 2021-12-19T10:48:57.000Z | // Copyright The Darwin Neuroevolution Framework Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "accelerometer_widget.h"
#include <QLineF>
#include <QPainter>
#include <QPen>
#include <QPointF>
#include <QRectF>
namespace physics_ui {
AccelerometerWidget::AccelerometerWidget(QWidget* parent) : Canvas(parent) {
setViewport(QRectF(-kCanvasWidth / 2, kCanvasHeight / 2, kCanvasWidth, -kCanvasHeight));
}
void AccelerometerWidget::setSensor(const sim::Accelerometer* sensor) {
sensor_ = sensor;
update();
}
void AccelerometerWidget::paintEvent(QPaintEvent* event) {
Canvas::paintEvent(event);
if (sensor_ != nullptr) {
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing |
QPainter::SmoothPixmapTransform |
QPainter::HighQualityAntialiasing);
// background (whole widget)
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::white);
painter.drawRect(rect());
painter.setTransform(transformFromViewport());
const QPen vector_pen(Qt::darkGreen, kVectorWidth, Qt::SolidLine, Qt::RoundCap);
QRectF sensor_rect(
-kSensorWidth / 2, -kSensorHeight / 2, kSensorWidth, kSensorHeight);
// axes
painter.setPen(QPen(Qt::lightGray, 0));
painter.setBrush(Qt::NoBrush);
painter.drawLine(QLineF(0, -kCanvasHeight / 2, 0, kCanvasHeight / 2));
painter.drawLine(QLineF(-kCanvasWidth / 2, 0, kCanvasWidth / 2, 0));
painter.drawEllipse(sensor_rect);
// angular acceleration
sensor_rect.adjust(+kSkinSize, +kSkinSize, -kSkinSize, -kSkinSize);
const float arc_angle = -sensor_->angularAcceleration() * 90;
painter.setPen(vector_pen);
painter.drawArc(sensor_rect, -90 * 16, int(arc_angle * 16));
// linear acceleration
const b2Vec2 linear_acceleration = sensor_->linearAcceleration() * kVectorLength;
painter.setPen(vector_pen);
painter.drawLine(QLineF(0, 0, linear_acceleration.x, linear_acceleration.y));
// inner circle
painter.setPen(QPen(Qt::lightGray, 0));
sensor_rect.adjust(+kSkinSize, +kSkinSize, -kSkinSize, -kSkinSize);
painter.drawEllipse(sensor_rect);
}
}
} // namespace physics_ui
| 33.876543 | 90 | 0.712464 | Siddhant-K-code |
0785437488fb1a85a75a4654b4cc7a4bb62777c9 | 1,778 | cpp | C++ | Visual Studio 2010/Projects/bjarneStroustrupC++PartI/object_oriented_examples/Chapter10Exercise8.cpp | Ziezi/Programming-Principles-and-Practice-Using-C-by-Bjarne-Stroustrup- | 6fd64801863e883508f15d16398744405f4f9e34 | [
"Unlicense"
] | 9 | 2018-10-24T15:16:47.000Z | 2021-12-14T13:53:50.000Z | Visual Studio 2010/Projects/bjarneStroustrupC++PartI/object_oriented_examples/Chapter10Exercise8.cpp | ChrisBKirov/Programming-Principles-and-Practice-Using-C-by-Bjarne-Stroustrup- | 6fd64801863e883508f15d16398744405f4f9e34 | [
"Unlicense"
] | null | null | null | Visual Studio 2010/Projects/bjarneStroustrupC++PartI/object_oriented_examples/Chapter10Exercise8.cpp | ChrisBKirov/Programming-Principles-and-Practice-Using-C-by-Bjarne-Stroustrup- | 6fd64801863e883508f15d16398744405f4f9e34 | [
"Unlicense"
] | 7 | 2018-10-29T15:30:37.000Z | 2021-01-18T15:15:09.000Z | /*
TITLE Concatenate two files Chapter10Exercise8.cpp
Bjarne Stroustrup "Programming: Principles and Practice Using C++"
COMMENT
Objective: Create a file that contains the concatenated data
of two other files.
Input: -
Output: -
Author: Chris B. Kirov
Date: 03.05.2015
*/
#include <iostream>
#include <fstream>
#include <string>
#include"Chapter10Exercise8.h"
void test_function();
//==========================================================================================
int main()
{
try
{
test_function();
}
catch(std::exception& e)
{
std::cerr<< e.what() << std::endl;
}
}
//==========================================================================================
/*
Function: test_function()
*/
void test_function()
{
std::string source_file_name1 = "Chapter10Exercise8File1.txt";
std::string source_file_name2 = "Chapter10Exercise8File2.txt";
std::string destination_file_name = "Chapter10Exercise8Conc.txt";
// print contents of source files
std::ifstream ifs1(source_file_name1.c_str());
if(!ifs1)
{
std::cerr <<"Can't open input file: "<< source_file_name1 <<'\n';
}
std::cout <<"Source file 1 contains:\n" << ifs1.rdbuf() <<'\n';
std::ifstream ifs2(source_file_name2.c_str());
if(!ifs1)
{
std::cerr <<"Can't open input file: "<< source_file_name2 <<'\n';
}
std::cout <<"Source file 2 contains:\n" << ifs2.rdbuf() <<'\n';
// concatenate
concatenate_two_files(source_file_name1, source_file_name2, destination_file_name);
// print contents of destination file
std::ifstream ifs3(destination_file_name.c_str());
if(!ifs1)
{
std::cerr <<"Can't open input file: "<< destination_file_name <<'\n';
}
std::cout <<"Destination file contains:\n" << ifs3.rdbuf() <<'\n';
}
| 23.706667 | 92 | 0.604612 | Ziezi |
0786f0888f05ce6e9ab1c0a1238ed5f4358a396a | 3,356 | cpp | C++ | example/timers.cpp | weiboad/adbase | d37ed32b55da24f7799be286c860e280ee0c786a | [
"Apache-2.0"
] | 62 | 2017-02-15T11:36:46.000Z | 2022-03-14T09:11:10.000Z | example/timers.cpp | AraHaan/adbase | d37ed32b55da24f7799be286c860e280ee0c786a | [
"Apache-2.0"
] | 5 | 2017-02-21T05:32:14.000Z | 2017-05-21T13:15:07.000Z | example/timers.cpp | AraHaan/adbase | d37ed32b55da24f7799be286c860e280ee0c786a | [
"Apache-2.0"
] | 22 | 2017-02-16T02:11:25.000Z | 2020-02-12T18:12:44.000Z | #include <signal.h>
#include <adbase/Net.hpp>
#include <adbase/Logging.hpp>
#include <adbase/Metrics.hpp>
adbase::metrics::Metrics* metrics = nullptr;
adbase::metrics::Timers* timers = nullptr;
adbase::EventLoop* gloop = nullptr;
void test1(void*) {
while(true) {
int num = rand() % 10000;
for (int i = 0; i < num; i++) {
if (timers != nullptr) {
adbase::metrics::Timer timer;
timer.start();
std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 2));
timers->setTimer(timer.stop());
}
}
}
}
void test(void*) {
if (metrics != nullptr) {
std::unordered_map<std::string, adbase::metrics::TimersItem> values = metrics->getTimers();
for (auto &t : values) {
adbase::metrics::MetricName name;
name = adbase::metrics::Metrics::getMetricName(t.first);
LOG_INFO << name.moduleName << "." << name.metricName << " : ";
LOG_INFO << "\tcount = " << t.second.meter.count;
LOG_INFO << "\tmean rate = " << t.second.meter.meanRate;
LOG_INFO << "\t1-minute rate = " << t.second.meter.min1Rate;
LOG_INFO << "\t5-minute rate = " << t.second.meter.min5Rate;
LOG_INFO << "\t15-minute rate = " << t.second.meter.min15Rate;
LOG_INFO << "\tmin = " << t.second.histogram.min;
LOG_INFO << "\tmax = " << t.second.histogram.max;
LOG_INFO << "\tmean = " << t.second.histogram.mean;
LOG_INFO << "\tstddev = " << t.second.histogram.stddev;
LOG_INFO << "\tmedian = " << t.second.histogram.median;
LOG_INFO << "\t75% <= " << t.second.histogram.percent75;
LOG_INFO << "\t95% <= " << t.second.histogram.percent95;
LOG_INFO << "\t98% <= " << t.second.histogram.percent98;
LOG_INFO << "\t99% <= " << t.second.histogram.percent99;
LOG_INFO << "\t99.9% <= " << t.second.histogram.percent999;
}
}
}
// {{{ static void killSignal()
static void killSignal(const int sig) {
(void)sig;
if (gloop != nullptr) {
gloop->stop();
delete gloop;
gloop = nullptr;
}
adbase::metrics::Metrics::stop();
exit(0);
}
// }}}
// {{{ static void reloadConf()
static void reloadConf(const int sig) {
(void)sig;
}
// }}}
// {{{ static void registerSignal()
static void registerSignal() {
/* 忽略Broken Pipe信号 */
signal(SIGPIPE, SIG_IGN);
/* 处理kill信号 */
signal(SIGINT, killSignal);
signal(SIGKILL, killSignal);
signal(SIGQUIT, killSignal);
signal(SIGTERM, killSignal);
signal(SIGHUP, killSignal);
signal(SIGSEGV, killSignal);
signal(SIGUSR1, reloadConf);
}
// }}}
int main(void) {
registerSignal();
adbase::EventLoop* eventloop = new adbase::EventLoop();
gloop = eventloop;
adbase::Timer timer(eventloop->getBase());
metrics = adbase::metrics::Metrics::init(&timer);
uint32_t interval = 1000;
timer.runEvery(interval, std::bind(test, std::placeholders::_1), nullptr);
timers = adbase::metrics::Metrics::buildTimers("test", "request", interval);
std::thread* t = new std::thread(std::bind(test1, std::placeholders::_1), nullptr);
eventloop->start();
t->join();
return 0;
}
| 31.961905 | 99 | 0.567938 | weiboad |
0788c566aaad9ecea5d43057eaa253fdfdcb1412 | 15,025 | hpp | C++ | client/client/src/proj/ap_type2s.hpp | oracleloyall/CommonLib | f2a092ab1b87f45cfd4470b9a87f5fd658e2d7da | [
"Apache-2.0"
] | 3 | 2019-07-03T03:16:39.000Z | 2019-12-02T08:08:43.000Z | client/client/src/proj/ap_type2s.hpp | oracleloyall/CommonLib | f2a092ab1b87f45cfd4470b9a87f5fd658e2d7da | [
"Apache-2.0"
] | null | null | null | client/client/src/proj/ap_type2s.hpp | oracleloyall/CommonLib | f2a092ab1b87f45cfd4470b9a87f5fd658e2d7da | [
"Apache-2.0"
] | null | null | null | /*
* ap_type2s.hpp
*
* Created on: 2015骞�6鏈�17鏃�
* Author: sw
*/
#ifndef PROJ_AP_TYPE2S_HPP_
#define PROJ_AP_TYPE2S_HPP_
#include "../hlib/global.hpp"
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned int __u32;
typedef unsigned long long __u64;
const __u16 H_PROTO_LOGO = 29559; // sw
const __u16 H_PROTO_UDP = 30000;
const __u8 H_PROTO_VER = 1;
const __u8 H_PROTO_NEO_VER = 2; // !!NOTICE: 鐗堟湰v2 [鏂癩
const __u16 H_PROTO_MAX_LEN = 4096;
const __u16 H_LENGTH_NEED_ZIP = 500; // 濡傛棤鐗规畩绾﹀畾锛岃秴杩囨闀垮害鑷姩鍘嬬缉
typedef __u8 msg_head_flag;
const msg_head_flag mhf_NONE = 0;
const msg_head_flag mhf_GZIP = 1;
const msg_head_flag mhf_ENCRYPT = 2;
const msg_head_flag mhf_ACK_REQED = 4;
const msg_head_flag mhf_NOT_END = 8;
const msg_head_flag mhf_ACK = 16;
typedef __u16 msg_cmd_type;
// 鐗堟湰v2
const msg_cmd_type msg_cmd_unknown = 0; //
const msg_cmd_type msg_cmd_conn_req2 = 1;// FatAP鍙戣捣锛氳繛鎺ヨ璇侊紝瀵瑰簲struct ap_conn_req;
const msg_cmd_type msg_cmd_conn_resp2 = 2; // 绠$悊鏈嶅姟鍣ㄨ繑鍥烇細鍒濆鍖栦俊鎭紝瀵瑰簲 struct ap_conn_resp;
const msg_cmd_type msg_cmd_ap_stat2 = 3; // FatAP鍙戝嚭锛欶atAP蹇冭烦锛屽搴� struct ap_stat;
const msg_cmd_type msg_cmd_ap_dns_white2 = 4; // 绠$悊鏈嶅姟鍣ㄨ姹侳atAP淇敼鐧藉悕鍗�, 瀵瑰簲 struct ap_dns_white;
const msg_cmd_type msg_cmd_ap_dev_conf2 = 5; // 绠$悊鏈嶅姟鍣ㄨ姹侳atAP淇敼閰嶇疆, 瀵瑰簲 struct ap_conf;
const msg_cmd_type msg_cmd_ap_net_conf2 = 6; // 绠$悊鏈嶅姟鍣ㄨ姹侳atAP淇敼鐨勭綉缁滈厤缃紝瀵瑰簲ap_net_conf2
const msg_cmd_type msg_cmd_ap_upgrade2 = 7; // 璁剧疆FatAP鍗囩骇, 瀵瑰簲 struct ap_upgrade
const msg_cmd_type msg_cmd_user_stat2 = 8; // 鍙屾柟鍧囧彲鍙戝嚭锛氱鐞嗘湇鍔″櫒鍙戝嚭鍒欎慨鏀圭敤鎴蜂俊鎭� 锛孎atAP鍙戝嚭閫氬憡鐩墠鐘跺喌(涓婁笅绾裤�佸叾鍚庣殑蹇冭烦) 锛屽搴� struct user_stat;
const msg_cmd_type msg_cmd_user_action2 = 9; // FatAP鍙戝嚭锛氱敤鎴风殑鎿嶄綔锛屽搴攕truct user_action;
const msg_cmd_type msg_cmd_link_detection = 10; // 閾捐矾妫�娴嬪懡浠�
const msg_cmd_type msg_cmd_ack2 = 11; /* 鍥炲簲瀵规柟鐗瑰畾seq宸茬粡澶勭悊锛屾棤鍖呬綋銆�
鍥炲簲鍗曚竴鐨勫寘鎺ユ敹锛宻eq娌跨敤瀵规柟seq銆俵en缃负0.
鍥炲簲杩炵画澶氫釜鍖呮帴鏀讹紝seq缃负鍥炲簲鐨勯涓猻eq锛屼竴鐩村埌seq+len
鍚屾椂缁欏畾鐩墠灏氭湭鎺ユ敹鐨勯娈祍eq鍦╟rc32c
*/
const msg_cmd_type msg_cmd_conn_heartbeat2 = 12; // 鍗忚鏂瑰鏀寔UDP锛屽簲瀹氭椂鍙戯紝鏃犻渶鍥炲簲
const msg_cmd_type msg_cmd_black_list2 = 13; // 绠$悊鏈嶅姟鍣ㄨ姹侳atAP淇敼榛戝悕鍗�,瀵瑰簲鐨剆truct ap_dns_black
const msg_cmd_type msg_cmd_reboot2 = 14; // 绠$悊鏈嶅姟鍣ㄨ姹侳atAP閲嶆柊鍚姩
//
const msg_cmd_type msg_cmd_ap_auth = 50; // 璁惧娉ㄥ唽鍛戒护(閫氳鍗忚閲囩敤udp鏂瑰紡)
const msg_cmd_type msg_cmd_max = 255;
typedef struct msg_head2
{
__u16 logo; /*鏍囧織锛宻w = smartwifi */
__u8 ver; /*鐗堟湰锛屽垵濮嬩负2 */
msg_head_flag flag;/*鎵╁睍鏍囪瘑锛�
浣�1浣嶄负1琛ㄧず鍖呬綋宸插仛 gzip
浣�2浣嶄负1琛ㄧず鍖呬綋宸插姞瀵嗭紙鏆傛椂鏈鐞嗗姞瀵嗭級
浣�3浣嶄负1琛ㄧず璇ュ寘闇�瑕佺瓑寰呭搴旂殑seq鐨勬帴鏀跺洖搴旓紙UDP蹇呴』缃�1锛�
浣�4浣嶄负1琛ㄧず鍖呬綋灏氭湭瀹岀粨锛屽彂閫佹柟宸茶嚜鍔ㄥ垏鍒嗚秴闀挎暟鎹寘銆傛帴鏀惰繛缁�掑seq锛岀洿鍒版煇涓寘flag璇ヤ綅涓�0鏃讹紝姝ゅ寘浣撴柟瀹岀粨銆�
浣�5浣嶄负1琛ㄧずack鍛戒护鍥炴姤鐨剆eq鍜宻eq浠ュ墠鐨勫潎宸叉敹鍒帮紙鍙湪ack鍛戒护鏃舵湁鏁堬級
*/
msg_cmd_type cmd;/*鐢ㄤ簬鏍囪瘑鍖呬綋鍛戒护绫诲瀷锛屽彇鍊艰enum msg_cmd_type*/
__u16 len; /*鍚庢帴鏁版嵁鍖呬綋鐨勯暱搴�*/
__u32 crc32c; /*鍖呬綋鏍¢獙鍜岋紝浣跨敤SSE4.2鐨勬爣鍑嗐�傚鍖呬綋 绯籫zip澶勭悊鍚庣粨鏋滐紝姝ゆ暟鍊间负瀵筭zip缁撴灉鐨勮绠楀�� 銆�
濡傛灉cmd涓篴ck锛屽垯姝ゅ瓧娈佃〃绀烘湡鏈涘彂閫佺殑绗竴娈电殑seq*/
__u32 seq; /*鍛戒护娴佹按銆傝捣濮嬪�间负0锛屽叾鍚庤嚜鐒跺闀裤�傜敤浜庤瘑鍒摢浜涜姹傚凡缁忚鍥炲簲锛岄伩鍏嶉噸澶嶅鐞嗭紱浠ュ強涓撻棬閫氱煡鐗瑰畾seq宸茬粡澶勭悊*/
} *pmsg_head2;
const int H_HEAD_LEN2 = sizeof(msg_head2);
typedef __u16 mi_type;
const mi_type mi_unknown = 0;
const mi_type mi_h3c = 1;
const mi_type mi_huawei = 2;
const mi_type mi_threenet = 3;
const mi_type mi_zdc = 4;
const mi_type mi_raisecom = 5;
const mi_type mi_wisechoice = 6;
const mi_type mi_commsky = 7;
const mi_type mi_ewifi = 255;
const mi_type mi_telin_daemon = 65535;
typedef __u8 UDIC_type; /* Unique device identification code */
const UDIC_type UDIC_unknown = 0; /* 杩樹负鑾峰彇璁惧鍞竴鏍囪瘑鐮� */
typedef struct ap_conn_req2
{
__u32 ap_time; /* FatAP鏃堕棿 */
__u32 soft_id; /* 璁惧杞欢鍨嬪彿 65535*/
__u32 hard_id; /* 璁惧纭欢鍨嬪彿 0 */
__u32 ability; /* 璁惧鑳藉姏鎻忚堪锛�
__u8 hard_seq[64]; /*璁惧搴忓垪鍙�*/
__u8 ip[16]; /* ipv4 绌轰綑鍚庨潰12涓瓧鑺� */
__u8 mac[6];
__u16 reserved; /* */
mi_type manu_id; /*鍘傚晢浠g爜*/
UDIC_type udic[12]; /*璁惧鍞竴鏍囪瘑鐮�*/
__u8 dev_id[16];
} *pap_conn_req2;
typedef struct ap_auth
{
bool if_test; // true琛ㄧず鐢ㄤ簬娴嬭瘯娉ㄥ唽姝ラ
__u16 port; // 缃戝叧绔彛
__u8 gw_mac[6]; // 缃戝叧MAC
__u8 gw_ip[16]; // 缃戝叧鐨刬p
__u8 accout_id[20]; // 璐︽埛
__u8 passwd[20]; // 璐﹀彿瀵嗙爜
__u8 soft_ver[20]; // 鐗堟湰
__u8 seq[20]; // 涓插彿
} *pap_auth;
typedef struct ap_auth_sp
{
__u8 devid[16]; // 璁惧ID
} *pap_auth_sp;
typedef __u16 udp_type;
typedef struct UDP_Msg
{
udp_type type;
union
{
ap_auth ap_reg;
ap_auth_sp ap_req_resp;
}data;
} *pUDP_Msg;
const int AP_AUTH_LEN = sizeof(UDP_Msg);
typedef __u8 cs_type;
const cs_type cs_unknown = 0;
const cs_type cs_telecom = 1;
const cs_type cs_cinema = 2;
const cs_type cs_supermarket = 3;
const cs_type cs_goverment = 4;
const cs_type cs_mall = 5;
const cs_type cs_cafe = 6;
const cs_type cs_bar = 7;
const cs_type cs_college = 8;
const cs_type cs_test = 254;
const cs_type cs_max = 255;
typedef __u8 ap_conn_ret;
const ap_conn_ret acr_OK = 0;
const ap_conn_ret acr_DENIED = 1;
const ap_conn_ret acr_REDIRECT = 2;
typedef __u8 ap_auth_mode;
const ap_auth_mode aam_PASS = 0;
const ap_auth_mode aam_AUTH = 1;
typedef __u8 ap_audit_mode;
const ap_audit_mode aam_NONE = 0;
const ap_audit_mode aam_AUDIT = 1;
typedef struct ap_conn_resp2
{
ap_conn_ret result; /* 璁よ瘉缁撴灉锛�0=閫氳繃锛�1=鎷掔粷锛寃hite涓哄鍚戝湴鍧�锛�2=瑕佹眰杞叾浠栫鐞嗘湇鍔″櫒锛�
搴旇浆鎺uth_srv涓潪璇ョ鐞嗘湇鍔″櫒鐨勫叾浠栨湇鍔″櫒 */
ap_auth_mode auth_mode; /* 缁堢璁よ瘉妯″紡锛�0=鐩存帴鏀捐锛�1=瑕佹眰璁よ瘉 */
ap_audit_mode audit_mode; /* 瀹¤妯″紡锛�0=涓嶄紶鐢ㄦ埛璁块棶鐨刄RL锛�1=鍥炰紶鐢ㄦ埛璁块棶鐨刄RL */
cs_type serv_type; /* 鍦烘墍绫诲瀷锛屽彇鍊煎弬鑰僥num cs_type锛� 濡傦紝閰掑簵銆佽嵂搴椼�佸皬鍖虹瓑绛� */
UDIC_type udic; /* 璁惧鍞竴琛ㄧず鐮� */
__u16 reserved1; /* 鏈�澶т紶杈撳崟鍏� */
__u16 ap_interval; /* FatAP涓庣鐞嗘湇鍔″櫒闂寸殑蹇冭烦鏃堕棿锛屽崟浣嶇锛岄粯璁や负60绉� */
__u16 user_interval; /* 缁堢鐢ㄦ埛姹囨姤鐨勫績璺虫椂闂达紝鍗曚綅绉掞紝榛樿涓�60绉� */
__u16 audit_interval; /* 鐢ㄦ埛琛屼负姹囨姤锛屽崟浣嶇锛岄粯璁や负60绉� */
__u8 auth_srv[64]; /* 绠$悊鏈嶅姟鍣ㄥ湴鍧�锛屾瘮濡�: www.auth_srv.com:8080, 0d鍒嗗壊锛岀浜屼釜鍙婁互鍚庝负beiyong */
__u8 audit_srv[64]; /* 瀹¤鏈嶅姟鍣紝鐩墠鏆傛椂淇濈暀涓嶇敤锛�0d鍒嗗壊锛�*/
__u8 def_302[128]; /* 榛樿璺宠浆鍦板潃锛屽湪struct user_stat 涓病鏈夋寚瀹氳烦杞湴鍧�鏃朵娇鐢� */
__u16 white_len; /* 鍩熷悕榛戠櫧鍚嶅崟闀垮害 鏈�闀夸负65535 */
__u16 black_len; /* 鍩熷悕榛戝悕鍗曢暱搴� 鏈�闀夸负65535 */
__u8 white[0]; /* 鍩熷悕鐧藉悕鍗曪紝鍩熷悕闂翠互鍒嗗彿鍒嗛殧 */
__u8 black[0]; /* 鍩熷悕榛戝悕鍗曪紝鍩熷悕闂翠互鍒嗗彿鍒嗛殧 */
} *pap_conn_resp2;
typedef __u8 user_stat_type; // 鐢ㄦ埛鐘舵��
const user_stat_type user_unknown = 0;
const user_stat_type user_on = 1; // 鐢ㄦ埛宸蹭笂绾挎湭鏀捐
const user_stat_type user_pass = 2; // 鐢ㄦ埛宸叉斁琛�
const user_stat_type user_off = 3; // 鐢ㄦ埛宸蹭笅绾�
const user_stat_type user_max = 255;
typedef struct user_stat2
{
user_stat_type stat;// __u8
__u8 url_len; // 瀵瑰簲鍖呯殑缁撳熬鏈夊闀縐RL
__u8 mac[6];
__u8 user_ip[16]; // IPv4鏃跺悗闈�12瀛楄妭鐣�0
__u64 incoming; // 涓嬭娴侀噺璁℃暟锛屽崟浣嶄负瀛楄妭
__u64 outgoing; // 涓婅娴侀噺璁℃暟锛屽崟浣嶄负瀛楄妭
__u64 ibw_limit; // 涓嬭甯﹀闄愬埗锛屽崟浣嶄负瀛楄妭锛�-1琛ㄧず涓嶉檺
__u64 obw_limit; // 涓婅甯﹀闄愬埗锛屽崟浣嶄负瀛楄妭锛�-1琛ㄧず涓嶉檺
__u32 online_date; // unix鏃堕棿鎴筹紝0琛ㄧず鏃犺褰�
__u32 offline_date; // unix鏃堕棿鎴筹紝0琛ㄧず鏃犺褰�
__u32 duration; // 宸茬粡涓婄嚎鏃堕棿锛屽崟浣嶄负绉掞紝鐘舵�佹敼鍙橈紙涓婄嚎/鏀捐/韪㈠嚭锛夋椂褰�0
__u16 ses_limit; // tcp session 闄愬埗锛�0=涓嶉檺
__u16 udp_limit; // udp session 闄愬埗锛�0=涓嶉檺
__u8 url_data[0]; // URL鏁版嵁,缁堢璁よ瘉鎴愬姛鍚庨渶瑕佽烦杞殑椤甸潰銆傝嫢涓嶅瓨鍦紝鍒欎娇鐢ㄩ粯璁よ烦杞〉闈�
} *puser_stat2;
typedef __u8 wlan_visiblity;
const wlan_visiblity wv_broadcast = 0;
const wlan_visiblity wv_hidden = 1;
typedef __u8 wlan_enable;
const wlan_enable we_enable = 1;
const wlan_enable we_disable = 0;
typedef __u8 wlan_ssid_encoding;
const wlan_ssid_encoding wse_gb2312 = 0; // for PC
const wlan_ssid_encoding wse_utf8 = 1; // for Phone
typedef __u8 wlan_type;
const wlan_type wt_unknown = 0;
const wlan_type wt_b = 1;
const wlan_type wt_g = 2;
const wlan_type wt_n = 4;
const wlan_type wt_a = 8;
const wlan_type wt_bg = 3;
const wlan_type wt_bgn = 7;
const wlan_type wt_abgn = 15;
#define DEL_WLAN 0x80
typedef struct wlan_entity2
{
__u8 wlan_ssid_len;
__u8 wlan_ssid[255];
__u8 wlan_index; // 绱㈠紩锛岀敤浜庢棩鍚庢搷浣� 鏈�楂樹綅缃�1锛岃〃绀哄垹闄ょ浉搴攚lan
wlan_visiblity wlan_hidden; // 1=hidden,0=broadcast
wlan_enable wlan_enabled; // 1=enable,0=disable
wlan_ssid_encoding wlan_utf8; // 1=utf8,0=gbk
ap_auth_mode auth_mode; // 缁堢璁よ瘉妯″紡锛�0=鐩存帴鏀捐锛�1=瑕佹眰璁よ瘉
__u8 encrtpt_mode; // 鍔犲瘑绠楁硶 0=涓嶅姞瀵� 1=AES 2=TKIP
__u8 wlan_txpower; // : 4
__u8 wlan_channel;
__u8 wlan_channel2; // 0=鏈睍棰�
__u8 session_limit; // 鎺ュ叆缁堢鏁伴噺闄愬埗
wlan_type dev_type; // abgn = 15
__u8 wlan_vlan; // : 8
wlan_enable dhcp_enabled; // 1=enable,0=disable
__u8 sofe_mode; // 0=unkown 1=NO,2=WEp 3=WPA
__u8 secret_key[20]; // 鏅�歸ifi妯″紡涓�,闇�瑕佽緭鍏ョ殑瀵嗙爜
__u8 dhcp_start[16]; // DHCP 璧峰IP鍦板潃
__u8 dhcp_end[16]; // DHCP 缁堟IP鍦板潃
__u8 wlan_ip[16]; //
__u16 white_len; // 鍚庨殢鐧藉悕鍗曢暱搴�
__u16 black_len; // 鍚庨殢榛戝悕鍗曢暱搴�
__u8 whitelist[0];
__u8 blacklist[0];
} *pwlan_entity2;
typedef __u8 wan_stat;
const wan_stat ws_unknown = 0;
const wan_stat ws_connecting = 1;
const wan_stat ws_connected = 2;
const wan_stat ws_disabled = 3;
typedef __u8 wan_mode;
const wan_mode wm_unknown = 0;
const wan_mode wm_PPPoE = 1;
const wan_mode wm_DHCP = 2;
const wan_mode wm_static = 3;
typedef struct wan_entity2
{
__u8 wan_index;
wan_stat wan_status; // 1=enable,0=disable
__u8 wan_mac[6];
__u8 wan_ip[16];
__u8 wan_gw[16];
__u8 wan_mask[16];
wan_mode conn_mode; // 0=unknown,1=PPPoE,2=DHCP,3=static : 0
wlan_enable auto_dns; // 0=disabled,1=enabled
__u8 dns_mode; // 1=鑷姩鑾峰彇,0=鎵嬪姩鑾峰彇
__u16 wan_mtu;
__u32 reserved;
__u8 host_len;
__u8 host[31];
__u8 dns_count; // 璁板綍鏈夊灏慸ns鏈嶅姟鍣�
__u8 dns[255];// 褰撴湁澶氫釜dns鏈嶅姟鍣ㄦ椂,ip鍦板潃绱у瘑鎺掑垪娌℃湁鍒嗛殧绗�,鍒ゆ柇涓嬩竴涓猧p鏄惁涓�0,鍒ゆ柇dns鍒楄〃鏄惁缁撴潫
__u8 usr_len; // pppoe name
__u8 usr[31];
__u8 pswd_len;
__u8 pswd[31];
} *pwan_entity2;
typedef __u8 vlan_mode;
const vlan_mode vm_unknown = 0;
const vlan_mode vm_by_port = 1;
const vlan_mode vm_by_mac = 2;
const vlan_mode vm_by_prot = 3; //鍗忚
const vlan_mode vn_by_ip = 4;
typedef union vlan_node
{
__u16 port;
__u8 mac[6];
__u8 prot[8];
} *pvlan_node;
#define DEL_VLAN 0x80
typedef struct vlan_entity
{
__u8 vlan_index; // 鏈�楂樹綅缃�1锛岃〃绀哄垹闄ゅ搴旂殑vlan
// 1 0 0 0 0 0 0 2 琛ㄧず鍒犻櫎id涓�2 鐨剉lan
ap_auth_mode auth_mode; // 缁堢璁よ瘉妯″紡锛�0=鐩存帴鏀捐锛�1=瑕佹眰璁よ瘉
ap_audit_mode audit_mode; // 瀹¤妯″紡锛�0=涓嶄紶鐢ㄦ埛璁块棶鐨刄RL锛�1=鍥炰紶鐢ㄦ埛璁块棶鐨刄RL
vlan_mode dev_mode; // vlan 鍒掑垎渚濇嵁
__u32 vlan_down_bw; // vlan鏁翠綋涓嬭甯﹀,鍗曚綅瀛愯妭
__u32 vlan_up_bw; // vlan鏁翠綋涓婅甯﹀,鍗曚綅瀛愯妭
__u32 sta_down_bw; // 缁堢涓嬭甯﹀,鍗曚綅瀛愯妭
__u32 sta_up_bw; // 缁堢涓婅甯﹀,鍗曚綅瀛愯妭
__u16 biz_ses_limit; // 鍟嗕笟Wifi鏁翠綋tcp session闄愬埗
__u16 biz_udp_limit; // 鍟嗕笟Wifi鏁翠綋udp session闄愬埗
__u8 ip_start[16]; // 鍙湁褰撴寜鐓p鍒掑垎鏃舵墠鏈夋晥
__u8 ip_end[16];
__u16 reserved;
__u16 node_len; //
vlan_node node[0];
} *pvlan_entity;
typedef struct lan_entity
{
__u8 dhcp_mode; // 1=寮�鍚痙hcp銆�0=鍏抽棴鐨刣hcp
__u8 vlan_id;
__u16 reserved1;
__u32 leasetime;
__u8 gw_mac[6];
__u16 reserved2;
__u8 dhcp_start[16];
__u8 dhcp_end[16];
__u8 gw_ip[16];
__u8 mask[16];
} *plan_entity;
typedef struct ap_stat2
{
__u32 free_mem; // 鍙敤鍐呭瓨锛屽崟浣嶄负K
__u32 free_storage; // 鍙敤瀛樺偍锛屽崟浣嶄负K
__u32 ap_time; // 绯荤粺鏃堕棿
__u32 uptime; // ap鍦ㄧ嚎鏃堕棿锛屽崟浣嶄负绉�
__u64 incoming; // 涓嬭鎬绘祦閲忥紝鍗曚綅涓哄瓧鑺�
__u64 outgoing; // 涓婅鎬绘祦閲忥紝鍗曚綅涓哄瓧鑺�
__u16 cpu; // 鍗曚綅涓轰竾鍒嗕箣涓�(鏁存暟閮ㄥ垎)
ap_auth_mode auth_mode; /* 缁堢璁よ瘉妯″紡锛�0=鐩存帴鏀捐锛�1=瑕佹眰璁よ瘉 */
ap_audit_mode audit_mode; /* 瀹¤妯″紡锛�0=涓嶄紶鐢ㄦ埛璁块棶鐨刄RL锛�1=鍥炰紶鐢ㄦ埛璁块棶鐨刄RL */
__u16 online_user; // 褰撳墠鐘跺喌
__u16 authed_user; // 褰撳墠鐘跺喌
__u16 ap_interval; /* FatAP涓庣鐞嗘湇鍔″櫒闂寸殑蹇冭烦鏃堕棿锛屽崟浣嶇锛岄粯璁や负30绉� */
__u16 user_interval; /* 缁堢鐢ㄦ埛姹囨姤鐨勫績璺虫椂闂达紝鍗曚綅绉掞紝榛樿涓�30绉� */
__u16 audit_interval; // 琛屼负涓婃姤闂撮殧
__u16 reserved1;
__u32 biz_ibw_limit; // 鍟嗕笟Wifi鏁翠綋涓嬭甯﹀闄愬埗锛屽崟浣嶄负瀛楄妭
__u32 biz_obw_limit; // 鍟嗕笟Wifi鏁翠綋涓婅甯﹀闄愬埗锛屽崟浣嶄负瀛楄妭
__u32 biz_ibw;
__u32 biz_obw;
__u16 biz_ses_limit; // 鍟嗕笟Wifi鏁翠綋tcp session闄愬埗
__u16 biz_udp_limit; // 鍟嗕笟Wifi鏁翠綋udp session闄愬埗
__u16 biz_ses;
__u16 biz_udp;
__u16 wlan_count; // 涔嬪悗鏈夊灏憌lan_entity
__u16 vlan_count; // 涔嬪悗鏈夊灏憌an_entity
__u16 wan_count; // 涔嬪悗鏈夊灏憌an_entity
__u16 reserved2;
wlan_entity2 wlan[0];
wan_entity2 wan[0];
vlan_entity vlan[0];
} *pap_stat2;
enum Ext_Dev_Conf // 瀹氫箟璁惧鎵╁睍鍙互鏀寔閰嶇疆
{
no_ext_dev_conf = 0, // 琛ㄧずap_dev_conf2鍚庢病鏈夎窡浠讳綍鎵╁睍閰嶇疆
base_dev_conf = 1, // 琛ㄧずAP涓�浜涘熀纭�閰嶇疆,瀵瑰簲ap_dev_base_conf
safe_dev_conf = 2, //
};
typedef __u16 dev_conf_type;
typedef struct ap_dev_base_conf
{
__u16 mtu; // 鏈�澶т紶杈撳崟鍏�
__u8 hostname[20]; // 淇敼涓绘満鍚�
__u8 auth_srv[64];// 绠$悊鏈嶅姟鍣ㄥ湴鍧�锛屾瘮濡�: www.auth_srv.com:8080, 0d鍒嗗壊锛岀浜屼釜鍙婁互鍚庝负beiyong
__u8 audit_srv[64]; // 瀹¤鏈嶅姟鍣紝鐩墠鏆傛椂淇濈暀涓嶇敤锛�0d鍒嗗壊锛�
__u8 plat_srv[64];
__u8 def_302[128]; // 榛樿璺宠浆鍦板潃锛屽湪struct user_stat 涓病鏈夋寚瀹氳烦杞湴鍧�鏃朵娇鐢�
__u16 ap_interval; // FatAP涓庣鐞嗘湇鍔″櫒闂寸殑蹇冭烦鏃堕棿锛屽崟浣嶇锛岄粯璁や负60绉�
__u16 user_interval; // 缁堢鐢ㄦ埛姹囨姤鐨勫績璺虫椂闂达紝鍗曚綅绉掞紝榛樿涓�60绉�
__u16 audit_interval; // 鐢ㄦ埛琛屼负姹囨姤锛屽崟浣嶇锛岄粯璁や负60绉�
__u16 gps_interval; //
__u32 biz_ibw_limit; // 鍟嗕笟Wifi鏁翠綋涓嬭甯﹀闄愬埗锛屽崟浣嶄负瀛愯妭
__u32 biz_obw_limit; // 鍟嗕笟Wifi鏁翠綋涓婅甯﹀闄愬埗锛屽崟浣嶄负瀛愯妭
}*pap_dev_base_conf;
typedef struct ap_safe_dev_conf
{
__u8 webaccount[20]; // web绠$悊骞冲彴璐﹀彿
__u8 webpasswd[20]; // web绠$悊骞冲彴瀵嗙爜
__u16 webport; // web绠$悊骞冲彴绔彛
__u8 telnetaccount[20]; // telnet鐧诲綍璐﹀彿
__u8 telnetpasswd[20]; // telnet鐧诲綍瀵嗙爜
__u16 telentport; // telnet绔彛
__u8 pingenable; // 0鍏抽棴ping,1鍏抽棴ping
} *pap_safe_dev_conf;
typedef struct ap_dev_conf2
{
dev_conf_type type; // 琛ㄧず闅忓悗鎵╁睍閰嶇疆绫诲瀷锛堟墍鏈夊彲鎵╁睍閰嶇疆閮藉湪Ext_Dev_Conf锛�
__u8 dev_conf[0];
}*pap_dev_conf2;
typedef __u16 Conf_Count;
typedef struct ap_net_conf2
{
Conf_Count lan_count;
Conf_Count vlan_count;
Conf_Count wan_count;
Conf_Count wlan_count;
lan_entity lan[0];
vlan_entity vlan[0];
wan_entity2 wan[0];
wlan_entity2 wlan[0];
} *pap_net_conf2;
typedef __u16 user_action_type;
const user_action_type uatURL = 0;
const user_action_type uatTCP = 1;
const user_action_type uatUDP = 2;
typedef struct user_action_entry
{
__u32 action_date;
user_action_type action;
__u16 data_len;
__u8 data[0];
} *puser_action_entry;
typedef struct user_action2
{
__u8 user_ip[16];
__u8 mac[6];
__u16 entry_count; // 鍏跺悗鎵挎帴澶氫釜user_action_entry, 姣忎釜entry澶氶暱鐢卞叾鑷韩鐨刣ata_len鎵�鍐冲畾
user_action_entry uae_list[0];
} *puser_action2;
typedef struct ap_dns_white2
{
__u8 data[0]; // dns鐧藉悕鍗曟暟鎹紝浠ュ崐瑙掑垎鍙峰垎鍓层�傛敮鎸佸湴鍧�銆佸湴鍧�:绔彛銆佸煙鍚嶃�佸煙鍚�:绔彛銆丮AC鍦板潃
} *pap_dns_white;
typedef struct ap_upgrade2
{
__u8 url[0]; // 鍗囩骇鍖呯殑url鍦板潃
} *pap_upgrade;
typedef struct ap_link_detection
{
#if 0
__u8 te_ip[16]; // IPv4鏃跺悗闈�12瀛楄妭鐣�0
__u16 transmitted;// 鍙戦�佺殑鍖呮暟
__u16 rececived;// 鎺ュ彈鐨勫寘鏁�
__u16 loss;// 涓㈠け鐨勫寘鏁�
__u16 time;// 妫�娴嬫椂闂� 锛屽崟浣峬s
#endif
}*pap_link_detection;
typedef struct ap_dns_black
{
__u8 data[0]; // 榛戝悕鍗�
} *pap_dns_black;
typedef struct ap_reboot
{
__u32 time; // 寤惰繜澶氬皯绉掗噸鍚澶� 0绔嬪埢閲嶅惎
} *pap_reboot;
typedef struct {
__u32 type;
__u32 len; // total packet length in bytes
__u32 sequence;
} HEAD;
#endif /* PROJ_AP_TYPE2S_HPP_ */
| 29.005792 | 137 | 0.733511 | oracleloyall |
078df870ecfa9a50db5dffb2638b40d244a61d42 | 4,619 | cpp | C++ | 2014/prelim/C.cpp | golmansax/google-code-jam | 4486db353b19a5d61512aee8d6350aca75a5ab56 | [
"MIT"
] | null | null | null | 2014/prelim/C.cpp | golmansax/google-code-jam | 4486db353b19a5d61512aee8d6350aca75a5ab56 | [
"MIT"
] | null | null | null | 2014/prelim/C.cpp | golmansax/google-code-jam | 4486db353b19a5d61512aee8d6350aca75a5ab56 | [
"MIT"
] | null | null | null | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;
struct tCell {
int x;
int y;
int adjacent_unopens;
tCell(int my_x, int my_y, int my_adjacent_unopens) :
x(my_x), y(my_y), adjacent_unopens(my_adjacent_unopens) {
}
bool operator<(const tCell& rhs) const {
return adjacent_unopens < rhs.adjacent_unopens;
}
};
int main() {
int n_tests;
cin >> n_tests;
for (int i_test = 0; i_test < n_tests; i_test++) {
int r, c, m;
cin >> r >> c >> m;
bool open[r][c];
int start_x, start_y;
bool found_answer = false;
vector<tCell> edges;
// Check start points for a quarter of the grid
for (start_y = 0; start_y < (r + 1) / 2; start_y++) {
for (start_x = 0; start_x < (c + 1) / 2; start_x++) {
// Reset variables
int remaining_opens = r * c - m - 1;
//cout << "Remaining opens: " << remaining_opens << endl;
for (int y = 0; y < r; y++) {
for (int x = 0; x < c; x++) {
if (start_y == y && x == start_x) {
open[y][x] = true;
} else {
open[y][x] = false;
}
}
}
if (remaining_opens == 0) {
found_answer = true;
break;
}
edges.clear();
tCell start_cell(start_x, start_y, 0);
edges.push_back(start_cell);
while (true) {
// Compute adjacent_unopens
vector<tCell>::iterator it = edges.begin();
for (; it != edges.end(); it++) {
int my_x = it->x;
int my_y = it->y;
int adjacent_unopens = 0;
for (int y = my_y - 1; y <= my_y + 1; y++) {
for (int x = my_x - 1; x <= my_x + 1; x++) {
if (y < 0 || y >= r || x < 0 || x >= c) { continue; }
if (!open[y][x]) { adjacent_unopens++; }
}
}
it->adjacent_unopens = adjacent_unopens;
if (remaining_opens == adjacent_unopens) { break; }
}
// If it is not end, then we have a finisher
if (it != edges.end()) {
int my_x = it->x;
int my_y = it->y;
for (int y = my_y - 1; y <= my_y + 1; y++) {
for (int x = my_x - 1; x <= my_x + 1; x++) {
if (y < 0 || y >= r || x < 0 || x >= c) { continue; }
open[y][x] = true;
}
}
found_answer = true;
break;
}
// If it is not end, then we have a finisher
if (it != edges.end()) {
int my_x = it->x;
int my_y = it->y;
for (int y = my_y - 1; y <= my_y + 1; y++) {
for (int x = my_x - 1; x <= my_x + 1; x++) {
if (y < 0 || y >= r || x < 0 || x >= c) { continue; }
open[y][x] = true;
}
}
found_answer = true;
break;
}
sort(edges.begin(), edges.end());
while (edges.begin() != edges.end() &&
edges.begin()->adjacent_unopens == 0) {
edges.erase(edges.begin());
}
// No possible solutions
if (edges.begin() == edges.end()) { break; }
// Add the first one to the list
it = edges.begin();
remaining_opens -= it->adjacent_unopens;
// No possible solutions
if (remaining_opens < 0) { break; }
int my_x = it->x;
int my_y = it->y;
//printf("Adding: %d %d\n", my_x, my_y);
for (int y = my_y - 1; y <= my_y + 1; y++) {
for (int x = my_x - 1; x <= my_x + 1; x++) {
if (y < 0 || y >= r || x < 0 || x >= c) { continue; }
open[y][x] = true;
tCell cell(x, y, 0);
edges.push_back(cell);
}
}
edges.erase(edges.begin());
}
if (found_answer) { break; }
}
if (found_answer) { break; }
}
printf("Case #%d:\n", i_test+1);
if (found_answer) {
for (int y = 0; y < r; y++) {
for (int x = 0; x < c; x++) {
if (open[y][x]) {
if (x == start_x && y == start_y) {
cout << 'c';
} else {
cout << '.';
}
} else {
cout << '*';
}
}
cout << endl;
}
} else {
cout << "Impossible" << endl;
}
}
}
| 26.394286 | 69 | 0.423252 | golmansax |
078ebf10fc69cdec76e3899d305e4916a872486a | 2,109 | hpp | C++ | include/psst/math/angles.hpp | maxpagani/math | fb93b8ab78f74278fdbf51bfb81373b12f887803 | [
"Apache-2.0"
] | 36 | 2016-12-14T16:02:47.000Z | 2022-03-03T18:16:45.000Z | include/psst/math/angles.hpp | maxpagani/math | fb93b8ab78f74278fdbf51bfb81373b12f887803 | [
"Apache-2.0"
] | null | null | null | include/psst/math/angles.hpp | maxpagani/math | fb93b8ab78f74278fdbf51bfb81373b12f887803 | [
"Apache-2.0"
] | 8 | 2017-09-17T06:01:32.000Z | 2021-07-28T09:28:41.000Z | /*
* pi.hpp
*
* Created on: Dec 19, 2016
* Author: zmij
*/
#ifndef PSST_MATH_ANGLES_HPP_
#define PSST_MATH_ANGLES_HPP_
#include <psst/math/detail/value_policy.hpp>
#include <cmath>
namespace psst {
namespace math {
template <typename T>
struct pi {
static const T value;
};
template <typename T>
const T pi<T>::value = std::atan((T)1) * 4;
/**
* Clamp angle in the range of [0, π*2)
* @param angle
* @return
*/
template <typename T>
constexpr T
zero_to_two_pi(T const& val)
{
const auto double_pi = math::pi<std::decay_t<T>>::value * 2;
T angle = val;
while (angle >= double_pi) {
angle -= double_pi;
}
while (angle < 0) {
angle += double_pi;
}
return angle;
}
template <typename T>
constexpr T
minus_plus_half_pi(T const& angle)
{
const auto half_pi = math::pi<std::decay_t<T>>::value / 2;
if (angle < -half_pi)
return -half_pi;
if (angle > half_pi)
return half_pi;
return angle;
}
template <typename T>
constexpr T
minus_plus_pi(T const& val)
{
const auto pi = math::pi<std::decay_t<T>>::value * 2;
const auto double_pi = pi * 2;
T angle = val;
while (angle > pi) {
angle -= double_pi;
}
while (angle < -pi) {
angle += double_pi;
}
return angle;
}
template <typename T>
constexpr T
degrees_to_radians(T degrees)
{
return degrees / 180 * pi<std::decay_t<T>>::value;
}
template <typename T>
constexpr T
radians_to_degrees(T radians)
{
return radians / pi<std::decay_t<T>>::value * 180;
}
inline constexpr double operator"" _deg(long double deg)
{
return degrees_to_radians(deg);
}
inline constexpr double operator"" _deg(unsigned long long int deg)
{
return degrees_to_radians<double>(deg);
}
namespace value_policy {
template <typename T>
using clamp_zero_to_two_pi = value_clamp<T, zero_to_two_pi<T>>;
template <typename T>
using clamp_minus_plus_half_pi = value_clamp<T, minus_plus_half_pi<T>>;
} // namespace value_policy
} /* namespace math */
} /* namespace psst */
#endif /* PSST_MATH_ANGLES_HPP_ */
| 18.663717 | 71 | 0.647226 | maxpagani |
078f7a0304ccf7aaf9ba222cf88734da77c9c91f | 2,081 | hpp | C++ | include/zmq/socket_cache.hpp | haal/fluent | b387aec46155a3f2d4c2060e818e212b7649c7ca | [
"Apache-2.0"
] | 1,164 | 2018-07-25T23:17:07.000Z | 2019-07-11T20:33:52.000Z | include/zmq/socket_cache.hpp | longwutianya/fluent | c8fc9f2dd781e5ed91c34351adc6a101cc383083 | [
"Apache-2.0"
] | 126 | 2018-07-25T22:41:53.000Z | 2019-07-10T21:49:19.000Z | include/zmq/socket_cache.hpp | longwutianya/fluent | c8fc9f2dd781e5ed91c34351adc6a101cc383083 | [
"Apache-2.0"
] | 178 | 2018-07-25T23:17:11.000Z | 2019-07-10T02:45:27.000Z | // Copyright 2018 U.C. Berkeley RISE Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_INCLUDE_ZMQ_SOCKET_CACHE_HPP_
#define SRC_INCLUDE_ZMQ_SOCKET_CACHE_HPP_
#include <map>
#include <string>
#include "types.hpp"
#include "zmq.hpp"
// A SocketCache is a map from ZeroMQ addresses to PUSH ZeroMQ sockets. The
// socket corresponding to address `address` can be retrieved from a
// SocketCache `cache` with `cache[address]` or `cache.At(address)`. If a
// socket with a given address is not in the cache when it is requested, one is
// created and connected to the address. An example:
//
// zmq::context_t context(1);
// SocketCache cache(&context);
// // This will create a socket and connect it to "inproc://a".
// zmq::socket_t& a = cache["inproc://a"];
// // This will not createa new socket. It will return the socket created in
// // the previous line. In other words, a and the_same_a_as_before are
// // references to the same socket.
// zmq::socket_t& the_same_a_as_before = cache["inproc://a"];
// // cache.At("inproc://a") is 100% equivalent to cache["inproc://a"].
// zmq::socket_t& another_a = cache.At("inproc://a");
class SocketCache {
public:
explicit SocketCache(zmq::context_t* context, int type) :
context_(context),
type_(type) {}
zmq::socket_t& At(const Address& addr);
zmq::socket_t& operator[](const Address& addr);
void clear_cache();
private:
zmq::context_t* context_;
std::map<Address, zmq::socket_t> cache_;
int type_;
};
#endif // SRC_INCLUDE_ZMQ_SOCKET_CACHE_HPP_
| 37.160714 | 79 | 0.709755 | haal |
079163232d247c1ce8d5a07de2c22fc6c1e84c77 | 1,047 | cpp | C++ | clstatphys/tests/rootfinder/false_position_method.cpp | FIshikawa/ClassicalStatPhys | e4010480d3c7977829c1b3fdeaf51401a2409373 | [
"MIT"
] | null | null | null | clstatphys/tests/rootfinder/false_position_method.cpp | FIshikawa/ClassicalStatPhys | e4010480d3c7977829c1b3fdeaf51401a2409373 | [
"MIT"
] | 2 | 2020-01-21T08:54:05.000Z | 2020-01-21T09:29:10.000Z | clstatphys/tests/rootfinder/false_position_method.cpp | FIshikawa/ClassicalStatPhys | e4010480d3c7977829c1b3fdeaf51401a2409373 | [
"MIT"
] | 2 | 2020-07-18T03:36:32.000Z | 2021-07-21T22:58:27.000Z | #include <gtest/gtest.h>
#include <clstatphys/tools/false_position_method.hpp>
double f(double x) { return 3*x*x-5*x+1; }
TEST(FlasePositionTest, FlasePosition1) {
optimization::FalsePositionMethod optimizer;
int iteration;
iteration = optimizer.find_zero(f, 0, 1);
EXPECT_TRUE(iteration > 0);
EXPECT_DOUBLE_EQ((5 - std::sqrt(13)) / 6, optimizer.zero());
}
TEST(FlasePositionTest, FlasePosition2) {
optimization::FalsePositionMethod optimizer;
int iteration;
iteration = optimizer.find_zero(f, 1, 10);
EXPECT_TRUE(iteration > 0);
EXPECT_DOUBLE_EQ((5 + std::sqrt(13)) / 6, optimizer.zero());
}
TEST(FlasePositionTest, FlasePosition3) {
optimization::FalsePositionMethod optimizer;
int iteration;
iteration = optimizer.find_zero(f, 10, 1);
EXPECT_TRUE(iteration > 0);
EXPECT_DOUBLE_EQ((5 + std::sqrt(13)) / 6, optimizer.zero());
}
TEST(FlasePositionTest, FlasePosition4) {
optimization::FalsePositionMethod optimizer;
int iteration;
iteration = optimizer.find_zero(f, 3, 4);
EXPECT_FALSE(iteration > 0);
}
| 29.083333 | 62 | 0.730659 | FIshikawa |
07927e7ce599ea938f72c7e5917ddc481c256d21 | 3,108 | cpp | C++ | src/tdme/tools/particlesystem/TDMEParticleSystem.cpp | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | src/tdme/tools/particlesystem/TDMEParticleSystem.cpp | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | src/tdme/tools/particlesystem/TDMEParticleSystem.cpp | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | #include <tdme/tools/particlesystem/TDMEParticleSystem.h>
#include <cstdlib>
#include <string>
#include <tdme/utils/Time.h>
#include <tdme/engine/Engine.h>
#include <tdme/engine/model/Color4.h>
#include <tdme/gui/GUI.h>
#include <tdme/tools/shared/tools/Tools.h>
#include <tdme/tools/shared/views/PopUps.h>
#include <tdme/tools/shared/views/SharedParticleSystemView.h>
#include <tdme/tools/shared/views/View.h>
#include <tdme/utils/Console.h>
using std::string;
using tdme::tools::particlesystem::TDMEParticleSystem;
using tdme::utils::Time;
using tdme::engine::Engine;
using tdme::engine::model::Color4;
using tdme::gui::GUI;
using tdme::tools::shared::tools::Tools;
using tdme::tools::shared::views::PopUps;
using tdme::tools::shared::views::SharedParticleSystemView;
using tdme::tools::shared::views::View;
using tdme::utils::Console;
string TDMEParticleSystem::VERSION = "1.9.9";
TDMEParticleSystem* TDMEParticleSystem::instance = nullptr;
TDMEParticleSystem::TDMEParticleSystem()
{
Tools::loadSettings(this);
TDMEParticleSystem::instance = this;
engine = Engine::getInstance();
view = nullptr;
viewInitialized = false;
viewNew = nullptr;
popUps = new PopUps();
particleSystemView = nullptr;
quitRequested = false;
}
TDMEParticleSystem::~TDMEParticleSystem() {
delete popUps;
delete particleSystemView;
}
void TDMEParticleSystem::main(int argc, char** argv)
{
Console::println(string("TDMEParticleSystem " + VERSION));
Console::println(string("Programmed 2018 by Andreas Drewke, drewke.net."));
Console::println();
auto tdmeParticleSystem = new TDMEParticleSystem();
tdmeParticleSystem->run(argc, argv, "TDMEParticleSystem");
}
TDMEParticleSystem* TDMEParticleSystem::getInstance()
{
return instance;
}
void TDMEParticleSystem::setView(View* view)
{
viewNew = view;
}
View* TDMEParticleSystem::getView()
{
return view;
}
void TDMEParticleSystem::quit()
{
quitRequested = true;
}
void TDMEParticleSystem::display()
{
if (viewNew != nullptr) {
if (view != nullptr && viewInitialized == true) {
view->deactivate();
view->dispose();
viewInitialized = false;
}
view = viewNew;
viewNew = nullptr;
}
if (view != nullptr) {
if (viewInitialized == false) {
view->initialize();
view->activate();
viewInitialized = true;
}
view->display();
}
engine->display();
if (view != nullptr) view->display();
if (quitRequested == true) {
if (view != nullptr) {
view->deactivate();
view->dispose();
}
Application::exit(0);
}
}
void TDMEParticleSystem::dispose()
{
if (view != nullptr && viewInitialized == true) {
view->deactivate();
view->dispose();
view = nullptr;
}
engine->dispose();
Tools::oseDispose();
}
void TDMEParticleSystem::initialize()
{
engine->initialize();
engine->setSceneColor(Color4(125.0f / 255.0f, 125.0f / 255.0f, 125.0f / 255.0f, 1.0f));
setInputEventHandler(engine->getGUI());
Tools::oseInit();
popUps->initialize();
setView(particleSystemView = new SharedParticleSystemView(popUps));
}
void TDMEParticleSystem::reshape(int32_t width, int32_t height)
{
engine->reshape(0, 0, width, height);
}
| 22.521739 | 88 | 0.717181 | mahula |
07930c1c3b65b8fd591ac2e791fb5ee01ec64163 | 5,553 | cpp | C++ | src/Scenes/Tiles/Tileset.cpp | Tristeon/Tristeon | 9052e87b743f1122ed4c81952f2bffda96599447 | [
"MIT"
] | 32 | 2018-06-16T20:50:15.000Z | 2022-03-26T16:57:15.000Z | src/Scenes/Tiles/Tileset.cpp | Tristeon/Tristeon2D | 9052e87b743f1122ed4c81952f2bffda96599447 | [
"MIT"
] | 2 | 2018-10-07T17:41:39.000Z | 2021-01-08T03:14:19.000Z | src/Scenes/Tiles/Tileset.cpp | Tristeon/Tristeon2D | 9052e87b743f1122ed4c81952f2bffda96599447 | [
"MIT"
] | 9 | 2018-06-12T21:00:58.000Z | 2021-01-08T02:18:30.000Z | #include "Tileset.h"
#include "AssetManagement/Resources.h"
#include <Rendering/Texture.h>
namespace Tristeon
{
void to_json(json& j, const TileInfo& p)
{
j["hasCollider"] = p.hasCollider;
j["density"] = p.density;
j["friction"] = p.friction;
j["restitution"] = p.restitution;
}
void from_json(const json& j, TileInfo& p)
{
p.hasCollider = j.value("hasCollider", false);
p.density = j.value("density", 1.0f);
p.friction = j.value("friction", 0.0f);
p.restitution = j.value("restitution", 0.0f);
}
Tileset::Tileset()
{
albedoMap = Resources::load<Texture>(Texture::defaultPath);
albedoPath = Texture::defaultPath;
this->tileInfo = std::make_unique<TileInfo[]>(cols * rows);
for (size_t i = 0; i < cols * rows; i++)
tileInfo[i] = TileInfo{};
}
json Tileset::serialize()
{
auto j = Serializable::serialize();
j["typeID"] = Type<Tileset>::fullName();
j["id"] = id;
j["width"] = cols;
j["height"] = rows;
j["albedoPath"] = albedoPath;
j["normalPath"] = normalPath;
j["normalMapStrength"] = normalMapStrength;
j["lightMaskPath"] = lightMaskPath;
j["spacingLeft"] = spacingLeft;
j["spacingRight"] = spacingRight;
j["spacingTop"] = spacingTop;
j["spacingBottom"] = spacingBottom;
j["horizontalSpacing"] = horizontalSpacing;
j["verticalSpacing"] = verticalSpacing;
auto info = json::array_t();
for (size_t i = 0; i < cols * rows; i++)
{
info.emplace_back(TileInfo{ false, 1, 0, 0 });
if (tileInfo)
info[i] = tileInfo[i];
}
j["tileInfo"] = info;
return j;
}
void Tileset::deserialize(json j)
{
Serializable::deserialize(j);
cols = j.value("width", 1u);
rows = j.value("height", 1u);
id = j.value("id", 0);
albedoPath = j.value("albedoPath", "");
albedoMap = Resources::load<Texture>(albedoPath);
normalPath = j.value("normalPath", "");
normalMap = Resources::load<Texture>(normalPath);
normalMapStrength = j.value("normalMapStrength", 1.0f);
lightMaskPath = j.value("lightMaskPath", "");
lightMask = Resources::load<Texture>(lightMaskPath);
spacingLeft = j.value("spacingLeft", 0);
spacingRight = j.value("spacingRight", 0);
spacingTop = j.value("spacingTop", 0);
spacingBottom = j.value("spacingBottom", 0);
horizontalSpacing = j.value("horizontalSpacing", 0);
verticalSpacing = j.value("verticalSpacing", 0);
this->tileInfo = std::make_unique<TileInfo[]>(cols * rows);
for (size_t i = 0; i < cols * rows; i++)
tileInfo[i] = TileInfo{};
if (j.contains("tileInfo") && j["tileInfo"].is_array())
{
for (size_t i = 0; i < cols * rows && i < j["tileInfo"].size(); i++)
{
tileInfo[i] = j["tileInfo"][i];
}
}
}
TileInfo Tileset::info(const int& index) const
{
if (index < 0 || index > cols * rows)
return {};
return tileInfo[index];
}
VectorI Tileset::tileSize() const
{
auto img = albedoMap->size();
img.x -= spacingLeft + spacingRight;
img.y -= spacingTop + spacingBottom;
img.x -= horizontalSpacing * (cols - 1);
img.y -= verticalSpacing * (rows - 1);
return { img.x / (int)cols, img.y / (int)rows };
}
Vector Tileset::tileSizeNormalized() const
{
if (!albedoMap)
return Vector{};
auto const img = albedoMap->size();
auto const size = tileSize();
return { size.x / (float)img.x, size.y / (float)img.y };
}
VectorI Tileset::tileMin(const int& x, const int& y) const
{
VectorI result{ (int)spacingLeft, (int)spacingTop };
auto const size = tileSize();
result.x += x * (size.x + horizontalSpacing);
result.y += y * (size.y + verticalSpacing);
return result;
}
VectorI Tileset::tileMin(const int& index) const
{
return tileMin(tileCoords(index));
}
VectorI Tileset::tileMin(const VectorI& coords) const
{
return tileMin(coords.x, coords.y);
}
Vector Tileset::tileMinNormalized(const int& x, const int& y) const
{
auto const min = tileMin(x, y);
auto const img = albedoMap->size();
return { min.x / (float)img.x, min.y / (float)img.y };
}
Vector Tileset::tileMinNormalized(const int& index) const
{
return tileMinNormalized(tileCoords(index));
}
Vector Tileset::tileMinNormalized(const VectorI& coords) const
{
return tileMinNormalized(coords.x, coords.y);
}
VectorI Tileset::tileMax(const int& x, const int& y) const
{
auto const min = tileMin(x, y);
auto const size = tileSize();
return min + size;
}
VectorI Tileset::tileMax(const int& index) const
{
return tileMax(tileCoords(index));
}
VectorI Tileset::tileMax(const VectorI& coords) const
{
return tileMax(coords.x, coords.y);
}
Vector Tileset::tileMaxNormalized(const int& x, const int& y) const
{
auto const max = tileMax(x, y);
auto const img = albedoMap->size();
return { max.x / (float)img.x, max.y / (float)img.y };
}
Vector Tileset::tileMaxNormalized(const int& index) const
{
return tileMaxNormalized(tileCoords(index));
}
Vector Tileset::tileMaxNormalized(const VectorI& coords) const
{
return tileMaxNormalized(coords.x, coords.y);
}
int Tileset::tile(const int& x, const int& y) const
{
assert(x >= 0);
assert(y >= 0);
return y * cols + x;
}
int Tileset::tile(const VectorI& coords) const
{
return tile(coords.x, coords.y);
}
VectorI Tileset::tileCoords(const int& index) const
{
return { (int)index % (int)cols, (int)(index / (float)cols) };
}
TileInfo Tileset::info(const int& x, const int& y) const
{
return tileInfo[tile(x, y)];
}
TileInfo Tileset::info(const VectorI& coords) const
{
return tileInfo[tile(coords.x, coords.y)];
}
}
| 23.529661 | 71 | 0.65118 | Tristeon |
079380678b7f324136966bee809ed8b96aa0e4a9 | 2,656 | cpp | C++ | Homeworks/HW-3/Task-3/task-3.cpp | kgolov/uni-data-structures | 8d8b2ff75ffa0ceed3ebe7bbc294680134b7d1c1 | [
"MIT"
] | null | null | null | Homeworks/HW-3/Task-3/task-3.cpp | kgolov/uni-data-structures | 8d8b2ff75ffa0ceed3ebe7bbc294680134b7d1c1 | [
"MIT"
] | null | null | null | Homeworks/HW-3/Task-3/task-3.cpp | kgolov/uni-data-structures | 8d8b2ff75ffa0ceed3ebe7bbc294680134b7d1c1 | [
"MIT"
] | null | null | null | #include <iostream>
// Calculates the number of balloons needed if the maximum number of sweets is target
long long balloonsNeeded(long long* sweets, long long* maxSweets, int size, long long target) {
long long counter = 0;
for (int i = 0; i < size; i++) {
// Check if we need balloons here to reduce the maximum number of sweets
if (maxSweets[i] > target) {
long long difference = maxSweets[i] - target;
// The balloons needed to make up this difference are the difference divided by the sweets
// field of the current day, rounded up to an integer
long long balloons = 1 + ((difference - 1) / sweets[i]);
counter += balloons;
}
}
return counter;
}
// Finds the minimum number of max sweets needed
long long findMaxSweets(long long* sweets, long long* maxSweets, int size, long long balloons) {
// Conduct a binary search for the answer
// The maximum number of sweets is our upper bound
long long left = 0;
long long right = 0;
for (int i = 0; i < size; i++) {
if (maxSweets[i] > right) {
right = maxSweets[i];
}
}
// We will store our result here
long long result = right;
while (left <= right) {
// Take a guess for the maximum number of sweets, in the middle between our lower and upper bounds
long long middle = left + (right - left) / 2;
// If the balloons needed for this given number of sweets are lower than, or equal to the amount we have
if (balloonsNeeded(sweets, maxSweets, size, middle) <= balloons) {
// Then, this is a possible solution, so save it as a result
if (middle < result) {
result = middle;
}
// And update our upper bound to search for an even lower possible number
right = middle - 1;
}
else {
// Else, this cannot be a solution, so search for a higher number
left = middle + 1;
}
}
// We have found the minimum number of max sweets
return result;
}
int main() {
int days;
std::cin >> days;
long long balloons;
std::cin >> balloons;
long long* maxBalloons = new long long[days];
long long* sweets = new long long[days];
long long* maxSweets = new long long[days];
for (int i = 0; i < days; i++) {
std::cin >> maxBalloons[i];
}
for (int i = 0; i < days; i++) {
std::cin >> sweets[i];
maxSweets[i] = maxBalloons[i] * sweets[i];
}
std::cout << findMaxSweets(sweets, maxSweets, days, balloons);
return 0;
}
| 32 | 112 | 0.589985 | kgolov |
07938e6b44fe67f182eafe4e1c24e97b0c79a870 | 3,588 | cc | C++ | src/main.cc | qianqian121/odrMgrLite | 877c5676198e8c35fb72c01c411c72a453449c65 | [
"Unlicense"
] | null | null | null | src/main.cc | qianqian121/odrMgrLite | 877c5676198e8c35fb72c01c411c72a453449c65 | [
"Unlicense"
] | null | null | null | src/main.cc | qianqian121/odrMgrLite | 877c5676198e8c35fb72c01c411c72a453449c65 | [
"Unlicense"
] | null | null | null | /* ===================================================
* file: main.cc
* ---------------------------------------------------
* purpose: main program for testing the
* OdrManager
* ---------------------------------------------------
* first edit: 08.07.2006 by M. Dupuis
* ===================================================
* 21.07.2008: udate to OpenDRIVE Manager 1.1.19
* 21.06.2007: udate to OpenDRIVE Manager 1.1.10
* ===================================================
*/
/* ====== INCLUSIONS ====== */
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <cstdio>
#include "OdrManagerLite.hh"
#ifdef LINUX
#include <sys/time.h>
#else
#include <windows.h>
#endif
using namespace std;
/* ====== GLOBAL VARIABLES ====== */
int main( int argc, char **argv )
{
OpenDrive::OdrManagerLite myManager;
if ( argc < 2 ) {
std::cerr << "Usage: " << std::endl;
std::cerr << " odrMgr <filename> <additional filename>" << std::endl;
exit( -1 );
}
std::cerr << "main: analyzing file <" << argv[1] << ">" << std::endl;
if ( !myManager.loadFile( argv[1] ) )
{
std::cerr << "main: could not load <" << argv[1] << ">" << std::endl;
exit( 0 );
}
/********************************************************************
* SAMPLE no. 1
* print the data tree
*********************************************************************/
// print the contents of the file
std::cerr << "main: printing data contents" << std::endl;
myManager.printData();
/********************************************************************
* SAMPLE no. 3
* navigate on the road data, a few samples
*********************************************************************/
// create a position object for access to the data/ std::cerr << "main: position tests" << std::endl;
OpenDrive::Position* myPos= myManager.createPosition();
// activate the position object
myManager.activatePosition( myPos );
int testCase = 0;
{
switch ( testCase )
{
case 0: // track to inertial and back
{
for ( double s = 0.0; s < 1600.0; s+= 100.0 )
{
myManager.setTrackPos( 17, s, 3.0 );
bool result = myManager.track2inertial();
fprintf( stderr, "testCase 0: result = %d, s = %.3f, x = %.8lf, y = %.8lf, z = %.8lf, pitch=%.8lf\n", result, s,
myManager.getInertialPos().getX(), myManager.getInertialPos().getY(),
myManager.getInertialPos().getZ(), myManager.getInertialPos().getP() );
// now the other way round
result = myManager.inertial2track();
myManager.footPoint2inertial();
fprintf( stderr, "testCase 0: result = %d, x = %.8lf, y = %.8lf, track = %d, s = %.8lf, t = %.8lf\n",
result, myManager.getInertialPos().getX(), myManager.getInertialPos().getY(),
myManager.getTrackPos().getTrackId(), myManager.getTrackPos().getS(), myManager.getTrackPos().getT() );
}
}
break;
}
}
return 1;
}
| 36.989691 | 145 | 0.401895 | qianqian121 |
0795b2136bb20d35edbae00ce15ee2459c33a7b6 | 1,067 | cpp | C++ | poj-3125.cpp | casper001207/uva-online-judge | 19dc42224c24ac66bc99d52498a26fd310caf6bc | [
"MIT"
] | 1 | 2020-04-08T14:07:05.000Z | 2020-04-08T14:07:05.000Z | poj-3125.cpp | casper001207/uva-online-judge | 19dc42224c24ac66bc99d52498a26fd310caf6bc | [
"MIT"
] | null | null | null | poj-3125.cpp | casper001207/uva-online-judge | 19dc42224c24ac66bc99d52498a26fd310caf6bc | [
"MIT"
] | null | null | null | #include <cstdio>
#include <queue>
using namespace std;
bool checkIfOkToPrint(queue<int> q, int job, int priority[]);
int main()
{
int Case, n, m;
int priority[105];
scanf("%d", &Case);
while (Case--) {
scanf("%d %d", &n, &m);
for (int i = 0; i < n; ++i)
scanf("%d", &priority[i]);
queue<int> q;
for (int i = 0; i < n; ++i)
q.push(i);
int time = 0;
bool isover = false;
while (!isover) {
int job = q.front();
q.pop();
bool check = checkIfOkToPrint(q, job, priority);
if (check == true) {
++time;
if (job == m) isover = true;
} else {
q.push(job);
}
}
printf("%d\n", time);
}
}
bool checkIfOkToPrint(queue<int> q, int job, int priority[])
{
while (!q.empty()) {
if (priority[q.front()] > priority[job])
return false;
else
q.pop();
}
return true;
}
| 22.702128 | 61 | 0.424555 | casper001207 |
079729a5017e1831a91fe6ed35bd1943da826158 | 834 | cpp | C++ | src/python/constants.cpp | PavelBlend/fluid-engine-dev | 45b4bdbdb4c6d8c0beebc682180469198203b0ef | [
"MIT"
] | 1,355 | 2016-05-08T07:29:22.000Z | 2022-03-30T13:59:35.000Z | src/python/constants.cpp | Taiyuan-Zhang/fluid-engine-dev | 45b4bdbdb4c6d8c0beebc682180469198203b0ef | [
"MIT"
] | 208 | 2016-05-25T19:47:27.000Z | 2022-01-17T04:18:29.000Z | src/python/constants.cpp | Taiyuan-Zhang/fluid-engine-dev | 45b4bdbdb4c6d8c0beebc682180469198203b0ef | [
"MIT"
] | 218 | 2016-08-23T16:51:10.000Z | 2022-03-31T03:55:48.000Z | // Copyright (c) 2018 Doyub Kim
//
// I am making my contributions/submissions to this project solely in my
// personal capacity and am not conveying any rights to any intellectual
// property of any third parties.
#include "constants.h"
#include "pybind11_utils.h"
#include <jet/constants.h>
namespace py = pybind11;
using namespace jet;
void addConstants(py::module& m) {
m.attr("DIRECTION_NONE") = py::int_(kDirectionNone);
m.attr("DIRECTION_LEFT") = py::int_(kDirectionLeft);
m.attr("DIRECTION_RIGHT") = py::int_(kDirectionRight);
m.attr("DIRECTION_DOWN") = py::int_(kDirectionDown);
m.attr("DIRECTION_UP") = py::int_(kDirectionUp);
m.attr("DIRECTION_BACK") = py::int_(kDirectionBack);
m.attr("DIRECTION_FRONT") = py::int_(kDirectionFront);
m.attr("DIRECTION_ALL") = py::int_(kDirectionAll);
}
| 33.36 | 72 | 0.71223 | PavelBlend |
0797efe0eac673f52f6db73a8cafe3d291b5d753 | 4,408 | cpp | C++ | UnitTest/Common/FoundationTest/TestResourceService.cpp | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | 2 | 2017-04-19T01:38:30.000Z | 2020-07-31T03:05:32.000Z | UnitTest/Common/FoundationTest/TestResourceService.cpp | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | null | null | null | UnitTest/Common/FoundationTest/TestResourceService.cpp | achilex/MgDev | f7baf680a88d37659af32ee72b9a2046910b00d8 | [
"PHP-3.0"
] | 1 | 2021-12-29T10:46:12.000Z | 2021-12-29T10:46:12.000Z | //
// Copyright (C) 2004-2011 by Autodesk, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of version 2.1 of the GNU Lesser
// General Public License as published by the Free Software Foundation.
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#include "TestResourceService.h"
MgTestResourceService::MgTestResourceService()
{
}
MgTestResourceService::~MgTestResourceService()
{
}
MgByteReader* MgTestResourceService::EnumerateRepositories(CREFSTRING repositoryType)
{
printf("Hello there\n");
return NULL;
}
void MgTestResourceService::CreateRepository(MgResourceIdentifier* resource, MgByteReader* content, MgByteReader* header)
{
}
void MgTestResourceService::DeleteRepository(MgResourceIdentifier* resource)
{
}
void MgTestResourceService::UpdateRepository(MgResourceIdentifier* resource, MgByteReader* content, MgByteReader* header)
{
}
void MgTestResourceService::ApplyResourcePackage(MgByteReader* resourcePackage)
{
}
MgByteReader* MgTestResourceService::EnumerateResources(MgResourceIdentifier* resource, INT32 depth, CREFSTRING type)
{
return NULL;
}
void MgTestResourceService::SetResource(MgResourceIdentifier* resource, MgByteReader* content, MgByteReader* header)
{
}
void MgTestResourceService::DeleteResource(MgResourceIdentifier* resource)
{
}
void MgTestResourceService::MoveResource(MgResourceIdentifier* sourceResource, MgResourceIdentifier* destResource, bool overwrite)
{
}
void MgTestResourceService::CopyResource(MgResourceIdentifier* sourceResource, MgResourceIdentifier* destResource, bool overwrite)
{
}
MgByteReader* MgTestResourceService::GetResourceContent(MgResourceIdentifier* resource)
{
return NULL;
}
MgByteReader* MgTestResourceService::GetResourceHeader(MgResourceIdentifier* resource)
{
return NULL;
}
void MgTestResourceService::ChangeResourceOwner(MgResourceIdentifier* resource, CREFSTRING owner, bool includeDescendants)
{
}
void MgTestResourceService::InheritPermissionsFrom(MgResourceIdentifier* resource)
{
}
void MgTestResourceService::SetResourceData(MgResourceIdentifier* resource, CREFSTRING dataName, CREFSTRING dataType, MgByteReader* data)
{
}
void MgTestResourceService::DeleteResourceData(MgResourceIdentifier* resource, CREFSTRING dataName)
{
}
void MgTestResourceService::RenameResourceData(MgResourceIdentifier* resource, CREFSTRING oldDataName, CREFSTRING newDataName, bool overwrite)
{
}
MgByteReader* MgTestResourceService::GetResourceData(MgResourceIdentifier* resource, CREFSTRING dataName)
{
return NULL;
}
MgByteReader* MgTestResourceService::EnumerateResourceData(MgResourceIdentifier* resource)
{
return NULL;
}
MgByteReader* MgTestResourceService::GetRepositoryContent(MgResourceIdentifier* resource)
{
return NULL;
}
MgByteReader* MgTestResourceService::GetRepositoryHeader(MgResourceIdentifier* resource)
{
return NULL;
}
MgByteReader* MgTestResourceService::EnumerateReferences(MgResourceIdentifier* resource)
{
return NULL;
}
MgByteReader* MgTestResourceService::EnumerateResources(MgResourceIdentifier* resource, INT32 depth, CREFSTRING type, INT32 properties, CREFSTRING fromDate, CREFSTRING toDate)
{
return NULL;
}
bool MgTestResourceService::ResourceExists(MgResourceIdentifier* resource)
{
return false;
}
MgByteReader* MgTestResourceService::GetResourceContent(MgResourceIdentifier* resource, CREFSTRING preProcessTags)
{
return NULL;
}
MgByteReader* MgTestResourceService::GetResourceData(MgResourceIdentifier* resource, CREFSTRING dataName, CREFSTRING preProcessTags)
{
return NULL;
}
MgDateTime* MgTestResourceService::GetResourceModifiedDate(MgResourceIdentifier* resource)
{
return NULL;
}
MgSerializableCollection* MgTestResourceService::EnumerateParentMapDefinitions(MgSerializableCollection* resources)
{
return NULL;
}
void MgTestResourceService::Dispose()
{
delete this;
}
IMPLEMENT_CREATE_SERVICE(MgTestResourceService)
| 26.715152 | 175 | 0.808984 | achilex |
079bca3915e04aa1ea5fa7f7fc726d691d0f6c03 | 908 | hh | C++ | src/cassette/CasImage.hh | sdsnatcher73/openMSX | 6de09386ff674668325ddf700b0b16334ad1d2ef | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 320 | 2015-06-16T20:32:33.000Z | 2022-03-26T17:03:27.000Z | src/cassette/CasImage.hh | sdsnatcher73/openMSX | 6de09386ff674668325ddf700b0b16334ad1d2ef | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 2,592 | 2015-05-30T12:12:21.000Z | 2022-03-31T17:16:15.000Z | src/cassette/CasImage.hh | imulilla/openMSX_TSXadv | afffe852f73cb5f9a1f1d60f0ab9ff9a4da98c31 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 74 | 2015-06-18T19:51:15.000Z | 2022-03-24T15:09:33.000Z | #ifndef CASIMAGE_HH
#define CASIMAGE_HH
#include "CassetteImage.hh"
#include <cstdint>
#include <vector>
namespace openmsx {
class CliComm;
class Filename;
class FilePool;
/**
* Code based on "cas2wav" tool by Vincent van Dam
*/
class CasImage final : public CassetteImage
{
public:
CasImage(const Filename& fileName, FilePool& filePool, CliComm& cliComm);
// CassetteImage
int16_t getSampleAt(EmuTime::param time) const override;
[[nodiscard]] EmuTime getEndTime() const override;
[[nodiscard]] unsigned getFrequency() const override;
void fillBuffer(unsigned pos, float** bufs, unsigned num) const override;
[[nodiscard]] float getAmplificationFactorImpl() const override;
struct Data {
std::vector<int8_t> wave;
unsigned frequency;
};
private:
Data init(const Filename& filename, FilePool& filePool, CliComm& cliComm);
private:
const Data data;
};
} // namespace openmsx
#endif
| 20.636364 | 75 | 0.75 | sdsnatcher73 |
079c67dacd53f1908346ff078896802240dcb050 | 5,862 | cpp | C++ | OpenROV/CAutopilot_EXP.cpp | noxxomatik/openrov-software-arduino-30.0.4-BNO055 | e40b64e84cec6de2ee00abd013fe24fb483ab42d | [
"MIT"
] | null | null | null | OpenROV/CAutopilot_EXP.cpp | noxxomatik/openrov-software-arduino-30.0.4-BNO055 | e40b64e84cec6de2ee00abd013fe24fb483ab42d | [
"MIT"
] | null | null | null | OpenROV/CAutopilot_EXP.cpp | noxxomatik/openrov-software-arduino-30.0.4-BNO055 | e40b64e84cec6de2ee00abd013fe24fb483ab42d | [
"MIT"
] | null | null | null | #include "AConfig.h"
#if( HAS_EXP_AUTOPILOT )
// Includes
#include "CAutopilot.h"
#include "CTimer.h"
#include "NDataManager.h"
#include "NCommManager.h"
#include "CPIDController.h"
#include "Utility.h"
// File local variables and methods
namespace
{
CTimer pilotTimer;
// These should be replaced with two CPIDController instances for yaw and depth
CPIDControllerAngular m_yawController( 0.01f, 0.0f, 0.0f, -1.0f, 1.0f, PID_CONTROLLER_DIRECTION_DIRECT, 10 );
CPIDControllerLinear m_depthController( 0.01f, 0.0f, 0.0f, -1.0f, 1.0f, PID_CONTROLLER_DIRECTION_DIRECT, 10 );
void HandleCommands()
{
if( !NCommManager::m_isCommandAvailable )
{
// No commands to process
return;
}
// Disable heading controller
if( NCommManager::m_currentCommand.Equals( "headloff" ) )
{
// Deactivate PID controller
m_yawController.Deactivate();
// Send command to drive yaw at zero capacity (to turn off whatever was last sent by the controller)
int m_argumentsToSend[] = { 1, 0 };
NCommManager::m_currentCommand.PushCommand( "yaw", m_argumentsToSend );
Serial.println( F( "log:heading_hold_disabled;" ) );
Serial.print( F( "targetHeading:" ) );
Serial.print( DISABLED );
Serial.println( ';' );
return;
}
// Enable heading controller
if( NCommManager::m_currentCommand.Equals( "headlon" ) )
{
if( NCommManager::m_currentCommand.m_arguments[0] == 0 )
{
// Set the new target to our current heading
NDataManager::m_controllerData.yawSetpoint = NDataManager::m_controllerData.yaw;
}
else
{
// Set new setpoint to the specified target value
NDataManager::m_controllerData.yawSetpoint = NCommManager::m_currentCommand.m_arguments[1];
}
// Activate PID controller
m_yawController.Activate();
Serial.print( F( "log:heading_hold_enabled on=" ) );
Serial.print( *m_yawController.m_pSetpoint );
Serial.println( ';' );
Serial.print( F( "targetHeading:" ) );
Serial.print( *m_yawController.m_pSetpoint );
Serial.println( ';' );
return;
}
// Disable depth controller
if( NCommManager::m_currentCommand.Equals( "deptloff" ) )
{
// Deactivate PID controller
m_depthController.Deactivate();
// Send command to drive lift at zero capacity (to turn off whatever was last sent by the controller)
int m_argumentsToSend[] = { 1, 0 };
NCommManager::m_currentCommand.PushCommand( "lift", m_argumentsToSend );
Serial.println( F( "log:depth_hold_disabled;" ) );
Serial.print( F( "targetDepth:" ) );
Serial.print( DISABLED );
Serial.println( ';' );
return;
}
// Enable depth controller
if( NCommManager::m_currentCommand.Equals( "deptlon" ) )
{
if( NCommManager::m_currentCommand.m_arguments[0] == 0 )
{
NDataManager::m_controllerData.depthSetpoint = NDataManager::m_controllerData.depth;
}
else
{
NDataManager::m_controllerData.depthSetpoint = NCommManager::m_currentCommand.m_arguments[1];
}
// Activate PID controller
m_depthController.Activate();
Serial.print( F( "log:depth_hold_enabled on=" ) );
Serial.print( *m_depthController.m_pSetpoint );
Serial.println( ';' );
Serial.print( F( "targetDepth:" ) );
Serial.print( *m_depthController.m_pSetpoint );
Serial.println( ';' );
return;
}
}
void AllocateDepthControls()
{
if( m_depthController.m_isActive )
{
// Map from -1to1 to -100to100
int lift = static_cast<int>( NDataManager::m_controllerData.depthCommand * 100.0f );
// TODO: Perform any deadbanding if necessary
Serial.println( F( "log:dhold pushing command;" ) );
// TODO: Add error term to PID Controller class
// TODO: Is this supposed to display as an integer?
int error = static_cast<int>( NDataManager::m_controllerData.depthSetpoint - NDataManager::m_controllerData.depth );
Serial.print( F( "dp_er:" ) );
Serial.print( error );
Serial.println( ';' );
// Send lift command
int m_argumentsToSend[] = { 1, lift };
NCommManager::m_currentCommand.PushCommand( "lift", m_argumentsToSend );
}
}
void AllocateYawControls()
{
if( m_yawController.m_isActive )
{
// Map from -1to1 to -100to100
int yaw = static_cast<int>( NDataManager::m_controllerData.yawCommand * 50.0f );
// TODO: Perform any deadbanding if necessary
Serial.println( F( "log:dhold pushing command;" ) );
// TODO: Add error term to PID Controller class
// TODO: Is this supposed to display as an integer?
int error = static_cast<int>( NORMALIZE_ANGLE( NDataManager::m_controllerData.yawSetpoint - NDataManager::m_controllerData.yaw ) );
Serial.print( F( "dp_er:" ) );
Serial.print( error );
Serial.println( ';' );
// Send yaw command
int m_argumentsToSend[] = { 1, yaw };
NCommManager::m_currentCommand.PushCommand( "yaw", m_argumentsToSend );
}
}
void UpdateControllers()
{
// Compute controller outputs
m_yawController.Compute();
m_depthController.Compute();
// Allocate controls
AllocateDepthControls();
AllocateYawControls();
}
}
void CAutopilot::Initialize()
{
// Initialize the controllers
// TODO: Maybe rethink pointer access and keep it standalone for usability
m_yawController.Initialize( &NDataManager::m_controllerData.yaw, &NDataManager::m_controllerData.yawCommand, &NDataManager::m_controllerData.yawSetpoint );
m_depthController.Initialize( &NDataManager::m_controllerData.depth, &NDataManager::m_controllerData.depthCommand, &NDataManager::m_controllerData.depthSetpoint );
// Reset the timer
pilotTimer.Reset();
Serial.println( F( "log:pilot setup complete;" ) );
}
void CAutopilot::Update( CCommand& commandIn )
{
// Handle commands
HandleCommands();
// Run controllers at 20Hz and send resulting motor control commands
if( pilotTimer.HasElapsed( 50 ) )
{
// Update the controllers
UpdateControllers();
}
}
#endif
| 27.521127 | 164 | 0.704708 | noxxomatik |
079cb8b3bc323aa7bfba617286de5052b0043dce | 7,271 | cpp | C++ | modules/cudastereo/src/stereobm.cpp | JosephGeoBenjamin/opencv_contrib-hip | 2a948c02b9077b0fd3ae2baf903e9990a5f0a684 | [
"BSD-3-Clause"
] | null | null | null | modules/cudastereo/src/stereobm.cpp | JosephGeoBenjamin/opencv_contrib-hip | 2a948c02b9077b0fd3ae2baf903e9990a5f0a684 | [
"BSD-3-Clause"
] | null | null | null | modules/cudastereo/src/stereobm.cpp | JosephGeoBenjamin/opencv_contrib-hip | 2a948c02b9077b0fd3ae2baf903e9990a5f0a684 | [
"BSD-3-Clause"
] | 1 | 2020-11-16T14:32:58.000Z | 2020-11-16T14:32:58.000Z | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#include "precomp.hpp"
using namespace cv;
using namespace cv::cuda;
#if !defined (HAVE_HIP) || defined (CUDA_DISABLER)
Ptr<cuda::StereoBM> cv::cuda::createStereoBM(int, int) { throw_no_cuda(); return Ptr<cuda::StereoBM>(); }
#else /* !defined (HAVE_HIP) */
namespace cv { namespace cuda { namespace device
{
namespace stereobm
{
void stereoBM_CUDA(const PtrStepSzb& left, const PtrStepSzb& right, const PtrStepSzb& disp, int ndisp, int winsz, const PtrStepSz<unsigned int>& minSSD_buf, hipStream_t & stream);
void prefilter_xsobel(const PtrStepSzb& input, const PtrStepSzb& output, int prefilterCap /*= 31*/, hipStream_t & stream);
void postfilter_textureness(const PtrStepSzb& input, int winsz, float avgTexturenessThreshold, const PtrStepSzb& disp, hipStream_t & stream);
}
}}}
namespace
{
class StereoBMImpl : public cuda::StereoBM
{
public:
StereoBMImpl(int numDisparities, int blockSize);
void compute(InputArray left, InputArray right, OutputArray disparity);
void compute(InputArray left, InputArray right, OutputArray disparity, Stream& stream);
int getMinDisparity() const { return 0; }
void setMinDisparity(int /*minDisparity*/) {}
int getNumDisparities() const { return ndisp_; }
void setNumDisparities(int numDisparities) { ndisp_ = numDisparities; }
int getBlockSize() const { return winSize_; }
void setBlockSize(int blockSize) { winSize_ = blockSize; }
int getSpeckleWindowSize() const { return 0; }
void setSpeckleWindowSize(int /*speckleWindowSize*/) {}
int getSpeckleRange() const { return 0; }
void setSpeckleRange(int /*speckleRange*/) {}
int getDisp12MaxDiff() const { return 0; }
void setDisp12MaxDiff(int /*disp12MaxDiff*/) {}
int getPreFilterType() const { return preset_; }
void setPreFilterType(int preFilterType) { preset_ = preFilterType; }
int getPreFilterSize() const { return 0; }
void setPreFilterSize(int /*preFilterSize*/) {}
int getPreFilterCap() const { return preFilterCap_; }
void setPreFilterCap(int preFilterCap) { preFilterCap_ = preFilterCap; }
int getTextureThreshold() const { return static_cast<int>(avergeTexThreshold_); }
void setTextureThreshold(int textureThreshold) { avergeTexThreshold_ = static_cast<float>(textureThreshold); }
int getUniquenessRatio() const { return 0; }
void setUniquenessRatio(int /*uniquenessRatio*/) {}
int getSmallerBlockSize() const { return 0; }
void setSmallerBlockSize(int /*blockSize*/){}
Rect getROI1() const { return Rect(); }
void setROI1(Rect /*roi1*/) {}
Rect getROI2() const { return Rect(); }
void setROI2(Rect /*roi2*/) {}
private:
int preset_;
int ndisp_;
int winSize_;
int preFilterCap_;
float avergeTexThreshold_;
GpuMat minSSD_, leBuf_, riBuf_;
};
StereoBMImpl::StereoBMImpl(int numDisparities, int blockSize)
: preset_(0), ndisp_(numDisparities), winSize_(blockSize), preFilterCap_(31), avergeTexThreshold_(3)
{
}
void StereoBMImpl::compute(InputArray left, InputArray right, OutputArray disparity)
{
compute(left, right, disparity, Stream::Null());
}
void StereoBMImpl::compute(InputArray _left, InputArray _right, OutputArray _disparity, Stream& _stream)
{
using namespace ::cv::cuda::device::stereobm;
const int max_supported_ndisp = 1 << (sizeof(unsigned char) * 8);
CV_Assert( 0 < ndisp_ && ndisp_ <= max_supported_ndisp );
CV_Assert( ndisp_ % 8 == 0 );
CV_Assert( winSize_ % 2 == 1 );
GpuMat left = _left.getGpuMat();
GpuMat right = _right.getGpuMat();
CV_Assert( left.type() == CV_8UC1 );
CV_Assert( left.size() == right.size() && left.type() == right.type() );
_disparity.create(left.size(), CV_8UC1);
GpuMat disparity = _disparity.getGpuMat();
hipStream_t stream = StreamAccessor::getStream(_stream);
cuda::ensureSizeIsEnough(left.size(), CV_32SC1, minSSD_);
PtrStepSzb le_for_bm = left;
PtrStepSzb ri_for_bm = right;
if (preset_ == cv::StereoBM::PREFILTER_XSOBEL)
{
cuda::ensureSizeIsEnough(left.size(), left.type(), leBuf_);
cuda::ensureSizeIsEnough(right.size(), right.type(), riBuf_);
prefilter_xsobel( left, leBuf_, preFilterCap_, stream);
prefilter_xsobel(right, riBuf_, preFilterCap_, stream);
le_for_bm = leBuf_;
ri_for_bm = riBuf_;
}
stereoBM_CUDA(le_for_bm, ri_for_bm, disparity, ndisp_, winSize_, minSSD_, stream);
if (avergeTexThreshold_ > 0)
postfilter_textureness(le_for_bm, winSize_, avergeTexThreshold_, disparity, stream);
}
}
Ptr<cuda::StereoBM> cv::cuda::createStereoBM(int numDisparities, int blockSize)
{
return makePtr<StereoBMImpl>(numDisparities, blockSize);
}
#endif /* !defined (HAVE_HIP) */
| 39.091398 | 187 | 0.673773 | JosephGeoBenjamin |
079d6c7a9f6eee82e69c43655c04877ed611621a | 2,602 | cpp | C++ | UVa/UVA227.cpp | Insouciant21/solution | 8f241ec2076c9c29c0d39c2c285ee12eac1dee9e | [
"Apache-2.0"
] | 1 | 2020-09-11T13:17:28.000Z | 2020-09-11T13:17:28.000Z | UVa/UVA227.cpp | Insouciant21/solution | 8f241ec2076c9c29c0d39c2c285ee12eac1dee9e | [
"Apache-2.0"
] | 1 | 2020-10-22T13:36:23.000Z | 2020-10-22T13:36:23.000Z | UVa/UVA227.cpp | Insouciant21/solution | 8f241ec2076c9c29c0d39c2c285ee12eac1dee9e | [
"Apache-2.0"
] | 1 | 2020-10-22T13:33:11.000Z | 2020-10-22T13:33:11.000Z | #include <bits/stdc++.h>
using namespace std;
int main() {
int kase = 0;
while (true) {
string grid[5];
for (auto &i : grid) i = "";
kase++;
char ch = getchar();
if (ch == '\n') ch = getchar();
if (ch == 'Z') return 0;
grid[0] += ch;
for (auto &i : grid) {
string t;
getline(cin, t);
i += t;
}
int x = 0, y = 0;
bool find = false;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (grid[i][j] == ' ') {
x = i, y = j;
find = true;
break;
}
}
if (find) break;
}
if (!find) {
for (int i = 0; i < 5; i++) {
if (grid[i].size() == 4) {
x = i, y = 4;
grid[i] += ' ';
break;
}
}
}
bool success = true;
while (true) {
char i = getchar();
if (i == '\n') i = getchar();
if (i == '0') break;
switch (i) {
case 'A':
if (x - 1 < 0) {
success = false;
break;
}
swap(grid[x][y], grid[x - 1][y]);
x--;
break;
case 'B':
if (x + 1 > 4) {
success = false;
break;
}
swap(grid[x][y], grid[x + 1][y]);
x++;
break;
case 'L':
if (y - 1 < 0) {
success = false;
break;
}
swap(grid[x][y], grid[x][y - 1]);
y--;
break;
case 'R':
if (y + 1 > 4) {
success = false;
break;
}
swap(grid[x][y], grid[x][y + 1]);
y++;
break;
}
}
if (kase != 1) printf("\n");
printf("Puzzle #%d:\n", kase);
if (!success) printf("This puzzle has no final configuration.\n");
else {
for (auto &i : grid) {
for (int j = 0; j < 5; j++) printf((j == 0) ? "%c" : " %c", i[j]);
printf("\n");
}
}
}
}
| 28.282609 | 82 | 0.259416 | Insouciant21 |
079de2e3f63c950bede97fde173e4f9d0a0252f5 | 2,765 | hpp | C++ | common/dpcpp/cuckoo_hashtable.hpp | bagrorg/dwarf_bench | e06427c2b64b1696ba88a46ba758b1f5c9605893 | [
"MIT"
] | 5 | 2021-09-17T19:16:23.000Z | 2022-03-18T11:45:44.000Z | common/dpcpp/cuckoo_hashtable.hpp | bagrorg/dwarf_bench | e06427c2b64b1696ba88a46ba758b1f5c9605893 | [
"MIT"
] | 20 | 2021-07-28T15:20:18.000Z | 2021-09-02T14:18:03.000Z | common/dpcpp/cuckoo_hashtable.hpp | bagrorg/dwarf_bench | e06427c2b64b1696ba88a46ba758b1f5c9605893 | [
"MIT"
] | null | null | null | #include <CL/sycl.hpp>
#include "hashfunctions.hpp"
template <class Key, class Val, class Hasher1, class Hasher2> class CuckooHashtable{
private:
sycl::global_ptr<Key> _keys;
sycl::global_ptr<Val> _vals;
const size_t _size;
Hasher1 _hasher1;
Hasher2 _hasher2;
const Key _EMPTY_KEY = std::numeric_limits<Key>::max();
sycl::global_ptr<uint32_t> _bitmask;
static constexpr uint32_t elem_sz = CHAR_BIT * sizeof(uint32_t);
public:
explicit CuckooHashtable(const size_t size, sycl::global_ptr<Key> keys, sycl::global_ptr<Val> vals,
sycl::global_ptr<uint32_t> bitmask, Hasher1 hasher1, Hasher2 hasher2):
_size(size), _keys(keys), _vals(vals), _bitmask(bitmask), _hasher1(hasher1), _hasher2(hasher2){}
const std::pair<Val, bool> at(Key key) const {
auto pos1 = _hasher1(key);
auto pos2 = _hasher2(key);
if (_keys[pos1] == key)
return {_vals[pos1], true};
if (_keys[pos2] == key)
return {_vals[pos2], true};
return {{}, false};
}
bool has(Key key) const {
return _keys[_hasher1(key)] == key || _keys[_hasher2(key)] == key;
}
bool insert(Key key, Val value) {
// TODO: change loop detection
size_t cnt = 0;
while (cnt < _size) {
size_t pos[] = {_hasher1(key), _hasher2(key)};
for (size_t i = 0; i < 2; i++) {
lock(pos[i]);
if (_keys[pos[i]] == _EMPTY_KEY) {
_keys[pos[i]] = key;
_vals[pos[i]] = value;
unlock(pos[i]);
return true;
}
unlock(pos[i]);
}
lock(pos[0]);
std::swap(key, _keys[pos[1]]);
std::swap(value, _vals[pos[1]]);
unlock(pos[0]);
cnt++;
}
return false;
}
void lock(size_t pos) {
uint32_t present;
uint32_t major_idx = pos / elem_sz;
uint8_t minor_idx = pos % elem_sz;
uint32_t mask = uint32_t(1) << minor_idx;
do {
present = sycl::atomic<uint32_t>(_bitmask + major_idx).fetch_or(mask);
} while (present & mask);
}
void unlock(size_t pos) {
uint32_t major_idx = pos / elem_sz;
uint8_t minor_idx = pos % elem_sz;
uint32_t mask = uint32_t(1) << minor_idx;
sycl::atomic<uint32_t>(_bitmask + major_idx).fetch_and(~mask);
}
}; | 34.135802 | 108 | 0.491863 | bagrorg |
07a1c7952a9a1bd56840f41440de7d7325c4695b | 2,571 | cpp | C++ | aifm/exp/fig12a/linux_mem/read/main.cpp | asarthas/AIFM | aaf7113cb3ba58381174e8b86bdd7a0f1fd1acc4 | [
"MIT"
] | 49 | 2020-11-01T00:14:40.000Z | 2022-03-26T07:28:12.000Z | aifm/exp/fig12a/linux_mem/read/main.cpp | asarthas/AIFM | aaf7113cb3ba58381174e8b86bdd7a0f1fd1acc4 | [
"MIT"
] | 12 | 2020-12-15T08:30:19.000Z | 2022-03-13T03:54:24.000Z | aifm/exp/fig12a/linux_mem/read/main.cpp | asarthas/AIFM | aaf7113cb3ba58381174e8b86bdd7a0f1fd1acc4 | [
"MIT"
] | 19 | 2020-12-24T22:32:22.000Z | 2022-03-30T01:33:43.000Z | extern "C" {
#include <runtime/runtime.h>
}
#include "deref_scope.hpp"
#include "device.hpp"
#include "helpers.hpp"
#include "manager.hpp"
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <iostream>
using namespace far_memory;
using namespace std;
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
using Data_t = uint64_t;
constexpr uint64_t kCacheSize = 5ULL << 30; // 5 GB.
constexpr uint64_t kFarMemSize = 5ULL << 30; // 5 GB.
constexpr uint64_t kWorkSetSize = 1ULL << 30; // 1 GB.
constexpr uint64_t kNumEntries = kWorkSetSize / sizeof(Data_t);
constexpr uint64_t kMeasureTimes = 1 << 20; // 1 million times.
constexpr uint64_t kRawMemoryAccessCycles = 170; // 1 million times.
constexpr uint64_t kNumConnections = 600;
constexpr uint8_t kNumGCThreads = 21;
unsigned cycles_low_start, cycles_high_start;
unsigned cycles_low_end, cycles_high_end;
uint32_t g_seed = 0xDEADBEEF;
unique_ptr<Data_t> ptrs[kNumEntries];
std::vector<uint64_t> durations;
uint32_t x = 123456789, y = 362436069, z = 521288629;
uint32_t xorshf96(void) {
uint32_t t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
template <typename T> void print_percentile(int percentile, T *container) {
auto idx = percentile / 100.0 * container->size();
cout << percentile << "\t" << (*container)[idx] << endl;
}
template <typename T> void print_results(T *container) {
sort(container->begin(), container->end());
print_percentile(90, container);
}
void do_work(void *arg) {
for (uint64_t i = 0; i < kNumEntries; i++) {
ptrs[i].reset(new Data_t());
}
DerefScope scope;
for (uint64_t i = 0; i < kMeasureTimes; i++) {
auto idx = xorshf96() % kNumEntries;
helpers::timer_start(&cycles_high_start, &cycles_low_start);
{
const Data_t *raw_const_ptr = ptrs[idx].get();
ACCESS_ONCE(*raw_const_ptr);
}
helpers::timer_end(&cycles_high_end, &cycles_low_end);
auto duration = helpers::get_elapsed_cycles(
cycles_high_start, cycles_low_start, cycles_high_end, cycles_low_end);
if (duration > kRawMemoryAccessCycles) {
durations.push_back(duration);
}
}
print_results(&durations);
}
int main(int argc, char *argv[]) {
int ret;
if (argc < 2) {
std::cerr << "usage: [cfg_file]" << std::endl;
return -EINVAL;
}
ret = runtime_init(argv[1], do_work, NULL);
if (ret) {
std::cerr << "failed to start runtime" << std::endl;
return ret;
}
return 0;
}
| 23.587156 | 78 | 0.671723 | asarthas |
07a9af8089988f8008f68223ee76642918479c26 | 5,326 | cpp | C++ | vmcon2D/DART_Interface.cpp | snumrl/volcon2D | 4b4277cef2caa0f62429781acedc71d9f8b6bd0d | [
"Apache-2.0"
] | null | null | null | vmcon2D/DART_Interface.cpp | snumrl/volcon2D | 4b4277cef2caa0f62429781acedc71d9f8b6bd0d | [
"Apache-2.0"
] | null | null | null | vmcon2D/DART_Interface.cpp | snumrl/volcon2D | 4b4277cef2caa0f62429781acedc71d9f8b6bd0d | [
"Apache-2.0"
] | null | null | null | #include "DART_Interface.h"
#include "GUI/GL_function.h"
#include <Eigen/Geometry>
#include <vector>
#include "GL/glut.h"
using namespace dart::dynamics;
using namespace dart::simulation;
/*************************************************************
MakeRootBody function
This function makes root body for skeleton.
globalOffset param is center of mass of body.
*************************************************************/
void
MakeRootBody(const SkeletonPtr& skel, const std::string& name,const Eigen::Vector3d& size,const Eigen::Vector3d& c_to_joint,const double& mass)
{
ShapePtr shape = std::shared_ptr<BoxShape>(new BoxShape(size));
dart::dynamics::Inertia inertia;
inertia.setMass(mass);
inertia.setMoment(shape->computeInertia(mass));
RevoluteJoint::Properties prop;
prop.mName = name + "_joint";
prop.mAxis = Eigen::Vector3d::UnitZ();
prop.mT_ChildBodyToJoint.translation() = c_to_joint;
BodyNodePtr bn = skel->createJointAndBodyNodePair<RevoluteJoint>(
nullptr,prop,BodyNode::AspectProperties(name)).second;
auto sn = bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(shape);
bn->setInertia(inertia);
}
/*************************************************************
MakeBody function
This function makes articulated body of skeleton.
Input is straightforward, except globaloffset and jointoffset.
globaloffset parameter is center of mass of body expressed in world coordinate.
jointoffset parameter is position of joint expressed in child(this) body coordinate.
*************************************************************/
void
MakeBody(const SkeletonPtr& skel,const BodyNodePtr& parent,const std::string& name,
const Eigen::Vector3d& size,
const Eigen::Vector3d& p_to_joint,
const Eigen::Vector3d& c_to_joint,const double& mass)
{
ShapePtr shape = std::shared_ptr<BoxShape>(new BoxShape(size));
dart::dynamics::Inertia inertia;
inertia.setMass(mass);
inertia.setMoment(shape->computeInertia(mass));
RevoluteJoint::Properties prop;
prop.mName = name + "_joint";
prop.mAxis = Eigen::Vector3d::UnitZ();
prop.mT_ParentBodyToJoint.translation() = p_to_joint;
prop.mT_ChildBodyToJoint.translation() = c_to_joint;
BodyNodePtr bn = skel->createJointAndBodyNodePair<RevoluteJoint>(
parent,prop,BodyNode::AspectProperties(name)).second;
auto sn = bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(shape);
bn->setInertia(inertia);
}
void MakeWeldBody(const SkeletonPtr& skel,
const BodyNodePtr& parent,const std::string& name,const double& radius,
const Eigen::Vector3d& p_to_joint,const Eigen::Vector3d& c_to_joint,const double& mass)
{
ShapePtr shape = std::shared_ptr<SphereShape>(new SphereShape(radius));
dart::dynamics::Inertia inertia;
inertia.setMass(mass);
inertia.setMoment(shape->computeInertia(mass));
WeldJoint::Properties prop;
prop.mName = name + "_joint";
prop.mT_ParentBodyToJoint.translation() = p_to_joint;
prop.mT_ChildBodyToJoint.translation() = c_to_joint;
BodyNodePtr bn = skel->createJointAndBodyNodePair<WeldJoint>(
parent,prop,BodyNode::AspectProperties(name)).second;
auto sn = bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(shape);
bn->setInertia(inertia);
}
void
MakeBall(const SkeletonPtr& skel,const double& radius,const double& mass)
{
ShapePtr shape = std::shared_ptr<SphereShape>(new SphereShape(radius));
dart::dynamics::Inertia inertia;
inertia.setMass(mass);
inertia.setMoment(shape->computeInertia(mass));
FreeJoint::Properties prop;
prop.mT_ParentBodyToJoint.setIdentity();
prop.mT_ChildBodyToJoint.setIdentity();
BodyNodePtr bn = skel->createJointAndBodyNodePair<FreeJoint>(
nullptr,prop,BodyNode::AspectProperties("ball")).second;
auto sn = bn->createShapeNodeWith<VisualAspect, CollisionAspect, DynamicsAspect>(shape);
bn->setCollidable(false);
bn->setInertia(inertia);
}
void
DrawSkeleton(const dart::dynamics::SkeletonPtr& skel,const Eigen::Vector3d& color)
{
glDisable(GL_DEPTH_TEST);
for(int j =0;j<skel->getNumBodyNodes();j++)
{
auto bn = skel->getBodyNode(j);
auto shapeNodes = bn->getShapeNodesWith<VisualAspect>();
auto T = bn->getTransform();
for (auto& sn : shapeNodes)
{
auto shape = sn->getShape().get();
if (shape->is<BoxShape>())
{
const auto* box = static_cast<const BoxShape*>(shape);
const auto& size = box->getSize();
DrawCapsule(T,size[0],size[1],color);
}
else if (shape->is<SphereShape>())
{
const auto* sphere = static_cast<const SphereShape*>(shape);
const auto& r = sphere->getRadius();
DrawSphere(T,r,color);
}
}
}
for(int j =0;j<skel->getNumBodyNodes();j++)
{
auto bn = skel->getBodyNode(j);
auto T = bn->getTransform();
Eigen::Vector3d p = T.translation();
Eigen::Vector3d v = bn->getCOMLinearVelocity();
v*= 0.05;
DrawArrow(p.block<2,1>(0,0),v.block<2,1>(0,0),Eigen::Vector3d(0,0,1));
}
glEnable(GL_DEPTH_TEST);
}
| 36.986111 | 143 | 0.657154 | snumrl |
07aac5a1de403d0a564475970c8977c8aedb089a | 3,040 | cpp | C++ | src/swish/hooks-i3nt.cpp | becls/swish-win | bab98dfa757dfd851d8cf5176fb3e88115f311f4 | [
"MIT"
] | 19 | 2017-12-05T21:48:32.000Z | 2019-12-09T05:18:02.000Z | src/swish/hooks-i3nt.cpp | becls/swish-win | bab98dfa757dfd851d8cf5176fb3e88115f311f4 | [
"MIT"
] | null | null | null | src/swish/hooks-i3nt.cpp | becls/swish-win | bab98dfa757dfd851d8cf5176fb3e88115f311f4 | [
"MIT"
] | 1 | 2019-06-15T22:39:56.000Z | 2019-06-15T22:39:56.000Z | // Copyright 2017 Beckman Coulter, Inc.
//
// 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 "stdafx.h"
#define HookStaticFunction(name)\
extern "C" uptr Hook##name(uptr next)\
{\
void* loc;\
uptr prev;\
__asm {lea eax, [name]}\
__asm {mov [loc], eax}\
__asm {mov eax, [eax]}\
__asm {mov [prev], eax}\
DWORD prot;\
VirtualProtect(loc, sizeof(uptr), PAGE_READWRITE, &prot);\
__asm {mov eax, [next]}\
__asm {mov [name], eax}\
VirtualProtect(loc, sizeof(uptr), prot, &prot);\
return prev;\
}
HookStaticFunction(ConnectNamedPipe)
HookStaticFunction(CreateEventW)
HookStaticFunction(CreateFileW)
HookStaticFunction(CreateIoCompletionPort)
HookStaticFunction(CreateNamedPipeW)
HookStaticFunction(CryptAcquireContextW)
HookStaticFunction(CryptGetHashParam)
HookStaticFunction(FormatMessageW)
HookStaticFunction(GetComputerNameW)
HookStaticFunction(GetDiskFreeSpaceExW)
HookStaticFunction(GetFileSizeEx)
HookStaticFunction(GetFullPathNameW)
HookStaticFunction(GetModuleFileNameW)
HookStaticFunction(GetStdHandle)
HookStaticFunction(QueryPerformanceCounter)
HookStaticFunction(QueryPerformanceFrequency)
HookStaticFunction(QueueUserWorkItem)
HookStaticFunction(ReadDirectoryChangesW);
HookStaticFunction(ReadFile)
HookStaticFunction(RegisterWaitForSingleObject)
HookStaticFunction(SetupDiEnumDeviceInterfaces)
HookStaticFunction(SetupDiGetClassDevsW)
HookStaticFunction(SetupDiGetDeviceInterfaceDetailW)
HookStaticFunction(SetEvent)
HookStaticFunction(TerminateProcess)
HookStaticFunction(UuidCreate)
HookStaticFunction(WinUsb_Initialize)
HookStaticFunction(WinUsb_ReadPipe)
HookStaticFunction(WinUsb_WritePipe)
HookStaticFunction(WSAAddressToStringW)
HookStaticFunction(WSAEventSelect)
HookStaticFunction(WSARecv)
HookStaticFunction(WSASend)
HookStaticFunction(WSAStartup)
HookStaticFunction(WriteFile)
HookStaticFunction(getpeername)
HookStaticFunction(getsockname)
HookStaticFunction(listen)
HookStaticFunction(setsockopt)
HookStaticFunction(socket)
HookStaticFunction(timeGetTime)
| 36.626506 | 70 | 0.819079 | becls |
07abeda787829d35361a1f1ff0cf2f5494618887 | 290 | hpp | C++ | pythran/pythonic/include/omp/set_nested.hpp | xmar/pythran | dbf2e8b70ed1e4d4ac6b5f26ead4add940a72592 | [
"BSD-3-Clause"
] | null | null | null | pythran/pythonic/include/omp/set_nested.hpp | xmar/pythran | dbf2e8b70ed1e4d4ac6b5f26ead4add940a72592 | [
"BSD-3-Clause"
] | null | null | null | pythran/pythonic/include/omp/set_nested.hpp | xmar/pythran | dbf2e8b70ed1e4d4ac6b5f26ead4add940a72592 | [
"BSD-3-Clause"
] | null | null | null | #ifndef PYTHONIC_INCLUDE_OMP_SET_NESTED_HPP
#define PYTHONIC_INCLUDE_OMP_SET_NESTED_HPP
#include <omp.h>
#include "pythonic/include/utils/functor.hpp"
namespace pythonic
{
namespace omp
{
void set_nested(long val);
DECLARE_FUNCTOR(pythonic::omp, set_nested);
}
}
#endif
| 14.5 | 47 | 0.762069 | xmar |
07ac42f03e495d5514cccd71b2a91d385c2790e7 | 830 | cpp | C++ | convolution/test/ntt.test.cpp | rsm9/cplib-cpp | 269064381eb259a049236335abb31f8f73ded7f4 | [
"MIT"
] | 4 | 2020-05-13T05:06:22.000Z | 2020-09-18T17:03:36.000Z | convolution/test/ntt.test.cpp | rsm9/cplib-cpp | 269064381eb259a049236335abb31f8f73ded7f4 | [
"MIT"
] | 1 | 2019-12-11T13:53:17.000Z | 2019-12-11T13:53:17.000Z | convolution/test/ntt.test.cpp | rsm9/cplib-cpp | 269064381eb259a049236335abb31f8f73ded7f4 | [
"MIT"
] | 3 | 2019-12-11T06:45:45.000Z | 2020-09-07T13:45:32.000Z | #define PROBLEM "https://judge.yosupo.jp/problem/convolution_mod"
#include "../ntt.hpp"
#include "../../modint.hpp"
#include "../../number/modint_runtime.hpp"
#include <iostream>
using namespace std;
constexpr int MOD = 998244353;
using mint = ModInt<MOD>;
using mintr = ModIntRuntime;
int main() {
cin.tie(nullptr), ios::sync_with_stdio(false);
mintr::set_mod(MOD);
int N, M;
cin >> N >> M;
vector<mint> A(N), B(M);
vector<mintr> Ar(N), Br(M);
for (int i = 0; i < N; i++) cin >> A[i], Ar[i] = A[i].val();
for (int i = 0; i < M; i++) cin >> B[i], Br[i] = B[i].val();
vector<mint> ret = nttconv(A, B);
vector<mintr> retr = nttconv(Ar, Br);
for (int i = 0; i < N + M - 1; i++) {
assert(ret[i].val() == retr[i].val());
cout << ret[i] << ' ';
}
cout << '\n';
}
| 25.9375 | 65 | 0.543373 | rsm9 |
07ade805a1e01f9d2aeb281d4a3f53b0dd02f27b | 2,671 | cpp | C++ | src/ui/Dialog.cpp | tomasiser/pepr3d | 5eaacd573c553e0e8eb79212842894bf32b5c666 | [
"BSD-2-Clause"
] | 128 | 2019-11-18T16:09:58.000Z | 2022-01-15T03:59:51.000Z | src/ui/Dialog.cpp | tomasiser/pepr3d | 5eaacd573c553e0e8eb79212842894bf32b5c666 | [
"BSD-2-Clause"
] | 3 | 2019-04-01T17:41:19.000Z | 2020-07-23T08:55:08.000Z | src/ui/Dialog.cpp | tomasiser/pepr3d | 5eaacd573c553e0e8eb79212842894bf32b5c666 | [
"BSD-2-Clause"
] | 31 | 2019-04-04T11:28:11.000Z | 2022-03-14T08:52:38.000Z | #include "Dialog.h"
namespace pepr3d {
bool Dialog::draw() const {
bool isAccepted = false;
if(!ImGui::IsPopupOpen("##dialog")) {
ImGui::OpenPopup("##dialog");
}
ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_NoTitleBar;
window_flags |= ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoResize;
window_flags |= ImGuiWindowFlags_NoCollapse;
window_flags |= ImGuiWindowFlags_NoNav;
const ImGuiIO& io = ImGui::GetIO();
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x / 2.0f, io.DisplaySize.y / 2.0f), ImGuiCond_Always,
ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowSize(ImVec2(400.0f, -1.0f));
ImGui::SetNextWindowBgAlpha(1.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ci::ColorA::hex(0xFFFFFF));
ImGui::PushStyleColor(ImGuiCol_Border, ci::ColorA::hex(0xE5E5E5));
ImGui::PushStyleColor(ImGuiCol_Text, ci::ColorA::hex(0x1C2A35));
ImGui::PushStyleColor(ImGuiCol_Separator, ci::ColorA::hex(0xE5E5E5));
ImGui::PushStyleColor(ImGuiCol_Button, ci::ColorA::zero());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ci::ColorA::hex(0xCFD5DA));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ci::ColorA::hex(0xA3B2BF));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, glm::vec2(12.0f));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, glm::vec2(8.0f, 6.0f));
if(ImGui::BeginPopupModal("##dialog", nullptr, window_flags)) {
auto captionColor = ci::ColorA::hex(0xEB5757); // red
if(mType == DialogType::Warning) {
captionColor = ci::ColorA::hex(0xF2994A); // orange
} else if(mType == DialogType::Information) {
captionColor = ci::ColorA::hex(0x017BDA); // blue
}
ImGui::PushStyleColor(ImGuiCol_Text, captionColor);
ImGui::TextWrapped(mCaption.c_str());
ImGui::PopStyleColor();
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
ImGui::TextWrapped(mMessage.c_str());
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
isAccepted = ImGui::Button(mAcceptButton.c_str(), glm::ivec2(ImGui::GetContentRegionAvailWidth(), 33));
ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(),
(ImColor)ci::ColorA::hex(0xE5E5E5));
if(isAccepted) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(7);
return isAccepted;
}
} // namespace pepr3d | 39.865672 | 111 | 0.649569 | tomasiser |
07b0da8a8d5eda5b8d8ef7dfa91b2c781d0cbc47 | 539 | cpp | C++ | 500-600/543.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | 500-600/543.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | 500-600/543.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | long int euler543() {
long int F[45] = {0, 1};
for (int i = 2; i <= 44; i++) {F[i] = F[i - 2] + F[i - 1]; }
long int sum = 2; // Seed with value for 3rd Fibonacci number
for (int i = 4; i <= 44; i++){
sum += primesieve::parallel_count_primes(1, F[i]) + // k=1
F[i] / 2 - 2 + primesieve::parallel_count_primes(1, F[i] - 2) + // k=2
(F[i] / 2 - 2) * (F[i] + 1) - 2 * (F[i] / 2 * (F[i] / 2 + 1) / 2 - 3); // k>2
}
return sum;
} | 35.933333 | 91 | 0.393321 | Thomaw |
07b39443adf607ff4bc02b5186e4858ec5d009b6 | 1,273 | cpp | C++ | src/raw-cpp/src/states/level-state.cpp | guillaume-haerinck/RollGoal | c6f95fad3b042da5c537dc892f5879326074549a | [
"MIT"
] | 6 | 2019-06-16T18:56:50.000Z | 2020-07-11T01:53:51.000Z | src/raw-cpp/src/states/level-state.cpp | guillaume-haerinck/RollGoal | c6f95fad3b042da5c537dc892f5879326074549a | [
"MIT"
] | null | null | null | src/raw-cpp/src/states/level-state.cpp | guillaume-haerinck/RollGoal | c6f95fad3b042da5c537dc892f5879326074549a | [
"MIT"
] | 2 | 2019-07-07T21:22:15.000Z | 2020-03-25T16:01:33.000Z | #include "level-state.h"
#include "systems/physic-system.h"
#include "systems/render-system.h"
#include "systems/input-system.h"
LevelState::LevelState(Context context) : IState(STATE_LEVEL, context)
{
m_systems = {
new PhysicSystem(*context.registry),
new RenderSystem(*context.registry),
new InputSystem(*context.registry, context.singletonComponentsId)
};
}
LevelState::~LevelState() {
for (const auto system : m_systems) {
delete system;
}
}
/////////////////////////////////////////////////////////////////////////////
////////////////////////////// PUBLIC METHODS ///////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void LevelState::onEnter() {
m_lifeCycle = StateLifeCycle::HAS_ENTERED;
}
void LevelState::update() {
for (const auto system : m_systems) {
system->update();
}
if (m_lifeCycle == StateLifeCycle::HAS_ENTERED)
m_lifeCycle = StateLifeCycle::HAS_UPDATED;
}
void LevelState::onExit() {
m_lifeCycle = StateLifeCycle::HAS_EXITED;
}
/////////////////////////////////////////////////////////////////////////////
//////////////////////////// GETTERS & SETTERS //////////////////////////////
/////////////////////////////////////////////////////////////////////////////
| 25.46 | 77 | 0.48154 | guillaume-haerinck |
07b5abd29b72cf8ae980b74807a8960950538081 | 951 | cpp | C++ | Source/SageChargeBar.cpp | Project2CITM/Proyecto2 | a10c78fded2b226629a817c4e9cd46ed9e8b5bc8 | [
"MIT"
] | 2 | 2022-03-13T20:31:50.000Z | 2022-03-28T06:43:45.000Z | Source/SageChargeBar.cpp | Project2CITM/The-last-purifier | e082e8ce6d6aa90b1d232cd9e15f4bec994556ed | [
"MIT"
] | null | null | null | Source/SageChargeBar.cpp | Project2CITM/The-last-purifier | e082e8ce6d6aa90b1d232cd9e15f4bec994556ed | [
"MIT"
] | null | null | null | #include "SageChargeBar.h"
SageChargeBar::SageChargeBar(iPoint pos, int width, int height, int values[3], SDL_Color totalColor, SDL_Color currentColors[3]) : Bar(pos, width, height, values[0], totalColor, currentColors[0])
{
totalValues[0] = values[0];
totalValues[1] = values[1];
totalValues[2] = values[2];
currentRectColors[0] = currentColors[0];
currentRectColors[1] = currentColors[1];
currentRectColors[2] = currentColors[2];
currentValueMaximum = 0;
}
void SageChargeBar::PreUpdate()
{
currentRectColor = currentRectColors[currentValueMaximum];
}
void SageChargeBar::SetValue(int value)
{
this->currentValue = value;
while (currentValue > totalValues[currentValueMaximum] && currentValueMaximum != 2) currentValueMaximum++;
totalValue = totalValues[currentValueMaximum];
SetValuePercentage((float)currentValue / (float)totalValue);
}
void SageChargeBar::ResetValues()
{
currentValueMaximum = 0;
this->currentValue = 0;
}
| 25.702703 | 195 | 0.756046 | Project2CITM |
07be2b957c358e75c60d9b0ffa30e191b561a4b5 | 1,791 | cpp | C++ | Chapter-6-Functions/6.7-The-Return-Statement/Examples/6-11.cpp | jesushilarioh/C-Plus-Plus | bbff921460ac4267af48558f040c7d82ccf42d5e | [
"MIT"
] | 3 | 2019-10-28T01:12:46.000Z | 2021-10-16T09:16:31.000Z | Chapter-6-Functions/6.7-The-Return-Statement/Examples/6-11.cpp | jesushilarioh/C-Plus-Plus | bbff921460ac4267af48558f040c7d82ccf42d5e | [
"MIT"
] | null | null | null | Chapter-6-Functions/6.7-The-Return-Statement/Examples/6-11.cpp | jesushilarioh/C-Plus-Plus | bbff921460ac4267af48558f040c7d82ccf42d5e | [
"MIT"
] | 4 | 2020-04-10T17:22:17.000Z | 2021-11-04T14:34:00.000Z | //**************************************************************
// This program uses a function to perform division. If division
// by zero is detected, the function returns.
//
// by: Jesus Hilario Hernandez
// last updated: November 2, 2016
//**************************************************************
#include <iostream>
using namespace std;
// Function prototype.
void divide(double, double);
double inputVal(double); // For error Checking
int main()
{
double num1, num2;
cout << "Enter two numbers and I will divide the first\n";
cout << "number by the second number: ";
num1 = inputVal(num1);
num2 = inputVal(num2);
divide(num1, num2);
return 0;
}
//*******************************************************************
// Definition of function divide. *
// Uses two parameters: arg1 and arg2. The function divides arg1 *
// by arg2 and shows the result. If arg2 is zero, however, the *
// function returns. *
//*******************************************************************
void divide(double arg1, double arg2)
{
if (arg2 == 0.0)
{
cout << "Sorry, I cannot divide by zero.\n";
return;
}
cout << "The quotient is " << (arg1 / arg2) << endl;
}
//*******************************************************************
// Function inputVal prompts the user to enter valid input data. *
// In this case the double data type is accepted only. *
//*******************************************************************
double inputVal(double num)
{
while (!(cin >> num))
{
cout << "I'm sorry a number must be entered: ";
cin.clear();
cin.ignore(123, '\n');
}
return num;
}
| 30.355932 | 69 | 0.450586 | jesushilarioh |
07c0ff457ca4a60a79fbf0d6df9a8df269f87f42 | 411 | cpp | C++ | chapter-7/7.37.cpp | zero4drift/Cpp-Primer-5th-Exercises | d3d0f0d228e8c2c5a3b3fe1fd03ce34e0894e93f | [
"MIT"
] | null | null | null | chapter-7/7.37.cpp | zero4drift/Cpp-Primer-5th-Exercises | d3d0f0d228e8c2c5a3b3fe1fd03ce34e0894e93f | [
"MIT"
] | null | null | null | chapter-7/7.37.cpp | zero4drift/Cpp-Primer-5th-Exercises | d3d0f0d228e8c2c5a3b3fe1fd03ce34e0894e93f | [
"MIT"
] | null | null | null | #include <iostream>
#include "Sales_data.hpp"
using std::cin;
Sales_data first_item(cin); // Sales_data(istream &is) {read(is, *this);} data members depend on cin
int main()
{
Sales_data next; // Sales_data(string s = ""): bookNo(s) {} bookNo "", units_sold 0, revenue 0.0
Sales_data last("9-999-99999-9"); // Sales_data(string s = ""): bookNo(s) {} bookNo "9-999-99999-9", units_sold 0, revenue 0.0
}
| 31.615385 | 129 | 0.6691 | zero4drift |
07c3faccaaec05a58727af6f1b4d826772024420 | 5,734 | cpp | C++ | examples/example_ranker.cpp | dbremner/mili | 7aab844b02c35c855c5823e71beb4d6576df8d6d | [
"BSL-1.0"
] | 17 | 2015-05-06T00:44:46.000Z | 2022-01-19T02:50:49.000Z | examples/example_ranker.cpp | dbremner/mili | 7aab844b02c35c855c5823e71beb4d6576df8d6d | [
"BSL-1.0"
] | null | null | null | examples/example_ranker.cpp | dbremner/mili | 7aab844b02c35c855c5823e71beb4d6576df8d6d | [
"BSL-1.0"
] | 6 | 2015-09-16T07:46:27.000Z | 2017-10-17T04:21:14.000Z | /*
example_ranker: An example that uses MiLi's Ranker.
This file is part of the MiLi Minimalistic Library.
Copyright (C) Ezequiel S. Velez, FuDePAN 2010
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt in the root directory or
copy at http://www.boost.org/LICENSE_1_0.txt)
MiLi 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
This is an example file.
*/
#include <iostream>
#include "mili/mili.h"
using namespace mili;
using namespace std;
template <class T>
void print(CAutonomousIterator<T> it)
{
while (!it.end())
{
cout << *it << endl;
++it;
}
}
//------------------------------
struct Player
{
string name;
float score;
Player(string name, float score): name(name), score(score)
{}
void print() const
{
cout << name << " - " << score << endl;
}
};
/* Compare two Players' names */
struct PlayerUnique
{
bool operator()(const Player& p1, const Player& p2)
{
return p1.name < p2.name;
}
};
/* Compare two Players' scores */
struct PlayerRanking
{
bool operator()(const Player& p1, const Player& p2)
{
return p1.score > p2.score;
}
};
typedef UniqueRanker<Player, PlayerRanking, PlayerUnique> PlayersRanking;
void print_classes(CAutonomousIterator<PlayersRanking> it)
{
while (!it.end())
{
it->print();
++it;
}
cout << "_______________________" << endl;
}
void unique_ranker_test()
{
PlayersRanking UR(5);
cout << UR.insert(Player("Umpa lumpa A", .1)) << endl;
cout << UR.insert(Player("Umpa lumpa B", .3)) << endl;
cout << UR.insert(Player("Umpa lumpa C", .3)) << endl;
cout << UR.insert(Player("Umpa lumpa B", .2)) << endl;
cout << UR.insert(Player("Umpa lumpa D", .5)) << endl;
cout << UR.insert(Player("Umpa lumpa E", .6)) << endl;
cout << UR.insert(Player("Umpa lumpa B", .5)) << endl;
cout << UR.insert(Player("Umpa lumpa F", .8)) << endl;
CAutonomousIterator<PlayersRanking> it(UR);
print_classes(it);
UR.top().print(); // Print the top Umpa Lumpa
UR.bottom().print(); // Print the bottom Umpa Lumpa
cout << "-------- remove Umpa lumpa E --------" << endl;
UR.remove(Player("Umpa lumpa E", .6));
CAutonomousIterator<PlayersRanking> it2(UR);
print_classes(it2);
}
//----------UNIQUE RANKER LINEAL TEST--------------
struct PlayerLineal : Player
{
PlayerLineal(const string& name, float score): Player(name, score)
{}
bool operator == (const Player& aPlayer) const
{
return name == aPlayer.name;
}
};
typedef UniqueRankerLineal<PlayerLineal, PlayerRanking> PlayersRankingLineal;
void print_classes_lineal(CAutonomousIterator<PlayersRankingLineal> it)
{
while (!it.end())
{
it->print();
++it;
}
cout << "_______________________" << endl;
}
void unique_ranker_lineal_test()
{
PlayersRankingLineal UR(5);
cout << UR.insert(PlayerLineal("Umpa lumpa A", .1)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa B", .3)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa C", .3)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa B", .2)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa D", .5)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa E", .6)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa B", .5)) << endl;
cout << UR.insert(PlayerLineal("Umpa lumpa F", .8)) << endl;
CAutonomousIterator<PlayersRankingLineal> it(UR);
print_classes_lineal(it);
UR.top().print(); // Print the top Umpa Lumpa
UR.bottom().print(); // Print the bottom Umpa Lumpa
cout << "-------- remove Umpa lumpa E --------" << endl;
UR.remove(PlayerLineal("Umpa lumpa E", .6));
CAutonomousIterator<PlayersRankingLineal> it2(UR);
print_classes_lineal(it2);
}
//-------------------------------------------
typedef Ranker<int, AddBeforeEqual> Ranking;
void ranker_test()
{
const size_t TOP = 5;
const int I = -10;
Ranking R(TOP);
R.insert(10);
R.insert(30);
R.insert(I);
R.insert(20);
R.insert(I);
CAutonomousIterator<Ranking> it(R);
print<Ranking> (it);
cout << "-- Insert 0 and 50 --" << endl;
R.insert(0);
R.insert(50);
CAutonomousIterator<Ranking> it1(R);
print<Ranking> (it1);
R.remove_all(I);
cout << "-- Remove All " << I << " --" << endl;
CAutonomousIterator<Ranking> it2(R);
print<Ranking> (it2);
cout << "----- size: " << R.size() << endl;
cout << "top: " << R.top() << " - bottom: " << R.bottom() << endl;
if (!R.empty()) R.clear();
cout << "size after clear: " << R.size() << endl;
}
//------------------------------------------------------
int main()
{
string test;
cout << "Indicate which library you want to test. (R = Ranker ; UR = Unique Ranker ; URL = Unique Ranker Lineal):" << endl;
cin >> test;
if (test == "R")
ranker_test();
else if (test == "UR")
unique_ranker_test();
else if (test == "URL")
unique_ranker_lineal_test();
else
cout << "Error: you must choose R, UR or URL" << endl;
return 0;
}
| 26.794393 | 127 | 0.591036 | dbremner |
07c3fc4540820ec5f4c605347750b2b7c4f550da | 505 | cpp | C++ | Problems/Codeforces/CF-816B.cpp | zhugezy/giggle | dfa50744a9fd328678b75af8135bbd770f18a6ac | [
"MIT"
] | 6 | 2019-10-12T15:14:10.000Z | 2020-02-02T11:16:00.000Z | Problems/Codeforces/CF-816B.cpp | zhugezy/giggle | dfa50744a9fd328678b75af8135bbd770f18a6ac | [
"MIT"
] | 73 | 2019-10-11T15:09:40.000Z | 2020-09-15T07:49:24.000Z | Problems/Codeforces/CF-816B.cpp | zhugezy/giggle | dfa50744a9fd328678b75af8135bbd770f18a6ac | [
"MIT"
] | 5 | 2019-10-14T02:57:39.000Z | 2020-06-19T09:38:34.000Z | // 816B
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k, q, l, r;
int b[N], sum[N];
int main() {
scanf("%d%d%d", &n, &k, &q);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &l, &r);
b[l]++;
b[r + 1]--;
}
int tot = 0;
for (int i = 1; i <= 200000; ++i) {
tot += b[i];
sum[i] = sum[i - 1];
if (tot >= k)
sum[i]++;
}
for (int i = 1; i <= q; ++i) {
scanf("%d%d", &l, &r);
printf("%d\n", sum[r] - sum[l - 1]);
}
return 0;
} | 17.413793 | 40 | 0.4 | zhugezy |
07c689c64812600c527e6d8a38f716b433e8cff0 | 1,507 | cpp | C++ | src/utils/posix/spawn.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | 1 | 2020-08-03T18:57:01.000Z | 2020-08-03T18:57:01.000Z | src/utils/posix/spawn.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | 1 | 2021-03-07T21:32:10.000Z | 2021-03-08T13:56:10.000Z | src/utils/posix/spawn.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | null | null | null | #include "utils/spawn.h"
#include "utils/command.h"
#include <vector>
#include <sys/wait.h>
#include <unistd.h>
namespace tofi
{
bool spawn(Command command)
{
// Fork first child to start a new session
pid_t pid{fork()};
if (0 == pid)
{
if (pid < 0)
{
exit(errno);
}
// Try getting a new session id.
pid = setsid();
if (pid < 0)
{
exit(errno);
}
// Fork second child who shall live a very long life
pid = fork();
if (0 == pid)
{
std::vector<char *> argv{command.argv.size() + 1, nullptr};
std::transform(std::begin(command.argv), std::end(command.argv), std::begin(argv), [](std::string &str) {
return str.data();
});
// command should be the first argument in argv, otherwise certain apps won't run correctly
execvp(argv[0], argv.data());
}
// Exit success or failure for the first child.
exit(pid > 0 ? 0 : errno);
}
if (pid < 0)
{
return false;
}
int stat{};
waitpid(pid, &stat, 0);
// Oddly, even if we're "successful" here, we don't actually know what happened to the child we care about
return WIFEXITED(stat) && 0 == WEXITSTATUS(stat);
}
} // namespace tofi
| 25.982759 | 121 | 0.474453 | scaryrawr |
07c77156c0c7ac935870303eed9006b25034cfde | 5,755 | cpp | C++ | Src/Object.cpp | bDiazCentro/AlchemyFramework | 6b55cdef1d0b9ddb4248382e44bbbfdb8320f062 | [
"MIT"
] | null | null | null | Src/Object.cpp | bDiazCentro/AlchemyFramework | 6b55cdef1d0b9ddb4248382e44bbbfdb8320f062 | [
"MIT"
] | null | null | null | Src/Object.cpp | bDiazCentro/AlchemyFramework | 6b55cdef1d0b9ddb4248382e44bbbfdb8320f062 | [
"MIT"
] | null | null | null | #include "Object.hpp"
#include <algorithm>
#include "GameManager.hpp"
#define VNAME(x) #x
#pragma region CONSTRUCTORS
Object::Object()
{
std::string name = "object";
int renameTry = 1;
std::string nameComplement = "";
while (GameManager::Instance()->ReturnGameObjectByName(name + nameComplement) != nullptr)
{
nameComplement = " (" + std::to_string(renameTry++) + ")";
}
objectName = name + nameComplement;
AddComponent(ComponentType::TRANSFORM);
}
Object::Object(string name)
{
int renameTry = 1;
std::string nameComplement = "";
while (GameManager::Instance()->ReturnGameObjectByName(name+nameComplement) != nullptr)
{
nameComplement = " ("+std::to_string(renameTry++)+")";
}
objectName = name+nameComplement;
AddComponent(ComponentType::TRANSFORM);
GameManager::Instance()->AddGameObject(this);
}
#pragma endregion
#pragma region SETTERS AND GETTERS
string Object::ObjectName()
{
return objectName;
}
void Object::ObjectName(string name)
{
int renameTry = 1;
std::string nameComplement = "";
while (GameManager::Instance()->ReturnGameObjectByName(name + nameComplement) != nullptr)
{
nameComplement = " (" + std::to_string(renameTry++) + ")";
}
objectName = name+nameComplement;
}
#pragma endregion
#pragma region OBJECT FUNCTIONS
void Object::DebugObjectInfo()
{
cout << "- - - - - - - - - - - - - - - - - - - - - - - -" << endl;
cout << "Object name: " << ObjectName().c_str() << endl << endl;
for (int i = 0; i < components.size(); i++)
{
switch (componentType[i])
{
case TRANSFORM:
cout << "TRANSFORM INFO" << endl;
components[i]->transform.Debug();
break;
case SPRITE:
cout << "SPRITE RENDERER INFO" << endl;
components[i]->spriteRenderer.Debug();
break;
case BOX_2D_COLLIDER:
cout << "BOX 2D COLLIDER INFO" << endl;
components[i]->box2dCollider.Debug();
break;
case CIRCLE_COLLIDER:
cout << "CIRCLE COLLIDER INFO" << endl;
components[i]->circleCollider.Debug();
break;
case CAMERA:
cout << "CAMERA INFO" << endl;
components[i]->cameraComponent.Debug();
break;
default:
break;
}
cout << endl;
}
}
void Object::AddComponent(ComponentType type)
{
if (std::find(componentType.begin(), componentType.end(), type) != componentType.end())
{
cout << "(" << objectName << ") already has a " << GetComponentName(type) << " component." << endl;
return;
}
Component *component = new Component();
switch (type)
{
case ComponentType::TRANSFORM:
new (&component->transform) TransformComponent(this);
break;
case ComponentType::SPRITE:
new (&component->spriteRenderer) SpriteRendererComponent(this);
objectHasSpriteComponent = true;
break;
case CIRCLE_COLLIDER:
new (&component->circleCollider) CircleColliderComponent(this);
break;
case BOX_2D_COLLIDER:
new (&component->box2dCollider) Box2dColliderComponent(this);
break;
case CAMERA:
new (&component->cameraComponent) CameraComponent(this);
break;
default:
cout << "(" << objectName << ") " << GetComponentName(type) << " component cannot be add to a gameObject object." << endl;
break;
}
components.push_back(component);
componentType.push_back(type);
}
void Object::RemoveComponent(ComponentType type)
{
if (TRANSFORM == type )
{
cout << "(" << objectName << ") " << GetComponentName(type) << " component cannot be removed from object." << endl;
return;
}
if (std::find(componentType.begin(), componentType.end(), type) != componentType.end())
{
int index = GetIndex(type);
components.erase(components.begin() + index);
componentType.erase(componentType.begin() + index);
if (type == SPRITE)objectHasSpriteComponent = false;
}
else {
cout << "(" << objectName << ")" << " object doesn't have a " << GetComponentName(type) << " component to remove" << endl;
}
}
void Object::Draw()
{
components[GetIndex(ComponentType::SPRITE)]->spriteRenderer.Draw();
}
int Object::GetIndex(const ComponentType type)
{
return find(componentType.begin(), componentType.end(), type) - componentType.begin();
}
Component *Object::GetComponent(const ComponentType type)
{
auto componentTypeIterator = std::find(componentType.cbegin(), componentType.cend(), type);
for (int i = 0; i < componentType.size(); ++i)
{
if (componentType[i] == type)
{
return components[i];
}
}
cout << objectName << " object doesn't have a " << GetComponentName(type) << " component." << endl;
return nullptr;
}
void Object::Update()
{
for (int i = 0; i < components.size(); i++)
{
switch (componentType[i])
{
case TRANSFORM:
components[i]->transform.Update();
break;
case SPRITE:
components[i]->spriteRenderer.Update();
break;
case CIRCLE_COLLIDER:
components[i]->circleCollider.Update();
break;
case BOX_2D_COLLIDER:
components[i]->box2dCollider.Update();
break;
case CAMERA:
components[i]->cameraComponent.Update();
break;
default:
break;
}
}
}
string Object::GetComponentName(ComponentType type)
{
switch (type)
{
case TRANSFORM:
return "transform";
break;
case SPRITE:
return "sprite";
break;
case CIRCLE_COLLIDER:
return "circle collider";
break;
case BOX_2D_COLLIDER:
return "box 2d collider";
break;
case CAMERA:
return "camera";
break;
default:
break;
}
}
void Object::SetVertexPoints(unsigned const int size, float *v_array)
{
vertexPoints = new float[size];
arraySizeInBytes = size * sizeof(float);
numVertex = size / 3;
for (int i = 0; i < size; i++)
{
vertexPoints[i] = v_array[i];
}
}
#pragma endregion | 24.489362 | 125 | 0.647958 | bDiazCentro |
07ca4aaea898196be71b8e746e623b592a9056ad | 3,111 | cpp | C++ | Source/Core/Elements/XMLNodeHandlerSelect.cpp | MatthiasJFM/RmlUi | 557dfdbf76ca1397d72c70003081aae4f33b82d0 | [
"MIT"
] | 1,099 | 2019-05-11T07:04:26.000Z | 2022-03-30T12:39:09.000Z | Source/Core/Elements/XMLNodeHandlerSelect.cpp | MatthiasJFM/RmlUi | 557dfdbf76ca1397d72c70003081aae4f33b82d0 | [
"MIT"
] | 251 | 2019-05-07T08:35:47.000Z | 2022-03-31T20:28:49.000Z | Source/Core/Elements/XMLNodeHandlerSelect.cpp | MatthiasJFM/RmlUi | 557dfdbf76ca1397d72c70003081aae4f33b82d0 | [
"MIT"
] | 148 | 2019-07-08T14:46:04.000Z | 2022-03-31T10:59:33.000Z | /*
* This source file is part of RmlUi, the HTML/CSS Interface Middleware
*
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
*
* 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 "XMLNodeHandlerSelect.h"
#include "../../../Include/RmlUi/Core/Log.h"
#include "../../../Include/RmlUi/Core/Factory.h"
#include "../../../Include/RmlUi/Core/XMLParser.h"
#include "../../../Include/RmlUi/Core/Elements/ElementFormControlSelect.h"
namespace Rml {
XMLNodeHandlerSelect::XMLNodeHandlerSelect()
{}
XMLNodeHandlerSelect::~XMLNodeHandlerSelect()
{}
Element* XMLNodeHandlerSelect::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes)
{
RMLUI_ASSERT(name == "select" || name == "option");
if (name == "select")
{
// Call this node handler for all children
parser->PushHandler("select");
// Attempt to instance the tabset
ElementPtr element = Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes);
ElementFormControlSelect* select_element = rmlui_dynamic_cast<ElementFormControlSelect*>(element.get());
if (!select_element)
{
Log::Message(Log::LT_ERROR, "Instancer failed to create element for tag %s.", name.c_str());
return nullptr;
}
// Add the Select element into the document
Element* result = parser->GetParseFrame()->element->AppendChild(std::move(element));
return result;
}
else if (name == "option")
{
// Call default element handler for all children.
parser->PushDefaultHandler();
ElementPtr option_element = Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes);
Element* result = nullptr;
ElementFormControlSelect* select_element = rmlui_dynamic_cast<ElementFormControlSelect*>(parser->GetParseFrame()->element);
if (select_element)
{
result = option_element.get();
select_element->Add(std::move(option_element));
}
return result;
}
return nullptr;
}
} // namespace Rml
| 35.352273 | 125 | 0.739312 | MatthiasJFM |
07cba57ef33c3215db724e30fc3a01f0b2d60d21 | 2,347 | cpp | C++ | src/byte_buffer_args_processor.cpp | TGAC/grassroots-blast-service | 6fec51a42f58c4ac86f94ed724cacfc620a72d70 | [
"Apache-2.0"
] | 1 | 2020-03-21T17:40:42.000Z | 2020-03-21T17:40:42.000Z | src/byte_buffer_args_processor.cpp | TGAC/grassroots-service-blast | b3af30cdb067fd7a2ca29701d4b3077057751359 | [
"Apache-2.0"
] | null | null | null | src/byte_buffer_args_processor.cpp | TGAC/grassroots-service-blast | b3af30cdb067fd7a2ca29701d4b3077057751359 | [
"Apache-2.0"
] | null | null | null | /*
** Copyright 2014-2016 The Earlham Institute
**
** 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.
*/
/*
* byte_buffer_args_processor.cpp
*
* Created on: 27 Oct 2016
* Author: billy
*/
#include "byte_buffer_args_processor.hpp"
#include "string_utils.h"
#include "alloc_failure.hpp"
#include "streams.h"
#ifdef _DEBUG
#define BYTE_BUFFER_ARGS_PROCESSSOR_DEBUG (STM_LEVEL_INFO)
#else
#define BYTE_BUFFER_ARGS_PROCESSSOR_DEBUG (STM_LEVEL_NONE)
#endif
ByteBufferArgsProcessor :: ByteBufferArgsProcessor ()
{
bbap_buffer_p = AllocateByteBuffer (1024);
if (!bbap_buffer_p)
{
throw AllocFailure ("Failed to create data for ByteBufferArgsProcessor");
}
#if BYTE_BUFFER_ARGS_PROCESSSOR_DEBUG >= STM_LEVEL_FINEST
PrintLog (STM_LEVEL_FINE, __FILE__, __LINE__, "Allocated buffer at %.16X");
#endif
}
ByteBufferArgsProcessor :: ~ByteBufferArgsProcessor ()
{
#if BYTE_BUFFER_ARGS_PROCESSSOR_DEBUG >= STM_LEVEL_FINEST
PrintLog (STM_LEVEL_FINE, __FILE__, __LINE__, "Freeing buffer at %.16X");
#endif
FreeByteBuffer (bbap_buffer_p);
}
bool ByteBufferArgsProcessor :: AddArg (const char *arg_s, const bool hyphen_flag)
{
bool success_flag = true;
const bool add_quotes_flag = DoesStringContainWhitespace (arg_s);
if (bbap_buffer_p -> bb_current_index != 0)
{
success_flag = AppendStringToByteBuffer (bbap_buffer_p, " ");
}
if (success_flag && hyphen_flag)
{
success_flag = AppendStringToByteBuffer (bbap_buffer_p, "-");
}
if (success_flag)
{
if (add_quotes_flag)
{
success_flag = AppendStringsToByteBuffer (bbap_buffer_p, "\"", arg_s, "\"", NULL);
}
else
{
success_flag = AppendStringToByteBuffer (bbap_buffer_p, arg_s);
}
}
return success_flag;
}
const char *ByteBufferArgsProcessor :: GetArgsAsString ()
{
return GetByteBufferData (bbap_buffer_p);
}
| 23.94898 | 87 | 0.738389 | TGAC |
07cea265b5e9ef37f01d5003a46c03e8e20146f6 | 2,904 | cc | C++ | chrome/browser/metrics/power/battery_level_provider.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | chrome/browser/metrics/power/battery_level_provider.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86 | 2015-10-21T13:02:42.000Z | 2022-03-14T07:50:50.000Z | chrome/browser/metrics/power/battery_level_provider.cc | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/metrics/power/battery_level_provider.h"
BatteryLevelProvider::BatteryState::BatteryState(
size_t interface_count,
size_t battery_count,
absl::optional<double> charge_level,
bool on_battery,
base::TimeTicks capture_time)
: interface_count(interface_count),
battery_count(battery_count),
charge_level(charge_level),
on_battery(on_battery),
capture_time(capture_time) {}
BatteryLevelProvider::BatteryState::BatteryState(const BatteryState&) = default;
BatteryLevelProvider::BatteryState&
BatteryLevelProvider::BatteryState::operator=(const BatteryState&) = default;
BatteryLevelProvider::BatteryInterface::BatteryInterface(
bool battery_present_in)
: battery_present(battery_present_in) {}
BatteryLevelProvider::BatteryInterface::BatteryInterface(
const BatteryDetails& details_in)
: battery_present(true), details(details_in) {}
BatteryLevelProvider::BatteryInterface::BatteryInterface(
const BatteryInterface&) = default;
BatteryLevelProvider::BatteryState BatteryLevelProvider::MakeBatteryState(
const std::vector<BatteryInterface>& battery_interfaces) {
const base::TimeTicks capture_time = base::TimeTicks::Now();
uint64_t total_max_capacity = 0;
uint64_t total_current_capacity = 0;
bool on_battery = true;
bool any_capacity_invalid = false;
size_t battery_count = 0;
for (auto& interface : battery_interfaces) {
// The interface might have no battery.
if (!interface.battery_present)
continue;
// Counts the number of interfaces that has |battery_present == true|.
++battery_count;
// The state is considered on battery power only if all of the batteries
// are explicitly marked as not connected.
if (!interface.details.has_value() || interface.details->is_connected)
on_battery = false;
if (!interface.details.has_value()) {
any_capacity_invalid = true;
continue;
}
// Total capacity is averaged across all the batteries.
total_current_capacity += interface.details->current_capacity;
total_max_capacity += interface.details->full_charged_capacity;
}
absl::optional<double> charge_level;
// Avoid invalid division.
if (!any_capacity_invalid && total_max_capacity != 0) {
charge_level = static_cast<double>(total_current_capacity) /
static_cast<double>(total_max_capacity);
}
// If no battery was detected, we consider the system to be drawing power
// from an external power source, which is different from |on_battery|'s
// default value.
if (battery_count == 0)
on_battery = false;
return {battery_interfaces.size(), battery_count, charge_level, on_battery,
capture_time};
}
| 34.987952 | 80 | 0.742424 | zealoussnow |
07cec5335433f24d8ef050758d4a11518b04317e | 3,103 | cpp | C++ | src/Graphics.cpp | williamsandst/theia-software-rasterizer | 75cfff3ca1e822e3cef25a86a846f4994c53ab17 | [
"MIT"
] | null | null | null | src/Graphics.cpp | williamsandst/theia-software-rasterizer | 75cfff3ca1e822e3cef25a86a846f4994c53ab17 | [
"MIT"
] | null | null | null | src/Graphics.cpp | williamsandst/theia-software-rasterizer | 75cfff3ca1e822e3cef25a86a846f4994c53ab17 | [
"MIT"
] | null | null | null | #include "Graphics.h"
void Graphics::setScreenSize(int width, int height)
{
screen = Framebuffer(width, height);
earlyZBuffer = Framebuffer(width, height);
}
void Graphics::addToObjectToPipeline(ObjectPtr object)
{
worldObjects.push_back(object);
objectFragments.push_back(vector<Fragment>());
}
void Graphics::generateFragments(vector<Fragment>& fragments, Vertices vertices, ObjectPtr object)
{
Primitive prim;
Vector4f surfaceNormal;
//Predict size somehow? Hmm. From last iteration? Genius
for (size_t i = 0; i < object->primitives.size(); i++)
{
prim = object->primitives[i];
Vertex vertex1 = vertices.getVertex(prim.points[0], prim.normals[0], prim.UVcoords[0], prim.colors[0]);
Vertex vertex2 = vertices.getVertex(prim.points[1], prim.normals[1], prim.UVcoords[1], prim.colors[1]);
Vertex vertex3 = vertices.getVertex(prim.points[2], prim.normals[2], prim.UVcoords[2], prim.colors[2]);
if (drawMode == WIREFRAME)
{
Rasterizer::createLineFragments(&fragments, vertex1, vertex2, vertex3, screen.width, screen.height);
}
else if (drawMode == POLY)
{
if (backfaceCulling && object->isClosed) //Backface culling
{
surfaceNormal = vertices.surfaceNormals.col(object->primitives[i].surfaceNormal);
if (vertex1.point.dot(surfaceNormal) >= 0) continue;
}
Rasterizer::createPolyFragments2(&fragments, vertex1, vertex2, vertex3, screen.width, screen.height, earlyZBuffer, earlyZTest);
}
else if (drawMode == DEBUG)
{
Rasterizer::createDebugFragments(&fragments, vertex1, vertex2, vertex3, screen.width, screen.height);
}
}
}
void Graphics::renderMainView()
{
//Performance stuff
memoryManagement();
view.updateMatrices();
//Render every object
Vertices objectVertices;
for (size_t i = 0; i < worldObjects.size(); i++)
{
objectVertices = VertexShaders::projectionShader(worldObjects[i]->vertices, view, worldObjects[i]->modelMatrix);
generateFragments(objectFragments[i], objectVertices, worldObjects[i]);
FragmentShaders::textureShader(objectFragments[i], worldObjects[i]->material.ambientTexture);
//FragmentShaders::simpleColorShader(objectFragments[i]);
}
for (size_t i = 0; i < objectFragments.size(); i++) //Draw all fragments
{
//std::sort(objectFragments[i].begin(), objectFragments[i].end());
Draw::drawFragments(screen, objectFragments[i]);
}
screen.generateOutputBuffer();
}
void Graphics::memoryManagement()
{
for (size_t i = 0; i < objectFragments.size(); i++)
{
int fragCount = objectFragments[i].size();
objectFragments[i].clear();
objectFragments[i].reserve((int)(fragCount * 1.2));
}
}
void Graphics::setup()
{
//Optimizations
backfaceCulling = false;
earlyZTest = false;
//Setup stuff
drawMode = POLY;
view.setViewport(screen.width, screen.height);
view.setTranslation(Vector3f(0, 0, -3));
view.setRotation(Vector3f(3.14, 3.14, 0));
view.setScale(1);
}
float* Graphics::getDisplaybufferPtr()
{
return &screen.colorBuffer[0];
}
void Graphics::clearDisplaybuffer()
{
screen.clear();
earlyZBuffer.clearDepthBuffer();
}
Graphics::Graphics()
{
}
Graphics::~Graphics()
{
}
| 26.982609 | 130 | 0.723493 | williamsandst |
07d0fc460e0805e5aa91ee91bb3fca6152cc415a | 547 | cpp | C++ | UVaOnlineJudge/Problem_Set_Volumes_(100...1999)/Volume6(600-699)/621/code.cpp | luiscbr92/algorithmic-challenges | bc35729e54e4284e9ade1aa61b51a1c2d72aa62c | [
"MIT"
] | 3 | 2015-10-21T18:56:43.000Z | 2017-06-06T10:44:22.000Z | UVaOnlineJudge/Problem_Set_Volumes_(100...1999)/Volume6(600-699)/621/code.cpp | luiscbr92/algorithmic-challenges | bc35729e54e4284e9ade1aa61b51a1c2d72aa62c | [
"MIT"
] | null | null | null | UVaOnlineJudge/Problem_Set_Volumes_(100...1999)/Volume6(600-699)/621/code.cpp | luiscbr92/algorithmic-challenges | bc35729e54e4284e9ade1aa61b51a1c2d72aa62c | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
using namespace std;
int main(){
int cases, length;
string s;
cin >> cases;
for(int i = 0; i < cases; i++){
cin >> s;
if(s=="1" || s == "4" || s == "78") cout << "+\n";
else if ((length = s.size()) >= 2){
if(s.substr(length - 2) == "35") cout << "-\n";
else if(s[0] == '9' && s[length-1] == '4') cout << "*\n";
else if (length >= 3 && s.substr(0, 3) == "190") cout << "?\n";
}
}
}
| 20.259259 | 78 | 0.380256 | luiscbr92 |
07d4975fc21b06cc10bc666197e980aecd5ba151 | 31,090 | cpp | C++ | src/jsusfx.cpp | asb2m10/jsusfx | be2b3bafe90b0f2eb28739257138844bc9d2941c | [
"Apache-2.0"
] | 49 | 2015-01-05T06:58:59.000Z | 2021-10-21T00:30:08.000Z | src/jsusfx.cpp | umlaeute/jsusfx | be2b3bafe90b0f2eb28739257138844bc9d2941c | [
"Apache-2.0"
] | 25 | 2016-02-25T15:59:03.000Z | 2021-12-20T15:08:16.000Z | src/jsusfx.cpp | umlaeute/jsusfx | be2b3bafe90b0f2eb28739257138844bc9d2941c | [
"Apache-2.0"
] | 13 | 2015-06-17T07:47:39.000Z | 2021-10-07T12:19:46.000Z | /*
* Copyright 2014-2015 Pascal Gauthier
* Copyright 2018 Pascal Gauthier, Marcel Smit
*
* 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 "jsusfx.h"
#include "jsusfx_file.h"
#include "jsusfx_gfx.h"
#include "jsusfx_serialize.h"
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include "WDL/ptrlist.h"
#include "WDL/assocarray.h"
#define REAPER_GET_INTERFACE(opaque) ((opaque) ? ((JsusFx*)opaque) : nullptr)
#define AUTOVAR(name) name = NSEEL_VM_regvar(m_vm, #name); *name = 0
#define AUTOVARV(name,value) name = NSEEL_VM_regvar(m_vm, #name); *name = value
#define EEL_STRING_GET_CONTEXT_POINTER(opaque) (((JsusFx *)opaque)->m_string_context)
#ifdef EEL_STRING_STDOUT_WRITE
#ifndef EELSCRIPT_NO_STDIO
#define EEL_STRING_STDOUT_WRITE(x,len) { fwrite(x,len,1,stdout); fflush(stdout); }
#endif
#endif
#include "WDL/eel2/eel_strings.h"
#include "WDL/eel2/eel_misc.h"
#include "WDL/eel2/eel_fft.h"
#include "WDL/eel2/eel_mdct.h"
#include <fstream> // to check if files exist
// Reaper API
static EEL_F * NSEEL_CGEN_CALL _reaper_slider(void *opaque, EEL_F *n)
{
JsusFx *ctx = REAPER_GET_INTERFACE(opaque);
const int index = *n;
if (index >= 0 && index < ctx->kMaxSliders)
return ctx->sliders[index].owner;
else {
ctx->dummyValue = 0;
return &ctx->dummyValue;
}
}
static EEL_F * NSEEL_CGEN_CALL _reaper_spl(void *opaque, EEL_F *n)
{
JsusFx *ctx = REAPER_GET_INTERFACE(opaque);
const int index = *n;
if (index >= 0 && index < ctx->numValidInputChannels)
return ctx->spl[index];
else {
ctx->dummyValue = 0;
return &ctx->dummyValue;
}
}
static EEL_F NSEEL_CGEN_CALL _midirecv(void *opaque, INT_PTR np, EEL_F **parms)
{
JsusFx *ctx = REAPER_GET_INTERFACE(opaque);
while (ctx->midiSize > 0) {
// peek the message type
const uint8_t b = ctx->midi[0];
if ((b & 0xf0) == 0xf0) {
// 0xf0 = system exclusive message
// consume the byte
ctx->midi++;
ctx->midiSize--;
// skip until we find a 0xf7 byte
for (;;) {
// end of data stream?
if (ctx->midiSize == 0)
break;
// consume the byte
const uint8_t b = ctx->midi[0];
ctx->midi++;
ctx->midiSize--;
// end of system exclusive message?
if (b == 0xf7)
break;
}
}
else if (b & 0x80) {
// status byte
const uint8_t event = b & 0xf0;
//const uint8_t channel = b & 0x0f;
// consume the byte
ctx->midi++;
ctx->midiSize--;
// data bytes
if (ctx->midiSize >= 2) {
*parms[0] = 0;
*parms[1] = event;
if (np >= 4) {
*parms[2] = ctx->midi[0];
*parms[3] = ctx->midi[1];
} else {
*parms[2] = ctx->midi[0] + ctx->midi[1] * 256;
}
ctx->midi += 2;
ctx->midiSize -= 2;
return 1;
} else {
ctx->midiSize = 0;
return 0;
}
} else {
// data byte without a preceeding status byte? something is wrong here
ctx->midiSize--; // decrement this otherwise it is an infinite loop
ctx->displayMsg("Inconsistent midi stream %x\n", b);
}
}
return 0;
}
static EEL_F NSEEL_CGEN_CALL _midisend(void *opaque, INT_PTR np, EEL_F **parms)
{
JsusFx *ctx = REAPER_GET_INTERFACE(opaque);
if (ctx->midiSendBufferSize + 3 > ctx->midiSendBufferCapacity) {
return 0;
} else if (np == 3) {
const int offset = (int)*parms[0];
(void)offset; // sample offset into current block. not used
const uint8_t msg1 = (uint8_t)*parms[1];
const uint16_t msg23 = (uint16_t)*parms[2];
const uint8_t msg2 = (msg23 >> 0) & 0xff;
const uint8_t msg3 = (msg23 >> 8) & 0xff;
//printf("midi send. cmd=%x, msg2=%d, msg3=%x\n", msg1, msg2, msg3);
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg1;
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg2;
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg3;
return msg1;
} else if (np == 4) {
const int offset = (int)*parms[0];
(void)offset; // sample offset into current block. not used
const uint8_t msg1 = (uint8_t)*parms[1];
const uint8_t msg2 = (uint8_t)*parms[2];
const uint8_t msg3 = (uint8_t)*parms[3];
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg1;
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg2;
ctx->midiSendBuffer[ctx->midiSendBufferSize++] = msg3;
return msg1;
} else {
return 0;
}
}
static EEL_F NSEEL_CGEN_CALL _midisend_buf(void *opaque, INT_PTR np, EEL_F **parms)
{
JsusFx *ctx = REAPER_GET_INTERFACE(opaque);
if (np == 3) {
const int offset = (int)*parms[0];
(void)offset; // sample offset into current block. not used
void *buf = (void*)parms[1];
const int len = (int)*parms[2];
// note : should we auto-detect SysEx messages? Reaper does it, but it seems like a bad idea..
// auto-detection would automagically determine the message's length here by parsing the message stream
if (len < 0 || ctx->midiSendBufferSize + len > ctx->midiSendBufferCapacity) {
return 0;
} else {
memcpy(&ctx->midiSendBuffer[ctx->midiSendBufferSize], buf, len);
ctx->midiSendBufferSize += len;
return len;
}
} else {
return 0;
}
}
// todo : remove __stub
static EEL_F NSEEL_CGEN_CALL __stub(void *opaque, INT_PTR np, EEL_F **parms)
{
return 0.0;
}
//
struct JsusFx_Section {
WDL_String code;
int lineOffset;
JsusFx_Section()
{
lineOffset = 0;
}
};
struct JsusFx_Sections {
JsusFx_Section init;
JsusFx_Section slider;
JsusFx_Section block;
JsusFx_Section sample;
JsusFx_Section gfx;
JsusFx_Section serialize;
};
//
static const char *skipWhite(const char *text) {
while ( *text && isspace(*text) )
text++;
return text;
}
static const char *nextToken(const char *text) {
while ( *text && *text != ',' && *text != '=' && *text != '<' && *text != '>' && *text != '{' && *text != '}' )
text++;
return text;
}
bool JsusFx_Slider::config(JsusFx &fx, const int index, const char *param, const int lnumber) {
char buffer[2048];
strncpy(buffer, param, 2048);
def = min = max = inc = 0;
exists = false;
enumNames.clear();
isEnum = false;
bool hasName = false;
const char *tmp = strchr(buffer, '>');
if ( tmp != NULL ) {
tmp++;
while (*tmp == ' ')
tmp++;
strncpy(desc, tmp, 64);
tmp = 0;
} else {
desc[0] = 0;
}
tmp = buffer;
if ( isalpha(*tmp) ) {
// extended syntax of format "slider1:variable_name=5<0,10,1>slider description"
const char *begin = tmp;
while ( *tmp && *tmp != '=' )
tmp++;
if ( *tmp != '=' ) {
fx.displayError("Expected '=' at end of slider name %d", lnumber);
return false;
}
const char *end = tmp;
int len = end - begin;
if ( len > JsusFx_Slider::kMaxName ) {
fx.displayError("Slider name too long %d", lnumber);
return false;
}
for ( int i = 0; i < len; ++i )
name[i] = begin[i];
name[len] = 0;
hasName = true;
tmp++;
}
if ( !sscanf(tmp, "%f", &def) )
return false;
tmp = nextToken(tmp);
if ( *tmp != '<' )
{
fx.displayError("slider info is missing");
return false;
}
else
{
tmp++;
if ( !sscanf(tmp, "%f", &min) )
{
fx.displayError("failed to read min value");
return false;
}
tmp = nextToken(tmp);
if ( *tmp != ',' )
{
fx.displayError("max value is missing");
return false;
}
else
{
tmp++;
if ( !sscanf(tmp, "%f", &max) )
{
fx.displayError("failed to read max value");
return false;
}
tmp = nextToken(tmp);
if ( *tmp == ',')
{
tmp++;
tmp = skipWhite(tmp);
if ( !sscanf(tmp, "%f", &inc) )
{
//log("failed to read increment value");
//return false;
inc = 0;
}
tmp = nextToken(tmp);
if ( *tmp == '{' )
{
isEnum = true;
inc = 1;
tmp++;
while ( true )
{
const char *end = nextToken(tmp);
const std::string name(tmp, end);
enumNames.push_back(name);
tmp = end;
if ( *tmp == 0 )
{
fx.displayError("enum value list not properly terminated");
return false;
}
if ( *tmp == '}' )
{
break;
}
tmp++;
}
tmp++;
}
}
}
}
if (hasName == false) {
sprintf(name, "slider%d", index);
}
owner = NSEEL_VM_regvar(fx.m_vm, name);
*owner = def;
exists = true;
return true;
}
//
JsusFxPathLibrary_Basic::JsusFxPathLibrary_Basic(const char * _dataRoot) {
if ( _dataRoot != nullptr )
dataRoot = _dataRoot;
}
void JsusFxPathLibrary_Basic::addSearchPath(const std::string & path) {
if ( path.empty() )
return;
// make sure it ends with '/' or '\\'
if ( path.back() == '/' || path.back() == '\\' )
searchPaths.push_back(path);
else
searchPaths.push_back(path + "/");
}
bool JsusFxPathLibrary_Basic::fileExists(const std::string &filename) {
std::ifstream is(filename);
return is.is_open();
}
bool JsusFxPathLibrary_Basic::resolveImportPath(const std::string &importPath, const std::string &parentPath, std::string &resolvedPath) {
const size_t pos = parentPath.rfind('/');
if ( pos != std::string::npos )
resolvedPath = parentPath.substr(0, pos + 1);
if ( fileExists(resolvedPath + importPath) ) {
resolvedPath = resolvedPath + importPath;
return true;
}
for ( std::string & searchPath : searchPaths ) {
if ( fileExists(resolvedPath + searchPath + importPath) ) {
resolvedPath = resolvedPath + searchPath + importPath;
return true;
}
}
return false;
}
bool JsusFxPathLibrary_Basic::resolveDataPath(const std::string &importPath, std::string &resolvedPath) {
if ( !dataRoot.empty() )
resolvedPath = dataRoot + "/" + importPath;
else
resolvedPath = importPath;
return fileExists(resolvedPath);
}
std::istream* JsusFxPathLibrary_Basic::open(const std::string &path) {
std::ifstream *stream = new std::ifstream(path);
if ( stream->is_open() == false ) {
delete stream;
stream = nullptr;
}
return stream;
}
void JsusFxPathLibrary_Basic::close(std::istream *&stream) {
delete stream;
stream = nullptr;
}
//
JsusFx::JsusFx(JsusFxPathLibrary &_pathLibrary)
: pathLibrary(_pathLibrary) {
m_vm = NSEEL_VM_alloc();
codeInit = codeSlider = codeBlock = codeSample = codeGfx = codeSerialize = NULL;
NSEEL_VM_SetCustomFuncThis(m_vm,this);
m_string_context = new eel_string_context_state();
eel_string_initvm(m_vm);
computeSlider = false;
srate = 0;
pathLibrary = _pathLibrary;
fileAPI = nullptr;
midi = nullptr;
midiSize = 0;
midiSendBuffer = nullptr;
midiSendBufferCapacity = 0;
midiSendBufferSize = 0;
gfx = nullptr;
gfx_w = 0;
gfx_h = 0;
serializer = nullptr;
for (int i = 0; i < kMaxSamples; ++i) {
char name[16];
sprintf(name, "spl%d", i);
spl[i] = NSEEL_VM_regvar(m_vm, name);
*spl[i] = 0;
}
numInputs = 0;
numOutputs = 0;
numValidInputChannels = 0;
AUTOVAR(srate);
AUTOVARV(num_ch, 2);
AUTOVAR(samplesblock);
AUTOVAR(trigger);
// transport state. use setTransportValues to set these
AUTOVARV(tempo, 120); // playback tempo in beats per minute
AUTOVARV(play_state, 1); // playback state. see the PlaybackState enum for details
AUTOVAR(play_position); // current playback position in seconds
AUTOVAR(beat_position); // current playback position in beats (beats = quarternotes in /4 time signatures)
AUTOVARV(ts_num, 0); // time signature nominator. i.e. 3 if using 3/4 time
AUTOVARV(ts_denom, 4); // time signature denominator. i.e. 4 if using 3/4 time
AUTOVAR(ext_noinit);
AUTOVAR(ext_nodenorm); // set to 1 to disable noise added to signals to avoid denormals from popping up
// midi bus support
AUTOVAR(ext_midi_bus); // when set to 1, support for midi buses is enabled. otherwise, only bus 0 is active and others will pass through
AUTOVAR(midi_bus);
// Reaper API
NSEEL_addfunc_varparm("slider_automate",1,NSEEL_PProc_THIS,&__stub); // todo : implement slider_automate. add Reaper api interface?
NSEEL_addfunc_varparm("slider_next_chg",2,NSEEL_PProc_THIS,&__stub); // todo : implement slider_next_chg. add Reaper api interface?
NSEEL_addfunc_varparm("sliderchange",1,NSEEL_PProc_THIS,&__stub); // todo : implement sliderchange. add Reaper api interface?
NSEEL_addfunc_retptr("slider",1,NSEEL_PProc_THIS,&_reaper_slider);
NSEEL_addfunc_retptr("spl",1,NSEEL_PProc_THIS,&_reaper_spl);
NSEEL_addfunc_varparm("midirecv",3,NSEEL_PProc_THIS,&_midirecv);
NSEEL_addfunc_varparm("midisend",3,NSEEL_PProc_THIS,&_midisend);
NSEEL_addfunc_varparm("midisend_buf",3,NSEEL_PProc_THIS,&_midisend_buf);
}
JsusFx::~JsusFx() {
releaseCode();
if (m_vm)
NSEEL_VM_free(m_vm);
delete m_string_context;
}
bool JsusFx::compileSection(int state, const char *code, int line_offset) {
if ( code[0] == 0 )
return true;
char errorMsg[4096];
//printf("section code:\n");
//printf("%s", code);
switch(state) {
case 0:
codeInit = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeInit == NULL ) {
snprintf(errorMsg, 4096, "@init line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
case 1:
codeSlider = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeSlider == NULL ) {
snprintf(errorMsg, 4096, "@slider line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
case 2:
codeBlock = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeBlock == NULL ) {
snprintf(errorMsg, 4096, "@block line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
case 3:
codeSample = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeSample == NULL ) {
snprintf(errorMsg, 4096, "@sample line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
case 4:
codeGfx = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeGfx == NULL ) {
snprintf(errorMsg, 4096, "@gfx line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
case 5:
codeSerialize = NSEEL_code_compile_ex(m_vm, code, line_offset, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS);
if ( codeSerialize == NULL ) {
snprintf(errorMsg, 4096, "@serialize line %s", NSEEL_code_getcodeerror(m_vm));
displayError(errorMsg);
return false;
}
break;
default:
//printf("unknown block");
break;
}
m_string_context->update_named_vars(m_vm);
return true;
}
bool JsusFx::processImport(JsusFxPathLibrary &pathLibrary, const std::string &path, const std::string &importPath, JsusFx_Sections §ions, const int compileFlags) {
bool result = true;
//displayMsg("Importing %s", path.c_str());
std::string resolvedPath;
if ( ! pathLibrary.resolveImportPath(importPath, path, resolvedPath) ) {
displayError("Failed to resolve import file path %s", importPath.c_str());
return false;
}
std::istream *is = pathLibrary.open(resolvedPath);
if ( is != nullptr ) {
result &= readSections(pathLibrary, resolvedPath, *is, sections, compileFlags);
} else {
displayError("Failed to open imported file %s", importPath.c_str());
result &= false;
}
pathLibrary.close(is);
return result;
}
static char *trim(char *line, bool trimStart, bool trimEnd)
{
if (trimStart) {
while (*line && isspace(*line))
line++;
}
if (trimEnd) {
char *last = line;
while (last[0] && last[1])
last++;
for (char *b = last; isspace(*b) && b >= line; b--)
*b = 0;
}
return line;
}
bool JsusFx::readHeader(JsusFxPathLibrary &pathLibrary, const std::string &path, std::istream &input) {
char line[4096];
for(int lnumber = 1; ! input.eof(); lnumber++) {
input.getline(line, sizeof(line), '\n');
if ( line[0] == '@' )
break;
if ( ! strnicmp(line, "slider", 6) ) {
int target = 0;
if ( ! sscanf(line, "slider%d:", &target) )
continue;
if ( target < 0 || target >= kMaxSliders )
continue;
JsusFx_Slider &slider = sliders[target];
char *p = line+7;
while ( *p && *p != ':' )
p++;
if ( *p != ':' )
continue;
p++;
if ( ! slider.config(*this, target, p, lnumber) ) {
displayError("Incomplete slider @line %d (%s)", lnumber, line);
return false;
}
trim(slider.desc, false, true);
continue;
}
else if ( ! strncmp(line, "desc:", 5) ) {
char *src = line+5;
src = trim(src, true, true);
strncpy(desc, src, 64);
continue;
}
else if ( ! strncmp(line, "in_pin:", 7) ) {
numInputs++;
}
else if ( ! strncmp(line, "out_pin:", 8) ) {
numOutputs++;
}
}
return true;
}
bool JsusFx::readSections(JsusFxPathLibrary &pathLibrary, const std::string &path, std::istream &input, JsusFx_Sections §ions, const int compileFlags) {
WDL_String * code = nullptr;
char line[4096];
// are we reading the header or sections?
bool isHeader = true;
for(int lnumber = 1; ! input.eof(); lnumber++) {
input.getline(line, sizeof(line), '\n');
const int l = input.gcount();
if ( line[0] == '@' ) {
char *b = line + 1;
b = trim(b, false, true);
// we've begun reading sections now
isHeader = false;
JsusFx_Section *section = nullptr;
if ( ! strnicmp(b, "init", 4) )
section = §ions.init;
else if ( ! strnicmp(b, "slider", 6) )
section = §ions.slider;
else if ( ! strnicmp(b, "block", 5) )
section = §ions.block;
else if ( ! strnicmp(b, "sample", 6) )
section = §ions.sample;
else if ( ! strnicmp(b, "gfx", 3) && (compileFlags & kCompileFlag_CompileGraphicsSection) != 0 ) {
if ( sscanf(b+3, "%d %d", &gfx_w, &gfx_h) != 2 ) {
gfx_w = 0;
gfx_h = 0;
}
section = §ions.gfx;
}
else if ( ! strnicmp(b, "serialize", 9) && (compileFlags & kCompileFlag_CompileSerializeSection) != 0 )
section = §ions.serialize;
if ( section != nullptr ) {
code = §ion->code;
section->lineOffset = lnumber;
} else {
code = nullptr;
}
continue;
}
if ( code != nullptr ) {
//int l = strlen(line);
if ( l > 0 && line[l-1] == '\r' )
line[l-1] = 0;
if ( line[0] != 0 ) {
code->Append(line);
}
code->Append("\n");
continue;
}
if (isHeader) {
if ( ! strnicmp(line, "slider", 6) ) {
int target = 0;
if ( ! sscanf(line, "slider%d:", &target) )
continue;
if ( target < 0 || target >= kMaxSliders )
continue;
JsusFx_Slider &slider = sliders[target];
char *p = line+7;
while ( *p && *p != ':' )
p++;
if ( *p != ':' )
continue;
p++;
if ( ! slider.config(*this, target, p, lnumber) ) {
displayError("Incomplete slider @line %d (%s)", lnumber, line);
return false;
}
trim(slider.desc, false, true);
continue;
}
else if ( ! strncmp(line, "desc:", 5) ) {
char *src = line+5;
src = trim(src, true, true);
strncpy(desc, src, 64);
continue;
}
else if ( ! strnicmp(line, "filename:", 9) ) {
// filename:0,filename.wav
char *src = line+8;
src = trim(src, true, false);
if ( *src != ':' )
return false;
src++;
src = trim(src, true, false);
int index;
if ( sscanf(src, "%d", &index) != 1 )
return false;
while ( isdigit(*src) )
src++;
src = trim(src, true, false);
if ( *src != ',' )
return false;
src++;
src = trim(src, true, true);
std::string resolvedPath;
if ( pathLibrary.resolveImportPath(src, path, resolvedPath) ) {
if ( ! handleFile(index, resolvedPath.c_str() ) ) {
return false;
}
}
}
else if ( ! strncmp(line, "import ", 7) ) {
char *src = line+7;
src = trim(src, true, true);
if (*src) {
processImport(pathLibrary, path, src, sections, compileFlags);
}
continue;
}
else if ( ! strncmp(line, "in_pin:", 7) ) {
if ( ! strncmp(line+7, "none", 4) ) {
numInputs = -1;
} else {
if ( numInputs != -1 )
numInputs++;
}
}
else if ( ! strncmp(line, "out_pin:", 8) ) {
if ( ! strncmp(line+8, "none", 4) ) {
numOutputs = -1;
} else {
if ( numOutputs != -1 )
numOutputs++;
}
}
}
}
return true;
}
bool JsusFx::compileSections(JsusFx_Sections §ions, const int compileFlags) {
bool result = true;
// 0 init
// 1 slider
// 2 block
// 3 sample
// 4 gfx
// 5 serialize
if (sections.init.code.GetLength() != 0)
result &= compileSection(0, sections.init.code.Get(), sections.init.lineOffset);
if (sections.slider.code.GetLength() != 0)
result &= compileSection(1, sections.slider.code.Get(), sections.slider.lineOffset);
if (sections.block.code.GetLength() != 0)
result &= compileSection(2, sections.block.code.Get(), sections.block.lineOffset);
if (sections.sample.code.GetLength() != 0)
result &= compileSection(3, sections.sample.code.Get(), sections.sample.lineOffset);
if (sections.gfx.code.GetLength() != 0 && (compileFlags & kCompileFlag_CompileGraphicsSection) != 0)
result &= compileSection(4, sections.gfx.code.Get(), sections.gfx.lineOffset);
if (sections.serialize.code.GetLength() != 0 && (compileFlags & kCompileFlag_CompileSerializeSection) != 0)
result &= compileSection(5, sections.serialize.code.Get(), sections.serialize.lineOffset);
if (result == false)
releaseCode();
return result;
}
bool JsusFx::compile(JsusFxPathLibrary &pathLibrary, const std::string &path, const int compileFlags) {
releaseCode();
std::string resolvedPath;
if ( ! pathLibrary.resolveImportPath(path, "", resolvedPath) ) {
displayError("Failed to open %s", path.c_str());
return false;
}
std::istream *input = pathLibrary.open(resolvedPath);
if ( input == nullptr ) {
displayError("Failed to open %s", resolvedPath.c_str());
return false;
}
// read code for the various sections inside the jsusfx script
JsusFx_Sections sections;
if ( ! readSections(pathLibrary, resolvedPath, *input, sections, compileFlags) )
return false;
pathLibrary.close(input);
// compile the sections
if ( ! compileSections(sections, compileFlags) ) {
releaseCode();
return false;
}
computeSlider = 1;
// in_pin and out_pin is optional, we default it to 2 in / 2 out if nothing is specified.
// if you really want no in or out, specify in_pin:none/out_pin:none
if ( numInputs == 0 )
numInputs = 2;
else if ( numInputs == -1 )
numInputs = 0;
if ( numOutputs == 0 )
numOutputs = 2;
else if ( numOutputs == -1 )
numOutputs = 0;
return true;
}
bool JsusFx::readHeader(JsusFxPathLibrary &pathLibrary, const std::string &path) {
std::string resolvedPath;
if ( ! pathLibrary.resolveImportPath(path, "", resolvedPath) ) {
displayError("Failed to open %s", path.c_str());
return false;
}
std::istream *input = pathLibrary.open(resolvedPath);
if ( input == nullptr ) {
displayError("Failed to open %s", resolvedPath.c_str());
return false;
}
if ( ! readHeader(pathLibrary, resolvedPath, *input) )
return false;
pathLibrary.close(input);
return true;
}
void JsusFx::prepare(int sampleRate, int blockSize) {
*srate = (double) sampleRate;
*samplesblock = blockSize;
NSEEL_code_execute(codeInit);
}
void JsusFx::moveSlider(int idx, float value, int normalizeSlider) {
if ( idx < 0 || idx >= kMaxSliders || !sliders[idx].exists )
return;
if ( normalizeSlider != 0 ) {
float steps = sliders[idx].max - sliders[idx].min;
value = (value * steps) / normalizeSlider;
value += sliders[idx].min;
}
if ( sliders[idx].inc != 0 ) {
int tmp = roundf(value / sliders[idx].inc);
value = sliders[idx].inc * tmp;
}
computeSlider |= sliders[idx].setValue(value);
}
void JsusFx::setMidi(const void * _midi, int numBytes) {
midi = (uint8_t*)_midi;
midiSize = numBytes;
}
void JsusFx::setMidiSendBuffer(void * buffer, int numBytes) {
midiSendBuffer = (uint8_t*)buffer;
midiSendBufferCapacity = numBytes;
midiSendBufferSize = 0;
}
void JsusFx::setTransportValues(
const double in_tempo,
const PlaybackState in_playbackState,
const double in_playbackPositionInSeconds,
const double in_beatPosition,
const int in_timeSignatureNumerator,
const int in_timeSignatureDenumerator)
{
*tempo = in_tempo;
*play_state = in_playbackState;
*play_position = in_playbackPositionInSeconds;
*beat_position = in_beatPosition;
*ts_num = in_timeSignatureNumerator;
*ts_denom = in_timeSignatureDenumerator;
}
bool JsusFx::process(const float **input, float **output, int size, int numInputChannels, int numOutputChannels) {
if ( codeSample == NULL )
return false;
if ( computeSlider ) {
NSEEL_code_execute(codeSlider);
computeSlider = false;
}
numValidInputChannels = numInputChannels;
*samplesblock = size;
*num_ch = numValidInputChannels;
NSEEL_code_execute(codeBlock);
for(int i=0;i<size;i++) {
for (int c = 0; c < numInputChannels; ++c)
*spl[c] = input[c][i];
NSEEL_code_execute(codeSample);
for (int c = 0; c < numOutputChannels; ++c)
output[c][i] = *spl[c];
}
return true;
}
bool JsusFx::process64(const double **input, double **output, int size, int numInputChannels, int numOutputChannels) {
if ( codeSample == NULL )
return false;
if ( computeSlider ) {
NSEEL_code_execute(codeSlider);
computeSlider = false;
}
numValidInputChannels = numInputChannels;
*samplesblock = size;
*num_ch = numValidInputChannels;
NSEEL_code_execute(codeBlock);
for(int i=0;i<size;i++) {
for (int c = 0; c < numInputChannels; ++c)
*spl[c] = input[c][i];
NSEEL_code_execute(codeSample);
for (int c = 0; c < numOutputChannels; ++c)
output[c][i] = *spl[c];
}
return true;
}
void JsusFx::draw() {
if ( codeGfx == NULL )
return;
if ( gfx != nullptr )
gfx->beginDraw();
NSEEL_code_execute(codeGfx);
if ( gfx != nullptr )
gfx->endDraw();
}
bool JsusFx::serialize(JsusFxSerializer & _serializer, const bool write) {
serializer = &_serializer;
serializer->begin(*this, write);
{
if (codeSerialize != nullptr)
NSEEL_code_execute(codeSerialize);
if (write == false)
{
if (codeSlider != nullptr)
NSEEL_code_execute(codeSlider);
computeSlider = false;
}
}
serializer->end();
serializer = nullptr;
return true;
}
const char * JsusFx::getString(const int index, WDL_FastString ** fs) {
void * opaque = this;
return EEL_STRING_GET_FOR_INDEX(index, fs);
}
bool JsusFx::handleFile(int index, const char *filename)
{
if (index < 0 || index >= kMaxFileInfos)
{
displayError("file index out of bounds %d:%s", index, filename);
return false;
}
if (fileInfos[index].isValid())
{
displayMsg("file already exists %d:%s", index, filename);
fileInfos[index] = JsusFx_FileInfo();
}
//
if (fileInfos[index].init(filename))
{
const char *ext = nullptr;
for (const char *p = filename; *p; ++p)
if (*p == '.')
ext = p + 1;
if (ext != nullptr && (stricmp(ext, "png") == 0 || stricmp(ext, "jpg") == 0))
{
if (gfx != nullptr)
{
gfx->gfx_loadimg(*this, index, index);
}
}
return true;
}
else
{
displayError("failed to find file %d:%s", index, filename);
return false;
}
}
void JsusFx::releaseCode() {
desc[0] = 0;
if ( codeInit )
NSEEL_code_free(codeInit);
if ( codeSlider )
NSEEL_code_free(codeSlider);
if ( codeBlock )
NSEEL_code_free(codeBlock);
if ( codeSample )
NSEEL_code_free(codeSample);
if ( codeGfx )
NSEEL_code_free(codeGfx);
codeInit = codeSlider = codeBlock = codeSample = codeGfx = codeSerialize = NULL;
NSEEL_code_compile_ex(m_vm, nullptr, 0, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS_RESET);
numInputs = 0;
numOutputs = 0;
for(int i=0;i<kMaxSliders;i++)
sliders[i].exists = false;
gfx_w = 0;
gfx_h = 0;
NSEEL_VM_remove_unused_vars(m_vm);
NSEEL_VM_remove_all_nonreg_vars(m_vm);
}
void JsusFx::init() {
EEL_string_register();
EEL_fft_register();
EEL_mdct_register();
EEL_string_register();
EEL_misc_register();
}
static int dumpvarsCallback(const char *name, EEL_F *val, void *ctx) {
JsusFx *fx = (JsusFx *) ctx;
int target;
if ( sscanf(name, "slider%d", &target) ) {
if ( target >= 0 && target < JsusFx::kMaxSliders ) {
if ( ! fx->sliders[target].exists ) {
return 1;
} else {
fx->displayMsg("%s --> %f (%s)", name, *val, fx->sliders[target].desc);
return 1;
}
}
}
fx->displayMsg("%s --> %f", name, *val);
return 1;
}
void JsusFx::dumpvars() {
NSEEL_VM_enumallvars(m_vm, dumpvarsCallback, this);
}
#ifndef JSUSFX_OWNSCRIPTMUTEXT
// todo : implement mutex interface ?
void NSEEL_HOSTSTUB_EnterMutex() { }
void NSEEL_HOSTSTUB_LeaveMutex() { }
#endif
| 25.694215 | 167 | 0.605886 | asb2m10 |
07d78ba06233cf02120b9ac3264fd6ee7df2a442 | 3,422 | cpp | C++ | src/http/connection_impl.cpp | Ri0n/blog-new-year-2021 | 449ae54400bcc06450d9b90518f3f9a67a5afeed | [
"BSL-1.0"
] | null | null | null | src/http/connection_impl.cpp | Ri0n/blog-new-year-2021 | 449ae54400bcc06450d9b90518f3f9a67a5afeed | [
"BSL-1.0"
] | null | null | null | src/http/connection_impl.cpp | Ri0n/blog-new-year-2021 | 449ae54400bcc06450d9b90518f3f9a67a5afeed | [
"BSL-1.0"
] | null | null | null | //
// Copyright (c) 2021 Richard Hodges (hodges.r@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "http/connection_impl.hpp"
namespace http
{
net::awaitable< error_code >
connection_impl::connect(async::stop_token stop)
{
error_code ec;
assert(co_await net::this_coro::executor == exec_);
if (!stream_.is_open())
ec = co_await stream_.connect(
stop, ssl_ctx_, transport_type_, hostname_, port_, options_);
co_return ec;
}
net::awaitable< std::tuple< error_code, response_type > >
connection_impl::rest_call(request_class const &request,
request_options const &options)
{
auto response = std::make_unique< response_class >();
auto ec = error_code(net::error::not_connected);
if (stream_.is_open())
ec = co_await rest_call(request, *response, options);
if (ec && ec != net::error::operation_aborted)
{
ec = co_await connect(options.stop);
if (!ec)
ec = co_await rest_call(request, *response, options);
}
if (ec || response->need_eof())
stream_.close();
co_return std::make_tuple(ec, std::move(response));
}
net::awaitable< error_code >
connection_impl::rest_call(request_class const &request,
response_class &response,
request_options const &options)
{
auto stop = options.stop;
auto ec = error_code();
if (stop.stopped())
ec = net::error::operation_aborted;
auto &tcp = stream_.get_tcp_layer();
if (!ec)
{
tcp.expires_after(options.write_timeout);
auto stopconn = stop.connect([&] { tcp.cancel(); });
co_await stream_.apply_visitor(
[&](auto &stream)
{
return beast::http::async_write(
stream,
request,
net::redirect_error(net::use_awaitable, ec));
});
}
if (!ec && stop.stopped())
ec = net::error::operation_aborted;
if (!ec)
{
tcp.expires_after(options.read_timeout);
auto stopconn = stop.connect([&] { tcp.cancel(); });
co_await stream_.apply_visitor(
[&](auto &stream)
{
return beast::http::async_read(
stream,
buf_,
response,
net::redirect_error(net::use_awaitable, ec));
});
}
if (ec || response.need_eof())
{
if (ec)
{
tcp.socket().shutdown(net::ip::tcp::socket::shutdown_both);
}
else
{
tcp.socket().shutdown(net::ip::tcp::socket::shutdown_both, ec);
}
stream_.close();
}
co_return ec;
}
connection_impl::connection_impl(net::io_strand exec,
ssl::context &sslctx,
std::string hostname,
std::string port,
transport_type ttype,
connect_options options)
: exec_(std::move(exec))
, ssl_ctx_(sslctx)
, hostname_(std::move(hostname))
, port_(std::move(port))
, transport_type_(ttype)
, options_(options)
, stream_()
, buf_()
{
}
} // namespace http
| 27.596774 | 79 | 0.547925 | Ri0n |
07d9cafde9c0e36feccb6befe458998d33f7b84d | 529 | cpp | C++ | Boost/The Boost C++ Libraries/src/14.4.6/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | 1 | 2021-03-12T19:29:33.000Z | 2021-03-12T19:29:33.000Z | Boost/The Boost C++ Libraries/src/14.4.6/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | 1 | 2019-03-13T01:36:12.000Z | 2019-03-13T01:36:12.000Z | Boost/The Boost C++ Libraries/src/14.4.6/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | null | null | null | #include <boost/variant.hpp>
#include <boost/any.hpp>
#include <vector>
#include <string>
#include <iostream>
std::vector<boost::any> vector;
struct output :
public boost::static_visitor<>
{
template <typename T>
void operator()(T &t) const
{
vector.push_back(t);
}
};
int main()
{
boost::variant<double, char, std::string> v;
v = 3.14;
boost::apply_visitor(output(), v);
v = 'A';
boost::apply_visitor(output(), v);
v = "Hello, world!";
boost::apply_visitor(output(), v);
} | 18.892857 | 47 | 0.612476 | goodspeed24e |
07d9ecc7783798bbea4197fc3c7db12202a9f9c1 | 4,309 | cpp | C++ | cv/cvthresh.cpp | hoozh/emcv | e61b1d5ad16c255f0306d0e9feb8f32e3a92d97f | [
"BSD-3-Clause"
] | null | null | null | cv/cvthresh.cpp | hoozh/emcv | e61b1d5ad16c255f0306d0e9feb8f32e3a92d97f | [
"BSD-3-Clause"
] | null | null | null | cv/cvthresh.cpp | hoozh/emcv | e61b1d5ad16c255f0306d0e9feb8f32e3a92d97f | [
"BSD-3-Clause"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License For Embedded Computer Vision Library
//
// Copyright (c) 2008-2012, EMCV Project,
// Copyright (c) 2000-2007, Intel Corporation,
// All rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the copyright holders nor the names of their 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.
//
// Contributors:
// * Shiqi Yu (Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences)
#include "_cv.h"
CV_IMPL void
cvThreshold( const void* srcarr, void* dstarr, double thresh, double maxval, int type )
{
CV_FUNCNAME( "cvThreshold" );
__BEGIN__;
CvMat src_stub, *src = (CvMat*)srcarr;
CvMat dst_stub, *dst = (CvMat*)dstarr;
int coi1 = 0, coi2 = 0;
CV_CALL( src = cvGetMat( src, &src_stub, &coi1 ));
CV_CALL( dst = cvGetMat( dst, &dst_stub, &coi2 ));
if( coi1 + coi2 )
CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
if( !CV_ARE_CNS_EQ( src, dst ) )
CV_ERROR( CV_StsUnmatchedFormats, "Both arrays must have equal number of channels" );
if( type != CV_THRESH_BINARY)
CV_ERROR( CV_StsBadFlag, "Only binary threshold is supported now. Please use type=CV_THRESH_BINARY." );
if( CV_MAT_TYPE(src->type) != CV_8UC1 || CV_MAT_TYPE(dst->type) != CV_8UC1)
CV_ERROR( CV_StsUnsupportedFormat, "Types should be 8uC1" );
switch( CV_MAT_DEPTH(src->type) )
{
case CV_8U:
register unsigned char ithreshs[4];
register unsigned char imaxvals[4];
int ithresh, imaxval;
int idx;
ithresh = cvFloor(thresh);
ithresh = (ithresh>255) ? 255 : ithresh;
ithresh = (ithresh<0) ? 0 : ithresh;
ithreshs[0]=ithreshs[1]=ithreshs[2]=ithreshs[3]=ithresh;
imaxval = cvRound(maxval);
imaxval = (imaxval>255) ? 255 : imaxval;
imaxval = (imaxval<0) ? 0 : imaxval;
imaxvals[0]=imaxvals[1]=imaxvals[2]=imaxvals[3]=imaxval;
#ifdef _TMS320C6X
register unsigned int binvals;
for(idx=0; idx < (src->step*src->height)/4; idx++)
{
binvals = _cmpgtu4( _mem4_const(src->data.i+idx), _mem4_const(ithreshs) );
binvals = _xpnd4( binvals );
_mem4(dst->data.i+idx) = binvals & _mem4_const(imaxvals);
}
#else
for(idx=0; idx < (src->step*src->height); idx++)
{
dst->data.ptr[idx] = (src->data.ptr[idx]>ithresh)? imaxval: 0;
}
#endif
break;
default:
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
}
__END__;
}
/* End of file. */
| 37.798246 | 105 | 0.671385 | hoozh |
07db098af39d225ff19a475de9228f48f8fe0333 | 28,165 | cpp | C++ | service/simulator/java/jni/simulator_resource_model_schema_jni.cpp | jonghenhan/iotivity | 7dfc2bc6a5c0506cf88bc23e88e38fe1b795da31 | [
"Apache-2.0"
] | 301 | 2015-01-20T16:11:32.000Z | 2021-11-25T04:29:36.000Z | service/simulator/java/jni/simulator_resource_model_schema_jni.cpp | jonghenhan/iotivity | 7dfc2bc6a5c0506cf88bc23e88e38fe1b795da31 | [
"Apache-2.0"
] | 21 | 2019-10-02T08:31:36.000Z | 2021-12-09T21:46:49.000Z | service/simulator/java/jni/simulator_resource_model_schema_jni.cpp | jonghenhan/iotivity | 7dfc2bc6a5c0506cf88bc23e88e38fe1b795da31 | [
"Apache-2.0"
] | 233 | 2015-01-26T03:41:59.000Z | 2022-03-18T23:54:04.000Z | /******************************************************************
*
* Copyright 2016 Samsung Electronics 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 "simulator_resource_model_schema_jni.h"
#include "simulator_utils_jni.h"
#include "jni_string.h"
static AttributeProperty::Type getType(JNIEnv *env, jobject &jProperty)
{
static jmethodID getTypeMID = env->GetMethodID(
gSimulatorClassRefs.attributePropertyCls, "getType",
"()Lorg/oic/simulator/AttributeProperty$Type;");
static jmethodID ordinalMID = env->GetMethodID(
gSimulatorClassRefs.attributePropertyTypeCls, "ordinal", "()I");
jobject jType = env->CallObjectMethod(jProperty, getTypeMID);
int ordinal = env->CallIntMethod(jType, ordinalMID);
return AttributeProperty::Type(ordinal);
}
class JniIntegerProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<IntegerProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java IntegerProperty.Builder object
jobject jPropertyBuilder = nullptr;
static jmethodID builderCtor = env->GetMethodID(
gSimulatorClassRefs.integerPropertyBuilderCls, "<init>", "()V");
jPropertyBuilder = env->NewObject(gSimulatorClassRefs.integerPropertyBuilderCls, builderCtor);
// Set default value
static jmethodID setDefaultValueMID = env->GetMethodID(
gSimulatorClassRefs.integerPropertyBuilderCls, "setDefaultValue", "(I)V");
env->CallVoidMethod(jPropertyBuilder, setDefaultValueMID, property->getDefaultValue());
// Set Range or enum value set
if (property->hasRange())
{
int min = 0;
int max = 0;
property->getRange(min, max);
static jmethodID setRangeMID = env->GetMethodID(
gSimulatorClassRefs.integerPropertyBuilderCls, "setRange", "(II)V");
env->CallVoidMethod(jPropertyBuilder, setRangeMID, min, max);
}
else if (property->hasValues())
{
std::vector<int> values;
property->getValues(values);
jintArray jIntArray = env->NewIntArray(values.size());
env->SetIntArrayRegion(jIntArray, 0, values.size(), reinterpret_cast<const jint *>(&values[0]));
static jmethodID setValuesMID = env->GetMethodID(
gSimulatorClassRefs.integerPropertyBuilderCls, "setValues", "([I)V");
env->CallVoidMethod(jPropertyBuilder, setValuesMID, jIntArray);
}
// Create Java IntegerProperty object
static jmethodID buildMID = env->GetMethodID(
gSimulatorClassRefs.integerPropertyBuilderCls, "build", "()Lorg/oic/simulator/IntegerProperty;");
return env->CallObjectMethod(jPropertyBuilder, buildMID);
}
static std::shared_ptr<IntegerProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID defaultValueFID = env->GetFieldID(gSimulatorClassRefs.integerPropertyCls,
"mDefaultValue", "I");
static jfieldID hasRangeFID = env->GetFieldID(gSimulatorClassRefs.integerPropertyCls,
"mHasRange", "Z");
jint defaultValue = env->GetIntField(jProperty, defaultValueFID);
jboolean hasRange = env->GetBooleanField(jProperty, hasRangeFID);
std::shared_ptr<IntegerProperty> integerProperty =
IntegerProperty::build(defaultValue);
if (hasRange)
{
static jfieldID minFID = env->GetFieldID(gSimulatorClassRefs.integerPropertyCls,
"mMin", "I");
static jfieldID maxFID = env->GetFieldID(gSimulatorClassRefs.integerPropertyCls,
"mMax", "I");
jint min = env->GetIntField(jProperty, minFID);
jint max = env->GetIntField(jProperty, maxFID);
integerProperty->setRange(min, max);
}
else
{
static jfieldID valuesFID = env->GetFieldID(gSimulatorClassRefs.integerPropertyCls,
"mValues", "[I");
jintArray jValues = (jintArray) env->GetObjectField(jProperty, valuesFID);
if (jValues)
{
std::vector<int> values;
jint *jIntArray = env->GetIntArrayElements(jValues, NULL);
size_t length = env->GetArrayLength(jValues);
for (size_t index = 0; index < length; index++)
{
values.push_back(jIntArray[index]);
}
integerProperty->setValues(values);
env->ReleaseIntArrayElements(jValues, jIntArray, 0);
}
}
return integerProperty;
}
};
class JniDoubleProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<DoubleProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java DoubleProperty.Builder object
jobject jPropertyBuilder = nullptr;
static jmethodID builderCtor = env->GetMethodID(
gSimulatorClassRefs.doublePropertyBuilderCls, "<init>", "()V");
jPropertyBuilder = env->NewObject(gSimulatorClassRefs.doublePropertyBuilderCls, builderCtor);
// Set default value
static jmethodID setDefaultValueMID = env->GetMethodID(
gSimulatorClassRefs.doublePropertyBuilderCls, "setDefaultValue", "(D)V");
env->CallVoidMethod(jPropertyBuilder, setDefaultValueMID, property->getDefaultValue());
// Set Range or enum value set
if (property->hasRange())
{
double min = 0.0;
double max = 0.0;
property->getRange(min, max);
static jmethodID setRangeMID = env->GetMethodID(
gSimulatorClassRefs.doublePropertyBuilderCls, "setRange", "(DD)V");
env->CallVoidMethod(jPropertyBuilder, setRangeMID, min, max);
}
else if (property->hasValues())
{
std::vector<double> values;
property->getValues(values);
jdoubleArray jDoubleArray = env->NewDoubleArray(values.size());
env->SetDoubleArrayRegion(jDoubleArray, 0, values.size(),
reinterpret_cast<const jdouble *>(&values[0]));
static jmethodID setValuesMID = env->GetMethodID(
gSimulatorClassRefs.doublePropertyBuilderCls, "setValues", "([D)V");
env->CallVoidMethod(jPropertyBuilder, setValuesMID, jDoubleArray);
}
// Create Java DoubleProperty object
static jmethodID buildMID = env->GetMethodID(
gSimulatorClassRefs.doublePropertyBuilderCls, "build", "()Lorg/oic/simulator/DoubleProperty;");
return env->CallObjectMethod(jPropertyBuilder, buildMID);
}
static std::shared_ptr<DoubleProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID defaultValueFID = env->GetFieldID(gSimulatorClassRefs.doublePropertyCls,
"mDefaultValue", "D");
static jfieldID hasRangeFID = env->GetFieldID(gSimulatorClassRefs.doublePropertyCls,
"mHasRange", "Z");
jdouble defaultValue = env->GetDoubleField(jProperty, defaultValueFID);
jboolean hasRange = env->GetBooleanField(jProperty, hasRangeFID);
std::shared_ptr<DoubleProperty> doubleProperty =
DoubleProperty::build(defaultValue);
if (hasRange)
{
static jfieldID minFID = env->GetFieldID(gSimulatorClassRefs.doublePropertyCls,
"mMin", "D");
static jfieldID maxFID = env->GetFieldID(gSimulatorClassRefs.doublePropertyCls,
"mMax", "D");
jdouble min = env->GetDoubleField(jProperty, minFID);
jdouble max = env->GetDoubleField(jProperty, maxFID);
doubleProperty->setRange(min, max);
}
else
{
static jfieldID valuesFID = env->GetFieldID(gSimulatorClassRefs.doublePropertyCls,
"mValues", "[D");
jdoubleArray jValues = (jdoubleArray) env->GetObjectField(jProperty, valuesFID);
if (jValues)
{
std::vector<double> values;
jdouble *jDoubleArray = env->GetDoubleArrayElements(jValues, NULL);
size_t length = env->GetArrayLength(jValues);
for (size_t index = 0; index < length; index++)
{
values.push_back(jDoubleArray[index]);
}
doubleProperty->setValues(values);
env->ReleaseDoubleArrayElements(jValues, jDoubleArray, 0);
}
}
return doubleProperty;
}
};
class JniBooleanProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<BooleanProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java BooleanProperty.Builder object
jobject jPropertyBuilder = nullptr;
static jmethodID builderCtor = env->GetMethodID(
gSimulatorClassRefs.booleanPropertyBuilderCls, "<init>", "()V");
jPropertyBuilder = env->NewObject(gSimulatorClassRefs.booleanPropertyBuilderCls, builderCtor);
// Set default value
static jmethodID setDefaultValueMID = env->GetMethodID(
gSimulatorClassRefs.booleanPropertyBuilderCls, "setDefaultValue", "(Z)V");
env->CallVoidMethod(jPropertyBuilder, setDefaultValueMID, property->getDefaultValue());
// Create Java BooleanProperty object
static jmethodID buildMID = env->GetMethodID(
gSimulatorClassRefs.booleanPropertyBuilderCls, "build", "()Lorg/oic/simulator/BooleanProperty;");
return env->CallObjectMethod(jPropertyBuilder, buildMID);
}
static std::shared_ptr<BooleanProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID defaultValueFID = env->GetFieldID(gSimulatorClassRefs.booleanPropertyCls,
"mDefaultValue", "Z");
jboolean defaultValue = env->GetBooleanField(jProperty, defaultValueFID);
return BooleanProperty::build(defaultValue);
}
};
class JniStringProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<StringProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java StringProperty.Builder object
jobject jPropertyBuilder = nullptr;
static jmethodID builderCtor = env->GetMethodID(
gSimulatorClassRefs.stringPropertyBuilderCls, "<init>", "()V");
jPropertyBuilder = env->NewObject(gSimulatorClassRefs.stringPropertyBuilderCls, builderCtor);
// Set default value
static jmethodID setDefaultValueMID = env->GetMethodID(
gSimulatorClassRefs.stringPropertyBuilderCls, "setDefaultValue", "(Ljava/lang/String;)V");
jstring jDefaultValue = env->NewStringUTF(property->getDefaultValue().c_str());
env->CallVoidMethod(jPropertyBuilder, setDefaultValueMID, jDefaultValue);
// Set Range or enum value set
if (property->hasRange())
{
size_t min = 0;
size_t max = 0;
property->getRange(min, max);
static jmethodID setRangeMID = env->GetMethodID(
gSimulatorClassRefs.stringPropertyBuilderCls, "setRange", "(II)V");
env->CallVoidMethod(jPropertyBuilder, setRangeMID, static_cast<jint>(min),
static_cast<jint>(max));
}
else if (property->hasValues())
{
std::vector<std::string> values;
property->getValues(values);
jobjectArray jStringArray = env->NewObjectArray(values.size(), gSimulatorClassRefs.stringCls,
nullptr);
for (size_t index = 0; index < values.size(); index++)
{
jstring element = env->NewStringUTF(values[index].c_str());
env->SetObjectArrayElement(jStringArray, index, element);
}
static jmethodID setValuesMID = env->GetMethodID(
gSimulatorClassRefs.stringPropertyBuilderCls, "setValues", "([Ljava/lang/String;)V");
env->CallVoidMethod(jPropertyBuilder, setValuesMID, jStringArray);
}
// Create Java StringProperty object
static jmethodID buildMID = env->GetMethodID(
gSimulatorClassRefs.stringPropertyBuilderCls, "build", "()Lorg/oic/simulator/StringProperty;");
return env->CallObjectMethod(jPropertyBuilder, buildMID);
}
static std::shared_ptr<StringProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID defaultValueFID = env->GetFieldID(gSimulatorClassRefs.stringPropertyCls,
"mDefaultValue", "Ljava/lang/String;");
static jfieldID hasRangeFID = env->GetFieldID(gSimulatorClassRefs.stringPropertyCls,
"mHasRange", "Z");
jstring defaultValue = (jstring) env->GetObjectField(jProperty, defaultValueFID);
jboolean hasRange = env->GetBooleanField(jProperty, hasRangeFID);
std::shared_ptr<StringProperty> stringProperty =
StringProperty::build(JniString(env, defaultValue).get());
if (hasRange)
{
static jfieldID minFID = env->GetFieldID(gSimulatorClassRefs.stringPropertyCls,
"mMin", "I");
static jfieldID maxFID = env->GetFieldID(gSimulatorClassRefs.stringPropertyCls,
"mMax", "I");
jint min = env->GetIntField(jProperty, minFID);
jint max = env->GetIntField(jProperty, maxFID);
if (min >= 0 && max >= 0)
{
stringProperty->setRange(static_cast<size_t>(min), static_cast<size_t>(max));
}
}
else
{
static jfieldID valuesFID = env->GetFieldID(gSimulatorClassRefs.stringPropertyCls,
"mValues", "[Ljava/lang/String;");
jobjectArray jValues = (jobjectArray) env->GetObjectField(jProperty, valuesFID);
if (jValues)
{
std::vector<std::string> values;
size_t length = env->GetArrayLength(jValues);
for (size_t index = 0; index < length; index++)
{
jstring jValue = (jstring) env->GetObjectArrayElement(jValues, index);
values.push_back(JniString(env, jValue).get());
}
stringProperty->setValues(values);
}
}
return stringProperty;
}
};
class JniArrayProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<ArrayProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java ArrayProperty.Builder object
jobject jPropertyBuilder = nullptr;
static jmethodID builderCtor = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "<init>", "()V");
jPropertyBuilder = env->NewObject(gSimulatorClassRefs.arrayPropertyBuilderCls, builderCtor);
// Set variable size propety
if (property->isVariable())
{
static jmethodID setVariableMID = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "setVariableSize", "(Z)V");
env->CallVoidMethod(jPropertyBuilder, setVariableMID, property->isVariable());
}
// Set unique propety
if (property->isUnique())
{
static jmethodID setUniqueMID = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "setUnique", "(Z)V");
env->CallVoidMethod(jPropertyBuilder, setUniqueMID, property->isUnique());
}
// Set range property
if (property->hasRange())
{
size_t min = property->getMinItems();
size_t max = property->getMaxItems();
static jmethodID setRangeMID = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "setRange", "(II)V");
env->CallVoidMethod(jPropertyBuilder, setRangeMID, static_cast<jint>(min),
static_cast<jint>(max));
}
// Set element property
jobject jElementProperty = AttributePropertyToJava(env, property->getElementProperty());
static jmethodID setElementPropertyMID = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "setElementProperty",
"(Lorg/oic/simulator/AttributeProperty;)V");
env->CallVoidMethod(jPropertyBuilder, setElementPropertyMID, jElementProperty);
// Create Java ArrayProperty object
static jmethodID buildMID = env->GetMethodID(
gSimulatorClassRefs.arrayPropertyBuilderCls, "build", "()Lorg/oic/simulator/ArrayProperty;");
return env->CallObjectMethod(jPropertyBuilder, buildMID);
}
static std::shared_ptr<ArrayProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID hasRangeFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mHasRange", "Z");
static jfieldID variableFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mIsVariableSize", "Z");
static jfieldID uniqueFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mIsUnique", "Z");
static jfieldID elementPropertyFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mElementProperty", "Lorg/oic/simulator/AttributeProperty;");
jboolean hasRange = env->GetBooleanField(jProperty, hasRangeFID);
jboolean isVariable = env->GetBooleanField(jProperty, variableFID);
jboolean isUnique = env->GetBooleanField(jProperty, uniqueFID);
jobject jElementProperty = env->GetObjectField(jProperty, elementPropertyFID);
std::shared_ptr<ArrayProperty> arrayProperty = ArrayProperty::build();
arrayProperty->setVariable(isVariable);
arrayProperty->setUnique(isUnique);
if (hasRange)
{
static jfieldID minFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mMin", "I");
static jfieldID maxFID = env->GetFieldID(gSimulatorClassRefs.arrayPropertyCls,
"mMax", "I");
jint min = env->GetIntField(jProperty, minFID);
jint max = env->GetIntField(jProperty, maxFID);
if (min >= 0 && max >= 0)
{
arrayProperty->setRange(static_cast<size_t>(min), static_cast<size_t>(max));
}
}
if (jElementProperty)
{
arrayProperty->setElementProperty(AttributePropertyToCpp(env, jElementProperty));
}
return arrayProperty;
}
};
class JniModelProperty
{
public:
static jobject toJava(JNIEnv *env, const std::shared_ptr<ModelProperty> &property)
{
if (!property)
{
return nullptr;
}
// Create Java ModelProperty object
jobject jModelProperty = nullptr;
static jmethodID modelPropertyCtor = env->GetMethodID(
gSimulatorClassRefs.modelPropertyCls, "<init>", "()V");
jModelProperty = env->NewObject(gSimulatorClassRefs.modelPropertyCls, modelPropertyCtor);
// Set child propeties
for (auto &propertyEntry : property->getChildProperties())
{
jstring jAttrName = env->NewStringUTF(propertyEntry.first.c_str());
jobject jProperty = AttributePropertyToJava(env, propertyEntry.second);
jboolean required = property->isRequired(propertyEntry.first);
static jmethodID addMID = env->GetMethodID(
gSimulatorClassRefs.modelPropertyCls, "add",
"(Ljava/lang/String;Lorg/oic/simulator/AttributeProperty;Z)Z");
env->CallBooleanMethod(jModelProperty, addMID, jAttrName, jProperty, required);
}
return jModelProperty;
}
static std::shared_ptr<ModelProperty> toCpp(JNIEnv *env, jobject &jProperty)
{
static jfieldID childPropertiesFID = env->GetFieldID(gSimulatorClassRefs.modelPropertyCls,
"mChildProperties", "Ljava/util/Map;");
static jmethodID isRequiredMID = env->GetMethodID(gSimulatorClassRefs.modelPropertyCls,
"isRequired", "()Z");
static jmethodID entrySetMID = env->GetMethodID(gSimulatorClassRefs.mapCls,
"entrySet", "()Ljava/util/Set;");
static jmethodID iteratorMID = env->GetMethodID(gSimulatorClassRefs.setCls,
"iterator", "()Ljava/util/Iterator;");
static jmethodID hasNextMID = env->GetMethodID(gSimulatorClassRefs.iteratorCls,
"hasNext", "()Z");
static jmethodID nextMID = env->GetMethodID(gSimulatorClassRefs.iteratorCls,
"next", "()Ljava/lang/Object;");
static jmethodID getKeyMID = env->GetMethodID(gSimulatorClassRefs.mapEntryCls,
"getKey", "()Ljava/lang/Object;");
static jmethodID getValueMID = env->GetMethodID(gSimulatorClassRefs.mapEntryCls,
"getValue", "()Ljava/lang/Object;");
std::shared_ptr<ModelProperty> modelProperty = ModelProperty::build();
jobject jChildProperties = env->GetObjectField(jProperty, childPropertiesFID);
if (jChildProperties)
{
jobject entrySet = env->CallObjectMethod(jChildProperties, entrySetMID);
jobject iterator = env->CallObjectMethod(entrySet, iteratorMID);
if (entrySet && iterator)
{
while (env->CallBooleanMethod(iterator, hasNextMID))
{
jobject entry = env->CallObjectMethod(iterator, nextMID);
jstring key = (jstring) env->CallObjectMethod(entry, getKeyMID);
jobject value = env->CallObjectMethod(entry, getValueMID);
jboolean isRequired = env->CallBooleanMethod(jProperty, isRequiredMID, key);
modelProperty->add(JniString(env, key).get(),
AttributePropertyToCpp(env, value), isRequired);
env->DeleteLocalRef(entry);
env->DeleteLocalRef(key);
env->DeleteLocalRef(value);
}
}
}
return modelProperty;
}
};
jobject AttributePropertyToJava(JNIEnv *env,
const std::shared_ptr<AttributeProperty> &property)
{
if (!property)
{
return nullptr;
}
if (property->isInteger())
{
return JniIntegerProperty::toJava(env, property->asInteger());
}
else if (property->isDouble())
{
return JniDoubleProperty::toJava(env, property->asDouble());
}
else if (property->isBoolean())
{
return JniBooleanProperty::toJava(env, property->asBoolean());
}
else if (property->isString())
{
return JniStringProperty::toJava(env, property->asString());
}
else if (property->isArray())
{
return JniArrayProperty::toJava(env, property->asArray());
}
else if (property->isModel())
{
return JniModelProperty::toJava(env, property->asModel());
}
return nullptr; // Control should never reach here
}
std::shared_ptr<AttributeProperty> AttributePropertyToCpp(JNIEnv *env,
jobject &jProperty)
{
if (!jProperty)
{
return nullptr;
}
switch (getType(env, jProperty))
{
case AttributeProperty::Type::INTEGER:
return JniIntegerProperty::toCpp(env, jProperty);
case AttributeProperty::Type::DOUBLE:
return JniDoubleProperty::toCpp(env, jProperty);
case AttributeProperty::Type::BOOLEAN:
return JniBooleanProperty::toCpp(env, jProperty);
case AttributeProperty::Type::STRING:
return JniStringProperty::toCpp(env, jProperty);
case AttributeProperty::Type::ARRAY:
return JniArrayProperty::toCpp(env, jProperty);
case AttributeProperty::Type::MODEL:
return JniModelProperty::toCpp(env, jProperty);
}
return nullptr; // Control should never reach here
}
| 44.706349 | 141 | 0.553737 | jonghenhan |
07dc68a6c8701a2df10ab824dfb0426c3ea3816d | 2,314 | cpp | C++ | reflection/TypeInfo.cpp | jess22664/x3ogre | 9de430859d877407ae0308908390c9fa004b0e84 | [
"MIT"
] | 1 | 2021-09-18T12:50:35.000Z | 2021-09-18T12:50:35.000Z | reflection/TypeInfo.cpp | jess22664/x3ogre | 9de430859d877407ae0308908390c9fa004b0e84 | [
"MIT"
] | null | null | null | reflection/TypeInfo.cpp | jess22664/x3ogre | 9de430859d877407ae0308908390c9fa004b0e84 | [
"MIT"
] | null | null | null | /*
* TypeInfo.cpp
*
* Created on: 13.02.2014
* Author: parojtbe
*/
#include <reflection/TypeInfo.h>
#include <reflection/db.h>
#include <stdexcept>
using namespace std;
namespace reflection {
TypeInfoCommon::TypeInfoCommon(const string& parentType) : _parentType(parentType) {
}
void TypeInfoCommon::_resolveParentInfo() {
string parentType = _parentType;
TypeInfoCommon* parentInfo = nullptr;
while((parentInfo = getTypeInfo(parentType))) {
_setters.insert(parentInfo->_setters.begin(), parentInfo->_setters.end());
parentType = parentInfo->_parentType;
}
#if 0
map<string, ISetterAdapter*>::iterator i = _setters.begin();
for(; i != _setters.end(); ++i) {
cout << "\t" << i->first << endl;
}
#endif
}
const std::string& TypeInfoCommon::memberByArgType(Object* arg) {
for(const auto& e : _setters) {
if(e.second->supports(arg)) {
return e.first;
}
}
throw runtime_error("could not find member by type");
}
void TypeInfoCommon::callMember(void* obj, const string& member, void* value) {
auto i = _setters.find(member);
if(i == _setters.end()) {
throw runtime_error("no such member: '"+member+"'");
}
(*i->second)(obj, value);
}
void TypeInfoCommon::callMember(void* obj, const string& member, const string& value) {
auto i = _setters.find(member);
if(i == _setters.end()) {
throw runtime_error("no such member: '"+member+"'");
}
(*i->second)(obj, value);
}
const void* TypeInfoCommon::callMember(const void* obj, const std::string& name) {
auto i = _getters.find(name);
if(i == _getters.end()) {
throw runtime_error("no such member: '"+name+"'");
}
return (*i->second)(obj);
}
std::string TypeInfoCommon::callMemberString(const void* obj, const std::string& name) {
auto i = _getters.find(name);
if(i == _getters.end()) {
throw runtime_error("no such member: '"+name+"'");
}
return i->second->stringValue(obj);
}
void TypeInfoCommon::callMember(void* obj, const std::string& member, const std::shared_ptr<void>& value) {
auto i = _setters.find(member);
if(i == _setters.end()) {
throw runtime_error("no such member: '"+member+"'");
}
(*i->second)(obj, value);
}
}
| 23.373737 | 107 | 0.625756 | jess22664 |
07dd0b1900d62e8f72ad89a6e819c601abf65897 | 1,877 | cc | C++ | shell/platform/common/incoming_message_dispatcher.cc | onix39/engine | ec66a45a3a7d5b9dfc2e0feab8965db7a91027cc | [
"BSD-3-Clause"
] | 5,823 | 2015-09-20T02:43:18.000Z | 2022-03-31T23:38:55.000Z | shell/platform/common/incoming_message_dispatcher.cc | onix39/engine | ec66a45a3a7d5b9dfc2e0feab8965db7a91027cc | [
"BSD-3-Clause"
] | 20,081 | 2015-09-19T16:07:59.000Z | 2022-03-31T23:33:26.000Z | shell/platform/common/incoming_message_dispatcher.cc | onix39/engine | ec66a45a3a7d5b9dfc2e0feab8965db7a91027cc | [
"BSD-3-Clause"
] | 5,383 | 2015-09-24T22:49:53.000Z | 2022-03-31T14:33:51.000Z | // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
namespace flutter {
IncomingMessageDispatcher::IncomingMessageDispatcher(
FlutterDesktopMessengerRef messenger)
: messenger_(messenger) {}
IncomingMessageDispatcher::~IncomingMessageDispatcher() = default;
/// @note Procedure doesn't copy all closures.
void IncomingMessageDispatcher::HandleMessage(
const FlutterDesktopMessage& message,
const std::function<void(void)>& input_block_cb,
const std::function<void(void)>& input_unblock_cb) {
std::string channel(message.channel);
// Find the handler for the channel; if there isn't one, report the failure.
if (callbacks_.find(channel) == callbacks_.end()) {
FlutterDesktopMessengerSendResponse(messenger_, message.response_handle,
nullptr, 0);
return;
}
auto& callback_info = callbacks_[channel];
FlutterDesktopMessageCallback message_callback = callback_info.first;
// Process the call, handling input blocking if requested.
bool block_input = input_blocking_channels_.count(channel) > 0;
if (block_input) {
input_block_cb();
}
message_callback(messenger_, &message, callback_info.second);
if (block_input) {
input_unblock_cb();
}
}
void IncomingMessageDispatcher::SetMessageCallback(
const std::string& channel,
FlutterDesktopMessageCallback callback,
void* user_data) {
if (!callback) {
callbacks_.erase(channel);
return;
}
callbacks_[channel] = std::make_pair(callback, user_data);
}
void IncomingMessageDispatcher::EnableInputBlockingForChannel(
const std::string& channel) {
input_blocking_channels_.insert(channel);
}
} // namespace flutter
| 31.813559 | 78 | 0.740543 | onix39 |
07dfb138f3f09ce6a032262ec2fb293f2662e9dd | 287 | hpp | C++ | include/Covariance/Covariance2D.hpp | belcour/CovarianceTracing | 60b5cfd82d7b0fa9a623743551ff8cf9595adf07 | [
"Unlicense"
] | 45 | 2016-07-19T21:52:06.000Z | 2021-12-07T08:21:49.000Z | include/Covariance/Covariance2D.hpp | belcour/CovarianceTracing | 60b5cfd82d7b0fa9a623743551ff8cf9595adf07 | [
"Unlicense"
] | null | null | null | include/Covariance/Covariance2D.hpp | belcour/CovarianceTracing | 60b5cfd82d7b0fa9a623743551ff8cf9595adf07 | [
"Unlicense"
] | 7 | 2016-07-28T15:18:26.000Z | 2020-06-14T12:20:16.000Z | #pragma once
namespace Covariance {
/*! The 2D isotropic version of Covariance Tracing.
* This code assumes that light transport in 2 dimensions and only
* store a 2D covariance matrix for space and angles.
*/
struct Covariance2D {
float matrix[3];
};
}
| 19.133333 | 70 | 0.672474 | belcour |
07e277e0584f3bc235ea31aa98d9d4fd4118fefb | 9,364 | cpp | C++ | src/lava_lib/reader_bgeo/test/test_vol.cpp | cinepost/Falcor | f70bd1d97c064d6f91a017d4409aa2037fd6903a | [
"BSD-3-Clause"
] | 7 | 2018-09-25T23:45:52.000Z | 2021-07-07T04:08:01.000Z | src/lava_lib/reader_bgeo/test/test_vol.cpp | cinepost/Falcor | f70bd1d97c064d6f91a017d4409aa2037fd6903a | [
"BSD-3-Clause"
] | 2 | 2021-03-02T10:16:06.000Z | 2021-08-13T10:10:21.000Z | src/lava_lib/reader_bgeo/test/test_vol.cpp | cinepost/Lava | f70bd1d97c064d6f91a017d4409aa2037fd6903a | [
"BSD-3-Clause"
] | 3 | 2020-06-07T05:47:48.000Z | 2020-10-03T12:34:54.000Z | /*
* Copyright 2018 Laika, LLC. Authored by Peter Stuart
*
* Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
* http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
* http://opensource.org/licenses/MIT>, at your option. This file may not be
* copied, modified, or distributed except according to those terms.
*/
#include <hboost/test/unit_test.hpp>
#include "bgeo/Bgeo.h"
#include "bgeo/Volume.h"
namespace ika
{
namespace bgeo
{
namespace test_vol
{
HBOOST_AUTO_TEST_CASE(test_vol)
{
Bgeo bgeo("geo/vol.bgeo");
HBOOST_CHECK_EQUAL(1, bgeo.getPointCount());
HBOOST_CHECK_EQUAL(1, bgeo.getTotalVertexCount());
HBOOST_CHECK_EQUAL(1, bgeo.getPrimitiveCount());
float expected_P[] = {
0, 0, 0
};
std::vector<float> P;
bgeo.getP(P);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_P[0], &expected_P[3], P.begin(), P.end());
auto primitive = bgeo.getPrimitive(0);
HBOOST_CHECK(primitive);
HBOOST_CHECK(primitive->isType<Volume>());
HBOOST_CHECK_EQUAL(1, primitive->getVertexCount());
const Volume* volume = primitive->cast<Volume>();
HBOOST_CHECK(volume);
int32_t expected_resolution[] = {
4, 3, 3
};
int32_t resolution[3];
volume->getResolution(resolution);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_resolution[0], &expected_resolution[3],
&resolution[0], &resolution[3]);
double Pd[3];
volume->getTranslate(Pd);
HBOOST_CHECK_CLOSE(expected_P[0], Pd[0], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[1], Pd[1], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[2], Pd[2], 0.0001);
// Use this for .geo vvvvvvvv
// double expected_xform[] = {
// 1.99180066586, 0, 0, 0,
// 0, 1.49385046959, 0, 0,
// 0, 0, 1.49385046959, 0,
// 0, 0, 0, 1
// };
// Use this for .bgeo vvvvvvv
double expected_xform[] = {
1.9918006658554077, 0, 0, 0,
0, 1.4938504695892334, 0, 0,
0, 0, 1.4938504695892334, 0,
0, 0, 0, 1
};
double matrix[16];
volume->getExtraTransform(matrix);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_xform[0], &expected_xform[16],
&matrix[0], &matrix[16]);
float expected_density[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0.729885101318,
0.446920752525, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
std::vector<float> voxels;
volume->getVoxels(voxels);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_density[0], &expected_density[36],
voxels.begin(), voxels.end());
}
HBOOST_AUTO_TEST_CASE(test_vol_14)
{
Bgeo bgeo("geo/vol_14.bgeo");
HBOOST_CHECK_EQUAL(1, bgeo.getPointCount());
HBOOST_CHECK_EQUAL(1, bgeo.getTotalVertexCount());
HBOOST_CHECK_EQUAL(1, bgeo.getPrimitiveCount());
float expected_P[] = {
0, 0, 0
};
std::vector<float> P;
bgeo.getP(P);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_P[0], &expected_P[3], P.begin(), P.end());
auto primitive = bgeo.getPrimitive(0);
HBOOST_CHECK(primitive);
HBOOST_CHECK(primitive->isType<Volume>());
HBOOST_CHECK_EQUAL(1, primitive->getVertexCount());
const Volume* volume = primitive->cast<Volume>();
HBOOST_CHECK(volume);
int32_t expected_resolution[] = {
4, 3, 3
};
int32_t resolution[3];
volume->getResolution(resolution);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_resolution[0], &expected_resolution[3],
&resolution[0], &resolution[3]);
double Pd[3];
volume->getTranslate(Pd);
HBOOST_CHECK_CLOSE(expected_P[0], Pd[0], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[1], Pd[1], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[2], Pd[2], 0.0001);
// Use this for .geo vvvvvvvv
// double expected_xform[] = {
// 1.99180066586, 0, 0, 0,
// 0, 1.49385046959, 0, 0,
// 0, 0, 1.49385046959, 0,
// 0, 0, 0, 1
// };
// Use this for .bgeo vvvvvvv
double expected_xform[] = {
1.9918006658554077, 0, 0, 0,
0, 1.4938504695892334, 0, 0,
0, 0, 1.4938504695892334, 0,
0, 0, 0, 1
};
double matrix[16];
volume->getExtraTransform(matrix);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_xform[0], &expected_xform[16],
&matrix[0], &matrix[16]);
float expected_density[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0.729885101318,
0.446920752525, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
std::vector<float> voxels;
volume->getVoxels(voxels);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_density[0], &expected_density[36],
voxels.begin(), voxels.end());
}
HBOOST_AUTO_TEST_CASE(test_vol_15)
{
Bgeo bgeo("geo/vol_15.bgeo");
HBOOST_CHECK_EQUAL(1, bgeo.getPointCount());
HBOOST_CHECK_EQUAL(1, bgeo.getTotalVertexCount());
HBOOST_CHECK_EQUAL(1, bgeo.getPrimitiveCount());
float expected_P[] = {
0, 0, 0
};
std::vector<float> P;
bgeo.getP(P);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_P[0], &expected_P[3], P.begin(), P.end());
auto primitive = bgeo.getPrimitive(0);
HBOOST_CHECK(primitive);
HBOOST_CHECK(primitive->isType<Volume>());
HBOOST_CHECK_EQUAL(1, primitive->getVertexCount());
const Volume* volume = primitive->cast<Volume>();
HBOOST_CHECK(volume);
int32_t expected_resolution[] = {
4, 3, 3
};
int32_t resolution[3];
volume->getResolution(resolution);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_resolution[0], &expected_resolution[3],
&resolution[0], &resolution[3]);
double Pd[3];
volume->getTranslate(Pd);
HBOOST_CHECK_CLOSE(expected_P[0], Pd[0], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[1], Pd[1], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[2], Pd[2], 0.0001);
// Use this for .geo vvvvvvvv
// double expected_xform[] = {
// 1.99180066586, 0, 0, 0,
// 0, 1.49385046959, 0, 0,
// 0, 0, 1.49385046959, 0,
// 0, 0, 0, 1
// };
// Use this for .bgeo vvvvvvv
double expected_xform[] = {
1.9918006658554077, 0, 0, 0,
0, 1.4938504695892334, 0, 0,
0, 0, 1.4938504695892334, 0,
0, 0, 0, 1
};
double matrix[16];
volume->getExtraTransform(matrix);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_xform[0], &expected_xform[16],
&matrix[0], &matrix[16]);
float expected_density[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0.729885101318,
0.446920752525, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
std::vector<float> voxels;
volume->getVoxels(voxels);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_density[0], &expected_density[36],
voxels.begin(), voxels.end());
}
HBOOST_AUTO_TEST_CASE(test_vol_16)
{
Bgeo bgeo("geo/vol_16.bgeo");
HBOOST_CHECK_EQUAL(1, bgeo.getPointCount());
HBOOST_CHECK_EQUAL(1, bgeo.getTotalVertexCount());
HBOOST_CHECK_EQUAL(1, bgeo.getPrimitiveCount());
float expected_P[] = {
0, 0, 0
};
std::vector<float> P;
bgeo.getP(P);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_P[0], &expected_P[3], P.begin(), P.end());
auto primitive = bgeo.getPrimitive(0);
HBOOST_CHECK(primitive);
HBOOST_CHECK(primitive->isType<Volume>());
HBOOST_CHECK_EQUAL(1, primitive->getVertexCount());
const Volume* volume = primitive->cast<Volume>();
HBOOST_CHECK(volume);
int32_t expected_resolution[] = {
4, 3, 3
};
int32_t resolution[3];
volume->getResolution(resolution);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_resolution[0], &expected_resolution[3],
&resolution[0], &resolution[3]);
double Pd[3];
volume->getTranslate(Pd);
HBOOST_CHECK_CLOSE(expected_P[0], Pd[0], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[1], Pd[1], 0.0001);
HBOOST_CHECK_CLOSE(expected_P[2], Pd[2], 0.0001);
// Use this for .geo vvvvvvvv
// double expected_xform[] = {
// 1.99180066586, 0, 0, 0,
// 0, 1.49385046959, 0, 0,
// 0, 0, 1.49385046959, 0,
// 0, 0, 0, 1
// };
// Use this for .bgeo vvvvvvv
double expected_xform[] = {
1.9918006658554077, 0, 0, 0,
0, 1.4938504695892334, 0, 0,
0, 0, 1.4938504695892334, 0,
0, 0, 0, 1
};
double matrix[16];
volume->getExtraTransform(matrix);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_xform[0], &expected_xform[16],
&matrix[0], &matrix[16]);
float expected_density[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0.729885101318,
0.446920752525, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
std::vector<float> voxels;
volume->getVoxels(voxels);
HBOOST_CHECK_EQUAL_COLLECTIONS(&expected_density[0], &expected_density[36],
voxels.begin(), voxels.end());
}
} // namespace test_vol
} // namespace bgeo
} // namespace ika
| 28.462006 | 87 | 0.591521 | cinepost |
07e2e04103dea9ac02c132b228a76e55dde99c44 | 6,208 | cpp | C++ | EmbeddedSystem/mainwindow.cpp | gzxultra/arm-thermometer-project | b68e92fb7c7e037dbe88f789962e16e27338739c | [
"MIT"
] | 2 | 2019-04-20T10:36:18.000Z | 2019-04-20T10:36:33.000Z | EmbeddedSystem/mainwindow.cpp | gzxultra/arm-thermometer-project | b68e92fb7c7e037dbe88f789962e16e27338739c | [
"MIT"
] | null | null | null | EmbeddedSystem/mainwindow.cpp | gzxultra/arm-thermometer-project | b68e92fb7c7e037dbe88f789962e16e27338739c | [
"MIT"
] | null | null | null | #include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->listWidget->hide();
this->InitProperty();
// Q_INIT_RESOURCE(web);
QList<QPushButton *> btn = this->findChildren<QPushButton *>();
foreach (QPushButton * b, btn) {
connect(b, SIGNAL(clicked()), this, SLOT(btn_clicked()));
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::placeSuggest()
{
qDebug() << "placeSuggest is called.";
myManager.setMethod("placeSuggest");
myManager.setTextBrowser(ui->textBrowser);
myManager.setLineEdit(ui->lineEdit);
myManager.setListWidget(ui->listWidget);
QString input = ui->lineEdit->text();
QString region = QByteArray("全国").toPercentEncoding();
QByteArray originRequest = "http://api.map.baidu.com/place/v2/suggestion?";
originRequest.append("query=");
originRequest.append(input);
originRequest.append("®ion=");
originRequest.append(region);
originRequest.append("&output=xml&ak=PAWBPVqwwomy8UBoeeUm9dfo");
myManager.setUrl(QUrl(originRequest));
myManager.placeSuggest();
}
void MainWindow::pushMessage()
{
myManager.setMainWindow(this);
QString telephoneNumber = ui->telephoneInput->text();
if (telephoneNumber.length() != 11)
{
QMessageBox::about(this,tr("提示信息"),tr("您输入的手机号有误!"));
return;
}
qDebug() << "pushMessage is called.";
myManager.setMethod(QString("pushMessage"));
myManager.setTextBrowser(ui->textBrowser);
myManager.setUrl(QUrl("https://api.submail.cn/message/xsend.json"));
QByteArray postConstruction = "appid=10586&to=";
postConstruction.append(telephoneNumber);
postConstruction.append("&project=d7skN4&signature=8202eb5e44a5519cd0b989a696a60cec");
postConstruction.append("&vars={\"code\":\"");
myDebug();
postConstruction.append(this->suggestions);
postConstruction.append("Currently, I am still working on it. ");
postConstruction.append(QDateTime::currentDateTime().toString());
postConstruction.append("\"}");
myManager.setPostData(postConstruction);
myManager.pushMessage();
ui->telephoneInput->clear();
}
void MainWindow::showSelectedItem()
{
ui->lineEdit->clear();
// QObject::disconnect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(placeSuggest()));
QListWidgetItem *item = ui->listWidget->currentItem();
qDebug() << item;
if(item != 0x0)
ui->lineEdit->setText(ui->listWidget->currentItem()->text());
else
qDebug() << "small glinches";
qDebug() << "set text successfully.";
}
void MainWindow::showHtml()
{
ui->webView->setZoomFactor(1.0);
writeHtml();
qDebug() << "show Html.";
QString currentPath = QDir::currentPath();
currentPath = "file:///" + currentPath + "/map.html";
qDebug() << "html path: " << currentPath;
ui->webView->load(QUrl(currentPath));
//ui->webView->load(QUrl("file://qrc:/data/map.html"));
}
void MainWindow::writeHtml()
{
QString currentPath = QDir::currentPath();
currentPath = currentPath + "/map.html";
qDebug() << "file path: " << currentPath;
//QFile file("qrc:/data/map.html");
QFile file(currentPath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text))
{
std::cerr << "Open failed.\n";
return;
}
QString html;
QTextStream txt(&file);
for (int i = 0; i <=48; ++i){
html.append(txt.readLine());
html.append("\n");
}
QString destination = ui->lineEdit->text();
html.append("transit.search(\"北京工业大学\", \"");
html.append(destination);
html.append("\");\n</script>");
txt.seek(0);
txt << html;
file.close();
}
void MainWindow::btn_clicked()
{
QPushButton *btn = (QPushButton *)sender();
QString objectName = btn->objectName();
QString value = btn->text();
if (objectName == "btnDelete")
{
ui->lineEdit->setText(ui->lineEdit->text().left(ui->lineEdit->text().length() - 1));
}else if (objectName == "btnSpace")
{
ui->lineEdit->setText(ui->lineEdit->text() + " ");
}
else if (btn->property("btnLetter").toBool())
{
ui->lineEdit->setText(ui->lineEdit->text() + value);
}
else if (objectName == "btnReturn")
{
showHtml();
}
}
void MainWindow::myDebug()
{
qDebug() << "get suggestions.";
QString buff = ui->webView->page()->mainFrame()->toPlainText();
buff = buff.replace("©", "");
buff = buff.replace("&", "");
buff = buff.replace("\n", " ");
suggestions = buff.trimmed();
qDebug() << suggestions;
}
void MainWindow::InitProperty()
{
ui->btna->setProperty("btnLetter", true);
ui->btnb->setProperty("btnLetter", true);
ui->btnc->setProperty("btnLetter", true);
ui->btnd->setProperty("btnLetter", true);
ui->btne->setProperty("btnLetter", true);
ui->btnf->setProperty("btnLetter", true);
ui->btng->setProperty("btnLetter", true);
ui->btnh->setProperty("btnLetter", true);
ui->btni->setProperty("btnLetter", true);
ui->btnj->setProperty("btnLetter", true);
ui->btnk->setProperty("btnLetter", true);
ui->btnl->setProperty("btnLetter", true);
ui->btnm->setProperty("btnLetter", true);
ui->btnn->setProperty("btnLetter", true);
ui->btno->setProperty("btnLetter", true);
ui->btnp->setProperty("btnLetter", true);
ui->btnq->setProperty("btnLetter", true);
ui->btnr->setProperty("btnLetter", true);
ui->btns->setProperty("btnLetter", true);
ui->btnt->setProperty("btnLetter", true);
ui->btnu->setProperty("btnLetter", true);
ui->btnv->setProperty("btnLetter", true);
ui->btnw->setProperty("btnLetter", true);
ui->btnx->setProperty("btnLetter", true);
ui->btny->setProperty("btnLetter", true);
ui->btnz->setProperty("btnLetter", true);
ui->btnDelete->setProperty("btnCommand", true);
ui->btnReturn->setProperty("btnCommand", true);
ui->btnSpace->setProperty("btnCommand", true);
ui->btnFn->setProperty("btnCommand", true);
ui->messageButton->setProperty("btnAction", true);
}
| 29.009346 | 99 | 0.63692 | gzxultra |
2e3d3eb90cab6e5c05ff567d18ad57bf38683e5b | 25,389 | cpp | C++ | sdktools/verifier/sdrvpage.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | sdktools/verifier/sdrvpage.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | sdktools/verifier/sdrvpage.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //
// Driver Verifier UI
// Copyright (c) Microsoft Corporation, 1999
//
//
//
// module: SDrvPage.cpp
// author: DMihai
// created: 11/1/00
//
// Description:
//
#include "stdafx.h"
#include <Cderr.h>
#include "verifier.h"
#include "SDrvPage.h"
#include "VrfUtil.h"
#include "VGlobal.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Help IDs
//
static DWORD MyHelpIds[] =
{
IDC_SELDRV_LIST, IDH_DV_SelectDriversToVerify,
IDC_SELDRV_ADD_BUTTON, IDH_DV_Addbut_UnloadedDrivers,
0, 0
};
/////////////////////////////////////////////////////////////////////////////
// CSelectDriversPage property page
IMPLEMENT_DYNCREATE(CSelectDriversPage, CVerifierPropertyPage)
CSelectDriversPage::CSelectDriversPage()
: CVerifierPropertyPage(CSelectDriversPage::IDD)
{
//{{AFX_DATA_INIT(CSelectDriversPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParentSheet = NULL;
m_nSortColumnIndex = 1;
m_bAscendSortVerified = FALSE;
m_bAscendSortDrvName = FALSE;
m_bAscendSortProvName = FALSE;
m_bAscendSortVersion = FALSE;
}
CSelectDriversPage::~CSelectDriversPage()
{
}
void CSelectDriversPage::DoDataExchange(CDataExchange* pDX)
{
CVerifierPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectDriversPage)
DDX_Control(pDX, IDC_SELDRV_NEXT_DESCR_STATIC, m_NextDescription);
DDX_Control(pDX, IDC_SELDRV_LIST, m_DriversList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSelectDriversPage, CVerifierPropertyPage)
//{{AFX_MSG_MAP(CSelectDriversPage)
ON_BN_CLICKED(IDC_SELDRV_ADD_BUTTON, OnAddButton)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_SELDRV_LIST, OnColumnclickSeldrvList)
ON_WM_CONTEXTMENU()
ON_MESSAGE( WM_HELP, OnHelp )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
VOID CSelectDriversPage::SetupListHeader()
{
CString strTitle;
CRect rectWnd;
LVCOLUMN lvColumn;
//
// The list's rectangle
//
m_DriversList.GetClientRect( &rectWnd );
ZeroMemory( &lvColumn,
sizeof( lvColumn ) );
lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
lvColumn.fmt = LVCFMT_LEFT;
//
// Column 0
//
VERIFY( strTitle.LoadString( IDS_VERIFICATION_STATUS ) );
lvColumn.iSubItem = 0;
lvColumn.cx = (int)( rectWnd.Width() * 0.08 );
lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
if (NULL != lvColumn.pszText)
{
VERIFY( m_DriversList.InsertColumn( 0, &lvColumn ) != -1 );
strTitle.ReleaseBuffer();
}
else
{
lvColumn.pszText = g_szVoidText;
VERIFY( m_DriversList.InsertColumn( 0, &lvColumn ) != -1 );
}
//
// Column 1
//
VERIFY( strTitle.LoadString( IDS_DRIVERS ) );
lvColumn.iSubItem = 1;
lvColumn.cx = (int)( rectWnd.Width() * 0.20 );
lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
if (NULL != lvColumn.pszText)
{
VERIFY( m_DriversList.InsertColumn( 1, &lvColumn ) != -1 );
strTitle.ReleaseBuffer();
}
else
{
lvColumn.pszText = g_szVoidText;
VERIFY( m_DriversList.InsertColumn( 1, &lvColumn ) != -1 );
}
//
// Column 2
//
VERIFY( strTitle.LoadString( IDS_PROVIDER ) );
lvColumn.iSubItem = 2;
lvColumn.cx = (int)( rectWnd.Width() * 0.47 );
lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
if (NULL != lvColumn.pszText)
{
VERIFY( m_DriversList.InsertColumn( 2, &lvColumn ) != -1 );
strTitle.ReleaseBuffer();
}
else
{
lvColumn.pszText = g_szVoidText;
VERIFY( m_DriversList.InsertColumn( 2, &lvColumn ) != -1 );
}
//
// Column 3
//
VERIFY( strTitle.LoadString( IDS_VERSION ) );
lvColumn.iSubItem = 3;
lvColumn.cx = (int)( rectWnd.Width() * 0.22 );
lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
if (NULL != lvColumn.pszText)
{
VERIFY( m_DriversList.InsertColumn( 3, &lvColumn ) != -1 );
strTitle.ReleaseBuffer();
}
else
{
VERIFY( m_DriversList.InsertColumn( 3, &lvColumn ) != -1 );
lvColumn.pszText = g_szVoidText;
}
}
/////////////////////////////////////////////////////////////////////////////
VOID CSelectDriversPage::FillTheList()
{
INT_PTR nDriversNo;
INT_PTR nCrtDriverIndex;
CDriverData *pCrtDrvData;
const CDriverDataArray &DrvDataArray = g_NewVerifierSettings.m_DriversSet.m_aDriverData;
m_DriversList.DeleteAllItems();
//
// Parse the driver data array
//
nDriversNo = DrvDataArray.GetSize();
for( nCrtDriverIndex = 0; nCrtDriverIndex < nDriversNo; nCrtDriverIndex += 1)
{
pCrtDrvData = DrvDataArray.GetAt( nCrtDriverIndex );
ASSERT_VALID( pCrtDrvData );
AddListItem( nCrtDriverIndex,
pCrtDrvData );
}
}
/////////////////////////////////////////////////////////////////////////////
INT CSelectDriversPage::AddListItem( INT_PTR nIndexInArray, CDriverData *pCrtDrvData )
{
INT nActualIndex;
LVITEM lvItem;
ASSERT_VALID( pCrtDrvData );
nActualIndex = -1;
ZeroMemory( &lvItem, sizeof( lvItem ) );
//
// LVITEM's member pszText is not a const pointer
// so we need to GetBuffer here :-(
//
//
// Sub-item 0 - verification status - empty text and a checkbox
//
lvItem.pszText = g_szVoidText;
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.lParam = nIndexInArray;
lvItem.iItem = m_DriversList.GetItemCount();
nActualIndex = m_DriversList.InsertItem( &lvItem );
if( nActualIndex < 0 )
{
//
// Could not add an item in the list - give up
//
goto Done;
}
m_DriversList.SetCheck( nActualIndex, FALSE );
//
// Sub-item 1 - driver name
//
lvItem.pszText = pCrtDrvData->m_strName.GetBuffer( pCrtDrvData->m_strName.GetLength() + 1 );
if( NULL == lvItem.pszText )
{
goto Done;
}
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nActualIndex;
lvItem.iSubItem = 1;
VERIFY( m_DriversList.SetItem( &lvItem ) );
pCrtDrvData->m_strName.ReleaseBuffer();
//
// Sub-item 2 - provider
//
lvItem.pszText = pCrtDrvData->m_strCompanyName.GetBuffer(
pCrtDrvData->m_strCompanyName.GetLength() + 1 );
if( NULL == lvItem.pszText )
{
goto Done;
}
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nActualIndex;
lvItem.iSubItem = 2;
VERIFY( m_DriversList.SetItem( &lvItem ) );
pCrtDrvData->m_strCompanyName.ReleaseBuffer();
//
// Sub-item 3 - version
//
lvItem.pszText = pCrtDrvData->m_strFileVersion.GetBuffer(
pCrtDrvData->m_strFileVersion.GetLength() + 1 );
if( NULL == lvItem.pszText )
{
goto Done;
}
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nActualIndex;
lvItem.iSubItem = 3;
VERIFY( m_DriversList.SetItem( &lvItem ) );
pCrtDrvData->m_strFileVersion.ReleaseBuffer();
Done:
//
// All done
//
return nActualIndex;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CSelectDriversPage::GetNewVerifiedDriversList()
{
INT nListItemCount;
INT nCrtListItem;
INT_PTR nCrtDriversArrayIndex;
BOOL bVerified;
CDriverData *pCrtDrvData;
const CDriverDataArray &DrvDataArray = g_NewVerifierSettings.m_DriversSet.m_aDriverData;
CDriverData::VerifyDriverTypeEnum VerifyStatus;
nListItemCount = m_DriversList.GetItemCount();
for( nCrtListItem = 0; nCrtListItem < nListItemCount; nCrtListItem += 1 )
{
//
// Verification status for the current list item
//
bVerified = m_DriversList.GetCheck( nCrtListItem );
if( bVerified )
{
VerifyStatus = CDriverData::VerifyDriverYes;
}
else
{
VerifyStatus = CDriverData::VerifyDriverNo;
}
//
// Set the right verify state in our driver array
//
nCrtDriversArrayIndex = m_DriversList.GetItemData( nCrtListItem );
pCrtDrvData = DrvDataArray.GetAt( nCrtDriversArrayIndex );
ASSERT_VALID( pCrtDrvData );
pCrtDrvData->m_VerifyDriverStatus = VerifyStatus;
}
return TRUE;
}
/////////////////////////////////////////////////////////////
VOID CSelectDriversPage::SortTheList()
{
if( 0 != m_nSortColumnIndex )
{
//
// Sort by driver name, provider or version
//
m_DriversList.SortItems( StringCmpFunc, (LPARAM)this );
}
else
{
//
// Sort by verified status
//
m_DriversList.SortItems( CheckedStatusCmpFunc, (LPARAM)this );
}
}
/////////////////////////////////////////////////////////////
int CALLBACK CSelectDriversPage::StringCmpFunc( LPARAM lParam1,
LPARAM lParam2,
LPARAM lParamSort)
{
int nCmpRez = 0;
BOOL bSuccess;
CString strName1;
CString strName2;
CSelectDriversPage *pThis = (CSelectDriversPage *)lParamSort;
ASSERT_VALID( pThis );
ASSERT( 0 != pThis->m_nSortColumnIndex );
//
// Get the first name
//
bSuccess = pThis->GetColumnStrValue( lParam1,
strName1 );
if( FALSE == bSuccess )
{
goto Done;
}
//
// Get the second name
//
bSuccess = pThis->GetColumnStrValue( lParam2,
strName2 );
if( FALSE == bSuccess )
{
goto Done;
}
//
// Compare the names
//
nCmpRez = strName1.CompareNoCase( strName2 );
switch( pThis->m_nSortColumnIndex )
{
case 1:
//
// Sort by driver name
//
if( FALSE != pThis->m_bAscendSortDrvName )
{
nCmpRez *= -1;
}
break;
case 2:
//
// Sort by provider name
//
if( FALSE != pThis->m_bAscendSortProvName )
{
nCmpRez *= -1;
}
break;
case 3:
//
// Sort by version
//
if( FALSE != pThis->m_bAscendSortVersion )
{
nCmpRez *= -1;
}
break;
default:
//
// Oops - how did we get here ?!?
//
ASSERT( FALSE );
break;
}
Done:
return nCmpRez;
}
/////////////////////////////////////////////////////////////
int CALLBACK CSelectDriversPage::CheckedStatusCmpFunc( LPARAM lParam1,
LPARAM lParam2,
LPARAM lParamSort)
{
int nCmpRez = 0;
INT nItemIndex;
BOOL bVerified1;
BOOL bVerified2;
LVFINDINFO FindInfo;
CSelectDriversPage *pThis = (CSelectDriversPage *)lParamSort;
ASSERT_VALID( pThis );
ASSERT( 0 == pThis->m_nSortColumnIndex );
//
// Find the first item
//
ZeroMemory( &FindInfo, sizeof( FindInfo ) );
FindInfo.flags = LVFI_PARAM;
FindInfo.lParam = lParam1;
nItemIndex = pThis->m_DriversList.FindItem( &FindInfo );
if( nItemIndex < 0 )
{
ASSERT( FALSE );
goto Done;
}
bVerified1 = pThis->m_DriversList.GetCheck( nItemIndex );
//
// Find the second item
//
FindInfo.flags = LVFI_PARAM;
FindInfo.lParam = lParam2;
nItemIndex = pThis->m_DriversList.FindItem( &FindInfo );
if( nItemIndex < 0 )
{
ASSERT( FALSE );
goto Done;
}
bVerified2 = pThis->m_DriversList.GetCheck( nItemIndex );
//
// Compare them
//
if( bVerified1 != bVerified2 )
{
if( FALSE != bVerified1 )
{
nCmpRez = 1;
}
else
{
nCmpRez = -1;
}
if( FALSE != pThis->m_bAscendSortVerified )
{
nCmpRez *= -1;
}
}
Done:
return nCmpRez;
}
/////////////////////////////////////////////////////////////
BOOL CSelectDriversPage::GetColumnStrValue( LPARAM lItemData,
CString &strName )
{
CDriverData *pCrtDrvData;
pCrtDrvData = g_NewVerifierSettings.m_DriversSet.m_aDriverData.GetAt( (INT_PTR) lItemData );
ASSERT_VALID( pCrtDrvData );
switch( m_nSortColumnIndex )
{
case 1:
//
// Sort by driver name
//
strName = pCrtDrvData->m_strName;
break;
case 2:
//
// Sort by provider name
//
strName = pCrtDrvData->m_strCompanyName;
break;
case 3:
//
// Sort by version
//
strName = pCrtDrvData->m_strFileVersion;
break;
default:
//
// Oops - how did we get here ?!?
//
ASSERT( FALSE );
break;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CSelectDriversPage::OnSetActive()
{
//
// The wizard has at least one more step (display the summarry)
//
if( (FALSE == g_bShowDiskPropertyPage) &&
(FALSE == g_NewVerifierSettings.m_aDiskData.VerifyAnyDisk()) )
{
//
// Disk verifier is disabled.
//
m_pParentSheet->SetWizardButtons( PSWIZB_BACK |
PSWIZB_FINISH );
VrfSetWindowText( m_NextDescription, IDS_SELDRV_PAGE_NEXT_DESCR_FINISH );
}
else
{
//
// Disk verifier is enabled.
//
m_pParentSheet->SetWizardButtons( PSWIZB_BACK |
PSWIZB_NEXT );
VrfSetWindowText( m_NextDescription, IDS_SELDRV_PAGE_NEXT_DESCR_NEXT );
}
return CVerifierPropertyPage::OnSetActive();
}
/////////////////////////////////////////////////////////////////////////////
// CSelectDriversPage message handlers
BOOL CSelectDriversPage::OnInitDialog()
{
CVerifierPropertyPage::OnInitDialog();
//
// setup the list
//
m_DriversList.SetExtendedStyle(
LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | m_DriversList.GetExtendedStyle() );
SetupListHeader();
FillTheList();
SortTheList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/////////////////////////////////////////////////////////////////////////////
BOOL CSelectDriversPage::OnWizardFinish()
{
BOOL bExitTheApp;
bExitTheApp = FALSE;
if( GetNewVerifiedDriversList() )
{
if( FALSE == g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers() )
{
VrfErrorResourceFormat( IDS_SELECT_AT_LEAST_ONE_DRIVER );
goto Done;
}
g_NewVerifierSettings.SaveToRegistry();
//
// Exit the app
//
bExitTheApp = CVerifierPropertyPage::OnWizardFinish();
}
Done:
return bExitTheApp;
}
/////////////////////////////////////////////////////////////////////////////
LRESULT CSelectDriversPage::OnWizardNext()
{
LRESULT lNextPageId;
lNextPageId = -1;
//
// We can get here only if the disk integrity checking is enabled.
//
ASSERT( FALSE != g_bShowDiskPropertyPage ||
FALSE != g_NewVerifierSettings.m_aDiskData.VerifyAnyDisk() );
if( GetNewVerifiedDriversList() )
{
if( FALSE == g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers() )
{
VrfErrorResourceFormat( IDS_SELECT_AT_LEAST_ONE_DRIVER );
goto Done;
}
lNextPageId = IDD_DISK_LIST_PAGE;
GoingToNextPageNotify( lNextPageId );
}
Done:
return lNextPageId;
}
/////////////////////////////////////////////////////////////////////////////
#define VRF_MAX_CHARS_FOR_OPEN 4096
void CSelectDriversPage::OnAddButton()
{
POSITION pos;
DWORD dwRetValue;
DWORD dwOldMaxFileName = 0;
DWORD dwErrorCode;
INT nFileNameStartIndex;
INT nNewListItemIndex;
INT_PTR nResult;
INT_PTR nNewDriverDataIndex;
CDriverData *pNewDrvData;
TCHAR szDriversDir[ _MAX_PATH ];
TCHAR szAppTitle[ _MAX_PATH ];
TCHAR *szFilesBuffer = NULL;
TCHAR *szOldFilesBuffer = NULL;
CString strPathName;
CString strFileName;
CFileDialog fileDlg(
TRUE, // open file
_T( "sys" ), // default extension
NULL, // no initial file name
OFN_ALLOWMULTISELECT | // multiple selection
OFN_HIDEREADONLY | // hide the "open read-only" checkbox
OFN_NONETWORKBUTTON | // no network button
OFN_NOTESTFILECREATE | // don't test for write protection, a full disk, etc.
OFN_SHAREAWARE, // don't check the existance of file with OpenFile
_T( "Drivers (*.sys)|*.sys||" ) ); // only one filter
//
// check the max length for the returned string
//
if( fileDlg.m_ofn.nMaxFile < VRF_MAX_CHARS_FOR_OPEN )
{
//
// allocate a new buffer for the file names
//
szFilesBuffer = new TCHAR[ VRF_MAX_CHARS_FOR_OPEN ];
if (NULL == szFilesBuffer)
{
VrfErrorResourceFormat( IDS_NOT_ENOUGH_MEMORY );
goto Done;
}
szFilesBuffer[ 0 ] = (TCHAR)0;
if( szFilesBuffer != NULL )
{
//
// Save the old buffer address and length
//
dwOldMaxFileName = fileDlg.m_ofn.nMaxFile;
szOldFilesBuffer = fileDlg.m_ofn.lpstrFile;
//
// Set the new buffer address and length
//
fileDlg.m_ofn.lpstrFile = szFilesBuffer;
fileDlg.m_ofn.nMaxFile = VRF_MAX_CHARS_FOR_OPEN;
}
}
//
// Dialog title
//
if( VrfLoadString(
IDS_APPTITLE,
szAppTitle,
ARRAY_LENGTH( szAppTitle ) ) )
{
fileDlg.m_ofn.lpstrTitle = szAppTitle;
}
//
// We change directory first time we try this to %windir%\system32\drivers
//
dwRetValue = ExpandEnvironmentStrings(
_T( "%windir%\\system32\\drivers" ),
szDriversDir,
ARRAY_LENGTH( szDriversDir ) );
if( dwRetValue > 0 && dwRetValue <= ARRAY_LENGTH( szDriversDir ) )
{
fileDlg.m_ofn.lpstrInitialDir = szDriversDir;
}
//
// Show the file selection dialog
//
nResult = fileDlg.DoModal();
switch( nResult )
{
case IDOK:
break;
case IDCANCEL:
goto cleanup;
default:
dwErrorCode = CommDlgExtendedError();
if( dwErrorCode == FNERR_BUFFERTOOSMALL )
{
VrfErrorResourceFormat(
IDS_TOO_MANY_FILES_SELECTED );
}
else
{
VrfErrorResourceFormat(
IDS_CANNOT_OPEN_FILES,
dwErrorCode );
}
goto cleanup;
}
//
// Parse all the selected files and try to enable them for verification
//
pos = fileDlg.GetStartPosition();
while( pos != NULL )
{
//
// Get the full path for the next file
//
strPathName = fileDlg.GetNextPathName( pos );
//
// Split only the file name, without the directory
//
nFileNameStartIndex = strPathName.ReverseFind( _T( '\\' ) );
if( nFileNameStartIndex < 0 )
{
//
// This shoudn't happen but you never know :-)
//
nFileNameStartIndex = 0;
}
else
{
//
// skip the backslash
//
nFileNameStartIndex += 1;
}
strFileName = strPathName.Right( strPathName.GetLength() - nFileNameStartIndex );
//
// Try to add this driver to our global driver list
//
if( g_NewVerifierSettings.m_DriversSet.IsDriverNameInList( strFileName ) )
{
VrfErrorResourceFormat( IDS_DRIVER_IS_ALREADY_IN_LIST,
(LPCTSTR) strFileName );
}
else
{
nNewDriverDataIndex = g_NewVerifierSettings.m_DriversSet.AddNewDriverData( strFileName );
if( nNewDriverDataIndex >= 0 )
{
//
// Force refreshing the unsigned driver data
//
g_NewVerifierSettings.m_DriversSet.m_bUnsignedDriverDataInitialized = FALSE;
//
// Add a new item to our list, for the new driver
//
pNewDrvData = g_NewVerifierSettings.m_DriversSet.m_aDriverData.GetAt( nNewDriverDataIndex );
ASSERT_VALID( pNewDrvData );
nNewListItemIndex = AddListItem( nNewDriverDataIndex,
pNewDrvData );
if( nNewListItemIndex >= 0 )
{
m_DriversList.EnsureVisible( nNewListItemIndex, TRUE );
}
}
}
}
cleanup:
if( szFilesBuffer != NULL )
{
fileDlg.m_ofn.nMaxFile = dwOldMaxFileName;
fileDlg.m_ofn.lpstrFile = szOldFilesBuffer;
delete [] szFilesBuffer;
}
Done:
NOTHING;
}
/////////////////////////////////////////////////////////////////////////////
void CSelectDriversPage::OnColumnclickSeldrvList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
switch( pNMListView->iSubItem )
{
case 0:
//
// Clicked on the "verified" column
//
if( m_nSortColumnIndex == pNMListView->iSubItem )
{
//
// Change the current ascend/descend order for this column
//
m_bAscendSortVerified = !m_bAscendSortVerified;
}
break;
case 1:
//
// Clicked on the driver name column
//
if( m_nSortColumnIndex == pNMListView->iSubItem )
{
//
// Change the current ascend/descend order for this column
//
m_bAscendSortDrvName = !m_bAscendSortDrvName;
}
break;
case 2:
//
// Clicked on the provider column
//
if( m_nSortColumnIndex == pNMListView->iSubItem )
{
//
// Change the current ascend/descend order for this column
//
m_bAscendSortProvName = !m_bAscendSortProvName;
}
break;
case 3:
//
// Clicked on the version column
//
if( m_nSortColumnIndex == pNMListView->iSubItem )
{
//
// Change the current ascend/descend order for this column
//
m_bAscendSortVersion = !m_bAscendSortVersion;
}
break;
default:
//
// Oops - how did we get here ?!?
//
ASSERT( FALSE );
goto Done;
}
m_nSortColumnIndex = pNMListView->iSubItem;
SortTheList();
Done:
*pResult = 0;
}
/////////////////////////////////////////////////////////////
LONG CSelectDriversPage::OnHelp( WPARAM wParam, LPARAM lParam )
{
LONG lResult = 0;
LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
::WinHelp(
(HWND) lpHelpInfo->hItemHandle,
g_szVerifierHelpFile,
HELP_WM_HELP,
(DWORD_PTR) MyHelpIds );
return lResult;
}
/////////////////////////////////////////////////////////////////////////////
void CSelectDriversPage::OnContextMenu(CWnd* pWnd, CPoint point)
{
::WinHelp(
pWnd->m_hWnd,
g_szVerifierHelpFile,
HELP_CONTEXTMENU,
(DWORD_PTR) MyHelpIds );
}
| 23.705882 | 109 | 0.51798 | npocmaka |
2e3e8506e2bac1efc615f97ab58e5a748a686773 | 305 | cpp | C++ | basics/Q2.cpp | shubhraagarwal/GUVI-codeKata | d8bf2354516dc27dd14d248cf0c702d652423e39 | [
"MIT"
] | null | null | null | basics/Q2.cpp | shubhraagarwal/GUVI-codeKata | d8bf2354516dc27dd14d248cf0c702d652423e39 | [
"MIT"
] | null | null | null | basics/Q2.cpp | shubhraagarwal/GUVI-codeKata | d8bf2354516dc27dd14d248cf0c702d652423e39 | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std ;
int main(){
bool isComp = false ;
int n ;
cin>> n;
for(int i = 2 ; i < n ; i++){
if(n % i == 0){
isComp = true ;
cout<<"yes";
break;
}
}
if(isComp == false){
cout<<"no";
}
} | 16.052632 | 33 | 0.390164 | shubhraagarwal |
2e4235f582d4396a492b5d036fb7d17dd7293fa7 | 3,722 | cpp | C++ | Game Engine 2D/Player.cpp | LaPeste/ComposeEngine | 8ae80ec7c49af896978d06371dee96a4d2315372 | [
"Apache-2.0"
] | 1 | 2017-03-13T11:19:40.000Z | 2017-03-13T11:19:40.000Z | Game Engine 2D/Player.cpp | LaPeste/ComposeEngine | 8ae80ec7c49af896978d06371dee96a4d2315372 | [
"Apache-2.0"
] | null | null | null | Game Engine 2D/Player.cpp | LaPeste/ComposeEngine | 8ae80ec7c49af896978d06371dee96a4d2315372 | [
"Apache-2.0"
] | null | null | null | //
// Player.cpp
// GameEngine2D
//
// Created by Andrea Catalini on 23/07/16.
// Copyright © 2016 Andrea Catalini. All rights reserved.
//
#include "Player.hpp"
#include "EntityManager.hpp"
//Components
#include "Appearance.hpp"
#include "Acceleration.hpp"
#include "Animation.hpp"
#include "Controller.hpp"
#include "EntityFlag.hpp"
#include "Velocity.hpp"
#include "Collider.hpp"
#include "Transform.hpp"
//Events
#include "InputEvent.hpp"
#include "Animations.hpp"
void Player::Init()
{
World& world = GetWorld();
const unsigned long int entityIndex = GetEntityIndex();
std::string playerSpritePath = Constants::RESOURCE_PATH + Constants::PLAYER_SPRITE_PATH;
sf::IntRect spriteRect(498, 12, Constants::PLAYER_WIDTH, Constants::PLAYER_HEIGHT);
EntityManager::AddComponent(world, entityIndex, new Appearance(world, entityIndex, playerSpritePath, spriteRect));
EntityManager::AddComponent(world, entityIndex, new Transform(world, entityIndex));
//(static_cast<Transform*>(world.EntitiesComponentsMatrix[entityIndex][Transform::Id]))->SetPosition(sf::Vector2f(Constants::PLAYER_PHYSICAL_STARTING_X, Constants::PLAYER_PHYSICAL_STARTING_Y));
GetComponent<Transform>()->SetPosition(sf::Vector2f(Constants::PLAYER_PHYSICAL_STARTING_X, Constants::PLAYER_PHYSICAL_STARTING_Y));
EntityManager::AddComponent(world, entityIndex, new Acceleration(world, entityIndex, Constants::PLAYER_MAX_ACCELERATION_X, Constants::PLAYER_MAX_ACCELERATION_Y));
Controller* controllerComp = new Controller(world, entityIndex);
EntityManager::AddComponent(world, entityIndex, controllerComp);
EntityManager::AddComponent(world, entityIndex, new Velocity(world, entityIndex));
EntityManager::AddComponent(world, entityIndex, new Collider(world, entityIndex, sf::Vector2f(0.5f, 0.5f)));
//Animation states - start
const auto* const playerSprite = GetComponent<Appearance>()->GetSprite();
std::map<AnimationState, AnimationData*> animationMap;
AnimationData* walkingAnim = new AnimationData(playerSprite, sf::Vector2f(Constants::PLAYER_SPRITE_STARTING_X, Constants::PLAYER_SPRITE_STARTING_Y),
sf::Vector2f(Constants::SPACE_BETWEEN_SPRITE_X, Constants::SPACE_BETWEEN_SPRITE_Y), false,
false, Constants::PLAYER_WIDTH, Constants::PLAYER_HEIGHT, Constants::PLAYER_SPRITE_MAX_FRAME, Constants::ANIMATION_FRAMERATE);
animationMap.insert( std::pair<AnimationState, AnimationData*>(AnimationState::WALKING, walkingAnim) );
AnimationData* idleAnim = new AnimationData(playerSprite, sf::Vector2f(14, 10),
sf::Vector2f(Constants::SPACE_BETWEEN_SPRITE_X, Constants::SPACE_BETWEEN_SPRITE_Y), false,
false, Constants::PLAYER_WIDTH, Constants::PLAYER_HEIGHT, 1, Constants::ANIMATION_FRAMERATE);
animationMap.insert(std::pair<AnimationState, AnimationData*>(AnimationState::IDLE, idleAnim));
AnimationData* jumpAnim = new AnimationData(playerSprite, sf::Vector2f(115, 7),
sf::Vector2f(Constants::SPACE_BETWEEN_SPRITE_X, Constants::SPACE_BETWEEN_SPRITE_Y), false,
false, 16, Constants::PLAYER_HEIGHT, 1, Constants::ANIMATION_FRAMERATE);
animationMap.insert(std::pair<AnimationState, AnimationData*>(AnimationState::JUMPING, jumpAnim));
//Animation states - end
Animation* animationComp = new Animation(world, entityIndex, AnimationState::IDLE, animationMap, true);
EntityManager::AddComponent(world, entityIndex, animationComp);
OnGameEvent<InputEvent>([&world, entityIndex](Event<InputEvent>* i) {
if (i != nullptr)
{
auto* castedEvent = static_cast<InputEvent*>(i);
Animations::BasicInputAnimation(world, entityIndex, *castedEvent);
}
else
{
DEBUG_WARNING("The event passed was null!");
}
});
} | 44.309524 | 197 | 0.764911 | LaPeste |
2e43e3909fb8a28c0174bd04f6f4106674e5bad2 | 6,284 | cpp | C++ | samplecode/CodeSnippets/SnpObjectActionHelper.cpp | shivendra14/AI_CC_2017_SDK_Win | e921f93bef0d73aa809bcda1bd6bbe2c0a4d28b2 | [
"X11"
] | null | null | null | samplecode/CodeSnippets/SnpObjectActionHelper.cpp | shivendra14/AI_CC_2017_SDK_Win | e921f93bef0d73aa809bcda1bd6bbe2c0a4d28b2 | [
"X11"
] | null | null | null | samplecode/CodeSnippets/SnpObjectActionHelper.cpp | shivendra14/AI_CC_2017_SDK_Win | e921f93bef0d73aa809bcda1bd6bbe2c0a4d28b2 | [
"X11"
] | null | null | null | //========================================================================================
//
// $File: //ai_stream/rel_21_0/devtech/sdk/public/samplecode/CodeSnippets/SnpObjectActionHelper.cpp $
//
// $Revision: #1 $
//
// Copyright 1987 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
#include "IllustratorSDK.h"
#include "AIObjectAction.h"
#include "SDKErrors.h"
// Framework includes:
#include "SnpRunnable.h"
#include "SnippetRunnerSuites.h"
#include "SnippetRunnerLog.h"
#include "SnippetRunnerParameter.h"
#include "SnpObjectActionHelper.h"
#include "SnpSelectionHelper.h"
/*
*/
SnpObjectActionHelper::VPB::VPB() : fActionParamValueRef(NULL)
{
ASErr result = kNoErr;
try {
SDK_ASSERT(sAIActionManager);
result = sAIActionManager->AINewActionParamValue(&fActionParamValueRef);
SDK_ASSERT(!result);
SDK_ASSERT(fActionParamValueRef);
}
catch (ai::Error) {
}
}
/*
*/
SnpObjectActionHelper::VPB::~VPB()
{
ASErr result = kNoErr;
try {
SDK_ASSERT(sAIActionManager);
result = sAIActionManager->AIDeleteActionParamValue(fActionParamValueRef);
SDK_ASSERT(!result);
fActionParamValueRef = NULL;
}
catch (ai::Error) {
}
}
/*
*/
ASErr SnpObjectActionHelper::CopySelection()
{
ASErr result = kNoErr;
try {
SnpObjectActionHelper::VPB vpb;
result = this->CopySelection(kDialogOff, vpb);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}
return result;
}
/*
*/
ASErr SnpObjectActionHelper::CopySelection(ActionDialogStatus dialogStatus, AIActionParamValueRef parameters)
{
ASErr result = kNoErr;
try {
SDK_ASSERT(sAIActionManager);
result = sAIActionManager->PlayActionEvent(kAICopySelectionAction, dialogStatus, parameters);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}
return result;
}
/*
*/
ASErr SnpObjectActionHelper::PasteClipboard()
{
ASErr result = kNoErr;
try {
SnpObjectActionHelper::VPB vpb;
result = this->PasteClipboard(kDialogOff, vpb);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}
return result;
}
/*
*/
ASErr SnpObjectActionHelper::PasteClipboard(ActionDialogStatus dialogStatus, AIActionParamValueRef parameters)
{
ASErr result = kNoErr;
try {
SDK_ASSERT(sAIActionManager);
result = sAIActionManager->PlayActionEvent(kAIPasteClipboardAction, dialogStatus, parameters);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}
return result;
}
// --------------------------------- SnippetRunner framework hook ---------------------------------------------------
/* Makes the snippet SnpObjectActionHelper available to the SnippetRunner framework.
*/
class _SnpRunnableObjectActionHelper : public SnpRunnable
{
public:
/* Constructor registers the snippet with the framework.
*/
_SnpRunnableObjectActionHelper () : SnpRunnable() {}
/* Destructor.
*/
virtual ~_SnpRunnableObjectActionHelper () {}
/* Returns name of snippet.
*/
std::string GetName() const;
/* Returns a description of what the snippet does.
*/
std::string GetDescription() const;
/* Returns operations supported by this snippet.
*/
Operations GetOperations() const;
/* Returns name of this snippet's default operation - must
be one of the operation names returned by GetOperations.
*/
std::string GetDefaultOperationName() const;
/** Returns the categories a snippet belongs to.
@return default categories.
*/
std::vector<std::string> GetCategories() const;
/* Returns true if the snippet can run.
@param runnableContext see ISnpRunnableContext for documentation.
@return true if snippet can run, false otherwise
*/
ASBoolean CanRun(SnpRunnable::Context& runnableContext);
/* Runs the snippet.
@param runnableContext see ISnpRunnableContext for documentation.
@return kNoErr on success, other ASErr otherwise.
*/
ASErr Run(SnpRunnable::Context& runnableContext);
};
/*
*/
std::string _SnpRunnableObjectActionHelper::GetName() const
{
return "ObjectActionHelper";
}
/*
*/
std::string _SnpRunnableObjectActionHelper::GetDescription() const
{
return "Helper class for programming object actions";
}
/*
*/
SnpRunnable::Operations _SnpRunnableObjectActionHelper::GetOperations() const
{
SnpRunnable::Operations operations;
operations.push_back(Operation("CopySelection", "document containing art", kSnpRunPathContext));
operations.push_back(Operation("PasteClipboard", "document", kSnpRunNewDocumentContext));
return operations;
}
/*
*/
std::string _SnpRunnableObjectActionHelper::GetDefaultOperationName() const
{
return "CopySelection";
}
/*
*/
std::vector<std::string> _SnpRunnableObjectActionHelper::GetCategories() const
{
std::vector<std::string> categories = SnpRunnable::GetCategories();
categories.push_back("Helper Snippets");
return categories;
}
/* Checks if preconditions are met.
*/
ASBoolean _SnpRunnableObjectActionHelper::CanRun(SnpRunnable::Context& runnableContext)
{
SnpSelectionHelper selectionHelper;
if (!selectionHelper.IsDocumentSelected())
return false;
if ("CopySelection" == runnableContext.GetOperation().GetName()) {
return selectionHelper.IsArtSelected();
}
else
return true;
}
/* Instantiates and calls your snippet class.
*/
ASErr _SnpRunnableObjectActionHelper::Run(SnpRunnable::Context& runnableContext)
{
ASErr result = kNoErr;
SnpObjectActionHelper instance;
if ("CopySelection" == runnableContext.GetOperation().GetName()) {
result = instance.CopySelection();
}
else if ("PasteClipboard" == runnableContext.GetOperation().GetName()) {
result = instance.PasteClipboard();
}
else {
result = kBadParameterErr;
}
return result;
}
/* Declares an instance to register the snippet hook with the framework.
*/
static _SnpRunnableObjectActionHelper instance_SnpRunnableObjectActionHelper;
// End SnpObjectActionHelper.cpp
| 24.076628 | 117 | 0.713081 | shivendra14 |
2e44698a53fc202d24f7cd59fc7a9cad5f54bf76 | 136,919 | cpp | C++ | start/opencv-3.4.1/build/build_main/modules/highgui/qrc_window_QT.cpp | shengxiaoyi1993/opencv_cpp | 8b9c8f31cd692cc6b1f4945ae0709ea605b15743 | [
"MIT"
] | 2 | 2019-10-08T07:01:36.000Z | 2019-10-08T07:01:38.000Z | start/opencv-3.4.1/build/build_main/modules/highgui/qrc_window_QT.cpp | shengxiaoyi1993/opencv_cpp | 8b9c8f31cd692cc6b1f4945ae0709ea605b15743 | [
"MIT"
] | null | null | null | start/opencv-3.4.1/build/build_main/modules/highgui/qrc_window_QT.cpp | shengxiaoyi1993/opencv_cpp | 8b9c8f31cd692cc6b1f4945ae0709ea605b15743 | [
"MIT"
] | null | null | null | /****************************************************************************
** Resource object code
**
** Created by: The Resource Compiler for Qt version 5.9.7
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
static const unsigned char qt_resource_data[] = {
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/23.png
0x0,0x0,0x6,0xce,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0x6,0x54,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0x5a,0xeb,0x6f,0x14,
0x55,0x14,0xff,0x9d,0xbb,0x5b,0x5a,0x68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0x7f,0xca,0xce,0x70,0x79,0x82,0x26,0xa9,0xeb,0xf9,0x61,0x4c,0x6f,
0xa8,0x83,0x95,0x2f,0xf4,0x6,0x4,0x5c,0x9,0x31,0x58,0x33,0x40,0x80,0x92,0x1c,
0x1,0x1c,0x48,0x89,0x10,0x2d,0xa7,0xfe,0x7,0x45,0xe5,0x15,0x67,0x40,0xe3,0x31,
0x8b,0xaa,0xa9,0x82,0xbc,0xc2,0x9c,0x71,0xc8,0x6,0x9,0x6a,0x8f,0x48,0x88,0x95,
0x4b,0xc2,0xc8,0x53,0x98,0x65,0x9f,0x9,0x20,0xf6,0x6c,0x5f,0x3d,0xfe,0x39,0x23,
0x24,0x68,0x78,0xcf,0x97,0x5c,0xd9,0x9d,0x27,0xaa,0x18,0x96,0x68,0xbe,0x70,0x69,
0xd0,0xb4,0x56,0x90,0xb6,0x1a,0x8c,0x54,0x21,0xad,0x75,0x10,0x1,0xc0,0x3,0x6c,
0x82,0x35,0x6d,0xff,0x7b,0x3,0x8,0xc7,0x53,0x82,0x0,0x66,0x97,0x25,0x4d,0x14,
0x38,0x57,0x68,0x7c,0xc6,0xbc,0x48,0x8,0x14,0x46,0x8a,0xd0,0x9a,0xb7,0x7,0x8b,
0x39,0x37,0x89,0x39,0x94,0x12,0xbb,0x36,0x7b,0xb6,0x4f,0x2e,0x3e,0xf4,0x38,0xe7,
0xe6,0x7c,0xc9,0x7d,0xcb,0xd,0x36,0xae,0x2d,0x33,0x5c,0xf0,0x16,0x8a,0x79,0x27,
0xbd,0xf7,0x8d,0x7f,0x77,0x84,0x12,0x52,0xae,0x84,0x18,0x6c,0x78,0x9d,0xc1,0xa6,
0xb6,0x2b,0x79,0xde,0x3c,0xe7,0x40,0x55,0xa5,0x7a,0xa7,0x32,0x1a,0xc7,0x78,0xd9,
0xce,0x81,0x16,0x45,0x82,0x90,0x1b,0xca,0x43,0xda,0xaa,0x67,0xdf,0x5b,0x97,0x77,
0xc4,0x1a,0x99,0x86,0xd6,0xba,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x41,0xda,0x72,0xd2,0xc0,0xdf,0xaa,0x8,0xf4,0xe4,
0xb3,0x56,0xaf,0x77,0xda,0xfb,0xcb,0x6e,0x79,0x7c,0x32,0xef,0x4f,0x77,0xfe,0xd5,
0xe0,0xe,0x81,0x3b,0x4,0x6e,0xef,0xe3,0x3f,0x66,0xc3,0x66,0xbf,0xfa,0x44,0xa2,
0x82,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/107.png
0x0,0x0,0xb,0xe,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,
0x0,0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6d,0x61,0x67,0x65,0x52,0x65,0x61,0x64,
0x79,0x71,0xc9,0x65,0x3c,0x0,0x0,0xa,0xb0,0x49,0x44,0x41,0x54,0x78,0xda,0xd4,
0x5a,0xb,0x70,0x5c,0x55,0x19,0xfe,0xf6,0xee,0x7b,0x37,0x9b,0xdd,0x24,0xdd,0x24,
0x9b,0x77,0xd2,0x36,0xf4,0x91,0xa4,0xa1,0x45,0x2a,0x3,0x48,0x32,0xb5,0xc,0xe3,
0xc0,0xb4,0xea,0x88,0x54,0x1d,0x69,0x6,0x75,0xa4,0x55,0x60,0x14,0x81,0xd1,0x19,
0xb1,0x2a,0x83,0x8e,0xa3,0xe0,0xc8,0x38,0xc,0xf,0x1b,0x40,0xa6,0x54,0xb0,0x16,
0x41,0xd0,0x5a,0xdb,0x74,0x44,0xb0,0x58,0xa6,0x9,0x7d,0x1,0x69,0x92,0x6d,0xb2,
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3.4.1/modules/highgui/src/files_Qt/Milky/48/28.png
0x0,0x0,0x6,0xb6,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0x6,0x3c,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0x59,0x5d,0x6c,0x14,
0x45,0x1c,0x9f,0xd9,0xbb,0xf6,0x7a,0x6d,0xa1,0xd7,0xa2,0x28,0x5,0x6c,0xb5,0x2d,
0x2a,0x2f,0x2d,0x14,0x83,0x3e,0x18,0x2e,0x3e,0x18,0xd1,0x7,0xd0,0x68,0x7c,0xe4,
0xd0,0x68,0x94,0x88,0x10,0x12,0x8c,0x24,0xc4,0x56,0x22,0x46,0x8d,0x51,0x8,0xd1,
0x18,0x25,0xf4,0xaa,0xa0,0x21,0x1a,0x28,0x22,0x82,0x89,0xf,0xd7,0x57,0xe3,0x43,
0x79,0x20,0x18,0xf5,0xa1,0xc8,0x37,0xed,0xb5,0xf7,0xb9,0xf7,0xb5,0x33,0xe3,0xcc,
0xec,0xde,0xec,0xce,0xde,0xee,0xdd,0x19,0x68,0xdc,0x26,0xdd,0x74,0x3a,0xb3,0xb3,
0x5f,0xbf,0xdf,0xfc,0x7f,0xff,0xff,0x7f,0x66,0xe,0x12,0x42,0xc0,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a2,0x2a,0x75,0x52,0xc7,0x2c,0x6c,0x10,0x22,
0x5e,0xb3,0x80,0xf5,0x38,0xfd,0x71,0x76,0x6b,0x41,0x2d,0xed,0xcc,0xd0,0x30,0x8b,
0x34,0x5c,0xe9,0x13,0x5e,0x94,0x90,0xfd,0x38,0xf3,0xa9,0x7a,0x50,0x2b,0xa0,0x48,
0x76,0x96,0x92,0x28,0x21,0x31,0x4b,0x64,0xd2,0x41,0x86,0x3f,0x78,0xfe,0x47,0xbe,
0x9f,0xf,0xe6,0x46,0x69,0x84,0x1a,0xa0,0x11,0x2a,0x51,0xca,0x97,0x4,0x70,0x3a,
0xc3,0x15,0xcb,0x3e,0x4f,0x13,0x60,0xc7,0xd9,0x43,0xf9,0xf3,0x74,0xd4,0xa9,0x73,
0xe7,0x27,0xe9,0xda,0x2,0x68,0x25,0x4c,0xb,0x9a,0x1f,0x16,0x28,0x1f,0xbf,0x7c,
0x5e,0xa4,0x61,0x96,0xc,0xa8,0xa9,0x7c,0x8c,0x49,0xaa,0x90,0xe1,0xe9,0x3e,0x3a,
0xe7,0x9b,0xbb,0xb,0xbf,0xd4,0x2f,0x10,0x58,0x20,0xb0,0x40,0xe0,0x7f,0x3d,0xfe,
0x5,0x2f,0xdb,0x52,0x42,0x2b,0x87,0x18,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,
0x44,0xae,0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/61.png
0x0,0x0,0xd,0x72,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,
0x0,0x41,0x64,0x6f,0x62,0x65,0x20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78,0x38,0x36,0x76,0xce,0xd3,0x77,0x19,0x45,0xa7,0xc0,0x93,0x10,0x74,0x9,0x68,
0x8,0xc8,0xa8,0xa3,0x67,0x52,0x79,0xd,0x87,0x86,0x93,0xc8,0x42,0xe3,0x52,0x33,
0x98,0xd4,0x6c,0x6f,0x99,0x4,0xde,0x24,0x1c,0x86,0xe1,0xa7,0xcf,0xd9,0x95,0xb3,
0x30,0x53,0x45,0xb5,0xbc,0xab,0x9b,0x1a,0x77,0x29,0x23,0x90,0xcc,0x69,0x48,0xd2,
0xb,0xda,0x1b,0x7c,0xd8,0xb9,0xa1,0x1e,0x41,0x8f,0x84,0x55,0x11,0xf,0x27,0x28,
0x9,0xcc,0x3b,0xd6,0x99,0xc9,0x85,0x59,0x7e,0x32,0xfe,0x29,0xd2,0xa9,0x34,0x7f,
0xf6,0xaa,0x1a,0x13,0x91,0x50,0x2f,0xbc,0xee,0x1a,0x4b,0x1e,0xb6,0x99,0xb,0xa4,
0x77,0xe6,0x9,0xd1,0x7e,0xae,0x9d,0x48,0x77,0xd4,0x79,0x71,0x62,0x2a,0xcb,0xbf,
0x67,0xda,0x9f,0x5c,0x2c,0x20,0x93,0x57,0xa9,0x69,0x18,0x8f,0xe7,0x2d,0x2f,0x55,
0x99,0xe4,0x2e,0xe8,0x1,0x41,0xb0,0x74,0x99,0xa2,0x41,0xfa,0x47,0x53,0x18,0x9c,
0xce,0xc2,0xed,0x96,0xa8,0xc9,0xf0,0xb0,0x38,0xe0,0x9f,0xa9,0x91,0x8c,0xa4,0xdc,
0xab,0x90,0x8c,0x63,0xe4,0x89,0x8f,0xd0,0xd0,0xd0,0x42,0xfa,0xc,0xf2,0x31,0x5b,
0xea,0xba,0xb1,0x30,0xbe,0x17,0x92,0xe9,0x41,0xa3,0xbf,0x1b,0x5b,0xba,0xef,0x43,
0x9,0x4d,0x98,0xc9,0xa8,0xe4,0xd,0x13,0x35,0x1e,0x11,0xf5,0xe4,0x1,0x86,0xcd,
0xe7,0x16,0x71,0x7d,0x57,0x4d,0x59,0x45,0xf4,0x7c,0x4,0x33,0x49,0x5,0x6f,0x7e,
0x1c,0xc7,0xe4,0x42,0x1,0xd5,0xf0,0xb3,0x77,0x54,0xf7,0x0,0x23,0x50,0xce,0x22,
0x42,0x59,0xcf,0x22,0x6f,0x56,0x3c,0x58,0x1,0x9b,0x5e,0x78,0xb,0x89,0x85,0x27,
0x10,0x6d,0x51,0xe1,0xf,0xfa,0xe1,0xa,0x19,0x98,0xcf,0xe,0x43,0x2c,0x88,0xfc,
0xf9,0xc9,0xd4,0x9,0x78,0xdc,0x3e,0xb4,0xd4,0x76,0x43,0xa8,0xcd,0xe2,0xed,0xd1,
0x27,0x28,0x31,0x78,0xd1,0xde,0xfc,0x43,0x28,0x7a,0x0,0xc3,0x4b,0x6,0x72,0x24,
0x29,0x93,0x52,0x6c,0x90,0xa4,0x58,0xce,0x40,0x2a,0x79,0x88,0x81,0x66,0x1e,0x50,
0x4a,0x3a,0xca,0x21,0x72,0xae,0xa1,0x1d,0x2,0xe7,0xde,0xe0,0x4,0xec,0x4,0xc2,
0x5a,0x39,0x43,0x30,0x77,0x97,0x83,0x73,0xe2,0xd4,0x4f,0xe0,0x9,0x1d,0x44,0x64,
0x95,0x17,0x2a,0xbd,0x24,0x93,0x2e,0x41,0xb0,0x33,0x90,0xae,0x59,0xf3,0x81,0x48,
0x24,0x4d,0x23,0x4f,0x12,0x38,0x41,0x92,0x18,0x44,0x24,0xd0,0x8c,0x2d,0x1b,0x76,
0x61,0x68,0xf8,0x31,0x92,0xd5,0xf7,0xe0,0x91,0xd6,0x42,0xa1,0x67,0x8a,0x3a,0x10,
0xcf,0x59,0x60,0x59,0x2b,0x11,0x29,0x55,0x37,0x1d,0x3,0x3a,0xa5,0xce,0x25,0x79,
0x40,0xb0,0xa2,0x8f,0x3d,0xdc,0xd2,0x90,0xb4,0x32,0x8e,0x6c,0xcd,0x1,0x83,0xfd,
0xbf,0x82,0x2f,0x7c,0x90,0xf2,0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,0xd5,0x45,0x89,0x47,0xa8,0x41,0x8d,0xb8,0x9a,0x13,0xe,0xbb,0x57,0x21,
0xb3,0x94,0x41,0x41,0x49,0x43,0xf6,0xc8,0xd0,0x54,0x8d,0xc,0xa4,0x70,0x23,0xa9,
0x9a,0xc2,0xdb,0x5c,0x72,0x12,0x2f,0xbe,0xf3,0x24,0x96,0x12,0x89,0x65,0x4,0xcc,
0x8b,0x23,0xc0,0x6,0x6a,0x69,0x59,0x8d,0x35,0x5d,0xeb,0x50,0x57,0x57,0x87,0xa8,
0x6b,0x15,0x52,0xe3,0x45,0x1e,0xac,0xac,0x6f,0x77,0xe7,0x6,0x14,0x52,0x25,0x6c,
0xdc,0xb0,0xd,0x41,0xa1,0x19,0xaa,0x99,0xb7,0x2b,0x4f,0x2b,0x4e,0xa,0x46,0xaa,
0xea,0xc2,0xc4,0x4b,0x24,0xfc,0x42,0x1d,0xee,0xb9,0xe3,0x61,0x8a,0x9b,0x14,0x4f,
0x16,0x43,0x13,0x87,0xd1,0x1c,0xed,0x76,0x80,0xab,0x7a,0x11,0xb9,0x42,0xa,0xc7,
0x4f,0xbf,0x8b,0x64,0x7a,0x9,0xb3,0xf3,0x53,0xe,0x1,0x5c,0x8a,0x7,0x34,0xad,
0x84,0x70,0x24,0x44,0x83,0x32,0x39,0x15,0x30,0x30,0x7c,0xc8,0x72,0x2f,0xd,0x14,
0xf2,0xd5,0xa3,0xb7,0xe7,0x7a,0x12,0x47,0x88,0x6,0x90,0x88,0x40,0xd1,0x1,0x5f,
0x3e,0xe7,0xf5,0x44,0x55,0x12,0x41,0xb1,0x11,0x3d,0x6b,0xaf,0x43,0xc8,0x53,0x8f,
0x62,0xbe,0x88,0x78,0x6a,0xc,0xd1,0x9a,0x66,0x2,0x9d,0xe1,0xef,0x65,0x24,0x4a,
0x2a,0xd5,0x62,0xf3,0x31,0x64,0x13,0x39,0x14,0x8b,0x59,0xa7,0x82,0xbd,0xa0,0x7,
0xce,0x3d,0x2c,0x4b,0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,0x42,0xec,0x97,0x57,0x8a,0x8d,0xcb,0x12,0xbc,0xe3,0x81,
0xcf,0xfe,0xd5,0xe0,0x33,0x2,0xff,0xc7,0x4,0xfe,0x21,0xc0,0x0,0xa2,0x78,0x21,
0xcb,0xf,0x38,0xb4,0x70,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,
0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/stylesheet_trackbar.qss
0x0,0x0,0x4,0xad,
0x2f,
0x2a,0x20,0x2f,0x2f,0x66,0x72,0x6f,0x6d,0x20,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
0x74,0x68,0x65,0x73,0x6d,0x69,0x74,0x68,0x66,0x61,0x6d,0x2e,0x6f,0x72,0x67,0x2f,
0x62,0x6c,0x6f,0x67,0x2f,0x32,0x30,0x31,0x30,0x2f,0x30,0x33,0x2f,0x31,0x30,0x2f,
0x66,0x61,0x6e,0x63,0x79,0x2d,0x71,0x73,0x6c,0x69,0x64,0x65,0x72,0x2d,0x73,0x74,
0x79,0x6c,0x65,0x73,0x68,0x65,0x65,0x74,0x2f,0x20,0x2a,0x2f,0xa,0xa,0x51,0x53,
0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x67,0x72,0x6f,0x6f,0x76,0x65,0x3a,0x68,0x6f,
0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,0x20,0x7b,0xa,0x62,0x6f,0x72,0x64,0x65,
0x72,0x3a,0x20,0x31,0x70,0x78,0x20,0x73,0x6f,0x6c,0x69,0x64,0x20,0x23,0x62,0x62,
0x62,0x3b,0xa,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x77,
0x68,0x69,0x74,0x65,0x3b,0xa,0x68,0x65,0x69,0x67,0x68,0x74,0x3a,0x20,0x31,0x30,
0x70,0x78,0x3b,0xa,0x62,0x6f,0x72,0x64,0x65,0x72,0x2d,0x72,0x61,0x64,0x69,0x75,
0x73,0x3a,0x20,0x34,0x70,0x78,0x3b,0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,
0x65,0x72,0x3a,0x3a,0x73,0x75,0x62,0x2d,0x70,0x61,0x67,0x65,0x3a,0x68,0x6f,0x72,
0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,0x20,0x7b,0xa,0x62,0x61,0x63,0x6b,0x67,0x72,
0x6f,0x75,0x6e,0x64,0x3a,0x20,0x71,0x6c,0x69,0x6e,0x65,0x61,0x72,0x67,0x72,0x61,
0x64,0x69,0x65,0x6e,0x74,0x28,0x78,0x31,0x3a,0x20,0x30,0x2c,0x20,0x79,0x31,0x3a,
0x20,0x30,0x2c,0x20,0x20,0x20,0x20,0x78,0x32,0x3a,0x20,0x30,0x2c,0x20,0x79,0x32,
0x3a,0x20,0x31,0x2c,0xa,0x73,0x74,0x6f,0x70,0x3a,0x20,0x30,0x20,0x23,0x36,0x36,
0x65,0x2c,0x20,0x73,0x74,0x6f,0x70,0x3a,0x20,0x31,0x20,0x23,0x62,0x62,0x66,0x29,
0x3b,0xa,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x71,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x28,0x78,0x31,
0x3a,0x20,0x30,0x2c,0x20,0x79,0x31,0x3a,0x20,0x30,0x2e,0x32,0x2c,0x20,0x78,0x32,
0x3a,0x20,0x31,0x2c,0x20,0x79,0x32,0x3a,0x20,0x31,0x2c,0xa,0x73,0x74,0x6f,0x70,
0x3a,0x20,0x30,0x20,0x23,0x62,0x62,0x66,0x2c,0x20,0x73,0x74,0x6f,0x70,0x3a,0x20,
0x31,0x20,0x23,0x35,0x35,0x66,0x29,0x3b,0xa,0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,
0x20,0x31,0x70,0x78,0x20,0x73,0x6f,0x6c,0x69,0x64,0x20,0x23,0x37,0x37,0x37,0x3b,
0xa,0x68,0x65,0x69,0x67,0x68,0x74,0x3a,0x20,0x31,0x30,0x70,0x78,0x3b,0xa,0x62,
0x6f,0x72,0x64,0x65,0x72,0x2d,0x72,0x61,0x64,0x69,0x75,0x73,0x3a,0x20,0x34,0x70,
0x78,0x3b,0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x61,
0x64,0x64,0x2d,0x70,0x61,0x67,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,
0x61,0x6c,0x20,0x7b,0xa,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,
0x20,0x23,0x66,0x66,0x66,0x3b,0xa,0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,0x20,0x31,
0x70,0x78,0x20,0x73,0x6f,0x6c,0x69,0x64,0x20,0x23,0x37,0x37,0x37,0x3b,0xa,0x68,
0x65,0x69,0x67,0x68,0x74,0x3a,0x20,0x31,0x30,0x70,0x78,0x3b,0xa,0x62,0x6f,0x72,
0x64,0x65,0x72,0x2d,0x72,0x61,0x64,0x69,0x75,0x73,0x3a,0x20,0x34,0x70,0x78,0x3b,
0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x68,0x61,0x6e,
0x64,0x6c,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,0x20,0x7b,
0xa,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x71,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x28,0x78,0x31,0x3a,
0x30,0x2c,0x20,0x79,0x31,0x3a,0x30,0x2c,0x20,0x78,0x32,0x3a,0x31,0x2c,0x20,0x79,
0x32,0x3a,0x31,0x2c,0xa,0x73,0x74,0x6f,0x70,0x3a,0x30,0x20,0x23,0x65,0x65,0x65,
0x2c,0x20,0x73,0x74,0x6f,0x70,0x3a,0x31,0x20,0x23,0x63,0x63,0x63,0x29,0x3b,0xa,
0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,0x20,0x31,0x70,0x78,0x20,0x73,0x6f,0x6c,0x69,
0x64,0x20,0x23,0x37,0x37,0x37,0x3b,0xa,0x77,0x69,0x64,0x74,0x68,0x3a,0x20,0x31,
0x33,0x70,0x78,0x3b,0xa,0x6d,0x61,0x72,0x67,0x69,0x6e,0x2d,0x74,0x6f,0x70,0x3a,
0x20,0x2d,0x32,0x70,0x78,0x3b,0xa,0x6d,0x61,0x72,0x67,0x69,0x6e,0x2d,0x62,0x6f,
0x74,0x74,0x6f,0x6d,0x3a,0x20,0x2d,0x32,0x70,0x78,0x3b,0xa,0x62,0x6f,0x72,0x64,
0x65,0x72,0x2d,0x72,0x61,0x64,0x69,0x75,0x73,0x3a,0x20,0x34,0x70,0x78,0x3b,0xa,
0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x68,0x61,0x6e,0x64,
0x6c,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,0x3a,0x68,0x6f,
0x76,0x65,0x72,0x20,0x7b,0xa,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,
0x3a,0x20,0x71,0x6c,0x69,0x6e,0x65,0x61,0x72,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,
0x74,0x28,0x78,0x31,0x3a,0x30,0x2c,0x20,0x79,0x31,0x3a,0x30,0x2c,0x20,0x78,0x32,
0x3a,0x31,0x2c,0x20,0x79,0x32,0x3a,0x31,0x2c,0xa,0x73,0x74,0x6f,0x70,0x3a,0x30,
0x20,0x23,0x66,0x66,0x66,0x2c,0x20,0x73,0x74,0x6f,0x70,0x3a,0x31,0x20,0x23,0x64,
0x64,0x64,0x29,0x3b,0xa,0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,0x20,0x31,0x70,0x78,
0x20,0x73,0x6f,0x6c,0x69,0x64,0x20,0x23,0x34,0x34,0x34,0x3b,0xa,0x62,0x6f,0x72,
0x64,0x65,0x72,0x2d,0x72,0x61,0x64,0x69,0x75,0x73,0x3a,0x20,0x34,0x70,0x78,0x3b,
0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x73,0x75,0x62,
0x2d,0x70,0x61,0x67,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,
0x3a,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x64,0x20,0x7b,0xa,0x62,0x61,0x63,0x6b,
0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x23,0x62,0x62,0x62,0x3b,0xa,0x62,0x6f,
0x72,0x64,0x65,0x72,0x2d,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x20,0x23,0x39,0x39,0x39,
0x3b,0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x61,0x64,
0x64,0x2d,0x70,0x61,0x67,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,
0x6c,0x3a,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x64,0x20,0x7b,0xa,0x62,0x61,0x63,
0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x23,0x65,0x65,0x65,0x3b,0xa,0x62,
0x6f,0x72,0x64,0x65,0x72,0x2d,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x20,0x23,0x39,0x39,
0x39,0x3b,0xa,0x7d,0xa,0xa,0x51,0x53,0x6c,0x69,0x64,0x65,0x72,0x3a,0x3a,0x68,
0x61,0x6e,0x64,0x6c,0x65,0x3a,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x74,0x61,0x6c,
0x3a,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x64,0x20,0x7b,0xa,0x62,0x61,0x63,0x6b,
0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x23,0x65,0x65,0x65,0x3b,0xa,0x62,0x6f,
0x72,0x64,0x65,0x72,0x3a,0x20,0x31,0x70,0x78,0x20,0x73,0x6f,0x6c,0x69,0x64,0x20,
0x23,0x61,0x61,0x61,0x3b,0xa,0x62,0x6f,0x72,0x64,0x65,0x72,0x2d,0x72,0x61,0x64,
0x69,0x75,0x73,0x3a,0x20,0x34,0x70,0x78,0x3b,0xa,0x7d,0xa,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/24.png
0x0,0x0,0x6,0x53,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0x5,0xd9,0x49,0x44,0x41,0x54,0x68,0xde,0xd5,0x59,0xdb,0x6b,0x1c,
0x55,0x18,0x3f,0x67,0xef,0x9b,0xdd,0x64,0xb7,0xa9,0x35,0x8,0x42,0xf3,0xe2,0x83,
0xf,0xd2,0xed,0x83,0x3e,0xf8,0xe2,0x82,0x8,0xa2,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x4d,0x6f,0x42,0x8d,0x58,0xc5,0x58,0xc0,0xe6,0xcf,0x1b,0xc0,
0xe8,0xf5,0x2c,0x30,0x74,0xb8,0xf,0x7d,0x3d,0xe7,0x95,0x9f,0x3e,0xd7,0x6e,0x4f,
0xf2,0x8c,0x23,0x61,0xc0,0x63,0x69,0xd,0xda,0x5f,0x48,0xaf,0x9,0xd3,0xd3,0x8e,
0xe7,0xe1,0x27,0xb,0xd5,0x1b,0x3c,0xf,0x85,0x8a,0x55,0x27,0x35,0xfe,0xc8,0x19,
0xc0,0xf1,0xf8,0x2b,0xa9,0x93,0x70,0x7b,0x23,0xbf,0x90,0x2d,0xdb,0xb,0xc0,0xe8,
0x7d,0xc,0x70,0xa6,0xb3,0xda,0xcf,0x5f,0x18,0x1b,0x53,0xf9,0xe8,0x28,0x82,0x78,
0x0,0xc4,0xcb,0xc9,0x12,0xcc,0xb9,0xe,0x4c,0xd4,0x70,0x2a,0x5d,0x63,0x3b,0x70,
0x3c,0xf7,0xcb,0x97,0x6c,0x77,0x6a,0x92,0xa3,0x0,0xb8,0xdb,0xc6,0xff,0xb3,0xb5,
0xca,0x85,0xbf,0x5a,0xb1,0x7c,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,
0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/7.png
0x0,0x0,0x7,0xf4,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0x7,0x7a,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0x5a,0x5b,0x6c,0x54,
0x45,0x18,0xfe,0xcf,0xd9,0x7b,0xbb,0xbd,0x21,0xb7,0x52,0xa,0xc5,0x14,0xa,0x44,
0x4b,0x93,0x6a,0x0,0x31,0x52,0x34,0x1,0x94,0x80,0x35,0x81,0x68,0x34,0x82,0xc6,
0x80,0xc4,0x97,0xf2,0x60,0xf4,0xc1,0x18,0xaa,0x49,0x13,0x13,0x1f,0x84,0x98,0x78,
0x7d,0x10,0xbc,0x90,0x98,0x40,0xac,0x21,0x6a,0xd0,0x28,0x60,0x4c,0x8,0x1,0xb9,
0xc4,0x88,0x58,0x5d,0x2c,0x65,0x5b,0xae,0xed,0xf6,0xbe,0xed,0xee,0x9e,0x19,0x67,
0x66,0xcf,0x9c,0x33,0xe7,0xba,0xb3,0x18,0x43,0x48,0x98,0x30,0x3d,0x97,0x9e,0x33,
0xf3,0x7d,0xf3,0x7f,0xff,0xe5,0x4c,0x51,0x30,0xc6,0x70,0x3b,0x37,0x15,0x6e,0xf3,
0x76,0x87,0xc0,0xad,0x6e,0x41,0xf1,0x42,0x51,0x14,0xc7,0x3,0xdb,0x3e,0x9c,0x3b,
0x17,0x14,0x68,0x55,0x55,0xa5,0x55,0x51,0x15,0xf6,0xcc,0x94,0x68,0x5d,0xf7,0xda,
0xda,0x37,0xf7,0xf0,0x77,0xf8,0x7b,0x6e,0xef,0xf3,0x7b,0x76,0x5f,0x13,0xaf,0xf7,
0x27,0x5e,0x6a,0x4f,0x67,0x87,0x80,0xde,0xc2,0x8,0xd3,0xde,0x49,0x7e,0xdf,0xf9,
0xf1,0xf6,0x9e,0x8b,0xf6,0xf1,0xec,0xe3,0x28,0xe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
0x61,0x6a,0x79,0x2d,0xb3,0xb6,0xab,0x84,0x8a,0x89,0x42,0xa,0x25,0x61,0x1,0x83,
0x8d,0x52,0x58,0xdc,0xb3,0x89,0x46,0xa3,0xac,0x42,0x94,0xf5,0x3,0x2f,0xc9,0xa9,
0xaa,0x6a,0x24,0x49,0x2e,0x13,0x4b,0x49,0x61,0xdc,0x50,0xe5,0xf2,0x0,0x56,0xf2,
0xdd,0xb2,0x35,0xe,0xce,0x62,0x2b,0x12,0x89,0xf8,0x6e,0xa7,0xfb,0x6d,0x0,0x98,
0xc5,0x1a,0xb6,0x15,0x92,0xd8,0xa7,0xa4,0x90,0xb0,0x80,0xb1,0x23,0xa0,0x4b,0xc6,
0xc8,0x92,0xc2,0x1e,0x3f,0x9f,0x94,0x4b,0x43,0x6,0xb0,0x94,0x1f,0x60,0xb0,0x4a,
0xc8,0x3,0x57,0x41,0x2,0x96,0xef,0x1,0xc3,0x5,0x30,0x3b,0x88,0x93,0x26,0x93,
0x49,0x48,0xa7,0xd3,0x96,0x55,0xf7,0x93,0x8f,0x17,0x91,0xea,0xea,0x6a,0x88,0xc5,
0x62,0xfa,0xd6,0xbd,0x5c,0x26,0xf7,0x23,0xd0,0xed,0xf5,0x22,0xff,0xe,0xe1,0xab,
0x5e,0x53,0x53,0x23,0xad,0xfd,0x42,0x7f,0xa1,0xb1,0x7f,0xc6,0xfa,0xb4,0x33,0x85,
0x8,0x74,0xca,0x14,0x34,0xa2,0x8c,0x8a,0xdd,0xec,0xf2,0x94,0x51,0x61,0x6,0x83,
0xa4,0x1f,0xf1,0x25,0x70,0xf4,0x53,0x18,0x5a,0xb9,0x19,0x68,0x4a,0x7c,0xce,0xb,
0x3f,0x9f,0x74,0x64,0x64,0x4,0x86,0x87,0x87,0x8b,0x8a,0x42,0x6e,0x4,0xca,0xca,
0xca,0x58,0x97,0x68,0xbb,0x28,0x3e,0xd8,0xb,0x5,0xff,0x42,0xb3,0x83,0xf4,0x56,
0xd2,0x2b,0x9d,0xf8,0xcd,0x30,0x1a,0xe,0x87,0xd9,0xc4,0xb2,0xba,0xf7,0x22,0x41,
0xc7,0x91,0x48,0x86,0x54,0xda,0xbb,0xa4,0x9c,0x58,0xb7,0x42,0x8b,0x6e,0xae,0x4a,
0x57,0x7f,0x20,0x93,0xd1,0x89,0x69,0x28,0xfd,0x2f,0xe0,0x25,0x65,0x47,0xa5,0xd3,
0xca,0x56,0x5f,0xf6,0xef,0xc4,0xe4,0x61,0xba,0x4f,0xd2,0x62,0x77,0x6a,0x6e,0x1,
0x31,0x8e,0xbb,0xd5,0x3c,0x7e,0xf5,0x91,0x5b,0xf9,0x81,0xb1,0x67,0x4,0xa2,0x4e,
0xdb,0xa2,0xe3,0x91,0xb,0xa3,0x36,0x12,0xf3,0x88,0x35,0xb6,0xe8,0xb2,0x6a,0xba,
0x91,0xea,0xeb,0xe6,0xa4,0x6e,0xc6,0x91,0xfd,0x22,0x51,0xff,0x60,0x6f,0x1d,0x39,
0xd4,0x9,0xc0,0xa9,0xe6,0xf7,0x4a,0x99,0x54,0xb6,0x20,0xfb,0x3f,0x1b,0x59,0xa8,
0xa,0xd2,0x57,0x16,0x83,0x97,0xf9,0xe3,0x9d,0xff,0xad,0x72,0x8b,0xdb,0xbf,0x38,
0x86,0xe7,0x24,0x54,0x18,0xe9,0xb3,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,
0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/38.png
0x0,0x0,0xb,0xf6,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0xb,0x7c,0x49,0x44,0x41,0x54,0x68,0xde,0xd5,0x98,0x67,0x50,0x95,
0x77,0x16,0xc6,0xfd,0xb0,0x51,0x23,0x2,0x57,0x14,0xec,0x8a,0x85,0xa6,0x94,0x4b,
0x17,0x15,0x54,0x2c,0x48,0x9,0xa1,0x89,0xa0,0x94,0x4b,0x13,0xd1,0xa8,0x17,0xb,
0x1d,0xc4,0x46,0x11,0x15,0x35,0x91,0x58,0x73,0x2d,0x31,0xb1,0x13,0x2b,0x6e,0xc4,
0x80,0x51,0x51,0x31,0x88,0xc6,0x64,0xd7,0xe0,0x26,0x24,0x31,0x3b,0xfb,0x91,0xc9,
0xcc,0xe6,0x53,0x66,0xf2,0xec,0x79,0xfe,0x17,0x98,0xcc,0x6e,0xb2,0x31,0x88,0x81,
0xbc,0x33,0xff,0xb9,0x17,0xef,0x2b,0x9c,0xdf,0x39,0xcf,0x73,0xce,0x79,0x6f,0x1f,
0x0,0x7d,0xfe,0xcc,0xa7,0xd7,0x5e,0xa1,0x79,0x96,0xd6,0x61,0x85,0x56,0x86,0xa8,
0x8d,0x23,0x5a,0x63,0x4b,0xc6,0xb5,0x25,0x56,0xd8,0x19,0x92,0x77,0x4c,0xd6,0xfc,
0xfc,0x9e,0x5e,0x9,0x10,0xb8,0x5a,0xa3,0x9,0xce,0xb2,0xa8,0x4c,0x28,0xb3,0xc7,
0xa6,0x93,0x91,0x38,0xd1,0xb0,0x11,0x17,0xef,0xef,0x46,0xf1,0xb1,0x8,0x8,0x40,
0x6b,0xea,0x4e,0x27,0x6d,0xaf,0x5,0x98,0xb7,0x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x1c,0x4e,0x25,0xd9,0xe2,0x72,0xc6,
0x24,0x54,0xa7,0xda,0xe3,0x9d,0x98,0xf1,0x12,0xdc,0x58,0x95,0x79,0x6,0x7a,0x38,
0x76,0x2,0x8e,0xc7,0xdb,0xe0,0xd8,0xe2,0x89,0xea,0x1c,0x59,0x34,0x41,0x41,0xec,
0xc,0x19,0xd,0x56,0x6a,0x5b,0xd0,0x48,0x10,0x5e,0x55,0x48,0xe,0xe5,0x56,0x3a,
0x6f,0x38,0x56,0x45,0xcd,0xc1,0xae,0x9d,0xbb,0x70,0xea,0xf4,0x99,0xce,0xe0,0xef,
0xde,0x6b,0xc4,0x17,0x2d,0x4f,0x9b,0x5b,0xbf,0xfe,0x46,0xd3,0x25,0x0,0x9,0xc0,
0x5a,0x2,0xd0,0x1f,0x89,0x9d,0xd0,0xfa,0x9e,0x4,0x75,0x69,0xe9,0x24,0xd4,0x67,
0x3a,0xe3,0xea,0xf2,0xc9,0x2a,0xf3,0x87,0x4,0x86,0x87,0x81,0x9e,0x13,0x18,0x75,
0x52,0xec,0x15,0x18,0x5f,0x8f,0xc7,0x4f,0xc4,0x3e,0xa9,0x2,0xab,0x41,0x38,0x49,
0x80,0x82,0xa5,0x8c,0x18,0x34,0x2b,0x45,0x18,0x56,0x25,0xd9,0x69,0x10,0x22,0x1d,
0x47,0x60,0x69,0x64,0x20,0x4a,0x4b,0x4a,0x71,0x59,0x0,0xba,0x12,0x7c,0x27,0xc0,
0xfb,0x9,0x36,0x61,0xc,0xe0,0x74,0x92,0x1d,0xfe,0xfa,0x86,0x23,0xee,0x64,0xbb,
0xe2,0xf6,0x3a,0x2d,0x3e,0x48,0xb3,0xc7,0xbb,0x71,0x13,0xd5,0x61,0xa0,0xfc,0xac,
0x66,0xd9,0x64,0x75,0x3e,0x5c,0xe1,0xa8,0x7e,0xbe,0x90,0xee,0x0,0xf9,0xff,0xaa,
0x1a,0x87,0x63,0xc7,0xe3,0x44,0xa2,0xd,0x24,0x9,0xa,0x60,0xab,0x48,0x8c,0xd5,
0x60,0xe0,0xfc,0x59,0xbc,0xa4,0x0,0xa2,0xc6,0xbd,0x2a,0xed,0xd6,0xc,0xd1,0x13,
0x7,0x22,0xd1,0xc1,0x14,0x8b,0x3d,0x27,0x20,0xde,0xd1,0xb2,0xb8,0x2b,0xdd,0x50,
0x1,0x88,0xae,0x8b,0x99,0xd9,0xda,0x95,0x4e,0xb8,0x25,0x81,0xdf,0x94,0xc3,0xac,
0x9e,0x12,0xbd,0x9f,0x5f,0xe2,0x80,0x1b,0xab,0x5d,0x50,0x27,0xd5,0xe0,0xb9,0xb5,
0x56,0xab,0xce,0xf5,0x55,0x4e,0xaa,0x4a,0x84,0x66,0xd0,0xbc,0x9f,0xc0,0xfc,0x3d,
0x94,0x5e,0x95,0x54,0xe1,0xa8,0x48,0xea,0xed,0xf0,0xb1,0xea,0x67,0x25,0xbd,0xd0,
0x31,0x28,0xf4,0xb5,0x42,0x82,0xad,0x9,0x38,0x33,0xa2,0x5,0x44,0x86,0x1e,0x62,
0xec,0xcc,0x90,0x68,0x6b,0xa2,0xef,0x32,0xc0,0x99,0x64,0x3b,0xdd,0x71,0xc9,0x32,
0xe5,0xf2,0x91,0xde,0x59,0x5,0xcd,0x8c,0x5f,0x5f,0xe5,0x8c,0x3b,0x59,0xac,0x86,
0x2b,0xee,0xe6,0xb8,0xa1,0x31,0xd7,0xd,0xb7,0xb3,0xb4,0xea,0x1e,0xde,0xcb,0xfb,
0xce,0xa7,0x39,0xa8,0xf7,0x67,0x53,0xec,0x40,0xe9,0x31,0x68,0x42,0xb0,0x32,0xec,
0x54,0x86,0x18,0xe3,0xa9,0x12,0x10,0x1a,0x7d,0x85,0x9b,0xc6,0x78,0x5c,0x35,0x58,
0xe2,0x68,0x8a,0x54,0x19,0x7a,0x49,0x52,0x85,0x24,0xfb,0x81,0xd6,0x5d,0x6,0xe0,
0x25,0x99,0x6c,0x3e,0x91,0x68,0xab,0xe4,0x71,0x45,0xce,0x4d,0xc9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,0x5c,0x2d,0xb8,0x99,0x8a,0x84,0x2a,
0x7b,0x35,0x40,0xe7,0x26,0xbb,0x74,0x92,0x4e,0x96,0xc0,0x36,0x66,0x5f,0x3d,0x57,
0xeb,0x9d,0x8c,0x5f,0xcd,0xc4,0xdb,0xe8,0xfe,0x14,0x0,0xbc,0xc4,0xd8,0x5a,0xa9,
0x44,0x33,0x1f,0x64,0xf8,0x65,0x1,0x2b,0x70,0x22,0xc1,0xc6,0xfa,0x4f,0x3,0xd0,
0x71,0x49,0xe0,0x3a,0x31,0x70,0xdd,0x99,0x64,0xbb,0xe2,0x97,0xf5,0x37,0x8,0xf0,
0x1f,0x25,0x5d,0x1c,0x30,0x6c,0xcb,0x33,0x9c,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,
0x44,0xae,0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/106.png
0x0,0x0,0xb,0x25,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,
0x0,0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6d,0x61,0x67,0x65,0x52,0x65,0x61,0x64,
0x79,0x71,0xc9,0x65,0x3c,0x0,0x0,0xa,0xc7,0x49,0x44,0x41,0x54,0x78,0xda,0xd4,
0x5a,0x9,0x6c,0x5c,0xd5,0x15,0x3d,0x7f,0xfe,0xec,0x1e,0x6f,0xf1,0xee,0x78,0x19,
0xe3,0xe0,0xa4,0x9,0x4e,0xec,0x34,0x40,0x52,0x14,0xb0,0xb,0xb4,0x42,0x84,0x26,
0x48,0xa5,0x2a,0x2,0x95,0x81,0x42,0x69,0x42,0x5b,0x92,0xaa,0x91,0xaa,0x22,0x68,
0x4b,0xab,0x4a,0x55,0x23,0xc5,0x54,0x65,0xeb,0x82,0x9d,0x50,0x94,0xb6,0x40,0x65,
0xd2,0x82,0x54,0x96,0x84,0xa0,0x96,0x82,0xe3,0x90,0xc9,0x42,0xec,0x78,0x8b,0xb7,
0x19,0xbc,0x8e,0xbf,0xed,0xd9,0x67,0xfe,0x4c,0xef,0x7d,0xb3,0x64,0xbc,0xb0,0x75,
0xc,0x49,0xbe,0xf2,0xf4,0xe6,0xcf,0xff,0xf3,0xde,0x39,0xf7,0x9d,0xbb,0xbc,0xe7,
0x48,0xd1,0x68,0x14,0x97,0xf2,0xa5,0xc1,0x25,0x7e,0x69,0x53,0x6f,0x24,0x49,0x5a,
0xf2,0x9,0xb6,0xec,0x32,0x37,0x48,0xb2,0xd4,0xa0,0xd1,0x68,0xb2,0x35,0xb2,0x54,
0x27,0x69,0x24,0x68,0x64,0xd,0xa8,0xb7,0xd3,0xfd,0x34,0x7d,0xff,0xe6,0x81,0x87,
0xc6,0xdf,0xfc,0x34,0x63,0xa6,0xaa,0x46,0x9a,0x73,0xb3,0x44,0x4,0xbe,0xba,0x5d,
0xcf,0xa0,0xef,0xca,0xcc,0xcd,0xda,0x56,0x54,0x5a,0x9c,0x53,0x54,0x5c,0x86,0xdc,
0xec,0x2,0x18,0xc,0x46,0x68,0x34,0x32,0xf4,0x5a,0x13,0x32,0xd,0x79,0xf0,0x7,
0xfc,0x18,0x1d,0x1f,0x44,0xbf,0xe3,0x7d,0x65,0xcc,0x35,0xd4,0xaa,0xd1,0x48,0x8f,
0x3d,0xbb,0x7b,0xc4,0x7e,0xc1,0x8,0x5c,0x7f,0xaf,0x6c,0x25,0xcb,0x36,0x2f,0x2b,
0xcd,0x6e,0xa8,0xa8,0x29,0x87,0x56,0xab,0x43,0x30,0x18,0x40,0x28,0x4c,0x4d,0xd,
0x12,0x78,0x89,0x2d,0xf,0x9e,0x86,0x7b,0xbd,0xce,0x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x1b,0xac,0xd7,0x23,0x3f,0xa7,0x58,0xe8,0xbd,0xaa,0x78,
0xd5,0xa2,0x13,0x9d,0xe8,0x7a,0xb,0x96,0x3c,0x53,0x2c,0x60,0xd0,0x3d,0x13,0x98,
0x99,0x9d,0x48,0x9b,0x80,0x92,0xc8,0xbe,0x7c,0xf1,0x46,0x65,0x5c,0x19,0x48,0xae,
0x40,0x82,0x40,0x86,0xc9,0x82,0xad,0xd7,0xd8,0x68,0x43,0x13,0x14,0xf7,0x67,0x7a,
0xed,0x18,0xf6,0x38,0xc4,0x4a,0xa8,0x41,0xd,0xae,0xac,0xbe,0x1,0x6b,0x56,0xd4,
0xc7,0xf6,0x2,0x26,0xd3,0xa2,0x35,0xff,0xd0,0xf8,0x19,0x14,0x15,0x58,0xc4,0x2a,
0x49,0x1a,0x92,0x5a,0x38,0xc4,0x5c,0xfa,0xd3,0xd,0xa3,0x27,0x78,0xc9,0xa3,0xf1,
0x2c,0xdc,0x73,0xee,0x24,0x2a,0xad,0x97,0x8b,0xca,0x92,0xef,0x39,0x7a,0x24,0xfc,
0x81,0x9d,0x91,0x43,0xa2,0xf8,0x9e,0x74,0xce,0x92,0xa,0xb8,0x55,0xd1,0xa7,0x66,
0x67,0xaf,0xd7,0x8b,0x40,0x20,0x30,0xe7,0xbb,0x9e,0x1,0x3b,0x24,0x53,0x48,0xc8,
0x8f,0xef,0xd,0x3a,0xb,0xa6,0xc9,0xfa,0xf4,0xf9,0x44,0xba,0x4,0x5a,0x55,0x22,
0x10,0x89,0x3b,0xe2,0xdb,0xed,0x2f,0xa3,0x61,0xf3,0xad,0x78,0xfe,0xb5,0x3d,0xb1,
0x15,0x9,0x85,0x92,0xe4,0xf8,0xe2,0xb2,0x82,0x89,0x18,0x64,0xde,0x2f,0x10,0x91,
0x50,0x44,0x44,0x1d,0x5e,0xa1,0x54,0xc7,0x67,0x2,0x1e,0x8f,0x47,0xf4,0x6c,0x84,
0x97,0xe,0x3f,0x8e,0x9c,0x92,0x4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xc1,0x7f,0xaa,0x72,0xba,
0xb6,0xb6,0xb6,0x8e,0x2c,0xde,0x40,0xad,0xbf,0xb7,0xb7,0xb7,0xf5,0x62,0x1,0xfd,
0xa1,0x12,0xba,0x14,0xaf,0x4b,0xfe,0x3f,0x7b,0x5c,0xf2,0x4,0xfe,0x27,0xc0,0x0,
0x8d,0xf1,0x12,0xbf,0xe7,0x10,0x37,0x3d,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,
0xae,0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/27.png
0x0,0x0,0xb,0xfb,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0xb,0x81,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0x9a,0xdb,0x8f,0x25,
0xd7,0x55,0xc6,0x7f,0x6b,0x57,0x9d,0x4b,0x9f,0xd3,0x97,0xb9,0xf7,0x58,0xbe,0x4c,
0xdb,0xc,0x8e,0x31,0x44,0x1a,0x5e,0x88,0x78,0x0,0x4f,0x24,0x24,0x9e,0x50,0x46,
0x81,0x97,0x48,0x20,0x1c,0x85,0x97,0x3c,0xc5,0x88,0x7f,0xc0,0x8f,0xbc,0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c7,0xf9,0x8d,0x1e,0x5b,0xc3,0x84,0x53,0xc3,0xa4,
0x96,0xd0,0xde,0xd2,0x73,0x7b,0x92,0xf3,0xc9,0xb4,0xa4,0x50,0x63,0x98,0xa,0xeb,
0xa9,0x63,0x73,0xe8,0xea,0x77,0xa9,0xc2,0xdd,0x49,0xce,0xf7,0xde,0x7f,0xc4,0xe3,
0x79,0xc1,0x46,0x48,0xf1,0x87,0x19,0xf0,0x1e,0xf5,0x35,0x0,0xd0,0x78,0x42,0xcc,
0x10,0x73,0x60,0xe1,0x61,0xbe,0x2,0x20,0x42,0x28,0xc4,0x82,0x73,0xd4,0xb2,0x4a,
0x9c,0x90,0xb8,0x90,0x95,0x46,0x3d,0xc7,0xf6,0x38,0xa5,0x9f,0x8,0xcb,0x52,0x61,
0x1,0x59,0xa9,0xc,0x53,0x47,0xa9,0xc6,0x7e,0xe6,0x31,0x60,0xdc,0x77,0x4c,0x96,
0x9e,0x7b,0x7,0x25,0x37,0x33,0x4f,0x96,0x95,0x2c,0xb3,0x92,0x2c,0xf3,0x2c,0xb3,
0x92,0x65,0xdc,0xbb,0x98,0xc1,0x6a,0x0,0xde,0xd7,0x45,0x4e,0x55,0xf1,0xde,0xb7,
0x18,0x28,0x7d,0x64,0x40,0x6a,0x19,0x55,0x12,0x8a,0xa9,0xbf,0x1,0x21,0x52,0x3,
0x91,0x56,0xca,0x74,0x12,0xb2,0xce,0x30,0x75,0xc,0x13,0xc7,0x20,0x15,0x7a,0x71,
0xca,0x31,0x48,0x84,0x13,0xc3,0x84,0x61,0xe2,0x70,0x78,0x96,0xa5,0x6,0xa0,0xad,
0x7b,0xdb,0x8e,0xaa,0xf6,0x44,0x25,0x34,0xd5,0xd9,0xea,0xd8,0xd4,0x52,0x9b,0x20,
0xf6,0x95,0x84,0x4c,0xc0,0x19,0x66,0xd,0xad,0x83,0x7e,0xc9,0xf6,0x99,0x3,0xce,
0x9e,0x9a,0x32,0x1a,0x96,0x9c,0xdc,0x9a,0x90,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,0x75,0xc6,0x56,0x97,0xfe,0xca,0xeb,
0x1,0x50,0xf5,0x1c,0x62,0x6d,0xa9,0xc1,0x1,0x44,0x70,0xde,0x2b,0x45,0x56,0x86,
0x6,0x56,0x6d,0x30,0x4d,0xbd,0x9,0xd3,0xd7,0x50,0xa3,0x5a,0x0,0xaa,0xe,0x4d,
0xe9,0xad,0x89,0x81,0x10,0x14,0x47,0x4b,0xc8,0x7c,0x5c,0x7c,0x8b,0x61,0x4e,0x62,
0xa5,0x6e,0x18,0x69,0xbc,0x5f,0x19,0x6f,0xf5,0x2a,0xac,0x1,0xd3,0x95,0x92,0x9a,
0x52,0x66,0xbe,0x36,0xa8,0x6,0xb0,0xc2,0x42,0x1d,0x87,0xd6,0x95,0x90,0xc5,0xe9,
0x78,0xc3,0x80,0x1e,0x25,0xa1,0x98,0xc2,0x2a,0x9,0x45,0xe3,0x6b,0x20,0x15,0x23,
0x51,0x42,0x12,0x41,0xb0,0x2,0x86,0x3a,0xa0,0xa3,0xac,0x20,0x4,0x6b,0xdb,0xa3,
0x2d,0xc9,0x74,0x19,0x69,0x7,0x71,0x23,0x21,0x93,0x8e,0x84,0x82,0xf7,0x7d,0x4b,
0x42,0xed,0x4a,0x5c,0x4b,0xa8,0xf2,0x7c,0x1c,0x5b,0xcb,0x68,0x71,0x52,0x7,0x67,
0x3b,0xe,0x2a,0x30,0x46,0xb3,0x36,0xd6,0xc8,0xaa,0xb5,0xe6,0x36,0x76,0xc,0x0,
0x69,0x25,0x98,0xe,0x80,0x55,0x9,0x95,0x51,0x67,0x6d,0x0,0xe1,0x26,0x45,0x7d,
0x3b,0x88,0xbb,0x12,0xb2,0x16,0x20,0x69,0x49,0xa9,0xe3,0x75,0xa9,0xda,0x8d,0x1,
0x50,0x58,0x3c,0x59,0xd3,0xc8,0xd5,0x46,0x16,0x47,0x32,0xe0,0xad,0x56,0x43,0x5,
0x58,0xa5,0xd,0xa0,0x95,0x85,0xa4,0xe9,0x55,0x5,0x6,0x8c,0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0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
// /home/sxy/Github/opencv_cpp/start/opencv-3.4.1/modules/highgui/src/files_Qt/Milky/48/19.png
0x0,0x0,0x7,0xbe,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x30,0x0,0x0,0x0,0x30,0x8,0x6,0x0,0x0,0x0,0x57,0x2,0xf9,0x87,
0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x25,0x0,0x0,0x80,0x83,
0x0,0x0,0xf9,0xff,0x0,0x0,0x80,0xe9,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,
0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x6f,0x92,0x5f,0xc5,0x46,0x0,0x0,0x0,0x9,
0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,
0x18,0x0,0x0,0x7,0x44,0x49,0x44,0x41,0x54,0x68,0xde,0xd5,0x59,0x6b,0x6c,0x54,
0x45,0x14,0x3e,0x77,0x77,0xdb,0x42,0x5b,0xba,0x2d,0xdb,0x17,0x2d,0xa5,0x4b,0xb,
0x95,0x87,0xd0,0xa5,0x11,0xad,0x1,0x43,0x9,0x22,0x98,0xa0,0x20,0xc6,0x7,0x46,
0xd3,0x95,0x7f,0xbe,0x8d,0x86,0x10,0x35,0x1a,0x88,0x6,0x31,0x86,0x88,0x8f,0xc8,
0x3f,0xbb,0x44,0xd,0x1a,0x8c,0xae,0x8,0x48,0x40,0xa5,0xa8,0x84,0x50,0x40,0x5a,
0xc1,0x16,0xda,0xd2,0x2d,0x7d,0x41,0x43,0x5b,0x76,0x69,0x6b,0xa1,0xdd,0x3b,0xe3,
0xcc,0xdc,0xb9,0xef,0x5d,0xba,0x65,0x6b,0xb7,0x34,0x99,0xbd,0x73,0xef,0xee,0xbd,
0x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44,0x51,0x2,0xc0,0x30,0xb,0xdc,0xfa,
0x98,0x5b,0x9f,0xf9,0x24,0x44,0x66,0x92,0x9f,0x81,0x98,0x17,0xa3,0x71,0x41,0x94,
0x1e,0x8,0x6a,0x3c,0xc0,0xad,0x7e,0x13,0x4f,0x8,0x82,0x9a,0x42,0x75,0x1e,0x88,
0x85,0x84,0x28,0x12,0x51,0x94,0x82,0x58,0xdb,0x32,0xca,0xc0,0x25,0xb0,0xa1,0x8,
0xa9,0xbf,0x65,0x31,0xc0,0x8,0xc4,0xc2,0x3,0x48,0xe,0x62,0x49,0x42,0x2,0x5f,
0x7c,0xa5,0x15,0xce,0xc,0x5c,0x47,0x88,0x87,0x4,0xf3,0x40,0x6c,0x83,0x98,0x10,
0x10,0xb5,0x12,0x92,0x82,0x43,0x95,0x4a,0x18,0x42,0x3c,0x2e,0x30,0x21,0x4f,0xf7,
0x89,0x62,0x14,0x3,0x52,0x10,0xd3,0xa1,0x34,0x28,0x58,0xb3,0x14,0x68,0x4a,0x8,
0x1d,0x21,0x50,0xe3,0x42,0x59,0x7,0x10,0x8e,0x5d,0x1a,0x45,0x48,0xcd,0x42,0xa0,
0xb5,0xba,0x6c,0x55,0x7d,0x63,0xa0,0xcf,0x50,0xac,0xb9,0x41,0xb1,0xa,0x62,0x2c,
0x95,0xd4,0x4a,0x59,0xad,0xb7,0xba,0x89,0x90,0x29,0x2e,0xf8,0xbd,0x8,0xc7,0x2a,
0x88,0x35,0x2d,0x21,0xc2,0x8a,0xd5,0xcd,0xfa,0xf,0x41,0x88,0x7b,0x43,0xed,0xf,
0x62,0x24,0x21,0xac,0x69,0x5e,0x14,0x90,0xc3,0xea,0x1f,0xa4,0x8e,0x82,0x95,0x12,
0xe4,0x28,0x62,0xd6,0xbc,0xc4,0x86,0x0,0x6f,0xd2,0x15,0xb,0x6a,0xf5,0x6f,0xdc,
0xdd,0xd,0x21,0x23,0xd3,0xfd,0x63,0x9d,0x85,0x90,0x4e,0x42,0xfa,0x4e,0x4c,0xf,
0x1c,0x42,0x92,0x8a,0xad,0x84,0x90,0x7e,0x7b,0x45,0x5a,0xac,0xcc,0x95,0xa7,0x11,
0x38,0xe3,0xc6,0x49,0xa9,0x1e,0x88,0x59,0x16,0xc2,0x6c,0x35,0xa5,0x1,0xad,0xd4,
0x41,0x4a,0xea,0xe4,0xdd,0x73,0x38,0x6f,0xc8,0x46,0x10,0x71,0xec,0xaa,0x51,0x39,
0x8,0xf5,0xe5,0xb4,0xa1,0x6c,0xe,0xe7,0xd,0xc5,0x3,0x68,0x1c,0x48,0x8,0x29,
0xda,0xd0,0xe8,0xc4,0x50,0xc4,0x81,0x31,0x36,0x40,0xdd,0xd5,0x8b,0x4d,0x2d,0x4,
0x7e,0x44,0xea,0x20,0xa4,0x89,0x1,0x93,0xd5,0xb1,0xa6,0x9b,0x87,0x10,0xa4,0x88,
0xf4,0x50,0x90,0x7e,0xe0,0xe6,0x98,0xfc,0x8f,0x6c,0xdd,0x96,0xc,0x9f,0x60,0x11,
0x9c,0x68,0x48,0x64,0x44,0x74,0x2d,0xe3,0x30,0xfb,0xbd,0xf4,0x15,0x16,0x9b,0x85,
0x7a,0xcf,0x4f,0xce,0x9c,0xbb,0xde,0xbc,0x12,0x88,0x34,0x7d,0x8f,0x68,0x73,0x77,
0x98,0xa7,0xad,0x21,0x5e,0xa8,0xa4,0x7b,0xa4,0xd6,0x38,0xb,0x58,0x6d,0x74,0x8,
0x4,0x98,0x66,0x58,0xcc,0x83,0xed,0xa9,0x12,0x6,0x28,0x88,0x9b,0x9,0x9e,0xb2,
0x48,0xc1,0x47,0xec,0x81,0xdb,0xe9,0xef,0x3f,0x1f,0x7a,0x6f,0x8f,0xc9,0x98,0xea,
0x6a,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};
static const unsigned char qt_resource_name[] = {
// right-icon
0x0,0xa,
0xf,0x7c,0xe9,0xfe,
0x0,0x72,
0x0,0x69,0x0,0x67,0x0,0x68,0x0,0x74,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// zoom_out-icon
0x0,0xd,
0xe,0xbf,0x98,0x9e,
0x0,0x7a,
0x0,0x6f,0x0,0x6f,0x0,0x6d,0x0,0x5f,0x0,0x6f,0x0,0x75,0x0,0x74,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// left-icon
0x0,0x9,
0xd,0x73,0x1f,0x3e,
0x0,0x6c,
0x0,0x65,0x0,0x66,0x0,0x74,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// imgRegion-icon
0x0,0xe,
0x5,0x82,0x92,0x5e,
0x0,0x69,
0x0,0x6d,0x0,0x67,0x0,0x52,0x0,0x65,0x0,0x67,0x0,0x69,0x0,0x6f,0x0,0x6e,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// stylesheet-trackbar
0x0,0x13,
0xe,0x2,0x40,0x42,
0x0,0x73,
0x0,0x74,0x0,0x79,0x0,0x6c,0x0,0x65,0x0,0x73,0x0,0x68,0x0,0x65,0x0,0x65,0x0,0x74,0x0,0x2d,0x0,0x74,0x0,0x72,0x0,0x61,0x0,0x63,0x0,0x6b,0x0,0x62,
0x0,0x61,0x0,0x72,
// down-icon
0x0,0x9,
0xe,0x13,0x30,0x9e,
0x0,0x64,
0x0,0x6f,0x0,0x77,0x0,0x6e,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// save-icon
0x0,0x9,
0xc,0x83,0xd,0x5e,
0x0,0x73,
0x0,0x61,0x0,0x76,0x0,0x65,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// properties-icon
0x0,0xf,
0x0,0xbb,0x15,0xfe,
0x0,0x70,
0x0,0x72,0x0,0x6f,0x0,0x70,0x0,0x65,0x0,0x72,0x0,0x74,0x0,0x69,0x0,0x65,0x0,0x73,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// zoom_in-icon
0x0,0xc,
0x0,0x3f,0x40,0xfe,
0x0,0x7a,
0x0,0x6f,0x0,0x6f,0x0,0x6d,0x0,0x5f,0x0,0x69,0x0,0x6e,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// zoom_x1-icon
0x0,0xc,
0xb,0x2f,0x40,0xbe,
0x0,0x7a,
0x0,0x6f,0x0,0x6f,0x0,0x6d,0x0,0x5f,0x0,0x78,0x0,0x31,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
// up-icon
0x0,0x7,
0xc,0x33,0xfa,0xbe,
0x0,0x75,
0x0,0x70,0x0,0x2d,0x0,0x69,0x0,0x63,0x0,0x6f,0x0,0x6e,
};
static const unsigned char qt_resource_struct[] = {
// :
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0xb,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/zoom_in-icon
0x0,0x0,0x0,0xf4,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x45,0xe,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/properties-icon
0x0,0x0,0x0,0xd0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x39,0x14,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/imgRegion-icon
0x0,0x0,0x0,0x52,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x18,0x9e,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/zoom_x1-icon
0x0,0x0,0x1,0x12,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x50,0x37,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/up-icon
0x0,0x0,0x1,0x30,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x5c,0x36,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/save-icon
0x0,0x0,0x0,0xb8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x31,0x1c,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/left-icon
0x0,0x0,0x0,0x3a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x11,0xe4,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/stylesheet-trackbar
0x0,0x0,0x0,0x74,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x26,0x14,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/down-icon
0x0,0x0,0x0,0xa0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x2a,0xc5,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/zoom_out-icon
0x0,0x0,0x0,0x1a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x6,0xd2,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
// :/right-icon
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
0x0,0x0,0x1,0x61,0xc1,0xd0,0x5b,0x28,
};
#ifdef QT_NAMESPACE
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
# define QT_RCC_MANGLE_NAMESPACE0(x) x
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
#else
# define QT_RCC_PREPEND_NAMESPACE(name) name
# define QT_RCC_MANGLE_NAMESPACE(name) name
#endif
#ifdef QT_NAMESPACE
namespace QT_NAMESPACE {
#endif
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
#ifdef QT_NAMESPACE
}
#endif
int QT_RCC_MANGLE_NAMESPACE(qInitResources_window_QT)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources_window_QT)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_window_QT)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_window_QT)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
namespace {
struct initializer {
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_window_QT)(); }
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_window_QT)(); }
} dummy;
}
| 76.320513 | 146 | 0.764196 | shengxiaoyi1993 |
2e447f5db9918bf5b71eb450ca7e55dcc5d523b5 | 1,908 | cpp | C++ | VOJ/zoj-1610.cpp | PIPIKAI/ACM | b8e4416a29c0619946c9b73b0fe5699b6e96e782 | [
"MIT"
] | null | null | null | VOJ/zoj-1610.cpp | PIPIKAI/ACM | b8e4416a29c0619946c9b73b0fe5699b6e96e782 | [
"MIT"
] | null | null | null | VOJ/zoj-1610.cpp | PIPIKAI/ACM | b8e4416a29c0619946c9b73b0fe5699b6e96e782 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1e9+7
#define ffr(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset( a,b,sizeof a)
#define Max(x,y) y>x? x=y: x=x
const int maxn=1e4+7;
int vis[maxn],last;
struct node{
int l,r;
ll sum;
void update(ll x){
sum=x;
}
}tree[maxn*4];
void push_up(int x){
//tree[x].sum=tree[x<<1].sum+tree[x<<1|1].sum; /// 根据题目要求
}
void push_down(int x){
int lazytp=tree[x].sum;
if(lazytp!=-1){
tree[x<<1].update(lazytp);
tree[x<<1|1].update(lazytp);
tree[x].sum=-1;
}
}
void built(int x,int l,int r){
tree[x]=node{l,r,-1};
if(l==r){
return ;
}
else{
int mid=(l+r)>>1;
built(x<<1 ,l ,mid );
built(x<<1|1 ,mid+1 ,r );
push_up(x);
}
}
void update(int x,int l,int r,int val){
int L=tree[x].l,R=tree[x].r;
if(l<=L&&R<=r){
tree[x].sum=val;
}
else{
push_down(x);
int mid=(L+R)>>1;
if(mid>=l)
update(x<<1,l,r,val);
if(mid<r)
update(x<<1|1,l,r,val);
push_up(x);
}
}
void query(int x,int l,int r){
int L=tree[x].l,R=tree[x].r;
int po=tree[x].sum;
if(L==R){
if(po!=last && po!=-1){
vis[po]++;
}
last=po;return ;
}
push_down(x);
int mid=(L+R)>>1;
if(mid>=l)
query(x<<1,l,r);
if(mid<r)
query(x<<1|1,l,r);
}
int main(){
std::ios::sync_with_stdio(false);
int n,q;
while(cin>>n){
built(1,1,8001);
for(int l,r,x,i=0;i<n;i++){
cin>>l>>r>>x;
update(1,l+1,r,x);///这里是l+1要注意,不然一直wa
}
last=-1;
mem(vis,0);
query(1,1,8001);
for(int i=0;i<=8000;i++){
if(vis[i]){
cout<<i<<" "<<vis[i]<<endl;
}
}
cout<<endl;
}
return 0;
}
| 20.73913 | 61 | 0.455451 | PIPIKAI |
2e447fcca052c1b7cb1736c2a77e2880605f32e9 | 442 | cpp | C++ | VGP332/HelloFSM/GameState.cpp | CyroPCJr/OmegaEngine | 65fbd6cff54266a9c934e3a875a4493d26758661 | [
"MIT"
] | 1 | 2021-04-23T19:18:12.000Z | 2021-04-23T19:18:12.000Z | VGP332/HelloFSM/GameState.cpp | CyroPCJr/OmegaEngine | 65fbd6cff54266a9c934e3a875a4493d26758661 | [
"MIT"
] | null | null | null | VGP332/HelloFSM/GameState.cpp | CyroPCJr/OmegaEngine | 65fbd6cff54266a9c934e3a875a4493d26758661 | [
"MIT"
] | 1 | 2021-06-15T10:42:08.000Z | 2021-06-15T10:42:08.000Z | #include "GameState.h"
#include "Cat.h"
#include <ImGui\Inc\imgui.h>
using namespace FSM;
using namespace Omega::Graphics;
void GameState::Initialize()
{
GraphicsSystem::Get()->SetClearColor(Colors::Black);
mCat.Load();
}
void GameState::Terminate()
{
mCat.UnLoad();
}
void GameState::Update(float deltaTime)
{
mCat.Update(deltaTime);
}
void GameState::Render()
{
}
void GameState::DebugUI()
{
} | 13 | 54 | 0.651584 | CyroPCJr |
2e455fd48065ee06527188f5d5f5c63615e16591 | 2,201 | cpp | C++ | DBManager/DBManager.cpp | Zilib/SimpleDatabaseManager | da6e775855d7fdf99935a9991921a6c61666732d | [
"MIT"
] | null | null | null | DBManager/DBManager.cpp | Zilib/SimpleDatabaseManager | da6e775855d7fdf99935a9991921a6c61666732d | [
"MIT"
] | null | null | null | DBManager/DBManager.cpp | Zilib/SimpleDatabaseManager | da6e775855d7fdf99935a9991921a6c61666732d | [
"MIT"
] | null | null | null | #include "database.h"
#include "Menu.h"
#include <Windows.h>
void ShowHeader(Poll* pPoll)
{
// static header, which will always showed
std::cout << pPoll->Title << std::endl;
std::cout << pPoll->Description << std::endl;
}
void ShowPolls(Database* PollDB)
{
int ArrayIndex{ 1 };
for(auto& Poll: PollDB->GetPolls())
{
if (ArrayIndex % 5 != 5) { std::cout << ArrayIndex++ << ". " << Poll.Title << "\t"; }
else if (ArrayIndex % 5 == 5) { std::cout << ArrayIndex++ << ". " << Poll.Title << std::endl; }
}
}
void SelectPoll(Database* PollDB,Poll& Poll)
{
std::cout << std::endl << std::endl;
std::cout << "Make your choice, which poll you want to answer for\n";
short int Choose;
std::cin >> Choose;
while (Choose > PollDB->GetPolls().size() || Choose <= 0) // TODO check does user input an character
{
std::cout << "Bad number\nPlease input number again!: ";
std::cin.clear();
std::cin.ignore();
std::cin >> Choose;
}
// Save a copy of object
Poll = PollDB->GetPolls()[Choose-1];
// Release memory, remove every other polls. Not necessary to do, but i know. I will not use other polls anymore
PollDB->DestroyPolls();
}
void LoadAnswersToVariables(Poll* pPoll)
{
for (auto* Question : pPoll->Questions)
{
Question->ShowContent();
Question->AnswerForQuestion(); // Load data into variable
}
}
// Send whenever customer answer for every question.
void SendAnswersToDatabase(Poll* pPoll,Database* DB)
{
for (auto* Question : pPoll->Questions)
{
DB->InsertUserAnswer(Question, pPoll->Id);
}
}
int main()
{
Database* MyDB = new Database;
Menu* pMenu = new Menu;
Poll Poll;
::Poll *pPoll{&Poll};
if(MyDB->ConstructObject())
{
/// Now database is selected, everything is fine so we can work!
char InputChoice = pMenu->ChooseChar();
while(InputChoice != '1' && InputChoice != '2')
{
InputChoice = pMenu->ChooseChar();
}
system("cls");
if(InputChoice == '1')
{
ShowPolls(MyDB);
SelectPoll(MyDB,Poll);
if(MyDB->LoadPollQuestions(Poll.Id, Poll.Questions))
{
LoadAnswersToVariables(pPoll);
SendAnswersToDatabase(pPoll, MyDB);
}
}
else if (InputChoice == '2')
{
MyDB->CreatePoll();
}
}
return 0;
}
| 22.927083 | 113 | 0.645616 | Zilib |
2e45680cfd0f33acd98b3686c71e4354c334eba6 | 28,398 | cc | C++ | scene_game.cc | kawa-yoiko/Fireflies-And-Forest-Flowers | 4bf2e0cbcace7e9b9b2d1264eed6ad9944c3765e | [
"CC-BY-4.0"
] | 1 | 2022-02-06T04:47:26.000Z | 2022-02-06T04:47:26.000Z | scene_game.cc | kawa-yoiko/Fireflies-And-Forest-Flowers | 4bf2e0cbcace7e9b9b2d1264eed6ad9944c3765e | [
"CC-BY-4.0"
] | null | null | null | scene_game.cc | kawa-yoiko/Fireflies-And-Forest-Flowers | 4bf2e0cbcace7e9b9b2d1264eed6ad9944c3765e | [
"CC-BY-4.0"
] | null | null | null | #include "main.hh"
#include "utils.hh"
#include <cstdio>
#include <utility>
#include <vector>
static inline bool seg_intxn(
const vec2 a, const vec2 b,
const vec2 c, const vec2 d
) {
return (c - a).det(b - a) * (d - a).det(b - a) <= 0 &&
(a - c).det(d - c) * (b - c).det(d - c) <= 0;
}
class scene_game : public scene {
public:
// ==== Display-related constants ====
static constexpr float BOARD_W = 20;
static constexpr float BOARD_H = 12;
static constexpr float SCALE = 35;
static rl::Vector2 scr(vec2 p) {
vec2 q = p * SCALE + vec2(W, H) / 2;
return (rl::Vector2){q.x, q.y};
}
static vec2 board(float x, float y) {
return (vec2(x, y) - vec2(W, H) / 2) / SCALE;
}
static const int STEPS = 480;
// ==== Tracks ====
struct track {
vec2 o;
float len; // Total length in units
enum {
ATTRACT = (1 << 0),
RETURN = (1 << 1),
COLLI = ATTRACT | RETURN,
FIXED = (1 << 4),
};
unsigned flags;
bool sel; // Is selected
track() { }
track(vec2 o, float len, unsigned flags)
: o(o), len(len),
flags(flags),
sel(false)
{ }
virtual ~track() { }
// Local position at given phase
virtual vec2 local_at(float t) const = 0;
vec2 at(float t) const { return local_at(t) + o; }
// Phase of nearest point on path, given a local point
// Returns <phase, distance>
virtual std::pair<float, float> local_nearest(vec2 p) const = 0;
std::pair<float, float> nearest(vec2 p) const { return local_nearest(p - o); }
virtual void draw(int T) const = 0;
inline rl::Color tint() const {
rl::Color t = (rl::Color){128, 128, 128, 255};
if (flags & ATTRACT) t = (rl::Color){136, 136, 64, 255};
if (flags & RETURN) t = (rl::Color){160, 96, 216, 255};
if (sel) {
t.r = 255 - (255 - t.r) / 2;
t.g = 255 - (255 - t.g) / 2;
t.b = 255 - (255 - t.b) / 2;
}
/*if (flags & FIXED) {
t.r = t.r * 2/3;
t.g = t.g * 2/3;
t.b = t.b * 2/3;
}*/
return t;
}
inline void ripples(int T, float &dist, float &alpha) const {
if (flags & RETURN) {
float phase = (float)((T + 450) % 900) / 600;
if (phase < 1) {
dist = (1 - powf(1 - phase, 4)) * 0.26;
alpha = (13 * expf(-4 * phase) * sin(phase) * (1 - phase)) * 0.6;
}
}
if (flags & ATTRACT) {
float phase = (float)(T % 900) / 600;
if (phase < 1) {
dist = powf(1 - phase, 4) * 0.26;
alpha = (19 * expf(-5.9 * phase) * sin(phase) * (1 - phase)) * 0.6;
}
}
}
};
static inline rl::Color premul_alpha(rl::Color tint, float alpha) {
return (rl::Color){
(unsigned char)(tint.r * alpha),
(unsigned char)(tint.g * alpha),
(unsigned char)(tint.b * alpha),
(unsigned char)(tint.a * alpha),
};
}
struct track_cir : public track {
float r; // Radius
float fix_angle; // Angle at which the fix mark is displayed
int fix_count; // Number of fix marks
track_cir(vec2 o, float r, unsigned flags = 0,
float fix_angle = 0, int fix_count = 2)
: r(r), fix_angle(fix_angle), fix_count(fix_count),
track(o, 2 * M_PI * r, flags)
{ }
vec2 local_at(float t) const { return vec2(r, 0).rot(t / r); }
std::pair<float, float> local_nearest(vec2 p) const {
float a = atan2f(p.y, p.x);
if (a < 0) a += 2 * M_PI;
return {a * r, (p - vec2(r, 0).rot(a)).norm()};
}
void draw(int T) const {
using namespace rl;
float w = (flags & FIXED) ? 2 : 2;
DrawRing(scr(o),
r * SCALE - w / 2, r * SCALE + w / 2,
0, 360, 24 * (r < 1 ? 1 : r), tint());
if (flags & FIXED) {
float angle = fix_angle;
vec2 p = vec2(r, 0).rot(angle);
vec2 move = vec2(0.13, 0).rot(angle - 1.0);
DrawLineEx(scr(o + p - move), scr(o + p + move), 2, tint());
if (fix_count != 1)
DrawLineEx(scr(o - p - move), scr(o - p + move), 2, tint());
}
float dist = 0, alpha = 0;
ripples(T, dist, alpha);
if (alpha > 0) {
DrawRing(scr(o),
(r + dist) * SCALE - w / 2,
(r + dist) * SCALE + w / 2,
0, 360, 48, premul_alpha(tint(), alpha));
if (r > dist) DrawRing(scr(o),
(r - dist) * SCALE - w / 2,
(r - dist) * SCALE + w / 2,
0, 360, 48, premul_alpha(tint(), alpha));
}
}
};
struct track_seg : public track {
vec2 ext; // Extension on both sides
track_seg(vec2 o, vec2 ext, unsigned flags = 0)
: ext(ext / ext.norm()),
track(o, ext.norm() * 2, flags)
{ }
vec2 local_at(float t) const { return ext * (t - len / 2); }
std::pair<float, float> local_nearest(vec2 p) const {
float t = p.dot(ext);
t = (t < -len / 2 ? -len / 2 : (t > len / 2 ? len / 2 : t));
return {t + len / 2, (p - (ext * t)).norm()};
}
void draw(int T) const {
using namespace rl;
DrawLineEx(
scr(o - ext * len / 2), scr(o + ext * len / 2),
2, tint());
vec2 n = (ext / ext.norm()).rot(M_PI / 2);
if (flags & FIXED) {
for (vec2 endpt : {(o - ext * len / 2), (o + ext * len / 2)}) {
DrawLineEx(
scr(endpt - n * 0.1), scr(endpt + n * 0.1),
2, tint());
}
}
float dist = 0, alpha = 0;
ripples(T, dist, alpha);
if (alpha > 0) {
vec2 move = n * dist;
DrawLineEx(
scr(o + move - ext * len / 2), scr(o + move + ext * len / 2),
2, premul_alpha(tint(), alpha));
DrawLineEx(
scr(o - move - ext * len / 2), scr(o - move + ext * len / 2),
2, premul_alpha(tint(), alpha));
}
}
};
// ==== Fireflies ===
struct firefly {
// Position (track + phase)
const track *tr;
float t;
inline vec2 pos() const { return tr->at(t); }
float v; // Velocity
bool sel; // Selected?
static const int TRAIL_N = 20;
static const int TRAIL_I = 8;
vec2 trail[TRAIL_N];
firefly(const track *tr, float t, float v)
: tr(tr), t(t), v(v),
sel(false)
{ }
inline void update(const std::vector<track *> &tracks) {
float t_prev = t;
vec2 p1 = pos();
t += v / STEPS;
if (t >= tr->len) t -= tr->len;
if (t < 0) t += tr->len;
vec2 p2 = pos();
// Attracting tracks
for (const auto tr : tracks) if (tr != this->tr && (tr->flags & track::COLLI)) {
auto near = tr->nearest(p1);
if (near.second >= 0.01) continue;
float t1 = near.first;
float t2 = tr->nearest(p2).first;
if (fabs(t1 - t2) < 1e-6) {
float d = (t1 < 1 ? 1e-6 : (t1 * 1e-6));
t1 -= d;
t2 += d;
}
// Lemma: (p1, p2) crosses the curve C iff
// (p1, p2) crosses (C(t1), C(t2))
if (seg_intxn(p1, p2, tr->at(t1), tr->at(t2))) {
// Point of intersection
if (tr->flags & track::ATTRACT) {
// Move to the new track
this->tr = tr;
// Take the later parameter to avoid recursion
this->t = t2;
// Reverse if making acute turns
if (this->v * (t2 - t1) < 0) this->v = -this->v;
}
if (tr->flags & track::RETURN) {
/*
printf("p1 = (%f, %f)\n", p1.x, p1.y);
printf("p2 = (%f, %f)\n", p2.x, p2.y);
printf("tr->at(t1) = (%f, %f)\n", tr->at(t1).x, tr->at(t1).y);
printf("tr->at(t2) = (%f, %f)\n", tr->at(t2).x, tr->at(t2).y);
*/
this->t = t_prev;
this->v = -this->v;
}
break;
}
}
}
inline void draw(int offs) const {
using namespace rl;
Color tint = (sel ?
(Color){255, 64, 64, 255} :
(Color){255, 255, 16, 255});
float alpha = 1.0/8 * (v < 1 ? 1 : v);
Color fade = (Color){
(unsigned char)(tint.r * alpha),
(unsigned char)(tint.g * alpha),
(unsigned char)(tint.b * alpha),
(unsigned char)(tint.a * alpha)
};
DrawCircleV(scr(pos()), 4, tint);
for (int i = 0; i < TRAIL_N; i++) {
vec2 p = trail[(i + offs) % TRAIL_N];
DrawCircleV(scr(p), 4 - (float)i / TRAIL_N * 2, fade);
}
}
struct trail_manager {
std::vector<firefly> &fireflies;
int counter = 0;
int pointer = 0;
trail_manager(std::vector<firefly> &fireflies)
: fireflies(fireflies),
counter(0), pointer(0)
{ }
void reset() {
counter = pointer = 0;
}
void recalc_init() {
for (auto &f : fireflies) {
for (int i = 0; i < TRAIL_N; i++)
f.trail[i] = f.tr->at(f.t - f.v * (float(TRAIL_I) / STEPS) * i);
}
}
void step() {
if (++counter == TRAIL_I) {
counter = 0;
pointer = (pointer + (TRAIL_N - 1)) % TRAIL_N;
for (firefly &f : fireflies)
f.trail[pointer] = f.pos();
}
}
};
};
// ==== Bellflowers ====
struct bellflower {
vec2 o;
float r;
int c0, c; // Initial count and current count
bellflower(vec2 o, float r, int c0)
: o(o), r(r), c0(c0)
{
reset();
}
virtual ~bellflower() { }
bool last_on;
int since_on, since_off;
virtual void reset() {
last_on = false;
since_on = since_off = 9999;
c = c0;
}
void update(bool on) {
since_on++;
since_off++;
if (!last_on && on) { c--; since_on = 0; }
if (last_on && !on) since_off = 0;
last_on = on;
}
void update_anim_only() {
since_on++;
since_off++;
}
virtual void update(const std::vector<firefly> &fireflies) = 0;
virtual void draw1(int finish_anim) const { }
virtual void draw2(int finish_anim) const { }
inline bool fireflies_within(const std::vector<firefly> &fireflies) {
for (const auto f : fireflies)
if ((f.pos() - o).norm() <= r) return true;
return false;
}
inline float tint() const {
float t_on = since_on / 480.0f;
float t_off = since_off / 480.0f;
if (last_on) {
if (t_on >= 0.2) return 1;
return t_on * 5;
} else {
if (t_off >= 0.2) return 0;
return (0.2 - t_off) * 5;
}
}
};
struct bellflower_ord : public bellflower {
bellflower_ord(vec2 o, float r, int c0)
: bellflower(o, r, c0)
{ }
void update(const std::vector<firefly> &fireflies) {
bool on = fireflies_within(fireflies);
bellflower::update(on);
}
void draw1(int finish_anim) const {
using namespace rl;
Vector2 cen = scr(o);
float t = tint();
if (finish_anim >= 0) {
float tf = finish_anim / 480.0f;
t *= (tf > 0.5 ? 0 : 1 - sqrtf(tf * 2));
}
Color off = (Color){32, 60, 96, 80};
Color on = (Color){96, 96, 64, 80};
DrawCircleV(cen, r * SCALE, (Color){
(unsigned char)(off.r + (float)(on.r - off.r) * t),
(unsigned char)(off.g + (float)(on.g - off.g) * t),
(unsigned char)(off.b + (float)(on.b - off.b) * t),
80
});
}
void draw2(int finish_anim) const {
using namespace rl;
Vector2 cen = scr(o);
float t = since_on / 960.0f;
float scale = 1;
if (t < 2) scale = 1 + 0.15 * expf(-t) * sinf(t * 8) * (2 - t);
float alpha = 0.85 + (0.15 * tint());
if (c == 0) alpha = 1 - (1 - alpha) * 0.3;
if (finish_anim >= 0) {
float tf = finish_anim / 480.0f;
alpha = alpha + (1 - alpha) * (tf > 0.5 ? 1 : sqrtf(tf * 2));
const float A = 0.3;
const float B = A + 0.3;
const float C = B + 2;
if (tf >= A && tf < B) {
scale *= 0.7 + 0.3 * expf(-(tf - A) * 25) * ((B - tf) / (B - A));
} else if (tf >= B && tf < C) {
float t = tf - B;
scale *= 1.0 - 0.3 * (expf(-20 * t) - expf(-5 * t) * sinf(24 * t)) * ((C - tf) / (C - B));
}
}
painter::image(
c == 0 ? "bellflower_call" : "bellflower_ord",
vec2(cen.x - 42, cen.y - 66 * scale),
vec2(80, 80 * scale),
tint4(alpha, alpha, alpha, alpha));
char s[8];
snprintf(s, sizeof s, "%d", c);
painter::text(s, 32, vec2(cen.x, cen.y + 20), vec2(0.5, 0.5),
tint4(0.8, 0.8, 0.8, 0.6));
}
};
struct bellflower_delay : public bellflower {
int d, d0;
bellflower_delay(vec2 o, float r, int c0, float d0)
: bellflower(o, r, c0), d0(d0 * STEPS)
{ reset(); }
void reset() {
bellflower::reset();
d = d0;
}
void update(const std::vector<firefly> &fireflies) {
bool on = fireflies_within(fireflies);
if (on) {
if (d > 0) d--;
} else {
d = d0;
}
bellflower::update(d == 0);
}
void draw1(int finish_anim) const {
using namespace rl;
DrawRing(scr(o), r * SCALE - 1, r * SCALE + 1, 0, 360, 48, (Color){64, 64, 64, 128});
DrawCircleV(scr(o), 0.5 * SCALE, GRAY);
DrawCircleV(scr(o), 0.5 * SCALE * (d0 - d) / d0, GREEN);
char s[8];
snprintf(s, sizeof s, "%d", c);
DrawText(s, scr(o).x - 4, scr(o).y - 8, 16, BLACK);
}
};
// ==== Scene ====
int T; // Update counter. Overflows after 51 days but whatever
struct tutorial {
vec2 pos;
const char *text;
vec2 cir;
float cir_radius;
};
int puzzle_id;
const char *title;
std::vector<track *> tracks;
std::vector<firefly> fireflies, fireflies_init;
std::vector<bellflower *> bellflowers;
std::vector<std::vector<std::pair<firefly *, float>>> ff_links;
std::vector<tutorial> tutorials;
int to_text;
firefly::trail_manager trail_m;
int tut_show_start, tut_show_end;
int tut_show_time, tut_hide_time;
firefly *sel_ff;
track *sel_track;
vec2 sel_offs;
int run_state = (8 << 1); // Initial speed 8 steps/update
int finish_timer = -1;
const float RT_SCALE = 2; // Scaling factor for render targets
rl::RenderTexture2D texBloomBase, texBloomStage1, texBloomStage2;
rl::Shader shaderBloom;
int shaderBloomPassLoc;
rl::Shader shaderSpotlight;
int shaderSpotlightCenLoc, shaderSpotlightRadLoc;
static const int BG_TREES_N = 25;
struct {
vec2 pos;
float rot_cen, rot_amp, rot_period;
float tint;
} trees[BG_TREES_N];
button_group buttons;
scene_game(int puzzle_id)
: T(0),
puzzle_id(puzzle_id),
sel_ff(nullptr), sel_track(nullptr),
trail_m(fireflies)
{
using button = button_group::button;
buttons.buttons = {(button){
vec2(10, 10), vec2(60, 60),
nullptr, // Will be filled later
[this]() { this->btn_play(); }
}, (button){
vec2(10, 80), vec2(60, 60),
nullptr,
[this]() { this->btn_speed(); }
}};
update_buttons_images();
to_text = -1;
std::vector<std::vector<int>> links;
switch (puzzle_id) {
#define T_cir new track_cir
#define T_seg new track_seg
#define B_ord new bellflower_ord
#define B_delay new bellflower_delay
#define F(_i, _t, ...) \
firefly(tracks[_i], tracks[_i]->len * (_t), __VA_ARGS__)
#include "puzzles.hh"
}
build_links(links);
trail_m.recalc_init();
tut_show_start = 0;
update_tut_show_range(true);
tut_hide_time = -1;
texBloomBase = rl::LoadRenderTexture(W * RT_SCALE, H * RT_SCALE);
rl::SetTextureFilter(texBloomBase.texture, rl::TEXTURE_FILTER_BILINEAR);
texBloomStage1 = rl::LoadRenderTexture(W * RT_SCALE, H * RT_SCALE);
rl::SetTextureFilter(texBloomStage1.texture, rl::TEXTURE_FILTER_BILINEAR);
texBloomStage2 = rl::LoadRenderTexture(W * RT_SCALE, H * RT_SCALE);
rl::SetTextureFilter(texBloomStage2.texture, rl::TEXTURE_FILTER_BILINEAR);
#ifdef PLATFORM_WEB
shaderBloom = rl::LoadShader("res/bloom_web.vert", "res/bloom_web.frag");
shaderSpotlight = rl::LoadShader("res/spotlight_web.vert", "res/spotlight_web.frag");
#else
shaderBloom = rl::LoadShader("res/bloom.vert", "res/bloom.frag");
shaderSpotlight = rl::LoadShader("res/spotlight.vert", "res/spotlight.frag");
#endif
shaderBloomPassLoc = rl::GetShaderLocation(shaderBloom, "pass");
shaderSpotlightCenLoc = rl::GetShaderLocation(shaderSpotlight, "spotCen");
shaderSpotlightRadLoc = rl::GetShaderLocation(shaderSpotlight, "spotRadius");
unsigned seed = 20220128;
for (const char *s = title; *s != '\0'; s++)
seed = (seed * 997 + *s);
for (int i = 0; i < BG_TREES_N; i++) {
unsigned rands[5];
for (int j = 0; j < 5; j++) {
seed = (seed * 1103515245 + 12345) & 0x7fffffff;
rands[j] = seed;
}
trees[i] = {
.pos = vec2(rands[0] % W, rands[1] % H),
.rot_cen = (float)rands[2] / 0x7fffffff * (float)M_PI * 2,
.rot_amp = 0.05f + (float)rands[3] / 0x7fffffff * 0.05f,
.rot_period = 1200 + 1200 * (float)((rands[4] >> 8) % 256) / 256,
.tint = (192 + ((rands[4] >> 16) % 32)) / 255.0f,
};
}
for (int it = 0; it < 1000; it++) {
for (int i = 0; i < BG_TREES_N; i++) {
vec2 move = vec2(0, 0);
for (int j = 0; j < BG_TREES_N; j++) if (j != i) {
vec2 d = (trees[i].pos - trees[j].pos);
if (d.norm() < 240)
move = move + d / d.norm() * (240 - d.norm());
}
trees[i].pos = trees[i].pos + move * 0.01;
if (trees[i].pos.x < 0) trees[i].pos.x /= 2;
if (trees[i].pos.x > W) trees[i].pos.x -= (trees[i].pos.x - W) / 2;
if (trees[i].pos.y < 0) trees[i].pos.y /= 2;
if (trees[i].pos.y > H) trees[i].pos.y -= (trees[i].pos.y - H) / 2;
}
}
}
~scene_game() {
rl::UnloadRenderTexture(texBloomBase);
rl::UnloadRenderTexture(texBloomStage1);
rl::UnloadRenderTexture(texBloomStage2);
rl::UnloadShader(shaderBloom);
for (auto t : tracks) delete t;
for (auto b : bellflowers) delete b;
}
inline void build_links(std::vector<std::vector<int>> links) {
ff_links.clear();
ff_links.resize(fireflies.size());
for (const auto group : links) {
for (const auto indep : group) {
auto &list = ff_links[indep];
float t = fireflies[indep].t;
list.reserve(group.size() - 1);
for (const auto dep : group) if (dep != indep) {
bool is_reverse = (fireflies[indep].v * fireflies[dep].v < 0);
float diff = (is_reverse ? fireflies[dep].t + t : fireflies[dep].t - t);
list.push_back({&fireflies[dep], diff});
}
}
}
}
inline bool tut_has_next() const {
return (tut_show_start < tutorials.size() &&
tutorials[tut_show_end - 1].cir_radius != 0);
}
inline void update_tut_show_range(bool always = false) {
if (!always && !tut_has_next()) return;
for (tut_show_end = tut_show_start;
tut_show_end < tutorials.size(); tut_show_end++)
if (tutorials[tut_show_end].cir_radius != 0) {
tut_show_end++;
break;
}
tut_show_time = T;
}
inline std::pair<firefly *, track *> find(const vec2 p) {
// Find the nearest firefly
firefly *best_ff = nullptr;
float best_dist = 0.75;
for (auto &f : fireflies) {
float dist = (p - f.pos()).norm();
if (dist < best_dist) {
best_dist = dist;
best_ff = &f;
}
}
if (best_ff != nullptr) return {best_ff, nullptr};
// Find the nearest firefly track
track *best_track = nullptr;
std::pair<float, float> best_result = {0, 0.5};
for (const auto t : tracks) if (!(t->flags & track::FIXED)) {
auto result = t->nearest(p);
if (result.second < best_result.second) {
best_result = result;
best_track = t;
}
}
return {nullptr, best_track};
}
void pton(float x, float y) {
if (tut_has_next()) return;
if (buttons.pton(x, y)) return;
if (run_state & 1) return;
vec2 p = board(x, y);
auto near = find(p);
if (near.first != nullptr) {
sel_ff = near.first;
sel_ff->sel = true;
sel_offs = sel_ff->pos() - p;
}
if (near.second != nullptr) {
sel_track = near.second;
sel_track->sel = true;
sel_offs = sel_track->o - p;
}
}
void ptmove(float x, float y) {
if (tut_has_next()) return;
if (buttons.ptmove(x, y)) return;
vec2 p = board(x, y);
if (sel_ff != nullptr) {
sel_ff->t = sel_ff->tr->nearest(p + sel_offs).first;
// Move linked fireflies
int index = sel_ff - &fireflies[0];
for (const auto link : ff_links[index]) {
link.first->t =
(link.first->v * sel_ff->v < 0) ?
link.second - sel_ff->t :
link.second + sel_ff->t;
}
trail_m.recalc_init();
}
if (sel_track != nullptr) {
sel_track->o = p + sel_offs;
trail_m.recalc_init();
}
}
void ptoff(float x, float y) {
if (tut_has_next()) {
if (tut_hide_time == -1) tut_hide_time = T;
}
if (buttons.ptoff(x, y)) return;
if (sel_ff != nullptr) {
sel_ff->sel = false;
sel_ff = nullptr;
}
if (sel_track != nullptr) {
sel_track->sel = false;
sel_track = nullptr;
}
}
// Button callbacks
void btn_play() {
if (finish_timer >= 0) return;
run_state ^= 1;
if (run_state & 1) start_run(); else stop_run();
}
void btn_speed() {
if (finish_timer >= 0) return;
if ((run_state >> 1) == 8)
run_state = (32 << 1) | (run_state & 1);
else
run_state = (8 << 1) | (run_state & 1);
update_buttons_images();
}
inline void update_buttons_images() {
buttons.buttons[0].image = ((run_state & 1) ? "btn_stop" : "btn_play");
buttons.buttons[1].image = ((run_state >> 1) == 8 ? "btn_1x" : "btn_2x");
}
inline void start_run() {
// Save
fireflies_init = fireflies;
update_buttons_images();
}
inline void stop_run() {
fireflies = fireflies_init;
for (auto b : bellflowers) b->reset();
trail_m.reset();
update_buttons_images();
}
bool last_space_down = false;
bool last_tab_down = false;
void update() {
T++;
if (finish_timer >= 0) finish_timer++;
if (tut_hide_time >= 0 && T == tut_hide_time + 60) {
tut_hide_time = -1;
tut_show_start = tut_show_end;
update_tut_show_range();
}
bool space_down = rl::IsKeyDown(rl::KEY_SPACE);
if (sel_track == nullptr &&
finish_timer == -1 &&
!last_space_down && space_down) {
run_state ^= 1;
if (run_state & 1) start_run(); else stop_run();
}
last_space_down = space_down;
bool tab_down = rl::IsKeyDown(rl::KEY_TAB);
if (finish_timer == -1 &&
!last_tab_down && tab_down) {
btn_speed();
}
last_tab_down = tab_down;
if (run_state & 1) for (int i = 0; i < (run_state >> 1); i++) {
for (auto &f : fireflies) f.update(tracks);
trail_m.step();
// No bellflowers are changed after finish
if (finish_timer == -1)
for (auto b : bellflowers) b->update(fireflies);
else
for (auto b : bellflowers) b->update_anim_only();
// Check for finish
if (finish_timer == -1) {
bool finish = true;
for (auto b : bellflowers)
if (b->c != 0) { finish = false; break; }
if (finish) {
finish_timer = 0;
run_state = (8 << 1) | 1; // Back to normal speed
}
}
}
if (finish_timer == 960) {
if (to_text != -1)
replace_scene(scene_text(to_text));
else
replace_scene(new scene_game(puzzle_id + 1));
}
}
void draw() {
using namespace rl;
ClearBackground((Color){5, 8, 1, 255});
// Background
for (int i = 0; i < BG_TREES_N; i++) {
int id = i % 4;
float rot = trees[i].rot_cen + trees[i].rot_amp *
sinf((float)T / trees[i].rot_period * M_PI * 2);
float tint = trees[i].tint;
if (finish_timer >= 360 + 1.2 * 240) {
float x = (finish_timer - (360 + 1.2 * 240)) / (0.5 * 240.0f);
if (x > 1) x = 1; else x = 1 - (1 - x) * (1 - x);
tint = tint + (1 - tint) * x * 0.95;
}
painter::image("board_bg",
trees[i].pos,
vec2(240, 240),
vec2(i % 4 * 240, 0),
vec2(240, 240),
vec2(120, 120),
rot,
tint4(tint, tint, tint));
}
// Rule grid
int x_range = (W / 2 / SCALE) + 1;
for (int i = -x_range; i <= x_range; i++) {
float x = scr(vec2(i, 0)).x;
DrawLineV((Vector2){x, 0}, (Vector2){x, H}, (Color){30, 30, 30, 255});
}
int y_range = (H / 2 / SCALE) + 1;
for (int i = -y_range; i <= y_range; i++) {
float y = scr(vec2(0, i)).y;
DrawLineV((Vector2){0, y}, (Vector2){W, y}, (Color){30, 30, 30, 255});
}
// Render scaled to texture
BeginBlendMode(BLEND_ADD_COLORS);
Color bg = (Color){0, 0, 0, 0};
BeginTextureMode(texBloomBase);
BeginMode2D((Camera2D){(Vector2){0, 0}, (Vector2){0, 0}, 0, RT_SCALE});
ClearBackground(bg);
for (const auto t : tracks) t->draw(T);
for (const auto &f : fireflies) f.draw(trail_m.pointer);
EndMode2D();
EndTextureMode();
int pass;
BeginTextureMode(texBloomStage1);
BeginMode2D((Camera2D){(Vector2){0, 0}, (Vector2){0, 0}, 0, RT_SCALE});
pass = 1;
SetShaderValue(shaderBloom, shaderBloomPassLoc, &pass, SHADER_UNIFORM_INT);
BeginShaderMode(shaderBloom);
ClearBackground(bg);
DrawTexturePro(texBloomBase.texture,
(Rectangle){0, 0, W * RT_SCALE, -H * RT_SCALE},
(Rectangle){0, 0, W, H},
(Vector2){0, 0}, 0, WHITE);
EndShaderMode();
EndMode2D();
EndTextureMode();
BeginTextureMode(texBloomStage2);
BeginMode2D((Camera2D){(Vector2){0, 0}, (Vector2){0, 0}, 0, RT_SCALE});
pass = 2;
SetShaderValue(shaderBloom, shaderBloomPassLoc, &pass, SHADER_UNIFORM_INT);
BeginShaderMode(shaderBloom);
ClearBackground(bg);
DrawTexturePro(texBloomStage1.texture,
(Rectangle){0, 0, W * RT_SCALE, -H * RT_SCALE},
(Rectangle){0, 0, W, H},
(Vector2){0, 0}, 0, WHITE);
EndShaderMode();
EndMode2D();
EndTextureMode();
EndBlendMode();
int finish_anim = -1;
if (finish_timer >= 360)
finish_anim = finish_timer - 360;
for (const auto b : bellflowers) b->draw1(finish_anim);
DrawTexturePro(texBloomBase.texture,
(Rectangle){0, 0, W * RT_SCALE, -H * RT_SCALE},
(Rectangle){0, 0, W, H},
(Vector2){0, 0}, 0, (Color){255, 255, 255, 160});
DrawTexturePro(texBloomStage2.texture,
(Rectangle){0, 0, W * RT_SCALE, -H * RT_SCALE},
(Rectangle){0, 0, W, H},
(Vector2){0, 0}, 0, WHITE);
for (const auto b : bellflowers) b->draw2(finish_anim);
// Tutorials
float tut_alpha = 1;
if (tut_hide_time >= 0) {
tut_alpha = 1 - (float)(T - tut_hide_time) / 60;
} else if (T - tut_show_time < 60) {
tut_alpha = (float)(T - tut_show_time) / 60;
}
if (tut_has_next()) {
const auto &t = tutorials[tut_show_end - 1];
float spotlightCen[2] = {scr(t.cir).x, scr(t.cir).y};
float spotlightRadius = t.cir_radius * SCALE
- 20 * (1 - tut_alpha) * (1 - tut_alpha);
SetShaderValue(shaderSpotlight, shaderSpotlightCenLoc,
spotlightCen, SHADER_UNIFORM_VEC2);
SetShaderValue(shaderSpotlight, shaderSpotlightRadLoc,
&spotlightRadius, SHADER_UNIFORM_FLOAT);
BeginShaderMode(shaderSpotlight);
DrawRectangle(0, 0, W, H,
(Color){255, 255, 255, (unsigned char)(255 * tut_alpha)});
EndShaderMode();
}
for (int i = tut_show_start; i < tut_show_end; i++) {
const auto &t = tutorials[i];
painter::text(t.text, 32,
vec2(scr(t.pos).x, scr(t.pos).y),
vec2(0.5, 0.5), tint4(0.6, 0.6, 0.6, tut_alpha));
}
// Buttons
buttons.draw();
// Title
char title_text[64];
snprintf(title_text, sizeof title_text,
"%02d. %s", puzzle_id, title);
painter::text(title_text, 36,
vec2(20, H - 20),
vec2(0, 1), tint4(0.9, 0.9, 0.9, 1));
}
};
scene *scene_game(int puzzle_id) {
return new class scene_game(puzzle_id);
}
| 30.050794 | 100 | 0.535249 | kawa-yoiko |
2e4791187e3b5ec0af2233dfaabad323952be920 | 773 | cpp | C++ | algospot/QUADTREE.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | algospot/QUADTREE.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | algospot/QUADTREE.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | #include <iostream>
#include <cstring>
#define MAXTREESIZE 4
using namespace std;
typedef struct TreeNode
{
char color;
struct TreeNode* link[MAXTREESIZE]; // 0:left-top 1:right-top 2:left-bottom 3:right-bottom
}TreeNode;
void AddTreeNode(char color)
{
TreeNode* newnode = CreateNode(color);
}
TreeNode* CreateNode(char color)
{
TreeNode* newnode = (TreeNode*)malloc(sizeof(TreeNode));
newnode->color = color;
for (int i = 0; i < MAXTREESIZE; i++)
newnode->link[i] == NULL;
return newnode;
}
int main()
{
TreeNode* Root;
char compress[1000];
int len;
int cnt = 0;
int level = 0;
cin >> compress;
len = strlen(compress);
for (int i = 0; i < len; i++)
{
if (compress[i] == 'w' || compress[i] == 'b')
AddTreeNode(compress[i]);
}
return 0;
}
| 16.804348 | 91 | 0.658473 | Twinparadox |
2e494fb5feb5c2d19635e49db8fc6ce5ffc4af19 | 635 | cc | C++ | vos/gui/sub/gui/si_save/SiSaveComponentCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 16 | 2020-10-21T05:56:26.000Z | 2022-03-31T10:02:01.000Z | vos/gui/sub/gui/si_save/SiSaveComponentCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | null | null | null | vos/gui/sub/gui/si_save/SiSaveComponentCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 2 | 2021-03-09T01:51:08.000Z | 2021-03-23T00:23:24.000Z | ////////////////////////////////////////////////////////////////
// SiSaveComponentCmd.h: Command class for any component within
// the SiSaveCmdInterface; all it does is tell the SCI to do its
// thing. Used for simple creation of Option menus.
////////////////////////////////////////////////////////////////
#include "SiSaveComponentCmd.h"
#include "SiSaveCmdInterface.h"
SiSaveComponentCmd::SiSaveComponentCmd(const char *name, int active,
CmdList *radioList, SiSaveCmdInterface *sci)
: RadioCmd(name, active, radioList)
{
_sci = sci;
}
void SiSaveComponentCmd::doit()
{
if (_value) {
_sci->runCommand();
}
}
| 26.458333 | 68 | 0.581102 | NASA-AMMOS |
2e4c85416c7524df5dadf03a5e8999f7f5c064ff | 401 | cpp | C++ | FakeReal/Source/Engine/Render/Buffer/UniformBuffer.cpp | UGEL4/FakeReal | 4ffc39fc500629fd537f688c56d5acdfc34d0b30 | [
"Apache-2.0"
] | null | null | null | FakeReal/Source/Engine/Render/Buffer/UniformBuffer.cpp | UGEL4/FakeReal | 4ffc39fc500629fd537f688c56d5acdfc34d0b30 | [
"Apache-2.0"
] | null | null | null | FakeReal/Source/Engine/Render/Buffer/UniformBuffer.cpp | UGEL4/FakeReal | 4ffc39fc500629fd537f688c56d5acdfc34d0b30 | [
"Apache-2.0"
] | null | null | null | #include "UniformBuffer.h"
#include "../Renderer.h"
#include <assert.h>
#include "../../Platform/OpenGL/Render/Buffer/UniformBuffer_GL.h"
namespace FakeReal {
UniformBuffer* UniformBuffer::Create(unsigned int uiSize, unsigned int uiBinding)
{
switch (Renderer::GetAPI())
{
case RenderAPI::API::OpenGL: return new UniformBuffer_GL(uiSize, uiBinding);
}
assert(0);
return nullptr;
}
}
| 21.105263 | 82 | 0.720698 | UGEL4 |
2e52ef2db0e514d4cd852dc314dd81238e1f0c9d | 1,192 | hpp | C++ | src/tracer/observers/energy_error_observer.hpp | ngc92/branchedflowsim | d38c0e7f892d07d0abd9b63d30570c41b3b83b34 | [
"MIT"
] | null | null | null | src/tracer/observers/energy_error_observer.hpp | ngc92/branchedflowsim | d38c0e7f892d07d0abd9b63d30570c41b3b83b34 | [
"MIT"
] | null | null | null | src/tracer/observers/energy_error_observer.hpp | ngc92/branchedflowsim | d38c0e7f892d07d0abd9b63d30570c41b3b83b34 | [
"MIT"
] | null | null | null | //
// Created by eriks on 4/24/18.
//
#ifndef BRANCHEDFLOWSIM_ENERGY_ERROR_OBSERVER_HPP
#define BRANCHEDFLOWSIM_ENERGY_ERROR_OBSERVER_HPP
#include "observer.hpp"
class EnergyErrorObserver : public ThreadLocalObserver {
public:
/// create an observer and specify the time interval for saving the particle's position
EnergyErrorObserver( std::string file_name = "energy.json" );
/// d'tor
virtual ~EnergyErrorObserver() = default;
// standard observer functions
// for documentation look at observer.hpp
void startTracing() override;
bool watch( const State& state, double t ) override { return false; }
void startTrajectory(const InitialCondition& start, std::size_t trajectory) override;
void endTrajectory(const State& final_state) override;
void save(std::ostream& target) override;
double getMaximumError() const;
double getMeanError() const;
private:
std::shared_ptr<ThreadLocalObserver> clone() const override;
void combine(ThreadLocalObserver& other) override;
double mInitialEnergy;
std::size_t mCount = 0;
double mSum = 0.0;
double mMax = 0.0;
};
#endif //BRANCHEDFLOWSIM_ENERGY_ERROR_OBSERVER_HPP
| 29.073171 | 91 | 0.737416 | ngc92 |
2e5316d8636bb256b2c48ffcf1d5e88c2d7b31ee | 235 | cpp | C++ | src/OpenLoco/GameState.cpp | petergaal/OpenLoco | d915b8b9d2ee2b90e2d7c9b5eae44a6fd01fee2c | [
"MIT"
] | 585 | 2019-02-20T18:32:39.000Z | 2022-03-31T10:59:57.000Z | src/OpenLoco/GameState.cpp | petergaal/OpenLoco | d915b8b9d2ee2b90e2d7c9b5eae44a6fd01fee2c | [
"MIT"
] | 643 | 2019-02-19T19:54:32.000Z | 2022-03-31T12:34:37.000Z | src/OpenLoco/GameState.cpp | petergaal/OpenLoco | d915b8b9d2ee2b90e2d7c9b5eae44a6fd01fee2c | [
"MIT"
] | 84 | 2019-02-19T15:03:14.000Z | 2022-03-30T01:27:02.000Z | #include "GameState.h"
#include "Interop/Interop.hpp"
using namespace OpenLoco::Interop;
namespace OpenLoco
{
loco_global<GameState, 0x00525E18> _gameState;
GameState& getGameState()
{
return *_gameState;
}
}
| 16.785714 | 50 | 0.697872 | petergaal |
2e54a0ab947cd3aa3aeca2011505a741888cf1c3 | 16,840 | cpp | C++ | src/plugins/simulator/physics_engines/dynamics2d/dynamics2d_engine.cpp | freedomcondor/argos3-harry | 10cc040af3d5339538cfd801f0317fa8269429a5 | [
"MIT"
] | null | null | null | src/plugins/simulator/physics_engines/dynamics2d/dynamics2d_engine.cpp | freedomcondor/argos3-harry | 10cc040af3d5339538cfd801f0317fa8269429a5 | [
"MIT"
] | null | null | null | src/plugins/simulator/physics_engines/dynamics2d/dynamics2d_engine.cpp | freedomcondor/argos3-harry | 10cc040af3d5339538cfd801f0317fa8269429a5 | [
"MIT"
] | null | null | null | /**
* @file <argos3/plugins/simulator/physics_engines/dynamics2d/dynamics2d_engine.cpp>
*
* @author Carlo Pinciroli - <ilpincy@gmail.com>
*/
#include "dynamics2d_engine.h"
#include "dynamics2d_model.h"
#include "dynamics2d_gripping.h"
#include <argos3/core/simulator/simulator.h>
#include <argos3/core/simulator/entity/embodied_entity.h>
#include <cmath>
namespace argos {
/****************************************/
/****************************************/
CDynamics2DEngine::CDynamics2DEngine() :
m_fBoxLinearFriction(1.49),
m_fBoxAngularFriction(1.49),
m_fCylinderLinearFriction(1.49),
m_fCylinderAngularFriction(1.49),
m_ptSpace(NULL),
m_ptGroundBody(NULL),
m_fElevation(0.0f) {
}
/****************************************/
/****************************************/
void CDynamics2DEngine::Init(TConfigurationNode& t_tree) {
try {
/* Init parent */
CPhysicsEngine::Init(t_tree);
/* Parse XML */
GetNodeAttributeOrDefault(t_tree, "elevation", m_fElevation, m_fElevation);
if(NodeExists(t_tree, "friction")) {
TConfigurationNode& tNode = GetNode(t_tree, "friction");
GetNodeAttributeOrDefault(tNode, "box_linear_friction", m_fBoxLinearFriction, m_fBoxLinearFriction);
GetNodeAttributeOrDefault(tNode, "box_angular_friction", m_fBoxAngularFriction, m_fBoxAngularFriction);
GetNodeAttributeOrDefault(tNode, "cylinder_linear_friction", m_fCylinderLinearFriction, m_fCylinderLinearFriction);
GetNodeAttributeOrDefault(tNode, "cylinder_angular_friction", m_fCylinderAngularFriction, m_fCylinderAngularFriction);
}
/* Override volume top and bottom with the value of m_fElevation */
if(!GetVolume().TopFace) GetVolume().TopFace = new SHorizontalFace;
if(!GetVolume().BottomFace) GetVolume().BottomFace = new SHorizontalFace;
GetVolume().TopFace->Height = m_fElevation;
GetVolume().BottomFace->Height = m_fElevation;
/* Initialize physics */
cpInitChipmunk();
cpResetShapeIdCounter();
/* Used to attach static geometries so that they won't move and to simulate friction */
m_ptGroundBody = cpBodyNew(INFINITY, INFINITY);
/* Create the space to contain the movable objects */
m_ptSpace = cpSpaceNew();
/* Subiterations to solve constraints.
The more, the better for precision but the worse for speed
*/
m_ptSpace->iterations = GetIterations();
/* Spatial hash */
if(NodeExists(t_tree, "spatial_hash")) {
TConfigurationNode& tNode = GetNode(t_tree, "spatial_hash");
cpFloat fSize;
UInt32 unNum;
GetNodeAttribute(tNode, "cell_size", fSize);
GetNodeAttribute(tNode, "cell_num", unNum);
cpSpaceUseSpatialHash(m_ptSpace, fSize, unNum);
}
/* Gripper-Gripped callback functions */
cpSpaceAddCollisionHandler(
m_ptSpace,
SHAPE_GRIPPER,
SHAPE_GRIPPABLE,
BeginCollisionBetweenGripperAndGrippable,
ManageCollisionBetweenGripperAndGrippable,
NULL,
NULL,
NULL);
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Error initializing the dynamics 2D engine \"" << GetId() << "\"", ex);
}
}
/****************************************/
/****************************************/
void CDynamics2DEngine::Reset() {
for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
it != m_tPhysicsModels.end(); ++it) {
it->second->Reset();
}
cpSpaceReindexStatic(m_ptSpace);
}
/****************************************/
/****************************************/
void CDynamics2DEngine::Update() {
/* Update the physics state from the entities */
for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
it != m_tPhysicsModels.end(); ++it) {
it->second->UpdateFromEntityStatus();
}
/* Perform the step */
for(size_t i = 0; i < GetIterations(); ++i) {
for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
it != m_tPhysicsModels.end(); ++it) {
it->second->UpdatePhysics();
}
cpSpaceStep(m_ptSpace, GetPhysicsClockTick());
}
/* Update the simulated space */
for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
it != m_tPhysicsModels.end(); ++it) {
it->second->UpdateEntityStatus();
}
}
/****************************************/
/****************************************/
void CDynamics2DEngine::Destroy() {
/* Empty the physics model map */
for(CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.begin();
it != m_tPhysicsModels.end(); ++it) {
delete it->second;
}
m_tPhysicsModels.clear();
/* Get rid of the physics space */
cpSpaceFree(m_ptSpace);
cpBodyFree(m_ptGroundBody);
}
/****************************************/
/****************************************/
size_t CDynamics2DEngine::GetNumPhysicsModels() {
return m_tPhysicsModels.size();
}
/****************************************/
/****************************************/
bool CDynamics2DEngine::AddEntity(CEntity& c_entity) {
SOperationOutcome cOutcome =
CallEntityOperation<CDynamics2DOperationAddEntity, CDynamics2DEngine, SOperationOutcome>
(*this, c_entity);
cpResetShapeIdCounter();
return cOutcome.Value;
}
/****************************************/
/****************************************/
bool CDynamics2DEngine::RemoveEntity(CEntity& c_entity) {
SOperationOutcome cOutcome =
CallEntityOperation<CDynamics2DOperationRemoveEntity, CDynamics2DEngine, SOperationOutcome>
(*this, c_entity);
return cOutcome.Value;
}
/****************************************/
/****************************************/
struct SDynamics2DSegmentHitData {
TEmbodiedEntityIntersectionData& Intersections;
const CRay3& Ray;
SDynamics2DSegmentHitData(TEmbodiedEntityIntersectionData& t_data,
const CRay3& c_ray) :
Intersections(t_data),
Ray(c_ray) {}
};
static void Dynamics2DSegmentQueryFunc(cpShape* pt_shape, cpFloat f_t, cpVect, void* pt_data) {
/* Get the data associated to this query */
SDynamics2DSegmentHitData& sData = *reinterpret_cast<SDynamics2DSegmentHitData*>(pt_data);
/* Hit found, is it within the limits? */
CDynamics2DModel& cModel = *reinterpret_cast<CDynamics2DModel*>(pt_shape->body->data);
CVector3 cIntersectionPoint;
sData.Ray.GetPoint(cIntersectionPoint, f_t);
if((cIntersectionPoint.GetZ() >= cModel.GetBoundingBox().MinCorner.GetZ()) &&
(cIntersectionPoint.GetZ() <= cModel.GetBoundingBox().MaxCorner.GetZ()) ) {
/* Yes, a real hit */
sData.Intersections.push_back(
SEmbodiedEntityIntersectionItem(
&cModel.GetEmbodiedEntity(),
f_t));
}
}
void CDynamics2DEngine::CheckIntersectionWithRay(TEmbodiedEntityIntersectionData& t_data,
const CRay3& c_ray) const {
/* Query all hits along the ray */
SDynamics2DSegmentHitData sHitData(t_data, c_ray);
cpSpaceSegmentQuery(
m_ptSpace,
cpv(c_ray.GetStart().GetX(), c_ray.GetStart().GetY()),
cpv(c_ray.GetEnd().GetX() , c_ray.GetEnd().GetY() ),
CP_ALL_LAYERS,
CP_NO_GROUP,
Dynamics2DSegmentQueryFunc,
&sHitData);
}
/****************************************/
/****************************************/
void CDynamics2DEngine::PositionPhysicsToSpace(CVector3& c_new_pos,
const CVector3& c_original_pos,
const cpBody* pt_body) {
c_new_pos.SetX(pt_body->p.x);
c_new_pos.SetY(pt_body->p.y);
c_new_pos.SetZ(c_original_pos.GetZ());
}
/****************************************/
/****************************************/
void CDynamics2DEngine::OrientationPhysicsToSpace(CQuaternion& c_new_orient,
cpBody* pt_body) {
c_new_orient.FromAngleAxis(CRadians(pt_body->a), CVector3::Z);
}
/****************************************/
/****************************************/
void CDynamics2DEngine::AddPhysicsModel(const std::string& str_id,
CDynamics2DModel& c_model) {
m_tPhysicsModels[str_id] = &c_model;
}
/****************************************/
/****************************************/
void CDynamics2DEngine::RemovePhysicsModel(const std::string& str_id) {
CDynamics2DModel::TMap::iterator it = m_tPhysicsModels.find(str_id);
if(it != m_tPhysicsModels.end()) {
delete it->second;
m_tPhysicsModels.erase(it);
}
else {
THROW_ARGOSEXCEPTION("Dynamics2D model id \"" << str_id << "\" not found in dynamics 2D engine \"" << GetId() << "\"");
}
}
/****************************************/
/****************************************/
REGISTER_PHYSICS_ENGINE(CDynamics2DEngine,
"dynamics2d",
"Carlo Pinciroli [ilpincy@gmail.com]",
"1.0",
"A 2D dynamics physics engine.",
"This physics engine is a 2D dynamics engine based on the Chipmunk library\n"
"(http://code.google.com/p/chipmunk-physics) version 6.0.1.\n\n"
"REQUIRED XML CONFIGURATION\n\n"
" <physics_engines>\n"
" ...\n"
" <dynamics2d id=\"dyn2d\" />\n"
" ...\n"
" </physics_engines>\n\n"
"The 'id' attribute is necessary and must be unique among the physics engines.\n"
"It is used in the subsequent section <arena_physics> to assign entities to\n"
"physics engines. If two engines share the same id, initialization aborts.\n\n"
"OPTIONAL XML CONFIGURATION\n\n"
"It is possible to set how many iterations this physics engine performs between\n"
"each simulation step. By default, this physics engine performs 10 steps every\n"
"two simulation steps. This means that, if the simulation step is 100ms, the\n"
"physics engine step is, by default, 10ms. Sometimes, collisions and joints are\n"
"not simulated with sufficient precision using these parameters. By increasing\n"
"the number of iterations, the temporal granularity of the solver increases and\n"
"with it its accuracy, at the cost of higher computational cost. To change the\n"
"number of iterations per simulation step use this syntax:\n\n"
" <physics_engines>\n"
" ...\n"
" <dynamics2d id=\"dyn2d\"\n"
" iterations=\"20\" />\n"
" ...\n"
" </physics_engines>\n\n"
"The plane of the physics engine can be translated on the Z axis, to simulate\n"
"for example hovering objects, such as flying robots. To translate the plane\n"
"2m up the Z axis, use the 'elevation' attribute as follows:\n\n"
" <physics_engines>\n"
" ...\n"
" <dynamics2d id=\"dyn2d\"\n"
" elevation=\"2.0\" />\n"
" ...\n"
" </physics_engines>\n\n"
"When not specified, the elevation is zero, which means that the plane\n"
"corresponds to the XY plane.\n\n"
"The friction parameters between the ground and movable boxes and cylinders can\n"
"be overridden. You can set both the linear and angular friction parameters.\n"
"The default value is 1.49 for each of them. To override the values, use this\n"
"syntax (all attributes are optional):\n\n"
" <physics_engines>\n"
" ...\n"
" <dynamics2d id=\"dyn2d\"\n"
" <friction box_linear_friction=\"1.0\"\n"
" box_angular_friction=\"2.0\"\n"
" cylinder_linear_friction=\"3.0\"\n"
" cylinder_angular_friction=\"4.0\" />\n"
" </dynamics2d>\n"
" ...\n"
" </physics_engines>\n\n"
"For the the robots that use velocity-based control, such as ground robots with\n"
"the differential_steering actuator (e.g. the foot-bot and the e-puck), it is\n"
"possible to customize robot-specific attributes that set the maximum force and\n"
"torque the robot has. The syntax is as follows, taking a foot-bot as example:\n\n"
" <arena ...>\n"
" ...\n"
" <foot-bot id=\"fb0\">\n"
" <body position=\"0.4,2.3,0.25\" orientation=\"45,0,0\" />\n"
" <controller config=\"mycntrl\" />\n"
" <!-- Specify new value for max_force and max_torque -->\n"
" <dynamics2d>\n"
" <differential_steering max_force=\"0.1\" max_torque=\"0.1\"/>\n"
" </dynamics2d>\n"
" </foot-bot>\n"
" ...\n"
" </arena>\n\n"
"The attributes 'max_force' and 'max_torque' are both optional, and they take the\n"
"robot-specific default if not set. Check the code of the dynamics2d model of the\n"
"robot you're using to know the default values.\n\n"
"By default, this engine uses the bounding-box tree method for collision shape\n"
"indexing. This method is the default in Chipmunk and it works well most of the\n"
"times. However, if you are running simulations with hundreds or thousands of\n"
"identical robots, a different shape collision indexing is available: the spatial\n"
"hash. The spatial hash is a grid stored in a hashmap. To get the max out of this\n"
"indexing method, you must set two parameters: the cell size and the suggested\n"
"minimum number of cells in the space. According to the documentation of\n"
"Chipmunk, the cell size should correspond to the size of the bounding box of the\n"
"most common object in the simulation; the minimum number of cells should be at\n"
"least 10x the number of objects managed by the physics engine. To use this\n"
"indexing method, use this syntax (all attributes are mandatory):\n\n"
" <physics_engines>\n"
" ...\n"
" <dynamics2d id=\"dyn2d\"\n"
" <spatial_hash cell_size=\"1.0\"\n"
" cell_num=\"2.0\" />\n"
" </dynamics2d>\n"
" ...\n"
" </physics_engines>\n"
,
"Usable"
);
}
| 47.705382 | 130 | 0.500238 | freedomcondor |
2e550b4bec8359ca1197d95f8c1a1b8bac17345f | 718 | hpp | C++ | libcaf_core/caf/message_priority.hpp | seewpx/actor-framework | 65ecf35317b81d7a211848d59e734f43483fe410 | [
"BSD-3-Clause"
] | 2,517 | 2015-01-04T22:19:43.000Z | 2022-03-31T12:20:48.000Z | libcaf_core/caf/message_priority.hpp | seewpx/actor-framework | 65ecf35317b81d7a211848d59e734f43483fe410 | [
"BSD-3-Clause"
] | 894 | 2015-01-07T14:21:21.000Z | 2022-03-30T06:37:18.000Z | libcaf_core/caf/message_priority.hpp | seewpx/actor-framework | 65ecf35317b81d7a211848d59e734f43483fe410 | [
"BSD-3-Clause"
] | 570 | 2015-01-21T18:59:33.000Z | 2022-03-31T19:00:02.000Z | // This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <cstdint>
#include <string>
#include <type_traits>
#include "caf/detail/core_export.hpp"
namespace caf {
enum class message_priority {
high = 0,
normal = 1,
};
using high_message_priority_constant
= std::integral_constant<message_priority, message_priority::high>;
using normal_message_priority_constant
= std::integral_constant<message_priority, message_priority::normal>;
CAF_CORE_EXPORT std::string to_string(message_priority);
} // namespace caf
| 24.758621 | 77 | 0.777159 | seewpx |
2e5adc532c473086d5dfeae55fede6b12fc532b1 | 5,415 | cpp | C++ | Templates/Project/Volund_Engine/src/Components/Renderer.cpp | Kaj9296/Volund-Engine | 2416edc6297da4818f0a9f5613daf2223ff868d9 | [
"MIT"
] | null | null | null | Templates/Project/Volund_Engine/src/Components/Renderer.cpp | Kaj9296/Volund-Engine | 2416edc6297da4818f0a9f5613daf2223ff868d9 | [
"MIT"
] | null | null | null | Templates/Project/Volund_Engine/src/Components/Renderer.cpp | Kaj9296/Volund-Engine | 2416edc6297da4818f0a9f5613daf2223ff868d9 | [
"MIT"
] | null | null | null | #pragma once
#include "PCH/PCH.h"
#include "Renderer.h"
#include "Camera.h"
#include "PointLight.h"
#include "DirectionalLight.h"
#include "Scene/Entity.h"
namespace Volund
{
void Renderer::SetMesh(Mesh& mesh)
{
this->mesh = &mesh;
}
void Renderer::SetMaterial(Material& material)
{
this->material = &material;
}
void Renderer::SetShader(Shader& shader)
{
this->shader = &shader;
}
Mesh* Renderer::GetMesh() const
{
if (this->mesh == nullptr)
{
Console::LogError("Renderer does not have a mesh.");
}
return this->mesh;
}
Material* Renderer::GetMaterial() const
{
if (this->material == nullptr)
{
Console::LogError("Renderer does not have a material.");
}
return this->material;
}
Shader* Renderer::GetShader() const
{
if (this->shader == nullptr)
{
Console::LogError("Renderer does not have a shader.");
}
return this->shader;
}
void Renderer::Render(GPUBuffer& Buffer, Camera const& Cam)
{
Buffer.BindFramebuffer();
Buffer.ViewPort();
this->ModelMatrix_P = Mat4(1.0f);
this->ModelMatrix_P = glm::translate(this->ModelMatrix, this->entity->Transform.Position);
this->ModelMatrix_P *= Mat4(this->entity->Transform.Quaternion);
this->ModelMatrix_P = glm::scale(this->ModelMatrix, this->entity->Transform.Scale);
this->shader->SetMat4(this->ModelMatrix, "ModelMatrix");
//Update uniforms
this->SendLights(*this->shader, Cam);
this->material->SendToShader(*this->shader);
Cam.SendToShader(*this->shader);
//Render mesh
shader->DrawMesh(*this->mesh);
}
void Renderer::Render(GPUBuffer& Buffer, Camera const& Cam, glm::vec4(&FrustumPlanes)[6])
{
AABB aabb = this->mesh->aabb;
aabb = aabb.GetInWorldSpace(this->entity);
if (this->InFrustum(aabb, FrustumPlanes))
{
Buffer.BindFramebuffer();
Buffer.ViewPort();
this->ModelMatrix_P = Mat4(1.0f);
this->ModelMatrix_P = glm::translate(this->ModelMatrix, this->entity->Transform.Position);
this->ModelMatrix_P *= Mat4(this->entity->Transform.Quaternion);
this->ModelMatrix_P = glm::scale(this->ModelMatrix, this->entity->Transform.Scale);
this->shader->SetMat4(this->ModelMatrix, "ModelMatrix");
//Update uniforms
this->SendLights(*this->shader, Cam);
this->material->SendToShader(*this->shader);
Cam.SendToShader(*this->shader);
//Render mesh
shader->DrawMesh(*this->mesh);
}
}
void Renderer::Render(GPUBuffer& Buffer, Camera const& Cam, glm::vec4(&FrustumPlanes)[6], Shader*& LastShader, Material*& LastMaterial)
{
AABB aabb = this->mesh->aabb;
aabb = aabb.GetInWorldSpace(this->entity);
if (this->InFrustum(aabb, FrustumPlanes))
{
this->ModelMatrix_P = Mat4(1.0f);
this->ModelMatrix_P = glm::translate(this->ModelMatrix, this->entity->Transform.Position);
this->ModelMatrix_P *= Mat4(this->entity->Transform.Quaternion);
this->ModelMatrix_P = glm::scale(this->ModelMatrix, this->entity->Transform.Scale);
this->shader->SetMat4(this->ModelMatrix, "ModelMatrix");
//Update uniforms
if (this->shader != LastShader)
{
this->SendLights(*this->shader, Cam);
this->material->SendToShader(*this->shader);
Cam.SendToShader(*this->shader);
Buffer.BindFramebuffer();
Buffer.ViewPort();
LastShader = this->shader;
LastMaterial = this->material;
}
else if (this->material != LastMaterial)
{
this->material->SendToShader(*this->shader);
LastMaterial = this->material;
}
//Render mesh
shader->DrawMesh(*this->mesh);
}
}
bool Renderer::InFrustum(AABB aabb, glm::vec4(&FrustumPlanes)[6])
{
Vec4 axisVert(1.0f);
for (int32_t y = 0; y < 6; y++)
{
// x-axis
if (FrustumPlanes[y].x < 0.0f)
{
axisVert.x = aabb.Min.x;
}
else
{
axisVert.x = aabb.Max.x;
}
// y-axis
if (FrustumPlanes[y].y < 0.0f)
{
axisVert.y = aabb.Min.y;
}
else
{
axisVert.y = aabb.Max.y;
}
// z-axis
if (FrustumPlanes[y].z < 0.0f)
{
axisVert.z = aabb.Min.z;
}
else
{
axisVert.z = aabb.Max.z;
}
if (Math::Dot(FrustumPlanes[y], axisVert) < 0.0f)
{
return false;
}
}
return true;
}
void Renderer::SendLights(Shader& shader, Camera const& Cam)
{
//Point Lights
auto Point_View = Engine::GetCurrentScene()->ComponentView<PointLight>();
for (uint32_t i = 0; i < Point_View.size(); i++)
{
Point_View[i]->SendToShader(shader, i);
}
int AmountOfPointLights = Point_View.size();
if (AmountOfPointLights > 1000)
{
Console::LogWarning("To many point lights in scene, maximum allowed amount is 1000.");
AmountOfPointLights = 1000;
}
shader.SetInt(AmountOfPointLights, "AmountOfPointLights");
//Directional Lights
auto Directional_View = Engine::GetCurrentScene()->ComponentView<DirectionalLight>();
for (uint32_t i = 0; i < Directional_View.size(); i++)
{
Directional_View[i]->SendToShader(shader, Cam, i);
}
int AmountOfDirectionalLights = Directional_View.size();
if (AmountOfDirectionalLights > 5)
{
Console::LogWarning("To many directional lights in scene, maximum allowed amount is 5.");
AmountOfDirectionalLights = 5;
}
shader.SetInt(AmountOfDirectionalLights, "AmountOfDirectionalLights");
}
Renderer::Renderer(Mesh const& mesh, Material const& material, Shader const& shader)
: mesh((Mesh*)&mesh), material((Material*)&material), shader((Shader*)&shader)
{
}
} //namespace Volund | 24.391892 | 136 | 0.668698 | Kaj9296 |
2e60934cfd02eaca62550f7d4ecc11f52d007808 | 31,741 | cpp | C++ | .vim/sourceCode/ogre_src_v1-8-1/RenderSystems/GL/src/nvparse/ps1.0_program.cpp | lakehui/Vim_config | 6cab80dc1209b34bf6379f42b1a92790bd0c146b | [
"MIT"
] | 2 | 2017-08-03T07:15:00.000Z | 2018-06-18T10:32:53.000Z | .vim/sourceCode/ogre_src_v1-8-1/RenderSystems/GL/src/nvparse/ps1.0_program.cpp | lakehui/Vim_config | 6cab80dc1209b34bf6379f42b1a92790bd0c146b | [
"MIT"
] | null | null | null | .vim/sourceCode/ogre_src_v1-8-1/RenderSystems/GL/src/nvparse/ps1.0_program.cpp | lakehui/Vim_config | 6cab80dc1209b34bf6379f42b1a92790bd0c146b | [
"MIT"
] | 2 | 2019-03-04T22:57:42.000Z | 2020-03-06T01:32:26.000Z | #include "ps1.0_program.h"
#include "nvparse_errors.h"
#include "nvparse_externs.h"
#include <string>
#include <map>
#include <algorithm>
#include <string.h>
#include <set>
using namespace std;
using namespace ps10;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
#define DBG_MESG(msg, line) errors.set(msg, line)
//#define DBG_MESG(msg, line)
namespace ps10
{
std::map<int, std::pair<int,int> > constToStageAndConstMap;
std::vector<int> constToStageArray;
std::map<int, int> stageToConstMap; // to keep track of which constants have been used up for this stage.
// r-value of 0 means none, r-value of 1 means c0 used, and r-value of 2 means both used.
//std::map<int, int> constToStageMap;
std::map<int, GLenum> stageToTargetMap;
std::set<const char*, ltstr> alphaBlueRegisters; // Keeps track of whether the result of a register
// was a dp3, if a register is in this set, it means that if it is used a source for the alpha
// component the blue component should be used, and not the alpha component.
void SetFinalCombinerStage();
}
void RemoveFromAlphaBlue(std::string s)
{
std::set<const char*, ltstr>::iterator iter =
ps10::alphaBlueRegisters.find(s.c_str());
if (iter != alphaBlueRegisters.end())
alphaBlueRegisters.erase(iter);
}
/*
void AddToMap(string s, int stage)
{
const char* cstr = s.c_str();
if (cstr[0] == 'c')
{
int constNum = atoi(&cstr[1]);
if (constNum < 0 || constNum > 7)
return;
constToStageMap[constNum] = stage;
}
}
*/
bool AddToMap(string s, int stage, GLenum& constVal)
{
const char* cstr = s.c_str();
if (cstr[0] == 'c')
{
int constNum = atoi(&cstr[1]);
std::map<int, int>::iterator iter = stageToConstMap.find(stage);
if (iter == stageToConstMap.end())
{
// no constants used for this stage.
std::pair<int, int> temp;
temp.first = stage;
temp.second = 0;
constToStageAndConstMap[constNum] = temp;
stageToConstMap[stage] = 0;
constVal = 0;
constToStageArray.push_back(constNum);
constToStageArray.push_back(stage);
constToStageArray.push_back(constVal);
}
else
{
int constUsed = (*iter).second;
if (constUsed >= 1)
return false;
else // const0 has been used, so use const1 for this stage.
{
std::pair<int,int> temp;
temp.first = stage;
temp.second = 1;
constToStageAndConstMap[constNum] = temp;
stageToConstMap[stage] = 1;
constVal = 1;
constToStageArray.push_back(constNum);
constToStageArray.push_back(stage);
constToStageArray.push_back(constVal);
}
}
}
constVal += GL_CONSTANT_COLOR0_NV;
return true;
}
bool IsLegalTarget(int target)
{
if (target == GL_TEXTURE_CUBE_MAP_ARB)
return true;
if (target == GL_TEXTURE_3D)
return true;
#if defined(GL_EXT_texture_rectangle)
if (target == GL_TEXTURE_RECTANGLE_EXT)
return true;
#elif defined(GL_NV_texture_rectangle)
if (target == GL_TEXTURE_RECTANGLE_NV)
return true;
#endif
if (target == GL_TEXTURE_2D)
return true;
if (target == GL_TEXTURE_1D)
return true;
return false;
}
bool ps10_set_map(const std::vector<int>& argv)
{
if (argv.size() % 2 != 0)
{
errors.set("Odd number of arguments for texture target map.");
return false;
}
for (unsigned int i=0;i<argv.size();i=i+2)
{
int stage = argv[i];
int target = argv[i+1];
if (!IsLegalTarget(target))
{
errors.set("Illegal target in texture target map.");
return false;
}
ps10::stageToTargetMap[stage] = target;
}
return true;
}
int const_to_combiner_reg_mapping[32][3]; // each 3 tuple is: (constant#, stage #, reg #)
int const_to_combiner_reg_mapping_count = 0;
namespace
{
struct set_constants
{
void operator() (constdef c)
{
if(c.reg[0] != 'c' && c.reg.size() != 2)
DBG_MESG("def line must use constant registers", 0);
int reg = c.reg[1] - '0';
GLenum stage = GL_COMBINER0_NV + (reg / 2);
GLenum cclr = GL_CONSTANT_COLOR0_NV + (reg % 2);
GLfloat cval[4];
cval[0] = c.r;
cval[1] = c.g;
cval[2] = c.b;
cval[3] = c.a;
glCombinerStageParameterfvNV(stage, cclr, cval);
}
};
GLenum get_tex_target(int stage)
{
std::map<int, GLenum>::iterator iter = stageToTargetMap.find(stage);
if (iter != stageToTargetMap.end())
return (*iter).second;
// If no mapping set, use the current state. This will not work correctly, in general,
// if nvparse was invoked within a display list.
if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
return GL_TEXTURE_CUBE_MAP_ARB;
if(glIsEnabled(GL_TEXTURE_3D))
return GL_TEXTURE_3D;
#if defined(GL_EXT_texture_rectangle)
if(glIsEnabled(GL_TEXTURE_RECTANGLE_EXT))
return GL_TEXTURE_RECTANGLE_EXT;
#elif defined(GL_NV_texture_rectangle)
if(glIsEnabled(GL_TEXTURE_RECTANGLE_NV))
return GL_TEXTURE_RECTANGLE_NV;
#endif
if(glIsEnabled(GL_TEXTURE_2D))
return GL_TEXTURE_2D;
if(glIsEnabled(GL_TEXTURE_1D))
return GL_TEXTURE_1D;
//otherwise make the op none...
return GL_NONE;
}
struct set_texture_shaders
{
set_texture_shaders(vector<constdef> * cdef)
{
for(stage = 0; stage < 4; stage++)
{
glActiveTextureARB(GL_TEXTURE0_ARB + stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
}
stage = 0;
c = cdef;
}
void operator() (vector<string> & instr)
{
if(stage > 3)
return;
glActiveTextureARB(GL_TEXTURE0_ARB + stage);
string op = instr[0];
if(op == "tex")
{
if(instr.size() != 2)
fprintf(stderr,"incorrect \"tex\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, get_tex_target(stage));
}
else if(op == "texbem")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texbem\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texbem\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texbeml")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texbeml\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_SCALE_NV);
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texbeml\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texcoord")
{
if(instr.size() != 2)
fprintf(stderr,"incorrect \"texcoord\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_PASS_THROUGH_NV);
}
else if(op == "texkill")
{
if(instr.size() != 2)
fprintf(stderr,"incorrect \"texkill\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_CULL_FRAGMENT_NV);
}
else if(op == "texm3x2pad")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texm3x2pad\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x2pad\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texm3x2tex")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texm3x2tex\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x2tex\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texm3x3pad")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texm3x3pad\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x3pad\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texm3x3tex")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texm3x3spec")
{
if(instr.size() != 4 || stage == 0)
fprintf(stderr,"incorrect \"texm3x3spec\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
if(! c)
return;
constdef cd;
for(int i = c->size()-1; i >= 0; i--)
{
cd = (*c)[i];
if(cd.reg == "c0")
break;
}
if(cd.reg != "c0" || instr[3] != "c0")
return;
GLfloat eye[4];
eye[0] = cd.r;
eye[1] = cd.g;
eye[2] = cd.b;
eye[3] = cd.a;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV);
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_CONST_EYE_NV, eye);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texm3x3vspec")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texm3x3vspec\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV);
if(instr[2].find("_bx2") != string::npos)
{
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
}
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texreg2ar")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texreg2ar\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV);
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texreg2ar\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
else if(op == "texreg2gb")
{
if(instr.size() != 3 || stage == 0)
fprintf(stderr,"incorrect \"texreg2gb\" instruction, stage %d...\n", stage);
reg2stage[instr[1]] = stage;
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV);
if(reg2stage.count(instr[2]) == 0)
fprintf(stderr,"incorrect \"texreg2gb\" instruction, stage %d...\n", stage);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
}
stage++;
}
map<string, int> reg2stage;
int stage;
vector<constdef> * c;
};
GLenum reg_enum(string s, int stage)
{
/*if(s == "c0")
return GL_CONSTANT_COLOR0_NV;
else if(s == "c1")
return GL_CONSTANT_COLOR1_NV;
else if(s == "c2")
return GL_CONSTANT_COLOR0_NV;
else if(s == "c3")
return GL_CONSTANT_COLOR1_NV;
else if(s == "c4")
return GL_CONSTANT_COLOR0_NV;
else if(s == "c5")
return GL_CONSTANT_COLOR1_NV;
else if(s == "c6")
return GL_CONSTANT_COLOR0_NV;
else if(s == "c7")
return GL_CONSTANT_COLOR1_NV;
*/
if (s == "c0" || s == "c1" || s == "c2" || s == "c3" ||
s == "c4" || s == "c5" || s == "c6" || s == "c7")
{
GLenum result;
if (!AddToMap(s,stage,result))
errors.set("Illegal constant usage.",line_number);
// This is a pain, since the caller is a void and no check is made for errors. Sigh.
return result;
}
else if(s == "t0")
return GL_TEXTURE0_ARB;
else if(s == "t1")
return GL_TEXTURE1_ARB;
else if(s == "t2")
return GL_TEXTURE2_ARB;
else if(s == "t3")
return GL_TEXTURE3_ARB;
else if(s == "v0")
return GL_PRIMARY_COLOR_NV;
else if(s == "v1")
return GL_SECONDARY_COLOR_NV;
else if(s == "r0")
return GL_SPARE0_NV;
else if(s == "r1")
return GL_SPARE1_NV;
else // ??
return GL_DISCARD_NV;
}
struct src
{
src(string s, int stage, string *regname=NULL)
{
init(s, stage, regname);
}
void init(string s, int stage, string *regname=NULL)
{
arg = s;
comp = GL_RGB;
alphaComp = GL_ALPHA;
map = GL_SIGNED_IDENTITY_NV;
string::size_type offset;
if(
(offset = s.find(".a")) != string::npos ||
(offset = s.find(".w")) != string::npos
)
{
comp = GL_ALPHA;
s.erase(offset, offset+2);
}
else if ((offset = s.find(".b")) != string::npos ||
(offset = s.find(".z")) != string::npos)
{
alphaComp = GL_BLUE;
s.erase(offset,offset+2);
}
bool negate = false;
if(s[0] == '1')
{
s.erase(0, 1);
while(s[0] == ' ')
s.erase(0,1);
if(s[0] == '-')
s.erase(0,1);
while(s[0] == ' ')
s.erase(0,1);
map = GL_UNSIGNED_INVERT_NV;
}
else if(s[0] == '-')
{
s.erase(0, 1);
while(s[0] == ' ')
s.erase(0,1);
negate = true;
map = GL_UNSIGNED_INVERT_NV;
}
bool half_bias = false;
bool expand = false;
if(s.find("_bias") != string::npos)
{
s.erase(s.find("_bias"), 5);
half_bias = true;
}
else if(s.find("_bx2") != string::npos)
{
s.erase(s.find("_bx2"), 4);
expand = true;
}
if(expand)
{
if(negate)
map = GL_EXPAND_NEGATE_NV;
else
map = GL_EXPAND_NORMAL_NV;
}
else if(half_bias)
{
if(negate)
map = GL_HALF_BIAS_NEGATE_NV;
else
map = GL_HALF_BIAS_NORMAL_NV;
}
reg = reg_enum(s,stage);
if (regname != NULL)
*regname = s; // return the bare register name
//alphaComp = GL_ALPHA;
std::set<const char*, ltstr>::iterator iter =
ps10::alphaBlueRegisters.find(s.c_str());
if (iter != ps10::alphaBlueRegisters.end())
alphaComp = GL_BLUE;
}
string arg;
GLenum reg;
GLenum map;
GLenum comp;
GLenum alphaComp;
};
struct set_register_combiners
{
set_register_combiners()
{
// combiner = 0;
combiner = -1;
}
void operator() (vector<string> & instr)
{
string op;
GLenum scale = GL_NONE;
bool paired_instr = false;
int instr_base = 0;
if (instr[0]=="+") {
paired_instr = true;
instr_base = 1;
}
op = instr[instr_base];
string::size_type offset;
if((offset = op.find("_x2")) != string::npos)
{
scale = GL_SCALE_BY_TWO_NV;
op.erase(op.begin()+offset, op.begin()+offset+3);
}
else if((offset = op.find("_x4")) != string::npos)
{
scale = GL_SCALE_BY_FOUR_NV;
op.erase(op.begin()+offset, op.begin()+offset+3);
}
else if((offset = op.find("_d2")) != string::npos)
{
scale = GL_SCALE_BY_ONE_HALF_NV;
op.erase(op.begin()+offset, op.begin()+offset+3);
}
if((offset = op.find("_sat")) != string::npos)
{
op.erase(op.begin()+offset, op.begin()+offset+4);
}
string dst = instr[1+instr_base];
int mask = GL_RGBA;
if(
(offset = dst.find(".rgba")) != string::npos ||
(offset = dst.find(".xyzw")) != string::npos
)
{
dst.erase(offset, offset + 5);
}
else if(
(offset = dst.find(".rgb")) != string::npos ||
(offset = dst.find(".xyz")) != string::npos
)
{
dst.erase(offset, offset + 4);
mask = GL_RGB;
}
else if(
(offset = dst.find(".a")) != string::npos ||
(offset = dst.find(".w")) != string::npos
)
{
dst.erase(offset, offset + 2);
mask = GL_ALPHA;
}
if (!paired_instr)
combiner++;
GLenum dreg = reg_enum(dst,combiner);
GLenum C = GL_COMBINER0_NV + combiner;
bool isAlphaBlue = false; // To keep track of whether the dst register's alpha was its blue value.
if(op == "add" || op == "sub")
{
src a(instr[2+instr_base],combiner);
src b(instr[3+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, b.reg, b.map, b.comp);
if(op == "add")
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
else
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, b.reg, b.map, b.alphaComp);
if(op == "add")
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
else
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_EXPAND_NORMAL_NV, GL_ALPHA);
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "cnd")
{
src a(instr[3+instr_base],combiner);
src b(instr[4+instr_base],combiner);
if(instr[2+instr_base] != "r0.a" && instr[2+instr_base] != "r0.w")
{} // bad
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, b.reg, b.map, b.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_TRUE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, b.reg, b.map, b.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_TRUE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "dp3")
{
src a(instr[2+instr_base],combiner);
src b(instr[3+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
GL_TRUE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
// ooh.. what to do here?
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
// todo -- make next ref to dst.a actually ref dst.b since combiners can't write dp3 to the alpha channel
// Done by Ashu: Put this register in the alphaBlueRegister set.
isAlphaBlue = true;
ps10::alphaBlueRegisters.insert(dst.c_str());
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "lrp")
{
src a(instr[2+instr_base],combiner);
src b(instr[3+instr_base],combiner);
src c(instr[4+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, GL_UNSIGNED_IDENTITY_NV, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, a.reg, GL_UNSIGNED_INVERT_NV, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, c.reg, c.map, c.comp);
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, GL_UNSIGNED_IDENTITY_NV, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, b.reg, b.map, b.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, a.reg, GL_UNSIGNED_INVERT_NV, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, c.reg, c.map, c.alphaComp);
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "mad")
{
src a(instr[2+instr_base],combiner);
src b(instr[3+instr_base],combiner);
src c(instr[4+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, c.reg, c.map, c.comp);
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, b.reg, b.map, b.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, c.reg, c.map, c.alphaComp);
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "mov")
{
src a(instr[2+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
glCombinerOutputNV(C, GL_ALPHA, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
else if(op == "mul")
{
src a(instr[2+instr_base],combiner);
src b(instr[3+instr_base],combiner);
if(mask == GL_RGBA || mask == GL_RGB)
{
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
if(mask == GL_RGBA || mask == GL_ALPHA)
{
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, a.alphaComp);
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, b.reg, b.map, b.alphaComp);
glCombinerOutputNV(C, GL_ALPHA, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
else if (!paired_instr)
{
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
GL_FALSE, GL_FALSE, GL_FALSE);
}
}
// combiner++;
if (!isAlphaBlue)
RemoveFromAlphaBlue(dst);
}
int combiner;
};
}
void ps10::SetFinalCombinerStage()
{
glFinalCombinerInputNV(GL_VARIABLE_A_NV,GL_FOG,GL_UNSIGNED_IDENTITY_NV,GL_ALPHA);
glFinalCombinerInputNV(GL_VARIABLE_B_NV,GL_SPARE0_NV,
GL_UNSIGNED_IDENTITY_NV,GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV,GL_FOG,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV,GL_ZERO,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_E_NV,GL_ZERO,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_F_NV,GL_ZERO,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
std::set<const char*, ltstr>::iterator iter = ps10::alphaBlueRegisters.find("r0");
GLenum alphaComp = GL_ALPHA;
if (iter != ps10::alphaBlueRegisters.end())
alphaComp = GL_BLUE;
glFinalCombinerInputNV(GL_VARIABLE_G_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,alphaComp);
// We can now clear alphaBlueRegisters for the next go around
alphaBlueRegisters.clear();
}
void ps10::invoke(vector<constdef> * c,
list<vector<string> > * a,
list<vector<string> > * b)
{
const_to_combiner_reg_mapping_count = 0; // Hansong
glEnable(GL_PER_STAGE_CONSTANTS_NV); // should we require apps to do this?
if(c)
for_each(c->begin(), c->end(), set_constants());
if(a)
for_each(a->begin(), a->end(), set_texture_shaders(c));
glActiveTextureARB( GL_TEXTURE0_ARB );
int numCombiners = 0;
list<vector<string> >::iterator it = b->begin();
for(; it!=b->end(); ++it) {
if ( (*it)[0] != "+" )
numCombiners++;
}
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, numCombiners);
if(b)
for_each(b->begin(), b->end(), set_register_combiners());
SetFinalCombinerStage();
// We can clear the stageToTarget map now.
stageToTargetMap.clear();
}
// simple identification - just look for magic substring
// -- easy to break...
bool is_ps10(const char * s)
{
if(strstr(s, "ps.1.0"))
return true;
if(strstr(s, "Ps.1.0"))
return true;
if(strstr(s, "ps.1.1"))
return true;
if(strstr(s, "Ps.1.1"))
return true;
return false;
}
bool ps10::init_extensions()
{
// register combiners
static bool rcinit = false;
if(rcinit == false)
{
/*
if(! glh_init_extensions("GL_NV_register_combiners"))
{
errors.set("unable to initialize GL_NV_register_combiners\n");
return false;
}
else
{
*/
rcinit = true;
/*
}
*/
}
// register combiners 2
static bool rc2init = false;
if(rc2init == false)
{
/*
if( ! glh_init_extensions("GL_NV_register_combiners2"))
{
errors.set("unable to initialize GL_NV_register_combiners2\n");
return false;
}
else
{
*/
rc2init = true;
/*
}
*/
}
static bool tsinit = 0;
if (tsinit == false )
{
/*
if(! glh_init_extensions( "GL_NV_texture_shader " "GL_ARB_multitexture " ))
{
errors.set("unable to initialize GL_NV_texture_shader\n");
return false;
}
else
{
*/
tsinit = true;
/*
}
*/
}
constToStageAndConstMap.clear();
constToStageArray.clear();
stageToConstMap.clear();
line_number = 1;
return true;
}
const int* ps10_get_info(int* pcount)
{
if (pcount)
*pcount = constToStageArray.size();
return &(constToStageArray[0]);
}
| 31.395648 | 110 | 0.650137 | lakehui |
2e6208a32d74edabdd44a6b6204724aa33ce4e33 | 2,047 | cpp | C++ | 21/modlarea.cpp | johnoel/tagest | be0a6b164683c448c90f0c3952343f5963eece3d | [
"BSD-2-Clause"
] | 3 | 2015-08-26T17:14:02.000Z | 2015-11-17T04:18:56.000Z | 21/modlarea.cpp | johnoel/tagest | be0a6b164683c448c90f0c3952343f5963eece3d | [
"BSD-2-Clause"
] | 10 | 2015-08-20T00:51:05.000Z | 2016-11-16T19:14:48.000Z | 21/modlarea.cpp | johnoel/tagest | be0a6b164683c448c90f0c3952343f5963eece3d | [
"BSD-2-Clause"
] | 3 | 2016-11-16T00:52:23.000Z | 2021-09-10T02:17:40.000Z | #include "modlarea.h"
Model_area::Model_area()
{
//cout << "Top of Model_area null constructor" << endl;
//cout << "Bottom of Model_area null constructor" << endl;
}//Model_area()
Model_area::~Model_area()
{
//cout << "Top of Model_area destructor" << endl;
//cout << "Bottom of Model_area destructor" << endl;
}//~Model_area()
void Model_area::allocate()
{
//cout << "allocate" << endl;
gridmap.allocate(1, m, 1, n); gridmap.initialize();
cell_type.allocate(1, m, 1, n); cell_type.initialize();
ilb.allocate(1,n); ilb.initialize();
iub.allocate(1,n); iub.initialize();
jlb.allocate(1,m); jlb.initialize();
jub.allocate(1,m); jub.initialize();
//cout << "out allocate" << endl;
/*
for (int i=1; i<=m; i++)
for (int j=1; j<=n; j++)
cell_type[i][j] = NONE;
*/
}//allocate()
void Model_area::initialize()
{
make_del_x();
}//initialize()
void Model_area::make_del_x()
{
del_x.allocate(1, n);
//del_x = deltay;
double lat_val = get_long_lat_lat();
double R = 3437.746771; //Nm
#ifdef __ZTC__
#undef PI
#endif
double PI = 3.14159265358979323846;
for (int i=1; i <= n; i++)
{
del_x[i] = R * cos( fabs(lat_val)*PI/180.0 ) * ( PI / 180.0 ) ;
lat_val += 1.0;
}
}//make_del_x()
//initialize model_area object to another model_area object
Model_area::Model_area(const Model_area& t)
: m(t.m), n(t.n),
west_bndry(t.west_bndry), east_bndry(t.east_bndry),
north_bndry(t.north_bndry), south_bndry(t.south_bndry),
deltax(t.deltax), deltay(t.deltay), del_x(t.del_x),
gridmap(t.gridmap), cell_type(t.cell_type),
ilb(t.ilb), iub(t.iub), jlb(t.jlb), jub(t.jub),
dfile_version(t.dfile_version)
{
//cout << "Top of Model_area copy constructor" << endl;
sw_coord = (Geo_coord)t.sw_coord;
lxy = t.lxy;
sp = t.sp;
//for (int i = 0; i < SZ; i++)
// filename[i] = t.filename[i];
//pathname(t.pathname);
pathname = t.pathname;
//for (int i = 0; i < VSZ; i++)
// dfile_version[i] = t.dfile_version[i];
//cout << "Bottom of Model_area copy constructor" << endl;
}
| 25.271605 | 67 | 0.632633 | johnoel |
2e62c3ff1ed61703a21949f4291e158bc7a1b1ef | 3,583 | cpp | C++ | algorithm/data structure class/2018.11.11 biTree study/treeQuestion.cpp | xmmmmmovo/BaseNotes | aa895c15e47d2f344ffcc48798d094a8ca942a79 | [
"MIT"
] | 2 | 2019-06-06T21:09:44.000Z | 2019-09-23T05:00:27.000Z | algorithm/data structure class/2018.11.11 biTree study/treeQuestion.cpp | xmmmmmovo/notes | 3f51cdac402f1ce31ea75fe897d77159f75dc9aa | [
"MIT"
] | 13 | 2020-11-12T14:35:34.000Z | 2022-02-27T09:25:06.000Z | algorithm/data structure class/2018.11.11 biTree study/treeQuestion.cpp | xmmmmmovo/BaseNotes | aa895c15e47d2f344ffcc48798d094a8ca942a79 | [
"MIT"
] | null | null | null | /**
* 2018-11-11 二叉树课后题目
* language: C/C++ author: xmmmmmovo
*/
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
using namespace std;//stack所需的命名空间
typedef struct treeNode{
char nodeCharctar;
treeNode *left;
treeNode *right;
}treeNode;
int i = 0;
//前序生成二叉树
treeNode *createTree(){
treeNode *node;
char ch;
if((ch = getchar()) == '#'){
node = NULL;
}else{
node = (treeNode *)malloc(sizeof(treeNode));
node->nodeCharctar = ch;
node->left = createTree();
node->right = createTree();
}
return node;
}
//前序遍历(非递归)
void preorder(treeNode *node){
stack<treeNode *> buffer;//存储遍历节点
while(!buffer.empty() || node){
if(node){
printf("%c ", node->nodeCharctar);
buffer.push(node);
node = node->left;
}else if(!buffer.empty()){
node = buffer.top()->right;
buffer.pop();
i++;
}
}
i++;
printf("\n");
}
//前序遍历(递归)
void preorder2(treeNode *node){
if(node){
printf("%c ", node->nodeCharctar);
preorder2(node->left);
preorder2(node->right);
}else{
i++;
}
}
//中序遍历
char inorder(treeNode *node){
stack<treeNode *> buffer;
char endchar;
while(node || !buffer.empty()){
if(node){
buffer.push(node);
node = node->left;
}else{
node = buffer.top();
buffer.pop();
printf("%c ", node->nodeCharctar);
endchar = node->nodeCharctar;
node = node->right;
}
}
printf("\n");
return endchar;
}
//后序搜索(非递归)
stack<treeNode *> postorderSearch(treeNode *node, char searchChar){
stack<treeNode *> buffer;
stack<bool> tag;
while(node || !buffer.empty()){
if(node){
buffer.push(node);
tag.push(false);
node = node->left;
}else{
if(tag.top()){
tag.pop();
node = buffer.top();
buffer.pop();
if(node->nodeCharctar == searchChar)
return buffer;
node = NULL;
}else{
node = buffer.top();
node = node->right;
tag.top() = true;
}
}
}
printf("\n");
return buffer;
}
stack<treeNode *> reserve(stack<treeNode *> buffer){
stack <treeNode *> reservenodes;
while(!buffer.empty()){
reservenodes.push(buffer.top());
buffer.pop();
}
return reservenodes;
}
treeNode *searchFather(treeNode *root, char fr, char se){
stack<treeNode *> frnodes = reserve(postorderSearch(root, fr));
stack<treeNode *> senodes = reserve(postorderSearch(root, se));
treeNode *node;
while(!(frnodes.empty() || senodes.empty())){
if(frnodes.top() == senodes.top()){
node = frnodes.top();
}
frnodes.pop();
senodes.pop();
}
return node;
}
int main(int argc, char const *argv[])
{
treeNode *root, *tempNode;
char fr, se;
//输入123##4##5##
root = createTree();
getchar();
preorder(root);
printf("%d\n", i/2);
i = 0;
preorder2(root);
printf("\n%d\n", i/2);
printf("%c\n", inorder(root));
fr = getchar();
getchar();
se = getchar();
tempNode = searchFather(root, fr, se);
if(tempNode){
printf("%c\n", tempNode->nodeCharctar);
}else{
printf("NULL\n");
}
system("pause");
return 0;
} | 20.953216 | 67 | 0.505721 | xmmmmmovo |
2e63ce7b634c760b85066908540eecd75e247244 | 13,529 | hpp | C++ | src/localization/ndt/include/ndt/ndt_map.hpp | rubis-lab/autoware_rubis | 498ec5ff4c448d456fa0c6fe2f17e02fbd13ddb9 | [
"Apache-2.0"
] | null | null | null | src/localization/ndt/include/ndt/ndt_map.hpp | rubis-lab/autoware_rubis | 498ec5ff4c448d456fa0c6fe2f17e02fbd13ddb9 | [
"Apache-2.0"
] | null | null | null | src/localization/ndt/include/ndt/ndt_map.hpp | rubis-lab/autoware_rubis | 498ec5ff4c448d456fa0c6fe2f17e02fbd13ddb9 | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 the Autoware Foundation
//
// 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.
//
// Co-developed by Tier IV, Inc. and Apex.AI, Inc.
#ifndef NDT__NDT_MAP_HPP_
#define NDT__NDT_MAP_HPP_
#include <ndt/ndt_common.hpp>
#include <ndt/ndt_voxel.hpp>
#include <ndt/ndt_voxel_view.hpp>
#include <sensor_msgs/point_cloud2_iterator.hpp>
#include <time_utils/time_utils.hpp>
#include <vector>
#include <limits>
#include <unordered_map>
#include <utility>
#include <string>
#include "common/types.hpp"
using autoware::common::types::float32_t;
namespace autoware
{
namespace localization
{
namespace ndt
{
/// Function that checks if the pcl message format is valid as an ndt map. The point cloud should
/// have the following fields: x, y, z, cov_xx, cov_xy, cov_xz, cov_yy, cov_yz, cov_zz. The data
/// type for the fields should be double.
/// \param msg Point cloud message
/// \return Safe and usable number of points. the formula is:
/// `min(data.size(), width, row_step) / point_step`
/// If the cloud is assessed to be invalid (i.e. due to invalid fields), then 0 is returned.
uint32_t NDT_PUBLIC validate_pcl_map(const sensor_msgs::msg::PointCloud2 & msg);
/////////////////////////////////////////////
template<typename Derived, typename VoxelT>
class NDTMapBase : public common::helper_functions::crtp<Derived>
{
public:
using Grid = std::unordered_map<uint64_t, VoxelT>;
using Point = Eigen::Vector3d;
using Config = autoware::perception::filters::voxel_grid::Config;
using TimePoint = std::chrono::system_clock::time_point;
using VoxelViewVector = std::vector<VoxelView<VoxelT>>;
/// Constructor
/// \param voxel_grid_config Voxel grid config to configure the underlying voxel grid.
explicit NDTMapBase(const Config & voxel_grid_config)
: m_config(voxel_grid_config), m_map(m_config.get_capacity())
{
m_output_vector.reserve(1U);
}
// Maps should be moved rather than being copied.
NDTMapBase(const NDTMapBase &) = delete;
NDTMapBase & operator=(const NDTMapBase &) = delete;
// Explicitly declaring to default is needed since we explicitly deleted the copy methods.
NDTMapBase(NDTMapBase &&) = default;
NDTMapBase & operator=(NDTMapBase &&) = default;
/// Lookup the cell at location.
/// \param x x coordinate
/// \param y y coordinate
/// \param z z coordinate
/// \return A vector containing the cell at given coordinates. A vector is used to support
/// near-neighbour cell queries in the future.
const VoxelViewVector & cell(float32_t x, float32_t y, float32_t z) const
{
return cell(Point({x, y, z}));
}
/// Lookup the cell at location.
/// \param pt point to lookup
/// \return A vector containing the cell at given coordinates. A vector is used to support
/// near-neighbour cell queries in the future.
const VoxelViewVector & cell(const Point & pt) const
{
// TODO(yunus.caliskan): revisit after multi-cell lookup support.
m_output_vector.clear();
const auto vx_it = m_map.find(m_config.index(pt));
// Only return a voxel if it's occupied (i.e. has enough points to compute covariance.)
if (vx_it != m_map.end() && vx_it->second.usable()) {
m_output_vector.emplace_back(vx_it->second);
}
return m_output_vector;
}
/// Insert a point cloud to the map.
/// \param msg PointCloud2 message to add.
void insert(const sensor_msgs::msg::PointCloud2 & msg)
{
m_stamp = ::time_utils::from_message(msg.header.stamp);
m_frame_id = msg.header.frame_id;
this->impl().insert_(msg);
}
/// Get size of the map
/// \return Number of voxels in the map. This number includes the voxels that do not have
/// enough numbers to be used yet.
uint64_t size() const noexcept
{
return m_map.size();
}
/// Get size of the cell.
/// \return A point representing the dimensions of the cell.
auto cell_size() const noexcept
{
return m_config.get_voxel_size();
}
/// \brief Returns an const iterator to the first element of the map
/// \return Iterator
typename Grid::const_iterator begin() const noexcept
{
return cbegin();
}
/// \brief Returns an iterator to the first element of the map
/// \return Iterator
typename Grid::iterator begin() noexcept
{
return m_map.begin();
}
/// \brief Returns a const iterator to the first element of the map
/// \return Iterator
typename Grid::const_iterator cbegin() const noexcept
{
return m_map.cbegin();
}
/// \brief Returns a const iterator to one past the last element of the map
/// \return Iterator
typename Grid::const_iterator end() const noexcept
{
return cend();
}
/// \brief Returns an iterator to one past the last element of the map
/// \return Iterator
typename Grid::iterator end() noexcept
{
return m_map.end();
}
/// \brief Returns a const iterator to one past the last element of the map
/// \return Iterator
typename Grid::const_iterator cend() const noexcept
{
return m_map.cend();
}
/// Clear all voxels in the map
void clear() noexcept
{
m_map.clear();
}
/// Get map's time stamp.
/// \return map's time stamp.
TimePoint stamp() const noexcept
{
return m_stamp;
}
/// \brief Set the contents of the pointcloud as the new map.
/// \param msg Pointcloud to be inserted.
void set(const sensor_msgs::msg::PointCloud2 & msg)
{
clear();
insert(msg);
}
/// Get map's frame id.
/// \return Frame id of the map.
const std::string & frame_id() const noexcept
{
return m_frame_id;
}
/// \brief Check if the map is valid.
/// \return True if the map and frame ID are not empty and the stamp is initialized.
bool valid()
{
return (!m_map.empty()) && (!m_frame_id.empty());
}
protected:
/// Get voxel index given a point.
/// \param pt point
/// \return voxel index
auto index(const Point & pt) const
{
return m_config.index(pt);
}
/// Get a reference to the voxel at the given index. If no voxel exists, a default constructed
/// Voxel is inserted.
/// \param idx
/// \return
VoxelT & voxel(uint64_t idx)
{
return m_map[idx];
}
auto emplace(uint64_t key, const VoxelT && vx)
{
return m_map.emplace(key, std::move(vx));
}
private:
mutable VoxelViewVector m_output_vector;
const Config m_config;
Grid m_map;
TimePoint m_stamp{};
std::string m_frame_id{};
};
/// Ndt Map for a dynamic voxel type. This map representation is only to be used
/// when a dense point cloud is intended to be represented as a map. (i.e. by the map publisher)
class NDT_PUBLIC DynamicNDTMap
: public NDTMapBase<DynamicNDTMap, DynamicNDTVoxel>
{
public:
using Voxel = DynamicNDTVoxel;
using Grid = std::unordered_map<uint64_t, Voxel>;
using Config = autoware::perception::filters::voxel_grid::Config;
using Point = Eigen::Vector3d;
using NDTMapBase::NDTMapBase;
/// Insert the dense point cloud to the map. This is intended for converting a dense
/// point cloud into the ndt representation. Ideal for reading dense pcd files.
/// \param msg PointCloud2 message to add.
void insert_(const sensor_msgs::msg::PointCloud2 & msg)
{
sensor_msgs::PointCloud2ConstIterator<float32_t> x_it(msg, "x");
sensor_msgs::PointCloud2ConstIterator<float32_t> y_it(msg, "y");
sensor_msgs::PointCloud2ConstIterator<float32_t> z_it(msg, "z");
while (x_it != x_it.end() &&
y_it != y_it.end() &&
z_it != z_it.end())
{
const auto pt = Point({*x_it, *y_it, *z_it});
const auto voxel_idx = index(pt);
voxel(voxel_idx).add_observation(pt); // Add or insert new voxel.
++x_it;
++y_it;
++z_it;
}
// try to stabilizie the covariance after inserting all the points
for (auto & vx_it : *this) {
auto & vx = vx_it.second;
(void) vx.try_stabilize();
}
}
};
/// NDT map using StaticNDTVoxels. This class is to be used when the pointcloud
/// messages to be inserted already have the correct format (see validate_pcl_map(...)) and
/// represent a transformed map. No centroid/covariance computation is done during run-time.
class NDT_PUBLIC StaticNDTMap
: public NDTMapBase<StaticNDTMap, StaticNDTVoxel>
{
public:
using NDTMapBase::NDTMapBase;
using Voxel = StaticNDTVoxel;
/// Insert point cloud message representing the map to the map representation instance.
/// Map is assumed to have correct format (see `validate_pcl_map(...)`) and was generated
/// by a dense map representation with identical configuration to this representation.
/// \param msg PointCloud2 message to add. Each point in this cloud should correspond to a
/// single voxel in the underlying voxel grid. This is checked via the `cell_id` field in the pcl
/// message which is expected to be equal to the voxel grid ID in the map's voxel grid. Since
/// the grid's index will be a long value to avoid overflows, `cell_id` field should be an array
/// of 2 unsigned integers. That is because there is no direct long support as a PointField.
void insert_(const sensor_msgs::msg::PointCloud2 & msg)
{
if (validate_pcl_map(msg) == 0U) {
// throwing rather than silently failing since ndt matching cannot be done with an
// empty/incorrect map
throw std::runtime_error(
"Point cloud representing the ndt map is either empty"
"or does not have the correct format.");
}
sensor_msgs::PointCloud2ConstIterator<Real> x_it(msg, "x");
sensor_msgs::PointCloud2ConstIterator<Real> y_it(msg, "y");
sensor_msgs::PointCloud2ConstIterator<Real> z_it(msg, "z");
sensor_msgs::PointCloud2ConstIterator<Real> icov_xx_it(msg, "icov_xx");
sensor_msgs::PointCloud2ConstIterator<Real> icov_xy_it(msg, "icov_xy");
sensor_msgs::PointCloud2ConstIterator<Real> icov_xz_it(msg, "icov_xz");
sensor_msgs::PointCloud2ConstIterator<Real> icov_yy_it(msg, "icov_yy");
sensor_msgs::PointCloud2ConstIterator<Real> icov_yz_it(msg, "icov_yz");
sensor_msgs::PointCloud2ConstIterator<Real> icov_zz_it(msg, "icov_zz");
sensor_msgs::PointCloud2ConstIterator<uint32_t> cell_id_it(msg, "cell_id");
while (x_it != x_it.end() &&
y_it != y_it.end() &&
z_it != z_it.end() &&
icov_xx_it != icov_xx_it.end() &&
icov_xy_it != icov_xy_it.end() &&
icov_xz_it != icov_xz_it.end() &&
icov_yy_it != icov_yy_it.end() &&
icov_yz_it != icov_yz_it.end() &&
icov_zz_it != icov_zz_it.end() &&
cell_id_it != cell_id_it.end())
{
const Point centroid{*x_it, *y_it, *z_it};
const auto voxel_idx = index(centroid);
// Since no native usigned long support is vailable for a point field
// the `cell_id_it` points to an array of two 32 bit integers to represent
// a long number. So the assignments must be done via memcpy.
Grid::key_type received_idx = 0U;
std::memcpy(&received_idx, &cell_id_it[0U], sizeof(received_idx));
// If the pointcloud does not represent a voxel grid of identical configuration,
// report the error
if (voxel_idx != received_idx) {
throw std::domain_error(
"NDTVoxelMap: Pointcloud representing the ndt map"
"does not have a matching grid configuration with "
"the map representation it is being inserted to. The cell IDs do not matchb");
}
Eigen::Matrix3d inv_covariance;
inv_covariance << *icov_xx_it, *icov_xy_it, *icov_xz_it,
*icov_xy_it, *icov_yy_it, *icov_yz_it,
*icov_xz_it, *icov_yz_it, *icov_zz_it;
const Voxel vx{centroid, inv_covariance};
const auto insert_res = emplace(voxel_idx, Voxel{centroid, inv_covariance});
if (!insert_res.second) {
// if a voxel already exist at this point, replace.
insert_res.first->second = vx;
}
++x_it;
++y_it;
++z_it;
++icov_xx_it;
++icov_xy_it;
++icov_xz_it;
++icov_yy_it;
++icov_yz_it;
++icov_zz_it;
++cell_id_it;
}
}
};
} // namespace ndt
} // namespace localization
namespace common
{
namespace geometry
{
namespace point_adapter
{
/// Point adapters for eigen vector
/// These adapters are necessary for the VoxelGrid to know how to access
/// the coordinates from an eigen vector.
template<>
inline NDT_PUBLIC auto x_(const Eigen::Vector3d & pt)
{
return static_cast<float32_t>(pt(0));
}
template<>
inline NDT_PUBLIC auto y_(const Eigen::Vector3d & pt)
{
return static_cast<float32_t>(pt(1));
}
template<>
inline NDT_PUBLIC auto z_(const Eigen::Vector3d & pt)
{
return static_cast<float32_t>(pt(2));
}
template<>
inline NDT_PUBLIC auto & xr_(Eigen::Vector3d & pt)
{
return pt(0);
}
template<>
inline NDT_PUBLIC auto & yr_(Eigen::Vector3d & pt)
{
return pt(1);
}
template<>
inline NDT_PUBLIC auto & zr_(Eigen::Vector3d & pt)
{
return pt(2);
}
} // namespace point_adapter
} // namespace geometry
} // namespace common
} // namespace autoware
#endif // NDT__NDT_MAP_HPP_
| 32.211905 | 99 | 0.687634 | rubis-lab |
2e662137a9b2b83cf0785cde027fba2a1c52102e | 1,830 | cpp | C++ | src/KrTools.cpp | cildhdi/KrUI | c6f18620838f15a82ee65cef5c8d428137e551fb | [
"MIT"
] | 5 | 2017-09-08T09:41:58.000Z | 2018-11-26T13:16:55.000Z | src/KrTools.cpp | cildhdi/KrUI | c6f18620838f15a82ee65cef5c8d428137e551fb | [
"MIT"
] | null | null | null | src/KrTools.cpp | cildhdi/KrUI | c6f18620838f15a82ee65cef5c8d428137e551fb | [
"MIT"
] | 2 | 2018-10-08T20:18:09.000Z | 2020-04-13T01:47:19.000Z | #include "KrTools.h"
namespace KrUI
{
Gdiplus::SizeF GetTextSize(std::wstring strText, Gdiplus::Font* pFont, Gdiplus::Rect rect)
{
Gdiplus::GraphicsPath path;
Gdiplus::FontFamily fontfamily;
pFont->GetFamily(&fontfamily);
path.AddString(strText.c_str(), -1, &fontfamily, pFont->GetStyle(), pFont->GetSize(), rect,
Gdiplus::StringFormat::GenericTypographic()/*&m_StringFormat*/);
Gdiplus::RectF bounds;
path.GetBounds(&bounds);
return Gdiplus::SizeF(bounds.Width, bounds.Height);
}
bool WCharStringToUTF8String(const std::wstring &wstr, std::string &u8str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
u8str = conv.to_bytes(wstr);
return true;
}
bool UTF8StringToWCharString(const std::string &u8str, std::wstring &wstr)
{
std::wstring_convert<std::codecvt_utf8<wchar_t> > conv;
wstr = conv.from_bytes(u8str);
return true;
}
std::string WideStringToString(std::wstring wStr)
{
if (wStr.size() == 0)
{
return "";
}
char *pszBuf = NULL;
int needBytes = WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), -1, NULL, 0, NULL, NULL);
if (needBytes > 0)
{
pszBuf = new char[needBytes + 1];
ZeroMemory(pszBuf, (needBytes + 1) * sizeof(char));
WideCharToMultiByte(CP_ACP, 0, wStr.c_str(), -1, pszBuf, needBytes, NULL, NULL);
}
std::string str = pszBuf;
delete[] pszBuf;
return str;
}
std::wstring StringToWideString(std::string str)
{
if (str.size() == 0)
{
return L"";
}
wchar_t *pszBuf = NULL;
int needWChar = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
if (needWChar > 0)
{
pszBuf = new wchar_t[needWChar + 1];
ZeroMemory(pszBuf, (needWChar + 1) * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, pszBuf, needWChar);
}
std::wstring wStr = pszBuf;
delete[] pszBuf;
return wStr;
}
} | 25.774648 | 93 | 0.67541 | cildhdi |
2e668c6401e862a3bde6e7ee6eb790214b429c7e | 1,841 | hxx | C++ | src/libserver/css/css_property.hxx | korgoth1/rspamd | 154f69f000244785209dcef937c47f10ede1f113 | [
"Apache-2.0"
] | null | null | null | src/libserver/css/css_property.hxx | korgoth1/rspamd | 154f69f000244785209dcef937c47f10ede1f113 | [
"Apache-2.0"
] | null | null | null | src/libserver/css/css_property.hxx | korgoth1/rspamd | 154f69f000244785209dcef937c47f10ede1f113 | [
"Apache-2.0"
] | null | null | null | /*-
* Copyright 2021 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifndef RSPAMD_CSS_PROPERTY_HXX
#define RSPAMD_CSS_PROPERTY_HXX
#include <string>
#include "parse_error.hxx"
#include "contrib/expected/expected.hpp"
namespace rspamd::css {
/*
* To be extended with properties that are interesting from the email
* point of view
*/
enum class css_property_type {
PROPERTY_FONT,
PROPERTY_COLOR,
PROPERTY_BGCOLOR,
PROPERTY_BACKGROUND,
PROPERTY_HEIGHT,
PROPERTY_WIDTH,
PROPERTY_DISPLAY,
PROPERTY_VISIBILITY,
};
struct css_property {
css_property_type type;
static tl::expected<css_property,css_parse_error> from_bytes (const char *input,
size_t inlen);
};
}
/* Make properties hashable */
namespace std {
template<>
class hash<rspamd::css::css_property> {
public:
/* Mix bits to provide slightly better distribution but being constexpr */
constexpr size_t operator() (const rspamd::css::css_property &prop) const {
std::size_t key = 0xdeadbeef ^static_cast<std::size_t>(prop.type);
key = (~key) + (key << 21);
key = key ^ (key >> 24);
key = (key + (key << 3)) + (key << 8);
key = key ^ (key >> 14);
key = (key + (key << 2)) + (key << 4);
key = key ^ (key >> 28);
key = key + (key << 31);
return key;
}
};
}
#endif //RSPAMD_CSS_PROPERTY_HXX | 25.929577 | 81 | 0.705052 | korgoth1 |
2e67eeed9cedf80b049288d9e2fdc3aa7e4cf44d | 5,390 | cpp | C++ | src/convolution.cpp | likunlun0618/snn | 65d2d919ad40842eb1682b9484a067d792503318 | [
"MIT"
] | 4 | 2020-01-16T08:15:22.000Z | 2020-03-30T04:30:23.000Z | src/convolution.cpp | likunlun0618/snn | 65d2d919ad40842eb1682b9484a067d792503318 | [
"MIT"
] | null | null | null | src/convolution.cpp | likunlun0618/snn | 65d2d919ad40842eb1682b9484a067d792503318 | [
"MIT"
] | null | null | null | #include <iostream>
#include <sstream>
#include <cblas.h>
#include <cstdlib>
#include "convolution.h"
//#include "global.h"
//#include "time.h"
namespace snn
{
Module* createConvolution(std::string options)
{
// 目前没有做错误处理
// b=0表示添加bias,b=1表示不添加bias
// 将所有的逗号替换为空格
// 因为原始文件需要用空格做split,所有不能直接用带空格的字符串做options
for (char &ch : options)
ch = ch == ',' ? ' ' : ch;
int c, n, k, s, p, b;
std::stringstream(options) >> c >> n >> k >> s >> p >> b;
Convolution *conv;
if (b != 0)
conv = new Convolution(c, n, k, s, p, true);
else
conv = new Convolution(c, n, k, s, p, false);
return (Module*)conv;
}
Convolution::Convolution(int _c, int _n, int _k, int _s, int _p, bool _bias): s(_s), p(_p)
{
weight.resize(_n, _c, _k, _k);
if (_bias)
bias.resize(1, 1, 1, _n);
}
Convolution::~Convolution() {}
Tensor Convolution::forward(const std::vector<Tensor> &inp)
{
long t1, t2;
// t1 = time();
if (inp[0].c != weight.c)
{
; // 输入和weight的channel不符
}
// p表示padding,s表示步长
// weight.h == weight.w == kernel size
int outh = (inp[0].h + 2*p - weight.h + s) / s;
int outw = (inp[0].w + 2*p - weight.w + s) / s;
// 向storage申请了足量的内存
Tensor out(1, weight.n, outh, outw);
// t1 = system_time();
// 当bias为空Tensor的时候,bias.data为NULL
_convolution(
inp[0].data, weight.data, out.data, bias.data, \
weight.c, inp[0].h, inp[0].w, weight.n, weight.h, s, p \
);
// t2 = time();
/*
if (global == 1 && global_module == 9)
{
std::cout << weight.h << "," << s << "," << p << std::endl;
std::cout << t2 - t1 << std::endl;
}
//*/
return out;
}
int Convolution::parameters() const
{
if (bias.n * bias.c * bias.h * bias.w > 0)
return 2;
else
return 1;
}
// index == 0表示加载weight的参数
// index == 1表示加载bias的参数
int Convolution::load(float *data, int size, int index)
{
if (index == 0 && size != weight.n * weight.c * weight.h * weight.w)
return -1; // weight长度不符合
if (index == 1 && bias.n * bias.c * bias.h * bias.w <= 0)
return -2; // 此卷积层没有偏置,但却尝试给偏置赋值
if (index == 1 && size != bias.n * bias.c * bias.h * bias.w)
return -3; // bias长度不符合
if (index > 1)
return -4; // 卷积的参数最多只有两个
// TODO:改为memcpy
float *p = index == 0 ? weight.data : bias.data;
for (int i = 0; i < size; ++i)
p[i] = data[i];
return 0;
}
int Convolution::_convolution(float *inp, float *weight, float *out, float *bias, \
int c, int h, int w, int n, int k, int s, int p)
{
//long t1 ,t2;
//t1 = time();
int outh = (h + 2*p - k + s) / s;
int outw = (w + 2*p - k + s) / s;
float *tmp;
// trick
if (k == 1 && s == 1 && p == 0)
{
tmp = inp;
}
else
{
tmp = new float[c * k * k * outh * outw];
_im2col(inp, tmp, c, h, w, k, s, p);
}
//t2 = time();
// 偏置相关
float beta;
if (bias)
{
for (int i = n - 1; i >= 0; --i)
{
float *p_out = out + i * (outh * outw);
for (int j = outh * outw - 1; j >= 0; --j)
p_out[j] = bias[i];
}
beta = 1.;
}
else
beta = 0.;
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, outh*outw, c*k*k, 1., \
weight, c*k*k, tmp, outh*outw, beta, out, outh*outw);
if (k == 1 && s == 1 && p == 0)
return 0;
delete [] tmp;
/*
if (global == 1 && global_module == 31)
{
std::cout << k << "," << s << "," << p << std::endl;
std::cout << t2 - t1 << "us" << std::endl;
}
*/
return 0;
}
int Convolution::_im2col(float *inp, float *out, int c, int h, int w, int k, int s, int p)
{
int outh = (h + 2*p - k + s) / s;
int outw = (w + 2*p - k + s) / s;
#pragma omp parallel for num_threads(4)
for (int ci = 0; ci < c; ++ci)
{
float *input = inp + ci * h * w;
int offset = ci * k * k * outh * outw;
for (int kh = 0; kh < k; ++kh)
for (int kw = 0; kw < k; ++kw)
for (int i = 0; i < outh; ++i)
for (int j = 0; j < outw; ++j)
{
int row = kh + i * s - p;
int col = kw + j * s - p;
if (row >= 0 && row < h && col >= 0 && col < w)
out[offset++] = input[row * w + col];
else
out[offset++] = 0.;
}
}
return 0;
}
void Convolution::mergeBN(float *k, float *b, int size)
{
if (size != weight.n)
{
std::cout << "BatchNorm size != Convolution weight n" << std::endl;
exit(0);
}
// 假如当前的卷积层没有bias
if (bias.n * bias.c * bias.h * bias.w <= 0)
{
bias.resize(1, 1, 1, size);
for (int i = 0; i < size; ++i)
bias.data[i] = 0.;
}
// k2c表示k^2 * c,其中k是kernel size,c是channel
int k2c = weight.c * weight.h * weight.w;
for (int i = 0; i < size; ++i)
{
// 融合BN层的weight
for (int j = 0; j < k2c; ++j)
{
weight.data[i * k2c + j] *= k[i];
}
// 融合BN层的bias
bias.data[i] = bias.data[i] * k[i] + b[i];
}
}
} // namespace snn
| 23.744493 | 90 | 0.459184 | likunlun0618 |
2e7096429de074c6dc0b94ff65492ad592ecc077 | 5,675 | cpp | C++ | rds/src/rds_3_agent.cpp | epfl-lasa/rds | 574b3881dbaf4fdcd785dd96ba4c451928454b40 | [
"MIT"
] | 12 | 2020-08-18T09:01:50.000Z | 2022-03-17T19:53:30.000Z | rds/src/rds_3_agent.cpp | epfl-lasa/rds | 574b3881dbaf4fdcd785dd96ba4c451928454b40 | [
"MIT"
] | null | null | null | rds/src/rds_3_agent.cpp | epfl-lasa/rds | 574b3881dbaf4fdcd785dd96ba4c451928454b40 | [
"MIT"
] | 1 | 2021-08-25T13:12:55.000Z | 2021-08-25T13:12:55.000Z | #include "rds_3_agent.hpp"
#include "capsule.hpp"
#include "rds_3.hpp"
#include <cmath>
using Geometry2D::Vec2;
using AdditionalPrimitives2D::Circle;
using Geometry2D::HalfPlane2;
using Geometry2D::Capsule;
void RDS3CapsuleAgent::stepEuler(float dt,
const Vec2& v_nominal_p_ref,
const std::vector<Circle>& circle_objects)
{
std::vector<Circle> objects_local;
getCircleObjectsInLocalFrame(circle_objects, &objects_local);
Vec2 v_nominal_p_ref_local;
transformVectorGlobalToLocal(v_nominal_p_ref, &v_nominal_p_ref_local);
Geometry2D::RDS3 rds_3(rds_3_configuration.tau,
rds_3_configuration.delta, rds_3_configuration.v_max);
Vec2 v_corrected_p_ref_local;
rds_3.computeCorrectedVelocity(rds_3_configuration.robot_shape, rds_3_configuration.p_ref,
v_nominal_p_ref_local, objects_local, &v_corrected_p_ref_local);
float v_linear = v_corrected_p_ref_local.x*rds_3_configuration.p_ref.x/
rds_3_configuration.p_ref.y + v_corrected_p_ref_local.y;
float v_angular = -v_corrected_p_ref_local.x/rds_3_configuration.p_ref.y;
Vec2 robot_local_velocity = Vec2(0.f, v_linear);
Vec2 robot_global_velocity;
transformVectorLocalToGlobal(robot_local_velocity, &robot_global_velocity);
position = position + dt*robot_global_velocity;
orientation = orientation + dt*v_angular;
transformVectorLocalToGlobal(v_corrected_p_ref_local, &(this->last_step_p_ref_velocity));
}
void RDS3CapsuleAgent::getCircleObjectsInLocalFrame(const std::vector<Circle>& objects,
std::vector<Circle>* objects_local)
{
float rxx = std::cos(-orientation);
float rxy = std::sin(-orientation);
float ryx = -rxy;
float ryy = rxx;
objects_local->resize(0);
for (auto& c : objects)
{
objects_local->push_back(Circle(Vec2(rxx*(c.center - position).x + ryx*(c.center - position).y,
rxy*(c.center - position).x + ryy*(c.center - position).y), c.radius));
}
}
void RDS3CapsuleAgent::transformVectorGlobalToLocal(const Vec2& v_global, Vec2* v_local)
{
*v_local = Vec2(std::cos(orientation)*v_global.x + std::sin(orientation)*v_global.y,
-std::sin(orientation)*v_global.x + std::cos(orientation)*v_global.y);
}
void RDS3CapsuleAgent::transformVectorLocalToGlobal(const Vec2& v_local, Vec2* v_global)
{
*v_global = Vec2(std::cos(orientation)*v_local.x - std::sin(orientation)*v_local.y,
+std::sin(orientation)*v_local.x + std::cos(orientation)*v_local.y);
}
void RDS3CircleAgent::stepEuler(float dt, const Vec2& v_nominal_p_ref,
const std::vector<Circle>& circle_objects,
const std::vector<Capsule>& capsule_objects,
std::vector<Circle>::size_type circle_index_to_skip)
{
std::vector<Circle> circle_objects_local;
getCircleObjectsInLocalFrame(circle_objects, &circle_objects_local, circle_index_to_skip);
std::vector<Capsule> capsule_objects_local;
getCapsuleObjectsInLocalFrame(capsule_objects, &capsule_objects_local);
Vec2 v_nominal_p_ref_local;
transformVectorGlobalToLocal(v_nominal_p_ref, &v_nominal_p_ref_local);
Geometry2D::RDS3 rds_3(rds_3_configuration.tau,
rds_3_configuration.delta, rds_3_configuration.v_max);
Vec2 v_corrected_p_ref_local;
rds_3.computeCorrectedVelocity(rds_3_configuration.robot_shape, rds_3_configuration.p_ref,
v_nominal_p_ref_local, circle_objects_local, capsule_objects_local, &v_corrected_p_ref_local);
float v_linear = v_corrected_p_ref_local.x*rds_3_configuration.p_ref.x/
rds_3_configuration.p_ref.y + v_corrected_p_ref_local.y;
float v_angular = -v_corrected_p_ref_local.x/rds_3_configuration.p_ref.y;
Vec2 robot_local_velocity = Vec2(0.f, v_linear);
Vec2 robot_global_velocity;
transformVectorLocalToGlobal(robot_local_velocity, &robot_global_velocity);
position = position + dt*robot_global_velocity;
orientation = orientation + dt*v_angular;
transformVectorLocalToGlobal(v_corrected_p_ref_local, &(this->last_step_p_ref_velocity));
}
void RDS3CircleAgent::getCircleObjectsInLocalFrame(const std::vector<Circle>& circle_objects,
std::vector<Circle>* circle_objects_local,
std::vector<Circle>::size_type circle_index_to_skip)
{
float rxx = std::cos(-orientation);
float rxy = std::sin(-orientation);
float ryx = -rxy;
float ryy = rxx;
circle_objects_local->resize(0);
for (std::vector<Circle>::size_type i = 0; i != circle_objects.size(); i++)
{
if (i != circle_index_to_skip)
{
const Circle& c(circle_objects[i]);
circle_objects_local->push_back(Circle(Vec2(rxx*(c.center - position).x + ryx*(c.center - position).y,
rxy*(c.center - position).x + ryy*(c.center - position).y), c.radius));
}
}
}
void RDS3CircleAgent::getCapsuleObjectsInLocalFrame(const std::vector<Capsule>& capsule_objects,
std::vector<Capsule>* capsule_objects_local)
{
float rxx = std::cos(-orientation);
float rxy = std::sin(-orientation);
float ryx = -rxy;
float ryy = rxx;
capsule_objects_local->resize(0);
for (auto& c : capsule_objects)
{
capsule_objects_local->push_back(Capsule(c.radius(),
Vec2(rxx*(c.center_a() - position).x + ryx*(c.center_a() - position).y,
rxy*(c.center_a() - position).x + ryy*(c.center_a() - position).y),
Vec2(rxx*(c.center_b() - position).x + ryx*(c.center_b() - position).y,
rxy*(c.center_b() - position).x + ryy*(c.center_b() - position).y)));
}
}
void RDS3CircleAgent::transformVectorGlobalToLocal(const Vec2& v_global, Vec2* v_local)
{
*v_local = Vec2(std::cos(orientation)*v_global.x + std::sin(orientation)*v_global.y,
-std::sin(orientation)*v_global.x + std::cos(orientation)*v_global.y);
}
void RDS3CircleAgent::transformVectorLocalToGlobal(const Vec2& v_local, Vec2* v_global)
{
*v_global = Vec2(std::cos(orientation)*v_local.x - std::sin(orientation)*v_local.y,
+std::sin(orientation)*v_local.x + std::cos(orientation)*v_local.y);
} | 39.137931 | 105 | 0.773568 | epfl-lasa |
2e738dec6a3a3099cab30b75006463d8015d1cfa | 29,456 | cc | C++ | chrome/browser/media/history/media_history_feeds_table.cc | Ron423c/chromium | 2edf7b980065b648f8b2a6e52193d83832fe36b7 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | chrome/browser/media/history/media_history_feeds_table.cc | Ron423c/chromium | 2edf7b980065b648f8b2a6e52193d83832fe36b7 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | chrome/browser/media/history/media_history_feeds_table.cc | Ron423c/chromium | 2edf7b980065b648f8b2a6e52193d83832fe36b7 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2021-03-07T14:20:02.000Z | 2021-03-07T14:20:02.000Z | // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/media/history/media_history_feeds_table.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/unguessable_token.h"
#include "base/updateable_sequenced_task_runner.h"
#include "chrome/browser/media/feeds/media_feeds.pb.h"
#include "chrome/browser/media/feeds/media_feeds_utils.h"
#include "chrome/browser/media/history/media_history_origin_table.h"
#include "chrome/browser/media/history/media_history_store.h"
#include "sql/statement.h"
#include "url/gurl.h"
namespace media_history {
namespace {
// The maximum number of logos to allow.
const int kMaxLogoCount = 5;
base::UnguessableToken ProtoToUnguessableToken(
const media_feeds::FeedResetToken& proto) {
return base::UnguessableToken::Deserialize(proto.high(), proto.low());
}
void AssignStatement(sql::Statement* statement,
sql::Database* db,
const sql::StatementID& id,
const std::vector<std::string>& sql) {
statement->Assign(
db->GetCachedStatement(id, base::JoinString(sql, " ").c_str()));
}
} // namespace
const char MediaHistoryFeedsTable::kTableName[] = "mediaFeed";
const char MediaHistoryFeedsTable::kFeedReadResultHistogramName[] =
"Media.Feeds.Feed.ReadResult";
MediaHistoryFeedsTable::MediaHistoryFeedsTable(
scoped_refptr<base::UpdateableSequencedTaskRunner> db_task_runner)
: MediaHistoryTableBase(std::move(db_task_runner)) {}
MediaHistoryFeedsTable::~MediaHistoryFeedsTable() = default;
sql::InitStatus MediaHistoryFeedsTable::CreateTableIfNonExistent() {
if (!CanAccessDatabase())
return sql::INIT_FAILURE;
bool success = DB()->Execute(
base::StringPrintf("CREATE TABLE IF NOT EXISTS %s("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"origin_id INTEGER NOT NULL UNIQUE,"
"url TEXT NOT NULL, "
"last_discovery_time_s INTEGER, "
"last_fetch_time_s INTEGER, "
"user_status INTEGER DEFAULT 0, "
"last_fetch_result INTEGER DEFAULT 0, "
"fetch_failed_count INTEGER, "
"last_fetch_time_not_cache_hit_s INTEGER, "
"last_fetch_item_count INTEGER, "
"last_fetch_safe_item_count INTEGER, "
"last_fetch_play_next_count INTEGER, "
"last_fetch_content_types INTEGER, "
"logo BLOB, "
"display_name TEXT, "
"user_identifier BLOB, "
"last_display_time_s INTEGER, "
"reset_reason INTEGER DEFAULT 0, "
"reset_token BLOB, "
"cookie_name_filter TEXT, "
"safe_search_result INTEGER DEFAULT 0, "
"favicon TEXT, "
"CONSTRAINT fk_origin "
"FOREIGN KEY (origin_id) "
"REFERENCES origin(id) "
"ON DELETE CASCADE"
")",
kTableName)
.c_str());
if (success) {
success = DB()->Execute(
base::StringPrintf(
"CREATE INDEX IF NOT EXISTS mediaFeed_origin_id_index ON "
"%s (origin_id)",
kTableName)
.c_str());
}
if (success) {
success = DB()->Execute(
"CREATE INDEX IF NOT EXISTS mediaFeed_fetch_time_index ON "
"mediaFeed (last_fetch_time_s)");
}
if (success) {
success = DB()->Execute(
"CREATE INDEX IF NOT EXISTS mediaFeed_safe_search_result ON "
"mediaFeed (safe_search_result)");
}
if (success) {
success = DB()->Execute(
"CREATE INDEX IF NOT EXISTS mediaFeed_last_fetch_content_types_index "
"ON "
"mediaFeed (last_fetch_content_types)");
}
if (success) {
success = DB()->Execute(
"CREATE INDEX IF NOT EXISTS mediaFeed_top_feeds_index ON "
"mediaFeed (last_fetch_content_types, safe_search_result)");
}
if (success) {
success = DB()->Execute(
"CREATE INDEX IF NOT EXISTS mediaFeed_user_status_index ON "
"mediaFeed (user_status)");
}
if (!success) {
ResetDB();
LOG(ERROR) << "Failed to create media history feeds table.";
return sql::INIT_FAILURE;
}
return sql::INIT_OK;
}
bool MediaHistoryFeedsTable::DiscoverFeed(const GURL& url,
const base::Optional<GURL>& favicon) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return false;
const auto origin =
MediaHistoryOriginTable::GetOriginForStorage(url::Origin::Create(url));
const auto now = base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds();
base::Optional<GURL> feed_url;
base::Optional<int64_t> feed_id;
{
// Check if we already have a feed for the current origin;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"SELECT id, url FROM mediaFeed WHERE origin_id = (SELECT id FROM "
"origin WHERE origin = ?)"));
statement.BindString(0, origin);
while (statement.Step()) {
DCHECK(!feed_id);
DCHECK(!feed_url);
feed_id = statement.ColumnInt64(0);
feed_url = GURL(statement.ColumnString(1));
}
}
if (!feed_url || url != feed_url) {
// If the feed does not exist or exists and has a different URL then we
// should replace the feed.
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"INSERT OR REPLACE INTO mediaFeed "
"(origin_id, url, last_discovery_time_s, favicon) VALUES "
"((SELECT id FROM origin WHERE origin = ?), ?, ?, ?)"));
statement.BindString(0, origin);
statement.BindString(1, url.spec());
statement.BindInt64(2, now);
if (favicon.has_value()) {
statement.BindString(3, favicon->spec());
} else {
statement.BindNull(3);
}
return statement.Run() && DB()->GetLastChangeCount() == 1;
} else {
// If the feed already exists in the database with the same URL we should
// just update the last discovery time so we don't delete the old entry.
sql::Statement statement(
DB()->GetCachedStatement(SQL_FROM_HERE,
"UPDATE mediaFeed SET last_discovery_time_s = "
"?, favicon = ? WHERE id = ?"));
statement.BindInt64(0, now);
statement.BindInt64(1, *feed_id);
if (favicon.has_value()) {
statement.BindString(2, favicon->spec());
} else {
statement.BindNull(2);
}
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
}
std::vector<media_feeds::mojom::MediaFeedPtr> MediaHistoryFeedsTable::GetRows(
const MediaHistoryKeyedService::GetMediaFeedsRequest& request) {
std::vector<media_feeds::mojom::MediaFeedPtr> feeds;
if (!CanAccessDatabase())
return feeds;
base::Optional<double> origin_count;
double rank = 0;
const bool top_feeds =
request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::Type::
kTopFeedsForFetch ||
request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::Type::
kTopFeedsForDisplay;
std::vector<std::string> sql;
sql.push_back(
"SELECT "
"mediaFeed.id, "
"mediaFeed.url, "
"mediaFeed.last_discovery_time_s, "
"mediaFeed.last_fetch_time_s, "
"mediaFeed.user_status, "
"mediaFeed.last_fetch_result, "
"mediaFeed.fetch_failed_count, "
"mediaFeed.last_fetch_time_not_cache_hit_s, "
"mediaFeed.last_fetch_item_count, "
"mediaFeed.last_fetch_safe_item_count, "
"mediaFeed.last_fetch_play_next_count, "
"mediaFeed.last_fetch_content_types, "
"mediaFeed.logo, "
"mediaFeed.display_name, "
"mediaFeed.last_display_time_s, "
"mediaFeed.reset_reason, "
"mediaFeed.user_identifier, "
"mediaFeed.cookie_name_filter, "
"mediaFeed.safe_search_result, "
"mediaFeed.reset_token, "
"mediaFeed.favicon ");
sql::Statement statement;
if (top_feeds) {
// Check the request has the right parameters.
DCHECK(request.limit.has_value());
if (request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::Type::
kTopFeedsForDisplay) {
DCHECK(request.fetched_items_min.has_value());
} else if (request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::
Type::kTopFeedsForFetch) {
DCHECK(request.audio_video_watchtime_min.has_value());
}
// If we need the top feeds we should select rows from the origin table and
// LEFT JOIN mediaFeed. This means there should be a row for each origin
// and if there is a media feed that will be included.
sql.push_back(
",origin.aggregate_watchtime_audio_video_s "
"FROM origin "
"LEFT JOIN mediaFeed "
"ON origin.id = mediaFeed.origin_id");
// If we have an audio/video watchtime requirement we should add that.
if (request.audio_video_watchtime_min.has_value())
sql.push_back("WHERE origin.aggregate_watchtime_audio_video_s >= ?");
// If we have a content type filter then we should add that.
if (request.filter_by_type.has_value())
sql.push_back("WHERE mediaFeed.last_fetch_content_types & ?");
// Finally, order the results by watchtime.
sql.push_back("ORDER BY origin.aggregate_watchtime_audio_video_s DESC");
// Get the total count of the origins so we can calculate a percentile.
sql::Statement origin_statement(DB()->GetCachedStatement(
SQL_FROM_HERE, "SELECT COUNT(id) FROM origin"));
while (origin_statement.Step()) {
origin_count = origin_statement.ColumnDouble(0);
rank = *origin_count;
}
DCHECK(origin_count.has_value());
// For each different query combination we should have an assign statement
// call that will generate a unique SQL_FROM_HERE value.
if (request.audio_video_watchtime_min.has_value() &&
request.filter_by_type) {
AssignStatement(&statement, DB(), SQL_FROM_HERE, sql);
} else if (request.audio_video_watchtime_min.has_value()) {
AssignStatement(&statement, DB(), SQL_FROM_HERE, sql);
} else if (request.filter_by_type) {
AssignStatement(&statement, DB(), SQL_FROM_HERE, sql);
} else {
AssignStatement(&statement, DB(), SQL_FROM_HERE, sql);
}
// Now bind all the parameters to the query.
int bind_index = 0;
if (request.audio_video_watchtime_min.has_value()) {
statement.BindInt64(bind_index++,
request.audio_video_watchtime_min->InSeconds());
}
if (request.filter_by_type.has_value()) {
statement.BindInt64(bind_index++,
static_cast<int>(*request.filter_by_type));
}
} else if (request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::
Type::kSelectedFeedsForFetch) {
sql.push_back("FROM mediaFeed WHERE user_status = ?");
statement.Assign(DB()->GetCachedStatement(
SQL_FROM_HERE, base::JoinString(sql, " ").c_str()));
statement.BindInt64(
0, static_cast<int>(media_feeds::mojom::FeedUserStatus::kEnabled));
} else if (request.type ==
MediaHistoryKeyedService::GetMediaFeedsRequest::Type::kNewFeeds) {
sql.push_back("FROM mediaFeed WHERE user_status = ?");
statement.Assign(DB()->GetCachedStatement(
SQL_FROM_HERE, base::JoinString(sql, " ").c_str()));
statement.BindInt64(
0, static_cast<int>(media_feeds::mojom::FeedUserStatus::kAuto));
} else {
sql.push_back("FROM mediaFeed");
statement.Assign(DB()->GetCachedStatement(
SQL_FROM_HERE, base::JoinString(sql, " ").c_str()));
}
while (statement.Step()) {
rank--;
// If there is no mediaFeed data then skip this.
if (statement.GetColumnType(0) == sql::ColumnType::kNull)
continue;
auto feed = media_feeds::mojom::MediaFeed::New();
feed->last_fetch_item_count = statement.ColumnInt64(8);
feed->last_fetch_safe_item_count = statement.ColumnInt64(9);
// If we are getting the top feeds for display then we should filter by
// the number of fetched items or fetched safe search items.
if (request.type == MediaHistoryKeyedService::GetMediaFeedsRequest::Type::
kTopFeedsForDisplay) {
if (request.fetched_items_min_should_be_safe) {
if (feed->last_fetch_safe_item_count < *request.fetched_items_min)
continue;
} else {
if (feed->last_fetch_item_count < *request.fetched_items_min)
continue;
}
}
feed->user_status = static_cast<media_feeds::mojom::FeedUserStatus>(
statement.ColumnInt64(4));
feed->last_fetch_result =
static_cast<media_feeds::mojom::FetchResult>(statement.ColumnInt64(5));
feed->reset_reason =
static_cast<media_feeds::mojom::ResetReason>(statement.ColumnInt64(15));
feed->safe_search_result =
static_cast<media_feeds::mojom::SafeSearchResult>(
statement.ColumnInt64(18));
if (!IsKnownEnumValue(feed->user_status)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadUserStatus);
continue;
}
if (!IsKnownEnumValue(feed->last_fetch_result)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadFetchResult);
continue;
}
if (!IsKnownEnumValue(feed->reset_reason)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadResetReason);
continue;
}
if (!IsKnownEnumValue(feed->safe_search_result)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadSafeSearchResult);
continue;
}
if (statement.GetColumnType(12) == sql::ColumnType::kBlob) {
media_feeds::ImageSet image_set;
if (!GetProto(statement, 12, image_set)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadLogo);
continue;
}
feed->logos = media_feeds::ProtoToMediaImages(image_set, kMaxLogoCount);
}
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kSuccess);
feed->id = statement.ColumnInt64(0);
feed->url = GURL(statement.ColumnString(1));
feed->last_discovery_time = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromSeconds(statement.ColumnInt64(2)));
if (statement.GetColumnType(3) == sql::ColumnType::kInteger) {
feed->last_fetch_time = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromSeconds(statement.ColumnInt64(3)));
}
feed->fetch_failed_count = statement.ColumnInt64(6);
if (statement.GetColumnType(7) == sql::ColumnType::kInteger) {
feed->last_fetch_time_not_cache_hit =
base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromSeconds(statement.ColumnInt64(7)));
}
feed->last_fetch_play_next_count = statement.ColumnInt64(10);
feed->last_fetch_content_types = statement.ColumnInt64(11);
feed->display_name = statement.ColumnString(13);
if (statement.GetColumnType(14) == sql::ColumnType::kInteger) {
feed->last_display_time = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromSeconds(statement.ColumnInt64(14)));
}
if (top_feeds && origin_count > 1) {
feed->origin_audio_video_watchtime_percentile =
(rank / (*origin_count - 1)) * 100;
} else if (top_feeds) {
DCHECK_EQ(1, *origin_count);
feed->origin_audio_video_watchtime_percentile = 100;
}
if (statement.GetColumnType(16) == sql::ColumnType::kBlob) {
media_feeds::UserIdentifier identifier;
if (!GetProto(statement, 16, identifier)) {
base::UmaHistogramEnumeration(kFeedReadResultHistogramName,
FeedReadResult::kBadUserIdentifier);
continue;
}
feed->user_identifier = media_feeds::mojom::UserIdentifier::New();
feed->user_identifier->name = identifier.name();
feed->user_identifier->email = identifier.email();
auto image_url = GURL(identifier.image().url());
if (image_url.is_valid())
feed->user_identifier->image = ProtoToMediaImage(identifier.image());
}
if (statement.GetColumnType(17) == sql::ColumnType::kText)
feed->cookie_name_filter = statement.ColumnString(17);
if (statement.GetColumnType(19) == sql::ColumnType::kBlob) {
media_feeds::FeedResetToken token;
if (GetProto(statement, 19, token))
feed->reset_token = ProtoToUnguessableToken(token);
}
if (statement.GetColumnType(20) == sql::ColumnType::kText)
feed->favicon = GURL(statement.ColumnString(20));
if (top_feeds) {
feed->aggregate_watchtime =
base::TimeDelta::FromSeconds(statement.ColumnInt64(21));
}
feeds.push_back(std::move(feed));
// If we are returning top feeds then we should apply a limit here.
if (top_feeds && feeds.size() >= *request.limit)
break;
}
DCHECK(statement.Succeeded());
return feeds;
}
bool MediaHistoryFeedsTable::UpdateFeedFromFetch(
const int64_t feed_id,
const media_feeds::mojom::FetchResult result,
const bool was_fetched_from_cache,
const int item_count,
const int item_play_next_count,
const int item_content_types,
const std::vector<media_feeds::mojom::MediaImagePtr>& logos,
const media_feeds::mojom::UserIdentifier* user_identifier,
const std::string& display_name,
const int item_safe_count,
const std::string& cookie_name_filter) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return false;
int fetch_failed_count = 0;
{
if (result != media_feeds::mojom::FetchResult::kSuccess) {
// See how many times we have failed to fetch the feed.
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"SELECT fetch_failed_count FROM mediaFeed WHERE id = ?"));
statement.BindInt64(0, feed_id);
while (statement.Step()) {
DCHECK(!fetch_failed_count);
fetch_failed_count = statement.ColumnInt64(0) + 1;
}
}
}
sql::Statement statement;
if (was_fetched_from_cache) {
statement.Assign(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET last_fetch_time_s = ?, last_fetch_result = ?, "
"fetch_failed_count = ?, last_fetch_item_count = ?, "
"last_fetch_play_next_count = ?, last_fetch_content_types = ?, "
"logo = ?, display_name = ?, last_fetch_safe_item_count = ?, "
"user_identifier = ?, cookie_name_filter = ? WHERE id = ?"));
} else {
statement.Assign(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET last_fetch_time_s = ?, last_fetch_result = ?, "
"fetch_failed_count = ?, last_fetch_item_count = ?, "
"last_fetch_play_next_count = ?, last_fetch_content_types = ?, "
"logo = ?, display_name = ?, last_fetch_safe_item_count = ?, "
"user_identifier = ?, cookie_name_filter = ?, "
"last_fetch_time_not_cache_hit_s = ? "
"WHERE id = ?"));
}
statement.BindInt64(0,
base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds());
statement.BindInt64(1, static_cast<int>(result));
statement.BindInt64(2, fetch_failed_count);
statement.BindInt64(3, item_count);
statement.BindInt64(4, item_play_next_count);
statement.BindInt64(5, item_content_types);
if (!logos.empty()) {
BindProto(statement, 6,
media_feeds::MediaImagesToProto(logos, kMaxLogoCount));
} else {
statement.BindNull(6);
}
statement.BindString(7, display_name);
statement.BindInt64(8, item_safe_count);
if (user_identifier) {
media_feeds::UserIdentifier proto_id;
proto_id.set_name(user_identifier->name);
if (user_identifier->email.has_value())
proto_id.set_email(user_identifier->email.value());
media_feeds::MediaImageToProto(proto_id.mutable_image(),
user_identifier->image);
BindProto(statement, 9, proto_id);
} else {
statement.BindNull(9);
}
if (!cookie_name_filter.empty()) {
statement.BindString(10, cookie_name_filter);
} else {
statement.BindNull(10);
}
if (was_fetched_from_cache) {
statement.BindInt64(11, feed_id);
} else {
statement.BindInt64(
11, base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds());
statement.BindInt64(12, feed_id);
}
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
bool MediaHistoryFeedsTable::UpdateDisplayTime(const int64_t feed_id) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return false;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET last_display_time_s = ? WHERE id = ?"));
statement.BindInt64(0,
base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds());
statement.BindInt64(1, feed_id);
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
bool MediaHistoryFeedsTable::RecalculateSafeSearchItemCount(
const int64_t feed_id) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return false;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET last_fetch_safe_item_count = (SELECT COUNT(id) "
"FROM mediaFeedItem WHERE safe_search_result = ? AND feed_id = ?) WHERE "
"id = ?"));
statement.BindInt64(
0, static_cast<int>(media_feeds::mojom::SafeSearchResult::kSafe));
statement.BindInt64(1, feed_id);
statement.BindInt64(2, feed_id);
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
bool MediaHistoryFeedsTable::Reset(
const int64_t feed_id,
const media_feeds::mojom::ResetReason reason) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return false;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET last_fetch_time_s = NULL, last_fetch_result = 0, "
"fetch_failed_count = 0, last_fetch_time_not_cache_hit_s = NULL, "
"last_fetch_item_count = 0, last_fetch_safe_item_count = 0, "
"last_fetch_play_next_count = 0, last_fetch_content_types = 0, "
"logo = NULL, display_name = NULL, user_identifier = NULL, "
"reset_reason = ?, reset_token = ? WHERE id = ?"));
statement.BindInt64(0, static_cast<int>(reason));
// Store a new feed reset token to invalidate any fetches.
auto token = base::UnguessableToken::Create();
media_feeds::FeedResetToken proto_token;
proto_token.set_high(token.GetHighForSerialization());
proto_token.set_low(token.GetLowForSerialization());
BindProto(statement, 1, proto_token);
statement.BindInt64(2, feed_id);
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
base::Optional<MediaHistoryKeyedService::MediaFeedFetchDetails>
MediaHistoryFeedsTable::GetFetchDetails(const int64_t feed_id) {
if (!CanAccessDatabase())
return base::nullopt;
sql::Statement statement(
DB()->GetCachedStatement(SQL_FROM_HERE,
"SELECT url, last_fetch_result, reset_token "
"FROM mediaFeed WHERE id = ?"));
statement.BindInt64(0, feed_id);
while (statement.Step()) {
MediaHistoryKeyedService::MediaFeedFetchDetails details;
details.url = GURL(statement.ColumnString(0));
if (!details.url.is_valid())
return base::nullopt;
details.last_fetch_result =
static_cast<media_feeds::mojom::FetchResult>(statement.ColumnInt64(1));
if (!IsKnownEnumValue(details.last_fetch_result))
return base::nullopt;
if (statement.GetColumnType(2) == sql::ColumnType::kBlob) {
media_feeds::FeedResetToken token;
if (!GetProto(statement, 2, token))
return base::nullopt;
details.reset_token = ProtoToUnguessableToken(token);
}
return details;
}
return base::nullopt;
}
bool MediaHistoryFeedsTable::Delete(const int64_t feed_id) {
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE, "DELETE FROM mediaFeed WHERE id = ?"));
statement.BindInt64(0, feed_id);
return statement.Run() && DB()->GetLastChangeCount() >= 1;
}
bool MediaHistoryFeedsTable::ClearResetReason(const int64_t feed_id) {
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE, "UPDATE mediaFeed SET reset_reason = ? WHERE id = ?"));
statement.BindInt64(0,
static_cast<int>(media_feeds::mojom::ResetReason::kNone));
statement.BindInt64(1, feed_id);
return statement.Run() && DB()->GetLastChangeCount() == 1;
}
std::string MediaHistoryFeedsTable::GetCookieNameFilter(const int64_t feed_id) {
DCHECK_LT(0, DB()->transaction_nesting());
if (!CanAccessDatabase())
return std::string();
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE, "SELECT cookie_name_filter FROM mediaFeed WHERE id = ?"));
statement.BindInt64(0, feed_id);
while (statement.Step())
return statement.ColumnString(0);
return std::string();
}
std::set<int64_t> MediaHistoryFeedsTable::GetFeedsForOriginSubdomain(
const url::Origin& origin) {
std::set<int64_t> feeds;
if (!CanAccessDatabase())
return feeds;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"SELECT id, url FROM mediaFeed WHERE url LIKE ? AND (last_fetch_result > "
"0 OR reset_reason > 0)"));
std::vector<std::string> wildcard_parts = base::SplitString(
MediaHistoryOriginTable::GetOriginForStorage(origin),
url::kStandardSchemeSeparator, base::WhitespaceHandling::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
if (wildcard_parts.size() != 2)
return feeds;
statement.BindString(
0, base::StrCat({wildcard_parts[0], url::kStandardSchemeSeparator, "%.",
wildcard_parts[1], "/%"}));
while (statement.Step()) {
// This shouldn't happen but is a backup so we don't accidentally reset
// feeds that we should not.
auto url = GURL(statement.ColumnString(1));
if (!url.DomainIs(origin.host()))
continue;
feeds.insert(statement.ColumnInt64(0));
}
return feeds;
}
base::Optional<int64_t> MediaHistoryFeedsTable::GetFeedForOrigin(
const url::Origin& origin) {
if (!CanAccessDatabase())
return base::nullopt;
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"SELECT mediaFeed.id FROM origin LEFT JOIN mediaFeed ON "
"mediaFeed.origin_id = origin.id WHERE origin.origin = ? AND "
"(mediaFeed.last_fetch_result > 0 OR mediaFeed.reset_reason > 0)"));
statement.BindString(0, MediaHistoryOriginTable::GetOriginForStorage(origin));
while (statement.Step())
return statement.ColumnInt64(0);
return base::nullopt;
}
MediaHistoryKeyedService::PendingSafeSearchCheckList
MediaHistoryFeedsTable::GetPendingSafeSearchCheckItems() {
MediaHistoryKeyedService::PendingSafeSearchCheckList items;
if (!CanAccessDatabase())
return items;
sql::Statement statement(DB()->GetUniqueStatement(
"SELECT id, url FROM mediaFeed WHERE safe_search_result = ?"));
statement.BindInt64(
0, static_cast<int>(media_feeds::mojom::SafeSearchResult::kUnknown));
DCHECK(statement.is_valid());
while (statement.Step()) {
auto check =
std::make_unique<MediaHistoryKeyedService::PendingSafeSearchCheck>(
MediaHistoryKeyedService::SafeSearchCheckedType::kFeed,
statement.ColumnInt64(0));
GURL url(statement.ColumnString(1));
if (url.is_valid())
check->urls.insert(url);
if (!check->urls.empty())
items.push_back(std::move(check));
}
return items;
}
bool MediaHistoryFeedsTable::StoreSafeSearchResult(
int64_t feed_id,
media_feeds::mojom::SafeSearchResult result) {
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE mediaFeed SET safe_search_result = ? WHERE id = ?"));
statement.BindInt64(0, static_cast<int>(result));
statement.BindInt64(1, feed_id);
return statement.Run();
}
bool MediaHistoryFeedsTable::UpdateFeedUserStatus(
const int64_t feed_id,
media_feeds::mojom::FeedUserStatus status) {
sql::Statement statement(DB()->GetCachedStatement(
SQL_FROM_HERE, "UPDATE mediaFeed SET user_status = ? WHERE id = ?"));
statement.BindInt64(0, static_cast<int>(status));
statement.BindInt64(1, feed_id);
return statement.Run();
}
} // namespace media_history
| 35.150358 | 80 | 0.661869 | Ron423c |
2e74647c409d68563ee04a2d2e000e3eb05061dd | 11,623 | hpp | C++ | 180726_calculate/calculate2.1.1rc6/calculate/node.hpp | newlawrence/Talks | d4f4e6b6ecf8f1aaf32ca9a2364c99ee23612745 | [
"CC-BY-4.0"
] | null | null | null | 180726_calculate/calculate2.1.1rc6/calculate/node.hpp | newlawrence/Talks | d4f4e6b6ecf8f1aaf32ca9a2364c99ee23612745 | [
"CC-BY-4.0"
] | 1 | 2019-01-15T14:21:34.000Z | 2019-01-15T15:19:41.000Z | 180726_calculate/calculate2.1.1rc6/calculate/node.hpp | newlawrence/Talks | d4f4e6b6ecf8f1aaf32ca9a2364c99ee23612745 | [
"CC-BY-4.0"
] | null | null | null | /*
Calculate - Version 2.1.1rc6
Last modified 2018/07/23
Released under MIT license
Copyright (c) 2016-2018 Alberto Lorenzo <alorenzo.md@gmail.com>
*/
#ifndef __CALCULATE_NODE_HPP__
#define __CALCULATE_NODE_HPP__
#include <iterator>
#include <ostream>
#include <stack>
#include <regex>
#include <unordered_set>
#include "symbol.hpp"
namespace calculate {
template<typename Parser>
class Node {
friend struct std::hash<Node>;
friend calculate::Symbol<Node>;
friend Parser;
public:
using Lexer = typename Parser::Lexer;
using Type = typename Parser::Type;
using Symbol = calculate::Symbol<Node>;
using SymbolType = typename Symbol::SymbolType;
using const_iterator = typename std::vector<Node>::const_iterator;
using const_reverse_iterator = typename std::vector<Node>::const_reverse_iterator;
class VariableHandler {
public:
const std::vector<std::string> variables;
private:
std::size_t _size;
std::unique_ptr<Type[]> _values;
std::size_t _refcount;
std::shared_ptr<VariableHandler> _copy;
void _update(std::size_t) const {}
template<typename Last>
void _update(std::size_t n, Last last) { _values[n] = last; }
template<typename Head, typename... Args>
void _update(std::size_t n, Head head, Args... args) {
_values[n] = head;
_update(n + 1, args...);
}
public:
VariableHandler(std::vector<std::string> keys, Lexer* lexer) :
variables{std::move(keys)},
_size{variables.size()},
_values{std::make_unique<Type[]>(_size)},
_refcount{0u},
_copy{nullptr}
{
std::unordered_set<std::string> singles{variables.begin(), variables.end()};
for (const auto &var : variables) {
if (!std::regex_match(var, lexer->name_regex))
throw UnsuitableName{var};
else if (singles.erase(var) == 0)
throw RepeatedSymbol{var};
}
}
explicit VariableHandler(std::vector<std::string> keys) :
variables{std::move(keys)},
_size{variables.size()},
_values{std::make_unique<Type[]>(_size)},
_refcount{0u},
_copy{nullptr}
{}
std::shared_ptr<VariableHandler> rebuild(std::vector<std::string> keys) noexcept {
++_refcount;
if (_copy)
return _copy;
_copy = std::make_shared<VariableHandler>(std::move(keys));
return _copy;
}
void reset() noexcept {
if (!--_refcount)
_copy = nullptr;
}
std::size_t index(const std::string& token) const {
auto found = std::find(variables.begin(), variables.end(), token);
if (found != variables.end())
return found - variables.begin();
throw UndefinedSymbol{token};
}
Type& at(const std::string& token) const { return _values[index(token)]; }
template<typename Args>
std::enable_if_t<util::is_vectorizable_v<Type, Args>> update(Args&& vals) {
std::size_t i{};
for (const auto& val : vals) {
if (i < _size)
_values[i] = val;
++i;
}
if (_size != i)
throw ArgumentsMismatch{_size, i};
}
template<typename... Args>
void update(Args&&... vals) {
if (_size != sizeof...(vals))
throw ArgumentsMismatch{_size, sizeof...(vals)};
_update(0, std::forward<Args>(vals)...);
}
};
private:
std::shared_ptr<Lexer> _lexer;
std::shared_ptr<VariableHandler> _variables;
std::string _token;
std::unique_ptr<Symbol> _symbol;
std::vector<Node> _nodes;
std::size_t _hash;
Node(
std::shared_ptr<Lexer> _lexer,
std::shared_ptr<VariableHandler> variables,
std::string token,
std::unique_ptr<Symbol>&& symbol,
std::vector<Node>&& nodes,
std::size_t hash
) :
_lexer{std::move(_lexer)},
_variables{std::move(variables)},
_token{std::move(token)},
_symbol{std::move(symbol)},
_nodes{std::move(nodes)},
_hash{hash}
{
if (_nodes.size() != _symbol->arguments())
throw ArgumentsMismatch{_token, _nodes.size(), _symbol->arguments()};
}
std::vector<std::string> _pruned() const noexcept {
std::vector<std::string> pruned{};
auto handlers = _lexer->tokenize_postfix(postfix());
for (const auto& var : _variables->variables)
for (const auto& handler : handlers)
if (var == handler.token) {
pruned.push_back(var);
break;
}
return pruned;
}
bool _compare(const Node& other) const noexcept {
std::stack<const_iterator> these{}, those{}, endings{};
auto equal = [&](auto left, auto right) {
try {
return
left->_variables->index(left->_token) ==
right->_variables->index(right->_token);
}
catch (const UndefinedSymbol&) {
if (left->_symbol == right->_symbol)
return true;
return *(left->_symbol) == *(right->_symbol);
}
};
if (!equal(this, &other))
return false;
these.push(this->begin());
those.push(other.begin());
endings.push(this->end());
while(!these.empty()) {
auto &one = these.top(), &another = those.top();
if (one != endings.top()) {
if (!equal(one, another))
return false;
these.push(one->begin());
those.push(another->begin());
endings.push(one->end());
one++, another++;
continue;
}
these.pop();
those.pop();
endings.pop();
}
return true;
}
std::string _infix(bool right) const noexcept {
using Operator = Operator<Node>;
using Associativity = typename Operator::Associativity;
std::string infix{};
auto brace = [&](std::size_t i) {
const auto& node = _nodes[i];
auto po = static_cast<Operator*>(_symbol.get());
if (node._symbol->type() == SymbolType::OPERATOR) {
auto co = static_cast<Operator*>(node._symbol.get());
auto pp = po->precedence();
auto cp = co->precedence();
auto pa = !i ?
po->associativity() != Associativity::RIGHT :
po->associativity() != Associativity::LEFT;
if ((pa && cp < pp) || (!pa && cp <= pp))
return _lexer->left + node._infix(false) + _lexer->right;
}
auto r = right || i || po->associativity() == Associativity::RIGHT;
return node._infix(r);
};
switch (_symbol->type()) {
case (SymbolType::FUNCTION):
infix += _token + _lexer->left;
for (auto node = _nodes.begin(); node != _nodes.end(); node++) {
infix += node->_infix(false);
infix += (node + 1 != _nodes.end() ? _lexer->separator : "");
}
return infix + _lexer->right;
case (SymbolType::OPERATOR):
return infix + brace(0) + _token + brace(1);
default:
if (right && _lexer->prefixed(_token))
return _lexer->left + _token + _lexer->right;
return _token;
}
return infix;
}
public:
Node(const Node& other) noexcept :
_lexer{other._lexer},
_variables{other._variables->rebuild(other._pruned())},
_token{other._token},
_symbol{nullptr},
_nodes{other._nodes},
_hash{other._hash}
{
using Variable = Variable<Node>;
other._variables->reset();
try {
_symbol = Variable{_variables->at(_token)}.clone();
}
catch (const UndefinedSymbol&) {
_symbol = other._symbol->clone();
}
}
Node(Node&& other) noexcept :
_lexer{std::move(other._lexer)},
_variables{std::move(other._variables)},
_token{std::move(other._token)},
_symbol{std::move(other._symbol)},
_nodes{std::move(other._nodes)},
_hash{std::move(other._hash)}
{}
const Node& operator=(Node other) noexcept {
swap(*this, other);
return *this;
}
friend void swap(Node& one, Node& another) noexcept {
using std::swap;
swap(one._lexer, another._lexer);
swap(one._variables, another._variables);
swap(one._token, another._token);
swap(one._symbol, another._symbol);
swap(one._nodes, another._nodes);
}
operator Type() const {
if (_variables->variables.size() > 0)
throw ArgumentsMismatch{_variables->variables.size(), 0};
return _symbol->eval(_nodes);
}
template<typename... Args>
Type operator()(Args&&... args) const {
_variables->update(std::forward<Args>(args)...);
return _symbol->eval(_nodes);
}
bool operator==(const Node& other) const noexcept {
if (_hash != other._hash)
return false;
return _compare(other);
}
bool operator!=(const Node& other) const noexcept { return !operator==(other); }
const Node& operator[](std::size_t index) const { return _nodes[index]; }
const Node& at(std::size_t index) const { return _nodes.at(index); }
std::size_t size() const noexcept { return _nodes.size(); }
const_iterator begin() const noexcept { return _nodes.cbegin(); }
const_iterator end() const noexcept { return _nodes.cend(); }
const_iterator cbegin() const noexcept { return _nodes.cbegin(); }
const_iterator cend() const noexcept { return _nodes.cend(); }
const_reverse_iterator rbegin() const noexcept { return _nodes.crbegin(); }
const_reverse_iterator rend() const noexcept { return _nodes.crend(); }
const_reverse_iterator crbegin() const noexcept { return _nodes.crbegin(); }
const_reverse_iterator crend() const noexcept { return _nodes.crend(); }
friend std::ostream& operator<<(std::ostream& ostream, const Node& node) noexcept {
ostream << node.infix();
return ostream;
}
const Lexer& lexer() const noexcept { return *_lexer; }
const std::string& token() const noexcept { return _token; }
SymbolType type() const noexcept { return _symbol->type(); }
std::size_t branches() const noexcept { return _nodes.size(); }
std::string infix() const noexcept { return _infix(false); }
std::string postfix() const noexcept {
std::string postfix{};
for (const auto& node : _nodes)
postfix += node.postfix() + " ";
return postfix + _token;
}
const std::vector<std::string>& variables() const noexcept { return _variables->variables; }
};
}
namespace std {
template<typename Parser>
struct hash<calculate::Node<Parser>> {
size_t operator()(const calculate::Node<Parser>& node) const { return node._hash; }
};
}
#endif
| 30.748677 | 96 | 0.549772 | newlawrence |
2e74c0aa5a641a97d07e066f6db2f30cca3bb37c | 1,972 | cc | C++ | chrome/browser/extensions/api/guest_view/guest_view_internal_api.cc | aranajhonny/chromium | caf5bcb822f79b8997720e589334266551a50a13 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2019-01-16T03:57:39.000Z | 2019-01-16T03:57:39.000Z | chrome/browser/extensions/api/guest_view/guest_view_internal_api.cc | aranajhonny/chromium | caf5bcb822f79b8997720e589334266551a50a13 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2018-02-10T21:00:08.000Z | 2018-03-20T05:09:50.000Z | chrome/browser/extensions/api/guest_view/guest_view_internal_api.cc | aranajhonny/chromium | caf5bcb822f79b8997720e589334266551a50a13 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/guest_view/guest_view_internal_api.h"
#include "chrome/browser/guest_view/guest_view_base.h"
#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/guest_view_internal.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
GuestViewInternalCreateGuestFunction::
GuestViewInternalCreateGuestFunction() {
}
bool GuestViewInternalCreateGuestFunction::RunAsync() {
std::string view_type;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &view_type));
base::DictionaryValue* create_params;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &create_params));
GuestViewManager* guest_view_manager =
GuestViewManager::FromBrowserContext(browser_context());
GuestViewManager::WebContentsCreatedCallback callback =
base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback,
this);
guest_view_manager->CreateGuest(view_type,
extension_id(),
render_view_host()->GetProcess()->GetID(),
*create_params,
callback);
return true;
}
void GuestViewInternalCreateGuestFunction::CreateGuestCallback(
content::WebContents* guest_web_contents) {
int guest_instance_id = 0;
if (guest_web_contents) {
GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents);
guest_instance_id = guest->GetGuestInstanceID();
}
SetResult(new base::FundamentalValue(guest_instance_id));
SendResponse(true);
}
} // namespace extensions
| 35.854545 | 78 | 0.736308 | aranajhonny |
2e75e3e4a2162124b20c1c8bbefa485237ebd4e7 | 750 | cpp | C++ | contests/icpc/2019_taiwan_regional/c.cpp | phogbinh/cp | 41a86550e14571c8f54bbec9579060647e77209c | [
"MIT"
] | null | null | null | contests/icpc/2019_taiwan_regional/c.cpp | phogbinh/cp | 41a86550e14571c8f54bbec9579060647e77209c | [
"MIT"
] | null | null | null | contests/icpc/2019_taiwan_regional/c.cpp | phogbinh/cp | 41a86550e14571c8f54bbec9579060647e77209c | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
bool IsMutuallyExclusive( int a, int b, int c )
{
return a != b && a != c && b != c;
}
int main()
{
int n;
cin >> n;
int a[ 50 ];
for ( int index = 0; index < n; index++ )
{
cin >> a[ index ];
}
for ( int i = 0; i < n; i++ )
{
for ( int j = 0; j < n; j++ )
{
for ( int k = 0; k < n; k++ )
{
if ( IsMutuallyExclusive( i, j, k ) )
{
if ( ( a[ i ] - a[ j ] ) % a[ k ] != 0 )
{
cout << "no";
return 0;
}
}
}
}
}
cout << "yes";
return 0;
} | 19.736842 | 60 | 0.3 | phogbinh |
2e770860d8331c041eb4dc0ce3ea9ff1533f8ff2 | 575 | cpp | C++ | final/stl containers/[]_vs_at()_vs_it.cpp | coderica/effective_cpp | 456d30cf42c6c71dc7187d88e362651dd79ac3fe | [
"MIT"
] | null | null | null | final/stl containers/[]_vs_at()_vs_it.cpp | coderica/effective_cpp | 456d30cf42c6c71dc7187d88e362651dd79ac3fe | [
"MIT"
] | null | null | null | final/stl containers/[]_vs_at()_vs_it.cpp | coderica/effective_cpp | 456d30cf42c6c71dc7187d88e362651dd79ac3fe | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <string>
using namespace std;
void main()
{
vector<string> people = { "alice", "barbara", "cleo", "darlene", "edna" };
try {
for (auto i = 0; i < people.size(); i++)
cout << people[i] << " ";
cout << endl;
for (auto i = 0; i < people.size(); i++)
cout << people.at(i) << " ";
cout << endl;
for (auto it = people.begin(); it != people.end()+1; it++)
cout << *it << " ";
cout << endl;
}
catch (exception e)
{
cout << "Exception: " << e.what() << endl;
}
} //end main
| 20.535714 | 76 | 0.50087 | coderica |
2e789f06af897447476f1d56a49eef96e8e51284 | 552 | cc | C++ | lhd/Code/onlyread_.cc | xiyoulinuxgroup-2019-summer/TeamF | 7a661b172f7410583bd11335a3b049f9df8797a3 | [
"MIT"
] | null | null | null | lhd/Code/onlyread_.cc | xiyoulinuxgroup-2019-summer/TeamF | 7a661b172f7410583bd11335a3b049f9df8797a3 | [
"MIT"
] | null | null | null | lhd/Code/onlyread_.cc | xiyoulinuxgroup-2019-summer/TeamF | 7a661b172f7410583bd11335a3b049f9df8797a3 | [
"MIT"
] | 1 | 2019-07-15T06:28:11.000Z | 2019-07-15T06:28:11.000Z | //只读算法
//学习闭包的概念
#include<iostream>
#include<numeric>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
vector<int> b ;
b.push_back(1);
b.push_back(2);
b.push_back(3);
int sum = accumulate(a.cbegin(),a.cend(),0);
cout << sum << endl;
bool trus = equal(a.cbegin(),a.cend(),b.cbegin());
cout << trus << endl;
//accumualte 作为使用运算符和返回值的类型
//fill表示把一个迭代器赋值给一个东西
//不能在一个空容器中使用fill_n
return 0;
}
| 20.444444 | 55 | 0.597826 | xiyoulinuxgroup-2019-summer |
2e7b66ec8342af3df59b9b44bc85f6f26162f260 | 1,703 | cpp | C++ | practicals/chapter5/main_chap_5_6.cpp | rasmunk/set10108 | 563bb339ecea28de80fffd11b5866be4fc25344d | [
"MIT"
] | null | null | null | practicals/chapter5/main_chap_5_6.cpp | rasmunk/set10108 | 563bb339ecea28de80fffd11b5866be4fc25344d | [
"MIT"
] | null | null | null | practicals/chapter5/main_chap_5_6.cpp | rasmunk/set10108 | 563bb339ecea28de80fffd11b5866be4fc25344d | [
"MIT"
] | null | null | null | #include <mpi.h>
#include <iostream>
#include <random>
#include <chrono>
using namespace std;
using namespace std::chrono;
double monte_carlo_pi(unsigned int iterations) {
auto microsec = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch());
default_random_engine e(microsec.count());
uniform_real_distribution<double> distribution(0.0, 1.0);
unsigned int in_cicle = 0;
for (unsigned int i = 0; i < iterations; i++) {
auto x = distribution(e);
auto y = distribution(e);
auto length = sqrt((x * x) + (y * y));
if (length <= 1.0)
++in_cicle;
}
auto pi = (4.0 * in_cicle) / static_cast<double>(iterations);
return pi;
}
int main() {
auto result = MPI_Init(nullptr, nullptr);
if (result != MPI_SUCCESS) {
cout << "Error - initializing MPI" << endl;
MPI_Abort(MPI_COMM_WORLD, result);
return -1;
}
int num_proces, my_rank, length;
char hostname[MPI_MAX_PROCESSOR_NAME];
MPI_Comm_size(MPI_COMM_WORLD, &num_proces);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Get_processor_name(hostname, &length);
double local_sum, global_sum;
local_sum = monte_carlo_pi(static_cast<unsigned int>(pow(2, 24)));
// Print out local sum
cout.precision(numeric_limits<double>::digits10);
cout << my_rank << ":" << local_sum << endl;
// reduce
MPI_Reduce(&local_sum, &global_sum, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
if (my_rank == 0) {
global_sum /= 4.0;
cout << "Pi=" << global_sum << endl;
}
MPI_Finalize();
return 0;
}
| 26.609375 | 98 | 0.609513 | rasmunk |
2e7c3c3300e62bbc655d664e247ec281bd44ce2d | 567 | cpp | C++ | Leetcode Solution/Tree/Easy/897. Increasing Order Search Tree.cpp | bilwa496/Placement-Preparation | bd32ee717f671d95c17f524ed28b0179e0feb044 | [
"MIT"
] | 169 | 2021-05-30T10:02:19.000Z | 2022-03-27T18:09:32.000Z | Leetcode Solution/Tree/Easy/897. Increasing Order Search Tree.cpp | bilwa496/Placement-Preparation | bd32ee717f671d95c17f524ed28b0179e0feb044 | [
"MIT"
] | 1 | 2021-10-02T14:46:26.000Z | 2021-10-02T14:46:26.000Z | Leetcode Solution/Tree/Easy/897. Increasing Order Search Tree.cpp | bilwa496/Placement-Preparation | bd32ee717f671d95c17f524ed28b0179e0feb044 | [
"MIT"
] | 44 | 2021-05-30T19:56:29.000Z | 2022-03-17T14:49:00.000Z |
class Solution {
private:
TreeNode *prev=NULL;
public:
TreeNode* increasingBST(TreeNode* root) {
if(NULL == root)
return root;
//Traversing right subtree first
increasingBST(root->right);
root->right=prev;
prev=root;
TreeNode *res=root;
//If left subtree exists traverse left subtree and return leftmost node
if(root->left){
res=increasingBST(root->left);
root->left=NULL;
}
//else return root only
return res;
}
};
| 22.68 | 80 | 0.550265 | bilwa496 |
2e7c6a1586f6ca65bf01743261d5a11debb26189 | 1,782 | hpp | C++ | OptimExplorer/widgets/metrics.hpp | MarkTuddenham/OptimExplorer | 1fb724bb80b099ade76d9f8d6179cb561dedb9bd | [
"MIT"
] | 1 | 2020-08-18T20:55:26.000Z | 2020-08-18T20:55:26.000Z | OptimExplorer/widgets/metrics.hpp | MarkTuddenham/OptimExplorer | 1fb724bb80b099ade76d9f8d6179cb561dedb9bd | [
"MIT"
] | 4 | 2020-10-11T12:57:29.000Z | 2020-10-11T14:06:17.000Z | OptimExplorer/widgets/metrics.hpp | MarkTuddenham/OptimExplorer | 1fb724bb80b099ade76d9f8d6179cb561dedb9bd | [
"MIT"
] | null | null | null | #pragma once
#include "core/events.hpp"
#include "core/utils.hpp"
#include "widgets/utils.hpp"
#include "widgets/widget.hpp"
DISABLE_WARNING_PUSH_ALL
#include <Mahi/Gui.hpp>
DISABLE_WARNING_POP
#include <iostream>
#include <utility>
#include <vector>
namespace OptimExplorer
{
class MetricsWidget : public Widget
{
public:
MetricsWidget() : Widget("Metrics")
{
event_dispatcher.appendListener(EventType::ClearMetrics, [&](const Event& ev) {
m_valid_loss.clear();
m_train_loss.clear();
m_valid_acc.clear();
m_train_acc.clear();
m_scroll_train_loss.clear();
});
event_dispatcher.appendListener(EventType::TrainMetric, [&](const Event& ev) {
auto me = dynamic_cast<const MetricEvent&>(ev);
if (me.get_name() == "loss")
{
m_train_loss.emplace_back(me.get_metric());
m_scroll_train_loss.add_point(me.get_metric());
}
else if (me.get_name() == "accuracy")
{
m_train_acc.emplace_back(me.get_metric());
}
});
event_dispatcher.appendListener(EventType::ValidMetric, [&](const Event& ev) {
auto me = dynamic_cast<const MetricEvent&>(ev);
if (me.get_name() == "loss")
{
m_valid_loss.emplace_back(me.get_metric());
}
else if (me.get_name() == "accuracy")
{
m_valid_acc.emplace_back(me.get_metric());
}
});
}
void render() override;
private:
void render_loss();
void render_accuracy();
void render_confusion_matrix();
std::vector<std::pair<double, double>> m_valid_loss, m_train_loss;
std::vector<std::pair<double, double>> m_valid_acc, m_train_acc;
bool m_scrolling_paused = false;
float m_scroll_history = 1.0f;
ScrollingData m_scroll_train_loss;
};
} // namespace OptimExplorer | 24.081081 | 83 | 0.664422 | MarkTuddenham |
2e7c93b51435e63ab3b3cdc7886326fd55933ccd | 10,664 | cpp | C++ | qt-creator-opensource-src-4.6.1/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp | kevinlq/Qt-Creator-Opensource-Study | b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f | [
"MIT"
] | 5 | 2018-12-22T14:49:13.000Z | 2022-01-13T07:21:46.000Z | qt-creator-opensource-src-4.6.1/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp | kevinlq/Qt-Creator-Opensource-Study | b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f | [
"MIT"
] | null | null | null | qt-creator-opensource-src-4.6.1/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp | kevinlq/Qt-Creator-Opensource-Study | b8cadff1f33f25a5d4ef33ed93f661b788b1ba0f | [
"MIT"
] | 8 | 2018-07-17T03:55:48.000Z | 2021-12-22T06:37:53.000Z | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "jsonwizardpagefactory_p.h"
#include "jsonfieldpage.h"
#include "jsonfieldpage_p.h"
#include "jsonfilepage.h"
#include "jsonkitspage.h"
#include "jsonprojectpage.h"
#include "jsonsummarypage.h"
#include "jsonwizardfactory.h"
#include <utils/qtcassert.h>
#include <utils/wizardpage.h>
#include <QCoreApplication>
#include <QVariant>
namespace ProjectExplorer {
namespace Internal {
// --------------------------------------------------------------------
// FieldPageFactory:
// --------------------------------------------------------------------
FieldPageFactory::FieldPageFactory()
{
setTypeIdsSuffix(QLatin1String("Fields"));
JsonFieldPage::registerFieldFactory(QLatin1String("Label"), []() { return new LabelField; });
JsonFieldPage::registerFieldFactory(QLatin1String("Spacer"), []() { return new SpacerField; });
JsonFieldPage::registerFieldFactory(QLatin1String("LineEdit"), []() { return new LineEditField; });
JsonFieldPage::registerFieldFactory(QLatin1String("TextEdit"), []() { return new TextEditField; });
JsonFieldPage::registerFieldFactory(QLatin1String("PathChooser"), []() { return new PathChooserField; });
JsonFieldPage::registerFieldFactory(QLatin1String("CheckBox"), []() { return new CheckBoxField; });
JsonFieldPage::registerFieldFactory(QLatin1String("ComboBox"), []() { return new ComboBoxField; });
JsonFieldPage::registerFieldFactory(QLatin1String("IconList"), []() { return new IconListField; });
}
Utils::WizardPage *FieldPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
QTC_ASSERT(canCreate(typeId), return nullptr);
auto page = new JsonFieldPage(wizard->expander());
if (!page->setup(data)) {
delete page;
return nullptr;
}
return page;
}
bool FieldPageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
QTC_ASSERT(canCreate(typeId), return false);
QList<QVariant> list = JsonWizardFactory::objectOrList(data, errorMessage);
if (list.isEmpty()) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"When parsing fields of page \"%1\": %2")
.arg(typeId.toString()).arg(*errorMessage);
return false;
}
foreach (const QVariant &v, list) {
JsonFieldPage::Field *field = JsonFieldPage::Field::parse(v, errorMessage);
if (!field)
return false;
delete field;
}
return true;
}
// --------------------------------------------------------------------
// FilePageFactory:
// --------------------------------------------------------------------
FilePageFactory::FilePageFactory()
{
setTypeIdsSuffix(QLatin1String("File"));
}
Utils::WizardPage *FilePageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return nullptr);
return new JsonFilePage;
}
bool FilePageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" for a \"File\" page needs to be unset or an empty object.");
return false;
}
return true;
}
// --------------------------------------------------------------------
// KitsPageFactory:
// --------------------------------------------------------------------
static const char KEY_PROJECT_FILE[] = "projectFilePath";
static const char KEY_REQUIRED_FEATURES[] = "requiredFeatures";
static const char KEY_PREFERRED_FEATURES[] = "preferredFeatures";
KitsPageFactory::KitsPageFactory()
{
setTypeIdsSuffix(QLatin1String("Kits"));
}
Utils::WizardPage *KitsPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
QTC_ASSERT(canCreate(typeId), return nullptr);
auto page = new JsonKitsPage;
const QVariantMap dataMap = data.toMap();
page->setUnexpandedProjectPath(dataMap.value(QLatin1String(KEY_PROJECT_FILE)).toString());
page->setRequiredFeatures(dataMap.value(QLatin1String(KEY_REQUIRED_FEATURES)));
page->setPreferredFeatures(dataMap.value(QLatin1String(KEY_PREFERRED_FEATURES)));
return page;
}
static bool validateFeatureList(const QVariantMap &data, const QByteArray &key, QString *errorMessage)
{
QString message;
JsonKitsPage::parseFeatures(data.value(QLatin1String(key)), &message);
if (!message.isEmpty()) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"Error parsing \"%1\" in \"Kits\" page: %2")
.arg(QLatin1String(key), message);
return false;
}
return true;
}
bool KitsPageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
QTC_ASSERT(canCreate(typeId), return false);
if (data.isNull() || data.type() != QVariant::Map) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" must be a JSON object for \"Kits\" pages.");
return false;
}
QVariantMap tmp = data.toMap();
if (tmp.value(QLatin1String(KEY_PROJECT_FILE)).toString().isEmpty()) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"Kits\" page requires a \"%1\" set.")
.arg(QLatin1String(KEY_PROJECT_FILE));
return false;
}
return validateFeatureList(tmp, KEY_REQUIRED_FEATURES, errorMessage)
&& validateFeatureList(tmp, KEY_PREFERRED_FEATURES, errorMessage);
}
// --------------------------------------------------------------------
// ProjectPageFactory:
// --------------------------------------------------------------------
static const char KEY_PROJECT_NAME_VALIDATOR[] = "projectNameValidator";
ProjectPageFactory::ProjectPageFactory()
{
setTypeIdsSuffix(QLatin1String("Project"));
}
Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return nullptr);
auto page = new JsonProjectPage;
QVariantMap tmp = data.isNull() ? QVariantMap() : data.toMap();
QString description
= tmp.value(QLatin1String("trDescription"), QLatin1String("%{trDescription}")).toString();
page->setDescription(wizard->expander()->expand(description));
QString projectNameValidator
= tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR)).toString();
if (!projectNameValidator.isEmpty()) {
QRegularExpression regularExpression(projectNameValidator);
if (regularExpression.isValid())
page->setProjectNameRegularExpression(regularExpression);
}
return page;
}
bool ProjectPageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
Q_UNUSED(errorMessage);
QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && data.type() != QVariant::Map) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" must be empty or a JSON object for \"Project\" pages.");
return false;
}
QVariantMap tmp = data.toMap();
QString projectNameValidator
= tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR)).toString();
if (!projectNameValidator.isNull()) {
QRegularExpression regularExpression(projectNameValidator);
if (!regularExpression.isValid()) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"Invalid regular expression \"%1\" in \"%2\". %3").arg(
projectNameValidator, QLatin1String(KEY_PROJECT_NAME_VALIDATOR), regularExpression.errorString());
return false;
}
}
return true;
}
// --------------------------------------------------------------------
// SummaryPageFactory:
// --------------------------------------------------------------------
static const char KEY_HIDE_PROJECT_UI[] = "hideProjectUi";
SummaryPageFactory::SummaryPageFactory()
{
setTypeIdsSuffix(QLatin1String("Summary"));
}
Utils::WizardPage *SummaryPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return nullptr);
auto page = new JsonSummaryPage;
QVariant hideProjectUi = data.toMap().value(QLatin1String(KEY_HIDE_PROJECT_UI));
page->setHideProjectUiValue(hideProjectUi);
return page;
}
bool SummaryPageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.type() != QVariant::Map)) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" for a \"Summary\" page can be unset or needs to be an object.");
return false;
}
return true;
}
} // namespace Internal
} // namespace ProjectExplorer
| 36.772414 | 122 | 0.629501 | kevinlq |
2e7d2873f7b314fbce113a0526319ff88f7bf73d | 3,960 | hpp | C++ | SOFT_dynamics/include/SOFT/TROTTER_prop.hpp | deba-cyber/SOFT_dynamics | 7ccad22a01f2e2782bf829aa670acb8c90e83b68 | [
"MIT"
] | null | null | null | SOFT_dynamics/include/SOFT/TROTTER_prop.hpp | deba-cyber/SOFT_dynamics | 7ccad22a01f2e2782bf829aa670acb8c90e83b68 | [
"MIT"
] | null | null | null | SOFT_dynamics/include/SOFT/TROTTER_prop.hpp | deba-cyber/SOFT_dynamics | 7ccad22a01f2e2782bf829aa670acb8c90e83b68 | [
"MIT"
] | null | null | null | # if !defined (TROTTER)
# define TROTTER
# include <SOFT/constants.hpp>
# include <iosfwd>
# include <vector>
# include <string>
# include <fftw3.h>
/* function to generate potential part of Trotter product
* of type fftw_complex */
std::vector<fftw_complex> get_pot_trotter_part(const std::vector<double>& V_vect);
/*------------------------------------------------------------*/
/* function to generate ke part of Trotter product of type
* fftw_complex */
std::vector<fftw_complex> get_ke_trotter_part(std::vector<std::vector<double>>& p_grid_vect,
const std::vector<double>& freq_vect);
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
/** Throughout the propagation, wave function will be modified
* in place ..
* In each step of propagation ..
* first real space wave function will be acted on by potential
* part of the Trotter product .. in place
* then it would be Fourier Transformed .. in place
* momentum space wave function will be acted on by momentum part
* of the Trotter product .. in place
* then it would be back Fourier Transformed to real space .. in place **/
/*-------------------------------------------------------------*/
/* function for multiplying two fftw_complex vectors
* psi_cur_vect is to be modified in place
* after multiplying with the first vector */
void generate_fftw_complex_product(std::vector<fftw_complex>& trotter_act,
std::vector<fftw_complex>& psi_cur_vect);
/*-------------------------------------------------------------*/
/* function for generating momentum grid from real space grid
* size & real space grid spacing **/
void onedim_momentum_grid(std::vector<double>& p_grid,int N_pts,
double delta);
/*-------------------------------------------------------------*/
/* function for shifting DC component to the center for plotting
* purpose in Fourier domain ..**/
void fftwshift_4_plot(std::vector<fftw_complex>& inplotvect,
std::vector<fftw_complex>& invect);
/*-------------------------------------------------------------*/
/** function for shifting DC component of momentum grid to
* the center for plotting purpose **/
void fftwshift_momentum_grid_4_plot(std::vector<double>& p_grid,
std::vector<double>& p_grid_4_plot);
/*-------------------------------------------------------------*/
/* complex multidimensional transform using basic interface */
/***************** plan forward ***********************/
void plan_Multidim_ForwardFFT(fftw_plan& plan, int N_pts,
const int* sizevect,int rank, const std::string& type);
/***************** plan backward ***********************/
void plan_Multidim_BackwardFFT(fftw_plan& plan, int N_pts,
const int* sizevect,int rank, const std::string& type);
/*-------------------------------------------------------------*/
/* complex one dimensional FFT using basic interface */
/***************** plan forward ***********************/
void plan_ForwardFFT_1d(fftw_plan& plan,int N_pts,
const std::string& type);
/***************** plan backward ***********************/
void plan_BackwardFFT_1d(fftw_plan& plan,int N_pts,
const std::string& type);
/****************** Execute FFT **********************/
void execute_inplaceFFT(std::vector<fftw_complex>& in,
const std::string& direction,fftw_plan plan);
void execute_outofplaceFFT(std::vector<fftw_complex>& in,
std::vector<fftw_complex>& out,
const std::string& direction,fftw_plan plan);
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* function to return real,imaginary parts & absolute value of
* the wave function from <fftw_complex> type */
void rtrn_real_imag_norm(std::vector<double>& rtrn_real_imag_nrm_vect,
const std::vector<fftw_complex>& psi_cur_vect);
/*--------------------------------------------------------------*/
# endif
| 33.277311 | 92 | 0.558838 | deba-cyber |
2e858331884578dde4fd38bc96a3199e87f64bc4 | 135 | cpp | C++ | BOJ_CPP/14490.cpp | tnsgh9603/BOJ_CPP | 432b1350f6c67cce83aec3e723e30a3c6b5dbfda | [
"MIT"
] | null | null | null | BOJ_CPP/14490.cpp | tnsgh9603/BOJ_CPP | 432b1350f6c67cce83aec3e723e30a3c6b5dbfda | [
"MIT"
] | null | null | null | BOJ_CPP/14490.cpp | tnsgh9603/BOJ_CPP | 432b1350f6c67cce83aec3e723e30a3c6b5dbfda | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
int main(){int a,b,g;scanf("%is_prime:%is_prime",&a,&b);g=std::gcd(a,b);printf("%is_prime:%is_prime",a/g,b/g);} | 67.5 | 111 | 0.644444 | tnsgh9603 |
2e8875fe1d9e64bc928c3b7f179c5be93507012b | 7,877 | cpp | C++ | addons/ofxPostProcessing/src/NoiseWarpPass.cpp | creatologist/openFrameworks0084 | aa74f188f105b62fbcecb7baf2b41d56d97cf7bc | [
"MIT"
] | null | null | null | addons/ofxPostProcessing/src/NoiseWarpPass.cpp | creatologist/openFrameworks0084 | aa74f188f105b62fbcecb7baf2b41d56d97cf7bc | [
"MIT"
] | null | null | null | addons/ofxPostProcessing/src/NoiseWarpPass.cpp | creatologist/openFrameworks0084 | aa74f188f105b62fbcecb7baf2b41d56d97cf7bc | [
"MIT"
] | null | null | null | /*
* NoiseWarpPass.cpp
*
* Copyright (c) 2013, Neil Mendoza, http://www.neilmendoza.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Neil Mendoza 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 "NoiseWarpPass.h"
namespace itg
{
NoiseWarpPass::NoiseWarpPass(const ofVec2f& aspect, bool arb, float frequency, float amplitude, float speed) :
frequency(frequency), amplitude(amplitude), speed(speed), RenderPass(aspect, arb, "noisewarp")
{
string fragShaderSrc = STRINGIFY(
uniform sampler2D tex;
uniform float frequency;
uniform float amplitude;
uniform float time;
uniform float speed;
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
vec3 mod289(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise(vec3 v)
{
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
// x0 = x0 - 0.0 + 0.0 * C.xxx;
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857; // 1.0/7.0
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
// end of noise functions
void main()
{
vec2 texCoords = gl_TexCoord[0].st + vec2(
amplitude * (snoise(vec3(frequency * gl_TexCoord[0].s, frequency * gl_TexCoord[0].t, speed * time))),
amplitude * (snoise(vec3(frequency * gl_TexCoord[0].s + 17.0, frequency * gl_TexCoord[0].t, speed * time)))
);
gl_FragColor = texture2D(tex, texCoords);
}
);
shader.setupShaderFromSource(GL_FRAGMENT_SHADER, fragShaderSrc);
shader.linkProgram();
#ifdef _ITG_TWEAKABLE
addParameter("amplitude", this->amplitude, "min=0 max=10");
addParameter("frequency", this->frequency, "min=0 max=20");
addParameter("speed", this->speed, "min=0 max=10");
#endif
}
void NoiseWarpPass::render(ofFbo& readFbo, ofFbo& writeFbo, ofTexture& depth)
{
writeFbo.begin();
shader.begin();
shader.setUniform1f("time", ofGetElapsedTimef());
shader.setUniformTexture("tex", readFbo.getTextureReference(), 0);
shader.setUniform1f("frequency", frequency);
shader.setUniform1f("amplitude", amplitude);
shader.setUniform1f("speed", speed);
texturedQuad(0, 0, writeFbo.getWidth(), writeFbo.getHeight());
shader.end();
writeFbo.end();
}
} | 42.578378 | 127 | 0.488765 | creatologist |
2e899fcc8e830a4309ab4fadaabf9c32c4de6dc6 | 28,125 | cpp | C++ | lammps-master/lib/atc/ChargeRegulator.cpp | rajkubp020/helloword | 4bd22691de24b30a0f5b73821c35a7ac0666b034 | [
"MIT"
] | null | null | null | lammps-master/lib/atc/ChargeRegulator.cpp | rajkubp020/helloword | 4bd22691de24b30a0f5b73821c35a7ac0666b034 | [
"MIT"
] | null | null | null | lammps-master/lib/atc/ChargeRegulator.cpp | rajkubp020/helloword | 4bd22691de24b30a0f5b73821c35a7ac0666b034 | [
"MIT"
] | null | null | null | #include "ChargeRegulator.h"
#include "PoissonSolver.h"
#include "LammpsInterface.h"
#include "ATC_Coupling.h"
#include "ATC_Error.h"
#include "Function.h"
#include "PrescribedDataManager.h"
#include <sstream>
#include <string>
#include <vector>
#include <utility>
#include <set>
using ATC_Utility::to_string;
using std::stringstream;
using std::map;
using std::vector;
using std::set;
using std::pair;
using std::string;
namespace ATC {
//========================================================
// Class ChargeRegulator
//========================================================
//--------------------------------------------------------
// Constructor
//--------------------------------------------------------
ChargeRegulator::ChargeRegulator(ATC_Coupling * atc) :
AtomicRegulator(atc)
{
// do nothing
}
//--------------------------------------------------------
// Destructor
//--------------------------------------------------------
ChargeRegulator::~ChargeRegulator()
{
map<string,ChargeRegulatorMethod *>::iterator it;
for (it = regulators_.begin(); it != regulators_.end(); it++) {
if (it->second) delete it->second;
}
}
//--------------------------------------------------------
// modify:
// parses and adjusts charge regulator state based on
// user input, in the style of LAMMPS user input
//--------------------------------------------------------
bool ChargeRegulator::modify(int narg, char **arg)
{
bool foundMatch = false;
return foundMatch;
}
//--------------------------------------------------------
// construct methods
//--------------------------------------------------------
void ChargeRegulator::construct_methods()
{
AtomicRegulator::construct_methods();
if (atc_->reset_methods()) {
// eliminate existing methods
delete_method();
// consruct new ones
map<string, ChargeRegulatorParameters>::iterator itr;
for (itr = parameters_.begin();
itr != parameters_.end(); itr++) {
string tag = itr->first;
if (regulators_.find(tag) != regulators_.end()) delete regulators_[tag];
ChargeRegulatorParameters & p = itr->second;
LammpsInterface * lammpsInterface = LammpsInterface::instance();
p.groupBit = lammpsInterface->group_bit(tag);
if (! p.groupBit)
throw ATC_Error("ChargeRegulator::initialize group not found");
switch (p.method) {
case NONE: {
regulators_[tag] = new ChargeRegulatorMethod(this,p);
break;
}
case FEEDBACK: {
regulators_[tag] = new ChargeRegulatorMethodFeedback(this,p);
break;
}
case IMAGE_CHARGE: {
regulators_[tag] = new ChargeRegulatorMethodImageCharge(this,p);
break;
}
case EFFECTIVE_CHARGE: {
regulators_[tag] = new ChargeRegulatorMethodEffectiveCharge(this,p);
break;
}
default:
throw ATC_Error("ChargeRegulator::construct_method unknown charge regulator type");
}
}
}
}
//--------------------------------------------------------
// initialize:
//--------------------------------------------------------
void ChargeRegulator::initialize()
{
map<string, ChargeRegulatorMethod *>::iterator itr;
for (itr = regulators_.begin();
itr != regulators_.end(); itr++) { itr->second->initialize(); }
atc_->set_boundary_integration_type(boundaryIntegrationType_);
AtomicRegulator::reset_nlocal();
AtomicRegulator::delete_unused_data();
needReset_ = false;
}
//--------------------------------------------------------
// apply pre force
//--------------------------------------------------------
void ChargeRegulator::apply_pre_force(double dt)
{
map<string, ChargeRegulatorMethod *>::iterator itr;
for (itr = regulators_.begin();
itr != regulators_.end(); itr++) { itr->second->apply_pre_force(dt);}
}
//--------------------------------------------------------
// apply post force
//--------------------------------------------------------
void ChargeRegulator::apply_post_force(double dt)
{
map<string, ChargeRegulatorMethod *>::iterator itr;
for (itr = regulators_.begin();
itr != regulators_.end(); itr++) { itr->second->apply_post_force(dt);}
}
//--------------------------------------------------------
// output
//--------------------------------------------------------
void ChargeRegulator::output(OUTPUT_LIST & outputData) const
{
map<string, ChargeRegulatorMethod *>::const_iterator itr;
for (itr = regulators_.begin();
itr != regulators_.end(); itr++) { itr->second->output(outputData);}
}
//========================================================
// Class ChargeRegulatorMethod
//========================================================
//--------------------------------------------------------
// Constructor
// Grab references to ATC and ChargeRegulator
//--------------------------------------------------------
ChargeRegulatorMethod::ChargeRegulatorMethod
(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & p)
: RegulatorShapeFunction(chargeRegulator),
chargeRegulator_(chargeRegulator),
lammpsInterface_(LammpsInterface::instance()),
rC_(0), rCsq_(0),
targetValue_(NULL),
targetPhi_(p.value),
surface_(p.faceset),
atomGroupBit_(p.groupBit),
boundary_(false),
depth_(p.depth),
surfaceType_(p.surfaceType),
permittivity_(p.permittivity),
initialized_(false)
{
const FE_Mesh * feMesh = atc_->fe_engine()->fe_mesh();
feMesh->faceset_to_nodeset(surface_,nodes_);
// assume flat get normal and primary coord
PAIR face = *(surface_.begin());
normal_.reset(nsd_);
feMesh->face_normal(face,0,normal_);
DENS_MAT faceCoords;
feMesh->face_coordinates(face,faceCoords);
point_.reset(nsd_);
for (int i=0; i < nsd_; i++) { point_(i) = faceCoords(i,0); }
#ifdef ATC_VERBOSE
stringstream ss; ss << "point: (" << point_(0) << "," << point_(1) << "," << point_(2) << ") normal: (" << normal_(0) << "," << normal_(1) << "," << normal_(2) << ") depth: " << depth_;
lammpsInterface_->print_msg_once(ss.str());
#endif
sum_.reset(nsd_);
}
//--------------------------------------------------------
// Initialize
//--------------------------------------------------------
// nomenclature might be a bit backwark: control --> nodes that exert the control, & influence --> atoms that feel the influence
void ChargeRegulatorMethod::initialize(void)
{
interscaleManager_ = &(atc_->interscale_manager());
poissonSolver_ =chargeRegulator_->poisson_solver();
if (! poissonSolver_) throw ATC_Error("need a poisson solver to initialize charge regulator");
// atomic vectors
// nodal information
nNodes_ = atc_->num_nodes();
// constants
rC_ = lammpsInterface_->pair_cutoff();
rCsq_ = rC_*rC_;
qV2e_ = lammpsInterface_->qv2e();
qqrd2e_ = lammpsInterface_->qqrd2e();
// note derived method set intialized to true
}
int ChargeRegulatorMethod::nlocal() { return atc_->nlocal(); }
void ChargeRegulatorMethod::set_greens_functions(void)
{
// set up Green's function per node
for (int i = 0; i < nNodes_; i++) {
set<int> localNodes;
for (int j = 0; j < nNodes_; j++)
localNodes.insert(j);
// call Poisson solver to get Green's function for node i
DENS_VEC globalGreensFunction;
poissonSolver_->greens_function(i,globalGreensFunction);
// store green's functions as sparse vectors only on local nodes
set<int>::const_iterator thisNode;
SparseVector<double> sparseGreensFunction(nNodes_);
for (thisNode = localNodes.begin(); thisNode != localNodes.end(); thisNode++)
sparseGreensFunction(*thisNode) = globalGreensFunction(*thisNode);
greensFunctions_.push_back(sparseGreensFunction);
}
}
//--------------------------------------------------------
// output
//--------------------------------------------------------
void ChargeRegulatorMethod::output(OUTPUT_LIST & outputData)
{
//vector<double> localSum(sum_.size());
//lammpsInteface_->allsum(localSum.pointer,sum_.pointer,sum_.size());
DENS_VEC localSum(sum_.size());
lammpsInterface_->allsum(localSum.ptr(),sum_.ptr(),sum_.size());
for (int i = 0; i < sum_.size(); i++) {
string name = "charge_regulator_influence_"+to_string(i);
// atc_->fe_engine()->add_global(name,sum_[i]);
}
}
//========================================================
// Class ChargeRegulatorMethodFeedback
//========================================================
//--------------------------------------------------------
// Constructor
//--------------------------------------------------------
ChargeRegulatorMethodFeedback::ChargeRegulatorMethodFeedback
(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & p)
: ChargeRegulatorMethod (chargeRegulator, p),
controlNodes_(nodes_),
influenceGroupBit_(p.groupBit)
{
nControlNodes_ = controlNodes_.size();
sum_.resize(1);
}
//--------------------------------------------------------
// Initialize
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::initialize(void)
{
ChargeRegulatorMethod::initialize();
if (surfaceType_ != ChargeRegulator::CONDUCTOR)
throw ATC_Error("currently charge feedback can only mimic a conductor");
set_influence();
set_influence_matrix();
initialized_ = true;
}
//--------------------------------------------------------
// Initialize
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::construct_transfers(void)
{
ChargeRegulatorMethod::construct_transfers();
InterscaleManager & interscaleManager((atomicRegulator_->atc_transfer())->interscale_manager());
PerAtomSparseMatrix<double> * atomShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost");
if (!atomShapeFunctions) {
atomShapeFunctions = new PerAtomShapeFunction(atomicRegulator_->atc_transfer(),
interscaleManager.per_atom_quantity("AtomicGhostCoarseGrainingPositions"),
interscaleManager.per_atom_int_quantity("AtomGhostElement"),
GHOST);
interscaleManager.add_per_atom_sparse_matrix(atomShapeFunctions,"InterpolantGhost");
}
}
//--------------------------------------------------------
// find measurement atoms and nodes
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::set_influence(void)
{
// get nodes that overlap influence atoms & compact list of influence atoms
boundary_ =
atc_->nodal_influence(influenceGroupBit_,influenceNodes_,influenceAtoms_);
nInfluenceAtoms_ = influenceAtoms_.size(); // local
nInfluenceNodes_ = influenceNodes_.size(); // global
stringstream ss; ss << "control nodes: " << nControlNodes_ << " influence nodes: " << nInfluenceNodes_ << " local influence atoms: " << nInfluenceAtoms_ ;
lammpsInterface_->print_msg(ss.str());
if (nInfluenceNodes_ == 0) throw ATC_Error("no influence nodes");
const Array<int> & map = (boundary_) ? atc_->ghost_to_atom_map() : atc_->internal_to_atom_map();
for (set<int>::const_iterator itr = influenceAtoms_.begin(); itr != influenceAtoms_.end(); itr++) {
influenceAtomsIds_.insert(map(*itr));
}
}
//--------------------------------------------------------
// constuct a Green's submatrix
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::set_influence_matrix(void)
{
// construct control-influence matrix bar{G}^-1: ds{p} = G{p,m}^-1 dphi{m}
//
if (nInfluenceNodes_ < nControlNodes_) throw ATC_Error(" least square not implmented ");
if (nInfluenceNodes_ > nControlNodes_) throw ATC_Error(" solve not possible ");
DENS_MAT G(nInfluenceNodes_,nControlNodes_);
DENS_VEC G_I;
set<int>::const_iterator itr,itr2,itr3;
const Array<int> & nmap = atc_->fe_engine()->fe_mesh()->global_to_unique_map();
int i = 0;
for (itr = influenceNodes_.begin(); itr != influenceNodes_.end(); itr++) {
poissonSolver_->greens_function(*itr, G_I);
int j = 0;
for (itr2 = controlNodes_.begin(); itr2 != controlNodes_.end(); itr2++) {
int jnode = nmap(*itr2);
G(i,j++) = G_I(jnode);
}
i++;
}
invG_ = inv(G);
// construct the prolong-restrict projector N N^T for influence nodes only
InterscaleManager & interscaleManager(atc_->interscale_manager());
const SPAR_MAT & N_Ia = (boundary_) ?
(interscaleManager.per_atom_sparse_matrix("InterpolantGhost"))->quantity():
(interscaleManager.per_atom_sparse_matrix("Interpolant"))->quantity();
NT_.reset(nInfluenceAtoms_,nInfluenceNodes_);
DENS_MAT NNT(nInfluenceNodes_,nInfluenceNodes_);
int k = 0;
for (itr3 = influenceAtoms_.begin(); itr3 != influenceAtoms_.end(); itr3++) {
int katom = *itr3;
int i = 0;
for (itr = influenceNodes_.begin(); itr != influenceNodes_.end(); itr++) {
int Inode = *itr;
int j = 0;
NT_(k,i) = N_Ia(katom,Inode);
for (itr2 = influenceNodes_.begin(); itr2 != influenceNodes_.end(); itr2++) {
int Jnode = *itr2;
NNT(i,j++) += N_Ia(katom,Inode)*N_Ia(katom,Jnode);
}
i++;
}
k++;
}
// swap contributions across processors
DENS_MAT localNNT = NNT;
int count = NNT.nRows()*NNT.nCols();
lammpsInterface_->allsum(localNNT.ptr(),NNT.ptr(),count);
invNNT_ = inv(NNT);
// total influence matrix
if (nInfluenceAtoms_ > 0) { NTinvNNTinvG_ = NT_*invNNT_*invG_; }
}
//--------------------------------------------------------
// change potential/charge pre-force calculation
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::apply_pre_force(double dt)
{
sum_ = 0;
if (nInfluenceAtoms_ == 0) return; // nothing to do
apply_feedback_charges();
}
//--------------------------------------------------------
// apply feedback charges to atoms
//--------------------------------------------------------
void ChargeRegulatorMethodFeedback::apply_feedback_charges()
{
double * q = lammpsInterface_->atom_charge();
// calculate error in potential on the control nodes
const DENS_MAT & phiField = (atc_->field(ELECTRIC_POTENTIAL)).quantity();
DENS_MAT dphi(nControlNodes_,1);
int i = 0;
set<int>::const_iterator itr;
for (itr = controlNodes_.begin(); itr != controlNodes_.end(); itr++) {
dphi(i++,0) = targetPhi_ - phiField(*itr,0);
}
// construct the atomic charges consistent with the correction
DENS_MAT dq = NTinvNNTinvG_*dphi;
i = 0;
for (itr = influenceAtomsIds_.begin(); itr != influenceAtomsIds_.end(); itr++) {
sum_(0) += dq(i,0);
q[*itr] += dq(i++,0);
}
(interscaleManager_->fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE))->force_reset();
(interscaleManager_->fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE, GHOST))->force_reset();
}
//========================================================
// Class ChargeRegulatorMethodImageCharge
//========================================================
//--------------------------------------------------------
// Constructor
//--------------------------------------------------------
ChargeRegulatorMethodImageCharge::ChargeRegulatorMethodImageCharge
(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & p)
: ChargeRegulatorMethod (chargeRegulator, p),
imageNodes_(nodes_)
{
}
//--------------------------------------------------------
// Initialize
//--------------------------------------------------------
void ChargeRegulatorMethodImageCharge::initialize(void)
{
ChargeRegulatorMethod::initialize();
if (surfaceType_ != ChargeRegulator::DIELECTRIC) throw ATC_Error("currently image charge can only mimic a dielectric");
double eps1 = permittivity_;// dielectric
double eps2 = lammpsInterface_->dielectric();// ambient
permittivityRatio_ = (eps2-eps1)/(eps2+eps1);
#ifdef ATC_VERBOSE
stringstream ss; ss << "permittivity ratio: " << permittivityRatio_;
lammpsInterface_->print_msg_once(ss.str());
#endif
set_greens_functions();
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
initialized_ = true;
}
//--------------------------------------------------------
// change potential/charge post-force calculation
//--------------------------------------------------------
void ChargeRegulatorMethodImageCharge::apply_post_force(double dt)
{
sum_ = 0;
apply_local_forces();
//correct_forces();
}
//--------------------------------------------------------
// apply local coulomb forces
// -- due to image charges
//--------------------------------------------------------
void ChargeRegulatorMethodImageCharge::apply_local_forces()
{
int inum = lammpsInterface_->neighbor_list_inum();
int * ilist = lammpsInterface_->neighbor_list_ilist();
int * numneigh = lammpsInterface_->neighbor_list_numneigh();
int ** firstneigh = lammpsInterface_->neighbor_list_firstneigh();
const int *mask = lammpsInterface_->atom_mask();
///..............................................
double ** x = lammpsInterface_->xatom();
double ** f = lammpsInterface_->fatom();
double * q = lammpsInterface_->atom_charge();
// loop over neighbor list
for (int ii = 0; ii < inum; ii++) {
int i = ilist[ii];
double qi = q[i];
if ((mask[i] & atomGroupBit_) && qi != 0.) {
double* fi = f[i];
DENS_VEC xi(x[i],nsd_);
// distance to surface
double dn = reflect(xi);
// all ions near the interface/wall
// (a) self image
if (dn < rC_) { // close enough to wall to have explicit image charges
double factor_coul = 1;
double dx = 2.*dn; // distance to image charge
double fn = factor_coul*qi*qi*permittivityRatio_/dx;
fi[0] += fn*normal_[0];
fi[1] += fn*normal_[1];
fi[2] += fn*normal_[2];
sum_ += fn*normal_;
// (b) neighbor images
int * jlist = firstneigh[i];
int jnum = numneigh[i];
for (int jj = 0; jj < jnum; jj++) {
int j = jlist[jj];
// this changes j
double factor_coul = lammpsInterface_->coulomb_factor(j);
double qj = q[j];
if (qj != 0.) { // all charged neighbors
DENS_VEC xj(x[j],nsd_);
dn = reflect(xj);
DENS_VEC dx = xi-xj;
double r2 = dx.norm_sq();
// neighbor image j' inside cutoff from i
if (r2 < rCsq_) {
double fm = factor_coul*qi*qj*permittivityRatio_/r2;
fi[0] += fm*dx(0);
fi[1] += fm*dx(1);
fi[2] += fm*dx(2);
sum_ += fm*dx;
}
}
}
} // end i < rC if
}
}
// update managed data
(interscaleManager_->fundamental_atom_quantity(LammpsInterface::ATOM_FORCE))->force_reset();
}
//--------------------------------------------------------
// correct charge densities
// - to reflect image charges
//--------------------------------------------------------
void ChargeRegulatorMethodImageCharge::correct_charge_densities()
{
}
//--------------------------------------------------------
// correct_forces
// - due to image charge density used in short-range solution
//--------------------------------------------------------
void ChargeRegulatorMethodImageCharge::correct_forces()
{
}
//========================================================
// Class ChargeRegulatorMethodEffectiveCharge
//========================================================
//--------------------------------------------------------
// Constructor
//--------------------------------------------------------
ChargeRegulatorMethodEffectiveCharge::ChargeRegulatorMethodEffectiveCharge(
ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & p)
: ChargeRegulatorMethod (chargeRegulator, p),
chargeDensity_(p.value),
useSlab_(false)
{
}
//--------------------------------------------------------
// add_charged_surface
//--------------------------------------------------------
void ChargeRegulatorMethodEffectiveCharge::initialize( )
{
ChargeRegulatorMethod::initialize();
boundary_ = atc_->is_ghost_group(atomGroupBit_);
// set face sources to all point at unit function for use in integration
SURFACE_SOURCE faceSources;
map<PAIR, Array<XT_Function*> > & fs(faceSources[ELECTRIC_POTENTIAL]);
XT_Function * f = XT_Function_Mgr::instance()->constant_function(1.);
set< PAIR >::const_iterator fsItr;
for (fsItr = surface_.begin(); fsItr != surface_.end(); fsItr++) {
Array < XT_Function * > & dof = fs[*fsItr];
dof.reset(1);
dof(0) = f;
}
// computed integrals of nodal shape functions on face
FIELDS nodalFaceWeights;
Array<bool> fieldMask(NUM_FIELDS); fieldMask(ELECTRIC_POTENTIAL) = true;
(atc_->fe_engine())->compute_fluxes(fieldMask,0.,faceSources,nodalFaceWeights);
const DENS_MAT & w = (nodalFaceWeights[ELECTRIC_POTENTIAL].quantity());
// Get coordinates of each node in face set
for (set<int>::const_iterator n =nodes_.begin(); n != nodes_.end(); n++) {
DENS_VEC x = atc_->fe_engine()->fe_mesh()->nodal_coordinates(*n);
// compute effective charge at each node I
// multiply charge density by integral of N_I over face
double v = w(*n,0)*chargeDensity_;
pair<DENS_VEC,double> p(x,v);
nodeXFMap_[*n] = p;
}
// set up data structure holding charged faceset information
FIELDS sources;
double k = lammpsInterface_->coulomb_constant();
string fname = "radial_power";
double xtArgs[8];
xtArgs[0] = 0; xtArgs[1] = 0; xtArgs[2] = 0;
xtArgs[3] = 1; xtArgs[4] = 1; xtArgs[5] = 1;
xtArgs[6] = k*chargeDensity_;
xtArgs[7] = -1.;
const DENS_MAT & s(sources[ELECTRIC_POTENTIAL].quantity());
NODE_TO_XF_MAP::iterator XFitr;
for (XFitr = nodeXFMap_.begin(); XFitr != nodeXFMap_.end(); XFitr++) {
// evaluate voltage at each node I
// set up X_T function for integration: k*chargeDensity_/||x_I - x_s||
// integral is approximated in two parts:
// 1) near part with all faces within r < rcrit evaluated as 2 * pi * rcrit * k sigma A/A0, A is area of this region and A0 = pi * rcrit^2, so 2 k sigma A / rcrit
// 2) far part evaluated using Gaussian quadrature on faceset
DENS_VEC x((XFitr->second).first);
xtArgs[0] = x(0); xtArgs[1] = x(1); xtArgs[2] = x(2);
f = XT_Function_Mgr::instance()->function(fname,8,xtArgs);
for (fsItr = surface_.begin(); fsItr != surface_.end(); fsItr++) {
fs[*fsItr] = f;
}
// perform integration to get quantities at nodes on facesets
// V_J' = int_S N_J k*sigma/|x_I - x_s| dS
(atc_->fe_engine())->compute_fluxes(fieldMask,0.,faceSources,sources);
// sum over all nodes in faceset to get total potential:
// V_I = sum_J VJ'
int node = XFitr->first;
nodalChargePotential_[node] = s(node,0);
double totalPotential = 0.;
for (set<int>::const_iterator n =nodes_.begin(); n != nodes_.end(); n++) {
totalPotential += s(*n,0); }
// assign an XT function per each node and
// then call the prescribed data manager and fix each node individually.
f = XT_Function_Mgr::instance()->constant_function(totalPotential);
(atc_->prescribed_data_manager())->fix_field(node,ELECTRIC_POTENTIAL,0,f);
}
initialized_ = true;
}
//--------------------------------------------------------
// add effective forces post LAMMPS force call
//--------------------------------------------------------
void ChargeRegulatorMethodEffectiveCharge::apply_post_force(double dt)
{
apply_local_forces();
}
//--------------------------------------------------------
// apply_charged_surfaces
//--------------------------------------------------------
void ChargeRegulatorMethodEffectiveCharge::apply_local_forces()
{
double * q = lammpsInterface_->atom_charge();
_atomElectricalForce_.resize(nlocal(),nsd_);
double penalty = poissonSolver_->penalty_coefficient();
if (penalty <= 0.0) throw ATC_Error("ExtrinsicModelElectrostatic::apply_charged_surfaces expecting non zero penalty");
double dx[3];
const DENS_MAT & xa((interscaleManager_->per_atom_quantity("AtomicCoarseGrainingPositions"))->quantity());
// WORKSPACE - most are static
SparseVector<double> dv(nNodes_);
vector<SparseVector<double> > derivativeVectors;
derivativeVectors.reserve(nsd_);
const SPAR_MAT_VEC & shapeFunctionDerivatives((interscaleManager_->vector_sparse_matrix("InterpolateGradient"))->quantity());
DenseVector<INDEX> nodeIndices;
DENS_VEC nodeValues;
NODE_TO_XF_MAP::const_iterator inode;
for (inode = nodeXFMap_.begin(); inode != nodeXFMap_.end(); inode++) {
int node = inode->first;
DENS_VEC xI = (inode->second).first;
double qI = (inode->second).second;
double phiI = nodalChargePotential_[node];
for (int i = 0; i < nlocal(); i++) {
int atom = (atc_->internal_to_atom_map())(i);
double qa = q[atom];
if (qa != 0) {
double dxSq = 0.;
for (int j = 0; j < nsd_; j++) {
dx[j] = xa(i,j) - xI(j);
dxSq += dx[j]*dx[j];
}
if (dxSq < rCsq_) {
// first apply pairwise coulombic interaction
if (!useSlab_) {
double coulForce = qqrd2e_*qI*qa/(dxSq*sqrtf(dxSq));
for (int j = 0; j < nsd_; j++) {
_atomElectricalForce_(i,j) += dx[j]*coulForce; }
}
// second correct for FE potential induced by BCs
// determine shape function derivatives at atomic location
// and construct sparse vectors to store derivative data
for (int j = 0; j < nsd_; j++) {
shapeFunctionDerivatives[j]->row(i,nodeValues,nodeIndices);
derivativeVectors.push_back(dv);
for (int k = 0; k < nodeIndices.size(); k++) {
derivativeVectors[j](nodeIndices(k)) = nodeValues(k); }
}
// compute greens function from charge quadrature
SparseVector<double> shortFePotential(nNodes_);
shortFePotential.add_scaled(greensFunctions_[node],penalty*phiI);
// compute electric field induced by charge
DENS_VEC efield(nsd_);
for (int j = 0; j < nsd_; j++) {
efield(j) = -.1*dot(derivativeVectors[j],shortFePotential); }
// apply correction in atomic forces
double c = qV2e_*qa;
for (int j = 0; j < nsd_; j++) {
if ((!useSlab_) || (j==nsd_)) {
_atomElectricalForce_(i,j) -= c*efield(j);
}
}
}
}
}
}
}
}; // end namespace
| 38.213315 | 190 | 0.542862 | rajkubp020 |
2e8a46e74dc16ecd02c750626c56df64ccf1c24d | 2,487 | cpp | C++ | TameParse/Dfa/character_lexer.cpp | Logicalshift/TameParse | 59512fc5c098046922099a59328ca82f174d8f68 | [
"MIT"
] | 6 | 2018-01-10T22:37:32.000Z | 2019-06-19T04:44:32.000Z | TameParse/Dfa/character_lexer.cpp | Logicalshift/TameParse | 59512fc5c098046922099a59328ca82f174d8f68 | [
"MIT"
] | null | null | null | TameParse/Dfa/character_lexer.cpp | Logicalshift/TameParse | 59512fc5c098046922099a59328ca82f174d8f68 | [
"MIT"
] | null | null | null | //
// character_lexer.cpp
// Parse
//
// Created by Andrew Hunter on 14/05/2011.
//
// Copyright (c) 2011-2012 Andrew Hunter
//
// 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 "TameParse/Dfa/character_lexer.h"
using namespace std;
using namespace dfa;
character_lexer::lstream::lstream(lexer_symbol_stream* stream)
: m_Stream(stream) {
}
character_lexer::lstream::~lstream() {
delete m_Stream;
}
/// \brief Fills in the contents of the specified pointer with the next lexeme (or NULL if the end of input has been reached)
lexeme_stream& character_lexer::lstream::operator>>(lexeme*& result) {
int next;
(*m_Stream) >> next;
if (next != symbol_set::end_of_input) {
lexeme::symbols syms;
syms.push_back(next);
result = new lexeme(syms, m_Position.current_position(), next);
m_Position.update_position(next);
} else {
result = NULL;
}
return *this;
}
///
/// \brief Creates a new lexer to process the specified symbol stream
///
/// The lexeme_stream should take ownership of the supplied lexer_symbol_stream and delete it once it has finished with it
///
lexeme_stream* character_lexer::create_stream(lexer_symbol_stream* stream) const {
return new lstream(stream);
}
///
/// \brief The number of bytes used by this lexer
///
size_t character_lexer::size() const {
return sizeof(character_lexer);
}
| 33.16 | 125 | 0.70969 | Logicalshift |
2e8de52c7b8eba8b6384f4e172062063721a5859 | 2,491 | cpp | C++ | atcoder/arc016/C/main.cpp | Johniel/contests | b692eff913c20e2c1eb4ff0ce3cd4c57900594e0 | [
"Unlicense"
] | null | null | null | atcoder/arc016/C/main.cpp | Johniel/contests | b692eff913c20e2c1eb4ff0ce3cd4c57900594e0 | [
"Unlicense"
] | 19 | 2016-05-04T02:46:31.000Z | 2021-11-27T06:18:33.000Z | atcoder/arc016/C/main.cpp | Johniel/contests | b692eff913c20e2c1eb4ff0ce3cd4c57900594e0 | [
"Unlicense"
] | null | null | null | // atcoder/arc016/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/
#include <bits/stdc++.h>
#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))
using namespace std;
template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }
template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;
constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;
int main(int argc, char *argv[])
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.setf(ios_base::fixed);
cout.precision(15);
int n, m;
while (cin >> n >> m) {
int c[m];
vec<pair<int, double>> p[m];
for (int i = 0; i < m; ++i) {
int x;
cin >> x >> c[i];
p[i].resize(x);
cin >> p[i];
each (j, p[i]) {
--j.first;
j.second /= 100.0;
}
}
const int BIT = 1 << 11;
double dp[BIT];
fill(dp, dp + BIT, 1e128);
dp[0] = 0;
for (int bit = 0; bit < (1 << n); ++bit) {
for (int i = 0; i < m; ++i) {
double x = c[i];
double y = 0;
for (int j = 0; j < p[i].size(); ++j) {
const int k = p[i][j].first;
if (bit & (1 << k)) {
x += dp[bit ^ (1 << k)] * p[i][j].second;
} else {
y += p[i][j].second;
}
}
if (y < 1.0) setmin(dp[bit], x / (1.0 - y));
}
}
cout << dp[(1 << n) - 1] << endl;
}
return 0;
}
| 31.531646 | 150 | 0.507828 | Johniel |
2e8edfceab6cdbce0f13bb726b0bf78829749ec3 | 68,192 | cpp | C++ | src/trunk/libs/seiscomp3/system/model.cpp | yannikbehr/seiscomp3 | ebb44c77092555eef7786493d00ac4efc679055f | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/trunk/libs/seiscomp3/system/model.cpp | yannikbehr/seiscomp3 | ebb44c77092555eef7786493d00ac4efc679055f | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/trunk/libs/seiscomp3/system/model.cpp | yannikbehr/seiscomp3 | ebb44c77092555eef7786493d00ac4efc679055f | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /***************************************************************************
* Copyright (C) by GFZ Potsdam *
* *
* You can redistribute and/or modify this program under the *
* terms of the SeisComP Public License. *
* *
* 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 *
* SeisComP Public License for more details. *
***************************************************************************/
#define SEISCOMP_COMPONENT System
#include <seiscomp3/logging/log.h>
#include <seiscomp3/system/model.h>
#include <seiscomp3/core/strings.h>
#include <seiscomp3/core/system.h>
#include <seiscomp3/utils/files.h>
#include <boost/version.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fstream>
#include <set>
using namespace std;
using namespace Seiscomp::Config;
namespace fs = boost::filesystem;
namespace Seiscomp {
namespace System {
IMPLEMENT_RTTI(Parameter, "Parameter", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Parameter)
IMPLEMENT_RTTI(Structure, "Structure", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Structure)
IMPLEMENT_RTTI(Group, "Group", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Group)
IMPLEMENT_RTTI(Section, "Section", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Section)
//IMPLEMENT_RTTI(BindingSection, "BindingSection", Core::BaseObject)
//IMPLEMENT_RTTI_METHODS(BindingSection)
IMPLEMENT_RTTI(Binding, "Binding", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Binding)
IMPLEMENT_RTTI(ModuleBinding, "ModuleBinding", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(ModuleBinding)
IMPLEMENT_RTTI(Module, "Module", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Module)
IMPLEMENT_RTTI(Station, "Station", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Station)
IMPLEMENT_RTTI(Model, "Model", Core::BaseObject)
IMPLEMENT_RTTI_METHODS(Model)
namespace {
class CaseSensitivityCheck : public ModelVisitor {
public:
CaseSensitivityCheck(ConfigDelegate *delegate,
Module *target, int stage, Config::Symbol *symbol)
: _delegate(delegate), _target(target), _stage(stage), _symbol(symbol) {}
protected:
virtual bool visit(Module *m) { return m == _target; }
virtual bool visit(Section*) { return true; }
virtual bool visit(Group*) { return true; }
virtual bool visit(Structure*) { return true; }
virtual void visit(Parameter *p, bool unknown) {
if ( !unknown && Core::compareNoCase(p->variableName, _symbol->name) == 0 ) {
ConfigDelegate::CSConflict csc;
csc.module = _target;
csc.parameter = p;
csc.stage = _stage;
csc.symbol = _symbol;
if ( _delegate ) _delegate->caseSensitivityConflict(csc);
}
}
private:
ConfigDelegate *_delegate;
Module *_target;
int _stage;
Config::Symbol *_symbol;
};
class DuplicateNameCheck : public ModelVisitor {
public:
DuplicateNameCheck()
: _currentModule(NULL) {}
bool visit(Module *mod) {
_currentModule = mod;
_currentSection = NULL;
_names.clear();
return true;
}
bool visit(Section *sec) {
_currentSection = sec;
return true;
}
bool visit(Group*) {
return true;
}
bool visit(Structure*) {
return true;
}
void visit(Parameter *param, bool unknown) {
// Do not touch unknown parameters
if ( unknown ) return;
if ( _names.find(param->variableName) != _names.end() ) {
if ( _currentSection )
SEISCOMP_WARNING("C duplicate parameter definition in %s/%s: %s",
_currentModule->definition->name.c_str(),
_currentSection->name.c_str(),
param->variableName.c_str());
else
SEISCOMP_WARNING("C duplicate parameter definition in %s: %s",
_currentModule->definition->name.c_str(),
param->variableName.c_str());
return;
}
_names.insert(param->variableName);
}
private:
const Module *_currentModule;
const Section *_currentSection;
set<string> _names;
};
struct ParameterCollector : public ModelVisitor {
ParameterCollector() {}
virtual bool visit(Module*) {
return true;
}
virtual bool visit(Section*) {
return true;
}
virtual bool visit(Group*) {
return true;
}
virtual bool visit(Structure*) {
return true;
}
virtual void visit(Parameter *param, bool unknown) {
parameters.push_back(param);
}
vector<Parameter*> parameters;
};
bool createPath(const std::string &pathname) {
if ( mkdir(pathname.c_str(), 0755) < 0 ) {
if ( errno == ENOENT ) {
size_t slash = pathname.rfind('/');
if ( slash != std::string::npos ) {
std::string prefix = pathname.substr(0, slash);
if ( !createPath(prefix) ) return false;
if ( slash == pathname.size() -1 ) return true;
return mkdir(pathname.c_str(), 0755) == 0;
}
else
return false;
}
else
return false;
}
return true;
}
string blockComment(const string &input, size_t lineWidth) {
// Make space for leading "# "
lineWidth -= 2;
string txt = string("# ") + input;
size_t s = 2;
size_t to = s + lineWidth;
while ( to < txt.length() ) {
// find linebreaks and comment each new line
size_t p = txt.find_first_of('\n', s);
if ( p != string::npos && (p - s) < lineWidth) {
s = p + 1;
txt.insert(p+1, "# ");
s = p + 3;
}
else {
// insert line break if possible at last space else inside word
// without hyphenation
p = txt.find_last_of(' ', to-1);
if ( p == string::npos || p < s || (p -s) > lineWidth) {
txt.insert(to, "\n# ");
s = to + 3;
}
else {
txt[p] = '\n';
txt.insert(p+1, "# ");
s = p+3;
}
}
to = s + lineWidth;
}
// comment line breaks in last line
while ( s < txt.length() ) {
size_t p = txt.find_first_of('\n', s);
if ( p == string::npos ) break;
txt.insert(p+1, "# ");
s = p + 3;
}
return txt;
}
time_t lastModificationTime(const string &fn) {
struct stat fstat;
if ( stat(fn.c_str(), &fstat) < 0 )
return 0;
return fstat.st_mtime;
}
bool loadGroup(Container *c, SchemaGroup *group, const std::string &prefix);
Structure *loadStructure(SchemaStructure *struc, const std::string &prefix,
const std::string &name) {
std::string namePrefix = prefix + name;
Structure *strucParam = new Structure(struc, namePrefix, name);
for ( size_t i = 0; i < struc->parameterCount(); ++i ) {
SchemaParameter *pdef = struc->parameter(i);
std::string paramName = namePrefix;
if ( !pdef->name.empty() )
paramName += "." + pdef->name;
ParameterPtr param = new Parameter(pdef, paramName);
strucParam->add(param.get());
}
for ( size_t i = 0; i < struc->groupCount(); ++i ) {
SchemaGroup *gdef = struc->group(i);
loadGroup(strucParam, gdef, namePrefix + ".");
}
for ( size_t i = 0; i < struc->structureCount(); ++i ) {
SchemaStructure *gdef = struc->structure(i);
strucParam->addType(loadStructure(gdef, namePrefix + ".", ""));
}
return strucParam;
}
Binding *loadCategoryBinding(SchemaBinding *def, const std::string &prefix,
const std::string &name) {
std::string namePrefix = prefix + name;
Binding *binding = new Binding(def->name);
binding->definition = def;
SectionPtr sec = new Section(def->name);
binding->sections.push_back(sec);
if ( def->parameters ) {
for ( size_t i = 0; i < def->parameters->parameterCount(); ++i ) {
SchemaParameter *pdef = def->parameters->parameter(i);
std::string paramName = namePrefix + "." + pdef->name;
ParameterPtr param = new Parameter(pdef, paramName);
sec->add(param.get());
}
for ( size_t i = 0; i < def->parameters->groupCount(); ++i ) {
SchemaGroup *gdef = def->parameters->group(i);
loadGroup(sec.get(), gdef, namePrefix + ".");
}
for ( size_t i = 0; i < def->parameters->structureCount(); ++i ) {
SchemaStructure *gdef = def->parameters->structure(i);
sec->addType(loadStructure(gdef, namePrefix + ".", ""));
}
}
return binding;
}
//void createSections();
bool loadGroup(Container *c, SchemaGroup *group, const std::string &prefix) {
std::string namePrefix = prefix + group->name;
GroupPtr groupParam;
Container *container = NULL;
// try to find the existing group
for ( size_t i = 0; i < c->groups.size(); ++i ) {
if ( c->groups[i]->definition->name == group->name ) {
container = c->groups[i].get();
break;
}
}
if ( !container ) {
groupParam = new Group(group, namePrefix);
container = groupParam.get();
}
for ( size_t i = 0; i < group->parameterCount(); ++i ) {
SchemaParameter *pdef = group->parameter(i);
std::string paramName = namePrefix + "." + pdef->name;
ParameterPtr param = new Parameter(pdef, paramName);
container->add(param.get());
}
for ( size_t i = 0; i < group->groupCount(); ++i ) {
SchemaGroup *gdef = group->group(i);
loadGroup(container, gdef, namePrefix + ".");
}
for ( size_t i = 0; i < group->structureCount(); ++i ) {
SchemaStructure *gdef = group->structure(i);
container->addType(loadStructure(gdef, namePrefix + ".", ""));
}
if ( groupParam ) c->add(groupParam.get());
return true;
}
void updateParameter(Parameter *param, Model::SymbolFileMap &symbols, int stage) {
SymbolMapItemPtr item = symbols[param->variableName];
if ( item == NULL ) {
item = new SymbolMapItem();
//item->symbol.name = param->variableName;
symbols[param->variableName] = item;
}
// Tell the item that it is known and stored
item->known = true;
param->symbols[stage] = item;
}
void updateContainer(Container *c, Model::SymbolFileMap &symbols, int stage) {
for ( size_t i = 0; i < c->parameters.size(); ++i )
updateParameter(c->parameters[i].get(), symbols, stage);
for ( size_t i = 0; i < c->groups.size(); ++i )
updateContainer(c->groups[i].get(), symbols, stage);
for ( size_t i = 0; i < c->structureTypes.size(); ++i ) {
const string &xpath = c->structureTypes[i]->path;
set<string> structs;
Model::SymbolFileMap::iterator it;
for ( it = symbols.begin(); it != symbols.end(); ++it ) {
// Parameter not from file?
if ( it->second->symbol.uri.empty() ) continue;
// Check if the symbol name starts with xpath
if ( it->first.compare(0, xpath.size(), xpath) ) continue;
size_t pos = it->first.find('.', xpath.size());
string name;
if ( pos != string::npos )
name = it->first.substr(xpath.size(), pos-xpath.size());
else
name = it->first.substr(xpath.size());
// No dot means we are looking at a variable and not a struct
//continue;
if ( !name.empty() ) structs.insert(name);
}
// Instantiate available structures
set<string>::iterator sit;
for ( sit = structs.begin(); sit != structs.end(); ++sit )
// This may fail if another stage has added this struct
// already.
c->instantiate(c->structureTypes[i].get(), sit->c_str());
}
for ( size_t i = 0; i < c->structures.size(); ++i )
updateContainer(c->structures[i].get(), symbols, stage);
}
void updateParameter(Parameter *param, int updateMaxStage) {
param->updateFinalValue(updateMaxStage);
}
void updateContainer(Container *c, int updateMaxStage) {
for ( size_t i = 0; i < c->parameters.size(); ++i )
updateParameter(c->parameters[i].get(), updateMaxStage);
for ( size_t i = 0; i < c->groups.size(); ++i )
updateContainer(c->groups[i].get(), updateMaxStage);
for ( size_t i = 0; i < c->structures.size(); ++i )
updateContainer(c->structures[i].get(), updateMaxStage);
}
bool write(const Parameter *param, const Section *sec, int stage,
set<string> &symbols, ofstream &ofs, const std::string &filename,
bool withComment) {
if ( !param->symbols[stage] ) return true;
// Do nothing
if ( param->symbols[stage]->symbol.stage == Environment::CS_UNDEFINED )
return true;
if ( !ofs.is_open() ) {
SEISCOMP_INFO("Updating %s", filename.c_str());
ofs.open(filename.c_str());
// Propagate error
if ( !ofs.is_open() ) return false;
}
// Already saved this symbol?
if ( symbols.find(param->variableName) != symbols.end() ) return true;
// Write description as comment.
if ( withComment ) {
if ( param->definition && !param->definition->description.empty() ) {
if ( !symbols.empty() ) ofs << endl;
ofs << blockComment(param->definition->description, 80) << endl;
}
else if ( !param->symbols[stage]->symbol.comment.empty() ) {
if ( !symbols.empty() ) ofs << endl;
ofs << param->symbols[stage]->symbol.comment << endl;
}
}
ofs << param->variableName << " = ";
if ( param->symbols[stage]->symbol.content.empty() )
ofs << "\"\"";
else
ofs << param->symbols[stage]->symbol.content;
//Config::Config::writeValues(ofs, ¶m->symbols[stage]->symbol);
ofs << endl;
symbols.insert(param->variableName);
return true;
}
bool write(const Container *cont, const Section *sec, int stage,
set<string> &symbols, ofstream &ofs, const std::string &filename,
bool withComment) {
for ( size_t p = 0; p < cont->parameters.size(); ++p ) {
if ( !write(cont->parameters[p].get(), sec, stage,
symbols, ofs, filename, withComment) )
return false;
}
for ( size_t g = 0; g < cont->groups.size(); ++g ) {
if ( !write(cont->groups[g].get(), sec, stage,
symbols, ofs, filename, withComment) )
return false;
}
for ( size_t s = 0; s < cont->structures.size(); ++s ) {
if ( !write(cont->structures[s].get(), sec, stage,
symbols, ofs, filename, withComment) )
return false;
}
return true;
}
bool compareName(const BindingPtr &v1, const BindingPtr &v2) {
return v1->name < v2->name;
}
}
Parameter::Parameter(SchemaParameter *def, const char *n)
: parent(NULL), super(NULL), definition(def), variableName(n) {
symbol.stage = Environment::CS_UNDEFINED;
}
Parameter::Parameter(SchemaParameter *def, const std::string &n)
: parent(NULL), super(NULL), definition(def), variableName(n) {
symbol.stage = Environment::CS_UNDEFINED;
}
Parameter *Parameter::copy(bool backImport) {
Parameter *param = new Parameter(definition, variableName);
param->symbol = symbol;
if ( backImport ) {
param->super = NULL;
super = param;
}
else
param->super = this;
return param;
}
Parameter *Parameter::clone() const {
Parameter *param = new Parameter(definition, variableName);
param->symbol = symbol;
param->super = super;
return param;
}
void Parameter::dump(std::ostream &os) const {
if ( !symbol.uri.empty() )
os << "[" << symbol.uri << "]" << endl;
os << variableName << " = " << symbol.content;
/*
Symbol::Values::const_iterator it = symbol.values.begin();
for ( ; it != symbol.values.end(); ++it ) {
if ( it != symbol.values.begin() )
os << ", ";
os << *it;
}
*/
os << endl;
}
bool Parameter::inherits(const Parameter *param) const {
const Parameter *p = super;
while ( p ) {
if ( p == param ) return true;
p = p->super;
}
return false;
}
void Parameter::updateFinalValue(int maxStage) {
symbol = Symbol();
symbol.values.push_back(definition->defaultValue);
symbol.content = definition->defaultValue;
if ( maxStage >= Environment::CS_QUANTITY )
maxStage = Environment::CS_LAST;
for ( int i = 0; i <= maxStage; ++i ) {
SymbolMapItem *item = symbols[i].get();
if ( !item || item->symbol.stage == Environment::CS_UNDEFINED )
continue;
symbol = item->symbol;
}
}
void Container::add(Parameter *param) {
param->parent = this;
parameters.push_back(param);
}
void Container::add(Structure *struc) {
struc->parent = this;
structures.push_back(struc);
}
void Container::add(Group *group) {
group->parent = this;
groups.push_back(group);
}
void Container::addType(Structure *struc) {
struc->parent = this;
structureTypes.push_back(struc);
}
Structure *Container::findStructureType(const std::string &type) const {
for ( size_t i = 0; i < structureTypes.size(); ++i )
if ( structureTypes[i]->definition->type == type )
return structureTypes[i].get();
return NULL;
}
bool Container::hasStructure(const char *name) const {
for ( size_t i = 0; i < structures.size(); ++i )
if ( structures[i]->name == name ) return true;
return false;
}
bool Container::hasStructure(const string &name) const {
for ( size_t i = 0; i < structures.size(); ++i )
if ( structures[i]->name == name ) return true;
return false;
}
Structure *Container::instantiate(const Structure *s, const char *name) {
if ( hasStructure(name) ) return NULL;
Structure *ns = s->instantiate(name);
if ( ns != NULL ) structures.push_back(ns);
return ns;
}
bool Container::remove(Structure *s) {
vector<StructurePtr>::iterator it;
it = find(structures.begin(), structures.end(), s);
if ( it == structures.end() ) return false;
structures.erase(it);
return true;
}
Parameter *Container::findParameter(const std::string &fullName) const {
for ( size_t i = 0; i < parameters.size(); ++i ) {
if ( parameters[i]->variableName == fullName )
return parameters[i].get();
}
for ( size_t i = 0; i < groups.size(); ++i ) {
Parameter *param = groups[i]->findParameter(fullName);
if ( param != NULL ) return param;
}
for ( size_t i = 0; i < structures.size(); ++i ) {
Parameter *param = structures[i]->findParameter(fullName);
if ( param != NULL ) return param;
}
return NULL;
}
Container *Container::findContainer(const std::string &path) const {
for ( size_t i = 0; i < groups.size(); ++i ) {
if ( groups[i]->path == path ) return groups[i].get();
Container *c = groups[i]->findContainer(path);
if ( c != NULL ) return c;
}
for ( size_t i = 0; i < structures.size(); ++i ) {
if ( structures[i]->path == path ) return structures[i].get();
Container *c = structures[i]->findContainer(path);
if ( c != NULL ) return c;
}
return NULL;
}
void Container::accept(ModelVisitor *visitor) const {
for ( size_t i = 0; i < parameters.size(); ++i )
visitor->visit(parameters[i].get(), false);
for ( size_t i = 0; i < groups.size(); ++i ) {
if ( !visitor->visit(groups[i].get()) ) continue;
groups[i]->accept(visitor);
}
for ( size_t i = 0; i < structures.size(); ++i ) {
if ( !visitor->visit(structures[i].get()) ) continue;
structures[i]->accept(visitor);
}
}
Structure *Structure::copy(bool backImport) {
Structure *struc = new Structure(definition, path, name);
if ( backImport ) {
struc->super = NULL;
super = struc;
}
else
struc->super = this;
for ( size_t i = 0; i < parameters.size(); ++i )
struc->add(parameters[i]->copy(backImport));
for ( size_t i = 0; i < groups.size(); ++i )
struc->add(groups[i]->copy(backImport));
for ( size_t i = 0; i < structureTypes.size(); ++i )
struc->addType(structureTypes[i]->clone());
return struc;
}
Structure *Structure::clone() const {
Structure *struc = new Structure(definition, path, name);
for ( size_t i = 0; i < parameters.size(); ++i )
struc->add(parameters[i]->clone());
for ( size_t i = 0; i < groups.size(); ++i )
struc->add(groups[i]->clone());
for ( size_t i = 0; i < structures.size(); ++i )
struc->add(structures[i]->clone());
for ( size_t i = 0; i < structureTypes.size(); ++i )
struc->addType(structureTypes[i]->clone());
return struc;
}
Structure *Structure::instantiate(const char *n) const {
if ( !name.empty() ) return NULL;
Structure *struc = loadStructure(definition, path, n);
updateContainer(struc, Environment::CS_QUANTITY);
Model::SymbolFileMap symbols;
updateContainer(struc, symbols, Environment::CS_CONFIG_APP);
return struc;
}
void Structure::dump(std::ostream &os) const {
for ( size_t i = 0; i < parameters.size(); ++i )
parameters[i]->dump(os);
}
Group *Group::copy(bool backImport) {
Group *group = new Group(definition, path);
if ( backImport ) {
group->super = NULL;
super = group;
}
else
group->super = this;
for ( size_t i = 0; i < parameters.size(); ++i )
group->add(parameters[i]->copy(backImport));
for ( size_t i = 0; i < groups.size(); ++i )
group->add(groups[i]->copy(backImport));
for ( size_t i = 0; i < structureTypes.size(); ++i )
group->addType(structureTypes[i]->clone());
return group;
}
Group *Group::clone() const {
Group *group = new Group(definition, path);
for ( size_t i = 0; i < parameters.size(); ++i )
group->add(parameters[i]->clone());
for ( size_t i = 0; i < groups.size(); ++i )
group->add(groups[i]->clone());
for ( size_t i = 0; i < structureTypes.size(); ++i )
group->addType(structureTypes[i]->clone());
return group;
}
void Group::dump(std::ostream &os) const {
for ( size_t i = 0; i < parameters.size(); ++i )
parameters[i]->dump(os);
}
Section *Section::copy(bool backImport) {
Section *sec = new Section(name);
sec->description = description;
for ( size_t i = 0; i < parameters.size(); ++i )
sec->add(parameters[i]->copy(backImport));
for ( size_t i = 0; i < groups.size(); ++i )
sec->add(groups[i]->copy(backImport));
for ( size_t i = 0; i < structureTypes.size(); ++i )
sec->addType(structureTypes[i]->clone());
return sec;
}
Section *Section::clone() const {
Section *section = new Section(name);
section->description = description;
for ( size_t i = 0; i < parameters.size(); ++i )
section->add(parameters[i]->clone());
for ( size_t i = 0; i < groups.size(); ++i )
section->add(groups[i]->clone());
for ( size_t i = 0; i < structureTypes.size(); ++i )
section->addType(structureTypes[i]->clone());
return section;
}
void Section::dump(std::ostream &os) const {
for ( size_t i = 0; i < parameters.size(); ++i )
parameters[i]->dump(os);
for ( size_t i = 0; i < groups.size(); ++i )
groups[i]->dump(os);
}
Binding *Binding::clone() const {
Binding *b = new Binding(*this);
for ( size_t s = 0; s < b->sections.size(); ++s ) {
b->sections[s] = b->sections[s]->clone();
b->sections[s]->parent = b;
}
return b;
}
void Binding::dump(std::ostream &os) const {
for ( size_t i = 0; i < sections.size(); ++i )
sections[i]->dump(os);
}
Container *Binding::findContainer(const std::string &path) const {
for ( size_t i = 0; i < sections.size(); ++i ) {
Container *c = sections[i]->findContainer(path);
if ( c != NULL ) return c;
}
return NULL;
}
Parameter *Binding::findParameter(const std::string &fullName) const {
for ( size_t i = 0; i < sections.size(); ++i ) {
Parameter *param = sections[i]->findParameter(fullName);
if ( param != NULL ) return param;
}
return NULL;
}
void Binding::accept(ModelVisitor *visitor) const {
for ( size_t i = 0; i < sections.size(); ++i ) {
if ( !visitor->visit(sections[i].get()) ) continue;
sections[i]->accept(visitor);
}
}
Binding *BindingCategory::binding(const std::string &name) const {
for ( size_t i = 0; i < bindingTypes.size(); ++i )
if ( bindingTypes[i]->name == name )
return bindingTypes[i].get();
return NULL;
}
BindingCategory *BindingCategory::clone() const {
BindingCategory *cat = new BindingCategory(*this);
cat->parent = NULL;
for ( size_t i = 0; i < cat->bindingTypes.size(); ++i ) {
cat->bindingTypes[i] = cat->bindingTypes[i]->clone();
cat->bindingTypes[i]->parent = (BindingCategory*)this;
}
for ( size_t i = 0; i < cat->bindings.size(); ++i ) {
cat->bindings[i].binding = cat->bindings[i].binding->clone();
cat->bindings[i].binding->parent = (BindingCategory*)this;
}
return cat;
}
void BindingCategory::dump(std::ostream &os) const {
for ( size_t i = 0; i < bindings.size(); ++i )
bindings[i].binding->dump(os);
}
Container *BindingCategory::findContainer(const std::string &path) const {
BindingInstances::const_iterator it;
for ( it = bindings.begin(); it != bindings.end(); ++it ) {
Container *c = it->binding->findContainer(path);
if ( c != NULL ) return c;
}
return NULL;
}
Parameter *BindingCategory::findParameter(const std::string &fullName) const {
BindingInstances::const_iterator it;
for ( it = bindings.begin(); it != bindings.end(); ++it ) {
Parameter *p = it->binding->findParameter(fullName);
if ( p != NULL ) return p;
}
return NULL;
}
void BindingCategory::accept(ModelVisitor *visitor) const {
BindingInstances::const_iterator it;
for ( it = bindings.begin(); it != bindings.end(); ++it )
it->binding->accept(visitor);
}
bool BindingCategory::hasBinding(const char *alias) const {
for ( size_t i = 0; i < bindings.size(); ++i )
if ( bindings[i].alias == alias ) return true;
return false;
}
Binding *BindingCategory::instantiate(const Binding *b, const char *alias) {
string tmp = alias;
if ( tmp.empty() ) tmp = b->name;
if ( hasBinding(tmp.c_str()) ) return NULL;
Binding *nb = loadCategoryBinding(b->definition, name + ".", tmp);
for ( size_t i = 0; i < nb->sections.size(); ++i )
updateContainer(nb->sections[i].get(), Environment::CS_QUANTITY);
Model::SymbolFileMap symbols;
for ( size_t i = 0; i < nb->sections.size(); ++i )
updateContainer(nb->sections[i].get(), symbols, Environment::CS_CONFIG_APP);
nb->parent = this;
bindings.push_back(BindingInstance(nb, tmp));
return nb;
}
const char *BindingCategory::alias(const Binding *b) const {
for ( size_t i = 0; i < bindings.size(); ++i )
if ( bindings[i].binding.get() == b ) return bindings[i].alias.c_str();
return NULL;
}
bool BindingCategory::removeInstance(const Binding *b) {
BindingInstances::iterator it = bindings.begin();
for ( ; it != bindings.end(); ++it ) {
if ( it->binding.get() == b ) {
bindings.erase(it);
return true;
}
}
return false;
}
bool BindingCategory::removeInstance(const char *alias) {
BindingInstances::iterator it = bindings.begin();
for ( ; it != bindings.end(); ++it ) {
if ( it->alias == alias ) {
bindings.erase(it);
return true;
}
}
return false;
}
ModuleBinding *ModuleBinding::clone() const {
ModuleBinding *b = new ModuleBinding(*this);
b->parent = NULL;
b->configFile = "";
for ( size_t s = 0; s < b->sections.size(); ++s ) {
b->sections[s] = b->sections[s]->clone();
b->sections[s]->parent = (ModuleBinding*)this;
}
for ( size_t i = 0; i < b->categories.size(); ++i ) {
b->categories[i] = b->categories[i]->clone();
b->categories[i]->parent = b;
}
return b;
}
void ModuleBinding::add(BindingCategory *cat) {
cat->parent = this;
categories.push_back(cat);
}
BindingCategory *ModuleBinding::category(const std::string &name) const {
for ( size_t i = 0; i < categories.size(); ++i )
if ( categories[i]->name == name )
return categories[i].get();
return NULL;
}
void ModuleBinding::dump(std::ostream &os) const {
Binding::dump(os);
for ( size_t i = 0; i < categories.size(); ++i )
categories[i]->dump(os);
}
//! Returns a container at path @path@.
Container *ModuleBinding::findContainer(const std::string &path) const {
Container *c = Binding::findContainer(path);
if ( c != NULL ) return c;
Categories::const_iterator it;
for ( it = categories.begin(); it != categories.end(); ++it ) {
c = (*it)->findContainer(path);
if ( c != NULL ) return c;
}
return NULL;
}
Parameter *ModuleBinding::findParameter(const std::string &fullName) const {
Parameter *p = Binding::findParameter(fullName);
if ( p != NULL ) return p;
Categories::const_iterator it;
for ( it = categories.begin(); it != categories.end(); ++it ) {
p = (*it)->findParameter(fullName);
if ( p != NULL ) return p;
}
return NULL;
}
void ModuleBinding::accept(ModelVisitor *visitor) const {
Binding::accept(visitor);
Categories::const_iterator it;
for ( it = categories.begin(); it != categories.end(); ++it )
(*it)->accept(visitor);
}
bool ModuleBinding::writeConfig(const string &filename, ConfigDelegate *delegate) const {
ofstream ofs(filename.c_str());
if ( !ofs.is_open() ) return false;
set<string> symbols;
int stage = Environment::CS_CONFIG_APP;
for ( size_t s = 0; s < sections.size(); ++s ) {
Section *section = sections[s].get();
if ( !write(section, NULL, stage, symbols, ofs, filename, true) )
return false;
}
for ( size_t i = 0; i < categories.size(); ++i ) {
BindingCategory *cat = categories[i].get();
if ( cat->bindings.empty() ) continue;
if ( !symbols.empty() ) ofs << endl;
ofs << "# Activated plugins for category " << cat->name << endl;
ofs << cat->name << " = ";
symbols.insert(cat->name);
for ( size_t b = 0; b < cat->bindings.size(); ++b ) {
if ( b > 0 ) ofs << ", ";
if ( cat->bindings[b].binding->name == cat->bindings[b].alias )
ofs << cat->bindings[b].binding->name;
else
ofs << cat->bindings[b].alias << ":" << cat->bindings[b].binding->name;
}
ofs << endl;
for ( size_t b = 0; b < cat->bindings.size(); ++b ) {
Binding *curr = cat->bindings[b].binding.get();
for ( size_t s = 0; s < curr->sections.size(); ++s ) {
Section *sec = curr->sections[s].get();
if ( !write(sec, NULL, stage, symbols, ofs, filename, true) )
return false;
}
}
}
return true;
}
void Module::add(Section *sec) {
sec->parent = this;
sections.push_back(sec);
}
Parameter *Module::findParameter(const std::string &fullName) const {
for ( size_t i = 0; i < unknowns.size(); ++i ) {
if ( unknowns[i]->variableName == fullName ) return unknowns[i].get();
}
for ( size_t i = 0; i < sections.size(); ++i ) {
Parameter *param = sections[i]->findParameter(fullName);
if ( param != NULL ) return param;
}
return NULL;
}
Container *Module::findContainer(const std::string &path) const {
for ( size_t i = 0; i < sections.size(); ++i ) {
Container *c = sections[i]->findContainer(path);
if ( c != NULL ) return c;
}
return NULL;
}
bool Module::hasConfiguration() const {
if ( definition == NULL || !definition->parameters ) return false;
return definition->parameters->parameterCount() > 0 ||
definition->parameters->groupCount() > 0 ||
definition->parameters->structureCount() > 0 ||
!definition->isStandalone();
}
int Module::loadProfiles(const std::string &keyDir, ConfigDelegate *delegate) {
if ( !supportsBindings() ) return -1;
fs::directory_iterator it;
fs::directory_iterator fsDirEnd;
try {
it = fs::directory_iterator(SC_FS_PATH(keyDir));
}
catch ( ... ) {
it = fsDirEnd;
SEISCOMP_DEBUG("%s not available", keyDir.c_str());
return 0;
}
for ( ; it != fsDirEnd; ++it ) {
if ( fs::is_directory(*it) ) continue;
string filename = SC_FS_IT_LEAF(it);
if ( filename.compare(0, 8, "profile_") != 0 )
continue;
ModuleBindingPtr profile = createBinding();
if ( profile == NULL ) {
cerr << "ERROR: internal error: unable to create binding" << endl;
break;
}
profile->name = filename.substr(8);
profile->configFile = SC_FS_IT_STR(it);
if ( !loadBinding(*profile, profile->configFile, false, delegate) ) {
cerr << "ERROR: invalid config file" << endl;
continue;
}
addProfile(profile.get());
}
return (int)profiles.size();
}
bool Module::addProfile(ModuleBinding *b) {
if ( b->name.empty() ) return false;
// Does a profile with this name exist already?
if ( getProfile(b->name) != NULL )
return false;
b->parent = this;
profiles.push_back(b);
return true;
}
bool Module::removeProfile(const std::string &profile) {
ModuleBinding *b = NULL;
for ( size_t i = 0; i < profiles.size(); ++i ) {
if ( profiles[i]->name == profile ) {
b = profiles[i].get();
profiles.erase(profiles.begin()+i);
break;
}
}
if ( b == NULL ) return false;
syncProfileRemoval(b);
return true;
}
bool Module::removeProfile(ModuleBinding *profile) {
ModuleBinding *b = NULL;
for ( size_t i = 0; i < profiles.size(); ++i ) {
if ( profiles[i] == profile ) {
b = profiles[i].get();
profiles.erase(profiles.begin()+i);
break;
}
}
if ( b == NULL ) return false;
syncProfileRemoval(b);
return true;
}
void Module::syncProfileRemoval(Binding *b) {
// Remove all station bindings that use this binding.
BindingMap::iterator it;
for ( it = bindings.begin(); it != bindings.end(); ) {
if ( it->second.get() == b )
bindings.erase(it++);
else
++it;
}
}
ModuleBinding *Module::bind(const StationID &id, const std::string &profile) {
ModuleBinding *b;
if ( profile.empty() )
return readBinding(id, profile, true);
else
b = getProfile(profile);
if ( b == NULL ) return NULL;
if ( !bind(id, b) ) return NULL;
return b;
}
bool Module::bind(const StationID &id, ModuleBinding *binding) {
if ( binding->parent && binding->parent != this ) return false;
binding->parent = this;
bindings[id] = binding;
return true;
}
bool Module::removeStation(const StationID &id) {
BindingMap::iterator it = bindings.find(id);
if ( it == bindings.end() ) return false;
bindings.erase(it);
return true;
}
ModuleBinding *Module::createBinding() const {
if ( !bindingTemplate ) return NULL;
return bindingTemplate->clone();
}
ModuleBinding *Module::createProfile(const std::string &name) {
if ( getProfile(name) != NULL ) return NULL;
ModuleBindingPtr prof = createBinding();
prof->name = name;
prof->configFile = keyDirectory + "/profile_" + prof->name;
if ( !loadBinding(*prof, prof->configFile, true) ) return NULL;
if ( !addProfile(prof.get()) ) return NULL;
return prof.get();
}
ModuleBinding *Module::getProfile(const std::string &name) const {
for ( size_t i = 0; i < profiles.size(); ++i )
if ( profiles[i]->name == name )
return profiles[i].get();
return NULL;
}
ModuleBinding *Module::getBinding(const StationID &id) const {
BindingMap::const_iterator it = bindings.find(id);
if ( it == bindings.end() ) return NULL;
return it->second.get();
}
bool Module::loadBinding(ModuleBinding &binding,
const std::string &filename,
bool allowConfigFileErrors,
ConfigDelegate *delegate) const {
Model::SymbolFileMap tmp;
Model::SymbolFileMap *usedSymbols;
if ( !filename.empty() )
usedSymbols = &model->symbols[filename];
else
usedSymbols = &tmp;
Model::SymbolFileMap &symbols = *usedSymbols;
if ( !filename.empty() ) {
Config::Config *cfg = new Config::Config;
if ( Util::fileExists(filename) ) {
if ( delegate ) delegate->aboutToRead(filename.c_str());
while ( true ) {
if ( delegate ) cfg->setLogger(delegate);
if ( cfg->readConfig(filename, Environment::CS_CONFIG_APP) ) {
if ( delegate ) delegate->finishedReading(filename.c_str());
break;
}
if ( delegate == NULL || !delegate->handleReadError(filename.c_str()) ) {
if ( !allowConfigFileErrors ) {
cerr << "ERROR: read " << filename << " failed" << endl;
delete cfg;
return false;
}
break;
}
delete cfg;
cfg = new Config::Config;
}
}
SymbolTable *symtab = cfg->symbolTable();
if ( symtab == NULL ) {
delete cfg;
cerr << "ERROR: internal error: symbol table not available" << endl;
return false;
}
for ( SymbolTable::iterator it = symtab->begin(); it != symtab->end(); ++it )
symbols[(*it)->name] = new SymbolMapItem(**it);
delete cfg;
}
else if ( !allowConfigFileErrors ) {
cerr << "ERROR: file required" << endl;
return false;
}
for ( size_t s = 0; s < binding.sections.size(); ++s ) {
updateContainer(binding.sections[s].get(), symbols, Environment::CS_CONFIG_APP);
updateContainer(binding.sections[s].get(), Environment::CS_QUANTITY);
}
for ( size_t c = 0; c < binding.categories.size(); ++c ) {
BindingCategory *cat = binding.categories[c].get();
cat->bindings.clear();
SymbolMapItemPtr item = symbols[cat->name];
if ( !item ) continue;
const Symbol::Values &catValues = item->symbol.values;
for ( size_t i = 0; i < catValues.size(); ++i ) {
size_t pos = catValues[i].find(':');
string alias, type;
if ( pos != string::npos ) {
alias = catValues[i].substr(0,pos);
type = catValues[i].substr(pos+1);
}
else {
type = catValues[i];
alias = type;
}
Binding *b = cat->binding(type);
if ( b == NULL ) {
cerr << "WARNING: binding " << cat->name << "/" << type
<< " does not exist: ignored" << endl;
continue;
}
if ( !cat->instantiate(b, alias.c_str()) ) {
cerr << "WARNING: binding " << cat->name << "/" << type
<< " could not be added with alias '" << alias
<< "': ignored" << endl;
continue;
}
}
for ( size_t b = 0; b < cat->bindings.size(); ++b ) {
Binding *binding = cat->bindings[b].binding.get();
for ( size_t s = 0; s < binding->sections.size(); ++s ) {
updateContainer(binding->sections[s].get(), symbols, Environment::CS_CONFIG_APP);
updateContainer(binding->sections[s].get(), Environment::CS_QUANTITY);
}
}
}
/*
// Find active bindings for categories
for ( size_t i = 0; i < binding.categories.size(); ++i ) {
BindingCategory *cat = binding.categories[i].get();
SymbolMapItemPtr item = symbols[cat->name];
if ( !item )
cat->activeBinding = NULL;
else
cat->activeBinding = cat->binding(item->symbol.content);
}
*/
return true;
}
ModuleBinding *Module::readBinding(const StationID &id,
const std::string &profile,
bool allowConfigFileErrors,
ConfigDelegate *delegate) {
if ( !profile.empty() ) {
ModuleBinding *b = bind(id, profile);
if ( b ) return b;
}
ModuleBindingPtr binding = createBinding();
if ( binding == NULL ) return NULL;
binding->name = profile;
binding->configFile = keyDirectory + "/";
// Station key file
if ( profile.empty() ) {
binding->configFile += "station_";
binding->configFile += id.networkCode + "_" + id.stationCode;
}
// Profile key file
else {
binding->configFile += "profile_";
binding->configFile += profile;
}
if ( !loadBinding(*binding, binding->configFile, allowConfigFileErrors, delegate) )
return NULL;
if ( !profile.empty() && !addProfile(binding.get()) ) {
cerr << "ERROR: adding profile '" << profile << "' to " << definition->name
<< " failed" << endl;
return NULL;
}
//binding->dump(cout);
if ( !bind(id, binding.get()) )
return NULL;
return binding.get();
}
void Module::accept(ModelVisitor *visitor) const {
for ( size_t i = 0; i < unknowns.size(); ++i )
visitor->visit(unknowns[i].get(), true);
for ( size_t i = 0; i < sections.size(); ++i ) {
if ( !visitor->visit(sections[i].get()) ) continue;
sections[i]->accept(visitor);
}
}
bool Station::readConfig(const char *filename) {
config.clear();
ifstream ifs(filename);
if ( !ifs.is_open() ) return false;
set<string> mods;
string line;
while ( getline(ifs, line) ) {
Core::trim(line);
// Skip empty lines
if ( line.empty() ) continue;
// Skip comments
if ( line[0] == '#' ) continue;
size_t pos_colon = line.find(':');
size_t pos_assign = line.find('=');
string mod, profile;
string name, value;
if ( pos_colon != string::npos ) {
mod = line.substr(0, pos_colon);
profile = line.substr(pos_colon+1);
Core::trim(mod);
Core::trim(profile);
}
else if ( pos_assign != string::npos ) {
name = line.substr(0, pos_assign);
value = line.substr(pos_assign+1);
Core::trim(name);
Core::trim(value);
}
else
mod = line;
if ( !mod.empty() ) {
if ( mods.find(mod) != mods.end() ) {
cerr << filename << ": duplicate module entry for '" << mod << "': ignoring" << endl;
continue;
}
mods.insert(mod);
config.push_back(ModuleConfig(mod, profile));
}
else if ( !name.empty() ) {
if ( tags.find(name) != tags.end() ) {
cerr << filename << ": duplicate tag entry for '" << name << "': ignoring" << endl;
continue;
}
tags[name] = value;
}
}
return true;
}
bool Station::writeConfig(const char *filename, ConfigDelegate *delegate) const {
ofstream ofs(filename, ios::out);
if ( !ofs.is_open() ) return false;
if ( !tags.empty() ) {
ofs << "# Station tags" << endl;
Tags::const_iterator it;
for ( it = tags.begin(); it != tags.end(); ++it )
ofs << it->first << " = " << it->second << endl;
}
if ( !config.empty() ) {
ofs << "# Binding references" << endl;
ModuleConfigs::const_iterator it;
for ( it = config.begin(); it != config.end(); ++it ) {
ofs << it->moduleName;
if ( !it->profile.empty() )
ofs << ":" << it->profile;
ofs << endl;
}
}
return true;
}
void Station::setConfig(const std::string &module, const std::string &profile) {
ModuleConfigs::iterator it;
for ( it = config.begin(); it != config.end(); ++it ) {
if ( it->moduleName == module ) {
it->profile = profile;
return;
}
}
config.push_back(ModuleConfig(module, profile));
}
bool Station::compareTag(const std::string &name, const std::string &value) const {
Tags::const_iterator it = tags.find(name);
if ( it == tags.end() ) return false;
return it->second == value;
}
Module *Model::module(const std::string &name) const {
ModMap::const_iterator it = modMap.find(name);
if ( it == modMap.end() ) return NULL;
return it->second;
}
std::string Model::systemConfigFilename(bool, const std::string &name) const {
return Environment::Instance()->appConfigFileName(name);
}
std::string Model::configFileLocation(bool, const std::string &name, int stage) const {
return Environment::Instance()->configFileLocation(name, stage);
}
std::string Model::stationConfigDir(bool, const std::string &name) const {
string keyBaseDir;
if ( !keyDirOverride.empty() ) {
keyBaseDir = keyDirOverride;
// Remove trailing slashes
while ( !keyBaseDir.empty() && (*keyBaseDir.rbegin() == '/') )
keyBaseDir.resize(keyBaseDir.size()-1);
}
else {
const char* keyDir = getenv("SEISCOMP_KEY_DIR");
if ( keyDir != NULL ) {
keyBaseDir = keyDir;
// Remove trailing slashes
while ( !keyBaseDir.empty() && (*keyBaseDir.rbegin() == '/') )
keyBaseDir.resize(keyBaseDir.size()-1);
}
else
keyBaseDir = Environment::Instance()->appConfigDir() + "/key";
}
if ( name.empty() )
return keyBaseDir;
else
return keyBaseDir+ "/" + name;
}
Model::Model() : schema(NULL) {}
bool Model::create(SchemaDefinitions *schema) {
modules.clear();
modMap.clear();
symbols.clear();
this->schema = schema;
// Build module definitions
for ( size_t i = 0; i < schema->moduleCount(); ++i ) {
SchemaModule *def = schema->module(i);
create(schema, def);
}
// Build back imports
for ( size_t i = 0; i < schema->moduleCount(); ++i ) {
SchemaModule *def = schema->module(i);
// We do not backimport aliases
if ( def->aliasedModule != NULL ) continue;
ModMap::iterator mit = modMap.find(def->name);
if ( mit == modMap.end() ) continue;
Module *mod = mit->second;
set<string> imports;
// Default is: standalone = false
// Then "global" is automatically imported
if ( def->name != "global" && (!def->standalone || *def->standalone == false) )
imports.insert("global");
if ( !def->import.empty() && def->import != def->name )
imports.insert(def->import);
Section *modSec = mod->sections.back().get();
set<string>::iterator it;
for ( it = imports.begin(); it != imports.end(); ++it ) {
mit = modMap.find(*it);
if ( mit == modMap.end() ) continue;
Module *baseMod = mit->second;
Section *secCopy = modSec->copy(true);
secCopy->description = string("Backimport which allows to configure ") + mod->definition->name +
" (including its aliases) parameters in " + baseMod->definition->name + ".";
baseMod->add(secCopy);
}
}
/*
DuplicateNameCheck check;
accept(&check);
*/
return true;
}
Module *Model::create(SchemaDefinitions *schema, SchemaModule *def) {
if ( def == NULL ) return NULL;
// Loaded already?
ModMap::iterator mit = modMap.find(def->name);
if ( mit != modMap.end() ) return mit->second;
set<string> imports;
// Default is: standalone = false
// Then "global" is automatically imported
if ( def->name != "global" && (!def->standalone || *def->standalone == false) )
imports.insert("global");
if ( !def->import.empty() && def->import != def->name )
imports.insert(def->import);
ModulePtr mod = new Module(def);
if ( !def->category.empty() )
categories.insert(def->category);
set<string>::iterator it;
for ( it = imports.begin(); it != imports.end(); ++it ) {
SchemaModule *baseDef = schema->module(*it);
if ( baseDef == NULL ) {
// TODO: set error message
return NULL;
}
Module *base = create(schema, baseDef);
if ( base == NULL ) {
// TODO: set error message
return NULL;
}
for ( size_t i = 0; i < base->sections.size(); ++i ) {
Section *secCopy = base->sections[i]->copy();
secCopy->description = string("Import of ") + base->definition->name + " parameters "
"which can be overwritten in this configuration.";
mod->add(secCopy);
}
}
SectionPtr sec = new Section(def->name);
//sec->description = def->description;
if ( def->parameters ) {
for ( size_t j = 0; j < def->parameters->parameterCount(); ++j ) {
SchemaParameter *pdef = def->parameters->parameter(j);
ParameterPtr param = new Parameter(pdef, pdef->name);
sec->add(param.get());
}
for ( size_t j = 0; j < def->parameters->groupCount(); ++j )
loadGroup(sec.get(), def->parameters->group(j), "");
for ( size_t j = 0; j < def->parameters->structureCount(); ++j )
sec->addType(loadStructure(def->parameters->structure(j), "", ""));
}
// Load plugin definitions
vector<SchemaPlugin*> plugins = schema->pluginsForModule(def->name);
for ( size_t p = 0; p < plugins.size(); ++p ) {
SchemaPlugin *plugin = plugins[p];
if ( plugin->parameters ) {
for ( size_t j = 0; j < plugin->parameters->parameterCount(); ++j ) {
SchemaParameter *pdef = plugin->parameters->parameter(j);
ParameterPtr param = new Parameter(pdef, pdef->name);
sec->add(param.get());
}
for ( size_t j = 0; j < plugin->parameters->groupCount(); ++j )
loadGroup(sec.get(), plugin->parameters->group(j), "");
for ( size_t j = 0; j < plugin->parameters->structureCount(); ++j )
sec->addType(loadStructure(plugin->parameters->structure(j), "", ""));
}
}
mod->add(sec.get());
// Create bindings model
vector<SchemaBinding*> schemaBindings = schema->bindingsForModule(def->name);
vector<SchemaBinding*> globalBindings;
if ( !schemaBindings.empty() && imports.find("global") != imports.end() &&
def->inheritGlobalBinding && *def->inheritGlobalBinding == true )
globalBindings = schema->bindingsForModule("global");
// Import global
if ( !globalBindings.empty() ) {
Section *sec = new Section("global");
sec->description = "The global section allows to override parameters of "
"the global binding. The values do not reflect the "
"currently assigned global binding values but the "
"values given in this binding.";
if ( mod->bindingTemplate == NULL ) {
mod->bindingTemplate = new ModuleBinding(def->name);
mod->bindingTemplate->parent = mod.get();
}
mod->bindingTemplate->sections.push_back(sec);
for ( size_t i = 0; i < globalBindings.size(); ++i ) {
SchemaBinding *sb = globalBindings[i];
// Category bindings are not supported for import
if ( !sb->category.empty() ) continue;
if ( sb->parameters ) {
for ( size_t j = 0; j < sb->parameters->parameterCount(); ++j ) {
SchemaParameter *pdef = sb->parameters->parameter(j);
ParameterPtr param = new Parameter(pdef, pdef->name);
sec->add(param.get());
}
for ( size_t j = 0; j < sb->parameters->groupCount(); ++j )
loadGroup(sec, sb->parameters->group(j), "");
for ( size_t j = 0; j < sb->parameters->structureCount(); ++j )
sec->addType(loadStructure(sb->parameters->structure(j), "", ""));
}
}
}
Section *bindingSection = NULL;
for ( size_t i = 0; i < schemaBindings.size(); ++i ) {
SchemaBinding *sb = schemaBindings[i];
if ( mod->bindingTemplate == NULL ) {
mod->bindingTemplate = new ModuleBinding(def->name);
mod->bindingTemplate->parent = mod.get();
}
if ( bindingSection == NULL ) {
bindingSection = new Section(def->name);
mod->bindingTemplate->sections.push_back(bindingSection);
}
Section *sec = NULL;
string prefix;
if ( sb->category.empty() ) {
sec = bindingSection;
// TODO: use definition vector to store multiple
// definitions (eg when using plugins)
mod->bindingTemplate->definition = sb;
}
else if ( !sb->name.empty() ) {
BindingCategoryPtr cat = mod->bindingTemplate->category(sb->category);
if ( cat == NULL ) {
cat = new BindingCategory(sb->category.c_str());
mod->bindingTemplate->add(cat.get());
}
BindingPtr b = cat->binding(sb->name);
if ( b != NULL ) {
cerr << "ERROR: " << def->name << "/" << sb->category << ": "
"duplicate name '" << sb->name << "'" << endl;
continue;
}
b = new Binding(sb->name);
b->definition = sb;
b->parent = cat.get();
b->description = b->definition->description;
b->sections.push_back(new Section(sb->name));
cat->bindingTypes.push_back(b);
sec = b->sections.back().get();
// Prefix configuration parameters with cat.name.
prefix = sb->category + "." + sb->name + ".";
}
else {
cerr << "ERROR: " << def->name << "/" << sb->category << " binding: "
"no name but a category: ignoring" << endl;
continue;
}
if ( sb->parameters ) {
for ( size_t j = 0; j < sb->parameters->parameterCount(); ++j ) {
SchemaParameter *pdef = sb->parameters->parameter(j);
ParameterPtr param = new Parameter(pdef, prefix + pdef->name);
sec->add(param.get());
}
for ( size_t j = 0; j < sb->parameters->groupCount(); ++j )
loadGroup(sec, sb->parameters->group(j), prefix);
for ( size_t j = 0; j < sb->parameters->structureCount(); ++j )
sec->addType(loadStructure(sb->parameters->structure(j), prefix, ""));
}
}
if ( mod->bindingTemplate ) {
for ( size_t i = 0; i < mod->bindingTemplate->categories.size(); ++i ) {
BindingCategory *cat = mod->bindingTemplate->categories[i].get();
sort(cat->bindingTypes.begin(), cat->bindingTypes.end(), compareName);
}
}
mod->model = this;
modules.push_back(mod);
modMap[def->name] = mod.get();
return mod.get();
}
bool Model::readConfig(int updateMaxStage, ConfigDelegate *delegate) {
fs::directory_iterator it;
fs::directory_iterator fsDirEnd;
string keyDir;
// Clear configuration of stations
stations.clear();
symbols.clear();
// Collect all symbols at each stage and build global map
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
// Clear bindings and profiles
mod->bindings.clear();
mod->profiles.clear();
// Initialize key directory
mod->keyDirectory = stationConfigDir(true, mod->definition->name);
// Initialize config file name
mod->configFile = systemConfigFilename(true, mod->definition->name);
for ( int stage = Environment::CS_FIRST; stage <= Environment::CS_LAST; ++stage ) {
string uri = configFileLocation(true, mod->definition->name, stage);
// File already read
if ( symbols.find(uri) != symbols.end() ) continue;
SEISCOMP_DEBUG("reading config %s", uri.c_str());
if ( delegate ) delegate->aboutToRead(uri.c_str());
Config::Config *cfg;
time_t lastModified = 0;
while ( true ) {
cfg = new Config::Config();
if ( delegate ) cfg->setLogger(delegate);
lastModified = lastModificationTime(uri);
if ( cfg->readConfig(uri, stage, true) ) {
if ( delegate ) delegate->finishedReading(uri.c_str());
break;
}
if ( delegate == NULL || !delegate->handleReadError(uri.c_str()) )
break;
delete cfg;
}
symbols[uri] = SymbolFileMap();
symbols[uri].lastModified = lastModified;
SymbolTable *symtab = cfg->symbolTable();
if ( symtab == NULL ) {
delete cfg;
continue;
}
for ( SymbolTable::iterator it = symtab->begin(); it != symtab->end(); ++it )
symbols[(*it)->uri][(*it)->name] = new SymbolMapItem(**it);
delete cfg;
}
}
// Update each module parameter with configuration symbols
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
bool isGlobal = mod->definition->name == "global";
map<string, ParameterPtr> unknowns;
mod->unknowns.clear();
for ( int stage = Environment::CS_FIRST; stage <= Environment::CS_LAST; ++stage ) {
SymbolFileMap *fileMap;
string uri;
if ( isGlobal && (stage == Environment::CS_DEFAULT_GLOBAL ||
stage == Environment::CS_CONFIG_GLOBAL ||
stage == Environment::CS_USER_GLOBAL) ) {
uri = "";
fileMap = &symbols[uri];
fileMap->clear();
}
else {
uri = configFileLocation(true, mod->definition->name, stage);
fileMap = &symbols[uri];
}
for ( size_t s = 0; s < mod->sections.size(); ++s ) {
Section *sec = mod->sections[s].get();
updateContainer(sec, *fileMap, stage);
}
// Collect and store unknown symbols
SymbolFileMap::iterator it;
for ( it = fileMap->begin(); it != fileMap->end(); ++it ) {
if ( it->second->known ) continue;
ParameterPtr param = unknowns[it->first];
if ( param == NULL ) {
param = new Parameter(NULL, it->first);
unknowns[it->first] = param;
mod->unknowns.push_back(param);
}
param->symbols[stage] = it->second;
}
}
for ( size_t s = 0; s < mod->sections.size(); ++s ) {
Section *sec = mod->sections[s].get();
updateContainer(sec, updateMaxStage);
}
// Read available profiles
mod->loadProfiles(stationConfigDir(true, mod->definition->name), delegate);
// Check for case sensitivity conflicts
for ( size_t p = 0; p < mod->unknowns.size(); ++ p ) {
ParameterPtr param = mod->unknowns[p];
for ( int stage = Environment::CS_FIRST; stage <= Environment::CS_LAST; ++stage ) {
if ( param->symbols[stage] == NULL ) continue;
CaseSensitivityCheck check(delegate, mod, stage, ¶m->symbols[stage]->symbol);
mod->accept(&check);
}
}
}
// Read station module configuration
keyDir = stationConfigDir(true);
try {
it = fs::directory_iterator(SC_FS_PATH(keyDir));
}
catch ( ... ) {
it = fsDirEnd;
SEISCOMP_DEBUG("%s not available", keyDir.c_str());
}
for ( ; it != fsDirEnd; ++it ) {
if ( fs::is_directory(*it) ) continue;
string filename = SC_FS_IT_LEAF(it);
if ( filename.compare(0, 8, "station_") != 0 )
continue;
size_t pos = filename.find('_', 8);
if ( pos == string::npos ) {
cerr << filename << ": invalid station id: expected '_' as "
"net-sta separator: ignoring" << endl;
continue;
}
StationID id;
id.networkCode = filename.substr(8, pos-8);
id.stationCode = filename.substr(pos+1);
if ( id.networkCode.empty() ) {
cerr << filename << ": invalid station id: network code must "
"not be empty: ignoring" << endl;
continue;
}
if ( id.stationCode.empty() ) {
cerr << filename << ": invalid station id: station code must "
"not be empty: ignoring" << endl;
continue;
}
//SEISCOMP_DEBUG("reading station key %s", it->path().string().c_str());
StationPtr station = new Station;
if ( !station->readConfig(SC_FS_IT_STR(it).c_str()) )
cerr << SC_FS_IT_STR(it) << ": error reading configuration: "
"set empty" << endl;
stations[id] = station;
for ( size_t i = 0; i < station->config.size(); ++i ) {
Module *mod = module(station->config[i].moduleName);
if ( mod == NULL ) {
cerr << "ERROR: module '" << station->config[i].moduleName
<< "' is not registered" << endl;
continue;
}
if ( !mod->bindingTemplate ) {
cerr << "ERROR: module '" << station->config[i].moduleName
<< "' has no registered binding definitions: ignoring" << endl;
continue;
}
if ( !mod->readBinding(id, station->config[i].profile, false, delegate) )
cerr << "ERROR: " << station->config[i].moduleName
<< ": read binding for " << id.networkCode << "."
<< id.stationCode << " failed: removed" << endl;
}
}
/*
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
for ( Module::BindingMap::iterator it = mod->bindings.begin();
it != mod->bindings.end(); ++it ) {
cout << "[" << mod->definition->name << "/" << it->first.stationCode << "]" << endl;
it->second->dump(cout);
}
}
*/
/*
for ( SymbolMap::iterator it1 = symbols.begin(); it1 != symbols.end(); ++it1 ) {
cout << "<" << it1->first << ">" << endl;
for ( SymbolFileMap::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 ) {
cout << " <" << it2->first << ">"
<< it2->second->symbol.content
<< "</" << it2->first << ">"
<< endl;
}
cout << "</" << it1->first << ">" << endl;
}
*/
return true;
}
bool Model::writeConfig(int stage, ConfigDelegate *delegate) {
//---------------------------------------------------
// Save station key files
//---------------------------------------------------
//stations.clear();
for ( Stations::iterator it = stations.begin(); it != stations.end(); ++it )
it->second->config.clear();
// Collect all stations keyfiles
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
if ( !mod->supportsBindings() ) continue;
Module::BindingMap::iterator it;
for ( it = mod->bindings.begin(); it != mod->bindings.end(); ++it ) {
pair<Stations::iterator, bool> sp;
sp = stations.insert(Stations::value_type(it->first, NULL));
if ( sp.second )
sp.first->second = new Station;
ModuleBinding *binding = it->second.get();
sp.first->second->setConfig(mod->definition->name, binding->name);
}
}
string keyDir = stationConfigDir(false);
fs::directory_iterator it;
fs::directory_iterator fsDirEnd;
SEISCOMP_INFO("Updating bindings in %s", keyDir.c_str());
// Clean up old key directory
try {
it = fs::directory_iterator(SC_FS_PATH(keyDir));
}
catch ( ... ) {
it = fsDirEnd;
}
for ( ; it != fsDirEnd; ++it ) {
string filename = SC_FS_IT_LEAF(it);
if ( filename.compare(0, 8, "station_") != 0 )
continue;
size_t pos = filename.find('_', 8);
if ( pos == string::npos ) continue;
StationID id;
id.networkCode = filename.substr(8, pos-8);
id.stationCode = filename.substr(pos+1);
if ( id.networkCode.empty() ) continue;
if ( id.stationCode.empty() ) continue;
if ( stations.find(id) == stations.end() ) {
try { fs::remove(*it); } catch ( ... ) {}
}
}
// Save configuration
createPath(keyDir);
for ( Stations::iterator it = stations.begin(); it != stations.end(); ++it ) {
string filename = keyDir + "/station_" + it->first.networkCode +
"_" + it->first.stationCode;
if ( !it->second->writeConfig(filename.c_str(), delegate) )
cerr << "[ERROR] writing " << filename << " failed" << endl;
}
//---------------------------------------------------
// Save module configurations
//---------------------------------------------------
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
string filename = configFileLocation(false, mod->definition->name, stage);
if ( !writeConfig(mod, filename, stage, delegate) )
cerr << "[ERROR] writing " << filename << " failed" << endl;
}
//---------------------------------------------------
// Save bindings
//---------------------------------------------------
for ( size_t i = 0; i < modules.size(); ++i ) {
Module *mod = modules[i].get();
if ( !mod->supportsBindings() ) continue;
string keyDir = stationConfigDir(false, mod->definition->name);
createPath(keyDir);
set<string> files;
// Save profiles
Module::Profiles::iterator pit;
for ( pit = mod->profiles.begin(); pit != mod->profiles.end(); ++pit) {
ModuleBinding *prof = pit->get();
// Safety check, but this should never happen
if ( prof->name.empty() ) continue;
files.insert(string("profile_") + prof->name);
if ( !prof->writeConfig(keyDir + "/profile_" + prof->name, delegate) )
cerr << "[ERROR] writing profile " << keyDir << "/profile"
<< prof->name << " failed" << endl;
}
// Save station keys
Module::BindingMap::iterator bit;
for ( bit = mod->bindings.begin(); bit != mod->bindings.end(); ++bit ) {
ModuleBinding *binding = bit->second.get();
// Profiles have been written already
if ( !binding->name.empty() ) continue;
files.insert(string("station_") + bit->first.networkCode +
"_" + bit->first.stationCode);
if ( !binding->writeConfig(keyDir + "/station_" +
bit->first.networkCode + "_" +
bit->first.stationCode,
delegate) )
cerr << "[ERROR] writing binding " << keyDir << "/profile"
<< binding->name << " failed" << endl;
}
// Remove unused files
try {
it = fs::directory_iterator(SC_FS_PATH(keyDir));
}
catch ( ... ) {
it = fsDirEnd;
}
for ( ; it != fsDirEnd; ++it ) {
if ( files.find(SC_FS_IT_LEAF(it)) == files.end() ) {
try { fs::remove(*it); } catch ( ... ) {}
}
}
}
return true;
}
bool Model::writeConfig(Module *mod, const std::string &filename, int stage, ConfigDelegate *delegate) {
if ( delegate )
delegate->aboutToWrite(filename.c_str());
ofstream ofs;
time_t lastModified = lastModificationTime(filename);
set<string> processedSymbols;
ParameterCollector pc;
mod->accept(&pc);
Config::Config cfg;
cfg.readConfig(filename, stage);
ConfigDelegate::ChangeList changes;
// Check all available parameters for corresponding
vector<Parameter*>::iterator pit;
for ( pit = pc.parameters.begin(); pit != pc.parameters.end(); ++pit ) {
Parameter *param = *pit;
Config::Symbol *sym = cfg.symbolTable()->get(param->variableName);
processedSymbols.insert(param->variableName);
if ( !param->symbols[stage] ) {
if ( sym != NULL ) {
if ( changes.empty() ) cerr << "[" << filename << "]" << endl;
cerr << "- " << sym->name << " '" << sym->content << "'" << endl;
changes.push_back(ConfigDelegate::Change(ConfigDelegate::Removed, sym->name, sym->content, ""));
}
continue;
}
if ( param->symbols[stage]->symbol.stage == Environment::CS_UNDEFINED ) {
if ( sym != NULL ) {
if ( changes.empty() ) cerr << "[" << filename << "]" << endl;
cerr << "- " << sym->name << " '" << sym->content << "'" << endl;
changes.push_back(ConfigDelegate::Change(ConfigDelegate::Removed, sym->name, sym->content, ""));
}
continue;
}
if ( (sym != NULL) && (sym->content == param->symbols[stage]->symbol.content) )
continue;
if ( changes.empty() ) cerr << "[" << filename << "]" << endl;
if ( sym == NULL ) {
cerr << "+ " << param->variableName << " '" << param->symbols[stage]->symbol.content << "'" << endl;
changes.push_back(ConfigDelegate::Change(ConfigDelegate::Added, param->variableName, "", param->symbols[stage]->symbol.content));
}
else {
cerr << "* " << param->variableName << " '" << sym->content << "' -> '" << param->symbols[stage]->symbol.content << "'" << endl;
changes.push_back(ConfigDelegate::Change(ConfigDelegate::Updated, param->variableName, sym->content, param->symbols[stage]->symbol.content));
}
}
SymbolMap::iterator it = symbols.find(filename);
Config::SymbolTable::iterator cit;
for ( cit = cfg.symbolTable()->begin(); cit != cfg.symbolTable()->end(); ++cit ) {
// Symbol not part of the already known parameters at load time?
if ( processedSymbols.find((*cit)->name) == processedSymbols.end() ) {
// Need to append this to the unknowns
ParameterPtr newParam = new Parameter(NULL, (*cit)->name);
newParam->symbols[stage] = new SymbolMapItem(**cit);
if ( it != symbols.end() )
it->second[newParam->variableName] = newParam->symbols[stage];
mod->unknowns.push_back(newParam);
}
}
// No update required?
if ( changes.empty() ) {
if ( it != symbols.end() )
it->second.lastModified = lastModified;
if ( delegate )
delegate->finishedWriting(filename.c_str(), changes);
return true;
}
processedSymbols.clear();
if ( it != symbols.end() ) {
if ( lastModified > it->second.lastModified ) {
cerr << filename << " has changed on disk" << endl;
if ( delegate && delegate->handleWriteTimeMismatch(filename.c_str(), changes) )
return true;
}
}
for ( size_t s = 0; s < mod->sections.size(); ++s ) {
Section *sec = mod->sections[s].get();
Section *paramSection = sec;
if ( !write(sec, paramSection, stage, processedSymbols, ofs, filename, true) ) {
if ( delegate )
delegate->hasWriteError(filename.c_str());
return false;
}
}
for ( size_t p = 0; p < mod->unknowns.size(); ++ p ) {
Parameter *param = mod->unknowns[p].get();
if ( !write(param, NULL, stage, processedSymbols, ofs, filename, true) ) {
if ( delegate )
delegate->hasWriteError(filename.c_str());
return false;
}
}
// Nothing written, remove the file
if ( processedSymbols.empty() ) {
try {
fs::remove(SC_FS_PATH(filename));
}
catch ( ... ) {}
}
if ( it != symbols.end() )
it->second.lastModified = lastModificationTime(filename);
if ( delegate )
delegate->finishedWriting(filename.c_str(), changes);
return true;
}
void Model::update(const Module *mod, Container *container) const {
bool isGlobal = mod->definition->name == "global";
for ( int stage = Environment::CS_FIRST; stage <= Environment::CS_LAST; ++stage ) {
SymbolFileMap *fileMap;
string uri;
if ( isGlobal && (stage == Environment::CS_DEFAULT_GLOBAL ||
stage == Environment::CS_CONFIG_GLOBAL ||
stage == Environment::CS_USER_GLOBAL) ) {
uri = "";
fileMap = &symbols[uri];
}
else {
uri = configFileLocation(true, mod->definition->name, stage);
fileMap = &symbols[uri];
}
updateContainer(container, *fileMap, stage);
}
updateContainer(container, Environment::CS_QUANTITY);
}
void Model::updateBinding(const ModuleBinding *mod, Binding *binding) const {
SymbolFileMap *fileMap = &symbols[mod->configFile];
for ( size_t s = 0; s < binding->sections.size(); ++s ) {
updateContainer(binding->sections[s].get(), *fileMap, Environment::CS_CONFIG_APP);
updateContainer(binding->sections[s].get(), Environment::CS_QUANTITY);
}
}
bool Model::addStation(const StationID &id) {
Stations::iterator it = stations.find(id);
if ( it != stations.end() ) return false;
stations[id] = new Station;
return true;
}
bool Model::removeStation(const StationID &id) {
Stations::iterator it = stations.find(id);
if ( it == stations.end() ) return false;
stations.erase(it);
for ( size_t i = 0; i < modules.size(); ++i )
modules[i]->removeStation(id);
return true;
}
bool Model::removeNetwork(const std::string &net) {
bool found = false;
Stations::iterator it = stations.begin();
for ( ; it != stations.end(); ) {
if ( it->first.networkCode != net )
++it;
else {
for ( size_t i = 0; i < modules.size(); ++i )
modules[i]->removeStation(it->first);
stations.erase(it++);
found = true;
}
}
return found;
}
bool Model::removeStationModule(const StationID &id, Module *mod) {
Stations::iterator it = stations.find(id);
if ( it == stations.end() ) return false;
Station *sta = it->second.get();
Station::ModuleConfigs::iterator cit = sta->config.begin();
for ( ; cit != sta->config.end(); ++cit ) {
if ( cit->moduleName == mod->definition->name ) {
sta->config.erase(cit);
return true;
}
}
return mod->removeStation(id);
}
void Model::accept(ModelVisitor *visitor) const {
for ( size_t i = 0; i < modules.size(); ++i ) {
if ( !visitor->visit(modules[i].get()) ) continue;
modules[i]->accept(visitor);
}
}
}
}
| 26.502915 | 144 | 0.622639 | yannikbehr |
2e919489f2f6981ce86b9ea5e0702489e79a572a | 396 | hpp | C++ | NWNXLib/API/Mac/API/xGetGeometryReply.hpp | acaos/nwnxee-unified | 0e4c318ede64028c1825319f39c012e168e0482c | [
"MIT"
] | 1 | 2019-06-04T04:30:24.000Z | 2019-06-04T04:30:24.000Z | NWNXLib/API/Mac/API/xGetGeometryReply.hpp | presscad/nwnee | 0f36b281524e0b7e9796bcf30f924792bf9b8a38 | [
"MIT"
] | null | null | null | NWNXLib/API/Mac/API/xGetGeometryReply.hpp | presscad/nwnee | 0f36b281524e0b7e9796bcf30f924792bf9b8a38 | [
"MIT"
] | 1 | 2019-10-20T07:54:45.000Z | 2019-10-20T07:54:45.000Z | #pragma once
#include <cstdint>
#include "unknown_CARD8.hpp"
namespace NWNXLib {
namespace API {
struct xGetGeometryReply
{
CARD8 type;
uint8_t depth;
uint16_t sequenceNumber;
uint32_t length;
uint32_t root;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t borderWidth;
uint16_t pad1;
uint32_t pad2;
uint32_t pad3;
};
}
}
| 12.774194 | 28 | 0.669192 | acaos |
2e9194bbb5d7aaf99956695988e7c7e71fe01bd1 | 13,573 | cc | C++ | src/cca/Chemistry/server/cxx/NWChem_Chemistry_QC_Model_Impl.cc | dinisAbranches/nwchem | 21cb07ff634475600ab687882652b823cad8c0cd | [
"ECL-2.0"
] | 317 | 2017-11-20T21:29:11.000Z | 2022-03-28T11:48:24.000Z | src/cca/Chemistry/server/cxx/NWChem_Chemistry_QC_Model_Impl.cc | dinisAbranches/nwchem | 21cb07ff634475600ab687882652b823cad8c0cd | [
"ECL-2.0"
] | 356 | 2017-12-05T01:38:12.000Z | 2022-03-31T02:28:21.000Z | src/cca/Chemistry/server/cxx/NWChem_Chemistry_QC_Model_Impl.cc | dinisAbranches/nwchem | 21cb07ff634475600ab687882652b823cad8c0cd | [
"ECL-2.0"
] | 135 | 2017-11-19T18:36:44.000Z | 2022-03-31T02:28:49.000Z | //
// File: NWChem_Chemistry_QC_Model_Impl.cc
// Symbol: NWChem.Chemistry_QC_Model-v0.4
// Symbol Type: class
// Babel Version: 0.10.12
// Description: Server-side implementation for NWChem.Chemistry_QC_Model
//
// WARNING: Automatically generated; only changes within splicers preserved
//
// babel-version = 0.10.12
// xml-url = /home/windus/CCA/mcmd-paper/nwchem/src/cca/repo/NWChem.Chemistry_QC_Model-v0.4.xml
//
#include "NWChem_Chemistry_QC_Model_Impl.hh"
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model._includes)
// Insert-Code-Here {NWChem.Chemistry_QC_Model._includes} (additional includes or code)
#include "NWChemWrap.fh"
#include <string>
#include <cctype>
#include <iostream>
using namespace std;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model._includes)
// user-defined constructor.
void NWChem::Chemistry_QC_Model_impl::_ctor() {
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model._ctor)
// Insert-Code-Here {NWChem.Chemistry_QC_Model._ctor} (constructor)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model._ctor)
}
// user-defined destructor.
void NWChem::Chemistry_QC_Model_impl::_dtor() {
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model._dtor)
// Insert-Code-Here {NWChem.Chemistry_QC_Model._dtor} (destructor)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model._dtor)
}
// static class initializer.
void NWChem::Chemistry_QC_Model_impl::_load() {
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model._load)
// Insert-Code-Here {NWChem.Chemistry_QC_Model._load} (class initialization)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model._load)
}
// user-defined static methods: (none)
// user-defined non-static methods:
/**
* Method: initialize[]
*/
void
NWChem::Chemistry_QC_Model_impl::initialize (
/* in */ const ::std::string& scratch_directory )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.initialize)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.initialize} (initialize method)
int len;
len=scratch_directory.length();
nwchem_nwchemstart_(scratch_directory.c_str(),len);
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.initialize)
}
/**
* Method: change_theory[]
*/
void
NWChem::Chemistry_QC_Model_impl::change_theory (
/* in */ const ::std::string& theory )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.change_theory)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.change_theory} (change_theory method)
nwchem_settheory_(theory.c_str());
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.change_theory)
}
/**
* Method: change_basis[]
*/
void
NWChem::Chemistry_QC_Model_impl::change_basis (
/* in */ const ::std::string& basis )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.change_basis)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.change_basis} (change_basis method)
int len;
len=basis.length();
nwchem_setbasisset_(basis.c_str(),len);
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.change_basis)
}
/**
* Method: setCoordinatesFromFile[]
*/
void
NWChem::Chemistry_QC_Model_impl::setCoordinatesFromFile (
/* in */ const ::std::string& molecule_filename )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.setCoordinatesFromFile)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.setCoordinatesFromFile} (setCoordinatesFromFile method)
std::cout << "\n\nNWCHEM COORDS FROM FILE: " << molecule_filename;
nwchem_setcoordinatesfromfile_(molecule_filename.c_str());
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.setCoordinatesFromFile)
}
/**
* Method: getNumCoordinates[]
*/
int32_t
NWChem::Chemistry_QC_Model_impl::getNumCoordinates ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.getNumCoordinates)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.getNumCoordinates} (getNumCoordinates method)
int num;
nwchem_getnumcoordinates_(&num);
return num;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.getNumCoordinates)
}
/**
* Method: get_coor[]
*/
::sidl::array<double>
NWChem::Chemistry_QC_Model_impl::get_coor ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_coor)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_coor} (get_coor method)
int num;
nwchem_getnumcoordinates_(&num);
sidl::array<double> x = sidl::array<double>::create1d(num);
double* dataPtr = x.first();
nwchem_getcoordinates_(dataPtr);
return x;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_coor)
}
/**
* Method: set_coor[]
*/
void
NWChem::Chemistry_QC_Model_impl::set_coor (
/* in */ ::sidl::array<double> x )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_coor)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_coor} (set_coor method)
double* dataPtr = x.first();
nwchem_setcoordinates_(dataPtr);
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_coor)
}
/**
* Set the molecule. @param molecule The new molecule.
*/
void
NWChem::Chemistry_QC_Model_impl::set_molecule (
/* in */ ::Chemistry::Molecule molecule )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_molecule)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_molecule} (set_molecule method)
molecule_ = molecule;
::sidl::array<double> x;
int coord_num;
double conv = molecule_.get_units().convert_to("bohr");
coord_num=molecule_.get_n_atom()*3;
x=molecule_.get_coor();
double* dataPtr = x.first();
for(int i=0;i<coord_num;++i)
{
*(dataPtr+i)=(*(dataPtr+i))*conv;
}
nwchem_setcoordinates_(dataPtr);
return;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_molecule)
}
/**
* Returns the molecule. @return The Molecule object.
*/
::Chemistry::Molecule
NWChem::Chemistry_QC_Model_impl::get_molecule ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_molecule)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_molecule} (get_molecule method)
return molecule_;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_molecule)
}
/**
* Method: get_energy[]
*/
double
NWChem::Chemistry_QC_Model_impl::get_energy ()
throw (
::sidl::BaseException
)
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_energy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_energy} (get_energy method)
double f;
nwchem_taskenergy_(&f);
return f;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_energy)
}
/**
* Sets the accuracy for subsequent energy calculations.
* @param acc The new accuracy.
*/
void
NWChem::Chemistry_QC_Model_impl::set_energy_accuracy (
/* in */ double acc )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_energy_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_energy_accuracy} (set_energy_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_energy_accuracy)
}
/**
* Returns the accuracy to which the energy is already computed.
* The result is undefined if the energy has not already
* been computed.
* @return The energy accuracy.
*/
double
NWChem::Chemistry_QC_Model_impl::get_energy_accuracy ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_energy_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_energy_accuracy} (get_energy_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_energy_accuracy)
}
/**
* This allows a programmer to request that if any result
* is computed,
* then the energy is computed too. This allows, say, for a request
* for a gradient to cause the energy to be computed. This computed
* energy is cached and returned when the get_energy() member
* is called.
* @param doit Whether or not to compute the energy.
*/
void
NWChem::Chemistry_QC_Model_impl::set_do_energy (
/* in */ bool doit )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_do_energy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_do_energy} (set_do_energy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_do_energy)
}
/**
* Returns the Cartesian gradient.
*/
::sidl::array<double>
NWChem::Chemistry_QC_Model_impl::get_gradient ()
throw (
::sidl::BaseException
)
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_gradient)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_gradient} (get_gradient method)
int num;
nwchem_getnumcoordinates_(&num);
sidl::array<double> g = sidl::array<double>::create1d(num);
double* gradPtr = g.first();
nwchem_taskgradient_(gradPtr);
return g;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_gradient)
}
/**
* Sets the accuracy for subsequent gradient calculations
* @param acc The new accuracy for gradients.
*/
void
NWChem::Chemistry_QC_Model_impl::set_gradient_accuracy (
/* in */ double acc )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_gradient_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_gradient_accuracy} (set_gradient_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_gradient_accuracy)
}
/**
* Returns the accuracy to which the gradient is already computed.
* The result is undefined if the gradient has not already
* been computed.
* @return The current gradient accuracy.
*/
double
NWChem::Chemistry_QC_Model_impl::get_gradient_accuracy ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_gradient_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_gradient_accuracy} (get_gradient_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_gradient_accuracy)
}
/**
* Returns the Cartesian Hessian. @return The Hessian.
*/
::sidl::array<double>
NWChem::Chemistry_QC_Model_impl::get_hessian ()
throw (
::sidl::BaseException
)
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_hessian)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_hessian} (get_hessian method)
int num;
nwchem_getnumcoordinates_(&num);
int lower[2]={1,1}, upper[2]={num,num};
sidl::array<double> h = sidl::array<double>::createCol(2,lower,upper);
double* hessPtr = h.first();
nwchem_taskhessian_(hessPtr);
return h;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_hessian)
}
/**
* Sets the accuracy for subsequent Hessian calculations.
* @param acc The new accuracy for Hessians.
*/
void
NWChem::Chemistry_QC_Model_impl::set_hessian_accuracy (
/* in */ double acc )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_hessian_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_hessian_accuracy} (set_hessian_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_hessian_accuracy)
}
/**
* Returns the accuracy to which the Hessian is already computed.
* The result is undefined if the Hessian has not already
* been computed.
*/
double
NWChem::Chemistry_QC_Model_impl::get_hessian_accuracy ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_hessian_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_hessian_accuracy} (get_hessian_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_hessian_accuracy)
}
/**
* Returns a Cartesian guess Hessian.
*/
::sidl::array<double>
NWChem::Chemistry_QC_Model_impl::get_guess_hessian ()
throw (
::sidl::BaseException
)
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_guess_hessian)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_guess_hessian} (get_guess_hessian method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_guess_hessian)
}
/**
* Sets the accuracy for subsequent guess Hessian calculations.
* @param acc The new accuracy for guess Hessians.
*/
void
NWChem::Chemistry_QC_Model_impl::set_guess_hessian_accuracy (
/* in */ double acc )
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.set_guess_hessian_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.set_guess_hessian_accuracy} (set_guess_hessian_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.set_guess_hessian_accuracy)
}
/**
* Returns the accuracy to which the guess Hessian is
* already computed. The result is undefined if the guess Hessian
* has not already been computed.
* @return The guess hessian accuracy.
*/
double
NWChem::Chemistry_QC_Model_impl::get_guess_hessian_accuracy ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.get_guess_hessian_accuracy)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.get_guess_hessian_accuracy} (get_guess_hessian_accuracy method)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.get_guess_hessian_accuracy)
}
/**
* This can be called when this Model object is no longer needed.
* No other members may be called after finalize.
*/
int32_t
NWChem::Chemistry_QC_Model_impl::finalize ()
throw ()
{
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model.finalize)
// Insert-Code-Here {NWChem.Chemistry_QC_Model.finalize} (finalize method)
nwchem_nwchemend_();
return 0;
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model.finalize)
}
// DO-NOT-DELETE splicer.begin(NWChem.Chemistry_QC_Model._misc)
// Insert-Code-Here {NWChem.Chemistry_QC_Model._misc} (miscellaneous code)
// DO-NOT-DELETE splicer.end(NWChem.Chemistry_QC_Model._misc)
| 31.130734 | 112 | 0.751713 | dinisAbranches |
2e91b3017863e7a26c289f6e5e11953ea38c12bf | 274 | hpp | C++ | cvmat2qimage/include/cvmat2qimage.hpp | majorx234/qt_videocam_hough | bb8c5ac8045a1d312e3428705967960496688846 | [
"BSD-2-Clause"
] | null | null | null | cvmat2qimage/include/cvmat2qimage.hpp | majorx234/qt_videocam_hough | bb8c5ac8045a1d312e3428705967960496688846 | [
"BSD-2-Clause"
] | null | null | null | cvmat2qimage/include/cvmat2qimage.hpp | majorx234/qt_videocam_hough | bb8c5ac8045a1d312e3428705967960496688846 | [
"BSD-2-Clause"
] | null | null | null | #ifndef CVMAT2QIMAGE_HPP
#define CVMAT2QIMAGE_HPP
#include <QImage>
#include <opencv2/core/core.hpp>
#include <string>
cv::Mat qimage2cvmat( const QImage &inImage);
QImage cvmat2qimage( const cv::Mat &inMat );
std::string type2str(int type);
#endif // QT_OPENCV_CONV_HPP | 22.833333 | 45 | 0.766423 | majorx234 |
2e9220c365030107a4e71da79f7781e3ff3a865f | 1,519 | cpp | C++ | src/tools.cpp | andrestoga/CarND-Extended-Kalman-Filter-Project | b387f9282258cfe92db654c50478cf3d1c1f5a9a | [
"MIT"
] | null | null | null | src/tools.cpp | andrestoga/CarND-Extended-Kalman-Filter-Project | b387f9282258cfe92db654c50478cf3d1c1f5a9a | [
"MIT"
] | null | null | null | src/tools.cpp | andrestoga/CarND-Extended-Kalman-Filter-Project | b387f9282258cfe92db654c50478cf3d1c1f5a9a | [
"MIT"
] | null | null | null | #include "tools.h"
#include <iostream>
using Eigen::VectorXd;
using Eigen::MatrixXd;
using std::vector;
Tools::Tools() {}
Tools::~Tools() {}
VectorXd Tools::CalculateRMSE(const vector<VectorXd> &estimations,
const vector<VectorXd> &ground_truth) {
/**
* Calculate the RMSE here.
*/
VectorXd res(4);
res << 0, 0, 0, 0;
if (estimations.size() != ground_truth.size())
{
return res;
}
for (int i = 0; i < estimations.size(); ++i)
{
VectorXd tmp = estimations[i].array() - ground_truth[i].array();
tmp = tmp.array() * tmp.array();
res += tmp;
}
res = res / estimations.size();
res = res.array().sqrt();
return res;
}
MatrixXd Tools::CalculateJacobian(const VectorXd& x_state) {
/**
* Calculate a Jacobian here.
*/
double px = x_state(0);
double py = x_state(1);
double vx = x_state(2);
double vy = x_state(3);
MatrixXd jaco = MatrixXd(3,4);
jaco << 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0;
double px2 = px * px;
double py2 = py * py;
double px2_py2 = px2 + py2;
double c1 = sqrt(px2_py2);
double c2 = pow(px2_py2, 3/2);
// TODO: I don't know what value to assign to the jacobian
// when there is division by 0
if (px2_py2 > 0.0001)
{
jaco << px/c1, py/c1, 0, 0,
-py/px2_py2, px/px2_py2, 0, 0,
py*(vx*py - vy*px)/c2, px*(vy*px - vx*py)/c2, px/c1, py/c2;
}
else
{
throw std::invalid_argument("Jacobian division by 0");
}
return jaco;
}
| 19.986842 | 71 | 0.57077 | andrestoga |
2e9699a79cf8fed4f81696cf4b3380f9b63a9143 | 423 | cpp | C++ | ch10/ex10_13.cpp | sanerror/sanerror-s-Cpp-Primer-Answers | 1e14c4789cacf03050c0aec93eb2e3a12010a77a | [
"MIT"
] | null | null | null | ch10/ex10_13.cpp | sanerror/sanerror-s-Cpp-Primer-Answers | 1e14c4789cacf03050c0aec93eb2e3a12010a77a | [
"MIT"
] | null | null | null | ch10/ex10_13.cpp | sanerror/sanerror-s-Cpp-Primer-Answers | 1e14c4789cacf03050c0aec93eb2e3a12010a77a | [
"MIT"
] | null | null | null | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
bool judge(const string & s1) {
return s1.size() < 5;
}
int main() {
vector<string> str{ "pen","pineapple","apple","pen" };
auto judge_begin = partition(str.begin(), str.end(), judge);
while (judge_begin != str.end()) {
cout << *judge_begin << " ";
++judge_begin;
}
cout << endl;
return 0;
} | 20.142857 | 62 | 0.607565 | sanerror |
2e96bd2aa74b798c78f7d958cc7b4093a7383579 | 2,315 | cpp | C++ | src/sly_1_unpacker.cpp | VelocityRa/SlyCooper | 03d4043293777d6a57093670968426a26384bc2b | [
"MIT"
] | 14 | 2020-12-07T11:45:43.000Z | 2022-01-14T14:51:40.000Z | src/sly_1_unpacker.cpp | VelocityRa/SlyCooper | 03d4043293777d6a57093670968426a26384bc2b | [
"MIT"
] | 2 | 2020-12-09T23:04:42.000Z | 2021-08-17T13:56:08.000Z | src/sly_1_unpacker.cpp | VelocityRa/SlyCooper | 03d4043293777d6a57093670968426a26384bc2b | [
"MIT"
] | 3 | 2020-12-09T15:28:38.000Z | 2021-10-17T04:20:14.000Z | #include "file_magic_utils.hpp"
#include "fs.hpp"
#include "types.hpp"
#include "wac.hpp"
#include <algorithm>
#include <cstdio>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdexcept>
constexpr bool DEBUG_MODE = false;
int main(int argc, char* argv[]) {
try {
if (argc < 2)
throw std::runtime_error(std::string(argv[0]) + " <input_file> [<output_dir>]");
const std::filesystem::path wac_path{ argv[1] };
std::string wal_path_str{ argv[1] };
wal_path_str.back() = 'L';
std::filesystem::path output_path;
if (argc < 3)
output_path = wac_path.parent_path() / "extracted";
else
output_path = argv[2];
std::filesystem::create_directory(output_path);
const auto wac_fp = fopen64(wac_path.string().c_str(), "rb");
if (wac_fp == NULL)
throw std::runtime_error("Failed to open: " + wac_path.string());
const auto wac_entries = parse_wac(wac_fp);
const auto wal_fp = fopen64(wal_path_str.c_str(), "rb");
if (wal_fp == NULL)
throw std::runtime_error("wal_fp == NULL");
Buffer file_data;
for (const auto& entry : wac_entries) {
file_data.resize(entry.size);
_fseeki64(wal_fp, entry.offset * SECTOR_SIZE, SEEK_SET);
fread(file_data.data(), entry.size, 1, wal_fp);
const auto extension = get_file_extension(file_data, (char)entry.type);
const auto out_path = output_path / (entry.name + extension);
const auto out_fp = fopen64(out_path.string().c_str(), "wb");
if (out_fp == NULL)
throw std::runtime_error("out_fp == NULL");
fwrite((const char*)file_data.data(), entry.size, 1, out_fp);
if (DEBUG_MODE)
printf("Wrote %s offset 0x%08llX size 0x%08llX\n", out_path.string().c_str(),
entry.offset * SECTOR_SIZE, file_data.size());
fclose(out_fp);
}
fclose(wal_fp);
fclose(wac_fp);
} catch (const std::runtime_error& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "errno: " << strerror(errno) << std::endl;
return 1;
}
return 0;
}
| 31.283784 | 93 | 0.577106 | VelocityRa |
2e989ae4e8f30f505d462831ba4ecec648258fb3 | 1,217 | cpp | C++ | src/allegro_flare/random.cpp | MarkOates/allegro_flare | b454cb85eb5e43d19c23c0c6fd2dc11b96666ce7 | [
"MIT"
] | 25 | 2015-03-30T02:02:43.000Z | 2019-03-04T22:29:12.000Z | src/allegro_flare/random.cpp | MarkOates/allegro_flare | b454cb85eb5e43d19c23c0c6fd2dc11b96666ce7 | [
"MIT"
] | 122 | 2015-04-01T08:15:26.000Z | 2019-10-16T20:31:22.000Z | src/allegro_flare/random.cpp | allegroflare/allegro_flare | 21d6fe2a5a5323102285598c8a8c75b393ce0322 | [
"MIT"
] | 4 | 2020-02-25T18:17:31.000Z | 2021-04-17T05:06:52.000Z | #include <allegro_flare/random.h>
namespace allegro_flare
{
Random::Random(unsigned int seed)
: seed(seed)
{
set_seed(seed);
}
void Random::set_seed(unsigned int new_seed)
{
seed = new_seed;
random_number_generator.seed(seed);
}
unsigned int Random::get_seed()
{
return seed;
}
int Random::get_random_int(int min, int max)
{
std::uniform_int_distribution<int> dist(min, max);
return dist(random_number_generator);
}
float Random::get_random_float(float min, float max)
{
std::uniform_real_distribution<float> dist(min, max);
return dist(random_number_generator);
}
double Random::get_random_double(double min, double max)
{
std::uniform_real_distribution<double> dist(min, max);
return dist(random_number_generator);
}
bool Random::get_one_in_chance(int chance)
{
if (get_random_int(0, chance - 1) == 0)
return true;
return false;
}
int Random::roll_dice(int number_of_die, int sides)
{
int result = 0;
for (int i = 0; i < number_of_die; i++)
result += get_random_int(sides, 1);
return result;
}
}
| 15.2125 | 60 | 0.622021 | MarkOates |
2e9d43df63c223a59a3b2d72792c53251da00d21 | 791 | cpp | C++ | unit/goto-programs/goto_trace_output.cpp | jeannielynnmoulton/cbmc | 1d4af6d88ec960677170049a8a89a9166b952996 | [
"BSD-4-Clause"
] | null | null | null | unit/goto-programs/goto_trace_output.cpp | jeannielynnmoulton/cbmc | 1d4af6d88ec960677170049a8a89a9166b952996 | [
"BSD-4-Clause"
] | 1 | 2019-02-05T16:18:25.000Z | 2019-02-05T16:18:25.000Z | unit/goto-programs/goto_trace_output.cpp | jeannielynnmoulton/cbmc | 1d4af6d88ec960677170049a8a89a9166b952996 | [
"BSD-4-Clause"
] | null | null | null | /*******************************************************************\
Module: Unit tests for goto_trace_stept::output
Author: Diffblue Limited. All rights reserved.
\*******************************************************************/
#include <testing-utils/catch.hpp>
#include <goto-programs/goto_program_template.h>
#include <goto-programs/goto_trace.h>
#include <iostream>
SCENARIO(
"Output trace with nil lhs object",
"[core][goto-programs][goto_trace]")
{
symbol_tablet symbol_table;
namespacet ns(symbol_table);
goto_programt::instructionst instructions;
instructions.emplace_back(goto_program_instruction_typet::OTHER);
goto_trace_stept step;
step.pc = instructions.begin();
step.type = goto_trace_stept::typet::ATOMIC_BEGIN;
step.output(ns, std::cout);
}
| 29.296296 | 69 | 0.633375 | jeannielynnmoulton |