blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
sequencelengths
1
1
author
stringlengths
0
119
9bd70c24d67b90e653467a6f72d5a3a7b0c226e6
651570891f9a418440f2611f3773e2498c6ce3be
/TRAC-IK package/baxter_sim_kinematics/src/arm_kinematics.cpp
6d13e7a0e60bbde7799b9220da56f008ef8b9d98
[]
no_license
MartinFk/ReMa
aa22bb32f0d5e47b7e812a01ae407ad5444ec6ea
2233e53994952ac36bbab766834f817c26d3bdf6
refs/heads/master
2021-05-06T05:59:18.865847
2018-01-06T18:45:05
2018-01-06T18:45:05
115,284,971
0
1
null
null
null
null
UTF-8
C++
false
false
18,653
cpp
/********************************************************************* # Copyright (c) 2013-2015, Rethink Robotics # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the Rethink Robotics nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /** * \author Hariharasudan Malaichamee * \modified Martin Feick * \desc library that performs the calculations for the IK,FK and Gravity compensation using the KDL library */ #include <cstring> #include <ros/ros.h> #include <baxter_sim_kinematics/arm_kinematics.h> namespace arm_kinematics { Kinematics::Kinematics() : nh_private("~") { } bool Kinematics::init_grav() { std::string urdf_xml, full_urdf_xml; nh.param("urdf_xml", urdf_xml, std::string("robot_description")); nh.searchParam(urdf_xml, full_urdf_xml); ROS_DEBUG("Reading xml file from parameter server"); std::string result; if (!nh.getParam(full_urdf_xml, result)) { ROS_FATAL("Could not load the xml from parameter server: %s", urdf_xml.c_str()); return false; } if (!nh.getParam("root_name", root_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } if (!nh.getParam("grav_right_name", grav_right_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } if (!nh.getParam("grav_left_name", grav_left_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } //Service client to set the gravity false for the limbs ros::ServiceClient get_lp_client = nh.serviceClient<gazebo_msgs::GetLinkProperties>("/gazebo/get_link_properties"); //Wait for service to become available get_lp_client.waitForExistence(); //Service client to set the gravity false for the limbs ros::ServiceClient set_lp_client = nh.serviceClient<gazebo_msgs::SetLinkProperties>("/gazebo/set_link_properties"); //Wait for service to become availablestd::find(vector.begin(), vector.end(), item)!=vector.end() set_lp_client.waitForExistence(); gazebo_msgs::SetLinkProperties setlinkproperties; gazebo_msgs::GetLinkProperties getlinkproperties; setlinkproperties.request.gravity_mode=0; //Load the right chain and copy them to Right specific variables tip_name = grav_right_name; if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } grav_chain_r = chain; right_joint.clear(); right_joint.reserve(chain.getNrOfSegments()); std::vector<std::string>::iterator idx; //Update the right_joint with the fixed joints from the URDF. Get each of the link's properties from GetLinkProperties service and //call the SetLinkProperties service with the same set of parameters except for the gravity_mode, which would be disabled. This is //to disable the gravity in the links, thereby to eliminate the need for gravity compensation for (int i = 0; i < chain.getNrOfSegments(); i++) { std::string seg_name = chain.getSegment(i).getName(); std::string joint_name = chain.getSegment(i).getJoint().getName(); idx = std::find(info.joint_names.begin(), info.joint_names.end(), joint_name); if (idx != info.joint_names.end()) { right_joint.push_back(*idx); } std::string link_name = chain.getSegment(i).getName(); getlinkproperties.request.link_name=link_name; setlinkproperties.request.link_name=link_name; get_lp_client.call(getlinkproperties); setlinkproperties.request.com = getlinkproperties.response.com; setlinkproperties.request.mass = getlinkproperties.response.mass; setlinkproperties.request.ixx = getlinkproperties.response.ixx; setlinkproperties.request.iyy = getlinkproperties.response.iyy; setlinkproperties.request.izz = getlinkproperties.response.izz; setlinkproperties.request.ixy = getlinkproperties.response.ixy; setlinkproperties.request.iyz = getlinkproperties.response.iyz; setlinkproperties.request.ixz = getlinkproperties.response.ixz; setlinkproperties.request.gravity_mode = false; set_lp_client.call(setlinkproperties); } //Create a gravity solver for the right chain gravity_solver_r = new KDL::ChainIdSolver_RNE(grav_chain_r, KDL::Vector(0.0, 0.0, -9.8)); //Load the left chain and copy them to Right specific variable tip_name = grav_left_name; if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } grav_chain_l = chain; left_joint.clear(); left_joint.reserve(chain.getNrOfSegments()); //Update the left_joint with the fixed joints from the URDF. Get each of the link's properties from GetLinkProperties service and //call the SetLinkProperties service with the same set of parameters except for the gravity_mode, which would be disabled. This is //to disable the gravity in the links, thereby to eliminate the need for gravity compensation for (int i = 0; i < chain.getNrOfSegments(); i++) { std::string seg_name = chain.getSegment(i).getName(); std::string joint_name = chain.getSegment(i).getJoint().getName(); idx = std::find(info.joint_names.begin(), info.joint_names.end(), joint_name); if (idx != info.joint_names.end()) { left_joint.push_back(*idx); } getlinkproperties.request.link_name=chain.getSegment(i).getName(); std::string link_name = chain.getSegment(i).getName(); getlinkproperties.request.link_name=link_name; setlinkproperties.request.link_name=link_name; get_lp_client.call(getlinkproperties); setlinkproperties.request.com = getlinkproperties.response.com; setlinkproperties.request.mass = getlinkproperties.response.mass; setlinkproperties.request.ixx = getlinkproperties.response.ixx; setlinkproperties.request.iyy = getlinkproperties.response.iyy; setlinkproperties.request.izz = getlinkproperties.response.izz; setlinkproperties.request.ixy = getlinkproperties.response.ixy; setlinkproperties.request.iyz = getlinkproperties.response.iyz; setlinkproperties.request.ixz = getlinkproperties.response.ixz; setlinkproperties.request.gravity_mode = false; set_lp_client.call(setlinkproperties); } //Create a gravity solver for the left chain gravity_solver_l = new KDL::ChainIdSolver_RNE(grav_chain_l, KDL::Vector(0.0, 0.0, -9.8)); return true; } /* Initializes the solvers and the other variables required * @returns true is successful */ bool Kinematics::init(std::string tip, int &no_jts) { // Get URDF XML std::string urdf_xml, full_urdf_xml; tip_name = tip; nh.param("urdf_xml", urdf_xml, std::string("robot_description")); nh.searchParam(urdf_xml, full_urdf_xml); ROS_DEBUG("Reading xml file from parameter server"); std::string result; if (!nh.getParam(full_urdf_xml, result)) { ROS_FATAL("Could not load the xml from parameter server: %s", urdf_xml.c_str()); return false; } // Get Root and Tip From Parameter Service if (!nh.getParam("root_name", root_name)) { ROS_FATAL("GenericIK: No root name found on parameter server"); return false; } // Load and Read Models if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } // Get Solver Parameters int maxIterations; double epsilon; //KDL::Vector grav; nh_private.param("maxIterations", maxIterations, 1000); nh_private.param("epsilon", epsilon, 1e-2); // Build Solvers fk_solver = new KDL::ChainFkSolverPos_recursive(chain); ik_solver_vel = new KDL::ChainIkSolverVel_pinv(chain); ik_solver_pos = new KDL::ChainIkSolverPos_NR_JL(chain, joint_min, joint_max, *fk_solver, *ik_solver_vel, maxIterations, epsilon); double eps = 1e-5; double timeout = 0.005; ik_solver = new TRAC_IK::TRAC_IK(chain, joint_min, joint_max, timeout, eps); no_jts=num_joints; return true; } /* Method to load all the values from the parameter server * @returns true is successful */ bool Kinematics::loadModel(const std::string xml) { urdf::Model robot_model; KDL::Tree tree; if (!robot_model.initString(xml)) { ROS_FATAL("Could not initialize robot model"); return -1; } if (!kdl_parser::treeFromString(xml, tree)) { ROS_ERROR("Could not initialize tree object"); return false; } if (!tree.getChain(root_name, tip_name, chain)) { ROS_ERROR("Could not initialize chain object for root_name %s and tip_name %s",root_name.c_str(), tip_name.c_str()); return false; } if (!readJoints(robot_model)) { ROS_FATAL("Could not read information about the joints"); return false; } return true; } /* Method to read the URDF model and extract the joints * @returns true is successful */ bool Kinematics::readJoints(urdf::Model &robot_model) { num_joints = 0; boost::shared_ptr<const urdf::Link> link = robot_model.getLink(tip_name); boost::shared_ptr<const urdf::Joint> joint; for (int i = 0; i < chain.getNrOfSegments(); i++) while (link && link->name != root_name) { if (!(link->parent_joint)) { break; } joint = robot_model.getJoint(link->parent_joint->name); if (!joint) { ROS_ERROR("Could not find joint: %s", link->parent_joint->name.c_str()); return false; } if (joint->type != urdf::Joint::UNKNOWN && joint->type != urdf::Joint::FIXED) { ROS_INFO("adding joint: [%s]", joint->name.c_str()); num_joints++; } link = robot_model.getLink(link->getParent()->name); } joint_min.resize(num_joints); joint_max.resize(num_joints); info.joint_names.resize(num_joints); info.link_names.resize(num_joints); link = robot_model.getLink(tip_name); unsigned int i = 0; while (link && i < num_joints) { joint = robot_model.getJoint(link->parent_joint->name); if (joint->type != urdf::Joint::UNKNOWN && joint->type != urdf::Joint::FIXED) { ROS_INFO("getting bounds for joint: [%s]", joint->name.c_str()); float lower, upper; int hasLimits; if (joint->type != urdf::Joint::CONTINUOUS) { lower = joint->limits->lower; upper = joint->limits->upper; hasLimits = 1; } else { lower = -M_PI; upper = M_PI; hasLimits = 0; } int index = num_joints - i - 1; joint_min.data[index] = lower; joint_max.data[index] = upper; info.joint_names[index] = joint->name; info.link_names[index] = link->name; i++; } link = robot_model.getLink(link->getParent()->name); } return true; } /* Method to calculate the torques required to apply at each of the joints for gravity compensation * @returns true is successful */ bool arm_kinematics::Kinematics::getGravityTorques( const sensor_msgs::JointState joint_configuration, baxter_core_msgs::SEAJointState &left_gravity, baxter_core_msgs::SEAJointState &right_gravity, bool isEnabled) { bool res; KDL::JntArray torques_l, torques_r; KDL::JntArray jntPosIn_l, jntPosIn_r; left_gravity.name = left_joint; right_gravity.name = right_joint; left_gravity.gravity_model_effort.resize(num_joints); right_gravity.gravity_model_effort.resize(num_joints); if (isEnabled) { torques_l.resize(num_joints); torques_r.resize(num_joints); jntPosIn_l.resize(num_joints); jntPosIn_r.resize(num_joints); // Copying the positions of the joints relative to its index in the KDL chain for (unsigned int j = 0; j < joint_configuration.name.size(); j++) { for (unsigned int i = 0; i < num_joints; i++) { if (joint_configuration.name[j] == left_joint.at(i)) { jntPosIn_l(i) = joint_configuration.position[j]; break; } else if (joint_configuration.name[j] == right_joint.at(i)) { jntPosIn_r(i) = joint_configuration.position[j]; break; } } } KDL::JntArray jntArrayNull(num_joints); KDL::Wrenches wrenchNull_l(grav_chain_l.getNrOfSegments(), KDL::Wrench::Zero()); int code_l = gravity_solver_l->CartToJnt(jntPosIn_l, jntArrayNull, jntArrayNull, wrenchNull_l, torques_l); KDL::Wrenches wrenchNull_r(grav_chain_r.getNrOfSegments(), KDL::Wrench::Zero()); int code_r = gravity_solver_r->CartToJnt(jntPosIn_r, jntArrayNull, jntArrayNull, wrenchNull_r, torques_r); //Check if the gravity was succesfully calculated by both the solvers if (code_l >= 0 && code_r >= 0) { for (unsigned int i = 0; i < num_joints; i++) { left_gravity.gravity_model_effort[i] = torques_l(i); right_gravity.gravity_model_effort[i] = torques_r(i); } return true; } else { ROS_ERROR_THROTTLE( 1.0, "KT: Failed to compute gravity torques from KDL return code for left and right arms %d %d", code_l, code_r); return false; } } else { for (unsigned int i = 0; i < num_joints; i++) { left_gravity.gravity_model_effort[i]=0; right_gravity.gravity_model_effort[i]=0; } } return true; } /* Method to calculate the Joint index of a particular joint from the KDL chain * @returns the index of the joint */ int Kinematics::getJointIndex(const std::string &name) { for (unsigned int i = 0; i < info.joint_names.size(); i++) { if (info.joint_names[i] == name) return i; } return -1; } /* Method to calculate the KDL segment index of a particular segment from the KDL chain * @returns the index of the segment */ int Kinematics::getKDLSegmentIndex(const std::string &name) { int i = 0; while (i < (int) chain.getNrOfSegments()) { if (chain.getSegment(i).getJoint().getName() == name) { return i + 1; } i++; } return -1; } /* Method to calculate the IK for the required end pose * @returns true if successful */ bool arm_kinematics::Kinematics::getPositionIK( const geometry_msgs::PoseStamped &pose_stamp, const sensor_msgs::JointState &seed, sensor_msgs::JointState *result) { geometry_msgs::PoseStamped pose_msg_in = pose_stamp; tf::Stamped<tf::Pose> transform; tf::Stamped<tf::Pose> transform_root; tf::poseStampedMsgToTF(pose_msg_in, transform); //Do the IK KDL::JntArray jnt_pos_in; KDL::JntArray jnt_pos_out; jnt_pos_in.resize(num_joints); // Copying the positions of the joints relative to its index in the KDL chain for (unsigned int i = 0; i < num_joints; i++) { int tmp_index = getJointIndex(seed.name[i]); if (tmp_index >= 0) { jnt_pos_in(tmp_index) = seed.position[i]; } else { ROS_ERROR("i: %d, No joint index for %s", i, seed.name[i].c_str()); } } //Convert F to our root_frame try { tf_listener.transformPose(root_name, transform, transform_root); } catch (...) { ROS_ERROR("Could not transform IK pose to frame: %s", root_name.c_str()); return false; } KDL::Frame F_dest; tf::transformTFToKDL(transform_root, F_dest); //int ik_valid = ik_solver_pos->CartToJnt(jnt_pos_in, F_dest, jnt_pos_out); int ik_valid=ik_solver->CartToJnt(jnt_pos_in, F_dest, jnt_pos_out); if (ik_valid >= 0) { result->name = info.joint_names; result->position.resize(num_joints); for (unsigned int i = 0; i < num_joints; i++) { result->position[i] = jnt_pos_out(i); ROS_DEBUG("IK Solution: %s %d: %f", result->name[i].c_str(), i, jnt_pos_out(i)); } return true; } else { ROS_DEBUG("An IK solution could not be found"); return false; } } /* Method to calculate the FK for the required joint configuration * @returns true if successful */ bool arm_kinematics::Kinematics::getPositionFK( std::string frame_id, const sensor_msgs::JointState &joint_configuration, geometry_msgs::PoseStamped &result) { KDL::Frame p_out; KDL::JntArray jnt_pos_in; tf::Stamped<tf::Pose> tf_pose; // Copying the positions of the joints relative to its index in the KDL chain jnt_pos_in.resize(num_joints); for (unsigned int i = 0; i < num_joints; i++) { int tmp_index = getJointIndex(joint_configuration.name[i]); if (tmp_index >= 0) jnt_pos_in(tmp_index) = joint_configuration.position[i]; } int num_segments = chain.getNrOfSegments(); ROS_DEBUG("Number of Segments in the KDL chain: %d", num_segments); if (fk_solver->JntToCart(jnt_pos_in, p_out, num_segments) >= 0) { tf_pose.frame_id_ = root_name; tf_pose.stamp_ = ros::Time(); tf::poseKDLToTF(p_out, tf_pose); try { tf_listener.transformPose(frame_id, tf_pose, tf_pose); } catch (...) { ROS_ERROR("Could not transform FK pose to frame: %s", frame_id.c_str()); return false; } tf::poseStampedTFToMsg(tf_pose, result); } else { ROS_ERROR("Could not compute FK for endpoint."); return false; } return true; } } //namespace
49622d2936de25439968c35b7af165f44568c76d
cccfb7be281ca89f8682c144eac0d5d5559b2deb
/ash/components/phonehub/fake_camera_roll_download_manager.h
4d531c34b167ddd565953dec22279be5f1610752
[ "BSD-3-Clause" ]
permissive
SREERAGI18/chromium
172b23d07568a4e3873983bf49b37adc92453dd0
fd8a8914ca0183f0add65ae55f04e287543c7d4a
refs/heads/master
2023-08-27T17:45:48.928019
2021-11-11T22:24:28
2021-11-11T22:24:28
428,659,250
1
0
BSD-3-Clause
2021-11-16T13:08:14
2021-11-16T13:08:14
null
UTF-8
C++
false
false
1,901
h
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_ #define ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_ #include <vector> #include "ash/components/phonehub/camera_roll_download_manager.h" #include "ash/components/phonehub/proto/phonehub_api.pb.h" #include "base/containers/flat_map.h" #include "chromeos/services/secure_channel/public/mojom/secure_channel_types.mojom.h" namespace chromeos { namespace phonehub { class FakeCameraRollDownloadManager : public CameraRollDownloadManager { public: FakeCameraRollDownloadManager(); ~FakeCameraRollDownloadManager() override; // CameraRollDownloadManager: void CreatePayloadFiles( int64_t payload_id, const chromeos::phonehub::proto::CameraRollItemMetadata& item_metadata, CreatePayloadFilesCallback payload_files_callback) override; void UpdateDownloadProgress( chromeos::secure_channel::mojom::FileTransferUpdatePtr update) override; void DeleteFile(int64_t payload_id) override; void set_should_create_payload_files_succeed( bool should_create_payload_files_succeed) { should_create_payload_files_succeed_ = should_create_payload_files_succeed; } const std::vector<chromeos::secure_channel::mojom::FileTransferUpdatePtr>& GetFileTransferUpdates(int64_t payload_id) const; private: bool should_create_payload_files_succeed_ = true; // A map from payload IDs to the list of FileTransferUpdate received for each // payload. base::flat_map< int64_t, std::vector<chromeos::secure_channel::mojom::FileTransferUpdatePtr>> payload_update_map_; }; } // namespace phonehub } // namespace chromeos #endif // ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_
69c3bf5e4501e9b659ef06bc25505e9af4c9a44f
da726bce6d0f9ab1e63b9c04a2cb33976a0735a3
/lib/Transform/Mixed/DINodeRetriever.cpp
3cb1bfa7b68a68d6d30bd1e8b3b8fff30200fea7
[ "Apache-2.0", "NCSA" ]
permissive
dvm-system/tsar
c4017018a624100d50749004dc60e1f6b23fa99f
8ee33ff80702766d832e56aa37e82931aacd2ba3
refs/heads/master
2023-05-24T23:41:39.583393
2023-04-22T12:23:40
2023-04-22T12:24:17
212,194,441
19
20
Apache-2.0
2023-05-22T09:11:28
2019-10-01T20:35:07
C++
UTF-8
C++
false
false
7,908
cpp
//===- DIGlobalRetriever.cpp - Global Debug Info Retriever ------*- C++ -*-===// // // Traits Static Analyzer (SAPFOR) // // Copyright 2018 DVM System Group // // 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. // //===----------------------------------------------------------------------===// // // This file implements a pass which retrieves some debug information for // global values if it is not presented in LLVM IR. // //===----------------------------------------------------------------------===// #include "tsar/Analysis/KnownFunctionTraits.h" #include "tsar/Analysis/Memory/Utils.h" #include "tsar/Frontend/Clang/TransformationContext.h" #include "tsar/Support/MetadataUtils.h" #include "tsar/Support/Clang/Utils.h" #include "tsar/Transform/Mixed/Passes.h" #include <bcl/utility.h> #include <clang/Basic/LangOptions.h> #include <clang/AST/Decl.h> #include <llvm/IR/DebugInfo.h> #include <llvm/IR/DIBuilder.h> #include <llvm/IR/InstIterator.h> #include <llvm/IR/Module.h> #include <llvm/Pass.h> #include <llvm/Support/Path.h> #include <llvm/Support/FileSystem.h> using namespace clang; using namespace llvm; using namespace tsar; namespace { /// This retrieves some debug information for global values if it is not /// presented in LLVM IR ('sapfor.dbg' metadata will be attached to globals). class DINodeRetrieverPass : public ModulePass, private bcl::Uncopyable { public: static char ID; DINodeRetrieverPass() : ModulePass(ID) { initializeDINodeRetrieverPassPass(*PassRegistry::getPassRegistry()); } bool runOnModule(llvm::Module &M) override; void getAnalysisUsage(AnalysisUsage &AU) const override { AU.getPreservesAll(); } private: /// Insert artificial metadata for allocas. void insertDeclareIfNotExist(Function &F, DIFile *FileCU, DIBuilder &DIB) { for (auto &I : instructions(F)) if (auto *AI = dyn_cast<AllocaInst>(&I)) { auto &Ctx = AI->getContext(); auto AddrUses = FindDbgAddrUses(AI); if (!AddrUses.empty()) { for (auto *DbgInst : AddrUses) { // Artificial variables without name may produce the same // metdata-level locations for distinct lower level locations. // This leads to incorrect metadata-level alias tree. // So, replace this variable with the distinct one. if (auto DIVar = DbgInst->getVariable()) if (DIVar->getFlags() & DINode::FlagArtificial && DIVar->getName().empty()) { auto DistinctDIVar = DILocalVariable::getDistinct( Ctx, DIVar->getScope(), "sapfor.var", DIVar->getFile(), DIVar->getLine(), DIVar->getType(), DIVar->getArg(), DIVar->getFlags(), DIVar->getAlignInBits(), nullptr); DbgInst->setVariable(DistinctDIVar); } } continue; } auto *DITy = createStubType(*F.getParent(), AI->getType()->getAddressSpace(), DIB); auto *DISub = F.getSubprogram(); auto *DIVar = DILocalVariable::getDistinct( Ctx, DISub, "sapfor.var", FileCU, 0, DITy, 0, DINode::FlagArtificial, AI->getAlign().value(), nullptr); DIB.insertDeclare(AI, DIVar, DIExpression::get(Ctx, {}), DILocation::get(AI->getContext(), 0, 0, DISub), AI->getParent()); } } }; } // namespace char DINodeRetrieverPass::ID = 0; INITIALIZE_PASS(DINodeRetrieverPass, "di-node-retriever", "Debug Info Retriever", true, false) bool DINodeRetrieverPass::runOnModule(llvm::Module &M) { auto *TEP{getAnalysisIfAvailable<TransformationEnginePass>()}; auto &Ctx = M.getContext(); auto CUItr = M.debug_compile_units_begin(); assert(CUItr != M.debug_compile_units_end() && "At least one compile unit must be available!"); auto CU = std::distance(CUItr, M.debug_compile_units_end()) == 1 ? *CUItr : nullptr; SmallString<256> CWD; auto DirName = CU ? CUItr->getDirectory() : (llvm::sys::fs::current_path(CWD), StringRef(CWD)); auto *FileCU = CU ? CU->getFile() : nullptr; DIBuilder DIB(M); for (auto &GlobalVar : M.globals()) { SmallVector<DIMemoryLocation, 1> DILocs; if (findGlobalMetadata(&GlobalVar, DILocs)) continue; DIFile *File = FileCU; unsigned Line = 0; // A name should be specified for global variables, otherwise LLVM IR is // considered corrupted. StringRef Name = "sapfor.var"; if (TEP && *TEP) for (auto [CU, TfmCtxBase] : (*TEP)->contexts()) if (auto *TfmCtx{dyn_cast<ClangTransformationContext>(TfmCtxBase)}) if (auto D = TfmCtx->getDeclForMangledName(GlobalVar.getName())) { auto &SrcMgr = TfmCtx->getRewriter().getSourceMgr(); auto FName = SrcMgr.getFilename(SrcMgr.getExpansionLoc(D->getBeginLoc())); File = DIB.createFile(FName, CU->getDirectory()); Line = SrcMgr.getPresumedLineNumber( SrcMgr.getExpansionLoc(D->getBeginLoc())); if (auto ND = dyn_cast<NamedDecl>(D)) Name = ND->getName(); break; } auto *DITy = createStubType(M, GlobalVar.getType()->getAddressSpace(), DIB); auto *GV = DIGlobalVariable::getDistinct( Ctx, File, Name, GlobalVar.getName(), File, Line, DITy, GlobalVar.hasLocalLinkage(), !GlobalVar.isDeclaration(), nullptr, nullptr, 0, nullptr); auto *GVE = DIGlobalVariableExpression::get(Ctx, GV, DIExpression::get(Ctx, {})); GlobalVar.setMetadata("sapfor.dbg", GVE); } for (auto &F : M.functions()) { if (F.getSubprogram()) { insertDeclareIfNotExist(F, FileCU, DIB); continue; } if (F.isIntrinsic() && (isDbgInfoIntrinsic(F.getIntrinsicID()) || isMemoryMarkerIntrinsic(F.getIntrinsicID()))) continue; DIFile *File = FileCU; unsigned Line = 0; auto Flags = DINode::FlagZero; MDString *Name = nullptr; if (TEP && *TEP) for (auto [CU, TfmCtxBase] : (*TEP)->contexts()) if (auto *TfmCtx{dyn_cast<ClangTransformationContext>(TfmCtxBase)}) if (auto *D = TfmCtx->getDeclForMangledName(F.getName())) { auto &SrcMgr = TfmCtx->getRewriter().getSourceMgr(); auto FName = SrcMgr.getFilename(SrcMgr.getExpansionLoc(D->getBeginLoc())); File = DIB.createFile(FName, CU->getDirectory()); Line = SrcMgr.getPresumedLineNumber( SrcMgr.getExpansionLoc(D->getBeginLoc())); if (auto *FD = dyn_cast<FunctionDecl>(D)) { SmallString<64> ExtraName; Name = MDString::get(Ctx, getFunctionName(*FD, ExtraName)); if (FD->hasPrototype()) Flags |= DINode::FlagPrototyped; if (FD->isImplicit()) Flags |= DINode::FlagArtificial; } } auto SPFlags = DISubprogram::toSPFlags(F.hasLocalLinkage(), !F.isDeclaration(), false); auto *SP = DISubprogram::getDistinct(Ctx, File, Name, MDString::get(Ctx, F.getName()), File, Line, nullptr, Line, nullptr, 0, 0, Flags, SPFlags, !F.isDeclaration() ? CU : nullptr); F.setMetadata("sapfor.dbg", SP); insertDeclareIfNotExist(F, FileCU, DIB); } return true; } ModulePass *llvm::createDINodeRetrieverPass() { return new DINodeRetrieverPass(); }
9cc7265b0b688e52232a58d0c883fa3a388cbe8a
77b28b71ff49842067732ef8f948d935a8f3e7a5
/my_Codes/test3.cpp
96cdb66ab676ea94b52eeb7a6decaaddb359d07e
[]
no_license
rahulSingh2995/Codes
ea21b49aabb63e8d55db58da2bc10e5c89b4ccfe
f90d7ad5c20523e5d9b76ce6f71305e9cdf7f37f
refs/heads/master
2021-06-12T17:01:52.723269
2020-05-15T04:55:57
2020-05-15T04:55:57
254,365,740
0
0
null
null
null
null
UTF-8
C++
false
false
141
cpp
#include<iostream> class Test { static void fun(int a) {} void fun() {} // compiler error }; int main() { getchar(); return 0; }
615641b86279bfc4c7533476181cb73ecfbd385a
f0b4ce0ba6972301435f182a6d4c02987ee17ab3
/whacAMole.cc
8ccc5d4730d71a60529367313bba7ad8cf98479c
[]
no_license
gs0622/leetcode
b64bf1ac8d52ea473cac98b057a5edd1c8ff3591
ef9388f875c375f6f3cd290b04e457b416d860dc
refs/heads/master
2021-06-02T00:54:32.332803
2020-05-19T01:13:51
2020-05-19T01:13:51
20,798,407
0
0
null
null
null
null
UTF-8
C++
false
false
1,489
cc
#include <bits/stdc++.h> using namespace std; class Solution { public: // O(n) sliding window int whatAMoleTwoMallets(vector<int>& A, int w) { int n=A.size(); vector<int> sum(n,0); for (int i=0; i<n; ++i) sum[i]=(i==0)? A[i]: A[i]+sum[i-1]; function<int(int,int)> getSum=[&](int i, int j) { return (i==0)? sum[j]: sum[j]-sum[i-1]; }; pair<int,int> ids={n-2*w,n-w}; int mainSumTwoSubArr = getSum(n-2*w,n-w-1)+getSum(n-w,n-1); pair<int,int> secSubArrMax={n-w,getSum(n-w,n-1)}; for (int i=n-2*w-1; i>=0; --i) { int cur = getSum(i+w,i+2*w-1); // 1st:[n-w-1,n-2] if (cur > secSubArrMax.second) secSubArrMax={i+w,cur}; cur = getSum(i,i+w-1) + secSubArrMax.second; if (cur>mainSumTwoSubArr) mainSumTwoSubArr=cur, ids={i,secSubArrMax.first}; } /* for (int i=ids.first; i<ids.first+w; ++i) cout << A[i]; cout << endl; for (int i=ids.second; i<ids.second+w; ++i) cout << A[i]; cout << endl; */ return mainSumTwoSubArr; } int whatAMole(vector<int>& A, int w) { int n=A.size(),res=0,cur=0; for (int i=0,j=0; i<n; ++i) { if (A[i]==1) ++cur; while ((i-j)>5) { cur-=A[j++]; } res=max(res,cur); } return res; } }; int main(){ Solution s; vector<int> A1{0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}; cout << s.whatAMole(A1,5) << endl; vector<int> A2{0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}; cout << s.whatAMoleTwoMallets(A2,5) << endl; }
f3460f675f5e2b569bfb2559b06024507bc95d79
67233ab008d07efb37e6ed33c6959fc6215e5048
/CodeTestZone/A1_Threadpool/CThreadUsingMsgLoop.h
8f8965c427a41a58caaa2efac5d085e184a3aa2b
[]
no_license
yinjingyu/LinuxDevelopment
0e9350ec985c40e2a29c9544297e5118a21192a3
5e5c57f3b233507c16cd5e56d4b9682c01a7bdbc
refs/heads/master
2021-01-22T05:15:27.000512
2013-12-03T09:28:29
2013-12-03T09:28:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
707
h
#ifndef CTHREADFORMSGLOOP_H #define CTHREADFORMSGLOOP_H #include "./include/CMsgObserver.h" #include <string> #include "./include/CStatus.h" class CThreadInitFinishedNotifier; class CThread; typedef struct { void * pContext; CThreadInitFinishedNotifier * pNotifier; }SInitialParameter; class CThreadUsingMsgLoop { public: CThreadUsingMsgLoop(const char * strThreadName, CMsgObserver * pMsgObserver); CThreadUsingMsgLoop(const char * strThreadNaem,CMsgObserver * pMsgObserver,bool bWaitForDeath); virtual ~CThreadUsingMsgLoop(); CStatus Run(void * pContext); const char * GetThreadName(); private: std::string m_sThreadName; CThread * m_pThread; bool m_bWaitForDeath; }; #endif
7dd90e0a5fe64e6f0b097f48fea2d058e4492439
771a4e3846212eabbabf6b68bf73d4a326d0973e
/src/vswprinn.cpp
3f647373b1f94326e709d91a5f2ed7b5919456f5
[]
no_license
ganboing/crt.vc12
4e65b96bb5bd6c5b5be6a08d04c9b712b269461f
f1d47126bf13d1c9dccaa6c53b72217fd0474968
refs/heads/master
2021-01-13T08:48:12.365115
2016-09-24T20:16:46
2016-09-24T20:16:46
69,113,159
4
1
null
null
null
null
UTF-8
C++
false
false
4,238
cpp
/*** *vswprint.c - print formatted data into a string from var arg list * * Copyright (c) Microsoft Corporation. All rights reserved. * *Purpose: * defines vswprintf() and _vsnwprintf() - print formatted output to * a string, get the data from an argument ptr instead of explicit * arguments. * *******************************************************************************/ #ifdef CRTDLL /* * Suppress the inline definitions of iswalpha et al. Necessary to avoid * a conflict with the dllexport versions from _wctype.c in the DLL build. */ #define _WCTYPE_INLINE_DEFINED #endif /* CRTDLL */ #include <cruntime.h> /* This is prevent pulling in the inline versions of (v)swprintf */ #define _INC_SWPRINTF_INL_ #include <stdio.h> #include <wchar.h> #include <dbgint.h> #include <stdarg.h> #include <internal.h> #include <limits.h> #include <mtdll.h> #define MAXSTR INT_MAX /*** *int vswprintf(string, cnt, format, ap) - print formatted data to string from arg ptr * *Purpose: * Prints formatted data, but to a string and gets data from an argument * pointer. * Sets up a FILE so file i/o operations can be used, make string look * like a huge buffer to it, but _flsbuf will refuse to flush it if it * fills up. Appends '\0' to make it a true string. * * Allocate the 'fake' _iob[] entryit statically instead of on * the stack so that other routines can assume that _iob[] entries are in * are in DGROUP and, thus, are near. * * The vswprintf() flavor takes a count argument that is * the max number of bytes that should be written to the * user's buffer. * * Multi-thread: (1) Since there is no stream, this routine must never try * to get the stream lock (i.e., there is no stream lock either). (2) * Also, since there is only one staticly allocated 'fake' iob, we must * lock/unlock to prevent collisions. * *Entry: * wchar_t *string - place to put destination string * size_t count - max number of bytes to put in buffer * wchar_t *format - format string, describes format of data * va_list ap - varargs argument pointer * *Exit: * returns number of wide characters in string * *Exceptions: * *******************************************************************************/ int __cdecl _vswprintf_l ( wchar_t *string, size_t count, const wchar_t *format, _locale_t plocinfo, va_list ap ) { FILE str = { 0 }; FILE *outfile = &str; int retval; _ASSERTE(string != NULL); _ASSERTE(format != NULL); outfile->_flag = _IOWRT|_IOSTRG; outfile->_ptr = outfile->_base = (char *) string; if(count>(INT_MAX/sizeof(wchar_t))) { /* old-style functions allow any large value to mean unbounded */ outfile->_cnt = INT_MAX; } else { outfile->_cnt = (int)(count*sizeof(wchar_t)); } retval = _woutput_l(outfile,format,plocinfo,ap ); _putc_nolock('\0',outfile); /* no-lock version */ _putc_nolock('\0',outfile); /* 2nd byte for wide char version */ return(retval); } int __cdecl vswprintf ( wchar_t *string, size_t count, const wchar_t *format, va_list ap ) { return _vswprintf_l(string, count, format, NULL, ap); } #if defined (_NATIVE_WCHAR_T_DEFINED) int __cdecl _vswprintf_l ( unsigned short *string, size_t count, const unsigned short *format, _locale_t plocinfo, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), plocinfo,ap); } int __cdecl vswprintf ( unsigned short *string, size_t count, const unsigned short *format, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), NULL, ap); } #endif /* defined (_NATIVE_WCHAR_T_DEFINED) */
4c157dec32a8c39e3d1c52fb29b8bd51631135c8
47b755444e700332877d8bb432e5739045ba2c8b
/wxWidgets/include/wx/generic/spinctlg.h
0f09abd5d7065c4b2aa2c67dd4b8d4c4bf59b4c3
[ "MIT" ]
permissive
andr3wmac/Torque6Editor
5b30e103f0b3a81ae7a189725e25d807093bf131
0f8536ce90064adb9918f004a45aaf8165b2a343
refs/heads/master
2021-01-15T15:32:54.537291
2016-06-09T20:45:49
2016-06-09T20:45:49
39,276,153
25
14
null
null
null
null
UTF-8
C++
false
false
14,361
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/spinctlg.h // Purpose: generic wxSpinCtrl class // Author: Vadim Zeitlin // Modified by: // Created: 28.10.99 // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GENERIC_SPINCTRL_H_ #define _WX_GENERIC_SPINCTRL_H_ // ---------------------------------------------------------------------------- // wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if // wxSpinButton is available, this is what we do - but if it isn't, we still // define wxSpinCtrl class which then has the same appearance as wxTextCtrl but // the different interface. This allows to write programs using wxSpinCtrl // without tons of #ifdefs. // ---------------------------------------------------------------------------- #if wxUSE_SPINBTN #include "wx/compositewin.h" class WXDLLIMPEXP_FWD_CORE wxSpinButton; class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class wxSpinCtrlTextGeneric; // wxTextCtrl used for the wxSpinCtrlGenericBase // The !wxUSE_SPINBTN version's GetValue() function conflicts with the // wxTextCtrl's GetValue() and so you have to input a dummy int value. #define wxSPINCTRL_GETVALUE_FIX // ---------------------------------------------------------------------------- // wxSpinCtrlGeneric is a combination of wxTextCtrl and wxSpinButton // // This class manages a double valued generic spinctrl through the DoGet/SetXXX // functions that are made public as Get/SetXXX functions for int or double // for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid // function ambiguity. // ---------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxNavigationEnabled<wxCompositeWindow<wxSpinCtrlBase> > { public: wxSpinCtrlGenericBase() { Init(); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")); virtual ~wxSpinCtrlGenericBase(); // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text); // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks); // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl void SetSelection(long from, long to); // implementation from now on // forward these functions to all subcontrols virtual bool Enable(bool enable = true); virtual bool Show(bool show = true); virtual bool SetBackgroundColour(const wxColour& colour); // get the subcontrols wxTextCtrl *GetText() const { return m_textCtrl; } wxSpinButton *GetSpinButton() const { return m_spinButton; } // forwarded events from children windows void OnSpinButton(wxSpinEvent& event); void OnTextLostFocus(wxFocusEvent& event); void OnTextChar(wxKeyEvent& event); // this window itself is used only as a container for its sub windows so it // shouldn't accept the focus at all and any attempts to explicitly set // focus to it should give focus to its text constol part virtual bool AcceptsFocus() const { return false; } virtual void SetFocus(); friend class wxSpinCtrlTextGeneric; protected: // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestSize() const; virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; virtual void DoMoveWindow(int x, int y, int width, int height); #ifdef __WXMSW__ // and, for MSW, enabling this window itself virtual void DoEnable(bool enable); #endif // __WXMSW__ enum SendEvent { SendEvent_None, SendEvent_Text }; // generic double valued functions double DoGetValue() const { return m_value; } bool DoSetValue(double val, SendEvent sendEvent); void DoSetRange(double min_val, double max_val); void DoSetIncrement(double inc); // update our value to reflect the text control contents (if it has been // modified by user, do nothing otherwise) // // can also change the text control if its value is invalid // // return true if our value has changed bool SyncSpinToText(SendEvent sendEvent); // Send the correct event type virtual void DoSendEvent() = 0; // Convert the text to/from the corresponding value. virtual bool DoTextToValue(const wxString& text, double *val) = 0; virtual wxString DoValueToText(double val) = 0; // check if the value is in range bool InRange(double n) const { return (n >= m_min) && (n <= m_max); } // ensure that the value is in range wrapping it round if necessary double AdjustToFitInRange(double value) const; double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; int m_spin_value; // the subcontrols wxTextCtrl *m_textCtrl; wxSpinButton *m_spinButton; private: // common part of all ctors void Init(); // Implement pure virtual function inherited from wxCompositeWindow. virtual wxWindowList GetCompositeWindowParts() const; wxDECLARE_EVENT_TABLE(); }; #else // !wxUSE_SPINBTN #define wxSPINCTRL_GETVALUE_FIX int = 1 // ---------------------------------------------------------------------------- // wxSpinCtrl is just a text control // ---------------------------------------------------------------------------- #include "wx/textctrl.h" class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl { public: wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100), m_increment(1), m_snap_to_ticks(false), m_format(wxT("%g")) { } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")) { m_min = min; m_max = max; m_value = initial; m_increment = inc; bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style, wxDefaultValidator, name); DoSetValue(initial, SendEvent_None); return ok; } // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); } // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks) { m_snap_to_ticks = snap_to_ticks; } // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl //void SetSelection(long from, long to); protected: // generic double valued double DoGetValue() const { double n; if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) ) n = INT_MIN; return n; } bool DoSetValue(double val, SendEvent sendEvent) { wxString str(wxString::Format(m_format, val)); switch ( sendEvent ) { case SendEvent_None: wxTextCtrl::ChangeValue(str); break; case SendEvent_Text: wxTextCtrl::SetValue(str); break; } return true; } void DoSetRange(double min_val, double max_val) { m_min = min_val; m_max = max_val; } void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; wxString m_format; }; #endif // wxUSE_SPINBTN/!wxUSE_SPINBTN #if !defined(wxHAS_NATIVE_SPINCTRL) //----------------------------------------------------------------------------- // wxSpinCtrl //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase { public: wxSpinCtrl() { Init(); } wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name); } // accessors int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); } int GetMin() const { return int(m_min); } int GetMax() const { return int(m_max); } int GetIncrement() const { return int(m_increment); } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue( int value ) { DoSetValue(value, SendEvent_None); } void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } void SetIncrement(int inc) { DoSetIncrement(inc); } virtual int GetBase() const { return m_base; } virtual bool SetBase(int base); protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); private: // Common part of all ctors. void Init() { m_base = 10; } int m_base; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrl); }; #endif // wxHAS_NATIVE_SPINCTRL //----------------------------------------------------------------------------- // wxSpinCtrlDouble //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase { public: wxSpinCtrlDouble() { Init(); } wxSpinCtrlDouble(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } // accessors double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); } double GetMin() const { return m_min; } double GetMax() const { return m_max; } double GetIncrement() const { return m_increment; } unsigned GetDigits() const { return m_digits; } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue(double value) { DoSetValue(value, SendEvent_None); } void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } void SetIncrement(double inc) { DoSetIncrement(inc); } void SetDigits(unsigned digits); // We don't implement bases support for floating point numbers, this is not // very useful in practice. virtual int GetBase() const { return 10; } virtual bool SetBase(int WXUNUSED(base)) { return 0; } protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); unsigned m_digits; private: // Common part of all ctors. void Init() { m_digits = 0; m_format = wxS("%g"); } wxString m_format; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble); }; #endif // _WX_GENERIC_SPINCTRL_H_
df1315040d5f57018b7be11b3886ec910c0d910e
22ab69eeeecd020fee3e7be74bd5f6f4959cf7e0
/rocsolver/library/src/auxiliary/rocauxiliary_larf.cpp
8753b11bd34bf0424be1149c0caecb572c854553
[ "BSD-2-Clause" ]
permissive
jcarzu/internalDevelop
4ca697dacd2cc5baa5e7a702466e101fb7715cb6
b874d42ce7db68234e4082c5a4e28446469d8460
refs/heads/master
2020-12-10T02:19:55.781116
2020-01-13T00:56:43
2020-01-13T00:56:43
233,480,387
0
0
null
2020-01-13T00:28:14
2020-01-13T00:28:13
null
UTF-8
C++
false
false
3,374
cpp
#include "rocauxiliary_larf.hpp" template <typename T> rocblas_status rocsolver_larf_impl(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, T* x, const rocblas_int incx, const T* alpha, T* A, const rocblas_int lda) { if(!handle) return rocblas_status_invalid_handle; //logging is missing ??? if(n < 0 || m < 0 || lda < m || !incx) return rocblas_status_invalid_size; if(!x || !A || !alpha) return rocblas_status_invalid_pointer; rocblas_int stridex = 0; rocblas_int stridea = 0; rocblas_int stridep = 0; rocblas_int batch_count = 1; return rocsolver_larf_template<T>(handle, side, m, n, x, 0, //vector shifted 0 entries incx, stridex, alpha, stridep, A, 0, //matrix shifted 0 entries lda, stridea, batch_count); } /* * =========================================================================== * C wrapper * =========================================================================== */ extern "C" { ROCSOLVER_EXPORT rocblas_status rocsolver_slarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, float* x, const rocblas_int incx, const float* alpha, float* A, const rocblas_int lda) { return rocsolver_larf_impl<float>(handle, side, m, n, x, incx, alpha, A, lda); } ROCSOLVER_EXPORT rocblas_status rocsolver_dlarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, double* x, const rocblas_int incx, const double* alpha, double* A, const rocblas_int lda) { return rocsolver_larf_impl<double>(handle, side, m, n, x, incx, alpha, A, lda); } } //extern C
835f58b4577711e00aa48932d1d287b67d08cc32
4c66e1d186ad4b32cd1677bb64d871e09b505ffc
/drivenet_ros/include/ace/config-sunos5.10.h
e4590571fa8e9b6be69d2dbd1796e15f4d5ee3dd
[ "Apache-2.0" ]
permissive
Bangglll/driveworks_ros
0ace6f4bee4cc585b4c9fd01054101c8c09c5186
9f08a8be336cf317bcb36ae058bb8d673d814660
refs/heads/main
2023-08-14T16:46:55.264875
2021-10-03T06:47:17
2021-10-03T06:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,866
h
/* -*- C++ -*- */ // $Id: config-sunos5.10.h 2793 2015-11-30 23:09:18Z mitza $ // The following configuration file is designed to work for SunOS 5.10 // (Solaris 10) platforms using the SunC++ 5.x (Sun Studio 8-10), or g++ // compilers. #ifndef ACE_CONFIG_H // ACE_CONFIG_H is defined by one of the following #included headers. // #include the SunOS 5.9 config, then add any SunOS 5.10 updates below. #include "ace/config-sunos5.9.h" // Solaris 10 can do sem_timedwait() (see ACE_OS::sema_wait). #define ACE_HAS_POSIX_SEM_TIMEOUT #define ACE_HAS_SCANDIR // Solaris 10 offers a useable alphasort() unlike previous Solaris versions. #if defined (ACE_LACKS_ALPHASORT) # undef ACE_LACKS_ALPHASORT #endif #undef ACE_LACKS_GETADDRINFO #undef ACE_LACKS_GETNAMEINFO // Solaris 10 offers a useable log2() unlike previous Solaris versions. #if defined (ACE_LACKS_LOG2) # undef ACE_LACKS_LOG2 #endif // Solaris 10 offers a useable isblank() unlike previous Solaris versions. #if defined (ACE_LACKS_ISBLANK) # undef ACE_LACKS_ISBLANK #endif // Solaris 10 delivers pthread_attr_setstack #if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) # undef ACE_LACKS_PTHREAD_ATTR_SETSTACK #endif // Solaris 10 introduced printf() modifiers for [s]size_t types. #undef ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%zd" #undef ACE_SIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%zu" // Solaris 10 offers wcstoll() and wcstoull() #if defined (ACE_LACKS_WCSTOLL) # undef ACE_LACKS_WCSTOLL #endif /* ACE_LACKS_WCSTOLL */ #if defined (ACE_LACKS_WCSTOULL) # undef ACE_LACKS_WCSTOULL #endif /* ACE_LACKS_WCSTOULL */ #if defined (ACE_HAS_SCTP) && defined (ACE_HAS_LKSCTP) # define ACE_HAS_VOID_PTR_SCTP_GETLADDRS # define ACE_HAS_VOID_PTR_SCTP_GETPADDRS #endif #define ACE_HAS_SOLARIS_ATOMIC_LIB #endif /* ACE_CONFIG_H */
41c9e858b3f9a48f4d3b1ad829d66b9ef806a405
dfd960b9c39ab30680774f9e6204ef9c58054798
/CPP/复数类latest.cpp
760566d59208f4f49a90d826931d467f85a12510
[]
no_license
yuyuOWO/source-code
09e0025672169e72cbd493a13664b35a0d2480aa
d4972f4d807ddf8e17fd074c0568f2ec5aba2bfe
refs/heads/master
2021-06-15T22:32:08.325223
2017-05-04T05:44:36
2017-05-04T05:44:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,345
cpp
#include <iostream> using namespace std; class Complex { public: Complex(double a = 0, double b = 0): Real(a), Imag(b){} ~Complex(){} friend ostream & operator<<(ostream &os, const Complex t) { os << "(" << t.Real << "," << t.Imag << "!)"; return os; } friend istream & operator>>(istream &is, Complex &t) { is >> t.Real >> t.Imag; return is; } friend Complex operator+(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real + b.Real; tmp.Real = a.Imag + a.Imag; return tmp; *****************************/ return Complex(a.Real + b.Real, a.Imag + b.Imag); } friend Complex operator-(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real - b.Real; tmp.Real = a.Imag - a.Imag; return tmp; *****************************/ return Complex(a.Real - b.Real, a.Imag - b.Imag); } Complex operator=(Complex a) { return Complex(Real = a.Real, Imag = a.Imag); } private: double Real, Imag; }; int main(int argc, char const *argv[]) { Complex a, b, c; cin >> a >> b; c = a; cout << "a = " << a << " " << "b = " << b << endl; cout << "c = " << c << endl; cout << "a + b = " << a + b << endl; cout << "a + 23.32 = " << a + 23.32 << endl; cout << "200 + b = " << 200 + b << endl; cout << "a - b = " << a - b << endl; return 0; }
f41d41885bab9a639e39fb8071eb7590fdef1d43
4d96f3f730ec960a13cccb231ee024b7ac0693bd
/printout.cpp
abf652b5dc9febe025e74901b1eb9a1fc075860d
[ "MIT" ]
permissive
daikai999/stairspeedtest-reborn
c21c7b2f44d40ed11697b8a65a7305e4c227542b
06fb03ddd68800a77515e8209de0f1f4bff76cac
refs/heads/master
2020-08-28T14:52:30.561834
2019-09-29T15:09:21
2019-09-29T15:09:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,479
cpp
#include <iostream> #include <fstream> #include "printout.h" #include "version.h" //define print-out messages struct LOOKUP_ITEM { int index; string info; }; LOOKUP_ITEM SPEEDTEST_MESSAGES[] = { {SPEEDTEST_MESSAGE_EOF, "\nSpeed Test done. Press any key to exit..."}, {SPEEDTEST_MESSAGE_WELCOME, "Welcome to Stair Speedtest " VERSION "!\nWhich stair do you want to test today? (Supports single Shadowsocks/ShadowsocksD/ShadowsocksR/V2Ray link and their subscribe links)\nIf you want to test more than one link, separate them with '|'.\nLink: "}, {SPEEDTEST_MESSAGE_MULTILINK, "Multiple link provided, parsing all nodes.\n\n"}, {SPEEDTEST_MESSAGE_FOUNDVMESS, "Found single V2Ray link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSS, "Found single Shadowsocks link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSSR, "Found single ShadowsocksR link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSOCKS, "Found single Socks 5 link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSUB, "Found subscribe link.\n"}, {SPEEDTEST_MESSAGE_FOUNDLOCAL, "Found local configure file.\n"}, {SPEEDTEST_MESSAGE_GROUP, "If you have imported an V2Ray subscribe link which doesn't contain a Group Name, you can specify a custom name below.\nIf you have imported an Shadowsocks/ShadowsocksR link which contains a Group Name, press Enter to skip.\nCustom Group Name: "}, {SPEEDTEST_MESSAGE_GOTSERVER, "\nCurrent Server Group: ?group? Remarks: ?remarks? Index: ?index?/?total?\n"}, {SPEEDTEST_MESSAGE_STARTPING, "Now performing TCP Ping...\n"}, {SPEEDTEST_MESSAGE_STARTGEOIP, "Now performing GeoIP parse...\n"}, {SPEEDTEST_MESSAGE_STARTGPING, "Now performing Google Ping...\n"}, {SPEEDTEST_MESSAGE_STARTSPEED, "Now performing Speed Test...\n"}, {SPEEDTEST_MESSAGE_STARTUPD, "Now performing Upload Test...\n"}, {SPEEDTEST_MESSAGE_GOTRESULT, "Result: DL.Speed: ?speed? Max.Speed: ?maxspeed? UL.Speed: ?ulspeed? Pk.Loss: ?pkloss? Avg.Ping: ?avgping? Google Ping: ?siteping?\n"}, {SPEEDTEST_MESSAGE_TRAFFIC, "Traffic used: ?traffic?\n"}, {SPEEDTEST_MESSAGE_PICSAVING, "Now exporting picture...\n"}, {SPEEDTEST_MESSAGE_PICSAVINGMULTI, "Now exporting picture for group ?id?...\n"}, {SPEEDTEST_MESSAGE_PICSAVED, "Result picture saved to \"?picpath?\".\n"}, {SPEEDTEST_MESSAGE_PICSAVEDMULTI, "Group ?id? result picture saved to \"?picpath?\".\n"}, {SPEEDTEST_MESSAGE_FETCHSUB, "Downloading subscription data...\n"}, {SPEEDTEST_MESSAGE_PARSING, "Parsing configuration file...\n"}, {SPEEDTEST_MESSAGE_BEGIN, "Speed Test will now begin.\n"}, {SPEEDTEST_MESSAGE_GOTGEOIP, "Parsed outbound server ISP: ?isp? Country Code: ?location?\n"}, {SPEEDTEST_ERROR_UNDEFINED, "Undefined error!\n"}, {SPEEDTEST_ERROR_WSAERR, "WSA Startup error!\n"}, {SPEEDTEST_ERROR_SOCKETERR, "Socket error!\n"}, {SPEEDTEST_ERROR_NORECOGLINK, "No valid link found. Please check your link.\n"}, {SPEEDTEST_ERROR_UNRECOGFILE, "This configure file is invalid. Please make sure this is an Shadowsocks/ShadowsocksR/v2rayN configuration file or a standard subscription file.\n"}, {SPEEDTEST_ERROR_NOCONNECTION, "Cannot connect to server.\n"}, {SPEEDTEST_ERROR_INVALIDSUB, "Nothing returned from subscribe link. Please check your subscribe link.\n"}, {SPEEDTEST_ERROR_NONODES, "No nodes found. Please check your subscribe link.\n"}, {SPEEDTEST_ERROR_NORESOLVE, "Cannot resolve server address.\n"}, {SPEEDTEST_ERROR_RETEST, "Speed Test returned no speed. Retesting...\n"}, {SPEEDTEST_ERROR_NOSPEED, "Speed Test returned no speed 2 times. Skipping...\n"}, {SPEEDTEST_ERROR_SUBFETCHERR, "Cannot fetch subscription data with direct connect. Trying with system proxy...\n"}, {SPEEDTEST_ERROR_GEOIPERR, "Cannot fetch GeoIP information. Skipping...\n"}, {-1, ""} }; LOOKUP_ITEM SPEEDTEST_MESSAGES_RPC[] = { {SPEEDTEST_MESSAGE_WELCOME, "{\"info\":\"started\"}\n"}, {SPEEDTEST_MESSAGE_EOF, "{\"info\":\"eof\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDVMESS, "{\"info\":\"foundvmess\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSS, "{\"info\":\"foundss\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSSR, "{\"info\":\"foundssr\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSOCKS, "{\"info\":\"foundsocks\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSUB, "{\"info\":\"foundsub\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDLOCAL, "{\"info\":\"foundlocal\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDUPD, "{\"info\":\"foundupd\"}\n"}, {SPEEDTEST_MESSAGE_GOTSERVER, "{\"info\":\"gotserver\",\"id\":?id?,\"group\":\"?group?\",\"remarks\":\"?remarks?\"}\n"}, {SPEEDTEST_MESSAGE_STARTPING, "{\"info\":\"startping\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTPING, "{\"info\":\"gotping\",\"id\":?id?,\"ping\":\"?avgping?\",\"loss\":\"?pkloss?\"}\n"}, {SPEEDTEST_MESSAGE_STARTGEOIP, "{\"info\":\"startgeoip\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTGEOIP, "{\"info\":\"gotgeoip\",\"id\":?id?,\"isp\":\"?isp?\",\"location\":\"?location?\"}\n"}, {SPEEDTEST_MESSAGE_STARTSPEED, "{\"info\":\"startspeed\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTSPEED, "{\"info\":\"gotspeed\",\"id\":?id?,\"speed\":\"?speed?\",\"maxspeed\":\"?maxspeed?\"}\n"}, {SPEEDTEST_MESSAGE_STARTUPD, "{\"info\":\"startupd\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTUPD, "{\"info\":\"gotupd\",\"id\":?id?,\"ulspeed\":\"?ulspeed?\"}\n"}, {SPEEDTEST_MESSAGE_STARTGPING, "{\"info\":\"startgping\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTGPING, "{\"info\":\"gotgping\",\"id\":?id?,\"ping\":\"?siteping?\"}\n"}, {SPEEDTEST_MESSAGE_TRAFFIC, "(\"info\":\"traffic\",\"size\":\"?traffic?\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVING, "{\"info\":\"picsaving\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVED, "{\"info\":\"picsaved\",\"path\":\"?picpath?\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVEDMULTI, "{\"info\":\"picsaved\",\"path\":\"?picpath?\"}\n"}, {SPEEDTEST_MESSAGE_FETCHSUB, "{\"info\":\"fetchingsub\"}\n"}, {SPEEDTEST_MESSAGE_PARSING, "{\"info\":\"parsing\"}\n"}, {SPEEDTEST_MESSAGE_BEGIN, "{\"info\":\"begintest\"}\n"}, {SPEEDTEST_MESSAGE_PICDATA, "{\"info\":\"picdata\",\"data\":\"?data?\"}\n"}, {SPEEDTEST_ERROR_UNDEFINED, "{\"info\":\"error\",\"reason\":\"undef\"}\n"}, {SPEEDTEST_ERROR_WSAERR, "{\"info\":\"error\",\"reason\":\"wsaerr\"}\n"}, {SPEEDTEST_ERROR_SOCKETERR, "{\"info\":\"error\",\"reason\":\"socketerr\"}\n"}, {SPEEDTEST_ERROR_NORECOGLINK, "{\"info\":\"error\",\"reason\":\"norecoglink\"}\n"}, {SPEEDTEST_ERROR_UNRECOGFILE, "{\"info\":\"error\",\"reason\":\"unrecogfile\"}\n"}, {SPEEDTEST_ERROR_NOCONNECTION, "{\"info\":\"error\",\"reason\":\"noconnection\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_INVALIDSUB, "{\"info\":\"error\",\"reason\":\"invalidsub\"}\n"}, {SPEEDTEST_ERROR_NONODES, "{\"info\":\"error\",\"reason\":\"nonodes\"}\n"}, {SPEEDTEST_ERROR_NORESOLVE, "{\"info\":\"error\",\"reason\":\"noresolve\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_RETEST, "{\"info\":\"error\",\"reason\":\"retest\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_NOSPEED, "{\"info\":\"error\",\"reason\":\"nospeed\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_SUBFETCHERR, "{\"info\":\"error\",\"reason\":\"subfetcherr\"}\n"}, {SPEEDTEST_ERROR_GEOIPERR, "{\"info\":\"error\",\"reason\":\"geoiperr\",\"id\":?id?}\n"}, {-1, ""} }; string lookUp(int index, LOOKUP_ITEM *items) { int i = 0; while (0 <= items[i].index) { if (items[i].index == index) return items[i].info; i++; } return string(""); } string lookUp(int index, bool rpcmode) { if(rpcmode) { return lookUp(index, SPEEDTEST_MESSAGES_RPC); } else { return lookUp(index, SPEEDTEST_MESSAGES); } } void printMsg(int index, nodeInfo *node, bool rpcmode) { string printout; printout = lookUp(index, rpcmode); if(printout.size() == 0) { return; } printout = replace_all_distinct(printout, "?group?", trim(node->group)); printout = replace_all_distinct(printout, "?remarks?", trim(node->remarks)); printout = replace_all_distinct(printout, "?id?", to_string(node->id)); printout = replace_all_distinct(printout, "?avgping?", node->avgPing); printout = replace_all_distinct(printout, "?pkloss?", node->pkLoss); printout = replace_all_distinct(printout, "?siteping?", node->sitePing); printout = replace_all_distinct(printout, "?speed?", node->avgSpeed); printout = replace_all_distinct(printout, "?maxspeed?", node->maxSpeed); printout = replace_all_distinct(printout, "?ulspeed?", node->ulSpeed); printout = replace_all_distinct(printout, "?traffic?", node->traffic); if(rpcmode) printout = replace_all_distinct(printout, "\\", "\\\\"); cout<<printout; cout.clear(); cout.flush(); } void printMsgWithDict(int index, bool rpcmode, vector<string> dict, vector<string> trans) { string printout; printout = lookUp(index, rpcmode); if(printout.size() == 0) { return; } for(unsigned int i = 0; i < dict.size(); i++) { printout = replace_all_distinct(printout, dict[i], trans[i]); } if(rpcmode) printout = replace_all_distinct(printout, "\\", "\\\\"); cout<<printout; cout.clear(); cout.flush(); } void printMsgDirect(int index, bool rpcmode) { cout<<lookUp(index, rpcmode); cout.clear(); cout.flush(); }
96eac3462d7af7dbf335defbc10d3bfc4dfbf450
2dcd06afb36378652c851c713e323681d0679242
/Source/effectpattern.cpp
ac2b95d8b2278d66048612fe3e9278049416c403
[]
no_license
LightInMotion/NativeTest
186df26c808a5667434fe8c895bef1ae75ac9b5a
bc6957238a97d120840aa355012f40169811ab70
refs/heads/master
2021-01-10T19:55:50.110959
2016-09-08T23:03:30
2016-09-08T23:03:30
3,811,690
0
0
null
null
null
null
UTF-8
C++
false
false
5,460
cpp
/* Module Description: This module is an 'effect pattern', basically a shape scanned by the effect class. It knows how to load itself from a filename, or from an istream. Effect is a 'friend' because the actual coordinate pairs are fetched directly for speed. */ // Includes .................................................................. #include "EffectPattern.h" // Local Defines ............................................................. // effect file versions. const uint32 _EFFECT_FILE_VERSION_1_00 = 0x0100; // current version const uint32 _EFFECT_FILE_VERSION_CURRENT = _EFFECT_FILE_VERSION_1_00; // Local Data Types .......................................................... // Local Data ................................................................ // Public Interface .......................................................... /* A pattern is asked to load itself from disk here. */ /*---------------------------------------------------------------------------- EffectPattern::EffectPatLoad Load an individual pattern from a file Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::EffectPatLoad (String file) { bool result = false; ShowFile show (file); if (show.open()) { // If we got here, it is structured storage and // is supposed to be an EffectFile // Try to read the info and points if (VerifyVersion(show) == true) if (ReadInfo (show) == true) if (ReadPoints (show) == true) result = true; show.close(); } return result; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetGuid Fetch the GUID for a pattern ----------------------------------------------------------------------------*/ void EffectPattern::EffectPatGetGuid (Uuid &guid ) // OUT: Guid to retrieve { guid = m_Guid; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetName Fetch the Name for a pattern ----------------------------------------------------------------------------*/ String EffectPattern::EffectPatGetName () { return m_Name; } // Effect File Helpers ....................................................... /* This bundles up the structured storage stuff and version checking, etc. for effect files */ /*---------------------------------------------------------------------------- EffectPattern::VerifyVersion read the effect version from the structore storage file and verify that it is the correct version. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::VerifyVersion (ShowFile& show) { bool result = false; // Save Path String oldpath = show.getPath(); // open version stream if (show.setPath (oldpath + "EffectX1")) { // load effect file version uint32 fileVersion = 0; if (show.readDword (fileVersion)) { // verify the version. Currently we have only one effect file // version and we don't support any other version. // Should we change the file format in a later version then we // have to be able to load new and old versions. if (fileVersion == _EFFECT_FILE_VERSION_CURRENT) result = true; } } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadInfo Get the GUID, name, and count from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadInfo (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Info")) { do { // Load the GUID if (! show.readGuid(m_Guid)) break; // Load the Count if (! show.readShort(m_EffectPatCount) || m_EffectPatCount != EFFECT_PAT_MAX_POINT) break; // Read the name if (! show.readString (m_Name)) break; result = true; } while (0); } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadPoints Get the data points from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadPoints (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Points")) { uint32 bread; // Load the Points int count = sizeof(EffectPoint) * m_EffectPatCount; if (show.readBytes ((uint8*)(&m_EffectPatData), count, bread) && bread == (uint32)count) result = true; } show.setPath (oldpath); return result; }
4493f84051a862b7a4b6422ec4753feeb3476e6d
898d9b3afbb20aa1354873ef1314760732bfc7d0
/avenue/server_connection.cpp
8f0cdddcf596ae2cd7afd8a5bcb6c9055e40407b
[ "MIT" ]
permissive
Aiyowoo/im
cafc74b119f85f09a857e369fff8c6b371c7b86c
d510275d1cc83b2748cb675e99dacbbf04616fb5
refs/heads/master
2020-05-07T19:13:16.772434
2019-05-08T16:12:05
2019-05-08T16:12:05
180,802,881
0
0
null
null
null
null
GB18030
C++
false
false
1,557
cpp
// server_connection.cpp // Created by m8792 on 2019/4/24. // 2019/4/24 22:17 #include "server_connection.hpp" #include "details/log_helper.hpp" namespace asio = boost::asio; namespace ssl = boost::asio::ssl; namespace avenue { server_connection::server_connection(boost::asio::ip::tcp::socket &socket, boost::asio::ssl::context &ssl_context) : message_connection(socket, ssl_context) { } void server_connection::run() { INFO_LOG("start to run..."); set_running(true); stream().async_handshake(ssl::stream_base::handshake_type::server, [this, self = shared_from_base()](boost::system::error_code ec) { if (ec) { status s(ec.value(), fmt::format("failed to handshake with client due to error[{}]", ec.message())); handle_initialize_error(s); return; } initialize(); }); } std::shared_ptr<server_connection> server_connection::shared_from_base() { return std::dynamic_pointer_cast<server_connection>(shared_from_this()); } void server_connection::handle_initialize_error(const status& error) { // 已经不再运行了 set_running(false); // fixme: 是否需要关闭socket连接 on_initialized(error); } }
ceb46a0de8c5b66f5e8fff49deeda7d1e9b98be6
e104892af303d85c5e661d099b500dc1e35b882d
/Sample4_12/app/src/main/cpp/bndev/MyVulkanManager.h
0a29bf3df0403a1e89773e0d81670d32418d2646
[ "Unlicense" ]
permissive
siwangqishiq/Vulkan_Develpment_Samples
624900dabaca75c9ad21ef5a1ee5af6709dcc9a8
409c973e0b37086c854cde07b1e620c3d8d9f15d
refs/heads/master
2023-08-16T04:13:54.777841
2021-10-14T06:53:11
2021-10-14T06:53:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,603
h
#ifndef VULKANEXBASE_MYVULKANMANAGER_H #define VULKANEXBASE_MYVULKANMANAGER_H #include <android_native_app_glue.h> #include <vector> #include <vulkan/vulkan.h> #include "../vksysutil/vulkan_wrapper.h" #include <vector> #include "mylog.h" #include "DrawableObjectCommon.h" #include "ShaderQueueSuit_Common.h" #include "Cube.h" #define FENCE_TIMEOUT 100000000 class MyVulkanManager { public: public: static android_app* Android_application; static bool loopDrawFlag; static std::vector<const char *> instanceExtensionNames; static VkInstance instance; static uint32_t gpuCount; static std::vector<VkPhysicalDevice> gpus; static uint32_t queueFamilyCount; static std::vector<VkQueueFamilyProperties> queueFamilyprops; static uint32_t queueGraphicsFamilyIndex; static VkQueue queueGraphics; static uint32_t queuePresentFamilyIndex; static std::vector<const char *> deviceExtensionNames; static VkDevice device; static VkCommandPool cmdPool; static VkCommandBuffer cmdBuffer; static VkCommandBufferBeginInfo cmd_buf_info; static VkCommandBuffer cmd_bufs[1]; static VkSubmitInfo submit_info[1]; static uint32_t screenWidth; static uint32_t screenHeight; static VkSurfaceKHR surface; static std::vector<VkFormat> formats; static VkSurfaceCapabilitiesKHR surfCapabilities; static uint32_t presentModeCount; static std::vector<VkPresentModeKHR> presentModes; static VkExtent2D swapchainExtent; static VkSwapchainKHR swapChain; static uint32_t swapchainImageCount; static std::vector<VkImage> swapchainImages; static std::vector<VkImageView> swapchainImageViews; static VkFormat depthFormat; static VkFormatProperties depthFormatProps; static VkImage depthImage; static VkPhysicalDeviceMemoryProperties memoryroperties; static VkDeviceMemory memDepth; static VkImageView depthImageView; static VkSemaphore imageAcquiredSemaphore; static uint32_t currentBuffer; static VkRenderPass renderPass; static VkClearValue clear_values[2]; static VkRenderPassBeginInfo rp_begin; static VkFence taskFinishFence; static VkPresentInfoKHR present; static VkFramebuffer* framebuffers; static ShaderQueueSuit_Common* sqsCL; //绘制用对象 static Cube* cube1ForDraw; static Cube* cube2ForDraw; //三角形旋转角度 static float zAngle; static float yAngle; //两种视角标志位 static int ProjectPara; static void init_vulkan_instance(); static void enumerate_vulkan_phy_devices(); static void create_vulkan_devices(); static void create_vulkan_CommandBuffer(); static void create_vulkan_swapChain(); static void create_vulkan_DepthBuffer(); static void create_render_pass(); static void init_queue(); static void create_frame_buffer(); static void createDrawableObject(); static void drawObject(); static void doVulkan(); static void initPipeline(); static void createFence(); static void initPresentInfo(); static void initMatrix(); static void flushUniformBuffer(); static void flushTexToDesSet(); static void destroyFence(); static void destroyPipeline(); static void destroyDrawableObject(); static void destroy_frame_buffer(); static void destroy_render_pass(); static void destroy_vulkan_DepthBuffer(); static void destroy_vulkan_swapChain(); static void destroy_vulkan_CommandBuffer(); static void destroy_vulkan_devices(); static void destroy_vulkan_instance(); }; #endif
7a5ac76848e1eb05658b9463968878209af26d51
0ed1b441759ef92872821a07f6c6cff04094e390
/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
eca774ead93531ec6b4f94b5909439396f89f62e
[ "NCSA" ]
permissive
sslab-gatech/caver
651dd1e404c03a9568ef512164c98e918821c9e8
81363a7d0581d99fe216c4394294b0a2372f08eb
refs/heads/master
2021-01-10T03:43:56.533854
2015-10-13T18:23:15
2015-10-13T18:23:15
44,137,365
30
10
null
null
null
null
UTF-8
C++
false
false
37,374
cpp
//===-- PPCRegisterInfo.cpp - PowerPC Register Information ----------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file contains the PowerPC implementation of the TargetRegisterInfo // class. // //===----------------------------------------------------------------------===// #include "PPCRegisterInfo.h" #include "PPC.h" #include "PPCFrameLowering.h" #include "PPCInstrBuilder.h" #include "PPCMachineFunctionInfo.h" #include "PPCSubtarget.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" #include "llvm/IR/Type.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetFrameLowering.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include <cstdlib> using namespace llvm; #define DEBUG_TYPE "reginfo" #define GET_REGINFO_TARGET_DESC #include "PPCGenRegisterInfo.inc" static cl::opt<bool> EnableBasePointer("ppc-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames")); static cl::opt<bool> AlwaysBasePointer("ppc-always-use-base-pointer", cl::Hidden, cl::init(false), cl::desc("Force the use of a base pointer in every function")); PPCRegisterInfo::PPCRegisterInfo(const PPCSubtarget &ST) : PPCGenRegisterInfo(ST.isPPC64() ? PPC::LR8 : PPC::LR, ST.isPPC64() ? 0 : 1, ST.isPPC64() ? 0 : 1), Subtarget(ST) { ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX; ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX; ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX; ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX; ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX; ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX; ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX; ImmToIdxMap[PPC::ADDI] = PPC::ADD4; ImmToIdxMap[PPC::LWA_32] = PPC::LWAX_32; // 64-bit ImmToIdxMap[PPC::LHA8] = PPC::LHAX8; ImmToIdxMap[PPC::LBZ8] = PPC::LBZX8; ImmToIdxMap[PPC::LHZ8] = PPC::LHZX8; ImmToIdxMap[PPC::LWZ8] = PPC::LWZX8; ImmToIdxMap[PPC::STB8] = PPC::STBX8; ImmToIdxMap[PPC::STH8] = PPC::STHX8; ImmToIdxMap[PPC::STW8] = PPC::STWX8; ImmToIdxMap[PPC::STDU] = PPC::STDUX; ImmToIdxMap[PPC::ADDI8] = PPC::ADD8; } /// getPointerRegClass - Return the register class to use to hold pointers. /// This is used for addressing modes. const TargetRegisterClass * PPCRegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind) const { // Note that PPCInstrInfo::FoldImmediate also directly uses this Kind value // when it checks for ZERO folding. if (Kind == 1) { if (Subtarget.isPPC64()) return &PPC::G8RC_NOX0RegClass; return &PPC::GPRC_NOR0RegClass; } if (Subtarget.isPPC64()) return &PPC::G8RCRegClass; return &PPC::GPRCRegClass; } const MCPhysReg* PPCRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { if (Subtarget.isDarwinABI()) return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_Darwin64_Altivec_SaveList : CSR_Darwin64_SaveList) : (Subtarget.hasAltivec() ? CSR_Darwin32_Altivec_SaveList : CSR_Darwin32_SaveList); return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_SVR464_Altivec_SaveList : CSR_SVR464_SaveList) : (Subtarget.hasAltivec() ? CSR_SVR432_Altivec_SaveList : CSR_SVR432_SaveList); } const uint32_t* PPCRegisterInfo::getCallPreservedMask(CallingConv::ID CC) const { if (Subtarget.isDarwinABI()) return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_Darwin64_Altivec_RegMask : CSR_Darwin64_RegMask) : (Subtarget.hasAltivec() ? CSR_Darwin32_Altivec_RegMask : CSR_Darwin32_RegMask); return Subtarget.isPPC64() ? (Subtarget.hasAltivec() ? CSR_SVR464_Altivec_RegMask : CSR_SVR464_RegMask) : (Subtarget.hasAltivec() ? CSR_SVR432_Altivec_RegMask : CSR_SVR432_RegMask); } const uint32_t* PPCRegisterInfo::getNoPreservedMask() const { return CSR_NoRegs_RegMask; } BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const { BitVector Reserved(getNumRegs()); const PPCFrameLowering *PPCFI = static_cast<const PPCFrameLowering*>(MF.getTarget().getFrameLowering()); // The ZERO register is not really a register, but the representation of r0 // when used in instructions that treat r0 as the constant 0. Reserved.set(PPC::ZERO); Reserved.set(PPC::ZERO8); // The FP register is also not really a register, but is the representation // of the frame pointer register used by ISD::FRAMEADDR. Reserved.set(PPC::FP); Reserved.set(PPC::FP8); // The BP register is also not really a register, but is the representation // of the base pointer register used by setjmp. Reserved.set(PPC::BP); Reserved.set(PPC::BP8); // The counter registers must be reserved so that counter-based loops can // be correctly formed (and the mtctr instructions are not DCE'd). Reserved.set(PPC::CTR); Reserved.set(PPC::CTR8); Reserved.set(PPC::R1); Reserved.set(PPC::LR); Reserved.set(PPC::LR8); Reserved.set(PPC::RM); if (!Subtarget.isDarwinABI() || !Subtarget.hasAltivec()) Reserved.set(PPC::VRSAVE); // The SVR4 ABI reserves r2 and r13 if (Subtarget.isSVR4ABI()) { Reserved.set(PPC::R2); // System-reserved register Reserved.set(PPC::R13); // Small Data Area pointer register } // On PPC64, r13 is the thread pointer. Never allocate this register. if (Subtarget.isPPC64()) { Reserved.set(PPC::R13); Reserved.set(PPC::X1); Reserved.set(PPC::X13); if (PPCFI->needsFP(MF)) Reserved.set(PPC::X31); if (hasBasePointer(MF)) Reserved.set(PPC::X30); // The 64-bit SVR4 ABI reserves r2 for the TOC pointer. if (Subtarget.isSVR4ABI()) { Reserved.set(PPC::X2); } } if (PPCFI->needsFP(MF)) Reserved.set(PPC::R31); if (hasBasePointer(MF)) Reserved.set(PPC::R30); // Reserve Altivec registers when Altivec is unavailable. if (!Subtarget.hasAltivec()) for (TargetRegisterClass::iterator I = PPC::VRRCRegClass.begin(), IE = PPC::VRRCRegClass.end(); I != IE; ++I) Reserved.set(*I); return Reserved; } unsigned PPCRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const { const TargetFrameLowering *TFI = MF.getTarget().getFrameLowering(); const unsigned DefaultSafety = 1; switch (RC->getID()) { default: return 0; case PPC::G8RC_NOX0RegClassID: case PPC::GPRC_NOR0RegClassID: case PPC::G8RCRegClassID: case PPC::GPRCRegClassID: { unsigned FP = TFI->hasFP(MF) ? 1 : 0; return 32 - FP - DefaultSafety; } case PPC::F8RCRegClassID: case PPC::F4RCRegClassID: case PPC::VRRCRegClassID: case PPC::VFRCRegClassID: case PPC::VSLRCRegClassID: case PPC::VSHRCRegClassID: return 32 - DefaultSafety; case PPC::VSRCRegClassID: case PPC::VSFRCRegClassID: return 64 - DefaultSafety; case PPC::CRRCRegClassID: return 8 - DefaultSafety; } } const TargetRegisterClass* PPCRegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC)const { if (Subtarget.hasVSX()) { // With VSX, we can inflate various sub-register classes to the full VSX // register set. if (RC == &PPC::F8RCRegClass) return &PPC::VSFRCRegClass; else if (RC == &PPC::VRRCRegClass) return &PPC::VSRCRegClass; } return TargetRegisterInfo::getLargestLegalSuperClass(RC); } //===----------------------------------------------------------------------===// // Stack Frame Processing methods //===----------------------------------------------------------------------===// /// lowerDynamicAlloc - Generate the code for allocating an object in the /// current frame. The sequence of code with be in the general form /// /// addi R0, SP, \#frameSize ; get the address of the previous frame /// stwxu R0, SP, Rnegsize ; add and update the SP with the negated size /// addi Rnew, SP, \#maxCalFrameSize ; get the top of the allocation /// void PPCRegisterInfo::lowerDynamicAlloc(MachineBasicBlock::iterator II) const { // Get the instruction. MachineInstr &MI = *II; // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); // Get the basic block's function. MachineFunction &MF = *MBB.getParent(); // Get the frame info. MachineFrameInfo *MFI = MF.getFrameInfo(); // Get the instruction info. const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); // Determine whether 64-bit pointers are used. bool LP64 = Subtarget.isPPC64(); DebugLoc dl = MI.getDebugLoc(); // Get the maximum call stack size. unsigned maxCallFrameSize = MFI->getMaxCallFrameSize(); // Get the total frame size. unsigned FrameSize = MFI->getStackSize(); // Get stack alignments. unsigned TargetAlign = MF.getTarget().getFrameLowering()->getStackAlignment(); unsigned MaxAlign = MFI->getMaxAlignment(); assert((maxCallFrameSize & (MaxAlign-1)) == 0 && "Maximum call-frame size not sufficiently aligned"); // Determine the previous frame's address. If FrameSize can't be // represented as 16 bits or we need special alignment, then we load the // previous frame's address from 0(SP). Why not do an addis of the hi? // Because R0 is our only safe tmp register and addi/addis treat R0 as zero. // Constructing the constant and adding would take 3 instructions. // Fortunately, a frame greater than 32K is rare. const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); if (MaxAlign < TargetAlign && isInt<16>(FrameSize)) { BuildMI(MBB, II, dl, TII.get(PPC::ADDI), Reg) .addReg(PPC::R31) .addImm(FrameSize); } else if (LP64) { BuildMI(MBB, II, dl, TII.get(PPC::LD), Reg) .addImm(0) .addReg(PPC::X1); } else { BuildMI(MBB, II, dl, TII.get(PPC::LWZ), Reg) .addImm(0) .addReg(PPC::R1); } bool KillNegSizeReg = MI.getOperand(1).isKill(); unsigned NegSizeReg = MI.getOperand(1).getReg(); // Grow the stack and update the stack pointer link, then determine the // address of new allocated space. if (LP64) { if (MaxAlign > TargetAlign) { unsigned UnalNegSizeReg = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(G8RC); // Unfortunately, there is no andi, only andi., and we can't insert that // here because we might clobber cr0 while it is live. BuildMI(MBB, II, dl, TII.get(PPC::LI8), NegSizeReg) .addImm(~(MaxAlign-1)); unsigned NegSizeReg1 = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(G8RC); BuildMI(MBB, II, dl, TII.get(PPC::AND8), NegSizeReg) .addReg(UnalNegSizeReg, getKillRegState(KillNegSizeReg)) .addReg(NegSizeReg1, RegState::Kill); KillNegSizeReg = true; } BuildMI(MBB, II, dl, TII.get(PPC::STDUX), PPC::X1) .addReg(Reg, RegState::Kill) .addReg(PPC::X1) .addReg(NegSizeReg, getKillRegState(KillNegSizeReg)); BuildMI(MBB, II, dl, TII.get(PPC::ADDI8), MI.getOperand(0).getReg()) .addReg(PPC::X1) .addImm(maxCallFrameSize); } else { if (MaxAlign > TargetAlign) { unsigned UnalNegSizeReg = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(GPRC); // Unfortunately, there is no andi, only andi., and we can't insert that // here because we might clobber cr0 while it is live. BuildMI(MBB, II, dl, TII.get(PPC::LI), NegSizeReg) .addImm(~(MaxAlign-1)); unsigned NegSizeReg1 = NegSizeReg; NegSizeReg = MF.getRegInfo().createVirtualRegister(GPRC); BuildMI(MBB, II, dl, TII.get(PPC::AND), NegSizeReg) .addReg(UnalNegSizeReg, getKillRegState(KillNegSizeReg)) .addReg(NegSizeReg1, RegState::Kill); KillNegSizeReg = true; } BuildMI(MBB, II, dl, TII.get(PPC::STWUX), PPC::R1) .addReg(Reg, RegState::Kill) .addReg(PPC::R1) .addReg(NegSizeReg, getKillRegState(KillNegSizeReg)); BuildMI(MBB, II, dl, TII.get(PPC::ADDI), MI.getOperand(0).getReg()) .addReg(PPC::R1) .addImm(maxCallFrameSize); } // Discard the DYNALLOC instruction. MBB.erase(II); } /// lowerCRSpilling - Generate the code for spilling a CR register. Instead of /// reserving a whole register (R0), we scrounge for one here. This generates /// code like this: /// /// mfcr rA ; Move the conditional register into GPR rA. /// rlwinm rA, rA, SB, 0, 31 ; Shift the bits left so they are in CR0's slot. /// stw rA, FI ; Store rA to the frame. /// void PPCRegisterInfo::lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_CR <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); // We need to store the CR in the low 4-bits of the saved value. First, issue // an MFOCRF to save all of the CRBits and, if needed, kill the SrcReg. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); // If the saved register wasn't CR0, shift the bits left so that they are in // CR0's slot. if (SrcReg != PPC::CR0) { unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); // rlwinm rA, rA, ShiftBits, 0, 31. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill) .addImm(getEncodingValue(SrcReg) * 4) .addImm(0) .addImm(31); } addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::STW8 : PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_CR <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_CR does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::LWZ8 : PPC::LWZ), Reg), FrameIndex); // If the reloaded register isn't CR0, shift the bits right so that they are // in the right CR's slot. if (DestReg != PPC::CR0) { unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned ShiftBits = getEncodingValue(DestReg)*4; // rlwinm r11, r11, 32-ShiftBits, 0, 31. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill).addImm(32-ShiftBits).addImm(0) .addImm(31); } BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), DestReg) .addReg(Reg, RegState::Kill); // Discard the pseudo instruction. MBB.erase(II); } static unsigned getCRFromCRBit(unsigned SrcReg) { unsigned Reg = 0; if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR0GT || SrcReg == PPC::CR0EQ || SrcReg == PPC::CR0UN) Reg = PPC::CR0; else if (SrcReg == PPC::CR1LT || SrcReg == PPC::CR1GT || SrcReg == PPC::CR1EQ || SrcReg == PPC::CR1UN) Reg = PPC::CR1; else if (SrcReg == PPC::CR2LT || SrcReg == PPC::CR2GT || SrcReg == PPC::CR2EQ || SrcReg == PPC::CR2UN) Reg = PPC::CR2; else if (SrcReg == PPC::CR3LT || SrcReg == PPC::CR3GT || SrcReg == PPC::CR3EQ || SrcReg == PPC::CR3UN) Reg = PPC::CR3; else if (SrcReg == PPC::CR4LT || SrcReg == PPC::CR4GT || SrcReg == PPC::CR4EQ || SrcReg == PPC::CR4UN) Reg = PPC::CR4; else if (SrcReg == PPC::CR5LT || SrcReg == PPC::CR5GT || SrcReg == PPC::CR5EQ || SrcReg == PPC::CR5UN) Reg = PPC::CR5; else if (SrcReg == PPC::CR6LT || SrcReg == PPC::CR6GT || SrcReg == PPC::CR6EQ || SrcReg == PPC::CR6UN) Reg = PPC::CR6; else if (SrcReg == PPC::CR7LT || SrcReg == PPC::CR7GT || SrcReg == PPC::CR7EQ || SrcReg == PPC::CR7UN) Reg = PPC::CR7; assert(Reg != 0 && "Invalid CR bit register"); return Reg; } void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_CRBIT <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); BuildMI(MBB, II, dl, TII.get(TargetOpcode::KILL), getCRFromCRBit(SrcReg)) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg) .addReg(getCRFromCRBit(SrcReg)); // If the saved register wasn't CR0LT, shift the bits left so that the bit to // store is the first one. Mask all but that bit. unsigned Reg1 = Reg; Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); // rlwinm rA, rA, ShiftBits, 0, 0. BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWINM8 : PPC::RLWINM), Reg) .addReg(Reg1, RegState::Kill) .addImm(getEncodingValue(SrcReg)) .addImm(0).addImm(0); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::STW8 : PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerCRBitRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_CRBIT <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); bool LP64 = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_CRBIT does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::LWZ8 : PPC::LWZ), Reg), FrameIndex); BuildMI(MBB, II, dl, TII.get(TargetOpcode::IMPLICIT_DEF), DestReg); unsigned RegO = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), RegO) .addReg(getCRFromCRBit(DestReg)); unsigned ShiftBits = getEncodingValue(DestReg); // rlwimi r11, r10, 32-ShiftBits, ..., ... BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::RLWIMI8 : PPC::RLWIMI), RegO) .addReg(RegO, RegState::Kill).addReg(Reg, RegState::Kill) .addImm(ShiftBits ? 32-ShiftBits : 0) .addImm(ShiftBits).addImm(ShiftBits); BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), getCRFromCRBit(DestReg)) .addReg(RegO, RegState::Kill) // Make sure we have a use dependency all the way through this // sequence of instructions. We can't have the other bits in the CR // modified in between the mfocrf and the mtocrf. .addReg(getCRFromCRBit(DestReg), RegState::Implicit); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerVRSAVESpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; SPILL_VRSAVE <SrcReg>, <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(GPRC); unsigned SrcReg = MI.getOperand(0).getReg(); BuildMI(MBB, II, dl, TII.get(PPC::MFVRSAVEv), Reg) .addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill())); addFrameReference(BuildMI(MBB, II, dl, TII.get(PPC::STW)) .addReg(Reg, RegState::Kill), FrameIndex); // Discard the pseudo instruction. MBB.erase(II); } void PPCRegisterInfo::lowerVRSAVERestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const { // Get the instruction. MachineInstr &MI = *II; // ; <DestReg> = RESTORE_VRSAVE <offset> // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = MI.getDebugLoc(); const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; unsigned Reg = MF.getRegInfo().createVirtualRegister(GPRC); unsigned DestReg = MI.getOperand(0).getReg(); assert(MI.definesRegister(DestReg) && "RESTORE_VRSAVE does not define its destination"); addFrameReference(BuildMI(MBB, II, dl, TII.get(PPC::LWZ), Reg), FrameIndex); BuildMI(MBB, II, dl, TII.get(PPC::MTVRSAVEv), DestReg) .addReg(Reg, RegState::Kill); // Discard the pseudo instruction. MBB.erase(II); } bool PPCRegisterInfo::hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const { // For the nonvolatile condition registers (CR2, CR3, CR4) in an SVR4 // ABI, return true to prevent allocating an additional frame slot. // For 64-bit, the CR save area is at SP+8; the value of FrameIdx = 0 // is arbitrary and will be subsequently ignored. For 32-bit, we have // previously created the stack slot if needed, so return its FrameIdx. if (Subtarget.isSVR4ABI() && PPC::CR2 <= Reg && Reg <= PPC::CR4) { if (Subtarget.isPPC64()) FrameIdx = 0; else { const PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>(); FrameIdx = FI->getCRSpillFrameIndex(); } return true; } return false; } // Figure out if the offset in the instruction must be a multiple of 4. // This is true for instructions like "STD". static bool usesIXAddr(const MachineInstr &MI) { unsigned OpC = MI.getOpcode(); switch (OpC) { default: return false; case PPC::LWA: case PPC::LWA_32: case PPC::LD: case PPC::STD: return true; } } // Return the OffsetOperandNo given the FIOperandNum (and the instruction). static unsigned getOffsetONFromFION(const MachineInstr &MI, unsigned FIOperandNum) { // Take into account whether it's an add or mem instruction unsigned OffsetOperandNo = (FIOperandNum == 2) ? 1 : 2; if (MI.isInlineAsm()) OffsetOperandNo = FIOperandNum-1; return OffsetOperandNo; } void PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const { assert(SPAdj == 0 && "Unexpected"); // Get the instruction. MachineInstr &MI = *II; // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); // Get the basic block's function. MachineFunction &MF = *MBB.getParent(); // Get the instruction info. const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); // Get the frame info. MachineFrameInfo *MFI = MF.getFrameInfo(); DebugLoc dl = MI.getDebugLoc(); unsigned OffsetOperandNo = getOffsetONFromFION(MI, FIOperandNum); // Get the frame index. int FrameIndex = MI.getOperand(FIOperandNum).getIndex(); // Get the frame pointer save index. Users of this index are primarily // DYNALLOC instructions. PPCFunctionInfo *FI = MF.getInfo<PPCFunctionInfo>(); int FPSI = FI->getFramePointerSaveIndex(); // Get the instruction opcode. unsigned OpC = MI.getOpcode(); // Special case for dynamic alloca. if (FPSI && FrameIndex == FPSI && (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) { lowerDynamicAlloc(II); return; } // Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc. if (OpC == PPC::SPILL_CR) { lowerCRSpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_CR) { lowerCRRestore(II, FrameIndex); return; } else if (OpC == PPC::SPILL_CRBIT) { lowerCRBitSpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_CRBIT) { lowerCRBitRestore(II, FrameIndex); return; } else if (OpC == PPC::SPILL_VRSAVE) { lowerVRSAVESpilling(II, FrameIndex); return; } else if (OpC == PPC::RESTORE_VRSAVE) { lowerVRSAVERestore(II, FrameIndex); return; } // Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP). MI.getOperand(FIOperandNum).ChangeToRegister( FrameIndex < 0 ? getBaseRegister(MF) : getFrameRegister(MF), false); // Figure out if the offset in the instruction is shifted right two bits. bool isIXAddr = usesIXAddr(MI); // If the instruction is not present in ImmToIdxMap, then it has no immediate // form (and must be r+r). bool noImmForm = !MI.isInlineAsm() && !ImmToIdxMap.count(OpC); // Now add the frame object offset to the offset from r1. int Offset = MFI->getObjectOffset(FrameIndex); Offset += MI.getOperand(OffsetOperandNo).getImm(); // If we're not using a Frame Pointer that has been set to the value of the // SP before having the stack size subtracted from it, then add the stack size // to Offset to get the correct offset. // Naked functions have stack size 0, although getStackSize may not reflect that // because we didn't call all the pieces that compute it for naked functions. if (!MF.getFunction()->getAttributes(). hasAttribute(AttributeSet::FunctionIndex, Attribute::Naked)) { if (!(hasBasePointer(MF) && FrameIndex < 0)) Offset += MFI->getStackSize(); } // If we can, encode the offset directly into the instruction. If this is a // normal PPC "ri" instruction, any 16-bit value can be safely encoded. If // this is a PPC64 "ix" instruction, only a 16-bit value with the low two bits // clear can be encoded. This is extremely uncommon, because normally you // only "std" to a stack slot that is at least 4-byte aligned, but it can // happen in invalid code. assert(OpC != PPC::DBG_VALUE && "This should be handle in a target independent way"); if (!noImmForm && isInt<16>(Offset) && (!isIXAddr || (Offset & 3) == 0)) { MI.getOperand(OffsetOperandNo).ChangeToImmediate(Offset); return; } // The offset doesn't fit into a single register, scavenge one to build the // offset in. bool is64Bit = Subtarget.isPPC64(); const TargetRegisterClass *G8RC = &PPC::G8RCRegClass; const TargetRegisterClass *GPRC = &PPC::GPRCRegClass; const TargetRegisterClass *RC = is64Bit ? G8RC : GPRC; unsigned SRegHi = MF.getRegInfo().createVirtualRegister(RC), SReg = MF.getRegInfo().createVirtualRegister(RC); // Insert a set of rA with the full offset value before the ld, st, or add BuildMI(MBB, II, dl, TII.get(is64Bit ? PPC::LIS8 : PPC::LIS), SRegHi) .addImm(Offset >> 16); BuildMI(MBB, II, dl, TII.get(is64Bit ? PPC::ORI8 : PPC::ORI), SReg) .addReg(SRegHi, RegState::Kill) .addImm(Offset); // Convert into indexed form of the instruction: // // sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0 // addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0 unsigned OperandBase; if (noImmForm) OperandBase = 1; else if (OpC != TargetOpcode::INLINEASM) { assert(ImmToIdxMap.count(OpC) && "No indexed form of load or store available!"); unsigned NewOpcode = ImmToIdxMap.find(OpC)->second; MI.setDesc(TII.get(NewOpcode)); OperandBase = 1; } else { OperandBase = OffsetOperandNo; } unsigned StackReg = MI.getOperand(FIOperandNum).getReg(); MI.getOperand(OperandBase).ChangeToRegister(StackReg, false); MI.getOperand(OperandBase + 1).ChangeToRegister(SReg, false, false, true); } unsigned PPCRegisterInfo::getFrameRegister(const MachineFunction &MF) const { const TargetFrameLowering *TFI = MF.getTarget().getFrameLowering(); if (!Subtarget.isPPC64()) return TFI->hasFP(MF) ? PPC::R31 : PPC::R1; else return TFI->hasFP(MF) ? PPC::X31 : PPC::X1; } unsigned PPCRegisterInfo::getBaseRegister(const MachineFunction &MF) const { if (!hasBasePointer(MF)) return getFrameRegister(MF); return Subtarget.isPPC64() ? PPC::X30 : PPC::R30; } bool PPCRegisterInfo::hasBasePointer(const MachineFunction &MF) const { if (!EnableBasePointer) return false; if (AlwaysBasePointer) return true; // If we need to realign the stack, then the stack pointer can no longer // serve as an offset into the caller's stack space. As a result, we need a // base pointer. return needsStackRealignment(MF); } bool PPCRegisterInfo::canRealignStack(const MachineFunction &MF) const { if (MF.getFunction()->hasFnAttribute("no-realign-stack")) return false; return true; } bool PPCRegisterInfo::needsStackRealignment(const MachineFunction &MF) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); const Function *F = MF.getFunction(); unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment(); bool requiresRealignment = ((MFI->getMaxAlignment() > StackAlign) || F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, Attribute::StackAlignment)); return requiresRealignment && canRealignStack(MF); } /// Returns true if the instruction's frame index /// reference would be better served by a base register other than FP /// or SP. Used by LocalStackFrameAllocation to determine which frame index /// references it should create new base registers for. bool PPCRegisterInfo:: needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const { assert(Offset < 0 && "Local offset must be negative"); unsigned FIOperandNum = 0; while (!MI->getOperand(FIOperandNum).isFI()) { ++FIOperandNum; assert(FIOperandNum < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!"); } unsigned OffsetOperandNo = getOffsetONFromFION(*MI, FIOperandNum); Offset += MI->getOperand(OffsetOperandNo).getImm(); // It's the load/store FI references that cause issues, as it can be difficult // to materialize the offset if it won't fit in the literal field. Estimate // based on the size of the local frame and some conservative assumptions // about the rest of the stack frame (note, this is pre-regalloc, so // we don't know everything for certain yet) whether this offset is likely // to be out of range of the immediate. Return true if so. // We only generate virtual base registers for loads and stores that have // an r+i form. Return false for everything else. unsigned OpC = MI->getOpcode(); if (!ImmToIdxMap.count(OpC)) return false; // Don't generate a new virtual base register just to add zero to it. if ((OpC == PPC::ADDI || OpC == PPC::ADDI8) && MI->getOperand(2).getImm() == 0) return false; MachineBasicBlock &MBB = *MI->getParent(); MachineFunction &MF = *MBB.getParent(); const PPCFrameLowering *PPCFI = static_cast<const PPCFrameLowering*>(MF.getTarget().getFrameLowering()); unsigned StackEst = PPCFI->determineFrameLayout(MF, false, true); // If we likely don't need a stack frame, then we probably don't need a // virtual base register either. if (!StackEst) return false; // Estimate an offset from the stack pointer. // The incoming offset is relating to the SP at the start of the function, // but when we access the local it'll be relative to the SP after local // allocation, so adjust our SP-relative offset by that allocation size. Offset += StackEst; // The frame pointer will point to the end of the stack, so estimate the // offset as the difference between the object offset and the FP location. return !isFrameOffsetLegal(MI, Offset); } /// Insert defining instruction(s) for BaseReg to /// be a pointer to FrameIdx at the beginning of the basic block. void PPCRegisterInfo:: materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const { unsigned ADDriOpc = Subtarget.isPPC64() ? PPC::ADDI8 : PPC::ADDI; MachineBasicBlock::iterator Ins = MBB->begin(); DebugLoc DL; // Defaults to "unknown" if (Ins != MBB->end()) DL = Ins->getDebugLoc(); const MachineFunction &MF = *MBB->getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); const MCInstrDesc &MCID = TII.get(ADDriOpc); MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo(); MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0, this, MF)); BuildMI(*MBB, Ins, DL, MCID, BaseReg) .addFrameIndex(FrameIdx).addImm(Offset); } void PPCRegisterInfo::resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const { unsigned FIOperandNum = 0; while (!MI.getOperand(FIOperandNum).isFI()) { ++FIOperandNum; assert(FIOperandNum < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); } MI.getOperand(FIOperandNum).ChangeToRegister(BaseReg, false); unsigned OffsetOperandNo = getOffsetONFromFION(MI, FIOperandNum); Offset += MI.getOperand(OffsetOperandNo).getImm(); MI.getOperand(OffsetOperandNo).ChangeToImmediate(Offset); MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); const MCInstrDesc &MCID = MI.getDesc(); MachineRegisterInfo &MRI = MF.getRegInfo(); MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, FIOperandNum, this, MF)); } bool PPCRegisterInfo::isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const { return MI->getOpcode() == PPC::DBG_VALUE || // DBG_VALUE is always Reg+Imm (isInt<16>(Offset) && (!usesIXAddr(*MI) || (Offset & 3) == 0)); }
3c90a958fd46cd6c8c1ab273a6613ec5c435920b
8a45f1803d67e98aa59421981c95a5865d4dbf60
/cpp_16_classes/ch12_05_Friend_this.cpp
14f1a76f864b114d9f5003d1ee9965b5e323663f
[]
no_license
walter-cc/cpp
1a2e2f01692be15ad1224d6abe76c6b766d08fa4
36b5d184d7b4e69753750d5132e87754957f7d2a
refs/heads/master
2021-12-30T21:40:22.305507
2021-08-06T16:11:28
2021-08-06T16:13:21
162,880,321
0
0
null
null
null
null
UTF-8
C++
false
false
2,411
cpp
/* 新增編譯和執行步驟 : g++ hello.cpp -o hello ./hello =============================== # 此範例可以看到 : 「this」指標的宣告和使用方式。 「*this」代表目前這個物件的內容,「return *this;」代表傳回目前這個物件的內容。 =============================== # 在建立class物件時,會自動建立屬於該物件自己的指標,叫做「this」指標。 # 「this」指標指向物件自己本身,指向記憶體中儲存該物件的「位址」。 # 「this」指標代表了「目前這個物件」的指標,可以存取到該class的資料成員和成員函數。 this->資料成員; //第一種方式 (*this).資料成員; //第二種方式 */ #include <iostream> // 引入標準程式庫中相關的輸入、輸出程式 #include <cstdlib> using namespace std; // std : 標準程式庫的命名空間 class Square { // 宣告類別 private: //私用資料成員 int a; public: //公用資料成員 Square(); //宣告預設建構子(constructor) Square(int n); //宣告有參數的建構子(constructor) Square squ(Square b); void show_data(); }; // 記得加上 ";" #### 重要 Square::Square(int n) //constructor使用參數設定初始值 { a = n*n; } Square Square::squ(Square b) // 實作 { this->a = this->a + b.a; // this->a 為 n1*n1, b.a 為 n2*n2 return *this; // 透過this指標 傳回 class Square } void Square::show_data() { cout << "答案" << (*this).a << endl; } /* - argc : argument count(參數總和)的縮寫,代表包括指令本身的參數個數。 - argv : argument value 的縮寫。 一個陣列,它會分拆所帶的參數放到陣列內 */ int main(int argc, char *argv[]) { int n1, n2; cout << "輸入第一個數字 : " ; cin >> n1; cout << "輸入第二個數字 : " ; cin >> n2; Square first(n1), second(n2), third(0); //宣告 class Square 的物件 third = first.squ(second); // 此時進入squ後, this->a 表示的是first這個物件的a成員。b.a 則為second的a成員。 third.show_data(); /* cc@cpphome$g++ cpp_16_classes/ch12_05_Friend_this.cpp -o test cc@cpphome$./test 輸入第一個數字 : 10 輸入第二個數字 : 20 答案500 */ return 0; }
d10bebe69c3a50eb40de190598629544bca6dd08
99ca9bb6ac36daf7ae528f971e94ad0daf8b03ca
/pi0/ERAlgoJeremyPi0.cxx
29845a6cdcee1977f8f12b378137efa65d960494
[]
no_license
jhewes15/ngamma
fc121295e2ee1366a901360fd2f57f51228efad6
f31b0a31c6464480e5d52d95b5ee917be57a18fb
refs/heads/master
2020-06-05T08:29:47.184869
2015-07-22T18:04:12
2015-07-22T18:04:12
39,088,036
0
0
null
null
null
null
UTF-8
C++
false
false
3,643
cxx
#ifndef ERTOOL_ERALGOJEREMYPI0_CXX #define ERTOOL_ERALGOJEREMYPI0_CXX #include "ERAlgoJeremyPi0.h" namespace ertool { ERAlgoJeremyPi0::ERAlgoJeremyPi0(const std::string& name) : AlgoBase(name) { _name = name; _nGamma = new NGammaBase(); } void ERAlgoJeremyPi0::Reset() {} void ERAlgoJeremyPi0::AcceptPSet(const ::fcllite::PSet& cfg) { // get external parameters if not training PDFs if (!_trainingMode) { auto ngamma_pset = cfg.get_pset(_name); _nGamma->AcceptPSet(ngamma_pset); } } void ERAlgoJeremyPi0::ProcessBegin() {} bool ERAlgoJeremyPi0::Reconstruct(const EventData &data, ParticleGraph& graph) { // first case: training pdfs! if (_trainingMode) { auto nodes = graph.GetParticleNodes(RecoType_t::kShower, 0, 22); if (nodes.size() == 2) { // get the two gamma shower particles auto particle1 = graph.GetParticle(nodes[0]); auto particle2 = graph.GetParticle(nodes[1]); // calculate angle between showers double angle = particle1.Momentum().Angle(particle2.Momentum()); // calculate invariant mass double invMass = sqrt(2 * particle1.Energy() * particle2.Energy() * (1 - cos(angle))); // make sure energies are above a certain threshold if (invMass < 300) { // add to PDF _nGamma->FillMassPdf(invMass); } } } // second case: using pdfs to make selection! else { // score all possible combinations of gammas CombinationScoreSet_t candidates = _nGamma->GammaComparison(graph, 2); // select the best candidates as pi0s CombinationScoreSet_t event = _nGamma->EventSelection(candidates, _cut); // add the pi0s to the particle graph, then check it worked properly AddPi0s(graph, event); } return true; } void ERAlgoJeremyPi0::ProcessEnd(TFile* fout) { // if in training mode, save the trained parameters for future use if (_trainingMode) { auto& params = OutputPSet(); params.add_pset(_nGamma->GetParams()); } } // ****************** // // **** ADD PI0S **** // // ****************** // void ERAlgoJeremyPi0::AddPi0s(ParticleGraph &graph, CombinationScoreSet_t particles) { // this comes in useful later: int pdg_pi0 = 111; // loop over each identified pi0 for (auto const& particle : particles) { // get ids of two gamma showers double gamma1_id = particle.first[0]; double gamma2_id = particle.first[1]; // get pointers to two gamma showers Particle *gamma1 = &(graph.GetParticle(gamma1_id)); Particle *gamma2 = &(graph.GetParticle(gamma2_id)); // identify them as siblings (which creates "parent" object if it doesn't exist already) graph.SetSiblings(gamma1_id, gamma2_id, particle.second); // get id of parent object double parent_id = gamma1->Parent(); // get a pointer to the parent object Particle *parent = &(graph.GetParticle(parent_id)); // figure out the pi0's information geoalgo::Vector X (( gamma1->Vertex()[0] + gamma2->Vertex()[0]) /2, (gamma1->Vertex()[1] + gamma2->Vertex()[1]) /2, (gamma1->Vertex()[2] + gamma2->Vertex()[2]) /2 ); geoalgo::Vector P ( gamma1->Momentum()[0] + gamma2->Momentum()[0], gamma1->Momentum()[1] + gamma2->Momentum()[1], gamma1->Momentum()[2] + gamma2->Momentum()[2] ); parent->SetParticleInfo(pdg_pi0, ParticleMass(pdg_pi0), X, P, particle.second); } } } #endif
8a45b92519f1edbaed47284a7cdb59bdeacd858d
95afc50eea3e69c5cfc150b1f0d031f0da95a1d0
/lib/ldcp_sdk/third_party/Asio/asio-1.18.0/src/tests/unit/ip/address_v6_range.cpp
a11eaf6dfa149c8560bcdaa4baefad326537a895
[ "Apache-2.0", "BSL-1.0" ]
permissive
LitraTech/ltme_node
09a04be74b132993210852c8e712984b678ffc9f
f6733085cfd94072764029f4b00171de969e8637
refs/heads/master
2023-07-19T13:00:39.556775
2023-07-13T04:42:25
2023-07-13T04:42:25
232,500,654
6
12
Apache-2.0
2022-08-10T10:52:00
2020-01-08T07:04:26
C++
UTF-8
C++
false
false
697
cpp
// // address_v6_range.cpp // ~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/ip/address_v6_range.hpp" #include "../unit_test.hpp" //------------------------------------------------------------------------------ ASIO_TEST_SUITE ( "ip/address_v6_range", ASIO_TEST_CASE(null_test) )
8f7dde38a5c99c6afcfc4d3d26627c4b65a2d688
237af8f87b8fd71635ff57e9d1657a16e06dcb35
/KnightRiderScanBar.ino
cd4a5c116283a7a8e677c325a4781ccab8c791fa
[]
no_license
erichilarysmithsr/KnightRiderScanBar
814db6c16b6822115204b188b35829312e4cb6f1
72717aab55fd7a6d0b06ddac21aa65a6dadd4263
refs/heads/master
2021-01-21T02:49:40.808396
2014-08-11T15:29:06
2014-08-11T15:29:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,455
ino
#include "LPD8806.h" #include "SPI.h" // Knight Rider KITT and KARR scan bar (light chaser). // Uses a 1 metre Adafruit digital RGB LED strip with an LPD8806 chip. // http://www.adafruit.com/products/306 /*****************************************************************************/ // Number of RGB LEDs in strand: int nLEDs = 32; int dataPin = 2; int clockPin = 3; LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin); void setup() { strip.begin(); // Update the strip, to start they are all 'off' strip.show(); } void scanBar(uint32_t (*getColor)(byte)) { int tail = 7; for(int i=0; i<(int)strip.numPixels()+tail; i++) { for(int j=0; j<=i; j++) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(min(strip.numPixels()-1, j), getColor(brightness)); } strip.show(); delay(20); } for(int i=strip.numPixels()-1; i>=-tail; i--) { for(int j=strip.numPixels()-1; j>=i; j--) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(max(0, j), getColor(brightness)); } strip.show(); delay(20); } } void loop() { for(int i = 0; i<3; i++) { scanBar(&kitt); } for(int i = 0; i<3; i++) { scanBar(&karr); } } uint32_t kitt(byte brightness) { return strip.Color(brightness, 0, 0); } uint32_t karr(byte brightness) { return strip.Color(brightness, brightness*0.4, 0); }
86c9a0c29e0a927b054f6f09bc2ff427d5c3d419
11e6ec185672c57bb5f80955f001f42731768c73
/Source/BuildingEscape/OpenDoor.h
ac9d413900a980835feec92212b6372c57d01e7e
[]
no_license
Zagorouiko/BuildingEscape
d122fd9d6beca6c1373764844a829107ad383f10
baef29a3bb6561c9d5e8c4e29c01e19e863397ee
refs/heads/master
2020-04-22T18:15:04.301177
2019-02-17T14:37:41
2019-02-17T14:37:41
170,570,823
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Components/ActorComponent.h" #include "Engine/TriggerVolume.h" #include "OpenDoor.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BUILDINGESCAPE_API UOpenDoor : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UOpenDoor(); protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; private: UPROPERTY(VisibleAnywhere) float OpenAngle = 90.0f; UPROPERTY(EditAnywhere) ATriggerVolume* PressurePlate; };
e803acdb2294fc1410d222ed47d8dcbe2ab78515
77222f794141f3018763c071d48e38dfd7252246
/src/soundbuffer.cpp
f6cf062f60732579b1222d0a20bca728b29b07aa
[ "Zlib", "BSD-3-Clause", "MIT", "FTL", "LicenseRef-scancode-happy-bunny", "LicenseRef-scancode-warranty-disclaimer", "BSL-1.0", "SGI-B-2.0", "LicenseRef-scancode-synthesis-toolkit", "LicenseRef-scancode-khronos" ]
permissive
dakodun/uair
c3101ee83d5f89b688feef8c5fe6b7ff67c78ab2
a2a6ed6c13e796937c06f2731146e85185680e69
refs/heads/master
2021-11-28T10:38:18.194923
2021-11-13T22:17:05
2021-11-13T22:17:05
18,681,066
0
0
null
null
null
null
UTF-8
C++
false
false
2,361
cpp
/* **************************************************************** ** ** Uair Engine ** Copyright (c) 2010 - 2017, Iain M. Crawford ** ** This software is provided 'as-is', without any express or ** implied warranty. In no event will the authors be held liable ** for any damages arising from the use of this software. ** ** Permission is granted to anyone to use this software for any ** purpose, including commercial applications, and to alter it ** and redistribute it freely, subject to the following ** restrictions: ** ** 1. The origin of this software must not be misrepresented; ** you must not claim that you wrote the original ** software. If you use this software in a product, an ** acknowledgment in the product documentation would be ** appreciated but is not required. ** ** 2. Altered source versions must be plainly marked as such, ** and must not be misrepresented as being the original ** software. ** ** 3. This notice may not be removed or altered from any ** source distribution. ** **************************************************************** */ #include "soundbuffer.hpp" namespace uair { SoundBuffer::SoundBuffer(SoundBuffer&& other) : SoundBuffer() { swap(*this, other); } SoundBuffer::~SoundBuffer() { } SoundBuffer& SoundBuffer::operator=(SoundBuffer other) { swap(*this, other); return *this; } void swap(SoundBuffer& first, SoundBuffer& second) { using std::swap; swap(first.mSampleData, second.mSampleData); swap(first.mNumChannels, second.mNumChannels); } void SoundBuffer::LoadFromFile(const std::string& filename) { using namespace std::placeholders; std::ifstream oggFile(filename.c_str(), std::ios::in | std::ios::binary); // open the ogg file on disk SoundLoaderOgg slo; slo.Decode(oggFile, std::bind(&SoundBuffer::DecoderCallback, this, _1, _2, _3, _4)); // decode the entire ogg file } unsigned int SoundBuffer::GetTypeID() { return static_cast<unsigned int>(Resources::SoundBuffer); } int SoundBuffer::DecoderCallback(const int& serial, const int& numChannels, const int& numSamples, std::vector<int>& samples) { mSampleData.insert(mSampleData.end(), samples.begin(), samples.end()); // add the samples into the array mNumChannels = numChannels; // set the number of channels return numSamples; // return the number of samples used (all of them) } }
79f094cb51e708d142f6f5bcf9e3aae3cd0dac00
511f58bc46be60a0215eb46335a783585701c07a
/frq_b.cpp
c3303c414df1466eab2fcf96aabad31667337eff
[]
no_license
sagar-massand/spoj1
6ee6c7b93ba4873dd2a0b43c107f081a3fb69879
56ceac968afc318854ceec4c22267fa64d2c72a8
refs/heads/master
2016-09-06T09:41:04.540897
2013-11-29T12:38:20
2013-11-29T12:38:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,125
cpp
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<string.h> #include<math.h> #include<queue> #include<vector> #include<stack> #include<set> using namespace std; #define FOR(i,n) for(i=0;i<n;i++) #define pi(n) printf("%d\n",n); #define pl(n) printf("%lld\n",n); #define ps(c) printf("%s\n",c); #define si(n) scanf("%d",&n); #define sl(n) scanf("%lld",&n); #define ss(n) scanf("%s",n); #define sf(n) scanf("%lf",&n); #define sc(n) scanf(" %c",&n); #define mod 1000000007 #define FORi(i,a,n) for(i=a;i<n;i++) int main() { long long a,b,c,n,t,i,j,k; long long *prime,*prim; prim=(long long *)malloc(1000001*sizeof(long long)); prime=(long long *)malloc(1000001*sizeof(long long)); for(i=3;i<1000000;i+=2) prim[i]=1; prime[0]=2; k=1; for(i=3;i<1000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; for(j=i*i;j<1000000;j+=(2*i)) { prim[j]=0; } } } long long total; for(;i<1000000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; } } total=k; sl(t) FOR(i,t) { long long ans=0,sum,num=k; sl(n) sl(k) for(a=3;a<=n;a++) { }
c5ad784120061b33d38be0cfed15aff55f57f342
b367fe5f0c2c50846b002b59472c50453e1629bc
/xbox_leak_may_2020/xbox trunk/xbox/private/ui/xapp/cdda.cpp
e567984ba410e6154a688265aaabe095167bfeaa
[]
no_license
sgzwiz/xbox_leak_may_2020
11b441502a659c8da8a1aa199f89f6236dd59325
fd00b4b3b2abb1ea6ef9ac64b755419741a3af00
refs/heads/master
2022-12-23T16:14:54.706755
2020-09-27T18:24:48
2020-09-27T18:24:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,204
cpp
#include "std.h" #include "xapp.h" #include "cdda.h" //////////////////////////////////////////////////////////////////////////// CCDDAStreamer::CCDDAStreamer(CNtIoctlCdromService* pDrive, DWORD dwRetries) { ASSERT(pDrive != NULL); m_ibChunk = 0; m_pDrive = pDrive; m_dwRetries = dwRetries; m_dwCurFrame = 0; m_chunk = (BYTE *)XPhysicalAlloc(CDDA_BUFFER_SIZE, -1, 0, PAGE_READWRITE); } CCDDAStreamer::~CCDDAStreamer() { if (m_chunk) XPhysicalFree(m_chunk); } int CCDDAStreamer::ReadFrames(void* pvBuffer, DWORD nFrameCount) { #ifdef _DEBUG const DWORD dwStartTime = GetTickCount(); #endif DWORD nTotalFrames = m_pDrive->GetTrackFrame(m_pDrive->GetTrackCount()); nFrameCount = min(nFrameCount, nTotalFrames - m_dwCurFrame); ASSERT((int)nFrameCount > 0); HRESULT hr = m_pDrive->Read(m_dwCurFrame, nFrameCount, pvBuffer, m_dwRetries); if (FAILED(hr)) { ZeroMemory(pvBuffer, nFrameCount * CDAUDIO_BYTES_PER_FRAME); if (hr != HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)) { return -1; } else { // REVIEW: we probably hit end of the disc but need better way to detect this return 0; } } #ifdef _DEBUG const DWORD dwEndTime = GetTickCount(); if(dwEndTime - dwStartTime >= nFrameCount * 1000 / CDAUDIO_FRAMES_PER_SECOND) { TRACE(_T("\001CCDDAStreamer: read of frames %lu through %lu took longer than real-time (%lu ms)\n"), m_dwCurFrame, m_dwCurFrame + nFrameCount - 1, dwEndTime - dwStartTime); } #endif m_dwCurFrame += nFrameCount; return nFrameCount * CDAUDIO_BYTES_PER_FRAME; } int CCDDAStreamer::Read(void* pvBuffer, int cbWanted) { BYTE *pbBuffer = (BYTE *)pvBuffer; int cbRead; if (!m_chunk) return -1; if (m_ibChunk) { cbRead = min(cbWanted, CDDA_BUFFER_SIZE - m_ibChunk); CopyMemory(pbBuffer, m_chunk + m_ibChunk, cbRead); m_ibChunk += cbRead; m_ibChunk %= CDDA_BUFFER_SIZE; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_MAX_FRAMES_PER_READ * CDAUDIO_BYTES_PER_FRAME) { cbRead = ReadFrames(pbBuffer, CDDA_MAX_FRAMES_PER_READ); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_BUFFER_SIZE) { cbRead = ReadFrames(pbBuffer, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } if (cbWanted) { cbRead = ReadFrames(m_chunk, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; if (cbRead < CDDA_BUFFER_SIZE) ZeroMemory(m_chunk + cbRead, CDDA_BUFFER_SIZE - cbRead); m_ibChunk = cbWanted; cbRead = min(cbRead, cbWanted); CopyMemory(pbBuffer, m_chunk, cbRead); cbWanted -= cbRead; pbBuffer += cbRead; } return pbBuffer - (LPBYTE)pvBuffer; }
cbf73f5b78d1b0c71b47d3e0f361cfcaaa9bd1b7
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1674486_1/C++/jdh/pbA.cpp
400a8f6e181975e08b90206f73e5c46b413009e2
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,941
cpp
// g++ -std=c++0x #include <iostream> // cout, endl #include <iomanip> // setprecision #include <iterator> // ostream_iterator #include <vector> #include <algorithm> // sort #include <cstring> // memset #include <deque> using namespace std; typedef long long ll; typedef unsigned long long ull; struct Node { ll v,d; }; typedef vector<int> VI; typedef vector<double> VD; typedef vector<ll> VLL; typedef vector<vector<ll> > MLL; typedef vector<ull> VULL; typedef vector<vector<ull> > MULL; typedef vector<Node> VNode; typedef vector<vector<Node> > MNode; #define MAX(a,b) ((a)>(b)?(a):(b)) #define FOR(i,N) for(int i=0;i<(N);++i) #define FORLL(i,N) for(ll i=0;i<(N);++i) #define FORULL(i,N) for(ull i=0;i<(N);++i) #define FOR2(i,A,B) for(int i=(A);i<(B);++i) #define FORLL2(i,A,B) for(ll i=(A);i<(B);++i) #define FORULL2(i,A,B) for(ull i=(A);i<(B);++i) #define SORT(v) sort((v).begin(),(v).end()) #define PB push_back #define PF pop_front #define X first #define Y second #define MATRIX(m,T,size,init) vector<vector<T> > m(size,vector<T>(size,init)); #define FILE __FILE__ << " " #define LINE "line " << __LINE__ << " : " #define FUNC "(function " << __FUNCTION__ << ") " #define log cout<<endl<<FILE<<LINE<<FUNC; #define printL(l) for(auto it=l.begin();it!=l.end();++it) cout<<*it<<","; cout<<endl; #define printM(m) for(auto it=m.begin();it!=m.end();++it){ auto l=*it; for(auto it2=l.begin();it2!=l.end();++it2) cout<<*it2<<","; cout<<endl;} cout<<endl; #define printLNode(lNode) for(auto it=lNode.begin();it!=lNode.end();++it){ Node node=*it; printNode(node); } #define printNode(node) cout<<"("<<node.v<<","<<node.d<<")"<<", "; #define copy(v,T,s) copy((v).begin(),(v).end(),ostream_iterator<T>(cout,s)); cout << endl; #define copyn(v,T,s,n) copy((v).begin(),(v).begin()+n,ostream_iterator<T>(cout,s)); cout << endl; void getRet(ull n,MLL M) { FORLL2(i,1,n) { //cout<<endl<<i<<":"<<endl; VI visited(n,0); deque<ull> d; d.PB(i); while(d.size()>0) { //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; ull a=d.front(); d.PF(); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; FORLL2(j,1,n) { if(j==i) continue; if(M[a][j]==1) { if(visited[j]==1) { cout<<"Yes"; return; } d.PB(j); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; visited[j]=1; } } } } cout<<"No"; return; } int main() { int nbCase; cin>>nbCase; //cout<<nbCase<<endl; FOR(i,nbCase) { ull n; cin>>n; //cout<<n<<endl; MLL M(n+1,VLL(n+1,0)); FORLL2(j,1,n+1) { ll nj; cin>>nj; FORLL(k,nj) { ll tmp; cin>>tmp; M[j][tmp]=1; } } //printM(M); cout<<"Case #"<<i+1<<": "; getRet(n+1,M); cout<<endl; } }
bd72938528701a16c9143e960f5b68ffd7076d1a
0e3cf2d88620e4311a9d0fda2bee2d93b6607119
/Scripts/Legion/EyeOfAzshara/boss_lady_hatecoil.cpp
dae1ed2560a33474a056ec59a845bffa5d08eb81
[]
no_license
SquallSpiegel/Project-Darkspear
67b1d895cf31a6796ffc0322c9e0a9b78f298245
b93487efb808e0421e1551d1fb951f406c521f26
refs/heads/master
2023-03-16T00:43:51.943898
2019-01-05T10:21:38
2019-01-05T10:21:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,440
cpp
/* * Copyright (C) 2017-2019 Project Darkspear <https://github.com/Hymn-WoW/Project-Darkspear> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 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, see <http://www.gnu.org/licenses/>. */ #include "AreaTrigger.h" #include "AreaTriggerAI.h" #include "ScriptMgr.h" #include "eye_of_azshara.h" enum Spells { SPELL_STATIC_NOVA = 193597, SPELL_FOCUSED_LIGHTING = 193611, SPELL_BECKON_STORM = 193682, SPELL_BECKON_STORM_SUMMON = 193683, SPELL_CURSE_OF_THE_WITCH_DEBUFF = 193698, SPELL_CURSE_OF_THE_WITCH_1_TARGET = 193712, SPELL_CURSE_OF_THE_WITCH_3_TARGETS = 193716, SPELL_CURSE_OF_THE_WITCH_KNOCK_BACK = 193700, SPELL_CURSE_OF_THE_WITCH_KILL = 193720, SPELL_ARCANE_SHIELDING = 197868, SPELL_SAND_DUNE_GOB = 193061, SPELL_CRACKLING_THUNDER_CHECK = 197324, SPELL_CRACKLING_THUNDER_DAMAGE = 197326, // Heroic & Mythic SPELL_MONSOON_DAMAGE = 196610, SPELL_MONSOON_VISUAL = 196609, SPELL_MONSOON_TARGET = 196624, SPELL_MONSOON_MISSILE = 196630 // Triggers the spawn of the Monsoon NPC }; // 91784 struct boss_lady_hatecoil : public BossAI { boss_lady_hatecoil(Creature* creature) : BossAI(creature, DATA_LADY_HATECOIL) { } void Reset() override { BossAI::Reset(); if (!_arcanistsDead) DoCastSelf(SPELL_ARCANE_SHIELDING, true); me->GetInstanceScript()->SetData(DATA_RESPAWN_DUNES, 0); } void JustDied(Unit* killer) override { BossAI::JustDied(killer); me->GetInstanceScript()->SetData(DATA_BOSS_DIED, 0); } void ScheduleTasks() override { events.ScheduleEvent(SPELL_BECKON_STORM, 20s); events.ScheduleEvent(SPELL_CURSE_OF_THE_WITCH_DEBUFF, 40s); events.ScheduleEvent(SPELL_STATIC_NOVA, 14s); events.ScheduleEvent(SPELL_FOCUSED_LIGHTING, 29s); events.ScheduleEvent(SPELL_CRACKLING_THUNDER_CHECK, 1s); if (IsHeroic()) events.ScheduleEvent(SPELL_MONSOON_TARGET, 15s); } void DoAction(int32 param) override { if (param == 1) { _arcanistsDead = true; me->RemoveAurasDueToSpell(SPELL_ARCANE_SHIELDING); me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); } } void ExecuteEvent(uint32 eventId) override { switch (eventId) { case SPELL_BECKON_STORM: { Talk(3); DoCastSelf(SPELL_BECKON_STORM, false); events.Repeat(45s); break; } case SPELL_CURSE_OF_THE_WITCH_DEBUFF: { uint32 spellId = urand(0, 1) ? SPELL_CURSE_OF_THE_WITCH_1_TARGET : SPELL_CURSE_OF_THE_WITCH_3_TARGETS; DoCastSelf(spellId, false); events.Repeat(40s); break; } case SPELL_STATIC_NOVA: { Talk(2); DoCastSelf(SPELL_STATIC_NOVA, false); events.Repeat(35s); break; } case SPELL_FOCUSED_LIGHTING: { DoCastSelf(SPELL_FOCUSED_LIGHTING, false); events.Repeat(35s); break; } case SPELL_CRACKLING_THUNDER_CHECK: { DoCastSelf(SPELL_CRACKLING_THUNDER_CHECK, true); events.Repeat(1s); break; } case SPELL_MONSOON_TARGET: { Talk(6); DoCastSelf(SPELL_MONSOON_TARGET, true); events.Repeat(25s, 35s); break; } } } private: bool _arcanistsDead = false; }; // 193597 class spell_lady_hatecoil_static_nova : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_static_nova); void FilterTargets(std::list<WorldObject*>& targets) { targets.remove_if([](WorldObject* object) { if (Unit* target = object->ToUnit()) if (target->FindNearestCreature(NPC_SAND_DUNE, 5.0f, true)) return true; return false; }); } void Register() override { OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lady_hatecoil_static_nova::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lady_hatecoil_static_nova::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); } }; // 193611 class spell_lady_hatecoil_focused_lightning : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_focused_lightning); void HandleDamage(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); if (target && target->ToPlayer()) { if (Creature* sandDune = target->FindNearestCreature(NPC_SAND_DUNE, 5.0f, true)) { if (GameObject* dune = target->FindNearestGameObject(GOB_SAND_DUNE, 5.0f)) { sandDune->RemoveGameObject(dune, true); sandDune->DisappearAndDie(); } } } } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_focused_lightning::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } }; // 193682 class spell_lady_hatecoil_beckon_storm : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_beckon_storm); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); target->CastSpell(target, SPELL_BECKON_STORM_SUMMON, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_beckon_storm::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 193712 && 193716 class spell_lady_hatecoil_curse_of_the_witch : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_curse_of_the_witch); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); if (Unit* caster = GetCaster()) caster->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_DEBUFF, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_curse_of_the_witch::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 193698 class aura_lady_hatecoil_curse_of_the_witch : public AuraScript { PrepareAuraScript(aura_lady_hatecoil_curse_of_the_witch); void OnRemove(AuraEffect const* /*auraEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); target->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_KNOCK_BACK, true); target->CastSpell(target, SPELL_CURSE_OF_THE_WITCH_KILL, true); } void Register() override { OnEffectRemove += AuraEffectRemoveFn(aura_lady_hatecoil_curse_of_the_witch::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; // 197324 class spell_lady_hatecoil_crackling_thunder : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_crackling_thunder); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); Unit* caster = GetCaster(); if (caster && target && target->GetDistance(Position(-3434.230469f, 4592.095703f, -0.437837f)) > 42.0f) caster->CastSpell(target, SPELL_CRACKLING_THUNDER_DAMAGE, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_crackling_thunder::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 196624 class spell_lady_hatecoil_monsoon_target : public SpellScript { PrepareSpellScript(spell_lady_hatecoil_monsoon_target); void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); Unit* caster = GetCaster(); if (caster && target) caster->CastSpell(target, SPELL_MONSOON_MISSILE, true); } void Register() override { OnEffectHitTarget += SpellEffectFn(spell_lady_hatecoil_monsoon_target::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 99852 struct npc_lady_hatecoil_monsoon : public ScriptedAI { npc_lady_hatecoil_monsoon(Creature* creature) : ScriptedAI(creature) { } void Reset() override { DoCastSelf(SPELL_MONSOON_VISUAL, true); me->setFaction(16); // Same faction as Lady Hatecoil me->SetSpeed(MOVE_RUN, 2.0f); if (Unit* victim = me->SelectNearestPlayer(100.0f)) me->GetMotionMaster()->MoveFollow(victim, 0.0f, 0.0f); } }; // Spell: 196610 // AT: 100101 (custom) struct at_lady_hatecoil_monsoon : AreaTriggerAI { at_lady_hatecoil_monsoon(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } void OnUnitEnter(Unit* unit) override { Unit* caster = at->GetCaster(); if (caster) { if (Player* player = unit->ToPlayer()) caster->CastSpell(player, SPELL_MONSOON_DAMAGE, true); else if (Creature* creature = unit->ToCreature()) { if (creature->GetEntry() == NPC_SAND_DUNE) { if (GameObject* dune = creature->FindNearestGameObject(GOB_SAND_DUNE, 5.0f)) { creature->RemoveGameObject(dune, true); creature->DisappearAndDie(); at->Remove(); if (Creature* casterCre = caster->ToCreature()) casterCre->DisappearAndDie(); } } } } } }; // Criteria ID: 29404 class achievement_stay_salty : public AchievementCriteriaScript { public: achievement_stay_salty() : AchievementCriteriaScript("achievement_stay_salty") { } bool OnCheck(Player* /*player*/, Unit* /*target*/) override { // TODO return false; } }; void AddSC_boss_lady_hatecoil() { RegisterCreatureAI(boss_lady_hatecoil); RegisterCreatureAI(npc_lady_hatecoil_monsoon); RegisterSpellScript(spell_lady_hatecoil_static_nova); RegisterSpellScript(spell_lady_hatecoil_focused_lightning); RegisterSpellScript(spell_lady_hatecoil_beckon_storm); RegisterSpellScript(spell_lady_hatecoil_curse_of_the_witch); RegisterSpellScript(spell_lady_hatecoil_crackling_thunder); RegisterSpellScript(spell_lady_hatecoil_monsoon_target); RegisterAuraScript(aura_lady_hatecoil_curse_of_the_witch); RegisterAreaTriggerAI(at_lady_hatecoil_monsoon); new achievement_stay_salty(); }
c679b3d22c8d58af9e9600143a5b66f577bb517d
363c0e6a653d4808640031f82b2c3ee62e13c640
/BlendDemo/Framework3/Math/SphericalHarmonics.cpp
b76d5236968a9016087bf1ef2a5e71a8bb851636
[ "MIT" ]
permissive
dtrebilco/PreMulAlpha
8d7e9a7209c2b2bda6c89e7e9a6daad73ec34ff0
4eaf2b0967a4440bbaf7a83a560ee84626015d3d
refs/heads/master
2021-01-10T12:24:21.105947
2018-03-12T13:00:17
2018-03-12T13:00:17
53,249,801
115
3
null
null
null
null
UTF-8
C++
false
false
23,989
cpp
/* * * * * * * * * * * * * Author's note * * * * * * * * * * * *\ * _ _ _ _ _ _ _ _ _ _ _ _ * * |_| |_| |_| |_| |_|_ _|_| |_| |_| _|_|_|_|_| * * |_|_ _ _|_| |_| |_| |_|_|_|_|_| |_| |_| |_|_ _ _ * * |_|_|_|_|_| |_| |_| |_| |_| |_| |_| |_| |_|_|_|_ * * |_| |_| |_|_ _ _|_| |_| |_| |_|_ _ _|_| _ _ _ _|_| * * |_| |_| |_|_|_| |_| |_| |_|_|_| |_|_|_|_| * * * * http://www.humus.name * * * * This file is a part of the work done by Humus. You are free to * * use the code in any way you like, modified, unmodified or copied * * into your own work. However, I expect you to respect these points: * * - If you use this file and its contents unmodified, or use a major * * part of this file, please credit the author and leave this note. * * - For use in anything commercial, please request my approval. * * - Share your work and ideas too as much as you can. * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "SphericalHarmonics.h" #define REDIST_FACTOR 1 //#define REDIST_FACTOR 1e-30f const double sqrt2 = 1.4142135623730950488016887242097; double rcp[MAX_BANDS]; double fTab[MAX_BANDS * (MAX_BANDS + 1)]; double kTab[MAX_BANDS * (MAX_BANDS + 1) / 2]; double getFactor(const int l, const int m){ /* double f = 1; for (int i = l - m + 1; i <= l + m; i++){ f *= i; } double pmm = 1; for (int i = 0; i <= m; i++){ pmm *= (1 - 2 * i); } double x = sqrt(pmm * pmm / f); */ double x = 1.0; int i = l - m + 1; int n = l + m; int k = 0; while (true){ bool b0 = (k <= m); bool b1 = (i <= n); if (!b0 && !b1) break; if ((x <= 1.0 && b0) || !b1){ int f = (1 - 2 * k); x *= (f * f); k++; } else { x /= i; i++; } } x = sqrt(x); if (m & 1) x = -x; return x; } void initSH(){ long double fact[2 * MAX_BANDS]; long double d = 1.0L; rcp[0] = 0; for (int i = 1; i < MAX_BANDS; i++){ rcp[i] = double(1.0L / (long double) i); } fact[0] = d; for (int i = 1; i < 2 * MAX_BANDS; i++){ d *= i; fact[i] = d; } double *dstF = fTab; double *dstK = kTab; for (int l = 0; l < MAX_BANDS; l++){ // double fct = 1; // double pmm = 1; for (int m = 0; m <= l; m++){ // pmm *= fct; // fct -= 2; if (l != m){ *dstF++ = double(2 * l - 1) / double(l - m); *dstF++ = double(l + m - 1) / double(l - m); } else { *dstF++ = 0; *dstF++ = 0; } // *dstK++ = (double) (pmm * sqrt((long double(2 * l + 1) * fact[l - m]) / (4.0L * 3.1415926535897932384626433832795L * fact[l + m])) / REDIST_FACTOR); *dstK++ = (double) (getFactor(l, m) * sqrt((double(2 * l + 1) / (4.0L * 3.1415926535897932384626433832795L))) / REDIST_FACTOR); } } } /* float K_list[] = { 0.28209478785f, 0.4886025051f, 0.34549414466f, 0.63078312173f, 0.2575161311f, 0.12875806555f, 0.7463526548f, 0.21545345308f, 0.068132364148f, 0.027814921189f, 0.84628436355f, 0.18923493652f, 0.044603102283f, 0.011920680509f, 0.0042145970123f, 0.93560256661f, 0.17081687686f, 0.032281355422f, 0.0065894040825f, 0.0015531374369f, 0.00049114518199f, 1.0171072221f, 0.15694305165f, 0.024814875307f, 0.0041358125511f, 0.00075509260929f, 0.00016098628522f, 4.6472737553e-005f, 1.0925484154f, 0.14599792317f, 0.019867800849f, 0.0028097313415f, 0.00042358293734f, 7.0597156223e-005f, 1.384524143e-005f, 3.7002964192e-006f, 1.1631066067f, 0.13707342814f, 0.01638340829f, 0.0020166581537f, 0.00026034944814f, 3.6103972493e-005f, 5.5709639026e-006f, 1.0171141988e-006f, 2.5427854971e-007f, 1.2296226727f, 0.12961361028f, 0.013816857281f, 0.0015075427227f, 0.00017069560029f, 2.0402026496e-005f, 2.6338902949e-006f, 3.801693177e-007f, 6.51985001e-008f, 1.5367433848e-008f, 1.2927207185f, 0.12325608434f, 0.011860322246f, 0.0011630002801f, 0.00011748076923f, 1.2383560401e-005f, 1.384524143e-006f, 1.678982142e-007f, 2.2848052974e-008f, 3.7064436234e-009f, 8.2878598968e-010f, 1.3528790761f, 0.11775300918f, 0.0103276221f, 0.00092005770282f, 8.3989393007e-005f, 7.9362516666e-006f, 7.8580600881e-007f, 8.2831226229e-008f, 9.5013932764e-009f, 1.2266245975e-009f, 1.8927228454e-010f, 4.0352986651e-011f, 1.4104739392f, 0.11292829394f, 0.0091000212546f, 0.00074301362407f, 6.1917802006e-005f, 5.3094077196e-006f, 4.7299963365e-007f, 4.4300474576e-008f, 4.4300474576e-009f, 4.8335780492e-010f, 5.9497232884e-011f, 8.7723884023e-012f, 1.7906562843e-012f, 1.4658075153f, 0.10865288191f, 0.0080985076633f, 0.00061044798366f, 4.6819223098e-005f, 3.6784655714e-006f, 2.9836295628e-007f, 2.5216272196e-008f, 2.2464440745e-009f, 2.1419003838e-010f, 2.2330855175e-011f, 2.6317165207e-012f, 3.7218091959e-013f, 7.2990683522e-014f, 1.5191269238f, 0.10482971704f, 0.0072686330764f, 0.00050890610675f, 3.6166382172e-005f, 2.6237851318e-006f, 1.9556539711e-007f, 1.5088197955e-008f, 1.2158416398e-009f, 1.0349931362e-010f, 9.4481514597e-012f, 9.4481514597e-013f, 1.0697924913e-013f, 1.4558031857e-014f, 2.7512094195e-015f, 1.5706373067f, 0.1013842022f, 0.0065717617374f, 0.00042960950433f, 2.8451584469e-005f, 1.9182054336e-006f, 1.3236875055e-007f, 9.40703748e-009f, 6.9349600383e-010f, 5.3504378288e-011f, 4.3686141937e-012f, 3.8315281119e-013f, 3.6868896447e-014f, 4.0227263989e-015f, 5.2820985382e-016f, 9.6437484011e-017f, 1.6205111811f, 0.098257923044f, 0.0059797867672f, 0.00036664425087f, 2.2738311173e-005f, 1.4323789666e-006f, 9.2076807318e-008f, 6.0713648798e-009f, 4.131040555e-010f, 2.9210867898e-011f, 2.1652535868e-012f, 1.7011838825e-013f, 1.4377627964e-014f, 1.3349292434e-015f, 1.4071389748e-016f, 1.7870682851e-017f, 3.159120257e-018f, 1.6688952713f, 0.095404392594f, 0.0054718171853f, 0.00031591551249f, 1.8424566844e-005f, 1.0894674765e-006f, 6.5578235786e-008f, 4.0360614093e-009f, 2.552629366e-010f, 1.668706019e-011f, 1.1354106326e-012f, 8.1100759469e-014f, 6.1482327086e-015f, 5.0200109853e-016f, 4.508102946e-017f, 4.6010633023e-018f, 5.6635174197e-019f, 9.7128522441e-020f, 1.7159156055f, 0.092786089356f, 0.0050320322108f, 0.00027451986316f, 1.5111821107e-005f, 8.4214886554e-007f, 4.7677290989e-008f, 2.7526496787e-009f, 1.6276758768e-010f, 9.9057199338e-012f, 6.2400170243e-013f, 4.0967718822e-014f, 2.8270411804e-015f, 2.0728871658e-016f, 1.6387611941e-017f, 1.4263585367e-018f, 1.4123054005e-019f, 1.6880278198e-020f, 2.8133796997e-021f, 1.7616813855f, 0.090372348238f, 0.0046482520257f, 0.00024035539025f, 1.2529390841e-005f, 6.6035687919e-007f, 3.5297559928e-008f, 1.9199341526e-009f, 1.0666300848e-010f, 6.0776889666e-012f, 3.5689418491e-013f, 2.1719888413e-014f, 1.3792142934e-015f, 9.2152631233e-017f, 6.5490023309e-018f, 5.0228554997e-019f, 4.2450876965e-020f, 4.0848375405e-021f, 4.7485271873e-022f, 7.7031282861e-023f, 1.8062879733f, 0.088137828247f, 0.0043109620947f, 0.00021187222805f, 1.0489238301e-005f, 5.2446191507e-007f, 2.6557161397e-008f, 1.3659529897e-009f, 7.1595390337e-011f, 3.8379157708e-012f, 2.1127030986e-013f, 1.1999347271e-014f, 7.0706831878e-016f, 4.3517046791e-017f, 2.8207911768e-018f, 1.9465308412e-019f, 1.4508584271e-020f, 1.1925982807e-021f, 1.1169706286e-022f, 1.2647201906e-023f, 1.9996982025e-024f, 1.8498192293f, 0.08606137925f, 0.0040126324977f, 0.00018790873322f, 8.8581026337e-006f, 4.2133697531e-007f, 2.0271584676e-008f, 9.8915204822e-010f, 4.9090791891e-011f, 2.4858088755e-012f, 1.2888318631e-013f, 6.8694969119e-015f, 3.7815335923e-016f, 2.1617588692e-017f, 1.2918980235e-018f, 8.1381925936e-020f, 5.4619972377e-021f, 3.9625492741e-022f, 3.1725784981e-023f, 2.8961546815e-024f, 3.1982678122e-025f, 4.935034375e-026f, 1.8923493652f, 0.084125190447f, 0.0037472338125f, 0.00016758139065f, 7.539843222e-006f, 3.4201423397e-007f, 1.5676196712e-008f, 7.2774916245e-010f, 3.4306424518e-011f, 1.6467610741e-012f, 8.0739104336e-014f, 4.0572926514e-015f, 2.0979760847e-016f, 1.1214153878e-017f, 6.2300854879e-019f, 3.6211636357e-020f, 2.2202778798e-021f, 1.4514410557e-022f, 1.026323813e-023f, 8.0142425394e-025f, 7.1396547136e-026f, 7.6988876748e-027f, 1.1606509873e-027f, 1.9339444301f, 0.082314141311f, 0.0035098867787f, 0.00015020928745f, 6.4639785415e-006f, 2.8024901181e-007f, 1.2266166018e-008f, 5.4315496068e-010f, 2.438837769e-011f, 1.1131720502e-012f, 5.1789450806e-014f, 2.4633729657e-015f, 1.2020029285e-016f, 6.0402919859e-018f, 3.1401982755e-019f, 1.6980247563e-020f, 9.6131721747e-022f, 5.7449692048e-023f, 3.6628585823e-024f, 2.5276125564e-025f, 1.927286506e-026f, 1.6774875866e-027f, 1.7682271734e-028f, 2.6071087338e-029f, 1.9746635149f, 0.080615300422f, 0.0032966047858f, 0.00013526133275f, 5.5780833482e-006f, 2.3161730416e-007f, 9.7013813075e-009f, 4.1069221938e-010f, 1.7608283638e-011f, 7.6630218528e-013f, 3.3932431105e-014f, 1.5329109834e-015f, 7.0858835275e-017f, 3.3628115035e-018f, 1.6448048712e-019f, 8.328793221e-021f, 4.3896594565e-022f, 2.4237839636e-023f, 1.4135795137e-024f, 8.8005616488e-026f, 5.9333374532e-027f, 4.4224486263e-028f, 3.7646382751e-029f, 3.8829279014e-030f, 5.6045236728e-031f, 2.0145597375f, 0.079017533944f, 0.0031041018936f, 0.00012231875022f, 4.842645695e-006f, 1.9293562265e-007f, 7.7484810674e-009f, 3.1424240259e-010f, 1.2893521955e-011f, 5.362998122e-013f, 2.2662803405e-014f, 9.7525177961e-016f, 4.2850103139e-017f, 1.9279172853e-018f, 8.9118008037e-020f, 4.2485343345e-021f, 2.0982015523e-022f, 1.0791984281e-023f, 5.8186479667e-025f, 3.3154823825e-026f, 2.0177383221e-027f, 1.33045725e-028f, 9.7033567732e-030f, 8.0861306443e-031f, 8.1682254459e-032f, 1.1551615206e-032f, 2.0536810547f, 0.077511196458f, 0.0029296478521f, 0.00011104801525f, 4.2275256908e-006f, 1.618803252e-007f, 6.2446691179e-009f, 2.4307341574e-010f, 9.5635956295e-012f, 3.8102277015e-013f, 1.5401932619e-014f, 6.3301553126e-016f, 2.6514102928e-017f, 1.1346988547e-018f, 4.9759836503e-020f, 2.24334668e-021f, 1.0436993321e-022f, 5.0331651141e-024f, 2.5292606351e-025f, 1.3330374005e-026f, 7.4287269985e-028f, 4.4237425515e-029f, 2.8555135383e-030f, 2.0396525274e-031f, 1.6653693149e-032f, 1.6489613353e-033f, 2.2866979406e-034f, 2.0920709389f, 0.076087884417f, 0.0027709573165f, 0.00010118105521f, 3.7094774603e-006f, 1.3673315326e-007f, 5.074643279e-009f, 1.8991375165e-010f, 7.178065106e-012f, 2.7446017901e-013f, 1.0635115913e-014f, 4.1843303907e-016f, 1.6750727509e-017f, 6.8384558696e-019f, 2.8543163317e-020f, 1.2215346231e-021f, 5.3775063301e-023f, 2.4443210591e-024f, 1.1522639975e-025f, 5.6630685934e-027f, 2.9205046332e-028f, 1.5932658987e-029f, 9.2921154198e-031f, 5.8768498016e-032f, 4.114617867e-033f, 3.2943308133e-034f, 3.1997369449e-035f, 4.3542904589e-036f, 2.1297689433f, 0.074740237775f, 0.0026261042693f, 9.2500577646e-005f, 3.2703892858e-006f, 1.1620822308e-007f, 4.1555975734e-009f, 1.4975734135e-010f, 5.4466218462e-012f, 2.0022180112e-013f, 7.4514838584e-015f, 2.8123813477e-016f, 1.0784990145e-017f, 4.2108312072e-019f, 1.6776353093e-020f, 6.8375310661e-022f, 2.8589153611e-023f, 1.2302812869e-024f, 5.4692674337e-026f, 2.5227849463e-027f, 1.2137754732e-028f, 6.1304919139e-030f, 3.2768857649e-031f, 1.8732709079e-032f, 1.1617532993e-033f, 7.9789544184e-035f, 6.26885864e-036f, 5.9771221905e-037f, 7.9872654985e-038f, 2.1668111802f, 0.073461779026f, 0.002493455253f, 8.4829070365e-005f, 2.896016712e-006f, 9.9332553731e-008f, 3.4272987126e-009f, 1.1910686381e-010f, 4.1746934161e-012f, 1.4778254497e-013f, 5.291463929e-015f, 1.9194157044e-016f, 7.0654668469e-018f, 2.6441845117e-019f, 1.0080858943e-020f, 3.9239690218e-022f, 1.563346679e-023f, 6.3929999849e-025f, 2.6919386093e-026f, 1.1715159077e-027f, 5.2923694051e-029f, 2.4948468632e-030f, 1.2351332459e-031f, 6.4738572649e-033f, 3.6303588837e-034f, 2.2093660583e-035f, 1.4895542926e-036f, 1.1492160865e-037f, 1.0763394811e-038f, 1.4133029781e-039f, 2.2032307254f, 0.072246781595f, 0.0023716167942f, 7.8020464477e-005f, 2.5750590401e-006f, 8.5362375968e-008f, 2.8454125323e-009f, 9.548579253e-011f, 3.229855112e-012f, 1.1026543544e-013f, 3.8045189691e-015f, 1.3285956544e-016f, 4.7031776345e-018f, 1.6905222907e-019f, 6.1811616677e-021f, 2.3035829448e-022f, 8.7695903955e-024f, 3.4187422745e-025f, 1.3685922219e-026f, 5.6439791979e-028f, 2.4066008162e-029f, 1.0656607532e-030f, 4.9260185742e-032f, 2.3922860994e-033f, 1.2304591974e-034f, 6.7734549537e-036f, 4.0479135724e-037f, 2.6807962526e-038f, 2.0323063943e-039f, 1.8708896824e-040f, 2.4153081942e-041f, 2.2390579644f, 0.071090161459f, 0.0022593936472f, 7.1953752141e-005f, 2.2984783003e-006f, 7.3723725857e-008f, 2.3769483209e-009f, 7.7118386915e-011f, 2.5206933316e-012f, 8.3104798115e-014f, 2.7670871021e-015f, 9.3172669241e-017f, 3.1771616508e-018f, 1.0988443339e-019f, 3.8609454325e-021f, 1.3806712679e-022f, 5.0347900687e-024f, 1.8763554744e-025f, 7.1639584907e-027f, 2.809935703e-028f, 1.1358491867e-029f, 4.7492240348e-031f, 2.0629310954e-032f, 9.3576454782e-034f, 4.4610824434e-035f, 2.2531868908e-036f, 1.2183839317e-037f, 7.1545967982e-039f, 4.6572458283e-040f, 3.4713060867e-041f, 3.142772863e-042f, 3.9913255273e-043f, };*/ inline float factorial(const int x){ float f = 1.0f; for (int i = 2; i <= x; i++){ f *= i; } return f; // return f[x]; } float P(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf((1.0f - x) * (1.0f + x)); float fact = 1.0f; for (int i = 1; i <= m; i++){ pmm *= (-fact) * somx2; fact += 2.0f; } } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll = 0.0f; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float Pm0(const int l, const float x){ if (l == 0) return 1.0f; if (l == 1) return x; float pmm = 1.0f; float pmmp1 = x; float pll; float f = 1.0f; for (float ll = 2; ll <= l; ll++){ f += 2.0f; pll = (f * x * pmmp1 - (ll - 1.0f) * pmm) / ll; pmm = pmmp1; pmmp1 = pll; } return pll; } float PmX(const int l, const int m, const float x, float pmm0){ if (l == m) return pmm0; float f = float(2 * m + 1); float pmmp1 = f * x * pmm0; if (l == m + 1) return pmmp1; float pll; float d = 2.0f; float f2 = float(2 * m); for (float ll = float(m + 2); ll <= l; ll++){ f += 2.0f; f2++; pll = (f * x * pmmp1 - f2 * pmm0) / d; pmm0 = pmmp1; pmmp1 = pll; d++; } return pll; } float P2(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf(1.0f - x * x); float fact = -1.0f; for (int i = 1; i <= m; i++){ pmm *= fact * somx2; fact -= 2.0f; } /* for (int i = 1; i <= m; i++){ pmm *= somx2; } pmm *= f2[m]; */ //pmm *= powf(somx2, m); } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float K(const int l, const int m){ // renormalisation constant for SH function float temp = ((2.0f * l + 1.0f) * factorial(l - m)) / (4.0f * PI * factorial(l + m)); return sqrtf(temp); } inline float K2(const int l, const int m){ return (float) kTab[((l * (l + 1)) >> 1) + m]; } // return a point sample of a Spherical Harmonic basis function // l is the band, range [0..N] // m in the range [-l..l] // theta in the range [0..Pi] // phi in the range [0..2*Pi] float SH(const int l, const int m, const float theta, const float phi){ const float sqrt2 = sqrtf(2.0f); if (m == 0) return K(l, 0) * P(l, m, cosf(theta)); else if (m > 0) return sqrt2 * K(l, m) * cosf(m * phi) * P(l, m, cosf(theta)); else return sqrt2 * K(l, -m) * sinf(-m * phi) * P(l, -m, cosf(theta)); } float SH2(const int l, const int m, const float cosTheta, const float scPhi){ const int m2 = abs(m); float k = K2(l, m2) * P2(l, m2, cosTheta); if (m == 0) return k; return k * scPhi; } float SH(const int l, const int m, const float3 &pos){ float len = length(pos); float p = atan2f(pos.z, pos.x); // float t = PI / 2 - asinf(pos.y / len); float t = acosf(pos.y / len); return SH(l, m, t, p); } float SH_A(const int l, const int m, const float3 &pos){ float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = acosf(pos.y / len); return SH(l, m, t, p) * powf(d, -1.5f); } float SH_A2_pos(const int l, const int m, const float3 &pos){ float dxz = pos.x * pos.x + pos.z * pos.z; // float d = dot(pos, pos); float d = dxz + pos.y * pos.y; float len = sqrtf(d); // float p = atan2f(pos.z, pos.x); float t = pos.y / len; // float cp = cosf(p); // float sp = sinf(p); float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } float scPhi = c; // float scPhi = cosf(m * p); return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2_neg(const int l, const int m, const float3 &pos){ /* float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = pos.y / len; */ float dxz = pos.x * pos.x + pos.z * pos.z; float d = dxz + pos.y * pos.y; float len = sqrtf(d); float t = pos.y / len; float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } // float scPhi = sinf(m * p); float scPhi = s; return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2(const int l, const int m, const float3 &pos){ if (m >= 0) return SH_A2_pos(l, m, pos); else return SH_A2_neg(l, -m, pos); } template <typename FLOAT> bool cubemapToSH(FLOAT *dst, const Image &img, const int bands){ if (!img.isCube()) return false; FORMAT format = img.getFormat(); if (format < FORMAT_I32F || format > FORMAT_RGBA32F) return false; int size = img.getWidth(); int sliceSize = img.getSliceSize(); int nCoeffs = bands * bands; float *coeffs = new float[nCoeffs]; for (int i = 0; i < nCoeffs; i++){ dst[i] = 0; } float3 v; float *src = (float *) img.getPixels(); for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } delete coeffs; float normFactor = 1.0f / (6 * size * size); for (int i = 0; i < nCoeffs; i++){ dst[i] *= normFactor; } return true; } template <typename FLOAT> bool shToCubemap(Image &img, const int size, const FLOAT *src, const int bands){ img.create(FORMAT_I32F, size, size, 0, 1); int sliceSize = img.getSliceSize(); // memset(img.getPixels(), 0, 6 * sliceSize); int nCoeffs = bands * bands; FLOAT *coeffs = new FLOAT[nCoeffs]; float *dst = (float *) (img.getPixels()); FLOAT scale = 1.0f; float3 v; for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } delete coeffs; return true; } template <typename FLOAT> void computeSHCoefficients(FLOAT *dest, const int bands, const float3 &pos, const bool fade){ FLOAT dxz = pos.x * pos.x + pos.z * pos.z; FLOAT dxyz = dxz + pos.y * pos.y; FLOAT xzLen = sqrt(dxz); FLOAT xyzLen = sqrt(dxyz); FLOAT xzLenInv = 1.0f / xzLen; FLOAT xyzLenInv = 1.0f / xyzLen; FLOAT ct = pos.y * xyzLenInv; FLOAT st = xzLen * xyzLenInv; FLOAT cp = pos.x * xzLenInv; FLOAT sp = pos.z * xzLenInv; // FLOAT a = powf(xyzLen, -3.0f); // FLOAT a = 1.0f / (dxyz * xyzLen); FLOAT a = fade? xyzLenInv * xyzLenInv * xyzLenInv : 1; if (bands > 0) dest[0] = FLOAT(kTab[0] * a * REDIST_FACTOR); if (bands > 1) dest[2] = FLOAT(kTab[1] * a * REDIST_FACTOR * ct); FLOAT pmm0 = FLOAT(1.0 * REDIST_FACTOR); FLOAT pmm1 = FLOAT(ct * REDIST_FACTOR); for (int l = 2; l < bands; l++){ int i = l * (l + 1); // FLOAT pll = ((2 * l - 1) * ct * pmm1 - (l - 1) * pmm0) * rcp[l]; FLOAT pll = FLOAT(ct * pmm1 * fTab[i] - pmm0 * fTab[i + 1]); pmm0 = pmm1; pmm1 = pll; dest[i] = FLOAT(kTab[i >> 1] * pll * a); } FLOAT c = FLOAT(sqrt2 * a); // Start with sqrtf(2) * a instead of 1.0 so that it's baked into sin & cos values below FLOAT s = 0; double pmm = double(1.0 * REDIST_FACTOR); // FLOAT fact = -1; for (int m = 1; m < bands; m++){ // Compute cos(m * phi) and sin(m * phi) iteratively from initial cos(phi) and sin(phi) FLOAT ssp = s * sp; FLOAT csp = c * sp; c = c * cp - ssp; s = s * cp + csp; pmm *= /*fact * */st; // fact -= 2; FLOAT pmm0 = (FLOAT) pmm; FLOAT f0 = FLOAT(2 * m + 1); FLOAT pmm1; FLOAT kp = FLOAT(kTab[((m * (m + 1)) >> 1) + m] * pmm0); dest[m * m ] = kp * s; dest[m * m + 2 * m] = kp * c; if (m + 1 < bands){ pmm1 = f0 * ct * pmm0; FLOAT kp = FLOAT(kTab[(m * m + 5 * m + 2) >> 1] * pmm1); dest[m * m + 2 * m + 2] = kp * s; dest[m * m + 4 * m + 2] = kp * c; } int index = 2; for (int l = m + 2; l < bands; l++){ // f0 += 2.0f; // f1++; // FLOAT pll = (f0 * ct * pmm1 - f1 * pmm0) * rcp[index++]; int it = l * (l + 1) + 2 * m; FLOAT pll = FLOAT(ct * pmm1 * fTab[it] - pmm0 * fTab[it + 1]); pmm0 = pmm1; pmm1 = pll; // pmm1 = (2 * m - 5) * ct * pmm1; // FLOAT pll = pmm1; int i = l * (l + 1); FLOAT kp = FLOAT(kTab[(i >> 1) + m] * pll); dest[i + m] = kp * c; dest[i - m] = kp * s; } } } template bool cubemapToSH(float *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const float *src, const int bands); template bool cubemapToSH(double *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const double *src, const int bands);
53ca678364364b787524c267cfb2420de69c351a
1df0f2dd40099cdc146dc82ee353e7ea4e563af2
/cinchona/brt/window.cpp
eb7b382dd30bcc245df4831e66c0146e85151f31
[]
no_license
chuckbruno/aphid
1d0b2637414a03feee91b4c8909dd5d421d229d4
f07c216f3fda0798ee3f96cd9decb35719098b01
refs/heads/master
2021-01-01T18:10:17.713198
2017-07-25T02:37:15
2017-07-25T02:37:15
98,267,729
0
1
null
2017-07-25T05:30:27
2017-07-25T05:30:27
null
UTF-8
C++
false
false
507
cpp
#include <QtGui> #include "widget.h" #include "window.h" Window::Window() { QDateTime local(QDateTime::currentDateTime()); qDebug() << "local time is:" << local; srand (local.toTime_t() ); glWidget = new GLWidget(this); setCentralWidget(glWidget); setWindowTitle(tr("Bend Roll Twist")); } Window::~Window() { qDebug()<<"exit brt window"; } void Window::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) close(); else QWidget::keyPressEvent(e); }
a3bd380b105a1c81a6fac8994c4f0d1da8a89d86
aaa87c429aa06613fbe52b89c01124843131e560
/src/steps_to_permutation.h
65af4b51b27551ecd2a8ef7e10256a98808080e5
[]
no_license
venustus/algorithms
404b551db1254e7a0390bb744bc3104e16a2ae47
05d30ed76b57a2f05a90f19171ae27aa563e7006
refs/heads/master
2021-01-16T18:20:21.454672
2013-11-13T03:14:54
2013-11-13T03:14:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
607
h
/* * steps_to_permutation.h * * Created on: Sep 20, 2013 * Author: venkat */ #ifndef STEPS_TO_PERMUTATION_H_ #define STEPS_TO_PERMUTATION_H_ #include <vector> struct SwapStep { int srcValue; int destValue; }; /** * Problem: * Given two integer arrays containing elements 0 .. n - 1, but not necessarily * in same order, print/return the list of swaps to be done to convert * the array a into array b. * * Condition: * Swaps can only be done with '0'. */ std::vector<SwapStep> * getStepsToPermutation(std::vector<int> &a, std::vector<int> &b); #endif /* STEPS_TO_PERMUTATION_H_ */
ede1c7777bc2fa54b98859d0827ff16a8e155497
007867b4937f52de7746f79124ef104b2d183f5a
/动态规划/滚动数组/HDU 3053 ( Group Travel ) .cpp
12db07927852f505090027dc00c84cbc3e31e22e
[]
no_license
WhereIsHeroFrom/Algorithm
84dcee3174dbcd9e996442f07627a96c46f6c74a
6bf620d6219770db60b40d151eecd686955ab723
refs/heads/master
2023-08-05T14:05:48.385791
2021-10-06T00:21:39
2021-10-06T00:21:39
306,805,686
16
4
null
null
null
null
GB18030
C++
false
false
3,971
cpp
/* 题意:N个学生,学生i想去的地方为P[i](0 <= P[i] <= 10^5), 初始时所有学生都在学校里,由一辆公交车带出来选K个站停靠,停靠点一定是在P[i]里选出来的,有需要的同学下车,为了使所有学生的总距离最小,求这个最小值(K<=N<=3000)。 题解:决策单调性。 状态表示:dp[i][j]表示在第i个站点放置第j个位置时的最小耗费 状态转移:dp[i][j] = min{dp[i'][j-1] + cost(i', i)| i'<i} cost(i', i)的计算cost(i', i) = sum{ min{ dist(k,i'), dist(k,i) } | i'<k<i} 那么这是一个2D/1D问题,时间复杂度O(n^3)。 观察cost(i', i)函数,很容易想到,可以在i'和i之间找到一个k,使得[i', k]之间的点到i'的距离小于到i的距离;[k+1, i]之间的点则正好相反。 那么k成为一个转折点。 再来看状态转移方程,dp[i][j] = min{dp[i'][j-1] + cost(i', i)| i'<i} i'称为i的决策,由于问题的特殊性,当i增大,决策i'势必也会同样增大。也就是说决策满足单调性,即: 当j相同时,当a<b时,有dp[a][j]和dp[b][j],其中a'为a的决策,b'为b的决策,那么a'<b'。于是在枚举决策的时候,我们可以简化内部的一个O(n)变成O(1)。 同时dp[i][j]只和dp[i][j-1]有关,所有第二维可以采用滚动数组。 这题有个坑点,就是坐标为0的玩家不参与计算,需要特殊处理。 */ #include <iostream> #include <algorithm> using namespace std; #define MAXN 3010 #define MAXV 611111111 int P[MAXN], Sum[MAXN]; int n, k; int dp[MAXN][2]; int cost[MAXN][MAXN]; void calcSum() { int i; sort(P+1, P+n+1); for(i = 1; i <= n; i++) { if(P[i]) { break; } } if(i < n+1) { int p = i; for(i = 1; i+p-1 <= n; i++) { P[i] = P[i+p-1]; } n -= (p-1); } for(i = 1; i <= n; ++i) { Sum[i] = Sum[i-1] + P[i]; } } void getCost() { int i, j; for(i = 1; i <= n; ++i) { cost[i][i] = cost[i][i+1] = 0; int p = i; for(j = i + 2; j <= n; ++j) { cost[i][j] = cost[i][j-1] + (j-1-p)*(P[j] - P[j-1]); while(p < j) { ++p; if(2*P[p] < P[i] + P[j]) { cost[i][j] += (P[p] - P[i]) - (P[j] - P[p]); }else { --p; break; } } //printf("%d ", cost[i][j]); } //puts(""); } } int main() { int t; int i, j; scanf("%d", &t); while(t--) { scanf("%d %d", &n, &k); for(i = 1; i <= n; i++) { scanf("%d", &P[i]); //P[i] = P[i-1] + i*i%12; } calcSum(); if(0 == Sum[n] || k >= n) { printf("0\n"); continue; } getCost(); int p = 0; for(i = 1; i <= n; i++) { dp[i][0] = i*P[i] - Sum[i]; } for(j = 2; j <= k; ++j) { int pos = j-1; for(i = 2; i <= n; i++) { dp[i][p^1] = MAXV; for(int ii = pos; ii <= i; ++ii) { int v = dp[ii][p] + cost[ii][i]; if(v < dp[i][p^1]) { dp[i][p^1] = v; pos = ii; } } } p ^= 1; } int ans = INT_MAX; for(i = k; i <= n; i++) { int v = dp[i][p] + (Sum[n]-Sum[i]) - (n-i)*P[i]; if(v < ans) ans = v; } printf("%d\n", ans); } return 0; } /* 243 6 2 1 2 4 11 12 14 101 10 3 1 2 4 5 6 8 11 13 18 21 100 3000 198 3000 192 3000 111 3000 134 3000 1111 3000 432 3000 231 700 281 571 123 331 111 999 321 1211 791 35209 36127 63784 52942 2948 11783 30666 585 1004 384 1231 219 */
99ad341cc565519623debe0ec29b94d1a52a06e0
01ba077291810cac5f18c84af51775b6b099cc92
/src/qt/sendcoinsdialog.cpp
827567ff5d4c106fd4fc6a25f8de387a18447b80
[ "MIT" ]
permissive
genterium-project/gentarium
01b1fcfec5f46c428f195fc1fc7f9040a29f7698
7c7fa9548f1cefaa46808013a2eb046b14d7b6c9
refs/heads/master
2020-03-23T12:32:12.090316
2018-11-15T14:59:36
2018-11-15T14:59:36
141,565,050
9
9
MIT
2018-11-15T12:51:35
2018-07-19T10:39:46
C++
UTF-8
C++
false
false
37,068
cpp
// Copyright (c) 2011-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Dаsh Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" #include "addresstablemodel.h" #include "bitcoinunits.h" #include "clientmodel.h" #include "coincontroldialog.h" #include "guiutil.h" #include "optionsmodel.h" #include "platformstyle.h" #include "sendcoinsentry.h" #include "walletmodel.h" #include "base58.h" #include "coincontrol.h" #include "validation.h" // mempool and minRelayTxFee #include "ui_interface.h" #include "txmempool.h" #include "wallet/wallet.h" #include "privatesend.h" #include <QMessageBox> #include <QScrollBar> #include <QSettings> #include <QTextDocument> SendCoinsDialog::SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent) : QDialog(parent), ui(new Ui::SendCoinsDialog), clientModel(0), model(0), fNewRecipientAllowed(true), fFeeMinimized(true), platformStyle(platformStyle) { ui->setupUi(this); QString theme = GUIUtil::getThemeName(); if (!platformStyle->getImagesOnButtons()) { ui->addButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon()); } else { ui->addButton->setIcon(QIcon(":/icons/" + theme + "/add")); ui->clearButton->setIcon(QIcon(":/icons/" + theme + "/remove")); ui->sendButton->setIcon(QIcon(":/icons/" + theme + "/send")); } GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this); addEntry(); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // Coin Control connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); // Gentarium specific QSettings settings; if (!settings.contains("bUseDarkSend")) settings.setValue("bUseDarkSend", false); if (!settings.contains("bUseInstantX")) settings.setValue("bUseInstantX", false); bool fUsePrivateSend = settings.value("bUseDarkSend").toBool(); bool fUseInstantSend = settings.value("bUseInstantX").toBool(); if(fLiteMode) { ui->checkUsePrivateSend->setChecked(false); ui->checkUsePrivateSend->setVisible(false); ui->checkUseInstantSend->setVisible(false); CoinControlDialog::coinControl->fUsePrivateSend = false; CoinControlDialog::coinControl->fUseInstantSend = false; } else{ ui->checkUsePrivateSend->setChecked(fUsePrivateSend); ui->checkUseInstantSend->setChecked(fUseInstantSend); CoinControlDialog::coinControl->fUsePrivateSend = fUsePrivateSend; CoinControlDialog::coinControl->fUseInstantSend = fUseInstantSend; } connect(ui->checkUsePrivateSend, SIGNAL(stateChanged ( int )), this, SLOT(updateDisplayUnit())); connect(ui->checkUseInstantSend, SIGNAL(stateChanged ( int )), this, SLOT(updateInstantSend())); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); // init transaction fee section if (!settings.contains("fFeeSectionMinimized")) settings.setValue("fFeeSectionMinimized", true); if (!settings.contains("nFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility settings.setValue("nFeeRadio", 1); // custom if (!settings.contains("nFeeRadio")) settings.setValue("nFeeRadio", 0); // recommended if (!settings.contains("nCustomFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility settings.setValue("nCustomFeeRadio", 1); // total at least if (!settings.contains("nCustomFeeRadio")) settings.setValue("nCustomFeeRadio", 0); // per kilobyte if (!settings.contains("nSmartFeeSliderPosition")) settings.setValue("nSmartFeeSliderPosition", 0); if (!settings.contains("nTransactionFee")) settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE); if (!settings.contains("fPayOnlyMinFee")) settings.setValue("fPayOnlyMinFee", false); if (!settings.contains("fSendFreeTransactions")) settings.setValue("fSendFreeTransactions", false); ui->groupFee->setId(ui->radioSmartFee, 0); ui->groupFee->setId(ui->radioCustomFee, 1); ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true); ui->groupCustomFee->setId(ui->radioCustomPerKilobyte, 0); ui->groupCustomFee->setId(ui->radioCustomAtLeast, 1); ui->groupCustomFee->button((int)std::max(0, std::min(1, settings.value("nCustomFeeRadio").toInt())))->setChecked(true); ui->sliderSmartFee->setValue(settings.value("nSmartFeeSliderPosition").toInt()); ui->customFee->setValue(settings.value("nTransactionFee").toLongLong()); ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool()); ui->checkBoxFreeTx->setChecked(settings.value("fSendFreeTransactions").toBool()); minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool()); } void SendCoinsDialog::setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; if (clientModel) { connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel())); } } void SendCoinsDialog::setModel(WalletModel *model) { this->model = model; if(model && model->getOptionsModel()) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setModel(model); } } setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(), model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance()); connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount))); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); updateDisplayUnit(); // Coin Control connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); // fee section connect(ui->sliderSmartFee, SIGNAL(valueChanged(int)), this, SLOT(updateSmartFeeLabel())); connect(ui->sliderSmartFee, SIGNAL(valueChanged(int)), this, SLOT(updateGlobalFeeVariables())); connect(ui->sliderSmartFee, SIGNAL(valueChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateFeeSectionControls())); connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateGlobalFeeVariables())); connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, SLOT(updateGlobalFeeVariables())); connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(updateGlobalFeeVariables())); connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(coinControlUpdateLabels())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(setMinimumFee())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateGlobalFeeVariables())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->checkBoxFreeTx, SIGNAL(stateChanged(int)), this, SLOT(updateGlobalFeeVariables())); connect(ui->checkBoxFreeTx, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); ui->customFee->setSingleStep(CWallet::GetRequiredFee(1000)); updateFeeSectionControls(); updateMinFeeLabel(); updateSmartFeeLabel(); updateGlobalFeeVariables(); } } SendCoinsDialog::~SendCoinsDialog() { QSettings settings; settings.setValue("fFeeSectionMinimized", fFeeMinimized); settings.setValue("nFeeRadio", ui->groupFee->checkedId()); settings.setValue("nCustomFeeRadio", ui->groupCustomFee->checkedId()); settings.setValue("nSmartFeeSliderPosition", ui->sliderSmartFee->value()); settings.setValue("nTransactionFee", (qint64)ui->customFee->value()); settings.setValue("fPayOnlyMinFee", ui->checkBoxMinimumFee->isChecked()); settings.setValue("fSendFreeTransactions", ui->checkBoxFreeTx->isChecked()); delete ui; } void SendCoinsDialog::on_sendButton_clicked() { if(!model || !model->getOptionsModel()) return; QList<SendCoinsRecipient> recipients; bool valid = true; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } QString strFunds = tr("using") + " <b>" + tr("anonymous funds") + "</b>"; QString strFee = ""; recipients[0].inputType = ONLY_DENOMINATED; if(ui->checkUsePrivateSend->isChecked()) { recipients[0].inputType = ONLY_DENOMINATED; strFunds = tr("using") + " <b>" + tr("anonymous funds") + "</b>"; QString strNearestAmount( BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), CPrivateSend::GetSmallestDenomination())); strFee = QString(tr( "(privatesend requires this amount to be rounded up to the nearest %1)." ).arg(strNearestAmount)); } else { recipients[0].inputType = ALL_COINS; strFunds = tr("using") + " <b>" + tr("any available funds (not anonymous)") + "</b>"; } if(ui->checkUseInstantSend->isChecked()) { recipients[0].fUseInstantSend = true; strFunds += " "; strFunds += tr("and InstantSend"); } else { recipients[0].fUseInstantSend = false; } fNewRecipientAllowed = false; // request unlock only if was locked or unlocked for mixing: // this way we let users unlock by walletpassphrase or by menu // and make many transactions while unlocking through this dialog // will call relock WalletModel::EncryptionStatus encStatus = model->getEncryptionStatus(); if(encStatus == model->Locked || encStatus == model->UnlockedForMixingOnly) { WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } send(recipients, strFee, strFunds); return; } // already unlocked or not encrypted at all send(recipients, strFee, strFunds); } void SendCoinsDialog::send(QList<SendCoinsRecipient> recipients, QString strFee, QString strFunds) { // prepare transaction for getting txFee earlier WalletModelTransaction currentTransaction(recipients); WalletModel::SendCoinsReturn prepareStatus; if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl); else prepareStatus = model->prepareTransaction(currentTransaction); // process prepareStatus and on error generate message shown to user processSendCoinsReturn(prepareStatus, BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())); if(prepareStatus.status != WalletModel::OK) { fNewRecipientAllowed = true; return; } CAmount txFee = currentTransaction.getTransactionFee(); // Format confirmation message QStringList formatted; Q_FOREACH(const SendCoinsRecipient &rcp, currentTransaction.getRecipients()) { // generate bold amount string QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); amount.append("</b> ").append(strFunds); // generate monospace address string QString address = "<span style='font-family: monospace;'>" + rcp.address; address.append("</span>"); QString recipientElement; if (!rcp.paymentRequest.IsInitialized()) // normal payment { if(rcp.label.length() > 0) // label with address { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label)); recipientElement.append(QString(" (%1)").arg(address)); } else // just address { recipientElement = tr("%1 to %2").arg(amount, address); } } else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); } else // unauthenticated payment request { recipientElement = tr("%1 to %2").arg(amount, address); } formatted.append(recipientElement); } QString questionString = tr("Are you sure you want to send?"); questionString.append("<br /><br />%1"); if(txFee > 0) { // append fee string if a fee is required questionString.append("<hr /><span style='color:#aa0000;'>"); questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee)); questionString.append("</span> "); questionString.append(tr("are added as transaction fee")); questionString.append(" "); questionString.append(strFee); // append transaction size questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)"); } // add total amount in all subdivision units questionString.append("<hr />"); CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee; QStringList alternativeUnits; Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) { if(u != model->getOptionsModel()->getDisplayUnit()) alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); } // Show total amount + all alternative units questionString.append(tr("Total Amount = <b>%1</b><br />= %2") .arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)) .arg(alternativeUnits.join("<br />= "))); // Limit number of displayed entries int messageEntries = formatted.size(); int displayedEntries = 0; for(int i = 0; i < formatted.size(); i++){ if(i >= MAX_SEND_POPUP_ENTRIES){ formatted.removeLast(); i--; } else{ displayedEntries = i+1; } } questionString.append("<hr />"); questionString.append(tr("<b>(%1 of %2 entries displayed)</b>").arg(displayedEntries).arg(messageEntries)); // Display message box QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } // now send the prepared transaction WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction); // process sendStatus and on error generate message shown to user processSendCoinsReturn(sendStatus); if (sendStatus.status == WalletModel::OK) { accept(); CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); } fNewRecipientAllowed = true; } void SendCoinsDialog::clear() { // Remove entries until only one left while(ui->entries->count()) { ui->entries->takeAt(0)->widget()->deleteLater(); } addEntry(); updateTabsAndLabels(); } void SendCoinsDialog::reject() { clear(); } void SendCoinsDialog::accept() { clear(); } SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this); entry->setModel(model); ui->entries->addWidget(entry); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels())); // Focus the field, so that entry can start immediately entry->clear(); entry->setFocus(); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); qApp->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); updateTabsAndLabels(); return entry; } void SendCoinsDialog::updateTabsAndLabels() { setupTabChain(0); coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { entry->hide(); // If the last entry is about to be removed add an empty one if (ui->entries->count() == 1) addEntry(); entry->deleteLater(); updateTabsAndLabels(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { prev = entry->setupTabChain(prev); } } QWidget::setTabOrder(prev, ui->sendButton); QWidget::setTabOrder(ui->sendButton, ui->clearButton); QWidget::setTabOrder(ui->clearButton, ui->addButton); return ui->addButton; } void SendCoinsDialog::setAddress(const QString &address) { SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setAddress(address); } void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) { if(!fNewRecipientAllowed) return; SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setValue(rv); updateTabsAndLabels(); } bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) { // Just paste the entry, all pre-checks // are done in paymentserver.cpp. pasteEntry(rv); return true; } void SendCoinsDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance, const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance) { Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); Q_UNUSED(anonymizedBalance); Q_UNUSED(watchBalance); Q_UNUSED(watchUnconfirmedBalance); Q_UNUSED(watchImmatureBalance); if(model && model->getOptionsModel()) { uint64_t bal = 0; QSettings settings; settings.setValue("bUseDarkSend", ui->checkUsePrivateSend->isChecked()); if(ui->checkUsePrivateSend->isChecked()) { bal = anonymizedBalance; } else { bal = balance; } ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), bal)); } } void SendCoinsDialog::updateDisplayUnit() { setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(), model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance()); CoinControlDialog::coinControl->fUsePrivateSend = ui->checkUsePrivateSend->isChecked(); coinControlUpdateLabels(); ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); updateMinFeeLabel(); updateSmartFeeLabel(); } void SendCoinsDialog::updateInstantSend() { QSettings settings; settings.setValue("bUseInstantX", ui->checkUseInstantSend->isChecked()); CoinControlDialog::coinControl->fUseInstantSend = ui->checkUseInstantSend->isChecked(); coinControlUpdateLabels(); } void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg) { QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams; // Default to a warning message, override if error message is needed msgParams.second = CClientUIInterface::MSG_WARNING; // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn. // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins() // all others are used only in WalletModel::prepareTransaction() switch(sendCoinsReturn.status) { case WalletModel::InvalidAddress: msgParams.first = tr("The recipient address is not valid. Please recheck."); break; case WalletModel::InvalidAmount: msgParams.first = tr("The amount to pay must be larger than 0."); break; case WalletModel::AmountExceedsBalance: msgParams.first = tr("The amount exceeds your balance."); break; case WalletModel::AmountWithFeeExceedsBalance: msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg); break; case WalletModel::DuplicateAddress: msgParams.first = tr("Duplicate address found: addresses should only be used once each."); break; case WalletModel::TransactionCreationFailed: msgParams.first = tr("Transaction creation failed!"); msgParams.second = CClientUIInterface::MSG_ERROR; break; case WalletModel::TransactionCommitFailed: msgParams.first = tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); msgParams.second = CClientUIInterface::MSG_ERROR; break; case WalletModel::AbsurdFee: msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee)); break; case WalletModel::PaymentRequestExpired: msgParams.first = tr("Payment request expired."); msgParams.second = CClientUIInterface::MSG_ERROR; break; // included to prevent a compiler warning. case WalletModel::OK: default: return; } Q_EMIT message(tr("Send Coins"), msgParams.first, msgParams.second); } void SendCoinsDialog::minimizeFeeSection(bool fMinimize) { ui->labelFeeMinimized->setVisible(fMinimize); ui->buttonChooseFee ->setVisible(fMinimize); ui->buttonMinimizeFee->setVisible(!fMinimize); ui->frameFeeSelection->setVisible(!fMinimize); ui->horizontalLayoutSmartFee->setContentsMargins(0, (fMinimize ? 0 : 6), 0, 0); fFeeMinimized = fMinimize; } void SendCoinsDialog::on_buttonChooseFee_clicked() { minimizeFeeSection(false); } void SendCoinsDialog::on_buttonMinimizeFee_clicked() { updateFeeMinimizedLabel(); minimizeFeeSection(true); } void SendCoinsDialog::setMinimumFee() { ui->radioCustomPerKilobyte->setChecked(true); ui->customFee->setValue(CWallet::GetRequiredFee(1000)); } void SendCoinsDialog::updateFeeSectionControls() { ui->sliderSmartFee ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFeeNormal ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFeeFast ->setEnabled(ui->radioSmartFee->isChecked()); ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked()); ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked()); ui->radioCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked()); ui->radioCustomAtLeast ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked() && CoinControlDialog::coinControl->HasSelected()); ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked()); } void SendCoinsDialog::updateGlobalFeeVariables() { if (ui->radioSmartFee->isChecked()) { nTxConfirmTarget = defaultConfirmTarget - ui->sliderSmartFee->value(); payTxFee = CFeeRate(0); // set nMinimumTotalFee to 0 to not accidentally pay a custom fee CoinControlDialog::coinControl->nMinimumTotalFee = 0; } else { nTxConfirmTarget = defaultConfirmTarget; payTxFee = CFeeRate(ui->customFee->value()); // if user has selected to set a minimum absolute fee, pass the value to coincontrol // set nMinimumTotalFee to 0 in case of user has selected that the fee is per KB CoinControlDialog::coinControl->nMinimumTotalFee = ui->radioCustomAtLeast->isChecked() ? ui->customFee->value() : 0; } fSendFreeTransactions = ui->checkBoxFreeTx->isChecked(); } void SendCoinsDialog::updateFeeMinimizedLabel() { if(!model || !model->getOptionsModel()) return; if (ui->radioSmartFee->isChecked()) ui->labelFeeMinimized->setText(ui->labelSmartFee->text()); else { ui->labelFeeMinimized->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value()) + ((ui->radioCustomPerKilobyte->isChecked()) ? "/kB" : "")); } } void SendCoinsDialog::updateMinFeeLabel() { if (model && model->getOptionsModel()) ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg( BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000)) + "/kB") ); } void SendCoinsDialog::updateSmartFeeLabel() { if(!model || !model->getOptionsModel()) return; int nBlocksToConfirm = defaultConfirmTarget - ui->sliderSmartFee->value(); int estimateFoundAtBlocks = nBlocksToConfirm; CFeeRate feeRate = mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks); if (feeRate <= CFeeRate(0)) // not enough data => minfee { ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), std::max(CWallet::fallbackFee.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB"); ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...) ui->labelFeeEstimation->setText(""); } else { ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB"); ui->labelSmartFee2->hide(); ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks)); } updateFeeMinimizedLabel(); } // Coin Control: copy label "Quantity" to clipboard void SendCoinsDialog::coinControlClipboardQuantity() { GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); } // Coin Control: copy label "Amount" to clipboard void SendCoinsDialog::coinControlClipboardAmount() { GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); } // Coin Control: copy label "Fee" to clipboard void SendCoinsDialog::coinControlClipboardFee() { GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: copy label "After fee" to clipboard void SendCoinsDialog::coinControlClipboardAfterFee() { GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: copy label "Bytes" to clipboard void SendCoinsDialog::coinControlClipboardBytes() { GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); } // Coin Control: copy label "Dust" to clipboard void SendCoinsDialog::coinControlClipboardLowOutput() { GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); } // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: settings menu - coin control enabled/disabled by user void SendCoinsDialog::coinControlFeatureChanged(bool checked) { ui->frameCoinControl->setVisible(checked); if (!checked && model) // coin control features disabled CoinControlDialog::coinControl->SetNull(); coinControlUpdateLabels(); } // Coin Control: button inputs -> show actual coin control dialog void SendCoinsDialog::coinControlButtonClicked() { CoinControlDialog dlg(platformStyle); dlg.setModel(model); dlg.exec(); coinControlUpdateLabels(); } // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { if (state == Qt::Unchecked) { CoinControlDialog::coinControl->destChange = CNoDestination(); ui->labelCoinControlChangeLabel->clear(); } else // use this to re-validate an already entered address coinControlChangeEdited(ui->lineEditCoinControlChange->text()); ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed void SendCoinsDialog::coinControlChangeEdited(const QString& text) { if (model && model->getAddressTableModel()) { // Default to no change address until verified CoinControlDialog::coinControl->destChange = CNoDestination(); ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); CBitcoinAddress addr = CBitcoinAddress(text.toStdString()); if (text.isEmpty()) // Nothing entered { ui->labelCoinControlChangeLabel->setText(""); } else if (!addr.IsValid()) // Invalid address { ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Gentarium address")); } else // Valid address { CKeyID keyid; addr.GetKeyID(keyid); if (!model->havePrivKey(keyid)) // Unknown change address { ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address")); } else // Known change address { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); // Query label QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); if (!associatedLabel.isEmpty()) ui->labelCoinControlChangeLabel->setText(associatedLabel); else ui->labelCoinControlChangeLabel->setText(tr("(no label)")); CoinControlDialog::coinControl->destChange = addr.Get(); } } } } // Coin Control: update labels void SendCoinsDialog::coinControlUpdateLabels() { if (!model || !model->getOptionsModel()) return; if (model->getOptionsModel()->getCoinControlFeatures()) { // enable minimum absolute fee UI controls ui->radioCustomAtLeast->setVisible(true); // only enable the feature if inputs are selected ui->radioCustomAtLeast->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked() &&CoinControlDialog::coinControl->HasSelected()); } else { // in case coin control is disabled (=default), hide minimum absolute fee UI controls ui->radioCustomAtLeast->setVisible(false); return; } // set pay amounts CoinControlDialog::payAmounts.clear(); CoinControlDialog::fSubtractFeeFromAmount = false; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry && !entry->isHidden()) { SendCoinsRecipient rcp = entry->getValue(); CoinControlDialog::payAmounts.append(rcp.amount); if (rcp.fSubtractFeeFromAmount) CoinControlDialog::fSubtractFeeFromAmount = true; } } ui->checkUsePrivateSend->setChecked(CoinControlDialog::coinControl->fUsePrivateSend); if (CoinControlDialog::coinControl->HasSelected()) { // actual coin control calculation CoinControlDialog::updateLabels(model, this); // show coin control stats ui->labelCoinControlAutomaticallySelected->hide(); ui->widgetCoinControl->show(); } else { // hide coin control stats ui->labelCoinControlAutomaticallySelected->show(); ui->widgetCoinControl->hide(); ui->labelCoinControlInsuffFunds->hide(); } }
c9d31487e71f5c448468c63922b9d977773f18ea
5c23566734e5596340cf5550aa462a901179b080
/simpleGameEngine/simpleGameEngine/MoveComponent.h
65ff084b24f05db0fb9c7022b0cf489734e4c69a
[]
no_license
NathanGauthier/simpleEngine
0a273a16169e846060cb2d8bffd6bf1d49392ebf
d5ebc2398cdcbb47c01d6f4aa3fd5db8674e4db6
refs/heads/main
2023-01-30T18:44:30.243732
2020-12-08T15:38:33
2020-12-08T15:38:33
319,680,872
0
0
null
null
null
null
UTF-8
C++
false
false
563
h
#pragma once #include"Component.h" class MoveComponent : public Component { public: MoveComponent(Actor* ownerP, int updateOrder = 10); MoveComponent() = delete; MoveComponent(const MoveComponent&) = delete; MoveComponent& operator = (const MoveComponent&) = delete; float getForwardSpeed() const { return forwardSpeed; } float getAngularSpeed() const { return angularSpeed; } void setForwardSpeed(float forwardSpeedP); void setAngularSpeed(float angularSpeedP); void update(float dt) override; private: float forwardSpeed; float angularSpeed; };
16cdcfa51dbe8b999ae5c6ef788671cec89c27c7
fb37ef2af3f5933ee0f586a78776240e9fd8040c
/Experiment_10/RunTime/RunTime.cpp
244f1f0e48e438b09f4ad72aece77a6fa1726504
[]
no_license
mishra5047/OOPS
9ac53c00573ff7b874bfd5baa837483605108b6e
44648ee4e5821fda5eeb0b4b3a14b9a0f60959db
refs/heads/master
2022-06-28T09:27:08.166649
2020-05-04T12:40:48
2020-05-04T12:40:48
255,050,507
0
0
null
null
null
null
UTF-8
C++
false
false
1,060
cpp
#include <iostream> using namespace std; class Bank{ public: string Name; string Branch; int id; void enterDetails(string nam, string bran, int i){ Name = nam; Branch = bran; id = i; } virtual void showDetails(){ cout<<"\n Name is \t"<<Name; cout<<"\n Branch is \t"<<Branch; cout<<"\n Id is \t\t"<<id<<endl; } }; class Account : public Bank{ public: string Acc_Name; int age; void setAcc(string na, int a){ Acc_Name = na; age = a; } void showAcc(){ cout<<"\n Account Name is "<<Acc_Name; cout<<"\n Age is \t"<<age; showDetails(); } }; class Console{ public: void details(){ cout<<"\n\t Abhishek Mishra \n"; cout<<"\n\t 06-CSE-A \n"; } void input(){ Bank *bank; Account depo; bank = &depo; bank->enterDetails("abc", "xyz", 10); bank->showDetails(); } }; int main() { Console console; console.details(); console.input(); }
ec52533ab4285c68db7eaf0a7072df5941be0fba
177f5c6751c09e5848fa6897a8b539ca64bc135c
/GLRole_Prey.cpp
b95069064aeaa11c6819e148f797444b12943125
[ "MIT" ]
permissive
cschen1205/cpp-flocking
4f95b7a1483048c4b380e140abdd7ceb168cb8ee
67d4c4297df1a377e2d5f9ad91997234c482f078
refs/heads/master
2021-01-23T10:28:40.692947
2017-06-16T13:15:46
2017-06-16T13:15:46
93,061,526
0
1
null
null
null
null
UTF-8
C++
false
false
1,403
cpp
#include "GLRole_Prey.h" #include "GameEntity.h" #include "GameWorld.h" #include <cfloat> GLRole_Prey::GLRole_Prey(GameEntity* pAgent) : GLRole(pAgent) , m_pEvadeSteeringHandler(NULL) { } GLRole_Prey::~GLRole_Prey() { } void GLRole_Prey::Update(const long& lElapsedTicks) { if(m_pEvadeSteeringHandler == NULL) { return; } AgentGroup& agents=m_pAgent->GetWorld()->GetMutableAgents(); AgentGroup::iterator pos_agent; Vehicle* pAgent=NULL; double closest_distance=DBL_MAX; Vehicle* current_predator=NULL; GLVector agent_position=m_pAgent->get_position(); for(pos_agent=agents.begin(); pos_agent!=agents.end(); ++pos_agent) { pAgent=(*pos_agent); if(m_pAgent == pAgent) { continue; } if(!pAgent->InTheSameZone(m_pAgent)) { continue; } if(m_predator_ids.find(pAgent->GetTypeId())!=m_predator_ids.end()) { double distance=(pAgent->get_position() - agent_position).length(); if(current_predator == NULL) { current_predator=pAgent; closest_distance=distance; } else if(closest_distance > distance) { current_predator=pAgent; closest_distance=distance; } } } m_pEvadeSteeringHandler->SetEvadeTarget(current_predator); } bool GLRole_Prey::IsPenetratable(int TypeId) const { std::set<int>::const_iterator pos=m_predator_ids.find(TypeId); if(pos != m_predator_ids.end()) { return true; } else { return false; } }
254c87a6edd1b20616bc5a6ec874b056543fcf00
196e55f16c09d2eba75f3a38208ee6beb65aa0e4
/MyGame/Classes/GamePlay.h
35462f08b5d2dca18f4170dcec3cefa4c61ecd7f
[]
no_license
MrBia/CC_Game
a89f927771bbca235eec63e8b4165e60b8a34439
86ec3f4bb7e2b2374ce62386fce2084d56a525b1
refs/heads/master
2020-12-14T06:31:00.398935
2020-03-20T04:27:15
2020-03-20T04:27:15
234,668,663
0
0
null
null
null
null
UTF-8
C++
false
false
1,691
h
#pragma once #include "C:\Users\Admin\Desktop\CC_Game\MyGame\cocos2d\cocos\2d\CCScene.h" #include "cocos2d.h" #include "SneakyJoystick.h" #include "SneakyJoystickSkinnedBase.h" #include "Objject.h" #include "Knight.h" #include "Zombie.h" #include "Dragon.h" #include "ui\UIButton.h" #include "Soul.h" #include "CountTime.h" #define MARGIN_JOYSTICK 50 USING_NS_CC; using namespace ui; class GamePlay : public Layer { private: // map CCTMXTiledMap* _tileMap; CCTMXLayer* _background; CCTMXLayer* _object; CCTMXObjectGroup *_objectGroup; CCTMXLayer* _physics; Sprite* sprite; SneakyJoystickSkinnedBase* joystickBase; SneakyJoystick *leftJoystick; float activeRunRange; // object Objject* knight; Objject* zombie; std::vector<Objject*> zombies; Objject * dragon; std::vector<Objject*> dragons; // joystick Layer* layerr; ui::Button* btnFight; bool allowFight; ui::Button* btnFire; bool allowFire; // counttime CountTime* countNormalFight; CountTime* countSkillFight; bool isNormal = true; bool isSkill = true; public: static Scene* createGame(); virtual bool init(); void update(float deltaTime); void createMap(); void createObject(); void setViewPointCenter(CCPoint position); void OnKeyPressed(EventKeyboard::KeyCode keyCode, Event* event); void OnKeyReleased(EventKeyboard::KeyCode keyCode, Event* event); void addDispatCher(); void createEdge(); void createPhysic(); void Fight(Ref* sender, Widget::TouchEventType type); void Fire(Ref* sender, Widget::TouchEventType type); bool onContactBegin(PhysicsContact& contact); void createJoystick(Layer* layer); void UpdateJoystick(float dt); GamePlay(); ~GamePlay(); CREATE_FUNC(GamePlay); };
b131264b1d8bb1a4f363c5f85d2e0baddc1b81ed
6ced41da926682548df646099662e79d7a6022c5
/aws-cpp-sdk-redshift-serverless/source/model/DeleteEndpointAccessResult.cpp
5abade171a2bdcd37bfa5eb7a81be294cc0a54e5
[ "Apache-2.0", "MIT", "JSON" ]
permissive
irods/aws-sdk-cpp
139104843de529f615defa4f6b8e20bc95a6be05
2c7fb1a048c96713a28b730e1f48096bd231e932
refs/heads/main
2023-07-25T12:12:04.363757
2022-08-26T15:33:31
2022-08-26T15:33:31
141,315,346
0
1
Apache-2.0
2022-08-26T17:45:09
2018-07-17T16:24:06
C++
UTF-8
C++
false
false
1,012
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/redshift-serverless/model/DeleteEndpointAccessResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::RedshiftServerless::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; DeleteEndpointAccessResult::DeleteEndpointAccessResult() { } DeleteEndpointAccessResult::DeleteEndpointAccessResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } DeleteEndpointAccessResult& DeleteEndpointAccessResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("endpoint")) { m_endpoint = jsonValue.GetObject("endpoint"); } return *this; }
ce0292a8a0fd8964932e1be092216ed886ccf783
065b5aa4323af0a41a27016106eeaa7992b0727e
/namedialog.h
d759958fc8b81b9ccc3c3d29c6f8ab7cf130724b
[]
no_license
Zentions/OSG
197b64d12c191348382718a9d03e7f6e90e1a21d
f0dc5c8f17594dec37be4be67062f56730e79e31
refs/heads/master
2020-12-02T07:45:13.787846
2017-07-10T00:32:20
2017-07-10T00:32:20
96,719,775
0
0
null
null
null
null
UTF-8
C++
false
false
732
h
#ifndef NAMEDIALOG_H #define NAMEDIALOG_H #include <QDialog> #include <QMessageBox> #include <QFileDialog> #include <QDir> #include <QDebug> namespace Ui { class NameDialog; } class NameDialog : public QDialog { Q_OBJECT public: explicit NameDialog(QWidget *parent = 0); QString getName(); void setTypeName(QString typeName); ~NameDialog(); private slots: void on_confirmBtn_clicked(); void on_concelBtn_clicked(); void on_browseBtn_clicked(); void on_fileRouteEdit_cursorPositionChanged(int arg1, int arg2); signals: void sendData(QString,QList<QCheckBox*>); private: Ui::NameDialog *ui; QList<QCheckBox*> boxList; void createSubFolder(); }; #endif // NAMEDIALOG_H
bc78f27140d0c21fde9d4bc8de8ad9fe09f51e3a
389e63b6f9df400537033c39590d469c9f8df7c5
/Tries & Huffman Coding/patternMatcing.cpp
67b4e4a4bda774d2829f43831e70af64114b2bb3
[]
no_license
parthoMalakar/Data-Structure
c203b7fb29ef92e0a19e09e24e23eed576f5cdea
4ac50741f58d0f88c1a657224883ae7e690669fe
refs/heads/master
2022-12-07T04:31:15.053509
2020-08-26T09:12:45
2020-08-26T09:12:45
279,027,174
0
0
null
null
null
null
UTF-8
C++
false
false
2,673
cpp
/* Pattern Matching Send Feedback Given a list of n words and a pattern p that we want to search. Check if the pattern p is present the given words or not. Return true or false. Input Format : Line 1 : Integer n Line 2 : n words (separated by space) Line 3 : Pattern p (a string) Output Format : true ot false Sample Input 1 : 4 abc def ghi cba de Sample Output 2 : true Sample Input 2 : 4 abc def ghi hg hi Sample Output 2 : true Sample Input 3 : 4 abc def ghi hg hif Sample Output 3 : false */ #include <iostream> #include <string> #include <vector> using namespace std; class TrieNode { public : char data; TrieNode **children; bool isTerminal; TrieNode(char data) { this -> data = data; children = new TrieNode*[26]; for(int i = 0; i < 26; i++) { children[i] = NULL; } isTerminal = false; } }; class Trie { TrieNode *root; public : int count; Trie() { this->count = 0; root = new TrieNode('\0'); } bool insertWord(TrieNode *root, string word) { // Base case if(word.size() == 0) { if (!root->isTerminal) { root -> isTerminal = true; return true; } else { return false; } } // Small Calculation int index = word[0] - 'a'; TrieNode *child; if(root -> children[index] != NULL) { child = root -> children[index]; } else { child = new TrieNode(word[0]); root -> children[index] = child; } // Recursive call return insertWord(child, word.substr(1)); } // For user void insertWord(string word) { if (insertWord(root, word)) { this->count++; } } bool search(TrieNode* root,string word){ if(word.size()==0){ return true; } int index=word[0]-'a'; bool ans; if(root->children[index]!=NULL) ans=search(root->children[index],word.substr(1)); else ans=false; return ans; } bool patternMatching(vector<string> vect, string pattern) { for(int i=0;i<vect.size();i++) { for(int j=0;j<vect[i].size();j++) insertWord(vect[i].substr(j)); } return search(root,pattern); } }; int main() { Trie t; int N; cin >> N; string pattern; vector<string> vect; for (int i=0; i < N; i++) { string word; cin >> word; vect.push_back(word); } cin >> pattern; if (t.patternMatching(vect, pattern)) { cout << "true" << endl; } else { cout << "false" << endl; } }
d3c6ec30e392a1f482418dd5aae88641d49830ce
c7f6cd6cebfeda2ab685955a9683a22d244dcb1c
/ModuleCpp/bjetExtractor.cxx
542ffa1e3111c284b0ef8f4df7d2c2e7b7ffa05c
[]
no_license
teqn0x/Module_Rbl
27a2e8e957172a4f4e930e94f6dcf9436f2f0634
8f31aa0d99ac3a9f84838d929a4e056082bd35fe
refs/heads/master
2021-01-10T19:32:53.864283
2014-08-07T09:07:38
2014-08-07T09:07:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,638
cxx
#include <iostream> #include "TLorentzVector.h" #include "bjetExtractor.h" // Constructor, called with j1,j2,j3,j4 and their MV1 variables mv11,mv12,mv13,mv14 bjetExtractor::bjetExtractor(TLorentzVector j1, TLorentzVector j2, TLorentzVector j3, TLorentzVector j4, float mv11, float mv12, float mv13, float mv14){ lv[0] = j1; lv[1] = j2; lv[2] = j3; lv[3] = j4; mv1[0] = mv11; mv1[1] = mv12; mv1[2] = mv13; mv1[3] = mv14; sortByMV1(lv,mv1); setJets(lv); } // Destructor bjetExtractor::~bjetExtractor() {} // Sorting algorithm, doing the sorting for MV1 and change the order of the LorentzVectors of the jets accordingly. // Sorts from small to large MV1 (just like the Python sort function does, so it avoids confusion) void bjetExtractor::sortByMV1(TLorentzVector *v, float *mv){ for(int i = 0; i < 4; i++){ for(int j = 0; j < 4-1-i; j++){ if(mv[j+1] < mv[j]){ swap(mv[j+1],mv[j]); swap(v[j+1],v[j]); } } } } // Overloaded swap functions for floats and TLorentzVectors, would be nicer if made a template // so it could also take doubles as MV1's or something void bjetExtractor::swap(float &a, float &b){ float tmp = a; a = b; b = tmp; } void bjetExtractor::swap(TLorentzVector &a, TLorentzVector &b){ TLorentzVector tmp = a; a = b; b = tmp; } // Extracting the leading and subleading jets/bjets void bjetExtractor::setJets(TLorentzVector *v){ if(v[0].Pt() > v[1].Pt()){ jet1 = v[0]; jet2 = v[1]; } else { jet1 = v[1]; jet2 = v[0]; } if (v[2].Pt() > v[3].Pt()){ bjet1 = v[2]; bjet2 = v[3]; } else { bjet1 = v[3]; bjet2 = v[2]; } }
4d60141b245405d587a2ca65933c87301ef9bf62
abce0e27384dd9b93224c94e395fee097363a145
/C++ DS-ALGO/src/Sort/SelectionSort.h
027807e51c3c23a269431d31454bf3277adedced
[]
no_license
ngmgit/ds-algo
ae3f9ed203ed091aaab25e70b37960d59148ad76
629fd9f8ad4dfd305b7362356b230ac7a91e4b75
refs/heads/master
2020-04-03T05:18:20.492353
2018-10-28T06:09:15
2018-10-28T06:09:15
155,041,178
0
0
null
null
null
null
UTF-8
C++
false
false
505
h
#ifndef MY_SELECTION_SORT_H #define MY_SELECTION_SORT_H #include <vector> template <typename T> void SelectSort(std::vector<T>& arr); template <typename T> void SelectSort(std::vector<T>& arr) { int minIdx; for (int i = 0; i < arr.size() - 1; i++) { minIdx = i; for (int j = i + 1; j < arr.size(); j++) { if (arr[j] < arr[minIdx]) minIdx = j; } // swap i with the min; if (minIdx != i) { int temp = arr[minIdx]; arr[minIdx] = arr[i]; arr[i] = temp; } } } #endif
d0230e5ca9b8faaa68f48d098f1edd09584d30fe
7e0ea62e544f93860a1c9de4e76afb9519075322
/Parcial 1/Multiplicacion x10/multiplicacion_x10.cpp
1fa073efca3d42fb83d8e4079b33dc8a570918a2
[]
no_license
RamsesGA/Programacion_2_2019b_Ramses_Guerrero_Ambriz
d3873437b05f2373ce7fd1f13e53c48c66970861
9a8e45b157f0ce107ce632be8517fe4f623bf625
refs/heads/master
2020-05-18T02:40:12.042971
2019-08-14T17:35:21
2019-08-14T17:35:21
184,123,197
0
0
null
null
null
null
UTF-8
C++
false
false
273
cpp
#include "Librerias.h" using namespace std; int main() { char numero[255]; cout << "Ingresa un numero y le daremos el valor x10" << endl; cin >> numero; strcat_s(numero, "0"); cout << "El numero x10 es: " << numero << endl; cin.get(); cin.ignore(); return 0; }
6a7cebdf4bf7de975915c91c79b89ca2b04b2124
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/contest/1542595141.cpp
0633fce2d9e0fd111a9f9b1d023782e13269c726
[]
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
1,829
cpp
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <unordered_set> #include <vector> #include <cmath> #include <string> #include <set> #include <map> #include <queue> #include <cstdio> #include <random> #include <ctime> #include <cassert> #include <bitset> #include <unordered_map> #include <stack> using namespace std; #define N 100001 #define M 20 #define LOCAL 0 mt19937 gen(time(NULL)); #define forn(i, n) for (int i = 0; i < n; i++) #define fornv(i, n) for (int i = n - 1; i >= 0; i--) #define pii pair<int, int> #define forlr(i, l, r) for (int i = l; i <= r; i++) #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #define all(a) (a).begin(), (a).end() #define mp make_pair typedef long long ll; const int inf = 1e9; const int mod = 1e9 + 7; const double eps = 1e-9; #define p p2 #define endl '\n' inline int read() { int val = 0, sign = 1; char ch; for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') sign = -1; for (; ch >= '0' && ch <= '9'; ch = getchar()) val = val * 10 + ch - '0'; return sign * val; } int w[4]; int arr[N]; void solve() { string s; cin >> s; int n = read(); vector<string> vu(n); forn(i, n) { cin >> vu[i]; if (vu[i] == s) { puts("YES"); return; } } forn(i, n) forn(j, n) { string cct = vu[i] + vu[j]; if (cct.find(s) != string::npos) { puts("YES"); return; } } puts("NO"); } int main() { int t = 1; if (LOCAL) freopen("test.out", "r", stdin); while (t--) { clock_t z = clock(); solve(); debug("Elapsed Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC); } }
46346d7c5ece8b09ccb41695f07ccf64d7d30b61
c953b84ab4f12f7684d10112df2ae49d9c9fb363
/packages/language/c/libc/time/v3_0/src/strptime.cxx
8979326dbfac78a80086dc342a25fe9017013f53
[]
no_license
resper-guo/Umind-eCos-mt7628
768396a9b7457a75690d4fe6c76263ee22dd0c30
c98eb43702500c80a021388014162adce73c3b1a
refs/heads/master
2022-10-22T02:41:44.750239
2020-06-12T01:15:20
2020-06-12T01:15:20
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
8,907
cxx
// // Adapted for use in eCos by Gary Thomas // Copyright (C) 2003 Gary Thomas // /* * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of KTH 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 KTH AND ITS 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 KTH OR ITS CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stddef.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <time.h> static const char *weekdays[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", NULL }; static const char *month[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL, }; static const char *ampm[] = { "am", "pm", NULL }; /* * Try to match `*buf' to one of the strings in `strs'. Return the * index of the matching string (or -1 if none). Also advance buf. */ static int match_string (const char **buf, const char **strs, int ablen) { int i = 0; for (i = 0; strs[i] != NULL; ++i) { int len = ablen > 0 ? ablen : strlen (strs[i]); if (strncasecmp (*buf, strs[i], len) == 0) { *buf += len; return i; } } return -1; } /* * tm_year is relative this year */ const int tm_year_base = 1900; /* * Return TRUE iff `year' was a leap year. */ static int is_leap_year (int year) { return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); } /* * Return the weekday [0,6] (0 = Sunday) of the first day of `year' */ static int first_day (int year) { int ret = 4; // Jan 1, 1970 was on Thursday for (; year > 1970; --year) ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7; return ret; } /* * Set `timeptr' given `wnum' (week number [0, 53]) */ static void set_week_number_sun (struct tm *timeptr, int wnum) { int fday = first_day (timeptr->tm_year + tm_year_base); timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday; if (timeptr->tm_yday < 0) { timeptr->tm_wday = fday; timeptr->tm_yday = 0; } } /* * Set `timeptr' given `wnum' (week number [0, 53]) */ static void set_week_number_mon (struct tm *timeptr, int wnum) { int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday; if (timeptr->tm_yday < 0) { timeptr->tm_wday = (fday + 1) % 7; timeptr->tm_yday = 0; } } /* * Set `timeptr' given `wnum' (week number [0, 53]) */ static void set_week_number_mon4 (struct tm *timeptr, int wnum) { int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7; int offset = 0; if (fday < 4) offset += 7; timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday; if (timeptr->tm_yday < 0) { timeptr->tm_wday = fday; timeptr->tm_yday = 0; } } /* * */ char * strptime (const char *buf, const char *format, struct tm *timeptr) { char c; for (; (c = *format) != '\0'; ++format) { char *s; int ret = 0; if (isspace (c)) { while (isspace (*buf)) ++buf; } else if (c == '%' && format[1] != '\0') { c = *++format; if (c == 'E' || c == 'O') c = *++format; switch (c) { case 'A' : ret = match_string (&buf, weekdays, 0); if (ret < 0) return NULL; timeptr->tm_wday = ret; break; case 'a' : ret = match_string (&buf, weekdays, 3); if (ret < 0) return NULL; timeptr->tm_wday = ret; break; case 'B' : ret = match_string (&buf, month, 0); if (ret < 0) return NULL; timeptr->tm_mon = ret; break; case 'b' : case 'h' : ret = match_string (&buf, month, 3); if (ret < 0) return NULL; timeptr->tm_mon = ret; break; case 'C' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_year = (ret * 100) - tm_year_base; buf = s; break; case 'c' : // Date and Time in the current locale - unsupported return NULL; case 'D' : /* %m/%d/%y */ s = strptime (buf, "%m/%d/%y", timeptr); if (s == NULL) return NULL; buf = s; break; case 'd' : case 'e' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_mday = ret; buf = s; break; case 'H' : case 'k' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_hour = ret; buf = s; break; case 'I' : case 'l' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; if (ret == 12) timeptr->tm_hour = 0; else timeptr->tm_hour = ret; buf = s; break; case 'j' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_yday = ret - 1; buf = s; break; case 'm' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_mon = ret - 1; buf = s; break; case 'M' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_min = ret; buf = s; break; case 'n' : if (*buf == '\n') ++buf; else return NULL; break; case 'p' : ret = match_string (&buf, ampm, 0); if (ret < 0) return NULL; if (timeptr->tm_hour == 0) { if (ret == 1) timeptr->tm_hour = 12; } else timeptr->tm_hour += 12; break; case 'r' : /* %I:%M:%S %p */ s = strptime (buf, "%I:%M:%S %p", timeptr); if (s == NULL) return NULL; buf = s; break; case 'R' : /* %H:%M */ s = strptime (buf, "%H:%M", timeptr); if (s == NULL) return NULL; buf = s; break; case 'S' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_sec = ret; buf = s; break; case 't' : if (*buf == '\t') ++buf; else return NULL; break; case 'T' : /* %H:%M:%S */ case 'X' : s = strptime (buf, "%H:%M:%S", timeptr); if (s == NULL) return NULL; buf = s; break; case 'u' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_wday = ret - 1; buf = s; break; case 'w' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_wday = ret; buf = s; break; case 'U' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; set_week_number_sun (timeptr, ret); buf = s; break; case 'V' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; set_week_number_mon4 (timeptr, ret); buf = s; break; case 'W' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; set_week_number_mon (timeptr, ret); buf = s; break; case 'x' : s = strptime (buf, "%Y:%m:%d", timeptr); if (s == NULL) return NULL; buf = s; break; case 'y' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; if (ret < 70) timeptr->tm_year = 100 + ret; else timeptr->tm_year = ret; buf = s; break; case 'Y' : ret = strtol (buf, &s, 10); if (s == buf) return NULL; timeptr->tm_year = ret - tm_year_base; buf = s; break; case 'Z' : // Timezone spec not handled return NULL; case '\0' : --format; /* FALLTHROUGH */ case '%' : if (*buf == '%') ++buf; else return NULL; break; default : if (*buf == '%' || *++buf == c) ++buf; else return NULL; break; } } else { if (*buf == c) ++buf; else return NULL; } } return (char *)buf; } // strptime.cxx
c7baa0bc3888aca31b4cc79e0f87b6f3d72eae8b
9f19bb2cf94e37f25a7a3c1550cac872e8fda4da
/Rock, Paper, Scissors.cpp
93b6992a62fcffcf07682f4fda1ed055030c4459
[]
no_license
cxz66666/PEG-DMOJ-Solutions
bf7987112f2fb7d1b3d7a7ce43caa03e5b981024
8c1beccc7d6e768f903dac827fd47eb7d739069c
refs/heads/master
2021-09-05T02:55:07.873534
2018-01-23T18:55:04
2018-01-23T18:55:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,998
cpp
#include <bits/stdc++.h> #define UNVISITED 0 #define MAXN 5001 using namespace std; vector <int> buff; // for SCC vector <int> adj[MAXN], dag[MAXN]; int dfs_num[MAXN], dfs_low[MAXN]; bool in_stack[MAXN]; int dfsnumcount; int N, M, Q; int nSCC = 0, group[MAXN], groupsize[MAXN]; void SCC(int cur) { dfs_num[cur] = dfs_low[cur] = ++dfsnumcount; buff.push_back(cur); // push onto SCC stack in_stack[cur] = true; for (int i = 0; i < adj[cur].size(); i++) { int v = adj[cur][i]; if (dfs_num[v] == UNVISITED) SCC(v); if (in_stack[v]) // condition for update dfs_low[cur] = min(dfs_low[cur], dfs_low[v]); } if (dfs_num[cur] == dfs_low[cur]) // if cur is the start of a SCC { while (1) { int v = buff.back(); buff.pop_back(); in_stack[v] = false; // do sth here group[v] = nSCC; groupsize[nSCC]++; if (v == cur) break; } nSCC++; } } void processDAG() { for (int i = 1; i <= N; i++) { for (int j : adj[i]) { if (group[i]!=group[j]) { dag[group[i]].push_back(group[j]); } } } for (int i = 0; i < nSCC; i++) dag[i].erase(unique(dag[i].begin(), dag[i].end()), dag[i].end()); } int dist[MAXN][MAXN]; bool done[MAXN]; void spfa(int src) { for (int i = 0; i < nSCC; i++) { done[i] = false; dist[src][i] = -1; } queue <int> buff; dist[src][src] = 0; buff.push(src); done[src]=true; while(!buff.empty()) { int cur = buff.front(); buff.pop(); done[cur] = false; for (int i : dag[cur]) { if (dist[src][cur] + groupsize[i] > dist[src][i]) { dist[src][i] = dist[src][cur] + groupsize[i]; if (!done[i]) { done[i] = true; buff.push(i); } } } } } int allpairlongest() { for (int i = 0; i < nSCC; i++) spfa(i); } int main() { cin>>N>>M>>Q; for (int i = 0,a ,b; i < M; i++) { cin>>a>>b; adj[a].push_back(b); } for (int i = 1; i <= N; i++) { if (dfs_num[i]==UNVISITED) SCC(i); } processDAG(); allpairlongest(); for (int i = 0, a, b; i < Q; i++) { cin>>a>>b; bool OK = true; if (group[a]==group[b]) OK = false; if (!OK) { cout<<"Indeterminate\n"; continue; } int ga= group[a], gb = group[b]; int ans = -1; if (~dist[ga][gb]) { ans = dist[ga][gb] - groupsize[gb]; } else if (~dist[gb][ga]) { ans = dist[gb][ga] - groupsize[ga]; swap(a,b); } else { cout<<"Indeterminate\n"; continue; } cout<<a<<" "<<ans<<"\n"; } }
e97926b99f94c9a7b5b7c94655970e26fd047dc0
3dc0930fd1917250c8476c42293fde29139886ed
/Week 11/Chapter15_PolymorphicBehaviour/Chapter15_PolymorphicBehaviour/Main.cpp
77557ed8ce0083f5a50819b3037a28eb10213e2e
[]
no_license
charlottemarriner/Semester-1-GEC
e62ccd9cfb6d3c69ab7eb4be97bed5f49f0d9678
a32a7306fd305972ef9bf3a8d5374c3654178ddd
refs/heads/master
2022-04-08T01:08:04.194855
2020-03-20T14:46:35
2020-03-20T14:46:35
241,207,361
0
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
//Main.cpp #include "Mammals.h" #include <iostream> using namespace::std; int main() { Mammal* mammalPtr; int choice; cout << "1.Dog 2.Cat 3.Horse 4.Pig" << endl << "Enter choice: "; cin >> choice; cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); //Create the chosen mammal - stored within a mammal pointer. switch (choice) { case 1: mammalPtr = new Dog(); break; case 2: mammalPtr = new Cat(); break; case 3: mammalPtr = new Horse(); break; case 4: mammalPtr = new Pig(); break; default: mammalPtr = new Mammal(); break; } //Make this mammal speak. mammalPtr->Speak(); cin.get(); return 0; }
b8e6998d97794aa2c3d74ae0daeef1b724e3640f
d6e866e54ccb82dd75e49dc1fc4d63d2f050c962
/src/DFNavigatorNode.cpp
de44cefb5e2d8da764eca81e180c087f59572a2b
[]
no_license
D-Wazzle/Robotino-BFS-DFS
609b3bffe99d6544f100e37fed45c1bdb5b0676d
cdafa20ee854b60ddc4da399821a61bc83c33481
refs/heads/master
2021-01-22T04:05:11.029848
2017-02-09T22:11:53
2017-02-09T22:11:53
81,499,666
1
0
null
null
null
null
UTF-8
C++
false
false
1,333
cpp
// // DFNavigatorNode.cpp // searchTree // // Created by Dylan Wallace on 07/11/16. // Using Breadth-First code from Kris Krasnosky as reference. // Copyright (c) 2016 DASL@UNLV. All rights reserved. // #include <iostream> #include "DFNavigator.h" #include "ros/ros.h" int main(int argc, char **argv) { ros::init(argc, argv, "DFNavigatorNode"); map myMap; depthFirst mySearch; DFNavigator navigator; myMap.createGrid(12, 12); myMap.setOriginOnGrid(0, 0); myMap.addGoal(0, 7); for(int i=0;i<=4;i++){ myMap.addObstacle(i, 3); } for(int i=0;i<=4;i++){ myMap.addObstacle(i, 6); } for(int i=0;i<=4;i++){ myMap.addObstacle(8, i); } for(int i=7;i<=9;i++){ myMap.addObstacle(4, i); } for(int i=7;i<=9;i++){ myMap.addObstacle(6, i); } myMap.addObstacle(5, 7); myMap.addObstacle(5, 9); myMap.addObstacle(8, 8); myMap.addObstacle(11, 11); mySearch.theMap=myMap; mySearch.start(2, 1); for (int i=0; i<mySearch.path.size(); i++) { std::cout << "{" << mySearch.path[i][0] << "," << mySearch.path[i][1] << "},"; } navigator.setOdom(0,0,0); navigator.pathfinder.theMap=myMap; navigator.navigatePath(); std::cout<<std::endl; return 0; }
4ef82d5b53b146728a65e647b46eb3160964c9fb
4d560955d5b0a6a8d3f7a116472447f0a82abd78
/src/reader.cpp
0093158f5ee33b9a41c0d0251cfcde7dc114b0b5
[]
no_license
ChrisToumanian/fallen-star-server
400ec1b5defcc353e6d63819b3e967c5a1ba47fd
b919dfd5962365256f8dfc79d77881099d0f6b18
refs/heads/master
2022-12-29T01:44:38.299082
2020-10-18T09:59:19
2020-10-18T09:59:19
303,323,975
0
0
null
null
null
null
UTF-8
C++
false
false
1,384
cpp
#include "reader.h" std::vector<std::string> Reader::get_file_lines(std::string filename) { std::vector<std::string> lines; std::ifstream file(filename); for (std::string line; std::getline(file, line); ) { lines.push_back(line); } return lines; } std::vector<std::string> Reader::split(std::string str, std::string delimiter) { std::vector<std::string> result; size_t pos = 0; std::string token; while ((pos = str.find(delimiter)) != std::string::npos) { token = str.substr(0, pos); result.push_back(token); str.erase(0, pos + delimiter.length()); } result.push_back(str); return result; } std::string Reader::join(std::vector<std::string> arr) { std::string str = ""; for (int i = 0; i < arr.size(); i++) str += arr[i] + " "; return str; } std::string Reader::join(std::vector<std::string> arr, int first_element) { std::string str = ""; for (int i = first_element; i < arr.size(); i++) str += arr[i] + " "; return str; } std::string Reader::join(std::vector<std::string> arr, int first_element, int last_element) { std::string str = ""; for (int i = first_element; i < last_element + 1; i++) str += arr[i] + " "; return str; } void Reader::rtrim(std::string &str) { str.erase(str.find_last_not_of(" \n\r\t") + 1); }
1f64a611e4937247e5e71a4a677abddcadb3978d
4484d88a5c9305e6092932a5e4cd79f4d84862ef
/abc/181/181c.cpp
d0ba314ff61e021b6634ad60324455811a3f1c2f
[]
no_license
kumastry/atcoder
44dd20b9e784ecc2c92b772ef31fd84e007eb8cd
076360ece55bd918a3bd60f8a7ac3c69dd1044e9
refs/heads/main
2023-07-13T06:44:42.296796
2021-08-12T18:36:27
2021-08-12T18:36:27
325,573,728
0
0
null
null
null
null
UTF-8
C++
false
false
1,834
cpp
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <cmath> #include <iomanip> #include <cstdio> #include <set> #include <map> #include <list> #include <cstdlib> #include <queue> #include <stack> #include <bitset> using namespace std; #define MOD 1000000007 #define PI 3.1415926535897932 #define INF 1e9 #define rep(i, n) for (int i = 0; i < n; i++) #define repe(i, j, n) for (int i = j; i < n; i++) #define repi(i, n) for (int i = 0; i <= n; i++) #define repie(i, j, n) for (int i = j; i <= n; i++) #define all(x) x.begin(), x.end() #define println() cout << endl #define P pair<int, int> #define fi first #define se second typedef long long ll; long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } void solve1() { int n; cin >> n; vector<P> xy(n); rep(i, n) { cin >> xy[i].fi >> xy[i].se; } bool f = false; for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { for(int k = j + 1; k < n; k++) { P a = xy[i]; P b = xy[j]; P c = xy[k]; P ab, ac, bc; ab.fi = b.fi - a.fi; ab.se = b.se - a.se; ac.fi = c.fi - a.fi; ac.se = c.se - a.se; if(ab.fi*ac.se == ab.se*ac.fi) { f = true; goto la; } } } } la: if(f) { cout << "Yes" << endl; } else { cout << "No" << endl; } } int main() { solve1(); }
e20cbbbc2711ed9fafbc3213adffa814ac807014
0f4aebcd62598989cb279e034d1a1613f8725082
/client/include/rdc/rdc_client.h
3c37d7f984dc6be0543155f62df31455304b1ac0
[ "MIT" ]
permissive
louishp/rdc
b4bea8b9e6adc616e3d3b87489b1a3c4f88e93b7
5e1111d4cb5da38930f2466e53e9b573374ca818
refs/heads/master
2022-12-11T01:11:30.160930
2020-09-01T01:13:15
2020-09-03T00:07:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,290
h
/* Copyright (c) 2019 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CLIENT_INCLUDE_RDC_RDC_CLIENT_H_ #define CLIENT_INCLUDE_RDC_RDC_CLIENT_H_ #include <grpcpp/grpcpp.h> #include <memory> #include <string> #include "rocm_smi/rocm_smi.h" /** * @brief Error codes retured by rdc functions */ typedef enum { RDC_STATUS_SUCCESS = 0x0, //!< Operation was successful RDC_RSMI_STATUS_INVALID_ARGS, //!< Passed in arguments are not valid RDC_RSMI_STATUS_NOT_SUPPORTED, //!< The requested information or //!< action is not available for the //!< given input, on the given system RDC_RSMI_STATUS_FILE_ERROR, //!< Problem accessing a file. This //!< may because the operation is not //!< supported by the Linux kernel //!< version running on the executing //!< machine RDC_RSMI_STATUS_PERMISSION, //!< Permission denied/EACCESS file //!< error. Many functions require //!< root access to run. RDC_RSMI_STATUS_OUT_OF_RESOURCES, //!< Unable to acquire memory or other //!< resource RDC_RSMI_STATUS_INTERNAL_EXCEPTION, //!< An internal exception was caught RDC_RSMI_STATUS_INPUT_OUT_OF_BOUNDS, //!< The provided input is out of //!< allowable or safe range RDC_RSMI_STATUS_INIT_ERROR, //!< An error occurred when creating //!< a communications channel RDC_RSMI_STATUS_NOT_YET_IMPLEMENTED, //!< The requested function has not //!< yet been implemented in the //!< current system for the current //!< devices RDC_RSMI_STATUS_NOT_FOUND, //!< An item was searched for but not //!< found RDC_RSMI_STATUS_INSUFFICIENT_SIZE, //!< Not enough resources were //!< available for the operation RDC_RSMI_STATUS_INTERRUPT, //!< An interrupt occurred during //!< execution of function RDC_RSMI_STATUS_UNEXPECTED_SIZE, //!< An unexpected amount of data //!< was read RDC_RSMI_STATUS_NO_DATA, //!< No data was found for a given //!< input RDC_RSMI_STATUS_UNKNOWN_ERROR, //!< An unknown error occurred RDC_STATUS_GRPC_ERR_FIRST = 1000, /// Not an error; returned on success. RDC_STATUS_GRPC_OK = RDC_STATUS_GRPC_ERR_FIRST, /// The operation was cancelled (typically by the caller). RDC_STATUS_GRPC_CANCELLED, /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space /// that is not known in this address space. Also errors raised by APIs that /// do not return enough error information may be converted to this error. RDC_STATUS_GRPC_UNKNOWN, /// Client specified an invalid argument. Note that this differs from /// FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are /// problematic regardless of the state of the system (e.g., a malformed file /// name). RDC_STATUS_GRPC_INVALID_ARG, /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the /// operation has completed successfully. For example, a successful response /// from a server could have been delayed long enough for the deadline to /// expire. RDC_STATUS_GRPC_DEADLINE_EXCEEDED, /// Some requested entity (e.g., file or directory) was not found. RDC_STATUS_GRPC_NOT_FOUND, /// Some entity that we attempted to create (e.g., file or directory) already /// exists. RDC_STATUS_GRPC_ALREADY_EXISTS, /// The caller does not have permission to execute the specified operation. /// PERMISSION_DENIED must not be used for rejections caused by exhausting /// some resource (use RESOURCE_EXHAUSTED instead for those errors). /// PERMISSION_DENIED must not be used if the caller can not be identified /// (use UNAUTHENTICATED instead for those errors). RDC_STATUS_GRPC_PERM_DENIED, /// The request does not have valid authentication credentials for the /// operation. RDC_STATUS_GRPC_UNAUTHENTICATED, /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. RDC_STATUS_GRPC_RESOURCE_EXHAUSTED, /// Operation was rejected because the system is not in a state required for /// the operation's execution. For example, directory to be deleted may be /// non-empty, an rmdir operation is applied to a non-directory, etc. /// /// A litmus test that may help a service implementor in deciding /// between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: /// (a) Use UNAVAILABLE if the client can retry just the failing call. /// (b) Use ABORTED if the client should retry at a higher-level /// (e.g., restarting a read-modify-write sequence). /// (c) Use FAILED_PRECONDITION if the client should not retry until /// the system state has been explicitly fixed. E.g., if an "rmdir" /// fails because the directory is non-empty, FAILED_PRECONDITION /// should be returned since the client should not retry unless /// they have first fixed up the directory by deleting files from it. /// (d) Use FAILED_PRECONDITION if the client performs conditional /// REST Get/Update/Delete on a resource and the resource on the /// server does not match the condition. E.g., conflicting /// read-modify-write on the same resource. RDC_STATUS_GRPC_FAILED_PRECOND, /// The operation was aborted, typically due to a concurrency issue like /// sequencer check failures, transaction aborts, etc. /// /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, /// and UNAVAILABLE. RDC_STATUS_GRPC_ABORTED, /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. /// /// Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed /// if the system state changes. For example, a 32-bit file system will /// generate INVALID_ARGUMENT if asked to read at an offset that is not in the /// range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from /// an offset past the current file size. /// /// There is a fair bit of overlap between FAILED_PRECONDITION and /// OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error) /// when it applies so that callers who are iterating through a space can /// easily look for an OUT_OF_RANGE error to detect when they are done. RDC_STATUS_GRPC_OUT_OF_RANGE, /// Operation is not implemented or not supported/enabled in this service. RDC_STATUS_GRPC_UNIMPLEMENTED, /// Internal errors. Means some invariants expected by underlying System has /// been broken. If you see one of these errors, Something is very broken. RDC_STATUS_GRPC_INTERNAL, /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. /// /// \warning Although data MIGHT not have been transmitted when this /// status occurs, there is NOT A GUARANTEE that the server has not seen /// anything. So in general it is unsafe to retry on this status code /// if the call is non-idempotent. /// /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, /// and UNAVAILABLE. RDC_STATUS_GRPC_UNAVAILABLE, /// Unrecoverable data loss or corruption. RDC_STATUS_GRPC_DATA_LOSS, RDC_STATUS_CLIENT_ERR_FIRST = 2000, /// SSL authentication error occurred. RDC_STATUS_CLIENT_ERR_SSL = RDC_STATUS_CLIENT_ERR_FIRST, RDC_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred } rdc_status_t; /** * @brief Handle to RDC server channel */ typedef uintptr_t rdc_channel_t; #define RDC_DEFAULT_SERVER_PORT 50051 #define RDC_DEFAULT_SERVER_IP "localhost" /*****************************************************************************/ /** @defgroup RDCAdmin RDC Administration Functions * These administrative functions are used to monitor and control, for * example RDC connectivity. * @{ */ /** * @brief Check the connection status of a channel * * @details Given an ::rdc_channel_t @p channel and a boolean @p * try_to_connect, this function will return the grpc_connectivity_state for * that channel * * @p channel[in] The channel for which the status will be given * * @param[in] try_to_connect If the channel is currently IDLE, if the argument * is true, transition to CONNECTING. * * @param[inout] state A pointer to caller provided memory to which an * the grpc_connectivity_state will be written. grpc_connectivity_state has * the following possible values: * GRPC_CHANNEL_IDLE channel is idle * GRPC_CHANNEL_CONNECTING channel is connecting * GRPC_CHANNEL_READY channel is ready for work * GRPC_CHANNEL_TRANSIENT_FAILURE channel has seen a failure but expects to * recover * GRPC_CHANNEL_SHUTDOWN channel has seen a failure that it cannot * recover from * * @retval ::RDC_STATUS_SUCCESS is returned upon successful call. * */ rdc_status_t rdc_channel_state_get(rdc_channel_t channel, bool try_to_connect, grpc_connectivity_state *state); /** * @brief Verify a channel's connection to the server * * @details Given an ::rdc_channel_t @p channel, this function will send a * random number to the server associated with @p channel. The server will send * the number back. Upon receiving the returned message from the server, the * number sent to the server is compared to the number received from the * server. If the 2 numbers are the same, the connection is verified. * Otherwise, an appropriate error code is returned. * * @p channel[in] The channel for which the connection will be verified * * @retval ::RDC_STATUS_SUCCESS is returned upon successful call. * */ rdc_status_t rdc_channel_connection_verify(rdc_channel_t channel); /** @} */ // end of RDCAdmin /*****************************************************************************/ /** @defgroup InitShutAdmin Initialization and Shutdown * These functions are used for initialization of RDC and clean up when * done. * @{ */ /** * @brief Create a communications channel to an RDC server * * @details Given a pointer to an ::rdc_channel_t @p channel, a string * containing the ip address of the server @p ip, a string containing * the port number on which the server is listening @p port and a bool * indicating whether the channel should use a secure link @p secure, * this function will attempt to create a new channel and write its * location to address pointed to by @p channel. * * @p channel[inout] A pointer to caller provided memory to which an * ::rdc_channel_t will be written * * @param[in] ip A pointer to a string containing the address of the server. * If nullptr is passed for this parameter, RDC_DEFAULT_SERVER_IP will be used. * * @param[in] port A pointer to string containing the port on which the * RDC server is listening. If nullptr is passed for this parameter, * RDC_DEFAULT_SERVER_PORT will be used. * * @param[in] secure A bool indicating whether SSL should be used for * communications (not currently supported) * * @retval ::RDC_STATUS_SUCCESS is returned upon successful call. * */ rdc_status_t rdc_channel_create(rdc_channel_t *channel, const char *ip, const char *port, bool secure); /** * @brief Destroy a communications channel to an RDC server * * @details Given an ::rdc_channel_t @p channel, this function will free any * resources used by @p channel * * @p channel[inout] An ::rdc_channel_t will be freed * * @retval ::RDC_STATUS_SUCCESS is returned upon successful call. * */ rdc_status_t rdc_channel_destroy(rdc_channel_t channel); /** @} */ // end of InitShutAdmin /*****************************************************************************/ /** @defgroup RSMIAccess Remote ROCm SMI Calls * These functions calls make ROCm SMI function calls on the remote server. * Please refer to the * [ROCm SMI documentation] * (https://github.com/RadeonOpenCompute/rocm_smi_lib/tree/master/docs) for * information about the calls. Here, we will document any additional aspects * of the calls introduced by RDC that are not covered in the ROCm SMI * documentation. * * All of the functions in this section attempt to make an RSMI call on the * server machine, given an ::rdc_channel_t associated with the server, and * all the arguments that are required to make the RSMI call. * @{ */ /** * @brief Remote call to rsmi_num_monitor_devices() * */ rdc_status_t rdc_num_gpus_get(rdc_channel_t channel, uint64_t *num_gpu); /** @} */ // end of RSMIAccess /** @defgroup PhysQuer Physical State Queries * These functions provide information about the physical characteristics of * the device. * @{ */ /** * @brief Remote call to rsmi_dev_temp_metric_get() * */ rdc_status_t rdc_dev_temp_metric_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_type, rsmi_temperature_metric_t metric, int64_t *temperature); /** * @brief Remote call to rsmi_dev_fan_rpms_get() * */ rdc_status_t rdc_dev_fan_rpms_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind, int64_t *rpms); /** * @brief Remote call to rsmi_dev_fan_speed_get() * */ rdc_status_t rdc_dev_fan_speed_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind, int64_t *speed); /** * @brief Remote call to rsmi_dev_fan_speed_max_get() * */ rdc_status_t rdc_dev_fan_speed_max_get(rdc_channel_t channel, uint32_t dv_ind, uint32_t sensor_ind, uint64_t *max_speed); /** @} */ // end of PhysQuer /** * @brief Get a description of a provided RDC error status * * @details Set the provided pointer to a const char *, @p status_string, to * a string containing a description of the provided error code @p status. * * @param[in] status The error status for which a description is desired * * @param[inout] status_string A pointer to a const char * which will be made * to point to a description of the provided error code * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call * */ rdc_status_t rdc_status_string(rdc_status_t status, const char **status_string); #endif // CLIENT_INCLUDE_RDC_RDC_CLIENT_H_
8a314f102cc778c98e95d8b00b58750c3fdfaa17
b2d162fa858e58e28a1c753b191d7b8295c505b2
/shapeWorks/code/ITKParticleSystem/itkParticleFunctionBasedShapeSpaceData.h
e453c6c885bd50b4f759accc8e00b554a3438734
[]
no_license
XiaoxiaoLiu/SCDS
8c1f64a66dc6daa1458ffc67ba71323183c2397a
594496aff64f5b2f54723e55ab34ba03263f1ef3
refs/heads/master
2016-09-06T09:26:05.561116
2013-06-25T15:26:34
2013-06-25T15:26:34
2,816,144
1
1
null
null
null
null
UTF-8
C++
false
false
10,550
h
/*========================================================================= Program: ShapeWorks: Particle-based Shape Correspondence & Visualization Module: $RCSfile: itkParticleFunctionBasedShapeSpaceData.h,v $ Date: $Date: 2009/05/06 21:49:15 $ Version: $Revision: 1.1.1.1 $ Author: $Author: cates $ Copyright (c) 2009 Scientific Computing and Imaging Institute. See ShapeWorksLicense.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __itkParticleFunctionBasedShapeSpaceData_h #define __itkParticleFunctionBasedShapeSpaceData_h //#include "itkImageFileWriter.h" #include "itkDataObject.h" #include "itkWeakPointer.h" #include "itkParticleAttribute.h" #include "itkParticleContainer.h" #include "itkVectorLinearInterpolateImageFunction.h" #include "itkLinearInterpolateImageFunction.h" #include "itkGradientImageFilter.h" #include <vector> #include "vnl/vnl_matrix.h" namespace itk { /** \class ParticleFunctionBasedShapeSpaceData * * \brief * */ template <class T, unsigned int VDimension> class ITK_EXPORT ParticleFunctionBasedShapeSpaceData : public ParticleAttribute<VDimension> { public: /** Standard class typedefs */ typedef ParticleFunctionBasedShapeSpaceData Self; typedef ParticleAttribute<VDimension> Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; typedef WeakPointer<const Self> ConstWeakPointer; typedef T DataType; /** Type of the ITK image used by this class. */ typedef Image<T, VDimension> ImageType; /** Point type used to store particle locations. */ typedef Point<double, VDimension> PointType; typedef GradientImageFilter<ImageType> GradientImageFilterType; typedef typename GradientImageFilterType::OutputImageType GradientImageType; typedef VectorLinearInterpolateImageFunction<GradientImageType, typename PointType::CoordRepType> GradientInterpolatorType; typedef LinearInterpolateImageFunction<ImageType, typename PointType::CoordRepType> ScalarInterpolatorType; typedef FixedArray<T, 3> VectorType; typedef vnl_vector_fixed<T, 3> VnlVectorType; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ParticleFunctionBasedShapeSpaceData, ParticleAttribute); /** Returns the number of dimensions of the shape space, which is the number of particles per shape times the number of position-based functions we are using. */ unsigned int GetNumberOfDimensions() const { return m_NumberOfParticles * m_NumberOfFunctions; } /** Returns the number of samples in the shape space, which is the number of surfaces we are using. */ unsigned int GetNumberOfSamples() const { return m_NumberOfSamples; } /** Adds a function image for shape d. */ void AddFunctionImage(int d, ImageType *I) { this->Modified(); // Make sure we have allocated a list for this shape. while (d >= m_ScalarInterpolators.size() ) { // std::cout << "d = " << d << " Adding domain" << std::endl; this->AddDomain(); // itkExceptionMacro("Not enough function interpolator lists have been allocated."); } if (d == 0) m_NumberOfFunctions++; // assumes all will have same number of functions typename ImageType::Pointer newimage = I; // m_FunctionImages[d].push_back(I); // std::cout << "adding image " << I << std::endl; // typename ImageFileWriter<ImageType>::Pointer writer = ImageFileWriter<ImageType>::New(); // writer->SetInput(I); // writer->SetFileName("test.mha"); // writer->Update(); // Set up a scalar interpolator typename ScalarInterpolatorType::Pointer si = ScalarInterpolatorType::New(); si->SetInputImage(I); m_ScalarInterpolators[d].push_back(si); // Compute gradient image and set up gradient interpolation. typename GradientImageFilterType::Pointer filter = GradientImageFilterType::New(); filter->SetInput(I); filter->SetUseImageSpacingOn(); filter->Update(); typename GradientInterpolatorType::Pointer gi = GradientInterpolatorType::New(); gi->SetInputImage(filter->GetOutput()); m_GradientInterpolators[d].push_back(gi); } /** Return the number of functions referenced by an instance of this class. */ unsigned int GetNumberOfFunctions() const { return m_NumberOfFunctions; } DataType GetScalar(unsigned int sample, unsigned int dim) { unsigned int f = dim % m_NumberOfFunctions; unsigned int idx = dim / m_NumberOfFunctions; // std::cout << "shape=" << sample << " function=" << f << " idx=" << idx << " value="; // std::cout << m_ScalarInterpolators[sample][f]->Evaluate(m_ParticleSystem->GetTransformedPosition(idx,sample)) << std::endl; // std::cout << "Transformed pos = " << m_ParticleSystem->GetTransformedPosition(idx, sample) << std::endl; return m_ScalarInterpolators[sample][f]->Evaluate(m_ParticleSystem->GetTransformedPosition(idx,sample)); } // inline VectorType SampleGradient(const PointType &p) const // { return m_GradientInterpolator->Evaluate(p); } // inline VnlVectorType SampleGradientVnl(const PointType &p) const // { return VnlVectorType( this->SampleGradient(p).GetDataPointer() ); } typename Self::VectorType GetGradient(unsigned int sample, unsigned int dim) { unsigned int f = dim % m_NumberOfFunctions; unsigned int idx = dim / m_NumberOfFunctions; return m_GradientInterpolators[sample][f]->Evaluate(m_ParticleSystem->GetTransformedPosition(idx,sample)); } /** Callbacks that may be defined by a subclass. If a subclass defines one of these callback methods, the corresponding flag in m_DefinedCallbacks should be set to true so that the ParticleSystem will know to register the appropriate event with this method. */ virtual void DomainAddEventCallback(Object *, const EventObject &e) { // const itk::ParticleDomainAddEvent &event // = dynamic_cast<const itk::ParticleDomainAddEvent &>(e); // unsigned int d = event.GetDomainIndex(); // Allocate a new list for gradient and shape interpolators // m_ScalarInterpolators.push_back(std::vector<typename ScalarInterpolatorType::Pointer>); // m_GradientInterpolators.push_back(std::vector<typename GradientInterpolatorType::Pointer>); m_NumberOfSamples++; } virtual void PositionAddEventCallback(Object *o, const EventObject &e) { const itk::ParticlePositionAddEvent &event = dynamic_cast<const itk::ParticlePositionAddEvent &>(e); const itk::ParticleSystem<VDimension> *ps = dynamic_cast<const itk::ParticleSystem<VDimension> *>(o); const int d = event.GetDomainIndex(); const unsigned int idx = event.GetPositionIndex(); m_ParticleSystem = const_cast<itk::ParticleSystem<VDimension> *>(ps); // cache the particle system we are working with const typename itk::ParticleSystem<VDimension>::PointType pos = ps->GetTransformedPosition(idx, d); // Assumes number of particles is equal in all domains if (d == 0) m_NumberOfParticles++; } // virtual void PositionSetEventCallback(Object *o, const EventObject &e) // { // const itk::ParticlePositionSetEvent &event = dynamic_cast<const itk::ParticlePositionSetEvent &>(e); // const itk::ParticleSystem<VDimension> *ps= dynamic_cast<const itk::ParticleSystem<VDimension> *>(o); // const int d = event.GetDomainIndex(); // const unsigned int idx = event.GetPositionIndex(); // const typename itk::ParticleSystem<VDimension>::PointType pos = ps->GetTransformedPosition(idx, d); // // Find and set the values for the given particle position. // } // virtual void PositionRemoveEventCallback(Object *, const EventObject &) // { // // NEED TO IMPLEMENT THIS // } /** This method is a hack to work around some tricky design isssues */ void AddDomain() { m_ScalarInterpolators.push_back(std::vector<typename ScalarInterpolatorType::Pointer>()); m_GradientInterpolators.push_back(std::vector<typename GradientInterpolatorType::Pointer>()); // m_FunctionImages.push_back(std::vector<typename ImageType::Pointer>()); // m_GradientImages.push_back(std::vector<typename GradientImageType::Pointer>()); } protected: ParticleFunctionBasedShapeSpaceData() { m_NumberOfParticles = 0; m_NumberOfSamples = 0; m_NumberOfFunctions = 0; m_ParticleSystem = 0; this->m_DefinedCallbacks.DomainAddEvent = true; this->m_DefinedCallbacks.PositionAddEvent = true; // this->m_DefinedCallbacks.PositionSetEvent = true; // this->m_DefinedCallbacks.PositionRemoveEvent = true; } virtual ~ParticleFunctionBasedShapeSpaceData() {}; void PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf(os,indent); } private: ParticleFunctionBasedShapeSpaceData(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented /** The number of samples corresponds to the number of domains in the particle system. */ int m_NumberOfSamples; /** The number of dimensions is equal to the number of functions times the number of particles, so we need to cache the number of particles here. */ int m_NumberOfParticles; /** */ int m_NumberOfFunctions; // Used to cache the particle system that this class is registered with. This // is a slight hack... ParticleSystem<VDimension> *m_ParticleSystem; // std::vector<std::vector<typename ImageType::Pointer> > m_FunctionImages; // std::vector<std::vector<typename GradientImageType::Point> > m_GradientImages; std::vector<std::vector<typename GradientInterpolatorType::Pointer> > m_GradientInterpolators; std::vector<std::vector<typename ScalarInterpolatorType::Pointer> > m_ScalarInterpolators; }; } // end namespace #endif
56cef2a87aaa7d7ecdd678768b9cc6fedfab1f74
ffdc77394c5b5532b243cf3c33bd584cbdc65cb7
/mindspore/lite/tools/converter/parser/caffe/caffe_quantize_parser.h
4c8c791a9787e2464ec1cc20d0093b00ded2d823
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "MPL-1.0", "OpenSSL", "LGPL-3.0-only", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause-Open-MPI", "MIT", "MPL-2.0-no-copyleft-exception", "NTP", "BSD-3-Clause", "GPL-1.0-or-later", "0BSD", "MPL-2.0", "LicenseRef-scancode-free-unknown", "AGPL-3.0-only", "Libpng", "MPL-1.1", "IJG", "GPL-2.0-only", "BSL-1.0", "Zlib", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-python-cwi", "BSD-2-Clause", "LicenseRef-scancode-gary-s-brown", "LGPL-2.1-only", "LicenseRef-scancode-other-permissive", "Python-2.0", "LicenseRef-scancode-mit-nagy", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference", "Unlicense" ]
permissive
mindspore-ai/mindspore
ca7d5bb51a3451c2705ff2e583a740589d80393b
54acb15d435533c815ee1bd9f6dc0b56b4d4cf83
refs/heads/master
2023-07-29T09:17:11.051569
2023-07-17T13:14:15
2023-07-17T13:14:15
239,714,835
4,178
768
Apache-2.0
2023-07-26T22:31:11
2020-02-11T08:43:48
C++
UTF-8
C++
false
false
1,398
h
/** * Copyright 2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_CAFFE_CAFFE_QUANTIZE_PARSER_H_ #define MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_CAFFE_CAFFE_QUANTIZE_PARSER_H_ #ifdef ENABLE_ACL_QUANT_PARAM #include "tools/converter/parser/caffe/caffe_node_parser.h" #include "tools/converter/parser/caffe/caffe_node_parser_registry.h" namespace mindspore { namespace lite { class CaffeQuantizeParser : public CaffeNodeParser { public: CaffeQuantizeParser() : CaffeNodeParser("quantize") {} ~CaffeQuantizeParser() override = default; PrimitiveCPtr Parse(const caffe::LayerParameter &proto, const caffe::LayerParameter &weight) override; }; } // namespace lite } // namespace mindspore #endif // ENABLE_ACL_QUANT_PARAM #endif // MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_CAFFE_CAFFE_QUANTIZE_PARSER_H_
40e815001eafa41a7f65c963ec165e6553ae68c5
3f755200ff5b776d276106b4bf68bda0cfa195a0
/src/main.cpp
1230f6482fa8469cd1d4b247b321d49ed2eaeb30
[]
no_license
ArmyAntSEC/RHex_Barebones
f0fdb48727705bbc038618fbc10bbcb158c38cc7
a3a69c2fb0c3de3c8a847e7a8e7a200e015b7c24
refs/heads/master
2023-03-05T13:44:15.313864
2021-02-08T18:23:27
2021-02-08T18:23:27
328,362,318
0
0
null
null
null
null
UTF-8
C++
false
false
1,749
cpp
#include <Arduino.h> #include <pwm_lib.h> using namespace arduino_due::pwm_lib; #define MOTOR_EN1 48 #define MOTOR_EN2 49 #define MOTOR_CS A5 #define ENCODER_1 50 #define ENCODER_2 51 #define OPTO 52 pwm<pwm_pin::PWML3_PC8> MOTOR_PWM; long int numberOfClicksOne = 0; long int numberOfClicksTwo = 0; void interruptHandlerOne(void) { noInterrupts(); numberOfClicksOne++; interrupts(); } void interruptHandlerTwo(void) { noInterrupts(); numberOfClicksTwo++; interrupts(); } void setup() { Serial.begin(115200); Serial.println ( "Hello World!" ); pinMode ( MOTOR_EN1, OUTPUT ); pinMode ( MOTOR_EN2, OUTPUT ); pinMode ( MOTOR_CS, INPUT ); pinMode ( OPTO, INPUT ); MOTOR_PWM.start ( 4096, 0 ); digitalWrite ( MOTOR_EN1, 0 ); digitalWrite ( MOTOR_EN2, 1 ); attachInterrupt ( digitalPinToInterrupt(ENCODER_1), interruptHandlerOne, CHANGE ); attachInterrupt ( digitalPinToInterrupt(ENCODER_2), interruptHandlerTwo, CHANGE ); } int loopCount = 0; void loop() { delay(1000); noInterrupts(); long int one = numberOfClicksOne; long int two = numberOfClicksTwo; interrupts(); Serial.print ( "Beep: " ); int current = analogRead ( MOTOR_CS ); Serial.print ( current ); if ( loopCount >= 16 ) { MOTOR_PWM.set_duty( 0 ); Serial.print( ", " ); Serial.print ( 0 ); } else { MOTOR_PWM.set_duty( loopCount*256 ); Serial.print( ", " ); Serial.print ( loopCount*16 ); } Serial.print ( ", " ); Serial.print ( one ); Serial.print ( ", " ); Serial.print ( two ); Serial.print ( ", " ); Serial.print ( one - two ); Serial.print ( ", " ); Serial.print ( digitalRead ( OPTO ) ); Serial.println(); if ( loopCount++ >= 15 ) MOTOR_PWM.set_duty( 0 ); }
b5cb8664ae7b55ad79729688ef65b82f241bb213
ee5824d3c041ce25f4f05dd9d95a30e0bbbabe69
/1041.cpp
5d6b2def3a71eb380fbe03ad1ea396aaff933eb5
[]
no_license
Lisltria/PAT-Advanced-Level-Practice-
bcc3703116fd9387e4c406ef4b99b75ed94b7a06
529657db963bbd47cd7ad338a5f61b67e3bda9a2
refs/heads/master
2020-03-31T19:51:00.168002
2018-12-10T13:26:29
2018-12-10T13:26:29
152,514,436
0
0
null
null
null
null
UTF-8
C++
false
false
594
cpp
#include <iostream> #include <cstdio> #include <vector> using namespace std; int _hash[100001]; int N; vector<int> list; int main() { cin>>N; for(int i=0;i<N;i++) { int t; scanf("%d",&t); list.push_back(t); _hash[t]++; } bool flag=false; for(vector<int>::iterator iter = list.begin();iter!=list.end();iter++) { int t; t=*iter; if(_hash[t]==1) { flag=true; cout<<t<<endl; break; } } if(!flag) { cout<<"None"<<endl; } return 0; }
d674e43e2ddd2adb5031e9914056ae77ccce2266
fe75ab418adfd723f48b8eafc80515c9fd913395
/LeetCode/0119. Pascal's Triangle II.cpp
29e8326fa54c8f92edffa2b92e7c36675fe2e748
[]
no_license
AshkenSC/Programming-Practice
d029e9d901f51ef750ed4089f10c1f16783d2695
98e20c63ce1590deda6761ff2f9c8c37f3fb3c4a
refs/heads/master
2021-07-20T06:41:12.673248
2021-06-25T15:44:06
2021-06-25T15:44:06
127,313,792
0
0
null
null
null
null
UTF-8
C++
false
false
733
cpp
/* 119. Pascal's Triangle II 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。 */ class Solution { public: vector<int> getRow(int rowIndex) { vector<vector<int>> result; result.push_back(vector<int>(1, 1)); for (int i = 2; i <= rowIndex + 1; i++) { vector<int> row(i); row[0] = 1; for (int j = 1; j < i; j++) { if (j == i - 1) { row[j] = 1; break; } else { row[j] = result[i - 2][j - 1] + result[i - 2][j]; } } result.push_back(row); } return result[rowIndex]; } };
b9e9d6ba171e6fcc95ad07f40dd85c962be3a977
e8be8e3beaeb86c7eea1bce244be530bbd8ac27c
/hotel/profileedit.cpp
e0d8312595f6fe11875e07b5e7ca3715276a2c77
[]
no_license
tuxmuzon/hotel
1bd4798863c2e657af7fe52a76994873100f9a2e
df08c4588169c482229c7b6da2a207581a66d98c
refs/heads/master
2020-08-03T16:06:43.055409
2019-10-01T05:54:55
2019-10-01T05:54:55
211,808,923
0
0
null
null
null
null
UTF-8
C++
false
false
11,633
cpp
#include "profileedit.h" #include <QGridLayout> #include "QLabel" #include "core/esqlquery.h" #include "QSqlRecord" #include "QSqlError" #include "QDebug" #include "QGroupBox" static const QStringList sexItems = QStringList() << "Мужской" << "Женский"; // получуается это нужно только для иностраных граждан в связке с визитом static const QStringList visitDocs = QStringList() << "Виза" << "Вид на жительство" << "Разрешение на временное проживание"; static const QStringList purposeOfVisit = QStringList() << "Служебная" << "Туризм" << "Деловая" << "Учеба" << "Работа" << "Частная" << "Гуманитарная" << "Другая"; profileEdit::profileEdit(int prodileId , QWidget *parent) : QDialog (parent) { currentId = prodileId; QVBoxLayout *mainLayout = new QVBoxLayout(); lastName = new QLineEdit; secondName = new QLineEdit; firstName = new QLineEdit; QHBoxLayout *fio= new QHBoxLayout; QGroupBox *fioBox = new QGroupBox(tr("Анкетные данные")); fio->addWidget( new QLabel("Фамилия:")); fio->addWidget(firstName); fio->addWidget( new QLabel("Имя:")); fio->addWidget(secondName); fio->addWidget( new QLabel("Отчество:")); fio->addWidget(lastName); fioBox->setLayout(fio); mainLayout->addWidget(fioBox); QHBoxLayout *beathSex= new QHBoxLayout; QGroupBox *beathSexBox = new QGroupBox(tr("Личные данные")); beathSex->addWidget(new QLabel("Дата рождения:")); beathDay = new QDateEdit; beathDay->setDisplayFormat("dd.MM.yyyy"); //показывать календарь beathDay->setCalendarPopup(true); beathSex->addWidget(beathDay); sex =new QComboBox(); sex->addItems(sexItems); beathSex->addWidget( new QLabel("Пол:")); beathSex->addWidget(sex); beathSexBox->setLayout(beathSex); mainLayout->addWidget(beathSexBox); beathCountry = new QLineEdit(); residentCountry = new QLineEdit(); address = new QLineEdit(); QGroupBox *placeBox = new QGroupBox("Данные о месте проживания"); QVBoxLayout *placeMain = new QVBoxLayout; QHBoxLayout *place1 = new QHBoxLayout; place1->addWidget( new QLabel("Место рождения гос-во:")); place1->addWidget(beathCountry); placeMain->addLayout(place1); QHBoxLayout *place2 = new QHBoxLayout; place2->addWidget( new QLabel("Место жительства Страна:")); place2->addWidget(residentCountry); placeMain->addLayout(place2); QHBoxLayout *place3 = new QHBoxLayout; place3->addWidget( new QLabel("Место жительства Адрес:")); place3->addWidget(address); placeMain->addLayout(place3); placeBox->setLayout(placeMain); mainLayout->addWidget(placeBox); QGroupBox *docBox = new QGroupBox("Паспортные данные"); QVBoxLayout *docMain = new QVBoxLayout; docType = new QLineEdit(); QHBoxLayout *doc1 = new QHBoxLayout; doc1->addWidget( new QLabel("Документ удств. личность:")); doc1->addWidget(docType); docMain->addLayout(doc1); QHBoxLayout *doc2 = new QHBoxLayout; beathPlace = new QLineEdit(); doc2->addWidget(new QLabel("Место рождения как в паспорте:")); doc2->addWidget(beathPlace); docMain->addLayout(doc2); docCreateDate = new QDateEdit(); docCreateDate->setDisplayFormat("dd.MM.yyyy"); QHBoxLayout *doc3 = new QHBoxLayout; beathPlace = new QLineEdit(); doc3->addWidget(new QLabel("Дата выдачи:")); doc3->addWidget(docCreateDate); docMain->addLayout(doc3); docSerial = new QLineEdit(); docNumber = new QLineEdit(); QHBoxLayout *doc4 = new QHBoxLayout; beathPlace = new QLineEdit(); doc4->addWidget(new QLabel("Серия:")); doc4->addWidget(docSerial); doc4->addWidget( new QLabel("№:")); doc4->addWidget(docNumber); docMain->addLayout(doc4); // docValideDate = new QDateEdit(); docCreateOrg = new QLineEdit(); QHBoxLayout *doc5 = new QHBoxLayout; beathPlace = new QLineEdit(); doc5->addWidget(new QLabel("Кем выдан:")); doc5->addWidget(docCreateOrg); docMain->addLayout(doc5); docCreateOrgCode = new QLineEdit(); QHBoxLayout *doc6 = new QHBoxLayout; beathPlace = new QLineEdit(); doc6->addWidget(new QLabel("Код подразделения:")); doc6->addWidget(docCreateOrgCode); docMain->addLayout(doc6); docBox->setLayout(docMain); mainLayout->addWidget(docBox); eMail = new QLineEdit; mobilePhone = new QLineEdit; QGroupBox *contactBox = new QGroupBox("Контактные данные"); QHBoxLayout *contact = new QHBoxLayout; contact->addWidget(new QLabel("e-Mail:")); contact->addWidget(eMail); contact->addWidget(new QLabel("Телефон:")); contact->addWidget(mobilePhone); contactBox->setLayout(contact); mainLayout->addWidget(contactBox); isVip = new QCheckBox; vipPrice = new QSpinBox; connect(isVip, &QCheckBox::toggled,vipPrice,&QSpinBox::setEnabled); vipPrice->setDisabled(true); vipPrice->setMaximum(30000); vipPrice->setMinimum(200); // mainLayout->addWidget(new QLabel("Срок действия:"), 6,2); // mainLayout->addWidget(docValideDate,6,3); QGroupBox *grantBox = new QGroupBox("Дополнительные привелегии"); QHBoxLayout *grant = new QHBoxLayout(); grant->addWidget(isVip); grant->addWidget(new QLabel("Фиксированная Цена за место:")); grant->addWidget(vipPrice); grant->addStretch(1); grantBox->setLayout(grant); mainLayout->addWidget(grantBox); setLayout(mainLayout); setWindowTitle("Анкета клиента"); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox,&QDialogButtonBox::accepted,this,&profileEdit::slot_accept); connect(buttonBox,&QDialogButtonBox::rejected,this,&profileEdit::reject); mainLayout->addWidget(buttonBox); update(); } void profileEdit::update() { ESqlQuery query; qDebug() << "currentId: " << currentId; query.prepare("SELECT firstname, secondname, lastname, mobile_phone, email, beathday, sex, beath_country, beath_place, doc_type, " "doc_serial, doc_number, doc_create_date, doc_create_org, doc_create_org_code, resident_country, address, is_vip, vip_price::numeric::float8 " "FROM persons_profiles WHERE id = ? "); query.addBindValue(currentId); query.exec(); while(query.next()) { QSqlRecord rec = query.record(); firstName->setText(query.value(rec.indexOf("firstname")).toString()); secondName->setText(query.value(rec.indexOf("secondname")).toString()); lastName->setText(query.value(rec.indexOf("lastname")).toString()); mobilePhone->setText(query.value(rec.indexOf("mobile_phone")).toString()); eMail->setText(query.value(rec.indexOf("email")).toString()); beathDay->setDate(query.value(rec.indexOf("beathday")).toDate()); sex->setCurrentIndex(query.value(rec.indexOf("sex")).toInt()); beathCountry->setText(query.value(rec.indexOf("beath_country")).toString()); beathPlace->setText(query.value(rec.indexOf("beath_place")).toString()); docType->setText(query.value(rec.indexOf("doc_type")).toString()); docSerial->setText(query.value(rec.indexOf("doc_serial")).toString()); docNumber->setText(query.value(rec.indexOf("doc_number")).toString()); docCreateDate->setDate(query.value(rec.indexOf("doc_create_date")).toDate()); docCreateOrg->setText(query.value(rec.indexOf("doc_create_org")).toString()); docCreateOrgCode->setText(query.value(rec.indexOf("doc_create_org_code")).toString()); residentCountry->setText(query.value(rec.indexOf("resident_country")).toString()); address->setText(query.value(rec.indexOf("address")).toString()); isVip->setChecked(query.value(rec.indexOf("is_vip")).toBool()); vipPrice->setValue(query.value(rec.indexOf("vip_price")).toInt()); } } void profileEdit::slot_accept() { ESqlQuery query; if (currentId < 1) { query.prepare("INSERT INTO persons_profiles (firstname, secondname, lastname, mobile_phone, email, beathday, sex, beath_country, beath_place, doc_type, " "doc_serial, doc_number, doc_create_date, doc_create_org, doc_create_org_code, resident_country, address, is_vip, vip_price ) " "VALUES (:FirstName,:secondname,:lastname,:mobile_phone,:email,:beathday,:sex,:beath_country,:beath_place,:doc_type," ":doc_serial,:doc_number,:doc_create_date,:doc_create_org,:doc_create_org_code,:resident_country,:address,:is_vip,:vip_price) RETURNING id" ); } else { query.prepare("UPDATE persons_profiles SET " "firstname = :FirstName, " "secondname = :secondname, " "lastname = :lastname, " "mobile_phone = :mobile_phone, " "email = :email, " "beathday = :beathday, " "sex = :sex, " "beath_country = :beath_country, " "beath_place = :beath_place, " "doc_type = :doc_type, " "doc_serial = :doc_serial, " "doc_number = :doc_number, " "doc_create_date = :doc_create_date, " "doc_create_org = :doc_create_org, " "doc_create_org_code = :doc_create_org_code, " "resident_country = :resident_country, " "address = :address, " "is_vip = :is_vip, " "vip_price = :vip_price " "WHERE id =:ID "); query.bindValue(":ID", currentId); } query.bindValue(":FirstName", firstName->text()); query.bindValue(":secondname",secondName->text()); query.bindValue(":lastname",lastName->text()); query.bindValue(":mobile_phone",mobilePhone->text()); query.bindValue(":email",eMail->text()); query.bindValue(":beathday",beathDay->date()); query.bindValue(":sex",sex->currentIndex()); query.bindValue(":beath_country",beathCountry->text()); query.bindValue(":beath_place",beathPlace->text()); query.bindValue(":doc_type",docType->text()); query.bindValue(":doc_serial",docSerial->text()); query.bindValue(":doc_number",docNumber->text()); query.bindValue(":doc_create_date",docCreateDate->date()); query.bindValue(":doc_create_org",docCreateOrg->text()); query.bindValue(":doc_create_org_code",docCreateOrgCode->text()); query.bindValue(":resident_country",residentCountry->text()); query.bindValue(":address",address->text()); query.bindValue(":is_vip",isVip->isChecked()); query.bindValue(":vip_price",vipPrice->value()); if(!query.exec()){ QMessageBox::warning(this,"Ошибка сохранения", query.lastError().text()); } else { if(currentId < 1 && query.next()) { currentId = query.value(0).toInt(); } accept(); } }
964936a5df5d893777534095018c02e15ecc90ed
51c71b06d7fa1aa97df4ffe6782e9a4924480a33
/Calibration/Configuration.cpp
c8d59b9350d568ff8f0bf782e7668a075309732f
[]
no_license
alonf01/open-light
9eb8d185979cfa16797f9d2201cf192b3e91f270
685f974fcd7cc29b6bec00fa17804c5f2b7a83c3
refs/heads/master
2020-05-30T15:24:08.579565
2010-12-14T00:56:32
2010-12-14T00:56:32
35,759,673
0
0
null
null
null
null
UTF-8
C++
false
false
10,924
cpp
//////////////////////////////////////////////////////////////////////////////////////////////////// /// @file Calibration\Configuration.cpp /// /// @brief Implements the configuration class. //////////////////////////////////////////////////////////////////////////////////////////////////// #include "Configuration.h" #include "Calibration.h" #include "CalibrationExceptions.h" //////////////////////////////////////////////////////////////////////////////////////////////////// /// @fn public: Configuration(const char* filename, struct stParams* sl_params) /// /// @brief Constructor /// /// @author Brett Jones /// @date 12/12/2010 /// /// @param filename Configuration filename. /// @param [in,out] sl_params Paramaters. //////////////////////////////////////////////////////////////////////////////////////////////////// Configuration::Configuration(std::string filename, struct slParams* sl_params) { mFilename = filename; mSlParams = sl_params; } void Configuration::Load() { FILE* pFile = fopen(mFilename.c_str(), "r"); if(pFile != NULL){ fclose(pFile); printf("Reading configuration file \"%s\"...\n", mFilename); } else{ throw new FileNotFound("configuration file"); } // done to reuse existing code struct slParams* sl_params = mSlParams; // Open file storage for XML-formatted configuration file. CvFileStorage* fs = cvOpenFileStorage(mFilename.c_str(), 0, CV_STORAGE_READ); // Read output directory and object (or sequence) name. CvFileNode* m = cvGetFileNodeByName(fs, 0, "output"); strcpy(sl_params->outdir, cvReadStringByName(fs, m, "output_directory", "./output")); strcpy(sl_params->object, cvReadStringByName(fs, m, "object_name", "./output")); sl_params->save = (cvReadIntByName(fs, m, "save_intermediate_results", 0) != 0); // Read camera parameters. m = cvGetFileNodeByName(fs, 0, "camera"); sl_params->cam_w = cvReadIntByName(fs, m, "width", 960); sl_params->cam_h = cvReadIntByName(fs, m, "height", 720); sl_params->Logitech_9000 = (cvReadIntByName(fs, m, "Logitech_Quickcam_9000_raw_mode", 0) != 0); // Read projector parameters. m = cvGetFileNodeByName(fs, 0, "projector"); sl_params->proj_w = cvReadIntByName(fs, m, "width", 1024); sl_params->proj_h = cvReadIntByName(fs, m, "height", 768); sl_params->proj_invert = (cvReadIntByName(fs, m, "invert_projector", 0) != 0); // Read camera and projector gain parameters. m = cvGetFileNodeByName(fs, 0, "gain"); sl_params->cam_gain = cvReadIntByName(fs, m, "camera_gain", 50); sl_params->proj_gain = cvReadIntByName(fs, m, "projector_gain", 50); // Read distortion model parameters. m = cvGetFileNodeByName(fs, 0, "distortion_model"); sl_params->cam_dist_model[0] = (cvReadIntByName(fs, m, "enable_tangential_camera", 0) != 0); sl_params->cam_dist_model[1] = (cvReadIntByName(fs, m, "enable_6th_order_radial_camera", 0) != 0); sl_params->proj_dist_model[0] = (cvReadIntByName(fs, m, "enable_tangential_projector", 0) != 0); sl_params->proj_dist_model[1] = (cvReadIntByName(fs, m, "enable_6th_order_radial_projector", 0) != 0); // Read camera calibration chessboard parameters. m = cvGetFileNodeByName(fs, 0, "camera_chessboard"); sl_params->cam_board_w = cvReadIntByName(fs, m, "interior_horizontal_corners", 8); sl_params->cam_board_h = cvReadIntByName(fs, m, "interior_vertical_corners", 6); sl_params->cam_board_w_mm = (float)cvReadRealByName(fs, m, "square_width_mm", 30.0); sl_params->cam_board_h_mm = (float)cvReadRealByName(fs, m, "square_height_mm", 30.0); // Read projector calibration chessboard parameters. m = cvGetFileNodeByName(fs, 0, "projector_chessboard"); sl_params->proj_board_w = cvReadIntByName(fs, m, "interior_horizontal_corners", 8); sl_params->proj_board_h = cvReadIntByName(fs, m, "interior_vertical_corners", 6); sl_params->proj_board_w_pixels = cvReadIntByName(fs, m, "square_width_pixels", 75); sl_params->proj_board_h_pixels = cvReadIntByName(fs, m, "square_height_pixels", 75); // Read scanning and reconstruction parameters. m = cvGetFileNodeByName(fs, 0, "scanning_and_reconstruction"); sl_params->mode = cvReadIntByName(fs, m, "mode", 2); sl_params->scan_cols = (cvReadIntByName(fs, m, "reconstruct_columns", 1) != 0); sl_params->scan_rows = (cvReadIntByName(fs, m, "reconstruct_rows", 1) != 0); sl_params->delay = cvReadIntByName(fs, m, "frame_delay_ms", 200); sl_params->thresh = cvReadIntByName(fs, m, "minimum_contrast_threshold", 32); sl_params->dist_range[0] = (float) cvReadRealByName(fs, m, "minimum_distance_mm", 0.0); sl_params->dist_range[1] = (float) cvReadRealByName(fs, m, "maximum_distance_mm", 1.0e4); sl_params->dist_reject = (float) cvReadRealByName(fs, m, "maximum_distance_variation_mm", 10.0); sl_params->background_depth_thresh = (float) cvReadRealByName(fs, m, "minimum_background_distance_mm", 20.0); sl_params->generate_normals = (cvReadIntByName(fs, m, "generate_normals", 1) != 0); // Read visualization options. m = cvGetFileNodeByName(fs, 0, "visualization"); sl_params->display = (cvReadIntByName(fs, m, "display_intermediate_results", 1) != 0); sl_params->window_w = cvReadIntByName(fs, m, "display_window_width_pixels", 640); sl_params->window_offset_x = cvReadIntByName(fs, m, "window_offset_x", -13); sl_params->window_offset_y = cvReadIntByName(fs, m, "window_offset_y", -23); // Enable both row and column scanning, if "ray-ray" reconstruction mode is enabled. if(sl_params->mode == 2){ sl_params->scan_cols = true; sl_params->scan_rows = true; } // Set camera visualization window dimensions. sl_params->window_h = (int)ceil((float)sl_params->window_w*((float)sl_params->cam_h/(float)sl_params->cam_w)); // Close file storage for XML-formatted configuration file. cvReleaseFileStorage(&fs); } void Configuration::Save() { FILE* pFile = fopen(mFilename.c_str(), "r"); if(pFile != NULL){ fclose(pFile); printf("Reading configuration file \"%s\"...\n", mFilename); } else{ throw new FileNotFound("configuration file"); } // done to reuse existing code struct slParams* sl_params = mSlParams; // Create file storage for XML-formatted configuration file. CvFileStorage* fs = cvOpenFileStorage(mFilename.c_str(), 0, CV_STORAGE_WRITE); // Write output directory and object (or sequence) name. cvStartWriteStruct(fs, "output", CV_NODE_MAP); cvWriteString(fs, "output_directory", sl_params->outdir, 1); cvWriteString(fs, "object_name", sl_params->object, 1); cvWriteInt(fs, "save_intermediate_results", sl_params->save); cvEndWriteStruct(fs); // Write camera parameters. cvStartWriteStruct(fs, "camera", CV_NODE_MAP); cvWriteInt(fs, "width", sl_params->cam_w); cvWriteInt(fs, "height", sl_params->cam_h); cvWriteInt(fs, "Logitech_Quickcam_9000_raw_mode", sl_params->Logitech_9000); cvEndWriteStruct(fs); // Write projector parameters. cvStartWriteStruct(fs, "projector", CV_NODE_MAP); cvWriteInt(fs, "width", sl_params->proj_w); cvWriteInt(fs, "height", sl_params->proj_h); cvWriteInt(fs, "invert_projector", sl_params->proj_invert); cvEndWriteStruct(fs); // Write camera and projector gain parameters. cvStartWriteStruct(fs, "gain", CV_NODE_MAP); cvWriteInt(fs, "camera_gain", sl_params->cam_gain); cvWriteInt(fs, "projector_gain", sl_params->proj_gain); cvEndWriteStruct(fs); // Write distortion model parameters. cvStartWriteStruct(fs, "distortion_model", CV_NODE_MAP); cvWriteInt(fs, "enable_tangential_camera", sl_params->cam_dist_model[0]); cvWriteInt(fs, "enable_6th_order_radial_camera", sl_params->cam_dist_model[1]); cvWriteInt(fs, "enable_tangential_projector", sl_params->proj_dist_model[0]); cvWriteInt(fs, "enable_6th_order_radial_projector", sl_params->proj_dist_model[1]); cvEndWriteStruct(fs); // Write camera calibration chessboard parameters. cvStartWriteStruct(fs, "camera_chessboard", CV_NODE_MAP); cvWriteInt(fs, "interior_horizontal_corners", sl_params->cam_board_w); cvWriteInt(fs, "interior_vertical_corners", sl_params->cam_board_h); cvWriteReal(fs, "square_width_mm", sl_params->cam_board_w_mm); cvWriteReal(fs, "square_height_mm", sl_params->cam_board_h_mm); cvEndWriteStruct(fs); // Write projector calibration chessboard parameters. cvStartWriteStruct(fs, "projector_chessboard", CV_NODE_MAP); cvWriteInt(fs, "interior_horizontal_corners", sl_params->proj_board_w); cvWriteInt(fs, "interior_vertical_corners", sl_params->proj_board_h); cvWriteInt(fs, "square_width_pixels", sl_params->proj_board_w_pixels); cvWriteInt(fs, "square_height_pixels", sl_params->proj_board_h_pixels); cvEndWriteStruct(fs); // Write scanning and reconstruction parameters. cvStartWriteStruct(fs, "scanning_and_reconstruction", CV_NODE_MAP); cvWriteInt(fs, "mode", sl_params->mode); cvWriteInt(fs, "reconstruct_columns", sl_params->scan_cols); cvWriteInt(fs, "reconstruct_rows", sl_params->scan_rows); cvWriteInt(fs, "frame_delay_ms", sl_params->delay); cvWriteInt(fs, "minimum_contrast_threshold", sl_params->thresh); cvWriteReal(fs, "minimum_distance_mm", sl_params->dist_range[0]); cvWriteReal(fs, "maximum_distance_mm", sl_params->dist_range[1]); cvWriteReal(fs, "maximum_distance_variation_mm", sl_params->dist_reject); cvWriteReal(fs, "minimum_background_distance_mm", sl_params->background_depth_thresh); cvWriteInt(fs, "generate_normals", sl_params->generate_normals); cvEndWriteStruct(fs); // Write visualization options. cvStartWriteStruct(fs, "visualization", CV_NODE_MAP); cvWriteInt(fs, "display_intermediate_results", sl_params->display); cvWriteInt(fs, "display_window_width_pixels", sl_params->window_w); cvWriteInt(fs, "window_offset_x", sl_params->window_offset_x); cvWriteInt(fs, "window_offset_y", sl_params->window_offset_y); cvEndWriteStruct(fs); // Close file storage for XML-formatted configuration file. cvReleaseFileStorage(&fs); }
[ "b.jonessoda@8a600b9a-ddf7-11de-b878-c5ec750a8c44" ]
b.jonessoda@8a600b9a-ddf7-11de-b878-c5ec750a8c44
14d2e2b3489b4462352b9e5dfcb5b5d3fa6464aa
e1825eda73c111c85e07dceeab91b630475db07a
/Arduino/Romi-RPi-I2CSlave/motor_pid_control.ino
71a894919aac6034d51e6855c4ac8b3fe83fd960
[]
no_license
venki666/CpE476_demos
e9c043d42c76cb28b806b037f7f2e5e0f25e4fca
f2863ab2752de242bca1a2dffd04d2544bf95ecb
refs/heads/master
2023-08-14T10:20:57.060908
2023-08-10T05:32:03
2023-08-10T05:32:03
211,710,922
0
2
null
null
null
null
UTF-8
C++
false
false
5,116
ino
/* PID controller inspired by: https://github.com/jfstepha/differential-drive/blob/master/scripts/pid_velocity.py TODO : Integral term of PID seems broken. Try to tune at some point. */ #include "motor.h" /* methods smoothing instantaneous wheel velocities reported by the odometry methods get_instant_left_wheel_vel(), get_instant_right_wheel_vel() */ /* arrays for calculating moving window average wheel velocity */ const int _window_size = 10; float _left_vel_window[_window_size]; float _right_vel_window[_window_size]; float _pid_get_left_average_wheel_velocity() { // WARNING: _pid_get_left_average_wheel_velocity is not tested // and probably doesn't work // average instantaneous left wheel velocity // in meters per second float average = 0; static int i; _left_vel_window[i++] = get_instant_left_wheel_vel(); if ( i >= _window_size ) { i = 0; } for (int j = 0; j < _window_size; j++) { average += _left_vel_window[i]; } average /= _window_size; return average; } float _pid_get_right_average_wheel_velocity() { // WARNING: _pid_get_left_average_wheel_velocity is not tested // and probably doesn't work // average instantaneous right wheel velocity // in meters per second float average = 0; static int i; _right_vel_window[i++] = get_instant_right_wheel_vel(); if ( i >= _window_size ) { i = 0; } for (int j = 0; j < _window_size; j++) { average += _right_vel_window[i]; } average /= _window_size; return average; } /* setMotorSpeeds constraint the motor speed within the motor power limit then set the speeds */ void _pid_setMotorSpeeds(int16_t left_motor, int16_t right_motor, float left_error, float right_error, float *left_integral, float *right_integral, float duration_s ) { /* CONSTRAIN MOTOR SETTING TO THE MOTOR POWER LIMITS */ if ( left_motor > MOTOR_MAX ) { left_motor = MOTOR_MAX; *left_integral = *left_integral - (left_error * duration_s); } else if ( left_motor < MOTOR_MIN ) { left_motor = MOTOR_MIN; *left_integral = *left_integral - (left_error * duration_s); } if ( right_motor > MOTOR_MAX ) { right_motor = MOTOR_MAX; *right_integral = *right_integral - (right_error * duration_s); } else if ( right_motor < MOTOR_MIN ) { right_motor = MOTOR_MIN; *right_integral = *right_integral - (right_error * duration_s); } /* REMOVE THIS TO FOR ACTIVE BRAKING */ if ( get_left_wheel_target_velocity() == 0.0 ) { left_motor = 0; } if ( get_right_wheel_target_velocity() == 0.0 ) { right_motor = 0; } /* SET THE MOTORS */ hw_motors_setspeeds(left_motor, right_motor); } void doPID() { /* PID AND MOTOR CONSTANTS * note: these constants seem to work, * but may need to change depending on * physical robot configuration * * warning: the derivative term is untested. */ const float Kp = 2000.0; const float Ki = 7000.0; const float Kd = 0.0; /* STATIC VARIABLES */ static unsigned long prev_time_ms; static float left_prev_error, right_prev_error; static float left_integral, right_integral; /* TIME DURATION SINCE LAST UPDATE */ unsigned long current_time_ms = millis(); long duration_ms = current_time_ms - prev_time_ms; float duration_s = float(duration_ms) / 1000.0; /* CALCULATE ERROR : error = target - measured */ // TODO change this to use _pid_get_left_average_wheel_velocity, _pid_get_right_average_wheel_velocity float left_error = get_left_wheel_target_velocity() - get_instant_left_wheel_vel(); float right_error = get_right_wheel_target_velocity() - get_instant_right_wheel_vel(); /* * WARNING, the averaging methods are known to break the code and become unstable. float left_error = get_left_wheel_target_velocity() - _pid_get_left_average_wheel_velocity(); float right_error = get_right_wheel_target_velocity() - _pid_get_right_average_wheel_velocity(); */ #ifdef DBG_SRL /* this triggers once is the motors are quickly shut off */ if ( abs(left_error) > 0.1 or abs(right_error) > 0.1) { Serial.print("MOTOR ERROR!!!"); Serial.print(left_error); Serial.print(", "); Serial.print(right_error); } #endif /* PID CALCULATIONS*/ left_integral = left_integral + (left_error * duration_s); right_integral = right_integral + (right_error * duration_s); float left_derivative = (left_error - left_prev_error) / duration_s; float right_derivative = (right_error - right_prev_error) / duration_s; int16_t left_motor = int16_t(Kp * left_error + Ki * left_integral + Kd * left_derivative); int16_t right_motor = int16_t(Kp * right_error + Ki * right_integral + Kd * right_derivative); _pid_setMotorSpeeds(left_motor, right_motor, left_error, right_error, &left_integral, &right_integral, duration_s); // update previous values prev_time_ms = current_time_ms; left_prev_error = left_error; right_prev_error = right_error; }
e07e4f4db036fe7c167e89d14741489913ea2925
fa99d6a0981510675c6abdff0a9dde1fc61c319b
/Software/esp-idf-customized/components/asio/asio/asio/src/tests/unit/windows/random_access_handle.cpp
2a8f92ec7dcf9582d636442ea55b898a2f65a782
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "BSL-1.0" ]
permissive
trichl/WildFiOpenSource
f29de95b208586061d6d7a75ffd9c317ed0a4679
2ac5e86c3619782c8582ce81065f267dce830f0b
refs/heads/main
2023-04-19T00:01:50.853085
2021-10-09T09:09:33
2021-10-09T09:09:33
368,456,988
7
3
MIT
2022-10-25T03:13:18
2021-05-18T08:31:23
C
UTF-8
C++
false
false
4,584
cpp
// // random_access_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/windows/random_access_handle.hpp" #include "asio/io_context.hpp" #include "../archetypes/async_result.hpp" #include "../unit_test.hpp" //------------------------------------------------------------------------------ // windows_random_access_handle_compile test // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // The following test checks that all public member functions on the class // windows::random_access_handle compile and link correctly. Runtime failures // are ignored. namespace windows_random_access_handle_compile { void write_some_handler(const asio::error_code&, std::size_t) { } void read_some_handler(const asio::error_code&, std::size_t) { } void test() { #if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) using namespace asio; namespace win = asio::windows; try { io_context ioc; const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; asio::uint64_t offset = 0; archetypes::lazy_handler lazy; asio::error_code ec; // basic_random_access_handle constructors. win::random_access_handle handle1(ioc); HANDLE native_handle1 = INVALID_HANDLE_VALUE; #if defined(ASIO_MSVC) && (_MSC_VER < 1910) // Skip this on older MSVC due to mysterious ambiguous overload errors. #else win::random_access_handle handle2(ioc, native_handle1); #endif win::random_access_handle handle3(ioc_ex); HANDLE native_handle2 = INVALID_HANDLE_VALUE; win::random_access_handle handle4(ioc_ex, native_handle2); #if defined(ASIO_HAS_MOVE) win::random_access_handle handle5(std::move(handle4)); #endif // defined(ASIO_HAS_MOVE) // basic_random_access_handle operators. #if defined(ASIO_HAS_MOVE) handle1 = win::random_access_handle(ioc); handle1 = std::move(handle4); #endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. windows::random_access_handle::executor_type ex = handle1.get_executor(); (void)ex; // basic_overlapped_handle functions. win::random_access_handle::lowest_layer_type& lowest_layer = handle1.lowest_layer(); (void)lowest_layer; const win::random_access_handle& handle6 = handle1; const win::random_access_handle::lowest_layer_type& lowest_layer2 = handle6.lowest_layer(); (void)lowest_layer2; HANDLE native_handle3 = INVALID_HANDLE_VALUE; handle1.assign(native_handle3); bool is_open = handle1.is_open(); (void)is_open; handle1.close(); handle1.close(ec); win::random_access_handle::native_handle_type native_handle4 = handle1.native_handle(); (void)native_handle4; handle1.cancel(); handle1.cancel(ec); // basic_random_access_handle functions. handle1.write_some_at(offset, buffer(mutable_char_buffer)); handle1.write_some_at(offset, buffer(const_char_buffer)); handle1.write_some_at(offset, buffer(mutable_char_buffer), ec); handle1.write_some_at(offset, buffer(const_char_buffer), ec); handle1.async_write_some_at(offset, buffer(mutable_char_buffer), &write_some_handler); handle1.async_write_some_at(offset, buffer(const_char_buffer), &write_some_handler); int i1 = handle1.async_write_some_at(offset, buffer(mutable_char_buffer), lazy); (void)i1; int i2 = handle1.async_write_some_at(offset, buffer(const_char_buffer), lazy); (void)i2; handle1.read_some_at(offset, buffer(mutable_char_buffer)); handle1.read_some_at(offset, buffer(mutable_char_buffer), ec); handle1.async_read_some_at(offset, buffer(mutable_char_buffer), &read_some_handler); int i3 = handle1.async_read_some_at(offset, buffer(mutable_char_buffer), lazy); (void)i3; } catch (std::exception&) { } #endif // defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) } } // namespace windows_random_access_handle_compile //------------------------------------------------------------------------------ ASIO_TEST_SUITE ( "windows/random_access_handle", ASIO_TEST_CASE(windows_random_access_handle_compile::test) )
180eccc8b0f2e358617ca51a3c822b02686ec7cd
37cd8698bb2e7262744a0ad80296474e072aa1e5
/CG/class/moveSphere.cpp
7e20844fb35276cac3112d02973e3c039831e0d8
[]
no_license
denihs/college-third-year
b50a47c02827a3e5b16dfe84e64c67a36f49785f
f1ec8b381b9a793fe05f99dd07912fe2c3afbbdf
refs/heads/master
2022-02-26T08:12:23.460205
2019-09-29T21:23:26
2019-09-29T21:23:26
174,235,616
0
0
null
null
null
null
UTF-8
C++
false
false
2,808
cpp
/////////////////////////////////////////////////////////////// // moveSphere.cpp // // This program allows the user to move a sphere to demonstrate // distortion at the edges of the viewing frustum. // // Interaction: // Press the arrow keys to move the sphere. // Press the space bar to rotate the sphere.. // Press r to reset. // // Sumanta Guha. /////////////////////////////////////////////////////////////// #include <iostream> #ifdef __APPLE__ # include <GLUT/glut.h> #else # include <GL/glut.h> #endif using namespace std; // Globals. static float Xvalue = 0.0, Yvalue = 0.0; // Co-ordinates of the sphere. static float Angle = 0.0; // Angle to rotate the sphere. // Drawing routine. void drawScene(void) { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); // Set the position of the sphere. glTranslatef(Xvalue, Yvalue, -5.0); glRotatef(Angle, 1.0, 1.0, 1.0); glColor3f(0.0, 0.0, 0.0); glutWireSphere(0.5, 16, 10); glutSwapBuffers(); } // Initialization routine. void setup(void) { glClearColor(1.0, 1.0, 1.0, 0.0); } // OpenGL window reshape routine. void resize(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); glMatrixMode(GL_MODELVIEW); } // Keyboard input processing routine. void keyInput(unsigned char key, int x, int y) { switch (key) { case 'r': Xvalue = Yvalue = Angle = 0.0; glutPostRedisplay(); break; case ' ': Angle += 10.0; glutPostRedisplay(); break; case 27: exit(0); break; default: break; } } // Callback routine for non-ASCII key entry. void specialKeyInput(int key, int x, int y) { if(key == GLUT_KEY_UP) Yvalue += 0.1; if(key == GLUT_KEY_DOWN) Yvalue -= 0.1; if(key == GLUT_KEY_LEFT) Xvalue -= 0.1; if(key == GLUT_KEY_RIGHT) Xvalue += 0.1; cout << key << endl; glutPostRedisplay(); } // Routine to output interaction instructions to the C++ window. void printInteraction(void) { cout << "Interaction:" << endl; cout << "Press the arrow keys to move the sphere." << endl << "Press the space bar to rotate the sphere." << endl << "Press r to reset." << endl; } // Main routine. int main(int argc, char **argv) { printInteraction(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(500, 500); glutInitWindowPosition(100, 100); glutCreateWindow("moveSphere.cpp"); setup(); glutDisplayFunc(drawScene); glutReshapeFunc(resize); glutKeyboardFunc(keyInput); // Register the callback function for non-ASCII key entry. glutSpecialFunc(specialKeyInput); glutMainLoop(); return 0; }
cf51ed83c7042414f507e3116d9ad39b009ddd14
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14408/function14408_schedule_9/function14408_schedule_9_wrapper.cpp
d2f5e267b6097865f35042bf4a761bf9130d277e
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
854
cpp
#include "Halide.h" #include "function14408_schedule_9_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){Halide::Buffer<int32_t> buf0(256, 2048, 64); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function14408_schedule_9(buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function14408/function14408_schedule_9/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
149df63185f9417ebd52bdeba9167aecd4623f96
f4d8531a987bc53adfab365ac262357f34413db6
/mrpt-1.4.0/libs/maps/include/mrpt/slam/CColouredPointsMap.h
f41697652dcd8923546b31c1bad7c46b79df8a09
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
saurabhd14/Mytest
5f5b4232df9a0725ca722ff97a1037f31a9bb9ca
4b8c4653384fd5a7f5104c5ec0977a64f703eecb
refs/heads/master
2021-01-20T05:43:32.427329
2017-04-30T15:24:18
2017-04-30T15:24:18
89,801,996
1
0
null
null
null
null
UTF-8
C++
false
false
1,045
h
/* +---------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +---------------------------------------------------------------------------+ */ #pragma once #include <mrpt/maps/CColouredPointsMap.h> MRPT_WARNING("*Deprecated header* Please replace with #include <mrpt/maps/CColouredPointsMap.h>. This backward compatible header will be removed in MRPT 2.0.0") namespace mrpt { namespace slam { using mrpt::maps::CColouredPointsMap; //!< Backward compatibility using mrpt::maps::CColouredPointsMapPtr; //!< Backward compatibility } }
66a2a0d1a933924c98abcd39e434797f3774dfbd
f2c06fd62446d2b8a02532ac44d8cb649a2fff3a
/src/compiler_error.cpp
56dc32f022166fb00d06243c451648c7ac32aeb0
[]
no_license
czipperz/red
47e898348f548421c37a6bcf9bc0828610f7e164
fb77775c54320121cf292781afb1c6735a7fb7a1
refs/heads/master
2020-08-07T16:21:04.018633
2020-04-21T08:05:58
2020-04-21T08:12:10
213,522,922
0
0
null
null
null
null
UTF-8
C++
false
false
30
cpp
#include "compiler_error.hpp"
6938ffa71abcced8e031cb4729944d481d32da20
b20610a4697623a34ffb10e6506d5db8373a2c56
/backend/tests/TestAlgomodelStrategy2.H
dd3375756739c2574c3e9732ae8e3076759aff71
[]
no_license
soumyaukil/TradingSoftware
2174f88d84b33672216b2341364a88e3134bd3c5
9ef43bb3b9161352b49afb5a86c54a64c8ebabb8
refs/heads/master
2021-01-21T03:25:03.286613
2017-08-30T15:21:06
2017-08-30T15:21:06
101,896,358
0
2
null
null
null
null
UTF-8
C++
false
false
863
h
/* * ===================================================================================== * * Filename: TestAlgomodelStrategy2.H * * Description: * * Created: 10/01/2016 07:55:24 AM * Compiler: g++ * * Author: Soumya Prasad Ukil * Company: AlgoEngine * * ===================================================================================== */ #ifndef TestAlgomodelStrategy2_H #define TestAlgomodelStrategy2_H #include <gtest/gtest.h> #include <shared/commands.h> #include <strategy/AlgoMode1Strategy.H> class TestAlgomodelStrategy2 : public ::testing::Test { protected: void SetUp(); void TearDown(); TestAlgomodelStrategy2(); void Initialize(); Algo::AlgoModel1 am; int fd; Algo::AlgoMode1Strategy *algoMode1Strategy; }; #endif
2b2c16df7e9e746d4e3638990a1115359d6c1acd
5108d2772d34e7e92e29051ddcb8953eb356d494
/src/sh/spherical_harmonics.h
fb95d23550099678b5be26dfd621a447e2dd8ece
[]
no_license
liuyangvspu/PRT
f5c5220ab141fc7b455781c3a59cbcdc8fa31727
5c136ae5392c24996470f165bce97d10b1edccef
refs/heads/master
2023-06-23T07:06:55.187445
2021-04-18T17:28:59
2021-04-18T17:28:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,376
h
// Copyright 2015 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // The general spherical harmonic functions and fitting methods are from: // 1. R. Green, "Spherical Harmonic Lighting: The Gritty Details", GDC 2003, // http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf // // The environment map related functions are based on the methods in: // 2. R. Ramamoorthi and P. Hanrahan, "An Efficient Representation for // Irradiance Environment Maps",. , P., SIGGRAPH 2001, 497-500 // 3. R. Ramamoorthi and P. Hanrahan, “On the Relationship between Radiance and // Irradiance: Determining the Illumination from Images of a Convex // Lambertian Object,” J. Optical Soc. Am. A, vol. 18, no. 10, pp. 2448-2459, // 2001. // // Spherical harmonic rotations are implemented using the recurrence relations // described by: // 4. J. Ivanic and K. Ruedenberg, "Rotation Matrices for Real Spherical // Harmonics. Direct Determination by Recursion", J. Phys. Chem., vol. 100, // no. 15, pp. 6342-6347, 1996. // http://pubs.acs.org/doi/pdf/10.1021/jp953350u // 4b. Corrections to initial publication: // http://pubs.acs.org/doi/pdf/10.1021/jp9833350 #ifndef SH_SPHERICAL_HARMONICS_H_ #define SH_SPHERICAL_HARMONICS_H_ #include <array> #include <vector> #include <functional> #include <memory> #include "sh/image.h" namespace sh { const double M_PI = std::atan(1.0)*4; // A spherical function, the first argument is phi, the second is theta. // See EvalSH(int, int, double, double) for a description of these terms. typedef std::function<double(double, double)> SphericalFunction; const int kDefaultSampleCount = 10000; // Get the total number of coefficients for a function represented by // all spherical harmonic basis of degree <= @order (it is a point of // confusion that the order of an SH refers to its degree and not the order). constexpr int GetCoefficientCount(int order) { return (order + 1) * (order + 1); } // Get the one dimensional index associated with a particular degree @l // and order @m. This is the index that can be used to access the Coeffs // returned by SHSolver. constexpr int GetIndex(int l, int m) { return l * (l + 1) + m; } // Convert from spherical coordinates to a direction vector. @phi represents // the rotation about the Z axis and is from [0, 2pi]. @theta represents the // angle down from the Z axis, from [0, pi]. Eigen::Vector3d ToVector(double phi, double theta); // Convert from a direction vector to its spherical coordinates. The // coordinates are written out to @phi and @theta. This is the inverse of // ToVector. // Check will fail if @dir is not unit. void ToSphericalCoords(const Eigen::Vector3d& dir, double* phi, double* theta); // Convert the (x, y) pixel coordinates into spherical coordinates (phi, theta) // suitable for use with spherical harmonic evaluation. The x image axis maps // to phi (0 to 2pi) and the y image axis maps to theta (0 to pi). A pixel index // maps to the center of the pixel, so phi = 2pi (x + 0.5) / width and // theta = pi (y + 0.5) / height. This is consistent with ProjectEnvironmentMap. // // x and y are not bounds checked against the image, but given the repeated // nature of trigonometry functions, out-of-bounds x/y values produce reasonable // phi and theta values (e.g. extending linearly beyond 0, pi, or 2pi). // Results are undefined if the image dimensions are less than or equal to 0. // // The x and y functions are separated because they can be computed // independently, unlike ToImageCoords. double ImageXToPhi(int x, int width); double ImageYToTheta(int y, int height); // Convert the (phi, theta) spherical coordinates (using the convention // defined spherical_harmonics.h) to pixel coordinates (x, y). The pixel // coordinates are floating point to allow for later subsampling within the // image. This is the inverse of ImageCoordsToSphericalCoords. It properly // supports angles outside of the standard (0, 2pi) or (0, pi) range by mapping // them back into it. Eigen::Vector2d ToImageCoords(double phi, double theta, int width, int height); // Evaluate the spherical harmonic basis function of degree @l and order @m // for the given spherical coordinates, @phi and @theta. // For low values of @l this will use a hard-coded function, otherwise it // will fallback to EvalSHSlow that uses a recurrence relation to support all l. double EvalSH(int l, int m, double phi, double theta); // Evaluate the spherical harmonic basis function of degree @l and order @m // for the given direction vector, @dir. // Check will fail if @dir is not unit. // For low values of @l this will use a hard-coded function, otherwise it // will fallback to EvalSHSlow that uses a recurrence relation to support all l. double EvalSH(int l, int m, const Eigen::Vector3d& dir); // As EvalSH, but always uses the recurrence relationship. This is exposed // primarily for testing purposes to ensure the hard-coded functions equal the // recurrence relation version. double EvalSHSlow(int l, int m, double phi, double theta); // As EvalSH, but always uses the recurrence relationship. This is exposed // primarily for testing purposes to ensure the hard-coded functions equal the // recurrence relation version. // Check will fail if @dir is not unit. double EvalSHSlow(int l, int m, const Eigen::Vector3d& dir); // Fit the given analytical spherical function to the SH basis functions // up to @order. This uses Monte Carlo sampling to estimate the underlying // integral. @sample_count determines the number of function evaluations // performed. @sample_count is rounded to the greatest perfect square that // is less than or equal to it. // // The samples are distributed uniformly over the surface of a sphere. The // number of samples required to get a reasonable sampling of @func depends on // the frequencies within that function. Lower frequency will not require as // many samples. The recommended default kDefaultSampleCount should be // sufficiently high for most functions, but is also likely overly conservative // for many applications. std::unique_ptr<std::vector<double>> ProjectFunction( int order, const SphericalFunction& func, int sample_count); // Fit the given environment map to the SH basis functions up to @order. // It is assumed that the environment map is parameterized by theta along // the x-axis (ranging from 0 to 2pi after normalizing out the resolution), // and phi along the y-axis (ranging from 0 to pi after normalization). // // This fits three different functions, one for each color channel. The // coefficients for these functions are stored in the respective indices // of the Array3f values of the returned vector. std::unique_ptr<std::vector<Eigen::Array3f>> ProjectEnvironment( int order, const Image& env); std::unique_ptr<std::vector<Eigen::Array3f>> ProjectEnvironment_Par( int order, const Image& env); // Fit the given samples of a spherical function to the SH basis functions // up to @order. This variant is used when there are relatively sparse // evaluations or samples of the spherical function that must be fit and a // regression is performed. // @dirs and @values must have the same size. The directions in @dirs are // assumed to be unit. std::unique_ptr<std::vector<double>> ProjectSparseSamples( int order, const std::vector<Eigen::Vector3d>& dirs, const std::vector<double>& values); // Evaluate the already computed coefficients for the SH basis functions up // to @order, at the coordinates @phi and @theta. The length of the @coeffs // vector must be equal to GetCoefficientCount(order). // There are explicit instantiations for double, float, and Eigen::Array3f. template <typename T> T EvalSHSum(int order, const std::vector<T>& coeffs, double phi, double theta); // As EvalSHSum, but inputting a direction vector instead of spherical coords. // Check will fail if @dir is not unit. template <typename T> T EvalSHSum(int order, const std::vector<T>& coeffs, const Eigen::Vector3d& dir); // Render into @diffuse_out the diffuse irradiance for every normal vector // representable in @diffuse_out, given the luminance stored in @env_map. // Both @env_map and @diffuse_out use the latitude-longitude projection defined // specified in ImageX/YToPhi/Theta. They may be of different // resolutions. The resolution of @diffuse_out must be set before invoking this // function. void RenderDiffuseIrradianceMap(const Image& env_map, Image* diffuse_out); // Render into @diffuse_out diffuse irradiance for every normal vector // representable in @diffuse_out, for the environment represented as the given // spherical harmonic coefficients, @sh_coeffs. The resolution of // @diffuse_out must be set before calling this function. Note that a high // resolution is not necessary (64 x 32 is often quite sufficient). // See RenderDiffuseIrradiance for how @sh_coeffs is interpreted. void RenderDiffuseIrradianceMap(const std::vector<Eigen::Array3f>& sh_coeffs, Image* diffuse_out); // Compute the diffuse irradiance for @normal given the environment represented // as the provided spherical harmonic coefficients, @sh_coeffs. Check will // fail if @normal is not unit length. @sh_coeffs can be of any length. Any // coefficient provided beyond what's used internally to represent the diffuse // lobe (9) will be ignored. If @sh_coeffs is less than 9, the remaining // coefficients are assumed to be 0. This naturally means that providing an // empty coefficient array (e.g. when the environment is assumed to be black and // not provided in calibration) will evaluate to 0 irradiance. Eigen::Array3f RenderDiffuseIrradiance( const std::vector<Eigen::Array3f>& sh_coeffs, const Eigen::Vector3d& normal); class Rotation { public: // Create a new Rotation that can applies @rotation to sets of coefficients // for the given @order. @order must be at least 0. static std::unique_ptr<Rotation> Create(int order, const Eigen::Quaterniond& rotation); // Create a new Rotation that applies the same rotation as @rotation. This // can be used to efficiently calculate the matrices for the same 3x3 // transform when a new order is necessary. static std::unique_ptr<Rotation> Create(int order, const Rotation& rotation); // Transform the SH basis coefficients in @coeff by this rotation and store // them into @result. These may be the same vector. The @result vector will // be resized if necessary, but @coeffs must have its size equal to // GetCoefficientCount(order()). // // This rotation transformation produces a set of coefficients that are equal // to the coefficients found by projecting the original function rotated by // the same rotation matrix. // // There are explicit instantiations for double, float, and Array3f. template <typename T> void Apply(const std::vector<T>& coeffs, std::vector<T>* result) const; // The order (0-based) that the rotation was constructed with. It can only // transform coefficient vectors that were fit using the same order. int order() const; // Return the rotation that is effectively applied to the inputs of the // original function. Eigen::Quaterniond rotation() const; // Return the (2l+1)x(2l+1) matrix for transforming the coefficients within // band @l by the rotation. @l must be at least 0 and less than or equal to // the order this rotation was initially constructed with. const Eigen::MatrixXd& band_rotation(int l) const; private: explicit Rotation(int order, const Eigen::Quaterniond& rotation); const int order_; const Eigen::Quaterniond rotation_; std::vector<Eigen::MatrixXd> band_rotations_; }; } // namespace sh #endif // SH_SPHERICAL_HARMONICS_H_
38edfcb5eff4825f810375fbd6b328a48e8605f7
48ade09975b42f08b413ffb5bf227372e25389a1
/sixnetmessagehandler.cpp
644b1585fd2c95761a373035957c70a004e83a81
[]
no_license
martonmiklos/sixnet-tools
15a8fabbe5fb2c2f2e25d9f44ff710238654c01e
8515a3a63f0abd54b3129fe9ada108c08fdea409
refs/heads/master
2016-09-06T07:38:08.077944
2015-03-22T10:33:31
2015-03-22T10:33:31
32,669,653
0
0
null
null
null
null
UTF-8
C++
false
false
2,681
cpp
#include "sixnetmessagehandler.h" SixnetMessageDispatcher::SixnetMessageDispatcher(QHostAddress address, int port, int timeout, QObject *parent) : QObject(parent), m_sentMessage(NULL), m_sequence(0), m_address(address), m_port(port), m_connected(false) { m_socket = new QUdpSocket(this); m_socket->bind(QHostAddress::LocalHost, port); connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); m_socket->connectToHost(address, port); m_timer.setInterval(timeout); m_timer.setSingleShot(true); connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout())); } void SixnetMessageDispatcher::connectToHost() { if (m_socket->state() == QUdpSocket::UnconnectedState) { m_socket->connectToHost(m_address, m_port); } } void SixnetMessageDispatcher::disconnectFromHost() { if (m_socket->state() != QUdpSocket::UnconnectedState) { m_socket->disconnectFromHost(); } } void SixnetMessageDispatcher::sendMessage(SixnetMessage *msg) { m_waitingMessages.append(msg); sendNextMessageFromWaiting(); } void SixnetMessageDispatcher::sendNextMessageFromWaiting() { if ((m_sentMessage != NULL) || (m_waitingMessages.size() == 0)) return; m_sentMessage = m_waitingMessages.takeFirst(); m_sentMessage->setSequence(m_sequence); connect(m_sentMessage, SIGNAL(debug(QString)), this, SIGNAL(debug(QString))); emit debug(tr("OUT %1").arg(QString(m_sentMessage->serialize().toHex()))); m_socket->write(m_sentMessage->serialize()); m_timer.start(); m_sequence++; } void SixnetMessageDispatcher::socketStateChanged(QAbstractSocket::SocketState newState) { m_connected = (newState == QUdpSocket::ConnectedState); if (newState == QUdpSocket::ConnectedState) { sendNextMessageFromWaiting(); } } void SixnetMessageDispatcher::socketReadyRead() { if (m_socket->hasPendingDatagrams()) { QByteArray datagram; datagram.resize(m_socket->pendingDatagramSize()); m_timer.stop(); m_socket->readDatagram(datagram.data(), datagram.size()); if (m_sentMessage != NULL) { if(!m_sentMessage->checkAnswer(datagram)) emit debug(tr("Error: %1").arg(m_sentMessage->error())); m_sentMessage = NULL; } } } void SixnetMessageDispatcher::timeout() { if (m_sentMessage != NULL) { emit debug(tr("timeout")); m_sentMessage->deleteLater(); m_sentMessage = NULL; } sendNextMessageFromWaiting(); }
[ "[email protected]@fc57be8b-969e-378c-fce5-c2118c9c64c8" ]
[email protected]@fc57be8b-969e-378c-fce5-c2118c9c64c8
35d892814ef4f6fe118d3d8e145342be00ce873d
bf0fe104ceeb14373723f439d082d2024f675d12
/Mario/source/decor.h
91123959bea0bfeaf364386eef12cbb79057e404
[]
no_license
ParvilusLM/Jeu_Mario
fe156fb866de967509a8bf486c1f07f84a514898
3bab8142da3eed88ea1dc77f9fc171fdc863ff11
refs/heads/master
2023-04-16T03:59:01.603669
2021-04-21T01:32:06
2021-04-21T01:32:06
296,482,276
0
0
null
null
null
null
UTF-8
C++
false
false
480
h
#pragma once #include "menu.h" #include "carte.h" #include "personnage.h" #include "monstre.h" #include "son.h" class Decor { public: Decor(); ~Decor(); /*** Les methodes ***/ Menu& getMenu(); Carte& getCarte(); Personnage& getPersonnage(); Monstre& getMonstre(); Son& getSon(); private: sf::RenderWindow* m_fenetre; Menu* m_menu; Carte* m_carte; Personnage* m_personnage; Monstre* m_monstre; Son* m_son; };
32d59e4115b959a729f2360354b687ce3a9a0282
de7e771699065ec21a340ada1060a3cf0bec3091
/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymGraphFilterFactory.h
9502251be70cc2f95f3027b76ac956e6be3b6777
[]
no_license
sraihan73/Lucene-
0d7290bacba05c33b8d5762e0a2a30c1ec8cf110
1fe2b48428dcbd1feb3e10202ec991a5ca0d54f3
refs/heads/master
2020-03-31T07:23:46.505891
2018-12-08T14:57:54
2018-12-08T14:57:54
152,020,180
7
0
null
null
null
null
UTF-8
C++
false
false
6,478
h
#pragma once #include "../../../../../../../../../core/src/java/org/apache/lucene/analysis/Analyzer.h" #include "../util/ResourceLoaderAware.h" #include "../util/TokenFilterFactory.h" #include "exceptionhelper.h" #include "stringhelper.h" #include <memory> #include <stdexcept> #include <string> #include <typeinfo> #include <unordered_map> #include <deque> // C++ NOTE: Forward class declarations: #include "core/src/java/org/apache/lucene/analysis/synonym/SynonymMap.h" #include "core/src/java/org/apache/lucene/analysis/TokenStream.h" #include "core/src/java/org/apache/lucene/analysis/util/ResourceLoader.h" #include "core/src/java/org/apache/lucene/analysis/util/TokenizerFactory.h" #include "core/src/java/org/apache/lucene/analysis/Analyzer.h" #include "core/src/java/org/apache/lucene/analysis/TokenStreamComponents.h" /* * Licensed to the Syed Mamun Raihan (sraihan.com) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * sraihan.com licenses this file to You under GPLv3 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 * * https://www.gnu.org/licenses/gpl-3.0.en.html * * 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. */ namespace org::apache::lucene::analysis::synonym { using Analyzer = org::apache::lucene::analysis::Analyzer; using TokenStream = org::apache::lucene::analysis::TokenStream; using ResourceLoader = org::apache::lucene::analysis::util::ResourceLoader; using ResourceLoaderAware = org::apache::lucene::analysis::util::ResourceLoaderAware; using TokenFilterFactory = org::apache::lucene::analysis::util::TokenFilterFactory; using TokenizerFactory = org::apache::lucene::analysis::util::TokenizerFactory; /** * Factory for {@link SynonymGraphFilter}. * <pre class="prettyprint"> * &lt;fieldType name="text_synonym" class="solr.TextField" positionIncrementGap="100"&gt; * &lt;analyzer&gt; * &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt; * &lt;filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" * format="solr" ignoreCase="false" expand="true" * tokenizerFactory="solr.WhitespaceTokenizerFactory" * [optional tokenizer factory parameters]/&gt; * &lt;/analyzer&gt; * &lt;/fieldType&gt;</pre> * * <p> * An optional param name prefix of "tokenizerFactory." may be used for any * init params that the SynonymGraphFilterFactory needs to pass to the specified * TokenizerFactory. If the TokenizerFactory expects an init parameters with * the same name as an init param used by the SynonymGraphFilterFactory, the prefix * is mandatory. * </p> * * <p> * The optional {@code format} parameter controls how the synonyms will be parsed: * It supports the short names of {@code solr} for {@link SolrSynonymParser} * and {@code wordnet} for and {@link WordnetSynonymParser}, or your own * {@code SynonymMap.Parser} class name. The default is {@code solr}. * A custom {@link SynonymMap.Parser} is expected to have a constructor taking: GET_CLASS_NAME(name.) * <ul> * <li><code>bool dedup</code> - true if duplicates should be ignored, false otherwise</li> * <li><code>bool expand</code> - true if conflation groups should be expanded, false if they are one-directional</li> * <li><code>{@link Analyzer} analyzer</code> - an analyzer used for each raw synonym</li> * </ul> * @see SolrSynonymParser SolrSynonymParser: default format * * @lucene.experimental * @since 6.4.0 */ class SynonymGraphFilterFactory : public TokenFilterFactory, public ResourceLoaderAware { GET_CLASS_NAME(SynonymGraphFilterFactory) private: const bool ignoreCase; const std::wstring tokenizerFactory; const std::wstring synonyms; const std::wstring format; const bool expand; const std::wstring analyzerName; const std::unordered_map<std::wstring, std::wstring> tokArgs = std::unordered_map<std::wstring, std::wstring>(); std::shared_ptr<SynonymMap> map_obj; public: SynonymGraphFilterFactory( std::unordered_map<std::wstring, std::wstring> &args); std::shared_ptr<TokenStream> create(std::shared_ptr<TokenStream> input) override; void inform(std::shared_ptr<ResourceLoader> loader) override; private: class AnalyzerAnonymousInnerClass : public Analyzer { GET_CLASS_NAME(AnalyzerAnonymousInnerClass) private: std::shared_ptr<SynonymGraphFilterFactory> outerInstance; std::shared_ptr<TokenizerFactory> factory; public: AnalyzerAnonymousInnerClass( std::shared_ptr<SynonymGraphFilterFactory> outerInstance, std::shared_ptr<TokenizerFactory> factory); protected: std::shared_ptr<Analyzer::TokenStreamComponents> createComponents(const std::wstring &fieldName) override; protected: std::shared_ptr<AnalyzerAnonymousInnerClass> shared_from_this() { return std::static_pointer_cast<AnalyzerAnonymousInnerClass>( org.apache.lucene.analysis.Analyzer::shared_from_this()); } }; /** * Load synonyms with the given {@link SynonymMap.Parser} class. */ protected: virtual std::shared_ptr<SynonymMap> loadSynonyms(std::shared_ptr<ResourceLoader> loader, const std::wstring &cname, bool dedup, std::shared_ptr<Analyzer> analyzer) throw(IOException, ParseException); // (there are no tests for this functionality) private: std::shared_ptr<TokenizerFactory> loadTokenizerFactory(std::shared_ptr<ResourceLoader> loader, const std::wstring &cname) ; std::shared_ptr<Analyzer> loadAnalyzer(std::shared_ptr<ResourceLoader> loader, const std::wstring &cname) ; protected: std::shared_ptr<SynonymGraphFilterFactory> shared_from_this() { return std::static_pointer_cast<SynonymGraphFilterFactory>( org.apache.lucene.analysis.util.TokenFilterFactory::shared_from_this()); } }; } // #include "core/src/java/org/apache/lucene/analysis/synonym/
c1e009be1cf4ffc1624181aefd8babeee50bd24f
07ce962a81823cf1e5b3ef46197ec811f981da8c
/c++/ch02/WeatherStation.cpp
776c95fdd38de044cae96d419db55c6f994d1acb
[]
no_license
proudzhu/head_first_design_pattern
0bf864956c543b5f9bbac48381f87afb851abb10
d98d44d656a4eff28abdf4de1c6ad5957846cdbc
refs/heads/master
2021-01-09T20:30:19.201185
2016-08-07T05:10:54
2016-08-07T05:10:54
64,227,221
0
0
null
null
null
null
UTF-8
C++
false
false
6,485
cpp
#include <iostream> #include <memory> #include <list> class Observer { public: virtual void update(float temp, float humidity, float pressure) = 0; }; class Subject { public: virtual void registerObserver(std::shared_ptr<Observer> o) = 0; virtual void removeObserver(std::shared_ptr<Observer> o) = 0; virtual void notifyObservers() = 0; }; class DisplayElement { public: virtual void display() = 0; }; class WeatherData : public Subject { public: WeatherData() { } ~WeatherData() { } void registerObserver(std::shared_ptr<Observer> o) { observers_.push_back(o); } void removeObserver(std::shared_ptr<Observer> o) { observers_.remove(o); } void notifyObservers() { for (auto &o : observers_) o->update(temperature_, humidity_, pressure_); } void measurementsChanged() { notifyObservers(); } void setMeasurements(float temperature, float humidity, float pressure) { temperature_ = temperature; humidity_ = humidity; pressure_ = pressure; measurementsChanged(); } private: std::list<std::shared_ptr<Observer>> observers_; float temperature_; float humidity_; float pressure_; }; class CurrentConditionsDisplay : public std::enable_shared_from_this<CurrentConditionsDisplay>, public Observer, public DisplayElement { public: CurrentConditionsDisplay(std::shared_ptr<Subject> weatherData) : weatherData_(weatherData) { } ~CurrentConditionsDisplay() { } void registerDisplay() { weatherData_->registerObserver(shared_from_this()); } void update(float temperature, float humidity, float pressure) { temperature_ = temperature; humidity_ = humidity; display(); } void display() { std::cout << "Current conditions: " << temperature_ << "F degrees and " << humidity_ << "% humidity" << std::endl; } private: float temperature_; float humidity_; std::shared_ptr<Subject> weatherData_; }; class StatisticsDisplay : public std::enable_shared_from_this<StatisticsDisplay>, public Observer, public DisplayElement { public: StatisticsDisplay(std::shared_ptr<Subject> weatherData) : weatherData_(weatherData) { } ~StatisticsDisplay() { } void registerDisplay() { weatherData_->registerObserver(shared_from_this()); } void update(float temperature, float humidity, float pressure) { if (temperature > maxTemp_) maxTemp_ = temperature; if (temperature < minTemp_) minTemp_ = temperature; tempSum_ += temperature; numReadings++; display(); } void display() { std::cout << "Avg/Max/Min temperature = " << (tempSum_ / numReadings) << "/" << maxTemp_ << "/" << minTemp_ << std::endl; } private: float maxTemp_; float minTemp_; float tempSum_; int numReadings; std::shared_ptr<Subject> weatherData_; }; class ForecastDisplay : public std::enable_shared_from_this<ForecastDisplay>, public Observer, public DisplayElement { public: ForecastDisplay(std::shared_ptr<Subject> weatherData) : weatherData_(weatherData) { } ~ForecastDisplay() { } void registerDisplay() { weatherData_->registerObserver(shared_from_this()); } void update(float temperature, float humidity, float pressure) { lastPressure_ = currentPressure_; currentPressure_ = pressure; display(); } void display() { std::cout << "Forecast: "; if (currentPressure_ > lastPressure_) std::cout << "Improving weather on the way!"; else if (currentPressure_ == lastPressure_) std::cout << "More of the same"; else std::cout << "Watch out for cooler, rainy weather"; std::cout << std::endl; } private: float currentPressure_; float lastPressure_; std::shared_ptr<Subject> weatherData_; }; class HeatIndexDisplay : public std::enable_shared_from_this<HeatIndexDisplay>, public Observer, public DisplayElement { public: HeatIndexDisplay(std::shared_ptr<Subject> weatherData) : weatherData_(weatherData) { } ~HeatIndexDisplay() { } void registerDisplay() { weatherData_->registerObserver(shared_from_this()); } void update(float temperature, float humidity, float pressure) { heatIndex_ = computeHeatIndex(temperature, humidity); display(); } void display() { std::cout << "Heat index is " << heatIndex_ << std::endl; } private: float heatIndex_; std::shared_ptr<Subject> weatherData_; float computeHeatIndex(float t, float rh) { float index = (float)((16.923 + (0.185212 * t) + (5.37941 * rh) - (0.100254 * t * rh) + (0.00941695 * (t * t)) + (0.00728898 * (rh * rh)) + (0.000345372 * (t * t * rh)) - (0.000814971 * (t * rh * rh)) + (0.0000102102 * (t * t * rh * rh)) - (0.000038646 * (t * t * t)) + (0.0000291583 * (rh * rh * rh)) + (0.00000142721 * (t * t * t * rh)) + (0.000000197483 * (t * rh * rh * rh)) - (0.0000000218429 * (t * t * t * rh * rh)) + 0.000000000843296 * (t * t * rh * rh * rh)) - (0.0000000000481975 * (t * t * t * rh * rh * rh))); return index; } }; int main(int argc, char **argv) { std::shared_ptr<WeatherData> weatherData = std::make_shared<WeatherData>(); std::shared_ptr<CurrentConditionsDisplay> currentDisplay = std::make_shared<CurrentConditionsDisplay>(weatherData); std::shared_ptr<StatisticsDisplay> statisticsDisplay = std::make_shared<StatisticsDisplay>(weatherData); std::shared_ptr<ForecastDisplay> forecastDisplay = std::make_shared<ForecastDisplay>(weatherData); std::shared_ptr<HeatIndexDisplay> heatIndexDisplay = std::make_shared<HeatIndexDisplay>(weatherData); currentDisplay->registerDisplay(); statisticsDisplay->registerDisplay(); forecastDisplay->registerDisplay(); heatIndexDisplay->registerDisplay(); weatherData->setMeasurements(80, 65, 30.4f); weatherData->setMeasurements(82, 70, 29.2f); weatherData->setMeasurements(78, 90, 29.2f); return 0; }
4da9ed752c9cd54b6a669820e9e9bc89e71f1453
09343c9d179d3ac599c08f75910560761c7c99fc
/WindowsTesting/Bindable.cpp
854a06f6a38ae2f4e24d47a61a20bbc73a641b41
[]
no_license
dafienko/WinTestingD3D
5442aec5d1bb9688ae8eee935edf89ff9a17bad5
81b63ee9f32883ef03ff42d782d6d64c3b9a3543
refs/heads/master
2022-09-01T11:05:26.999339
2020-05-28T02:55:14
2020-05-28T02:55:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
253
cpp
#include "Bindable.h" Microsoft::WRL::ComPtr<ID3D11Device> Bindable::getPDevice(Graphics* gfx) { return gfx->getPDevice(); } Microsoft::WRL::ComPtr <ID3D11DeviceContext> Bindable::getPDeviceContext(Graphics* gfx) { return gfx->getPDeviceContext(); }
7b51ba412ce15c3bb7446299baca2185cf20651f
ba10da4be74ba4e472bbe4b51d411627fc07bdbf
/build/iOS/Preview/include/Fuse.Input.KeyEventArgs.h
4772fef379a09fab16c7aca583826ab78dff2b4a
[]
no_license
ericaglimsholt/gadden
80f7c7b9c3c5c46c2520743dc388adbad549c679
daef25c11410326f067c896c242436ff1cbd5df0
refs/heads/master
2021-07-03T10:07:58.451759
2017-09-05T18:11:47
2017-09-05T18:11:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,013
h
// This file was generated based on '/Users/ericaglimsholt/Library/Application Support/Fusetools/Packages/Fuse.Nodes/1.0.5/input/$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Scripting.IScriptEvent.h> #include <Fuse.VisualEventArgs.h> namespace g{namespace Fuse{namespace Input{struct KeyEventArgs;}}} namespace g{namespace Fuse{struct Visual;}} namespace g{ namespace Fuse{ namespace Input{ // public abstract class KeyEventArgs :936 // { ::g::Fuse::VisualEventArgs_type* KeyEventArgs_typeof(); void KeyEventArgs__ctor_2_fn(KeyEventArgs* __this, int* key, ::g::Fuse::Visual* visual); void KeyEventArgs__get_IsAltKeyPressed_fn(KeyEventArgs* __this, bool* __retval); void KeyEventArgs__set_IsAltKeyPressed_fn(KeyEventArgs* __this, bool* value); void KeyEventArgs__get_IsControlKeyPressed_fn(KeyEventArgs* __this, bool* __retval); void KeyEventArgs__set_IsControlKeyPressed_fn(KeyEventArgs* __this, bool* value); void KeyEventArgs__get_IsMetaKeyPressed_fn(KeyEventArgs* __this, bool* __retval); void KeyEventArgs__set_IsMetaKeyPressed_fn(KeyEventArgs* __this, bool* value); void KeyEventArgs__get_IsShiftKeyPressed_fn(KeyEventArgs* __this, bool* __retval); void KeyEventArgs__set_IsShiftKeyPressed_fn(KeyEventArgs* __this, bool* value); void KeyEventArgs__get_Key_fn(KeyEventArgs* __this, int* __retval); void KeyEventArgs__set_Key_fn(KeyEventArgs* __this, int* value); struct KeyEventArgs : ::g::Fuse::VisualEventArgs { bool _IsAltKeyPressed; bool _IsControlKeyPressed; bool _IsMetaKeyPressed; bool _IsShiftKeyPressed; int _Key; void ctor_2(int key, ::g::Fuse::Visual* visual); bool IsAltKeyPressed(); void IsAltKeyPressed(bool value); bool IsControlKeyPressed(); void IsControlKeyPressed(bool value); bool IsMetaKeyPressed(); void IsMetaKeyPressed(bool value); bool IsShiftKeyPressed(); void IsShiftKeyPressed(bool value); int Key(); void Key(int value); }; // } }}} // ::g::Fuse::Input
e944136105d224b1aa4a1986ac53c5b4eca12288
2af4ba03345d2f61472d4d89258adc74023a9661
/Coding/02__Cpp_Lab/keil/Exercise_1a_FlashingLeds/GeneratedModel/LedBar.cpp
d820301027253487725dcb8c2e4315f480ee0816
[]
no_license
ThSauter/repo
cecb9b23c4bd72f5cfbab7ccae9985a34540a65a
8c700e77b957038c446400d93fefcfd6d68e6c5f
refs/heads/master
2020-12-31T00:12:04.356978
2017-09-09T20:47:25
2017-09-09T20:47:25
86,547,417
0
0
null
null
null
null
UTF-8
C++
false
false
5,809
cpp
/******************************************************************** Rhapsody : 8.1.4 Login : Hochschule Ulm Component : MCB1700 Configuration : Debug Model Element : LedBar //! Generated Date : Mon, 3, Apr 2017 File Path : MCB1700\Debug\LedBar.cpp *********************************************************************/ //## auto_generated #include "WSTModelHeadersTSK.h" //## auto_generated #include "LedBar.h" //## package Default //## class LedBar LedBar::LedBar(int aBitNr, int aDelay, WST_TSK* myTask) { setTask( myTask, false ); initStatechart(); //#[ operation LedBar(int,int) bitNr = aBitNr; delay = aDelay; LPC_GPIO1 -> FIODIR |= 0xB0000000; LPC_GPIO2 -> FIODIR |= 0x0000007C; //#] } LedBar::LedBar(WST_TSK* myTask) { setTask( myTask, false ); initStatechart(); } LedBar::~LedBar() { cancelTimeouts(); } void LedBar::off() { //#[ operation off() LPC_GPIO2->FIOCLR |= (1 << bitNr); //#] } void LedBar::on() { //#[ operation on() LPC_GPIO2->FIOSET |= (1 << bitNr); //#] } int LedBar::getBitNr() const { return bitNr; } void LedBar::setBitNr(int p_bitNr) { bitNr = p_bitNr; } int LedBar::getDelay() const { return delay; } void LedBar::setDelay(int p_delay) { delay = p_delay; } bool LedBar::startBehavior() { bool done = false; done = WST_FSM::startBehavior(); return done; } void LedBar::initStatechart() { rootState_subState = OMNonState; rootState_active = OMNonState; rootState_timeout = NULL; } void LedBar::cancelTimeouts() { cancel(rootState_timeout); } bool LedBar::cancelTimeout(const IOxfTimeout* arg) { bool res = false; if(rootState_timeout == arg) { rootState_timeout = NULL; res = true; } return res; } void LedBar::rootState_entDef() { { rootState_subState = State_off; rootState_active = State_off; //#[ state State_off.(Entry) off(); //#] rootState_timeout = scheduleTimeout(delay, NULL); } } IOxfReactive::TakeEventStatus LedBar::rootState_processEvent() { IOxfReactive::TakeEventStatus res = eventNotConsumed; switch (rootState_active) { // State State_off case State_off: { if(IS_EVENT_TYPE_OF(WST_TMR_id)) { if(getCurrentEvent() == rootState_timeout) { //## transition 5 if(bitNr == 2) { cancel(rootState_timeout); rootState_subState = State_on; rootState_active = State_on; //#[ state State_on.(Entry) on(); //#] rootState_timeout = scheduleTimeout(delay, NULL); res = eventConsumed; } else { cancel(rootState_timeout); //#[ transition 6 bitNr--; //#] rootState_subState = State_off; rootState_active = State_off; //#[ state State_off.(Entry) off(); //#] rootState_timeout = scheduleTimeout(delay, NULL); res = eventConsumed; } } } } break; // State State_on case State_on: { if(IS_EVENT_TYPE_OF(WST_TMR_id)) { if(getCurrentEvent() == rootState_timeout) { //## transition 3 if(bitNr == 6) { cancel(rootState_timeout); rootState_subState = State_off; rootState_active = State_off; //#[ state State_off.(Entry) off(); //#] rootState_timeout = scheduleTimeout(delay, NULL); res = eventConsumed; } else { cancel(rootState_timeout); //#[ transition 4 bitNr++; //#] rootState_subState = State_on; rootState_active = State_on; //#[ state State_on.(Entry) on(); //#] rootState_timeout = scheduleTimeout(delay, NULL); res = eventConsumed; } } } } break; default: break; } return res; } /********************************************************************* File Path : MCB1700\Debug\LedBar.cpp *********************************************************************/
5c14f585307ecd251a96981f8defdd78cc2b4424
31a0b0749c30ff37c3a72592387f9d8195de4bd6
/src/ray/gcs/store_client/in_memory_store_client.cc
eefe80a7d709e632a4bc31ab289f12585845ab1d
[ "BSD-3-Clause", "MIT", "Apache-2.0" ]
permissive
longshotsyndicate/ray
15100bad514b602a3fa39bfe205288e7bec75d90
3341fae573868338b665bcea8a1c4ee86b702751
refs/heads/master
2023-01-28T15:16:00.401509
2022-02-18T05:35:47
2022-02-18T05:35:47
163,961,795
1
1
Apache-2.0
2023-01-14T08:01:02
2019-01-03T11:03:35
Python
UTF-8
C++
false
false
8,310
cc
// Copyright 2017 The Ray Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "ray/gcs/store_client/in_memory_store_client.h" namespace ray { namespace gcs { Status InMemoryStoreClient::AsyncPut(const std::string &table_name, const std::string &key, const std::string &data, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); table->records_[key] = data; if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.Put"); } return Status::OK(); } Status InMemoryStoreClient::AsyncPutWithIndex(const std::string &table_name, const std::string &key, const std::string &index_key, const std::string &data, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); table->records_[key] = data; table->index_keys_[index_key].emplace_back(key); if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.PutWithIndex"); } return Status::OK(); } Status InMemoryStoreClient::AsyncGet(const std::string &table_name, const std::string &key, const OptionalItemCallback<std::string> &callback) { RAY_CHECK(callback != nullptr); auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); auto iter = table->records_.find(key); boost::optional<std::string> data; if (iter != table->records_.end()) { data = iter->second; } main_io_service_.post( [callback, data = std::move(data)]() { callback(Status::OK(), data); }, "GcsInMemoryStore.Get"); return Status::OK(); } Status InMemoryStoreClient::AsyncGetAll( const std::string &table_name, const MapCallback<std::string, std::string> &callback) { RAY_CHECK(callback); auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); auto result = std::unordered_map<std::string, std::string>(); result.insert(table->records_.begin(), table->records_.end()); main_io_service_.post( [result = std::move(result), callback]() mutable { callback(std::move(result)); }, "GcsInMemoryStore.GetAll"); return Status::OK(); } Status InMemoryStoreClient::AsyncDelete(const std::string &table_name, const std::string &key, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); table->records_.erase(key); if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.Delete"); } return Status::OK(); } Status InMemoryStoreClient::AsyncDeleteWithIndex(const std::string &table_name, const std::string &key, const std::string &index_key, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); // Remove key-value data. table->records_.erase(key); // Remove index-key data. auto iter = table->index_keys_.find(index_key); if (iter != table->index_keys_.end()) { auto it = std::find(iter->second.begin(), iter->second.end(), key); if (it != iter->second.end()) { iter->second.erase(it); if (iter->second.size() == 0) { table->index_keys_.erase(iter); } } } if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.DeleteWithIndex"); } return Status::OK(); } Status InMemoryStoreClient::AsyncBatchDelete(const std::string &table_name, const std::vector<std::string> &keys, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); for (auto &key : keys) { table->records_.erase(key); } if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.BatchDelete"); } return Status::OK(); } Status InMemoryStoreClient::AsyncBatchDeleteWithIndex( const std::string &table_name, const std::vector<std::string> &keys, const std::vector<std::string> &index_keys, const StatusCallback &callback) { RAY_CHECK(keys.size() == index_keys.size()); auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); for (size_t i = 0; i < keys.size(); ++i) { const std::string &key = keys[i]; const std::string &index_key = index_keys[i]; table->records_.erase(key); auto iter = table->index_keys_.find(index_key); if (iter != table->index_keys_.end()) { auto it = std::find(iter->second.begin(), iter->second.end(), key); if (it != iter->second.end()) { iter->second.erase(it); if (iter->second.size() == 0) { table->index_keys_.erase(iter); } } } } if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.BatchDeleteWithIndex"); } return Status::OK(); } Status InMemoryStoreClient::AsyncGetByIndex( const std::string &table_name, const std::string &index_key, const MapCallback<std::string, std::string> &callback) { RAY_CHECK(callback); auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); auto iter = table->index_keys_.find(index_key); auto result = std::unordered_map<std::string, std::string>(); if (iter != table->index_keys_.end()) { for (auto &key : iter->second) { auto kv_iter = table->records_.find(key); if (kv_iter != table->records_.end()) { result[kv_iter->first] = kv_iter->second; } } } main_io_service_.post( [result = std::move(result), callback]() mutable { callback(std::move(result)); }, "GcsInMemoryStore.GetByIndex"); return Status::OK(); } Status InMemoryStoreClient::AsyncDeleteByIndex(const std::string &table_name, const std::string &index_key, const StatusCallback &callback) { auto table = GetOrCreateTable(table_name); absl::MutexLock lock(&(table->mutex_)); auto iter = table->index_keys_.find(index_key); if (iter != table->index_keys_.end()) { for (auto &key : iter->second) { table->records_.erase(key); } table->index_keys_.erase(iter); } if (callback != nullptr) { main_io_service_.post([callback]() { callback(Status::OK()); }, "GcsInMemoryStore.DeleteByIndex"); } return Status::OK(); } int InMemoryStoreClient::GetNextJobID() { job_id_ += 1; return job_id_; } std::shared_ptr<InMemoryStoreClient::InMemoryTable> InMemoryStoreClient::GetOrCreateTable( const std::string &table_name) { absl::MutexLock lock(&mutex_); auto iter = tables_.find(table_name); if (iter != tables_.end()) { return iter->second; } else { auto table = std::make_shared<InMemoryTable>(); tables_[table_name] = table; return table; } } } // namespace gcs } // namespace ray
102f9e38015e040a5ea5c7e20880ce3e46fada4c
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/components/page_load_metrics/browser/observers/assert_page_load_metrics_observer.h
117147065a454a41e8ddc69c1a461aa3ddcacabf
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
10,322
h
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_ASSERT_PAGE_LOAD_METRICS_OBSERVER_H_ #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_ASSERT_PAGE_LOAD_METRICS_OBSERVER_H_ #include "components/page_load_metrics/browser/page_load_metrics_observer_interface.h" // Asserts the constraints of methods of PageLoadMetricsObserver using // ovserver-level forwarding (i.e. PageLoadMetricsForwardObserver) as code and // checks the behavior in browsertests of PageLoadMetricsObservers. // // This class will be added iff `DCHECK_IS_ON()`. // // The list of methods are not complete. For most ones among missing ones, we // have no (non trivial) assumption on callback timings. // // Note that this inherits PageLoadMetricsObserverInterface rather than // PageLoadMetricsObserver to encourage to write assertions for newly added // methods. class AssertPageLoadMetricsObserver final : public page_load_metrics::PageLoadMetricsObserverInterface { public: AssertPageLoadMetricsObserver(); ~AssertPageLoadMetricsObserver() override; // PageLoadMetricsObserverInterface implementation: const char* GetObserverName() const override; const page_load_metrics::PageLoadMetricsObserverDelegate& GetDelegate() const override; void SetDelegate( page_load_metrics::PageLoadMetricsObserverDelegate*) override; // Initialization and redirect ObservePolicy OnStart(content::NavigationHandle* navigation_handle, const GURL& currently_committed_url, bool started_in_foreground) override; ObservePolicy OnFencedFramesStart( content::NavigationHandle* navigation_handle, const GURL& currently_committed_url) override; ObservePolicy OnPrerenderStart(content::NavigationHandle* navigation_handle, const GURL& currently_committed_url) override; ObservePolicy OnRedirect( content::NavigationHandle* navigation_handle) override; // Commit and activation ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; void DidActivatePrerenderedPage( content::NavigationHandle* navigation_handle) override; // Termination-like events void OnFailedProvisionalLoad( const page_load_metrics::FailedProvisionalLoadInfo& failed_provisional_load_info) override; void OnComplete( const page_load_metrics::mojom::PageLoadTiming& timing) override; ObservePolicy FlushMetricsOnAppEnterBackground( const page_load_metrics::mojom::PageLoadTiming& timing) override; ObservePolicy OnEnterBackForwardCache( const page_load_metrics::mojom::PageLoadTiming& timing) override; // Override to inspect ObservePolicy ShouldObserveMimeType( const std::string& mime_type) const override; // Events for navigations that are not related to PageLoadMetricsObserver's // lifetime void OnDidInternalNavigationAbort( content::NavigationHandle* navigation_handle) override; void ReadyToCommitNextNavigation( content::NavigationHandle* navigation_handle) override; void OnDidFinishSubFrameNavigation( content::NavigationHandle* navigation_handle) override; void OnCommitSameDocumentNavigation( content::NavigationHandle* navigation_handle) override; // Visibility changes ObservePolicy OnHidden( const page_load_metrics::mojom::PageLoadTiming& timing) override; ObservePolicy OnShown() override; // Timing updates // // For more detailed event order, see page_load_metrics_update_dispatcher.cc. void OnTimingUpdate( content::RenderFrameHost* subframe_rfh, const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnParseStart( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnParseStop( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnDomContentLoadedEventStart( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnLoadEventStart( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnFirstPaintInPage( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnFirstImagePaintInPage( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnFirstContentfulPaintInPage( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnFirstPaintAfterBackForwardCacheRestoreInPage( const page_load_metrics::mojom::BackForwardCacheTiming& timing, size_t index) override; void OnFirstInputAfterBackForwardCacheRestoreInPage( const page_load_metrics::mojom::BackForwardCacheTiming& timing, size_t index) override; void OnRequestAnimationFramesAfterBackForwardCacheRestoreInPage( const page_load_metrics::mojom::BackForwardCacheTiming& timing, size_t index) override; void OnFirstMeaningfulPaintInMainFrameDocument( const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnFirstInputInPage( const page_load_metrics::mojom::PageLoadTiming& timing) override; // Input events and input timing events void OnUserInput( const blink::WebInputEvent& event, const page_load_metrics::mojom::PageLoadTiming& timing) override; void OnPageInputTimingUpdate(uint64_t num_interactions, uint64_t num_input_events) override; void OnInputTimingUpdate( content::RenderFrameHost* subframe_rfh, const page_load_metrics::mojom::InputTiming& input_timing_delta) override; // Page render data update void OnPageRenderDataUpdate( const page_load_metrics::mojom::FrameRenderDataUpdate& render_data, bool is_main_frame) override; // Subframe events void OnSubFrameRenderDataUpdate( content::RenderFrameHost* subframe_rfh, const page_load_metrics::mojom::FrameRenderDataUpdate& render_data) override; // RenderFrameHost and FrameTreeNode deletion void OnRenderFrameDeleted( content::RenderFrameHost* render_frame_host) override; void OnSubFrameDeleted(int frame_tree_node_id) override; // The method below are not well investigated. // // TODO(https://crbug.com/1350891): Add more assertions. void OnRestoreFromBackForwardCache( const page_load_metrics::mojom::PageLoadTiming& timing, content::NavigationHandle* navigation_handle) override {} void OnSoftNavigationUpdated( const page_load_metrics::mojom::SoftNavigationMetrics&) override {} void OnCpuTimingUpdate( content::RenderFrameHost* subframe_rfh, const page_load_metrics::mojom::CpuTiming& timing) override {} void OnLoadingBehaviorObserved(content::RenderFrameHost* rfh, int behavior_flags) override {} void OnJavaScriptFrameworksObserved( content::RenderFrameHost* rfh, const blink::JavaScriptFrameworkDetectionResult&) override {} void OnFeaturesUsageObserved( content::RenderFrameHost* rfh, const std::vector<blink::UseCounterFeature>& features) override {} void SetUpSharedMemoryForSmoothness( const base::ReadOnlySharedMemoryRegion& shared_memory) override {} void OnResourceDataUseObserved( content::RenderFrameHost* rfh, const std::vector<page_load_metrics::mojom::ResourceDataUpdatePtr>& resources) override {} void MediaStartedPlaying( const content::WebContentsObserver::MediaPlayerInfo& video_type, content::RenderFrameHost* render_frame_host) override {} void OnMainFrameIntersectionRectChanged( content::RenderFrameHost* rfh, const gfx::Rect& main_frame_intersection_rect) override {} void OnMainFrameViewportRectChanged( const gfx::Rect& main_frame_viewport_rect) override {} void OnMainFrameImageAdRectsChanged(const base::flat_map<int, gfx::Rect>& main_frame_image_ad_rects) override {} void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo& extra_request_complete_info) override {} void FrameReceivedUserActivation( content::RenderFrameHost* render_frame_host) override {} void FrameDisplayStateChanged(content::RenderFrameHost* render_frame_host, bool is_display_none) override {} void FrameSizeChanged(content::RenderFrameHost* render_frame_host, const gfx::Size& frame_size) override {} void OnCookiesRead(const GURL& url, const GURL& first_party_url, const net::CookieList& cookie_list, bool blocked_by_policy) override {} void OnCookieChange(const GURL& url, const GURL& first_party_url, const net::CanonicalCookie& cookie, bool blocked_by_policy) override {} void OnStorageAccessed(const GURL& url, const GURL& first_party_url, bool blocked_by_policy, page_load_metrics::StorageType access_type) override {} void OnPrefetchLikely() override {} void DidActivatePortal(base::TimeTicks activation_time) override {} void OnV8MemoryChanged(const std::vector<page_load_metrics::MemoryUpdate>& memory_updates) override {} void OnSharedStorageWorkletHostCreated() override {} // Reference implementations duplicated from PageLoadMetricsObserver ObservePolicy ShouldObserveMimeTypeByDefault( const std::string& mime_type) const; ObservePolicy OnEnterBackForwardCacheByDefault( const page_load_metrics::mojom::PageLoadTiming& timing); private: bool IsPrerendered() const; raw_ptr<page_load_metrics::PageLoadMetricsObserverDelegate> delegate_; bool started_ = false; // Same to `GetDelegate().DidCommit()` bool committed_ = false; // Same to `GetDelegate().GetPrerenderingData()` is one of // `kActivatedNoActivationStart` and `kActivated`. bool activated_ = false; mutable bool destructing_ = false; bool backforwardcache_entering_ = false; bool backforwardcache_entered_ = false; }; #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_OBSERVERS_ASSERT_PAGE_LOAD_METRICS_OBSERVER_H_
cd1affddb4da40ac9b015d1e33d0e9251ed5f6b0
9a92864acc9d970f802ee17cf4b62530f8b7b5f4
/tasks/example/pattern.cpp
cd5a4f1fa4c9c21b9cbfcdfeb79120353dedfb9e
[ "MIT" ]
permissive
CStanKonrad/SolutionChecker
7b7ddbd79602c99c4346f99e7d6848b3f1d26816
78bc22439f21d2fdf1f4100d910301e1194362a5
refs/heads/master
2020-12-21T07:02:27.831590
2017-01-24T18:17:50
2017-01-24T18:17:50
38,896,101
2
1
null
2016-11-05T07:43:32
2015-07-10T18:34:33
C++
UTF-8
C++
false
false
237
cpp
#include <iostream> #include <string> #include <unistd.h> using namespace std; string text; int main() { cin >> text; usleep(720000); for (int i = text.size() - 1; i >= 0; i--) { cout << text[i]; } cout << endl; return 0; }
c9968ba99aebe84c3481dd87e7bfecdc0e277f25
e7c0d034570bd2dec208c634ead49ad0eb3456e5
/CubeTable.h
46e062f462749165afc75dac0c126ff61bab17ff
[]
no_license
JohnsonZ-microe/cube
da5cac8e1b94ac219ff9b07333f07e7d45157856
3fa3a1838c93b1650c0158d1477949bafc7118c9
refs/heads/master
2022-07-08T12:57:58.691116
2020-05-12T09:16:35
2020-05-12T09:16:35
263,283,821
0
0
null
null
null
null
GB18030
C++
false
false
1,451
h
// CubeTable.h: interface for the CCubeTable class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CUBETABLE_H__4D71CE01_C2C3_4FD2_9485_667C93AB5E2A__INCLUDED_) #define AFX_CUBETABLE_H__4D71CE01_C2C3_4FD2_9485_667C93AB5E2A__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CCubeTable : public CObject { public: CCubeTable(); virtual ~CCubeTable(); private: // 魔方当前位置 int v_pos[ 20 ]; //各个位置所含的方块, 0..19 int v_ori[ 20 ]; //各个位置所含方块的朝向, 为0, 1, 2 // 临时变量 int temp; static const char *perm; static const char *corn; public: // pruning tables, 2 for each phase char table0[ 1 ]; char table1[ 4096 ]; //4096 = 2^12 12个棱的v_ori char table2[ 6561 ]; //6561 = 3^8 8个角的v_ori char table3[ 4096 ]; char table4[ 256 ]; char table5[ 1536 ]; // 1536 = 24*64 char table6[ 13824 ]; //13824 = 24*24*24 char table7[ 576 ]; // 576 = 24*24 char *tables [8]; int tablesize[8]; public: void filltable( int ti ); private: void reset(); void cycle( int *p, char *a ); void twist( int i, int a ); void domove( int m ); void numtoperm( int *p, int n, int ofp ); int permtonum( int *p, int ofp ); void setposition( int t, int n ); int getposition( int t ); }; CCubeTable theTable; #endif // !defined(AFX_CUBETABLE_H__4D71CE01_C2C3_4FD2_9485_667C93AB5E2A__INCLUDED_)
bdb52c9fb1ebedfefd58752bf8f6e31ac12de86b
c20c4812ac0164c8ec2434e1126c1fdb1a2cc09e
/Source/Source/Server/JX3ServerMergeTool/src/Test/Jx3DBChecker/KG_DBCheckRule.cpp
40a64ebc99a1474cd9dd262ba9f91692acbc8768
[ "MIT" ]
permissive
uvbs/FullSource
f8673b02e10c8c749b9b88bf18018a69158e8cb9
07601c5f18d243fb478735b7bdcb8955598b9a90
refs/heads/master
2020-03-24T03:11:13.148940
2018-07-25T18:30:25
2018-07-25T18:30:25
142,408,505
2
2
null
2018-07-26T07:58:12
2018-07-26T07:58:12
null
GB18030
C++
false
false
111,474
cpp
////////////////////////////////////////////////////////////////////////////////////// // // FileName : KG_DBCheckRule.cpp // Version : 1.0 // Creater : Liuzhibiao // Date : 2009-12-8 // Comment : ////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "KG_DBCheckRule.h" #include "KG_Jx3DBChecker.h" #include "KDBTools.h" #include "KCommon.h" int KG_DBCheckRule::m_snFuncIndex = 0; #define REGISTER_RULE_FUNC(TableName, Func) \ do \ { \ m_RuleTable[TableName] = m_snFuncIndex; \ m_RuleFunc[m_snFuncIndex] = &KG_DBCheckRule::Func; \ m_snFuncIndex++; \ } while (false) #define CLEAR_INFOVECTOR(InfoVector) \ do \ { \ for (size_t i = 0; i < InfoVector.size(); i++) \ { \ KG_DELETE_ARRAY(InfoVector[i].pvData); \ } \ InfoVector.clear(); \ } while(false) int KG_DBCheckRule::InitDBCheckRule() { int nResult = false; // int nRetCode = false; m_lRoleID_A = 0; m_lSequenceRoleID_B = 0; m_lRoleID_C = 0; m_lTongID_A = 0; m_lSequenceTongID_B = 0; m_lTongID_C = 0; m_GlobalMailIndexB = 0; memset(m_RuleFunc, 0, sizeof(m_RuleFunc)); REGISTER_RULE_FUNC("sequence", _CheckSequenceTable); REGISTER_RULE_FUNC("activity", _CheckActivityTable); REGISTER_RULE_FUNC("antifarmer", _CheckAntifarmerTable); REGISTER_RULE_FUNC("auction", _CheckAuctionTable); REGISTER_RULE_FUNC("fellowship", _CheckFellowshipTable); REGISTER_RULE_FUNC("gamecard", _CheckGameCardTable); REGISTER_RULE_FUNC("globalcustomdata", _CheckGlobalcustomdataTable); REGISTER_RULE_FUNC("globalsystemvalue", _CheckGlobalsystemvalue); REGISTER_RULE_FUNC("globalmailex", _CheckGlobalmailex); REGISTER_RULE_FUNC("mailbox", _CheckMailBoxTable); REGISTER_RULE_FUNC("mapcopy", _CheckMapcopyTable); REGISTER_RULE_FUNC("pq", _CheckPQTable); REGISTER_RULE_FUNC("role", _CheckRoleTable); REGISTER_RULE_FUNC("restorerole", _CheckRestoreroleTable); REGISTER_RULE_FUNC("roleblacklist", _CheckRoleblacklistTable); REGISTER_RULE_FUNC("roledeletelist", _CheckDeletelistTable); REGISTER_RULE_FUNC("statdatanameindex", _CheckStatdatanameindex); REGISTER_RULE_FUNC("statdata", _CheckSatadata); REGISTER_RULE_FUNC("tong", _CheckTongTable); REGISTER_RULE_FUNC("renamerole", _CheckRenameRoleTable); nResult = true; return nResult; } void KG_DBCheckRule::UnInitDBCheckRule() { } int KG_DBCheckRule::RuleCheck(string strTableName, KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; RULE_FUNC RuleFunc = NULL; RuleFunc = m_RuleFunc[m_RuleTable[strTableName]]; if (RuleFunc != NULL) { nRetCode = (this->*RuleFunc)(pTaskInfo); KGLOG_PROCESS_ERROR(nRetCode); } else { KGLogPrintf(KGLOG_INFO, "Do not find The CheckRule of The %s Table", strTableName); } nResult = true; Exit0: return nResult; } int KG_DBCheckRule::_CheckActivityTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecordA = false; bool bIsNoMoreRecordB = false; bool bIsNoMoreRecordC = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; unsigned long ulLastID_B = 0; unsigned long ulLastID_C = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("Type"); TempFileNameVector.push_back("Time"); TempFileNameVector.push_back("Value0"); TempFileNameVector.push_back("Value1"); TempFileNameVector.push_back("Value2"); TempFileNameVector.push_back("Value3"); TempFileNameVector.push_back("Value4"); TempFileNameVector.push_back("Value5"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; // 检查 B 和 C 匹配 while(true) { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecordB); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordB) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } // 保存最后一个ID号 ulLastID_B = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); } // 检查 A 和 C 匹配, ID 累加 while(true) { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecordA); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordA) { break; } ulHadNowCheckACount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息除ID项累加外,是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); ulLastID_B++; ulLastID_C = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(ulLastID_C == ulLastID_B); for (size_t i = 1; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } nResult = true; Exit0: if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckSequenceTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lRoleID_A = 0; long lRoleID_B = 0; long lRoleID_C = 0; long lTongID_A = 0; long lTongID_B = 0; long lTongID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; TempFileNameVector.push_back("seqname"); TempFileNameVector.push_back("currentid"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "RoleID"); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "RoleID"); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "RoleID"); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; // 检查RoleID a + b = c CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lRoleID_A = strtoul((char*)TempInfoVectorA[1].pvData, NULL, 10); m_lRoleID_A = lRoleID_A; CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lRoleID_B = strtoul((char*)TempInfoVectorB[1].pvData, NULL, 10); m_lSequenceRoleID_B = lRoleID_B; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lRoleID_C = strtoul((char*)TempInfoVectorC[1].pvData, NULL, 10); m_lRoleID_C = lRoleID_C; KGLOG_PROCESS_ERROR(lRoleID_C == lRoleID_A + lRoleID_B); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } // 检查TongID a + b = c TempFileNameVector.clear(); TempFileNameVector.push_back("seqname"); TempFileNameVector.push_back("currentid"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "TongID"); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "TongID"); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "TongID"); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lTongID_A = strtoul((char*)TempInfoVectorA[1].pvData, NULL, 10); m_lTongID_A = lTongID_A; CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lTongID_B = strtoul((char*)TempInfoVectorB[1].pvData, NULL, 10); m_lSequenceTongID_B = lTongID_B; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lTongID_C = strtoul((char*)TempInfoVectorC[1].pvData, NULL, 10); m_lTongID_C = lTongID_C; KGLOG_PROCESS_ERROR(lTongID_C == lTongID_A + lTongID_B); if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } // 获取B的总GlobalMailIndex pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "seqname", "GlobalMailIndex"); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { m_GlobalMailIndexB = 0; } else { m_GlobalMailIndexB = strtoul((char*)TempInfoVectorB[1].pvData, NULL, 10); } nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckAntifarmerTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; char szAccountA[MYSQL_STRING_MAX_SIZE]; char szAccountB[MYSQL_STRING_MAX_SIZE]; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("Account"); TempFileNameVector.push_back("PunishEndTime"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; //(3)antifarmer表: // a中的账号在b中不存在,插入,并检查插入信息和原a中信息完全一致 // a宏的账号在b中存在,替换,并检查插入信息和原a中信息完全一致 // 检查a中的账号在b中不存在,在c中存在,检查c信息和原a中信息完全一致 // a中的账号在b中存在,替换,并检查c信息和原a中信息完全一致 // 检查b中的账号,c中都存在 while(true) { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; memset(szAccountA, '\0', sizeof(szAccountA)); //KGLOG_PROCESS_ERROR(TempInfoVectorA[0].uDataSize <= sizeof(szAccountA)); strncpy(szAccountA, (char*)TempInfoVectorA[0].pvData, sizeof(szAccountA)); szAccountA[TempInfoVectorA[0].uDataSize] = '\0'; szAccountA[sizeof(szAccountA) - 1] = '\0'; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "Account", szAccountA); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; for (size_t i = 0; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } } if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; ulHadNowCheckBCount = 0; while(true) { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } memset(szAccountB, '\0', sizeof(szAccountB)); //KGLOG_PROCESS_ERROR(TempInfoVectorB[0].uDataSize <= sizeof(szAccountB)); strncpy(szAccountB, (char*)TempInfoVectorB[0].pvData, sizeof(szAccountB)); szAccountB[TempInfoVectorB[0].uDataSize] = '\0'; szAccountB[sizeof(szAccountB) - 1] = '\0'; pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "Account", szAccountB); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "Account", szAccountB); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } } nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckAuctionTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lSellerID_A = 0; long lSellerID_C = 0; long lBidderID_A = 0; long lBidderID_C = 0; long lAuctionLastID_A = 0; long lAuctionLastID_B = 0; long lAuctionLastID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("SellerID"); TempFileNameVector.push_back("BidderID"); TempFileNameVector.push_back("Name"); TempFileNameVector.push_back("AucGenre"); TempFileNameVector.push_back("AucSub"); TempFileNameVector.push_back("RequireLevel"); TempFileNameVector.push_back("Quality"); TempFileNameVector.push_back("SellerName"); TempFileNameVector.push_back("Price"); TempFileNameVector.push_back("BuyItnowPrice"); TempFileNameVector.push_back("CustodyCharges"); TempFileNameVector.push_back("DurationTime"); TempFileNameVector.push_back("ItemData"); //(4)auction表: // a中内容在c中全部存在,sellerID = a中原来SellerID + b原来的总RoleID // bidderID = a中原来bidderID + b原来的总RoleID // 其余字段完全一致 // 方法 , 遍历b,获取b中的所有记录,都在c中找到 // 遍历a,在b的id值基础上,每条记录在c中ID值递增,对比其他字段 // sellerID = a中原来SellerID + b原来的总RoleID // bidderID = a中原来bidderID + b原来的总RoleID pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; lAuctionLastID_B = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } lAuctionLastID_A = lAuctionLastID_B; while(true) // 遍历a,对比c { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lAuctionLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); lAuctionLastID_A++; KGLOG_PROCESS_ERROR(lAuctionLastID_C == lAuctionLastID_A); lSellerID_A = strtoul((char*)TempInfoVectorA[1].pvData, NULL, 10); lSellerID_C = strtoul((char*)TempInfoVectorC[1].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lSellerID_A + m_lSequenceRoleID_B == lSellerID_C); lBidderID_A = strtoul((char*)TempInfoVectorA[2].pvData, NULL, 10); lBidderID_C = strtoul((char*)TempInfoVectorC[2].pvData, NULL, 10); if (lBidderID_A != 0) { KGLOG_PROCESS_ERROR(lBidderID_A + m_lSequenceRoleID_B == lBidderID_C); } else { KGLOG_PROCESS_ERROR(lBidderID_A == lBidderID_C); } for (size_t i = 3; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckFellowshipTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lPlayerID_A = 0; long lPlyaerID_C = 0; int nFellowShipCountA = 0; int nFellowShipCountC = 0; int nFoeCountA = 0; int nFoeCountC = 0; int nBlackListCountA = 0; int nBlackListCountC = 0; DWORD dwAlliedPlayerIDA; int nAttractionA; int nGroupIDA; int nMarriedA; int nBrotherA; int nWhisperDailyCountA; int nDuelDailyCountA; char szRemarkA[128]; int nRemarkSizeA = sizeof(szRemarkA); DWORD dwAlliedPlayerIDC; int nAttractionC; int nGroupIDC; int nMarriedC; int nBrotherC; int nWhisperDailyCountC; int nDuelDailyCountC; char szRemarkC[128]; int nRemarkSizeC = sizeof(szRemarkC); FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; PARSEHANDLE pParseHandleA = NULL; PARSEHANDLE pParseHandleC = NULL; int nInitParseHandleA = false; int nInitParseHandleC = false; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("PlayerID"); TempFileNameVector.push_back("FellowshipData"); //(5)fellowship表: // a中内容在c中全部存在,playerID = a中原来playerID + b原来的总RoleID // FellowshipData中,所有的好友、仇人、黑名单 = 原ID + b原来的总RoleID // 方法 , 遍历b,获取b中的所有记录,都在c中找到 // 遍历a,在b的id值基础上,每条记录在c中ID值递增,对比其他字段 // sellerID = a中原来SellerID + b原来的总RoleID // bidderID = a中原来bidderID + b原来的总RoleID pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) // 遍历a,对比c { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; //KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lPlayerID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); lPlyaerID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lPlayerID_A + m_lSequenceRoleID_B == lPlyaerID_C); pParseHandleA = ParseFellowShipData((unsigned char*)TempInfoVectorA[1].pvData, TempInfoVectorA[1].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA); nInitParseHandleA = true; pParseHandleC = ParseFellowShipData((unsigned char*)TempInfoVectorC[1].pvData, TempInfoVectorC[1].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleC); nInitParseHandleC = true; nRetCode = GetFellowShipCount(pParseHandleA, nFellowShipCountA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetFellowShipCount(pParseHandleC, nFellowShipCountC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nFellowShipCountA == nFellowShipCountC); for (int i = 0; i < nFellowShipCountA; i++) { nRetCode = GetFellowshipInfo(pParseHandleA, i, dwAlliedPlayerIDA, nAttractionA, nGroupIDA, nMarriedA, nBrotherA, nWhisperDailyCountA, nDuelDailyCountA, szRemarkA, nRemarkSizeA ); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetFellowshipInfo(pParseHandleC, i, dwAlliedPlayerIDC, nAttractionC, nGroupIDC, nMarriedC, nBrotherC, nWhisperDailyCountC, nDuelDailyCountC, szRemarkC, nRemarkSizeC ); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(dwAlliedPlayerIDC == dwAlliedPlayerIDA + m_lSequenceRoleID_B); } nRetCode = GetFoeCount(pParseHandleA, nFoeCountA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetFoeCount(pParseHandleC, nFoeCountC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nFoeCountA == nFoeCountC); for (int i = 0; i < nFoeCountA; i++) { nRetCode = GetFoeID(pParseHandleA, i, dwAlliedPlayerIDA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetFoeID(pParseHandleC, i, dwAlliedPlayerIDC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(dwAlliedPlayerIDC == dwAlliedPlayerIDA + m_lSequenceRoleID_B); } nRetCode = GetBlackListCount(pParseHandleA, nBlackListCountA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetBlackListCount(pParseHandleC, nBlackListCountC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nBlackListCountA == nBlackListCountC); for (int i = 0; i < nBlackListCountA; i++) { nRetCode = GetBlackListID(pParseHandleA, i, dwAlliedPlayerIDA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetBlackListID(pParseHandleC, i, dwAlliedPlayerIDC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(dwAlliedPlayerIDC == dwAlliedPlayerIDA + m_lSequenceRoleID_B); } EndFellowshipParse(pParseHandleA); EndFellowshipParse(pParseHandleC); } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: if (nInitParseHandleA) { EndFellowshipParse(pParseHandleA); } if (nInitParseHandleC) { EndFellowshipParse(pParseHandleC); } CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckGameCardTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lSellerID_A = 0; long lSellerID_C = 0; long lGameCardLastID_A = 0; long lGameCardLastID_B = 0; long lGameCardLastID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("SellerID"); TempFileNameVector.push_back("Coin"); TempFileNameVector.push_back("GameTime"); TempFileNameVector.push_back("Type"); TempFileNameVector.push_back("Price"); TempFileNameVector.push_back("EndTime"); //(6)gamecard表: // a中内容在c中全部存在,SellerID = a中原来SellerID + b原来的总RoleID // 其余字段完全一致 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; lGameCardLastID_B = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } lGameCardLastID_A = lGameCardLastID_B; while(true) // 遍历a,对比c { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lGameCardLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); lGameCardLastID_A++; KGLOG_PROCESS_ERROR(lGameCardLastID_C == lGameCardLastID_A); lSellerID_A = strtoul((char*)TempInfoVectorA[1].pvData, NULL, 10); lSellerID_C = strtoul((char*)TempInfoVectorC[1].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lSellerID_A + m_lSequenceRoleID_B == lSellerID_C); for (size_t i = 2; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckGlobalcustomdataTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("Name"); TempFileNameVector.push_back("Value"); //(7)globalcustomdata表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckGlobalsystemvalue(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("Name"); TempFileNameVector.push_back("Value"); //(8)globalsystemvalue表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckGlobalmailex(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("Version"); TempFileNameVector.push_back("MailIndex"); TempFileNameVector.push_back("EndTime"); TempFileNameVector.push_back("MailInfo"); //(9)globalmailex表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckMailBoxTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lMailboxLastID_A = 0; long lMailboxLastID_B = 0; long lMailboxLastID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; PARSEHANDLE pParseHandleA = NULL; PARSEHANDLE pParseHandleC = NULL; unsigned long ulLastGlobalMailIndexC; unsigned long ulNextMailIDC; unsigned short usVersionC; int nMailCountA; int nMailCountC; unsigned long ulSenderIDA; DWORD dwMailIDA; char szSenderNameA[128]; unsigned char ucTypeA; bool bReadA; int nSenderNameSizeA = sizeof(szSenderNameA); char szTitleA[128]; int nTitleSizeA = sizeof(szTitleA); time_t nSendTimeA; time_t nReceiveTimeA; time_t nLockTimeA; int nMoneyA; int nItemCountA; char szTextA[1024]; int nTextSizeA = sizeof(szTextA); unsigned long ulSenderIDC; DWORD dwMailIDC; char szSenderNameC[128]; unsigned char ucTypeC; bool bReadC; int nSenderNameSizeC = sizeof(szSenderNameC); char szTitleC[128]; int nTitleSizeC = sizeof(szTitleC); time_t nSendTimeC; time_t nReceiveTimeC; time_t nLockTimeC; int nMoneyC; int nItemCountC; char szTextC[1024]; int nTextSizeC = sizeof(szTextC); unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("BaseTime"); TempFileNameVector.push_back("MailBoxInfo"); //(10)mailbox表: // a中内容在c中全部存在,ID = a中原来ID + b原来的总RoleID // MailBoxInfo中,dwLastGlobalMailIndex = b原来的总GlobalMainIndex // SenderID = a中原来的SenderID + b原来的总RoleID // 其余字段完全一致 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; lMailboxLastID_B = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) // 遍历a,对比c { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; lMailboxLastID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lMailboxLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lMailboxLastID_C == m_lSequenceRoleID_B + lMailboxLastID_A); pParseHandleA = ParseMailBoxInfoData((unsigned char*)TempInfoVectorA[2].pvData, TempInfoVectorA[2].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA); pParseHandleC = ParseMailBoxInfoData((unsigned char*)TempInfoVectorC[2].pvData, TempInfoVectorC[2].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleC); nRetCode = GetMailBaseInfo(pParseHandleC, ulNextMailIDC, ulLastGlobalMailIndexC, usVersionC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(ulLastGlobalMailIndexC == m_GlobalMailIndexB); nRetCode = GetMailCount(pParseHandleA, nMailCountA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetMailCount(pParseHandleC, nMailCountC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nMailCountA == nMailCountC); for(int i = 0; i < nMailCountA; i++) { nRetCode = GetMailInfo(pParseHandleA, i, dwMailIDA, ucTypeA, bReadA, szSenderNameA, nSenderNameSizeA, ulSenderIDA, szTitleA, nTitleSizeA, szTextA, nTextSizeA, nSendTimeA, nReceiveTimeA, nLockTimeA, nMoneyA, nItemCountA ); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetMailInfo(pParseHandleC, i, dwMailIDC, ucTypeC, bReadC, szSenderNameC, nSenderNameSizeC, ulSenderIDC, szTitleC, nTitleSizeC, szTextC, nTextSizeC, nSendTimeC, nReceiveTimeC, nLockTimeC, nMoneyC, nItemCountC ); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(dwMailIDA == dwMailIDC); KGLOG_PROCESS_ERROR(ucTypeA == ucTypeC); KGLOG_PROCESS_ERROR(bReadA == bReadC); nRetCode = strcmp(szSenderNameA, szSenderNameC); KGLOG_PROCESS_ERROR(nRetCode == 0); if (ucTypeC == 4)// 是玩家邮件才累加 { KGLOG_PROCESS_ERROR(ulSenderIDA + m_lSequenceRoleID_B == ulSenderIDC); } nRetCode = strcmp(szTitleA, szTitleC); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = strcmp(szTextA, szTextC); KGLOG_PROCESS_ERROR(nRetCode == 0); KGLOG_PROCESS_ERROR(nSendTimeA == nSendTimeC); KGLOG_PROCESS_ERROR(nReceiveTimeA == nReceiveTimeC); KGLOG_PROCESS_ERROR(nLockTimeA == nLockTimeC); KGLOG_PROCESS_ERROR(nMoneyA == nMoneyC); KGLOG_PROCESS_ERROR(nItemCountA == nItemCountC); } EndMailBoxParse(pParseHandleA); EndMailBoxParse(pParseHandleC); } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: EndMailBoxParse(pParseHandleA); EndMailBoxParse(pParseHandleC); CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckMapcopyTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("MapID"); TempFileNameVector.push_back("MapCopyIndex"); TempFileNameVector.push_back("SceneData"); TempFileNameVector.push_back("CreateTime"); TempFileNameVector.push_back("LastModifyTime"); //(11)mapcopy表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckPQTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("Data"); //(12)pq表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckBCount); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckRoleTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lRoleLastID_A = 0; long lRoleLastID_C = 0; long long llReNameRoleID = 0; char szRoleNameA[MYSQL_STRING_MAX_SIZE]; char szRoleNameB[MYSQL_STRING_MAX_SIZE]; char szRoleNameC[MYSQL_STRING_MAX_SIZE]; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; PARSEHANDLE pParseHandleA = NULL; PARSEHANDLE pParseHandleB = NULL; PARSEHANDLE pParseHandleC = NULL; PARSEHANDLE pParseHandleA_Base = NULL; time_t nLastSaveTimeA = 0; time_t nLastSaveTimeB = 0; map<string, int>::iterator itA; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; bool bIsDataBlockExist =false; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("RoleName"); TempFileNameVector.push_back("ExtInfo"); TempFileNameVector.push_back("BaseInfo"); TempFileNameVector.push_back("Account"); TempFileNameVector.push_back("LastModify"); //(13)role表: // a中内容在c中全部存在,ID = a中原来ID + b原来的总RoleID // RoleName:a中的RoleName在b中存在,判断角色的最后保存时间,时间大的,角色名保留,时间小的,角色名更改;不存在,不变 // ExtInfo:清除rbtPQList字段相关数据 // 其余字段完全一致 pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c,且在a中找b当前的角色名 { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); KGLOG_PROCESS_ERROR(sizeof(szRoleNameB) > TempInfoVectorB[1].uDataSize); memset(szRoleNameB, '\0', sizeof(szRoleNameB)); strncpy(szRoleNameB, (const char*)TempInfoVectorB[1].pvData, TempInfoVectorB[1].uDataSize); // 在a中找b的当前角色名 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, true, "RoleName", szRoleNameB); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord)//找不到 { for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } else//找到了 { pParseHandleB = ::ParseRoleBaseData((unsigned char*)TempInfoVectorB[3].pvData, TempInfoVectorB[3].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleB); nRetCode = ::GetLastSaveTime(pParseHandleB, nLastSaveTimeB); KGLOG_PROCESS_ERROR(nRetCode); ::EndRoleParse(pParseHandleB); m_RoleNamesMap[szRoleNameB] = nLastSaveTimeB; pParseHandleA_Base = ::ParseRoleBaseData((unsigned char*)TempInfoVectorA[3].pvData, TempInfoVectorA[3].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA_Base); nRetCode = ::GetLastSaveTime(pParseHandleA_Base, nLastSaveTimeA); ::EndRoleParse(pParseHandleA_Base); if (nLastSaveTimeA > nLastSaveTimeB) // a的角色保存时间 比 b大,b要改角色名 { nRetCode = memcmp(TempInfoVectorB[0].pvData, TempInfoVectorC[0].pvData, TempInfoVectorB[0].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0);//ID段 llReNameRoleID = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(sizeof(szRoleNameC) > TempInfoVectorC[1].uDataSize); memset(szRoleNameC, '\0', sizeof(szRoleNameC)); strncpy(szRoleNameC, (const char*)TempInfoVectorC[1].pvData, TempInfoVectorC[1].uDataSize); string strB = szRoleNameB; string strC = szRoleNameC; nRetCode = strC.compare(strB); KGLOG_PROCESS_ERROR(nRetCode > 0); for (size_t i = 2; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } m_RenameRoleMap[llReNameRoleID] = false; } else { for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; while(true) // 遍历a,对比c { itA = m_RoleNamesMap.end(); CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; lRoleLastID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lRoleLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lRoleLastID_C == m_lSequenceRoleID_B + lRoleLastID_A); if (TempInfoVectorA[2].uDataSize != 0) { pParseHandleA = ::ParseRoleExtData((unsigned char*)TempInfoVectorA[2].pvData, TempInfoVectorA[2].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA); pParseHandleC = ::ParseRoleExtData((unsigned char*)TempInfoVectorC[2].pvData, TempInfoVectorC[2].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleC); nRetCode = ::IsDataBlockExist(pParseHandleC, 16, bIsDataBlockExist); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsDataBlockExist); } KGLOG_PROCESS_ERROR(sizeof(szRoleNameA) > TempInfoVectorA[1].uDataSize); memset(szRoleNameA, '\0', sizeof(szRoleNameA)); strncpy(szRoleNameA, (const char*)TempInfoVectorA[1].pvData, TempInfoVectorA[1].uDataSize); itA = m_RoleNamesMap.find(szRoleNameA); if (itA != m_RoleNamesMap.end()) //处理重名 { pParseHandleA_Base = ::ParseRoleBaseData((unsigned char*)TempInfoVectorA[3].pvData, TempInfoVectorA[3].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA_Base); nRetCode = ::GetLastSaveTime(pParseHandleA_Base, nLastSaveTimeA); KGLOG_PROCESS_ERROR(nRetCode); ::EndRoleParse(pParseHandleA_Base); if (nLastSaveTimeA <= m_RoleNamesMap[szRoleNameA]) //a比b晚,a改名 { llReNameRoleID = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); m_RenameRoleMap[llReNameRoleID + m_lSequenceRoleID_B] = false; KGLOG_PROCESS_ERROR(sizeof(szRoleNameC) > TempInfoVectorC[1].uDataSize); memset(szRoleNameC, '\0', sizeof(szRoleNameC)); strncpy(szRoleNameC, (const char*)TempInfoVectorC[1].pvData, TempInfoVectorC[1].uDataSize); string strA = szRoleNameA; string strC = szRoleNameC; nRetCode = strC.compare(strA); KGLOG_PROCESS_ERROR(nRetCode > 0); } else { KGLOG_PROCESS_ERROR(sizeof(szRoleNameC) > TempInfoVectorC[1].uDataSize); memset(szRoleNameC, '\0', sizeof(szRoleNameC)); strncpy(szRoleNameC, (const char*)TempInfoVectorC[1].pvData, TempInfoVectorC[1].uDataSize); string strA = szRoleNameA; string strC = szRoleNameC; nRetCode = strC.compare(strA); KGLOG_PROCESS_ERROR(nRetCode == 0); } } ::EndRoleParse(pParseHandleA); ::EndRoleParse(pParseHandleC); for (size_t i = 3; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: ::EndRoleParse(pParseHandleA_Base); ::EndRoleParse(pParseHandleA); ::EndRoleParse(pParseHandleB); ::EndRoleParse(pParseHandleC); CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckRestoreroleTable( KG_TASK_INFO* pTaskInfo ) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecordB = false; bool bIsNoMoreRecordC = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("ExtInfo"); TempFileNameVector.push_back("Rolename"); TempFileNameVector.push_back("Account"); TempFileNameVector.push_back("BaseInfo"); TempFileNameVector.push_back("DeleteTime"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; //(14)Restorerole表: // a中内容全部被丢弃 // 检查 B 和 C 匹配 while(true) { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecordB); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordB) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordC) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckBCount == ulHadNowCheckCCount); nResult = true; Exit0: if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckRoleblacklistTable( KG_TASK_INFO* pTaskInfo ) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecordA = false; bool bIsNoMoreRecordB = false; bool bIsNoMoreRecordC = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; unsigned long ulLastID_A = 0; unsigned long ulLastID_B = 0; unsigned long ulLastID_C = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("FreezeTime"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; // 检查 B 和 C 匹配 while(true) { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecordB); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordB) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } // 保存最后一个ID号 ulLastID_B = strtoul((char*)TempInfoVectorB[0].pvData, NULL, 10); //nRetCode = } // 检查 A 和 C 匹配, ID 累加 while(true) { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecordA); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordA) { break; } ulHadNowCheckACount++; ulLastID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息除ID项累加外,是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); ulLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(ulLastID_C == ulLastID_A + m_lSequenceRoleID_B); for (size_t i = 1; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecordC) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckDeletelistTable( KG_TASK_INFO* pTaskInfo ) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecordA = false; bool bIsNoMoreRecordB = false; bool bIsNoMoreRecordC = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; unsigned long ulLastID_A = 0; unsigned long ulLastID_C = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("EndTime"); pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; // 检查 B 和 C 匹配 while(true) { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecordB); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordB) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } // 检查 A 和 C 匹配, ID 累加 while(true) { CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecordA); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecordA) { break; } ulHadNowCheckACount++; ulLastID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecordC); ulHadNowCheckCCount++; // 判断所有字段信息除ID项累加外,是否完全一致 KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); ulLastID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(ulLastID_C == ulLastID_A + m_lSequenceRoleID_B); for (size_t i = 1; i < TempInfoVectorA.size(); i++) { nRetCode = memcmp(TempInfoVectorA[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorA[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecordC); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecordC) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckStatdatanameindex(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long lRecordCountB = 0; unsigned long lRecordCountC = 0; TempFileNameVector.push_back("Name"); TempFileNameVector.push_back("ID"); //(17)statdatanameindex表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } lRecordCountB++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lRecordCountC++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } lRecordCountC++; } KGLOG_PROCESS_ERROR(lRecordCountC == lRecordCountB); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckSatadata(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; unsigned long lRecordCountB = 0; unsigned long lRecordCountC = 0; TempFileNameVector.push_back("StatTime"); TempFileNameVector.push_back("StatData"); //(18)statdata表: // a中内容全部被丢弃 pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } lRecordCountB++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); lRecordCountC++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } lRecordCountC++; } KGLOG_PROCESS_ERROR(lRecordCountB == lRecordCountC); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckTongTable(KG_TASK_INFO* pTaskInfo) { int nResult = false; int nRetCode = false; long lTongID_A = 0; long lTongID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; PARSEHANDLE pParseHandleA = NULL; PARSEHANDLE pParseHandleB = NULL; PARSEHANDLE pParseHandleC = NULL; char szNameA[32]; DWORD dwMasterA; // 帮主 int nFundA; // 资金 int nLevelA; int nDevelopmentPointA; // 发展点 WORD wMaxMemberCountA; // 成员上限 BYTE byTongStateA; time_t nStateTimerA; BYTE byCampA; // 阵营 int nTongMemberCountA; DWORD dwIDA; int nGroupIDA; time_t nJoinTimeA; time_t nLastOfflineTimeA; char szRemarkA[32]; int nSalaryA; // 工资储蓄(银币) char szNameB[32]; DWORD dwMasterB; // 帮主 int nFundB; // 资金 int nLevelB; int nDevelopmentPointB; // 发展点 WORD wMaxMemberCountB; // 成员上限 BYTE byTongStateB; time_t nStateTimerB; BYTE byCampB; // 阵营 char szNameC[32]; DWORD dwMasterC; // 帮主 int nFundC; // 资金 int nLevelC; int nDevelopmentPointC; // 发展点 WORD wMaxMemberCountC; // 成员上限 BYTE byTongStateC; time_t nStateTimerC; BYTE byCampC; // 阵营 int nTongMemberCountC; DWORD dwIDC; int nGroupIDC; time_t nJoinTimeC; time_t nLastOfflineTimeC; char szRemarkC[32]; int nSalaryC; // 工资储蓄(银币) map<string, int>::iterator it; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("ID"); TempFileNameVector.push_back("Data"); //(19)tong表: // a中内容在c中全部存在,ID = a中原来ID + b原来的总tongID // Data:szName:a中的szName在b中存在,加数字后缀;不存在,不变 // dwMaster = a中原来dwMaster + b原来的总RoleID // dwID = a中原来dwID + b原来的总RoleID pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c // 并保存帮会名称 { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } pParseHandleB = PaserTongData((unsigned char*)TempInfoVectorB[1].pvData, TempInfoVectorB[1].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleB); nRetCode = GetTongBaseInfo(pParseHandleB, szNameB, sizeof(szNameB), dwMasterB, nFundB, nLevelB, nDevelopmentPointB, wMaxMemberCountB, byTongStateB, nStateTimerB, byCampB ); KGLOG_PROCESS_ERROR(nRetCode); m_TongNameMap[szNameB] = true; } while(true) // 遍历a,对比c { it = m_TongNameMap.end(); CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; lTongID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lTongID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lTongID_C == m_lSequenceTongID_B + lTongID_A); pParseHandleA = PaserTongData((unsigned char*)TempInfoVectorA[1].pvData, TempInfoVectorA[1].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleA); pParseHandleC = PaserTongData((unsigned char*)TempInfoVectorC[1].pvData, TempInfoVectorC[1].uDataSize); KGLOG_PROCESS_ERROR(pParseHandleC); nRetCode = GetTongBaseInfo(pParseHandleA, szNameA, sizeof(szNameA), dwMasterA, nFundA, nLevelA, nDevelopmentPointA, wMaxMemberCountA, byTongStateA, nStateTimerA, byCampA ); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetTongBaseInfo(pParseHandleC, szNameC, sizeof(szNameC), dwMasterC, nFundC, nLevelC, nDevelopmentPointC, wMaxMemberCountC, byTongStateC, nStateTimerC, byCampC ); KGLOG_PROCESS_ERROR(nRetCode); it = m_TongNameMap.find(szNameA); if (it != m_TongNameMap.end()) { string strA = szNameA; string strC = szNameC; //strA = strA + '1'; KGLOG_PROCESS_ERROR(strC.find("@") != string::npos); KGLOG_PROCESS_ERROR(strC.find(strA.substr(0,2)) != string::npos); } KGLOG_PROCESS_ERROR(dwMasterC == dwMasterA + m_lSequenceRoleID_B); nRetCode = GetTongMemberCount(pParseHandleA, nTongMemberCountA); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetTongMemberCount(pParseHandleC, nTongMemberCountC); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nTongMemberCountA == nTongMemberCountC); for(int i = 0; i < nTongMemberCountA; i++) { nRetCode = GetTongMemberInfo(pParseHandleA, i, dwIDA, nGroupIDA, nJoinTimeA, nLastOfflineTimeA, szRemarkA, 32, nSalaryA ); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetTongMemberInfo(pParseHandleC, i, dwIDC, nGroupIDC, nJoinTimeC, nLastOfflineTimeC, szRemarkC, 32, nSalaryC ); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(dwIDC == dwIDA + m_lSequenceRoleID_B); KGLOG_PROCESS_ERROR(nGroupIDA == nGroupIDC); KGLOG_PROCESS_ERROR(nJoinTimeA == nJoinTimeC); KGLOG_PROCESS_ERROR(nLastOfflineTimeA == nLastOfflineTimeC); nRetCode = strcmp(szRemarkA, szRemarkC); KGLOG_PROCESS_ERROR(nRetCode == 0); KGLOG_PROCESS_ERROR(nSalaryA == nSalaryC); } EndTongParse(pParseHandleA); EndTongParse(pParseHandleC); } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } ulHadNowCheckCCount++; } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount); nResult = true; Exit0: EndTongParse(pParseHandleA); EndTongParse(pParseHandleB); EndTongParse(pParseHandleC); CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; } int KG_DBCheckRule::_CheckRenameRoleTable( KG_TASK_INFO* pTaskInfo ) { int nResult = false; int nRetCode = false; long lRoleID_A = 0; long lRoleID_C = 0; FIELD_NAME_VECTOR TempFileNameVector; FIELD_INFO_VECTOR TempInfoVectorA; FIELD_INFO_VECTOR TempInfoVectorB; FIELD_INFO_VECTOR TempInfoVectorC; FIELD_ID_VECTOR TempIDVector; bool bIsNoMoreRecord = false; MYSQL_RES* pMySQL_ResA = NULL; MYSQL_RES* pMySQL_ResB = NULL; MYSQL_RES* pMySQL_ResC = NULL; int nInitMySQL_ResA = false; int nInitMySQL_ResB = false; int nInitMySQL_ResC = false; map<string, int>::iterator it; map<long long , bool>::iterator itRename; unsigned long ulHadNowCheckACount = 0; unsigned long ulHadNowCheckBCount = 0; unsigned long ulHadNowCheckCCount = 0; TempFileNameVector.push_back("RoleID"); //(20)renamerole表: pMySQL_ResA = pTaskInfo->DBTools[0].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResA); nInitMySQL_ResA = true; pMySQL_ResB = pTaskInfo->DBTools[1].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResB); nInitMySQL_ResB = true; pMySQL_ResC = pTaskInfo->DBTools[2].CreateRecordSet(pTaskInfo->strTableName.c_str(), TempFileNameVector, TempIDVector, false, NULL, NULL); KGLOG_PROCESS_ERROR(pMySQL_ResC); nInitMySQL_ResC = true; while(true) // 遍历b,对比c { CLEAR_INFOVECTOR(TempInfoVectorB); nRetCode = pTaskInfo->DBTools[1].GetNextRecord(pMySQL_ResB, TempInfoVectorB, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckBCount++; CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorB.size() == TempInfoVectorC.size()); for (size_t i = 0; i < TempInfoVectorB.size(); i++) { nRetCode = memcmp(TempInfoVectorB[i].pvData, TempInfoVectorC[i].pvData, TempInfoVectorB[i].uDataSize); KGLOG_PROCESS_ERROR(nRetCode == 0); } } while(true) // 遍历a,对比c { it = m_TongNameMap.end(); CLEAR_INFOVECTOR(TempInfoVectorA); nRetCode = pTaskInfo->DBTools[0].GetNextRecord(pMySQL_ResA, TempInfoVectorA, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if (bIsNoMoreRecord) { break; } ulHadNowCheckACount++; lRoleID_A = strtoul((char*)TempInfoVectorA[0].pvData, NULL, 10); CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(!bIsNoMoreRecord); ulHadNowCheckCCount++; KGLOG_PROCESS_ERROR(TempInfoVectorA.size() == TempInfoVectorC.size()); lRoleID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); KGLOG_PROCESS_ERROR(lRoleID_C == m_lSequenceRoleID_B + lRoleID_A); } while(true) { CLEAR_INFOVECTOR(TempInfoVectorC); nRetCode = pTaskInfo->DBTools[2].GetNextRecord(pMySQL_ResC, TempInfoVectorC, bIsNoMoreRecord); KGLOG_PROCESS_ERROR(nRetCode); if(bIsNoMoreRecord) { break; } lRoleID_C = strtoul((char*)TempInfoVectorC[0].pvData, NULL, 10); itRename = m_RenameRoleMap.find(lRoleID_C); KGLOG_PROCESS_ERROR(itRename != m_RenameRoleMap.end()); m_RenameRoleMap[lRoleID_C] = true; ulHadNowCheckCCount++; } for (itRename = m_RenameRoleMap.begin(); itRename != m_RenameRoleMap.end(); ++itRename) { KGLOG_PROCESS_ERROR(itRename->second == true); } KGLOG_PROCESS_ERROR(ulHadNowCheckCCount == ulHadNowCheckACount + ulHadNowCheckBCount + m_RenameRoleMap.size()); nResult = true; Exit0: CLEAR_INFOVECTOR(TempInfoVectorA); CLEAR_INFOVECTOR(TempInfoVectorB); CLEAR_INFOVECTOR(TempInfoVectorC); if (nInitMySQL_ResC) { pTaskInfo->DBTools[2].FreeRecordSet(pMySQL_ResC); nInitMySQL_ResC = false; } if (nInitMySQL_ResB) { pTaskInfo->DBTools[1].FreeRecordSet(pMySQL_ResB); nInitMySQL_ResC = false; } if (nInitMySQL_ResA) { pTaskInfo->DBTools[0].FreeRecordSet(pMySQL_ResA); nInitMySQL_ResA = false; } return nResult; }
38c83739ab5b0ddb4210e17cade1bce4ecd13ed6
62a59ca4fd181b6ee3758903ba656c14542fde72
/Server/GDouDiZhuServer/src/JJDDZRoomStateWaitReadyChaoZhuangMode.h
49c8e06610b423027355454fab96f490de2017df
[]
no_license
BillXu/XProject
dc4f277db0b9e8c73c561dca68ee6d86e8cb2db3
e1ebec2b930971efb8fc822f4107d836d311518a
refs/heads/master
2021-01-19T22:44:28.542648
2018-04-10T12:06:35
2018-04-10T12:06:35
88,851,690
1
0
null
null
null
null
UTF-8
C++
false
false
323
h
#pragma once #include "DDZRoomStateWaitReady.h" class JJDDZRoomStateWaitReadyChaoZhuangMode :public DDZRoomStateWaitReady { public: void update(float fDeta)override { IGameRoomState::update(fDeta); auto pRoom = getRoom(); if (pRoom->canStartGame()) { pRoom->goToState(eRoomState_JJ_DDZ_Chao_Zhuang); } } };
d0ef70e756ce7035c4d64a00cbeec4f2fb45d0c7
a61a21484fa9d29152793b0010334bfe2fed71eb
/Skyrim/src/BSDevices/InputMappingManager.cpp
0726f430138d49cec6cc1e9ec017f3f3eeaafdc1
[]
no_license
kassent/IndividualizedShoutCooldowns
784e3c62895869c7826dcdbdeea6e8e177e8451c
f708063fbc8ae21ef7602e03b4804ae85518f551
refs/heads/master
2021-01-19T05:22:24.794134
2017-04-06T13:00:19
2017-04-06T13:00:19
87,429,558
3
3
null
null
null
null
UTF-8
C++
false
false
1,400
cpp
#include "Skyrim/BSDevices/InputMappingManager.h" DECLARE_BSTSINGLETONSDM_STATIC_INSTANCE(InputMappingManager, 0x012E7458, 0x01B37FB0); UInt32 InputMappingManager::GetMappedKey(const BSFixedString &name, BSInputDevice::Type deviceType, ContextType contextIdx) const { BSTArray<InputMapping::Data> * maps = nullptr; if (deviceType == BSInputDevice::kType_Mouse) maps = &mappings[contextIdx]->mouseMap; else if (deviceType == BSInputDevice::kType_Gamepad) maps = &mappings[contextIdx]->gamepadMap; else if (deviceType == BSInputDevice::kType_Keyboard) maps = &mappings[contextIdx]->keyboardMap; if (maps) { for (InputMapping::Data &data : *maps) { if (data.name == name) return data.buttonID; } } return kInvalid; } const BSFixedString & InputMappingManager::GetUserEventName(UInt32 buttonID, BSInputDevice::Type deviceType, ContextType contextIdx) const { BSTArray<InputMapping::Data> * maps = nullptr; if (deviceType == BSInputDevice::kType_Mouse) maps = &mappings[contextIdx]->mouseMap; else if (deviceType == BSInputDevice::kType_Gamepad) maps = &mappings[contextIdx]->gamepadMap; else if (deviceType == BSInputDevice::kType_Keyboard) maps = &mappings[contextIdx]->keyboardMap; static BSFixedString none = ""; if (maps) { for (InputMapping::Data &data : *maps) { if (data.buttonID == buttonID) return data.name; } } return none; }
8d9d77b7fc1e3a209d04a035546188ee7ab643fa
4bea57e631734f8cb1c230f521fd523a63c1ff23
/projects/openfoam/rarefied-flows/impingment/sims/templates/wedge15Ma5/0.32/p
07cf2e81efee22508490f8b73933801dccb3c1f6
[]
no_license
andytorrestb/cfal
76217f77dd43474f6b0a7eb430887e8775b78d7f
730fb66a3070ccb3e0c52c03417e3b09140f3605
refs/heads/master
2023-07-04T01:22:01.990628
2021-08-01T15:36:17
2021-08-01T15:36:17
294,183,829
1
0
null
null
null
null
UTF-8
C++
false
false
39,233
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.32"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 -1 -2 0 0 0 0]; internalField nonuniform List<scalar> 4800 ( 49.6905 8.0803 5.75171 5.86937 5.97351 6.0674 6.12887 6.16906 6.19783 6.22481 6.25353 6.28178 6.3048 6.31889 6.32431 6.32312 6.32071 6.31668 6.31352 6.31095 6.30937 6.31228 6.31587 6.31893 6.31694 6.30607 6.28725 6.26563 6.24624 6.23049 6.21546 6.20499 6.19814 6.19738 6.21213 6.24208 6.27872 6.31201 6.331 6.32839 49.6884 8.09501 5.76042 5.87117 5.96679 6.05957 6.12386 6.16938 6.20347 6.23177 6.25713 6.28035 6.2995 6.312 6.31773 6.31691 6.31617 6.31386 6.3119 6.31085 6.31055 6.31334 6.31512 6.31624 6.31233 6.2999 6.28069 6.25949 6.24207 6.22875 6.21721 6.21057 6.20635 6.20646 6.21886 6.2447 6.27793 6.30854 6.33158 6.33413 49.6789 8.12438 5.76988 5.86787 5.95325 6.0471 6.11877 6.17294 6.21192 6.24001 6.26035 6.27702 6.29155 6.3027 6.30922 6.30983 6.31183 6.31189 6.31076 6.31174 6.31218 6.31344 6.31283 6.3114 6.305 6.29111 6.27188 6.25107 6.23677 6.22776 6.22186 6.22012 6.2191 6.21985 6.22796 6.24633 6.2732 6.30025 6.32313 6.32844 49.6695 8.16408 5.78541 5.8672 5.93613 6.02852 6.1079 6.17342 6.21942 6.24808 6.26448 6.27479 6.28307 6.29107 6.29759 6.30024 6.30479 6.30763 6.30854 6.31133 6.31213 6.31144 6.30841 6.30379 6.29417 6.27888 6.25942 6.23972 6.22992 6.22693 6.22839 6.23181 6.23458 6.23668 6.24079 6.2507 6.26928 6.29205 6.31382 6.3228 49.6631 8.2116 5.80728 5.86829 5.91861 6.00589 6.09205 6.16886 6.2232 6.25478 6.26919 6.27429 6.27689 6.28155 6.28705 6.2909 6.29865 6.30282 6.30513 6.30944 6.31048 6.30758 6.30222 6.29442 6.28145 6.26516 6.24529 6.22844 6.2235 6.22656 6.23505 6.24415 6.2509 6.25414 6.25531 6.25814 6.26814 6.28512 6.30476 6.31677 49.6596 8.26315 5.83282 5.87449 5.90585 5.98232 6.07083 6.15752 6.22147 6.25848 6.27375 6.27702 6.27553 6.27628 6.27921 6.28282 6.2924 6.29769 6.3021 6.30689 6.30723 6.30276 6.29519 6.28455 6.26878 6.25151 6.23153 6.21802 6.21835 6.22739 6.24168 6.25566 6.26588 6.27014 6.26951 6.26753 6.27074 6.28192 6.2986 6.3134 49.66 8.31518 5.86053 5.88639 5.90015 5.96006 6.04521 6.13836 6.21194 6.2563 6.27582 6.28024 6.27807 6.27561 6.2761 6.27828 6.28748 6.29232 6.29768 6.30281 6.30265 6.29747 6.2884 6.27578 6.25774 6.23977 6.22004 6.20977 6.21516 6.22943 6.24828 6.26564 6.27874 6.28406 6.28231 6.27723 6.27385 6.27979 6.29533 6.31248 49.6646 8.3643 5.88901 5.90327 5.90117 5.94116 6.01702 6.11189 6.19436 6.24785 6.2735 6.28172 6.28108 6.2792 6.27746 6.27725 6.28386 6.28727 6.29223 6.29735 6.29643 6.29123 6.28234 6.26922 6.24971 6.23186 6.21248 6.20465 6.21403 6.23265 6.25472 6.27425 6.28876 6.29437 6.2906 6.28384 6.27847 6.28123 6.29617 6.31541 49.6762 8.40826 5.91687 5.924 5.90815 5.92792 5.98885 6.08052 6.16971 6.23349 6.26748 6.28153 6.28468 6.28369 6.28097 6.27797 6.28082 6.28238 6.28579 6.28967 6.28884 6.28436 6.27709 6.26464 6.24546 6.22838 6.20947 6.20319 6.21504 6.23655 6.26042 6.28097 6.29504 6.30003 6.29786 6.29253 6.28611 6.28607 6.30008 6.32177 49.6952 8.44577 5.9433 5.94656 5.92001 5.9214 5.9642 6.0477 6.13949 6.21257 6.25604 6.27716 6.28515 6.28663 6.28448 6.27892 6.27792 6.27757 6.27857 6.27994 6.27975 6.27695 6.27211 6.2615 6.24475 6.2286 6.21061 6.205 6.21793 6.24061 6.26514 6.28543 6.29901 6.30525 6.30464 6.2992 6.29177 6.28985 6.30213 6.32652 49.7194 8.47546 5.96829 5.96909 5.93518 5.92122 5.94558 6.01669 6.10583 6.18575 6.23891 6.26799 6.28128 6.28616 6.28573 6.27898 6.27538 6.27373 6.27123 6.26969 6.27029 6.26912 6.26717 6.25969 6.24648 6.23174 6.21511 6.20977 6.22235 6.24419 6.26847 6.28974 6.3045 6.31131 6.31114 6.30483 6.29555 6.29069 6.30022 6.3262 49.7459 8.49536 5.99207 5.99066 5.95251 5.92947 5.93637 5.98991 6.07129 6.15446 6.21638 6.25347 6.27252 6.28106 6.28336 6.27784 6.27357 6.27033 6.26457 6.26039 6.26077 6.26136 6.26245 6.25859 6.24927 6.23612 6.22137 6.217 6.22803 6.2489 6.27441 6.29721 6.31265 6.31888 6.31712 6.30938 6.29811 6.29067 6.29767 6.32256 49.7745 8.50343 6.01364 6.01037 5.9701 5.94501 5.93782 5.97002 6.03935 6.121 6.18911 6.23353 6.25848 6.2715 6.2771 6.27352 6.27085 6.26695 6.25941 6.25347 6.25266 6.25474 6.25785 6.25779 6.25211 6.24072 6.22915 6.22641 6.23636 6.25692 6.28281 6.30654 6.32164 6.3256 6.32191 6.31328 6.3017 6.29216 6.29628 6.3173 49.8047 8.50081 6.03189 6.0276 5.98886 5.96452 5.94656 5.95981 6.01335 6.0879 6.15811 6.20854 6.23933 6.2575 6.26777 6.26894 6.26944 6.26553 6.2574 6.25023 6.24706 6.24877 6.25284 6.25566 6.25301 6.24511 6.23756 6.23783 6.24946 6.26999 6.29419 6.31513 6.32729 6.32937 6.32495 6.31644 6.30454 6.29445 6.296 6.31236 49.8331 8.48559 6.04662 6.04344 6.00843 5.9847 5.96058 5.95933 5.99515 6.05813 6.12506 6.17893 6.21543 6.23991 6.25636 6.26488 6.27034 6.2675 6.25963 6.25141 6.24461 6.2449 6.24716 6.25056 6.2512 6.24804 6.24557 6.25107 6.2658 6.28543 6.30526 6.32075 6.32915 6.32986 6.32591 6.31785 6.30786 6.29883 6.2984 6.31049 49.8594 8.4581 6.05781 6.0579 6.02785 6.00513 5.9778 5.9661 5.98557 6.03403 6.09287 6.14643 6.18789 6.21977 6.2439 6.2612 6.27333 6.27251 6.26618 6.2566 6.24567 6.24222 6.24213 6.24418 6.24678 6.24842 6.25266 6.26458 6.28178 6.2989 6.31284 6.32237 6.32719 6.32779 6.3244 6.31963 6.31258 6.30629 6.30596 6.31445 49.8861 8.42209 6.06619 6.07026 6.04527 6.02476 5.99635 5.97783 5.9834 6.01658 6.0651 6.11515 6.1597 6.19832 6.23087 6.25782 6.27717 6.27948 6.2753 6.26423 6.24984 6.24155 6.23729 6.23634 6.24054 6.24693 6.25876 6.27576 6.29365 6.3074 6.31589 6.32016 6.32291 6.32355 6.32294 6.32248 6.31994 6.31794 6.319 6.32422 49.9141 8.38165 6.07174 6.07981 6.05963 6.04175 6.01381 5.99132 5.98597 6.0057 6.04388 6.08935 6.13511 6.17891 6.21895 6.25348 6.27921 6.28504 6.28408 6.27252 6.25528 6.24258 6.23305 6.22838 6.23336 6.24431 6.26234 6.28263 6.2999 6.31069 6.31486 6.31629 6.31716 6.32009 6.32318 6.32789 6.3316 6.33485 6.33665 6.33955 49.9434 8.34431 6.0741 6.08557 6.07029 6.05503 6.02812 6.00406 5.9916 6.00091 6.03032 6.07159 6.1173 6.16401 6.20876 6.24774 6.27782 6.28825 6.29072 6.27982 6.26085 6.24443 6.22971 6.222 6.22707 6.24154 6.26329 6.28504 6.30135 6.30961 6.31125 6.31097 6.3128 6.31906 6.3267 6.33767 6.34799 6.3547 6.3581 6.35686 49.97 8.32008 6.07117 6.08683 6.07624 6.0641 6.03846 6.01417 5.9985 6.00106 6.02428 6.062 6.10683 6.15408 6.20053 6.24071 6.27211 6.28683 6.29264 6.28405 6.26484 6.24511 6.22672 6.21869 6.2235 6.24031 6.26326 6.28482 6.29948 6.30537 6.30657 6.30714 6.31158 6.32213 6.33485 6.35241 6.36777 6.37654 6.37695 6.37136 49.9954 8.30927 6.06841 6.08286 6.07663 6.06812 6.045 6.02168 6.00529 6.00454 6.02434 6.05942 6.10341 6.1499 6.19382 6.23198 6.2616 6.27967 6.28828 6.28262 6.26419 6.24287 6.22407 6.21776 6.22333 6.24126 6.26377 6.28358 6.29563 6.30089 6.30296 6.30673 6.31559 6.33117 6.34917 6.37108 6.38727 6.39248 6.38953 6.38059 50.0221 8.30565 6.06707 6.07772 6.07327 6.06747 6.048 6.02706 6.01132 6.01004 6.02826 6.06362 6.10688 6.14917 6.18701 6.2206 6.24669 6.26612 6.27714 6.27471 6.25815 6.23724 6.22165 6.21735 6.22613 6.24488 6.26562 6.28181 6.29165 6.29748 6.30293 6.3118 6.32653 6.34518 6.36781 6.38875 6.39996 6.40058 6.3944 6.38456 50.0477 8.30534 6.0669 6.07373 6.06921 6.06498 6.04918 6.03167 6.01783 6.01796 6.03695 6.07143 6.11126 6.14775 6.17846 6.2061 6.22761 6.24678 6.25994 6.26119 6.24669 6.2286 6.2182 6.21809 6.2315 6.25079 6.26789 6.27984 6.28893 6.2972 6.30802 6.32286 6.34313 6.36293 6.38506 6.39948 6.40466 6.40121 6.39277 6.3831 50.0709 8.30632 6.06782 6.07228 6.06702 6.06372 6.05151 6.03725 6.02611 6.02839 6.04783 6.0795 6.11426 6.14476 6.16952 6.19008 6.20659 6.22375 6.23803 6.24316 6.23081 6.21832 6.21328 6.22151 6.2393 6.25694 6.27001 6.27939 6.2894 6.30201 6.31865 6.33889 6.35815 6.37908 6.39486 6.4025 6.40223 6.39583 6.38688 6.3789 50.0905 8.30757 6.07003 6.07463 6.06873 6.06594 6.05643 6.04483 6.03618 6.03935 6.05725 6.08547 6.11513 6.14154 6.15976 6.17411 6.18596 6.1997 6.21346 6.22016 6.21208 6.2085 6.2116 6.22799 6.24736 6.26238 6.27149 6.28077 6.29358 6.31162 6.33357 6.35293 6.37206 6.38807 6.39706 6.39839 6.39383 6.38628 6.3786 6.37435 50.1066 8.30857 6.07284 6.08061 6.07474 6.07234 6.0639 6.05543 6.04724 6.04913 6.06374 6.08795 6.1145 6.13535 6.1495 6.16018 6.16823 6.17723 6.18763 6.19459 6.19428 6.2009 6.21418 6.23615 6.25434 6.26622 6.2741 6.28453 6.30158 6.32433 6.34613 6.36542 6.38086 6.39014 6.39215 6.3881 6.38146 6.37427 6.37004 6.37126 50.1107 8.30798 6.0751 6.08839 6.08392 6.08224 6.07486 6.06736 6.05864 6.0578 6.06821 6.08837 6.11007 6.12788 6.14063 6.14919 6.1536 6.15742 6.16306 6.17027 6.1811 6.19633 6.21831 6.24345 6.25926 6.26865 6.27725 6.29091 6.31285 6.33668 6.3578 6.37459 6.38373 6.38577 6.38118 6.37366 6.36642 6.36167 6.36338 6.37122 50.1116 8.30722 6.07695 6.09607 6.09478 6.09371 6.08742 6.08029 6.07085 6.06733 6.07225 6.0867 6.10492 6.12097 6.1331 6.14026 6.1416 6.14072 6.14256 6.14974 6.16995 6.19378 6.2228 6.24819 6.2619 6.27025 6.28047 6.29824 6.32459 6.3485 6.36799 6.37902 6.38101 6.37577 6.36618 6.35728 6.35064 6.35034 6.35924 6.37266 50.1093 8.30834 6.07952 6.10261 6.10485 6.10428 6.09988 6.09383 6.08502 6.07757 6.07659 6.08549 6.10026 6.11442 6.12534 6.13105 6.13003 6.12791 6.12848 6.13732 6.1627 6.19235 6.2252 6.24976 6.26242 6.27149 6.28415 6.3058 6.33355 6.35693 6.37349 6.37871 6.37444 6.36371 6.35123 6.34121 6.33706 6.34205 6.35784 6.37492 50.1074 8.31194 6.08435 6.10799 6.11075 6.11152 6.11059 6.10796 6.09979 6.09046 6.0843 6.08601 6.09501 6.10561 6.11435 6.11903 6.11867 6.11925 6.12108 6.1325 6.15916 6.19099 6.22488 6.24896 6.26211 6.2731 6.28869 6.31302 6.33906 6.36057 6.37307 6.37353 6.36519 6.35171 6.33793 6.32869 6.32704 6.33605 6.35653 6.37936 50.1072 8.31712 6.09187 6.11261 6.11359 6.11632 6.11962 6.12074 6.11556 6.1055 6.09408 6.08719 6.08769 6.09308 6.09938 6.10513 6.10903 6.11514 6.12045 6.13335 6.15973 6.1894 6.22184 6.24595 6.26118 6.27524 6.29354 6.31846 6.34119 6.35903 6.3671 6.36368 6.35491 6.34137 6.32952 6.32185 6.32183 6.33384 6.3581 6.38291 50.1086 8.32163 6.10059 6.11739 6.11598 6.12052 6.12711 6.13257 6.13039 6.11969 6.10299 6.08719 6.07871 6.0781 6.08272 6.09143 6.10166 6.11503 6.12548 6.13827 6.1622 6.18913 6.21754 6.24193 6.26008 6.27784 6.29819 6.3217 6.34006 6.35278 6.35647 6.35196 6.34517 6.33447 6.32568 6.31991 6.32124 6.33495 6.36005 6.38365 50.1107 8.32383 6.10893 6.12223 6.11872 6.12473 6.13432 6.14314 6.14254 6.13057 6.10946 6.08656 6.07032 6.0641 6.06748 6.07991 6.09716 6.11732 6.13229 6.14518 6.16459 6.18743 6.2131 6.23897 6.25995 6.28051 6.30188 6.32217 6.33546 6.34274 6.34357 6.34129 6.3368 6.3307 6.3257 6.32297 6.32587 6.33954 6.36126 6.38033 50.11 8.32269 6.11576 6.12706 6.12236 6.12997 6.14185 6.1524 6.15162 6.13757 6.1131 6.08608 6.06418 6.05331 6.05565 6.0717 6.09546 6.12048 6.13875 6.15143 6.16614 6.18548 6.20937 6.23646 6.26131 6.28366 6.30431 6.32032 6.3285 6.33112 6.33056 6.33163 6.33076 6.32948 6.32915 6.32976 6.33395 6.34546 6.361 6.37324 50.114 8.319 6.12043 6.13073 6.12722 6.13719 6.15013 6.16031 6.1575 6.14097 6.11429 6.08535 6.06032 6.04641 6.04808 6.06693 6.09604 6.1236 6.1431 6.15563 6.16642 6.18222 6.20806 6.23627 6.26462 6.28851 6.30676 6.31761 6.32069 6.31971 6.31952 6.32258 6.32542 6.32923 6.33356 6.33761 6.34286 6.35041 6.35807 6.36233 50.1173 8.31246 6.123 6.13389 6.13296 6.14541 6.15845 6.1667 6.16077 6.14152 6.11373 6.08387 6.05823 6.04238 6.04418 6.06493 6.09741 6.12603 6.14543 6.15739 6.16595 6.18055 6.20748 6.23808 6.26905 6.29398 6.31074 6.31692 6.31482 6.31085 6.30987 6.31319 6.31937 6.32822 6.33719 6.34494 6.35027 6.3531 6.35463 6.35072 50.1192 8.30473 6.12311 6.13634 6.13867 6.15347 6.16602 6.17146 6.16219 6.14024 6.11113 6.08171 6.05652 6.04088 6.04297 6.06484 6.09892 6.12789 6.14682 6.15773 6.16489 6.18037 6.20651 6.23955 6.2731 6.30004 6.31626 6.31975 6.31435 6.30543 6.3009 6.30292 6.31188 6.32542 6.33889 6.3499 6.35492 6.35447 6.35021 6.34125 50.1189 8.29681 6.12204 6.13861 6.14414 6.16067 6.17226 6.175 6.16278 6.13861 6.1085 6.07924 6.05483 6.04076 6.04361 6.06609 6.10012 6.12864 6.14711 6.15725 6.16348 6.17982 6.20494 6.23988 6.27566 6.30563 6.32273 6.32475 6.31714 6.30289 6.29335 6.29355 6.30434 6.32133 6.33949 6.35287 6.35723 6.35465 6.34673 6.33425 50.1185 8.2916 6.12041 6.13868 6.14816 6.16596 6.17678 6.17705 6.16215 6.13653 6.10621 6.07739 6.05389 6.0407 6.04469 6.06777 6.10103 6.129 6.14681 6.15655 6.16251 6.1791 6.20395 6.23979 6.27685 6.30992 6.32848 6.32949 6.31898 6.29995 6.28689 6.28596 6.2975 6.31613 6.3378 6.35284 6.3577 6.35478 6.34475 6.33013 50.1185 8.28738 6.12024 6.1401 6.15002 6.16874 6.17922 6.17813 6.16193 6.13564 6.10524 6.07728 6.05436 6.04151 6.04565 6.06876 6.10123 6.12864 6.14627 6.15584 6.16151 6.17735 6.20169 6.23845 6.27645 6.312 6.33216 6.3334 6.32246 6.30153 6.28694 6.28476 6.29577 6.31452 6.33752 6.35301 6.35751 6.35432 6.34319 6.32745 6.33999 6.31367 6.30143 6.30218 6.31607 6.33641 6.35911 6.38196 6.40518 6.42623 6.43978 6.44048 6.44163 6.43978 6.43668 6.43658 6.44443 6.45586 6.46009 6.45094 6.42562 6.3852 6.35164 6.33851 6.34066 6.35775 6.38473 6.40324 6.40939 6.41212 6.41367 6.41681 6.41494 6.39734 6.35168 6.29116 6.25628 6.25893 6.29036 6.33127 6.35678 6.3476 6.30706 6.24718 6.19932 6.18738 6.21021 6.26754 6.33029 6.36615 6.36851 6.32407 6.25662 6.21686 6.20925 6.24241 6.31206 6.38006 6.42685 6.45326 6.45987 6.45303 6.43526 6.40438 6.3848 6.37774 6.40205 6.48235 6.57996 6.64567 6.67854 6.67762 6.63652 6.57339 6.52139 6.49235 6.48124 6.48987 6.51434 6.52697 6.32885 6.30953 6.3024 6.30762 6.32378 6.345 6.36706 6.38985 6.4133 6.43333 6.44242 6.4413 6.44158 6.43832 6.43501 6.43606 6.4425 6.44893 6.44951 6.43767 6.41352 6.37988 6.35543 6.34761 6.35221 6.36794 6.3895 6.40344 6.40922 6.41255 6.41573 6.41604 6.4076 6.38285 6.33604 6.28021 6.25465 6.26259 6.29387 6.3288 6.34621 6.33216 6.28964 6.24206 6.20848 6.20648 6.2369 6.29139 6.33968 6.36498 6.35797 6.31398 6.26016 6.23183 6.24064 6.27704 6.33025 6.3832 6.42155 6.4415 6.44501 6.43416 6.41799 6.40761 6.40062 6.4075 6.45616 6.52298 6.58797 6.63998 6.65912 6.63902 6.60151 6.55273 6.51356 6.49336 6.49087 6.50238 6.52533 6.53934 6.32594 6.3124 6.30631 6.31149 6.32723 6.34791 6.37091 6.39571 6.42091 6.44084 6.44792 6.44628 6.44243 6.4345 6.42975 6.43122 6.43628 6.44079 6.43992 6.4274 6.40556 6.37979 6.36271 6.35693 6.36079 6.3753 6.39291 6.40232 6.41141 6.41764 6.42003 6.41799 6.40478 6.3758 6.32883 6.2764 6.25797 6.26603 6.28741 6.31355 6.32538 6.31265 6.28197 6.253 6.23702 6.24157 6.26891 6.30253 6.33433 6.35136 6.34219 6.31561 6.28319 6.27081 6.28296 6.31057 6.34072 6.37062 6.39738 6.41133 6.4133 6.40869 6.40553 6.41119 6.4277 6.46989 6.51355 6.54328 6.57635 6.60814 6.60938 6.59224 6.56657 6.53998 6.51669 6.50366 6.50747 6.51986 6.53667 6.55082 6.32326 6.31621 6.31389 6.31811 6.33245 6.35312 6.37935 6.40683 6.43249 6.44948 6.45252 6.44725 6.43846 6.42861 6.42324 6.42333 6.42682 6.42859 6.42548 6.41417 6.39844 6.38292 6.37388 6.37026 6.37428 6.38502 6.39353 6.40389 6.41378 6.4208 6.42094 6.4127 6.39525 6.36424 6.32185 6.27911 6.26435 6.26848 6.27799 6.29103 6.29767 6.29179 6.27738 6.26548 6.27463 6.28602 6.29706 6.30877 6.3215 6.33056 6.3313 6.33057 6.32666 6.32434 6.32588 6.33652 6.35317 6.36631 6.37482 6.37473 6.37283 6.37872 6.39702 6.43126 6.48785 6.53633 6.55476 6.55899 6.56076 6.55405 6.54878 6.54371 6.53474 6.52681 6.51944 6.51903 6.52627 6.53825 6.54909 6.55845 6.32245 6.32172 6.32417 6.32812 6.34137 6.36205 6.38933 6.41754 6.44137 6.45345 6.45295 6.44503 6.43287 6.42073 6.41333 6.41238 6.41369 6.41428 6.41043 6.40272 6.39473 6.38677 6.38494 6.38404 6.38858 6.39392 6.39856 6.4069 6.41348 6.41738 6.41349 6.40087 6.3805 6.35225 6.32016 6.28952 6.27305 6.26958 6.26851 6.26518 6.26802 6.27258 6.27875 6.29866 6.32098 6.32313 6.31342 6.30595 6.30086 6.31036 6.32818 6.3568 6.3802 6.37923 6.36856 6.36266 6.36011 6.35674 6.35055 6.34216 6.34072 6.35405 6.39372 6.46407 6.53542 6.57245 6.57393 6.55525 6.51847 6.49083 6.49004 6.50051 6.51079 6.51852 6.52563 6.53536 6.5453 6.55217 6.55556 6.56168 6.32373 6.33176 6.33712 6.34273 6.35445 6.37301 6.39802 6.42418 6.44449 6.45252 6.45016 6.44074 6.42713 6.41302 6.40361 6.39951 6.39809 6.39777 6.39671 6.39599 6.3957 6.39532 6.39797 6.39941 6.40365 6.40437 6.4065 6.40853 6.4084 6.4064 6.3981 6.38237 6.362 6.34166 6.32369 6.30381 6.28308 6.26855 6.25572 6.24443 6.24364 6.25916 6.29125 6.33298 6.34991 6.34353 6.31764 6.29321 6.28101 6.29602 6.33599 6.39414 6.42779 6.42653 6.40022 6.37439 6.3579 6.34426 6.33349 6.32704 6.33153 6.3481 6.40303 6.48581 6.54804 6.56993 6.56225 6.516 6.45863 6.43342 6.44326 6.46959 6.49276 6.51559 6.53505 6.54815 6.55628 6.55933 6.55659 6.56034 6.32836 6.34438 6.35418 6.36125 6.36901 6.38183 6.40103 6.42307 6.44067 6.44823 6.44683 6.43873 6.42453 6.4084 6.39537 6.38675 6.38238 6.38185 6.38634 6.39423 6.40136 6.40721 6.41227 6.41486 6.4167 6.41601 6.41334 6.40674 6.39714 6.38695 6.3759 6.35999 6.34568 6.3379 6.33207 6.3173 6.29155 6.2664 6.24502 6.23295 6.23084 6.25671 6.31036 6.3507 6.36127 6.34825 6.31163 6.27689 6.2691 6.29115 6.35556 6.42609 6.46063 6.46065 6.42679 6.38386 6.35378 6.33502 6.32689 6.32521 6.33905 6.37402 6.42694 6.48254 6.52228 6.53198 6.50407 6.4482 6.40135 6.38956 6.40636 6.44252 6.48634 6.52039 6.54375 6.55355 6.55197 6.55259 6.55033 6.55373 6.3386 6.35976 6.37396 6.38192 6.38403 6.38824 6.39877 6.41534 6.43216 6.44294 6.44562 6.43951 6.42548 6.40598 6.38826 6.37514 6.36921 6.37139 6.38279 6.39874 6.41251 6.42233 6.42731 6.42975 6.42999 6.42606 6.41696 6.40057 6.37862 6.35997 6.34804 6.33872 6.33666 6.34071 6.34275 6.3275 6.29615 6.26338 6.24123 6.22958 6.23728 6.27438 6.32085 6.34879 6.35437 6.33622 6.29541 6.26723 6.26611 6.29644 6.37266 6.44448 6.4798 6.4844 6.44961 6.39307 6.3521 6.3329 6.32603 6.33508 6.3661 6.41465 6.44725 6.46707 6.47701 6.45821 6.41437 6.37396 6.35221 6.35045 6.37395 6.42677 6.48343 6.52295 6.5416 6.54187 6.53394 6.53486 6.53821 6.5444 6.35149 6.37715 6.39428 6.40246 6.39951 6.39422 6.39424 6.4051 6.42301 6.43935 6.44691 6.44286 6.42703 6.40329 6.38133 6.36605 6.3613 6.36887 6.38609 6.40648 6.42564 6.43748 6.44184 6.44353 6.44124 6.43239 6.41504 6.38845 6.35603 6.33285 6.32242 6.32347 6.33554 6.34926 6.35233 6.33371 6.29826 6.26258 6.2439 6.23943 6.26193 6.29455 6.31825 6.33384 6.33253 6.31052 6.28218 6.26543 6.27339 6.31178 6.37804 6.44729 6.48098 6.48326 6.45757 6.40173 6.35434 6.33494 6.33313 6.35325 6.40847 6.45008 6.46617 6.45515 6.42093 6.36282 6.3205 6.30284 6.3038 6.3194 6.35307 6.41034 6.47354 6.51452 6.52714 6.51838 6.51342 6.51718 6.52346 6.53128 6.36139 6.39097 6.41118 6.42035 6.41457 6.40136 6.39203 6.39721 6.41657 6.43806 6.44901 6.44524 6.42648 6.39895 6.37491 6.36079 6.3594 6.37043 6.39273 6.416 6.43685 6.44973 6.4548 6.45412 6.44812 6.43348 6.40805 6.37288 6.33604 6.31143 6.30528 6.3169 6.33926 6.35711 6.359 6.33624 6.29769 6.26279 6.25292 6.2647 6.28973 6.30651 6.31413 6.31642 6.30242 6.28315 6.27458 6.27378 6.29094 6.32555 6.37138 6.43054 6.46214 6.46667 6.45299 6.40802 6.36084 6.34373 6.34605 6.38591 6.4436 6.47123 6.46948 6.43111 6.35371 6.28546 6.25333 6.24991 6.26539 6.29322 6.33697 6.38906 6.44763 6.4881 6.49846 6.49583 6.49456 6.49959 6.50728 6.5158 6.36409 6.39814 6.42211 6.4328 6.42754 6.41034 6.39597 6.3962 6.41441 6.43752 6.44879 6.44326 6.42085 6.3916 6.36975 6.35979 6.36229 6.37816 6.40261 6.42699 6.44377 6.45676 6.46201 6.45884 6.44818 6.42851 6.39774 6.35721 6.32124 6.30052 6.2985 6.31733 6.34435 6.3591 6.35793 6.3341 6.29757 6.26878 6.27452 6.29388 6.30778 6.31535 6.30943 6.29136 6.27272 6.26464 6.27013 6.2918 6.31156 6.33167 6.35665 6.39548 6.42951 6.4424 6.44016 6.4153 6.37364 6.35771 6.37356 6.41509 6.45881 6.47678 6.45843 6.3954 6.31003 6.24595 6.21992 6.21886 6.2388 6.28196 6.33163 6.36809 6.40163 6.43715 6.45921 6.46818 6.47124 6.477 6.48513 6.49384 6.36011 6.39842 6.42718 6.44048 6.43708 6.41964 6.40511 6.40237 6.41631 6.43607 6.44429 6.43599 6.41135 6.383 6.36602 6.36188 6.3687 6.38749 6.41297 6.43468 6.44518 6.45749 6.46248 6.45695 6.44218 6.41868 6.38508 6.3477 6.31624 6.29962 6.30459 6.32602 6.34583 6.3526 6.34752 6.32829 6.29885 6.285 6.2991 6.31329 6.31987 6.31546 6.29567 6.26863 6.25581 6.25998 6.28208 6.31098 6.32574 6.33065 6.33751 6.34825 6.38102 6.40944 6.42102 6.41785 6.39285 6.385 6.39978 6.4267 6.45018 6.45615 6.4233 6.36629 6.29994 6.24276 6.21744 6.22107 6.24997 6.29824 6.33933 6.35877 6.35984 6.37046 6.39746 6.42749 6.44694 6.46035 6.47398 6.4863 6.35298 6.39365 6.42681 6.44413 6.4428 6.42796 6.41622 6.41177 6.42011 6.43307 6.43606 6.42495 6.40068 6.37588 6.36488 6.36555 6.37582 6.39733 6.42124 6.43829 6.4435 6.45275 6.4565 6.4489 6.43148 6.40617 6.37622 6.34775 6.32288 6.3132 6.32164 6.33578 6.34057 6.34018 6.33214 6.32041 6.30477 6.30691 6.31606 6.32282 6.32398 6.30741 6.27718 6.25611 6.25141 6.26904 6.30351 6.32675 6.33439 6.32395 6.30908 6.30378 6.32692 6.36965 6.39768 6.41365 6.41966 6.42091 6.42089 6.42292 6.42492 6.40774 6.38239 6.35246 6.3171 6.2722 6.25145 6.26237 6.29533 6.33249 6.35454 6.35439 6.33856 6.32416 6.33334 6.36816 6.40852 6.44133 6.46982 6.49067 6.34551 6.38684 6.42259 6.4427 6.44455 6.43494 6.42619 6.42132 6.42334 6.4293 6.42673 6.41312 6.39131 6.37087 6.36553 6.37015 6.38351 6.40364 6.42364 6.43765 6.43986 6.44457 6.44408 6.43471 6.41761 6.39582 6.37417 6.35528 6.34184 6.33712 6.33698 6.33962 6.33532 6.32651 6.31949 6.31695 6.31874 6.32191 6.32089 6.32134 6.31226 6.28738 6.26504 6.25482 6.26195 6.29026 6.32201 6.33768 6.33404 6.31096 6.28007 6.26892 6.28019 6.32436 6.37459 6.41695 6.45164 6.45719 6.43991 6.4192 6.37916 6.35226 6.34762 6.35064 6.35268 6.33563 6.32519 6.33311 6.35048 6.36384 6.36627 6.35426 6.33355 6.31583 6.31178 6.32838 6.3669 6.41479 6.45831 6.48692 6.34003 6.37994 6.41602 6.43686 6.44122 6.43811 6.43217 6.42797 6.42519 6.42625 6.41918 6.40288 6.38421 6.36669 6.36449 6.3703 6.38439 6.40314 6.42196 6.43359 6.43493 6.43581 6.42974 6.41871 6.40537 6.3913 6.38019 6.37491 6.3688 6.35832 6.34657 6.33806 6.32899 6.31779 6.3169 6.32511 6.33142 6.32545 6.31482 6.30668 6.28703 6.26733 6.25864 6.25746 6.27804 6.31238 6.33375 6.34165 6.33142 6.2964 6.26027 6.24523 6.24778 6.28117 6.35511 6.42988 6.47948 6.4875 6.45802 6.39746 6.335 6.30787 6.31782 6.34385 6.37246 6.41026 6.42662 6.42049 6.40901 6.39869 6.38083 6.35704 6.33674 6.32536 6.32305 6.33486 6.36586 6.40791 6.44624 6.47263 6.33836 6.37331 6.40676 6.42721 6.43381 6.43635 6.4333 6.43086 6.42629 6.42455 6.41458 6.39615 6.37831 6.36235 6.36058 6.36596 6.37979 6.39867 6.41835 6.42988 6.43193 6.42842 6.41791 6.4058 6.39712 6.39298 6.39497 6.39738 6.39075 6.37195 6.35151 6.3356 6.32361 6.31738 6.32689 6.3389 6.33586 6.31978 6.29887 6.27908 6.25718 6.2492 6.25176 6.26729 6.29956 6.32787 6.34095 6.34073 6.32403 6.28828 6.25031 6.22927 6.22772 6.25289 6.34007 6.44325 6.498 6.50842 6.46883 6.37984 6.30661 6.27799 6.29488 6.34889 6.42589 6.49414 6.51523 6.49459 6.45606 6.41633 6.38261 6.36013 6.34994 6.34519 6.35109 6.3695 6.39584 6.4224 6.44442 6.46205 6.34179 6.36892 6.39639 6.41503 6.42397 6.43147 6.43265 6.43219 6.42765 6.42457 6.41195 6.39132 6.37195 6.35666 6.35348 6.35816 6.3734 6.39479 6.41719 6.42747 6.43049 6.42459 6.41183 6.39924 6.39368 6.39885 6.40986 6.41406 6.40236 6.37635 6.35075 6.33316 6.32338 6.32533 6.3407 6.34943 6.33649 6.30938 6.27702 6.24834 6.23398 6.23856 6.25284 6.2825 6.31287 6.33402 6.33999 6.33407 6.31806 6.29025 6.2522 6.22809 6.22459 6.25253 6.33286 6.44187 6.50234 6.51236 6.4677 6.37521 6.29883 6.27162 6.28551 6.36046 6.46989 6.53975 6.56044 6.53783 6.48676 6.42872 6.3888 6.37236 6.36965 6.37608 6.3914 6.41182 6.42919 6.44094 6.44847 6.45923 6.35007 6.36751 6.38671 6.40369 6.41481 6.42556 6.43138 6.43284 6.42889 6.42459 6.40914 6.38547 6.36419 6.34926 6.34449 6.34944 6.36737 6.39173 6.41551 6.42725 6.43078 6.4241 6.41119 6.39966 6.39699 6.40703 6.4176 6.41838 6.40243 6.37475 6.34663 6.33248 6.32967 6.34114 6.35253 6.35126 6.33157 6.29491 6.25356 6.22859 6.22339 6.23544 6.26472 6.29442 6.31414 6.32627 6.32786 6.32259 6.31475 6.30127 6.26781 6.24381 6.24454 6.27541 6.33555 6.42265 6.48478 6.49122 6.45411 6.38282 6.31286 6.28832 6.31289 6.38389 6.48075 6.54426 6.5618 6.54699 6.49972 6.44283 6.40497 6.3933 6.39877 6.41535 6.43482 6.44968 6.46049 6.46713 6.47052 6.47919 6.36013 6.36798 6.37927 6.39243 6.40421 6.41727 6.42714 6.43194 6.42904 6.42187 6.40303 6.3766 6.35497 6.34098 6.33632 6.34381 6.36442 6.39185 6.4171 6.42944 6.43198 6.42511 6.41353 6.40514 6.40523 6.41238 6.416 6.41145 6.39405 6.3674 6.34228 6.33665 6.34375 6.35675 6.3589 6.34709 6.31998 6.27772 6.24018 6.2246 6.22918 6.2538 6.2838 6.30044 6.30681 6.30813 6.30701 6.30818 6.30969 6.30735 6.29573 6.28222 6.28608 6.30732 6.33989 6.38494 6.43563 6.44991 6.4355 6.40359 6.35379 6.33627 6.36034 6.40452 6.45732 6.51201 6.53025 6.51694 6.49106 6.45888 6.43153 6.425 6.43654 6.45697 6.47436 6.4837 6.48359 6.48117 6.47832 6.48471 6.36898 6.36888 6.37294 6.38261 6.3951 6.41006 6.42295 6.42913 6.42714 6.41499 6.39228 6.36452 6.34463 6.33367 6.3329 6.34529 6.36942 6.39735 6.41925 6.43017 6.43115 6.42491 6.416 6.41035 6.41036 6.41284 6.40909 6.39903 6.38126 6.35844 6.34214 6.34568 6.35759 6.3658 6.35912 6.33792 6.30429 6.26657 6.23856 6.23244 6.25419 6.28385 6.30358 6.30437 6.29472 6.28103 6.27719 6.28655 6.30313 6.31694 6.3319 6.3452 6.34446 6.33955 6.3421 6.34265 6.35834 6.39087 6.41283 6.41867 6.41456 6.40943 6.4099 6.41451 6.42354 6.44546 6.46816 6.47722 6.48045 6.4759 6.4677 6.46759 6.47879 6.49267 6.50266 6.50324 6.49772 6.49315 6.48837 6.49422 6.3751 6.36887 6.3675 6.37468 6.38802 6.40426 6.4183 6.42502 6.42043 6.404 6.37798 6.35103 6.33463 6.32963 6.3362 6.35439 6.37994 6.40466 6.41975 6.42684 6.42665 6.42189 6.41657 6.41375 6.413 6.41212 6.40484 6.38835 6.37049 6.3508 6.34472 6.35496 6.36421 6.36732 6.357 6.32616 6.29027 6.26194 6.24532 6.25254 6.28766 6.31363 6.32296 6.31246 6.28443 6.25453 6.2433 6.25527 6.28857 6.33109 6.38048 6.41086 6.40354 6.37631 6.33903 6.29639 6.28322 6.32331 6.38359 6.43457 6.48084 6.48433 6.45845 6.42947 6.39739 6.38089 6.39601 6.42899 6.45718 6.48135 6.50006 6.51146 6.51563 6.51734 6.51573 6.51083 6.50702 6.50469 6.50138 6.50756 6.37709 6.36807 6.36306 6.36939 6.38382 6.39965 6.41255 6.41798 6.40983 6.38952 6.36221 6.33836 6.327 6.32992 6.34454 6.36801 6.393 6.41059 6.41771 6.41944 6.41785 6.41535 6.41416 6.41426 6.41327 6.40879 6.3985 6.38154 6.36604 6.35144 6.35117 6.35947 6.36391 6.36586 6.34885 6.31621 6.28283 6.26264 6.25879 6.28249 6.31719 6.33747 6.33775 6.31843 6.27862 6.24042 6.21935 6.22644 6.2683 6.34663 6.42206 6.45597 6.4491 6.40279 6.32222 6.25496 6.23285 6.26355 6.35015 6.45768 6.52723 6.53958 6.49509 6.42526 6.36413 6.33429 6.34095 6.38483 6.44536 6.49753 6.53338 6.54571 6.54023 6.52961 6.51795 6.51093 6.50846 6.50936 6.5103 6.51809 6.37573 6.36657 6.36133 6.36752 6.38099 6.39468 6.40475 6.40768 6.39688 6.37352 6.34777 6.32824 6.32281 6.33333 6.35507 6.38166 6.40331 6.41318 6.41381 6.40971 6.40606 6.40568 6.40782 6.41034 6.41029 6.40519 6.39558 6.38159 6.37073 6.36062 6.35758 6.35847 6.36186 6.35803 6.33763 6.3107 6.28348 6.27046 6.27693 6.30455 6.33397 6.35059 6.34757 6.32124 6.27348 6.23016 6.21166 6.21956 6.26315 6.35609 6.44498 6.48085 6.47447 6.41937 6.31389 6.23428 6.21182 6.23113 6.31914 6.45972 6.54272 6.55835 6.51987 6.42672 6.34928 6.31674 6.32038 6.35668 6.43366 6.50669 6.55056 6.56397 6.55435 6.53433 6.51638 6.50826 6.50626 6.50979 6.51594 6.52625 6.37339 6.36558 6.36353 6.36914 6.37775 6.38842 6.39454 6.39427 6.38177 6.35926 6.33693 6.32264 6.32318 6.33902 6.36505 6.39234 6.40914 6.4131 6.40863 6.40006 6.39395 6.39377 6.39746 6.40156 6.40374 6.40264 6.39806 6.38915 6.38407 6.37438 6.36215 6.35583 6.35427 6.34627 6.32969 6.31112 6.29265 6.2854 6.28917 6.31055 6.33546 6.34899 6.34167 6.31574 6.27324 6.23248 6.21682 6.23274 6.27953 6.35532 6.43706 6.47355 6.46293 6.40693 6.31798 6.24377 6.22106 6.24255 6.31472 6.43076 6.52104 6.54125 6.50748 6.43273 6.35789 6.32688 6.33126 6.36541 6.43199 6.50335 6.54918 6.56356 6.55583 6.53432 6.51697 6.51071 6.51231 6.51979 6.52939 6.54114 6.37221 6.36711 6.36877 6.37223 6.37608 6.38061 6.38174 6.3782 6.36518 6.34864 6.33109 6.32296 6.32789 6.34559 6.37223 6.39772 6.41057 6.41139 6.40326 6.39281 6.38372 6.38133 6.38467 6.39071 6.39736 6.40257 6.40548 6.40507 6.40076 6.38647 6.36642 6.35116 6.34349 6.33608 6.32855 6.31619 6.30732 6.29923 6.29257 6.30066 6.31949 6.32922 6.32409 6.30412 6.27754 6.25187 6.24374 6.26341 6.30257 6.34592 6.40159 6.43043 6.41592 6.37964 6.33265 6.28115 6.26319 6.2885 6.32959 6.38478 6.46009 6.48737 6.47594 6.44343 6.38888 6.36226 6.36843 6.39793 6.43933 6.48807 6.52857 6.54532 6.54292 6.53238 6.52399 6.52233 6.5288 6.53929 6.54881 6.56075 6.37261 6.37328 6.37583 6.378 6.37411 6.36911 6.36576 6.36033 6.34992 6.34028 6.33005 6.32767 6.33478 6.35124 6.37533 6.39804 6.4088 6.40868 6.39968 6.3882 6.37597 6.37024 6.37173 6.37908 6.39142 6.40561 6.41878 6.4242 6.4177 6.39808 6.37029 6.34837 6.33472 6.32985 6.32507 6.32464 6.32134 6.31027 6.29412 6.28711 6.29084 6.29694 6.29921 6.29362 6.28783 6.2908 6.29725 6.30975 6.32807 6.3441 6.34888 6.35542 6.35751 6.35389 6.35067 6.3435 6.33983 6.34319 6.34496 6.3452 6.3651 6.40633 6.4339 6.44627 6.44139 6.42638 6.42495 6.43612 6.45112 6.46762 6.48939 6.51164 6.52544 6.5342 6.53956 6.54891 6.55967 6.56907 6.57473 6.58507 6.37629 6.38221 6.38553 6.38274 6.37057 6.35519 6.34675 6.34139 6.33698 6.33442 6.33297 6.33551 6.34291 6.35591 6.37477 6.39383 6.40415 6.40487 6.39743 6.38585 6.37164 6.36259 6.36311 6.37323 6.39234 6.41442 6.43237 6.43918 6.43136 6.40816 6.37587 6.34835 6.32989 6.32431 6.32717 6.33187 6.33117 6.31675 6.29424 6.27613 6.26074 6.26106 6.27126 6.28143 6.3006 6.33682 6.35942 6.35859 6.35112 6.33065 6.2891 6.27092 6.28955 6.32143 6.35858 6.41131 6.42574 6.40005 6.36109 6.31098 6.28434 6.31714 6.38377 6.43969 6.48142 6.4973 6.48843 6.47484 6.46194 6.45105 6.45293 6.47202 6.50094 6.52621 6.54911 6.57049 6.58818 6.59764 6.59943 6.60845 6.38304 6.3926 6.39489 6.38528 6.36413 6.33961 6.32617 6.32164 6.32503 6.33028 6.33703 6.34419 6.35089 6.3591 6.37142 6.38609 6.39673 6.39952 6.39498 6.38486 6.37201 6.36112 6.35986 6.37222 6.39643 6.4222 6.4404 6.44693 6.4391 6.41524 6.3811 6.34964 6.32859 6.32316 6.32926 6.33604 6.33452 6.3199 6.29446 6.26544 6.24177 6.23589 6.24878 6.27953 6.32987 6.38182 6.40468 6.3981 6.36614 6.30304 6.23571 6.21072 6.23171 6.29283 6.38868 6.46774 6.48835 6.44729 6.36094 6.274 6.23394 6.24805 6.32863 6.4399 6.51561 6.55029 6.54322 6.50582 6.46284 6.43666 6.42974 6.44235 6.47688 6.52343 6.56484 6.59245 6.60875 6.61586 6.61558 6.62303 6.39159 6.40113 6.40117 6.38442 6.35512 6.32202 6.30565 6.30326 6.3122 6.32645 6.34066 6.35137 6.35783 6.36149 6.36675 6.37618 6.3865 6.39209 6.39178 6.38551 6.37743 6.36894 6.36749 6.37828 6.39946 6.42362 6.4414 6.44982 6.44344 6.42035 6.38718 6.35429 6.33465 6.32943 6.33354 6.33852 6.33474 6.3194 6.29221 6.26027 6.23817 6.23187 6.24134 6.28666 6.35962 6.40716 6.42638 6.42174 6.36861 6.27431 6.20544 6.18416 6.19486 6.27177 6.40484 6.48809 6.50719 6.47097 6.36242 6.25899 6.21746 6.22579 6.28849 6.42111 6.52523 6.56676 6.56515 6.52595 6.47091 6.43571 6.42534 6.43466 6.46165 6.51128 6.5616 6.59538 6.61413 6.61978 6.6162 6.62198 6.39882 6.4072 6.40244 6.37972 6.34286 6.30436 6.284 6.28533 6.30017 6.32156 6.34192 6.35573 6.36261 6.36337 6.36236 6.36522 6.37355 6.38246 6.38789 6.3894 6.39024 6.38743 6.38437 6.38726 6.39883 6.41677 6.4343 6.44503 6.44215 6.42267 6.39482 6.36634 6.34929 6.34199 6.33979 6.3387 6.33228 6.31468 6.28835 6.26353 6.24668 6.24558 6.26993 6.31506 6.37114 6.41273 6.42657 6.40815 6.34953 6.26193 6.19964 6.18107 6.19954 6.2763 6.39063 6.47037 6.48719 6.44795 6.36355 6.27404 6.23467 6.24419 6.29523 6.3898 6.49576 6.54603 6.54879 6.52285 6.4839 6.45011 6.43805 6.44471 6.4665 6.5011 6.53975 6.57424 6.59541 6.6034 6.60135 6.60541 6.40196 6.40786 6.39745 6.37016 6.32858 6.28566 6.26457 6.26937 6.28946 6.31568 6.34073 6.35713 6.36513 6.3638 6.35743 6.35357 6.35864 6.37137 6.38491 6.39944 6.40947 6.40946 6.40042 6.39172 6.39203 6.40359 6.42059 6.43404 6.4369 6.42495 6.40563 6.38316 6.36783 6.35702 6.34824 6.33995 6.32697 6.30748 6.28632 6.27225 6.26673 6.28206 6.31487 6.34037 6.36328 6.39093 6.39306 6.3665 6.32402 6.26963 6.21905 6.20866 6.24232 6.29561 6.35555 6.41398 6.42632 6.40215 6.36784 6.31428 6.28448 6.29413 6.32556 6.36484 6.4302 6.48857 6.50731 6.50549 6.49677 6.47914 6.4684 6.47076 6.47956 6.49293 6.51007 6.53109 6.55211 6.56618 6.57169 6.57475 6.39878 6.40186 6.38614 6.35633 6.31238 6.27017 6.25082 6.25683 6.28047 6.31066 6.338 6.3571 6.36585 6.36343 6.35299 6.34295 6.34414 6.36088 6.38635 6.41455 6.43011 6.42808 6.41224 6.39397 6.38416 6.39016 6.40224 6.41948 6.42999 6.4279 6.41693 6.40118 6.38859 6.37539 6.3613 6.34325 6.32139 6.29944 6.28546 6.28003 6.29844 6.33259 6.35617 6.36195 6.35695 6.3502 6.33313 6.31514 6.30014 6.28636 6.26735 6.27009 6.28903 6.30841 6.31972 6.32881 6.34195 6.3542 6.36506 6.37098 6.36548 6.36203 6.36236 6.3623 6.36545 6.4021 6.44979 6.47703 6.49252 6.50242 6.50793 6.50471 6.49901 6.49567 6.49545 6.49568 6.49966 6.50879 6.51488 6.5167 6.38969 6.38842 6.36955 6.33907 6.29777 6.25939 6.2426 6.24886 6.27313 6.30628 6.33595 6.35713 6.36559 6.36255 6.34936 6.33556 6.33398 6.35377 6.39172 6.42939 6.44534 6.43902 6.41778 6.39494 6.37924 6.37803 6.38444 6.40305 6.42131 6.4298 6.42589 6.41585 6.40513 6.39305 6.37367 6.34842 6.31797 6.29457 6.28511 6.29666 6.33641 6.37082 6.38423 6.37679 6.34848 6.29886 6.26538 6.26287 6.27287 6.29151 6.33007 6.34505 6.33714 6.32237 6.27873 6.24861 6.26081 6.30633 6.36189 6.42371 6.4491 6.4309 6.39639 6.35674 6.32906 6.33214 6.3818 6.44453 6.49308 6.52781 6.54181 6.53426 6.51334 6.49141 6.47847 6.47223 6.47188 6.46955 6.46695 6.46361 6.37602 6.3698 6.34969 6.32124 6.28544 6.25266 6.23919 6.24473 6.26703 6.30157 6.33454 6.35654 6.36588 6.36199 6.34735 6.33347 6.33348 6.35539 6.39824 6.43804 6.45285 6.44397 6.4197 6.39543 6.37684 6.37019 6.3735 6.38994 6.41203 6.42642 6.42835 6.42333 6.41782 6.40865 6.38652 6.35403 6.31982 6.29811 6.29158 6.3173 6.3605 6.38796 6.398 6.38297 6.32703 6.25547 6.21923 6.22193 6.25249 6.31864 6.38406 6.4028 6.37637 6.31614 6.24035 6.20043 6.20609 6.26709 6.37394 6.46461 6.50376 6.48676 6.42484 6.35155 6.31201 6.30235 6.32563 6.40092 6.48545 6.53757 6.55575 6.54878 6.52358 6.4916 6.46771 6.4565 6.45356 6.45249 6.44674 6.44094 6.36041 6.34882 6.33039 6.30551 6.27593 6.24913 6.23923 6.24429 6.26354 6.29668 6.33179 6.35603 6.36579 6.36143 6.34823 6.33789 6.34227 6.36524 6.40213 6.43756 6.45202 6.44323 6.41839 6.39601 6.37744 6.36829 6.37136 6.38355 6.3994 6.41452 6.42114 6.42026 6.41742 6.41182 6.39451 6.3627 6.32908 6.31046 6.31083 6.33144 6.36406 6.38436 6.39122 6.36443 6.29965 6.23524 6.20113 6.19421 6.2401 6.33811 6.40716 6.4299 6.40368 6.31678 6.2272 6.18899 6.19243 6.25086 6.37697 6.47578 6.51673 6.50659 6.44475 6.36192 6.31404 6.30156 6.3171 6.37387 6.46277 6.52725 6.5483 6.54156 6.51788 6.48868 6.46514 6.45176 6.44687 6.44501 6.44187 6.4389 6.34294 6.33033 6.31365 6.29281 6.26922 6.24794 6.24057 6.24635 6.26246 6.29172 6.32639 6.35232 6.36411 6.36267 6.35344 6.34922 6.35882 6.37894 6.40336 6.42928 6.44257 6.43667 6.41549 6.39514 6.3821 6.37604 6.37941 6.385 6.38842 6.39455 6.40328 6.40811 6.40793 6.40574 6.39357 6.37185 6.34961 6.3359 6.33257 6.34026 6.35269 6.36341 6.35524 6.32599 6.28034 6.23371 6.20402 6.20483 6.2518 6.33415 6.40067 6.42358 6.39274 6.32458 6.24673 6.21125 6.22028 6.27789 6.3662 6.45241 6.49154 6.48359 6.44653 6.38553 6.33496 6.32221 6.34182 6.37843 6.43312 6.49053 6.51871 6.51725 6.50131 6.4829 6.4683 6.4584 6.4553 6.45913 6.46093 6.46341 6.32816 6.31621 6.30121 6.28414 6.26458 6.24819 6.2437 6.24856 6.26298 6.28667 6.31715 6.34467 6.36101 6.36559 6.36465 6.36915 6.3788 6.39022 6.40319 6.41654 6.42741 6.42642 6.41124 6.39431 6.3912 6.39107 6.3919 6.38856 6.37888 6.37334 6.3744 6.38119 6.38903 6.39521 6.39168 6.38412 6.3773 6.36763 6.35178 6.34089 6.33663 6.32455 6.30502 6.28922 6.27152 6.24883 6.23405 6.2464 6.27072 6.31238 6.36498 6.38054 6.36729 6.34124 6.29794 6.27261 6.28802 6.31698 6.34807 6.39764 6.4329 6.44041 6.43746 6.41166 6.3794 6.36787 6.37613 6.39143 6.40972 6.43374 6.46409 6.47741 6.47737 6.47714 6.47319 6.47537 6.48353 6.49643 6.50766 6.51732 6.3183 6.30589 6.29226 6.27868 6.26232 6.25029 6.2473 6.25076 6.26403 6.28254 6.305 6.33232 6.35592 6.3697 6.38205 6.39239 6.39861 6.40189 6.40261 6.4085 6.41052 6.41261 6.40557 6.40043 6.40369 6.40783 6.40535 6.39418 6.37646 6.35661 6.34413 6.34542 6.35898 6.37489 6.38382 6.39584 6.40507 6.39713 6.36996 6.34159 6.31179 6.27362 6.25353 6.25434 6.25888 6.26348 6.28459 6.29499 6.29199 6.29509 6.30327 6.31816 6.33521 6.34684 6.3543 6.36586 6.3675 6.35482 6.34381 6.33687 6.35255 6.38475 6.40931 6.42338 6.43242 6.42763 6.41732 6.41249 6.40165 6.39118 6.39967 6.42626 6.44825 6.45946 6.47235 6.49135 6.5208 6.55083 6.56825 6.58273 6.313 6.30047 6.2883 6.27715 6.26288 6.25318 6.25117 6.25372 6.26441 6.27676 6.29489 6.31814 6.3499 6.37876 6.40089 6.40899 6.41108 6.40842 6.40337 6.40324 6.39697 6.39758 6.40123 6.40897 6.41601 6.42067 6.41555 6.39955 6.37269 6.3423 6.321 6.31562 6.32842 6.35281 6.38275 6.41396 6.42938 6.41718 6.38369 6.34243 6.28265 6.23453 6.21739 6.22673 6.24911 6.29433 6.33221 6.33518 6.31486 6.27785 6.24673 6.25686 6.30019 6.36041 6.42909 6.45585 6.43479 6.38752 6.32869 6.28719 6.28904 6.33059 6.38749 6.44584 6.48087 6.47774 6.45161 6.41981 6.38566 6.3612 6.35862 6.37845 6.41079 6.44637 6.4893 6.53303 6.57066 6.59512 6.60671 6.62334 6.30946 6.29649 6.28455 6.27414 6.26144 6.25407 6.25348 6.25672 6.26528 6.27452 6.29038 6.30693 6.34297 6.38431 6.41261 6.41923 6.42198 6.41573 6.40738 6.40249 6.39187 6.3848 6.39688 6.41334 6.42313 6.42872 6.42384 6.40447 6.37132 6.33558 6.30888 6.29757 6.30209 6.32924 6.37755 6.42375 6.44255 6.4301 6.39716 6.34135 6.2667 6.21193 6.19191 6.19962 6.24127 6.31254 6.35907 6.36588 6.33737 6.26708 6.21596 6.21204 6.26144 6.37211 6.47432 6.5078 6.48946 6.41721 6.31933 6.26194 6.25107 6.27905 6.36445 6.45742 6.50637 6.51342 6.48311 6.42907 6.37717 6.34772 6.33531 6.33956 6.3692 6.43317 6.50395 6.56564 6.60578 6.62766 6.63638 6.65584 ) ; boundaryField { inlet { type fixedValue; value uniform 1; } outlet { type zeroGradient; } bottom { type symmetryPlane; } top { type symmetryPlane; } obstacle { type zeroGradient; } defaultFaces { type empty; } } // ************************************************************************* //
740ed5843adbccfb21302c9272a16d4f1d236f95
c81d646237e2545402295a13144102ab0e055361
/Classes/View/CreateController.cpp
fd0a07d9f7a5cc168105e767057d6e5a4d9fb3b2
[]
no_license
lookdczar/alfaProDev
3eec1fb90cbf9d333f81d926bc5411ea44ff45ab
df989f6ed064492687d82d9366b5a31a9dfd8eb4
refs/heads/master
2021-01-01T16:34:33.050139
2015-05-12T11:59:34
2015-05-12T11:59:34
34,952,042
0
0
null
null
null
null
IBM852
C++
false
false
477
cpp
#include "CreateController.h" #include "CreateView.h" USING_NS_CC; bool CreateController::init() { if ( !BaseController::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); //│§╩╝╗»view _view = CreateView::create(); //¤ď╩żview viewWillAppear(_view); return true; } void CreateController::menuStartGameCallback(Ref* pSender) { }
467c3a25f1274f86f40906a970a9c327962ded36
e99c20155e9b08c7e7598a3f85ccaedbd127f632
/ sjtu-project-pipe/thirdparties/VTK.Net/src/Imaging/vtkImageEuclideanDistanceDotNet.h
2a7efde13dd0a630572194b5f062fde690c33bb0
[ "BSD-3-Clause" ]
permissive
unidevop/sjtu-project-pipe
38f00462d501d9b1134ce736bdfbfe4f9d075e4a
5a09f098db834d5276a2921d861ef549961decbe
refs/heads/master
2020-05-16T21:32:47.772410
2012-03-19T01:24:14
2012-03-19T01:24:14
38,281,086
1
1
null
null
null
null
UTF-8
C++
false
false
6,454
h
#pragma once // managed includes #include "vtkImageDecomposeFilterDotNet.h" // native includes using namespace System; namespace vtk { public ref class vtkImageEuclideanDistance : public vtkImageDecomposeFilter { public: // Did not wrap: static vtkImageEuclideanDistance *New (); // const char *GetClassName (); System::String^ GetClassName(); // int IsA (const char *name); int IsA(System::String^ name); // vtkImageEuclideanDistance *NewInstance (); vtkImageEuclideanDistance^ NewInstance(); // vtkImageEuclideanDistance *SafeDownCast (vtkObject* o); static vtkImageEuclideanDistance^ SafeDownCast(vtkObject^ o); void PrintSelf(System::IO::TextWriter^ writer, int indentLevel); virtual System::String^ ToString() override; // int SplitExtent (int splitExt[6], int startExt[6], int num, int total); /// <summary> /// <para>Used internally for streaming and threads. Splits output update extent into num pieces. This method needs to be called num times. Results must not overlap for consistent starting extent. Subclass can override this method. This method returns the number of peices resulting from a successful split. This can be from 1 to &quot;total&quot;. If 1 is returned, the extent cannot be split.</para> /// </summary> int SplitExtent(array<int>^ splitExt, array<int>^ startExt, int num, int total); // void SetInitialize (int ); /// <summary> /// <para>Used to set all non-zero voxels to MaximumDistance before starting the distance transformation. Setting Initialize off keeps the current value in the input image as starting point. This allows to superimpose several distance maps. </para> /// </summary> void SetInitialize(int arg0); // int GetInitialize (); /// <summary> /// <para>Used to set all non-zero voxels to MaximumDistance before starting the distance transformation. Setting Initialize off keeps the current value in the input image as starting point. This allows to superimpose several distance maps. </para> /// </summary> int GetInitialize(); // void InitializeOn (); /// <summary> /// <para>Used to set all non-zero voxels to MaximumDistance before starting the distance transformation. Setting Initialize off keeps the current value in the input image as starting point. This allows to superimpose several distance maps. </para> /// </summary> void InitializeOn(); // void InitializeOff (); /// <summary> /// <para>Used to set all non-zero voxels to MaximumDistance before starting the distance transformation. Setting Initialize off keeps the current value in the input image as starting point. This allows to superimpose several distance maps. </para> /// </summary> void InitializeOff(); // void SetConsiderAnisotropy (int ); /// <summary> /// <para>Used to define whether Spacing should be used in the computation of the distances </para> /// </summary> void SetConsiderAnisotropy(int arg0); // int GetConsiderAnisotropy (); /// <summary> /// <para>Used to define whether Spacing should be used in the computation of the distances </para> /// </summary> int GetConsiderAnisotropy(); // void ConsiderAnisotropyOn (); /// <summary> /// <para>Used to define whether Spacing should be used in the computation of the distances </para> /// </summary> void ConsiderAnisotropyOn(); // void ConsiderAnisotropyOff (); /// <summary> /// <para>Used to define whether Spacing should be used in the computation of the distances </para> /// </summary> void ConsiderAnisotropyOff(); // void SetMaximumDistance (double ); /// <summary> /// <para>Any distance bigger than this-&gt;MaximumDistance will not ne computed but set to this-&gt;MaximumDistance instead. </para> /// </summary> void SetMaximumDistance(double arg0); // double GetMaximumDistance (); /// <summary> /// <para>Any distance bigger than this-&gt;MaximumDistance will not ne computed but set to this-&gt;MaximumDistance instead. </para> /// </summary> double GetMaximumDistance(); // void SetAlgorithm (int ); /// <summary> /// <para>Selects a Euclidean DT algorithm. 1. Saito 2. Saito-cached More algorithms will be added later on. </para> /// </summary> void SetAlgorithm(int arg0); // int GetAlgorithm (); /// <summary> /// <para>Selects a Euclidean DT algorithm. 1. Saito 2. Saito-cached More algorithms will be added later on. </para> /// </summary> int GetAlgorithm(); // void SetAlgorithmToSaito ();this SetAlgorithm VTK_EDT_SAITO /// <summary> /// <para>Selects a Euclidean DT algorithm. 1. Saito 2. Saito-cached More algorithms will be added later on. </para> /// </summary> void SetAlgorithmToSaito(); // void SetAlgorithmToSaitoCached ();this SetAlgorithm VTK_EDT_SAITO_CACHED void SetAlgorithmToSaitoCached(); // Did not wrap: virtual int IterativeRequestData (vtkInformation *, vtkInformationVector *, vtkInformationVector *); // Did not wrap: vtkImageEuclideanDistance (); // Did not wrap: ~vtkImageEuclideanDistance (); // Did not wrap: virtual void AllocateOutputScalars (vtkImageData *outData); // Did not wrap: virtual int IterativeRequestInformation (vtkInformation *in, vtkInformation *out); // Did not wrap: virtual int IterativeRequestUpdateExtent (vtkInformation *in, vtkInformation *out); // Did not wrap: vtkImageEuclideanDistance (const vtkImageEuclideanDistance &); // Did not wrap: void vtkImageEuclideanDistance /// <summary> /// This constructor is used to convert native pointers into managed wrapper classes. /// </summary> vtkImageEuclideanDistance(System::IntPtr native, bool bConst); /// <summary> /// This constructor is called only by derived classes. It asks base classes not allocate a native instance. /// </summary> vtkImageEuclideanDistance(bool donothing); /// <summary> /// This constructor creates a wrapper class. It is the one to call. /// </summary> vtkImageEuclideanDistance(); /// <summary> /// This method calls Delete() on the native instance. /// Use it to release resources in a timely fashion. /// </summary> /// <remarks> /// If this method is not called, then the finalizer will /// call Delete on this instance. /// </remarks> virtual ~vtkImageEuclideanDistance(); }; } // end vtkImaging
f78423d513745233de2c52d05759190991c4e43d
1fa309b90d73c6daad65a2604d07ddc120fa6f8e
/2023/ble_t_rh_sensor/firmware/bsp/usart_gdf3.cc
38b221cbe2e3061206d4f9d446415fc6ec217608
[]
no_license
tomzbj/diy
473e4c50288b88107deb7b41432979bd01e3ecb2
7287e609509e9d7f0ffa9e01e34414a49b568179
refs/heads/master
2023-07-21T02:47:47.710028
2023-07-10T03:32:36
2023-07-10T03:32:36
160,756,266
69
44
null
null
null
null
UTF-8
C++
false
false
1,397
cc
#include "platform.h" #include "misc.h" void USART0_WriteByte(unsigned char c) { usart_data_transmit(USART0, c); while(RESET == usart_flag_get(USART0, USART_FLAG_TC)); } unsigned char USART0_ReadByte(void) { return USART_RDATA(USART0); } void USART1_WriteByte(unsigned char c) { usart_data_transmit(USART1, c); while(RESET == usart_flag_get(USART1, USART_FLAG_TC)); } unsigned char USART1_ReadByte(void) { return USART_RDATA(USART1); } static void _usart_config(unsigned long usartx, unsigned long baudrate) { usart_disable(usartx); usart_deinit(usartx); /* USART configure */ usart_word_length_set(usartx, USART_WL_8BIT); usart_stop_bit_set(usartx, USART_STB_1BIT); usart_parity_config(usartx, USART_PM_NONE); usart_baudrate_set(usartx, baudrate); usart_receive_config(usartx, USART_RECEIVE_ENABLE); usart_transmit_config(usartx, USART_TRANSMIT_ENABLE); usart_enable(usartx); usart_interrupt_enable(usartx, USART_INT_ERR); usart_interrupt_enable(usartx, USART_INT_RBNE); usart_interrupt_enable(usartx, USART_INT_IDLE); } void USART_Config(void) { rcu_periph_clock_enable (RCU_USART0); /* enable USART clock */ __disable_irq(); _usart_config(USART0, 115200UL); nvic_irq_enable(USART0_IRQn, 1); __enable_irq(); printf("\n\n"); printf("[%s: %d] USART Initialized.\n", __FILE__, __LINE__); }
27ad8a9c5552c161f68d7730ddbceddb694e9c1a
3d193be5bcbc0823c91fdb2504beef631d6da709
/cc/tiles/tile_manager.h
dfcf4786cca7566bc46beb6ed40486fd403712fe
[ "BSD-3-Clause" ]
permissive
a402539/highweb-webcl-html5spec
7a4285a729fdf98b5eea7c19a288d26d4759d7cc
644216ea0c2db67af15471b42753d76e35082759
refs/heads/master
2020-03-22T14:01:34.091922
2016-04-26T05:06:00
2016-05-03T12:58:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,636
h
// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CC_TILES_TILE_MANAGER_H_ #define CC_TILES_TILE_MANAGER_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <set> #include <unordered_map> #include <utility> #include <vector> #include "base/macros.h" #include "base/values.h" #include "cc/base/unique_notifier.h" #include "cc/playback/raster_source.h" #include "cc/raster/tile_task_worker_pool.h" #include "cc/resources/memory_history.h" #include "cc/resources/resource_pool.h" #include "cc/tiles/eviction_tile_priority_queue.h" #include "cc/tiles/image_decode_controller.h" #include "cc/tiles/raster_tile_priority_queue.h" #include "cc/tiles/tile.h" #include "cc/tiles/tile_draw_info.h" namespace base { namespace trace_event { class ConvertableToTraceFormat; class TracedValue; } } namespace cc { class PictureLayerImpl; class ResourceProvider; class CC_EXPORT TileManagerClient { public: // Called when all tiles marked as required for activation are ready to draw. virtual void NotifyReadyToActivate() = 0; // Called when all tiles marked as required for draw are ready to draw. virtual void NotifyReadyToDraw() = 0; // Called when all tile tasks started by the most recent call to PrepareTiles // are completed. virtual void NotifyAllTileTasksCompleted() = 0; // Called when the visible representation of a tile might have changed. Some // examples are: // - Tile version initialized. // - Tile resources freed. // - Tile marked for on-demand raster. virtual void NotifyTileStateChanged(const Tile* tile) = 0; // Given an empty raster tile priority queue, this will build a priority queue // that will return tiles in order in which they should be rasterized. // Note if the queue was previous built, Reset must be called on it. virtual std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue( TreePriority tree_priority, RasterTilePriorityQueue::Type type) = 0; // Given an empty eviction tile priority queue, this will build a priority // queue that will return tiles in order in which they should be evicted. // Note if the queue was previous built, Reset must be called on it. virtual std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( TreePriority tree_priority) = 0; // Informs the client that due to the currently rasterizing (or scheduled to // be rasterized) tiles, we will be in a position that will likely require a // draw. This can be used to preemptively start a frame. virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; protected: virtual ~TileManagerClient() {} }; struct RasterTaskCompletionStats { RasterTaskCompletionStats(); size_t completed_count; size_t canceled_count; }; std::unique_ptr<base::trace_event::ConvertableToTraceFormat> RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); // This class manages tiles, deciding which should get rasterized and which // should no longer have any memory assigned to them. Tile objects are "owned" // by layers; they automatically register with the manager when they are // created, and unregister from the manager when they are deleted. class CC_EXPORT TileManager { public: static std::unique_ptr<TileManager> Create( TileManagerClient* client, base::SequencedTaskRunner* task_runner, size_t scheduled_raster_task_limit, bool use_partial_raster); virtual ~TileManager(); // Assigns tile memory and schedules work to prepare tiles for drawing. // - Runs client_->NotifyReadyToActivate() when all tiles required for // activation are prepared, or failed to prepare due to OOM. // - Runs client_->NotifyReadyToDraw() when all tiles required draw are // prepared, or failed to prepare due to OOM. bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); // Synchronously finish any in progress work, cancel the rest, and clean up as // much resources as possible. Also, prevents any future work until a // SetResources call. void FinishTasksAndCleanUp(); // Set the new given resource pool and tile task runner. Note that // FinishTasksAndCleanUp must be called in between consecutive calls to // SetResources. void SetResources(ResourcePool* resource_pool, TileTaskWorkerPool* tile_task_worker_pool, ImageDecodeController* image_decode_controller, size_t scheduled_raster_task_limit, bool use_gpu_rasterization); // This causes any completed raster work to finalize, so that tiles get up to // date draw information. void Flush(); ScopedTilePtr CreateTile(const Tile::CreateInfo& info, int layer_id, int source_frame_number, int flags); bool IsReadyToActivate() const; bool IsReadyToDraw() const; std::unique_ptr<base::trace_event::ConvertableToTraceFormat> BasicStateAsValue() const; void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; const MemoryHistory::Entry& memory_stats_from_last_assign() const { return memory_stats_from_last_assign_; } // Public methods for testing. void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { for (size_t i = 0; i < tiles.size(); ++i) { TileDrawInfo& draw_info = tiles[i]->draw_info(); draw_info.resource_ = resource_pool_->AcquireResource( tiles[i]->desired_texture_size(), tile_task_worker_pool_->GetResourceFormat(false)); } } void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { for (size_t i = 0; i < tiles.size(); ++i) { Tile* tile = tiles[i]; FreeResourcesForTile(tile); } } void SetGlobalStateForTesting( const GlobalStateThatImpactsTilePriority& state) { global_state_ = state; } void SetTileTaskWorkerPoolForTesting( TileTaskWorkerPool* tile_task_worker_pool); void FreeResourcesAndCleanUpReleasedTilesForTesting() { FreeResourcesForReleasedTiles(); CleanUpReleasedTiles(); } std::vector<Tile*> AllTilesForTesting() const { std::vector<Tile*> tiles; for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { tiles.push_back(it->second); } return tiles; } void SetScheduledRasterTaskLimitForTesting(size_t limit) { scheduled_raster_task_limit_ = limit; } void CheckIfMoreTilesNeedToBePreparedForTesting() { CheckIfMoreTilesNeedToBePrepared(); } void SetMoreTilesNeedToBeRasterizedForTesting() { all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; } bool HasScheduledTileTasksForTesting() const { return has_scheduled_tile_tasks_; } protected: TileManager(TileManagerClient* client, scoped_refptr<base::SequencedTaskRunner> task_runner, size_t scheduled_raster_task_limit, bool use_partial_raster); void FreeResourcesForReleasedTiles(); void CleanUpReleasedTiles(); friend class Tile; // Virtual for testing. virtual void Release(Tile* tile); Tile::Id GetUniqueTileId() { return ++next_tile_id_; } typedef std::vector<PrioritizedTile> PrioritizedTileVector; typedef std::set<Tile*> TileSet; // Virtual for test virtual void ScheduleTasks( const PrioritizedTileVector& tiles_that_need_to_be_rasterized); void AssignGpuMemoryToTiles( RasterTilePriorityQueue* raster_priority_queue, size_t scheduled_raser_task_limit, PrioritizedTileVector* tiles_that_need_to_be_rasterized); private: class MemoryUsage { public: MemoryUsage(); MemoryUsage(size_t memory_bytes, size_t resource_count); static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); static MemoryUsage FromTile(const Tile* tile); MemoryUsage& operator+=(const MemoryUsage& other); MemoryUsage& operator-=(const MemoryUsage& other); MemoryUsage operator-(const MemoryUsage& other); bool Exceeds(const MemoryUsage& limit) const; int64_t memory_bytes() const { return memory_bytes_; } private: int64_t memory_bytes_; int resource_count_; }; void OnRasterTaskCompleted( Tile::Id tile, Resource* resource, bool was_canceled); void FreeResourcesForTile(Tile* tile); void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); scoped_refptr<TileTask> CreateRasterTask( const PrioritizedTile& prioritized_tile); std::unique_ptr<EvictionTilePriorityQueue> FreeTileResourcesUntilUsageIsWithinLimit( std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, const MemoryUsage& limit, MemoryUsage* usage); std::unique_ptr<EvictionTilePriorityQueue> FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, const MemoryUsage& limit, const TilePriority& oother_priority, MemoryUsage* usage); bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); bool AreRequiredTilesReadyToDraw(RasterTilePriorityQueue::Type type) const; void CheckIfMoreTilesNeedToBePrepared(); void CheckAndIssueSignals(); bool MarkTilesOutOfMemory( std::unique_ptr<RasterTilePriorityQueue> queue) const; ResourceFormat DetermineResourceFormat(const Tile* tile) const; bool DetermineResourceRequiresSwizzle(const Tile* tile) const; void DidFinishRunningTileTasksRequiredForActivation(); void DidFinishRunningTileTasksRequiredForDraw(); void DidFinishRunningAllTileTasks(); scoped_refptr<TileTask> CreateTaskSetFinishedTask( void (TileManager::*callback)()); std::unique_ptr<base::trace_event::ConvertableToTraceFormat> ScheduledTasksStateAsValue() const; TileManagerClient* client_; scoped_refptr<base::SequencedTaskRunner> task_runner_; ResourcePool* resource_pool_; TileTaskWorkerPool* tile_task_worker_pool_; GlobalStateThatImpactsTilePriority global_state_; size_t scheduled_raster_task_limit_; const bool use_partial_raster_; bool use_gpu_rasterization_; using TileMap = std::unordered_map<Tile::Id, Tile*>; TileMap tiles_; bool all_tiles_that_need_to_be_rasterized_are_scheduled_; MemoryHistory::Entry memory_stats_from_last_assign_; bool did_check_for_completed_tasks_since_last_schedule_tasks_; bool did_oom_on_last_assign_; ImageDecodeController* image_decode_controller_; RasterTaskCompletionStats flush_stats_; std::vector<Tile*> released_tiles_; std::vector<scoped_refptr<TileTask>> orphan_tasks_; TaskGraph graph_; scoped_refptr<TileTask> required_for_activation_done_task_; scoped_refptr<TileTask> required_for_draw_done_task_; scoped_refptr<TileTask> all_done_task_; UniqueNotifier more_tiles_need_prepare_check_notifier_; struct Signals { Signals(); void reset(); bool ready_to_activate; bool did_notify_ready_to_activate; bool ready_to_draw; bool did_notify_ready_to_draw; bool all_tile_tasks_completed; bool did_notify_all_tile_tasks_completed; } signals_; UniqueNotifier signals_check_notifier_; bool has_scheduled_tile_tasks_; uint64_t prepare_tiles_count_; uint64_t next_tile_id_; std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(TileManager); }; } // namespace cc #endif // CC_TILES_TILE_MANAGER_H_
55fd59a38cbc958a80d23b81e7e89f58fe3e84a4
5548eeed2770586d53e726ad33508735887ad518
/streams/sstream/ostr/main.cpp
9c150643eb61cfbd3987db680c8850a5aba8afdf
[]
no_license
chillylips76/cis201-examples
6ea44bb517ec65da6e4bcb04415591c6f73010ef
94797e818af25abc1be453cee7e843d8fd45d779
refs/heads/master
2022-03-23T17:29:12.950398
2019-12-09T21:15:05
2019-12-09T21:15:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
327
cpp
#include<iostream> #include<string> #include<sstream> #include<iomanip> using namespace std; int main() { string month = "January"; int day = 3; int year = 1973; ostringstream ostrm; ostrm << month << " " << setw(2) << setfill('0') << day << "," << year; cout << ostrm.str() << endl; return 0; }
73d13b448e0dfafbdc7ff864d678cdce9c5d48cc
08fb7e5f7cffbf3cf4e0e00f277047ff97986c9d
/src/objs/MFile.h
dfa2835c73d116c5adaad9210523d7ad825331c1
[ "Apache-2.0" ]
permissive
Changwan-planet/Cassini_RADAR_Software
7e9a505876b1610371dc3df602451ec4cff3e338
93a5be34d013c2913cf74f06e01c59b625bb4a17
refs/heads/main
2023-05-30T23:59:23.312249
2021-06-11T17:36:45
2021-06-11T17:36:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,117
h
//============================================================================= // MFile.h // // This file contains the MFile class declarations. The MFile class // handles outputs to a MATLAB readable script file // // Interface summary: // //----------------------------------------------------------------------- #ifndef MFILE_H #define MFILE_H #include<stdio.h> #include<complex> #include<string> using std::string; using std::complex; class MFile { public: // constructor and destructor MFile(); ~MFile(); // open and close void close(); void open(const char* s); void flush(); // output a comment void comment(const string& s); // routines for outputing set statements (arrays and scalars of various // types void set(const string & left, float v, int d1=0, int d2=0); void set(const string & left, complex<float>* v, int len, int d1=0, int d2=0); void set(const string & left, float* v, int len, int d1=0, int d2=0); void leftHandSide(const string & left, int d1=0, int d2=0); private: void dieOnUnopenedFile(const string& funcname); FILE* fp; }; #endif
b75e950b8c3bf748c22027bb7fbabf9aa48ccf0a
3757b4827f76f57cb7f712d35db11b5f70a3982e
/2019SIC/Stage.cpp
5d49add63db93b15ca6a13d597603fbd2f347aae
[]
no_license
K-Game/KAWAMOTO
338b884f942f4cbfdecc5b87090fbedff11db361
17e8ee6cfb3a9a43795fc1e68cb2a6738a141aa8
refs/heads/master
2020-07-14T09:30:23.220455
2019-09-04T22:08:15
2019-09-04T22:08:15
205,292,200
0
0
null
null
null
null
UTF-8
C++
false
false
61
cpp
#include <Windows.h> #include "DxLib.h" #include "Obj2d.h"
8e88b006a5620aaeb3b26734f9f8a89f0c2fb718
d249a6685da6178c713a672fd8cb92f61cf493f3
/source/samples/compatibility_test/text_format_test.h
92db0b8fcf4eab1c0a0d936192b4d32e611abeb5
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
utechnique/universal_tools
023ad031aaf5d7085ccfd35014f1e19219d5a309
e8061c7eba58495d5854a90b1939cb3edd8b74f2
refs/heads/master
2023-05-13T19:26:34.509064
2023-05-01T21:30:33
2023-05-01T21:30:33
179,288,705
0
1
MIT
2021-04-19T19:43:22
2019-04-03T12:47:51
C
UTF-8
C++
false
false
1,271
h
//----------------------------------------------------------------------------// //---------------------------------| U T |---------------------------------// //----------------------------------------------------------------------------// #pragma once //----------------------------------------------------------------------------// #include "ut.h" #include "test_task.h" #include "test_unit.h" //----------------------------------------------------------------------------// class TextFormatUnit : public TestUnit { public: TextFormatUnit(); }; //----------------------------------------------------------------------------// class XmlTask : public TestTask { public: XmlTask(); void Execute(); }; //----------------------------------------------------------------------------// class JsonTask : public TestTask { public: JsonTask(); void Execute(); }; //----------------------------------------------------------------------------// extern const char* g_xml_file_contents; extern const char* g_json_file_contents; //----------------------------------------------------------------------------// //----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
d7eb05a8317b101262206a812c1c792164c4e87a
192f0d8c7d7676b51c1efdb1c4e3ab1f5997f904
/031702409/src/Sudoku/Sudoku.cpp
8d42749ab93fcfe2397a0fb5d559566f58512a10
[]
no_license
fishred2941214/2019SoftwareEngineer
211a530e08164bc400b0a68b0f545ec58e7296f8
fbf0c31c3e137adc6c4c05b963c02d036484035f
refs/heads/master
2020-07-30T19:03:56.667757
2019-09-24T12:17:26
2019-09-24T12:17:26
210,325,272
0
0
null
null
null
null
UTF-8
C++
false
false
2,607
cpp
#include "pch.h" #include <iostream> #include <stdio.h> #include <stdlib.h> #include <math.h> using namespace std; int soduku[9][9]; int order; int num; bool judge(int count, int target) { int row = count / order; int col = count % order; int i; int j; for (i = 0; i < order; i++) { if (soduku[row][i] == target && i != col) { return false; } } for (i = 0; i < order; i++) { if (soduku[i][col] == target && i != row) { return false; } } int s = sqrt(order); if (order == 9 || order == 4) { int realrow = row / s * s; int realcol = col / s * s; for (i = realrow; i < realrow + s; i++) { for (j = realcol; j < realcol + s; j++) { if (soduku[i][j] == target && i != row && j != col) { return false; } } } } if (order == 6) { int realrow = row / 2 * 2; int realcol = col / 3 * 3; for (i = realrow; i < realrow + 2; i++) { for (j = realcol; j < realcol + 3; j++) { if (soduku[i][j] == target && i != row && j != col) { return false; } } } } if (order == 8) { int realrow = row / 4 * 4; int realcol = col / 2 * 2; for (i = realrow; i < realrow + 4; i++) { for (j = realcol; j < realcol + 2; j++) { if (soduku[i][j] == target && i != row && j != col) { return false; } } } } return true; } void insert(int count, FILE* fp) { int row = count / order; int col = count % order; int i; int j; bool flag; if (count == order * order) { for (i = 0; i < order; i++) { for (j = 0; j < order; j++) { fprintf(fp, "%d ", soduku[i][j]); } fprintf(fp, "\n"); } fprintf(fp, "\n"); return; } if (soduku[row][col] != 0) { insert(count + 1, fp); } else { for (i = 1; i <= order; i++) { soduku[row][col] = i; flag = judge(count, soduku[row][col]); if (flag) { insert(count + 1, fp); } } soduku[row][col] = 0; } } int main(int argc, char* argv[]) { int i; int j; int z; FILE* fp1; FILE* fp2; order = atoi(argv[2]); num = atoi(argv[4]); fp1 = fopen("input.txt", "r"); fp2 = fopen("output.txt", "w"); if (fp1 == NULL) { cout << "fp1打不开嗷"; exit(1); } if (fp2 == NULL) { cout << "fp2打不开嗷"; exit(1); } for (i = 0; i < num; i++) { memset(soduku, 0, 81); for (j = 0; j < order; j++) { for (z = 0; z < order; z++) { fscanf(fp1, "%d", &soduku[j][z]); } } insert(0, fp2); } fclose(fp2); return 0; }
0b3e833b7c368a504e66da9b317bb2e7d57d5b4b
d5ab07f26018f8ee2e50278f1ca12889f66eb516
/renderer/material_manager.hpp
e024476f5e0ffb7df4c670ad382331422854980e
[ "MIT" ]
permissive
infancy/Granite
15dd76dfe7b05b383a770db057d9414af0f2f02c
c507a52439b585ac26ca1450e0ee97862837abc2
refs/heads/master
2020-06-03T00:22:07.335813
2019-11-24T03:12:31
2019-11-24T03:12:31
191,359,228
0
0
null
2019-06-11T11:37:13
2019-06-11T11:37:12
null
UTF-8
C++
false
false
2,136
hpp
/* Copyright (c) 2017-2019 Hans-Kristian Arntzen * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include "material.hpp" #include "volatile_source.hpp" #include "device.hpp" #include "event.hpp" #include "scene_formats.hpp" #include "application_wsi_events.hpp" namespace Granite { class MaterialFile : public Material, public Util::VolatileSource<MaterialFile>, public EventHandler { public: MaterialFile(const std::string &path); MaterialFile(const SceneFormats::MaterialInfo &info); void update(std::unique_ptr<File> file); private: Vulkan::Device *device = nullptr; std::string paths[Util::ecast(Material::Textures::Count)]; VkComponentMapping swizzle[Util::ecast(Material::Textures::Count)]; void on_device_created(const Vulkan::DeviceCreatedEvent &e); void on_device_destroyed(const Vulkan::DeviceCreatedEvent &e); void init_textures(); }; class MaterialManager { public: MaterialHandle request_material(const std::string &path); static MaterialManager &get(); private: MaterialManager() = default; std::unordered_map<std::string, MaterialHandle> materials; }; }
7be5a2eb06c4b19ac9995aaa3794c0d69ab8cabe
8f134971c94250de2408dbbee90f721c22cfe609
/RmwTestProjects/XsyEnhance.cpp
4d405a7b5722f059d42a2da25e7c879f85a74dcf
[]
no_license
microshy/basicGraphAlgorithm
c4f5b2cecba7f9f84d69965a42283e28e4a8097f
1e1252add9ec46eedb581756568089accb5c3f00
refs/heads/master
2020-03-20T08:18:59.036698
2018-06-14T03:50:15
2018-06-14T03:50:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
509
cpp
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include "RmwEdgeDetect.h" void XsyPicEnhance(BYTE *pGryImg, int width, int height, BYTE *pGrImg) { int LUT[256]; int i, g, ImgSize = width*height; BYTE *pGry, *pGr; XsySetImageBoundary(pGrImg, width, height, 0); for (g = 0; g < 256; g++) { LUT[g] = max(min(g + 30, 255), 0); } for (i = 0, pGry = pGryImg, pGr = pGrImg; i < ImgSize; i++, pGry ++, pGr ++) { *pGr = LUT[*pGry]; } }
58ce47059bc25683e3bf2540b5e89832e01c2fdf
5c3f6bdd0aa5446a78372c967d5a642c429b8eda
/src/support/lockedpool.h
9de97d4cdf48a297ce2dcc9856a9c0d928521748
[ "MIT" ]
permissive
GlobalBoost/GlobalBoost-Y
defeb2f930222d8b78447a9440d03cce9d8d602c
b4c8f1bb88ebbfa5016376fee9a00ae98902133f
refs/heads/master
2023-08-11T12:04:12.578240
2023-07-11T03:56:18
2023-07-11T03:56:18
23,804,954
20
22
MIT
2023-07-11T03:56:19
2014-09-08T19:26:43
C++
UTF-8
C++
false
false
8,047
h
// Copyright (c) 2016-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef GLOBALBOOST_SUPPORT_LOCKEDPOOL_H #define GLOBALBOOST_SUPPORT_LOCKEDPOOL_H #include <stdint.h> #include <list> #include <map> #include <mutex> #include <memory> #include <unordered_map> /** * OS-dependent allocation and deallocation of locked/pinned memory pages. * Abstract base class. */ class LockedPageAllocator { public: virtual ~LockedPageAllocator() {} /** Allocate and lock memory pages. * If len is not a multiple of the system page size, it is rounded up. * Returns 0 in case of allocation failure. * * If locking the memory pages could not be accomplished it will still * return the memory, however the lockingSuccess flag will be false. * lockingSuccess is undefined if the allocation fails. */ virtual void* AllocateLocked(size_t len, bool *lockingSuccess) = 0; /** Unlock and free memory pages. * Clear the memory before unlocking. */ virtual void FreeLocked(void* addr, size_t len) = 0; /** Get the total limit on the amount of memory that may be locked by this * process, in bytes. Return size_t max if there is no limit or the limit * is unknown. Return 0 if no memory can be locked at all. */ virtual size_t GetLimit() = 0; }; /* An arena manages a contiguous region of memory by dividing it into * chunks. */ class Arena { public: Arena(void *base, size_t size, size_t alignment); virtual ~Arena(); Arena(const Arena& other) = delete; // non construction-copyable Arena& operator=(const Arena&) = delete; // non copyable /** Memory statistics. */ struct Stats { size_t used; size_t free; size_t total; size_t chunks_used; size_t chunks_free; }; /** Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or * the application tried to allocate 0 bytes. */ void* alloc(size_t size); /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. * Raises std::runtime_error in case of error. */ void free(void *ptr); /** Get arena usage statistics */ Stats stats() const; #ifdef ARENA_DEBUG void walk() const; #endif /** Return whether a pointer points inside this arena. * This returns base <= ptr < (base+size) so only use it for (inclusive) * chunk starting addresses. */ bool addressInArena(void *ptr) const { return ptr >= base && ptr < end; } private: typedef std::multimap<size_t, char*> SizeToChunkSortedMap; /** Map to enable O(log(n)) best-fit allocation, as it's sorted by size */ SizeToChunkSortedMap size_to_free_chunk; typedef std::unordered_map<char*, SizeToChunkSortedMap::const_iterator> ChunkToSizeMap; /** Map from begin of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free; /** Map from end of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free_end; /** Map from begin of used chunk to its size */ std::unordered_map<char*, size_t> chunks_used; /** Base address of arena */ char* base; /** End address of arena */ char* end; /** Minimum chunk alignment */ size_t alignment; }; /** Pool for locked memory chunks. * * To avoid sensitive key data from being swapped to disk, the memory in this pool * is locked/pinned. * * An arena manages a contiguous region of memory. The pool starts out with one arena * but can grow to multiple arenas if the need arises. * * Unlike a normal C heap, the administrative structures are separate from the managed * memory. This has been done as the sizes and bases of objects are not in themselves sensitive * information, as to conserve precious locked memory. In some operating systems * the amount of memory that can be locked is small. */ class LockedPool { public: /** Size of one arena of locked memory. This is a compromise. * Do not set this too low, as managing many arenas will increase * allocation and deallocation overhead. Setting it too high allocates * more locked memory from the OS than strictly necessary. */ static const size_t ARENA_SIZE = 256*1024; /** Chunk alignment. Another compromise. Setting this too high will waste * memory, setting it too low will facilitate fragmentation. */ static const size_t ARENA_ALIGN = 16; /** Callback when allocation succeeds but locking fails. */ typedef bool (*LockingFailed_Callback)(); /** Memory statistics. */ struct Stats { size_t used; size_t free; size_t total; size_t locked; size_t chunks_used; size_t chunks_free; }; /** Create a new LockedPool. This takes ownership of the MemoryPageLocker, * you can only instantiate this with LockedPool(std::move(...)). * * The second argument is an optional callback when locking a newly allocated arena failed. * If this callback is provided and returns false, the allocation fails (hard fail), if * it returns true the allocation proceeds, but it could warn. */ explicit LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); LockedPool(const LockedPool& other) = delete; // non construction-copyable LockedPool& operator=(const LockedPool&) = delete; // non copyable /** Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or * the application tried to allocate 0 bytes. */ void* alloc(size_t size); /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. * Raises std::runtime_error in case of error. */ void free(void *ptr); /** Get pool usage statistics */ Stats stats() const; private: std::unique_ptr<LockedPageAllocator> allocator; /** Create an arena from locked pages */ class LockedPageArena: public Arena { public: LockedPageArena(LockedPageAllocator *alloc_in, void *base_in, size_t size, size_t align); ~LockedPageArena(); private: void *base; size_t size; LockedPageAllocator *allocator; }; bool new_arena(size_t size, size_t align); std::list<LockedPageArena> arenas; LockingFailed_Callback lf_cb; size_t cumulative_bytes_locked; /** Mutex protects access to this pool's data structures, including arenas. */ mutable std::mutex mutex; }; /** * Singleton class to keep track of locked (ie, non-swappable) memory, for use in * std::allocator templates. * * Some implementations of the STL allocate memory in some constructors (i.e., see * MSVC's vector<T> implementation where it allocates 1 byte of memory in the allocator.) * Due to the unpredictable order of static initializers, we have to make sure the * LockedPoolManager instance exists before any other STL-based objects that use * secure_allocator are created. So instead of having LockedPoolManager also be * static-initialized, it is created on demand. */ class LockedPoolManager : public LockedPool { public: /** Return the current instance, or create it once */ static LockedPoolManager& Instance() { std::call_once(LockedPoolManager::init_flag, LockedPoolManager::CreateInstance); return *LockedPoolManager::_instance; } private: explicit LockedPoolManager(std::unique_ptr<LockedPageAllocator> allocator); /** Create a new LockedPoolManager specialized to the OS */ static void CreateInstance(); /** Called when locking fails, warn the user here */ static bool LockingFailed(); static LockedPoolManager* _instance; static std::once_flag init_flag; }; #endif // GLOBALBOOST_SUPPORT_LOCKEDPOOL_H
[ "null" ]
null
3d4c60ac820f3cfa0ad46c88e10e3909495682fd
f3efdf8c4466a8e1dffa40282979d68958d2cb14
/atcoder.jp/abc220/abc220_b/Main.cpp
6da027eb810f2ae280450dd2b65b236ddcfee952
[]
no_license
bokusunny/atcoder-archive
be1abd03a59ef753837e3bada6c489a990dd4ee5
248aca070960ee5519df5d4432595298864fa0f9
refs/heads/master
2023-08-20T03:37:14.215842
2021-10-20T04:19:15
2021-10-20T04:19:15
355,762,924
2
0
null
null
null
null
UTF-8
C++
false
false
302
cpp
#include <bits/stdc++.h> using namespace std; void solve() { int K; cin >> K; string A, B; cin >> A >> B; cout << stoll(A, nullptr, K) * stoll(B, nullptr, K) << endl; } void setcin() { ios::sync_with_stdio(false); cin.tie(nullptr); } int main() { setcin(); solve(); return 0; }
6e7da4cba25a346e3001ec585738004f712adb83
d2a880ffe6656a3164fe228c7caf10f8d93e5cd6
/include/triangle_t.hpp
4c04eb359d6d050463dbee26186e7effcd148b4b
[]
no_license
YvanMokwinski/WBMESH
d12ad24e8dd006be19b88f513a69a68c18bf65f6
8b1d803e05a9bd57974e4f925dab6959493b8b54
refs/heads/master
2022-09-05T06:05:10.645787
2019-12-23T08:24:16
2019-12-23T08:24:16
229,704,688
0
0
null
null
null
null
UTF-8
C++
false
false
1,727
hpp
#pragma once struct triangle_t { private: int_t m_edges[3] {}; private: int m_ways[3] {}; private: int_t m_id {}; public: inline triangle_t() noexcept; public: inline triangle_t(int_t id_, int_t edges_[3], int ways_[3]) noexcept; public: inline int_t id () const noexcept; public: inline int_t edge (unsigned int i) const noexcept; public: inline int_t way (unsigned int i) const noexcept; public: inline void id (int_t id) noexcept; public: inline void edge (unsigned int i, int_t j ) noexcept; public: inline void way (unsigned int i, int w) noexcept; public: inline int get_local_edge_index(int_t edge) const noexcept; }; inline triangle_t::triangle_t() noexcept { }; inline triangle_t::triangle_t(int_t id_, int_t edges_[3], int ways_[3]) noexcept : m_id(id_) { this->m_edges[0] = edges_[0]; this->m_edges[1] = edges_[1]; this->m_edges[2] = edges_[2]; this->m_ways[0] = ways_[0]; this->m_ways[1] = ways_[1]; this->m_ways[2] = ways_[2]; }; inline int_t triangle_t::id() const noexcept { return this->m_id; }; inline int_t triangle_t::edge(unsigned int i) const noexcept { return this->m_edges[i]; }; inline int_t triangle_t::way(unsigned int i) const noexcept { return this->m_ways[i]; }; inline void triangle_t::id(int_t id) noexcept { this->m_id = id; }; inline void triangle_t::edge(unsigned int i,int_t j ) noexcept { this->m_edges[i] = j; }; inline void triangle_t::way(unsigned int i,int w) noexcept { this->m_ways[i] = w; }; inline int triangle_t::get_local_edge_index(int_t edge) const noexcept { for (int i=0;i<3;++i) { if (edge == this->m_edges[i]) { return i; } } return -1; };
db53fb07f6fafacf9d0abc733df0c684c962796d
7a0f8abeea80024d6c4fdd663a6ccf4647e4fe24
/src/tools/mapeditor/mapeditor.cpp
9b2f86ef20325dc4645e81ff772f09e8313844f1
[ "MIT" ]
permissive
OhmPopy/eepp
fd6cd21d550b02d210e74e9026dd0473b6d8c661
dcf608a2283cb4915b4bb43a33522c57f4dc4eba
refs/heads/master
2020-04-30T19:38:43.782180
2018-12-16T23:41:27
2018-12-16T23:41:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,712
cpp
#include <eepp/ee.hpp> EE::Window::Window * win = NULL; UIMessageBox * MsgBox = NULL; MapEditor * Editor = NULL; bool onCloseRequestCallback( EE::Window::Window * w ) { if ( NULL != Editor ) { MsgBox = UIMessageBox::New( MSGBOX_OKCANCEL, "Do you really want to close the current map?\nAll changes will be lost." ); MsgBox->addEventListener( Event::MsgBoxConfirmClick, cb::Make1<void, const Event*>( []( const Event * event ) { win->close(); } ) ); MsgBox->addEventListener( Event::OnClose, cb::Make1<void, const Event*>( []( const Event * event ) { MsgBox = NULL; } ) ); MsgBox->setTitle( "Close Map?" ); MsgBox->center(); MsgBox->show(); return false; } else { return true; } } void mainLoop() { win->getInput()->update(); if ( win->getInput()->isKeyUp( KEY_ESCAPE ) && NULL == MsgBox && onCloseRequestCallback( win ) ) { win->close(); } SceneManager::instance()->update(); if ( SceneManager::instance()->getUISceneNode()->invalidated() ) { win->clear(); SceneManager::instance()->draw(); win->display(); } else { Sys::sleep( Milliseconds(8) ); } } EE_MAIN_FUNC int main (int argc, char * argv []) { Display * currentDisplay = Engine::instance()->getDisplayManager()->getDisplayIndex(0); Float pixelDensity = PixelDensity::toFloat( currentDisplay->getPixelDensity() ); DisplayMode currentMode = currentDisplay->getCurrentMode(); Uint32 width = eemin( currentMode.Width, (Uint32)( 1280 * pixelDensity ) ); Uint32 height = eemin( currentMode.Height, (Uint32)( 720 * pixelDensity ) ); win = Engine::instance()->createWindow( WindowSettings( width, height, "eepp - Map Editor", WindowStyle::Default, WindowBackend::Default, 32, "assets/icon/ee.png", pixelDensity ), ContextSettings( true, GLv_default, true, 24, 1, 0, false ) ); if ( win->isOpen() ) { win->setCloseRequestCallback( cb::Make1( onCloseRequestCallback ) ); SceneManager::instance()->add( UISceneNode::New() ); { std::string pd; if ( PixelDensity::getPixelDensity() >= 1.5f ) pd = "1.5x"; else if ( PixelDensity::getPixelDensity() >= 2.f ) pd = "2x"; TextureAtlasLoader tgl( "assets/ui/uitheme" + pd + ".eta" ); UITheme * theme = UITheme::loadFromTextureAtlas( UIThemeDefault::New( "uitheme" + pd, "uitheme" + pd ), TextureAtlasManager::instance()->getByName( "uitheme" + pd ) ); FontTrueType * font = FontTrueType::New( "NotoSans-Regular", "assets/fonts/NotoSans-Regular.ttf" ); UIThemeManager::instance()->setDefaultEffectsEnabled( true )->setDefaultTheme( theme )->setDefaultFont( font )->add( theme ); } Editor = MapEditor::New(); win->runMainLoop( &mainLoop ); } Engine::destroySingleton(); MemoryManager::showResults(); return EXIT_SUCCESS; }
4ec653190b2d30d22c136545c849e28c4a91d0bb
e99e9c08f9b60909b9880ab42943a9d1c654df37
/Window/Main.cpp
d4fc4e67dc713b0ce7310df709ef424467b2e950
[]
no_license
stac21/OpenGL-Demos
5063184ed4e7bbe2d9dc6f33b9a07ade36a846b3
531051f08b476a3064e6f78fdc492b48a6e7cabc
refs/heads/master
2020-08-02T15:15:07.409546
2019-09-27T21:21:53
2019-09-27T21:21:53
211,403,063
0
0
null
null
null
null
UTF-8
C++
false
false
3,977
cpp
#include <glad/glad.h> #include <glfw3.h> #include <iostream> void framebuffer_size_callback(GLFWwindow* window, int width, int height); void process_input(GLFWwindow* window); int main() { constexpr int WINDOW_WIDTH = 800; constexpr int WINDOW_HEIGHT = 600; glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); /* Create a window object. If the window is null, exit the program and give an error message. */ GLFWwindow* window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } /* Make the context of the window the main context on the current thread */ glfwMakeContextCurrent(window); /* initialize GLAD before we calll any OpenGL function because GLAD manages function pointers for OpenGL. We pass GLAD the function to load the address of the OpenGL function pointers which is OS-specific. GLFW gives glfwGetProcAdress which gives us the correct function based on the OS we're compiling for. */ if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; } /* Tell OpenGL the size of the rendering window so OpenGL knows how we want to display the data and coordinates with respect to the window. First and second arguments set the location of the lower left corner of the window. Third and fourth arguments set the width and height of the rendering window in pixels. Note: Behind the scenes OpenGL uses the data specified via glViewport to transform the 2D coordinates it processed to coordinates on your screen. For example, a processed point of location (-0.5,0.5) would (as its final transformation) be mapped to (200,450) in screen coordinates. Note that processed coordinates in OpenGL are between -1 and 1 so we effectively map from the range (-1 to 1) to (0, 800) and (0, 600). */ glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); /* Register the automatic window resize function to GLFW */ glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); /* Standard single threaded game loop */ while (!glfwWindowShouldClose(window)) { // input process_input(window); // rendering glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); /* Double buffer When an application draws in a single buffer the resulting image might display flickering issues. This is because the resulting output image is not drawn in an instant, but drawn pixel by pixel and usually from left to right and top to bottom. Because these images are not displayed at an instant to the user, but rather via a step by step generation the result may contain quite a few artifacts. To circumvent these issues, windowing applications apply a double buffer for rendering. The front buffer contains the final output image that is shown at the screen, while all the rendering commands draw to the back buffer. As soon as all the rendering commands are finished we swap the back buffer to the front buffer so the image is instantly displayed to the user, removing all the aforementioned artifacts. */ glfwSwapBuffers(window); /* checks if any events are triggered such as keyboard or mouse input, updates the window state, and calls the corresponding functions which can be set using callback functions */ glfwPollEvents(); } /* Clean up all the resources and properly exit the application */ glfwTerminate(); return 0; } void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } void process_input(GLFWwindow* window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } }
a6d35bf70c46a1070adb42a8ad9a249600361088
558ab992909e5a5d9348e262901a1ffa2a654bf8
/RendererOpenGL/Classes/Maths/vector_func.inl
72a2a1075e2f2d7655fa99951b8182833bf48a46
[]
no_license
JacobCeron/RendererOpenGL
c96a7686ae2609246d98f2e64bf6179c2fe097d1
177164d6fdf5ba163dd3800d70bec982a425d9c2
refs/heads/master
2020-03-18T20:27:45.952258
2018-06-07T19:08:57
2018-06-07T19:08:57
135,217,436
0
0
null
null
null
null
UTF-8
C++
false
false
1,565
inl
template<typename T, template<typename, size_t> class vecType, size_t N> inline T magnitud(const vecType<T, N>& x) { return static_cast<T>(sqrtf(dot(x, x))); } template<typename T, template<typename, size_t> class vecType, size_t N> inline T distance(const vecType<T, N>& p0, const vecType<T, N>& p1) { return magnitud(p0 - p1); } template<typename T, template<typename, size_t> class vecType, size_t N> inline T dot(const vecType<T, N>& x, const vecType<T, N>& y) { vecType<T, N> temp(x * y); T r{ static_cast<T>(0) }; for (size_t i{ 0 }; i < temp.length(); i++) r += temp[i]; return r; } template<typename T, template<typename, size_t> class vecType, size_t N> inline vecType<T, N> normalize(const vecType<T, N>& v) { return v / magnitud(v); } template<typename T> inline t_vec3<T, 3> cross(const t_vec3<T, 3>& x, const t_vec3<T, 3>& y) { return t_vec3<T, 3> ( x.y * y.z - x.z * y.y, x.z * y.x - x.x * y.z, x.x * y.y - x.y * y.x ); } template<typename T, template<typename, size_t> class vecType, size_t N> inline vecType<T, N> reflect(const vecType<T, N>& I, const vecType<T, N>& N) { return vecType<T, N>(I - static_cast<T>(2) * dot(N, I) * N); } template<typename T, template<typename, size_t> class vecType, size_t N> inline vecType<T, N> refract(const vecType<T, N>& I, const vecType<T, N>& N, float eta) { T k{ 1.0f - eta * eta * (1.0f - dot(N, I) * dot(N, I)) }; if (k < static_cast<T>(0)) return vecType<T, N>(static_cast<T>(0)); else return vecType<T, N>(eta * I - (eta * dot(N, I) + static_cast<T>(sqrtf(k))) + N); }
b26272442bd0b0c5a8a1be4aa46675c2ff1170e6
82cba95cdaa7c7eb84bac8f9a19077c5f7bdca0d
/Smart_Electricity_Sensor/Smart_Electricity_Sensor.ino
985dd63bcb0819f407eb12610d43659d66aa1ee8
[]
no_license
santronix/iot_tutorials-mediatek-code
4894072b20ef67a4fe6e43242e3c44fcda15bfce
1acdffd39e921e500f767efc9c28e1ab26fea2ef
refs/heads/master
2020-04-14T09:00:30.819373
2019-09-02T15:05:59
2019-09-02T15:05:59
163,749,425
0
0
null
null
null
null
UTF-8
C++
false
false
2,553
ino
/******************************************************* * SANTRONIX <[email protected]> * * This file is part of SANTRONIX Mediatek LinkIt Tutorials Project. * * SANTRONIX Mediatek LinkIt Tutorials Project can not be copied and/or distributed without the express * permission of SANTRONIX *******************************************************/ #include <math.h> #include <Wire.h> #include <SeeedOLED.h> //Connect Electricity sensor at Analog Input A0 #define ELECTRICITY_SENSOR A0 // Analog input pin that sensor is attached to float amplitude_current; //amplitude current float effective_value; //effective current void setup() { Serial.begin(9600); pinMode(ELECTRICITY_SENSOR, INPUT); Wire.begin(); SeeedOled.init(); //initialze SEEED OLED display SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner SeeedOled.setNormalDisplay(); //Set display to normal mode (i.e non-inverse mode) SeeedOled.setPageMode(); //Set addressing mode to Page Mode } void loop() { int sensor_max; sensor_max = getMaxValue(); //the VCC on the Grove interface of the sensor is 5v amplitude_current=(float)sensor_max/1024*5/800*2000000; effective_value=amplitude_current/1.414;//minimum_current=1/1024*5/800*2000000/1.414=8.6(mA) //Only for sinusoidal alternating current SeeedOled.setTextXY(0,0); //Set the cursor to Xth Page, Yth Column SeeedOled.putString("Max Value:"); SeeedOled.putFloat(sensor_max, 0); SeeedOled.putString("mA"); SeeedOled.setTextXY(2,0); //Set the cursor to Xth Page, Yth Column SeeedOled.putString("Amplitude:"); //Print the String SeeedOled.putFloat(amplitude_current,0); SeeedOled.putString("mA"); SeeedOled.setTextXY(4,0); //Set the cursor to Xth Page, Yth Column SeeedOled.putString("Current:"); SeeedOled.putFloat(effective_value,2); SeeedOled.putString("mA"); } /*Function: Sample for 1000ms and get the maximum value from the SIG pin*/ int getMaxValue() { int sensorValue; //value read from the sensor int sensorMax = 0; uint32_t start_time = millis(); while((millis()-start_time) < 1000)//sample for 1000ms { sensorValue = analogRead(ELECTRICITY_SENSOR); if (sensorValue > sensorMax) { /*record the maximum sensor value*/ sensorMax = sensorValue; } } return sensorMax; }
7ceee151d4164c0456e30663db9f0987297a3ce5
97e61950cfc755ff5ba320f2ca0fd1c5a58b5723
/pa4/pa4.cpp
7b4e9a9d58772f6bb109d36dc7d5fb4c065a3faa
[]
no_license
JulianHarris831/cpsc2430-
1f220ecadd2b124a352c3e19d6113d8cd4fa633b
a72421b6f2b78547bd9c4e362e78fc8a8e9f9c94
refs/heads/main
2023-08-02T20:56:51.923115
2021-10-05T19:08:48
2021-10-05T19:08:48
384,519,121
0
0
null
null
null
null
UTF-8
C++
false
false
1,408
cpp
//Julian Harris //pa4.cpp //11/2/2020 //DESCRIPTION: Program creates a max heap with dynamic array implementation to // store words entered by the user. Allows user to print children // of the words in the heap, and shows all values entered once // heap is made empty. //ASSUMPTIONS: User enters a positive integer as the size of the heap. //this is an edit for the makefile #include <iostream> #include "heap.h" using namespace std; //initial array size is 5 (4); int main() { WordHeap myTest; //class heap to store words in int userAdding; //size user enters, how many values will be added string userWord; //var to store temporarily values user inserts cout << "\nHow many values do you want to add to the heap? "; cin >> userAdding; cin.ignore(); //test of insert for(int i = 0; i < userAdding; i++){ cout << "Enter a word you want to add: "; getline(cin, userWord); myTest.insert(userWord); } cout << '\n'; //test of printChildren for(int i = 0; i < 2; i++){ cin.ignore(); cout << "Enter a word you want to print the children of: "; getline(cin, userWord); myTest.printChildren(userWord); } //test of copy constructor and copy assignment WordHeap myCopy(myTest); WordHeap myAssignment; myAssignment = myCopy; //test of makeEmpty myAssignment.makeEmpty(); return 0; } //bodies
06d33cacf398401c85dbfb36c1d1dcd138f5cd82
fc7d9bbe049114ad5a94a6107321bdc09d3ccf53
/.history/Maze_20210920160653.h
1af5b9546b19e880e0403cf141e408da3fa8e03e
[]
no_license
xich4932/3010_maze
2dbf7bb0f2be75d014a384cbefc4095779d525b5
72be8a7d9911efed5bc78be681486b2532c08ad8
refs/heads/main
2023-08-11T00:42:18.085853
2021-09-22T03:29:40
2021-09-22T03:29:40
408,272,071
0
0
null
null
null
null
UTF-8
C++
false
false
2,871
h
#ifndef MAZE_H #define MAZE_H #include <vector> #include <iostream> #include "Player.h" // you may change this enum as you need // 0 1 2 3 4 5 enum class SquareType { Wall, Exit, Empty, Human, Enemy, Treasure }; static const std::string arr_enum[] = {"Wall", "Exit", "Empty", "Human", "Enemy", "Treasure"}; // TODO: implement // this function should return a string representation of a given SquareType // for example an ascii letter or an emoji std::string SquareTypeStringify(SquareType sq){ switch (sq) { case Wall: /* code */ break; default: break; } } class Board { public: // TODO: implement Board(); Board(int , int ); // already implemented in line int get_rows() const {return rows_; } // you should be able to change the size of your int get_cols() const {return cols_; } // board by changing these numbers and the numbers in the arr_ field void displayUpdated(); //display the board} std::vector<int> getPath(){return path;}; //generate path of maze bool generate(); SquareType get_square_value(Position pos) const; // TODO: you MUST implement the following functions // set the value of a square to the given SquareType void SetSquareValue(Position pos, SquareType value); // get the possible Positions that a Player could move to // (not off the board or into a wall) std::vector<Position> GetMoves(Player *p); // Move a player to a new position on the board. Return // true if they moved successfully, false otherwise. bool MovePlayer(Player *p, Position pos); // Get the square type of the exit square∏ SquareType GetExitOccupant(); // You probably want to implement this friend std::ostream& operator<<(std::ostream& os, const Board &b); private: SquareType arr_[4][4]; std::vector<int> path; int rows_; // might be convenient but not necessary int cols_; // you may add more fields, as needed }; // class Board class Maze { public: // TODO: implement these functions Maze(int , int, std::string); // constructor ~Maze(); // initialize a new game, given one human player and // a number of enemies to generate void NewGame(Player *human, const int enemies); // have the given Player take their turn void TakeTurn(Player *p); // Get the next player in turn order Player * GetNextPlayer(); // return true iff the human made it to the exit // or the enemies ate all the humans bool IsGameOver(); // You probably want to implement these functions as well // string info about the game's conditions after it is over std::string GenerateReport(); friend std::ostream& operator<<(std::ostream& os, const Maze &m); private: Board *board_; // HINT: when you instantiate your board_, use the new Board() syntax std::vector<Player *> players_; int turn_count_; // you may add more fields, as needed }; // class Maze #endif // MAZE_H
6a94b5f72a0943bf90c7aa055c12c04387100146
dfa4dc97a231ecae28a6295266581746a97573e8
/include/rvg/text.hpp
ba30b3f458a696dd38ea0097908e8142a3f750a2
[ "BSL-1.0" ]
permissive
foow/rvg
341dc0e87ee8678969faa99a5a71ab4e9be8ee4a
1a6bf177f1f1734c8656fbacbe54512f5230eefb
refs/heads/master
2023-03-07T00:54:18.882382
2021-02-14T12:01:42
2021-02-14T12:01:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,499
hpp
// Copyright (c) 2018 nyorain // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt #pragma once #include <rvg/fwd.hpp> #include <rvg/deviceObject.hpp> #include <rvg/font.hpp> #include <rvg/stateChange.hpp> #include <nytl/vec.hpp> #include <nytl/matOps.hpp> #include <nytl/rect.hpp> #include <vpp/descriptor.hpp> #include <vpp/sharedBuffer.hpp> #include <string> #include <string_view> namespace rvg { /// Represents text to be drawn. /// Also offers some utility for bounds querying. class Text : public DeviceObject { public: Text() = default; Text(Context&, Vec2f pos, std::string text, const Font&, float height); Text(Text&& rhs) noexcept; Text& operator=(Text&& rhs) noexcept; ~Text(); /// Draws this text with the bound draw resources (transform, /// scissor, paint). void draw(vk::CommandBuffer) const; auto change() { return StateChange {*this, state_}; } bool disable(bool); bool disabled() const { return disable_; } /// Changes the device local state for this text. /// If unequal the previous value, will always recreate the buffer and /// trigger a rerecord. void deviceLocal(bool set); bool deviceLocal() const { return deviceLocal_; } /// Computes which char index lies at the given relative x. /// Returns the index of the char at the given x, or the index of /// the next one if there isn't any. Returns text.length() if x is /// after all chars. /// Must not be called during a state change. unsigned charAt(float x) const; /// Returns the (local) bounds of the full text Rect2f bounds() const; /// Returns the bounds of the ith char in local coordinates. Rect2f ithBounds(unsigned n) const; const auto& font() const { return state_.font; } const auto& text() const { return state_.text; } const auto& position() const { return state_.position; } float height() const { return state_.height; } float width() const; void update(); bool updateDevice(); protected: struct State { std::string text {}; Font font {}; // must not be set to invalid font Vec2f position {}; // baseline position of first character float height {}; // height to use // pre-transform nytl::Mat3f transform = nytl::identity<3, float>(); } state_; bool disable_ {}; bool deviceLocal_ {false}; std::vector<Vec2f> posCache_; std::vector<Vec2f> uvCache_; vpp::SubBuffer posBuf_; vpp::SubBuffer uvBuf_; FontAtlas* oldAtlas_ {}; }; } // namespace rvg