blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
327a5d0481eb5f243d87c54300f99d47de0924b3 | 37a7fbfe78db40ab5ad289182b81333eac153812 | /AA/lab2/main.cpp | 2e5d8ca04ce76338fb7e9d1c8575f0ab6e05db87 | [] | no_license | chudilo/study | a7ce73b801c8d863e82f6ea7a31cef2f5389444e | 47546c24cead2e3d708cf5e262c88fccd7216871 | refs/heads/master | 2020-03-30T21:01:54.310085 | 2019-06-21T04:39:02 | 2019-06-21T04:39:02 | 151,614,030 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,466 | cpp | #include <cstdio>
#include "matrix_func.h"
#include "get_time.h"
//#define SIZE 1000
#define TIMES 10
int main() {
for(int i = 0; i < 20; i++) {
int SIZE = 100 + i*100;
int **matrA = matrixCreate(SIZE,SIZE);
int **matrB = matrixCreate(SIZE,SIZE);
int **resMatr = matrixCreate(SIZE,SIZE);
double t1, t2, restimeMult = 0, restimeVin = 0, restimeVinUpgr = 0;
for(int j = 0; j < TIMES; j++) {
matrixFillRand(matrA, SIZE, SIZE);
matrixFillRand(matrB, SIZE, SIZE);
matrixFillZero(resMatr, SIZE, SIZE);
t1 = getCPUTime( );
matrixMult(matrA,matrB,resMatr,SIZE);
t2 = getCPUTime( );
//matrixPrint(resMatr,SIZE,SIZE);
restimeMult += (t2-t1);
matrixFillZero(resMatr, SIZE, SIZE);
t1 = getCPUTime( );
matrixMultVinograd(matrA,matrB,resMatr,SIZE);
t2 = getCPUTime( );
//matrixPrint(resMatr,SIZE,SIZE);
restimeVin += (t2-t1);
matrixFillZero(resMatr, SIZE, SIZE);
t1 = getCPUTime( );
matrixMultVinogradUpgr(matrA,matrB,resMatr,SIZE);
t2 = getCPUTime( );
//matrixPrint(resMatr,SIZE,SIZE);
restimeVinUpgr += (t2-t1);
}
printf("Proc time for %d elements casual mult :\n%f\n", SIZE, restimeMult/TIMES);
printf("Proc time for %d elements Vinograd mult :\n%f\n", SIZE, restimeVin/TIMES);
printf("Proc time for %d elements upgrade Vinograd mult:\n%f\n",SIZE, restimeVinUpgr/TIMES);
puts("");
matrixFree(matrA,SIZE);
matrixFree(matrB,SIZE);
matrixFree(resMatr,SIZE);
}
}
| [
"chudik97@yandex.ru"
] | chudik97@yandex.ru |
34cbe7dcb6a64c5235bb6f2091e7a52253199bf5 | f04dc850b9745eaf6badd9a788aece2602989a40 | /src/gui/clientwindow.cpp | e7dc63ac19dec2255faf13eca69a6d9666981149 | [] | no_license | bartromgens/clientserver | 89616a4689668102ced10297856a87562b618d77 | 8d8a7fe54616e3af5739f8f2f29cc0301d2c5116 | refs/heads/master | 2016-09-05T08:51:11.527630 | 2014-12-13T18:28:32 | 2014-12-13T18:28:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,108 | cpp | #include "clientwindow.h"
#include "ui_clientwindow.h"
#include "shared/message.h"
#include "shared/messagejson.h"
#include <thread>
ClientWindow::ClientWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ClientWindow),
m_clients(),
m_timer(new QTimer(this)),
m_time()
{
ui->setupUi(this);
m_time.start();
createActions();
connect(m_timer, SIGNAL(timeout()), this, SLOT(update()));
m_timer->start(1000);
}
ClientWindow::~ClientWindow()
{
delete ui;
}
void
ClientWindow::createActions()
{
QAction* actionStartClient = new QAction("New Client", this);
ui->mainToolBar->addAction(actionStartClient);
connect(actionStartClient, SIGNAL(triggered()), this, SLOT(slotCreateClient()));
QAction* actionConnectClients = new QAction("Connect Clients", this);
ui->mainToolBar->addAction(actionConnectClients);
connect(actionConnectClients, SIGNAL(triggered()), this, SLOT(slotConnectAllClients()));
QAction* actionDisonnectClients = new QAction("Disconnect Clients", this);
ui->mainToolBar->addAction(actionDisonnectClients);
connect(actionDisonnectClients, SIGNAL(triggered()), this, SLOT(slotDisconnectAllClients()));
QAction* actionCrash = new QAction("Crash", this);
ui->mainToolBar->addAction(actionCrash);
connect(actionCrash, SIGNAL(triggered()), this, SLOT(slotCrash()));
QAction* actionRunClients = new QAction("Run Clients", this);
ui->mainToolBar->addAction(actionRunClients);
connect(actionRunClients, SIGNAL(triggered()), this, SLOT(slotRunClients()));
}
void
ClientWindow::update()
{
}
void
ClientWindow::slotCreateClient()
{
m_clients.push_back(std::unique_ptr<Client>(new Client()));
}
void
ClientWindow::slotConnectAllClients()
{
for (std::size_t i = 0; i < m_clients.size(); ++i)
{
try
{
m_clients[i]->connect();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
}
}
void
ClientWindow::slotDisconnectAllClients()
{
for (std::size_t i = 0; i < m_clients.size(); ++i)
{
m_clients[i]->disconnect();
}
}
void
ClientWindow::slotCrash() const
{
std::vector<int> vector(0);
vector[1] = 0;
}
void
ClientWindow::slotRunClients()
{
m_time.restart();
for (unsigned int i = 0; i < m_clients.size(); ++i)
{
if (m_clients[i]->isConnected())
{
runClientTest(i);
}
}
std::cout << "ClientWindow::slotRunClients() : time elapsed: " << m_time.elapsed() << std::endl;
}
void
ClientWindow::runClientTest(int id)
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
GetParameters command;
std::string json = command.serialize();
std::cout << json << std::endl;
Message message(0, 0);
message.setData( json );
Message reply = m_clients[id]->sendMessage( message );
Parameters parametersMessage;
parametersMessage.deserialize( reply.getData() );
std::vector<Parameter> parameters = parametersMessage.getParameters();
std::cout << "parameters received: " << std::endl;
for (auto iter = parameters.begin(); iter != parameters.end(); ++iter)
{
std::cout << iter->id << ", " << iter->name << std::endl;
}
}
| [
"bart.romgens@gmail.com"
] | bart.romgens@gmail.com |
d4cecbf178e989734a3a26418ba67637c7a49a18 | d7bb352cf956e517967eabb77af8ace595ec17b9 | /include/mono-vo/CameraInfo.h | 4607fc0fdff81ad2a946d2e7ac33720a0f5a6137 | [] | no_license | Sino0904/DAQ | ed013cf4ca2069ec6d4588f8429d747fe05813ea | 6fe329263a39816946c94d44ecda8be2716f95e9 | refs/heads/master | 2021-06-01T09:16:09.369178 | 2016-08-11T12:03:14 | 2016-08-11T12:03:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,182 | h | #include <opencv2/core/core.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <iostream>
#include <string>
class CameraInfo
{
public:
cv::FileStorage CalibrationData;
cv::FileStorage CharacteristicsFile;
cv::Mat IntrinsicParameters;
cv::Mat ExtrinsicParameters;
cv::Mat DistortionCoefficients;
int ImageWidth;
int ImageHeight;
double FoVx;
double FoVy;
static const double ApertureWidth = 3.67;
static const double ApertureHeight = 2.74;
double FocalLength;
double AspectRatio;
cv::Point2d PrincipalPoint;
void SaveCharacteristics(const std::string& Source)
{
CharacteristicsFile = cv::FileStorage(Source,cv::FileStorage::WRITE);
CharacteristicsFile << "IntrinsicParameters" << IntrinsicParameters;
CharacteristicsFile << "ExtrinsicParameters" << ExtrinsicParameters;
CharacteristicsFile << "DistortionCoefficients" << DistortionCoefficients;
CharacteristicsFile << "AperatureWidth" << ApertureWidth;
CharacteristicsFile << "AperatureHeight" << ApertureHeight;
CharacteristicsFile << "FocalLength" << FocalLength;
CharacteristicsFile << "AspectRatio" << AspectRatio;
CharacteristicsFile << "PrincipalPoint" << PrincipalPoint;
CharacteristicsFile << "FoVx" << FoVx;
CharacteristicsFile << "FoVy" << FoVy;
CharacteristicsFile << "ImageWidth" << ImageWidth;
CharacteristicsFile << "ImageHeight" << ImageHeight;
CharacteristicsFile.release();
}
bool ReadCalibrationData(const std::string& Source)
{
if (CalibrationData.open(Source,cv::FileStorage::READ))
{
CalibrationData["image_width"] >> ImageWidth;
CalibrationData["image_height"] >> ImageHeight;
CalibrationData["camera_cv::Matrix"] >> IntrinsicParameters;
CalibrationData["distortion_coefficients"] >> DistortionCoefficients;
CalibrationData["extrinsic_parameters"] >> ExtrinsicParameters;
std::cout << "Extracting Inforcv::Mation from Camera cv::Matrix" << std::endl;
calibrationMatrixValues(IntrinsicParameters,cv::Size(ImageWidth,ImageHeight),ApertureWidth,ApertureHeight,FoVx,FoVy,FocalLength,PrincipalPoint,AspectRatio);
std::cout << "Extraction Done, Values Stored" << std::endl;
return 1;
}
else
{
std::cout << "Invalid Calibration Data File!" << std::endl;
return 0;
}
CalibrationData.release();
}
bool ReadCharacteristics(const std::string& Source)
{
if (CharacteristicsFile.open(Source,cv::FileStorage::READ))
{
CharacteristicsFile["IntrinsicParameters"] >> IntrinsicParameters;
CharacteristicsFile["ExtrinsicParameters"] >> ExtrinsicParameters;
CharacteristicsFile["DistortionCoefficients"] >> DistortionCoefficients;
CharacteristicsFile["AperatureWidth"] >> ApertureWidth;
CharacteristicsFile["AperatureHeight"] >> ApertureHeight;
CharacteristicsFile["AspectRation"] >> AspectRatio;
CharacteristicsFile["ImageWidth"] >> ImageWidth;
CharacteristicsFile["ImageHeight"] >> ImageHeight;
CharacteristicsFile["FoVx"] >> FoVx;
CharacteristicsFile["FoVy"] >> FoVy;
CharacteristicsFile["FocalLength"] >> FocalLength;
}
else
{
std::cout << "Invalid Characteristics File !" << std::endl;
}
}
};
| [
"mahmoud.abdulgalil@gmail.com"
] | mahmoud.abdulgalil@gmail.com |
8a8fad528f8ec63a3421c4e3970a3de6cee4b81b | 1bd2698bde9265ab4741358c2b8e1bec1901e7f9 | /Tonb0.1/AutLib/Continuum/Mesh/Alg/AdvFront/Entities/Front/Identifiers/LocalFrontIdentifiers_FrontEntity.hxx | 1717c8b794652aaad7e1edc178a81a327dac8e76 | [] | no_license | amir5200fx/Tonb0.1 | 150f9843ce3ad02da2ef18f409a100964c08983a | 7b17c6d2b3ddeca8e6b2900967b9599b0b1d61ed | refs/heads/master | 2022-01-17T09:47:25.291502 | 2019-06-14T13:27:39 | 2019-06-14T13:27:39 | 169,406,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,249 | hxx | #pragma once
#ifndef _LocalFrontIdentifiers_FrontEntity_Header
#define _LocalFrontIdentifiers_FrontEntity_Header
#include <Standard_TypeDef.hxx>
#include <error.hxx>
namespace AutLib
{
template<class Point>
class LocalFrontIdentifiers_FrontEntity
{
/*Private Data*/
//- Centre of entity
Point theCentre_;
Standard_Real theCharLength_;
Standard_Boolean IsOnCavity_;
public:
LocalFrontIdentifiers_FrontEntity()
: theCharLength_(0)
{}
const Point& Centre() const
{
return theCentre_;
}
Point& Centre()
{
return theCentre_;
}
Standard_Real CharLength() const
{
return theCharLength_;
}
Standard_Real& CharLength()
{
return theCharLength_;
}
Standard_Boolean IsOnCavity() const
{
return IsOnCavity_;
}
Standard_Boolean& IsOnCavity()
{
return IsOnCavity_;
}
void SetCentre(const Point& theCoord)
{
theCentre_ = theCoord;
}
void SetCharLength(const Standard_Real theLength)
{
Debug_If_Condition(theLength <= 0);
theCharLength_ = theLength;
}
void MarkEntityAsCavity()
{
IsOnCavity_ = Standard_True;
}
void RemoveEntityAsCavity()
{
IsOnCavity_ = Standard_False;
}
};
}
#endif // !_LocalFrontIdentifiers_FrontEntity_Header
| [
"aasoleimani86@gmail.com"
] | aasoleimani86@gmail.com |
1c264be53902347bb202a2a4a0e23c2da30ffeec | 7a8ba610ac92c458e77ac533020e59547c8c06da | /xerces/xerces-c-3.2.0/src/xercesc/framework/psvi/XSNamespaceItem.cpp | 24538a63b8874b2ad603d723ef5d9f022fc0fe4f | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | DolbyLaboratories/pmd_tool | b29dc50400024f7da3ba651675ced360c7d4b91c | 4c6d27df5f531d488a627f96f489cf213cbf121a | refs/heads/master | 2022-10-23T19:45:29.418814 | 2021-08-13T03:13:47 | 2021-08-13T03:13:47 | 160,738,449 | 16 | 0 | BSD-3-Clause | 2021-08-13T03:13:48 | 2018-12-06T22:07:14 | C++ | UTF-8 | C++ | false | false | 7,464 | cpp | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XSNamespaceItem.cpp 674012 2008-07-04 11:18:21Z borisk $
*/
#include <xercesc/framework/psvi/XSNamespaceItem.hpp>
#include <xercesc/validators/schema/SchemaGrammar.hpp>
#include <xercesc/framework/psvi/XSModel.hpp>
#include <xercesc/framework/psvi/XSAnnotation.hpp>
#include <xercesc/validators/schema/XMLSchemaDescriptionImpl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// XSNamespaceItem: Constructors and Destructors
// ---------------------------------------------------------------------------
XSNamespaceItem::XSNamespaceItem(XSModel* const xsModel,
SchemaGrammar* const grammar,
MemoryManager* const manager)
: fMemoryManager(manager)
, fGrammar(grammar)
, fXSModel(xsModel)
, fXSAnnotationList(0)
, fSchemaNamespace(grammar->getTargetNamespace())
{
// Populate XSNamedMaps by going through the components
for (XMLSize_t i=0; i<XSConstants::MULTIVALUE_FACET; i++)
{
switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
case XSConstants::TYPE_DEFINITION:
case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
case XSConstants::MODEL_GROUP_DEFINITION:
case XSConstants::NOTATION_DECLARATION:
fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
20, // size
29, // modulus
fXSModel->getURIStringPool(),
false, // adoptElems
fMemoryManager
);
fHashMap[i] = new (fMemoryManager) RefHashTableOf<XSObject>
(
29,
false,
fMemoryManager
);
break;
default:
// ATTRIBUTE_USE
// MODEL_GROUP
// PARTICLE
// IDENTITY_CONSTRAINT
// WILDCARD
// ANNOTATION
// FACET
// MULTIVALUE
fComponentMap[i] = 0;
fHashMap[i] = 0;
break;
}
}
fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (5, false, manager);
}
XSNamespaceItem::XSNamespaceItem(XSModel* const xsModel,
const XMLCh* const schemaNamespace,
MemoryManager* const manager)
: fMemoryManager(manager)
, fGrammar(0)
, fXSModel(xsModel)
, fXSAnnotationList(0)
, fSchemaNamespace(schemaNamespace)
{
// Populate XSNamedMaps by going through the components
for (XMLSize_t i=0; i<XSConstants::MULTIVALUE_FACET; i++)
{
switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
case XSConstants::TYPE_DEFINITION:
case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
case XSConstants::MODEL_GROUP_DEFINITION:
case XSConstants::NOTATION_DECLARATION:
fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
20, // size
29, // modulus
fXSModel->getURIStringPool(),
false, // adoptElems
fMemoryManager
);
fHashMap[i] = new (fMemoryManager) RefHashTableOf<XSObject>
(
29,
false,
fMemoryManager
);
break;
default:
// ATTRIBUTE_USE
// MODEL_GROUP
// PARTICLE
// IDENTITY_CONSTRAINT
// WILDCARD
// ANNOTATION
// FACET
// MULTIVALUE
fComponentMap[i] = 0;
fHashMap[i] = 0;
break;
}
}
fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (5, false, manager);
}
XSNamespaceItem::~XSNamespaceItem()
{
for (XMLSize_t i=0; i<XSConstants::MULTIVALUE_FACET; i++)
{
switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
case XSConstants::TYPE_DEFINITION:
case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
case XSConstants::MODEL_GROUP_DEFINITION:
case XSConstants::NOTATION_DECLARATION:
delete fComponentMap[i];
delete fHashMap[i];
break;
}
}
delete fXSAnnotationList;
}
// ---------------------------------------------------------------------------
// XSNamespaceItem: access methods
// ---------------------------------------------------------------------------
XSNamedMap<XSObject> *XSNamespaceItem::getComponents(XSConstants::COMPONENT_TYPE objectType)
{
return fComponentMap[objectType -1];
}
XSElementDeclaration *XSNamespaceItem::getElementDeclaration(const XMLCh *name)
{
if (name)
return (XSElementDeclaration*) fHashMap[XSConstants::ELEMENT_DECLARATION -1]->get(name);
return 0;
}
XSAttributeDeclaration *XSNamespaceItem::getAttributeDeclaration(const XMLCh *name)
{
if (name)
return (XSAttributeDeclaration*) fHashMap[XSConstants::ATTRIBUTE_DECLARATION -1]->get(name);
return 0;
}
XSTypeDefinition *XSNamespaceItem::getTypeDefinition(const XMLCh *name)
{
if (name)
return (XSTypeDefinition*) fHashMap[XSConstants::TYPE_DEFINITION -1]->get(name);
return 0;
}
XSAttributeGroupDefinition *XSNamespaceItem::getAttributeGroup(const XMLCh *name)
{
if (name)
return (XSAttributeGroupDefinition*) fHashMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->get(name);
return 0;
}
XSModelGroupDefinition *XSNamespaceItem::getModelGroupDefinition(const XMLCh *name)
{
if (name)
return (XSModelGroupDefinition*) fHashMap[XSConstants::MODEL_GROUP_DEFINITION -1]->get(name);
return 0;
}
XSNotationDeclaration *XSNamespaceItem::getNotationDeclaration(const XMLCh *name)
{
if (name)
return (XSNotationDeclaration*) fHashMap[XSConstants::NOTATION_DECLARATION -1]->get(name);
return 0;
}
const StringList *XSNamespaceItem::getDocumentLocations()
{
if (fGrammar)
return ((XMLSchemaDescriptionImpl*) fGrammar->getGrammarDescription())->getLocationHints();
return 0;
}
XERCES_CPP_NAMESPACE_END
| [
"jtc@dolby.com"
] | jtc@dolby.com |
ba05cfb5028ddc3f06638f4bd99092c3887b4a23 | 54020f5f80e6680ed9b7f69aa229a8ba2bc72630 | /src/graphics/Material.cpp | 53a8a61427008f8660a9145f6aaa76341a7063ff | [] | no_license | snacchus/DeferredRenderer | 12c6b3aa48de68d5912a774b198cfba7144f81da | eec45e067b59ef8969e49303b657739689bd649a | refs/heads/master | 2022-03-28T08:14:55.672704 | 2017-07-07T22:19:13 | 2017-07-07T22:19:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,062 | cpp | #include "Material.hpp"
#include "Effect.hpp"
#include "core/type_registry.hpp"
#include "content/pooled.hpp"
#include "scripting/class_registry.hpp"
REGISTER_OBJECT_TYPE_NO_EXT(Material);
Material::Material() : m_effect(nullptr) { }
void Material::setEffect(Effect* effect)
{
m_effect = effect;
if (m_effect) {
for (auto it = m_effect->begin_properties(); it != m_effect->end_properties(); ++it) {
auto pit = m_properties.find(it->id);
if (pit != m_properties.end()) {
if (!is_same_type(*it, *pit)) {
m_properties.replace(pit, *it);
}
} else {
m_properties.insert(*it);
}
}
}
}
const shader_property* Material::getProperty(uniform_id id) const
{
auto it = m_properties.find(id);
if (it != m_properties.end()) {
return &(*it);
}
return nullptr;
}
void Material::apply(const ShaderProgram* p) const
{
m_effect->applyProperties(p, this);
}
void Material::apply_json_impl(const nlohmann::json& json)
{
auto eit = json.find("effect");
if (eit != json.end()) {
Effect* effect = content::get_pooled_json<Effect>(*eit);
setEffect(effect);
}
auto pit = json.find("properties");
if (pit != json.end() && pit->is_object()) {
auto& pj = *pit;
for (auto it = pj.begin(); it != pj.end(); ++it) {
setPropFromJson(it.key(), it.value());
}
}
}
void Material::setPropFromJson(const std::string& name, const nlohmann::json& json)
{
auto it = m_properties.find(uniform_name_to_id(name));
if (it != m_properties.end()) {
m_properties.modify(it, [&json](shader_property& prop) {
prop.assign_json(json);
});
}
}
SCRIPTING_REGISTER_DERIVED_CLASS(Material, NamedObject)
SCRIPTING_AUTO_METHOD(Material, effect)
SCRIPTING_AUTO_METHOD(Material, setEffect)
SCRIPTING_DEFINE_METHOD(Material, getProperty)
{
auto self = scripting::check_self<Material>(L);
scripting::raise_error(L, "method not implemented");
// TODO
return 0;
}
SCRIPTING_DEFINE_METHOD(Material, setProperty)
{
auto self = scripting::check_self<Material>(L);
scripting::raise_error(L, "method not implemented");
// TODO
return 0;
}
| [
"dennisjp.heinze@gmail.com"
] | dennisjp.heinze@gmail.com |
538dd6e90b8dbfe445ecf496f914bf7b20e52ece | b29b689e889879fe5b7834947acca2f93ce3e374 | /data/diagramm.cpp | 25d33ee1f10a48d40d5f742b0e41826f25a09d09 | [] | no_license | Eisboar/desktop.teachSmart | 971a63aeebd0f0f9e4ca488f9fd329f04385f6bb | 6b0da5a7a75bf740c94e13675b9d5c820303d0d1 | refs/heads/master | 2021-01-15T11:18:47.725899 | 2014-07-17T13:33:09 | 2014-07-17T13:33:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,214 | cpp | #include "diagramm.h"
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QNetworkDiskCache>
#include <QtConcurrent>
#include <QVariant>
#include <iostream>
//! [ ImageAnalyzer - Constructor ]
void
Diagramm::createDummyData(){
values = new QMap<QString, QVariant>;
values->insert("Antwort ", 2);
values->insert("Antwort 2", 3);
values->insert("Antwort 3", 4);
}
Diagramm::Diagramm()
{
createDummyData();
//QObject::connect(m_watcher, SIGNAL(progressValueChanged(int)),
// this, SLOT(progressStatus(int)));
}
Diagramm::~Diagramm()
{
delete(m_watcher);
}
QMap<QString, QVariant> Diagramm::getValues() {return *values;}
void Diagramm::progressStatus(int newstat)
{
emit updateProgress(newstat);
}
void Diagramm::startAnalysis(const QStringList & urls)
{
if ( values->contains("lala")){
QVariant value =(*values)["lala"] ;
int intValue = value.toInt();
intValue++;
(*values)["lala"]=QVariant(intValue);
}
//m_URLQueue = urls;
//fetchURLs();
}
void
Diagramm::draw(){
if ( values->contains("Antwort ")){
QVariant value =(*values)["Antwort "] ;
int intValue = value.toInt();
intValue++;
(*values)["Antwort "]=QVariant(intValue);
}
progressStatus(0);
}
void
Diagramm::setQuestion(Question *question){
//delete values;
std::cout << "set_question: " <<
question->getType().toStdString() << "\n";
//std::cout << "size:" << question->getUserAnswers()->size() << "\n";
std::cout.flush();
title = "";
title.append(QString::number(question->getPosition()));
title.append(") ");
title.append(question->getQuestionText());
//std::cout <<question->getType().toStdString() << '\n';
if (question->getUserAnswers()==0)
return;
std::cout << "size:" << question->getUserAnswers()->size() << "\n";
std::cout.flush();
if (values!=0)
delete values;
values = new QMap<QString, QVariant>;
//std::cout << question->getType().toStdString() << "\n";
if (question->getType()=="multiple_choice"){
std::cout << "lala" << "\n";
QMap<int, int> *userAnswers = question->getUserAnswers();
for( QMap<int,int>::iterator it = userAnswers->begin(); it != userAnswers->end(); )
{
values->insert(QString::number(it.key()),it.value());
it++;
// if( it->value == something )
// {
// map.insert(it.key()+10,it.value());
// it = map.erase(it);
// } else {
// ++it;
// }
}
} else if (question->getType()=="rating"){
std::cout << "lala" << "\n";
QMap<int, int> *userAnswers = question->getUserAnswers();
//std::cout << "size:" << userAnswers->size() << "\n";
for( QMap<int,int>::iterator it = userAnswers->begin(); it != userAnswers->end(); ) {
std::cout << "insert" << "\n";
values->insert(QString::number(it.key()),it.value());
it++;
}
}
}
QString
Diagramm::getTitle(){
return title;
}
| [
"sascha_hasel@yahoo.de"
] | sascha_hasel@yahoo.de |
3bf52fbe9635c006cceb0921011165e68f6e6bcf | 1b5802806cdf2c3b6f57a7b826c3e064aac51d98 | /tensorrt-integrate-1.23-openvino-yolov5/openvino_2022.1.0.643/runtime/include/openvino/op/experimental_detectron_roi_feature.hpp | c73010754113cd54849e2c906c91f228480a95fa | [
"MIT"
] | permissive | jinmin527/learning-cuda-trt | def70b3b1b23b421ab7844237ce39ca1f176b297 | 81438d602344c977ef3cab71bd04995c1834e51c | refs/heads/main | 2023-05-23T08:56:09.205628 | 2022-07-24T02:48:24 | 2022-07-24T02:48:24 | 517,213,903 | 36 | 18 | null | 2022-07-24T03:05:05 | 2022-07-24T03:05:05 | null | UTF-8 | C++ | false | false | 2,182 | hpp | // Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <cstddef>
#include <cstdint>
#include <vector>
#include "openvino/core/attribute_adapter.hpp"
#include "openvino/op/op.hpp"
#include "openvino/op/util/attr_types.hpp"
namespace ov {
namespace op {
namespace v6 {
/// \brief An operation ExperimentalDetectronROIFeatureExtractor
/// is the ROIAlign operation applied over a feature pyramid.
class OPENVINO_API ExperimentalDetectronROIFeatureExtractor : public Op {
public:
OPENVINO_OP("ExperimentalDetectronROIFeatureExtractor", "opset6", op::Op, 6);
BWDCMP_RTTI_DECLARATION;
/// \brief Structure that specifies attributes of the operation
struct Attributes {
int64_t output_size;
int64_t sampling_ratio;
std::vector<int64_t> pyramid_scales;
bool aligned;
};
ExperimentalDetectronROIFeatureExtractor() = default;
/// \brief Constructs a ExperimentalDetectronROIFeatureExtractor operation.
///
/// \param args Inputs of ExperimentalDetectronROIFeatureExtractor
/// \param attrs Operation attributes
ExperimentalDetectronROIFeatureExtractor(const OutputVector& args, const Attributes& attrs);
/// \brief Constructs a ExperimentalDetectronROIFeatureExtractor operation.
///
/// \param args Inputs of ExperimentalDetectronROIFeatureExtractor
/// \param attrs Operation attributes
ExperimentalDetectronROIFeatureExtractor(const NodeVector& args, const Attributes& attrs);
bool visit_attributes(AttributeVisitor& visitor) override;
void validate_and_infer_types() override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
/// \brief Returns attributes of the operation.
const Attributes& get_attrs() const {
return m_attrs;
}
private:
Attributes m_attrs;
template <class T>
friend void shape_infer(const ExperimentalDetectronROIFeatureExtractor* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes);
};
} // namespace v6
} // namespace op
} // namespace ov
| [
"dujw@deepblueai.com"
] | dujw@deepblueai.com |
bd24a848fc607e148b809de58ccf5c5a55cb86f2 | 54f352a242a8ad6ff5516703e91da61e08d9a9e6 | /Source Codes/CodeJamData/08/95/10.cpp | fc8dda442ffe5c1c3f05f7a002abe48f4159b21b | [] | no_license | Kawser-nerd/CLCDSA | 5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb | aee32551795763b54acb26856ab239370cac4e75 | refs/heads/master | 2022-02-09T11:08:56.588303 | 2022-01-26T18:53:40 | 2022-01-26T18:53:40 | 211,783,197 | 23 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 1,648 | cpp | // Chmel.Tolstiy
// Tolstsikau Aliaksei
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1, 1, 1, -1, -1, 2, 2, -2, -2};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1, 2, -2, 2, -2, 1, -1, 1, -1};
#define mp make_pair
int test;
int n, m;
char s[20][20];
int S[20];
int f[17][16][1 << 16];
int find(int r, int c, int ms) {
if (r == n + 1) return 0;
if (c == m) return find(r + 1, 0, ms);
if (f[r][c][ms] != -1) return f[r][c][ms];
int & res = f[r][c][ms];
int ns = ms; if (ns & (1 << c)) ns -= 1 << c;
if (s[r][c] == '.') {
res = find(r, c + 1, ns);
}
if (s[r][c] == '#') {
res = find(r, c + 1, ns + (1 << c)) + 4;
if (ms & (1 << c)) res-=2;
if (c > 0 && (ms & (1 << (c - 1)))) res-=2;
}
if (s[r][c] == '?') {
res = find(r, c + 1, ns + (1 << c)) + 4;
if (ms & (1 << c)) res-=2;
if (c > 0 && (ms & (1 << (c - 1)))) res-=2;
res = max(res, find(r, c + 1, ns));
}
return res;
}
void solve() {
cout << "Case #" << test << ": ";
int ans = 0;
cin >> n >> m;
memset(f, -1, sizeof(f));
for (int i = 0; i < n; i++) {
cin >> s[i+1];
}
ans = find(1, 0, 0);
cout << ans << endl;
}
int main() {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int tests;
cin >> tests;
for (test = 1; test <= tests; test++)
solve();
fclose(stdout);
return 0;
} | [
"kwnafi@yahoo.com"
] | kwnafi@yahoo.com |
74d7634801dc33b49fbffd18d103318363715cbe | b9fec31908e40cfc52400e13f847ac0f4e8c48bb | /matlab tests/DH/libs/obs/include/mrpt/maps/TMetricMapTypesRegistry.h | a1f055985c3928d121c66aa1cab5d9454400ad2f | [
"BSD-3-Clause"
] | permissive | DavidRicardoGarcia/measurement-of-angles | e7ff8e9f15a9e50bc57c0d45f5807fcf1fa0ec74 | ab16ca937262e05bf9f82dca5f425791cacfa459 | refs/heads/master | 2021-07-16T12:30:53.523173 | 2021-06-24T07:16:49 | 2021-06-24T07:16:49 | 122,414,543 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,492 | h | /* +---------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2017, 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/utils/core_defs.h>
#include <mrpt/obs/link_pragmas.h>
#include <mrpt/obs/obs_frwds.h>
#include <map>
#include <string>
namespace mrpt
{
namespace maps
{
struct TMetricMapInitializer;
namespace internal
{
typedef mrpt::maps::TMetricMapInitializer* (*MapDefCtorFunctor)(void);
typedef mrpt::maps::CMetricMap* (*MapCtorFromDefFunctor)(const mrpt::maps::TMetricMapInitializer&);
/** Class factory & registry for map classes. Used from mrpt::maps::TMetricMapInitializer */
struct OBS_IMPEXP TMetricMapTypesRegistry
{
public:
static TMetricMapTypesRegistry & Instance();
size_t doRegister(const std::string &name,MapDefCtorFunctor func1,MapCtorFromDefFunctor func2); //!< Return the index of the class in the list (not important, just used as a trick to initialize static members)
mrpt::maps::TMetricMapInitializer* factoryMapDefinition(const std::string &className) const; //!< Return NULL if not found
mrpt::maps::CMetricMap* factoryMapObjectFromDefinition(const mrpt::maps::TMetricMapInitializer&mi) const; //!< Return NULL if not found
typedef std::map<std::string,std::pair<MapDefCtorFunctor,MapCtorFromDefFunctor> > TListRegisteredMaps;
const TListRegisteredMaps & getAllRegistered() const { return m_registry;}
private:
TMetricMapTypesRegistry() {} // Access thru singleton in Instance()
TListRegisteredMaps m_registry;
};
/** Add a MAP_DEFINITION_START() ... MAP_DEFINITION_END() block inside the declaration of each metric map */
#define MAP_DEFINITION_START(_CLASS_NAME_,_LINKAGE_) \
public: \
/** @name Map Definition Interface stuff (see mrpt::maps::TMetricMapInitializer) @{ */ \
struct _LINKAGE_ TMapDefinitionBase : public mrpt::maps::TMetricMapInitializer { \
TMapDefinitionBase() : TMetricMapInitializer(CLASS_ID(_CLASS_NAME_)) { } \
};\
struct _LINKAGE_ TMapDefinition : public TMapDefinitionBase { \
#define MAP_DEFINITION_END(_CLASS_NAME_,_LINKAGE_) \
TMapDefinition();\
protected: \
void loadFromConfigFile_map_specific(const mrpt::utils::CConfigFileBase &source, const std::string §ionNamePrefix) MRPT_OVERRIDE; \
void dumpToTextStream_map_specific(mrpt::utils::CStream &out) const MRPT_OVERRIDE; \
}; \
/** Returns default map definition initializer. See mrpt::maps::TMetricMapInitializer */ \
static mrpt::maps::TMetricMapInitializer* MapDefinition(); \
/** Constructor from a map definition structure: initializes the map and its parameters accordingly */ \
static _CLASS_NAME_* CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def); \
static mrpt::maps::CMetricMap* internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def); \
/** ID used to initialize class registration (just ignore it) */ \
static const size_t m_private_map_register_id; \
/** @} */
/** Registers one map class into TMetricMapInitializer factory.
* One or several alternative class names can be provided, separated with whitespaces or commas */
#define MAP_DEFINITION_REGISTER(_CLASSNAME_STRINGS, _CLASSNAME_WITH_NS) \
const size_t _CLASSNAME_WITH_NS::m_private_map_register_id = mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister(_CLASSNAME_STRINGS,&_CLASSNAME_WITH_NS::MapDefinition,&_CLASSNAME_WITH_NS::internal_CreateFromMapDefinition); \
mrpt::maps::TMetricMapInitializer* _CLASSNAME_WITH_NS::MapDefinition() { return new _CLASSNAME_WITH_NS::TMapDefinition; } \
_CLASSNAME_WITH_NS* _CLASSNAME_WITH_NS::CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def) \
{ return dynamic_cast<_CLASSNAME_WITH_NS*>(_CLASSNAME_WITH_NS::internal_CreateFromMapDefinition(def)); }
} // end NS internal
} // End of namespace
} // End of namespace
| [
"davidnf.44@gmail.com"
] | davidnf.44@gmail.com |
4b8fa5f0e683fb0eae81e28c09cc7ea11cc9d683 | afc634fb025471b4c10676d9bc842b8a06bd2fad | /4. lintcode/subtreeWithMaximumAverage/BinaryTree.cpp | fdd6f8f80ac9c37f618b25475a342e819d04c60b | [] | no_license | alyssssa8/resume | 3013a236f56036c3597607e209dfb309229cd5f4 | ce0cb95e398e421b0ecf879b1f0109a20c0c5d92 | refs/heads/master | 2022-07-15T15:08:00.125861 | 2019-06-26T03:52:50 | 2019-06-26T03:52:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,962 | cpp | // Implementation file for the IntBinaryTree class
#include <iostream>
#include "BinaryTree.h"
using namespace std;
//*************************************************************
// insert accepts a TreeNode pointer and a pointer to a node. *
// The function inserts the node into the tree pointed to by *
// the TreeNode pointer. This function is called recursively. *
//*************************************************************
void IntBinaryTree::insert(TreeNode *&nodePtr, TreeNode *&newNode)
{
if (nodePtr == nullptr)
nodePtr = newNode; // Insert the node.
else if (newNode->value < nodePtr->value)
insert(nodePtr->left, newNode); // Search the left branch
else
insert(nodePtr->right, newNode); // Search the right branch
}
//**********************************************************
// insertNode creates a new node to hold num as its value, *
// and passes it to the insert function. *
//**********************************************************
void IntBinaryTree::insertNode(int num)
{
TreeNode *newNode = nullptr; // Pointer to a new node.
// Create a new node and store num in it.
newNode = new TreeNode;
newNode->value = num;
newNode->left = newNode->right = nullptr;
// Insert the node.
insert(root, newNode);
}
//***************************************************
// destroySubTree is called by the destructor. It *
// deletes all nodes in the tree. *
//***************************************************
void IntBinaryTree::destroySubTree(TreeNode *nodePtr)
{
if (nodePtr)
{
if (nodePtr->left)
destroySubTree(nodePtr->left);
if (nodePtr->right)
destroySubTree(nodePtr->right);
delete nodePtr;
}
}
//***************************************************
// searchNode determines if a value is present in *
// the tree. If so, the function returns true. *
// Otherwise, it returns false. *
//***************************************************
bool IntBinaryTree::searchNode(int num)
{
TreeNode *nodePtr = root;
while (nodePtr)
{
if (nodePtr->value == num)
return true;
else if (num < nodePtr->value)
nodePtr = nodePtr->left;
else
nodePtr = nodePtr->right;
}
return false;
}
//**********************************************
// remove calls deleteNode to delete the *
// node whose value member is the same as num. *
//**********************************************
void IntBinaryTree::remove(int num)
{
deleteNode(num, root);
}
//********************************************
// deleteNode deletes the node whose value *
// member is the same as num. *
//********************************************
void IntBinaryTree::deleteNode(int num, TreeNode *&nodePtr)
{
if (num < nodePtr->value)
deleteNode(num, nodePtr->left);
else if (num > nodePtr->value)
deleteNode(num, nodePtr->right);
else
makeDeletion(nodePtr);
}
//***********************************************************
// makeDeletion takes a reference to a pointer to the node *
// that is to be deleted. The node is removed and the *
// branches of the tree below the node are reattached. *
//***********************************************************
void IntBinaryTree::makeDeletion(TreeNode *&nodePtr)
{
// Define a temporary pointer to use in reattaching
// the left subtree.
TreeNode *tempNodePtr = nullptr;
if (nodePtr == nullptr)
cout << "Cannot delete empty node.\n";
else if (nodePtr->right == nullptr)
{
tempNodePtr = nodePtr;
nodePtr = nodePtr->left; // Reattach the left child
delete tempNodePtr;
}
else if (nodePtr->left == nullptr)
{
tempNodePtr = nodePtr;
nodePtr = nodePtr->right; // Reattach the right child
delete tempNodePtr;
}
// If the node has two children.
else
{
// Move one node the right.
tempNodePtr = nodePtr->right;
// Go to the end left node.
while (tempNodePtr->left)
tempNodePtr = tempNodePtr->left;
// Reattach the left subtree.
tempNodePtr->left = nodePtr->left;
tempNodePtr = nodePtr;
// Reattach the right subtree.
nodePtr = nodePtr->right;
delete tempNodePtr;
}
}
//****************************************************************
// The displayInOrder member function displays the values *
// in the subtree pointed to by nodePtr, via inorder traversal. *
//****************************************************************
void IntBinaryTree::displayInOrder(TreeNode *nodePtr) const
{
if (nodePtr)
{
displayInOrder(nodePtr->left);
cout << nodePtr->value << endl;
displayInOrder(nodePtr->right);
}
}
//****************************************************************
// The displayPreOrder member function displays the values *
// in the subtree pointed to by nodePtr, via preorder traversal. *
//****************************************************************
void IntBinaryTree::displayPreOrder(TreeNode *nodePtr) const
{
if (nodePtr)
{
cout << nodePtr->value << endl;
displayPreOrder(nodePtr->left);
displayPreOrder(nodePtr->right);
}
}
//****************************************************************
// The displayPostOrder member function displays the values *
// in the subtree pointed to by nodePtr, via postorder traversal.*
//****************************************************************
void IntBinaryTree::displayPostOrder(TreeNode *nodePtr) const
{
if (nodePtr)
{
displayPostOrder(nodePtr->left);
displayPostOrder(nodePtr->right);
cout << nodePtr->value << endl;
}
} | [
"yuwanguk@hotmail.com"
] | yuwanguk@hotmail.com |
ec934e899cece085275657e8343337d153762dba | a0423109d0dd871a0e5ae7be64c57afd062c3375 | /Aplicacion Movil/generated/bundles/login-transition/build/Android/Preview/app/src/main/include/Android.Base.Primitiv-2924c081.h | ec47b1a1e509169ac22d817ad903e3255a421f67 | [
"Apache-2.0"
] | permissive | marferfer/SpinOff-LoL | 1c8a823302dac86133aa579d26ff90698bfc1ad6 | a9dba8ac9dd476ec1ef94712d9a8e76d3b45aca8 | refs/heads/master | 2020-03-29T20:09:20.322768 | 2018-10-09T10:19:33 | 2018-10-09T10:19:33 | 150,298,258 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 459 | h | // This file was generated based on C:/Users/JuanJose/AppData/Local/Fusetools/Packages/UnoCore/1.9.0/Targets/Android/Uno/Base/Primitives.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
namespace g{
namespace Android{
namespace Base{
namespace Primitives{
// public extern struct uweakptr :21
// {
uStructType* uweakptr_typeof();
struct uweakptr
{
};
// }
}}}} // ::g::Android::Base::Primitives
| [
"mariofdezfdez@hotmail.com"
] | mariofdezfdez@hotmail.com |
38bc87bc612a1282d8df3afae8e448568470112f | 5702eb53222af6e3e41672853c98e87c76fda0e3 | /util/cpp/net/MessageFactory.cpp | 85538693e43c9c09de11136118573933d902c4eb | [] | no_license | agilecomputing/nomads | fe46464f62440d29d6074370c1750f69c75ea309 | 0c381bfe728fb24d170721367336c383f209d839 | refs/heads/master | 2021-01-18T11:12:29.670874 | 2014-12-13T00:46:40 | 2014-12-13T00:46:40 | 50,006,520 | 1 | 0 | null | 2016-01-20T05:19:14 | 2016-01-20T05:19:13 | null | UTF-8 | C++ | false | false | 6,440 | cpp | /*
* MessageFactory.cpp
*
* This file is part of the IHMC Util Library
* Copyright (c) 1993-2014 IHMC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 (GPLv3) as published by the Free Software Foundation.
*
* U.S. Government agencies and organizations may redistribute
* and/or modify this program under terms equivalent to
* "Government Purpose Rights" as defined by DFARS
* 252.227-7014(a)(12) (February 2014).
*
* Alternative licenses that allow for use within commercial products may be
* available. Contact Niranjan Suri at IHMC (nsuri@ihmc.us) for details.
*/
#include "MessageFactory.h"
#include "NetworkMessageV2.h"
#include "NetworkMessageV1.h"
#include <stdlib.h>
using namespace NOMADSUtil;
MessageFactory::MessageFactory (uint8 ui8MessageVersion)
{
srand ((uint32)getTimeInMilliseconds());
// Set session id
// I want to limit the session id to 65535 since
// this is the greatest number which is rapresentable
// with 16 bits.
_ui16SessionID = (rand() % 65535);
_ui8MessageVersion = ui8MessageVersion;
}
MessageFactory::~MessageFactory()
{
_seqIdsByNodeAddress.removeAll();
}
NetworkMessage * MessageFactory::getDataMessage (uint8 ui8MsgType, uint32 ui32SourceAddress, uint32 ui32TargetAddress,
uint16 ui16MsgId, uint8 ui8HopCount, uint8 ui8TTL,
NetworkMessage::ChunkType chunkType,
const void *pMsgMetaData, uint16 ui16MsgMetaDataLen,
const void *pMsg, uint16 ui16MsgLen)
{
return createNetworkMessageFromFields (ui8MsgType, ui32SourceAddress, ui32TargetAddress,
_ui16SessionID, ui16MsgId, ui8HopCount, ui8TTL, chunkType, false,
pMsgMetaData, ui16MsgMetaDataLen, pMsg, ui16MsgLen, _ui8MessageVersion);
}
NetworkMessage * MessageFactory::getReliableDataMessage (uint8 ui8MsgType, uint32 ui32SourceAddress, uint32 ui32TargetAddress,
uint8 ui8HopCount, uint8 ui8TTL, NetworkMessage::ChunkType chunkType,
const void *pMsgMetaData, uint16 ui16MsgMetaDataLen,
const void *pMsg, uint16 ui16MsgLen)
{
return createNetworkMessageFromFields (ui8MsgType, ui32SourceAddress, ui32TargetAddress,
_ui16SessionID, getNodeSeqId (ui32TargetAddress), ui8HopCount,
ui8TTL, chunkType, true, pMsgMetaData, ui16MsgMetaDataLen,
pMsg, ui16MsgLen, _ui8MessageVersion);
}
NetworkMessage * MessageFactory::getSAckMessage (uint8 ui8MsgType, uint32 ui32SourceAddress, uint32 ui32TargetAddress,
uint8 ui8HopCount, uint8 ui8TTL,
const void *pMsgMetaData, uint16 ui16MsgMetaDataLen,
const void *pMsg, uint16 ui16MsgLen)
{
return createNetworkMessageFromFields (ui8MsgType, ui32SourceAddress, ui32TargetAddress,
_ui16SessionID, 0, ui8HopCount, ui8TTL,
NetworkMessage::CT_SAck, false, NULL, 0, pMsg,
ui16MsgLen, _ui8MessageVersion);
}
uint16 MessageFactory::getNodeSeqId (uint32 ui32TargetAddress)
{
SequenceID * pSeqID = _seqIdsByNodeAddress.get (ui32TargetAddress);
if (pSeqID == NULL) {
pSeqID = new SequenceID();
_seqIdsByNodeAddress.put (ui32TargetAddress, pSeqID);
}
else {
pSeqID->seqID = pSeqID->seqID + 1;
}
return pSeqID->seqID;
}
NetworkMessage * MessageFactory::createNetworkMessage (uint8 ui8Version)
{
switch (ui8Version) {
case 1 :
return new NetworkMessageV1();
case 2 :
return new NetworkMessageV2();
default :
return NULL;
}
}
// Constructor to deserealize
NetworkMessage * MessageFactory::createNetworkMessageFromBuffer (const void *pBuf, uint16 ui16BufSize, uint8 ui8Version)
{
switch (ui8Version) {
case 1 :
return new NetworkMessageV1 (pBuf, ui16BufSize);
case 2 :
return new NetworkMessageV2 (pBuf, ui16BufSize);
default :
return NULL;
}
}
NetworkMessage * MessageFactory::createNetworkMessageFromMessage (const NetworkMessage& nmi, uint8 ui8Version)
{
switch (ui8Version) {
case 1 :
return new NetworkMessageV1 (nmi);
case 2 :
return new NetworkMessageV2 (nmi);
default :
return NULL;
}
}
// Constructor to serialize
NetworkMessage * MessageFactory::createNetworkMessageFromFields (uint8 ui8MsgType, uint32 ui32SourceAddress,
uint32 ui32TargetAddress, uint16 ui16SessionId,
uint16 ui16MsgId, uint8 ui8HopCount, uint8 ui8TTL,
NetworkMessage::ChunkType chunkType, bool bReliable,
const void *pMsgMetaData, uint16 ui16MsgMetaDataLen,
const void *pMsg, uint16 ui16MsgLen, uint8 ui8Version)
{
switch (ui8Version) {
case 1 :
return new NetworkMessageV1 (ui8MsgType, ui32SourceAddress, ui32TargetAddress,
ui16SessionId, ui16MsgId, ui8HopCount, ui8TTL,
chunkType, bReliable, pMsgMetaData, ui16MsgMetaDataLen,
pMsg, ui16MsgLen);
case 2 :
return new NetworkMessageV2 (ui8MsgType, ui32SourceAddress, ui32TargetAddress, ui16SessionId,
ui16MsgId, ui8HopCount, ui8TTL, chunkType, bReliable, pMsgMetaData,
ui16MsgMetaDataLen, pMsg, ui16MsgLen, 0);
default :
return NULL;
}
}
| [
"giacomo.benincasa@gmail.com"
] | giacomo.benincasa@gmail.com |
66dbdb620cbed65fa31e24e2a71b6a1313382a23 | b03aefe71117bb80ac125d4097e3be4e592fc8f9 | /Search-Interface-Qt/GUI/Tile.h | 8cb3f397af41ab33ffb46fdb69275a7677adea05 | [] | no_license | saifulkhan/dphil_project_search_index | bbc44c1f6fe448eb7f4827be09b50e5a3ce619d6 | 7a55e8194ee12713764b4cf9469c3c31463a7d53 | refs/heads/master | 2021-09-20T16:20:30.424865 | 2018-08-12T10:55:23 | 2018-08-12T10:55:23 | 71,154,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,013 | h | #ifndef TILE_H
#define TILE_H
#include <QGraphicsItem>
#include <QtGui>
#include <QMessageBox>
#include <QStyleOptionGraphicsItem>
#include <Conversion.h>
#include <FileInfo.h>
#include "Layout.h"
#define TREEMAP_FONT_SIZE 6
class Tile : public QGraphicsItem
{
private:
const FileInfo fileInfo;
const int depth;
const int maxdepth;
const QRectF bound;
QColor colour;
QColor lastcolour;
QPen pen;
QColor getColour();
QColor blendColor( QColor a, QColor b, qreal alpha );
public:
Tile(FileInfo fileInfo, int depth, int maxdepth, QRectF bound, QGraphicsItem *parent = 0);
//Tile(NodeTM* node, int maxdepth, QGraphicsItem *parent = 0);
~Tile ();
QRectF boundingRect () const;
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
void mousePressEvent( QGraphicsSceneMouseEvent * );
//void hoverEnterEvent(QGraphicsSceneHoverEvent *);
//void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
};
#endif //
| [
"saiful.etc@gmail.com"
] | saiful.etc@gmail.com |
c4b6e28e5c0296b797ac53f88e3dda5251f16ac7 | 57d14ce1d056dcba9a938c2f8e1d954225a6d0c6 | /src/examples/SPI_SI4432_Radio/src/si4432.cpp | d1dca4ebd5893a03d6646a5be1cc2fb6c143196d | [] | no_license | nihuyaka/libarmpit-cortex | a81d443ef3e953996ecf7f993f41fec69388f521 | eda7700be66d91af0fa83fae6ebe181a11c32488 | refs/heads/master | 2016-09-06T05:40:16.709507 | 2015-10-24T16:42:20 | 2015-10-24T16:42:20 | 44,834,918 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,813 | cpp | #include "si4432.h"
#include "rcc.h"
#include <math.h>
#define MAX_TRANSMIT_TIMEOUT 200
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
//values here are kept in khz x 10 format (for not to deal with decimals) - look at AN440 page 26 for whole table
const uint16_t IFFilterTable[][2] =
{
{ 322, 0x26 },
{ 3355, 0x88 },
{ 3618, 0x89 },
{ 4202, 0x8A },
{ 4684, 0x8B },
{ 5188, 0x8C },
{ 5770, 0x8D },
{ 6207, 0x8E } };
Si4432::Si4432(SPI* spi, GPIO_PIN* ssPin, GPIO_PIN* sdnPin, GPIO_PIN* interruptPin = 0)
{ // default is 450 mhz
_spi = spi;
ssPin->SetupGPIO_OutPP();
_spi->SetSSPin(ssPin);
_sdnPin = sdnPin;
_intPin = interruptPin;
if (_intPin != 0)
_intPin->SetupGPIO_InPullUp();
_sdnPin->SetupGPIO_OutPP();
_freqCarrier = 433000000;
_freqChannel = 0;
_kbps = 100;
_packageSign = 0xBEEF;
}
void Si4432::setFrequency(unsigned long baseFrequencyMhz)
{
if ((baseFrequencyMhz < 240) || (baseFrequencyMhz > 930))
return; // invalid frequency
_freqCarrier = baseFrequencyMhz;
uint8_t highBand = 0;
if (baseFrequencyMhz >= 480)
{
highBand = 1;
}
double fPart = (baseFrequencyMhz / (10 * (highBand + 1))) - 24;
uint8_t freqband = (uint8_t) fPart; // truncate the int
uint16_t freqcarrier = (fPart - freqband) * 64000;
// sideband is always on (0x40) :
uint8_t vals[3] =
{
(uint8_t)0x40 | (uint8_t)((uint8_t)highBand << 5) | (uint8_t)((uint8_t)freqband & 0x3F),
((uint8_t)((uint8_t)freqcarrier >> 8)),
(uint8_t)(freqcarrier & 0xFF)
};
BurstWrite(REG_FREQBAND, vals, 3);
}
void Si4432::setCommsSignature(uint16_t signature)
{
_packageSign = signature;
ChangeRegister(REG_TRANSMIT_HEADER3, _packageSign >> 8); // header (signature) uint8_t 3 val
ChangeRegister(REG_TRANSMIT_HEADER2, (_packageSign & 0xFF)); // header (signature) uint8_t 2 val
ChangeRegister(REG_CHECK_HEADER3, _packageSign >> 8); // header (signature) uint8_t 3 val for receive checks
ChangeRegister(REG_CHECK_HEADER2, (_packageSign & 0xFF)); // header (signature) uint8_t 2 val for receive checks
#ifdef DEBUG
Serial.println("Package signature is set!");
#endif
}
void Si4432::init()
{
turnOff();
_spi->SetSlaveSelectHigh();
hardReset();
}
void Si4432::boot()
{
/*
uint8_t currentFix[] = { 0x80, 0x40, 0x7F };
BurstWrite(REG_CHARGEPUMP_OVERRIDE, currentFix, 3); // refer to AN440 for reasons
ChangeRegister(REG_GPIO0_CONF, 0x0F); // tx/rx data clk pin
ChangeRegister(REG_GPIO1_CONF, 0x00); // POR inverted pin
ChangeRegister(REG_GPIO2_CONF, 0x1C); // clear channel pin
*/
ChangeRegister(REG_AFC_TIMING_CONTROL, 0x02); // refer to AN440 for reasons
ChangeRegister(REG_AFC_LIMITER, 0xFF); // write max value - excel file did that.
ChangeRegister(REG_AGC_OVERRIDE, 0x60); // max gain control
ChangeRegister(REG_AFC_LOOP_GEARSHIFT_OVERRIDE, 0x3C); // turn off AFC
ChangeRegister(REG_DATAACCESS_CONTROL, 0xAD); // enable rx packet handling, enable tx packet handling, enable CRC, use CRC-IBM
ChangeRegister(REG_HEADER_CONTROL1, 0x0C); // no broadcast address control, enable check headers for uint8_ts 3 & 2
ChangeRegister(REG_HEADER_CONTROL2, 0x22); // enable headers uint8_t 3 & 2, no fixed package length, sync word 3 & 2
ChangeRegister(REG_PREAMBLE_LENGTH, 0x08); // 8 * 4 bits = 32 bits (4 uint8_ts) preamble length
ChangeRegister(REG_PREAMBLE_DETECTION, 0x3A); // validate 7 * 4 bits of preamble in a package
ChangeRegister(REG_SYNC_WORD3, 0x2D); // sync uint8_t 3 val
ChangeRegister(REG_SYNC_WORD2, 0xD4); // sync uint8_t 2 val
ChangeRegister(REG_TX_POWER, 0x1F); // max power
ChangeRegister(REG_CHANNEL_STEPSIZE, 0x64); // each channel is of 1 Mhz interval
setFrequency(_freqCarrier); // default freq
setBaudRate(_kbps); // default baud rate is 100kpbs
setChannel(_freqChannel); // default channel is 0
setCommsSignature(_packageSign); // default signature
switchMode(Ready);
}
bool Si4432::sendPacket(uint8_t length, const uint8_t* data, bool waitResponse, uint32_t ackTimeout, uint8_t* responseLength, uint8_t* responseBuffer)
{
clearTxFIFO();
ChangeRegister(REG_PKG_LEN, length);
BurstWrite(REG_FIFO, data, length);
ChangeRegister(REG_INT_ENABLE1, 0x04); // set interrupts on for package sent
ChangeRegister(REG_INT_ENABLE2, 0x00); // set interrupts off for anything else
//read interrupt registers to clean them
ReadRegister(REG_INT_STATUS1);
ReadRegister(REG_INT_STATUS2);
switchMode(TXMode | Ready);
for (int i = 0; i < MAX_TRANSMIT_TIMEOUT; ++i)
{
if ((_intPin == 0) || !_intPin->IsSet())
{
uint8_t intStatus = ReadRegister(REG_INT_STATUS1);
ReadRegister(REG_INT_STATUS2);
if (intStatus & 0x04)
{
switchMode(Ready | TuneMode);
// package sent. now, return true if not to wait ack, or wait ack (wait for packet only for 'remaining' amount of time)
if (waitResponse)
{
if (waitForPacket(ackTimeout))
{
getPacketReceived(responseLength, responseBuffer);
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
}
RCC_Delay_ms(1);
}
switchMode(Ready);
if (ReadRegister(REG_DEV_STATUS) & 0x80)
{
clearFIFO();
}
return false;
}
bool Si4432::waitForPacket(uint32_t waitMs)
{
startListening();
bool rc = false;
for (uint32_t i = 0; i < waitMs; ++i)
{
if (isPacketReceived())
{
rc = true;
break;
}
RCC_Delay_ms(1);
}
switchMode(Ready);
clearRxFIFO();
return rc;
}
void Si4432::getPacketReceived(uint8_t* length, uint8_t* readData)
{
*length = ReadRegister(REG_RECEIVED_LENGTH);
BurstRead(REG_FIFO, readData, *length);
clearRxFIFO(); // which will also clear the interrupts
}
void Si4432::setChannel(uint8_t channel)
{
ChangeRegister(REG_FREQCHANNEL, channel);
}
void Si4432::switchMode(uint8_t mode)
{
ChangeRegister(REG_STATE, mode); // receive mode
//delay(20);
}
void Si4432::ChangeRegister(uint8_t reg, uint8_t value)
{
BurstWrite(reg, &value, 1);
}
void Si4432::setBaudRate(uint16_t kbps)
{
// chip normally supports very low bps values, but they are cumbersome to implement - so I just didn't implement lower bps values
if ((kbps > 256) || (kbps < 1))
return;
_kbps = kbps;
uint8_t freqDev = kbps <= 10 ? 15 : 150; // 15khz / 150 khz
uint8_t modulationValue = _kbps < 30 ? 0x4c : 0x0c; // use FIFO Mode, GFSK, low baud mode on / off
uint8_t modulationVals[] =
{ modulationValue, 0x23, (uint8_t)round((freqDev * 1000.0) / 625.0) }; // msb of the kpbs to 3rd bit of register
BurstWrite(REG_MODULATION_MODE1, modulationVals, 3);
// set data rate
uint16_t bpsRegVal = round((kbps * (kbps < 30 ? 2097152 : 65536.0)) / 1000.0);
uint8_t datarateVals[] =
{ (uint8_t)(bpsRegVal >> 8), (uint8_t)(bpsRegVal & 0xFF) };
BurstWrite(REG_TX_DATARATE1, datarateVals, 2);
//now set the timings
uint16_t minBandwidth = (2 * (uint32_t) freqDev) + kbps;
uint8_t IFValue = 0xff;
//since the table is ordered (from low to high), just find the 'minimum bandwith which is greater than required'
for (uint8_t i = 0; i < 8; ++i)
{
if (IFFilterTable[i][0] >= (minBandwidth * 10))
{
IFValue = IFFilterTable[i][1];
break;
}
}
ChangeRegister(REG_IF_FILTER_BW, IFValue);
uint8_t dwn3_bypass = (IFValue & 0x80) ? 1 : 0; // if msb is set
uint8_t ndec_exp = (IFValue >> 4) & 0x07; // only 3 bits
uint16_t rxOversampling = round((500.0 * (1 + 2 * dwn3_bypass)) / ((pow(2, ndec_exp - 3)) * (double) kbps));
uint32_t ncOffset = ceil(((double) kbps * (pow(2, ndec_exp + 20))) / (500.0 * (1 + 2 * dwn3_bypass)));
uint16_t crGain = 2 + ((65535 * (int64_t) kbps) / ((int64_t) rxOversampling * freqDev));
uint8_t crMultiplier = 0x00;
if (crGain > 0x7FF)
{
crGain = 0x7FF;
}
uint8_t timingVals[] =
{
(uint8_t)(rxOversampling & 0x00FF),
(uint8_t)((rxOversampling & 0x0700) >> 3) | ((ncOffset >> 16) & 0x0F),
(uint8_t)((ncOffset >> 8) & 0xFF),
(uint8_t)(ncOffset & 0xFF),
(uint8_t)((crGain & 0x0700) >> 8) | crMultiplier,
(uint8_t)(crGain & 0xFF)
};
BurstWrite(REG_CLOCK_RECOVERY_OVERSAMPLING, timingVals, 6);
}
uint8_t Si4432::ReadRegister(uint8_t reg)
{
uint8_t val = 0xFF;
BurstRead(reg, &val, 1);
return val;
}
void Si4432::BurstWrite(uint8_t startReg, const uint8_t value[], uint8_t length)
{
uint8_t regVal = (uint8_t) startReg | 0x80; // set MSB
_spi->SetSlaveSelectLow();
_spi->TransmitByte(regVal);
for (uint8_t i = 0; i < length; ++i)
{
_spi->TransmitByte(value[i]);
}
_spi->SetSlaveSelectHigh();
}
void Si4432::BurstRead(uint8_t startReg, uint8_t value[], uint8_t length)
{
uint8_t regVal = (uint8_t) startReg & 0x7F; // set MSB
_spi->SetSlaveSelectLow();
_spi->TransmitByte(regVal);
for (uint8_t i = 0; i < length; ++i)
{
value[i] = _spi->TransmitByte(0xFF);
}
_spi->SetSlaveSelectHigh();
}
void Si4432::clearTxFIFO()
{
ChangeRegister(REG_OPERATION_CONTROL, 0x01);
ChangeRegister(REG_OPERATION_CONTROL, 0x00);
}
void Si4432::clearRxFIFO()
{
ChangeRegister(REG_OPERATION_CONTROL, 0x02);
ChangeRegister(REG_OPERATION_CONTROL, 0x00);
}
void Si4432::clearFIFO()
{
ChangeRegister(REG_OPERATION_CONTROL, 0x03);
ChangeRegister(REG_OPERATION_CONTROL, 0x00);
}
void Si4432::softReset()
{
ChangeRegister(REG_STATE, 0x80);
uint8_t reg = ReadRegister(REG_INT_STATUS2);
while ((reg & 0x02) != 0x02)
{
RCC_Delay_ms(1);
reg = ReadRegister(REG_INT_STATUS2);
}
boot();
}
void Si4432::hardReset()
{
turnOff();
turnOn();
uint8_t reg = ReadRegister(REG_INT_STATUS2);
while ((reg & 0x02) != 0x02)
{
RCC_Delay_ms(1);
reg = ReadRegister(REG_INT_STATUS2);
}
boot();
}
void Si4432::startListening()
{
clearRxFIFO(); // clear first, so it doesn't overflow if packet is big
ChangeRegister(REG_INT_ENABLE1, 0x03); // set interrupts on for package received and CRC error
#ifdef DEBUG
ChangeRegister(REG_INT_ENABLE2, 0xC0);
#else
ChangeRegister(REG_INT_ENABLE2, 0x00); // set other interrupts off
#endif
//read interrupt registers to clean them
ReadRegister(REG_INT_STATUS1);
ReadRegister(REG_INT_STATUS2);
switchMode(RXMode | Ready);
}
bool Si4432::isPacketReceived()
{
if (_intPin != 0 && _intPin->IsSet())
{
return false; // if no interrupt occured, no packet received is assumed (since startListening will be called prior, this assumption is enough)
}
// check for package received status interrupt register
uint8_t intStat = ReadRegister(REG_INT_STATUS1);
#ifdef DEBUG
uint8_t intStat2 = ReadRegister(REG_INT_STATUS2);
if (intStat2 & 0x40)
{ //interrupt occured, check it && read the Interrupt Status1 register for 'preamble '
Serial.print("HEY!! HEY!! Valid Preamble detected -- ");
Serial.println(intStat2, HEX);
}
if (intStat2 & 0x80)
{ //interrupt occured, check it && read the Interrupt Status1 register for 'preamble '
Serial.print("HEY!! HEY!! SYNC WORD detected -- ");
Serial.println(intStat2, HEX);
}
#else
ReadRegister(REG_INT_STATUS2);
#endif
if (intStat & 0x02)
{ //interrupt occured, check it && read the Interrupt Status1 register for 'valid packet'
switchMode(Ready | TuneMode); // if packet came, get out of Rx mode till the packet is read out. Keep PLL on for fast reaction
return true;
}
else if (intStat & 0x01)
{ // packet crc error
switchMode(Ready); // get out of Rx mode till buffers are cleared
clearRxFIFO();
switchMode(RXMode | Ready); // get back to work
return false;
}
//no relevant interrupt? no packet!
return false;
}
void Si4432::turnOn()
{
// turn on the chip now
_sdnPin->Reset();
RCC_Delay_ms(20);
}
void Si4432::turnOff()
{
// turn off the chip now
_sdnPin->Set();
RCC_Delay_ms(1);
}
void Si4432::readAll() {
uint8_t allValues[0x7F];
BurstRead(REG_DEV_TYPE, allValues, 0x7F);
static volatile uint8_t tmp;
for (uint8_t i = 0; i < 0x7f; ++i)
{
tmp = allValues[i];
UNUSED(tmp);
}
}
| [
"nihuyaka@gmail.com"
] | nihuyaka@gmail.com |
bc68bb15bf5b4ce15b5c3756984a2be0a1df491b | cae0243512e1614fc9ef945713c9499d1a56d389 | /src/data/dStrategy/neighbor_selecting_first_improvement.h | 91946176af27fcaf3d9c0f2ac405654b75257c95 | [] | no_license | alejandro-reyesamaro/POSL | 15b5b58a9649234fa9bedbca4393550d38a69e7d | 0b3b7cf01a0392fc76394bbc04c52070637b3009 | refs/heads/master | 2021-04-15T11:10:24.998562 | 2016-09-06T15:10:54 | 2016-09-06T15:10:54 | 33,991,084 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 896 | h | #pragma once
#include "../neighborhood.h"
#include "../decision_pair.h"
#include "../../benchmarks/benchmark.h"
#include "../../solver/psp.h"
class NeighborSelectingFirstImprovement
{
public:
NeighborSelectingFirstImprovement(std::shared_ptr<Domain> domain, int dimension);
//! Select the the current and the selected configurations when the search state indicates to stop
/*!
* \param psp The search process
* \param V The set (a Neighborhood)
* \return The current and the new found configurations
*/
std::shared_ptr<DecisionPair> select(std::shared_ptr<PSP> psp, std::shared_ptr<Neighborhood> V);
private:
std::shared_ptr<DecisionPair> rPair;
std::shared_ptr<POSL_Iterator> it;
std::vector<int> current_config;
std::vector<int> best_found_config;
std::vector<int> neighbor;
};
| [
"alejandro-reyesamaro@univ-nantes.fr"
] | alejandro-reyesamaro@univ-nantes.fr |
46f2c0ceef7b89c32935c8d265a5f81c4b31908d | b5914f85d4e67d0aed49867923ce3b970f7ee481 | /ParallelCoordinates/ext/tapkee/traits/callbacks_traits.hpp | 6f9542b3a4d10673f0266b7621feaada646e7b90 | [] | no_license | BeHalcyon/GSIM | 391653c3d8656baf9f474c3fd462ce0e45d1b981 | cad6be7ce7da915e0300e6b434822f44ff080122 | refs/heads/master | 2022-06-20T11:49:57.357994 | 2019-07-03T08:39:11 | 2019-07-03T08:39:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 723 | hpp | /* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Copyright (c) 2012-2013 Sergey Lisitsyn
*/
#ifndef TAPKEE_CALLBACK_TRAITS_H_
#define TAPKEE_CALLBACK_TRAITS_H_
namespace tapkee
{
template <class Callback>
struct BatchCallbackTraits
{
static const bool supports_batch;
};
#define TAPKEE_CALLBACK_SUPPORTS_BATCH(X) \
template<> const bool BatchCallbackTraits<X>::supports_batch = true; \
template <class T>
class is_dummy
{
typedef char yes;
typedef long no;
template <typename C> static yes dummy(typename C::dummy*);
template <typename C> static no dummy(...);
public:
static const bool value = (sizeof(dummy<T>(0)) == sizeof(yes));
};
}
#endif
| [
"hexiangyang.zju@qq.com"
] | hexiangyang.zju@qq.com |
bd8d714e43a1eb4117d8067c301d521fe060d040 | 2a4de0cd9d40d15a9b7fdf14abe4bdfab812999c | /SequoiaDB/engine/include/pmdOptions.hpp | e693f5387d2845da57ae2d5f4c195e0117404ab4 | [] | no_license | thundercrawl/Common-CPlus | bfa9fd38c9e649ee5991be99444449835109db49 | 5e5220a9e8d75cbfe6798ff18c37701ddf46e123 | refs/heads/master | 2021-01-13T02:07:17.675012 | 2015-04-28T06:22:24 | 2015-04-28T06:22:24 | 34,710,336 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,762 | hpp | /* Copyright 2012 SequoiaDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Copyright (C) 2011-2014 SequoiaDB Ltd.
* This program is free software: you can redistribute it and/or modify
* it under the term of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warrenty of
* MARCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/license/>.
*/
// This Header File is automatically generated, you MUST NOT modify this file anyway!
// On the contrary, you can modify the xml file "sequoiadb/misc/autogen/optlist.xml" if necessary!
#ifndef PMDOPTIONS_HPP_
#define PMDOPTIONS_HPP_
#include "pmdOptions.h"
#define PMD_COMMANDS_OPTIONS \
( PMD_COMMANDS_STRING (PMD_OPTION_HELP, ",h"), "help" ) \
( PMD_OPTION_VERSION, "Database version" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_DBPATH, ",d"), boost::program_options::value<string>(), "Database path" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_IDXPATH, ",i"), boost::program_options::value<string>(), "Index path" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_CONFPATH, ",c"), boost::program_options::value<string>(), "Configure file path" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_LOGPATH, ",l"), boost::program_options::value<string>(), "Log file path" ) \
( PMD_OPTION_DIAGLOGPATH, boost::program_options::value<string>(), "Diagnostic log file path" ) \
( PMD_OPTION_DIAGLOG_NUM, boost::program_options::value<int>(), "The max number of diagnostic log files, default:20, -1:unlimited" ) \
( PMD_OPTION_BKUPPATH, boost::program_options::value<string>(), "Backup path" ) \
( PMD_OPTION_MAXPOOL, boost::program_options::value<int>(), "The maximum number of pooled agent,defalut:0" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_SVCNAME, ",p"), boost::program_options::value<string>(), "Local service name or port" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_REPLNAME, ",r"), boost::program_options::value<string>(), "Replication service name or port, default: 'svcname'+1" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_SHARDNAME, ",a"), boost::program_options::value<string>(), "Sharding service name or port, default: 'svcname'+2" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_CATANAME, ",x"), boost::program_options::value<string>(), "Catalog service name or port, default: 'svcname'+3" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_RESTNAME, ",s"), boost::program_options::value<string>(), "REST service name or port, default: 'svcname'+4" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_DIAGLEVEL, ",v"), boost::program_options::value<int>(), "Diagnostic level,default:3,value range:[0-5]" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_ROLE, ",o"), boost::program_options::value<string>(), "Role of the node (data/coord/catalog/standalone)" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_CATALOG_ADDR, ",t"), boost::program_options::value<string>(), "Catalog addr (hostname1:servicename1,hostname2:servicename2,...)" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_LOGFILESZ, ",f"), boost::program_options::value<int>(), "Log file size ( in MB ),default:64,value range:[64,2048]" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_LOGFILENUM, ",n"), boost::program_options::value<int>(), "Number of log files,default:20, value range:[1,11800]" ) \
( PMD_COMMANDS_STRING (PMD_OPTION_TRANSACTIONON, ",e"), boost::program_options::value<string>(), "Turn on transaction, default:FALSE" ) \
( PMD_OPTION_NUMPRELOAD, boost::program_options::value<int>(), "The number of pre-loaders, default:0,value range:[0,100]" ) \
( PMD_OPTION_MAX_PREF_POOL, boost::program_options::value<int>(), "The maximum number of prefetchers, default:0, value range:[0,1000]" ) \
( PMD_OPTION_MAX_REPL_SYNC, boost::program_options::value<int>(), "The maximum number of repl-sync threads, default:10, value range:[0, 200], 0:disable concurrent repl-sync" ) \
( PMD_OPTION_LOGBUFFSIZE, boost::program_options::value<int>(), "The number of pages ( in 64KB ) for replica log memory ( default:1024, value range:[512,1024000] ), the size should be smaller than log space" ) \
( PMD_OPTION_DMS_TMPBLKPATH, boost::program_options::value<string>(), "The path of the temp files" ) \
( PMD_OPTION_SORTBUF_SIZE, boost::program_options::value<int>(), "Size of the sorting buf(MB), default:256, min value:128" ) \
( PMD_OPTION_HJ_BUFSZ, boost::program_options::value<int>(), "Size of the hash join buf(MB), default:128, min value:64" ) \
( PMD_OPTION_SYNC_STRATEGY, boost::program_options::value<string>(), "The control strategy of data sync in ReplGroup, value enumeration: none,keepnormal,keepall, default:keepnormal." ) \
( PMD_OPTION_PREFINST, boost::program_options::value<string>(), "Prefered instance for read request, default:A, value enum:M,S,A,1-7" ) \
( PMD_OPTION_NUMPAGECLEANERS, boost::program_options::value<int>(), "Number of page cleaners, default 0, value range:[0, 50]" ) \
( PMD_OPTION_PAGECLEANINTERVAL, boost::program_options::value<int>(), "The minimal interval between two cleanup actions for each collection space (in ms, default 10000, min 1000 )" ) \
( PMD_OPTION_LOBPATH, boost::program_options::value<string>(), "Large object file path" ) \
( PMD_OPTION_DIRECT_IO_IN_LOB, boost::program_options::value<string>(), "Open direct io in large object" ) \
( PMD_OPTION_SPARSE_FILE, boost::program_options::value<string>(), "extend the file as a sparse file" ) \
( PMD_OPTION_WEIGHT, boost::program_options::value<int>(), "The weight of election, default is 10, range [1, 100]" ) \
#define PMD_HIDDEN_COMMANDS_OPTIONS \
( PMD_OPTION_WWWPATH, boost::program_options::value<string>(), "Web service root path" ) \
( PMD_OPTION_OMNAME, boost::program_options::value<string>(), "OM service name or port, default: 'svcname'+5" ) \
( PMD_OPTION_MAX_SUB_QUERY, boost::program_options::value<int>(), "The maximum number of sub-query for each SQL request, default:10, min value is 0, max value can't more than param 'maxprefpool'" ) \
( PMD_OPTION_REPL_BUCKET_SIZE, boost::program_options::value<int>(), "Repl bucket size ( must be the power of 2 ), default is 32, value range:[1,4096]" ) \
( PMD_OPTION_MEMDEBUG, boost::program_options::value<string>(), "Enable memory debug, default:FALSE" ) \
( PMD_OPTION_MEMDEBUGSIZE, boost::program_options::value<int>(), "Memory debug segment size,default:0, if not zero, the value range:[256,4194304]" ) \
( PMD_OPTION_CATALIST, boost::program_options::value<string>(), "Catalog node list(json)" ) \
( PMD_OPTION_DPSLOCAL, boost::program_options::value<string>(), "Log the operation from local port, default:FALSE" ) \
( PMD_OPTION_TRACEON, boost::program_options::value<string>(), "Turn on trace when starting, default:FALSE" ) \
( PMD_OPTION_TRACEBUFSZ, boost::program_options::value<int>(), "Trace buffer size, default:268435456, value range:[524288,1073741824]" ) \
( PMD_OPTION_SHARINGBRK, boost::program_options::value<int>(), "The timeout period for heartbeat in each replica group ( in ms ), default:5000, value range:[5000,300000] " ) \
( PMD_OPTION_INDEX_SCAN_STEP, boost::program_options::value<int>(), "Index scan step, default is 100, range:[1, 10000]" ) \
( PMD_OPTION_START_SHIFT_TIME, boost::program_options::value<int>(), "Nodes starting shift time(sec), default:600, value range:[0,7200]" ) \
( PMD_OPTION_CLUSTER_NAME, boost::program_options::value<string>(), "Cluster name which belonging to" ) \
( PMD_OPTION_BUSINESS_NAME, boost::program_options::value<string>(), "Business name which belonging to" ) \
( PMD_OPTION_USERTAG, boost::program_options::value<string>(), "User defined tag" ) \
#endif /* PMDOPTIONS_HPP_ */ | [
"brightpegion@gmail.com"
] | brightpegion@gmail.com |
2b6ed47e44b02a2e1c862299a88415bd14d09c90 | f9726d2483d3c5ac38c8867a9cf962dc1bcaf5b4 | /CSE 225L Data Structures and Algorithms/Resources/Codes Previous/Spring-2019-CSE225 1/Lab12( Stack and Queue Linked List )/queue(3).h | 1619105de8029357665dd2918dcc901de65d2725 | [
"MIT"
] | permissive | diptu/Teaching | e03c82feefe6cda52ebd05cd644063abb3cf8cd5 | 20655bb2c688ae29566b0a914df4a3e5936a2f61 | refs/heads/main | 2023-06-27T15:27:32.113183 | 2021-07-31T05:53:47 | 2021-07-31T05:53:47 | 341,259,841 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 373 | h | #ifndef QUEUE_H_INCLUDED
#define QUEUE_H_INCLUDED
#include "list.h"
template<class T>
class QueueLL : public SinglyLinkedListWithTail<T>{
private:
SinglyLinkedListWithTail<T> ls;
public:
QueueLL();
~QueueLL();
virtual void enqueue(T value);
virtual T dequeue();
virtual T frontItem();
virtual bool isEmpty();
};
#endif // QUEUE_H_INCLUDED
| [
"diptunazmulalam@gmail.com"
] | diptunazmulalam@gmail.com |
d2ae11c2ec0b66b849c4092e6510396cbac32dd0 | 5e00242dc035fdab6aa6bbb40c6d7e6c119ad8e6 | /Vault/CodeJam2018/R2/CostumeChange_Testset1.cpp | 9559b4e47eda6896f3d32ad6d5afcbc854e47e34 | [] | no_license | AkiLotus/AkikazeCP | 39b9c649383dcb7c71962a161e830b9a9a54a4b3 | 064db52198873bf61872ea66235d66b97fcde80e | refs/heads/master | 2023-07-15T09:53:36.520644 | 2021-09-03T09:54:06 | 2021-09-03T09:54:06 | 141,382,884 | 9 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 16,374 | cpp | /**
Template by Akikaze (秋風) - formerly proptit_4t41.
Code written by a random fan of momocashew and Chiho.
H△G x Mili - November 27th, 2013
Mag Mell (Mili) - Sep 17th, 2014
H△G x Mili Vol.2 - May 9th, 2015
Miracle Milk (Mili) - Oct 12th, 2016
青色フィルム (H△G) - February 14th, 2018
Millennium Mother (Mili) - April 25th, 2018
**/
/** -----PRAGMA----- **/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
/** -----BASIC MACROS----- **/
#define endl '\n'
#define i64 long long
#define ld long double
#define rsz resize
#define pub push_back
#define mp make_pair
#define fi first
#define se second
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double PI = 3.141592653589793116, EPS = 1e-9, GOLD = ((1+sqrt(5))/2);
typedef vector<i64> vi;
typedef vector<ld> vd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<i64, i64> pii;
typedef pair<i64, pii> pip;
typedef pair<pii, i64> ppi;
i64 keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
vi HashMod(keymod, keymod + sizeof(keymod) / sizeof(i64));
/** -----BIT CONTROLS----- **/
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s); }
/** -----IDEAS/ALGORITHMS-----
-------------------------- **/
/** -----CUSTOM TYPEDEFS/DEFINES----- **/
/** -----GLOBAL VARIABLES----- **/
i64 T, N, cas = 1, ans = LINF;
vector<vi> A;
/** -----EXTENSIVE FUNCTIONS----- **/
bool check(vector<vb> B) {
vector<vi> C = A;
for (i64 i=0; i<N; i++) {
for (i64 j=0; j<N; j++) {
if (!B[i][j]) continue;
vb cc(N*2+1, false);
for (i64 x=0; x<N; x++) {
if (x != i) cc[C[x][j]+N] = true;
if (x != j) cc[C[i][x]+N] = true;
}
for (i64 x=0; x<=2*N; x++) {
if (x == N) continue;
if (!cc[x]) {C[i][j] = x-N; break;}
}
}
}
for (i64 i=0; i<N; i++) {
vb cc(N*2+1, false), cr(N*2+1, false);
for (i64 x=0; x<N; x++) {
if (cc[C[x][i]+N]) return false;
cc[C[x][i]+N] = true;
if (cr[C[i][x]+N]) return false;
cr[C[i][x]+N] = true;
}
}
return true;
}
/** -----COMPULSORY FUNCTIONS----- **/
void VarInput() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
cin >> T;
}
void ProSolve() {
ans = LINF; cin >> N; A.clear(); A.rsz(N, vi(N));
for (i64 i=0; i<N; i++) {
for (i64 j=0; j<N; j++) {
cin >> A[i][j];
}
}
for (i64 i=0; i<(1 << (N*N)); i++) {
vector<vb> B(N, vb(N, false));
for (i64 j=0; j<N*N; j++) {
if ((i & (1LL << j)) != 0) {
B[j/N][j%N] = true;
}
}
if (check(B)) ans = min(ans, (i64)cntbit(i));
}
cout << "Case #" << cas++ << ": " << ans << endl;
}
/** -----MAIN FUNCTION----- **/
int main() {
#ifdef Akikaze
//freopen("FILE.INP", "r", stdin);
//freopen("FILE.OUT", "w", stdout);
#endif
VarInput();
#ifdef Akikaze
auto TIME1 = chrono::steady_clock::now();
#endif
while (T--) ProSolve();
#ifdef Akikaze
auto TIME2 = chrono::steady_clock::now();
auto DIFF = TIME2 - TIME1;
cout << "\n\nTime elapsed: " << chrono::duration<double>(DIFF).count() << " seconds.";
#endif
return 0;
}
/**
KKKKWWWWK;:.....:;,,,,,,,::,,,,,,,::,,,,,,i;,;ttttttt;:....:;EEDLffjfLGKWWWKLjjjfDWWWWWDffjffffi::::
WWWWWWWWW;:.....:;,,,,,,,::,,,,,,,:::,,,,,;;,,ttttttt,:....:,GDDGLLffLGDWWWKLjttjGWWWWWDfjjjjjji:...
WWWWWKWWW;:.....:,,,,,,,,::,,,,,,,:::,,,,,;;,;ttttttt,:....:,LGGGGGLLLLDWWWKftttjGWWWWWGjjjjjjj;:...
WWWWKKKWW;:.....:,,,,,,,,::,,,,,,,:.:,,,,,;;,,ttttttt,:....:,DDGGGGLLLLDWWWKfttttGWWWWWGjtjjjjj;:...
WWWWWWWWWi:.....:,,,,,,,,::,,,,,,,:::,,,,,;;,,ttttttt,......,EDGGGLLLLLDWWWKjtittGWWWWWLjtttttt;:...
WWWWWWWWWi:.....:,,,,,,,,::,,:,,,,:::,,,,,;;,;ttiiiit,......,DDLLLLLfLLDWWWKjiiitGWWWWWLttttttt;:...
WWWWWWWWWi:.....:::::::::::::::::::.:::::::,,,,,,;;;;,:.....,fLfffffjffGKKWEjiiitLWWWWWLttttttt;:...
WWWWWWKEDi:.....:::.::.:.:.......:..::::::::::::::::::......:,,,,,,,,,,;;;;;,,,,,,;;;;;;,,,;;;;,:...
KKEEKKEDG;:......::,,::,,:::::::::::::::::::.:::::::::......:::::::::::::::::::::::::::::::::::::...
jjttffLDG;:......:,ii;;ii,:,ii;;ii,:,i;,,;;::,;,,,,,:.......::,,,,,,:::,,:,,:::,,:,,,::::,::,::::...
ii;iiitLf;:......:,it;;it;:,it;;tt,:,tt;;ti,:;i;;it;:.......:,ii;;ii,:;ti;it;::;;;;ti,:;i;;ii,::....
iiiiiijft,:......:,ii,,;i,:,ii;;ii,:,ii;;ii,:;i;;;i;:.......:,ii;;ii,:,t;;it;::;;;;ti::;i;;ii,::....
tttttjffi,.......:,;;,,;;,:,;;;,;;,:,;;,,;;::,;,,;;,:........,;;,,i;,:,;;,;i,::;;,;i;::;;;,;i,:.....
ffjjffLft;:......:,i;;,;i,:,ii;;ii,:,ii;,;;::,;;,;;,:........,;;,,;;::,;,,;;,::;;,,i;::;;;,;;,:.....
LLLLLGGGf;:......:,ii;;it;:,tt;;tt,:,ii;;ii::;i;;;i;:........,ii;;i;::,i;;ii;:,ii;;ti::;i;;ii,:.....
DGGGGDDDLi:......::;;,,;;,::ii;;ii,:,i;,;i;::;i;;;i;:........,ii;;ii::;i;;;t;:,ti;;ti::;t;;tt,:.....
EEEEDDEDGt:......::::::::::::::::::::,:::,:::,,,,,,,::.......:,,,,,,:::,,,,;,::;,,,;;::,;,,;;,:.....
EEEEDDEEDj:....................................::::::........:::::::::::::::::::::::::::::::::::....
EEEEDDDEEG;:......................................................::................................
EEKEEEEEEGj:..............................................:.........................................
KKKKKKKKKEL;:............................................::.........................................
WWWWWWWKKKDj:.........................................:::::...::::,:............................::::
WWWWWWWWWKEG,:............::::................:jfLffLLj::,,::::.::,:.......................:::::,,;i
KWWWWWWWWWKD;::::,,,,,,,,,;;;,;::::::::..::.;tffLjffDGjfttL,,:::::,,,:.............:.......:,,,,;;ii
KKWWWWWWWWft,:::,tGGGGGGLGGfji;;tfttttfffLL;ittjjjLLGLGffEjttji,,,::;i,,,,,;;;;;;;,;,,,,;;,,,;;;;;;i
KKKKKKKWWD;:::..:;DGDEEEEEEGji,;;iitjittLttit;tjjfDGGfLfGfGffjfjfit,;;;itLDEDDDGGGGGjiitti;;itji;;;i
KKKEDEEKWK;:....:;GGDKWWKKELLji;;iiti;;;tjjjLtfjjtfjLLLLGffLLLLfLLj;;,,;;tDEDDDDGGGLt;;tii;;iitiitit
WWKEDDEKWWG,:...:;DKDEW#WEjt;;i;ii;;;;;,GLDDGDDLGEitDjLLGGGLDGfEELfGi,,i;;tjLGDGLGEjiiitttiitttiiitj
WWWKKKEEKKWj::.::iDEDDEWWDii;;;;;;,,;;,,LDEGEKEDELGLfGLfLLLfDGKWDELGLjii;;;;tGGLfGEjiiiiiittti;;;;it
WWKKKEDDDKKKt;,;iLGGGLLLGfiii;i;,;i;ii;DDKDLKEEEKKDKfLjEfELDGEKELEKEEtti;;i;tffffLGLt;;ttttjt;;iittj
WWKKEDGGGDEEEDDDGfjtttiii;;,,;i;,ii;;itEKKKKWKKKKKKEEELtLfDGKWDEWKKLLGDj,;iijLfjjjfLfitjtttjtittjfff
KEEDGLffLGGGGGLfjti;;;ii;;,;,;iii;,iiiDWKKKKWWW#WWWKKEEDKGDfWfKWWEGGGjiti;iitjtttttttittiittttjjjttf
EDDGLfjjfLLfffjtti;;;;tjt;;;,;;;;;,,;;KWWKEWWWWWWKEKKEKDEEDWEKWKEDDDEG,,iii;;iiiiii;;;iii;;;iitttttL
KKEEDGjitffLLLffjti;;itjj;;,,;,;,;,,;DKWWWWWWWWWWWKWWEWKKW#EEKKKEGWWEj;:,i;,,;iti;;;iiiiii;;iitiijjD
WWWDLfjiiitfDGfLLffttjjji,,,;;;;;,,,;KWWKWWWWWWWWKWWWWWKWWWWKKKEWWWKfii,:;;;;tti;,,tGGGLGGLLLfjjjfDD
WWDfjtiii;;;;;,;;iitfLj;,,:,i;i;ti;;jWWWWWWW#W#WWWWWWWWWWWWEWWGW#KWGjti,:,,,,iti;,,fWEjtjLLjfLjjjji;
WDGfji;;iii;;,:,,,,,;;;;;,,;;ii;;i;;KWWWWWWW#W#WKWWW#W###WGWE#WWKWKfti;,,:,;;;ff;;;fWKfjt;;ijfjjfi,:
EGGGfjiitiii;,,,,,,,;;;ti;;;iii;;t;iWWWWWWWW#WKKWWWWWW###WW#WWWWKELjti;;;,,,,,;;;;;jGGjt;;itjjtit,:.
LEEGGLjjji;;;;,,,,;;iitttt;;tti;;tfGW#WW#WKWWWK#WW##W###WWWWW#WWKELtii;;;;,,,,;;;,;fji,;iii;iti,;,:.
fWDLGLfLjii;;;,,,;;;;;;;iii;iji;itfEWWWWW#WW#W##WW#W######W#WWWKGLjiii;;;;i;;;;ti;;ti;:,;i;,;;;:,,:.
fWEDGLffjjti;;,:,,,,,,;iii;;tjt;itfKWWWWWW##WW#WW###W##W###W#WELjtii;;;,;;ii;,,i,,ij;,,,;i;;;,,::...
fWWKGtttii;,;i,,;i;,;iit;tf;;tfiitjWWW##W#WW#WW##WWW########WKftitii;;;;t;tt;,,,::;,:,;;ii;;;i;:....
fWKKLtiii;,,;ti;tjtitii;,,;;tjftiiEWWWWWWW##WWW##W##K##W###WWEtii;;;;ffDKjfji;,,:;;;;;;itttiijt,:...
LWKEjttiii;ijjfGLjttti;;;;;iifLt;;EWW#W#WWWKWK#WW###WW#####WKGiiiiitjfffGjjti;;;;t;,;;ttijiiijti;:..
LKKEtittjLjjGDDEEGji;;;;;iittGGf;iKWWWWWWEEWW#WWWW#KKKW###WWKfii;itLGLjiffj;;;,;;ii;,,jjjiijt,,;,,:.
LKKDjijLGLfLDKKftjt,,::,;;;LffLGjKKWWWWWWKWWWW#WWW#WWKWW##WEGjii;;iLDKEtjjt;t;;,,;iittLLDjtLfi,,:::.
LKEELffLGLLDDEj,,;tt;::,ittfGfjDGDWWKWW#KWKW##WW###WWEEKWWKDft;i;;;tGK#Eitiii;,:,;LfjfLtLLtLjjti,:..
GKEKDGLGGGDEEDii;;itti;;jtijLfjtGKWWWWWKWEWW#####W#WWGDEKKEDfi;;;;,,;fGt;i;;i;,,ittjjtttjGGELLti;:..
GEEDGfGGLffLLiiji;;;;tjtfjjffLfjGWWWWWWWWWWW#######GKDDDEEEDtti;;;,,,tt;,i,;jfttij;jfitfjLGEEf;;,:..
GEEDLjLDDjtfi,ijt;iitff;tDDLfGLEGWW#WWWWW#######W##EGEDGDEEGjiii;i;;,,,,,,,;jGt;ttfjjjifDDfLEE;::,::
LEEDLjffjfGGiifGDjfttLDitffjfGjDDKWWWWKWW##W#W#####KGLGGDGDLttiiiiii;,,;;:;tit,,tiii;iiLGGGtLEi:.:,:
GEEELjfttfGLfjfGDLGGGKKfLfLGLLjGKKWWWWWW###########DtfGGLEGfjttttttti;,;;:ii;,,;;i,i;iiLLj;;fft:.::.
GEEGGLLLfjjfGELLLfGGGLEt;;tjGGLEW##WWWWW##W########WWEGLLLftttttttjti;,t;,.jt;iiiiijfitjjt;,;tt;,:,,
DDLGGDEDLjjjGEftjLEfffi,,,;tjjEWWWWWWW##WW#########WWWELLjjttittttttti;i;ttjf;ititffjitjfj;::;itiitj
DGLGEEKDjtjLGjttjfLLGj,,;i;iiiDWWWKKWW##W##########WWWELfjttiittttjtttGjjKji,,fGjjfLj;tLft;::,,ittjL
GDGDEKKLttfKDjtLDfLDDi,itttjiiEKWWWWW##############WWKELfjtttitttttjjttEftit;;DDLjfLjijjtti,::,;jjLG
GEDDEKEGjGWWKEKWWEEEEfjfLjttjLKKWKWWW##############WKKEGfjtttttttjjjjt;jfj;tjLEELjfffttiti;;::,,;fDE
GEDDEKKGjLKWW#WWKDGEEEDGDLjtjDKWWKWW###############WKKEDLjjttttjjjjffjt;LjtjfGDGGfLtLjffLjit;:,,,jEE
LEDDEEKGjjLKW###EttDEEGfjLDLEEKWWW##W###W##########WEEEGLfjjjjjtjjfffDDLjjftLLLftfjiLDEDffftj;i;,iDK
LEDEEEEDjtfEW#WWLtjEEGfjjfEKEEWWWWW################WWEEGGLjjjjjjjffLKDEGttjjfjttijfDGLLfjft,;ttt;;fD
LEDEKEEDffGWW#WWDfGELLffLfKEEWWWWW#################KDEDDLLfjjjjjjffLfLLftttjtjfGjifEELfjjj,.:,;ittjj
GEEKKWKEGDKWWW#WWEEELGfjLEEEEWWWW#################WKDDDDGLLfjjjjfLLfjLLjjjjfjjLEDjEWELfjjj;::,,ijfjj
DEEKWWWKEEWWWWWWWWWWEGjfGEEKKWWWW#################WELGEDGGLffjjffLLffjjtjLDLLLfEEjKWELGjfjti;itffffj
EEEKWW#WKKWWWWWWWWW#KLLEDDEKWWWWW##############W#WEELGDDGGLffjfffLfffttttfDGGGLEKDWWKEDitfLLLGGGGLLL
DDEKWW#WKKWWWWWWWWWWEGEKEEKEKWWW#################WGGLGGDGGLfjfffffffji;tjfLGDEEEWKDEGLGijGEEEDGLLLff
GDEKWW#WWKKKKKKKWWWWDEKKEEDLWWW########W########WEDLLLGDGGLGEGtjfffLfi;;;tGDDKEDKLtfDLftttfGfjiii;;;
GDKKWW#WWKKKWKDEKKWWKKKKKKDEWWW##W##############KELLLLGDGGGELjLEjjjfj:,tijDDDEEDEGjjDGjt;,iti;,,,,,,
EKKKWWWWWKKWWKDDKKWWWKKKWKKKWWW##WW###WW###WWW#WEGLffLLGGLEDLLDEL;tGi:,jjGGGDEDLLDGffGji;,;;;,,:,:::
WKKKWWWWWWWWWKDLGEKKWKEKWKKKWW##WWW##WWW##WWW#WEDLfffLLLLEDDEEKKGjfDLjLjiLLLDEDjfGGffGti;;;;;,,,,,,:
WKEEEEEKWWWKEEEGLDEKKEDGEKKWW###WW###WW##WWWWWDGLffffLLLDELDEEKWKEGGGLLLiijttDDLGDDGGLjttiiiiiiii;;;
WKEEt;;LWWWEDDDDDDEEGGGjLEKWW##W####WW#WWKWWWDfjjjjffLLLEEGDKEWWWEDDGGfLfit;,;GGKKEGGfGGGLfjffLLLfjj
WWKi:.:iKKKEEDEEDDDDGGfitKWWW##K###WWW#KEKWWfiiittjjfLLfGEDKKEKWKEDDDGtifftji;jDKKEDGfEKEEEEEEEEKEDD
WKt: :jEEEEEEEEDDEDDDjtGKKWW##W###WW#GfKWL;,,,;ittjfLfEEDDEKEEKWWELGDLjffjGEfLDWWEDLLEEEEEEKKEEEKKE
Kt:. :iGDDDDDDDDDDDDGGLLKWEW##WW#WW##GDKDi....:,;ittjfKWWKKKKEEKWKKEEGGfjjLDEEGGWKDDfLDGLDKKEEGGDEEE
t:. .;LGGDGGGGGGGGGGLLGGGWWW#WW#WWWWGEj;. .,;iitftGLKWKKKKDEKEDKKDGftLDDGLGEDLfjDEDDEWWWKDDEKKK
:. .,tLGDDGLLLLLLGGGLLGGDWW##W###WWKK:, ...;;it;tGEKKWKKEEKEEKKDDt;tGEGfLDDLjfEWWWWW#W#WWWWWW
. .:j;iLGGLffLLLLLLGLLDGDKW######WWW.: ...;i;;jEKKKKWWKKWWKGLDGtffGGfjGDfjGEKWWWWWWWWWWWWW
..:tGiifLLLffffLLLLLfLGLGKW#####WWW.: ....;;;DKKKKKWKKKWKLfDKDLjfGjjGGtjLGEWKKKKKKKEDEEK
:,ifLjjLLffffffLLLLLfLLLGKW#W###WW:, ...::tGKKKEKWKKKKKDfGEEGfLLjfGftjGDEEDEEEDEDDGDED
iitLLtjfffffffffLLLLLLGGDWWWW##WWG.. .....::KDGEKWKKWKKELLEKEjtjjffttLGGEEDDDDDDDDDDDD
Dj;tjtjffffLffjjfLLLLGGGG#######W:: ....::EEEKKWEDEKKKDLDEDfttffLtfLLLGGGGGGGGGGGGGG
DL,;ttffjjfLffjjLLLLLGDGDW######E: ....:.WWKKKEDEKKKKGGDLLjtjfDLfjffLLLLLLLffffffL
DDjitjffjfjjffffLfLLLLDGGWW#####: .. ..:..EWKKEKKKWKKKEEDftttjfGfttjjffffffjfjfjjjj
DDjttjjfffjjfffffjfLLLDDDW#####W: ... . .i,iit;;ft .....KKKEKKWKWEEKKDfjLLfjfjtjjjjjjjjjjjjjjjjt
DGjtjjffffLfLfffffLLLLGDEW#####t.... .. GG.ttjLDf:,f .....;KKWWWWWWKDEDDLLDGftjjjjjjjjtttttttttttt
DLjjjfffffffffffLLGLLLGDE######: .: . .. ,. .jE,:.....EKWWWWWWWKELGDDEGjjjjttttttttttttititti
DfjjfLLfffffLLLLLGDGGEEEKWW###L .:... ... . .j......KKWWWWWKKKGDDDEGjtjtttttttiiiiiiiiiiii
DjjfLLfLLfjfGLGGGDDDDDEE#W#W##,.::....... .:...::::.. ;.....iKWWWWWKKEDDGLffttjtttiiii;;;;;;;;;;;,
LjffLLLGLfffGGDDDEDDEEKKWW###W..,......... :,:::...:: :.....KWWKKKKKEfGDGfffjjtttii;;;;;;;,,,,,,,
LLLLGGGDDGGDEEEEEEDDKKKWWW###,.:,..... .: :,,:..:...:,, :.... KWKKWKWGjLDDGLLLttti;;;;,,;;;,,,,,,,
LGLLGGLGDDDEEEEKKKKKKKKW#####:.::........:..,,:::::...:,,:......tKKWWKKDfDKGjjfLttti;;;;,;;;;,,,,,,,
GGfLLLLGDEEEEEEKKKKKKKKWW####..::........::;;,::::::...:,,,......KWWWWEDLDEGjijftiiiii;i;;;i;;;;;;;;
LGffffGEKKKKWKKWWWKWKKKW####j.::::.......:;,,::::,:....:,,:;:.....WWWKKEGEEKGtfjiiiiiiiiiiiiiiiii;;;
LLfLfLEWWWWWWWW#WWWKKEWWW###:.::::::...:::,:,::,:::.....:,,;:.....EWWKKKDEKWKLLtiiiiiiiiiiii;ii;;;;;
LffGGDKWWWWWWWWWKKEEEEWWWW##..::.:::.:.:::,,:,,:::::....:,,:,:.....WWWEEEEKWWKDt;;iiii;;;;;,,;;,,,,,
LffDDDDEEDDEDDEDDEDDDDEKWWWW..::::::::.:..:,:,:,:::.....:,,,;,.....tWKEEEEKWWWDt;;iiii;;,,,:,,,:::::
LLfGGLLGGLGGDDDDDGGDGEEWWE#W.::::::::::::.,,:,,,:::......:,,;,:.....EEEKEDEWWWDi;;;iii;;,,,:,;;,::::
LfjGLLLGGLLGDDGDDLGDGEEWEEWW..:::::,,..:..,,,,,,::.......:,,:,,.....jEEKGGEWWWGt;;iiiii;;,,:,,,,::::
ffjLGGGGGLGDGLLDGLGDEEKWGE#W...::,:,:.::.::,,,,,::.....::::,,,,,.....KKEDDKWKKDj;;iiiiii;,,,,,,,::::
ffjfLLGGLLGDGLLDGLLGEKWWWKWW...::,,,:.:.::,,,:,:,:......::,:,;;,... .EEDDEDKKWEj;;iiiiiii;,,,,,,::::
LftjLLGLLGGDGLGGKGfjDWWWEEW#....:,,,::::::,,,,::::.. ..:::,,,,,:....DEDEEGGDEDfi;;iiiiii;,,:,,:::::
LfjjLGDGLGGGGGGGGEEEEWDGE#W#....::,:::.:::,,,::::.. .....:::,:,,,... GKDEEEDEKEELiiiiiiii;,:,,,:::::
GLjjLDDGGLGGLLLGLLKKEGKWWWW#i...::,:.:::::,,,::....:.::...:.,:,,,:....KDLLDEDEDDLjttttttti,,,;;,::::
GGffDDGGGGDLLLGLfLGKWWW##WW#i;...:,:::,,::,,:::,,,;,;t;: ,i::::,,,:...EDjtGDGLjffjfjjjjttt;;;i;,,:,:
DGffGDLLLGDLLLGfffLGGLW#####,t:.::,:::,,::::;:,;ii;;iitt:::i::;:,,:...LEfjGLLftjLfffjjjttttiti;,,,,:
KEGLGGLffGGLfffjjjfGfffL####;i,:::::::,:::tiiii;i,,;iiii:,;:;,f:,,,:...WKKKKKKDDEEGEfjtttttttt;,,,,,
KEEEDGffLGLjtfffffLGjtjW####;;,.:::..:::jt;;;ii;;i;;iii;:,;;,,,;:::::..WWWWWWKKEEEDEftiiiiitti;,,,,,
DDDDDGLLGGLfjLGfffLGtitjjGW#f;,::::.::,ii;i;;;i;;iiii;;,:,:,;;;W:,:::::WWWWWWWWKGEKEt;;;;;;;;;;,,,,,
GDDDEDDGGLLfLGLjtjLLtittjjjW#;;::.:.:;i;;;,;;;i;;iii;;i.,,,::,:Gj::::::WWWWWWWWWDGGDi;;;;,,,,,,,,,,,
DDEEDGGGDGGGGDLLffLftttjjttjfi;::.::;t,i;,,;,;;;;;;;;;;.,,,,;;:ED:,:,,:KKWWWWWWWWEEKt;;;;,;,,,,,,,,,
DGDEDGLGEDGGGLffffjitttjjiitji;,::::j;,i,;;;;;;;;;;;;;,.:,,:,;,.L#:,,,,WWWWWKWWWWWKEt;;;;;;;,,,,,,,,
LGDEEGLGDGLLLLjjjftitttjftitjLit,,:;j,;i,,,;;,;;,,;;;,::,;,::;,.EG,,:;,WWWWWKWWKKWEEt;;;;;;;;;;;;;,,
GGEEDGGGLfffGLfjtjffjjttjtttjfiii,,tj:ii,:,;;;;;,,,,,,.:,;;,.,,,.GW:,;,WWKWWWWWWWWKGjttttiiitttiiii;
GLLDDDDLffjfGLffjjLfjtitfjjjjLtij;,tf,t;::,,,,,,,,,,,,.,,,,,:,,::;f;;i,KWKKWWWWWWKKLijjjjjjjtttttttt
GLfGGGDLffjfLfjjjfGjtiitfjtjjLLitt:tf;i;,,,;,,,,,,,,,::,,,,,:;;:;.KG:i;WKKWWKWWWWWWGtjjjjjjttttttttt
EEGLLGDGfLfLLffjjLLtiiitfjjjjLfjij,jj;ti,,,,,,,,,,,,,.:,,,,::;;:;::L:iiWWWKWWWWWWWWKLjjjtttttttttiii
DDLffLGGLLfLLjjjjfftiiitftttjGfftttjj;i;:,,,,,,,:::,,.:,,,,,:,,:i,,E;iLWWKKWKKWWWWWKDtttttttttiiiiii
DLfjfLDLffffjttjjfftiiiijtjjfLLLjttfj;it:,,,,:,,,::,,.::,,,,:,,,ii,WtiKWWKKWKKWWWWWEGtiiiiiiiiiiiiii
DfjjjGGfjfLLjjjjfLLjjjjffffffLfjfjtffiti,,,,,,,:,:::::,:,,,,:,,:ii,LtiKWWWKKWWWWWKKKGtiiiiiiiiiiii;i
DGLLLDGfffLGLfffLLfjtttjfjjjffLjfjjtLtti:::,:,:,::::.:,,,,,,,:,:ii;f;;KKWWKKWKWWWWKKEjii;i;;;;;;;;;;
GLLLGGfjfjfLfjjjLGLftttjfjjtjfffLLjjjGtt:,,,,,,,,::: ::,,,,,::,,it;Ei;KWWWKKWKWWWWWWELi;;;;;;;;;;;;;
GGGLGLfjjjfffjjjLDGLjtttjjjjjffjfLffjLti,,,,:,,,,:::.::,,,,:,:,;tt;LiiKKKWWWWWWWWWWWKDi;;;;;;;;;;,,,
GGLLDLffjfffffffGGDGfjtjfjjjjLLLffLjfjtt,,,,,:,:,:::.:::::,:::,itt;ti;KKKWWWWWWWWWKKKEi;;;,,,,,,,,,,
LLLGGjjjffLffjjfLGGLfjjjfjjttjjffjjLfjjt,,,,,,,,,::::::::::,,:,ittDtijWKKWWWWWWWWWWKEDi;;;;;,,,,,,,,
fjLDjijfLLGLfjfLGLfjjjjjfjjjjfLGGLLDjftt;,,,,,:,,,,.:::,,,,,,:,ttt#tiWWWKWWWWWWWWWWWKEj;;;i;;;,,,,,,
jjLEfjjfjfLfjttLGLjtjtttjjtjfLLLGGGDEjftt,,,,:::::: ::::::::::,ttKKjiWWWKKWWWWWWWKWWKKDi;ii;;;;;,,,,
jjfGfffjtjjjjffLGGjtjjiifjjjfLLLGGGGELjLt,,,,,,::::.::::::,:,,,ttWELKEWWWKKKWWWWWWWWWWKj;ii;;;,,,,;;
jjjffffjjffjjffLLLftttitjjjtjfffLLGLGLjft,,,,,:::,,.::::::,,,:;tjWKE,WKWWWKKKWWWWWWWWWWjii;;;,,,,,,;
**/
// Tribute to a friend I owe countless. Thanks, TN. | [
"duybach.224575@gmail.com"
] | duybach.224575@gmail.com |
329da81cbbb59814ca66a9c792619a8f96725486 | 24bc4990e9d0bef6a42a6f86dc783785b10dbd42 | /ash/system/unified/date_tray.cc | 0850ce6b99decdc960f23cbfe7b11f2575819579 | [
"BSD-3-Clause"
] | permissive | nwjs/chromium.src | 7736ce86a9a0b810449a3b80a4af15de9ef9115d | 454f26d09b2f6204c096b47f778705eab1e3ba46 | refs/heads/nw75 | 2023-08-31T08:01:39.796085 | 2023-04-19T17:25:53 | 2023-04-19T17:25:53 | 50,512,158 | 161 | 201 | BSD-3-Clause | 2023-05-08T03:19:09 | 2016-01-27T14:17:03 | null | UTF-8 | C++ | false | false | 3,532 | cc | // 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.
#include "ash/system/unified/date_tray.h"
#include "ash/constants/tray_background_view_catalog.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/model/clock_model.h"
#include "ash/system/model/system_tray_model.h"
#include "ash/system/time/time_tray_item_view.h"
#include "ash/system/tray/tray_background_view.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_model.h"
#include "base/time/time.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
namespace ash {
DateTray::DateTray(Shelf* shelf, UnifiedSystemTray* tray)
: TrayBackgroundView(shelf,
TrayBackgroundViewCatalogName::kDateTray,
TrayBackgroundView::kStartRounded),
time_view_(tray_container()->AddChildView(
std::make_unique<TimeTrayItemView>(shelf, TimeView::Type::kDate))),
unified_system_tray_(tray) {
SetID(VIEW_ID_SA_DATE_TRAY);
SetPressedCallback(
base::BindRepeating(&DateTray::OnButtonPressed, base::Unretained(this)));
tray_container()->SetMargin(
/*main_axis_margin=*/kUnifiedTrayContentPadding -
ShelfConfig::Get()->status_area_hit_region_padding(),
/*cross_axis_margin=*/0);
scoped_unified_system_tray_observer_.Observe(unified_system_tray_);
}
DateTray::~DateTray() = default;
std::u16string DateTray::GetAccessibleNameForBubble() {
if (unified_system_tray_->IsBubbleShown())
return unified_system_tray_->GetAccessibleNameForQuickSettingsBubble();
return GetAccessibleNameForTray();
}
void DateTray::HandleLocaleChange() {
time_view_->HandleLocaleChange();
}
std::u16string DateTray::GetAccessibleNameForTray() {
base::Time now = base::Time::Now();
return l10n_util::GetStringFUTF16(
IDS_ASH_DATE_TRAY_ACCESSIBLE_DESCRIPTION,
base::TimeFormatFriendlyDate(now),
base::TimeFormatTimeOfDayWithHourClockType(
now, Shell::Get()->system_tray_model()->clock()->hour_clock_type(),
base::kKeepAmPm));
}
void DateTray::UpdateLayout() {
TrayBackgroundView::UpdateLayout();
time_view_->UpdateAlignmentForShelf(shelf());
}
void DateTray::UpdateAfterLoginStatusChange() {
SetVisiblePreferred(true);
}
void DateTray::CloseBubble() {
if (!is_active()) {
return;
}
// Lets the `unified_system_tray_` close the bubble since it's the owner of
// the bubble view.
unified_system_tray_->CloseBubble();
}
void DateTray::OnOpeningCalendarView() {
SetIsActive(true);
}
void DateTray::OnLeavingCalendarView() {
SetIsActive(false);
}
void DateTray::OnButtonPressed(const ui::Event& event) {
// Lets the `unified_system_tray_` decide whether to show the bubble or not,
// since it's the owner of the bubble view.
if (is_active()) {
unified_system_tray_->CloseBubble();
return;
}
// Need to set the date tray as active before notifying the system tray of
// an action because we need the system tray to know that the date tray is
// already active when it is creating the `UnifiedSystemTrayBubble`.
SetIsActive(true);
unified_system_tray_->OnDateTrayActionPerformed(event);
}
BEGIN_METADATA(DateTray, ActionableView)
END_METADATA
} // namespace ash
| [
"roger@nwjs.io"
] | roger@nwjs.io |
dadc05b9b4c653d28f37d3c95e2221775bb2976b | 3b643754f27f6b07863de364846fce45665d0901 | /src/ufile/utextfile.cpp | 508019cf42eb8f8cb51a44af1681c0625f836589 | [] | no_license | windnc/ulib | 6f0e0d2e36ddb62c4cdab69a82e147b33383a4ef | cdb1b33338ac633693465628fbcf58513eff342c | refs/heads/master | 2020-05-30T14:33:05.307969 | 2014-01-29T07:17:43 | 2014-01-29T07:17:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,332 | cpp | /*
작성자 : swlee
작성일 : Sep. 22, 2006
버전 : 0.6.0
설명 : text file
미구현 :
버그 : write mode로 연 후 CloseFile()로 닫으면 그 이후에system명령어로 이 파일을 쓸려고 하면 에러
*/
#include "utextfile.h"
namespace ulib {
//////////////////////////////////////////////////////////////////
CUTextFile::CUTextFile( int arg_verbosity )
{
Verbosity( arg_verbosity );
Init();
}
//////////////////////////////////////////////////////////////////
CUTextFile::CUTextFile( CUString arg_file_name, CUString arg_file_mode, int arg_verbosity )
{
Verbosity( arg_verbosity );
Init();
OpenFile( arg_file_name, arg_file_mode );
}
//////////////////////////////////////////////////////////////////
CUTextFile::~CUTextFile()
{
if( verbosity >= 1 ) {
printf( "CUTextFile Release...\n" );
fflush( stdout );
}
CloseFile();
if( verbosity >= 1 ) {
printf( "CUTextFile Release... [OK]\n" );
fflush( stdout );
}
}
//////////////////////////////////////////////////////////////////
void CUTextFile::Init()
{
fp = NULL;
content = NULL;
file_size = UNKNOWN;
num_line = UNKNOWN;
now_line = 0;
}
//////////////////////////////////////////////////////////////////
bool CUTextFile::OpenFile( CUString arg_file_name, CUString arg_file_mode )
{
if( verbosity >= 2 ) {
printf( "OpenFile... %s(%s)\n", arg_file_name.GetStr(), arg_file_mode.GetStr() );
fflush( stdout );
}
// check
if( arg_file_name.IsEmpty() ) return false;
if( arg_file_mode.IsEmpty() ) return false;
// open
file_name = arg_file_name;
file_mode = arg_file_mode;
fp = fopen( file_name.GetStr(), file_mode.GetStr() );
if( !fp ) {
return false;
}
// get file size
MoveToEnd();
file_size = ftell( fp );
MoveToStart();
if( verbosity >= 1 ) {
printf( "OpenFile... [OK]\n" );
fflush( stdout );
}
return true;
}
////////////////////////////////////////////////////////
bool CUTextFile::CheckOpen( FILE *fp )
{
CUString color_str = GetFileName();
color_str.SetColor( "light_blue" );
fprintf( fp, "File open [%s]... ", color_str.GetStr() );
if( IsOpen() ) {
CUString msg = "OK";
msg.SetColor( "light_blue" );
fprintf( fp, "[%s]\n", msg.GetStr() );
return true;
}
else {
CUString msg = "FAIL";
msg.SetColor( "light_red" );
fprintf( fp, "[%s]\n", msg.GetStr() );
return false;
}
}
////////////////////////////////////////////////////////
void CUTextFile::CloseFile()
{
if( verbosity >= 2 ) {
printf( "CloseFile...\n" );
fflush( stdout );
}
if( fp ) {
fclose( fp );
fp = NULL;
}
if( verbosity >= 1 ) {
printf( "CloseFile...[OK]\n" );
fflush( stdout );
}
}
//////////////////////////////////////////////////////////////////
bool CUTextFile::ReopenFile( CUString arg_file_name, CUString arg_file_mode )
{
if( verbosity >= 2 ) {
printf( "ReopenFile... %s(%s)\n", arg_file_name.GetStr(), arg_file_mode.GetStr() );
fflush( stdout );
}
CloseFile();
return OpenFile( arg_file_name, arg_file_mode );
if( verbosity >= 2 ) {
printf( "ReopenFile... [OK]\n" );
fflush( stdout );
}
}
////////////////////////////////////////////////////////
bool CUTextFile::LoadToStr( CUString &str )
{
if( IsOpen() == false ) return false;
str.Empty();
MoveToStart();
char *tmp = new char[file_size+5];
/*
while(1) {
CUString line;
if( ReadLine( line ) == false ) break;
str += line + "\n";
}
str.Replace( "\r", "" );
*/
fread( tmp, 1, file_size, GetFP() );
tmp[ file_size ] = '\0';
// check \0
for( int i=0; i<file_size; i++ )
{
if( tmp[i] == '\0' )
{
return false;
}
}
str = tmp;
delete tmp;
str.Replace("\r", "");
return true;
}
////////////////////////////////////////////////////////
bool CUTextFile::LoadToMem()
{
if( IsOpen() == false ) return false;
MoveToStart();
content = new char[file_size+5];
fread( content, 1, file_size, GetFP() );
content[ file_size ] = '\0';
return true;
}
////////////////////////////////////////////////////////
bool CUTextFile::IsOpen()
{
if( fp == NULL ) return false;
else return true;
}
////////////////////////////////////////////////////////
FILE *CUTextFile::GetFP()
{
return fp;
}
//////////////////////////////////////////////////////////////////
CUString CUTextFile::GetFileName()
{
return file_name;
}
//////////////////////////////////////////////////////////////////
CUString CUTextFile::GetFileMode()
{
return file_mode;
}
//////////////////////////////////////////////////////////////////
void CUTextFile::Verbosity( int arg_verbosity )
{
verbosity = arg_verbosity;
}
//////////////////////////////////////////////////////////////////
long CUTextFile::GetNumLine()
{
// check
if( !IsOpen() ) {
return UNKNOWN;
}
// 이미 계산 되어져 있으면 바로 리턴
if( num_line != UNKNOWN ) {
return num_line;
}
MoveToEnd();
// size_t max_byte = ftell( GetFP() );
// size_t total_byte = 0;
num_line = 0;
now_line = 0;
MoveToStart();
char buf[UFILE_BUFF_SIZE];
while(1) {
// byte단위로 읽음
size_t read_byte = fread( buf, sizeof(char), UFILE_BUFF_SIZE, GetFP() );
if( read_byte < 0 ) return UNKNOWN;
// 파일의 끝까지 읽었는지 체크
if( read_byte == 0 ) {
break;
}
// 읽은 byte내에 \n 개수를 셈
for( size_t i=0; i<read_byte; i++ ) {
if( buf[i] == '\n' ) num_line++;
}
}
MoveToStart();
return num_line;
}
bool CUTextFile::MoveToLine( long sel_line )
{
// check
if( !IsOpen() ) return false;
if( !GetFP() ) return false;
MoveToEnd();
size_t max_byte = ftell( GetFP() );
size_t total_byte = 0;
MoveToStart();
long tmp_line = 0;
MoveToStart();
char buf[UFILE_BUFF_SIZE];
while(1) {
// byte단위로 읽음
size_t read_byte = fread( buf, sizeof(char), UFILE_BUFF_SIZE, GetFP() );
// 읽은 byte내에 \n 개수를 셈
for( size_t i=0; i<read_byte; i++ ) {
if( buf[i] == '\n' ) {
if( tmp_line < sel_line ) {
tmp_line++;
}
else {
fseek( fp, -(UFILE_BUFF_SIZE-i-1), SEEK_CUR );
return true;
}
}
}
// 파일의 끝까지 읽었는지 체크
total_byte += read_byte;
if( total_byte >= max_byte ) break;
}
return false;
}
//////////////////////////////////////////////////////////////////
long CUTextFile::GetFileSize()
{
return file_size;
}
//////////////////////////////////////////////////////////////////
void CUTextFile::MoveToStart()
{
if( IsOpen() ) {
fseek( fp, 0, SEEK_SET );
}
}
//////////////////////////////////////////////////////////////////
void CUTextFile::MoveToEnd()
{
if( IsOpen() ) {
fseek( fp, 0, SEEK_END );
}
}
////////////////////////////////////////////////////////
bool CUTextFile::ReadLine( CUString &str )
{
if( !IsOpen() ) return false;
if( !GetFP() ) return false;
str.Empty();
// fget으로는 한 줄을 다 읽을 수 있는 보장이 없으므로
// 확인이 될 때 까지 계속 읽으며 str의 뒤에 붙혀 넣는다.
while(1) {
char buf2[UFILE_BUFF_SIZE];
if(!fgets( buf2, UFILE_BUFF_SIZE, GetFP() ) ) {
return false;
}
// 뒤에 붙힘
str += buf2;
// 버퍼가 꽉 찼다면
if( strlen( buf2 ) >= UFILE_BUFF_SIZE-1 ) {
// 이전에 \n, \r이 있다면 한 줄 읽은 것임.
if( buf2[UFILE_BUFF_SIZE-2] == '\n' || buf2[UFILE_BUFF_SIZE-2] == '\r' ) {
break;
}
// 버퍼가 꽉차고 \n으로 끝나지 않았으므로 읽을 부분이 더 남았음
else {
// Do Nothing. ( fgets가 다시 호출 되도록 함. )
}
}
// 버퍼가 꽉 차지 않았다면 한 줄 다 읽었음.
else {
break;
}
}
// newline 제거
// str.TrimRight( "\n\r" );
str.Replace("\r", "" );
str.TrimRight( "\n\r" );
return true;
}
//////////////////////////////////////////////////////////////////
char* CUTextFile::ReadLine()
{
if( content == NULL ) {
if( LoadToMem() == false ) return NULL;
line_start_idx = 0;
}
char *ret = NULL;
for( int i=line_start_idx; content[i] !='\0'; i++ ) {
if( content[i] == '\n' ) {
content[i] = '\0';
for( int r=i-1; r>=0; i-- ) {
if( content[r] == '\r' ) content[r] = '\0';
else break;
}
ret = content+line_start_idx;
line_start_idx = i+1;
break;
}
}
return ret;
}
////////////////////////////////////////////////////////
bool CUTextFile::WriteLine( CUString str )
{
if( !IsOpen() ) return false;
if( !GetFP() ) return false;
fprintf( GetFP(), "%s\n", str.GetStr() );
if( ftell(GetFP()) > file_size ) {
file_size = ftell( GetFP() );
}
return true;
}
////////////////////////////////////////////////////////
bool CUTextFile::WriteLog( CUString str )
{
if( !IsOpen() ) return false;
if( !GetFP() ) return false;
time_t t;
time( &t );
char *buf = ctime( &t );
buf[ strlen( buf) -1 ] ='\0';
fprintf( GetFP(), "%s:::%s\n", buf, str.GetStr() );
Flush();
return true;
}
////////////////////////////////////////////////////////
void CUTextFile::Flush()
{
fflush( GetFP() );
}
/*
CUString CUTextFile::GetLineMem( long sel_line )
{
return CUString("");
long cnt_line=0;
long start = 0;
long end = -1;
for( long i=0; i<GetFileSize(); i++ ) {
if( mem[i] == '\n' ) {
if( cnt_line == sel_line -1 ) {
start = i + 1;
i++;
}
else if( cnt_line == sel_line ) {
end = i - 1;
break;
}
cnt_line++;
}
}
if( end == -1 ) {
CUString t;
return t;
}
CUString t( mem );
t = t.SubStr( start, end+1 );
return t;
}
bool CUTextFile::GetNextLineMem( CUString &str )
{
long start = offset;
long end = -1;
for( long i=start; i<size; i++ ) {
if( buf[i] == '\n' ) {
end = i;
break;
}
}
if( end == -1 ) {
return false;
}
offset = end + 1;
str.SetStr( buf );
str = str.SubStr( start, end );
return true;
}
*/
/*
060922 ReadNextLine 삭제, ReadLine 수정
060810 버그수정 : utextfile(filename) 생성시 getnumline 0으로만 출력
getnumline의 fread로 체크 하는 부분 수정
*/
}
// EOF
| [
"windnc@gmail.com"
] | windnc@gmail.com |
29f9289db9686de35ce162c6d8edf0afec5532fb | 6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849 | /sstd_boost/sstd/boost/config/detail/select_compiler_config.hpp | 772eb7ad21514744bb1b5e902775be2b5452d905 | [
"BSL-1.0"
] | permissive | KqSMea8/sstd_library | 9e4e622e1b01bed5de7322c2682539400d13dd58 | 0fcb815f50d538517e70a788914da7fbbe786ce1 | refs/heads/master | 2020-05-03T21:07:01.650034 | 2019-04-01T00:10:47 | 2019-04-01T00:10:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,571 | hpp | // Boost compiler configuration selection header file
// (C) Copyright John Maddock 2001 - 2003.
// (C) Copyright Martin Wille 2003.
// (C) Copyright Guillaume Melquiond 2003.
//
// 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)
// See http://www.boost.org/ for most recent version.
// locate which compiler we are using and define
// BOOST_COMPILER_CONFIG as needed:
#if defined __CUDACC__
// NVIDIA CUDA C++ compiler for GPU
# include "sstd/boost/config/compiler/nvcc.hpp"
#endif
#if defined(__GCCXML__)
// GCC-XML emulates other compilers, it has to appear first here!
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/gcc_xml.hpp"
#elif defined(_CRAYC)
// EDG based Cray compiler:
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/cray.hpp"
#elif defined __COMO__
// Comeau C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/comeau.hpp"
#elif defined(__PATHSCALE__) && (__PATHCC__ >= 4)
// PathScale EKOPath compiler (has to come before clang and gcc)
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/pathscale.hpp"
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
// Intel
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/intel.hpp"
#elif defined __clang__ && !defined(__ibmxl__)
// Clang C++ emulates GCC, so it has to appear early.
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/clang.hpp"
#elif defined __DMC__
// Digital Mars C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/digitalmars.hpp"
#elif defined __DCC__
// Wind River Diab C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/diab.hpp"
#elif defined(__PGI)
// Portland Group Inc.
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/pgi.hpp"
# elif defined(__GNUC__) && !defined(__ibmxl__)
// GNU C++:
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/gcc.hpp"
#elif defined __KCC
// Kai C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/kai.hpp"
#elif defined __sgi
// SGI MIPSpro C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/sgi_mipspro.hpp"
#elif defined __DECCXX
// Compaq Tru64 Unix cxx
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/compaq_cxx.hpp"
#elif defined __ghs
// Greenhills C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/greenhills.hpp"
#elif defined __CODEGEARC__
// CodeGear - must be checked for before Borland
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/codegear.hpp"
#elif defined __BORLANDC__
// Borland
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/borland.hpp"
#elif defined __MWERKS__
// Metrowerks CodeWarrior
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/metrowerks.hpp"
#elif defined __SUNPRO_CC
// Sun Workshop Compiler C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/sunpro_cc.hpp"
#elif defined __HP_aCC
// HP aCC
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/hp_acc.hpp"
#elif defined(__MRC__) || defined(__SC__)
// MPW MrCpp or SCpp
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/mpw.hpp"
#elif defined(__IBMCPP__) && defined(__COMPILER_VER__) && defined(__MVS__)
// IBM z/OS XL C/C++
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/xlcpp_zos.hpp"
#elif defined(__ibmxl__)
// IBM XL C/C++ for Linux (Little Endian)
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/xlcpp.hpp"
#elif defined(__IBMCPP__)
// IBM Visual Age or IBM XL C/C++ for Linux (Big Endian)
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/vacpp.hpp"
#elif defined _MSC_VER
// Microsoft Visual C++
//
// Must remain the last #elif since some other vendors (Metrowerks, for
// example) also #define _MSC_VER
# define BOOST_COMPILER_CONFIG "sstd/boost/config/compiler/visualc.hpp"
#elif defined (BOOST_ASSERT_CONFIG)
// this must come last - generate an error if we don't
// recognise the compiler:
# error "Unknown compiler - please configure (http://www.boost.org/libs/config/config.htm#configuring) and report the results to the main boost mailing list (http://www.boost.org/more/mailing_lists.htm#main)"
#endif
#if 0
//
// This section allows dependency scanners to find all the headers we *might* include:
//
#include <sstd/boost/config/compiler/gcc_xml.hpp>
#include <sstd/boost/config/compiler/cray.hpp>
#include <sstd/boost/config/compiler/comeau.hpp>
#include <sstd/boost/config/compiler/pathscale.hpp>
#include <sstd/boost/config/compiler/intel.hpp>
#include <sstd/boost/config/compiler/clang.hpp>
#include <sstd/boost/config/compiler/digitalmars.hpp>
#include <sstd/boost/config/compiler/gcc.hpp>
#include <sstd/boost/config/compiler/kai.hpp>
#include <sstd/boost/config/compiler/sgi_mipspro.hpp>
#include <sstd/boost/config/compiler/compaq_cxx.hpp>
#include <sstd/boost/config/compiler/greenhills.hpp>
#include <sstd/boost/config/compiler/codegear.hpp>
#include <sstd/boost/config/compiler/borland.hpp>
#include <sstd/boost/config/compiler/metrowerks.hpp>
#include <sstd/boost/config/compiler/sunpro_cc.hpp>
#include <sstd/boost/config/compiler/hp_acc.hpp>
#include <sstd/boost/config/compiler/mpw.hpp>
#include <sstd/boost/config/compiler/xlcpp_zos.hpp>
#include <sstd/boost/config/compiler/xlcpp.hpp>
#include <sstd/boost/config/compiler/vacpp.hpp>
#include <sstd/boost/config/compiler/pgi.hpp>
#include <sstd/boost/config/compiler/visualc.hpp>
#endif
| [
"zhaixueqiang@hotmail.com"
] | zhaixueqiang@hotmail.com |
a1e22fc3b6e13c14ea375c4f54e9cf9e38788bae | 1d2b50d80609fc03e403f9ee8fe6c4763e931a49 | /GameEngine/Source/Graphics/Stages/Shaders/PixelShader.cpp | f8c224a9715951f3b4566088c3adc7dff41ff306 | [] | no_license | shadercoder/RenderMaster | 17e1a7f65937ab520be4fbe45a7339a9e77fb487 | 845dfadff21c27250a81183f1202267602a5cd50 | refs/heads/master | 2021-01-18T14:19:19.296788 | 2014-07-10T19:07:07 | 2014-07-10T19:07:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,023 | cpp | #include "Core.h"
#include "PixelShader.h"
#include "../../Other/Blob.h"
bool PixelShader::Create(Blob & shaderbuffer)
{
HRESULT hr = DX11API::D3D11Device()->CreatePixelShader(shaderbuffer.m_pBlob->GetBufferPointer(),
shaderbuffer.m_pBlob->GetBufferSize(), NULL, &m_pShader);
VALID(hr);
}
bool PixelShader::CreateFromFile(const char * filename)
{
SHADER_LOAD_FROM_FILE()
auto hr = DX11API::D3D11Device()->CreatePixelShader(&compiledShader[0], size, nullptr, &m_pShader);
VALID(hr);
}
bool PixelShader::CreateAndCompile(const wstring & fileName, const string & entrypoint, const string & target, Blob * pErrors)
{
//Compile the shader first
Blob compiledShaderBlob{};
if (!compiledShaderBlob.CompileShader(fileName, entrypoint, ST_Pixel, target, pErrors))
{
assert(0 && "Some error when compiling the pixel shader occured!");
return false;
}
//Create shader
if (!Create(compiledShaderBlob))
{
assert(0 && "Some error when creating the pixel shader occured!");
return false;
}
return true;
} | [
"evg.gamedev@gmail.com"
] | evg.gamedev@gmail.com |
7d09e4443de57653923848901ccda25b5100099f | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /components/download/internal/common/resource_downloader.h | b2f8ec766fe2687d656197bd71adfd4d0ed443d7 | [
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 6,970 | h | // Copyright 2017 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 COMPONENTS_DOWNLOAD_INTERNAL_COMMON_RESOURCE_DOWNLOADER_H_
#define COMPONENTS_DOWNLOAD_INTERNAL_COMMON_RESOURCE_DOWNLOADER_H_
#include "base/callback.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_response_handler.h"
#include "components/download/public/common/download_utils.h"
#include "components/download/public/common/url_download_handler.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "net/cert/cert_status_flags.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/url_loader.mojom.h"
namespace service_manager {
class Connector;
} // namespace service_manager
namespace download {
class DownloadURLLoaderFactoryGetter;
// Class for handing the download of a url. Lives on IO thread.
class COMPONENTS_DOWNLOAD_EXPORT ResourceDownloader
: public download::UrlDownloadHandler,
public download::DownloadResponseHandler::Delegate {
public:
// Called to start a download, must be called on IO thread.
static std::unique_ptr<ResourceDownloader> BeginDownload(
base::WeakPtr<download::UrlDownloadHandler::Delegate> delegate,
std::unique_ptr<download::DownloadUrlParameters> download_url_parameters,
std::unique_ptr<network::ResourceRequest> request,
scoped_refptr<download::DownloadURLLoaderFactoryGetter>
url_loader_factory_getter,
const URLSecurityPolicy& url_security_policy,
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_referrer_url,
bool is_new_download,
bool is_parallel_request,
std::unique_ptr<service_manager::Connector> connector,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// Create a ResourceDownloader from a navigation that turns to be a download.
// No URLLoader is created, but the URLLoaderClient implementation is
// transferred.
static std::unique_ptr<ResourceDownloader> InterceptNavigationResponse(
base::WeakPtr<UrlDownloadHandler::Delegate> delegate,
std::unique_ptr<network::ResourceRequest> resource_request,
int render_process_id,
int render_frame_id,
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_referrer_url,
std::vector<GURL> url_chain,
const scoped_refptr<network::ResourceResponse>& response,
net::CertStatus cert_status,
network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,
scoped_refptr<download::DownloadURLLoaderFactoryGetter>
url_loader_factory_getter,
const URLSecurityPolicy& url_security_policy,
std::unique_ptr<service_manager::Connector> connector,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
ResourceDownloader(
base::WeakPtr<UrlDownloadHandler::Delegate> delegate,
std::unique_ptr<network::ResourceRequest> resource_request,
int render_process_id,
int render_frame_id,
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_referrer_url,
bool is_new_download,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_refptr<download::DownloadURLLoaderFactoryGetter>
url_loader_factory_getter,
const URLSecurityPolicy& url_security_policy,
std::unique_ptr<service_manager::Connector> connector);
~ResourceDownloader() override;
// download::DownloadResponseHandler::Delegate
void OnResponseStarted(
std::unique_ptr<download::DownloadCreateInfo> download_create_info,
download::mojom::DownloadStreamHandlePtr stream_handle) override;
void OnReceiveRedirect() override;
void OnResponseCompleted() override;
bool CanRequestURL(const GURL& url) override;
void OnUploadProgress(uint64_t bytes_uploaded) override;
private:
// Helper method to start the network request.
void Start(
std::unique_ptr<download::DownloadUrlParameters> download_url_parameters,
bool is_parallel_request);
// Intercepts the navigation response.
void InterceptResponse(
const scoped_refptr<network::ResourceResponse>& response,
std::vector<GURL> url_chain,
net::CertStatus cert_status,
network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints);
// UrlDownloadHandler implementations.
void CancelRequest() override;
// Ask the |delegate_| to destroy this object.
void Destroy();
// Requests the wake lock using |connector|.
void RequestWakeLock(service_manager::Connector* connector);
base::WeakPtr<download::UrlDownloadHandler::Delegate> delegate_;
// The ResourceRequest for this object.
std::unique_ptr<network::ResourceRequest> resource_request_;
// Object that will handle the response.
std::unique_ptr<network::mojom::URLLoaderClient> url_loader_client_;
// URLLoaderClient binding. It sends any requests to the |url_loader_client_|.
std::unique_ptr<mojo::Binding<network::mojom::URLLoaderClient>>
url_loader_client_binding_;
// URLLoader for sending out the request.
network::mojom::URLLoaderPtr url_loader_;
// Whether this is a new download.
bool is_new_download_;
// GUID of the download, or empty if this is a new download.
std::string guid_;
// Callback to run after download starts.
download::DownloadUrlParameters::OnStartedCallback callback_;
// Callback to run with upload updates.
DownloadUrlParameters::UploadProgressCallback upload_callback_;
// Frame and process id associated with the request.
int render_process_id_;
int render_frame_id_;
// Site URL for the site instance that initiated the download.
GURL site_url_;
// The URL of the tab that started us.
GURL tab_url_;
// The referrer URL of the tab that started us.
GURL tab_referrer_url_;
// URLLoader status when intercepting the navigation request.
base::Optional<network::URLLoaderCompletionStatus> url_loader_status_;
// TaskRunner to post callbacks to the |delegate_|
scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
// URLLoaderFactory getter for issueing network requests.
scoped_refptr<download::DownloadURLLoaderFactoryGetter>
url_loader_factory_getter_;
// Used to check if the URL is safe to request.
URLSecurityPolicy url_security_policy_;
// Used to keep the system from sleeping while a download is ongoing. If the
// system enters power saving mode while a download is alive, it can cause
// download to be interrupted.
device::mojom::WakeLockPtr wake_lock_;
base::WeakPtrFactory<ResourceDownloader> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ResourceDownloader);
};
} // namespace download
#endif // COMPONENTS_DOWNLOAD_INTERNAL_COMMON_RESOURCE_DOWNLOADER_H_
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
4957ea2ee8475bb90c59406645bd41ca1adeb193 | c2f09d0b63cc127e873b3513d8bc8f12b0ded3fd | /threads/EventBarrier.h | cde1a8af73afaf02ee464a2e9e0e8f0af8321af9 | [
"MIT-Modern-Variant"
] | permissive | RookieHong/nachos | 055f021ae26893112042d3bc9d88360a5f3213f7 | 5226575641666578204e79821de2280a033d74d9 | refs/heads/master | 2020-03-20T05:59:28.865019 | 2018-06-16T04:17:40 | 2018-06-16T04:17:40 | 137,234,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 359 | h | #include "synch.h"
#include "system.h"
class EventBarrier {
public:
EventBarrier(char *debugName);
~EventBarrier();
void Wait();
void Signal();
void Complete();
int Waiters();
int Status();
private:
enum {SIGNALED, UNSIGNALED} status;
int numWaiting;
Condition *signalCon;
Condition *completeCon;
Lock *lock;
char *name;
};
| [
"120948741@qq.com"
] | 120948741@qq.com |
3c7e46631e0b0e3411b2705fbb68cf02ae54a66f | 27ef59e3fda57483be6abfda7ebe1517b0c8e707 | /sharma92/src/network_util.cpp | 3ba1fb606eea096a69eab2c8f1b98df9626047e1 | [] | no_license | Shefali-Sharma/Distance-Vector-Routing | dd4611ea0933e7a7c1472d7e30d3dd46d3b42fe4 | 361612392ee464e2f3350fbcd013fcd596f3a650 | refs/heads/master | 2021-05-14T14:58:35.472763 | 2018-02-12T16:41:09 | 2018-02-12T16:41:09 | 115,982,756 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,473 | cpp | /**
* @network_util
* @author Shefali Sharma <sharma92@buffalo.edu>
* @version 1.0
*
* @section LICENSE
*
* 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 at
* http://www.gnu.org/copyleft/gpl.html
*
* @section DESCRIPTION
*
* Network I/O utility functions. send/recvALL are simple wrappers for
* the underlying send() and recv() system calls to ensure nbytes are always
* sent/received.
*/
#include <stdlib.h>
#include <sys/socket.h>
ssize_t recvALL(int sock_index, char *buffer, ssize_t nbytes)
{
ssize_t bytes = 0;
bytes = recv(sock_index, buffer, nbytes, 0);
if(bytes == 0) return -1;
while(bytes != nbytes)
bytes += recv(sock_index, buffer+bytes, nbytes-bytes, 0);
return bytes;
}
ssize_t sendALL(int sock_index, char *buffer, ssize_t nbytes)
{
ssize_t bytes = 0;
bytes = send(sock_index, buffer, nbytes, 0);
if(bytes == 0) return -1;
while(bytes != nbytes)
bytes += send(sock_index, buffer+bytes, nbytes-bytes, 0);
return bytes;
}
| [
"shefali92@github.com"
] | shefali92@github.com |
ba5f51c09c1e614465f4543eaaf93975c601c478 | 099f2181439ba42a5fbeb774a182faf3db9bad8c | /problems/082-remove-duplicates-from-sorted-list-ii.cpp | 66d313e403c6a901cf954039bf6f828b84fca1e8 | [] | no_license | luchenqun/leet-code | 76a9193e315975b094225d15f0281d0d462c2ee7 | 38b3f660e5173ad175b8451a730bf4ee3f03a66b | refs/heads/master | 2021-07-09T09:49:36.068938 | 2019-01-15T07:15:22 | 2019-01-15T07:15:22 | 102,130,497 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 973 | cpp | /*
* [82] Remove Duplicates from Sorted List II
*
* https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/description/
* https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/discuss/
*
* algorithms
* Medium (28.95%)
* Total Accepted: 508
* Total Submissions: 1.8K
* Testcase Example: '[1,2,3,3,4,4,5]'
*
* 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字。
* 示例 1:
* 输入: 1->2->3->3->4->4->5
* 输出: 1->2->5
* 示例 2:
* 输入: 1->1->1->2->3
* 输出: 2->3
*/
#include <iostream>
#include <string>
using namespace std;
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
}
};
int main()
{
Solution s;
return 0;
}
| [
"luchenqun@juzix.io"
] | luchenqun@juzix.io |
2c96956e165e12675345b7cb4fd2411819662a48 | 9b4f6fa69ec833198d5e27bef0453ffce21da316 | /09-04_pq/pq_test.cpp | cbc46ded0c20ee98d3e32f18522d5387e64d90b0 | [] | no_license | nattee/data2019 | cec667fc90d35689815557a9f4c546fa11f35a63 | 3f9373bf6fbaac4ec83bd4e7beba160e5f63eb42 | refs/heads/master | 2020-07-04T15:37:10.427297 | 2019-10-16T04:04:14 | 2019-10-16T04:04:14 | 202,326,521 | 2 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 458 | cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
priority_queue<pair<int,int>> pq;
pq.push( make_pair(1,2) );
pq.push( {1,200} );
pq.push( {1,-100} );
pq.push( {-2,3} );
pq.push( {4,1} );
while (!pq.empty() ) {
auto x = pq.top();
pq.pop();
cout << x.first << "," << x.second << endl;
}
pair<int,int> a,b;
a = {1,3};
b = {1,5};
if (a < b) {
cout << "YEAH" << endl;
}
}
| [
"nattee@gmail.com"
] | nattee@gmail.com |
7cc48b54c4cc7be5972f8619d62e5d326a2b90bf | ab095beae34c9f74b7de2e7a87ad541a984b3060 | /DiamondSquareNew/Triangle.cpp | 74a1a755144fd6d2bffe8ffa7d28387933a387ed | [] | no_license | imarie97/bmstu-projects | 62ece44be4d66d0b1eab0b10f8c553bbfbf9c2b4 | da08f3548306500cf6b9e7337253b107af82e0a8 | refs/heads/master | 2022-04-18T17:05:53.472040 | 2020-04-12T12:03:44 | 2020-04-12T12:03:44 | 255,073,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,616 | cpp | #include "stdafx.hpp"
//
// Created by user on 3/18/18.
//
#include "Triangle.hpp"
Triangle::Triangle(glm::vec3 a, glm::vec3 b, glm::vec3 c) {
this->a = a;
this->b = b;
this->c = c;
}
Triangle::Triangle() { a = b = c = glm::vec3(0); }
void Triangle::setWater() {
color = glm::vec3(0.28f + dist(random_gen) * 0.1f,
0.48f + dist(random_gen) * 0.1f,
0.78f + dist(random_gen) * 0.1f);
}
void Triangle::setBeach() {
color =
// glm::vec3(0.5f + dist(random_gen) * 0.1f, 0.77f + dist(random_gen) * 0.1f,
// 0.27f + dist(random_gen) * 0.1f);
glm::vec3(0.15f + dist(random_gen) * 0.1f, 0.24f + dist(random_gen) * 0.1f,
0.f + dist(random_gen) * 0.1f);
}
void Triangle::setForest() {
color =
glm::vec3(0.05f + dist(random_gen) * 0.1f, 0.2f + dist(random_gen) * 0.1f,
0.f + dist(random_gen) * 0.1f);
}
void Triangle::setMountain() {
color =
glm::vec3(0.4f + dist(random_gen) * 0.1f, 0.4f + dist(random_gen) * 0.1f,
0.4f + dist(random_gen) * 0.1f);
}
void Triangle::setGlacier() {
color = glm::vec3(0.95f + dist(random_gen) * 0.1f, 0.95f + dist(random_gen) * 0.1f,
0.95f + dist(random_gen) * 0.1f);// - dist(random_gen) * 0.1f);
}
glm::vec3 Triangle::getNormal() {
auto dir = glm::cross(b - a, c - a);
auto norm = glm::normalize(dir);
return norm;
}
void Triangle::recalcColor() {
glm::vec3 normal = getNormal();
const glm::vec3 UP(0.0f, 1.0f, 0.0f);
color = glm::vec3(std::abs(glm::dot(UP, normal) * 0.5f));
}
| [
"marie.kovega@yandex.ru"
] | marie.kovega@yandex.ru |
b8ee2c9d3668d293282785d8b4d3afd087ff5f70 | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /c++/godot/2017/12/gd_mono_marshal.cpp | d744d24f24697381b9d5923d85698072d0f8c241 | [
"MIT"
] | permissive | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | C++ | false | false | 25,749 | cpp | /*************************************************************************/
/* gd_mono_marshal.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_mono_marshal.h"
#include "gd_mono.h"
#include "gd_mono_class.h"
namespace GDMonoMarshal {
#define RETURN_BOXED_STRUCT(m_t, m_var_in) \
{ \
const m_t &m_in = m_var_in->operator ::m_t(); \
MARSHALLED_OUT(m_t, m_in, raw); \
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(m_t), raw); \
}
#define RETURN_UNBOXED_STRUCT(m_t, m_var_in) \
{ \
float *raw = (float *)mono_object_unbox(m_var_in); \
MARSHALLED_IN(m_t, raw, ret); \
return ret; \
}
Variant::Type managed_to_variant_type(const ManagedType &p_type) {
switch (p_type.type_encoding) {
case MONO_TYPE_BOOLEAN:
return Variant::BOOL;
case MONO_TYPE_I1:
return Variant::INT;
case MONO_TYPE_I2:
return Variant::INT;
case MONO_TYPE_I4:
return Variant::INT;
case MONO_TYPE_I8:
return Variant::INT;
case MONO_TYPE_U1:
return Variant::INT;
case MONO_TYPE_U2:
return Variant::INT;
case MONO_TYPE_U4:
return Variant::INT;
case MONO_TYPE_U8:
return Variant::INT;
case MONO_TYPE_R4:
return Variant::REAL;
case MONO_TYPE_R8:
return Variant::REAL;
case MONO_TYPE_STRING: {
return Variant::STRING;
} break;
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = p_type.type_class;
if (tclass == CACHED_CLASS(Vector2))
return Variant::VECTOR2;
if (tclass == CACHED_CLASS(Rect2))
return Variant::RECT2;
if (tclass == CACHED_CLASS(Transform2D))
return Variant::TRANSFORM2D;
if (tclass == CACHED_CLASS(Vector3))
return Variant::VECTOR3;
if (tclass == CACHED_CLASS(Basis))
return Variant::BASIS;
if (tclass == CACHED_CLASS(Quat))
return Variant::QUAT;
if (tclass == CACHED_CLASS(Transform))
return Variant::TRANSFORM;
if (tclass == CACHED_CLASS(AABB))
return Variant::AABB;
if (tclass == CACHED_CLASS(Color))
return Variant::COLOR;
if (tclass == CACHED_CLASS(Plane))
return Variant::PLANE;
if (mono_class_is_enum(tclass->get_raw()))
return Variant::INT;
} break;
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(p_type.type_class));
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
return Variant::ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
return Variant::POOL_BYTE_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
return Variant::POOL_INT_ARRAY;
if (array_type->eklass == REAL_T_MONOCLASS)
return Variant::POOL_REAL_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(String))
return Variant::POOL_STRING_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
return Variant::POOL_VECTOR2_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
return Variant::POOL_VECTOR3_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return Variant::POOL_COLOR_ARRAY;
} break;
case MONO_TYPE_CLASS: {
GDMonoClass *type_class = p_type.type_class;
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
return Variant::OBJECT;
}
if (CACHED_CLASS(NodePath) == type_class) {
return Variant::NODE_PATH;
}
if (CACHED_CLASS(RID) == type_class) {
return Variant::_RID;
}
} break;
case MONO_TYPE_GENERICINST: {
if (CACHED_RAW_MONO_CLASS(Dictionary) == p_type.type_class->get_raw()) {
return Variant::DICTIONARY;
}
} break;
default: {
} break;
}
// Unknown
return Variant::NIL;
}
String mono_to_utf8_string(MonoString *p_mono_string) {
MonoError error;
char *utf8 = mono_string_to_utf8_checked(p_mono_string, &error);
ERR_EXPLAIN("Conversion of MonoString to UTF8 failed.");
ERR_FAIL_COND_V(!mono_error_ok(&error), String());
String ret = String::utf8(utf8);
mono_free(utf8);
return ret;
}
String mono_to_utf16_string(MonoString *p_mono_string) {
int len = mono_string_length(p_mono_string);
String ret;
if (len == 0)
return ret;
ret.resize(len + 1);
ret.set(len, 0);
CharType *src = (CharType *)mono_string_chars(p_mono_string);
CharType *dst = &(ret.operator[](0));
for (int i = 0; i < len; i++) {
dst[i] = src[i];
}
return ret;
}
MonoObject *variant_to_mono_object(const Variant *p_var) {
ManagedType type;
type.type_encoding = MONO_TYPE_OBJECT;
return variant_to_mono_object(p_var, type);
}
MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_type) {
switch (p_type.type_encoding) {
case MONO_TYPE_BOOLEAN: {
MonoBoolean val = p_var->operator bool();
return BOX_BOOLEAN(val);
}
case MONO_TYPE_I1: {
char val = p_var->operator signed char();
return BOX_INT8(val);
}
case MONO_TYPE_I2: {
short val = p_var->operator signed short();
return BOX_INT16(val);
}
case MONO_TYPE_I4: {
int val = p_var->operator signed int();
return BOX_INT32(val);
}
case MONO_TYPE_I8: {
int64_t val = p_var->operator int64_t();
return BOX_INT64(val);
}
case MONO_TYPE_U1: {
char val = p_var->operator unsigned char();
return BOX_UINT8(val);
}
case MONO_TYPE_U2: {
short val = p_var->operator unsigned short();
return BOX_UINT16(val);
}
case MONO_TYPE_U4: {
int val = p_var->operator unsigned int();
return BOX_UINT32(val);
}
case MONO_TYPE_U8: {
uint64_t val = p_var->operator uint64_t();
return BOX_UINT64(val);
}
case MONO_TYPE_R4: {
float val = p_var->operator float();
return BOX_FLOAT(val);
}
case MONO_TYPE_R8: {
double val = p_var->operator double();
return BOX_DOUBLE(val);
}
case MONO_TYPE_STRING: {
return (MonoObject *)mono_string_from_godot(p_var->operator String());
} break;
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = p_type.type_class;
if (tclass == CACHED_CLASS(Vector2))
RETURN_BOXED_STRUCT(Vector2, p_var);
if (tclass == CACHED_CLASS(Rect2))
RETURN_BOXED_STRUCT(Rect2, p_var);
if (tclass == CACHED_CLASS(Transform2D))
RETURN_BOXED_STRUCT(Transform2D, p_var);
if (tclass == CACHED_CLASS(Vector3))
RETURN_BOXED_STRUCT(Vector3, p_var);
if (tclass == CACHED_CLASS(Basis))
RETURN_BOXED_STRUCT(Basis, p_var);
if (tclass == CACHED_CLASS(Quat))
RETURN_BOXED_STRUCT(Quat, p_var);
if (tclass == CACHED_CLASS(Transform))
RETURN_BOXED_STRUCT(Transform, p_var);
if (tclass == CACHED_CLASS(AABB))
RETURN_BOXED_STRUCT(AABB, p_var);
if (tclass == CACHED_CLASS(Color))
RETURN_BOXED_STRUCT(Color, p_var);
if (tclass == CACHED_CLASS(Plane))
RETURN_BOXED_STRUCT(Plane, p_var);
if (mono_class_is_enum(tclass->get_raw())) {
int val = p_var->operator signed int();
return BOX_ENUM(tclass->get_raw(), val);
}
} break;
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(p_type.type_class));
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
return (MonoObject *)Array_to_mono_array(p_var->operator Array());
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
return (MonoObject *)PoolByteArray_to_mono_array(p_var->operator PoolByteArray());
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
return (MonoObject *)PoolIntArray_to_mono_array(p_var->operator PoolIntArray());
if (array_type->eklass == REAL_T_MONOCLASS)
return (MonoObject *)PoolRealArray_to_mono_array(p_var->operator PoolRealArray());
if (array_type->eklass == CACHED_CLASS_RAW(String))
return (MonoObject *)PoolStringArray_to_mono_array(p_var->operator PoolStringArray());
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
return (MonoObject *)PoolVector2Array_to_mono_array(p_var->operator PoolVector2Array());
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
return (MonoObject *)PoolVector3Array_to_mono_array(p_var->operator PoolVector3Array());
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed array of unmarshallable element type.");
ERR_FAIL_V(NULL);
} break;
case MONO_TYPE_CLASS: {
GDMonoClass *type_class = p_type.type_class;
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
return GDMonoUtils::unmanaged_get_managed(p_var->operator Object *());
}
if (CACHED_CLASS(NodePath) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator NodePath());
}
if (CACHED_CLASS(RID) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator RID());
}
} break;
case MONO_TYPE_OBJECT: {
// Variant
switch (p_var->get_type()) {
case Variant::BOOL: {
MonoBoolean val = p_var->operator bool();
return BOX_BOOLEAN(val);
}
case Variant::INT: {
int val = p_var->operator signed int();
return BOX_INT32(val);
}
case Variant::REAL: {
#ifdef REAL_T_IS_DOUBLE
double val = p_var->operator double();
return BOX_DOUBLE(val);
#else
float val = p_var->operator float();
return BOX_FLOAT(val);
#endif
}
case Variant::STRING:
return (MonoObject *)mono_string_from_godot(p_var->operator String());
case Variant::VECTOR2:
RETURN_BOXED_STRUCT(Vector2, p_var);
case Variant::RECT2:
RETURN_BOXED_STRUCT(Rect2, p_var);
case Variant::VECTOR3:
RETURN_BOXED_STRUCT(Vector3, p_var);
case Variant::TRANSFORM2D:
RETURN_BOXED_STRUCT(Transform2D, p_var);
case Variant::PLANE:
RETURN_BOXED_STRUCT(Plane, p_var);
case Variant::QUAT:
RETURN_BOXED_STRUCT(Quat, p_var);
case Variant::AABB:
RETURN_BOXED_STRUCT(AABB, p_var);
case Variant::BASIS:
RETURN_BOXED_STRUCT(Basis, p_var);
case Variant::TRANSFORM:
RETURN_BOXED_STRUCT(Transform, p_var);
case Variant::COLOR:
RETURN_BOXED_STRUCT(Color, p_var);
case Variant::NODE_PATH:
return GDMonoUtils::create_managed_from(p_var->operator NodePath());
case Variant::_RID:
return GDMonoUtils::create_managed_from(p_var->operator RID());
case Variant::OBJECT: {
return GDMonoUtils::unmanaged_get_managed(p_var->operator Object *());
}
case Variant::DICTIONARY:
return Dictionary_to_mono_object(p_var->operator Dictionary());
case Variant::ARRAY:
return (MonoObject *)Array_to_mono_array(p_var->operator Array());
case Variant::POOL_BYTE_ARRAY:
return (MonoObject *)PoolByteArray_to_mono_array(p_var->operator PoolByteArray());
case Variant::POOL_INT_ARRAY:
return (MonoObject *)PoolIntArray_to_mono_array(p_var->operator PoolIntArray());
case Variant::POOL_REAL_ARRAY:
return (MonoObject *)PoolRealArray_to_mono_array(p_var->operator PoolRealArray());
case Variant::POOL_STRING_ARRAY:
return (MonoObject *)PoolStringArray_to_mono_array(p_var->operator PoolStringArray());
case Variant::POOL_VECTOR2_ARRAY:
return (MonoObject *)PoolVector2Array_to_mono_array(p_var->operator PoolVector2Array());
case Variant::POOL_VECTOR3_ARRAY:
return (MonoObject *)PoolVector3Array_to_mono_array(p_var->operator PoolVector3Array());
case Variant::POOL_COLOR_ARRAY:
return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
default:
return NULL;
}
break;
case MONO_TYPE_GENERICINST: {
if (CACHED_RAW_MONO_CLASS(Dictionary) == p_type.type_class->get_raw()) {
return Dictionary_to_mono_object(p_var->operator Dictionary());
}
} break;
} break;
}
ERR_EXPLAIN(String() + "Attempted to convert Variant to an unmarshallable managed type. Name: \'" +
p_type.type_class->get_name() + "\' Encoding: " + itos(p_type.type_encoding));
ERR_FAIL_V(NULL);
}
Variant mono_object_to_variant(MonoObject *p_obj) {
if (!p_obj)
return Variant();
GDMonoClass *tclass = GDMono::get_singleton()->get_class(mono_object_get_class(p_obj));
ERR_FAIL_COND_V(!tclass, Variant());
MonoType *raw_type = tclass->get_raw_type(tclass);
ManagedType type;
type.type_encoding = mono_type_get_type(raw_type);
type.type_class = tclass;
return mono_object_to_variant(p_obj, type);
}
Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
switch (p_type.type_encoding) {
case MONO_TYPE_BOOLEAN:
return (bool)unbox<MonoBoolean>(p_obj);
case MONO_TYPE_I1:
return unbox<int8_t>(p_obj);
case MONO_TYPE_I2:
return unbox<int16_t>(p_obj);
case MONO_TYPE_I4:
return unbox<int32_t>(p_obj);
case MONO_TYPE_I8:
return unbox<int64_t>(p_obj);
case MONO_TYPE_U1:
return unbox<uint8_t>(p_obj);
case MONO_TYPE_U2:
return unbox<uint16_t>(p_obj);
case MONO_TYPE_U4:
return unbox<uint32_t>(p_obj);
case MONO_TYPE_U8:
return unbox<uint64_t>(p_obj);
case MONO_TYPE_R4:
return unbox<float>(p_obj);
case MONO_TYPE_R8:
return unbox<double>(p_obj);
case MONO_TYPE_STRING: {
if (p_obj == NULL)
return Variant(); // NIL
return mono_string_to_godot_not_null((MonoString *)p_obj);
} break;
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = p_type.type_class;
if (tclass == CACHED_CLASS(Vector2))
RETURN_UNBOXED_STRUCT(Vector2, p_obj);
if (tclass == CACHED_CLASS(Rect2))
RETURN_UNBOXED_STRUCT(Rect2, p_obj);
if (tclass == CACHED_CLASS(Transform2D))
RETURN_UNBOXED_STRUCT(Transform2D, p_obj);
if (tclass == CACHED_CLASS(Vector3))
RETURN_UNBOXED_STRUCT(Vector3, p_obj);
if (tclass == CACHED_CLASS(Basis))
RETURN_UNBOXED_STRUCT(Basis, p_obj);
if (tclass == CACHED_CLASS(Quat))
RETURN_UNBOXED_STRUCT(Quat, p_obj);
if (tclass == CACHED_CLASS(Transform))
RETURN_UNBOXED_STRUCT(Transform, p_obj);
if (tclass == CACHED_CLASS(AABB))
RETURN_UNBOXED_STRUCT(AABB, p_obj);
if (tclass == CACHED_CLASS(Color))
RETURN_UNBOXED_STRUCT(Color, p_obj);
if (tclass == CACHED_CLASS(Plane))
RETURN_UNBOXED_STRUCT(Plane, p_obj);
if (mono_class_is_enum(tclass->get_raw()))
return unbox<int32_t>(p_obj);
} break;
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(p_type.type_class));
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
return mono_array_to_Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
return mono_array_to_PoolByteArray((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
return mono_array_to_PoolIntArray((MonoArray *)p_obj);
if (array_type->eklass == REAL_T_MONOCLASS)
return mono_array_to_PoolRealArray((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(String))
return mono_array_to_PoolStringArray((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
return mono_array_to_PoolVector2Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
return mono_array_to_PoolVector3Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return mono_array_to_PoolColorArray((MonoArray *)p_obj);
ERR_EXPLAIN(String() + "Attempted to convert a managed array of unmarshallable element type to Variant.");
ERR_FAIL_V(Variant());
} break;
case MONO_TYPE_CLASS: {
GDMonoClass *type_class = p_type.type_class;
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj));
return ptr ? Variant(ptr) : Variant();
}
if (CACHED_CLASS(NodePath) == type_class) {
NodePath *ptr = unbox<NodePath *>(CACHED_FIELD(NodePath, ptr)->get_value(p_obj));
return ptr ? Variant(*ptr) : Variant();
}
if (CACHED_CLASS(RID) == type_class) {
RID *ptr = unbox<RID *>(CACHED_FIELD(RID, ptr)->get_value(p_obj));
return ptr ? Variant(*ptr) : Variant();
}
} break;
case MONO_TYPE_GENERICINST: {
if (CACHED_RAW_MONO_CLASS(Dictionary) == p_type.type_class->get_raw()) {
return mono_object_to_Dictionary(p_obj);
}
} break;
}
ERR_EXPLAIN(String() + "Attempted to convert an unmarshallable managed type to Variant. Name: \'" +
p_type.type_class->get_name() + "\' Encoding: " + itos(p_type.type_encoding));
ERR_FAIL_V(Variant());
}
MonoArray *Array_to_mono_array(const Array &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
MonoObject *boxed = variant_to_mono_object(p_array[i]);
mono_array_setref(ret, i, boxed);
}
return ret;
}
Array mono_array_to_Array(MonoArray *p_array) {
Array ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_array, MonoObject *, i);
ret.push_back(mono_object_to_variant(elem));
}
return ret;
}
// TODO Optimize reading/writing from/to PoolArrays
MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(int32_t), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
mono_array_set(ret, int32_t, i, p_array[i]);
}
return ret;
}
PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
PoolIntArray ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
int32_t elem = mono_array_get(p_array, int32_t, i);
ret.push_back(elem);
}
return ret;
}
MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(uint8_t), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
mono_array_set(ret, uint8_t, i, p_array[i]);
}
return ret;
}
PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
PoolByteArray ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
uint8_t elem = mono_array_get(p_array, uint8_t, i);
ret.push_back(elem);
}
return ret;
}
MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), REAL_T_MONOCLASS, p_array.size());
for (int i = 0; i < p_array.size(); i++) {
mono_array_set(ret, real_t, i, p_array[i]);
}
return ret;
}
PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
PoolRealArray ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
real_t elem = mono_array_get(p_array, real_t, i);
ret.push_back(elem);
}
return ret;
}
MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
MonoString *boxed = mono_string_from_godot(p_array[i]);
mono_array_set(ret, MonoString *, i, boxed);
}
return ret;
}
PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
PoolStringArray ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
MonoString *elem = mono_array_get(p_array, MonoString *, i);
ret.push_back(mono_string_to_godot(elem));
}
return ret;
}
MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Color), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
#ifdef YOLOCOPY
mono_array_set(ret, Color, i, p_array[i]);
#else
real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 4, i);
const Color &elem = p_array[i];
raw[0] = elem.r;
raw[1] = elem.g;
raw[2] = elem.b;
raw[3] = elem.a;
#endif
}
return ret;
}
PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
PoolColorArray ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 4, i);
MARSHALLED_IN(Color, raw_elem, elem);
ret.push_back(elem);
}
return ret;
}
MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector2), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
#ifdef YOLOCOPY
mono_array_set(ret, Vector2, i, p_array[i]);
#else
real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 2, i);
const Vector2 &elem = p_array[i];
raw[0] = elem.x;
raw[1] = elem.y;
#endif
}
return ret;
}
PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
PoolVector2Array ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 2, i);
MARSHALLED_IN(Vector2, raw_elem, elem);
ret.push_back(elem);
}
return ret;
}
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector3), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
#ifdef YOLOCOPY
mono_array_set(ret, Vector3, i, p_array[i]);
#else
real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 3, i);
const Vector3 &elem = p_array[i];
raw[0] = elem.x;
raw[1] = elem.y;
raw[2] = elem.z;
#endif
}
return ret;
}
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
PoolVector3Array ret;
int length = mono_array_length(p_array);
for (int i = 0; i < length; i++) {
real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 3, i);
MARSHALLED_IN(Vector3, raw_elem, elem);
ret.push_back(elem);
}
return ret;
}
MonoObject *Dictionary_to_mono_object(const Dictionary &p_dict) {
MonoArray *keys = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_dict.size());
MonoArray *values = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_dict.size());
int i = 0;
const Variant *dkey = NULL;
while ((dkey = p_dict.next(dkey))) {
mono_array_set(keys, MonoObject *, i, variant_to_mono_object(dkey));
mono_array_set(values, MonoObject *, i, variant_to_mono_object(p_dict[*dkey]));
i++;
}
GDMonoUtils::MarshalUtils_ArraysToDict arrays_to_dict = CACHED_METHOD_THUNK(MarshalUtils, ArraysToDictionary);
MonoObject *ex = NULL;
MonoObject *ret = arrays_to_dict(keys, values, &ex);
if (ex) {
mono_print_unhandled_exception(ex);
ERR_FAIL_V(NULL);
}
return ret;
}
Dictionary mono_object_to_Dictionary(MonoObject *p_dict) {
Dictionary ret;
GDMonoUtils::MarshalUtils_DictToArrays dict_to_arrays = CACHED_METHOD_THUNK(MarshalUtils, DictionaryToArrays);
MonoArray *keys = NULL;
MonoArray *values = NULL;
MonoObject *ex = NULL;
dict_to_arrays(p_dict, &keys, &values, &ex);
if (ex) {
mono_print_unhandled_exception(ex);
ERR_FAIL_V(Dictionary());
}
int length = mono_array_length(keys);
for (int i = 0; i < length; i++) {
MonoObject *key_obj = mono_array_get(keys, MonoObject *, i);
MonoObject *value_obj = mono_array_get(values, MonoObject *, i);
Variant key = key_obj ? mono_object_to_variant(key_obj) : Variant();
Variant value = value_obj ? mono_object_to_variant(value_obj) : Variant();
ret[key] = value;
}
return ret;
}
}
| [
"rodrigosoaresilva@gmail.com"
] | rodrigosoaresilva@gmail.com |
9d7f2fa1891288248e604ea262efbc67e7e997bd | 8fd11fb8d935a3572630bcd779cd68619395390b | /connections.hpp | 31d3f5e58b3b7b89618c57cc0cf8b0020581c138 | [] | no_license | hacknazar21/simulations | b378a3213cf05876bbc48dfbea5854f832c3f8f3 | 8a3d14b034e54d9ad35df9be1a78b5c6ef652a70 | refs/heads/master | 2022-07-18T20:40:47.666234 | 2020-05-26T12:51:02 | 2020-05-26T12:51:02 | 266,716,767 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 112 | hpp | #include <iostream>
#include <windows.h>
#include <ctime>
#include <cstdlib>
#include <conio.h>
#include <cmath> | [
"nazarcool2001@gmail.com"
] | nazarcool2001@gmail.com |
190b98e1873ede0346a356ec21cf793525fbdce5 | 73c8a3179b944b63b2a798542896e4cdf0937b6e | /USACO/MessageRelay.cpp | c064c8f4779e9531f7b84aa9510a14f035528b4b | [
"Apache-2.0"
] | permissive | aajjbb/contest-files | c151f1ab9b562ca91d2f8f4070cb0aac126a188d | 71de602a798b598b0365c570dd5db539fecf5b8c | refs/heads/master | 2023-07-23T19:34:12.565296 | 2023-07-16T00:57:55 | 2023-07-16T00:57:59 | 52,963,297 | 2 | 4 | null | 2017-08-03T20:12:19 | 2016-03-02T13:05:25 | C++ | UTF-8 | C++ | false | false | 1,528 | cpp | #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <memory>
#include <iomanip>
#include <numeric>
#include <functional>
#include <new>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <cctype>
#include <ctime>
#define REP(i, n) for(int (i) = 0; i < n; i++)
#define FOR(i, a, n) for(int (i) = a; i < n; i++)
#define FORR(i, a, n) for(int (i) = a; i <= n; i++)
#define for_each(q, s) for(typeof(s.begin()) q=s.begin(); q!=s.end(); q++)
#define sz(n) n.size()
#define pb(n) push_back(n)
#define all(n) n.begin(), n.end()
template<typename T> T gcd(T a, T b) {
if(!b) return a;
return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
return a * b / gcd(a, b);
}
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = 1010;
int N, ans, nx[MAXN], done[MAXN];
int main(void) {
freopen("relay.in", "r", stdin);
freopen("relay.out", "w", stdout);
scanf("%d", &N);
for(int i = 1; i <= N; i++) {
scanf("%d", &nx[i]);
if(nx[i] == 0) done[i] = 1;
else done[i] = 0;
}
for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
if(done[nx[j]] == 1) done[j] = 1;
}
ans = 0;
for(int i = 1; i <= N; i++) ans += done[i];
printf("%d\n", ans);
return 0;
}
| [
"jefersonlsiq@gmail.com"
] | jefersonlsiq@gmail.com |
23495d329df71f4eb564adacb12a45abb5ee4512 | dfa4bb724b21cff9e8f66d96c0104482ef404d3f | /src/Lab2.cpp | a8453e47d4a1e745e26031fbd01423cf7cb1c782 | [] | no_license | addisonsi/Lab2 | 5faeaf8d71b064ba4c69e66ccb3e6b400f406924 | 3f90639c97c4e0d1d5c2bfa2d5ed601b0b0f7e00 | refs/heads/main | 2023-06-05T04:14:02.630518 | 2021-06-29T18:17:29 | 2021-06-29T18:17:29 | 381,457,300 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 747 | cpp | /******************************************************/
// THIS IS A GENERATED FILE - DO NOT EDIT //
/******************************************************/
#include "Particle.h"
#line 1 "/Users/addisonsimon/Lab2/src/Lab2.ino"
void setup();
void loop();
#line 2 "/Users/addisonsimon/Lab2/src/Lab2.ino"
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
void setup() {
// Put initialization like pinMode and begin functions here.
Serial.begin(9600);
pinMode(D5, OUTPUT);
//uint16_t value;
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
uint16_t value;
value = analogRead(A5);
Serial.println(value);
digitalWrite(D5, HIGH);
delay(value);
digitalWrite(D5, LOW);
delay(value);
} | [
"addisonsimon@Addisons-MacBook-Air.local"
] | addisonsimon@Addisons-MacBook-Air.local |
1318c39efe581855be22fbc0425071b475f3ee9f | 71b45a09a4d5d991079e96b91b35bcf44df85f2b | /Sources/Math/LumiereMathStd.h | 4c7ed6f15af3bd0601d7599601d35d51a5f7c2b1 | [
"MIT"
] | permissive | LeptusHe/Lumiere | 230661fd4fa31c0562757ba04a156676c7f15c41 | 907afdb030c619a07e8a6c33ed55e5898f73be63 | refs/heads/master | 2021-06-22T17:06:16.954323 | 2021-05-17T16:36:00 | 2021-05-17T16:36:00 | 223,726,794 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,719 | h | #pragma once
#include "Common/LumiereMacro.h"
#include "LumiereFloatDefs.h"
BEGIN_LUMIERE_NAMESPACE
#ifdef LUMIERE_IS_DEVICE_CODE
#define ShadowEpsilon 0.0001f
#define Pi Float(3.14159265358979323846)
#define InvPi Float(0.31830988618379067154)
#define Inv2Pi Float(0.15915494309189533577)
#define Inv4Pi Float(0.07957747154594766788)
#define PiOver2 Float(1.57079632679489661923)
#define PiOver4 Float(0.78539816339744830961)
#define Sqrt2 Float(1.41421356237309504880)
#else
// Mathematical Constants
constexpr Float ShadowEpsilon = 0.0001f;
constexpr Float Pi = 3.14159265358979323846;
constexpr Float InvPi = 0.31830988618379067154;
constexpr Float Inv2Pi = 0.15915494309189533577;
constexpr Float Inv4Pi = 0.07957747154594766788;
constexpr Float PiOver2 = 1.57079632679489661923;
constexpr Float PiOver4 = 0.78539816339744830961;
constexpr Float Sqrt2 = 1.41421356237309504880;
#endif
template <typename T>
inline LUMIERE_HOST_DEVICE typename std::enable_if_t<std::is_integral<T>::value, T> FMA(T a, T b, T c)
{
return a * b + c;
}
template <typename Ta, typename Tb, typename Tc, typename Td>
LUMIERE_HOST_DEVICE inline auto DifferenceOfProducts(Ta a, Tb b, Tc c, Td d)
{
auto cd = c * d;
auto differenceOfProducts = FMA(a, b, -cd);
auto error = FMA(-c, d, cd);
return differenceOfProducts + error;
}
template <typename Ta, typename Tb, typename Tc, typename Td>
LUMIERE_HOST_DEVICE inline auto SumOfProducts(Ta a, Tb b, Tc c, Td d)
{
auto cd = c * d;
auto sumOfProducts = FMA(a, b, cd);
auto error = FMA(c, d, -cd);
return sumOfProducts + error;
}
template <typename T>
LUMIERE_HOST_DEVICE inline constexpr T Sqr(T v)
{
return v * v;
}
END_LUMIERE_NAMESPACE | [
"weidonghe@tencent.com"
] | weidonghe@tencent.com |
1e42f6ef7ded4d5fcadcc9603feba352534fc308 | ab79c0e06b231c0b0d2644ba661e13a2e4690ab4 | /src/Model/Node.h | b12a0746d5bad7b994c848e00f9e209653d1f35b | [] | no_license | justasktylerj/Nodes | ed5fc7a1f384cbc9ff02bfb243799199dedfa8dd | 6fd48ff4e64a64fb679a7a9d753da0d18ff7e84d | refs/heads/master | 2021-01-10T09:32:20.334431 | 2016-03-10T16:38:37 | 2016-03-10T16:38:37 | 50,521,896 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 385 | h | /*
* Node.h
*
* Created on: Jan 27, 2016
* Author: tjar2074
*/
#ifndef MODEL_NODE_H_
#define MODEL_NODE_H_
#include <iostream>
template <class Type>
class Node
{
private:
Type value;
Node * pointers;
public:
Node();
Node(const Type& value);
virtual ~Node();
Type getValue();
void setValue(const Type& value);
Node * getPointers();
};
#endif /* MODEL_NODE_H_ */
| [
"tjar2074@740s-pl-104.local"
] | tjar2074@740s-pl-104.local |
f2db0dd4edf04d0dcd30171a25746c54241999d7 | 42614c9938e56d9349f82e632fededd10a4382de | /1053-previousPermutationWithOneSwap.cpp | bfb3388d8fd3c985ddbbe671dab3ed79b464df4d | [] | no_license | rouman321/code-practice | fe1e092f0f99c689e0ffb3398222d6482cda3fe3 | d43c73c8a74a95b5e5a568fe40b5cb0cda6c8974 | refs/heads/master | 2020-07-29T06:29:30.820220 | 2019-11-25T19:26:12 | 2019-11-25T19:26:12 | 209,698,973 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | /*
LeetCode 1053. Previous Permutation With One Swap
medium
time: 112ms
space: 12.7mb
*/
class Solution {
public:
vector<int> prevPermOpt1(vector<int>& A) {
int i = A.size()-2;
while(i>=0&&A[i]<=A[i+1]){
--i;
}
if(i!=-1){
int l = i;
int m = 0;
int r = 0;
i = l+1;
while(i<A.size()&&A[i]<A[l]){
if(A[i]>m){
m = A[i];
r = i;
}
++i;
}
swap(A[l],A[r]);
}
return A;
}
}; | [
"rouman321@gmail.com"
] | rouman321@gmail.com |
af685631e5fed86a12a0f85b20c51bd06b159be1 | b4e9ff1b80ff022aaacdf2f863bc3a668898ce7f | /openfl/Atriangle/Export/macos/obj/include/lime/text/harfbuzz/HBFeature.h | e05b033b3784ccc0db36782dc046fff37d87fdfb | [
"MIT"
] | permissive | TrilateralX/TrilateralSamples | c1aa206495cf6e1f4f249c87e49fa46d62544c24 | 9c9168c5c2fabed9222b47e738c67ec724b52aa6 | refs/heads/master | 2023-04-02T05:10:13.579952 | 2021-04-01T17:41:23 | 2021-04-01T17:41:23 | 272,706,707 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 1,864 | h | // Generated by Haxe 4.2.0-rc.1+7dc565e63
#ifndef INCLUDED_lime_text_harfbuzz_HBFeature
#define INCLUDED_lime_text_harfbuzz_HBFeature
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_STACK_FRAME(_hx_pos_e935673f08494dca_6_new)
HX_DECLARE_CLASS3(lime,text,harfbuzz,HBFeature)
namespace lime{
namespace text{
namespace harfbuzz{
class HXCPP_CLASS_ATTRIBUTES HBFeature_obj : public ::hx::Object
{
public:
typedef ::hx::Object super;
typedef HBFeature_obj OBJ_;
HBFeature_obj();
public:
enum { _hx_ClassId = 0x6f399a5a };
void __construct();
inline void *operator new(size_t inSize, bool inContainer=false,const char *inName="lime.text.harfbuzz.HBFeature")
{ return ::hx::Object::operator new(inSize,inContainer,inName); }
inline void *operator new(size_t inSize, int extra)
{ return ::hx::Object::operator new(inSize+extra,false,"lime.text.harfbuzz.HBFeature"); }
inline static ::hx::ObjectPtr< HBFeature_obj > __new() {
::hx::ObjectPtr< HBFeature_obj > __this = new HBFeature_obj();
__this->__construct();
return __this;
}
inline static ::hx::ObjectPtr< HBFeature_obj > __alloc(::hx::Ctx *_hx_ctx) {
HBFeature_obj *__this = (HBFeature_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(HBFeature_obj), false, "lime.text.harfbuzz.HBFeature"));
*(void **)__this = HBFeature_obj::_hx_vtable;
{
HX_STACKFRAME(&_hx_pos_e935673f08494dca_6_new)
}
return __this;
}
static void * _hx_vtable;
static Dynamic __CreateEmpty();
static Dynamic __Create(::hx::DynamicArray inArgs);
//~HBFeature_obj();
HX_DO_RTTI_ALL;
static void __register();
bool _hx_isInstanceOf(int inClassId);
::String __ToString() const { return HX_("HBFeature",dc,0e,b5,fa); }
};
} // end namespace lime
} // end namespace text
} // end namespace harfbuzz
#endif /* INCLUDED_lime_text_harfbuzz_HBFeature */
| [
"none"
] | none |
122cec1c718a3c07bb4d6c43d1b1e3230c7a1283 | 1df5d571b3c16a85358738e4ce6fe779d7c7483e | /TestCases/testFac.cpp | 3d89a288a03bff92a2886e824f3b39a18505c526 | [] | no_license | devdeepray/IITBCompilerLabProject | 0bfe176460be65d33fbe41f43bbf8dc5885f2c9b | d634f57244cbcf603a3d4b1f710f2c0c1b602c4e | refs/heads/master | 2020-04-16T04:32:52.011568 | 2015-04-28T12:00:38 | 2015-04-28T12:00:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 179 | cpp | int fac(int n)
{
if(n==0)
{
return 1;
}
else
{
;
}
return n*fac(n-1);
}
int main()
{
int x;
x = 10;
printf("Fac of x: %d", fac(x));
return 23;
}
| [
"vishalagarwal3010@gmail.com"
] | vishalagarwal3010@gmail.com |
270e69fd21b9d9f878f58ab51d31e64246b427fa | 0e7a7f8447d42e9c2eef5fb45a11b10895248729 | /frameworks/runtime-src/Classes/PluginFlurryAnalyticsLuaHelper.cpp | 15ff6ee298fe585e7d1ecfde0a1c7b61fc9ee35f | [] | no_license | galigalikun/qb | c2f0ce5563922277bdd7d34a25222ff5dbc05c70 | 3681c8b30e526322c77eb2dcfc38bf6440e28d99 | refs/heads/master | 2016-09-12T17:31:34.924403 | 2016-05-22T13:54:59 | 2016-05-22T13:54:59 | 58,214,895 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,170 | cpp |
#include "PluginFlurryAnalyticsLuaHelper.h"
#include "PluginFlurryAnalytics/PluginFlurryAnalytics.h"
#include "CCLuaEngine.h"
#include "tolua_fix.h"
#include "SDKBoxLuaHelper.h"
#include <sstream>
class FlurryAnalyticsListenerLua : public sdkbox::FlurryAnalyticsListener {
public:
FlurryAnalyticsListenerLua(): mLuaHandler(0) {
}
~FlurryAnalyticsListenerLua() {
resetHandler();
}
void setHandler(int luaHandler) {
if (mLuaHandler == luaHandler) {
return;
}
resetHandler();
mLuaHandler = luaHandler;
}
void resetHandler() {
if (0 == mLuaHandler) {
return;
}
LUAENGINE->removeScriptHandler(mLuaHandler);
mLuaHandler = 0;
}
void flurrySessionDidCreateWithInfo(std::map<std::string, std::string>& info) {
std::string jsonStr = map2JsonString(info);
LuaStack* stack = LUAENGINE->getLuaStack();
stack->pushString(jsonStr.c_str());
stack->executeFunctionByHandler(mLuaHandler, 1);
}
private:
std::string map2JsonString(std::map<std::string, std::string>& map) {
std::ostringstream strStream;
bool bFirstItem = true;
strStream << "{";
for (std::map<std::string, std::string>::iterator it = map.begin()
; it != map.end()
; it++)
{
if (!bFirstItem) {
strStream << ",";
}
strStream << "\"";
strStream << it->first;
strStream << "\":\"";
strStream << it->second;
strStream << "\"";
bFirstItem = false;
}
strStream << "}";
return strStream.str();
}
private:
int mLuaHandler;
};
int lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_logEvent(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"sdkbox.PluginFlurryAnalytics",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
int ret = sdkbox::PluginFlurryAnalytics::logEvent(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 2)
{
if (lua_isboolean(tolua_S, 3)) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
bool arg1;
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
int ret = sdkbox::PluginFlurryAnalytics::logEvent(arg0, arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
} else {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
int ret = sdkbox::PluginFlurryAnalytics::logEvent(arg0, arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
}
} while (0);
ok = true;
do
{
if (argc == 3)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
bool arg2;
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "sdkbox.PluginFlurryAnalytics:logEvent");
if (!ok) { break; }
int ret = sdkbox::PluginFlurryAnalytics::logEvent(arg0, arg1, arg2);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "sdkbox.PluginFlurryAnalytics:logEvent",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_logEvent'.",&tolua_err);
#endif
return 0;
}
int lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_addOrigin(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"sdkbox.PluginFlurryAnalytics",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 2)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:addOrigin");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:addOrigin");
if (!ok) { break; }
sdkbox::PluginFlurryAnalytics::addOrigin(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 3)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:addOrigin");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:addOrigin");
if (!ok) { break; }
std::string arg2;
ok &= luaval_to_std_string(tolua_S, 4,&arg2, "sdkbox.PluginFlurryAnalytics:addOrigin");
if (!ok) { break; }
sdkbox::PluginFlurryAnalytics::addOrigin(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "sdkbox.PluginFlurryAnalytics:addOrigin",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_addOrigin'.",&tolua_err);
#endif
return 0;
}
int lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_endTimedEvent(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"sdkbox.PluginFlurryAnalytics",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:endTimedEvent");
if (!ok) { break; }
sdkbox::PluginFlurryAnalytics::endTimedEvent(arg0);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 2)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "sdkbox.PluginFlurryAnalytics:endTimedEvent");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "sdkbox.PluginFlurryAnalytics:endTimedEvent");
if (!ok) { break; }
sdkbox::PluginFlurryAnalytics::endTimedEvent(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "sdkbox.PluginFlurryAnalytics:endTimedEvent",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_endTimedEvent'.",&tolua_err);
#endif
return 0;
}
int lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_setListener(lua_State* tolua_S) {
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"sdkbox.PluginFlurryAnalytics",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(tolua_S, 2 , "LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
FlurryAnalyticsListenerLua* lis = NULL;
if (NULL == lis) {
lis = new FlurryAnalyticsListenerLua();
}
lis->setHandler(handler);
sdkbox::PluginFlurryAnalytics::setListener(lis);
return 0;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "sdkbox.PluginFlurryAnalytics::setListener",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_setListener'.",&tolua_err);
#endif
return 0;
}
int extern_PluginFlurryAnalytics(lua_State* L) {
if (NULL == L) {
return 0;
}
lua_pushstring(L, "sdkbox.PluginFlurryAnalytics");
lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1))
{
tolua_function(L, "logEvent", lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_logEvent);
tolua_function(L,"addOrigin", lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_addOrigin);
tolua_function(L,"endTimedEvent", lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_endTimedEvent);
tolua_function(L,"setListener", lua_PluginFlurryAnalyticsLua_PluginFlurryAnalytics_setListener);
}
lua_pop(L, 1);
return 1;
}
TOLUA_API int register_all_PluginFlurryAnalyticsLua_helper(lua_State* L) {
tolua_module(L,"sdkbox",0);
tolua_beginmodule(L,"sdkbox");
extern_PluginFlurryAnalytics(L);
tolua_endmodule(L);
return 1;
}
| [
"t_akaishi@cgate.jp"
] | t_akaishi@cgate.jp |
9dcc2dfeb9d7246b113db12f28687c3ad58c681a | 8d952a06e3809a06825a3be7b067201f3652f16a | /debug/atomics/qss/qss_switch.h | 192d07b0be49c866ac2d53de9e4c5d7a639a9295 | [
"MIT",
"GPL-3.0-only"
] | permissive | andyLaurito92/haikunet | b771eaf6bd91292485f0a49698ce123b9308d676 | db44623b248c56735c28a5f589c3239dc7e9855e | refs/heads/master | 2021-06-14T12:38:38.996450 | 2021-05-05T18:26:02 | 2021-05-05T18:26:02 | 75,564,849 | 2 | 1 | MIT | 2021-05-05T18:26:26 | 2016-12-04T21:12:31 | C++ | UTF-8 | C++ | false | false | 567 | h | //CPP:qss/qsstools.cpp
//CPP:qss/qss_switch.cpp
#if !defined qss_switch_h
#define qss_switch_h
#include "simulator.h"
#include "event.h"
#include "stdarg.h"
#include "qss/qsstools.h"
class qss_switch: public Simulator {
//states
double sigma,tcross;
double u[3][10];
int sw,change;
//output
double y[10];
//parameters
double level;
#define INF 1e20
public:
qss_switch(const char *n): Simulator(n) {};
void init(double, ...);
double ta(double t);
void dint(double);
void dext(Event , double );
Event lambda(double);
void exit();
};
#endif
| [
"andy.laurito@gmail.com"
] | andy.laurito@gmail.com |
cb042e333218c4f44be0170211629e2a23adcb6b | fabafea14b6ba449e8745875b0ef66062808dbe9 | /Part_5/cartesian_planner/src/baxter_cartesian_planner.cpp | 3631bfb3ad1ccb2903ff044f08d3e2ee2c8f3e39 | [] | no_license | wsnewman/learning_ros | fdfb3caac4bf99d53d9079f4f46212eb8b33d2ef | c98c8a02750eb4271bd1568a3c444c36fa984ee1 | refs/heads/noetic_devel | 2022-06-02T15:27:32.280923 | 2022-03-14T14:36:06 | 2022-03-14T14:36:06 | 49,152,692 | 362 | 246 | null | 2022-03-28T14:54:19 | 2016-01-06T18:12:19 | C++ | UTF-8 | C++ | false | false | 24,403 | cpp | // baxter_cartesian_planner.cpp:
// wsn, Nov, 2016
// a library of arm-motion planning functions
// assumes use of tool-flange frame (to allow for interchangeable grippers)
// uses package joint_space_planner to find a good joint-space path among options
// from IK solutions
// key fnc:
// nsolns = baxter_IK_solver_.ik_solve_approx_wrt_torso(a_flange_des, q_solns);
// a_flange_des is the desired tool-flange pose of RIGHT ARM
#include <cartesian_planner/baxter_cartesian_planner.h>
//constructor:
CartTrajPlanner::CartTrajPlanner() // optionally w/ args, e.g.
//: as_(nh_, "CartTrajPlanner", boost::bind(&cartTrajActionServer::executeCB, this, _1), false)
{
ROS_INFO("in constructor of CartTrajPlanner...");
//define a fixed orientation: tool flange pointing down, with x-axis forward
b_des_ << 0, 0, -1;
n_des_ << 1, 0, 0;
t_des_ = b_des_.cross(n_des_);
R_gripper_down_.col(0) = n_des_;
R_gripper_down_.col(1) = t_des_;
R_gripper_down_.col(2) = b_des_;
// define a fixed orientation corresponding to horizontal tool normal,
// vector between fingers also horizontal
// right-hand gripper approach direction along y axis
// useful, e.g. for picking up a bottle to be poured
tool_n_des_horiz_ << 1, 0, 0;
tool_b_des_horiz_ << 0, 1, 0;
tool_t_des_horiz_ = tool_b_des_horiz_.cross(tool_n_des_horiz_);
R_gripper_horiz_.col(0) = tool_n_des_horiz_;
R_gripper_horiz_.col(1) = tool_t_des_horiz_;
R_gripper_horiz_.col(2) = tool_b_des_horiz_;
jspace_planner_weights_.resize(7);
jspace_planner_weights_[0] = 2;
//penalize shoulder lift more:
jspace_planner_weights_[1] = 10;
//humerus:
jspace_planner_weights_[2] = 3;
//penalize elbow and wrist less
jspace_planner_weights_[3] = 0.5;
jspace_planner_weights_[4] = 0.2;
jspace_planner_weights_[5] = 0.2;
jspace_planner_weights_[6] = 0.2;
}
//specify start and end poses w/rt torso. Only orientation of end pose will be considered; orientation of start pose is ignored
bool CartTrajPlanner::cartesian_path_planner(Eigen::Affine3d a_flange_start, Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path) {
std::vector<std::vector<Eigen::VectorXd> > path_options;
path_options.clear();
std::vector<Eigen::VectorXd> single_layer_nodes;
Eigen::VectorXd node;
Eigen::Affine3d a_flange_des;
Eigen::Matrix3d R_des = a_flange_end.linear();
a_flange_des.linear() = R_des;
//store a vector of Cartesian affine samples for desired path:
cartesian_affine_samples_.clear();
//cartesian_affine_samples_.push_back(a_flange_start);
int nsolns;
bool reachable_proposition;
int nsteps = 0;
Eigen::Vector3d p_des, dp_vec, del_p, p_start, p_end;
p_start = a_flange_start.translation();
p_end = a_flange_end.translation();
del_p = p_end - p_start;
double dp_scalar = CARTESIAN_PATH_SAMPLE_SPACING;
nsteps = round(del_p.norm() / dp_scalar);
if (nsteps < 1) nsteps = 1;
dp_vec = del_p / nsteps;
nsteps++; //account for pose at step 0
std::vector<Vectorq7x1> q_solns;
p_des = p_start;
for (int istep = 0; istep < nsteps; istep++) {
a_flange_des.translation() = p_des;
cartesian_affine_samples_.push_back(a_flange_des);
cout << "trying: " << p_des.transpose() << endl;
nsolns = baxter_IK_solver_.ik_solve_approx_wrt_torso(a_flange_des, q_solns);
std::cout << "nsolns = " << nsolns << endl;
single_layer_nodes.clear();
if (nsolns > 0) {
single_layer_nodes.resize(nsolns);
for (int isoln = 0; isoln < nsolns; isoln++) {
// this is annoying: can't treat std::vector<Vectorq7x1> same as std::vector<Eigen::VectorXd>
node = q_solns[isoln];
single_layer_nodes[isoln] = node;
}
path_options.push_back(single_layer_nodes);
}
else {
return false;
}
p_des += dp_vec;
}
//plan a path through the options:
int nlayers = path_options.size();
if (nlayers < 1) {
ROS_WARN("no viable options: quitting");
return false; // give up if no options
}
//std::vector<Eigen::VectorXd> optimal_path;
optimal_path.resize(nlayers);
double trip_cost;
// compute min-cost path, using Stagecoach algorithm
cout << "instantiating a JointSpacePlanner:" << endl;
{ //limit the scope of jsp here:
JointSpacePlanner jsp(path_options, jspace_planner_weights_);
cout << "recovering the solution..." << endl;
jsp.get_soln(optimal_path);
trip_cost = jsp.get_trip_cost();
}
//now, jsp is deleted, but optimal_path lives on:
cout << "resulting solution path: " << endl;
for (int ilayer = 0; ilayer < nlayers; ilayer++) {
cout << "ilayer: " << ilayer << " node: " << optimal_path[ilayer].transpose() << endl;
}
cout << "soln min cost: " << trip_cost << endl;
return true;
}
// alt version: specify start as a q_vec, and goal as a Cartesian pose of tool flange (w/rt torso)
bool CartTrajPlanner::cartesian_path_planner(Vectorq7x1 q_start, Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path,
double dp_scalar/* = CARTESIAN_PATH_SAMPLE_SPACING*/) {
std::vector<std::vector<Eigen::VectorXd> > path_options;
path_options.clear();
std::vector<Eigen::VectorXd> single_layer_nodes;
Eigen::VectorXd node;
Eigen::Affine3d a_flange_des, a_flange_start;
Eigen::Matrix3d R_des = a_flange_end.linear();
a_flange_start = baxter_fwd_solver_.fwd_kin_flange_wrt_torso_solve(q_start);
cout << "fwd kin from q_start: " << a_flange_start.translation().transpose() << endl;
cout << "fwd kin from q_start R: " << endl;
cout << a_flange_start.linear() << endl;
//store a vector of Cartesian affine samples for desired path:
cartesian_affine_samples_.clear();
a_flange_des = a_flange_end;
a_flange_start.linear() = R_des; // no interpolation of orientation; set goal orientation immediately
a_flange_des.linear() = R_des; //expected behavior: will try to achieve orientation first, before translating
int nsolns;
bool reachable_proposition;
int nsteps = 0;
Eigen::Vector3d p_des, dp_vec, del_p, p_start, p_end;
p_start = a_flange_start.translation();
p_end = a_flange_des.translation();
del_p = p_end - p_start;
cout << "p_start: " << p_start.transpose() << endl;
cout << "p_end: " << p_end.transpose() << endl;
cout << "del_p: " << del_p.transpose() << endl;
//double dp_scalar = CARTESIAN_PATH_SAMPLE_SPACING;
nsteps = round(del_p.norm() / dp_scalar);
if (nsteps < 1) nsteps = 1;
dp_vec = del_p / nsteps;
cout << "dp_vec for nsteps = " << nsteps << " is: " << dp_vec.transpose() << endl;
nsteps++; //account for pose at step 0
//coerce path to start from provided q_start;
single_layer_nodes.clear();
node = q_start;
single_layer_nodes.push_back(node);
path_options.push_back(single_layer_nodes);
std::vector<Vectorq7x1> q_solns;
p_des = p_start;
cartesian_affine_samples_.push_back(a_flange_start);
for (int istep = 1; istep < nsteps; istep++) {
p_des += dp_vec;
a_flange_des.translation() = p_des;
cartesian_affine_samples_.push_back(a_flange_des);
cout << "trying: " << p_des.transpose() << endl;
nsolns = baxter_IK_solver_.ik_solve_approx_wrt_torso(a_flange_des, q_solns);
std::cout << "nsolns = " << nsolns << endl;
single_layer_nodes.clear();
if (nsolns > 0) {
single_layer_nodes.resize(nsolns);
for (int isoln = 0; isoln < nsolns; isoln++) {
// this is annoying: can't treat std::vector<Vectorq7x1> same as std::vector<Eigen::VectorXd>
node = q_solns[isoln];
single_layer_nodes[isoln] = node;
}
path_options.push_back(single_layer_nodes);
} else {
return false;
}
}
//plan a path through the options:
int nlayers = path_options.size();
if (nlayers < 1) {
ROS_WARN("no viable options: quitting");
return false; // give up if no options
}
//std::vector<Eigen::VectorXd> optimal_path;
optimal_path.resize(nlayers);
double trip_cost;
// compute min-cost path, using Stagecoach algorithm
cout << "instantiating a JointSpacePlanner:" << endl;
{ //limit the scope of jsp here:
JointSpacePlanner jsp(path_options, jspace_planner_weights_);
cout << "recovering the solution..." << endl;
jsp.get_soln(optimal_path);
trip_cost = jsp.get_trip_cost();
}
//now, jsp is deleted, but optimal_path lives on:
cout << "resulting solution path: " << endl;
for (int ilayer = 0; ilayer < nlayers; ilayer++) {
cout << "ilayer: " << ilayer << " node: " << optimal_path[ilayer].transpose() << endl;
}
cout << "soln min cost: " << trip_cost << endl;
return true;
}
//this version uses a finer Cartesian sampling dp than the default
bool CartTrajPlanner::fine_cartesian_path_planner(Vectorq7x1 q_start, Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path) {
//do trajectory planning w/ fine samples along Cartesian direction, but approximate IK solns:
bool valid = cartesian_path_planner(q_start, a_flange_end, optimal_path, CARTESIAN_PATH_FINE_SAMPLE_SPACING);
if (!valid) {
return false;
}
//now refine this w/ IK iterations:
refine_cartesian_path_plan(optimal_path);
return valid;
}
// alt version: specify start as a q_vec, and desired delta-p Cartesian motion while holding R fixed
bool CartTrajPlanner::cartesian_path_planner_delta_p(Vectorq7x1 q_start, Eigen::Vector3d delta_p, std::vector<Eigen::VectorXd> &optimal_path) {
std::vector<std::vector<Eigen::VectorXd> > path_options;
//store a vector of Cartesian affine samples for desired path:
cartesian_affine_samples_.clear();
path_options.clear();
std::vector<Eigen::VectorXd> single_layer_nodes;
Eigen::VectorXd node;
Eigen::Affine3d a_flange_des, a_flange_start, a_flange_end;
Eigen::Vector3d p_des, dp_vec, del_p, p_start, p_end;
a_flange_start = baxter_fwd_solver_.fwd_kin_flange_wrt_torso_solve(q_start);
Eigen::Matrix3d R_des = a_flange_start.linear();
p_des = a_flange_start.translation();
cartesian_affine_samples_.push_back(a_flange_start);
cout << "fwd kin from q_start p: " << p_des.transpose() << endl;
cout << "fwd kin from q_start R: " << endl;
cout << a_flange_start.linear() << endl;
//a_flange_start.linear() = R_des; // override the orientation component--require point down
//construct a goal pose, based on start pose:
a_flange_end.linear() = R_des;
a_flange_des.linear() = R_des; // variable used to hold steps of a_des...always with same R
a_flange_end.translation() = p_des + delta_p;
int nsolns;
bool reachable_proposition;
int nsteps = 0;
p_start = a_flange_start.translation();
p_end = a_flange_end.translation();
del_p = p_end - p_start; // SHOULD be same as delta_p input
cout << "p_start: " << p_start.transpose() << endl;
cout << "p_end: " << p_end.transpose() << endl;
cout << "del_p: " << del_p.transpose() << endl;
double dp_scalar = 0.05;
nsteps = round(del_p.norm() / dp_scalar);
if (nsteps < 1) nsteps = 1;
dp_vec = del_p / nsteps;
cout << "dp_vec for nsteps = " << nsteps << " is: " << dp_vec.transpose() << endl;
nsteps++; //account for pose at step 0
//coerce path to start from provided q_start;
single_layer_nodes.clear();
node = q_start;
single_layer_nodes.push_back(node);
path_options.push_back(single_layer_nodes);
std::vector<Vectorq7x1> q_solns;
p_des = p_start;
for (int istep = 1; istep < nsteps; istep++) {
p_des += dp_vec;
a_flange_des.translation() = p_des;
cartesian_affine_samples_.push_back(a_flange_des);
cout << "trying: " << p_des.transpose() << endl;
nsolns = baxter_IK_solver_.ik_solve_approx_wrt_torso(a_flange_des, q_solns);
std::cout << "nsolns = " << nsolns << endl;
single_layer_nodes.clear();
if (nsolns > 0) {
single_layer_nodes.resize(nsolns);
for (int isoln = 0; isoln < nsolns; isoln++) {
// this is annoying: can't treat std::vector<Vectorq7x1> same as std::vector<Eigen::VectorXd>
node = q_solns[isoln];
single_layer_nodes[isoln] = node;
}
path_options.push_back(single_layer_nodes);
} else {
return false;
}
}
//plan a path through the options:
int nlayers = path_options.size();
if (nlayers < 1) {
ROS_WARN("no viable options: quitting");
return false; // give up if no options
}
//std::vector<Eigen::VectorXd> optimal_path;
optimal_path.resize(nlayers);
double trip_cost;
// compute min-cost path, using Stagecoach algorithm
cout << "instantiating a JointSpacePlanner:" << endl;
{ //limit the scope of jsp here:
JointSpacePlanner jsp(path_options, jspace_planner_weights_);
cout << "recovering the solution..." << endl;
jsp.get_soln(optimal_path);
trip_cost = jsp.get_trip_cost();
}
//now, jsp is deleted, but optimal_path lives on:
cout << "resulting solution path: " << endl;
for (int ilayer = 0; ilayer < nlayers; ilayer++) {
cout << "ilayer: " << ilayer << " node: " << optimal_path[ilayer].transpose() << endl;
}
cout << "soln min cost: " << trip_cost << endl;
return true;
}
//given an approximate motion plan in joint space, and given the corresponding Cartesian affine samples in cartesian_affine_samples_,
// use Jacobian iterations to improve the joint-space solution accuracy for each point;
// update optimal_path with these revised joint-space solutions
bool CartTrajPlanner::refine_cartesian_path_plan(std::vector<Eigen::VectorXd> &optimal_path) {
int nsamps_path = optimal_path.size();
int nsamps_cart = cartesian_affine_samples_.size();
if (nsamps_path != nsamps_cart) {
ROS_WARN("found %d samples in provided optimal path", nsamps_path);
ROS_WARN("found %d samples in internal vector of Cartesian samples", nsamps_cart);
ROS_WARN("number of jspace samples does not match number of cartesian samples; cannot refine path:");
return false;
}
if (nsamps_path<2) {
ROS_WARN("refine_cartesian path: not enough points in provided path");
return false;
}
//if here, march through each solution and refine it:
ROS_INFO("refining cartesian solutions...");
Eigen::Affine3d des_flange_affine;
Eigen::VectorXd approx_jspace_soln;
Eigen::VectorXd refined_jspace_soln;
Vectorq7x1 q_in, q_7dof_precise;
bool valid;
//start from i=1; keep start pose as-is
for (int i = 1; i < nsamps_cart; i++) {
des_flange_affine = cartesian_affine_samples_[i];
approx_jspace_soln = optimal_path[i];
q_in = approx_jspace_soln; //convert data type
valid = baxter_IK_solver_.improve_7dof_soln_wrt_torso(des_flange_affine, q_in, q_7dof_precise);
if (valid) { //note: if solution is not improved, retain approximate solution
refined_jspace_soln = q_7dof_precise;
optimal_path[i] = refined_jspace_soln; //install the improved soln
}
}
return true;
}
// alt version: specify start as a q_vec, and goal as a Cartesian pose (w/rt torso)--but only plan a wrist path
bool CartTrajPlanner::cartesian_path_planner_wrist(Vectorq7x1 q_start, Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path) {
std::vector<std::vector<Eigen::VectorXd> > path_options;
path_options.clear();
std::vector<Eigen::VectorXd> single_layer_nodes;
Eigen::VectorXd node;
Eigen::Affine3d a_flange_des, a_flange_start;
Eigen::Matrix3d R_des = a_flange_end.linear();
a_flange_start = baxter_fwd_solver_.fwd_kin_flange_wrt_torso_solve(q_start);
cout << "fwd kin from q_start: " << a_flange_start.translation().transpose() << endl;
cout << "fwd kin from q_start R: " << endl;
cout << a_flange_start.linear() << endl;
a_flange_start.linear() = R_des; // override the orientation component--require point down
a_flange_des.linear() = R_des;
int nsolns;
bool reachable_proposition;
int nsteps = 0;
Eigen::Vector3d p_des, dp_vec, del_p, p_start, p_end;
p_start = a_flange_start.translation();
p_end = a_flange_end.translation();
del_p = p_end - p_start;
cout << "p_start: " << p_start.transpose() << endl;
cout << "p_end: " << p_end.transpose() << endl;
cout << "del_p: " << del_p.transpose() << endl;
double dp_scalar = CARTESIAN_PATH_SAMPLE_SPACING;
nsteps = round(del_p.norm() / dp_scalar);
if (nsteps < 1) nsteps = 1;
dp_vec = del_p / nsteps;
cout << "dp_vec for nsteps = " << nsteps << " is: " << dp_vec.transpose() << endl;
nsteps++; //account for pose at step 0
//coerce path to start from provided q_start;
single_layer_nodes.clear();
node = q_start;
single_layer_nodes.push_back(node);
path_options.push_back(single_layer_nodes);
std::vector<Vectorq7x1> q_solns;
p_des = p_start;
for (int istep = 1; istep < nsteps; istep++) {
p_des += dp_vec;
a_flange_des.translation() = p_des;
cout << "trying: " << p_des.transpose() << endl;
//int ik_wristpt_solve_approx_wrt_torso(Eigen::Affine3d const& desired_hand_pose_wrt_torso,std::vector<Vectorq7x1> &q_solns);
nsolns = baxter_IK_solver_.ik_wristpt_solve_approx_wrt_torso(a_flange_des, q_solns);
std::cout << "nsolns = " << nsolns << endl;
single_layer_nodes.clear();
if (nsolns > 0) {
single_layer_nodes.resize(nsolns);
for (int isoln = 0; isoln < nsolns; isoln++) {
// this is annoying: can't treat std::vector<Vectorq7x1> same as std::vector<Eigen::VectorXd>
node = q_solns[isoln];
single_layer_nodes[isoln] = node;
}
path_options.push_back(single_layer_nodes);
} else {
return false;
}
}
//plan a path through the options:
int nlayers = path_options.size();
if (nlayers < 1) {
ROS_WARN("no viable options: quitting");
return false; // give up if no options
}
//std::vector<Eigen::VectorXd> optimal_path;
optimal_path.resize(nlayers);
double trip_cost;
// compute min-cost path, using Stagecoach algorithm
cout << "instantiating a JointSpacePlanner:" << endl;
{ //limit the scope of jsp here:
JointSpacePlanner jsp(path_options, jspace_planner_weights_);
cout << "recovering the solution..." << endl;
jsp.get_soln(optimal_path);
trip_cost = jsp.get_trip_cost();
}
//now, jsp is deleted, but optimal_path lives on:
cout << "resulting solution path: " << endl;
for (int ilayer = 0; ilayer < nlayers; ilayer++) {
cout << "ilayer: " << ilayer << " node: " << optimal_path[ilayer].transpose() << endl;
}
cout << "soln min cost: " << trip_cost << endl;
return true;
}
//bool CartTrajPlanner::cartesian_path_planner(Eigen::Affine3d a_flange_start,Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path) {
bool CartTrajPlanner::jspace_trivial_path_planner(Vectorq7x1 q_start, Vectorq7x1 q_end, std::vector<Eigen::VectorXd> &optimal_path) {
Eigen::VectorXd qx_start(7), qx_end(7); // need to convert to this type
//qx_start<<0,0,0,0,0,0,0; // resize
//qx_end<<0,0,0,0,0,0,0;
for (int i = 0; i < 7; i++) {
qx_start[i] = q_start[i];
qx_end[i] = q_end[i];
}
cout << "jspace_trivial_path_planner: " << endl;
cout << "q_start: " << qx_start.transpose() << endl;
cout << "q_end: " << qx_end.transpose() << endl;
optimal_path.clear();
optimal_path.push_back(qx_start);
optimal_path.push_back(qx_end);
return true;
}
bool CartTrajPlanner::jspace_path_planner_to_affine_goal(Vectorq7x1 q_start, Eigen::Affine3d a_flange_end, std::vector<Eigen::VectorXd> &optimal_path) {
Eigen::VectorXd qx_start(7), qx_end(7); // need to convert to this type
std::vector<Vectorq7x1> q_solns;
std::vector<std::vector<Eigen::VectorXd> > path_options;
path_options.clear();
std::vector<Eigen::VectorXd> single_layer_nodes;
Eigen::VectorXd node, precise_node;
Vectorq7x1 q_approx,q_refined;
single_layer_nodes.clear();
node = q_start;
single_layer_nodes.push_back(node);
for (int i = 0; i < 7; i++) {
qx_start[i] = q_start[i];
}
cout << "jspace planner to Cartesian goal: " << endl;
int nsolns = baxter_IK_solver_.ik_solve_approx_wrt_torso(a_flange_end, q_solns);
std::cout << "nsolns at goal pose = " << nsolns << endl;
single_layer_nodes.clear();
if (nsolns<1) return false; // give up
//else power on...
//single_layer_nodes.resize(nsolns);
for (int isoln = 0; isoln < nsolns; isoln++) {
q_approx = q_solns[isoln];
if (baxter_IK_solver_.improve_7dof_soln_wrt_torso(a_flange_end, q_approx, q_refined)) {
precise_node = q_refined; //convert to Eigen::VectorXd
cout<<"precise_node: "<<precise_node.transpose()<<endl;
single_layer_nodes.push_back(precise_node);
}
}
nsolns = single_layer_nodes.size();
ROS_INFO("found %d refined goal IK solns",nsolns);
if (nsolns <1) {
return false; //no solns
}
//ok--we have at least one precise soln;
//
optimal_path.clear();
optimal_path.push_back(qx_start);
//here is where we pick which of the joint-space goal solns is best:
// note: baxter's joints all include "0" within the reachable range
// and all solns must pass through 0. Therefore, qx_end-qx_start is an appropriate metric
// and motion THRU zero is appropriate (not shortest periodic distance)
//note: prepose hard-code defined in baxter_cart_move_as;
//q_pre_pose_ << -0.907528, -0.111813, 2.06622, 1.8737, -1.295, 2.00164, 0;
// should move this to a header; want shoulder elevation near zero to elevate elbow
Eigen::VectorXd dq_move(7), q_modified_start(7);
q_modified_start = qx_start;
q_modified_start[1] = 0; // bias preference for shoulder elevation near zero,
// regardless of start pose
cout<<"q_modified_start: "<<q_modified_start.transpose()<<endl;
//from baxter_traj_streamer.h:
//const double q0dotmax = 0.5;
//const double q1dotmax = 0.5;
//const double q2dotmax = 0.5;
//const double q3dotmax = 0.5;
//const double q4dotmax = 1;
//const double q5dotmax = 1;
//const double q6dotmax = 1;
// should make these speed limits more accessible
//jspace_planner_weights_ are defined here, above
double penalty_best = 1000000;
double penalty;
cout<<"jspace_planner_weights_: "<<jspace_planner_weights_.transpose()<<endl;
qx_end = single_layer_nodes[0]; //default: first soln
cout<<"qx_end: "<<qx_end.transpose()<<endl;
for (int i=0;i<nsolns;i++) {
dq_move = q_modified_start-single_layer_nodes[i];
cout<<"dq_move: "<<dq_move.transpose()<<endl;
penalty=0.0;
for (int j=0;j<7;j++) {
penalty+= jspace_planner_weights_[j]*fabs(dq_move[j]); //should scale by speed limits
}
ROS_INFO("soln %d has penalty = %f",i,penalty);
if (penalty<penalty_best) {
penalty_best = penalty;
qx_end = single_layer_nodes[i];
}
}
optimal_path.push_back(qx_end);
return true;
//return false; // not debugged, so don't trust!
}
// use this classes baxter fk solver to compute and return tool-flange pose w/rt torso, given right-arm joint angles
Eigen::Affine3d CartTrajPlanner::get_fk_Affine_from_qvec(Vectorq7x1 q_vec) {
Eigen::Affine3d Affine_pose;
Affine_pose = baxter_fwd_solver_.fwd_kin_flange_wrt_torso_solve(q_vec);
}
| [
"wsn@case.edu"
] | wsn@case.edu |
e9e0c9b97d2a2f1dcfa80eab4c24c251a179ae29 | f42cb6231258093a651053c87931186ef3ca19bc | /code/include/actor/step/HttpStep.hpp | a892d12b447a46952719d3a1db3a6f75afb7d24c | [] | no_license | lwaly/jy | 39f400102130461b20890838b293e2cdb5d349bd | 91b04dfa0c227b81629682427ef34cb1aef0660b | refs/heads/master | 2020-04-03T15:18:26.198584 | 2019-02-27T11:30:55 | 2019-02-27T11:30:55 | 155,358,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,449 | hpp | /*******************************************************************************
* Project: Nebula
* @file HttpStep.hpp
* @brief Http服务的异步步骤基类
* @author Bwar
* @date: 2016年8月13日
* @note
* Modify history:
******************************************************************************/
#ifndef SRC_ACTOR_STEP_HTTPSTEP_HPP_
#define SRC_ACTOR_STEP_HTTPSTEP_HPP_
#include <actor/step/Step.hpp>
#include "util/http/http_parser.h"
namespace neb
{
class HttpStep: public Step
{
public:
HttpStep(std::shared_ptr<Step> pNextStep = nullptr, ev_tstamp dTimeout = gc_dDefaultTimeout);
HttpStep(std::shared_ptr<SocketChannel> pUpstreamChannel, std::shared_ptr<Step> pNextStep = nullptr, ev_tstamp dTimeout = gc_dDefaultTimeout);
HttpStep(const HttpStep&) = delete;
HttpStep& operator=(const HttpStep&) = delete;
virtual ~HttpStep();
virtual E_CMD_STATUS Callback(
std::shared_ptr<SocketChannel> pUpstreamChannel,
const HttpMsg& oHttpMsg,
void* data = NULL) = 0;
bool HttpPost(const std::string& strUrl, const std::string& strBody, const std::unordered_map<std::string, std::string>& mapHeaders);
bool HttpGet(const std::string& strUrl);
protected:
bool HttpRequest(const HttpMsg& oHttpMsg);
std::shared_ptr<SocketChannel> m_pUpstreamChannel;
};
} /* namespace neb */
#endif /* SRC_ACTOR_STEP_HTTPSTEP_HPP_ */
| [
"279527404@qq.com"
] | 279527404@qq.com |
1e87dcd01a6c67a36de061aaab878f5e43c4d578 | 10bac563fc7e174d8f7c79c8777e4eb8460bc49e | /splam/detail/conversion.hpp | aef0433bdd9223bb0a01b479c20d3ed5a57cffc5 | [] | no_license | chenbk85/alcordev | 41154355a837ebd15db02ecaeaca6726e722892a | bdb9d0928c80315d24299000ca6d8c492808f1d5 | refs/heads/master | 2021-01-10T13:36:29.338077 | 2008-10-22T15:57:50 | 2008-10-22T15:57:50 | 44,953,286 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,428 | hpp | #ifndef CONVERSION_H
#define CONVERSION_H
//------------------------------------------------------------------------------------------------
#include <vector>
#include <cmath>
#include "ariautil.h"
#include "alcor.extern/pmap/slap.h"
#include "alcor/math/pose2d.h"
//------------------------------------------------------------------------------------------------
using namespace all::math;
//------------------------------------------------------------------------------------------------
namespace all{
namespace util{
inline pose2_t ArPose_to_pose2_t(ArPose pose)
{
pose2_t temp;
temp.pos.x = pose.getX();
temp.pos.y = pose.getY();
temp.rot = pose.getThRad();
return temp;
}
inline ArPose pose2_t_to_ArPose(pose2_t pose)
{
ArPose temp;
temp.setX(pose.pos.x);
temp.setY(pose.pos.y);
temp.setThRad(pose.rot);
return temp;
}
inline pose2_t pose2d_to_pose2_t(pose2d pose)
{
pose2_t temp;
temp.pos.x = pose.getX();
temp.pos.y = pose.getY();
temp.rot = pose.get_th(rad_tag);
return temp;
}
inline pose2d pose2_t_to_pose2d(pose2_t pose)
{
return pose2d(pose.pos.x,pose.pos.y,pose.rot,rad_tag);
}
inline pose2d ArPose_to_pose2d(ArPose pose)
{
return pose2d(pose.getX(), pose.getY(), pose.getThRad(), rad_tag);
}
}//namespace util
}//namespace all
//------------------------------------------------------------------------------------------------
#endif | [
"giorgio.ugazio@1c7d64d3-9b28-0410-bae3-039769c3cb81"
] | giorgio.ugazio@1c7d64d3-9b28-0410-bae3-039769c3cb81 |
1a188859d6c2aba6387efc13dd018cd438db89ab | 9a120f288f3bc6cbb9e768d3a55e2ebc37c8432c | /luna_new/luna_new/Project/Selene/Source/Class/Render/2D/CPrimitive2DBaseMgr.cpp | a580d37c27097f642bb7f224d5dfa56874511b90 | [] | no_license | gondur/Magical-Broom-Extreme | 2f5996975a5eb9ed70c38d7f6a36b33db302ecf5 | c33f9606b267fd2ba52903d366091b080e5c5802 | refs/heads/master | 2021-01-19T20:41:24.779704 | 2019-07-02T21:50:13 | 2019-07-02T21:50:13 | 88,536,102 | 1 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,451 | cpp |
//-----------------------------------------------------------------------------------
// INCLUDE
//-----------------------------------------------------------------------------------
#include "Base.h" // PCH
#include "Render/2D/CPrimitive2DBaseMgr.h"
#include "Render/2D/CPrimitive2DBase.h"
//-----------------------------------------------------------------------------------
// NAMESPACE
//-----------------------------------------------------------------------------------
using namespace Selene;
//-----------------------------------------------------------------------------------
/**
@brief コンストラクタ
*/
//-----------------------------------------------------------------------------------
CPrimitive2DBaseMgr::CPrimitive2DBaseMgr( CDevice *pDevice ) : CDeviceObjectMgr( pDevice )
{
}
//-----------------------------------------------------------------------------------
/**
@brief デストラクタ
*/
//-----------------------------------------------------------------------------------
CPrimitive2DBaseMgr::~CPrimitive2DBaseMgr()
{
}
//-----------------------------------------------------------------------------------
/**
*/
//-----------------------------------------------------------------------------------
void CPrimitive2DBaseMgr::SetScissoring( RECT *pRect )
{
CBaseObject *pObj = GetTop();
while ( pObj != NULL )
{
((CPrimitive2DBase*)pObj)->SetScissoring( pRect );
pObj = GetNext( pObj );
}
}
| [
"hhhh@hotmail.com"
] | hhhh@hotmail.com |
7a60c8ed72a6ef4b38bd7ae46e2497f054ac986a | 94871047ac9f952530d12b5ca8d8c7cffffed17e | /sdk/pfc/string.h | e108bf728c2c42076b1ed8eb0b3df86577249b26 | [] | no_license | GreyTeardrop/foo_playback_log | b32510d288a9372c4fb097fd585d3f97109eccc4 | 1612f3a739d5188dd23720b8ca1cb309f2e099ee | refs/heads/master | 2020-12-24T15:31:37.703392 | 2008-12-04T09:48:40 | 2008-12-04T09:48:40 | 278,026 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,722 | h | #ifndef _PFC_STRING_H_
#define _PFC_STRING_H_
namespace pfc {
class NOVTABLE string_receiver {
public:
virtual void add_string(const char * p_string,t_size p_string_size = infinite) = 0;
void add_char(t_uint32 c);//adds unicode char to the string
void add_byte(char c) {add_string(&c,1);}
void add_chars(t_uint32 p_char,t_size p_count) {for(;p_count;p_count--) add_char(p_char);}
protected:
string_receiver() {}
~string_receiver() {}
};
t_size scan_filename(const char * ptr);
bool is_path_separator(unsigned c);
bool is_path_bad_char(unsigned c);
bool is_valid_utf8(const char * param,t_size max = infinite);
bool is_lower_ascii(const char * param);
bool is_multiline(const char * p_string,t_size p_len = infinite);
bool has_path_bad_chars(const char * param);
void recover_invalid_utf8(const char * src,char * out,unsigned replace);//out must be enough to hold strlen(char) + 1, or appropiately bigger if replace needs multiple chars
void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace = '?');//out should be at least strlen(src)+1 long
inline char ascii_tolower(char c) {if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; return c;}
inline char ascii_toupper(char c) {if (c >= 'a' && c <= 'z') c += 'A' - 'a'; return c;}
t_size string_find_first(const char * p_string,char p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last(const char * p_string,char p_tofind,t_size p_start = ~0); //returns infinite if not found
t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start = ~0); //returns infinite if not found
t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = ~0); //returns infinite if not found
t_size string_find_first_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = 0); //returns infinite if not found
t_size string_find_last_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = ~0); //returns infinite if not found
template<typename t_char>
t_size strlen_max_t(const t_char * ptr,t_size max) {
if (ptr == NULL) return 0;
t_size n = 0;
while(n<max && ptr[n] != 0) n++;
return n;
}
inline t_size strlen_max(const char * ptr,t_size max) {return strlen_max_t(ptr,max);}
inline t_size wcslen_max(const wchar_t * ptr,t_size max) {return strlen_max_t(ptr,max);}
#ifdef _WINDOWS
inline t_size tcslen_max(const TCHAR * ptr,t_size max) {return strlen_max_t(ptr,max);}
#endif
bool string_is_numeric(const char * p_string,t_size p_length = infinite);
inline bool char_is_numeric(char p_char) {return p_char >= '0' && p_char <= '9';}
inline bool char_is_ascii_alpha_upper(char p_char) {return p_char >= 'A' && p_char <= 'Z';}
inline bool char_is_ascii_alpha_lower(char p_char) {return p_char >= 'a' && p_char <= 'z';}
inline bool char_is_ascii_alpha(char p_char) {return char_is_ascii_alpha_lower(p_char) || char_is_ascii_alpha_upper(p_char);}
inline bool char_is_ascii_alphanumeric(char p_char) {return char_is_ascii_alpha(p_char) || char_is_numeric(p_char);}
unsigned atoui_ex(const char * ptr,t_size max);
t_int64 atoi64_ex(const char * ptr,t_size max);
t_uint64 atoui64_ex(const char * ptr,t_size max);
t_size strlen_utf8(const char * s,t_size num = ~0);//returns number of characters in utf8 string; num - no. of bytes (optional)
t_size utf8_char_len(const char * s,t_size max = ~0);//returns size of utf8 character pointed by s, in bytes, 0 on error
t_size utf8_char_len_from_header(char c);
t_size utf8_chars_to_bytes(const char * string,t_size count);
t_size strcpy_utf8_truncate(const char * src,char * out,t_size maxbytes);
t_size utf8_decode_char(const char * src,unsigned * out,t_size src_bytes = ~0);//returns length in bytes
t_size utf8_encode_char(unsigned c,char * out);//returns used length in bytes, max 6
t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = ~0);
t_size utf16_encode_char(unsigned c,wchar_t * out);
t_size strstr_ex(const char * p_string,t_size p_string_len,const char * p_substring,t_size p_substring_len);
int strcmp_partial(const char * p_string,const char * p_substring);
int strcmp_partial_ex(const char * p_string,t_size p_string_length,const char * p_substring,t_size p_substring_length);
t_size skip_utf8_chars(const char * ptr,t_size count);
char * strdup_n(const char * src,t_size len);
int stricmp_ascii(const char * s1,const char * s2);
int stricmp_ascii_ex(const char * s1,t_size len1,const char * s2,t_size len2);
int strcmp_ex(const char* p1,t_size n1,const char* p2,t_size n2);
unsigned utf8_get_char(const char * src);
inline bool utf8_advance(const char * & var) {
t_size delta = utf8_char_len(var);
var += delta;
return delta>0;
}
inline bool utf8_advance(char * & var) {
t_size delta = utf8_char_len(var);
var += delta;
return delta>0;
}
inline const char * utf8_char_next(const char * src) {return src + utf8_char_len(src);}
inline char * utf8_char_next(char * src) {return src + utf8_char_len(src);}
class NOVTABLE string_base : public pfc::string_receiver {
public:
virtual const char * get_ptr() const = 0;
virtual void add_string(const char * p_string,t_size p_length = ~0) = 0;//same as string_receiver method
virtual void set_string(const char * p_string,t_size p_length = ~0) {reset();add_string(p_string,p_length);}
virtual void truncate(t_size len)=0;
virtual t_size get_length() const {return strlen(get_ptr());}
virtual char * lock_buffer(t_size p_requested_length) = 0;
virtual void unlock_buffer() = 0;
//! For compatibility with old conventions.
inline t_size length() const {return get_length();}
inline void reset() {truncate(0);}
inline bool is_empty() const {return *get_ptr()==0;}
void skip_trailing_char(unsigned c = ' ');
bool is_valid_utf8() {return pfc::is_valid_utf8(get_ptr());}
void convert_to_lower_ascii(const char * src,char replace = '?');
inline const string_base & operator= (const char * src) {set_string(src);return *this;}
inline const string_base & operator+= (const char * src) {add_string(src);return *this;}
inline const string_base & operator= (const string_base & src) {set_string(src);return *this;}
inline const string_base & operator+= (const string_base & src) {add_string(src);return *this;}
inline operator const char * () const {return get_ptr();}
t_size scan_filename() const {return pfc::scan_filename(get_ptr());}
t_size find_first(char p_char,t_size p_start = 0) {return pfc::string_find_first(get_ptr(),p_char,p_start);}
t_size find_last(char p_char,t_size p_start = ~0) {return pfc::string_find_last(get_ptr(),p_char,p_start);}
t_size find_first(const char * p_string,t_size p_start = 0) {return pfc::string_find_first(get_ptr(),p_string,p_start);}
t_size find_last(const char * p_string,t_size p_start = ~0) {return pfc::string_find_last(get_ptr(),p_string,p_start);}
void fix_dir_separator(char p_char);
protected:
string_base() {}
~string_base() {}
};
template<t_size max_length>
class string_fixed_t : public pfc::string_base {
public:
inline string_fixed_t() {init();}
inline string_fixed_t(const string_fixed_t<max_length> & p_source) {init(); *this = p_source;}
inline string_fixed_t(const char * p_source) {init(); set_string(p_source);}
inline const string_fixed_t<max_length> & operator=(const string_fixed_t<max_length> & p_source) {set_string(p_source);return *this;}
inline const string_fixed_t<max_length> & operator=(const char * p_source) {set_string(p_source);return *this;}
char * lock_buffer(t_size p_requested_length) {
if (p_requested_length >= max_length) return NULL;
memset(m_data,0,sizeof(m_data));
return m_data;
}
void unlock_buffer() {
m_length = strlen(m_data);
}
inline operator const char * () const {return m_data;}
const char * get_ptr() const {return m_data;}
void add_string(const char * ptr,t_size len) {
len = strlen_max(ptr,len);
if (m_length + len < m_length || m_length + len > max_length) throw pfc::exception_overflow();
for(t_size n=0;n<len;n++) {
m_data[m_length++] = ptr[n];
}
m_data[m_length] = 0;
}
void truncate(t_size len) {
if (len > max_length) len = max_length;
if (m_length > len) {
m_length = len;
m_data[len] = 0;
}
}
t_size get_length() const {return m_length;}
private:
inline void init() {
pfc::static_assert<(max_length>1)>();
m_length = 0; m_data[0] = 0;
}
t_size m_length;
char m_data[max_length+1];
};
template<template<typename> class t_alloc>
class string8_t : public pfc::string_base {
private:
typedef string8_t<t_alloc> t_self;
protected:
pfc::array_t<char,t_alloc> m_data;
t_size used;
inline void makespace(t_size s)
{
t_size old_size = m_data.get_size();
if (old_size < s)
m_data.set_size(s+16);
else if (old_size > s + 32)
m_data.set_size(s);
}
inline const char * __get_ptr() const throw() {return used > 0 ? m_data.get_ptr() : "";}
public:
inline const t_self & operator= (const char * src) {set_string(src);return *this;}
inline const t_self & operator+= (const char * src) {add_string(src);return *this;}
inline const t_self & operator= (const string_base & src) {set_string(src);return *this;}
inline const t_self & operator+= (const string_base & src) {add_string(src);return *this;}
inline const t_self & operator= (const t_self & src) {set_string(src);return *this;}
inline const t_self & operator+= (const t_self & src) {add_string(src);return *this;}
inline operator const char * () const throw() {return __get_ptr();}
string8_t() : used(0) {}
string8_t(const char * p_string) : used(0) {set_string(p_string);}
string8_t(const char * p_string,t_size p_length) : used(0) {set_string(p_string,p_length);}
string8_t(const t_self & p_string) : used(0) {set_string(p_string);}
string8_t(const string_base & p_string) : used(0) {set_string(p_string);}
void prealloc(t_size p_size) {m_data.prealloc(p_size+1);}
const char * get_ptr() const throw() {return __get_ptr();}
void add_string(const char * p_string,t_size p_length = ~0);
void set_string(const char * p_string,t_size p_length = ~0);
void truncate(t_size len)
{
if (used>len) {used=len;m_data[len]=0;makespace(used+1);}
}
t_size get_length() const throw() {return used;}
void set_char(unsigned offset,char c);
t_size replace_nontext_chars(char p_replace = '_');
t_size replace_char(unsigned c1,unsigned c2,t_size start = 0);
t_size replace_byte(char c1,char c2,t_size start = 0);
void fix_filename_chars(char def = '_',char leave=0);//replace "bad" characters, leave can be used to keep eg. path separators
void remove_chars(t_size first,t_size count); //slow
void insert_chars(t_size first,const char * src, t_size count);//slow
void insert_chars(t_size first,const char * src);
bool truncate_eol(t_size start = 0);
bool fix_eol(const char * append = " (...)",t_size start = 0);
bool limit_length(t_size length_in_chars,const char * append = " (...)");
//for string_buffer class
char * lock_buffer(t_size n)
{
makespace(n+1);
pfc::memset_t(m_data,(char)0);
return m_data.get_ptr();;
}
void unlock_buffer() {
used=strlen(m_data.get_ptr());
makespace(used+1);
}
void force_reset() {used=0;m_data.force_reset();}
inline static void g_swap(t_self & p_item1,t_self & p_item2) {
pfc::swap_t(p_item1.m_data,p_item2.m_data);
pfc::swap_t(p_item1.used,p_item2.used);
}
};
typedef string8_t<pfc::alloc_standard> string8;
typedef string8_t<pfc::alloc_fast> string8_fast;
typedef string8_t<pfc::alloc_fast_aggressive> string8_fast_aggressive;
//for backwards compatibility
typedef string8_t<pfc::alloc_fast_aggressive> string8_fastalloc;
template<template<typename> class t_alloc> class traits_t<string8_t<t_alloc> > : public pfc::combine_traits<pfc::traits_vtable,pfc::traits_t<pfc::array_t<char,t_alloc> > > {
public:
enum {
needs_constructor = true,
};
};
}
#include "string8_impl.h"
#define PFC_DEPRECATE_PRINTF PFC_DEPRECATE("Use string8/string_fixed_t with operator<< overloads instead.")
namespace pfc {
class string_buffer {
private:
string_base & m_owner;
char * m_buffer;
public:
explicit string_buffer(string_base & p_string,t_size p_requeted_length) : m_owner(p_string) {m_buffer = m_owner.lock_buffer(p_requeted_length);}
~string_buffer() {m_owner.unlock_buffer();}
operator char* () {return m_buffer;}
};
class PFC_DEPRECATE_PRINTF string_printf : public string8_fastalloc {
public:
static void g_run(string_base & out,const char * fmt,va_list list);
void run(const char * fmt,va_list list);
explicit string_printf(const char * fmt,...);
};
class PFC_DEPRECATE_PRINTF string_printf_va : public string8_fastalloc {
public:
string_printf_va(const char * fmt,va_list list);
};
class format_time {
public:
format_time(t_uint64 p_seconds);
const char * get_ptr() const {return m_buffer;}
operator const char * () const {return m_buffer;}
protected:
string_fixed_t<127> m_buffer;
};
class format_time_ex {
public:
format_time_ex(double p_seconds,unsigned p_extra = 3);
const char * get_ptr() const {return m_buffer;}
operator const char * () const {return m_buffer;}
private:
string_fixed_t<127> m_buffer;
};
class string_filename : public string8 {
public:
explicit string_filename(const char * fn);
};
class string_filename_ext : public string8 {
public:
explicit string_filename_ext(const char * fn);
};
class string_extension
{
char buffer[32];
public:
inline const char * get_ptr() const {return buffer;}
inline t_size length() const {return strlen(buffer);}
inline operator const char * () const {return buffer;}
explicit string_extension(const char * src);
};
class string_replace_extension
{
public:
string_replace_extension(const char * p_path,const char * p_ext);
inline operator const char*() const {return m_data;}
private:
string8 m_data;
};
class string_directory
{
public:
string_directory(const char * p_path);
inline operator const char*() const {return m_data;}
private:
string8 m_data;
};
void float_to_string(char * out,t_size out_max,double val,unsigned precision,bool force_sign = false);//doesnt add E+X etc, has internal range limits, useful for storing float numbers as strings without having to bother with international coma/dot settings BS
double string_to_float(const char * src,t_size len = infinite);
template<>
inline void swap_t(string8 & p_item1,string8 & p_item2)
{
string8::g_swap(p_item1,p_item2);
}
class format_float
{
public:
format_float(double p_val,unsigned p_width,unsigned p_prec);
format_float(const format_float & p_source) {*this = p_source;}
inline const char * get_ptr() const {return m_buffer.get_ptr();}
inline operator const char*() const {return m_buffer.get_ptr();}
private:
string8 m_buffer;
};
class format_int
{
public:
format_int(t_int64 p_val,unsigned p_width = 0,unsigned p_base = 10);
format_int(const format_int & p_source) {*this = p_source;}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
char m_buffer[64];
};
class format_uint
{
public:
format_uint(t_uint64 p_val,unsigned p_width = 0,unsigned p_base = 10);
format_uint(const format_uint & p_source) {*this = p_source;}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
char m_buffer[64];
};
class format_hex
{
public:
format_hex(t_uint64 p_val,unsigned p_width = 0);
format_hex(const format_hex & p_source) {*this = p_source;}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
char m_buffer[17];
};
class format_hex_lowercase
{
public:
format_hex_lowercase(t_uint64 p_val,unsigned p_width = 0);
format_hex_lowercase(const format_hex_lowercase & p_source) {*this = p_source;}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
char m_buffer[17];
};
typedef string8_fastalloc string_formatter;
class format_hexdump
{
public:
format_hexdump(const void * p_buffer,t_size p_bytes,const char * p_spacing = " ");
inline const char * get_ptr() const {return m_formatter;}
inline operator const char * () const {return m_formatter;}
private:
string_formatter m_formatter;
};
class format_hexdump_lowercase
{
public:
format_hexdump_lowercase(const void * p_buffer,t_size p_bytes,const char * p_spacing = " ");
inline const char * get_ptr() const {return m_formatter;}
inline operator const char * () const {return m_formatter;}
private:
string_formatter m_formatter;
};
class format_fixedpoint
{
public:
format_fixedpoint(t_int64 p_val,unsigned p_point);
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
string_formatter m_buffer;
};
class format_char {
public:
format_char(char p_char) {m_buffer[0] = p_char; m_buffer[1] = 0;}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
char m_buffer[2];
};
template<typename t_stringbuffer = pfc::string8_fastalloc>
class format_pad_left {
public:
format_pad_left(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = infinite) {
t_size source_len = 0, source_walk = 0;
while(source_walk < p_string_length && source_len < p_chars) {
unsigned dummy;
t_size delta = pfc::utf8_decode_char(p_string + source_walk, &dummy, p_string_length - source_walk);
if (delta == 0) break;
source_len++;
source_walk += delta;
}
m_buffer.add_string(p_string,source_walk);
m_buffer.add_chars(p_padding,p_chars - source_len);
}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
t_stringbuffer m_buffer;
};
template<typename t_stringbuffer = pfc::string8_fastalloc>
class format_pad_right {
public:
format_pad_right(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = infinite) {
t_size source_len = 0, source_walk = 0;
while(source_walk < p_string_length && source_len < p_chars) {
unsigned dummy;
t_size delta = pfc::utf8_decode_char(p_string + source_walk, &dummy, p_string_length - source_walk);
if (delta == 0) break;
source_len++;
source_walk += delta;
}
m_buffer.add_chars(p_padding,p_chars - source_len);
m_buffer.add_string(p_string,source_walk);
}
inline const char * get_ptr() const {return m_buffer;}
inline operator const char*() const {return m_buffer;}
private:
t_stringbuffer m_buffer;
};
}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const char * p_source) {p_fmt.add_string(p_source); return p_fmt;}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_int32 p_val) {return p_fmt << pfc::format_int(p_val);}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_uint32 p_val) {return p_fmt << pfc::format_uint(p_val);}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_int64 p_val) {return p_fmt << pfc::format_int(p_val);}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_uint64 p_val) {return p_fmt << pfc::format_uint(p_val);}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,double p_val) {return p_fmt << pfc::format_float(p_val,0,7);}
inline pfc::string_base & operator<<(pfc::string_base & p_fmt,std::exception const & p_exception) {return p_fmt << p_exception.what();}
namespace pfc {
template<typename t_char>
class string_simple_t {
private:
typedef string_simple_t<t_char> t_self;
public:
t_size length(t_size p_limit = infinite) const {return pfc::strlen_t(get_ptr(),infinite);}
bool is_empty() const {return length(1) == 0;}
void set_string(const t_char * p_source,t_size p_length = infinite) {
t_size length = pfc::strlen_t(p_source,p_length);
m_buffer.set_size(length + 1);
pfc::memcpy_t(m_buffer.get_ptr(),p_source,length);
m_buffer[length] = 0;
}
string_simple_t() {}
string_simple_t(const t_char * p_source,t_size p_length = infinite) {set_string(p_source,p_length);}
const t_self & operator=(const t_char * p_source) {set_string(p_source);return *this;}
operator const t_char* () const {return get_ptr();}
const t_char * get_ptr() const {return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : pfc::empty_string_t<t_char>();}
private:
pfc::array_t<t_char> m_buffer;
};
typedef string_simple_t<char> string_simple;
template<typename t_char> class traits_t<string_simple_t<t_char> > : public traits_t<array_t<t_char> > {};
}
namespace pfc {
//for tree/map classes
class comparator_strcmp {
public:
inline static int compare(const char * p_item1,const char * p_item2) {return strcmp(p_item1,p_item2);}
};
class comparator_stricmp_ascii {
public:
inline static int compare(const char * p_item1,const char * p_item2) {return pfc::stricmp_ascii(p_item1,p_item2);}
};
}
#endif //_PFC_STRING_H_ | [
"mykola.rybak@gmail.com"
] | mykola.rybak@gmail.com |
ee78f1665bcefb172af1923a3b9008a027602140 | 609dfe9425ae272f97b89f383d8ecc1281e743f6 | /aulas/aula33_mapas/mapa_nome.cpp | e1cc2a0913326ab3ceb48db24e95a0955ddcaf56 | [
"Apache-2.0"
] | permissive | senapk/fup_2014_2 | 956ae522d0c05c1c21ebb7c7aac0671d472f1cb4 | 5fc2986724f2e5fb912524b6208744b7295c6347 | refs/heads/master | 2021-01-23T09:28:40.138103 | 2018-06-27T18:51:20 | 2018-06-27T18:51:20 | 22,660,268 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | cpp | #include <iostream>
#include <vector>
//#include <algorithm> //find
#include <map>
using namespace std;
struct Pessoa{
int cpf;
string nome;
};
int main(){
//vector<Pessoa> base;
map<string, Pessoa> mapa;
//base.push_back(a);
mapa["zuleica_maria"] = Pessoa{1, "zuleica_maria"};
mapa["fernando"] = Pessoa{2, "fernando"};
mapa["fulano"] = Pessoa{5, "fulano"};
cout << "Digite o nome" << endl;
string nome;
cin >> nome;
auto it = mapa.find(nome);
if(it == mapa.end())
cout << "nao encontrei\n";
else
cout << "encontrei " << it->first << " " << it->second.cpf << endl;
cout << "cpf fulano" << mapa["fulano"].cpf << endl;
return 0;
} | [
"sena.ufc@gmail.com"
] | sena.ufc@gmail.com |
0dbb160dba308f9e1dc403246dc173c231d467a7 | 93f1c62de3f33773a0e5f5a579103f521c3cb1ce | /kvs/char_storage_kvs.h | 16875a6b0ab9c3e33b3b6157eea3a03fdc5f5626 | [] | no_license | liva/simple_kvs | 25a15e6a1cfafed654d61ff03e2d99e90e437c2b | ea8582236d64c3f267b65d64bb6f21b135a5f31e | refs/heads/master | 2023-08-21T08:04:19.208192 | 2021-11-02T11:54:30 | 2021-11-02T11:54:30 | 397,344,916 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,128 | h | #pragma once
#include "kvs_interface.h"
#include "kvs/simple_kvs.h"
#include "char_storage/log.h"
#include "char_storage/interface.h"
#include "utils/multipleslice_container.h"
namespace HayaguiKvs
{
class CharStorageKvs final : public Kvs
{
public:
CharStorageKvs() = delete;
CharStorageKvs(AppendOnlyCharStorageInterface &char_storage, Kvs &cache_kvs)
: char_storage_(char_storage),
log_(char_storage_),
cache_kvs_(cache_kvs)
{
if (log_.Open().IsError())
{
abort();
}
RecoverFromStorage();
}
CharStorageKvs(const CharStorageKvs &obj) = delete;
CharStorageKvs &operator=(const CharStorageKvs &obj) = delete;
virtual ~CharStorageKvs()
{
}
virtual Status Get(ReadOptions options, const ValidSlice &key, SliceContainer &container) override
{
return cache_kvs_.Get(options, key, container);
}
virtual Status Put(WriteOptions options, const ValidSlice &key, const ValidSlice &value) override
{
const ValidSlice *slices[3];
MultipleValidSliceContainer container(slices, 3);
Signature::PutSignature signature;
container.Set(&signature.GetSlice());
container.Set(&key);
container.Set(&value);
if (log_.AppendEntries(container).IsError())
{
return Status::CreateErrorStatus();
}
return cache_kvs_.Put(options, key, value);
}
virtual Status Delete(WriteOptions options, const ValidSlice &key) override
{
const ValidSlice *slices[2];
MultipleValidSliceContainer container(slices, 2);
Signature::DeleteSignature signature;
container.Set(&signature.GetSlice());
container.Set(&key);
if (log_.AppendEntries(container).IsError())
{
return Status::CreateErrorStatus();
}
return cache_kvs_.Delete(options, key);
}
virtual Optional<KvsEntryIterator> GetFirstIterator() override
{
Optional<KvsEntryIterator> cache_iter = cache_kvs_.GetFirstIterator();
if (!cache_iter.isPresent())
{
return Optional<KvsEntryIterator>::CreateInvalidObj();
}
SliceContainer key_container;
Status s1 = cache_iter.get().GetKey(key_container);
assert(s1.IsOk());
return Optional<KvsEntryIterator>::CreateValidObj(GetIterator(key_container.CreateConstSlice()));
}
virtual KvsEntryIterator GetIterator(const ValidSlice &key) override
{
GenericKvsEntryIteratorBase *base = MemAllocator::alloc<GenericKvsEntryIteratorBase>();
new (base) GenericKvsEntryIteratorBase(*this, key);
return KvsEntryIterator(base);
}
virtual Status FindNextKey(const ValidSlice &key, SliceContainer &container) override
{
return cache_kvs_.FindNextKey(key, container);
}
private:
void RecoverFromStorage()
{
SequentialReadCharStorageOverRandomReadCharStorage seqread_char_storage(char_storage_);
LogReader log(seqread_char_storage);
if (log.Open().IsError())
{
return;
}
while (true)
{
uint8_t signature;
if (Signature::RetrieveSignature(log, signature).IsError())
{
return;
}
if (signature == Signature::kSignaturePut)
{
SliceContainer key_container, value_container;
if (RetrievePutItem(log, key_container, value_container).IsError())
{
abort();
}
if (cache_kvs_.Put(WriteOptions(), key_container.CreateConstSlice(), value_container.CreateConstSlice()).IsError())
{
abort();
}
}
else if (signature == Signature::kSignatureDelete)
{
SliceContainer key_container;
if (RetrieveDeletedItem(log, key_container).IsError())
{
abort();
}
if (cache_kvs_.Delete(WriteOptions(), key_container.CreateConstSlice()).IsError())
{
abort();
}
}
else
{
abort();
}
}
}
Status RetrievePutItem(LogReader &log, SliceContainer &key_container, SliceContainer &value_container)
{
if (log.RetrieveNextEntry(key_container).IsError())
{
return Status::CreateErrorStatus();
}
return log.RetrieveNextEntry(value_container);
}
Status RetrieveDeletedItem(LogReader &log, SliceContainer &key_container)
{
return log.RetrieveNextEntry(key_container);
}
AppendOnlyCharStorageInterface &char_storage_;
LogAppender log_;
Kvs &cache_kvs_;
class Signature
{
public:
static Status RetrieveSignature(LogReader &log, uint8_t &signature)
{
SliceContainer signature_container;
if (log.RetrieveNextEntry(signature_container).IsError())
{
return Status::CreateErrorStatus();
}
int len;
if (signature_container.GetLen(len).IsError())
{
return Status::CreateErrorStatus();
}
if (len != 1)
{
return Status::CreateErrorStatus();
}
return signature_container.CopyToBuffer((char *)&signature);
}
class DeleteSignature
{
public:
DeleteSignature() : slice_(buf_, 1)
{
buf_[0] = kSignatureDelete;
}
ValidSlice &GetSlice()
{
return slice_;
}
private:
char buf_[1];
BufferPtrSlice slice_;
};
class PutSignature
{
public:
PutSignature() : slice_(buf_, 1)
{
buf_[0] = kSignaturePut;
}
ValidSlice &GetSlice()
{
return slice_;
}
private:
char buf_[1];
BufferPtrSlice slice_;
};
static const uint8_t kSignaturePut = 0;
static const uint8_t kSignatureDelete = 1;
};
};
} | [
"sap.pcmail@gmail.com"
] | sap.pcmail@gmail.com |
6a5042e8d444289db8b9bafdfc05dcbd28c96346 | 4d8f7b7fe6e4b8f8bc772339bd187960d3e01e2b | /quizzes/review3/a/analysis.h | 6e3988a817b6fa787027e68a179d661454534700 | [] | no_license | ajalsingh/PFMS-A2020 | 1dd2c18691ac48867d07d062114b49b029c7004b | e52a5e1677b6d0c5b309dbeec8e125c0ac19d857 | refs/heads/master | 2023-05-29T04:08:48.327745 | 2021-06-08T08:04:16 | 2021-06-08T08:04:16 | 275,065,349 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 426 | h | #ifndef ANALYSIS_H
#define ANALYSIS_H
#include "analysisinterface.h"
class Analysis : public AnalysisInterface
{
public:
Analysis();
void setShapes(std::vector<Shape*> shapes);
void setLine(Line line);
//Returns a container of bools that indicates if the correspoing shape intersects the line
std::vector<bool> intersectsLine();
private:
std::vector<Shape*> shapes_;
Line line_;
};
#endif // ANALYSIS_H
| [
"ajal.singh@multifin.com.au"
] | ajal.singh@multifin.com.au |
9311589812ff9ad70b626296b675a28cc1c64fd1 | 1a60c841c4cf4159d9badacbe3e3c05dd4340d73 | /week_2/2920_tjdwn9410.cpp | e5bf8d3f536c8d24604bd8efa25422d89d7079d5 | [] | no_license | sungjunyoung/algorithm-study | e5d38f0569ec7b639ebd905f0ef79398862696d2 | 5fb4bc9fa9f96a0d17a097ed641de01f378ead27 | refs/heads/master | 2020-12-03T03:46:05.244078 | 2017-10-14T08:01:25 | 2017-10-14T08:04:59 | 95,769,994 | 9 | 12 | null | 2017-10-14T08:05:00 | 2017-06-29T11:16:04 | C++ | UTF-8 | C++ | false | false | 595 | cpp | //
// Created by MAC on 2017. 7. 2..
//
#include <iostream>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
int main() {
int input;
int check;
cin >> input;
check = (input == 8) ? 9 : 0;
for (int i = 2; i <= 8; i++) {
cin >> input;
if (input != abs(i - check))
check = -1;
}
switch (check) {
case 0 :
cout << "ascending";
break;
case 9 :
cout << "descending";
break;
default:
cout << "mixed";
break;
}
return 0;
} | [
"abc3176@nate.com"
] | abc3176@nate.com |
2ebf428057308ed50b0a84af07b5b69c9693924e | d2bdde8fdf7a16dd49d2bf75f927bcb688e58535 | /customnibg.cpp | 9fda93a777483468db6e91c90bf1548f5619fdf2 | [] | no_license | markkun/Monitor | 24808f9a91e9d31b3560715fc36f30f89570c481 | 53a7ad1b8644788894fc5ac3aa170fcac8900dc2 | refs/heads/master | 2021-09-18T10:44:50.004525 | 2018-07-13T09:56:57 | 2018-07-13T09:56:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,641 | cpp | #include "customnibg.h"
CustomNibg::CustomNibg(QWidget *parent) : QWidget(parent)
{
this->setFixedSize(150,760*1/7);
QPalette palette1 = this->palette(); // 获取调色板
QPalette palette2 = this->palette(); // 获取调色板
palette1.setColor(QPalette::WindowText, QColor("#FEFEFE")); // 亮白
palette2.setColor(QPalette::WindowText, QColor("#939395")); // 暗白
QFont font1("Microsoft YaHei", 14, QFont::Medium);
QFont font2("Microsoft YaHei", 28, QFont::Medium);
QFont font3("Microsoft YaHei", 12, QFont::Medium);
label_ul = new QLabel(this);
label_ru = new QLabel(this);
label_content1 = new QLabel(this);
label_lr = new QLabel(this);
label_ul->setText("NIBG");
label_ru->setText("mg/dL");
label_content1->setText("97");
label_lr->setText("13:01");
label_ul->setPalette(palette1);
label_ru->setPalette(palette2);
label_content1->setPalette(palette1);
label_lr->setPalette(palette2);
label_ul->setFont(font1);
label_ru->setFont(font3);
label_content1->setFont(font2);
label_lr->setFont(font3);
label_ul->move(10,10);
label_ru->move(width()-55,10);
label_content1->move(55,40);
label_lr->move(width()-50,height()-25);
}
void CustomNibg::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
QPen pen;
pen.setWidth(1);
pen.setColor(QColor(100, 100, 100 , 255));
painter.setPen(pen);
QRect rect = this->rect();
rect.setWidth(rect.width());
rect.setHeight(rect.height());
painter.drawRoundedRect(rect, 6, 6);
}
| [
"1340016728@qq.com"
] | 1340016728@qq.com |
416e36dfd9ef14039dcbed5e06a72b2255af6b9c | 0f980b15d8b3f22767ca5294751e8d875f19ec0c | /ATMega328 2018-02-25 nrf24L01/src/nrf24.c | fd96818b476967609ddc823e1d6da075820a4861 | [
"MIT"
] | permissive | NahlaHussien/AVR-projects | 825addd6a08563427dff01de4fc6dd30ce57ebae | 68593c0e55304aa7fef8c00d36860f8b867c8c98 | refs/heads/master | 2020-08-12T03:00:29.886202 | 2019-09-26T12:42:15 | 2019-09-26T12:42:15 | 214,675,803 | 1 | 1 | MIT | 2019-10-12T16:06:21 | 2019-10-12T16:06:21 | null | UTF-8 | C++ | false | false | 8,799 | c | /*
* ----------------------------------------------------------------------------
* “THE COFFEEWARE LICENSE” (Revision 1):
* <ihsan@kehribar.me> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a coffee in return.
* -----------------------------------------------------------------------------
* This library is based on this library:
* https://github.com/aaronds/arduino-nrf24l01
* Which is based on this library:
* http://www.tinkerer.eu/AVRLib/nRF24L01
* -----------------------------------------------------------------------------
*/
#include "nrf24.h"
uint8_t payload_len;
/* init the hardware pins */
void nrf24_init()
{
nrf24_setupPins();
nrf24_ce_digitalWrite(LOW);
nrf24_csn_digitalWrite(HIGH);
}
/* configure the module */
void nrf24_config(uint8_t channel, uint8_t pay_length)
{
/* Use static payload length ... */
payload_len = pay_length;
// Set RF channel
nrf24_configRegister(RF_CH,channel);
// Set length of incoming payload
nrf24_configRegister(RX_PW_P0, 0x00); // Auto-ACK pipe ...
nrf24_configRegister(RX_PW_P1, payload_len); // Data payload pipe
nrf24_configRegister(RX_PW_P2, 0x00); // Pipe not used
nrf24_configRegister(RX_PW_P3, 0x00); // Pipe not used
nrf24_configRegister(RX_PW_P4, 0x00); // Pipe not used
nrf24_configRegister(RX_PW_P5, 0x00); // Pipe not used
// 1 Mbps, TX gain: 0dbm
nrf24_configRegister(RF_SETUP, (0<<RF_DR)|((0x03)<<RF_PWR));
// CRC enable, 1 byte CRC length
nrf24_configRegister(CONFIG,nrf24_CONFIG);
// Auto Acknowledgment
nrf24_configRegister(EN_AA,(1<<ENAA_P0)|(1<<ENAA_P1)|(0<<ENAA_P2)|(0<<ENAA_P3)|(0<<ENAA_P4)|(0<<ENAA_P5));
// Enable RX addresses
nrf24_configRegister(EN_RXADDR,(1<<ERX_P0)|(1<<ERX_P1)|(0<<ERX_P2)|(0<<ERX_P3)|(0<<ERX_P4)|(0<<ERX_P5));
// Auto retransmit delay: 1000 us and Up to 15 retransmit trials
nrf24_configRegister(SETUP_RETR,(0x04<<ARD)|(0x0F<<ARC));
// Dynamic length configurations: No dynamic length
nrf24_configRegister(DYNPD,(0<<DPL_P0)|(0<<DPL_P1)|(0<<DPL_P2)|(0<<DPL_P3)|(0<<DPL_P4)|(0<<DPL_P5));
// Start listening
nrf24_powerUpRx();
}
/* Set the RX address */
void nrf24_rx_address(uint8_t * adr)
{
nrf24_ce_digitalWrite(LOW);
nrf24_writeRegister(RX_ADDR_P1,adr,nrf24_ADDR_LEN);
nrf24_ce_digitalWrite(HIGH);
}
/* Returns the payload length */
uint8_t nrf24_payload_length()
{
return payload_len;
}
/* Set the TX address */
void nrf24_tx_address(uint8_t* adr)
{
/* RX_ADDR_P0 must be set to the sending addr for auto ack to work. */
nrf24_writeRegister(RX_ADDR_P0,adr,nrf24_ADDR_LEN);
nrf24_writeRegister(TX_ADDR,adr,nrf24_ADDR_LEN);
}
/* Checks if data is available for reading */
/* Returns 1 if data is ready ... */
uint8_t nrf24_dataReady()
{
// See note in getData() function - just checking RX_DR isn't good enough
uint8_t status = nrf24_getStatus();
// We can short circuit on RX_DR, but if it's not set, we still need
// to check the FIFO for any pending packets
if ( status & (1 << RX_DR) )
{
return 1;
}
return !nrf24_rxFifoEmpty();;
}
/* Checks if receive FIFO is empty or not */
uint8_t nrf24_rxFifoEmpty()
{
uint8_t fifoStatus;
nrf24_readRegister(FIFO_STATUS,&fifoStatus,1);
return (fifoStatus & (1 << RX_EMPTY));
}
/* Returns the length of data waiting in the RX fifo */
uint8_t nrf24_payloadLength()
{
uint8_t status;
nrf24_csn_digitalWrite(LOW);
spi_transfer(R_RX_PL_WID);
status = spi_transfer(0x00);
nrf24_csn_digitalWrite(HIGH);
return status;
}
/* Reads payload bytes into data array */
void nrf24_getData(uint8_t* data)
{
/* Pull down chip select */
nrf24_csn_digitalWrite(LOW);
/* Send cmd to read rx payload */
spi_transfer( R_RX_PAYLOAD );
/* Read payload */
nrf24_transferSync(data,data,payload_len);
/* Pull up chip select */
nrf24_csn_digitalWrite(HIGH);
/* Reset status register */
nrf24_configRegister(STATUS,(1<<RX_DR));
}
/* Returns the number of retransmissions occured for the last message */
uint8_t nrf24_retransmissionCount()
{
uint8_t rv;
nrf24_readRegister(OBSERVE_TX,&rv,1);
rv = rv & 0x0F;
return rv;
}
// Sends a data package to the default address. Be sure to send the correct
// amount of bytes as configured as payload on the receiver.
void nrf24_send(uint8_t* value)
{
/* Go to Standby-I first */
nrf24_ce_digitalWrite(LOW);
/* Set to transmitter mode , Power up if needed */
nrf24_powerUpTx();
/* Do we really need to flush TX fifo each time ? */
#if 1
/* Pull down chip select */
nrf24_csn_digitalWrite(LOW);
/* Write cmd to flush transmit FIFO */
spi_transfer(FLUSH_TX);
/* Pull up chip select */
nrf24_csn_digitalWrite(HIGH);
#endif
/* Pull down chip select */
nrf24_csn_digitalWrite(LOW);
/* Write cmd to write payload */
spi_transfer(W_TX_PAYLOAD);
/* Write payload */
nrf24_transmitSync(value,payload_len);
/* Pull up chip select */
nrf24_csn_digitalWrite(HIGH);
/* Start the transmission */
nrf24_ce_digitalWrite(HIGH);
}
uint8_t nrf24_isSending()
{
uint8_t status;
/* read the current status */
status = nrf24_getStatus();
/* if sending successful (TX_DS) or max retries exceded (MAX_RT). */
if((status & ((1 << TX_DS) | (1 << MAX_RT))))
{
return 0; /* false */
}
return 1; /* true */
}
uint8_t nrf24_getStatus()
{
uint8_t rv;
nrf24_csn_digitalWrite(LOW);
rv = spi_transfer(NOP);
nrf24_csn_digitalWrite(HIGH);
return rv;
}
uint8_t nrf24_lastMessageStatus()
{
uint8_t rv;
rv = nrf24_getStatus();
/* Transmission went OK */
if((rv & ((1 << TX_DS))))
{
return NRF24_TRANSMISSON_OK;
}
/* Maximum retransmission count is reached */
/* Last message probably went missing ... */
else if((rv & ((1 << MAX_RT))))
{
return NRF24_MESSAGE_LOST;
}
/* Probably still sending ... */
else
{
return 0xFF;
}
}
void nrf24_powerUpRx()
{
nrf24_csn_digitalWrite(LOW);
spi_transfer(FLUSH_RX);
nrf24_csn_digitalWrite(HIGH);
nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));
nrf24_ce_digitalWrite(LOW);
nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(1<<PRIM_RX)));
nrf24_ce_digitalWrite(HIGH);
}
void nrf24_powerUpTx()
{
nrf24_configRegister(STATUS,(1<<RX_DR)|(1<<TX_DS)|(1<<MAX_RT));
nrf24_configRegister(CONFIG,nrf24_CONFIG|((1<<PWR_UP)|(0<<PRIM_RX)));
}
void nrf24_powerDown()
{
nrf24_ce_digitalWrite(LOW);
nrf24_configRegister(CONFIG,nrf24_CONFIG);
}
/* software spi routine */
uint8_t spi_transfer(uint8_t tx)
{
uint8_t i = 0;
uint8_t rx = 0;
nrf24_sck_digitalWrite(LOW);
for(i=0;i<8;i++)
{
if(tx & (1<<(7-i)))
{
nrf24_mosi_digitalWrite(HIGH);
}
else
{
nrf24_mosi_digitalWrite(LOW);
}
nrf24_sck_digitalWrite(HIGH);
rx = rx << 1;
if(nrf24_miso_digitalRead())
{
rx |= 0x01;
}
nrf24_sck_digitalWrite(LOW);
}
return rx;
}
/* send and receive multiple bytes over SPI */
void nrf24_transferSync(uint8_t* dataout,uint8_t* datain,uint8_t len)
{
uint8_t i;
for(i=0;i<len;i++)
{
datain[i] = spi_transfer(dataout[i]);
}
}
/* send multiple bytes over SPI */
void nrf24_transmitSync(uint8_t* dataout,uint8_t len)
{
uint8_t i;
for(i=0;i<len;i++)
{
spi_transfer(dataout[i]);
}
}
/* Clocks only one byte into the given nrf24 register */
void nrf24_configRegister(uint8_t reg, uint8_t value)
{
nrf24_csn_digitalWrite(LOW);
spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
spi_transfer(value);
nrf24_csn_digitalWrite(HIGH);
}
/* Read single register from nrf24 */
void nrf24_readRegister(uint8_t reg, uint8_t* value, uint8_t len)
{
nrf24_csn_digitalWrite(LOW);
spi_transfer(R_REGISTER | (REGISTER_MASK & reg));
nrf24_transferSync(value,value,len);
nrf24_csn_digitalWrite(HIGH);
}
/* Write to a single register of nrf24 */
void nrf24_writeRegister(uint8_t reg, uint8_t* value, uint8_t len)
{
nrf24_csn_digitalWrite(LOW);
spi_transfer(W_REGISTER | (REGISTER_MASK & reg));
nrf24_transmitSync(value,len);
nrf24_csn_digitalWrite(HIGH);
}
| [
"swharden@gmail.com"
] | swharden@gmail.com |
5d34a0df655c9d5ff0a5d7d16f2c8d5b100f93bd | f2479c4537f8fb96a185341ab8d97cddde74b65d | /Rownania_rozniczkowe_czastkowe/Lab11/1.Przydatne/MO_projekt_C/Projekt C - Visual Studio/stdafx.h | 5e3b255590251e0e3340c6da1d7350129a3e1674 | [] | no_license | baid14/MetodyObliczeniowe | a8eba4e3c7c87cb6c83a5b0b1d17311b112ae1dd | c1592caf3cb101a296d267649b17bc9badd2ec18 | refs/heads/master | 2021-01-20T00:27:28.010073 | 2017-04-23T09:21:48 | 2017-04-23T09:21:48 | 89,130,578 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 212 | h | #pragma once
#include <iostream>
#include <iomanip>
#include <math.h>
#include <Windows.h>
#include <fstream>
#include <sstream>
#include <string>
#include "calerf.h"
#include "Projekt_C.h"
using namespace std; | [
"baid@o2.pl"
] | baid@o2.pl |
24e7331c2bd1247fa6cdd16af0aeae5f7cc24bbb | 501591e4268ad9a5705012cd93d36bac884847b7 | /src/server/scripts/Outland/hellfire_peninsula.cpp | b1c9f6967260b488190f04deb75a974bf56b1bf9 | [] | no_license | CryNet/MythCore | f550396de5f6e20c79b4aa0eb0a78e5fea9d86ed | ffc5fa1c898d25235cec68c76ac94c3279df6827 | refs/heads/master | 2020-07-11T10:09:31.244662 | 2013-06-29T19:06:43 | 2013-06-29T19:06:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,928 | cpp | /*
* Copyright (C) 2008 - 2011 Trinity <http://www.trinitycore.org/>
*
* Copyright (C) 2010 - 2012 Myth Project <http://mythprojectnetwork.blogspot.com/>
*
* Myth Project's source is based on the Trinity Project source, you can find the
* link to that easily in Trinity Copyrights. Myth Project is a private community.
* To get access, you either have to donate or pass a developer test.
* You may not share Myth Project's sources! For personal use only.
*/
#include "ScriptPCH.h"
#include "ScriptedEscortAI.h"
enum eAeranas
{
SAY_SUMMON = -1000138,
SAY_FREE = -1000139,
FACTION_HOSTILE = 16,
FACTION_FRIENDLY = 35,
SPELL_ENVELOPING_WINDS = 15535,
SPELL_SHOCK = 12553,
C_AERANAS = 17085
};
class npc_aeranas : public CreatureScript
{
public:
npc_aeranas() : CreatureScript("npc_aeranas") { }
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_aeranasAI(pCreature);
}
struct npc_aeranasAI : public ScriptedAI
{
npc_aeranasAI(Creature* pCreature) : ScriptedAI(pCreature) { }
uint32 Faction_Timer;
uint32 EnvelopingWinds_Timer;
uint32 Shock_Timer;
void Reset()
{
Faction_Timer = 8000;
EnvelopingWinds_Timer = 9000;
Shock_Timer = 5000;
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
me->setFaction(FACTION_FRIENDLY);
DoScriptText(SAY_SUMMON, me);
}
void UpdateAI(const uint32 diff)
{
if(Faction_Timer)
{
if(Faction_Timer <= diff)
{
me->setFaction(FACTION_HOSTILE);
Faction_Timer = 0;
} else Faction_Timer -= diff;
}
if(!UpdateVictim())
return;
if(HealthBelowPct(30))
{
me->setFaction(FACTION_FRIENDLY);
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
me->RemoveAllAuras();
me->DeleteThreatList();
me->CombatStop(true);
DoScriptText(SAY_FREE, me);
return;
}
if(Shock_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_SHOCK);
Shock_Timer = 10000;
} else Shock_Timer -= diff;
if(EnvelopingWinds_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_ENVELOPING_WINDS);
EnvelopingWinds_Timer = 25000;
} else EnvelopingWinds_Timer -= diff;
DoMeleeAttackIfReady();
}
};
};
enum eAncestralWolf
{
EMOTE_WOLF_LIFT_HEAD = -1000496,
EMOTE_WOLF_HOWL = -1000497,
SAY_WOLF_WELCOME = -1000498,
SPELL_ANCESTRAL_WOLF_BUFF = 29981,
NPC_RYGA = 17123
};
class npc_ancestral_wolf : public CreatureScript
{
public:
npc_ancestral_wolf() : CreatureScript("npc_ancestral_wolf") { }
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_ancestral_wolfAI(pCreature);
}
struct npc_ancestral_wolfAI : public npc_escortAI
{
npc_ancestral_wolfAI(Creature* pCreature) : npc_escortAI(pCreature)
{
if(pCreature->GetOwner() && pCreature->GetOwner()->GetTypeId() == TYPEID_PLAYER)
Start(false, false, pCreature->GetOwner()->GetGUID());
else
sLog->outError("TRINITY: npc_ancestral_wolf can not obtain owner or owner is not a player.");
pCreature->SetSpeed(MOVE_WALK, 1.5f);
Reset();
}
Unit* pRyga;
void Reset()
{
pRyga = NULL;
DoCast(me, SPELL_ANCESTRAL_WOLF_BUFF, true);
}
void MoveInLineOfSight(Unit* who)
{
if(!pRyga && who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_RYGA && me->IsWithinDistInMap(who, 15.0f))
pRyga = who;
npc_escortAI::MoveInLineOfSight(who);
}
void WaypointReached(uint32 uiPointId)
{
switch(uiPointId)
{
case 0:
DoScriptText(EMOTE_WOLF_LIFT_HEAD, me);
break;
case 2:
DoScriptText(EMOTE_WOLF_HOWL, me);
break;
case 50:
if(pRyga && pRyga->isAlive() && !pRyga->isInCombat())
DoScriptText(SAY_WOLF_WELCOME, pRyga);
break;
}
}
};
};
class go_haaleshi_altar : public GameObjectScript
{
public:
go_haaleshi_altar() : GameObjectScript("go_haaleshi_altar") { }
bool OnGossipHello(Player* /*pPlayer*/, GameObject* pGo)
{
pGo->SummonCreature(C_AERANAS, -1321.79f, 4043.80f, 116.24f, 1.25f, TEMPSUMMON_TIMED_DESPAWN, 180000);
return false;
}
};
#define GOSSIP_NALADU_ITEM1 "Why don't you escape?"
enum eNaladu
{
GOSSIP_TEXTID_NALADU1 = 9788
};
class npc_naladu : public CreatureScript
{
public:
npc_naladu() : CreatureScript("npc_naladu") { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
if(uiAction == GOSSIP_ACTION_INFO_DEF+1)
player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_NALADU1, creature->GetGUID());
return true;
}
bool OnGossipHello(Player* player, Creature* creature)
{
if(creature->isQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NALADU_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
};
#define GOSSIP_TEXT_REDEEM_MARKS "I have marks to redeem!"
#define GOSSIP_TRACY_PROUDWELL_ITEM1 "I heard that your dog Fei Fei took Klatu's prayer beads..."
#define GOSSIP_TRACY_PROUDWELL_ITEM2 "<back>"
enum eTracy
{
GOSSIP_TEXTID_TRACY_PROUDWELL1 = 10689,
QUEST_DIGGING_FOR_PRAYER_BEADS = 10916
};
class npc_tracy_proudwell : public CreatureScript
{
public:
npc_tracy_proudwell() : CreatureScript("npc_tracy_proudwell") { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
switch(uiAction)
{
case GOSSIP_ACTION_INFO_DEF+1:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TRACY_PROUDWELL_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TRACY_PROUDWELL1, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+2:
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
break;
case GOSSIP_ACTION_TRADE:
player->GetSession()->SendListInventory(creature->GetGUID());
break;
}
return true;
}
bool OnGossipHello(Player* player, Creature* creature)
{
if(creature->isQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
if(creature->isVendor())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_REDEEM_MARKS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
if(player->GetQuestStatus(QUEST_DIGGING_FOR_PRAYER_BEADS) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TRACY_PROUDWELL_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
};
#define GOSSIP_TROLLBANE_ITEM1 "Tell me of the Sons of Lothar."
#define GOSSIP_TROLLBANE_ITEM2 "<more>"
#define GOSSIP_TROLLBANE_ITEM3 "Tell me of your homeland."
enum eTrollbane
{
GOSSIP_TEXTID_TROLLBANE1 = 9932,
GOSSIP_TEXTID_TROLLBANE2 = 9933,
GOSSIP_TEXTID_TROLLBANE3 = 8772
};
class npc_trollbane : public CreatureScript
{
public:
npc_trollbane() : CreatureScript("npc_trollbane") { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
{
player->PlayerTalkClass->ClearMenus();
switch(uiAction)
{
case GOSSIP_ACTION_INFO_DEF+1:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE1, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+2:
player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE2, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+3:
player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE3, creature->GetGUID());
break;
}
return true;
}
bool OnGossipHello(Player* player, Creature* creature)
{
if(creature->isQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
};
enum eWoundedBloodElf
{
SAY_ELF_START = -1000117,
SAY_ELF_SUMMON1 = -1000118,
SAY_ELF_RESTING = -1000119,
SAY_ELF_SUMMON2 = -1000120,
SAY_ELF_COMPLETE = -1000121,
SAY_ELF_AGGRO = -1000122,
QUEST_ROAD_TO_FALCON_WATCH = 9375
};
class npc_wounded_blood_elf : public CreatureScript
{
public:
npc_wounded_blood_elf() : CreatureScript("npc_wounded_blood_elf") { }
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
{
if(quest->GetQuestId() == QUEST_ROAD_TO_FALCON_WATCH)
{
if(npc_escortAI* pEscortAI = CAST_AI(npc_wounded_blood_elf::npc_wounded_blood_elfAI, creature->AI()))
pEscortAI->Start(true, false, player->GetGUID());
// Change faction so mobs attack
creature->setFaction(775);
}
return true;
}
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_wounded_blood_elfAI(pCreature);
}
struct npc_wounded_blood_elfAI : public npc_escortAI
{
npc_wounded_blood_elfAI(Creature* pCreature) : npc_escortAI(pCreature) { }
void WaypointReached(uint32 i)
{
Player* player = GetPlayerForEscort();
if(!player)
return;
switch(i)
{
case 0:
DoScriptText(SAY_ELF_START, me, player);
break;
case 9:
DoScriptText(SAY_ELF_SUMMON1, me, player);
// Spawn two Haal'eshi Talonguard
DoSpawnCreature(16967, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
DoSpawnCreature(16967, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
break;
case 13:
DoScriptText(SAY_ELF_RESTING, me, player);
break;
case 14:
DoScriptText(SAY_ELF_SUMMON2, me, player);
// Spawn two Haal'eshi Windwalker
DoSpawnCreature(16966, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
DoSpawnCreature(16966, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
break;
case 27:
DoScriptText(SAY_ELF_COMPLETE, me, player);
// Award quest credit
player->GroupEventHappens(QUEST_ROAD_TO_FALCON_WATCH, me);
break;
}
}
void Reset() { }
void EnterCombat(Unit* /*pWho*/)
{
if(HasEscortState(STATE_ESCORT_ESCORTING))
DoScriptText(SAY_ELF_AGGRO, me);
}
void JustSummoned(Creature* summoned)
{
summoned->AI()->AttackStart(me);
}
};
};
enum eFelGuard
{
SPELL_SUMMON_POO = 37688,
NPC_DERANGED_HELBOAR = 16863
};
class npc_fel_guard_hound : public CreatureScript
{
public:
npc_fel_guard_hound() : CreatureScript("npc_fel_guard_hound") { }
CreatureAI* GetAI(Creature* pCreature) const
{
return new npc_fel_guard_houndAI(pCreature);
}
struct npc_fel_guard_houndAI : public ScriptedAI
{
npc_fel_guard_houndAI(Creature* pCreature): ScriptedAI(pCreature) { }
uint32 uiCheckTimer;
uint64 uiHelboarGUID;
void Reset()
{
uiCheckTimer = 5000; //check for creature every 5 sec
uiHelboarGUID = 0;
}
void MovementInform(uint32 uiType, uint32 uiId)
{
if(uiType != POINT_MOTION_TYPE || uiId != 1)
return;
if(Creature* pHelboar = me->GetCreature(*me, uiHelboarGUID))
{
pHelboar->RemoveCorpse();
DoCast(SPELL_SUMMON_POO);
if(Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
}
}
void UpdateAI(const uint32 diff)
{
if(uiCheckTimer <= diff)
{
if(Creature* pHelboar = me->FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false))
{
if(pHelboar->GetGUID() != uiHelboarGUID && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && !me->FindCurrentSpellBySpellId(SPELL_SUMMON_POO))
{
uiHelboarGUID = pHelboar->GetGUID();
me->GetMotionMaster()->MovePoint(1, pHelboar->GetPositionX(), pHelboar->GetPositionY(), pHelboar->GetPositionZ());
}
}
uiCheckTimer = 5000;
} else uiCheckTimer -= diff;
if(!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
};
void AddSC_hellfire_peninsula()
{
new npc_aeranas;
new npc_ancestral_wolf;
new go_haaleshi_altar;
new npc_naladu;
new npc_tracy_proudwell;
new npc_trollbane;
new npc_wounded_blood_elf;
new npc_fel_guard_hound;
}
| [
"vitasic-pokataev@yandex.ru"
] | vitasic-pokataev@yandex.ru |
04dcc776b3f0176a738dbf195bf4ba015a176066 | a0b0eb383ecfeaeed3d2b0271657a0c32472bf8e | /51nod/1392.cpp | a4399ecd85d40fbc4a4f4993b491ecba820b1352 | [
"Apache-2.0"
] | permissive | tangjz/acm-icpc | 45764d717611d545976309f10bebf79c81182b57 | f1f3f15f7ed12c0ece39ad0dd044bfe35df9136d | refs/heads/master | 2023-04-07T10:23:07.075717 | 2022-12-24T15:30:19 | 2022-12-26T06:22:53 | 13,367,317 | 53 | 20 | Apache-2.0 | 2022-12-26T06:22:54 | 2013-10-06T18:57:09 | C++ | UTF-8 | C++ | false | false | 1,541 | cpp | #include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 210;
struct Box
{
int x, y;
bool operator < (const Box &t) const
{
return x < t.x || x == t.x && y < t.y;
}
bool operator == (const Box &t) const
{
return x == t.x && y == t.y;
}
} a[maxn];
int n, g[maxn][maxn], lx[maxn], ly[maxn], match[maxn], ans;
bool sx[maxn], sy[maxn];
bool path(int u)
{
sx[u] = 1;
for(int v = 0; v < n; ++v)
{
if(sy[v] || lx[u] + ly[v] != g[u][v])
continue;
sy[v] = 1;
if(match[v] == -1 || path(match[v]))
{
match[v] = u;
return 1;
}
}
return 0;
}
int main()
{
scanf("%d", &n);
for(int i = 0; i < n; ++i)
scanf("%d%d", &a[i].x, &a[i].y);
sort(a, a + n);
n = unique(a, a + n) - a;
for(int i = 0; i < n; ++i)
{
ans += a[i].x * a[i].y;
for(int j = i + 1; j < n; ++j)
if(a[i].x <= a[j].x && a[i].y <= a[j].y)
g[i][j] = a[i].x * a[i].y;
lx[i] = a[i].x * a[i].y;
}
memset(match, -1, sizeof match);
for(int i = 0; i < n; ++i)
while(1)
{
memset(sx, 0, sizeof sx);
memset(sy, 0, sizeof sy);
if(path(i))
break;
int dx = 0x3f3f3f3f;
for(int j = 0; j < n; ++j)
{
if(!sx[j])
continue;
for(int k = 0; k < n; ++k)
if(!sy[k] && dx > lx[j] + ly[k] - g[j][k])
dx = lx[j] + ly[k] - g[j][k];
}
for(int j = 0; j < n; ++j)
{
if(sx[j])
lx[j] -= dx;
if(sy[j])
ly[j] += dx;
}
}
for(int i = 0; i < n; ++i)
if(match[i] != -1)
ans -= g[match[i]][i];
printf("%d\n", ans);
return 0;
}
| [
"t251346744@gmail.com"
] | t251346744@gmail.com |
87364752961e598132a4549b36a7ad04c014381d | a76d599d12054bccd4ba28b16cd236aa2ad47761 | /contest/NSU_PRACTICE/Geometry_Marathon/C.cpp | 17e8a5568eb51082cadc135971cb70cf6e2fc4f0 | [] | no_license | naimulhaider/acm | 56c36133b6f0de70d9dc9a1a320c1d4ba21b59c6 | c4ee9ecf95d1b18309dfa7536b91502a57e25289 | refs/heads/master | 2020-05-19T14:49:22.093043 | 2014-09-16T05:19:07 | 2014-09-16T05:19:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,063 | cpp | #include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
struct point{
double x, y;
point(double _x, double _y): x(_x), y(_y){}
};
double dist( point a, point b ) {
return hypot( a.x - b.x , a.y - b.y );
}
double norm ( double x, double y ) {
return sqrt( x * x + y * y );
}
bool insideRectangle( point a , point b, point p ) {
if( p.x > a.x && p.x < b.x && p.y > b.y && p.y < a.y ) return 1;
return 0;
}
double gta( point a, point b, point c ) {
double s1 = dist( a, b ) , s2 = dist( a,c ) , s3 = dist(b, c);
double s = (s1 + s2 + s3) * 0.5;
double ret = (s - s1) * (s - s2) * (s - s3);
ret *= s;
return sqrt( ret );
}
bool insideCircle( point o, double r, point p ) {
return norm( o.x - p.x , o.y - p.y ) < r;
}
bool insideTriangle( point a, point b, point c, point p ) {
double ar1 = gta(a,b,c);
double ar2 = gta(a,b,p) + gta(a,c,p) + gta(b,c,p);
return fabs( ar2 - ar1 ) < EPS;
}
int main() {
// freopen("input.in", "r" ,stdin);
char c;
vector<point> fig[15];
char typ[15];
double crad[15];
int ind = 0;
while( cin >> c ) {
if( c == '*' ) break;
if( c == 'r' ) {
double x1,y1,x2,y2;
cin >> x1>>y1>>x2>>y2;
point a(x1,y1), b(x2,y2);
fig[ind].push_back( a );
fig[ind].push_back( b );
typ[ind] = 'r';
} else if( c == 'c' ) {
double x1 , y1, r;
cin >> x1 >> y1 >> r;
point o(x1,y1);
fig[ind].push_back( o );
crad[ind] = r;
typ[ind] = 'c';
} else {
double x1,y1,x2,y2,x3,y3;
cin >> x1>>y1>>x2>>y2>>x3>>y3;
point a(x1,y1);
point b(x2,y2);
point c(x3,y3);
fig[ind].push_back(a);
fig[ind].push_back(b);
fig[ind].push_back(c);
typ[ind] = 't';
}
ind++;
}
double x , y;
int cnt = 1;
while( cin >> x >> y ) {
if( fabs(x-9999.9) < EPS && fabs(y-9999.9)<EPS ) break;
// cout << x << " " << y << endl;
point k(x,y);
bool ok = 0;
for( int i=0 ; i < ind; i++ ) {
if( typ[i] == 'c' ) {
if( insideCircle(fig[i][0],crad[i],k) ) {
ok = 1;
cout<<"Point "<< cnt <<" is contained in figure "<<i+1<<"\n";
}
} else if ( typ[i] == 'r' ) {
if( insideRectangle(fig[i][0],fig[i][1],k) ) {
ok = 1;
cout<<"Point "<< cnt <<" is contained in figure "<<i+1<<"\n";
}
} else {
if( insideTriangle( fig[i][0],fig[i][1],fig[i][2],k ) ) {
ok = 1;
cout<<"Point "<< cnt <<" is contained in figure "<<i+1<<"\n";
}
}
}
if( !ok ) {
cout << "Point "<< cnt <<" is not contained in any figure\n";
}
cnt++;
}
return 0;
}
| [
"naimulhaider@gmail.com"
] | naimulhaider@gmail.com |
322de3e424427cb80fa072a0db12071935664853 | dde6b384c7769e00eafa4b10831162fa9394e701 | /OpenCVUtils.h | bd524205e36f78f7a526fab2da092510e8a413fb | [
"LicenseRef-scancode-public-domain"
] | permissive | PeterZs/Neurally-Guided-Style-Transfer | 4f83e0fa66d99e20b76eead4c3c18cae95054070 | a99773fda66573995694907c72167d3382e73c63 | refs/heads/master | 2022-11-16T02:16:03.336911 | 2020-07-12T22:18:07 | 2020-07-12T22:18:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | h | #pragma once
#include <cstdio>
#include <string>
// cv::Mat forward declaration
namespace cv
{
class Mat;
};
cv::Mat cumsum(cv::Mat & src);
cv::Mat& ScanImageAndReduceC(cv::Mat& I, const unsigned char* const table);
cv::Mat GrayHistMatching(cv::Mat I, cv::Mat R);
void ResizeImageMaintainAspectRatio(cv::Mat& image, const int desiredSmallerSide);
cv::Mat Imread(const std::string& path, const bool swapRandB);
void Imwrite(const std::string& path, const cv::Mat& image, const bool swapRandB);
bool isOutOfImage(const cv::Mat& image, const int row, const int col);
/*
void imshowInWindow(const std::string& windowTitle, const cv::Mat& image);
void imshowInWindow(const std::string& windowTitle, const cv::Mat& image, int windowWidth, int windowHeight);
void imshowInWindow(const std::string& windowTitle, const cv::Mat& image, int windowWidth, int windowHeight, int moveX, int moveY);
*/ | [
"ondrej.texler@gmail.com"
] | ondrej.texler@gmail.com |
727bfbd836e7213d6f6c203062aecfab49f9b9de | b4ba3bc2725c8ff84cd80803c8b53afbe5e95e07 | /Medusa/MedusaCore/Core/Log/linux/LinuxConsoleLogger.h | c914fccaaee858786896c357ce23fe470b3a4984 | [
"MIT"
] | permissive | xueliuxing28/Medusa | c4be1ed32c2914ff58bf02593f41cf16e42cc293 | 15b0a59d7ecc5ba839d66461f62d10d6dbafef7b | refs/heads/master | 2021-06-06T08:27:41.655517 | 2016-10-08T09:49:54 | 2016-10-08T09:49:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 504 | h | // Copyright (c) 2015 fjz13. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
#pragma once
#include "Core/Log/ILogger.h"
MEDUSA_BEGIN;
#ifdef MEDUSA_LINUX
class LinuxConsoleLogger :public ILogger
{
public:
LinuxConsoleLogger(bool isLogHeader=true);
virtual ~LinuxConsoleLogger(void);
protected:
virtual void OutputLogString(StringRef inString);
virtual void OutputLogString(WStringRef inString);
};
#endif
MEDUSA_END;
| [
"fjz13@live.cn"
] | fjz13@live.cn |
7c1246af8b45576d456d91a1d48cddde0338f9ab | 24fc2132f5cfe01dae1f38f954c6e1c10c144e27 | /include/utils/sfinae.h | 1523029c4ff2e88be66171e9cfd29bd57cd00bac | [
"MIT"
] | permissive | BooshSource/AlphaTools | ad612d09b4f554f5b2e6835a8ace5926d8ac60de | 70ff9cd4ec4184f67d7e8b779538ef88f1e88682 | refs/heads/master | 2022-04-26T15:44:57.929480 | 2020-03-08T16:22:54 | 2020-03-08T16:22:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,014 | h | #pragma once
#include <type_traits>
#include "types.h"
/**
* \file sfinae.h
* \brief Various SFINAE utilities
*/
namespace util {
template<typename T>
struct DerefPointer;
/**
* Class that provides compile-time determination of a type. Seperates into numeric, array, class, function, member
* data, or member function. Pointers will be maximally de-referenced, getting the 'underlying' type
*
* \tparam T Type to determine classification of
*/
template<typename T>
class TypeFinder {
typedef const char _numeric[1];
typedef const char _array[2];
typedef const char _class[3];
typedef const char _function[4];
typedef const char _memberdata[5];
typedef const char _memberfunc[6];
template<typename C, std::enable_if_t<std::is_integral<C>::value || std::is_floating_point<C>::value, int> = 0>
static _numeric& test() {return "";}
template<typename C, std::enable_if_t<std::is_array<C>::value, int> = 0>
static _array& test() {return "a";}
template<typename C, std::enable_if_t<std::is_class<C>::value, int> = 0>
static _class& test() {return "cc";}
template<typename C, std::enable_if_t<std::is_function<C>::value, int> = 0>
static _function& test() {return "fff";}
template<typename C, std::enable_if_t<std::is_member_object_pointer<C>::value, int> = 0>
static _memberdata& test() {return "mdmd";}
template<typename C, std::enable_if_t<std::is_member_function_pointer<C>::value, int> = 0>
static _memberfunc& test() {return "mfmfm";}
static const size_t _result = sizeof(test<typename DerefPointer<typename std::remove_reference<T>::type>::type>());
public:
/**
* TypeFinder constant enum values
*/
enum {
numeric = _result == sizeof(_numeric),
array = _result == sizeof(_array),
cls = _result == sizeof(_class),
function = _result == sizeof(_function),
member_data = _result == sizeof(_memberdata),
member_func = _result == sizeof(_memberfunc),
};
};
/**
* \internal
*
* Implementation of MakePtr, for if the type is already a pointer
*
* \tparam T Type to make into a pointer
*/
template<typename T, bool = std::is_pointer<T>::value>
struct __MakePtr {
/**
* Unchanged type, it's already a pointer
*/
typedef T type;
/**
* Take a pointer and return it unchanged.
*
* \param val Reference to return
* \return Same pointer
*/
static T make_ptr(const T& val);
};
/**
* \internal
*
* Implementation of MakePtr, for if the type is not a pointer
*
* \tparam T Type to make into a pointer
*/
template<typename T>
struct __MakePtr<T, false> {
/**
* Type with added pointer
*/
typedef T* type;
/**
* Runtime convert a reference to the type into a pointer to that reference.
*
* \param val Reference to convert
* \return Pointer to reference
*/
static T* make_ptr(T& val);
};
/**
* Class that converts a type into a pointer, if it's not already a pointer type
* For example, `int` becomes `int*`, but `int*` remains `int*`.
* Also contains a method `make_ptr` for runtime conversion.
*
* \tparam T Type to conditionally convert
*/
template<typename T>
struct MakePtr : public __MakePtr<T> {};
/**
* \internal
*
* Implementation of DerefPointer, for if the type is not a pointer type
*
* \tparam T Type to deref
* \tparam U Derefed form of T
*/
template<typename T, typename U>
struct __DerefPointer {
/**
* Fully de-referenced type
*/
typedef T type;
/**
* How many times the type was de-referenced
*/
static constexpr size_t depth = 0;
};
/**
* \internal
*
* Implementation of DerefPointer, for if the type is a pointer type
*
* \tparam T Type to deref
* \tparam U Derefed form of T
*/
template<typename T, typename U>
struct __DerefPointer<T, U*> {
/**
* Fully de-referenced type
*/
typedef typename __DerefPointer<U, U>::type type;
/**
* How many times the type was de-referenced
*/
static constexpr size_t depth = __DerefPointer<U, U>::depth + 1;
};
/**
* Get the most possibly de-referenced form of a pointer. `int` stays the same, `int**` will become `int`.
*
* \tparam T Type to dereference
*/
template<typename T>
struct DerefPointer : public __DerefPointer<T, T> {};
/**
* Get information about a function type. Specialization for if the type isn't a function.
*/
template<typename>
struct FunctionTraits {
/**
* FunctionTrait constant enum values
*/
enum {
valid = 0,
invalid = 1
};
};
/**
* Get information about a function type. Specialization for if the type is a function.
*
* \tparam Ret Return type of the function
* \tparam Args Variadic pack of argument types to the function
*/
template<typename Ret, typename... Args>
struct FunctionTraits<Ret(Args...)> {
/**
* Return type of the function
*/
typedef Ret return_type;
/**
* Non-pointer function type
*/
typedef Ret(raw_type)(Args...);
/**
* Equivalent function pointer type
*/
typedef Ret(*pointer_type)(Args...);
/**
* Number of arguments to this function
*/
static constexpr size_t num_args = sizeof...(Args);
/**
* FunctionTraits constant enum values
*/
enum {
valid = 1,
invalid = 0
};
};
/**
* Get information about a function type. Specialization for if the type is a pointer to a function.
*
* \tparam Ret Return type of the function
* \tparam Args Variadic pack of argument types to the function
*/
template<typename Ret, typename... Args>
struct FunctionTraits<Ret(*)(Args...)> {
/**
* Return type of the function
*/
typedef Ret return_type;
/**
* Equivalent non-pointer function type
*/
typedef Ret(raw_type)(Args...);
/**
* Function pointer type
*/
typedef Ret(*pointer_type)(Args...);
/**
* Number of arguments to this function
*/
static constexpr size_t num_args = sizeof...(Args);
/**
* FunctionTraits constant enum values
*/
enum {
valid = 1,
invalid = 0
};
};
/**
* Get information about a member data type. Specialization for if the type isn't a pointer to member data.
*/
template<typename>
struct MemberTraits {
/**
* Void type for invalid type
*/
typedef void class_type;
/**
* MemberTraits constant enum values
*/
enum {
valid = 0,
invalid = 1
};
};
/**
* Get information about a member data type. Specialization for if the type is a pointer to member data.
*
* \tparam Val Type of the data pointed to
* \tparam Cls Type of the containing class
*/
template<typename Val, typename Cls>
struct MemberTraits<Val Cls::*> {
/**
* Class type of the member
*/
typedef Cls class_type;
/**
* Value type of the member
*/
typedef Val member_type;
/**
* MemberTraits constant enum values
*/
enum {
valid = 1,
invalid = 0
};
};
/**
* Get information about a member function type. Specialization for if the type isn't a pointer to a member func
*/
template<typename>
struct MethodTraits {
/**
* Void type for invalid type
*/
typedef void class_type;
/**
* MethodTraits constant enum values
*/
enum {
valid = 0,
invalid = 1
};
};
/**
* Get information about a member function type. Specialization for if the type is a pointer to a member func
*
* \tparam Ret Return type of the method
* \tparam Cls Type of the containing class
* \tparam Args Variadic pack of argument types to the method
*/
template<typename Ret, typename Cls, typename... Args>
struct MethodTraits<Ret(Cls::*)(Args...)> {
/**
* Return type of the method
*/
typedef Ret return_type;
/**
* Class type of the method
*/
typedef Cls class_type;
/**
* Number of arguments to the method
*/
static constexpr size_t num_args = sizeof...(Args);
/**
* MethodTraits constant enum values
*/
enum {
/// Whether the type is a valid method type
valid = 1,
/// Whether the type is not a valid method type
invalid = 0
};
};
/**
* Access to the raw data of a type as any other type/types.
* Note that this type does not take ownership, and is only valid for the lifetime of its backing instance.
*
* \tparam T Type to access raw data of
*/
template<typename T>
class RawData {
uchar* data;
public:
static constexpr size_t size = sizeof(T);
/**
* Construct this RawData from a pointer to an instance
*
* \param obj Object to access the raw data of
*/
explicit RawData(T& obj);
/**
* Construct this RawData from a reference to an instance
*
* \param obj Object to access the raw data of
*/
explicit RawData(T* obj);
/**
* Access into the object as if it was a uchar array, with bounds checking
*
* \param pos Index to access
* \return Character value at that index
*/
uchar& operator[](size_t pos);
/**
* Access into the object as if it was an array of type U, with bounds checking
*
* \tparam U Type to access
* \param pos Index to access at (byte-aligned)
* \return U value at index
*/
template<typename U>
U& get_value(size_t pos);
/**
* Set a value in the object as if it was an array of type U, with bounds checking
*
* \tparam U Type to set as
* \param pos Index to set at (byte-aligned)
* \param val value to set at location
*/
template<typename U>
void set_value(size_t pos, const U& val);
};
/**
* Type representing a Templated compile-time integer range
* Take as an argument, and then one can use I in variadic unpacking for a guaranteed range
*
* \tparam I Variadic pack of integer values
*/
template<size_t... I>
struct TemplateRange {};
/**
* \brief Helper for creating various instances of TemplateRange
*
* Provides RangeBuilder, and in the future possibly other ways to generate TemplateRange instances.
*/
namespace VariadicRangeBuilder {
/**
* RangeBuilder base. Takes a minimum value, a maximum value, and a pack of the result.
*
* \tparam MIN Value to start range at
* \tparam N Current count value of the builder
* \tparam I Variadic pack of integer values
*/
template<size_t MIN, size_t N, size_t... I>
struct RangeBuilder;
/**
* RangeBuilder specialization for when the range is fully built (N == MIN). Returns the finalized TemplateRange
*
* \tparam MIN Value to start at
* \tparam I Finished value pack
*/
template<size_t MIN, size_t... I>
struct RangeBuilder<MIN, MIN, I...> {
/**
* Final constructed TemplateRange, with full range
*/
typedef TemplateRange<I...> range;
};
/**
* RangeBuilder specialization for when the range is still being built. Adds the next value to the pack,
* and decrements N.
*
* \tparam MIN Value to start at
* \tparam N Current count value of the builder
* \tparam I Variadic pack of values
*/
template<size_t MIN, size_t N, size_t... I>
struct RangeBuilder : public RangeBuilder<MIN, N - 1, N - 1, I...> {};
}
/**
* Alias for a VariadicRangeBuilder that counts from [0, sizeof...(Args)).
* Useful for indexing an array based on a variadic template
*/
template<typename... Args>
using VariadicRange = typename VariadicRangeBuilder::RangeBuilder<0, sizeof...(Args)>::range;
}
#include "sfinae.tpp"
| [
"runetynan@gmail.com"
] | runetynan@gmail.com |
4ab541a7aeed0cff7e04695d0c16c02cfcbe1f65 | d00f0f4d5514a0bce3f51aa82f454a9ba7627d65 | /robot_motion/src/flipper.cpp | 1eb8fc754a7dbe701e5c749cb300ae8024330fa8 | [] | no_license | DOZAP/RMRC2020 | 8d39409563e79b636ea08215deb3201a58863f11 | e23f99cb393974a93aa37ecfa6915d3fd3d34219 | refs/heads/master | 2021-02-27T12:54:25.516432 | 2020-03-07T10:06:07 | 2020-03-07T10:06:07 | 245,607,757 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,950 | cpp | #include <cmath>
#include <comprehensive/Button.h>
#include <iostream>
#include <ros/ros.h>
#include <std_msgs/Float64.h>
#include <std_msgs/Float64MultiArray.h>
#include <vector>
using std::vector;
vector<double> dynamixel_current_angle = {0, 0, 0, 0};
vector<double> dynamixel_goal_angle = {0, 0, 0, 0};
double distance_front = 0, distance_back = 0, gyro_robot = 0,
prev_gyro_robot = 0;
bool flag_manual = false;
bool flag_prev_status = false;
// judgement of rotate the rear flipper in the negative direction
bool flag_lower = false;
enum Status { MANUAL, UP_BOTH, UP_EITHER };
void angleCallback(const std_msgs::Float64MultiArray &msg) {
for (auto &num : dynamixel_current_angle) {
num = msg.data[num];
}
}
void distanceCallback(const std_msgs::Float64MultiArray &msg) {
distance_front = msg.data[0];
distance_back = msg.data[1];
}
void gyroCallback(const std_msgs::Float64 &msg) { gyro_robot = msg.data; }
void controlleCallback(const comprehensive::Button &msg) {
msg.dynamixel_right_front
? flag_manual = true
: msg.dynamixel_right_back
? flag_manual = true
: msg.dynamixel_left_front
? flag_manual = true
: msg.dynamixel_left_back ? flag_manual = true : flag_manual =
false;
dynamixel_goal_angle[0] = msg.dynamixel_right_front;
dynamixel_goal_angle[1] = msg.dynamixel_left_front;
dynamixel_goal_angle[2] = msg.dynamixel_right_back;
dynamixel_goal_angle[3] = msg.dynamixel_left_back;
}
bool judge_angle_front(double front, double distance_front);
bool judge_angle_back(double robot, double back, double distance_back);
bool flag_down_back(double robot, bool contacts_front);
Status judge_angle(double &front, double &back, double &distance_front,
double &distance_back, double &robot_angle);
int main(int argc, char **argv) {
ros::init(argc, argv, "flipper_angle");
ros::NodeHandle n;
// send message type is radian
ros::Publisher angle_pub =
n.advertise<std_msgs::Float64MultiArray>("flipper_angle", 10);
ros::Subscriber servo_angle_sub = n.subscribe<"angle_now", 10, angleCallback>;
ros::Subscriber distance_sub = n.subscribe<"distance", 10, distanceCallback>;
ros::Subscriber gyro_sub = n.subscribe<"gyro_pitch", 10, gyroCallback>;
ros::Subscriber xbox_sub = n.subscribe<"xbox", 10, controllerCallback>;
ros::Rate loop_rate(100);
std_msgs::Float64MultiArray angle_data;
angle_data.resize(4);
double angle_front = 0, angle_back = 0;
// setting flipper_parameter
constexpr double flipper_length = 100;
constexpr double nomal_angle_front = 25;
constexpr double nomal_angle_back = 25;
constexpr double wall_angle_front = 10;
constexpr double wall_angle_back = 0;
Status servoStatus;
while (ros::ok()) {
if (flag_manual == true)
servoStatus = MANUAL;
else {
servoStatus = judge_angle(double &angle_front, double &angle_back,
double &distance_front, double &distance_back,
double &robot_angle);
//----------calcuration of angle_front----------
if (dynamixel_current_angle[0] > 0 && dynamixel_current_angle[1] < 90) {
if (dynamixel_current_angle[1] > 0 && dynamixel_current_angle[2] < 90) {
angle_front =
(dynamixel_current_angle[0] + dynamixel_current_angle[1]) / 2;
} else {
angle_front = dynamixel_current_angle[0];
}
} else if (dynamixel_current_angle[1] > 0 &&
dynamixel_current_angle[2] < 90) {
angle_front = dynamixel_current_angle[1];
} else {
angle_front = nomal_angle_front;
}
//----------calcuration of angle_back----------
if (dynamixel_current_angle[2] > 0 && dynamixel_current_angle[2] < 90) {
if (dynamixel_current_angle[3] > 0 && dynamixel_current_angle[3] < 90) {
angle_back =
(dynamixel_current_angle[2] + dynamixel_current_angle[3]) / 2;
} else {
angle_back = dynamixel_current_angle[2];
}
} else if (dynamixel_current_angle[3] > 0 &&
dynamixel_current_angle[3] < 90) {
angle_back = dynamixel_current_angle[3];
} else {
angle_back = nomal_angle_back;
}
}
//----------calcuration of dynamixel_goal_angle----------
switch (servoStatus) {
case MANUAL:
flag_prev_status = false;
break;
case UP_BOTH:
dynamixel_goal_angle[0] = 15;
dynamixel_goal_angle[1] = 15;
dynamixel_goal_angle[2] = 0;
dynamixel_goal_angle[3] = 0;
flag_prev_status = false;
break;
case UP_EITHER:
dynamixel_goal_angle[0] = 25;
dynamixel_goal_angle[1] = 25;
if (flag_lower == false) {
dynamixel_goal_angle[2] -= 2;
dynamixel_goal_angle[3] -= 2;
}
flag_prev_status = true;
break;
}
//----------set dynamixel_parameters----------
for (auto &num : dynamixel_goal_angle) {
angle_data.data[num] = num;
angle_data.data[num] = (angle_data.data[num] / 180) * M_PI;
}
angle_pub.publish(angle_data);
flag_manual = false;
ros::spinOnce;
loop_rate.sleep();
}
}
Status judge_angle(double &front, double &back, double &distance_front,
double &distance_back, double &robot_angle) {
bool front_contacts = false, back_contacts = false;
if (distance_angle < flipper_length) {
if ()
front_contacts = true;
else
front_contacts = false;
} else if () {
// if angle > 0 the robot cannot down the flipper
robot_angle > 0 ? back_contacts = true : back_contacts = false;
}
if (flag_prev_status) {
if (prev_gyro_robot > gyro_robot - 5 && prev_gyro_robot < gyro_robot + 5) {
flag_lower = true;
} else {
flag_lower = false;
}
} else {
flag_lower = false;
}
(front_contacts == true && back_contacts == true)
? return UP_BOTH
: (front_contacts == false && back_contacts true) ? return UP_EITHER
: return MANUAL;
}
| [
"m1830@s.akashi.ac.jp"
] | m1830@s.akashi.ac.jp |
c925e63cb3b93fdc2a6f2b4fb4f580f9f0ecf129 | 3d02813d5dbc6ba95751de50e3a31732c91b0d17 | /Shh0yaInjector/LoadLibrary.cpp | df6a6a98ca06603db97fd564c3e130f86bd93e65 | [] | no_license | veath1/Shh0yaInjector | 1e26018e21ceaaea35c60791cf3b49b47a6c487b | 06f48168e8e8be8ad8c88be37761ef6ae3e20ca1 | refs/heads/main | 2023-03-04T04:30:07.899900 | 2021-02-18T16:22:09 | 2021-02-18T16:22:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 411 | cpp | #include "Injection.h"
VOID InjLoadLibrary(PINJECT_DATA pData)
{
PVOID pRemoteBuffer = VirtualAllocEx(pData->ProcessHandle, 0, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE);
if (!pRemoteBuffer)
{
}
else
{
if (!WriteProcessMemory(pData->ProcessHandle, pRemoteBuffer, pData->DllPath, strlen(pData->DllPath) + 1, NULL))
{
}
else
{
CodeExecution(pData, LoadLibraryA, pRemoteBuffer);
}
}
} | [
"36813165+Shhoya@users.noreply.github.com"
] | 36813165+Shhoya@users.noreply.github.com |
3bad1736edc0f337fdeb075426965b14a6fcdc3b | 68cf7a060c571d518e318701929758c6385c26e3 | /AtmosVisualizer/AtmosEditor/src/log/a3LogHTML.h | aa2b9e668c0f0f48ce695488e2a710c35578f570 | [] | no_license | BentleyBlanks/AtmosVisualizer | e7fe270e7ce55bc8332018c499cf8d8a98277dc3 | fb66c43d61a6aa528b0945257a4c9c72f2c8acaa | refs/heads/master | 2021-01-22T18:28:06.032301 | 2018-02-03T13:50:51 | 2018-02-03T13:50:51 | 85,084,289 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,163 | h | #ifndef A3_LOGHTML_H
#define A3_LOGHTML_H
#include "a3Log.h"
// not support UTF8 log to file
// default file name format [year]-[month]-[day]-Atmos-VertionType.html
// would cover the same name file, be sure to end() when everything is finished
class a3LogHTML
{
public:
static void log(a3LogLevel logLevel, const char* message, ...);
static void begin();
static void end();
// log to default name file: [prefix]:Atmos-VerisionType.html
static void fatalError(const char* message, ...);
static void error(const char* message, ...);
static void seriousWarning(const char* message, ...);
static void warning(const char* message, ...);
static void success(const char* message, ...);
static void info(const char* message, ...);
static void dev(const char* message, ...);
static void debug(const char* message, ...);
private:
a3LogHTML() {}
a3LogHTML(const a3LogHTML&) {}
~a3LogHTML() {}
a3LogHTML& operator=(const a3LogHTML& event) const {}
static void log(a3LogLevel logLevel, const char* message, va_list args);
static std::ofstream* ofile;
static bool isBegin;
};
#endif | [
"bentleyjobs@gmail.com"
] | bentleyjobs@gmail.com |
95701f8897c8208e94669f86e976aa098c069c69 | 845e3e104ec4af1476f082f070e5aee7e55f53ee | /DuyetDoThi/DuongDiDFSCoHuong.cpp | cd6ab542ddc434d67e57c5c5f81386bf3c9c97b0 | [] | no_license | hoangnv2810/Algorithm | 96000ede09269adb0ac8d8fa598b158997fd4286 | cdc5c7708e63f12ed01a84b3de4fec7585b5070a | refs/heads/main | 2023-08-23T08:44:07.510186 | 2021-09-28T13:19:35 | 2021-09-28T13:19:35 | 411,252,789 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,044 | cpp | #include<bits/stdc++.h>
using namespace std;
bool vs[1001];
int truoc[1001];
vector<int> ke[1001];
void DFS(int u){
stack<int> s;
s.push(u);
// cout << u << " ";
vs[u] = true;
while(!s.empty()){
u = s.top();
s.pop();
for(int i = 0; i < ke[u].size(); i++){
if(!vs[ke[u][i]]){
// cout << ke[u][i] << " ";
s.push(u);
s.push(ke[u][i]);
vs[ke[u][i]] = true;
truoc[ke[u][i]] = u;
break;
}
}
}
}
void result(int s, int t){
vector<int> res;
if(truoc[t] == 0){
cout << -1;
} else {
res.push_back(t);
while(t != s){
t = truoc[t];
res.push_back(t);
}
for(int i = res.size()-1; i >= 0; i--){
cout << res[i] << " ";
}
}
}
int main(){
int t;
cin >> t;
while(t--){
int v, e, u, t;
cin >> v >> e >> u >> t;
memset(vs, false, sizeof(vs));
memset(truoc, 0, sizeof(truoc));
for(int i = 1; i < v+1; i++){
ke[i].clear();
}
int start, end;
for(int i = 0; i < e; i++){
cin >> start >> end;
ke[start].push_back(end);
}
DFS(u);
result(u, t);
cout << endl;
}
}
| [
"hoangnv2810@gmail.com"
] | hoangnv2810@gmail.com |
ab5fb2d1353c47fda0f8d3dd409098fac0a005d1 | 4c4eacdf282ca3a02b9d94434412b14269d31fcd | /ComputerGraphics/RenderModel.h | ac9e1b691069dca1f10e73747287f02d1bd9c78a | [] | no_license | zheminggu/computer-graphics | 91d14511ae3069bb567eaac766c4fb8fd11102f4 | 4bcd9edee043f416287ec41d3e5301f3f288b23f | refs/heads/master | 2022-11-08T17:44:01.041461 | 2020-06-27T22:18:53 | 2020-06-27T22:18:53 | 240,895,980 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,309 | h | #pragma once
#ifndef RENDERMODEL_H
#define RENDERMODEL_H
#include "Surface.h"
#include "Vector4.h"
#include "Light.h"
#include <vector>
class Vector3;
class Matrix4;
class EdgeTable;
class Light;
class RenderModel
{
public:
RenderModel();
~RenderModel();
void AddVertices(Vector4& point);
void AddSurfaces(Surface& surface);
void LeftProduct(Matrix4& mat);
void DrawModel();
void Print();
void PrintVertices();
void PrintVertices(int number);
void PrintSurfaces();
void PrintSurfaces(int number);
void CalculateColor(Vector3& cameraDirection, std::vector<Light>& lights, Vector3& worldColor, float k_a);
static Vector4 CalculateColor(Vector3& vector, Vector3& cameraDirection, std::vector<Light>& lights, Vector3& worldColor, Vector3& modelColor, float k_a, float k_d);
void RegulateModel();
std::vector<EdgeTable> CreateEdgeTable();
void InitVerticeVector();
inline void SetModelColor(Vector3& modelColor, float k_d) { this->modelColor = Vector3(modelColor); this->k_d = k_d; }
inline Vector3 GetModelColor() { return this->modelColor; }
inline float GetK_D() { return k_d; }
private:
std::vector<Vector4> vertices;
std::vector<Surface> surfaces;
std::vector<Vector4> vertice_color;
std::vector<Vector3> vertice_vector;
Vector3 modelColor;
float k_d;
};
#endif // !RENDERMODEL_H
| [
"zheminggugu@gmail.com"
] | zheminggugu@gmail.com |
6b5229013e095c7e2818e9715a4bc4ecab582245 | 7e5e5e2f195b1e1b6204988adcaae7a20611b696 | /lkg/2014-12-26/ColorScale.cpp | e6b22870092d0d50a025c5a3472952666d497a3e | [] | no_license | Preppy/PalMod | 08194536fab486f3562666f9eba8de908cb208c2 | 6b8b57db3f4ec90965a4ef73a0f90b8096dcd4ee | refs/heads/master | 2023-08-24T20:34:27.611939 | 2023-08-22T04:37:53 | 2023-08-22T04:37:53 | 239,400,781 | 31 | 23 | null | 2023-09-01T17:50:29 | 2020-02-10T01:05:30 | C++ | UTF-8 | C++ | false | false | 10,096 | cpp | /******************************************************************************
MODULE: COLORSCALE.FP
PURPOSE: Color scaling and RGB-HSL conversion functions
AUTHOR: Guillaume Dargaud
HISTORY: Jan 2001 - Tested under Unix
NOTE: Standard ANSI C, Windows, Unix
******************************************************************************/
#include "stdafx.h"
#include <iso646.h>
#include <math.h>
#include "ColorScale.h"
#define MIN3(a,b,c) ( (a)<=(b) ? (a)<=(c)?(a):(c) : (b)<=(c)?(b):(c) )
#define MAX3(a,b,c) ( (a)>=(b) ? (a)>=(c)?(a):(c) : (b)>=(c)?(b):(c) )
/******************************************************************************
FUNCTION: ColorScaleRGB
PURPOSE: Returns the RGB linear interpolated color between 2 colors
If Ratio=0, you get Col1,
If Ratio=1, you get Col2
IN: Col1: low color in hex 0xRRGGBB format
Col2: high color in hex 0xRRGGBB format
Ratio: 0 for low color, 1 for high color, or in between
EXAMPLE: Col1=0, Col2=0xFF00FF, Ratio=0.5 returns 0x800080
******************************************************************************/
COLORREF ColorScaleRGB( const COLORREF Col1,
const COLORREF Col2,
const float Ratio) {
int R1=(Col1>>16)&0xFF, G1=(Col1>>8)&0xFF, B1=Col1&0xFF;
int R2=(Col2>>16)&0xFF, G2=(Col2>>8)&0xFF, B2=Col2&0xFF;
int Color;
if (Ratio<=0) return Col1; // Ratio parameter must be between 0 and 1
else if (Ratio>=1) return Col2;
Color= (int)(R1+(R2-R1)*Ratio+0.5)<<16 | // rounding
(int)(G1+(G2-G1)*Ratio+0.5)<<8 |
(int)(B1+(B2-B1)*Ratio+0.5);
return Color;
}
/******************************************************************************
FUNCTION: ColorScaleHSL
PURPOSE: Returns the HSL linear interpolated color between 2 colors
(more natural looking than RGB interpolation)
For instance if the luminance is the same in Col1 and Col2,
then the luminance of the result will be the same
If Ratio=0, you get Col1,
If Ratio=1, you get Col2
IN: Col1: low color in hex 0xRRGGBB format
Col2: high color in hex 0xRRGGBB format
Ratio: 0 for low color, 1 for high color, or in between
EXAMPLE: Col1=0, Col2=0xFF00FF, Ratio=0.5 returns 0x1F5F3F
******************************************************************************/
COLORREF ColorScaleHSL( const COLORREF Col1,
const COLORREF Col2,
const float Ratio) {
static double H1, H2, S1, S2, L1, L2;
static int rgb;
if (Ratio<=0) return Col1; // Ratio parameter must be between 0 and 1
else if (Ratio>=1) return Col2;
RGBtoHLS( Col1, &H1, &L1, &S1);
RGBtoHLS( Col2, &H2, &L2, &S2);
return rgb=HLStoRGB( H1+(H2-H1)*Ratio, L1+(L2-L1)*Ratio, S1+(S2-S1)*Ratio );
}
/******************************************************************************
FUNCTION: ColorScaleRGB3
PURPOSE: Returns the RGB linear interpolated color between 3 colors
IN: Ratio1/2/3 is the weight assigned to color 1/2/3 (0 to 1)
NOTE: In general you want to pass Ratio1=1-Ratio2-Ratio3
making sure that it stays between 0 and 1
******************************************************************************/
extern COLORREF ColorScaleRGB3(const COLORREF Col1, const COLORREF Col2, const COLORREF Col3,
float Ratio1, float Ratio2, float Ratio3) {
int R1=(Col1>>16)&0xFF, G1=(Col1>>8)&0xFF, B1=Col1&0xFF;
int R2=(Col2>>16)&0xFF, G2=(Col2>>8)&0xFF, B2=Col2&0xFF;
int R3=(Col3>>16)&0xFF, G3=(Col3>>8)&0xFF, B3=Col3&0xFF;
int Color;
double SR;
if (Ratio1<0) Ratio1=0; else if (Ratio1>1) Ratio1=1;
if (Ratio2<0) Ratio2=0; else if (Ratio2>1) Ratio2=1;
if (Ratio3<0) Ratio3=0; else if (Ratio3>1) Ratio3=1;
if ((SR=Ratio1+Ratio2+Ratio3)==0) return Col1;
Color= (int)( (Ratio1*R1+Ratio2*R2+Ratio3*R3)/SR +0.5) <<16 | // rounding
(int)( (Ratio1*G1+Ratio2*G2+Ratio3*G3)/SR +0.5)<<8 |
(int)( (Ratio1*B1+Ratio2*B2+Ratio3*B3)/SR +0.5);
return Color;
}
/******************************************************************************
FUNCTION: ColorScaleHSL3
PURPOSE: Returns the HSL linear interpolated color between 3 colors
IN: Ratio1/2/3 is the weight assigned to color 1/2/3 (0 to 1)
NOTE: In general you want to pass Ratio1=1-Ratio2-Ratio3
making sure that it stays between 0 and 1
******************************************************************************/
extern COLORREF ColorScaleHSL3(const COLORREF Col1, const COLORREF Col2, const COLORREF Col3,
float Ratio1, float Ratio2, float Ratio3) {
static double H1, H2, H3, S1, S2, S3, L1, L2, L3, SR;
static int rgb;
if (Ratio1<0) Ratio1=0; else if (Ratio1>1) Ratio1=1;
if (Ratio2<0) Ratio2=0; else if (Ratio2>1) Ratio2=1;
if (Ratio3<0) Ratio3=0; else if (Ratio3>1) Ratio3=1;
if ((SR=Ratio1+Ratio2+Ratio3)==0) return Col1;
RGBtoHLS( Col1, &H1, &L1, &S1);
RGBtoHLS( Col2, &H2, &L2, &S2);
RGBtoHLS( Col3, &H3, &L3, &S3);
return rgb=HLStoRGB( (Ratio1*H1+Ratio2*H2+Ratio3*H3)/SR,
(Ratio1*L1+Ratio2*L2+Ratio3*L3)/SR,
(Ratio1*S1+Ratio2*S2+Ratio3*S3)/SR);
}
/******************************************************************************
Q: How do I convert between the HSL (Hue, Saturation, and Luminosity) and RBG color models ?
A: The conversion algorithms presented here come from the book
Fundamentals of Interactive Computer Graphics by Foley and van Dam.
In the example code, HSL values are represented as floating point number in the range 0 to 1.
RGB tridrants use the Windows convention of 0 to 255 of each element.
******************************************************************************/
/******************************************************************************
FUNCTION: RGBtoHLS
PURPOSE: Convert from RGB to HLS
IN: RGB color (0xRRGGBB)
OUT: Hue, Saturation, Luminance from 0 to 1
COPYRIGHT:1995-1997 Robert Mashlan
Modified for LabWindows/CVI, 1999 Guillaume Dargaud
******************************************************************************/
void RGBtoHLS( const COLORREF rgb,
double *H, double *L, double *S ) {
double delta;
double r = (double)((rgb>>16)&0xFF)/255;
double g = (double)((rgb>> 8)&0xFF)/255;
double b = (double)((rgb )&0xFF)/255;
double cmax = MAX3(r,g,b);
double cmin = MIN3(r,g,b);
*L=(cmax+cmin)/2.0;
if(cmax==cmin) *S = *H = 0; // it's really undefined
else {
if(*L < 0.5) *S = (cmax-cmin)/(cmax+cmin);
else *S = (cmax-cmin)/(2.0-cmax-cmin);
delta = cmax - cmin;
if (r==cmax) *H = (g-b)/delta;
else
if(g==cmax) *H = 2.0 +(b-r)/delta;
else *H = 4.0+(r-g)/delta;
*H /= 6.0;
if (*H < 0.0) *H += 1;
}
}
/******************************************************************************
FUNCTION: HueToRGB
PURPOSE: Convert a hue (color) to RGB
COPYRIGHT:1995-1997 Robert Mashlan
Modified for LabWindows/CVI, 1999 Guillaume Dargaud
******************************************************************************/
static double HueToRGB(const double m1, const double m2, double h ) {
if (h<0) h+=1.0;
if (h>1) h-=1.0;
if (6.0*h < 1 ) return (m1+(m2-m1)*h*6.0);
if (2.0*h < 1 ) return m2;
if (3.0*h < 2.0) return (m1+(m2-m1)*((2.0/3.0)-h)*6.0);
return m1;
}
/******************************************************************************
FUNCTION: HLStoRGB
PURPOSE: Convert from HSL to RGB
IN: Hue, Saturation, Luminance from 0 to 1
RETURN: RGB color (0xRRGGBB)
COPYRIGHT:1995-1997 Robert Mashlan
Modified for LabWindows/CVI, 1999 Guillaume Dargaud
******************************************************************************/
typedef unsigned char BYTE; // 8-bit unsigned entity
COLORREF HLStoRGB(const double H, const double L, const double S ) {
double r,g,b;
double m1, m2;
if (S==0) r=g=b=L;
else {
if (L <=0.5) m2 = L*(1.0+S);
else m2 = L+S-L*S;
m1 = 2.0*L-m2;
r = HueToRGB(m1,m2,H+1.0/3.0);
g = HueToRGB(m1,m2,H);
b = HueToRGB(m1,m2,H-1.0/3.0);
}
return MakeRGB((BYTE)(r*255),(BYTE)(g*255),(BYTE)(b*255));
}
/******************************************************************************
FUNCTION: ColorStepsRGB
PURPOSE: Identical to ColorScaleRGB, except that the color is spread on a number
of steps, making for much more readable maps
IN: NbSteps: Number of steps (should be >=2, better around 8)
******************************************************************************/
COLORREF ColorStepsRGB( const COLORREF Col1,
const COLORREF Col2,
const float Ratio, const int NbSteps) {
int R1=(Col1>>16)&0xFF, G1=(Col1>>8)&0xFF, B1=Col1&0xFF;
int R2=(Col2>>16)&0xFF, G2=(Col2>>8)&0xFF, B2=Col2&0xFF;
int Color;
double IR;
if (Ratio<0) IR=0; // Ratio parameter must be between 0 and 1
else if (Ratio>=1) IR=0.999999999999;
else IR=Ratio;
if (NbSteps>1) // Normal ColorScaleRGB if 0
IR=floor(IR*NbSteps)/(NbSteps-1); // Inverted steps
// IR=IR+(1-2*(IR*NbSteps-floor(IR*NbSteps)))/NbSteps; // Inverted steps
Color= (int)(R1+(R2-R1)*IR+0.5)<<16 | // rounding
(int)(G1+(G2-G1)*IR+0.5)<<8 |
(int)(B1+(B2-B1)*IR+0.5);
return Color;
}
/******************************************************************************
FUNCTION: ColorStepsHSL
PURPOSE: Identical to ColorScaleHSL, except that the color is spread on a number
of steps, making for much more readable maps
IN: NbSteps: Number of steps (should be >=2, better around 8)
******************************************************************************/
COLORREF ColorStepsHSL( const COLORREF Col1,
const COLORREF Col2,
const float Ratio, const int NbSteps) {
double H1, H2, S1, S2, L1, L2;
int rgb;
double IR;
if (Ratio<0) IR=0; // Ratio parameter must be between 0 and 1
else if (Ratio>=1) IR=0.999999999999;
else IR=Ratio;
if (NbSteps>1) // Normal ColorScaleHSL if 0
IR=floor(IR*NbSteps)/(NbSteps-1); // Truncated steps
// IR=IR+(1-2*(IR*NbSteps-floor(IR*NbSteps)))/NbSteps; // Inverted steps
RGBtoHLS( Col1, &H1, &L1, &S1);
RGBtoHLS( Col2, &H2, &L2, &S2);
return rgb=HLStoRGB( H1+(H2-H1)*IR, L1+(L2-L1)*IR, S1+(S2-S1)*IR );
} | [
"meandyouftw@gmail.com"
] | meandyouftw@gmail.com |
106592eea9a22691c8f2a98dec1a2be137e03ec9 | a9e03ee1284ab4b24e6fbb0ff196d7a71c8a99f8 | /STM32/TestModules/PointerWithinTest/PointerWithinTest.ino | 7fed9a11c831db6539268a8d6b5113bb13baeb71 | [] | no_license | MabezDev/MabezWatchOS | 35dddc56f950e369573c853b826f8d397d6377bc | 9b2ca981e18b798c16b3954b5629bd2c9be85772 | refs/heads/master | 2020-12-24T06:43:58.246092 | 2017-03-02T18:43:51 | 2017-03-02T18:43:51 | 42,149,172 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,068 | ino | const short SMALL = 0;
const short NORMAL = 1;
const short LARGE = 2;
const short MSG_SIZE[3] = {25,200,750};
short textIndexes[3] = {0,0,0};
char SmallText[50][25];
char NormalText[25][200];
char LargeText[5][750];
void *types[3] = {SmallText,NormalText,LargeText}; // store a pointer of each matrix, later to be casted to a char *
typedef struct {
char packageName[15];
//char title[15];
String title;
short dateReceived[2];
short textLength;
/*
* Add these two vars below to the Notification struct in the OS
*/
char *textPointer; //points to a char array containing the text, replaces the raw text
short textType; // used to find or remove in the correct array
} Notification;
Notification notifications[80];
int notificationIndex = 0;
void setup() {
Serial.begin(9600);
while(!Serial.isConnected());
newNotification("Hello",5,SMALL);
newNotification("Hellooooo222",12,SMALL);
newNotification("Hellooooo333",12,SMALL);
newNotification("Hellooooo444",12,SMALL);
newNotification("Hello this is evidently longer than 25 characters and quite clearly needs to go in a normal notification",104,NORMAL);
newNotification("Whassup this is evidently longer than 25 characters and quite clearly needs to go in a normal notification",104,NORMAL);
newNotification("olleH this is evidently longer than 25 characters and quite clearly needs to go in a normal notification",104,NORMAL);
newNotification("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",574,LARGE);
newNotification("Lorem DIFF1 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",574,LARGE);
newNotification("Lorem DIFF2 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",574,LARGE);
printNotificationTexts();
//printSmallArray();
Serial.println();
removeNotification(2);
Serial.println();
//printSmallArray();
printNotificationTexts();
}
void addTextToNotification(Notification *notification, char *textToSet, short len){
// gives us the location to start writing our new text
char *textPointer = (char*)(types[notification->textType]); //pointer to the first element in the respective array, i.e Small, Normal Large
/*
* Move the pointer along an element at a time using the MSG_SIZE array to get the size of an element based on type,
* then times that by the index we want to add the text to
*/
textPointer += (MSG_SIZE[notification->textType] * textIndexes[notification->textType]);
// write the text to the new found location
setText(textToSet, textPointer, len);
// store a reference to the textpointer for later removal
notification->textPointer = textPointer;
notification->textLength = len;
// Serial.print("Index for type ");
// Serial.print(notification->textType);
// Serial.print(" is ");
// Serial.println(textIndexes[notification->textType]);
textIndexes[notification->textType]++; //increment the respective index
}
void removeTextFromNotification(Notification *notification){
char *arrIndexPtr = (char*)(types[notification->textType]); // find the begining of the respective array, i.e SMALL,NORMAL,LARGE
for(int i=0; i < textIndexes[notification->textType];i++){ // look through all valid elements
if((notification->textPointer - arrIndexPtr) == 0){ // more 'safe way' of comparing pointers to avoid compiler optimisations
Serial.print("Found the text to be wiped at index ");
Serial.print(i);
Serial.print(" in array of type ");
Serial.println(notification->textType);
for ( short c = i ; c < (textIndexes[notification->textType] - 1) ; c++ ){
// move each block into the index before it, basically Array[c] = Array[c+1], but done soley using memory modifying methods
memcpy((char*)(types[notification->textType]) + (c * MSG_SIZE[notification->textType]),(char*)(types[notification->textType]) + ((c+1) * MSG_SIZE[notification->textType]), MSG_SIZE[notification->textType]);
}
textIndexes[notification->textType]--; // remeber to decrease the index once we have removed it
}
arrIndexPtr += MSG_SIZE[notification->textType]; // if we haven't found our pointer, move the next elemnt by moving our pointer along
}
}
void newNotification(char *text, short len ,short type){
// this code can go in getNotification in the OS, should work fine provided we add our new funcs and vars
notifications[notificationIndex].title = "Test title";
notifications[notificationIndex].textType = type;
addTextToNotification(¬ifications[notificationIndex],text,len);
notificationIndex++;
}
void removeNotification(short pos){
if ( pos >= notificationIndex + 1 ){
Serial.println(F("Can't delete notification."));
} else {
//need to zero out the array or stray chars will overlap with notifications
//memset(notifications[pos].title,0,sizeof(notifications[pos].title));
//memset(notifications[pos].packageName,0,sizeof(notifications[pos].packageName));
removeTextFromNotification(¬ifications[pos]);
for ( short c = pos; c < (notificationIndex - 1) ; c++ ){
// Serial.print(notifications[c].textPointer);
// Serial.print(" now equals ");
// Serial.println(notifications[c+1].textPointer);
notifications[c] = notifications[c+1];
}
Serial.print(F("Removed notification at index: "));
Serial.println(pos);
//lower the index
notificationIndex--;
}
}
void printNotificationTexts(){
Serial.println("Notification Texts: ");
for(int i=0; i < notificationIndex; i++){
Serial.print(i);
Serial.print("). ");
Serial.println(notifications[i].textPointer);
}
}
void printSmallArray(){
Serial.print("SmallText (index = ");
Serial.print(textIndexes[0]);
Serial.println(") :");
for(int i=0; i < textIndexes[0]; i++){
Serial.print(i);
Serial.print("). ");
Serial.println(SmallText[i]);
}
}
//void removeTextFromNotification(Notification *notification){
// switch(notification->textType){
// case 0:
// //find our notification to remove using out pointer
// for(int i=0; i < sIndex;i++){
// if(notification->textPointer == SmallText[i]){
// for ( short c = i ; c < (sIndex - 1) ; c++ ){
// strcpy(SmallText[c], SmallText[c+1]);
// }
// sIndex--;
// }
// }
// break;
// case 1:
// //find our notification to remove using out pointer
// for(int i=0; i < nIndex;i++){
// if(notification->textPointer == NormalText[i]){
// for ( short c = i ; c < (nIndex - 1) ; c++ ){
// strcpy(NormalText[c], NormalText[c+1]);
// }
// nIndex--;
// }
// }
// break;
// case 2:
// for(int i=0; i < lIndex;i++){
// if(notification->textPointer == LargeText[i]){
// for ( short c = i ; c < (lIndex - 1) ; c++ ){
// strcpy(LargeText[c], LargeText[c+1]);
// }
// lIndex--;
// }
// }
// }
//}
//void removeNotification(short pos, char *arr, short len){
// //need to zero out the array or stray chars will overlap with notifications
// arr+= pos; // move pointer to pos
// for ( short c = pos ; c < (len - 1) ; c++ ){
// //arr[c] = arr[c+1];
// arr = arr++;
// }
//}
//// TYPE, address of the notification to change, text to set , length of text to set
//void addTextToNotification(Notification *notification, char *textToSet, short len){
// switch(notification->textType){
// case 0:
// Serial.println("SMALL");
// setText(textToSet,SmallText[sIndex],len);
// notification->textPointer = SmallText[sIndex];
// notification->textLength = len;
// sIndex++;
// break;
// case 1:
// Serial.println("NORMAL");
// setText(textToSet,NormalText[nIndex],len);
// notification->textPointer = NormalText[nIndex];
// notification->textLength = len;
// nIndex++;
// break;
// case 2:
// Serial.println("LARGE");
// setText(textToSet,LargeText[lIndex],len);
// notification->textPointer = LargeText[lIndex];
// notification->textLength = len;
// lIndex++;
// break;
// }
//}
void setText(char* c, char* textPtr, short len){
int i = 0;
while(i < len){
// set the actual array value to the next value in the setText String
*(textPtr++) = *(c++);
i++;
}
}
void loop() {
// put your main code here, to run repeatedly:
}
| [
"scottdanielmabin@gmail.com"
] | scottdanielmabin@gmail.com |
59974ce76dfa3a82c6201c069b3c7daa85308556 | e7169e62f55299abe9d1699772843d88eb6bcdf5 | /gpu/GrDrawContext.cpp | 9e80f732c259c7c7bde2778baeff664138e542c8 | [] | no_license | amendgit/skiasnapshot | eda8206290bbc9f9da0771e1b0da5d259d473e85 | 27da382c7d0ed2f3bac392f42b9a2757fb08cab1 | refs/heads/master | 2021-01-12T04:19:35.666192 | 2016-12-29T06:20:07 | 2016-12-29T06:20:07 | 77,588,169 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 52,705 | cpp | /*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrBatchTest.h"
#include "GrColor.h"
#include "GrDrawContext.h"
#include "GrDrawContextPriv.h"
#include "GrDrawingManager.h"
#include "GrFixedClip.h"
#include "GrGpuResourcePriv.h"
#include "GrOvalRenderer.h"
#include "GrPathRenderer.h"
#include "GrPipelineBuilder.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetPriv.h"
#include "GrResourceProvider.h"
#include "SkSurfacePriv.h"
#include "batches/GrBatch.h"
#include "batches/GrClearBatch.h"
#include "batches/GrDrawAtlasBatch.h"
#include "batches/GrDrawVerticesBatch.h"
#include "batches/GrRectBatchFactory.h"
#include "batches/GrNinePatch.h" // TODO Factory
#include "effects/GrRRectEffect.h"
#include "instanced/InstancedRendering.h"
#include "text/GrAtlasTextContext.h"
#include "text/GrStencilAndCoverTextContext.h"
#include "../private/GrAuditTrail.h"
#include "SkLatticeIter.h"
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingManager->getContext())
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
#define ASSERT_SINGLE_OWNER_PRIV \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSingleOwner);)
#define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return; }
#define RETURN_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return false; }
#define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return nullptr; }
using gr_instanced::InstancedRendering;
class AutoCheckFlush {
public:
AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingManager) {
SkASSERT(fDrawingManager);
}
~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
private:
GrDrawingManager* fDrawingManager;
};
bool GrDrawContext::wasAbandoned() const {
return fDrawingManager->wasAbandoned();
}
// In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-progress
// drawTargets to be picked up and added to by drawContexts lower in the call
// stack. When this occurs with a closed drawTarget, a new one will be allocated
// when the drawContext attempts to use it (via getDrawTarget).
GrDrawContext::GrDrawContext(GrContext* context,
GrDrawingManager* drawingMgr,
sk_sp<GrRenderTarget> rt,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* surfaceProps,
GrAuditTrail* auditTrail,
GrSingleOwner* singleOwner)
: fDrawingManager(drawingMgr)
, fRenderTarget(std::move(rt))
, fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget()))
, fContext(context)
, fInstancedPipelineInfo(fRenderTarget.get())
, fColorSpace(std::move(colorSpace))
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
, fAuditTrail(auditTrail)
#ifdef SK_DEBUG
, fSingleOwner(singleOwner)
#endif
{
SkDEBUGCODE(this->validate();)
}
#ifdef SK_DEBUG
void GrDrawContext::validate() const {
SkASSERT(fRenderTarget);
ASSERT_OWNED_RESOURCE(fRenderTarget);
if (fDrawTarget && !fDrawTarget->isClosed()) {
SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget);
}
}
#endif
GrDrawContext::~GrDrawContext() {
ASSERT_SINGLE_OWNER
SkSafeUnref(fDrawTarget);
}
GrDrawTarget* GrDrawContext::getDrawTarget() {
ASSERT_SINGLE_OWNER
SkDEBUGCODE(this->validate();)
if (!fDrawTarget || fDrawTarget->isClosed()) {
fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget.get());
}
return fDrawTarget;
}
bool GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface");
return this->getDrawTarget()->copySurface(fRenderTarget.get(), src, srcRect, dstPoint);
}
void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawText");
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
atlasTextContext->drawText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps,
text, byteLength, x, y, clipBounds);
}
void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPosText");
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
atlasTextContext->drawPosText(fContext, this, clip, grPaint, skPaint, viewMatrix,
fSurfaceProps, text, byteLength, pos, scalarsPerPosition,
offset, clipBounds);
}
void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix, const SkTextBlob* blob,
SkScalar x, SkScalar y,
SkDrawFilter* filter, const SkIRect& clipBounds) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawTextBlob");
GrAtlasTextContext* atlasTextContext = fDrawingManager->getAtlasTextContext();
atlasTextContext->drawTextBlob(fContext, this, clip, skPaint, viewMatrix, fSurfaceProps, blob,
x, y, filter, clipBounds);
}
void GrDrawContext::discard() {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::discard");
AutoCheckFlush acf(fDrawingManager);
this->getDrawTarget()->discard(fRenderTarget.get());
}
void GrDrawContext::clear(const SkIRect* rect,
const GrColor color,
bool canIgnoreRect) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear");
AutoCheckFlush acf(fDrawingManager);
const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height());
SkIRect clippedRect;
bool isFull = false;
if (!rect ||
(canIgnoreRect && fContext->caps()->fullClearIsFree()) ||
rect->contains(rtRect)) {
rect = &rtRect;
isFull = true;
} else {
clippedRect = *rect;
if (!clippedRect.intersect(rtRect)) {
return;
}
rect = &clippedRect;
}
if (fContext->caps()->useDrawInsteadOfClear()) {
// This works around a driver bug with clear by drawing a rect instead.
// The driver will ignore a clear if it is the only thing rendered to a
// target before the target is read.
if (rect == &rtRect) {
this->discard();
}
GrPaint paint;
paint.setColor4f(GrColor4f::FromGrColor(color));
paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect));
} else if (isFull) {
this->getDrawTarget()->fullClear(this->accessRenderTarget(), color);
} else {
sk_sp<GrBatch> batch(GrClearBatch::Make(*rect, color, this->accessRenderTarget()));
this->getDrawTarget()->addBatch(std::move(batch));
}
}
void GrDrawContext::drawPaint(const GrClip& clip,
const GrPaint& origPaint,
const SkMatrix& viewMatrix) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint");
// set rect to be big enough to fill the space, but not super-huge, so we
// don't overflow fixed-point implementations
SkRect r;
r.setLTRB(0, 0,
SkIntToScalar(fRenderTarget->width()),
SkIntToScalar(fRenderTarget->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
// by definition this fills the entire clip, no need for AA
if (paint->isAntiAlias()) {
paint.writable()->setAntiAlias(false);
}
bool isPerspective = viewMatrix.hasPerspective();
// We attempt to map r by the inverse matrix and draw that. mapRect will
// map the four corners and bound them with a new rect. This will not
// produce a correct result for some perspective matrices.
if (!isPerspective) {
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
SkDebugf("Could not invert matrix\n");
return;
}
inverse.mapRect(&r);
this->drawRect(clip, *paint, viewMatrix, r);
} else {
SkMatrix localMatrix;
if (!viewMatrix.invert(&localMatrix)) {
SkDebugf("Could not invert matrix\n");
return;
}
AutoCheckFlush acf(fDrawingManager);
this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &localMatrix, nullptr,
false /* useHWAA */);
}
}
static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& point) {
return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
point.fY >= rect.fTop && point.fY <= rect.fBottom;
}
static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) {
return viewMatrix.preservesRightAngles();
}
static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt,
bool* useHWAA = nullptr) {
if (!paint.isAntiAlias()) {
if (useHWAA) {
*useHWAA = false;
}
return false;
} else {
if (useHWAA) {
*useHWAA = rt->isUnifiedMultisampled();
}
return !rt->isUnifiedMultisampled();
}
}
// Attempts to crop a rect and optional local rect to the clip boundaries.
// Returns false if the draw can be skipped entirely.
static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip,
const SkMatrix& viewMatrix, SkRect* rect,
SkRect* localRect = nullptr) {
if (!viewMatrix.rectStaysRect()) {
return true;
}
SkMatrix inverseViewMatrix;
if (!viewMatrix.invert(&inverseViewMatrix)) {
return false;
}
SkIRect clipDevBounds;
SkRect clipBounds;
SkASSERT(inverseViewMatrix.rectStaysRect());
clip.getConservativeBounds(rt->width(), rt->height(), &clipDevBounds);
inverseViewMatrix.mapRect(&clipBounds, SkRect::Make(clipDevBounds));
if (localRect) {
if (!rect->intersects(clipBounds)) {
return false;
}
const SkScalar dx = localRect->width() / rect->width();
const SkScalar dy = localRect->height() / rect->height();
if (clipBounds.fLeft > rect->fLeft) {
localRect->fLeft += (clipBounds.fLeft - rect->fLeft) * dx;
rect->fLeft = clipBounds.fLeft;
}
if (clipBounds.fTop > rect->fTop) {
localRect->fTop += (clipBounds.fTop - rect->fTop) * dy;
rect->fTop = clipBounds.fTop;
}
if (clipBounds.fRight < rect->fRight) {
localRect->fRight -= (rect->fRight - clipBounds.fRight) * dx;
rect->fRight = clipBounds.fRight;
}
if (clipBounds.fBottom < rect->fBottom) {
localRect->fBottom -= (rect->fBottom - clipBounds.fBottom) * dy;
rect->fBottom = clipBounds.fBottom;
}
return true;
}
return rect->intersect(clipBounds);
}
bool GrDrawContext::drawFilledRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrUserStencilSettings* ss) {
SkRect croppedRect = rect;
if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) {
return true;
}
SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
if (ss) {
pipelineBuilder.setUserStencil(ss);
}
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return true;
}
}
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
// The fill path can handle rotation but not skew.
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
SkRect devBoundRect;
viewMatrix.mapRect(&devBoundRect, croppedRect);
batch.reset(GrRectBatchFactory::CreateAAFill(paint, viewMatrix, rect, croppedRect,
devBoundRect));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
if (ss) {
pipelineBuilder.setUserStencil(ss);
}
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return true;
}
}
} else {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, nullptr, ss,
useHWAA);
return true;
}
return false;
}
void GrDrawContext::drawRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrStyle* style) {
if (!style) {
style = &GrStyle::SimpleFill();
}
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect");
// Path effects should've been devolved to a path in SkGpuDevice
SkASSERT(!style->pathEffect());
AutoCheckFlush acf(fDrawingManager);
const SkStrokeRec& stroke = style->strokeRec();
if (stroke.getStyle() == SkStrokeRec::kFill_Style) {
if (!fContext->caps()->useDrawInsteadOfClear()) {
// Check if this is a full RT draw and can be replaced with a clear. We don't bother
// checking cases where the RT is fully inside a stroke.
SkRect rtRect;
fRenderTarget->getBoundsRect(&rtRect);
// Does the clip contain the entire RT?
if (clip.quickContains(rtRect)) {
SkMatrix invM;
if (!viewMatrix.invert(&invM)) {
return;
}
// Does the rect bound the RT?
SkPoint srcSpaceRTQuad[4];
invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
// Will it blend?
GrColor clearColor;
if (paint.isConstantBlendedColor(&clearColor)) {
this->clear(nullptr, clearColor, true);
return;
}
}
}
}
if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) {
return;
}
} else if (stroke.getStyle() == SkStrokeRec::kStroke_Style ||
stroke.getStyle() == SkStrokeRec::kHairline_Style) {
if ((!rect.width() || !rect.height()) &&
SkStrokeRec::kHairline_Style != stroke.getStyle()) {
SkScalar r = stroke.getWidth() / 2;
// TODO: Move these stroke->fill fallbacks to GrShape?
switch (stroke.getJoin()) {
case SkPaint::kMiter_Join:
this->drawRect(clip, paint, viewMatrix,
{rect.fLeft - r, rect.fTop - r,
rect.fRight + r, rect.fBottom + r},
&GrStyle::SimpleFill());
return;
case SkPaint::kRound_Join:
// Raster draws nothing when both dimensions are empty.
if (rect.width() || rect.height()){
SkRRect rrect = SkRRect::MakeRectXY(rect.makeOutset(r, r), r, r);
this->drawRRect(clip, paint, viewMatrix, rrect, GrStyle::SimpleFill());
return;
}
case SkPaint::kBevel_Join:
if (!rect.width()) {
this->drawRect(clip, paint, viewMatrix,
{rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom},
&GrStyle::SimpleFill());
} else {
this->drawRect(clip, paint, viewMatrix,
{rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r},
&GrStyle::SimpleFill());
}
return;
}
}
bool useHWAA;
bool snapToPixelCenters = false;
SkAutoTUnref<GrDrawBatch> batch;
GrColor color = paint.getColor();
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
// The stroke path needs the rect to remain axis aligned (no rotation or skew).
if (viewMatrix.rectStaysRect()) {
batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, stroke));
}
} else {
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
// hairline rects. We jam all the vertices to pixel centers to avoid this, but not
// when MSAA is enabled because it can cause ugly artifacts.
snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Style &&
!fRenderTarget->isUnifiedMultisampled();
batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect,
stroke, snapToPixelCenters));
}
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
if (snapToPixelCenters) {
pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
snapToPixelCenters);
}
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
SkPath path;
path.setIsVolatile(true);
path.addRect(rect);
this->internalDrawPath(clip, paint, viewMatrix, path, *style);
}
void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fDrawContext->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::clearStencilClip");
AutoCheckFlush acf(fDrawContext->fDrawingManager);
fDrawContext->getDrawTarget()->clearStencilClip(rect, insideClip,
fDrawContext->accessRenderTarget());
}
void GrDrawContextPriv::stencilPath(const GrClip& clip,
bool useHWAA,
const SkMatrix& viewMatrix,
const GrPath* path) {
fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, useHWAA, viewMatrix, path);
}
void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,
const GrUserStencilSettings* ss,
bool useHWAA,
const SkMatrix& viewMatrix,
const SkRect& rect) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fDrawContext->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencilRect");
AutoCheckFlush acf(fDrawContext->fDrawingManager);
GrPaint paint;
paint.setAntiAlias(useHWAA);
paint.setXPFactory(GrDisableColorXPFactory::Make());
fDrawContext->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nullptr, ss, useHWAA);
}
bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip,
const GrUserStencilSettings* ss,
SkRegion::Op op,
bool invert,
bool doAA,
const SkMatrix& viewMatrix,
const SkRect& rect) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_FALSE_IF_ABANDONED_PRIV
SkDEBUGCODE(fDrawContext->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAndStencilRect");
AutoCheckFlush acf(fDrawContext->fDrawingManager);
GrPaint paint;
paint.setAntiAlias(doAA);
paint.setCoverageSetOpXPFactory(op, invert);
if (fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss)) {
return true;
}
SkPath path;
path.setIsVolatile(true);
path.addRect(rect);
return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path);
}
void GrDrawContext::fillRectToRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkRect& localRect) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect");
SkRect croppedRect = rectToDraw;
SkRect croppedLocalRect = localRect;
if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect, &croppedLocalRect)) {
return;
}
AutoCheckFlush acf(fDrawingManager);
bool useHWAA;
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
croppedLocalRect, paint.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect,
nullptr, nullptr, useHWAA);
return;
}
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(),
viewMatrix,
croppedRect,
croppedLocalRect));
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->drawBatch(pipelineBuilder, clip, batch);
return;
}
SkMatrix viewAndUnLocalMatrix;
if (!viewAndUnLocalMatrix.setRectToRect(localRect, rectToDraw, SkMatrix::kFill_ScaleToFit)) {
SkDebugf("fillRectToRect called with empty local matrix.\n");
return;
}
viewAndUnLocalMatrix.postConcat(viewMatrix);
SkPath path;
path.setIsVolatile(true);
path.addRect(localRect);
this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
}
void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkMatrix& localMatrix) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatrix");
SkRect croppedRect = rectToDraw;
if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) {
return;
}
AutoCheckFlush acf(fDrawingManager);
bool useHWAA;
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
localMatrix, paint.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
&localMatrix, nullptr, useHWAA);
return;
}
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix,
localMatrix, croppedRect));
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
SkMatrix viewAndUnLocalMatrix;
if (!localMatrix.invert(&viewAndUnLocalMatrix)) {
SkDebugf("fillRectWithLocalMatrix called with degenerate local matrix.\n");
return;
}
viewAndUnLocalMatrix.postConcat(viewMatrix);
SkPath path;
path.setIsVolatile(true);
path.addRect(rectToDraw);
path.transform(localMatrix);
this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
}
void GrDrawContext::drawVertices(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
GrPrimitiveType primitiveType,
int vertexCount,
const SkPoint positions[],
const SkPoint texCoords[],
const GrColor colors[],
const uint16_t indices[],
int indexCount) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawVertices");
AutoCheckFlush acf(fDrawingManager);
// TODO clients should give us bounds
SkRect bounds;
if (!bounds.setBoundsCheck(positions, vertexCount)) {
SkDebugf("drawVertices call empty bounds\n");
return;
}
viewMatrix.mapRect(&bounds);
// If we don't have AA then we outset for a half pixel in each direction to account for
// snapping. We also do this for the "hair" primitive types: lines and points since they have
// a 1 pixel thickness in device space.
if (!paint.isAntiAlias() || GrIsPrimTypeLines(primitiveType) ||
kPoints_GrPrimitiveType == primitiveType) {
bounds.outset(0.5f, 0.5f);
}
SkAutoTUnref<GrDrawBatch> batch(new GrDrawVerticesBatch(paint.getColor(),
primitiveType, viewMatrix, positions,
vertexCount, indices, indexCount,
colors, texCoords, bounds));
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawAtlas(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
int spriteCount,
const SkRSXform xform[],
const SkRect texRect[],
const SkColor colors[]) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas");
AutoCheckFlush acf(fDrawingManager);
SkAutoTUnref<GrDrawBatch> batch(new GrDrawAtlasBatch(paint.getColor(), viewMatrix, spriteCount,
xform, texRect, colors));
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawRRect(const GrClip& origClip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const GrStyle& style) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect");
if (rrect.isEmpty()) {
return;
}
GrNoClip noclip;
const GrClip* clip = &origClip;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// The Android framework frequently clips rrects to themselves where the clip is non-aa and the
// draw is aa. Since our lower level clip code works from batch bounds, which are SkRects, it
// doesn't detect that the clip can be ignored (modulo antialiasing). The following test
// attempts to mitigate the stencil clip cost but will only help when the entire clip stack
// can be ignored. We'd prefer to fix this in the framework by removing the clips calls.
SkRRect devRRect;
if (rrect.transform(viewMatrix, &devRRect) && clip->quickContains(devRRect)) {
clip = &noclip;
}
#endif
SkASSERT(!style.pathEffect()); // this should've been devolved to a path in SkGpuDevice
AutoCheckFlush acf(fDrawingManager);
const SkStrokeRec stroke = style.strokeRec();
bool useHWAA;
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
stroke.isFillStyle()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRRect(rrect, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch);
return;
}
}
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.getColor(),
viewMatrix,
rrect,
stroke,
shaderCaps));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch);
return;
}
}
SkPath path;
path.setIsVolatile(true);
path.addRRect(rrect);
this->internalDrawPath(*clip, paint, viewMatrix, path, style);
}
bool GrDrawContext::drawFilledDRRect(const GrClip& clip,
const GrPaint& paintIn,
const SkMatrix& viewMatrix,
const SkRRect& origOuter,
const SkRRect& origInner) {
SkASSERT(!origInner.isEmpty());
SkASSERT(!origOuter.isEmpty());
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
bool useHWAA;
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordDRRect(origOuter, origInner, viewMatrix,
paintIn.getColor(), paintIn.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paintIn, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return true;
}
}
bool applyAA = paintIn.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled();
GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdgeType :
kInverseFillBW_GrProcessorEdgeType;
GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType :
kFillBW_GrProcessorEdgeType;
SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter);
SkMatrix inverseVM;
if (!viewMatrix.isIdentity()) {
if (!origInner.transform(viewMatrix, inner.writable())) {
return false;
}
if (!origOuter.transform(viewMatrix, outer.writable())) {
return false;
}
if (!viewMatrix.invert(&inverseVM)) {
return false;
}
} else {
inverseVM.reset();
}
GrPaint grPaint(paintIn);
grPaint.setAntiAlias(false);
// TODO these need to be a geometry processors
sk_sp<GrFragmentProcessor> innerEffect(GrRRectEffect::Make(innerEdgeType, *inner));
if (!innerEffect) {
return false;
}
sk_sp<GrFragmentProcessor> outerEffect(GrRRectEffect::Make(outerEdgeType, *outer));
if (!outerEffect) {
return false;
}
grPaint.addCoverageFragmentProcessor(std::move(innerEffect));
grPaint.addCoverageFragmentProcessor(std::move(outerEffect));
SkRect bounds = outer->getBounds();
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseVM);
return true;
}
void GrDrawContext::drawDRRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& outer,
const SkRRect& inner) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawDRRect");
SkASSERT(!outer.isEmpty());
SkASSERT(!inner.isEmpty());
AutoCheckFlush acf(fDrawingManager);
if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) {
return;
}
SkPath path;
path.setIsVolatile(true);
path.addRRect(inner);
path.addRRect(outer);
path.setFillType(SkPath::kEvenOdd_FillType);
this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill());
}
///////////////////////////////////////////////////////////////////////////////
void GrDrawContext::drawOval(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& oval,
const GrStyle& style) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval");
if (oval.isEmpty()) {
return;
}
SkASSERT(!style.pathEffect()); // this should've been devolved to a path in SkGpuDevice
AutoCheckFlush acf(fDrawingManager);
const SkStrokeRec& stroke = style.strokeRec();
bool useHWAA;
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
stroke.isFillStyle()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordOval(oval, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
oval,
stroke,
shaderCaps));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
SkPath path;
path.setIsVolatile(true);
path.addOval(oval);
this->internalDrawPath(clip, paint, viewMatrix, path, style);
}
void GrDrawContext::drawImageLattice(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
int imageWidth,
int imageHeight,
std::unique_ptr<SkLatticeIter> iter,
const SkRect& dst) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageLattice");
AutoCheckFlush acf(fDrawingManager);
SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), viewMatrix,
imageWidth, imageHeight,
std::move(iter), dst));
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
void GrDrawContext::prepareForExternalIO() {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::prepareForExternalIO");
ASSERT_OWNED_RESOURCE(fRenderTarget);
fDrawingManager->getContext()->prepareSurfaceForExternalIO(fRenderTarget.get());
}
void GrDrawContext::drawNonAAFilledRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix,
const GrUserStencilSettings* ss,
bool useHWAA) {
SkASSERT(!useHWAA || this->isStencilBufferMultisampled());
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect, localRect,
localMatrix));
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
if (ss) {
pipelineBuilder.setUserStencil(ss);
}
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
// Can 'path' be drawn as a pair of filled nested rectangles?
static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path, SkRect rects[2]) {
if (path.isInverseFillType()) {
return false;
}
// TODO: this restriction could be lifted if we were willing to apply
// the matrix to all the points individually rather than just to the rect
if (!viewMatrix.rectStaysRect()) {
return false;
}
SkPath::Direction dirs[2];
if (!path.isNestedFillRects(rects, dirs)) {
return false;
}
if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) {
// The two rects need to be wound opposite to each other
return false;
}
// Right now, nested rects where the margin is not the same width
// all around do not render correctly
const SkScalar* outer = rects[0].asScalars();
const SkScalar* inner = rects[1].asScalars();
bool allEq = true;
SkScalar margin = SkScalarAbs(outer[0] - inner[0]);
bool allGoE1 = margin >= SK_Scalar1;
for (int i = 1; i < 4; ++i) {
SkScalar temp = SkScalarAbs(outer[i] - inner[i]);
if (temp < SK_Scalar1) {
allGoE1 = false;
}
if (!SkScalarNearlyEqual(margin, temp)) {
allEq = false;
}
}
return allEq || allGoE1;
}
void GrDrawContext::drawPath(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkPath& path,
const GrStyle& style) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPath");
if (path.isEmpty()) {
if (path.isInverseFillType()) {
this->drawPaint(clip, paint, viewMatrix);
}
return;
}
AutoCheckFlush acf(fDrawingManager);
bool useHWAA;
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && !style.pathEffect()) {
if (style.isSimpleFill() && !path.isConvex()) {
// Concave AA paths are expensive - try to avoid them for special cases
SkRect rects[2];
if (fills_as_nested_rects(viewMatrix, path, rects)) {
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFillNestedRects(
paint.getColor(), viewMatrix, rects));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
return;
}
}
SkRect ovalRect;
bool isOval = path.isOval(&ovalRect);
if (isOval && !path.isInverseFillType()) {
GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
ovalRect,
style.strokeRec(),
shaderCaps));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
return;
}
}
}
// Note that internalDrawPath may sw-rasterize the path into a scratch texture.
// Scratch textures can be recycled after they are returned to the texture
// cache. This presents a potential hazard for buffered drawing. However,
// the writePixels that uploads to the scratch will perform a flush so we're
// OK.
this->internalDrawPath(clip, paint, viewMatrix, path, style);
}
bool GrDrawContextPriv::drawAndStencilPath(const GrFixedClip& clip,
const GrUserStencilSettings* ss,
SkRegion::Op op,
bool invert,
bool doAA,
const SkMatrix& viewMatrix,
const SkPath& path) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_FALSE_IF_ABANDONED_PRIV
SkDEBUGCODE(fDrawContext->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPath");
if (path.isEmpty() && path.isInverseFillType()) {
this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(),
SkRect::MakeIWH(fDrawContext->width(),
fDrawContext->height()));
return true;
}
AutoCheckFlush acf(fDrawContext->fDrawingManager);
// An Assumption here is that path renderer would use some form of tweaking
// the src color (either the input alpha or in the frag shader) to implement
// aa. If we have some future driver-mojo path AA that can do the right
// thing WRT to the blend then we'll need some query on the PR.
bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisampled();
bool hasUserStencilSettings = !ss->isUnused();
bool isStencilBufferMSAA = fDrawContext->fRenderTarget->isStencilBufferMultisampled();
const GrPathRendererChain::DrawType type =
useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType
: GrPathRendererChain::kColor_DrawType;
GrShape shape(path, GrStyle::SimpleFill());
GrPathRenderer::CanDrawPathArgs canDrawArgs;
canDrawArgs.fShaderCaps = fDrawContext->fDrawingManager->getContext()->caps()->shaderCaps();
canDrawArgs.fViewMatrix = &viewMatrix;
canDrawArgs.fShape = &shape;
canDrawArgs.fAntiAlias = useCoverageAA;
canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings;
canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA;
// Don't allow the SW renderer
GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawArgs, false, type);
if (!pr) {
return false;
}
GrPaint paint;
paint.setCoverageSetOpXPFactory(op, invert);
GrPathRenderer::DrawPathArgs args;
args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resourceProvider();
args.fPaint = &paint;
args.fUserStencilSettings = ss;
args.fDrawContext = fDrawContext;
args.fClip = &clip;
args.fViewMatrix = &viewMatrix;
args.fShape = &shape;
args.fAntiAlias = useCoverageAA;
args.fGammaCorrect = fDrawContext->isGammaCorrect();
pr->drawPath(args);
return true;
}
SkBudgeted GrDrawContextPriv::isBudgeted() const {
ASSERT_SINGLE_OWNER_PRIV
if (fDrawContext->wasAbandoned()) {
return SkBudgeted::kNo;
}
SkDEBUGCODE(fDrawContext->validate();)
return fDrawContext->fRenderTarget->resourcePriv().isBudgeted();
}
void GrDrawContext::internalDrawPath(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkPath& path,
const GrStyle& style) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkASSERT(!path.isEmpty());
bool useCoverageAA = should_apply_coverage_aa(paint, fRenderTarget.get());
constexpr bool kHasUserStencilSettings = false;
bool isStencilBufferMSAA = fRenderTarget->isStencilBufferMultisampled();
const GrPathRendererChain::DrawType type =
useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType
: GrPathRendererChain::kColor_DrawType;
GrShape shape(path, style);
if (shape.isEmpty()) {
return;
}
GrPathRenderer::CanDrawPathArgs canDrawArgs;
canDrawArgs.fShaderCaps = fDrawingManager->getContext()->caps()->shaderCaps();
canDrawArgs.fViewMatrix = &viewMatrix;
canDrawArgs.fShape = &shape;
canDrawArgs.fAntiAlias = useCoverageAA;
canDrawArgs.fHasUserStencilSettings = kHasUserStencilSettings;
canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA;
// Try a 1st time without applying any of the style to the geometry (and barring sw)
GrPathRenderer* pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type);
SkScalar styleScale = GrStyle::MatrixToScaleFactor(viewMatrix);
if (!pr && shape.style().pathEffect()) {
// It didn't work above, so try again with the path effect applied.
shape = shape.applyStyle(GrStyle::Apply::kPathEffectOnly, styleScale);
if (shape.isEmpty()) {
return;
}
pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type);
}
if (!pr) {
if (shape.style().applies()) {
shape = shape.applyStyle(GrStyle::Apply::kPathEffectAndStrokeRec, styleScale);
if (shape.isEmpty()) {
return;
}
}
// This time, allow SW renderer
pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type);
}
if (!pr) {
#ifdef SK_DEBUG
SkDebugf("Unable to find path renderer compatible with path.\n");
#endif
return;
}
GrPathRenderer::DrawPathArgs args;
args.fResourceProvider = fDrawingManager->getContext()->resourceProvider();
args.fPaint = &paint;
args.fUserStencilSettings = &GrUserStencilSettings::kUnused;
args.fDrawContext = this;
args.fClip = &clip;
args.fViewMatrix = &viewMatrix;
args.fShape = canDrawArgs.fShape;
args.fAntiAlias = useCoverageAA;
args.fGammaCorrect = this->isGammaCorrect();
pr->drawPath(args);
}
void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip& clip,
GrDrawBatch* batch) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
| [
"erxiangbo@wacai.com"
] | erxiangbo@wacai.com |
7af16ac5eec9ad03d5b4f010b7ec04c4808fbe6a | cf506e4b0ae3353431c13cf00998fee705f14532 | /NesEmu/main.cpp | c991fd3900d75436d1f4adbe82ebf54ac2b6e9a8 | [] | no_license | KareshiKraise/Kraise-code | da9bc41aac893b5248f4ce87a335164ac63b503b | 80776157c7e9489aa9e9491fb83df56f1f758881 | refs/heads/master | 2020-06-13T06:05:19.595807 | 2017-03-07T14:03:46 | 2017-03-07T14:03:46 | 75,422,968 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 286 | cpp | #include <iostream>
#include "KR_Nes.h"
int main(int argc, char *argv[])
{
KR_Nes nes;
if (nes.loadRom("duck_tales.nes") == LOAD_OK)
{
std::cout << "rom carregada com sucesso" << std::endl;
}
std::cout << (int)nes.m_cart.mapper;
int c;
std::cin >> c;
return 0;
}
| [
"vitormoraesaranha@gmail.com"
] | vitormoraesaranha@gmail.com |
8c3f2ce030d19ec3e4cf4127758abdd24fdfb84e | 6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849 | /sstd_boost/sstd/boost/property_tree/id_translator.hpp | c86bdaaab2b2a862e3f2f8d60e38e3e7198e8257 | [
"BSL-1.0"
] | permissive | KqSMea8/sstd_library | 9e4e622e1b01bed5de7322c2682539400d13dd58 | 0fcb815f50d538517e70a788914da7fbbe786ce1 | refs/heads/master | 2020-05-03T21:07:01.650034 | 2019-04-01T00:10:47 | 2019-04-01T00:10:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,614 | hpp | // ----------------------------------------------------------------------------
// Copyright (C) 2009 Sebastian Redl
//
// 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)
//
// For more information, see www.boost.org
// ----------------------------------------------------------------------------
#ifndef BOOST_PROPERTY_TREE_ID_TRANSLATOR_HPP_INCLUDED
#define BOOST_PROPERTY_TREE_ID_TRANSLATOR_HPP_INCLUDED
#include <sstd/boost/property_tree/ptree_fwd.hpp>
#include <sstd/boost/optional.hpp>
#include <string>
namespace boost { namespace property_tree
{
/// Simple implementation of the Translator concept. It does no translation.
template <typename T>
struct id_translator
{
typedef T internal_type;
typedef T external_type;
boost::optional<T> get_value(const T &v) { return v; }
boost::optional<T> put_value(const T &v) { return v; }
};
// This is the default translator whenever you get two equal types.
template <typename T>
struct translator_between<T, T>
{
typedef id_translator<T> type;
};
// A more specific specialization for std::basic_string. Otherwise,
// stream_translator's specialization wins.
template <typename Ch, typename Traits, typename Alloc>
struct translator_between< std::basic_string<Ch, Traits, Alloc>,
std::basic_string<Ch, Traits, Alloc> >
{
typedef id_translator< std::basic_string<Ch, Traits, Alloc> > type;
};
}}
#endif
| [
"zhaixueqiang@hotmail.com"
] | zhaixueqiang@hotmail.com |
ed718cff539dd30b3b7e36b9b6b811a8beb6cd23 | 47efc544b33368a8f79c5dfe8ef00ca503e8f3ed | /BinaryTreePaths.cpp | 078c742ba9345dc31469c30d58781141414e34c4 | [] | no_license | ruzhuxiaogu/MyLeetCode | a27bb28c3b485f4b92cbd0dcd471a170e2f897a2 | e0d06c18e1d91546616715d660abd2786f26e8bf | refs/heads/master | 2021-01-10T21:50:40.684657 | 2015-10-06T02:34:09 | 2015-10-06T02:34:09 | 42,800,164 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 988 | cpp | class Solution{
public:
vector<string> binaryTreePaths(TreeNode* root){
string str="";
vector<string> vec;
//如果是一棵空树,返回空的容器。
if(!root) return vec;
searchBinaryTreePaths(vec,str,root);
return vec;
}
//注意一定要加引用 & 符号
void searchBinaryTreePaths(vector<string> &vec,string str,TreeNode* root){
stringstream ss;
//叶子节点
if(!root->left&&!root->right)
{
ss<<root->val;//将int转化为string
str+=ss.str();
vec.push_back(str);
return ;
}
//非叶子节点
ss<<root->val;//将int转化为string
str+=ss.str()+"->";
//左子树不为空
if(root->left){
searchBinaryTreePaths(vec,str,root->left);
}
//右子树不为空
if(root->right){
searchBinaryTreePaths(vec,str,root->right);
}
}
};
| [
"m18354276092@163.com"
] | m18354276092@163.com |
da27549d0408883682d72362d1c998b43c8f9aad | 21b7d8820a0fbf8350d2d195f711c35ce9865a21 | /Vladik and Complicated Book.cpp | 862d6bf26083f5b4f35432e8faf690bdc24e25c8 | [] | no_license | HarshitCd/Codeforces-Solutions | 16e20619971c08e036bb19186473e3c77b9c4634 | d8966129b391875ecf93bc3c03fc7b0832a2a542 | refs/heads/master | 2022-12-25T22:00:17.077890 | 2020-10-12T16:18:20 | 2020-10-12T16:18:20 | 286,409,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 433 | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n, m, l, r, x, c;
cin>>n>>m;
vector<int> v(n), u;
map<int, int> ma;
for(int i=0; i<n; i++){
cin>>v[i];
ma[i+1] = v[i];
}
while(m--){
cin>>l>>r>>x;
c=0;
for(int i=l-1; i<r; i++)
if(v[x-1]>v[i]) c++;
if(v[l+c-1]==v[x-1]) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
| [
"harshitcd@gmail.com"
] | harshitcd@gmail.com |
b3636f3457423aae175ccb92aefb860ae557d34b | a44fb3ced30b31c1b57d325c6c202d3182e61e0a | /HMaps.cpp | 4b0b9b28d292d15e4a2e8ede665305095bc32153 | [] | no_license | AcTap/testing | 6fce6ebc2768e56d6a0d83846e5e4c19cafcfc8f | bfbe827f309e14371e48d0fc1b25155333e7afc2 | refs/heads/master | 2021-01-18T21:12:21.980591 | 2016-04-18T18:47:47 | 2016-04-18T18:47:47 | 24,942,208 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,328 | cpp | // HMaps.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
struct MAP
{
float map[128][64];
}
;
void DiamondH(int ax,int ay,int bx,int by,MAP& it);
void DiamondV(int ax, int ay, int bx, int by, MAP& it);
void Square(int ax, int ay, int bx, int by, MAP& it);
void DiamondSquare(int ax, int ay, int bx, int by, MAP& it);
int _tmain(int argc, _TCHAR* argv[])
{
std::srand(time(0));
MAP terra;
for (int i = 0; i < 128; i++)
{
for (int k = 0; k < 64; k++)
{
terra.map[i][k] = 0;
}
}
terra.map[0][0] = std::rand() % 255 /255.0;
terra.map[0][63] = std::rand() % 255 / 255.0;
terra.map[127][0] = std::rand() % 255 / 255.0;
terra.map[127][63] = std::rand() % 255 / 255.0;
DiamondSquare(0, 0, 64, 128, terra);
return 0;
}
void DiamondH(int ax, int ay, int bx, int by, MAP& it)
{
int cx = ax;
int cy = ay;
int dx = (bx + ax) / 2;
int dy = (ay+(ay - by) / 2) % 128;
int fx = bx;
int fy = ay;
int ex = dx;
int ey = (by+(by - ay) / 2) % 128;
return;
}
void Square(int ax, int ay, int bx, int by, MAP& it)
{
float height = (it.map[ay][ax] + it.map[ay][bx] + it.map[by][ax] + it.map[by][bx]) / 4;
height += std::rand() % 255 / 255.0;
int x = (bx + ax) / 2;
int y = (by + ay) / 2;
it.map[y][x] = height;
return;
} | [
"Taras.Borisenko@motorolasolutions.com"
] | Taras.Borisenko@motorolasolutions.com |
83602a78d4fc85fbe1772d332015f64cf6b4765d | d0985731c45024388a2d8938a9e8a52dc7f985f3 | /src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | 4443b003207e8953b39b8c3293b226ca58772234 | [] | no_license | Naios/MythCore | 1ac1096ad8afefdf743ed206e10c2432f7f57bed | 38acab976959eed1167b6b4438ce7c7075156dd8 | refs/heads/master | 2023-08-24T08:26:26.657783 | 2012-06-07T05:24:00 | 2012-06-07T05:24:00 | 4,604,578 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 44,829 | cpp | /*
* Copyright (C) 2008 - 2011 Trinity <http://www.trinitycore.org/>
*
* Copyright (C) 2010 - 2012 Myth Project <http://mythprojectnetwork.blogspot.com/>
*
* Myth Project's source is based on the Trinity Project source, you can find the
* link to that easily in Trinity Copyrights. Myth Project is a private community.
* To get access, you either have to donate or pass a developer test.
* You can't share Myth Project's sources! Only for personal use.
*/
#include "ObjectMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "BattlegroundMgr.h"
#include "Battleground.h"
#include "BattlegroundEY.h"
#include "Creature.h"
#include "Language.h"
#include "Object.h"
#include "Player.h"
#include "Util.h"
// these variables aren't used outside of this file, so declare them only here
uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
330, // normal honor
200 // holiday
};
BattlegroundEY::BattlegroundEY()
{
m_BuffChange = true;
m_BgObjects.resize(BG_EY_OBJECT_MAX);
m_BgCreatures.resize(BG_EY_CREATURES_MAX);
m_Points_Trigger[FEL_REAVER] = TR_FEL_REAVER_BUFF;
m_Points_Trigger[BLOOD_ELF] = TR_BLOOD_ELF_BUFF;
m_Points_Trigger[DRAENEI_RUINS] = TR_DRAENEI_RUINS_BUFF;
m_Points_Trigger[MAGE_TOWER] = TR_MAGE_TOWER_BUFF;
m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_BG_EY_START_TWO_MINUTES;
m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_EY_START_ONE_MINUTE;
m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_EY_START_HALF_MINUTE;
m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_EY_HAS_BEGUN;
}
BattlegroundEY::~BattlegroundEY() { }
void BattlegroundEY::Update(uint32 diff)
{
Battleground::Update(diff);
if(GetStatus() == STATUS_IN_PROGRESS)
{
m_PointAddingTimer -= diff;
if(m_PointAddingTimer <= 0)
{
m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME;
if(m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0)
AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]);
if(m_TeamPointsCount[BG_TEAM_HORDE] > 0)
AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]);
}
if(m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND)
{
m_FlagsTimer -= diff;
if(m_FlagsTimer < 0)
{
m_FlagsTimer = 0;
if(m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN)
RespawnFlag(true);
else
RespawnFlagAfterDrop();
}
}
m_TowerCapCheckTimer -= diff;
if(m_TowerCapCheckTimer <= 0)
{
this->CheckSomeoneJoinedPoint();
this->CheckSomeoneLeftPoint();
this->UpdatePointStatuses();
m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME;
}
}
if(GetStatus() == STATUS_WAIT_JOIN)
{
m_CheatersCheckTimer -= diff;
if(m_CheatersCheckTimer <= 0)
{
for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player* pPlayer = sObjectMgr->GetPlayer(itr->first);
if(!pPlayer || !pPlayer->IsInWorld())
continue;
if(pPlayer->GetPositionZ() < 1249)
{
if(pPlayer->GetTeam() == HORDE)
pPlayer->TeleportTo(566, 1807.73f, 1539.41f, 1267.63f, pPlayer->GetOrientation(), 0);
else
pPlayer->TeleportTo(566, 2523.68f, 1596.59f, 1269.35f, pPlayer->GetOrientation(), 0);
}
}
m_CheatersCheckTimer = 3000;
}
}
}
void BattlegroundEY::StartingEventCloseDoors()
{
SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY);
SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_IMMEDIATELY);
for(uint32 i = BG_EY_OBJECT_A_BANNER_FEL_REAVER_CENTER; i < BG_EY_OBJECT_MAX; ++i)
SpawnBGObject(i, RESPAWN_ONE_DAY);
}
void BattlegroundEY::StartingEventOpenDoors()
{
SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_ONE_DAY);
SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_ONE_DAY);
for(uint32 i = BG_EY_OBJECT_N_BANNER_FEL_REAVER_CENTER; i <= BG_EY_OBJECT_FLAG_NETHERSTORM; ++i)
SpawnBGObject(i, RESPAWN_IMMEDIATELY);
for(uint32 i = 0; i < EY_POINTS_MAX; ++i)
{
//randomly spawn buff
uint8 buff = urand(0, 2);
SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + buff + i * 3, RESPAWN_IMMEDIATELY);
}
}
void BattlegroundEY::AddPoints(uint32 Team, uint32 Points)
{
BattlegroundTeamId team_index = GetTeamIndexByTeamId(Team);
m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points;
if(m_HonorScoreTics[team_index] >= m_HonorTics)
{
RewardHonorToTeam(GetBonusHonorFromKill(1), Team);
m_HonorScoreTics[team_index] -= m_HonorTics;
}
UpdateTeamScore(Team);
}
void BattlegroundEY::CheckSomeoneJoinedPoint()
{
GameObject* obj = NULL;
for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(m_BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if(obj)
{
uint8 j = 0;
while(j < m_PlayersNearPoint[EY_POINTS_MAX].size())
{
Player* plr = sObjectMgr->GetPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]);
if(!plr)
{
sLog->outError("BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j]));
++j;
continue;
}
if(plr->CanCaptureTowerPoint() && plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
{
//player joined point!
//show progress bar
UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, plr);
UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], plr);
UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, plr);
//add player to point
m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]);
//remove player from "free space"
m_PlayersNearPoint[EY_POINTS_MAX].erase(m_PlayersNearPoint[EY_POINTS_MAX].begin() + j);
}
else
++j;
}
}
}
}
void BattlegroundEY::CheckSomeoneLeftPoint()
{
//reset current point counts
for(uint8 i = 0; i < 2*EY_POINTS_MAX; ++i)
m_CurrentPointPlayersCount[i] = 0;
GameObject* obj = NULL;
for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(m_BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if(obj)
{
uint8 j = 0;
while(j < m_PlayersNearPoint[i].size())
{
Player* plr = sObjectMgr->GetPlayer(m_PlayersNearPoint[i][j]);
if(!plr)
{
sLog->outError("BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j]));
//move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
++j;
continue;
}
if(!plr->CanCaptureTowerPoint() || !plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
//move player out of point (add him to players that are out of points
{
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr);
}
else
{
//player is neat flag, so update count:
m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(plr->GetTeam())]++;
++j;
}
}
}
}
}
void BattlegroundEY::UpdatePointStatuses()
{
_400Ally40Horde = 0;
for(uint8 point = 0; point < EY_POINTS_MAX; ++point)
{
if(m_PlayersNearPoint[point].empty())
continue;
//count new point bar status:
m_PointBarStatus[point] += (m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] < BG_EY_POINT_MAX_CAPTURERS_COUNT) ? m_CurrentPointPlayersCount[2 * point] - m_CurrentPointPlayersCount[2 * point + 1] : BG_EY_POINT_MAX_CAPTURERS_COUNT;
if(m_PointBarStatus[point] > BG_EY_PROGRESS_BAR_ALI_CONTROLLED) {
m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_ALI_CONTROLLED;
_400Ally40Horde += 10;
} else if(m_PointBarStatus[point] < BG_EY_PROGRESS_BAR_HORDE_CONTROLLED) {
_400Ally40Horde += 100;
m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED;
}
uint32 pointOwnerTeamId = 0;
//find which team should own this point
if(m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW)
pointOwnerTeamId = HORDE;
else if(m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH)
pointOwnerTeamId = ALLIANCE;
else
pointOwnerTeamId = EY_POINT_NO_OWNER;
for(uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i)
{
Player* plr = sObjectMgr->GetPlayer(m_PlayersNearPoint[point][i]);
if(plr)
{
this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr);
//if point owner changed we must evoke event!
if(pointOwnerTeamId != m_PointOwnedByTeam[point])
{
//point was uncontrolled and player is from team which captured point
if(m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId)
this->EventTeamCapturedPoint(plr, point);
//point was under control and player isn't from team which controlled it
if(m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point])
this->EventTeamLostPoint(plr, point);
}
if(point == FEL_REAVER && m_PointOwnedByTeam[point] == plr->GetTeam()) // hack fix for Fel Reaver Ruins
{
if(m_FlagState && GetFlagPickerGUID() == plr->GetGUID())
if(plr->GetDistance2d(2044.0f,1730.0f) < 7.0f)
EventPlayerCapturedFlag(plr, BG_EY_OBJECT_FLAG_FEL_REAVER);
}
}
}
}
}
void BattlegroundEY::UpdateTeamScore(uint32 Team)
{
uint32 score = GetTeamScore(Team);
//TODO there should be some sound played when one team is near victory!! - and define variables
/*if(!m_IsInformedNearVictory && score >= BG_EY_WARNING_NEAR_VICTORY_SCORE)
{
if(Team == ALLIANCE)
SendMessageToAll(LANG_BG_EY_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
else
SendMessageToAll(LANG_BG_EY_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
PlaySoundToAll(BG_EY_SOUND_NEAR_VICTORY);
m_IsInformedNearVictory = true;
}*/
if(score >= BG_EY_MAX_TEAM_SCORE)
{
score = BG_EY_MAX_TEAM_SCORE;
EndBattleground(Team);
}
if(Team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_RESOURCES, score);
else
UpdateWorldState(EY_HORDE_RESOURCES, score);
}
void BattlegroundEY::StartBattleground()
{
Battleground::StartBattleground();
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_FLURRY_START_EVENT);
}
void BattlegroundEY::EndBattleground(uint32 winner)
{
//win reward
if(winner == ALLIANCE)
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
if(winner == HORDE)
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
//complete map reward
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
Battleground::EndBattleground(winner);
}
void BattlegroundEY::UpdatePointsCount(uint32 Team)
{
if(Team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]);
else
UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]);
}
void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
{
//we MUST firstly send 0, after that we can send 1!!!
if(m_PointState[Point] == EY_POINT_UNDER_CONTROL)
{
UpdateWorldState(m_PointsIconStruct[Point].WorldStateControlIndex, 0);
if(Team == ALLIANCE)
UpdateWorldState(m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1);
else
UpdateWorldState(m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 1);
} else {
if(Team == ALLIANCE)
UpdateWorldState(m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0);
else
UpdateWorldState(m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 0);
UpdateWorldState(m_PointsIconStruct[Point].WorldStateControlIndex, 1);
}
}
void BattlegroundEY::AddPlayer(Player* plr)
{
Battleground::AddPlayer(plr);
//create score and add it to map
BattlegroundEYScore* sc = new BattlegroundEYScore;
m_PlayersNearPoint[EY_POINTS_MAX].push_back(plr->GetGUID());
m_PlayerScores[plr->GetGUID()] = sc;
}
void BattlegroundEY::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
for(int j = EY_POINTS_MAX; j >= 0; --j)
{
for(size_t i = 0; i < m_PlayersNearPoint[j].size(); ++i)
if(m_PlayersNearPoint[j][i] == guid)
{
m_PlayersNearPoint[j].erase(m_PlayersNearPoint[j].begin() + i);
break;
}
}
if(IsFlagPickedup())
{
if(m_FlagKeeper == guid)
{
if(plr)
EventPlayerDroppedFlag(plr);
else
{
SetFlagPicker(0);
RespawnFlag(true);
}
}
}
}
void BattlegroundEY::HandleAreaTrigger(Player* Source, uint32 uiTrigger)
{
if(GetStatus() != STATUS_IN_PROGRESS)
return;
if(!Source->isAlive()) //hack code, must be removed later
return;
switch(uiTrigger)
{
case TR_BLOOD_ELF_POINT:
if(m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BLOOD_ELF] == Source->GetTeam())
if(m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_BLOOD_ELF);
break;
case TR_FEL_REAVER_POINT:
if(m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[FEL_REAVER] == Source->GetTeam())
if(m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_FEL_REAVER);
break;
case TR_MAGE_TOWER_POINT:
if(m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[MAGE_TOWER] == Source->GetTeam())
if(m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_MAGE_TOWER);
break;
case TR_DRAENEI_RUINS_POINT:
if(m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[DRAENEI_RUINS] == Source->GetTeam())
if(m_FlagState && GetFlagPickerGUID() == Source->GetGUID())
EventPlayerCapturedFlag(Source, BG_EY_OBJECT_FLAG_DRAENEI_RUINS);
break;
case 4512:
case 4515:
case 4517:
case 4519:
case 4530:
case 4531:
case 4568:
case 4569:
case 4570:
case 4571:
case 5866:
break;
default:
sLog->outError("WARNING: Unhandled AreaTrigger in Battleground: %u", uiTrigger);
Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", uiTrigger);
break;
}
}
bool BattlegroundEY::SetupBattleground()
{
// doors
if(!AddObject(BG_EY_OBJECT_DOOR_A, BG_OBJECT_A_DOOR_EY_ENTRY, 2527.6f, 1596.91f, 1262.13f, -3.12414f, -0.173642f, -0.001515f, 0.98477f, -0.008594f, RESPAWN_IMMEDIATELY)
|| !AddObject(BG_EY_OBJECT_DOOR_H, BG_OBJECT_H_DOOR_EY_ENTRY, 1803.21f, 1539.49f, 1261.09f, 3.14159f, 0.173648f, 0, 0.984808f, 0, RESPAWN_IMMEDIATELY)
// banners (alliance)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_A_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_A_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_A_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_A_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// banners (horde)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_H_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_H_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_H_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_H_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// banners (natural)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2057.46f, 1735.07f, 1187.91f, -0.925024f, 0, 0, 0.446198f, -0.894934f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2032.25f, 1729.53f, 1190.33f, 1.8675f, 0, 0, 0.803857f, 0.594823f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_FEL_REAVER_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2092.35f, 1775.46f, 1187.08f, -0.401426f, 0, 0, 0.199368f, -0.979925f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2047.19f, 1349.19f, 1189.0f, -1.62316f, 0, 0, 0.725374f, -0.688354f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2074.32f, 1385.78f, 1194.72f, 0.488692f, 0, 0, 0.241922f, 0.970296f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_BLOOD_ELF_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2025.13f, 1386.12f, 1192.74f, 2.3911f, 0, 0, 0.930418f, 0.366501f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2276.8f, 1400.41f, 1196.33f, 2.44346f, 0, 0, 0.939693f, 0.34202f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2305.78f, 1404.56f, 1199.38f, 1.74533f, 0, 0, 0.766044f, 0.642788f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_DRAENEI_RUINS_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2245.4f, 1366.41f, 1195.28f, 2.21657f, 0, 0, 0.894934f, 0.446198f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_CENTER, BG_OBJECT_N_BANNER_EY_ENTRY, 2270.84f, 1784.08f, 1186.76f, 2.42601f, 0, 0, 0.936672f, 0.350207f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_LEFT, BG_OBJECT_N_BANNER_EY_ENTRY, 2269.13f, 1737.7f, 1186.66f, 0.994838f, 0, 0, 0.477159f, 0.878817f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_RIGHT, BG_OBJECT_N_BANNER_EY_ENTRY, 2300.86f, 1741.25f, 1187.7f, -0.785398f, 0, 0, 0.382683f, -0.92388f, RESPAWN_ONE_DAY)
// flags
|| !AddObject(BG_EY_OBJECT_FLAG_NETHERSTORM, BG_OBJECT_FLAG2_EY_ENTRY, 2174.782227f, 1569.054688f, 1160.361938f, -1.448624f, 0, 0, 0.662620f, -0.748956f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_FEL_REAVER, BG_OBJECT_FLAG1_EY_ENTRY, 2044.28f, 1729.68f, 1189.96f, -0.017453f, 0, 0, 0.008727f, -0.999962f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_BLOOD_ELF, BG_OBJECT_FLAG1_EY_ENTRY, 2048.83f, 1393.65f, 1194.49f, 0.20944f, 0, 0, 0.104528f, 0.994522f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_DRAENEI_RUINS, BG_OBJECT_FLAG1_EY_ENTRY, 2286.56f, 1402.36f, 1197.11f, 3.72381f, 0, 0, 0.957926f, -0.287016f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_FLAG_MAGE_TOWER, BG_OBJECT_FLAG1_EY_ENTRY, 2284.48f, 1731.23f, 1189.99f, 2.89725f, 0, 0, 0.992546f, 0.121869f, RESPAWN_ONE_DAY)
// tower cap
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_FEL_REAVER, BG_OBJECT_FR_TOWER_CAP_EY_ENTRY, 2024.600708f, 1742.819580f, 1195.157715f, 2.443461f, 0, 0, 0.939693f, 0.342020f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_BLOOD_ELF, BG_OBJECT_BE_TOWER_CAP_EY_ENTRY, 2050.493164f, 1372.235962f, 1194.563477f, 1.710423f, 0, 0, 0.754710f, 0.656059f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_DRAENEI_RUINS, BG_OBJECT_DR_TOWER_CAP_EY_ENTRY, 2301.010498f, 1386.931641f, 1197.183472f, 1.570796f, 0, 0, 0.707107f, 0.707107f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_TOWER_CAP_MAGE_TOWER, BG_OBJECT_HU_TOWER_CAP_EY_ENTRY, 2282.121582f, 1760.006958f, 1189.707153f, 1.919862f, 0, 0, 0.819152f, 0.573576f, RESPAWN_ONE_DAY)
)
{
sLog->outErrorDb("BatteGroundEY: Failed to spawn some object Battleground not created!");
return false;
}
//buffs
for(int i = 0; i < EY_POINTS_MAX; ++i)
{
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(m_Points_Trigger[i]);
if(!at)
{
sLog->outError("BattlegroundEY: Unknown trigger: %u", m_Points_Trigger[i]);
continue;
}
if(!AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
|| !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY)
)
sLog->outError("BattlegroundEY: Cannot spawn buff");
}
WorldSafeLocsEntry const *sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE);
if(!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, ALLIANCE))
{
sLog->outErrorDb("BatteGroundEY: Failed to spawn spirit guide! Battleground not created!");
return false;
}
sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_HORDE);
if(!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, HORDE))
{
sLog->outErrorDb("BatteGroundEY: Failed to spawn spirit guide! Battleground not created!");
return false;
}
return true;
}
void BattlegroundEY::Reset()
{
//call parent's class reset
Battleground::Reset();
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
m_TeamScores[BG_TEAM_HORDE] = 0;
m_TeamPointsCount[BG_TEAM_ALLIANCE] = 0;
m_TeamPointsCount[BG_TEAM_HORDE] = 0;
m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0;
m_HonorScoreTics[BG_TEAM_HORDE] = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
m_FlagCapturedBgObjectType = 0;
m_FlagKeeper = 0;
m_DroppedFlagGUID = 0;
m_PointAddingTimer = 0;
m_TowerCapCheckTimer = 0;
m_CheatersCheckTimer = 0;
bool isBGWeekend = sBattlegroundMgr->IsBGWeekend(GetTypeID());
m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks;
for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
m_PointOwnedByTeam[i] = EY_POINT_NO_OWNER;
m_PointState[i] = EY_POINT_STATE_UNCONTROLLED;
m_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE;
m_PlayersNearPoint[i].clear();
m_PlayersNearPoint[i].reserve(15); //tip size
}
m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].clear();
m_PlayersNearPoint[EY_PLAYERS_OUT_OF_POINTS].reserve(30);
}
void BattlegroundEY::RespawnFlag(bool send_message)
{
if(m_FlagCapturedBgObjectType > 0)
SpawnBGObject(m_FlagCapturedBgObjectType, RESPAWN_ONE_DAY);
m_FlagCapturedBgObjectType = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_IMMEDIATELY);
if(send_message)
{
SendMessageToAll(LANG_BG_EY_RESETED_FLAG, CHAT_MSG_BG_SYSTEM_NEUTRAL);
PlaySoundToAll(BG_EY_SOUND_FLAG_RESET); // flags respawned sound...
}
UpdateWorldState(NETHERSTORM_FLAG, 1);
}
void BattlegroundEY::RespawnFlagAfterDrop()
{
RespawnFlag(true);
GameObject* obj = HashMapHolder<GameObject>::Find(GetDroppedFlagGUID());
if(obj)
obj->Delete();
else
sLog->outError("BattlegroundEY: Unknown dropped flag guid: %u", GUID_LOPART(GetDroppedFlagGUID()));
SetDroppedFlagGUID(0);
}
void BattlegroundEY::HandleKillPlayer(Player* pPlayer, Player* pKiller)
{
if(GetStatus() != STATUS_IN_PROGRESS)
return;
Battleground::HandleKillPlayer(pPlayer, pKiller);
EventPlayerDroppedFlag(pPlayer);
}
void BattlegroundEY::EventPlayerDroppedFlag(Player* Source)
{
if(GetStatus() != STATUS_IN_PROGRESS)
{
// if not running, do not cast things at the dropper player, neither send unnecessary messages
// just take off the aura
if(IsFlagPickedup() && GetFlagPickerGUID() == Source->GetGUID())
{
SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
}
return;
}
if(!IsFlagPickedup())
return;
if(GetFlagPickerGUID() != Source->GetGUID())
return;
SetFlagPicker(0);
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
m_FlagState = BG_EY_FLAG_STATE_ON_GROUND;
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
Source->CastSpell(Source, SPELL_RECENTLY_DROPPED_FLAG, true);
Source->CastSpell(Source, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true);
//this does not work correctly :((it should remove flag carrier name)
UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_WAIT_RESPAWN);
if(Source->GetTeam() == ALLIANCE)
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL);
else
SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL);
}
void BattlegroundEY::EventPlayerClickedOnFlag(Player* pSource, GameObject* pGO)
{
if(GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !pSource->IsWithinDistInMap(pGO, 10))
return;
if(pSource->GetTeam() == ALLIANCE) {
UpdateWorldState(NETHERSTORM_FLAG_STATE_ALLIANCE, BG_EY_FLAG_STATE_ON_PLAYER);
PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE);
} else {
UpdateWorldState(NETHERSTORM_FLAG_STATE_HORDE, BG_EY_FLAG_STATE_ON_PLAYER);
PlaySoundToAll(BG_EY_SOUND_FLAG_PICKED_UP_HORDE);
}
if(m_FlagState == BG_EY_FLAG_STATE_ON_BASE)
UpdateWorldState(NETHERSTORM_FLAG, 0);
m_FlagState = BG_EY_FLAG_STATE_ON_PLAYER;
SpawnBGObject(BG_EY_OBJECT_FLAG_NETHERSTORM, RESPAWN_ONE_DAY);
SetFlagPicker(pSource->GetGUID());
//get flag aura on player
pSource->CastSpell(pSource, BG_EY_NETHERSTORM_FLAG_SPELL, true);
pSource->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if(pSource->GetTeam() == ALLIANCE)
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, pSource->GetName());
else
PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, pSource->GetName());
}
void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point)
{
if(GetStatus() != STATUS_IN_PROGRESS)
return;
//Natural point
uint32 Team = m_PointOwnedByTeam[Point];
if(!Team)
return;
if(Team == ALLIANCE)
{
m_TeamPointsCount[BG_TEAM_ALLIANCE]--;
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 2, RESPAWN_ONE_DAY);
}
else
{
m_TeamPointsCount[BG_TEAM_HORDE]--;
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 2, RESPAWN_ONE_DAY);
}
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_LosingPointTypes[Point].SpawnNeutralObjectType + 2, RESPAWN_IMMEDIATELY);
m_PointOwnedByTeam[Point] = EY_POINT_NO_OWNER;
m_PointState[Point] = EY_POINT_NO_OWNER;
if(Team == ALLIANCE)
SendMessageToAll(m_LosingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else
SendMessageToAll(m_LosingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source);
UpdatePointsIcons(Team, Point);
UpdatePointsCount(Team);
//remove bonus honor aura trigger creature when node is lost
if(Point < EY_POINTS_MAX)
DelCreature(Point + 6);//NULL checks are in DelCreature! 0-5 spirit guides
}
void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point)
{
if(GetStatus() != STATUS_IN_PROGRESS)
return;
uint32 Team = Source->GetTeam();
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY);
if(Team == ALLIANCE)
{
if ( _400Ally40Horde == 400) {
if(AchievementEntry const* pAchievment = GetAchievementStore()->LookupEntry(211))
Source->CompletedAchievement(pAchievment);
}
m_TeamPointsCount[BG_TEAM_ALLIANCE]++;
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY);
}
else
{
if ( _400Ally40Horde == 40) {
if(AchievementEntry const* pAchievment = GetAchievementStore()->LookupEntry(211))
Source->CompletedAchievement(pAchievment);
}
m_TeamPointsCount[BG_TEAM_HORDE]++;
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
}
//buff isn't respawned
m_PointOwnedByTeam[Point] = Team;
m_PointState[Point] = EY_POINT_UNDER_CONTROL;
if(Team == ALLIANCE)
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else
SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source);
if(m_BgCreatures[Point])
DelCreature(Point);
WorldSafeLocsEntry const *sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
if(!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team))
sLog->outError("BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u",
Point, Team, m_CapturingPointTypes[Point].GraveYardId);
UpdatePointsIcons(Team, Point);
UpdatePointsCount(Team);
if(Point >= EY_POINTS_MAX)
return;
Creature* trigger = GetBGCreature(Point + 6);//0-5 spirit guides
if(!trigger)
trigger = AddCreature(WORLD_TRIGGER, Point+6, Team, BG_EY_TriggerPositions[Point][0], BG_EY_TriggerPositions[Point][1], BG_EY_TriggerPositions[Point][2], BG_EY_TriggerPositions[Point][3]);
//add bonus honor aura trigger creature when node is accupied
//cast bonus aura (+50% honor in 25yards)
//aura should only apply to players who have accupied the node, set correct faction for trigger
if(trigger)
{
trigger->setFaction(Team == ALLIANCE ? 84 : 83);
trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false);
}
}
void BattlegroundEY::EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType)
{
if(GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != Source->GetGUID())
return;
SetFlagPicker(0);
m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN;
Source->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if(Source->GetTeam() == ALLIANCE)
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE);
else
PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE);
SpawnBGObject(BgObjectType, RESPAWN_IMMEDIATELY);
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
m_FlagCapturedBgObjectType = BgObjectType;
uint8 team_id = 0;
if(Source->GetTeam() == ALLIANCE)
{
team_id = BG_TEAM_ALLIANCE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
}
else
{
team_id = BG_TEAM_HORDE;
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, Source);
}
if(m_TeamPointsCount[team_id] > 0)
AddPoints(Source->GetTeam(), BG_EY_FlagPoints[m_TeamPointsCount[team_id] - 1]);
UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1);
}
void BattlegroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor)
{
BattlegroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
if(itr == m_PlayerScores.end()) // player not found
return;
switch(type)
{
case SCORE_FLAG_CAPTURES: // flags captured
((BattlegroundEYScore*)itr->second)->FlagCaptures += value;
Source->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, EY_OBJECTIVE_CAPTURE_FLAG);
break;
default:
Battleground::UpdatePlayerScore(Source, type, value, doAddHonor);
break;
}
}
void BattlegroundEY::FillInitialWorldStates(WorldPacket& data)
{
data << uint32(EY_HORDE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_HORDE]);
data << uint32(EY_ALLIANCE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_ALLIANCE]);
data << uint32(0xab6) << uint32(0x0);
data << uint32(0xab5) << uint32(0x0);
data << uint32(0xab4) << uint32(0x0);
data << uint32(0xab3) << uint32(0x0);
data << uint32(0xab2) << uint32(0x0);
data << uint32(0xab1) << uint32(0x0);
data << uint32(0xab0) << uint32(0x0);
data << uint32(0xaaf) << uint32(0x0);
data << uint32(DRAENEI_RUINS_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == HORDE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
data << uint32(DRAENEI_RUINS_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[DRAENEI_RUINS] == ALLIANCE && m_PointState[DRAENEI_RUINS] == EY_POINT_UNDER_CONTROL);
data << uint32(DRAENEI_RUINS_UNCONTROL) << uint32(m_PointState[DRAENEI_RUINS] != EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[MAGE_TOWER] == ALLIANCE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[MAGE_TOWER] == HORDE && m_PointState[MAGE_TOWER] == EY_POINT_UNDER_CONTROL);
data << uint32(MAGE_TOWER_UNCONTROL) << uint32(m_PointState[MAGE_TOWER] != EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[FEL_REAVER] == HORDE && m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[FEL_REAVER] == ALLIANCE && m_PointState[FEL_REAVER] == EY_POINT_UNDER_CONTROL);
data << uint32(FEL_REAVER_UNCONTROL) << uint32(m_PointState[FEL_REAVER] != EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_HORDE_CONTROL) << uint32(m_PointOwnedByTeam[BLOOD_ELF] == HORDE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_ALLIANCE_CONTROL) << uint32(m_PointOwnedByTeam[BLOOD_ELF] == ALLIANCE && m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL);
data << uint32(BLOOD_ELF_UNCONTROL) << uint32(m_PointState[BLOOD_ELF] != EY_POINT_UNDER_CONTROL);
data << uint32(NETHERSTORM_FLAG) << uint32(m_FlagState == BG_EY_FLAG_STATE_ON_BASE);
data << uint32(0xad2) << uint32(0x1);
data << uint32(0xad1) << uint32(0x1);
data << uint32(0xabe) << uint32(GetTeamScore(HORDE));
data << uint32(0xabd) << uint32(GetTeamScore(ALLIANCE));
data << uint32(0xa05) << uint32(0x8e);
data << uint32(0xaa0) << uint32(0x0);
data << uint32(0xa9f) << uint32(0x0);
data << uint32(0xa9e) << uint32(0x0);
data << uint32(0xc0d) << uint32(0x17b);
}
WorldSafeLocsEntry const *BattlegroundEY::GetClosestGraveYard(Player* player)
{
uint32 g_id = 0;
switch(player->GetTeam())
{
case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break;
case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break;
default: return NULL;
}
float distance, nearestDistance;
WorldSafeLocsEntry const* entry = NULL;
WorldSafeLocsEntry const* nearestEntry = NULL;
entry = sWorldSafeLocsStore.LookupEntry(g_id);
nearestEntry = entry;
if(!entry)
{
sLog->outError("BattlegroundEY: Not found the main team graveyard. Graveyard system isn't working!");
return NULL;
}
float plr_x = player->GetPositionX();
float plr_y = player->GetPositionY();
float plr_z = player->GetPositionZ();
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
nearestDistance = distance;
for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
if(m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL)
{
entry = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[i].GraveYardId);
if(!entry)
sLog->outError("BattlegroundEY: Not found graveyard: %u", m_CapturingPointTypes[i].GraveYardId);
else
{
distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z);
if(distance < nearestDistance)
{
nearestDistance = distance;
nearestEntry = entry;
}
}
}
}
return nearestEntry;
}
bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const
{
uint32 count = 0;
for(int i = 0; i < EY_POINTS_MAX; ++i)
if(m_PointOwnedByTeam[i] == team && m_PointState[i] == EY_POINT_UNDER_CONTROL)
++count;
return count == EY_POINTS_MAX;
}
| [
"taumer943@gmail.com"
] | taumer943@gmail.com |
dc90dac0cdb3fafe306d8d445600cd000c640c43 | 87057f0cd3637fde633046867072ffb86c73abfe | /cpp/libs/src/opendnp3/link/LinkLayerParser.h | 9fd6b4fde10f8feb50f627076090456269cfb7f2 | [
"Apache-2.0"
] | permissive | Saintat1/dnp3 | b7fa4e2c18eca0a8477ac9cf369bf9c8235076f5 | 96309d067a62ca84fb338116f642530c832020d4 | refs/heads/2.0.x | 2021-01-11T19:36:29.360903 | 2016-09-23T17:52:39 | 2016-09-23T17:52:39 | 69,037,382 | 0 | 0 | null | 2016-09-23T16:24:17 | 2016-09-23T15:29:09 | C++ | UTF-8 | C++ | false | false | 2,817 | h | /*
* Licensed to Green Energy Corp (www.greenenergycorp.com) under one or
* more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Green Energy Corp licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This project was forked on 01/01/2013 by Automatak, LLC and modifications
* may have been made to this file. Automatak, LLC licenses these modifications
* to you under the terms of the License.
*/
#ifndef OPENDNP3_LINKLAYERPARSER_H
#define OPENDNP3_LINKLAYERPARSER_H
#include <openpal/container/WSlice.h>
#include <openpal/logging/Logger.h>
#include "opendnp3/ErrorCodes.h"
#include "opendnp3/link/ShiftableBuffer.h"
#include "opendnp3/link/LinkFrame.h"
#include "opendnp3/link/LinkHeader.h"
#include "opendnp3/link/LinkChannelStatistics.h"
namespace opendnp3
{
class IFrameSink;
/// Parses FT3 frames
class LinkLayerParser
{
enum class State
{
FindSync,
ReadHeader,
ReadBody,
Complete
};
public:
/// @param logger_ Logger that the receiver is to use.
/// @param pSink_ Completely parsed frames are sent to this interface
LinkLayerParser(const openpal::Logger& logger, LinkChannelStatistics* pStatistics_ = nullptr);
/// Called when valid data has been written to the current buffer write position
/// Parses the new data and calls the specified frame sink
/// @param numBytes Number of bytes written
void OnRead(uint32_t numBytes, IFrameSink& sink);
/// @return Buffer that can currently be used for writing
openpal::WSlice WriteBuff() const;
/// Resets the state of parser
void Reset();
private:
State ParseUntilComplete();
State ParseOneStep();
State ParseSync();
State ParseHeader();
State ParseBody();
void PushFrame(IFrameSink& sink);
bool ReadHeader();
bool ValidateBody();
bool ValidateHeaderParameters();
bool ValidateFunctionCode();
void FailFrame();
void TransferUserData();
openpal::Logger logger;
LinkChannelStatistics* pStatistics;
LinkHeader header;
State state;
uint32_t frameSize;
openpal::RSlice userData;
// buffer where received data is written
uint8_t rxBuffer[LPDU_MAX_FRAME_SIZE];
// facade over the rxBuffer that provides ability to "shift" as data is read
ShiftableBuffer buffer;
};
}
#endif
| [
"jadamcrain@gmail.com"
] | jadamcrain@gmail.com |
bef3d4d97e1d58a44eb81dad4d73f27b61475d95 | ff58a47840463a8520b93a5ff2ed96e5f87fc587 | /Study_examples/IntCell.cpp | 209457f06653c00a7c5095b041a19aa758d0d415 | [] | no_license | MFowler85/ExtraInterviewQuestions | 0677993c5f2ba1c4692b6681cbdf3b43daf2bf0e | 3aa74ec666d4206920357f628ee087d69d33214c | refs/heads/master | 2021-01-10T17:00:21.019021 | 2017-07-06T23:37:23 | 2017-07-06T23:37:23 | 49,293,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 287 | cpp | /*
* File: IntCell.cpp
* Author: mcf8379
*
* Created on June 12, 2015, 8:28 AM
*/
#include "IntCell.h"
IntCell::IntCell(int initialValue): storedValue(initialValue)
{
}
int IntCell::read() const
{
return storedValue;
}
void IntCell::write(int x)
{
storedValue = x;
} | [
"mike85nc@yahoo.com"
] | mike85nc@yahoo.com |
c9515a8684c835864b01865ea0d935f5456ca2ba | 28f8a21b5d4b961477f105bddeb36654a6cc3d57 | /SUSYBSMAnalysis/SusyCAF/plugins/SusyCAF_DQMFlags.cc | d95f3c27778e4f66782301fef6b880d0b3d1e4b6 | [] | no_license | fcostanz/NTupler | 316be24ca3c8b9784def7e0deea3fd5ead58f72e | adc566a93ad4973fe61a1a9a24ceaabc3973a7ed | refs/heads/master | 2016-09-06T03:57:21.982267 | 2014-02-17T10:01:14 | 2014-02-17T10:01:14 | 16,286,291 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,303 | cc | #include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "SUSYBSMAnalysis/SusyCAF/interface/SusyCAF_DQMFlags.h"
SusyCAF_DQMFlags::SusyCAF_DQMFlags( const edm::ParameterSet& iConfig )
: flagNames( iConfig.getParameter<vector<string> > ("ListOfDQMFlags") ),
server( iConfig.getParameter<string> ("server") )
{
produces <std::map<std::string,int> > ( "DQMFlags" );
}
void SusyCAF_DQMFlags::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) {
int runNo = iEvent.id().run();
// check the map if run# exists
if( runFlagMap.find(runNo) == runFlagMap.end() ){
// a new run# we are going to access the run registry
// accessing runFlagMap[runNo] automatically creates a new flag vector
if( !AskRR( runFlagMap[runNo], runNo ) )
edm::LogError("Run Registry access error");
}
std::auto_ptr<std::map<std::string,int> > dqmflags (new std::map<std::string,int>());
// export flags into iEvent
for( unsigned int i=0; i<flagNames.size(); i++ )
(*dqmflags)[flagNames.at(i)] = runFlagMap[runNo][i];
iEvent.put( dqmflags, "DQMFlags" );
}
void SusyCAF_DQMFlags::beginJob(){}
bool SusyCAF_DQMFlags::AskRR( vector<int>& flags, int runNo ) {
if( flagNames.size()==0 ) return false;
flags.resize( flagNames.size() );
Py_Initialize();
PyObject * module;
PyObject * dict;
module = PyImport_AddModule( "__main__" );
dict = PyModule_GetDict( module );
// library for xmlrpc
PyRun_SimpleString( "import xmlrpclib\n" );
// open server and ask for all flags
string serverstring = "server = xmlrpclib.ServerProxy('" + server + "')\n";
PyRun_SimpleString( serverstring.c_str() );
char request[100];
sprintf( request, "data = server.DataExporter.export('RUN','GLOBAL', 'xml_datasets', {'runNumber': '%i'})\n", runNo );
PyRun_SimpleString( request );
// library for xml parsing
PyRun_SimpleString( "from xml.sax import make_parser, SAXException, parseString\n" );
PyRun_SimpleString( "from xml.sax.handler import ContentHandler\n" );
stringstream flagstringstream;
// python allFlags list
flagstringstream << "allFlags=[\"CMP_" << flagNames[0];
for( unsigned int i=1; i<flagNames.size(); i++ )
flagstringstream << "\",\"CMP_" << flagNames[i];
flagstringstream << "\"]\n";
// python allFlagValuesi list
flagstringstream <<"allFlagValuesi="<<flagNames.size()<<"*[99]"<<"\n"<<endl;
PyRun_SimpleString( flagstringstream.str().c_str() );
// python class def of ContentHandler used in parseing
PyRun_SimpleString(
"class FindFlags(ContentHandler):\n"
"\tdef __init__(self, flagN):\n"
"\t\tself.Index=flagN\n"
"\t\tself.search_flag = allFlags[self.Index]\n"
"\t\tself.isflag = 0\n"
"\t\tself.flagvalue = \"\"\n"
"\tdef startElement(self, name, attrs):\n"
"\t\tself.isflag=0\n"
"\t\tif name == self.search_flag:\n"
"\t\t\tself.isflag = 1\n"
"\tdef characters(self, text):\n"
"\t\tif self.isflag ==1:\n"
"\t\t\tself.flagvalue=text\n"
"\t\t\tif self.flagvalue==\"GOOD\":\n"
"\t\t\t\tallFlagValuesi[self.Index]=1\n"
"\t\t\tif self.flagvalue==\"BAD\":\n"
"\t\t\t\tallFlagValuesi[self.Index]=-1\n"
"\t\t\tif self.flagvalue==\"EXCL\":\n"
"\t\t\t\tallFlagValuesi[self.Index]=0\n"
"\t\t\tif self.flagvalue==\"NOTSET\":\n"
"\t\t\t\tallFlagValuesi[self.Index]=10\n"
);
// parse
PyRun_SimpleString(
"for inte in range(len(allFlags)):\n"
"\tparseString(data,FindFlags(inte))\n"
);
stringstream setVariables;
// fli neccessary?
setVariables << "for inte in range(len(allFlags)):\n";
for(unsigned int i=0;i<flagNames.size();i++)
setVariables << "\tif allFlags[inte]==\"CMP_" << flagNames[i] << "\" : "
<< flagNames[i] << "fli =allFlagValuesi[inte]\n";
PyRun_SimpleString( setVariables.str().c_str() );
// read flags from python into flags vector
for( unsigned int i=0; i<flagNames.size(); i++ ) {
char itemName[100];
strcpy( itemName, flagNames[i].c_str() );
strcat( itemName, "fli" );
PyObject* pyItem = PyMapping_GetItemString( dict, itemName );
if(pyItem != NULL) {
flags[i]=PyInt_AsLong( pyItem );
Py_DECREF(pyItem);
} else flags[i]=99;
}
bool success=true;
if(PyErr_Occurred()) success=false;;
Py_Finalize();
return success;
}
| [
"fcost@nafhh-cms02.desy.de"
] | fcost@nafhh-cms02.desy.de |
6898d587029d780207fa20c14b6e6d7590ab9e4b | 7b9f638e5f4a96a7a6aeb728728f65833e743b02 | /myProject/face/opencvPro/FaceRecognizer/myFaceRecognizer/main.cpp | b213055689ac41c47f4bce0561f1a945f0a01704 | [] | no_license | unityzf/YUSZF | 57d5063b6cdfe0d134f7b8e5c8fef379c4ebc431 | 976233560bdae197db507aa76347756f90ea346f | refs/heads/master | 2021-01-26T00:36:39.307523 | 2020-02-26T11:18:37 | 2020-02-26T11:18:37 | 243,241,421 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 350 | cpp | #include <opencv2/opencv.hpp>
#include <vector>
#include <iostream>
#include <stdio.h>
#include "myfacerecognizer.h"
//#include <stdio.h>
//#include <cv.h>
RNG g_rng(12345);
using namespace std;
using namespace cv;
int main()
{
myFaceRecognizer * face=new myFaceRecognizer();
// face->takePicture();
face->Recognizer();
return 0;
}
| [
"1332305282@qq.com"
] | 1332305282@qq.com |
a33f036aee6953b7537f45111404b783a11a9e06 | 522a944acfc5798d6fb70d7a032fbee39cc47343 | /d6k/trunk/src/netbus/net_config.h | 8d72ea1538b8d12ace1a7df1b7bb27314e67ce8a | [] | no_license | liuning587/D6k2.0master | 50275acf1cb0793a3428e203ac7ff1e04a328a50 | 254de973a0fbdd3d99b651ec1414494fe2f6b80f | refs/heads/master | 2020-12-30T08:21:32.993147 | 2018-03-30T08:20:50 | 2018-03-30T08:20:50 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,073 | h | /*! @file net_config.h
<PRE>
********************************************************************************
模块名 :
文件名 : net_config.h
文件实现功能 : 系统网络配置及状态
作者 : LiJin
版本 : V1.00
--------------------------------------------------------------------------------
备注 : <其它说明>
--------------------------------------------------------------------------------
修改记录 :
日 期 版本 修改人 修改内容
********************************************************************************
</PRE>
* @brief 系统网络配置及状态
* @author LiJin
* @version 1.0
* @date 2016.11.26
*******************************************************************************/
#ifndef NET_CONFIG_H
#define NET_CONFIG_H
#include "datatypes.h"
#include "netbus/nbdef.h"
#include <string>
#include <atomic>
#include <map>
#include <memory>
#if 0
struct NODE_CONFIG
{
int32u OccNo; //! 节点在数据库中的ID
int32u SlaveOccNo;
int32u NodeType; //! 节点类型
int32u NetAIPAddr; //! IP address of net1, filled by cfg.
int32u NetBIPAddr; //! IP address of net2, filled by cfg.
int32u NetAIpV6Addr[4]; //! IPV6 的A网地址
int32u NetBIpV6Addr[4]; //! IPV6 的B网地址
int8u IsCheckTime; //! 是否对时
int8u IsDefaultHost; //! 是否默认为主
char HostName[NAME_SIZE]; //! 主机名称
char TagName[NAME_SIZE]; //! 别名
// 实时值
int32u HostSlave; //! 主从状态
int8u CardStatus[2]; //! AB网状态
};
typedef struct NODE_CONFIG CNodeConfig;
/*! \struct NET_CONFIG
* \brief 网络节点定义 */
struct NET_CONFIG
{
int32u IsDoubleNet; //! 是否双网
char CheckTime[NAME_SIZE]; //! 对时节点别名
int32u NodeCount; //! 节点数
CNodeConfig* pNodeConfig; //! 节点表指针
};
#endif
struct NET_CONFIG;
class CNodeInfo : protected CNodeConfig
{
public:
CNodeInfo();
CNodeInfo(NODE_CONFIG *pNode);
~CNodeInfo();
enum CardIdx:int32u
{
NET_A = 0,
NET_B = 1,
};
public:
int32u GetOccNo() const
{
return OccNo;
}
// 获取网卡状态
int32u GetCardState(CardIdx nIdx) const
{
return m_nCardState[nIdx];
}
// 设置网卡状态
void SetCardStarte(CardIdx nIdx,int32u nState)
{
m_nCardState[nIdx] = nState;
this->CardStatus[nIdx] = static_cast<int8u> (nState);
}
// 获取节点状态
int32u GetNodeState() const
{
return m_nHostState;
}
// 设置节点状态
void SetNodeState(int32u nState)
{
m_nHostState = nState;
this->HostSlave = nState;
}
private:
//! 双网的
std::atomic<int32u> m_nCardState[2];
//! 主从状态
std::atomic<int32u> m_nHostState;
};
class CNetState
{
public:
CNetState();
CNetState(NET_CONFIG *pConfig);
~CNetState();
public:
protected:
NET_CONFIG *m_pNetConfig;
std::map <int32u, std::shared_ptr<CNodeInfo>> m_mapNetConf;
};
#endif // NET_CONFIG_H
/** @}*/
| [
"xingzhibing_ab@hotmail.com"
] | xingzhibing_ab@hotmail.com |
da531a0cfc492cf6d841e01fcab9d35985e4118b | 199403e1f6ef2a720b3682f2e02e50f6645dbb13 | /source/Engine/Matrix3.cpp | 707a22f2e7e8046215de90c707eb0827e46d586c | [] | no_license | austinkelmore/SideProject | fb9c75d878c427340c8f8e673a58555d7f9c698a | 072365318534ab44ae739d4c8ada10f931a29555 | refs/heads/master | 2021-01-19T20:13:04.611505 | 2014-08-26T03:20:47 | 2014-08-26T03:20:47 | 4,035,131 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 666 | cpp |
#include "Matrix3.h"
const Matrix3 Matrix3::Identity;
Matrix3::Matrix3()
: m00(1.f), m01(0.f), m02(0.f),
m10(0.f), m11(1.f), m12(0.f),
m20(0.f), m21(0.f), m22(1.f)
{
// set to the identity matrix
}
Matrix3::Matrix3(const Matrix3& rhs)
{
*this = rhs;
}
Matrix3& Matrix3::operator=(const Matrix3& rhs)
{
memcpy(m, rhs.m, sizeof(this));
return *this;
}
Matrix3 Matrix3::operator*(const Matrix3& rhs) const
{
Matrix3 temp;
for (int row = 0; row < 3; ++row)
{
for (int col = 0; col < 3; ++col)
{
temp.m[row][col] = m[row][0] * rhs.m[0][col] +
m[row][1] * rhs.m[1][col] +
m[row][2] * rhs.m[2][col];
}
}
return temp;
}
| [
"github@austinmcgee.com"
] | github@austinmcgee.com |
f886d2dc61418ff2b73da01ca0c4b3d4a4d15899 | b367fe5f0c2c50846b002b59472c50453e1629bc | /xbox_leak_may_2020/xbox trunk/xbox/private/test/directx/d3d/frame/locussrv/resource.cpp | 4473033cc71da6325393f0a56ceac5df160fc740 | [] | 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 | 2,715 | cpp | #include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#include <winsock.h>
#include <d3dx8.h>
#include "transprt.h"
#include "util.h"
#include "typetran.h"
#include "server.h"
//***********************************************************************************
extern "C" void __cdecl M_RES8_AddRef(LPDIRECT3DRESOURCE8 pd3dres, ULONG* pulRet) {
*pulRet = pd3dres->AddRef();
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_Release(LPDIRECT3DRESOURCE8 pd3dres, ULONG* pulRet) {
*pulRet = g_pServer->ReleaseObject(pd3dres);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_GetType(LPDIRECT3DRESOURCE8 pd3dres, D3DRESOURCETYPE* pd3drt) {
*pd3drt = pd3dres->GetType();
REMAPOUT(D3DTI_D3DRESOURCETYPE, *pd3drt);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_GetDevice(LPDIRECT3DRESOURCE8 pd3dres, HRESULT* phr, LPDIRECT3DDEVICE8* ppDevice) {
*phr = pd3dres->GetDevice(ppDevice);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_GetPrivateData(LPDIRECT3DRESOURCE8 pd3dres, HRESULT* phr, GUID* prefguid, void* pvData, DWORD* pdwSizeOfData) {
*phr = pd3dres->GetPrivateData(*prefguid, pvData, pdwSizeOfData);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_SetPrivateData(LPDIRECT3DRESOURCE8 pd3dres, HRESULT* phr, GUID* prefguid, void* pvData, DWORD dwSizeOfData, DWORD dwFlags) {
*phr = pd3dres->SetPrivateData(*prefguid, pvData, dwSizeOfData, dwFlags);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_FreePrivateData(LPDIRECT3DRESOURCE8 pd3dres, HRESULT* phr, GUID* prefguid) {
*phr = pd3dres->FreePrivateData(*prefguid);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_GetPriority(LPDIRECT3DRESOURCE8 pd3dres, DWORD* pdwRet) {
*pdwRet = pd3dres->GetPriority();
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_SetPriority(LPDIRECT3DRESOURCE8 pd3dres, DWORD* pdwRet, DWORD dwPriority) {
*pdwRet = pd3dres->SetPriority(dwPriority);
}
//***********************************************************************************
extern "C" void __cdecl M_RES8_PreLoad(LPDIRECT3DRESOURCE8 pd3dres) {
pd3dres->PreLoad();
}
| [
"benjamin.barratt@icloud.com"
] | benjamin.barratt@icloud.com |
fd9523d72c4dd6fcca918df9c97d1d8a3cfec217 | a590f039107aaab0980d7ded36b6f79cd47e541d | /OpenFOAM/elliot-7/Dissertation/H/Initial Cases/scalarTransportH/0.675/T | 619e8586f2cbb13e0a84f03ef04f0b4f8e897983 | [] | no_license | etenno/uni | 3f85179768ae5a5d77dd21879f84323278a7a2f6 | bb62570182ea239c123df954eb0893e2d681fe8d | refs/heads/master | 2023-03-04T08:30:00.034753 | 2021-02-14T12:54:03 | 2021-02-14T12:54:03 | 338,678,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 56,391 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.675";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField nonuniform List<scalar>
7000
(
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
106.127
106.125
106.12
106.115
106.108
106.1
106.092
106.086
106.081
106.078
98.4086
98.4021
98.3896
98.3718
98.3502
98.3265
98.3029
98.2819
98.2661
98.2576
98.4085
98.4021
98.3896
98.3718
98.3502
98.3265
98.3029
98.2819
98.2661
98.2576
98.4085
98.4021
98.3895
98.3718
98.3502
98.3265
98.3029
98.2819
98.2661
98.2576
98.4085
98.402
98.3895
98.3718
98.3502
98.3265
98.3028
98.2819
98.2661
98.2576
98.4085
98.402
98.3895
98.3718
98.3502
98.3265
98.3028
98.2819
98.2661
98.2576
98.4085
98.402
98.3895
98.3718
98.3502
98.3265
98.3028
98.2819
98.2661
98.2576
98.4085
98.402
98.3895
98.3718
98.3502
98.3265
98.3028
98.2819
98.2661
98.2576
98.4085
98.402
98.3895
98.3718
98.3502
98.3265
98.3028
98.2819
98.2661
98.2576
98.4085
98.4021
98.3895
98.3718
98.3502
98.3265
98.3029
98.2819
98.2661
98.2576
98.4085
98.4021
98.3895
98.3718
98.3502
98.3265
98.3029
98.2819
98.2661
98.2576
90.7753
90.7642
90.7426
90.7118
90.6741
90.6324
90.5905
90.5531
90.5246
90.5092
90.7753
90.7642
90.7425
90.7118
90.6741
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7118
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7118
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7117
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7117
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7117
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7118
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7641
90.7425
90.7118
90.674
90.6323
90.5905
90.553
90.5246
90.5092
90.7753
90.7642
90.7425
90.7118
90.6741
90.6323
90.5905
90.553
90.5246
90.5092
83.2822
83.2659
83.234
83.1885
83.1321
83.0691
83.0051
82.947
82.9023
82.8778
83.2822
83.2658
83.234
83.1885
83.1321
83.0691
83.0051
82.947
82.9023
82.8778
83.2822
83.2658
83.234
83.1884
83.1321
83.0691
83.0051
82.947
82.9022
82.8778
83.2821
83.2658
83.234
83.1884
83.1321
83.0691
83.0051
82.9469
82.9022
82.8778
83.2821
83.2658
83.2339
83.1884
83.1321
83.0691
83.0051
82.9469
82.9022
82.8778
83.2821
83.2658
83.2339
83.1884
83.1321
83.0691
83.0051
82.9469
82.9022
82.8778
83.2821
83.2658
83.2339
83.1884
83.1321
83.0691
83.0051
82.9469
82.9022
82.8778
83.2821
83.2658
83.234
83.1884
83.1321
83.0691
83.0051
82.9469
82.9022
82.8778
83.2822
83.2658
83.234
83.1884
83.1321
83.0691
83.0051
82.947
82.9023
82.8778
83.2822
83.2658
83.234
83.1885
83.1321
83.0691
83.0051
82.947
82.9023
82.8778
75.9822
75.96
75.9166
75.854
75.7756
75.6866
75.5945
75.509
75.4418
75.4044
75.9821
75.96
75.9166
75.854
75.7756
75.6866
75.5944
75.5089
75.4418
75.4044
75.9821
75.9599
75.9165
75.854
75.7756
75.6866
75.5944
75.5089
75.4417
75.4044
75.9821
75.9599
75.9165
75.8539
75.7755
75.6865
75.5944
75.5089
75.4417
75.4044
75.9821
75.9599
75.9165
75.8539
75.7755
75.6865
75.5944
75.5089
75.4417
75.4043
75.9821
75.9599
75.9165
75.8539
75.7755
75.6865
75.5944
75.5089
75.4417
75.4043
75.9821
75.9599
75.9165
75.8539
75.7755
75.6865
75.5944
75.5089
75.4417
75.4044
75.9821
75.9599
75.9165
75.8539
75.7755
75.6865
75.5944
75.5089
75.4417
75.4044
75.9821
75.9599
75.9165
75.854
75.7756
75.6866
75.5944
75.5089
75.4418
75.4044
75.9821
75.96
75.9166
75.854
75.7756
75.6866
75.5944
75.5089
75.4418
75.4044
68.9253
68.8967
68.8403
68.7582
68.6537
68.5326
68.4039
68.2807
68.1807
68.1234
68.9252
68.8966
68.8403
68.7582
68.6537
68.5326
68.4039
68.2807
68.1807
68.1234
68.9252
68.8966
68.8403
68.7581
68.6536
68.5326
68.4038
68.2807
68.1806
68.1233
68.9252
68.8966
68.8402
68.7581
68.6536
68.5325
68.4038
68.2806
68.1806
68.1233
68.9252
68.8966
68.8402
68.7581
68.6536
68.5325
68.4038
68.2806
68.1806
68.1233
68.9252
68.8966
68.8402
68.7581
68.6536
68.5325
68.4038
68.2806
68.1806
68.1233
68.9252
68.8966
68.8402
68.7581
68.6536
68.5325
68.4038
68.2806
68.1806
68.1233
68.9252
68.8966
68.8402
68.7581
68.6536
68.5325
68.4038
68.2807
68.1806
68.1233
68.9252
68.8966
68.8403
68.7581
68.6537
68.5326
68.4038
68.2807
68.1807
68.1234
68.9252
68.8966
68.8403
68.7582
68.6537
68.5326
68.4039
68.2807
68.1807
68.1234
62.1577
62.1223
62.052
61.9482
61.8136
61.6534
61.4771
61.3008
61.1501
61.0592
62.1577
62.1222
62.0519
61.9481
61.8135
61.6534
61.477
61.3007
61.15
61.0592
62.1576
62.1222
62.0519
61.9481
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1222
62.0519
61.948
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1221
62.0518
61.948
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1221
62.0518
61.948
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1222
62.0518
61.948
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1222
62.0519
61.9481
61.8135
61.6533
61.477
61.3007
61.15
61.0591
62.1576
62.1222
62.0519
61.9481
61.8135
61.6534
61.477
61.3007
61.15
61.0592
62.1577
62.1222
62.0519
61.9481
61.8136
61.6534
61.4771
61.3008
61.1501
61.0592
55.7211
55.6788
55.5944
55.468
55.3006
55.0949
54.858
54.6063
54.3734
54.2196
55.721
55.6788
55.5944
55.468
55.3005
55.0948
54.858
54.6062
54.3734
54.2196
55.721
55.6787
55.5943
55.4679
55.3005
55.0948
54.8579
54.6062
54.3733
54.2196
55.7209
55.6787
55.5943
55.4679
55.3005
55.0948
54.8579
54.6061
54.3733
54.2195
55.7209
55.6787
55.5943
55.4679
55.3005
55.0947
54.8579
54.6061
54.3733
54.2195
55.7209
55.6787
55.5943
55.4679
55.3005
55.0947
54.8579
54.6061
54.3733
54.2195
55.7209
55.6787
55.5943
55.4679
55.3005
55.0948
54.8579
54.6061
54.3733
54.2195
55.721
55.6787
55.5943
55.4679
55.3005
55.0948
54.8579
54.6062
54.3733
54.2196
55.721
55.6787
55.5943
55.468
55.3005
55.0948
54.8579
54.6062
54.3734
54.2196
55.721
55.6788
55.5944
55.468
55.3006
55.0949
54.858
54.6063
54.3734
54.2197
49.6512
49.603
49.5059
49.3585
49.1587
48.9045
48.5955
48.2397
47.8692
47.5807
49.6511
49.6029
49.5059
49.3585
49.1587
48.9044
48.5955
48.2396
47.8692
47.5807
49.6511
49.6029
49.5058
49.3584
49.1586
48.9044
48.5954
48.2396
47.8691
47.5806
49.6511
49.6029
49.5058
49.3584
49.1586
48.9043
48.5954
48.2395
47.8691
47.5806
49.6511
49.6029
49.5058
49.3584
49.1586
48.9043
48.5954
48.2395
47.8691
47.5806
49.651
49.6028
49.5058
49.3584
49.1586
48.9043
48.5954
48.2395
47.8691
47.5806
49.6511
49.6029
49.5058
49.3584
49.1586
48.9043
48.5954
48.2395
47.8691
47.5806
49.6511
49.6029
49.5058
49.3584
49.1586
48.9044
48.5954
48.2395
47.8691
47.5806
49.6511
49.6029
49.5058
49.3584
49.1587
48.9044
48.5955
48.2396
47.8692
47.5807
49.6511
49.603
49.5059
49.3585
49.1587
48.9045
48.5955
48.2396
47.8692
47.5807
43.9773
43.9249
43.8187
43.6556
43.4299
43.133
42.7511
42.2664
41.6696
41.0457
43.9772
43.9248
43.8186
43.6555
43.4299
43.1329
42.751
42.2663
41.6696
41.0456
43.9772
43.9248
43.8186
43.6555
43.4298
43.1329
42.751
42.2663
41.6695
41.0456
43.9772
43.9247
43.8186
43.6554
43.4298
43.1328
42.751
42.2662
41.6695
41.0455
43.9771
43.9247
43.8185
43.6554
43.4298
43.1328
42.7509
42.2662
41.6695
41.0455
43.9771
43.9247
43.8185
43.6554
43.4298
43.1328
42.7509
42.2662
41.6695
41.0455
43.9771
43.9247
43.8186
43.6554
43.4298
43.1328
42.7509
42.2662
41.6695
41.0455
43.9772
43.9248
43.8186
43.6554
43.4298
43.1329
42.751
42.2663
41.6695
41.0456
43.9772
43.9248
43.8186
43.6555
43.4299
43.1329
42.751
42.2663
41.6695
41.0456
43.9772
43.9248
43.8187
43.6555
43.4299
43.133
42.7511
42.2664
41.6696
41.0457
38.7206
38.6668
38.5572
38.3879
38.151
37.8323
37.4047
36.8119
35.917
34.319
38.7206
38.6667
38.5572
38.3879
38.151
37.8322
37.4046
36.8118
35.917
34.3189
38.7205
38.6667
38.5571
38.3878
38.1509
37.8322
37.4046
36.8118
35.9169
34.3189
38.7205
38.6666
38.5571
38.3878
38.1509
37.8321
37.4046
36.8117
35.9169
34.3188
38.7205
38.6666
38.5571
38.3878
38.1509
37.8321
37.4046
36.8117
35.9169
34.3188
38.7205
38.6666
38.5571
38.3878
38.1509
37.8321
37.4045
36.8117
35.9169
34.3188
38.7205
38.6666
38.5571
38.3878
38.1509
37.8321
37.4046
36.8117
35.9169
34.3188
38.7205
38.6666
38.5571
38.3878
38.1509
37.8322
37.4046
36.8117
35.9169
34.3189
38.7206
38.6667
38.5572
38.3879
38.1509
37.8322
37.4046
36.8118
35.917
34.3189
38.7206
38.6667
38.5572
38.3879
38.151
37.8323
37.4047
36.8119
35.917
34.319
33.8938
33.8418
33.7362
33.5733
33.3462
33.0419
32.6371
32.0886
31.318
30.2051
33.8937
33.8417
33.7361
33.5733
33.3461
33.0419
32.6371
32.0885
31.318
30.205
33.8937
33.8417
33.7361
33.5732
33.3461
33.0418
32.637
32.0885
31.3179
30.2049
33.8936
33.8416
33.7361
33.5732
33.3461
33.0418
32.637
32.0885
31.3179
30.2049
33.8936
33.8416
33.736
33.5732
33.346
33.0418
32.637
32.0884
31.3179
30.2049
33.8936
33.8416
33.736
33.5732
33.346
33.0418
32.637
32.0884
31.3179
30.2049
33.8936
33.8416
33.736
33.5732
33.3461
33.0418
32.637
32.0885
31.3179
30.2049
33.8937
33.8416
33.7361
33.5732
33.3461
33.0418
32.637
32.0885
31.3179
30.2049
33.8937
33.8417
33.7361
33.5733
33.3461
33.0419
32.6371
32.0885
31.318
30.205
33.8937
33.8417
33.7362
33.5733
33.3462
33.0419
32.6371
32.0886
31.318
30.2051
29.4999
29.4531
29.3588
29.215
29.0184
28.7627
28.4381
28.0308
27.5295
26.9563
29.4998
29.453
29.3587
29.215
29.0183
28.7627
28.4381
28.0308
27.5294
26.9563
29.4998
29.453
29.3587
29.2149
29.0183
28.7626
28.438
28.0307
27.5294
26.9562
29.4998
29.453
29.3586
29.2149
29.0183
28.7626
28.438
28.0307
27.5293
26.9562
29.4998
29.453
29.3586
29.2149
29.0183
28.7626
28.438
28.0307
27.5293
26.9561
29.4998
29.4529
29.3586
29.2149
29.0183
28.7626
28.438
28.0307
27.5293
26.9561
29.4998
29.453
29.3586
29.2149
29.0183
28.7626
28.438
28.0307
27.5293
26.9562
29.4998
29.453
29.3587
29.2149
29.0183
28.7626
28.438
28.0307
27.5293
26.9562
29.4998
29.453
29.3587
29.215
29.0183
28.7627
28.4381
28.0307
27.5294
26.9562
29.4999
29.4531
29.3587
29.215
29.0184
28.7627
28.4381
28.0308
27.5295
26.9563
25.5333
25.4944
25.4171
25.3022
25.1511
24.9659
24.7509
24.5163
24.2877
24.1291
25.5332
25.4943
25.4171
25.3022
25.151
24.9658
24.7508
24.5162
24.2877
24.129
25.5332
25.4943
25.417
25.3021
25.151
24.9658
24.7508
24.5162
24.2876
24.1289
25.5331
25.4943
25.417
25.3021
25.151
24.9657
24.7507
24.5161
24.2876
24.1289
25.5331
25.4943
25.417
25.3021
25.1509
24.9657
24.7507
24.5161
24.2876
24.1289
25.5331
25.4943
25.417
25.3021
25.1509
24.9657
24.7507
24.5161
24.2876
24.1289
25.5331
25.4943
25.417
25.3021
25.151
24.9657
24.7507
24.5161
24.2876
24.1289
25.5332
25.4943
25.417
25.3021
25.151
24.9658
24.7508
24.5162
24.2876
24.1289
25.5332
25.4943
25.4171
25.3022
25.151
24.9658
24.7508
24.5162
24.2877
24.129
25.5332
25.4944
25.4171
25.3022
25.1511
24.9659
24.7509
24.5163
24.2877
24.129
21.9802
21.951
21.8942
21.8135
21.7151
21.6087
21.5098
21.4433
21.4501
21.5971
21.9802
21.9509
21.8941
21.8135
21.7151
21.6087
21.5098
21.4432
21.45
21.597
21.9801
21.9509
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.45
21.597
21.9801
21.9508
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.4499
21.5969
21.9801
21.9508
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.4499
21.5969
21.9801
21.9508
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.4499
21.5969
21.9801
21.9508
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.4499
21.5969
21.9801
21.9509
21.8941
21.8134
21.715
21.6086
21.5097
21.4432
21.45
21.597
21.9802
21.9509
21.8941
21.8135
21.7151
21.6087
21.5098
21.4432
21.45
21.597
21.9802
21.951
21.8942
21.8135
21.7151
21.6087
21.5098
21.4433
21.4501
21.5971
18.8208
18.8016
18.7662
18.7206
18.675
18.6453
18.6547
18.737
18.9388
19.3203
18.8208
18.8016
18.7662
18.7206
18.675
18.6452
18.6546
18.7369
18.9387
19.3202
18.8207
18.8016
18.7661
18.7205
18.6749
18.6452
18.6546
18.7369
18.9387
19.3202
18.8207
18.8015
18.7661
18.7205
18.6749
18.6451
18.6545
18.7368
18.9386
19.3201
18.8207
18.8015
18.7661
18.7205
18.6749
18.6451
18.6545
18.7368
18.9386
19.3201
18.8207
18.8015
18.7661
18.7205
18.6749
18.6451
18.6545
18.7368
18.9386
19.3201
18.8207
18.8015
18.7661
18.7205
18.6749
18.6451
18.6545
18.7368
18.9386
19.3201
18.8207
18.8016
18.7661
18.7205
18.6749
18.6452
18.6546
18.7369
18.9387
19.3202
18.8207
18.8016
18.7662
18.7206
18.675
18.6452
18.6546
18.7369
18.9387
19.3202
18.8208
18.8016
18.7662
18.7206
18.675
18.6453
18.6547
18.737
18.9388
19.3203
16.0306
16.0209
16.0052
15.9916
15.9931
16.03
16.1315
16.338
16.7017
17.2797
16.0305
16.0208
16.0052
15.9915
15.9931
16.0299
16.1314
16.338
16.7016
17.2796
16.0305
16.0208
16.0052
15.9915
15.993
16.0299
16.1314
16.3379
16.7016
17.2795
16.0305
16.0208
16.0051
15.9915
15.993
16.0299
16.1313
16.3379
16.7015
17.2795
16.0305
16.0208
16.0051
15.9915
15.993
16.0299
16.1313
16.3379
16.7015
17.2795
16.0305
16.0208
16.0051
15.9915
15.993
16.0299
16.1313
16.3379
16.7015
17.2795
16.0305
16.0208
16.0051
15.9915
15.993
16.0299
16.1313
16.3379
16.7015
17.2795
16.0305
16.0208
16.0052
15.9915
15.993
16.0299
16.1314
16.3379
16.7016
17.2795
16.0305
16.0208
16.0052
15.9915
15.9931
16.03
16.1314
16.338
16.7016
17.2796
16.0306
16.0209
16.0052
15.9916
15.9931
16.03
16.1315
16.338
16.7017
17.2797
13.5825
13.5807
13.5814
13.5936
13.6321
13.7197
13.8901
14.1912
14.6869
15.4496
13.5824
13.5806
13.5814
13.5935
13.632
13.7196
13.8901
14.1911
14.6868
15.4495
13.5824
13.5806
13.5813
13.5935
13.632
13.7196
13.89
14.1911
14.6868
15.4495
13.5824
13.5806
13.5813
13.5935
13.6319
13.7196
13.89
14.191
14.6867
15.4494
13.5823
13.5806
13.5813
13.5935
13.6319
13.7196
13.89
14.191
14.6867
15.4494
13.5823
13.5806
13.5813
13.5935
13.6319
13.7196
13.89
14.191
14.6867
15.4494
13.5824
13.5806
13.5813
13.5935
13.6319
13.7196
13.89
14.191
14.6867
15.4494
13.5824
13.5806
13.5813
13.5935
13.632
13.7196
13.89
14.1911
14.6868
15.4495
13.5824
13.5806
13.5814
13.5935
13.632
13.7196
13.8901
14.1911
14.6868
15.4495
13.5824
13.5807
13.5814
13.5936
13.6321
13.7197
13.8901
14.1912
14.6869
15.4496
11.4483
11.4524
11.4649
11.4947
11.5569
11.6747
11.8831
12.2365
12.82
13.7633
11.4483
11.4524
11.4648
11.4947
11.5569
11.6746
11.8831
12.2365
12.8199
13.7633
11.4483
11.4524
11.4648
11.4946
11.5568
11.6746
11.883
12.2364
12.8199
13.7632
11.4482
11.4523
11.4648
11.4946
11.5568
11.6745
11.883
12.2364
12.8198
13.7632
11.4482
11.4523
11.4648
11.4946
11.5568
11.6745
11.883
12.2364
12.8198
13.7632
11.4482
11.4523
11.4648
11.4946
11.5568
11.6745
11.883
12.2364
12.8198
13.7632
11.4482
11.4523
11.4648
11.4946
11.5568
11.6746
11.883
12.2364
12.8198
13.7632
11.4483
11.4523
11.4648
11.4946
11.5568
11.6746
11.883
12.2364
12.8199
13.7632
11.4483
11.4524
11.4648
11.4947
11.5569
11.6746
11.8831
12.2365
12.8199
13.7633
11.4483
11.4524
11.4649
11.4947
11.5569
11.6747
11.8831
12.2365
12.82
13.7634
9.60042
9.60809
9.62731
9.66615
9.73782
9.86246
10.0707
10.412
10.9808
12.0107
9.60038
9.60805
9.62727
9.66611
9.73778
9.86242
10.0706
10.412
10.9808
12.0107
9.60035
9.60802
9.62725
9.66608
9.73775
9.86239
10.0706
10.4119
10.9807
12.0106
9.60033
9.60801
9.62723
9.66606
9.73773
9.86237
10.0706
10.4119
10.9807
12.0106
9.60032
9.608
9.62722
9.66605
9.73772
9.86236
10.0706
10.4119
10.9807
12.0106
9.60032
9.608
9.62722
9.66605
9.73772
9.86236
10.0706
10.4119
10.9807
12.0106
9.60033
9.60801
9.62723
9.66606
9.73773
9.86237
10.0706
10.4119
10.9807
12.0106
9.60035
9.60803
9.62725
9.66608
9.73775
9.86239
10.0706
10.4119
10.9807
12.0106
9.60038
9.60805
9.62728
9.66611
9.73779
9.86243
10.0706
10.412
10.9808
12.0107
9.60041
9.60809
9.62732
9.66616
9.73783
9.86247
10.0707
10.412
10.9808
12.0108
30.5899
29.2632
29.5984
31.3559
34.5174
39.2072
45.6927
54.4486
66.3329
83.0589
30.5898
29.2631
29.5983
31.3558
34.5173
39.2071
45.6926
54.4485
66.3328
83.0587
30.5898
29.263
29.5982
31.3557
34.5172
39.207
45.6925
54.4484
66.3327
83.0586
30.5897
29.263
29.5982
31.3556
34.5171
39.2069
45.6924
54.4483
66.3326
83.0585
30.5897
29.263
29.5981
31.3556
34.5171
39.2069
45.6924
54.4483
66.3325
83.0585
30.5897
29.263
29.5981
31.3556
34.5171
39.2069
45.6924
54.4482
66.3325
83.0585
30.5897
29.263
29.5981
31.3556
34.5171
39.2069
45.6924
54.4483
66.3326
83.0585
30.5898
29.263
29.5982
31.3556
34.5172
39.2069
45.6924
54.4483
66.3326
83.0586
30.5898
29.2631
29.5982
31.3557
34.5172
39.207
45.6925
54.4484
66.3327
83.0587
30.5899
29.2631
29.5983
31.3558
34.5173
39.2071
45.6926
54.4485
66.3328
83.0588
28.7281
28.1941
28.8195
30.6464
33.736
38.2118
44.2772
52.23
62.4558
75.2739
28.7281
28.194
28.8194
30.6463
33.7359
38.2117
44.2771
52.2299
62.4556
75.2737
28.728
28.194
28.8193
30.6462
33.7358
38.2116
44.277
52.2298
62.4555
75.2736
28.728
28.1939
28.8193
30.6462
33.7357
38.2115
44.2769
52.2297
62.4554
75.2735
28.7279
28.1939
28.8192
30.6461
33.7357
38.2115
44.2769
52.2297
62.4554
75.2735
28.7279
28.1939
28.8192
30.6461
33.7357
38.2115
44.2769
52.2297
62.4554
75.2735
28.7279
28.1939
28.8193
30.6461
33.7357
38.2115
44.2769
52.2297
62.4554
75.2735
28.728
28.1939
28.8193
30.6462
33.7358
38.2116
44.2769
52.2297
62.4555
75.2736
28.728
28.194
28.8194
30.6462
33.7358
38.2116
44.277
52.2298
62.4556
75.2737
28.7281
28.1941
28.8194
30.6463
33.7359
38.2118
44.2771
52.2299
62.4557
75.2738
26.4693
26.5587
27.4807
29.3659
32.3115
36.4228
41.8237
48.6418
56.9427
66.5459
26.4692
26.5586
27.4806
29.3657
32.3114
36.4227
41.8236
48.6416
56.9425
66.5458
26.4691
26.5585
27.4805
29.3657
32.3113
36.4226
41.8235
48.6415
56.9424
66.5457
26.4691
26.5585
27.4805
29.3656
32.3112
36.4225
41.8234
48.6415
56.9423
66.5456
26.4691
26.5585
27.4805
29.3656
32.3112
36.4225
41.8234
48.6414
56.9423
66.5456
26.4691
26.5585
27.4805
29.3656
32.3112
36.4225
41.8234
48.6414
56.9423
66.5456
26.4691
26.5585
27.4805
29.3656
32.3112
36.4225
41.8234
48.6414
56.9423
66.5456
26.4691
26.5585
27.4805
29.3656
32.3112
36.4225
41.8235
48.6415
56.9424
66.5457
26.4692
26.5586
27.4806
29.3657
32.3113
36.4226
41.8236
48.6416
56.9425
66.5458
26.4692
26.5587
27.4807
29.3658
32.3114
36.4227
41.8237
48.6417
56.9426
66.5459
24.1809
24.6814
25.8159
27.7103
30.4568
34.131
38.792
44.4613
51.0687
58.3527
24.1809
24.6813
25.8158
27.7102
30.4567
34.1308
38.7918
44.4612
51.0686
58.3525
24.1808
24.6812
25.8157
27.7101
30.4566
34.1308
38.7918
44.4611
51.0685
58.3524
24.1808
24.6811
25.8156
27.7101
30.4566
34.1307
38.7917
44.461
51.0684
58.3523
24.1807
24.6811
25.8156
27.7101
30.4566
34.1307
38.7917
44.461
51.0684
58.3523
24.1807
24.6811
25.8156
27.71
30.4565
34.1307
38.7917
44.461
51.0684
58.3523
24.1808
24.6811
25.8156
27.7101
30.4566
34.1307
38.7917
44.461
51.0684
58.3523
24.1808
24.6812
25.8157
27.7101
30.4566
34.1307
38.7917
44.4611
51.0684
58.3524
24.1809
24.6812
25.8157
27.7102
30.4567
34.1308
38.7918
44.4612
51.0685
58.3525
24.1809
24.6813
25.8158
27.7103
30.4568
34.1309
38.7919
44.4613
51.0687
58.3526
21.9874
22.7547
24.0205
25.8791
28.3994
31.6266
35.5759
40.2162
45.4393
51.0226
21.9873
22.7546
24.0204
25.879
28.3993
31.6265
35.5758
40.216
45.4392
51.0225
21.9872
22.7546
24.0203
25.8789
28.3993
31.6264
35.5757
40.216
45.4391
51.0224
21.9872
22.7545
24.0203
25.8789
28.3992
31.6264
35.5757
40.2159
45.439
51.0223
21.9872
22.7545
24.0202
25.8788
28.3992
31.6263
35.5756
40.2159
45.439
51.0223
21.9872
22.7545
24.0202
25.8788
28.3992
31.6263
35.5756
40.2159
45.439
51.0223
21.9872
22.7545
24.0203
25.8788
28.3992
31.6264
35.5757
40.2159
45.439
51.0223
21.9872
22.7546
24.0203
25.8789
28.3992
31.6264
35.5757
40.2159
45.4391
51.0224
21.9873
22.7546
24.0204
25.879
28.3993
31.6265
35.5758
40.216
45.4392
51.0225
21.9874
22.7547
24.0205
25.8791
28.3994
31.6266
35.5759
40.2162
45.4393
51.0226
19.9517
20.9053
22.2515
24.051
26.3471
29.1594
32.4755
36.2406
40.3466
44.6258
19.9517
20.9052
22.2514
24.0509
26.347
29.1593
32.4753
36.2405
40.3465
44.6257
19.9516
20.9052
22.2514
24.0508
26.3469
29.1592
32.4752
36.2404
40.3464
44.6256
19.9516
20.9051
22.2513
24.0508
26.3469
29.1591
32.4752
36.2404
40.3463
44.6255
19.9515
20.9051
22.2513
24.0507
26.3468
29.1591
32.4752
36.2403
40.3463
44.6255
19.9515
20.9051
22.2513
24.0507
26.3468
29.1591
32.4752
36.2403
40.3463
44.6255
19.9516
20.9051
22.2513
24.0508
26.3468
29.1591
32.4752
36.2404
40.3463
44.6255
19.9516
20.9052
22.2514
24.0508
26.3469
29.1592
32.4752
36.2404
40.3464
44.6256
19.9516
20.9052
22.2514
24.0509
26.347
29.1593
32.4753
36.2405
40.3465
44.6257
19.9517
20.9053
22.2515
24.051
26.3471
29.1594
32.4754
36.2406
40.3466
44.6258
18.1171
19.2272
20.6365
22.3782
24.4761
26.9312
29.7132
32.7543
35.9506
39.1757
18.117
19.2272
20.6364
22.3781
24.476
26.9311
29.7131
32.7542
35.9505
39.1755
18.117
19.2271
20.6364
22.3781
24.4759
26.931
29.713
32.7541
35.9504
39.1754
18.1169
19.2271
20.6363
22.378
24.4759
26.931
29.7129
32.754
35.9503
39.1754
18.1169
19.227
20.6363
22.378
24.4758
26.931
29.7129
32.754
35.9503
39.1753
18.1169
19.227
20.6363
22.378
24.4758
26.931
29.7129
32.754
35.9503
39.1753
18.1169
19.2271
20.6363
22.378
24.4759
26.931
29.7129
32.7541
35.9503
39.1754
18.117
19.2271
20.6364
22.3781
24.4759
26.931
29.713
32.7541
35.9504
39.1754
18.117
19.2272
20.6364
22.3781
24.476
26.9311
29.7131
32.7542
35.9505
39.1755
18.1171
19.2272
20.6365
22.3782
24.4761
26.9312
29.7132
32.7543
35.9506
39.1757
16.5183
17.8005
19.2834
20.9882
22.9312
25.1031
27.4602
29.9201
32.3686
34.687
16.5182
17.8004
19.2833
20.9882
22.9311
25.103
27.4601
29.92
32.3685
34.6869
16.5182
17.8003
19.2832
20.9881
22.931
25.1029
27.46
29.9199
32.3684
34.6868
16.5181
17.8003
19.2832
20.988
22.9309
25.1029
27.4599
29.9199
32.3683
34.6867
16.5181
17.8003
19.2832
20.988
22.9309
25.1028
27.4599
29.9198
32.3683
34.6867
16.5181
17.8003
19.2832
20.988
22.9309
25.1028
27.4599
29.9199
32.3683
34.6867
16.5181
17.8003
19.2832
20.9881
22.931
25.1029
27.4599
29.9199
32.3683
34.6868
16.5182
17.8003
19.2832
20.9881
22.931
25.1029
27.46
29.9199
32.3684
34.6868
16.5182
17.8004
19.2833
20.9882
22.9311
25.103
27.4601
29.92
32.3685
34.6869
16.5183
17.8005
19.2834
20.9883
22.9312
25.1031
27.4602
29.9201
32.3686
34.687
15.1979
16.7096
18.2903
19.9872
21.8279
23.8024
25.8559
27.8842
29.7334
31.2214
15.1978
16.7095
18.2902
19.9871
21.8279
23.8023
25.8558
27.8841
29.7333
31.2213
15.1977
16.7095
18.2901
19.987
21.8278
23.8023
25.8557
27.884
29.7332
31.2212
15.1977
16.7094
18.2901
19.987
21.8278
23.8022
25.8557
27.8839
29.7331
31.2211
15.1977
16.7094
18.2901
19.987
21.8277
23.8022
25.8556
27.8839
29.7331
31.2211
15.1977
16.7094
18.2901
19.987
21.8277
23.8022
25.8557
27.8839
29.7331
31.2211
15.1977
16.7095
18.2901
19.987
21.8278
23.8022
25.8557
27.8839
29.7331
31.2212
15.1978
16.7095
18.2901
19.987
21.8278
23.8023
25.8557
27.884
29.7332
31.2212
15.1978
16.7095
18.2902
19.9871
21.8279
23.8024
25.8558
27.8841
29.7333
31.2213
15.1979
16.7096
18.2903
19.9872
21.828
23.8025
25.8559
27.8842
29.7334
31.2214
14.2745
16.0738
17.7527
19.4599
21.2522
23.1247
25.0156
26.7978
28.2547
29.0148
14.2745
16.0738
17.7527
19.4598
21.2521
23.1247
25.0155
26.7977
28.2546
29.0147
14.2744
16.0737
17.7526
19.4598
21.2521
23.1246
25.0154
26.7976
28.2545
29.0146
14.2744
16.0737
17.7526
19.4597
21.252
23.1246
25.0154
26.7976
28.2545
29.0146
14.2744
16.0737
17.7526
19.4597
21.252
23.1245
25.0154
26.7975
28.2545
29.0146
14.2744
16.0737
17.7526
19.4597
21.252
23.1245
25.0154
26.7975
28.2545
29.0146
14.2744
16.0737
17.7526
19.4598
21.2521
23.1246
25.0154
26.7976
28.2545
29.0146
14.2744
16.0737
17.7526
19.4598
21.2521
23.1246
25.0155
26.7976
28.2546
29.0147
14.2745
16.0738
17.7527
19.4599
21.2522
23.1247
25.0155
26.7977
28.2546
29.0147
14.2745
16.0739
17.7528
19.46
21.2523
23.1248
25.0156
26.7978
28.2548
29.0149
108.588
120.663
128.015
133.128
136.888
139.695
141.765
143.229
144.165
144.622
108.588
120.663
128.015
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.662
128.015
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.662
128.014
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.587
120.662
128.014
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.587
120.662
128.014
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.662
128.014
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.662
128.015
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.663
128.015
133.127
136.887
139.694
141.765
143.228
144.165
144.622
108.588
120.663
128.015
133.128
136.888
139.695
141.765
143.229
144.165
144.622
90.0426
100.759
108.301
113.745
117.763
120.75
122.941
124.483
125.466
125.946
90.0425
100.759
108.301
113.745
117.763
120.75
122.941
124.483
125.466
125.946
90.0424
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0423
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0422
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0422
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0423
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0423
100.759
108.301
113.744
117.763
120.75
122.941
124.482
125.466
125.945
90.0424
100.759
108.301
113.745
117.763
120.75
122.941
124.483
125.466
125.946
90.0426
100.759
108.301
113.745
117.763
120.75
122.941
124.483
125.466
125.946
76.6048
85.1255
91.8122
96.9422
100.85
103.801
105.982
107.523
108.509
108.989
76.6046
85.1254
91.812
96.942
100.85
103.8
105.982
107.523
108.508
108.989
76.6045
85.1252
91.8119
96.9419
100.85
103.8
105.982
107.523
108.508
108.989
76.6044
85.1252
91.8118
96.9418
100.85
103.8
105.982
107.523
108.508
108.989
76.6044
85.1251
91.8118
96.9418
100.85
103.8
105.982
107.523
108.508
108.989
76.6044
85.1251
91.8118
96.9418
100.85
103.8
105.982
107.523
108.508
108.989
76.6044
85.1252
91.8118
96.9418
100.85
103.8
105.982
107.523
108.508
108.989
76.6045
85.1252
91.8119
96.9419
100.85
103.8
105.982
107.523
108.508
108.989
76.6046
85.1253
91.812
96.942
100.85
103.8
105.982
107.523
108.509
108.989
76.6047
85.1255
91.8122
96.9422
100.85
103.801
105.982
107.523
108.509
108.989
65.74
72.4004
77.9889
82.5003
86.0579
88.8053
90.866
92.335
93.2793
93.7413
65.7399
72.4002
77.9888
82.5001
86.0578
88.8051
90.8658
92.3348
93.2792
93.7412
65.7398
72.4001
77.9887
82.5
86.0577
88.805
90.8657
92.3347
93.2791
93.7411
65.7397
72.4
77.9886
82.4999
86.0576
88.8049
90.8656
92.3347
93.279
93.741
65.7397
72.4
77.9885
82.4999
86.0575
88.8049
90.8656
92.3346
93.279
93.741
65.7397
72.4
77.9885
82.4999
86.0575
88.8049
90.8656
92.3346
93.279
93.741
65.7397
72.4
77.9886
82.5
86.0576
88.8049
90.8656
92.3347
93.279
93.7411
65.7398
72.4001
77.9887
82.5
86.0577
88.805
90.8657
92.3348
93.2791
93.7412
65.7399
72.4002
77.9888
82.5002
86.0578
88.8051
90.8659
92.3349
93.2793
93.7413
65.74
72.4004
77.9889
82.5003
86.058
88.8053
90.8661
92.3351
93.2795
93.7415
56.6112
61.7938
66.3233
70.1219
73.2112
75.6527
77.5148
78.8576
79.7273
80.1546
56.6111
61.7936
66.3231
70.1218
73.211
75.6525
77.5146
78.8574
79.7271
80.1544
56.611
61.7935
66.323
70.1216
73.2109
75.6524
77.5145
78.8573
79.727
80.1544
56.6109
61.7935
66.3229
70.1216
73.2108
75.6523
77.5144
78.8572
79.727
80.1543
56.6109
61.7934
66.3229
70.1215
73.2108
75.6523
77.5144
78.8572
79.7269
80.1543
56.6109
61.7934
66.3229
70.1215
73.2108
75.6523
77.5144
78.8572
79.7269
80.1543
56.6109
61.7935
66.3229
70.1216
73.2108
75.6523
77.5144
78.8573
79.727
80.1543
56.611
61.7935
66.323
70.1217
73.2109
75.6524
77.5145
78.8574
79.7271
80.1544
56.6111
61.7937
66.3231
70.1218
73.211
75.6525
77.5147
78.8575
79.7272
80.1546
56.6112
61.7938
66.3233
70.1219
73.2112
75.6527
77.5148
78.8577
79.7274
80.1547
48.8654
52.8524
56.4319
59.524
62.1074
64.1949
65.8148
66.9978
67.7705
68.1521
48.8653
52.8522
56.4317
59.5239
62.1072
64.1948
65.8146
66.9976
67.7704
68.1519
48.8652
52.8521
56.4316
59.5238
62.1071
64.1947
65.8145
66.9975
67.7703
68.1519
48.8651
52.852
56.4315
59.5237
62.107
64.1946
65.8145
66.9975
67.7702
68.1518
48.8651
52.852
56.4315
59.5236
62.107
64.1946
65.8144
66.9974
67.7702
68.1518
48.8651
52.852
56.4315
59.5237
62.107
64.1946
65.8145
66.9974
67.7702
68.1518
48.8651
52.8521
56.4316
59.5237
62.107
64.1946
65.8145
66.9975
67.7703
68.1518
48.8652
52.8521
56.4316
59.5238
62.1071
64.1947
65.8146
66.9976
67.7704
68.1519
48.8653
52.8522
56.4317
59.5239
62.1072
64.1948
65.8147
66.9977
67.7705
68.1521
48.8654
52.8524
56.4319
59.524
62.1074
64.195
65.8149
66.9979
67.7707
68.1522
42.3133
45.2901
48.0274
50.4595
52.5458
54.2701
55.6323
56.6404
57.3051
57.635
42.3131
45.2899
48.0273
50.4593
52.5457
54.27
55.6321
56.6403
57.3049
57.6349
42.313
45.2898
48.0272
50.4592
52.5456
54.2699
55.632
56.6402
57.3049
57.6348
42.313
45.2898
48.0271
50.4591
52.5455
54.2698
55.6319
56.6401
57.3048
57.6348
42.313
45.2897
48.0271
50.4591
52.5455
54.2698
55.6319
56.6401
57.3048
57.6348
42.313
45.2897
48.0271
50.4591
52.5455
54.2698
55.6319
56.6401
57.3048
57.6348
42.313
45.2898
48.0271
50.4592
52.5455
54.2698
55.632
56.6402
57.3048
57.6348
42.3131
45.2898
48.0272
50.4592
52.5456
54.2699
55.6321
56.6402
57.3049
57.6349
42.3132
45.2899
48.0273
50.4594
52.5457
54.27
55.6322
56.6404
57.3051
57.635
42.3133
45.2901
48.0275
50.4595
52.5459
54.2702
55.6323
56.6405
57.3052
57.6352
36.8238
38.8944
40.8788
42.7124
44.3373
45.715
46.825
47.6584
48.2134
48.4904
36.8237
38.8942
40.8786
42.7123
44.3372
45.7149
46.8248
47.6583
48.2132
48.4903
36.8236
38.8942
40.8785
42.7122
44.3371
45.7148
46.8248
47.6582
48.2132
48.4903
36.8236
38.8941
40.8785
42.7121
44.337
45.7148
46.8247
47.6582
48.2131
48.4902
36.8235
38.8941
40.8785
42.7121
44.337
45.7147
46.8247
47.6581
48.2131
48.4902
36.8236
38.8941
40.8785
42.7121
44.337
45.7147
46.8247
47.6581
48.2131
48.4902
36.8236
38.8941
40.8785
42.7122
44.337
45.7148
46.8247
47.6582
48.2131
48.4903
36.8237
38.8942
40.8786
42.7122
44.3371
45.7149
46.8248
47.6583
48.2132
48.4903
36.8238
38.8943
40.8787
42.7123
44.3372
45.715
46.8249
47.6584
48.2133
48.4905
36.8239
38.8944
40.8788
42.7125
44.3374
45.7151
46.8251
47.6585
48.2135
48.4906
32.2619
33.4644
34.7783
36.0887
37.3064
38.3724
39.2507
39.9207
40.3716
40.5981
32.2618
33.4643
34.7782
36.0886
37.3063
38.3723
39.2506
39.9206
40.3715
40.598
32.2618
33.4642
34.7781
36.0885
37.3062
38.3722
39.2505
39.9205
40.3714
40.5979
32.2617
33.4642
34.778
36.0885
37.3061
38.3721
39.2504
39.9205
40.3714
40.5979
32.2617
33.4641
34.778
36.0884
37.3061
38.3721
39.2504
39.9205
40.3713
40.5979
32.2617
33.4641
34.778
36.0884
37.3061
38.3721
39.2504
39.9205
40.3714
40.5979
32.2617
33.4642
34.778
36.0885
37.3062
38.3722
39.2505
39.9205
40.3714
40.598
32.2618
33.4642
34.7781
36.0885
37.3062
38.3722
39.2505
39.9206
40.3715
40.598
32.2619
33.4643
34.7782
36.0887
37.3063
38.3723
39.2507
39.9207
40.3716
40.5981
32.262
33.4645
34.7783
36.0888
37.3065
38.3725
39.2508
39.9208
40.3717
40.5983
28.3576
28.7524
29.5225
30.4119
31.2939
32.0958
32.773
33.2984
33.6558
33.8366
28.3575
28.7523
29.5224
30.4118
31.2938
32.0957
32.7729
33.2983
33.6557
33.8365
28.3575
28.7522
29.5224
30.4117
31.2937
32.0956
32.7728
33.2982
33.6557
33.8364
28.3574
28.7522
29.5223
30.4116
31.2937
32.0955
32.7728
33.2982
33.6556
33.8364
28.3574
28.7521
29.5223
30.4116
31.2936
32.0955
32.7727
33.2981
33.6556
33.8364
28.3574
28.7521
29.5223
30.4116
31.2937
32.0955
32.7728
33.2981
33.6556
33.8364
28.3574
28.7522
29.5223
30.4116
31.2937
32.0956
32.7728
33.2982
33.6557
33.8364
28.3575
28.7522
29.5224
30.4117
31.2938
32.0956
32.7729
33.2983
33.6557
33.8365
28.3576
28.7523
29.5225
30.4118
31.2939
32.0957
32.773
33.2984
33.6558
33.8366
28.3577
28.7524
29.5226
30.4119
31.294
32.0959
32.7731
33.2985
33.656
33.8367
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
404.778
404.795
404.828
404.87
404.919
404.967
405.011
405.047
405.073
405.086
374.406
374.461
374.562
374.696
374.846
374.996
375.133
375.244
375.323
375.363
374.406
374.46
374.562
374.696
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.695
374.846
374.996
375.133
375.244
375.322
375.363
374.406
374.46
374.562
374.696
374.846
374.996
375.133
375.244
375.322
375.363
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.954
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.954
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.953
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.954
344.243
344.343
344.528
344.771
345.041
345.309
345.55
345.746
345.883
345.954
314.412
314.575
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.255
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.255
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.255
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.255
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
314.412
314.574
314.871
315.256
315.677
316.089
316.456
316.752
316.957
317.063
285.006
285.261
285.719
286.299
286.921
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.719
286.299
286.921
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.719
286.299
286.921
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.718
286.298
286.92
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.718
286.298
286.92
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.718
286.298
286.92
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.718
286.298
286.92
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.718
286.298
286.921
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.719
286.299
286.921
287.518
288.041
288.456
288.743
288.889
285.006
285.261
285.719
286.299
286.921
287.518
288.041
288.456
288.743
288.889
256.073
256.476
257.178
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.178
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.177
258.038
258.933
259.769
260.486
261.046
261.429
261.622
256.073
256.476
257.178
258.038
258.933
259.769
260.486
261.046
261.429
261.622
227.587
228.245
229.335
230.607
231.874
233.017
233.971
234.703
235.195
235.443
227.587
228.245
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.245
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.244
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.244
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.244
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.244
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.245
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.442
227.587
228.245
229.335
230.607
231.873
233.017
233.971
234.702
235.195
235.443
227.587
228.245
229.335
230.607
231.873
233.017
233.971
234.703
235.195
235.443
199.392
200.533
202.269
204.148
205.913
207.439
208.672
209.596
210.21
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.672
209.596
210.21
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.671
209.596
210.209
210.515
199.392
200.533
202.269
204.148
205.913
207.438
208.672
209.596
210.21
210.515
199.392
200.533
202.269
204.148
205.913
207.439
208.672
209.596
210.21
210.515
171.079
173.256
176.097
178.853
181.253
183.223
184.761
185.888
186.625
186.99
171.078
173.256
176.097
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.078
173.256
176.096
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.078
173.256
176.096
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.078
173.255
176.096
178.853
181.252
183.222
184.761
185.888
186.625
186.989
171.078
173.255
176.096
178.853
181.252
183.222
184.761
185.888
186.625
186.989
171.078
173.256
176.096
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.078
173.256
176.096
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.078
173.256
176.097
178.853
181.253
183.223
184.761
185.888
186.625
186.989
171.079
173.256
176.097
178.853
181.253
183.223
184.761
185.888
186.625
186.99
141.657
146.393
151.101
155.021
158.143
160.573
162.409
163.725
164.575
164.992
141.657
146.393
151.101
155.02
158.143
160.573
162.409
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.1
155.02
158.143
160.573
162.408
163.725
164.575
164.992
141.657
146.393
151.101
155.02
158.143
160.573
162.409
163.725
164.575
164.992
141.657
146.393
151.101
155.021
158.144
160.573
162.409
163.725
164.575
164.992
8.01216
8.02135
8.04289
8.08314
8.15207
8.26362
8.4358
8.68879
9.03354
9.41364
8.01212
8.02132
8.04286
8.0831
8.15203
8.26358
8.43576
8.68875
9.0335
9.41361
8.0121
8.02129
8.04283
8.08308
8.152
8.26356
8.43573
8.68872
9.03348
9.41358
8.01208
8.02128
8.04281
8.08306
8.15199
8.26354
8.43572
8.68871
9.03346
9.41356
8.01207
8.02127
8.04281
8.08305
8.15198
8.26353
8.43571
8.6887
9.03345
9.41355
8.01207
8.02127
8.04281
8.08305
8.15198
8.26353
8.43571
8.6887
9.03345
9.41355
8.01208
8.02128
8.04282
8.08306
8.15199
8.26354
8.43572
8.68871
9.03346
9.41357
8.0121
8.0213
8.04283
8.08308
8.15201
8.26357
8.43574
8.68874
9.03349
9.41359
8.01212
8.02132
8.04286
8.08311
8.15204
8.2636
8.43578
8.68877
9.03353
9.41363
8.01215
8.02136
8.0429
8.08315
8.15208
8.26364
8.43582
8.68882
9.03357
9.41368
6.65878
6.66794
6.68855
6.72509
6.78402
6.87324
7.00022
7.1673
7.35978
7.52013
6.65875
6.66791
6.68852
6.72505
6.78399
6.87321
7.00019
7.16727
7.35975
7.5201
6.65872
6.66788
6.6885
6.72503
6.78397
6.87318
7.00016
7.16724
7.35973
7.52008
6.65871
6.66787
6.68848
6.72502
6.78395
6.87317
7.00014
7.16722
7.35971
7.52006
6.6587
6.66786
6.68848
6.72501
6.78394
6.87316
7.00014
7.16722
7.3597
7.52006
6.6587
6.66786
6.68848
6.72501
6.78394
6.87316
7.00014
7.16722
7.35971
7.52006
6.65871
6.66787
6.68849
6.72502
6.78396
6.87317
7.00015
7.16723
7.35972
7.52007
6.65873
6.66789
6.6885
6.72504
6.78397
6.87319
7.00017
7.16725
7.35974
7.5201
6.65875
6.66791
6.68853
6.72506
6.784
6.87322
7.0002
7.16729
7.35977
7.52013
6.65877
6.66794
6.68856
6.7251
6.78404
6.87326
7.00024
7.16733
7.35982
7.52017
5.5175
5.52566
5.5435
5.57382
5.6203
5.68656
5.77424
5.87936
5.98639
6.06203
5.51747
5.52563
5.54347
5.57379
5.62027
5.68653
5.77421
5.87933
5.98636
6.062
5.51745
5.52561
5.54345
5.57377
5.62025
5.68651
5.77419
5.87931
5.98634
6.06198
5.51744
5.5256
5.54343
5.57375
5.62023
5.6865
5.77417
5.87929
5.98633
6.06197
5.51743
5.52559
5.54343
5.57375
5.62023
5.68649
5.77417
5.87929
5.98632
6.06197
5.51743
5.52559
5.54343
5.57375
5.62023
5.68649
5.77417
5.87929
5.98632
6.06197
5.51744
5.5256
5.54344
5.57376
5.62024
5.6865
5.77418
5.8793
5.98634
6.06198
5.51745
5.52561
5.54345
5.57377
5.62025
5.68652
5.7742
5.87932
5.98636
6.062
5.51747
5.52563
5.54348
5.5738
5.62028
5.68655
5.77423
5.87935
5.98638
6.06203
5.51749
5.52566
5.54351
5.57383
5.62031
5.68658
5.77426
5.87938
5.98642
6.06207
4.56756
4.57429
4.58866
4.61225
4.64688
4.69374
4.75203
4.81695
4.87749
4.91629
4.56754
4.57426
4.58863
4.61223
4.64685
4.69371
4.75201
4.81692
4.87747
4.91627
4.56752
4.57425
4.58862
4.61221
4.64683
4.69369
4.75199
4.8169
4.87745
4.91626
4.56751
4.57423
4.5886
4.6122
4.64682
4.69368
4.75198
4.81689
4.87744
4.91625
4.5675
4.57423
4.5886
4.61219
4.64682
4.69368
4.75197
4.81689
4.87743
4.91624
4.5675
4.57423
4.5886
4.61219
4.64682
4.69368
4.75197
4.81689
4.87744
4.91625
4.56751
4.57424
4.58861
4.6122
4.64683
4.69369
4.75198
4.8169
4.87745
4.91626
4.56752
4.57425
4.58862
4.61222
4.64684
4.6937
4.752
4.81692
4.87746
4.91628
4.56754
4.57427
4.58864
4.61224
4.64686
4.69373
4.75202
4.81694
4.87749
4.9163
4.56756
4.57429
4.58867
4.61227
4.64689
4.69376
4.75206
4.81697
4.87752
4.91633
3.79029
3.79553
3.80651
3.82402
3.84878
3.88085
3.91878
3.95867
3.99364
4.01476
3.79027
3.7955
3.80648
3.82399
3.84876
3.88083
3.91876
3.95865
3.99362
4.01474
3.79025
3.79549
3.80647
3.82398
3.84874
3.88081
3.91874
3.95863
3.9936
4.01473
3.79024
3.79548
3.80646
3.82397
3.84873
3.8808
3.91873
3.95862
3.99359
4.01472
3.79024
3.79547
3.80645
3.82396
3.84873
3.8808
3.91873
3.95862
3.99359
4.01471
3.79024
3.79547
3.80645
3.82396
3.84873
3.8808
3.91873
3.95862
3.99359
4.01472
3.79024
3.79548
3.80646
3.82397
3.84874
3.88081
3.91874
3.95863
3.9936
4.01473
3.79025
3.79549
3.80647
3.82398
3.84875
3.88082
3.91875
3.95864
3.99362
4.01474
3.79027
3.79551
3.80649
3.824
3.84877
3.88084
3.91877
3.95867
3.99364
4.01477
3.79029
3.79553
3.80652
3.82403
3.8488
3.88087
3.9188
3.95869
3.99367
4.01479
3.16916
3.17307
3.18115
3.19371
3.21094
3.23244
3.25685
3.28141
3.30202
3.314
3.16914
3.17305
3.18113
3.19369
3.21092
3.23242
3.25683
3.28139
3.302
3.31399
3.16913
3.17304
3.18111
3.19368
3.2109
3.2324
3.25681
3.28138
3.30198
3.31398
3.16912
3.17303
3.1811
3.19367
3.21089
3.2324
3.2568
3.28137
3.30198
3.31397
3.16911
3.17303
3.1811
3.19367
3.21089
3.23239
3.2568
3.28137
3.30197
3.31397
3.16912
3.17303
3.1811
3.19367
3.21089
3.23239
3.2568
3.28137
3.30198
3.31397
3.16912
3.17303
3.18111
3.19367
3.2109
3.2324
3.25681
3.28138
3.30198
3.31398
3.16913
3.17304
3.18112
3.19369
3.21091
3.23241
3.25682
3.28139
3.302
3.31399
3.16915
3.17306
3.18114
3.1937
3.21093
3.23243
3.25684
3.28141
3.30202
3.31401
3.16916
3.17308
3.18116
3.19373
3.21095
3.23246
3.25687
3.28143
3.30204
3.31404
2.68999
2.69284
2.69865
2.7075
2.71931
2.73362
2.74933
2.7646
2.77701
2.78405
2.68997
2.69282
2.69863
2.70748
2.71929
2.7336
2.74931
2.76458
2.77699
2.78404
2.68996
2.69281
2.69861
2.70747
2.71928
2.73359
2.74929
2.76457
2.77698
2.78403
2.68995
2.6928
2.69861
2.70746
2.71927
2.73358
2.74929
2.76456
2.77698
2.78402
2.68995
2.6928
2.6986
2.70745
2.71927
2.73358
2.74928
2.76456
2.77697
2.78402
2.68995
2.6928
2.6986
2.70746
2.71927
2.73358
2.74929
2.76456
2.77698
2.78403
2.68996
2.6928
2.69861
2.70746
2.71928
2.73359
2.74929
2.76457
2.77698
2.78403
2.68996
2.69281
2.69862
2.70747
2.71929
2.7336
2.74931
2.76458
2.777
2.78405
2.68998
2.69283
2.69864
2.70749
2.71931
2.73361
2.74932
2.7646
2.77702
2.78406
2.68999
2.69285
2.69866
2.70751
2.71933
2.73364
2.74935
2.76462
2.77704
2.78409
2.34112
2.34319
2.34737
2.35364
2.36182
2.37147
2.38178
2.39154
2.39929
2.40361
2.3411
2.34317
2.34735
2.35362
2.3618
2.37145
2.38176
2.39153
2.39927
2.40359
2.34109
2.34316
2.34734
2.35361
2.36179
2.37144
2.38175
2.39152
2.39926
2.40359
2.34108
2.34315
2.34734
2.3536
2.36178
2.37143
2.38175
2.39151
2.39926
2.40358
2.34108
2.34315
2.34733
2.3536
2.36178
2.37143
2.38174
2.39151
2.39925
2.40358
2.34108
2.34315
2.34733
2.3536
2.36178
2.37143
2.38175
2.39151
2.39926
2.40358
2.34108
2.34316
2.34734
2.35361
2.36179
2.37144
2.38175
2.39152
2.39926
2.40359
2.34109
2.34317
2.34735
2.35362
2.3618
2.37145
2.38177
2.39153
2.39928
2.4036
2.3411
2.34318
2.34736
2.35363
2.36181
2.37147
2.38178
2.39155
2.39929
2.40362
2.34112
2.3432
2.34738
2.35365
2.36183
2.37149
2.3818
2.39157
2.39931
2.40364
2.11359
2.11517
2.11832
2.12297
2.12894
2.13584
2.14305
2.14974
2.15495
2.15782
2.11358
2.11515
2.1183
2.12296
2.12893
2.13583
2.14304
2.14973
2.15494
2.15781
2.11357
2.11514
2.11829
2.12295
2.12892
2.13582
2.14303
2.14972
2.15493
2.1578
2.11356
2.11514
2.11829
2.12294
2.12891
2.13581
2.14302
2.14971
2.15492
2.1578
2.11356
2.11513
2.11828
2.12294
2.12891
2.13581
2.14302
2.14971
2.15492
2.1578
2.11356
2.11513
2.11829
2.12294
2.12891
2.13581
2.14302
2.14971
2.15492
2.1578
2.11356
2.11514
2.11829
2.12295
2.12892
2.13582
2.14303
2.14972
2.15493
2.15781
2.11357
2.11515
2.1183
2.12296
2.12893
2.13583
2.14304
2.14973
2.15494
2.15782
2.11358
2.11516
2.11831
2.12297
2.12894
2.13584
2.14306
2.14975
2.15496
2.15783
2.1136
2.11518
2.11833
2.12299
2.12896
2.13586
2.14308
2.14977
2.15498
2.15785
2.00136
2.0027
2.00535
2.00924
2.01417
2.01979
2.0256
2.03091
2.035
2.03724
2.00135
2.00269
2.00534
2.00923
2.01416
2.01978
2.02559
2.0309
2.03499
2.03724
2.00134
2.00268
2.00533
2.00922
2.01415
2.01977
2.02558
2.03089
2.03499
2.03723
2.00134
2.00267
2.00533
2.00921
2.01414
2.01977
2.02557
2.03089
2.03498
2.03723
2.00134
2.00267
2.00532
2.00921
2.01414
2.01977
2.02557
2.03088
2.03498
2.03723
2.00134
2.00267
2.00533
2.00921
2.01414
2.01977
2.02557
2.03089
2.03498
2.03723
2.00134
2.00268
2.00533
2.00922
2.01415
2.01977
2.02558
2.03089
2.03499
2.03724
2.00135
2.00269
2.00534
2.00923
2.01416
2.01978
2.02559
2.0309
2.035
2.03725
2.00136
2.0027
2.00535
2.00924
2.01417
2.0198
2.0256
2.03092
2.03502
2.03726
2.00137
2.00271
2.00537
2.00926
2.01419
2.01982
2.02562
2.03094
2.03503
2.03728
24.1761
24.4407
24.9301
25.5338
26.1628
26.7543
27.2658
27.6691
27.9466
28.0877
24.176
24.4406
24.93
25.5337
26.1627
26.7542
27.2657
27.6691
27.9465
28.0877
24.1759
24.4406
24.9299
25.5336
26.1626
26.7541
27.2656
27.669
27.9464
28.0876
24.1759
24.4405
24.9299
25.5336
26.1625
26.7541
27.2656
27.6689
27.9464
28.0876
24.1759
24.4405
24.9299
25.5335
26.1625
26.7541
27.2655
27.6689
27.9464
28.0876
24.1759
24.4405
24.9299
25.5336
26.1625
26.7541
27.2656
27.6689
27.9464
28.0876
24.1759
24.4405
24.9299
25.5336
26.1626
26.7541
27.2656
27.669
27.9464
28.0876
24.176
24.4406
24.9299
25.5336
26.1626
26.7542
27.2657
27.669
27.9465
28.0877
24.176
24.4407
24.93
25.5337
26.1627
26.7543
27.2658
27.6691
27.9466
28.0878
24.1761
24.4408
24.9301
25.5338
26.1628
26.7544
27.2659
27.6693
27.9467
28.0879
20.4447
20.6211
20.9448
21.3585
21.8046
22.2356
22.616
22.9205
23.1321
23.2404
20.4446
20.621
20.9447
21.3584
21.8045
22.2355
22.6159
22.9204
23.132
23.2403
20.4446
20.6209
20.9447
21.3584
21.8044
22.2354
22.6159
22.9204
23.132
23.2402
20.4445
20.6209
20.9446
21.3583
21.8044
22.2354
22.6158
22.9203
23.1319
23.2402
20.4445
20.6208
20.9446
21.3583
21.8043
22.2354
22.6158
22.9203
23.1319
23.2402
20.4445
20.6208
20.9446
21.3583
21.8043
22.2354
22.6158
22.9203
23.1319
23.2402
20.4445
20.6209
20.9446
21.3583
21.8044
22.2354
22.6159
22.9204
23.132
23.2403
20.4446
20.6209
20.9447
21.3584
21.8044
22.2355
22.6159
22.9204
23.132
23.2403
20.4447
20.621
20.9448
21.3585
21.8045
22.2356
22.616
22.9205
23.1321
23.2404
20.4447
20.6211
20.9449
21.3586
21.8046
22.2357
22.6161
22.9206
23.1322
23.2405
17.1922
17.311
17.5302
17.8164
18.1325
18.4444
18.7243
18.9513
19.1104
19.1922
17.1921
17.3109
17.5301
17.8164
18.1324
18.4443
18.7243
18.9512
19.1103
19.1922
17.192
17.3108
17.53
17.8163
18.1324
18.4442
18.7242
18.9511
19.1102
19.1921
17.192
17.3108
17.53
17.8163
18.1323
18.4442
18.7242
18.9511
19.1102
19.1921
17.192
17.3108
17.53
17.8163
18.1323
18.4442
18.7241
18.9511
19.1102
19.1921
17.192
17.3108
17.53
17.8163
18.1323
18.4442
18.7242
18.9511
19.1102
19.1921
17.192
17.3108
17.53
17.8163
18.1323
18.4442
18.7242
18.9511
19.1102
19.1921
17.192
17.3108
17.5301
17.8163
18.1324
18.4443
18.7242
18.9512
19.1103
19.1922
17.1921
17.3109
17.5301
17.8164
18.1325
18.4444
18.7243
18.9513
19.1104
19.1923
17.1922
17.311
17.5302
17.8165
18.1326
18.4445
18.7244
18.9514
19.1105
19.1924
14.4183
14.4995
14.6503
14.8502
15.0746
15.2995
15.5042
15.6719
15.7903
15.8515
14.4182
14.4994
14.6502
14.8501
15.0745
15.2994
15.5041
15.6718
15.7903
15.8515
14.4182
14.4993
14.6502
14.85
15.0744
15.2994
15.5041
15.6718
15.7902
15.8514
14.4181
14.4993
14.6501
14.85
15.0744
15.2994
15.504
15.6717
15.7902
15.8514
14.4181
14.4993
14.6501
14.85
15.0744
15.2993
15.504
15.6717
15.7902
15.8514
14.4181
14.4993
14.6501
14.85
15.0744
15.2994
15.504
15.6717
15.7902
15.8514
14.4181
14.4993
14.6502
14.85
15.0744
15.2994
15.5041
15.6718
15.7902
15.8515
14.4182
14.4994
14.6502
14.8501
15.0745
15.2994
15.5041
15.6718
15.7903
15.8515
14.4182
14.4994
14.6503
14.8501
15.0745
15.2995
15.5042
15.6719
15.7903
15.8516
14.4183
14.4995
14.6503
14.8502
15.0746
15.2996
15.5043
15.672
15.7904
15.8517
12.1068
12.1631
12.2683
12.4092
12.5693
12.7317
12.881
13.0045
13.0922
13.1377
12.1068
12.163
12.2683
12.4091
12.5692
12.7316
12.881
13.0044
13.0921
13.1377
12.1067
12.163
12.2682
12.4091
12.5691
12.7316
12.8809
13.0044
13.0921
13.1376
12.1067
12.163
12.2682
12.409
12.5691
12.7315
12.8809
13.0043
13.0921
13.1376
12.1067
12.1629
12.2682
12.409
12.5691
12.7315
12.8809
13.0043
13.0921
13.1376
12.1067
12.163
12.2682
12.409
12.5691
12.7315
12.8809
13.0043
13.0921
13.1376
12.1067
12.163
12.2682
12.409
12.5691
12.7316
12.8809
13.0044
13.0921
13.1377
12.1067
12.163
12.2682
12.4091
12.5692
12.7316
12.881
13.0044
13.0922
13.1377
12.1068
12.1631
12.2683
12.4091
12.5692
12.7317
12.881
13.0045
13.0922
13.1378
12.1068
12.1631
12.2684
12.4092
12.5693
12.7318
12.8811
13.0046
13.0923
13.1378
10.2339
10.2736
10.3481
10.4487
10.564
10.6821
10.7915
10.8827
10.9477
10.9816
10.2338
10.2735
10.348
10.4486
10.5639
10.682
10.7915
10.8826
10.9477
10.9816
10.2338
10.2735
10.348
10.4485
10.5639
10.6819
10.7914
10.8825
10.9477
10.9816
10.2338
10.2734
10.348
10.4485
10.5638
10.6819
10.7914
10.8825
10.9476
10.9815
10.2337
10.2734
10.348
10.4485
10.5638
10.6819
10.7914
10.8825
10.9476
10.9815
10.2337
10.2734
10.348
10.4485
10.5638
10.6819
10.7914
10.8825
10.9476
10.9815
10.2338
10.2734
10.348
10.4485
10.5639
10.6819
10.7914
10.8826
10.9477
10.9816
10.2338
10.2735
10.348
10.4486
10.5639
10.682
10.7915
10.8826
10.9477
10.9816
10.2338
10.2735
10.3481
10.4486
10.5639
10.682
10.7915
10.8827
10.9478
10.9817
10.2339
10.2736
10.3481
10.4487
10.564
10.6821
10.7916
10.8827
10.9478
10.9817
8.77364
8.80229
8.85633
8.92965
9.0143
9.1016
9.18307
9.25125
9.30017
9.3257
8.77358
8.80223
8.85628
8.92959
9.01425
9.10154
9.18301
9.25119
9.30012
9.32566
8.77354
8.80219
8.85623
8.92955
9.01421
9.1015
9.18298
9.25116
9.30008
9.32563
8.77351
8.80217
8.85621
8.92953
9.01418
9.10148
9.18295
9.25113
9.30006
9.32562
8.7735
8.80216
8.8562
8.92952
9.01417
9.10147
9.18295
9.25113
9.30006
9.32561
8.77351
8.80216
8.8562
8.92952
9.01418
9.10148
9.18295
9.25114
9.30007
9.32562
8.77352
8.80218
8.85622
8.92954
9.0142
9.1015
9.18298
9.25116
9.30009
9.32565
8.77355
8.80221
8.85626
8.92958
9.01424
9.10153
9.18301
9.2512
9.30013
9.32569
8.77359
8.80225
8.8563
8.92963
9.01429
9.10159
9.18307
9.25125
9.30018
9.32574
8.77364
8.80231
8.85637
8.92969
9.01435
9.10165
9.18313
9.25132
9.30025
9.32581
7.70208
7.72361
7.76433
7.81982
7.88421
7.95096
8.01359
8.06622
8.10411
8.12394
7.70203
7.72355
7.76428
7.81977
7.88416
7.95091
8.01353
8.06617
8.10407
8.1239
7.70199
7.72352
7.76424
7.81973
7.88412
7.95088
8.0135
8.06614
8.10404
8.12388
7.70197
7.72349
7.76422
7.81971
7.8841
7.95085
8.01348
8.06612
8.10402
8.12386
7.70196
7.72348
7.76421
7.8197
7.88409
7.95085
8.01347
8.06611
8.10401
8.12386
7.70196
7.72349
7.76422
7.8197
7.88409
7.95085
8.01348
8.06612
8.10402
8.12387
7.70198
7.72351
7.76423
7.81972
7.88411
7.95087
8.0135
8.06614
8.10405
8.12389
7.70201
7.72353
7.76426
7.81975
7.88415
7.95091
8.01354
8.06618
8.10408
8.12393
7.70204
7.72358
7.76431
7.8198
7.8842
7.95096
8.01359
8.06623
8.10413
8.12398
7.70209
7.72363
7.76437
7.81986
7.88426
7.95102
8.01365
8.06629
8.1042
8.12404
6.99944
7.0167
7.04943
7.09416
7.14626
7.20047
7.25151
7.29455
7.32562
7.34189
6.99939
7.01665
7.04939
7.09412
7.14621
7.20042
7.25147
7.29451
7.32557
7.34186
6.99935
7.01662
7.04935
7.09408
7.14618
7.20039
7.25144
7.29448
7.32555
7.34184
6.99933
7.0166
7.04933
7.09406
7.14616
7.20037
7.25142
7.29446
7.32553
7.34183
6.99932
7.01659
7.04932
7.09406
7.14615
7.20037
7.25141
7.29446
7.32553
7.34182
6.99933
7.01659
7.04933
7.09406
7.14616
7.20037
7.25142
7.29447
7.32554
7.34183
6.99934
7.01661
7.04935
7.09408
7.14618
7.20039
7.25144
7.29449
7.32556
7.34186
6.99937
7.01664
7.04938
7.09411
7.14621
7.20043
7.25148
7.29452
7.32559
7.34189
6.99941
7.01668
7.04942
7.09415
7.14625
7.20047
7.25152
7.29457
7.32564
7.34194
6.99945
7.01673
7.04947
7.09421
7.14631
7.20053
7.25158
7.29463
7.3257
7.342
6.65173
6.66701
6.69599
6.73567
6.78196
6.83023
6.87578
6.91424
6.94204
6.95663
6.65169
6.66697
6.69596
6.73563
6.78192
6.8302
6.87574
6.91421
6.94201
6.95661
6.65166
6.66694
6.69593
6.7356
6.78189
6.83017
6.87571
6.91418
6.94199
6.95659
6.65164
6.66692
6.69591
6.73558
6.78188
6.83015
6.8757
6.91417
6.94198
6.95657
6.65163
6.66691
6.6959
6.73558
6.78187
6.83015
6.87569
6.91416
6.94197
6.95657
6.65164
6.66692
6.69591
6.73558
6.78188
6.83015
6.8757
6.91417
6.94198
6.95658
6.65165
6.66693
6.69592
6.7356
6.78189
6.83017
6.87572
6.91419
6.942
6.9566
6.65168
6.66696
6.69595
6.73563
6.78193
6.83021
6.87575
6.91423
6.94204
6.95664
6.65171
6.667
6.69599
6.73567
6.78197
6.83025
6.8758
6.91427
6.94208
6.95668
6.65175
6.66705
6.69605
6.73573
6.78203
6.83031
6.87586
6.91433
6.94214
6.95674
)
;
boundaryField
{
inlet1
{
type fixedValue;
value uniform 10;
}
inlet2
{
type fixedValue;
value uniform 20;
}
outlet1
{
type zeroGradient;
}
outlet2
{
type zeroGradient;
}
fixedWalls
{
type zeroGradient;
}
}
// ************************************************************************* //
| [
"elliot.s.tennison@gmail.com"
] | elliot.s.tennison@gmail.com | |
97814f81cbb837ff8e0c28ca211fe24befdd36b3 | 75bc948f21807a59207d510747fd5641a2dc9f59 | /modules/UnifyDLL_RF_U2416_Certification/TestProcessor/TestItem/BTWLAN/BTWLAN_BT_TxTest.h | 1c979c23651728a0d0e5a0dff7039b41f8512943 | [] | no_license | EmbeddedSystemClass/U24 | 665a7211b790cd08035d7719775c58f0bc15072b | de2ef2884ad1a8a07df3a444d1db9f13a921a774 | refs/heads/master | 2021-06-15T09:40:47.079680 | 2016-09-14T12:29:57 | 2016-09-20T06:53:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,130 | h | #ifndef _C_BTWLAN_BT_TX_TEST_H_
#define _C_BTWLAN_BT_TX_TEST_H_
#include "../../../CommonUtility/BaseObject/ITestProcessor.h"
class CBTWLAN_BT_TxTest : public ITestProcessor
{
RF_DECLARE_DYNCREATE(CBTWLAN_BT_TxTest)
private:
std::string m_strPICSName;
std::string m_strPICSName_Value;
double m_dFrequency;
double m_dAdjPower, m_dRBW, m_dVBW, m_dSpan;
double m_dLower, m_dUpper;
double m_dChannelBWMHz;
int m_iCommandDelay;
//int m_iStartDelay;
int m_iAverageTimes;
int m_iChannel;
int m_iPower;
int m_iType;
int m_iSweepTime;
int m_iAttenuationManual;
int m_iRefLevel;
std::string m_strChannel;
std::string m_strTraceMode;
std::string m_strDetector;
std::string m_strDiagramFull;
std::string m_strMsg;
std::string m_strMeasured;
bool m_WriteCPKLog;
bool m_bKLossMode;
std::vector <std::string> m_CPKHeaderList;
public:
CBTWLAN_BT_TxTest(void);
virtual ~CBTWLAN_BT_TxTest(void);
virtual bool InitData(std::map<std::string, std::string>& paramMap);
virtual bool Run(void);
private:
bool MainFunction(void);
protected:
bool ParseCPKItems();
};
#endif // End of #ifndef _C_BTWLAN_BT_TX_TEST_H_ | [
"Lion.Wu@Qisda.com"
] | Lion.Wu@Qisda.com |
9a335d52283a64aa70d6f95445374f2d26e6ecdd | 5cdc481e6f74abc93dbfa421998779c5c3984e2a | /Codeforces/318A.cc | 750f464cf7235926b50b442759d8271bcf763553 | [] | no_license | joaquingx/Competitive-Programming-Problems | 4f0676bc3fb43d88f6427e106c6d9c81698993ce | c6baddbb6f1bdb1719c19cf08d3594bb37ba3147 | refs/heads/master | 2021-01-15T08:36:45.392896 | 2016-11-21T17:29:15 | 2016-11-21T17:29:15 | 54,804,029 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 336 | cc | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,k; cin >> n >> k;
if(n % 2 == 0)
{
if(k > n/2)
cout << (k - n/2)*2;
else
cout << k * 2 -1;
}
else
{
if(k > n/2 + 1)
cout << (k - (n/2+1)) * 2;
else
cout << k * 2 - 1;
}
cout << "\n";
return 0;
}
| [
"joaquingc123@gmail.com"
] | joaquingc123@gmail.com |
ae5e4e56512e154ac3607fdeec45c18d722bf567 | 88f1bc5acfa2b70e3a23ff7910910d455ffaef12 | /rdbms/InputBuffer.cpp | 1df7a5cb919e516f82b07f93dd1393ad2d019a2a | [] | no_license | sbuj1/rdbms | c335b2fe4c5ae959e2a94dde7c69ce482f93aef8 | 8e26f550516589d43bedb5bacf9975a8c06df379 | refs/heads/main | 2023-08-25T11:41:46.670816 | 2021-10-16T05:09:49 | 2021-10-16T05:09:49 | 416,562,460 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 443 | cpp | #include "InputBuffer.h"
#include <iostream>
#include <string>
InputBuffer::InputBuffer() {
std::string buffer = "";
}
void InputBuffer::read_input()
{
std::getline(std::cin, buffer);
if (buffer.length() <= 0) {
std::cout << "Error reading input" << std::endl;
exit(EXIT_FAILURE);
}
}
void InputBuffer::close_input_buffer(InputBuffer* inputBuffer)
{
delete inputBuffer;
}
void InputBuffer::print_prompt() { std::cout << "db > "; } | [
"steven.bujak@gmail.com"
] | steven.bujak@gmail.com |
5bb64c2bb3a4a4eda2299ed3d4095256ac64cf2f | fff80cdaf12712704f36038479f50418253f42f3 | /fbthrift/thrift/lib/cpp2/test/server/ThriftServerTest.cpp | 78471f61934bc2575fddd7c01ee0b05dd539bd31 | [] | no_license | rudolfkopriva/Facebook | 1ea0cfbc116f68ae0317332eeb9155461af5645a | 56e4c6a83f992bb01849ad353004b28409e53eef | refs/heads/master | 2023-02-14T01:54:36.519860 | 2021-01-05T02:09:26 | 2021-01-05T02:09:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 60,792 | cpp | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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 <memory>
#include <string>
#include <utility>
#include <boost/cast.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <fmt/core.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include <folly/Conv.h>
#include <folly/ExceptionWrapper.h>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/Range.h>
#include <folly/executors/GlobalExecutor.h>
#include <folly/io/GlobalShutdownSocketSet.h>
#include <folly/io/async/AsyncServerSocket.h>
#include <folly/io/async/AsyncSocket.h>
#include <folly/io/async/AsyncSocketException.h>
#include <folly/io/async/AsyncTransport.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/test/TestSSLServer.h>
#include <wangle/acceptor/ServerSocketConfig.h>
#include <folly/io/async/AsyncSocket.h>
#include <proxygen/httpserver/HTTPServerOptions.h>
#include <thrift/lib/cpp/transport/THeader.h>
#include <thrift/lib/cpp2/async/HTTPClientChannel.h>
#include <thrift/lib/cpp2/async/HeaderClientChannel.h>
#include <thrift/lib/cpp2/async/RequestChannel.h>
#include <thrift/lib/cpp2/async/RocketClientChannel.h>
#include <thrift/lib/cpp2/server/Cpp2Connection.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>
#include <thrift/lib/cpp2/test/gen-cpp2/TestService.h>
#include <thrift/lib/cpp2/test/util/TestHeaderClientChannelFactory.h>
#include <thrift/lib/cpp2/test/util/TestInterface.h>
#include <thrift/lib/cpp2/test/util/TestThriftServerFactory.h>
#include <thrift/lib/cpp2/transport/http2/common/HTTP2RoutingHandler.h>
#include <thrift/lib/cpp2/util/ScopedServerInterfaceThread.h>
#include <thrift/lib/cpp2/util/ScopedServerThread.h>
using namespace apache::thrift;
using namespace apache::thrift::test;
using namespace apache::thrift::util;
using namespace apache::thrift::async;
using namespace apache::thrift::transport;
using namespace std::literals;
using std::string;
DECLARE_int32(thrift_cpp2_protocol_reader_string_limit);
std::unique_ptr<HTTP2RoutingHandler> createHTTP2RoutingHandler(
ThriftServer& server) {
auto h2_options = std::make_unique<proxygen::HTTPServerOptions>();
h2_options->threads = static_cast<size_t>(server.getNumIOWorkerThreads());
h2_options->idleTimeout = server.getIdleTimeout();
h2_options->shutdownOn = {SIGINT, SIGTERM};
return std::make_unique<HTTP2RoutingHandler>(
std::move(h2_options), server.getThriftProcessor(), server);
}
TEST(ThriftServer, H2ClientAddressTest) {
class EchoClientAddrTestInterface : public TestServiceSvIf {
void sendResponse(std::string& _return, int64_t /* size */) override {
_return = getConnectionContext()->getPeerAddress()->describe();
}
};
ScopedServerInterfaceThread runner(
std::make_shared<EchoClientAddrTestInterface>());
auto& thriftServer = dynamic_cast<ThriftServer&>(runner.getThriftServer());
thriftServer.addRoutingHandler(createHTTP2RoutingHandler(thriftServer));
folly::EventBase base;
folly::AsyncSocket::UniquePtr socket(
new folly::AsyncSocket(&base, runner.getAddress()));
TestServiceAsyncClient client(
HTTPClientChannel::newHTTP2Channel(std::move(socket)));
auto channel =
boost::polymorphic_downcast<HTTPClientChannel*>(client.getChannel());
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, channel->getTransport()->getLocalAddress().describe());
}
TEST(ThriftServer, OnewayClientConnectionCloseTest) {
static std::atomic<bool> done(false);
class OnewayTestInterface : public TestServiceSvIf {
void noResponse(int64_t size) override {
usleep(size);
done = true;
}
};
TestThriftServerFactory<OnewayTestInterface> factory2;
ScopedServerThread st(factory2.create());
{
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *st.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
client.sync_noResponse(10000);
} // client out of scope
usleep(50000);
EXPECT_TRUE(done);
}
TEST(ThriftServer, OnewayDeferredHandlerTest) {
class OnewayTestInterface : public TestServiceSvIf {
public:
folly::Baton<> done;
folly::Future<folly::Unit> future_noResponse(int64_t size) override {
auto tm = getThreadManager();
auto ctx = getConnectionContext();
return folly::futures::sleep(std::chrono::milliseconds(size))
.via(tm)
.thenValue(
[ctx](auto&&) { EXPECT_EQ("noResponse", ctx->getMethodName()); })
.thenValue([this](auto&&) { done.post(); });
}
};
auto handler = std::make_shared<OnewayTestInterface>();
ScopedServerInterfaceThread runner(handler);
handler->done.reset();
auto client = runner.newClient<TestServiceAsyncClient>();
client->sync_noResponse(100);
ASSERT_TRUE(handler->done.try_wait_for(std::chrono::seconds(1)));
}
TEST(ThriftServer, CompressionClientTest) {
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
auto channel =
boost::polymorphic_downcast<HeaderClientChannel*>(client.getChannel());
channel->setTransform(apache::thrift::transport::THeader::ZLIB_TRANSFORM);
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
auto trans = channel->getWriteTransforms();
EXPECT_EQ(trans.size(), 1);
for (auto& tran : trans) {
EXPECT_EQ(tran, apache::thrift::transport::THeader::ZLIB_TRANSFORM);
}
}
TEST(ThriftServer, ResponseTooBigTest) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
runner.getThriftServer().setMaxResponseSize(4096);
auto client = runner.newClient<TestServiceAsyncClient>();
std::string request(4096, 'a');
std::string response;
try {
client->sync_echoRequest(response, request);
ADD_FAILURE() << "should throw";
} catch (const TApplicationException& tae) {
EXPECT_EQ(
tae.getType(),
TApplicationException::TApplicationExceptionType::INTERNAL_ERROR);
} catch (...) {
ADD_FAILURE() << "unexpected exception thrown";
}
}
class TestConnCallback : public folly::AsyncSocket::ConnectCallback {
public:
void connectSuccess() noexcept override {}
void connectErr(const folly::AsyncSocketException& ex) noexcept override {
exception.reset(new folly::AsyncSocketException(ex));
}
std::unique_ptr<folly::AsyncSocketException> exception;
};
TEST(ThriftServer, SSLClientOnPlaintextServerTest) {
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
auto sslCtx = std::make_shared<folly::SSLContext>();
std::shared_ptr<folly::AsyncSocket> socket(
TAsyncSSLSocket::newSocket(sslCtx, &base));
TestConnCallback cb;
socket->connect(&cb, *sst.getAddress());
base.loop();
ASSERT_TRUE(cb.exception);
auto msg = cb.exception->what();
EXPECT_NE(nullptr, strstr(msg, "unexpected message"));
}
TEST(ThriftServer, DefaultCompressionTest) {
/* Tests the functionality of default transforms, ensuring the server properly
applies them even if the client does not apply any transforms. */
class Callback : public RequestCallback {
public:
explicit Callback(bool compressionExpected, uint16_t expectedTransform)
: compressionExpected_(compressionExpected),
expectedTransform_(expectedTransform) {}
private:
void requestSent() override {}
void replyReceived(ClientReceiveState&& state) override {
auto trans = state.header()->getTransforms();
if (compressionExpected_) {
EXPECT_EQ(trans.size(), 1);
for (auto& tran : trans) {
EXPECT_EQ(tran, expectedTransform_);
}
} else {
EXPECT_EQ(trans.size(), 0);
}
}
void requestError(ClientReceiveState&& state) override {
state.exception().throw_exception();
}
bool compressionExpected_;
uint16_t expectedTransform_;
};
TestThriftServerFactory<TestInterface> factory;
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
ScopedServerThread sst(server);
folly::EventBase base;
// no compression if client does not compress/send preference
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
client.sendResponse(std::make_unique<Callback>(false, 0), 64);
base.loop();
// Ensure that client transforms take precedence
auto channel =
boost::polymorphic_downcast<HeaderClientChannel*>(client.getChannel());
channel->setTransform(apache::thrift::transport::THeader::SNAPPY_TRANSFORM);
client.sendResponse(
std::make_unique<Callback>(
true, apache::thrift::transport::THeader::SNAPPY_TRANSFORM),
64);
base.loop();
}
TEST(ThriftServer, HeaderTest) {
TestThriftServerFactory<TestInterface> factory;
auto serv = factory.create();
ScopedServerThread sst(serv);
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
RpcOptions options;
// Set it as a header directly so the client channel won't set a
// timeout and the test won't throw TTransportException
options.setWriteHeader(
apache::thrift::transport::THeader::CLIENT_TIMEOUT_HEADER,
folly::to<std::string>(10));
try {
client.sync_processHeader(options);
ADD_FAILURE() << "should timeout";
} catch (const TApplicationException& e) {
EXPECT_EQ(
e.getType(), TApplicationException::TApplicationExceptionType::TIMEOUT);
}
}
namespace {
void doLoadHeaderTest(bool isRocket) {
static constexpr int kEmptyMetricLoad = 12345;
auto makeClient = [=](auto& runner) {
if (!isRocket) {
return runner.template newClient<TestServiceAsyncClient>(
nullptr /* executor */, [](auto socket) mutable {
return HeaderClientChannel::newChannel(std::move(socket));
});
} else {
return runner.template newClient<TestServiceAsyncClient>(
nullptr /* executor */, [](auto socket) mutable {
return RocketClientChannel::newChannel(std::move(socket));
});
}
};
auto checkLoadHeader = [](const auto& headers,
folly::Optional<std::string> loadMetric) {
auto* load = folly::get_ptr(headers, THeader::QUERY_LOAD_HEADER);
ASSERT_EQ(loadMetric.hasValue(), load != nullptr);
if (!loadMetric) {
return;
}
folly::StringPiece loadSp(*loadMetric);
if (loadSp.removePrefix("custom_load_metric_")) {
EXPECT_EQ(loadSp, *load);
} else if (loadSp.empty()) {
EXPECT_EQ(folly::to<std::string>(kEmptyMetricLoad), *load);
} else {
FAIL() << "Unexpected load metric";
}
};
class BlockInterface : public TestServiceSvIf {
public:
folly::Optional<folly::Baton<>> block;
void voidResponse() override {
if (block) {
block.value().wait();
}
}
};
uint32_t nCalls = 0;
ScopedServerInterfaceThread runner(
std::make_shared<BlockInterface>(), "::1", 0, [&nCalls](auto& server) {
server.setGetLoad([](const std::string& metric) {
folly::StringPiece metricPiece(metric);
if (metricPiece.removePrefix("custom_load_metric_")) {
return folly::to<int32_t>(metricPiece.toString());
} else if (metricPiece.empty()) {
return kEmptyMetricLoad;
}
ADD_FAILURE() << "Unexpected load metric on request";
return -42;
});
server.setIsOverloaded(
[&nCalls](const auto*, const std::string* method) {
EXPECT_EQ("voidResponse", *method);
return ++nCalls == 4;
});
});
auto client = makeClient(runner);
{
// No load header
RpcOptions options;
client->sync_voidResponse(options);
checkLoadHeader(options.getReadHeaders(), folly::none);
}
{
// Empty load header
RpcOptions options;
const std::string kLoadMetric;
options.setWriteHeader(THeader::QUERY_LOAD_HEADER, kLoadMetric);
client->sync_voidResponse(options);
checkLoadHeader(options.getReadHeaders(), kLoadMetric);
}
{
// Custom load header
RpcOptions options;
const std::string kLoadMetric{"custom_load_metric_789"};
options.setWriteHeader(THeader::QUERY_LOAD_HEADER, kLoadMetric);
client->sync_voidResponse(options);
checkLoadHeader(options.getReadHeaders(), kLoadMetric);
}
{
// Force server overload. Load should still be returned on server overload.
RpcOptions options;
const std::string kLoadMetric;
options.setWriteHeader(THeader::QUERY_LOAD_HEADER, kLoadMetric);
auto ew = folly::try_and_catch<std::exception>(
[&] { client->sync_voidResponse(options); });
// Check that request was actually rejected due to server overload
const bool matched =
ew.with_exception([](const TApplicationException& tae) {
ASSERT_EQ(
TApplicationException::TApplicationExceptionType::LOADSHEDDING,
tae.getType());
});
ASSERT_TRUE(matched);
checkLoadHeader(options.getReadHeaders(), kLoadMetric);
}
{
// Force queue timeout.
// for Rocket: load should still be returned
// for Header: load is not returned because of thread safety concerns.
auto handler = dynamic_cast<BlockInterface*>(
runner.getThriftServer().getProcessorFactory().get());
handler->block.emplace();
auto fut = client->semifuture_voidResponse();
auto guard = folly::makeGuard([&] {
handler->block.value().post();
std::move(fut).get();
});
RpcOptions options;
const std::string kLoadMetric;
options.setWriteHeader(THeader::QUERY_LOAD_HEADER, kLoadMetric);
options.setQueueTimeout(std::chrono::milliseconds(10));
auto ew = folly::try_and_catch<std::exception>(
[&] { client->sync_voidResponse(options); });
// Check that request was actually rejected due to queue timeout
const bool matched =
ew.with_exception([](const TApplicationException& tae) {
ASSERT_EQ(TApplicationException::TIMEOUT, tae.getType());
});
ASSERT_TRUE(matched);
if (isRocket) {
checkLoadHeader(options.getReadHeaders(), kLoadMetric);
} else {
checkLoadHeader(options.getReadHeaders(), folly::none);
}
EXPECT_EQ(
*folly::get_ptr(options.getReadHeaders(), "ex"),
kServerQueueTimeoutErrorCode);
}
{
// Force task timeout.
// for Rocket: load should still be returned
// for Header: load is not returned because of thread safety concerns.
auto handler = dynamic_cast<BlockInterface*>(
runner.getThriftServer().getProcessorFactory().get());
handler->block.emplace();
RpcOptions options;
const std::string kLoadMetric;
options.setWriteHeader(THeader::QUERY_LOAD_HEADER, kLoadMetric);
options.setTimeout(std::chrono::seconds(1));
auto prevTaskExpireTime = runner.getThriftServer().getTaskExpireTime();
auto prevUseClientTimeout = runner.getThriftServer().getUseClientTimeout();
runner.getThriftServer().setTaskExpireTime(std::chrono::milliseconds(100));
runner.getThriftServer().setUseClientTimeout(false);
auto guard = folly::makeGuard([&] {
handler->block.value().post();
runner.getThriftServer().setTaskExpireTime(prevTaskExpireTime);
runner.getThriftServer().setUseClientTimeout(prevUseClientTimeout);
});
auto ew = folly::try_and_catch<std::exception>(
[&] { client->sync_voidResponse(options); });
// Check that request was actually rejected due to task timeout
const bool matched =
ew.with_exception([](const TApplicationException& tae) {
ASSERT_EQ(TApplicationException::TIMEOUT, tae.getType());
});
ASSERT_TRUE(matched);
if (isRocket) {
checkLoadHeader(options.getReadHeaders(), kLoadMetric);
} else {
checkLoadHeader(options.getReadHeaders(), folly::none);
}
EXPECT_EQ(
*folly::get_ptr(options.getReadHeaders(), "ex"), kTaskExpiredErrorCode);
}
}
} // namespace
TEST(ThriftServer, LoadHeaderTest_HeaderClientChannel) {
doLoadHeaderTest(false);
}
TEST(ThriftServer, LoadHeaderTest_RocketClientChannel) {
doLoadHeaderTest(true);
}
enum LatencyHeaderStatus {
EXPECTED,
NOT_EXPECTED,
};
static void validateLatencyHeaders(
std::map<std::string, std::string> headers,
LatencyHeaderStatus status) {
bool isHeaderExpected = (status == LatencyHeaderStatus::EXPECTED);
auto queueLatency = folly::get_optional(headers, kQueueLatencyHeader.str());
ASSERT_EQ(isHeaderExpected, queueLatency.has_value());
auto processLatency =
folly::get_optional(headers, kProcessLatencyHeader.str());
ASSERT_EQ(isHeaderExpected, processLatency.has_value());
if (isHeaderExpected) {
EXPECT_GE(folly::to<int64_t>(queueLatency.value()), 0);
EXPECT_GE(folly::to<int64_t>(processLatency.value()), 0);
}
}
TEST(ThriftServer, LatencyHeader_LoggingDisabled) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
folly::EventBase base;
auto client = runner.newClient<TestServiceAsyncClient>(&base);
RpcOptions rpcOptions;
client->sync_voidResponse(rpcOptions);
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::NOT_EXPECTED);
}
namespace {
enum class TransportType { Header, Rocket };
enum class Compression { Enabled, Disabled };
enum class ErrorType { Overload, AppOverload, MethodOverload, Client, Server };
} // namespace
class HeaderOrRocketTest : public testing::Test {
public:
TransportType transport = TransportType::Rocket;
Compression compression = Compression::Enabled;
auto makeClient(ScopedServerInterfaceThread& runner, folly::EventBase* evb) {
if (transport == TransportType::Header) {
return runner.newClient<TestServiceAsyncClient>(
evb, [&](auto socket) mutable {
auto channel = HeaderClientChannel::newChannel(std::move(socket));
if (compression == Compression::Enabled) {
channel->setTransform(
apache::thrift::transport::THeader::ZSTD_TRANSFORM);
}
return channel;
});
} else {
return runner.newClient<TestServiceAsyncClient>(
evb, [&](auto socket) mutable {
auto channel = RocketClientChannel::newChannel(std::move(socket));
return channel;
});
}
}
};
class OverloadTest : public HeaderOrRocketTest,
public ::testing::WithParamInterface<
std::tuple<TransportType, Compression, ErrorType>> {
public:
ErrorType errorType;
bool isCustomError() {
return errorType == ErrorType::Client || errorType == ErrorType::Server;
}
LatencyHeaderStatus getLatencyHeaderStatus() {
// we currently only report latency headers for Header,
// and only when method handler was executed started running.
return errorType == ErrorType::MethodOverload &&
transport == TransportType::Header
? LatencyHeaderStatus::EXPECTED
: LatencyHeaderStatus::NOT_EXPECTED;
}
void validateErrorHeaders(const RpcOptions& rpc) {
auto& headers = rpc.getReadHeaders();
if (errorType == ErrorType::Client) {
EXPECT_EQ(*folly::get_ptr(headers, "ex"), kAppClientErrorCode);
EXPECT_EQ(*folly::get_ptr(headers, "uex"), "name");
EXPECT_EQ(*folly::get_ptr(headers, "uexw"), "message");
} else if (errorType == ErrorType::Server) {
EXPECT_EQ(*folly::get_ptr(headers, "uex"), "name");
EXPECT_EQ(*folly::get_ptr(headers, "uexw"), "message");
} else if (errorType == ErrorType::AppOverload) {
EXPECT_EQ(*folly::get_ptr(headers, "ex"), kAppOverloadedErrorCode);
EXPECT_EQ(folly::get_ptr(headers, "uex"), nullptr);
EXPECT_EQ(folly::get_ptr(headers, "uexw"), nullptr);
} else if (errorType == ErrorType::MethodOverload) {
EXPECT_EQ(*folly::get_ptr(headers, "ex"), kAppOverloadedErrorCode);
EXPECT_EQ(folly::get_ptr(headers, "uex"), nullptr);
EXPECT_EQ(folly::get_ptr(headers, "uexw"), nullptr);
} else if (errorType == ErrorType::Overload) {
EXPECT_EQ(*folly::get_ptr(headers, "ex"), kOverloadedErrorCode);
EXPECT_EQ(folly::get_ptr(headers, "uex"), nullptr);
EXPECT_EQ(folly::get_ptr(headers, "uexw"), nullptr);
} else {
FAIL() << "Unknown error type: " << (int)errorType;
}
}
void SetUp() override {
std::tie(transport, compression, errorType) = GetParam();
}
};
class CancellationTest : public HeaderOrRocketTest,
public ::testing::WithParamInterface<TransportType> {
public:
void SetUp() override {
transport = GetParam();
}
};
TEST_P(CancellationTest, Test) {
class NotCalledBackHandler {
public:
explicit NotCalledBackHandler(
std::unique_ptr<HandlerCallback<void>> callback)
: thriftCallback_{std::move(callback)},
cancelCallback_(
thriftCallback_->getConnectionContext()
->getConnectionContext()
->getCancellationToken(),
[this]() { requestCancelled(); }) {}
folly::Baton<> cancelBaton;
private:
void requestCancelled() {
// Invoke the thrift callback once the request has canceled.
// Even after the request has been canceled handlers still should
// eventually invoke the request callback.
std::exchange(thriftCallback_, nullptr)
->exception(std::runtime_error("request cancelled"));
cancelBaton.post();
}
std::unique_ptr<HandlerCallback<void>> thriftCallback_;
folly::CancellationCallback cancelCallback_;
};
class NotCalledBackInterface : public TestServiceSvIf {
public:
using NotCalledBackHandlers =
std::vector<std::shared_ptr<NotCalledBackHandler>>;
void async_tm_notCalledBack(
std::unique_ptr<HandlerCallback<void>> cb) override {
auto handler = std::make_shared<NotCalledBackHandler>(std::move(cb));
notCalledBackHandlers_.lock()->push_back(std::move(handler));
handlersCV_.notify_one();
}
/**
* Get all handlers for currently pending notCalledBack() thrift calls.
*
* If there is no call currently pending this function will wait for up to
* the specified timeout for one to arrive. If the timeout expires before a
* notCalledBack() call is received an empty result set will be returned.
*/
NotCalledBackHandlers getNotCalledBackHandlers(
std::chrono::milliseconds timeout) {
auto end_time = std::chrono::steady_clock::now() + timeout;
NotCalledBackHandlers results;
auto handlers = notCalledBackHandlers_.lock();
if (!handlersCV_.wait_until(handlers.getUniqueLock(), end_time, [&] {
return !handlers->empty();
})) {
// If we get here we timed out.
// Just return an empty result set in this case.
return results;
}
results.swap(*handlers);
return results;
}
private:
folly::Synchronized<NotCalledBackHandlers, std::mutex>
notCalledBackHandlers_;
std::condition_variable handlersCV_;
};
ScopedServerInterfaceThread runner(
std::make_shared<NotCalledBackInterface>());
folly::EventBase base;
auto client = makeClient(runner, &base);
auto interface = std::dynamic_pointer_cast<NotCalledBackInterface>(
runner.getThriftServer().getProcessorFactory());
ASSERT_TRUE(interface);
EXPECT_EQ(0, interface->getNotCalledBackHandlers(0s).size());
// Make a call to notCalledBack(), which will time out since the server never
// reponds to this API.
try {
RpcOptions rpcOptions;
rpcOptions.setTimeout(std::chrono::milliseconds(10));
client->sync_notCalledBack(rpcOptions);
EXPECT_FALSE(true) << "request should have never returned";
} catch (const TApplicationException& ex) {
if (ex.getType() != TApplicationException::TIMEOUT) {
throw;
}
}
// Wait for the server to register the call
auto handlers = interface->getNotCalledBackHandlers(10s);
ASSERT_EQ(1, handlers.size()) << "expected a single notCalledBack() call";
auto wasCancelled = handlers[0]->cancelBaton.ready();
// Currently we do not trigger per-request cancellations, but only
// when client closes the connection.
EXPECT_FALSE(wasCancelled);
// Close the client. This should trigger request cancellation on the server.
client.reset();
// The handler's cancellation token should be triggered when we close the
// connection.
wasCancelled = handlers[0]->cancelBaton.try_wait_for(10s);
EXPECT_TRUE(wasCancelled);
}
INSTANTIATE_TEST_CASE_P(
CancellationTestFixture,
CancellationTest,
testing::Values(TransportType::Header, TransportType::Rocket));
TEST_P(OverloadTest, Test) {
class BlockInterface : public TestServiceSvIf {
public:
folly::Baton<> block;
void voidResponse() override {
block.wait();
}
void async_eb_eventBaseAsync(
std::unique_ptr<HandlerCallback<std::unique_ptr<::std::string>>>
callback) override {
callback->appOverloadedException("loadshedding request");
}
};
ScopedServerInterfaceThread runner(std::make_shared<BlockInterface>());
folly::EventBase base;
auto client = makeClient(runner, &base);
runner.getThriftServer().setIsOverloaded(
[&](const auto*, const string* method) {
if (errorType == ErrorType::AppOverload) {
EXPECT_EQ("voidResponse", *method);
return true;
}
return false;
});
runner.getThriftServer().setPreprocess([&](auto, auto) -> PreprocessResult {
if (errorType == ErrorType::Client) {
return {AppClientException("name", "message")};
} else if (errorType == ErrorType::Server) {
return {AppServerException("name", "message")};
}
return {};
});
// force overloaded
folly::Function<void()> onExit = [] {};
auto guard = folly::makeGuard([&] { onExit(); });
if (errorType == ErrorType::Overload) {
// Thrift is overloaded on max requests
runner.getThriftServer().setMaxRequests(1);
auto handler = dynamic_cast<BlockInterface*>(
runner.getThriftServer().getProcessorFactory().get());
client->semifuture_voidResponse();
while (runner.getThriftServer().getActiveRequests() < 1) {
std::this_thread::yield();
}
onExit = [handler] { handler->block.post(); };
}
RpcOptions rpcOptions;
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
try {
if (errorType == ErrorType::MethodOverload) {
std::string dummy;
client->sync_eventBaseAsync(rpcOptions, dummy);
} else {
client->sync_voidResponse(rpcOptions);
}
FAIL() << "Expected that the service call throws TApplicationException";
} catch (const apache::thrift::TApplicationException& ex) {
auto expectType = isCustomError() ? TApplicationException::UNKNOWN
: TApplicationException::LOADSHEDDING;
EXPECT_EQ(expectType, ex.getType());
auto expectMessage = isCustomError() ? "message" : "loadshedding request";
EXPECT_EQ(expectMessage, ex.getMessage());
validateErrorHeaders(rpcOptions);
// Latency headers are NOT set, when server is overloaded
validateLatencyHeaders(
rpcOptions.getReadHeaders(), getLatencyHeaderStatus());
} catch (...) {
FAIL()
<< "Expected that the service call throws TApplicationException, got "
<< folly::exceptionStr(std::current_exception());
}
}
INSTANTIATE_TEST_CASE_P(
OverloadTestsFixture,
OverloadTest,
::testing::Combine(
testing::Values(TransportType::Header, TransportType::Rocket),
testing::Values(Compression::Enabled, Compression::Disabled),
testing::Values(
ErrorType::Overload,
ErrorType::MethodOverload,
ErrorType::AppOverload,
ErrorType::Client,
ErrorType::Server)));
TEST(ThriftServer, LatencyHeader_ClientTimeout) {
ScopedServerInterfaceThread runner(
std::make_shared<TestInterface>(), "::1", 0, [](auto& server) {
server.setUseClientTimeout(false);
});
auto client =
runner.newClient<TestServiceAsyncClient>(nullptr, [](auto socket) {
return HeaderClientChannel::newChannel(std::move(socket));
});
RpcOptions rpcOptions;
// Setup client timeout
rpcOptions.setTimeout(std::chrono::milliseconds(1));
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
std::string response;
EXPECT_ANY_THROW(client->sync_sendResponse(rpcOptions, response, 20000));
// Latency headers are NOT set, when client times out.
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::NOT_EXPECTED);
}
TEST(ThriftServer, LatencyHeader_RequestSuccess) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
auto client =
runner.newClient<TestServiceAsyncClient>(nullptr, [](auto socket) {
return HeaderClientChannel::newChannel(std::move(socket));
});
RpcOptions rpcOptions;
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
client->sync_voidResponse(rpcOptions);
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::EXPECTED);
}
TEST(ThriftServer, LatencyHeader_RequestFailed) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
auto client =
runner.newClient<TestServiceAsyncClient>(nullptr, [](auto socket) {
return HeaderClientChannel::newChannel(std::move(socket));
});
RpcOptions rpcOptions;
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
EXPECT_ANY_THROW(client->sync_throwsHandlerException(rpcOptions));
// Latency headers are set, when handler throws exception
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::EXPECTED);
}
TEST(ThriftServer, LatencyHeader_TaskExpiry) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
auto client =
runner.newClient<TestServiceAsyncClient>(nullptr, [](auto socket) {
return HeaderClientChannel::newChannel(std::move(socket));
});
// setup task expire timeout.
runner.getThriftServer().setTaskExpireTime(std::chrono::milliseconds(10));
runner.getThriftServer().setUseClientTimeout(false);
RpcOptions rpcOptions;
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
std::string response;
EXPECT_ANY_THROW(client->sync_sendResponse(rpcOptions, response, 30000));
// Latency headers are set, when task expires
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::EXPECTED);
}
TEST(ThriftServer, LatencyHeader_QueueTimeout) {
ScopedServerInterfaceThread runner(std::make_shared<TestInterface>());
auto client =
runner.newStickyClient<TestServiceAsyncClient>(nullptr, [](auto socket) {
return HeaderClientChannel::newChannel(std::move(socket));
});
// setup timeout
runner.getThriftServer().setQueueTimeout(std::chrono::milliseconds(5));
// Run a long request.
auto slowRequestFuture = client->semifuture_sendResponse(20000);
RpcOptions rpcOptions;
rpcOptions.setWriteHeader(kClientLoggingHeader.str(), "");
std::string response;
EXPECT_ANY_THROW(client->sync_sendResponse(rpcOptions, response, 1000));
// Latency headers are set, when server throws queue timeout
validateLatencyHeaders(
rpcOptions.getReadHeaders(), LatencyHeaderStatus::EXPECTED);
folly::EventBase base;
std::move(slowRequestFuture).via(&base).getVia(&base);
}
TEST(ThriftServer, ClientTimeoutTest) {
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
ScopedServerThread sst(server);
folly::EventBase base;
auto getClient = [&base, &sst]() {
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
return std::make_shared<TestServiceAsyncClient>(
HeaderClientChannel::newChannel(socket));
};
int cbCtor = 0;
int cbCall = 0;
auto callback = [&cbCall, &cbCtor](
std::shared_ptr<TestServiceAsyncClient> client,
bool& timeout) {
cbCtor++;
return std::unique_ptr<RequestCallback>(new FunctionReplyCallback(
[&cbCall, client, &timeout](ClientReceiveState&& state) {
cbCall++;
if (state.exception()) {
timeout = true;
auto ex = state.exception().get_exception();
auto& e = dynamic_cast<TTransportException const&>(*ex);
EXPECT_EQ(TTransportException::TIMED_OUT, e.getType());
return;
}
try {
std::string resp;
client->recv_sendResponse(resp, state);
} catch (const TApplicationException& e) {
timeout = true;
EXPECT_EQ(TApplicationException::TIMEOUT, e.getType());
EXPECT_TRUE(
state.header()->getFlags() & HEADER_FLAG_SUPPORT_OUT_OF_ORDER);
return;
}
timeout = false;
}));
};
// Set the timeout to be 5 milliseconds, but the call will take 10 ms.
// The server should send a timeout after 5 milliseconds
RpcOptions options;
options.setTimeout(std::chrono::milliseconds(5));
auto client1 = getClient();
bool timeout1;
client1->sendResponse(options, callback(client1, timeout1), 10000);
base.loop();
EXPECT_TRUE(timeout1);
usleep(10000);
// This time we set the timeout to be 100 millseconds. The server
// should not time out
options.setTimeout(std::chrono::milliseconds(100));
client1->sendResponse(options, callback(client1, timeout1), 10000);
base.loop();
EXPECT_FALSE(timeout1);
usleep(10000);
// This time we set server timeout to be 5 millseconds. However, the
// task should start processing within that millisecond, so we should
// not see an exception because the client timeout should be used after
// processing is started
server->setTaskExpireTime(std::chrono::milliseconds(5));
client1->sendResponse(options, callback(client1, timeout1), 10000);
base.loop();
usleep(10000);
// The server timeout stays at 5 ms, but we put the client timeout at
// 5 ms. We should timeout even though the server starts processing within
// 5ms.
options.setTimeout(std::chrono::milliseconds(5));
client1->sendResponse(options, callback(client1, timeout1), 10000);
base.loop();
EXPECT_TRUE(timeout1);
usleep(50000);
// And finally, with the server timeout at 50 ms, we send 2 requests at
// once. Because the first request will take more than 50 ms to finish
// processing (the server only has 1 worker thread), the second request
// won't start processing until after 50ms, and will timeout, despite the
// very high client timeout.
// We don't know which one will timeout (race conditions) so we just check
// the xor
auto client2 = getClient();
bool timeout2;
server->setTaskExpireTime(std::chrono::milliseconds(50));
options.setTimeout(std::chrono::milliseconds(110));
client1->sendResponse(options, callback(client1, timeout1), 100000);
client2->sendResponse(options, callback(client2, timeout2), 100000);
base.loop();
EXPECT_TRUE(timeout1 || timeout2);
EXPECT_FALSE(timeout1 && timeout2);
EXPECT_EQ(cbCall, cbCtor);
}
TEST(ThriftServer, ConnectionIdleTimeoutTest) {
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
server->setIdleTimeout(std::chrono::milliseconds(20));
apache::thrift::util::ScopedServerThread st(server);
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *st.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
client.sync_sendResponse(response, 200);
EXPECT_EQ(response, "test200");
base.loop();
}
TEST(ThriftServer, BadSendTest) {
class Callback : public RequestCallback {
void requestSent() override {
ADD_FAILURE();
}
void replyReceived(ClientReceiveState&&) override {
ADD_FAILURE();
}
void requestError(ClientReceiveState&& state) override {
EXPECT_TRUE(state.exception());
auto ex =
state.exception()
.get_exception<apache::thrift::transport::TTransportException>();
ASSERT_TRUE(ex);
EXPECT_THAT(
ex->what(), testing::StartsWith("transport is closed in write()"));
}
};
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
client.sendResponse(std::unique_ptr<RequestCallback>(new Callback), 64);
socket->shutdownWriteNow();
base.loop();
std::string response;
EXPECT_THROW(client.sync_sendResponse(response, 64), TTransportException);
}
TEST(ThriftServer, ResetStateTest) {
folly::EventBase base;
// Create a server socket and bind, don't listen. This gets us a
// port to test with which is guaranteed to fail.
auto ssock = std::unique_ptr<
folly::AsyncServerSocket,
folly::DelayedDestruction::Destructor>(new folly::AsyncServerSocket);
ssock->bind(0);
EXPECT_FALSE(ssock->getAddresses().empty());
// We do this loop a bunch of times, because the bug which caused
// the assertion failure was a lost race, which doesn't happen
// reliably.
for (int i = 0; i < 1000; ++i) {
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, ssock->getAddresses()[0]));
// Create a client.
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
// This will fail, because there's no server.
EXPECT_THROW(client.sync_sendResponse(response, 64), TTransportException);
// On a failed client object, this should also throw an exception.
// In the past, this would generate an assertion failure and
// crash.
EXPECT_THROW(client.sync_sendResponse(response, 64), TTransportException);
}
}
TEST(ThriftServer, FailureInjection) {
enum ExpectedFailure { NONE = 0, ERROR, TIMEOUT, DISCONNECT, END };
std::atomic<ExpectedFailure> expected(NONE);
using apache::thrift::transport::TTransportException;
class Callback : public RequestCallback {
public:
explicit Callback(const std::atomic<ExpectedFailure>* expected)
: expected_(expected) {}
private:
void requestSent() override {}
void replyReceived(ClientReceiveState&& state) override {
std::string response;
try {
TestServiceAsyncClient::recv_sendResponse(response, state);
EXPECT_EQ(NONE, *expected_);
} catch (const apache::thrift::TApplicationException&) {
const auto& headers = state.header()->getHeaders();
EXPECT_TRUE(
headers.find("ex") != headers.end() &&
headers.find("ex")->second == kInjectedFailureErrorCode);
EXPECT_EQ(ERROR, *expected_);
} catch (...) {
ADD_FAILURE() << "Unexpected exception thrown";
}
// Now do it again with exception_wrappers.
auto ew =
TestServiceAsyncClient::recv_wrapped_sendResponse(response, state);
if (ew) {
EXPECT_TRUE(
ew.is_compatible_with<apache::thrift::TApplicationException>());
EXPECT_EQ(ERROR, *expected_);
} else {
EXPECT_EQ(NONE, *expected_);
}
}
void requestError(ClientReceiveState&& state) override {
ASSERT_TRUE(state.exception());
auto ex_ = state.exception().get_exception();
auto& ex = dynamic_cast<TTransportException const&>(*ex_);
if (ex.getType() == TTransportException::TIMED_OUT) {
EXPECT_EQ(TIMEOUT, *expected_);
} else {
EXPECT_EQ(DISCONNECT, *expected_);
}
}
const std::atomic<ExpectedFailure>* expected_;
};
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
auto server = std::dynamic_pointer_cast<ThriftServer>(sst.getServer().lock());
CHECK(server);
SCOPE_EXIT {
server->setFailureInjection(ThriftServer::FailureInjection());
};
RpcOptions rpcOptions;
rpcOptions.setTimeout(std::chrono::milliseconds(100));
for (int i = 0; i < END; ++i) {
auto exp = static_cast<ExpectedFailure>(i);
ThriftServer::FailureInjection fi;
switch (exp) {
case NONE:
break;
case ERROR:
fi.errorFraction = 1;
break;
case TIMEOUT:
fi.dropFraction = 1;
break;
case DISCONNECT:
fi.disconnectFraction = 1;
break;
case END:
LOG(FATAL) << "unreached";
}
server->setFailureInjection(std::move(fi));
expected = exp;
auto callback = std::make_unique<Callback>(&expected);
client.sendResponse(rpcOptions, std::move(callback), 1);
base.loop();
}
}
TEST(ThriftServer, useExistingSocketAndExit) {
TestThriftServerFactory<TestInterface> factory;
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
folly::AsyncServerSocket::UniquePtr serverSocket(
new folly::AsyncServerSocket);
serverSocket->bind(0);
server->useExistingSocket(std::move(serverSocket));
// In the past, this would cause a SEGV
}
TEST(ThriftServer, useExistingSocketAndConnectionIdleTimeout) {
// This is ConnectionIdleTimeoutTest, but with an existing socket
TestThriftServerFactory<TestInterface> factory;
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
folly::AsyncServerSocket::UniquePtr serverSocket(
new folly::AsyncServerSocket);
serverSocket->bind(0);
server->useExistingSocket(std::move(serverSocket));
server->setIdleTimeout(std::chrono::milliseconds(20));
apache::thrift::util::ScopedServerThread st(server);
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *st.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
client.sync_sendResponse(response, 200);
EXPECT_EQ(response, "test200");
base.loop();
}
namespace {
class ReadCallbackTest : public folly::AsyncTransport::ReadCallback {
public:
void getReadBuffer(void**, size_t*) override {}
void readDataAvailable(size_t) noexcept override {}
void readEOF() noexcept override {
eof = true;
}
void readErr(const folly::AsyncSocketException&) noexcept override {
eof = true;
}
bool eof = false;
};
} // namespace
TEST(ThriftServer, ShutdownSocketSetTest) {
TestThriftServerFactory<TestInterface> factory;
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
ScopedServerThread sst(server);
folly::EventBase base;
ReadCallbackTest cb;
std::shared_ptr<folly::AsyncSocket> socket2(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
socket2->setReadCB(&cb);
base.tryRunAfterDelay(
[&]() { folly::tryGetShutdownSocketSet()->shutdownAll(); }, 10);
base.tryRunAfterDelay([&]() { base.terminateLoopSoon(); }, 30);
base.loopForever();
EXPECT_EQ(cb.eof, true);
}
TEST(ThriftServer, ShutdownDegenarateServer) {
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
server->setMaxRequests(1);
server->setNumIOWorkerThreads(1);
ScopedServerThread sst(server);
}
TEST(ThriftServer, ModifyingIOThreadCountLive) {
TestThriftServerFactory<TestInterface> factory;
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
auto iothreadpool = std::make_shared<folly::IOThreadPoolExecutor>(0);
server->setIOThreadPool(iothreadpool);
ScopedServerThread sst(server);
// If there are no worker threads, generally the server event base
// will stop loop()ing. Create a timeout event to make sure
// it continues to loop for the duration of the test.
server->getServeEventBase()->runInEventBaseThread(
[&]() { server->getServeEventBase()->tryRunAfterDelay([]() {}, 5000); });
server->getServeEventBase()->runInEventBaseThreadAndWait(
[=]() { iothreadpool->setNumThreads(0); });
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly ::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
boost::polymorphic_downcast<HeaderClientChannel*>(client.getChannel())
->setTimeout(100);
// This should fail as soon as it connects:
// since AsyncServerSocket has no accept callbacks installed,
// it should close the connection right away.
ASSERT_ANY_THROW(client.sync_sendResponse(response, 64));
server->getServeEventBase()->runInEventBaseThreadAndWait(
[=]() { iothreadpool->setNumThreads(30); });
std::shared_ptr<folly::AsyncSocket> socket2(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
// Can't reuse client since the channel has gone bad
TestServiceAsyncClient client2(HeaderClientChannel::newChannel(socket2));
client2.sync_sendResponse(response, 64);
}
TEST(ThriftServer, setIOThreadPool) {
auto exe = std::make_shared<folly::IOThreadPoolExecutor>(1);
TestThriftServerFactory<TestInterface> factory;
factory.useSimpleThreadManager(false);
auto server = std::static_pointer_cast<ThriftServer>(factory.create());
// Set the exe, this used to trip various calls like
// CHECK(ioThreadPool->numThreads() == 0).
server->setIOThreadPool(exe);
EXPECT_EQ(1, server->getNumIOWorkerThreads());
}
TEST(ThriftServer, IdleServerTimeout) {
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
auto thriftServer = dynamic_cast<ThriftServer*>(server.get());
thriftServer->setIdleServerTimeout(std::chrono::milliseconds(50));
ScopedServerThread scopedServer(server);
scopedServer.join();
}
TEST(ThriftServer, ServerConfigTest) {
ThriftServer server;
wangle::ServerSocketConfig defaultConfig;
// If nothing is set, expect defaults
auto serverConfig = server.getServerSocketConfig();
EXPECT_EQ(
serverConfig.sslHandshakeTimeout, defaultConfig.sslHandshakeTimeout);
// Idle timeout of 0 with no SSL handshake set, expect it to be 0.
server.setIdleTimeout(std::chrono::milliseconds::zero());
serverConfig = server.getServerSocketConfig();
EXPECT_EQ(
serverConfig.sslHandshakeTimeout, std::chrono::milliseconds::zero());
// Expect the explicit to always win
server.setSSLHandshakeTimeout(std::chrono::milliseconds(100));
serverConfig = server.getServerSocketConfig();
EXPECT_EQ(serverConfig.sslHandshakeTimeout, std::chrono::milliseconds(100));
// Clear it and expect it to be zero again (due to idle timeout = 0)
server.setSSLHandshakeTimeout(folly::none);
serverConfig = server.getServerSocketConfig();
EXPECT_EQ(
serverConfig.sslHandshakeTimeout, std::chrono::milliseconds::zero());
}
TEST(ThriftServer, MultiPort) {
class MultiPortThriftServer : public ThriftServer {
public:
using ServerBootstrap::getSockets;
};
auto server = std::make_shared<MultiPortThriftServer>();
server->setInterface(std::make_shared<TestInterface>());
server->setNumIOWorkerThreads(1);
server->setNumCPUWorkerThreads(1);
// Add two ports 0 to trigger listening on two random ports.
folly::SocketAddress addr;
addr.setFromLocalPort(static_cast<uint16_t>(0));
server->setAddresses({addr, addr});
ScopedServerThread t(server);
auto sockets = server->getSockets();
ASSERT_EQ(sockets.size(), 2);
folly::SocketAddress addr1, addr2;
sockets[0]->getAddress(&addr1);
sockets[1]->getAddress(&addr2);
EXPECT_NE(addr1.getPort(), addr2.getPort());
// Test that we can talk via first port.
folly::EventBase base;
auto testFn = [&](folly::SocketAddress& address) {
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, address));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
client.sync_sendResponse(response, 42);
EXPECT_EQ(response, "test42");
};
testFn(addr1);
testFn(addr2);
}
TEST(ThriftServer, ClientIdentityHook) {
/* Tests that the server calls the client identity hook when creating a new
connection context */
std::atomic<bool> flag{false};
auto hook = [&flag](
const folly::AsyncTransport* /* unused */,
const X509* /* unused */,
const folly::SocketAddress& /* unused */) {
flag = true;
return std::unique_ptr<void, void (*)(void*)>(nullptr, [](void*) {});
};
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
server->setClientIdentityHook(hook);
apache::thrift::util::ScopedServerThread st(server);
folly::EventBase base;
auto socket = folly::AsyncSocket::newSocket(&base, *st.getAddress());
TestServiceAsyncClient client(
HeaderClientChannel::newChannel(std::move(socket)));
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_TRUE(flag);
}
namespace {
void setupServerSSL(ThriftServer& server) {
auto sslConfig = std::make_shared<wangle::SSLContextConfig>();
sslConfig->setCertificate(folly::kTestCert, folly::kTestKey, "");
sslConfig->clientCAFile = folly::kTestCA;
sslConfig->sessionContext = "ThriftServerTest";
server.setSSLConfig(std::move(sslConfig));
}
std::shared_ptr<folly::SSLContext> makeClientSslContext() {
auto ctx = std::make_shared<folly::SSLContext>();
ctx->loadCertificate(folly::kTestCert);
ctx->loadPrivateKey(folly::kTestKey);
ctx->loadTrustedCertificates(folly::kTestCA);
ctx->authenticate(
true /* verify server cert */, false /* don't verify server name */);
ctx->setVerificationOption(folly::SSLContext::SSLVerifyPeerEnum::VERIFY);
return ctx;
}
void doBadRequestHeaderTest(bool duplex, bool secure) {
auto server = std::static_pointer_cast<ThriftServer>(
TestThriftServerFactory<TestInterface>().create());
server->setDuplex(duplex);
if (secure) {
setupServerSSL(*server);
}
ScopedServerThread sst(std::move(server));
folly::EventBase evb;
folly::AsyncSocket::UniquePtr socket(
secure ? new folly::AsyncSSLSocket(makeClientSslContext(), &evb)
: new folly::AsyncSocket(&evb));
socket->connect(nullptr /* connect callback */, *sst.getAddress());
class RecordWriteSuccessCallback
: public folly::AsyncTransport::WriteCallback {
public:
void writeSuccess() noexcept override {
EXPECT_FALSE(success_);
success_.emplace(true);
}
void writeErr(
size_t /* bytesWritten */,
const folly::AsyncSocketException& /* exception */) noexcept override {
EXPECT_FALSE(success_);
success_.emplace(false);
}
bool success() const {
return success_ && *success_;
}
private:
folly::Optional<bool> success_;
};
RecordWriteSuccessCallback recordSuccessWriteCallback;
class CheckClosedReadCallback : public folly::AsyncTransport::ReadCallback {
public:
explicit CheckClosedReadCallback(folly::AsyncSocket& socket)
: socket_(socket) {
socket_.setReadCB(this);
}
~CheckClosedReadCallback() override {
// We expect that the server closed the connection
EXPECT_TRUE(remoteClosed_);
socket_.close();
}
void getReadBuffer(void** bufout, size_t* lenout) override {
// For this test, we never do anything with the buffered data, but we
// still need to implement the full ReadCallback interface.
*bufout = buf_;
*lenout = sizeof(buf_);
}
void readDataAvailable(size_t /* len */) noexcept override {}
void readEOF() noexcept override {
remoteClosed_ = true;
}
void readErr(const folly::AsyncSocketException& ex) noexcept override {
ASSERT_EQ(ECONNRESET, ex.getErrno());
remoteClosed_ = true;
}
private:
folly::AsyncSocket& socket_;
char buf_[1024];
bool remoteClosed_{false};
};
EXPECT_TRUE(socket->good());
{
CheckClosedReadCallback checkClosedReadCallback_(*socket);
constexpr folly::StringPiece kBadRequest("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
socket->write(
&recordSuccessWriteCallback, kBadRequest.data(), kBadRequest.size());
evb.loop();
}
EXPECT_TRUE(recordSuccessWriteCallback.success());
EXPECT_FALSE(socket->good());
}
} // namespace
TEST(ThriftServer, BadRequestHeaderNoDuplexNoSsl) {
doBadRequestHeaderTest(false /* duplex */, false /* secure */);
}
TEST(ThriftServer, BadRequestHeaderDuplexNoSsl) {
doBadRequestHeaderTest(true /* duplex */, false /* secure */);
}
TEST(ThriftServer, BadRequestHeaderNoDuplexSsl) {
doBadRequestHeaderTest(false /* duplex */, true /* secure */);
}
TEST(ThriftServer, BadRequestHeaderDuplexSsl) {
doBadRequestHeaderTest(true /* duplex */, true /* secure */);
}
TEST(ThriftServer, SSLRequiredRejectsPlaintext) {
auto server = std::static_pointer_cast<ThriftServer>(
TestThriftServerFactory<TestInterface>().create());
server->setSSLPolicy(SSLPolicy::REQUIRED);
setupServerSSL(*server);
ScopedServerThread sst(std::move(server));
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
EXPECT_THROW(client.sync_sendResponse(response, 64);, TTransportException);
}
TEST(ThriftServer, SSLRequiredAllowsLocalPlaintext) {
auto server = std::static_pointer_cast<ThriftServer>(
TestThriftServerFactory<TestInterface>().create());
server->setAllowPlaintextOnLoopback(true);
server->setSSLPolicy(SSLPolicy::REQUIRED);
setupServerSSL(*server);
ScopedServerThread sst(std::move(server));
folly::EventBase base;
// ensure that the address is loopback
auto port = sst.getAddress()->getPort();
folly::SocketAddress loopback("::1", port);
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, loopback));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
base.loop();
}
TEST(ThriftServer, SSLRequiredLoopbackUsesSSL) {
auto server = std::static_pointer_cast<ThriftServer>(
TestThriftServerFactory<TestInterface>().create());
server->setAllowPlaintextOnLoopback(true);
server->setSSLPolicy(SSLPolicy::REQUIRED);
setupServerSSL(*server);
ScopedServerThread sst(std::move(server));
folly::EventBase base;
// ensure that the address is loopback
auto port = sst.getAddress()->getPort();
folly::SocketAddress loopback("::1", port);
auto ctx = makeClientSslContext();
auto sslSock = TAsyncSSLSocket::newSocket(ctx, &base);
sslSock->connect(nullptr /* connect callback */, loopback);
TestServiceAsyncClient client(HeaderClientChannel::newChannel(sslSock));
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
base.loop();
}
TEST(ThriftServer, SSLPermittedAcceptsPlaintextAndSSL) {
auto server = std::static_pointer_cast<ThriftServer>(
TestThriftServerFactory<TestInterface>().create());
server->setSSLPolicy(SSLPolicy::PERMITTED);
setupServerSSL(*server);
ScopedServerThread sst(std::move(server));
folly::EventBase base;
{
SCOPED_TRACE("Plaintext");
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
base.loop();
}
{
SCOPED_TRACE("SSL");
auto ctx = makeClientSslContext();
auto sslSock = TAsyncSSLSocket::newSocket(ctx, &base);
sslSock->connect(nullptr /* connect callback */, *sst.getAddress());
TestServiceAsyncClient client(HeaderClientChannel::newChannel(sslSock));
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
base.loop();
}
}
TEST(ThriftServer, ClientOnlyTimeouts) {
class SendResponseInterface : public TestServiceSvIf {
void sendResponse(std::string& _return, int64_t shouldSleepMs) override {
auto header = getConnectionContext()->getHeader();
if (shouldSleepMs) {
usleep(shouldSleepMs * 1000);
}
_return = fmt::format(
"{}:{}",
header->getClientTimeout().count(),
header->getClientQueueTimeout().count());
}
};
TestThriftServerFactory<SendResponseInterface> factory;
ScopedServerThread st(factory.create());
folly::EventBase base;
std::shared_ptr<folly::AsyncSocket> socket(
folly::AsyncSocket::newSocket(&base, *st.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
for (bool clientOnly : {false, true}) {
for (bool shouldTimeOut : {true, false}) {
std::string response;
RpcOptions rpcOpts;
rpcOpts.setTimeout(std::chrono::milliseconds(20));
rpcOpts.setQueueTimeout(std::chrono::milliseconds(20));
rpcOpts.setClientOnlyTimeouts(clientOnly);
try {
client.sync_sendResponse(rpcOpts, response, shouldTimeOut ? 50 : 0);
EXPECT_FALSE(shouldTimeOut);
if (clientOnly) {
EXPECT_EQ(response, "0:0");
} else {
EXPECT_EQ(response, "20:20");
}
} catch (...) {
EXPECT_TRUE(shouldTimeOut);
}
}
}
base.loop();
}
TEST(ThriftServer, QueueTimeoutStressTest) {
// Make sure we only open one connection to the server.
auto ioExecutor = std::make_shared<folly::IOThreadPoolExecutor>(1);
folly::setIOExecutor(ioExecutor);
static std::atomic<int> server_reply = 0;
static std::atomic<int> received_reply = 0;
class SendResponseInterface : public TestServiceSvIf {
void sendResponse(std::string& _return, int64_t id) override {
DCHECK(lastSeenId_ < id);
if (lastSeenId_ + 1 == id) {
std::this_thread::sleep_for(sleepTime_);
sleepTime_ *= 2;
} else {
sleepTime_ = std::chrono::microseconds{1};
}
server_reply++;
lastSeenId_ = id;
_return = "wow";
}
std::chrono::microseconds sleepTime_{1};
int64_t lastSeenId_{-1};
};
constexpr size_t kNumReqs = 50000;
{
ScopedServerInterfaceThread runner(
std::make_shared<SendResponseInterface>());
runner.getThriftServer().setQueueTimeout(std::chrono::milliseconds{10});
auto client = runner.newClient<TestServiceAsyncClient>(
nullptr /* executor */, [](auto socket) mutable {
return RocketClientChannel::newChannel(std::move(socket));
});
std::vector<folly::SemiFuture<std::string>> futures;
for (size_t req = 0; req < kNumReqs; ++req) {
futures.emplace_back(client->semifuture_sendResponse(req));
}
size_t exceptions = 0;
for (auto& future : futures) {
auto t = std::move(future).getTry();
if (t.hasValue()) {
++received_reply;
} else {
++exceptions;
}
}
EXPECT_LT(exceptions, kNumReqs);
EXPECT_GT(exceptions, 0);
}
EXPECT_EQ(received_reply, server_reply);
}
| [
"nateweiler84@gmail.com"
] | nateweiler84@gmail.com |
036dbede7374c8241300fc95aa0832cfd4bf9e38 | bd9d40d0bd8a4759b3db20e10d2dda616a411c48 | /Samples/Graphics/BillboardNodes/BillboardNodesWindow.cpp | 6870950ef1538b9e867d7d1c4a72791a038f610b | [] | no_license | lai3d/GeometricToolsEngine3p16 | d07f909da86e54aa597abd49c57d17981f3dc72f | 50a6096e1b9f021483cf42aaf244587ff9a81f5b | refs/heads/master | 2020-04-01T19:28:22.495042 | 2018-10-18T06:27:05 | 2018-10-18T06:27:05 | 153,555,419 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,672 | cpp | // David Eberly, Geometric Tools, Redmond WA 98052
// Copyright (c) 1998-2018
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// File Version: 3.0.0 (2016/06/19)
#include "BillboardNodesWindow.h"
int main(int, char const*[])
{
#if defined(_DEBUG)
LogReporter reporter(
"LogReport.txt",
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL);
#endif
Window::Parameters parameters(L"BillboardNodesWindow", 0, 0, 640, 480);
auto window = TheWindowSystem.Create<BillboardNodesWindow>(parameters);
TheWindowSystem.MessagePump(window, TheWindowSystem.DEFAULT_ACTION);
TheWindowSystem.Destroy<BillboardNodesWindow>(window);
return 0;
}
BillboardNodesWindow::BillboardNodesWindow(Parameters& parameters)
:
Window3(parameters)
{
if (!SetEnvironment())
{
parameters.created = false;
return;
}
mEngine->SetClearColor({0.9f, 0.9f, 0.9f, 1.0f});
// InitializeCamera(...) occurs before CreateScene() because the billboard
// node creation requires the camera to be initialized.
InitializeCamera(60.0f, GetAspectRatio(), 0.1f, 100.0f, 0.005f, 0.002f,
{ 0.0f, -1.0f, 0.25f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f });
CreateScene();
mPVWMatrices.Update();
mCuller.ComputeVisibleSet(mCamera, mScene);
}
void BillboardNodesWindow::OnIdle()
{
mTimer.Measure();
if (mCameraRig.Move())
{
mPVWMatrices.Update();
mCuller.ComputeVisibleSet(mCamera, mScene);
}
mEngine->ClearBuffers();
for (auto const& visual : mCuller.GetVisibleSet())
{
mEngine->Draw(visual);
}
#if defined(DEMONSTRATE_VIEWPORT_BOUNDING_RECTANGLE)
ComputeTorusBoundingRectangle();
mEngine->SetBlendState(mBlendState);
std::shared_ptr<RasterizerState> rstate = mEngine->GetRasterizerState();
mEngine->SetRasterizerState(mNoCullState);
mEngine->Draw(mOverlay);
mEngine->SetRasterizerState(rstate);
mEngine->SetDefaultBlendState();
#endif
mEngine->Draw(8, mYSize - 8, { 1.0f, 1.0f, 1.0f, 1.0f }, mTimer.GetFPS());
mEngine->DisplayColorBuffer(0);
mTimer.UpdateFrameCount();
}
bool BillboardNodesWindow::OnCharPress(unsigned char key, int x, int y)
{
switch (key)
{
case 'p':
case 'P':
if (mEngine->GetRasterizerState() != mCullCWState)
{
Matrix4x4<float> xReflect = Matrix4x4<float>::Identity();
xReflect(0, 0) = -1.0f;
mCamera->SetPostProjectionMatrix(xReflect);
mEngine->SetRasterizerState(mCullCWState);
}
else
{
mCamera->SetPostProjectionMatrix(Matrix4x4<float>::Identity());
mEngine->SetDefaultRasterizerState();
}
mPVWMatrices.Update();
return true;
}
return Window::OnCharPress(key, x, y);
}
bool BillboardNodesWindow::OnMouseMotion(MouseButton button, int x, int y,
unsigned int modifiers)
{
if (Window3::OnMouseMotion(button, x, y, modifiers))
{
mPVWMatrices.Update();
mCuller.ComputeVisibleSet(mCamera, mScene);
}
return true;
}
bool BillboardNodesWindow::SetEnvironment()
{
std::string path = GetGTEPath();
if (path == "")
{
return false;
}
mEnvironment.Insert(path + "/Samples/Data/");
std::vector<std::string> inputs =
{
"BlueGrid.png",
"RedSky.png"
};
for (auto const& input : inputs)
{
if (mEnvironment.GetPath(input) == "")
{
LogError("Cannot find file " + input);
return false;
}
}
return true;
}
void BillboardNodesWindow::CreateScene()
{
mScene = std::make_shared<Node>();
std::string path = mEnvironment.GetPath("BlueGrid.png");
mGroundTexture = WICFileIO::Load(path, true);
mGroundTexture->AutogenerateMipmaps();
path = mEnvironment.GetPath("RedSky.png");
mSkyTexture = WICFileIO::Load(path, false);
VertexFormat vformat;
vformat.Bind(VA_POSITION, DF_R32G32B32_FLOAT, 0);
vformat.Bind(VA_TEXCOORD, DF_R32G32_FLOAT, 0);
MeshFactory mf;
mf.SetVertexFormat(vformat);
// Create the ground. It covers a square with vertices (1,1,0), (1,-1,0),
// (-1,1,0), and (-1,-1,0). Multiply the texture coordinates by a factor
// to enhance the wrap-around.
mGround = mf.CreateRectangle(2, 2, 16.0f, 16.0f);
mScene->AttachChild(mGround);
std::shared_ptr<VertexBuffer> vbuffer = mGround->GetVertexBuffer();
unsigned int numVertices = vbuffer->GetNumElements();
Vertex* vertex = vbuffer->Get<Vertex>();
for (unsigned int i = 0; i < numVertices; ++i)
{
vertex[i].tcoord *= 128.0f;
}
// Create a texture effect for the ground.
std::shared_ptr<Texture2Effect> groundEffect =
std::make_shared<Texture2Effect>(mProgramFactory, mGroundTexture,
SamplerState::MIN_L_MAG_L_MIP_L, SamplerState::WRAP,
SamplerState::WRAP);
mGround->SetEffect(groundEffect);
// Create a rectangle mesh. The mesh is in the xy-plane. Do not apply
// local transformations to the mesh. Use the billboard node transforms
// to control the mesh location and orientation.
mRectangle = mf.CreateRectangle(2, 2, 0.125f, 0.25f);
// Create a texture effect for the rectangle.
std::shared_ptr<Texture2Effect> rectEffect =
std::make_shared<Texture2Effect>(mProgramFactory, mSkyTexture,
SamplerState::MIN_L_MAG_L_MIP_P, SamplerState::CLAMP,
SamplerState::CLAMP);
mRectangle->SetEffect(rectEffect);
// Create a torus mesh. Do not apply local transformations to the mesh.
// Use the billboard node transforms to control the mesh location and
// orientation.
mTorus = mf.CreateTorus(16, 16, 1.0f, 0.25f);
mTorus->localTransform.SetUniformScale(0.1f);
// Create a texture effect for the torus.
std::shared_ptr<Texture2Effect> torusEffect =
std::make_shared<Texture2Effect>(mProgramFactory, mSkyTexture,
SamplerState::MIN_L_MAG_L_MIP_P, SamplerState::CLAMP,
SamplerState::CLAMP);
mTorus->SetEffect(torusEffect);
// Create a billboard node that causes a rectangle always to be facing the
// camera. This is the type of billboard for an avatar.
mBillboard0 = std::make_shared<BillboardNode>(mCamera);
mBillboard0->AttachChild(mRectangle);
mScene->AttachChild(mBillboard0);
// The billboard rotation is about its model-space up-vector (0,1,0). In
// this application, world-space up is (0,0,1). Locally rotate the
// billboard so it's up-vector matches the world's.
AxisAngle<4, float> aa(Vector4<float>::Unit(0), (float)GTE_C_HALF_PI);
mBillboard0->localTransform.SetTranslation(-0.25f, 0.0f, 0.25f);
mBillboard0->localTransform.SetRotation(aa);
// Create a billboard node that causes the torus always to be oriented the
// same way relative to the camera.
mBillboard1 = std::make_shared<BillboardNode>(mCamera);
mBillboard1->AttachChild(mTorus);
mScene->AttachChild(mBillboard1);
// The billboard rotation is about its model-space up-vector (0,1,0). In
// this application, world-space up is (0,0,1). Locally rotate the
// billboard so it's up-vector matches the world's.
mBillboard1->localTransform.SetTranslation(0.25f, 0.0f, 0.25f);
mBillboard1->localTransform.SetRotation(aa);
// When the trackball moves, automatically update the PVW matrices that
// are used by the effects.
mPVWMatrices.Subscribe(mGround->worldTransform, groundEffect->GetPVWMatrixConstant());
mPVWMatrices.Subscribe(mRectangle->worldTransform, rectEffect->GetPVWMatrixConstant());
mPVWMatrices.Subscribe(mTorus->worldTransform, torusEffect->GetPVWMatrixConstant());
// Attach the scene to the virtual trackball. When the trackball moves,
// the W matrix of the scene is updated automatically. The W matrices
// of the child objects are also updated by the hierarchical update.
mTrackball.Attach(mScene);
mTrackball.Update();
#if defined(DEMONSTRATE_VIEWPORT_BOUNDING_RECTANGLE)
mBlendState = std::make_shared<BlendState>();
mBlendState->target[0].enable = true;
mBlendState->target[0].srcColor = BlendState::BM_SRC_ALPHA;
mBlendState->target[0].dstColor = BlendState::BM_INV_SRC_ALPHA;
mBlendState->target[0].srcAlpha = BlendState::BM_SRC_ALPHA;
mBlendState->target[0].dstAlpha = BlendState::BM_INV_SRC_ALPHA;
mOverlay = std::make_shared<OverlayEffect>(mProgramFactory, mXSize,
mYSize, 1, 1, SamplerState::MIN_P_MAG_P_MIP_P, SamplerState::CLAMP,
SamplerState::CLAMP, true);
std::shared_ptr<Texture2> overlayTexture = std::make_shared<Texture2>(
DF_R8G8B8A8_UNORM, 1, 1);
mOverlay->SetTexture(overlayTexture);
unsigned int& texel = *overlayTexture->Get<unsigned int>();
texel = 0x40FF0000; // (r,g,b,a) = (0,0,255,64)
mNoCullState = std::make_shared<RasterizerState>();
mNoCullState->cullMode = RasterizerState::CULL_NONE;
#endif
#if defined(DEMONSTRATE_POST_PROJECTION_REFLECTION)
mCullCWState = std::make_shared<RasterizerState>();
mCullCWState->cullMode = RasterizerState::CULL_FRONT;
#endif
}
#if defined(DEMONSTRATE_VIEWPORT_BOUNDING_RECTANGLE)
void BillboardNodesWindow::ComputeTorusBoundingRectangle()
{
Matrix4x4<float> pvMatrix = mCamera->GetProjectionViewMatrix();
#if defined(GTE_USE_MAT_VEC)
Matrix4x4<float> pvwMatrix = pvMatrix * mTorus->worldTransform;
#else
Matrix4x4<float> pvwMatrix = mTorus->worldTransform * pvMatrix;
#endif
std::shared_ptr<VertexBuffer> vbuffer = mTorus->GetVertexBuffer();
unsigned int numVertices = vbuffer->GetNumElements();
Vertex const* vertex = vbuffer->Get<Vertex>();
// Compute the extremes of the normalized display coordinates.
float const maxFloat = std::numeric_limits<float>::max();
float xmin = maxFloat, xmax = -maxFloat;
float ymin = maxFloat, ymax = -maxFloat;
for (unsigned int i = 0; i < numVertices; ++i, ++vertex)
{
Vector4<float> input{ vertex->position[0], vertex->position[1], vertex->position[2], 1.0f };
#if defined(GTE_USE_MAT_VEC)
Vector4<float> output = pvwMatrix * input;
#else
Vector4<float> output = input * pvwMatrix;
#endif
// Reflect the y-values because the normalized display coordinates
// are right-handed but the overlay rectangle coordinates are
// left-handed.
float invW = 1.0f / output[3];
float x = output[0] * invW;
float y = -output[1] * invW;
if (x < xmin)
{
xmin = x;
}
if (x > xmax)
{
xmax = x;
}
if (y < ymin)
{
ymin = y;
}
if (y > ymax)
{
ymax = y;
}
}
// Map normalized display coordinates [-1,1]^2 to [0,1]^2.
xmin = 0.5f * (xmin + 1.0f);
xmax = 0.5f * (xmax + 1.0f);
ymin = 0.5f * (ymin + 1.0f);
ymax = 0.5f * (ymax + 1.0f);
// Update the overlay to the region covered by the bounding rectangle.
std::array<int, 4> rectangle;
rectangle[0] = static_cast<int>(xmin * mXSize);
rectangle[1] = static_cast<int>(ymin * mYSize);
rectangle[2] = static_cast<int>((xmax - xmin) * mXSize);
rectangle[3] = static_cast<int>((ymax - ymin) * mYSize);
mOverlay->SetOverlayRectangle(rectangle);
mEngine->Update(mOverlay->GetVertexBuffer());
}
#endif
| [
"larry@qjt.sg"
] | larry@qjt.sg |
cde58fed207a64db2a93fa30d9cbdd3066388a3f | 53abc1bed5e97696bb24e8a7216de42c3a85acf5 | /broadcastradio/1.1/default/VirtualProgram.h | a14830d77af5d8e9b7ab5ffbdaf695733c649fda | [
"Apache-2.0"
] | permissive | projectceladon/hardware-interfaces | ebcdeeab2f617779550d56b29dbcbd89bbc16c82 | 4af44ed420db38156bc5ac05b5cd9ac1d2c555e6 | refs/heads/master | 2023-01-27T16:54:08.072221 | 2023-01-10T07:17:46 | 2023-01-10T07:17:46 | 127,979,554 | 2 | 4 | null | 2018-07-17T02:16:45 | 2018-04-03T23:18:03 | C++ | UTF-8 | C++ | false | false | 1,777 | h | /*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
#include <android/hardware/broadcastradio/1.1/types.h>
#include <broadcastradio-utils/Utils.h>
namespace android {
namespace hardware {
namespace broadcastradio {
namespace V1_1 {
namespace implementation {
/**
* A radio program mock.
*
* This represents broadcast waves flying over the air,
* not an entry for a captured station in the radio tuner memory.
*/
struct VirtualProgram {
ProgramSelector selector;
std::string programName = "";
std::string songArtist = "";
std::string songTitle = "";
ProgramInfo getProgramInfo(utils::HalRevision halRev) const;
friend bool operator<(const VirtualProgram& lhs, const VirtualProgram& rhs);
};
std::vector<ProgramInfo> getProgramInfoVector(const std::vector<VirtualProgram>& vec,
utils::HalRevision halRev);
} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
| [
"twasilczyk@google.com"
] | twasilczyk@google.com |
4026924e3fff89cbf2a6c971613f5c6b7baaf5de | f3d51858b71e1f656a5064e120c9ca8c7287a37e | /bst.cc | 0ddb9995330126ce1e868f0d709286815b310ab5 | [] | no_license | benjin1996/test | a62a27ebd96c73ba0069731f1b2fe9b3ecacdc03 | e507b411fef7193064b1f0a4ead36aae135c3901 | refs/heads/master | 2021-04-06T05:32:16.461891 | 2018-03-13T20:45:14 | 2018-03-13T20:45:14 | 125,110,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,484 | cc | #include "bst.h"
#include <iostream>
#include <string>
using namespace std;
treenode::treenode(int v): element{v}, left{NULL}, right{NULL}, size{1}, height{1} {}
treenode::treenode(const treenode& t): element{t.element}, left{NULL}, right{NULL}, size{t.size} {
left = new treenode(*(t.left));
right = new treenode(*(t.right));}
//treenode& treenode::operator=(const treenode& t) {
// v = t.v;}
void treenode::updateheight() {
if (left == NULL && right == NULL) {
height = 1;}
else if (left == NULL || right == NULL) {
if (left == NULL) {
height = right->height + 1;}
else {
height = left->height + 1;}}
else {
int l = left->height;
int r = right->height;
if (r > l) {
height = 1 + r;}
else {
height = 1 + l;}}}
void treenode::insert(int v) {
size += 1;
if (v > element) {
if (right == NULL) {
right = new treenode(v);}
else {
right->insert(v);}}
else {
if (left == NULL) {
left = new treenode(v);}
else {
left->insert(v);}}
updateheight();}
int treenode::sum() {
if (this == NULL) {
return 0;}
return element + right->sum() + left->sum();}
int ithele(treenode* t, int i) {
if (t->left == NULL) {
if (i == 1) {
return t->element;}
else if (i > 1) {
return ithele(t->right, i - 1);}}
else {
int counter = t->left->size;
if (i == counter + 1) {
return t->element;}
else if (i > counter + 1) {
return ithele(t->right,i - counter - 1);}
else {
return ithele(t->left,i);}}}
treenode* delnode(treenode* t, int v) {
if (t->element == v) {
if (t->left == NULL && t->right == NULL) {
delete t;
return NULL;}
else if (t->left == NULL) {
treenode* temp = t->right;
delete t;
return temp;}
else if (t->right == NULL) {
treenode* temp = t->left;
delete t;
return temp;}
else {
treenode* temp = t->right;
treenode* leftcopy = t->left;
treenode* rightcopy = t->right;
int cursize = t->size;
if (temp->left == NULL) {
temp->left = leftcopy;
temp->size += temp->left->size;
delete t;
return temp;}
treenode* tc = t->right;
int r = tc->right->height;
int l = tc->left->height;
int counter = 0;
while (temp->left != NULL) {
if (counter != 0) {
tc = tc->left;}
temp->size -= 1;
temp = temp->left;
counter += 1;}
tc->left = temp->right;
temp->size = cursize - 1;
temp->right = rightcopy;
temp->left = leftcopy;
delete t;
return temp;}}
else {
t->size -= 1;
if (v > t->element) {
t->right = delnode(t->right,v);}
else {
t->left = delnode(t->left,v);}}
t->updateheight();}
void treenode::printtree() {
if (this == NULL) {
return;}
left->printtree();
cout << element << endl;
right->printtree();}
treenode::~treenode() {}
bsttree::bsttree(treenode* t) {
root = t;
treenode* temp = t;
treenode* temp2 = t;
while (temp->left != NULL) {
temp = temp->left;}
min = temp->element;
while (temp2->right != NULL) {
temp2 = temp2->right;}
max = temp2->element;}
void bsttree::ins(int v) {
if (v > max) {
max = v;}
else if (v < min) {
min = v;}
root->insert(v);}
void bsttree::del(int v) {
// if (v == max) {
// max = ithele(root,root->size-1);}
// else if (v == min) {
// min = ithele(root,2);}
root = delnode(root,v);}
void deletehelper(treenode* t) {
if (t == NULL) {
return;}
deletehelper(t->left);
deletehelper(t->right);
delete t;}
void bsttree::print() {
root->printtree();
cout << endl;}
bsttree::~bsttree() {
deletehelper(root);}
| [
"qsjin@student.cs.uwaterloo.ca"
] | qsjin@student.cs.uwaterloo.ca |
b0153c2380c59cd155a0876988f795f1beba951a | 04aa795836b531b9ed7156469a0049d9bc67251f | /src/convert/pinyin.cpp | c36916d164df81997cf2fd687151337be9e59fd6 | [] | no_license | fshmjl/shove.c | 45c1b75f1ff45fdf44330187d26d871d51ab84eb | d510d5e3bb8be4a902c001e0ac87305582b3dfb2 | refs/heads/master | 2020-03-19T09:13:17.459884 | 2018-06-06T02:58:58 | 2018-06-06T02:58:58 | 136,269,674 | 1 | 0 | null | 2018-06-06T03:58:51 | 2018-06-06T03:58:51 | null | UTF-8 | C++ | false | false | 1,449 | cpp | #include "pinyin.h"
namespace shove
{
namespace convert
{
static const size_t SIZE_ARRAY = sizeof(code_pin) / sizeof(short);
const char* get_pinyin(unsigned short char_zh)
{
size_t low = 0, high = SIZE_ARRAY - 1;
size_t index;
while (high - low != 1)
{
index = (low + high) / 2;
if (code_pin[index] == char_zh)
{
return str_pin[index];
}
if (code_pin[index] < char_zh)
{
low = index;
}
else
{
high = index;
}
}
return str_pin[code_pin[high] <= char_zh ? high : low];
}
string chineseToPinyin(string const &input, bool isLetteryEnd)
{
string result;
unsigned short char_zh;
int inputLength = input.length();
unsigned char high, low;
for (int i = 0; i < inputLength; ++i)
{
high = input[i];
if (high < 0x80)
{
if (isLetteryEnd && (i > 0 && input[i - 1] < 0))
{
result.append(1, ' ');
}
result.append(1, high);
}
else
{
if (isLetteryEnd && (i > 0))
{
result.append(1, ' ');
}
low = input[++i];
char_zh = (high << 8) + low;
result.append(get_pinyin(char_zh));
}
}
return result;
}
}
}
| [
"shove@163.com"
] | shove@163.com |
f9d27e4310da59a8c49d20b306aa867635600890 | c3c2701c90bdf0a1f52537b0a6747191369e309d | /1581/1581.cpp | 6b15e00e1214464cdf768e90c0d86a87042afd3a | [] | no_license | bzz13/timus | 3c2b845a05cfd716c117fdee832f81e867f0245d | f102d3f10be0e939b96f2bfabac45bf5b763ba32 | refs/heads/master | 2021-06-19T14:02:24.815170 | 2021-02-01T09:12:40 | 2021-02-01T09:12:40 | 47,258,903 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 300 | cpp | #include <iostream>
using namespace std;
int main()
{
int count, prev, n = 1, tmp;
cin >> count;
cin >> prev;
while (count --> 1)
{
cin >> tmp;
if (tmp == prev)
{
n++;
continue;
}
cout << n << " " << prev << " ";
prev = tmp;
n = 1;
}
cout << n << " " << prev << " ";
} | [
"BZz13@skbkontur.ru"
] | BZz13@skbkontur.ru |
d79aef7dc02cd542eb4ac89547797327aef5ed2f | 2c232e51b27dc23d204a0b65e29536a72efd5b83 | /Source/Simulation/Moods/FoodMood.h | d1f7352bf93eec337493dbf5db842fc3dcfe6404 | [] | no_license | Bakuipje/CitySim | 16613d719306f9f67b4209b271fb60874aa3cff4 | 9dd11e663f0971aa421c539a4717c82c214ffe35 | refs/heads/master | 2020-03-14T13:50:28.483830 | 2018-04-30T20:27:19 | 2018-04-30T20:27:19 | 131,641,075 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 396 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Moods/MoodBase.h"
#include "FoodMood.generated.h"
/**
*
*/
UCLASS()
class SIMULATION_API UFoodMood : public UMoodBase
{
GENERATED_BODY()
public:
virtual URGBehaviorTreeBase* GetBehaviorTree_Implementation(URGBehaviorTreeComponent* behviorTreeComponent);
};
| [
"raulgernaert@hotmail.com"
] | raulgernaert@hotmail.com |
a25e902af97c046593500e64c30f6fb7b22602d1 | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/com/oleutest/balls/client/dllhost/main.cxx | 90b562c8e16a8dcfd5673e87f326c1e3eca9ea18 | [] | no_license | jjzhang166/WinNT5_src_20201004 | 712894fcf94fb82c49e5cd09d719da00740e0436 | b2db264153b80fbb91ef5fc9f57b387e223dbfc2 | refs/heads/Win2K3 | 2023-08-12T01:31:59.670176 | 2021-10-14T15:14:37 | 2021-10-14T15:14:37 | 586,134,273 | 1 | 0 | null | 2023-01-07T03:47:45 | 2023-01-07T03:47:44 | null | UTF-8 | C++ | false | false | 757 | cxx | //+------------------------------------------------------------------
//
// File: main.cxx
//
// Contents: common entry point for test drivers.
//
//--------------------------------------------------------------------
#include <tstmain.hxx>
#include <tdllhost.h>
//+-------------------------------------------------------------------
//
// Function: main
//
// Synopsis: Entry point to EXE
//
// Returns: TRUE
//
// History: 21-Nov-92 Rickhi Created
//
// Just delegates to a <main> subroutine that is common for all test
// drivers.
//
//--------------------------------------------------------------------
int _cdecl main(int argc, char **argv)
{
return DriverMain(argc, argv, "Dll Host", &TestDllHost);
}
| [
"seta7D5@protonmail.com"
] | seta7D5@protonmail.com |
77f5044b9ffbf1a7f07c4793b40d14265ba669c9 | f3b71749df0c2cad2418bca71426c657ef9a17e3 | /Example-4/source/House.h | 8145df66f12a39570616700b28926912ba4199b2 | [] | no_license | randyL78/review-02 | 6bd9ca0b0c078934b6036460fc998b0593d6fffb | 3feb5822ecbe6ff98fd213abddb6574549ce1c7a | refs/heads/master | 2020-12-22T17:48:15.337042 | 2020-01-29T01:10:59 | 2020-01-29T01:10:59 | 236,878,800 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,539 | h | #ifndef HOUSE_H_INCLUDED
#define HOUSE_H_INCLUDED
#include <iostream>
#include <string>
#include <list>
#include "Room.h"
/**
* A House is composed of zero or more Room objects.
* <p>
* This class serves as our demonstration of the STL
* iterator interface.
*/
class House{
public:
/**
* A standard C++ STL style iterator.
* <p>
* Recall the rules on Class naming and the STL.
*/
typedef std::list<Room>::iterator iterator;
/**
* A standard C++ STL style iterator.
* <p>
* Recall the rules on Class naming and the STL.
*/
typedef std::list<Room>::const_iterator const_iterator;
private:
/**
* Name of the house--e.g.,
* Minecraft Beach House
*/
std::string name;
/**
* Container of Rooms
*/
std::list<Room> rooms;
public:
/**
* Construct a House with a
* generic name and no rooms.
*/
House();
/**
* Construct a House with a specified name
*/
House(std::string name);
/**
* Add a Room
*
* @param toAdd new Room object
*/
void addRoom(Room toAdd);
/**
* Allow access to the _beginning_ of the
* house--i.e., Room container--via an
* iterator.
*/
iterator begin();
/**
* Allow access to the _beginning_ of the
* house--i.e., Room container--via a
* const_iterator.
*/
const_iterator begin() const;
/**
* Allow access to the _end_ of the
* house--i.e., Room container--via an
* iterator.
*/
iterator end();
/**
* Allow access to the _end_ of the
* house--i.e., Room container--via a
* const_iterator.
*/
const_iterator end() const;
/**
* Return the size of the house--i.e.,
* the number of rooms
*/
size_t size() const;
/**
* Print the house
*/
void display(std::ostream& outs) const;
};
/**
* House Stream Insertion (Output) Operator
*
* This is often written as a wrapper for a
* display or print function.
* <p>
* This operator can *NOT* be implemented as a member function.
*/
inline
std::ostream& operator<<(std::ostream &outs, const House &prt)
{
prt.display(outs);
return outs;
}
#endif | [
"randydavidl78@gmail.com"
] | randydavidl78@gmail.com |
9fb96ccb1817b436ee775196e9feebe7b43444e1 | 5879255ef03810ce9488c22514e01942be1675ca | /Software/ExpShield1/ASInc/Sampler.h | 7d90939136a2226c4d3560f0f95c4ef82bb6c312 | [] | no_license | ec-jrc/airsenseur-sensorsshield | 0321ce44caec82b4e65f876dc266e5aec8ca20e7 | 7069ced06ca2407d194144845c761517a9289256 | refs/heads/master | 2023-05-24T18:07:18.022929 | 2023-05-16T15:11:00 | 2023-05-16T15:11:00 | 143,874,983 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,165 | h | /* ===========================================================================
* Copyright 2015 EUROPEAN UNION
*
* Licensed under the EUPL, Version 1.1 or subsequent versions of the
* EUPL (the "License"); You may not use this work except in compliance
* with the License. You may obtain a copy of the License at
* http://ec.europa.eu/idabc/eupl
* 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.
*
* Date: 02/04/2015
* Authors:
* - Michel Gerboles, michel.gerboles@jrc.ec.europa.eu,
* Laurent Spinelle, laurent.spinelle@jrc.ec.europa.eu and
* Alexander Kotsev, alexander.kotsev@jrc.ec.europa.eu:
* European Commission - Joint Research Centre,
* - Marco Signorini, marco.signorini@liberaintentio.com
*
* ===========================================================================
*/
#ifndef SAMPLER_H
#define SAMPLER_H
class SensorDevice;
/* This is the base class for a sampler unit.
A sampler unit implements a basic multichannel aware sampler with prescaler and decimation timing option
*/
class Sampler {
public:
Sampler(unsigned char channels, SensorDevice *sensor);
virtual ~Sampler() { };
virtual const unsigned char getNumChannels() const;
virtual void setPreScaler(unsigned char value);
virtual unsigned char getPrescaler();
virtual void setDecimation(unsigned char value);
virtual unsigned char getDecimation();
virtual bool savePreset(unsigned char myID);
virtual bool loadPreset(unsigned char myID);
virtual void onStartSampling();
virtual void onStopSampling();
virtual bool sampleTick();
virtual bool sampleLoop();
virtual void setLowPowerMode(bool lowPower);
virtual bool setEnableChannel(unsigned char channel, unsigned char enabled);
virtual bool getChannelIsEnabled(unsigned char channel, unsigned char* enabled);
virtual unsigned short getLastSample(unsigned char channel);
protected:
virtual bool applyDecimationFilter();
virtual void onReadSample(unsigned char channel, unsigned short newSample);
SensorDevice* getSensor();
virtual bool atLeastOneChannelEnabled();
protected:
volatile bool go; // it's time for a new sample (shared info from interrupt)
unsigned char prescaler; // basic samples are taken at sampleTick/prescaler
unsigned char timer; // this is the prescaler counter
unsigned char decimation; // decimation filter length
unsigned char decimationTimer; // this is the decimation counter
unsigned char numChannels; // Number of channels the sampler is valid to handle
unsigned short *lastSample; // last valid sample read buffers
bool *enabled; // channels enabled/disabled status
SensorDevice *sensor; // The sensor associated to this sampler
};
#endif /* SAMPLER_H */
| [
"marco.signorini@liberaintentio.com"
] | marco.signorini@liberaintentio.com |
b91b4a10abb60124cad3577143a7e88ee50eb31f | 834db2ce1c2a59f49d90ba926c1a7a2a084124e8 | /src/sdk/knmenulayer.cpp | f8d297d1bfd453b9fe0aff19fdf8cd890d5cbe27 | [] | no_license | Harinlen/Cinema | f98a7961e7f71fd5156c6a5ed9e6287bac33dfa2 | 251b8eb47d540932387e8784db57ffb14eed7630 | refs/heads/master | 2020-04-22T00:27:45.011736 | 2019-02-18T12:41:13 | 2019-02-18T12:41:13 | 169,980,228 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,095 | cpp | /*
* Copyright (C) Kreogist Dev Team
*
* 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QPainter>
#include <QKeyEvent>
#include <QTimeLine>
#include "knmenubase.h"
#include "kndpimanager.h"
#include "knaudiomanager.h"
#include "knmenulayer.h"
#define Darkness 157
#define Duration 333
#define MenuWidth 480
KNMenuLayer::KNMenuLayer(QWidget *parent) : QWidget(parent),
m_timeLine(new QTimeLine(Duration, this)),
m_menuWidget(nullptr),
m_showing(false)
{
setFocusPolicy(Qt::StrongFocus);
//Configure the timeline.
m_timeLine->setUpdateInterval(16);
m_timeLine->setEasingCurve(QEasingCurve::OutCubic);
connect(m_timeLine, &QTimeLine::frameChanged, [=](int offset)
{
//Save the darkness.
m_menuWidget->move(width()-offset, 0);
//Set the menu status.
m_menuWidget->setOpacity(m_showing?m_timeLine->currentValue():
1.0-m_timeLine->currentValue());
//Update the widget.
update();
});
//Hide the widget at beginning.
hide();
}
void KNMenuLayer::showMenu()
{
if(m_timeLine->state()==QTimeLine::Running)
{
return;
}
m_showing=true;
//Prepare the hovering.
m_menuWidget->prepareHover();
//Configure the animation.
m_timeLine->setFrameRange(0, m_menuWidget->width());
//Start animation.
m_menuWidget->move(width(), 0);
m_timeLine->start();
//Play the audio hint.
knAudio->play(KNAudioManager::AudioMenuOpen);
//Change the focus.
m_menuWidget->setFocus();
}
void KNMenuLayer::hideMenu()
{
if(m_timeLine->state()==QTimeLine::Running)
{
return;
}
m_showing=false;
//Configure the time line.
m_timeLine->setFrameRange(m_menuWidget->width(), 0);
connect(m_timeLine, &QTimeLine::finished, [=]
{
//Disconnect the finished signal.
disconnect(m_timeLine, &QTimeLine::finished, nullptr, nullptr);
//Emit the signal.
emit menuHideComplete();
//Hide the widget.
hide();
});
//Start the animation.
m_timeLine->start();
}
void KNMenuLayer::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Escape:
if(m_timeLine->state()==QTimeLine::Running)
{
event->ignore();
return;
}
//Play the audio hint.
knAudio->play(KNAudioManager::AudioMenuClose);
//Hide the menu.
hideMenu();
event->accept();
break;
default:
event->accept();
break;
}
}
void KNMenuLayer::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
//Check the menu widget.
if(m_menuWidget)
{
//Update the menu widget size.
m_menuWidget->resize(knDpi->width(MenuWidth), height());
}
}
QWidget *KNMenuLayer::menuWidget() const
{
return m_menuWidget;
}
void KNMenuLayer::setMenuWidget(KNMenuBase *menuWidget)
{
//Save the menu widget pointer.
m_menuWidget = menuWidget;
//Link the request signal from menu widget.
connect(m_menuWidget, &KNMenuBase::requireHideMenu,
this, &KNMenuLayer::hideMenu);
//Transfer the relationship.
m_menuWidget->setParent(this);
m_menuWidget->move(width(), 0);
m_menuWidget->resize(knDpi->width(MenuWidth), height());
//Transfer the focus proxy.
setFocusProxy(m_menuWidget);
}
| [
"tomguts@126.com"
] | tomguts@126.com |
449f811a923df47cbd18de3f9060bda1cd7e2292 | 19eb97436a3be9642517ea9c4095fe337fd58a00 | /private/inet/mshtml/src/site/miscelem/elabel.hxx | a29811a25818771dbd78f558c405052010a75551 | [] | no_license | oturan-boga/Windows2000 | 7d258fd0f42a225c2be72f2b762d799bd488de58 | 8b449d6659840b6ba19465100d21ca07a0e07236 | refs/heads/main | 2023-04-09T23:13:21.992398 | 2021-04-22T11:46:21 | 2021-04-22T11:46:21 | 360,495,781 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,763 | hxx | //+---------------------------------------------------------------------------
// Microsoft Forms
// Copyright (C) Microsoft Corporation, 1994-1996
//
// File: elabel.hxx
//
// Contents: CLabelElement class
//
// History: 10-Oct-1996 MohanB Created
//
//----------------------------------------------------------------------------
#ifndef I_ELABEL_HXX_
#define I_ELABEL_HXX_
#pragma INCMSG("--- Beg 'elabel.hxx'")
#define _hxx_
#include "label.hdl"
MtExtern(CLabelElement)
class CLabelElement : public CElement
{
DECLARE_CLASS_TYPES(CLabelElement, CElement)
public:
DECLARE_MEMCLEAR_NEW_DELETE(Mt(CLabelElement))
CLabelElement(CDoc *pDoc)
: CElement(ETAG_LABEL, pDoc)
{
#ifdef WIN16
m_baseOffset = ((BYTE *) (void *) (CBase *)this) - ((BYTE *) this);
m_ElementOffset = ((BYTE *) (void *) (CElement *)this) - ((BYTE *) this);
#endif
}
~CLabelElement() {}
static HRESULT CreateElement(CHtmTag *pht,
CDoc *pDoc, CElement **ppElementResult);
#ifndef NO_DATABINDING
// databinding over-rides from CElement
virtual const CDBindMethods *GetDBindMethods();
#endif // ndef NO_DATABINDING
virtual HRESULT BUGCALL HandleMessage(CMessage *pmsg);
virtual HRESULT ClickAction(CMessage * pMessage);
static const CLSID * s_apclsidPages[];
#define _CLabelElement_
#include "label.hdl"
virtual void Notify(CNotification * pNF);
protected:
DECLARE_CLASSDESC_MEMBERS;
private:
RECT _rcWobbleZone;
BOOL _fCanClick:1;
NO_COPY(CLabelElement);
};
#pragma INCMSG("--- End 'elabel.hxx'")
#else
#pragma INCMSG("*** Dup 'elabel.hxx'")
#endif
| [
"mehmetyilmaz3371@gmail.com"
] | mehmetyilmaz3371@gmail.com |
87272b9a0cd3816fb2d886c80f0f8d08cfa0a84e | 09608c3e53c8e8050b4d82b13a5e2b6746bbc9ac | /ESP8266PowerMonitor.ino | 96643da245666f800f1f7f7e79fc11638829f5e6 | [
"MIT"
] | permissive | davide83/ESP8266PowerMonitor | e540067a386e2da6b847f12d3ecbfc4873c4cc6f | d3b6720f46ca6caaac859a5c4b5c93c9f6ca2d9f | refs/heads/master | 2020-04-16T14:24:41.822938 | 2018-02-25T20:09:59 | 2018-02-25T20:09:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,672 | ino | /**
The MIT License (MIT)
Copyright (c) 2018 by ThingPulse, Daniel Eichhorn
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.
Please note: We are spending a lot of time developing Software and Hardware
for these projects. Please consider supporting us by
a) Buying my hardware kits from https://thingpulse.com
b) Send a donation: https://paypal.me/thingpulse/5USD
c) Or using this affiliate link while shopping: https://www.banggood.com/?p=CJ091019038450201802
See more at https://thingpulse.com
*/
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include <SSD1306.h> // alias for `#include "SSD1306Wire.h"`
#include "Adafruit_INA219.h"
/** Config **/
// If a current in mA above this value is measured the device is awake
#define AWAKE_THRESHOLD 1.0
// The battery used for forecasting the runtime in days in mAh
#define BAT_CAPACITY 600
/** End Config */
// States of the monitored device
#define STATE_NA 0
#define STATE_SLEEPING 1
#define STATE_AWAKE 2
// initial state
int deviceState = STATE_NA;
// Create OLED and INA219 globals.
SSD1306 display(0x3c, D5, D6);
Adafruit_INA219 ina219;
uint32_t lastUpdateMillis = 0;
uint32_t lastScreenUpdateMillis = 0;
uint32_t totalMeasuredMillis = 0;
uint32_t awakeStartMillis = 0;
uint32_t sleepStartMillis = 0;
uint32_t totalAwakeMillis = 0;
uint32_t totalSleepMillis = 0;
float totalAwakeMAh = 0;
float totalSleepMAh = 0;
float forecastBat = 0;
String getStateText(int state) {
switch(state) {
case STATE_NA:
return "NA";
case STATE_AWAKE:
return "AWAKE";
case STATE_SLEEPING:
return "SLEEP";
}
return "?";
}
void setup() {
Serial.begin(115200);
Serial.println("Setting up display...");
// Setup the OLED display.
display.init();
deviceState = STATE_NA;
// Clear the display.
display.clear();
display.setFont(ArialMT_Plain_10);
display.display();
ina219.begin(D3, D4);
// By default the INA219 will be calibrated with a range of 32V, 2A.
// However uncomment one of the below to change the range. A smaller
// range can't measure as large of values but will measure with slightly
// better precision.
//ina219.setCalibration_32V_1A();
ina219.setCalibration_16V_400mA();
}
void loop() {
// Read voltage and current from INA219.
float shuntvoltage = ina219.getShuntVoltage_mV();
float busvoltage = ina219.getBusVoltage_V();
float currentMA = ina219.getCurrent_mA();
uint32_t timeSinceLastMeasurement = millis() - lastUpdateMillis;
totalMeasuredMillis += timeSinceLastMeasurement;
uint32_t totalSec = totalMeasuredMillis / 1000;
if (currentMA > AWAKE_THRESHOLD) {
if (deviceState == STATE_NA) {
deviceState = STATE_AWAKE;
awakeStartMillis = millis();
totalAwakeMAh = 0;
totalMeasuredMillis = 0;
} else if (deviceState == STATE_SLEEPING) {
deviceState = STATE_AWAKE;
awakeStartMillis = millis();
totalAwakeMAh = 0;
totalMeasuredMillis = 0;
} else if (deviceState == STATE_AWAKE) {
totalAwakeMillis = millis() - awakeStartMillis;
totalAwakeMAh = totalAwakeMAh + ((currentMA * timeSinceLastMeasurement) / (3600 * 1000));
}
} else if (currentMA <= AWAKE_THRESHOLD) {
if (deviceState == STATE_NA) {
//deviceState = STATE_SLEEPING;
} else if (deviceState == STATE_SLEEPING) {
totalSleepMillis = millis() - sleepStartMillis;
totalSleepMAh = totalSleepMAh + ((currentMA * timeSinceLastMeasurement) / (3600 * 1000));
float forecastSleepMAh = 20 * 60 * 1000 * totalSleepMAh / totalSleepMillis;
forecastBat = (((totalAwakeMillis + 20 * 60 * 1000) / 1000) / (144 * (totalAwakeMAh + forecastSleepMAh)));
} else if (deviceState == STATE_AWAKE) {
deviceState = STATE_SLEEPING;
sleepStartMillis = millis();
totalSleepMAh = 0;
}
}
lastUpdateMillis = millis();
if (millis() - lastScreenUpdateMillis > 500) {
Wire.begin(D5, D6);
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 0, "Awake:");
display.drawString(0, 54, "State:");
display.drawString(0, 20, "Sleep:");
display.drawString(0, 40, "Forecast 0.6Ah:");
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(128, 0, String(totalAwakeMillis) + "ms");
display.drawString(128, 10, String(totalAwakeMAh) + "mAh");
display.drawString(128, 20, String(totalSleepMillis) + "ms");
display.drawString(128, 30, String(totalSleepMAh, 6) + "mAh");
display.drawString(128, 40, String(forecastBat) + "d");
display.drawString(128, 54, getStateText(deviceState));
display.display();
Wire.begin(D3, D4);
lastScreenUpdateMillis = millis();
}
}
| [
"dani.eichhorn@squix.ch"
] | dani.eichhorn@squix.ch |
05658131092ccd0901ace44a2736c57c44ca8540 | ae1aa3cc06ed670e501a625ff688a4cc24d86b5f | /PreContest/SDK-gcc/cdn/deploy.cpp | 9be2993282be173d0d1d8d3b8338b761e35b375e | [] | no_license | maxluck518/hw_codecraft2017 | 70ae33bd78eacfb02e2436b9e9f0bc1b4fcfd10c | 6b7594830e48a692d93f174de71cd8155e0ee4a2 | refs/heads/master | 2021-03-27T18:52:54.779398 | 2017-07-29T02:51:58 | 2017-07-29T02:51:58 | 98,703,786 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,783 | cpp | /*
* *************************************************************************
* HuaWei Code
*
* *************************************************************************
*/
#include "deploy.h"
/* ********************** generic ************************** */
float GA_ELITRATE = 0.05;
float GA_MUTATIONRATE = 0.95;
int GA_POPSIZE = 90;
/* ********************** hanming ************************** */
float HanMingDis = 0.9;
int PopInitRate = 10;
/* ********************** time_limit ************************** */
int TIME_LIMIT = 85;
/* ********************** control ************************** */
int GA_TARSIZE = 0;
int is_first_calcu = 1;
void topo_init(char * topo[MAX_EDGE_NUM],int line_num,MCMF * cdn,MCFS * qiwei){
int pNum[line_num][4];
int tmp = 0;
int k = 0;
for(int i = 0;i < line_num;i++)
for(int j = 0;j < (int)strlen(topo[i]);j++)
if(topo[i][j] == '\r' || topo[i][j] == '\n'){
pNum[i][k++]= tmp;
tmp = 0;
k = 0;
break;
}
else if(topo[i][j] != ' ')
tmp = tmp * 10 + (int)(topo[i][j] - 48);
else{
pNum[i][k++]= tmp;
tmp = 0;
}
/* create cdn graph */
/*
* case 0: get edge_num,cus_num,net_num 0
* case 1: get server cost 2
* case 2: get edge 4~3+edge_num
* case 3: get customer 5+edge_num ~ 4+edge_num+cus_num
* start[4] = {0,2,4,5+edge_num}
* end[4] = {0,2,4+edge_num,5+edge_num+cus_num}
*/
/* case 0 */
int net_num = pNum[0][0];
int edge_num = pNum[0][1];
int cus_num = pNum[0][2];
cdn->init(net_num + 2);
cdn->s = net_num;
cdn->t = net_num +1;
/* case 1 */
int server_cost = pNum[2][0];
cdn->server_cost = server_cost;
/* case 2,3 pre */
int start[4] = {0,2,4,-1};
int end[4] = {0,2,-1,-1};
start[3] = 5 + edge_num;
end[2] = 4 + edge_num;
end[3] = 5 + edge_num + cus_num;
/* case 2 */
NSarc *NSarc;
for( NSarc = qiwei->arc_array_begin ; NSarc != qiwei->arc_array_end ; NSarc++ )
{
if(NSarc->flow!=0)
{
int from=(NSarc->from)-(qiwei->node_array_begin);
int to=(NSarc->to)-(qiwei->node_array_begin);
int flow=NSarc->flow;
int cost=NSarc->cost;
// cout<<"wei from="<<from<<" to="<<to<<" flow="<<flow<<" cost="<<cost<<endl;
// cout<<endl;
if(to == cdn->s)
cdn->AddSuperS(to);
else
cdn->AddEdge(from,to,flow,cost);
}
}
/* case 3 */
for(int i = start[3];i < end[3];i++){
cdn->AddSuperT(pNum[i][1],pNum[i][2]);
cdn->SaveCustomer(pNum[i][0],pNum[i][1]);
}
}
void deploy_server(char * topo[MAX_EDGE_NUM], int line_num,char * filename)
{
char * topo_file = new char[MAX_EDGE_NUM](); MCMF *cdn = new MCMF;
MCFS *f_cdn = new MCFS;
/* ***************************************************************************** */
graph_init *clean_graph=new graph_init;
MCFS* qiwei=new MCFS;
qiwei->ReadData(topo,line_num,clean_graph);//读数据到graph中
GA_TARSIZE = clean_graph->G_n - 1;
/* *************************** Time Limit **************************** */
int TopoSize = 0;
if(GA_TARSIZE < 300)
TopoSize = 1;
else if(GA_TARSIZE < 700)
TopoSize = 2;
else
TopoSize = 3;
switch(TopoSize){
case 0:
break;
case 1:
// GA_ELITRATE = 0.05;
// GA_MUTATIONRATE = 0.95;
// GA_POPSIZE = 90;
// PopInitRate = 20;
// HanMingDis = 0.8;
TIME_LIMIT = 50;
break;
case 2:
// GA_ELITRATE = 0.05;
// GA_MUTATIONRATE = 0.95;
// GA_POPSIZE = 70;
// PopInitRate = 10;
// HanMingDis = 0.9;
TIME_LIMIT = 86;
break;
case 3:
// GA_ELITRATE = 0.05;
// GA_MUTATIONRATE = 0.95;
// GA_POPSIZE = 90;
// PopInitRate = 10;
// HanMingDis = 0.9;
TIME_LIMIT = 86;
break;
default:
break;
}
// cout << "GA_ELITRATE" << '\t' << "GA_MUTATIONRATE" << '\t' << "GA_POPSIZE" << '\t' << "PopInitRate" << '\t' << "HanMingDis" << '\t' << "TIME_LIMIT" << endl;
// cout << GA_ELITRATE << '\t' << GA_MUTATIONRATE << '\t' << GA_POPSIZE << '\t' << PopInitRate << '\t' << HanMingDis << '\t' << TIME_LIMIT << endl;
cout << "GA_ELITRATE" << '\t' << GA_ELITRATE << endl;
cout << "GA_MUTATIONRATE" << '\t' << GA_MUTATIONRATE << endl;
cout << "GA_POPSIZE" << '\t' << GA_POPSIZE << endl;
cout << "PopInitRate" << '\t' << PopInitRate << endl;
cout << "HanMingDis" << '\t' << HanMingDis << endl;
cout << "TIME_LIMIT" << '\t' << TIME_LIMIT << endl;
/* ***************************************************************************** */
int cost = INF;
if(Ga_For_MCF(f_cdn,clean_graph,topo_file)){
topo_init(topo,line_num,cdn,f_cdn);
cost = FinalMincost(cdn->s,cdn->t,cdn,topo_file);
}
cout << "The cost of spfa is :" << cost <<endl;
write_result(topo_file, filename);
delete cdn;
delete qiwei;
}
void InsertServer(MCMF * cdn,vector<int> server_id){
int n = server_id.size();
for(int i = 0;i < n;i++){
cdn->AddSuperS(server_id[i]);
}
}
bool BellmanFord(int s,int t,int &flow,int &cost,MCMF *cdn){
for(int i = 0;i < cdn->n;i++) cdn->d[i]=INF;
memset(cdn->inq,0,sizeof(cdn->inq));
cdn->d[s] = 0;
cdn->inq[s] = 1;
cdn->p[s] = 0;
cdn->a[s] = INF;
/* ******************* The min ******************* */
LinkQueue Q;
Q.init_Queue();
QElemType source = {cdn->s,0};
Q.en_Queue_Rear(source);
while(!Q.is_Empty()){
QElemType to = Q.GetTop();
Q.de_Queue();
int u = to.NetId;
cdn->inq[u] = 0;
int Gsize = (int)cdn->G[u].size();
for(int i = 0;i < Gsize;i++){
Edge& e = cdn->edges[cdn->G[u][i]];
if(e.cap > e.flow && cdn->d[e.to] > cdn->d[u] + e.cost){
cdn->a[e.to] = min(cdn->a[u],e.cap - e.flow);
cdn->d[e.to] = cdn->d[u] + e.cost;
cdn->p[e.to] = cdn->G[u][i];
if(!cdn->inq[e.to] && cdn->d[e.to] <= cdn->d[t]) {
QElemType q_in;
QElemType q_front;
q_in.NetId = e.to;
q_in.dist = cdn->d[e.to];
if(!Q.is_Empty()){
q_front = Q.GetTop();
if(abs(q_in.dist) > abs(q_front.dist)){
Q.en_Queue_Rear(q_in);
}
else{
Q.en_Queue_Top(q_in);
}
}
else{
Q.en_Queue_Rear(q_in);
}
cdn->inq[e.to] = 1;
}
}
if(cdn->d[t] == 0) break;
}
if(cdn->d[t] == 0) break;
}
/* ******************* The end ******************* */
if(cdn->d[t] == INF) return false;
int u = t;
while(u != s){
cdn->edges[cdn->p[u]].flow += cdn->a[t];
cdn->edges[cdn->p[u]^1].flow -= cdn->a[t];
cdn->edge_check(&cdn->edges[cdn->p[u]]);
cdn->edge_check(&cdn->edges[cdn->p[u]^1]);
u = cdn->edges[cdn->p[u]].from;
/* update the new cost 0 for an fixed server */
if(cdn->edges[cdn->p[u]].from == s){
/* update flow and cost in this turn */
flow += cdn->a[t];
cost += cdn->d[t] * cdn->a[t];
/* ***************************************** */
}
/* ***************************************** */
}
return true;
}
void CompTrace(MCMF *cdn,char *trace){ // for the output of trace
int s = cdn->s;
int t = cdn->t;
int u = t;
stack<int> tmp_trace;
tmp_trace.push(u);
while(u != s){
u = cdn->edges[cdn->p[u]].from;
tmp_trace.push(u);
}
char *str = new char[MAX]();
int record = -1;
while(!tmp_trace.empty()){
u = tmp_trace.top();
tmp_trace.pop();
if(u != s && u != t){
sprintf(str,"%d",u);
if(record == -1){
sprintf(trace,"%s%s",trace,str);
}
else{
sprintf(trace,"%s%s%s",trace," ",str);
}
record = u;
}
}
/* save the customer num. and added flow in this turn. */
sprintf(str,"%d",cdn->cus[record]);
sprintf(trace,"%s%s%s",trace," ",str);
sprintf(str,"%d",cdn->a[t]);
sprintf(trace,"%s%s%s",trace," ",str);
/* *************************************************** */
delete[] str;
}
int FinalMincost(int s,int t,MCMF *cdn,char *output){
int flow = 0,cost = 0;
int n = 0;
char * ttmp = new char[MAX_EDGE_NUM]();
char * trace = new char[MAX]();
char * str = new char[MAX]();
while(BellmanFord(s,t,flow,cost,cdn))
{
CompTrace(cdn,trace);
n++;
sprintf(ttmp,"%s%s%s",ttmp,"\n",trace);
memset(trace,0,sizeof(*trace));
}
/* compute server cost first */
cost += (cdn->G[s]).size() * cdn->server_cost;
/* **************************** */
/* check the correctness of the flow */
if(!cdn->FlowCheck(flow))
cost = INF;
/* ******************************* */
sprintf(str,"%d",n);
sprintf(output,"%s%s%s%s",str,"\n",ttmp,"\0");
delete ttmp;
delete[] trace;
delete[] str;
return cost;
}
inspire_interface MFCSolver(MCFS *cdn,vector<int> server,graph_init* clean_graph){
graph_init tmp = *clean_graph;
graph_init *dirt_graph = &tmp;
inspire_interface result;
result.server_list=server;
cdn->Add_Super_Arc(server,dirt_graph); //加server到graph中 junwei need
cdn->InitNet(dirt_graph); //用graph初始化MCFS
cdn->qiwei_solve(&result);
return result;
}
/* ********************************************************************************** */
/*
* genetic algorithm defination
*/
ga_struct init_key_serevr(graph_init *clean_graph){
ga_struct citizen;
vector<int> ::iterator it;
citizen.serverNum = 0;
citizen.fitness = 0;
citizen.server_id.clear();
citizen.server.erase();
for(int i=0; i<clean_graph->G_n-1; i++)
{
if(clean_graph->Deficit[i]!=0)
{
citizen.server_id.push_back(i);
citizen.serverNum ++;
}
}
for(int k =0;k<GA_TARSIZE;k++)
citizen.server += '0';
for(it = citizen.server_id.begin();it != citizen.server_id.end();it++)
citizen.server[*it] = '1';
cout << "*******************" << endl;
cout << citizen.server << endl;
cout << "*******************" << endl;
return citizen;
}
ga_struct init_key_serevr2(graph_init *clean_graph){
ga_struct citizen;
vector<int> ::iterator it;
citizen.serverNum = 0;
citizen.fitness = 0;
citizen.server_id.clear();
citizen.server.erase();
for(int i=0; i<clean_graph->G_n-1; i++)
{
if(clean_graph->Deficit[i]==0)
{
citizen.server_id.push_back(i);
citizen.serverNum ++;
}
}
for(int k =0;k<GA_TARSIZE;k++)
citizen.server += '0';
for(it = citizen.server_id.begin();it != citizen.server_id.end();it++)
citizen.server[*it] = '1';
cout << "*******************" << endl;
cout << citizen.server << endl;
cout << "*******************" << endl;
return citizen;
}
ga_struct init_key_serevr3(graph_init *clean_graph,int rate){
ga_struct citizen;
vector<int> ::iterator it;
citizen.serverNum = 0;
citizen.fitness = 0;
citizen.server_id.clear();
citizen.server.erase();
for(int i=0; i<clean_graph->G_n-1; i++)
{
if(clean_graph->Deficit[i]!=0)
{
if(rand()%100 < rate){
citizen.server_id.push_back(i);
citizen.serverNum ++;
}
}
}
for(int k =0;k<GA_TARSIZE;k++)
citizen.server += '0';
for(it = citizen.server_id.begin();it != citizen.server_id.end();it++)
citizen.server[*it] = '1';
cout << "*******************" << endl;
cout << citizen.server << endl;
cout << "*******************" << endl;
return citizen;
}
// void init_population(ga_vector &population, ga_vector &buffer,graph_init *clean_graph)
// {
// int tsize = GA_TARSIZE;
// population.push_back(init_key_serevr(clean_graph));
// for (int i=1; i<GA_POPSIZE; i++) {
// ga_struct citizen;
// citizen.serverNum = 0;
// citizen.fitness = 0;
// citizen.server_id.clear();
// citizen.server.erase();
// for (int j=0; j<tsize; j++){
// citizen.server += ((1+rand()%100) > 50)?'1':'0';
// if(citizen.server[j]=='1'){
// citizen.serverNum++;
// citizen.server_id.push_back(j);
// }
// }
// population.push_back(citizen);
// }
// buffer.resize(GA_POPSIZE);
// }
bool init_population(ga_vector &population, ga_vector &buffer,graph_init *clean_graph)
{
int tsize = GA_TARSIZE;
// 首选在所有的client进行布点
population.push_back(init_key_serevr(clean_graph));
population.push_back(init_key_serevr2(clean_graph));
population.push_back(init_key_serevr3(clean_graph,85));
population.push_back(init_key_serevr3(clean_graph,95));
population.push_back(init_key_serevr3(clean_graph,90));
int count = 0;
for (int i=5; i<GA_POPSIZE; i++) {
count ++;
ga_struct citizen;
citizen.serverNum = 0;
citizen.fitness = 0;
citizen.server_id.clear();
citizen.server.erase();
for (int j=0; j<tsize; j++){
citizen.server += ((1+rand()%100) > PopInitRate)?'1':'0';
if(citizen.server[j]=='1'){
citizen.serverNum++;
citizen.server_id.push_back(j);
}
}
if (hanMing(population,citizen)){
population.push_back(citizen);
}
else
i--;
if(count > 500)
return false;
}
// cout << "The count is : " << count << endl;
buffer.resize(GA_POPSIZE);
return true;
}
//如果相同字符个数大于长度的一半,则不采用,return false
bool hanMing(ga_vector population, ga_struct citizen)
{
int tsize = GA_TARSIZE;
for (int i=0;i<population.size();i++){
if (hanMingDis(population[i],citizen) > tsize * HanMingDis)
return false;
}
return true;
}
//返回字符相同的个数
int hanMingDis(ga_struct popu_citizen,ga_struct citizen)
{
int tsize = GA_TARSIZE;
int count = 0;
for (int i=0;i<tsize;i++){
if (popu_citizen.server[i] == citizen.server[i])
count += 1;
}
return count;
}
inline void calc_fitness(ga_vector &population,graph_init *clean_graph)
{
int esize = 0;
/* ******* elite population need not to calculate conce more ******* */
if(is_first_calcu){
esize = 0;
is_first_calcu = 0;
}
else
esize = GA_POPSIZE * GA_ELITRATE;
/* ************************************************************************ */
for (int i=esize; i<GA_POPSIZE; i++) {
MCFS* cdn=new MCFS;
inspire_interface result = MFCSolver(cdn,population[i].server_id,clean_graph);
cdn->DAlloc();
delete cdn;
if(result.link_cost == INF)
population[i].fitness = INF;
else{
population[i].fitness = result.link_cost + result.server_used.size()*clean_graph->server_cost;
population[i].server_id = result.server_used;
population[i].serverNum = result.server_used.size();
// cout <<"link.cost is : "<< result.link_cost << endl;
// cout <<"size is : "<< result.server_used.size() << endl;
// cout <<"server_cost is : "<< clean_graph->server_cost << endl;
// cout << "The cost is : "<<population[i].fitness << endl;
vector<int> ::iterator it;
for(int k =0;k<GA_TARSIZE;k++)
population[i].server[k] = '0';
for(it = population[i].server_id.begin();it != population[i].server_id.end();it++)
population[i].server[*it] = '1';
}
}
}
inline bool fitness_sort(ga_struct x, ga_struct y) {
return (x.fitness < y.fitness);
}
inline void sort_by_fitness(ga_vector &population){
sort(population.begin(), population.end(), fitness_sort);
}
void elitism(ga_vector &population, ga_vector &buffer, int esize ){
for (int i=0; i<esize; i++) {
buffer[i].serverNum = population[i].serverNum;
buffer[i].server = population[i].server;
buffer[i].fitness = population[i].fitness;
buffer[i].server_id = population[i].server_id;
}
}
inline void mutate(ga_struct &member){
int tsize = GA_TARSIZE;
int ipos = rand() % tsize;
if(member.server[ipos]=='1') member.server[ipos] = '0';
else member.server[ipos] = '1';
}
int SetParent(ga_vector &population){
int TotalFitness = 0;
int EachFitnes[GA_POPSIZE/2];
int cnt;
for(int i = 0;i < GA_POPSIZE/2;i++){
// cout << "*************************: "<< i << " : " <<population[i].fitness << endl;
EachFitnes[i] = INF/population[i].fitness;
TotalFitness += EachFitnes[i];
}
int dRange = rand() % TotalFitness;
int dCursor = 0;
for(cnt = 0;cnt < GA_POPSIZE/2;cnt++){
dCursor += EachFitnes[cnt];
if(dCursor > dRange)
break;
}
return cnt;
}
void mate(ga_vector &population, ga_vector &buffer){
int esize = GA_POPSIZE * GA_ELITRATE;
int tsize = GA_TARSIZE, spos, i1, i2;
elitism(population, buffer, esize);
for (int i=esize; i<GA_POPSIZE; i++) {
/* *********************** seclection *********************** */
// i1 = rand() % (GA_POPSIZE / 2);
// i2 = rand() % (GA_POPSIZE / 2);
i1 = SetParent(population);
i2 = SetParent(population);
// cout << i1 << endl;
// cout << i2 << endl;
/* *********************** end *********************** */
/* *********************** crossover *********************** */
spos = rand() % tsize;
buffer[i].server.erase();
buffer[i].server = population[i1].server.substr(0, spos) +
population[i2].server.substr(spos, tsize - spos);
/* *********************** end *********************** */
// muntrace();
if (rand() < GA_MUTATION) mutate(buffer[i]);
buffer[i].server_id.clear();
buffer[i].serverNum = 0;
for (int j = 0; j < tsize; ++j)
if(buffer[i].server[j]=='1'){
buffer[i].serverNum++;
buffer[i].server_id.push_back(j);
}
}
}
inline void print_best(ga_vector &gav)
{ cout << "Best: " << gav[0].server << " (" << gav[0].fitness << ")" << endl; }
inline void swap(ga_vector *&population, ga_vector *&buffer){
ga_vector *temp = population; population = buffer; buffer = temp;
}
/* ********************************************************************************** */
/* *************************** main solver ************************************ */
bool Ga_For_MCF(MCFS * f_cdn,graph_init * clean_graph,char * output){
srand(unsigned(time(NULL)));
time_t begin,end;
ga_vector pop_alpha, pop_beta;
ga_vector *population, *buffer;
if(!init_population(pop_alpha, pop_beta,clean_graph)){
// cout << "The init of population failed!" << endl;
return false;
}
population = &pop_alpha;
buffer = &pop_beta;
begin = time(NULL);
for (int i=0; i<GA_MAXITER; i++) {
calc_fitness(*population,clean_graph); // calculate fitness
sort_by_fitness(*population); // sort them
mate(*population, *buffer); // mate the population together
swap(population, buffer); // swap buffers
end = time(NULL);
if(end - begin > TIME_LIMIT){
break;
cout << "The loop num. is : " << i << endl;
}
print_best(*population);
cout << "The time of this turn is : "<< end - begin << endl;
}
print_best(*population);
inspire_interface result;
result = MFCSolver(f_cdn,pop_alpha[0].server_id,clean_graph);
return true;
}
/* ********************************************************************************** */
| [
"msql518@gmail.com"
] | msql518@gmail.com |
f33d2df5c0df0bb692ae767c5702ae7840335835 | d385df4dd22a0484359b39d17ba6a347a6ee45a5 | /src/HAC/Hac4.h | 3cd6791b4b6215f2cc9c6d96d36047f8c7708fa4 | [] | no_license | Sunday0/CMGameEngine | 9703840d4e728050c4f38459287b2128fed93db3 | 36a8c4146fe6598a407af2901605fb22b5327944 | refs/heads/master | 2020-03-11T17:22:30.625990 | 2016-01-25T07:23:09 | 2016-01-25T07:23:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,144 | h | #ifndef HAC4_INCLUDE
#define HAC4_INCLUDE
#include"HacTemplate.h"
#include<hgl/Compress.h>
#include<hgl/ut/Hash.h>
namespace hgl
{
namespace io
{
class InputStream;
class DataInputStream;
}//namespace io
struct Hac4File
{
UTF16String FileName; ///<文件名
UTF16String CompressName; ///<压缩算法
uint64 FileSize; ///<文件长度
uint64 CompressSize; ///<压缩后大小
MD5Code md5; ///<文件MD5校验码
uint64 Offset; ///<数据在包中的偏移量
};//struct Hac4File
class HAC4:public HacTemplate<Hac4File>
{
uint64 TotalSize;
io::DataInputStream *stream;
void LoadFolder(io::DataInputStream *,HacFolder<Hac4File> *);
public:
HAC4(io::DataInputStream *);
~HAC4();
bool LoadFilePart(void *,uint,uint,void *); ///<加载一个文件的一部分
io::InputStream *LoadFileFrom(void *,const UTF16String &,bool=false); ///<加载一个文件到内存流
bool LoadFileFrom(void *,const UTF16String &,void **,int *); ///<加载一个文件到指定内存块
};//class HAC4
}//namespace hgl
#endif//HAC4_INCLUDE
| [
"devnull@localhost"
] | devnull@localhost |
20c58a3d446b66ec49ffcf125dd19dc5d21b6eaa | 5950c4973a1862d2b67e072deeea8f4188d23d97 | /Export/macos/obj/src/lime/app/_Event_ofEvents_T_Void.cpp | b5380309da5784e0307be91f5546aadceb989c49 | [
"MIT"
] | permissive | TrilateralX/TrilateralLimeTriangle | b3cc0283cd3745b57ccc9131fcc9b81427414718 | 219d8e54fc3861dc1ffeb3da25da6eda349847c1 | refs/heads/master | 2022-10-26T11:51:28.578254 | 2020-06-16T12:32:35 | 2020-06-16T12:32:35 | 272,572,760 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 11,027 | cpp | // Generated by Haxe 4.2.0-rc.1+cb30bd580
#include <hxcpp.h>
#ifndef INCLUDED_Reflect
#include <Reflect.h>
#endif
#ifndef INCLUDED_lime_app__Event_ofEvents_T_Void
#include <lime/app/_Event_ofEvents_T_Void.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_602a5331235d55ea_42_new,"lime.app._Event_ofEvents_T_Void","new",0xde11e822,"lime.app._Event_ofEvents_T_Void.new","lime/app/Event.hx",42,0xbda45bec)
HX_LOCAL_STACK_FRAME(_hx_pos_602a5331235d55ea_58_add,"lime.app._Event_ofEvents_T_Void","add",0xde0809e3,"lime.app._Event_ofEvents_T_Void.add","lime/app/Event.hx",58,0xbda45bec)
HX_LOCAL_STACK_FRAME(_hx_pos_602a5331235d55ea_82_cancel,"lime.app._Event_ofEvents_T_Void","cancel",0x39599af8,"lime.app._Event_ofEvents_T_Void.cancel","lime/app/Event.hx",82,0xbda45bec)
HX_LOCAL_STACK_FRAME(_hx_pos_602a5331235d55ea_127_has,"lime.app._Event_ofEvents_T_Void","has",0xde0d571c,"lime.app._Event_ofEvents_T_Void.has","lime/app/Event.hx",127,0xbda45bec)
HX_LOCAL_STACK_FRAME(_hx_pos_602a5331235d55ea_143_remove,"lime.app._Event_ofEvents_T_Void","remove",0x85ae49c2,"lime.app._Event_ofEvents_T_Void.remove","lime/app/Event.hx",143,0xbda45bec)
HX_LOCAL_STACK_FRAME(_hx_pos_89c82c0cd6a35496_82_dispatch,"lime.app._Event_ofEvents_T_Void","dispatch",0x766e57b8,"lime.app._Event_ofEvents_T_Void.dispatch","lime/_internal/macros/EventMacro.hx",82,0xc5a10671)
namespace lime{
namespace app{
void _Event_ofEvents_T_Void_obj::__construct(){
HX_STACKFRAME(&_hx_pos_602a5331235d55ea_42_new)
HXLINE( 44) this->canceled = false;
HXLINE( 45) this->_hx___listeners = ::Array_obj< ::Dynamic>::__new();
HXLINE( 46) this->_hx___priorities = ::Array_obj< int >::__new();
HXLINE( 47) this->_hx___repeat = ::Array_obj< bool >::__new();
}
Dynamic _Event_ofEvents_T_Void_obj::__CreateEmpty() { return new _Event_ofEvents_T_Void_obj; }
void *_Event_ofEvents_T_Void_obj::_hx_vtable = 0;
Dynamic _Event_ofEvents_T_Void_obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< _Event_ofEvents_T_Void_obj > _hx_result = new _Event_ofEvents_T_Void_obj();
_hx_result->__construct();
return _hx_result;
}
bool _Event_ofEvents_T_Void_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x2d049712;
}
void _Event_ofEvents_T_Void_obj::add( ::Dynamic listener,::hx::Null< bool > __o_once,::hx::Null< int > __o_priority){
bool once = __o_once.Default(false);
int priority = __o_priority.Default(0);
HX_STACKFRAME(&_hx_pos_602a5331235d55ea_58_add)
HXLINE( 60) {
HXLINE( 60) int _g = 0;
HXDLIN( 60) int _g1 = this->_hx___priorities->length;
HXDLIN( 60) while((_g < _g1)){
HXLINE( 60) _g = (_g + 1);
HXDLIN( 60) int i = (_g - 1);
HXLINE( 62) if ((priority > this->_hx___priorities->__get(i))) {
HXLINE( 64) this->_hx___listeners->insert(i,listener);
HXLINE( 65) this->_hx___priorities->insert(i,priority);
HXLINE( 66) this->_hx___repeat->insert(i,!(once));
HXLINE( 67) return;
}
}
}
HXLINE( 71) this->_hx___listeners->push(listener);
HXLINE( 72) this->_hx___priorities->push(priority);
HXLINE( 73) this->_hx___repeat->push(!(once));
}
HX_DEFINE_DYNAMIC_FUNC3(_Event_ofEvents_T_Void_obj,add,(void))
void _Event_ofEvents_T_Void_obj::cancel(){
HX_STACKFRAME(&_hx_pos_602a5331235d55ea_82_cancel)
HXDLIN( 82) this->canceled = true;
}
HX_DEFINE_DYNAMIC_FUNC0(_Event_ofEvents_T_Void_obj,cancel,(void))
bool _Event_ofEvents_T_Void_obj::has( ::Dynamic listener){
HX_STACKFRAME(&_hx_pos_602a5331235d55ea_127_has)
HXLINE( 129) {
HXLINE( 129) int _g = 0;
HXDLIN( 129) ::Array< ::Dynamic> _g1 = this->_hx___listeners;
HXDLIN( 129) while((_g < _g1->length)){
HXLINE( 129) ::Dynamic l = _g1->__get(_g);
HXDLIN( 129) _g = (_g + 1);
HXLINE( 131) if (::Reflect_obj::compareMethods(l,listener)) {
HXLINE( 131) return true;
}
}
}
HXLINE( 135) return false;
}
HX_DEFINE_DYNAMIC_FUNC1(_Event_ofEvents_T_Void_obj,has,return )
void _Event_ofEvents_T_Void_obj::remove( ::Dynamic listener){
HX_STACKFRAME(&_hx_pos_602a5331235d55ea_143_remove)
HXLINE( 145) int i = this->_hx___listeners->length;
HXLINE( 147) while(true){
HXLINE( 147) i = (i - 1);
HXDLIN( 147) if (!((i >= 0))) {
HXLINE( 147) goto _hx_goto_6;
}
HXLINE( 149) if (::Reflect_obj::compareMethods(this->_hx___listeners->__get(i),listener)) {
HXLINE( 151) this->_hx___listeners->removeRange(i,1);
HXLINE( 152) this->_hx___priorities->removeRange(i,1);
HXLINE( 153) this->_hx___repeat->removeRange(i,1);
}
}
_hx_goto_6:;
}
HX_DEFINE_DYNAMIC_FUNC1(_Event_ofEvents_T_Void_obj,remove,(void))
void _Event_ofEvents_T_Void_obj::dispatch( ::Dynamic a){
HX_STACKFRAME(&_hx_pos_89c82c0cd6a35496_82_dispatch)
HXLINE( 83) this->canceled = false;
HXLINE( 85) ::Array< ::Dynamic> listeners = this->_hx___listeners;
HXLINE( 86) ::Array< bool > repeat = this->_hx___repeat;
HXLINE( 87) int i = 0;
HXLINE( 89) while((i < listeners->length)){
HXLINE( 91) listeners->__get(i)(a);
HXLINE( 93) if (!(repeat->__get(i))) {
HXLINE( 95) this->remove(listeners->__get(i));
}
else {
HXLINE( 99) i = (i + 1);
}
HXLINE( 102) if (this->canceled) {
HXLINE( 104) goto _hx_goto_8;
}
}
_hx_goto_8:;
}
HX_DEFINE_DYNAMIC_FUNC1(_Event_ofEvents_T_Void_obj,dispatch,(void))
::hx::ObjectPtr< _Event_ofEvents_T_Void_obj > _Event_ofEvents_T_Void_obj::__new() {
::hx::ObjectPtr< _Event_ofEvents_T_Void_obj > __this = new _Event_ofEvents_T_Void_obj();
__this->__construct();
return __this;
}
::hx::ObjectPtr< _Event_ofEvents_T_Void_obj > _Event_ofEvents_T_Void_obj::__alloc(::hx::Ctx *_hx_ctx) {
_Event_ofEvents_T_Void_obj *__this = (_Event_ofEvents_T_Void_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(_Event_ofEvents_T_Void_obj), true, "lime.app._Event_ofEvents_T_Void"));
*(void **)__this = _Event_ofEvents_T_Void_obj::_hx_vtable;
__this->__construct();
return __this;
}
_Event_ofEvents_T_Void_obj::_Event_ofEvents_T_Void_obj()
{
}
void _Event_ofEvents_T_Void_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(_Event_ofEvents_T_Void);
HX_MARK_MEMBER_NAME(canceled,"canceled");
HX_MARK_MEMBER_NAME(_hx___repeat,"__repeat");
HX_MARK_MEMBER_NAME(_hx___priorities,"__priorities");
HX_MARK_MEMBER_NAME(_hx___listeners,"__listeners");
HX_MARK_END_CLASS();
}
void _Event_ofEvents_T_Void_obj::__Visit(HX_VISIT_PARAMS)
{
HX_VISIT_MEMBER_NAME(canceled,"canceled");
HX_VISIT_MEMBER_NAME(_hx___repeat,"__repeat");
HX_VISIT_MEMBER_NAME(_hx___priorities,"__priorities");
HX_VISIT_MEMBER_NAME(_hx___listeners,"__listeners");
}
::hx::Val _Event_ofEvents_T_Void_obj::__Field(const ::String &inName,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 3:
if (HX_FIELD_EQ(inName,"add") ) { return ::hx::Val( add_dyn() ); }
if (HX_FIELD_EQ(inName,"has") ) { return ::hx::Val( has_dyn() ); }
break;
case 6:
if (HX_FIELD_EQ(inName,"cancel") ) { return ::hx::Val( cancel_dyn() ); }
if (HX_FIELD_EQ(inName,"remove") ) { return ::hx::Val( remove_dyn() ); }
break;
case 8:
if (HX_FIELD_EQ(inName,"canceled") ) { return ::hx::Val( canceled ); }
if (HX_FIELD_EQ(inName,"__repeat") ) { return ::hx::Val( _hx___repeat ); }
if (HX_FIELD_EQ(inName,"dispatch") ) { return ::hx::Val( dispatch_dyn() ); }
break;
case 11:
if (HX_FIELD_EQ(inName,"__listeners") ) { return ::hx::Val( _hx___listeners ); }
break;
case 12:
if (HX_FIELD_EQ(inName,"__priorities") ) { return ::hx::Val( _hx___priorities ); }
}
return super::__Field(inName,inCallProp);
}
::hx::Val _Event_ofEvents_T_Void_obj::__SetField(const ::String &inName,const ::hx::Val &inValue,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 8:
if (HX_FIELD_EQ(inName,"canceled") ) { canceled=inValue.Cast< bool >(); return inValue; }
if (HX_FIELD_EQ(inName,"__repeat") ) { _hx___repeat=inValue.Cast< ::Array< bool > >(); return inValue; }
break;
case 11:
if (HX_FIELD_EQ(inName,"__listeners") ) { _hx___listeners=inValue.Cast< ::Array< ::Dynamic> >(); return inValue; }
break;
case 12:
if (HX_FIELD_EQ(inName,"__priorities") ) { _hx___priorities=inValue.Cast< ::Array< int > >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void _Event_ofEvents_T_Void_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_("canceled",59,18,26,1f));
outFields->push(HX_("__repeat",7b,02,ac,ae));
outFields->push(HX_("__priorities",e2,cb,e6,1c));
outFields->push(HX_("__listeners",5f,ae,ba,21));
super::__GetFields(outFields);
};
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo _Event_ofEvents_T_Void_obj_sMemberStorageInfo[] = {
{::hx::fsBool,(int)offsetof(_Event_ofEvents_T_Void_obj,canceled),HX_("canceled",59,18,26,1f)},
{::hx::fsObject /* ::Array< bool > */ ,(int)offsetof(_Event_ofEvents_T_Void_obj,_hx___repeat),HX_("__repeat",7b,02,ac,ae)},
{::hx::fsObject /* ::Array< int > */ ,(int)offsetof(_Event_ofEvents_T_Void_obj,_hx___priorities),HX_("__priorities",e2,cb,e6,1c)},
{::hx::fsObject /* ::Array< ::Dynamic> */ ,(int)offsetof(_Event_ofEvents_T_Void_obj,_hx___listeners),HX_("__listeners",5f,ae,ba,21)},
{ ::hx::fsUnknown, 0, null()}
};
static ::hx::StaticInfo *_Event_ofEvents_T_Void_obj_sStaticStorageInfo = 0;
#endif
static ::String _Event_ofEvents_T_Void_obj_sMemberFields[] = {
HX_("canceled",59,18,26,1f),
HX_("__repeat",7b,02,ac,ae),
HX_("__priorities",e2,cb,e6,1c),
HX_("add",21,f2,49,00),
HX_("cancel",7a,ed,33,b8),
HX_("has",5a,3f,4f,00),
HX_("remove",44,9c,88,04),
HX_("__listeners",5f,ae,ba,21),
HX_("dispatch",ba,ce,63,1e),
::String(null()) };
::hx::Class _Event_ofEvents_T_Void_obj::__mClass;
void _Event_ofEvents_T_Void_obj::__register()
{
_Event_ofEvents_T_Void_obj _hx_dummy;
_Event_ofEvents_T_Void_obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("lime.app._Event_ofEvents_T_Void",30,ef,76,e4);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &::hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(_Event_ofEvents_T_Void_obj_sMemberFields);
__mClass->mCanCast = ::hx::TCanCast< _Event_ofEvents_T_Void_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = _Event_ofEvents_T_Void_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = _Event_ofEvents_T_Void_obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace lime
} // end namespace app
| [
"none"
] | none |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.