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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b820dde45cf4236704686c4f45893c5d433ead37 | c7a771dc8763f5f8803385ec0830d2fe484fcf88 | /utility/MsgQueue.hpp | 198aba34af7a9d37ba9e07e8d2b024f6e0c74f41 | [] | no_license | aralehuan/QtDemo | 1af39465be372e9d7f835ec6fd3a80ab2250d8ad | 79a619661cb37546717e39989e693940e1a2fe25 | refs/heads/master | 2021-05-26T00:58:29.152006 | 2020-06-11T10:44:41 | 2020-06-11T10:44:41 | 253,991,323 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,719 | hpp | #ifndef _MSG_QUEUE_H_
#define _MSG_QUEUE_H_
#include "concurrentqueue.h"
#define MSG_MAX_LEN 65535
/*
消息包队列(先进先出)
支持多线程
lixiaoming 2020-02-04
*/
class MsgQueue
{
public:
struct Item
{
int type;
uint16_t len;
void* data = nullptr;
size_t offset;
~Item()
{
if (data)
free(data);
}
};
public:
~MsgQueue()
{
exit = true;
}
void Exit()
{
exit=true;
}
//写入1条消息
bool Push(int type, uint16_t len, const void* data, size_t dataoffset)
{
auto item = new Item;
if (!item)
{
printf("alloc failed\n");
return false;
}
item->offset = dataoffset/(1024*1024);
item->type = type;
item->len = len;
item->data = malloc(len);
if (!item->data)
goto FAILED;
memcpy(item->data, data, len);
while (!mItemQueue.enqueue(item) && (!exit));
return true;
FAILED:
if (item)
delete item;
return false;
}
//读取一定数量的消息
//返回值:消息数量
size_t Pop(Item** ppItem, size_t nItemMaxNum)
{
auto nItemNum = mItemQueue.try_dequeue_bulk(ppItem, nItemMaxNum);
return nItemNum;
}
//释放消息内存
void Free(Item** ppItem, size_t nItemNum)
{
for (size_t i = 0; i < nItemNum; ++i)
delete ppItem[i];
}
protected:
bool exit=false;
struct MyTraits : public moodycamel::ConcurrentQueueDefaultTraits
{
static const size_t BLOCK_SIZE = 256;//每次分配一块内存,内存可以存放BLOCK_SIZE个元素
static const size_t MAX_SUBQUEUE_SIZE = 512*1024;//总共存多少元素,实际数量为(MAX_SUBQUEUE_SIZE+BLOCK_SIZE-1)/BLOCK_SIZE*BLOCK_SIZE;即整数个BLOCK_SIZE
};
moodycamel::ConcurrentQueue<Item*, MyTraits> mItemQueue;
};
#endif
| [
"411635116@qq.com"
] | 411635116@qq.com |
e691de82570ec69293a0f4ccec8d311a9c5051d3 | fe2362eda423bb3574b651c21ebacbd6a1a9ac2a | /VTK-7.1.1/Views/Core/vtkDataRepresentation.cxx | bc3746092f4b461b34d9d4b4b89a62bb85fa672f | [
"BSD-3-Clause"
] | permissive | likewatchk/python-pcl | 1c09c6b3e9de0acbe2f88ac36a858fe4b27cfaaf | 2a66797719f1b5af7d6a0d0893f697b3786db461 | refs/heads/master | 2023-01-04T06:17:19.652585 | 2020-10-15T21:26:58 | 2020-10-15T21:26:58 | 262,235,188 | 0 | 0 | NOASSERTION | 2020-05-08T05:29:02 | 2020-05-08T05:29:01 | null | UTF-8 | C++ | false | false | 13,677 | cxx | /*=========================================================================
Program: Visualization Toolkit
Module: vtkDataRepresentation.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
#include "vtkDataRepresentation.h"
#include "vtkAlgorithmOutput.h"
#include "vtkAnnotationLayers.h"
#include "vtkAnnotationLink.h"
#include "vtkCommand.h"
#include "vtkConvertSelectionDomain.h"
#include "vtkDataObject.h"
#include "vtkDataSet.h"
#include "vtkDemandDrivenPipeline.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkSelection.h"
#include "vtkSelectionNode.h"
#include "vtkSmartPointer.h"
#include "vtkStringArray.h"
#include "vtkTrivialProducer.h"
#include <map>
//---------------------------------------------------------------------------
// vtkDataRepresentation::Internals
//---------------------------------------------------------------------------
class vtkDataRepresentation::Internals {
public:
// This is a cache of shallow copies of inputs provided for convenience.
// It is a map from (port index, connection index) to (original input data port, shallow copy port).
// NOTE: The original input data port pointer is not reference counted, so it should
// not be assumed to be a valid pointer. It is only used for pointer comparison.
std::map<std::pair<int, int>,
std::pair<vtkAlgorithmOutput*, vtkSmartPointer<vtkTrivialProducer> > >
InputInternal;
// This is a cache of vtkConvertSelectionDomain filters provided for convenience.
// It is a map from (port index, connection index) to convert selection domain filter.
std::map<std::pair<int, int>, vtkSmartPointer<vtkConvertSelectionDomain> >
ConvertDomainInternal;
};
//---------------------------------------------------------------------------
// vtkDataRepresentation::Command
//----------------------------------------------------------------------------
class vtkDataRepresentation::Command : public vtkCommand
{
public:
static Command* New() { return new Command(); }
void Execute(vtkObject *caller, unsigned long eventId,
void *callData) VTK_OVERRIDE
{
if (this->Target)
{
this->Target->ProcessEvents(caller, eventId, callData);
}
}
void SetTarget(vtkDataRepresentation* t)
{
this->Target = t;
}
private:
Command() { this->Target = 0; }
vtkDataRepresentation* Target;
};
//----------------------------------------------------------------------------
// vtkDataRepresentation
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkDataRepresentation);
vtkCxxSetObjectMacro(vtkDataRepresentation,
AnnotationLinkInternal, vtkAnnotationLink);
vtkCxxSetObjectMacro(vtkDataRepresentation, SelectionArrayNames, vtkStringArray);
//----------------------------------------------------------------------------
vtkTrivialProducer* vtkDataRepresentation::GetInternalInput(int port, int conn)
{
return this->Implementation->InputInternal[
std::pair<int, int>(port, conn)].second.GetPointer();
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::SetInternalInput(int port, int conn,
vtkTrivialProducer* producer)
{
this->Implementation->InputInternal[std::pair<int, int>(port, conn)] =
std::pair<vtkAlgorithmOutput*, vtkSmartPointer<vtkTrivialProducer> >(
this->GetInputConnection(port, conn), producer);
}
//----------------------------------------------------------------------------
vtkDataRepresentation::vtkDataRepresentation()
{
this->Implementation = new vtkDataRepresentation::Internals();
// Listen to event indicating that the algorithm is done executing.
// We may need to clear the data object cache after execution.
this->Observer = Command::New();
this->AddObserver(vtkCommand::EndEvent, this->Observer);
this->Selectable = true;
this->SelectionArrayNames = vtkStringArray::New();
this->SelectionType = vtkSelectionNode::INDICES;
this->AnnotationLinkInternal = vtkAnnotationLink::New();
this->SetNumberOfOutputPorts(0);
}
//----------------------------------------------------------------------------
vtkDataRepresentation::~vtkDataRepresentation()
{
delete this->Implementation;
this->Observer->Delete();
this->SetSelectionArrayNames(0);
this->SetAnnotationLinkInternal(0);
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::SetAnnotationLink(vtkAnnotationLink* link)
{
this->SetAnnotationLinkInternal(link);
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::ProcessEvents(vtkObject *caller, unsigned long eventId, void *vtkNotUsed(callData))
{
// After the algorithm executes, if the release data flag is on,
// clear the input shallow copy cache.
if (caller == this && eventId == vtkCommand::EndEvent)
{
// Release input data if requested.
for (int i = 0; i < this->GetNumberOfInputPorts(); ++i)
{
for (int j = 0; j < this->GetNumberOfInputConnections(i); ++j)
{
vtkInformation* inInfo = this->GetExecutive()->GetInputInformation(i, j);
vtkDataObject* dataObject = inInfo->Get(vtkDataObject::DATA_OBJECT());
if (dataObject && (dataObject->GetGlobalReleaseDataFlag() ||
inInfo->Get(vtkDemandDrivenPipeline::RELEASE_DATA())))
{
std::pair<int, int> p(i, j);
this->Implementation->InputInternal.erase(p);
this->Implementation->ConvertDomainInternal.erase(p);
}
}
}
}
}
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkDataRepresentation::GetInternalOutputPort(int port, int conn)
{
if (port >= this->GetNumberOfInputPorts() ||
conn >= this->GetNumberOfInputConnections(port))
{
vtkErrorMacro("Port " << port << ", connection "
<< conn << " is not defined on this representation.");
return 0;
}
// The cached shallow copy is out of date when the input data object
// changed, or the shallow copy modified time is less than the
// input modified time.
std::pair<int, int> p(port, conn);
vtkAlgorithmOutput* input = this->GetInputConnection(port, conn);
vtkDataObject* inputDObj = this->GetInputDataObject(port, conn);
if (this->Implementation->InputInternal.find(p) ==
this->Implementation->InputInternal.end() ||
this->Implementation->InputInternal[p].first != input ||
this->Implementation->InputInternal[p].second->GetMTime() < inputDObj->GetMTime())
{
this->Implementation->InputInternal[p].first = input;
vtkDataObject* copy = inputDObj->NewInstance();
copy->ShallowCopy(inputDObj);
vtkTrivialProducer* tp = vtkTrivialProducer::New();
tp->SetOutput(copy);
copy->Delete();
this->Implementation->InputInternal[p].second = tp;
tp->Delete();
}
return this->Implementation->InputInternal[p].second->GetOutputPort();
}
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkDataRepresentation::GetInternalAnnotationOutputPort(
int port, int conn)
{
if (port >= this->GetNumberOfInputPorts() ||
conn >= this->GetNumberOfInputConnections(port))
{
vtkErrorMacro("Port " << port << ", connection "
<< conn << " is not defined on this representation.");
return 0;
}
// Create a new filter in the cache if necessary.
std::pair<int, int> p(port, conn);
if (this->Implementation->ConvertDomainInternal.find(p) ==
this->Implementation->ConvertDomainInternal.end())
{
this->Implementation->ConvertDomainInternal[p] =
vtkSmartPointer<vtkConvertSelectionDomain>::New();
}
// Set up the inputs to the cached filter.
vtkConvertSelectionDomain* domain = this->Implementation->ConvertDomainInternal[p];
domain->SetInputConnection(0,
this->GetAnnotationLink()->GetOutputPort(0));
domain->SetInputConnection(1,
this->GetAnnotationLink()->GetOutputPort(1));
domain->SetInputConnection(2,
this->GetInternalOutputPort(port, conn));
// Output port 0 of the convert domain filter is the linked
// annotation(s) (the vtkAnnotationLayers object).
return domain->GetOutputPort();
}
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkDataRepresentation::GetInternalSelectionOutputPort(
int port, int conn)
{
// First make sure the convert domain filter is up to date.
if (!this->GetInternalAnnotationOutputPort(port, conn))
{
return 0;
}
// Output port 1 of the convert domain filter is the current selection
// that was contained in the linked annotation.
std::pair<int, int> p(port, conn);
if (this->Implementation->ConvertDomainInternal.find(p) !=
this->Implementation->ConvertDomainInternal.end())
{
return this->Implementation->ConvertDomainInternal[p]->GetOutputPort(1);
}
return NULL;
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::Select(
vtkView* view, vtkSelection* selection, bool extend)
{
if (this->Selectable)
{
vtkSelection* converted = this->ConvertSelection(view, selection);
if (converted)
{
this->UpdateSelection(converted, extend);
if (converted != selection)
{
converted->Delete();
}
}
}
}
//----------------------------------------------------------------------------
vtkSelection* vtkDataRepresentation::ConvertSelection(
vtkView* vtkNotUsed(view), vtkSelection* selection)
{
return selection;
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::UpdateSelection(vtkSelection* selection, bool extend)
{
if (extend)
{
selection->Union(this->AnnotationLinkInternal->GetCurrentSelection());
}
this->AnnotationLinkInternal->SetCurrentSelection(selection);
this->InvokeEvent(vtkCommand::SelectionChangedEvent, reinterpret_cast<void*>(selection));
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::Annotate(
vtkView* view, vtkAnnotationLayers* annotations, bool extend)
{
vtkAnnotationLayers* converted = this->ConvertAnnotations(view, annotations);
if (converted)
{
this->UpdateAnnotations(converted, extend);
if (converted != annotations)
{
converted->Delete();
}
}
}
//----------------------------------------------------------------------------
vtkAnnotationLayers* vtkDataRepresentation::ConvertAnnotations(
vtkView* vtkNotUsed(view), vtkAnnotationLayers* annotations)
{
return annotations;
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::UpdateAnnotations(vtkAnnotationLayers* annotations, bool extend)
{
if (extend)
{
// Append the annotations to the existing set of annotations on the link
vtkAnnotationLayers* currentAnnotations = this->AnnotationLinkInternal->GetAnnotationLayers();
for(unsigned int i=0; i<annotations->GetNumberOfAnnotations(); ++i)
{
currentAnnotations->AddAnnotation(annotations->GetAnnotation(i));
}
this->InvokeEvent(vtkCommand::AnnotationChangedEvent, reinterpret_cast<void*>(currentAnnotations));
}
else
{
this->AnnotationLinkInternal->SetAnnotationLayers(annotations);
this->InvokeEvent(vtkCommand::AnnotationChangedEvent, reinterpret_cast<void*>(annotations));
}
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::SetSelectionArrayName(const char* name)
{
if (!this->SelectionArrayNames)
{
this->SelectionArrayNames = vtkStringArray::New();
}
this->SelectionArrayNames->Initialize();
this->SelectionArrayNames->InsertNextValue(name);
}
//----------------------------------------------------------------------------
const char* vtkDataRepresentation::GetSelectionArrayName()
{
if (this->SelectionArrayNames &&
this->SelectionArrayNames->GetNumberOfTuples() > 0)
{
return this->SelectionArrayNames->GetValue(0);
}
return 0;
}
//----------------------------------------------------------------------------
void vtkDataRepresentation::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "AnnotationLink: " << (this->AnnotationLinkInternal ? "" : "(null)") << endl;
if (this->AnnotationLinkInternal)
{
this->AnnotationLinkInternal->PrintSelf(os, indent.GetNextIndent());
}
os << indent << "Selectable: " << this->Selectable << endl;
os << indent << "SelectionType: " << this->SelectionType << endl;
os << indent << "SelectionArrayNames: " << (this->SelectionArrayNames ? "" : "(null)") << endl;
if (this->SelectionArrayNames)
{
this->SelectionArrayNames->PrintSelf(os, indent.GetNextIndent());
}
}
| [
"likewatchk@gmail.com"
] | likewatchk@gmail.com |
ed7bc8e083c12884fded08dd6edf49f934cfca2a | aa049fc9c45ab0ee44a4f68ce456972fac36705f | /client/TxClient/withdraw.h | ad9aaab93dc28b5e8715752c2ad2626568ea6e71 | [] | no_license | yudi-matsuzake/tx | 3fca86912594a0a339d009ca561c93b9df6daef9 | 5cf42f096bff1ed228ab93011e0dc329601d708a | refs/heads/master | 2021-01-21T21:14:39.476972 | 2017-06-07T16:53:13 | 2017-06-07T16:53:13 | 92,320,591 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 400 | h | #ifndef WITHDRAW_H
#define WITHDRAW_H
#include <QString>
#include <QJsonObject>
class Withdraw
{
public:
Withdraw();
Withdraw(const int& account_id, const double& value, const QString& withdraw_method);
bool write(QJsonObject& json) const;
bool read(QJsonObject& json);
private:
static const QString JSON_TYPE;
int account_id;
double value;
QString withdraw_method;
};
#endif // WITHDRAW_H
| [
"paulor@alunos.utfpr.edu.br"
] | paulor@alunos.utfpr.edu.br |
e31be0253ab44b174f872e3a16544589c43267d5 | 529ffc32bdfb6779c36fac274096db5855c98ef7 | /binary search tree/find no of rotation by bs method.cpp | 8c005bcb164bf8e5ab9a46b11b60df1ae82c399f | [] | no_license | rajukumar2152/Dtastructure-Algorithm | c2bc7442ff36d5a9ca1d5298f8d1b1acc178f8b2 | 545a28aeba3be3495ec73b9c8876997b8ccb313d | refs/heads/master | 2023-07-08T15:39:12.168944 | 2021-08-05T19:59:41 | 2021-08-05T19:59:41 | 373,874,308 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 623 | cpp |
///raju kumar sahi chak raha hain
#include<iostream>
using namespace std;
int k ;
void binrysearch(int a[], int s, int e , int num ){
int mid = s+(e-s)/2;
if (a[mid]==num){
cout << "NUMBER IS FOUND at index ->";
cout<<mid<<endl ;
int k=mid;
cout<<k<<"kbs ";
return;
}
if (num <a[mid]){
binrysearch(a, s, mid-1, num);
}
if (num >a[mid]){
binrysearch(a,mid+1, e, num );
}
}
int main()
{
int a[]= {1,2,3,12,13,45,65,85};
binrysearch(a,0,7,12);
cout<<k<<"raju klsmks";
return 0;
} | [
"rajukumar2152chd@gmail.com"
] | rajukumar2152chd@gmail.com |
81b50e9261d1acbc2d278add0930fe56fcfd8a49 | d00270bfa470bd6b040f5001b745a2d57a526ab5 | /Hacker Rank/sock-merchant.cpp | ccd91f9136340043a1f17d42c8f2db02736be61a | [] | no_license | williamchanrico/competitive-programming | fcec67b3c7c338ebd250bdfc33627a26afe44ab4 | 6290e9f7ebd5063b0341c8068a321d2044a2ad63 | refs/heads/master | 2021-01-22T23:15:32.561571 | 2020-10-17T12:16:44 | 2020-10-17T12:16:44 | 85,616,873 | 2 | 4 | null | 2019-08-11T14:49:18 | 2017-03-20T19:20:11 | C++ | UTF-8 | C++ | false | false | 409 | cpp | #include <algorithm>
#include <cstdio>
#include <map>
int main()
{
int N;
scanf("%d", &N);
int arr[110];
std::map<int, int> m;
for (int a = 0; a < N; a++) {
scanf("%d", &arr[a]);
++m[arr[a]];
}
std::sort(arr, arr + N);
int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
ans += (int)(it->second / 2);
}
printf("%d\n", ans);
}
| [
"williamchanrico@gmail.com"
] | williamchanrico@gmail.com |
b5b2092bc5acebcfc8ca728bd5eb339655720b6a | a0ebf3f7218a7599ae603ad42b5810b85502b3f8 | /DataStructures.Tests/polynomial_test.cpp | 5b314821de73dafd926b2298727e601f8d860309 | [] | no_license | drussell33/Data-Structures-With-Tests | 381cdc2ececd2d210b3fd8de9d349e707ab4819b | 570c8ff25d979dc16910a1652b4658dac8931d67 | refs/heads/main | 2023-08-30T02:47:21.426698 | 2021-11-10T21:57:47 | 2021-11-10T21:57:47 | 426,788,191 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,161 | cpp | #include "pch.h"
#include "CppUnitTest.h"
#include "adt_exception.hpp"
#include "crt_check_memory.hpp"
#include "polynomial.hpp"
using namespace data_structures;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace data_structures_tests
{
TEST_CLASS(T14_Polynomial_Test)
{
public:
TEST_METHOD(PolynomialAddSameNumberCoefficients)
{
const CrtCheckMemory check;
// 60x^4 + 50x^3 + 40x^2 + 30^x + 20
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
// 6x^4 + 7x^3 + 8x^2 + 9^x + 10
const double coefficients_of_polynomial_2[]{ 10.0, 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 5 };
const Polynomial<double> your_answer = polynomial_1 + polynomial_2;
const double coefficients_of_answer[] = { 30.0, 39.0, 48.0, 57.0, 66.0 };
const Polynomial<double> correct_answer(coefficients_of_answer, 5);
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialSubtractSameNumberCoefficients)
{
const CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
double coefficients_of_polynomial_2[]{ 10.0, 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 5 };
const auto your_answer{ polynomial_1 - polynomial_2 };
double coefficients_of_answer[]{ 10.0, 21.0, 32.0, 43.0, 54.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialAddDifferentNumberCoefficients_LeftLarger)
{
const CrtCheckMemory check;
// 60x^4 + 50x^3 + 40x^2 + 30^x + 20
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
// 6x^3 + 7x^2 + 8x + 9
const double coefficients_of_polynomial_2[]{ 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 4 };
const auto your_answer{ polynomial_1 + polynomial_2 };
const double coefficients_of_answer[]{ 29.0, 38.0, 47.0, 56.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialAddDifferentNumberCoefficients_RightLarger)
{
const CrtCheckMemory check;
// 6x^3 + 7x^2 + 8x + 9
const double coefficients_of_polynomial_1[]{ 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_1(coefficients_of_polynomial_1, 4);
// 60x^4 + 50x^3 + 40x^2 + 30^x + 20
const double coefficients_of_polynomial_2[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 5 };
const auto your_answer{ polynomial_1 + polynomial_2 };
const double coefficients_of_answer[]{ 29.0, 38.0, 47.0, 56.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialSubtractDifferentNumberCoefficients_LeftLarger)
{
const CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const double coefficients_of_polynomial_2[]{ 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 4 };
const auto your_answer{ polynomial_1 - polynomial_2 };
const double coefficients_of_answer[]{ 11.0, 22.0, 33.0, 44.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialSubtractDifferentNumberCoefficients_RightLarger)
{
const CrtCheckMemory check;
const double coefficients_of_polynomial_1[4] = { 9.0, 8.0, 7.0, 6.0 };
const Polynomial<double> polynomial_1(coefficients_of_polynomial_1, 4);
const double coefficients_of_polynomial_2[5] = { 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_2(coefficients_of_polynomial_2, 5);
const auto your_answer = polynomial_1 - polynomial_2;
const double coefficients_of_answer[5] = { -11.0, -22.0, -33.0, -44.0, 60.0 };
const Polynomial<double> correct_answer(coefficients_of_answer, 5);
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialAddNegativeNumbers)
{
CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ -20.0, 30.0, -40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const double coefficients_of_polynomial_2[]{ 9.0, -8.0, 7.0, -6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 4 };
const auto your_answer{ polynomial_1 + polynomial_2 };
double coefficients_of_answer[]{ -11.0, 22.0, -33.0, 44.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialSubtractNegativeNumbers)
{
const CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ -20.0, 30.0, -40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const double coefficients_of_polynomial_2[]{ 9.0, -8.0, 7.0, -6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 4 };
const auto your_answer{ polynomial_1 - polynomial_2 };
const double coefficients_of_answer[]{ -29.0, 38.0, -47.0, 56.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialAssignmentOperator)
{
const CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ -20.0, 30.0, -40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const auto polynomial_2{ polynomial_1 };
Assert::IsTrue(polynomial_1 == polynomial_2);
}
TEST_METHOD(PolynomialConstructorandAssignmentOperator)
{
const CrtCheckMemory check;
// 60x^4 + 50x^3 + 40x^2 + 30^x + 20
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const Polynomial<double> your_answer = polynomial_1;
const double coefficients_of_answer[] = { 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> correct_answer(coefficients_of_answer, 5);
Assert::IsTrue(correct_answer == your_answer);
}
TEST_METHOD(PolynomialNumberofCoefficientsReturnTest)
{
const CrtCheckMemory check;
// 60x^4 + 50x^3 + 40x^2 + 30^x + 20
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const Polynomial<double> your_answer = polynomial_1;
Assert::IsTrue(your_answer.NumberOfCoefficients() == 5);
}
TEST_METHOD(PolynomialMoveTest)
{
const CrtCheckMemory check;
{
const double coefficients_of_polynomial_1[]{ 20.0, 30.0, 40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
Polynomial<double> polynomial_moved(std::move(polynomial_1));
}
}
TEST_METHOD(PolynomialAddNegativeNumbersAndTestNumberOfCoefficients)
{
CrtCheckMemory check;
const double coefficients_of_polynomial_1[]{ -20.0, 30.0, -40.0, 50.0, 60.0 };
const Polynomial<double> polynomial_1{ coefficients_of_polynomial_1, 5 };
const double coefficients_of_polynomial_2[]{ 9.0, -8.0, 7.0, -6.0 };
const Polynomial<double> polynomial_2{ coefficients_of_polynomial_2, 4 };
const auto your_answer{ polynomial_1 + polynomial_2 };
double coefficients_of_answer[]{ -11.0, 22.0, -33.0, 44.0, 60.0 };
const Polynomial<double> correct_answer{ coefficients_of_answer, 5 };
Assert::IsTrue(your_answer.NumberOfCoefficients() == 5);
}
};
;
} | [
"drussell19@wou.edu"
] | drussell19@wou.edu |
af4a4903fa6f9fadc6fcf0c8e72b22f08aeea755 | 45ce394ca1fc18194f7ed9dc1d3a7bfcb5d7fb99 | /Codeforces/818A.cpp | ddc230ffd71c90511745e4de535e077390780ae2 | [] | no_license | lethanhtam1604/MyAPCodes | 4bd34c19538ebd7271dde9b9cd6100cad7893e77 | d2528cda1ef8051839067a0bc05294bc34b357ea | refs/heads/master | 2021-01-23T16:26:06.383769 | 2018-02-10T12:46:10 | 2018-02-10T12:46:10 | 93,297,575 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 448 | cpp | #include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("/Users/TamLe/Documents/Input.txt", "rt", stdin);
#endif
long long n,k;
scanf("%I64d %I64d", &n, &k);
long long a = (n/2)/(k+1);
long long b = k*a;
long long c = n-(a+b);
printf("%I64d %I64d %I64d\n", a, b, c);
}
| [
"thanhtam.le@citynow.vn"
] | thanhtam.le@citynow.vn |
9534275d39d6da0c9002f20fb3a99d0296301b82 | 7ed5234fa370e40aea99b6ea1e547500cf771780 | /EasyHLS_RTSP/main.cpp | f64d5446e421eb7e2a76ec6e5c8ac853749af8ef | [] | no_license | ntvis/EasyHLS | 63979e5b911eaef70639968dac01fe5aa5507ee2 | 65c9b17c8badc831eb645c893d4c62e22c4711fa | refs/heads/master | 2021-01-15T19:35:13.687040 | 2015-08-12T06:46:42 | 2015-08-12T06:46:42 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,056 | cpp | /*
Copyright (c) 2013-2014 EasyDarwin.ORG. All rights reserved.
Github: https://github.com/EasyDarwin
WEChat: EasyDarwin
Website: http://www.EasyDarwin.org
*/
#define _CRTDBG_MAP_ALLOC
#include <stdio.h>
#include "EasyHLSAPI.h"
#include "EasyRTSPClientAPI.h"
#include <windows.h>
#define RTSPURL "rtsp://admin:admin@192.168.1.108/"
#define PLAYLIST_CAPACITY 4
#define ALLOW_CACHE false
#define M3U8_VERSION 3
#define TARGET_DURATION 4
#define HLS_ROOT_DIR "./"
#define HLS_SESSION_NAME "rtsp"
#define HTTP_ROOT_URL "http://www.easydarwin.org/easyhls/"
Easy_HLS_Handle fHlsHandle = 0;
Easy_RTSP_Handle fNVSHandle = 0;
/* NVSource从RTSPClient获取数据后回调给上层 */
int Easy_APICALL __NVSourceCallBack( int _chid, int *_chPtr, int _mediatype, char *pbuf, RTSP_FRAME_INFO *frameinfo)
{
if (NULL != frameinfo)
{
if (frameinfo->height==1088) frameinfo->height=1080;
else if (frameinfo->height==544) frameinfo->height=540;
}
if(NULL == fHlsHandle) return -1;
if (_mediatype == MEDIA_TYPE_VIDEO)
{
printf("Get %s Video Len:%d tm:%d rtp:%d\n",frameinfo->type==FRAMETYPE_I?"I":"P", frameinfo->length, frameinfo->timestamp_sec, frameinfo->rtptimestamp);
unsigned int uiFrameType = 0;
if (frameinfo->type == FRAMETYPE_I)
{
uiFrameType = TS_TYPE_PES_VIDEO_I_FRAME;
}
else
{
uiFrameType = TS_TYPE_PES_VIDEO_P_FRAME;
}
EasyHLS_VideoMux(fHlsHandle, uiFrameType, (unsigned char*)pbuf, frameinfo->length, frameinfo->rtptimestamp, frameinfo->rtptimestamp, frameinfo->rtptimestamp);
}
else if (_mediatype == MEDIA_TYPE_AUDIO)
{
printf("Get Audio Len:%d tm:%d rtp:%d\n", frameinfo->length, frameinfo->timestamp_sec, frameinfo->rtptimestamp);
// 暂时不对音频进行处理
}
else if (_mediatype == MEDIA_TYPE_EVENT)
{
if (NULL == pbuf && NULL == frameinfo)
{
printf("Connecting:%s ...\n", RTSPURL);
}
else if (NULL!=frameinfo && frameinfo->type==0xF1)
{
printf("Lose Packet:%s ...\n", RTSPURL);
}
}
return 0;
}
int main()
{
//创建NVSource
EasyRTSP_Init(&fNVSHandle);
if (NULL == fNVSHandle) return 0;
unsigned int mediaType = MEDIA_TYPE_VIDEO;
//mediaType |= MEDIA_TYPE_AUDIO; //换为NVSource, 屏蔽声音
//设置数据回调处理
EasyRTSP_SetCallback(fNVSHandle, __NVSourceCallBack);
//打开RTSP流
EasyRTSP_OpenStream(fNVSHandle, 0, RTSPURL, RTP_OVER_TCP, mediaType, 0, 0, NULL, 1000, 0);
//创建EasyHLS Session
fHlsHandle = EasyHLS_Session_Create(PLAYLIST_CAPACITY, ALLOW_CACHE, M3U8_VERSION);
char subDir[64] = { 0 };
sprintf(subDir,"%s/",HLS_SESSION_NAME);
EasyHLS_ResetStreamCache(fHlsHandle, HLS_ROOT_DIR, subDir, HLS_SESSION_NAME, TARGET_DURATION);
printf("HLS URL:%s%s/%s.m3u8", HTTP_ROOT_URL, HLS_SESSION_NAME, HLS_SESSION_NAME);
while(1)
{
Sleep(10);
};
EasyHLS_Session_Release(fHlsHandle);
fHlsHandle = 0;
EasyRTSP_CloseStream(fNVSHandle);
EasyRTSP_Deinit(&fNVSHandle);
fNVSHandle = NULL;
return 0;
} | [
"mysunpany@gmail.com"
] | mysunpany@gmail.com |
c8979234267967df51c34d1f6320764989876a01 | 6054718314d0c98d8c8e8296e9f331fcb114ffae | /RenderToScreen.cpp | 3abe799f889dede59ddf38d1ea530685a8eeb8d6 | [
"MIT"
] | permissive | paleahn/ROIW_based-Raytracer | b00e21276f7a5aa496047fc801afaf006017d8d0 | 70499e2a4a0f1d12a4ca18909819026dbf2ac49e | refs/heads/master | 2022-04-23T18:52:23.846410 | 2020-04-25T16:21:55 | 2020-04-25T16:21:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,356 | cpp | #include "RenderToScreen.h"
#include "Logger.h"
#include <cstdint>
union color
{
struct
{
uint8_t b, g, r, a;
};
uint8_t data[4];
};
#pragma region WINDOW DISPLAY
//base code for window display provided Tommi Lipponen
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#include <stdio.h>
struct RenderTarget {
HDC device;
int width;
int height;
unsigned *data;
BITMAPINFO info;
RenderTarget(HDC givenDevice, int width, int height)
: device(givenDevice), width(width), height(height), data(nullptr)
{
data = new unsigned[unsigned int(width * height)];
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info.bmiHeader.biWidth = width;
info.bmiHeader.biHeight = height;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 32;
info.bmiHeader.biCompression = BI_RGB;
}
~RenderTarget() { delete[] data; }
inline int size() const {
return width * height;
}
void clear(unsigned color) {
const int count = size();
for (int i = 0; i < count; i++) {
data[i] = color;
}
}
inline void pixel(int x, int y, unsigned color) {
data[y * width + x] = color;
}
void present() {
StretchDIBits(device,
0, 0, width, height,
0, 0, width, height,
data, &info,
DIB_RGB_COLORS, SRCCOPY);
}
};
static unsigned
makeColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
{
unsigned result = 0;
if (alpha > 0)
{
result |= ((unsigned)red << 16);
result |= ((unsigned)green << 8);
result |= ((unsigned)blue << 0);
result |= ((unsigned)alpha << 24);
}
return result;
}
static LRESULT CALLBACK
Win32DefaultProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
switch (message) {
case WM_CLOSE: { PostQuitMessage(0); } break;
default: { return DefWindowProcA(window, message, wparam, lparam); } break;
}
return 0;
}
#pragma endregion
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0L;
default:
return DefWindowProcW(hWnd, message, wParam, lParam);
}
}
RenderToScreen::RenderToScreen(color *image, size_t width, size_t height, const char *title) : width(width), height(height), rt(nullptr), title(title)
{
const char *const myclass = "minimalWindowClass";
WNDCLASSEXA wc = {};
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = GetModuleHandle(0);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = myclass;
if (RegisterClassExA(&wc))
{
DWORD window_style = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
RECT rc = { 0, 0, width, height };
if (!AdjustWindowRect(&rc, window_style, FALSE))
{
Logger::LogError("Couldn't show the image : window rect adjustment failed!");
return;
}
HWND windowHandleA = CreateWindowExA(0, wc.lpszClassName,
title, window_style, CW_USEDEFAULT, CW_USEDEFAULT,
rc.right - rc.left, rc.bottom - rc.top, 0, 0, GetModuleHandle(NULL), NULL);
if (!windowHandleA) { Logger::LogError("Couldn't show the image : window handle creation was unsuccessful!"); return; }
ShowWindow(windowHandleA, SW_SHOW);
if (windowHandleA)
{
HDC device = GetDC(windowHandleA);
rt = new RenderTarget(device, width, height);
rt->clear(makeColor(0x00,0x00,0x00,0xff));
} else
{
Logger::LogError("Couldn't show the image : Couldn't create the window!");
}
} else
{
Logger::LogError("Couldn't show the image : Could not register window class!");
}
}
RenderToScreen::~RenderToScreen()
{
delete rt;
}
void RenderToScreen::handleMessagesBlocking()
{
MSG msg;
while(GetMessage(&msg, 0, 0, 0))
{
if (msg.message == WM_QUIT) { return; }
TranslateMessage(&msg);
DispatchMessage(&msg);
rt->present();
}
}
void RenderToScreen::updateImage(color *image)
{
if (rt == nullptr) return;
for (size_t y = 0; y < height; y++)
for (size_t x = 0; x < width; x++)
{
color ¤tColor = image[y * width + x];
rt->pixel(x, y, makeColor(currentColor.r, currentColor.g, currentColor.b, currentColor.a));
}
rt->present();
}
| [
"clepirelli@gmail.com"
] | clepirelli@gmail.com |
bca4be2272a4e895b122e7a049507646263ab59a | da659b9c71a3c89a71f1639669da93e315edb198 | /Compactador-Huffman/comdeshuff/tcell.h | 98f4cf84a77116aec493647d2ec346b18d4c6a41 | [] | no_license | amg1127/PROGRAMAS-DA-FACULDADE | 941b732f1abc1c2b8859dd2b8f1ce5e580183153 | 48efcdb52e6a165d6980406909b3501212c0d2c4 | refs/heads/master | 2020-05-17T19:56:39.930515 | 2020-02-17T11:55:04 | 2020-02-17T11:55:04 | 183,930,907 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,674 | h | class TCell {
private:
int _id;
int _weight;
char _character;
TCell *_parent;
TCell *_son0;
TCell *_son1;
bool _hasSons;
std::string _pathToSon (TCell *);
template <typename SWPTYPE>
inline void swapvar (SWPTYPE &v1, SWPTYPE &v2) { SWPTYPE aux; aux=v1; v1=v2; v2=aux; }
public:
TCell (TCell * = NULL);
~TCell ();
int id (void);
void setId (int);
char character (void);
void setCharacter (char);
int weight ();
void setWeight (int);
int distanceToRoot (void);
int maxDistanceToSons (void);
bool isRoot (void);
bool hasSons (void);
void killSons (void);
void makeSons (void);
TCell *son0 (void);
TCell *son1 (void);
TCell *son (int);
TCell *parent (void);
TCell *root (void);
TCell *findSonByWeight (int);
TCell *findSonById (int);
TCell *findSonByCharacter (char);
TCell *findSonByPath (std::string);
TCell *self (void);
std::string pathFromRootToMe (void);
std::string pathToSon (TCell &);
std::string pathToSon (TCell *);
bool isSonOf (TCell &);
bool isSonOf (TCell *);
bool isParentOf (TCell &);
bool isParentOf (TCell *);
void swap (TCell &, bool = false);
void swap (TCell *, bool = false);
void copyFrom (TCell &, bool = false);
void copyFrom (TCell *, bool = false);
void copyTo (TCell &, bool = false);
void copyTo (TCell *, bool = false);
std::string dump (int = 0);
};
| [
"amg1127@5465fe1f-e9f4-4a51-a9b0-42098c041c11"
] | amg1127@5465fe1f-e9f4-4a51-a9b0-42098c041c11 |
f466f3f46c747c7cf2cc4a2a55c61133767947a6 | 719bcf0ec862bed0416c6a4d78ef03f1191f608b | /01.计算机基础知识/05.设计模式/04.行为型模式/08.访问者模式/c++/ComputerPart.h | ef0c52d40d0aaf80ad7b529c40f8d0cfc154a8bd | [] | no_license | cleveryuan777/C-background-development-interview-experience | d16e73efd08d020e3db2b7c3f718394b1806f2b3 | 48c1f22ea431a36288b73bc53e8573f828eed88c | refs/heads/main | 2023-06-14T05:04:55.013084 | 2021-04-04T14:19:56 | 2021-04-04T14:19:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 185 | h | #pragma once
class ComputerPartVisitor;
class ComputerPart
{
public:
ComputerPart();
virtual void accept(ComputerPartVisitor* computerPartVisitor) = 0;
virtual ~ComputerPart();
};
| [
"jackster@163.com"
] | jackster@163.com |
19ac5e384467acbcc86d92914909e001e00a65ca | 40d5773ad01d383dc6f03b293859925e87711810 | /factory/factory2.h | a1e146939735716007e14edd9aec2121a49732ac | [] | no_license | luoyouchun/DesignPatten | 3bc2f0a89fc995b87b0d7369ccc5aee51c2efe0d | fc3f7e0756c5868dc100f908a6c75143cc8f1666 | refs/heads/master | 2020-04-17T10:18:12.047018 | 2019-01-31T09:15:46 | 2019-01-31T09:15:46 | 166,495,963 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,171 | h | #pragma once
#include <map>
#include <string>
#include <functional>
#include <memory>
template<typename P>
struct factory2
{
template<typename T>
struct register_t
{
register_t(const std::string& key)
{
factory2::get().map_.emplace(key, ®ister_t<T>::create);
}
inline static P* create() { return new T; }
};
inline P* produce(const std::string& key)
{
if (map_.find(key) == map_.end())
throw std::invalid_argument("the product key is not exist!");
return map_[key]();
}
std::unique_ptr<P> produce_unique(const std::string& key)
{
return std::unique_ptr<P>(produce(key));
}
std::shared_ptr<P> produce_shared(const std::string& key)
{
return std::shared_ptr<P>(produce(key));
}
typedef P*(*FunPtr)();
inline static factory2& get()
{
static factory2 instance;
return instance;
}
private:
factory2() {};
factory2(const factory2&) = delete;
factory2(factory2&&) = delete;
std::map<std::string, FunPtr> map_;
};
#define REGISTER_PRODUCT_VNAME(T) reg_product_##T##_
#define REGISTER_PRODUCT(T, key) static factory2<T>::register_t<T> REGISTER_PRODUCT_VNAME(T)(key); | [
"chinaluo_007@163.com"
] | chinaluo_007@163.com |
6c19f429bb84e5bfc1f4e2d9e989c38712c7ec90 | dfb83f9e1d2a64e719c3d61004b25650f372f5a2 | /src/compiler/simplified-lowering.h | 19b98109671f18d0c6f7b0c0ae8b4237d24df1df | [] | no_license | kingland/v8-MinGW | 8ae0a89ebe9ad022bd88612f7e38398cfd50287e | 83c03915b0005faf60a517b7fe1938c08dd44d18 | refs/heads/master | 2021-01-10T08:27:14.667611 | 2015-10-01T04:17:59 | 2015-10-01T04:17:59 | 43,477,682 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,392 | h | // Copyright 2014 the V8 project 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 V8_COMPILER_SIMPLIFIED_LOWERING_H_
#define V8_COMPILER_SIMPLIFIED_LOWERING_H_
#include "compiler/graph-reducer.h"
#include "compiler/js-graph.h"
#include "compiler/lowering-builder.h"
#include "compiler/machine-operator.h"
#include "compiler/node.h"
#include "compiler/simplified-operator.h"
namespace v8 {
namespace internal {
namespace compiler {
class SimplifiedLowering : public LoweringBuilder {
public:
explicit SimplifiedLowering(JSGraph* jsgraph,
SourcePositionTable* source_positions)
: LoweringBuilder(jsgraph->graph(), source_positions),
jsgraph_(jsgraph),
machine_(jsgraph->zone()) {}
virtual ~SimplifiedLowering() {}
void LowerAllNodes();
virtual void Lower(Node* node);
void LowerChange(Node* node, Node* effect, Node* control);
// TODO(titzer): These are exposed for direct testing. Use a friend class.
void DoLoadField(Node* node);
void DoStoreField(Node* node);
void DoLoadElement(Node* node);
void DoStoreElement(Node* node);
private:
JSGraph* jsgraph_;
MachineOperatorBuilder machine_;
Node* SmiTag(Node* node);
Node* IsTagged(Node* node);
Node* Untag(Node* node);
Node* OffsetMinusTagConstant(int32_t offset);
Node* ComputeIndex(const ElementAccess& access, Node* index);
void DoChangeTaggedToUI32(Node* node, Node* effect, Node* control,
bool is_signed);
void DoChangeUI32ToTagged(Node* node, Node* effect, Node* control,
bool is_signed);
void DoChangeTaggedToFloat64(Node* node, Node* effect, Node* control);
void DoChangeFloat64ToTagged(Node* node, Node* effect, Node* control);
void DoChangeBoolToBit(Node* node, Node* effect, Node* control);
void DoChangeBitToBool(Node* node, Node* effect, Node* control);
friend class RepresentationSelector;
Zone* zone() { return jsgraph_->zone(); }
JSGraph* jsgraph() { return jsgraph_; }
Graph* graph() { return jsgraph()->graph(); }
CommonOperatorBuilder* common() { return jsgraph()->common(); }
MachineOperatorBuilder* machine() { return &machine_; }
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_
| [
"sarayu.noo@gmail.com"
] | sarayu.noo@gmail.com |
c2e54c22d8ac1eacc6eb7b461133b6f1164c1580 | 95033e45e9abcc2316ed8c2cf4b7c5077beacd62 | /core/osd/ClockDevice.h | 04d51ce35ec2e758da5097d1827a39a2de27a8d3 | [] | no_license | zeromus/bliss32 | 5083ae05298962cf55d77396f1ad0a4a68e96e33 | 7a41f9d051c7e2ead21b4b1ed009935449b17d16 | refs/heads/master | 2016-09-01T18:02:18.309718 | 2015-06-17T22:12:06 | 2015-06-17T22:12:06 | 5,157,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 247 | h |
#ifndef CLOCKDEVICE_H
#define CLOCKDEVICE_H
#include "types.h"
#include "Device.h"
class ClockDevice : public Device
{
public:
virtual INT64 getTickFrequency() = 0;
virtual INT64 getTick() = 0;
};
#endif
| [
"zeromus@zeromus.org"
] | zeromus@zeromus.org |
78673482b3db29f0d28ec6224b57931364ad991e | 941214a73266366edbf48a05971c8c83512bfcda | /MS/directshow/baseclassesvc2017/transip.h | e59199d681e47b72c67c4c385854758769a8c143 | [] | no_license | sjk7/edu | 19c2f570c5addc02dbcb675cb4c37c578ecbb839 | 41842fca23d46b3d7709f40117e26490fd06b22b | refs/heads/master | 2020-06-15T19:37:16.043521 | 2017-11-19T05:48:18 | 2017-11-19T05:48:18 | 75,267,497 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,578 | h | //------------------------------------------------------------------------------
// File: TransIP.h
//
// Desc: DirectShow base classes - defines classes from which simple
// Transform-In-Place filters may be derived.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
// The difference between this and Transfrm.h is that Transfrm copies the data.
//
// It assumes the filter has one input and one output stream, and has no
// interest in memory management, interface negotiation or anything else.
//
// Derive your class from this, and supply Transform and the media type/format
// negotiation functions. Implement that class, compile and link and
// you're done.
#ifndef __TRANSIP__
#define __TRANSIP__
// ======================================================================
// This is the com object that represents a simple transform filter. It
// supports IBaseFilter, IMediaFilter and two pins through nested interfaces
// ======================================================================
class CTransInPlaceFilter;
// Several of the pin functions call filter functions to do the work,
// so you can often use the pin classes unaltered, just overriding the
// functions in CTransInPlaceFilter. If that's not enough and you want
// to derive your own pin class, override GetPin in the filter to supply
// your own pin classes to the filter.
// ==================================================
// Implements the input pin
// ==================================================
class CTransInPlaceInputPin : public CTransformInputPin
{
protected:
CTransInPlaceFilter * const m_pTIPFilter; // our filter
BOOL m_bReadOnly; // incoming stream is read only
public:
CTransInPlaceInputPin(
__in_opt LPCTSTR pObjectName,
__inout CTransInPlaceFilter *pFilter,
__inout HRESULT *phr,
__in_opt LPCWSTR pName);
// --- IMemInputPin -----
// Provide an enumerator for media types by getting one from downstream
STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
// Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt);
// Return our upstream allocator
STDMETHODIMP GetAllocator(__deref_out IMemAllocator ** ppAllocator);
// get told which allocator the upstream output pin is actually
// going to use.
STDMETHODIMP NotifyAllocator(IMemAllocator * pAllocator,
BOOL bReadOnly);
// Allow the filter to see what allocator we have
// N.B. This does NOT AddRef
IMemAllocator * PeekAllocator() const
{ return m_pAllocator; }
// Pass this on downstream if it ever gets called.
STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps);
HRESULT CompleteConnect(IPin *pReceivePin);
inline const BOOL ReadOnly() { return m_bReadOnly ; }
}; // CTransInPlaceInputPin
// ==================================================
// Implements the output pin
// ==================================================
class CTransInPlaceOutputPin : public CTransformOutputPin
{
protected:
// m_pFilter points to our CBaseFilter
CTransInPlaceFilter * const m_pTIPFilter;
public:
CTransInPlaceOutputPin(
__in_opt LPCTSTR pObjectName,
__inout CTransInPlaceFilter *pFilter,
__inout HRESULT *phr,
__in_opt LPCWSTR pName);
// --- CBaseOutputPin ------------
// negotiate the allocator and its buffer size/count
// Insists on using our own allocator. (Actually the one upstream of us).
// We don't override this - instead we just agree the default
// then let the upstream filter decide for itself on reconnect
// virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc);
// Provide a media type enumerator. Get it from upstream.
STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
// Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt);
// This just saves the allocator being used on the output pin
// Also called by input pin's GetAllocator()
void SetAllocator(IMemAllocator * pAllocator);
IMemInputPin * ConnectedIMemInputPin()
{ return m_pInputPin; }
// Allow the filter to see what allocator we have
// N.B. This does NOT AddRef
IMemAllocator * PeekAllocator() const
{ return m_pAllocator; }
HRESULT CompleteConnect(IPin *pReceivePin);
}; // CTransInPlaceOutputPin
class AM_NOVTABLE CTransInPlaceFilter : public CTransformFilter
{
public:
// map getpin/getpincount for base enum of pins to owner
// override this to return more specialised pin objects
virtual CBasePin *GetPin(int n);
public:
// Set bModifiesData == false if your derived filter does
// not modify the data samples (for instance it's just copying
// them somewhere else or looking at the timestamps).
CTransInPlaceFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,
bool bModifiesData = true);
#ifdef UNICODE
CTransInPlaceFilter(__in_opt LPCSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,
bool bModifiesData = true);
#endif
// The following are defined to avoid undefined pure virtuals.
// Even if they are never called, they will give linkage warnings/errors
// We override EnumMediaTypes to bypass the transform class enumerator
// which would otherwise call this.
HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType)
{ DbgBreak("CTransInPlaceFilter::GetMediaType should never be called");
return E_UNEXPECTED;
}
// This is called when we actually have to provide our own allocator.
HRESULT DecideBufferSize(IMemAllocator*, __inout ALLOCATOR_PROPERTIES *);
// The functions which call this in CTransform are overridden in this
// class to call CheckInputType with the assumption that the type
// does not change. In Debug builds some calls will be made and
// we just ensure that they do not assert.
HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut)
{
return S_OK;
};
// =================================================================
// ----- You may want to override this -----------------------------
// =================================================================
HRESULT CompleteConnect(PIN_DIRECTION dir,IPin *pReceivePin);
// chance to customize the transform process
virtual HRESULT Receive(IMediaSample *pSample);
// =================================================================
// ----- You MUST override these -----------------------------------
// =================================================================
virtual HRESULT Transform(IMediaSample *pSample) PURE;
// this goes in the factory template table to create new instances
// static CCOMObject * CreateInstance(LPUNKNOWN, HRESULT *);
#ifdef PERF
// Override to register performance measurement with a less generic string
// You should do this to avoid confusion with other filters
virtual void RegisterPerfId()
{m_idTransInPlace = MSR_REGISTER(TEXT("TransInPlace"));}
#endif // PERF
// implementation details
protected:
IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource);
#ifdef PERF
int m_idTransInPlace; // performance measuring id
#endif // PERF
bool m_bModifiesData; // Does this filter change the data?
// these hold our input and output pins
friend class CTransInPlaceInputPin;
friend class CTransInPlaceOutputPin;
CTransInPlaceInputPin *InputPin() const
{
return (CTransInPlaceInputPin *)m_pInput;
};
CTransInPlaceOutputPin *OutputPin() const
{
return (CTransInPlaceOutputPin *)m_pOutput;
};
// Helper to see if the input and output types match
BOOL TypesMatch()
{
return InputPin()->CurrentMediaType() ==
OutputPin()->CurrentMediaType();
}
// Are the input and output allocators different?
BOOL UsingDifferentAllocators() const
{
return InputPin()->PeekAllocator() != OutputPin()->PeekAllocator();
}
}; // CTransInPlaceFilter
#endif /* __TRANSIP__ */
| [
"radiowebmasters@gmail.com"
] | radiowebmasters@gmail.com |
1a422115c8460dbad76bf699f522a7f4388eceea | 39185d0b188bf1736fb209a6480e732a31e1cb83 | /project/Shader.cpp | cd99267dd8134c846f9078aeb3caa7ead5a2bc98 | [] | no_license | DaniGodin/MotionBlur | a61f9fd19f9bd5b865729689d7d96c3119d81898 | 89a15760876e71bc29e62b3966cc21c1c3f20057 | refs/heads/master | 2020-05-20T20:57:20.468241 | 2019-07-08T09:28:57 | 2019-07-08T09:28:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,069 | cpp | //
// Created by dany on 03/07/19.
//
#include "Shader.hpp"
Shader::Shader(const char* vertexPath, const char* fragmentPath)
{
// 1. retrieve the vertex/fragment source code from filePath
std::string vertexCode;
std::string fragmentCode;
std::ifstream vShaderFile;
std::ifstream fShaderFile;
// ensure ifstream objects can throw exceptions:
vShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
try
{
// open files
vShaderFile.open(vertexPath);
fShaderFile.open(fragmentPath);
std::stringstream vShaderStream, fShaderStream;
// read file's buffer contents into streams
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderFile.rdbuf();
// close file handlers
vShaderFile.close();
fShaderFile.close();
// convert stream into string
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
}
catch (std::ifstream::failure e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
const char* vShaderCode = vertexCode.c_str();
const char * fShaderCode = fragmentCode.c_str();
// 2. compile shaders
unsigned int vertex, fragment;
// vertex shader
vertex = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex, 1, &vShaderCode, NULL);
glCompileShader(vertex);
checkCompileErrors(vertex, "VERTEX");
// fragment Shader
fragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment, 1, &fShaderCode, NULL);
glCompileShader(fragment);
checkCompileErrors(fragment, "FRAGMENT");
// shader Program
ID = glCreateProgram();
glAttachShader(ID, vertex);
glAttachShader(ID, fragment);
glLinkProgram(ID);
checkCompileErrors(ID, "PROGRAM");
// delete the shaders as they're linked into our program now and no longer necessary
glDeleteShader(vertex);
glDeleteShader(fragment);
}
| [
"danielgodin.pro@gmail.com"
] | danielgodin.pro@gmail.com |
e72a2c65edf89f10ad353e538bcb233101f954e6 | d2dd6b45c6e6ac4fcc0f7aa34bc044615d3f42ce | /src/para/thread/thread_pool_test.cc | 7257a608d6c97c6b7868b92844b0bbd6dfa1229e | [
"MIT"
] | permissive | wzheng21/libpara | 50c92eed7f323d055871a7c30646c6bae21fcee7 | 25598bf4ba2407d4f9af50a2e9a49a6b5658fafe | refs/heads/main | 2023-06-05T04:06:49.149237 | 2021-06-19T00:30:26 | 2021-06-19T00:30:26 | 343,213,140 | 0 | 0 | MIT | 2021-06-19T00:30:27 | 2021-02-28T20:58:10 | C++ | UTF-8 | C++ | false | false | 527 | cc | // Copyright (c) 2021
// Authors: Weixiong (Victor) Zheng
// All rights reserved
//
// SPDX-License-Identifier: MIT
#include "para/thread/thread_pool.h"
#include "para/base/time.h"
#include "para/testing/testing.h"
#include "glog/logging.h"
namespace para {
TEST(SimpleThreadPool, Basic) {
SimpleThreadPool pool(2);
for (int i = 1; i <= 5; ++i) {
pool.Submit([i](){
LOG(INFO) << "Sleep, Thread " << i;
SleepForSeconds(1.);
LOG(INFO) << "Wake up, Thread " << i;
});
}
}
} // namespace para
| [
"zwxne2010@gmail.com"
] | zwxne2010@gmail.com |
520a33eb013975868822fa7c6698f18b9517447c | 2705848da209f2200c651301b25e323e9eeaffbc | /EnergyEfficient_Scheduling_GGA/GroupingGenome.cpp | e4913218582d4bf5234a296b5aa2534a264937dc | [] | no_license | JR8ll/EEBS | a57aa2c1c553761cd761dec61b1f68b5aecb8207 | bd3902ede624e5d19da65f890bdd1f4409a45e8f | refs/heads/main | 2023-02-27T12:27:03.244492 | 2021-02-01T09:17:23 | 2021-02-01T09:17:23 | 334,894,607 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 21,688 | cpp |
#include "GroupingGenome.h"
GroupingGenome::GroupingGenome(){}
GroupingGenome::GroupingGenome(const GroupingGenome &other) {
this->copy((const GroupingGenome *) &other);
}
GroupingGenome::~GroupingGenome(){
int n = this->size();
for(int i = 0; i < n; i++) {
delete this->at(i);
}
}
void GroupingGenome::init() {
destroy();
this->resize(0);
}
void GroupingGenome::destroy() {
int n = this->size();
// Destroys all of the containers
for (int i = 0; i < n; i++) {
if ((*this)[i] != NULL) {
// TODO delete all jobs 23.07.2018
for(unsigned j = 0; j < (*this)[i]->numJobs; j++) {
(*this)[i]->destroy();
}
delete (*this)[i];
}
(*this)[i] = NULL;
}
}
void GroupingGenome::copy(const GroupingGenome *other) {
if (this == other) return;
this->destroy();
int n = other->size();
this->resize(n);
for (int i = 0; i < n; i++) {
(*this)[i] = new Batch(); //new Batch();
(*this)[i]->copy((*other)[i]);
}
}
void GroupingGenome::clean() { // Initialize all Genes (NOT clear()
int n = this->size();
for (int i = 0; i < n; i++) {
(*this)[i]->clear();
}
}
int GroupingGenome::firstEmpty(const bool from_start) {
int n = this->size();
if(from_start) {
for (unsigned i = 0; i < n; i++) {
if(this->at(i)->numJobs == 0) {
return i;
}
}
} else {
for (int i = n-1; i >= 0; i--) {
if(this->at(i)->numJobs == 0) {
return i;
}
}
}
return -1;
}
int GroupingGenome::predecessorOnMachine(int batchIdx){
int n = this->size();
int assignedM = 0;
if(batchIdx > 0 && batchIdx < n) {
assignedM = (int) floor(this->at(batchIdx)->key);
for(int i = batchIdx - 1; i >= 0; i--) {
if(floor(this->at(i)->key) == assignedM) {
return i;
}
}
}
return -1; // no predecessor
}
void GroupingGenome::operator=(const GroupingGenome &other) {
copy((const GroupingGenome *) & other);
}
// Initialization
void GroupingGenome::initializeRandom() {
// ACTUAL INITIALIZATION IS DONE IN ***SOLUTION CLASSES (MOMHLib)
this->clear();
this->resize(Global::problem->n);
for(unsigned i = 0; i < Global::problem->n; i++) {
// do {
// TODO: cur_batch = GARandomInt(0, Global::nJobs - 1);
// } while (!batches[cur_batch].addOrder(&order[i]));
}
}
void GroupingGenome::initializeEDD() {
// ACTUAL INITIALIZATION IS DONE IN ***SOLUTION CLASSES (MOMHLib)
cout << "GroupingGenome::initializeEDD() not implemented!" << endl;
};
void GroupingGenome::initializeTWD(){
// ACTUAL INITIALIZATION IS DONE IN ***SOLUTION CLASSES (MOMHLib)
cout << "GroupingGenome::initializeTWD() not implemented!" << endl;
};
// Mutation
void GroupingGenome::mutShift(const float prob){
cout << "GroupingGenome::mutShift(const float) not implemented." << endl;
}
void GroupingGenome::mutSwap(const float prob){
cout << "GroupingGenome::mutSwap(const float) not implemented." << endl;
}
// Refinement
bool GroupingGenome::shiftJobsForDominance(const int srcBatchIdx, const int dstBatchIdx) {
cout << "GroupingGenome::shiftJobsForDominance is not yet implemented." << endl;
if(srcBatchIdx >= 0 && srcBatchIdx < this->size() && dstBatchIdx >= 0 && dstBatchIdx < this->size() && srcBatchIdx != dstBatchIdx) {
if(this->at(srcBatchIdx)->numJobs <= 0) {
// no Jobs contained in source
return false;
}
}
return false;
}
bool GroupingGenome::shiftJobsTWT(const int srcBatchIdx, const int dstBatchIdx) {
// shift a job from source to destination batch if (assume that dst´s completion <= scr´s completion)
if(srcBatchIdx >= 0 && srcBatchIdx < this->size() && dstBatchIdx >= 0 && dstBatchIdx < this->size() && srcBatchIdx != dstBatchIdx) {
if(this->at(srcBatchIdx)->numJobs > 0 && this->at(srcBatchIdx)->f == (this->at(dstBatchIdx)->f || this->at(dstBatchIdx)->f == 0 && this->at(dstBatchIdx)->freeCapacity > 0)) {
vector<int> jobIds2bShifted;
for(unsigned i = 0; i < this->at(srcBatchIdx)->numJobs; i++) {
jobIds2bShifted.push_back(this->at(srcBatchIdx)->getJob(i).id);
}
// sort jobs by weight
// make_heap(jobIds2bShifted.begin(), jobIds2bShifted.end());
// sort_heap(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobWeight);
sort(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobWeight);
bool jobsShifted = false;
for(unsigned i = 0; i < jobIds2bShifted.size(); i++) {
if(Global::problem->jobs.getJobByID(jobIds2bShifted[i])->s <= this->at(dstBatchIdx)->freeCapacity) {
if(Global::problem->jobs.getJobByID(jobIds2bShifted[i])->r <= this->at(dstBatchIdx)->r) { // IMPORTANT
// job will not increase the batch´s release time
// capacity available, addJob to dst, eraseJob from src
if(this->at(dstBatchIdx)->addJob(Global::problem->jobs.getJobByID(jobIds2bShifted[i]))) {
this->at(srcBatchIdx)->erase(jobIds2bShifted[i]);
jobsShifted = true;
if(this->at(dstBatchIdx)->freeCapacity <= 0) {
break;
}
}
}
}
}
return jobsShifted;
}
// no Jobs contained in source, incompatible families or no free capacity
return false;
}
// index out of bounds
return false;
}
bool GroupingGenome::shiftJobsEPC(const int srcBatchIdx, const int dstBatchIdx) {
// shift jobs aiming at a decreased EPC => try to shift as many jobs into the destination batch so eventually the source batch can be cleared
if(srcBatchIdx >= 0 && srcBatchIdx < this->size() && dstBatchIdx >= 0 && dstBatchIdx < this->size() && srcBatchIdx != dstBatchIdx) {
if(this->at(srcBatchIdx)->numJobs > 0 && this->at(dstBatchIdx)->numJobs > 0 && this->at(srcBatchIdx)->f == this->at(dstBatchIdx)->f && this->at(dstBatchIdx)->freeCapacity > 0) {
vector<int> jobIds2bShifted;
for(unsigned i = 0; i < this->at(srcBatchIdx)->numJobs; i++) {
jobIds2bShifted.push_back(this->at(srcBatchIdx)->getJob(i).id);
}
// sort jobs by size
// make_heap(jobIds2bShifted.begin(), jobIds2bShifted.end());
//sort_heap(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobSize);
sort(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobSize);
// shift jobs
bool jobsShifted = false;
for(unsigned i = 0; i < jobIds2bShifted.size(); i++) {
if(Global::problem->jobs.getJobByID(jobIds2bShifted[i])->s <= this->at(dstBatchIdx)->freeCapacity) {
// TODO: conditions to shift a job
// capacity available, addJob to dst, eraseJob from src
if(this->at(dstBatchIdx)->addJob(Global::problem->jobs.getJobByID(jobIds2bShifted[i]))) {
this->at(srcBatchIdx)->erase(jobIds2bShifted[i]);
jobsShifted = true;
if(this->at(dstBatchIdx)->freeCapacity <= 0) {
break;
}
}
}
}
return jobsShifted;
}
// else, no jobs contained in either src or dst, incompatible families or no free capacity
}
// index out of bounds or src eq dst
return false;
}
bool GroupingGenome::shiftJobsTWC(const int srcBatchIdx, const int dstBatchIdx) {
// shift a job from source to destination batch if (assume that dst´s completion <= scr´s completion)
if(srcBatchIdx >= 0 && srcBatchIdx < this->size() && dstBatchIdx >= 0 && dstBatchIdx < this->size() && srcBatchIdx != dstBatchIdx) {
if(this->at(srcBatchIdx)->numJobs > 0 && this->at(srcBatchIdx)->f == (this->at(dstBatchIdx)->f || this->at(dstBatchIdx)->f == 0 && this->at(dstBatchIdx)->freeCapacity > 0)) {
vector<int> jobIds2bShifted;
for(unsigned i = 0; i < this->at(srcBatchIdx)->numJobs; i++) {
jobIds2bShifted.push_back(this->at(srcBatchIdx)->getJob(i).id);
}
// sort jobs by weight
// make_heap(jobIds2bShifted.begin(), jobIds2bShifted.end());
// sort_heap(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobWeight);
sort(jobIds2bShifted.begin(), jobIds2bShifted.end(), compareJobWeight);
bool jobsShifted = false;
for(unsigned i = 0; i < jobIds2bShifted.size(); i++) {
if(Global::problem->jobs.getJobByID(jobIds2bShifted[i])->s <= this->at(dstBatchIdx)->freeCapacity) {
if(Global::problem->jobs.getJobByID(jobIds2bShifted[i])->r <= this->at(dstBatchIdx)->r) { // IMPORTANT
// job will not increase the batch´s release time
// capacity available, addJob to dst, eraseJob from src
if(this->at(dstBatchIdx)->addJob(Global::problem->jobs.getJobByID(jobIds2bShifted[i]))) {
this->at(srcBatchIdx)->erase(jobIds2bShifted[i]);
jobsShifted = true;
if(this->at(dstBatchIdx)->freeCapacity <= 0) {
break;
}
}
}
}
}
return jobsShifted;
}
// no Jobs contained in source, incompatible families or no free capacity
return false;
}
// index out of bounds
return false;
}
bool GroupingGenome::swapJobsPossible(const int batchId1, const int jobId1, const int batchId2, const int jobId2) {
if( batchId1 >= 0 && batchId1 <= this->size() && batchId2 >= 0 && batchId2 <= this->size() ) {
if(!this->at(batchId1)->contains(jobId1) || !this->at(batchId2)->contains(jobId2)) {
// batch does not contain the job
return false;
}
else {
// check for matching families and sufficient capacity
return (this->at(batchId1)->f = this->at(batchId2)->f)
&& ( (this->at(batchId1)->freeCapacity + Global::problem->jobs.getJobByID(jobId1)->s) >= Global::problem->jobs.getJobByID(jobId2)->s )
&& ( (this->at(batchId2)->freeCapacity + Global::problem->jobs.getJobByID(jobId2)->s) >= Global::problem->jobs.getJobByID(jobId1)->s );
}
}
// else: index out of bounds
return false;
}
/// sorting
void GroupingGenome::sortBy_r(bool asc) {
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_r);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_r_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_pLot(bool asc) {
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_pLot);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_pLot_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_pItem(bool asc){
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_pItem);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_pItem_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_w(bool asc){
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_w);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_w_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_wpLot(bool asc) {
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_wpLot);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_wpLot_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_wpItem(bool asc) {
if(asc) {
sort(this->begin(), this->end(), GroupingGenome::compareBy_wpItem);
}
else {
sort(this->begin(), this->end(), GroupingGenome::compareBy_wpItem_desc);
}
// TODO update completion times ?
}
void GroupingGenome::sortBy_BATCII(int time, double kappa, bool asc) {
// get average p
double avgP = 0; // average processing time
double numJ = 0; // total number of jobs
int bMax = this->size();
for(unsigned i = 0; i < bMax; i++) {
int jMax = this->at(i)->numJobs;
numJ += (double) jMax;
for(unsigned j = 0; j < jMax; j++) {
avgP += (double) this->at(i)->getJob(j).p;
}
}
avgP = avgP / numJ;
if(asc) { // sort ascending
sort(this->begin(), this->end(), CompareBy_BATCII(avgP, time, kappa));
}
else { // sort descending
sort(this->begin(), this->end(), CompareBy_BATCII_desc(avgP, time, kappa));
}
// TODO this->updateCompletionTimes(); ??
}
void GroupingGenome::moveNonEmptyBatchesToFront() {
sort(this->begin(), this->end(), GroupingGenome::compareEmpty);
}
bool GroupingGenome::reinsert(vector<int> &missingJobs) {
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int iMax = unins.size();
int bMax = this->size();
for(unsigned i = 0; i < iMax; i++) {
// insert first-fit into existing batches
for(unsigned b = 0; b < bMax; b++) {
if (this->at(b)->addJob(Global::problem->jobs.getJobByID(unins[i]))) {
if(this->at(b)->numJobs <= 1) {
this->at(b)->setKey((double) rand() / ((double) RAND_MAX + 1.0) * Global::problem->m);
}
assigned.insert(unins[i]);
break;
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertTWTEPC_2(vector<int> &missingJobs) {
// TODO: check earliestStart, latestC and update the batches´ values
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int iMax = unins.size();
int bMax = this->size();
for(unsigned i = 0; i < iMax; i++) {
// insert first-fit into existing batches
for(unsigned b = 0; b < bMax; b++) {
// TODO: check if job.r <= batch.earliestD und job.p <= batch.latestC-batch.earliestStart
if(Global::problem->jobs.getJobByID(unins[i])->r <= this->at(b)->earliestStart && Global::problem->jobs.getJobByID(unins[i])->p <= (this->at(b)->latestC - this->at(b)->earliestStart)) {
if (this->at(b)->addJob(Global::problem->jobs.getJobByID(unins[i]))) {
assigned.insert(unins[i]);
break;
}
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertTWTEPC_3(vector<int> &missingJobs) {
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int iMax = unins.size();
int bMax = this->size();
for(unsigned i = 0; i < iMax; i++) {
// insert first-fit into existing batches
for(unsigned b = 0; b < bMax; b++) {
// check if job.r <= batch.earliestD und job.p <= batch.latestC-batch.earliestStart
if(Global::problem->jobs.getJobByID(unins[i])->r <= this->at(b)->r) {
// job´s r does not affect batch´s r
if (this->at(b)->addJob(Global::problem->jobs.getJobByID(unins[i]))) {
assigned.insert(unins[i]);
break;
}
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertTWCEPC_2(vector<int> &missingJobs) {
// TODO: check earliestStart, latestC and update the batches´ values
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int iMax = unins.size();
int bMax = this->size();
for(unsigned i = 0; i < iMax; i++) {
// insert first-fit into existing batches
for(unsigned b = 0; b < bMax; b++) {
// TODO: check if job.r <= batch.earliestD und job.p <= batch.latestC-batch.earliestStart
if(Global::problem->jobs.getJobByID(unins[i])->r <= this->at(b)->earliestStart && Global::problem->jobs.getJobByID(unins[i])->p <= (this->at(b)->latestC - this->at(b)->earliestStart)) {
if (this->at(b)->addJob(Global::problem->jobs.getJobByID(unins[i]))) {
assigned.insert(unins[i]);
break;
}
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertReady(vector<int> &missingJobs){ // reinsert considering ready times
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int jMax = unins.size();
int bMax = this->size();
// sort job ids by decreasing weight
sort(missingJobs.begin(), missingJobs.end(), compareJobWeight);
for(unsigned i = 0; i < bMax; i++) {
for(unsigned j = 0; j < jMax; j++) {
if(assigned.count(unins[j]) == 0 && this->at(i)->r >= Global::problem->jobs.getJobByID(unins[j])->r || this->at(i)->numJobs == 0) {
// Try to assign a job if 1) it is not yet assigned AND 2) its r is not larger than the batch´s r OR 3) the batch is empty
if(this->at(i)->addJob(Global::problem->jobs.getJobByID(j))) {
// The job is only assigned if the batch´s capacity restriction is met and the families match
assigned.insert(unins[j]);
}
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertDue(vector<int> &missingJobs){ // reinsert considering due dates
set<int> assigned;
vector<int> unins = missingJobs;
assigned.clear();
int iMax = unins.size();
int bMax = this->size();
int dRestriction;
// sort job ids by decreasing weight
sort(missingJobs.begin(), missingJobs.end(), compareJobWeight);
for(unsigned j = 0; j < iMax; j++) {
for(unsigned i = 0; i < bMax; i++) {
if(this->at(i)->getC() <= 0) {
dRestriction = this->at(i)->latestD;
}
else {
dRestriction = this->at(i)->getC();
}
// at the time of reinsertion the batch is not yet scheduled, therefore put job in if its d is not larger than the latest d of jobs already assigned
if(assigned.count(unins[j]) == 0 && this->at(i)->latestD >= Global::problem->jobs.getJobByID(unins[j])->d || this->at(i)->numJobs == 0) {
// Try to assign a job if 1) it is not yet assigned AND 2) its r is not larger than the batch´s r OR 3) the batch is empty
if(this->at(i)->addJob(Global::problem->jobs.getJobByID(j))) {
// The job is only assigned if the batch´s capacity restriction is met and the families match
assigned.insert(unins[j]);
}
}
}
}
return assigned.size() == unins.size();
}
bool GroupingGenome::reinsertReadyDue(vector<int> &missingJobs){ // reinsert considering ready times and due dates
return false;
}
bool GroupingGenome::reinsertReadyDueWeight(vector<int> &missingJobs){ // reinsert considering ready times, due dates and weight
return false;
}
bool GroupingGenome::reinsertMinDeltaTWT(vector<int> &missingJobs){ // reinsert increasing TWT as little as possible
return false;
}
bool GroupingGenome::reinsertTWT(vector<int> &missingJobs){ // reinsert so that TWT of accepting batch does not increase
std::cout << "GroupingGenome::reinsterTWT(vector<int>) not implemented." << endl;
return false;
}
bool GroupingGenome::reinsertTWC(vector<int> &missingJobs){ // reinsert so that TWT of accepting batch does not increase
std::cout << "GroupingGenome::reinsterTWC(vector<int>) not implemented." << endl;
return false;
}
bool GroupingGenome::reinsertBATC(vector<int> &missingJobs){ // reinsert so the BATC values of utilized batches are not increased
return false;
}
// compare Batches
/// ascending order
bool GroupingGenome::compareBy_r(const Batch* a, const Batch* b) {
if(a->r == b->r) {
return a->id < b->id;
}
else {
return a->r< b->r;
}
}
bool GroupingGenome::compareBy_pLot(const Batch* a, const Batch* b) {
if(a->pLot == b->pLot) {
return a->id < b->id;
}
else {
return a->pLot < b->pLot;
}
}
bool GroupingGenome::compareBy_pItem(const Batch* a, const Batch* b) {
if(a->pItem == b->pItem) {
return a->id < b->id;
}
else {
return a->pItem < b->pItem;
}
}
bool GroupingGenome::compareBy_w(const Batch* a, const Batch* b) {
if(a->w == b->w) {
return a->id < b->id;
}
else {
return a->w < b->w;
}
}
bool GroupingGenome::compareBy_wpLot(const Batch* a, const Batch* b) {
// consider empty batches
if(a->pLot == 0) {
if(b->pLot == 0) {
return a->id < b->id;
} else {
return false; // TODO check
}
}
if(b->pLot == 0) {
return true;
}
if(((double)a->w / (double)a->pLot) == ((double)b->w / (double)b->pLot)) {
return a->id < b->id;
}
else {
return ((double)a->w / (double)a->pLot) < ((double)b->w / (double)b->pLot);
}
}
bool GroupingGenome::compareBy_wpItem(const Batch* a, const Batch* b) {
// consider empty batches
if(a->pLot == 0) {
if(b->pLot == 0) {
return a->id < b->id;
} else {
return false; // TODO check
}
}
if(b->pLot == 0) {
return true;
}
if(((double)a->w / (double)a->pItem) == ((double)b->w / (double)b->pItem)) {
return a->id < b->id;
}
else {
return ((double)a->w / (double)a->pItem) < ((double)b->w / (double)b->pItem);
}
}
bool GroupingGenome::compareEmpty(const Batch* a, const Batch* b) {
if( (a->numJobs > 0 && b->numJobs > 0) || (a->numJobs == 0 && b->numJobs == 0) ) {
return a->id < b->id;
}
else if( b->numJobs > 0) {
return false;
}
return true;
// return true if a is to be placed before b
}
/// descending order
bool GroupingGenome::compareBy_r_desc(const Batch* a, const Batch* b) {
if(a->r == b->r) {
return a->id < b->id;
}
else {
return a->r > b->r;
}
}
bool GroupingGenome::compareBy_pLot_desc(const Batch* a, const Batch* b) {
if(a->pLot == b->pLot) {
return a->id < b->id;
}
else {
return a->pLot > b->pLot;
}
}
bool GroupingGenome::compareBy_pItem_desc(const Batch* a, const Batch* b) {
if(a->pItem == b->pItem) {
return a->id < b->id;
}
else {
return a->pItem > b->pItem;
}
}
bool GroupingGenome::compareBy_w_desc(const Batch* a, const Batch* b) {
if(a->w == b->w) {
return a->id < b->id;
}
else {
return a->w > b->w;
}
}
bool GroupingGenome::compareBy_wpLot_desc(const Batch* a, const Batch* b) {
// consider empty batches
if(a->pLot == 0) {
if(b->pLot == 0) {
return a->id < b->id;
} else {
return false; // TODO check
}
}
if(b->pLot == 0) {
return true;
}
if(((double)a->w / (double)a->pLot) == ((double)b->w / (double)b->pLot)) {
return a->id < b->id;
}
else {
return ((double)a->w / (double)a->pLot) > ((double)b->w / (double)b->pLot);
}
}
bool GroupingGenome::compareBy_wpItem_desc(const Batch* a, const Batch* b) {
// consider empty batches
if(a->pLot == 0) {
if(b->pLot == 0) {
return a->id < b->id;
} else {
return false; // TODO check
}
}
if(b->pLot == 0) {
return true;
}
if(((double)a->w / (double)a->pItem) == ((double)b->w / (double)b->pItem)) {
return a->id < b->id;
}
else {
return ((double)a->w / (double)a->pItem) > ((double)b->w / (double)b->pItem);
}
}
bool compareJobWeight(const int JobIdx1, const int JobIdx2) {
return Global::problem->jobs.getJobByID(JobIdx1)->w > Global::problem->jobs.getJobByID(JobIdx2)->w;
}
bool compareJobSize(const int JobIdx1, const int JobIdx2) {
return Global::problem->jobs.getJobByID(JobIdx1)->s > Global::problem->jobs.getJobByID(JobIdx2)->s;
} | [
"jrocholl@gmx.de"
] | jrocholl@gmx.de |
27596d2634f0d9efd956d0a48f022a7ceb563be5 | f6f0be9108ba516d0f49e009ffe525814c6f0c95 | /test/graph/checking_bipartiteness_online_test.cpp | 94b29046a79bb35626b011646ab44200615b5241 | [] | no_license | PauloMiranda98/Competitive-Programming-Notebook | fe07a318c50c147cc3939dfde9034fe3de5056d9 | 54af0a8dcefdeb5505538a3716855db62bcdc716 | refs/heads/master | 2023-08-02T04:36:52.830218 | 2023-07-31T00:21:04 | 2023-07-31T00:21:04 | 242,273,238 | 20 | 4 | null | 2021-07-08T19:21:44 | 2020-02-22T03:30:13 | C++ | UTF-8 | C++ | false | false | 130 | cpp | #include "../../code/graph/floyd_warshall.h"
void test(){
//No tests yet, then I'll add
}
int main() {
test();
return 0;
}
| [
"paulomirandamss12@gmail.com"
] | paulomirandamss12@gmail.com |
e5d151e1755e98bacb494378aa48a8ef08ee98a4 | 019870db548f9dbad19093de581d75686d68d6ca | /src/core/XMLLoadable.cpp | f5cbc46d7241122571d1e3ada66bbc6d2266f727 | [
"WTFPL"
] | permissive | davidhhyq/JVGS | cf8c54f6e557b1b31960cdd11ea03e1713e107f1 | 59be35ed61b355b445b82bf32796c0f229e21b60 | refs/heads/master | 2020-06-17T14:19:03.785109 | 2014-11-12T09:48:17 | 2014-11-12T09:48:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,618 | cpp | #include "XMLLoadable.h"
#include "LogManager.h"
#include "../tinyxml/tinyxml.h"
using namespace std;
namespace jvgs
{
namespace core
{
XMLLoadable::XMLLoadable()
{
}
XMLLoadable::~XMLLoadable()
{
}
void XMLLoadable::queryBoolAttribute(TiXmlElement *element,
const string &attribute, bool *value) const
{
if(element->Attribute(attribute)) {
string str = element->Attribute(attribute.c_str());
if(str == "true")
*value = true;
else if(str == "false")
*value = false;
else
LogManager::getInstance()->error(
"Bool attributes should be true or false.");
}
}
void XMLLoadable::load(TiXmlElement *element)
{
/* First load data from another file. */
if(element->Attribute("filename"))
load(element->Attribute("filename"));
/* Now load the specific data. */
loadData(element);
}
void XMLLoadable::load(const string &fileName)
{
LogManager *logManager = LogManager::getInstance();
TiXmlDocument *document = new TiXmlDocument(fileName);
if(document->LoadFile()) {
load(document->RootElement());
} else {
logManager->warning("Could not load xml document: %s.",
fileName.c_str());
}
delete document;
}
}
}
| [
"jaspervdj@gmail.com"
] | jaspervdj@gmail.com |
9228924cb3c36116eed4107f3ddb3e76833b73b4 | f8d1986a121ae1f7448d5af1b58ad12dc60c6bcf | /deep_learning_object_detection/include/velodyne_height_map/heightmap.h | 08ec84c514925f85313f498e6494c752187b0ffa | [] | no_license | Sadaku1993/my_master_thesis_ros | 93d080b5de0bf2d7b47bea0665415bca6fac4aa4 | b60bb0b7822b9308d30f54d72d831e10db468fcc | refs/heads/master | 2020-03-11T07:41:35.225356 | 2018-03-24T06:19:11 | 2018-03-24T06:19:11 | 129,863,849 | 0 | 1 | null | 2018-04-17T07:26:12 | 2018-04-17T07:26:11 | null | UTF-8 | C++ | false | false | 1,959 | h | /* -*- mode: C++ -*- */
/* Copyright (C) 2010 UT-Austin & Austin Robot Technology,
* David Claridge, Michael Quinlan
*
* License: Modified BSD Software License
*/
#ifndef _HEIGHT_MAP_H_
#define _HEIGHT_MAP_H_
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/kdtree/kdtree.h>
#include <pcl-1.7/pcl/filters/voxel_grid.h>
namespace velodyne_height_map {
// shorter names for point cloud types in this namespace
// typedef pcl::PointXYZINormal VPoint;
typedef pcl::PointXYZRGBNormal VPoint;
typedef pcl::PointCloud<VPoint> VPointCloud;
class HeightMap
{
public:
/** Constructor
*
* @param node NodeHandle of this instance
* @param private_nh private NodeHandle of this instance
*/
HeightMap(ros::NodeHandle node, ros::NodeHandle private_nh);
~HeightMap();
/** callback to process data input
*
* @param scan vector of input 3D data points
* @param stamp time stamp of data
* @param frame_id data frame of reference
*/
void processData(const VPointCloud::ConstPtr &scan);
private:
void constructFullClouds(const VPointCloud::ConstPtr &scan, unsigned npoints,
size_t &obs_count, size_t &empty_count);
void constructGridClouds(const VPointCloud::ConstPtr &scan, unsigned npoints,
size_t &obs_count, size_t &empty_count);
// Parameters that define the grids and the height threshold
// Can be set via the parameter server
int grid_dim_;
double m_per_cell_;
double height_diff_threshold_;
bool full_clouds_;
// Point clouds generated in processData
VPointCloud obstacle_cloud_;
VPointCloud clear_cloud_;
VPointCloud original_cloud_;
// ROS topics
ros::Subscriber velodyne_scan_;
ros::Publisher obstacle_publisher_;
ros::Publisher clear_publisher_;
ros::Publisher original_publisher_;
};
} // namespace velodyne_height_map
#endif
| [
"ce62001@meiji.ac.jp"
] | ce62001@meiji.ac.jp |
6b051b551d2e3aa7abe399710d0706d2748df7eb | 4cd434f48bf76da03503130cb3e9d8611a29a659 | /iTrace/CinematicCamera.cpp | ef9ee7b22502c3b7c107db646b011d6f7f4053c1 | [
"MIT"
] | permissive | Ruixel/iTrace | 39d593856f89664d9c42e570369af146e2098713 | 07e31bb60acba03bc6523986233f16191c502682 | refs/heads/master | 2022-12-22T13:44:10.535266 | 2020-10-01T22:43:41 | 2020-10-01T22:43:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,035 | cpp | #include "CinematicCamera.h"
#include <unordered_map>
#include "CommandPusher.h"
#include <iostream>
namespace iTrace {
namespace Rendering {
std::unordered_map<std::string, KeyFrame> KeyFrames;
std::unordered_map<std::string, Animation> Animations;
Animation* PlayingAnimation = nullptr;
std::vector<std::string> KeyFrameCommand(std::vector<std::string> Input)
{
auto ParseInterpolationMode = [](std::string& Text) {
if (Text == "linear") {
return InterpolationMode::LINEAR;
}
else if (Text == "sine") {
return InterpolationMode::SINE;
}
else {
return InterpolationMode::NONE;
}
};
if (Input.size() == 0) {
return { "Not enough data provided for keyframe command" };
}
if (Input[0] == ">help") {
//todo: write help text (probably needs to be pretty long)
return { "temporary help text" };
}
if (Input.size() < 2) {
return { "Not enough data provided for keyframe command" };
}
if (Input[0] == "add") {
if (Input.size() < 4) {
return { "Not enough data provided for keyframe command" };
}
std::string& Name = Input[1];
if (KeyFrames.find(Name) == KeyFrames.end()) {
KeyFrame ToAddKeyFrame;
ToAddKeyFrame.FirstHalf = ParseInterpolationMode(Input[2]);
ToAddKeyFrame.SecondHalf = ParseInterpolationMode(Input[3]);
if (ToAddKeyFrame.FirstHalf == NONE || ToAddKeyFrame.SecondHalf == NONE) {
return { "incorrect interpolation mode has been used", "available modes are: linear and sine" };
}
ToAddKeyFrame.Position = std::any_cast<Vector3f>(GetGlobalCommandPusher().GivenConstantData["camera_pos"]);
ToAddKeyFrame.Rotation = glm::mod(std::any_cast<Vector3f>(GetGlobalCommandPusher().GivenConstantData["camera_rot"]),360.f);
ToAddKeyFrame.Fov = std::any_cast<float>(GetGlobalCommandPusher().GivenConstantData["camera_fov"]);
KeyFrames[Name] = ToAddKeyFrame;
return { "Added keyframe: " + Name };
}
else {
return { "There is already a keyframe with the name: " + Name,
"if you wish to modify this keyframe, use 'keyframe modify [...]' instead" };
}
}
else if (Input[0] == "remove") {
std::string& Name = Input[1];
if (KeyFrames.find(Name) == KeyFrames.end()) {
return { "Could not find keyframe called: " + Name };
}
else {
KeyFrames.erase(Name);
}
}
else if (Input[0] == "modify") {
if (Input.size() < 4) {
return { "Not enough data provided for keyframe command" };
}
std::string& Name = Input[1];
if (KeyFrames.find(Name) == KeyFrames.end()) {
return { "Could not find keyframe called: " + Name };
}
}
else {
return { Input[0] + " is not a correct syntax for the keyframe command, see keyframe >help" };
}
return std::vector<std::string>();
}
std::vector<std::string> AnimationCommand(std::vector<std::string> Input)
{
if (Input.size() < 1) {
return { "Not enough data provided for animation command" };
}
if (Input[0] == ">help") {
return { "temporary help text" };
}
if (Input[0] == "add") {
if (Input.size() < 2) {
return { "Not enough data provided for animation command" };
}
auto& Name = Input[1];
Animation ToAddAnimation;
if (Animations.find(Name) == Animations.end()) {
//parse keyframes + keyframe timings
for (int i = 0; i < (Input.size() - 2) / 2; i++) {
auto& KeyFrameName = Input[i * 2 + 2];
float KeyFrameTiming;
AnimationKeyFrame AnimationKeyFrame;
if (KeyFrames.find(KeyFrameName) == KeyFrames.end()) {
return { "No keyframe with the name: " + KeyFrameName };
}
if (Core::SafeParseFloat(Input[i * 2 + 3], KeyFrameTiming)) {
auto& KeyFrame = KeyFrames[KeyFrameName];
AnimationKeyFrame = KeyFrame;
AnimationKeyFrame.Time = ToAddAnimation.LatestTime + KeyFrameTiming;
}
else {
return { "Failed to parse timing: " + Input[i * 2 + 3] };
}
ToAddAnimation.KeyFrames.push_back(AnimationKeyFrame);
ToAddAnimation.LatestTime += KeyFrameTiming;
}
Animations[Name] = ToAddAnimation;
return { "Added animation: " + Name };
}
else {
return { "There already exists an animation called: " + Name };
}
}
else if (Input[0] == "play") {
if (Input.size() < 2) {
return { "Not enough data provided for animation command" };
}
auto& Name = Input[1];
if (Animations.find(Name) == Animations.end()) {
return { "No animation called: " + Name };
}
else {
PlayingAnimation = &Animations[Name];
//ideally integrate some kind of safety here to ensure you cannot remove
//a playing animation
return { "Now playing animation: " + Name };
}
}
}
bool PollAnimation(Camera& Camera, Window& Window)
{
if (PlayingAnimation == nullptr) {
return false;
}
else {
PlayingAnimation->TimeInAnimation += Window.GetFrameTime();
if (PlayingAnimation->TimeInAnimation >= PlayingAnimation->LatestTime) {
PlayingAnimation->TimeInAnimation = 0.0;
PlayingAnimation->ActiveKeyFrame = 0;
PlayingAnimation = nullptr;
return false;
}
//begin by interpolating only the positions!
while (PlayingAnimation->TimeInAnimation >= PlayingAnimation->KeyFrames[PlayingAnimation->ActiveKeyFrame].Time) {
PlayingAnimation->ActiveKeyFrame++;
}
if (PlayingAnimation->ActiveKeyFrame == 0) {
Camera.Position = PlayingAnimation->KeyFrames[0].Position;
Camera.Rotation = PlayingAnimation->KeyFrames[0].Rotation;
Camera.fov = PlayingAnimation->KeyFrames[0].Fov;
Camera.Project = glm::perspective(glm::radians(Camera.fov), float(Window.GetResolution().x) / float(Window.GetResolution().y), Camera.znear, Camera.zfar);
}
else {
int KeyFrameIdx = PlayingAnimation->ActiveKeyFrame;
auto& CurrentKeyFrame = PlayingAnimation->KeyFrames[KeyFrameIdx - 1];
auto& NextKeyFrame = PlayingAnimation->KeyFrames[KeyFrameIdx];
float Interpolation = (PlayingAnimation->TimeInAnimation - CurrentKeyFrame.Time) / (NextKeyFrame.Time - CurrentKeyFrame.Time);
//for now, linear!
Interpolation = 1.0 - (sin(Interpolation * 3.14159265 + 1.570796) * 0.5 + 0.5);
Camera.Position = glm::mix(CurrentKeyFrame.Position, NextKeyFrame.Position, Interpolation);
Camera.fov = glm::mix(CurrentKeyFrame.Fov, NextKeyFrame.Fov, Interpolation);
auto MixRotation = [](float a, float b, float interp) {
float dist = abs(a - b);
if (dist > 180.0) {
//we need to use the different direction!
//one of our angles needs to be converted!
if (a > 180.0 && b < 180.0) {
//here we use an example, a is 350 degrees,
//and b is 10 degrees
//here b should be converted to 370 degrees,
//and then it should be interpolated
b = b + 360.0;
return glm::mod(glm::mix(a, b, interp), 360.f);
}
else {
//here we use an example, a is 10 degrees,
//and b is 350 degrees
//here a should be converted to 370 degrees,
//and then it should be interpolated
a = a + 360.0;
return glm::mod(glm::mix(a, b, interp), 360.f);
}
}
else {
return glm::mix(a, b, interp);
}
};
Camera.Rotation = Vector3f(
MixRotation(CurrentKeyFrame.Rotation.x, NextKeyFrame.Rotation.x, Interpolation),
MixRotation(CurrentKeyFrame.Rotation.y, NextKeyFrame.Rotation.y, Interpolation),
MixRotation(CurrentKeyFrame.Rotation.z, NextKeyFrame.Rotation.z, Interpolation)
);
Camera.Project = glm::perspective(glm::radians(Camera.fov), float(Window.GetResolution().x) / float(Window.GetResolution().y), Camera.znear, Camera.zfar);
}
return true;
}
}
}
} | [
"420iblazeitcopswontfindme@gmail.com"
] | 420iblazeitcopswontfindme@gmail.com |
0c544558fa04ba6f3513a0a955c4688df4d3775a | a4c71e7e8fdd4f1a5595dc765dbd78681b786586 | /libraries/utilities/include/TypeAliases.h | 8e24eb85a2cf4275e63d3104e98890130c236b4e | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | awesomemachinelearning/ELL | 68307c9ed6aa001baab64d23529e22baad643f02 | cb897e3aec148a1e9bd648012b5f53ab9d0dd20c | refs/heads/master | 2020-09-26T10:41:06.841270 | 2019-08-09T22:02:42 | 2019-08-09T22:02:42 | 226,237,954 | 1 | 0 | NOASSERTION | 2019-12-06T03:26:24 | 2019-12-06T03:26:23 | null | UTF-8 | C++ | false | false | 1,161 | h | ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Project: Embedded Learning Library (ELL)
// File: TypeAliases.h (utilities)
// Authors: Kern Handa
//
////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <type_traits>
namespace ell
{
namespace utilities
{
// macOS seems to alias intptr_t to long, which is different from what they
// alias for int32_t and int64_t, which are int and long long,
// respectively. We will now use a custom type to alias to either int32_t
// or int64_t, depending on the value of sizeof(void*). If neither
// int32_t nor int64_t match the width of void*, then we will raise a
// static_assert and fail to compile.
using IntPtrT = std::conditional_t<sizeof(void*) == sizeof(int32_t), int32_t, int64_t>;
static_assert(sizeof(IntPtrT) == sizeof(void*), "Unsupported architecture");
using UIntPtrT = std::make_unsigned_t<IntPtrT>;
static_assert(sizeof(UIntPtrT) == sizeof(void*), "Unsupported architecture");
} // namespace utilities
} // namespace ell
| [
"kerha@microsoft.com"
] | kerha@microsoft.com |
cb5da0a2dbaa7f8347be7f0219f53b1ef4f681c0 | 04855d63403efcb5316e3ea11e57128e9f7c5c02 | /mediapipe/calculators/core/flow_limiter_calculator.cc | 6d595e6cd19ae24cee7e6723bc3f2cb91a9b60b2 | [
"Apache-2.0"
] | permissive | Gilgahex/mediapipe | bc49f9d8b7048f24c9fe59c98f68d8b3b6cd863d | c06effd494e8da07488723615522e67ce9783c0a | refs/heads/master | 2021-10-28T07:25:30.760525 | 2020-03-09T01:52:05 | 2020-03-09T01:52:05 | 216,973,960 | 4 | 7 | Apache-2.0 | 2021-10-14T01:29:02 | 2019-10-23T05:19:19 | C++ | UTF-8 | C++ | false | false | 7,454 | cc | // Copyright 2019 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <algorithm>
#include <utility>
#include <vector>
#include "mediapipe/framework/calculator_framework.h"
#include "mediapipe/framework/port/ret_check.h"
#include "mediapipe/framework/port/status.h"
#include "mediapipe/util/header_util.h"
namespace mediapipe {
// FlowLimiterCalculator is used to limit the number of pipelined processing
// operations in a section of the graph.
//
// Typical topology:
//
// in ->-[FLC]-[foo]-...-[bar]-+->- out
// ^_____________________|
// FINISHED
//
// By connecting the output of the graph section to this calculator's FINISHED
// input with a backwards edge, this allows FLC to keep track of how many
// timestamps are currently being processed.
//
// The limit defaults to 1, and can be overridden with the MAX_IN_FLIGHT side
// packet.
//
// As long as the number of timestamps being processed ("in flight") is below
// the limit, FLC allows input to pass through. When the limit is reached,
// FLC starts dropping input packets, keeping only the most recent. When the
// processing count decreases again, as signaled by the receipt of a packet on
// FINISHED, FLC allows packets to flow again, releasing the most recently
// queued packet, if any.
//
// If there are multiple input streams, packet dropping is synchronized.
//
// IMPORTANT: for each timestamp where FLC forwards a packet (or a set of
// packets, if using multiple data streams), a packet must eventually arrive on
// the FINISHED stream. Dropping packets in the section between FLC and
// FINISHED will make the in-flight count incorrect.
//
// TODO: Remove this comment when graph-level ISH has been removed.
// NOTE: this calculator should always use the ImmediateInputStreamHandler and
// uses it by default. However, if the graph specifies a graph-level
// InputStreamHandler, to override that setting, the InputStreamHandler must
// be explicitly specified as shown below.
//
// Example config:
// node {
// calculator: "FlowLimiterCalculator"
// input_stream: "raw_frames"
// input_stream: "FINISHED:finished"
// input_stream_info: {
// tag_index: 'FINISHED'
// back_edge: true
// }
// input_stream_handler {
// input_stream_handler: 'ImmediateInputStreamHandler'
// }
// output_stream: "gated_frames"
// }
class FlowLimiterCalculator : public CalculatorBase {
public:
static ::mediapipe::Status GetContract(CalculatorContract* cc) {
int num_data_streams = cc->Inputs().NumEntries("");
RET_CHECK_GE(num_data_streams, 1);
RET_CHECK_EQ(cc->Outputs().NumEntries(""), num_data_streams)
<< "Output streams must correspond input streams except for the "
"finish indicator input stream.";
for (int i = 0; i < num_data_streams; ++i) {
cc->Inputs().Get("", i).SetAny();
cc->Outputs().Get("", i).SetSameAs(&(cc->Inputs().Get("", i)));
}
cc->Inputs().Get("FINISHED", 0).SetAny();
if (cc->InputSidePackets().HasTag("MAX_IN_FLIGHT")) {
cc->InputSidePackets().Tag("MAX_IN_FLIGHT").Set<int>();
}
if (cc->Outputs().HasTag("ALLOW")) {
cc->Outputs().Tag("ALLOW").Set<bool>();
}
cc->SetInputStreamHandler("ImmediateInputStreamHandler");
return ::mediapipe::OkStatus();
}
::mediapipe::Status Open(CalculatorContext* cc) final {
finished_id_ = cc->Inputs().GetId("FINISHED", 0);
max_in_flight_ = 1;
if (cc->InputSidePackets().HasTag("MAX_IN_FLIGHT")) {
max_in_flight_ = cc->InputSidePackets().Tag("MAX_IN_FLIGHT").Get<int>();
}
RET_CHECK_GE(max_in_flight_, 1);
num_in_flight_ = 0;
allowed_id_ = cc->Outputs().GetId("ALLOW", 0);
allow_ctr_ts_ = Timestamp(0);
num_data_streams_ = cc->Inputs().NumEntries("");
data_stream_bound_ts_.resize(num_data_streams_);
RET_CHECK_OK(CopyInputHeadersToOutputs(cc->Inputs(), &(cc->Outputs())));
return ::mediapipe::OkStatus();
}
bool Allow() { return num_in_flight_ < max_in_flight_; }
::mediapipe::Status Process(CalculatorContext* cc) final {
bool old_allow = Allow();
Timestamp lowest_incomplete_ts = Timestamp::Done();
// Process FINISHED stream.
if (!cc->Inputs().Get(finished_id_).Value().IsEmpty()) {
RET_CHECK_GT(num_in_flight_, 0)
<< "Received a FINISHED packet, but we had none in flight.";
--num_in_flight_;
}
// Process data streams.
for (int i = 0; i < num_data_streams_; ++i) {
auto& stream = cc->Inputs().Get("", i);
auto& out = cc->Outputs().Get("", i);
Packet& packet = stream.Value();
auto ts = packet.Timestamp();
if (ts.IsRangeValue() && data_stream_bound_ts_[i] <= ts) {
data_stream_bound_ts_[i] = ts + 1;
// Note: it's ok to update the output bound here, before sending the
// packet, because updates are batched during the Process function.
out.SetNextTimestampBound(data_stream_bound_ts_[i]);
}
lowest_incomplete_ts =
std::min(lowest_incomplete_ts, data_stream_bound_ts_[i]);
if (packet.IsEmpty()) {
// If the input stream is closed, close the corresponding output.
if (stream.IsDone() && !out.IsClosed()) {
out.Close();
}
// TODO: if the packet is empty, the ts is unset, and we
// cannot read the timestamp bound, even though we'd like to propagate
// it.
} else if (mediapipe::ContainsKey(pending_ts_, ts)) {
// If we have already sent this timestamp (on another stream), send it
// on this stream too.
out.AddPacket(std::move(packet));
} else if (Allow() && (ts > last_dropped_ts_)) {
// If the in-flight is under the limit, and if we have not already
// dropped this or a later timestamp on another stream, then send
// the packet and add an in-flight timestamp.
out.AddPacket(std::move(packet));
pending_ts_.insert(ts);
++num_in_flight_;
} else {
// Otherwise, we'll drop the packet.
last_dropped_ts_ = std::max(last_dropped_ts_, ts);
}
}
// Remove old pending_ts_ entries.
auto it = std::lower_bound(pending_ts_.begin(), pending_ts_.end(),
lowest_incomplete_ts);
pending_ts_.erase(pending_ts_.begin(), it);
// Update ALLOW signal.
if ((old_allow != Allow()) && allowed_id_.IsValid()) {
cc->Outputs()
.Get(allowed_id_)
.AddPacket(MakePacket<bool>(Allow()).At(++allow_ctr_ts_));
}
return ::mediapipe::OkStatus();
}
private:
std::set<Timestamp> pending_ts_;
Timestamp last_dropped_ts_;
int num_data_streams_;
int num_in_flight_;
int max_in_flight_;
CollectionItemId finished_id_;
CollectionItemId allowed_id_;
Timestamp allow_ctr_ts_;
std::vector<Timestamp> data_stream_bound_ts_;
};
REGISTER_CALCULATOR(FlowLimiterCalculator);
} // namespace mediapipe
| [
"jqtang@google.com"
] | jqtang@google.com |
07cdabae9b7c1e1bfb720e23afff04355786c49f | e60849340c8c1a4c50c915c36ce45387e0388032 | /StructureGraphLib/Synthesizer.h | 7b70339b54d14b3766474550b06e45774f015c10 | [] | no_license | BigkoalaZhu/StBl | bb55d013d54052870aeb6982babaf240d14aa0d1 | 0433e1ed92b2e3993fe559709ecbdc218fcf3546 | refs/heads/master | 2021-01-13T00:59:08.416099 | 2015-12-12T02:56:37 | 2015-12-12T02:56:37 | 44,472,750 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,726 | h | #pragma once
#include "StructureGraph.h"
using namespace Structure;
#include "RMF.h"
extern int randomCount;
extern int uniformTriCount;
struct ParameterCoord{
float u, v;
float theta, psi;
float origOffset;
Eigen::Vector3f origPoint;
Eigen::Vector3f origNormal;
Structure::Node * origNode;
ParameterCoord(){ u = v = -1; theta = psi = 0; origOffset = 0; origNode = NULL; }
ParameterCoord(float theta, float psi, float u, float v = 0, float offset = 0, Structure::Node * node = NULL){
this->u = u;
this->v = v;
this->theta = theta;
this->psi = psi;
this->origOffset = offset;
this->origNode = node;
}
bool operator < (const ParameterCoord& other) const{
return (u < other.u);
}
};
static inline QDebug operator<<(QDebug dbg, const ParameterCoord &c){
dbg.nospace() << QString("[ %1, %2] - theta = %3 \tpsi = %4").arg(c.u).arg(c.v).arg(c.theta).arg(c.psi);
return dbg.space();
}
typedef QMap<QString, QMap<QString, QVariant> > SynthData;
struct Synthesizer{
// Generate sample points in the parameter domain
static QVector<ParameterCoord> genPointCoordsCurve( Structure::Curve * curve, const std::vector<Eigen::Vector3f> & points, const std::vector<Eigen::Vector3f> & normals );
static QVector<ParameterCoord> genPointCoordsSheet( Structure::Sheet * sheet, const std::vector<Eigen::Vector3f> & points, const std::vector<Eigen::Vector3f> & normals );
static QVector<ParameterCoord> genFeatureCoords( Structure::Node * node );
static QVector<ParameterCoord> genEdgeCoords( Structure::Node * node );
static QVector<ParameterCoord> genRandomCoords( Structure::Node * node, int samples_count );
static QVector<ParameterCoord> genUniformCoords( Structure::Node * node, float sampling_resolution = -1);
static QVector<ParameterCoord> genRemeshCoords( Structure::Node * node );
static QVector<ParameterCoord> genUniformTrisCoords( Structure::Node * node );
static QVector<ParameterCoord> genSampleCoordsCurve(Structure::Curve * curve, int samplingType = Features | Random);
static QVector<ParameterCoord> genSampleCoordsSheet(Structure::Sheet * sheet, int samplingType = Features | Random);
// Compute the geometry on given samples in the parameter domain
static void sampleGeometryCurve( QVector<ParameterCoord> samples, Structure::Curve * curve, QVector<float> &offsets, QVector<Vec2f> &normals);
static void sampleGeometrySheet( QVector<ParameterCoord> samples, Structure::Sheet * sheet, QVector<float> &offsets, QVector<Vec2f> &normals );
// Preparation
enum SamplingType{ Features = 1, Edges = 2, Random = 4, Uniform = 8, All = 16, AllNonUniform = 32, Remeshing = 64, TriUniform = 128 };
static void prepareSynthesizeCurve( Structure::Curve * curve1, Structure::Curve * curve2, int samplingType, SynthData & output );
static void prepareSynthesizeSheet( Structure::Sheet * sheet1, Structure::Sheet * sheet2, int samplingType, SynthData & output );
// Blend geometries
static void blendGeometryCurves( Structure::Curve * curve, float alpha, const SynthData & data, QVector<Eigen::Vector3f> &points, QVector<Eigen::Vector3f> &normals, bool isApprox);
static void blendGeometrySheets( Structure::Sheet * sheet, float alpha, const SynthData & data, QVector<Eigen::Vector3f> &points, QVector<Eigen::Vector3f> &normals, bool isApprox);
// Reconstruction on given base skeleton
static void reconstructGeometryCurve( Structure::Curve * base_curve, const QVector<ParameterCoord> &in_samples, const QVector<float> &in_offsets,
const QVector<Vec2f> &in_normals, QVector<Eigen::Vector3f> &out_points, QVector<Eigen::Vector3f> &out_normals, bool isApprox);
static void reconstructGeometrySheet( Structure::Sheet * base_sheet, const QVector<ParameterCoord> &in_samples, const QVector<float> &in_offsets,
const QVector<Vec2f> &in_normals, QVector<Eigen::Vector3f> &out_points, QVector<Eigen::Vector3f> &out_normals, bool isApprox);
// Blend skeleton bases
static void blendCurveBases(Structure::Curve * curve1, Structure::Curve * curve2, float alpha);
static void blendSheetBases(Structure::Sheet * sheet1, Structure::Sheet * sheet2, float alpha);
// Helper functions
static RMF consistentFrame( Structure::Curve * curve, Array1D_Vector4d & coords );
// IO
static void saveSynthesisData(Structure::Node *node, QString prefix, SynthData & input);
static int loadSynthesisData(Structure::Node *node, QString prefix, SynthData & output);
static void writeXYZ( QString filename, std::vector<Eigen::Vector3f> points, std::vector<Eigen::Vector3f> normals );
};
Q_DECLARE_METATYPE(Eigen::Vector3f)
Q_DECLARE_METATYPE(QVector<float>)
Q_DECLARE_METATYPE(QVector<Vec2f>)
Q_DECLARE_METATYPE(QVector<Eigen::Vector3f>)
Q_DECLARE_METATYPE(QVector<ParameterCoord>)
| [
"chenyang.chandler.zhu@gmail.com"
] | chenyang.chandler.zhu@gmail.com |
cc2b95e4cd0e3d00ce662e4723d3e07de8caa6f3 | 577491f76e130d0fc757f011834691c6aa635051 | /Sources/Devices/Instance.cpp | 2cb63e0471429ae04e8346e632af47ed0a6538fa | [
"MIT"
] | permissive | opencollective/Acid | e627b082046e0148aaf7e2a8667fdd22df34235b | 0e1ed9605c4cddb89f92c2daeaa70ec512ce23f3 | refs/heads/master | 2023-08-26T13:26:36.840191 | 2019-09-21T05:30:22 | 2019-09-21T05:30:22 | 210,002,966 | 0 | 1 | null | 2019-09-21T14:51:39 | 2019-09-21T14:51:38 | null | UTF-8 | C++ | false | false | 6,913 | cpp | #include "Instance.hpp"
#include "Graphics/Graphics.hpp"
#include "Window.hpp"
#if !defined(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
#define VK_EXT_DEBUG_UTILS_EXTENSION_NAME "VK_EXT_debug_utils"
#endif
namespace acid {
const std::vector<const char *> Instance::ValidationLayers = {"VK_LAYER_LUNARG_standard_validation"}; // "VK_LAYER_RENDERDOC_Capture"
const std::vector<const char *> Instance::InstanceExtensions = {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME};
const std::vector<const char *> Instance::DeviceExtensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME}; // VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME,
// VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME
VKAPI_ATTR VkBool32 VKAPI_CALL CallbackDebug(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode,
const char *pLayerPrefix, const char *pMessage, void *pUserData) {
Log::Error(pMessage, '\n');
return static_cast<VkBool32>(false);
}
VkResult Instance::FvkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator,
VkDebugReportCallbackEXT *pCallback) {
auto func = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT"));
if (func) {
return func(instance, pCreateInfo, pAllocator, pCallback);
}
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
void Instance::FvkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator) {
auto func = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT"));
if (func) {
func(instance, callback, pAllocator);
}
}
void Instance::FvkCmdPushDescriptorSetKHR(VkDevice device, VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set,
uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites) {
auto func = reinterpret_cast<PFN_vkCmdPushDescriptorSetKHR>(vkGetDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR"));
if (func) {
func(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites);
}
}
uint32_t Instance::FindMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties *deviceMemoryProperties, const VkMemoryRequirements *memoryRequirements,
const VkMemoryPropertyFlags &requiredProperties) {
for (uint32_t i = 0; i < deviceMemoryProperties->memoryTypeCount; ++i) {
if (memoryRequirements->memoryTypeBits & (1 << i)) {
if ((deviceMemoryProperties->memoryTypes[i].propertyFlags & requiredProperties) == requiredProperties) {
return i;
}
}
}
throw std::runtime_error("Couldn't find a proper memory type");
}
Instance::Instance() {
SetupLayers();
SetupExtensions();
CreateInstance();
CreateDebugCallback();
}
Instance::~Instance() {
FvkDestroyDebugReportCallbackEXT(m_instance, m_debugReportCallback, nullptr);
vkDestroyInstance(m_instance, nullptr);
}
void Instance::SetupLayers() {
uint32_t instanceLayerPropertyCount;
vkEnumerateInstanceLayerProperties(&instanceLayerPropertyCount, nullptr);
std::vector<VkLayerProperties> instanceLayerProperties(instanceLayerPropertyCount);
vkEnumerateInstanceLayerProperties(&instanceLayerPropertyCount, instanceLayerProperties.data());
#if defined(ACID_DEBUG)
LogVulkanLayers(instanceLayerProperties);
#endif
// Sets up the layers.
#if defined(ACID_DEBUG) && !defined(ACID_BUILD_MACOS)
for (const auto &layerName : ValidationLayers) {
bool layerFound = false;
for (const auto &layerProperties : instanceLayerProperties) {
if (strcmp(layerName, layerProperties.layerName) == 0) {
layerFound = true;
break;
}
}
if (!layerFound) {
Log::Error("Vulkan validation layer not found: ", std::quoted(layerName), '\n');
continue;
}
m_instanceLayers.emplace_back(layerName);
}
#endif
for (const auto &layerName : DeviceExtensions) {
m_deviceExtensions.emplace_back(layerName);
}
}
void Instance::SetupExtensions() {
// Sets up the extensions.
auto [extensions, extensionsCount] = Window::Get()->GetInstanceExtensions();
for (uint32_t i = 0; i < extensionsCount; i++) {
m_instanceExtensions.emplace_back(extensions[i]);
}
for (const auto &instanceExtension : InstanceExtensions) {
m_instanceExtensions.emplace_back(instanceExtension);
}
#if defined(ACID_DEBUG) && !defined(ACID_BUILD_MACOS)
m_instanceExtensions.emplace_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
m_instanceExtensions.emplace_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
#endif
}
void Instance::CreateInstance() {
const auto &engineVersion = Engine::Get()->GetVersion();
//const auto &appVersion = Engine::Get()->GetApp()->GetVersion();
//const auto &appName = Engine::Get()->GetApp()->GetName();
VkApplicationInfo applicationInfo = {};
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
//applicationInfo.pApplicationName = appName.c_str();
//applicationInfo.applicationVersion = VK_MAKE_VERSION(appVersion.m_major, appVersion.m_minor, appVersion.m_patch);
applicationInfo.pEngineName = "Acid";
applicationInfo.engineVersion = VK_MAKE_VERSION(engineVersion.m_major, engineVersion.m_minor, engineVersion.m_patch);
applicationInfo.apiVersion = VK_MAKE_VERSION(1, 1, 0);
VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.pApplicationInfo = &applicationInfo;
instanceCreateInfo.enabledLayerCount = static_cast<uint32_t>(m_instanceLayers.size());
instanceCreateInfo.ppEnabledLayerNames = m_instanceLayers.data();
instanceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(m_instanceExtensions.size());
instanceCreateInfo.ppEnabledExtensionNames = m_instanceExtensions.data();
Graphics::CheckVk(vkCreateInstance(&instanceCreateInfo, nullptr, &m_instance));
}
void Instance::CreateDebugCallback() {
#if defined(ACID_DEBUG) && !defined(ACID_BUILD_MACOS)
VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo = {};
debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
debugReportCallbackCreateInfo.pNext = nullptr;
debugReportCallbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
debugReportCallbackCreateInfo.pfnCallback = &CallbackDebug;
debugReportCallbackCreateInfo.pUserData = nullptr;
Graphics::CheckVk(FvkCreateDebugReportCallbackEXT(m_instance, &debugReportCallbackCreateInfo, nullptr, &m_debugReportCallback));
#endif
}
void Instance::LogVulkanLayers(const std::vector<VkLayerProperties> &layerProperties) {
Log::Out("Instance Layers: ");
for (const auto &layer : layerProperties) {
Log::Out(layer.layerName, ", ");
}
Log::Out("\n\n");
}
}
| [
"mattparks5855@gmail.com"
] | mattparks5855@gmail.com |
5605b06bcb526fea47c7520deb241382ef612c4c | a4c8533710e295ecf4726c618c1a02760d888613 | /02_Build/01_Compile/01_Tasking_4p3/ctc/include.stl/stl/_rope.h | 2313f7ebacb1b15989fa6433940d9c41d75eb3b3 | [] | no_license | miaozhendaoren/K2SAR_EMS | ee42a1918cf45fbbbb24b0c8a128951d14eeee67 | 787d17cfa2c9a3ef89743dce1778f0087de32254 | refs/heads/master | 2021-01-17T23:05:04.505435 | 2015-12-22T14:39:24 | 2015-12-22T14:39:24 | 49,954,845 | 1 | 0 | null | 2016-01-19T13:35:48 | 2016-01-19T13:35:48 | null | UTF-8 | C++ | false | false | 80,854 | h |
/*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
// rope<_CharT,_Alloc> is a sequence of _CharT.
// Ropes appear to be mutable, but update operations
// really copy enough of the data structure to leave the original
// valid. Thus ropes can be logically copied by just copying
// a pointer value.
#ifndef _STLP_INTERNAL_ROPE_H
#define _STLP_INTERNAL_ROPE_H
#ifndef _STLP_INTERNAL_ALGOBASE_H
# include <stl/_algobase.h>
#endif
#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_INTERNAL_IOSFWD)
# include <stl/_iosfwd.h>
#endif
#ifndef _STLP_INTERNAL_ALLOC_H
# include <stl/_alloc.h>
#endif
#ifndef _STLP_INTERNAL_ITERATOR_H
# include <stl/_iterator.h>
#endif
#ifndef _STLP_INTERNAL_ALGO_H
# include <stl/_algo.h>
#endif
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
# include <stl/_function_base.h>
#endif
#ifndef _STLP_INTERNAL_NUMERIC_H
# include <stl/_numeric.h>
#endif
#ifndef _STLP_INTERNAL_HASH_FUN_H
# include <stl/_hash_fun.h>
#endif
#ifndef _STLP_CHAR_TRAITS_H
# include <stl/char_traits.h>
#endif
#ifndef _STLP_INTERNAL_THREADS_H
# include <stl/_threads.h>
#endif
#ifdef _STLP_SGI_THREADS
# include <mutex.h>
#endif
#ifndef _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE
# define _STLP_CREATE_ALLOCATOR(__atype,__a, _Tp) (_Alloc_traits<_Tp,__atype>::create_allocator(__a))
#else
# define _STLP_CREATE_ALLOCATOR(__atype,__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
#endif
_STLP_BEGIN_NAMESPACE
// First a lot of forward declarations. The standard seems to require
// much stricter "declaration before use" than many of the implementations
// that preceded it.
template<class _CharT, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_CharT>) > class rope;
template<class _CharT, class _Alloc> struct _Rope_RopeConcatenation;
template<class _CharT, class _Alloc> struct _Rope_RopeRep;
template<class _CharT, class _Alloc> struct _Rope_RopeLeaf;
template<class _CharT, class _Alloc> struct _Rope_RopeFunction;
template<class _CharT, class _Alloc> struct _Rope_RopeSubstring;
template<class _CharT, class _Alloc> class _Rope_iterator;
template<class _CharT, class _Alloc> class _Rope_const_iterator;
template<class _CharT, class _Alloc> class _Rope_char_ref_proxy;
template<class _CharT, class _Alloc> class _Rope_char_ptr_proxy;
_STLP_MOVE_TO_PRIV_NAMESPACE
template <class _CharT>
struct _BasicCharType { typedef __false_type _Ret; };
_STLP_TEMPLATE_NULL
struct _BasicCharType<char> { typedef __true_type _Ret; };
#ifdef _STLP_HAS_WCHAR_T
_STLP_TEMPLATE_NULL
struct _BasicCharType<wchar_t> { typedef __true_type _Ret; };
#endif
// Some helpers, so we can use the power algorithm on ropes.
// See below for why this isn't local to the implementation.
// This uses a nonstandard refcount convention.
// The result has refcount 0.
template<class _CharT, class _Alloc>
struct _Rope_Concat_fn
: public binary_function<rope<_CharT,_Alloc>, rope<_CharT,_Alloc>,
rope<_CharT,_Alloc> > {
rope<_CharT,_Alloc> operator() (const rope<_CharT,_Alloc>& __x,
const rope<_CharT,_Alloc>& __y) {
return __x + __y;
}
};
template <class _CharT, class _Alloc>
inline
rope<_CharT,_Alloc>
__identity_element(_Rope_Concat_fn<_CharT, _Alloc>)
{ return rope<_CharT,_Alloc>(); }
_STLP_MOVE_TO_STD_NAMESPACE
// Store an eos
template <class _CharT>
inline void _S_construct_null_aux(_CharT *__p, const __true_type&)
{ *__p = 0; }
template <class _CharT>
inline void _S_construct_null_aux(_CharT *__p, const __false_type&)
{ _STLP_STD::_Construct(__p); }
template <class _CharT>
inline void _S_construct_null(_CharT *__p) {
typedef typename _IsIntegral<_CharT>::_Ret _Char_Is_Integral;
_S_construct_null_aux(__p, _Char_Is_Integral());
}
// char_producers are logically functions that generate a section of
// a string. These can be converted to ropes. The resulting rope
// invokes the char_producer on demand. This allows, for example,
// files to be viewed as ropes without reading the entire file.
template <class _CharT>
class char_producer {
public:
virtual ~char_producer() {}
virtual void operator()(size_t __start_pos, size_t __len,
_CharT* __buffer) = 0;
// Buffer should really be an arbitrary output iterator.
// That way we could flatten directly into an ostream, etc.
// This is thoroughly impossible, since iterator types don't
// have runtime descriptions.
};
// Sequence buffers:
//
// Sequence must provide an append operation that appends an
// array to the sequence. Sequence buffers are useful only if
// appending an entire array is cheaper than appending element by element.
// This is true for many string representations.
// This should perhaps inherit from ostream<sequence::value_type>
// and be implemented correspondingly, so that they can be used
// for formatted. For the sake of portability, we don't do this yet.
//
// For now, sequence buffers behave as output iterators. But they also
// behave a little like basic_ostringstream<sequence::value_type> and a
// little like containers.
template<class _Sequence
# if !(defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) || \
defined ( _STLP_NO_DEFAULT_NON_TYPE_PARAM ))
, size_t _Buf_sz = 100
# if defined(__sgi) && !defined(__GNUC__)
# define __TYPEDEF_WORKAROUND
,class _V = typename _Sequence::value_type
# endif /* __sgi */
# endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
>
// The 3rd parameter works around a common compiler bug.
class sequence_buffer : public iterator <output_iterator_tag, void, void, void, void> {
public:
# ifndef __TYPEDEF_WORKAROUND
typedef typename _Sequence::value_type value_type;
typedef sequence_buffer<_Sequence
# if !(defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) || \
defined ( _STLP_NO_DEFAULT_NON_TYPE_PARAM ))
, _Buf_sz
> _Self;
# else /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
> _Self;
enum { _Buf_sz = 100};
# endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
// # endif
# else /* __TYPEDEF_WORKAROUND */
typedef _V value_type;
typedef sequence_buffer<_Sequence, _Buf_sz, _V> _Self;
# endif /* __TYPEDEF_WORKAROUND */
protected:
_Sequence* _M_prefix;
value_type _M_buffer[_Buf_sz];
size_t _M_buf_count;
public:
void flush() {
_M_prefix->append(_M_buffer, _M_buffer + _M_buf_count);
_M_buf_count = 0;
}
~sequence_buffer() { flush(); }
sequence_buffer() : _M_prefix(0), _M_buf_count(0) {}
sequence_buffer(const _Self& __x) {
_M_prefix = __x._M_prefix;
_M_buf_count = __x._M_buf_count;
_STLP_STD::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
}
sequence_buffer(_Self& __x) {
__x.flush();
_M_prefix = __x._M_prefix;
_M_buf_count = 0;
}
sequence_buffer(_Sequence& __s) : _M_prefix(&__s), _M_buf_count(0) {}
_Self& operator= (_Self& __x) {
__x.flush();
_M_prefix = __x._M_prefix;
_M_buf_count = 0;
return *this;
}
_Self& operator= (const _Self& __x) {
_M_prefix = __x._M_prefix;
_M_buf_count = __x._M_buf_count;
_STLP_STD::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
return *this;
}
void push_back(value_type __x) {
if (_M_buf_count < _Buf_sz) {
_M_buffer[_M_buf_count] = __x;
++_M_buf_count;
} else {
flush();
_M_buffer[0] = __x;
_M_buf_count = 1;
}
}
void append(const value_type *__s, size_t __len) {
if (__len + _M_buf_count <= _Buf_sz) {
size_t __i = _M_buf_count;
size_t __j = 0;
for (; __j < __len; __i++, __j++) {
_M_buffer[__i] = __s[__j];
}
_M_buf_count += __len;
} else if (0 == _M_buf_count) {
_M_prefix->append(__s, __s + __len);
} else {
flush();
append(__s, __len);
}
}
_Self& write(const value_type *__s, size_t __len) {
append(__s, __len);
return *this;
}
_Self& put(value_type __x) {
push_back(__x);
return *this;
}
_Self& operator=(const value_type& __rhs) {
push_back(__rhs);
return *this;
}
_Self& operator*() { return *this; }
_Self& operator++() { return *this; }
_Self& operator++(int) { return *this; }
};
// The following should be treated as private, at least for now.
template<class _CharT>
class _Rope_char_consumer {
#if !defined (_STLP_MEMBER_TEMPLATES)
public:
//Without member templates we have to use run-time parameterization.
// The symmetry with char_producer is accidental and temporary.
virtual ~_Rope_char_consumer() {}
virtual bool operator()(const _CharT* __buffer, size_t __len) = 0;
#endif
};
//
// What follows should really be local to rope. Unfortunately,
// that doesn't work, since it makes it impossible to define generic
// equality on rope iterators. According to the draft standard, the
// template parameters for such an equality operator cannot be inferred
// from the occurence of a member class as a parameter.
// (SGI compilers in fact allow this, but the __result wouldn't be
// portable.)
// Similarly, some of the static member functions are member functions
// only to avoid polluting the global namespace, and to circumvent
// restrictions on type inference for template functions.
//
//
// The internal data structure for representing a rope. This is
// private to the implementation. A rope is really just a pointer
// to one of these.
//
// A few basic functions for manipulating this data structure
// are members of _RopeRep. Most of the more complex algorithms
// are implemented as rope members.
//
// Some of the static member functions of _RopeRep have identically
// named functions in rope that simply invoke the _RopeRep versions.
//
template<class _CharT, class _Alloc>
struct _Rope_RopeRep
: public _Refcount_Base
{
typedef _Rope_RopeRep<_CharT, _Alloc> _Self;
public:
//
// GAB: 11/09/05
//
// "__ROPE_DEPTH_SIZE" is set to one more then the "__ROPE_MAX_DEPTH".
// This was originally just an addition of "__ROPE_MAX_DEPTH + 1"
// but this addition causes the sunpro compiler to complain about
// multiple declarations during the initialization of "_S_min_len".
// Changed to be a fixed value and the sunpro compiler appears to
// be happy???
//
# define __ROPE_MAX_DEPTH 45
# define __ROPE_DEPTH_SIZE 46 // __ROPE_MAX_DEPTH + 1
enum { _S_max_rope_depth = __ROPE_MAX_DEPTH };
enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function};
// Apparently needed by VC++
// The data fields of leaves are allocated with some
// extra space, to accomodate future growth and for basic
// character types, to hold a trailing eos character.
enum { _S_alloc_granularity = 8 };
_Tag _M_tag:8;
bool _M_is_balanced:8;
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef _Alloc allocator_type;
allocator_type get_allocator() const { return allocator_type(_M_size); }
unsigned char _M_depth;
_CharT* _STLP_VOLATILE _M_c_string;
_STLP_PRIV _STLP_alloc_proxy<size_t, _CharT, allocator_type> _M_size;
#ifdef _STLP_NO_ARROW_OPERATOR
_Rope_RopeRep() : _Refcount_Base(1), _M_size(allocator_type(), 0) {
# if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
_STLP_CHECK_RUNTIME_COMPATIBILITY();
# endif
}
#endif
/* Flattened version of string, if needed. */
/* typically 0. */
/* If it's not 0, then the memory is owned */
/* by this node. */
/* In the case of a leaf, this may point to */
/* the same memory as the data field. */
_Rope_RopeRep(_Tag __t, unsigned char __d, bool __b, size_t _p_size,
allocator_type __a) :
_Refcount_Base(1),
_M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0), _M_size(__a, _p_size) {
#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
_STLP_CHECK_RUNTIME_COMPATIBILITY();
#endif
}
typedef _STLP_TYPENAME _STLP_PRIV _BasicCharType<_CharT>::_Ret _IsBasicCharType;
#if 0
/* Please tell why this code is necessary if you uncomment it.
* Problem with it is that rope implementation expect that _S_rounded_up_size(n)
* returns a size > n in order to store the terminating null charater. When
* instanciation type is not a char or wchar_t this is not guaranty resulting in
* memory overrun.
*/
static size_t _S_rounded_up_size_aux(size_t __n, __true_type const& /*_IsBasicCharType*/) {
// Allow slop for in-place expansion.
return (__n + _S_alloc_granularity) & ~(_S_alloc_granularity - 1);
}
static size_t _S_rounded_up_size_aux(size_t __n, __false_type const& /*_IsBasicCharType*/) {
// Allow slop for in-place expansion.
return (__n + _S_alloc_granularity - 1) & ~(_S_alloc_granularity - 1);
}
#endif
// fbp : moved from RopeLeaf
static size_t _S_rounded_up_size(size_t __n)
//{ return _S_rounded_up_size_aux(__n, _IsBasicCharType()); }
{ return (__n + _S_alloc_granularity) & ~(_S_alloc_granularity - 1); }
static void _S_free_string( _CharT* __s, size_t __len,
allocator_type __a) {
_STLP_STD::_Destroy_Range(__s, __s + __len);
// This has to be a static member, so this gets a bit messy
# ifndef _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE
__a.deallocate(__s, _S_rounded_up_size(__len)); //*ty 03/24/2001 - restored not to use __stl_alloc_rebind() since it is not defined under _STLP_MEMBER_TEMPLATE_CLASSES
# else
__stl_alloc_rebind (__a, (_CharT*)0).deallocate(__s, _S_rounded_up_size(__len));
# endif
}
// Deallocate data section of a leaf.
// This shouldn't be a member function.
// But its hard to do anything else at the
// moment, because it's templatized w.r.t.
// an allocator.
// Does nothing if __GC is defined.
void _M_free_c_string();
void _M_free_tree();
// Deallocate t. Assumes t is not 0.
void _M_unref_nonnil() {
if (_M_decr() == 0) _M_free_tree();
}
void _M_ref_nonnil() {
_M_incr();
}
static void _S_unref(_Self* __t) {
if (0 != __t) {
__t->_M_unref_nonnil();
}
}
static void _S_ref(_Self* __t) {
if (0 != __t) __t->_M_incr();
}
//static void _S_free_if_unref(_Self* __t) {
// if (0 != __t && 0 == __t->_M_ref_count) __t->_M_free_tree();
//}
};
template<class _CharT, class _Alloc>
struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> {
public:
_CharT* _M_data; /* Not necessarily 0 terminated. */
/* The allocated size is */
/* _S_rounded_up_size(size), except */
/* in the GC case, in which it */
/* doesn't matter. */
private:
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
typedef typename _RopeRep::_IsBasicCharType _IsBasicCharType;
void _M_init(__true_type const& /*_IsBasicCharType*/) {
this->_M_c_string = _M_data;
}
void _M_init(__false_type const& /*_IsBasicCharType*/) {}
public:
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef typename _RopeRep::allocator_type allocator_type;
_Rope_RopeLeaf( _CharT* __d, size_t _p_size, allocator_type __a)
: _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_leaf, 0, true, _p_size, __a),
_M_data(__d) {
_STLP_ASSERT(_p_size > 0)
_M_init(_IsBasicCharType());
}
# ifdef _STLP_NO_ARROW_OPERATOR
_Rope_RopeLeaf() {}
_Rope_RopeLeaf(const _Rope_RopeLeaf<_CharT, _Alloc>& ) {}
# endif
// The constructor assumes that d has been allocated with
// the proper allocator and the properly padded size.
// In contrast, the destructor deallocates the data:
~_Rope_RopeLeaf() {
if (_M_data != this->_M_c_string) {
this->_M_free_c_string();
}
_RopeRep::_S_free_string(_M_data, this->_M_size._M_data, this->get_allocator());
}
};
template<class _CharT, class _Alloc>
struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT, _Alloc> {
private:
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
public:
_RopeRep* _M_left;
_RopeRep* _M_right;
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef typename _RopeRep::allocator_type allocator_type;
_Rope_RopeConcatenation(_RopeRep* __l, _RopeRep* __r, allocator_type __a)
: _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_concat,
(max)(__l->_M_depth, __r->_M_depth) + 1, false,
__l->_M_size._M_data + __r->_M_size._M_data, __a), _M_left(__l), _M_right(__r)
{}
# ifdef _STLP_NO_ARROW_OPERATOR
_Rope_RopeConcatenation() {}
_Rope_RopeConcatenation(const _Rope_RopeConcatenation<_CharT, _Alloc>&) {}
# endif
~_Rope_RopeConcatenation() {
this->_M_free_c_string();
_M_left->_M_unref_nonnil();
_M_right->_M_unref_nonnil();
}
};
template <class _CharT, class _Alloc>
struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT, _Alloc> {
private:
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
public:
char_producer<_CharT>* _M_fn;
/*
* Char_producer is owned by the
* rope and should be explicitly
* deleted when the rope becomes
* inaccessible.
*/
bool _M_delete_when_done;
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef typename _Rope_RopeRep<_CharT,_Alloc>::allocator_type allocator_type;
# ifdef _STLP_NO_ARROW_OPERATOR
_Rope_RopeFunction() {}
_Rope_RopeFunction(const _Rope_RopeFunction<_CharT, _Alloc>& ) {}
# endif
_Rope_RopeFunction(char_producer<_CharT>* __f, size_t _p_size,
bool __d, allocator_type __a)
: _Rope_RopeRep<_CharT,_Alloc>(_RopeRep::_S_function, 0, true, _p_size, __a), _M_fn(__f)
, _M_delete_when_done(__d)
{ _STLP_ASSERT(_p_size > 0) }
~_Rope_RopeFunction() {
this->_M_free_c_string();
if (_M_delete_when_done) {
delete _M_fn;
}
}
};
/*
* Substring results are usually represented using just
* concatenation nodes. But in the case of very long flat ropes
* or ropes with a functional representation that isn't practical.
* In that case, we represent the __result as a special case of
* RopeFunction, whose char_producer points back to the rope itself.
* In all cases except repeated substring operations and
* deallocation, we treat the __result as a RopeFunction.
*/
template<class _CharT, class _Alloc>
struct _Rope_RopeSubstring : public char_producer<_CharT>, public _Rope_RopeFunction<_CharT,_Alloc> {
public:
// XXX this whole class should be rewritten.
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
_RopeRep *_M_base; // not 0
size_t _M_start;
/* virtual */ void operator()(size_t __start_pos, size_t __req_len,
_CharT* __buffer) {
typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction;
typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf;
switch (_M_base->_M_tag) {
case _RopeRep::_S_function:
case _RopeRep::_S_substringfn:
{
char_producer<_CharT>* __fn =
__STATIC_CAST(_RopeFunction*, _M_base)->_M_fn;
_STLP_ASSERT(__start_pos + __req_len <= this->_M_size._M_data)
_STLP_ASSERT(_M_start + this->_M_size._M_data <= _M_base->_M_size._M_data)
(*__fn)(__start_pos + _M_start, __req_len, __buffer);
}
break;
case _RopeRep::_S_leaf:
{
_CharT* __s =
__STATIC_CAST(_RopeLeaf*, _M_base)->_M_data;
_STLP_PRIV __ucopy_n(__s + __start_pos + _M_start, __req_len, __buffer);
}
break;
default:
_STLP_ASSERT(false)
;
}
}
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef typename _RopeRep::allocator_type allocator_type;
_Rope_RopeSubstring(_RopeRep* __b, size_t __s, size_t __l, allocator_type __a)
: _Rope_RopeFunction<_CharT,_Alloc>(this, __l, false, __a),
_M_base(__b), _M_start(__s) {
_STLP_ASSERT(__l > 0)
_STLP_ASSERT(__s + __l <= __b->_M_size._M_data)
_M_base->_M_ref_nonnil();
this->_M_tag = _RopeRep::_S_substringfn;
}
virtual ~_Rope_RopeSubstring()
{ _M_base->_M_unref_nonnil(); }
};
/*
* Self-destructing pointers to Rope_rep.
* These are not conventional smart pointers. Their
* only purpose in life is to ensure that unref is called
* on the pointer either at normal exit or if an exception
* is raised. It is the caller's responsibility to
* adjust reference counts when these pointers are initialized
* or assigned to. (This convention significantly reduces
* the number of potentially expensive reference count
* updates.)
*/
template<class _CharT, class _Alloc>
struct _Rope_self_destruct_ptr {
_Rope_RopeRep<_CharT,_Alloc>* _M_ptr;
~_Rope_self_destruct_ptr()
{ _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); }
# ifdef _STLP_USE_EXCEPTIONS
_Rope_self_destruct_ptr() : _M_ptr(0) {}
# else
_Rope_self_destruct_ptr() {}
# endif
_Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {}
_Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; }
_Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; }
operator _Rope_RopeRep<_CharT,_Alloc>*() { return _M_ptr; }
_Rope_self_destruct_ptr<_CharT, _Alloc>&
operator= (_Rope_RopeRep<_CharT,_Alloc>* __x)
{ _M_ptr = __x; return *this; }
};
/*
* Dereferencing a nonconst iterator has to return something
* that behaves almost like a reference. It's not possible to
* return an actual reference since assignment requires extra
* work. And we would get into the same problems as with the
* CD2 version of basic_string.
*/
template<class _CharT, class _Alloc>
class _Rope_char_ref_proxy {
typedef _Rope_char_ref_proxy<_CharT, _Alloc> _Self;
friend class rope<_CharT,_Alloc>;
friend class _Rope_iterator<_CharT,_Alloc>;
friend class _Rope_char_ptr_proxy<_CharT,_Alloc>;
typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr;
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
typedef rope<_CharT,_Alloc> _My_rope;
size_t _M_pos;
_CharT _M_current;
bool _M_current_valid;
_My_rope* _M_root; // The whole rope.
public:
_Rope_char_ref_proxy(_My_rope* __r, size_t __p) :
_M_pos(__p), _M_current_valid(false), _M_root(__r) {}
_Rope_char_ref_proxy(const _Self& __x) :
_M_pos(__x._M_pos), _M_current_valid(false), _M_root(__x._M_root) {}
// Don't preserve cache if the reference can outlive the
// expression. We claim that's not possible without calling
// a copy constructor or generating reference to a proxy
// reference. We declare the latter to have undefined semantics.
_Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c)
: _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) {}
inline operator _CharT () const;
_Self& operator= (_CharT __c);
_Rope_char_ptr_proxy<_CharT, _Alloc> operator& () const;
_Self& operator= (const _Self& __c) {
return operator=((_CharT)__c);
}
};
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
template<class _CharT, class __Alloc>
inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a,
_Rope_char_ref_proxy <_CharT, __Alloc > __b) {
_CharT __tmp = __a;
__a = __b;
__b = __tmp;
}
#else
// There is no really acceptable way to handle this. The default
// definition of swap doesn't work for proxy references.
// It can't really be made to work, even with ugly hacks, since
// the only unusual operation it uses is the copy constructor, which
// is needed for other purposes. We provide a macro for
// full specializations, and instantiate the most common case.
# define _ROPE_SWAP_SPECIALIZATION(_CharT, __Alloc) \
inline void swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a, \
_Rope_char_ref_proxy <_CharT, __Alloc > __b) { \
_CharT __tmp = __a; \
__a = __b; \
__b = __tmp; \
}
_ROPE_SWAP_SPECIALIZATION(char, allocator<char>)
# ifndef _STLP_NO_WCHAR_T
_ROPE_SWAP_SPECIALIZATION(wchar_t, allocator<wchar_t>)
# endif
#endif /* !_STLP_FUNCTION_TMPL_PARTIAL_ORDER */
template<class _CharT, class _Alloc>
class _Rope_char_ptr_proxy {
// XXX this class should be rewritten.
public:
typedef _Rope_char_ptr_proxy<_CharT, _Alloc> _Self;
friend class _Rope_char_ref_proxy<_CharT,_Alloc>;
size_t _M_pos;
rope<_CharT,_Alloc>* _M_root; // The whole rope.
_Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x)
: _M_pos(__x._M_pos), _M_root(__x._M_root) {}
_Rope_char_ptr_proxy(const _Self& __x)
: _M_pos(__x._M_pos), _M_root(__x._M_root) {}
_Rope_char_ptr_proxy() {}
_Rope_char_ptr_proxy(_CharT* __x) : _M_pos(0), _M_root(0) {
_STLP_ASSERT(0 == __x)
}
_Self& operator= (const _Self& __x) {
_M_pos = __x._M_pos;
_M_root = __x._M_root;
return *this;
}
_Rope_char_ref_proxy<_CharT,_Alloc> operator*() const {
return _Rope_char_ref_proxy<_CharT,_Alloc>(_M_root, _M_pos);
}
};
/*
* Rope iterators:
* Unlike in the C version, we cache only part of the stack
* for rope iterators, since they must be efficiently copyable.
* When we run out of cache, we have to reconstruct the iterator
* value.
* Pointers from iterators are not included in reference counts.
* Iterators are assumed to be thread private. Ropes can
* be shared.
*/
template<class _CharT, class _Alloc>
class _Rope_iterator_base
/* : public random_access_iterator<_CharT, ptrdiff_t> */
{
friend class rope<_CharT,_Alloc>;
typedef _Rope_iterator_base<_CharT, _Alloc> _Self;
typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcat;
public:
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
enum { _S_path_cache_len = 4 }; // Must be <= 9 because of _M_path_direction.
enum { _S_iterator_buf_len = 15 };
size_t _M_current_pos;
// The whole rope.
_RopeRep* _M_root;
// Starting position for current leaf
size_t _M_leaf_pos;
// Buffer possibly containing current char.
_CharT* _M_buf_start;
// Pointer to current char in buffer, != 0 ==> buffer valid.
_CharT* _M_buf_ptr;
// One past __last valid char in buffer.
_CharT* _M_buf_end;
// What follows is the path cache. We go out of our
// way to make this compact.
// Path_end contains the bottom section of the path from
// the root to the current leaf.
struct {
# if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
_RopeRep const*_M_data[4];
# else
_RopeRep const*_M_data[_S_path_cache_len];
# endif
} _M_path_end;
// Last valid __pos in path_end;
// _M_path_end[0] ... _M_path_end[_M_leaf_index-1]
// point to concatenation nodes.
int _M_leaf_index;
// (_M_path_directions >> __i) & 1 is 1
// if we got from _M_path_end[leaf_index - __i - 1]
// to _M_path_end[leaf_index - __i] by going to the
// __right. Assumes path_cache_len <= 9.
unsigned char _M_path_directions;
// Short buffer for surrounding chars.
// This is useful primarily for
// RopeFunctions. We put the buffer
// here to avoid locking in the
// multithreaded case.
// The cached path is generally assumed to be valid
// only if the buffer is valid.
struct {
# if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
_CharT _M_data[15];
# else
_CharT _M_data[_S_iterator_buf_len];
# endif
} _M_tmp_buf;
// Set buffer contents given path cache.
static void _S_setbuf(_Rope_iterator_base<_CharT, _Alloc>& __x);
// Set buffer contents and path cache.
static void _S_setcache(_Rope_iterator_base<_CharT, _Alloc>& __x);
// As above, but assumes path cache is valid for previous posn.
static void _S_setcache_for_incr(_Rope_iterator_base<_CharT, _Alloc>& __x);
_Rope_iterator_base() {}
_Rope_iterator_base(_RopeRep* __root, size_t __pos)
: _M_current_pos(__pos),_M_root(__root), _M_buf_ptr(0) {}
void _M_incr(size_t __n);
void _M_decr(size_t __n);
public:
size_t index() const { return _M_current_pos; }
private:
void _M_copy_buf(const _Self& __x) {
_M_tmp_buf = __x._M_tmp_buf;
if (__x._M_buf_start == __x._M_tmp_buf._M_data) {
_M_buf_start = _M_tmp_buf._M_data;
_M_buf_end = _M_buf_start + (__x._M_buf_end - __x._M_buf_start);
_M_buf_ptr = _M_buf_start + (__x._M_buf_ptr - __x._M_buf_start);
} else {
_M_buf_end = __x._M_buf_end;
}
}
public:
_Rope_iterator_base(const _Self& __x) :
_M_current_pos(__x._M_current_pos),
_M_root(__x._M_root),
_M_leaf_pos( __x._M_leaf_pos ),
_M_buf_start(__x._M_buf_start),
_M_buf_ptr(__x._M_buf_ptr),
_M_path_end(__x._M_path_end),
_M_leaf_index(__x._M_leaf_index),
_M_path_directions(__x._M_path_directions)
{
if (0 != __x._M_buf_ptr) {
_M_copy_buf(__x);
}
}
_Self& operator = (const _Self& __x)
{
_M_current_pos = __x._M_current_pos;
_M_root = __x._M_root;
_M_buf_start = __x._M_buf_start;
_M_buf_ptr = __x._M_buf_ptr;
_M_path_end = __x._M_path_end;
_M_leaf_index = __x._M_leaf_index;
_M_path_directions = __x._M_path_directions;
_M_leaf_pos = __x._M_leaf_pos;
if (0 != __x._M_buf_ptr) {
_M_copy_buf(__x);
}
return *this;
}
};
template<class _CharT, class _Alloc> class _Rope_iterator;
template<class _CharT, class _Alloc>
class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> {
friend class rope<_CharT,_Alloc>;
typedef _Rope_const_iterator<_CharT, _Alloc> _Self;
typedef _Rope_iterator_base<_CharT,_Alloc> _Base;
// protected:
public:
# ifndef _STLP_HAS_NO_NAMESPACES
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
// The one from the base class may not be directly visible.
# endif
_Rope_const_iterator(const _RopeRep* __root, size_t __pos):
_Rope_iterator_base<_CharT,_Alloc>(__CONST_CAST(_RopeRep*,__root), __pos)
// Only nonconst iterators modify root ref count
{}
public:
typedef _CharT reference; // Really a value. Returning a reference
// Would be a mess, since it would have
// to be included in refcount.
typedef const _CharT* pointer;
typedef _CharT value_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag iterator_category;
public:
_Rope_const_iterator() {}
_Rope_const_iterator(const _Self& __x) :
_Rope_iterator_base<_CharT,_Alloc>(__x) { }
_Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x):
_Rope_iterator_base<_CharT,_Alloc>(__x) {}
_Rope_const_iterator(const rope<_CharT,_Alloc>& __r, size_t __pos) :
_Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr._M_data, __pos) {}
_Self& operator= (const _Self& __x) {
_Base::operator=(__x);
return *this;
}
reference operator*() {
if (0 == this->_M_buf_ptr)
#if !defined (__DMC__)
_S_setcache(*this);
#else
{ _Rope_iterator_base<_CharT, _Alloc>* __x = this; _S_setcache(*__x); }
#endif
return *(this->_M_buf_ptr);
}
_Self& operator++()
{
if ( this->_M_buf_ptr != 0 ) {
_CharT *__next = this->_M_buf_ptr + 1;
if ( __next < this->_M_buf_end ) {
this->_M_buf_ptr = __next;
++this->_M_current_pos;
return *this;
}
}
this->_M_incr(1);
return *this;
}
_Self& operator+=(ptrdiff_t __n) {
if (__n >= 0) {
this->_M_incr(__n);
} else {
this->_M_decr(-__n);
}
return *this;
}
_Self& operator--() {
this->_M_decr(1);
return *this;
}
_Self& operator-=(ptrdiff_t __n) {
if (__n >= 0) {
this->_M_decr(__n);
} else {
this->_M_incr(-__n);
}
return *this;
}
_Self operator++(int) {
size_t __old_pos = this->_M_current_pos;
this->_M_incr(1);
return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
// This makes a subsequent dereference expensive.
// Perhaps we should instead copy the iterator
// if it has a valid cache?
}
_Self operator--(int) {
size_t __old_pos = this->_M_current_pos;
this->_M_decr(1);
return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
}
inline reference operator[](size_t __n);
};
template<class _CharT, class _Alloc>
class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> {
friend class rope<_CharT,_Alloc>;
typedef _Rope_iterator<_CharT, _Alloc> _Self;
typedef _Rope_iterator_base<_CharT,_Alloc> _Base;
typedef _Rope_RopeRep<_CharT,_Alloc> _RopeRep;
public:
rope<_CharT,_Alloc>* _M_root_rope;
// root is treated as a cached version of this,
// and is used to detect changes to the underlying
// rope.
// Root is included in the reference count.
// This is necessary so that we can detect changes reliably.
// Unfortunately, it requires careful bookkeeping for the
// nonGC case.
_Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos);
void _M_check();
public:
typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference;
typedef _Rope_char_ref_proxy<_CharT,_Alloc>* pointer;
typedef _CharT value_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag iterator_category;
public:
~_Rope_iterator() { //*TY 5/6/00 - added dtor to balance reference count
_RopeRep::_S_unref(this->_M_root);
}
rope<_CharT,_Alloc>& container() { return *_M_root_rope; }
_Rope_iterator() {
this->_M_root = 0; // Needed for reference counting.
}
_Rope_iterator(const _Self& __x) :
_Rope_iterator_base<_CharT,_Alloc>(__x) {
_M_root_rope = __x._M_root_rope;
_RopeRep::_S_ref(this->_M_root);
}
_Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos);
_Self& operator= (const _Self& __x) {
_RopeRep* __old = this->_M_root;
_RopeRep::_S_ref(__x._M_root);
_Base::operator=(__x);
_M_root_rope = __x._M_root_rope;
_RopeRep::_S_unref(__old);
return *this;
}
reference operator*() {
_M_check();
if (0 == this->_M_buf_ptr) {
return reference(_M_root_rope, this->_M_current_pos);
} else {
return reference(_M_root_rope, this->_M_current_pos, *(this->_M_buf_ptr));
}
}
_Self& operator++() {
this->_M_incr(1);
return *this;
}
_Self& operator+=(ptrdiff_t __n) {
if (__n >= 0) {
this->_M_incr(__n);
} else {
this->_M_decr(-__n);
}
return *this;
}
_Self& operator--() {
this->_M_decr(1);
return *this;
}
_Self& operator-=(ptrdiff_t __n) {
if (__n >= 0) {
this->_M_decr(__n);
} else {
this->_M_incr(-__n);
}
return *this;
}
_Self operator++(int) {
size_t __old_pos = this->_M_current_pos;
this->_M_incr(1);
return _Self(_M_root_rope, __old_pos);
}
_Self operator--(int) {
size_t __old_pos = this->_M_current_pos;
this->_M_decr(1);
return _Self(_M_root_rope, __old_pos);
}
reference operator[](ptrdiff_t __n) {
return reference(_M_root_rope, this->_M_current_pos + __n);
}
};
# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
template <class _CharT, class _Alloc>
inline random_access_iterator_tag
iterator_category(const _Rope_iterator<_CharT,_Alloc>&) { return random_access_iterator_tag();}
template <class _CharT, class _Alloc>
inline _CharT* value_type(const _Rope_iterator<_CharT,_Alloc>&) { return 0; }
template <class _CharT, class _Alloc>
inline ptrdiff_t* distance_type(const _Rope_iterator<_CharT,_Alloc>&) { return 0; }
template <class _CharT, class _Alloc>
inline random_access_iterator_tag
iterator_category(const _Rope_const_iterator<_CharT,_Alloc>&) { return random_access_iterator_tag(); }
template <class _CharT, class _Alloc>
inline _CharT* value_type(const _Rope_const_iterator<_CharT,_Alloc>&) { return 0; }
template <class _CharT, class _Alloc>
inline ptrdiff_t* distance_type(const _Rope_const_iterator<_CharT,_Alloc>&) { return 0; }
#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
template <class _CharT, class _Alloc, class _CharConsumer>
bool _S_apply_to_pieces(_CharConsumer& __c,
_Rope_RopeRep<_CharT, _Alloc> *__r,
size_t __begin, size_t __end);
// begin and end are assumed to be in range.
template <class _CharT, class _Alloc>
class rope
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
: public __stlport_class<rope<_CharT, _Alloc> >
#endif
{
typedef rope<_CharT,_Alloc> _Self;
public:
typedef _CharT value_type;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef _CharT const_reference;
typedef const _CharT* const_pointer;
typedef _Rope_iterator<_CharT,_Alloc> iterator;
typedef _Rope_const_iterator<_CharT,_Alloc> const_iterator;
typedef _Rope_char_ref_proxy<_CharT,_Alloc> reference;
typedef _Rope_char_ptr_proxy<_CharT,_Alloc> pointer;
friend class _Rope_iterator<_CharT,_Alloc>;
friend class _Rope_const_iterator<_CharT,_Alloc>;
friend struct _Rope_RopeRep<_CharT,_Alloc>;
friend class _Rope_iterator_base<_CharT,_Alloc>;
friend class _Rope_char_ptr_proxy<_CharT,_Alloc>;
friend class _Rope_char_ref_proxy<_CharT,_Alloc>;
friend struct _Rope_RopeSubstring<_CharT,_Alloc>;
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
protected:
typedef _CharT* _Cstrptr;
static _CharT _S_empty_c_str[1];
enum { _S_copy_max = 23 };
// For strings shorter than _S_copy_max, we copy to
// concatenate.
typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
typedef typename _RopeRep::_IsBasicCharType _IsBasicCharType;
public:
_STLP_FORCE_ALLOCATORS(_CharT, _Alloc)
typedef _Alloc allocator_type;
public:
// The only data member of a rope:
_STLP_PRIV _STLP_alloc_proxy<_RopeRep*, _CharT, allocator_type> _M_tree_ptr;
public:
allocator_type get_allocator() const { return allocator_type(_M_tree_ptr); }
public:
typedef _Rope_RopeConcatenation<_CharT,_Alloc> _RopeConcatenation;
typedef _Rope_RopeLeaf<_CharT,_Alloc> _RopeLeaf;
typedef _Rope_RopeFunction<_CharT,_Alloc> _RopeFunction;
typedef _Rope_RopeSubstring<_CharT,_Alloc> _RopeSubstring;
// Retrieve a character at the indicated position.
static _CharT _S_fetch(_RopeRep* __r, size_type __pos);
// Obtain a pointer to the character at the indicated position.
// The pointer can be used to change the character.
// If such a pointer cannot be produced, as is frequently the
// case, 0 is returned instead.
// (Returns nonzero only if all nodes in the path have a refcount
// of 1.)
static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos);
static void _S_unref(_RopeRep* __t) {
_RopeRep::_S_unref(__t);
}
static void _S_ref(_RopeRep* __t) {
_RopeRep::_S_ref(__t);
}
typedef _Rope_self_destruct_ptr<_CharT,_Alloc> _Self_destruct_ptr;
// _Result is counted in refcount.
static _RopeRep* _S_substring(_RopeRep* __base,
size_t __start, size_t __endp1);
static _RopeRep* _S_concat_char_iter(_RopeRep* __r,
const _CharT* __iter, size_t __slen);
// Concatenate rope and char ptr, copying __s.
// Should really take an arbitrary iterator.
// Result is counted in refcount.
static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r,
const _CharT* __iter, size_t __slen);
// As above, but one reference to __r is about to be
// destroyed. Thus the pieces may be recycled if all
// relevent reference counts are 1.
// General concatenation on _RopeRep. _Result
// has refcount of 1. Adjusts argument refcounts.
static _RopeRep* _S_concat_rep(_RopeRep* __left, _RopeRep* __right);
public:
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _CharConsumer>
#else
typedef _Rope_char_consumer<_CharT> _CharConsumer;
#endif
void apply_to_pieces(size_t __begin, size_t __end,
_CharConsumer& __c) const
{ _S_apply_to_pieces(__c, _M_tree_ptr._M_data, __begin, __end); }
protected:
static size_t _S_rounded_up_size(size_t __n)
{ return _RopeRep::_S_rounded_up_size(__n); }
// Allocate and construct a RopeLeaf using the supplied allocator
// Takes ownership of s instead of copying.
static _RopeLeaf* _S_new_RopeLeaf(_CharT *__s,
size_t _p_size, allocator_type __a) {
_RopeLeaf* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a,
_RopeLeaf).allocate(1);
_STLP_TRY {
new(__space) _RopeLeaf(__s, _p_size, __a);
}
_STLP_UNWIND(_STLP_CREATE_ALLOCATOR(allocator_type,__a,
_RopeLeaf).deallocate(__space, 1))
return __space;
}
static _RopeConcatenation* _S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right,
allocator_type __a) {
_RopeConcatenation* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a,
_RopeConcatenation).allocate(1);
return new(__space) _RopeConcatenation(__left, __right, __a);
}
static _RopeFunction* _S_new_RopeFunction(char_producer<_CharT>* __f,
size_t _p_size, bool __d, allocator_type __a) {
_RopeFunction* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a,
_RopeFunction).allocate(1);
return new(__space) _RopeFunction(__f, _p_size, __d, __a);
}
static _RopeSubstring* _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,
size_t __l, allocator_type __a) {
_RopeSubstring* __space = _STLP_CREATE_ALLOCATOR(allocator_type, __a,
_RopeSubstring).allocate(1);
return new(__space) _RopeSubstring(__b, __s, __l, __a);
}
static
_RopeLeaf* _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s,
size_t _p_size, allocator_type __a) {
if (0 == _p_size) return 0;
_CharT* __buf = _STLP_CREATE_ALLOCATOR(allocator_type,__a, _CharT).allocate(_S_rounded_up_size(_p_size));
_STLP_PRIV __ucopy_n(__s, _p_size, __buf);
_S_construct_null(__buf + _p_size);
_STLP_TRY {
return _S_new_RopeLeaf(__buf, _p_size, __a);
}
_STLP_UNWIND(_RopeRep::_S_free_string(__buf, _p_size, __a))
_STLP_RET_AFTER_THROW(0)
}
// Concatenation of nonempty strings.
// Always builds a concatenation node.
// Rebalances if the result is too deep.
// Result has refcount 1.
// Does not increment left and right ref counts even though
// they are referenced.
static _RopeRep*
_S_tree_concat(_RopeRep* __left, _RopeRep* __right);
// Concatenation helper functions
static _RopeLeaf*
_S_leaf_concat_char_iter(_RopeLeaf* __r,
const _CharT* __iter, size_t __slen);
// Concatenate by copying leaf.
// should take an arbitrary iterator
// result has refcount 1.
static _RopeLeaf* _S_destr_leaf_concat_char_iter
(_RopeLeaf* __r, const _CharT* __iter, size_t __slen);
// A version that potentially clobbers __r if __r->_M_ref_count == 1.
// A helper function for exponentiating strings.
// This uses a nonstandard refcount convention.
// The result has refcount 0.
typedef _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc> _Concat_fn;
#if !defined (__GNUC__) || (__GNUC__ < 3)
friend _Concat_fn;
#else
friend struct _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc>;
#endif
public:
static size_t _S_char_ptr_len(const _CharT* __s) {
return char_traits<_CharT>::length(__s);
}
public: /* for operators */
rope(_RopeRep* __t, const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, __t) { }
private:
// Copy __r to the _CharT buffer.
// Returns __buffer + __r->_M_size._M_data.
// Assumes that buffer is uninitialized.
static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer);
// Again, with explicit starting position and length.
// Assumes that buffer is uninitialized.
static _CharT* _S_flatten(_RopeRep* __r,
size_t __start, size_t __len,
_CharT* __buffer);
// fbp : HP aCC prohibits access to protected min_len from within static methods ( ?? )
public:
static const unsigned long _S_min_len[__ROPE_DEPTH_SIZE];
protected:
static bool _S_is_balanced(_RopeRep* __r)
{ return (__r->_M_size._M_data >= _S_min_len[__r->_M_depth]); }
static bool _S_is_almost_balanced(_RopeRep* __r) {
return (__r->_M_depth == 0 ||
__r->_M_size._M_data >= _S_min_len[__r->_M_depth - 1]);
}
static bool _S_is_roughly_balanced(_RopeRep* __r) {
return (__r->_M_depth <= 1 ||
__r->_M_size._M_data >= _S_min_len[__r->_M_depth - 2]);
}
// Assumes the result is not empty.
static _RopeRep* _S_concat_and_set_balanced(_RopeRep* __left,
_RopeRep* __right) {
_RopeRep* __result = _S_concat_rep(__left, __right);
if (_S_is_balanced(__result)) __result->_M_is_balanced = true;
return __result;
}
// The basic rebalancing operation. Logically copies the
// rope. The result has refcount of 1. The client will
// usually decrement the reference count of __r.
// The result is within height 2 of balanced by the above
// definition.
static _RopeRep* _S_balance(_RopeRep* __r);
// Add all unbalanced subtrees to the forest of balanceed trees.
// Used only by balance.
static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest);
// Add __r to forest, assuming __r is already balanced.
static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest);
#ifdef _STLP_DEBUG
// Print to stdout, exposing structure
static void _S_dump(_RopeRep* __r, int __indent = 0);
#endif
// Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp.
static int _S_compare(const _RopeRep* __x, const _RopeRep* __y);
void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const;
void _M_reset(_RopeRep* __r) {
//if (__r != _M_tree_ptr._M_data) {
_S_unref(_M_tree_ptr._M_data);
_M_tree_ptr._M_data = __r;
//}
}
public:
bool empty() const { return 0 == _M_tree_ptr._M_data; }
// Comparison member function. This is public only for those
// clients that need a ternary comparison. Others
// should use the comparison operators below.
int compare(const _Self& __y) const {
return _S_compare(_M_tree_ptr._M_data, __y._M_tree_ptr._M_data);
}
rope(const _CharT* __s, const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, _S_RopeLeaf_from_unowned_char_ptr(__s, _S_char_ptr_len(__s),__a))
{}
rope(const _CharT* __s, size_t __len,
const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, (_S_RopeLeaf_from_unowned_char_ptr(__s, __len, __a)))
{}
// Should perhaps be templatized with respect to the iterator type
// and use Sequence_buffer. (It should perhaps use sequence_buffer
// even now.)
rope(const _CharT *__s, const _CharT *__e,
const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, _S_RopeLeaf_from_unowned_char_ptr(__s, __e - __s, __a))
{}
rope(const const_iterator& __s, const const_iterator& __e,
const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, _S_substring(__s._M_root, __s._M_current_pos,
__e._M_current_pos))
{}
rope(const iterator& __s, const iterator& __e,
const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, _S_substring(__s._M_root, __s._M_current_pos,
__e._M_current_pos))
{}
rope(_CharT __c, const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, (_RopeRep*)0) {
_CharT* __buf = _M_tree_ptr.allocate(_S_rounded_up_size(1));
_Copy_Construct(__buf, __c);
_S_construct_null(__buf + 1);
_STLP_TRY {
_M_tree_ptr._M_data = _S_new_RopeLeaf(__buf, 1, __a);
}
_STLP_UNWIND(_RopeRep::_S_free_string(__buf, 1, __a))
}
rope(size_t __n, _CharT __c,
const allocator_type& __a = allocator_type()):
_M_tree_ptr(__a, (_RopeRep*)0) {
if (0 == __n)
return;
rope<_CharT,_Alloc> __result;
# define __exponentiate_threshold size_t(32)
_RopeRep* __remainder;
rope<_CharT,_Alloc> __remainder_rope;
// gcc-2.7.2 bugs
typedef _STLP_PRIV _Rope_Concat_fn<_CharT,_Alloc> _Concat_fn;
size_t __exponent = __n / __exponentiate_threshold;
size_t __rest = __n % __exponentiate_threshold;
if (0 == __rest) {
__remainder = 0;
} else {
_CharT* __rest_buffer = _M_tree_ptr.allocate(_S_rounded_up_size(__rest));
uninitialized_fill_n(__rest_buffer, __rest, __c);
_S_construct_null(__rest_buffer + __rest);
_STLP_TRY {
__remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a);
}
_STLP_UNWIND(_RopeRep::_S_free_string(__rest_buffer, __rest, __a))
}
__remainder_rope._M_tree_ptr._M_data = __remainder;
if (__exponent != 0) {
_CharT* __base_buffer = _M_tree_ptr.allocate(_S_rounded_up_size(__exponentiate_threshold));
_RopeLeaf* __base_leaf;
rope<_CharT,_Alloc> __base_rope;
uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c);
_S_construct_null(__base_buffer + __exponentiate_threshold);
_STLP_TRY {
__base_leaf = _S_new_RopeLeaf(__base_buffer,
__exponentiate_threshold, __a);
}
_STLP_UNWIND(_RopeRep::_S_free_string(__base_buffer,
__exponentiate_threshold, __a))
__base_rope._M_tree_ptr._M_data = __base_leaf;
if (1 == __exponent) {
__result = __base_rope;
// One each for base_rope and __result
//_STLP_ASSERT(2 == __result._M_tree_ptr._M_data->_M_ref_count)
} else {
__result = _STLP_PRIV __power(__base_rope, __exponent, _Concat_fn());
}
if (0 != __remainder) {
__result += __remainder_rope;
}
} else {
__result = __remainder_rope;
}
_M_tree_ptr._M_data = __result._M_tree_ptr._M_data;
_M_tree_ptr._M_data->_M_ref_nonnil();
# undef __exponentiate_threshold
}
rope(const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, (_RopeRep*)0) {}
// Construct a rope from a function that can compute its members
rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn,
const allocator_type& __a = allocator_type())
: _M_tree_ptr(__a, (_RopeRep*)0) {
_M_tree_ptr._M_data = (0 == __len) ?
0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a);
}
rope(const _Self& __x)
: _M_tree_ptr(__x._M_tree_ptr, __x._M_tree_ptr._M_data) {
_S_ref(_M_tree_ptr._M_data);
}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
rope(__move_source<_Self> __src)
: _M_tree_ptr(__src.get()._M_tree_ptr, __src.get()._M_tree_ptr._M_data) {
__src.get()._M_tree_ptr._M_data = 0;
}
#endif
~rope() {
_S_unref(_M_tree_ptr._M_data);
}
_Self& operator=(const _Self& __x) {
_STLP_ASSERT(get_allocator() == __x.get_allocator())
_S_ref(__x._M_tree_ptr._M_data);
_M_reset(__x._M_tree_ptr._M_data);
return *this;
}
void clear() {
_S_unref(_M_tree_ptr._M_data);
_M_tree_ptr._M_data = 0;
}
void push_back(_CharT __x) {
_M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, &__x, 1));
}
void pop_back() {
_RopeRep* __old = _M_tree_ptr._M_data;
_M_tree_ptr._M_data =
_S_substring(_M_tree_ptr._M_data, 0, _M_tree_ptr._M_data->_M_size._M_data - 1);
_S_unref(__old);
}
_CharT back() const {
return _S_fetch(_M_tree_ptr._M_data, _M_tree_ptr._M_data->_M_size._M_data - 1);
}
void push_front(_CharT __x) {
_RopeRep* __old = _M_tree_ptr._M_data;
_RopeRep* __left =
_S_RopeLeaf_from_unowned_char_ptr(&__x, 1, _M_tree_ptr);
_STLP_TRY {
_M_tree_ptr._M_data = _S_concat_rep(__left, _M_tree_ptr._M_data);
_S_unref(__old);
_S_unref(__left);
}
_STLP_UNWIND(_S_unref(__left))
}
void pop_front() {
_RopeRep* __old = _M_tree_ptr._M_data;
_M_tree_ptr._M_data = _S_substring(_M_tree_ptr._M_data, 1, _M_tree_ptr._M_data->_M_size._M_data);
_S_unref(__old);
}
_CharT front() const {
return _S_fetch(_M_tree_ptr._M_data, 0);
}
void balance() {
_RopeRep* __old = _M_tree_ptr._M_data;
_M_tree_ptr._M_data = _S_balance(_M_tree_ptr._M_data);
_S_unref(__old);
}
void copy(_CharT* __buffer) const {
_STLP_STD::_Destroy_Range(__buffer, __buffer + size());
_S_flatten(_M_tree_ptr._M_data, __buffer);
}
/*
* This is the copy function from the standard, but
* with the arguments reordered to make it consistent with the
* rest of the interface.
* Note that this guaranteed not to compile if the draft standard
* order is assumed.
*/
size_type copy(size_type __pos, size_type __n, _CharT* __buffer) const {
size_t _p_size = size();
size_t __len = (__pos + __n > _p_size? _p_size - __pos : __n);
_STLP_STD::_Destroy_Range(__buffer, __buffer + __len);
_S_flatten(_M_tree_ptr._M_data, __pos, __len, __buffer);
return __len;
}
# ifdef _STLP_DEBUG
// Print to stdout, exposing structure. May be useful for
// performance debugging.
void dump() {
_S_dump(_M_tree_ptr._M_data);
}
# endif
// Convert to 0 terminated string in new allocated memory.
// Embedded 0s in the input do not terminate the copy.
const _CharT* c_str() const;
// As above, but also use the flattened representation as the
// the new rope representation.
const _CharT* replace_with_c_str();
// Reclaim memory for the c_str generated flattened string.
// Intentionally undocumented, since it's hard to say when this
// is safe for multiple threads.
void delete_c_str () {
if (0 == _M_tree_ptr._M_data) return;
if (_RopeRep::_S_leaf == _M_tree_ptr._M_data->_M_tag &&
((_RopeLeaf*)_M_tree_ptr._M_data)->_M_data ==
_M_tree_ptr._M_data->_M_c_string) {
// Representation shared
return;
}
_M_tree_ptr._M_data->_M_free_c_string();
_M_tree_ptr._M_data->_M_c_string = 0;
}
_CharT operator[] (size_type __pos) const {
return _S_fetch(_M_tree_ptr._M_data, __pos);
}
_CharT at(size_type __pos) const {
if (__pos >= size()) _M_throw_out_of_range();
return (*this)[__pos];
}
const_iterator begin() const {
return(const_iterator(_M_tree_ptr._M_data, 0));
}
// An easy way to get a const iterator from a non-const container.
const_iterator const_begin() const {
return(const_iterator(_M_tree_ptr._M_data, 0));
}
const_iterator end() const {
return(const_iterator(_M_tree_ptr._M_data, size()));
}
const_iterator const_end() const {
return(const_iterator(_M_tree_ptr._M_data, size()));
}
size_type size() const {
return(0 == _M_tree_ptr._M_data? 0 : _M_tree_ptr._M_data->_M_size._M_data);
}
size_type length() const {
return size();
}
size_type max_size() const {
return _S_min_len[__ROPE_MAX_DEPTH-1] - 1;
// Guarantees that the result can be sufficiently
// balanced. Longer ropes will probably still work,
// but it's harder to make guarantees.
}
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator const_rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
const_reverse_iterator const_rend() const {
return const_reverse_iterator(begin());
}
// The symmetric cases are intentionally omitted, since they're presumed
// to be less common, and we don't handle them as well.
// The following should really be templatized.
// The first argument should be an input iterator or
// forward iterator with value_type _CharT.
_Self& append(const _CharT* __iter, size_t __n) {
_M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, __iter, __n));
return *this;
}
_Self& append(const _CharT* __c_string) {
size_t __len = _S_char_ptr_len(__c_string);
append(__c_string, __len);
return *this;
}
_Self& append(const _CharT* __s, const _CharT* __e) {
_M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, __s, __e - __s));
return *this;
}
_Self& append(const_iterator __s, const_iterator __e) {
_STLP_ASSERT(__s._M_root == __e._M_root)
_STLP_ASSERT(get_allocator() == __s._M_root->get_allocator())
_Self_destruct_ptr __appendee(_S_substring(__s._M_root, __s._M_current_pos, __e._M_current_pos));
_M_reset(_S_concat_rep(_M_tree_ptr._M_data, (_RopeRep*)__appendee));
return *this;
}
_Self& append(_CharT __c) {
_M_reset(_S_destr_concat_char_iter(_M_tree_ptr._M_data, &__c, 1));
return *this;
}
_Self& append() { return append(_CharT()); } // XXX why?
_Self& append(const _Self& __y) {
_STLP_ASSERT(__y.get_allocator() == get_allocator())
_M_reset(_S_concat_rep(_M_tree_ptr._M_data, __y._M_tree_ptr._M_data));
return *this;
}
_Self& append(size_t __n, _CharT __c) {
rope<_CharT,_Alloc> __last(__n, __c);
return append(__last);
}
void swap(_Self& __b) {
_M_tree_ptr.swap(__b._M_tree_ptr);
}
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
protected:
// Result is included in refcount.
static _RopeRep* replace(_RopeRep* __old, size_t __pos1,
size_t __pos2, _RopeRep* __r) {
if (0 == __old) { _S_ref(__r); return __r; }
_Self_destruct_ptr __left(_S_substring(__old, 0, __pos1));
_Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size._M_data));
_STLP_MPWFIX_TRY //*TY 06/01/2000 -
_RopeRep* __result;
if (0 == __r) {
__result = _S_concat_rep(__left, __right);
} else {
_STLP_ASSERT(__old->get_allocator() == __r->get_allocator())
_Self_destruct_ptr __left_result(_S_concat_rep(__left, __r));
__result = _S_concat_rep(__left_result, __right);
}
return __result;
_STLP_MPWFIX_CATCH //*TY 06/01/2000 -
}
public:
void insert(size_t __p, const _Self& __r) {
if (__p > size()) _M_throw_out_of_range();
_STLP_ASSERT(get_allocator() == __r.get_allocator())
_M_reset(replace(_M_tree_ptr._M_data, __p, __p, __r._M_tree_ptr._M_data));
}
void insert(size_t __p, size_t __n, _CharT __c) {
rope<_CharT,_Alloc> __r(__n,__c);
insert(__p, __r);
}
void insert(size_t __p, const _CharT* __i, size_t __n) {
if (__p > size()) _M_throw_out_of_range();
_Self_destruct_ptr __left(_S_substring(_M_tree_ptr._M_data, 0, __p));
_Self_destruct_ptr __right(_S_substring(_M_tree_ptr._M_data, __p, size()));
_Self_destruct_ptr __left_result(
_S_concat_char_iter(__left, __i, __n));
// _S_ destr_concat_char_iter should be safe here.
// But as it stands it's probably not a win, since __left
// is likely to have additional references.
_M_reset(_S_concat_rep(__left_result, __right));
}
void insert(size_t __p, const _CharT* __c_string) {
insert(__p, __c_string, _S_char_ptr_len(__c_string));
}
void insert(size_t __p, _CharT __c) {
insert(__p, &__c, 1);
}
void insert(size_t __p) {
_CharT __c = _CharT();
insert(__p, &__c, 1);
}
void insert(size_t __p, const _CharT* __i, const _CharT* __j) {
_Self __r(__i, __j);
insert(__p, __r);
}
void insert(size_t __p, const const_iterator& __i,
const const_iterator& __j) {
_Self __r(__i, __j);
insert(__p, __r);
}
void insert(size_t __p, const iterator& __i,
const iterator& __j) {
_Self __r(__i, __j);
insert(__p, __r);
}
// (position, length) versions of replace operations:
void replace(size_t __p, size_t __n, const _Self& __r) {
if (__p > size()) _M_throw_out_of_range();
_M_reset(replace(_M_tree_ptr._M_data, __p, __p + __n, __r._M_tree_ptr._M_data));
}
void replace(size_t __p, size_t __n,
const _CharT* __i, size_t __i_len) {
_Self __r(__i, __i_len);
replace(__p, __n, __r);
}
void replace(size_t __p, size_t __n, _CharT __c) {
_Self __r(__c);
replace(__p, __n, __r);
}
void replace(size_t __p, size_t __n, const _CharT* __c_string) {
_Self __r(__c_string);
replace(__p, __n, __r);
}
void replace(size_t __p, size_t __n,
const _CharT* __i, const _CharT* __j) {
_Self __r(__i, __j);
replace(__p, __n, __r);
}
void replace(size_t __p, size_t __n,
const const_iterator& __i, const const_iterator& __j) {
_Self __r(__i, __j);
replace(__p, __n, __r);
}
void replace(size_t __p, size_t __n,
const iterator& __i, const iterator& __j) {
_Self __r(__i, __j);
replace(__p, __n, __r);
}
// Single character variants:
void replace(size_t __p, _CharT __c) {
if (__p > size()) _M_throw_out_of_range();
iterator __i(this, __p);
*__i = __c;
}
void replace(size_t __p, const _Self& __r) {
replace(__p, 1, __r);
}
void replace(size_t __p, const _CharT* __i, size_t __i_len) {
replace(__p, 1, __i, __i_len);
}
void replace(size_t __p, const _CharT* __c_string) {
replace(__p, 1, __c_string);
}
void replace(size_t __p, const _CharT* __i, const _CharT* __j) {
replace(__p, 1, __i, __j);
}
void replace(size_t __p, const const_iterator& __i,
const const_iterator& __j) {
replace(__p, 1, __i, __j);
}
void replace(size_t __p, const iterator& __i,
const iterator& __j) {
replace(__p, 1, __i, __j);
}
// Erase, (position, size) variant.
void erase(size_t __p, size_t __n) {
if (__p > size()) _M_throw_out_of_range();
_M_reset(replace(_M_tree_ptr._M_data, __p, __p + __n, 0));
}
// Erase, single character
void erase(size_t __p) {
erase(__p, __p + 1);
}
// Insert, iterator variants.
iterator insert(const iterator& __p, const _Self& __r)
{ insert(__p.index(), __r); return __p; }
iterator insert(const iterator& __p, size_t __n, _CharT __c)
{ insert(__p.index(), __n, __c); return __p; }
iterator insert(const iterator& __p, _CharT __c)
{ insert(__p.index(), __c); return __p; }
iterator insert(const iterator& __p )
{ insert(__p.index()); return __p; }
iterator insert(const iterator& __p, const _CharT* c_string)
{ insert(__p.index(), c_string); return __p; }
iterator insert(const iterator& __p, const _CharT* __i, size_t __n)
{ insert(__p.index(), __i, __n); return __p; }
iterator insert(const iterator& __p, const _CharT* __i,
const _CharT* __j)
{ insert(__p.index(), __i, __j); return __p; }
iterator insert(const iterator& __p,
const const_iterator& __i, const const_iterator& __j)
{ insert(__p.index(), __i, __j); return __p; }
iterator insert(const iterator& __p,
const iterator& __i, const iterator& __j)
{ insert(__p.index(), __i, __j); return __p; }
// Replace, range variants.
void replace(const iterator& __p, const iterator& __q,
const _Self& __r)
{ replace(__p.index(), __q.index() - __p.index(), __r); }
void replace(const iterator& __p, const iterator& __q, _CharT __c)
{ replace(__p.index(), __q.index() - __p.index(), __c); }
void replace(const iterator& __p, const iterator& __q,
const _CharT* __c_string)
{ replace(__p.index(), __q.index() - __p.index(), __c_string); }
void replace(const iterator& __p, const iterator& __q,
const _CharT* __i, size_t __n)
{ replace(__p.index(), __q.index() - __p.index(), __i, __n); }
void replace(const iterator& __p, const iterator& __q,
const _CharT* __i, const _CharT* __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
void replace(const iterator& __p, const iterator& __q,
const const_iterator& __i, const const_iterator& __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
void replace(const iterator& __p, const iterator& __q,
const iterator& __i, const iterator& __j)
{ replace(__p.index(), __q.index() - __p.index(), __i, __j); }
// Replace, iterator variants.
void replace(const iterator& __p, const _Self& __r)
{ replace(__p.index(), __r); }
void replace(const iterator& __p, _CharT __c)
{ replace(__p.index(), __c); }
void replace(const iterator& __p, const _CharT* __c_string)
{ replace(__p.index(), __c_string); }
void replace(const iterator& __p, const _CharT* __i, size_t __n)
{ replace(__p.index(), __i, __n); }
void replace(const iterator& __p, const _CharT* __i, const _CharT* __j)
{ replace(__p.index(), __i, __j); }
void replace(const iterator& __p, const_iterator __i,
const_iterator __j)
{ replace(__p.index(), __i, __j); }
void replace(const iterator& __p, iterator __i, iterator __j)
{ replace(__p.index(), __i, __j); }
// Iterator and range variants of erase
iterator erase(const iterator& __p, const iterator& __q) {
size_t __p_index = __p.index();
erase(__p_index, __q.index() - __p_index);
return iterator(this, __p_index);
}
iterator erase(const iterator& __p) {
size_t __p_index = __p.index();
erase(__p_index, 1);
return iterator(this, __p_index);
}
_Self substr(size_t __start, size_t __len = 1) const {
if (__start > size()) _M_throw_out_of_range();
return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start, __start + __len));
}
_Self substr(iterator __start, iterator __end) const {
return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start.index(), __end.index()));
}
_Self substr(iterator __start) const {
size_t __pos = __start.index();
return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __pos, __pos + 1));
}
_Self substr(const_iterator __start, const_iterator __end) const {
// This might eventually take advantage of the cache in the
// iterator.
return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __start.index(), __end.index()));
}
rope<_CharT,_Alloc> substr(const_iterator __start) {
size_t __pos = __start.index();
return rope<_CharT,_Alloc>(_S_substring(_M_tree_ptr._M_data, __pos, __pos + 1));
}
#include <stl/_string_npos.h>
size_type find(const _Self& __s, size_type __pos = 0) const {
if (__pos >= size())
# ifndef _STLP_OLD_ROPE_SEMANTICS
return npos;
# else
return size();
# endif
size_type __result_pos;
const_iterator __result = _STLP_STD::search(const_begin() + (ptrdiff_t)__pos, const_end(), __s.begin(), __s.end() );
__result_pos = __result.index();
# ifndef _STLP_OLD_ROPE_SEMANTICS
if (__result_pos == size()) __result_pos = npos;
# endif
return __result_pos;
}
size_type find(_CharT __c, size_type __pos = 0) const;
size_type find(const _CharT* __s, size_type __pos = 0) const {
size_type __result_pos;
const_iterator __result = _STLP_STD::search(const_begin() + (ptrdiff_t)__pos, const_end(),
__s, __s + _S_char_ptr_len(__s));
__result_pos = __result.index();
# ifndef _STLP_OLD_ROPE_SEMANTICS
if (__result_pos == size()) __result_pos = npos;
# endif
return __result_pos;
}
iterator mutable_begin() {
return(iterator(this, 0));
}
iterator mutable_end() {
return(iterator(this, size()));
}
reverse_iterator mutable_rbegin() {
return reverse_iterator(mutable_end());
}
reverse_iterator mutable_rend() {
return reverse_iterator(mutable_begin());
}
reference mutable_reference_at(size_type __pos) {
return reference(this, __pos);
}
# ifdef __STD_STUFF
reference operator[] (size_type __pos) {
return reference(this, __pos);
}
reference at(size_type __pos) {
if (__pos >= size()) _M_throw_out_of_range();
return (*this)[__pos];
}
void resize(size_type, _CharT) {}
void resize(size_type) {}
void reserve(size_type = 0) {}
size_type capacity() const {
return max_size();
}
// Stuff below this line is dangerous because it's error prone.
// I would really like to get rid of it.
// copy function with funny arg ordering.
size_type copy(_CharT* __buffer, size_type __n,
size_type __pos = 0) const {
return copy(__pos, __n, __buffer);
}
iterator end() { return mutable_end(); }
iterator begin() { return mutable_begin(); }
reverse_iterator rend() { return mutable_rend(); }
reverse_iterator rbegin() { return mutable_rbegin(); }
# else
const_iterator end() { return const_end(); }
const_iterator begin() { return const_begin(); }
const_reverse_iterator rend() { return const_rend(); }
const_reverse_iterator rbegin() { return const_rbegin(); }
# endif
}; //class rope
#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
template <class _CharT, class _Alloc>
const size_t rope<_CharT, _Alloc>::npos = ~(size_t) 0;
#endif
template <class _CharT, class _Alloc>
inline _CharT
_Rope_const_iterator< _CharT, _Alloc>::operator[](size_t __n)
{ return rope<_CharT,_Alloc>::_S_fetch(this->_M_root, this->_M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline bool operator== (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y) {
return (__x._M_current_pos == __y._M_current_pos &&
__x._M_root == __y._M_root);
}
template <class _CharT, class _Alloc>
inline bool operator< (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return (__x._M_current_pos < __y._M_current_pos); }
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
template <class _CharT, class _Alloc>
inline bool operator!= (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return !(__x == __y); }
template <class _CharT, class _Alloc>
inline bool operator> (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return __y < __x; }
template <class _CharT, class _Alloc>
inline bool operator<= (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return !(__y < __x); }
template <class _CharT, class _Alloc>
inline bool operator>= (const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return !(__x < __y); }
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
template <class _CharT, class _Alloc>
inline ptrdiff_t operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x,
const _Rope_const_iterator<_CharT,_Alloc>& __y)
{ return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; }
#if !defined( __MWERKS__ ) || __MWERKS__ >= 0x2000 // dwa 8/21/97 - "ambiguous access to overloaded function" bug.
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT,_Alloc>
operator-(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n)
{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos - __n); }
# endif
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT,_Alloc>
operator+(const _Rope_const_iterator<_CharT,_Alloc>& __x, ptrdiff_t __n)
{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline _Rope_const_iterator<_CharT,_Alloc>
operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT,_Alloc>& __x)
{ return _Rope_const_iterator<_CharT,_Alloc>(__x._M_root, __x._M_current_pos + __n); }
template <class _CharT, class _Alloc>
inline bool operator== (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y) {
return (__x._M_current_pos == __y._M_current_pos &&
__x._M_root_rope == __y._M_root_rope);
}
template <class _CharT, class _Alloc>
inline bool operator< (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return (__x._M_current_pos < __y._M_current_pos); }
#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
template <class _CharT, class _Alloc>
inline bool operator!= (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return !(__x == __y); }
template <class _CharT, class _Alloc>
inline bool operator> (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return __y < __x; }
template <class _CharT, class _Alloc>
inline bool operator<= (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return !(__y < __x); }
template <class _CharT, class _Alloc>
inline bool operator>= (const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return !(__x < __y); }
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
template <class _CharT, class _Alloc>
inline ptrdiff_t operator-(const _Rope_iterator<_CharT,_Alloc>& __x,
const _Rope_iterator<_CharT,_Alloc>& __y)
{ return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; }
#if !defined( __MWERKS__ ) || __MWERKS__ >= 0x2000 // dwa 8/21/97 - "ambiguous access to overloaded function" bug.
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT,_Alloc>
operator-(const _Rope_iterator<_CharT,_Alloc>& __x,
ptrdiff_t __n) {
return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos - __n);
}
# endif
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT,_Alloc>
operator+(const _Rope_iterator<_CharT,_Alloc>& __x,
ptrdiff_t __n) {
return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos + __n);
}
template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT,_Alloc>
operator+(ptrdiff_t __n, const _Rope_iterator<_CharT,_Alloc>& __x) {
return _Rope_iterator<_CharT,_Alloc>(__x._M_root_rope, __x._M_current_pos + __n);
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>
operator+ (const rope<_CharT,_Alloc>& __left,
const rope<_CharT,_Alloc>& __right) {
_STLP_ASSERT(__left.get_allocator() == __right.get_allocator())
return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_rep(__left._M_tree_ptr._M_data, __right._M_tree_ptr._M_data));
// Inlining this should make it possible to keep __left and __right in registers.
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>&
operator+= (rope<_CharT,_Alloc>& __left,
const rope<_CharT,_Alloc>& __right) {
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>
operator+ (const rope<_CharT,_Alloc>& __left,
const _CharT* __right) {
size_t __rlen = rope<_CharT,_Alloc>::_S_char_ptr_len(__right);
return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_char_iter(__left._M_tree_ptr._M_data, __right, __rlen));
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>&
operator+= (rope<_CharT,_Alloc>& __left,
const _CharT* __right) {
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>
operator+ (const rope<_CharT,_Alloc>& __left, _CharT __right) {
return rope<_CharT,_Alloc>(rope<_CharT,_Alloc>::_S_concat_char_iter(__left._M_tree_ptr._M_data, &__right, 1));
}
template <class _CharT, class _Alloc>
inline rope<_CharT,_Alloc>&
operator+= (rope<_CharT,_Alloc>& __left, _CharT __right) {
__left.append(__right);
return __left;
}
template <class _CharT, class _Alloc>
inline bool
operator< (const rope<_CharT,_Alloc>& __left,
const rope<_CharT,_Alloc>& __right) {
return __left.compare(__right) < 0;
}
template <class _CharT, class _Alloc>
inline bool
operator== (const rope<_CharT,_Alloc>& __left,
const rope<_CharT,_Alloc>& __right) {
return __left.compare(__right) == 0;
}
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
template <class _CharT, class _Alloc>
inline bool
operator!= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {
return !(__x == __y);
}
template <class _CharT, class _Alloc>
inline bool
operator> (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {
return __y < __x;
}
template <class _CharT, class _Alloc>
inline bool
operator<= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {
return !(__y < __x);
}
template <class _CharT, class _Alloc>
inline bool
operator>= (const rope<_CharT,_Alloc>& __x, const rope<_CharT,_Alloc>& __y) {
return !(__x < __y);
}
template <class _CharT, class _Alloc>
inline bool operator!= (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,
const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) {
return !(__x == __y);
}
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
template <class _CharT, class _Alloc>
inline bool operator== (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,
const _Rope_char_ptr_proxy<_CharT,_Alloc>& __y) {
return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root);
}
#if !defined (_STLP_USE_NO_IOSTREAMS)
template<class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r);
#endif
typedef rope<char, allocator<char> > crope;
#if defined (_STLP_HAS_WCHAR_T)
typedef rope<wchar_t, allocator<wchar_t> > wrope;
#endif
inline crope::reference __mutable_reference_at(crope& __c, size_t __i)
{ return __c.mutable_reference_at(__i); }
#if defined (_STLP_HAS_WCHAR_T)
inline wrope::reference __mutable_reference_at(wrope& __c, size_t __i)
{ return __c.mutable_reference_at(__i); }
#endif
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
template <class _CharT, class _Alloc>
inline void swap(rope<_CharT,_Alloc>& __x, rope<_CharT,_Alloc>& __y)
{ __x.swap(__y); }
#else
inline void swap(crope& __x, crope& __y) { __x.swap(__y); }
# ifdef _STLP_HAS_WCHAR_T // dwa 8/21/97
inline void swap(wrope& __x, wrope& __y) { __x.swap(__y); }
# endif
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
// Hash functions should probably be revisited later:
_STLP_TEMPLATE_NULL struct hash<crope> {
size_t operator()(const crope& __str) const {
size_t _p_size = __str.size();
if (0 == _p_size) return 0;
return 13*__str[0] + 5*__str[_p_size - 1] + _p_size;
}
};
#if defined (_STLP_HAS_WCHAR_T) // dwa 8/21/97
_STLP_TEMPLATE_NULL struct hash<wrope> {
size_t operator()(const wrope& __str) const {
size_t _p_size = __str.size();
if (0 == _p_size) return 0;
return 13*__str[0] + 5*__str[_p_size - 1] + _p_size;
}
};
#endif
#if (!defined (_STLP_MSVC) || (_STLP_MSVC >= 1310))
// I couldn't get this to work with VC++
template<class _CharT,class _Alloc>
# if defined (__DMC__)
extern
# endif
void _Rope_rotate(_Rope_iterator<_CharT, _Alloc> __first,
_Rope_iterator<_CharT, _Alloc> __middle,
_Rope_iterator<_CharT, _Alloc> __last);
inline void rotate(_Rope_iterator<char, allocator<char> > __first,
_Rope_iterator<char, allocator<char> > __middle,
_Rope_iterator<char, allocator<char> > __last)
{ _Rope_rotate(__first, __middle, __last); }
#endif
template <class _CharT, class _Alloc>
inline _Rope_char_ref_proxy<_CharT, _Alloc>::operator _CharT () const {
if (_M_current_valid) {
return _M_current;
} else {
return _My_rope::_S_fetch(_M_root->_M_tree_ptr._M_data, _M_pos);
}
}
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
template <class _CharT, class _Alloc>
struct __move_traits<rope<_CharT, _Alloc> > {
typedef __true_type implemented;
//Completness depends on the allocator:
typedef typename __move_traits<_Alloc>::complete complete;
};
#endif
_STLP_END_NAMESPACE
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
# include <stl/_rope.c>
#endif
#endif /* _STLP_INTERNAL_ROPE_H */
// Local Variables:
// mode:C++
// End:
| [
"331201091@qq.com"
] | 331201091@qq.com |
9665d519f309d7a075c1d3c027c0e94f1a0ebf3d | f85cfed4ae3c54b5d31b43e10435bb4fc4875d7e | /sc-virt/src/tools/clang/test/OpenMP/critical_codegen.cpp | be749a65f0cb7e42896ef99098c4da514b875417 | [
"NCSA",
"MIT"
] | permissive | archercreat/dta-vs-osc | 2f495f74e0a67d3672c1fc11ecb812d3bc116210 | b39f4d4eb6ffea501025fc3e07622251c2118fe0 | refs/heads/main | 2023-08-01T01:54:05.925289 | 2021-09-05T21:00:35 | 2021-09-05T21:00:35 | 438,047,267 | 1 | 1 | MIT | 2021-12-13T22:45:20 | 2021-12-13T22:45:19 | null | UTF-8 | C++ | false | false | 4,380 | cpp | // RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
// expected-no-diagnostics
// REQUIRES: x86-registered-target
#ifndef HEADER
#define HEADER
// CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
// CHECK: [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
// CHECK: [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
// CHECK: [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
// CHECK: define {{.*}}void [[FOO:@.+]]()
void foo() {}
// CHECK-LABEL: @main
// TERM_DEBUG-LABEL: @main
int main() {
// CHECK: [[A_ADDR:%.+]] = alloca i8
char a;
// CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
// CHECK: call {{.*}}void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
// CHECK-NEXT: store i8 2, i8* [[A_ADDR]]
// CHECK-NEXT: call {{.*}}void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
#pragma omp critical
a = 2;
// CHECK: call {{.*}}void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
// CHECK-NEXT: invoke {{.*}}void [[FOO]]()
// CHECK: call {{.*}}void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
#pragma omp critical(the_name)
foo();
// CHECK: call {{.*}}void @__kmpc_critical_with_hint([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK1]], i{{64|32}} 23)
// CHECK-NEXT: invoke {{.*}}void [[FOO]]()
// CHECK: call {{.*}}void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK1]])
#pragma omp critical(the_name1) hint(23)
foo();
// CHECK: call {{.*}}void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
// CHECK: br label
// CHECK-NOT: call {{.*}}void @__kmpc_end_critical(
// CHECK: br label
// CHECK-NOT: call {{.*}}void @__kmpc_end_critical(
// CHECK: br label
if (a)
#pragma omp critical(the_name)
while (1)
;
// CHECK: call {{.*}}void [[FOO]]()
foo();
// CHECK-NOT: call void @__kmpc_critical
// CHECK-NOT: call void @__kmpc_end_critical
return a;
}
struct S {
int a;
};
// CHECK-LABEL: critical_ref
void critical_ref(S &s) {
// CHECK: [[S_ADDR:%.+]] = alloca %struct.S*,
// CHECK: [[S_REF:%.+]] = load %struct.S*, %struct.S** [[S_ADDR]],
// CHECK: [[S_A_REF:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_REF]], i32 0, i32 0
++s.a;
// CHECK: [[S_REF:%.+]] = load %struct.S*, %struct.S** [[S_ADDR]],
// CHECK: store %struct.S* [[S_REF]], %struct.S** [[S_ADDR:%.+]],
// CHECK: call void @__kmpc_critical(
#pragma omp critical
// CHECK: [[S_REF:%.+]] = load %struct.S*, %struct.S** [[S_ADDR]],
// CHECK: [[S_A_REF:%.+]] = getelementptr inbounds %struct.S, %struct.S* [[S_REF]], i32 0, i32 0
++s.a;
// CHECK: call void @__kmpc_end_critical(
}
// CHECK-LABEL: parallel_critical
// TERM_DEBUG-LABEL: parallel_critical
void parallel_critical() {
#pragma omp parallel
#pragma omp critical
// TERM_DEBUG-NOT: __kmpc_global_thread_num
// TERM_DEBUG: call void @__kmpc_critical({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]]
// TERM_DEBUG: invoke void {{.*}}foo{{.*}}()
// TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],
// TERM_DEBUG-NOT: __kmpc_global_thread_num
// TERM_DEBUG: call void @__kmpc_end_critical({{.+}}), !dbg [[DBG_LOC_END:![0-9]+]]
// TERM_DEBUG: [[TERM_LPAD]]
// TERM_DEBUG: call void @__clang_call_terminate
// TERM_DEBUG: unreachable
foo();
}
// TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-12]],
// TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-3]],
#endif
| [
"sebi@quantstamp.com"
] | sebi@quantstamp.com |
56d078f0ae59c6912ec3b34f4d5f49b65e32936f | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE590_Free_Memory_Not_on_Heap/s01/CWE590_Free_Memory_Not_on_Heap__delete_array_int_declare_53a.cpp | a1c1b30a02a9a6d0247843407acab9a6aed2d0e3 | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 2,733 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__delete_array_int_declare_53a.cpp
Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete_array.label.xml
Template File: sources-sink-53a.tmpl.cpp
*/
/*
* @description
* CWE: 590 Free Memory Not on Heap
* BadSource: declare Data buffer is declared on the stack
* GoodSource: Allocate memory on the heap
* Sink:
* BadSink : Print then free data
* Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
namespace CWE590_Free_Memory_Not_on_Heap__delete_array_int_declare_53
{
#ifndef OMITBAD
/* bad function declaration */
void badSink_b(int * data);
void bad()
{
int * data;
data = NULL; /* Initialize data */
{
/* FLAW: data is allocated on the stack and deallocated in the BadSink */
int dataBuffer[100];
{
size_t i;
for (i = 0; i < 100; i++)
{
dataBuffer[i] = 5;
}
}
data = dataBuffer;
}
badSink_b(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
void goodG2BSink_b(int * data);
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
int * data;
data = NULL; /* Initialize data */
{
/* FIX: data is allocated on the heap and deallocated in the BadSink */
int * dataBuffer = new int[100];
{
size_t i;
for (i = 0; i < 100; i++)
{
dataBuffer[i] = 5;
}
}
data = dataBuffer;
}
goodG2BSink_b(data);
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE590_Free_Memory_Not_on_Heap__delete_array_int_declare_53; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"yzhang0701@gmail.com"
] | yzhang0701@gmail.com |
1736d80dfec0aa35a8fcb213f6abe8abcc7d7ddd | 9e02c151f257584592d7374b0045196a3fd2cf53 | /AtCoder/ABC/102/A.cpp | e297acd7049e01fface3292eefcffe07afb84f8d | [] | no_license | robertcal/cpp_competitive_programming | 891c97f315714a6b1fc811f65f6be361eb642ef2 | 0bf5302f1fb2aa8f8ec352d83fa6281f73dec9b5 | refs/heads/master | 2021-12-13T18:12:31.930186 | 2021-09-29T00:24:09 | 2021-09-29T00:24:09 | 173,748,291 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 185 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int N; cin >> N;
if (N % 2 == 0) {
cout << N << endl;
} else {
cout << N * 2 << endl;
}
}
| [
"robertcal900@gmail.com"
] | robertcal900@gmail.com |
b44aee909a850211924f4a503dd11391b4666a0f | b511bb6461363cf84afa52189603bd9d1a11ad34 | /code/twice_integer.cpp | 4f6c7de443c001b58e475604e4b5e46e7f37a203 | [] | no_license | masumr/problem_solve | ec0059479425e49cc4c76a107556972e1c545e89 | 1ad4ec3e27f28f10662c68bbc268eaad9f5a1a9e | refs/heads/master | 2021-01-16T19:07:01.198885 | 2017-08-12T21:21:59 | 2017-08-12T21:21:59 | 100,135,794 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 614 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int i,t,n,j,k;
vector<int>a;
cin>>t;
while(t--)
{
cin>>n;
for(i=0;i<n;i++){
cin>>k;
a.push_back(k);
}
sort(a.begin(),a.end());
int count=0;
for(i=0;i<a.size();i++)
{
int k=2*a[i];
for(j=i+1;j<a.size();j++)
{
if(k==a[j]){
count++;
break;
}
}
}
cout<<count<<endl;
a.clear();
}
}
| [
"masumr455@gmial.com"
] | masumr455@gmial.com |
9d4930a7f256d7941824c2c34fd5ea6c2272d637 | 36183993b144b873d4d53e7b0f0dfebedcb77730 | /GameDevelopment/Game Programming Gems 5/Section5-Graphics/5.05-GridlessFire_Adabala/pqueue.cpp | 4babdca7db308bbdee2454a06186a16fbbeaa4e5 | [] | no_license | alecnunn/bookresources | b95bf62dda3eb9b0ba0fb4e56025c5c7b6d605c0 | 4562f6430af5afffde790c42d0f3a33176d8003b | refs/heads/master | 2020-04-12T22:28:54.275703 | 2018-12-22T09:00:31 | 2018-12-22T09:00:31 | 162,790,540 | 20 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 1,846 | cpp | /***********************************************
Demo for chapter "Gridless Controllable Fire"
in Games Programming Gems 5.
Author: Neeharika Adabala
Date: August 2004
************************************************/
#include"pqueue.h"
void PQ::PQupheap(float *DistArr,int *FoundArr,int k)const
{
float v;
int j;
//printf("in PQupheap\n");
v=DistArr[k]; DistArr[0] = 999999999999999.0f;
j=FoundArr[k];
while((DistArr[k/2] <= v)&&(k>0)) {
DistArr[k] = DistArr[k/2];
FoundArr[k] = FoundArr[k/2];
k=k/2;
// printf("in PQupheap\n");
}
if (k==0) printf("Distance is %f\n",v);
DistArr[k] = v;
FoundArr[k] = j;
}
void PQ::PQInsert(float distance,int index,float *DistArr,int *FoundArr)
const
{
//printf("in PQInsert\n");
FoundArr[0]=FoundArr[0]+1;
DistArr[FoundArr[0]] = distance;
FoundArr[FoundArr[0]] = index;
PQupheap(DistArr,FoundArr,FoundArr[0]);
}
void PQ::PQdownheap(float *DistArr,int *FoundArr,int k,int index) const
{
int j,N;
float v;
v=DistArr[k];
N = FoundArr[0]; /* tricky patch to maintain the data structure */
FoundArr[0]=index;
while (k <= N/2) {
j=k+k;
if (j < N && DistArr[j] <DistArr[j+1]) j++;
if (v>=DistArr[j]) break;
DistArr[k]=DistArr[j];
FoundArr[k]=FoundArr[j];
k=j;
//printf("in PQdownheap \n");
}
DistArr[k] = v;
FoundArr[k]= index;
FoundArr[0]=N; /* restore data struct */
}
void PQ::PQreplace(float distance,float *DistArr,int *FoundArr,int index)
const
{
//printf("in PQreplace\n");
DistArr[0]=distance;
PQdownheap(DistArr,FoundArr,0,index);
}
| [
"alec.nunn@gmail.com"
] | alec.nunn@gmail.com |
a969f570535f19af222f1023faa5f9039884f7ab | 44ab57520bb1a9b48045cb1ee9baee8816b44a5b | /Assist/Code/Toolset/CoreTools/ExportTest/CoreTools/Shared/MathematicsMacroShared.h | b2dc0d0e6549e0fd15b035850cd7f891099b35ec | [
"BSD-3-Clause"
] | permissive | WuyangPeng/Engine | d5d81fd4ec18795679ce99552ab9809f3b205409 | 738fde5660449e87ccd4f4878f7bf2a443ae9f1f | refs/heads/master | 2023-08-17T17:01:41.765963 | 2023-08-16T07:27:05 | 2023-08-16T07:27:05 | 246,266,843 | 10 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,025 | h | /// Copyright (c) 2010-2023
/// Threading Core Render Engine
///
/// 作者:彭武阳,彭晔恩,彭晔泽
/// 联系作者:94458936@qq.com
///
/// 标准:std:c++20
/// 版本:0.9.1.2 (2023/07/28 15:00)
#ifndef EXPORT_TEST_MATHEMATICS_MACRO_SHARED_H
#define EXPORT_TEST_MATHEMATICS_MACRO_SHARED_H
#include "Mathematics/MathematicsDll.h"
#include "CoreTools/Contract/ContractFwd.h"
#include "CoreTools/Helper/Export/SharedExportMacro.h"
MATHEMATICS_SHARED_EXPORT_IMPL(MathematicsMacroSharedImpl);
namespace Mathematics
{
class MATHEMATICS_DEFAULT_DECLARE MathematicsMacroShared final
{
public:
SHARED_TYPE_DECLARE(MathematicsMacroShared);
public:
explicit MathematicsMacroShared(int count);
CLASS_INVARIANT_DECLARE;
NODISCARD int GetCount() const noexcept;
void SetCount(int count) noexcept;
NODISCARD const void* GetAddress() const noexcept;
private:
PackageType impl;
};
}
#endif // EXPORT_TEST_MATHEMATICS_MACRO_SHARED_H | [
"94458936@qq.com"
] | 94458936@qq.com |
931b6d161bf8ea675f2d50896cf7b796109823f7 | d613fa2cbc96c5de066248d9dfda9ac43bfe0f69 | /app/src/EditTableController.cpp | 595b7ecd75dda5896cf4db233eba68e038ab6d09 | [] | no_license | alejinjer/utag | bc4b082432c6f2fea323ce2efd85658b31db7d2a | c3abcddd7c8c2a5e89a6fed28c534aa53b55f6d2 | refs/heads/main | 2022-12-31T13:42:11.620722 | 2020-10-23T12:57:34 | 2020-10-23T12:57:34 | 306,637,045 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 781 | cpp | #include "EditTableController.h"
EditTableController::EditTableController(QTableWidget *parent)
: m_parent(parent)
{
for (int i = 0; i < TAG_COUNT; ++i) {
m_currentFileTags[i] = new QTableWidgetItem("");
m_parent->setItem(i, 0, m_currentFileTags[i]);
}
}
EditTableController::~EditTableController()
{
}
void EditTableController::setCurrentFile(const QVector<QString> &v)
{
for (auto i = 0; i < TAG_COUNT; i++) {
m_currentFileTags[i]->setData(Qt::DisplayRole, v[i + 1]);
}
}
void EditTableController::unsetCurrentFile()
{
for (auto i = 0; i < TAG_COUNT; i++) {
m_currentFileTags[i]->setData(Qt::DisplayRole, "");
}
}
QVector<QTableWidgetItem *> EditTableController::getCurrentFile()
{
return m_currentFileTags;
}
| [
"opiskun@e1r4p8.unit.ua"
] | opiskun@e1r4p8.unit.ua |
037b9c6432e4f5f53e699ca34a5e6df17d654390 | 58e06a9c681c20a9d84b926247c723087331b9f1 | /cse20311/lab1/prog2.cpp | c4322789120e7d3f90f2a694f280852f063e9ae0 | [] | no_license | ericl1ericl/Notre-Dame | 1869a5f2d138d98520471d1838581d4bfdeb5f51 | 0a2f6c371e1bbb54b723d8c2c2c2b1b212922c14 | refs/heads/master | 2021-01-25T04:36:45.670324 | 2018-10-29T20:54:19 | 2018-10-29T20:54:19 | 93,458,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 582 | cpp | #include <iostream>
using namespace std;
int main()
{
int td;
cout << "Enter the number of touchdowns scored by the Irish: ";
cin >> td;
int xpt;
cout << "Enter the number of extra points made by the Irish: ";
cin >> xpt;
int fg;
cout << "Enter the number of field goals made by the Irish: ";
cin >> fg;
int s;
cout << "Enter the number of safeties scored by the Irish: ";
cin >> s;
int sum;
sum = td*6 + xpt*1 + fg*3 + s*2;
cout << "The Fighting Irish scored " << sum << " points. Go Irish!"
<< endl;
return 0;
}
// Eric Layne
| [
"elayne@nd.edu"
] | elayne@nd.edu |
848114d88c4cb77a2e2608983754a0e87ce40d9e | d732c881b57ef5e3c8f8d105b2f2e09b86bcc3fe | /src/module-wx/VType_wxNavigationKeyEvent.cpp | 7865193e75d53c4add497dbeb0ff05fedb77495a | [] | no_license | gura-lang/gurax | 9180861394848fd0be1f8e60322b65a92c4c604d | d9fedbc6e10f38af62c53c1bb8a4734118d14ce4 | refs/heads/master | 2023-09-01T09:15:36.548730 | 2023-09-01T08:49:33 | 2023-09-01T08:49:33 | 160,017,455 | 10 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,114 | cpp | //==============================================================================
// VType_wxNavigationKeyEvent.cpp
// Don't edit this file since it's been generated by Generate.gura.
//==============================================================================
#include "stdafx.h"
Gurax_BeginModuleScope(wx)
//------------------------------------------------------------------------------
// Help
//------------------------------------------------------------------------------
static const char* g_docHelp_en = u8R"""(
# Overview
# Predefined Variable
${help.ComposePropertyHelp(wx.NavigationKeyEvent, `en)}
# Operator
# Cast Operation
${help.ComposeConstructorHelp(wx.NavigationKeyEvent, `en)}
${help.ComposeMethodHelp(wx.NavigationKeyEvent, `en)}
)""";
static const char* g_docHelp_ja = u8R"""(
# 概要
# 定数
${help.ComposePropertyHelp(wx.NavigationKeyEvent, `ja)}
# オペレータ
# キャスト
${help.ComposeConstructorHelp(wx.NavigationKeyEvent, `ja)}
${help.ComposeMethodHelp(wx.NavigationKeyEvent, `ja)}
)""";
//------------------------------------------------------------------------------
// Implementation of constructor
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Implementation of method
//-----------------------------------------------------------------------------
// wx.NavigationKeyEvent#GetCurrentFocus() {block?}
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, GetCurrentFocus_gurax, "GetCurrentFocus")
{
Declare(VTYPE_wxWindow, Flag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, GetCurrentFocus_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxWindow(
pEntity_gurax->GetCurrentFocus()));
}
// wx.NavigationKeyEvent#GetDirection()
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, GetDirection_gurax, "GetDirection")
{
Declare(VTYPE_Bool, Flag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, GetDirection_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
bool rtn = pEntity_gurax->GetDirection();
return new Gurax::Value_Bool(rtn);
}
// wx.NavigationKeyEvent#IsFromTab()
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, IsFromTab_gurax, "IsFromTab")
{
Declare(VTYPE_Bool, Flag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, IsFromTab_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
bool rtn = pEntity_gurax->IsFromTab();
return new Gurax::Value_Bool(rtn);
}
// wx.NavigationKeyEvent#IsWindowChange()
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, IsWindowChange_gurax, "IsWindowChange")
{
Declare(VTYPE_Bool, Flag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, IsWindowChange_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
bool rtn = pEntity_gurax->IsWindowChange();
return new Gurax::Value_Bool(rtn);
}
// wx.NavigationKeyEvent#SetCurrentFocus(currentFocus as wx.Window)
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, SetCurrentFocus_gurax, "SetCurrentFocus")
{
Declare(VTYPE_Nil, Flag::None);
DeclareArg("currentFocus", VTYPE_wxWindow, ArgOccur::Once, ArgFlag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, SetCurrentFocus_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxWindow& value_currentFocus = args_gurax.Pick<Value_wxWindow>();
wxWindow* currentFocus = value_currentFocus.GetEntityPtr();
// Function body
pEntity_gurax->SetCurrentFocus(currentFocus);
return Gurax::Value::nil();
}
// wx.NavigationKeyEvent#SetDirection(direction as Bool)
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, SetDirection_gurax, "SetDirection")
{
Declare(VTYPE_Nil, Flag::None);
DeclareArg("direction", VTYPE_Bool, ArgOccur::Once, ArgFlag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, SetDirection_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
bool direction = args_gurax.PickBool();
// Function body
pEntity_gurax->SetDirection(direction);
return Gurax::Value::nil();
}
// wx.NavigationKeyEvent#SetFlags(flags as Number)
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, SetFlags_gurax, "SetFlags")
{
Declare(VTYPE_Nil, Flag::None);
DeclareArg("flags", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, SetFlags_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
long flags = args_gurax.PickNumber<long>();
// Function body
pEntity_gurax->SetFlags(flags);
return Gurax::Value::nil();
}
// wx.NavigationKeyEvent#SetFromTab(fromTab as Bool)
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, SetFromTab_gurax, "SetFromTab")
{
Declare(VTYPE_Nil, Flag::None);
DeclareArg("fromTab", VTYPE_Bool, ArgOccur::Once, ArgFlag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, SetFromTab_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
bool fromTab = args_gurax.PickBool();
// Function body
pEntity_gurax->SetFromTab(fromTab);
return Gurax::Value::nil();
}
// wx.NavigationKeyEvent#SetWindowChange(windowChange as Bool)
Gurax_DeclareMethodAlias(wxNavigationKeyEvent, SetWindowChange_gurax, "SetWindowChange")
{
Declare(VTYPE_Nil, Flag::None);
DeclareArg("windowChange", VTYPE_Bool, ArgOccur::Once, ArgFlag::None);
}
Gurax_ImplementMethodEx(wxNavigationKeyEvent, SetWindowChange_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
bool windowChange = args_gurax.PickBool();
// Function body
pEntity_gurax->SetWindowChange(windowChange);
return Gurax::Value::nil();
}
//-----------------------------------------------------------------------------
// Implementation of property
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// VType_wxNavigationKeyEvent
//------------------------------------------------------------------------------
VType_wxNavigationKeyEvent VTYPE_wxNavigationKeyEvent("NavigationKeyEvent");
void VType_wxNavigationKeyEvent::DoPrepare(Frame& frameOuter)
{
// Add help
AddHelp(Gurax_Symbol(en), g_docHelp_en);
AddHelp(Gurax_Symbol(ja), g_docHelp_ja);
// Declaration of VType
Declare(VTYPE_wxEvent, Flag::Mutable);
// Assignment of method
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, GetCurrentFocus_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, GetDirection_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, IsFromTab_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, IsWindowChange_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, SetCurrentFocus_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, SetDirection_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, SetFlags_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, SetFromTab_gurax));
Assign(Gurax_CreateMethod(wxNavigationKeyEvent, SetWindowChange_gurax));
}
//------------------------------------------------------------------------------
// Value_wxNavigationKeyEvent
//------------------------------------------------------------------------------
VType& Value_wxNavigationKeyEvent::vtype = VTYPE_wxNavigationKeyEvent;
EventValueFactoryDeriv<Value_wxNavigationKeyEvent> Value_wxNavigationKeyEvent::eventValueFactory;
String Value_wxNavigationKeyEvent::ToString(const StringStyle& ss) const
{
return ToStringGeneric(ss, "wx.NavigationKeyEvent");
}
Gurax_EndModuleScope(wx)
| [
"ypsitau@nifty.com"
] | ypsitau@nifty.com |
4d556bae0498eabf9dba7cfd2d964e91a34fd3ec | c9b02ab1612c8b436c1de94069b139137657899b | /sgonline_srv/app/logic/LogicUserInteract.h | cac0eef8294334147163d11e7d5dfddc6d7527bf | [] | no_license | colinblack/game_server | a7ee95ec4e1def0220ab71f5f4501c9a26ab61ab | a7724f93e0be5c43e323972da30e738e5fbef54f | refs/heads/master | 2020-03-21T19:25:02.879552 | 2020-03-01T08:57:07 | 2020-03-01T08:57:07 | 138,948,382 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,595 | h | #ifndef LOGICUSERINTERACT_H_
#define LOGICUSERINTERACT_H_
#include "LogicInc.h"
class CLogicUserInteract
{
public:
int AddHelp(unsigned uidFrom, unsigned uidTo);
int AddAttack(unsigned uidFrom, unsigned uidTo);
int GetInteract(unsigned uid, unsigned oppositeUid, DataUserInteract &interact);
int GetInteracts(unsigned uid, map<unsigned, DataUserInteract> &interacts);
int ProcessRequest(const DataMessage &request, unsigned from, unsigned to, const string &type, int action, const Json::Value &data);
int SendRequest(unsigned uid, const string &type, const string &data, const map<string, string> &userRequests);
int GetRequestFilter(unsigned uid, const string &requestType, Json::Value &users);
int FilterRequestUsers(const UidList &users, const Json::Value &filter, Json::Value &filterUsers);
int RequestItem(unsigned uid, const string &itemid, int requireCount, uint64_t &messageId, unsigned &waitTime);
int SendHelpReward(unsigned uid, const string &itemid, int count, uint64_t &messageId);
int GetFriendInteracts(unsigned uid, map<unsigned, int> &interacts);
int AddFriendInteract(unsigned uid, unsigned friendId, const string &type);
int ChangeInteractPoint(unsigned uid, int count);
int AddGiftReceiveCount(unsigned uid);
int AddInteract(const DataUserInteract &interact);
int SetInteract(const DataUserInteract &interact);
int GetInteractsAttackAfter(unsigned uid, unsigned last_attack_time, vector<DataUserInteract> &interacts);
int RemoveInteracts(unsigned uid);
int RemoveInteracts(unsigned uid, unsigned opposite_uid);
};
#endif /* LOGICUSERINTERACT_H_ */
| [
"178370407@qq.com"
] | 178370407@qq.com |
2c27679e65e182cf55805ea8661aefacf8d08412 | ffdc77394c5b5532b243cf3c33bd584cbdc65cb7 | /mindspore/lite/tools/converter/micro/coder/opcoders/nnacl/fp32/shape_fp32_coder.cc | 2fae254c1c8c1a029780416350abca3ab653853c | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license",
"MPL-1.0",
"OpenSSL",
"LGPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause-Open-MPI",
"MIT",
"MPL-2.0-no-copyleft-exception",
"NTP",
"BSD-3-Clause",
"GPL-1.0-or-later",
"0BSD",
"MPL-2.0",
"LicenseRef-scancode-f... | permissive | mindspore-ai/mindspore | ca7d5bb51a3451c2705ff2e583a740589d80393b | 54acb15d435533c815ee1bd9f6dc0b56b4d4cf83 | refs/heads/master | 2023-07-29T09:17:11.051569 | 2023-07-17T13:14:15 | 2023-07-17T13:14:15 | 239,714,835 | 4,178 | 768 | Apache-2.0 | 2023-07-26T22:31:11 | 2020-02-11T08:43:48 | C++ | UTF-8 | C++ | false | false | 2,242 | cc | /**
* Copyright 2022 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "coder/opcoders/nnacl/fp32/shape_fp32_coder.h"
#include <string>
#include <vector>
#include "coder/opcoders/serializers/nnacl_serializer/nnacl_fp32_serializer.h"
#include "coder/opcoders/file_collector.h"
using mindspore::schema::PrimitiveType_Shape;
namespace mindspore::lite::micro::nnacl {
int ShapeFP32Coder::DoCode(CoderContext *const context) {
std::string output_str = allocator_->GetRuntimeAddr(output_tensor_);
NNaclFp32Serializer code;
MS_LOG(WARNING)
<< "The shape op can be fused and optimized by configuring the 'inputShape' parameter of the converter tool.";
code << " {\n";
int index = 0;
for (auto &shape : input_tensors_.at(0)->shape()) {
code << " " << output_str << "[" << index++ << "] = " << shape << ";\n";
}
code << " }\n";
context->AppendCode(code.str());
return RET_OK;
}
REG_OPERATOR_CODER(kAllTargets, kNumberTypeFloat32, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt32, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeBool, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt8, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeUInt8, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeInt64, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
REG_OPERATOR_CODER(kAllTargets, kNumberTypeFloat16, PrimitiveType_Shape, CPUOpCoderCreator<ShapeFP32Coder>)
} // namespace mindspore::lite::micro::nnacl
| [
"gongdaguo1@huawei.com"
] | gongdaguo1@huawei.com |
84d7b308256818236e1a5459e272be9b2b9c7b5c | 33f8a1164c44b4ade4a1ae9edca25a5d631b14dc | /MusicClip.cpp | 53dab6e1e0f72cc6018b8ff6f72dbdeaf06e5652 | [] | no_license | kuribohlv9/Skelly_Dungeon | fe2ef781c3e4169ef7300a3af1347ee7f18bf4a3 | 01d8d165a3d045b58b467a5e5c4594ba6c92a115 | refs/heads/master | 2020-04-30T09:03:41.956469 | 2015-02-07T15:29:12 | 2015-02-07T15:29:12 | 28,010,758 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | cpp | // MusicClip.cpp
#include "stdafx.h"
#include "MusicClip.h"
MusicClip::MusicClip()
{
m_xClip = nullptr;
m_iChannel = -1;
}
MusicClip::~MusicClip()
{
m_xClip = nullptr;
m_iChannel = -1;
}
MusicClip::MusicClip(Mix_Music* p_xClip)
{
m_xClip = p_xClip;
m_iChannel = -1;
}
void MusicClip::Play()
{
m_iChannel = Mix_PlayMusic(m_xClip, -1);
}
void MusicClip::Pause()
{
if (m_iChannel == -1)
return;
if ( Mix_PausedMusic() )
Mix_ResumeMusic();
else
Mix_Pause(m_iChannel);
}
void MusicClip::Volume(int p_iVolume)
{
Mix_VolumeMusic(p_iVolume);
}
void MusicClip::Stop()
{
if (m_iChannel == -1)
return;
Mix_HaltChannel(m_iChannel);
m_iChannel = -1;
} | [
"gamedesignwithdee@gmail.com"
] | gamedesignwithdee@gmail.com |
feb8f93817283ad5a7356cc24b00d6f93afd0618 | 90e6ac97019b3478ff0596eb193af315a7a8bd4a | /IDR(s)/Matrix.h | 3d8274b4615dffcd9603a80881c48c9cd36503c5 | [] | no_license | aggarwal2000/IDR-biortho-NLA4HPC | ab2674e0975778f4310ede4a8391801c5f9fead3 | acd2aa6ed61f487d2be5ba103cfebe8a68d59421 | refs/heads/master | 2023-03-18T08:52:07.186156 | 2021-03-09T15:07:48 | 2021-03-09T15:07:48 | 346,045,190 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,992 | h | /*!
\file Matrix.h
\brief Definition of classes Dense_Matrix, CSR_Matrix and COO_Matrix
*/
# pragma once
#include<cassert>
#include<cuComplex.h>
#include"location_enums.h"
typedef cuDoubleComplex DoubleComplex;
//! enum class which defines storage order for dense matrices
/**
This enum class defines the order(row/column) in which values are stored in dense matrices
*/
enum class ORDER {
COLUMN_MAJOR, /*!< means that the matrix values are stored in column major order */
ROW_MAJOR /*!< means that the matrix values are stored in row major order */
};
//! Class for Complex Dense Matrices
/*!
This class contains attributes and member functions for complex dense matrix class objects.
*/
class Dense_Matrix {
private:
const int rows; /*!< Number of rows in dense matrix*/
const int cols; /*!< Number of columns in dense matrix */
const int lda; /*!< Leading Dimension of dimension of dense matrix (Usually the number of rows is rounded up to a certain value to give lda.) */
ORDER order = ORDER::COLUMN_MAJOR; /*!< storage order of dense matrix */
CPU_EXISTENCE cpu_exists = CPU_EXISTENCE::NON_EXISTENT; /*!< presence/absence of dense matrix internals(large arrays) in CPU memory*/
GPU_EXISTENCE gpu_exists = GPU_EXISTENCE::NON_EXISTENT; /*!< presence/absence of dense matrix internals(large arrays) in GPU memory*/
DoubleComplex* cpu_values = nullptr; /*!< Pointer storing base address of the array allocated on CPU containing dense matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until they are copied.*/
DoubleComplex* gpu_values = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing dense matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until they are copied.*/
public:
//! Returns number of rows in dense matrix
/*!
\return number of rows in dense matrix
*/
int GetRows() const
{
return rows;
}
//! Returns number of columns in dense matrix
/*!
\return number of columns in dense matrix
*/
int GetCols() const
{
return cols;
}
//! Returns leading dimension of dense matrix
/*!
\return leading dimension of dense matrix
*/
int GetLda() const
{
return lda;
}
//! Returns storage order of dense matrix
/*!
\return order in which values are stored in the dense matrix
*/
ORDER GetOrder() const
{
return order;
}
//! Returns a pointer to the array allocated on CPU which stores the dense matrix values
/*!
\return pointer to the array allocated on CPU which stores the dense matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetCPUValues() const
{
if(ExistsCPU() == true)
return cpu_values;
else
return nullptr;
}
//! Returns a pointer to the array allocated on GPU which stores the dense matrix values
/*!
\return pointer to the array allocated on GPU which stores the dense matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetGPUValues() const
{
if(ExistsGPU() == true)
return gpu_values;
else
return nullptr;
}
//! Takes in a column index and returns a pointer to its starting location on GPU.
/*!
\param[in] col_ind index of the column for which the pointer (to GPU memory) is required
\return pointer to the starting location of the column on GPU memory; nullptr in case no memory is allocated on GPU
*/
DoubleComplex* GetColPtrGPU(const int col_ind) const
{
assert(col_ind < GetCols());
//return &gpu_values[lda * col_ind];
if(ExistsGPU() == true)
return GetGPUValues() + GetLda() * col_ind;
else
return nullptr;
}
//! Takes in a column index and returns a pointer to its starting location on CPU.
/*!
\param[in] col_ind index of the column for which the pointer (to CPU memory) is required
\return pointer to the starting location of the column on CPU memory; nullptr in case no memory is allocated on CPU
*/
DoubleComplex* GetColPtrCPU(const int col_ind) const
{
assert(col_ind < GetCols());
if(ExistsCPU() == true)
return GetCPUValues() + GetLda() * col_ind;
else
return nullptr;
}
//! Takes in a location and returns its GPU memory address
/*!
\param[in] row row index of the element
\param[in] col column index the element
\return pointer(GPU memory address) to the element; nullptr in case no memory is allocated on GPU
*/
DoubleComplex* GetSpecificLocationPtrGPU(const int row, const int col) const
{
//return &gpu_values[row + lda * col];
assert(row < GetRows());
assert(col < GetCols());
if(ExistsGPU() == true)
return GetGPUValues() + row + GetLda()* col;
else
return nullptr;
}
//! Takes in a location and returns its CPU memory address
/*!
\param[in] row row index of the element
\param[in] col column index the element
\return pointer(CPU memory address) to the element; nullptr in case no memory is allocated on CPU
*/
DoubleComplex* GetSpecificLocationPtrCPU(const int row, const int col) const
{
assert(row < GetRows());
assert(col < GetCols());
if(ExistsCPU() == true)
return GetCPUValues() + row + GetLda()* col;
else
return nullptr;
}
//! Returns true if Dense matrix values are present on CPU memory
/*!
\return boolean value
*/
bool ExistsCPU() const
{
return cpu_exists == CPU_EXISTENCE::EXISTENT;
}
//! Returns true if Dense matrix values are present on GPU memory
/*!
\return boolean value
*/
bool ExistsGPU() const
{
return gpu_exists == GPU_EXISTENCE::EXISTENT;
}
void Allocate_Memory(const LOCATION loc);
Dense_Matrix(const int rows, const int cols, const int lda, const ORDER order, const CPU_EXISTENCE cpu_exists, const GPU_EXISTENCE gpu_exists);
~Dense_Matrix();
void CopyMatrix_cpu_to_gpu();
void CopyMatrix_gpu_to_cpu();
void Deallocate_Memory(const LOCATION loc);
Dense_Matrix(const Dense_Matrix& mat);
Dense_Matrix(Dense_Matrix&& mat);
Dense_Matrix& operator= (const Dense_Matrix& mat);
Dense_Matrix& operator= (Dense_Matrix&& mat);
void CopyMatrix_cpu_to_gpu(int col_start , int col_end , int row_start , int row_end);
void CopyMatrix_gpu_to_cpu(int col_start , int col_end, int row_start, int row_end);
};
//! Class for complex sparse CSR matrix
/*!
This class contains attributes and member functions for complex sparse CSR matrix class.
*/
class CSR_Matrix {
private:
const int rows; /*!< Number of rows in CSR matrix*/
const int cols; /*!< Number of columns in CSR matrix*/
const int nz; /*!< Number of nonzero elemnents in CSR matrix*/
CPU_EXISTENCE cpu_exists = CPU_EXISTENCE::NON_EXISTENT; /*!< presence/absence of CSR matrix internals in CPU memory*/
GPU_EXISTENCE gpu_exists = GPU_EXISTENCE::NON_EXISTENT; /*!< presence/absence of CSR matrix internals in GPU memory*/
DoubleComplex* cpu_values = nullptr; /*!< Pointer storing base address of the array allocated on CPU containing CSR matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until they are copied.*/
DoubleComplex* gpu_values = nullptr; /*!< Pointer storing base address of the array allocated on GPU containing CSR matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until they are copied.*/
int* cpu_row_ptr = nullptr; /*!< Pointer storing base address of the array allocated on CPU containing CSR matrix row pointers
It is equal to nullptr in case no memory is allocated.*/
int* gpu_row_ptr = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing CSR matrix row pointers
It is equal to nullptr in case no memory is allocated.*/
int* cpu_col_ind = nullptr;/*!< Pointer storing base address of the array allocated on CPU containing CSR matrix column indices
It is equal to nullptr in case no memory is allocated.*/
int* gpu_col_ind = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing CSR matrix column indices
It is equal to nullptr in case no memory is allocated.*/
public:
//! Returns number of rows in CSR matrix
/*!
\return number of rows in CSR matrix
*/
int GetRows() const
{
return rows;
}
//! Returns number of columns in CSR matrix
/*!
\return number of columns in CSR matrix
*/
int GetCols() const
{
return cols;
}
//! Returns number of non zero elements in CSR matrix
/*!
\return number of non zero elements in CSR matrix
*/
int Getnz() const
{
return nz;
}
//! Returns a pointer to the array allocated on CPU which stores the CSR matrix values
/*!
\return pointer to the array allocated on CPU which stores the CSR matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetCPUValues() const
{
if(ExistsCPU() == true)
return cpu_values;
else
return nullptr;
}
//! Returns a pointer to the array allocated on CPU which stores the CSR matrix row pointers
/*!
\return pointer to the array allocated on CPU which stores the CSR matrix row pointers; nullptr in case no such array exists
*/
int* GetCPURowPtr() const
{
if(ExistsCPU() == true)
return cpu_row_ptr;
else
return nullptr;
}
//! Returns a pointer to the array allocated on CPU which stores the CSR matrix column indices
/*!
\return pointer to the array allocated on CPU which stores the CSR matrix column indices; nullptr in case no such array exists
*/
int* GetCPUColInd() const
{
if(ExistsCPU() == true)
return cpu_col_ind;
else
return nullptr;
}
//! Returns a pointer to the array allocated on GPU which stores the CSR matrix values
/*!
\return pointer to the array allocated on GPU which stores the CSR matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetGPUValues() const
{
if(ExistsGPU() == true)
return gpu_values;
else
return nullptr;
}
//! Returns a pointer to the array allocated on GPU which stores the CSR matrix row pointers
/*!
\return pointer to the array allocated on GPU which stores the CSR matrix row pointers; nullptr in case no such array exists
*/
int* GetGPURowPtr() const
{
if(ExistsGPU() == true)
return gpu_row_ptr;
else
return nullptr;
}
//! Returns a pointer to the array allocated on GPU which stores the CSR matrix column indices
/*!
\return pointer to the array allocated on GPU which stores the CSR matrix column indices; nullptr in case no such array exists
*/
int* GetGPUColInd() const
{
return gpu_col_ind;
}
//! Returns true if CSR matrix internals(large arrays) are present on CPU memory
/*!
\return boolean value
*/
bool ExistsCPU() const
{
return cpu_exists == CPU_EXISTENCE::EXISTENT;
}
//! Returns true if CSR matrix internals(large arrays) are present on GPU memory
/*!
\return boolean value
*/
bool ExistsGPU() const
{
return gpu_exists == GPU_EXISTENCE::EXISTENT;
}
void Allocate_Memory(const LOCATION loc);
CSR_Matrix(const int rows, const int cols, const int nz, const CPU_EXISTENCE cpu_exists, const GPU_EXISTENCE gpu_exists);
~CSR_Matrix();
void CopyMatrix_cpu_to_gpu();
void CopyMatrix_gpu_to_cpu();
void Deallocate_Memory(const LOCATION loc);
//! Copy constructor for CSR Matrix class
/*!
A deleted constructor
*/
CSR_Matrix(const CSR_Matrix& mat) = delete;
//! Move constructor for CSR Matrix class
/*!
A deleted constructor
*/
CSR_Matrix(CSR_Matrix&& mat) = delete;
//! Copy assignment operator for CSR matrix class
/*!
A deleted operator.
*/
CSR_Matrix& operator= (const CSR_Matrix& mat) = delete;
//! Move assignment operator for CSR matrix class
/*!
A deleted operator.
*/
CSR_Matrix& operator= (CSR_Matrix&& mat) = delete;
};
//! Class for complex sparse COO matrix
/*!
This class contains attributes and member functions for complex COO matrix
*/
class COO_Matrix {
private:
const int rows;/*!< Number of rows in COO matrix*/
const int cols;/*!< Number of columns in COO matrix*/
int nz; /*!< Number of nonzero elemnents in COO matrix, this can also be changed by Set_nz(int) member function*/
CPU_EXISTENCE cpu_exists = CPU_EXISTENCE::NON_EXISTENT;/*!< presence/absence of COO matrix internals(matrix arrays) in CPU memory*/
GPU_EXISTENCE gpu_exists = GPU_EXISTENCE::NON_EXISTENT; /*!< presence/absence of COO matrix internals(matrix arrays) in GPU memory*/
DoubleComplex* cpu_values = nullptr;/*!< Pointer storing base address of the array allocated on CPU containing COO matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until they are copied.*/
DoubleComplex* gpu_values = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing COO matrix's values.
It is equal to nullptr in case no memory is allocated. Note:values on CPU and GPU do not match until thay are copied.*/
int* cpu_row_ind = nullptr;/*!< Pointer storing base address of the array allocated on CPU containing COO matrix row indices
It is equal to nullptr in case no memory is allocated.*/
int* gpu_row_ind = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing COO matrix row indices
It is equal to nullptr in case no memory is allocated.*/
int* cpu_col_ind = nullptr;/*!< Pointer storing base address of the array allocated on CPU containing COO matrix column indices
It is equal to nullptr in case no memory is allocated.*/
int* gpu_col_ind = nullptr;/*!< Pointer storing base address of the array allocated on GPU containing COO matrix column indices
It is equal to nullptr in case no memory is allocated.*/
public:
//! Returns number of rows in COO matrix
/*!
\return number of rows in COO matrix
*/
int GetRows() const
{
return rows;
}
//! Returns number of columns in COO matrix
/*!
\return number of columns in COO matrix
*/
int GetCols() const
{
return cols;
}
//! Returns number of non zero elements in COO matrix
/*!
\return number of non zero elements in COO matrix
*/
int Getnz() const
{
return nz;
}
//! Sets the number of non zero elements in COO matrix
/*!
This is used to set the number of non zero elements in COO matrix object after it is formed.
Typical example of where it is useful is: If the number of non zero elemnets in COO matrix is unknown in the
beginning then an estimate of it is used while creating the object(estimate must be greater else the memory which is
allocated based on the estimate won't be enough to store matrix arrays) and later on, after writing the values
into memory and counting the elements along with that, the number of non zero elements can be set to the exact value using this function.
\param[in] mat_nz number of non zero elements to be set for the current matrix object
*/
void Set_nz(const int mat_nz)
{
nz = mat_nz;
}
//! Returns a pointer to the array allocated on CPU which stores the COO matrix values
/*!
\return pointer to the array allocated on CPU which stores the COO matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetCPUValues() const
{
return cpu_values;
}
//! Returns a pointer to the array allocated on CPU which stores the COO matrix row indices
/*!
\return pointer to the array allocated on CPU which stores the COO matrix row indices; nullptr in case no such array exists
*/
int* GetCPURowInd() const
{
return cpu_row_ind;
}
//! Returns a pointer to the array allocated on CPU which stores the COO matrix column indices
/*!
\return pointer to the array allocated on CPU which stores the COO matrix column indices; nullptr in case no such array exists
*/
int* GetCPUColInd() const
{
return cpu_col_ind;
}
//! Returns a pointer to the array allocated on GPU which stores the COO matrix values
/*!
\return pointer to the array allocated on GPU which stores the COO matrix values; nullptr in case no such array exists
*/
DoubleComplex* GetGPUValues() const
{
return gpu_values;
}
//! Returns a pointer to the array allocated on GPU which stores the COO matrix row indices
/*!
\return pointer to the array allocated on GPU which stores the COO matrix row indices; nullptr in case no such array exists
*/
int* GetGPURowInd() const
{
return gpu_row_ind;
}
//! Returns a pointer to the array allocated on GPU which stores the COO matrix column indices
/*!
\return pointer to the array allocated on GPU which stores the COO matrix column indices; nullptr in case no such array exists
*/
int* GetGPUColInd() const
{
return gpu_col_ind;
}
//! Returns true if COO matrix internals(matrix arrays) are present on CPU memory
/*!
\return boolean value
*/
bool ExistsCPU() const
{
return cpu_exists == CPU_EXISTENCE::EXISTENT;
}
//! Returns true if COO matrix internals(matrix arrays) are present on GPU memory
/*!
\return boolean value
*/
bool ExistsGPU() const
{
return gpu_exists == GPU_EXISTENCE::EXISTENT;
}
void Allocate_Memory(const LOCATION loc);
COO_Matrix(const int rows, const int cols, const int nz, const CPU_EXISTENCE cpu_exists, const GPU_EXISTENCE gpu_exists);
~COO_Matrix();
void CopyMatrix_cpu_to_gpu();
void CopyMatrix_gpu_to_cpu();
void Deallocate_Memory(const LOCATION loc);
//! Copy constructor for COO Matrix class
/*!
A deleted constructor
*/
COO_Matrix(const COO_Matrix& mat) = delete;
//! Move constructor for COO Matrix class
/*!
A deleted constructor
*/
COO_Matrix(COO_Matrix&& mat) = delete;
//! Copy assignment operator for COO matrix class
/*!
A deleted operator.
*/
COO_Matrix& operator= (const COO_Matrix& mat) = delete;
//! Move assignment operator for COO matrix class
/*!
A deleted operator.
*/
COO_Matrix& operator= (COO_Matrix&& mat) = delete;
};
| [
"aggarwal2000chd@gmail.com"
] | aggarwal2000chd@gmail.com |
6a13614cd35fde8e2425622356dc85a580d25ead | 2053e0ec782db1f74eba0c210fcc3ab381e7f152 | /leetcode/162.cpp | 6a5bcd28c30b753d1325b1b911f3300f4c2b8736 | [] | no_license | danielsamfdo/codingAlgo | 86d18b0265c4f5edb323d01ac52f24a2b88599d4 | 0a8e5b67d814ddedcb604f4588e6d959c8958c0b | refs/heads/master | 2021-05-15T10:46:18.941263 | 2017-11-01T02:42:40 | 2017-11-01T02:42:40 | 108,208,650 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 858 | cpp | //https://leetcode.com/problems/find-peak-element/
class Solution {
public:
int search(vector<int>& nums, int l, int r) {
if (l == r)
return l;
int mid = (l + r) / 2;
if (nums[mid] > nums[mid + 1])
return search(nums, l, mid);
return search(nums, mid + 1, r);
}
int findPeakElement(vector<int>& nums) {
return search(nums,0,nums.size()-1);
// int l = 0;
// int r = nums.size()-1;
// if(r==1)return 0;
// int res;
// while(l<r){
// int mid= (l+r)/2;
// res = mid;
// if(nums[mid]>nums[mid+1]){
// r=mid;
// }
// else{
// l=mid+1;
// }
// }
// return l;
}
};//https://leetcode.com/problems/find-peak-element/solution/ | [
"danielsamfdo@gmail.com"
] | danielsamfdo@gmail.com |
ea6856858ffbc835cb51e9f4c4e204bde93dac55 | b570f5afc4d9baeaaeb3757f46017a8eeb89d681 | /C++/Text/lib/Header.cpp | ce6c0bbc997fce3ee27463852ad959ffe2206ba8 | [] | no_license | Anat37/akos | b87f7b2e91adb0994ab2741b1ad65e303af87633 | 78f90b062ebf3dac7be241f95efc1b9f41aa20d0 | refs/heads/master | 2020-12-24T19:37:00.703813 | 2016-11-06T18:01:03 | 2016-11-06T18:01:03 | 58,388,351 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,259 | cpp | #include "Header.h"
Header::Header(const T_Args& args, int t_lvl)
{
level = t_lvl;
w_v = args.w_v;
char *tmp_border = new char[w_v+1];
memset(tmp_border, '#', w_v);
tmp_border[w_v] = '\0';
border = T_String(tmp_border);
delete[] tmp_border;
}
T_String Header::begining(T_String tmp, int curr_level)
{
return T_String();
}
T_String Header::ending(T_String tmp, int curr_level)
{
return T_String();
}
void Header::next_level()
{
++level;
}
void Header::prev_level()
{
--level;
}
T_String Header::split_by_words(T_String str, int curr_level)
{
int col = 0,
last_pos = 0,
i = 0;
for(i = 0; str[i]; i++, col++)
{
if ((str[i] == ' ')&&(col<=w_v))
{
last_pos = i;
}
if (col>w_v)
{
if (i-last_pos>w_v)
{
cout<<"word len error!"<<endl;
exit(0);
}else
{
str[last_pos] = '\n';
i = ++last_pos;
col = 0;
}
}
}
if (col>w_v)
{
if (i-last_pos>w_v)
{
cout<<"word len error!"<<endl;
exit(0);
}else
{
str[last_pos] = '\n';
}
}
int last_i = 0;
T_String tmp_str;
int first = 1;
for(int i = 0; str[i]; i++)
{
if (str[i] == '\n')
{
if (first)
{
tmp_str = tmp_str+get_start_indent(str.slice(last_i, i));
first = 0;
}
else
{
tmp_str = tmp_str+T_String('\n')+get_start_indent(str.slice(last_i, i));
}
last_i = i+1;
}
}
if (first)
{
tmp_str = tmp_str+get_start_indent(str.slice(last_i, strlen(str)));
}
else
{
tmp_str = tmp_str+T_String('\n')+get_start_indent(str.slice(last_i, strlen(str)));
}
return border+T_String('\n')+tmp_str+T_String('\n')+border;
}
T_String Header::get_start_indent(T_String str)
{
if (strlen(str)>w_v)
return str;
size_t pos = (w_v-strlen(str))/2;
char *indent_start = new char [pos+2];
memset(indent_start, ' ', pos);
indent_start[pos] = '\0';
T_String str_indent_start(indent_start);
delete[] indent_start;
return str_indent_start+str;
}
void Header::print()
{
T_String ans;
for (size_t i = 0; i<pos; i++)
{
ans = ans + begining(data[i], levels[i]) + split_by_words( data[i], levels[i]) + ending(data[i], levels[i]) + T_String('\n');
}
ans = ans + T_String('\n');
cout << ans;
}
unsigned long int Header::countSymbols()
{
T_String ans;
for (size_t i = 0; i<pos; i++)
{
ans = ans + begining(data[i], levels[i]) + split_by_words( data[i], levels[i]) + ending(data[i], levels[i]) + T_String('\n');
}
ans = ans + T_String('\n');
return strlen(ans);
}
unsigned long int Header::countWords()
{
unsigned long int count = 0;
for (size_t i = 0; i<pos; i++)
{
for(size_t j = 0; j<strlen(data[i]); j++)
{
if ((data[i][j] == ' ')||(data[i][j] == '\n'))
count += 1;
}
}
return count;
} | [
"kozlof9@yandex.ru"
] | kozlof9@yandex.ru |
501c1a1e373129a4267a207b570cecb4a1ec363f | fdaf20f014438477812de55aa21f0449293df0e9 | /dataserver/common/hash_combine.h | 179ee397e16b283ed4cb845b29ed8d6566e0196d | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Totopolis/dataserver | b9b3d4ddb93f63de804e92d9e878fe33fa04ddf7 | 4aabebf7920973c67fb4249a4aca735956d5209c | refs/heads/master | 2021-01-23T11:20:21.098020 | 2019-04-08T17:52:04 | 2019-04-08T17:52:04 | 46,785,828 | 6 | 4 | null | 2016-09-28T15:23:27 | 2015-11-24T10:56:16 | C++ | UTF-8 | C++ | false | false | 1,419 | h | // hash_combine.h
//
#pragma once
#ifndef __SDL_COMMON_HASH_COMBINE_H__
#define __SDL_COMMON_HASH_COMBINE_H__
#include "dataserver/common/common.h"
namespace sdl { namespace hash_detail {
/*#if defined(_MSC_VER)
# define SDL_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r)
#else
# define SDL_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r))
#endif*/
template<uint32 r>
inline constexpr uint32 hash_rotl32(const uint32 x)
{
return (x << r) | (x >> (32 - r));
}
inline void hash_combine_impl(uint64 & h, uint64 k)
{
constexpr uint64_t m = UINT64_C(0xc6a4a7935bd1e995);
constexpr int r = 47;
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
h *= m;
// Completely arbitrary number, to prevent 0's
// from hashing to 0.
h += 0xe6546b64;
}
template <typename SizeT>
inline void hash_combine_impl(SizeT & seed, SizeT value)
{
seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
inline void hash_combine_impl(uint32 & h1, uint32 k1)
{
constexpr uint32 c1 = 0xcc9e2d51;
constexpr uint32 c2 = 0x1b873593;
k1 *= c1;
k1 = hash_rotl32<15>(k1);
k1 *= c2;
h1 ^= k1;
h1 = hash_rotl32<13>(h1);
h1 = h1 * 5 + 0xe6546b64;
}
template <class T>
inline void hash_combine(std::size_t & seed, T const & v) // see boost::hash_combine
{
hash_combine_impl(seed, std::hash<T>{}(v));
}
} // hash_detail
} // sdl
#endif // __SDL_COMMON_HASH_COMBINE_H__
| [
"idalidchik@gmail.com"
] | idalidchik@gmail.com |
e908f1eb8661dacd5e95926183ccbe93942b52ee | 35cfa2ac88a962d71905c1a77f76d3fa3c3a6f55 | /Plane.cpp | c59617879d0b858b987fe8b8902270b55fda1851 | [] | no_license | Romain96/M1S2_GN | 31524dd471ac214dde5f44d744cf2d3a34b37ca8 | 9743f634c22035051587dffa917221d6b296ee58 | refs/heads/master | 2021-03-16T11:00:21.236577 | 2018-03-04T22:49:13 | 2018-03-04T22:49:13 | 120,600,256 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,405 | cpp | /*
* (C) Romain PERRIN
* romain.perrin@etu.unistra.fr
* UFR de Mathématiques-Informatique
* 2018-2019
*/
// glm
#include "glm/glm.hpp"
#include "glm/vec3.hpp"
#include "Plane.h"
//-----------------------------------------------------------------------------
// Constant(s)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Constructor(s)
//-----------------------------------------------------------------------------
Plane::Plane() :
_eigenvector1(glm::vec3(0.f)),
_eigenvector2(glm::vec3(0.f)),
_eigenvector3(glm::vec3(0.f))
{
// nothing
}
/**
* @brief Plane::Plane constructs a new plane with ACP computed eigenvectors
* @param ev1 eigenvector 1
* @param ev2 eigenvector 2
* @param ev3 eigenvector 3
*/
Plane::Plane(glm::vec3 &ev1, glm::vec3 &ev2, glm::vec3 &ev3) :
_eigenvector1(ev1),
_eigenvector2(ev2),
_eigenvector3(ev3)
{
// nothing
}
//-----------------------------------------------------------------------------
// Getter(s)
//-----------------------------------------------------------------------------
/**
* @brief Plane::getEigenvector1
* @return the first eigenvector
*/
glm::vec3& Plane::getEigenvector1()
{
return _eigenvector1;
}
/**
* @brief Plane::getEigenvector2
* @return the second eigenvector
*/
glm::vec3& Plane::getEigenvector2()
{
return _eigenvector2;
}
/**
* @brief Plane::getEigenvector3
* @return the third eigenvector
*/
glm::vec3& Plane::getEigenvector3()
{
return _eigenvector3;
}
//-----------------------------------------------------------------------------
// Setter(s)
//-----------------------------------------------------------------------------
/**
* @brief Plane::setEigenvector1
* @param ev1 new first eigenvector
*/
void Plane::setEigenvector1(glm::vec3 &ev1)
{
_eigenvector1 = ev1;
}
/**
* @brief Plane::setEigenvector2
* @param ev2 new second eigenvector
*/
void Plane::setEigenvector2(glm::vec3 &ev2)
{
_eigenvector2 = ev2;
}
/**
* @brief Plane::setEigenvector3
* @param ev3 new third eigenvector
*/
void Plane::setEigenvector3(glm::vec3 &ev3)
{
_eigenvector3 = ev3;
}
//-----------------------------------------------------------------------------
// Method(s)
//-----------------------------------------------------------------------------
| [
"romain.perrin@etu.unistra.fr"
] | romain.perrin@etu.unistra.fr |
e13e9c5e81bb48ccad4f42a3e87f5618a60d9a3e | b52bb5ec68118ea7e1f1246c26d4c84c409ff6bf | /RTS_AE/Game/Presets.cpp | 56ff83247fa4c325c5767352ab4bb4cf1b92f8c9 | [] | no_license | varo5/RTS_2016B | 8c8c0bb62af9dd22e56e2cb270f8db5ae0b00705 | 3784cb6d6b9a16f3161281db25af69b5cca15bc5 | refs/heads/master | 2021-01-19T07:01:36.501508 | 2016-10-10T21:43:38 | 2016-10-10T21:43:38 | 65,869,598 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 160 | cpp | #include "stdafx.h"
#include "Presets.h"
aePresets::aePresets()
{
m_nClassID = ClassId::Preset;
}
aePresets::~aePresets()
{
}
void aePresets::Destroy()
{
}
| [
"monsal00@gmail.com"
] | monsal00@gmail.com |
796027e8d72687c6dd5d3e7397f99064d8845caa | 96a59ce1d89472f3342de04123606816e4b88ca3 | /zswlib/mesh/mesh_op.h | eeb208cd55424034b20e4a55b4e3c26c4865fcd1 | [] | no_license | wegatron/geometry | f620796fbeffc25417090c580041cdacefe74a01 | 36aa73a04deb54c8c24c2919f723af89dbf91226 | refs/heads/master | 2020-04-06T07:04:48.212278 | 2016-03-31T07:11:50 | 2016-03-31T07:11:50 | 36,479,096 | 0 | 0 | null | 2016-03-31T07:11:51 | 2015-05-29T02:50:36 | C++ | UTF-8 | C++ | false | false | 329 | h | #ifndef MESH_OP_H
#define MESH_OP_H
#include <zswlib/config.h>
#include <zswlib/mesh/mesh_type.h>
#include <zswlib/data_type.h>
namespace zsw
{
namespace mesh {
void ZSW_API rRingVertex(const zsw::mesh::TriMesh &tm, const size_t r, std::vector<zsw::FakeSet<size_t>> &ring);
}
}
#endif /* MESH_OP_H */
| [
"wegatron@gmail.com"
] | wegatron@gmail.com |
522a169f3d7c26997b4279be7a9bbc3f50194c09 | 12f441018818dc2dcb1a8a89bccd946d87e0ac9e | /cppwinrt/winrt/impl/Windows.Graphics.Imaging.1.h | 12eca538456ba35555f8a70f04a136e509d26eff | [
"MIT"
] | permissive | dlech/bleak-winrt | cc7dd76fca9453b7415d65a428e22b2cbfe36209 | a6c1f3fd073a7b5678304ea6bc08b9b067544320 | refs/heads/main | 2022-09-12T00:15:01.497572 | 2022-09-09T22:57:53 | 2022-09-09T22:57:53 | 391,440,675 | 10 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,596 | h | // WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.220608.4
#pragma once
#ifndef WINRT_Windows_Graphics_Imaging_1_H
#define WINRT_Windows_Graphics_Imaging_1_H
#include "winrt/impl/Windows.Foundation.0.h"
#include "winrt/impl/Windows.Graphics.Imaging.0.h"
WINRT_EXPORT namespace winrt::Windows::Graphics::Imaging
{
struct __declspec(empty_bases) IBitmapBuffer :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapBuffer>,
impl::require<winrt::Windows::Graphics::Imaging::IBitmapBuffer, winrt::Windows::Foundation::IClosable, winrt::Windows::Foundation::IMemoryBuffer>
{
IBitmapBuffer(std::nullptr_t = nullptr) noexcept {}
IBitmapBuffer(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapCodecInformation :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapCodecInformation>
{
IBitmapCodecInformation(std::nullptr_t = nullptr) noexcept {}
IBitmapCodecInformation(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapDecoder :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapDecoder>
{
IBitmapDecoder(std::nullptr_t = nullptr) noexcept {}
IBitmapDecoder(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapDecoderStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapDecoderStatics>
{
IBitmapDecoderStatics(std::nullptr_t = nullptr) noexcept {}
IBitmapDecoderStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapDecoderStatics2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapDecoderStatics2>
{
IBitmapDecoderStatics2(std::nullptr_t = nullptr) noexcept {}
IBitmapDecoderStatics2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapEncoder :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapEncoder>
{
IBitmapEncoder(std::nullptr_t = nullptr) noexcept {}
IBitmapEncoder(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapEncoderStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapEncoderStatics>
{
IBitmapEncoderStatics(std::nullptr_t = nullptr) noexcept {}
IBitmapEncoderStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapEncoderStatics2 :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapEncoderStatics2>
{
IBitmapEncoderStatics2(std::nullptr_t = nullptr) noexcept {}
IBitmapEncoderStatics2(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapEncoderWithSoftwareBitmap :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapEncoderWithSoftwareBitmap>
{
IBitmapEncoderWithSoftwareBitmap(std::nullptr_t = nullptr) noexcept {}
IBitmapEncoderWithSoftwareBitmap(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapFrame :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapFrame>
{
IBitmapFrame(std::nullptr_t = nullptr) noexcept {}
IBitmapFrame(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapFrameWithSoftwareBitmap :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapFrameWithSoftwareBitmap>,
impl::require<winrt::Windows::Graphics::Imaging::IBitmapFrameWithSoftwareBitmap, winrt::Windows::Graphics::Imaging::IBitmapFrame>
{
IBitmapFrameWithSoftwareBitmap(std::nullptr_t = nullptr) noexcept {}
IBitmapFrameWithSoftwareBitmap(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapProperties :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapProperties>,
impl::require<winrt::Windows::Graphics::Imaging::IBitmapProperties, winrt::Windows::Graphics::Imaging::IBitmapPropertiesView>
{
IBitmapProperties(std::nullptr_t = nullptr) noexcept {}
IBitmapProperties(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapPropertiesView :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapPropertiesView>
{
IBitmapPropertiesView(std::nullptr_t = nullptr) noexcept {}
IBitmapPropertiesView(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapTransform :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapTransform>
{
IBitmapTransform(std::nullptr_t = nullptr) noexcept {}
IBitmapTransform(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapTypedValue :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapTypedValue>
{
IBitmapTypedValue(std::nullptr_t = nullptr) noexcept {}
IBitmapTypedValue(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IBitmapTypedValueFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IBitmapTypedValueFactory>
{
IBitmapTypedValueFactory(std::nullptr_t = nullptr) noexcept {}
IBitmapTypedValueFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IPixelDataProvider :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<IPixelDataProvider>
{
IPixelDataProvider(std::nullptr_t = nullptr) noexcept {}
IPixelDataProvider(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) ISoftwareBitmap :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ISoftwareBitmap>,
impl::require<winrt::Windows::Graphics::Imaging::ISoftwareBitmap, winrt::Windows::Foundation::IClosable>
{
ISoftwareBitmap(std::nullptr_t = nullptr) noexcept {}
ISoftwareBitmap(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) ISoftwareBitmapFactory :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ISoftwareBitmapFactory>
{
ISoftwareBitmapFactory(std::nullptr_t = nullptr) noexcept {}
ISoftwareBitmapFactory(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) ISoftwareBitmapStatics :
winrt::Windows::Foundation::IInspectable,
impl::consume_t<ISoftwareBitmapStatics>
{
ISoftwareBitmapStatics(std::nullptr_t = nullptr) noexcept {}
ISoftwareBitmapStatics(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
}
#endif
| [
"david@lechnology.com"
] | david@lechnology.com |
6da2378488d0d6493ea99e8fc4ef0e3920a67ab5 | 67d18d4bb54f3e7da06674c2bb65e4658d4538ba | /frontend/include/g++_HEADERS/hdrs1/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp | 5755938990137c056005a5d609421df794161499 | [
"MIT"
] | permissive | uwplse/stng | 8c1f483a96c8313b8ec36a15791db75d20cfcf33 | b077f4d469edf4971c356367f6019132047d6a3b | refs/heads/master | 2022-05-06T08:28:27.139569 | 2022-04-05T05:01:49 | 2022-04-05T05:01:49 | 63,819,139 | 15 | 7 | null | 2017-01-13T11:56:50 | 2016-07-20T22:32:32 | C++ | UTF-8 | C++ | false | false | 76 | hpp | /usr/include/c++/4.4/./ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp | [
"akcheung@cs.washington.edu"
] | akcheung@cs.washington.edu |
be19cdf6ae5a6d8518be5ccea1c5ae277b350541 | 33fa64e174fe0ba321b02f9c122d8eb97bb80cfa | /Source/Editor/Objects/SpriteEditor/spriteEditorTools.h | bd361cded7e95bded6b26b43539ad964341ff903 | [] | no_license | HumMan/BaluEngine | c59447d00e9b450a8a190ffc0f56821e423f057b | f62c2d6fbff0472389a6dd424e3cedbf72967979 | refs/heads/master | 2021-04-26T15:37:53.726774 | 2016-10-25T09:23:41 | 2016-10-25T09:23:41 | 43,567,178 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 438 | h | #pragma once
#include <Editor/abstractEditor.h>
using namespace EngineInterface;
class TSpriteEditorScene;
class TSpriteEditorToolsRegistry
{
public:
std::vector<TToolWithDescription> tools;
TSpriteEditorScene* scene;
public:
TSpriteEditorToolsRegistry(TSpriteEditorScene* scene);
TSpriteEditorToolsRegistry(TSpriteEditorToolsRegistry&& o);
const std::vector<TToolWithDescription>& GetTools();
~TSpriteEditorToolsRegistry();
};
| [
"kop3nha@gmail.com"
] | kop3nha@gmail.com |
3d4803ce1a48c47b55dd694492e3fb3ec81c6526 | e1e43f3e90aa96d758be7b7a8356413a61a2716f | /datacommsserver/esockserver/test/te_mecunittest/src/mectestpanic6step.cpp | eadcc5863fbeee85c8a02eaad988c0e6c16c0456 | [] | no_license | SymbianSource/oss.FCL.sf.os.commsfw | 76b450b5f52119f6bf23ae8a5974c9a09018fdfa | bc8ac1a6d5273cbfa7852bbb8ce27d6ddc076984 | refs/heads/master | 2021-01-18T23:55:06.285537 | 2010-10-03T23:21:43 | 2010-10-03T23:21:43 | 72,773,202 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,251 | cpp | // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
// mectestpanic6step.cpp
//
/**
@file
*/
#include "mectestpanic6step.h"
#include "testextensions.h"
#include <comms-infras/ss_rmetaextensioncontainer.h>
#include <comms-infras/ss_commsprov.h>
using namespace ESock;
CMecTestPanic6Step::~CMecTestPanic6Step()
{
}
/**
//! @SYMTestCaseID MEC_UNIT_TEST_106
//! @SYMTestCaseDesc Test Panic mecpanic:1 (ENoImplementation) for RMetaExtensionContainerC::FindExtensionL()
//! @SYMFssID COMMS-INFRAS/Esock/MetaExtensionContainer/UnitTest
//! @SYMTestActions 1) FindExtensionL T1 in constMec
//! @SYMTestExpectedResults Panic mecpanic:1
*/
TVerdict CMecTestPanic6Step::RunTestStepL()
{
RMetaExtensionContainerC mec;
const Meta::SMetaData& ext = mec.FindExtensionL(TTestExtension1::TypeId()); // PANIC
return EFail;
}
| [
"kirill.dremov@nokia.com"
] | kirill.dremov@nokia.com |
6c24425c29c07c480fbfa84260baa5dcf6c31729 | 36c31b485a5906ab514c964491b8f001a70a67f5 | /CSES/Problemset/Range Queries/subarraysumqueries.cpp | 9190157fae83d0ad24f7ab5a8ed53c63d34b6037 | [] | no_license | SMiles02/CompetitiveProgramming | 77926918d5512824900384639955b31b0d0a5841 | 035040538c7e2102a88a2e3587e1ca984a2d9568 | refs/heads/master | 2023-08-18T22:14:09.997704 | 2023-08-13T20:30:42 | 2023-08-13T20:30:42 | 277,504,801 | 25 | 5 | null | 2022-11-01T01:34:30 | 2020-07-06T09:54:44 | C++ | UTF-8 | C++ | false | false | 1,206 | cpp | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mn = 2e5+1;
ll seg[mn<<2][4];
void recalc(int i)
{
int l=(i<<1)+1,r=(i<<1)+2;
seg[i][0]=seg[l][0]+seg[r][0];
seg[i][1]=max({seg[l][0],seg[l][0]+seg[r][0],seg[l][0]+seg[r][1],seg[l][1]});
seg[i][2]=max({seg[r][0],seg[r][0]+seg[l][0],seg[r][0]+seg[l][2],seg[r][2]});
seg[i][3]=max({seg[i][0],seg[i][1],seg[i][2],seg[l][3],seg[r][3],seg[l][2]+seg[r][1]});
}
void build(int i, int l, int r)
{
if (l==r)
{
cin>>seg[i][0];
seg[i][1]=seg[i][2]=seg[i][3]=seg[i][0];
return;
}
build((i<<1)+1,l,(l+r)>>1);
build((i<<1)+2,((l+r)>>1)+1,r);
recalc(i);
}
void update(int i, int l, int r, int j, int x)
{
if (r<j||j<l)
return;
if (l==r)
{
for (int k=0;k<4;++k)
seg[i][k]=x;
return;
}
update((i<<1)+1,l,(l+r)>>1,j,x);
update((i<<1)+2,((l+r)>>1)+1,r,j,x);
recalc(i);
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n,q,x,y;
cin>>n>>q;
build(0,1,n);
while (q--)
{
cin>>x>>y;
update(0,1,n,x,y);
cout<<max({seg[0][3],0LL})<<"\n";
}
return 0;
} | [
"mahajan.suneet2002@gmail.com"
] | mahajan.suneet2002@gmail.com |
e6d7f2ecb53458fd2ac5a688695c41d9311693e4 | f34f81ffa1edddcf935ffb752dc6d55d2d6bed0d | /memory.cpp | bf442bfa87245611ddee20583674e6d41bd6839d | [] | no_license | cesa1995/Enviromental3 | ad0ed3a85ccb58ec786061e8ff5f9215a61aec35 | cb075083c37a4aed2168783ab0e7330089932e12 | refs/heads/master | 2022-11-14T03:32:55.258251 | 2020-06-22T18:03:07 | 2020-06-22T18:03:07 | 274,207,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,169 | cpp | #include "memory.h"
memory::memory(){}
//iniciar la memoria del controlador
bool memory::begin(){
bool success=true;
if(!SPIFFS.begin(true)){
Serial.println("SPIFFS Mount Failed");
success=false;
}
return success;
}
void memory::getServerConfig(int type, String arg[], memory memory, timeClock timeClock, const char* conf){
switch(type){
//guardar apn
case 0:{
Serial.println("configurando APN");
memory.setApn(arg[0]);
memory.setApn_user(arg[1]);
memory.setApn_pass(arg[2]);
Serial.print(memory.getApn());
}break;
//guardar ap
case 1:{
Serial.println("configurando AP");
memory.setSsid_AP(arg[0]);
memory.setPasswd_AP(arg[1]);
// serverWifi.AP_connect(memory);
}break;
//guardar sta
case 2:{
Serial.println("configurando STA");
memory.setSsid_STA(arg[0]);
memory.setPasswd_STA(arg[1]);
//serverWifi.STA_connect(memory, timeClock);
}break;
//guardar la hora
case 3:{
Serial.println("configurando hora");
int yeard=arg[0].substring(0,4).toInt();
int mes=arg[0].substring(5,7).toInt()-1;
int dia=arg[0].substring(8,10).toInt();
int hora=arg[1].substring(0,2).toInt();
int minu=arg[1].substring(3,6).toInt();
timeClock.setTiempo(yeard, mes, dia, hora, minu);
}break;
//guardar el tiempo de espera
case 4:{
Serial.println("configurando time");
memory.setTime_to_sleep(arg[0].toInt());
}break;
}
memory.writeConfiguration(conf);
}
bool memory::existFile(const char * path){
bool success=true;
if(!SPIFFS.exists(path)){
success=false;
}
return success;
}
float memory::sizeFiles(){
float Size=0;
File root=SPIFFS.open("/");
File file = root.openNextFile();
while(file){
if(!file.isDirectory()){
Size+=file.size();
}
file = root.openNextFile();
}
Serial.print("Memoria usada:");
Serial.print(Size/1024);
Serial.println(" KB/4096 KB");
return Size;
}
void memory::deleteFile(const char * path){
Serial.printf("Deleting file: %s\n", path);
if(SPIFFS.remove(path)){
Serial.println("File deleted");
} else {
Serial.println("Delete failed");
}
}
// leer la configuacion si existe en la memoria del controlador
// en caso contrario colocar valores por defecto
bool memory::readConfiguration(const char * filename){
DynamicJsonDocument doc(1500);
bool success=true;
File file = SPIFFS.open(filename);
if(!file){
Serial.println("No existe el archivo. Configurando por defecto!");
success=false;
}
DeserializationError errorD = deserializeJson(doc, file);
if (errorD){
Serial.println("Error al deserializar el archivo.");
Serial.println(errorD.c_str());
success=false;
}
strlcpy(sim.apn, doc["sim"][0] | "", sizeof(sim.apn));
strlcpy(sim.user, doc["sim"][1] | "", sizeof(sim.user));
strlcpy(sim.pass, doc["sim"][2] | "", sizeof(sim.pass));
strlcpy(STA.ssid, doc["sta"][0] | "", sizeof(STA.ssid));
strlcpy(STA.pass, doc["sta"][1] | "", sizeof(STA.pass));
strlcpy(AP.ssid, doc["ap"][0] | "9-COCO2CH4", sizeof(AP.ssid));
strlcpy(AP.pass, doc["ap"][1] | "12345678", sizeof(AP.pass));
CO2.RO=doc["RoCO2"] | 18496.15;
CH4.RO=doc["RoCH4"] | 6765.0;
CO.RO=doc["RoCO"] | 320.0;
CO2.ATM=doc["atmCO2"] | 392.57;
CH4.ATM=doc["atmCH4"] | 1845.0;
CO.ATM=doc["atmCO"] | 1.0;
TIME_TO_SLEEP=doc["sleep"] | 1;
Mode=doc["mode"] | 3;
file.close();
delay(1000);
return success;
}
// Guardar los datos del programa en la memoria interna del controlador
bool memory::writeConfiguration(const char * filename){
DynamicJsonDocument doc(1500);
SPIFFS.remove(filename);
delay(100);
File file = SPIFFS.open(filename, FILE_WRITE);
if (!file) {
Serial.println("no se pudo abrir el archivo.");
return false;
}
JsonArray SIM=doc.createNestedArray("sim");
SIM.add(sim.apn);
SIM.add(sim.user);
SIM.add(sim.pass);
JsonArray sta=doc.createNestedArray("sta");
sta.add(STA.ssid);
sta.add(STA.pass);
JsonArray ap=doc.createNestedArray("ap");
ap.add(AP.ssid);
ap.add(AP.pass);
doc["RoCO2"]=(String)CO2.RO;
doc["RoCH4"]=(String)CH4.RO;
doc["RoCO"]=(String)CO.RO;
doc["atmCO2"]=(String)CO2.ATM;
doc["atmNH4"]=(String)CH4.ATM;
doc["atmCO"]=(String)CO.ATM;
doc["sleep"]=(String)TIME_TO_SLEEP;
doc["mode"]=(String)Mode;
if (serializeJson(doc, file) == 0) {
Serial.println("no se pudo guardar configuracion.");
return false;
}
file.close();
delay(1000);
return true;
}
char* memory::getSsid_AP(){
return AP.ssid;
}
void memory::setSsid_AP(String ssid){
ssid.toCharArray(AP.ssid,sizeof(AP.ssid));
}
char* memory::getPasswd_AP(){
return AP.pass;
}
void memory::setPasswd_AP(String passwd){
passwd.toCharArray(AP.pass,sizeof(AP.pass));
}
char* memory::getSsid_STA(){
return STA.ssid;
}
void memory::setSsid_STA(String ssid){
ssid.toCharArray(STA.ssid, sizeof(STA.ssid));
}
char* memory::getPasswd_STA(){
return STA.pass;
}
void memory::setPasswd_STA(String passwd){
passwd.toCharArray(STA.pass,sizeof(STA.pass));
}
char* memory::getApn(){
return sim.apn;
}
void memory::setApn(String Apn){
Apn.toCharArray(sim.apn, sizeof(sim.apn));
}
char* memory::getApn_user(){
return sim.user;
}
void memory::setApn_user(String user){
user.toCharArray(sim.user, sizeof(sim.user));
}
char* memory::getApn_pass(){
return sim.pass;
}
void memory::setApn_pass(String pass){
pass.toCharArray(sim.pass, sizeof(sim.pass));
}
int memory::getTime_to_sleep(){
return TIME_TO_SLEEP;
}
void memory::setTime_to_sleep(int time_to_sleep){
TIME_TO_SLEEP=time_to_sleep;
}
//getter a setter de sensores
//BME sensor
int memory::getHumidity(){
return BME.humidity;
}
void memory::setHumidity(int humidity){
BME.humidity=humidity;
}
int memory::getTemperature(){
return BME.temperature;
}
void memory::setTemperature(int temperature){
BME.temperature=temperature;
}
int memory::getHeight(){
return BME.height;
}
void memory::setHeight(int height){
BME.height=height;
}
int memory::getPressure(){
return BME.pressure;
}
void memory::setPressure(int pressure){
BME.pressure=pressure;
}
//co2 sensor
int memory::getCo2(){
return CO2.co2;
}
void memory::setCo2(int co2){
CO2.co2=co2;
}
int memory::getCo2_ro(){
return CO2.RO;
}
void memory::setCo2_ro(int ro){
CO2.RO=ro;
}
int memory::getCo2_Atm(){
return CO2.ATM;
}
void memory::setCo2_Atm(int Atm){
CO2.ATM=Atm;
}
//co sensor
int memory::getCo(){
return CO.co;
}
void memory::setCo(int co){
CO.co=co;
}
int memory::getCo_ro(){
return CO.RO;
}
void memory::setCo_ro(int ro){
CO.RO=ro;
}
int memory::getCo_Atm(){
return CO.ATM;
}
void memory::setCo_Atm(int Atm){
CO.ATM=Atm;
}
//ch4 sensor
int memory::getCh4(){
return CH4.ch4;
}
void memory::setCh4(int ch4){
CH4.ch4=ch4;
}
int memory::getCh4_ro(){
return CH4.RO;
}
void memory::setCh4_ro(int ro){
CH4.RO=ro;
}
int memory::getCh4_Atm(){
return CH4.ATM;
}
void memory::setCh4_Atm(int Atm){
CH4.ATM=Atm;
}
| [
"cesar.contreras24777@gmail.com"
] | cesar.contreras24777@gmail.com |
3de0a9fe34ad3392e07f869b899a97351ed66875 | 6762cae7e065d013247f6cce6404949d58cb7966 | /Software/SMT_Oven_stubs/Sources/fonts.h | 4dc7ac29a7e5590f4c2432ea45ef4e47499b6e87 | [] | no_license | podonoghue/T962a_Oven_Controller | c1569d474a134eea82a6b37e9a004df7bd27e699 | 816f82b0fba72aebe46eeb48660ff40b4e00e2d1 | refs/heads/master | 2021-01-17T18:23:13.665067 | 2019-06-12T11:25:57 | 2019-06-12T11:26:20 | 69,413,627 | 15 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 1,007 | h | /**
* @file fonts.h
* @brief Fonts for LCD
*/
#ifndef INCLUDE_USBDM_FONTS_H
#define INCLUDE_USBDM_FONTS_H
#include <stdint.h>
/*
* *****************************
* *** DO NOT EDIT THIS FILE ***
* *****************************
*
* This file is generated automatically.
* Any manual changes will be lost.
*/
namespace USBDM {
/**
* Represents a simple font
*/
class Font {
public:
static constexpr uint8_t BASE_CHAR = ' '; // First character in character set
const uint8_t width; // Width of the character in pixels
const uint8_t height; // Height of the character in pixels
const uint8_t bytesPerChar; // Bytes used for each character in data table
const uint8_t *const data; // Data describing the character pixels (index starts at BASE_CHAR)
};
/** Small 6x8 font */
extern Font smallFont;
/** Medium 8x8 font */
extern Font mediumFont;
/** Large 8x16 font */
extern Font largeFont;
}; // end namespace USBDM
#endif /* INCLUDE_USBDM_FONTS_H */
| [
"podonoghue@swin.edu.au"
] | podonoghue@swin.edu.au |
8e3f4809ec4a5cf983c00aa6a27101dbbb0ab60e | da14530f0161ff1d0461e5eba14c996dc4d329de | /class_CommandLine.h | 69a828aebe74b626b99ca53797d8f2e68afba53e | [] | no_license | lancegatlin/sample-cpp | 2677fa2ff9ce7fc091489e195773593f47361da5 | ed754d5309ae965cd4875045c1293647461a958f | refs/heads/master | 2016-09-06T19:22:32.189562 | 2013-03-23T20:48:59 | 2013-03-23T20:48:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,005 | h | #ifndef __CLASS_COMMANDLINE_H
#define __CLASS_COMMANDLINE_H
#include <vector>
#include <string>
#include <iostream>
#include <string_algorithm.h>
class CommandLine {
public:
typedef std::vector<std::string> tokenList;
private:
std::ostream &_out;
std::istream &_in;
std::string _prompt;
std::string _unkcmd_err;
bool running;
int retcode;
public:
CommandLine(std::ostream &__out, std::istream &__in, const std::string &__prompt)
: _out(__out)
, _in(__in)
, running(true)
, retcode(0)
, _prompt(__prompt)
, _unkcmd_err("Unknown Command")
{ }
std::ostream &out() { return _out; };
std::istream &in() { return _in; };
const std::string &prompt() { return _prompt; };
void prompt(const std::string &s) { _prompt = s; };
const std::string &unkerr_cmd() { return _unkcmd_err; };
void unkcmd_err(const std::string &s) { _unkcmd_err = s; };
virtual void showPrompt() { _out << _prompt; }
virtual int onGo() { return 0; };
virtual int onExit() { return 0; };
virtual void onUnknownCommand(const std::string &input) { _out << _unkcmd_err << std::endl; };
virtual int onCommand(const std::string &input)
{
static tokenList tokens;
tokens.clear();
parse(input, tokens);
return onCommand(input, tokens);
}
virtual int onCommand(const std::string &input, const tokenList &tokens) { return -1; };
virtual int onException(std::exception &e, const std::string &input)
{
_out << "Exception: input=[" << input << "]" << std::endl;
_out << e.what() << std::endl;
}
void stop() { running = false; };
int go(int argc, char *argv[])
{
std::string startup;
if(argc >= 2)
{
startup = argv[1];
for(size_t i=2;i<argc;i++)
{
startup += ' ';
startup += argv[i];
}
}
go(startup);
}
int go(const std::string &startup = std::string())
{
int retcode = onGo();
if(retcode < -1)
return retcode;
std::string input;
input.reserve(1024);
if(startup.length())
input = startup;
else
{
showPrompt();
std::getline(_in, input);
}
tokenList tokens;
while(!_in.eof())
{
try {
if(onCommand(input) == -1)
onUnknownCommand(input);
} catch(std::exception &e)
{
onException(e, input);
}
if(!running)
break;
showPrompt();
std::getline(_in, input);
}
return onExit();
}
virtual void parse(const std::string &in, tokenList &tokens)
{
static const std::string &whitespace = std::string(" \t\n");
::parse(in, tokens, whitespace);
}
};
#endif
| [
"lance.gatlin@gtri.gatech.edu"
] | lance.gatlin@gtri.gatech.edu |
4d19449e6b45d8e9a07f94617db4140b66ac9e6e | 8e8b748965e211710f926deef69cab8077509fef | /Dusk/Graphics/RenderModules/FFTRenderPass.h | 65f6138dca070db1e537052a19fa1b8cb88d2d43 | [] | no_license | i0r/project_freeride | 09240c7725298b4946d911dfff9de22a17c9288b | 896e6c3f08b830f93083f719a0816678c9128efb | refs/heads/master | 2023-02-06T10:07:30.369487 | 2020-12-28T11:10:07 | 2020-12-28T11:10:07 | 263,069,858 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 780 | h | /*
Dusk Source Code
Copyright (C) 2020 Prevost Baptiste
*/
#pragma once
class FrameGraph;
class RenderDevice;
class ShaderCache;
#include "Graphics/FrameGraph.h"
// Output of a FFT renderpass (inverse, convolution, etc.).
struct FFTPassOutput
{
FGHandle RealPart;
FGHandle ImaginaryPart;
FFTPassOutput()
: RealPart( FGHandle::Invalid )
, ImaginaryPart( FGHandle::Invalid )
{
}
};
FFTPassOutput AddFFTComputePass( FrameGraph& frameGraph, FGHandle input, f32 inputTargetWidth, f32 inputTargetHeight );
FGHandle AddInverseFFTComputePass( FrameGraph& frameGraph, FFTPassOutput& inputInFrequencyDomain, f32 outputTargetWidth, f32 outputTarget );
// Dimension (in pixels) for the FFT image.
constexpr i32 FFT_TEXTURE_DIMENSION = 512;
| [
"baptiste.prevost@protonmail.com"
] | baptiste.prevost@protonmail.com |
4fd155a1ce0d59004273936e6988965d92f86d59 | 5ec06dab1409d790496ce082dacb321392b32fe9 | /clients/cpp-qt5-qhttpengine-server/generated/server/src/models/OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo.cpp | 98da913c3996a2fb976babfb5f264ff6b6bf6b6b | [
"Apache-2.0",
"MIT"
] | permissive | shinesolutions/swagger-aem-osgi | e9d2385f44bee70e5bbdc0d577e99a9f2525266f | c2f6e076971d2592c1cbd3f70695c679e807396b | refs/heads/master | 2022-10-29T13:07:40.422092 | 2021-04-09T07:46:03 | 2021-04-09T07:46:03 | 190,217,155 | 3 | 3 | Apache-2.0 | 2022-10-05T03:26:20 | 2019-06-04T14:23:28 | null | UTF-8 | C++ | false | false | 4,625 | cpp | /**
* Adobe Experience Manager OSGI config (AEM) API
* Swagger AEM OSGI is an OpenAPI specification for Adobe Experience Manager (AEM) OSGI Configurations API
*
* OpenAPI spec version: 1.0.0-pre.0
* Contact: opensource@shinesolutions.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo.h"
#include "OAIHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace OpenAPI {
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo(QString json) {
this->fromJson(json);
}
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo() {
this->init();
}
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::~OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo() {
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::init() {
m_pid_isSet = false;
m_title_isSet = false;
m_description_isSet = false;
m_properties_isSet = false;
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::fromJson(QString jsonString) {
QByteArray array (jsonString.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::fromJsonObject(QJsonObject json) {
::OpenAPI::fromJsonValue(pid, json[QString("pid")]);
::OpenAPI::fromJsonValue(title, json[QString("title")]);
::OpenAPI::fromJsonValue(description, json[QString("description")]);
::OpenAPI::fromJsonValue(properties, json[QString("properties")]);
}
QString
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::asJson () const {
QJsonObject obj = this->asJsonObject();
QJsonDocument doc(obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::asJsonObject() const {
QJsonObject obj;
if(m_pid_isSet){
obj.insert(QString("pid"), ::OpenAPI::toJsonValue(pid));
}
if(m_title_isSet){
obj.insert(QString("title"), ::OpenAPI::toJsonValue(title));
}
if(m_description_isSet){
obj.insert(QString("description"), ::OpenAPI::toJsonValue(description));
}
if(properties.isSet()){
obj.insert(QString("properties"), ::OpenAPI::toJsonValue(properties));
}
return obj;
}
QString
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::getPid() const {
return pid;
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::setPid(const QString &pid) {
this->pid = pid;
this->m_pid_isSet = true;
}
QString
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::getTitle() const {
return title;
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::setTitle(const QString &title) {
this->title = title;
this->m_title_isSet = true;
}
QString
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::getDescription() const {
return description;
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::setDescription(const QString &description) {
this->description = description;
this->m_description_isSet = true;
}
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougProperties
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::getProperties() const {
return properties;
}
void
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::setProperties(const OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougProperties &properties) {
this->properties = properties;
this->m_properties_isSet = true;
}
bool
OAIComDayCqMcmLandingpageParserTaghandlersCtaGraphicalClickThrougInfo::isSet() const {
bool isObjectUpdated = false;
do{
if(m_pid_isSet){ isObjectUpdated = true; break;}
if(m_title_isSet){ isObjectUpdated = true; break;}
if(m_description_isSet){ isObjectUpdated = true; break;}
if(properties.isSet()){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}
| [
"cliffano@gmail.com"
] | cliffano@gmail.com |
dc4d99e897b94c1e245f92b0f5458954d46725c6 | d9650a91cde69003c0049779afd43e01646c56b7 | /Server/hdr/Logger.hpp | 65a6ffc6ca3e9c6caf64e90598a0c29a7a8be371 | [] | no_license | sdberardinelli/fault-detection | b080be8e1b3e45c5759b384933be803f08486e0b | f26bc9c6f92facb1a33ff4550aa9b48f833cc792 | refs/heads/master | 2020-12-24T17:08:33.775713 | 2014-04-23T02:29:19 | 2014-04-23T02:29:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,017 | hpp | /******************************************************************************
* Filename : Logger.hpp
* Source File(s): Logger.cpp
* Description :
* Authors(s) :
* Date Created :
* Date Modified :
* Modifier(s) :
*******************************************************************************/
#ifndef LOGGER_H
#define LOGGER_H
/*******************************************************************************
* INCLUDES
********************************************************************************/
#include <string>
/*******************************************************************************
* DEFINES
********************************************************************************/
/*******************************************************************************
* MACROS
********************************************************************************/
/*******************************************************************************
* DATA TYPES
********************************************************************************/
/*******************************************************************************
* EXTERNALS
********************************************************************************/
/*******************************************************************************
* CLASS DEFINITIONS
********************************************************************************/
class Logger
{
public:
/* constructors */
Logger ( bool, bool );
Logger ( void ); /* default */
Logger ( Logger& ); /* copy */
Logger& operator= ( const Logger& ); /* assign */
~Logger ( void );
/* functions */
void log (std::string,std::string,std::string);
void enable_logging ( void );
void disable_logging ( void );
void enable_timestamp ( void );
void disable_timestamp ( void );
private:
void _init (void);
bool logging;
bool timestamp;
};
#endif | [
"sethb@198.105.251.35"
] | sethb@198.105.251.35 |
5c3737d68b6ebc0ac4d4ed621715a7092b1dfbcd | 3fee62a27cffa0853e019a3352ac4fc0e0496a3d | /zCleanupCamSpace/ZenGin/Gothic_I_Addon/API/oBarrier.h | 021dc7e4209330335b23e18e7a30b57d6d62c7d3 | [] | no_license | Gratt-5r2/zCleanupCamSpace | f4efcafe95e8a19744347ac40b5b721ddbd73227 | 77daffabac84c8e8bc45e0d7bcd7289520766068 | refs/heads/master | 2023-08-20T15:22:49.382145 | 2021-10-30T12:27:17 | 2021-10-30T12:27:17 | 422,874,598 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,661 | h | // Supported with union (c) 2018-2021 Union team
#ifndef __OBARRIER_H__VER1__
#define __OBARRIER_H__VER1__
namespace Gothic_I_Addon {
enum zTThunderSector {
zTThunderSector_None,
zTThunderSector_1,
zTThunderSector_2,
zTThunderSector_3,
zTThunderSector_4
};
// sizeof F8h
struct myVert {
public:
int vertIndex; // sizeof 04h offset 00h
int vertNeighbours[8]; // sizeof 20h offset 04h
int numNeighbours; // sizeof 04h offset 24h
int polyIndices[50]; // sizeof C8h offset 28h
int numPolyIndices; // sizeof 04h offset F0h
int active; // sizeof 04h offset F4h
myVert() {}
};
// sizeof 4Ch
struct myThunder {
public:
zVEC3 originVec; // sizeof 0Ch offset 00h
myThunder* childs; // sizeof 04h offset 0Ch
int numChilds; // sizeof 04h offset 10h
float startTime[5]; // sizeof 14h offset 14h
zCPolyStrip* polyStrip; // sizeof 04h offset 28h
int numSegs; // sizeof 04h offset 2Ch
int valid; // sizeof 04h offset 30h
float t0; // sizeof 04h offset 34h
float t1; // sizeof 04h offset 38h
int numSplits; // sizeof 04h offset 3Ch
int dead; // sizeof 04h offset 40h
int isChild; // sizeof 04h offset 44h
zTThunderSector sector; // sizeof 04h offset 48h
void myThunder_OnInit() zCall( 0x00655E80 );
~myThunder() zCall( 0x006550A0 );
myThunder() zInit( myThunder_OnInit() );
};
// sizeof 04h
struct myPoly {
public:
int Alpha; // sizeof 04h offset 00h
myPoly() {}
};
// sizeof 124h
class oCBarrier {
public:
zCMesh* skySphereMesh; // sizeof 04h offset 00h
myPoly* myPolyList; // sizeof 04h offset 04h
myVert* myVertList; // sizeof 04h offset 08h
int numMyVerts; // sizeof 04h offset 0Ch
int numMyPolys; // sizeof 04h offset 10h
myThunder* myThunderList; // sizeof 04h offset 14h
int numMaxThunders; // sizeof 04h offset 18h
int numMyThunders; // sizeof 04h offset 1Ch
int actualIndex; // sizeof 04h offset 20h
int rootBoltIndex; // sizeof 04h offset 24h
int startPointList1[10]; // sizeof 28h offset 28h
int numStartPoints1; // sizeof 04h offset 50h
int startPointList2[10]; // sizeof 28h offset 54h
int numStartPoints2; // sizeof 04h offset 7Ch
int startPointList3[10]; // sizeof 28h offset 80h
int numStartPoints3; // sizeof 04h offset A8h
int startPointList4[10]; // sizeof 28h offset ACh
int numStartPoints4; // sizeof 04h offset D4h
int topestPoint; // sizeof 04h offset D8h
int bFadeInOut; // sizeof 04h offset DCh
int fadeState; // sizeof 04h offset E0h
int fadeIn; // sizeof 04h offset E4h
int fadeOut; // sizeof 04h offset E8h
zCSoundFX* sfx1; // sizeof 04h offset ECh
int sfxHandle1; // sizeof 04h offset F0h
zCSoundFX* sfx2; // sizeof 04h offset F4h
int sfxHandle2; // sizeof 04h offset F8h
zCSoundFX* sfx3; // sizeof 04h offset FCh
int sfxHandle3; // sizeof 04h offset 100h
zCSoundFX* sfx4; // sizeof 04h offset 104h
int sfxHandle4; // sizeof 04h offset 108h
zCDecal* thunderStartDecal; // sizeof 04h offset 10Ch
int activeThunder_Sector1; // sizeof 04h offset 110h
int activeThunder_Sector2; // sizeof 04h offset 114h
int activeThunder_Sector3; // sizeof 04h offset 118h
int activeThunder_Sector4; // sizeof 04h offset 11Ch
zVEC2* originalTexUVList; // sizeof 04h offset 120h
void oCBarrier_OnInit() zCall( 0x006550D0 );
oCBarrier() zInit( oCBarrier_OnInit() );
~oCBarrier() zCall( 0x00655AB0 );
void Initialise( int ) zCall( 0x00655D90 );
void AddTremor( zTRenderContext& ) zCall( 0x00655E90 );
void RenderLayer( zTRenderContext&, int, int& ) zCall( 0x00655EA0 );
int Render( zTRenderContext&, int, int ) zCall( 0x006560E0 );
void InitThunder( myThunder* ) zCall( 0x00656B70 );
void RemoveThunder( myThunder* ) zCall( 0x00656BA0 );
int AddThunderSub( myThunder*, int, int, int, int ) zCall( 0x00656C50 );
int AddThunder( int, int, float, zTThunderSector ) zCall( 0x00656FE0 );
int RenderThunder( myThunder*, zTRenderContext& ) zCall( 0x00657820 );
void RenderThunderList( zTRenderContext& ) zCall( 0x00657AF0 );
// user API
#include "oCBarrier.inl"
};
// sizeof 688h
class oCSkyControler_Barrier : public zCSkyControler_Outdoor {
public:
oCBarrier* barrier; // sizeof 04h offset 680h
int bFadeInOut; // sizeof 04h offset 684h
void oCSkyControler_Barrier_OnInit() zCall( 0x00657B30 );
oCSkyControler_Barrier() zInit( oCSkyControler_Barrier_OnInit() );
virtual ~oCSkyControler_Barrier() zCall( 0x00657BF0 );
virtual void RenderSkyPre() zCall( 0x00657C60 );
// user API
#include "oCSkyControler_Barrier.inl"
};
} // namespace Gothic_I_Addon
#endif // __OBARRIER_H__VER1__ | [
"amax96@yandex.ru"
] | amax96@yandex.ru |
411730936e9eb1ef35caddd0090aaa22eb0bdd64 | e6d888dedc7b5a98352a2cd0e78c90a5a2b40497 | /src/cpp/deus/unicode_view_impl/UTF8SymbolToByteIndex.inl | 82a818bba93fb299c3c9cf63cd0a3fa496bfd2b9 | [] | no_license | the-arcane-initiative/Deus | 91659f2ca229cea5af94935d78eb36e1b594c44b | b1780190c6dfb3f6257c3cb77c8d35115bb59ef8 | refs/heads/master | 2021-05-03T17:31:29.867167 | 2018-06-12T10:49:32 | 2018-06-12T10:49:32 | 120,448,101 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,879 | inl | /*!
* \file
* \author David Saxon
* \brief Inline definitions for UTF-8 implementations of the
* symbol_to_byte_index function.
*
* \copyright Copyright (c) 2018, The Arcane Initiative
* All rights reserved.
*
* \license BSD 3-Clause License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DEUS_UNICODEVIEWIMPL_UTF8SYMBOLTOBYTEINDEX_INL_
#define DEUS_UNICODEVIEWIMPL_UTF8SYMBOLTOBYTEINDEX_INL_
namespace deus
{
DEUS_VERSION_NS_BEGIN
namespace utf8_inl
{
DEUS_FORCE_INLINE std::size_t symbol_to_byte_index_naive(
const deus::UnicodeView& self,
std::size_t symbol_index)
{
// generic checks
// --
if(symbol_index >= self.length())
{
return self.c_str_length() + (symbol_index - self.length());
}
// --
const char* data = self.c_str();
std::size_t current_symbol = 0;
std::size_t byte_counter = 0;
while(current_symbol != symbol_index)
{
byte_counter += utf8_inl::bytes_in_symbol(data + byte_counter);
++current_symbol;
}
return byte_counter;
}
// TODO: can write a word batching version that checks whether we've reached the
// symbol index or not
// However for now this implementation seems suspiciously fast.
} // namespace utf8_inl
DEUS_VERSION_NS_END
} // namespace deus
#endif
| [
"davidesaxon@gmail.com"
] | davidesaxon@gmail.com |
10920370e6fe997a6661ff2392c4a1a136719834 | ba9999ffb55fcd9491ddb796301f5c53975e275d | /include/sflight/mdls/modules/InverseDesign.hpp | e79e49b61a859a23260fe80131f96f177a0bad07 | [] | no_license | doughodson/sflight | 60c9d90d48e8a924652c38180c3031076e78e19e | 2200e5e8c9ececb3cde6e425ff95bea1ad336aca | refs/heads/master | 2022-02-28T21:34:35.854217 | 2019-09-06T18:11:29 | 2019-09-06T18:11:29 | 85,605,587 | 10 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,465 | hpp |
#ifndef __sflight_mdls_InverseDesign_HPP__
#define __sflight_mdls_InverseDesign_HPP__
#include "sflight/mdls/modules/Module.hpp"
#include "sflight/xml_bindings/init_InverseDesign.hpp"
namespace sflight {
namespace xml {
class Node;
}
namespace mdls {
class Player;
//------------------------------------------------------------------------------
// Class: InverseDesign
// Description: Sets up a simple aero lookup table system
//------------------------------------------------------------------------------
class InverseDesign : public Module
{
public:
InverseDesign(Player*, const double frameRate);
// module interface
virtual void update(const double timestep) override;
void getAeroCoefs(const double pitch, const double u, const double vz, const double rho,
const double weight, const double thrust, double& alpha, double& cl, double& cd);
double getThrust(double rho, double mach, double throttle);
double getFuelFlow(double rho, double mach, double thrust);
friend void xml_bindings::init_InverseDesign(xml::Node*, InverseDesign*);
private:
double designWeight{};
double designAlt{};
double wingSpan{};
double wingArea{};
double staticThrust{};
double staticTSFC{};
double thrustAngle{};
double dTdM{};
double dTdRho{};
double dTSFCdM{};
double qdes{};
double cdo{};
double clo{};
double a{};
double b{};
bool usingMachEffects{true};
};
}
}
#endif
| [
"doug@openeaagles.org"
] | doug@openeaagles.org |
80af6eb91c0bd37f232f942052f404a7f8dbdf94 | 0149a18329517d09305285f16ab41a251835269f | /Problem Set Volumes/Volume 6 (600-699)/UVa_612_DNA_Sorting.cpp | 644ce8301b0bf740259c48ecaab9ab1c700ff47a | [] | no_license | keisuke-kanao/my-UVa-solutions | 138d4bf70323a50defb3a659f11992490f280887 | f5d31d4760406378fdd206dcafd0f984f4f80889 | refs/heads/master | 2021-05-14T13:35:56.317618 | 2019-04-16T10:13:45 | 2019-04-16T10:13:45 | 116,445,001 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 900 | cpp |
/*
UVa 612 - DNA Sorting
To build using Visual Studio 2008:
cl -EHsc -O2 UVa_612_DNA_Sorting.cpp
*/
#include <iostream>
#include <algorithm>
using namespace std;
const int n_max = 50, m_max = 100;
struct dna_string {
char s_[n_max + 1];
int sortedness_;
bool operator<(const dna_string& s) const {return sortedness_ < s.sortedness_;}
};
dna_string dna_strings[m_max];
int main()
{
int M;
cin >> M;
while (M--) {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
dna_string& ds = dna_strings[i];
cin >> ds.s_;
ds.sortedness_ = 0;
for (int j = 0; j < n - 1; j++)
for (int k = j + 1; k < n; k++)
if (ds.s_[j] > ds.s_[k])
ds.sortedness_++;
}
stable_sort(dna_strings, dna_strings + m);
for (int i = 0; i < m; i++)
cout << dna_strings[i].s_ << endl;
if (M)
cout << endl;
}
return 0;
}
| [
"keisuke.kanao.154@gmail.com"
] | keisuke.kanao.154@gmail.com |
367779c0fd92eb9ea361673e871055af8f66fb36 | 0dda8cef707f38f5058c3503666cbe3bf6ce8c57 | /CODEFORCES/373D_Counting_Rectangles_is_Fun.cpp | 36254a53fe909f3124831bf4460d2b6e004b84f8 | [] | no_license | Yuessiah/Destiny_Record | 4b1ea05be13fa8e78b55bc95f8ee9a1b682108f2 | 69beb5486d2048e43fb5943c96c093f77e7133af | refs/heads/master | 2022-10-09T07:05:04.820318 | 2022-10-07T01:50:58 | 2022-10-07T01:50:58 | 44,083,491 | 0 | 1 | null | 2017-05-04T12:50:35 | 2015-10-12T04:08:17 | C++ | UTF-8 | C++ | false | false | 998 | cpp | #include<bits/stdc++.h>
using namespace std;
int constexpr maxn = 50;
int n, m, q, a, b, c, d;
char grid[maxn][maxn];
int pre[maxn][maxn], dp[maxn][maxn][maxn][maxn];
int main()
{
cin >> n >> m >> q;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> grid[i][j];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
pre[i][j] = pre[i][j-1]+pre[i-1][j]-pre[i-1][j-1]+(grid[i][j]=='1');
for(int a = n; a >= 1; a--)
for(int b = m; b >= 1; b--)
for(int c = a; c <= n; c++)
for(int d = b; d <= m; d++) {
dp[a][b][c][d] = pre[c][d]-pre[c][b-1]-pre[a-1][d]+pre[a-1][b-1] == 0; // good?
for(int k = 1; k < 1<<4; k++) {
int pie = (__builtin_popcount(k)&1)? 1 : -1; // principle of inclusion-exclusion
dp[a][b][c][d] += pie * dp[a+!!(k&1)][b+!!(k&2)][c-!!(k&4)][d-!!(k&8)];
}
}
while(q--) {
cin >> a >> b >> c >> d;
cout << dp[a][b][c][d] << endl;
}
return 0;
}
| [
"yuessiah@gmail.com"
] | yuessiah@gmail.com |
7689076f1b0904bbd6d961ace044d0226e93eb50 | bf04643a3ef65d04eace73ea5757ea5f2a1841c4 | /LCOF/lcof51 数组中的逆序对(归并排序)/res.cpp | 200b974cde66e35554e8fa2f9aae8ab2361300a6 | [] | no_license | MiChuan/Leetcode | 4ec65ee65bc4769ba0f7dbdba2db38e50ec4b331 | 802386b9ad4dd89d085ea9a7c095d101eb3d5343 | refs/heads/master | 2022-12-23T07:58:02.425794 | 2020-10-04T08:18:49 | 2020-10-04T08:18:49 | 275,826,054 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | cpp | class Solution {
public:
vector<int> tmp;
int merge(vector<int>& nums,int l,int r){
if(l>=r) return 0;
int mid = (l+r)>>1;
int res = merge(nums,l,mid)+merge(nums,mid+1,r);
for(int i = l;i<=r;i++) tmp[i]=nums[i];
for(int k = l,i =l,j=mid+1;k<=r;k++)
if( i > mid) nums[k]=tmp[j++];
else if( j > r) nums[k]=tmp[i++];
else if(tmp[i]>tmp[j]) {
//nums[i]>nums[j]时,res+=mid-i+1;
//其余与归并排序一样
nums[k]=tmp[j++];
res += mid-i+1;
}
else nums[k]=tmp[i++];
return res;
}
int reversePairs(vector<int>& nums) {
tmp = vector<int> (nums.begin(),nums.end());
return merge(nums,0,nums.size()-1);
}
}; | [
"1102066475@qq.com"
] | 1102066475@qq.com |
967190f3ffe7c13adda19bff8c9b24375accb390 | 417e25aca1bbbaada5864d3b3b5814fa16ecbe11 | /supersonic/deke/table2data/table2data_q3_1.cc | 106d4caced4399b2a544bde6441aba66eefc6fd6 | [] | no_license | axyu/mixDB | 3f2da4935db870947156c139bd6a66be862778c1 | bf12a4d1d181c815d475eaef3920f4ad145d23f1 | refs/heads/master | 2021-01-17T13:25:59.423964 | 2016-07-14T05:44:32 | 2016-07-14T05:44:32 | 54,551,705 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,070 | cc | #include <iostream>
#include "supersonic/supersonic.h"
#include "supersonic/base/infrastructure/tuple_schema.h"
#include "supersonic/base/infrastructure/test_data_generater.h"
#include "supersonic/utils/file.h"
#include "supersonic/cursor/infrastructure/file_io.h"
#include <vector>
#include <sstream>
#include "deke/include/visit_times_to_locality.h"
#include "deke/include/ssb_q3_1.h"
using std::cout;
using std::endl;
using std::vector;
using std::stringstream;
using namespace supersonic;
int get_time(struct timespec& begin, struct timespec& end) {
return 1000 * (end.tv_sec - begin.tv_sec) + (end.tv_nsec - begin.tv_nsec) / 1000000;
}
int main(int argc, char* argv[]) {
Table2Data_Q3_1::Customer("/home/fish/data/ssb/customer.tbl", "../storage/customer_q3_1.tbl");
Table2Data_Q3_1::Supplier("/home/fish/data/ssb/supplier.tbl", "../storage/supplier_q3_1.tbl");
Table2Data_Q3_1::Date("/home/fish/data/ssb/date.tbl", "../storage/date_q3_1.tbl");
//Table2Data_Q3_1::Lineorder("/home/fish/data/ssb/lineorder.tbl", "../storage/lineorder_q3_1.tbl");
return 0;
}
| [
"lab.u@catfish.com"
] | lab.u@catfish.com |
c227489850397a1f1562772e73ff2198eb800d4e | 5d38d989e096bb2b2298d38c3c570e914e3a2c50 | /Source/OceanBoats/Private/UI/Menu/Widgets/SSoldierMenuItem.h | a807b2fe14990332211f83bd069e4c313cc9af26 | [] | no_license | magrlemon/OceanShips | 2b9b7419184aadea38f62acb123194c10a8dd42a | 7e4cb5a3aa6b6bd3c7c1027b3d9c1b9b270c6ebf | refs/heads/master | 2023-01-02T21:54:55.404769 | 2020-10-21T14:37:34 | 2020-10-21T14:37:34 | 285,441,836 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,578 | h | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SlateBasics.h"
#include "SlateExtras.h"
//class declare
class SSoldierMenuItem : public SCompoundWidget
{
public:
DECLARE_DELEGATE_OneParam( FOnArrowPressed, int );
SLATE_BEGIN_ARGS(SSoldierMenuItem)
{}
/** weak pointer to the parent PC */
SLATE_ARGUMENT(TWeakObjectPtr<ULocalPlayer>, PlayerOwner)
/** called when the button is clicked */
SLATE_EVENT(FOnClicked, OnClicked)
/** called when the left or right arrow is clicked */
SLATE_EVENT(FOnArrowPressed, OnArrowPressed)
/** menu item text attribute */
SLATE_ATTRIBUTE(FText, Text)
/** is it multi-choice item? */
SLATE_ARGUMENT(bool, bIsMultichoice)
/** menu item option text attribute */
SLATE_ATTRIBUTE(FText, OptionText)
/** menu item text transparency when item is not active, optional argument */
SLATE_ARGUMENT(TOptional<float>, InactiveTextAlpha)
/** end of slate attributes definition */
SLATE_END_ARGS()
/** needed for every widget */
void Construct(const FArguments& InArgs);
/** says that we can support keyboard focus */
virtual bool SupportsKeyboardFocus() const override { return true; }
/** mouse button down callback */
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
/** mouse button up callback */
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
/** sets this menu item as active (selected) */
void SetMenuItemActive(bool bIsMenuItemActive);
/** modify the displayed item text */
void UpdateItemText(const FText& UpdatedText);
/** set in option item to enable left arrow*/
EVisibility LeftArrowVisible;
/** set in option item to enable right arrow*/
EVisibility RightArrowVisible;
protected:
/** the delegate to execute when the button is clicked */
FOnClicked OnClicked;
/** the delegate to execute when one of arrows was pressed */
FOnArrowPressed OnArrowPressed;
private:
/** menu item text attribute */
TAttribute< FText > Text;
/** menu item option text attribute */
TAttribute< FText > OptionText;
/** menu item text widget */
TSharedPtr<STextBlock> TextWidget;
/** menu item text color */
FLinearColor TextColor;
/** item margin */
float ItemMargin;
/** getter for menu item background color */
FSlateColor GetButtonBgColor() const;
/** getter for menu item text color */
FSlateColor GetButtonTextColor() const;
/** getter for menu item text shadow color */
FLinearColor GetButtonTextShadowColor() const;
/** getter for left option arrow visibility */
EVisibility GetLeftArrowVisibility() const;
/** getter for right option arrow visibility */
EVisibility GetRightArrowVisibility() const;
/** getter option padding (depends on right arrow visibility) */
FMargin GetOptionPadding() const;
/** calls OnArrowPressed */
FReply OnRightArrowDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent);
/** calls OnArrowPressed */
FReply OnLeftArrowDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent);
/** inactive text alpha value*/
float InactiveTextAlpha;
/** active item flag */
bool bIsActiveMenuItem;
/** is this menu item represents multi-choice field */
bool bIsMultichoice;
/** pointer to our parent PC */
TWeakObjectPtr<class ULocalPlayer> PlayerOwner;
/** style for the menu item */
const struct FArmySimMenuItemStyle *ItemStyle;
};
| [
"magr_lemon@126.com"
] | magr_lemon@126.com |
3a4b778e7e584bdbd90fef490052d0b3b9858700 | b939f147cff6f256c9a30b66e8826d7d3f021ea7 | /cpp/gpu-offscreen/external/ktx/other_include/assimp/SceneCombiner.h | 9b2be795f4a4201b443c4462787f19f4177dfc24 | [] | no_license | evopen/gr | 6364db7fc4a8bf72ad047fd30c08aba4f73fe6f8 | 8947b093d0559a5f90de239e9bc5ead2325e3f5c | refs/heads/master | 2021-05-26T03:27:07.030549 | 2020-09-05T01:14:50 | 2020-09-05T01:14:50 | 254,032,767 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,745 | h | /*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file Declares a helper class, "SceneCombiner" providing various
* utilities to merge scenes.
*/
#ifndef AI_SCENE_COMBINER_H_INC
#define AI_SCENE_COMBINER_H_INC
#include <assimp/ai_assert.h>
#include <assimp/types.h>
#include <assimp/Defines.h>
#include <stddef.h>
#include <set>
#include <list>
#include <stdint.h>
#include <vector>
struct aiScene;
struct aiNode;
struct aiMaterial;
struct aiTexture;
struct aiCamera;
struct aiLight;
struct aiMetadata;
struct aiBone;
struct aiMesh;
struct aiAnimation;
struct aiNodeAnim;
namespace Assimp {
// ---------------------------------------------------------------------------
/** \brief Helper data structure for SceneCombiner.
*
* Describes to which node a scene must be attached to.
*/
struct AttachmentInfo
{
AttachmentInfo()
: scene (NULL)
, attachToNode (NULL)
{}
AttachmentInfo(aiScene* _scene, aiNode* _attachToNode)
: scene (_scene)
, attachToNode (_attachToNode)
{}
aiScene* scene;
aiNode* attachToNode;
};
// ---------------------------------------------------------------------------
struct NodeAttachmentInfo
{
NodeAttachmentInfo()
: node (NULL)
, attachToNode (NULL)
, resolved (false)
, src_idx (SIZE_MAX)
{}
NodeAttachmentInfo(aiNode* _scene, aiNode* _attachToNode,size_t idx)
: node (_scene)
, attachToNode (_attachToNode)
, resolved (false)
, src_idx (idx)
{}
aiNode* node;
aiNode* attachToNode;
bool resolved;
size_t src_idx;
};
// ---------------------------------------------------------------------------
/** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES
* Generate unique names for all named scene items
*/
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1
/** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES
* Generate unique names for materials, too.
* This is not absolutely required to pass the validation.
*/
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2
/** @def AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY
* Use deep copies of duplicate scenes
*/
#define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4
/** @def AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS
* If attachment nodes are not found in the given master scene,
* search the other imported scenes for them in an any order.
*/
#define AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS 0x8
/** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY
* Can be combined with AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES.
* Unique names are generated, but only if this is absolutely
* required to avoid name conflicts.
*/
#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY 0x10
typedef std::pair<aiBone*,unsigned int> BoneSrcIndex;
// ---------------------------------------------------------------------------
/** @brief Helper data structure for SceneCombiner::MergeBones.
*/
struct BoneWithHash : public std::pair<uint32_t,aiString*> {
std::vector<BoneSrcIndex> pSrcBones;
};
// ---------------------------------------------------------------------------
/** @brief Utility for SceneCombiner
*/
struct SceneHelper
{
SceneHelper ()
: scene (NULL)
, idlen (0)
{
id[0] = 0;
}
explicit SceneHelper (aiScene* _scene)
: scene (_scene)
, idlen (0)
{
id[0] = 0;
}
AI_FORCE_INLINE aiScene* operator-> () const
{
return scene;
}
// scene we're working on
aiScene* scene;
// prefix to be added to all identifiers in the scene ...
char id [32];
// and its strlen()
unsigned int idlen;
// hash table to quickly check whether a name is contained in the scene
std::set<unsigned int> hashes;
};
// ---------------------------------------------------------------------------
/** \brief Static helper class providing various utilities to merge two
* scenes. It is intended as internal utility and NOT for use by
* applications.
*
* The class is currently being used by various postprocessing steps
* and loaders (ie. LWS).
*/
class ASSIMP_API SceneCombiner
{
// class cannot be instanced
SceneCombiner() {}
public:
// -------------------------------------------------------------------
/** Merges two or more scenes.
*
* @param dest Receives a pointer to the destination scene. If the
* pointer doesn't point to NULL when the function is called, the
* existing scene is cleared and refilled.
* @param src Non-empty list of scenes to be merged. The function
* deletes the input scenes afterwards. There may be duplicate scenes.
* @param flags Combination of the AI_INT_MERGE_SCENE flags defined above
*/
static void MergeScenes(aiScene** dest,std::vector<aiScene*>& src,
unsigned int flags = 0);
// -------------------------------------------------------------------
/** Merges two or more scenes and attaches all scenes to a specific
* position in the node graph of the master scene.
*
* @param dest Receives a pointer to the destination scene. If the
* pointer doesn't point to NULL when the function is called, the
* existing scene is cleared and refilled.
* @param master Master scene. It will be deleted afterwards. All
* other scenes will be inserted in its node graph.
* @param src Non-empty list of scenes to be merged along with their
* corresponding attachment points in the master scene. The function
* deletes the input scenes afterwards. There may be duplicate scenes.
* @param flags Combination of the AI_INT_MERGE_SCENE flags defined above
*/
static void MergeScenes(aiScene** dest, aiScene* master,
std::vector<AttachmentInfo>& src,
unsigned int flags = 0);
// -------------------------------------------------------------------
/** Merges two or more meshes
*
* The meshes should have equal vertex formats. Only components
* that are provided by ALL meshes will be present in the output mesh.
* An exception is made for VColors - they are set to black. The
* meshes should have the same material indices, too. The output
* material index is always the material index of the first mesh.
*
* @param dest Destination mesh. Must be empty.
* @param flags Currently no parameters
* @param begin First mesh to be processed
* @param end Points to the mesh after the last mesh to be processed
*/
static void MergeMeshes(aiMesh** dest,unsigned int flags,
std::vector<aiMesh*>::const_iterator begin,
std::vector<aiMesh*>::const_iterator end);
// -------------------------------------------------------------------
/** Merges two or more bones
*
* @param out Mesh to receive the output bone list
* @param flags Currently no parameters
* @param begin First mesh to be processed
* @param end Points to the mesh after the last mesh to be processed
*/
static void MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator it,
std::vector<aiMesh*>::const_iterator end);
// -------------------------------------------------------------------
/** Merges two or more materials
*
* The materials should be complementary as much as possible. In case
* of a property present in different materials, the first occurrence
* is used.
*
* @param dest Destination material. Must be empty.
* @param begin First material to be processed
* @param end Points to the material after the last material to be processed
*/
static void MergeMaterials(aiMaterial** dest,
std::vector<aiMaterial*>::const_iterator begin,
std::vector<aiMaterial*>::const_iterator end);
// -------------------------------------------------------------------
/** Builds a list of uniquely named bones in a mesh list
*
* @param asBones Receives the output list
* @param it First mesh to be processed
* @param end Last mesh to be processed
*/
static void BuildUniqueBoneList(std::list<BoneWithHash>& asBones,
std::vector<aiMesh*>::const_iterator it,
std::vector<aiMesh*>::const_iterator end);
// -------------------------------------------------------------------
/** Add a name prefix to all nodes in a scene.
*
* @param Current node. This function is called recursively.
* @param prefix Prefix to be added to all nodes
* @param len STring length
*/
static void AddNodePrefixes(aiNode* node, const char* prefix,
unsigned int len);
// -------------------------------------------------------------------
/** Add an offset to all mesh indices in a node graph
*
* @param Current node. This function is called recursively.
* @param offset Offset to be added to all mesh indices
*/
static void OffsetNodeMeshIndices (aiNode* node, unsigned int offset);
// -------------------------------------------------------------------
/** Attach a list of node graphs to well-defined nodes in a master
* graph. This is a helper for MergeScenes()
*
* @param master Master scene
* @param srcList List of source scenes along with their attachment
* points. If an attachment point is NULL (or does not exist in
* the master graph), a scene is attached to the root of the master
* graph (as an additional child node)
* @duplicates List of duplicates. If elem[n] == n the scene is not
* a duplicate. Otherwise elem[n] links scene n to its first occurrence.
*/
static void AttachToGraph ( aiScene* master,
std::vector<NodeAttachmentInfo>& srcList);
static void AttachToGraph (aiNode* attach,
std::vector<NodeAttachmentInfo>& srcList);
// -------------------------------------------------------------------
/** Get a deep copy of a scene
*
* @param dest Receives a pointer to the destination scene
* @param src Source scene - remains unmodified.
*/
static void CopyScene(aiScene** dest,const aiScene* source,bool allocate = true);
// -------------------------------------------------------------------
/** Get a flat copy of a scene
*
* Only the first hierarchy layer is copied. All pointer members of
* aiScene are shared by source and destination scene. If the
* pointer doesn't point to NULL when the function is called, the
* existing scene is cleared and refilled.
* @param dest Receives a pointer to the destination scene
* @param src Source scene - remains unmodified.
*/
static void CopySceneFlat(aiScene** dest,const aiScene* source);
// -------------------------------------------------------------------
/** Get a deep copy of a mesh
*
* @param dest Receives a pointer to the destination mesh
* @param src Source mesh - remains unmodified.
*/
static void Copy (aiMesh** dest, const aiMesh* src);
// similar to Copy():
static void Copy (aiMaterial** dest, const aiMaterial* src);
static void Copy (aiTexture** dest, const aiTexture* src);
static void Copy (aiAnimation** dest, const aiAnimation* src);
static void Copy (aiCamera** dest, const aiCamera* src);
static void Copy (aiBone** dest, const aiBone* src);
static void Copy (aiLight** dest, const aiLight* src);
static void Copy (aiNodeAnim** dest, const aiNodeAnim* src);
static void Copy (aiMetadata** dest, const aiMetadata* src);
// recursive, of course
static void Copy (aiNode** dest, const aiNode* src);
private:
// -------------------------------------------------------------------
// Same as AddNodePrefixes, but with an additional check
static void AddNodePrefixesChecked(aiNode* node, const char* prefix,
unsigned int len,
std::vector<SceneHelper>& input,
unsigned int cur);
// -------------------------------------------------------------------
// Add node identifiers to a hashing set
static void AddNodeHashes(aiNode* node, std::set<unsigned int>& hashes);
// -------------------------------------------------------------------
// Search for duplicate names
static bool FindNameMatch(const aiString& name,
std::vector<SceneHelper>& input, unsigned int cur);
};
}
#endif // !! AI_SCENE_COMBINER_H_INC
| [
"520dhh@gmail.com"
] | 520dhh@gmail.com |
e2df6ab700cfab5c6e24ed5ce19ef95bc6327c64 | d2d6aae454fd2042c39127e65fce4362aba67d97 | /build/iOS/Preview1/include/Fuse.Reactive.ThreadW-a73c34f4.h | 3d2c5851bcacc35bfeca53fa5b0fd1806a74ff3d | [] | no_license | Medbeji/Eventy | de88386ff9826b411b243d7719b22ff5493f18f5 | 521261bca5b00ba879e14a2992e6980b225c50d4 | refs/heads/master | 2021-01-23T00:34:16.273411 | 2017-09-24T21:16:34 | 2017-09-24T21:16:34 | 92,812,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,127 | h | // This file was generated based on '/Users/medbeji/Library/Application Support/Fusetools/Packages/Fuse.Reactive.JavaScript/1.0.2/$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
namespace g{namespace Fuse{namespace Reactive{struct ThreadWorker;}}}
namespace g{namespace Fuse{namespace Reactive{struct ThreadWorker__MethodClosure;}}}
namespace g{namespace Fuse{namespace Scripting{struct Array;}}}
namespace g{namespace Fuse{namespace Scripting{struct Function;}}}
namespace g{namespace Fuse{namespace Scripting{struct ScriptMethod;}}}
namespace g{
namespace Fuse{
namespace Reactive{
// private sealed class ThreadWorker.MethodClosure :1598
// {
uType* ThreadWorker__MethodClosure_typeof();
void ThreadWorker__MethodClosure__ctor__fn(ThreadWorker__MethodClosure* __this, ::g::Fuse::Scripting::Function* cl, ::g::Fuse::Scripting::ScriptMethod* m, ::g::Fuse::Reactive::ThreadWorker* worker);
void ThreadWorker__MethodClosure__Callback_fn(ThreadWorker__MethodClosure* __this, uArray* args, uObject** __retval);
void ThreadWorker__MethodClosure__CopyArgs_fn(::g::Fuse::Scripting::Array* args, uArray** __retval);
void ThreadWorker__MethodClosure__New1_fn(::g::Fuse::Scripting::Function* cl, ::g::Fuse::Scripting::ScriptMethod* m, ::g::Fuse::Reactive::ThreadWorker* worker, ThreadWorker__MethodClosure** __retval);
struct ThreadWorker__MethodClosure : uObject
{
static uSStrong<uArray*> _emptyArgs_;
static uSStrong<uArray*>& _emptyArgs() { return ThreadWorker__MethodClosure_typeof()->Init(), _emptyArgs_; }
uStrong< ::g::Fuse::Scripting::ScriptMethod*> _m;
uStrong< ::g::Fuse::Reactive::ThreadWorker*> _worker;
void ctor_(::g::Fuse::Scripting::Function* cl, ::g::Fuse::Scripting::ScriptMethod* m, ::g::Fuse::Reactive::ThreadWorker* worker);
uObject* Callback(uArray* args);
static uArray* CopyArgs(::g::Fuse::Scripting::Array* args);
static ThreadWorker__MethodClosure* New1(::g::Fuse::Scripting::Function* cl, ::g::Fuse::Scripting::ScriptMethod* m, ::g::Fuse::Reactive::ThreadWorker* worker);
};
// }
}}} // ::g::Fuse::Reactive
| [
"medbeji@MacBook-Pro-de-MedBeji.local"
] | medbeji@MacBook-Pro-de-MedBeji.local |
338bffc422bb5e1e60a3f702a73e51831dc24e5c | 2139bff1c9096ea7d168d453470e2bc89848e72a | /all.h | 8975de1798b4d697b1135c995c0067ab15719a98 | [] | no_license | si0005hp/cpp-sandbox | 33814ceaa3f1131e22d781a0e1ae24f0b9f4963d | 68f946afd01c6abdab2595ad06dc5d6f8af74c95 | refs/heads/master | 2023-06-08T07:25:49.819312 | 2021-06-20T09:45:47 | 2021-06-20T09:45:47 | 338,561,875 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,267 | h | #include <cassert>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cstdalign>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <system_error>
#include <typeinfo>
#if __has_include(<string_view>)
#include <string_view>
#endif
#include <unistd.h>
#include <algorithm>
#include <any>
#include <array>
#include <cfenv>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#if __has_include(<filesystem>)
#include <filesystem>
#endif
#include <atomic>
#include <cinttypes>
#include <condition_variable>
#include <cstdio>
#include <future>
#include <mutex>
#include <regex>
#include <shared_mutex>
#include <thread>
// Out of original list
#include <functional>
#include "util.h"
using namespace std::literals;
| [
"si0005hp@gmail.com"
] | si0005hp@gmail.com |
1700581b3a83173edd4ab22d7ea6c3105fbbf97f | 2ce5246d19d55211172d79b4091aeafd73e77a27 | /Problems/boj1094.cpp | e53d7ddf0059f93f3919beff4f88475f2d0f1cdf | [] | no_license | MingNine9999/algorithm | 49e76a1fbcdbeea8388491c793f31ee6866054ae | 76be13e394e3e96cdcec0de9390f1fd573d442c5 | refs/heads/master | 2021-04-23T09:09:05.097401 | 2020-09-11T16:23:29 | 2020-09-11T16:23:29 | 249,915,663 | 2 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 367 | cpp | //Problem Number : 1094
//Problem Title : ¸·´ë±â
//Problem Link : https://www.acmicpc.net/problem/1094
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
int ans = 0;
cin >> n;
for (int i = 1; i <= 64; i <<= 1) {
if (n & i) {
ans++;
}
}
cout << ans;
return 0;
} | [
"mingu.song@nhn.com"
] | mingu.song@nhn.com |
4ececd4a01f9989ae006c95eaa322436250762bd | a71b63bc220edcc1ee52fb6ee356c14a20e11ac1 | /Project/Oscilloscope/Graphic/gui/src/main_screen/MainPresenter.cpp | 852ea626dacb0399c7e283c0f77180878b226383 | [] | no_license | mmastouri/Oscilloscope | f57a91e88e2642c1c9e724ff47af141fc858139e | 2a5c109ab6f9c530f1a2d71ceae3c792570cbd28 | refs/heads/master | 2023-06-28T18:54:38.918255 | 2021-08-07T19:58:44 | 2021-08-07T19:58:44 | 363,997,981 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,204 | cpp | /**************************************************************************************************
* FILE NAME: MainPresenter.cpp *
* *
* PURPOSE: Provide Function to manipulate the data stored in Model *
* *
* FILE REFERENCES: *
* *
* Name I/O Description *
* ---- --- ----------- *
* *
* EXTERNAL VARIABLES: *
* Source: < > *
* *
* Name Type I/O Description *
* ---- ---- --- ----------- *
* *
* EXTERNAL REFERENCES: *
* *
* Name Description *
* ---- ----------- *
* *
* ABNORMAL TERMINATION CONDITIONS, ERROR AND WARNING MESSAGES: *
* *
* ASSUMPTIONS, CONSTRAINTS, RESTRICTIONS: *
* *
* NOTES: *
* *
* REQUIREMENTS/FUNCTIONAL SPECIFICATIONS REFERENCES: *
* *
* DEVELOPMENT HISTORY: *
* *
* Date Author Change Id Release Description Of Change *
* ---- ------ --------- ------- --------------------- *
* 30.06.2016 Hai Nguyen 01 2.0 Original *
* *
***************************************************************************************************/
#include <gui/main_screen/MainPresenter.hpp>
#include <gui/main_screen/MainView.hpp>
#include <gui/model/Model.hpp>
#include <gui\common\main_header.h>
#include <gui/common/FrontendApplication.hpp>
#ifdef SIMULATOR
uint16_t dummy[1000] = { 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,
4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0 };
uint16_t dummy1[1000] = { 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919,
2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145,
3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952,
3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032,
3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353,
3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177,
2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951,
844, 743, 646, 555, 470, 391, 319, 253, 195, 144,
100, 64, 36, 16, 4, 0, 4, 16, 36, 64,
100, 144, 195, 253, 319, 391, 470, 555, 646, 743,
844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919};
#endif
/***************************************************************************************************
* *
* FUNCTION NAME: MainPresenter *
* *
* ARGUMENTS: *
* *
* ARGUMENT TYPE I/O DESCRIPTION *
* -------- ---- --- ----------- *
* *
* RETURNS: *
* *
***************************************************************************************************/
MainPresenter::MainPresenter(MainView& v)
: view(v)
{
}
/***************************************************************************************************
* *
* FUNCTION NAME: activate *
* *
* ARGUMENTS: *
* *
* ARGUMENT TYPE I/O DESCRIPTION *
* -------- ---- --- ----------- *
* *
* RETURNS: *
* *
***************************************************************************************************/
void MainPresenter::activate()
{
// Set initial value on main screen
}
/***************************************************************************************************
* *
* FUNCTION NAME: deactivate *
* *
* ARGUMENTS: *
* *
* ARGUMENT TYPE I/O DESCRIPTION *
* -------- ---- --- ----------- *
* *
* RETURNS: *
* *
***************************************************************************************************/
void MainPresenter::deactivate()
{
}
void MainPresenter::p_SetRawData(int channel)
{
if(channel == CHANNEL_1)
{
#ifndef SIMULATOR
model->SetRawData(channel, PushDaTaToModel_1());
#else
model->SetRawData(channel, dummy1);
#endif // !1
}
else
{
#ifndef SIMULATOR
model->SetRawData(channel, PushDaTaToModel_2());
#else
model->SetRawData(channel, dummy);
#endif // !1
}
model->ConvertToTriggerData(channel);
}
int * MainPresenter::p_GetTriggerData(int channel)
{
return model->GetTriggerData(channel);
}
void MainPresenter::p_SetTriggerData(int channel, int value)
{
model->SetTriggerValue(channel, value);
}
void MainPresenter::p_SetYOffset(int channel, int value)
{
model->SetYOffset(channel, value);
}
int MainPresenter::p_GetYOffset(int channel)
{
return model->GetYOffset(channel);
}
int MainPresenter::p_GetTriggerValue(int channel)
{
return model->GetTriggerValue(channel);
}
void MainPresenter::p_SetTriggerValue(int channel, int value)
{
model->SetTriggerValue(channel, value);
}
int MainPresenter::p_getSignalPeak(int channel)
{
return model->getSignalPeak(channel);
}
int MainPresenter::p_getSignalFreq(int channel)
{
return model->getSignalFreq(channel);
}
bool MainPresenter::p_GetTrigger(int channel)
{
return model->GetTrigger(channel) ;
}
void MainPresenter::p_SetTrigger(int channel, bool value)
{
model->SetTrigger(channel, value);
}
bool MainPresenter::p_GetTriggerType(int channel)
{
return model->GetTriggerType(channel);
}
void MainPresenter::p_SetTriggerType(int channel, bool value)
{
model->SetTriggerType(channel, value);
}
int MainPresenter::p_GetTimeScale(int channel)
{
return model->GetTimeScale(channel);
}
void MainPresenter::p_SetTimeScale(int channel, int value)
{
model->SetTimeScale(channel, value);
}
int MainPresenter::p_GetVoltageScale(int channel)
{
return model->GetVoltageScale(channel);
}
void MainPresenter::p_SetVoltageScale(int channel, int value)
{
model->SetVoltageScale(channel, value);
}
float MainPresenter::p_GetTimeScale2Pixel(int channel)
{
return model->GetTimeScale2Pixel(channel);
}
int MainPresenter::p_GetVoltScale2Pixel(int channel)
{
return model->GetVoltageScale2Pixel(channel);
}
float MainPresenter::p_VoltagePerPixel(int channel)
{
float temp_value = 0;
switch (model->GetVoltageScale(channel))
{
//div 2V
case 7:
temp_value = 52.63f;
break;
//div 1V
case 6:
temp_value = 26.32f;
break;
//div 500mV
case 5:
temp_value = 13.16f;
break;
//div 200mV
case 4:
temp_value = 5.26f;
break;
//div 100mV
case 3:
temp_value = 2.63f;
break;
//div 50mV
case 2:
temp_value = 1.32f;
break;
//div 20mV
case 1:
temp_value = 0.53f;
break;
//div 10mV
case 0:
temp_value = 0.26f;
break;
}
return temp_value;
}
void MainPresenter::p_SetXOffset(int channel, int value)
{
model->SetXOffset(channel, value);
}
int MainPresenter::p_GetXOffset(int channel)
{
return model->GetXOffset(channel);
}
| [
"maher.mastouri@gmail.com"
] | maher.mastouri@gmail.com |
900435c7292f2dd5f43f3931d2859227abcb29cd | 7cfdb0b1bd04783d985eaf063812aea97da922cc | /hdu/2015.cpp | fecea192edc701ac91c41ba9795d09dd562fc641 | [
"MIT"
] | permissive | bashell/oj | dcf0eb00825dabdbd71ea701eb121d9e25faa102 | 9471e32d735168148390d42029998187e0e04e2b | refs/heads/master | 2021-01-11T03:25:23.989568 | 2018-10-30T14:27:37 | 2018-10-30T14:27:37 | 71,035,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | cpp | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 111;
int arr[maxn];
int n, m;
void init(int n) {
memset(arr, 0, sizeof(arr));
for(int i = 0; i < n; ++i)
arr[i] = 2+2*i;
}
void solve(int n, int m) {
if(m >= n) {
printf("%d\n", accumulate(arr, arr+n, 0)/n);
} else {
printf("%d", accumulate(arr, arr+m, 0)/m);
for(int i = m; i < n; ) {
if(i+m <= n)
printf(" %d", accumulate(arr+i, arr+i+m, 0)/m);
else
printf(" %d", accumulate(arr+i, arr+n, 0)/(n-i));
i += m;
}
printf("\n");
}
}
int main()
{
//freopen("in.txt", "r", stdin);
while(2 == scanf("%d%d", &n, &m)) {
init(n);
solve(n, m);
}
return 0;
}
| [
"nju.liuc@gmail.com"
] | nju.liuc@gmail.com |
175f80fa6a86f8d58f498ce6d6de4d75ede0792e | 8b5d6c8965011d818399df2de6292a377962672d | /src/qt/utilitydialog.h | f289338cd6dfcdedc3f0a9830aba6013a2d04df2 | [
"MIT"
] | permissive | catracoin/catracoin | 56e921b6bb27f04de0d847c57c9bb7b64d2ecfbd | 0ecd8ec316e2bdb180325e26ff6bcb857ceea6c9 | refs/heads/master | 2023-02-19T14:34:38.056169 | 2021-01-20T15:07:39 | 2021-01-20T15:07:39 | 331,340,760 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,089 | h | // Copyright (c) 2011-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef CATRA_QT_UTILITYDIALOG_H
#define CATRA_QT_UTILITYDIALOG_H
#include <QDialog>
#include <QObject>
class CatraGUI;
namespace interfaces {
class Node;
}
namespace Ui {
class HelpMessageDialog;
}
/** "Help message" dialog box */
class HelpMessageDialog : public QDialog
{
Q_OBJECT
public:
explicit HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about);
~HelpMessageDialog();
void printToConsole();
void showOrPrint();
private:
Ui::HelpMessageDialog *ui;
QString text;
private Q_SLOTS:
void on_okButton_accepted();
};
/** "Shutdown" window */
class ShutdownWindow : public QWidget
{
Q_OBJECT
public:
explicit ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static QWidget *showShutdownWindow(CatraGUI *window);
protected:
void closeEvent(QCloseEvent *event);
};
#endif // CATRA_QT_UTILITYDIALOG_H
| [
"77095210+bitcatra@users.noreply.github.com"
] | 77095210+bitcatra@users.noreply.github.com |
3b593dc7a3649d128c74422ba38a27315d9c7fab | 777a75e6ed0934c193aece9de4421f8d8db01aac | /src/Providers/UNIXProviders/RelatedSpanningTree/UNIX_RelatedSpanningTreeMain.cpp | f18b3de373bedffdf328982a9969110711b5f766 | [
"MIT"
] | permissive | brunolauze/openpegasus-providers-old | 20fc13958016e35dc4d87f93d1999db0eae9010a | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | refs/heads/master | 2021-01-01T20:05:44.559362 | 2014-04-30T17:50:06 | 2014-04-30T17:50:06 | 19,132,738 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,210 | cpp | //%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////
//
//%/////////////////////////////////////////////////////////////////////////
#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/String.h>
#include <Pegasus/Common/PegasusVersion.h>
PEGASUS_USING_PEGASUS;
PEGASUS_USING_STD;
#include "UNIX_RelatedSpanningTreeProvider.h"
extern "C"
PEGASUS_EXPORT CIMProvider* PegasusCreateProvider(const String& providerName)
{
if (String::equalNoCase(providerName, CIMHelper::EmptyString)) return NULL;
else if (String::equalNoCase(providerName, "UNIX_RelatedSpanningTreeProvider")) return new UNIX_RelatedSpanningTreeProvider();
return NULL;
}
| [
"brunolauze@msn.com"
] | brunolauze@msn.com |
8a4effe750b80bbe7cb63866e75536880d844e47 | 3ded37602d6d303e61bff401b2682f5c2b52928c | /toy/0205/Classes/Model/CBAppManager.h | 64507d7d57847d9e00a7dc9f3d3a89187a617730 | [] | no_license | CristinaBaby/Demo_CC | 8ce532dcf016f21b442d8b05173a7d20c03d337e | 6f6a7ff132e93271b8952b8da6884c3634f5cb59 | refs/heads/master | 2021-05-02T14:58:52.900119 | 2018-02-09T11:48:02 | 2018-02-09T11:48:02 | 120,727,659 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 937 | h | //
// CBAppManager.h
// ColorBook
//
// Created by maxiang on 4/21/15.
//
//
#ifndef __ColorBook__CBAppManager__
#define __ColorBook__CBAppManager__
#include "cocos2d.h"
#include "CBAppGlobal.h"
#define xApp AppManager::getInstance()
class AppManager
{
public:
static AppManager* getInstance();
virtual ~AppManager();
AppManager();
//first launch app
bool isFirstLaunchApp(){return _isFirstLaunchApp;};
void setIsFirstLaunchApp(bool isFirstLaunch){_isFirstLaunchApp = isFirstLaunch;};
//ads
void requestCrossAd();
void requestCrossAd(cocos2d::Node* parent, int zorder = 0);
void requestFullScreenAd();
void requestFullScreenAd(cocos2d::Node* parent, int zorder);
/* Rate us logic, when user save picture 3 times, show rate us */
void rateUsLogic();
protected:
int _saveTimes;
bool _isFirstLaunchApp;
};
#endif /* defined(__ColorBook__CBAppManager__) */
| [
"wuguiling@smalltreemedia.com"
] | wuguiling@smalltreemedia.com |
01ae59c3cb1726a7c7e12b64778e760b93a70608 | ecffba720cb0af51925868f17a4d558cbdcb546a | /Flight Software/PowerTest_V2/MPU6050.ino | c4e6462e4a0bb3e26980269cdbf7e4fa3fe4178d | [] | no_license | ndshetty/CanSatElectronics2017-18 | 7bda8d926ffce49b1935d6ca8b43c9ab0ec1be47 | 679087ba58f028c8622340cf8b87729e1ef66dd5 | refs/heads/master | 2020-09-15T12:16:24.813888 | 2018-05-29T22:15:37 | 2018-05-29T22:15:37 | 223,441,561 | 1 | 0 | null | 2019-11-22T16:19:31 | 2019-11-22T16:19:31 | null | UTF-8 | C++ | false | false | 573 | ino |
/*void mpuSetup()
{
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
{
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
delay(500);
}
mpu.calibrateGyro();
mpu.setThreshold(3);
}
void mpuLoop()
{
mpuTime = millis();
Vector norm = mpu.readNormalizeGyro();
// Calculate Pitch, Roll and Yaw
pitch = pitch + norm.YAxis * mpuTimeStep;
roll = roll + norm.XAxis * mpuTimeStep;
yaw = yaw + norm.ZAxis * mpuTimeStep;
TeleArray[TeleTiltX] = roll;
TeleArray[TeleTiltY] = pitch;
TeleArray[TeleTiltZ] = yaw;
}
*/
| [
"ahsan.abrar16@hotmail.com"
] | ahsan.abrar16@hotmail.com |
5af329d579b4551371b2d6803f14e8b490885fcf | e867868c78f972149e085b203dc42c120d60c76a | /ProceduralTexture/Plugins/UnrealShadertoy/Source/UnrealShadertoy/Public/ShaderToy.h | eff46ef6875876f1e2f4a07c76af326b07a0887a | [] | no_license | Sanctorum003/Unreal-4-rendering-programming | c95831d369c1150760497a7c019a54943e0edb7a | c431b82fefcc773e20575c56349245742aa2301c | refs/heads/master | 2020-12-05T11:10:50.413852 | 2020-05-03T08:59:55 | 2020-05-03T08:59:55 | 232,091,408 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,935 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "MaterialExpressionIO.h"
#include "Materials/MaterialExpression.h"
#include "Materials/MaterialExpressionCustom.h"
#include "ShaderToy.generated.h"
USTRUCT()
struct FCodeableString
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "CodeableString")
FString Code;
FCodeableString() = default;
FCodeableString(const FString& Code)
:Code(Code)
{}
template <
typename CharType,
typename = typename TEnableIf<TIsCharType<CharType>::Value>::Type
>
FORCEINLINE FCodeableString(const CharType* Src)
:Code(Src)
{}
operator FString() const { return Code; }
};
USTRUCT()
struct FShaderToyHLSLFunction
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "FuncDecs"))
FString FunctionName;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "FuncBody"))
FCodeableString FunctionCodes;
};
/**
*
*/
UCLASS(collapsecategories, hidecategories = Object, MinimalAPI)
class UShaderToy : public UMaterialExpression
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "NodeName"))
FString NodeTitle;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "DefineBody"))
FCodeableString DefineBody;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "Inputs"))
TArray<struct FCustomInput> Inputs;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "MainFunctionOutput"))
TEnumAsByte<enum ECustomMaterialOutputType> OutputType;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "MainFunction"))
FShaderToyHLSLFunction MainFunction;
UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "ChildFunctions"))
TArray<FShaderToyHLSLFunction> HLSLFunctions;
//~ Begin UObject Interface.
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif // WITH_EDITOR
virtual void Serialize(FArchive& Ar) override;
//~ End UObject Interface.
//~ Begin UMaterialExpression Interface
#if WITH_EDITOR
virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override;
virtual void GetCaption(TArray<FString>& OutCaptions) const override;
#endif
virtual const TArray<FExpressionInput*> GetInputs() override;
virtual FExpressionInput* GetInput(int32 InputIndex) override;
virtual FName GetInputName(int32 InputIndex) const override;
#if WITH_EDITOR
virtual uint32 GetInputType(int32 InputIndex) override { return MCT_Unknown; }
virtual uint32 GetOutputType(int32 OutputIndex) override;
#endif // WITH_EDITOR
//~ End UMaterialExpression Interface
};
| [
"lushuchengsky@126.com"
] | lushuchengsky@126.com |
02c289a9eaa755b29b5514ba73c23135bbe30739 | d6b4bdf418ae6ab89b721a79f198de812311c783 | /privatedns/include/tencentcloud/privatedns/v20201028/model/DescribeRequestDataResponse.h | 91007f4f2b9ceac492242360920a6611b49d42ce | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp-intl-en | d0781d461e84eb81775c2145bacae13084561c15 | d403a6b1cf3456322bbdfb462b63e77b1e71f3dc | refs/heads/master | 2023-08-21T12:29:54.125071 | 2023-08-21T01:12:39 | 2023-08-21T01:12:39 | 277,769,407 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,172 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_
#define TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
#include <tencentcloud/privatedns/v20201028/model/MetricData.h>
namespace TencentCloud
{
namespace Privatedns
{
namespace V20201028
{
namespace Model
{
/**
* DescribeRequestData response structure.
*/
class DescribeRequestDataResponse : public AbstractModel
{
public:
DescribeRequestDataResponse();
~DescribeRequestDataResponse() = default;
CoreInternalOutcome Deserialize(const std::string &payload);
std::string ToJsonString() const;
/**
* 获取Request volume statistics table
* @return Data Request volume statistics table
*
*/
std::vector<MetricData> GetData() const;
/**
* 判断参数 Data 是否已赋值
* @return Data 是否已赋值
*
*/
bool DataHasBeenSet() const;
/**
* 获取Request volume unit time. Valid values: Day, Hour
* @return Interval Request volume unit time. Valid values: Day, Hour
*
*/
std::string GetInterval() const;
/**
* 判断参数 Interval 是否已赋值
* @return Interval 是否已赋值
*
*/
bool IntervalHasBeenSet() const;
private:
/**
* Request volume statistics table
*/
std::vector<MetricData> m_data;
bool m_dataHasBeenSet;
/**
* Request volume unit time. Valid values: Day, Hour
*/
std::string m_interval;
bool m_intervalHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
39bbd6702a3295914227c31be7f4a9c647482be3 | 641f6bdac7d6969dbd302211e48ac0e224584bd3 | /arduino/old/arduino_qianyun/other/testScripts/limitSwitchTest/limitSwitchTest.ino | 7b5237779c191370fa42ce54c1ecda68515665bf | [] | no_license | richard-warren/obstacleRig | 5fb0d03081863ae6fc977ca434c2b36eb58fba49 | 4f351aa9bde83cbb0b94c65b02be652ea29dcccd | refs/heads/master | 2022-12-07T10:55:59.325000 | 2020-07-07T16:09:59 | 2020-07-07T16:09:59 | 101,103,191 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 406 | ino | const int startLimitPin = 9; // signal is LOW when engaged
const int stopLimitPin = 10; // signal is LOW when engaged
void setup() {
pinMode(startLimitPin, INPUT_PULLUP);
pinMode(stopLimitPin, INPUT_PULLUP);
Serial.begin(115200);
}
void loop() {
Serial.print(" start: ");
Serial.print(digitalRead(startLimitPin));
Serial.print(" stop: ");
Serial.println(digitalRead(stopLimitPin));
}
| [
"richardwarren2163@gmail.com"
] | richardwarren2163@gmail.com |
be0d4c97fb7cb4c3e7d980198886df5341d2929e | 8c8820fb84dea70d31c1e31dd57d295bd08dd644 | /NavigationSystem/Public/NavFilters/RecastFilter_UseDefaultArea.h | 8a932836c655046fb8bb6cace151f0cc6145cee0 | [] | no_license | redisread/UE-Runtime | e1a56df95a4591e12c0fd0e884ac6e54f69d0a57 | 48b9e72b1ad04458039c6ddeb7578e4fc68a7bac | refs/heads/master | 2022-11-15T08:30:24.570998 | 2020-06-20T06:37:55 | 2020-06-20T06:37:55 | 274,085,558 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 576 | h | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "NavFilters/NavigationQueryFilter.h"
#include "RecastFilter_UseDefaultArea.generated.h"
class ANavigationData;
/** Regular navigation area, applied to entire navigation data by default */
UCLASS(MinimalAPI)
class URecastFilter_UseDefaultArea : public UNavigationQueryFilter
{
GENERATED_UCLASS_BODY()
virtual void InitializeFilter(const ANavigationData& NavData, const UObject* Querier, FNavigationQueryFilter& Filter) const override;
};
| [
"wujiahong19981022@outlook.com"
] | wujiahong19981022@outlook.com |
8032e9b66585044096fb5bd01837bf6fe0cb813c | 13a32b92b1ba8ffb07e810dcc8ccdf1b8b1671ab | /home--tommy--mypy/mypy/lib/python2.7/site-packages/pystan/stan/lib/stan_math/test/unit/math/prim/mat/prob/agrad_distributions_multi_student_t.hpp | 1f46e7157bf083f5375502b58553cae21587e5e2 | [
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | tommybutler/mlearnpy2 | 8ec52bcd03208c9771d8d02ede8eaa91a95bda30 | 9e5d377d0242ac5eb1e82a357e6701095a8ca1ff | refs/heads/master | 2022-10-24T23:30:18.705329 | 2022-10-17T15:41:37 | 2022-10-17T15:41:37 | 118,529,175 | 0 | 2 | Unlicense | 2022-10-15T23:32:18 | 2018-01-22T23:27:10 | Python | UTF-8 | C++ | false | false | 826 | hpp | class agrad_distributions_multi_student_t : public ::testing::Test {
protected:
virtual void SetUp() {
nu = 5;
y.resize(3,1);
y << 2.0, -2.0, 11.0;
y2.resize(3,1);
y2 << 15.0, 1.0, -5.0;
mu.resize(3,1);
mu << 1.0, -1.0, 3.0;
mu2.resize(3,1);
mu2 << 6.0, 2.0, -6.0;
Sigma.resize(3,3);
Sigma << 9.0, -3.0, 0.0,
-3.0, 4.0, 0.0,
0.0, 0.0, 5.0;
Sigma2.resize(3,3);
Sigma2 << 3.0, 1.0, 0.0,
1.0, 5.0, -2.0,
0.0, -2.0, 9.0;
}
double nu;
Eigen::Matrix<double,Eigen::Dynamic,1> y;
Eigen::Matrix<double,Eigen::Dynamic,1> y2;
Eigen::Matrix<double,Eigen::Dynamic,1> mu;
Eigen::Matrix<double,Eigen::Dynamic,1> mu2;
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> Sigma;
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> Sigma2;
};
| [
"tbutler.github@internetalias.net"
] | tbutler.github@internetalias.net |
1da9e71d9d21e92bf133d77f3b0881ccd94f7c79 | 830c3f036753f0afae50c4dcedbb80a6babf119a | /tests/tools/Dx11DemoRemoteWrite.cpp | a3a8444f36c0f3650ea25ee579a6eead39502f24 | [
"MIT"
] | permissive | yukunchen/Terminal | e72d8d481391fcc617fbc27e4542f965334d4996 | 13afb7e69de384eca38a9c03def3fc2ff9fbe600 | refs/heads/master | 2020-05-20T22:18:58.025272 | 2019-05-09T23:58:14 | 2019-05-09T23:58:14 | 185,779,890 | 0 | 0 | null | 2019-05-09T10:42:52 | 2019-05-09T10:42:52 | null | UTF-8 | C++ | false | false | 11,970 | cpp | #include <windows.h>
#include <vector>
#include <iostream>
#include <cassert>
// Xfer
#include "NetXferInterface.h"
#include "resource.h"
using namespace std;
//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE g_hInst = nullptr;
HWND g_hMainWnd = nullptr;
HWND g_hControlWnd = nullptr;
HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
// For client
bool g_ServerConnected;
bool ConnectServer();
void DisconnectServer();
void GetServerAddress(wchar_t*, wchar_t*);
NetXferInterface* pHvrNetXfer = nullptr;
typedef struct _POLLING_THREAD_DATA
{
HANDLE TerminateThreadsEvent;
} POLLING_THREAD_DATA;
DWORD WINAPI PollingThread(_In_ void* Param);
POLLING_THREAD_DATA g_PollingTData;
HANDLE g_PollingTHandle;
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
if (FAILED(InitWindow(hInstance, nCmdShow)))
{
return 0;
}
g_ServerConnected = false;
g_PollingTHandle = nullptr;
RtlZeroMemory(&g_PollingTData, sizeof(g_PollingTData));
g_PollingTData.TerminateThreadsEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!g_PollingTData.TerminateThreadsEvent)
{
wprintf(L"Fail call to CreateEvent\n");
return 0;
}
ResetEvent(g_PollingTData.TerminateThreadsEvent);
// Main message loop
MSG msg = { 0 };
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//
}
}
CloseHandle(g_PollingTData.TerminateThreadsEvent);
return (int)msg.wParam;
}
HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_APPICON);
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"Dx11DemoRemoteWriteWindowClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_APPICON);
if (!RegisterClassEx(&wcex))
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
g_hMainWnd = CreateWindow(L"Dx11DemoRemoteWriteWindowClass", L"RemoteVR - Remote Renderer", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance,
nullptr);
if (!g_hMainWnd)
return E_FAIL;
// Create Control Window
g_hControlWnd = CreateDialog(hInstance, MAKEINTRESOURCE(DLG_CONTROL), NULL, (DLGPROC)DlgProc);
if (!g_hControlWnd)
{
return E_FAIL;
}
//ShowWindow(g_hMainWnd, nCmdShow);
ShowWindow(g_hControlWnd, nCmdShow);
UpdateWindow(g_hControlWnd);
return S_OK;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_SIZE:
break;
case WM_MOVE:
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_DESTROY:
if (g_ServerConnected)
{
DisconnectServer();
}
PostQuitMessage(0);
break;
case WM_INITDIALOG:
wchar_t buf[MAX_PATH];
RtlZeroMemory(buf, MAX_PATH);
swprintf_s(buf, MAX_PATH, L"%s:%s", L"127.0.0.1", HVR_NET_XFER_SERVER_PORT);
SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), WM_SETTEXT, (WPARAM)NULL, (LPARAM)buf);
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
{
if (g_ServerConnected)
{
DisconnectServer();
}
PostQuitMessage(0);
return (INT_PTR)TRUE;
}
else if (LOWORD(wParam) == IDC_BUTTON_CONNECT)
{
g_ServerConnected = !g_ServerConnected;
wchar_t *btnCap = nullptr;
if (g_ServerConnected)
{
SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), EM_SETREADONLY, (WPARAM)true, (LPARAM)btnCap);
btnCap = L"Disconnect";
ConnectServer();
}
else
{
SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), EM_SETREADONLY, (WPARAM)false, (LPARAM)btnCap);
btnCap = L"Connect";
DisconnectServer();
}
SendMessage(GetDlgItem(hWnd, IDC_BUTTON_CONNECT), WM_SETTEXT, (WPARAM)NULL, (LPARAM)btnCap);
}
break;
}
return (INT_PTR)FALSE;
}
bool ConnectServer()
{
bool isSuccess = true;
ResetEvent(g_PollingTData.TerminateThreadsEvent);
pHvrNetXfer = new NetXferInterface();
DWORD ThreadId;
g_PollingTHandle = CreateThread(nullptr, 0, PollingThread, &g_PollingTData, 0, &ThreadId);
if (nullptr == g_PollingTHandle)
{
isSuccess = false;
wprintf(L"Fail to create polling thread");
}
return isSuccess;
}
void DisconnectServer()
{
SetEvent(g_PollingTData.TerminateThreadsEvent);
if (g_PollingTHandle)
{
WaitForMultipleObjectsEx(1, &g_PollingTHandle, TRUE, INFINITE, FALSE);
CloseHandle(g_PollingTHandle);
}
}
void GetServerAddress(wchar_t* pServerIP, wchar_t* pServerPort)
{
if (nullptr != pServerIP && nullptr != pServerPort)
{
wchar_t buf[MAX_PATH];
SendMessage(GetDlgItem(g_hControlWnd, IDC_INPUT_SERVER_ADDR), WM_GETTEXT, MAX_PATH, LPARAM(buf));
wchar_t* colon = nullptr;
wchar_t* nextToken = nullptr;
colon = wcstok_s(buf, L":", &nextToken);
if (0 == wcslen(colon) || 0 == wcslen(nextToken))
{
swprintf_s(pServerIP, MAX_PATH, L"%s", HVR_NET_XFER_SERVER_IP);
swprintf_s(pServerPort, MAX_PATH, L"%s", HVR_NET_XFER_SERVER_PORT);
}
else
{
wcscpy_s(pServerIP, MAX_PATH, colon);
wcscpy_s(pServerPort, MAX_PATH, nextToken);
}
}
}
DWORD WINAPI PollingThread(_In_ void* Param)
{
bool isSuccess = true;
POLLING_THREAD_DATA* TData = reinterpret_cast<POLLING_THREAD_DATA*>(Param);
wchar_t bufIP[MAX_PATH];
wchar_t bufPort[MAX_PATH];
RtlZeroMemory(bufIP, MAX_PATH);
RtlZeroMemory(bufPort, MAX_PATH);
GetServerAddress(bufIP, bufPort);
if (pHvrNetXfer)
{
pHvrNetXfer->InitNetXfer(L"Client", L"TCP", bufIP, bufPort);
}
FILE* pFile = nullptr;
UINT32 frameSize = 0;
INT64 latency = 0;
PBYTE pReceiveBuf = (PBYTE)malloc(HVR_NET_XFER_RECV_ELEMENT_MAX_SIZE);
uint32_t receiveSize = 0;
bool netXferSuccess = false;
UINT64 encodeDoneFrmIdx = 0;
bool connected = false;
bool infoReceived = false;
bool fileCreated = false;
bool streamStart = false;
bool closeFile = false;
HVR_NET_XFER_PACKET_HEADER pktHeader;
while (isSuccess && (WaitForSingleObjectEx(TData->TerminateThreadsEvent, 0, FALSE) == WAIT_TIMEOUT))
{
netXferSuccess = pHvrNetXfer->GetPacket(
&pktHeader,
pReceiveBuf,
HVR_NET_XFER_RECV_ELEMENT_MAX_SIZE);
if (netXferSuccess)
{
switch (pktHeader.cmdInfo.s.CmdType)
{
case HVR_NET_XFER_PACKET_COMMAND_TYPE_GENERAL:
{
if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_GENERAL_COMMAND_CONNECT)
{
connected = true;
}
else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_GENERAL_COMMAND_DISCONNECT)
{
connected = false;
}
break;
}
case HVR_NET_XFER_PACKET_COMMAND_TYPE_ENCODE:
{
if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_INFO)
{
infoReceived = true;
if (infoReceived && !fileCreated)
{
PHVR_NET_XFER_ENCODE_H264_INFO pH264Info = (PHVR_NET_XFER_ENCODE_H264_INFO)pReceiveBuf;
SYSTEMTIME curTime = { 0 };
GetLocalTime(&curTime);
wchar_t buf[MAX_PATH * 2];
ZeroMemory(buf, MAX_PATH * 2 * sizeof(wchar_t));
GetCurrentDirectory(MAX_PATH * 2, buf);
swprintf_s(buf, MAX_PATH * 2, L"%s\\Encoded_%dx%d_%dfps_%04d%02d%02d_%02d%02d%02d.h264",
buf,
pH264Info->width, pH264Info->height, pH264Info->fps,
curTime.wYear, curTime.wMonth, curTime.wDay, curTime.wHour, curTime.wMinute, curTime.wSecond);
//pFile = _wfopen(buf, L"w+b");
_wfopen_s(&pFile, buf, L"w+b");
if (pFile)
{
fileCreated = true;
}
else
{
assert(0);
}
}
}
else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_START)
{
streamStart = true;
}
else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_END)
{
if (fileCreated && streamStart)
{
if (pFile)
{
fclose(pFile);
}
fileCreated = false;
}
streamStart = false;
infoReceived = false;
}
else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_DATA)
{
if (fileCreated && streamStart && pFile)
{
PHVR_NET_XFER_ENCODE_H264_DATA_HEADER pH264Header = (PHVR_NET_XFER_ENCODE_H264_DATA_HEADER)pReceiveBuf;
fwrite(pReceiveBuf + sizeof(HVR_NET_XFER_ENCODE_H264_DATA_HEADER), 1, pH264Header->frameSize, pFile);
}
}
break;
}
default:
break;
}
}
//wprintf(L"OK\n");// Debug using console
}
if (fileCreated && streamStart)
{
if (pFile)
{
fclose(pFile);
}
fileCreated = false;
}
streamStart = false;
infoReceived = false;
netXferSuccess = pHvrNetXfer->SendPacket(
HVR_NET_XFER_PACKET_COMMAND_TYPE_GENERAL,
HVR_NET_XFER_PACKET_GENERAL_COMMAND_DISCONNECT,
nullptr,
0);
pHvrNetXfer->DestroyNetXfer();
if (pReceiveBuf)
{
free(pReceiveBuf);
}
return 0;
}
| [
"yukun_chen@hotmail.com"
] | yukun_chen@hotmail.com |
73242a81f3729b2b974e82b196c1f7c3f7ab170a | 338f16b907cdca5d99f6fc4ee978b3dede217615 | /include/mesos/authentication/http/authenticatee.hpp | 00676febe6d90b728d0721a6cca4e4fd9be083ee | [
"Apache-2.0",
"GPL-2.0-or-later",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-protobuf",
"LGPL-2.1-only",
"PSF-2.0",
"BSL-1.0",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | apache/mesos | 24c92eb34ea9cbb2912d6471815a433c9942e0c9 | 8856d6fba11281df898fd65b0cafa1e20eb90fe8 | refs/heads/master | 2023-08-28T06:36:36.458732 | 2023-01-13T21:00:06 | 2023-01-14T00:29:23 | 11,469,439 | 4,860 | 2,034 | Apache-2.0 | 2023-04-12T06:10:25 | 2013-07-17T07:00:13 | C++ | UTF-8 | C++ | false | false | 2,503 | hpp | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
#define __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
#include <mesos/v1/mesos.hpp>
#include <process/future.hpp>
#include <process/http.hpp>
#include <stout/option.hpp>
namespace mesos {
namespace http {
namespace authentication {
/**
* An abstraction enabling any HTTP API consumer to authenticate.
*/
class Authenticatee
{
public:
virtual ~Authenticatee() = default;
/**
* Reset the authenticatee to its initial state.
*
* Allows the implementation to invalidate possibly cached state.
* This is useful if for example token-based authentication is
* performed and the authenticator signaled an expired token.
*/
virtual void reset() {};
/**
* Name of the authentication scheme implemented.
*
* @return Authentication scheme.
*/
virtual std::string scheme() const = 0;
/**
* Create an HTTP request for authentication.
*
* Used for mutating a provided `Request` with any means of
* authentication-related headers or other additions and changes.
*
* @param request The HTTP payload intended to be sent to an
* authenticated endpoint.
* @param credential The principal and secret optionally used to
* create the authentication request.
* @return The mutated HTTP request object containing all information
* needed for authenticating.
*/
virtual process::Future<process::http::Request> authenticate(
const process::http::Request& request,
const Option<mesos::v1::Credential>& credential) = 0;
};
} // namespace authentication {
} // namespace http {
} // namespace mesos {
#endif // __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
| [
"toenshoff@me.com"
] | toenshoff@me.com |
6410964114ae42f5967ad2af999ff965082b0ba1 | d3a4f1389f5cdd64cb61ea76d63fe4b051843e6f | /ch8/Ex_8_11.cpp | f3ce9cef73ae64c1a4c53268909f8bfacfe9c9f6 | [] | no_license | SeA-xiAoD/Cpp_Primer_Homework | 3562f61b8518ab51f36a9d202c0c0dffd8b088ec | dfa13331fb44062ea967d176270731b5a921afca | refs/heads/master | 2021-04-06T01:36:15.725887 | 2018-06-04T13:29:34 | 2018-06-04T13:29:34 | 124,748,094 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 493 | cpp | #include <iostream>
#include <sstream>
#include <vector>
#include <string>
using namespace std;
struct PersonInfo{
string name;
vector<string> phones;
};
int main()
{
string line, word;
vector<PersonInfo> people;
istringstream record;
while(getline(cin, line))
{
PersonInfo info;
record.clear();
record.str(line);
while(record >> word)
info.phones.push_back(word);
people.push_back(info);
}
return 0;
} | [
"1002811562@qq.com"
] | 1002811562@qq.com |
de64adfaab1818173563094e70ca6a5341d956fc | 3c7f8ddd3d61da88aa3444196bf29e22f3f452a8 | /spoj_codes/HS08FOUR.cpp | 8bc90a222f8a33d08b5ae130d5c6359e1efb97b5 | [] | no_license | rathi062/codes | c836239092fd5e37e00a0c59412c94203e59ef18 | ca06002592927e2a01474eec27209f0b78d05de2 | refs/heads/master | 2021-01-23T02:30:21.455737 | 2015-08-23T11:21:42 | 2015-08-23T11:21:42 | 21,992,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,208 | cpp | #include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
#define PB push_back
#define LL long long
#define MX 5
using namespace std;
#define getcx getchar_unlocked
inline void inp( int &n )
{
n=0;
int ch=getcx();int sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
n=n*sign;
}
long MOD;
bool check[1000000];
LL MT[MX][MX], pM[MX][MX], tmp[MX][MX], pre[10000000][MX][MX];
LL val[MX],fR[MX];
int cnt=0;
map<int,int> m;
void createMT(){
LL mat[5][5] = {
{1,1,0,0,0},
{0,0,1,1,1},
{3,3,0,0,0},
{0,0,2,1,0},
{0,0,1,0,0}
};
for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) MT[i][j] = mat[i][j];
}
void init(){
val[0]=1;
val[1]=val[2]=val[4]=3;
val[3]=6;
}
void getfRMT(){
for(int i=0;i<MX;i++){
LL ans=0;
for(int j=0;j<MX;j++){
ans+=pM[i][j]*val[j];
if(ans >= MOD)
ans = ans%MOD;
}
fR[i]=ans;
}
}
LL numberOfWays(){
LL ans = 0;
for(int i=0;i<MX;i++){
ans += fR[i];
if(ans >=MOD)
ans = ans % MOD;
}
return ans;
}
void copy(){
for(int i=0;i<MX;i++){
for(int j=0;j<MX;j++){
pM[i][j]=tmp[i][j];
}
}
}
void square(){
for(int i=0;i<MX;i++){
for(int j=0;j<MX;j++){
LL ans=0;
for(int k=0;k<MX;k++){
ans += pM[i][k] * pM[k][j];
if(ans > MOD)
ans = ans%MOD;
}
tmp[i][j]=ans;
}
}
copy();
}
void multi(){
for(int i=0;i<MX;i++){
for(int j=0;j<MX;j++){
LL ans=0;
for(int k=0;k<MX;k++){
ans += pM[i][k] * MT[k][j];
if(ans > MOD)
ans = ans%MOD;
}
tmp[i][j]=ans;
}
}
copy();
}
void rpSq(int n) {
if(m.find(n)!=m.end()){
// cout<<"got it "<<n<<endl;
int idx = m.find(n)->second;
for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) pM[i][j] = pre[idx][i][j];
return;
}
if(n<1)
return;
if(n==1){
for(int i=0;i<MX;i++)
for(int j=0;j<MX;j++)
pM[i][j] = MT[i][j];
return;
}
rpSq(n/2);
square();
if(n%2){
multi();
}
if(cnt<1000000){
for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) pre[cnt][i][j] = pM[i][j];
m[n]=cnt++;
}
}
void copyValTofR(){
for(int j=0;j<MX;j++){
fR[j]=val[j];
}
}
int main(){
int q,k,i,j;
inp(q);
MOD = 1000000007;
for(i=0;i<MX;i++) for(j=0;j<MX;j++) MT[i][j]=0;
createMT();
init();
while(q--){
for(i=0;i<MX;i++) for(j=0;j<MX;j++) pM[i][j]=0;
inp(k);
if(k==0){
cout<<"0"<<endl;
continue;
}
if(k==1){
cout<<"4"<<endl;
continue;
}
rpSq(k-2);
if(k>2)
getfRMT();
else
copyValTofR();
cout<<numberOfWays()<<endl;
}
}
| [
"mohit.rathi@flipkart.com"
] | mohit.rathi@flipkart.com |
71164fba1488d26943bdfb331b8fb5766739afc9 | 87508c6edf6bbfcded3c2dcf17c1c8512fc5b17c | /shifr/des.h | a7e18f6ed751477df58d4d3858025d40ea478f5d | [] | no_license | Yashin20PI1/TIMP_PR_4 | 845fcbec714a92bed7669b67ca7689902dec1a43 | 8a221d284b6b9f49ede1f8395fd554cf00ef80f2 | refs/heads/master | 2023-05-27T21:51:16.443581 | 2021-05-29T20:00:10 | 2021-05-29T20:00:10 | 370,821,278 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | #pragma once
#include <cryptopp/cryptlib.h>
#include <cryptopp/files.h>
#include <cryptopp/sha.h>
#include <cryptopp/des.h>
#include <cryptopp/pwdbased.h>
#include <cryptopp/filters.h>
#include <cryptopp/osrng.h>
#include "cryptopp/modes.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
using namespace CryptoPP;
class DES_CLASS
{
private:
string in;
string out;
string IV;
string psw;
string salt = "saltandsugarforourdearprepodfgfgfgfgfgfggf";
public:
DES_CLASS() = delete;
DES_CLASS(const string& in, const string& out, const string& pass);
DES_CLASS(const string& in, const string& out, const string& pass, const string & iv);
void enDES (DES_CLASS enc);
void decDES (DES_CLASS dec);
}; | [
"Yashin20PI1"
] | Yashin20PI1 |
6570c7dcb7a8347f005b6bb5cb8ac455605f03f8 | 9068d0b9762c872be4f4cccc11240a66b0757bd8 | /Arduino/libraries/eHealth/eHealth.cpp | 38864aeead3ec20b57c303848edaabd671f5e996 | [] | no_license | cthylhu/Biofeedback_real-time-plotting | f674aceff8d6a39833c884fc44849b7d85c8c207 | e4e69ad4ec2b6eade2ca263e1386a33c68334d61 | refs/heads/master | 2020-06-04T10:34:51.449207 | 2015-02-13T23:18:42 | 2015-02-13T23:18:42 | 28,119,976 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 33,020 | cpp | /*
* eHealth sensor platform for Arduino and Raspberry from Cooking-hacks.
*
* Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi
* users to perform biometric and medical applications by using 9 different
* sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing),
* Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin
* Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and
* Patient Position (Accelerometer)."
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 2.0
* Author: Luis Martín & Ahmad Saad
*/
// include this library's description file
#include "eHealth.h"
//***************************************************************
// Accelerometer Variables and definitions *
//***************************************************************
//! not the wire library, can't use pull-ups
#include "utils/i2c.h"
//! Breakout board defaults to 1, set to 0 if SA0 jumper is set
#define SA0 1
#if SA0
#define MMA8452_ADDRESS 0x1D //! SA0 is high, 0x1C if low
#else
#define MMA8452_ADDRESS 0x1C
#endif
#define int1Pin 2
#define int2Pin 3
//! Set the scale below either 2, 4 or 8.
const byte scale = 2;
//! Set the output data rate below. Value should be between 0 and 7.
//! 0=800Hz, 1=400, 2=200, 3=100, 4=50, 5=12.5, 6=6.25, 7=1.56
const byte dataRate = 0;
//***************************************************************
// Constructor of the class *
//***************************************************************
//! Function that handles the creation and setup of instances
eHealthClass::eHealthClass(void) { /*void constructor*/ }
//***************************************************************
// Public Methods *
//***************************************************************
//!******************************************************************************
//! Name: initPositionSensor() *
//! Description: Initializes the position sensor and configure some values. *
//! Param : void *
//! Returns: void *
//! Example: eHealth.initPositionSensor(); *
//!******************************************************************************
void eHealthClass::initPositionSensor(void)
{
byte c;
/* Set up the interrupt pins, they're set as active high, push-pull */
pinMode(int1Pin, INPUT);
digitalWrite(int1Pin, LOW);
pinMode(int2Pin, INPUT);
digitalWrite(int2Pin, LOW);
/* Read the WHO_AM_I register, this is a good test of communication */
c = readRegister(0x0D); // Read WHO_AM_I register
if (c == 0x2A) { // WHO_AM_I should always be 0x2A
initMMA8452(scale, dataRate); // init the accelerometer if communication is good
Serial.println("MMA8452Q is online...");
} else {
Serial.print("Could not connect to MMA8452Q: 0x");
Serial.println(c, HEX);
//while (1); // Loop forever if communication doesn't happen
}
}
//!******************************************************************************
//! Name: readBloodPressureSensor() *
//! Description: Initializes the BloodPressureSensor sensor. *
//! Param : void *
//! Returns: void *
//! Example: eHealth.initBloodPressureSensor(); *
//!******************************************************************************
void eHealthClass::readBloodPressureSensor(void)
{
unsigned char _data;
int ia=0;
length=0;
Serial.begin(19200);
Serial.write(0xAA);
delayMicroseconds(1);
Serial.write(0x55);
delayMicroseconds(1);
Serial.write(0x88);
delay(2500);
Serial.print("\n");
if (Serial.available() > 0) { // The protocol sends the measures
for (int i = 0; i<4; i++){ // Read four dummy data
Serial.read();
}
while(_data != 0xD1){
if (ia==0){
_data = Serial.read();
}
bloodPressureDataVector[length].year = swap(_data);
bloodPressureDataVector[length].month = swap(Serial.read());
bloodPressureDataVector[length].day = swap(Serial.read());
bloodPressureDataVector[length].hour = swap(Serial.read());
bloodPressureDataVector[length].minutes = swap(Serial.read());
bloodPressureDataVector[length].systolic = swap(Serial.read());
bloodPressureDataVector[length].diastolic = swap(Serial.read());
bloodPressureDataVector[length].pulse = swap(Serial.read());
length++;
ia=1;
for (int i = 0; i<4; i++){ // CheckSum 1
Serial.read();
}
_data = Serial.read();
}
for (int i = 0; i<3; i++){ // CheckSum 2
Serial.read();
}
}
}
//!******************************************************************************
//! Name: initPulsioximeter() *
//! Description: Initializes the pulsioximeter sensor. *
//! Param : void *
//! Returns: void *
//! Example: eHealth.initPulsioximeter(); *
//!******************************************************************************
void eHealthClass::initPulsioximeter(void)
{
// Configuring digital pins like INPUTS
pinMode(13, INPUT); pinMode(12, INPUT);
pinMode(11, INPUT); pinMode(10, INPUT);
pinMode( 9, INPUT); pinMode( 8, INPUT);
pinMode( 7, INPUT); pinMode( 6, INPUT);
// attach a PinChange Interrupt to our pin on the rising edge
}
//!******************************************************************************
//! Name: getTemperature() *
//! Description: Returns the corporal temperature. *
//! Param : void *
//! Returns: float with the corporal temperature value. *
//! Example: float temperature = eHealth.getTemperature(); *
//!******************************************************************************
float eHealthClass::getTemperature(void)
{
//Local variables
float Temperature; //Corporal Temperature
float Resistance; //Resistance of sensor.
float ganancia=5.0;
float Vcc=3.3;
float RefTension=3.0; // Voltage Reference of Wheatstone bridge.
float Ra=4700.0; //Wheatstone bridge resistance.
float Rc=4700.0; //Wheatstone bridge resistance.
float Rb=821.0; //Wheatstone bridge resistance.
int sensorValue = analogRead(A3);
float voltage2=((float)sensorValue*Vcc)/1023; // binary to voltage conversion
// Wheatstone bridge output voltage.
voltage2=voltage2/ganancia;
// Resistance sensor calculate
float aux=(voltage2/RefTension)+Rb/(Rb+Ra);
Resistance=Rc*aux/(1-aux);
if (Resistance >=1822.8) {
// if temperature between 25ºC and 29.9ºC. R(tª)=6638.20457*(0.95768)^t
Temperature=log(Resistance/6638.20457)/log(0.95768);
} else {
if (Resistance >=1477.1){
// if temperature between 30ºC and 34.9ºC. R(tª)=6403.49306*(0.95883)^t
Temperature=log(Resistance/6403.49306)/log(0.95883);
} else {
if (Resistance >=1204.8){
// if temperature between 35ºC and 39.9ºC. R(tª)=6118.01620*(0.96008)^t
Temperature=log(Resistance/6118.01620)/log(0.96008);
}
else{
if (Resistance >=988.1){
// if temperature between 40ºC and 44.9ºC. R(tª)=5859.06368*(0.96112)^t
Temperature=log(Resistance/5859.06368)/log(0.96112);
}
else {
if (Resistance >=811.7){
// if temperature between 45ºC and 50ºC. R(tª)=5575.94572*(0.96218)^t
Temperature=log(Resistance/5575.94572)/log(0.96218);
}
}
}
}
}
return Temperature;
}
//!******************************************************************************
//! Name: getOxygenSaturation() *
//! Description: Returns the oxygen saturation in blood in percent. *
//! Param : void *
//! Returns: int with the oxygen saturation value *
//! Example: int SPO2 = eHealth.getOxygenSaturation(); *
//!******************************************************************************
int eHealthClass::getOxygenSaturation(void)
{
return SPO2;
}
//!******************************************************************************
//! Name: getBPM() *
//! Description: Returns the heart beats per minute. *
//! Param : void *
//! Returns: int with the beats per minute *
//! Example: int BPM = eHealth.getBPM(); *
//!******************************************************************************
int eHealthClass::getBPM(void)
{
return BPM;
}
//!******************************************************************************
//! Name: getSkinConductance() *
//! Description: Returns the value of skin conductance. *
//! Param : void *
//! Returns: float with the value of skin conductance *
//! Example: float conductance = eHealth.getSkinConductance(); *
//!******************************************************************************
float eHealthClass::getSkinConductance(void)
{
// Local variable declaration.
float resistance;
float conductance;
delay(1);
// Read an analogic value from analogic2 pin.
float sensorValue = analogRead(A2);
float voltage = sensorValue*5.0/1023;
conductance = 2*((voltage - 0.5) / 100000);
// Conductance calculation
resistance = 1 / conductance;
conductance = conductance * 1000000;
delay(1);
if (conductance > 1.0) return conductance;
else return -1.0;
}
//!******************************************************************************
//! Name: getSkinResistance() *
//! Description: Returns the value of skin resistance. *
//! Param : void *
//! Returns: float with the value of skin resistance *
//! Example: float resistance = eHealth.getSkinResistance(); *
//!******************************************************************************
float eHealthClass::getSkinResistance(void)
{
// Local variable declaration.
float resistance;
float conductance;
// Read an analogic value from analogic2 pin.
float sensorValue = analogRead(A2);
float voltage = (sensorValue * 5.0) / 1023;
delay(2);
conductance = 2*((voltage - 0.5) / 100000);
//Conductance calcultacion
resistance = 1 / conductance;
delay(2);
if (resistance > 1.0 ) return resistance;
else return -1.0;
}
//!******************************************************************************
//! Name: getSkinConductanceVoltage() *
//! Description: Returns the skin conductance value in voltage . *
//! Param : void *
//! Returns: float with the skin conductance value in voltage *
//! Example: float volt = eHealth.getSkinConductanceVoltage(); *
//!******************************************************************************
float eHealthClass::getSkinConductanceVoltage(void)
{
delay(2);
//Read analogic value from analogic2 pin.
int sensorValue = analogRead(A2);
//Convert the readed value to voltage.
float voltage = ( sensorValue * 5.0 ) / 1023;
delay(2);
return voltage;
}
//!******************************************************************************
//! Name: getECG() *
//! Description: Returns an analogic value to represent the ECG. *
//! Param : void *
//! Returns: float with the ECG value in voltage *
//! Example: float volt = eHealth.getECG(); *
//!******************************************************************************
float eHealthClass::getECG(void)
{
float analog0;
// Read from analogic in.
analog0=analogRead(0);
// binary to voltage conversion
return analog0 = (float)analog0 * 5 / 1023.0;
}
//!******************************************************************************
//! Name: getEMG() *
//! Description: Returns an analogic value to represent the EMG. *
//! Param : void *
//! Returns: float with the EMG value in voltage *
//! Example: float volt = eHealth.getEMG(); *
//!******************************************************************************
int eHealthClass::getEMG(void)
{
int analog0;
// Read from analogic in.
analog0=analogRead(0);
// binary to voltage conversion
return analog0;
}
//!******************************************************************************
//! Name: getBodyPosition() *
//! Description: Returns the current body position. *
//! Param : void *
//! Returns: uint8_t with the the position of the pacient. *
//! Example: uint8_t position = eHealth.getBodyPosition(); *
//!******************************************************************************
uint8_t eHealthClass::getBodyPosition(void)
{
static byte source;
/* If int1 goes high, all data registers have new data */
if (digitalRead(int1Pin)) {// Interrupt pin, should probably attach to interrupt function
readRegisters(0x01, 6, &data[0]); // Read the six data registers into data array.
/* For loop to calculate 12-bit ADC and g value for each axis */
for (int i=0; i<6; i+=2) {
accelCount[i/2] = ((data[i] << 8) | data[i+1]) >> 4; // Turn the MSB and LSB into a 12-bit value
if (data[i] > 0x7F) {
accelCount[i/2] = ~accelCount[i/2] + 1;
accelCount[i/2] *= -1; // Transform into negative 2's complement #
}
accel[i/2] = (float) accelCount[i/2]/((1<<12)/(2*scale)); // get actual g value, this depends on scale being set
}
}
/* If int2 goes high, either p/l has changed or there's been a single/double tap */
if (digitalRead(int2Pin)) {
source = readRegister(0x0C); // Read the interrupt source reg.
if ((source & 0x10)==0x10) // If the p/l bit is set, go check those registers
portraitLandscapeHandler();
delay(50); // Delay here for a little printing visibility, make it longer, or delete it
}
delay(100);
return bodyPos;
}
//!******************************************************************************
//! Name: getGData( void ) *
//! Description: Get g data for X, Y, Z Axis *
//! Param : void *
//! Returns: float with g data. *
//! Example: float gData = eHealth.getGdata(); *
//!******************************************************************************
void eHealthClass::getGData( void )
{
//float gData [3];
if (digitalRead(int1Pin)) {// Interrupt pin, should probably attach to interrupt function
readRegisters(0x01, 6, &data[0]); // Read the six data registers into data array.
/* For loop to calculate 12-bit ADC and g value for each axis */
for (int i=0; i<6; i+=2) {
accelCount[i/2] = ((data[i] << 8) | data[i+1]) >> 4; // Turn the MSB and LSB into a 12-bit value
if (data[i] > 0x7F) {
accelCount[i/2] = ~accelCount[i/2] + 1;
accelCount[i/2] *= -1; // Transform into negative 2's complement #
}
accel[i/2] = (float) accelCount[i/2]/((1<<12)/(2*scale)); // get actual g value, this depends on scale being set
gData[i/2] = accel[i/2];
}
}
//return 0;
}
//!******************************************************************************
//! Name: getSystolicPressure() *
//! Description: Returns the value of the systolic pressure. *
//! Param : int *
//! Returns: int with the systolic pressure. *
//! Example: int systolic = eHealth.getSystolicPressure(1); *
//!******************************************************************************
int eHealthClass::getSystolicPressure(int i)
{
return bloodPressureDataVector[i].systolic;
}
//!******************************************************************************
//! Name: getDiastolicPressure() *
//! Description: Returns the value of the diastolic pressure. *
//! Param : int *
//! Returns: int with the diastolic pressure. *
//! Example: int diastolic = eHealth.getDiastolicPressure(1); *
//!******************************************************************************
int eHealthClass::getDiastolicPressure(int i)
{
return bloodPressureDataVector[i].diastolic;
}
//!******************************************************************************
//! Name: getAirFlow() *
//! Description: Returns an analogic value to represent the air flow. *
//! Param : void *
//! Returns: int with the airFlow value (0-1023). *
//! Example: int airFlow = eHealth.getAirFlow(); *
//!******************************************************************************
int eHealthClass::getAirFlow(void)
{
int airFlow = analogRead(A1);
return airFlow;
}
//!******************************************************************************
//! Name: printPosition() *
//! Description: Returns an analogic value to represent the air flow. *
//! Param : uint8_t position : the current body position. *
//! Returns: void *
//! Example: eHealth.printPosition(position); *
//!******************************************************************************
void eHealthClass::printPosition( uint8_t position )
{
if (position == 1) {
Serial.println("Supine position");
} else if (position == 2) {
Serial.println("Left lateral decubitus");
} else if (position == 3) {
Serial.println("Rigth lateral decubitus");
} else if (position == 4) {
Serial.println("Prone position");
} else if (position == 5) {
Serial.println("Stand or sit position");
} else {
Serial.println("non-defined position");
}
}
//!******************************************************************************
//! Name: readPulsioximeter() *
//! Description: It reads a value from pulsioximeter sensor. *
//! Param : void *
//! Returns: void *
//! Example: readPulsioximeter(); *
//!******************************************************************************
void eHealthClass::readPulsioximeter(void)
{
uint8_t digito[] = {0,0,0,0,0,0};
uint8_t A = 0;
uint8_t B = 0;
uint8_t C = 0;
uint8_t D = 0;
uint8_t E = 0;
uint8_t F = 0;
uint8_t G = 0;
for (int i = 0; i<6 ; i++) { // read all the led's of the module
A = !digitalRead(13);
B = !digitalRead(12);
C = !digitalRead(11);
D = !digitalRead(10);
E = !digitalRead(9);
F = !digitalRead(8);
G = !digitalRead(7);
digito[i] = segToNumber(A, B, C ,D ,E, F,G);
delayMicroseconds(2800); //2800 microseconds
}
SPO2 = 10 * digito[5] + digito[4];
BPM = 100 * digito[2] + 10 * digito[1] + digito[0];
}
//!******************************************************************************
//! Name: airflowWave() *
//! Description: It prints air flow wave form in the serial monitor *
//! Param : int air with the analogic value *
//! Returns: void *
//! Example: eHealth.airflowWave(); *
//!******************************************************************************
void eHealthClass::airFlowWave(int air)
{
for (int i=0; i < (air / 5) ; i ++) {
Serial.print("..");
}
Serial.print("..");
Serial.print("\n");
delay(25);
}
//!******************************************************************************
//! Name: readGlucometer() *
//! Description: It reads the data stored in the glucometer *
//! Param : void *
//! Returns: void *
//! Example: eHealth.readGlucometer(); *
//!******************************************************************************
void eHealthClass::readGlucometer(void)
{
// Configuring digital pins like INPUTS
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
delay(100);
Serial.begin(1200);
delay(100);
Serial.print("U"); // Start communication command.
delay(1000); // Wait while receiving data.
Serial.print("\n");
if (Serial.available() > 0) {
length = Serial.read();// The protocol sends the number of measures
Serial.read(); // Read one dummy data
for (int i = 0; i<length; i++) { // The protocol sends data in this order
glucoseDataVector[i].year = Serial.read();
glucoseDataVector[i].month = Serial.read();
glucoseDataVector[i].day = Serial.read();
glucoseDataVector[i].hour = Serial.read();
glucoseDataVector[i].minutes = Serial.read();
Serial.read(); // Byte of separation must be 0x00.
glucoseDataVector[i].glucose = Serial.read();
glucoseDataVector[i].meridian = Serial.read();
Serial.read(); // CheckSum 1
Serial.read(); // CheckSum 2
}
}
digitalWrite(5, LOW);
}
//!******************************************************************************
//! Name: getGlucometerLength() *
//! Description: it returns the number of data stored in the glucometer *
//! Param : void *
//! Returns: uint8_t with length *
//! Example: int length = eHealth.getGlucometerLength(); *
//!******************************************************************************
uint8_t eHealthClass::getGlucometerLength(void)
{
return length;
}
//!******************************************************************************
//! Name: getBloodPressureLength() *
//! Description: it returns the number of data stored in *
//! the blood pressure sensor *
//! Param : void *
//! Returns: uint8_t with length *
//! Example: int length = eHealth.getBloodPressureLength(); *
//!******************************************************************************
uint8_t eHealthClass::getBloodPressureLength(void)
{
return length;
}
//!******************************************************************************
//! Name: numberToMonth() *
//! Description: Convert month variable from numeric to character. *
//! Param : int month in numerical format *
//! Returns: String with the month characters (January, February...). *
//! Example: Serial.print(eHealth.numberToMonth(month)); *
//!******************************************************************************
String eHealthClass::numberToMonth(int month)
{
if (month == 1) return "January";
else if (month == 2) return "February";
else if (month == 3) return "March";
else if (month == 4) return "April";
else if (month == 5) return "May";
else if (month == 6) return "June";
else if (month == 7) return "July";
else if (month == 8) return "August";
else if (month == 9) return "September";
else if (month == 10) return "October";
else if (month == 11) return "November";
else return "December";
}
//!******************************************************************************
//! Name: version() *
//! Description: It check the version of the library *
//! Param : void *
//! Returns: void *
//! Example: eHealth.version(); *
//!******************************************************************************
int eHealthClass::version(void)
{
return 2.0;
}
//***************************************************************
// Private Methods *
//***************************************************************
//! This function will read the p/l source register and
//! print what direction the sensor is now facing */
void eHealthClass::portraitLandscapeHandler()
{
byte pl = readRegister(0x10); // Reads the PL_STATUS register
switch((pl&0x06)>>1) // Check on the LAPO[1:0] bits
{
case 0:
position[0] = 0;
break;
case 1:
position[0] = 1;
break;
case 2:
position[0] = 2;
break;
case 3:
position[0] = 3;
break;
}
if (pl&0x01) // Check the BAFRO bit
position[1] = 0;
else
position[1] = 1;
if (pl&0x40) // Check the LO bit
position[2] = 0;
else
position[2] = 1;
bodyPosition();
}
/*******************************************************************************************************/
//! Initialize the MMA8452 registers.
void eHealthClass::initMMA8452(byte fsr, byte dataRate)
{
MMA8452Standby(); // Must be in standby to change registers
/* Set up the full scale range to 2, 4, or 8g. */
if ((fsr==2)||(fsr==4)||(fsr==8))
writeRegister(0x0E, fsr >> 2);
else
writeRegister(0x0E, 0);
/* Setup the 3 data rate bits, from 0 to 7 */
writeRegister(0x2A, readRegister(0x2A) & ~(0x38));
if (dataRate <= 7)
writeRegister(0x2A, readRegister(0x2A) | (dataRate << 3));
/* Set up portrait/landscap registers */
writeRegister(0x11, 0x40); // Enable P/L
writeRegister(0x13, 0x14); // 29deg z-lock,
writeRegister(0x14, 0x84); // 45deg thresh, 14deg hyst
writeRegister(0x12, 0x05); // debounce counter at 100ms
/* Set up single and double tap */
writeRegister(0x21, 0x7F); // enable single/double taps on all axes
writeRegister(0x23, 0x20); // x thresh at 2g
writeRegister(0x24, 0x20); // y thresh at 2g
writeRegister(0x25, 0x8); // z thresh at .5g
writeRegister(0x26, 0x30); // 60ms time limit, the min/max here is very dependent on output data rate
writeRegister(0x27, 0x28); // 200ms between taps min
writeRegister(0x28, 0xFF); // 1.275s (max value) between taps max
/* Set up interrupt 1 and 2 */
writeRegister(0x2C, 0x02); // Active high, push-pull
writeRegister(0x2D, 0x19); // DRDY int enabled, P/L enabled
writeRegister(0x2E, 0x01); // DRDY on INT1, P/L on INT2
MMA8452Active(); // Set to active to start reading
}
/*******************************************************************************************************/
//! Sets the MMA8452 to standby mode. It must be in standby to change most register settings.
void eHealthClass::MMA8452Standby()
{
byte c = readRegister(0x2A);
writeRegister(0x2A, c & ~(0x01));
}
/*******************************************************************************************************/
//! Sets the MMA8452 to active mode. Needs to be in this mode to output data
void eHealthClass::MMA8452Active()
{
byte c = readRegister(0x2A);
writeRegister(0x2A, c | 0x01);
}
/*******************************************************************************************************/
//! Read i registers sequentially, starting at address into the dest byte array.
void eHealthClass::readRegisters(byte address, int i, byte * dest)
{
i2cSendStart();
i2cWaitForComplete();
i2cSendByte((MMA8452_ADDRESS<<1)); // write 0xB4
i2cWaitForComplete();
i2cSendByte(address); // write register address
i2cWaitForComplete();
i2cSendStart();
i2cSendByte((MMA8452_ADDRESS<<1)|0x01); // write 0xB5
i2cWaitForComplete();
for (int j=0; j<i; j++) {
i2cReceiveByte(TRUE);
i2cWaitForComplete();
dest[j] = i2cGetReceivedByte(); // Get MSB result
}
i2cWaitForComplete();
i2cSendStop();
cbi(TWCR, TWEN);// Disable TWI
sbi(TWCR, TWEN);// Enable TWI
}
/*******************************************************************************************************/
//! Read a single byte from address and return it as a byte.
byte eHealthClass::readRegister(uint8_t address)
{
byte data;
i2cSendStart();
i2cWaitForComplete();
i2cSendByte((MMA8452_ADDRESS<<1)); // write 0xB4
i2cWaitForComplete();
i2cSendByte(address); // write register address
i2cWaitForComplete();
i2cSendStart();
i2cSendByte((MMA8452_ADDRESS<<1)|0x01); // write 0xB5
i2cWaitForComplete();
i2cReceiveByte(TRUE);
i2cWaitForComplete();
data = i2cGetReceivedByte(); // Get MSB result
i2cWaitForComplete();
i2cSendStop();
cbi(TWCR, TWEN); // Disable TWI
sbi(TWCR, TWEN); // Enable TWI
return data;
}
/*******************************************************************************************************/
//! Writes a single byte (data) into address
void eHealthClass::writeRegister(unsigned char address, unsigned char data)
{
i2cSendStart();
i2cWaitForComplete();
i2cSendByte((MMA8452_ADDRESS<<1));// write 0xB4
i2cWaitForComplete();
i2cSendByte(address);// write register address
i2cWaitForComplete();
i2cSendByte(data);
i2cWaitForComplete();
i2cSendStop();
}
/*******************************************************************************************************/
//! Assigns a value depending on body position.
void eHealthClass::bodyPosition( void )
{
if (( position[0] == 0 ) && (position[1] == 1) && (position [2] == 0)) {
bodyPos = 1;
} else if (( position[0] == 1 ) && (position[1] == 1) && (position [2] == 0)) {
bodyPos = 1;
} else if (( position[0] == 3 ) && (position[1] == 1) && (position [2] == 0)) {
bodyPos = 1;
} else if (( position[0] == 2 ) && (position[1] == 0) && (position [2] == 0)) {
bodyPos = 1;
} else if (( position[0] == 2 ) && (position[1] == 1) && (position [2] == 1)) {
bodyPos = 1;
} else if (( position[0] == 2 ) && (position[1] == 1) && (position [2] == 0)) {
bodyPos = 1;
} else if (( position[0] == 0 ) && (position[1] == 1) && (position [2] == 1)) {
bodyPos = 2;
} else if (( position[0] == 0 ) && (position[1] == 0) && (position [2] == 1)) {
bodyPos = 2;
} else if (( position[0] == 1 ) && (position[1] == 1) && (position [2] == 1)) {
bodyPos = 3;
} else if (( position[0] == 1 ) && (position[1] == 0) && (position [2] == 1)) {
bodyPos = 3;
} else if (( position[0] == 1 ) && (position[1] == 0) && (position [2] == 0)) {
bodyPos = 4;
} else if (( position[0] == 3 ) && (position[1] == 0) && (position [2] == 0)) {
bodyPos = 4;
} else if (( position[0] == 3 ) && (position[1] == 0) && (position [2] == 1)) {
bodyPos = 5;
} else if (( position[0] == 3 ) && (position[1] == 1) && (position [2] == 1)) {
bodyPos = 5;
} else if (( position[0] == 2 ) && (position[1] == 0) && (position [2] == 1)) {
bodyPos = 5;
} else {
bodyPos = 6;
}
}
/*******************************************************************************************************/
//! Converts from 7 segments to number.
uint8_t eHealthClass::segToNumber(uint8_t A, uint8_t B, uint8_t C, uint8_t D, uint8_t E, uint8_t F, uint8_t G )
{
if ((A == 1) && (B == 1) && (C == 1) && (D == 0) && (E == 1) && (F == 1) && (G == 1)) {
return 0;
} else if ((A == 0) && (B == 1) && (C == 0) && (D == 0) && (E == 1) && (F == 0) && (G == 0)) {
return 1;
} else if ((A == 1) && (B == 1) && (C == 0) && (D == 1) && (E == 0) && (F == 1) && (G == 1)) {
return 2;
} else if ((A == 1) && (B == 1) && (C == 0) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) {
return 3;
} else if ((A == 0) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 0)) {
return 4;
} else if ((A == 1) && (B == 0) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) {
return 5;
} else if ((A == 1) && (B == 0) && (C == 1) && (D == 1) && (E == 1) && (F == 1) && (G == 1)) {
return 6;
} else if ((A == 1) && (B == 1) && (C == 0) && (D == 0) && (E == 1) && (F == 0) && (G == 0)) {
return 7;
} else if ((A == 1) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 1) && (G == 1)) {
return 8;
} else if ((A == 1) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) {
return 9;
} else {
return 0;
}
}
/*******************************************************************************************************/
//! Swap data for blood pressure mesure
char eHealthClass::swap(char _data)
{
char highBits = (_data & 0xF0) / 16;
char lowBits = (_data & 0x0F) * 16;
return ~(highBits + lowBits);
}
/*******************************************************************************************************/
//***************************************************************
// Preinstantiate Objects *
//***************************************************************
eHealthClass eHealth = eHealthClass();
| [
"cyl35@cornell.edu"
] | cyl35@cornell.edu |
40db43303abd51acfe56f72e391e2b5b3423648c | d2190cbb5ea5463410eb84ec8b4c6a660e4b3d0e | /old_hydra/hydra/tags/apr07/rich/hrichparset.cc | 552c3d319a9fdcaffea85ef8c7da6a089bde1dd2 | [] | no_license | wesmail/hydra | 6c681572ff6db2c60c9e36ec864a3c0e83e6aa6a | ab934d4c7eff335cc2d25f212034121f050aadf1 | refs/heads/master | 2021-07-05T17:04:53.402387 | 2020-08-12T08:54:11 | 2020-08-12T08:54:11 | 149,625,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,388 | cc | // File: hrichparset.cc
// ***************************************************************************
//*-- Author : Witold Przygoda (przygoda@psja1.if.uj.edu.pl)
//*-- Modified : 1999/12/04 by Witold Przygoda (przygoda@psja1.if.uj.edu.pl)
using namespace std;
#include <iostream>
#include <iomanip>
#include "hrichparset.h"
#include "hdetector.h"
#include "hpario.h"
#include "hdetpario.h"
// ***************************************************************************
//_HADES_CLASS_DESCRIPTION
//////////////////////////////////////////////////////////////////////////////
//
// HRichParSet
//
// Set of RICH containers.
//
//////////////////////////////////////////////////////////////////////////////
// ***************************************************************************
ClassImp(HRichParSet)
//----------------------------------------------------------------------------
HRichParSet::HRichParSet(const char* name,const char* title,
const char* context)
: HParSet(name,title,context) {
strcpy(detName,"Rich");
}
//============================================================================
//----------------------------------------------------------------------------
Bool_t HRichParSet::init(HParIo* inp,Int_t* set) {
// intitializes the container from an input
HDetParIo* input=inp->getDetParIo("HRichParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
//============================================================================
//----------------------------------------------------------------------------
Int_t HRichParSet::write(HParIo* output) {
HDetParIo* out=output->getDetParIo("HRichParIo");
if (out) return out->write(this);
return kFALSE;
}
//============================================================================
/*
//______________________________________________________________________________
void HRichParSet::Streamer(TBuffer &R__b)
{
// Stream an object of class HRichParSet.
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
HParSet::Streamer(R__b);
m_pReadParam = NULL;
// R__b >> m_pReadParam;
} else {
R__b.WriteVersion(HRichParSet::IsA());
HParSet::Streamer(R__b);
// R__b << m_pReadParam;
}
}
//============================================================================
*/
| [
"waleed.physics@gmail.com"
] | waleed.physics@gmail.com |
72788706d6a971cb334a0023bf1d7657cb829a0e | 0688ed4fbbbd19613cc453c568af75ba59ae5144 | /libraries/mojingsdk/src/main/cpp/googlebreakpad/src/third_party/protobuf/protobuf/src/google/protobuf/compiler/zip_writer.h | 8e245161562b382e4a2c8b30c3e4048596bf183f | [
"LicenseRef-scancode-protobuf"
] | permissive | playbar/testplayer | 49c068e53a5b93768b4d46f4f9b8d2bb739ff7fe | b4869ed9193739ab48c067cd51b4f5084943e924 | refs/heads/master | 2021-05-07T03:37:09.438661 | 2017-11-20T03:38:59 | 2017-11-20T03:38:59 | 110,958,488 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,949 | h | // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/zero_copy_stream.h>
namespace google {
namespace protobuf {
namespace compiler {
class ZipWriter {
public:
ZipWriter(io::ZeroCopyOutputStream* raw_output);
~ZipWriter();
bool Write(const string& filename, const string& contents);
bool WriteDirectory();
private:
struct FileInfo {
string name;
uint32 offset;
uint32 size;
uint32 crc32;
};
io::ZeroCopyOutputStream* raw_output_;
vector<FileInfo> files_;
};
} // namespace compiler
} // namespace protobuf
} // namespace google
| [
"hgl868@126.com"
] | hgl868@126.com |
926434727b4c0e62e60f582dc027898c14bdd78e | bdc11b8ffdff4d6fd7c8f34eb1cd1e0609edf9e9 | /ofApp.cpp | 7b8bd5aa829007260306c789a3329272f5bd6710 | [] | no_license | junkiyoshi/Insta20170919 | a4e02467ae4379ae83c865e5bca75c4d7d2013a7 | f2d2f628fd051fe7f24fb4a28ac68ec867fa72da | refs/heads/master | 2021-06-29T19:57:27.687280 | 2017-09-19T08:42:27 | 2017-09-19T08:42:27 | 104,049,590 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,394 | cpp | #include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofSetFrameRate(30);
ofBackground(0);
ofSetWindowTitle("Insta");
ofEnableDepthTest();
ofEnableSmoothing();
this->size = 30;
bool flg = true;
for (float y = -ofGetHeight(); y < ofGetHeight(); y += this->size + this->size / 2) {
for (float x = -ofGetWidth(); x < ofGetWidth(); x += this->size * sqrt(3)) {
ofVec3f location;
if (flg) {
location = ofVec3f(x, y, 0);
} else {
location = ofVec3f(ofVec3f(x + (this->size * sqrt(3) / 2), y, 0));
}
ofColor body_color(255, 0, 0);
this->particles.push_back(new Particle(location, this->size, body_color));
}
flg = !flg;
}
}
//--------------------------------------------------------------
void ofApp::update(){
for (Particle* p : this->particles) {
float height = 300 * ofNoise(p->getLocation().x * 0.0025, p->getLocation().y * 0.0025, ofGetFrameNum() * 0.005);
p->update(height);
}
}
//--------------------------------------------------------------
void ofApp::draw() {
this->cam.begin();
for (Particle* p : this->particles) {
p->draw();
}
this->cam.end();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
| [
"nakauchi.k@g-hits.co.jp"
] | nakauchi.k@g-hits.co.jp |
b6ce59b587487ed4dc97704db9513d7ba7d78910 | 0577a46d8d28e1fd8636893bbdd2b18270bb8eb8 | /update_notifier/thirdparty/wxWidgets/src/generic/colour.cpp | 0f21410520f2e7567831bec4ff8ab421ebc99097 | [
"BSD-3-Clause"
] | permissive | ric2b/Vivaldi-browser | 388a328b4cb838a4c3822357a5529642f86316a5 | 87244f4ee50062e59667bf8b9ca4d5291b6818d7 | refs/heads/master | 2022-12-21T04:44:13.804535 | 2022-12-17T16:30:35 | 2022-12-17T16:30:35 | 86,637,416 | 166 | 41 | BSD-3-Clause | 2021-03-31T18:49:30 | 2017-03-29T23:09:05 | null | UTF-8 | C++ | false | false | 1,122 | cpp | /////////////////////////////////////////////////////////////////////////////
// Name: src/generic/colour.cpp
// Purpose: wxColour class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/colour.h"
#ifndef WX_PRECOMP
#include "wx/gdicmn.h"
#endif
// Colour
void wxColour::Init()
{
m_red =
m_blue =
m_green = 0;
m_alpha = wxALPHA_OPAQUE;
m_isInit = false;
}
void wxColour::InitRGBA(unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a)
{
m_red = r;
m_green = g;
m_blue = b;
m_alpha = a;
m_isInit = true;
}
wxColour& wxColour::operator=(const wxColour& col)
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_alpha = col.m_alpha;
m_isInit = col.m_isInit;
return *this;
}
| [
"mathieu.caroff@free.fr"
] | mathieu.caroff@free.fr |
8e5f93a2d20a194d2a1b390527d7a153be0b7d38 | b9ba37afe2d79814c2e3e4798add49aadf8ed7b2 | /Theoretical Practical/TP1/parque.cpp | 5b6448d03155b7a353d8397fcb2abbcf45f9cb64 | [] | no_license | beatrizlopesdossantos/FEUP-AEDA | aed530f240add2d955feb3d846fcd35eba446768 | 9a64cbf0d8ca0e9009d5658c2203afaeb73e108c | refs/heads/master | 2023-03-04T15:57:50.085482 | 2021-02-17T23:02:07 | 2021-02-17T23:02:07 | 339,875,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,934 | cpp | #include "parque.h"
using namespace std;
ParqueEstacionamento::ParqueEstacionamento(unsigned lot, unsigned nMaxCli): lotacao(lot), numMaximoClientes(nMaxCli) {
vagas=lot;
}
unsigned ParqueEstacionamento::getNumLugares() const {
return lotacao;
}
unsigned ParqueEstacionamento::getNumMaximoClientes() const {
return numMaximoClientes;
}
int ParqueEstacionamento::posicaoCliente(const string & nome) const {
for (int i = 0; i < clientes.size(); i++) {
if (clientes[i].nome == nome) {
return i;
}
}
return -1;
}
bool ParqueEstacionamento::adicionaCliente(const string & nome) {
if (clientes.size() == numMaximoClientes) {
return false;
}
if (posicaoCliente(nome) != -1) {
return false;
}
InfoCartao info;
info.nome = nome;
info.presente=false;
clientes.push_back(info);
return true;
}
bool ParqueEstacionamento::entrar(const string & nome) {
int pos = posicaoCliente(nome);
if (pos == -1 || clientes[pos].presente == true || vagas == 0) {
return false;
}
clientes[pos].presente = true;
vagas--;
return true;
}
bool ParqueEstacionamento::retiraCliente(const string & nome) {
for (auto it = clientes.begin(); it != clientes.end(); it++)
if ( (*it).nome == nome ) {
if ( (*it).presente == false ) {
clientes.erase(it);
return true;
}
else return false;
}
return false;
}
bool ParqueEstacionamento::sair(const string & nome) {
int pos = posicaoCliente(nome);
if (pos == -1 || !clientes[pos].presente) {
return false;
}
clientes[pos].presente = false;
vagas++;
return true;
}
unsigned ParqueEstacionamento::getNumLugaresOcupados() const {
return numMaximoClientes-lotacao;
}
unsigned ParqueEstacionamento::getNumClientesAtuais() const {
return clientes.size();
}
| [
"mbrlopes.santos@gmail.com"
] | mbrlopes.santos@gmail.com |
763447116b4124a00885ad14958c0df4c9fb2c88 | 397f37e9db6a52ca5015b31082b465946e0ef1ec | /src/constants.cc | 27d13387a72240c974c800ac575dcf29c7b83bba | [
"MIT"
] | permissive | rcythr/RML | c188aadd578430e88e026aab196aad8791d7599f | 5f07eb4adba73c289f88f43bd0268225ef1376b4 | refs/heads/master | 2021-01-19T19:36:09.395215 | 2014-09-02T14:48:42 | 2014-09-02T14:48:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,668 | cc | // This file is part of RML
// RML is licensed with the MIT License. See the LICENSE file for more information.
#include <RML/constants.hpp>
#include <RML/util.hpp>
namespace rml
{
std::unordered_set<std::string> html5Tags
{
"a",
"abbr",
"address",
"area",
"article",
"aside",
"audio",
"b",
"base",
"bdi",
"bdo",
"blockquote",
"body",
"br",
"button",
"canvas",
"caption",
"cite",
"code",
"col",
"colgroup",
"data",
"datalist",
"dd",
"del",
"details",
"dfn",
"div",
"dl",
"dt",
"em",
"embed",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"head",
"header",
"hr",
"html",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"keygen",
"label",
"legend",
"li",
"link",
"main",
"map",
"mark",
"math",
"menu",
"menuitem",
"meta",
"meter",
"nav",
"noscript",
"object",
"ol",
"optgroup",
"option",
"output",
"p",
"param",
"pre",
"progress",
"q",
"rp",
"rt",
"ruby",
"s",
"samp",
"script",
"section",
"select",
"small",
"source",
"span",
"strong",
"style",
"sub",
"summary",
"sup",
"svg",
"table",
"tbody",
"td",
"template",
"textarea",
"tfoot",
"th",
"thead",
"time",
"title",
"tr",
"track",
"u",
"ul",
"var"
"wbr",
};
std::unordered_set<std::string> deprecatedTags
{
"acronym",
"applet",
"basefont",
"bgsound",
"big",
"blink",
"center",
"decorator",
"dir",
"font",
"frame",
"frameset",
"hgroup",
"isindex",
"listing",
"marquee",
"nobr",
"noframes",
"plaintext",
"shadow",
"spacer",
"strike",
"tt",
"xmp"
};
std::unordered_set<std::string> globalAttributes
{
"accesskey",
"class",
"contenteditable",
"contextmenu",
"dir",
"draggable",
"dropzone",
"hidden",
"id",
"itemid",
"itemprop",
"itemref",
"itemscope",
"itemtype",
"lang",
"spellcheck",
"style",
"tabindex",
"title",
// ARIA
"role"
};
std::unordered_map<std::string, std::set<std::string>> attributeValidationSets
{
{ "a", { "download", "href", "media", "ping", "rel", "target", "datafld", "datasrc", "hreflang", "methods", "type", "urn" } },
{ "area", { "alt", "coords", "download", "href", "hreflang", "media", "rel", "shape", "target", "type" } },
{"audio", {"autoplay","buffered","controls","loop", "muted","played", "preload", "src","volume"}},
{"base", {"href","target"}},
{"blockquote", {"cite"}},
{"body", { "onafterprint", "onbeforeprint", "onbeforeunload", "onblur", "onerror", "onfocus", "onhashchange", "onload", "onmessage", "onoffline", "ononline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload" }},
{"button", { "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "type", "value"}},
{"canvas", {"width", "height"}},
{"col", {"span"}},
{"colgroup", {"span"}},
{"data", {"value"}},
{"datalist", {}},
{"dd", {"nowrap"}},
{"del", {"cite","datetime"}},
{"details", {"open"}},
{"dl", {"compact"}},
{"embed", {"height","src","type","width"}},
{"fieldset", {"disabled","form","name"}},
{"form", {"accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target",}},
{"head", { "profile" }},
{"hr", {"color"}},
{"html", { "manifest", "version" }},
{"iframe", {"allowfullscreen","height","name","remote","scrolling","sandbox","seamless","src","srcdoc","width"}},
{"img", {"alt","crossorigin","height","ismap","longdesc","src","srcset","width","usemap"}},
{"input", {"type","accept","autocomplete","autofocus","autosave","checked","disabled","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","list","max","maxlength","min","minlength","multiple","name","pattern","placeholder","readonly","required","selectionDirection","size","spellcheck","src","step","value","width"}},
{"ins", {"cite","datetime"}},
{"keygen", { "autofocus", "challenge", "disabled", "form", "keytype", "name"}},
{"label", { "accesskey", "for", "form" }},
{"li", {"value", "type"}},
{"link", { "charset", "disabled", "href", "hreflang", "media", "methods", "rel", "sizes", "target", "type" }},
{"map", {"name"}},
{"menu",{"label","type"}},
{"menuitem", {"checked", "command", "default", "disabled", "icon", "label", "radiogroup", "type"}},
{"meta", { "charset", "content", "http-equiv", "name", "scheme" }},
{"meter", { "value", "min", "max", "low", "high", "optimum", "form"}},
{"object", {"data","form","height","name","type","usemap","width"}},
{"ol", {"reversed", "start", "type"}},
{"optgroup", {"disabled", "label"}},
{"option", {"disabled","label", "selected","value"}},
{"output", { "for", "form", "name" }},
{"param", {"name", "value"}},
{"pre", {"wrap"}},
{"progress", {"max","value"}},
{"q", {"cite"}},
{"script", { "async", "src", "type", "language", "defer", "crossorigin" }},
{"select", {"autofocus", "disabled", "form", "multiple", "name", "required", "size"}},
{"source", {"src", "type"}},
{"style", { "type", "media", "scoped", "title", "disabled" }},
{"td", {"colspan","headers","rowspan"}},
{"template", { "content" }},
{"textarea", {"autocomplete","autofocus","cols","disabled","form","maxlength","minlength","name","placeholder","readonly","required","rows","selectionDirection","selectionEnd","selectionStart","spellcheck","wrap"}},
{"th", {"colspan", "headers", "rowspan", "scope"}},
{"time", {"datetime"}},
{"track", {"default", "kind", "label", "src", "srclang"}},
{"video", {"autoplay", "buffered", "controls", "crossorigin", "height", "loop", "muted", "played", "preload", "poster", "src", "width"}},
};
std::unordered_set<std::string> voidTags
{
"base",
"br",
"col",
"embed",
"img",
"input",
"keygen",
"link",
"menuitem",
"meta",
"param",
"source",
"track",
"wbr",
};
bool isHtml5Tag(std::string& tag)
{
return html5Tags.find(tag) != html5Tags.end();
}
bool isDeprecatedTag(std::string& tag)
{
return deprecatedTags.find(tag) != deprecatedTags.end();
}
bool isVoidTag(std::string& tag)
{
return voidTags.find(tag) != voidTags.end();
}
bool isAttributeValidForTag(const std::string& tag, const std::string& attr)
{
// Special cases
if (tag == "svg")
return true;
else if (tag == "math")
return true;
else if (tag == "mstyle")
return true;
if (beginsWith(attr, "data-"))
return true;
else if(beginsWith(attr, "aria-"))
return true;
// Handle global attributes
auto glob_find = globalAttributes.find(attr);
if(glob_find != globalAttributes.end())
return true;
// Handle tag specific
auto tag_find = attributeValidationSets.find(tag);
if (tag_find != attributeValidationSets.end())
{
auto attr_find = tag_find->second.find(attr);
return attr_find != tag_find->second.end();
}
// With an invalid tag there are no valid attributes.
return false;
}
}
| [
"rwl3564@rit.edu"
] | rwl3564@rit.edu |
8b5531ae427ae85639c4aa5b0983f5671f9c065b | eafabfbd433f01126ef9b0105d86ff720902f931 | /BizEntity/TradeFund/stdafx.cpp | 0dbdff2dc550e81fdd46ca688572af0b6199ba01 | [] | no_license | imuse2012/XCaimi | 9b3f06eee4f1b6091e625b3fc8c5b555a18e01c0 | ccadd2daefade077e46e3f8be49f3ba3769bf26d | refs/heads/master | 2021-01-18T07:47:28.956755 | 2013-11-18T04:47:27 | 2013-11-18T04:47:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 202 | cpp | // stdafx.cpp : source file that includes just the standard includes
// TradeFund.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"youqian@vip.sina.com"
] | youqian@vip.sina.com |
81beca2cbb06bf73f41693cfd3033b46d1c3b220 | 48e4c9712b38a90b819c84db064422e1088c4565 | /toolchains/motoezx/qt/include/qt-2.3.8/qgdict.h | 93db6a205af015ab5c1fbd8e5d371eadce332492 | [] | no_license | blchinezu/EZX-SDK_CPP-QT-SDL | 8e4605ed5940805f49d76e7700f19023dea9e36b | cbb01e0f1dd03bdf8b071f503c4e3e43b2e6ac33 | refs/heads/master | 2020-06-05T15:25:21.527826 | 2020-05-15T11:11:13 | 2020-05-15T11:11:13 | 39,446,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,548 | h | /****************************************************************************
** $Id: qt/src/tools/qgdict.h 2.3.8 edited 2004-08-05 $
**
** Definition of QGDict and QGDictIterator classes
**
** Created : 920529
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the tools module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QGDICT_H
#define QGDICT_H
#ifndef QT_H
#include "qcollection.h"
#include "qstring.h"
#endif // QT_H
class QGDictIterator;
class QGDItList;
class QBaseBucket // internal dict node
{
public:
QCollection::Item getData() { return data; }
QCollection::Item setData( QCollection::Item d ) { return data = d; }
QBaseBucket *getNext() { return next; }
void setNext( QBaseBucket *n) { next = n; }
protected:
QBaseBucket( QCollection::Item d, QBaseBucket *n ) : data(d), next(n) {}
QCollection::Item data;
QBaseBucket *next;
};
class QStringBucket : public QBaseBucket
{
public:
QStringBucket( const QString &k, QCollection::Item d, QBaseBucket *n )
: QBaseBucket(d,n), key(k) {}
const QString &getKey() const { return key; }
private:
QString key;
};
class QAsciiBucket : public QBaseBucket
{
public:
QAsciiBucket( const char *k, QCollection::Item d, QBaseBucket *n )
: QBaseBucket(d,n), key(k) {}
const char *getKey() const { return key; }
private:
const char *key;
};
class QIntBucket : public QBaseBucket
{
public:
QIntBucket( long k, QCollection::Item d, QBaseBucket *n )
: QBaseBucket(d,n), key(k) {}
long getKey() const { return key; }
private:
long key;
};
class QPtrBucket : public QBaseBucket
{
public:
QPtrBucket( void *k, QCollection::Item d, QBaseBucket *n )
: QBaseBucket(d,n), key(k) {}
void *getKey() const { return key; }
private:
void *key;
};
class Q_EXPORT QGDict : public QCollection // generic dictionary class
{
public:
uint count() const { return numItems; }
uint size() const { return vlen; }
QCollection::Item look_string( const QString& key, QCollection::Item,
int );
QCollection::Item look_ascii( const char *key, QCollection::Item, int );
QCollection::Item look_int( long key, QCollection::Item, int );
QCollection::Item look_ptr( void *key, QCollection::Item, int );
#ifndef QT_NO_DATASTREAM
QDataStream &read( QDataStream & );
QDataStream &write( QDataStream & ) const;
#endif
protected:
enum KeyType { StringKey, AsciiKey, IntKey, PtrKey };
QGDict( uint len, KeyType kt, bool cs, bool ck );
QGDict( const QGDict & );
~QGDict();
QGDict &operator=( const QGDict & );
bool remove_string( const QString &key, QCollection::Item item=0 );
bool remove_ascii( const char *key, QCollection::Item item=0 );
bool remove_int( long key, QCollection::Item item=0 );
bool remove_ptr( void *key, QCollection::Item item=0 );
QCollection::Item take_string( const QString &key );
QCollection::Item take_ascii( const char *key );
QCollection::Item take_int( long key );
QCollection::Item take_ptr( void *key );
void clear();
void resize( uint );
int hashKeyString( const QString & );
int hashKeyAscii( const char * );
void statistics() const;
#ifndef QT_NO_DATASTREAM
virtual QDataStream &read( QDataStream &, QCollection::Item & );
virtual QDataStream &write( QDataStream &, QCollection::Item ) const;
#endif
private:
QBaseBucket **vec;
uint vlen;
uint numItems;
uint keytype : 2;
uint cases : 1;
uint copyk : 1;
QGDItList *iterators;
void unlink_common( int, QBaseBucket *, QBaseBucket * );
QStringBucket *unlink_string( const QString &,
QCollection::Item item = 0 );
QAsciiBucket *unlink_ascii( const char *, QCollection::Item item = 0 );
QIntBucket *unlink_int( long, QCollection::Item item = 0 );
QPtrBucket *unlink_ptr( void *, QCollection::Item item = 0 );
void init( uint, KeyType, bool, bool );
friend class QGDictIterator;
};
class Q_EXPORT QGDictIterator // generic dictionary iterator
{
friend class QGDict;
public:
QGDictIterator( const QGDict & );
QGDictIterator( const QGDictIterator & );
QGDictIterator &operator=( const QGDictIterator & );
~QGDictIterator();
QCollection::Item toFirst();
QCollection::Item get() const;
QString getKeyString() const;
const char *getKeyAscii() const;
long getKeyInt() const;
void *getKeyPtr() const;
QCollection::Item operator()();
QCollection::Item operator++();
QCollection::Item operator+=(uint);
protected:
QGDict *dict;
private:
QBaseBucket *curNode;
uint curIndex;
};
inline QCollection::Item QGDictIterator::get() const
{
return curNode ? curNode->getData() : 0;
}
inline QString QGDictIterator::getKeyString() const
{
return curNode ? ((QStringBucket*)curNode)->getKey() : QString::null;
}
inline const char *QGDictIterator::getKeyAscii() const
{
return curNode ? ((QAsciiBucket*)curNode)->getKey() : 0;
}
inline long QGDictIterator::getKeyInt() const
{
return curNode ? ((QIntBucket*)curNode)->getKey() : 0;
}
inline void *QGDictIterator::getKeyPtr() const
{
return curNode ? ((QPtrBucket*)curNode)->getKey() : 0;
}
#endif // QGDICT_H
| [
"eu.gabii@yahoo.com"
] | eu.gabii@yahoo.com |
0923816457327bb14ff7f7bf2aafd384705a7d96 | f7ef7dabcc31ce5e2684a028f25f059302040392 | /src/gs2/friend/request/DeleteRequestRequest.hpp | ad6311277376ace40c2179a08ed1be4ca071c1fb | [] | no_license | gs2io/gs2-cpp-sdk | 68bb09c0979588b850913feb07406698f661b012 | 8dc862e247e4cc2924a060701be783096d307a44 | refs/heads/develop | 2021-08-16T17:11:59.557099 | 2020-08-03T09:26:00 | 2020-08-03T09:26:10 | 148,787,757 | 0 | 0 | null | 2020-11-15T08:08:06 | 2018-09-14T12:50:30 | C++ | UTF-8 | C++ | false | false | 7,250 | hpp | /*
* Copyright 2016 Game Server Services, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file 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 GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_
#define GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_
#include <gs2/core/control/Gs2BasicRequest.hpp>
#include <gs2/core/util/List.hpp>
#include <gs2/core/util/StringHolder.hpp>
#include <gs2/core/util/StandardAllocator.hpp>
#include <gs2/core/external/optional/optional.hpp>
#include <gs2/friend/Gs2FriendConst.hpp>
#include <gs2/friend/model/model.hpp>
#include <memory>
namespace gs2 { namespace friend_
{
/**
* フレンドリクエストを削除 のリクエストモデル
*
* @author Game Server Services, Inc.
*/
class DeleteRequestRequest : public Gs2BasicRequest, public Gs2Friend
{
public:
constexpr static const Char* const FUNCTION = "";
private:
class Data : public Gs2BasicRequest::Data
{
public:
/** アクセストークン */
optional<StringHolder> accessToken;
/** ネームスペース名 */
optional<StringHolder> namespaceName;
/** リクエストの送信先ユーザID */
optional<StringHolder> targetUserId;
/** 重複実行回避機能に使用するID */
optional<StringHolder> duplicationAvoider;
Data() = default;
Data(const Data& data) :
Gs2BasicRequest::Data(data),
accessToken(data.accessToken),
namespaceName(data.namespaceName),
targetUserId(data.targetUserId),
duplicationAvoider(data.duplicationAvoider)
{
}
Data(Data&& data) = default;
~Data() = default;
Data& operator=(const Data&) = delete;
Data& operator=(Data&&) = delete;
};
GS2_CORE_SHARED_DATA_DEFINE_MEMBERS(Data, ensureData)
Gs2BasicRequest::Data& getData_() GS2_OVERRIDE
{
return ensureData();
}
const Gs2BasicRequest::Data& getData_() const GS2_OVERRIDE
{
return ensureData();
}
public:
DeleteRequestRequest() = default;
DeleteRequestRequest(const DeleteRequestRequest& deleteRequestRequest) = default;
DeleteRequestRequest(DeleteRequestRequest&& deleteRequestRequest) = default;
~DeleteRequestRequest() GS2_OVERRIDE = default;
DeleteRequestRequest& operator=(const DeleteRequestRequest& deleteRequestRequest) = default;
DeleteRequestRequest& operator=(DeleteRequestRequest&& deleteRequestRequest) = default;
DeleteRequestRequest deepCopy() const
{
GS2_CORE_SHARED_DATA_DEEP_COPY_IMPLEMENTATION(DeleteRequestRequest);
}
const DeleteRequestRequest* operator->() const
{
return this;
}
DeleteRequestRequest* operator->()
{
return this;
}
/**
* アクセストークンを取得。
*
* @return アクセストークン
*/
const gs2::optional<StringHolder>& getAccessToken() const
{
return ensureData().accessToken;
}
/**
* アクセストークンを設定。
*
* @param accessToken アクセストークン
*/
void setAccessToken(StringHolder accessToken)
{
ensureData().accessToken.emplace(std::move(accessToken));
}
/**
* アクセストークンを設定。
*
* @param accessToken アクセストークン
* @return this
*/
DeleteRequestRequest& withAccessToken(StringHolder accessToken)
{
setAccessToken(std::move(accessToken));
return *this;
}
/**
* ネームスペース名を取得
*
* @return ネームスペース名
*/
const optional<StringHolder>& getNamespaceName() const
{
return ensureData().namespaceName;
}
/**
* ネームスペース名を設定
*
* @param namespaceName ネームスペース名
*/
void setNamespaceName(StringHolder namespaceName)
{
ensureData().namespaceName.emplace(std::move(namespaceName));
}
/**
* ネームスペース名を設定
*
* @param namespaceName ネームスペース名
*/
DeleteRequestRequest& withNamespaceName(StringHolder namespaceName)
{
ensureData().namespaceName.emplace(std::move(namespaceName));
return *this;
}
/**
* リクエストの送信先ユーザIDを取得
*
* @return リクエストの送信先ユーザID
*/
const optional<StringHolder>& getTargetUserId() const
{
return ensureData().targetUserId;
}
/**
* リクエストの送信先ユーザIDを設定
*
* @param targetUserId リクエストの送信先ユーザID
*/
void setTargetUserId(StringHolder targetUserId)
{
ensureData().targetUserId.emplace(std::move(targetUserId));
}
/**
* リクエストの送信先ユーザIDを設定
*
* @param targetUserId リクエストの送信先ユーザID
*/
DeleteRequestRequest& withTargetUserId(StringHolder targetUserId)
{
ensureData().targetUserId.emplace(std::move(targetUserId));
return *this;
}
/**
* 重複実行回避機能に使用するIDを取得
*
* @return 重複実行回避機能に使用するID
*/
const optional<StringHolder>& getDuplicationAvoider() const
{
return ensureData().duplicationAvoider;
}
/**
* 重複実行回避機能に使用するIDを設定
*
* @param duplicationAvoider 重複実行回避機能に使用するID
*/
void setDuplicationAvoider(StringHolder duplicationAvoider)
{
ensureData().duplicationAvoider.emplace(std::move(duplicationAvoider));
}
/**
* 重複実行回避機能に使用するIDを設定
*
* @param duplicationAvoider 重複実行回避機能に使用するID
*/
DeleteRequestRequest& withDuplicationAvoider(StringHolder duplicationAvoider)
{
ensureData().duplicationAvoider.emplace(std::move(duplicationAvoider));
return *this;
}
/**
* GS2認証クライアントIDを設定。
* 通常は自動的に計算されるため、この値を設定する必要はありません。
*
* @param gs2ClientId GS2認証クライアントID
*/
DeleteRequestRequest& withGs2ClientId(StringHolder gs2ClientId)
{
setGs2ClientId(std::move(gs2ClientId));
return *this;
}
/**
* GS2リクエストIDを設定。
*
* @param gs2RequestId GS2リクエストID
*/
DeleteRequestRequest& withRequestId(StringHolder gs2RequestId)
{
setRequestId(std::move(gs2RequestId));
return *this;
}
};
} }
#endif //GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_ | [
"imatake_haruhiko@gs2.io"
] | imatake_haruhiko@gs2.io |
cf814477135e44a59c2b547267942184882c351c | 9819d9ef8fd274cc17e50dd1a5295f0b05cb6dce | /source/gui/noname.cpp | 01c14cd12bd511b3fb9b06e4e02af3594fe6e37a | [] | no_license | geekgg20/XssDetect | 1ffa77724d637367da536d2e37d86661e81148be | 5ebeb2c5429fb72cb4c813e27c0e8bd92fce20ff | refs/heads/master | 2020-09-24T13:27:01.527228 | 2016-06-07T09:37:52 | 2016-06-07T09:37:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 30,665 | cpp | ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "noname.h"
///////////////////////////////////////////////////////////////////////////
XssDetectFrame::XssDetectFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* main_bSizer;
main_bSizer = new wxBoxSizer( wxVERTICAL );
logo_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* logo_bSizer;
logo_bSizer = new wxBoxSizer( wxVERTICAL );
logo_bitmap = new wxStaticBitmap( logo_panel, wxID_ANY, wxBitmap( wxT("images/logo.jpg"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
logo_bSizer->Add( logo_bitmap, 2, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
logo_panel->SetSizer( logo_bSizer );
logo_panel->Layout();
logo_bSizer->Fit( logo_panel );
main_bSizer->Add( logo_panel, 3, wxEXPAND | wxALL, 5 );
m_notebook4 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
setting_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_bSizer;
setting_bSizer = new wxBoxSizer( wxVERTICAL );
thread_ctrl_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxStaticBoxSizer* thread_ctrl_sbSizer;
thread_ctrl_sbSizer = new wxStaticBoxSizer( new wxStaticBox( thread_ctrl_panel, wxID_ANY, wxT("系统线程设置") ), wxHORIZONTAL );
spider_thread_num_staticText = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("爬虫线程数量(0~100):"), wxDefaultPosition, wxDefaultSize, 0 );
spider_thread_num_staticText->Wrap( -1 );
thread_ctrl_sbSizer->Add( spider_thread_num_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
spider_thread_num_slider = new wxSlider( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, 10, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
thread_ctrl_sbSizer->Add( spider_thread_num_slider, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText_spider_unit = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("10"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText_spider_unit->Wrap( -1 );
thread_ctrl_sbSizer->Add( m_staticText_spider_unit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText_space = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxT("df") );
m_staticText_space->Wrap( -1 );
thread_ctrl_sbSizer->Add( m_staticText_space, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
check_thread_num_staticText = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("检测线程数量(0~100):"), wxDefaultPosition, wxDefaultSize, 0 );
check_thread_num_staticText->Wrap( -1 );
thread_ctrl_sbSizer->Add( check_thread_num_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
check_thread_num_slider = new wxSlider( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, 10, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
thread_ctrl_sbSizer->Add( check_thread_num_slider, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText_check_unit = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("10"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText_check_unit->Wrap( -1 );
thread_ctrl_sbSizer->Add( m_staticText_check_unit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
thread_ctrl_panel->SetSizer( thread_ctrl_sbSizer );
thread_ctrl_panel->Layout();
thread_ctrl_sbSizer->Fit( thread_ctrl_panel );
setting_bSizer->Add( thread_ctrl_panel, 1, wxEXPAND | wxALL, 5 );
setting_login_info_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxStaticBoxSizer* setting_login_info_sbSizer;
setting_login_info_sbSizer = new wxStaticBoxSizer( new wxStaticBox( setting_login_info_panel, wxID_ANY, wxT("HTTP授权信息") ), wxVERTICAL );
setting_cookie_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_cookie_bSizer;
setting_cookie_bSizer = new wxBoxSizer( wxHORIZONTAL );
login_url_staticText = new wxStaticText( setting_cookie_panel, wxID_ANY, wxT("登录链接:"), wxDefaultPosition, wxDefaultSize, 0 );
login_url_staticText->Wrap( -1 );
setting_cookie_bSizer->Add( login_url_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
login_url_textCtrl = new wxTextCtrl( setting_cookie_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_cookie_bSizer->Add( login_url_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
cookie_staticText = new wxStaticText( setting_cookie_panel, wxID_ANY, wxT("Cookie:"), wxDefaultPosition, wxDefaultSize, 0 );
cookie_staticText->Wrap( -1 );
setting_cookie_bSizer->Add( cookie_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
cookie_textCtrl = new wxTextCtrl( setting_cookie_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_cookie_bSizer->Add( cookie_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
setting_cookie_panel->SetSizer( setting_cookie_bSizer );
setting_cookie_panel->Layout();
setting_cookie_bSizer->Fit( setting_cookie_panel );
setting_login_info_sbSizer->Add( setting_cookie_panel, 1, wxEXPAND | wxALL, 5 );
setting_username_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_username_bSizer;
setting_username_bSizer = new wxBoxSizer( wxHORIZONTAL );
username_key_staticText = new wxStaticText( setting_username_panel, wxID_ANY, wxT("username key:"), wxDefaultPosition, wxDefaultSize, 0 );
username_key_staticText->Wrap( -1 );
setting_username_bSizer->Add( username_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
username_key_textCtrl = new wxTextCtrl( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer->Add( username_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
username_value_staticText1 = new wxStaticText( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
username_value_staticText1->Wrap( -1 );
setting_username_bSizer->Add( username_value_staticText1, 1, wxALL, 5 );
username_value_staticText = new wxStaticText( setting_username_panel, wxID_ANY, wxT("username value:"), wxDefaultPosition, wxDefaultSize, 0 );
username_value_staticText->Wrap( -1 );
setting_username_bSizer->Add( username_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
username_value_textCtr = new wxTextCtrl( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer->Add( username_value_textCtr, 3, wxALL, 5 );
setting_username_panel->SetSizer( setting_username_bSizer );
setting_username_panel->Layout();
setting_username_bSizer->Fit( setting_username_panel );
setting_login_info_sbSizer->Add( setting_username_panel, 1, wxEXPAND | wxALL, 5 );
setting_password_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_username_bSizer1;
setting_username_bSizer1 = new wxBoxSizer( wxHORIZONTAL );
password_key_staticText = new wxStaticText( setting_password_panel, wxID_ANY, wxT("password key:"), wxDefaultPosition, wxDefaultSize, 0 );
password_key_staticText->Wrap( -1 );
setting_username_bSizer1->Add( password_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
password_key_textCtrl = new wxTextCtrl( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer1->Add( password_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
username_value_staticText11 = new wxStaticText( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
username_value_staticText11->Wrap( -1 );
setting_username_bSizer1->Add( username_value_staticText11, 1, wxALL, 5 );
password_value_staticText = new wxStaticText( setting_password_panel, wxID_ANY, wxT("password value:"), wxDefaultPosition, wxDefaultSize, 0 );
password_value_staticText->Wrap( -1 );
setting_username_bSizer1->Add( password_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
password_value_textCtr = new wxTextCtrl( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer1->Add( password_value_textCtr, 3, wxALL, 5 );
setting_password_panel->SetSizer( setting_username_bSizer1 );
setting_password_panel->Layout();
setting_username_bSizer1->Fit( setting_password_panel );
setting_login_info_sbSizer->Add( setting_password_panel, 1, wxEXPAND | wxALL, 5 );
setting_vercode_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_username_bSizer11;
setting_username_bSizer11 = new wxBoxSizer( wxHORIZONTAL );
vercode_key_staticText = new wxStaticText( setting_vercode_panel, wxID_ANY, wxT("vercode key:"), wxDefaultPosition, wxDefaultSize, 0 );
vercode_key_staticText->Wrap( -1 );
setting_username_bSizer11->Add( vercode_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
vercode_key_textCtrl = new wxTextCtrl( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer11->Add( vercode_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
username_value_staticText111 = new wxStaticText( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
username_value_staticText111->Wrap( -1 );
setting_username_bSizer11->Add( username_value_staticText111, 1, wxALL, 5 );
vercode_value_staticText = new wxStaticText( setting_vercode_panel, wxID_ANY, wxT("vercode value:"), wxDefaultPosition, wxDefaultSize, 0 );
vercode_value_staticText->Wrap( -1 );
setting_username_bSizer11->Add( vercode_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
vercode_value_textCtr = new wxTextCtrl( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
setting_username_bSizer11->Add( vercode_value_textCtr, 3, wxALL, 5 );
setting_vercode_panel->SetSizer( setting_username_bSizer11 );
setting_vercode_panel->Layout();
setting_username_bSizer11->Fit( setting_vercode_panel );
setting_login_info_sbSizer->Add( setting_vercode_panel, 1, wxEXPAND | wxALL, 5 );
setting_login_info_ctrl_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* settinglogin_bSizer;
settinglogin_bSizer = new wxBoxSizer( wxHORIZONTAL );
vercode_staticText = new wxStaticText( setting_login_info_ctrl_panel, wxID_ANY, wxT("验证码链接:"), wxDefaultPosition, wxDefaultSize, 0 );
vercode_staticText->Wrap( -1 );
settinglogin_bSizer->Add( vercode_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
vercode_textCtrl = new wxTextCtrl( setting_login_info_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
settinglogin_bSizer->Add( vercode_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
vercode_bitmap = new wxStaticBitmap( setting_login_info_ctrl_panel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
settinglogin_bSizer->Add( vercode_bitmap, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
get_vercode_button = new wxButton( setting_login_info_ctrl_panel, wxID_ANY, wxT("获取验证码"), wxDefaultPosition, wxDefaultSize, 0 );
settinglogin_bSizer->Add( get_vercode_button, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
login_button = new wxButton( setting_login_info_ctrl_panel, wxID_ANY, wxT("登录"), wxDefaultPosition, wxDefaultSize, 0 );
settinglogin_bSizer->Add( login_button, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
setting_login_info_ctrl_panel->SetSizer( settinglogin_bSizer );
setting_login_info_ctrl_panel->Layout();
settinglogin_bSizer->Fit( setting_login_info_ctrl_panel );
setting_login_info_sbSizer->Add( setting_login_info_ctrl_panel, 1, wxEXPAND | wxALL, 5 );
setting_login_info_panel->SetSizer( setting_login_info_sbSizer );
setting_login_info_panel->Layout();
setting_login_info_sbSizer->Fit( setting_login_info_panel );
setting_bSizer->Add( setting_login_info_panel, 5, wxEXPAND | wxALL, 5 );
setting_payload_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxStaticBoxSizer* setting_payload_sbSizer;
setting_payload_sbSizer = new wxStaticBoxSizer( new wxStaticBox( setting_payload_panel, wxID_ANY, wxT("自定义信息") ), wxHORIZONTAL );
setting_payload_text_panel = new wxPanel( setting_payload_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* setting_payload_text_bSizer;
setting_payload_text_bSizer = new wxBoxSizer( wxVERTICAL );
payload_text_panel = new wxPanel( setting_payload_text_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* payload_text_bSizer;
payload_text_bSizer = new wxBoxSizer( wxVERTICAL );
payload_staticText = new wxStaticText( payload_text_panel, wxID_ANY, wxT("自定义向量:"), wxDefaultPosition, wxDefaultSize, 0 );
payload_staticText->Wrap( -1 );
payload_text_bSizer->Add( payload_staticText, 0, wxALL, 5 );
payload_textCtrl = new wxTextCtrl( payload_text_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
payload_text_bSizer->Add( payload_textCtrl, 1, wxALL|wxEXPAND, 5 );
payload_text_panel->SetSizer( payload_text_bSizer );
payload_text_panel->Layout();
payload_text_bSizer->Fit( payload_text_panel );
setting_payload_text_bSizer->Add( payload_text_panel, 3, wxEXPAND | wxALL, 5 );
exclude_url_panel = new wxPanel( setting_payload_text_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* exclude_url_bSizer;
exclude_url_bSizer = new wxBoxSizer( wxHORIZONTAL );
exclude_url_staticText = new wxStaticText( exclude_url_panel, wxID_ANY, wxT("排除的URL:"), wxDefaultPosition, wxDefaultSize, 0 );
exclude_url_staticText->Wrap( -1 );
exclude_url_bSizer->Add( exclude_url_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
exclude_url_textCtrl = new wxTextCtrl( exclude_url_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
exclude_url_bSizer->Add( exclude_url_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
exclude_url_panel->SetSizer( exclude_url_bSizer );
exclude_url_panel->Layout();
exclude_url_bSizer->Fit( exclude_url_panel );
setting_payload_text_bSizer->Add( exclude_url_panel, 1, wxEXPAND | wxALL, 5 );
setting_payload_text_panel->SetSizer( setting_payload_text_bSizer );
setting_payload_text_panel->Layout();
setting_payload_text_bSizer->Fit( setting_payload_text_panel );
setting_payload_sbSizer->Add( setting_payload_text_panel, 3, wxEXPAND | wxALL, 5 );
save_info_panel = new wxPanel( setting_payload_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* save_info_bSizer;
save_info_bSizer = new wxBoxSizer( wxVERTICAL );
save_info_staticText = new wxStaticText( save_info_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
save_info_staticText->Wrap( -1 );
save_info_bSizer->Add( save_info_staticText, 1, wxALL, 5 );
save_payload_button = new wxButton( save_info_panel, wxID_ANY, wxT("添加PAYLOAD"), wxDefaultPosition, wxDefaultSize, 0 );
save_info_bSizer->Add( save_payload_button, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
save_info_staticText1 = new wxStaticText( save_info_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
save_info_staticText1->Wrap( -1 );
save_info_bSizer->Add( save_info_staticText1, 1, wxALL, 5 );
m_button6 = new wxButton( save_info_panel, wxID_ANY, wxT("保存系统设置"), wxDefaultPosition, wxDefaultSize, 0 );
save_info_bSizer->Add( m_button6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
save_info_panel->SetSizer( save_info_bSizer );
save_info_panel->Layout();
save_info_bSizer->Fit( save_info_panel );
setting_payload_sbSizer->Add( save_info_panel, 1, wxEXPAND | wxALL, 5 );
setting_payload_panel->SetSizer( setting_payload_sbSizer );
setting_payload_panel->Layout();
setting_payload_sbSizer->Fit( setting_payload_panel );
setting_bSizer->Add( setting_payload_panel, 3, wxEXPAND | wxALL, 5 );
setting_panel->SetSizer( setting_bSizer );
setting_panel->Layout();
setting_bSizer->Fit( setting_panel );
m_notebook4->AddPage( setting_panel, wxT("系统设置"), false );
spider_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* spider_bSizer;
spider_bSizer = new wxBoxSizer( wxVERTICAL );
spider_ctrl_panel = new wxPanel( spider_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* spider_ctrl_bSizer;
spider_ctrl_bSizer = new wxBoxSizer( wxHORIZONTAL );
seed_url_label = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxT("种子连接:"), wxDefaultPosition, wxDefaultSize, 0 );
seed_url_label->Wrap( -1 );
spider_ctrl_bSizer->Add( seed_url_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
seed_url_text = new wxTextCtrl( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
spider_ctrl_bSizer->Add( seed_url_text, 7, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText29 = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_staticText29->Wrap( -1 );
spider_ctrl_bSizer->Add( m_staticText29, 1, wxALL, 5 );
crawl_depth_staticText = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxT("爬取深度:"), wxDefaultPosition, wxDefaultSize, 0 );
crawl_depth_staticText->Wrap( -1 );
spider_ctrl_bSizer->Add( crawl_depth_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
crawl_depth_textCtrl = new wxTextCtrl( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
spider_ctrl_bSizer->Add( crawl_depth_textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
start_crawling_button = new wxButton( spider_ctrl_panel, wxID_ANY, wxT("开始爬取"), wxDefaultPosition, wxDefaultSize, 0 );
spider_ctrl_bSizer->Add( start_crawling_button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
spider_ctrl_panel->SetSizer( spider_ctrl_bSizer );
spider_ctrl_panel->Layout();
spider_ctrl_bSizer->Fit( spider_ctrl_panel );
spider_bSizer->Add( spider_ctrl_panel, 1, wxALL|wxEXPAND, 5 );
spider_show_panel = new wxPanel( spider_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* spider_grid_bSizer;
spider_grid_bSizer = new wxBoxSizer( wxVERTICAL );
spider_grid = new wxGrid( spider_show_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
spider_grid->CreateGrid( 10, 4 );
spider_grid->EnableEditing( true );
spider_grid->EnableGridLines( true );
spider_grid->EnableDragGridSize( false );
spider_grid->SetMargins( 0, 0 );
// Columns
spider_grid->SetColSize( 0, 64 );
spider_grid->SetColSize( 1, 446 );
spider_grid->SetColSize( 2, 80 );
spider_grid->SetColSize( 3, 78 );
spider_grid->EnableDragColMove( false );
spider_grid->EnableDragColSize( true );
spider_grid->SetColLabelSize( 30 );
spider_grid->SetColLabelValue( 0, wxT("线程名") );
spider_grid->SetColLabelValue( 1, wxT("URL") );
spider_grid->SetColLabelValue( 2, wxT("请求类型") );
spider_grid->SetColLabelValue( 3, wxT("深度") );
spider_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
spider_grid->EnableDragRowSize( true );
spider_grid->SetRowLabelSize( 80 );
spider_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
spider_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
spider_grid_bSizer->Add( spider_grid, 1, wxALL|wxEXPAND, 5 );
spider_show_panel->SetSizer( spider_grid_bSizer );
spider_show_panel->Layout();
spider_grid_bSizer->Fit( spider_show_panel );
spider_bSizer->Add( spider_show_panel, 6, wxEXPAND | wxALL, 5 );
spider_panel->SetSizer( spider_bSizer );
spider_panel->Layout();
spider_bSizer->Fit( spider_panel );
m_notebook4->AddPage( spider_panel, wxT("网络爬虫"), false );
check_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* check_bSizer;
check_bSizer = new wxBoxSizer( wxVERTICAL );
check_ctrl_panel = new wxPanel( check_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* reflected_check_bSizer;
reflected_check_bSizer = new wxBoxSizer( wxHORIZONTAL );
reflect_check_staticText = new wxStaticText( check_ctrl_panel, wxID_ANY, wxT("反射型XSS检测:"), wxDefaultPosition, wxDefaultSize, 0 );
reflect_check_staticText->Wrap( -1 );
reflected_check_bSizer->Add( reflect_check_staticText, 0, wxALL, 5 );
reflect_checking_url = new wxStaticText( check_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
reflect_checking_url->Wrap( -1 );
reflected_check_bSizer->Add( reflect_checking_url, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
start_check_button = new wxButton( check_ctrl_panel, wxID_ANY, wxT("开始检测"), wxDefaultPosition, wxDefaultSize, 0 );
reflected_check_bSizer->Add( start_check_button, 0, wxALL, 5 );
check_ctrl_panel->SetSizer( reflected_check_bSizer );
check_ctrl_panel->Layout();
reflected_check_bSizer->Fit( check_ctrl_panel );
check_bSizer->Add( check_ctrl_panel, 1, wxEXPAND | wxALL, 5 );
check_show_panel = new wxPanel( check_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* check_show_bSizer;
check_show_bSizer = new wxBoxSizer( wxVERTICAL );
check_grid = new wxGrid( check_show_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
check_grid->CreateGrid( 10, 3 );
check_grid->EnableEditing( false );
check_grid->EnableGridLines( true );
check_grid->EnableDragGridSize( false );
check_grid->SetMargins( 0, 0 );
// Columns
check_grid->SetColSize( 0, 80 );
check_grid->SetColSize( 1, 422 );
check_grid->SetColSize( 2, 163 );
check_grid->EnableDragColMove( false );
check_grid->EnableDragColSize( true );
check_grid->SetColLabelSize( 30 );
check_grid->SetColLabelValue( 0, wxT("XSS漏洞类型") );
check_grid->SetColLabelValue( 1, wxT("存在漏洞的URL") );
check_grid->SetColLabelValue( 2, wxT("PAYLOAD") );
check_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
check_grid->EnableDragRowSize( true );
check_grid->SetRowLabelSize( 80 );
check_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
check_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
check_show_bSizer->Add( check_grid, 1, wxALL|wxEXPAND, 5 );
check_show_panel->SetSizer( check_show_bSizer );
check_show_panel->Layout();
check_show_bSizer->Fit( check_show_panel );
check_bSizer->Add( check_show_panel, 4, wxEXPAND | wxALL, 5 );
check_panel->SetSizer( check_bSizer );
check_panel->Layout();
check_bSizer->Fit( check_panel );
m_notebook4->AddPage( check_panel, wxT("XSS 检测"), true );
main_bSizer->Add( m_notebook4, 3, wxEXPAND | wxALL, 5 );
this->SetSizer( main_bSizer );
this->Layout();
statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
this->Centre( wxBOTH );
// Connect Events
spider_thread_num_slider->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
get_vercode_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnGetVercodeButtonClick ), NULL, this );
login_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnLoginButtonClick ), NULL, this );
save_payload_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSavePayloadButtonClick ), NULL, this );
m_button6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSaveSettingInfoButtonClick ), NULL, this );
start_crawling_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCrawlingButtonClick ), NULL, this );
start_check_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCheckButtonClick ), NULL, this );
}
XssDetectFrame::~XssDetectFrame()
{
// Disconnect Events
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
spider_thread_num_slider->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
check_thread_num_slider->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this );
get_vercode_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnGetVercodeButtonClick ), NULL, this );
login_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnLoginButtonClick ), NULL, this );
save_payload_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSavePayloadButtonClick ), NULL, this );
m_button6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSaveSettingInfoButtonClick ), NULL, this );
start_crawling_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCrawlingButtonClick ), NULL, this );
start_check_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCheckButtonClick ), NULL, this );
}
| [
"mguichun@foxmail.com"
] | mguichun@foxmail.com |
9fc4f0f296871ee70a577591acd2214f25645058 | 757a5c0ad5dace24855fdd523019ed3fbb3ca9ce | /3rdparty/spirv-tools/source/opt/debug_info_manager.cpp | 6593c3fbded1c5aaea4a77f0413c583f21c05cc0 | [
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | VirtualGeo/bgfx | 1631f59596c4db9099f8ac7c15d5496fa412f6a8 | f2fe00958b07a99403f6cab0b4da8b6ad4bc7d31 | refs/heads/master | 2023-08-24T11:06:30.571411 | 2021-10-15T11:12:48 | 2021-10-15T11:12:48 | 250,211,166 | 0 | 1 | BSD-2-Clause | 2021-09-14T08:50:03 | 2020-03-26T09:13:31 | C++ | UTF-8 | C++ | false | false | 35,895 | cpp | // Copyright (c) 2020 Google LLC
//
// 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 "source/opt/debug_info_manager.h"
#include <cassert>
#include "source/opt/ir_context.h"
// Constants for OpenCL.DebugInfo.100 & NonSemantic.Shader.DebugInfo.100
// extension instructions.
static const uint32_t kOpLineOperandLineIndex = 1;
static const uint32_t kLineOperandIndexDebugFunction = 7;
static const uint32_t kLineOperandIndexDebugLexicalBlock = 5;
static const uint32_t kDebugFunctionOperandFunctionIndex = 13;
static const uint32_t kDebugFunctionDefinitionOperandDebugFunctionIndex = 4;
static const uint32_t kDebugFunctionDefinitionOperandOpFunctionIndex = 5;
static const uint32_t kDebugFunctionOperandParentIndex = 9;
static const uint32_t kDebugTypeCompositeOperandParentIndex = 9;
static const uint32_t kDebugLexicalBlockOperandParentIndex = 7;
static const uint32_t kDebugInlinedAtOperandInlinedIndex = 6;
static const uint32_t kDebugExpressOperandOperationIndex = 4;
static const uint32_t kDebugDeclareOperandLocalVariableIndex = 4;
static const uint32_t kDebugDeclareOperandVariableIndex = 5;
static const uint32_t kDebugValueOperandExpressionIndex = 6;
static const uint32_t kDebugOperationOperandOperationIndex = 4;
static const uint32_t kOpVariableOperandStorageClassIndex = 2;
static const uint32_t kDebugLocalVariableOperandParentIndex = 9;
static const uint32_t kExtInstInstructionInIdx = 1;
static const uint32_t kDebugGlobalVariableOperandFlagsIndex = 12;
static const uint32_t kDebugLocalVariableOperandFlagsIndex = 10;
namespace spvtools {
namespace opt {
namespace analysis {
namespace {
void SetInlinedOperand(Instruction* dbg_inlined_at, uint32_t inlined_operand) {
assert(dbg_inlined_at);
assert(dbg_inlined_at->GetCommonDebugOpcode() ==
CommonDebugInfoDebugInlinedAt);
if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex) {
dbg_inlined_at->AddOperand(
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {inlined_operand}});
} else {
dbg_inlined_at->SetOperand(kDebugInlinedAtOperandInlinedIndex,
{inlined_operand});
}
}
uint32_t GetInlinedOperand(Instruction* dbg_inlined_at) {
assert(dbg_inlined_at);
assert(dbg_inlined_at->GetCommonDebugOpcode() ==
CommonDebugInfoDebugInlinedAt);
if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex)
return kNoInlinedAt;
return dbg_inlined_at->GetSingleWordOperand(
kDebugInlinedAtOperandInlinedIndex);
}
bool IsEmptyDebugExpression(Instruction* instr) {
return (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression) &&
instr->NumOperands() == kDebugExpressOperandOperationIndex;
}
} // namespace
DebugInfoManager::DebugInfoManager(IRContext* c) : context_(c) {
AnalyzeDebugInsts(*c->module());
}
uint32_t DebugInfoManager::GetDbgSetImportId() {
uint32_t setId =
context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo();
if (setId == 0) {
setId =
context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo();
}
return setId;
}
Instruction* DebugInfoManager::GetDbgInst(uint32_t id) {
auto dbg_inst_it = id_to_dbg_inst_.find(id);
return dbg_inst_it == id_to_dbg_inst_.end() ? nullptr : dbg_inst_it->second;
}
void DebugInfoManager::RegisterDbgInst(Instruction* inst) {
assert(inst->NumInOperands() != 0 &&
(GetDbgSetImportId() == inst->GetInOperand(0).words[0]) &&
"Given instruction is not a debug instruction");
id_to_dbg_inst_[inst->result_id()] = inst;
}
void DebugInfoManager::RegisterDbgFunction(Instruction* inst) {
if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) {
auto fn_id = inst->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex);
// Do not register function that has been optimized away.
auto fn_inst = GetDbgInst(fn_id);
if (fn_inst != nullptr) {
assert(GetDbgInst(fn_id)->GetOpenCL100DebugOpcode() ==
OpenCLDebugInfo100DebugInfoNone);
return;
}
assert(
fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
"Register DebugFunction for a function that already has DebugFunction");
fn_id_to_dbg_fn_[fn_id] = inst;
} else if (inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
auto fn_id = inst->GetSingleWordOperand(
kDebugFunctionDefinitionOperandOpFunctionIndex);
auto fn_inst = GetDbgInst(inst->GetSingleWordOperand(
kDebugFunctionDefinitionOperandDebugFunctionIndex));
assert(fn_inst && fn_inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunction);
assert(fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
"Register DebugFunctionDefinition for a function that already has "
"DebugFunctionDefinition");
fn_id_to_dbg_fn_[fn_id] = fn_inst;
} else {
assert(false && "inst is not a DebugFunction");
}
}
void DebugInfoManager::RegisterDbgDeclare(uint32_t var_id,
Instruction* dbg_declare) {
assert(dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugValue);
auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_id);
if (dbg_decl_itr == var_id_to_dbg_decl_.end()) {
var_id_to_dbg_decl_[var_id] = {dbg_declare};
} else {
dbg_decl_itr->second.insert(dbg_declare);
}
}
uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
const DebugScope& scope) {
uint32_t setId = GetDbgSetImportId();
if (setId == 0) return kNoInlinedAt;
spv_operand_type_t line_number_type =
spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER;
// In NonSemantic.Shader.DebugInfo.100, all constants are IDs of OpConstant,
// not literals.
if (setId ==
context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo())
line_number_type = spv_operand_type_t::SPV_OPERAND_TYPE_ID;
uint32_t line_number = 0;
if (line == nullptr) {
auto* lexical_scope_inst = GetDbgInst(scope.GetLexicalScope());
if (lexical_scope_inst == nullptr) return kNoInlinedAt;
CommonDebugInfoInstructions debug_opcode =
lexical_scope_inst->GetCommonDebugOpcode();
switch (debug_opcode) {
case CommonDebugInfoDebugFunction:
line_number = lexical_scope_inst->GetSingleWordOperand(
kLineOperandIndexDebugFunction);
break;
case CommonDebugInfoDebugLexicalBlock:
line_number = lexical_scope_inst->GetSingleWordOperand(
kLineOperandIndexDebugLexicalBlock);
break;
case CommonDebugInfoDebugTypeComposite:
case CommonDebugInfoDebugCompilationUnit:
assert(false &&
"DebugTypeComposite and DebugCompilationUnit are lexical "
"scopes, but we inline functions into a function or a block "
"of a function, not into a struct/class or a global scope.");
break;
default:
assert(false &&
"Unreachable. a debug extension instruction for a "
"lexical scope must be DebugFunction, DebugTypeComposite, "
"DebugLexicalBlock, or DebugCompilationUnit.");
break;
}
} else {
line_number = line->GetSingleWordOperand(kOpLineOperandLineIndex);
// If we need the line number as an ID, generate that constant now.
if (line_number_type == spv_operand_type_t::SPV_OPERAND_TYPE_ID) {
uint32_t line_id =
context()->get_constant_mgr()->GetUIntConst(line_number);
line_number = line_id;
}
}
uint32_t result_id = context()->TakeNextId();
std::unique_ptr<Instruction> inlined_at(new Instruction(
context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
result_id,
{
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {setId}},
{spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(CommonDebugInfoDebugInlinedAt)}},
{line_number_type, {line_number}},
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetLexicalScope()}},
}));
// |scope| already has DebugInlinedAt. We put the existing DebugInlinedAt
// into the Inlined operand of this new DebugInlinedAt.
if (scope.GetInlinedAt() != kNoInlinedAt) {
inlined_at->AddOperand(
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetInlinedAt()}});
}
RegisterDbgInst(inlined_at.get());
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(inlined_at.get());
context()->module()->AddExtInstDebugInfo(std::move(inlined_at));
return result_id;
}
DebugScope DebugInfoManager::BuildDebugScope(
const DebugScope& callee_instr_scope,
DebugInlinedAtContext* inlined_at_ctx) {
return DebugScope(callee_instr_scope.GetLexicalScope(),
BuildDebugInlinedAtChain(callee_instr_scope.GetInlinedAt(),
inlined_at_ctx));
}
uint32_t DebugInfoManager::BuildDebugInlinedAtChain(
uint32_t callee_inlined_at, DebugInlinedAtContext* inlined_at_ctx) {
if (inlined_at_ctx->GetScopeOfCallInstruction().GetLexicalScope() ==
kNoDebugScope)
return kNoInlinedAt;
// Reuse the already generated DebugInlinedAt chain if exists.
uint32_t already_generated_chain_head_id =
inlined_at_ctx->GetDebugInlinedAtChain(callee_inlined_at);
if (already_generated_chain_head_id != kNoInlinedAt) {
return already_generated_chain_head_id;
}
const uint32_t new_dbg_inlined_at_id =
CreateDebugInlinedAt(inlined_at_ctx->GetLineOfCallInstruction(),
inlined_at_ctx->GetScopeOfCallInstruction());
if (new_dbg_inlined_at_id == kNoInlinedAt) return kNoInlinedAt;
if (callee_inlined_at == kNoInlinedAt) {
inlined_at_ctx->SetDebugInlinedAtChain(kNoInlinedAt, new_dbg_inlined_at_id);
return new_dbg_inlined_at_id;
}
uint32_t chain_head_id = kNoInlinedAt;
uint32_t chain_iter_id = callee_inlined_at;
Instruction* last_inlined_at_in_chain = nullptr;
do {
Instruction* new_inlined_at_in_chain = CloneDebugInlinedAt(
chain_iter_id, /* insert_before */ last_inlined_at_in_chain);
assert(new_inlined_at_in_chain != nullptr);
// Set DebugInlinedAt of the new scope as the head of the chain.
if (chain_head_id == kNoInlinedAt)
chain_head_id = new_inlined_at_in_chain->result_id();
// Previous DebugInlinedAt of the chain must point to the new
// DebugInlinedAt as its Inlined operand to build a recursive
// chain.
if (last_inlined_at_in_chain != nullptr) {
SetInlinedOperand(last_inlined_at_in_chain,
new_inlined_at_in_chain->result_id());
}
last_inlined_at_in_chain = new_inlined_at_in_chain;
chain_iter_id = GetInlinedOperand(new_inlined_at_in_chain);
} while (chain_iter_id != kNoInlinedAt);
// Put |new_dbg_inlined_at_id| into the end of the chain.
SetInlinedOperand(last_inlined_at_in_chain, new_dbg_inlined_at_id);
// Keep the new chain information that will be reused it.
inlined_at_ctx->SetDebugInlinedAtChain(callee_inlined_at, chain_head_id);
return chain_head_id;
}
Instruction* DebugInfoManager::GetDebugOperationWithDeref() {
if (deref_operation_ != nullptr) return deref_operation_;
uint32_t result_id = context()->TakeNextId();
std::unique_ptr<Instruction> deref_operation;
if (context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo()) {
deref_operation = std::unique_ptr<Instruction>(new Instruction(
context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
result_id,
{
{SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(OpenCLDebugInfo100DebugOperation)}},
{SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION,
{static_cast<uint32_t>(OpenCLDebugInfo100Deref)}},
}));
} else {
uint32_t deref_id = context()->get_constant_mgr()->GetUIntConst(
NonSemanticShaderDebugInfo100Deref);
deref_operation = std::unique_ptr<Instruction>(
new Instruction(context(), SpvOpExtInst,
context()->get_type_mgr()->GetVoidTypeId(), result_id,
{
{SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(
NonSemanticShaderDebugInfo100DebugOperation)}},
{SPV_OPERAND_TYPE_ID, {deref_id}},
}));
}
// Add to the front of |ext_inst_debuginfo_|.
deref_operation_ =
context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
std::move(deref_operation));
RegisterDbgInst(deref_operation_);
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_operation_);
return deref_operation_;
}
Instruction* DebugInfoManager::DerefDebugExpression(Instruction* dbg_expr) {
assert(dbg_expr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression);
std::unique_ptr<Instruction> deref_expr(dbg_expr->Clone(context()));
deref_expr->SetResultId(context()->TakeNextId());
deref_expr->InsertOperand(
kDebugExpressOperandOperationIndex,
{SPV_OPERAND_TYPE_ID, {GetDebugOperationWithDeref()->result_id()}});
auto* deref_expr_instr =
context()->ext_inst_debuginfo_end()->InsertBefore(std::move(deref_expr));
AnalyzeDebugInst(deref_expr_instr);
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_expr_instr);
return deref_expr_instr;
}
Instruction* DebugInfoManager::GetDebugInfoNone() {
if (debug_info_none_inst_ != nullptr) return debug_info_none_inst_;
uint32_t result_id = context()->TakeNextId();
std::unique_ptr<Instruction> dbg_info_none_inst(new Instruction(
context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
result_id,
{
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(CommonDebugInfoDebugInfoNone)}},
}));
// Add to the front of |ext_inst_debuginfo_|.
debug_info_none_inst_ =
context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
std::move(dbg_info_none_inst));
RegisterDbgInst(debug_info_none_inst_);
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(debug_info_none_inst_);
return debug_info_none_inst_;
}
Instruction* DebugInfoManager::GetEmptyDebugExpression() {
if (empty_debug_expr_inst_ != nullptr) return empty_debug_expr_inst_;
uint32_t result_id = context()->TakeNextId();
std::unique_ptr<Instruction> empty_debug_expr(new Instruction(
context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
result_id,
{
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(CommonDebugInfoDebugExpression)}},
}));
// Add to the front of |ext_inst_debuginfo_|.
empty_debug_expr_inst_ =
context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
std::move(empty_debug_expr));
RegisterDbgInst(empty_debug_expr_inst_);
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(empty_debug_expr_inst_);
return empty_debug_expr_inst_;
}
Instruction* DebugInfoManager::GetDebugInlinedAt(uint32_t dbg_inlined_at_id) {
auto* inlined_at = GetDbgInst(dbg_inlined_at_id);
if (inlined_at == nullptr) return nullptr;
if (inlined_at->GetCommonDebugOpcode() != CommonDebugInfoDebugInlinedAt) {
return nullptr;
}
return inlined_at;
}
Instruction* DebugInfoManager::CloneDebugInlinedAt(uint32_t clone_inlined_at_id,
Instruction* insert_before) {
auto* inlined_at = GetDebugInlinedAt(clone_inlined_at_id);
if (inlined_at == nullptr) return nullptr;
std::unique_ptr<Instruction> new_inlined_at(inlined_at->Clone(context()));
new_inlined_at->SetResultId(context()->TakeNextId());
RegisterDbgInst(new_inlined_at.get());
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(new_inlined_at.get());
if (insert_before != nullptr)
return insert_before->InsertBefore(std::move(new_inlined_at));
return context()->module()->ext_inst_debuginfo_end()->InsertBefore(
std::move(new_inlined_at));
}
bool DebugInfoManager::IsVariableDebugDeclared(uint32_t variable_id) {
auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
return dbg_decl_itr != var_id_to_dbg_decl_.end();
}
bool DebugInfoManager::KillDebugDeclares(uint32_t variable_id) {
bool modified = false;
auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
if (dbg_decl_itr != var_id_to_dbg_decl_.end()) {
// We intentionally copy the list of DebugDeclare instructions because
// context()->KillInst(dbg_decl) will update |var_id_to_dbg_decl_|. If we
// directly use |dbg_decl_itr->second|, it accesses a dangling pointer.
auto copy_dbg_decls = dbg_decl_itr->second;
for (auto* dbg_decl : copy_dbg_decls) {
context()->KillInst(dbg_decl);
modified = true;
}
var_id_to_dbg_decl_.erase(dbg_decl_itr);
}
return modified;
}
uint32_t DebugInfoManager::GetParentScope(uint32_t child_scope) {
auto dbg_scope_itr = id_to_dbg_inst_.find(child_scope);
assert(dbg_scope_itr != id_to_dbg_inst_.end());
CommonDebugInfoInstructions debug_opcode =
dbg_scope_itr->second->GetCommonDebugOpcode();
uint32_t parent_scope = kNoDebugScope;
switch (debug_opcode) {
case CommonDebugInfoDebugFunction:
parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
kDebugFunctionOperandParentIndex);
break;
case CommonDebugInfoDebugLexicalBlock:
parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
kDebugLexicalBlockOperandParentIndex);
break;
case CommonDebugInfoDebugTypeComposite:
parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
kDebugTypeCompositeOperandParentIndex);
break;
case CommonDebugInfoDebugCompilationUnit:
// DebugCompilationUnit does not have a parent scope.
break;
default:
assert(false &&
"Unreachable. A debug scope instruction must be "
"DebugFunction, DebugTypeComposite, DebugLexicalBlock, "
"or DebugCompilationUnit.");
break;
}
return parent_scope;
}
bool DebugInfoManager::IsAncestorOfScope(uint32_t scope, uint32_t ancestor) {
uint32_t ancestor_scope_itr = scope;
while (ancestor_scope_itr != kNoDebugScope) {
if (ancestor == ancestor_scope_itr) return true;
ancestor_scope_itr = GetParentScope(ancestor_scope_itr);
}
return false;
}
bool DebugInfoManager::IsDeclareVisibleToInstr(Instruction* dbg_declare,
Instruction* scope) {
assert(dbg_declare != nullptr);
assert(scope != nullptr);
std::vector<uint32_t> scope_ids;
if (scope->opcode() == SpvOpPhi) {
scope_ids.push_back(scope->GetDebugScope().GetLexicalScope());
for (uint32_t i = 0; i < scope->NumInOperands(); i += 2) {
auto* value = context()->get_def_use_mgr()->GetDef(
scope->GetSingleWordInOperand(i));
if (value != nullptr)
scope_ids.push_back(value->GetDebugScope().GetLexicalScope());
}
} else {
scope_ids.push_back(scope->GetDebugScope().GetLexicalScope());
}
uint32_t dbg_local_var_id =
dbg_declare->GetSingleWordOperand(kDebugDeclareOperandLocalVariableIndex);
auto dbg_local_var_itr = id_to_dbg_inst_.find(dbg_local_var_id);
assert(dbg_local_var_itr != id_to_dbg_inst_.end());
uint32_t decl_scope_id = dbg_local_var_itr->second->GetSingleWordOperand(
kDebugLocalVariableOperandParentIndex);
// If the scope of DebugDeclare is an ancestor scope of the instruction's
// scope, the local variable is visible to the instruction.
for (uint32_t scope_id : scope_ids) {
if (scope_id != kNoDebugScope &&
IsAncestorOfScope(scope_id, decl_scope_id)) {
return true;
}
}
return false;
}
bool DebugInfoManager::AddDebugValueIfVarDeclIsVisible(
Instruction* scope_and_line, uint32_t variable_id, uint32_t value_id,
Instruction* insert_pos,
std::unordered_set<Instruction*>* invisible_decls) {
assert(scope_and_line != nullptr);
auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
if (dbg_decl_itr == var_id_to_dbg_decl_.end()) return false;
bool modified = false;
for (auto* dbg_decl_or_val : dbg_decl_itr->second) {
if (!IsDeclareVisibleToInstr(dbg_decl_or_val, scope_and_line)) {
if (invisible_decls) invisible_decls->insert(dbg_decl_or_val);
continue;
}
// Avoid inserting the new DebugValue between OpPhi or OpVariable
// instructions.
Instruction* insert_before = insert_pos->NextNode();
while (insert_before->opcode() == SpvOpPhi ||
insert_before->opcode() == SpvOpVariable) {
insert_before = insert_before->NextNode();
}
modified |= AddDebugValueForDecl(dbg_decl_or_val, value_id, insert_before,
scope_and_line) != nullptr;
}
return modified;
}
Instruction* DebugInfoManager::AddDebugValueForDecl(
Instruction* dbg_decl, uint32_t value_id, Instruction* insert_before,
Instruction* scope_and_line) {
if (dbg_decl == nullptr || !IsDebugDeclare(dbg_decl)) return nullptr;
std::unique_ptr<Instruction> dbg_val(dbg_decl->Clone(context()));
dbg_val->SetResultId(context()->TakeNextId());
dbg_val->SetInOperand(kExtInstInstructionInIdx, {CommonDebugInfoDebugValue});
dbg_val->SetOperand(kDebugDeclareOperandVariableIndex, {value_id});
dbg_val->SetOperand(kDebugValueOperandExpressionIndex,
{GetEmptyDebugExpression()->result_id()});
dbg_val->UpdateDebugInfoFrom(scope_and_line);
auto* added_dbg_val = insert_before->InsertBefore(std::move(dbg_val));
AnalyzeDebugInst(added_dbg_val);
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_val);
if (context()->AreAnalysesValid(
IRContext::Analysis::kAnalysisInstrToBlockMapping)) {
auto insert_blk = context()->get_instr_block(insert_before);
context()->set_instr_block(added_dbg_val, insert_blk);
}
return added_dbg_val;
}
uint32_t DebugInfoManager::GetVulkanDebugOperation(Instruction* inst) {
assert(inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation &&
"inst must be Vulkan DebugOperation");
return context()
->get_constant_mgr()
->GetConstantFromInst(context()->get_def_use_mgr()->GetDef(
inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex)))
->GetU32();
}
uint32_t DebugInfoManager::GetVariableIdOfDebugValueUsedForDeclare(
Instruction* inst) {
if (inst->GetCommonDebugOpcode() != CommonDebugInfoDebugValue) return 0;
auto* expr =
GetDbgInst(inst->GetSingleWordOperand(kDebugValueOperandExpressionIndex));
if (expr == nullptr) return 0;
if (expr->NumOperands() != kDebugExpressOperandOperationIndex + 1) return 0;
auto* operation = GetDbgInst(
expr->GetSingleWordOperand(kDebugExpressOperandOperationIndex));
if (operation == nullptr) return 0;
// OpenCL.DebugInfo.100 contains a literal for the operation, Vulkan uses an
// OpConstant.
if (inst->IsOpenCL100DebugInstr()) {
if (operation->GetSingleWordOperand(kDebugOperationOperandOperationIndex) !=
OpenCLDebugInfo100Deref) {
return 0;
}
} else {
uint32_t operation_const = GetVulkanDebugOperation(operation);
if (operation_const != NonSemanticShaderDebugInfo100Deref) {
return 0;
}
}
uint32_t var_id =
inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
if (!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) {
assert(false &&
"Checking a DebugValue can be used for declare needs DefUseManager");
return 0;
}
auto* var = context()->get_def_use_mgr()->GetDef(var_id);
if (var->opcode() == SpvOpVariable &&
SpvStorageClass(var->GetSingleWordOperand(
kOpVariableOperandStorageClassIndex)) == SpvStorageClassFunction) {
return var_id;
}
return 0;
}
bool DebugInfoManager::IsDebugDeclare(Instruction* instr) {
if (!instr->IsCommonDebugInstr()) return false;
return instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
GetVariableIdOfDebugValueUsedForDeclare(instr) != 0;
}
void DebugInfoManager::ReplaceAllUsesInDebugScopeWithPredicate(
uint32_t before, uint32_t after,
const std::function<bool(Instruction*)>& predicate) {
auto scope_id_to_users_itr = scope_id_to_users_.find(before);
if (scope_id_to_users_itr != scope_id_to_users_.end()) {
for (Instruction* inst : scope_id_to_users_itr->second) {
if (predicate(inst)) inst->UpdateLexicalScope(after);
}
scope_id_to_users_[after] = scope_id_to_users_itr->second;
scope_id_to_users_.erase(scope_id_to_users_itr);
}
auto inlinedat_id_to_users_itr = inlinedat_id_to_users_.find(before);
if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
for (Instruction* inst : inlinedat_id_to_users_itr->second) {
if (predicate(inst)) inst->UpdateDebugInlinedAt(after);
}
inlinedat_id_to_users_[after] = inlinedat_id_to_users_itr->second;
inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr);
}
}
void DebugInfoManager::ClearDebugScopeAndInlinedAtUses(Instruction* inst) {
auto scope_id_to_users_itr = scope_id_to_users_.find(inst->result_id());
if (scope_id_to_users_itr != scope_id_to_users_.end()) {
scope_id_to_users_.erase(scope_id_to_users_itr);
}
auto inlinedat_id_to_users_itr =
inlinedat_id_to_users_.find(inst->result_id());
if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr);
}
}
void DebugInfoManager::AnalyzeDebugInst(Instruction* inst) {
if (inst->GetDebugScope().GetLexicalScope() != kNoDebugScope) {
auto& users = scope_id_to_users_[inst->GetDebugScope().GetLexicalScope()];
users.insert(inst);
}
if (inst->GetDebugInlinedAt() != kNoInlinedAt) {
auto& users = inlinedat_id_to_users_[inst->GetDebugInlinedAt()];
users.insert(inst);
}
if (!inst->IsCommonDebugInstr()) return;
RegisterDbgInst(inst);
if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction ||
inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
RegisterDbgFunction(inst);
}
if (deref_operation_ == nullptr &&
inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugOperation &&
inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex) ==
OpenCLDebugInfo100Deref) {
deref_operation_ = inst;
}
if (deref_operation_ == nullptr &&
inst->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation) {
uint32_t operation_const = GetVulkanDebugOperation(inst);
if (operation_const == NonSemanticShaderDebugInfo100Deref) {
deref_operation_ = inst;
}
}
if (debug_info_none_inst_ == nullptr &&
inst->GetCommonDebugOpcode() == CommonDebugInfoDebugInfoNone) {
debug_info_none_inst_ = inst;
}
if (empty_debug_expr_inst_ == nullptr && IsEmptyDebugExpression(inst)) {
empty_debug_expr_inst_ = inst;
}
if (inst->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare) {
uint32_t var_id =
inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
RegisterDbgDeclare(var_id, inst);
}
if (uint32_t var_id = GetVariableIdOfDebugValueUsedForDeclare(inst)) {
RegisterDbgDeclare(var_id, inst);
}
}
void DebugInfoManager::ConvertDebugGlobalToLocalVariable(
Instruction* dbg_global_var, Instruction* local_var) {
if (dbg_global_var->GetCommonDebugOpcode() !=
CommonDebugInfoDebugGlobalVariable) {
return;
}
assert(local_var->opcode() == SpvOpVariable ||
local_var->opcode() == SpvOpFunctionParameter);
// Convert |dbg_global_var| to DebugLocalVariable
dbg_global_var->SetInOperand(kExtInstInstructionInIdx,
{CommonDebugInfoDebugLocalVariable});
auto flags = dbg_global_var->GetSingleWordOperand(
kDebugGlobalVariableOperandFlagsIndex);
for (uint32_t i = dbg_global_var->NumInOperands() - 1;
i >= kDebugLocalVariableOperandFlagsIndex; --i) {
dbg_global_var->RemoveOperand(i);
}
dbg_global_var->SetOperand(kDebugLocalVariableOperandFlagsIndex, {flags});
context()->ForgetUses(dbg_global_var);
context()->AnalyzeUses(dbg_global_var);
// Create a DebugDeclare
std::unique_ptr<Instruction> new_dbg_decl(new Instruction(
context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
context()->TakeNextId(),
{
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
{spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
{static_cast<uint32_t>(CommonDebugInfoDebugDeclare)}},
{spv_operand_type_t::SPV_OPERAND_TYPE_ID,
{dbg_global_var->result_id()}},
{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {local_var->result_id()}},
{spv_operand_type_t::SPV_OPERAND_TYPE_ID,
{GetEmptyDebugExpression()->result_id()}},
}));
// Must insert after all OpVariables in block
Instruction* insert_before = local_var;
while (insert_before->opcode() == SpvOpVariable)
insert_before = insert_before->NextNode();
auto* added_dbg_decl = insert_before->InsertBefore(std::move(new_dbg_decl));
if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_decl);
if (context()->AreAnalysesValid(
IRContext::Analysis::kAnalysisInstrToBlockMapping)) {
auto insert_blk = context()->get_instr_block(local_var);
context()->set_instr_block(added_dbg_decl, insert_blk);
}
}
void DebugInfoManager::AnalyzeDebugInsts(Module& module) {
deref_operation_ = nullptr;
debug_info_none_inst_ = nullptr;
empty_debug_expr_inst_ = nullptr;
module.ForEachInst([this](Instruction* cpi) { AnalyzeDebugInst(cpi); });
// Move |empty_debug_expr_inst_| to the beginning of the debug instruction
// list.
if (empty_debug_expr_inst_ != nullptr &&
empty_debug_expr_inst_->PreviousNode() != nullptr &&
empty_debug_expr_inst_->PreviousNode()->IsCommonDebugInstr()) {
empty_debug_expr_inst_->InsertBefore(
&*context()->module()->ext_inst_debuginfo_begin());
}
// Move |debug_info_none_inst_| to the beginning of the debug instruction
// list.
if (debug_info_none_inst_ != nullptr &&
debug_info_none_inst_->PreviousNode() != nullptr &&
debug_info_none_inst_->PreviousNode()->IsCommonDebugInstr()) {
debug_info_none_inst_->InsertBefore(
&*context()->module()->ext_inst_debuginfo_begin());
}
}
void DebugInfoManager::ClearDebugInfo(Instruction* instr) {
auto scope_id_to_users_itr =
scope_id_to_users_.find(instr->GetDebugScope().GetLexicalScope());
if (scope_id_to_users_itr != scope_id_to_users_.end()) {
scope_id_to_users_itr->second.erase(instr);
}
auto inlinedat_id_to_users_itr =
inlinedat_id_to_users_.find(instr->GetDebugInlinedAt());
if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
inlinedat_id_to_users_itr->second.erase(instr);
}
if (instr == nullptr || !instr->IsCommonDebugInstr()) {
return;
}
id_to_dbg_inst_.erase(instr->result_id());
if (instr->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) {
auto fn_id =
instr->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex);
fn_id_to_dbg_fn_.erase(fn_id);
}
if (instr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugFunction) {
auto fn_id = instr->GetSingleWordOperand(
kDebugFunctionDefinitionOperandOpFunctionIndex);
fn_id_to_dbg_fn_.erase(fn_id);
}
if (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
instr->GetCommonDebugOpcode() == CommonDebugInfoDebugValue) {
auto var_or_value_id =
instr->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_or_value_id);
if (dbg_decl_itr != var_id_to_dbg_decl_.end()) {
dbg_decl_itr->second.erase(instr);
}
}
if (deref_operation_ == instr) {
deref_operation_ = nullptr;
for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
++dbg_instr_itr) {
// OpenCL.DebugInfo.100 contains the operation as a literal operand, in
// Vulkan it's referenced as an OpConstant.
if (instr != &*dbg_instr_itr &&
dbg_instr_itr->GetOpenCL100DebugOpcode() ==
OpenCLDebugInfo100DebugOperation &&
dbg_instr_itr->GetSingleWordOperand(
kDebugOperationOperandOperationIndex) ==
OpenCLDebugInfo100Deref) {
deref_operation_ = &*dbg_instr_itr;
break;
} else if (instr != &*dbg_instr_itr &&
dbg_instr_itr->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugOperation) {
uint32_t operation_const = GetVulkanDebugOperation(&*dbg_instr_itr);
if (operation_const == NonSemanticShaderDebugInfo100Deref) {
deref_operation_ = &*dbg_instr_itr;
break;
}
}
}
}
if (debug_info_none_inst_ == instr) {
debug_info_none_inst_ = nullptr;
for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
++dbg_instr_itr) {
if (instr != &*dbg_instr_itr && dbg_instr_itr->GetCommonDebugOpcode() ==
CommonDebugInfoDebugInfoNone) {
debug_info_none_inst_ = &*dbg_instr_itr;
break;
}
}
}
if (empty_debug_expr_inst_ == instr) {
empty_debug_expr_inst_ = nullptr;
for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
++dbg_instr_itr) {
if (instr != &*dbg_instr_itr && IsEmptyDebugExpression(&*dbg_instr_itr)) {
empty_debug_expr_inst_ = &*dbg_instr_itr;
break;
}
}
}
}
} // namespace analysis
} // namespace opt
} // namespace spvtools
| [
"branimirkaradzic@gmail.com"
] | branimirkaradzic@gmail.com |
90d6dc96d5f9e9d7974ff0c273bef7080e1d2a69 | 995fef3accf2aedbcd431dd98bc9ab2a2ecace9d | /src/plugins/lmp/plugins/graffiti/progressmanager.h | 5987e73ce8c47cda860fb3e7ca115eeb999efc3a | [
"BSL-1.0"
] | permissive | eringus/leechcraft | 2e3da6263e7530f002b532aae616a4b158d53ff6 | 415a9a49aa4c942a4953e8c6e59876fc7e217b24 | refs/heads/master | 2020-12-26T04:56:09.461868 | 2013-12-17T13:03:26 | 2013-12-17T13:03:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,384 | h | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2013 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#pragma once
#include <QObject>
#include <QHash>
class QStandardItemModel;
class QAbstractItemModel;
class QStandardItem;
namespace LeechCraft
{
namespace LMP
{
namespace Graffiti
{
class CueSplitter;
class ProgressManager : public QObject
{
Q_OBJECT
QStandardItemModel *Model_;
QHash<QObject*, QList<QStandardItem*>> TagsFetchObj2Row_;
QHash<CueSplitter*, QList<QStandardItem*>> Splitter2Row_;
public:
ProgressManager (QObject* = 0);
QAbstractItemModel* GetModel () const;
public slots:
void handleTagsFetch (int fetched, int total, QObject *obj);
void handleCueSplitter (CueSplitter*);
void handleSplitProgress (int, int, CueSplitter*);
void handleSplitFinished (CueSplitter*);
};
}
}
}
| [
"0xd34df00d@gmail.com"
] | 0xd34df00d@gmail.com |
e35889b2f1f4bf30ff5d3caa7cf7d5aad639f13a | 10047fd47735b78c70834072cc5253784d0d46cc | /pre_85/876(链表的中间结点).cpp | 6aaae0096296f2221dee2c74f2590735526c5570 | [] | no_license | HccqXd/my_leetcode1 | 676e6aa2cf901d7705f3944e4b423edc88da9961 | 170eaeda8d9aac66e70039079c6db2e329d227e4 | refs/heads/master | 2020-11-25T19:03:54.700682 | 2020-01-06T14:16:22 | 2020-01-06T14:16:22 | 228,803,491 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,979 | cpp | ///*
//题目描述:
// 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。
// 如果有两个中间结点,则返回第二个中间结点。
//
//示例 1:
// 输入:[1,2,3,4,5]
// 输出:此列表中的结点 3 (序列化形式:[3,4,5])
// 返回的结点值为 3 。 (测评系统对该结点序列化表述是 [3,4,5])。
// 注意,我们返回了一个 ListNode 类型的对象 ans,这样:
// ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next = NULL.
//
//示例 2:
// 输入:[1,2,3,4,5,6]
// 输出:此列表中的结点 4 (序列化形式:[4,5,6])
// 由于该列表有两个中间结点,值分别为 3 和 4,我们返回第二个结点。
//
//
//提示:
// 给定链表的结点数介于 1 和 100 之间。
//*/
//#include"List.h"
//
///*解法1:常规,其实这题根本没有头节点,误人子弟
//先遍历链表,得到链表长度len
//再从头遍历链表到第len/2+1个结点即为所求
//*/
//class Solution1 {
//public:
// ListNode* middleNode(ListNode* head) {
// int len = 0;
// ListNode* res = head->next;
// while (res != nullptr) {
// len++;
// res = res->next;
// }
// res = head;
// for (int i = 0; i <= len / 2 + 1; i++) {
// res = res->next;
// }
// return res;
// }
//};
//
///*解法2(官方解答):快慢指针法
// 当用慢指针 slow 遍历列表时,让另一个指针 fast 的速度是它的两倍。
// 当 fast 到达列表的末尾时,slow 必然位于中间。
//
//作者:LeetCode
//链接:https ://leetcode-cn.com/problems/middle-of-the-linked-list/solution/lian-biao-de-zhong-jian-jie-dian-by-leetcode/
//来源:力扣(LeetCode)*/
//class Solution {
//public:
// ListNode* middleNode(ListNode* head) {
// ListNode* slow = head;
// ListNode* fast = head;
// while (fast != NULL && fast->next != NULL) {
// slow = slow->next;
// fast = fast->next->next;
// }
// return slow;
// }
//};
| [
"hccqxd@qq.com"
] | hccqxd@qq.com |
8dfecf879bea29fd77605ec916055332abb590a7 | 23a8f5bcd50ee94d973e2b5bc86a5b97c6941b7f | /Scientific Programming/SOLUTIONS/series11/serie11/vector.cpp | 3e0db1ade6b8e3e364c4c645d62265d0034b15fc | [] | no_license | Johnson2209/TU-Wien-Assignments | b1b7ef92664761c21b0f8cac159efbb11bb55c7a | 7fdb176ca4dc99378467f64ea9eeba8ae2e78cfc | refs/heads/master | 2023-06-28T20:01:54.409267 | 2021-08-13T15:36:39 | 2021-08-13T15:36:39 | 395,697,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,576 | cpp | #include "vector.hpp"
#include <iostream>
using std::cout;
Vector::Vector() {
dim = 0;
coeff = (double*) 0;
// just for demonstration purposes
// cout << "constructor, empty\n";
}
Vector::Vector(int dim, double init) {
assert(dim >= 0);
this->dim = dim;
if (dim == 0) {
coeff = (double*) 0;
}
else {
coeff = new double[dim];
for (int j=0; j<dim; ++j) {
coeff[j] = init;
}
}
}
Vector::Vector(const Vector& rhs) {
dim = rhs.dim;
if (dim == 0) {
coeff = (double*) 0;
}
else {
coeff = new double[dim];
for (int j=0; j<dim; ++j) {
coeff[j] = rhs[j];
}
}
}
Vector::~Vector() {
if (dim > 0) {
delete[] coeff;
}
}
Vector& Vector::operator=(const Vector& rhs) {
if (this != &rhs) {
if (dim != rhs.dim) {
if (dim > 0) {
delete[] coeff;
}
dim = rhs.dim;
if (dim > 0) {
coeff = new double[dim];
}
else {
coeff = (double*) 0;
}
}
for (int j=0; j<dim; ++j) {
coeff[j] = rhs[j];
}
}
// just for demonstration purposes
// cout << "deep copy, length " << dim << "\n";
return *this;
}
int Vector::size() const {
return dim;
}
const double& Vector::operator[](int k) const {
assert(k>=0 && k<dim);
return coeff[k];
}
double& Vector::operator[](int k) {
assert(k>=0 && k<dim);
return coeff[k];
}
double Vector::norm() const {
double sum = 0;
for (int j=0; j<dim; ++j) {
sum = sum + coeff[j]*coeff[j];
}
return sqrt(sum);
}
const Vector operator+(const Vector& rhs1, const Vector& rhs2) {
assert(rhs1.size() == rhs2.size());
Vector result(rhs1);
for (int j=0; j<result.size(); ++j) {
result[j] += rhs2[j];
}
return result;
}
const Vector operator*(const double scalar, const Vector& input) {
Vector result(input);
for (int j=0; j<result.size(); ++j) {
result[j] *= scalar;
}
return result;
}
const Vector operator*(const Vector& input, const double scalar) {
return scalar*input;
}
const double operator*(const Vector& rhs1, const Vector& rhs2) {
double scalarproduct = 0;
assert(rhs1.size() == rhs2.size());
for (int j=0; j<rhs1.size(); ++j) {
scalarproduct += rhs1[j]*rhs2[j];
}
return scalarproduct;
}
std::ostream& operator<<(std::ostream& output, const Vector& p) {
int deg = p.size();
if (deg == 0) {
return output << 0;
}
else {
output << "(";
for (int i=0;i<deg-1;i++) {
output << p[i] << ",";
}
return output << p[deg-1] << ")";
}
}
| [
"johnsonoyero22@gmail.com"
] | johnsonoyero22@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.