blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f4ee2d60ba0e70a3fc9605c5f6bf9e4ea67ceb2c | 4a0c25841c0e8bfa85710371a3c3f3d4fcda7ee6 | /Classes/CharacterListPage.cpp | 742cbd5575d3982abc00a4e52840c69367bfe977 | [] | no_license | ljl884/KanColle | 7735b830cceae7beea57dae6fe46e9cb05e2ef39 | 4211b9b703f4c68838e8c38417fe65d255d9db5a | refs/heads/master | 2016-09-15T16:40:05.574596 | 2015-06-13T10:35:45 | 2015-06-13T10:35:45 | 31,156,933 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,336 | cpp | #include "CharacterListPage.h"
#include "Helper.h"
#include "PortOrganizeLayer.h"
#define SHIPS_PER_PAGE 10
#define FONT_COLOR Color3B::BLACK
CharacterListPage::CharacterListPage(PortOrganizeLayer* parent)
{
this->parent = parent;
Hidden = true;
menu = Menu::create(NULL);
auto bgimg = Sprite::create("OrganizeMain/image 176.png");
this->addChild(bgimg);
bgimg->setPosition(654, 195);
auto titleBar = Sprite::create("OrganizeMain/image 177.png");
this->addChild(titleBar);
titleBar->setPosition(753, 397);
auto top_label = Sprite::create("OrganizeMain/image 178.png");
this->addChild(top_label);
top_label->setPosition(398, 399);
auto category = Sprite::create("OrganizeMain/image 179.png");
this->addChild(category);
category->setPosition(595, 370);
sortButton = Sprite::create("OrganizeMain/image 189.png");
auto sortMenuItem = MenuItemSprite::create(sortButton, sortButton, CC_CALLBACK_1(CharacterListPage::sortButtonCallback, this));
sortMenuItem->setPosition(773, 370);
menu->addChild(sortMenuItem);
//list
list = Node::create();
this->addChild(list);
listMenu = Menu::create(NULL);
listMenu->setPosition(Point::ZERO);
this->addChild(listMenu);
firstRow = makeRow(nullptr);
firstRow->setPosition(540, 345);
this->addChild(firstRow);
for (int i = 0; i < SHIPS_PER_PAGE; i++)
{
auto node = Node::create();
rows.push_back(node);
auto item = Sprite::create("OrganizeMain/image 182.png");
item->setOpacity(0);
auto menuitem = MenuItemSprite::create(item, Sprite::create("OrganizeMain/image 182.png"), item, CC_CALLBACK_1(CharacterListPage::exchangeCallback, this, i));
menuitem->setPosition(550, 347 - (i + 1) * 28);
menuitem->setScaleY(0.85);
listMenu->addChild(menuitem);
}
currentPage = 0;
updateList(currentPage);
//bottom button
auto firstPage = MenuItemImage::create("commonAssets/image 196.png", "commonAssets/image 196.png");
firstPage->setPosition(430,33);
auto previousPage = MenuItemImage::create("commonAssets/image 190.png", "commonAssets/image 190.png");
previousPage->setPosition(465, 33);
auto nextPage = MenuItemImage::create("commonAssets/image 187.png", "commonAssets/image 187.png");
nextPage->setPosition(685, 33);
auto lastPage = MenuItemImage::create("commonAssets/image 193.png", "commonAssets/image 193.png");
lastPage->setPosition(720, 33);
auto Page1 = MenuItemLabel::create(Label::create("1", "fonts/DengXian.ttf", 16),CC_CALLBACK_1(CharacterListPage::setPageCallback,this,0));
Page1->setPosition(502, 33);
Page1->setColor(Color3B(0,127,255));
auto Page2 = MenuItemLabel::create(Label::create("2", "fonts/DengXian.ttf", 16), CC_CALLBACK_1(CharacterListPage::setPageCallback, this, 1));
Page2->setPosition(539, 33);
Page2->setColor(FONT_COLOR);
auto Page3 = MenuItemLabel::create(Label::create("3", "fonts/DengXian.ttf", 16));
Page3->setPosition(576, 33);
Page3->setColor(FONT_COLOR);
auto Page4 = MenuItemLabel::create(Label::create("4", "fonts/DengXian.ttf", 16));
Page4->setPosition(613, 33);
Page4->setColor(FONT_COLOR);
auto Page5 = MenuItemLabel::create(Label::create("5", "fonts/DengXian.ttf", 16));
Page5->setPosition(650, 33);
Page5->setColor(FONT_COLOR);
menu->addChild(firstPage);
menu->addChild(previousPage);
menu->addChild(nextPage);
menu->addChild(lastPage);
menu->addChild(Page1);
menu->addChild(Page2);
menu->addChild(Page3);
menu->addChild(Page4);
menu->addChild(Page5);
this->addChild(menu);
menu->setPosition(Point::ZERO);
}
void CharacterListPage::updateList(int page)
{
auto gameModel = GameModel::getInstance();
std::vector<CharacterInfo*> ships = gameModel->getAllShips();
//sortByCategory(ships);
displayingCharacters.clear();
list->removeAllChildren();
for (int i = 0; i < SHIPS_PER_PAGE; i++)
{
if ((SHIPS_PER_PAGE*page + i) == ships.size() )
return;
auto row = makeRow(ships[SHIPS_PER_PAGE*page + i]);
displayingCharacters.push_back(ships[SHIPS_PER_PAGE*page + i]);
rows[i] = row;
list->addChild(row);
row->setPosition(540, 345 - (i + 1) * 28);
}
}
Node* CharacterListPage::makeRow(CharacterInfo* info)
{
auto node = Node::create();
Color3B fcolor = FONT_COLOR;
auto line = Sprite::create("commonAssets/Line.png");
node->addChild(line);
line->setPosition(35, -12);
if (info == nullptr)
{
auto firstRow = Label::create(Helper::getString("remove"), "fonts/DengXian.ttf", 13);
firstRow->setPosition(-135,0);
firstRow->setColor(fcolor);
firstRow->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT);
node->addChild(firstRow);
return node;
}
auto fleet = Sprite::create();
node->addChild(fleet);
fleet->setPosition(-160,0);
if (info->currentFleet == 0)
fleet->setTexture("commonAssets/image 70.png");
else if (info->currentFleet == 1)
fleet->setTexture("commonAssets/image 79.png");
else if (info->currentFleet == 2)
fleet->setTexture("commonAssets/image 91.png");
else if (info->currentFleet == 3)
fleet->setTexture("commonAssets/image 98.png");
std::string type = Helper::getShipType(info->type);
auto name = Label::create(type+" "+info->nameCH, "fonts/DengXian.ttf", 13);
name->setAlignment(TextHAlignment::LEFT);
name->setPosition(-135, 0);
name->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT);
name->setColor(fcolor);
auto level = Label::create(Helper::int2str(info->level), "fonts/DengXian.ttf", 13);
level->setPosition(32, 0);
level->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
level->setColor(fcolor);
auto maxHP = Label::create(Helper::int2str(info->maxHP), "fonts/DengXian.ttf", 13);
maxHP->setPosition(70, 0);
maxHP->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
maxHP->setColor(fcolor);
auto firePower = Label::create(Helper::int2str(info->firePower), "fonts/DengXian.ttf", 13);
firePower->setPosition(105, 0);
firePower->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
firePower->setColor(fcolor);
auto torpedo = Label::create(Helper::int2str(info->torpedo), "fonts/DengXian.ttf", 13);
torpedo->setPosition(135, 0);
torpedo->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
torpedo->setColor(fcolor);
auto antiaircraft = Label::create(Helper::int2str(info->antiaircraft), "fonts/DengXian.ttf", 13);
antiaircraft->setPosition(165, 0);
antiaircraft->setAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
antiaircraft->setColor(fcolor);
auto speed = Sprite::create();
speed->setPosition(189, 2);
if (info->speed == high)
speed->setTexture("commonAssets/image 283.png");
else
speed->setTexture("commonAssets/image 281.png");
node->addChild(name);
node->addChild(level);
node->addChild(maxHP);
node->addChild(firePower);
node->addChild(torpedo);
node->addChild(antiaircraft);
node->addChild(speed);
return node;
}
void CharacterListPage::moveOut()
{
if (!Hidden)
{
this->runAction(MoveBy::create(0.2, ccp(800, 0)));
Hidden = true;
}
}
void CharacterListPage::moveIn()
{
if (Hidden)
{
this->runAction(MoveBy::create(0.2, ccp(-800, 0)));
Hidden = false;
}
}
void CharacterListPage::sortButtonCallback(Ref* pSender)
{
}
void CharacterListPage::exchangeCallback(Ref* pSender, int indexInList)
{
GameModel::getInstance()->getFleet(0)->switchShip(displayingCharacters[indexInList], parent->getSelectedShipIndex());
this->updateList(currentPage);
this->moveOut();
parent->updateContainers();
}
void CharacterListPage::setPageCallback(Ref* PSendr, int page)
{
this->updateList(page);
} | [
"wentaol@student.unimelb.edu.au"
] | wentaol@student.unimelb.edu.au |
dc4331d6528222efa4aef59a83142cbcd8f58508 | b1cc102f2c360707dce70e068f50f93e1ad8fb4c | /csSpreadControl.ino | c135da4840fbdf32f8f0320a965ce9c889d8985b | [
"MIT"
] | permissive | petruspierre/csSpreadControl | 6f8d27adc64991a6466baa35f17489f076013c51 | daebd46ed4c3fa773f0a1c6952d8a6a16f146545 | refs/heads/master | 2022-04-22T21:34:37.200108 | 2020-04-21T23:05:08 | 2020-04-21T23:05:08 | 257,680,229 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,106 | ino | #define pinBtn 13
int count = 0;
void setup() {
Serial.begin(9600);
pinMode(pinBtn, INPUT_PULLUP);
}
void loop() {
int _isPressed = digitalRead(pinBtn);
Serial.println(_isPressed);
if(_isPressed){
count++;
mouse(count);
delay(95);
} else {
if(count > 0){
Serial.println("release");
count=0;
}
}
delay(10);
}
void mouse(int n){
switch(n){
case 1:
Serial.println("press");
break;
case 2:
Serial.println("-2,19");
break;
case 3:
Serial.println("1,27");
break;
case 4:
Serial.println("2,27");
break;
case 5:
Serial.println("4,26");
break;
case 6:
Serial.println("5,27");
break;
case 7:
Serial.println("5,27");
break;
case 8:
Serial.println("2,29");
break;
case 9:
Serial.println("-10,29");
break;
case 10:
Serial.println("-20,10");
break;
case 11:
Serial.println("-15,3");
break;
case 12:
Serial.println("-10,4");
break;
case 13:
Serial.println("-6,2");
break;
case 14:
Serial.println("4,2");
break;
case 15:
Serial.println("14,3");
break;
case 16:
Serial.println("20,3");
break;
case 17:
Serial.println("20,3");
break;
case 18:
Serial.println("19,2");
break;
case 19:
Serial.println("12,-2");
break;
case 20:
Serial.println("2,-2");
break;
case 21:
Serial.println("-2,2");
break;
case 22:
Serial.println("-2,4");
break;
case 23:
Serial.println("3,2");
break;
case 24:
Serial.println("3,2");
break;
case 25:
Serial.println("-3,0");
break;
case 26:
Serial.println("-15,-2");
break;
case 27:
Serial.println("-44,-5");
break;
case 28:
Serial.println("-28,-7");
break;
case 29:
Serial.println("-29,-8");
break;
case 30:
count=0;
Serial.println("release");
break;
}
}
| [
"petrus.pierre@academico.ifpb.edu.br"
] | petrus.pierre@academico.ifpb.edu.br |
afac4958cd0d545b66be72527583a601fd4b9cef | 7a91985397ce12d98e8e9be79b2ba9053e4089a0 | /6.26/main.cpp | 53ac99d572652bec46a3f61304452fc16c6d8e1f | [] | no_license | fuzhong123/ma_fuzhong | 7ec7ed1b49b649564a952d730af1ca6cd5bde7c8 | bbe93dd4e159d0fea61ad7c1fd5a62243be2c864 | refs/heads/master | 2020-04-03T10:40:59.518494 | 2019-05-26T09:13:36 | 2019-05-26T09:13:36 | 155,199,581 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 773 | cpp | #include<iostream>
using namespace std;
//华氏温度 = 摄氏温度 * 9.0 / 5.0 + 32
int main()
{
const unsigned short A = 32;
const double R = 9.0 /5.0;
double tempIn, tempOut;
char typeIn, typeOut;
cout<<"请以【xx.x C】或者【xx.x F】这样的格式输入一个温度:\n\n";
cin >> tempIn >> typeIn;
cin.ignore(100,'\n');
cout << "\n";
switch( typeIn )
{
case 'C':tempOut = tempIn * R +A;typeOut = 'F'; typeIn='C';
break;
case 'F':tempOut= (tempIn -A) / R ;typeOut ='C'; typeIn= 'F';
break;
default:
typeOut = 'E';
break;
}
if(typeOut !='E')
{
cout<< tempIn << typeIn<<"="<<tempOut<<typeOut<<"\n\n";
}
else
{
cout << "输入错误!" << "\n\n";
}
cout << "请输入任何字符结束程序!\n\n";
cin.get();
return 0;
}
| [
"863242240@qq.com"
] | 863242240@qq.com |
a52e5a4afe9fac9c89be7707abf2e9363c0f8b2a | 4f4e784edad7b5604737fcf4ca33c3b61943b30c | /atcoder/abc/130b.cpp | 7ffb7517636cb74a3bd3f8ee9c0fb59f87540790 | [] | no_license | yakan15/procon | 4197d834576de28ef41e113188013e281dc0aefc | 69272a99d0398d8d5b6efe5b2c10138a8b36ce87 | refs/heads/master | 2021-08-19T22:46:56.223803 | 2020-06-01T16:36:49 | 2020-06-01T16:36:49 | 189,934,967 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 468 | cpp | #include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(void) {
int n,x;
cin >> n >> x;
vector<int> l;
int ball=0;
int res=1;
rep(i,n){
int tmp;
cin >> tmp;
ball += tmp;
if(ball<=x)res++;
}
cout << res << endl;
return 0;
}
| [
"h.m_92e3i1@hotmail.com"
] | h.m_92e3i1@hotmail.com |
329919d13792e146de2319c2df333a135ccf5619 | d217da69dc1df15cb1f3df58a5920d9417073d5c | /4_5_2018_tekma2/pcl_demos/src/cylinder_segmentation.cpp | 86cd49c667922cb2533dc5931631169452f91950 | [] | no_license | Zanz2/RiS_team_gamma | fcf9f3cad92972ce1300f06af460f1b6edb5a8e4 | 77fc86a7012e8ba51661687ae000597b361c4bfe | refs/heads/master | 2021-01-25T13:17:24.028469 | 2018-06-13T10:14:36 | 2018-06-13T10:14:36 | 123,545,872 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,677 | cpp | #include <iostream>
#include <ros/ros.h>
#include <math.h>
#include <visualization_msgs/Marker.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/filters/passthrough.h>
#include <pcl/features/normal_3d.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include "pcl/point_cloud.h"
#include "tf2_ros/transform_listener.h"
#include "tf2_geometry_msgs/tf2_geometry_msgs.h"
#include "geometry_msgs/PointStamped.h"
#include <cmath>
ros::Publisher pubx;
ros::Publisher puby;
ros::Publisher pubm;
tf2_ros::Buffer tf2_buffer;
typedef pcl::PointXYZ PointT;
void
cloud_cb (const pcl::PCLPointCloud2ConstPtr& cloud_blob)
{
// All the objects needed
ros::Time time_rec, time_test;
time_rec = ros::Time::now();
pcl::PassThrough<PointT> pass;
pcl::NormalEstimation<PointT, pcl::Normal> ne;
pcl::SACSegmentationFromNormals<PointT, pcl::Normal> seg;
pcl::PCDWriter writer;
pcl::ExtractIndices<PointT> extract;
pcl::ExtractIndices<pcl::Normal> extract_normals;
pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT> ());
Eigen::Vector4f centroid;
// Datasets
pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>);
pcl::PointCloud<PointT>::Ptr cloud_filtered (new pcl::PointCloud<PointT>);
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
pcl::PointCloud<PointT>::Ptr cloud_filtered2 (new pcl::PointCloud<PointT>);
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals2 (new pcl::PointCloud<pcl::Normal>);
pcl::ModelCoefficients::Ptr coefficients_plane (new pcl::ModelCoefficients), coefficients_cylinder (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers_plane (new pcl::PointIndices), inliers_cylinder (new pcl::PointIndices);
// Read in the cloud data
pcl::fromPCLPointCloud2 (*cloud_blob, *cloud);
std::cerr << "PointCloud has: " << cloud->points.size () << " data points." << std::endl;
// Build a passthrough filter to remove spurious NaNs
pass.setInputCloud (cloud);
pass.setFilterFieldName ("z");
pass.setFilterLimits (0, 1.5);
pass.filter (*cloud_filtered);
std::cerr << "PointCloud after filtering has: " << cloud_filtered->points.size () << " data points." << std::endl;
// Estimate point normals
ne.setSearchMethod (tree);
ne.setInputCloud (cloud_filtered);
ne.setKSearch (50);
ne.compute (*cloud_normals);
// Create the segmentation object for the planar model and set all the parameters
seg.setOptimizeCoefficients (true);
seg.setModelType (pcl::SACMODEL_NORMAL_PLANE);
seg.setNormalDistanceWeight (0.1);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations (100);
seg.setDistanceThreshold (0.03);
seg.setInputCloud (cloud_filtered);
seg.setInputNormals (cloud_normals);
// Obtain the plane inliers and coefficients
seg.segment (*inliers_plane, *coefficients_plane);
std::cerr << "Plane coefficients: " << *coefficients_plane << std::endl;
// Extract the planar inliers from the input cloud
extract.setInputCloud (cloud_filtered);
extract.setIndices (inliers_plane);
extract.setNegative (false);
// Write the planar inliers to disk
pcl::PointCloud<PointT>::Ptr cloud_plane (new pcl::PointCloud<PointT> ());
extract.filter (*cloud_plane);
std::cerr << "PointCloud representing the planar component: " << cloud_plane->points.size () << " data points." << std::endl;
pcl::PCLPointCloud2 outcloud_plane;
pcl::toPCLPointCloud2 (*cloud_plane, outcloud_plane);
pubx.publish (outcloud_plane);
// Remove the planar inliers, extract the rest
extract.setNegative (true);
extract.filter (*cloud_filtered2);
extract_normals.setNegative (true);
extract_normals.setInputCloud (cloud_normals);
extract_normals.setIndices (inliers_plane);
extract_normals.filter (*cloud_normals2);
// Create the segmentation object for cylinder segmentation and set all the parameters
seg.setOptimizeCoefficients (true);
seg.setModelType (pcl::SACMODEL_CYLINDER);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setNormalDistanceWeight (0.1);
seg.setMaxIterations (10000);
seg.setDistanceThreshold (0.05);
seg.setRadiusLimits (0.06, 0.2);
seg.setInputCloud (cloud_filtered2);
seg.setInputNormals (cloud_normals2);
// Obtain the cylinder inliers and coefficients
seg.segment (*inliers_cylinder, *coefficients_cylinder);
std::cerr << "Cylinder coefficients: " << *coefficients_cylinder << std::endl;
// Write the cylinder inliers to disk
extract.setInputCloud (cloud_filtered2);
extract.setIndices (inliers_cylinder);
extract.setNegative (false);
pcl::PointCloud<PointT>::Ptr cloud_cylinder (new pcl::PointCloud<PointT> ());
extract.filter (*cloud_cylinder);
if (cloud_cylinder->points.empty ())
{
std::cerr << "Can't find the cylindrical component." << std::endl;
ros::shutdown();
}
else
{
std::cerr << "PointCloud representing the cylindrical component: " << cloud_cylinder->points.size () << " data points." << std::endl;
pcl::compute3DCentroid (*cloud_cylinder, centroid);
std::cerr << "centroid of the cylindrical component: " << centroid[0] << " " << centroid[1] << " " << centroid[2] << " " << centroid[3] << std::endl;
//Create a point in the "camera_rgb_optical_frame"
geometry_msgs::PointStamped point_camera;
geometry_msgs::PointStamped point_map;
visualization_msgs::Marker marker;
geometry_msgs::TransformStamped tss;
point_camera.header.frame_id = "camera_rgb_optical_frame";
point_camera.header.stamp = ros::Time::now();
point_map.header.frame_id = "map";
point_map.header.stamp = ros::Time::now();
point_camera.point.x = centroid[0];
point_camera.point.y = centroid[1];
point_camera.point.z = centroid[2];
try{
time_test = ros::Time::now();
std::cerr << time_rec << std::endl;
std::cerr << time_test << std::endl;
tss = tf2_buffer.lookupTransform("map","camera_rgb_optical_frame", time_rec);
// tf2_buffer.transform(point_camera, point_map, "map", ros::Duration(2));
}
catch (tf2::TransformException &ex)
{
ROS_WARN("Transform warning: %s\n", ex.what());
}
std::cerr << tss ;
tf2::doTransform(point_camera, point_map, tss);
if(std::isnan(point_map.point.x))
return;
std::cerr << "point_camera: " << point_camera.point.x << " " << point_camera.point.y << " " << point_camera.point.z << std::endl;
std::cerr << "point_map: " << point_map.point.x << " " << point_map.point.y << " " << point_map.point.z << std::endl;
marker.header.frame_id = "map";
marker.header.stamp = ros::Time::now();
marker.ns = "cylinder";
marker.id = 0;
marker.type = visualization_msgs::Marker::CYLINDER;
marker.action = visualization_msgs::Marker::ADD;
marker.pose.position.x = point_map.point.x;
marker.pose.position.y = point_map.point.y;
marker.pose.position.z = point_map.point.z;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
marker.scale.x = 0.1;
marker.scale.y = 0.1;
marker.scale.z = 0.1;
marker.color.r=0.0f;
marker.color.g=1.0f;
marker.color.b=0.0f;
marker.color.a=1.0f;
marker.lifetime = ros::Duration();
pubm.publish (marker);
pcl::PCLPointCloud2 outcloud_cylinder;
pcl::toPCLPointCloud2 (*cloud_cylinder, outcloud_cylinder);
puby.publish (outcloud_cylinder);
system("python /home/team_gamma/ROS/src/exercise3/src/cylinder_found.py");
ros::shutdown();
}
}
int
main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "cylinder_segment");
ros::NodeHandle nh;
// For transforming between coordinate frames
tf2_ros::TransformListener tf2_listener(tf2_buffer);
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pubx = nh.advertise<pcl::PCLPointCloud2> ("planes", 1);
puby = nh.advertise<pcl::PCLPointCloud2> ("cylinder", 1);
pubm = nh.advertise<visualization_msgs::Marker>("detected_cylinder",1);
// Spin
ros::spin();
}
| [
"zan.zagar@hotmail.com"
] | zan.zagar@hotmail.com |
8318c6beeb334675e152e2d74a74a6d18bb11182 | e2f71ee757e2ca32e762c2696893be6b6f7c76c3 | /TD2-Banque/Banque - Qt/build-BanqueQt-Desktop_Qt_5_11_1_GCC_64bit-Debug/ui_banque.h | 3e9b81935e7284e364ac83979055a7126dd2958e | [] | no_license | EzraGagnard/SNIR1-CPP | 1077cdecaeb8d88effb53eb41246f209a9985ff7 | 30620e08b4ee415f23bc421e42d275163f61fee4 | refs/heads/master | 2020-05-23T23:04:37.492730 | 2019-05-17T12:17:22 | 2019-05-17T12:17:22 | 186,986,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,289 | h | /********************************************************************************
** Form generated from reading UI file 'banque.ui'
**
** Created by: Qt User Interface Compiler version 5.11.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_BANQUE_H
#define UI_BANQUE_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Banque
{
public:
QWidget *verticalLayoutWidget;
QVBoxLayout *verticalLayout;
QLabel *label;
QLineEdit *lineEditMontant;
QPushButton *pushButtonDeposer;
QPushButton *pushButtonRetirer;
QWidget *horizontalLayoutWidget;
QHBoxLayout *horizontalLayout;
QLabel *label_2;
QLineEdit *lineEditSolde;
QWidget *verticalLayoutWidget_2;
QVBoxLayout *verticalLayout_2;
QLabel *label_3;
QListWidget *listWidgetHistorique;
QPushButton *pushButtonQuitter;
QWidget *verticalLayoutWidget_3;
QVBoxLayout *verticalLayout_3;
QLabel *label_4;
QSpinBox *spinBoxDecouvert;
QPushButton *pushButtonChangerDecouvert;
QWidget *horizontalLayoutWidget_2;
QHBoxLayout *horizontalLayout_2;
QLabel *label_5;
QLineEdit *lineEditSoldeEpargne;
QWidget *verticalLayoutWidget_4;
QVBoxLayout *verticalLayout_4;
QLabel *label_6;
QLineEdit *lineEditMontantEpargne;
QPushButton *pushButtonDeposerEpargne;
QPushButton *pushButtonRetirerEpargne;
QWidget *verticalLayoutWidget_5;
QVBoxLayout *verticalLayout_5;
QLabel *label_7;
QDoubleSpinBox *doubleSpinBoxTaux;
QPushButton *pushButtonNvTaux;
QPushButton *pushButtonCrediterInteret;
void setupUi(QWidget *Banque)
{
if (Banque->objectName().isEmpty())
Banque->setObjectName(QStringLiteral("Banque"));
Banque->setEnabled(true);
Banque->setMinimumSize(QSize(0, 0));
Banque->setMaximumSize(QSize(16777215, 16777215));
Banque->setCursor(QCursor(Qt::ArrowCursor));
Banque->setLayoutDirection(Qt::LeftToRight);
Banque->setAutoFillBackground(false);
verticalLayoutWidget = new QWidget(Banque);
verticalLayoutWidget->setObjectName(QStringLiteral("verticalLayoutWidget"));
verticalLayoutWidget->setGeometry(QRect(20, 80, 131, 112));
verticalLayout = new QVBoxLayout(verticalLayoutWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
label = new QLabel(verticalLayoutWidget);
label->setObjectName(QStringLiteral("label"));
verticalLayout->addWidget(label);
lineEditMontant = new QLineEdit(verticalLayoutWidget);
lineEditMontant->setObjectName(QStringLiteral("lineEditMontant"));
verticalLayout->addWidget(lineEditMontant);
pushButtonDeposer = new QPushButton(verticalLayoutWidget);
pushButtonDeposer->setObjectName(QStringLiteral("pushButtonDeposer"));
verticalLayout->addWidget(pushButtonDeposer);
pushButtonRetirer = new QPushButton(verticalLayoutWidget);
pushButtonRetirer->setObjectName(QStringLiteral("pushButtonRetirer"));
verticalLayout->addWidget(pushButtonRetirer);
horizontalLayoutWidget = new QWidget(Banque);
horizontalLayoutWidget->setObjectName(QStringLiteral("horizontalLayoutWidget"));
horizontalLayoutWidget->setGeometry(QRect(20, 10, 251, 51));
horizontalLayout = new QHBoxLayout(horizontalLayoutWidget);
horizontalLayout->setSpacing(6);
horizontalLayout->setContentsMargins(11, 11, 11, 11);
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
horizontalLayout->setContentsMargins(0, 0, 0, 0);
label_2 = new QLabel(horizontalLayoutWidget);
label_2->setObjectName(QStringLiteral("label_2"));
horizontalLayout->addWidget(label_2);
lineEditSolde = new QLineEdit(horizontalLayoutWidget);
lineEditSolde->setObjectName(QStringLiteral("lineEditSolde"));
horizontalLayout->addWidget(lineEditSolde);
verticalLayoutWidget_2 = new QWidget(Banque);
verticalLayoutWidget_2->setObjectName(QStringLiteral("verticalLayoutWidget_2"));
verticalLayoutWidget_2->setGeometry(QRect(160, 80, 231, 191));
verticalLayout_2 = new QVBoxLayout(verticalLayoutWidget_2);
verticalLayout_2->setSpacing(6);
verticalLayout_2->setContentsMargins(11, 11, 11, 11);
verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
verticalLayout_2->setContentsMargins(0, 0, 0, 0);
label_3 = new QLabel(verticalLayoutWidget_2);
label_3->setObjectName(QStringLiteral("label_3"));
verticalLayout_2->addWidget(label_3);
listWidgetHistorique = new QListWidget(verticalLayoutWidget_2);
listWidgetHistorique->setObjectName(QStringLiteral("listWidgetHistorique"));
verticalLayout_2->addWidget(listWidgetHistorique);
pushButtonQuitter = new QPushButton(Banque);
pushButtonQuitter->setObjectName(QStringLiteral("pushButtonQuitter"));
pushButtonQuitter->setGeometry(QRect(210, 280, 131, 25));
verticalLayoutWidget_3 = new QWidget(Banque);
verticalLayoutWidget_3->setObjectName(QStringLiteral("verticalLayoutWidget_3"));
verticalLayoutWidget_3->setGeometry(QRect(20, 200, 131, 82));
verticalLayout_3 = new QVBoxLayout(verticalLayoutWidget_3);
verticalLayout_3->setSpacing(6);
verticalLayout_3->setContentsMargins(11, 11, 11, 11);
verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3"));
verticalLayout_3->setContentsMargins(0, 0, 0, 0);
label_4 = new QLabel(verticalLayoutWidget_3);
label_4->setObjectName(QStringLiteral("label_4"));
verticalLayout_3->addWidget(label_4);
spinBoxDecouvert = new QSpinBox(verticalLayoutWidget_3);
spinBoxDecouvert->setObjectName(QStringLiteral("spinBoxDecouvert"));
verticalLayout_3->addWidget(spinBoxDecouvert);
pushButtonChangerDecouvert = new QPushButton(verticalLayoutWidget_3);
pushButtonChangerDecouvert->setObjectName(QStringLiteral("pushButtonChangerDecouvert"));
verticalLayout_3->addWidget(pushButtonChangerDecouvert);
horizontalLayoutWidget_2 = new QWidget(Banque);
horizontalLayoutWidget_2->setObjectName(QStringLiteral("horizontalLayoutWidget_2"));
horizontalLayoutWidget_2->setGeometry(QRect(290, 10, 231, 51));
horizontalLayout_2 = new QHBoxLayout(horizontalLayoutWidget_2);
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setContentsMargins(11, 11, 11, 11);
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
horizontalLayout_2->setContentsMargins(0, 0, 0, 0);
label_5 = new QLabel(horizontalLayoutWidget_2);
label_5->setObjectName(QStringLiteral("label_5"));
horizontalLayout_2->addWidget(label_5);
lineEditSoldeEpargne = new QLineEdit(horizontalLayoutWidget_2);
lineEditSoldeEpargne->setObjectName(QStringLiteral("lineEditSoldeEpargne"));
horizontalLayout_2->addWidget(lineEditSoldeEpargne);
verticalLayoutWidget_4 = new QWidget(Banque);
verticalLayoutWidget_4->setObjectName(QStringLiteral("verticalLayoutWidget_4"));
verticalLayoutWidget_4->setGeometry(QRect(400, 80, 141, 112));
verticalLayout_4 = new QVBoxLayout(verticalLayoutWidget_4);
verticalLayout_4->setSpacing(6);
verticalLayout_4->setContentsMargins(11, 11, 11, 11);
verticalLayout_4->setObjectName(QStringLiteral("verticalLayout_4"));
verticalLayout_4->setContentsMargins(0, 0, 0, 0);
label_6 = new QLabel(verticalLayoutWidget_4);
label_6->setObjectName(QStringLiteral("label_6"));
verticalLayout_4->addWidget(label_6);
lineEditMontantEpargne = new QLineEdit(verticalLayoutWidget_4);
lineEditMontantEpargne->setObjectName(QStringLiteral("lineEditMontantEpargne"));
verticalLayout_4->addWidget(lineEditMontantEpargne);
pushButtonDeposerEpargne = new QPushButton(verticalLayoutWidget_4);
pushButtonDeposerEpargne->setObjectName(QStringLiteral("pushButtonDeposerEpargne"));
verticalLayout_4->addWidget(pushButtonDeposerEpargne);
pushButtonRetirerEpargne = new QPushButton(verticalLayoutWidget_4);
pushButtonRetirerEpargne->setObjectName(QStringLiteral("pushButtonRetirerEpargne"));
verticalLayout_4->addWidget(pushButtonRetirerEpargne);
verticalLayoutWidget_5 = new QWidget(Banque);
verticalLayoutWidget_5->setObjectName(QStringLiteral("verticalLayoutWidget_5"));
verticalLayoutWidget_5->setGeometry(QRect(400, 200, 146, 113));
verticalLayout_5 = new QVBoxLayout(verticalLayoutWidget_5);
verticalLayout_5->setSpacing(6);
verticalLayout_5->setContentsMargins(11, 11, 11, 11);
verticalLayout_5->setObjectName(QStringLiteral("verticalLayout_5"));
verticalLayout_5->setContentsMargins(0, 0, 0, 0);
label_7 = new QLabel(verticalLayoutWidget_5);
label_7->setObjectName(QStringLiteral("label_7"));
verticalLayout_5->addWidget(label_7);
doubleSpinBoxTaux = new QDoubleSpinBox(verticalLayoutWidget_5);
doubleSpinBoxTaux->setObjectName(QStringLiteral("doubleSpinBoxTaux"));
verticalLayout_5->addWidget(doubleSpinBoxTaux);
pushButtonNvTaux = new QPushButton(verticalLayoutWidget_5);
pushButtonNvTaux->setObjectName(QStringLiteral("pushButtonNvTaux"));
verticalLayout_5->addWidget(pushButtonNvTaux);
pushButtonCrediterInteret = new QPushButton(verticalLayoutWidget_5);
pushButtonCrediterInteret->setObjectName(QStringLiteral("pushButtonCrediterInteret"));
verticalLayout_5->addWidget(pushButtonCrediterInteret);
retranslateUi(Banque);
QObject::connect(pushButtonQuitter, SIGNAL(clicked()), Banque, SLOT(close()));
QMetaObject::connectSlotsByName(Banque);
} // setupUi
void retranslateUi(QWidget *Banque)
{
Banque->setWindowTitle(QApplication::translate("Banque", "Banque", nullptr));
label->setText(QApplication::translate("Banque", "Montant:", nullptr));
pushButtonDeposer->setText(QApplication::translate("Banque", "Deposer", nullptr));
pushButtonRetirer->setText(QApplication::translate("Banque", "Retirer", nullptr));
label_2->setText(QApplication::translate("Banque", "Compte Courant:", nullptr));
label_3->setText(QApplication::translate("Banque", "Historique:", nullptr));
pushButtonQuitter->setText(QApplication::translate("Banque", "Quitter", nullptr));
label_4->setText(QApplication::translate("Banque", "Changer le d\303\251couvert:", nullptr));
pushButtonChangerDecouvert->setText(QApplication::translate("Banque", "Changer", nullptr));
label_5->setText(QApplication::translate("Banque", "Compte Epargne:", nullptr));
label_6->setText(QApplication::translate("Banque", "Montant Epargne:", nullptr));
pushButtonDeposerEpargne->setText(QApplication::translate("Banque", "Deposer", nullptr));
pushButtonRetirerEpargne->setText(QApplication::translate("Banque", "Retirer", nullptr));
label_7->setText(QApplication::translate("Banque", "Changer le taux d'interet:", nullptr));
pushButtonNvTaux->setText(QApplication::translate("Banque", "Nouveau taux d'int\303\251rets", nullptr));
pushButtonCrediterInteret->setText(QApplication::translate("Banque", "Crediter interets", nullptr));
} // retranslateUi
};
namespace Ui {
class Banque: public Ui_Banque {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_BANQUE_H
| [
"gmgagnard@gmail.com"
] | gmgagnard@gmail.com |
afd995a8202505b7cf0e04c93fd0e3176e1c08a1 | a56252fda5c9e42eff04792c6e16e413ad51ba1a | /resources/home/dnanexus/root/include/TRefTable.h | 947bec6db8f46b7a314b882dac73ff2d8a43da49 | [
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"Apache-2.0"
] | permissive | edawson/parliament2 | 4231e692565dbecf99d09148e75c00750e6797c4 | 2632aa3484ef64c9539c4885026b705b737f6d1e | refs/heads/master | 2021-06-21T23:13:29.482239 | 2020-12-07T21:10:08 | 2020-12-07T21:10:08 | 150,246,745 | 0 | 0 | Apache-2.0 | 2019-09-11T03:22:55 | 2018-09-25T10:21:03 | Python | UTF-8 | C++ | false | false | 4,399 | h | // @(#)root/cont:$Id$
// Author: Rene Brun 17/08/2004
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TRefTable
#define ROOT_TRefTable
//////////////////////////////////////////////////////////////////////////
// //
// TRefTable //
// //
// A TRefTable maintains the association between a referenced object //
// and the parent object supporting this referenced object. //
// The parent object is typically a branch of a TTree. //
// //
//////////////////////////////////////////////////////////////////////////
#include "TObject.h"
#include <string>
#include <vector>
class TObjArray;
class TProcessID;
class TRefTable : public TObject {
protected:
Int_t fNumPIDs; //!number of known ProcessIDs
Int_t *fAllocSize; //![fNumPIDs] allocated size of array fParentIDs for each ProcessID
Int_t *fN; //![fNumPIDs] current maximum number of IDs in array fParentIDs for each ProcessID
Int_t **fParentIDs; //![fNumPIDs][fAllocSize] array of Parent IDs
Int_t fParentID; //!current parent ID in fParents (latest call to SetParent)
Int_t fDefaultSize;//!default size for a new PID array
UInt_t fUID; //!Current uid (set by TRef::GetObject)
TProcessID *fUIDContext; //!TProcessID the current uid is referring to
Int_t fSize; //dummy for backward compatibility
TObjArray *fParents; //array of Parent objects (eg TTree branch) holding the referenced objects
TObject *fOwner; //Object owning this TRefTable
std::vector<std::string> fProcessGUIDs; // UUIDs of TProcessIDs used in fParentIDs
std::vector<Int_t> fMapPIDtoInternal; //! cache of pid to index in fProcessGUIDs
static TRefTable *fgRefTable; //Pointer to current TRefTable
Int_t AddInternalIdxForPID(TProcessID* procid);
virtual Int_t ExpandForIID(Int_t iid, Int_t newsize);
void ExpandPIDs(Int_t numpids);
Int_t FindPIDGUID(const char* guid) const;
Int_t GetInternalIdxForPID(TProcessID* procid) const;
Int_t GetInternalIdxForPID(Int_t pid) const;
public:
enum EStatusBits {
kHaveWarnedReadingOld = BIT(14)
};
TRefTable();
TRefTable(TObject *owner, Int_t size);
virtual ~TRefTable();
virtual Int_t Add(Int_t uid, TProcessID* context = 0);
virtual void Clear(Option_t * /*option*/ ="");
virtual Int_t Expand(Int_t pid, Int_t newsize);
virtual void FillBuffer(TBuffer &b);
static TRefTable *GetRefTable();
Int_t GetNumPIDs() const {return fNumPIDs;}
Int_t GetSize(Int_t pid) const {return fAllocSize[GetInternalIdxForPID(pid)];}
Int_t GetN(Int_t pid) const {return fN[GetInternalIdxForPID(pid)];}
TObject *GetOwner() const {return fOwner;}
TObject *GetParent(Int_t uid, TProcessID* context = 0) const;
TObjArray *GetParents() const {return fParents;}
UInt_t GetUID() const {return fUID;}
TProcessID *GetUIDContext() const {return fUIDContext;}
virtual Bool_t Notify();
virtual void ReadBuffer(TBuffer &b);
virtual void Reset(Option_t * /* option */ ="");
virtual Int_t SetParent(const TObject* parent, Int_t branchID);
static void SetRefTable(TRefTable *table);
virtual void SetUID(UInt_t uid, TProcessID* context = 0) {fUID=uid; fUIDContext = context;}
ClassDef(TRefTable,3) //Table of referenced objects during an I/O operation
};
#endif
| [
"slzarate96@gmail.com"
] | slzarate96@gmail.com |
bfce13612e490827ab03e3a6eb732b6eb08efb07 | 64c395a9925516d909b20df3f322ae92877a73b4 | /src/projects/error_correction/error_correction.hpp | db1b9734e8560e33f7b91d02424918f87a6f6f59 | [
"BSD-3-Clause"
] | permissive | AntonBankevich/DR | 8fbef7455c34d18e7501e92b49f5b916b266abdd | 057795fdb75c3b8fe4984845dc9e0ddb2f3dd765 | refs/heads/master | 2022-02-09T22:37:26.179203 | 2022-02-01T18:53:52 | 2022-02-01T18:53:52 | 248,891,874 | 3 | 0 | NOASSERTION | 2020-12-21T05:35:26 | 2020-03-21T02:23:55 | C++ | UTF-8 | C++ | false | false | 16,374 | hpp | //
// Created by anton on 8/26/20.
//
#pragma once
#include "dbg/sparse_dbg.hpp"
#include "common/hash_utils.hpp"
#include "common/output_utils.hpp"
#include "common/simple_computation.hpp"
#include <queue>
#include <functional>
namespace error_correction {
inline std::ostream& operator<<(std::ostream& out, const unsigned __int128& item) {
std::vector<char> res;
unsigned __int128 tmp = item;
while(tmp != 0) {
res.push_back(char((tmp % 10) + '0'));
tmp /= 10;
}
return out << std::string(res.rbegin(), res.rend());
}
struct State {
State() = default;
State(size_t lastMatch, size_t diff, Vertex *graphPosition, bool match) : last_match(lastMatch),
diff(diff),
graph_position(graphPosition),
match(match) {}
size_t last_match;
size_t diff;
Vertex *graph_position;
bool match;
bool operator==(const State &other) const {
return last_match == other.last_match && diff == other.diff &&
graph_position == other.graph_position && match == other.match;
}
size_t hash() const {
return std::hash<size_t>()(last_match) ^ std::hash<size_t>()(diff) ^
std::hash<void *>()(graph_position) ^ std::hash<bool>()(match);
}
};
std::ostream& operator<<(std::ostream& out, const State & item) {
return out << "(" << item.last_match << " " << item.diff << " " << item.graph_position->hash() << " " << item.match << ")";
}
}
namespace std {
template <>
struct hash<error_correction::State> {
std::size_t operator()(const error_correction::State &state) const {
return std::hash<size_t>()(state.last_match) ^ std::hash<size_t>()(state.diff) ^
std::hash<void *>()(state.graph_position) ^ std::hash<bool>()(state.match);
}
};
}
namespace error_correction {
struct ResRecord {
ResRecord(ResRecord *prev, Edge *lastEdge, bool goodmatch) :
prev(prev), last_edge(lastEdge), good_match(goodmatch) {}
ResRecord *prev;
Edge *last_edge;
bool good_match;
};
struct ScoredState {
State state;
ResRecord resRecord;
size_t score;
ScoredState(const State &state, const ResRecord &resRecord, size_t score) : state(state),
resRecord(resRecord),
score(score) {}
bool operator<(const ScoredState &other) const {
return score > other.score;
}
};
struct CorrectionResult {
CorrectionResult(const Path &path, size_t score, size_t iterations) : path(path),
score(score),
iterations(
iterations) {}
Path path;
size_t score;
size_t iterations;
};
struct ScoreScheme {
size_t cov_threshold = 8;
size_t alternative_penalty = 2;
size_t diff_penalty = 20;
size_t max_diff = 10;
size_t low_coverage_penalty = 10;
size_t very_bad_coverage = 3;
size_t very_bad_covereage_penalty = 50;
size_t high_coverage_penalty = 50;
size_t match_to_freeze = 100;
size_t scoreMatchingEdge(const Edge &edge) const {
if (edge.getCoverage() <= very_bad_coverage) {
return very_bad_covereage_penalty * edge.size();
} else if (edge.getCoverage() < cov_threshold) {
return low_coverage_penalty * edge.size();
} else {
return 0;
}
}
size_t scoreAlternativeEdge(const Edge &edge) const {
if (edge.getCoverage() <= very_bad_coverage) {
return (very_bad_covereage_penalty + alternative_penalty) * edge.size();
} else if (edge.getCoverage() < cov_threshold) {
return (low_coverage_penalty + alternative_penalty) * edge.size();
} else {
return alternative_penalty * edge.size();
}
}
size_t scoreRemovedEdge(const Edge &edge) const {
if (edge.getCoverage() > cov_threshold) {
return high_coverage_penalty * edge.size();
} else {
return 0;
}
}
};
std::vector<Edge*> restoreResult(const std::unordered_map<State, ResRecord> stateMap,
ResRecord *resRecord) {
std::vector<Edge*> res;
while(resRecord->prev != nullptr) {
if (resRecord->last_edge != nullptr) {
res.push_back(resRecord->last_edge);
}
resRecord = resRecord->prev;
}
return {res.rbegin(), res.rend()};
}
size_t checkPerfect(const std::unordered_map<State, ResRecord> stateMap,
ResRecord *resRecord, size_t length) {
size_t len = 0;
size_t cnt = 0;
while(resRecord->prev != nullptr) {
if (!resRecord->good_match) {
return size_t(-1);
}
len += resRecord->last_edge->size();
cnt += 1;
if(len >= length)
return cnt;
resRecord = resRecord->prev;
}
return size_t(-1);
}
CorrectionResult correct(Path & initial_path, ScoreScheme scores = {}) {
// std::cout << "New read " << path.size() << std::endl;
// for (size_t i = 0; i < path.size(); i++) {
// std::cout << " " << path[i].end()->hash() << " " << path[i].getCoverage() << " " << path[i].size();
// }
// std::cout << std::endl;
size_t from = 0;
size_t cut_len_start = 0;
size_t to = initial_path.size();
while(from < to && initial_path[from].getCoverage() < scores.cov_threshold && cut_len_start < 1000) {
cut_len_start +=initial_path[from].size();
from += 1;
}
size_t cut_len_end = 0;
while(from < to && initial_path[to - 1].getCoverage() < scores.cov_threshold && cut_len_end < 1000) {
cut_len_end += initial_path[to - 1].size();
to -= 1;
}
if (from == to || cut_len_end + cut_len_start > 1500) {
// std::cout << "Finished fail " << (size_t(-1) >> 1u) << std::endl;
return {initial_path, size_t(-1) >> 1u, size_t(-1) >> 1u};
}
Path path = initial_path.subPath(from, to);
std::priority_queue<ScoredState> queue;
queue.emplace(State(0, 0, &path.start(), true), ResRecord(nullptr, nullptr, false), 0);
std::unordered_map<State, ResRecord> res;
size_t cnt = 0;
size_t frozen = 0;
while(!queue.empty()) {
ScoredState next = queue.top();
queue.pop();
if(next.state.last_match == path.size()) {
VERIFY(next.state.match);
// std::cout << "Finished " << next.score << " " << cnt << std::endl;
return {Path(path.start(), restoreResult(res, &next.resRecord)), next.score, cnt};
}
// std::cout<< "New state " << next.state << " " << next.score << " " << next.state.graph_position->outDeg();
// for(size_t i = 0; i < next.state.graph_position->outDeg(); i++) {
// std::cout << " " << next.state.graph_position->getOutgoing()[i].getCoverage();
// }
// if (next.resRecord.last_edge != nullptr)
// std::cout << " " << next.resRecord.last_edge->getCoverage() << " " << next.resRecord.last_edge->seq;
// std::cout << std::endl;
if(res.find(next.state) != res.end() || next.state.last_match < frozen)
continue;
ResRecord &prev = res.emplace(next.state, next.resRecord).first->second;
State &state = next.state;
if(next.state.match && !prev.good_match) {
size_t perfect_len = 0;
size_t right = state.last_match;
while(right < path.size() && path[right].getCoverage() >= scores.cov_threshold) {
right += 1;
}
size_t left = right;
while(left > state.last_match && perfect_len + path[left - 1].size() < scores.match_to_freeze) {
perfect_len += path[left - 1].size();
left -= 1;
}
if (left > state.last_match) {
// std::cout << "Skip to " << left << " " << &path.getVertex(left) << std::endl;
frozen = left;
ResRecord *prev_ptr = &prev;
for(size_t i = state.last_match; i + 1 < left; i++) {
prev_ptr = &res.emplace(State(i + 1, 0, &path.getVertex(i + 1), true),
ResRecord(prev_ptr, &path[i], true)).first->second;
}
queue.emplace(State(left, 0, &path.getVertex(left), true),
ResRecord(prev_ptr, &path[left - 1], true), next.score);
continue;
}
}
if(next.state.match) {
queue.emplace(State(next.state.last_match + 1, 0, &path.getVertex(next.state.last_match + 1), true),
ResRecord(&prev, &path[next.state.last_match], path[next.state.last_match].getCoverage() > scores.cov_threshold),
next.score + scores.scoreMatchingEdge(path[next.state.last_match]));
// std::cout << "Add perfect " << next.score + scores.scoreMatchingEdge(path[next.state.last_match]) << std::endl;
} else {
size_t path_dist = 0;
size_t extra_score = 0;
for(size_t i = next.state.last_match; i < path.size(); i++) {
path_dist += path[i].size();
extra_score += scores.scoreRemovedEdge(path[i]);
if(path_dist > next.state.diff + scores.max_diff) {
break;
}
if(path_dist > next.state.diff - scores.max_diff && &path.getVertex(i + 1) == next.state.graph_position) {
size_t diff = std::min<size_t>(path_dist - next.state.diff, next.state.diff - path_dist);
queue.emplace(State(i + 1, 0, next.state.graph_position, true),
ResRecord(&prev, nullptr, false),
next.score + extra_score + diff * scores.diff_penalty);
// std::cout << "Add back to good " << next.score + extra_score + diff * scores.diff_penalty << std::endl;
}
}
}
for(size_t i = 0; i < next.state.graph_position->outDeg(); i++) {
Edge &edge = next.state.graph_position->operator[](i);
if (!next.state.match || edge.seq != path[next.state.last_match].seq) {
queue.emplace(State(next.state.last_match, next.state.diff + edge.size(), edge.end(), false),
ResRecord(&prev, &edge, false),
next.score + scores.scoreAlternativeEdge(edge));
// std::cout << "Add bad " << next.score + scores.scoreAlternativeEdge(edge) << std::endl;
}
}
cnt += 1;
if (cnt >= 100000) {
break;
}
}
// std::cout << "Finished fail " << cnt << std::endl;
return {initial_path, size_t(-1) >> 1u, cnt};
}
template<class Iterator>
void correctSequences(SparseDBG &sdbg, logging::Logger &logger, Iterator begin, Iterator end,
const std::experimental::filesystem::path& output_file,
const std::experimental::filesystem::path& bad_file,
size_t threads, const size_t min_read_size) {
// threads = 1;
// omp_set_num_threads(1);
typedef typename Iterator::value_type ContigType;
logger.info() << "Starting to correct reads" << std::endl;
ParallelRecordCollector<size_t> times(threads);
ParallelRecordCollector<size_t> scores(threads);
ParallelRecordCollector<Contig> result(threads);
ParallelRecordCollector<Contig> prev_result(threads);
ParallelRecordCollector<std::pair<Contig, size_t>> bad_reads(threads);
std::unordered_map<std::string, size_t> read_order;
std::unordered_map<std::string, size_t> prev_read_order;
std::ofstream os;
os.open(output_file);
std::function<void(size_t, ContigType &)> task = [&sdbg, ×, &scores, min_read_size, &result, &bad_reads](size_t num, ContigType & contig) {
Sequence seq = contig.makeSequence();
if(seq.size() >= min_read_size) {
Path path = GraphAligner(sdbg).align(seq).path();
CorrectionResult res = correct(path);
times.emplace_back(res.iterations);
scores.emplace_back(res.score);
result.emplace_back(res.path.Seq(), contig.id + " " + std::to_string(res.score));
if(res.score > 25000)
bad_reads.emplace_back(Contig(contig.makeSequence(), contig.id + " " + std::to_string(res.score)), res.score);
} else {
result.emplace_back(seq, contig.id + " 0");
}
};
ParallelProcessor<StringContig> processor(task, logger, threads);
processor.doInOneThread = [&read_order](ContigType & contig) {
size_t val = read_order.size();
read_order[split(contig.id)[0]] = val;
};
processor.doAfter = [&read_order, &prev_read_order, &result, &prev_result]() {
std::swap(read_order, prev_read_order);
std::swap(result, prev_result);
read_order.clear();
result.clear();
};
processor.doInParallel = [&prev_read_order, &prev_result, &os]() {
VERIFY(prev_read_order.size() == prev_result.size());
std::vector<Contig> res(prev_read_order.size());
for(Contig &contig : prev_result) {
res[prev_read_order[split(contig.id)[0]]] = std::move(contig);
}
for(Contig &contig : res) {
os << ">" << contig.id << "\n" << contig.seq << "\n";
}
};
processor.doInTheEnd = processor.doInParallel;
processor.processRecords(begin, end);
os.close();
std::vector<size_t> time_hist = histogram(times.begin(), times.end(), 100000, 1000);
std::vector<size_t> score_hist = histogram(scores.begin(), scores.end(), 100000, 1000);
logger.info() << "Reader corrected" << std::endl;
logger.info() << "Iterations" << std::endl;
for(size_t i = 0; i < time_hist.size(); i++) {
logger << i * 1000 << " " << time_hist[i] << std::endl;
}
logger.info() << "Scores" << std::endl;
for(size_t i = 0; i < score_hist.size(); i++) {
logger << i * 1000 << " " << score_hist[i] << std::endl;
}
logger.info() << "Printed corrected reads to " << output_file << std::endl;
logger.info() << "Found " << bad_reads.size() << " bad reads" << std::endl;
std::ofstream bados;
bados.open(bad_file);
for(auto & contig : bad_reads) {
bados << ">" << contig.first.id << " " << contig.second << "\n" << contig.first.seq << "\n";
}
bados.clear();
logger.info() << "Printed bad reads to " << bad_file << std::endl;
}
}
| [
"anton.bankevich@gmail.com"
] | anton.bankevich@gmail.com |
18b3188ebbc7d543c18cfe876526203be2798078 | d83ffa98b2a2c4fa96d2ce59f7b986e407437f09 | /src/client/net/BinaryClientTransport.h | 5acc81d7d5c409b04cb1e45bbeb048bf275e53c1 | [] | no_license | maumyrtille/VoxelGameClient | 2e01f26f53fada98de6381121ff2a85f469ffc3a | 48b91efc443d41e73f2985976d70a9ebf3251978 | refs/heads/master | 2023-06-19T12:15:42.103194 | 2021-07-16T20:24:04 | 2021-07-16T20:24:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,246 | h | #pragma once
#include <vector>
#include <mutex>
#include <bitsery/bitsery.h>
#include <bitsery/adapter/buffer.h>
#include <bitsery/traits/string.h>
#include "ClientTransport.h"
class GameEngine;
class BinaryClientTransport: public ClientTransport {
VoxelTypeSerializationContext m_voxelTypeSerializationContext;
protected:
template<typename T> static void deserialize(const std::string &data, T& message) {
bitsery::quickDeserialization<bitsery::InputBufferAdapter<std::string>>(
{data.begin(), data.size()},
message
);
}
template<typename T> void serializeAndSendMessage(const T &message) {
std::string buffer;
auto count = bitsery::quickSerialization<bitsery::OutputBufferAdapter<std::string>>(buffer, message);
sendMessage(buffer.data(), count);
}
void handleMessage(const std::string &payload);
virtual void sendMessage(const void *data, size_t dataSize) = 0;
using ClientTransport::sendPlayerPosition;
void sendPlayerPosition(const glm::vec3 &position, float yaw, float pitch, int viewRadius) override;
void sendHello();
public:
explicit BinaryClientTransport(GameEngine &engine);
void updateActiveInventoryItem(int index) override;
void digVoxel() override;
void placeVoxel() override;
};
| [
"kiv.apple@gmail.com"
] | kiv.apple@gmail.com |
7bedc1ccc9795a0010e1dbe827d11a104b2ebec8 | d3b07a9519e32ea0b209f2a28545ec79c4daffca | /Delhi_University_BSc(HOUN)Computer_Science_Practicals/In_C++/Program_3_WAP to reverse a user entered string using recursion.cpp | 355c7722f6c76372d2754594fd9a97c97f3edf19 | [] | no_license | Hacker-BlackHATS/Data-Structures | 7a3479e135e54d705f56e7e57e4084c7b5d49e4f | ed03b374f13ba1ac8b4330e8a7786350f83d2119 | refs/heads/master | 2020-08-26T21:04:28.657814 | 2019-11-20T18:26:59 | 2019-11-20T18:26:59 | 217,148,111 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 496 | cpp | //Objective : WAP to reverse a user entered string using recursion.
#include <iostream>
#include<conio.h>
using namespace std;
string rev(string s,int i, int j){
if((i==j)||(j<i)){
return s;
}
else{
char c = s[i];
s[i]=s[j];
s[j]=c;
return rev(s,++i,--j);
}
}
int main()
{
string s;
cout<<"Enter a string : ";
cin>>s;
cout<<"String in reverse : "<<rev(s,0,s.length()-1);
getch();
return 0;
}
| [
"noreply@github.com"
] | Hacker-BlackHATS.noreply@github.com |
fa0f76de13edc182c449619ebde2ef09feeef620 | f3995affb205e57e40bf3037c22f2925cc0e8ed4 | /UVA101.cpp | c3604c2811b79c725f34f42b1c2d3c2a3594f7d4 | [] | no_license | 1025652942/UVA | e3789ecf553980a50666d0fcf3b687ac9da9e29f | 2b3c33890095e0c72540056e8aba257c82b2807d | refs/heads/master | 2021-05-10T11:10:51.474215 | 2018-01-22T06:40:19 | 2018-01-22T06:40:19 | 118,407,683 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,666 | cpp | ///模拟 查找a,b的位置 2n 2
///将a上所有积木复原 v[i].push_back(i);
///将a落到b上
#include<iostream>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
vector<int>ss[27];
vector<int>::iterator it,it1,it2;
///pile over
void deal1(int a1,int a2,int n)
{
///cout<<"1"<<endl;
int loc1=-1;int loc2=-1;
for(int i=0;i<n;++i)
{
if(find(ss[i].begin(),ss[i].end(),a1)!=ss[i].end()) {loc1=i;it1=find(ss[i].begin(),ss[i].end(),a1);}
if(find(ss[i].begin(),ss[i].end(),a2)!=ss[i].end()) {loc2=i;it2=find(ss[i].begin(),ss[i].end(),a2);}
}
if(loc1==-1||loc2==-1) return;
if(loc1==loc2) return;
///不放回
for(it1;it1!=ss[loc1].end();)
{
ss[loc2].push_back( (*it1) );
it1=ss[loc1].erase(it1);
}
}
void deal2(int a1,int a2,int n)
{
///cout<<"2\n";
///move over
int loc1=-1;int loc2=-1;
for(int i=0;i<n;++i)
{
if(find(ss[i].begin(),ss[i].end(),a1)!=ss[i].end()) {loc1=i;it1=find(ss[i].begin(),ss[i].end(),a1);}
if(find(ss[i].begin(),ss[i].end(),a2)!=ss[i].end()) {loc2=i;it2=find(ss[i].begin(),ss[i].end(),a2);}
}
if(loc1==-1||loc2==-1) return;
if(loc1==loc2) return;
ss[loc2].push_back(*it1);
it1=ss[loc1].erase(it1);
for(it1;it1!=ss[loc1].end();)
{
ss[*it1].push_back(*it1);
it1=ss[loc1].erase(it1);
}
}
void deal3(int a1,int a2,int n)
{
///cout<<"3\n";
///pile onto
int loc1=-1;int loc2=-1;
for(int i=0;i<n;++i)
{
if(find(ss[i].begin(),ss[i].end(),a1)!=ss[i].end()) {loc1=i;it1=find(ss[i].begin(),ss[i].end(),a1);}
if(find(ss[i].begin(),ss[i].end(),a2)!=ss[i].end()) {loc2=i;it2=find(ss[i].begin(),ss[i].end(),a2);}
}
if(loc1==-1||loc2==-1) return;
if(loc1==loc2) return;
it2++;
for(it2;it2!=ss[loc2].end();)
{
ss[*it2].push_back(*it2);
it2=ss[loc2].erase(it2);
}
for(it1;it1!=ss[loc1].end();)
{
ss[loc2].push_back(*it1);
it1=ss[loc1].erase(it1);
}
}
void deal4(int a1,int a2,int n)
{
///cout<<"4\n";
///move onto
int loc1=-1;int loc2=-1;
for(int i=0;i<n;++i)
{
if(find(ss[i].begin(),ss[i].end(),a1)!=ss[i].end()) {loc1=i;it1=find(ss[i].begin(),ss[i].end(),a1);}
if(find(ss[i].begin(),ss[i].end(),a2)!=ss[i].end()) {loc2=i;it2=find(ss[i].begin(),ss[i].end(),a2);}
}
if(loc1==-1||loc2==-1) return;
if(loc1==loc2) return;
it2++;
for(it2;it2!=ss[loc2].end();)
{
ss[*it2].push_back(*it2);
it2=ss[loc2].erase(it2);
}
ss[loc2].push_back(*it1);
it1=ss[loc1].erase(it1);
for(it1;it1!=ss[loc1].end();)
{
ss[*it1].push_back(*it1);
it1=ss[loc1].erase(it1);
}
}
void display(int n)
{
for(int i=0;i<n;++i)
{
cout<<i<<":";
if(!ss[i].empty())
{
for(it=ss[i].begin();it<ss[i].end();it++)
cout<<" "<<*it ;
}
cout<<endl;
}
}
int main()
{
int n;
cin>>n;
///getchar();
///初始化
for(int i=0;i<n;++i)
{
ss[i].push_back(i);
}
///display(n);
char temp[15];
string s1;
string s2;
bool mark1;
bool mark2;
int a1;
int a2;
string c="quit";
string c1="move";
string c2="pile";
string c3="onto";
string c4="over";
while (cin >> s1)
{
if(s1==c) break;
cin>> a1 >> s2 >> a2;
/*for(int i=0;i<4;++i)
{
s1[i]=a[i];
}*/
///cout<<"s1"<<s1<<"\n";
if(s1==c1) mark1=0;
else if(s1==c2) mark1=1;
/*
for(int i=0;i<4;++i)
{
s2[i]=a[6+i];
}*/
///cout<<"s2"<<s2<<"\n";
if(s2==c3) mark2=0;
else if(s2==c4) mark2=1;
///cout<<"marks"<<mark1<<" "<<mark2<<" \n";
///a2=(int)a[12]-(int)'0';
if(mark1&&mark2) deal1(a1,a2,n);///pile over
else if(!mark1&&mark2) deal2(a1,a2,n);///move over
else if(mark1&&!mark2) deal3(a1,a2,n);///pile onto
else if(!mark1&&!mark2) {deal4(a1,a2,n);}///move onto
///cout<<"end\n";
///display(n);
}
display(n);
return 0;
}
| [
"noreply@github.com"
] | 1025652942.noreply@github.com |
7e6bc6162d685e41cf9c4060f8eed42c10f0c58f | e1cef84f11449c5107f79a5f1d10198d39048028 | /sources/IPAddress.cpp | d4581bfc850438d5ade6e6b35ea81f0beff15739 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | LukasBanana/MercuriusLib | 7e391d019b225a04b4c0c4906e0cc2af8b30cc77 | 0b80c49b52a166a4a5490f3044c64f4a8895d9ae | refs/heads/master | 2021-01-20T00:13:42.433365 | 2018-09-24T14:12:49 | 2018-09-24T14:12:49 | 89,097,810 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,030 | cpp | /*
* IPAddress.cpp
*
* This file is part of the "MercuriusLib" project (Copyright (c) 2017 by Lukas Hermanns)
* See "LICENSE.txt" for license information.
*/
#include <Merc/IPAddress.h>
#include "IPv4Address.h"
namespace Mc
{
std::unique_ptr<IPAddress> IPAddress::MakeIPv4(unsigned short port)
{
return std::unique_ptr<IPAddress> { new IPv4Address(port) };
}
std::unique_ptr<IPAddress> IPAddress::MakeIPv4(unsigned short port, unsigned long address)
{
return std::unique_ptr<IPAddress> { new IPv4Address(port, address) };
}
std::unique_ptr<IPAddress> IPAddress::MakeIPv4(unsigned short port, const std::string& addressName)
{
return std::unique_ptr<IPAddress> { new IPv4Address(port, addressName) };
}
std::unique_ptr<IPAddress> IPAddress::MakeIPv4Localhost(unsigned short port)
{
return MakeIPv4(port, "127.0.0.1");
}
std::unique_ptr<IPAddress> IPAddress::Make(const AddressFamily family, unsigned short port)
{
switch (family)
{
case AddressFamily::IPv4:
return MakeIPv4(port);
default:
return nullptr;
}
}
std::vector<std::unique_ptr<IPAddress>> IPAddress::QueryAddressesFromHost(const std::string& hostName)
{
/* Query addresses from host name */
addrinfo* results;
if (::getaddrinfo(hostName.c_str(), nullptr, nullptr, &results) != 0)
throw std::runtime_error("failed to query addresses from host name: " + hostName);
/* Enumerate addresses */
std::vector<std::unique_ptr<IPAddress>> addresses;
for (auto ptr = results; ptr != nullptr; ptr = ptr->ai_next)
{
switch (ptr->ai_family)
{
case AF_INET:
{
if (ptr->ai_addr)
{
addresses.emplace_back(
std::unique_ptr<IPv4Address>(
new IPv4Address { *reinterpret_cast<const sockaddr_in*>(ptr->ai_addr) }
)
);
}
}
break;
case AF_INET6:
{
//TODO...
}
break;
default:
break;
}
}
return addresses;
}
IPAddress::~IPAddress()
{
}
MC_EXPORT bool operator == (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) == 0);
}
MC_EXPORT bool operator != (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) != 0);
}
MC_EXPORT bool operator < (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) < 0);
}
MC_EXPORT bool operator <= (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) <= 0);
}
MC_EXPORT bool operator > (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) > 0);
}
MC_EXPORT bool operator >= (const IPAddress& lhs, const IPAddress& rhs)
{
return (lhs.CompareSWO(rhs) >= 0);
}
} // /namespace Mc
// ================================================================================
| [
"lukas.hermanns90@gmail.com"
] | lukas.hermanns90@gmail.com |
7723f6b2c21f8414f74b7e9f94152090f3468949 | 2021a4467ef792337c3975ad26c2f9415544a62f | /Source/Hunter/HT_LoginWidget.cpp | bf3496dc5b6583f2e83d48e76c7bfc143bce0880 | [] | no_license | blackCatx/Unreal-Portfolio | 72f01c09753b79c8c69a2a5e713f161d60f497b3 | a9ac90e00e2c06c0f2cc24c1ee7c921b5d4bad4e | refs/heads/master | 2020-08-03T07:17:06.689709 | 2018-04-26T09:25:35 | 2018-04-26T09:25:35 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,200 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Hunter.h"
#include "HT_LoginWidget.h"
#include "HT_GameInstance.h"
#include "EditableTextBox.h"
#include "HT_LoginThread.h"
#include "HT_MessageBoxWidget.h"
#include "Runtime/Sockets/Public/Sockets.h"
void UHT_LoginWidget::OnLoginButton()
{
UEditableTextBox* ID_Input = Cast<UEditableTextBox>(this->GetWidgetFromName("ID_Input"));
UEditableTextBox* PW_Input = Cast<UEditableTextBox>(this->GetWidgetFromName("PW_Input"));
FString ID = ID_Input->GetText().ToString();
FString PW = PW_Input->GetText().ToString();
UHT_GameInstance* GameInstance = Cast<UHT_GameInstance>(GetWorld()->GetGameInstance());
if (ID.Len() > 0 && PW.Len() > 0)
{
GameInstance->Init_Network(ID, PW);
IsLoginChaking = true;
}
else if (ID.Len() == 0)
{
UHT_MessageBoxWidget* NewWidget = CreateWidget<UHT_MessageBoxWidget>(GetWorld(), GameInstance->MessageBoxWidgetClass);
NewWidget->SetMessageText(TEXT("ID를 입력하세요."));
NewWidget->AddToViewport();
}
else if (PW.Len() == 0)
{
UHT_MessageBoxWidget* NewWidget = CreateWidget<UHT_MessageBoxWidget>(GetWorld(), GameInstance->MessageBoxWidgetClass);
NewWidget->SetMessageText(TEXT("PW를 입력하세요."));
NewWidget->AddToViewport();
}
}
void UHT_LoginWidget::OnCencelButton()
{
//FHT_LoginThread::JoyInit()->Shutdown();
}
void UHT_LoginWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
if (IsLoginChaking)
{
if (FHT_LoginThread::GetInstance()->IsComplete)
{
UHT_GameInstance* GameInstance = Cast<UHT_GameInstance>(GetWorld()->GetGameInstance());
UHT_MessageBoxWidget* NewWidget = CreateWidget<UHT_MessageBoxWidget>(GetWorld(), GameInstance->MessageBoxWidgetClass);
if (FHT_LoginThread::GetInstance()->IsSuccess)
{
NewWidget->SetMessageText(TEXT("인증 성공!"));
NewWidget->IsLogin = true;
}
else
{
NewWidget->SetMessageText(TEXT("인증 실패!"));
//인증 실패
NewWidget->IsLogin = false;
GameInstance->ChattingSocket->Close();
GameInstance->ChattingSocket = NULL;
}
NewWidget->AddToViewport();
FHT_LoginThread::GetInstance()->Shutdown();
}
}
} | [
"iso5930@naver.com"
] | iso5930@naver.com |
2ae89233c0bd79c6b87c010f5d190709a049f1ea | 6fd9a785cd59f1673e2bb13e6308dfee7dd5141e | /c++stl/myvec.cpp | 34648b522b17a25046d5ca1eb441e49583bd3aba | [] | no_license | debnathsinha/scratch | d68fb3e8a3fdf8c19dfb86a37a7c64e6919739d0 | 2154061d3e926b52cfd9ffdbb6761ba6ff6bd64e | refs/heads/master | 2021-01-01T17:04:43.211081 | 2013-07-11T18:06:02 | 2013-07-11T18:06:02 | 1,557,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 424 | cpp | #include <iostream>
#include <vector>
#include <list>
int main() {
std::cout << "Hello World" << std::endl;
const int N = 3;
std::vector<int> region1(N);
std::list<int> region2;
region2.push_back(1);
region2.push_back(0);
region2.push_back(3);
std::copy(region2.begin(), region2.end(), region1.begin());
for( int i = 0; i < N; i++ )
std::cout << region1[i] << " ";
std::cout << std::endl;
}
| [
"debnathsinha@gmail.com"
] | debnathsinha@gmail.com |
144d159ccf554f44b369957c3098264590a36d9b | 86a493c7e48bb37fddf081bcd7c8cb0e10e01219 | /pattern7.cpp | 1207810131087ee9c344d03b46f50e5d8ac74e30 | [] | no_license | dsprajput/apnacollege | aa5640ca29df161d66c027c0222d79895df96d74 | 84128142c9b52549f7c738c3834a906bd12b5654 | refs/heads/main | 2023-02-07T18:24:38.405214 | 2020-12-30T09:27:13 | 2020-12-30T09:27:13 | 311,663,453 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 538 | cpp | #include<iostream>
using namespace std;
int main()
{
for(int i=0; i<4; i++)
{
for(int j=0; j<4+i; j++)
{
if(i+j>=3)
{
cout<<"*";
}
else
cout<<" ";
}
cout<<endl;
}
for(int i=4; i>0; i--)
{
for(int j=0; j<=2+i; j++)
{
if(i+j<4)
{
cout<<" ";
}
else
cout<<"*";
}
cout<<endl;
}
return 0;
}
| [
"dsprajput.2801@gmail.com"
] | dsprajput.2801@gmail.com |
db3de6533283136709337fe769321790ca3d218d | 5175bd24b43d8db699341997df5fecf21cc7afc1 | /libs/leaf/test/accumulate_basic_test.cpp | 94b88608b937d8b8c2b46e39011b24efa536bbc9 | [
"BSL-1.0",
"LicenseRef-scancode-proprietary-license"
] | permissive | quinoacomputing/Boost | 59d1dc5ce41f94bbd9575a5f5d7a05e2b0c957bf | 8b552d32489ff6a236bc21a5cf2c83a2b933e8f1 | refs/heads/master | 2023-07-13T08:03:53.949858 | 2023-06-28T20:18:05 | 2023-06-28T20:18:05 | 38,334,936 | 0 | 0 | BSL-1.0 | 2018-04-02T14:17:23 | 2015-06-30T21:50:37 | C++ | UTF-8 | C++ | false | false | 1,195 | cpp | // Copyright (c) 2018-2021 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifdef BOOST_LEAF_TEST_SINGLE_HEADER
# include "leaf.hpp"
#else
# include <boost/leaf/on_error.hpp>
# include <boost/leaf/handle_errors.hpp>
# include <boost/leaf/result.hpp>
#endif
#include "lightweight_test.hpp"
namespace leaf = boost::leaf;
template <int>
struct info
{
int value;
};
leaf::error_id g()
{
auto load = leaf::on_error( [](info<1> & x) {++x.value;} );
return leaf::new_error();
}
leaf::error_id f()
{
auto load = leaf::on_error( [](info<1> & x) {++x.value;}, [](info<2> & x) {++x.value;} );
return g();
}
int main()
{
int r = leaf::try_handle_all(
[]() -> leaf::result<int>
{
return f();
},
[]( info<1> const & a, info<2> const & b )
{
BOOST_TEST_EQ(a.value, 2);
BOOST_TEST_EQ(b.value, 1);
return 1;
},
[]
{
return 2;
} );
BOOST_TEST_EQ(r, 1);
return boost::report_errors();
}
| [
"apandare@lanl.gov"
] | apandare@lanl.gov |
70f00cbbcd02a64611c42d869a4a7ea7b7aa2884 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_new_new_log_360.cpp | d85b5ca5a79bdc14d8c371888e2013c6630e95f4 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 58 | cpp | utils::Assert(rmax >= rmin + wmin, "relation constraint"); | [
"993273596@qq.com"
] | 993273596@qq.com |
dd5f32f5d2cea9a7fbd39f35c49f9a04c8e5534f | 83ac6cbdf70e6ffaed06184e4803377563c3fc88 | /condition_parser.h | 731991b366a58e76031711d55219645e393a2df2 | [] | no_license | jBuly4/Yandex_Art_of_modern_Cpp_developing_Yellow_belt | 36405c1a65163042b1d3fd8d2200ff21a21e6dba | f2a1dc5291e5f314b027bee0db37f38e44379e49 | refs/heads/main | 2023-08-26T14:42:03.119289 | 2021-10-30T10:15:41 | 2021-10-30T10:15:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 352 | h | //
// condition_parser.h
// yellow_course_poject
//
// Created by research on 09.03.2021.
//
#ifndef condition_parser_h
#define condition_parser_h
#pragma once
#include "node.h"
#include <memory>
#include <iostream>
using namespace std;
shared_ptr<Node> ParseCondition(istream& is);
void TestParseCondition();
#endif /* condition_parser_h */
| [
"ibuly4@gmail.com"
] | ibuly4@gmail.com |
d22ee4325cfce2ab6c13b38ec383111e837ffe01 | 447cd9de29b2455aa097d465088ff132668cf9ce | /riscv_scml/vp/src/platform/multicore/mc_main.cpp | f44b1180510404a377ed67e76ad7d15bdc3ef85c | [
"MIT"
] | permissive | yangdunan/riscv_vp | 892a3e216805deb42cb1f8d1c79a588cb860b5c1 | 5db8f38ee35cb872ed7155299a2b9cab1644da7e | refs/heads/master | 2021-04-17T18:31:30.025459 | 2020-03-25T16:22:27 | 2020-03-25T16:22:27 | 249,466,241 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,681 | cpp | #include <cstdlib>
#include <ctime>
#include "core/common/clint.h"
#include "elf_loader.h"
#include "iss.h"
#include "mem.h"
#include "memory.h"
#include "syscall.h"
#include <boost/io/ios_state.hpp>
#include <boost/program_options.hpp>
#include <iomanip>
#include <iostream>
using namespace rv32;
struct Options {
typedef unsigned int addr_t;
Options &check_and_post_process() {
return *this;
}
std::string input_program;
addr_t mem_size = 1024 * 1024 * 32; // 32 MB ram, to place it before the CLINT and run the base examples (assume
// memory start at zero) without modifications
addr_t mem_start_addr = 0x00000000;
addr_t mem_end_addr = mem_start_addr + mem_size - 1;
addr_t clint_start_addr = 0x02000000;
addr_t clint_end_addr = 0x0200ffff;
addr_t sys_start_addr = 0x02010000;
addr_t sys_end_addr = 0x020103ff;
bool use_instr_dmi = false;
bool use_data_dmi = false;
bool trace_mode = false;
unsigned int tlm_global_quantum = 10;
};
Options parse_command_line_arguments(int argc, char **argv) {
// Note: first check for *help* argument then run *notify*, see:
// https://stackoverflow.com/questions/5395503/required-and-optional-arguments-using-boost-library-program-options
try {
Options opt;
namespace po = boost::program_options;
po::options_description desc("Options");
// clang-format off
desc.add_options()
("help", "produce help message")
("memory-start", po::value<unsigned int>(&opt.mem_start_addr),"set memory start address")
("trace-mode", po::bool_switch(&opt.trace_mode), "enable instruction tracing")
("tlm-global-quantum", po::value<unsigned int>(&opt.tlm_global_quantum), "set global tlm quantum (in NS)")
("use-instr-dmi", po::bool_switch(&opt.use_instr_dmi), "use dmi to fetch instructions")
("use-data-dmi", po::bool_switch(&opt.use_data_dmi), "use dmi to execute load/store operations")
("use-dmi", po::bool_switch(), "use instr and data dmi")
("input-file", po::value<std::string>(&opt.input_program)->required(), "input file to use for execution");
// clang-format on
po::positional_options_description pos;
pos.add("input-file", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(pos).run(), vm);
if (vm.count("help")) {
std::cout << desc << std::endl;
exit(0);
}
po::notify(vm);
if (vm["use-dmi"].as<bool>()) {
opt.use_data_dmi = true;
opt.use_instr_dmi = true;
}
return opt.check_and_post_process();
} catch (boost::program_options::error &e) {
std::cerr << "Error parsing command line options: " << e.what() << std::endl;
exit(-1);
}
}
int sc_main(int argc, char **argv) {
Options opt = parse_command_line_arguments(argc, argv);
std::srand(std::time(nullptr)); // use current time as seed for random generator
tlm::tlm_global_quantum::instance().set(sc_core::sc_time(opt.tlm_global_quantum, sc_core::SC_NS));
ISS core0(0);
ISS core1(1);
CombinedMemoryInterface core0_mem_if("MemoryInterface0", core0);
CombinedMemoryInterface core1_mem_if("MemoryInterface1", core1);
SimpleMemory mem("SimpleMemory", opt.mem_size);
ELFLoader loader(opt.input_program.c_str());
SimpleBus<2, 3> bus("SimpleBus");
SyscallHandler sys("SyscallHandler");
CLINT<2> clint("CLINT");
std::shared_ptr<BusLock> bus_lock = std::make_shared<BusLock>();
core0_mem_if.bus_lock = bus_lock;
core1_mem_if.bus_lock = bus_lock;
bus.ports[0] = new PortMapping(opt.mem_start_addr, opt.mem_end_addr);
bus.ports[1] = new PortMapping(opt.clint_start_addr, opt.clint_end_addr);
bus.ports[2] = new PortMapping(opt.sys_start_addr, opt.sys_end_addr);
loader.load_executable_image(mem.data, mem.size, opt.mem_start_addr);
core0.init(&core0_mem_if, &core0_mem_if, &clint, loader.get_entrypoint(),
opt.mem_end_addr - 3); // -3 to not overlap with the next region and stay 32 bit aligned
core1.init(&core1_mem_if, &core1_mem_if, &clint, loader.get_entrypoint(), opt.mem_end_addr - 32767);
sys.init(mem.data, opt.mem_start_addr, loader.get_heap_addr());
sys.register_core(&core0);
sys.register_core(&core1);
// connect TLM sockets
core0_mem_if.isock.bind(bus.tsocks[0]);
core1_mem_if.isock.bind(bus.tsocks[1]);
bus.isocks[0].bind(mem.tsock);
bus.isocks[1].bind(clint.tsock);
bus.isocks[2].bind(sys.tsock);
// connect interrupt signals/communication
clint.target_harts[0] = &core0;
clint.target_harts[1] = &core1;
// switch for printing instructions
core0.trace = opt.trace_mode;
core1.trace = opt.trace_mode;
new DirectCoreRunner(core0);
new DirectCoreRunner(core1);
sc_core::sc_start();
core0.show();
core1.show();
return 0;
}
| [
"juliany922@gmail.com"
] | juliany922@gmail.com |
670743b329dbf67591a8a55085a811a5129960db | 45ee32435c345790cae1f10111e37f860395f1ea | /art-extension/runtime/elf_file.h | c3616f7290c6cc6806b0aeb42ec8136e6ff81728 | [
"Apache-2.0",
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | android-art-intel/Nougat | b93eb0bc947088ba55d03e62324af88d332c5e93 | ea41b6bfe5c6b62a3163437438b21568cc783a24 | refs/heads/master | 2020-07-05T18:53:19.370466 | 2016-12-16T04:23:40 | 2016-12-16T04:23:40 | 73,984,816 | 9 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,537 | h | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ART_RUNTIME_ELF_FILE_H_
#define ART_RUNTIME_ELF_FILE_H_
#include <memory>
#include <string>
#include "base/macros.h"
// Explicitly include our own elf.h to avoid Linux and other dependencies.
#include "./elf.h"
#include "os.h"
namespace art {
template <typename ElfTypes>
class ElfFileImpl;
// Explicitly instantiated in elf_file.cc
typedef ElfFileImpl<ElfTypes32> ElfFileImpl32;
typedef ElfFileImpl<ElfTypes64> ElfFileImpl64;
// Used for compile time and runtime for ElfFile access. Because of
// the need for use at runtime, cannot directly use LLVM classes such as
// ELFObjectFile.
class ElfFile {
public:
static ElfFile* Open(File* file,
bool writable,
bool program_header_only,
bool low_4gb,
std::string* error_msg,
uint8_t* requested_base = nullptr); // TODO: move arg to before error_msg.
// Open with specific mmap flags, Always maps in the whole file, not just the
// program header sections.
static ElfFile* Open(File* file,
int mmap_prot,
int mmap_flags,
std::string* error_msg);
~ElfFile();
// Load segments into memory based on PT_LOAD program headers
bool Load(bool executable, bool low_4gb, std::string* error_msg);
const uint8_t* FindDynamicSymbolAddress(const std::string& symbol_name) const;
size_t Size() const;
// The start of the memory map address range for this ELF file.
uint8_t* Begin() const;
// The end of the memory map address range for this ELF file.
uint8_t* End() const;
const File& GetFile() const;
bool GetSectionOffsetAndSize(const char* section_name, uint64_t* offset, uint64_t* size) const;
bool HasSection(const std::string& name) const;
uint64_t FindSymbolAddress(unsigned section_type,
const std::string& symbol_name,
bool build_map);
bool GetLoadedSize(size_t* size, std::string* error_msg) const;
// Strip an ELF file of unneeded debugging information.
// Returns true on success, false on failure.
static bool Strip(File* file, std::string* error_msg);
// Fixup an ELF file so that that oat header will be loaded at oat_begin.
// Returns true on success, false on failure.
static bool Fixup(File* file, uint64_t oat_data_begin);
bool Fixup(uint64_t base_address);
bool Is64Bit() const {
return elf64_.get() != nullptr;
}
ElfFileImpl32* GetImpl32() const {
return elf32_.get();
}
ElfFileImpl64* GetImpl64() const {
return elf64_.get();
}
private:
explicit ElfFile(ElfFileImpl32* elf32);
explicit ElfFile(ElfFileImpl64* elf64);
const std::unique_ptr<ElfFileImpl32> elf32_;
const std::unique_ptr<ElfFileImpl64> elf64_;
DISALLOW_COPY_AND_ASSIGN(ElfFile);
};
} // namespace art
#endif // ART_RUNTIME_ELF_FILE_H_
| [
"aleksey.v.ignatenko@intel.com"
] | aleksey.v.ignatenko@intel.com |
d1eaf1461e2358231f532f8f747215576411a295 | 66476eb7b8a452a8bd4e1e8a57dd272e8971cf45 | /main/editeng/source/accessibility/AccessibleHyperlink.cxx | 82ebffded5e39fdf62d64f154d2862eac0b967dc | [
"Apache-2.0",
"LGPL-2.0-or-later",
"HPND-sell-variant",
"ICU",
"LicenseRef-scancode-warranty-disclaimer",
"PSF-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"IJG",
"Zlib",
"NTP",
"W3C",
"GPL-1.0-or-later",
"LicenseRef-scancode-python-cwi",
"Bitstream-Vera",
"LicenseRef-scan... | permissive | ECSE437-Fall2019/OpenOffice | 36d6fb9830ceadc2f48ebab617b38b33c09cfd14 | b420a30da4cb79c4d772ac2797aefce603e3a17b | refs/heads/master | 2020-09-16T15:30:56.625335 | 2019-11-25T03:44:52 | 2019-11-25T03:44:52 | 223,813,824 | 0 | 5 | Apache-2.0 | 2019-11-25T04:52:31 | 2019-11-24T21:37:39 | C++ | UTF-8 | C++ | false | false | 13,536 | cxx | /**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_editeng.hxx"
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/accessiblekeybindinghelper.hxx>
#include "AccessibleHyperlink.hxx"
#include "editeng/unoedprx.hxx"
#include <editeng/flditem.hxx>
#include <vcl/keycodes.hxx>
using namespace ::com::sun::star;
//------------------------------------------------------------------------
//
// AccessibleHyperlink implementation
//
//------------------------------------------------------------------------
namespace accessibility
{
AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const ::rtl::OUString& rD )
: rTA( r )
{
pFld = p;
nPara = nP;
nRealIdx = nR;
nStartIdx = nStt;
nEndIdx = nEnd;
aDescription = rD;
}
AccessibleHyperlink::~AccessibleHyperlink()
{
delete pFld;
}
// XAccessibleAction
sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
{
return isValid() ? 1 : 0;
}
sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
sal_Bool bRet = sal_False;
if ( isValid() && ( nIndex == 0 ) )
{
rTA.FieldClicked( *pFld, nPara, nRealIdx );
bRet = sal_True;
}
return bRet;
}
::rtl::OUString SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
::rtl::OUString aDesc;
if ( isValid() && ( nIndex == 0 ) )
aDesc = aDescription;
return aDesc;
}
uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
if( isValid() && ( nIndex == 0 ) )
{
::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
xKeyBinding = pKeyBindingHelper;
awt::KeyStroke aKeyStroke;
aKeyStroke.Modifiers = 0;
aKeyStroke.KeyCode = KEY_RETURN;
aKeyStroke.KeyChar = 0;
aKeyStroke.KeyFunc = 0;
pKeyBindingHelper->AddKeyBinding( aKeyStroke );
}
return xKeyBinding;
}
// XAccessibleHyperlink
uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
return uno::Any();
}
uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
{
return uno::Any();
}
sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
{
return nStartIdx;
}
sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
{
return nEndIdx;
}
sal_Bool SAL_CALL AccessibleHyperlink::isValid( ) throw (uno::RuntimeException)
{
return rTA.IsValid();
}
} // end of namespace accessibility
//------------------------------------------------------------------------
// MT IA2: Accessiblehyperlink.hxx from IA2 CWS - meanwhile we also introduced one in DEV300 (above)
// Keeping this for reference - we probably should get support for image maps in our implementation...
/*
class SVX_DLLPUBLIC SvxAccessibleHyperlink :
public ::cppu::WeakImplHelper1<
::com::sun::star::accessibility::XAccessibleHyperlink >
{
SvxURLField* mpField;
sal_Int32 nStartIdx;
sal_Int32 nEndIdx;
ImageMap* mpImageMap;
SdrObject* m_pShape;
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > shapeParent;
public:
SvxAccessibleHyperlink(){};
//SvxAccessibleHyperlink(::rtl::OUString name, const Imagemap* pImageMap);
SvxAccessibleHyperlink(const SvxURLField* p, sal_Int32 nStt, sal_Int32 nEnd);
SvxAccessibleHyperlink(SdrObject* p, ::accessibility::AccessibleShape* pAcc);
virtual ~SvxAccessibleHyperlink();
//void setImageMap(ImageMap* pMap);
//void setXAccessibleImage(::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > parent);
::rtl::OUString GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException);
sal_Bool IsValidHyperlink();
// XAccessibleAction
virtual sal_Int32 SAL_CALL getAccessibleActionCount()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex )
throw (::com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription(
sal_Int32 nIndex )
throw (::com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference<
::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
getAccessibleActionKeyBinding( sal_Int32 nIndex )
throw (::com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
// XAccessibleHyperlink
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionAnchor(
sal_Int32 nIndex )
throw (::com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionObject(
sal_Int32 nIndex )
throw (::com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getStartIndex()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getEndIndex()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL isValid( )
throw (::com::sun::star::uno::RuntimeException);
};
SvxAccessibleHyperlink::SvxAccessibleHyperlink( const SvxURLField *p,
sal_Int32 nStt, sal_Int32 nEnd ) :
nStartIdx( nStt ),
nEndIdx( nEnd ),
m_pShape(NULL),
shapeParent(NULL)
{
if(p)
mpField = (SvxURLField*)p->Clone();
else
mpField = NULL;
}
SvxAccessibleHyperlink::SvxAccessibleHyperlink(SdrObject* p,
::accessibility::AccessibleShape* pAcc) :
nStartIdx( -1 ),
nEndIdx( -1 ),
mpField(NULL),
m_pShape(p)
{
mpImageMap = m_pShape->GetModel()->GetImageMapForObject(m_pShape);
shapeParent = dynamic_cast< XAccessible* >(pAcc);
}
SvxAccessibleHyperlink::~SvxAccessibleHyperlink()
{
if(mpField)
delete mpField;
}
::rtl::OUString SvxAccessibleHyperlink::GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException)
{
if( mpField )
{
if (nIndex != 0)
throw ::com::sun::star::lang::IndexOutOfBoundsException();
return ::rtl::OUString( mpField->GetURL() );
}
else if (mpImageMap)
{
if (nIndex < 0 || nIndex >=mpImageMap->GetIMapObjectCount())
throw IndexOutOfBoundsException();
IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
if (pMapObj->GetURL().Len())
return ::rtl::OUString( pMapObj->GetURL() );
}
else
{
if (nIndex != 0)
throw ::com::sun::star::lang::IndexOutOfBoundsException();
SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( m_pShape );
if(pUnoCtrl)
{
try
{
uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
form::FormButtonType eButtonType = form::FormButtonType_URL;
const ::rtl::OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
{
::rtl::OUString aString;
// URL
const ::rtl::OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
if(xPropInfo->hasPropertyByName(sTargetURL))
{
if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
return aString;
}
}
}
catch( uno::Exception& )
{
}
}
// If hyperlink can't be got from sdrobject, query the corresponding document to retrieve the link info
uno::Reference< XAccessibleGroupPosition > xGroupPosition (shapeParent, uno::UNO_QUERY);
if (xGroupPosition.is())
return xGroupPosition->getObjectLink( uno::makeAny( shapeParent ) );
}
return ::rtl::OUString();
}
// Just check whether the first hyperlink is valid
sal_Bool SvxAccessibleHyperlink::IsValidHyperlink()
{
::rtl::OUString url = GetHyperlinkURL(0);
if (url.getLength() > 0)
return sal_True;
else
return sal_False;
}
// XAccessibleAction
sal_Int32 SAL_CALL SvxAccessibleHyperlink::getAccessibleActionCount()
throw (RuntimeException)
{
if (mpImageMap)
return mpImageMap->GetIMapObjectCount();
else
return 1; // only shape link or url field
//return mpField ? 1 : (mpImageMap ? mpImageMap->GetIMapObjectCount() : 0);
}
sal_Bool SAL_CALL SvxAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
OUString url = GetHyperlinkURL(nIndex);
if( url.getLength() > 0 )
{
SfxStringItem aStrItem(SID_FILE_NAME, url);
const SfxObjectShell* pDocSh = SfxObjectShell::Current();
if( pDocSh )
{
SfxMedium* pSfxMedium = pDocSh->GetMedium();
if( pSfxMedium)
{
SfxStringItem aReferer(SID_REFERER, pSfxMedium->GetName());
SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
SfxViewFrame* pFrame = SfxViewFrame::Current();
if( pFrame )
{
pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
&aStrItem, &aBrowseItem, &aReferer, 0L);
bRet = sal_True;
}
}
}
}
return bRet;
}
OUString SAL_CALL SvxAccessibleHyperlink::getAccessibleActionDescription(
sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException)
{
return GetHyperlinkURL(nIndex);
}
::com::sun::star::uno::Reference< XAccessibleKeyBinding > SAL_CALL
SvxAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 )
throw (IndexOutOfBoundsException, RuntimeException)
{
::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding;
if( mpField || m_pShape)
{
::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
new ::comphelper::OAccessibleKeyBindingHelper();
xKeyBinding = pKeyBindingHelper;
::com::sun::star::awt::KeyStroke aKeyStroke;
aKeyStroke.Modifiers = 0;
aKeyStroke.KeyCode = KEY_RETURN;
aKeyStroke.KeyChar = 0;
aKeyStroke.KeyFunc = 0;
pKeyBindingHelper->AddKeyBinding( aKeyStroke );
}
return xKeyBinding;
}
// XAccessibleHyperlink
Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionAnchor(
sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException)
{
Any aRet;
::rtl::OUString retText;
if(mpField && nIndex == 0)
{
retText = mpField->GetRepresentation();
aRet <<= retText;
return aRet;
}
else if(mpImageMap)
{
IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
if(pMapObj && pMapObj->GetURL().Len())
aRet <<= shapeParent;
return aRet;
}
else if (nIndex == 0)
{
aRet <<= shapeParent;
return aRet;
}
return aRet;
}
Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionObject(
sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException)
{
::rtl::OUString retText = GetHyperlinkURL(nIndex);
Any aRet;
aRet <<= retText;
return aRet;
}
sal_Int32 SAL_CALL SvxAccessibleHyperlink::getStartIndex()
throw (RuntimeException)
{
return nStartIdx;
}
sal_Int32 SAL_CALL SvxAccessibleHyperlink::getEndIndex()
throw (RuntimeException)
{
return nEndIdx;
}
sal_Bool SAL_CALL SvxAccessibleHyperlink::isValid( )
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
//return mpField ? sal_True: ( mpImageMap ? sal_True : sal_False );
if (mpField || m_pShape)
return sal_True;
else
return sal_False;
}
*/
| [
"boury.mbodj@mail.mcgill.ca"
] | boury.mbodj@mail.mcgill.ca |
5329782712fbde3e49a23d45c3b25195b0f0995a | 4ba0b403637e7aa3e18c9bafae32034e3c394fe4 | /cplusplus/wrencc2/utility.hh | 4dd3102f2ccbd03b7bc6bcba741e7a3e592f8af1 | [] | no_license | ASMlover/study | 3767868ddae63ac996e91b73700d40595dd1450f | 1331c8861fcefbef2813a2bdd1ee09c1f1ee46d6 | refs/heads/master | 2023-09-06T06:45:45.596981 | 2023-09-01T08:19:49 | 2023-09-01T08:19:49 | 7,519,677 | 23 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 2,833 | hh | // Copyright (c) 2019 ASMlover. 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 ofconditions 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 materialsprovided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <functional>
#include "common.hh"
#include "./container/string.hh"
#include "./container/array_list.hh"
namespace wrencc {
template <typename T>
using CompareFn = std::function<bool (const T&, const T&)>;
template <typename T>
inline bool __compare(const T& x, const T& y) { return x == y; }
template <typename T, typename Function = CompareFn<T>>
class DynamicTable final : private UnCopyable {
Function compare_{};
ArrayList<T> datas_;
public:
DynamicTable(Function&& fn = __compare<T>) noexcept
: compare_(std::move(fn)) {
}
inline int count() const noexcept { return Xt::as_type<int>(datas_.size()); }
inline void clear() noexcept { datas_.clear(); }
inline T& operator[](int i) noexcept { return datas_[i]; }
inline const T& operator[](int i) const noexcept { return datas_[i]; }
inline T& at(int i) noexcept { return datas_[i]; }
inline const T& at(int i) const noexcept { return datas_[i]; }
inline int append(const T& x) {
datas_.append(x);
return count() - 1;
}
inline int ensure(const T& x) {
if (int existing = find(x); existing != -1)
return existing;
return append(x);
}
inline int find(const T& x) {
for (int i = 0; i < count(); ++i) {
if (compare_(datas_[i], x))
return i;
}
return -1;
}
template <typename Function>
inline void for_each(Function&& fn) { datas_.for_each(fn); }
};
using SymbolTable = DynamicTable<String>;
}
| [
"asmlover@126.com"
] | asmlover@126.com |
6b49a2c7d2dca92bc2a0e185a6f2f7d10533d3cc | 9acaa2118fb9315d0c2ce59db5a51ee1d3f5ed40 | /include/Gaffer/Private/IECorePreview/LRUCache.h | cf6e0f85d9481e82fbc8c22bd82adea6ae6a7c6d | [
"BSD-3-Clause"
] | permissive | medubelko/gaffer | 9f65e70c29e340e4d0b74c92c878f7b6d234ebdd | 12c5994c21dcfb8b13b5b86efbcecdcb29202b33 | refs/heads/master | 2021-06-07T16:29:54.862429 | 2020-05-22T11:55:16 | 2020-05-22T11:55:16 | 129,820,571 | 1 | 0 | NOASSERTION | 2019-06-14T18:53:40 | 2018-04-16T23:59:50 | C++ | UTF-8 | C++ | false | false | 8,459 | h | //////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2014, Image Engine Design Inc. 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 Image Engine Design nor the names of any
// other contributors to this software 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.
//
//////////////////////////////////////////////////////////////////////////
#ifndef IECOREPREVIEW_LRUCACHE_H
#define IECOREPREVIEW_LRUCACHE_H
#include "boost/function.hpp"
#include "boost/noncopyable.hpp"
#include "boost/variant.hpp"
namespace IECorePreview
{
namespace LRUCachePolicy
{
/// Not threadsafe. Either use from only a single thread
/// or protect with an external mutex. Key type must have
/// a `hash_value` implementation as described in the boost
/// documentation.
template<typename LRUCache>
class Serial;
/// Threadsafe, `get()` blocks if another thread is already
/// computing the value. Key type must have a `hash_value`
/// implementation as described in the boost documentation.
template<typename LRUCache>
class Parallel;
/// Threadsafe, `get()` collaborates on TBB tasks if another
/// thread is already computing the value. Key type must have
/// a `hash_value` implementation as described in the boost
/// documentation.
///
/// > Note : There is measurable overhead in the task collaboration
/// > mechanism, so if it is known that tasks will not be spawned for
/// > `GetterFunction( getterKey )` you may define a `bool spawnsTasks( const GetterKey & )`
/// > function that will be used to avoid the overhead.
template<typename LRUCache>
class TaskParallel;
} // namespace LRUCachePolicy
/// A mapping from keys to values, where values are computed from keys using a user
/// supplied function. Recently computed values are stored in the cache to accelerate
/// subsequent lookups. Each value has a cost associated with it, and the cache has
/// a maximum total cost above which it will remove the least recently accessed items.
///
/// The Value type must be default constructible, copy constructible and assignable.
/// Note that Values are returned by value, and erased by assigning a default constructed
/// value. In practice this means that a smart pointer is the best choice of Value.
///
/// The Policy determines the thread safety, eviction and performance characteristics
/// of the cache. See the documentation for each individual policy in the LRUCachePolicy
/// namespace.
///
/// The GetterKey may be used where the GetterFunction requires some auxiliary information
/// in addition to the Key. It must be implicitly castable to Key, and all GetterKeys
/// which yield the same Key must also yield the same results from the GetterFunction.
///
/// \ingroup utilityGroup
template<typename Key, typename Value, template <typename> class Policy=LRUCachePolicy::Parallel, typename GetterKey=Key>
class LRUCache : private boost::noncopyable
{
public:
typedef size_t Cost;
typedef Key KeyType;
/// The GetterFunction is responsible for computing the value and cost for a cache entry
/// when given the key. It should throw a descriptive exception if it can't get the data for
/// any reason.
typedef boost::function<Value ( const GetterKey &key, Cost &cost )> GetterFunction;
/// The optional RemovalCallback is called whenever an item is discarded from the cache.
typedef boost::function<void ( const Key &key, const Value &data )> RemovalCallback;
LRUCache( GetterFunction getter );
LRUCache( GetterFunction getter, Cost maxCost );
LRUCache( GetterFunction getter, RemovalCallback removalCallback, Cost maxCost );
virtual ~LRUCache();
/// Retrieves an item from the cache, computing it if necessary.
/// The item is returned by value, as it may be removed from the
/// cache at any time by operations on another thread, or may not
/// even be stored in the cache if it exceeds the maximum cost.
/// Throws if the item can not be computed.
Value get( const GetterKey &key );
/// Adds an item to the cache directly, bypassing the GetterFunction.
/// Returns true for success and false on failure - failure can occur
/// if the cost exceeds the maximum cost for the cache. Note that even
/// when true is returned, the item may be removed from the cache by a
/// subsequent (or concurrent) operation.
bool set( const Key &key, const Value &value, Cost cost );
/// Returns true if the object is in the cache. Note that the
/// return value may be invalidated immediately by operations performed
/// by another thread.
bool cached( const Key &key ) const;
/// Erases the item if it was cached. Returns true if it was cached
/// and false if it wasn't cached and therefore wasn't removed.
bool erase( const Key &key );
/// Erases all cached items. Note that when this returns, the cache
/// may have been repopulated with items if other threads have called
/// set() or get() concurrently.
void clear();
/// Sets the maximum cost of the items held in the cache, discarding any
/// items if necessary to meet the new limit.
void setMaxCost( Cost maxCost );
/// Returns the maximum cost.
Cost getMaxCost() const;
/// Returns the current cost of all cached items.
Cost currentCost() const;
private :
// Data
//////////////////////////////////////////////////////////////////////////
// Give Policy access to CacheEntry definitions.
friend class Policy<LRUCache>;
// A function for computing values, and one for notifying of removals.
GetterFunction m_getter;
RemovalCallback m_removalCallback;
// Status of each item in the cache.
enum Status
{
Uncached, // entry without valid value
Cached, // entry with valid value
Failed // m_getter failed when computing entry
};
// The type used to store a single cached item.
struct CacheEntry
{
CacheEntry();
// We use a boost::variant to compactly store
// a union of the data needed for each Status.
//
// - Uncached : A boost::blank instance
// - Cached : The Value itself
// - Failed ; The exception thrown by the GetterFn
typedef boost::variant<boost::blank, Value, std::exception_ptr> State;
State state;
Cost cost; // the cost for this item
Status status() const;
};
// Policy. This is responsible for
// the internal storage for the cache.
Policy<LRUCache> m_policy;
Cost m_maxCost;
// Methods
// =======
// Updates the cached value and updates the current
// total cost.
bool setInternal( const Key &key, CacheEntry &cacheEntry, const Value &value, Cost cost );
// Removes any cached value and updates the current total
// cost.
bool eraseInternal( const Key &key, CacheEntry &cacheEntry );
// Removes items from the cache until the current cost is
// at or below the specified limit.
void limitCost( Cost cost );
static void nullRemovalCallback( const Key &key, const Value &value );
};
} // namespace IECorePreview
#include "Gaffer/Private/IECorePreview/LRUCache.inl"
#endif // IECOREPREVIEW_LRUCACHE_H
| [
"thehaddonyoof@gmail.com"
] | thehaddonyoof@gmail.com |
a3b5ad2b5c9750dd4625ffd1115900481b9449cd | 68cf71d51d1ec73432eac938d61300b2705bceb2 | /src/nstl/hash/testLinearProbingHashTime.cc | 6f7dda2ec606a5d7bc0d049bd9f0db2f4e685385 | [] | no_license | ciklon-z/v4abs | ed72583475d1a818b830572b074b2fcf938b2a6d | 6ef899eafc1f7df98d7d7cf9bf454e907be5a898 | refs/heads/master | 2021-01-14T08:32:08.419868 | 2014-09-15T08:27:56 | 2014-09-15T08:27:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 561 | cc | #include "test/UnitTest.h"
#include "HashTable.h"
#include "Random.h"
#include "Config.h"
#define DEBUG_EXPR(expr) do { std::cerr << #expr << " : " << (expr) << " @ (" << __FILE__ << " : "<< __LINE__ << ")" << std::endl; } while(0)
void test_linear_probing_hash_time() {
HashTable<int> hash;
// const size_t valSize = 1000;
const size_t valSize = kVariableSize;
for (size_t i = 0; i < valSize; ++i)
hash.insert(Random<int>::get());
UNIT_TEST_FUNCTION_END_FUNCTION_TEST();
}
int main() {
test_linear_probing_hash_time();
}
| [
"chiahsun0814@gmail.com"
] | chiahsun0814@gmail.com |
9d7ea7ede7ee53228e266ff35c7208ad8c026737 | 6e790b19299272268806f8808d759a80401f8825 | /DX/DX/src/Include/GameplayLayer/Components/transform.h | aed2dd78f56f6d7c391504cd43dc11424bb07f7e | [] | no_license | SilvanVR/DX | 8e80703e7ce015d287ba3ebc2fc0d78085d312f1 | 0fd7ec94e8d868c7a087f95f9dda60e97df38682 | refs/heads/master | 2023-07-16T01:42:48.306869 | 2021-08-28T02:36:32 | 2021-08-28T02:36:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,998 | h | #pragma once
/**********************************************************************
class: Transform (transform.h)
author: S. Hau
date: December 17, 2017
**********************************************************************/
#include "i_component.h"
namespace Components {
//**********************************************************************
class Transform : public IComponent
{
public:
Transform() {}
Math::Vec3 position = Math::Vec3( 0.0f, 0.0f, 0.0f );
Math::Vec3 scale = Math::Vec3( 1.0f, 1.0f, 1.0f );
Math::Quat rotation = Math::Quat( 0.0f, 0.0f, 0.0f, 1.0f );
const ArrayList<Transform*>& getChildren() const { return m_pChildren; }
const Transform* getParent() const { return m_pParent; }
Math::Vec3 getWorldPosition() const;
Math::Vec3 getWorldScale() const;
Math::Quat getWorldRotation() const;
void getWorldTransform(Math::Vec3* pos, Math::Vec3* scale, Math::Quat* quat);
//----------------------------------------------------------------------
// Rotates this transform to look at the given target.
// (P.S. This might be incorrect if the target has the opposite direction from the world up vector i.e. looking straight down)
//----------------------------------------------------------------------
void lookAt(const Math::Vec3& target);
//----------------------------------------------------------------------
// Set the parent for this transform component.
// @Params:
// "t": This transform becomes the new parent transform.
// "keepWorldTransform": If true, this component will keep the current world transform.
//----------------------------------------------------------------------
void setParent(Transform* t, bool keepWorldTransform = true);
//----------------------------------------------------------------------
// Add a child to this transform.
// @Params:
// "t": This transform becomes the new child.
// "keepWorldTransform": If true, the child will keep his current world transform.
//----------------------------------------------------------------------
void addChild(Transform* t, bool keepWorldTransform = true);
//----------------------------------------------------------------------
// Returns the final composited world transformation matrix.
//----------------------------------------------------------------------
DirectX::XMMATRIX getWorldMatrix() const;
private:
Transform* m_pParent = nullptr;
ArrayList<Transform*> m_pChildren;
inline void _RemoveFromParent();
inline DirectX::XMMATRIX _GetLocalTransformationMatrix() const;
NULL_COPY_AND_ASSIGN(Transform)
};
} | [
"silvan-hau@web.de"
] | silvan-hau@web.de |
93c96235718204222ae41cd86e0baf3e790cc49e | f4e4d657944eae561d009cd29650219539a2333b | /src/Core/Input.h | 1e738903f28612eb87bdb3bfe6f00e8558041df9 | [] | no_license | antopilo/OpenGLSandbox | bbada90d31f86c0c3d28f7aa50876c9fcc49fdc0 | 2a80d069c0ab36b8e0fc28c87091e9a7cac28e9d | refs/heads/master | 2023-04-08T02:29:18.839751 | 2021-04-13T17:10:26 | 2021-04-13T17:10:26 | 324,453,168 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 511 | h | #pragma once
#include <utility>
class Input
{
public:
static bool IsKeyPressed(int keycode);
static bool IsKeyPress(int keycode);
static bool IsKeyReleased(int keycode);
static bool IsMouseButtonPressed(int button);
static void HideMouse();
static void ShowMouse();
static bool IsMouseHidden();
static float GetMouseX();
static float GetMouseY();
static std::pair<float, float> GetMousePosition();
static bool Init();
Input* Get() { return s_Instance; }
private:
static Input* s_Instance;
};
| [
"antoinepilote1@hotmail.com"
] | antoinepilote1@hotmail.com |
4f63ee106f489751690222d8a58da8470a2ba0cd | daf6dd0d2db12106bfc1202586781ef9f658fe42 | /Basic Codes/DhakaSim-qt/qt/qt/userinterface-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/ui_plot.h | 9b4bce504e8c06a8af9acd51e0b3966c13e4b0af | [] | no_license | bejon028/DhakaTrafficeSimulator | 359e89afe5c590c821441aea44e4b0bce98b4b00 | ff9d38d9cdb42ce45c8fc0542c705e55b2215fe7 | refs/heads/master | 2021-01-22T04:18:08.987528 | 2017-02-10T05:28:23 | 2017-02-10T05:28:23 | 81,529,918 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,030 | h | /********************************************************************************
** Form generated from reading UI file 'plot.ui'
**
** Created by: Qt User Interface Compiler version 5.0.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_PLOT_H
#define UI_PLOT_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QWidget>
#include "qcustomplot.h"
QT_BEGIN_NAMESPACE
class Ui_plot
{
public:
QWidget *centralwidget;
QCustomPlot *widget;
QMenuBar *menubar;
QStatusBar *statusbar;
void setupUi(QMainWindow *plot)
{
if (plot->objectName().isEmpty())
plot->setObjectName(QStringLiteral("plot"));
plot->resize(555, 431);
centralwidget = new QWidget(plot);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
widget = new QCustomPlot(centralwidget);
widget->setObjectName(QStringLiteral("widget"));
widget->setGeometry(QRect(30, 20, 491, 361));
plot->setCentralWidget(centralwidget);
menubar = new QMenuBar(plot);
menubar->setObjectName(QStringLiteral("menubar"));
menubar->setGeometry(QRect(0, 0, 555, 21));
plot->setMenuBar(menubar);
statusbar = new QStatusBar(plot);
statusbar->setObjectName(QStringLiteral("statusbar"));
plot->setStatusBar(statusbar);
retranslateUi(plot);
QMetaObject::connectSlotsByName(plot);
} // setupUi
void retranslateUi(QMainWindow *plot)
{
plot->setWindowTitle(QApplication::translate("plot", "MainWindow", 0));
} // retranslateUi
};
namespace Ui {
class plot: public Ui_plot {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_PLOT_H
| [
"bejon.sarker@konasl.com"
] | bejon.sarker@konasl.com |
476aa8997fc3ad92c2471657b2330fb91eb6ab6f | 4deeef97bd5346899c463bc92c564990cb56fc9c | /lab1/sketch_part3/sketch_part3.ino | 70a12d9b7ecbd73addc32d4bd6cbb35a1e3d0b2f | [] | no_license | daveyproctor/Arduino | f5bd73ab2292e8cf931fdce5881e30a1a578a04e | 45d51524c149ed61a22be1585e6b0ef8808b60a2 | refs/heads/master | 2020-04-21T10:25:17.114535 | 2019-05-03T20:03:33 | 2019-05-03T20:03:33 | 169,485,836 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | ino | #include "testasm.h"
void setup() {
// put your setup code here, to run once
Serial.begin(9600);
Serial.print("The third Fibonacci number is ");
Serial.println(testasm(3));
Serial.print("The fifth Fibonacci number is ");
Serial.println(testasm(5));
Serial.print("The seventh Fibonacci number is ");
Serial.println(testasm(7));
Serial.print("The tenth Fibonacci number is ");
Serial.println(testasm(10));
Serial.print("The sixteenth Fibonacci number is ");
Serial.println(testasm(16));
pinMode (13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (13, HIGH);
delay(400);
digitalWrite (13, LOW);
delay(400);
}
| [
"david.proctor@yale.edu"
] | david.proctor@yale.edu |
ba234220c3f041b427529742e3ac9f3871cdbe6e | 9381784914cff5dcb9d168fde6401757bd4b55f8 | /DSU on trees/D. Distance in Tree.cpp | 0c40fc2f5a3357ac5e7b895e54e5d9715fa2508c | [] | no_license | AhmedMorgan/morganslib | d4aa4cda2d2a83376910548faa83c5fd334f4005 | 3322bcfc1f543596e9e8659324bbcdf8a8b66db7 | refs/heads/master | 2020-08-06T03:01:15.600413 | 2019-10-04T12:29:40 | 2019-10-04T12:29:40 | 212,809,537 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,876 | cpp | #include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define PI 3.1415926535897932384626433832
#define MOD 1000000007
#define MOD2 1000000009
#define bas 29
#define bas2 19
using namespace std;
const int len = 5e4 + 9;
int n, k, x, y;
vector<int> *vec[len];
int cnt[len * 2];
int cnt1[len * 2];
int lev[len];
int siz[len];
ll res = 0;
vector<vector<int> > g(len, vector<int>());
void dfsForLevel(int v, int p, int level){
lev[v] = level;
for(auto u: g[v]){
if(u != p)
dfsForLevel(u, v, level + 1);
}
}
int dfssz(int v, int p){
int sum = 1;
for(auto u : g[v]){
if(u != p)
sum += dfssz(u, v);
}
siz[v] = sum;
return sum;
}
void dfs(int v, int p, bool keep){
int sz = -1, mx = -1;
for(auto u : g[v]){
if(u != p && siz[u] > sz){
sz = siz[u];
mx = u;
}
}
for(auto u : g[v]){
if(u != p && u != mx){
dfs(u, v, 0);
}
}
if(mx != -1) dfs(mx, v, 1), vec[v] = vec[mx];
else vec[v] = new vector<int>();
vec[v]->push_back(v);
cnt[ lev[v] ]++;
for(auto u : g[v]){
if(u == mx || u == p)continue;
for(auto x : *vec[u]){
cnt1[ lev[x] ]++;
vec[v]->push_back(x);
}
for(int i = 1; i <= k; i++){
res += cnt[ lev[v] + i ] * cnt1[ lev[v] + k - i ];
}
for(auto x : *vec[u]){
cnt1[ lev[x] ]--;
cnt[lev[x]]++;
}
}
res += cnt[lev[v] + k];
if(!keep){
for(auto u : *vec[v]){
cnt[ lev[u] ]--;
}
}
}
int main(){
scanf("%d%d", &n, &k);
for(int i = 1; i < n; i++){
scanf("%d%d", &x, &y);
g[x].push_back(y);
g[y].push_back(x);
}
dfsForLevel(1, -1, 0);
dfssz(1, -1);
dfs(1, -1, 1);
printf("%lld", res);
}
| [
"medo.morgan22@gmail.com"
] | medo.morgan22@gmail.com |
8adc9b7cf1ec69be388ec6b6ac028251e82e755a | a7e3f6b805cabe1c906fb94430a8aadd9b3eab7c | /BloggerProxyModel.cpp | 7fdc19414ca801119e54b6a52842ffd9904cb231 | [] | no_license | luisfilipegoncalves/bloggerQml | 5d4be3b4d9e01611f20a8f8e6d762028515b4cb0 | c5476b03532215c48c8328679df918462ba2644a | refs/heads/master | 2020-12-24T15:32:39.051595 | 2013-11-04T23:28:07 | 2013-11-04T23:28:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,101 | cpp | #include "BloggerProxyModel.h"
#include "BlogModel.h"
#include "BloggerLoader.h"
#include <QDate>
#include <QDebug>
#include <QUuid>
BloggerProxyModel::BloggerProxyModel(QObject *parent) :
QSortFilterProxyModel(parent)
{
}
void BloggerProxyModel::search(const QString &text)
{
setFilterWildcard(text);
}
bool BloggerProxyModel::tryAddBlog(QString name, QString url, int rating, QString lastDateStr, QString note)
{
BlogModel *model = qobject_cast<BlogModel*>(sourceModel());
if(!model)
return false;
qDebug() << "try to add new blog...";
qDebug() << "name: " << name;
qDebug() << "url: " << url;
qDebug() << "rating: " << rating;
qDebug() << "lastDate: " << lastDateStr;
qDebug() << "note: " << note;
QDate lastDate = QDate::fromString(lastDateStr, "dd-MM-yyyy");
QDate nextdate;
if(!lastDate.isNull())
nextdate = BloggerLoader::nextDate(lastDate, rating);
QString id = QUuid::createUuid().toString();
model->addBlog(name, url, rating, lastDateStr, nextdate.toString("dd-MM-yyyy"), note, id);
return true;
}
QString BloggerProxyModel::deleteBlog(int row)
{
qDebug() << "Delete blog row: " << row;
QModelIndex sourceIndex = mapToSource(index(row, 0));
QString name = sourceIndex.data(Qt::DisplayRole).toString();
qDebug() << "Delete blog source index: " << sourceIndex << name;
bool deleted = sourceModel()->removeRow(sourceIndex.row());
qDebug() << "Deleted ? " << deleted;
if(deleted)
return name;
else
return QString(); // false or failled to remove
}
bool BloggerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
QString url = index.data(Qt::UserRole+1).toString();
QString note = index.data(Qt::UserRole+5).toString();
QRegExp regE = filterRegExp();
if(url.contains(regE))
return true;
else if(note.contains(regE))
return true;
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
| [
"exnlesi@gmail.com"
] | exnlesi@gmail.com |
5a5e1a5fd44f384b715f4d5b9586cada29845623 | f969f027e98c3d5106c423e57ea4fc7d2903a8fb | /AddTwoNumbers.cpp | c59385aec5c0ad6f1359dd4bf9b64a35fb3728cb | [] | no_license | BenQuickDeNN/LeetCodeSolutions | eb2e1e3d2f13621f4d603e26f28a0fce2af75f1b | 4165aca74114e9841a312b27ccc4a807a9fd65e5 | refs/heads/master | 2023-09-04T12:02:24.846562 | 2021-11-13T03:44:11 | 2021-11-13T03:44:11 | 255,344,497 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,856 | cpp | /*****************************************************************************************************
* 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储
* 一位 数字。
* 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。
* 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。
* 示例:
* ----------------------------------------
* 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)
* 输出:7 -> 0 -> 8
* 原因:342 + 465 = 807
* ---------------------------------------
* Algorithm:
* 就像你在纸上计算两个数字的和那样,我们首先从最低有效位也就是列表 l1l1l1 和 l2l2l2 的表头开始相加。由于每位数字都应当
* 处于 0…90 \ldots 90…9 的范围内,我们计算两个数字的和时可能会出现 “溢出”。例如,5+7=125 + 7 = 125+7=12。在这种情
* 况下,我们会将当前位的数值设置为 222,并将进位 carry=1carry = 1carry=1 带入下一次迭代。进位 carrycarrycarry 必
* 定是 000 或 111,这是因为两个数字相加(考虑到进位)可能出现的最大和为 9+9+1=199 + 9 + 1 = 199+9+1=19。
* 作者:LeetCode
* 链接:https://leetcode-cn.com/problems/add-two-numbers/solution/liang-shu-xiang-jia-by-leetcode/
* 来源:力扣(LeetCode)
* 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
*****************************************************************************************************/
#include <cstdio>
/// Definition for singly-linked list.
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution
{
public:
static ListNode* addTwoNumbers(ListNode* l1, ListNode* l2)
{
if (l1 != NULL && l2 == NULL)
return l1;
else if (l1 == NULL && l2 != NULL)
return l2;
else if (l1 == NULL && l2 == NULL)
return NULL;
bool carry = false;
bool flag_l1_end = false;
bool flag_l2_end = false;
ListNode *l1_sIdx = l1; // recording the address of l1
while (true)
{
if (carry) // flag_l1_end must be false
{
if (!flag_l2_end)
l1->val += l2->val + 1;
else
l1->val++;
}
else
{
if (!flag_l1_end && !flag_l2_end)
l1->val += l2->val;
else if (flag_l1_end && !flag_l2_end)
l1->next = l2;
}
if (l1->val < 10)
carry = false;
else
{
l1->val %= 10;
// carry
carry = true;
if (l1->next == NULL)
l1->next = new ListNode(0);
}
if (l1->next == NULL && l2->next == NULL)
break;
if (l1->next != NULL)
l1 = l1->next;
else
flag_l1_end = true;
if (l2->next != NULL)
l2 = l2->next;
else
flag_l2_end = true;
}
return l1_sIdx;
}
};
int main()
{
ListNode *p_l1 = new ListNode(0);
ListNode *p_l2 = new ListNode(7);
//p_l1->next = new ListNode(9);
//p_l1->next->next = new ListNode(9);
p_l2->next = new ListNode(3);
//p_l2->next->next = new ListNode(4);
ListNode *result = Solution::addTwoNumbers(p_l1, p_l2);
while (true)
{
printf("%d, ", result->val);
if (result->next != NULL)
result = result->next;
else
break;
}
printf("\r\n");
} | [
"benquickdenn@foxmail.com"
] | benquickdenn@foxmail.com |
0d43252d8907b5ff2c44660ec56cbe21568d0d75 | f2339e85157027dada17fadd67c163ecb8627909 | /Server/Spell/Include/ISpell.h | 80d3e4b089a3bd94830a24166fd658f399152cc7 | [] | no_license | fynbntl/Titan | 7ed8869377676b4c5b96df953570d9b4c4b9b102 | b069b7a2d90f4d67c072e7c96fe341a18fedcfe7 | refs/heads/master | 2021-09-01T22:52:37.516407 | 2017-12-29T01:59:29 | 2017-12-29T01:59:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,101 | h | /*******************************************************************
** 文件名: ISpell.h
** 版 权: (C) 深圳冰川网络技术有限公司 2008 - All Rights Reserved
** 创建人: 陈涛 (Carl Chen)
** 日 期: 1/8/2015
** 版 本: 1.0
** 描 述:
技能系统接口
********************************************************************/
#pragma once
#include "IEntity.h"
#include "SpellDef.h"
using namespace SPELL;
struct ATTACK_DATA;
struct IAttackObject;
struct SPELL_CONTEXT;
// ================================================================================//
/**
技能接口:
1.单个技能接口,负责维护技能施放逻辑,及技能相关的天赋数据
*/
// ================================================================================//
struct ISpell : public IEventExecuteSink
{
// 载入技能
// @param pEntity: 技能实体指针(属于某实体,同步方便)
virtual void onLoad(__IEntity *pEntity, SLOT_TYPE nSlotType, int nSlotIndex, int nAddCoolTime) = 0;
// 取得技能ID
virtual int getID() = 0;
// 克隆一个技能对象,因为每个玩家都需要一个
virtual ISpell * clone() = 0;
// 获取状态标志,例如攻击计数,是否在吟唱状态
virtual int getFlag(int nIndex) = 0;
// 设置状态标志: 这个状态标志可以有很多功能,例如攻击计数
virtual void setFlag( int nIndex, int nFlag ) = 0;
// 获取某个技能数值
virtual int getSpellData( SPELL_DATA_ID nIndex ) = 0;
// 获取某个技能数值
virtual const char * getSpellDataStr( SPELL_DATA_ID nIndex ) = 0;
virtual bool addTalent(int nTalentID) = 0;
// 添加天赋数据: 天赋数据可对技能数值进行影响
// @param nTalentID : 天赋ID,可以用这个ID查到天赋说明,同一个天赋ID是不能重复添加的
// @param isAdd : 是增加数值还是直接设置数值
// @param nIndex: 技能数值索引
// @param nValue: 数值大小
// @param nToken: 令牌(删除时传入同样令牌可移除天赋)
//virtual bool addTalent( int nTalentID,bool isAdd,SPELL_DATA_ID nIndex,int nValue) = 0;
// 添加天赋数据: 天赋数据可对技能数值进行影响,同一个天赋ID是不能重复添加的
// @param nTalentID : 天赋ID,可以用这个ID查到天赋说明
// @param nIndex: 技能数值索引
// @param nValue: 数值大小
// @param nToken: 令牌(删除时传入同样令牌可移除天赋)
//virtual bool addTalent( int nTalentID,SPELL_DATA_ID nIndex,const char * szValue ) = 0;
// 移除天赋数据
// @param nToken : 添加时传入的令牌
virtual bool removeTalent( int nTalentID ) = 0;
// 更新技能数据
// @param pData : 除技能ID外,其他都可改变,连招用时,目前只支持同类型的技能连招
virtual void updateSpellData( SPELL_DATA * pData ) = 0;
// 处理施法事件:
virtual bool onSpellEvent( SPELL_EVENT nEventID,SPELL_CONTEXT * context ) = 0;
// 该技能是否已经发动
virtual bool isWorking() = 0;
// 取得天赋数量
virtual int getTalentCount(void) = 0;
// 取得天赋数据
// @param nIndex : 天赋索引位置
virtual SPELL_TALENT *getTalentData(int nIndex) = 0;
// 更新技能现场
// @param uidTarget : 目标ID
// @param ptTargetTile : 目标点
virtual void updateSpellContext(UID uidTarget, Vector3 ptTargetTile) = 0;
// 增加实体(需要管理的对象实体,调用此接口保存)
// 因为lol中有道具有召唤怪物功能,所以此放到技能里面,对应技能管理召唤对象(一个英雄可能多个这种技能)
// @param uidEntity : 实体UID
// @param nMaxCount : 最大实体数量
virtual void addEntity(UID uidEntity, int nMaxCount) = 0;
// 移除实体(移除管理的对象实体)
// @param uidEntity : 实体UID
virtual void removeEntity(UID uidEntity) = 0;
// 取得槽位类型
virtual SLOT_TYPE getSlotType(void) = 0;
// 取得槽位索引
virtual int getSlotIndex(void) = 0;
// 获得技能数据
virtual SPELL_DATA *getSpellData(void) = 0;
// 设置某个技能数值
virtual void setSpellData(SPELL_DATA_ID nIndex, int nIndexData, const char* pData) = 0;
// 获取当前技能上下文
virtual SPELL_CONTEXT* getCurSpellContext() = 0;
// 获取技能状态
virtual int getState() = 0;
// 设置Key值
virtual void setKey(DWORD dwKey) = 0;
// 获取Key值
virtual DWORD getKey(void) = 0;
// 销毁技能
virtual void release() = 0;
};
// ================================================================================//
/**
实体部件接口,继承该接口可以挂接到实体上
注意:::::::::::::::::::::::::::::::::::
1.每个玩家都是一个独立协程,所以Part的实现中如果需要访问全局数据,一定要注意线程安全
2.一个玩家的多个Part直接互相调用是线程安全的,可以放心使用
*/
// ================================================================================//
struct __ISpellPart : public __IEntityPart
{
// 取得技能数量
virtual int getSpellCount() = 0;
// 取得第一个技能
virtual ISpell *getFirstSpell(void) = 0;
// 取得下一个技能
virtual ISpell *getNextSpell(void) = 0;
// 查找技能
virtual ISpell * findSpell( int nSpellID ) = 0;
// 添加技能
// @param nSpellID : 技能ID
// @param nSlotType : 槽位类型
// @param nSlotIndex: 槽位索引
// @param nAddCoolTime: 增加冷却,有些技能技能上次升级技能冷却
virtual bool addSpell(int nSpellID, SLOT_TYPE nSlotType=SLOT_TYPE_SKILL, int nSlotIndex=SPELL_SLOT_MAX_COUNT, int nAddCoolTime = 0) = 0;
// 移除技能
virtual bool removeSpell(int nSpellID) = 0;
// 施法技能
virtual bool castSpell( SPELL_CONTEXT * context ) = 0;
// 升级技能
// @param nSlotIndex : 槽位索引
virtual bool upgradeSpell( int nSlotIndex ) = 0;
// 取得最后施法时间
virtual DWORD getLastCastTime(void) = 0;
// 设置僵直时间
virtual void setRigidityTime( int nTime,int nSpellEffectType, int nCastFlag ) = 0;
// 取得是否已创建实体(此函数用来知道技能和天赋改变是否需要同步客户,
// 未创建实体时改变了技能和天赋通过deSerialize打包技能和天赋数据)
virtual bool getCreateEntity(void) = 0;
// 激活天赋(用作外部接口时,作为临时天赋 并不会判断激活条件,直接激活)
// bCost需要消耗点数,有些天赋是需要金钱激活的,但用户断线重连进来,已激活的不消耗
virtual bool activeTalent(int nTalentID, bool bCost = true) = 0;
// 取消天赋
virtual void deActiveTalent(int nTalentID) = 0;
// 创建一个攻击对象
// @param type : 攻击类型
// @param pAttack : 攻击数据
// @param pContext: 攻击现场
// @return : 返回攻击对象序号
virtual DWORD createAttackObject( ATTACK_TYPE type,ATTACK_DATA * pAttack,SPELL_CONTEXT * pContext ) = 0;
// 取得攻击对象
// @param dwSerialID : 对象序列号
// @return : 攻击对象
virtual IAttackObject *getAttackObject(DWORD dwSerialID) = 0;
// 关闭攻击对象
// @param dwSerialID : 对象序列号
virtual void closeAttackObject(DWORD dwSerialID) = 0;
// 增加技能点数
// @param nPoint : 技能点数
virtual void addSpellPoint(int nPoint) = 0;
// 获得技能点数
// @return : 获得技能点数
virtual int getSpellPoint() = 0;
// 取得技能槽等级
virtual int getSpellSlotLevel(int nSlotIndex) = 0;
// 设置技能槽位
virtual void setSpellSlotLevel(int nSlotIndex, int nLevel) = 0;
// 创建攻击对象序列号
virtual DWORD CreateAttackObjectSerialID(void) = 0;
};
// ================================================================================//
/**
技能工厂: 加载技能模版,并创建技能
*/
// ================================================================================//
struct ISpellFactory
{
// 装载脚本
// @param szDataFile : 技能数据脚本
// @param szLogicFile: 技能逻辑脚本
virtual bool Load(const char * szDataFile,const char * szLogicFile) = 0;
// 获取技能配置数据
virtual SPELL_DATA * getSpellData( int nSpellID ) = 0;
// 创建一个技能
virtual ISpell * createSpell( int nSpellID ) = 0;
// 创建一个技能部件
virtual __ISpellPart * createSpellPart() = 0;
// 执行Service的on_stop
virtual void onStop(void) = 0;
virtual void release() = 0;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
#include "LoadLib.h"
#if defined(_LIB) || defined(SPELL_STATIC_LIB) /// 静态库版本
# pragma comment(lib, MAKE_LIB_NAME(Spell))
extern "C" ISpellFactory * CreateSpellFactory();
# define CreateSpellFactoryProc CreateSpellFactory
#else /// 动态库版本
typedef ISpellFactory * (RKT_CDECL * procCreateSpellFactory)();
# define CreateSpellFactoryProc DllApi<procCreateSpellFactory>::load(MAKE_DLL_NAME(Spell), "CreateSpellFactory")
#endif
| [
"85789685@qq.com"
] | 85789685@qq.com |
e9184190cb114af611343297ae5a083184297aa0 | 81e71315f2f9e78704b29a5688ba2889928483bb | /include/crutil/crCollectOccludersVisitor.h | 30bca079bf43d4da4a73334068212273a6c33e52 | [] | no_license | Creature3D/Creature3DApi | 2c95c1c0089e75ad4a8e760366d0dd2d11564389 | b284e6db7e0d8e957295fb9207e39623529cdb4d | refs/heads/master | 2022-11-13T07:19:58.678696 | 2019-07-06T05:48:10 | 2019-07-06T05:48:10 | 274,064,341 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,976 | h | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* 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
* OpenSceneGraph Public License for more details.
*/
//Modified by Wucaihua
#ifndef CRUTIL_CRCOLLECTOCCLUDERSVISITOR_H
#define CRUTIL_CRCOLLECTOCCLUDERSVISITOR_H 1
#include <CRUtil/crExport.h>
#include <CRCore/crNodeVisitor.h>
#include <CRCore/crCullStack.h>
#include <set>
namespace CRUtil {
class CRUTIL_EXPORT crCollectOccludersVisitor : public CRCore::crNodeVisitor, public CRCore::crCullStack
{
public:
typedef std::set<CRCore::crShadowVolumeOccluder> ShadowVolumeOccluderSet;
crCollectOccludersVisitor();
virtual ~crCollectOccludersVisitor();
virtual crCollectOccludersVisitor* cloneType() const { return new crCollectOccludersVisitor(); }
virtual void reset();
virtual float getDistanceToEyePoint(const CRCore::crVector3& pos, bool withLODScale) const;
virtual float getDistanceFromEyePoint(const CRCore::crVector3& pos, bool withLODScale) const;
virtual void apply(CRCore::crNode&);
//virtual void apply(CRCore::crObject&);
//virtual void apply(CRCore::crDrawable&);
virtual void apply(CRCore::crTransform& node);
virtual void apply(CRCore::crProjection& node);
virtual void apply(CRCore::crSwitch& node);
virtual void apply(CRCore::crLod& node);
virtual void apply(CRCore::crOccluderNode& node);
/** Set the minimum shadow occluder volume that an active occluder must have.
* volume is units relative the clip space volume where 1.0 is the whole clip space.*/
void setMinimumShadowOccluderVolume(float vol) { m_minShadowOccluderVolume = vol; }
float getMinimumShadowOccluderVolume() const { return m_minShadowOccluderVolume; }
/** Set the maximum number of occluders to have active for culling purposes.*/
void setMaximumNumberOfActiveOccluders(unsigned int num) { m_maxNumberOfActiveOccluders = num; }
unsigned int getMaximumNumberOfActiveOccluders() const { return m_maxNumberOfActiveOccluders; }
// void setMaximumNumberOfCollectOccluders(unsigned int num) { m_maxNumberOfCollectOccluders = num; }
void setCreateDrawablesOnOccludeNodes(bool flag) { m_createDrawables=flag; }
bool getCreateDrawablesOnOccludeNodes() const { return m_createDrawables; }
void setCollectedOcculderList(const ShadowVolumeOccluderSet& svol) { m_occluderSet = svol; }
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return m_occluderSet; }
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return m_occluderSet; }
/** remove occluded occluders for the collected occluders list,
* and then discard of all but MaximumNumberOfActiveOccluders of occluders,
* discarding the occluders with the lowests shadow occluder volume .*/
void removeOccludedOccluders();
//void creatOccluder(const crVector3& v1,const crVector3& v2,const crVector3& v3,const crVector3& v4);
protected:
/** prevent unwanted copy construction.*/
//crCollectOccludersVisitor(const crCollectOccludersVisitor&):CRCore::crNodeVisitor(),CRCore::crCullStack() {}
/** prevent unwanted copy operator.*/
crCollectOccludersVisitor& operator = (const crCollectOccludersVisitor&) { return *this; }
inline void handle_cull_callbacks_and_traverse(CRCore::crNode& node)
{
/*CRCore::crNodeCallback* callback = node.getCullCallback();
if (callback) (*callback)(&node,this);
else*/ if (node.getNumChildrenWithOccluderNodes()>0) traverse(node);
}
inline void handle_cull_callbacks_and_accept(CRCore::crNode& node,CRCore::crNode* acceptNode)
{
/*CRCore::crNodeCallback* callback = node.getCullCallback();
if (callback) (*callback)(&node,this);
else*/ if (node.getNumChildrenWithOccluderNodes()>0) acceptNode->accept(*this);
}
//float m_minCalculateValue;
float m_minShadowOccluderVolume;
unsigned int m_maxNumberOfActiveOccluders;
//unsigned int m_maxNumberOfCollectOccluders;
bool m_createDrawables;
ShadowVolumeOccluderSet m_occluderSet;
};
}
#endif
| [
"wucaihua@86aba9cf-fb85-4101-ade8-2f98c1f5b361"
] | wucaihua@86aba9cf-fb85-4101-ade8-2f98c1f5b361 |
0244e5ed51a4daf96358bf4affbd487f86f934dc | 9eaf9c37dda16a2861a354b928acf3f63973aa34 | /include/obvi/util/camera3.hpp | 270b9c9802ec5860f74a573fe62d2581548037fa | [
"MIT"
] | permissive | stephen-sorley/obvi | 5d9eb9799f66cd44c160024ea5b923ae6b292f79 | ead96e23dfd9ffba35590b3a035556eeb093d9a8 | refs/heads/master | 2020-04-22T23:22:33.818191 | 2020-03-03T23:10:06 | 2020-03-03T23:10:06 | 170,739,476 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,411 | hpp | /* Header-only class to manage a camera in 3D space.
*
* This includes both the camera's position/orientation in world space, and the projection
* transformation used to model the camera's lens.
*
* Projection matrix math taken from here:
* https://www.glprogramming.com/red/appendixf.html (frustum only - the ortho matrix has a typo)
* https://en.wikipedia.org/wiki/Orthographic_projection
* http://www.songho.ca/opengl/gl_transform.html
*
* [point in clip coords] = Projection * View * Model * [point in object coordinates]
*
* To go from clip coords (4d vector) to normalized device coordinates (3d vector), divide
* [x,y,z] components by w (fourth component).
*
* Normalized device coordinates (NDC) are just the window coordinates normalized to range [-1, 1].
* Note that in OpenGL NDC (-1,-1) is the lower-left corner of the screen and (1,1) is the
* upper-right.
*
* This differs from standard convention in windowing systems like Qt, where (0,0) is the upper-left
* corner of the window, and (width,height) is the lower-right. You'll need to factor that in when
* converting NDC coords to window coords, or vice-versa.
*
* Inverse (convert point in clip coords to a ray in object coords):
* [point in object coords] = Model^-1 * View^-1 * Projection^-1 * [point in clip coords]
*
* * * * * * * * * * * *
* The MIT License (MIT)
*
* Copyright (c) 2019 Stephen Sorley
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* * * * * * * * * * * *
*/
#ifndef OBVI_CAMERA3_HPP
#define OBVI_CAMERA3_HPP
#include <cmath>
#include <obvi/util/affine3.hpp>
#include <obvi/util/math.hpp>
namespace obvi {
enum class camera_type {
ORTHOGRAPHIC, // Orthographic projection (objects do not get smaller with distance)
PERSPECTIVE // Perspective projection (real-world view)
};
template<typename real>
struct camera3
{
// Easiest way to set the camera's orientation and position (view transformation).
//
// camera_pos = location of camera in world coordinates
// target_pos = point camera should be aimed at, in world coordinates
// up = direction in world coordinates that will represent "up" in the camera's image
void look_at(const vec3<real>& camera_pos, const vec3<real>& target_pos, const vec3<real>& up) {
// Rotate axes so that -z points from camera to target. Set +x to be perpendicular to up
// vector and +z, in direction to obey right-hand rule. Set +y to be perpendicular to +x
// and +z. Store result in 'view' as affine transform.
mat3<real> rot;
vec3<real> look_dir = target_pos - camera_pos;
rot.rows[0] = (look_dir.cross(up)).normalized(); // new +x, expressed in old coords
rot.rows[1] = (rot.rows[0].cross(look_dir)).normalized(); // new +y, expressed in old coords
rot.rows[2] = -look_dir.normalized(); // new +z, expressed in old coords
view = rot;
// Translate coordinate system so that camera is at (0,0,0).
view *= affine3<real>(-camera_pos);
// Store the inverse of the transformation, too.
invview = view.inv();
}
// Set the view transformation directly.
// Use look_at() instead of this function, if possible (it's easier to do correctly).
void set_view(const affine3<real>& new_view) {
view = new_view;
invview = new_view.inv();
}
// Return this camera's current view transform (inverse of camera position and orientation).
const affine3<real>& get_view() const {
return view;
}
// Return inverse of this camera's current view transform (camera position and orientation).
const affine3<real>& get_inverse_view() const {
return invview;
}
// Return camera's position, in world coordinates.
const vec3<real>& get_position() const {
return invview.translation();
}
// Return camera's look direction vector, in world coordinates.
vec3<real> get_look_dir() const {
//invview.rotation() * <0,0,-1>
return -invview.rotation().col(2);
}
// Return camera's up direction vector, in world coordinates.
vec3<real> get_up_dir() const {
//invview.rotation() * <0,1,0>
return invview.rotation().col(1);
}
// Set the camera's projection matrix (basially, this describes the camera's lens).
// For typical scenes, just use set_perspective(). This function is only useful if you
// need an orthographic projection, or an off-axis perspective projection.
//
// left: location of left clipping plane
// right: location of right clipping plane (left + right = 0 if on-axis)
// bottom: location of bottom clipping plane
// top: location of top clipping plane (bottom + top = 0 if on-axis)
// near: distance to near clipping plane (must always be POSITIVE)
// far: distance to far clipping plane (must always be POSITIVE)
bool set_projection(camera_type proj, real left, real right, real bottom, real top,
real near_clip, real far_clip) {
if(near_clip <= real(0) || far_clip <= real(0) || left == right || bottom == top) {
return false;
}
proj_type = proj;
switch(proj_type) {
case camera_type::ORTHOGRAPHIC:
recalc_orthographic(left, right, bottom, top, near_clip, far_clip);
break;
case camera_type::PERSPECTIVE:
recalc_perspective(left, right, bottom, top, near_clip, far_clip);
break;
}
return true;
}
/* Shortcut for common case - perspective projection centered on viewing axis, defined by
vertical field-of-view angle in radians (fovy_rad) and aspect ratio (width / height).
See: https://stackoverflow.com/a/12943456
*/
bool set_perspective(real fovy_rad, real aspect_ratio, real near_clip, real far_clip) {
if(fovy_rad <= real(0) || aspect_ratio <= real(0)) {
return false;
}
real fH = std::tan(fovy_rad * real(0.5)) * near_clip;
real fW = fH * aspect_ratio;
return set_projection(camera_type::PERSPECTIVE, -fW, fW, -fH, fH, near_clip, far_clip);
}
// Construct (projection * view) matrix, save in opengl format.
template<typename GLreal>
void to_gl(std::array<GLreal, 16>& arr) const {
to_gl_internal(arr, view);
}
// Construct (projection * view * model) matrix, save in opengl format.
template<typename GLreal>
void to_gl(std::array<GLreal, 16>& arr, const affine3<real>& model) const {
to_gl_internal(arr, view * model);
}
// Reverse the camera transform - convert vector in clip coords back to world coords.
vec3<real> unproject(const vec3<real>& vec) const {
vec3<real> res = vec;
// Reverse the projection transformation, to go from clip coords back to eye coords.
switch(proj_type) {
case camera_type::ORTHOGRAPHIC:
res = unproject_orthographic(vec);
break;
case camera_type::PERSPECTIVE:
res = unproject_perspective(vec);
break;
}
// Reverse the view transformation, to go from eye coords back to world coords.
// Note: caller will still need to multiply by inverse of each object's transform matrix
// before using the returned vector to interrogate the object.
return invview * res;
}
private:
// Inverse of camera position and orientation (view matrix).
affine3<real> view;
affine3<real> invview; // calculate this once and save, to avoid recalc on calls to unproject().
// Camera projection matrix (think of it as the lens of the camera).
// Initialize to orthographic type camera, with identity matrices for the projection matrix
// and its inverse.
camera_type proj_type = camera_type::ORTHOGRAPHIC;
real p[6] = {1, 1, 1, 0, 0, 0}; // projection matrix (sparse, only store non-const values)
real invp[6] = {1, 1, 1, 0, 0, 0}; // inverse of projection matrix
// Private helper functions.
void recalc_orthographic(real left, real right, real bottom, real top, real near_clip, real far_clip) {
real w = right - left;
real h = top - bottom;
real nd = near_clip - far_clip;
/* Orthographic:
|p[0] 0 0 p[4]|
| 0 p[1] 0 p[5]|
| 0 0 p[2] p[3]|
| 0 0 0 1 |
*/
p[0] = real(2) / w;
p[1] = real(2) / h;
p[2] = real(2) / nd;
p[3] = (near_clip + far_clip) / nd;
p[4] = (left + right) / -w;
p[5] = (bottom + top) / -h;
/* Orthographic (Inverse):
|invp[0] 0 0 invp[4]|
| 0 invp[1] 0 invp[5]|
| 0 0 invp[2] invp[3]|
| 0 0 0 1 |
*/
invp[0] = w / real(2);
invp[1] = h / real(2);
invp[2] = nd / real(2);
invp[3] = (near_clip + far_clip) / real(-2);
invp[4] = (left + right) / real(2);
invp[5] = (bottom + top) / real(2);
}
void recalc_perspective(real left, real right, real bottom, real top, real near_clip, real far_clip) {
real w = right - left;
real h = top - bottom;
real nd = near_clip - far_clip;
real n2 = real(2) * near_clip;
real nf2 = n2 * far_clip;
/* Perspective:
|p[0] 0 p[4] 0 |
| 0 p[1] p[5] 0 |
| 0 0 p[2] p[3]|
| 0 0 -1 0 |
*/
p[0] = n2 / w;
p[1] = n2 / h;
p[2] = (near_clip + far_clip) / nd;
p[3] = nf2 / nd;
p[4] = (right + left) / w;
p[5] = (bottom + top) / h;
/* Perspective (Inverse):
|invp[0] 0 0 invp[4]|
| 0 invp[1] 0 invp[5]|
| 0 0 0 -1 |
| 0 0 invp[2] invp[3]|
*/
invp[0] = w / n2;
invp[1] = h / n2;
invp[2] = nd / nf2;
invp[3] = (near_clip + far_clip) / nf2;
invp[4] = (right + left) / n2;
invp[5] = (bottom + top) / n2;
}
// Reverse the orthographic projection - go from NDC back to eye coords.
vec3<real> unproject_orthographic(const vec3<real>& vec) const {
vec3<real> res;
// Note: for orthographic, value of 'w' is implicilty always 1.
res.x() = invp[0]*vec.x() + invp[4];
res.y() = invp[1]*vec.y() + invp[5];
res.z() = invp[2]*vec.z() + invp[3];
return res;
}
// Reverse the perspective projection - go from NDC back to eye coords.
vec3<real> unproject_perspective(const vec3<real>& vec) const {
vec3<real> res;
res.x() = invp[0]*vec.x() + invp[4];
res.y() = invp[1]*vec.y() + invp[5];
res.z() = -vec.z();
/*
Since 'res' is a 3D vector (w is assumed to be 1), but the result of an inverse
perspective projection will have a value other than '1' for the w component, we need to
calculate the w component and then divide all the vector components by it so that
(x,y,z) have the proper values for w=1.
*/
res /= invp[2]*vec.z() + invp[3];
return res;
}
static size_t colmajor(size_t row, size_t col) {
return col * 4 + row;
}
template<typename GLreal>
void to_gl_internal(std::array<GLreal, 16>& arr, const affine3<real>& aff) const {
switch(proj_type) {
case camera_type::ORTHOGRAPHIC:
to_gl_internal_orthographic(arr, aff);
break;
case camera_type::PERSPECTIVE:
to_gl_internal_perspective(arr, aff);
break;
}
}
// Compute (ortho projection * aff), store column-wise in arr for export to OpenGL.
template<typename GLreal>
void to_gl_internal_orthographic(std::array<GLreal, 16>& arr, const affine3<real>& aff) const {
const mat3<real>& rot = aff.rotation();
const vec3<real>& tr = aff.translation();
// Initialize with all zeros.
arr.fill(GLreal(0));
// Combine scale with rotation matrix, then compute upper-left 3x3 of result.
real s00 = rot(0,0) * aff.scale();
real s11 = rot(1,1) * aff.scale();
real s22 = rot(2,2) * aff.scale();
arr[colmajor(0,0)] = GLreal( p[0]*s00 );
arr[colmajor(0,1)] = GLreal( p[0]*rot(0,1) );
arr[colmajor(0,2)] = GLreal( p[0]*rot(0,2) );
arr[colmajor(1,0)] = GLreal( p[1]*rot(1,0) );
arr[colmajor(1,1)] = GLreal( p[1]*s11 );
arr[colmajor(1,2)] = GLreal( p[1]*rot(1,2) );
arr[colmajor(2,0)] = GLreal( p[2]*rot(2,0) );
arr[colmajor(2,1)] = GLreal( p[2]*rot(2,1) );
arr[colmajor(2,2)] = GLreal( p[2]*s22 );
// Compute upper-right 3x1 of result.
arr[colmajor(0,3)] = GLreal( p[0]*tr.x() + p[4] );
arr[colmajor(1,3)] = GLreal( p[1]*tr.y() + p[5] );
arr[colmajor(2,3)] = GLreal( p[2]*tr.z() + p[3] );
arr[colmajor(3,3)] = GLreal( 1 );
}
// Compute (perspective projection * aff), store column-wise in arr for export to OpenGL.
template<typename GLreal>
void to_gl_internal_perspective(std::array<GLreal, 16>& arr, const affine3<real>& aff) const {
const mat3<real>& rot = aff.rotation();
const vec3<real>& tr = aff.translation();
// Initialize with all zeros.
arr.fill(GLreal(0));
// Combine scale with rotation matrix, then compute upper-left 3x3 of result.
real s00 = rot(0,0) * aff.scale();
real s11 = rot(1,1) * aff.scale();
real s22 = rot(2,2) * aff.scale();
arr[colmajor(0,0)] = GLreal( p[0]*s00 + p[4]*rot(2,0) );
arr[colmajor(0,1)] = GLreal( p[0]*rot(0,1) + p[4]*rot(2,1) );
arr[colmajor(0,2)] = GLreal( p[0]*rot(0,2) + p[4]*s22 );
arr[colmajor(1,0)] = GLreal( p[1]*rot(1,0) + p[5]*rot(2,0) );
arr[colmajor(1,1)] = GLreal( p[1]*s11 + p[5]*rot(2,1) );
arr[colmajor(1,2)] = GLreal( p[1]*rot(1,2) + p[5]*s22 );
arr[colmajor(2,0)] = GLreal( p[2]*rot(2,0) );
arr[colmajor(2,1)] = GLreal( p[2]*rot(2,1) );
arr[colmajor(2,2)] = GLreal( p[2]*s22 );
// Compute upper-right 3x1 of result.
arr[colmajor(0,3)] = GLreal( p[0]*tr.x() + p[4]*tr.z() );
arr[colmajor(1,3)] = GLreal( p[1]*tr.y() + p[5]*tr.z() );
arr[colmajor(2,3)] = GLreal( p[2]*tr.z() + p[3] );
// Compute bottom row (1x4) of result.
arr[colmajor(3,0)] = GLreal( -rot(2,0) );
arr[colmajor(3,1)] = GLreal( -rot(2,1) );
arr[colmajor(3,2)] = GLreal( -s22 );
arr[colmajor(3,3)] = GLreal( -tr.z() );
}
};
using camera3f = camera3<float>;
using camera3d = camera3<double>;
} // END namespace obvi
#endif // OBVI_CAMERA3_HPP
| [
"stephen.sorley@gmail.com"
] | stephen.sorley@gmail.com |
76bd00982fc1a77ecaa4bc4535e658b408c17ebc | 69b9cb379b4da73fa9f62ab4b51613c11c29bb6b | /submissions/agc015_b/main.cpp | 2bc19333e5075673a0b5fff7dd5c92c9d72fbcbc | [] | no_license | tatt61880/atcoder | 459163aa3dbbe7cea7352d84cbc5b1b4d9853360 | 923ec4d5d4ae5454bc6da2ac877946672ff807e7 | refs/heads/main | 2023-07-16T16:19:22.404571 | 2021-08-15T20:54:24 | 2021-08-15T20:54:24 | 118,358,608 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 514 | cpp | #include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)
int main(void)
{
char S[100001];
cin >> S;
ll ans = 0;
int len = strlen(S);
Rep(i, len){
if(S[i] == 'U'){
ans += 1 * (len - i - 1);
ans += 2 * (i);
}else{
ans += 2 * (len - i - 1);
ans += 1 * (i);
}
}
PrintLn(ans);
return 0;
}
| [
"tatt61880@gmail.com"
] | tatt61880@gmail.com |
0100bc3677aa5a07ed95c1dedb295fa0b7e086be | 6f8db19fbc8f1f0d14251d47c6cec03fee6b21d7 | /LetterEditor/main.cpp | 9bb2ed669c6c937b1240651778e298e99bd26e1f | [] | no_license | sebastienbrg/ReadLearnWrite | 348b121d16240b802607e88beec3680e30013202 | 661508a52fbb2f39ba370406cc6c41f7ed03f623 | refs/heads/master | 2020-04-02T06:07:41.975409 | 2018-11-20T12:33:21 | 2018-11-20T12:33:21 | 154,130,694 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 445 | cpp | #include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "pathmodel.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<PathModel>("pathmodel", 1, 0, "PathModel");
engine.load(QUrl("./main.qml"));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
| [
"sebastien.berge@vossloh.com"
] | sebastien.berge@vossloh.com |
340b4cf7a452d0030168667f1cf44b6e8d37e677 | d38fc517d34598d7f2f8a32de9c29e90f12c6d2f | /unittests/test_protocol.hpp | 35af737db9f4652bec1f561eb030cf8e8a37022d | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | EOSIO/history-tools | 3a1455e54b0c58075ff97d14751eb6754fd01be6 | 4f1052dabdf88b1497db06718c31b4594175c1c8 | refs/heads/master | 2022-08-04T21:50:54.682181 | 2022-01-13T18:10:57 | 2022-01-13T18:10:57 | 159,573,050 | 59 | 55 | MIT | 2022-06-01T05:45:19 | 2018-11-28T22:20:21 | C++ | UTF-8 | C++ | false | false | 35,928 | hpp | #pragma once
#include <eosio/check.hpp>
#include <eosio/crypto.hpp>
#include <eosio/fixed_bytes.hpp>
#include <eosio/float.hpp>
#include <eosio/name.hpp>
#include <eosio/opaque.hpp>
#include <eosio/stream.hpp>
#include <eosio/time.hpp>
#include <eosio/varint.hpp>
namespace test_protocol {
typedef __uint128_t uint128_t;
#ifdef __eosio_cdt__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Winvalid-noreturn"
[[noreturn]] inline void report_error(const std::string& s) { eosio::check(false, s); }
# pragma clang diagnostic pop
#else
[[noreturn]] inline void report_error(const std::string& s) { throw std::runtime_error(s); }
#endif
struct extension {
uint16_t type = {};
eosio::input_stream data = {};
};
EOSIO_REFLECT(extension, type, data)
enum class transaction_status : uint8_t {
executed = 0, // succeed, no error handler executed
soft_fail = 1, // objectively failed (not executed), error handler executed
hard_fail = 2, // objectively failed and error handler objectively failed thus no state change
delayed = 3, // transaction delayed/deferred/scheduled for future execution
expired = 4, // transaction expired and storage space refunded to user
};
// todo: switch to eosio::result. switch to new serializer string support.
inline std::string to_string(transaction_status status) {
switch (status) {
case transaction_status::executed: return "executed";
case transaction_status::soft_fail: return "soft_fail";
case transaction_status::hard_fail: return "hard_fail";
case transaction_status::delayed: return "delayed";
case transaction_status::expired: return "expired";
}
report_error("unknown status: " + std::to_string((uint8_t)status));
}
// todo: switch to eosio::result. switch to new serializer string support.
inline transaction_status get_transaction_status(const std::string& s) {
if (s == "executed")
return transaction_status::executed;
if (s == "soft_fail")
return transaction_status::soft_fail;
if (s == "hard_fail")
return transaction_status::hard_fail;
if (s == "delayed")
return transaction_status::delayed;
if (s == "expired")
return transaction_status::expired;
report_error("unknown status: " + s);
}
struct get_status_request_v0 {};
EOSIO_REFLECT(get_status_request_v0)
struct block_position {
uint32_t block_num = {};
eosio::checksum256 block_id = {};
};
EOSIO_REFLECT(block_position, block_num, block_id)
struct get_status_result_v0 {
block_position head = {};
block_position last_irreversible = {};
uint32_t trace_begin_block = {};
uint32_t trace_end_block = {};
uint32_t chain_state_begin_block = {};
uint32_t chain_state_end_block = {};
eosio::checksum256 chain_id = {}; // todo: switch to binary extension
};
EOSIO_REFLECT(get_status_result_v0, head, last_irreversible, trace_begin_block, trace_end_block,
chain_state_begin_block, chain_state_end_block, chain_id)
struct get_blocks_request_v0 {
uint32_t start_block_num = {};
uint32_t end_block_num = {};
uint32_t max_messages_in_flight = {};
std::vector<block_position> have_positions = {};
bool irreversible_only = {};
bool fetch_block = {};
bool fetch_traces = {};
bool fetch_deltas = {};
};
EOSIO_REFLECT(get_blocks_request_v0, start_block_num, end_block_num, max_messages_in_flight, have_positions,
irreversible_only, fetch_block, fetch_traces, fetch_deltas)
struct get_blocks_ack_request_v0 {
uint32_t num_messages = {};
};
EOSIO_REFLECT(get_blocks_ack_request_v0, num_messages)
using request = std::variant<get_status_request_v0, get_blocks_request_v0, get_blocks_ack_request_v0>;
struct get_blocks_result_base {
block_position head = {};
block_position last_irreversible = {};
std::optional<block_position> this_block = {};
std::optional<block_position> prev_block = {};
};
EOSIO_REFLECT(get_blocks_result_base, head, last_irreversible, this_block, prev_block)
struct get_blocks_result_v0 : get_blocks_result_base {
std::optional<eosio::input_stream> block = {};
std::optional<eosio::input_stream> traces = {};
std::optional<eosio::input_stream> deltas = {};
};
EOSIO_REFLECT(get_blocks_result_v0, base get_blocks_result_base, block, traces, deltas)
struct row_v0 {
bool present = {}; // false (not present), true (present, old / new)
eosio::input_stream data = {};
};
EOSIO_REFLECT(row_v0, present, data)
struct table_delta_v0 {
std::string name = {};
std::vector<row_v0> rows = {};
};
EOSIO_REFLECT(table_delta_v0, name, rows)
struct row_v1 {
uint8_t present = {}; // 0 (not present), 1 (present, old), 2 (present, new)
eosio::input_stream data = {};
};
EOSIO_REFLECT(row_v1, present, data)
struct table_delta_v1 {
std::string name = {};
std::vector<row_v1> rows = {};
};
EOSIO_REFLECT(table_delta_v1, name, rows)
using table_delta = std::variant<table_delta_v0, table_delta_v1>;
struct permission_level {
eosio::name actor = {};
eosio::name permission = {};
};
EOSIO_REFLECT(permission_level, actor, permission)
struct action {
eosio::name account = {};
eosio::name name = {};
std::vector<permission_level> authorization = {};
eosio::input_stream data = {};
};
EOSIO_REFLECT(action, account, name, authorization, data)
struct account_auth_sequence {
eosio::name account = {};
uint64_t sequence = {};
};
EOSIO_REFLECT(account_auth_sequence, account, sequence)
EOSIO_COMPARE(account_auth_sequence);
struct action_receipt_v0 {
eosio::name receiver = {};
eosio::checksum256 act_digest = {};
uint64_t global_sequence = {};
uint64_t recv_sequence = {};
std::vector<account_auth_sequence> auth_sequence = {};
eosio::varuint32 code_sequence = {};
eosio::varuint32 abi_sequence = {};
};
EOSIO_REFLECT(action_receipt_v0, receiver, act_digest, global_sequence, recv_sequence, auth_sequence, code_sequence,
abi_sequence)
using action_receipt = std::variant<action_receipt_v0>;
struct account_delta {
eosio::name account = {};
int64_t delta = {};
};
EOSIO_REFLECT(account_delta, account, delta)
EOSIO_COMPARE(account_delta);
struct action_trace_v0 {
eosio::varuint32 action_ordinal = {};
eosio::varuint32 creator_action_ordinal = {};
std::optional<action_receipt> receipt = {};
eosio::name receiver = {};
action act = {};
bool context_free = {};
int64_t elapsed = {};
std::string console = {};
std::vector<account_delta> account_ram_deltas = {};
std::optional<std::string> except = {};
std::optional<uint64_t> error_code = {};
};
EOSIO_REFLECT(action_trace_v0, action_ordinal, creator_action_ordinal, receipt, receiver, act, context_free, elapsed,
console, account_ram_deltas, except, error_code)
struct action_trace_v1 {
eosio::varuint32 action_ordinal = {};
eosio::varuint32 creator_action_ordinal = {};
std::optional<action_receipt> receipt = {};
eosio::name receiver = {};
action act = {};
bool context_free = {};
int64_t elapsed = {};
std::string console = {};
std::vector<account_delta> account_ram_deltas = {};
std::vector<account_delta> account_disk_deltas = {};
std::optional<std::string> except = {};
std::optional<uint64_t> error_code = {};
eosio::input_stream return_value = {};
};
EOSIO_REFLECT(action_trace_v1, action_ordinal, creator_action_ordinal, receipt, receiver, act, context_free, elapsed,
console, account_ram_deltas, account_disk_deltas, except, error_code, return_value)
using action_trace = std::variant<action_trace_v0, action_trace_v1>;
struct prunable_data_none {
eosio::checksum256 prunable_digest;
};
using segment_type = std::variant<eosio::checksum256, eosio::input_stream>;
constexpr const char* get_typ_name(segment_type*){ return "segment_type"; }
struct prunable_data_partial {
std::vector<eosio::signature> signatures;
std::vector<segment_type> context_free_segments;
};
struct prunable_data_full {
std::vector<eosio::signature> signatures;
std::vector<eosio::input_stream> context_free_segments;
};
struct prunable_data_full_legacy {
std::vector<eosio::signature> signatures;
eosio::input_stream packed_context_free_data;
};
using prunable_data_t = std::variant<prunable_data_full_legacy, prunable_data_none, prunable_data_partial, prunable_data_full>;
constexpr const char* get_typ_name(prunable_data_t*){ return "prunable_data_t"; }
struct prunable_data_type {
prunable_data_t prunable_data;
};
EOSIO_REFLECT(prunable_data_type, prunable_data)
EOSIO_REFLECT(prunable_data_none, prunable_digest)
EOSIO_REFLECT(prunable_data_partial, signatures, context_free_segments)
EOSIO_REFLECT(prunable_data_full, signatures, context_free_segments)
EOSIO_REFLECT(prunable_data_full_legacy, signatures, packed_context_free_data)
struct partial_transaction_v0 {
eosio::time_point_sec expiration = {};
uint16_t ref_block_num = {};
uint32_t ref_block_prefix = {};
eosio::varuint32 max_net_usage_words = {};
uint8_t max_cpu_usage_ms = {};
eosio::varuint32 delay_sec = {};
std::vector<extension> transaction_extensions = {};
std::vector<eosio::signature> signatures = {};
std::vector<eosio::input_stream> context_free_data = {};
};
EOSIO_REFLECT(partial_transaction_v0, expiration, ref_block_num, ref_block_prefix, max_net_usage_words,
max_cpu_usage_ms, delay_sec, transaction_extensions, signatures, context_free_data)
struct partial_transaction_v1 {
eosio::time_point_sec expiration = {};
uint16_t ref_block_num = {};
uint32_t ref_block_prefix = {};
eosio::varuint32 max_net_usage_words = {};
uint8_t max_cpu_usage_ms = {};
eosio::varuint32 delay_sec = {};
std::vector<extension> transaction_extensions = {};
std::optional<prunable_data_type> prunable_data = {};
};
EOSIO_REFLECT(partial_transaction_v1, expiration, ref_block_num, ref_block_prefix, max_net_usage_words,
max_cpu_usage_ms, delay_sec, transaction_extensions, prunable_data)
using partial_transaction = std::variant<partial_transaction_v0, partial_transaction_v1>;
struct recurse_transaction_trace;
struct transaction_trace_v0 {
eosio::checksum256 id = {};
transaction_status status = {};
uint32_t cpu_usage_us = {};
eosio::varuint32 net_usage_words = {};
int64_t elapsed = {};
uint64_t net_usage = {};
bool scheduled = {};
std::vector<action_trace> action_traces = {};
std::optional<account_delta> account_ram_delta = {};
std::optional<std::string> except = {};
std::optional<uint64_t> error_code = {};
// semantically, this should be std::optional<transaction_trace>;
// optional serializes as bool[,transaction_trace]
// vector serializes as size[,transaction_trace..] but vector will only ever have 0 or 1 transaction trace
// This assumes that bool and size for false/true serializes to same as size 0/1
std::vector<recurse_transaction_trace> failed_dtrx_trace = {};
std::optional<partial_transaction> partial = {};
};
EOSIO_REFLECT(transaction_trace_v0, id, status, cpu_usage_us, net_usage_words, elapsed, net_usage, scheduled,
action_traces, account_ram_delta, except, error_code, failed_dtrx_trace, partial)
using transaction_trace = std::variant<transaction_trace_v0>;
struct recurse_transaction_trace {
transaction_trace recurse = {};
};
EOSIO_REFLECT(recurse_transaction_trace, recurse)
struct producer_key {
eosio::name producer_name = {};
eosio::public_key block_signing_key = {};
};
EOSIO_REFLECT(producer_key, producer_name, block_signing_key)
struct producer_schedule {
uint32_t version = {};
std::vector<producer_key> producers = {};
};
EOSIO_REFLECT(producer_schedule, version, producers)
struct transaction_receipt_header {
transaction_status status = {};
uint32_t cpu_usage_us = {};
eosio::varuint32 net_usage_words = {};
};
EOSIO_REFLECT(transaction_receipt_header, status, cpu_usage_us, net_usage_words)
struct packed_transaction_v0 {
std::vector<eosio::signature> signatures = {};
uint8_t compression = {};
eosio::input_stream packed_context_free_data = {};
eosio::input_stream packed_trx = {};
};
EOSIO_REFLECT(packed_transaction_v0, signatures, compression, packed_context_free_data, packed_trx)
struct packed_transaction {
uint8_t compression = {};
prunable_data_type prunable_data = {};
eosio::input_stream packed_trx = {};
};
EOSIO_REFLECT(packed_transaction, compression, prunable_data, packed_trx)
using transaction_variant_v0 = std::variant<eosio::checksum256, packed_transaction_v0>;
struct transaction_receipt_v0 : transaction_receipt_header {
transaction_variant_v0 trx = {};
};
EOSIO_REFLECT(transaction_receipt_v0, base transaction_receipt_header, trx)
using transaction_variant = std::variant<eosio::checksum256, packed_transaction>;
struct transaction_receipt : transaction_receipt_header {
transaction_variant trx = {};
};
EOSIO_REFLECT(transaction_receipt, base transaction_receipt_header, trx)
struct block_header {
eosio::block_timestamp timestamp{};
eosio::name producer = {};
uint16_t confirmed = {};
eosio::checksum256 previous = {};
eosio::checksum256 transaction_mroot = {};
eosio::checksum256 action_mroot = {};
uint32_t schedule_version = {};
std::optional<producer_schedule> new_producers = {};
std::vector<extension> header_extensions = {};
};
EOSIO_REFLECT(block_header, timestamp, producer, confirmed, previous, transaction_mroot, action_mroot,
schedule_version, new_producers, header_extensions)
struct signed_block_header : block_header {
eosio::signature producer_signature = {};
};
EOSIO_REFLECT(signed_block_header, base block_header, producer_signature)
struct signed_block_v0 : signed_block_header {
std::vector<transaction_receipt_v0> transactions = {};
std::vector<extension> block_extensions = {};
};
EOSIO_REFLECT(signed_block_v0, base signed_block_header, transactions, block_extensions)
struct signed_block_v1 : signed_block_header {
uint8_t prune_state = {};
std::vector<transaction_receipt> transactions = {};
std::vector<extension> block_extensions = {};
};
EOSIO_REFLECT(signed_block_v1, base signed_block_header, prune_state, transactions, block_extensions)
using signed_block_variant = std::variant<signed_block_v0, signed_block_v1>;
struct get_blocks_result_v1 : get_blocks_result_base {
std::optional<signed_block_variant> block = {};
eosio::opaque<std::vector<transaction_trace>> traces = {};
eosio::opaque<std::vector<table_delta>> deltas = {};
};
EOSIO_REFLECT(get_blocks_result_v1, base get_blocks_result_base, block, traces, deltas)
using result = std::variant<get_status_result_v0, get_blocks_result_v0, get_blocks_result_v1>;
struct transaction_header {
eosio::time_point_sec expiration = {};
uint16_t ref_block_num = {};
uint32_t ref_block_prefix = {};
eosio::varuint32 max_net_usage_words = {};
uint8_t max_cpu_usage_ms = {};
eosio::varuint32 delay_sec = {};
};
EOSIO_REFLECT(transaction_header, expiration, ref_block_num, ref_block_prefix, max_net_usage_words, max_cpu_usage_ms,
delay_sec)
struct transaction : transaction_header {
std::vector<action> context_free_actions = {};
std::vector<action> actions = {};
std::vector<extension> transaction_extensions = {};
};
EOSIO_REFLECT(transaction, base transaction_header, context_free_actions, actions, transaction_extensions)
struct code_id {
uint8_t vm_type = {};
uint8_t vm_version = {};
eosio::checksum256 code_hash = {};
};
EOSIO_REFLECT(code_id, vm_type, vm_version, code_hash)
struct account_v0 {
eosio::name name = {};
eosio::block_timestamp creation_date = {};
eosio::input_stream abi = {};
};
EOSIO_REFLECT(account_v0, name, creation_date, abi)
using account = std::variant<account_v0>;
struct account_metadata_v0 {
eosio::name name = {};
bool privileged = {};
eosio::time_point last_code_update = {};
std::optional<code_id> code = {};
};
EOSIO_REFLECT(account_metadata_v0, name, privileged, last_code_update, code)
using account_metadata = std::variant<account_metadata_v0>;
struct code_v0 {
uint8_t vm_type = {};
uint8_t vm_version = {};
eosio::checksum256 code_hash = {};
eosio::input_stream code = {};
};
EOSIO_REFLECT(code_v0, vm_type, vm_version, code_hash, code)
using code = std::variant<code_v0>;
struct contract_table_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
eosio::name payer = {};
};
EOSIO_REFLECT(contract_table_v0, code, scope, table, payer)
using contract_table = std::variant<contract_table_v0>;
struct contract_row_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
eosio::input_stream value = {};
};
EOSIO_REFLECT(contract_row_v0, code, scope, table, primary_key, payer, value)
using contract_row = std::variant<contract_row_v0>;
struct contract_index64_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
uint64_t secondary_key = {};
};
EOSIO_REFLECT(contract_index64_v0, code, scope, table, primary_key, payer, secondary_key)
using contract_index64 = std::variant<contract_index64_v0>;
struct contract_index128_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
uint128_t secondary_key = {};
};
EOSIO_REFLECT(contract_index128_v0, code, scope, table, primary_key, payer, secondary_key)
using contract_index128 = std::variant<contract_index128_v0>;
struct contract_index256_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
eosio::checksum256 secondary_key = {};
};
EOSIO_REFLECT(contract_index256_v0, code, scope, table, primary_key, payer, secondary_key)
using contract_index256 = std::variant<contract_index256_v0>;
struct contract_index_double_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
double secondary_key = {};
};
EOSIO_REFLECT(contract_index_double_v0, code, scope, table, primary_key, payer, secondary_key)
using contract_index_double = std::variant<contract_index_double_v0>;
struct contract_index_long_double_v0 {
eosio::name code = {};
eosio::name scope = {};
eosio::name table = {};
uint64_t primary_key = {};
eosio::name payer = {};
eosio::float128 secondary_key = {};
};
EOSIO_REFLECT(contract_index_long_double_v0, code, scope, table, primary_key, payer, secondary_key)
using contract_index_long_double = std::variant<contract_index_long_double_v0>;
struct key_value_v0 {
eosio::name contract = {};
eosio::input_stream key = {};
eosio::input_stream value = {};
eosio::name payer = {};
};
EOSIO_REFLECT(key_value_v0, contract, key, value, payer)
using key_value = std::variant<key_value_v0>;
struct key_weight {
eosio::public_key key = {};
uint16_t weight = {};
};
EOSIO_REFLECT(key_weight, key, weight)
struct block_signing_authority_v0 {
uint32_t threshold = {};
std::vector<key_weight> keys = {};
};
EOSIO_REFLECT(block_signing_authority_v0, threshold, keys)
using block_signing_authority = std::variant<block_signing_authority_v0>;
struct producer_authority {
eosio::name producer_name = {};
block_signing_authority authority = {};
};
EOSIO_REFLECT(producer_authority, producer_name, authority)
struct producer_authority_schedule {
uint32_t version = {};
std::vector<producer_authority> producers = {};
};
EOSIO_REFLECT(producer_authority_schedule, version, producers)
struct chain_config_v0 {
uint64_t max_block_net_usage = {};
uint32_t target_block_net_usage_pct = {};
uint32_t max_transaction_net_usage = {};
uint32_t base_per_transaction_net_usage = {};
uint32_t net_usage_leeway = {};
uint32_t context_free_discount_net_usage_num = {};
uint32_t context_free_discount_net_usage_den = {};
uint32_t max_block_cpu_usage = {};
uint32_t target_block_cpu_usage_pct = {};
uint32_t max_transaction_cpu_usage = {};
uint32_t min_transaction_cpu_usage = {};
uint32_t max_transaction_lifetime = {};
uint32_t deferred_trx_expiration_window = {};
uint32_t max_transaction_delay = {};
uint32_t max_inline_action_size = {};
uint16_t max_inline_action_depth = {};
uint16_t max_authority_depth = {};
};
EOSIO_REFLECT(chain_config_v0, max_block_net_usage, target_block_net_usage_pct, max_transaction_net_usage,
base_per_transaction_net_usage, net_usage_leeway, context_free_discount_net_usage_num,
context_free_discount_net_usage_den, max_block_cpu_usage, target_block_cpu_usage_pct,
max_transaction_cpu_usage, min_transaction_cpu_usage, max_transaction_lifetime,
deferred_trx_expiration_window, max_transaction_delay, max_inline_action_size, max_inline_action_depth,
max_authority_depth)
struct chain_config_v1 {
uint64_t max_block_net_usage = {};
uint32_t target_block_net_usage_pct = {};
uint32_t max_transaction_net_usage = {};
uint32_t base_per_transaction_net_usage = {};
uint32_t net_usage_leeway = {};
uint32_t context_free_discount_net_usage_num = {};
uint32_t context_free_discount_net_usage_den = {};
uint32_t max_block_cpu_usage = {};
uint32_t target_block_cpu_usage_pct = {};
uint32_t max_transaction_cpu_usage = {};
uint32_t min_transaction_cpu_usage = {};
uint32_t max_transaction_lifetime = {};
uint32_t deferred_trx_expiration_window = {};
uint32_t max_transaction_delay = {};
uint32_t max_inline_action_size = {};
uint16_t max_inline_action_depth = {};
uint16_t max_authority_depth = {};
uint32_t max_action_return_value_size = {};
};
EOSIO_REFLECT(chain_config_v1, max_block_net_usage, target_block_net_usage_pct, max_transaction_net_usage,
base_per_transaction_net_usage, net_usage_leeway, context_free_discount_net_usage_num,
context_free_discount_net_usage_den, max_block_cpu_usage, target_block_cpu_usage_pct,
max_transaction_cpu_usage, min_transaction_cpu_usage, max_transaction_lifetime,
deferred_trx_expiration_window, max_transaction_delay, max_inline_action_size, max_inline_action_depth,
max_authority_depth, max_action_return_value_size)
using chain_config = std::variant<chain_config_v0, chain_config_v1>;
struct global_property_v0 {
std::optional<uint32_t> proposed_schedule_block_num = {};
producer_schedule proposed_schedule = {};
chain_config configuration = {};
};
EOSIO_REFLECT(global_property_v0, proposed_schedule_block_num, proposed_schedule, configuration)
struct global_property_v1 {
std::optional<uint32_t> proposed_schedule_block_num = {};
producer_authority_schedule proposed_schedule = {};
chain_config configuration = {};
eosio::checksum256 chain_id = {};
};
EOSIO_REFLECT(global_property_v1, proposed_schedule_block_num, proposed_schedule, configuration, chain_id)
struct kv_database_config {
uint32_t max_key_size = 0; ///< the maximum size in bytes of a key
uint32_t max_value_size = 0; ///< the maximum size in bytes of a value
uint32_t max_iterators = 0; ///< the maximum number of iterators that a contract can have simultaneously.
};
EOSIO_REFLECT(kv_database_config, max_key_size, max_value_size, max_iterators)
struct wasm_config {
uint32_t max_mutable_global_bytes;
uint32_t max_table_elements;
uint32_t max_section_elements;
uint32_t max_linear_memory_init;
uint32_t max_func_local_bytes;
uint32_t max_nested_structures;
uint32_t max_symbol_bytes;
uint32_t max_module_bytes;
uint32_t max_code_bytes;
uint32_t max_pages;
uint32_t max_call_depth;
};
EOSIO_REFLECT(wasm_config, max_mutable_global_bytes, max_table_elements, max_section_elements,
max_linear_memory_init, max_func_local_bytes, max_nested_structures, max_symbol_bytes,
max_module_bytes, max_code_bytes, max_pages, max_call_depth)
struct transaction_hook {
uint32_t type;
eosio::name contract;
eosio::name action;
};
EOSIO_REFLECT(transaction_hook, type, contract, action)
struct global_property_extension_v0 {
uint32_t proposed_security_group_block_num = 0;
std::vector<eosio::name> proposed_security_group_participants;
std::vector<transaction_hook> transaction_hooks;
};
EOSIO_REFLECT(global_property_extension_v0, proposed_security_group_block_num, proposed_security_group_participants, transaction_hooks)
struct global_property_v2 : global_property_v1 {
kv_database_config kv_configuration;
wasm_config wasm_configuration;
std::variant<global_property_extension_v0> extension;
};
EOSIO_REFLECT(global_property_v2, base global_property_v1, kv_configuration, wasm_configuration, extension)
using global_property = std::variant<global_property_v0, global_property_v1, global_property_v2>;
struct generated_transaction_v0 {
eosio::name sender = {};
uint128_t sender_id = {};
eosio::name payer = {};
eosio::checksum256 trx_id = {};
eosio::input_stream packed_trx = {};
};
EOSIO_REFLECT(generated_transaction_v0, sender, sender_id, payer, trx_id, packed_trx)
using generated_transaction = std::variant<generated_transaction_v0>;
struct activated_protocol_feature_v0 {
eosio::checksum256 feature_digest = {};
uint32_t activation_block_num = {};
};
EOSIO_REFLECT(activated_protocol_feature_v0, feature_digest, activation_block_num)
using activated_protocol_feature = std::variant<activated_protocol_feature_v0>;
struct protocol_state_v0 {
std::vector<activated_protocol_feature> activated_protocol_features = {};
};
EOSIO_REFLECT(protocol_state_v0, activated_protocol_features)
using protocol_state = std::variant<protocol_state_v0>;
struct permission_level_weight {
permission_level permission = {};
uint16_t weight = {};
};
EOSIO_REFLECT(permission_level_weight, permission, weight)
struct wait_weight {
uint32_t wait_sec = {};
uint16_t weight = {};
};
EOSIO_REFLECT(wait_weight, wait_sec, weight)
struct authority {
uint32_t threshold = {};
std::vector<key_weight> keys = {};
std::vector<permission_level_weight> accounts = {};
std::vector<wait_weight> waits = {};
};
EOSIO_REFLECT(authority, threshold, keys, accounts, waits)
struct permission_v0 {
eosio::name owner = {};
eosio::name name = {};
eosio::name parent = {};
eosio::time_point last_updated = {};
authority auth = {};
};
EOSIO_REFLECT(permission_v0, owner, name, parent, last_updated, auth)
using permission = std::variant<permission_v0>;
struct permission_link_v0 {
eosio::name account = {};
eosio::name code = {};
eosio::name message_type = {};
eosio::name required_permission = {};
};
EOSIO_REFLECT(permission_link_v0, account, code, message_type, required_permission)
using permission_link = std::variant<permission_link_v0>;
struct resource_limits_v0 {
eosio::name owner = {};
int64_t net_weight = {};
int64_t cpu_weight = {};
int64_t ram_bytes = {};
};
EOSIO_REFLECT(resource_limits_v0, owner, net_weight, cpu_weight, ram_bytes)
using resource_limits = std::variant<resource_limits_v0>;
struct usage_accumulator_v0 {
uint32_t last_ordinal = {};
uint64_t value_ex = {};
uint64_t consumed = {};
};
EOSIO_REFLECT(usage_accumulator_v0, last_ordinal, value_ex, consumed)
using usage_accumulator = std::variant<usage_accumulator_v0>;
struct resource_usage_v0 {
eosio::name owner = {};
usage_accumulator net_usage = {};
usage_accumulator cpu_usage = {};
uint64_t ram_usage = {};
};
EOSIO_REFLECT(resource_usage_v0, owner, net_usage, cpu_usage, ram_usage)
using resource_usage = std::variant<resource_usage_v0>;
struct resource_limits_state_v0 {
usage_accumulator average_block_net_usage = {};
usage_accumulator average_block_cpu_usage = {};
uint64_t total_net_weight = {};
uint64_t total_cpu_weight = {};
uint64_t total_ram_bytes = {};
uint64_t virtual_net_limit = {};
uint64_t virtual_cpu_limit = {};
};
EOSIO_REFLECT(resource_limits_state_v0, average_block_net_usage, average_block_cpu_usage, total_net_weight,
total_cpu_weight, total_ram_bytes, virtual_net_limit, virtual_cpu_limit)
using resource_limits_state = std::variant<resource_limits_state_v0>;
struct resource_limits_ratio_v0 {
uint64_t numerator = {};
uint64_t denominator = {};
};
EOSIO_REFLECT(resource_limits_ratio_v0, numerator, denominator)
using resource_limits_ratio = std::variant<resource_limits_ratio_v0>;
struct elastic_limit_parameters_v0 {
uint64_t target = {};
uint64_t max = {};
uint32_t periods = {};
uint32_t max_multiplier = {};
resource_limits_ratio contract_rate = {};
resource_limits_ratio expand_rate = {};
};
EOSIO_REFLECT(elastic_limit_parameters_v0, target, max, periods, max_multiplier, contract_rate, expand_rate)
using elastic_limit_parameters = std::variant<elastic_limit_parameters_v0>;
struct resource_limits_config_v0 {
elastic_limit_parameters cpu_limit_parameters = {};
elastic_limit_parameters net_limit_parameters = {};
uint32_t account_cpu_usage_average_window = {};
uint32_t account_net_usage_average_window = {};
};
EOSIO_REFLECT(resource_limits_config_v0, cpu_limit_parameters, net_limit_parameters,
account_cpu_usage_average_window, account_net_usage_average_window)
using resource_limits_config = std::variant<resource_limits_config_v0>;
} // namespace test_protocol
| [
"huangh@objectcomputing.com"
] | huangh@objectcomputing.com |
682e44a22c19cba9efb45e4d7f48c2f939a1197f | 3394ee144825b7875c4294c496274809823900fb | /Album.hpp | c9e59a9e7e747ab61af3babf372c1f8774c5a6c7 | [] | no_license | road-cycling/jsonp5 | e58941be32ebd94fee51cda3d4299ad68b2e4b7a | 9519f4ce7160547c684891d5eb40e806ea1d11c5 | refs/heads/master | 2021-08-23T03:20:31.146426 | 2017-12-02T21:25:05 | 2017-12-02T21:25:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,364 | hpp | #ifndef _album_hpp
#define _album_hpp
//class Tracks;
class Artist;
#include "JSONDataObject.hpp"
#include "AlbumImage.hpp"
#include "AlbumImages.hpp"
#include "Tracks.hpp"
//#include "Artist.hpp"
#include <iostream>
#include <memory>
#include <fstream>
#include <algorithm>
class Album: public JSONDataObject {
public:
Album();
~Album();
std::string title();
std::string genres();
int albumID();
int artistID();
int numImages();
int numTracks();
std::string year();
void setTracks(Tracks *tracks);
void setArtist(Artist *artist);
Artist *artist() { return _artist; }
Tracks *tracks() { return _tracks; }
void setAlbumImages(AlbumImages *ai);
AlbumImage *&primaryImage() { return _primaryAlbumImage; }
AlbumImage *&secondaryImage() { return _secondaryAlbumImage; }
void print();
std::string htmlString();
void createFile();
private:
std::string _title{""}, _genres{""}, _year{""};
int _albumID{0}, _artistID{0}, _numImages{0}, _numTracks{0};
bool cachedtitle{false}, cachedgenre{false}, cachedyear{false}, cachedalbumid{false}, cachedartistid{false}, cachednumimages{false}, cachednumtracks{false};
AlbumImage *_primaryAlbumImage{nullptr}, *_secondaryAlbumImage{nullptr}; //unused
Tracks *_tracks{nullptr};
Artist *_artist{nullptr};
};
#endif
| [
"eathotlead@gmail.com"
] | eathotlead@gmail.com |
81c80881b40c61f507a904273914b4d675750768 | 998720baa128c629e00d44482201a0a6b52be1fd | /src/cg/framebuffer_object.h | 61d81fef7fcf6186e34f10054cb450c6d5e7b5dd | [] | no_license | hpsoar/axle | b3037fd972f7f387641e0746b0c3938bb7a4a09e | 1a88f49e5253d0f48c2882f174b04fd52f2bab70 | refs/heads/master | 2021-01-20T09:12:33.463095 | 2013-10-28T14:54:34 | 2013-10-28T14:54:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,522 | h | #ifndef AXLE_CG_FRAMEBUFFER_OBJECT_H
#define AXLE_CG_FRAMEBUFFER_OBJECT_H
#include "../core/settings.h"
#include <GL/glew.h>
namespace ax {
class FramebufferObject {
public:
FramebufferObject();
~FramebufferObject();
/// Bind this FBO as current render target
void Bind() const;
/// Bind a texture to the "attachment" point of this FBO
void AttachTexture(GLenum tex_target, GLuint tex_id,
GLenum attachment = GL_COLOR_ATTACHMENT0_EXT,
int mip_level = 0, int zslice = 0);
/// Bind an array of textures to multiple "attachment" points of this FBO
/// - By default, the first 'numTextures' attachments are used,
/// starting with GL_COLOR_ATTACHMENT0_EXT
void AttachTextures(int tex_count, GLenum tex_target[],
GLuint tex_id[], GLenum attachment[] = NULL,
int mip_level[] = NULL, int zslice[] = NULL);
/// Bind a render buffer to the "attachment" point of this FBO
void AttachRenderBuffer(GLuint buffId,
GLenum attachment = GL_COLOR_ATTACHMENT0_EXT);
/// Bind an array of render buffers to corresponding "attachment" points
/// of this FBO.
/// - By default, the first 'numBuffers' attachments are used,
/// starting with GL_COLOR_ATTACHMENT0_EXT
void AttachRenderBuffers(int buffer_count, GLuint buffer_id[],
GLenum attachment[] = NULL);
/// Free any resource bound to the "attachment" point of this FBO
void Unattach(GLenum attachment);
/// Free any resources bound to any attachment points of this FBO
void UnattachAll();
void UnattachAllColorAttachement();
/// BEGIN : Accessors
/// Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?
GLenum GetAttachedType(GLenum attachment);
/// What is the Id of Renderbuffer/texture currently
/// attached to "attachement?"
GLuint GetAttachedId(GLenum attachment);
/// Which mipmap level is currently attached to "attachement?"
GLint GetAttachedMipLevel(GLenum attachment);
/// Which cube face is currently attached to "attachment?"
GLint GetAttachedCubeFace(GLenum attachment);
/// Which z-slice is currently attached to "attachment?"
GLint GetAttachedZSlice(GLenum attachment);
/// END : Accessors
/// BEGIN : Static methods global to all FBOs
/// Return number of color attachments permitted
static int GetMaxColorAttachments();
/// Disable all FBO rendering and return to traditional,
/// windowing-system controlled framebuffer
/// NOTE:
/// This is NOT an "unbind" for this specific FBO, but rather
/// disables all FBO rendering. This call is intentionally "static"
/// and named "Disable" instead of "Unbind" for this reason. The
/// motivation for this strange semantic is performance. Providing
/// "Unbind" would likely lead to a large number of unnecessary
/// FBO enablings/disabling.
static void Disable();
/// END : Static methods global to all FBOs
bool IsValid() { return CheckBufferStatus(); }
bool CheckBufferStatus();
protected:
bool CheckRedundancy(GLenum attachment, GLuint tex_id,
int mip_level, int z_slice);
void GuardedBind();
void GuardedUnbind();
void FramebufferTextureND(GLenum attachment, GLenum tex_target,
GLuint tex_id, int mip_level, int z_slice);
static GLuint GenerateFboId();
private:
GLuint fbo_id_;
GLint saved_fbo_id_;
};
} // ax
#endif // AXLE_CG_FRAMEBUFFER_OBJECT_H
| [
"hpsoar@gmail.com"
] | hpsoar@gmail.com |
eba9212ff5d92a3c75e93be92466ddda25ecadd0 | a6d9b0f30f38bb7c3e777cb4befd4bc675935fa8 | /src/Common/localdata/GetExistingTrackImportJobQuery.cpp | 270984ceb8c4baf958884fe32a0bc80b811410eb | [] | no_license | asdlei99/Tidal-Unofficial-Win10 | 2cb41ed8478078bc02ea26c74234de1e1075c526 | 37dbfde89c8e346dd09526adc6144e3699c943c0 | refs/heads/master | 2021-06-09T12:48:17.904735 | 2016-08-25T11:07:56 | 2016-08-25T11:07:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,041 | cpp | #include "pch.h"
#include "GetExistingTrackImportJobQuery.h"
using namespace localdata;
std::string localdata::GetExistingTrackImportJobQuery::identifier()
{
return "GetExistingTrackImportJobQuery";
}
std::string localdata::GetExistingTrackImportJobQuery::sql(int statementIndex)
{
return "select " + track_import_job::getOrderedColumnsForSelect() + " from track_import_job where id = @id";
}
track_import_job localdata::GetExistingTrackImportJobQuery::materialize(sqlite3 * db, sqlite3_stmt * statement)
{
return track_import_job::createFromSqlRecord(statement);
}
void localdata::GetExistingTrackImportJobQuery::bindParameters(int statementIndex, sqlite3 * db, sqlite3_stmt * statement)
{
sqlite3_bind_int64(statement, sqlite3_bind_parameter_index(statement, "@id"), _id);
}
std::string localdata::CountExistingTrackImportJobsQuery::identifier()
{
return "CountExistingTrackImportJobsQuery";
}
std::string localdata::CountExistingTrackImportJobsQuery::sql(int statementIndex)
{
return "select count(*) from track_import_job";
}
| [
"sferquel@infinitesquare.com"
] | sferquel@infinitesquare.com |
35f45a1edbf9a8ad8529413e5ade2792d65c8776 | 52dc9080af88c00222cc9b37aa08c35ff3cafe86 | /1100/40/1148a.cpp | 6cae6296c8c1d1ba0b79df37e0a6adf9aff697a6 | [
"Unlicense"
] | permissive | shivral/cf | 1c1acde25fc6af775acaeeb6b5fe5aa9bbcfd4d2 | d7be128c3a9adb014a231a399f1c5f19e1ab2a38 | refs/heads/master | 2023-03-20T01:29:25.559828 | 2021-03-05T08:30:30 | 2021-03-05T08:30:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 326 | cpp | #include <iostream>
void answer(size_t v)
{
std::cout << v << '\n';
}
void solve(size_t a, size_t b, size_t c)
{
const size_t d = std::min(a, b);
a -= d, b -= d;
answer((b > 0) + (c + d) * 2 + (a > 0));
}
int main()
{
size_t a, b, c;
std::cin >> a >> b >> c;
solve(a, b, c);
return 0;
}
| [
"5691735+actium@users.noreply.github.com"
] | 5691735+actium@users.noreply.github.com |
4a782cb6f08074e13111dcaa4896f3311b763f86 | ae4675b9c473b19252a26f54e2a27af91684e3f0 | /Arduino Files/Connect_to_Cayenne/Connect_to_Cayenne.ino | bde0ca4225c25f38c22da5cd95c2b0a50f1cb71e | [] | no_license | purichkung/connect-esp8266-to-cayenne | 503396fda11973bc28db5d43d2db5adb3eff869e | 864c1ae56137c820d0fcfaa06de620ce9836be04 | refs/heads/master | 2022-12-08T08:41:40.437034 | 2017-03-12T14:10:48 | 2017-03-12T14:10:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 611 | ino | #define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "your token took from Cayenne website";
// Your network name and password.
char ssid[] = "your wireless ssid";
char password[] = "your wireless password";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token, ssid, password);
}
void loop()
{
Cayenne.run();
}
| [
"noreply@github.com"
] | purichkung.noreply@github.com |
aa7caff6a9ce929f4bb0dab6dd7e33c811df6177 | 8a4f5627b58aa54fd6a549f90b3c79b6e285c638 | /C++/Longest Common Subsequence/print_shortest_common_supersequence.cpp | 5fc26a24d862665a8807756088ceef6beff88a03 | [] | no_license | MrChepe09/Dynamic-Programming-Series | 334f24af4f834f88840bf5222746d2b7452a33ee | d49e5bd7cb329b0b0f1382eb8627ba0427383499 | refs/heads/master | 2022-11-29T09:40:01.065561 | 2020-08-07T05:15:21 | 2020-08-07T05:15:21 | 283,384,811 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,224 | cpp | #include<bits/stdc++.h>
using namespace std;
void printscs(string a, string b){
int m = a.length();
int n = b.length();
int dp[n+1][m+1];
for(int i=0; i<=m; i++){
for(int j=0; j<=n; j++){
if(i==0 || j==0){
dp[i][j] = 0;
} else if(a[i-1]==b[j-1]){
dp[i][j] = 1 + dp[i-1][j-1];
} else{
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
}
}
int i, j;
string res = "";
//dp = lcs(a, b);
i = a.length();
j = b.length();
while(i>0 && j>0){
if(a[i-1] == b[j-1]){
res += a[i-1];
i = i-1;
j = j-1;
} else {
if(dp[i-1][j]>dp[i][j-1]){
res += a[i-1];
i = i-1;
} else {
res += b[j-1];
j = j-1;
}
}
}
while(i>0){
res += a[i-1];
i--;
}
while(j>0){
res += b[j-1];
j--;
}
reverse(res.begin(), res.end());
cout<<res<<'\n';
}
int main(){
int test;
string a, b;
cin>>test;
while(test--){
cin>>a;
cin>>b;
printscs(a, b);
}
} | [
"khanujabhupinder09@gmail.com"
] | khanujabhupinder09@gmail.com |
d38ee4f55861e8f318fb3a029766703563e1d828 | 5b31026105843fc6a6a0c542f3dd4e59ca3a27e1 | /ddimon/DdiMon/inject.cpp | 04fe6ccc465adaa0e741eb1201ec14cbbb0ec484 | [
"MIT"
] | permissive | fIappy/Syscall-Monitor | a7e35444e1fc1e23f1d881b4dc3cf080b33ea646 | fb391fbc2ac09daeb9bf35317565ef36da4c38c6 | refs/heads/master | 2021-06-18T03:27:16.821143 | 2021-06-15T16:27:08 | 2021-06-15T16:27:08 | 260,613,717 | 1 | 0 | null | 2020-05-02T04:30:52 | 2020-05-02T04:30:51 | null | UTF-8 | C++ | false | false | 24,354 | cpp | #include <ntifs.h>
#include <Ntstrsafe.h>
#include "NativeEnums.h"
#include "NativeStructs.h"
#include "PEStructs.h"
#include "main.h"
#pragma warning(disable : 4311)
#pragma warning(disable : 4302)
EXTERN_C{
UNICODE_STRING m_GlobalInject = { 0 };
#ifdef AMD64
UNICODE_STRING m_GlobalInject64 = { 0 };
#endif
extern DYNAMIC_DATA dynData;
typedef NTSTATUS(*fnNtTerminateThread)(HANDLE ProcessHandle, NTSTATUS ExitStatus);
typedef NTSTATUS(*fnNtProtectVirtualMemory)(HANDLE ProcessHandle, PVOID* BaseAddress, SIZE_T* NumberOfBytesToProtect, ULONG NewAccessProtection, PULONG OldAccessProtection);
typedef NTSTATUS(*fnNtWriteVirtualMemory)(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG BufferLength, PULONG ReturnLength);
typedef NTSTATUS(*fnNtReadVirtualMemory)(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG BufferLength, PULONG ReturnLength);
typedef NTSTATUS(*fnNtQueryVirtualMemory)(HANDLE ProcessHandle, PVOID BaseAddress, MEMORY_INFORMATION_CLASS_EX MemoryInformationClass, PVOID MemoryInformation, SIZE_T MemoryInformationLength, PSIZE_T ReturnLength);
typedef NTSTATUS(*fnNtCreateThreadEx)(OUT PHANDLE hThread, IN ACCESS_MASK DesiredAccess, IN PVOID ObjectAttributes, IN HANDLE ProcessHandle, IN PVOID lpStartAddress, IN PVOID lpParameter, IN ULONG Flags, IN SIZE_T StackZeroBits, IN SIZE_T SizeOfStackCommit, IN SIZE_T SizeOfStackReserve, OUT PVOID lpBytesBuffer);
NTKERNELAPI PVOID NTAPI PsGetProcessPeb(PEPROCESS Process);
#ifdef AMD64
NTKERNELAPI PVOID NTAPI PsGetProcessWow64Process(PEPROCESS Process);
#endif
typedef struct _INJECT_BUFFER
{
UCHAR code[0x200];
UCHAR original_code[8];
PVOID hook_func;
union
{
UNICODE_STRING path;
UNICODE_STRING32 path32;
};
wchar_t buffer[488];
PVOID module;
} INJECT_BUFFER, *PINJECT_BUFFER;
PVOID GetSSDTEntry(IN ULONG index);
static PVOID PsNtDllBase = NULL;
static PVOID fnLdrLoadDll = NULL;
static PVOID fnProtectVirtualMemory = NULL;
static PVOID fnHookFunc = NULL;
#ifdef AMD64
static PVOID PsNtDllBase64 = NULL;
static PVOID fnLdrLoadDll64 = NULL;
static PVOID fnProtectVirtualMemory64 = NULL;
static PVOID fnHookFunc64 = NULL;
#endif
PINJECT_BUFFER GetInlineHookCode(IN HANDLE hProcess, IN PUNICODE_STRING pDllPath);
PINJECT_BUFFER GetInlineHookCode64(IN HANDLE hProcess, IN PUNICODE_STRING pDllPath);
PVOID GetModuleExport(IN PVOID pBase, IN PCCHAR name_ord);
#pragma alloc_text(PAGE, GetInlineHookCode)
#pragma alloc_text(PAGE, GetInlineHookCode64)
#pragma alloc_text(PAGE, GetModuleExport)
NTSTATUS NTAPI NewZwTerminateThread(_In_opt_ HANDLE ThreadHandle, _In_ NTSTATUS ExitStatus)
{
NTSTATUS status = STATUS_SUCCESS;
fnNtTerminateThread pfnNtTerminateThread;
if (dynData.NtTermThrdIndex == 0)
return STATUS_NOT_FOUND;
pfnNtTerminateThread = (fnNtTerminateThread)(ULONG_PTR)GetSSDTEntry(dynData.NtTermThrdIndex);
if (pfnNtTerminateThread)
{
PUCHAR pPrevMode = (PUCHAR)PsGetCurrentThread() + dynData.PrevMode;
UCHAR prevMode = *pPrevMode;
*pPrevMode = KernelMode;
status = pfnNtTerminateThread(ThreadHandle, ExitStatus);
*pPrevMode = prevMode;
}
else
status = STATUS_NOT_FOUND;
return status;
}
NTSTATUS NTAPI NewZwQueryVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, MEMORY_INFORMATION_CLASS_EX MemoryInformationClass, PVOID MemoryInformation, SIZE_T MemoryInformationLength, PSIZE_T ReturnLength)
{
NTSTATUS status = STATUS_SUCCESS;
fnNtQueryVirtualMemory pfnNtQueryVirtualMemory;
if (dynData.NtQueryIndex == 0)
return STATUS_NOT_FOUND;
pfnNtQueryVirtualMemory = (fnNtQueryVirtualMemory)(ULONG_PTR)GetSSDTEntry(dynData.NtQueryIndex);
if (pfnNtQueryVirtualMemory)
{
PUCHAR pPrevMode = (PUCHAR)PsGetCurrentThread() + dynData.PrevMode;
UCHAR prevMode = *pPrevMode;
*pPrevMode = KernelMode;
status = pfnNtQueryVirtualMemory(ProcessHandle, BaseAddress, MemoryInformationClass, MemoryInformation, MemoryInformationLength, ReturnLength);
*pPrevMode = prevMode;
}
else
status = STATUS_NOT_FOUND;
return status;
}
NTSTATUS NTAPI NewNtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG ReturnLength OPTIONAL)
{
NTSTATUS status = STATUS_SUCCESS;
fnNtReadVirtualMemory pfnNtReadVirtualMemory;
if (dynData.NtReadIndex == 0)
return STATUS_NOT_FOUND;
pfnNtReadVirtualMemory = (fnNtReadVirtualMemory)(ULONG_PTR)GetSSDTEntry(dynData.NtReadIndex);
if (pfnNtReadVirtualMemory)
{
PUCHAR pPrevMode = (PUCHAR)PsGetCurrentThread() + dynData.PrevMode;
UCHAR prevMode = *pPrevMode;
*pPrevMode = KernelMode;
status = pfnNtReadVirtualMemory(ProcessHandle, BaseAddress, Buffer, BufferLength, ReturnLength);
*pPrevMode = prevMode;
}
else
status = STATUS_NOT_FOUND;
return status;
}
NTSTATUS NTAPI NewNtWriteVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG ReturnLength OPTIONAL)
{
NTSTATUS status = STATUS_SUCCESS;
fnNtWriteVirtualMemory pfnNtWriteVirtualMemory;
if (dynData.NtWriteIndex == 0)
return STATUS_NOT_FOUND;
pfnNtWriteVirtualMemory = (fnNtWriteVirtualMemory)(ULONG_PTR)GetSSDTEntry(dynData.NtWriteIndex);
if (pfnNtWriteVirtualMemory)
{
PUCHAR pPrevMode = (PUCHAR)PsGetCurrentThread() + dynData.PrevMode;
UCHAR prevMode = *pPrevMode;
*pPrevMode = KernelMode;
status = pfnNtWriteVirtualMemory(ProcessHandle, BaseAddress, Buffer, BufferLength, ReturnLength);
*pPrevMode = prevMode;
}
else
status = STATUS_NOT_FOUND;
return status;
}
NTSTATUS NTAPI NewNtProtectVirtualMemory(IN HANDLE ProcessHandle, IN PVOID* BaseAddress, IN SIZE_T* NumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG OldAccessProtection)
{
NTSTATUS status = STATUS_SUCCESS;
fnNtProtectVirtualMemory pfnNtProtectVirtualMemory;
if (dynData.NtProtectIndex == 0)
return STATUS_NOT_FOUND;
pfnNtProtectVirtualMemory = (fnNtProtectVirtualMemory)(ULONG_PTR)GetSSDTEntry(dynData.NtProtectIndex);
if (pfnNtProtectVirtualMemory)
{
PUCHAR pPrevMode = (PUCHAR)PsGetCurrentThread() + dynData.PrevMode;
UCHAR prevMode = *pPrevMode;
*pPrevMode = KernelMode;
status = pfnNtProtectVirtualMemory(ProcessHandle, BaseAddress, NumberOfBytesToProtect, NewAccessProtection, OldAccessProtection);
*pPrevMode = prevMode;
}
else
status = STATUS_NOT_FOUND;
return status;
}
/*
PVOID AllocateInjectMemory(IN HANDLE ProcessHandle, IN PVOID DesiredAddress, IN SIZE_T DesiredSize)
{
MEMORY_BASIC_INFORMATION mbi;
SIZE_T AllocateSize = DesiredSize;
if ((ULONG_PTR)DesiredAddress >= 0x70000000 && (ULONG_PTR)DesiredAddress < 0x80000000)
DesiredAddress = (PVOID)0x70000000;
while (1)
{
if (!NT_SUCCESS(NewZwQueryVirtualMemory(ProcessHandle, DesiredAddress, MemoryBasicInformationEx, &mbi, sizeof(mbi), NULL)))
return NULL;
if (DesiredAddress != mbi.AllocationBase)
{
DesiredAddress = mbi.AllocationBase;
}
else
{
DesiredAddress = (PVOID)((ULONG_PTR)mbi.AllocationBase - 0x10000);
}
if (mbi.State == MEM_FREE)
{
if (NT_SUCCESS(ZwAllocateVirtualMemory(ProcessHandle, &mbi.BaseAddress, 0, &AllocateSize, MEM_RESERVE, PAGE_EXECUTE_READWRITE)))
{
if (NT_SUCCESS(ZwAllocateVirtualMemory(ProcessHandle, &mbi.BaseAddress, 0, &AllocateSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE)))
{
return mbi.BaseAddress;
}
}
}
}
return NULL;
}
const UCHAR HookCode[] =
{
0x55, // push ebp
0x8B, 0xEC, // mov ebp,esp
0x83, 0xEC, 0x0C, // sub esp,0Ch
0xA1, 0, 0, 0, 0, // mov eax,dword ptr[fnHookFunc] //offset +7
0x89, 0x45, 0xF4, // mov dword ptr[ebp-0Ch],eax
0x8D, 0x45, 0xFC, // lea eax,[ebp - 4]
0x50, // push eax
0x6A, 0x40, // push 40h
0x8D, 0x45, 0xF8, // lea eax,[ebp - 8]
0xC7, 0x45, 0xF8, 5, 0, 0, 0, // mov dword ptr[ebp - 8],5
0x50, // push eax
0x8D, 0x45, 0xF4, // lea eax,[ebp - 0Ch]
0x50, // push eax
0x6A, 0xFF, // push 0FFFFFFFFh
0xE8, 0, 0, 0, 0, // call NtProtectVirtualMemory //offset +38
0x8B, 0x0D, 0, 0, 0, 0, // mov ecx,dword ptr ds : [fnHookFunc] //offset + 44
0xA1, 0, 0, 0, 0, // mov eax,dword ptr ds : [fnOriCode] //offset + 49
0x89, 0x01, // mov dword ptr[ecx],eax
0xA0, 0, 0, 0, 0, // mov al,byte ptr ds : [fnOriCode+4] //offset +56
0x88, 0x41, 0x04, // mov byte ptr[ecx + 4],al
0x8D, 0x45, 0xFC, // lea eax,[ebp-4]
0x50, // push eax
0xFF, 0x75, 0xFC, // push dword ptr[ebp-4]
0x8D, 0x45, 0xF8, // lea eax,[ebp - 8]
0x50, // push eax
0x8D, 0x45, 0xF4, // lea eax,[ebp - 0Ch]
0x50, // push eax
0x6A, 0xFF, // push 0FFFFFFFFh
0xE8, 0, 0, 0, 0, // call NtProtectVirtualMemory //offset +81
0x68, 0, 0, 0, 0, // push ModuleHandle //offset +86
0x68, 0, 0, 0, 0, // push ModuleFileName //offset +91
0x6A, 0, // push 0
0x6A, 0, // push 0
0xE8, 0, 0, 0, 0, // call LdrLoadDll //offset +100
0x8B, 0xE5, // mov esp,ebp
0x5D, // pop ebp
0xE9, 0, 0, 0, 0, // jmp //offset+108
0xCC, // padding
};
PINJECT_BUFFER GetInlineHookCode(IN HANDLE ProcessHandle, IN PUNICODE_STRING pDllPath)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
PINJECT_BUFFER pBuffer = NULL;
INJECT_BUFFER Buffer = { 0 };
//Try to allocate before ntdll.dll
pBuffer = (PINJECT_BUFFER)AllocateInjectMemory(ProcessHandle, (PVOID)PsNtDllBase, PAGE_SIZE);
if (pBuffer != NULL)
{
status = NewNtReadVirtualMemory(ProcessHandle, fnHookFunc, Buffer.original_code, sizeof(Buffer.original_code), NULL);
if (NT_SUCCESS(status))
{
// Fill data
Buffer.path32.Length = min(pDllPath->Length, sizeof(Buffer.buffer));
Buffer.path32.MaximumLength = min(pDllPath->MaximumLength, sizeof(Buffer.buffer));
Buffer.path32.Buffer = (ULONG)pBuffer->buffer;
Buffer.hook_func = fnHookFunc;
memcpy(Buffer.buffer, pDllPath->Buffer, Buffer.path32.Length);
memcpy(Buffer.code, HookCode, sizeof(HookCode));
// Fill code
*(DWORD*)((PUCHAR)Buffer.code + 7) = (DWORD)&pBuffer->hook_func;
*(DWORD*)((PUCHAR)Buffer.code + 38) = (DWORD)((DWORD)fnProtectVirtualMemory - ((DWORD)pBuffer + 42));
*(DWORD*)((PUCHAR)Buffer.code + 44) = (DWORD)&pBuffer->hook_func;
*(DWORD*)((PUCHAR)Buffer.code + 49) = (DWORD)pBuffer->original_code;
*(DWORD*)((PUCHAR)Buffer.code + 56) = (DWORD)pBuffer->original_code + 4;
*(DWORD*)((PUCHAR)Buffer.code + 81) = (DWORD)((DWORD)fnProtectVirtualMemory - ((DWORD)pBuffer + 85));
*(DWORD*)((PUCHAR)Buffer.code + 86) = (DWORD)&pBuffer->module;
*(DWORD*)((PUCHAR)Buffer.code + 91) = (DWORD)&pBuffer->path32;
*(DWORD*)((PUCHAR)Buffer.code + 100) = (DWORD)((DWORD)fnLdrLoadDll - ((DWORD)pBuffer + 104));
*(DWORD*)((PUCHAR)Buffer.code + 108) = (DWORD)((DWORD)fnHookFunc - ((DWORD)pBuffer + 112));
// Copy all
NewNtWriteVirtualMemory(ProcessHandle, pBuffer, &Buffer, sizeof(Buffer), NULL);
return pBuffer;
}
else
{
DbgPrint("%s: Failed to read original code %X\n", __FUNCTION__, status);
}
}
else
{
DbgPrint("%s: Failed to allocate memory\n", __FUNCTION__);
}
return NULL;
}
#ifdef AMD64
const UCHAR HookCode64[] = {
0x50, // push rax
0x51, // push rcx
0x52, // push rdx
0x41, 0x50, // push r8
0x41, 0x51, // push r9
0x41, 0x53, // push r11
0x48, 0x83, 0xEC, 0x38, // sub rsp,38h
0x48, 0x8B, 0x05, 0, 0, 0, 0, // mov rax,qword ptr [fnHookPort] offset+16
0x4C, 0x8D, 0x44, 0x24, 0x48, // lea r8,[rsp + 48h]
0x48, 0x89, 0x44, 0x24, 0x50, // mov qword ptr [rsp+50h],rax
0x48, 0x8D, 0x54, 0x24, 0x50, // lea rdx,[rsp + 50h]
0x48, 0x8D, 0x44, 0x24, 0x40, // lea rax,[rsp + 40h]
0x48, 0xC7, 0x44, 0x24, 0x48, // mov qword ptr[rsp + 48h],5
5, 0, 0, 0,
0x41, 0xB9, 0x40, 0, 0, 0, // mov r9d,40h
0x48, 0x89, 0x44, 0x24, 0x20, // mov qword ptr[rsp + 20h],rax
0x48, 0x83, 0xC9, 0xFF, // or rcx, 0FFFFFFFFFFFFFFFFh
0xE8, 0, 0, 0, 0, // call fnProtectVirtualMemory offset +65
0x8B, 0x05, 0, 0, 0, 0, // mov eax,dword ptr[fnOriCode] offset+71
0x4C, 0x8D, 0x44, 0x24, 0x48, // lea r8,[rsp + 48h]
0x48, 0x8B, 0x15, 0, 0, 0, 0, // mov rdx,qword ptr[fnHookPort] offset+83
0x48, 0x83, 0xC9, 0xFF, // or rcx, 0FFFFFFFFFFFFFFFFh
0x89, 0x02, // mov dword ptr[rdx],eax
0x0F, 0xB6, 0x05, 0, 0, 0, 0, // movzx eax,byte ptr[fnOriCode+4] offset+96
0x88, 0x42, 0x04, // mov byte ptr[rdx + 4],al
0x48, 0x8D, 0x44, 0x24, 0x40, // lea rax,[rsp + 40h]
0x44, 0x8B, 0x4C, 0x24, 0x40, // mov r9d,dword ptr[rsp + 40h]
0x48, 0x8D, 0x54, 0x24, 0x50, // lea rdx,[rsp + 50h]
0x48, 0x89, 0x44, 0x24, 0x20, // mov qword ptr [rsp+20h],rax
0xE8, 0, 0, 0, 0, // call fnProtectVirtualMemory offset +124
0x4C, 0x8D, 0x0D, 0, 0, 0, 0, // lea r9,qword ptr [pModuleHandle] offset+131
0x33, 0xD2, // xor edx,edx
0x4C, 0x8D, 0x05, 0, 0, 0, 0, // lea r8,qword ptr [pModuleName] offset+140
0x33, 0xC9, // xor ecx,ecx
0xE8, 0, 0, 0, 0, // call fnLdrLoadDll offset +147
0x48, 0x83, 0xC4, 0x38, // add rsp,38h
0x41, 0x5B, // pop r11
0x41, 0x59, // pop r9
0x41, 0x58, // pop r8
0x5A, // pop rdx
0x59, // pop rcx
0x58, // pop rax
0xE9, 0, 0, 0, 0, // jmp OriFunc offset+165
0xCC, // padding
};
PINJECT_BUFFER GetInlineHookCode64(IN HANDLE ProcessHandle, IN PUNICODE_STRING pDllPath)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
PINJECT_BUFFER pBuffer = NULL;
INJECT_BUFFER Buffer = { 0 };
//Try to allocate before ntdll.dll
pBuffer = (PINJECT_BUFFER)AllocateInjectMemory(ProcessHandle, (PVOID)PsNtDllBase64, PAGE_SIZE);
if (pBuffer != NULL)
{
status = NewNtReadVirtualMemory(ProcessHandle, fnHookFunc64, Buffer.original_code, sizeof(Buffer.original_code), NULL);
if (NT_SUCCESS(status))
{
// Fill data
Buffer.path.Length = min(pDllPath->Length, sizeof(Buffer.buffer));
Buffer.path.MaximumLength = min(pDllPath->MaximumLength, sizeof(Buffer.buffer));
Buffer.path.Buffer = (PWCH)pBuffer->buffer;
Buffer.hook_func = fnHookFunc64;
memcpy(Buffer.buffer, pDllPath->Buffer, Buffer.path.Length);
memcpy(Buffer.code, HookCode64, sizeof(HookCode64));
// Fill code
*(ULONG*)((PUCHAR)Buffer.code + 16) = (ULONG)((ULONGLONG)&pBuffer->hook_func - ((ULONGLONG)pBuffer + 20));
*(ULONG*)((PUCHAR)Buffer.code + 65) = (ULONG)((ULONGLONG)fnProtectVirtualMemory64 - ((ULONGLONG)pBuffer + 69));
*(ULONG*)((PUCHAR)Buffer.code + 71) = (ULONG)((ULONGLONG)pBuffer->original_code - ((ULONGLONG)pBuffer + 75));
*(ULONG*)((PUCHAR)Buffer.code + 83) = (ULONG)((ULONGLONG)&pBuffer->hook_func - ((ULONGLONG)pBuffer + 87));
*(ULONG*)((PUCHAR)Buffer.code + 96) = (ULONG)((ULONGLONG)(pBuffer->original_code + 4) - ((ULONGLONG)pBuffer + 100));
*(ULONG*)((PUCHAR)Buffer.code + 124) = (ULONG)((ULONGLONG)fnProtectVirtualMemory64 - ((ULONGLONG)pBuffer + 128));
*(ULONG*)((PUCHAR)Buffer.code + 131) = (ULONG)((ULONGLONG)&pBuffer->module - ((ULONGLONG)pBuffer + 135));
*(ULONG*)((PUCHAR)Buffer.code + 140) = (ULONG)((ULONGLONG)&pBuffer->path - ((ULONGLONG)pBuffer + 144));
*(ULONG*)((PUCHAR)Buffer.code + 147) = (ULONG)((ULONGLONG)fnLdrLoadDll64 - ((ULONGLONG)pBuffer + 151));
*(ULONG*)((PUCHAR)Buffer.code + 165) = (ULONG)((ULONGLONG)fnHookFunc64 - ((ULONGLONG)pBuffer + 169));
//Write all
NewNtWriteVirtualMemory(ProcessHandle, pBuffer, &Buffer, sizeof(Buffer), NULL);
return pBuffer;
}
else
{
DbgPrint("%s: Failed to read original code %X\n", __FUNCTION__, status);
}
}
else
{
DbgPrint("%s: Failed to allocate memory\n", __FUNCTION__);
}
return NULL;
}
#endif
PVOID GetModuleExport(IN PVOID pBase, IN PCCHAR name_ord)
{
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)pBase;
PIMAGE_NT_HEADERS32 pNtHdr32 = NULL;
PIMAGE_NT_HEADERS64 pNtHdr64 = NULL;
PIMAGE_EXPORT_DIRECTORY pExport = NULL;
ULONG expSize = 0;
ULONG_PTR pAddress = 0;
PUSHORT pAddressOfOrds;
PULONG pAddressOfNames;
PULONG pAddressOfFuncs;
ULONG i;
ASSERT(pBase != NULL);
if (pBase == NULL)
return NULL;
/// Not a PE file
if (pDosHdr->e_magic != IMAGE_DOS_SIGNATURE)
return NULL;
pNtHdr32 = (PIMAGE_NT_HEADERS32)((PUCHAR)pBase + pDosHdr->e_lfanew);
pNtHdr64 = (PIMAGE_NT_HEADERS64)((PUCHAR)pBase + pDosHdr->e_lfanew);
// Not a PE file
if (pNtHdr32->Signature != IMAGE_NT_SIGNATURE)
return NULL;
// 64 bit image
if (pNtHdr32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
{
pExport = (PIMAGE_EXPORT_DIRECTORY)(pNtHdr64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress + (ULONG_PTR)pBase);
expSize = pNtHdr64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
}
// 32 bit image
else
{
pExport = (PIMAGE_EXPORT_DIRECTORY)(pNtHdr32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress + (ULONG_PTR)pBase);
expSize = pNtHdr32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
}
pAddressOfOrds = (PUSHORT)(pExport->AddressOfNameOrdinals + (ULONG_PTR)pBase);
pAddressOfNames = (PULONG)(pExport->AddressOfNames + (ULONG_PTR)pBase);
pAddressOfFuncs = (PULONG)(pExport->AddressOfFunctions + (ULONG_PTR)pBase);
for (i = 0; i < pExport->NumberOfFunctions; ++i)
{
USHORT OrdIndex = 0xFFFF;
PCHAR pName = NULL;
// Find by index
if ((ULONG_PTR)name_ord <= 0xFFFF)
{
OrdIndex = (USHORT)i;
}
// Find by name
else if ((ULONG_PTR)name_ord > 0xFFFF && i < pExport->NumberOfNames)
{
pName = (PCHAR)(pAddressOfNames[i] + (ULONG_PTR)pBase);
OrdIndex = pAddressOfOrds[i];
}
// Weird params
else
return NULL;
if (((ULONG_PTR)name_ord <= 0xFFFF && (USHORT)((ULONG_PTR)name_ord) == OrdIndex + pExport->Base) ||
((ULONG_PTR)name_ord > 0xFFFF && strcmp(pName, name_ord) == 0))
{
pAddress = pAddressOfFuncs[OrdIndex] + (ULONG_PTR)pBase;
// Check forwarded export
if (pAddress >= (ULONG_PTR)pExport && pAddress <= (ULONG_PTR)pExport + expSize)
{
return NULL;
}
break;
}
}
return (PVOID)pAddress;
}
NTSTATUS InjectByHook(HANDLE ProcessId, PVOID ImageBase, PUNICODE_STRING pDllPath)
{
ULONG ReturnLength;
NTSTATUS status = STATUS_UNSUCCESSFUL;
PEPROCESS Process = NULL;
HANDLE ProcessHandle = NULL;
if (!PsNtDllBase)
PsNtDllBase = ImageBase;
status = PsLookupProcessByProcessId((HANDLE)ProcessId, &Process);
if (NT_SUCCESS(status))
{
status = ObOpenObjectByPointer(Process, OBJ_KERNEL_HANDLE, NULL, PROCESS_ALL_ACCESS, NULL, KernelMode, &ProcessHandle);
if (NT_SUCCESS(status))
{
status = STATUS_UNSUCCESSFUL;
if (!fnLdrLoadDll || !fnHookFunc || !fnProtectVirtualMemory)
{
KAPC_STATE kApc;
KeStackAttachProcess(Process, &kApc);
fnProtectVirtualMemory = GetModuleExport(ImageBase, "ZwProtectVirtualMemory");
fnLdrLoadDll = GetModuleExport(ImageBase, "LdrLoadDll");
fnHookFunc = GetModuleExport(ImageBase, "ZwTestAlert");
KeUnstackDetachProcess(&kApc);
}
if (fnLdrLoadDll && fnHookFunc && fnProtectVirtualMemory)
{
PINJECT_BUFFER pBuffer = GetInlineHookCode(ProcessHandle, pDllPath);
if (pBuffer)
{
UCHAR trampo[] = { 0xE9, 0, 0, 0, 0 };
ULONG OldProtect = 0;
PVOID ProtectAddress = fnHookFunc;
SIZE_T ProtectSize = sizeof(trampo);
*(DWORD *)(trampo + 1) = (DWORD)((DWORD)pBuffer->code - ((DWORD)fnHookFunc + 5));
status = NewNtProtectVirtualMemory(ProcessHandle, &ProtectAddress, &ProtectSize, PAGE_EXECUTE_READWRITE, &OldProtect);
if (NT_SUCCESS(status))
{
NewNtWriteVirtualMemory(ProcessHandle, fnHookFunc, trampo, sizeof(trampo), &ReturnLength);
NewNtProtectVirtualMemory(ProcessHandle, &ProtectAddress, &ProtectSize, OldProtect, &OldProtect);
}
}
}
ZwClose(ProcessHandle);
}
ObDereferenceObject(Process);
}
return status;
}
#ifdef AMD64
NTSTATUS InjectByHook64(HANDLE ProcessId, PVOID ImageBase, PUNICODE_STRING pDllPath)
{
ULONG ReturnLength;
NTSTATUS status = STATUS_UNSUCCESSFUL;
PEPROCESS Process = NULL;
HANDLE ProcessHandle = NULL;
if (!PsNtDllBase64)
PsNtDllBase64 = ImageBase;
status = PsLookupProcessByProcessId((HANDLE)ProcessId, &Process);
if (NT_SUCCESS(status))
{
//Do not inject WOW64 process
status = STATUS_UNSUCCESSFUL;
if (PsGetProcessWow64Process(Process) == NULL)
{
status = ObOpenObjectByPointer(Process, OBJ_KERNEL_HANDLE, NULL, PROCESS_ALL_ACCESS, NULL, KernelMode, &ProcessHandle);
if (NT_SUCCESS(status))
{
KAPC_STATE kApc;
if (!fnLdrLoadDll64 || !fnHookFunc64 || !fnProtectVirtualMemory64)
{
KeStackAttachProcess(Process, &kApc);
fnProtectVirtualMemory64 = GetModuleExport(ImageBase, "ZwProtectVirtualMemory");
fnLdrLoadDll64 = GetModuleExport(ImageBase, "LdrLoadDll");
fnHookFunc64 = GetModuleExport(ImageBase, "ZwTestAlert");
KeUnstackDetachProcess(&kApc);
}
status = STATUS_UNSUCCESSFUL;
if (fnLdrLoadDll64 && fnHookFunc64 && fnProtectVirtualMemory64)
{
PINJECT_BUFFER pBuffer = GetInlineHookCode64(ProcessHandle, pDllPath);
if (pBuffer)
{
UCHAR trampo[] = { 0xE9, 0, 0, 0, 0 };
ULONG OldProtect = 0;
PVOID ProtectAddress = fnHookFunc64;
SIZE_T ProtectSize = sizeof(trampo);
*(DWORD *)(trampo + 1) = (DWORD)((ULONG_PTR)pBuffer->code - ((ULONG_PTR)fnHookFunc64 + 5));
status = NewNtProtectVirtualMemory(ProcessHandle, &ProtectAddress, &ProtectSize, PAGE_EXECUTE_READWRITE, &OldProtect);
if (NT_SUCCESS(status))
{
NewNtWriteVirtualMemory(ProcessHandle, fnHookFunc64, trampo, sizeof(trampo), &ReturnLength);
NewNtProtectVirtualMemory(ProcessHandle, &ProtectAddress, &ProtectSize, OldProtect, &OldProtect);
}
}
}
ZwClose(ProcessHandle);
}
}
ObDereferenceObject(Process);
}
return status;
}
#endif
BOOLEAN ReadKernelMemory(PVOID pDestination, PVOID pSourceAddress, SIZE_T SizeOfCopy)
{
PMDL pMdl = NULL;
PVOID pSafeAddress = NULL;
pMdl = IoAllocateMdl(pSourceAddress, (ULONG)SizeOfCopy, FALSE, FALSE, NULL);
if (!pMdl) return FALSE;
__try
{
MmProbeAndLockPages(pMdl, KernelMode, IoReadAccess);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
IoFreeMdl(pMdl);
return FALSE;
}
pSafeAddress = MmGetSystemAddressForMdlSafe(pMdl, NormalPagePriority);
if (!pSafeAddress) return FALSE;
RtlCopyMemory(pDestination, pSafeAddress, SizeOfCopy);
MmUnlockPages(pMdl);
IoFreeMdl(pMdl);
return TRUE;
}
BOOLEAN WriteKernelMemory(PVOID pDestination, PVOID pSourceAddress, SIZE_T SizeOfCopy)
{
PMDL pMdl = NULL;
PVOID pSafeAddress = NULL;
pMdl = IoAllocateMdl(pDestination, (ULONG)SizeOfCopy, FALSE, FALSE, NULL);
if (!pMdl) return FALSE;
__try
{
MmProbeAndLockPages(pMdl, KernelMode, IoReadAccess);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
IoFreeMdl(pMdl);
return FALSE;
}
pSafeAddress = MmGetSystemAddressForMdlSafe(pMdl, NormalPagePriority);
if (!pSafeAddress) return FALSE;
RtlCopyMemory(pSafeAddress, pSourceAddress, SizeOfCopy);
MmUnlockPages(pMdl);
IoFreeMdl(pMdl);
return TRUE;
}
*/
}//EXTERN C | [
"113660872@qq.com"
] | 113660872@qq.com |
241780398d88347a6b3ee93da70d9b060fe61b52 | 86a9081a05b837ad0f0feaf6e003a1cbb276993f | /cg_exercises-cg_exercise_01/cg_exercise_01/cglib/lib/glm/glm/detail/_features.hpp | e5a1a54321277df72b7b3f9e8c6b3bb711862e51 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-happy-bunny",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | flex3r/cg_exercises | e2defd27427c251d5f0f567a8d192af8d87bca3c | 7c4b699a8211ba66710ac2137f0d460933069331 | refs/heads/master | 2020-12-11T14:06:15.052585 | 2018-02-11T13:58:23 | 2018-02-11T13:58:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,967 | hpp | /// @ref core
/// @file glm/detail/_features.hpp
#pragma once
// #define GLM_CXX98_EXCEPTIONS
// #define GLM_CXX98_RTTI
// #define GLM_CXX11_RVALUE_REFERENCES
// Rvalue references - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
// GLM_CXX11_TRAILING_RETURN
// Rvalue references for *this - GCC not supported
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
// GLM_CXX11_NONSTATIC_MEMBER_INIT
// Initialization of class objects by rvalues - GCC any
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1610.html
// GLM_CXX11_NONSTATIC_MEMBER_INIT
// Non-static data member initializers - GCC 4.7
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2756.htm
// #define GLM_CXX11_VARIADIC_TEMPLATE
// Variadic templates - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
//
// Extending variadic template template parameters - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
// #define GLM_CXX11_GENERALIZED_INITIALIZERS
// Initializer lists - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
// #define GLM_CXX11_STATIC_ASSERT
// Static assertions - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
// #define GLM_CXX11_AUTO_TYPE
// auto-typed variables - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
// #define GLM_CXX11_AUTO_TYPE
// Multi-declarator auto - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf
// #define GLM_CXX11_AUTO_TYPE
// Removal of auto as a storage-class specifier - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2546.htm
// #define GLM_CXX11_AUTO_TYPE
// New function declarator syntax - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
// #define GLM_CXX11_LAMBDAS
// New wording for C++0x lambdas - GCC 4.5
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2927.pdf
// #define GLM_CXX11_DECLTYPE
// Declared type of an expression - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
//
// Right angle brackets - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
//
// Default template arguments for function templates DR226 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
//
// Solving the SFINAE problem for expressions DR339 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2634.html
// #define GLM_CXX11_ALIAS_TEMPLATE
// Template aliases N2258 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
//
// Extern templates N1987 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
// #define GLM_CXX11_NULLPTR
// Null pointer constant N2431 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
// #define GLM_CXX11_STRONG_ENUMS
// Strongly-typed enums N2347 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
//
// Forward declarations for enums N2764 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
//
// Generalized attributes N2761 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
//
// Generalized constant expressions N2235 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf
//
// Alignment support N2341 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
// #define GLM_CXX11_DELEGATING_CONSTRUCTORS
// Delegating constructors N1986 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
//
// Inheriting constructors N2540 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm
// #define GLM_CXX11_EXPLICIT_CONVERSIONS
// Explicit conversion operators N2437 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
//
// New character types N2249 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2249.html
//
// Unicode string literals N2442 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
//
// Raw string literals N2442 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
//
// Universal character name literals N2170 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html
// #define GLM_CXX11_USER_LITERALS
// User-defined literals N2765 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
//
// Standard Layout Types N2342 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm
// #define GLM_CXX11_DEFAULTED_FUNCTIONS
// #define GLM_CXX11_DELETED_FUNCTIONS
// Defaulted and deleted functions N2346 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
//
// Extended friend declarations N1791 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
//
// Extending sizeof N2253 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
// #define GLM_CXX11_INLINE_NAMESPACES
// Inline namespaces N2535 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm
// #define GLM_CXX11_UNRESTRICTED_UNIONS
// Unrestricted unions N2544 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
// #define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS
// Local and unnamed types as template arguments N2657 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
// #define GLM_CXX11_RANGE_FOR
// Range-based for N2930 GCC 4.6
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html
// #define GLM_CXX11_OVERRIDE_CONTROL
// Explicit virtual overrides N2928 N3206 N3272 GCC 4.7
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm
//
// Minimal support for garbage collection and reachability-based leak detection N2670 No
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm
// #define GLM_CXX11_NOEXCEPT
// Allowing move constructors to throw [noexcept] N3050 GCC 4.6 (core language only)
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
//
// Defining move special member functions N3053 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html
//
// Sequence points N2239 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html
//
// Atomic operations N2427 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html
//
// Strong Compare and Exchange N2748 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
//
// Bidirectional Fences N2752 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2752.htm
//
// Memory model N2429 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm
//
// Data-dependency ordering: atomics and memory model N2664 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2664.htm
//
// Propagating exceptions N2179 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html
//
// Abandoning a process and at_quick_exit N2440 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2440.htm
//
// Allow atomics use in signal handlers N2547 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2547.htm
//
// Thread-local storage N2659 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm
//
// Dynamic initialization and destruction with concurrency N2660 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm
//
// __func__ predefined identifier N2340 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm
//
// C99 preprocessor N1653 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm
//
// long long N1811 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf
//
// Extended integral types N1988 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1988.pdf
#if(GLM_COMPILER & GLM_COMPILER_GCC)
# if(GLM_COMPILER >= GLM_COMPILER_GCC43)
# define GLM_CXX11_STATIC_ASSERT
# endif
#elif(GLM_COMPILER & GLM_COMPILER_CLANG)
# if(__has_feature(cxx_exceptions))
# define GLM_CXX98_EXCEPTIONS
# endif
# if(__has_feature(cxx_rtti))
# define GLM_CXX98_RTTI
# endif
# if(__has_feature(cxx_access_control_sfinae))
# define GLM_CXX11_ACCESS_CONTROL_SFINAE
# endif
# if(__has_feature(cxx_alias_templates))
# define GLM_CXX11_ALIAS_TEMPLATE
# endif
# if(__has_feature(cxx_alignas))
# define GLM_CXX11_ALIGNAS
# endif
# if(__has_feature(cxx_attributes))
# define GLM_CXX11_ATTRIBUTES
# endif
# if(__has_feature(cxx_constexpr))
# define GLM_CXX11_CONSTEXPR
# endif
# if(__has_feature(cxx_decltype))
# define GLM_CXX11_DECLTYPE
# endif
# if(__has_feature(cxx_default_function_template_args))
# define GLM_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS
# endif
# if(__has_feature(cxx_defaulted_functions))
# define GLM_CXX11_DEFAULTED_FUNCTIONS
# endif
# if(__has_feature(cxx_delegating_constructors))
# define GLM_CXX11_DELEGATING_CONSTRUCTORS
# endif
# if(__has_feature(cxx_deleted_functions))
# define GLM_CXX11_DELETED_FUNCTIONS
# endif
# if(__has_feature(cxx_explicit_conversions))
# define GLM_CXX11_EXPLICIT_CONVERSIONS
# endif
# if(__has_feature(cxx_generalized_initializers))
# define GLM_CXX11_GENERALIZED_INITIALIZERS
# endif
# if(__has_feature(cxx_implicit_moves))
# define GLM_CXX11_IMPLICIT_MOVES
# endif
# if(__has_feature(cxx_inheriting_constructors))
# define GLM_CXX11_INHERITING_CONSTRUCTORS
# endif
# if(__has_feature(cxx_inline_namespaces))
# define GLM_CXX11_INLINE_NAMESPACES
# endif
# if(__has_feature(cxx_lambdas))
# define GLM_CXX11_LAMBDAS
# endif
# if(__has_feature(cxx_local_type_template_args))
# define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS
# endif
# if(__has_feature(cxx_noexcept))
# define GLM_CXX11_NOEXCEPT
# endif
# if(__has_feature(cxx_nonstatic_member_init))
# define GLM_CXX11_NONSTATIC_MEMBER_INIT
# endif
# if(__has_feature(cxx_nullptr))
# define GLM_CXX11_NULLPTR
# endif
# if(__has_feature(cxx_override_control))
# define GLM_CXX11_OVERRIDE_CONTROL
# endif
# if(__has_feature(cxx_reference_qualified_functions))
# define GLM_CXX11_REFERENCE_QUALIFIED_FUNCTIONS
# endif
# if(__has_feature(cxx_range_for))
# define GLM_CXX11_RANGE_FOR
# endif
# if(__has_feature(cxx_raw_string_literals))
# define GLM_CXX11_RAW_STRING_LITERALS
# endif
# if(__has_feature(cxx_rvalue_references))
# define GLM_CXX11_RVALUE_REFERENCES
# endif
# if(__has_feature(cxx_static_assert))
# define GLM_CXX11_STATIC_ASSERT
# endif
# if(__has_feature(cxx_auto_type))
# define GLM_CXX11_AUTO_TYPE
# endif
# if(__has_feature(cxx_strong_enums))
# define GLM_CXX11_STRONG_ENUMS
# endif
# if(__has_feature(cxx_trailing_return))
# define GLM_CXX11_TRAILING_RETURN
# endif
# if(__has_feature(cxx_unicode_literals))
# define GLM_CXX11_UNICODE_LITERALS
# endif
# if(__has_feature(cxx_unrestricted_unions))
# define GLM_CXX11_UNRESTRICTED_UNIONS
# endif
# if(__has_feature(cxx_user_literals))
# define GLM_CXX11_USER_LITERALS
# endif
# if(__has_feature(cxx_variadic_templates))
# define GLM_CXX11_VARIADIC_TEMPLATES
# endif
#endif//(GLM_COMPILER & GLM_COMPILER_CLANG)
// CG_REVISION 1d384085f04ade0a730db0ed88bbd9f2df80dad9
| [
"n1085633848@outlook.com"
] | n1085633848@outlook.com |
fefd48271de7b2f16a32bedbbcaaf52d7397254c | 7e5603e4fa6df95506eb7ab25b934c3922281d0b | /src/Tweener.cpp | 7383c19a5f32bb6b28101c5559e31d359af8c0d3 | [
"MIT"
] | permissive | johndpope/GIRenderer | 344168021ccae09800a3f43943f2036c5d948dd2 | 3856c2455b668d16c0bf41d453be895a39053217 | refs/heads/master | 2021-06-10T01:30:02.117024 | 2016-09-26T14:47:30 | 2016-09-26T14:47:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 335 | cpp | //
// Created by inosphe on 2016. 9. 21..
//
#include "Tweener.h"
Tweener::Tweener(glm::vec3 v0, glm::vec3 v1, float time):m_v0(v0), m_v1(v1), m_time(time) {
}
void Tweener::Update(float dt) {
m_t += dt;
if(m_t >= m_time)
m_t -= m_time;
}
glm::vec3 Tweener::GetValue() {
float t = m_t/m_time;
return m_v0 + (m_v1-m_v0)*t;
}
| [
"inosphe@gmail.com"
] | inosphe@gmail.com |
e85b29e4903ff033afb4e6cd76144d1a0228c1c8 | 4500e857477f7f763f17c0fa0f59450457f3a46c | /src/math/lp/nla_order_lemmas.h | 24b7b2cb4df4fec2688ab436c6a985c88ae5dc28 | [
"MIT"
] | permissive | copumpkin/z3 | 1cc2c8977c9a7692d01a2598632870d73dba4c3b | 785c9a18cab28b9adfc71ec981f7452fd65279fd | refs/heads/master | 2022-04-22T19:32:53.727110 | 2020-04-24T18:58:48 | 2020-04-24T18:58:48 | 258,669,037 | 1 | 1 | NOASSERTION | 2020-04-25T02:20:48 | 2020-04-25T02:20:48 | null | UTF-8 | C++ | false | false | 3,170 | h | /*++
Copyright (c) 2017 Microsoft Corporation
Module Name:
<name>
Abstract:
<abstract>
Author:
Nikolaj Bjorner (nbjorner)
Lev Nachmanson (levnach)
Revision History:
--*/
#pragma once
#include "math/lp/factorization.h"
#include "math/lp/nla_common.h"
namespace nla {
class core;
class order: common {
public:
order(core *c) : common(c) {}
void order_lemma();
private:
bool order_lemma_on_ac_and_bc_and_factors(const monic& ac,
const factor& a,
const factor& c,
const monic& bc,
const factor& b);
// a >< b && c > 0 => ac >< bc
// a >< b && c < 0 => ac <> bc
// ac[k] plays the role of c
bool order_lemma_on_ac_and_bc(const monic& rm_ac,
const factorization& ac_f,
bool k,
const monic& rm_bd);
bool order_lemma_on_ac_explore(const monic& rm, const factorization& ac, bool k);
void order_lemma_on_factorization(const monic& rm, const factorization& ab);
/**
\brief Add lemma:
a > 0 & b <= value(b) => sign*ab <= value(b)*a if value(a) > 0
a < 0 & b >= value(b) => sign*ab <= value(b)*a if value(a) < 0
*/
void order_lemma_on_ab_gt(const monic& m, const rational& sign, lpvar a, lpvar b);
// we need to deduce ab >= val(b)*a
/**
\brief Add lemma:
a > 0 & b >= value(b) => sign*ab >= value(b)*a if value(a) > 0
a < 0 & b <= value(b) => sign*ab >= value(b)*a if value(a) < 0
*/
void order_lemma_on_ab_lt(const monic& m, const rational& sign, lpvar a, lpvar b);
void order_lemma_on_ab(const monic& m, const rational& sign, lpvar a, lpvar b, bool gt);
void order_lemma_on_factor_binomial_explore(const monic& m, bool k);
void order_lemma_on_factor_binomial_rm(const monic& ac, bool k, const monic& bd);
void order_lemma_on_binomial_ac_bd(const monic& ac, bool k, const monic& bd, const factor& b, lpvar d);
void order_lemma_on_binomial_sign(const monic& ac, lpvar x, lpvar y, int sign);
void order_lemma_on_binomial(const monic& ac);
void order_lemma_on_monic(const monic& rm);
void generate_ol(const monic& ac,
const factor& a,
const factor& c,
const monic& bc,
const factor& b);
void generate_ol_eq(const monic& ac,
const factor& a,
const factor& c,
const monic& bc,
const factor& b);
void generate_mon_ol(const monic& ac,
lpvar a,
const rational& c_sign,
lpvar c,
const monic& bd,
const factor& b,
const rational& d_sign,
lpvar d,
llc ab_cmp);
};
}
| [
"levnach@hotmail.com"
] | levnach@hotmail.com |
d2dbc4eff802e6133b9134acea2263f9d13b7d11 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第四章 数组和指针/20090321_习题4.33_把int型vector对象复制给int型数组.cpp | 34d2f7c15f3d670793fbd37093933f52a6fc303f | [] | no_license | lzq123218/guoyishi-works | dbfa42a3e2d3bd4a984a5681e4335814657551ef | 4e78c8f2e902589c3f06387374024225f52e5a92 | refs/heads/master | 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 570 | cpp | //20090321 Care of DELETE
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int ival;
vector<int> ivec;
cout << "Enter some integers(Ctrl+Z to end):" << endl;
while (cin >> ival) {
ivec.push_back(ival);
}
cin.clear();
int *parr = new int[ivec.size()];
size_t ix;
vector<int>::iterator iter = ivec.begin();
for (ix = 0; ix != ivec.size(); ++ix) {
parr[ix] = *iter++;
cout << parr[ix] << " ";
if ((ix + 1) % 10 == 0)
cout << endl;
}
cout << endl;
delete [] parr; //IMPORTANT
return 0;
}
| [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] | baicaibang@70501136-4834-11de-8855-c187e5f49513 |
d9b2cea8e7465fb1e60da6ab3740c1bc9c7a2c3f | 6680f8d317de48876d4176d443bfd580ec7a5aef | /Header/ProjectConfig/ISettingStorageEditor.h | dee65ed0086c6e32e07d15031675d8831498affa | [] | no_license | AlirezaMojtabavi/misInteractiveSegmentation | 1b51b0babb0c6f9601330fafc5c15ca560d6af31 | 4630a8c614f6421042636a2adc47ed6b5d960a2b | refs/heads/master | 2020-12-10T11:09:19.345393 | 2020-03-04T11:34:26 | 2020-03-04T11:34:26 | 233,574,482 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 679 | h | #pragma once
#include "ISettingsContainer.h"
// The ISettingStorageEditor class provides an abstract interface for opening, editing, and saving a settings storage file.
class ISettingStorageEditor
{
public:
// Loads the user preferences from the file specified.
virtual void LoadFromFile(const std::string& preferences) = 0;
// Saves the user preferences to the file specified.
virtual void SaveToFile(const std::string& preferences) = 0;
// Gets the Preferences loaded from the registry.
virtual std::shared_ptr<ISettingsContainer> GetPreferences() const = 0;
virtual void SetRootNodePath(const std::string& path) = 0;
virtual ~ISettingStorageEditor(void) { }
};
| [
"alireza_mojtabavi@yahoo.com"
] | alireza_mojtabavi@yahoo.com |
81eb2869c035a5713ce067948c567ec635ce1497 | 674cad3c5f99f608f920b70c7ea865d72cfe940c | /Uri/Geral/UOJ_1286 - (57920) Accepted.cpp | 5767af01a8098719920119867ff3b8cb1d33be56 | [] | no_license | wellvolks/Problemas | c876b6120f1622d614767ecc99dba802c395e772 | 6513ea2b126977f45cb2388f753188e95328af2e | refs/heads/master | 2020-06-30T18:38:15.453372 | 2017-11-20T00:42:36 | 2017-11-20T00:42:36 | 67,306,714 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,208 | cpp | #include <map>
#include <set>
#include <list>
#include <stack>
#include <cmath>
#include <queue>
#include <ctime>
#include <cfloat>
#include <vector>
#include <string>
#include <cstdio>
#include <bitset>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define RFOR(i, b, a) for(int i = b; i >= a; --i)
#define REP(i, N) for(int i = 0; i < N; ++i)
#define RREP(i, N) for(int i = N-1; i >= 1; --i)
#define FORIT(i, a) for( TI(a) i = a.begin(); i != a.end(); i++ )
#define MAXN 10000
#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3FFFFFFFFFLL
#define FILL(X, V) memset( X, V, sizeof(X) )
#define TI(X) __typeof((X).begin())
#define ALL(V) V.begin(), V.end()
#define SIZE(V) int((V).size())
#define pb push_back
#define mk make_pair
struct tri{
int atual, custo;
tri ( int atual = 0, int custo = 0) : atual(atual), custo(custo) { }
};
int k;
typedef vector < int > vi;
typedef vector < vi > vii;
typedef vector < tri > vtri;
typedef vector < vtri > vvtri;
typedef long long int64;
typedef unsigned long long uint64;
int dp[1000][1000], w[1000], v[1000];
inline void read( int &n ) {
n = 0;
bool neg = false;
char c = getchar_unlocked();
if( c == EOF){ n = -400; return; }
while (!('0' <= c && c <= '9')) {
if( c == '-' ) neg = true;
c = getchar_unlocked();
}
while ('0' <= c && c <= '9') {
n = n * 10 + c - '0';
c = getchar_unlocked();
}
n = (neg ? (-n) : (n));
}
int mochila (int n, int W){
register int a, b;
for(register int y = 0; y <= W; y++){
dp[0][y] = 0;
for(register int i = 1; i <= n; i++){
a = dp[i-1][y];
if(w[i] > y) b = 0;
else b = dp[i-1][y-w[i]] + v[i];
dp[i][y] = max(a,b);
}
}
return dp[n][W];
}
int main(){
register int s, n, t;
while(true ){
read(n);
if( ! n ) break;
read(s);
REP(i,n){ read(v[i+1]); read(w[i+1]); } //scanf("%d%d",&v[i+1],&w[i+1]);
printf("%d min.\n", mochila(n,s));
}
return 0;
}
| [
"noreply@github.com"
] | wellvolks.noreply@github.com |
6cce342ed727a6b37c7867687a316a5f5a9c1c5a | f0ceef11d730b63337fa5485309bcff898aee5d1 | /Actor/Timer.h | 47a970ceaa45f6e2f682480ce177676485895cc3 | [
"MIT"
] | permissive | ahwayakchih/Medo | ec222efbbbfa22a6b2b1ae2982a1157d459b86b1 | acc34c189676544c092fbc6800c27a25d05de6dd | refs/heads/main | 2023-02-02T14:57:46.884655 | 2020-12-22T23:49:55 | 2020-12-22T23:49:55 | 323,804,986 | 0 | 0 | MIT | 2020-12-23T04:47:34 | 2020-12-23T04:47:33 | null | UTF-8 | C++ | false | false | 1,551 | h | /* PROJECT: Yarra Actor Model
AUTHORS: Zenja Solaja, Melbourne Australia
COPYRIGHT: 2017-2018, ZenYes Pty Ltd
DESCRIPTION: Timer
*/
#ifndef _YARRA_TIMER_H_
#define _YARRA_TIMER_H_
#ifndef _YARRA_ACTOR_H_
#include "Actor.h"
#endif
#include <deque>
namespace Platform
{
class Thread;
class Semaphore;
};
namespace yarra
{
/******************************
yarra::Timer
*******************************/
class Timer : public Actor
{
public:
Timer();
~Timer();
/* Schedule timer message:
Prefer to use yarra::ActorManager::GetInstance()->AddTimer(milliseconds, target, std::bind(&Actor::Behaviour, target, ...));
*/
void AddTimer(const int64_t milliseconds, Actor *target, std::function<void()> behaviour);
void CancelTimersLocked(Actor *target);
private:
struct TimerObject
{
int64_t milliseconds;
Actor *target;
std::function<void()> behaviour;
#if ACTOR_DEBUG
double timestamp;
#endif
TimerObject(int64_t ms, Actor *t, std::function<void()> b)
: milliseconds(ms), target(t), behaviour(b)
{
#if ACTOR_DEBUG
timestamp = Platform::GetElapsedTime();
#endif
}
};
std::deque<TimerObject> fTimerQueue;
double fTimeStamp;
void TimerTickLocked();
Platform::Thread *fTimerThread;
Platform::Semaphore fQueueLock;
Platform::Semaphore fThreadSemaphore;
static int TimerThread(void *);
bool fKeepAlive;
friend class ActorManager;
const bool IsBusy();
};
}; //namespace yarra
#endif //#ifndef _YARRA_TIMER_H_ | [
"solaja@gmail.com"
] | solaja@gmail.com |
b7dd1c96678fa245994f9d5e9c2008e55f487bf3 | 5fa0e32ee5bf534e4a187870985d62d55eb3d5c6 | /humble-crap/humble-network.hpp | 7a8dd9461cbe2464425c6e4962bc2879b7e4f343 | [
"Unlicense"
] | permissive | lukesalisbury/humble-crap | 271ce3b6df1dfa9f1e7a8d710509e4e82bb1629c | 814c551cfdfa2687d531b50d350a0d2a6f5cf832 | refs/heads/master | 2021-01-18T17:14:59.234310 | 2019-10-28T05:30:37 | 2019-10-28T05:30:37 | 12,215,398 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,395 | hpp | /****************************************************************************
* Copyright © Luke Salisbury
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgement in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
****************************************************************************/
#ifndef HUMBLENETWORK_HPP
#define HUMBLENETWORK_HPP
#include <QObject>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtCore>
#include <QNetworkCookieJar>
#include <QNetworkCookie>
#include "local-cookie-jar.hpp"
class HumbleNetworkRequest : public QObject
{
Q_OBJECT
public:
explicit HumbleNetworkRequest( );
QByteArray retrieveContent();
bool writeContent( QString outputFile );
void appendPost( QString key, QString value );
bool makeRequest(QUrl url, QString requester = "XMLHttpRequest");
QNetworkCookieJar * getCookies();
bool setCookies(QNetworkCookieJar * cookies_jar);
void printCookies();
signals:
void requestError( QString errorMessage, QByteArray content, qint16 httpCode );
void requestSuccessful( QByteArray content );
void requestProgress( qint64 bytesReceived, qint64 bytesTotal );
public slots:
void finishRequest( QNetworkReply* pReply );
void sslError( QNetworkReply* pReply, const QList<QSslError> & errors );
void downloadProgress ( qint64 bytesReceived, qint64 bytesTotal );
private:
QNetworkReply * reply;
QNetworkAccessManager * webManager;
QByteArray downloadData;
QString errorMessage;
QByteArray postData;
public:
bool sslMissing;
QString csrfPreventionToken = "";
};
#endif // HUMBLENETWORK_HPP
| [
"dev@lukesalisbury.name"
] | dev@lukesalisbury.name |
e1616ce9bab8b4bf5796ead03be1bc7f7e15f8d9 | 1c8bca2e8234e0b6e8a70db91b1d4749d13783f2 | /Linux/FFP/12_TexturePyramidAndCube/TexturePyramidAndCube.cpp | 5aac4ed0b084ebd6395a35b33ca5c21b24f0a8e6 | [] | no_license | jayshreegandhi/RTR | 206e6e307dc9d3bfef85492b2f0efdcb7e429881 | 88d49f1e1f2b6ad58e29b5aaf279ffdfe7f53201 | refs/heads/master | 2023-01-05T01:47:18.935907 | 2020-11-09T06:36:20 | 2020-11-09T06:36:20 | 311,237,656 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,513 | cpp | #include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<X11/Xlib.h>
#include<X11/Xutil.h>
#include<X11/XKBlib.h>
#include<X11/keysym.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>
#include<SOIL/SOIL.h>
using namespace std;
bool bFullscreen = false;
Display *gpDisplay = NULL;
XVisualInfo *gpXVisualInfo = NULL;
Colormap gColormap;
Window gWindow;
int gWindowWidth = 800;
int gWindowHeight = 600;
FILE *gpFile = NULL;
//function prototypes
void CreateWindow(void);
void ToggleFullscreen(void);
void uninitialize(void);
GLXContext gGLXContext;
void initialize(void);
void resize(int,int);
void display(void);
void update(void);
bool bDone = false;
bool loadTexture(GLuint *, const char *);
void DrawPyramid(void);
void DrawCube(void);
GLfloat pyramidSpinningAngle = 0.0f;
GLuint texture_stone;
GLfloat cubeRotationAngle = 0.0f;
GLuint texture_kundali;
int main(void)
{
int winWidth = gWindowWidth;
int winHeight = gWindowHeight;
gpFile = fopen("Log.txt", "w");
if (!(gpFile))
{
printf("Log file can not be created\n");
exit(0);
}
else
{
fprintf(gpFile, "Log file created successfully...\n");
}
CreateWindow();
initialize();
XEvent event;
KeySym keysym;
while(bDone == false)
{
while(XPending(gpDisplay))
{
XNextEvent(gpDisplay,&event);
switch(event.type)
{
case MapNotify:
break;
case KeyPress:
keysym = XkbKeycodeToKeysym(gpDisplay, event.xkey.keycode, 0, 0);
switch(keysym)
{
case XK_Escape:
bDone = true;
break;
case XK_F:
case XK_f:
if(bFullscreen == false)
{
ToggleFullscreen();
bFullscreen = true;
}
else
{
ToggleFullscreen();
bFullscreen = false;
}
break;
default:
break;
}
break;
case ButtonPress:
switch(event.xbutton.button)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
break;
case MotionNotify:
break;
case ConfigureNotify:
winWidth = event.xconfigure.width;
winHeight = event.xconfigure.height;
resize(winWidth,winHeight);
break;
case Expose:
break;
case DestroyNotify:
break;
case 33:
bDone = true;
break;
default:
break;
}
}
update();
display();
}
uninitialize();
return(0);
}
void CreateWindow(void)
{
XSetWindowAttributes winAttribs;
int defaultScreen;
//int defaultDepth;
int styleMask;
//though not necessary in our opengl practices , it(static) is done by many SDKs ex: Imagination,Unreal
static int frameBufferAttribute[] = {
GLX_RGBA,
GLX_DOUBLEBUFFER,True,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE,24,
None
};
gpDisplay = XOpenDisplay(NULL);
if(gpDisplay == NULL)
{
fprintf(gpFile, "\nERROR : Unable to open XDisplay.Exitting now..\n");
printf("\nERROR : Unable to open XDisplay.\nExitting now..\n");
uninitialize();
exit(1);
}
defaultScreen = XDefaultScreen(gpDisplay);
//defaultDepth = DefaultDepth(gpDisplay,defaultScreen);
//Bridging API gives you visual in opengl code
gpXVisualInfo = glXChooseVisual(gpDisplay, defaultScreen, frameBufferAttribute);
if(gpXVisualInfo == NULL)
{
fprintf(gpFile, "\nERROR : Unable to get XVisualInfo .Exitting now..\n");
printf("\nERROR : Unable to get XVisualInfo.\nExitting now..\n");
uninitialize();
exit(1);
}
winAttribs.border_pixel = 0;
winAttribs.border_pixmap = 0;
winAttribs.colormap = XCreateColormap(gpDisplay,
RootWindow(gpDisplay, gpXVisualInfo->screen),
gpXVisualInfo->visual,
AllocNone);
winAttribs.background_pixel = BlackPixel(gpDisplay, defaultScreen);
winAttribs.background_pixmap = 0;
winAttribs.event_mask = ExposureMask |
VisibilityChangeMask |
ButtonPressMask |
KeyPressMask |
PointerMotionMask |
StructureNotifyMask;
styleMask = CWBorderPixel |
CWBackPixel |
CWEventMask |
CWColormap;
gWindow = XCreateWindow(gpDisplay,
RootWindow(gpDisplay, gpXVisualInfo->screen),
0,
0,
gWindowWidth,
gWindowHeight,
0,
gpXVisualInfo->depth,
InputOutput,
gpXVisualInfo->visual,
styleMask,
&winAttribs);
if(!gWindow)
{
fprintf(gpFile, "\nERROR : Failed to create main window.Exitting now..\n");
printf("\nERROR : Failed to create main window.\nExitting now..\n");
uninitialize();
exit(1);
}
XStoreName(gpDisplay, gWindow, "My First XWindows Window - Jayshree Gandhi");
Atom windowManagerDelete = XInternAtom(gpDisplay, "WM_DELETE_WINDOW",True);
XSetWMProtocols(gpDisplay, gWindow, &windowManagerDelete, 1);
XMapWindow(gpDisplay, gWindow);
}
void ToggleFullscreen(void)
{
Atom wm_state;
Atom fullscreen;
XEvent xev = {0};
wm_state = XInternAtom(gpDisplay, "_NET_WM_STATE", False);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = gWindow;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = bFullscreen ? 0 : 1;
fullscreen = XInternAtom(gpDisplay, "_NET_WM_STATE_FULLSCREEN", False);
xev.xclient.data.l[1] = fullscreen;
XSendEvent(gpDisplay,
RootWindow(gpDisplay, gpXVisualInfo->screen),
False,
StructureNotifyMask,
&xev);
}
bool loadTexture(GLuint *texture, const char* path)
{
bool bResult = false;
int imageWidth;
int imageHeight;
unsigned char* imageData = NULL;
imageData = SOIL_load_image(path,
&imageWidth,
&imageHeight,
0,
SOIL_LOAD_RGB);
if(imageData == NULL)
{
bResult = false;
return(bResult);
}
else
{
bResult = true;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D,
3,
imageWidth,
imageHeight,
GL_BGR_EXT,
GL_UNSIGNED_BYTE,
imageData);
SOIL_free_image_data(imageData);
return(bResult);
}
void initialize(void)
{
//get the rendering context
gGLXContext = glXCreateContext(gpDisplay,gpXVisualInfo,NULL,GL_TRUE);
if(gGLXContext == NULL)
{
//return(-1);
fprintf(gpFile, "\nERROR : glXCreateContext() Failed\n");
printf("\nERROR : glXCreateContext() Failed\nExitting now..\n");
uninitialize();
exit(1);
}
glXMakeCurrent(gpDisplay,gWindow,gGLXContext);
//usual opengl initialization code:
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
loadTexture(&texture_stone,"Stone.bmp");
loadTexture(&texture_kundali,"Kundali.bmp");
resize(gWindowWidth,gWindowHeight);
}
void resize(int width, int height)
{
//usual resize code
if(height == 0)
{
height = 1;
}
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
}
void display(void)
{
//usual display code - last line only in double buffering
//but in single buffering, whole code is same
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
glTranslatef(-1.5f, 0.0f, -5.0f);
glRotatef(pyramidSpinningAngle, 0.0f, 1.0f, 0.0f);
glBindTexture(GL_TEXTURE_2D,texture_stone);
DrawPyramid();
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
glTranslatef(1.5f, 0.0f, -5.0f);
glScalef(0.75f, 0.75f, 0.75f);
glRotatef(cubeRotationAngle,1.0f, 1.0f, 1.0f);
glBindTexture(GL_TEXTURE_2D, texture_kundali);
DrawCube();
glDisable(GL_TEXTURE_2D);
glXSwapBuffers(gpDisplay, gWindow);
}
void update(void)
{
pyramidSpinningAngle = pyramidSpinningAngle + 1.0f;
if (pyramidSpinningAngle >= 360.0f)
{
pyramidSpinningAngle = 0.0f;
}
cubeRotationAngle = cubeRotationAngle - 1.0f;
if (cubeRotationAngle <= -360.0f)
{
cubeRotationAngle = 0.0f;
}
}
void uninitialize(void)
{
GLXContext currentGLXContext = glXGetCurrentContext();
if(currentGLXContext != NULL && currentGLXContext == gGLXContext)
{
glXMakeCurrent(gpDisplay, 0,0);
}
if(gGLXContext)
{
glXDestroyContext(gpDisplay,gGLXContext);
}
if(gWindow)
{
XDestroyWindow(gpDisplay, gWindow);
gWindow = 0;
}
if(gColormap)
{
XFreeColormap(gpDisplay, gColormap);
gColormap = 0;
}
if(gpXVisualInfo)
{
free(gpXVisualInfo);
gpXVisualInfo = NULL;
}
if(gpDisplay)
{
XCloseDisplay(gpDisplay);
gpDisplay = NULL;
}
if (texture_stone)
{
glDeleteTextures(1,&texture_stone);
}
if (texture_kundali)
{
glDeleteTextures(1, &texture_kundali);
}
if (gpFile)
{
fprintf(gpFile, "Log file closed successfully\n");
fclose(gpFile);
gpFile = NULL;
}
}
void DrawPyramid(void)
{
glBegin(GL_TRIANGLES);
//front face
glTexCoord2f(0.5f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
//right face
glTexCoord2f(0.5f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
//back face
glTexCoord2f(0.5f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
//left face
glTexCoord2f(0.5f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glEnd();
}
void DrawCube(void)
{
glBegin(GL_QUADS);
//top face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, -1.0f);//rt
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);//lt
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);//lb
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);//rb
glEnd();
glBegin(GL_QUADS);
//bottom face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, -1.0f, -1.0f);//rt
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);//lt
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);//lb
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);//rb
glEnd();
glBegin(GL_QUADS);
//front face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glEnd();
glBegin(GL_QUADS);
//back face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glEnd();
glBegin(GL_QUADS);
//right face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glEnd();
glBegin(GL_QUADS);
//left face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glEnd();
}
| [
"jayshreeggandhi@gmail.com"
] | jayshreeggandhi@gmail.com |
a8f2d00ce0d777937bf428f669a0f650aa41c23e | a1df96e81a37b702ede4b8d8d68fb752ab864c48 | /src/qt/bitcoingui.cpp | 7d3ead241db96271e589a50bcab834430dbc0ca6 | [
"MIT"
] | permissive | underline-project/underline-success-build | 83fd0f552088cfa4a4c5ec1e9032cde5355fa7eb | 420ea9d83204e6e79a14c57a85881bef88735c60 | refs/heads/master | 2021-04-15T14:47:51.034232 | 2018-03-23T09:23:51 | 2018-03-23T09:23:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,320 | cpp | // Copyright (c) 2011-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
#include "bitcoingui.h"
#include "bitcoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "modaloverlay.h"
#include "networkstyle.h"
#include "notificator.h"
#include "openuridialog.h"
#include "optionsdialog.h"
#include "optionsmodel.h"
#include "platformstyle.h"
#include "rpcconsole.h"
#include "utilitydialog.h"
#ifdef ENABLE_WALLET
#include "walletframe.h"
#include "walletmodel.h"
#endif // ENABLE_WALLET
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#include "chainparams.h"
#include "init.h"
#include "ui_interface.h"
#include "util.h"
#include <iostream>
#include <QAction>
#include <QApplication>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QListWidget>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressDialog>
#include <QSettings>
#include <QShortcut>
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
#if QT_VERSION < 0x050000
#include <QTextDocument>
#include <QUrl>
#else
#include <QUrlQuery>
#endif
const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
#if defined(Q_OS_MAC)
"macosx"
#elif defined(Q_OS_WIN)
"windows"
#else
"other"
#endif
;
/** Display name for default wallet name. Uses tilde to avoid name
* collisions in the future with additional wallets */
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
enableWallet(false),
clientModel(0),
walletFrame(0),
unitDisplayControl(0),
labelWalletEncryptionIcon(0),
labelWalletHDStatusIcon(0),
connectionsControl(0),
labelBlocksIcon(0),
progressBarLabel(0),
progressBar(0),
progressDialog(0),
appMenuBar(0),
overviewAction(0),
historyAction(0),
quitAction(0),
sendCoinsAction(0),
sendCoinsMenuAction(0),
usedSendingAddressesAction(0),
usedReceivingAddressesAction(0),
signMessageAction(0),
verifyMessageAction(0),
aboutAction(0),
receiveCoinsAction(0),
receiveCoinsMenuAction(0),
optionsAction(0),
toggleHideAction(0),
encryptWalletAction(0),
backupWalletAction(0),
changePassphraseAction(0),
aboutQtAction(0),
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
trayIcon(0),
trayIconMenu(0),
notificator(0),
rpcConsole(0),
helpMessageDialog(0),
modalOverlay(0),
prevBlocks(0),
spinnerFrame(0),
platformStyle(_platformStyle)
{
QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
}
QString windowTitle = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
if(enableWallet)
{
windowTitle += tr("Wallet");
} else {
windowTitle += tr("Node");
}
windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowIcon(networkStyle->getTrayAndWindowIcon());
#else
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
setWindowTitle(windowTitle);
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
// This property is not implemented in Qt 5. Setting it has no effect.
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
setUnifiedTitleAndToolBarOnMac(true);
#endif
rpcConsole = new RPCConsole(_platformStyle, 0);
helpMessageDialog = new HelpMessageDialog(this, false);
#ifdef ENABLE_WALLET
if(enableWallet)
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(_platformStyle, this);
setCentralWidget(walletFrame);
} else
#endif // ENABLE_WALLET
{
/* When compiled without wallet or -disablewallet is provided,
* the central widget is the rpc console.
*/
setCentralWidget(rpcConsole);
}
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
createActions();
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create system tray icon and notification
createTrayIcon(networkStyle);
// Create status bar
statusBar();
// Disable size grip because it looks ugly and nobody needs it
statusBar()->setSizeGripEnabled(false);
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel();
connectionsControl = new GUIUtil::ClickableLabel();
labelBlocksIcon = new GUIUtil::ClickableLabel();
if(enableWallet)
{
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(unitDisplayControl);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
}
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(connectionsControl);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
progressBarLabel->setVisible(false);
progressBar = new GUIUtil::ProgressBar();
progressBar->setAlignment(Qt::AlignCenter);
progressBar->setVisible(false);
// Override style sheet for progress bar for styles that have a segmented progress bar,
// as they make the text unreadable (workaround for issue #1071)
// See https://qt-project.org/doc/qt-4.8/gallery.html
QString curStyle = QApplication::style()->metaObject()->className();
if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
{
progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
}
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->addPermanentWidget(frameBlocks);
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
// Initially wallet actions should be disabled
setWalletActionsEnabled(false);
// Subscribe to notifications from core
subscribeToCoreSignals();
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
modalOverlay = new ModalOverlay(this->centralWidget());
#ifdef ENABLE_WALLET
if(enableWallet) {
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
}
#endif
}
BitcoinGUI::~BitcoinGUI()
{
// Unsubscribe from notifications from core
unsubscribeFromCoreSignals();
QSettings settings;
settings.setValue("MainWindowGeometry", saveGeometry());
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
delete appMenuBar;
MacDockIconHandler::cleanup();
#endif
delete rpcConsole;
}
void BitcoinGUI::createActions()
{
QActionGroup *tabGroup = new QActionGroup(this);
overviewAction = new QAction(platformStyle->SingleColorIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
sendCoinsAction->setStatusTip(tr("Send coins to a Underline address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
tabGroup->addAction(sendCoinsAction);
sendCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/send"), sendCoinsAction->text(), this);
sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and underline: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
tabGroup->addAction(receiveCoinsAction);
receiveCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this);
receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);
#ifdef ENABLE_WALLET
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
#endif // ENABLE_WALLET
quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&About %1").arg(tr(PACKAGE_NAME)), this);
aboutAction->setStatusTip(tr("Show information about %1").arg(tr(PACKAGE_NAME)));
aboutAction->setMenuRole(QAction::AboutRole);
aboutAction->setEnabled(false);
aboutQtAction = new QAction(platformStyle->TextColorIcon(":/icons/about_qt"), tr("About &Qt"), this);
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(platformStyle->TextColorIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
optionsAction->setMenuRole(QAction::PreferencesRole);
optionsAction->setEnabled(false);
toggleHideAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(platformStyle->TextColorIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
signMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your Underline addresses to prove you own them"));
verifyMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/verify"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Underline addresses"));
openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
// initially disable the debug window menu item
openRPCConsoleAction->setEnabled(false);
usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a underline: URI or payment request"));
showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Underline command-line options").arg(tr(PACKAGE_NAME)));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showDebugWindow()));
// prevents an open debug window from becoming stuck/unusable on client shutdown
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
#ifdef ENABLE_WALLET
if(walletFrame)
{
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
}
#endif // ENABLE_WALLET
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showDebugWindowActivateConsole()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, SLOT(showDebugWindow()));
}
void BitcoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
// Get the main window's menu bar on other platforms
appMenuBar = menuBar();
#endif
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
if(walletFrame)
{
file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
}
file->addAction(quitAction);
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
if(walletFrame)
{
settings->addAction(encryptWalletAction);
settings->addAction(changePassphraseAction);
settings->addSeparator();
}
settings->addAction(optionsAction);
QMenu *help = appMenuBar->addMenu(tr("&Help"));
if(walletFrame)
{
help->addAction(openRPCConsoleAction);
}
help->addAction(showHelpMessageAction);
help->addSeparator();
help->addAction(aboutAction);
help->addAction(aboutQtAction);
}
void BitcoinGUI::createToolBars()
{
if(walletFrame)
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
toolbar->setMovable(false);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
overviewAction->setChecked(true);
}
}
void BitcoinGUI::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
if(_clientModel)
{
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
// while the client has not yet fully loaded
createTrayIconMenu();
// Keep up to date with client
updateNetworkState();
connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(nullptr), false);
connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
// Receive and report messages from client model
connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
// Show progress dialog
connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
rpcConsole->setClientModel(_clientModel);
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->setClientModel(_clientModel);
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
OptionsModel* optionsModel = _clientModel->getOptionsModel();
if(optionsModel)
{
// be aware of the tray icon disable state change reported by the OptionsModel object.
connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
// initialize the disable state of the tray icon with the current value in the model.
setTrayIconVisible(optionsModel->getHideTrayIcon());
}
} else {
// Disable possibility to show main window via action
toggleHideAction->setEnabled(false);
if(trayIconMenu)
{
// Disable context menu on tray icon
trayIconMenu->clear();
}
// Propagate cleared model to child objects
rpcConsole->setClientModel(nullptr);
#ifdef ENABLE_WALLET
if (walletFrame)
{
walletFrame->setClientModel(nullptr);
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(nullptr);
}
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
{
if(!walletFrame)
return false;
setWalletActionsEnabled(true);
return walletFrame->addWallet(name, walletModel);
}
bool BitcoinGUI::setCurrentWallet(const QString& name)
{
if(!walletFrame)
return false;
return walletFrame->setCurrentWallet(name);
}
void BitcoinGUI::removeAllWallets()
{
if(!walletFrame)
return;
setWalletActionsEnabled(false);
walletFrame->removeAllWallets();
}
#endif // ENABLE_WALLET
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
{
overviewAction->setEnabled(enabled);
sendCoinsAction->setEnabled(enabled);
sendCoinsMenuAction->setEnabled(enabled);
receiveCoinsAction->setEnabled(enabled);
receiveCoinsMenuAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
signMessageAction->setEnabled(enabled);
verifyMessageAction->setEnabled(enabled);
usedSendingAddressesAction->setEnabled(enabled);
usedReceivingAddressesAction->setEnabled(enabled);
openAction->setEnabled(enabled);
}
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
trayIcon->setToolTip(toolTip);
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
trayIcon->hide();
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
}
void BitcoinGUI::createTrayIconMenu()
{
#ifndef Q_OS_MAC
// return if trayIcon is unset (only on non-Mac OSes)
if (!trayIcon)
return;
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsMenuAction);
trayIconMenu->addAction(receiveCoinsMenuAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
}
#ifndef Q_OS_MAC
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger)
{
// Click on system tray icon triggers show/hide of the main window
toggleHidden();
}
}
#endif
void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
return;
OptionsDialog dlg(this, enableWallet);
dlg.setModel(clientModel->getOptionsModel());
dlg.exec();
}
void BitcoinGUI::aboutClicked()
{
if(!clientModel)
return;
HelpMessageDialog dlg(this, true);
dlg.exec();
}
void BitcoinGUI::showDebugWindow()
{
rpcConsole->showNormal();
rpcConsole->show();
rpcConsole->raise();
rpcConsole->activateWindow();
}
void BitcoinGUI::showDebugWindowActivateConsole()
{
rpcConsole->setTabFocus(RPCConsole::TAB_CONSOLE);
showDebugWindow();
}
void BitcoinGUI::showHelpMessageClicked()
{
helpMessageDialog->show();
}
#ifdef ENABLE_WALLET
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg(this);
if(dlg.exec())
{
Q_EMIT receivedURI(dlg.getURI());
}
}
void BitcoinGUI::gotoOverviewPage()
{
overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
void BitcoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
}
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);
}
#endif // ENABLE_WALLET
void BitcoinGUI::updateNetworkState()
{
int count = clientModel->getNumConnections();
QString icon;
switch(count)
{
case 0: icon = ":/icons/connect_0"; break;
case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
default: icon = ":/icons/connect_4"; break;
}
QString tooltip;
if (clientModel->getNetworkActive()) {
tooltip = tr("%n active connection(s) to Underline network", "", count) + QString(".<br>") + tr("Click to disable network activity.");
} else {
tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
icon = ":/icons/network_disabled";
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
connectionsControl->setToolTip(tooltip);
connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
}
void BitcoinGUI::setNumConnections(int count)
{
updateNetworkState();
}
void BitcoinGUI::setNetworkActive(bool networkActive)
{
updateNetworkState();
}
void BitcoinGUI::updateHeadersSyncProgressLabel()
{
int64_t headersTipTime = clientModel->getHeaderTipTime();
int headersTipHeight = clientModel->getHeaderTipHeight();
int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
}
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
{
if (modalOverlay)
{
if (header)
modalOverlay->setKnownBestHeight(count, blockDate);
else
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
}
if (!clientModel)
return;
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
statusBar()->clearMessage();
// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
switch (blockSource) {
case BLOCK_SOURCE_NETWORK:
if (header) {
updateHeadersSyncProgressLabel();
return;
}
progressBarLabel->setText(tr("Synchronizing with network..."));
updateHeadersSyncProgressLabel();
break;
case BLOCK_SOURCE_DISK:
if (header) {
progressBarLabel->setText(tr("Indexing blocks on disk..."));
} else {
progressBarLabel->setText(tr("Processing blocks on disk..."));
}
break;
case BLOCK_SOURCE_REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
break;
case BLOCK_SOURCE_NONE:
if (header) {
return;
}
progressBarLabel->setText(tr("Connecting to peers..."));
break;
}
QString tooltip;
QDateTime currentDate = QDateTime::currentDateTime();
qint64 secs = blockDate.secsTo(currentDate);
tooltip = tr("Processed %n block(s) of transaction history.", "", count);
// Set icon state: spinning if catching up, tick otherwise
if(secs < 90*60)
{
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->showOutOfSyncWarning(false);
modalOverlay->showHide(true, true);
}
#endif // ENABLE_WALLET
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
}
else
{
QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000);
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
progressBar->setVisible(true);
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
if(count != prevBlocks)
{
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
prevBlocks = count;
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->showOutOfSyncWarning(true);
modalOverlay->showHide();
}
#endif // ENABLE_WALLET
tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible.");
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
}
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
QString strTitle = tr("Underline"); // default title
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
QString msgType;
// Prefer supplied title over style based title
if (!title.isEmpty()) {
msgType = title;
}
else {
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
break;
default:
break;
}
}
// Append title to "Bitcoin - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
}
else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
buttons = QMessageBox::Ok;
showNormalIfMinimized();
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
int r = mBox.exec();
if (ret != nullptr)
*ret = r == QMessageBox::Ok;
}
else
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
}
void BitcoinGUI::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
{
QTimer::singleShot(0, this, SLOT(hide()));
e->ignore();
}
}
}
#endif
}
void BitcoinGUI::closeEvent(QCloseEvent *event)
{
#ifndef Q_OS_MAC // Ignored on Mac
if(clientModel && clientModel->getOptionsModel())
{
if(!clientModel->getOptionsModel()->getMinimizeOnClose())
{
// close rpcConsole in case it was open to make some space for the shutdown window
rpcConsole->close();
QApplication::quit();
}
else
{
QMainWindow::showMinimized();
event->ignore();
}
}
#else
QMainWindow::closeEvent(event);
#endif
}
void BitcoinGUI::showEvent(QShowEvent *event)
{
// enable the debug window when the main window shows up
openRPCConsoleAction->setEnabled(true);
aboutAction->setEnabled(true);
optionsAction->setEnabled(true);
}
#ifdef ENABLE_WALLET
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
{
// On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) +
tr("Type: %1\n").arg(type);
if (!label.isEmpty())
msg += tr("Label: %1\n").arg(label);
else if (!address.isEmpty())
msg += tr("Address: %1\n").arg(address);
message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
msg, CClientUIInterface::MSG_INFORMATION);
}
#endif // ENABLE_WALLET
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
if(event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void BitcoinGUI::dropEvent(QDropEvent *event)
{
if(event->mimeData()->hasUrls())
{
for (const QUrl &uri : event->mimeData()->urls())
{
Q_EMIT receivedURI(uri.toString());
}
}
event->acceptProposedAction();
}
bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
{
// Catch status tip events
if (event->type() == QEvent::StatusTip)
{
// Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
if (progressBarLabel->isVisible() || progressBar->isVisible())
return true;
}
return QMainWindow::eventFilter(object, event);
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
{
// URI has to be valid
if (walletFrame && walletFrame->handlePaymentRequest(recipient))
{
showNormalIfMinimized();
gotoSendCoinsPage();
return true;
}
return false;
}
void BitcoinGUI::setHDStatus(int hdEnabled)
{
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
// eventually disable the QLabel to set its opacity to 50%
labelWalletHDStatusIcon->setEnabled(hdEnabled);
}
void BitcoinGUI::setEncryptionStatus(int status)
{
switch(status)
{
case WalletModel::Unencrypted:
labelWalletEncryptionIcon->hide();
encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::Locked:
labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
}
}
#endif // ENABLE_WALLET
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if(!clientModel)
return;
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (isHidden())
{
show();
activateWindow();
}
else if (isMinimized())
{
showNormal();
activateWindow();
}
else if (GUIUtil::isObscured(this))
{
raise();
activateWindow();
}
else if(fToggleHidden)
hide();
}
void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
void BitcoinGUI::detectShutdown()
{
if (ShutdownRequested())
{
if(rpcConsole)
rpcConsole->hide();
qApp->quit();
}
}
void BitcoinGUI::showProgress(const QString &title, int nProgress)
{
if (nProgress == 0)
{
progressDialog = new QProgressDialog(title, "", 0, 100);
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
}
else if (nProgress == 100)
{
if (progressDialog)
{
progressDialog->close();
progressDialog->deleteLater();
}
}
else if (progressDialog)
progressDialog->setValue(nProgress);
}
void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
{
if (trayIcon)
{
trayIcon->setVisible(!fHideTrayIcon);
}
}
void BitcoinGUI::showModalOverlay()
{
if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
modalOverlay->toggleVisibility();
}
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
// The SECURE flag has no effect in the Qt GUI.
// bool secure = (style & CClientUIInterface::SECURE);
style &= ~CClientUIInterface::SECURE;
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(gui, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
void BitcoinGUI::subscribeToCoreSignals()
{
// Connect signals to client
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
uiInterface.ThreadSafeQuestion.connect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
}
void BitcoinGUI::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
}
void BitcoinGUI::toggleNetworkActive()
{
if (clientModel) {
clientModel->setNetworkActive(!clientModel->getNetworkActive());
}
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
optionsModel(0),
menu(0)
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
int max_width = 0;
const QFontMetrics fm(font());
for (const BitcoinUnits::Unit unit : units)
{
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
}
/** So that it responds to button clicks */
void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
{
onDisplayUnitsClicked(event->pos());
}
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu(this);
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
{
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
}
/** Lets the control know about the Options Model (and its signals) */
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)
{
if (_optionsModel)
{
this->optionsModel = _optionsModel;
// be aware of a display unit change reported by the OptionsModel object.
connect(_optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
// initialize the display units label with the current value in the model.
updateDisplayUnit(_optionsModel->getDisplayUnit());
}
}
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
setText(BitcoinUnits::name(newUnits));
}
/** Shows context menu with Display Unit options by the mouse coordinates */
void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)
{
QPoint globalPos = mapToGlobal(point);
menu->exec(globalPos);
}
/** Tells underlying optionsModel to update its current display unit. */
void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
{
if (action)
{
optionsModel->setDisplayUnit(action->data());
}
}
| [
"xmrpoolmine@gmail.com"
] | xmrpoolmine@gmail.com |
c4e0e560df8f7592022550e0817a8e04d164227e | e436914385170e37c3a2caf483a7422f1da3affb | /src/qt/bitcoinunits.cpp | bfdcf68b2c07afca63fda0f35ea4d2453c8a279c | [
"MIT"
] | permissive | pereirasilv/plasma | 4dea2533d06be4fbf1fb35eaa07b6acd8191c112 | e1375bd11f92391ab8d37ca046b0d1920f6b8f27 | refs/heads/master | 2021-06-19T01:24:35.486746 | 2017-06-07T20:18:13 | 2017-06-07T20:18:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,289 | cpp | #include "bitcoinunits.h"
#include <QStringList>
BitcoinUnits::BitcoinUnits(QObject *parent):
QAbstractListModel(parent),
unitlist(availableUnits())
{
}
QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits()
{
QList<BitcoinUnits::Unit> unitlist;
unitlist.append(BTC);
unitlist.append(mBTC);
unitlist.append(uBTC);
return unitlist;
}
bool BitcoinUnits::valid(int unit)
{
switch(unit)
{
case BTC:
case mBTC:
case uBTC:
return true;
default:
return false;
}
}
QString BitcoinUnits::name(int unit)
{
switch(unit)
{
case BTC: return QString("XPZ");
case mBTC: return QString("XPZ");
case uBTC: return QString::fromUtf8("μXPZ");
default: return QString("???");
}
}
QString BitcoinUnits::description(int unit)
{
switch(unit)
{
case BTC: return QString("plasmacoins");
case mBTC: return QString("Milli-plasmacoins (1 / 1,000)");
case uBTC: return QString("Micro-plasmacoins (1 / 1,000,000)");
default: return QString("???");
}
}
qint64 BitcoinUnits::factor(int unit)
{
switch(unit)
{
case BTC: return 100000000;
case mBTC: return 100000;
case uBTC: return 100;
default: return 100000000;
}
}
int BitcoinUnits::amountDigits(int unit)
{
switch(unit)
{
case BTC: return 9; // 21,000,000 (# digits, without commas)
case mBTC: return 11; // 21,000,000,000
case uBTC: return 14; // 21,000,000,000,000
default: return 0;
}
}
int BitcoinUnits::decimals(int unit)
{
switch(unit)
{
case BTC: return 8;
case mBTC: return 5;
case uBTC: return 2;
default: return 0;
}
}
QString BitcoinUnits::format(int unit, qint64 n, bool fPlus)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
if(!valid(unit))
return QString(); // Refuse to format invalid unit
qint64 coin = factor(unit);
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
qint64 remainder = n_abs % coin;
QString quotient_str = QString::number(quotient);
QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
// Right-trim excess zeros after the decimal point
int nTrim = 0;
for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i)
++nTrim;
remainder_str.chop(nTrim);
if (n < 0)
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
quotient_str.insert(0, '+');
return quotient_str + QString(".") + remainder_str;
}
QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign)
{
return format(unit, amount, plussign) + QString(" ") + name(unit);
}
bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
{
if(!valid(unit) || value.isEmpty())
return false; // Refuse to parse invalid unit or empty string
int num_decimals = decimals(unit);
QStringList parts = value.split(".");
if(parts.size() > 2)
{
return false; // More than one dot
}
QString whole = parts[0];
QString decimals;
if(parts.size() > 1)
{
decimals = parts[1];
}
if(decimals.size() > num_decimals)
{
return false; // Exceeds max precision
}
bool ok = false;
QString str = whole + decimals.leftJustified(num_decimals, '0');
if(str.size() > 18)
{
return false; // Longer numbers will exceed 63 bits
}
qint64 retvalue = str.toLongLong(&ok);
if(val_out)
{
*val_out = retvalue;
}
return ok;
}
int BitcoinUnits::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return unitlist.size();
}
QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{
int row = index.row();
if(row >= 0 && row < unitlist.size())
{
Unit unit = unitlist.at(row);
switch(role)
{
case Qt::EditRole:
case Qt::DisplayRole:
return QVariant(name(unit));
case Qt::ToolTipRole:
return QVariant(description(unit));
case UnitRole:
return QVariant(static_cast<int>(unit));
}
}
return QVariant();
}
| [
"plasmacoin@scryptmail.com"
] | plasmacoin@scryptmail.com |
0a3b91e75f8f88b3389e7d9ef737063b568d234e | 2f396d9c1cff7136f652f05dd3dea2e780ecc56e | /tools/tracer/wrappers/mfx_video_core.cpp | 0b032a0ca6183977cbc10a99874bb08a13cb9dff | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Intel"
] | permissive | Intel-Media-SDK/MediaSDK | d90c84f37fd93afc9f0a0b98ac20109d322c3337 | 7a72de33a15d6e7cdb842b12b901a003f7154f0a | refs/heads/master | 2023-08-24T09:19:16.315839 | 2023-05-17T16:55:38 | 2023-05-17T16:55:38 | 87,199,173 | 957 | 595 | MIT | 2023-05-17T16:55:40 | 2017-04-04T14:52:06 | C++ | UTF-8 | C++ | false | false | 20,201 | cpp | /* ****************************************************************************** *\
Copyright (C) 2012-2020 Intel Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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.
File Name: mfx_video_core.cpp
\* ****************************************************************************** */
#include <exception>
#include <iostream>
#include "../loggers/timer.h"
#include "../tracer/functions_table.h"
#include "mfx_structures.h"
#if TRACE_CALLBACKS
mfxStatus mfxFrameAllocator_Alloc(mfxHDL _pthis, mfxFrameAllocRequest *request, mfxFrameAllocResponse *response)
{
try
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
mfxLoader *loader = (mfxLoader*)_pthis;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxHDL pthis = loader->callbacks[emfxFrameAllocator_Alloc_tracer][1];
Log::WriteLog("callback: mfxFrameAllocator::Alloc(mfxHDL pthis=" + ToString(pthis)
+ ", mfxFrameAllocRequest *request=" + ToString(request)
+ ", mfxFrameAllocResponse *response=" + ToString(response) + ") +");
if (!loader) return MFX_ERR_INVALID_HANDLE;
fmfxFrameAllocator_Alloc proc = (fmfxFrameAllocator_Alloc)loader->callbacks[emfxFrameAllocator_Alloc_tracer][0];
if (!proc) return MFX_ERR_INVALID_HANDLE;
Log::WriteLog(context.dump("pthis", pthis));
if (request) Log::WriteLog(context.dump("request", *request));
if (response) Log::WriteLog(context.dump("response", *response));
Timer t;
mfxStatus status = (*proc) (pthis, request, response);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> callback: mfxFrameAllocator::Alloc called");
if (response) Log::WriteLog(context.dump("response", *response));
Log::WriteLog("callback: mfxFrameAllocator::Alloc(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus mfxFrameAllocator_Lock(mfxHDL _pthis, mfxMemId mid, mfxFrameData *ptr)
{
try
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
mfxLoader *loader = (mfxLoader*)_pthis;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxHDL pthis = loader->callbacks[emfxFrameAllocator_Lock_tracer][1];
Log::WriteLog("callback: mfxFrameAllocator::Lock(mfxHDL pthis=" + ToString(pthis)
+ ", mfxMemId mid=" + ToString(mid)
+ ", mfxFrameData *ptr=" + ToString(ptr) + ") +");
fmfxFrameAllocator_Lock proc = (fmfxFrameAllocator_Lock)loader->callbacks[emfxFrameAllocator_Lock_tracer][0];
if (!proc) return MFX_ERR_INVALID_HANDLE;
Log::WriteLog(context.dump("pthis", pthis));
if (ptr) Log::WriteLog(context.dump("ptr", *ptr));
Timer t;
mfxStatus status = (*proc) (pthis, mid, ptr);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> callback: mfxFrameAllocator::Lock called");
if (ptr) Log::WriteLog(context.dump("ptr", *ptr));
Log::WriteLog("callback: mfxFrameAllocator::Lock(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus mfxFrameAllocator_Unlock(mfxHDL _pthis, mfxMemId mid, mfxFrameData *ptr)
{
try
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
mfxLoader *loader = (mfxLoader*)_pthis;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxHDL pthis = loader->callbacks[emfxFrameAllocator_Unlock_tracer][1];
Log::WriteLog("callback: mfxFrameAllocator::Unlock(mfxHDL pthis=" + ToString(pthis)
+ ", mfxMemId mid=" + ToString(mid)
+ ", mfxFrameData *ptr=" + ToString(ptr) + ") +");
fmfxFrameAllocator_Unlock proc = (fmfxFrameAllocator_Unlock)loader->callbacks[emfxFrameAllocator_Unlock_tracer][0];
if (!proc) return MFX_ERR_INVALID_HANDLE;
Log::WriteLog(context.dump("pthis", pthis));
if (ptr) Log::WriteLog(context.dump("ptr", *ptr));
Timer t;
mfxStatus status = (*proc) (pthis, mid, ptr);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> callback: mfxFrameAllocator::Unlock called");
if (ptr) Log::WriteLog(context.dump("ptr", *ptr));
Log::WriteLog("callback: mfxFrameAllocator::Unlock(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus mfxFrameAllocator_GetHDL(mfxHDL _pthis, mfxMemId mid, mfxHDL *handle)
{
try
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
mfxLoader *loader = (mfxLoader*)_pthis;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxHDL pthis = loader->callbacks[emfxFrameAllocator_GetHDL_tracer][1];
Log::WriteLog("callback: mfxFrameAllocator::GetHDL(mfxHDL pthis=" + ToString(pthis)
+ ", mfxMemId mid=" + ToString(mid)
+ ", mfxHDL *handle=" + ToString(handle) + ") +");
fmfxFrameAllocator_GetHDL proc = (fmfxFrameAllocator_GetHDL)loader->callbacks[emfxFrameAllocator_GetHDL_tracer][0];
if (!proc) return MFX_ERR_INVALID_HANDLE;
Log::WriteLog(context.dump("pthis", pthis));
if (handle) Log::WriteLog(context.dump("handle", *handle));
Timer t;
mfxStatus status = (*proc) (pthis, mid, handle);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> callback: mfxFrameAllocator::GetHDL called");
if (handle) Log::WriteLog(context.dump("handle", *handle));
Log::WriteLog("callback: mfxFrameAllocator::GetHDL(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus mfxFrameAllocator_Free(mfxHDL _pthis, mfxFrameAllocResponse *response)
{
try
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
mfxLoader *loader = (mfxLoader*)_pthis;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxHDL pthis = loader->callbacks[emfxFrameAllocator_Free_tracer][1];
Log::WriteLog("callback: mfxFrameAllocator::Free(mfxHDL pthis=" + ToString(pthis)
+ ", mfxFrameAllocResponse *response=" + ToString(response) + ") +");
fmfxFrameAllocator_Free proc = (fmfxFrameAllocator_Free)loader->callbacks[emfxFrameAllocator_Free_tracer][0];
if (!proc) return MFX_ERR_INVALID_HANDLE;
Log::WriteLog(context.dump("pthis", pthis));
if (response) Log::WriteLog(context.dump("response", *response));
Timer t;
mfxStatus status = (*proc) (pthis, response);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> callback: mfxFrameAllocator::Free called");
if (response) Log::WriteLog(context.dump("response", *response));
Log::WriteLog("callback: mfxFrameAllocator::Free(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e)
{
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
#endif //TRACE_CALLBACKS
// CORE interface functions
mfxStatus MFXVideoCORE_SetBufferAllocator(mfxSession session, mfxBufferAllocator *allocator)
{
try{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
Log::WriteLog("function: MFXVideoCORE_SetBufferAllocator(mfxSession session=" + ToString(session) + ", mfxBufferAllocator *allocator=" + ToString(allocator) + ") +");
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_SetBufferAllocator_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
if(allocator) Log::WriteLog(context.dump("allocator", *allocator));
Timer t;
mfxStatus status = (*(fMFXVideoCORE_SetBufferAllocator) proc) (session, allocator);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_SetBufferAllocator called");
Log::WriteLog(context.dump("session", session));
if(allocator) Log::WriteLog(context.dump("allocator", *allocator));
Log::WriteLog("function: MFXVideoCORE_SetBufferAllocator(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus MFXVideoCORE_SetFrameAllocator(mfxSession session, mfxFrameAllocator *allocator)
{
try{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
Log::WriteLog("function: MFXVideoCORE_SetFrameAllocator(mfxSession session=" + ToString(session) + ", mfxFrameAllocator *allocator=" + ToString(allocator) + ") +");
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_SetFrameAllocator_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
if(allocator) Log::WriteLog(context.dump("allocator", *allocator));
#if TRACE_CALLBACKS
INIT_CALLBACK_BACKUP(loader->callbacks);
mfxFrameAllocator proxyAllocator;
if (allocator)
{
proxyAllocator = *allocator;
allocator = &proxyAllocator;
SET_CALLBACK(mfxFrameAllocator, allocator->, Alloc, allocator->pthis);
SET_CALLBACK(mfxFrameAllocator, allocator->, Lock, allocator->pthis);
SET_CALLBACK(mfxFrameAllocator, allocator->, Unlock, allocator->pthis);
SET_CALLBACK(mfxFrameAllocator, allocator->, GetHDL, allocator->pthis);
SET_CALLBACK(mfxFrameAllocator, allocator->, Free, allocator->pthis);
if (allocator->pthis)
allocator->pthis = loader;
}
#endif //TRACE_CALLBACKS
Timer t;
mfxStatus status = (*(fMFXVideoCORE_SetFrameAllocator) proc) (session, allocator);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_SetFrameAllocator called");
//No need to dump input-only parameters twice!!!
//Log::WriteLog(context.dump("session", session));
//if(allocator) Log::WriteLog(context.dump("allocator", *allocator));
Log::WriteLog("function: MFXVideoCORE_SetFrameAllocator(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
#if TRACE_CALLBACKS
if (status != MFX_ERR_NONE)
callbacks.RevertAll();
#endif //TRACE_CALLBACKS
return status;
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus MFXVideoCORE_SetHandle(mfxSession session, mfxHandleType type, mfxHDL hdl)
{
try{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
Log::WriteLog("function: MFXVideoCORE_SetHandle(mfxSession session=" + ToString(session) + ", mfxHandleType type=" + ToString(type) + ", mfxHDL hdl=" + ToString(hdl) + ") +");
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_SetHandle_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("type", type));
Log::WriteLog(context.dump_mfxHDL("hdl", &hdl));
Timer t;
mfxStatus status = (*(fMFXVideoCORE_SetHandle) proc) (session, type, hdl);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_SetHandle called");
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("type", type));
Log::WriteLog(context.dump_mfxHDL("hdl", &hdl));
Log::WriteLog("function: MFXVideoCORE_SetHandle(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus MFXVideoCORE_GetHandle(mfxSession session, mfxHandleType type, mfxHDL *hdl)
{
try{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
Log::WriteLog("function: MFXVideoCORE_GetHandle(mfxSession session=" + ToString(session) + ", mfxHandleType type=" + ToString(type) + ", mfxHDL *hdl=" + ToString(hdl) + ") +");
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_GetHandle_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("type", type));
Log::WriteLog(context.dump_mfxHDL("hdl", hdl));
Timer t;
mfxStatus status = (*(fMFXVideoCORE_GetHandle) proc) (session, type, hdl);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_GetHandle called");
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("type", type));
Log::WriteLog(context.dump_mfxHDL("hdl", hdl));
Log::WriteLog("function: MFXVideoCORE_GetHandle(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus MFXVideoCORE_QueryPlatform(mfxSession session, mfxPlatform* platform)
{
try{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
Log::WriteLog("function: MFXVideoCORE_QueryPlatform(mfxSession session=" + ToString(session) + ", mfxPlatform* platform=" + ToString(platform) + ") +");
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_QueryPlatform_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("platform", platform));
Timer t;
mfxStatus status = (*(fMFXVideoCORE_QueryPlatform) proc) (session, platform);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_QueryPlatform called");
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("platform", platform));
Log::WriteLog("function: MFXVideoCORE_QueryPlatform(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
mfxStatus MFXVideoCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait)
{
try{
if (Log::GetLogLevel() >= LOG_LEVEL_FULL) //call function with logging
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
TracerSyncPoint sp;
if (syncp) {
sp.syncPoint = syncp;
Log::WriteLog("function: MFXVideoCORE_SyncOperation(mfxSession session=" + ToString(session) + ", mfxSyncPoint syncp=" + ToString(syncp) + ", mfxU32 wait=" + ToString(wait) + ") +");
//sp.component == ENCODE ? Log::WriteLog("SyncOperation(ENCODE," + TimeToString(sp.timer.GetTime()) + ")") : (sp.component == DECODE ? Log::WriteLog("SyncOperation(DECODE, " + ToString(sp.timer.GetTime()) + " sec)") : Log::WriteLog("SyncOperation(VPP, " + ToString(sp.timer.GetTime()) + " sec)"));
}
else {
// already synced
Log::WriteLog("Already synced");
return MFX_ERR_NONE;
}
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_SyncOperation_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("syncp", syncp));
Log::WriteLog(context.dump_mfxU32("wait", wait));
Timer t;
mfxStatus status = (*(fMFXVideoCORE_SyncOperation) proc) (session, sp.syncPoint, wait);
std::string elapsed = TimeToString(t.GetTime());
Log::WriteLog(">> MFXVideoCORE_SyncOperation called");
Log::WriteLog(context.dump("session", session));
Log::WriteLog(context.dump("syncp", sp.syncPoint));
Log::WriteLog(context.dump_mfxU32("wait", wait));
Log::WriteLog("function: MFXVideoCORE_SyncOperation(" + elapsed + ", " + context.dump_mfxStatus("status", status) + ") - \n\n");
return status;
}
else // call function without logging
{
DumpContext context;
context.context = DUMPCONTEXT_MFX;
TracerSyncPoint sp;
if (syncp) {
sp.syncPoint = syncp;
}
else {
// already synced
return MFX_ERR_NONE;
}
mfxLoader *loader = (mfxLoader*) session;
if (!loader) return MFX_ERR_INVALID_HANDLE;
mfxFunctionPointer proc = loader->table[eMFXVideoCORE_SyncOperation_tracer];
if (!proc) return MFX_ERR_INVALID_HANDLE;
session = loader->session;
mfxStatus status = (*(fMFXVideoCORE_SyncOperation) proc) (session, sp.syncPoint, wait);
return status;
}
}
catch (std::exception& e){
std::cerr << "Exception: " << e.what() << '\n';
return MFX_ERR_ABORTED;
}
}
| [
"oleg.nabiullin@intel.com"
] | oleg.nabiullin@intel.com |
76547add7d701de9dcb3608df82392ea9c5fad6a | d41ebea78a3f0d717c482e9f3ef677b27a64a2d7 | /ENGINE_/FeaServer.Engine.Cpu/src/System/cpuFalloc.h | 412f2ee3228169316969bc8cc75305af49f79483 | [] | no_license | JiujiangZhu/feaserver | c8b89b2c66bf27cecf7afa7775a5f3c466e482d5 | 864077bb3103cbde78a2b51e8e2536b5d87e6712 | refs/heads/master | 2020-05-18T00:58:56.385143 | 2012-09-14T14:28:41 | 2012-09-14T14:28:41 | 39,262,812 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,622 | h | #pragma region License
/*
The MIT License
Copyright (c) 2009 Sky Morey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma endregion
#ifndef CPUFALLOC_H
#define CPUFALLOC_H
/*
* This is the header file supporting cpuFalloc.c and defining both the host and device-side interfaces. See that file for some more
* explanation and sample use code. See also below for details of the host-side interfaces.
*
* Quick sample code:
*
#include "cpuFalloc.c"
int main()
{
cpuFallocHeap heap = cpuFallocInit();
fallocInit(heap.deviceHeap);
// create/free heap
void* obj = fallocGetChunk(heap.deviceHeap);
fallocFreeChunk(heap.deviceHeap, obj);
// create/free alloc
fallocContext* ctx = fallocCreateCtx(heap.deviceHeap);
char* testString = (char*)falloc(ctx, 10);
int* testInteger = falloc<int>(ctx);
fallocDisposeCtx(ctx);
// free and exit
cpuFallocEnd(heap);
return 0;
}
*/
///////////////////////////////////////////////////////////////////////////////
// DEVICE SIDE
// External function definitions for device-side code
typedef struct _cpuFallocDeviceHeap fallocDeviceHeap;
void fallocInit(fallocDeviceHeap* deviceHeap);
void* fallocGetChunk(fallocDeviceHeap* deviceHeap);
void* fallocGetChunks(fallocDeviceHeap* deviceHeap, size_t length, size_t* allocLength = nullptr);
void fallocFreeChunk(fallocDeviceHeap* deviceHeap, void* obj);
void fallocFreeChunks(fallocDeviceHeap* deviceHeap, void* obj);
// ALLOC
typedef struct _cpuFallocContext fallocContext;
fallocContext* fallocCreateCtx(fallocDeviceHeap* deviceHeap);
void fallocDisposeCtx(fallocContext* ctx);
void* falloc(fallocContext* ctx, unsigned short bytes, bool alloc = true);
void* fallocRetract(fallocContext* ctx, unsigned short bytes);
void fallocMark(fallocContext* ctx, void* &mark, unsigned short &mark2);
bool fallocAtMark(fallocContext* ctx, void* mark, unsigned short mark2);
template <typename T> T* falloc(fallocContext* ctx) { return (T*)falloc(ctx, sizeof(T), true); }
template <typename T> void fallocPush(fallocContext* ctx, T t) { *((T*)falloc(ctx, sizeof(T), false)) = t; }
template <typename T> T fallocPop(fallocContext* ctx) { return *((T*)fallocRetract(ctx, sizeof(T))); }
// ATOMIC
typedef struct _cpuFallocAutomic fallocAutomic;
fallocAutomic* fallocCreateAtom(fallocDeviceHeap* deviceHeap, unsigned short pitch, size_t length);
void fallocDisposeAtom(fallocAutomic* atom);
void* fallocAtomNext(fallocAutomic* atom, unsigned short bytes);
///////////////////////////////////////////////////////////////////////////////
// HOST SIDE
// External function definitions for host-side code
typedef struct {
fallocDeviceHeap* deviceHeap;
int length;
void* reserved;
} cpuFallocHeap;
//
// cpuFallocInit
//
// Call this to initialise a falloc heap. If the buffer size needs to be changed, call cudaFallocEnd()
// before re-calling cudaFallocInit().
//
// The default size for the buffer is 1 megabyte. For CUDA
// architecture 1.1 and above, the buffer is filled linearly and
// is completely used.
//
// Arguments:
// length - Length, in bytes, of total space to reserve (in device global memory) for output.
//
// Returns:
// cudaSuccess if all is well.
//
extern "C" cpuFallocHeap cpuFallocInit(size_t length=1048576, void* reserved=nullptr); // 1-meg
//
// cpuFallocEnd
//
// Cleans up all memories allocated by cudaFallocInit() for a heap.
// Call this at exit, or before calling cudaFallocInit() again.
//
extern "C" void cpuFallocEnd(cpuFallocHeap &heap);
#endif // CPUFALLOC_H
| [
"Moreys@MOREYS01.gateway.2wire.net"
] | Moreys@MOREYS01.gateway.2wire.net |
90c20498c7c14076e4ac1a24a831286a07a3d6de | bffe69fcd11a8d34a0a18078e9b4c277269ea6ab | /Workshop7/Workshop7/Workshop7/Q2.cpp | 8260049c86511c5dd3461f9b69cf6438ba3a5c77 | [] | no_license | m-kojic/cplusplus-exercises | 8da379431f26066008efca7003a53e996b06bd73 | 9f1bd01edee61960f29d140935e94b2218be5a75 | refs/heads/master | 2020-12-29T23:40:15.385601 | 2020-03-27T13:06:27 | 2020-03-27T13:06:27 | 238,780,211 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 506 | cpp | //Q2(only 5.41 % correct)
//#include <iostream>
//using namespace std;
//
//int main()
//{
// std::cout << "Q2\n";
//
// // A) i is declared before the loop so we can use it after the loop
// int i;
// for (i = 0; i < 5; i++) {
// // B) multiply i by 2 and store it to i
// i = 2 * i;
// cout << "i: " << i << endl;
// }
// cout << "i after the loop: " << i << endl;
//
// // OUTPUT:
// // i : 0
// // i : 2
// // i : 6
// // i after the loop : 7
//}
| [
"m.kojic@live.com"
] | m.kojic@live.com |
4c852c8ba5b1e4b4ca5cf28ecc77c542f3a7cf32 | 24d75ffa3af1b85325b39dc909343a8d945e9171 | /Avocado/AvocadoActiveXCtrl/AvocadoActiveXCtrl.cpp | fb0650af4fc184469d8caed734a7ad4c88482b18 | [] | no_license | assafyariv/PSG | 0c2bf874166c7a7df18e8537ae5841bf8805f166 | ce932ca9a72a5553f8d1826f3058e186619a4ec8 | refs/heads/master | 2016-08-12T02:57:17.021428 | 2015-09-24T17:14:51 | 2015-09-24T17:14:51 | 43,080,715 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,302 | cpp | // AvocadoActiveXCtrl.cpp : Implementation of CAvocadoActiveXCtrlApp and DLL registration.
#include "stdafx.h"
#include "AvocadoActiveXCtrl.h"
#include "../AvocadoEngine/AvocadoAppInterface.h"
#include "Cathelp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CAvocadoActiveXCtrlApp theApp;
const GUID CDECL _tlid = { 0x1D49C79F, 0x2D78, 0x417F, { 0x91, 0x23, 0x8D, 0xF5, 0xC1, 0x8E, 0xA, 0x7F } };
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;
// CLSID_SafeItem - Necessary for safe ActiveX control
// The value is taken from IMPLEMENT_OLECREATE_EX in MFCSafeActiveXCtrl.cpp.
// It is actually the CLSID of the ActiveX control.
const CATID CLSID_SafeItem =
{ 0x1ebae592, 0x7515, 0x43c2,{ 0xa6, 0xf1, 0xcd, 0xee, 0xdf, 0x3f, 0xd8, 0x2b}};
// CAvocadoActiveXCtrlApp::InitInstance - DLL initialization
BOOL CAvocadoActiveXCtrlApp::InitInstance()
{
BOOL bInit = COleControlModule::InitInstance();
if (bInit)
{
// TODO: Add your own module initialization code here.
avocado::AvocadoInit ();
}
return bInit;
}
// CAvocadoActiveXCtrlApp::ExitInstance - DLL termination
int CAvocadoActiveXCtrlApp::ExitInstance()
{
// TODO: Add your own module termination code here.
avocado::AvocadoTerminate();
return COleControlModule::ExitInstance();
}
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
AFX_MANAGE_STATE(_afxModuleAddrThis);
if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
return ResultFromScode(SELFREG_E_CLASS);
// Mark the control as safe for initializing. (Added)
HRESULT hr = CreateComponentCategory(CATID_SafeForInitializing,
L"Controls safely initializable from persistent data!");
if (FAILED(hr))
return hr;
hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing);
if (FAILED(hr))
return hr;
// Mark the control as safe for scripting. (Added)
hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls safely scriptable!");
if (FAILED(hr))
return hr;
hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting);
if (FAILED(hr))
return hr;
hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_PersistsToFile);
if (FAILED(hr))
return hr;
hr = RegisterCLSIDInCategory(CLSID_SafeItem, CATID_DesignTimeUIActivatableControl);
if (FAILED(hr))
return hr;
return NOERROR;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
AFX_MANAGE_STATE(_afxModuleAddrThis);
if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
return ResultFromScode(SELFREG_E_CLASS);
// Remove entries from the registry.
// safe stuff ..
HRESULT hr = UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing);
if (FAILED(hr))
return hr;
hr = UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting);
if (FAILED(hr))
return hr;
hr = UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_PersistsToFile);
if (FAILED(hr))
return hr;
hr = UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_DesignTimeUIActivatableControl);
if (FAILED(hr))
return hr;
return NOERROR;
}
| [
"assafyariv@gmail.com"
] | assafyariv@gmail.com |
05343144ff1f7dfd0c7d7745923dce1ca2224af1 | 4f2712cecd653a33a89c27bdc074b232c99b8511 | /lab3_q2.cpp | eab3f456b12a7c0b20413328bdeb800bfdb47395 | [] | no_license | tamoghnaaa2012/cs141 | 0b3b46ed043f2f5c3573e8333305fa55d75cfefc | a95206d69d659dcf10a75860e9ceaff41964be0a | refs/heads/master | 2020-03-25T10:58:06.345725 | 2018-08-16T15:09:42 | 2018-08-16T15:09:42 | 143,713,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 724 | cpp | //include library
#include <iostream>
using namespace std;
//main function
int main()
{
int a,b,sum,substract,product,remainder ; // declaration
float division;
a = 5; // definition
b = 3; //definition
sum = a + b; // adds 2 numbers
substract = a - b; // calculates the difference
product = a * b; // calculates the product
division = a / b; // divides the numbers
remainder = a % b; // finds the remainder
// displaying the calculations in terminal
cout << "numbers are " << a << "," << b << endl;
cout << " results in integer" << endl;
cout << " sum is " << sum << endl;
cout << "difference is " << substract << endl;
cout << "quotient is " << division << endl;
cout << "remainder is " << remainder << endl;
return 0;
}
| [
"noreply@github.com"
] | tamoghnaaa2012.noreply@github.com |
be7f6fe3a60582528685480ff7b7819358e16898 | 6dfb27b6b6c5addd0bdb28c56e32174a7b9e079c | /637-Average of Levels in Binary Tree /main.cpp | 4149ebee479601ce75c473780f261d2be38505a8 | [] | no_license | wondervictor/LeetCode-Solutions | cb4313a6c2e9290627fb362b72bf2ad6106f8e58 | 3f20837739595481e6a5e5b0ba869a406ec0607e | refs/heads/master | 2021-01-13T13:44:06.178067 | 2020-04-23T12:47:22 | 2020-04-23T12:47:22 | 76,328,898 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,144 | cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
/**
* Definition for a binary tree node.
*/
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution {
public:
vector<double> averageOfLevels(TreeNode* root) {
vector<double> result;
if (root == nullptr) {
return result;
}
queue<TreeNode* > nodes;
nodes.push(root);
while(nodes.size()) {
int size = (int)nodes.size();
double currentSum = 0;
for(int i = 0; i < size; i ++) {
TreeNode* curNode = nodes.front();
nodes.pop();
currentSum += curNode->val;
if (curNode->left)
nodes.push(curNode->left);
if (curNode->right)
nodes.push(curNode->right);
}
double avg = currentSum/size;
result.push_back(avg);
}
return result;
}
};
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
} | [
"victorchanchina@gmail.com"
] | victorchanchina@gmail.com |
8b3bf340ef46fc178d70241a5c7e4218a9e4ef40 | 337806d560b58c53fff0ec4ae11fcbde0419d4ba | /计算器.cpp | 74b4c68076adb1cc60abb13698a898bb27b3ff62 | [] | no_license | ynmz/calculating-machine- | 48597e23f0ab1be9665b615762eac1a7ee3b6252 | 24503ddaaf888451887411bb993ebc52fd4401ac | refs/heads/master | 2020-04-15T01:27:27.744802 | 2019-01-06T05:28:56 | 2019-01-06T05:28:56 | 164,276,478 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,732 | cpp | #include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cmath>
using namespace std;
char s[1000];
int g_pos; // 字符数组的下标
/* 字符转数字 */
double Translation(int & pos)
{
double integer = 0.0; // 整数部分
double remainder = 0.0; // 余数部分
while (s[pos] >= '0' && s[pos] <= '9')
{
integer *= 10;
integer += (s[pos] - '0');
pos++;
}
if (s[pos] == '.')
{
pos++;
int c = 1;
while (s[pos] >= '0' && s[pos] <= '9')
{
double t = s[pos] - '0';
t *= pow(0.1, c);
c++;
remainder += t;
pos++;
}
}
return integer + remainder;
}
/* 返回运算符级别 */
int GetLevel(char ch)
{
switch (ch)
{
case '+':
case '-':
return 1;
case '*':
case '/':
return 2;
case '(':
return 0;
case '#':
return -1;
};
}
/* 对两个数进行运算 */
double Operate(double a1, char op, double a2)
{
switch (op)
{
case '+':
return a1 + a2;
case '-':
return a1 - a2;
case '*':
return a1 * a2;
case '/':
return a1 / a2;
};
}
/* 利用两个栈进行模拟计算 */
double Compute()
{
stack<char> optr; // 操作符栈
stack<double> opnd; // 操作数栈
optr.push('#'); //置于符栈顶
int len = strlen(s);
bool is_minus = true; // 判断'-'是减号还是负号, true表示负号
for (g_pos = 0; g_pos < len;)
{
//1. 负号
if (s[g_pos] == '-' && is_minus) // 是负号
{
opnd.push(0);
optr.push('-');
g_pos++;
}
//2. 是右括号 )
else if (s[g_pos] == ')')
{
is_minus = false;
g_pos++;
while (optr.top() != '(')
{
double a2 = opnd.top();
opnd.pop();
double a1 = opnd.top();
opnd.pop();
char op = optr.top();
optr.pop();
double result = Operate(a1, op, a2);
opnd.push(result);
}
optr.pop(); // 删除'('
}
//3. 数字
else if (s[g_pos] >= '0' && s[g_pos] <= '9')
{
is_minus = false;
opnd.push(Translation(g_pos));
}
//4. ( 左括号
else if (s[g_pos] == '(')
{
is_minus = true;
optr.push(s[g_pos]);
g_pos++;
}
//5. + - * / 四种
else
{
while (GetLevel(s[g_pos]) <= GetLevel(optr.top())) //当前优先级小于栈尾优先级
{
double a2 = opnd.top();
opnd.pop();
double a1 = opnd.top();
opnd.pop();
char op = optr.top();
optr.pop();
double result = Operate(a1, op, a2);
opnd.push(result);
}
optr.push(s[g_pos]);
g_pos++;
}
}
while (optr.top() != '#')
{
double a2 = opnd.top();
opnd.pop();
double a1 = opnd.top();
opnd.pop();
char op = optr.top();
optr.pop();
double result = Operate(a1, op, a2);
opnd.push(result);
}
return opnd.top();
}
int main()
{
while (cin >> s)
cout << "结果为:" << Compute() << endl << endl;
return 0;
} | [
"noreply@github.com"
] | ynmz.noreply@github.com |
5cb455cc22176dd7e57005baa18bf7577fc03b90 | db707fe41a0f41bdb633ab003b8d64f71e3d4e1b | /stack.hpp | d521b5d807cba4b6b5a0663e0cba6d0d20f01eb5 | [] | no_license | mle-moni/ft_containers | 5bf0924cc1c79b1183c2e95e279d0bc6b3dfba3c | 2467947948d5fd181017ca2b1527662024f14904 | refs/heads/master | 2022-12-30T04:45:32.707297 | 2020-10-19T17:55:06 | 2020-10-19T17:55:06 | 293,537,366 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,618 | hpp |
#ifndef STACK_H
#define STACK_H
#include "vector.hpp"
#include "shared_functions.hpp"
namespace ft
{
template <class T, class Container = ft::vector<T> >
class stack {
public:
typedef T value_type;
typedef Container container_type;
typedef size_t size_type;
protected:
Container c;
public:
// constructors
stack (const container_type& ctnr = container_type()): c(ctnr) {}
stack (const stack& other): c(other.c) {}
virtual ~stack() {}
// operator=
stack& operator= (const stack& other)
{
c = other.c;
return (*this);
}
// member functions
bool empty() const
{
return (c.empty());
}
size_type size() const
{
return (c.size());
}
value_type& top()
{
return (c.back());
}
const value_type& top() const
{
return (c.back());
}
void push (const value_type& val)
{
c.push_back(val);
}
void pop()
{
c.pop_back();
}
// Non-member (but friend) function overloads
template <class Tp, class Cntnr>
friend bool operator== (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
template <class Tp, class Cntnr>
friend bool operator!= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
template <class Tp, class Cntnr>
friend bool operator< (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
template <class Tp, class Cntnr>
friend bool operator<= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
template <class Tp, class Cntnr>
friend bool operator> (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
template <class Tp, class Cntnr>
friend bool operator>= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs);
};
// Non-member (but friend) function overloads
template <class Tp, class Cntnr>
bool operator== (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c == rhs.c);
}
template <class Tp, class Cntnr>
bool operator!= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c != rhs.c);
}
template <class Tp, class Cntnr>
bool operator< (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c < rhs.c);
}
template <class Tp, class Cntnr>
bool operator<= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c <= rhs.c);
}
template <class Tp, class Cntnr>
bool operator> (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c > rhs.c);
}
template <class Tp, class Cntnr>
bool operator>= (const stack<Tp,Cntnr>& lhs, const stack<Tp,Cntnr>& rhs)
{
return (lhs.c >= rhs.c);
}
}
#endif | [
"m.lemoniesdesagazan@gmail.com"
] | m.lemoniesdesagazan@gmail.com |
91a25e27dd1335999f48452da1dfbc07c823bf1e | e36128cfc5a6ef0cef1da54e536c99250fc6fd43 | /Libs/include/YXC_Sys/YXC_NCMClient.hpp | 75e89d0018c019785534de92847d9563897f870d | [] | no_license | yuanqs86/native | f53cb48bae133976c89189e1ea879ab6854a9004 | 0a46999537260620b683296d53140e1873442514 | refs/heads/master | 2021-08-31T14:50:41.572622 | 2017-12-21T19:20:10 | 2017-12-21T19:20:10 | 114,990,467 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,245 | hpp | /* ****************************************************************************** *\
Author : Qiushi Yuan
Copyright(c) 2008-2015 Qiushi Yuan. All Rights Reserved.
This software is supplied under the terms, you cannot copy or disclose except agreement with the author.
\* ****************************************************************************** */
#ifndef __INC_YXC_BASEEX_NET_CSMODEL_CLIENT_HPP__
#define __INC_YXC_BASEEX_NET_CSMODEL_CLIENT_HPP__
#include <YXC_Sys/YXC_NetSModelClient.h>
#include <YXC_Sys/YXC_Locker.hpp>
namespace YXCLib
{
class YXC_CLASS NCMClient
{
public:
NCMClient();
virtual ~NCMClient();
YXC_Status SendPackage(const YXC_NetPackage* pPackage, yuint32_t stTimeout);
void Close(ybool_t bWaitForClosed);
ybool_t IsConnected() const;
YXC_Status ConnectAndCreateW(YXC_NetSModelClientMgr cliMgr, const wchar_t* cszIp, yuint32_t uPort, yuint32_t uTimeout);
YXC_Status ConnectAndCreate(YXC_NetSModelClientMgr cliMgr, const ychar* cszIp, yuint32_t uPort, yuint32_t uTimeout);
YXC_Status ConnectAndCreateA(YXC_NetSModelClientMgr cliMgr, const char* cwszIp, yuint32_t uPort, yuint32_t uTimeout);
YXC_Status AttachSocket(YXC_NetSModelClientMgr cliMgr, YXC_Socket sock);
YXC_Status GetSocketOpt(YXC_SocketOption option, YXC_SocketOptValue* pOptVal);
YXC_Status SetSocketOpt(YXC_SocketOption option, const YXC_SocketOptValue* pOptVal);
void NotifyClose();
protected:
virtual YXC_Status _OnInitSockAttr(YXC_Socket sock);
virtual void _OnClose(ybool_t bClosedActively, const YXC_Error* pClosedReason);
virtual void _OnReceive(const YXC_NetPackage* pPackage);
private:
NCMClient(const NCMClient& rhs);
NCMClient& operator =(const NCMClient& rhs);
YXC_Status _AttachSocket(YXC_NetSModelClientMgr cliMgr, YXC_Socket sock);
private:
static void OnClientClose(YXC_NetSModelClientMgr mgr, YXC_NetSModelClient client, void* pExtData, void* pClientExt,
ybool_t bClosedActively);
static void OnClientRecv(YXC_NetSModelClientMgr mgr, YXC_NetSModelClient client, const YXC_NetPackage* pPackage,
void* pExtData, void* pClientExt);
private:
YXC_NetSModelClient _client;
YXC_NetSModelClientMgr _mgr;
};
}
#endif /* __INC_YXC_BASEEX_NET_CSMODEL_CLIENT_HPP__ */
| [
"34738843+yuanqs86@users.noreply.github.com"
] | 34738843+yuanqs86@users.noreply.github.com |
675e9ba4175b5589e3eb4a53aa776dca7ed1914c | 544fbe639a4d1f5bdf91c6bbf8568a37233e8546 | /aws-cpp-sdk-auditmanager/include/aws/auditmanager/model/AssessmentFramework.h | c6e98dee903788002f10261e92727c21dfa5d562 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | jweinst1/aws-sdk-cpp | 833dbed4871a576cee3d7e37d93ce49e8d649ed5 | fef0f65a49f08171cf6ebc8fbd357731d961ab0f | refs/heads/main | 2023-07-14T03:42:55.080906 | 2021-08-29T04:07:48 | 2021-08-29T04:07:48 | 300,541,857 | 0 | 0 | Apache-2.0 | 2020-10-02T07:53:42 | 2020-10-02T07:53:41 | null | UTF-8 | C++ | false | false | 6,581 | h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/auditmanager/AuditManager_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/auditmanager/model/FrameworkMetadata.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/auditmanager/model/AssessmentControlSet.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace AuditManager
{
namespace Model
{
/**
* <p> The file used to structure and automate Audit Manager assessments for a
* given compliance standard. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/auditmanager-2017-07-25/AssessmentFramework">AWS
* API Reference</a></p>
*/
class AWS_AUDITMANAGER_API AssessmentFramework
{
public:
AssessmentFramework();
AssessmentFramework(Aws::Utils::Json::JsonView jsonValue);
AssessmentFramework& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p> The unique identifier for the framework. </p>
*/
inline const Aws::String& GetId() const{ return m_id; }
/**
* <p> The unique identifier for the framework. </p>
*/
inline bool IdHasBeenSet() const { return m_idHasBeenSet; }
/**
* <p> The unique identifier for the framework. </p>
*/
inline void SetId(const Aws::String& value) { m_idHasBeenSet = true; m_id = value; }
/**
* <p> The unique identifier for the framework. </p>
*/
inline void SetId(Aws::String&& value) { m_idHasBeenSet = true; m_id = std::move(value); }
/**
* <p> The unique identifier for the framework. </p>
*/
inline void SetId(const char* value) { m_idHasBeenSet = true; m_id.assign(value); }
/**
* <p> The unique identifier for the framework. </p>
*/
inline AssessmentFramework& WithId(const Aws::String& value) { SetId(value); return *this;}
/**
* <p> The unique identifier for the framework. </p>
*/
inline AssessmentFramework& WithId(Aws::String&& value) { SetId(std::move(value)); return *this;}
/**
* <p> The unique identifier for the framework. </p>
*/
inline AssessmentFramework& WithId(const char* value) { SetId(value); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline const Aws::String& GetArn() const{ return m_arn; }
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline bool ArnHasBeenSet() const { return m_arnHasBeenSet; }
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline void SetArn(const Aws::String& value) { m_arnHasBeenSet = true; m_arn = value; }
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline void SetArn(Aws::String&& value) { m_arnHasBeenSet = true; m_arn = std::move(value); }
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline void SetArn(const char* value) { m_arnHasBeenSet = true; m_arn.assign(value); }
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline AssessmentFramework& WithArn(const Aws::String& value) { SetArn(value); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline AssessmentFramework& WithArn(Aws::String&& value) { SetArn(std::move(value)); return *this;}
/**
* <p> The Amazon Resource Name (ARN) of the specified framework. </p>
*/
inline AssessmentFramework& WithArn(const char* value) { SetArn(value); return *this;}
inline const FrameworkMetadata& GetMetadata() const{ return m_metadata; }
inline bool MetadataHasBeenSet() const { return m_metadataHasBeenSet; }
inline void SetMetadata(const FrameworkMetadata& value) { m_metadataHasBeenSet = true; m_metadata = value; }
inline void SetMetadata(FrameworkMetadata&& value) { m_metadataHasBeenSet = true; m_metadata = std::move(value); }
inline AssessmentFramework& WithMetadata(const FrameworkMetadata& value) { SetMetadata(value); return *this;}
inline AssessmentFramework& WithMetadata(FrameworkMetadata&& value) { SetMetadata(std::move(value)); return *this;}
/**
* <p> The control sets associated with the framework. </p>
*/
inline const Aws::Vector<AssessmentControlSet>& GetControlSets() const{ return m_controlSets; }
/**
* <p> The control sets associated with the framework. </p>
*/
inline bool ControlSetsHasBeenSet() const { return m_controlSetsHasBeenSet; }
/**
* <p> The control sets associated with the framework. </p>
*/
inline void SetControlSets(const Aws::Vector<AssessmentControlSet>& value) { m_controlSetsHasBeenSet = true; m_controlSets = value; }
/**
* <p> The control sets associated with the framework. </p>
*/
inline void SetControlSets(Aws::Vector<AssessmentControlSet>&& value) { m_controlSetsHasBeenSet = true; m_controlSets = std::move(value); }
/**
* <p> The control sets associated with the framework. </p>
*/
inline AssessmentFramework& WithControlSets(const Aws::Vector<AssessmentControlSet>& value) { SetControlSets(value); return *this;}
/**
* <p> The control sets associated with the framework. </p>
*/
inline AssessmentFramework& WithControlSets(Aws::Vector<AssessmentControlSet>&& value) { SetControlSets(std::move(value)); return *this;}
/**
* <p> The control sets associated with the framework. </p>
*/
inline AssessmentFramework& AddControlSets(const AssessmentControlSet& value) { m_controlSetsHasBeenSet = true; m_controlSets.push_back(value); return *this; }
/**
* <p> The control sets associated with the framework. </p>
*/
inline AssessmentFramework& AddControlSets(AssessmentControlSet&& value) { m_controlSetsHasBeenSet = true; m_controlSets.push_back(std::move(value)); return *this; }
private:
Aws::String m_id;
bool m_idHasBeenSet;
Aws::String m_arn;
bool m_arnHasBeenSet;
FrameworkMetadata m_metadata;
bool m_metadataHasBeenSet;
Aws::Vector<AssessmentControlSet> m_controlSets;
bool m_controlSetsHasBeenSet;
};
} // namespace Model
} // namespace AuditManager
} // namespace Aws
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
71163e81681a14261a671036b66767aa81251daa | f9376571d54d2d3aa54505aa863ed452a0140558 | /sparseRRT/src/quadrotor_sst_search.cpp | 9b82eca9e2ba451b4ac27e0e5f41e79ad60c1d64 | [] | no_license | gnunoe/Cf_ROS | f63ddc45655caa5d332a4a61e789aa23399d000a | 7299bef22bd853d41326f7e45865782f2fb549f9 | refs/heads/master | 2021-01-21T14:01:17.355897 | 2015-06-26T18:59:09 | 2015-06-26T18:59:09 | 38,109,928 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,097 | cpp | #include <ros/ros.h>
#include <ros/package.h>
#include "sparseRRT/utilities/parameter_reader.hpp"
#include "sparseRRT/utilities/condition_check.hpp"
#include "sparseRRT/utilities/random.hpp"
#include "sparseRRT/utilities/timer.hpp"
#include "sparseRRT/systems/point.hpp"
#include "sparseRRT/systems/quadrotor.hpp"
#include "sparseRRT/motion_planners/sst.hpp"
#include "sparseRRT/motion_planners/rrt.hpp"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <stdlib.h>
#include <stdio.h>
//SRV test
#include "sparseRRT/sparse_search.h"
#include "std_msgs/String.h"
using namespace std;
//Call ROS nodes to visualize result in RVIZ
void visualize_path()
{
std::string command = "roslaunch sparseRRT disp_obst_traj.launch map:=" + params::map
+ " file_name:=trajectory_sst_search.csv";
//command.append(params::map);
system(command.c_str());
}
class tree{
public:
//=================================//
// VARIABLES //
//=================================//
//Pointer to hold the quadrotor system
system_t* system;
//Pointer to hold the planner (sst)
planner_t* planner;
//Service to process the requests
ros::ServiceServer sparse_search;
//Ros Node Handle
ros::NodeHandle n;
//bool to check the tree has been built
bool tree_built;
//=================================//
// METHODS //
//=================================//
//Constructor
tree(std::string path_file, std::string map, int iter_time, double start[3], double goal[3])
{
ROS_INFO_STREAM("creating tree object ...");
//Initializate variables
sparse_search = n.advertiseService("sparse_tree_search",&tree::search_nodes_in_tree, this);
tree_built = false;
//Read default paramentes and complete them with
//the args received
read_parameters();
params::path_file = path_file;
params::map = map;
params::stopping_check = iter_time;
params::start_state[0] = start[0];
params::start_state[1] = start[1];
params::start_state[2] = start[2];
params::goal_state[0] = goal[0];
params::goal_state[1] = goal[1];
params::goal_state[2] = goal[2];
//Create the system and the planner desired
init_random(std::time(NULL));//params::random_seed);
if(params::system=="quadrotor_cf")
{
system = new quadrotor_cf_t();
}
if(params::planner=="rrt")
{
planner = new rrt_t(system);
}
else if(params::planner=="sst")
{
planner = new sst_t(system);
}
//Change the limits of the map if the selected
//is a only simulation map
if (params::map == "Map2_3D" ||
params::map == "Map3_3D" ||
params::map == "Map4_3D")
{
system->change_Map_Limits(5.0, 6.0, 0.5, 2.5);
}
if (params::map == "Map5_3D")
{
system->change_Map_Limits(5.0, 6.0, 0.5, 4.0);
}
if (params::map == "Map5" ||
params::map == "Map6")
{
system->change_Map_Limits(2.0, 2.5, 0.5, 2.4);
}
}
//Service for search two nodes in the tree
//Return code message
// -> 1 = Success
// -> 2 = Start in collision
// -> 3 = Goal in collision
// -> 4 = Path not found
// -> 5 = Start exceeds map limits
// -> 6 = Goal exceeds map limits
bool search_nodes_in_tree(sparseRRT::sparse_search::Request &req,
sparseRRT::sparse_search::Response &res)
{
//space map limits
double mocap_limits[4]= {2.0, 2.5, 0.5, 1.5};
std::string answer;
bool smooth = false;
while(true)
{
ROS_INFO_STREAM("Apply smoothing to the trajectory? (y/n)");
std::cin >> answer;
if (answer == "y" || answer == "Y")
{
smooth = true;
break;
}
else if (answer == "n" || answer == "N")
{
smooth = false;
break;
}
}
double sec = ros::Time::now().toSec();
ROS_INFO_STREAM("Processing request");
double start[3]={req.x_s, req.y_s, req.z_s};
double goal[3] ={req.x_g, req.y_g, req.z_g};
//if the big maps for simulation were selected,
//change the mocap limits
if (params::map == "Map2_3D" ||
params::map == "Map3_3D" ||
params::map == "Map4_3D")
{
mocap_limits[0] = 5.0;
mocap_limits[1] = 6.0;
mocap_limits[2] = 0.5;
mocap_limits[3] = 2.5;
}
if (params::map == "Map5_3D")
{
mocap_limits[0] = 5.0;
mocap_limits[1] = 6.0;
mocap_limits[2] = 0.5;
mocap_limits[3] = 4.0;
}
if (params::map == "Map5" ||
params::map == "Map6")
{
mocap_limits[0] = 2.0;
mocap_limits[1] = 2.5;
mocap_limits[2] = 0.5;
mocap_limits[3] = 2.4;
}
if (abs(start[0])>mocap_limits[0] | abs(start[1])>mocap_limits[1] |
start[2]<mocap_limits[2] | start[2]>mocap_limits[3])
{
ROS_ERROR_STREAM("Start exceeded map limits");
ROS_ERROR_STREAM("X--> -" << mocap_limits[0] << " < X < " << mocap_limits[0]);
ROS_ERROR_STREAM("Y--> -" << mocap_limits[1] << " < Y < " << mocap_limits[1]);
ROS_ERROR_STREAM("Z--> " << mocap_limits[2] << " < Z < " << mocap_limits[3]);
res.done = 5;
return true;
}
if (abs(goal[0])>mocap_limits[0] | abs(goal[1])>mocap_limits[1] |
goal[2]<mocap_limits[2] | goal[2]>mocap_limits[3])
{
ROS_ERROR_STREAM("Goal exceeded map limits");
ROS_ERROR_STREAM("X--> -" << mocap_limits[0] << " < X < " << mocap_limits[0]);
ROS_ERROR_STREAM("Y--> -" << mocap_limits[1] << " < Y < " << mocap_limits[1]);
ROS_ERROR_STREAM("Z--> " << mocap_limits[2] << " < Z < " << mocap_limits[3]);
res.done = 6;
return true;
}
bool start_ok = system->obstacles_in_start(start[0],start[1],start[2]);
if(start_ok)
{
res.done = 2;
return true;
}
bool goal_ok = system->obstacles_in_start(goal[0],goal[1],goal[2]);
if(goal_ok)
{
res.done = 3;
return true;
}
bool found_path = planner->path_between_nodes(start[0], start[1], start[2],
goal[0], goal[1], goal[2],
smooth);
if (!found_path)
{
res.done = 4;
return true;
}
ROS_INFO_STREAM("Processed in: " << ros::Time::now().toSec() - sec << " seconds");
ROS_INFO_STREAM("Visualizing in RVIZ...");
visualize_path();
res.done = 1;
return true;
}
/*
bool search(double x_s, double y_s, double z_s, double x_g, double y_g, double z_g)
{
bool start_ok = system->obstacles_in_start(x_s, y_s,z_s);
if(start_ok)
{
return false;
}
bool goal_ok = system->obstacles_in_start(x_g, y_g, z_g);
if(goal_ok)
{
return false;
}
bool found_path = planner->path_between_nodes(x_s, y_s, z_s, x_g, y_g, z_g);
if (!found_path)
{
return false;
}
//ROS_INFO_STREAM(ros::Time::now().toSec() - sec);
return true;
}
*/
//Create the tree
void create_tree()
{
planner->set_start_state(params::start_state);
planner->set_goal_state(params::goal_state,params::goal_radius);
planner->setup_planning();
condition_check_t checker(params::stopping_type,params::stopping_check);
condition_check_t* stats_check=NULL;
if(params::stats_check!=0)
{
stats_check = new condition_check_t(params::stats_type,params::stats_check);
}
checker.reset();
std::cout<<"Building the tree for the planner: "<<params::planner<<" for the system: "<<params::system<<" in: "<< params::map <<std::endl;
if(stats_check==NULL)
{
do
{
planner->step();
}
while(!checker.check());
std::cout<<"Time: "<<checker.time()<<" Iterations: "<<checker.iterations()<<" Nodes: "<<planner->number_of_nodes<< "\n";
}
else
{
int count = 0;
bool execution_done = false;
bool stats_print = false;
while(true && ros::ok())
{
do
{
planner->step();
execution_done = checker.check();
stats_print = stats_check->check();
}
while(!execution_done && !stats_print);
if(stats_print)
{
std::cout<<"Time: "<<checker.time()<<" Iterations: "<<checker.iterations()<<" Nodes: "<<planner->number_of_nodes<< "\n";
stats_print = false;
stats_check->reset();
}
if (execution_done)
{
std::cout<<"Time: "<<checker.time()<<" Iterations: "<<checker.iterations()<<" Nodes: "<<planner->number_of_nodes<<"\n";
break;
}
}
}
ROS_INFO_STREAM("Tree built, waiting for request");
tree_built = true;
n.setParam("available_sparse_service", 1);
infinite_loop();
}
//Infinite loop to keep the node alive and process client requests
void infinite_loop()
{
while(ros::ok())
{
/*
//std::cout << ".";
double start[3];
double goal[3];
std::cin >> start[0];
std::cin >> start[1];
std::cin >> start[2];
std::cin >> goal[0];
std::cin >> goal[1];
std::cin >> goal[2];
bool done = search(start[0], start[1], start[2], goal[0], goal[1], goal[2]);
std::cout << done << "\n";
*/
ros::spinOnce();
}
}
};
int main( int argc, char** argv )
{
ros::init(argc, argv, "quadrotor_SST_tree_service");
std::string path_file ="";
std::string map_name = "";
int iter_time = 0;
double sparse_start[3]={0,0,0};
double sparse_goal[3]={0,0,0};
if (argc !=10)
{
ROS_INFO_STREAM("Usage: quadrotor_SST <Map> <Iteration Time> <startX> <startY> <startZ> <goalX> <goalY> <goalZ>");
ROS_INFO_STREAM("Supported Maps: Map1, Map2, Map3, Map4");
return 1;
}
else
{
path_file = argv[1];
map_name = argv[2];
iter_time = atoi(argv[3]);
//fill start position
sparse_start[0] = atof(argv[4]);
sparse_start[1] = atof(argv[5]);
sparse_start[2] = atof(argv[6]);
//and goal position
sparse_goal[0] = atof(argv[7]);
sparse_goal[1] = atof(argv[8]);
sparse_goal[2] = atof(argv[9]);
if (map_name != "Map1" &&
map_name != "Map2" &&
map_name != "Map3" &&
map_name != "Map4" &&
map_name != "Map5" &&
map_name != "Map6" &&
map_name != "Map1_3D" &&
map_name != "Map2_3D" &&
map_name != "Map3_3D" &&
map_name != "Map4_3D" &&
map_name != "Map5_3D")
{
ROS_INFO_STREAM(map_name << " is not a supported map");
return 1;
}
}
ros::NodeHandle n;
tree *t = new tree(path_file, map_name, iter_time, sparse_start, sparse_goal);
//Check if there is obstacles in goal or start
bool goal_in_obstacle = t->system->obstacles_in_goal();
if (goal_in_obstacle)
{
ROS_ERROR_STREAM("Abort planning, obstacles in goal");
}
bool start_in_obstacle = t->system->obstacles_in_start();
if (start_in_obstacle)
{
ROS_ERROR_STREAM("Abort planning, obstacles in start");
}
if(start_in_obstacle || goal_in_obstacle)
{
ROS_ERROR_STREAM("Closing tree server...");
n.setParam("available_sparse_service", 2);
}
else
{
//n.setParam("available_sparse_service", 1);
t->create_tree();
}
return 1;
}
| [
"estevez@brixx.informatik.uni-freiburg.de"
] | estevez@brixx.informatik.uni-freiburg.de |
2ec9049741ca704138179e45c8d67b27fca2d607 | ecf0bc675b4225da23f1ea36c0eda737912ef8a9 | /Reco_Csrc/Engine/Terrain/TRGenerate.cpp | 12ce3ad9767bb608c2373a33eebcb7b6d675a233 | [] | no_license | Artarex/MysteryV2 | 6015af1b501ce5b970fdc9f5b28c80a065fbcfed | 2fa5608a4e48be36f56339db685ae5530107a520 | refs/heads/master | 2022-01-04T17:00:05.899039 | 2019-03-11T19:41:19 | 2019-03-11T19:41:19 | 175,065,496 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 130 | cpp | version https://git-lfs.github.com/spec/v1
oid sha256:0ad34741e40313c160df19708a9b0062ed5e535b5452518b9ebcb84946562262
size 93885
| [
"artarex@web.de"
] | artarex@web.de |
425fca8f3685e57f82296bf9e613bc0952f8c899 | 5ab88620c3706881e01b204c3bd945b7ba224929 | /IOM/IOM_prep/assoc_container/sol.cpp | 929f5a03ed21971cdfd8f90b2dbd48b7a17f8ee3 | [] | no_license | therray/old-codes | 81799fec3deb7560a7cdaa6a07d45a014f8edf2c | 7f2d03f67a954d8182fb1807ee23d80ec07980b3 | refs/heads/main | 2023-05-06T09:09:20.017626 | 2021-05-30T14:05:49 | 2021-05-30T14:05:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 439 | cpp | // author: erray
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
gp_hash_table<long long, int> freq;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
pbds t;
t.insert(1);
t.insert(5);
int x = t.order_of_key(2);
cout << *t.find_by_order(x) << '\n';
} | [
"c.e.aslan37@gmail.com"
] | c.e.aslan37@gmail.com |
e33bbb02857d810cb936870fa62ab52868b8acf5 | 8e9221ca3e521f2a46444b6e1627fdcfc1f02ea8 | /src/core/include/capsaicin.h | 5385331e5dd86cb71349c1e0cc493a7fe4d87f35 | [] | no_license | yozhijk/capsaicin | 2d5e72d348daae7f5afcb47c86c40784a0ae0263 | b79fe2029666aff7371019deb712cd0b4bbb2d0f | refs/heads/master | 2021-03-02T16:05:43.358395 | 2020-09-21T14:13:55 | 2020-09-21T14:13:55 | 245,882,382 | 7 | 2 | null | 2020-08-21T07:50:42 | 2020-03-08T20:24:09 | C | UTF-8 | C++ | false | false | 572 | h | #pragma once
#include <cstdint>
#include <string>
// Backend specific stuff
#ifdef WIN32
#define NOMINMAX
#include <Windows.h>
struct RenderSessionParams
{
HWND hwnd;
};
struct Input
{
UINT message;
LPARAM lparam;
WPARAM wparam;
};
#endif
using std::uint32_t;
namespace capsaicin
{
void Init();
void InitRenderSession(void* params);
void LoadSceneFromOBJ(const std::string& file_name);
void ProcessInput(void* input);
void Update(float time_ms);
void Render();
void SetOption();
void ShutdownRenderSession();
void Shutdown();
} // namespace capsaicin | [
"dmitry.a.kozlov@gmail.com"
] | dmitry.a.kozlov@gmail.com |
a0bafc586e60e8aaa1ddf5e8f99f7f5abdee99de | 55cfa1eed966766aeb72e54a1ed6f2591255e5c0 | /LC_261.cpp | eed44d8de2439077b03d57856931e25fe87b72d6 | [] | no_license | iCodeIN/leetcode-4 | 1bf2751c861ccf1652b0e5b096595e6874e568e3 | 9081802f99da6cfded421fe10052839bad449fd2 | refs/heads/master | 2023-01-13T07:22:53.362907 | 2020-11-13T03:56:20 | 2020-11-13T03:56:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 967 | cpp | class Solution {
public:
bool validTree(int n, vector<vector<int>>& edges) {
int i,sz=edges.size(),from,to,neigh;
vector<vector<int>>adj(n+1);
if(sz!=n-1)
return false;
vector<int>visited(n+1,0);
for(i=0;i<sz;i++)
{
from=edges[i][0];
to=edges[i][1];
adj[from].push_back(to);
adj[to].push_back(from);
}
queue<int>q;
q.push(0);
visited[0]=1;
while(!q.empty())
{
from=q.front();
q.pop();
for(i=0;i<adj[from].size();i++)
{
neigh=adj[from][i];
if(!visited[neigh])
{
q.push(neigh);
visited[neigh]=1;
}
}
}
for(i=0;i<n;i++)
{
if(visited[i]==0)
return false;
}
return true;
}
};
| [
"noreply@github.com"
] | iCodeIN.noreply@github.com |
b505d642325edca96e09c2cff976b204e92b15c6 | 7c9b4968c3a7c20eb0811a6275c4fb3b0ba8fda2 | /WaterLevel/ABP/ABP.ino | 4efdf98a46223e02184aea5b6b4bb42a4d86b017 | [] | no_license | Ellerbach/LoRaGPSTrackerWaterLevel | c98119592af96ff759227daecbf7cb0ec1b87dd8 | 830af1e6f0fae0793666fdba846f7694e1083621 | refs/heads/master | 2020-04-11T21:21:56.248218 | 2018-12-17T09:24:59 | 2018-12-17T09:24:59 | 162,103,261 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,707 | ino |
#include <LoRaWan.h>
#include <Seeed_vl53l0x.h>
Seeed_vl53l0x VL53L0X;
//set to true to send confirmed data up messages
bool confirmed=true;
//application information, should be similar to what was provisiionned in the device twins
char * deviceId ="5555ABCDEF123456";
char * devAddr ="55555555";
char * appSKey ="55551234567890ABCDEF1234567890AB";
char * nwkSKey ="55551234567890ABCDEF1234567890AB";
#define PIN_SOIL_HUMID PIN_A2
#define PIN_WATER_LEVEL PIN_A0
#define PIN_BATTERY PIN_A4
#define PIN_CHARGING PIN_A5
/*
iot hub ABP tags for deviceid: 46AAC86800430028
"desired": {
"AppSKey": "0A501524F8EA5FCBF9BDB5AD7D126F75",
"NwkSKey": "99D58493D1205B43EFF938F0F66C339E",
"DevAddr": "55555555",
"GatewayID" :"",
"SensorDecoder" :"DecoderValueSensor"
},
*/
//set initial datarate and physical information for the device
_data_rate_t dr=DR6;
_physical_type_t physicalType =EU868 ;
//internal variables
#define DATA_LENGTH 4
byte data[DATA_LENGTH];
char buffer[256];
int i=0;
int lastCall=0;
void setup(void)
{
SerialUSB.begin(115200);
while(!SerialUSB);
lora.init();
lora.setId(devAddr, deviceId, NULL);
lora.setKey(nwkSKey, appSKey, NULL);
lora.setDeciveMode(LWABP);
lora.setDataRate(dr, physicalType);
lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);
lora.setReceiceWindowFirst(0, 868.1);
lora.setAdaptiveDataRate(false);
lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);
lora.setPower(14);
pinMode(PIN_SOIL_HUMID, INPUT);
pinMode(PIN_WATER_LEVEL, INPUT);
pinMode(PIN_BATTERY, INPUT);
pinMode(PIN_CHARGING, INPUT);
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
Status=VL53L0X.VL53L0X_common_init();
if(VL53L0X_ERROR_NONE!=Status)
{
SerialUSB.println("start vl53l0x mesurement failed!");
VL53L0X.print_pal_error(Status);
while(1);
}
VL53L0X.VL53L0X_high_accuracy_ranging_init();
if(VL53L0X_ERROR_NONE!=Status)
{
SerialUSB.println("start vl53l0x mesurement failed!");
VL53L0X.print_pal_error(Status);
while(1);
}
}
void loop(void)
{
if((millis()-lastCall)>5000){
lastCall=millis();
bool result = false;
String packetString = "12";
packetString=String(i);
SerialUSB.println(packetString);
int distance = MeasureDistance();
int waterLevel = MeasureWaterLevel();
int soilHumid = MeasureSoilHumid();
int battery = MeasureBattery();
int charging = MeasureCharging();
SerialUSB.print("Distance: ");
SerialUSB.print(distance);
SerialUSB.print(" waterLevel: ");
SerialUSB.print(waterLevel);
SerialUSB.print(" soilHumid: ");
SerialUSB.print(soilHumid);
SerialUSB.print(" battery: ");
SerialUSB.println(battery);
SerialUSB.print(" charge: ");
SerialUSB.println(charging);
EncodeData(distance, waterLevel, soilHumid, battery, charging);
if(confirmed)
result = lora.transferPacketWithConfirmed(data, DATA_LENGTH);
else
result = lora.transferPacket(data, DATA_LENGTH);
i++;
if(result)
{
short length;
short rssi;
memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);
if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print( char(buffer[i]));
}
SerialUSB.println();
}
}
}
}
int MeasureDistance()
{
VL53L0X_RangingMeasurementData_t RangingMeasurementData;
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
memset(&RangingMeasurementData,0,sizeof(VL53L0X_RangingMeasurementData_t));
Status=VL53L0X.PerformSingleRangingMeasurement(&RangingMeasurementData);
if(VL53L0X_ERROR_NONE==Status)
{
if(RangingMeasurementData.RangeMilliMeter>=2000)
{
SerialUSB.println("out of range!!");
return 0;
}
else
{
SerialUSB.print("Measured distance:");
SerialUSB.print(RangingMeasurementData.RangeMilliMeter);
SerialUSB.println(" mm");
}
}
else
{
SerialUSB.print("mesurement failed !! Status code =");
SerialUSB.println(Status);
return 0;
}
return RangingMeasurementData.RangeMilliMeter;
}
int MeasureWaterLevel()
{
return analogRead(PIN_WATER_LEVEL)/2;
}
int MeasureSoilHumid()
{
return analogRead(PIN_SOIL_HUMID)/2;
}
int MeasureBattery()
{
int bat = analogRead(PIN_BATTERY);
//bat stops working at 2.5V so 70
//3.7V is 105
if (bat > 96)
bat = 3;
else if (bat > 87)
bat = 2;
else if (bat > 78)
bat = 1;
else
bat = 0;
return bat;
}
int MeasureCharging()
{
int ch = digitalRead(PIN_CHARGING);
if (ch==LOW)
return 1;
return 0;
}
void EncodeData(int distance, int waterLevel, int soilHumid, int battery, int charging)
{
/*
Min Max Number of bits
Time to Flight 10 2000 11
Water Sensor 0 511 9
Soil Humid 0 511 9
Battery Level 0 3 2
Charging 0 1 1
Total 32
bits
TF 0->10
WS 11->19
SH 20->28
BA 29->30
CH 30->31
*/
data[0] = distance & 0xFF;
data[1] = (distance >> 8) & 0x07;
data[1] = data[1] | ((waterLevel & 0x1F) << 3);
data[2] = (waterLevel >> 3) & 0x0F;
data[2] = data[2] | ((soilHumid & 0x0F) << 4);
data[3] = (soilHumid >> 4) & 0x1F;
data[3] = data[3] | ((battery & 0x03) << 5);
data[3] = data[3] | ((charging & 0x01) << 7);
} | [
"laurelle@microsoft.com"
] | laurelle@microsoft.com |
ebd338a5a2a3c5eaddaeac3f02b8c59e7790ffa7 | 808d73dd23af6376527c420348695aa01df2a79c | /src/LAB10.ino | ab0be575949a4137b4d8645d41c3c1d89e955870 | [] | no_license | Yusufalsomali/LAB10 | 76b2c8352c9fd972b7fedf1dfb1747a2b65d2e8b | 754320252db38bac123eaa3ae5d6cf009199dde3 | refs/heads/master | 2023-06-15T21:44:43.478833 | 2021-07-07T17:49:06 | 2021-07-07T17:49:06 | 383,881,280 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 846 | ino | /*
* Project LAB10
* Description:
* Author:
* Date:
*/
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
#include <Wire.h>
void setup() {
//set up wire, and serial
Serial.begin(9600);
Wire.begin();
}
void loop() {
while (!Serial.isConnected()); //dont start until Serial is connected
if (Serial.available()) {
//char x = '?';
char x = Serial.read();
Serial.println(x);
//transmit value of light to slave bus
if (x == '0' || x == '1')
{
Wire.beginTransmission(0x2A); // transmit to slave device
Wire.write((char) x); // sends one byte
Wire.endTransmission(); // stop transmitting
}
//receive transmission
else if (x == '?')
{
//read request and print to serial
Wire.requestFrom(0x2a, 1);
char state = Wire.read();
Serial.print(state);
}
}
} | [
"yusufalsomali5@gmail.com"
] | yusufalsomali5@gmail.com |
9750590c48d3567ce1bc9cf26da3030e841f4e9b | 261edff1dddb9b4087a73e0bf0ab13ea9e084c2e | /Constructors.cpp | e80d81eb2cca45ef57f87336f16d65cb831408fa | [
"Apache-2.0"
] | permissive | Rohit-Anand/Constructors | b3fa97f5c86789f0dd7dcc61cbaa5ec2be9ed9fb | 45b37d860910f61b57486769a4ee3ccdd36fc943 | refs/heads/master | 2020-03-23T13:12:02.826342 | 2018-07-19T16:40:58 | 2018-07-19T16:47:35 | 141,605,292 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,434 | cpp | //
// Constructors.cpp
// Learning_cpp
//
// Created by Rohit Anand on 23/06/18.
// Copyright © 2018 Rohit Anand. All rights reserved.
//
// This file is dummy, just to print and monitor the c'Tors, may be used later to introduce
// C'Tors and D'Tors to others
#include <iostream>
using namespace std;
class Base {
public:
Base() {
cout << "Base default c'tor" << endl;
a = 10;
}
Base (const Base& b) {
cout << "Base Copy Const c'tor" << endl;
}
Base (Base& b) {
cout << "Base Copy c'tor" << endl;
}
Base(Base&& b) {
cout << "Base Move c'tor" << endl;
a = b.a;
b.a = 0;
}
Base& operator= (Base& b) {
cout << "operator = Base" << endl;
return b;
}
virtual void fun() const {
cout << "Base Fun: " << a << endl;
}
int a;
Base(const Base&& b) {
cout << "Base const Move c'tor" << endl;
a = b.a;
}
};
class Derived : public Base {
public:
void fun() const {
cout << "Derived Fun" << endl;
}
};
int main() {
const Base b;
cout << " -- --- " << endl;
Base b1(b);
cout << " -- --- " << endl;
Base b2(std::move(b));
cout << " -- --- " << endl;
b.fun();
b2.fun();
Derived d;
d.fun();
cout << " -- bD --- " << endl;
Base* b3 = new Derived();
b3->fun();
return 0;
}
| [
"rohitanand28@gmail.com"
] | rohitanand28@gmail.com |
3bcd8766270c82975b5c889c468ab20dc8830444 | 2c47e7983a01c9ddb0627353c53686fdec6ef930 | /source/aafile/localWriter.h | da18120a071ca042480328e5e0c2323a2047ec57 | [] | no_license | 16in/yatools | 1ca4005def8b1abe3bf245931803da1785e1b96a | b023cbc67c89c9691c40d8762089152c53e9e8ff | refs/heads/master | 2021-07-07T18:25:54.938089 | 2019-04-01T21:12:57 | 2019-04-01T21:12:57 | 169,947,699 | 2 | 1 | null | null | null | null | SHIFT_JIS | C++ | false | false | 4,705 | h | /*----------------------------------------------------------------------
*
* AA関連ファイルライタから参照するローカル関数
*
* Copyright (c) 2012-2019 _16in/◆7N5y1wtOn2
*
*----------------------------------------------------------------------*/
#pragma once
#include <aafile/AAFileAccessor.h>
#include "types.h"
namespace aafile {
/**
* ページ内容のみ書き出す
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @return uint_t 書き出した文字数
*/
static uint_t WritePageValue( AAFilePage* page, wchar_t* writeString, uint_t length );
/**
* TXTファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageTXT( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* MLTファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageMLT( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* ASTファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageAST( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* ASDファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageASD( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* AADataファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageAADATA( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* AAListファイルの書き出し
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageAALIST( AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
/**
* AADataファイルの書き出し
* @param[in] split 分割文字列
* @param[in] end 終端分割文字列
* @param[in] page ページデータ
* @param[out] writeString 書き出し先
* @param[in] length 書き出し先の文字数
* @param[in] lastPage 最終ページなら真
* @return uint_t 書き出した文字数
*/
static uint_t WritePageAADataList( const wchar_t* split, const wchar_t* end, AAFilePage* page, wchar_t* writeString, uint_t length, bool lastPage );
}
/*----------------------------------------------------------------------
* License
*
* AAFileAccessor
*
* Copyright (c) 2012-2019 _16in/◆7N5y1wtOn2
*
* 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.
*
*----------------------------------------------------------------------*/
| [
"kmp.16in@gmail.com"
] | kmp.16in@gmail.com |
b6233d62361331640263d652ddcb63c1d91715be | 639d6f230b480183879b6d3035032e9d6c1b13c4 | /Inheritance/Inheritance -II/Ass2/smanager.h | c17d7ee5b16db139596ced2790553240b593e6c5 | [] | no_license | Sweety4/CPP-Solution | 5a1dbf29e549f4563e5aabc996a096c2b0332a0c | d9365a9cf3bbac0d4a21732eb847b5b46e4d536f | refs/heads/main | 2023-01-12T01:17:28.183053 | 2020-11-09T13:37:14 | 2020-11-09T13:37:14 | 311,346,419 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 231 | h |
#include"sales.h"
#include"manager.h"
class cSalesManager :public cSalesPerson, public cManager
{
public:
cSalesManager();
cSalesManager(int, const char*, float, float, float, float, float);
void Accept();
void Display();
};
| [
"sweetyjangale5@gmail.com"
] | sweetyjangale5@gmail.com |
771972d3037644b1160cadcaab472e9831227457 | 554881e86cedef1e63d322d46dfdb40f41abbc6b | /UrlTitleCollector/net/httpconnection.h | 5efa1182315f8efad1a6db057d0a4d494cb2d436 | [
"MIT"
] | permissive | SteaveP/UrlTitleCollector | 07839e7463063c3aecd1a90e328da1e60566e9c2 | ea5f0bf57b9469d30c536df4b62a08ac7e1a58d7 | refs/heads/master | 2021-01-22T20:55:34.574333 | 2017-03-24T17:21:56 | 2017-03-24T17:21:56 | 85,379,029 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,619 | h | #pragma once
#include "../data/iconnection.h"
#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
namespace nc
{
namespace net
{
// TODO remove code duplication (merge with HttpsConnection)
class HttpConnection : public IConnection, public boost::enable_shared_from_this<HttpConnection>
{
public:
HttpConnection(
boost::asio::io_service& io_service,
boost::asio::ip::tcp::resolver::iterator endpoint_iterator
);
virtual ~HttpConnection();
virtual void connect(TConnectionCallback connectionCallback, TAnyPtr data = TAnyPtr()) override;
virtual void close() override;
virtual void setData(TAnyPtr data) override { data_ = data; }
virtual TAnyPtr getData() const override { return data_; }
virtual void async_read(TReadCallback callback) override;
virtual void async_write(const char* message, size_t message_size, TWriteCallback callback) override;
private:
void handle_connect(TConnectionCallback connectionCallback, const boost::system::error_code& error);
void handle_write(TWriteCallback writeCallback, const boost::system::error_code& error, size_t bytes_transferred);
void handle_read(TReadCallback readCallback, const boost::system::error_code& error, size_t bytes_transferred);
boost::shared_ptr<HttpConnection> getptr() { return shared_from_this(); }
private:
boost::asio::ip::tcp::socket socket_;
boost::asio::streambuf buffer_request_;
boost::asio::streambuf buffer_reply_;
// use strand to prevent concurrent callbacks
boost::asio::strand strand_;
boost::asio::ip::tcp::resolver::iterator connection_point_;
bool connected_;
TAnyPtr data_;
};
}
} | [
"Swoo2n@gmail.com"
] | Swoo2n@gmail.com |
8776dc495f656d8f37afb30993e1870272eba0dc | c3aa9ecb1d49a3949260ae48571de2be2484eaea | /src/TerrainRange.h | 541262c08cc15e3c1520c5592bea32c681eef675 | [] | no_license | skryvokhizhyn/TransportMania | 0f628b47c87d3bce71d8aa5f0997e3e748602f29 | 3033a82a5115ef56275a31bd5c81b031e7d481be | refs/heads/master | 2021-05-16T02:14:31.979601 | 2017-03-11T15:18:36 | 2017-03-11T15:18:36 | 18,496,320 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 712 | h | #ifndef _TERRAINRANGE_H_
#define _TERRAINRANGE_H_
//#include "Point2d.h"
#include <boost/noncopyable.hpp>
#include <utility>
#include <vector>
#include <ostream>
namespace trm
{
struct Point2d;
class TerrainRange
{
public:
struct Range
{
int y;
int xBegin;
int xEnd;
Range();
Range(const int a, const int b, const int c);
};
typedef std::vector<Range> Ranges;
public:
virtual ~TerrainRange();
const Ranges & GetRanges() const;
protected:
void Init(const size_t sz);
void PutRange(const Range & r);
private:
Ranges ranges_;
};
std::ostream & operator << (std::ostream & ostr, const trm::TerrainRange::Range & r);
} // namespace trm
#endif // _TERRAINRANGE_H_
| [
"vv1ld@ua.fm"
] | vv1ld@ua.fm |
325ab60666ad3500c0ffcce467ef0de47e50131e | c251c69949132212bf15432136104380719cbbfd | /SQF/dayz_code/Configs/CfgMagazines/Crafting/equip_part_camo.hpp | 6d83b997ee4d4a750de7533f646361dea6f0e7e0 | [] | no_license | DayZMod/DayZ | fc7c27ab4ceb9501229b0b952e6d0894fe6af57a | 42368d7bbf0c85e51ddc75074a82196a21db9a55 | refs/heads/Development | 2021-01-23T16:26:17.696800 | 2019-01-26T16:24:58 | 2019-01-26T16:24:58 | 10,610,876 | 173 | 176 | null | 2020-03-26T14:26:53 | 2013-06-10T22:31:23 | C++ | UTF-8 | C++ | false | false | 255 | hpp | class equip_part_camo : CA_Magazine {
scope = public;
count = 1;
displayName = $STR_ITEM_NAME_equip_part_camo;
descriptionShort = $STR_ITEM_DESC_equip_part_camo;
picture = "\z\addons\dayz_communityassets\textures\equip_part_camo.paa";
type = 256;
}; | [
"R4Z0R49@gmail.com"
] | R4Z0R49@gmail.com |
f74a8913e9ee030bc338e2edf62e9cede9c43206 | c8814f2e344cf72bc25ad84e2e596505bbddcdf2 | /2 数学/2.1 代数/2.1.6 Adaptive Simpson's Rule.cpp | 9199127800ba70a28e47bf9928fea491269d7bb1 | [] | no_license | Hukeqing/ACM-Template-SingDanceRap | b648d7058f05be8e6c268e27cc63e18fa2168f1a | 3c61332d5630ab466a48b95b9c67de31e1e63087 | refs/heads/master | 2023-02-02T14:38:07.376220 | 2020-12-24T01:57:44 | 2020-12-24T01:57:44 | 189,908,584 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 694 | cpp | double F(double x)
{
//Simpson公式用到的函数
}
double simpson(double a, double b)//三点Simpson法,这里要求F是一个全局函数
{
double c = a + (b - a) / 2;
return (F(a) + 4 * F(c) + F(b))*(b - a) / 6;
}
double asr(double a, double b, double eps, double A)//自适应Simpson公式(递归过程)。已知整个区间[a,b]上的三点Simpson值A
{
double c = a + (b - a) / 2;
double L = simpson(a, c), R = simpson(c, b);
if (fabs(L + R - A) <= 15 * eps)return L + R + (L + R - A) / 15.0;
return asr(a, c, eps / 2, L) + asr(c, b, eps / 2, R);
}
double asr(double a, double b, double eps)//自适应Simpson公式(主过程)
{
return asr(a, b, eps, simpson(a, b));
} | [
"zhangyf3210@163.com"
] | zhangyf3210@163.com |
083beb8e16f1aac1fc3af4f818e8e9f450448af1 | d2847848e1decbb8076345ebcc71223edf47ac80 | /tests/fitting/ComplexDiffTest.h | 15db961e46a694be9b8113cd7f6410298378fe5f | [
"MIT"
] | permissive | lao19881213/base-scimath | fd274a76ea386fb3f659666812b1ab522ad3bc65 | bfbe6b01be130d83f116c11f48189062782ced35 | refs/heads/main | 2023-05-31T03:23:03.407735 | 2021-06-12T06:38:52 | 2021-06-12T06:38:52 | 376,219,225 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,900 | h | /// @file
///
/// @brief Tests of ComplexDiff autodifferentiation class
/// @details See ComplexDiff for description of what this class
/// is supposed to do. This file contains appropriate unit tests.
///
/// @copyright (c) 2007 CSIRO
/// Australia Telescope National Facility (ATNF)
/// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
/// PO Box 76, Epping NSW 1710, Australia
/// atnf-enquiries@csiro.au
///
/// This file is part of the ASKAP software distribution.
///
/// The ASKAP software distribution is free software: you can redistribute it
/// and/or modify it under the terms of the GNU General Public License as
/// published by the Free Software Foundation; either version 2 of the License,
/// or (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// @author Max Voronkov <maxim.voronkov@csiro.au>
#ifndef COMPLEX_DIFF_TEST
#define COMPLEX_DIFF_TEST
#include <askap/scimath/fitting/ComplexDiff.h>
#include <askap/scimath/fitting/ComplexDiffMatrix.h>
#include <cppunit/extensions/HelperMacros.h>
#include <askap/askap/AskapError.h>
#include <algorithm>
#include <set>
namespace askap {
namespace scimath {
class ComplexDiffTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ComplexDiffTest);
CPPUNIT_TEST(testAdd);
CPPUNIT_TEST(testMultiply);
CPPUNIT_TEST(testMultiplyVector);
CPPUNIT_TEST(testConjugate);
CPPUNIT_TEST(testParameterList);
CPPUNIT_TEST(testParameterType);
CPPUNIT_TEST_SUITE_END();
private:
ComplexDiff f,g;
public:
void setUp();
void testAdd();
void testMultiply();
void testMultiplyVector();
void testConjugate();
void testParameterList();
void testParameterType();
};
void ComplexDiffTest::setUp()
{
f = ComplexDiff("g1",casa::Complex(35.,-15.));
g = ComplexDiff("g2",casa::Complex(-35.,15.));
}
void ComplexDiffTest::testAdd()
{
f+=g;
CPPUNIT_ASSERT(abs(f.value())<1e-7);
CPPUNIT_ASSERT(abs(f.derivRe("g1")-casa::Complex(1.,0.))<1e-7);
CPPUNIT_ASSERT(abs(f.derivRe("g2")-casa::Complex(1.,0.))<1e-7);
CPPUNIT_ASSERT(abs(f.derivIm("g1")-casa::Complex(0.,1.))<1e-7);
CPPUNIT_ASSERT(abs(f.derivIm("g2")-casa::Complex(0.,1.))<1e-7);
g+=f;
CPPUNIT_ASSERT(abs(g.value()-casa::Complex(-35.,15.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivRe("g1")-casa::Complex(1.,0.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivIm("g1")-casa::Complex(0.,1.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivRe("g2")-casa::Complex(2.,0.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivIm("g2")-casa::Complex(0.,2.))<1e-7);
ComplexDiff d = g+f+1+casa::Complex(0.,-2.);
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(-34.,13.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g1")-casa::Complex(2.,0.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g1")-casa::Complex(0.,2.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(3.,0.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(0.,3.))<1e-7);
}
void ComplexDiffTest::testMultiply()
{
ComplexDiff d = g*f;
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(-1000.,1050.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g1")-casa::Complex(-35.,15.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g1")-casa::Complex(-15.,-35.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(35.,-15.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(15.,35.))<1e-7);
g*=f;
CPPUNIT_ASSERT(abs(g.value()-casa::Complex(-1000.,1050.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivRe("g1")-casa::Complex(-35.,15.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivIm("g1")-casa::Complex(-15.,-35.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivRe("g2")-casa::Complex(35.,-15.))<1e-7);
CPPUNIT_ASSERT(abs(g.derivIm("g2")-casa::Complex(15.,35.))<1e-7);
d = g*casa::Complex(0.,1.);
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(-1050.,-1000.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g1")-casa::Complex(-15,-35.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g1")-casa::Complex(35.,-15.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(15,35.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(-35.,15.))<1e-7);
}
void ComplexDiffTest::testMultiplyVector()
{
casa::Vector<casa::Complex> vec(10,casa::Complex(0.,-2.));
ComplexDiffMatrix cdVec = vec * f;
for (casa::uInt i = 0; i< vec.nelements(); ++i) {
ASKAPASSERT(i < cdVec.nElements());
const ComplexDiff &d = cdVec[i];
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(-30.,-70.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g1")-casa::Complex(0,-2.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g1")-casa::Complex(2.,0.))<1e-7);
}
ComplexDiff g1(g);
cdVec = g1 * vec;
for (casa::uInt i = 0; i< vec.nelements(); ++i) {
ASKAPASSERT(i < cdVec.nElements());
const ComplexDiff &d = cdVec[i];
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(30.,70.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(0,-2.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(2.,0.))<1e-7);
}
cdVec*= f;
for (casa::uInt i = 0; i< vec.nelements(); ++i) {
ASKAPASSERT(i < cdVec.nElements());
const ComplexDiff &d = cdVec[i];
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(2100.,2000))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g1")-casa::Complex(30.,70.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g1")-casa::Complex(-70.,30.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(-30.,-70.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(70.,-30.))<1e-7);
}
}
void ComplexDiffTest::testConjugate()
{
ComplexDiff d = conj(g);
CPPUNIT_ASSERT(abs(d.value()-casa::Complex(-35.,-15.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivRe("g2")-casa::Complex(1.,0.))<1e-7);
CPPUNIT_ASSERT(abs(d.derivIm("g2")-casa::Complex(0.,-1.))<1e-7);
}
void ComplexDiffTest::testParameterList()
{
ComplexDiff d = g*f+1+casa::Complex(0.,-2.);
std::vector<std::string> buf;
std::copy(d.begin(),d.end(),std::back_insert_iterator<std::vector<std::string> >(buf));
CPPUNIT_ASSERT(buf[0] == "g1");
CPPUNIT_ASSERT(buf[1] == "g2");
CPPUNIT_ASSERT(buf.size() == 2);
}
void ComplexDiffTest::testParameterType()
{
ComplexDiff d("real",5);
CPPUNIT_ASSERT(!g.isReal("g2"));
CPPUNIT_ASSERT(!f.isReal("g1"));
CPPUNIT_ASSERT(d.isReal("real"));
ComplexDiff product = g*f*d;
CPPUNIT_ASSERT(!product.isReal("g2"));
CPPUNIT_ASSERT(!product.isReal("g1"));
CPPUNIT_ASSERT(product.isReal("real"));
}
} // namespace scimath
} // namespace askap
#endif // #ifndef COMPLEX_DIFF_TEST
| [
"lbq@shao.ac.cn"
] | lbq@shao.ac.cn |
313888bfb388f06478a711307a78ae612bebe121 | a86bccfd580eb97dcf4f485a2eadb0b773194cdc | /AsterRebotador/stdafx.cpp | d6cacac76b4e60f0b034d7b7effeb1c52b3d9f1c | [
"Apache-2.0"
] | permissive | AaronRebel09/AsteroidSimpleRebounder | 1a76585cd0daf1aad4dcca80dcbb74556249ae4e | 461a17ef9964d16973a50969824ef91111a784d9 | refs/heads/master | 2021-01-22T06:06:33.327043 | 2017-09-03T19:09:40 | 2017-09-03T19:09:40 | 102,283,617 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 327 | cpp | // stdafx.cpp: archivo de código fuente que contiene sólo las inclusiones estándar
// AsterRebotador.pch será el encabezado precompilado
// stdafx.obj contiene la información de tipos precompilada
#include "stdafx.h"
// TODO: mencionar los encabezados adicionales que se necesitan en STDAFX.H
// pero no en este archivo
| [
"aron_rebel@comunidad.unam.mx"
] | aron_rebel@comunidad.unam.mx |
fe4f68537a94a31886347d1135b7290b62ba277f | 6d1bea5c9109dffb129bd61f59db1346c0b114bc | /software/cse/assistance/buffer_dim1.h | 56b4d4cb5d72fc84426afe5986857ff07f44325d | [] | no_license | chibby0ne/split_row_threshold | 8517399e9bd17e450c66fc138b92a6c3444c0d99 | 42dee227bcfb8058dd6a14b704111b931cfa4e7a | refs/heads/master | 2020-12-31T03:55:46.137550 | 2014-08-29T06:23:30 | 2014-08-29T06:23:30 | 16,789,111 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,096 | h | //
// Copyright (C) 2011 Creonic GmbH
//
// This file is part of the Creonic simulation environment (CSE)
// for communication systems.
//
/// \file
/// \brief Specialization of the buffer class for dim = 1
/// \author Timo Lehnigk-Emden
/// \date 2011/06/10
//
#ifndef BUFFER_DIM1_H_
#define BUFFER_DIM1_H_
#include "buffer_abstract.h"
// Enable IT++ Support and library dependency
#ifdef ITPP_SUPPORT
#include <itpp/itbase.h>
#endif
/// Buffer class with one dimension (array)
/**
* Buffer class to store data into a matrix array.
* Class is a specialization of the buffer<T,dim> class with dim = 1.
* In addition if the ITPP_SUPPORT definition is set the class member functions support
* the Vec<T> data type of the it++ library.
* Class as an explicit it++ support, that mean to operate with the Vec<T>
* type from it++ instantiate the class with the type T and NOT with the type
* Vec<T> !
* In addition it has many functions to read and write data to native C++ arrays.
*
* \ingroup base_class
* \ingroup assistance
*/
template <class T> class Buffer<T,1> : public Buffer_Abstract
{
public:
/// Buffer View, a new buffer object is created which uses the memory of the given buffer
Buffer(const Buffer<T,1>& buffer, Buffer_Abstract::BUFFER_TYPE_ENUM buffer_type);
/// Copy constructor
Buffer(const Buffer<T,1>& buffer);
/// Create a new buffer with zero elements
Buffer();
/// Create a new buffer and initialize it with the given values
explicit Buffer(const char* init_value);
/// Create a new buffer with a given size
/**
* @param size Number of elements which can the buffer store
*/
explicit Buffer(unsigned int size);
/// Creates a partial view or a copy of the given buffer
Buffer(const Buffer<T,1>& buffer, unsigned int start_pos, unsigned int length, Buffer_Abstract::BUFFER_TYPE_ENUM buffer_type);
/// Destructor
virtual ~Buffer();
/// Append the given value to the buffer and return a buffer reference.
Buffer<T,1>& operator()(T value)
{
this->Append(value);
return (*this);
}
/// Resize the buffer from the current size to a new size
/**
* \param size New size of the buffer
* \param copy Holds the data if copy=true, if the new buffer size is smaller than the previous one, the oversized date were discarded.
* \param error_out Enable or disable the error messages. An error can occurs if you want to keep the values,
* but the new buffer size is smaller than the old one.
*/
void Resize(unsigned int size, bool copy = false, bool error_out = true);
/// Transform the current buffer instance to a (partial) view of another buffer.
/**
* \param src_buffer Buffer to create the view on.
* \param start_pos Starting position of the view of the source buffer
* \param length Length of the view (number of elements).
* = 0: Create a view up to the end of the original buffer
*/
void Transform_To_View(const Buffer<T,1>& src_buffer, unsigned int start_pos = 0, unsigned int length = 0);
/// Get a single element of the buffer (constant)
/**
* @param i position to set or get, beginning with zero
*/
const T& operator[](int i) const { return mem_ptr_[i]; }
//T operator[](int i) const { return mem_ptr_[i]; }
/// Get or Set a single element of the buffer
/**
* @param i position to set or get, beginning with zero
*/
T& operator[](int i) { return mem_ptr_[i]; }
/// Copy the values from buffer to buffer
/**
* @param input buffer to copy.
*/
Buffer<T,1> &operator=(const Buffer<T,1>& input);
/// Set the value in the buffer from the given string
/**
* The format is val1, val2, val3. The operator throws the invalid_argument exception in
* case of an conversion error.
* The buffer is automatically resized to the number of elements read
*/
Buffer<T,1>& operator=(const std::string& input);
/// Write date into the buffer
/**
* @param input Pointer to data to write into the buffer. Number of
* elements in input must be equal or greater than the buffer.
*/
Buffer<T,1> &operator=(T *input);
/// Set all elements to zero (clear the buffer)
void Clear()
{
for(unsigned int i = 0; i < length_; i++)
(*this)[i] = static_cast<T>(0);
}
/// Set all elements to the given value.
void Set(T input)
{
for(unsigned int i = 0; i < length_; i++)
(*this)[i] = static_cast<T>(input);
}
/// Get the pointer of the internal memory of the buffer, only for advanced users
T* Data_Ptr();
/// Get the pointer of the internal memory of the buffer, only for advanced users
const T* Data_Ptr() const;
/// Write data into the buffer, same as = operator
/**
* @param input Pointer the array to copy the data. Number of elements in input must be equal or greater than the buffer.
*/
void Write(T *input);
/// Write the Sub array/vector into the buffer
/**
* @param[in] input Pointer to the date to write into the buffer
* @param start Index of the buffer to start writing
* @param end Index of the buffer to stop writing the data, if =-1 copy all data up to the end
*/
void Write_Sub_Vector(T* input,int start, int end=-1);
/// Read the whole buffer
/**
* @param[out] output Pointer to the array to copy the date form the buffer into the array. output array must be great enough to store all data.
*/
void Read(T* output);
/// Read the sub array/vector out of the buffer.
/**
* @param[out] output Pointer to the array to copy the date from the buffer into the array. output array must be great enough to store all data.
* @param start Index of the buffer to start reading
* @param end Index of the buffer to stop reading, if =-1 copy all data up to the end
*/
void Read_Sub_Vector(T* output, int start, int end=-1);
/// Compare the value of the current buffer with another one and return the number of differences
int Compare(const Buffer<T,1> &buffer);
/// Compare the value of the current buffer with another one
bool operator==(const Buffer<T,1> &input);
/// Append a single element to the Buffer (Resize included).
void Append(T input);
// Functions for it++ Vec<T> data type
#ifdef ITPP_SUPPORT
/**
* For use with the it++ data type Vec<T>, see operator =()
* \overload
*/
Buffer<T,1> &operator=(itpp::Vec<T> &input);
/**
* For use with the it++ data type bvec, see operator =()
* \overload
*/
Buffer<T,1> &operator=(itpp::bvec &input);
/**
* For use with the it++ data type itpp::Vec<T>, see Read()
* \overload void Read(itpp::Vec<T> &output)
*/
void Read(itpp::Vec<T> &output);
/**
* For use with the it++ data type itpp::Vec<T>, see Read_Sub_Vector()
* \overload void Read_Sub_Vector(itpp::Vec<T>& output, int start, int end=-1);
*/
void Read_Sub_Vector(itpp::Vec<T> &output,int start, int end=-1);
/// Create a new vector which contains a copy of all data of the buffer
/**
* @return New vector of type itpp::Vec<T>
*/
itpp::Vec<T> Read();
/// Return a new vector which contains parts of the buffer values
/**
* @param start First index of data to read from buffer
* @param end Last index of data to read
* @return New vector of type itpp::Vec<T> which contains the requested date
*/
itpp::Vec<T> Read_Sub_Vector(int start, int end=-1);
/// Read the converted values from buffer and stores them into the given itpp vec container.
/**
* \param destination itpp vec container to write the converted data to type T_IT from the buffer.
* The size of the destination container is adapted automatically to the size of the buffer.
*/
template<typename T_IT> void Read_Convert(itpp::Vec<T_IT>& destination);
/**
* For use with the it++ data type itpp::Vec<T>, see Write()
* \overload void Write(itpp::Vec<T> &input);
*/
void Write(itpp::Vec<T> &input);
/**
* For use with the it++ data type itpp::Vec<T>, see Write_Sub_Vector()
* \overload void Write_Sub_Vector(itpp::Vec<T> &input, int start, int end=-1);
*/
void Write_Sub_Vector(itpp::Vec<T> &input, int start, int end = -1);
/// Write the converted values from the given itpp vec container into the buffer.
/**
* \param source itpp container to read the data, convert them to the buffer type T and write them into the buffer.
* The size of the buffer is adapted automatically to the size of the source container.
*/
template<typename T_IT> void Write_Convert(const itpp::Vec<T_IT>& source);
#endif
/// Overload of << operator
inline friend std::ostream & operator<<(std::ostream & os, Buffer<T,1> & data)
{
if(data.length_ != 0)
{
for(unsigned int i=0; i < data.length_ - 1; i++)
os << data.mem_ptr_[i] << ", ";
// Print last data without comma and whitespace at the end
os << data.mem_ptr_[data.length_ - 1];
}
return os;
}
/// Overload of >> operator
inline friend std::istream & operator>>(std::istream & os, Buffer<T,1> & data)
{
for(unsigned int i = 0; i < data.length_; i++)
os >> data.mem_ptr_[i];
return os;
}
/// Dump the content of the buffer to stdout or a file.
/**
* @param filename If a file name is give, the buffer is written to a file
* @param append = false, file content is overwritten, = true append the date to the file
* @param linebreak = false, values separated by blank, = true values separated by linebreak
*/
void Dump(std::string filename="", bool append=false, bool linebreak=false);
/// Dump the content of the buffer modulo 2^mod_bw to stdout or a file.
/**
* @param filename If a file name is give, the buffer is written to a file
* @param append = false, file content is overwritten, = true append the date to the file
* @param mod_bw All values are dumped modulo 2^mod_bw
* @param separator Values are separated by this string. Default is a blank.
*/
void Dump_Modulo(int mod_bw, std::string filename="", bool append=false, const char* separator=" ");
/// Stream the content of the buffer modulo 2^mod_bw
/**
* @param mod_bw All values are dumped modulo 2^mod_bw
* @param separator Values are separated by this string. Default is a blank.
*/
std::string Stream_Modulo(int mod_bw, const char* separator=" ");
/// Return the number of elements (length) of the buffer
unsigned int length() const {return length_;}
/// Return a Buffer with the current dimensions of the buffer
Buffer<unsigned int, 1> dim()
{
Buffer<unsigned int, 1> ret(1);
ret[0] = length_;
return ret;
}
/// Return the maximum value in the buffer
T Max();
private:
/// Set the buffer values from a string
void Set_From_String(const std::string& input);
void View_Parent_Changed();
/// Name of the current buffer instance
std::string instance_name_;
/// Internal memory allocation function
void Alloc_Mem();
/// Store the length of the current memory
unsigned int length_;
/// Pointer to the memory
T *mem_ptr_;
/// Buffer View of buffer
bool view_;
/// Original view parameter
class View_Parameter
{
public:
unsigned int length_; /// length of the view
unsigned int start_pos_; /// start position of the view
Buffer<T, 1>* parent; /// Pointer to the original buffer object
} view_parameter_;
};
#endif
| [
"chibby0ne@gmail.com"
] | chibby0ne@gmail.com |
2d1f5ac9e3cd721411bcaedb3a8899b26da5b85d | 6c45a2bc233267188bfaff0f2e7c61d910b4edaa | /util/cpp/exception.h | 054e76883e1b0593d535ce00284c688d9fa068e3 | [] | no_license | nextonr/code | b86a88ea4cdb274ff39ed91ec1cad9fa21ba0a1b | c4a717dbfbafb853f8856496594b139f63ff63ef | refs/heads/master | 2021-10-28T13:17:56.292640 | 2019-04-24T01:12:14 | 2019-04-24T01:12:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 544 | h | //
// Created by hujianzhe on 16-5-2.
//
#ifndef UTIL_CPP_EXCEPTION_H
#define UTIL_CPP_EXCEPTION_H
#include "cpp_compiler_define.h"
#include <stdio.h>
#include <exception>
#include <stdexcept>
#define assert_throw(exp)\
if (!(exp)) {\
throw std::logic_error(__FILE__"(" MACRO_TOSTRING(__LINE__) "): " #exp "\r\n");\
}
#define logic_throw(exp, fmt, ...)\
if (!(exp)) {\
char _str[512];\
snprintf(_str, sizeof(_str), __FILE__"(" MACRO_TOSTRING(__LINE__) "): %s\r\n" fmt "\r\n", #exp, ##__VA_ARGS__);\
throw std::logic_error(_str);\
}
#endif
| [
"776095293@qq.com"
] | 776095293@qq.com |
7f66d90e54c63c97886a87606a6d0f129daa65d0 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /third_party/blink/renderer/core/layout/line/line_breaker.cc | c0362d86c75bcb69a7772b2fabb4d444489dd53f | [
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 4,545 | cc | /*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
* All right reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "third_party/blink/renderer/core/layout/line/line_breaker.h"
#include "third_party/blink/renderer/core/layout/line/breaking_context_inline_headers.h"
namespace blink {
void LineBreaker::SkipLeadingWhitespace(InlineBidiResolver& resolver,
LineInfo& line_info,
LineWidth& width) {
while (
!resolver.GetPosition().AtEnd() &&
!RequiresLineBox(resolver.GetPosition(), line_info, kLeadingWhitespace)) {
LineLayoutItem line_layout_item =
resolver.GetPosition().GetLineLayoutItem();
if (line_layout_item.IsOutOfFlowPositioned()) {
SetStaticPositions(block_, LineLayoutBox(line_layout_item),
width.IndentText());
if (line_layout_item.Style()->IsOriginalDisplayInlineType()) {
resolver.Runs().AddRun(
CreateRun(0, 1, LineLayoutItem(line_layout_item), resolver));
line_info.IncrementRunsFromLeadingWhitespace();
}
} else if (line_layout_item.IsFloating()) {
block_.InsertFloatingObject(LineLayoutBox(line_layout_item));
block_.PlaceNewFloats(block_.LogicalHeight(), &width);
}
resolver.GetPosition().Increment(&resolver);
}
resolver.CommitExplicitEmbedding(resolver.Runs());
}
void LineBreaker::Reset() {
positioned_objects_.clear();
hyphenated_ = false;
clear_ = EClear::kNone;
}
InlineIterator LineBreaker::NextLineBreak(InlineBidiResolver& resolver,
LineInfo& line_info,
LayoutTextInfo& layout_text_info,
WordMeasurements& word_measurements) {
Reset();
DCHECK(resolver.GetPosition().Root() == block_);
bool applied_start_width = resolver.GetPosition().Offset() > 0;
bool is_first_formatted_line =
line_info.IsFirstLine() && block_.CanContainFirstFormattedLine();
LineWidth width(
block_, line_info.IsFirstLine(),
RequiresIndent(is_first_formatted_line,
line_info.PreviousLineBrokeCleanly(), block_.StyleRef()));
SkipLeadingWhitespace(resolver, line_info, width);
if (resolver.GetPosition().AtEnd())
return resolver.GetPosition();
BreakingContext context(resolver, line_info, width, layout_text_info,
applied_start_width, block_);
while (context.CurrentItem()) {
context.InitializeForCurrentObject();
if (context.CurrentItem().IsBR()) {
context.HandleBR(clear_);
} else if (context.CurrentItem().IsOutOfFlowPositioned()) {
context.HandleOutOfFlowPositioned(positioned_objects_);
} else if (context.CurrentItem().IsFloating()) {
context.HandleFloat();
} else if (context.CurrentItem().IsLayoutInline()) {
context.HandleEmptyInline();
} else if (context.CurrentItem().IsAtomicInlineLevel()) {
context.HandleReplaced();
} else if (context.CurrentItem().IsText()) {
if (context.HandleText(word_measurements, hyphenated_)) {
// We've hit a hard text line break. Our line break iterator is updated,
// so go ahead and early return.
return context.LineBreak();
}
} else {
NOTREACHED();
}
if (context.AtEnd())
return context.HandleEndOfLine();
context.CommitAndUpdateLineBreakIfNeeded();
if (context.AtEnd())
return context.HandleEndOfLine();
context.Increment();
}
context.ClearLineBreakIfFitsOnLine();
return context.HandleEndOfLine();
}
} // namespace blink
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
0e4d8dea6315ff7fe40e9b94baaf168a79943a8b | 05f580305dd6aaef48afc1ad2bfbb2646015a674 | /expressions/scalar/ScalarSharedExpression.hpp | d5dddbced3255619b3958611e3fd7b4738ed47da | [
"Apache-2.0",
"MIT",
"BSD-3-Clause"
] | permissive | udippant/incubator-quickstep | 637b6d24c5783dab5d38c26ef4b5fb8525c1711c | 8169306c2923d68235ba3c0c8df4c53f5eee9a68 | refs/heads/master | 2021-01-20T00:45:37.576857 | 2017-04-20T20:28:12 | 2017-04-23T19:57:02 | 89,181,659 | 1 | 0 | null | 2017-04-24T00:24:48 | 2017-04-24T00:24:48 | null | UTF-8 | C++ | false | false | 3,943 | hpp | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
#ifndef QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_SHARED_EXPRESSION_HPP_
#define QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_SHARED_EXPRESSION_HPP_
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "catalog/CatalogTypedefs.hpp"
#include "expressions/Expressions.pb.h"
#include "expressions/scalar/Scalar.hpp"
#include "storage/StorageBlockInfo.hpp"
#include "types/TypedValue.hpp"
#include "types/containers/ColumnVector.hpp"
#include "utility/Macros.hpp"
namespace quickstep {
class ColumnVectorCache;
class ValueAccessor;
struct SubBlocksReference;
/** \addtogroup Expressions
* @{
*/
/**
* @brief Scalars that represent common subexpressions whose results are cached
* and shared.
**/
class ScalarSharedExpression : public Scalar {
public:
/**
* @brief Constructor.
*
* @param share_id The unique integer identifier for each equivalence class of
* common subexpressions.
* @param operand The underlying scalar subexpression.
**/
ScalarSharedExpression(const int share_id, Scalar *operand);
/**
* @brief Destructor.
**/
~ScalarSharedExpression() override {
}
serialization::Scalar getProto() const override;
Scalar* clone() const override;
ScalarDataSource getDataSource() const override {
return kSharedExpression;
}
TypedValue getValueForSingleTuple(const ValueAccessor &accessor,
const tuple_id tuple) const override;
TypedValue getValueForJoinedTuples(
const ValueAccessor &left_accessor,
const relation_id left_relation_id,
const tuple_id left_tuple_id,
const ValueAccessor &right_accessor,
const relation_id right_relation_id,
const tuple_id right_tuple_id) const override;
bool hasStaticValue() const override {
return operand_->hasStaticValue();
}
const TypedValue& getStaticValue() const override {
return operand_->getStaticValue();
}
ColumnVectorPtr getAllValues(ValueAccessor *accessor,
const SubBlocksReference *sub_blocks_ref,
ColumnVectorCache *cv_cache) const override;
ColumnVectorPtr getAllValuesForJoin(
const relation_id left_relation_id,
ValueAccessor *left_accessor,
const relation_id right_relation_id,
ValueAccessor *right_accessor,
const std::vector<std::pair<tuple_id, tuple_id>> &joined_tuple_ids,
ColumnVectorCache *cv_cache) const override;
protected:
void getFieldStringItems(
std::vector<std::string> *inline_field_names,
std::vector<std::string> *inline_field_values,
std::vector<std::string> *non_container_child_field_names,
std::vector<const Expression*> *non_container_child_fields,
std::vector<std::string> *container_child_field_names,
std::vector<std::vector<const Expression*>> *container_child_fields) const override;
private:
const int share_id_;
std::unique_ptr<Scalar> operand_;
DISALLOW_COPY_AND_ASSIGN(ScalarSharedExpression);
};
/** @} */
} // namespace quickstep
#endif // QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_SHARED_EXPRESSION_HPP_
| [
"jianqiao@cs.wisc.edu"
] | jianqiao@cs.wisc.edu |
71fafa6c4f603bf6b6da4eb52d7387e2869b399d | 39e0b454c34bd992e6f5b2f3486f9c599e61e046 | /demo/input.cxx | bb2fa0e389765e78129bb1e4f492ab6f3d97cc85 | [] | no_license | sashagoebbels/SpeX | 26c734ad6d7f78654b0b243afc961e55b9b319aa | d542340c15377fe050a475972896170a6c9e7d36 | refs/heads/master | 2022-11-12T05:24:50.270868 | 2017-08-17T19:22:25 | 2017-08-17T19:22:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,963 | cxx | //
// "$Id: input.cxx,v 1.4 1998/11/08 15:05:47 mike Exp $"
//
// Input field test program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@easysw.com".
//
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Secret_Input.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Color_Chooser.H>
void cb(Fl_Widget *ob) {
printf("Callback for %s '%s'\n",ob->label(),((Fl_Input*)ob)->value());
}
int when = 0;
Fl_Input *input[5];
void toggle_cb(Fl_Widget *o, long v) {
if (((Fl_Toggle_Button*)o)->value()) when |= v; else when &= ~v;
for (int i=0; i<5; i++) input[i]->when(when);
}
void test(Fl_Input *i) {
if (i->changed()) {
i->clear_changed(); printf("%s '%s'\n",i->label(),i->value());
}
}
void button_cb(Fl_Widget *,void *) {
for (int i=0; i<5; i++) test(input[i]);
}
void color_cb(Fl_Widget* button, void* v) {
Fl_Color c;
switch ((int)v) {
case 0: c = FL_WHITE; break;
case 1: c = FL_SELECTION_COLOR; break;
default: c = FL_BLACK; break;
}
uchar r,g,b; Fl::get_color(c, r,g,b);
if (fl_color_chooser(0,r,g,b)) {
Fl::set_color(c,r,g,b); Fl::redraw();
button->labelcolor(contrast(FL_BLACK,c));
button->redraw();
}
}
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(400,400);
int y = 10;
input[0] = new Fl_Input(70,y,300,30,"Normal:"); y += 35;
// input[0]->cursor_color(FL_SELECTION_COLOR);
// input[0]->maximum_size(20);
// input[0]->static_value("this is a testgarbage");
input[1] = new Fl_Float_Input(70,y,300,30,"Float:"); y += 35;
input[2] = new Fl_Int_Input(70,y,300,30,"Int:"); y += 35;
input[3] = new Fl_Secret_Input(70,y,300,30,"Secret:"); y += 35;
input[4] = new Fl_Multiline_Input(70,y,300,100,"Multiline:"); y += 105;
for (int i = 0; i < 4; i++) {
input[i]->when(0); input[i]->callback(cb);
}
int y1 = y;
Fl_Button *b;
b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&CHANGED");
b->callback(toggle_cb, FL_WHEN_CHANGED); y += 25;
b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&RELEASE");
b->callback(toggle_cb, FL_WHEN_RELEASE); y += 25;
b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&ENTER_KEY");
b->callback(toggle_cb, FL_WHEN_ENTER_KEY); y += 25;
b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&NOT_CHANGED");
b->callback(toggle_cb, FL_WHEN_NOT_CHANGED); y += 25;
y += 5;
b = new Fl_Button(10,y,200,25,"&print changed()");
b->callback(button_cb);
b = new Fl_Button(220,y1,100,25,"color"); y1 += 25;
b->color(input[0]->color()); b->callback(color_cb, (void*)0);
b = new Fl_Button(220,y1,100,25,"selection_color"); y1 += 25;
b->color(input[0]->selection_color()); b->callback(color_cb, (void*)1);
b = new Fl_Button(220,y1,100,25,"textcolor"); y1 += 25;
b->color(input[0]->textcolor()); b->callback(color_cb, (void*)2);
b->labelcolor(contrast(FL_BLACK,b->color()));
window->end();
window->show(argc,argv);
return Fl::run();
}
//
// End of "$Id: input.cxx,v 1.4 1998/11/08 15:05:47 mike Exp $".
//
| [
"vmg@arachnion.de"
] | vmg@arachnion.de |
468ee2847bbf416e9394ea8bdc974dd77e1056bc | 329e9d7fef75150f01d3faf355dd1f7c33e5f994 | /BouncingBallOpenGL/BouncingBall/src/GameplayState.cpp | 1181e01164e97679505fee3abfadc84336bfda54 | [
"MIT"
] | permissive | 09pawel0898/BouncingBall | 6c138c2f56d74d1fd6f4c76975b9a7b0b5481730 | dc3b7a6e73d838d03c60d315d833c90707007105 | refs/heads/master | 2023-08-16T03:54:53.124551 | 2021-09-30T21:07:47 | 2021-09-30T21:07:47 | 409,669,094 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,018 | cpp | #include "GameplayState.h"
#include "Utility.h"
GameplayState::GameplayState(En::States::StateManager& stateManager, Context context)
: State(stateManager, context),
m_FrameCounter(0),
m_LastJumpFrame(0)
{
InitTextures();
InitSprites();
InitBall();
}
void GameplayState::OnRender(void) const
{
En::Renderer::Draw(m_Background);
En::Renderer::Draw(m_Ball);
En::Renderer::Draw(m_BackButton);
}
bool GameplayState::OnUpdate(double deltaTime)
{
if (IsButtonCovered<ButtonType::Round>(m_BackButton, 30))
m_BackButton.SetScale(0.64f);
else
m_BackButton.SetScale(0.55f);
if (m_Ball.m_IsJumping && (m_LastJumpFrame == m_FrameCounter - 30))
m_Ball.m_IsJumping = false;
//this->jc = std::to_string(this->ball.jump_counter);
/*
if (this->jc.size() == 1)
this->shift = 25;
else if (this->jc.size() > 1)
{
if (this->jc.size() == 2)
this->shift = 47;
else this->shift = 69;
}
*/
if (m_Ball.GetPosition().y - 1000 > App->GetWindow()->GetHeight())
{
m_GameLost = true;
App->GetStateManager()->PushState("GameLost");
}
/*
this->COUNTER.setPosition(this->window->getSize().x / 2.0f - this->shift, 138);
this->COUNTER.setString(this->jc);
*/
static RectangleShape leftWall{ {0,0}, {2,600} };
static RectangleShape rightWall{ {448,0}, {2,600} };
m_Ball.Update(leftWall, rightWall);
m_FrameCounter++;
return true;
}
bool GameplayState::OnEvent(En::Event& event)
{
En::EventDispatcher dispatcher(event);
dispatcher.Dipatch<En::MouseButtonPressedEvent>(BIND_EVENT_FN(GameplayState::OnMouseButtonPressed));
return true;
}
void GameplayState::OnAwake(void)
{
m_GameLost = false;
m_Ball.Reset();
}
bool GameplayState::OnMouseButtonPressed(En::MouseButtonPressedEvent& event)
{
if (m_Ball.IsBallClicked())
{
if (!m_Ball.m_IsJumping)
{
m_Ball.m_JumpCounter++;
m_Ball.Jump();
m_LastJumpFrame = m_FrameCounter;
m_Ball.m_IsJumping = true;
return true;
}
}
if (IsButtonCovered<ButtonType::Round>(m_BackButton, 48))
GoToMainMenu();
return true;
}
void GameplayState::InitTextures(void)
{
const auto& texManager = App->GetTextureManager();
texManager->LoadResource("ball", "res/textures/ball.png");
texManager->LoadResource("backButton", "res/textures/buttonback.png");
//texManager->LoadResource("tile", "res/textures/tile.png");
//texManager->LoadResource("ballicon", "res/textures/ballicon.png");
}
void GameplayState::InitSprites(void)
{
const auto& texManager = App->GetTextureManager();
m_Background.SetTexture(texManager->GetResource("background"));
m_BackButton.SetTexture(texManager->GetResource("backButton"));
m_BackButton.SetOrigin({48,48});
m_BackButton.SetScale(0.6f);
m_BackButton.SetPosition({400,50});
}
void GameplayState::InitBall(void)
{
const auto& texManager = App->GetTextureManager();
m_Ball.SetTexture(texManager->GetResource("ball"));
m_Ball.SetPosition({App->GetWindow()->GetWidth() /2,150});
m_Ball.SetOrigin({ 43,43 });
}
void GameplayState::GoToMainMenu(void)
{
App->GetStateManager()->PopState();
} | [
"pawel_2014@interia.eu"
] | pawel_2014@interia.eu |
ccd4f1658b43c6a8cfd4d3b6164559ddaed19b33 | d05383f9f471b4e0691a7735aa1ca50654704c8b | /CPP2MIssues/SampleClass678.cpp | fca93b7a7beb1690cc1bec5e5d6d66e4ff62e715 | [] | no_license | KetkiT/CPP2MIssues | d2186a78beeb36312cc1a756a005d08043e27246 | 82664377d0f0047d84e6c47e9380d1bafa840d19 | refs/heads/master | 2021-08-26T07:27:00.804769 | 2017-11-22T07:29:45 | 2017-11-22T07:29:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 50,048 | cpp | class SampleClass678{
public:
void m1() {
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
int *ptr = new int (10);
}
}; | [
"ketki.thosar@acellere.com"
] | ketki.thosar@acellere.com |
fd104c2c78a87aa33f47dbbc64d380084bfcf507 | 785df77400157c058a934069298568e47950e40b | /TnbHydrostatic/TnbLib/Hydrostatic/Entities/Functions/rArm/HydStatic_StbFun_rArm.cxx | 065b8133fe137c103510a9475dd117fce590a94b | [] | no_license | amir5200fx/Tonb | cb108de09bf59c5c7e139435e0be008a888d99d5 | ed679923dc4b2e69b12ffe621fc5a6c8e3652465 | refs/heads/master | 2023-08-31T08:59:00.366903 | 2023-08-31T07:42:24 | 2023-08-31T07:42:24 | 230,028,961 | 9 | 3 | null | 2023-07-20T16:53:31 | 2019-12-25T02:29:32 | C++ | UTF-8 | C++ | false | false | 515 | cxx | #include <HydStatic_StbFun_rArm.hxx>
#include <HydStatic_rArmCurve.hxx>
#include <TnbError.hxx>
#include <OSstream.hxx>
Standard_Real
tnbLib::hydStcLib::StbFun_rArm::MinHeel() const
{
Debug_Null_Pointer(Arm());
return Arm()->MinHeel();
}
Standard_Real
tnbLib::hydStcLib::StbFun_rArm::MaxHeel() const
{
Debug_Null_Pointer(Arm());
return Arm()->MaxHeel();
}
Standard_Real
tnbLib::hydStcLib::StbFun_rArm::Value
(
const Standard_Real thePhi
) const
{
Debug_Null_Pointer(Arm());
return Arm()->Value(thePhi);
} | [
"aasoleimani86@gmail.com"
] | aasoleimani86@gmail.com |
3409e97e3aa0cc58fb40e02e0f697b619fd3baa5 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_new_log_2930.cpp | 311f467a108ed4623a3d07973a3f99a4d21ea6aa | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 46 | cpp | error_errno("error while reading from stdin"); | [
"993273596@qq.com"
] | 993273596@qq.com |
a3dba22f54bcc80a4cccfb1e45576f021ebaa069 | 5d309f75555c9fa49cd1bb0f953c6ee73d711fe6 | /garnet/bin/zxdb/symbols/function.h | 3ea0485a1fbac1a243eb14eac685a3a2b743cf75 | [
"BSD-3-Clause"
] | permissive | the-locksmith/fuchsia | d2d0b7d6e011a1468cb299441494be2c9c5cae0a | 2620709744ff49fe289169a8af63f8499239333b | refs/heads/master | 2021-10-21T10:55:16.114376 | 2019-02-28T22:37:39 | 2019-03-04T00:05:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,063 | h | // Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include <string>
#include "garnet/bin/zxdb/symbols/code_block.h"
#include "garnet/bin/zxdb/symbols/file_line.h"
#include "garnet/bin/zxdb/symbols/variable_location.h"
namespace zxdb {
// Represents a function (a "subprogram" in DWARF parlance). This is different
// than a "FunctionType" which is the type used to represent function pointers.
//
// Some functions in DWARF are "implementations" that have code ranges
// associated with them, and some are "specifications" (akin to C forward
// declarations) that don't. The context about the namespaces and parent
// classes comes from the specification, while the implementation of the
// function may be outside of any namespace or class definitions.
//
// It seems Clang puts the function parameters in both places, some attributes
// like DW_AT_frame_base will only be on the implementation, and others like
// DW_AT_decl_file/line, DW_AT_accessibility, and the return type (DW_AT_type)
// are only on the specification.
//
// In the case of an implementation, the decoder will attempt to fill in the
// attributes from the specification automatically so this Function object
// will have full context. Be aware that this won't necessarily match the
// DIE that generated the object.
//
// NAMING: The "full name" (as returned by Symbol::GetFullName()) of a function
// is the qualified name without any return types or parameters. Some callers
// may want parameters, we can add a helper function in the future if necessary
// (for display we would often want to syntax highlight these differently so
// this is often betetr done at a a different layer).
class Function final : public CodeBlock {
public:
// Construct with fxl::MakeRefCounted().
// Symbol overrides.
const Function* AsFunction() const override;
const std::string& GetAssignedName() const final { return assigned_name_; }
// Returns true if this function is an inlined function instance.
bool is_inline() const { return tag() == Symbol::kTagInlinedSubroutine; }
// The containing block is the CodeBlock that contains an inlined function.
// This will be null for non-inlined functions.
//
// For inlined functions, Symbol::parent() will contain the lexical parent of
// the inlined function (a class or namespace) while the containing block
// will be the CodeBlock (of any type) that the code is inlined into.
const LazySymbol& containing_block() const { return containing_block_; }
void set_containing_block(LazySymbol c) { containing_block_ = std::move(c); }
// Unmangled name. Does not include any class or namespace qualifications.
// (see Symbol::GetAssignedName)
void set_assigned_name(std::string n) { assigned_name_ = std::move(n); }
// Mangled name.
const std::string& linkage_name() const { return linkage_name_; }
void set_linkage_name(std::string n) { linkage_name_ = std::move(n); }
// The location in the source code of the declaration. May be empty.
const FileLine& decl_line() const { return decl_line_; }
void set_decl_line(FileLine decl) { decl_line_ = std::move(decl); }
// For inline functions, this can be set to indicate the call location.
const FileLine& call_line() const { return call_line_; }
void set_call_line(FileLine call) { call_line_ = std::move(call); }
// The return value type. This should be some kind of Type object. Will be
// empty for void return types.
const LazySymbol& return_type() const { return return_type_; }
void set_return_type(const LazySymbol& rt) { return_type_ = rt; }
// Parameters passed to the function. These should be Variable objects.
const std::vector<LazySymbol>& parameters() const { return parameters_; }
void set_parameters(std::vector<LazySymbol> p) { parameters_ = std::move(p); }
// The frame base is the location where "fbreg" expressions are evaluated
// relative to (this will be most local variables in a function). This can
// be an empty location if there's no frame base or it's not needed (e.g.
// for inline functions).
//
// When compiled with full stack frames, this will usually evaluate to the
// contents of the CPU's "BP" register, but can be different or arbitrarily
// complicated, especially when things are optimized.
const VariableLocation& frame_base() const { return frame_base_; }
void set_frame_base(VariableLocation base) { frame_base_ = std::move(base); }
// The object pointer is the "this" object for the current function.
// Quick summary: Use GetObjectPointerVariable() to retrieve "this".
//
// The object_pointer() will be a reference to a parameter (object type
// Variable). It should theoretically match one of the entries in the
// parameters() list but we can't guarantee what the compiler has generated.
// The variable will be the implicit object ("this") pointer for member
// functions. For nonmember or static member functions the object pointer
// will be null.
//
// For inlined functions the location on the object_pointer variable may be
// wrong. Typically an inlined subroutine consists of two entries:
//
// Shared entry for all inlined instances:
// (1) DW_TAG_subprogram "InlinedFunc"
// DW_AT_object_pointer = reference to (2)
// (2) DW_TAG_formal_parameter "this"
// <info on the parameter>
//
// Specific inlined function instance:
// (3) DW_TAG_inlined_subroutine "InlinedFunc"
// DW_AT_abstract_origin = reference to (1)
// (4) DW_TAG_formal_parameter "this"
// DW_AT_abstract_origin = reference to (2)
// <info on parameter, possibly different than (2)>
//
// Looking at the object pointer will give the variable on the abstract
// origin, while the inlined subroutine will have its own declaration for
// "this" which will have a location specific to this inlined instantiation.
//
// The GetObjectPointerVariable() function handles this case and returns the
// correct resulting variable. It will return null if there is no object
// pointer.
const LazySymbol& object_pointer() const { return object_pointer_; }
void set_object_pointer(const LazySymbol& op) { object_pointer_ = op; }
const Variable* GetObjectPointerVariable() const;
private:
FRIEND_REF_COUNTED_THREAD_SAFE(Function);
FRIEND_MAKE_REF_COUNTED(Function);
// The tag must be either "subprogram" or "inlined subroutine" according to
// whether or not this is an inlined function.
explicit Function(int tag);
~Function();
// Symbol protected overrides.
std::string ComputeFullName() const override;
LazySymbol containing_block_;
std::string assigned_name_;
std::string linkage_name_;
FileLine decl_line_;
FileLine call_line_;
LazySymbol return_type_;
std::vector<LazySymbol> parameters_;
VariableLocation frame_base_;
LazySymbol object_pointer_;
};
} // namespace zxdb
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
e16e51f28d5876255b968ed719cccf955f5c74a6 | eb95af611f23b7cc6311035de44475bdcaecc2c5 | /cf/999/c1.cpp | 6b74ec8b84c91b9461f75d9ff2d798abafc11777 | [] | no_license | biswanaths/competition | a0f0dc1781a9cf5354f9c26932015bf1d22c8992 | 1a46f12be90c5b6866a9347bb79dc91a240b5b48 | refs/heads/master | 2023-03-07T11:56:55.485722 | 2023-02-24T09:05:44 | 2023-02-24T09:05:44 | 31,366,626 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,369 | cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define lld long long int
#define EOL '\0'
#define PEL cout<<endl;
#define N 100002
#define rep(n) for(int i =0;(i)<(int)(n);(i)++)
#define repij(n,m) for(int i =0;(i)<(int)(n);(i)++) for(int j =0;(j)<(int)(m);(j)++)
#define SSTR( x ) dynamic_cast< std::ostringstream & >( \
std::ostringstream() << std::dec << x ).str()
#define For(iterable) for(__typeof__((iterable).begin()) it = (iterable).begin(); it != (iterable).end(); ++it)
int main()
{
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("test.in", "r",stdin);
//freopen("test.out", "w",stdout);
#endif
int n,k; string s;
cin>>n>>k>>s;
vector<pair<char,int> > c(n);
rep(n) c[i] = make_pair(s[i],i);
sort(c.begin(), c.end());
sort(c.begin()+k, c.end(), [&] (const pair<char, int> &a, const pair<char, int> &b) {
return a.second < b. second; });
for(int i=k;i<n;i++) cout<<c[i].first;
return 0;
}
| [
"biswanaths@gmail.com"
] | biswanaths@gmail.com |
b400c02b21759270f8bde3fa1505c960d65042b6 | a193f7b36932acfc1c9d151f9268c232bacd7c87 | /dsp-checking/src/util/ieee_float.h | 251f42febabbce9a21e6d286aac7e61637da020e | [
"BSD-2-Clause"
] | permissive | ashokkelur/CBMC-With-DSP-C | c21dbfacf956b77b8ea5a381e15b292128713b52 | 1de07c526bfe67e265c39126de1dfe3e419b50a4 | refs/heads/master | 2021-01-23T14:04:10.599920 | 2013-09-14T09:21:47 | 2013-09-14T09:21:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,063 | h | /*******************************************************************\
Module:
Author: Daniel Kroening, kroening@kroening.com
\*******************************************************************/
#ifndef CPROVER_IEEE_FLOAT_H
#define CPROVER_IEEE_FLOAT_H
#include <ostream>
#include <mp_arith.h>
#include <format_spec.h>
class exprt;
class floatbv_typet;
class ieee_float_spect
{
public:
// Bits for fraction (excluding hidden bit) and exponent,
// respectively
unsigned f, e;
mp_integer bias() const;
ieee_float_spect(const floatbv_typet &type)
{
from_type(type);
}
void from_type(const floatbv_typet &type);
ieee_float_spect():f(0), e(0)
{
}
ieee_float_spect(unsigned _f, unsigned _e):f(_f), e(_e)
{
}
inline unsigned width() const
{
// add one for the sign bit
return f+e+1;
}
mp_integer max_exponent() const;
mp_integer max_fraction() const;
class floatbv_typet to_type() const;
// the well-know standard formats
inline static ieee_float_spect single_precision()
{
return ieee_float_spect(23, 8);
}
inline static ieee_float_spect double_precision()
{
return ieee_float_spect(52, 11);
}
};
class ieee_floatt
{
public:
// ROUND_TO_EVEN is also known as "round to nearest, ties to even", and
// is the IEEE default
typedef enum {
ROUND_TO_EVEN, ROUND_TO_ZERO, ROUND_TO_PLUS_INF, ROUND_TO_MINUS_INF,
UNKNOWN, NONDETERMINISTIC }
rounding_modet;
rounding_modet rounding_mode;
ieee_float_spect spec;
ieee_floatt(const ieee_float_spect &_spec):
rounding_mode(ROUND_TO_EVEN),
spec(_spec), sign(false), exponent(0), fraction(0),
NaN(false), infinity(false)
{
}
ieee_floatt():
rounding_mode(ROUND_TO_EVEN),
sign(false), exponent(0), fraction(0),
NaN(false), infinity(false)
{
}
ieee_floatt(const exprt &expr):
rounding_mode(ROUND_TO_EVEN)
{
from_expr(expr);
}
void negate()
{
sign=!sign;
}
void set_sign(bool _sign)
{ sign = _sign; }
void make_zero()
{
sign=false;
exponent=0;
fraction=0;
NaN=false;
infinity = false;
}
void make_NaN();
void make_plus_infinity();
void make_minus_infinity();
void make_fltmax();
void make_fltmin();
// set to next representable number towards plus or minus infinity
void increment(bool distinguish_zero=false)
{
if(is_zero() && get_sign() && distinguish_zero)
negate();
else
next_representable(true);
}
void decrement(bool distinguish_zero=false)
{
if(is_zero() && !get_sign() && distinguish_zero)
negate();
else
next_representable(false);
}
bool is_zero() const { return !NaN && !infinity && fraction==0 && exponent==0; }
bool get_sign() const { return sign; }
bool is_NaN() const { return NaN; }
bool is_infinity() const { return !NaN && infinity; }
const mp_integer &get_exponent() const { return exponent; }
const mp_integer &get_fraction() const { return fraction; }
// performs conversion to ieee floating point format
void from_integer(const mp_integer &i);
void from_base10(const mp_integer &exp, const mp_integer &frac);
void build(const mp_integer &exp, const mp_integer &frac);
void unpack(const mp_integer &i);
void from_double(const double d);
void from_float(const float f);
// perfroms conversions from ieee float-point format
// to something else
double to_double() const;
float to_float() const;
bool is_double() const;
bool is_float() const;
mp_integer pack() const;
void extract(mp_integer &_exponent, mp_integer &_fraction) const;
mp_integer to_integer() const; // this rounds to zero
// conversions
void change_spec(const ieee_float_spect &dest_spec);
// output
void print(std::ostream &out) const;
std::string to_ansi_c_string() const
{
return format(format_spect());
}
std::string format(const format_spect &format_spec) const;
friend inline std::ostream& operator << (std::ostream &out, const ieee_floatt &f)
{
return out << f.to_ansi_c_string();
}
// expressions
exprt to_expr() const;
void from_expr(const exprt &expr);
// the usual opertors
ieee_floatt &operator /= (const ieee_floatt &other);
ieee_floatt &operator *= (const ieee_floatt &other);
ieee_floatt &operator += (const ieee_floatt &other);
ieee_floatt &operator -= (const ieee_floatt &other);
friend bool operator < (const ieee_floatt &a, const ieee_floatt &b);
friend bool operator <=(const ieee_floatt &a, const ieee_floatt &b);
friend bool operator > (const ieee_floatt &a, const ieee_floatt &b);
friend bool operator >=(const ieee_floatt &a, const ieee_floatt &b);
// warning: these do packed equality, not IEEE equality
// e.g., NAN==NAN
friend bool operator ==(const ieee_floatt &a, const ieee_floatt &b);
friend bool operator !=(const ieee_floatt &a, const ieee_floatt &b);
friend bool operator ==(const ieee_floatt &a, int i);
// these do IEEE equality, i.e., NAN!=NAN
friend bool ieee_equal(const ieee_floatt &a, const ieee_floatt &b);
friend bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b);
protected:
void divide_and_round(mp_integer &fraction, const mp_integer &factor);
void align();
void next_representable(bool greater);
// we store the number unpacked
bool sign;
mp_integer exponent; // this is unbiased
mp_integer fraction; // this _does_ include the hidden bit
bool NaN, infinity;
};
bool operator < (const ieee_floatt &a, const ieee_floatt &b);
bool operator <=(const ieee_floatt &a, const ieee_floatt &b);
bool operator > (const ieee_floatt &a, const ieee_floatt &b);
bool operator >=(const ieee_floatt &a, const ieee_floatt &b);
bool operator ==(const ieee_floatt &a, const ieee_floatt &b);
bool operator !=(const ieee_floatt &a, const ieee_floatt &b);
std::ostream& operator << (std::ostream &, const ieee_floatt &);
bool ieee_equal(const ieee_floatt &a, const ieee_floatt &b);
bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b);
#endif
| [
"ashoksarf@gmail.com"
] | ashoksarf@gmail.com |
d839acface5b079f6f17b2ac28d4d8d7dd7cf18c | e17c7cf738ee8c59789e9bef6aca875715545912 | /tests/commoninjectiondll.cpp | 6a59bbfc27384e8c4242030e048a9709f0fa4041 | [] | no_license | KDE/libkcw | e279b1336b2228716853e3bc9465a1424adacd75 | 810b71cc946d7fa0625d481d4245cfb6d3f2a04c | refs/heads/master | 2016-09-08T01:32:43.445800 | 2014-01-17T21:07:48 | 2014-01-17T21:08:45 | 42,731,774 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,942 | cpp | /* Copyright 2013-2014 Patrick Spendrin <ps_ml@gmx.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 "kcwsharedmemory.h"
#include "kcwdebug.h"
#include <windows.h>
extern "C" __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpvReserved */ ) {
switch(dwReason) {
case DLL_PROCESS_ATTACH:
{
KcwSharedMemory<int> shmem(L"injectortest", 1, false);
KcwSharedMemory<WCHAR> shmemvar(L"injectortestvar", 9, false);
*shmem += 1;
memcpy(shmemvar.data(), _wgetenv(L"MYTEST"), 9 * sizeof(WCHAR));
break;
}
case DLL_PROCESS_DETACH:
{
break;
}
};
return TRUE;
}
| [
"ps_ml@gmx.de"
] | ps_ml@gmx.de |
7edf3839297c5216f0d6a2b593b7417e34a5c84e | d2566520060aa4e0dc9ee53cca3cfe8b0bc09cb9 | /src/IO/STLTxtMeshReader.hpp | 9e2b4a8c7be5ab2903be251b120a907ed095f482 | [
"BSD-2-Clause"
] | permissive | supermangithu/quinoa | f4a452de8ff1011a89dec1365a32730299ceecc1 | 2dd7ead9592b43a06fa25fec2f7fa7687f6169bf | refs/heads/master | 2023-04-13T14:42:02.394865 | 2020-09-12T13:35:33 | 2020-09-12T13:35:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,455 | hpp | // *****************************************************************************
/*!
\file src/IO/STLTxtMeshReader.hpp
\copyright 2012-2015 J. Bakosi,
2016-2018 Los Alamos National Security, LLC.,
2019-2020 Triad National Security, LLC.
All rights reserved. See the LICENSE file for details.
\brief ASCII STL (STereoLithography) reader class declaration
\details ASCII STL (STereoLithographu) reader class declaration.
*/
// *****************************************************************************
#ifndef STLTxtMeshReader_h
#define STLTxtMeshReader_h
#include <iostream>
#include <stddef.h>
#include <string>
#include "Types.hpp"
#include "Reader.hpp"
#include "Exception.hpp"
namespace tk {
class STLMesh;
//! \brief STLTxtMeshReader : tk::Reader
//! \details Mesh reader class facilitating reading a mesh from a file in
//! ASCII STL format.
class STLTxtMeshReader : public Reader {
public:
//! Constructor
explicit STLTxtMeshReader( const std::string& filename, STLMesh& mesh );
//! Read ASCII STL mesh
void readMesh();
private:
//! \brief ASCII STL keyword with operator>> redefined to do error checking
//! without contaminating client-code
struct STLKeyword {
std::string read; //!< Keyword read in from input
const std::string correct; //!< Keyword that should be read in
//! Initializer constructor
explicit STLKeyword( const std::string& corr ) noexcept :
read(), correct(corr) {}
//! Operator >> for reading a keyword and hande error
friend std::ifstream& operator>> (std::ifstream& is, STLKeyword& kw) {
is >> kw.read;
ErrChk( kw.read == kw.correct,
"Corruption in ASCII STL file while parsing keyword '" +
kw.read + "', should be '" + kw.correct + "'" );
return is;
}
};
//! Read (or count vertices in) ASCII STL mesh
std::size_t readFacets( const bool store,
tk::real* const x = nullptr,
tk::real* const y = nullptr,
tk::real* const z = nullptr );
const bool STORE = true; //!< Indicator to store facets
const bool COUNT = false; //!< Indicator to only count facets
STLMesh& m_mesh; //!< Mesh
};
} // tk::
#endif // STLTxtMeshReader_h
| [
"jbakosi@lanl.gov"
] | jbakosi@lanl.gov |
32730fd65a04eae568300105327e0c9b6c89cf97 | 60c9d985436e81a18e5b4b1332f14212312f6e7a | /edbee-data/code/cpp/b_qabstractgraphicsshapeitem_w.hpp | bf7dfe071a463330c81f5a67d88c706ddb36cce9 | [] | no_license | visualambda/simpleIDE | 53b69e47de6e4f9ad333ae9d00d3bfb3a571048c | 37e3395c5fffa2cf1ca74652382461eadaffa9aa | refs/heads/master | 2020-03-23T07:22:19.938662 | 2018-08-16T03:43:26 | 2018-08-16T03:43:26 | 141,267,532 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 272 | hpp | ////////// GENERATED FILE, EDITS WILL BE LOST //////////
#ifndef HOPPY_MODULE_qtah_qabstractgraphicsshapeitemwrap
#define HOPPY_MODULE_qtah_qabstractgraphicsshapeitemwrap
extern "C" {
} // extern "C"
#endif // ifndef HOPPY_MODULE_qtah_qabstractgraphicsshapeitemwrap
| [
"jellyzone@gmail.com"
] | jellyzone@gmail.com |
3e7931e856c7c3989c04f129a97136297956f655 | ad747031d023eae994c3411b734cbc0afbc766d3 | /BASE_X_BASE_Y.cpp | a1a991c3853ee00171193dc59d0b7e189e6a588a | [] | no_license | SourabhMaheshP/ConnectProgram2020 | 8bdb56b4bbace0219b1debf23ad2121666834a61 | 07c4dc10f7a4eb9821518f711b3c88b5e1e99e75 | refs/heads/master | 2020-12-12T01:19:42.070007 | 2020-01-26T07:24:15 | 2020-01-26T07:24:15 | 234,007,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,490 | cpp | //compiler used : g++ compiler
//Sourabh Mahesh Pankhawala
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
//Constraint:
// BaseX <= Base36
// BaseY <= Base36
//this function is used for computation and printing values to the console.
//this function is recursive.
//Example if input: 26 Base_x = 10 Base_y = 16 then ordinary computation gives output as: "A1"
//but this function outputs require "actual" output as reverse: "1A"
void compute(int num, int y, int res)
{
if (num == 0 && res == 0)
return;
compute(num / y, y, num % y);
if (res >= 0 && res <= 9)
cout << res << " ";
else if (res >= 10 && res <= 36)
cout << (char)(res + 55) << " ";
}
//function for conversion
void conversion(string str, int x, int y)
{
int i=0,num = 0, res = -1,j=0;
//1. string to integer 2. change any base x to Decimal
for (i = str.length()-1,j=0 ; i >= 0 ; --i,++j)
{
if (str[i] >= '0' && str[i] <= '9')
num += (pow(x, j) * (str[i] - '0'));
else if (str[i] >= 'A' && str[i] <= 'Z')
num += (pow(x, j) * (str[i] - 55));
}
//3. Decimal to Base Y
if (y != 10) //because num is decimal
compute(num, y, res);
else
cout << num << endl;
}
//This function will check if the given inputs are valid for conversion.
int validate(string str, int x)
{
for (int i = 0; str[i]; i++)
{
if ((str[i] >= '0' && str[i] <= '9'))
{
if ((str[i] - '0') >= x)
return true;
}
else if (str[i] >= 'A' && str[i] <= 'Z')
if ((str[i] - 55) >= x)
return true;
}
return false;
}
//Driver Code
int main()
{
string number;
int base_x, base_y;
//Required inputs
cout << "Enter Number " << endl;
getline(cin, number);
do {
cout << "Enter Base X:" << endl;
cin >> base_x;
if (validate(number, base_x))
cout << "Incorrect Base X!!!" << endl;
} while (validate(number, base_x) || base_x < 2);
do {
cout << "Enter Base Y:" << endl;
cin >> base_y;
if (base_y < 2)
cout << "Incorrect Base Y!!" << endl;
} while (base_y < 2);
//This function will convert a given input to any base
conversion(number,base_x,base_y);
//to hault the command prompt for a character input.
cin.ignore();
cin.get();
return 0;
}
//Code snippet for conversion to Binary (using bitwise operator)- for optimization purpose.
/*for (i = 7; i >= 0; --i)
((num >> i) & 1) ? cout << "1" : cout << "0";
*/
| [
"noreply@github.com"
] | SourabhMaheshP.noreply@github.com |
1b70c37250a73c91ce70de2ae0dfed2b4b7817a2 | 48a8a4fc4954111becec90f8fa05ac55d065526c | /HDU_2011多项式求和.cpp | f508b386237a55534150fa053894c43c8ce223f9 | [] | no_license | vanishblue/OJ | 9dc4ed397e1aaa7c769991e9a966299ee2d9468a | 8ec972c7bdb7c5850aab10dbb3a70fc94213495d | refs/heads/master | 2020-04-24T09:11:44.193865 | 2019-03-10T08:06:06 | 2019-03-10T08:06:06 | 171,855,348 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 356 | cpp | #include <iostream>
#include <iomanip>
#include <cmath>
using namespace std ;
int main()
{
int m, n, i, j ;
cin>>m ;
for (i=0; i<m; i++)
{
double sum=1 ;
cin>>n ;
for (j=2; j<=n; j++)
{
if (j%2 == 0)
sum -= double(1)/double(j) ;
else
sum += double(1)/double(j) ;
}
cout<<fixed<<setprecision(2)<<sum<<endl ;
}
return 0 ;
}
| [
"904644710@qq.com"
] | 904644710@qq.com |
736b1fe77342c9f83b3df438af513e6828c09ce6 | 09b7d2f60e3d710f9590dcc283ac0d94bea0938b | /modplayer.cpp | ba4d2b3c679b08757c77552c8461fa00bb6ba317 | [] | no_license | metanas/Champions | fde617280bf59961b7a6acd102c34ebff0a153b1 | 6ac49e9c9f473adda157c9d6e9f13508b2625024 | refs/heads/master | 2020-04-03T14:04:56.514671 | 2017-07-14T16:38:34 | 2017-07-14T16:38:34 | 95,134,976 | 0 | 1 | null | 2017-07-14T16:38:35 | 2017-06-22T16:24:16 | C++ | UTF-8 | C++ | false | false | 2,718 | cpp | #include "modplayer.h"
#include "ui_modplayer.h"
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlQueryModel>
#include <QDebug>
#include <QModelIndex>
extern QSqlDatabase db;
modplayer::modplayer(QWidget *parent) :
QDialog(parent),
ui(new Ui::modplayer)
{
ui->setupUi(this);
}
modplayer::~modplayer()
{
hide();
}
void modplayer::on_pushButton_clicked()
{
hide();
}
void modplayer::on_pushButton_2_clicked()
{
QSqlQueryModel *modal = new QSqlQueryModel();
QSqlQuery req;
if (!ui->Equipe->text().isEmpty())
req.prepare("SELECT * FROM Joueur where Equipe='" + ui->Equipe->text() +"'");
else if (!ui->Nom->text().isEmpty())
req.prepare("SELECT * FROM Joueur where Nom='" + ui->Nom->text() + "'");
else if (!ui->Prenom->text().isEmpty())
req.prepare("SELECT * FROM Joueur where Prenom='" + ui->Prenom->text()+ "'");
else if (!ui->Num->text().isEmpty())
req.prepare("SELECT * FROM Joueur where Numero='" + ui->Num->text() + "'");
else if (!ui->dateEdit->text().isEmpty())
req.prepare("SELECT * FROM Joueur where Date_de_naissance='" + ui->dateEdit->text() + "'");
else if (!ui->Nast->text().isEmpty())
req.prepare("SELECT * FROM Joueur where nationalite='" + ui->Nast->text() + "'");
else if (!ui->Poste->currentText().isEmpty())
req.prepare("SELECT * FROM Joueur where Poste='" + ui->Poste->currentText() + "'");
req.exec();
modal->setQuery(req);
ui->tableView->setModel(modal);
}
void modplayer::on_tableView_clicked(const QModelIndex &index)
{
QSqlQuery req;
if (index.column() == 0){
req.prepare("SELECT * FROM Joueur where Nom='" + index.data().toString() + "'");
}
req.exec();
req.next();
ui->Nom->setText(req.value(0).toString());
ui->Prenom->setText(req.value(1).toString());
ui->Num->setValue(req.value(2).toInt());
ui->dateEdit->setDate(req.value(3).toDate());
ui->Equipe->setText(req.value(4).toString());
QString post = req.value(5).toString();
int indx = ui->Poste->findText(post);
ui->Poste->setCurrentIndex(indx);
ui->Nast->setText(req.value(6).toString());
Player = req.value(0).toString();
}
void modplayer::on_pushButton_3_clicked()
{
QSqlQuery req;
req.prepare("Update Joueur set Nom='" +ui->Nom->text() + "', Prenom='" + ui->Prenom->text() + "', Numero=" + ui->Num->text() + ", Date_de_naissance='" + ui->dateEdit->text() + "', Equipe='" + ui->Equipe->text() + "', Poste='" +ui->Poste->currentText() + "', Nationalite='" + ui->Nast->text() + "' where Nom='" + Player + "'");
req.exec();
}
| [
"metanas@pre-history.com"
] | metanas@pre-history.com |
560af4df8881ed1d0fa8bbe5bcd89a028f242f46 | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /scrape/data/Tokitsukaze and Discard Items/z7z_Eta_TLE.cpp | c945a26c8713e770a9c572c9acc0a09ea6ceb1a6 | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 944 | cpp | // SeptEtavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define re register
#define ll long long
#define il inline
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(ch) putchar(ch)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%I64d",x)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
// c_ints
il ll ci(){
re char ch;
while(isspace(ch=getchar()));
re ll x= ch^'0';
while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
return x;
}
enum{M=100023};
ll a[M];
int main(){
ci();
ll m= ci(), k= ci();
rep(i,1,m) a[i]= ci();
ll end= k, cnt= 0, p= 1;
ll move;
while( p<=m ){
move= 0;
while( p<=m && a[p]<=end ){
move++;
p++;
}
if( move ) cnt++, end+=move;
else end+=k;
}
ptll(cnt);
return 0;
}
/*
10 7 3
1 2 4 5 7 9 10
*/ | [
"harshitagar1907@gmail.com"
] | harshitagar1907@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.