blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
886fdc954f17772764f1beade755481566b6d500 | 63168b3cc1a8019583b331ebc8c4ec58c241753c | /inference-engine/src/mkldnn_plugin/nodes/mkldnn_ctc_greedy_decoder_seq_len_node.cpp | acd273a9ad9b82c1309fa7e4fcce6ef7cf2ae52c | [
"Apache-2.0"
] | permissive | generalova-kate/openvino | 2e14552ab9b1196fe35af63b5751a96d0138587a | 72fb7d207cb61fd5b9bb630ee8785881cc656b72 | refs/heads/master | 2023-08-09T20:39:03.377258 | 2021-09-07T09:43:33 | 2021-09-07T09:43:33 | 300,206,718 | 0 | 0 | Apache-2.0 | 2020-10-01T08:35:46 | 2020-10-01T08:35:45 | null | UTF-8 | C++ | false | false | 7,299 | cpp | // Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <string>
#include <vector>
#include <ngraph/op/ctc_greedy_decoder_seq_len.hpp>
#include "ie_parallel.hpp"
#include "mkldnn_ctc_greedy_decoder_seq_len_node.h"
using namespace MKLDNNPlugin;
using namespace InferenceEngine;
bool MKLDNNCTCGreedyDecoderSeqLenNode::isSupportedOperation(const std::shared_ptr<ngraph::Node>& op, std::string& errorMessage) noexcept {
try {
const auto greedyDecOp = ngraph::as_type_ptr<const ngraph::op::v6::CTCGreedyDecoderSeqLen>(op);
if (!greedyDecOp) {
errorMessage = "Node is not an instance of the CTCGreedyDecoderSeqLen operation from operation set v6.";
return false;
}
} catch (...) {
return false;
}
return true;
}
MKLDNNCTCGreedyDecoderSeqLenNode::MKLDNNCTCGreedyDecoderSeqLenNode(const std::shared_ptr<ngraph::Node>& op, const mkldnn::engine& eng,
MKLDNNWeightsSharing::Ptr &cache) : MKLDNNNode(op, eng, cache) {
std::string errorMessage;
if (!isSupportedOperation(op, errorMessage)) {
IE_THROW(NotImplemented) << errorMessage;
}
errorPrefix = "CTCGreedyDecoderSeqLen layer with name '" + op->get_friendly_name() + "' ";
if (getOriginalInputsNumber() < 2 || getOriginalInputsNumber() > 3)
IE_THROW() << errorPrefix << "has invalid number of input edges: " << getOriginalInputsNumber();
if (getOriginalOutputsNumber() != 2)
IE_THROW() << errorPrefix << "has invalid number of outputs edges: " << getOriginalOutputsNumber();
if (op->get_input_shape(DATA_INDEX)[0] != op->get_input_shape(SEQUENCE_LENGTH_INDEX)[0])
IE_THROW() << errorPrefix << "has invalid input shapes.";
auto greedyDecOp = ngraph::as_type_ptr<const ngraph::op::v6::CTCGreedyDecoderSeqLen>(op);
mergeRepeated = greedyDecOp->get_merge_repeated();
}
void MKLDNNCTCGreedyDecoderSeqLenNode::initSupportedPrimitiveDescriptors() {
if (!supportedPrimitiveDescriptors.empty())
return;
Precision inDataPrecision = getOriginalInputPrecisionAtPort(DATA_INDEX);
if (inDataPrecision != Precision::FP32 && inDataPrecision != Precision::BF16)
IE_THROW() << errorPrefix << "has unsupported 'data' input precision: " << inDataPrecision;
Precision seqLenPrecision = getOriginalInputPrecisionAtPort(SEQUENCE_LENGTH_INDEX);
if (seqLenPrecision != Precision::I32 && seqLenPrecision != Precision::I64)
IE_THROW() << errorPrefix << "has unsupported 'sequence_length' input precision: " << seqLenPrecision;
std::vector<PortConfigurator> inDataConf;
inDataConf.reserve(getOriginalInputsNumber());
inDataConf.emplace_back(LayoutType::ncsp, Precision::FP32);
for (int i = 1; i < getOriginalInputsNumber(); ++i)
inDataConf.emplace_back(LayoutType::ncsp, Precision::I32);
addSupportedPrimDesc(inDataConf,
{{LayoutType::ncsp, Precision::I32},
{LayoutType::ncsp, Precision::I32}},
impl_desc_type::ref_any);
}
void MKLDNNCTCGreedyDecoderSeqLenNode::execute(mkldnn::stream strm) {
const float* probabilities = reinterpret_cast<const float *>(getParentEdgeAt(DATA_INDEX)->getMemoryPtr()->GetPtr());
const int* sequenceLengths = reinterpret_cast<const int *>(getParentEdgeAt(SEQUENCE_LENGTH_INDEX)->getMemoryPtr()->GetPtr());
int* decodedClasses = reinterpret_cast<int *>(getChildEdgesAtPort(DECODED_CLASSES_INDEX)[0]->getMemoryPtr()->GetPtr());
int* decodedClassesLength = reinterpret_cast<int *>(getChildEdgesAtPort(DECODED_CLASSES_LENGTH_INDEX)[0]->getMemoryPtr()->GetPtr());
const size_t B = getParentEdgeAt(DATA_INDEX)->getShape().getStaticDims()[0];;
const size_t T = getParentEdgeAt(DATA_INDEX)->getShape().getStaticDims()[1];;
const int C = getParentEdgeAt(DATA_INDEX)->getShape().getStaticDims()[2];;
const size_t TC = T * C;
int blankIndex = C - 1;
if (inputShapes.size() > BLANK_INDEX)
blankIndex = (reinterpret_cast<const int *>(getParentEdgeAt(BLANK_INDEX)->getMemoryPtr()->GetPtr()))[0];
size_t workAmount = 0;
for (size_t b = 0; b < B; b++) {
if (sequenceLengths[b] > T) {
std::string errorMsg = errorPrefix
+ ". Sequence length " + std::to_string(sequenceLengths[b])
+ " cannot be greater than according decoded classes dimension size "
+ std::to_string(getChildEdgesAtPort(DECODED_CLASSES_INDEX)[0]->getShape().getStaticDims()[1]);
IE_THROW() << errorMsg;
}
workAmount += sequenceLengths[b];
}
// Parallelization could not be made directly by T due to output index depends on merged classes and
// blank index, thus could not be shared between threads. Better to divide operation on two steps.
// At the first stage find the maximum index. At second stage merge if needed.
// Such approach makes parallelization more efficient.
auto threadBody = [&](const int ithr, const int nthr) {
size_t start(0lu), end(0lu);
splitter(workAmount, nthr, ithr, start, end);
if (start >= end)
return;
size_t tStart = 0lu, bStart = 0lu;
for (; bStart < B; bStart++) {
tStart += sequenceLengths[bStart];
if (tStart >= start) {
tStart = start - (tStart - sequenceLengths[bStart]);
break;
}
}
size_t workCounter = start;
for (size_t b = bStart; b < B; ++b) {
size_t outputIndex = b * T + tStart;
const float* probs = probabilities + b * TC + C * tStart;
const size_t actualSeqLen = sequenceLengths[b];
for (size_t t = tStart; t < actualSeqLen; ++t) {
int maxClassIdx = 0;
float maxProb = probs[0];
probs++;
for (int c = 1; c < C; c++, probs++) {
if (*probs > maxProb) {
maxClassIdx = c;
maxProb = *probs;
}
}
decodedClasses[outputIndex++] = maxClassIdx;
if (++workCounter >= end) {
return;
}
}
tStart = 0lu;
}
}; // thread body
parallel_nt(0, threadBody);
parallel_for(B, [&](size_t b) {
int prevClassIdx = -1;
size_t outputIndex = b * T;
const size_t actualSeqLen = sequenceLengths[b];
int* shiftedOut = decodedClasses + b * T;
for (size_t t = 0; t < actualSeqLen; ++t) {
if (*shiftedOut != blankIndex &&
!(mergeRepeated && *shiftedOut == prevClassIdx)) {
decodedClasses[outputIndex++] = *shiftedOut;
}
prevClassIdx = *shiftedOut;
shiftedOut++;
}
std::fill(decodedClasses + outputIndex, decodedClasses + (b + 1) * T, -1);
decodedClassesLength[b] = outputIndex - b * T;
});
}
bool MKLDNNCTCGreedyDecoderSeqLenNode::created() const {
return getType() == CTCGreedyDecoderSeqLen;
}
REG_MKLDNN_PRIM_FOR(MKLDNNCTCGreedyDecoderSeqLenNode, CTCGreedyDecoderSeqLen)
| [
"noreply@github.com"
] | noreply@github.com |
189e34f66cd80f0999496cd3c336573c1de3e9d1 | a76fc4b155b155bb59a14a82b5939a30a9f74eca | /AtelierCinema/DlgCritere.h | b101670bcfa885a232719b5526b7c1670b4b55ce | [] | no_license | isliulin/JFC-Tools | aade33337153d7cc1b5cfcd33744d89fe2d56b79 | 98b715b78ae5c01472ef595b1faa5531f356e794 | refs/heads/master | 2023-06-01T12:10:51.383944 | 2021-06-17T14:41:07 | 2021-06-17T14:41:07 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,528 | h | #if !defined(AFX_DLGCRITERE_H__24CA7706_4074_4492_8B32_5F3A840C16AC__INCLUDED_)
#define AFX_DLGCRITERE_H__24CA7706_4074_4492_8B32_5F3A840C16AC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgCritere.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDlgCritere dialog
class CDlgCritere : public CDialog
{
// Construction
public:
CDlgCritere(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlgCritere)
enum { IDD = IDD_CRITERE };
CListBox m_ListCritere;
CEdit m_CritereBase;
CObj_Gray m_Cadre1;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgCritere)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// attributes
public :
// N° du critère de base et nombre de moadalités associés
int m_NoCritere;
int m_NbModalite;
private :
// Chargement des critères disponibles
bool ChargeCritere();
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgCritere)
afx_msg void OnPaint();
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnSelchangeListcritere();
afx_msg void OnDblclkListcritere();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGCRITERE_H__24CA7706_4074_4492_8B32_5F3A840C16AC__INCLUDED_)
| [
"a.chambard@jfc-infomedia.fr"
] | a.chambard@jfc-infomedia.fr |
8cea78a45551dae8109a017eb2fe9a79037e96a5 | 0e19a0c8a32f1d836b88d7661607ec13d4eaac9c | /moon_net/lua.hpp | 0096293ad89fc25a68149c05bee468eb00021b0c | [] | no_license | dr520/moon_net | 767784bf0acf65ebf9916a6b6af755adf63ffd6f | 1f2782d14fc04aa25d00e3ca9e9436439eb1d5a5 | refs/heads/master | 2020-02-26T13:40:58.988711 | 2016-07-09T11:48:38 | 2016-07-09T11:48:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 125 | hpp | #pragma once
extern "C" {
#include "..\liblua\lua.h"
#include "..\liblua\lualib.h"
#include "..\liblua\lauxlib.h"
}; | [
"hanyongtao@live.com"
] | hanyongtao@live.com |
6958ac4c83b77cee21b13525829e1bc8c299a304 | 7e385bf9e0740d12e691e2e1004ed4ad64bfcddb | /卡特1.cpp | 3dcd95499e00f0a24708aba2d71bc31b7cc14eb2 | [] | no_license | 504281906/ACM | c23def3e50cbcbc020641d1df7021f6a75acd039 | 481d7d4d16f1cb421500aff3b747ccefe0f3d369 | refs/heads/master | 2021-01-23T04:13:40.729427 | 2017-04-18T02:07:34 | 2017-04-18T02:07:34 | 32,318,925 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 219 | cpp | #include <iostream>
#include <cstring>
using namespace std;
int f[100],i,j;
int main()
{
memset(f,0,sizeof(f));
f[0]=1;
f[1]=1;
for (i=2;i<=16;i++)
for (j=0;j<i;j++)
f[i]+=f[j]*f[i-j-1];
cout<<f[16]<<endl;
}
| [
"504281906@qq.com"
] | 504281906@qq.com |
1b07315135a0d60b71af9f6719973fcf4314388c | 00de836e49e568a222393cb211dff89db04ae934 | /stl-assesment/Alien.cpp | 8d290e04c524cbaa355dc7a8a839b09fad383db5 | [] | no_license | nitin1259/cpp-learning | 4afad95bd087d334e165ca41efb5b9dcf091a98e | ff5a7a8b89ea0cc2e4eebefdf015ec807952daf9 | refs/heads/main | 2023-06-03T23:46:07.266692 | 2021-06-21T03:33:26 | 2021-06-21T03:33:26 | 376,873,807 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,556 | cpp | #include "Alien.h"
#include <cstdlib>
#include <ctime>
using namespace std;
Alien::Alien(int weight, int height, char gender)
{
this->weight = weight;
this->height = height;
this->gender = gender;
}
int Alien::getWeight() const
{
return weight;
}
int Alien::getHeight() const
{
return height;
}
char Alien::getGender() const
{
return gender;
}
int Alien::getPrestige() const
{
int genderValue;
if (gender == 'M')
{
genderValue = 2;
}
else
{
genderValue = 3;
}
return weight * height * genderValue;
}
bool Alien::operator==(Alien& other) const
{
return getPrestige() == other.getPrestige();
}
bool Alien::operator!=(Alien& other) const
{
return getPrestige() != other.getPrestige();
}
bool Alien::operator>(Alien& other) const
{
return getPrestige() > other.getPrestige();
}
bool Alien::operator>=(Alien& other) const
{
return getPrestige() >= other.getPrestige();
}
bool Alien::operator<(Alien& other) const
{
return getPrestige() < other.getPrestige();
}
bool Alien::operator<=(Alien& other) const
{
return getPrestige() <= other.getPrestige();
}
Alien Alien::operator+(Alien& other) const
{
srand(time(nullptr));
int randNum = rand() % 10 + 1; //1-10 inclusive
char newGender;
int newWeight = (weight + other.weight) / 2;
int newHeight = (height + other.height) / 2;
if (randNum < 4)
{
newGender = 'F';
}
else
{
newGender = 'M';
}
return Alien(newWeight, newHeight, newGender);
}
void Alien::operator=(Alien& other)
{
weight = other.weight;
height = other.height;
gender = other.gender;
} | [
"nitinkumar.singh@f5.com"
] | nitinkumar.singh@f5.com |
cd1333617c1517e5d0f1735bafa50a19d53da784 | 240b69600c0e3ab71c772dcb7d075ceaddbcbb39 | /main/main.ino | a77df0df3bd8b214fee15e79314f3748aed62dd6 | [] | no_license | graysunday/remoteTank | 58fb636cefebb5ed50e1a13d7d3fc3df15e6a5b5 | d3f303a873796c53f5a417c29968d254e991711a | refs/heads/master | 2020-03-31T21:26:23.017356 | 2018-11-11T10:08:00 | 2018-11-11T10:08:00 | 152,580,618 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 913 | ino | /*
Name: main.ino
Created: 2018-10-11 오후 8:23:30
Author: 이원호
*/
#include <L298N.h>
#include <Joystick.h>
void setup() {
Serial.begin(9600);
}
// the loop function runs over and over again until power down or reset
void loop() {
int xPin = 1; /* analog */
int yPin = 0; /* analog */
int bPin = 3; /* digital */
Joystick joystick(xPin, yPin, bPin); /* joystick pin No. */
int ena = 5; /* digital pwm */
int in1 = 2; /* digital */
int in2 = 4; /* digital */
int in3 = 7; /* digital */
int in4 = 8; /* digital */
int enb = 9; /* digital pwm */
L298N driver(ena, in1, in2, in3, in4, enb); /* L298N pin No. */
int Direction = joystick.getDirection(); /* 0: stop, 1:forward, 2:backward, 3:right, 4:left, 13, 14, 23, 24 */
int xSpeed = joystick.getX();
int ySpeed = joystick.getY();
driver.dualWheelOutput(Direction, xSpeed, ySpeed);
delay(300);
}
| [
"graysunday@outlook.kr"
] | graysunday@outlook.kr |
5897927182735949d92501d7957225b3a3072554 | ed143fc81cdf338e2b2c3e8ab8288abdb746bf55 | /C++ Primer Plus/Ch.2 - Setting Out to C++/Programming Exercises/2-3.cpp | f41d4da2769adb657a50754e7987d25b6902d343 | [
"MIT"
] | permissive | yoonBot/Computer-Science-and-Engineering | f64230dc52ecb98ed641b190b2a3d15c513874cf | 34a267a0f4debc2082d6ec11e289e4250019fb96 | refs/heads/main | 2023-08-14T01:40:31.765474 | 2021-09-28T02:25:06 | 2021-09-28T02:25:06 | 305,714,969 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 332 | cpp | // C++ Primer Plus Ch.2 -- Problem 3
// @reproduced by yoonBot
#include <iostream>
using namespace std;
void mice();
void run();
int main(){
mice();
mice();
run();
run();
return 0;
}
void mice(){
cout << "Three blind mice." << endl;
}
void run(){
cout << "See how they run." << endl;
}
| [
"noreply@github.com"
] | noreply@github.com |
f119ab8646ddc62ed681e6dfa6d829e19a762b88 | a1859bbfc6cef11345ca554a85469de857d17e03 | /AISDeocder/include/src/nmea/vtg.cpp | 2eb24215098e033500a3e5f79921b926efec6b7e | [] | no_license | ashraful100/Web-Service-Broker | 272cc8f3ef64fad076a73bd4529ea1c60299c7e1 | 3ff53e6bbc869c5c66abb4fc043c2cb403dee302 | refs/heads/master | 2020-06-11T12:52:34.777579 | 2019-06-26T20:26:13 | 2019-06-26T20:26:13 | 193,970,445 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,610 | cpp | #include "vtg.hpp"
#include <src/nmea/io.hpp>
namespace src
{
namespace nmea
{
constexpr const char * vtg::TAG;
vtg::vtg()
: sentence(ID, TAG, talker_id::global_positioning_system)
{
}
vtg::vtg(talker talk, fields::const_iterator first, fields::const_iterator last)
: sentence(ID, TAG, talk)
{
// before and after NMEA 2.3
const auto size = std::distance(first, last);
if ((size < 8) || (size > 9))
throw std::invalid_argument{"invalid number of fields in vtg"};
read(*(first + 0), track_true_);
read(*(first + 1), type_true_);
read(*(first + 2), track_magn_);
read(*(first + 3), type_magn_);
read(*(first + 4), speed_kn_);
read(*(first + 5), speed_kn_unit_);
read(*(first + 6), speed_kmh_);
read(*(first + 7), speed_kmh_unit_);
// NMEA 2.3 or newer
if (size > 8)
read(*(first + 8), mode_ind_);
}
void vtg::set_speed_kn(double t) noexcept
{
speed_kn_ = t;
speed_kn_unit_ = unit::velocity::knot;
}
void vtg::set_speed_kmh(double t) noexcept
{
speed_kmh_ = t;
speed_kmh_unit_ = unit::velocity::kmh;
}
void vtg::set_track_magn(double t) noexcept
{
track_magn_ = t;
type_magn_ = reference::MAGNETIC;
}
void vtg::set_track_true(double t) noexcept
{
track_true_ = t;
type_true_ = reference::TRUE;
}
void vtg::append_data_to(std::string & s) const
{
append(s, to_string(track_true_));
append(s, to_string(type_true_));
append(s, to_string(track_magn_));
append(s, to_string(type_magn_));
append(s, to_string(speed_kn_));
append(s, to_string(speed_kn_unit_));
append(s, to_string(speed_kmh_));
append(s, to_string(speed_kmh_unit_));
append(s, to_string(mode_ind_));
}
}
}
| [
"write2ashraf_eee@yahoo.com"
] | write2ashraf_eee@yahoo.com |
ff66a9f3e48add5c1af068bee16386395356ce2e | 30e990b10aadf0d66c4903511e1002a44d3de5d3 | /src/Raycasting.cpp | 2cdea7a03ebdc1e2d34afa4e6db4ed6fab9883bd | [
"MIT"
] | permissive | diegomazala/QtKinect | d86a964c618c1487ab56168f859773df8a3bd590 | c51819980af92b857d87a417d19c5f01d8fada77 | refs/heads/master | 2021-04-09T17:09:24.899044 | 2017-02-14T21:03:04 | 2017-02-14T21:03:04 | 44,559,609 | 5 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 9,896 | cpp |
#include <QApplication>
#include "QImageWidget.h"
#include "Raycasting.h"
#include "KinectSpecs.h"
#define DegToRad(angle_degrees) (angle_degrees * 3.14159265359 / 180.0) // Converts degrees to radians.
#define RadToDeg(angle_radians) (angle_radians * 180.0 / 3.14159265359) // Converts radians to degrees.
static void multDirMatrix(const Eigen::Vector3f &src, const Eigen::Matrix4f &mat, Eigen::Vector3f &dst)
{
float a, b, c;
a = src[0] * mat(0, 0) + src[1] * mat(1, 0) + src[2] * mat(2, 0);
b = src[0] * mat(0, 1) + src[1] * mat(1, 1) + src[2] * mat(2, 1);
c = src[0] * mat(0, 2) + src[1] * mat(1, 2) + src[2] * mat(2, 2);
dst.x() = a;
dst.y() = b;
dst.z() = c;
}
template <typename Type>
static Eigen::Matrix<Type, 3, 1> compute_normal(
const Eigen::Matrix<Type, 3, 1>& p1,
const Eigen::Matrix<Type, 3, 1>& p2,
const Eigen::Matrix<Type, 3, 1>& p3)
{
Eigen::Matrix<Type, 3, 1> u = p2 - p1;
Eigen::Matrix<Type, 3, 1> v = p3 - p1;
return v.cross(u).normalized();
}
template <typename Type>
static Eigen::Matrix<Type, 3, 1> reflect(const Eigen::Matrix<Type, 3, 1>& i, const Eigen::Matrix<Type, 3, 1>& n)
{
return i - 2.0 * n * n.dot(i);
}
int raycast_and_render_grid(int argc, char* argv[])
{
//int vx_count = 3;
//int vx_size = 1;
int vx_count = 8;
int vx_size = 16;
Eigen::Vector3i voxel_count(vx_count, vx_count, vx_count);
Eigen::Vector3i voxel_size(vx_size, vx_size, vx_size);
//if (argc > 2)
//{
// vx_count = atoi(argv[1]);
// vx_size = atoi(argv[2]);
// voxel_count = Eigen::Vector3i(vx_count, vx_count, vx_count);
// voxel_size = Eigen::Vector3i(vx_size, vx_size, vx_size);
//}
Eigen::Vector3i volume_size(voxel_count.x() * voxel_size.x(), voxel_count.y() * voxel_size.y(), voxel_count.z() * voxel_size.z());
Eigen::Vector3f half_volume_size = volume_size.cast<float>() * 0.5f;
const int total_voxels = voxel_count.x() * voxel_count.y() * voxel_count.z();
std::cout << std::fixed
<< "Voxel Count : " << voxel_count.transpose() << std::endl
<< "Voxel Size : " << voxel_size.transpose() << std::endl
<< "Volume Size : " << volume_size.transpose() << std::endl
<< "Total Voxels : " << total_voxels << std::endl;
//
// create the grid params and set a few voxels with different signals
// in order to obtain zero crossings
//
std::vector<Eigen::Vector2f> tsdf(total_voxels, Eigen::Vector2f::Ones());
//tsdf.at(13)[0] =
//tsdf.at(22)[0] =
//tsdf.at(18)[0] =
//tsdf.at(26)[0] = -1.0f;
tsdf.at(0)[0] = -1.0f;
//tsdf.at(tsdf.size() - voxel_count.x())[0] =
//tsdf.at(tsdf.size() - 1)[0] = -1.0f;
//
// setup camera parameters
//
Eigen::Affine3f camera_to_world = Eigen::Affine3f::Identity();
#if 0
float cam_z = (-vx_count - 1) * vx_size;
camera_to_world.translate(Eigen::Vector3f(half_volume_size.x(), half_volume_size.y(), cam_z));
#else
//camera_to_world.rotate(Eigen::AngleAxisf(DegToRad(-25), Eigen::Vector3f::UnitX()));
//camera_to_world.translate(Eigen::Vector3f(half_volume_size.x(), half_volume_size.y(), 0));
//camera_to_world.translate(Eigen::Vector3f(0, 7, -4));
//camera_to_world.rotate(Eigen::AngleAxisf(DegToRad(-20), Eigen::Vector3f::UnitY()));
//camera_to_world.translate(Eigen::Vector3f(half_volume_size.x(), half_volume_size.y(), 0));
//camera_to_world.translate(Eigen::Vector3f(-5, 0, -6));
camera_to_world.translate(Eigen::Vector3f(60, 256, -60));
camera_to_world.rotate(Eigen::AngleAxisf(DegToRad(-60), Eigen::Vector3f::UnitX()));
#endif
Eigen::Vector3f camera_pos = camera_to_world.matrix().col(3).head<3>();
float scale = (float)tan(DegToRad(KINECT_V2_FOVY * 0.5f));
float aspect_ratio = KINECT_V2_DEPTH_ASPECT_RATIO;
//
// setup image parameters
//
unsigned short image_width = KINECT_V2_DEPTH_WIDTH;
unsigned short image_height = image_width / aspect_ratio;
QImage image(image_width, image_height, QImage::Format_RGB888);
image.fill(Qt::GlobalColor::black);
//
// for each pixel, trace a ray
//
for (int y = 0; y < image_height; ++y)
{
for (int x = 0; x < image_width; ++x)
{
// Convert from image space (in pixels) to screen space
// Screen Space alon X axis = [-aspect ratio, aspect ratio]
// Screen Space alon Y axis = [-1, 1]
Eigen::Vector3f screen_coord(
(2 * (x + 0.5f) / (float)image_width - 1) * aspect_ratio * scale,
(1 - 2 * (y + 0.5f) / (float)image_height) * scale,
1.0f);
Eigen::Vector3f direction;
multDirMatrix(screen_coord, camera_to_world.matrix(), direction);
direction.normalize();
Eigen::Vector3f hit_normal;
long voxels_zero_crossing[2];
int hit_count = raycast_tsdf_volume(camera_pos, direction, voxel_count, voxel_size, tsdf, hit_normal, voxels_zero_crossing);
if (hit_count > 0)
{
//if (voxels_zero_crossing[0] > -1 && voxels_zero_crossing[1] > -1)
//if (voxels_zero_crossing[0] > -1 || voxels_zero_crossing[1] > -1)
if (hit_count == 2)
{
Eigen::Vector3i rgb = (hit_normal.cwiseAbs() * 255).cast<int>();
image.setPixel(QPoint(x, y), qRgb(rgb.x(), rgb.y(), rgb.z()));
}
else
{
image.setPixel(QPoint(x, y), qRgb(128, 128, 0));
}
}
else
{
image.setPixel(QPoint(x, y), qRgb(128, 0, 0));
}
}
}
QApplication app(argc, argv);
QImageWidget widget;
widget.setImage(image);
widget.show();
return app.exec();
}
int raycast_and_render_two_triangles(int argc, char* argv[])
{
Eigen::Affine3f camera_to_world = Eigen::Affine3f::Identity();
camera_to_world.translate(Eigen::Vector3f(2, 2, 5));
Eigen::Vector3f camera_pos = camera_to_world.matrix().col(3).head<3>();
float scale = tan(DegToRad(60.f * 0.5f));
float aspect_ratio = 1.7778f;
unsigned short image_width = 710;
unsigned short image_height = 400;
QImage image(image_width, image_height, QImage::Format_RGB888);
Eigen::Vector3f hit;
Eigen::Vector3f v1(0.0f, -1.0f, -2.0f);
Eigen::Vector3f v2(0.0f, 1.0f, -4.0f);
Eigen::Vector3f v3(-1.0f, -1.0f, -3.0f);
Eigen::Vector3f v4(0.0f, -1.0f, -2.0f);
Eigen::Vector3f v5(0.0f, 1.0f, -4.0f);
Eigen::Vector3f v6(1.0f, -1.0f, -3.0f);
Eigen::Vector3f diff_color(1, 0, 0);
Eigen::Vector3f spec_color(1, 1, 0);
float spec_shininess = 1.0f;
Eigen::Vector3f E(0, 0, -1); // view direction
Eigen::Vector3f L = Eigen::Vector3f(0.2, -1, -1).normalized(); // light direction
Eigen::Vector3f N[2] = {
compute_normal(v1, v2, v3),
compute_normal(v4, v5, v6) };
Eigen::Vector3f R[2] = {
-reflect(L, N[0]).normalized(),
-reflect(L, N[1]).normalized() };
for (int y = 0; y < image_height; ++y)
{
for (int x = 0; x < image_width; ++x)
{
// Convert from image space (in pixels) to screen space
// Screen Space alon X axis = [-aspect ratio, aspect ratio]
// Screen Space alon Y axis = [-1, 1]
Eigen::Vector3f screen_coord(
(2 * (x + 0.5f) / (float)image_width - 1) * aspect_ratio * scale,
(1 - 2 * (y + 0.5f) / (float)image_height) * scale,
-1.0f);
Eigen::Vector3f direction;
multDirMatrix(screen_coord, camera_to_world.matrix(), direction);
direction.normalize();
bool intersec[2] = {
triangle_intersection(camera_pos, direction, v1, v2, v3, hit),
triangle_intersection(camera_pos, direction, v4, v5, v6, hit) };
for (int i = 0; i < 2; ++i)
{
if (intersec[i])
{
Eigen::Vector3f diff = diff_color * std::fmax(N[i].dot(L), 0.0f);
Eigen::Vector3f spec = spec_color * pow(std::fmax(R[i].dot(E), 0.0f), spec_shininess);
Eigen::Vector3f color = eigen_clamp(diff + spec, 0.f, 1.f) * 255;
image.setPixel(QPoint(x, y), qRgb(color.x(), color.y(), color.z()));
}
}
}
}
QApplication app(argc, argv);
QImageWidget widget;
widget.setImage(image);
widget.show();
return app.exec();
}
int raycast_volume_test(int argc, char **argv)
{
int vx_count = 3;
int vx_size = 1;
//int vx_count = 2;
//int vx_size = 2;
//int vx_count = 3;
//int vx_size = 16;
Eigen::Vector3i voxel_count(vx_count, vx_count, vx_count);
Eigen::Vector3i voxel_size(vx_size, vx_size, vx_size);
//Eigen::Vector3f ray_origin(0.5f, 0.5f, -1.0f);
//Eigen::Vector3f ray_target(0.5f, 2.0f, 1.f); // { 3, 6, 15, 24 }
//Eigen::Vector3f ray_origin(2.f, 2.f, -2.0f);
//Eigen::Vector3f ray_target(2.f, 2.f, 2.f); // { 3, 7 }
//Eigen::Vector3f ray_origin(64.f, 64.f, -32.0f);
//Eigen::Vector3f ray_target(8.f, 8.f, 40.f);
//Eigen::Vector3f ray_origin(50.f, 2.9f, -1.0f);
//Eigen::Vector3f ray_target(1.5f, 2.9f, 1.f); // { 8, 7, 16, 15 }
Eigen::Vector3f ray_origin(50.f, 50.0f, -1.0f);
Eigen::Vector3f ray_target(1.5f, 2.9f, 1.f); // { 7, 16, 15, 12 }
Eigen::Vector3f ray_direction = (ray_target - ray_origin).normalized();
//if (argc > 8)
//{
// vx_count = atoi(argv[1]);
// vx_size = atoi(argv[2]);
// voxel_count = Eigen::Vector3i(vx_count, vx_count, vx_count);
// voxel_size = Eigen::Vector3i(vx_size, vx_size, vx_size);
// ray_origin = Eigen::Vector3f(atof(argv[3]), atof(argv[4]), atof(argv[5]));
// ray_target = Eigen::Vector3f(atof(argv[6]), atof(argv[7]), atof(argv[8]));
// ray_direction = (ray_target - ray_origin).normalized();
//}
std::vector<int> voxels_intersected;
Timer t;
t.start();
raycast_volume<float>(ray_origin, ray_direction, voxel_count, voxel_size, voxels_intersected);
t.print_interval("Raycasting volume : ");
std::cout << "Voxels Intersected: ";
for (auto v : voxels_intersected)
std::cout << v << ' ';
std::cout << std::endl;
return 0;
}
int main(int argc, char **argv)
{
#if 0
// Usage: ./Raycastingd.exe vx_count vx_size cam_x y z target_x y z
// Usage: ./Raycastingd.exe 3 1 1.5 1.5 -15 1.5 1.5 -10
raycast_volume_test(argc, argv);
#endif
#if 0
// Usage: ./Raycastingd.exe
Timer t;
t.start();
raycast_and_render_two_triangles(argc, argv);
t.print_interval("Raycasting and render : ");
#endif
#if 1
// Usage: ./Raycastingd.exe vx_count vx_size
// Usage: ./Raycastingd.exe 3 1
raycast_and_render_grid(argc, argv);
#endif
return 0;
}
| [
"diegomazala@gmail.com"
] | diegomazala@gmail.com |
fc0c2759b79d52cbac2a62ff03134f0b2d2273d8 | e28a86a134ed5983c47ce25a788fd9988a7c1b97 | /k2asm/CodeGen.h | ece6db09cc55aadef8fda91f9d17e0ac3f5c09bb | [
"Artistic-1.0"
] | permissive | b0rje/k2xtools | ab3d0cd1e9602d371d7f671e35409faaab746ad1 | c81a8ef4b93119b38d88ceb4fe371dd22e2f7a1a | refs/heads/master | 2020-05-17T15:41:31.467646 | 2015-04-09T20:59:28 | 2015-04-09T20:59:28 | 33,531,197 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,036 | h |
#ifndef _CODE_GEN_HEADER
#define _CODE_GEN_HEADER
#include <iostream>
#include "NodeVisitor.h"
using namespace std;
class CodeGen : public NodeVisitor {
ostream& out;
ostream& oexp;
ostream* odnc;
bool doexp;
bool doobj;
bool dodnc;
int pc;
int sizeContext;
Node* root;
void writeDNCData(const Number&, const Node* node);
public:
CodeGen(ostream& output);
CodeGen(ostream& output, ostream& expout);
void setDncStream(ostream& d);
CodeGen* setObj(bool);
bool visit(Node* n);
virtual bool procNode(Node* n);
//virtual bool procScope(Scope* n);
virtual bool procRootScope(RootScope* n);
//virtual bool procNamedScope(NamedScope* n);
virtual bool procOpcode(Opcode* n);
virtual bool procLabel(Label* n);
virtual bool procLookup(Lookup* n);
virtual bool procDefinition(Definition* n);
virtual bool procByteValue(ByteValue* n);
virtual bool procWordValue(WordValue* n);
virtual bool procValueList(ValueList* n);
virtual bool procByteBuffer(ByteBuffer* n);
};
#endif
| [
"boerje@flaregames.com"
] | boerje@flaregames.com |
115718b9d98d00177a1d9a883afb0eb683c5ffa5 | bb0ede8c2458900f3e0f415137de73266dccdbb8 | /root/multicore/tprocpool.cpp | a7e3e01d21d4c364f723df83deaa85184c208352 | [] | no_license | zzxuanyuan/roottest | 35fbc95436125c195601cb2685f67a4c4633ce0b | 0943e1e8a88bc0b1375421db732fc64a462511b5 | refs/heads/master | 2021-01-18T15:07:02.907099 | 2016-04-05T19:50:05 | 2016-04-05T19:51:33 | 50,401,451 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,977 | cpp | #include "TH1F.h"
#include "TProcPool.h"
#include "TList.h"
#include <functional>
#include <list>
#include <vector>
#include <numeric> //accumulate
#include <iostream>
int f(int a)
{
return a+1;
}
class fClass {
public:
int operator()(int a)
{
return a+1;
}
};
TObject *rootF(TObject *o)
{
TH1F *h = (TH1F*)o;
h->FillRandom("gaus", 1);
return h;
}
int PoolTest() {
TProcPool pool;
fClass c;
auto boundF = std::bind(f, 1);
/**** TProcPool::Map ****/
std::vector<int> truth = {1,1,1,1};
// init list and lambda
auto res = pool.Map([](int a) -> int { return a+1; }, {0,0,0,0});
if( res != truth)
return 1;
// vector and C++ function
std::vector<int> vargs = {0,0,0,0};
auto res2 = pool.Map(f, vargs);
if(res2 != truth)
return 2;
// std::list and functor class
std::list<int> largs = {0,0,0,0};
auto res3 = pool.Map(c, largs);
if(res3 != truth)
return 3;
// TList
TList tlargs;
tlargs.Add(new TH1F("h1","h",100,-3,3));
tlargs.Add(new TH1F("h2","h",100,-3,3));
auto res4 = pool.Map(rootF, tlargs);
if(res4.GetEntries() != 2 || ((TH1F*)res4[0])->GetEntries() != 1 || ((TH1F*)res4[1])->GetEntries() != 1)
return 4;
res4.Delete();
tlargs.Delete();
//nTimes signature and bound function
auto res6 = pool.Map(boundF, 100);
if(res6 != std::vector<int>(100,2))
return 6;
/**** TProcPool::MapReduce ****/
int redtruth = 4;
auto redfunc = [](std::vector<int> a) -> int { return std::accumulate(a.begin(), a.end(), 0); };
// init list and lambda
auto redres = pool.MapReduce([](int a) { return a+1; }, {0,0,0,0}, redfunc);
if(redres != redtruth)
return 8;
// vector and C++ function
std::vector<int> vargs2 = {0,0,0,0};
auto redres2 = pool.MapReduce(f, vargs2, redfunc);
if(redres2 != redtruth)
return 9;
// std::list and functor class
std::list<int> largs2 = {0,0,0,0};
auto redres3 = pool.MapReduce(c, largs2, redfunc);
if(redres3 != redtruth)
return 10;
// TList
TList tlargs2;
tlargs2.Add(new TH1F("h1","h",100,-3,3));
tlargs2.Add(new TH1F("h2","h",100,-3,3));
TH1F* redres4 = static_cast<TH1F*>(pool.MapReduce(rootF, tlargs2, PoolUtils::ReduceObjects));
if(redres4->GetEntries() != 2)
return 11;
tlargs2.Delete();
delete redres4;
//nTimes signature and bound function
auto redres6 = pool.MapReduce(boundF, 100, redfunc);
if(redres6 != 200)
return 12;
/***** other tests *****/
//returning a c-string
auto extrares1 = pool.Map([]() { return "42"; }, 25);
for(auto c_str : extrares1)
if(strcmp(c_str, "42") != 0)
return 13;
for(auto c_str : extrares1)
delete [] c_str;
//returning a string
auto extrares2 = pool.Map([]() { return std::string("fortytwo"); }, 25);
for(auto str : extrares2)
if(str != "fortytwo")
return 14;
return 0;
}
int main() {
return PoolTest();
}
| [
"danilo.piparo@cern.ch"
] | danilo.piparo@cern.ch |
8cbde9a03d2fd4d924e68983221cc2f01792a0e5 | 9be1ffde86d0adba37ce4db77000b23f491a5d8d | /covid/smooth/aligator/covid_lin.cpp | e4cf660a6e879300ea5dfd6aa14577db7bc955d5 | [
"MIT"
] | permissive | Gandor26/cacovid | f32d2b724570d9fcf361f433dae6417d9c208daa | 2b966579dba1eac6e33f439515de6de9e802d08a | refs/heads/main | 2023-02-27T21:10:31.754230 | 2021-02-06T00:42:54 | 2021-02-06T00:42:54 | 319,486,190 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,068 | cpp | //#include<iostream>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
#include<cmath>
#include<vector>
#include<utility>
using namespace std;
namespace py = pybind11;
double prev_pred = 0;
int final_idx;
struct expert{
double prediction;
double loss;
//int count;
double weight;
int start_idx;
int end_idx;
expert(){
prediction = 0;
loss = 0;
//count = 0;
weight = 0;
start_idx = 0;
end_idx = 0;
}
};
int init_experts(std::vector<std::vector<expert> >& pool, int n){
int count = 0;
for(int k = 0; k <= floor(log2(n)); k++){
int stop = ((n+1) >> k) - 1;
//int stop = floor((n+1)/pow(2,k) -1);
if(stop < 1)
break;
std::vector<expert> elist;
for (int i=1; i<= stop; i++){
expert e;
e.start_idx = i* (1 << k) - 1; // 0-based index
e.end_idx = (i+1)*(1 << k) - 2 < final_idx ? (i+1)*(1 << k) - 2 : final_idx;
elist.push_back(e);
count++;
}
pool.push_back(elist);
}
return count;
}
std::pair<double, double> perform_ols(int start, int end, int idx, std::vector<double>& y){
// start - end + 1 must be greater than 2
//calculation of slope
int n = end - start + 1;
n = n -1; // beacuse of leave one out
double sum_xy = 0;
double sum_x = 0;
double sum_y = 0;
double sum_x2 = 0;
for(int i = start; i<= end; i++){
if(i == idx) continue;
sum_xy = sum_xy + (i+1)*y[i];
sum_x = sum_x + (i+1);
sum_y = sum_y + y[i];
sum_x2 = sum_x2 + ((i+1)*(i+1));
}
double m = ((n*sum_xy) - (sum_x * sum_y))/((n*sum_x2)-(sum_x * sum_x));
double c = (sum_y - (m*sum_x))/n;
return std::make_pair(m,c);
}
void get_awake_set(std::vector<int>& index, int t, int n){
//std::vector<int> index;
for(int k=0; k<= floor(log2(t)); k++){
int i = (t >> k);
if(((i+1) << k) - 1 > n)
index.push_back(-1);
else
index.push_back(i);
}
//return index;
}
double get_forecast(std::vector<int>& awake_set,
std::vector<std::vector<expert> >& pool,
double& normalizer, int pool_size, int idx,
std::vector<double> y){
double output = 0;
normalizer = 0;
int i;
double prediction;
for(int k=0; k<awake_set.size(); k++){
if(awake_set[k] == -1) continue;
i = awake_set[k] - 1;
if(pool[k][i].weight == 0){
pool[k][i].weight = 1.0/pool_size;
// added to reduce jittery output for isotonic case
prediction = prev_pred;
}
if(pool[k][i].end_idx - pool[k][i].start_idx +1 <= 2)
prediction = prev_pred;
else{
std::pair<double,double> ols = perform_ols(pool[k][i].start_idx, pool[k][i].end_idx,
idx, y);
prediction = (ols.first * (idx+1) ) + ols.second;
}
pool[k][i].prediction = prediction;
output = output + (pool[k][i].weight * prediction);
normalizer = normalizer + pool[k][i].weight;
}
return output/normalizer;
}
void compute_losses(std::vector<int>& awake_set,
std::vector<std::vector<expert> >& pool,
std::vector<double>& losses, double y,
double B, int n, double sigma, double delta){
int i;
//double norm = 2*(B + sigma*sqrt(log(2*n/delta)))*
//(B + sigma*sqrt(log(2*n/delta)));
// using sigma as a proxy for step size
double norm = 2*sigma*B*B;
for(int k=0; k<awake_set.size(); k++){
if(awake_set[k] == -1){
losses.push_back(-1);
}
else{
i = awake_set[k] - 1;
double loss= (y-pool[k][i].prediction)*(y-pool[k][i].prediction)/norm;
losses.push_back(loss);
}
}
}
void update_weights(std::vector<int>& awake_set,
std::vector<std::vector<expert> >& pool,
std::vector<double>& losses,
double normalizer){
double norm = 0;
int i;
// compute new normalizer
for(int k=0; k < awake_set.size(); k++){
if(awake_set[k] == -1) continue;
i = awake_set[k] - 1;
//assert(losses[k] != -1);
norm = norm + pool[k][i].weight * exp(-losses[k]);
}
// update weights
for(int k=0; k < awake_set.size(); k++){
if(awake_set[k] == -1) continue;
i = awake_set[k] - 1;
pool[k][i].weight = pool[k][i].weight * exp(-losses[k]) *
normalizer/norm;
}
}
std::vector<double> make_durational_forecast(int n,std::vector<std::vector<expert> >& pool,
std::vector<double>& y, int duration){
std::vector<int> awake_set;
get_awake_set(awake_set,n,n);
double m = 0;
double c = 0;
double normalizer = 0;
int i;
for(int k=0; k<awake_set.size(); k++){
if(awake_set[k] == -1) continue;
i = awake_set[k] - 1;
if(pool[k][i].end_idx - pool[k][i].start_idx +1 < 2)
c = c + pool[k][i].weight * y[n-1];
else{
std::pair<double,double> ols = perform_ols(pool[k][i].start_idx, pool[k][i].end_idx,
-1, y);
m = m + (pool[k][i].weight * ols.first);
c = c + (pool[k][i].weight * ols.second);
}
normalizer = normalizer + pool[k][i].weight;
}
m = m/normalizer;
c = c/normalizer;
std::vector<double> estimates;
for(int j = n+1; j <= n+duration; j++){
double pred = m*j + c;
estimates.push_back(pred);
}
return estimates;
}
std::vector<double> run_aligator(int n, std::vector<double> y,
std::vector<int> index,
double sigma,
double B, double delta,
int duration ){
prev_pred = 0;
final_idx = n-1;
std::vector<double> estimates(n);
std::vector<std::vector<expert> > pool;
int pool_size = init_experts(pool,n);
for(int t=0; t<n; t++){
double normalizer = 0;
std::vector<int> awake_set;
int idx = index[t];
double y_curr = y[idx];
//get_awake_set(awake_set,t+1,n);
get_awake_set(awake_set,idx+1,n);
double output = get_forecast(awake_set, pool, normalizer, pool_size, idx, y);
//estimates.push_back(output);
estimates[idx] = output;
std::vector<double> losses;
//compute_losses(awake_set, pool, losses, y[t], B, n, sigma, delta);
compute_losses(awake_set, pool, losses, y_curr, B, n, sigma, delta);
//update_weights_and_predictions(awake_set, pool, losses, normalizer, y[t]);
update_weights(awake_set, pool, losses, normalizer);
//prev_pred = output;
prev_pred = y_curr;
}
if(duration == -1)
return estimates;
// forecast the upcoming duration
return make_durational_forecast(n,pool,y,duration);
}
PYBIND11_MODULE(covid_lin, m) {
m.doc() = "pybind11 covid plugin"; // optional module docstring
m.def("run_aligator", [](int n, std::vector<double> y, std::vector<int> index, \
double sigma, double B, double delta, int duration) -> py::array {
auto v = run_aligator(n,y,index,sigma,B,delta,duration);
return py::array(v.size(), v.data());
},py::arg("n"), py::arg("index"), py::arg("y"), py::arg("sigma"), \
py::arg("B"), py::arg("delta"), py::arg("duration"));
}
/*
c++ -O3 -Wall -shared -std=c++11 -fPIC `python3 -m pybind11 --includes` covid_lin.cpp -o covid_lin`python3-config --extension-suffix`
*/
| [
"jxy9426@gmail.com"
] | jxy9426@gmail.com |
c5997c4ae0912f3d60847b3e1723402ab6141277 | ad61ceccd4817d9123984d64e73a112867f1e8ea | /C++/BST.cpp | 036be4097cadae892699abdaa109347241c274d1 | [] | no_license | utkarsh-42/Algo | 8cefb8b4484b31939b57c058485d59406a08d2e1 | f574f9df28eb8581a25e73969803c7ebe0db413c | refs/heads/master | 2020-08-12T22:25:15.195826 | 2019-10-13T16:40:26 | 2019-10-13T16:40:26 | 214,854,635 | 0 | 0 | null | 2019-10-13T16:31:51 | 2019-10-13T16:31:51 | null | UTF-8 | C++ | false | false | 2,885 | cpp | #include <iostream>
#include <queue>
#include <stack>
struct node {
int data ;
node *left ;
node *right ;
} ;
class BST {
public :
node *root ;
BST() {
root = NULL ;
}
void insert(int value) {
node *key = new node ;
key->data = value ;
key->left = NULL ;
key->right = NULL ;
if(root == NULL) {
root = key ;
return ;
}
node* temp = new node ;
temp = root ;
while(true) {
if( temp->data > value) {
if(temp->left == NULL) {
temp->left = key ;
return;
}
temp = temp->left ;
}
else {
if(temp->right == NULL) {
temp->right = key ;
return ;
}
temp = temp->right ;
}
}
}
void inorder(node *root) {
if(root == NULL) {
return ;
}
if(root!=NULL) {
inorder(root->left);
std::cout<<root->data<<", " ;
inorder(root->right);
}
}
void preorder(node *root) {
if(root == NULL) {
return ;
}
if(root!=NULL) {
std::cout<<root->data<<", " ;
preorder(root->left);
preorder(root->right);
}
}
void postorder(node *root) {
if(root == NULL) {
return ;
}
if(root!=NULL) {
postorder(root->left);
postorder(root->right);
std::cout<<root->data<<", " ;
}
}
void LevelOrder(node* root) {
if(root==NULL) return ;
std::queue<node*> Q ;
Q.push(root);
while(!Q.empty()) {
node* current = Q.front();
Q.pop();
std::cout<<current->data<<" " ;
if(current->left != NULL) Q.push(current->left);
if(current->right != NULL) Q.push(current->right);
}
}
void InorderIte(node* root) {
std::stack<node*> s ;
node* current = root;
while(!s.empty()|| current !=NULL) {
if(current != NULL) {
s.push(current);
current = current->left ;
}
else{
current = s.top();
s.pop();
std::cout<<current->data<<" ";
current = current->right ;
}
}
}
};
int main() {
BST myTree ;
myTree.insert(11);
myTree.insert(4);
myTree.insert(15);
myTree.insert(2);
myTree.insert(13);
myTree.insert(17);
myTree.inorder(myTree.root);
std::cout<<"\n";
// myTree.preorder(myTree.root);
// std::cout<<"\n";
myTree.LevelOrder(myTree.root);
return 0 ;
}
| [
"noreply@github.com"
] | noreply@github.com |
0749deb0aac2c545578ebead9ff01aa9aa6f49fe | 4499faa7aaed608fc05d1a1b65a54da1beed992b | /Solutions/3.cpp | 087df96980753a71345d308b18e7afb57ea31123 | [] | no_license | Merevoli-DatLuu/OLP_TRAINING | bd1b4f0e5dcceb1fdb62e2570467c1f5eb80ec77 | ca2427df3e8cdc6108a369eeaafe4995497cf63c | refs/heads/master | 2023-02-17T19:38:13.375028 | 2021-01-19T15:16:08 | 2021-01-19T15:16:08 | 322,836,427 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,011 | cpp | // Time: O(n)
// Space: O(1)
class Solution {
public:
vector<int> singleNumber(vector<int>& nums) {
int num_1 = 0;
int k_1 = 0;
// Duyệt từng bit
for (int i=0; i<32; i++){
int sum = 0;
for (int n : nums){
if ((n >> i) & 1){
sum++;
}
}
// Dừng khi gặp bit của số đầu tiên
if (sum % 2 != 0){
k_1 = i;
break;
}
}
// Tìm các số có bit 1 ơ vị trí k_1
for (int i=0; i<nums.size(); i++){
if ((nums[i] >> k_1) & 1){
num_1 ^= nums[i]; // Xor để tìm num_1
}
}
int num_2 = 0;
for (int n : nums){
num_2 ^= n;
}
// Xor num_1 để tìm num_2 (vì num_2 lúc này bằng num_1^num_2)
num_2 ^= num_1;
return {num_1, num_2};
}
}; | [
"47155364+Merevoli-DatLuu@users.noreply.github.com"
] | 47155364+Merevoli-DatLuu@users.noreply.github.com |
bc37b8938a1364ce55ad91f0208689bcec2df023 | 719858b10be8be50e43f56933192ed98d8ca5c00 | /Practica1EDD_201314817/pasajero.cpp | fcc91be3fd1557a4a8e9310c6e53785311d81cd5 | [] | no_license | Reba001/EDD_201314817 | cc92bd12c1593acdf40216b21d2509ee6398caf9 | ba14cac399f67102f820db7a0501eb5511c2c6c2 | refs/heads/master | 2021-09-03T15:27:52.195132 | 2018-01-10T05:05:07 | 2018-01-10T05:05:07 | 113,395,957 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 968 | cpp | #include "pasajero.h"
Pasajero::Pasajero(int documento, int maletas, int id, int turnos)
{
this->documento = documento;
this->maletas = maletas;
this->id = id;
this->turnos = turnos;
}
Pasajero::Pasajero()
{
}
int Pasajero::getMaletas() const
{
return this->maletas;
}
void Pasajero::setMaletas(int value)
{
this->maletas = value;
}
int Pasajero::getId() const
{
return this->id;
}
void Pasajero::setId(int value)
{
this->id = value;
}
int Pasajero::getTurnos() const
{
return this->turnos;
}
void Pasajero::setTurnos(int value)
{
this->turnos = value;
}
string Pasajero::toString()
{
string cadena = "";
cadena += "id: "+ to_string(id) + "\n documento: "+ to_string(documento) + "\n maletas: "+to_string(maletas)+ "\n Turnos: "+to_string(turnos);
return cadena;
}
int Pasajero::getDocumento() const
{
return this->documento;
}
void Pasajero::setDocumento(int value)
{
this->documento = value;
}
| [
"aaperez.tomas@gmail.com"
] | aaperez.tomas@gmail.com |
b6983cdfb511266bd4cad66e66cbaf12f6394b12 | 4e09017a39dae4f85baa05d14b840ff123137ad3 | /Totally Not Zelda/Tile.cpp | 033e4cb1aa2babfb4805af20b81144790d6eeec0 | [] | no_license | KurMax-Studios/Totally_Not_Zelda | 52a32aeb8ef79d6f18cdcc88353991dba69ce701 | d46cf6ba4ba173ee05ddd944da085862abd70ee8 | refs/heads/master | 2021-03-12T20:13:54.163161 | 2014-05-23T13:33:58 | 2014-05-23T13:33:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 97 | cpp | #include "Tile.h"
Tile::Tile()
{
}
Tile::Tile(int idIn)
{
id = idIn;
}
Tile::~Tile(void)
{
}
| [
"emil.jinstrand@gmail.com"
] | emil.jinstrand@gmail.com |
adde353e4770d367e1195b5d4556f685a7aed964 | 740fdf1cca74bdb8f930a7907a48f9bdd9b5fbd3 | /content/browser/download/download_browsertest.cc | b39e04eb3f944ed71eee45ad0a4c02f50a38e930 | [
"BSD-3-Clause"
] | permissive | hefen1/chromium | a1384249e2bb7669df189235a1ff49ac11fc5790 | 52f0b6830e000ca7c5e9aa19488af85be792cc88 | refs/heads/master | 2016-09-05T18:20:24.971432 | 2015-03-23T14:53:29 | 2015-03-23T14:53:29 | 32,579,801 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 69,191 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file contains download browser tests that are known to be runnable
// in a pure content context. Over time tests should be migrated here.
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "content/browser/byte_stream.h"
#include "content/browser/download/download_file_factory.h"
#include "content/browser/download/download_file_impl.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/download_resource_handler.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/power_save_blocker.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/test_file_error_injector.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_download_manager_delegate.h"
#include "content/shell/browser/shell_network_delegate.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/test/url_request/url_request_slow_download_job.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#if defined(ENABLE_PLUGINS)
#include "content/browser/plugin_service_impl.h"
#endif
using ::net::test_server::EmbeddedTestServer;
using ::testing::AllOf;
using ::testing::Field;
using ::testing::InSequence;
using ::testing::Property;
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::_;
namespace content {
namespace {
class MockDownloadItemObserver : public DownloadItem::Observer {
public:
MockDownloadItemObserver() {}
virtual ~MockDownloadItemObserver() {}
MOCK_METHOD1(OnDownloadUpdated, void(DownloadItem*));
MOCK_METHOD1(OnDownloadOpened, void(DownloadItem*));
MOCK_METHOD1(OnDownloadRemoved, void(DownloadItem*));
MOCK_METHOD1(OnDownloadDestroyed, void(DownloadItem*));
};
class MockDownloadManagerObserver : public DownloadManager::Observer {
public:
MockDownloadManagerObserver(DownloadManager* manager) {
manager_ = manager;
manager->AddObserver(this);
}
virtual ~MockDownloadManagerObserver() {
if (manager_)
manager_->RemoveObserver(this);
}
MOCK_METHOD2(OnDownloadCreated, void(DownloadManager*, DownloadItem*));
MOCK_METHOD1(ModelChanged, void(DownloadManager*));
void ManagerGoingDown(DownloadManager* manager) {
DCHECK_EQ(manager_, manager);
MockManagerGoingDown(manager);
manager_->RemoveObserver(this);
manager_ = NULL;
}
MOCK_METHOD1(MockManagerGoingDown, void(DownloadManager*));
private:
DownloadManager* manager_;
};
class DownloadFileWithDelayFactory;
static DownloadManagerImpl* DownloadManagerForShell(Shell* shell) {
// We're in a content_browsertest; we know that the DownloadManager
// is a DownloadManagerImpl.
return static_cast<DownloadManagerImpl*>(
BrowserContext::GetDownloadManager(
shell->web_contents()->GetBrowserContext()));
}
class DownloadFileWithDelay : public DownloadFileImpl {
public:
DownloadFileWithDelay(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
scoped_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer,
base::WeakPtr<DownloadFileWithDelayFactory> owner);
~DownloadFileWithDelay() override;
// Wraps DownloadFileImpl::Rename* and intercepts the return callback,
// storing it in the factory that produced this object for later
// retrieval.
void RenameAndUniquify(const base::FilePath& full_path,
const RenameCompletionCallback& callback) override;
void RenameAndAnnotate(const base::FilePath& full_path,
const RenameCompletionCallback& callback) override;
private:
static void RenameCallbackWrapper(
const base::WeakPtr<DownloadFileWithDelayFactory>& factory,
const RenameCompletionCallback& original_callback,
DownloadInterruptReason reason,
const base::FilePath& path);
// This variable may only be read on the FILE thread, and may only be
// indirected through (e.g. methods on DownloadFileWithDelayFactory called)
// on the UI thread. This is because after construction,
// DownloadFileWithDelay lives on the file thread, but
// DownloadFileWithDelayFactory is purely a UI thread object.
base::WeakPtr<DownloadFileWithDelayFactory> owner_;
DISALLOW_COPY_AND_ASSIGN(DownloadFileWithDelay);
};
// All routines on this class must be called on the UI thread.
class DownloadFileWithDelayFactory : public DownloadFileFactory {
public:
DownloadFileWithDelayFactory();
~DownloadFileWithDelayFactory() override;
// DownloadFileFactory interface.
DownloadFile* CreateFile(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
base::WeakPtr<DownloadDestinationObserver> observer) override;
void AddRenameCallback(base::Closure callback);
void GetAllRenameCallbacks(std::vector<base::Closure>* results);
// Do not return until GetAllRenameCallbacks() will return a non-empty list.
void WaitForSomeCallback();
private:
std::vector<base::Closure> rename_callbacks_;
bool waiting_;
base::WeakPtrFactory<DownloadFileWithDelayFactory> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DownloadFileWithDelayFactory);
};
DownloadFileWithDelay::DownloadFileWithDelay(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
scoped_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer,
base::WeakPtr<DownloadFileWithDelayFactory> owner)
: DownloadFileImpl(
save_info.Pass(), default_download_directory, url, referrer_url,
calculate_hash, stream.Pass(), bound_net_log, observer),
owner_(owner) {}
DownloadFileWithDelay::~DownloadFileWithDelay() {}
void DownloadFileWithDelay::RenameAndUniquify(
const base::FilePath& full_path,
const RenameCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DownloadFileImpl::RenameAndUniquify(
full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper,
owner_, callback));
}
void DownloadFileWithDelay::RenameAndAnnotate(
const base::FilePath& full_path, const RenameCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DownloadFileImpl::RenameAndAnnotate(
full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper,
owner_, callback));
}
// static
void DownloadFileWithDelay::RenameCallbackWrapper(
const base::WeakPtr<DownloadFileWithDelayFactory>& factory,
const RenameCompletionCallback& original_callback,
DownloadInterruptReason reason,
const base::FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!factory)
return;
factory->AddRenameCallback(base::Bind(original_callback, reason, path));
}
DownloadFileWithDelayFactory::DownloadFileWithDelayFactory()
: waiting_(false),
weak_ptr_factory_(this) {}
DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {}
DownloadFile* DownloadFileWithDelayFactory::CreateFile(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_download_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
base::WeakPtr<DownloadDestinationObserver> observer) {
scoped_ptr<PowerSaveBlocker> psb(
PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
"Download in progress"));
return new DownloadFileWithDelay(
save_info.Pass(), default_download_directory, url, referrer_url,
calculate_hash, stream.Pass(), bound_net_log,
psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr());
}
void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
rename_callbacks_.push_back(callback);
if (waiting_)
base::MessageLoopForUI::current()->Quit();
}
void DownloadFileWithDelayFactory::GetAllRenameCallbacks(
std::vector<base::Closure>* results) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
results->swap(rename_callbacks_);
}
void DownloadFileWithDelayFactory::WaitForSomeCallback() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (rename_callbacks_.empty()) {
waiting_ = true;
RunMessageLoop();
waiting_ = false;
}
}
class CountingDownloadFile : public DownloadFileImpl {
public:
CountingDownloadFile(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_downloads_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
scoped_ptr<PowerSaveBlocker> power_save_blocker,
base::WeakPtr<DownloadDestinationObserver> observer)
: DownloadFileImpl(save_info.Pass(), default_downloads_directory,
url, referrer_url, calculate_hash,
stream.Pass(), bound_net_log, observer) {}
~CountingDownloadFile() override {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
active_files_--;
}
void Initialize(const InitializeCallback& callback) override {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
active_files_++;
return DownloadFileImpl::Initialize(callback);
}
static void GetNumberActiveFiles(int* result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
*result = active_files_;
}
// Can be called on any thread, and will block (running message loop)
// until data is returned.
static int GetNumberActiveFilesFromFileThread() {
int result = -1;
BrowserThread::PostTaskAndReply(
BrowserThread::FILE,
FROM_HERE,
base::Bind(&CountingDownloadFile::GetNumberActiveFiles, &result),
base::MessageLoop::current()->QuitClosure());
base::MessageLoop::current()->Run();
DCHECK_NE(-1, result);
return result;
}
private:
static int active_files_;
};
int CountingDownloadFile::active_files_ = 0;
class CountingDownloadFileFactory : public DownloadFileFactory {
public:
CountingDownloadFileFactory() {}
~CountingDownloadFileFactory() override {}
// DownloadFileFactory interface.
DownloadFile* CreateFile(
scoped_ptr<DownloadSaveInfo> save_info,
const base::FilePath& default_downloads_directory,
const GURL& url,
const GURL& referrer_url,
bool calculate_hash,
scoped_ptr<ByteStreamReader> stream,
const net::BoundNetLog& bound_net_log,
base::WeakPtr<DownloadDestinationObserver> observer) override {
scoped_ptr<PowerSaveBlocker> psb(
PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
"Download in progress"));
return new CountingDownloadFile(
save_info.Pass(), default_downloads_directory, url, referrer_url,
calculate_hash, stream.Pass(), bound_net_log,
psb.Pass(), observer);
}
};
class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate {
public:
TestShellDownloadManagerDelegate()
: delay_download_open_(false) {}
~TestShellDownloadManagerDelegate() override {}
bool ShouldOpenDownload(
DownloadItem* item,
const DownloadOpenDelayedCallback& callback) override {
if (delay_download_open_) {
delayed_callbacks_.push_back(callback);
return false;
}
return true;
}
void SetDelayedOpen(bool delay) {
delay_download_open_ = delay;
}
void GetDelayedCallbacks(
std::vector<DownloadOpenDelayedCallback>* callbacks) {
callbacks->swap(delayed_callbacks_);
}
private:
bool delay_download_open_;
std::vector<DownloadOpenDelayedCallback> delayed_callbacks_;
};
// Record all state transitions and byte counts on the observed download.
class RecordingDownloadObserver : DownloadItem::Observer {
public:
struct RecordStruct {
DownloadItem::DownloadState state;
int bytes_received;
};
typedef std::vector<RecordStruct> RecordVector;
RecordingDownloadObserver(DownloadItem* download)
: download_(download) {
last_state_.state = download->GetState();
last_state_.bytes_received = download->GetReceivedBytes();
download_->AddObserver(this);
}
~RecordingDownloadObserver() override { RemoveObserver(); }
void CompareToExpectedRecord(const RecordStruct expected[], size_t size) {
EXPECT_EQ(size, record_.size());
int min = size > record_.size() ? record_.size() : size;
for (int i = 0; i < min; ++i) {
EXPECT_EQ(expected[i].state, record_[i].state) << "Iteration " << i;
EXPECT_EQ(expected[i].bytes_received, record_[i].bytes_received)
<< "Iteration " << i;
}
}
private:
void OnDownloadUpdated(DownloadItem* download) override {
DCHECK_EQ(download_, download);
DownloadItem::DownloadState state = download->GetState();
int bytes = download->GetReceivedBytes();
if (last_state_.state != state || last_state_.bytes_received > bytes) {
last_state_.state = state;
last_state_.bytes_received = bytes;
record_.push_back(last_state_);
}
}
void OnDownloadDestroyed(DownloadItem* download) override {
DCHECK_EQ(download_, download);
RemoveObserver();
}
void RemoveObserver() {
if (download_) {
download_->RemoveObserver(this);
download_ = NULL;
}
}
DownloadItem* download_;
RecordStruct last_state_;
RecordVector record_;
};
// Get the next created download.
class DownloadCreateObserver : DownloadManager::Observer {
public:
DownloadCreateObserver(DownloadManager* manager)
: manager_(manager),
item_(NULL),
waiting_(false) {
manager_->AddObserver(this);
}
~DownloadCreateObserver() override {
if (manager_)
manager_->RemoveObserver(this);
manager_ = NULL;
}
void ManagerGoingDown(DownloadManager* manager) override {
DCHECK_EQ(manager_, manager);
manager_->RemoveObserver(this);
manager_ = NULL;
}
void OnDownloadCreated(DownloadManager* manager,
DownloadItem* download) override {
if (!item_)
item_ = download;
if (waiting_)
base::MessageLoopForUI::current()->Quit();
}
DownloadItem* WaitForFinished() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!item_) {
waiting_ = true;
RunMessageLoop();
waiting_ = false;
}
return item_;
}
private:
DownloadManager* manager_;
DownloadItem* item_;
bool waiting_;
};
// Filter for waiting for a certain number of bytes.
bool DataReceivedFilter(int number_of_bytes, DownloadItem* download) {
return download->GetReceivedBytes() >= number_of_bytes;
}
// Filter for download completion.
bool DownloadCompleteFilter(DownloadItem* download) {
return download->GetState() == DownloadItem::COMPLETE;
}
// Filter for saving the size of the download when the first IN_PROGRESS
// is hit.
bool InitialSizeFilter(int* download_size, DownloadItem* download) {
if (download->GetState() != DownloadItem::IN_PROGRESS)
return false;
*download_size = download->GetReceivedBytes();
return true;
}
// Request handler to be used with CreateRedirectHandler().
scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendRedirectResponse(
const std::string& relative_url,
const GURL& target_url,
const net::test_server::HttpRequest& request) {
scoped_ptr<net::test_server::BasicHttpResponse> response;
if (request.relative_url == relative_url) {
response.reset(new net::test_server::BasicHttpResponse);
response->set_code(net::HTTP_FOUND);
response->AddCustomHeader("Location", target_url.spec());
}
return response.Pass();
}
// Creates a request handler for EmbeddedTestServer that responds with a HTTP
// 302 redirect if the request URL matches |relative_url|.
EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler(
const std::string& relative_url,
const GURL& target_url) {
return base::Bind(
&HandleRequestAndSendRedirectResponse, relative_url, target_url);
}
// Request handler to be used with CreateBasicResponseHandler().
scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse(
const std::string& relative_url,
const std::string& content_type,
const std::string& body,
const net::test_server::HttpRequest& request) {
scoped_ptr<net::test_server::BasicHttpResponse> response;
if (request.relative_url == relative_url) {
response.reset(new net::test_server::BasicHttpResponse);
response->set_content_type(content_type);
response->set_content(body);
}
return response.Pass();
}
// Creates a request handler for an EmbeddedTestServer that response with an
// HTTP 200 status code, a Content-Type header and a body.
EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler(
const std::string& relative_url,
const std::string& content_type,
const std::string& body) {
return base::Bind(
&HandleRequestAndSendBasicResponse, relative_url, content_type, body);
}
} // namespace
class DownloadContentTest : public ContentBrowserTest {
protected:
// An initial send from a website of at least this size will not be
// help up by buffering in the underlying downloads ByteStream data
// transfer. This is important because on resumption tests we wait
// until we've gotten the data we expect before allowing the test server
// to send its reset, to get around hard close semantics on the Windows
// socket layer implementation.
int GetSafeBufferChunk() const {
return (DownloadResourceHandler::kDownloadByteStreamSize /
ByteStreamWriter::kFractionBufferBeforeSending) + 1;
}
void SetUpOnMainThread() override {
ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir());
test_delegate_.reset(new TestShellDownloadManagerDelegate());
test_delegate_->SetDownloadBehaviorForTesting(downloads_directory_.path());
DownloadManager* manager = DownloadManagerForShell(shell());
manager->GetDelegate()->Shutdown();
manager->SetDelegate(test_delegate_.get());
test_delegate_->SetDownloadManager(manager);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler));
base::FilePath mock_base(GetTestFilePath("download", ""));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
&net::URLRequestMockHTTPJob::AddUrlHandlers, mock_base,
make_scoped_refptr(content::BrowserThread::GetBlockingPool())));
}
TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() {
return test_delegate_.get();
}
// Create a DownloadTestObserverTerminal that will wait for the
// specified number of downloads to finish.
DownloadTestObserver* CreateWaiter(
Shell* shell, int num_downloads) {
DownloadManager* download_manager = DownloadManagerForShell(shell);
return new DownloadTestObserverTerminal(download_manager, num_downloads,
DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
}
// Create a DownloadTestObserverInProgress that will wait for the
// specified number of downloads to start.
DownloadCreateObserver* CreateInProgressWaiter(
Shell* shell, int num_downloads) {
DownloadManager* download_manager = DownloadManagerForShell(shell);
return new DownloadCreateObserver(download_manager);
}
DownloadTestObserver* CreateInterruptedWaiter(
Shell* shell, int num_downloads) {
DownloadManager* download_manager = DownloadManagerForShell(shell);
return new DownloadTestObserverInterrupted(download_manager, num_downloads,
DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
}
// Note: Cannot be used with other alternative DownloadFileFactorys
void SetupEnsureNoPendingDownloads() {
DownloadManagerForShell(shell())->SetDownloadFileFactoryForTesting(
scoped_ptr<DownloadFileFactory>(
new CountingDownloadFileFactory()).Pass());
}
bool EnsureNoPendingDownloads() {
bool result = true;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&EnsureNoPendingDownloadJobsOnIO, &result));
base::MessageLoop::current()->Run();
return result &&
(CountingDownloadFile::GetNumberActiveFilesFromFileThread() == 0);
}
void NavigateToURLAndWaitForDownload(
Shell* shell,
const GURL& url,
DownloadItem::DownloadState expected_terminal_state) {
scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell, 1));
NavigateToURL(shell, url);
observer->WaitForFinished();
EXPECT_EQ(1u, observer->NumDownloadsSeenInState(expected_terminal_state));
}
// Checks that |path| is has |file_size| bytes, and matches the |value|
// string.
bool VerifyFile(const base::FilePath& path,
const std::string& value,
const int64 file_size) {
std::string file_contents;
bool read = base::ReadFileToString(path, &file_contents);
EXPECT_TRUE(read) << "Failed reading file: " << path.value() << std::endl;
if (!read)
return false; // Couldn't read the file.
// Note: we don't handle really large files (more than size_t can hold)
// so we will fail in that case.
size_t expected_size = static_cast<size_t>(file_size);
// Check the size.
EXPECT_EQ(expected_size, file_contents.size());
if (expected_size != file_contents.size())
return false;
// Check the contents.
EXPECT_EQ(value, file_contents);
if (memcmp(file_contents.c_str(), value.c_str(), expected_size) != 0)
return false;
return true;
}
// Start a download and return the item.
DownloadItem* StartDownloadAndReturnItem(GURL url) {
scoped_ptr<DownloadCreateObserver> observer(
CreateInProgressWaiter(shell(), 1));
NavigateToURL(shell(), url);
observer->WaitForFinished();
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
EXPECT_EQ(1u, downloads.size());
if (1u != downloads.size())
return NULL;
return downloads[0];
}
// Wait for data
void WaitForData(DownloadItem* download, int size) {
DownloadUpdatedObserver data_observer(
download, base::Bind(&DataReceivedFilter, size));
data_observer.WaitForEvent();
ASSERT_EQ(size, download->GetReceivedBytes());
ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState());
}
// Tell the test server to release a pending RST and confirm
// that the interrupt is received properly (for download resumption
// testing).
void ReleaseRSTAndConfirmInterruptForResume(DownloadItem* download) {
scoped_ptr<DownloadTestObserver> rst_observer(
CreateInterruptedWaiter(shell(), 1));
NavigateToURL(shell(), test_server()->GetURL("download-finish"));
rst_observer->WaitForFinished();
EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState());
}
// Confirm file status expected for the given location in a stream
// provided by the resume test server.
void ConfirmFileStatusForResume(
DownloadItem* download, bool file_exists,
int received_bytes, int total_bytes,
const base::FilePath& expected_filename) {
// expected_filename is only known if the file exists.
ASSERT_EQ(file_exists, !expected_filename.empty());
EXPECT_EQ(received_bytes, download->GetReceivedBytes());
EXPECT_EQ(total_bytes, download->GetTotalBytes());
EXPECT_EQ(expected_filename.value(),
download->GetFullPath().BaseName().value());
EXPECT_EQ(file_exists,
(!download->GetFullPath().empty() &&
base::PathExists(download->GetFullPath())));
if (file_exists) {
std::string file_contents;
EXPECT_TRUE(base::ReadFileToString(
download->GetFullPath(), &file_contents));
ASSERT_EQ(static_cast<size_t>(received_bytes), file_contents.size());
for (int i = 0; i < received_bytes; ++i) {
EXPECT_EQ(static_cast<char>((i * 2 + 15) % 256), file_contents[i])
<< "File contents diverged at position " << i
<< " for " << expected_filename.value();
if (static_cast<char>((i * 2 + 15) % 256) != file_contents[i])
return;
}
}
}
private:
static void EnsureNoPendingDownloadJobsOnIO(bool* result) {
if (net::URLRequestSlowDownloadJob::NumberOutstandingRequests())
*result = false;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure());
}
// Location of the downloads directory for these tests
base::ScopedTempDir downloads_directory_;
scoped_ptr<TestShellDownloadManagerDelegate> test_delegate_;
};
IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadCancelled) {
SetupEnsureNoPendingDownloads();
// Create a download, wait until it's started, and confirm
// we're in the expected state.
scoped_ptr<DownloadCreateObserver> observer(
CreateInProgressWaiter(shell(), 1));
NavigateToURL(shell(), GURL(net::URLRequestSlowDownloadJob::kUnknownSizeUrl));
observer->WaitForFinished();
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
// Cancel the download and wait for download system quiesce.
downloads[0]->Cancel(true);
scoped_refptr<DownloadTestFlushObserver> flush_observer(
new DownloadTestFlushObserver(DownloadManagerForShell(shell())));
flush_observer->WaitForFlush();
// Get the important info from other threads and check it.
EXPECT_TRUE(EnsureNoPendingDownloads());
}
// Check that downloading multiple (in this case, 2) files does not result in
// corrupted files.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, MultiDownload) {
SetupEnsureNoPendingDownloads();
// Create a download, wait until it's started, and confirm
// we're in the expected state.
scoped_ptr<DownloadCreateObserver> observer1(
CreateInProgressWaiter(shell(), 1));
NavigateToURL(shell(), GURL(net::URLRequestSlowDownloadJob::kUnknownSizeUrl));
observer1->WaitForFinished();
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
ASSERT_EQ(DownloadItem::IN_PROGRESS, downloads[0]->GetState());
DownloadItem* download1 = downloads[0]; // The only download.
// Start the second download and wait until it's done.
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file));
// Download the file and wait.
NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE);
// Should now have 2 items on the manager.
downloads.clear();
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(2u, downloads.size());
// We don't know the order of the downloads.
DownloadItem* download2 = downloads[(download1 == downloads[0]) ? 1 : 0];
ASSERT_EQ(DownloadItem::IN_PROGRESS, download1->GetState());
ASSERT_EQ(DownloadItem::COMPLETE, download2->GetState());
// Allow the first request to finish.
scoped_ptr<DownloadTestObserver> observer2(CreateWaiter(shell(), 1));
NavigateToURL(shell(),
GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
observer2->WaitForFinished(); // Wait for the third request.
EXPECT_EQ(1u, observer2->NumDownloadsSeenInState(DownloadItem::COMPLETE));
// Get the important info from other threads and check it.
EXPECT_TRUE(EnsureNoPendingDownloads());
// The |DownloadItem|s should now be done and have the final file names.
// Verify that the files have the expected data and size.
// |file1| should be full of '*'s, and |file2| should be the same as the
// source file.
base::FilePath file1(download1->GetTargetFilePath());
size_t file_size1 = net::URLRequestSlowDownloadJob::kFirstDownloadSize +
net::URLRequestSlowDownloadJob::kSecondDownloadSize;
std::string expected_contents(file_size1, '*');
ASSERT_TRUE(VerifyFile(file1, expected_contents, file_size1));
base::FilePath file2(download2->GetTargetFilePath());
ASSERT_TRUE(base::ContentsEqual(
file2, GetTestFilePath("download", "download-test.lib")));
}
#if defined(ENABLE_PLUGINS)
// Content served with a MIME type of application/octet-stream should be
// downloaded even when a plugin can be found that handles the file type.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadOctetStream) {
const base::FilePath::CharType kTestFilePath[] =
FILE_PATH_LITERAL("octet-stream.abc");
const char kTestPluginName[] = "TestPlugin";
const char kTestMimeType[] = "application/x-test-mime-type";
const char kTestFileType[] = "abc";
WebPluginInfo plugin_info;
plugin_info.name = base::ASCIIToUTF16(kTestPluginName);
plugin_info.mime_types.push_back(
WebPluginMimeType(kTestMimeType, kTestFileType, ""));
plugin_info.type = WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS;
PluginServiceImpl::GetInstance()->RegisterInternalPlugin(plugin_info, false);
// The following is served with a Content-Type of application/octet-stream.
GURL url(
net::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kTestFilePath)));
NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE);
}
#endif
// Try to cancel just before we release the download file, by delaying final
// rename callback.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) {
// Setup new factory.
DownloadFileWithDelayFactory* file_factory =
new DownloadFileWithDelayFactory();
DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
download_manager->SetDownloadFileFactoryForTesting(
scoped_ptr<DownloadFileFactory>(file_factory).Pass());
// Create a download
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file));
// Wait until the first (intermediate file) rename and execute the callback.
file_factory->WaitForSomeCallback();
std::vector<base::Closure> callbacks;
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
callbacks[0].Run();
callbacks.clear();
// Wait until the second (final) rename callback is posted.
file_factory->WaitForSomeCallback();
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
// Cancel it.
std::vector<DownloadItem*> items;
download_manager->GetAllDownloads(&items);
ASSERT_EQ(1u, items.size());
items[0]->Cancel(true);
RunAllPendingInMessageLoop();
// Check state.
EXPECT_EQ(DownloadItem::CANCELLED, items[0]->GetState());
// Run final rename callback.
callbacks[0].Run();
callbacks.clear();
// Check state.
EXPECT_EQ(DownloadItem::CANCELLED, items[0]->GetState());
}
// Try to cancel just after we release the download file, by delaying
// in ShouldOpenDownload.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtRelease) {
DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
// Mark delegate for delayed open.
GetDownloadManagerDelegate()->SetDelayedOpen(true);
// Setup new factory.
DownloadFileWithDelayFactory* file_factory =
new DownloadFileWithDelayFactory();
download_manager->SetDownloadFileFactoryForTesting(
scoped_ptr<DownloadFileFactory>(file_factory).Pass());
// Create a download
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file));
// Wait until the first (intermediate file) rename and execute the callback.
file_factory->WaitForSomeCallback();
std::vector<base::Closure> callbacks;
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
callbacks[0].Run();
callbacks.clear();
// Wait until the second (final) rename callback is posted.
file_factory->WaitForSomeCallback();
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
// Call it.
callbacks[0].Run();
callbacks.clear();
// Confirm download still IN_PROGRESS (internal state COMPLETING).
std::vector<DownloadItem*> items;
download_manager->GetAllDownloads(&items);
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
// Cancel the download; confirm cancel fails.
ASSERT_EQ(1u, items.size());
items[0]->Cancel(true);
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
// Need to complete open test.
std::vector<DownloadOpenDelayedCallback> delayed_callbacks;
GetDownloadManagerDelegate()->GetDelayedCallbacks(
&delayed_callbacks);
ASSERT_EQ(1u, delayed_callbacks.size());
delayed_callbacks[0].Run(true);
// *Now* the download should be complete.
EXPECT_EQ(DownloadItem::COMPLETE, items[0]->GetState());
}
// Try to shutdown with a download in progress to make sure shutdown path
// works properly.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownInProgress) {
// Create a download that won't complete.
scoped_ptr<DownloadCreateObserver> observer(
CreateInProgressWaiter(shell(), 1));
NavigateToURL(shell(), GURL(net::URLRequestSlowDownloadJob::kUnknownSizeUrl));
observer->WaitForFinished();
// Get the item.
std::vector<DownloadItem*> items;
DownloadManagerForShell(shell())->GetAllDownloads(&items);
ASSERT_EQ(1u, items.size());
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
// Shutdown the download manager and make sure we get the right
// notifications in the right order.
StrictMock<MockDownloadItemObserver> item_observer;
items[0]->AddObserver(&item_observer);
MockDownloadManagerObserver manager_observer(
DownloadManagerForShell(shell()));
// Don't care about ModelChanged() events.
EXPECT_CALL(manager_observer, ModelChanged(_))
.WillRepeatedly(Return());
{
InSequence notifications;
EXPECT_CALL(manager_observer, MockManagerGoingDown(
DownloadManagerForShell(shell())))
.WillOnce(Return());
EXPECT_CALL(item_observer, OnDownloadUpdated(
AllOf(items[0],
Property(&DownloadItem::GetState, DownloadItem::CANCELLED))))
.WillOnce(Return());
EXPECT_CALL(item_observer, OnDownloadDestroyed(items[0]))
.WillOnce(Return());
}
// See http://crbug.com/324525. If we have a refcount release/post task
// race, the second post will stall the IO thread long enough so that we'll
// lose the race and crash. The first stall is just to give the UI thread
// a chance to get the second stall onto the IO thread queue after the cancel
// message created by Shutdown and before the notification callback
// created by the IO thread in canceling the request.
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&base::PlatformThread::Sleep,
base::TimeDelta::FromMilliseconds(25)));
DownloadManagerForShell(shell())->Shutdown();
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&base::PlatformThread::Sleep,
base::TimeDelta::FromMilliseconds(25)));
items.clear();
}
// Try to shutdown just after we release the download file, by delaying
// release.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownAtRelease) {
DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
// Mark delegate for delayed open.
GetDownloadManagerDelegate()->SetDelayedOpen(true);
// Setup new factory.
DownloadFileWithDelayFactory* file_factory =
new DownloadFileWithDelayFactory();
download_manager->SetDownloadFileFactoryForTesting(
scoped_ptr<DownloadFileFactory>(file_factory).Pass());
// Create a download
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
NavigateToURL(shell(), net::URLRequestMockHTTPJob::GetMockUrl(file));
// Wait until the first (intermediate file) rename and execute the callback.
file_factory->WaitForSomeCallback();
std::vector<base::Closure> callbacks;
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
callbacks[0].Run();
callbacks.clear();
// Wait until the second (final) rename callback is posted.
file_factory->WaitForSomeCallback();
file_factory->GetAllRenameCallbacks(&callbacks);
ASSERT_EQ(1u, callbacks.size());
// Call it.
callbacks[0].Run();
callbacks.clear();
// Confirm download isn't complete yet.
std::vector<DownloadItem*> items;
DownloadManagerForShell(shell())->GetAllDownloads(&items);
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
// Cancel the download; confirm cancel fails anyway.
ASSERT_EQ(1u, items.size());
items[0]->Cancel(true);
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
RunAllPendingInMessageLoop();
EXPECT_EQ(DownloadItem::IN_PROGRESS, items[0]->GetState());
MockDownloadItemObserver observer;
items[0]->AddObserver(&observer);
EXPECT_CALL(observer, OnDownloadDestroyed(items[0]));
// Shutdown the download manager. Mostly this is confirming a lack of
// crashes.
DownloadManagerForShell(shell())->Shutdown();
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(
base::StringPrintf("rangereset?size=%d&rst_boundary=%d",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell()));
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1);
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
::testing::Mock::VerifyAndClearExpectations(&dm_observer);
// Confirm resumption while in progress doesn't do anything.
download->Resume();
ASSERT_EQ(GetSafeBufferChunk(), download->GetReceivedBytes());
ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState());
// Tell the server to send the RST and confirm the interrupt happens.
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
// Resume, confirming received bytes on resumption is correct.
// Make sure no creation calls are included.
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(0);
int initial_size = 0;
DownloadUpdatedObserver initial_size_observer(
download, base::Bind(&InitialSizeFilter, &initial_size));
download->Resume();
initial_size_observer.WaitForEvent();
EXPECT_EQ(GetSafeBufferChunk(), initial_size);
::testing::Mock::VerifyAndClearExpectations(&dm_observer);
// and wait for expected data.
WaitForData(download, GetSafeBufferChunk() * 2);
// Tell the server to send the RST and confirm the interrupt happens.
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 2, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
// Resume and wait for completion.
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset")));
// Confirm resumption while complete doesn't do anything.
download->Resume();
ASSERT_EQ(GetSafeBufferChunk() * 3, download->GetReceivedBytes());
ASSERT_EQ(DownloadItem::COMPLETE, download->GetState());
RunAllPendingInMessageLoop();
ASSERT_EQ(GetSafeBufferChunk() * 3, download->GetReceivedBytes());
ASSERT_EQ(DownloadItem::COMPLETE, download->GetState());
}
// Confirm restart fallback happens if a range request is bounced.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
// Auto-restart if server doesn't handle ranges.
GURL url = test_server()->GetURL(
base::StringPrintf(
// First download hits an RST, rest don't, no ranges.
"rangereset?size=%d&rst_boundary=%d&"
"token=NoRange&rst_limit=1&bounce_range",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
// Start the download and wait for first data chunk.
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
RecordingDownloadObserver recorder(download);
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset")));
static const RecordingDownloadObserver::RecordStruct expected_record[] = {
// Result of RST
{DownloadItem::INTERRUPTED, GetSafeBufferChunk()},
// Starting continuation
{DownloadItem::IN_PROGRESS, GetSafeBufferChunk()},
// Notification of receiving whole file.
{DownloadItem::IN_PROGRESS, 0},
// Completion.
{DownloadItem::COMPLETE, GetSafeBufferChunk() * 3},
};
recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record));
}
// Confirm restart fallback happens if a precondition is failed.
IN_PROC_BROWSER_TEST_F(DownloadContentTest,
ResumeInterruptedDownloadBadPrecondition) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(base::StringPrintf(
// First download hits an RST, rest don't, precondition fail.
"rangereset?size=%d&rst_boundary=%d&"
"token=BadPrecondition&rst_limit=1&fail_precondition=2",
GetSafeBufferChunk() * 3,
GetSafeBufferChunk()));
// Start the download and wait for first data chunk.
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
RecordingDownloadObserver recorder(download);
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
EXPECT_EQ("BadPrecondition2", download->GetETag());
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset")));
EXPECT_EQ("BadPrecondition0", download->GetETag());
static const RecordingDownloadObserver::RecordStruct expected_record[] = {
// Result of RST
{DownloadItem::INTERRUPTED, GetSafeBufferChunk()},
// Starting continuation
{DownloadItem::IN_PROGRESS, GetSafeBufferChunk()},
// Server precondition fail.
{DownloadItem::INTERRUPTED, 0},
// Notification of successful restart.
{DownloadItem::IN_PROGRESS, 0},
// Completion.
{DownloadItem::COMPLETE, GetSafeBufferChunk() * 3},
};
recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record));
}
// Confirm we don't try to resume if we don't have a verifier.
IN_PROC_BROWSER_TEST_F(DownloadContentTest,
ResumeInterruptedDownloadNoVerifiers) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(
base::StringPrintf(
// First download hits an RST, rest don't, no verifiers.
"rangereset?size=%d&rst_boundary=%d&"
"token=NoRange&rst_limit=1&no_verifiers",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
// Start the download and wait for first data chunk.
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
RecordingDownloadObserver recorder(download);
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, false, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath());
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset")));
static const RecordingDownloadObserver::RecordStruct expected_record[] = {
// Result of RST
{DownloadItem::INTERRUPTED, GetSafeBufferChunk()},
// Restart for lack of verifiers
{DownloadItem::IN_PROGRESS, 0},
// Completion.
{DownloadItem::COMPLETE, GetSafeBufferChunk() * 3},
};
recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record));
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(
base::StringPrintf(
// First download hits an RST, rest don't
"rangereset?size=%d&rst_boundary=%d&"
"token=NoRange&rst_limit=1",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
// Start the download and wait for first data chunk.
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
RecordingDownloadObserver recorder(download);
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
// Delete the intermediate file.
base::DeleteFile(download->GetFullPath(), false);
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk() * 3, GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset")));
static const RecordingDownloadObserver::RecordStruct expected_record[] = {
// Result of RST
{DownloadItem::INTERRUPTED, GetSafeBufferChunk()},
// Starting continuation
{DownloadItem::IN_PROGRESS, GetSafeBufferChunk()},
// Error because file isn't there.
{DownloadItem::INTERRUPTED, 0},
// Restart.
{DownloadItem::IN_PROGRESS, 0},
// Completion.
{DownloadItem::COMPLETE, GetSafeBufferChunk() * 3},
};
recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record));
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileInitError) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file));
// Setup the error injector.
scoped_refptr<TestFileErrorInjector> injector(
TestFileErrorInjector::Create(DownloadManagerForShell(shell())));
TestFileErrorInjector::FileErrorInfo err = {
url.spec(),
TestFileErrorInjector::FILE_OPERATION_INITIALIZE,
0,
DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE
};
injector->AddError(err);
injector->InjectErrors();
// Start and watch for interrupt.
scoped_ptr<DownloadTestObserver> int_observer(
CreateInterruptedWaiter(shell(), 1));
DownloadItem* download(StartDownloadAndReturnItem(url));
int_observer->WaitForFinished();
ASSERT_EQ(DownloadItem::INTERRUPTED, download->GetState());
EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE,
download->GetLastReason());
EXPECT_EQ(0, download->GetReceivedBytes());
EXPECT_TRUE(download->GetFullPath().empty());
EXPECT_TRUE(download->GetTargetFilePath().empty());
// We need to make sure that any cross-thread downloads communication has
// quiesced before clearing and injecting the new errors, as the
// InjectErrors() routine alters the currently in use download file
// factory, which is a file thread object.
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// Clear the old errors list.
injector->ClearErrors();
injector->InjectErrors();
// Resume and watch completion.
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE);
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest,
ResumeWithFileIntermediateRenameError) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file));
// Setup the error injector.
scoped_refptr<TestFileErrorInjector> injector(
TestFileErrorInjector::Create(DownloadManagerForShell(shell())));
TestFileErrorInjector::FileErrorInfo err = {
url.spec(),
TestFileErrorInjector::FILE_OPERATION_RENAME_UNIQUIFY,
0,
DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE
};
injector->AddError(err);
injector->InjectErrors();
// Start and watch for interrupt.
scoped_ptr<DownloadTestObserver> int_observer(
CreateInterruptedWaiter(shell(), 1));
DownloadItem* download(StartDownloadAndReturnItem(url));
int_observer->WaitForFinished();
ASSERT_EQ(DownloadItem::INTERRUPTED, download->GetState());
EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE,
download->GetLastReason());
EXPECT_TRUE(download->GetFullPath().empty());
// Target path will have been set after file name determination. GetFullPath()
// being empty is sufficient to signal that filename determination needs to be
// redone.
EXPECT_FALSE(download->GetTargetFilePath().empty());
// We need to make sure that any cross-thread downloads communication has
// quiesced before clearing and injecting the new errors, as the
// InjectErrors() routine alters the currently in use download file
// factory, which is a file thread object.
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// Clear the old errors list.
injector->ClearErrors();
injector->InjectErrors();
// Resume and watch completion.
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE);
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileFinalRenameError) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
base::FilePath file(FILE_PATH_LITERAL("download-test.lib"));
GURL url(net::URLRequestMockHTTPJob::GetMockUrl(file));
// Setup the error injector.
scoped_refptr<TestFileErrorInjector> injector(
TestFileErrorInjector::Create(DownloadManagerForShell(shell())));
DownloadManagerForShell(shell())->RemoveAllDownloads();
TestFileErrorInjector::FileErrorInfo err = {
url.spec(),
TestFileErrorInjector::FILE_OPERATION_RENAME_ANNOTATE,
0,
DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE
};
injector->AddError(err);
injector->InjectErrors();
// Start and watch for interrupt.
scoped_ptr<DownloadTestObserver> int_observer(
CreateInterruptedWaiter(shell(), 1));
DownloadItem* download(StartDownloadAndReturnItem(url));
int_observer->WaitForFinished();
ASSERT_EQ(DownloadItem::INTERRUPTED, download->GetState());
EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE,
download->GetLastReason());
EXPECT_TRUE(download->GetFullPath().empty());
// Target path should still be intact.
EXPECT_FALSE(download->GetTargetFilePath().empty());
// We need to make sure that any cross-thread downloads communication has
// quiesced before clearing and injecting the new errors, as the
// InjectErrors() routine alters the currently in use download file
// factory, which is a file thread object.
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// Clear the old errors list.
injector->ClearErrors();
injector->InjectErrors();
// Resume and watch completion.
DownloadUpdatedObserver completion_observer(
download, base::Bind(DownloadCompleteFilter));
download->Resume();
completion_observer.WaitForEvent();
EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE);
}
// An interrupted download should remove the intermediate file when it is
// cancelled.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelInterruptedDownload) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url1 = test_server()->GetURL(
base::StringPrintf("rangereset?size=%d&rst_boundary=%d",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
DownloadItem* download(StartDownloadAndReturnItem(url1));
WaitForData(download, GetSafeBufferChunk());
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
base::FilePath intermediate_path(download->GetFullPath());
ASSERT_FALSE(intermediate_path.empty());
EXPECT_TRUE(base::PathExists(intermediate_path));
download->Cancel(true /* user_cancel */);
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// The intermediate file should now be gone.
EXPECT_FALSE(base::PathExists(intermediate_path));
EXPECT_TRUE(download->GetFullPath().empty());
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveDownload) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
// An interrupted download should remove the intermediate file when it is
// removed.
{
GURL url1 = test_server()->GetURL(
base::StringPrintf("rangereset?size=%d&rst_boundary=%d",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
DownloadItem* download(StartDownloadAndReturnItem(url1));
WaitForData(download, GetSafeBufferChunk());
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
base::FilePath intermediate_path(download->GetFullPath());
ASSERT_FALSE(intermediate_path.empty());
EXPECT_TRUE(base::PathExists(intermediate_path));
download->Remove();
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// The intermediate file should now be gone.
EXPECT_FALSE(base::PathExists(intermediate_path));
}
// A completed download shouldn't delete the downloaded file when it is
// removed.
{
// Start the second download and wait until it's done.
base::FilePath file2(FILE_PATH_LITERAL("download-test.lib"));
GURL url2(net::URLRequestMockHTTPJob::GetMockUrl(file2));
scoped_ptr<DownloadTestObserver> completion_observer(
CreateWaiter(shell(), 1));
DownloadItem* download(StartDownloadAndReturnItem(url2));
completion_observer->WaitForFinished();
// The target path should exist.
base::FilePath target_path(download->GetTargetFilePath());
EXPECT_TRUE(base::PathExists(target_path));
download->Remove();
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
// The file should still exist.
EXPECT_TRUE(base::PathExists(target_path));
}
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) {
SetupEnsureNoPendingDownloads();
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(
base::StringPrintf("rangereset?size=%d&rst_boundary=%d",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell()));
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1);
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
::testing::Mock::VerifyAndClearExpectations(&dm_observer);
// Tell the server to send the RST and confirm the interrupt happens.
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
base::FilePath intermediate_path(download->GetFullPath());
ASSERT_FALSE(intermediate_path.empty());
EXPECT_TRUE(base::PathExists(intermediate_path));
// Resume and remove download. We expect only a single OnDownloadCreated()
// call, and that's for the second download created below.
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1);
download->Resume();
download->Remove();
// The intermediate file should now be gone.
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
EXPECT_FALSE(base::PathExists(intermediate_path));
// Start the second download and wait until it's done. The test server is
// single threaded. The response to this download request should follow the
// response to the previous resumption request.
GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x"));
NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE);
EXPECT_TRUE(EnsureNoPendingDownloads());
}
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) {
SetupEnsureNoPendingDownloads();
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
ASSERT_TRUE(test_server()->Start());
GURL url = test_server()->GetURL(
base::StringPrintf("rangereset?size=%d&rst_boundary=%d",
GetSafeBufferChunk() * 3, GetSafeBufferChunk()));
MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell()));
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1);
DownloadItem* download(StartDownloadAndReturnItem(url));
WaitForData(download, GetSafeBufferChunk());
::testing::Mock::VerifyAndClearExpectations(&dm_observer);
// Tell the server to send the RST and confirm the interrupt happens.
ReleaseRSTAndConfirmInterruptForResume(download);
ConfirmFileStatusForResume(
download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3,
base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload")));
base::FilePath intermediate_path(download->GetFullPath());
ASSERT_FALSE(intermediate_path.empty());
EXPECT_TRUE(base::PathExists(intermediate_path));
// Resume and cancel download. We expect only a single OnDownloadCreated()
// call, and that's for the second download created below.
EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1);
download->Resume();
download->Cancel(true);
// The intermediate file should now be gone.
RunAllPendingInMessageLoop(BrowserThread::FILE);
RunAllPendingInMessageLoop();
EXPECT_FALSE(base::PathExists(intermediate_path));
EXPECT_TRUE(download->GetFullPath().empty());
// Start the second download and wait until it's done. The test server is
// single threaded. The response to this download request should follow the
// response to the previous resumption request.
GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x"));
NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE);
EXPECT_TRUE(EnsureNoPendingDownloads());
}
// Check that the cookie policy is correctly updated when downloading a file
// that redirects cross origin.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) {
ASSERT_TRUE(test_server()->Start());
net::HostPortPair host_port = test_server()->host_port_pair();
DCHECK_EQ(host_port.host(), std::string("127.0.0.1"));
// Block third-party cookies.
ShellNetworkDelegate::SetAcceptAllCookies(false);
// |url| redirects to a different origin |download| which tries to set a
// cookie.
std::string download(base::StringPrintf(
"http://localhost:%d/set-cookie?A=B", host_port.port()));
GURL url(test_server()->GetURL("server-redirect?" + download));
// Download the file.
SetupEnsureNoPendingDownloads();
scoped_ptr<DownloadUrlParameters> dl_params(
DownloadUrlParameters::FromWebContents(shell()->web_contents(), url));
scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1));
DownloadManagerForShell(shell())->DownloadUrl(dl_params.Pass());
observer->WaitForFinished();
// Get the important info from other threads and check it.
EXPECT_TRUE(EnsureNoPendingDownloads());
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState());
// Check that the cookies were correctly set.
EXPECT_EQ("A=B",
content::GetCookies(shell()->web_contents()->GetBrowserContext(),
GURL(download)));
}
// A filename suggestion specified via a @download attribute should not be
// effective if the final download URL is in another origin from the original
// download URL.
IN_PROC_BROWSER_TEST_F(DownloadContentTest,
DownloadAttributeCrossOriginRedirect) {
EmbeddedTestServer origin_one;
EmbeddedTestServer origin_two;
ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady());
ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady());
// The download-attribute.html page contains an anchor element whose href is
// set to the value of the query parameter (specified as |target| in the URL
// below). The suggested filename for the anchor is 'suggested-filename'. When
// the page is loaded, a script simulates a click on the anchor, triggering a
// download of the target URL.
//
// We construct two test servers; origin_one and origin_two. Once started, the
// server URLs will differ by the port number. Therefore they will be in
// different origins.
GURL download_url = origin_one.GetURL("/ping");
GURL referrer_url = origin_one.GetURL(
std::string("/download-attribute.html?target=") + download_url.spec());
// <origin_one>/download-attribute.html initiates a download of
// <origin_one>/ping, which redirects to <origin_two>/download.
origin_one.ServeFilesFromDirectory(GetTestFilePath("download", ""));
origin_one.RegisterRequestHandler(
CreateRedirectHandler("/ping", origin_two.GetURL("/download")));
origin_two.RegisterRequestHandler(CreateBasicResponseHandler(
"/download", "application/octet-stream", "Hello"));
NavigateToURLAndWaitForDownload(
shell(), referrer_url, DownloadItem::COMPLETE);
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
EXPECT_EQ(FILE_PATH_LITERAL("download"),
downloads[0]->GetTargetFilePath().BaseName().value());
ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete());
ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete());
}
// A filename suggestion specified via a @download attribute should be effective
// if the final download URL is in the same origin as the initial download URL.
// Test that this holds even if there are cross origin redirects in the middle
// of the redirect chain.
IN_PROC_BROWSER_TEST_F(DownloadContentTest,
DownloadAttributeSameOriginRedirect) {
EmbeddedTestServer origin_one;
EmbeddedTestServer origin_two;
ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady());
ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady());
// The download-attribute.html page contains an anchor element whose href is
// set to the value of the query parameter (specified as |target| in the URL
// below). The suggested filename for the anchor is 'suggested-filename'. When
// the page is loaded, a script simulates a click on the anchor, triggering a
// download of the target URL.
//
// We construct two test servers; origin_one and origin_two. Once started, the
// server URLs will differ by the port number. Therefore they will be in
// different origins.
GURL download_url = origin_one.GetURL("/ping");
GURL referrer_url = origin_one.GetURL(
std::string("/download-attribute.html?target=") + download_url.spec());
origin_one.ServeFilesFromDirectory(GetTestFilePath("download", ""));
// <origin_one>/download-attribute.html initiates a download of
// <origin_one>/ping, which redirects to <origin_two>/pong, and then finally
// to <origin_one>/download.
origin_one.RegisterRequestHandler(
CreateRedirectHandler("/ping", origin_two.GetURL("/pong")));
origin_two.RegisterRequestHandler(
CreateRedirectHandler("/pong", origin_one.GetURL("/download")));
origin_one.RegisterRequestHandler(CreateBasicResponseHandler(
"/download", "application/octet-stream", "Hello"));
NavigateToURLAndWaitForDownload(
shell(), referrer_url, DownloadItem::COMPLETE);
std::vector<DownloadItem*> downloads;
DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
EXPECT_EQ(FILE_PATH_LITERAL("suggested-filename"),
downloads[0]->GetTargetFilePath().BaseName().value());
ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete());
ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete());
}
// The file empty.bin is served with a MIME type of application/octet-stream.
// The content body is empty. Make sure this case is handled properly and we
// don't regress on http://crbug.com/320394.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) {
EmbeddedTestServer test_server;
ASSERT_TRUE(test_server.InitializeAndWaitUntilReady());
GURL url = test_server.GetURL("/empty.bin");
test_server.ServeFilesFromDirectory(GetTestFilePath("download", ""));
NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE);
// That's it. This should work without crashing.
}
} // namespace content
| [
"hefen2007303257@gmail.com"
] | hefen2007303257@gmail.com |
f58e9b5c0bcddb8170dbe8ea49d36914b3888d4f | 92b3a58ce954d11324dce50b57239b7ecb058771 | /movie.h | 357d714007aaf1f0d437bd59fe61a3bd2c3f2680 | [] | no_license | youssefbiaz/sample | a914ed2403a6d07f60044a9351b84456a2245a12 | 5e5d1788beabb60f7201ac48169800165ad9ebc4 | refs/heads/master | 2021-01-25T08:55:28.217346 | 2014-12-25T02:16:38 | 2014-12-25T02:16:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 675 | h | #ifndef MOVIE_H
#define MOVIE_H
#include <string>
#include "lib/set.h"
class Movie {
public:
Movie(); // default constructor
Movie(std::string title); // constructor for a movie w a given title
Movie(const Movie &other); // copy constructor
~Movie(); // destructor
std::string getTitle () const; //returns the title of a movie
void addKeyword (std::string keyword);
/*Adds the (free-form) keyword to this movie.
If the exact same keyword (up to capitalization) was already associated
with the movie, then the keyword is not added again.*/
Set<std::string> getAllKeywords () const;
private:
Set<std::string> keyWords;
std::string movieTitle;
};
#endif
| [
"biaz@usc.edu"
] | biaz@usc.edu |
5ebb796b8564b745b2eda9b05c0c5e1a8a95ab64 | d9cfe5dd9bcbd5e168c780c0f4ede892b9e9df63 | /pfs.legacy/src/pfs-sys/timer_p.hpp | 5cd5b28c7b12c41949913123ec4fb1395d03c3b7 | [] | no_license | semenovf/archive | c196d326d85524f86ee734adee74b2f090eac6ee | 5bc6d21d072292dedc9aa4d7a281bc75a1663441 | refs/heads/master | 2022-05-30T11:04:17.315475 | 2022-04-27T03:33:56 | 2022-04-27T03:33:56 | 130,155,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 653 | hpp | /*
* timer_p.hpp
*
* Created on: Sep 17, 2015
* Author: wladt
*/
#ifndef __PFS_TIMER_P_HPP__
#define __PFS_TIMER_P_HPP__
#include "pfs/timer.hpp"
/**
* Timer support on Linux:
*
* - getitimer, setitimer.
* Conforming to POSIX.1-2001, SVr4, 4.4BSD
* (this call first appeared in 4.2BSD).
* POSIX.1-2008 marks this calls obsolete, recommending the
* use of the POSIX timers API (timer_gettime(2),
* timer_settime(2), etc.) instead.
*
* - timer_create, timer_settime, timer_gettime, timer_getoverrun, timer_delete.
* Conforming to POSIX.1-2001.
*/
#endif /* __PFS_TIMER_P_HPP__ */
| [
"fedor.v.semenov@gmail.com"
] | fedor.v.semenov@gmail.com |
0d014487fffadd981c91ff58f853136318873a0a | f6176f517c5985abef45c26ee1e84c1560daa0a6 | /work/FlashDriveCopy/FlashDriveCopy.cpp | aba8ac94bf43d2575a5bf5bfc223741489ba1a4c | [] | no_license | IgorYunusov/Test | b8699b38762a1908040ff92d3e32217de190a82b | bed7f05cadd2e46826152710c5c0bcc599913a21 | refs/heads/master | 2020-03-09T02:43:17.309400 | 2012-02-24T12:22:36 | 2012-02-24T12:22:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,689 | cpp | #include "stdafx.h"
#include "FlashDriveCopy.h"
#include "MainDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CFlashDriveCopyApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
CFlashDriveCopyApp theApp;
BOOL CFlashDriveCopyApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
MainDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
| [
"troyvova@mail.com"
] | troyvova@mail.com |
033a70929afbd6ccbf2ff65824902ddca72a9cf5 | 5bb0f18d6954d5eb17b54e5ac27a9761c62c7d3b | /GameHud.h | f6fdfd3af9eb160c76da55a518b7052a099be0ab | [] | no_license | sfpgmr/sfgame | 438304feed3bf8e874cd8f037a530e6a6b424e08 | 3893dc9392820509d780347eacbbc506bdce589e | refs/heads/master | 2020-05-09T14:29:57.691319 | 2013-06-29T18:58:39 | 2013-06-29T18:58:39 | 10,086,444 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,906 | h | //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
// GameHud:
// This class maintains the resources necessary to draw the Heads Up Display, which is a
// 2D overlay on top of the main 3D graphics generated for the game.
// The GameHud Render method expects to be called within the context of a D2D BeginDraw
// and makes D2D drawing calls to draw the text elements on the window.
#include "gamemain.h"
#include "DirectXSample.h"
namespace sf {
ref class GameHud
{
internal:
GameHud();
void CreateDeviceIndependentResources(
_In_ IDWriteFactory* dwriteFactory,
_In_ IWICImagingFactory* wicFactory
);
void CreateDeviceResources(_In_ ID2D1DeviceContext* d2dContext);
void UpdateForWindowSizeChange(_In_ Windows::Foundation::Rect windowBounds);
void Render(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void RenderPause(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawScore(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawHighScore(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawTitle(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawHighScores(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawPlayerLeft(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawGameStart(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void DrawGameOver(
_In_ GameMain^ game,
_In_ ID2D1DeviceContext* d2dContext,
_In_ Windows::Foundation::Rect windowBounds
);
void SetLicenseInfo(_In_ Platform::String^ licenseInfo);
private:
Microsoft::WRL::ComPtr<IDWriteFactory> m_dwriteFactory;
Microsoft::WRL::ComPtr<IWICImagingFactory> m_wicFactory;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_textBrush;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_textBrushGrey;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatBody;
//Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatBodySymbol;
//Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatTitleHeader;
//Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatTitleBody;
Microsoft::WRL::ComPtr<IDWriteTextFormat> m_textFormatTitleLicense;
/* Microsoft::WRL::ComPtr<IDWriteTextLayout> m_titleHeaderLayout;
Microsoft::WRL::ComPtr<IDWriteTextLayout> m_titleBodyLayout;*/
Microsoft::WRL::ComPtr<IDWriteTextLayout> m_titleLicenseInfoLayout;
Platform::String^ m_ScoreHeader;
Platform::String^ m_HighScoreHeader;
Platform::String^ m_PauseGameString;
Platform::String^ m_titleLicenseInfo;
float m_titleBodyVerticalOffset;
float m_titleLicenseVerticalOffset;
//D2D1_SIZE_F m_logoSize;
D2D1_SIZE_F m_maxTitleSize;
};
}
| [
"sfpgmr@dummy.com"
] | sfpgmr@dummy.com |
6aea0a0d1f9010cb813bf4884fd19f739bb6f7c6 | b32055f9ee67e3a9ac500c9ab38c95fc70d2eb99 | /CS381/KBoghossian - CS381 - Ass05/Project/Graphics.cpp | 18512ba13bfdfe62850977fff7671b126d5fb9df | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | KBog/college-projects | 8fcc1eedabe8f57f2e448aed1055b5dabcaab2e7 | 6db3de5f76fa7a3d5e080806e1638ba0ab718877 | refs/heads/master | 2020-03-27T02:05:08.994109 | 2018-08-22T21:39:16 | 2018-08-22T21:39:17 | 145,765,073 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 16,214 | cpp | #include"Graphics.h"
#include"Settings.h"
#include"Viewing.h"
#include"Clipping.h"
#include <math.h>
extern HWND GlobalHwnd;
extern ViewPort *ViewPort_List;
DWORD bitCount=0;
char isWindowed=1;
int Width,Height;
unsigned char *VideoBuffer=NULL;
LPDIRECTDRAW lpdd=NULL; //Direct Draw object
LPDIRECTDRAWSURFACE lpdds_Primary=NULL; //Primary Surface
LPDIRECTDRAWSURFACE lpdds_Secondary=NULL;//Secondary Surface
LPDIRECTDRAWCLIPPER lpclipper=NULL; //Clipper Object
HRESULT Graphics_CreateFullScreenDisplay(HWND hwnd,WORD bdp)
{
DDSURFACEDESC ddsd;
/*Get System Resolution*/
Width=GetSystemMetrics(SM_CXSCREEN);
Height=GetSystemMetrics(SM_CYSCREEN);
/*Creating Direct Draw Object*/
if(FAILED(DirectDrawCreate(NULL,&lpdd,NULL)))
/*ERROR*/return E_FAIL;
/*Setting cooperative level to full screen mode*/
if(FAILED(lpdd->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN)))
/*ERROR*/return E_FAIL;
/*Setting the Display Mode*/
if(FAILED(lpdd->SetDisplayMode(Width,Height,bdp)))
/*ERROR*/return E_FAIL;
/*Creating the surface and back-buffer*/
/*Initializing the Direct Draw surface description*/
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(DDSURFACEDESC);
ddsd.dwFlags=DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount=1;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE|DDSCAPS_COMPLEX|DDSCAPS_FLIP;
/*Creating the primary surface*/
if(FAILED(lpdd->CreateSurface(&ddsd,&lpdds_Primary,NULL)))
/*ERROR*/return E_FAIL;
/*Creating the Back-Buffer surface*/
ddsd.ddsCaps.dwCaps=DDSCAPS_BACKBUFFER;
if(FAILED(lpdds_Primary->GetAttachedSurface(&ddsd.ddsCaps,&lpdds_Secondary)))
/*ERROR*/return E_FAIL;
Graphics_CreateBuffer();
return S_OK;
}
HRESULT Graphics_CreateWindowedDisplay(HWND hwnd,DWORD width,DWORD height)
{
DDSURFACEDESC ddsd;
int x=(GetSystemMetrics(SM_CXSCREEN)-width)/2,y=(GetSystemMetrics(SM_CYSCREEN)-height)/2;
RECT r;
/*Setting the Width and Height*/
Width=width;
Height=height;
/*Creating Direct Draw Object*/
if(FAILED(DirectDrawCreate(NULL,&lpdd,NULL)))
/*ERROR*/return E_FAIL;
/*Setting cooperative level to window mode*/
if(FAILED(lpdd->SetCooperativeLevel(hwnd,DDSCL_NORMAL)))
/*ERROR*/return E_FAIL;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE;
/*Creating the primary surface*/
if(FAILED(lpdd->CreateSurface(&ddsd,&lpdds_Primary,NULL)))
/*ERROR*/return E_FAIL;
/*Creating the Off-Screen surface*/
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
ddsd.dwWidth=width;
ddsd.dwHeight=height;
ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY;
if(FAILED(lpdd->CreateSurface(&ddsd,&lpdds_Secondary,NULL)))
return E_FAIL;
/*Setting Window Rectangle*/
SetRect(&r,x,y,x+width,y+height);
/*Adjusting Client Area rectangle*/
AdjustWindowRectEx(&r,GetWindowStyle(hwnd),GetMenu(hwnd)!=NULL,GetWindowExStyle(hwnd));
MoveWindow(hwnd,r.left,r.top,r.right-r.left,r.bottom-r.top,FALSE);
/*Creating the clipper and associating it to the window*/
if(FAILED(lpdd->CreateClipper(0,&lpclipper,NULL)))
return E_FAIL;
if(FAILED(lpclipper->SetHWnd(0,hwnd)))
{
lpclipper->Release();
return E_FAIL;
}
if(FAILED(lpdds_Primary->SetClipper(lpclipper)))
{
lpclipper->Release();
return E_FAIL;
}
Graphics_CreateBuffer();
return S_OK;
}
void Graphics_CreateBuffer()
{
DDSURFACEDESC ddsd;
/*Getting Secondary Surface Description*/
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
lpdds_Secondary->GetSurfaceDesc(&ddsd);
/*Pixel Depth*/
bitCount=ddsd.ddpfPixelFormat.dwRGBBitCount>>3;
/*Allocate Memory for VideBuffer*/
VideoBuffer = (unsigned char*)malloc(Width*Height*bitCount);
memset(VideoBuffer,0xFF,Width*Height*bitCount);
}
void Graphics_FreeDirectDraw()
{
/*Check if pointer is valid*/
if(lpdd)
{
/*Restore normal window and default resolution and depth*/
lpdd->SetCooperativeLevel(GlobalHwnd,DDSCL_NORMAL);
lpdd->RestoreDisplayMode();
}
/*Releasing the clipper (if it exists)*/
SAFE_RELEASE(lpclipper);
/*Releasing the Secondary Surface (if it exists)*/
SAFE_RELEASE(lpdds_Secondary);
/*Releasing the Primary Surface (if it exists)*/
SAFE_RELEASE(lpdds_Primary);
/*Free Direct Draw object*/
SAFE_RELEASE(lpdd);
/*Free VideoBuffer if it's pointer is valid*/
if(VideoBuffer){free(VideoBuffer);VideoBuffer=NULL;}
}
void Graphics_Flip()
{
if(lpdds_Primary&&lpdds_Secondary)
if(isWindowed)
{
/*If in Windowed mode, we need to Blit*/
RECT client_rect;
GetClientRect(GlobalHwnd,&client_rect);
ClientToScreen(GlobalHwnd,(POINT*)&client_rect);
ClientToScreen(GlobalHwnd,(POINT*)&client_rect+1);
lpdds_Primary->Blt(&client_rect,lpdds_Secondary,NULL,DDBLT_WAIT,NULL);
}
else
/*If in Full Screen mode, we only need to Flip*/
lpdds_Primary->Flip(NULL,DDFLIP_WAIT);
}
void Graphics_TextOut(int x,int y,const char *str, unsigned char r, unsigned char g, unsigned char b)
{
HDC hdc;
if(lpdds_Secondary)
{
/*Get Handle to Device Context from secondary surface*/
lpdds_Secondary->GetDC(&hdc);
/*Set text background and color*/
SetBkMode(hdc,TRANSPARENT);
SetTextColor(hdc,RGB(r,g,b));
/*Output text to surface*/
TextOut(hdc,x,y,str,(int)strlen(str));
/*Release Handle to Device Context*/
lpdds_Secondary->ReleaseDC(hdc);
}
}
void Graphics_Draw(void(*drawingFn)())
{
int i;
int lPitch;
unsigned char *buffer=NULL;
unsigned char *tempBuffer=VideoBuffer;
if(lpdds_Secondary)
{
DDSURFACEDESC ddsd;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
/*Lock the Secondary Surface*/
lpdds_Secondary->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT,NULL);
/*Set the Surface memory pointer and the Pitch*/
buffer=(unsigned char*)ddsd.lpSurface;
lPitch=ddsd.lPitch;
if(drawingFn)
drawingFn();
if(lPitch==bitCount*Width)
/*Block Copy*/
memcpy((void*)buffer,(void*)tempBuffer,Width*Height*bitCount);
else
{
for(i=0;i<Height;i++)
{
/*Line by Line Copy*/
memcpy((void*)buffer,(void*)tempBuffer,Width*bitCount);
buffer+=lPitch;
tempBuffer+=bitCount*Width;
}
}
/*Unlock Surface*/
lpdds_Secondary->Unlock(NULL);
}
}
void Init_Buffer(int Color)
{
/*Initialize all VideoBuffer to Black*/
memset(VideoBuffer,Color,Width*Height*bitCount);
}
void Init_View (int Color)
{
int i,x0,y0;
unsigned char *p;
for(ViewPort *tmp=ViewPort_List; tmp; tmp = tmp->next)
{
/*Drawing Radar ViewPort*/
x0=(int)tmp->Center.x-(((int)tmp->Width)>>1);
y0=(int)tmp->Center.y-(((int)tmp->Height)>>1);
p=&VideoBuffer[(x0+Width*y0)*bitCount];
/*memset Line by Line*/
for(i=0;i<tmp->Height;i++)
{
memset(p,0,(size_t)tmp->Width*bitCount);
p+=Width*bitCount;
}
}
}
/*Primitive Rasterization functions*/
/*Line Rasterizer*/
void LINE(float x0,float y0,float x1,float y1,unsigned int r,unsigned int g,unsigned int b)
{
/*Declaring and defining all variables needed for algorithm*/
int xStep,yStep,dx=(int)(x1+=0.5f)-(int)(x0+=0.5f),dy=(int)(y1+=0.5f)-(int)(y0+=0.5f),X0=(int)x0,Y0=(int)y0,X1=(int)x1,Y1=(int)y1;
int PixelCount, PixelLeft;
xStep=(dx>0)?1:-1;
yStep=(dy>0)?1:-1;
dx=(dx>0)?dx:-dx;
dy=(dy>0)?dy:-dy;
/*if both dx and dy are zero, return from function (nothing to draw)*/
if(!dx&!dy)
return;
Graphics_WritePixel(X0,Y0,r,g,b);
Graphics_WritePixel(X1,Y1,r,g,b);
if(dx>=dy)
{
/*Declare and Define Decision variables*/
int d0=2*dy-dx;
int dA=2*(dy-dx);
int dB=2*dy;
PixelCount=(dx-1)/2;
PixelLeft=(dx-1)%2;
while(PixelCount--)
{
X0+=xStep;
X1-=xStep;
if(d0>=0)
{
d0+=dA;
Y0+=yStep;
Y1-=yStep;
}
else
d0+=dB;
Graphics_WritePixel(X0,Y0,r,g,b);
Graphics_WritePixel(X1,Y1,r,g,b);
}
if(PixelLeft)
{
X0+=xStep;
if(d0>=0)
Y0+=yStep;
Graphics_WritePixel(X0,Y0,r,g,b);
}
}
else
{
/*Declare and Define Decision variables*/
int d0=2*dx-dy;
int dA=2*(dx-dy);
int dB=2*dx;
PixelCount=(dy-1)/2;
PixelLeft=(dy-1)%2;
while(PixelCount--)
{
Y0+=yStep;
Y1-=yStep;
if(d0>=0)
{
d0+=dA;
X0+=xStep;
X1-=xStep;
}
else
d0+=dB;
Graphics_WritePixel(X0,Y0,r,g,b);
Graphics_WritePixel(X1,Y1,r,g,b);
}
if(PixelLeft)
{
Y0+=yStep;
if(d0>=0)
X0+=xStep;
Graphics_WritePixel(X0,Y0,r,g,b);
}
}
}
/*Circle Rasterizer*/
void CIRCLE(float xc,float yc, int R,unsigned char r,unsigned char g,unsigned char b)
{
/*Defining all needed variables*/
int Xc=(int)(xc+0.5f),Yc=(int)(yc+0.5f);
int X=0,Y=R,d=1-R;
/*Draw first 8 points on circle (8 way symmetric)*/
if(Pixel_Clip(X+Xc,Y+Yc))
Graphics_WritePixel(X+Xc,Y+Yc,r,g,b);
if(Pixel_Clip(-X+Xc,Y+Yc))
Graphics_WritePixel(-X+Xc,Y+Yc,r,g,b);
if(Pixel_Clip(X+Xc,-Y+Yc))
Graphics_WritePixel(X+Xc,-Y+Yc,r,g,b);
if(Pixel_Clip(-X+Xc,-Y+Yc))
Graphics_WritePixel(-X+Xc,-Y+Yc,r,g,b);
if(Pixel_Clip(Y+Xc,X+Yc))
Graphics_WritePixel(Y+Xc,X+Yc,r,g,b);
if(Pixel_Clip(-Y+Xc,X+Yc))
Graphics_WritePixel(-Y+Xc,X+Yc,r,g,b);
if(Pixel_Clip(Y+Xc,-X+Yc))
Graphics_WritePixel(Y+Xc,-X+Yc,r,g,b);
if(Pixel_Clip(-Y+Xc,-X+Yc))
Graphics_WritePixel(-Y+Xc,-X+Yc,r,g,b);
while(X<Y) //Loop while X is less than Y ==> dx>dy
{
if(d<0) //if the decision variable is less than zero
d+=2*X+3; //Update decision variable by 2*X+3
else //else
{
d+=2*(X-Y)+5; //Update decision variable by 2*(X-Y)+5
Y--; //Decrement Y by 1
}
X++; //Increment X by 1
/*Draw all 8 symmetric points*/
if(Pixel_Clip(X+Xc,Y+Yc))
Graphics_WritePixel(X+Xc,Y+Yc,r,g,b);
if(Pixel_Clip(-X+Xc,Y+Yc))
Graphics_WritePixel(-X+Xc,Y+Yc,r,g,b);
if(Pixel_Clip(X+Xc,-Y+Yc))
Graphics_WritePixel(X+Xc,-Y+Yc,r,g,b);
if(Pixel_Clip(-X+Xc,-Y+Yc))
Graphics_WritePixel(-X+Xc,-Y+Yc,r,g,b);
if(Pixel_Clip(Y+Xc,X+Yc))
Graphics_WritePixel(Y+Xc,X+Yc,r,g,b);
if(Pixel_Clip(-Y+Xc,X+Yc))
Graphics_WritePixel(-Y+Xc,X+Yc,r,g,b);
if(Pixel_Clip(Y+Xc,-X+Yc))
Graphics_WritePixel(Y+Xc,-X+Yc,r,g,b);
if(Pixel_Clip(-Y+Xc,-X+Yc))
Graphics_WritePixel(-Y+Xc,-X+Yc,r,g,b);
}
}
/*Filled Circle Rasterizer*/
void FILL_CIRCLE(float xc,float yc, int R,unsigned char r,unsigned char g,unsigned char b)
{
/*Defining all needed variables*/
int X=0,Y=R,Xc=(int)(xc+0.5f),Yc=(int)(yc+0.5f),d=1-R,de=3,dse=-2*R+5;
int x,xEnd,y;
/*Draw first horizontal diameter*/
if((y=X+Yc)>=ClipRect.top && y<ClipRect.bottom)
{
x=-Y+Xc;if(x<ClipRect.left){x=ClipRect.left;};
xEnd=Y+Xc;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
}
while(X<Y)
{
if(d<0)
{
d+=de;
de+=2;
dse+=2;
}
else
{
d+=dse;
de+=2;
dse+=4;
Y--;
}
X++;
/*Draw all 4 lines*/
if((y=Y+Yc)>=ClipRect.top && y<ClipRect.bottom)
{
x=-X+Xc;if(x<ClipRect.left){x=ClipRect.left;};
xEnd=X+Xc;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
}
if((y=X+Yc)>=ClipRect.top && y<ClipRect.bottom)
{
x=-Y+Xc;if(x<ClipRect.left){x=ClipRect.left;};
xEnd=Y+Xc;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
}
if((y=-Y+Yc)>=ClipRect.top && y<ClipRect.bottom)
{
x=-X+Xc;if(x<ClipRect.left){x=ClipRect.left;};
xEnd=X+Xc;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
}
if((y=-X+Yc)>=ClipRect.top && y<ClipRect.bottom)
{
x=-Y+Xc;if(x<ClipRect.left){x=ClipRect.left;};
xEnd=Y+Xc;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
}
}
}
long Ceil(float g)
{
/*Function to return the ceiling of a float*/
long l=(long)g;
return ((l==g)|(g<0))?l:l+1;
}
/*Triangle Rasterizer*/
void TRIANGLE(Point_Float *PF, unsigned char r,unsigned char g,unsigned char b)
{
int i, j;
for(i=0, j=1; i<3; i++, j++)
{
if(j==3)
j=0;
Point_Float V0=PF[i],V1=PF[j];
if(LB_Clipp(&V0,&V1))
LINE(V0.x, V0.y, V1.x, V1.y,r,g,b);
}
}
/*Filled Triangle Rasterizer*/
void FILL_TRIANGLE(Point_Float *triangleVtx,unsigned char r,unsigned char g,unsigned char b)
{
char topVtx,midVtx,botVtx,MidIsLeft,leftEdge,rightEdge;
int y,yEnd,x,xEnd;
float InvSlope[3],xL,xR;
/*
Determining Positions of the three vertices and updating
topVtx, midVtx, botVtx and MidIsLeft variables accordingly
*/
///////////////////////////////////////////////
if(triangleVtx[0].y<triangleVtx[1].y)
{
if(triangleVtx[2].y<triangleVtx[0].y)
{
topVtx=2;
midVtx=0;
botVtx=1;
MidIsLeft=1;
}
else
{
topVtx=0;
if(triangleVtx[1].y<triangleVtx[2].y)
{
midVtx=1;
botVtx=2;
MidIsLeft=1;
}
else
{
midVtx=2;
botVtx=1;
MidIsLeft=0;
}
}
}
else
{
if(triangleVtx[2].y<triangleVtx[1].y)
{
topVtx=2;
midVtx=1;
botVtx=0;
MidIsLeft=0;
}
else
{
topVtx=1;
if(triangleVtx[0].y<triangleVtx[2].y)
{
midVtx=0;
botVtx=2;
MidIsLeft=0;
}
else
{
midVtx=2;
botVtx=0;
MidIsLeft=1;
}
}
}
///////////////////////////////////////////////
/*Updating Inverse Slope Values*/
InvSlope[0]=(triangleVtx[botVtx].x-triangleVtx[topVtx].x)/(triangleVtx[botVtx].y-triangleVtx[topVtx].y);
InvSlope[1]=(triangleVtx[midVtx].x-triangleVtx[topVtx].x)/(triangleVtx[midVtx].y-triangleVtx[topVtx].y);
InvSlope[2]=(triangleVtx[botVtx].x-triangleVtx[midVtx].x)/(triangleVtx[botVtx].y-triangleVtx[midVtx].y);
/*Updating the leftEdge and rightEdge Variables*/
leftEdge=MidIsLeft;
rightEdge=!MidIsLeft;
/*Getting starting and ending y values*/
y=Ceil(triangleVtx[topVtx].y);
yEnd=Ceil(triangleVtx[midVtx].y)-1;
/*Getting Initial x values*/
xL=xR=triangleVtx[topVtx].x;
/*Clipping First half of triangle by interpolating x and y*/
if(y<=ClipRect.top)
{
xL+=InvSlope[leftEdge]*(ClipRect.top-y);
xR+=InvSlope[rightEdge]*(ClipRect.top-y);
y=ClipRect.top;
}
if(yEnd>=ClipRect.bottom-1)
yEnd=ClipRect.bottom-1;
/*Filling the triangle from Top to Mid vertex*/
for(;y<=yEnd;y++)
{
x=Ceil(xL);if(x<ClipRect.left){x=ClipRect.left;};
xEnd=Ceil(xR)-1;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
xL+=InvSlope[leftEdge];
xR+=InvSlope[rightEdge];
}
/*Updating the leftEdge and rightEdge Variables*/
leftEdge=MidIsLeft<<1;
rightEdge=(!MidIsLeft)<<1;
/*Updating starting and ending y Values*/
y=Ceil(triangleVtx[midVtx].y);
yEnd=Ceil(triangleVtx[botVtx].y)-1;
/*Clipping Second half of triangle by interpolating x and y*/
if(MidIsLeft)
{
xL=triangleVtx[midVtx].x;
if(y<=ClipRect.top)
{
xL=triangleVtx[midVtx].x+InvSlope[2]*(ClipRect.top-y);
xR=triangleVtx[topVtx].x+InvSlope[0]*(ClipRect.top-Ceil(triangleVtx[topVtx].y));
y=ClipRect.top;
}
if(yEnd>=ClipRect.bottom-1)
yEnd=ClipRect.bottom-1;
}
else
{
xR=triangleVtx[midVtx].x;
if(y<=ClipRect.top)
{
xR=triangleVtx[midVtx].x+InvSlope[2]*(ClipRect.top-y);
xL=triangleVtx[topVtx].x+InvSlope[0]*(ClipRect.top-Ceil(triangleVtx[topVtx].y));
y=ClipRect.top;
}
if(yEnd>=ClipRect.bottom-1)
yEnd=ClipRect.bottom-1;
}
/*Filling the triangle from Mid to Bot vertex*/
for(;y<=yEnd;y++)
{
x=Ceil(xL);if(x<ClipRect.left){x=ClipRect.left;};
xEnd=Ceil(xR)-1;if(xEnd>ClipRect.right-1){xEnd=ClipRect.right-1;};
for(;x<=xEnd;x++)
Graphics_WritePixel(x,y,r,g,b);
xL+=InvSlope[leftEdge];
xR+=InvSlope[rightEdge];
}
} | [
"karl@boosterfuels.com"
] | karl@boosterfuels.com |
e2e5715e15afabfba6933e6240acb683c9e4b9fe | 05731593231d105d7361cb016f7d240af118edb0 | /src/kalman_filter.cpp | 658f16c0580cfff0ba0750a826594cff991f417a | [] | no_license | dvu4/CarND-Extended-Kalman-Filter-Project | 147d426ac501ddf30c37b7be409e5b672ecd2139 | 739a7af88c574471c6fedec031c1aebbd753b214 | refs/heads/master | 2021-01-21T14:32:17.427405 | 2017-06-24T11:48:49 | 2017-06-24T11:48:49 | 95,293,358 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,571 | cpp | #include "kalman_filter.h"
#include "tools.h"
using Eigen::MatrixXd;
using Eigen::VectorXd;
KalmanFilter::KalmanFilter() {}
KalmanFilter::~KalmanFilter() {}
void KalmanFilter::Init(VectorXd &x_in, MatrixXd &P_in, MatrixXd &F_in,
MatrixXd &H_in, MatrixXd &R_in, MatrixXd &Q_in) {
x_ = x_in;
P_ = P_in;
F_ = F_in;
H_ = H_in;
R_ = R_in;
Q_ = Q_in;
}
void KalmanFilter::Predict() {
/**
TODO:
* predict the state
*/
x_ = F_ * x_;
MatrixXd Ft = F_.transpose();
P_ = F_ * P_ * Ft + Q_;
}
void KalmanFilter::Update(const VectorXd &z) {
/**
TODO:
* update the state by using Kalman Filter equations
*/
VectorXd z_pred = H_ * x_;
VectorXd y = z - z_pred;
MatrixXd Ht = H_.transpose();
MatrixXd S = H_ * P_ * Ht + R_;
MatrixXd Si = S.inverse();
MatrixXd PHt = P_ * Ht;
MatrixXd K = PHt * Si;
// new estimate
x_ = x_ + (K * y);
long x_size = x_.size();
MatrixXd I = MatrixXd::Identity(x_size, x_size);
P_ = (I - K * H_) * P_;
}
void KalmanFilter::UpdateEKF(const VectorXd &z) {
/**
TODO:
* update the state by using Extended Kalman Filter equations
*/
//recover state parameters
VectorXd z_pred = VectorXd(3);
float px = x_(0);
float py = x_(1);
float vx = x_(2);
float vy = x_(3);
// range rho (distance to the pedestrian)
float rho = sqrt(px*px + py*py);
// angle phi between rho and x direction
float phi = atan2(py, px);
// range rate rho (derivation)
float rho_dot = (px*vx + py*vy) / rho;
//if (rho == 0){
// rho_dot = 0;
//}
//else{
// rho_dot = (px*vx + py*vy)/rho;
//}
// normalize phi (y(1)) between -pi and pi
while (phi < -M_PI) phi += 2 * M_PI; // phi < - pi => phi+2*pi < pi
while (phi > M_PI) phi -= 2 * M_PI; // phi > pi => phi-2*pi> -pi
z_pred << rho, phi, rho_dot;
VectorXd y = z - z_pred;
// normalize phi (y(1)) between -pi and pi
while (y(1) < -M_PI) y(1) += 2 * M_PI; // phi < - pi => phi+2*pi < pi
while (y(1) > M_PI) y(1) -= 2 * M_PI; // phi > pi => phi-2*pi> -pi
// Calculate a Jacobian matrix Hj_
Tools tools;
MatrixXd Hj_ = tools.CalculateJacobian(x_);
MatrixXd Ht = Hj_.transpose();
MatrixXd S = Hj_ * P_ * Ht + R_;
MatrixXd Si = S.inverse();
MatrixXd PHt = P_ * Ht;
MatrixXd K = PHt * Si;
// new estimate
x_ = x_ + (K * y);
long x_size = x_.size();
MatrixXd I = MatrixXd::Identity(x_size, x_size);
P_ = (I - K * Hj_) * P_;
}
| [
"noreply@github.com"
] | noreply@github.com |
2081e17fc9c3dbddb1f107abed919b545db5697d | 7efcbc6c17b1f54be26f7869e5d53ce04b0af774 | /src/Library/MusicLibrary.cpp | f00e112b3c7f74717af6bdf75c3968b82c776650 | [] | no_license | marsh000/MyMedia | 0129b630c46212ecc9c0f9385d44130c4bd82906 | d3dd09b678ca85ad4fa3a59d48b77364e265f4f4 | refs/heads/master | 2020-11-26T09:38:57.008806 | 2015-07-24T11:07:26 | 2015-07-24T11:07:26 | 39,626,514 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,530 | cpp | #include <include/Library/MusicLibrary.h>
#include <include/Custom Controls/Media Players/MusicPlayer.h>
#include <include/Device/DeviceBase.h>
#include <include/ErrorLog.h>
#include <include/FilePaths.h>
#include <include/Media/Song.h>
#include <include/Helper.h>
#include "fileref.h"
#include "tag.h"
CMusicLibrary::CMusicLibrary(wxWindow* pParent, wxWindowID ID, cmsDatabase* pDatabase, CDevice* pDevice, CMusicPlayer* pPlayer)
: CLibrary(pParent, ID), m_pMusicPlayerCtrl(pPlayer)
{
wxASSERT_MSG(pDevice, "pDevice must point to a valid Device");
m_LibraryName = "Music";
m_pDatabase = pDatabase;
m_pDevice = pDevice;
m_MediaType = MEDIATYPE_MUSIC;
// set library path
wxString Path = pDevice->GetDeviceBasePath();
if (pDevice->GetDeviceType() == DEVTYPE_MASTER)
{
Path << "My Music\\MyMedia\\Music Library\\";
}
else
{
Path << "Music\\";
}
this->SetLibraryPath(Path);
// set up columns
m_pTreelistCtrl->AppendColumn("Artist / Album / Title", 100, wxALIGN_LEFT);
m_pTreelistCtrl->AppendColumn("Genre", 150, wxALIGN_LEFT);
m_pTreelistCtrl->AppendColumn("Time", 65, wxALIGN_RIGHT);
m_pTreelistCtrl->AppendColumn("Track", 65, wxALIGN_RIGHT);
m_pTreelistCtrl->AppendColumn("Year", 65, wxALIGN_RIGHT);
m_pTreelistCtrl->AppendColumn("Type", 65, wxALIGN_RIGHT);
m_pTreelistCtrl->AppendColumn("Bit Rate", 80, wxALIGN_RIGHT);
m_pTreelistCtrl->AppendColumn("Sample Rate", 100, wxALIGN_RIGHT);
m_pTreelistCtrl->Bind(wxEVT_COMMAND_TREELIST_ITEM_CHECKED, &CMusicLibrary::OnTreeListItemChecked, this);
m_pTreelistCtrl->Bind(wxEVT_COMMAND_TREELIST_ITEM_CONTEXT_MENU, &CMusicLibrary::OnTreeListItemRightClick, this);
}
CMusicLibrary::~CMusicLibrary()
{
}
bool CMusicLibrary::InitDatabase()
{
if (this->GetDevice() == NULL)
return false;
wxString SqlStr = wxEmptyString;
SqlStr << "CREATE TABLE IF NOT EXISTS main.'" << m_pDevice->GetDeviceName() << "' "
<< "("
<< "col_Artist TEXT, "
<< "col_Album TEXT, "
<< "col_Title TEXT, "
<< "col_Genre TEXT, "
<< "col_Time TEXT, "
<< "col_Track INT, "
<< "col_Year INT, "
<< "col_Type TEXT, "
<< "col_BitRate INT, "
<< "col_SampleRate INT, "
<< "col_Channels INT, "
<< "col_Comment TEXT, "
<< "col_FullPath TEXT"
<< ")";
if (m_pDatabase->ProcessStatement(SqlStr) )
{
/*//////////////////////////////////////////////////////////////////////////
wxArrayString Files;
size_t NumFiles = 0;
NumFiles += wxDir::GetAllFiles(this->GetLibraryPath(), &Files, "*.m4a");
NumFiles += wxDir::GetAllFiles(this->GetLibraryPath(), &Files, "*.m4p");
NumFiles += wxDir::GetAllFiles(this->GetLibraryPath(), &Files, "*.aac");
NumFiles += wxDir::GetAllFiles(this->GetLibraryPath(), &Files, "*.mp3");
for (size_t x = 0; x < NumFiles; x++)
{
CSong Song(Files[x] );
wxString str;
str << "INSERT INTO main." << m_pDevice->GetDeviceName()
<< " (col_Artist,col_Album,col_Title,col_Genre,"
<< "col_Time,col_Track,col_Year,col_Type,col_BitRate,col_SampleRate,"
<< "col_Channels,col_Comment,col_FullPath) VALUES ("
<< "'" << cms::sqlEscapeQuotes(Song.GetArtist() ) << "',"
<< "'" << cms::sqlEscapeQuotes(Song.GetAlbum() ) << "',"
<< "'" << cms::sqlEscapeQuotes(Song.GetTitle() ) << "',"
<< "'" << cms::sqlEscapeQuotes(Song.GetGenre() ) << "',"
<< "'" << Song.GetTimeString() << "',"
<< "'" << Song.GetTrack() << "',"
<< "'" << Song.GetYear() << "',"
<< "'" << Song.GetType() << "',"
<< "'" << Song.GetBitRate() << "',"
<< "'" << Song.GetSampleRate() << "',"
<< "'" << Song.GetChannels() << "',"
<< "'" << cms::sqlEscapeQuotes(Song.GetComment() ) << "',"
<< "'" << cms::sqlEscapeQuotes(Song.GetFullPath() ) << "')";
if (!m_pDatabase->ProcessStatement(str) )
{
wxString msg;
msg << x << " of " << NumFiles << " Songs copied";
cmsLogError(msg);
return false;
}
}
wxString msg;
msg << NumFiles << " Songs copied";
cmsLogError(msg);
*///////////////////////////////////////////////////////////////////////////
return true;
}
return false;
}
bool CMusicLibrary::LoadLibraryFromDatabase()
{
wxString SqlStr = wxString::Format("SELECT ROWID,* FROM main.'%s'", m_pDevice->GetDeviceName() );
cmsSQLQueryId* pQueryId = NULL;
if (m_pDatabase->BeginQuery(SqlStr, &pQueryId) )
{
int RetVal = m_pDatabase->GetNextRowFromQuery(pQueryId);
while (RetVal == SQLITE_ROW)
{
CSong Song;
this->GetSongFromQuery(pQueryId, &Song);
this->InsertMediaInList(&Song);
RetVal = m_pDatabase->GetNextRowFromQuery(pQueryId);
}
m_pDatabase->EndQuery(&pQueryId);
if (RetVal != SQLITE_DONE)
{
return false;
}
// expand all items
wxTreeListItem Artist = m_pTreelistCtrl->GetFirstChild(m_pTreelistCtrl->GetRootItem() );
while (Artist.IsOk() )
{
m_pTreelistCtrl->Expand(Artist);
wxTreeListItem Album = m_pTreelistCtrl->GetFirstChild(Artist);
while (Album.IsOk() )
{
m_pTreelistCtrl->Expand(Album);
Album = m_pTreelistCtrl->GetNextSibling(Album);
}
Artist = m_pTreelistCtrl->GetNextSibling(Artist);
}
return true;
}
SqlStr << "\n\n" << m_pDatabase->GetLastErrorMsg();
cmsLogError(SqlStr);
return false;
}
bool CMusicLibrary::InsertMediaInList(CMedia* pMedia)
{
CSong* pThisSong = static_cast<CSong*>(pMedia);
wxTreeListItem ArtistItem,
AlbumItem,
TitleItem,
ThisItem,
LastArtistItem,
LastAlbumItem,
LastTitleItem;
// artist
ThisItem = m_pTreelistCtrl->GetFirstChild(m_pTreelistCtrl->GetRootItem() );
if (!ThisItem.IsOk() )
{
ArtistItem = m_pTreelistCtrl->AppendItem(m_pTreelistCtrl->GetRootItem(), pThisSong->GetArtist() );
}
else
{
while (ThisItem.IsOk() )
{
int comp = pThisSong->GetArtist().CmpNoCase(m_pTreelistCtrl->GetItemText(ThisItem, 0) );
if (comp > 0) // keep going
{
LastArtistItem = ThisItem;
ThisItem = m_pTreelistCtrl->GetNextSibling(LastArtistItem);
if (!ThisItem.IsOk() )
{
ArtistItem = m_pTreelistCtrl->AppendItem(m_pTreelistCtrl->GetRootItem(), pThisSong->GetArtist() );
break;
}
}
else if (comp < 0) // prepend
{
if (LastArtistItem.IsOk() )
ArtistItem = m_pTreelistCtrl->InsertItem(m_pTreelistCtrl->GetRootItem(), LastArtistItem, pThisSong->GetArtist() );
else
ArtistItem = m_pTreelistCtrl->PrependItem(m_pTreelistCtrl->GetRootItem(), pThisSong->GetArtist() );
break;
}
else if (comp == 0) // append here
{
ArtistItem = ThisItem;
break;
}
}
}
// album
ThisItem = m_pTreelistCtrl->GetFirstChild(ArtistItem);
if (!ThisItem.IsOk() )
{
AlbumItem = m_pTreelistCtrl->AppendItem(ArtistItem, pThisSong->GetAlbum() );
}
else
{
while (ThisItem.IsOk() )
{
int comp = pThisSong->GetAlbum().CmpNoCase(m_pTreelistCtrl->GetItemText(ThisItem, 0) );
if (comp > 0) // append
{
LastAlbumItem = ThisItem;
ThisItem = m_pTreelistCtrl->GetNextSibling(LastAlbumItem);
if (!ThisItem.IsOk() )
{
AlbumItem = m_pTreelistCtrl->AppendItem(ArtistItem, pThisSong->GetAlbum() );
break;
}
}
else if (comp < 0) // prepend
{
if (LastAlbumItem.IsOk() )
AlbumItem = m_pTreelistCtrl->InsertItem(ArtistItem, LastAlbumItem, pThisSong->GetAlbum() );
else
AlbumItem = m_pTreelistCtrl->PrependItem(ArtistItem, pThisSong->GetAlbum() );
break;
}
else if (comp == 0) // append here
{
AlbumItem = ThisItem;
break;
}
}
}
// track
ThisItem = m_pTreelistCtrl->GetFirstChild(AlbumItem);
if (!ThisItem.IsOk() )
{
TitleItem = m_pTreelistCtrl->AppendItem(AlbumItem, pThisSong->GetTitle() );
}
else
{
while (ThisItem.IsOk() )
{
wxString temp = m_pTreelistCtrl->GetItemText(ThisItem, TRACK_COLUMN_NUM);
long CurrentTrack = -1;
temp.ToLong(&CurrentTrack);
int ThisTrack = pThisSong->GetTrack();
if (ThisTrack > CurrentTrack) // append
{
LastTitleItem = ThisItem;
ThisItem = m_pTreelistCtrl->GetNextSibling(LastTitleItem);
if (!ThisItem.IsOk() )
{
TitleItem = m_pTreelistCtrl->AppendItem(AlbumItem, pThisSong->GetTitle() );
break;
}
}
else if (ThisTrack < CurrentTrack) // prepend
{
if (LastTitleItem.IsOk() )
TitleItem = m_pTreelistCtrl->InsertItem(AlbumItem, LastTitleItem, pThisSong->GetTitle() );
else
TitleItem = m_pTreelistCtrl->PrependItem(AlbumItem, pThisSong->GetTitle() );
break;
}
else if (ThisTrack == CurrentTrack) // duplicate item
{
return true;
}
}
}
// song info
m_pTreelistCtrl->SetItemText(TitleItem, GENRE_COLUMN_NUM, pThisSong->GetGenre() );
m_pTreelistCtrl->SetItemText(TitleItem, TIME_COLUMN_NUM, pThisSong->GetTimeString() );
m_pTreelistCtrl->SetItemText(TitleItem, TRACK_COLUMN_NUM, wxString::Format("%d", pThisSong->GetTrack() ) );
m_pTreelistCtrl->SetItemText(TitleItem, YEAR_COLUMN_NUM, wxString::Format("%d", pThisSong->GetYear() ) );
m_pTreelistCtrl->SetItemText(TitleItem, TYPE_COLUMN_NUM, pThisSong->GetType() );
m_pTreelistCtrl->SetItemText(TitleItem, BITRATE_COLUMN_NUM, wxString::Format("%d", pThisSong->GetBitRate() ) );
m_pTreelistCtrl->SetItemText(TitleItem, SAMPLERATE_COLUMN_NUM, wxString::Format("%d", pThisSong->GetSampleRate() ) );
CListItemData* pData = new CListItemData(pThisSong->GetID() );
m_pTreelistCtrl->SetItemData(TitleItem, pData);
m_ItemCount++;
return true;
}
bool CMusicLibrary::DeleteMedia(CMedia* pMedia)
{
return true;
}
bool CMusicLibrary::GetMedia(int Id, CMedia* pMedia)
{
wxString SqlStr = wxString::Format("SELECT ROWID,* FROM main.%s WHERE ROWID=%d", m_pDevice->GetDeviceName(), Id);
cmsSQLQueryId* pQueryId = NULL;
bool RetVal = false;
if (m_pDatabase->BeginQuery(SqlStr, &pQueryId) )
{
if (m_pDatabase->GetNextRowFromQuery(pQueryId) == SQLITE_ROW)
{
this->GetSongFromQuery(pQueryId, static_cast<CSong*>(pMedia) );
RetVal = true;
}
}
m_pDatabase->EndQuery(&pQueryId);
return RetVal;
}
bool CMusicLibrary::SaveMedia(CMedia* pMedia)
{
CSong* pSong = static_cast<CSong*>(pMedia);
long ID = pSong->GetID();
// save the song to the device
wxString Path = this->GetLibraryPath();
bool OK = true;
OK = OK | m_pDevice->AddFolder(cms::ReplaceIllegalPathCharsWithUnderscore(pSong->GetArtist() ), Path);
OK = OK | m_pDevice->AddFolder(cms::ReplaceIllegalPathCharsWithUnderscore(pSong->GetAlbum() ), Path);
Path << cms::ReplaceIllegalPathCharsWithUnderscore(pSong->GetTitle() ) << ".";
Path << CMedia::GetFileTypeStr(pSong->GetFullPath() );
if (!OK)
{
return false;
}
if (!m_pDevice->SaveMedia(pSong, Path) )
{
return false;
}
// add song to library database
wxString str;
if (pSong->GetID() < 0)
{
str << "INSERT INTO main." << m_pDevice->GetDeviceName()
<< " (col_Artist,col_Album,col_Title,col_Genre,"
<< "col_Time,col_Track,col_Year,col_Type,col_BitRate,col_SampleRate,"
<< "col_Channels,col_Comment,col_FullPath) VALUES ("
<< "'" << cms::sqlEscapeQuotes(pSong->GetArtist() ) << "',"
<< "'" << cms::sqlEscapeQuotes(pSong->GetAlbum() ) << "',"
<< "'" << cms::sqlEscapeQuotes(pSong->GetTitle() ) << "',"
<< "'" << cms::sqlEscapeQuotes(pSong->GetGenre() ) << "',"
<< "'" << pSong->GetTimeString() << "',"
<< "'" << pSong->GetTrack() << "',"
<< "'" << pSong->GetYear() << "',"
<< "'" << pSong->GetType() << "',"
<< "'" << pSong->GetBitRate() << "',"
<< "'" << pSong->GetSampleRate() << "',"
<< "'" << pSong->GetChannels() << "',"
<< "'" << cms::sqlEscapeQuotes(pSong->GetComment() ) << "',"
<< "'" << cms::sqlEscapeQuotes(pSong->GetFullPath() ) << "')";
}
else
{
str << "UPDATE main." << m_pDevice->GetDeviceName() << " SET "
<< "col_Artist=" << cms::sqlEscapeQuotes(pSong->GetArtist() ) << ","
<< "col_Album=" << cms::sqlEscapeQuotes(pSong->GetAlbum() ) << ","
<< "col_Title=" << cms::sqlEscapeQuotes(pSong->GetTitle() ) << ","
<< "col_Genre=" << cms::sqlEscapeQuotes(pSong->GetGenre() ) << ","
<< "col_Time=" << pSong->GetTimeString() << ","
<< "col_Track=" << pSong->GetTrack() << ","
<< "col_Year=" << pSong->GetYear() << ","
<< "col_Type=" << pSong->GetType() << ","
<< "col_BitRate=" << pSong->GetBitRate() << ","
<< "col_SampleRate=" << pSong->GetSampleRate() << ","
<< "col_Channels=" << pSong->GetChannels() << ","
<< "col_Comment=" << cms::sqlEscapeQuotes(pSong->GetComment() ) << ","
<< "col_FullPath=" << cms::sqlEscapeQuotes(pSong->GetFullPath() )
<< " WHERE ROWID=" << pSong->GetID();
}
if (!m_pDatabase->ProcessStatement(str) )
{
return false;
}
return true;
}
void CMusicLibrary::GetSongFromQuery(cmsSQLQueryId* pQueryId, CSong* pSong)
{
pSong->SetID(m_pDatabase->GetItemAsInteger(pQueryId, 0) );
pSong->SetArtist(m_pDatabase->GetItem(pQueryId, 1) );
pSong->SetAlbum(m_pDatabase->GetItem(pQueryId, 2) );
pSong->SetTitle(m_pDatabase->GetItem(pQueryId, 3) );
pSong->SetGenre(m_pDatabase->GetItem(pQueryId, 4) );
pSong->SetTimeString(m_pDatabase->GetItem(pQueryId, 5) );
pSong->SetTrack(m_pDatabase->GetItemAsInteger(pQueryId, 6) );
pSong->SetYear(m_pDatabase->GetItemAsInteger(pQueryId, 7) );
pSong->SetType(m_pDatabase->GetItem(pQueryId, 8) );
pSong->SetBitRate(m_pDatabase->GetItemAsInteger(pQueryId, 9) );
pSong->SetSampleRate(m_pDatabase->GetItemAsInteger(pQueryId, 10) );
pSong->SetChannels(m_pDatabase->GetItemAsInteger(pQueryId, 11) );
pSong->SetComment(m_pDatabase->GetItem(pQueryId, 12) );
pSong->SetFullPath(m_pDatabase->GetItem(pQueryId, 13) );
}
void CMusicLibrary::OnTreeListItemChecked(wxTreeListEvent& Event)
{
wxTreeListItem Item = Event.GetItem();
wxCheckBoxState State = m_pTreelistCtrl->GetCheckedState(Item);
m_pTreelistCtrl->CheckItemRecursively(Item, State);
m_pTreelistCtrl->UpdateItemParentStateRecursively(Item);
}
void CMusicLibrary::OnTreeListItemRightClick(wxTreeListEvent& Event)
{
wxTreeListItem ThisItem = Event.GetItem();
wxClientData* pClientData = m_pTreelistCtrl->GetItemData(ThisItem);
if (pClientData == NULL)
{
return;
}
CListItemData* pData = static_cast<CListItemData*>(pClientData);
CSong Song;
this->GetMedia(pData->GetId(), &Song);
wxMenu PopupMenu;
PopupMenu.Append(idPOPUP_MENU_PLAY, "Play", "Play this song");
PopupMenu.Append(idPOPUP_MENU_DELETE, "Delete", "Delete this song");
int Selection = m_pTreelistCtrl->GetPopupMenuSelectionFromUser(PopupMenu);
switch (Selection)
{
case idPOPUP_MENU_PLAY:
{
m_pMusicPlayerCtrl->Load(&Song);
}
break;
case idPOPUP_MENU_DELETE:
{
if (wxYES == wxMessageBox("This action will permanently remove the selected item.\nAre you sure you want to do this?",
"Remove Item",
wxYES_NO | wxCENTRE | wxICON_EXCLAMATION) )
{
if (this->DeleteMedia(&Song) )
{
wxMessageBox("Item deleted!");
}
}
}
break;
case wxID_NONE:
default:
return;
}
}
| [
"raymond.marsh@phx-rising.net"
] | raymond.marsh@phx-rising.net |
753fd21f34d6b669525c876b1040a1699c18f59a | 6456978ebb4921fdb95e699419b85ceade701be0 | /homework/06/main.cpp | 84a1711b525c59b6d8088c2add93fe25a410d98e | [] | no_license | LevKats/msu_cpp_automn_2019 | ba74800a3a1359999e92efac14169ce8f6e28423 | a341e000419beefe5768ede92e60091ea2727727 | refs/heads/master | 2020-08-08T21:07:21.851684 | 2020-01-21T01:09:37 | 2020-01-21T01:09:37 | 213,919,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,323 | cpp | #include <iostream>
#include <cassert>
#include <string>
#include "format.h"
void test_no_args_empty() {
bool error = false;
try {
auto text = format(nullptr);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_no_args_extra_open_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj { slkkldskf");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_no_args_extra_close_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj } slkkldskf");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_one_arg_empty() {
bool error = false;
try {
auto text = format(nullptr, "one");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_one_arg_extra_open_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} { slkkldskf", "one");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_one_arg_extra_close_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} } slkkldskf", "one");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_one_arg_extra_indicies() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} {4} slkkldskf", "one");
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_several_args_empty() {
bool error = false;
try {
auto text = format(nullptr, "one", 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_several_args_extra_open_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} {1} { slkkldskf", "one", 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_several_args_extra_close_parentheses() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} } {1} slkkldskf", "one", 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_several_args_extra_indicies() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} {4} {1} slkkldskf", "one", 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
void test_no_args_ok() {
auto text = format("sdklfjsldkfj slkkldskf");
assert(text == "sdklfjsldkfj slkkldskf");
}
void test_one_arg_ok() {
auto text = format("sdklfjsldkfj {0} slkklds{0}kf{0} {0}", 24);
assert(text == "sdklfjsldkfj 24 slkklds24kf24 24");
}
void test_several_args_ok() {
auto text = format("sdklfjsldkfj {0} slkklds{0}kf{1} {0} {1}", 24, 1);
assert(text == "sdklfjsldkfj 24 slkklds24kf1 24 1");
}
void test_several_extra_args_ok() {
auto text = format("sdklfjsldkfj {0} slkklds{0}kf{1} {0} {1}", 24, 1,
"one");
assert(text == "sdklfjsldkfj 24 slkklds24kf1 24 1");
}
void test_strange_indicies() {
bool error = false;
try {
auto text = format("sdklfjsldkfj {0} {4} {1} slkkldskf", "one", 2, 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
error = false;
try {
auto text = format("sdklfjsldkfj {0} {:(} {1} slkkldskf", "one", 2, 2);
}
catch (const std::runtime_error &e) {
error = true;
}
assert(error);
}
int main() {
test_no_args_empty();
test_no_args_extra_open_parentheses();
test_no_args_extra_close_parentheses();
test_one_arg_empty();
test_one_arg_extra_open_parentheses();
test_one_arg_extra_close_parentheses();
test_one_arg_extra_indicies();
test_several_args_empty();
test_several_args_extra_open_parentheses();
test_several_args_extra_close_parentheses();
test_several_args_extra_indicies();
test_no_args_ok();
test_one_arg_ok();
test_several_args_ok();
test_several_extra_args_ok();
test_strange_indicies();
return 0;
}
| [
"lev-katz@mail.ru"
] | lev-katz@mail.ru |
92cce97f2a81753c3e3ce536cb4fc2a6622da2e3 | 0ea6177fa7255e914496f061d39773ca63f880e3 | /Include/FixedRingBuffer.hpp | 925a7f99760a6cb7d9784e25ab46eb46f1ffc6ab | [] | no_license | h-sigma/Blunderbuss | fdf6f15172e280550c81b35cc9fefd8d7ed2eb1a | 189ce6af282f9d73008491dbe693e1a21e316379 | refs/heads/master | 2020-08-22T10:04:37.146430 | 2019-10-24T16:40:59 | 2019-10-24T16:40:59 | 216,371,398 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,242 | hpp | //
// Created by harshdeep on 19/10/19.
//
#ifndef BLUNDERBUSS_FIXEDRINGBUFFER_HPP
#define BLUNDERBUSS_FIXEDRINGBUFFER_HPP
#include <cstddef>
#include <array>
#include <optional>
template <typename T, std::size_t Size>
class FixedRingBuffer
{
public:
explicit FixedRingBuffer() = default;
bool push(const T&) noexcept(std::is_nothrow_copy_assignable_v<T>) ;
bool push(T&&) noexcept(std::is_nothrow_move_constructible_v<T>) ;
template<typename... Args> T* emplace(Args &&...);
std::optional<T> pop() noexcept(std::is_nothrow_move_constructible_v<T>) ;
void clear() noexcept;
[[nodiscard]] bool is_empty() const noexcept ;
[[nodiscard]] bool is_full() const noexcept ;
[[nodiscard]] constexpr std::size_t capacity() const noexcept ;
[[nodiscard]] std::size_t size() const noexcept ;
private:
std::array<T, Size> buffer_;
std::size_t tail_ = 0u, head_ = 0u;
bool full_ = false;
// tail always rests at the next element to be inserted
};
template<typename T, std::size_t Size>
bool FixedRingBuffer<T, Size>::push(const T& t) noexcept(std::is_nothrow_copy_assignable_v<T>) {
if(is_full())
return false;
buffer_[tail_] = t;
tail_++;
if(tail_ == Size)
tail_ = 0u;
if(tail_ == head_)
full_ = true;
return true;
}
template<typename T, std::size_t Size>
bool FixedRingBuffer<T, Size>::push(T && t) noexcept(std::is_nothrow_move_constructible_v<T>) {
if(is_full())
return false;
buffer_[tail_] = t;
tail_++;
if(tail_ == Size)
tail_ = 0u;
if(tail_ == head_)
full_ = true;
return true;
}
template<typename T, std::size_t Size>
std::optional<T> FixedRingBuffer<T, Size>::pop() noexcept(std::is_nothrow_move_constructible_v<T>) {
if(is_empty())
return {};
auto found = head_;
head_++;
if(head_ == Size)
head_ = 0u;
full_ = false;
return {std::move(buffer_[found])};
}
template<typename T, std::size_t Size>
bool FixedRingBuffer<T, Size>::is_empty() const noexcept {
return head_ == tail_ && !is_full();
}
template<typename T, std::size_t Size>
bool FixedRingBuffer<T, Size>::is_full() const noexcept {
return full_;
}
template<typename T, std::size_t Size>
void FixedRingBuffer<T, Size>::clear() noexcept {
head_ == tail_ == 0u;
full_ = false;
}
template<typename T, std::size_t Size>
constexpr std::size_t FixedRingBuffer<T, Size>::capacity() const noexcept {
return Size;
}
template<typename T, std::size_t Size>
std::size_t FixedRingBuffer<T, Size>::size() const noexcept {
if(tail_ < head_)
return capacity() - (head_ - tail_) ;
else if(head_ < tail_)
return tail_ - head_;
else
{
if(is_full())
return capacity();
else
return 0u; //empty
}
}
template<typename T, std::size_t Size>
template<typename... Args>
T* FixedRingBuffer<T, Size>::emplace(Args &&... args) {
if(is_full())
return nullptr;
new(&buffer_[tail_]) T(std::forward<Args>(args)...);
auto t = &buffer_[tail_];
tail_++;
if(tail_ == Size)
tail_ = 0u;
if(tail_ == head_)
full_ = true;
return t;
}
#endif //BLUNDERBUSS_FIXEDRINGBUFFER_HPP
| [
"harshdeepsinghmudhar@gmail.com"
] | harshdeepsinghmudhar@gmail.com |
fc81d2d14253c33541ae0aa04a361f5043b6627e | a7764174fb0351ea666faa9f3b5dfe304390a011 | /inc/Geom_BoundedSurface.hxx | c46294bdc38ff2ffefeaa08db0ae066a6b5a7ef4 | [] | no_license | uel-dataexchange/Opencascade_uel | f7123943e9d8124f4fa67579e3cd3f85cfe52d91 | 06ec93d238d3e3ea2881ff44ba8c21cf870435cd | refs/heads/master | 2022-11-16T07:40:30.837854 | 2020-07-08T01:56:37 | 2020-07-08T01:56:37 | 276,290,778 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,350 | hxx | // This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#ifndef _Geom_BoundedSurface_HeaderFile
#define _Geom_BoundedSurface_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_DefineHandle_HeaderFile
#include <Standard_DefineHandle.hxx>
#endif
#ifndef _Handle_Geom_BoundedSurface_HeaderFile
#include <Handle_Geom_BoundedSurface.hxx>
#endif
#ifndef _Geom_Surface_HeaderFile
#include <Geom_Surface.hxx>
#endif
//! The root class for bounded surfaces in 3D space. A <br>
//! bounded surface is defined by a rectangle in its 2D parametric space, i.e. <br>
//! - its u parameter, which ranges between two finite <br>
//! values u0 and u1, referred to as "First u <br>
//! parameter" and "Last u parameter" respectively, and <br>
//! - its v parameter, which ranges between two finite <br>
//! values v0 and v1, referred to as "First v <br>
//! parameter" and the "Last v parameter" respectively. <br>
//! The surface is limited by four curves which are the <br>
//! boundaries of the surface: <br>
//! - its u0 and u1 isoparametric curves in the u parametric direction, and <br>
//! - its v0 and v1 isoparametric curves in the v parametric direction. <br>
//! A bounded surface is finite. <br>
//! The common behavior of all bounded surfaces is <br>
//! described by the Geom_Surface class. <br>
//! The Geom package provides three concrete <br>
//! implementations of bounded surfaces: <br>
//! - Geom_BezierSurface, <br>
//! - Geom_BSplineSurface, and <br>
//! - Geom_RectangularTrimmedSurface. <br>
//! The first two of these implement well known <br>
//! mathematical definitions of complex surfaces, the third <br>
//! trims a surface using four isoparametric curves, i.e. it <br>
//! limits the variation of its parameters to a rectangle in <br>
//! 2D parametric space. <br>
class Geom_BoundedSurface : public Geom_Surface {
public:
DEFINE_STANDARD_RTTI(Geom_BoundedSurface)
protected:
private:
};
// other Inline functions and methods (like "C++: function call" methods)
#endif
| [
"shoka.sho2@excel.co.jp"
] | shoka.sho2@excel.co.jp |
86b867a8839d54882da725b9cbe00fbadb7e2261 | 6471b7fcd852da00bc35875fd6a55b4c4b9100a1 | /RolandV1HDTallyCCu.ino | c3c8ff91a821dc2e131c5fd780459f312ab222b2 | [] | no_license | DaveTheK/RolandV-1HD-Arduino-TallyLights | d606ca87229649a4f4cd565c7c7155db6f86b3c8 | ce64db0541b62ecbdca8f663ab16facd632a05d6 | refs/heads/main | 2023-03-25T01:46:26.766923 | 2021-03-25T17:05:48 | 2021-03-25T17:05:48 | 350,854,772 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,764 | ino | #include <Adafruit_NeoPixel.h>
#include <Wire.h>
/*
This code is for the Arduino in the Roland V-1HD Tally Light Camera Control Unit CCU
The CCU receives DTM commands over the mic line from the Main unit and sets the appropriate tally lights for each camera,
Code assumes the Tally Lights are Adafruit NEOPIXEL devices
Note the model here is built on 4 15-pixel neopixel strips. Lighting them all with full brightness exceeds the power of the Arduino, so
make sure to supplement the neopixel power.
DTMF Code thanks to Gadget Reboot!
https://github.com/GadgetReboot/MT8870_DTMF
https://youtu.be/Wx6C4k_xxz0
Pinout:
Pin 2-6 from MT8870 Decoder board
Pin 8-11 controls the 4 adafruit neipoxel strips for the camera tally lights
Uses interrupt on pin 2
*/
// Using a Mitel MT8870 board, it sets STQ high when it detects a valid digital, then read its code from D0-D3.
#define STQ 2
#define D0 3
#define D1 4
#define D2 5
#define D3 6
// The board builtin LED is echoed out to the panel so you can tell the Arduino has power
#define ALED 13
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 8
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 15
// Declare our NeoPixel strip objects, we have one strip per camera
// Pins 8, 9, 10 and 11 control neopixels
Adafruit_NeoPixel strip0(LED_COUNT, LED_PIN, NEO_GRB);
Adafruit_NeoPixel strip1(LED_COUNT, LED_PIN + 1, NEO_GRB);
Adafruit_NeoPixel strip2(LED_COUNT, LED_PIN + 2, NEO_GRB);
Adafruit_NeoPixel strip3(LED_COUNT, LED_PIN + 3, NEO_GRB);
// Create an array of neopixel controllers so we can loop through them.
Adafruit_NeoPixel nps[] = {strip0, strip1, strip2, strip3};
bool cameraOn[] = {false, false, false, false};
// preset some colors in advance
uint32_t colourRed, colourGreen, colourBlue, colourWhite;
// this is an interrupt variable indicating a new DTMF tone has been located/received
// a variable is marked volatile to tell the compiler not to assume its state and try to optimize it, since the isr can set this variable asynchronously.
// e.g. an optimizing compiler might say "toneLoc" will never be true since newDTMF is never "called" and decide to take out all the code in the loop!
volatile bool toneLoc = false;
// Interrupt Sevice Routine
// isr to set data received flag upon interrupt. While this could be just tested each time through the loop, it's good to know about interrupts!
void newDTMF() {
// just set this variable to true and we wil pick it up next time trough the loop
toneLoc = true;
}
void setStripColour (Adafruit_NeoPixel *strip, uint32_t col)
{
for (int i = 0; i < LED_COUNT; i++)
{
strip->setPixelColor(i, col);
}
strip->show();
}
void setup() {
// Turn Power LED ON
pinMode (LED_BUILTIN, OUTPUT);
digitalWrite (LED_BUILTIN, HIGH);
// set the pins coming from the MT8870 board as input so we can read status and which dtmf tone arrived.
pinMode(D0, INPUT);
pinMode(D1, INPUT);
pinMode(D2, INPUT);
pinMode(D3, INPUT);
pinMode(STQ, INPUT);
// if you are not familiar with interrupts, this is a command that runs the function newDTMF whenever the 8870 raises the STQ voltage signallng
// a new DTMF tone has been decoded.
// run isr to set data received flag when interrupt occurs on pin 2
attachInterrupt(digitalPinToInterrupt(STQ), newDTMF, RISING);
colourBlue = strip0.Color (0, 0, 8); // make blue low intensity
colourGreen = strip0.Color (0, 8, 0); // make green low intensity
colourRed = strip0.Color (255, 0, 0); // make red high intensity
colourWhite = strip0.Color (16, 16, 16); // make white med intensity
Serial.begin(9600);
Serial.println("ROLAND V-1HD Camera Control Unit");
for (int i = 0; i < 4; i++)
{
// initialize each neopixel strip
nps[i].begin();
nps[i].show();
nps[i].setBrightness(250);
}
for (int i = 0; i < 4; i++)
{
nps[i].clear(); // Set all pixels in RAM to 0 (off)
for (int j = 0; j < LED_COUNT; j++)
{
// initialize all strips to aqua/cyan
uint32_t colour = strip0.Color (0, 16, 16);
nps[i].setPixelColor (j, colour);
nps[i].show();
delay (25);
}
}
}
void loop() {
uint32_t colour;
int val;
// We wait until the 8870 detects a tone, which creates an interrupt which then sets this variable toneLoc to true;
if (toneLoc)
{
digitalWrite (ALED, LOW);
toneLoc = false;
cameraOn[0] = digitalRead(D3); // camera 1
cameraOn[1] = digitalRead(D2); // camera 2
cameraOn[2] = digitalRead(D1); // camera 3
cameraOn[3] = digitalRead(D0); // camera 4
// compose val into a value from 0 to 15 so we can determine if this is a red tally command or a green tally command
val = (cameraOn[3] << 3 | cameraOn[2] << 2 | cameraOn[1] << 1 | cameraOn[0]);
// The special values 7, 11, 13, and 14 are used to set the green standby tally
if ((val == 7) || (val == 11) || (val == 13) || (val == 14))
{
switch (val) {
case 7: {
setStripColour (&nps[0], colourGreen);
} break;
case 11: {
setStripColour (&nps[1], colourGreen);
} break;
case 13: {
setStripColour (&nps[2], colourGreen);
} break;
case 14: {
setStripColour (&nps[3], colourGreen);
} break;
}
}
else
for (int i = 4; i >= 0; i--)
// some weird behavior in the neopixel timimg made it more reliable to go this direction. don't know why.
{
setStripColour (&nps[i], cameraOn[i] ? colourRed : colourBlue);
}
digitalWrite (ALED, HIGH);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
bd89349db2e52043456666d965b2773ee7e3713b | 253e782c6cfb45ef6e7761c23fb12df8717e783f | /Chapter02/Source/Chapter2/ColoredTexture.h | 7168b1219238e2afd7373cf6cd8542fcef02f771 | [
"MIT"
] | permissive | sunithshetty/Unreal-Engine-4-Scripting-with-CPlusPlus-Cookbook | 548639184020fbd483e1bebb15ffd93f377408bd | 0b78eed3f712bf2965a981b28801da528b4231bf | refs/heads/master | 2021-01-11T04:41:18.777016 | 2016-10-17T09:11:29 | 2016-10-17T09:11:29 | 71,113,373 | 13 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 335 | h | #pragma once
#include "Chapter2.h"
#include "ColoredTexture.generated.h"
USTRUCT()
struct CHAPTER2_API FColoredTexture
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )
UTexture* Texture;
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )
FLinearColor Color;
};
| [
"packt.suniths@gmail.com"
] | packt.suniths@gmail.com |
7d859d88124caac5ad6e216b144c317ba8a5d8d2 | 36c0e07fba5319f186a135a41f2ecd2445656894 | /systemc/src/sysc/kernel/sc_process.h | e740febd9f90bbdf659ec02307979f5caa191f92 | [
"Apache-2.0",
"LLVM-exception"
] | permissive | mfkiwl/systemc-compiler | 5f53c3dbd52439997289b3947d863d9d8b3c90b4 | 96d94cac721224745cffe3daaee35c406af36e9e | refs/heads/main | 2023-06-12T06:39:48.707703 | 2021-07-08T11:10:41 | 2021-07-08T11:10:41 | 385,031,718 | 1 | 0 | NOASSERTION | 2021-07-11T19:05:42 | 2021-07-11T19:05:42 | null | UTF-8 | C++ | false | false | 32,913 | h | /*****************************************************************************
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
more contributor license agreements. See the NOTICE file distributed
with this work for additional information regarding copyright ownership.
Accellera 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.
*****************************************************************************/
/*****************************************************************************
sc_process.h -- Process base class support.
Original Author: Andy Goodrich, Forte Design Systems, 04 August 2005
CHANGE LOG AT THE END OF THE FILE
*****************************************************************************/
#if !defined(sc_process_h_INCLUDED)
#define sc_process_h_INCLUDED
#include "sysc/kernel/sc_constants.h"
#include "sysc/kernel/sc_object.h"
#include "sysc/kernel/sc_kernel_ids.h"
#include "sysc/communication/sc_export.h"
#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
#pragma warning(push)
#pragma warning(disable: 4251) // DLL import for std::vector
#endif
namespace sc_core {
// Forward declarations:
class sc_process_handle;
class sc_thread_process;
class sc_reset;
SC_API const char* sc_gen_unique_name( const char*, bool preserve_first );
SC_API sc_process_handle sc_get_current_process_handle();
void sc_thread_cor_fn( void* arg );
SC_API bool timed_out( sc_simcontext* );
SC_API extern bool sc_allow_process_control_corners; // see sc_simcontext.cpp.
// Process handles as forward references:
typedef class sc_cthread_process* sc_cthread_handle;
typedef class sc_method_process* sc_method_handle;
typedef class sc_thread_process* sc_thread_handle;
// Standard process types:
enum sc_curr_proc_kind
{
SC_NO_PROC_,
SC_METHOD_PROC_,
SC_THREAD_PROC_,
SC_CTHREAD_PROC_
};
// Descendant information for process hierarchy operations:
enum sc_descendant_inclusion_info {
SC_NO_DESCENDANTS=0,
SC_INCLUDE_DESCENDANTS,
SC_INVALID_DESCENDANTS
};
//==============================================================================
// CLASS sc_process_host
//
// This is the base class for objects which may have processes defined for
// their methods (e.g., sc_module)
//==============================================================================
class SC_API sc_process_host
{
public:
sc_process_host() {}
virtual ~sc_process_host() { } // Needed for cast check for sc_module.
void defunct() {}
};
//==============================================================================
// CLASS sc_process_monitor
//
// This class provides a way of monitoring a process' status (e.g., waiting
// for a thread to complete its execution.) This class is intended to be a base
// class for classes which need to monitor a process or processes (e.g.,
// sc_join.) Its methods should be overloaded where notifications are desired.
//==============================================================================
class SC_API sc_process_monitor {
public:
enum {
spm_exit = 0
};
virtual ~sc_process_monitor() {}
virtual void signal(sc_thread_handle thread_p, int type);
};
inline void sc_process_monitor::signal(sc_thread_handle , int ) {}
//------------------------------------------------------------------------------
// PROCESS INVOCATION METHOD OR FUNCTION:
//
// Define SC_USE_MEMBER_FUNC_PTR if we want to use member function pointers
// to implement process dispatch. Otherwise, we'll use a hack that involves
// creating a templated invocation object which will invoke the member
// function. This should not be necessary, but some compilers (e.g., VC++)
// do not allow the conversion from `void (callback_tag::*)()' to
// `void (sc_process_host::*)()'. This is supposed to be OK as long as the
// dynamic type is correct. C++ Standard 5.4 "Explicit type conversion",
// clause 7: a pointer to member of derived class type may be explicitly
// converted to a pointer to member of an unambiguous non-virtual base class
// type.
//-----------------------------------------------------------------------------
#if defined(_MSC_VER)
#if ( _MSC_VER > 1200 )
# define SC_USE_MEMBER_FUNC_PTR
#endif
#else
# define SC_USE_MEMBER_FUNC_PTR
#endif
// COMPILER DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
#if defined(SC_USE_MEMBER_FUNC_PTR)
typedef void (sc_process_host::*SC_ENTRY_FUNC)();
# define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
# define SC_MAKE_FUNC_PTR(callback_tag, func) \
static_cast<sc_core::SC_ENTRY_FUNC>(&callback_tag::func)
// COMPILER NOT DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
#else // !defined(SC_USE_MEMBER_FUNC_PTR)
class SC_API sc_process_call_base {
public:
inline sc_process_call_base()
{
}
virtual ~sc_process_call_base()
{
}
virtual void invoke(sc_process_host* host_p)
{
}
};
extern sc_process_call_base sc_process_defunct;
template<class T>
class sc_process_call : public sc_process_call_base {
public:
sc_process_call( void (T::*method_p)() ) :
sc_process_call_base()
{
m_method_p = method_p;
}
virtual ~sc_process_call()
{
}
virtual void invoke(sc_process_host* host_p)
{
(((T*)host_p)->*m_method_p)();
}
protected:
void (T::*m_method_p)(); // Method implementing the process.
};
typedef sc_process_call_base* SC_ENTRY_FUNC;
# define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
# define SC_MAKE_FUNC_PTR(callback_tag, func) \
(::sc_core::SC_ENTRY_FUNC) (new \
::sc_core::sc_process_call<callback_tag>(&callback_tag::func))
#endif // !defined(SC_USE_MEMBER_FUNC_PTR)
extern SC_API void sc_set_stack_size( sc_thread_handle, std::size_t );
class sc_event;
class sc_event_list;
class sc_name_gen;
class sc_spawn_options;
class sc_unwind_exception;
//==============================================================================
// CLASS sc_throw_it<EXCEPT> - ARBITRARY EXCEPTION CLASS
//
// This class serves as a way of throwing an execption for an aribtrary type
// without knowing what that type is. A true virtual method in the base
// class is used to actually throw the execption. A pointer to the base
// class is used internally removing the necessity of knowing what the type
// of EXCEPT is for code internal to the library.
//
// Note the clone() true virtual method. This is used to allow instances
// of the sc_throw_it<EXCEPT> class to be easily garbage collected. Since
// an exception may be propogated to more than one process knowing when
// to garbage collect is non-trivial. So when a call is made to
// sc_process_handle::throw_it() an instance of sc_throw_it<EXCEPT> is
// allocated on the stack. For each process throwing the exception a copy is
// made via clone(). That allows those objects to be deleted by the individual
// processes when they are no longer needed (in this implementation of SystemC
// that deletion will occur each time a new exception is thrown ( see
// sc_thread_process::suspend_me() ).
//==============================================================================
class SC_API sc_throw_it_helper {
public:
virtual sc_throw_it_helper* clone() const = 0;
virtual void throw_it() = 0;
sc_throw_it_helper() {}
virtual ~sc_throw_it_helper() {}
};
template<typename EXCEPT>
class sc_throw_it : public sc_throw_it_helper
{
typedef sc_throw_it<EXCEPT> this_type;
public:
sc_throw_it( const EXCEPT& value ) : m_value(value) { }
virtual ~sc_throw_it() {}
virtual inline this_type* clone() const { return new this_type(m_value); }
virtual inline void throw_it() { throw m_value; }
protected:
EXCEPT m_value; // value to be thrown.
};
//==============================================================================
// CLASS sc_process_b - USER INITIATED DYNAMIC PROCESS SUPPORT:
//
// This class implements the base class for a threaded process_base process
// whose semantics are provided by the true virtual method semantics().
// Classes derived from this one will provide a version of semantics which
// implements the desired semantics. See the sc_spawn_xxx classes below.
//
// Notes:
// (1) Object instances of this class maintain a reference count of
// outstanding handles. When the handle count goes to zero the
// object will be deleted.
// (2) Descriptions of the methods and operators in this class appear with
// their implementations.
// (3) The m_sticky_reset field is used to handle synchronous resets that
// are enabled via the sc_process_handle::sync_reset_on() method. These
// resets are not generated by a signal, but rather are modal by
// method call: sync_reset_on - sync_reset_off.
//
//==============================================================================
class SC_API sc_process_b : public sc_object {
friend class sc_simcontext; // Allow static processes to have base.
friend class sc_cthread_process; // Child can access parent.
friend class sc_method_process; // Child can access parent.
friend class sc_process_handle; // Allow handles to modify ref. count.
friend class sc_process_table; // Allow process_table to modify ref. count.
friend class sc_thread_process; // Child can access parent.
friend class sc_event;
friend class sc_object;
friend class sc_port_base;
friend class sc_runnable;
friend class sc_sensitive;
friend class sc_sensitive_pos;
friend class sc_sensitive_neg;
friend class sc_module;
friend class sc_report_handler;
friend class sc_reset;
friend class sc_reset_finder;
friend class sc_unwind_exception;
friend SC_API const char* sc_gen_unique_name( const char*, bool preserve_first );
friend SC_API sc_process_handle sc_get_current_process_handle();
friend void sc_thread_cor_fn( void* arg );
friend SC_API bool timed_out( sc_simcontext* );
public:
enum process_throw_type {
THROW_NONE = 0,
THROW_KILL,
THROW_USER,
THROW_ASYNC_RESET,
THROW_SYNC_RESET
};
enum process_state {
ps_bit_disabled = 1, // process is disabled.
ps_bit_ready_to_run = 2, // process is ready to run.
ps_bit_suspended = 4, // process is suspended.
ps_bit_zombie = 8, // process is a zombie.
ps_normal = 0 // must be zero.
};
enum reset_type { // types for sc_process_b::reset_process()
reset_asynchronous = 0, // asynchronous reset.
reset_synchronous_off, // turn off synchronous reset sticky bit.
reset_synchronous_on // turn on synchronous reset sticky bit.
};
enum trigger_t
{
STATIC,
EVENT,
OR_LIST,
AND_LIST,
TIMEOUT,
EVENT_TIMEOUT,
OR_LIST_TIMEOUT,
AND_LIST_TIMEOUT
};
protected:
enum spawn_t {
SPAWN_ELAB = 0x0, // spawned during elaboration (static process)
SPAWN_START = 0x1, // spawned during simulation start (dynamic process)
SPAWN_SIM = 0x2 // spawned during simulation (dynamic process)
};
public:
sc_process_b( const char* name_p, bool is_thread, bool free_host,
SC_ENTRY_FUNC method_p, sc_process_host* host_p,
const sc_spawn_options* opt_p );
protected:
// may not be deleted manually (called from destroy_process())
virtual ~sc_process_b();
public:
inline int current_state() { return m_state; }
bool dont_initialize() const { return m_dont_init; }
virtual void dont_initialize( bool dont );
std::string dump_state() const;
const ::std::vector<sc_object*>& get_child_objects() const;
inline sc_curr_proc_kind proc_kind() const;
sc_event& reset_event();
sc_event& terminated_event();
const std::vector<const sc_event*>& get_static_events() {return m_static_events;}
public:
static inline sc_process_handle last_created_process_handle();
protected:
virtual void add_child_object( sc_object* );
void add_static_event( const sc_event& );
bool dynamic() const { return m_dynamic_proc != SPAWN_ELAB; }
const char* gen_unique_name( const char* basename_, bool preserve_first );
inline sc_report* get_last_report() { return m_last_report_p; }
inline bool is_disabled() const;
inline bool is_runnable() const;
static inline sc_process_b* last_created_process_base();
virtual bool remove_child_object( sc_object* );
void remove_dynamic_events( bool skip_timeout = false );
void remove_static_events();
inline void set_last_report( sc_report* last_p )
{
delete m_last_report_p;
m_last_report_p = last_p;
}
inline bool timed_out() const;
void report_error( const char* msgid, const char* msg = "" ) const;
void report_immediate_self_notification() const;
protected: // process control methods:
virtual void disable_process(
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
void disconnect_process();
virtual void enable_process(
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
inline void initially_in_reset( bool async );
inline bool is_unwinding() const;
inline bool start_unwinding();
inline bool clear_unwinding();
virtual void kill_process(
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
void reset_changed( bool async, bool asserted );
void reset_process( reset_type rt,
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS );
virtual void resume_process(
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
virtual void suspend_process(
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
virtual void throw_user( const sc_throw_it_helper& helper,
sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
virtual void throw_reset( bool async ) = 0;
virtual bool terminated() const;
void trigger_reset_event();
private:
void delete_process();
inline void reference_decrement();
inline void reference_increment();
protected:
inline void semantics();
// debugging stuff:
public:
const char* file;
int lineno;
int proc_id;
protected:
int m_active_areset_n; // number of aresets active.
int m_active_reset_n; // number of resets active.
bool m_dont_init; // true: no initialize call.
spawn_t m_dynamic_proc; // SPAWN_ELAB, SPAWN_START, SPAWN_SIM
const sc_event* m_event_p; // Dynamic event waiting on.
int m_event_count; // number of events.
const sc_event_list* m_event_list_p; // event list waiting on.
sc_process_b* m_exist_p; // process existence link.
bool m_free_host; // free sc_semantic_host_p.
bool m_has_reset_signal; // has reset_signal_is.
bool m_has_stack; // true is stack present.
bool m_is_thread; // true if this is thread.
sc_report* m_last_report_p; // last report this process.
sc_name_gen* m_name_gen_p; // subprocess name generator
sc_curr_proc_kind m_process_kind; // type of process.
int m_references_n; // outstanding handles.
std::vector<sc_reset*> m_resets; // resets for process.
sc_event* m_reset_event_p; // reset event.
sc_event* m_resume_event_p; // resume event.
sc_process_b* m_runnable_p; // sc_runnable link
sc_process_host* m_semantics_host_p; // host for semantics.
SC_ENTRY_FUNC m_semantics_method_p; // method for semantics.
int m_state; // process state.
std::vector<const sc_event*> m_static_events; // static events waiting on.
bool m_sticky_reset; // see note 3 above.
sc_event* m_term_event_p; // terminated event.
sc_throw_it_helper* m_throw_helper_p; // what to throw.
process_throw_type m_throw_status; // exception throwing status
bool m_timed_out; // true if we timed out.
sc_event* m_timeout_event_p; // timeout event.
trigger_t m_trigger_type; // type of trigger using.
bool m_unwinding; // true if unwinding stack.
protected:
static sc_process_b* m_last_created_process_p; // Last process created.
};
typedef sc_process_b sc_process_b; // For compatibility.
//------------------------------------------------------------------------------
//"sc_process_b::XXXX_child_YYYYY"
//
// These methods provide child object support.
//------------------------------------------------------------------------------
inline void
sc_process_b::add_child_object( sc_object* object_p )
{
sc_object::add_child_object( object_p );
reference_increment();
}
inline bool
sc_process_b::remove_child_object( sc_object* object_p )
{
if ( sc_object::remove_child_object( object_p ) ) {
reference_decrement();
return true;
}
else
{
return false;
}
}
inline const ::std::vector<sc_object*>&
sc_process_b::get_child_objects() const
{
return m_child_objects;
}
//------------------------------------------------------------------------------
//"sc_process_b::initially_in_reset"
//
// This inline method is a callback to indicate that a reset is active at
// start up. This is because the signal will have been initialized before
// a reset linkage for it is set up, so we won't get a reset_changed()
// callback.
// async = true if this an asynchronous reset.
//------------------------------------------------------------------------------
inline void sc_process_b::initially_in_reset( bool async )
{
if ( async )
m_active_areset_n++;
else
m_active_reset_n++;
}
//------------------------------------------------------------------------------
//"sc_process_b::is_disabled"
//
// This method returns true if this process is disabled.
//------------------------------------------------------------------------------
inline bool sc_process_b::is_disabled() const
{
return (m_state & ps_bit_disabled) ? true : false;
}
//------------------------------------------------------------------------------
//"sc_process_b::is_runnable"
//
// This method returns true if this process is runnable. That is indicated
// by a non-zero m_runnable_p field.
//------------------------------------------------------------------------------
inline bool sc_process_b::is_runnable() const
{
return m_runnable_p != 0;
}
//------------------------------------------------------------------------------
//"sc_process_b::is_unwinding"
//
// This method returns true if this process is unwinding from a kill or reset.
//------------------------------------------------------------------------------
inline bool sc_process_b::is_unwinding() const
{
return m_unwinding;
}
//------------------------------------------------------------------------------
//"sc_process_b::start_unwinding"
//
// This method flags that this object instance should start unwinding if the
// current throw status requires an unwind.
//
// Result is true if the flag is set, false if the flag is already set.
//------------------------------------------------------------------------------
inline bool sc_process_b::start_unwinding()
{
if ( !m_unwinding )
{
switch( m_throw_status )
{
case THROW_KILL:
case THROW_ASYNC_RESET:
case THROW_SYNC_RESET:
m_unwinding = true;
return true;
case THROW_USER:
default:
break;
}
}
return false;
}
//------------------------------------------------------------------------------
//"sc_process_b::clear_unwinding"
//
// This method clears this object instance's throw status and always returns
// true.
//------------------------------------------------------------------------------
inline bool sc_process_b::clear_unwinding()
{
m_unwinding = false;
return true;
}
//------------------------------------------------------------------------------
//"sc_process_b::last_created_process_base"
//
// This virtual method returns the sc_process_b pointer for the last
// created process. It is only used internally by the simulator.
//------------------------------------------------------------------------------
inline sc_process_b* sc_process_b::last_created_process_base()
{
return m_last_created_process_p;
}
//------------------------------------------------------------------------------
//"sc_process_b::proc_kind"
//
// This method returns the kind of this process.
//------------------------------------------------------------------------------
inline sc_curr_proc_kind sc_process_b::proc_kind() const
{
return m_process_kind;
}
//------------------------------------------------------------------------------
//"sc_process_b::reference_decrement"
//
// This inline method decrements the number of outstanding references to this
// object instance. If the number of references goes to zero, this object
// can be deleted in "sc_process_b::delete_process()".
//------------------------------------------------------------------------------
inline void sc_process_b::reference_decrement()
{
m_references_n--;
if ( m_references_n == 0 ) delete_process();
}
//------------------------------------------------------------------------------
//"sc_process_b::reference_increment"
//
// This inline method increments the number of outstanding references to this
// object instance.
//------------------------------------------------------------------------------
inline void sc_process_b::reference_increment()
{
sc_assert(m_references_n != 0);
m_references_n++;
}
//------------------------------------------------------------------------------
//"sc_process_b::semantics"
//
// This inline method invokes the semantics for this object instance.
// We check to see if we are initially in reset and then invoke the
// process semantics.
//
// Notes:
// (1) For a description of the process reset mechanism see the top of
// the file sc_reset.cpp.
//------------------------------------------------------------------------------
struct SC_API scoped_flag
{
scoped_flag( bool& b ) : ref(b){ ref = true; }
~scoped_flag() { ref = false; }
bool& ref;
private:
scoped_flag& operator=(const scoped_flag&) /* = delete */;
};
inline void sc_process_b::semantics()
{
// within this function, the process has a stack associated
scoped_flag scoped_stack_flag( m_has_stack );
sc_assert( m_process_kind != SC_NO_PROC_ );
// Determine the reset status of this object instance and potentially
// trigger its notify event:
// See if we need to trigger the notify event:
if ( m_reset_event_p &&
( (m_throw_status == THROW_SYNC_RESET) ||
(m_throw_status == THROW_ASYNC_RESET) )
) {
trigger_reset_event();
}
// Set the new reset status of this object based on the reset counts:
m_throw_status = m_active_areset_n ? THROW_ASYNC_RESET :
( m_active_reset_n ? THROW_SYNC_RESET : THROW_NONE);
// Dispatch the actual semantics for the process:
# ifndef SC_USE_MEMBER_FUNC_PTR
m_semantics_method_p->invoke( m_semantics_host_p );
# else
(m_semantics_host_p->*m_semantics_method_p)();
# endif
}
//------------------------------------------------------------------------------
//"sc_process_b::terminated"
//
// This inline method returns true if this object has terminated.
//------------------------------------------------------------------------------
inline bool sc_process_b::terminated() const
{
return (m_state & ps_bit_zombie) != 0;
}
//------------------------------------------------------------------------------
//"sc_process_b::timed_out"
//
// This inline method returns true if this object instance timed out.
//------------------------------------------------------------------------------
inline bool sc_process_b::timed_out() const
{
return m_timed_out;
}
} // namespace sc_core
#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
#pragma warning(pop)
#endif
/*****************************************************************************
MODIFICATION LOG - modifiers, enter your name, affiliation, date and
changes you are making here.
Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 12 Aug 05
Description of Modification: This is the rewrite of process support. It
contains some code from the original
sc_process.h by Stan Liao, and the now-defunct
sc_process_b.h by Stan Liao and Martin
Janssen, all of Synopsys, Inc., It also contains
code from the original sc_process_b.h by
Andy Goodrich of Forte Design Systems and
Bishnupriya Bhattacharya of Cadence Design
Systems.
Name, Affiliation, Date:
Description of Modification:
*****************************************************************************/
// $Log: sc_process.h,v $
// Revision 1.36 2011/08/26 22:44:30 acg
// Torsten Maehne: eliminate unused argument warning.
//
// Revision 1.35 2011/08/26 20:46:10 acg
// Andy Goodrich: moved the modification log to the end of the file to
// eliminate source line number skew when check-ins are done.
//
// Revision 1.34 2011/08/24 22:05:51 acg
// Torsten Maehne: initialization changes to remove warnings.
//
// Revision 1.33 2011/08/15 16:43:24 acg
// Torsten Maehne: changes to remove unused argument warnings.
//
// Revision 1.32 2011/07/24 11:20:03 acg
// Philipp A. Hartmann: process control error message improvements:
// (1) Downgrade error to warning for re-kills of processes.
// (2) Add process name to process messages.
// (3) drop some superfluous colons in messages.
//
// Revision 1.31 2011/04/13 02:44:26 acg
// Andy Goodrich: added m_unwinding flag in place of THROW_NOW because the
// throw status will be set back to THROW_*_RESET if reset is active and
// the check for an unwind being complete was expecting THROW_NONE as the
// clearing of THROW_NOW.
//
// Revision 1.30 2011/04/11 22:07:27 acg
// Andy Goodrich: check for reset event notification before resetting the
// throw_status value.
//
// Revision 1.29 2011/04/10 22:17:36 acg
// Andy Goodrich: added trigger_reset_event() to allow sc_process.h to
// contain the run_process() inline method. sc_process.h cannot have
// sc_simcontext information because of recursive includes.
//
// Revision 1.28 2011/04/08 22:34:06 acg
// Andy Goodrich: moved the semantics() method to this file and made it
// an inline method. Added reset processing to the semantics() method.
//
// Revision 1.27 2011/04/08 18:24:48 acg
// Andy Goodrich: moved reset_changed() to .cpp since it needs visibility
// to sc_simcontext.
//
// Revision 1.26 2011/04/01 21:24:57 acg
// Andy Goodrich: removed unused code.
//
// Revision 1.25 2011/03/28 13:02:51 acg
// Andy Goodrich: Changes for disable() interactions.
//
// Revision 1.24 2011/03/20 13:43:23 acg
// Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
//
// Revision 1.23 2011/03/12 21:07:51 acg
// Andy Goodrich: changes to kernel generated event support.
//
// Revision 1.22 2011/03/08 20:49:31 acg
// Andy Goodrich: implement coarse checking for synchronous reset - suspend
// interaction.
//
// Revision 1.21 2011/03/07 17:38:43 acg
// Andy Goodrich: tightening up of checks for undefined interaction between
// synchronous reset and suspend.
//
// Revision 1.20 2011/03/06 19:57:11 acg
// Andy Goodrich: refinements for the illegal suspend - synchronous reset
// interaction.
//
// Revision 1.19 2011/03/05 19:44:20 acg
// Andy Goodrich: changes for object and event naming and structures.
//
// Revision 1.18 2011/02/19 08:30:53 acg
// Andy Goodrich: Moved process queueing into trigger_static from
// sc_event::notify.
//
// Revision 1.17 2011/02/18 20:27:14 acg
// Andy Goodrich: Updated Copyrights.
//
// Revision 1.16 2011/02/18 20:10:44 acg
// Philipp A. Hartmann: force return expression to be a bool to keep MSVC
// happy.
//
// Revision 1.15 2011/02/17 19:52:45 acg
// Andy Goodrich:
// (1) Simplified process control usage.
// (2) Changed dump_status() to dump_state() with new signature.
//
// Revision 1.14 2011/02/16 22:37:30 acg
// Andy Goodrich: clean up to remove need for ps_disable_pending.
//
// Revision 1.13 2011/02/13 21:47:37 acg
// Andy Goodrich: update copyright notice.
//
// Revision 1.12 2011/02/13 21:41:34 acg
// Andy Goodrich: get the log messages for the previous check in correct.
//
// Revision 1.11 2011/02/13 21:32:24 acg
// Andy Goodrich: moved sc_process_b::reset_process() implementation
// from header to cpp file . Added dump_status() to print out the status of a
// process.
//
// Revision 1.10 2011/02/11 13:25:24 acg
// Andy Goodrich: Philipp A. Hartmann's changes:
// (1) Removal of SC_CTHREAD method overloads.
// (2) New exception processing code.
//
// Revision 1.9 2011/02/04 15:27:36 acg
// Andy Goodrich: changes for suspend-resume semantics.
//
// Revision 1.8 2011/02/01 21:06:12 acg
// Andy Goodrich: new layout for the process_state enum.
//
// Revision 1.7 2011/01/25 20:50:37 acg
// Andy Goodrich: changes for IEEE 1666 2011.
//
// Revision 1.6 2011/01/19 23:21:50 acg
// Andy Goodrich: changes for IEEE 1666 2011
//
// Revision 1.5 2011/01/18 20:10:45 acg
// Andy Goodrich: changes for IEEE1666_2011 semantics.
//
// Revision 1.4 2010/07/22 20:02:33 acg
// Andy Goodrich: bug fixes.
//
// Revision 1.3 2009/05/22 16:06:29 acg
// Andy Goodrich: process control updates.
//
// Revision 1.2 2008/05/22 17:06:26 acg
// Andy Goodrich: updated copyright notice to include 2008.
//
// Revision 1.1.1.1 2006/12/15 20:20:05 acg
// SystemC 2.3
//
// Revision 1.11 2006/05/08 17:58:10 acg
// Andy Goodrich: added David Long's forward declarations for friend
// functions, methods, and operators to keep the Microsoft compiler happy.
//
// Revision 1.10 2006/04/28 23:29:01 acg
// Andy Goodrich: added an sc_core:: prefix to SC_FUNC_PTR in the
// SC_MAKE_FUNC_PTR macro to allow its transpareuse outside of the sc_core
// namespace.
//
// Revision 1.9 2006/04/28 21:52:57 acg
// Andy Goodrich: changed SC_MAKE_FUNC_PTR to use a static cast to address
// and AIX issue wrt sc_module's inherited classes.
//
// Revision 1.8 2006/04/20 17:08:17 acg
// Andy Goodrich: 3.0 style process changes.
//
// Revision 1.7 2006/04/11 23:13:21 acg
// Andy Goodrich: Changes for reduced reset support that only includes
// sc_cthread, but has preliminary hooks for expanding to method and thread
// processes also.
//
// Revision 1.6 2006/03/13 20:26:50 acg
// Andy Goodrich: Addition of forward class declarations, e.g.,
// sc_reset, to keep gcc 4.x happy.
//
// Revision 1.5 2006/01/31 20:09:10 acg
// Andy Goodrich: added explaination of static vs dynamic waits to
// sc_process_b::trigger_static.
//
// Revision 1.4 2006/01/24 20:49:05 acg
// Andy Goodrich: changes to remove the use of deprecated features within the
// simulator, and to issue warning messages when deprecated features are used.
//
// Revision 1.3 2006/01/13 18:44:30 acg
// Added $Log to record CVS changes into the source.
#endif // !defined(sc_process_h_INCLUDED)
| [
"mikhail.moiseev@intel.com"
] | mikhail.moiseev@intel.com |
b067cdd6edc6ca3f39f139f0943a5132c1a821b0 | 880aed51aacd07481b9952d5fc54e2da970e9f6d | /FTP/CurlHandle.h | a8b94209d428332e26fa7a053698e0242dd3ff50 | [
"MIT"
] | permissive | Finkman/ftpclient-cpp | c7789f2f6ab3c8f04632efde7c53eec0ad3b850c | d8d866cdef12b07df5e43f35e84908a595ad226e | refs/heads/master | 2022-04-24T21:05:37.230389 | 2020-03-30T19:06:07 | 2020-03-30T19:06:07 | 250,280,549 | 0 | 0 | MIT | 2020-03-26T14:26:30 | 2020-03-26T14:26:29 | null | UTF-8 | C++ | false | false | 413 | h | #ifndef INCLUDE_CURLHANDLE_H_
#define INCLUDE_CURLHANDLE_H_
namespace embeddedmz {
class CurlHandle {
public:
static CurlHandle &instance();
CurlHandle(CurlHandle const &) = delete;
CurlHandle(CurlHandle &&) = delete;
CurlHandle &operator=(CurlHandle const &) = delete;
CurlHandle &operator=(CurlHandle &&) = delete;
~CurlHandle();
private:
CurlHandle();
};
} // namespace embeddedmz
#endif
| [
"sven.fink@wipotec.com"
] | sven.fink@wipotec.com |
64525706b577ab602e2001f5f503fac51d6a834c | ae80810f77d90d30a622b47806cadae1c3331d69 | /22 - Bits, Characters, C Strings and structs/22.41 - Text Analysis/ex_22_41.cpp | 4852651f0dd3ec4a3c0a12160554374bfc78125e | [] | no_license | iRobot42/Deitels-Cpp-10e | 408357b97af2cc69b010ed3fd82b8277afa84bb8 | e41ddc55055f69fb519e6df80050d48b2747518e | refs/heads/master | 2023-05-25T19:34:17.901350 | 2023-05-23T22:09:53 | 2023-05-23T22:09:53 | 165,110,152 | 27 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 2,351 | cpp | // Exercise 22.41: ex_22_41.cpp
// Text Analysis
#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std;
void part_a( const char* );
void part_b( const char* );
void part_c( const char* );
int main() {
const char str[]{ "To be, or not to be: that is the question:\n"
"Whether 'tis nobler in the mind to suffer" };
cout << str << endl;
part_a( str );
part_b( str );
part_c( str );
//cout << endl << str << endl;
return EXIT_SUCCESS;
}
void part_a( const char* s ) {
const int LETTERS{ 26 };
int frequency[ LETTERS ]{};
for ( s; *s; ++s )
frequency[ tolower( *s ) - 'a' ]++;
cout << "\nFrequency of letters\n" << string( 20, '-' ) << endl;
for ( int i{}; i < LETTERS; ++i )
if ( frequency[ i ] )
cout << char( 'a' + i ) << ": " << frequency[ i ] << endl;
}
void part_b( const char* s ) {
const int WORD{ 20 }, TEXT{ 100 };
const char delim[]{ " ,.:;!?\"\n\t" };
char copy[ TEXT ];
memcpy( copy, s, TEXT );
int occurences[ WORD ]{};
char* token{ strtok( copy, delim ) };
while ( token ) {
occurences[ strlen( token ) ]++;
token = strtok( NULL, delim );
}
cout << "\nWord length\tOccurences\n" << string( 26, '-' ) << endl;
for ( int i{}; i < WORD; ++i )
if ( occurences[ i ] )
cout << i << "\t\t" << occurences[ i ] << endl;
}
void part_c( const char* s ) {
const int WORD{ 20 }, TEXT{ 100 }, WORDS{ 50 };
const char delim[]{ " ,.:;!?\"\n\t" };
char copy[ TEXT ];
memcpy( copy, s, TEXT );
char words[ WORDS ][ WORD ]{};
int occurences[ WORDS ]{}, w{};
char* token{ strtok( copy, delim ) };
while ( token ) {
*token = tolower( *token );
bool found{};
for ( int i{}; i < w; ++i )
if ( !memcmp( token, words[ i ], strlen( token ) ) ) {
found = true;
occurences[ i ]++;
break;
}
if ( !found ) {
memcpy( words[ w ], token, WORD );
occurences[ w++ ]++;
}
token = strtok( NULL, delim );
}
cout << endl << left << setw( WORD ) << "Word" << " Occurences\n"
<< string( WORD + 11, '-' ) << endl;
for ( int i{}; i < w; ++i )
cout << setw( WORD ) << words[ i ] << ' ' << occurences[ i ] << endl;
}
| [
"noreply@github.com"
] | noreply@github.com |
63e96ed76e2a366496b8641cbcf7b513cf00261a | 0df514e10c31665566998af6020b1f25ca669a8e | /android/build/generated/BootstrapJS.cpp | d704450bc29b1cd0d5826695953c6d0dce6a1586 | [] | no_license | AppWerft/Ti.AndroidPay | 3883bb78600bf1085c298d5db00451be6483e8b0 | 30e949638406ea9272f214aba734ab7664775382 | refs/heads/master | 2021-01-20T06:30:27.435871 | 2017-08-28T18:39:01 | 2017-08-28T18:39:01 | 101,502,116 | 7 | 3 | null | 2017-08-28T18:39:02 | 2017-08-26T17:35:27 | Java | UTF-8 | C++ | false | false | 11,364 | cpp | #ifndef KROLL_NATIVES_H
#define KROLL_NATIVES_H
#include <stdint.h>
namespace titanium {
const char bootstrap_native[] = { 47, 42, 42, 10, 32, 42, 32, 65, 112, 112, 99, 101, 108, 101, 114, 97, 116, 111, 114, 32, 84, 105, 116, 97, 110, 105, 117, 109, 32, 77, 111, 98, 105, 108, 101, 10, 32, 42, 32, 67, 111, 112, 121, 114, 105, 103, 104, 116, 32, 40, 99, 41, 32, 50, 48, 49, 49, 32, 98, 121, 32, 65, 112, 112, 99, 101, 108, 101, 114, 97, 116, 111, 114, 44, 32, 73, 110, 99, 46, 32, 65, 108, 108, 32, 82, 105, 103, 104, 116, 115, 32, 82, 101, 115, 101, 114, 118, 101, 100, 46, 10, 32, 42, 32, 76, 105, 99, 101, 110, 115, 101, 100, 32, 117, 110, 100, 101, 114, 32, 116, 104, 101, 32, 116, 101, 114, 109, 115, 32, 111, 102, 32, 116, 104, 101, 32, 65, 112, 97, 99, 104, 101, 32, 80, 117, 98, 108, 105, 99, 32, 76, 105, 99, 101, 110, 115, 101, 10, 32, 42, 32, 80, 108, 101, 97, 115, 101, 32, 115, 101, 101, 32, 116, 104, 101, 32, 76, 73, 67, 69, 78, 83, 69, 32, 105, 110, 99, 108, 117, 100, 101, 100, 32, 119, 105, 116, 104, 32, 116, 104, 105, 115, 32, 100, 105, 115, 116, 114, 105, 98, 117, 116, 105, 111, 110, 32, 102, 111, 114, 32, 100, 101, 116, 97, 105, 108, 115, 46, 10, 32, 42, 10, 32, 42, 32, 87, 97, 114, 110, 105, 110, 103, 58, 32, 84, 104, 105, 115, 32, 102, 105, 108, 101, 32, 105, 115, 32, 71, 69, 78, 69, 82, 65, 84, 69, 68, 44, 32, 97, 110, 100, 32, 115, 104, 111, 117, 108, 100, 32, 110, 111, 116, 32, 98, 101, 32, 109, 111, 100, 105, 102, 105, 101, 100, 10, 32, 42, 47, 10, 118, 97, 114, 32, 98, 111, 111, 116, 115, 116, 114, 97, 112, 32, 61, 32, 107, 114, 111, 108, 108, 46, 78, 97, 116, 105, 118, 101, 77, 111, 100, 117, 108, 101, 46, 114, 101, 113, 117, 105, 114, 101, 40, 34, 98, 111, 111, 116, 115, 116, 114, 97, 112, 34, 41, 44, 10, 9, 105, 110, 118, 111, 107, 101, 114, 32, 61, 32, 107, 114, 111, 108, 108, 46, 78, 97, 116, 105, 118, 101, 77, 111, 100, 117, 108, 101, 46, 114, 101, 113, 117, 105, 114, 101, 40, 34, 105, 110, 118, 111, 107, 101, 114, 34, 41, 44, 10, 9, 84, 105, 116, 97, 110, 105, 117, 109, 32, 61, 32, 107, 114, 111, 108, 108, 46, 98, 105, 110, 100, 105, 110, 103, 40, 34, 84, 105, 116, 97, 110, 105, 117, 109, 34, 41, 46, 84, 105, 116, 97, 110, 105, 117, 109, 59, 10, 10, 102, 117, 110, 99, 116, 105, 111, 110, 32, 109, 111, 100, 117, 108, 101, 66, 111, 111, 116, 115, 116, 114, 97, 112, 40, 109, 111, 100, 117, 108, 101, 66, 105, 110, 100, 105, 110, 103, 41, 32, 123, 10, 9, 102, 117, 110, 99, 116, 105, 111, 110, 32, 108, 97, 122, 121, 71, 101, 116, 40, 111, 98, 106, 101, 99, 116, 44, 32, 98, 105, 110, 100, 105, 110, 103, 44, 32, 110, 97, 109, 101, 44, 32, 110, 97, 109, 101, 115, 112, 97, 99, 101, 41, 32, 123, 10, 9, 9, 114, 101, 116, 117, 114, 110, 32, 98, 111, 111, 116, 115, 116, 114, 97, 112, 46, 108, 97, 122, 121, 71, 101, 116, 40, 111, 98, 106, 101, 99, 116, 44, 32, 98, 105, 110, 100, 105, 110, 103, 44, 10, 9, 9, 9, 110, 97, 109, 101, 44, 32, 110, 97, 109, 101, 115, 112, 97, 99, 101, 44, 32, 109, 111, 100, 117, 108, 101, 66, 105, 110, 100, 105, 110, 103, 46, 103, 101, 116, 66, 105, 110, 100, 105, 110, 103, 41, 59, 10, 9, 125, 10, 10, 9, 118, 97, 114, 32, 109, 111, 100, 117, 108, 101, 32, 61, 32, 109, 111, 100, 117, 108, 101, 66, 105, 110, 100, 105, 110, 103, 46, 103, 101, 116, 66, 105, 110, 100, 105, 110, 103, 40, 34, 116, 105, 46, 97, 110, 100, 114, 111, 105, 100, 112, 97, 121, 46, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 77, 111, 100, 117, 108, 101, 34, 41, 91, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 93, 59, 10, 9, 118, 97, 114, 32, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 115, 32, 61, 32, 109, 111, 100, 117, 108, 101, 46, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 115, 32, 61, 32, 91, 93, 59, 10, 9, 109, 111, 100, 117, 108, 101, 46, 97, 112, 105, 78, 97, 109, 101, 32, 61, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 59, 10, 10, 9, 102, 117, 110, 99, 116, 105, 111, 110, 32, 97, 100, 100, 73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 40, 109, 111, 100, 117, 108, 101, 44, 32, 109, 111, 100, 117, 108, 101, 78, 97, 109, 101, 115, 112, 97, 99, 101, 44, 32, 110, 97, 109, 101, 115, 112, 97, 99, 101, 44, 32, 97, 112, 105, 41, 32, 123, 10, 9, 9, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 115, 46, 112, 117, 115, 104, 40, 123, 32, 110, 97, 109, 101, 115, 112, 97, 99, 101, 58, 32, 110, 97, 109, 101, 115, 112, 97, 99, 101, 44, 32, 97, 112, 105, 58, 32, 97, 112, 105, 32, 125, 41, 59, 10, 9, 125, 10, 10, 9, 97, 100, 100, 73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 40, 109, 111, 100, 117, 108, 101, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 99, 114, 101, 97, 116, 101, 67, 97, 114, 116, 34, 41, 59, 97, 100, 100, 73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 40, 109, 111, 100, 117, 108, 101, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 99, 114, 101, 97, 116, 101, 76, 105, 110, 101, 73, 116, 101, 109, 34, 41, 59, 97, 100, 100, 73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 65, 80, 73, 40, 109, 111, 100, 117, 108, 101, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 65, 110, 100, 114, 111, 105, 100, 112, 97, 121, 109, 101, 110, 116, 34, 44, 32, 34, 99, 114, 101, 97, 116, 101, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 34, 41, 59, 10, 9, 9, 105, 102, 32, 40, 33, 40, 34, 95, 95, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 68, 101, 102, 105, 110, 101, 100, 95, 95, 34, 32, 105, 110, 32, 109, 111, 100, 117, 108, 101, 41, 41, 32, 123, 79, 98, 106, 101, 99, 116, 46, 100, 101, 102, 105, 110, 101, 80, 114, 111, 112, 101, 114, 116, 105, 101, 115, 40, 109, 111, 100, 117, 108, 101, 44, 32, 123, 10, 34, 67, 97, 114, 116, 34, 58, 32, 123, 10, 103, 101, 116, 58, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 118, 97, 114, 32, 67, 97, 114, 116, 32, 61, 32, 32, 108, 97, 122, 121, 71, 101, 116, 40, 116, 104, 105, 115, 44, 32, 34, 116, 105, 46, 97, 110, 100, 114, 111, 105, 100, 112, 97, 121, 46, 67, 97, 114, 116, 80, 114, 111, 120, 121, 34, 44, 32, 34, 67, 97, 114, 116, 34, 44, 32, 34, 67, 97, 114, 116, 34, 41, 59, 10, 114, 101, 116, 117, 114, 110, 32, 67, 97, 114, 116, 59, 10, 125, 44, 10, 99, 111, 110, 102, 105, 103, 117, 114, 97, 98, 108, 101, 58, 32, 116, 114, 117, 101, 10, 125, 44, 10, 34, 76, 105, 110, 101, 73, 116, 101, 109, 34, 58, 32, 123, 10, 103, 101, 116, 58, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 118, 97, 114, 32, 76, 105, 110, 101, 73, 116, 101, 109, 32, 61, 32, 32, 108, 97, 122, 121, 71, 101, 116, 40, 116, 104, 105, 115, 44, 32, 34, 116, 105, 46, 97, 110, 100, 114, 111, 105, 100, 112, 97, 121, 46, 76, 105, 110, 101, 73, 116, 101, 109, 80, 114, 111, 120, 121, 34, 44, 32, 34, 76, 105, 110, 101, 73, 116, 101, 109, 34, 44, 32, 34, 76, 105, 110, 101, 73, 116, 101, 109, 34, 41, 59, 10, 114, 101, 116, 117, 114, 110, 32, 76, 105, 110, 101, 73, 116, 101, 109, 59, 10, 125, 44, 10, 99, 111, 110, 102, 105, 103, 117, 114, 97, 98, 108, 101, 58, 32, 116, 114, 117, 101, 10, 125, 44, 10, 34, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 34, 58, 32, 123, 10, 103, 101, 116, 58, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 118, 97, 114, 32, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32, 61, 32, 32, 108, 97, 122, 121, 71, 101, 116, 40, 116, 104, 105, 115, 44, 32, 34, 116, 105, 46, 97, 110, 100, 114, 111, 105, 100, 112, 97, 121, 46, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 80, 114, 111, 120, 121, 34, 44, 32, 34, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 34, 44, 32, 34, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 34, 41, 59, 10, 114, 101, 116, 117, 114, 110, 32, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 59, 10, 125, 44, 10, 99, 111, 110, 102, 105, 103, 117, 114, 97, 98, 108, 101, 58, 32, 116, 114, 117, 101, 10, 125, 44, 10, 10, 125, 41, 59, 10, 109, 111, 100, 117, 108, 101, 46, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 46, 112, 114, 111, 116, 111, 116, 121, 112, 101, 46, 99, 114, 101, 97, 116, 101, 67, 97, 114, 116, 32, 61, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 114, 101, 116, 117, 114, 110, 32, 110, 101, 119, 32, 109, 111, 100, 117, 108, 101, 91, 34, 67, 97, 114, 116, 34, 93, 40, 97, 114, 103, 117, 109, 101, 110, 116, 115, 41, 59, 10, 125, 10, 109, 111, 100, 117, 108, 101, 46, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 46, 112, 114, 111, 116, 111, 116, 121, 112, 101, 46, 99, 114, 101, 97, 116, 101, 76, 105, 110, 101, 73, 116, 101, 109, 32, 61, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 114, 101, 116, 117, 114, 110, 32, 110, 101, 119, 32, 109, 111, 100, 117, 108, 101, 91, 34, 76, 105, 110, 101, 73, 116, 101, 109, 34, 93, 40, 97, 114, 103, 117, 109, 101, 110, 116, 115, 41, 59, 10, 125, 10, 109, 111, 100, 117, 108, 101, 46, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 46, 112, 114, 111, 116, 111, 116, 121, 112, 101, 46, 99, 114, 101, 97, 116, 101, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32, 61, 32, 102, 117, 110, 99, 116, 105, 111, 110, 40, 41, 32, 123, 10, 114, 101, 116, 117, 114, 110, 32, 110, 101, 119, 32, 109, 111, 100, 117, 108, 101, 91, 34, 80, 97, 121, 109, 101, 110, 116, 77, 101, 116, 104, 111, 100, 84, 111, 107, 101, 110, 105, 122, 97, 116, 105, 111, 110, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 34, 93, 40, 97, 114, 103, 117, 109, 101, 110, 116, 115, 41, 59, 10, 125, 10, 125, 10, 109, 111, 100, 117, 108, 101, 46, 95, 95, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 68, 101, 102, 105, 110, 101, 100, 95, 95, 32, 61, 32, 116, 114, 117, 101, 59, 10, 114, 101, 116, 117, 114, 110, 32, 109, 111, 100, 117, 108, 101, 59, 10, 10, 125, 10, 101, 120, 112, 111, 114, 116, 115, 46, 98, 111, 111, 116, 115, 116, 114, 97, 112, 32, 61, 32, 109, 111, 100, 117, 108, 101, 66, 111, 111, 116, 115, 116, 114, 97, 112, 59, 10, 0 };
struct _native {
const char* name;
const char* source;
size_t source_length;
};
static const struct _native natives[] = {
{ "bootstrap", bootstrap_native, sizeof(bootstrap_native) - 1 },
{ NULL, NULL, 0 } /* sentinel */
};
}
#endif
| [
"“rs@hamburger-appwerft.de“"
] | “rs@hamburger-appwerft.de“ |
7dbfe1cb3bb59053e7540850fdb3c5ef6b00c0ed | c89dde9a4c7558786308aa0c0ee0c56e69667be9 | /sumas.cpp | cc63ecabab55de8f07dc2852a05cf9bf7848b5aa | [] | no_license | WuilsonEstacio/2020i-programs-herrc | 13528c37319d39d1e091862556a4b100006f8876 | a72c5211e6469d6b78464699e6576b5642007cfa | refs/heads/master | 2023-05-26T10:34:26.745224 | 2021-06-09T21:30:49 | 2021-06-09T21:30:49 | 293,173,985 | 0 | 1 | null | 2020-11-14T03:57:02 | 2020-09-06T00:09:22 | C++ | UTF-8 | C++ | false | false | 528 | cpp | # include <iostream>
# include <cmath>
typedef float REAL;
REAL sumup(int Nmax); //
REAL sumdown(int Nmax);
int main(void){
for(int nmax =1; nmax <= 100; ++ nmax){
std::cout <<nmax<< "\t"
<<std::fabs(1-sumdown(nmax)/sumup(nmax))
<<std::endl;
}
return 0;
}
REAL sumup(int Nmax){
REAL suma = 0.0;
for(int ii = 1; ii<=Nmax; ++ii){
suma += 1.0/ii;
}
return suma;
}
REAL sumdown(int Nmax){
REAL suma = 0.0;
for(int ii= Nmax; ii>=1; --ii){
suma +=1.0/ii;
}
return suma;
}
| [
"noreply@github.com"
] | noreply@github.com |
a8d59884104f41563a65de85b9b4d5131ae7d643 | c123780aaf212429d371d876af17ac520986e595 | /rlutil.h | 59814f3f080153cf2e2e8efdfd3448738b3a66a0 | [] | no_license | zmorgado/TrabajoFinal-PROGII | 980b18be91166df8790e775319cc7af51426eed2 | 519fdcac801d01a2c334db0724cdb153ead89c91 | refs/heads/main | 2023-06-17T05:05:50.252352 | 2021-07-12T19:18:51 | 2021-07-12T19:18:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,465 | h | #pragma once
/**
* File: rlutil.h
*
* About: Description
* This file provides some useful utilities for console mode
* roguelike game development with C and C++. It is aimed to
* be cross-platform (at least Windows and Linux).
*
* About: Copyright
* (C) 2010 Tapio Vierros
*
* About: Licensing
* See <License>
*/
void * __gxx_personality_v0=0;
void * _Unwind_Resume =0;
/// Define: RLUTIL_USE_ANSI
/// Define this to use ANSI escape sequences also on Windows
/// (defaults to using WinAPI instead).
#if 0
#define RLUTIL_USE_ANSI
#endif
/// Define: RLUTIL_STRING_T
/// Define/typedef this to your preference to override rlutil's string type.
///
/// Defaults to std::string with C++ and char* with C.
#if 0
#define RLUTIL_STRING_T char*
#endif
#ifndef RLUTIL_INLINE
#ifdef _MSC_VER
#define RLUTIL_INLINE __inline
#else
#define RLUTIL_INLINE static __inline__
#endif
#endif
#ifdef __cplusplus
/// Common C++ headers
#include <iostream>
#include <string>
#include <cstdio> // for getch()
/// Namespace forward declarations
namespace rlutil {
RLUTIL_INLINE void locate(int x, int y);
}
#else
#include <stdio.h> // for getch() / printf()
#include <string.h> // for strlen()
RLUTIL_INLINE void locate(int x, int y); // Forward declare for C to avoid warnings
#endif // __cplusplus
#ifdef _WIN32
#include <windows.h> // for WinAPI and Sleep()
#define _NO_OLDNAMES // for MinGW compatibility
#include <conio.h> // for getch() and kbhit()
#define getch _getch
#define kbhit _kbhit
#else
#include <termios.h> // for getch() and kbhit()
#include <unistd.h> // for getch(), kbhit() and (u)sleep()
#include <sys/ioctl.h> // for getkey()
#include <sys/types.h> // for kbhit()
#include <sys/time.h> // for kbhit()
/// Function: getch
/// Get character without waiting for Return to be pressed.
/// Windows has this in conio.h
RLUTIL_INLINE int getch(void) {
// Here be magic.
struct termios oldt, newt;
int ch;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
/// Function: kbhit
/// Determines if keyboard has been hit.
/// Windows has this in conio.h
RLUTIL_INLINE int kbhit(void) {
// Here be dragons.
static struct termios oldt, newt;
int cnt = 0;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
newt.c_iflag = 0; // input mode
newt.c_oflag = 0; // output mode
newt.c_cc[VMIN] = 1; // minimum time to wait
newt.c_cc[VTIME] = 1; // minimum characters to wait for
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ioctl(0, FIONREAD, &cnt); // Read count
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 100;
select(STDIN_FILENO+1, NULL, NULL, NULL, &tv); // A small time delay
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return cnt; // Return number of characters
}
#endif // _WIN32
#ifndef gotoxy
/// Function: gotoxy
/// Same as <rlutil.locate>.
RLUTIL_INLINE void gotoxy(int x, int y) {
#ifdef __cplusplus
rlutil::
#endif
locate(x,y);
}
#endif // gotoxy
#ifdef __cplusplus
/// Namespace: rlutil
/// In C++ all functions except <getch>, <kbhit> and <gotoxy> are arranged
/// under namespace rlutil. That is because some platforms have them defined
/// outside of rlutil.
namespace rlutil {
#endif
/**
* Defs: Internal typedefs and macros
* RLUTIL_STRING_T - String type depending on which one of C or C++ is used
* RLUTIL_PRINT(str) - Printing macro independent of C/C++
*/
#ifdef __cplusplus
#ifndef RLUTIL_STRING_T
typedef std::string RLUTIL_STRING_T;
#endif // RLUTIL_STRING_T
#define RLUTIL_PRINT(st) do { std::cout << st; } while(false)
#else // __cplusplus
#ifndef RLUTIL_STRING_T
typedef const char* RLUTIL_STRING_T;
#endif // RLUTIL_STRING_T
#define RLUTIL_PRINT(st) printf("%s", st)
#endif // __cplusplus
/**
* Enums: Color codes
*
* BLACK - Black
* BLUE - Blue
* GREEN - Green
* CYAN - Cyan
* RED - Red
* MAGENTA - Magenta / purple
* BROWN - Brown / dark yellow
* GREY - Grey / dark white
* DARKGREY - Dark grey / light black
* LIGHTBLUE - Light blue
* LIGHTGREEN - Light green
* LIGHTCYAN - Light cyan
* LIGHTRED - Light red
* LIGHTMAGENTA - Light magenta / light purple
* YELLOW - Yellow (bright)
* WHITE - White (bright)
*/
enum {
BLACK,
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
GREY,
DARKGREY,
LIGHTBLUE,
LIGHTGREEN,
LIGHTCYAN,
LIGHTRED,
LIGHTMAGENTA,
YELLOW,
WHITE
};
/**
* Consts: ANSI escape strings
*
* ANSI_CLS - Clears screen
* ANSI_CONSOLE_TITLE_PRE - Prefix for changing the window title, print the window title in between
* ANSI_CONSOLE_TITLE_POST - Suffix for changing the window title, print the window title in between
* ANSI_ATTRIBUTE_RESET - Resets all attributes
* ANSI_CURSOR_HIDE - Hides the cursor
* ANSI_CURSOR_SHOW - Shows the cursor
* ANSI_CURSOR_HOME - Moves the cursor home (0,0)
* ANSI_BLACK - Black
* ANSI_RED - Red
* ANSI_GREEN - Green
* ANSI_BROWN - Brown / dark yellow
* ANSI_BLUE - Blue
* ANSI_MAGENTA - Magenta / purple
* ANSI_CYAN - Cyan
* ANSI_GREY - Grey / dark white
* ANSI_DARKGREY - Dark grey / light black
* ANSI_LIGHTRED - Light red
* ANSI_LIGHTGREEN - Light green
* ANSI_YELLOW - Yellow (bright)
* ANSI_LIGHTBLUE - Light blue
* ANSI_LIGHTMAGENTA - Light magenta / light purple
* ANSI_LIGHTCYAN - Light cyan
* ANSI_WHITE - White (bright)
* ANSI_BACKGROUND_BLACK - Black background
* ANSI_BACKGROUND_RED - Red background
* ANSI_BACKGROUND_GREEN - Green background
* ANSI_BACKGROUND_YELLOW - Yellow background
* ANSI_BACKGROUND_BLUE - Blue background
* ANSI_BACKGROUND_MAGENTA - Magenta / purple background
* ANSI_BACKGROUND_CYAN - Cyan background
* ANSI_BACKGROUND_WHITE - White background
*/
const RLUTIL_STRING_T ANSI_CLS = "\033[2J\033[3J";
const RLUTIL_STRING_T ANSI_CONSOLE_TITLE_PRE = "\033]0;";
const RLUTIL_STRING_T ANSI_CONSOLE_TITLE_POST = "\007";
const RLUTIL_STRING_T ANSI_ATTRIBUTE_RESET = "\033[0m";
const RLUTIL_STRING_T ANSI_CURSOR_HIDE = "\033[?25l";
const RLUTIL_STRING_T ANSI_CURSOR_SHOW = "\033[?25h";
const RLUTIL_STRING_T ANSI_CURSOR_HOME = "\033[H";
const RLUTIL_STRING_T ANSI_BLACK = "\033[22;30m";
const RLUTIL_STRING_T ANSI_RED = "\033[22;31m";
const RLUTIL_STRING_T ANSI_GREEN = "\033[22;32m";
const RLUTIL_STRING_T ANSI_BROWN = "\033[22;33m";
const RLUTIL_STRING_T ANSI_BLUE = "\033[22;34m";
const RLUTIL_STRING_T ANSI_MAGENTA = "\033[22;35m";
const RLUTIL_STRING_T ANSI_CYAN = "\033[22;36m";
const RLUTIL_STRING_T ANSI_GREY = "\033[22;37m";
const RLUTIL_STRING_T ANSI_DARKGREY = "\033[01;30m";
const RLUTIL_STRING_T ANSI_LIGHTRED = "\033[01;31m";
const RLUTIL_STRING_T ANSI_LIGHTGREEN = "\033[01;32m";
const RLUTIL_STRING_T ANSI_YELLOW = "\033[01;33m";
const RLUTIL_STRING_T ANSI_LIGHTBLUE = "\033[01;34m";
const RLUTIL_STRING_T ANSI_LIGHTMAGENTA = "\033[01;35m";
const RLUTIL_STRING_T ANSI_LIGHTCYAN = "\033[01;36m";
const RLUTIL_STRING_T ANSI_WHITE = "\033[01;37m";
const RLUTIL_STRING_T ANSI_BACKGROUND_BLACK = "\033[40m";
const RLUTIL_STRING_T ANSI_BACKGROUND_RED = "\033[41m";
const RLUTIL_STRING_T ANSI_BACKGROUND_GREEN = "\033[42m";
const RLUTIL_STRING_T ANSI_BACKGROUND_YELLOW = "\033[43m";
const RLUTIL_STRING_T ANSI_BACKGROUND_BLUE = "\033[44m";
const RLUTIL_STRING_T ANSI_BACKGROUND_MAGENTA = "\033[45m";
const RLUTIL_STRING_T ANSI_BACKGROUND_CYAN = "\033[46m";
const RLUTIL_STRING_T ANSI_BACKGROUND_WHITE = "\033[47m";
// Remaining colors not supported as background colors
/**
* Enums: Key codes for keyhit()
*
* KEY_ESCAPE - Escape
* KEY_ENTER - Enter
* KEY_SPACE - Space
* KEY_INSERT - Insert
* KEY_HOME - Home
* KEY_END - End
* KEY_DELETE - Delete
* KEY_PGUP - PageUp
* KEY_PGDOWN - PageDown
* KEY_UP - Up arrow
* KEY_DOWN - Down arrow
* KEY_LEFT - Left arrow
* KEY_RIGHT - Right arrow
* KEY_F1 - F1
* KEY_F2 - F2
* KEY_F3 - F3
* KEY_F4 - F4
* KEY_F5 - F5
* KEY_F6 - F6
* KEY_F7 - F7
* KEY_F8 - F8
* KEY_F9 - F9
* KEY_F10 - F10
* KEY_F11 - F11
* KEY_F12 - F12
* KEY_NUMDEL - Numpad del
* KEY_NUMPAD0 - Numpad 0
* KEY_NUMPAD1 - Numpad 1
* KEY_NUMPAD2 - Numpad 2
* KEY_NUMPAD3 - Numpad 3
* KEY_NUMPAD4 - Numpad 4
* KEY_NUMPAD5 - Numpad 5
* KEY_NUMPAD6 - Numpad 6
* KEY_NUMPAD7 - Numpad 7
* KEY_NUMPAD8 - Numpad 8
* KEY_NUMPAD9 - Numpad 9
*/
enum {
KEY_ESCAPE = 0,
KEY_ENTER = 1,
KEY_SPACE = 32,
KEY_INSERT = 2,
KEY_HOME = 3,
KEY_PGUP = 4,
KEY_DELETE = 5,
KEY_END = 6,
KEY_PGDOWN = 7,
KEY_UP = 14,
KEY_DOWN = 15,
KEY_LEFT = 16,
KEY_RIGHT = 17,
KEY_F1 = 18,
KEY_F2 = 19,
KEY_F3 = 20,
KEY_F4 = 21,
KEY_F5 = 22,
KEY_F6 = 23,
KEY_F7 = 24,
KEY_F8 = 25,
KEY_F9 = 26,
KEY_F10 = 27,
KEY_F11 = 28,
KEY_F12 = 29,
KEY_NUMDEL = 30,
KEY_NUMPAD0 = 31,
KEY_NUMPAD1 = 127,
KEY_NUMPAD2 = 128,
KEY_NUMPAD3 = 129,
KEY_NUMPAD4 = 130,
KEY_NUMPAD5 = 131,
KEY_NUMPAD6 = 132,
KEY_NUMPAD7 = 133,
KEY_NUMPAD8 = 134,
KEY_NUMPAD9 = 135
};
/// Function: getkey
/// Reads a key press (blocking) and returns a key code.
///
/// See <Key codes for keyhit()>
///
/// Note:
/// Only Arrows, Esc, Enter and Space are currently working properly.
RLUTIL_INLINE int getkey(void) {
#ifndef _WIN32
int cnt = kbhit(); // for ANSI escapes processing
#endif
int k = getch();
switch(k) {
case 0: {
int kk;
switch (kk = getch()) {
case 71: return KEY_NUMPAD7;
case 72: return KEY_NUMPAD8;
case 73: return KEY_NUMPAD9;
case 75: return KEY_NUMPAD4;
case 77: return KEY_NUMPAD6;
case 79: return KEY_NUMPAD1;
case 80: return KEY_NUMPAD2;
case 81: return KEY_NUMPAD3;
case 82: return KEY_NUMPAD0;
case 83: return KEY_NUMDEL;
default: return kk-59+KEY_F1; // Function keys
}}
case 224: {
int kk;
switch (kk = getch()) {
case 71: return KEY_HOME;
case 72: return KEY_UP;
case 73: return KEY_PGUP;
case 75: return KEY_LEFT;
case 77: return KEY_RIGHT;
case 79: return KEY_END;
case 80: return KEY_DOWN;
case 81: return KEY_PGDOWN;
case 82: return KEY_INSERT;
case 83: return KEY_DELETE;
default: return kk-123+KEY_F1; // Function keys
}}
case 13: return KEY_ENTER;
#ifdef _WIN32
case 27: return KEY_ESCAPE;
#else // _WIN32
case 155: // single-character CSI
case 27: {
// Process ANSI escape sequences
if (cnt >= 3 && getch() == '[') {
switch (k = getch()) {
case 'A': return KEY_UP;
case 'B': return KEY_DOWN;
case 'C': return KEY_RIGHT;
case 'D': return KEY_LEFT;
}
} else return KEY_ESCAPE;
}
#endif // _WIN32
default: return k;
}
}
/// Function: nb_getch
/// Non-blocking getch(). Returns 0 if no key was pressed.
RLUTIL_INLINE int nb_getch(void) {
if (kbhit()) return getch();
else return 0;
}
/// Function: getANSIColor
/// Return ANSI color escape sequence for specified number 0-15.
///
/// See <Color Codes>
RLUTIL_INLINE RLUTIL_STRING_T getANSIColor(const int c) {
switch (c) {
case BLACK : return ANSI_BLACK;
case BLUE : return ANSI_BLUE; // non-ANSI
case GREEN : return ANSI_GREEN;
case CYAN : return ANSI_CYAN; // non-ANSI
case RED : return ANSI_RED; // non-ANSI
case MAGENTA : return ANSI_MAGENTA;
case BROWN : return ANSI_BROWN;
case GREY : return ANSI_GREY;
case DARKGREY : return ANSI_DARKGREY;
case LIGHTBLUE : return ANSI_LIGHTBLUE; // non-ANSI
case LIGHTGREEN : return ANSI_LIGHTGREEN;
case LIGHTCYAN : return ANSI_LIGHTCYAN; // non-ANSI;
case LIGHTRED : return ANSI_LIGHTRED; // non-ANSI;
case LIGHTMAGENTA: return ANSI_LIGHTMAGENTA;
case YELLOW : return ANSI_YELLOW; // non-ANSI
case WHITE : return ANSI_WHITE;
default: return "";
}
}
/// Function: getANSIBackgroundColor
/// Return ANSI background color escape sequence for specified number 0-15.
///
/// See <Color Codes>
RLUTIL_INLINE RLUTIL_STRING_T getANSIBackgroundColor(const int c) {
switch (c) {
case BLACK : return ANSI_BACKGROUND_BLACK;
case BLUE : return ANSI_BACKGROUND_BLUE;
case GREEN : return ANSI_BACKGROUND_GREEN;
case CYAN : return ANSI_BACKGROUND_CYAN;
case RED : return ANSI_BACKGROUND_RED;
case MAGENTA: return ANSI_BACKGROUND_MAGENTA;
case BROWN : return ANSI_BACKGROUND_YELLOW;
case GREY : return ANSI_BACKGROUND_WHITE;
default: return "";
}
}
/// Function: setColor
/// Change color specified by number (Windows / QBasic colors).
/// Don't change the background color
///
/// See <Color Codes>
RLUTIL_INLINE void setColor(int c) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
SetConsoleTextAttribute(hConsole, (csbi.wAttributes & 0xFFF0) | (WORD)c); // Foreground colors take up the least significant byte
#else
RLUTIL_PRINT(getANSIColor(c));
#endif
}
/// Function: setBackgroundColor
/// Change background color specified by number (Windows / QBasic colors).
/// Don't change the foreground color
///
/// See <Color Codes>
RLUTIL_INLINE void setBackgroundColor(int c) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
SetConsoleTextAttribute(hConsole, (csbi.wAttributes & 0xFF0F) | (((WORD)c) << 4)); // Background colors take up the second-least significant byte
#else
RLUTIL_PRINT(getANSIBackgroundColor(c));
#endif
}
/// Function: saveDefaultColor
/// Call once to preserve colors for use in resetColor()
/// on Windows without ANSI, no-op otherwise
///
/// See <Color Codes>
/// See <resetColor>
RLUTIL_INLINE int saveDefaultColor(void) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
static char initialized = 0; // bool
static WORD attributes;
if (!initialized) {
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
attributes = csbi.wAttributes;
initialized = 1;
}
return (int)attributes;
#else
return -1;
#endif
}
/// Function: resetColor
/// Reset color to default
/// Requires a call to saveDefaultColor() to set the defaults
///
/// See <Color Codes>
/// See <setColor>
/// See <saveDefaultColor>
RLUTIL_INLINE void resetColor(void) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (WORD)saveDefaultColor());
#else
RLUTIL_PRINT(ANSI_ATTRIBUTE_RESET);
#endif
}
/// Function: cls
/// Clears screen, resets all attributes and moves cursor home.
RLUTIL_INLINE void cls(void) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
// Based on https://msdn.microsoft.com/en-us/library/windows/desktop/ms682022%28v=vs.85%29.aspx
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
const COORD coordScreen = {0, 0};
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
const DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
#else
RLUTIL_PRINT(ANSI_CLS);
RLUTIL_PRINT(ANSI_CURSOR_HOME);
#endif
}
/// Function: locate
/// Sets the cursor position to 1-based x,y.
RLUTIL_INLINE void locate(int x, int y) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
COORD coord;
// TODO: clamping/assert for x/y <= 0?
coord.X = (SHORT)(x - 1);
coord.Y = (SHORT)(y - 1); // Windows uses 0-based coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
#else // _WIN32 || USE_ANSI
#ifdef __cplusplus
RLUTIL_PRINT("\033[" << y << ";" << x << "H");
#else // __cplusplus
char buf[32];
sprintf(buf, "\033[%d;%df", y, x);
RLUTIL_PRINT(buf);
#endif // __cplusplus
#endif // _WIN32 || USE_ANSI
}
/// Function: setString
/// Prints the supplied string without advancing the cursor
#ifdef __cplusplus
RLUTIL_INLINE void setString(const RLUTIL_STRING_T & str_) {
const char * const str = str_.data();
unsigned int len = str_.size();
#else // __cplusplus
RLUTIL_INLINE void setString(RLUTIL_STRING_T str) {
unsigned int len = strlen(str);
#endif // __cplusplus
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD numberOfCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
WriteConsoleOutputCharacterA(hConsoleOutput, str, len, csbi.dwCursorPosition, &numberOfCharsWritten);
#else // _WIN32 || USE_ANSI
RLUTIL_PRINT(str);
#ifdef __cplusplus
RLUTIL_PRINT("\033[" << len << 'D');
#else // __cplusplus
char buf[3 + 20 + 1]; // 20 = max length of 64-bit unsigned int when printed as dec
sprintf(buf, "\033[%uD", len);
RLUTIL_PRINT(buf);
#endif // __cplusplus
#endif // _WIN32 || USE_ANSI
}
/// Function: setChar
/// Sets the character at the cursor without advancing the cursor
RLUTIL_INLINE void setChar(char ch) {
const char buf[] = {ch, 0};
setString(buf);
}
/// Function: setCursorVisibility
/// Shows/hides the cursor.
RLUTIL_INLINE void setCursorVisibility(char visible) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
HANDLE hConsoleOutput = GetStdHandle( STD_OUTPUT_HANDLE );
CONSOLE_CURSOR_INFO structCursorInfo;
GetConsoleCursorInfo( hConsoleOutput, &structCursorInfo ); // Get current cursor size
structCursorInfo.bVisible = (visible ? TRUE : FALSE);
SetConsoleCursorInfo( hConsoleOutput, &structCursorInfo );
#else // _WIN32 || USE_ANSI
RLUTIL_PRINT((visible ? ANSI_CURSOR_SHOW : ANSI_CURSOR_HIDE));
#endif // _WIN32 || USE_ANSI
}
/// Function: hidecursor
/// Hides the cursor.
RLUTIL_INLINE void hidecursor(void) {
setCursorVisibility(0);
}
/// Function: showcursor
/// Shows the cursor.
RLUTIL_INLINE void showcursor(void) {
setCursorVisibility(1);
}
/// Function: msleep
/// Waits given number of milliseconds before continuing.
RLUTIL_INLINE void msleep(unsigned int ms) {
#ifdef _WIN32
Sleep(ms);
#else
// usleep argument must be under 1 000 000
if (ms > 1000) sleep(ms/1000000);
usleep((ms % 1000000) * 1000);
#endif
}
/// Function: trows
/// Get the number of rows in the terminal window or -1 on error.
RLUTIL_INLINE int trows(void) {
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
return -1;
else
return csbi.srWindow.Bottom - csbi.srWindow.Top + 1; // Window height
// return csbi.dwSize.Y; // Buffer height
#else
#ifdef TIOCGSIZE
struct ttysize ts;
ioctl(STDIN_FILENO, TIOCGSIZE, &ts);
return ts.ts_lines;
#elif defined(TIOCGWINSZ)
struct winsize ts;
ioctl(STDIN_FILENO, TIOCGWINSZ, &ts);
return ts.ws_row;
#else // TIOCGSIZE
return -1;
#endif // TIOCGSIZE
#endif // _WIN32
}
/// Function: tcols
/// Get the number of columns in the terminal window or -1 on error.
RLUTIL_INLINE int tcols(void) {
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
return -1;
else
return csbi.srWindow.Right - csbi.srWindow.Left + 1; // Window width
// return csbi.dwSize.X; // Buffer width
#else
#ifdef TIOCGSIZE
struct ttysize ts;
ioctl(STDIN_FILENO, TIOCGSIZE, &ts);
return ts.ts_cols;
#elif defined(TIOCGWINSZ)
struct winsize ts;
ioctl(STDIN_FILENO, TIOCGWINSZ, &ts);
return ts.ws_col;
#else // TIOCGSIZE
return -1;
#endif // TIOCGSIZE
#endif // _WIN32
}
/// Function: anykey
/// Waits until a key is pressed.
/// In C++, it either takes no arguments
/// or a template-type-argument-deduced
/// argument.
/// In C, it takes a const char* representing
/// the message to be displayed, or NULL
/// for no message.
#ifdef __cplusplus
RLUTIL_INLINE void anykey() {
getch();
}
template <class T> void anykey(const T& msg) {
RLUTIL_PRINT(msg);
#else
RLUTIL_INLINE void anykey(RLUTIL_STRING_T msg) {
if (msg)
RLUTIL_PRINT(msg);
#endif // __cplusplus
getch();
}
RLUTIL_INLINE void setConsoleTitle(RLUTIL_STRING_T title) {
const char * true_title =
#ifdef __cplusplus
title.c_str();
#else // __cplusplus
title;
#endif // __cplusplus
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
SetConsoleTitleA(true_title);
#else
RLUTIL_PRINT(ANSI_CONSOLE_TITLE_PRE);
RLUTIL_PRINT(true_title);
RLUTIL_PRINT(ANSI_CONSOLE_TITLE_POST);
#endif // defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
}
// Classes are here at the end so that documentation is pretty.
#ifdef __cplusplus
/// Class: CursorHider
/// RAII OOP wrapper for <rlutil.hidecursor>.
/// Hides the cursor and shows it again
/// when the object goes out of scope.
struct CursorHider {
CursorHider() { hidecursor(); }
~CursorHider() { showcursor(); }
};
} // namespace rlutil
#endif
| [
"noreply@github.com"
] | noreply@github.com |
21590dd98b8756e111a394107a261c0657b3303c | 421f7eba3bdbb63ffc7246d5fe1d8e27651002e0 | /io/qtTemporaryFile.cpp | b07688dd8675a36069a48ffd43e3b5032fd5f5d9 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | BetsyMcPhail/qtextensions | fb90652e5e132490ff7f57c099e8cda1b42972f8 | b2848e06ebba4c39dc63caa2363abc50db75f9d9 | refs/heads/master | 2022-10-24T22:24:29.352059 | 2020-03-30T17:05:22 | 2020-03-30T17:05:22 | 273,300,981 | 0 | 0 | NOASSERTION | 2020-06-18T17:32:56 | 2020-06-18T17:32:55 | null | UTF-8 | C++ | false | false | 6,338 | cpp | /*ckwg +5
* Copyright 2018 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#include <QDir>
#include <QScopedArrayPointer>
static const int MAX_RETRIES = 500;
#ifdef Q_OS_WIN
#include <QFileInfo>
#include <QRegExp>
#include <QUuid>
#include <io.h>
#include <fcntl.h>
#else
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#endif
#include <sys/stat.h>
#include <cerrno>
#include "qtTemporaryFile.h"
QTE_IMPLEMENT_D_FUNC(qtTemporaryFile)
//-----------------------------------------------------------------------------
class qtTemporaryFilePrivate
{
public:
QString templatePath;
};
//-----------------------------------------------------------------------------
qtTemporaryFile::qtTemporaryFile() : d_ptr(new qtTemporaryFilePrivate)
{
this->setTemplateName(".qte_temp.XXXXXX");
}
//-----------------------------------------------------------------------------
qtTemporaryFile::qtTemporaryFile(const QString& templateName)
: d_ptr(new qtTemporaryFilePrivate)
{
(QDir::isAbsolutePath(templateName)
? this->setTemplatePath(templateName)
: this->setTemplateName(templateName));
}
//-----------------------------------------------------------------------------
qtTemporaryFile::~qtTemporaryFile()
{
QTE_D(qtTemporaryFile);
delete d;
}
//-----------------------------------------------------------------------------
QString qtTemporaryFile::templatePath() const
{
QTE_D_CONST(qtTemporaryFile);
return d->templatePath;
}
//-----------------------------------------------------------------------------
void qtTemporaryFile::setTemplateName(const QString& name)
{
this->setTemplatePath(QDir::tempPath() + '/' + name);
}
//-----------------------------------------------------------------------------
void qtTemporaryFile::setTemplatePath(const QString& path)
{
QTE_D(qtTemporaryFile);
d->templatePath = path;
}
//-----------------------------------------------------------------------------
bool qtTemporaryFile::open()
{
return this->open(QIODevice::ReadWrite);
}
//-----------------------------------------------------------------------------
#ifdef Q_OS_WIN
namespace
{
QString mktemp(QString templatePath)
{
QFileInfo fi(templatePath);
QDir dir(fi.path());
if (!dir.exists())
{
return {};
}
QString fileName = fi.fileName();
QString prefix = dir.canonicalPath() + '/' +
fileName.left(fileName.count() - 6);
QString seed = QUuid::createUuid().toString().toLower();
seed = seed.remove(QRegExp("[^0123456789abcdef]"));
QByteArray suffix = QByteArray::fromHex(seed.toLatin1()).toBase64();
suffix = suffix.left(6).replace('/', ',');
return prefix + QString::fromLatin1(suffix.toLower());
}
}
#endif
//-----------------------------------------------------------------------------
bool qtTemporaryFile::open(OpenMode flags)
{
if ((flags & QIODevice::ReadWrite) != QIODevice::ReadWrite)
{
this->setErrorString("Bad mode");
return false;
}
QTE_D(qtTemporaryFile);
if (!d->templatePath.endsWith("XXXXXX"))
{
this->setErrorString("Bad template");
return false;
}
int fd = -1;
#ifdef Q_OS_WIN
int tries = MAX_RETRIES;
while (--tries)
{
// Generate name of a non-existing file
QString t = mktemp(d->templatePath);
if (t.isEmpty())
{
break;
}
// Try to open the file:
// - _O_RDWR | _O_BINARY should be obvious
// - _O_CREAT | _O_EXCL specifies it must not exist
// - _O_SHORT_LIVED says to keep it in cache only, if possible
// - _O_TEMPORARY says to delete it on close; best we can do on Windows
// - _O_NOINHERIT says "prevent creation of a shared file descriptor"
int oflags = _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL |
_O_SHORT_LIVED | _O_TEMPORARY | _O_NOINHERIT;
errno_t e = _wsopen_s(&fd, t.toStdWString().c_str(),
oflags, _SH_DENYRW, _S_IWRITE | _S_IREAD);
if (e == EEXIST)
{
fd = -1;
continue;
}
else if (e != 0)
{
// Unable to open the file; try again
this->setErrorString("Failed to open temporary file: " +
qt_error_string(errno));
return false;
}
else
{
break;
}
}
// No dice...
if (fd < 0)
{
this->setErrorString("Unable to create temporary file name");
return false;
}
#else
// Create the temporary file
QByteArray path = d->templatePath.toLocal8Bit();
fd = mkstemp(path.data());
// Check for failure, and set error string accordingly
if (fd < 0)
{
this->setErrorString("Failed to open temporary file: " +
qt_error_string(errno));
return false;
}
// Remove the file immediately. This way, if anything goes wrong, at worst we
// litter an empty file. By removing it immediately, we ensure that the file
// system will garbage collect it when we die (even abnormally), and it also
// serves as an additional measure of security.
if (unlink(path.constData()) < 0)
{
this->setErrorString("Failed to unlink temporary file: " +
qt_error_string(errno));
return false;
}
// Set the permissions so that the file is not writable by other users...
// just in case someone is able to recover a link to the descriptor (the
// specification of mkstemp does not include the mode with which the file is
// created)
if (fchmod(fd, S_IRUSR | S_IWUSR) < 0)
{
this->setErrorString("Failed to change permissions of temporary file: " +
qt_error_string(errno));
return false;
}
// Now that the file is as safe as we can make it, ensure it is empty and we
// are not seeing anything that might possibly have been written to it by a
// malicious user
if (ftruncate(fd, 0) < 0)
{
this->setErrorString("Failed to truncate temporary file: " +
qt_error_string(errno));
return false;
}
#endif
// At this point, the file descriptor has been opened successfully, so now
// all we need to do is wrap the fd with QFile so that we can use it normally
return (QFile::open(fd, flags));
}
| [
"matthew.woehlke@kitware.com"
] | matthew.woehlke@kitware.com |
c2fad061e313afa14d73bec95e47f5ed8ded5f48 | 4a5957a7bf94b78515758c6876db097f93953fb6 | /LearnCG/src/scenes/study/S_myClickeEffect.h | 60a40ade2a896d2edd207c5e4606e8d352b4952c | [] | no_license | LeChenHz/LearnCG | 0cbeada72a58616fb7fd107fa0cd1ac2014d8128 | 895f7e56962c32c05a293b05b9514bf5e73155d9 | refs/heads/master | 2022-01-27T05:15:52.964409 | 2022-01-25T02:58:40 | 2022-01-25T02:58:40 | 176,194,098 | 0 | 1 | null | 2019-03-18T02:58:11 | 2019-03-18T02:58:10 | null | UTF-8 | C++ | false | false | 767 | h | #pragma once
#include "../Scene.h"
#include <iostream>
#include <fstream>
#include <string>
class S_MyClickEffect : public Scene
{
public:
virtual void initGL();
virtual void paintGL(float deltaTime);
virtual void freeGL();
virtual void setCursePos(float x, float y);
virtual void Clicked() { time = 0.0f; };
virtual void setRender(bool b) { render = b; };
virtual void setScreenSize(int width, int height);
S_MyClickEffect();
~S_MyClickEffect();
Shader* shader = nullptr;
Shader* ClickEffect_1 = nullptr;
Shader* ClickEffect_2 = nullptr;
GLuint backendTexture = 0; //texture
GLuint effect_1 = 0, effect_2 = 0;
GLuint texture_target;
GLuint m_framebuffer = 0;
GLuint VBO, EBO;
GLuint effectVBO;
float time = 0.0f;
bool render = false;
}; | [
"lichenhao@corp.netease.com"
] | lichenhao@corp.netease.com |
f3c547b349e94ed73da5e61036c392863c12f02c | 910d0f0f30aab4bf2d741b57abc24ab174f3c726 | /libraries/Mozzi/examples/01.Basics/Control_Gain/Control_Gain.ino | 6f734df807c6313f09a70bdbf20b4b2b237c4640 | [] | no_license | PennAerospaceClub/HAB-13 | 8d8dbc78007d9836b292d9be6aa559226e630c95 | 4f3e9e0e6f0f373a2050948932301a0b808395c8 | refs/heads/master | 2021-05-01T06:40:00.779260 | 2018-03-30T15:02:45 | 2018-03-30T15:02:45 | 121,149,088 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,363 | ino | /* Example changing the gain of a sinewave,
using Mozzi sonification library.
Demonstrates the use of a control variable to influence an
audio signal.
Circuit: Audio output on digital pin 9 on a Uno or similar, or
DAC/A14 on Teensy 3.1, or
check the README or http://sensorium.github.com/Mozzi/
Mozzi help/discussion/announcements:
https://groups.google.com/forum/#!forum/mozzi-users
Tim Barrass 2012, CC by-nc-sa.
*/
//#include <ADC.h> // Teensy 3.1 uncomment this line and install http://github.com/pedvide/ADC
#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin2048_int8.h> // sine table for oscillator
// use: Oscil <table_size, update_rate> oscilName (wavetable), look in .h file of table #included above
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin(SIN2048_DATA);
// control variable, use the smallest data size you can for anything used in audio
byte gain = 255;
void setup(){
startMozzi(); // start with default control rate of 64
aSin.setFreq(3320); // set the frequency
}
void updateControl(){
// as byte, this will automatically roll around to 255 when it passes 0
gain = gain - 3 ;
}
int updateAudio(){
return (aSin.next()* gain)>>8; // shift back to STANDARD audio range, like /256 but faster
}
void loop(){
audioHook(); // required here
}
| [
"amenarde@gmail.com"
] | amenarde@gmail.com |
ff001ce342cd1b6eb7734cb44d18c66256f37e10 | bc8f1ea8b5f32f67b15a0b54f23ee3776ae284df | /tools/Reactivision/reacTIVision/reacTIVision/ext/libdtouch/fiducialrecognition.cpp | 66068912c2b671f20e325bc98fd991df26e25752 | [
"MIT"
] | permissive | schalleneider/irtaktiks | 3117283c49b6f954cdda1ff122edac76bc01a416 | da27b5ac3740dc68840d9524121ee15909511036 | refs/heads/master | 2020-12-02T05:25:11.682932 | 2017-08-16T17:53:32 | 2017-08-16T17:53:32 | 96,902,262 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,169 | cpp | /***************************************************************************
fiducialrecognition.cpp - description
-------------------
begin : Tue Aug 27 2002
copyright : (C) 2002 by Enrico Costanza
email : e.costanza@ieee.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330 *
* Boston, MA 02111-1307 USA *
* *
***************************************************************************/
/* Changes
Code optimization by Jorge M Santiago
Small amount of further optimisation by Justen Hyde
*/
#include "fiducialrecognition.h"
#include "types.h"
#include "regionadjacencygraph.h"
#include "ragbuilder.h"
#include "listhash.h"
#include <iomanip>
#include <math.h>
using std::cout;
using std::cerr;
using std::endl;
//345678901234567890123456789012345678901234567890123456789012345678901234567890
FiducialRecognition::FiducialRecognition( int in_width, int in_height,
int in_noFiducialSequences, int **in_fiducialSequence,
bool *in_usingLinearFiducials ) :
width(in_width),
height(in_height),
m_uD(40),
m_uR(64),
//m_uS(m_uD/2)
m_uS(20),
//m_uM(in_width/m_uS),
//m_uN(in_height/m_uS),
m_uM(in_height/20),
m_uN(in_width/20)
{
//for(int i=0;i<256;i++) s[i]=0;
// !!! JMS - Does it have to be initialized
memset(s,0,256*sizeof(int));
// !!! JMS
//minBuffer = new int [width/(d/2) * height/(d/2)];
//maxBuffer = new int [width/(d/2) * height/(d/2)];
m_vuMinBuffer = new unsigned int [(in_width/20) * (in_height/20)];
m_vuMaxBuffer = new unsigned int [(in_width/20) * (in_height/20)];
_graphSize = 4000;
_regionsPool = new StaticPool<DTPoint>(width*height);
_edges = new ListHash<int>*[_graphSize];
_stored = new bool[width*height];
_region = new DTRegion*[_graphSize];
_labelsPtrPool = new DynamicPool<int *>(_graphSize);
DTRegion ** l_Region = _region;
ListHash<int>** l_Edges = _edges;
for(int i=0;i<_graphSize;i++){
*l_Edges++ = new ListHash<int>(_graphSize);
//_region[i] = new DTRegion(_regionsPool, _labelsPtrPool);
*l_Region++ = new DTRegion(_regionsPool, _labelsPtrPool);
}
_labelsMap = new int*[width*height];
_labels = new int[width*height];
threshold = new unsigned char[width*height];
memset(threshold, 128, width*height);
noFiducialSequences = in_noFiducialSequences;
usingLinearFiducials = new bool[noFiducialSequences];
fiducialSequence = new int * [noFiducialSequences];
for(int i=0;i<noFiducialSequences;i++){
usingLinearFiducials[i] = in_usingLinearFiducials[i];
fiducialSequence[i] = new int[in_fiducialSequence[i][0]+1];
memcpy( fiducialSequence[i], in_fiducialSequence[i], (in_fiducialSequence[i][0]+1)*sizeof(int) );
}
}
FiducialRecognition::FiducialRecognition( int in_width, int in_height,
int *in_fiducialSequence, bool in_usingLinearFiducials ) :
width(in_width),
height(in_height),
m_uD(40),
m_uR(64),
//m_uS(m_uD/2)
m_uS(20),
//m_uM(in_width/m_uS),
//m_uN(in_height/m_uS),
m_uM(in_height/20),
m_uN(in_width/20)
{
//for(int i=0;i<256;i++) s[i]=0;
// !!! JMS - Does it have to be initialized
memset(s,0,256*sizeof(int));
// !!! JMS
//minBuffer = new int [width/(d/2) * height/(d/2)];
//maxBuffer = new int [width/(d/2) * height/(d/2)];
m_vuMinBuffer = new unsigned int [(in_width/20) * (in_height/20)];
m_vuMaxBuffer = new unsigned int [(in_width/20) * (in_height/20)];
_graphSize = 4000;
_regionsPool = new StaticPool<DTPoint>(width*height);
_edges = new ListHash<int>*[_graphSize];
_stored = new bool[width*height];
_region = new DTRegion*[_graphSize];
_labelsPtrPool = new DynamicPool<int *>(_graphSize);
DTRegion ** l_Region = _region;
ListHash<int>** l_Edges = _edges;
for(int i=0;i<_graphSize;i++){
*l_Edges++ = new ListHash<int>(_graphSize);
//_region[i] = new DTRegion(_regionsPool, _labelsPtrPool);
*l_Region++ = new DTRegion(_regionsPool, _labelsPtrPool);
}
_labelsMap = new int*[width*height];
memset(_labelsMap,0, sizeof(int*)*width*height);
_labels = new int[width*height];
memset(_labels,0, sizeof(int)*width*height);
threshold = new unsigned char[width*height];
memset(threshold, 128, width*height*sizeof(unsigned char));
if( in_fiducialSequence==NULL ){
noFiducialSequences = 1;
usingLinearFiducials = new bool[noFiducialSequences];
usingLinearFiducials[0] = false;
fiducialSequence = new int * [noFiducialSequences];
fiducialSequence[0] = new int[6];
fiducialSequence[0][0] = 5;
fiducialSequence[0][1] = 0;
fiducialSequence[0][2] = 1;
fiducialSequence[0][3] = 2;
fiducialSequence[0][4] = 3;
fiducialSequence[0][5] = 4;
}else{
noFiducialSequences = 1;
usingLinearFiducials = new bool[noFiducialSequences];
usingLinearFiducials[0] = in_usingLinearFiducials;
fiducialSequence = new int *[noFiducialSequences];
fiducialSequence[0] = new int[in_fiducialSequence[0]+1];
memcpy( fiducialSequence[0], in_fiducialSequence, (in_fiducialSequence[0]+1)*sizeof(int) );
}
}
FiducialRecognition::~FiducialRecognition()
{
if (m_vuMinBuffer != NULL)
{
delete [] m_vuMinBuffer;
m_vuMinBuffer = NULL;
}
if (m_vuMaxBuffer != NULL)
{
delete [] m_vuMaxBuffer;
m_vuMaxBuffer = NULL;
}
delete [] usingLinearFiducials;
for(int i=0;i<noFiducialSequences;i++){
delete [] fiducialSequence[i];
}
delete [] fiducialSequence;
if(threshold!=NULL){ delete [] threshold; }
for(int i=0;i<_graphSize;i++){
delete _edges[i];
delete _region[i];
}
delete _regionsPool;
delete _labelsPtrPool;
delete [] _edges;
delete [] _region;
delete [] _labelsMap;
delete [] _labels;
delete [] _stored;
}
// WARNING: process ASSUMES image is in grayscale format
int FiducialRecognition::process( unsigned char *img, FiducialData **fiducialData ){
// for compatibility with NON-ANSI old MS compiler
// index variable i is declared once for the entire
// method
// I do *not* like this, but I need compatibility
// ..at least until mr JRH will decide that Linux is the way to go! :-)
int i;
// !!! JMS
//memset(histogram,0,256*sizeof(int));
memset(histogram,0,sizeof(histogram));
unsigned char *ip = img;
int limit = width*height;
for(i=0;i<limit;i++){
(*(histogram + *ip++))++;
}
setBernsenThreshold( img );
RegionAdjacencyGraph sceneRAG( width, height, _graphSize, _regionsPool,
_edges, _region, _labelsMap, _labels );
RAGBuilder ragBuilder( img, width, height, threshold, &sceneRAG, _stored );
//
//int ragBuilt = ragBuilder.buildRAG();
//int ragBuilt = ragBuilder.buildRAGBorder();
int ragBuilt = ragBuilder.buildRAGFullBorder(_graphSize/2);
// update the graph size (stored in MyCameraFramework)
// as the graph might have been expanded in buildRAG
_graphSize = sceneRAG.getSize();
_edges = sceneRAG.getEdges();
_region = sceneRAG.getRegions();
if( ragBuilt != 0 ){
fiducialData = NULL;
return 0;
}
//mk int noRegions = sceneRAG.getNoRegions();
int noFiducials = 0;
for(int k=0;k<noFiducialSequences;k++){
FiducialData *tmpFiducialData;
int tmpNoFiducials = sceneRAG.findFiducials( fiducialSequence[k],
&tmpFiducialData, usingLinearFiducials[k] );
FiducialData *result = new FiducialData [tmpNoFiducials+noFiducials];
memcpy( result, *fiducialData, noFiducials * sizeof(FiducialData) );
memcpy( result+noFiducials, tmpFiducialData, tmpNoFiducials * sizeof(FiducialData) );
delete [] *fiducialData;
*fiducialData = result;
delete [] tmpFiducialData;
noFiducials += tmpNoFiducials;
}
#ifdef _EC_DEBUG
cout << noFiducials << " fiducials found" << endl;
for( i=0;i<noFiducials;i++){
FiducialData *fiducialDataPtr = fiducialData[i];
cout << "#" << i << ": type: " << fiducialDataPtr->Type() << " -> ";
cout << ", angle: " << fiducialDataPtr->Angle();
cout << endl;
}
#endif
return noFiducials;
}
void FiducialRecognition::setMinMaxBuffersForThreshold(unsigned char *img)
{
unsigned int *minBufferPtr = m_vuMinBuffer;
unsigned int *maxBufferPtr = m_vuMaxBuffer;
unsigned int m;
unsigned int n;
unsigned int x;
unsigned int y;
unsigned int max;
unsigned int min;
unsigned int nXs;
unsigned int mXs;
unsigned int yXwidth;
unsigned char *ip;
for(m = 0, mXs = 0; m < m_uM; ++m, mXs += m_uS )
{
for(n = 0, nXs = 0; n < m_uN; ++n, nXs += m_uS )
{
max = 0;
min = 255;
// for(y = mXs; y < ((m+1) * m_uS); ++y )
for(y = mXs, yXwidth = (y * width); y < (mXs + m_uS); ++y, yXwidth += width )
{
//for(x = 0, ip = img + nXs + (y*width); x < m_uS; ++x, ++ip )
for(x = 0, ip = img + nXs + yXwidth; x < m_uS; ++x, ++ip )
{
if( *ip > max )
{
max = *ip;
}
else if( *ip < min )
{
min = *ip;
}
}
}
*minBufferPtr++ = min;
*maxBufferPtr++ = max;
}
}
}
void FiducialRecognition::setSubClustersMinMax(unsigned int uOstuThreshold)
{
unsigned int m;
unsigned int n;
unsigned int mXn;
unsigned int mXs;
unsigned int nXs;
unsigned int *minBufferCurrent;
unsigned int *minBufferRight;
unsigned int *minBufferBelow;
unsigned int *minBufferBelowRight;
unsigned int *maxBufferCurrent;
unsigned int *maxBufferRight;
unsigned int *maxBufferBelow;
unsigned int *maxBufferBelowRight;
unsigned int min;
unsigned int max;
unsigned char thresholdHere;
unsigned int y;
unsigned int yXwidth;
unsigned char *tp;
for(m = 0, mXn = 0, mXs = 0; m < (m_uM-1); ++m, mXn += m_uN, mXs += m_uS)
{
minBufferCurrent = m_vuMinBuffer + mXn;
minBufferRight = m_vuMinBuffer + mXn + 1;
minBufferBelow = m_vuMinBuffer + mXn + m_uN;
minBufferBelowRight = m_vuMinBuffer + mXn + m_uN + 1;
maxBufferCurrent = m_vuMaxBuffer + mXn;
maxBufferRight = m_vuMaxBuffer + mXn + 1;
maxBufferBelow = m_vuMaxBuffer + mXn + m_uN;
maxBufferBelowRight = m_vuMaxBuffer + mXn + m_uN + 1;
for(n = 0, nXs = 0; n < m_uN-1; ++n, nXs += m_uS )
{
//calculate cluster min
min = *minBufferCurrent++;
( min > *minBufferRight ) ? ( min = *minBufferRight++ ) : ( *minBufferRight++ );
( min > *minBufferBelow ) ? ( min = *minBufferBelow++ ) : ( *minBufferBelow++ );
( min > *minBufferBelowRight ) ? ( min = *minBufferBelowRight++ ) : ( *minBufferBelowRight++ );
//cluster min ready
//calculate cluster max
max = *maxBufferCurrent++;
( max < *maxBufferRight ) ? ( max = *maxBufferRight++ ) : ( *maxBufferRight++ );
( max < *maxBufferBelow ) ? ( max = *maxBufferBelow++ ) : ( *maxBufferBelow++ );
( max < *maxBufferBelowRight ) ? ( max = *maxBufferBelowRight++ ) : ( *maxBufferBelowRight++ );
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = uOstuThreshold;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
//for(y = m*m_uS+m_uS/2; y<(m+1)*m_uS+m_uS/2; y++ )
for(y = mXs + (m_uS >> 1), yXwidth = (y*width); y < mXs + m_uS + (m_uS >> 1); ++y, yXwidth += width )
{
tp = threshold + nXs + (m_uS >> 1) + yXwidth;
memset(tp, thresholdHere, m_uS);
}
//end of cluster
}
}
}
void FiducialRecognition::setBernsenThreshold( unsigned char *img )
{
unsigned int min;
unsigned int max;
unsigned char thresholdHere;
unsigned int x;
unsigned int y;
unsigned int yXwidth;
unsigned int m;
unsigned int n;
unsigned int mXn;
unsigned int mXs;
unsigned int nXs;
unsigned int sDIV2 = (m_uS >> 1);
//calculate a global threshold, to be used when the std deviation is below a certain threshold
int ostuT = thresholdOstu();
//calculate 2 buffers with min and max of quarters of each cluster
//this is used to reduce the number of operations (comparison) needed to calculate the mean
setMinMaxBuffersForThreshold(img);
//calculate actual min and max of each cluster, then contrast and threshold
//for each cluster this is done combining 4 sub-clusters (i.e. the min and max values
//of 4 sub-clusters are compared)
setSubClustersMinMax(ostuT);
//need to handle the borders of the image separately
//top left corner
min = m_vuMinBuffer[0];
max = m_vuMaxBuffer[0];
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
//for( y = 0, yXwidth = 0; y < m_uS/2; ++y, yXwidth += width )
for( y = 0, yXwidth = 0; y < sDIV2; ++y, yXwidth += width )
{
memset(threshold + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
//top row
for(n = 0, nXs = 0; n < m_uN-1; ++n, nXs += m_uS)
{
//calculate cluster min
min = m_vuMinBuffer[n];
if( min > m_vuMinBuffer[n+1] )
{
min = m_vuMinBuffer[n+1];
}
//cluster min ready
//calculate cluster max
max = m_vuMaxBuffer[n];
if( max < m_vuMaxBuffer[n+1] )
{
max = m_vuMaxBuffer[n+1];
}
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
//for(y = 0, yXwidth = 0; y < m_uS/2; ++y, yXwidth += width)
x = nXs + sDIV2;
for(y = 0, yXwidth = 0; y < sDIV2; ++y, yXwidth += width)
{
memset(threshold + x + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
}
//top right corner
min = m_vuMinBuffer[m_uN-1]; //m_uN-1+0*m_uN
max = m_vuMaxBuffer[m_uN-1]; //m_uN-1+0*m_uN
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
x = (m_uN-1) * m_uS;
for( y = 0, yXwidth = 0; y < sDIV2; ++y, yXwidth += width )
{
memset(threshold + x + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
n = m_uN-1;
nXs = n * m_uS;
for(m = 0, mXn = 0, mXs = 0; m < m_uM-1; ++m, mXn += m_uN, mXs += m_uS )
{
//calculate cluster min
min = m_vuMinBuffer[n + mXn];
//if( min > m_vuMinBuffer[n + (m+1)*m_uN] )
if( min > m_vuMinBuffer[n + (mXn + m_uN)] )
{
min = m_vuMinBuffer[n + (mXn + m_uN)];
}
//cluster min ready
//calculate cluster max
max = m_vuMaxBuffer[n + mXn];
if( max < m_vuMaxBuffer[n + (mXn + m_uN)] )
{
max = m_vuMaxBuffer[n + (mXn + m_uN)];
}
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
//for(y = mXs + sDIV2, yXwidth = y*width; y < (m+1) * m_uS + sDIV2; ++y, yXwidth += width)
x = nXs + sDIV2;
for(y = mXs + sDIV2, yXwidth = y*width; y < (mXs + m_uS) + sDIV2; ++y, yXwidth += width)
{
memset(threshold + x + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
}
//bottom right corner
mXn = m_uN*m_uM;
//calculate cluster min
min = m_vuMinBuffer[mXn-1];
//cluster min ready
//calculate cluster max
max = m_vuMaxBuffer[mXn-1];
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
x = (m_uN-1) * m_uS + sDIV2;
for(y = (m_uM-1) * m_uS + sDIV2, yXwidth = y*width; y<height; ++y, yXwidth += width )
{
memset(threshold + x + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
//bottom row
m = m_uM-1;
mXs = m * m_uS;
for(n = 0, mXn = 0, nXs = 0; n < m_uN-1; ++n, mXn += m_uM, nXs += m_uS )
{
//calculate cluster min
min = m_vuMinBuffer[n + mXn];
if( min > m_vuMinBuffer[(n+1) + mXn] )
{
min = m_vuMinBuffer[(n+1) + mXn];
}
//cluster min ready
//calculate cluster max
max = m_vuMaxBuffer[n + mXn];
if( max < m_vuMaxBuffer[(n+1) + mXn] )
{
max = m_vuMaxBuffer[(n+1) + mXn];
}
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
x = mXs + sDIV2;
for(y = mXs + sDIV2, yXwidth = y*width; y<height; ++y, yXwidth += width )
{
memset(threshold + x + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
}
//bottom left corner
min = m_vuMinBuffer[(m_uM-1) * m_uN]; //0+(m_uM-1)*m_uN
max = m_vuMaxBuffer[(m_uM-1) * m_uN]; //0+(m_uM-1)*m_uN
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pixel in this cluster (central ones)
for(y = (m_uM-1)*m_uS + sDIV2, yXwidth = y*width; y < height; ++y, yXwidth += width )
{
memset(threshold + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
//leftmost column
for(m = 0, mXn = 0, mXs = 0; m < m_uM-1; ++m, mXn += m_uN, mXs += m_uS )
{
//calculate cluster min
min = m_vuMinBuffer[mXn];
if( min > m_vuMinBuffer[mXn + m_uN] )
{
min = m_vuMinBuffer[mXn + m_uN];
}
//cluster min ready
//calculate cluster max
max = m_vuMaxBuffer[mXn];
if( max < m_vuMaxBuffer[mXn + m_uN] )
{
max = m_vuMaxBuffer[mXn + m_uN];
}
//cluster max ready
if( (max - min) < m_uR )
{
thresholdHere = ostuT;
}
else
{
//thresholdHere = (min + max) / 2;
thresholdHere = (min + max) >> 1;
}
//apply threshold to 1/4 of the pyxel in this cluster (central ones)
for(y = mXs + sDIV2, yXwidth = y*width; y < mXs + m_uS + sDIV2; ++y, yXwidth += width )
{
memset(threshold + yXwidth, thresholdHere, sDIV2);
}
//end of cluster
}
}
int FiducialRecognition::thresholdOstu()
{
int t=0;
int histogramArea=0;
int * l_Hist = histogram;
for( int i=0; i< 256; i++ ) {
t+=*l_Hist * i;
histogramArea+=*l_Hist++;
}
t/=histogramArea;
if( t<1 ) t++;
if( t>254 ) t--;
s[t] = sigma(histogram, t);
s[t-1] = sigma(histogram, t-1);
s[t+1] = sigma(histogram, t+1);
if( !((s[t] > s[t+1]) && (s[t] > s[t-1])) ) {
int delta = 0;
if( (s[t] <= s[t+1]) ) delta = +1;
if( (s[t] <= s[t-1]) ) delta = -1;
if( (s[t] < s[t+1]) ) delta = +1;
if( (s[t] < s[t-1]) ) delta = -1;
while( (t>1 && t<253) && (s[t] <= s[t+delta]) ) {
t += delta;
s[t+delta] = sigma(histogram, t+delta);
}
}
return t;
}
int FiducialRecognition::sigma( int *histo, int t )
{
int i;
long xAvg = 0;
long x1Avg = 0;
long w = 0; //= 32640; // 255 * 256 / 2
long w1 = 0; //= t * (t+1) / 2;
int * l_Hist = histo;
for( i=0; i<t; i++ ) {
x1Avg += i * *l_Hist;
w1 += *l_Hist++;
}
xAvg = x1Avg;
w = w1;
l_Hist = histo;
for( i=t; i<256; i++ ) {
xAvg += i * *l_Hist;
w += *l_Hist++;
}
double x1d = x1Avg;
double xd = xAvg;
double wd = w;
double w1d = w1;
double termA = (x1d/w1d - xd/wd);
double termB = w1d/(wd-w1d);
return (int) ( termA*termA*termB );
}
// end of file
| [
"schalleneider@users.noreply.github.com"
] | schalleneider@users.noreply.github.com |
bef2eafb27bd6ff1960bac27b20e71a0589470b3 | 39b0eb3fb97db4cf0531e7c01986d7d7539453b2 | /compiler/IR/pLinkTarget.cpp | 669d90bc9869bffb478e50486075fe4b4a4759b2 | [] | no_license | zjsxwc/roadsend-php-raven | 3f96b0a22e729e19fca806cacd529ab57249149b | 2da4406bbe3a668dfd72f7fa0ad9a569731694de | refs/heads/master | 2020-08-05T21:21:49.539500 | 2019-10-06T01:43:45 | 2019-10-06T01:43:45 | 212,715,939 | 0 | 0 | null | 2019-10-04T01:42:52 | 2019-10-04T01:42:52 | null | UTF-8 | C++ | false | false | 956 | cpp | /* ***** BEGIN LICENSE BLOCK *****
;; Roadsend PHP Compiler
;;
;; Copyright (c) 2008-2009 Shannon Weyrick <weyrick@roadsend.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 2
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
***** END LICENSE BLOCK *****
*/
#include "rphp/IR/pLinkTarget.h"
namespace rphp {
} // namespace
| [
"weyrick@mozek.us"
] | weyrick@mozek.us |
1180ab3aaed4ef249057630e9405ac42af4e2c26 | 79406addafa8d09ffdd209aa3b64d97b0f2483a8 | /src/chain.h | 43203a79fc6ee0ed8c76ef2cc94fd61658af3fc4 | [
"MIT"
] | permissive | citrixrep/Pylon-Segwit | faa9e46e9ba7251a174440d83ef8215c4c1cb76b | 395e71d5be0fde8a1cf6e2b49b1ff75f5d19f75f | refs/heads/master | 2020-03-22T22:17:28.691076 | 2018-07-17T13:38:35 | 2018-07-17T13:38:35 | 140,743,627 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,570 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 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 BITCOIN_CHAIN_H
#define BITCOIN_CHAIN_H
#include "arith_uint256.h"
#include "primitives/block.h"
#include "tinyformat.h"
#include "uint256.h"
#include <vector>
#include <boost/foreach.hpp>
#include "consensus/params.h"
struct CDiskBlockPos
{
int nFile;
unsigned int nPos;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(VARINT(nFile));
READWRITE(VARINT(nPos));
}
CDiskBlockPos() {
SetNull();
}
CDiskBlockPos(int nFileIn, unsigned int nPosIn) {
nFile = nFileIn;
nPos = nPosIn;
}
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) {
return (a.nFile == b.nFile && a.nPos == b.nPos);
}
friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b) {
return !(a == b);
}
void SetNull() { nFile = -1; nPos = 0; }
bool IsNull() const { return (nFile == -1); }
std::string ToString() const
{
return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos);
}
};
enum BlockStatus {
//! Unused.
BLOCK_VALID_UNKNOWN = 0,
//! Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future
BLOCK_VALID_HEADER = 1,
//! All parent headers found, difficulty matches, timestamp >= median previous, checkpoint. Implies all parents
//! are also at least TREE.
BLOCK_VALID_TREE = 2,
/**
* Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid, no duplicate txids,
* sigops, size, merkle root. Implies all parents are at least TREE but not necessarily TRANSACTIONS. When all
* parent blocks also have TRANSACTIONS, CBlockIndex::nChainTx will be set.
*/
BLOCK_VALID_TRANSACTIONS = 3,
//! Outputs do not overspend inputs, no double spends, coinbase output ok, no immature coinbase spends, BIP30.
//! Implies all parents are also at least CHAIN.
BLOCK_VALID_CHAIN = 4,
//! Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
BLOCK_VALID_SCRIPTS = 5,
//! All validity bits.
BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS |
BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS,
BLOCK_HAVE_DATA = 8, //! full block available in blk*.dat
BLOCK_HAVE_UNDO = 16, //! undo data available in rev*.dat
BLOCK_HAVE_MASK = BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO,
BLOCK_FAILED_VALID = 32, //! stage after last reached validness failed
BLOCK_FAILED_CHILD = 64, //! descends from failed block
BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD,
BLOCK_OPT_WITNESS = 128, //!< block data in blk*.data was received with a witness-enforcing client
};
/** The block chain is a tree shaped structure starting with the
* genesis block at the root, with each block potentially having multiple
* candidates to be the next block. A blockindex may have multiple pprev pointing
* to it, but at most one of them can be part of the currently active branch.
*/
class CBlockIndex
{
public:
//! pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
const uint256* phashBlock;
//! pointer to the index of the predecessor of this block
CBlockIndex* pprev;
//! pointer to the index of some further predecessor of this block
CBlockIndex* pskip;
//! height of the entry in the chain. The genesis block has height 0
int nHeight;
//! Which # file this block is stored in (blk?????.dat)
int nFile;
//! Byte offset within blk?????.dat where this block's data is stored
unsigned int nDataPos;
//! Byte offset within rev?????.dat where this block's undo data is stored
unsigned int nUndoPos;
//! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
arith_uint256 nChainWork;
//! Number of transactions in this block.
//! Note: in a potential headers-first mode, this number cannot be relied upon
unsigned int nTx;
//! (memory only) Number of transactions in the chain up to and including this block.
//! This value will be non-zero only if and only if transactions for this block and all its parents are available.
//! Change to 64-bit type when necessary; won't happen before 2030
unsigned int nChainTx;
//! Verification status of this block. See enum BlockStatus
unsigned int nStatus;
//! block header
int nVersion;
uint256 hashMerkleRoot;
uint256 hashPayload;
unsigned int nTime;
unsigned int nCreatorId;
vector<uint32_t> vMissingSignerIds;
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
uint32_t nSequenceId;
void SetNull()
{
phashBlock = NULL;
pprev = NULL;
pskip = NULL;
nHeight = 0;
nFile = 0;
nDataPos = 0;
nUndoPos = 0;
nChainWork = arith_uint256();
nTx = 0;
nChainTx = 0;
nStatus = 0;
nSequenceId = 0;
nVersion = 0;
hashMerkleRoot = uint256();
hashPayload = uint256();
nTime = 0;
nCreatorId = 0;
}
CBlockIndex()
{
SetNull();
}
CBlockIndex(const CBlockHeader& block, const vector<uint32_t>* vMissingSignerIdsIn)
{
SetNull();
nVersion = block.nVersion;
hashMerkleRoot = block.hashMerkleRoot;
hashPayload = block.hashPayload;
nTime = block.nTime;
nCreatorId = block.nCreatorId;
if (vMissingSignerIdsIn)
vMissingSignerIds = *vMissingSignerIdsIn;
else
vMissingSignerIds.clear();
}
CDiskBlockPos GetBlockPos() const {
CDiskBlockPos ret;
if (nStatus & BLOCK_HAVE_DATA) {
ret.nFile = nFile;
ret.nPos = nDataPos;
}
return ret;
}
CDiskBlockPos GetUndoPos() const {
CDiskBlockPos ret;
if (nStatus & BLOCK_HAVE_UNDO) {
ret.nFile = nFile;
ret.nPos = nUndoPos;
}
return ret;
}
CBlockHeader GetBlockHeader() const
{
CBlockHeader block;
block.nVersion = nVersion;
if (pprev)
block.hashPrevBlock = pprev->GetBlockHash();
block.hashMerkleRoot = hashMerkleRoot;
block.hashPayload = hashPayload;
block.nTime = nTime;
block.nCreatorId = nCreatorId;
return block;
}
uint256 GetBlockHash() const
{
return *phashBlock;
}
int64_t GetBlockTime() const
{
return (int64_t)nTime;
}
enum { nMedianTimeSpan=11 };
int64_t GetMedianTimePast() const
{
int64_t pmedian[nMedianTimeSpan];
int64_t* pbegin = &pmedian[nMedianTimeSpan];
int64_t* pend = &pmedian[nMedianTimeSpan];
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
*(--pbegin) = pindex->GetBlockTime();
std::sort(pbegin, pend);
return pbegin[(pend - pbegin)/2];
}
std::string GetPayloadString() const
{
std::stringstream payload;
if (nVersion & CBlock::TX_PAYLOAD)
payload << "tx";
if (nVersion & CBlock::CVN_PAYLOAD)
payload << strprintf("%scvninfo", (payload.tellp() > 0) ? "|" : "");
if (nVersion & CBlock::CHAIN_PARAMETERS_PAYLOAD)
payload << strprintf("%sparams", (payload.tellp() > 0) ? "|" : "");
if (nVersion & CBlock::CHAIN_ADMINS_PAYLOAD)
payload << strprintf("%sadmins", (payload.tellp() > 0) ? "|" : "");
if (nVersion & CBlock::COIN_SUPPLY_PAYLOAD)
payload << strprintf("%ssupply", (payload.tellp() > 0) ? "|" : "");
return payload.str();
}
//! Check whether this block index entry is valid up to the passed validity level.
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const
{
assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed.
if (nStatus & BLOCK_FAILED_MASK)
return false;
return ((nStatus & BLOCK_VALID_MASK) >= nUpTo);
}
//! Raise the validity level of this block index entry.
//! Returns true if the validity was changed.
bool RaiseValidity(enum BlockStatus nUpTo)
{
assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed.
if (nStatus & BLOCK_FAILED_MASK)
return false;
if ((nStatus & BLOCK_VALID_MASK) < nUpTo) {
nStatus = (nStatus & ~BLOCK_VALID_MASK) | nUpTo;
return true;
}
return false;
}
//! Build the skiplist pointer for this entry.
void BuildSkip();
string ToString() const;
//! Efficiently find an ancestor of this block.
CBlockIndex* GetAncestor(int height);
const CBlockIndex* GetAncestor(int height) const;
};
/** Used to marshal pointers into hashes for db storage. */
class CDiskBlockIndex : public CBlockIndex
{
public:
uint256 hashPrev;
CDiskBlockIndex() {
hashPrev = uint256();
}
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
hashPrev = (pprev ? pprev->GetBlockHash() : uint256());
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
int nVersion = s.GetVersion();
if (!(s.GetType() & SER_GETHASH))
READWRITE(VARINT(nVersion));
READWRITE(VARINT(nHeight));
READWRITE(VARINT(nStatus));
READWRITE(VARINT(nTx));
if (nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO))
READWRITE(VARINT(nFile));
if (nStatus & BLOCK_HAVE_DATA)
READWRITE(VARINT(nDataPos));
if (nStatus & BLOCK_HAVE_UNDO)
READWRITE(VARINT(nUndoPos));
// block header
READWRITE(this->nVersion);
READWRITE(hashPrev);
READWRITE(hashMerkleRoot);
READWRITE(hashPayload);
READWRITE(nTime);
READWRITE(nCreatorId);
READWRITE(vMissingSignerIds);
}
uint256 GetBlockHash() const
{
CBlockHeader block;
block.nVersion = nVersion;
block.hashPrevBlock = hashPrev;
block.hashMerkleRoot = hashMerkleRoot;
block.hashPayload = hashPayload;
block.nTime = nTime;
block.nCreatorId = nCreatorId;
return block.GetHash();
}
std::string ToString() const
{
std::string str = "CDiskBlockIndex(";
str += CBlockIndex::ToString();
str += strprintf("\n hashBlock=%s, hashPrev=%s)",
GetBlockHash().ToString(),
hashPrev.ToString());
return str;
}
};
/** An in-memory indexed chain of blocks. */
class CChain {
private:
std::vector<CBlockIndex*> vChain;
public:
/** Returns the index entry for the genesis block of this chain, or NULL if none. */
CBlockIndex *Genesis() const {
return vChain.size() > 0 ? vChain[0] : NULL;
}
/** Returns the index entry for the tip of this chain, or NULL if none. */
CBlockIndex *Tip() const {
return vChain.size() > 0 ? vChain[vChain.size() - 1] : NULL;
}
/** Returns the index entry at a particular height in this chain, or NULL if no such height exists. */
CBlockIndex *operator[](int nHeight) const {
if (nHeight < 0 || nHeight >= (int)vChain.size())
return NULL;
return vChain[nHeight];
}
/** Compare two chains efficiently. */
friend bool operator==(const CChain &a, const CChain &b) {
return a.vChain.size() == b.vChain.size() &&
a.vChain[a.vChain.size() - 1] == b.vChain[b.vChain.size() - 1];
}
/** Efficiently check whether a block is present in this chain. */
bool Contains(const CBlockIndex *pindex) const {
return (*this)[pindex->nHeight] == pindex;
}
/** Find the successor of a block in this chain, or NULL if the given index is not found or is the tip. */
CBlockIndex *Next(const CBlockIndex *pindex) const {
if (Contains(pindex))
return (*this)[pindex->nHeight + 1];
else
return NULL;
}
/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
int Height() const {
return vChain.size() - 1;
}
/** Set/initialize a chain with a given tip. */
void SetTip(CBlockIndex *pindex);
/** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
CBlockLocator GetLocator(const CBlockIndex *pindex = NULL) const;
/** Find the last common block between this chain and a block index entry. */
const CBlockIndex *FindFork(const CBlockIndex *pindex) const;
};
#endif // BITCOIN_CHAIN_H
| [
"maxtvstream@live.com"
] | maxtvstream@live.com |
ba972d058a4a3adbbe2e56d14038bcadd98c2381 | 05b3c7d89a652eda02c76c86795496019bf49a4d | /Source/Section47/AI/BehaviorTree/S47BTTask_AttackRange.h | 71dfe6b95454a5de7a1ba98948d3b727bfdec7f2 | [] | no_license | pasqueta/Section47 | 38ba462884d269bb4a852f63df2ec838a99dfa30 | 97cdb13908a34931b3f6d0f41da014465f67ecd7 | refs/heads/master | 2020-11-28T08:19:59.740638 | 2019-07-23T15:50:18 | 2019-07-23T15:50:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 452 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h"
#include "S47BTTask_AttackRange.generated.h"
/**
*
*/
UCLASS()
class SECTION47_API US47BTTask_AttackRange : public UBTTask_BlackboardBase
{
GENERATED_BODY()
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)override;
};
| [
"vince.col.colin@gmail.com"
] | vince.col.colin@gmail.com |
84c09ed17ce219d2b9c21179798265e9729017ec | 5aed93c5a217dabc935c8fb3e201ac2874abba0b | /ego/src/cc/filter/http/filter-native.cc | 8269b58c76da90683b7f4b0545853707432b8638 | [
"Apache-2.0"
] | permissive | rkt2spc/ego-demo | 6a927fc2d6de0e10ba4528c77cc760d5194250e6 | 063d18e147b619d415880e6be6765c6652531c90 | refs/heads/master | 2023-05-24T02:52:59.556216 | 2021-03-08T08:12:18 | 2021-03-08T08:12:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,439 | cc | // Copyright 2020-2021 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
//
// Use of this source code is governed by the Apache License 2.0 that can be
// found in the LICENSE file
#include "common/common/empty_string.h"
#include "filter.h"
namespace Envoy {
namespace Http {
void GoHttpFilter::setDecoderFilterCallbacks(StreamDecoderFilterCallbacks& callbacks) {
ASSERT(0 < pins_.load());
ASSERT(0 == decoderCallbacks_);
// Assuming dispatcher is shared between callbacks
// https://github.com/envoyproxy/envoy/blob/master/include/envoy/thread_local/thread_local.h
ASSERT(nullptr == dispatcher_);
decoderCallbacks_ = &callbacks;
dispatcher_ = &callbacks.dispatcher();
// Handle logic can not create fitler on Go-side
if (cgoTag_ == 0) {
decoderCallbacks_->sendLocalReply(Code::InternalServerError, EMPTY_STRING, nullptr,
absl::nullopt, EMPTY_STRING);
}
}
void GoHttpFilter::setEncoderFilterCallbacks(StreamEncoderFilterCallbacks& callbacks) {
ASSERT(0 < pins_.load());
ASSERT(0 == encoderCallbacks_);
encoderCallbacks_ = &callbacks;
}
uint64_t GoHttpRouteSpecificFilterConfig::cgoTag(std::string filterName) const {
auto it = filters_.find(filterName);
if (it != filters_.cend()) {
return it->second;
}
return 0;
}
GoHttpRouteSpecificFilterConfig::~GoHttpRouteSpecificFilterConfig() { onDestroy_(); }
} // namespace Http
} // namespace Envoy | [
"bjorn.karge@grabtaxi.com"
] | bjorn.karge@grabtaxi.com |
57c34e867e800950d477cbc827608a73501842bb | 60bb67415a192d0c421719de7822c1819d5ba7ac | /blazemark/src/eigen/Mat6TMat6Mult.cpp | d18888b993db1dd43b646550224269a556b3da50 | [
"BSD-3-Clause"
] | permissive | rtohid/blaze | 48decd51395d912730add9bc0d19e617ecae8624 | 7852d9e22aeb89b907cb878c28d6ca75e5528431 | refs/heads/master | 2020-04-16T16:48:03.915504 | 2018-12-19T20:29:42 | 2018-12-19T20:29:42 | 165,750,036 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,630 | cpp | //=================================================================================================
/*!
// \file src/eigen/Mat6TMat6Mult.cpp
// \brief Source file for the Eigen 6D matrix/transpose matrix multiplication kernel
//
// Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD 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 names of the Blaze development group 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.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <iostream>
#include <vector>
#include <Eigen/Dense>
#include <blaze/util/Timing.h>
#include <blazemark/eigen/init/Matrix.h>
#include <blazemark/eigen/Mat6TMat6Mult.h>
#include <blazemark/system/Config.h>
namespace blazemark {
namespace eigen {
//=================================================================================================
//
// KERNEL FUNCTIONS
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Eigen uBLAS 6-dimensional matrix/transpose matrix multiplication kernel.
//
// \param N The number of 6x6 matrices to be computed.
// \param steps The number of iteration steps to perform.
// \return Minimum runtime of the kernel function.
//
// This kernel function implements the 6-dimensional matrix/transpose matrix multiplication by
// means of the Eigen functionality.
*/
double mat6tmat6mult( size_t N, size_t steps )
{
using ::blazemark::element_t;
using ::Eigen::Dynamic;
using ::Eigen::RowMajor;
using ::Eigen::ColMajor;
::blaze::setSeed( seed );
::std::vector< ::Eigen::Matrix<element_t,6,6,RowMajor> > A( N ), C( N );
::std::vector< ::Eigen::Matrix<element_t,6,6,ColMajor> > B( N );
::blaze::timing::WcTimer timer;
for( size_t i=0UL; i<N; ++i ) {
init( A[i] );
init( B[i] );
}
for( size_t i=0UL; i<N; ++i ) {
C[i].noalias() = A[i] * B[i];
}
for( size_t rep=0UL; rep<reps; ++rep )
{
timer.start();
for( size_t step=0UL, i=0UL; step<steps; ++step, ++i ) {
if( i == N ) i = 0UL;
C[i].noalias() = A[i] * B[i];
}
timer.end();
for( size_t i=0UL; i<N; ++i )
if( C[i](0,0) < element_t(0) )
std::cerr << " Line " << __LINE__ << ": ERROR detected!!!\n";
if( timer.last() > maxtime )
break;
}
const double minTime( timer.min() );
const double avgTime( timer.average() );
if( minTime * ( 1.0 + deviation*0.01 ) < avgTime )
std::cerr << " Eigen kernel 'mat6tmat6mult': Time deviation too large!!!\n";
return minTime;
}
//*************************************************************************************************
} // namespace eigen
} // namespace blazemark
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
27cd11695b7ba3a5d30364c5f88d49d19bb02587 | bcb8de142557f509b140b1ecab82d2ea09ab189c | /MPI2Send8.cpp | 143316c32cca99d746fd23368288f0e749d49c5f | [] | no_license | skyich/CS321 | 926c8c2e27f4feac98222b03891488eab49864ab | 055a63b03cf7be28e2429695ff8598e5f490bf9c | refs/heads/master | 2020-12-01T21:57:20.439214 | 2019-12-29T17:41:27 | 2019-12-29T17:41:27 | 230,783,049 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 570 | cpp | #include "pt4.h"
#include "mpi.h"
void Solve()
{
Task("MPI2Send8");
int flag;
MPI_Initialized(&flag);
if (flag == 0)
return;
int rank, size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank != 0) {
int x;
pt >> x;
if (x != 0)
MPI_Send(&x, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
}
else {
int x;
MPI_Status status;
MPI_Probe(MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &status);
MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &status);
pt << x;
pt << status.MPI_SOURCE;
}
}
| [
"pvoronezhsky@gmail.com"
] | pvoronezhsky@gmail.com |
3975a439c92b1c8cfc844e64cdb14cc612a6679b | 7f389855fd6dbd6a7a07533f8875aa79def25088 | /ARK2D/src/main.cpp | 4a99e6e73bd8430157f3c631b7ed4c837bb8d6f1 | [
"MIT"
] | permissive | galexcode/ark2d | 86db3354b5342adafba05e619b1aadec428e0138 | 1bb550b3f2d4dd21681d14402470f1e8aba9d20b | refs/heads/master | 2020-05-20T23:09:13.156142 | 2013-05-06T22:36:14 | 2013-05-06T22:36:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 210 | cpp | /*
* main.cpp
*
* Created on: 7 Jun 2011
* Author: Ashley
*/
#if defined(__AVM2__)
#include <AS3/AS3.h>
#endif
int main(int argc, char *argv[]) {
#if defined(__AVM2__)
#endif
return 0;
}
| [
"info@ashleygwinnell.co.uk"
] | info@ashleygwinnell.co.uk |
7c807e3c5a87103375d5509c19671785a6fe6a8a | 37481ac87b70de823ee39fb394a43ca74aec6566 | /ManagementSystem/zrsMFC.h | 654038dbbd165b2353cdecd829ddf2ef9e26eb0d | [] | no_license | NS-Tang/ManagementSystem | eb866fd47a1a1943094c2e3a532a1ee067caefdb | 21e3a939716721fc7a74bcf60f3006d6ace439eb | refs/heads/master | 2022-12-15T13:33:17.358725 | 2020-09-08T11:50:30 | 2020-09-08T11:50:30 | 292,990,161 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,442 | h | /**自己写的一些MFC中可用的类和函数.
* @file zrsMFC.h
* @author 张润生
*/
#pragma once
#ifndef ZRS_MFC
#define ZRS_MFC
#include "stdafx.h"
#include <vector>
#include <map>
#include "afxdialogex.h"
namespace zrs
{
namespace MFC
{
/**把用separator间隔的字符串分成arrayLength个子字符串.
* 分隔符只在字符串中间,不在开头和末尾,例如[substring0][separator][substring1][separator][substring2]
* @param separator [in] 分隔符
* @param string [in] 要分割的字符串
* @param substrings [out] 分割后的字符串组
*/
void DivideStringIntoSubstrings(_In_ CString separator, _In_ CString & string, _Out_ std::vector<CString>& substrings);
/**把arrayLength个子字符串连成用separator间隔的字符串.
* 分隔符只在字符串中间,不在开头和末尾,例如[substring0][separator][substring1][separator][substring2],不添加换行符
* @param separator [in] 分隔符
* @param string [out] 连接后的字符串
* @param substrings [in] 要连接的字符串组
*/
void ConcatenateSubstringsIntoString(_In_ CString separator, _Out_ CString & string, _In_ std::vector<CString>& substring);
/**从文件对象获取账户信息.
* @param file [in] 输入的文件对象
* @param acount [out] 输出的账户信息map
*/
void GetAcount(_In_ CStdioFile & file, _Out_ std::map<CString,CString>& acount);
/**取账户信息写入文件对象.
* @param file [out] 输出的文件对象
* @param acount [in] 输入的账户信息map
*/
void SetAcount(_Out_ CStdioFile & file, _In_ std::map<CString,CString>& acount);
/**点击列标题排序.
* 首先在资源中添加LVN_COLUMNCLICK消息*/
class SortingOnLvnColumnclickList
{
private:
CImageList m_ImageList;
static int m_sort_column;
static bool m_method;
private:
/**自己定义的排序函数.*/
static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
public:
/**增加上下箭头的图标.
* IDI_ICON1为下箭头,IDI_ICON2为上箭头
* OnInitDialog中调用
* @param list 要增加图标的List Control
*/
void AddIcon(CListCtrl& list);
/**点击列标题排序.
* OnLvnColumnclickList中调用
* @param sort_column 取值pNMLV->iSubItem
* @param list 要排序的List Control
*/
static void run(int sort_column, CListCtrl& list);
};
}
}
#endif /* ZRS_MFC */
| [
"13521060078@163.com"
] | 13521060078@163.com |
47a7826519acd98d3fc94162890661dcf98f6425 | 6a4b5b025ab5b39cdfc4ef92247c2f88b6260bf8 | /Queue.h | fe9ae40f3a8b078f5cf92fda739065b79f8b8da6 | [] | no_license | jungster-han/Doubly-Linked-List-in-Circle | 162b5e5bcbdf2f76abb155465ea569ffa2922b50 | 5e13380c23947999057466f9d4f9837c422d5bee | refs/heads/master | 2023-04-02T16:10:09.079033 | 2017-05-22T14:37:55 | 2017-05-22T14:37:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,427 | h | //-----------------------------------------------------------------------------
// File: Queue.h
//
// Class: Queue
//-----------------------------------------------------------------------------
#ifndef CQUEUE_H
#define CQUEUE_H
#include "List.h"
//-----------------------------------------------------------------------------
// Class: Queue
// Title: Queue Class
//
// Description: This file contains the class definition for Queue Class
// Queue is like a list but follows FIFO(first in first out)
//
// Programmer: Paul Bladek
// Han Jung
//
// Date: 5/4/2017
// Version: 1.0
// Enviornment: Intel i5-6600
// SoftWare: MS Window 10 Enterprise 64-bit(10.0, Build 14393)
// Compiles under Microsoft Visual C++.Net 2015
//
//
// class list:
// Properties:
// unsigned m_size -- number of elements in the list
//
// public:
// Queue() { CDLList<datatype>(); } -- default constructor
// Queue(size_t n_elements, datatype datum) -- with size and data
// Queue(const CDLList& myList) -- copy constructor
// Queue(iterator begin, iterator end) -- constructor with iterators
// virtual ~Queue() -- destructor
// bool empty() -- check if queue is empty
// void release() -- empties out queue
// unsigned getSize() const -- get the size of the queue
// iterator begin() const -- points to head of the queue
// iterator end() const -- points to tail of the queue
// void push(datatype datum) -- push data from the back
// datatype& pop() -- pop data from the front
//-----------------------------------------------------------------------------
using namespace HJ_ADT;
namespace HJ_QUEUE
{
template<typename datatype>
class Queue : virtual protected CDLList<datatype>
{
public:
Queue() { CDLList<datatype>(); }
Queue(size_t n_elements, datatype datum) { CDLList<datatype>
(n_elements, datum); };
Queue(const CDLList& myList) { CDLList<datatype>(myList); };
Queue(iterator begin, iterator end) {
CDLList<datatype>(begin, end); };
virtual ~Queue() { release(); }
bool empty() { return CDLList<datatype>::empty(); }
void release() { while (!empty()) { pop(); } }
unsigned getSize() const { return m_size; }
iterator begin() const { return head; }
iterator end() const { return tail; }
void push(datatype datum) {
CDLList<datatype>::push_back(datum); m_size++; }
datatype& pop() { m_size--; return CDLList<datatype>::pop_front(); }
private:
unsigned m_size;
};
//------------------------------------------------------------------------
// method: operator<<(ostream& sout, const
// Queue<datatype>& myList)
// description: returns contents of the queue to the ostream
// calls: end()
// begin()
// called by: main()
//
// parameters: ostream& sout -- stream to write to
// const Queue<datatype>& myList -- List of data
// returns: ostream&
// History Log:
// 5/21/2017 HJ completed version 1.0
// -----------------------------------------------------------------------
template<typename datatype>
ostream& operator<<(ostream& sout, const Queue<datatype>& myList) {
CDLList<datatype>::iterator p = myList.begin();
if (p == nullptr)
sout << "()";
else {
sout << "(";
while (p != myList.end())
{
sout << *p;
if (p != myList.end())
sout << ",";
++p; // advances iterator using next
}
sout << *myList.end();
sout << ")\n";
}
return sout;
}
}
#endif | [
"hsjungcr@gmail.com"
] | hsjungcr@gmail.com |
c17067eeb2756ddaef6c9079503e8c55abce0594 | f2347cf0cf3feb14bd84acdedebb4b1b790e3eac | /parser.cpp | c425116b31329268b36ac2384fc869638de0c755 | [
"MIT"
] | permissive | TusharRaturi/8085_Emulator | a39be66097369af843681faf4144e094525c527e | 9e950c0cb56474c8630b6c5fbb53a2c625f3f48c | refs/heads/master | 2023-09-03T22:46:03.939590 | 2023-08-19T07:32:16 | 2023-08-19T07:32:16 | 111,665,368 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,591 | cpp | #include "parser.h"
std::string outPlaceAppend(std::string a, std::string b)
{
return std::string().append(a).append(b);
}
void extractDelimited(TaggedSubtokens token[10], std::string s, std::string delimiter, int *out_length)
{
size_t pos = 0;
int i = 0;
while ((pos = s.find(delimiter)) != std::string::npos)
{
token[i++].value = s.substr(0, pos);
s.erase(0, pos + delimiter.length());
}
*out_length = i;
if(s.length() > 0)
{
if(s == delimiter)
return;
(*out_length)++;
token[i].value = s;
}
}
int strToInt(std::string n)
{
int tmp = 0;
int x = 0;
for(int i = 0; i < n.length(); i++)
{
if(!isdigit(n[i]))
{
error("Found Invalid Number/Integer");
return 0;
}
}
while(x < n.length())
{
int dig = n[x] - 48;
tmp = tmp * 10 + dig;
x++;
}
return tmp;
}
int makeSignedx16(int val)
{
return (0x8000&val ? (int)(0x7FFF&val)-0x8000 : val);
}
int makeSignedx8(int val)
{
return (0x80&val ? (int)(0x7F&val)-0x80 : val);
}
int strHexToDec(std::string in)
{
if(!(in.length() <= 4))
error("There was an error while Integer-Hex conversion. This is most probably a bug. Please contact the developer of this software.");
unsigned int x;
std::stringstream ss;
ss << std::hex << in;
ss >> x;
//std::cout << "LENGTH IS: " << in.length() <<" IN STR HEX TO DEC:" << x << std::endl;
return static_cast<int>(x);
}
int strHexToDecx8(std::string in)
{
/*unsigned int x;
stringstream ss;
ss << hex << in;
ss >> x;
return makeSignedx8(static_cast<int>(x));*/
return strHexToDec(in);
}
int strHexToDecx16(std::string in)
{
/*unsigned int x;
stringstream ss;
ss << hex << in;
ss >> x;
return makeSignedx16(static_cast<int>(x));*/
return strHexToDec(in);
}
std::string intToHex(int x, int digits1, int y, int digits2)
{
return outPlaceAppend(intToHex(x, digits1), intToHex(y, digits2));
}
std::string intToHex(int x, int digits)
{
std::stringstream stream;
stream << std::setfill('0') << std::setw(digits) << std::hex << x;
return stream.str();
}
std::string intToHex(int x)
{
std::stringstream stream;
stream << std::setfill('0') << std::setw(2) << std::hex << x;
return stream.str();
}
bool isHexDigit(char ch)
{
return isdigit(ch) || ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f';
}
bool parse(std::string in, std::string &in_op, TaggedSubtokens (&in_subTokens)[10], int &in_subTokenLength)
{
for(int i = 0; i < in.length(); i++)
{
if(!isalnum(in[i]) && in[i] != ' ' && in[i] != ',')
{
error(std::string("Illegal symbol: ").append(std::string(1, in[i])));
return false;
}
}
int i = 0;
TaggedSubtokens tokens[10];
int tokenLength = 0;
extractDelimited(tokens, in, " ", &tokenLength);
TaggedSubtokens subTokens[10];
int subTokenLength = 0;
extractDelimited(subTokens, tokens[1].value, ",", &subTokenLength);
if(isValidOperation(tokens[0].value, subTokens, subTokenLength))
{
in_op = tokens[0].value;
for(int i = 0; i < subTokenLength; i++)
in_subTokens[i] = subTokens[i];
in_subTokenLength = subTokenLength;
return true;
}
else
error(std::string("Instruction ").append(tokens[0].value).append(" is either wrong / wrongly written or undefined"));
return false;
}
template <typename T> std::string to_string(const T& n)
{
std::ostringstream strm;
strm << n;
return strm.str();
}
bool isXBitHex(std::string &in, int bits, std::string command)
{
int noOfBytes = bits / 8;
int numLength = bits / 4;
if(in.length() < 1 || in.length() > numLength)
{
error(std::string("Only ").append(to_string(noOfBytes)).append(std::string(" byte(s) of data can be used with ")).append(command).append(std::string(" which should be in the format: ")).append(std::string(noOfBytes == 1 ? "XX" : "XXXX")).append("(where each X is 0 to f in hex)"));
return false;
}
for(int i = 0; i < in.length(); i++)
if(!isHexDigit(in[i]))
{
error(std::string("Illegal Symbol: ") += in[i]);
error(std::string("Only ").append(to_string(noOfBytes)).append(std::string(" byte(s) of data can be used with ")).append(command).append(std::string(" which should be in the format: ")).append(std::string(noOfBytes == 1 ? "XX" : "XXXX")).append("(where each X is 0 to f in hex)"));
return false;
}
while(in.length() < numLength)
in.insert(0, "0");
return true;
}
bool isRegisterOrMemory(std::string in)
{
if(in == "a" || in == "b" || in == "c" || in == "d" || in == "e" || in == "h" || in == "l" || in == "m")
return true;
return false;
}
bool isRegPair(std::string in)
{
if(in == "b" || in == "d" || in == "h")
return true;
return false;
}
bool isValidOperation(std::string op, TaggedSubtokens (&subTokens)[10], int subTokenLength)
{
if(op == "mov")
{
if(subTokenLength != 2)
error("Wrong number of arguments.");
else
{
if(isRegisterOrMemory(subTokens[0].value))
{
if(isRegisterOrMemory(subTokens[1].value))
{
if(!(subTokens[0].value == "m" && subTokens[1].value == "m"))
{
subTokens[0].td = TD_STR;
subTokens[1].td = TD_STR;
return true;
}
else
error("Both cannot be memory");
}
else
expected("Register or memory in argument 2");
}
else
expected("Register or memory in argument 1");
}
}
else if(op == "mvi")
{
if(subTokenLength != 2)
error("Wrong number of arguments.");
else
{
if(isRegisterOrMemory(subTokens[0].value))
{
if(isXBitHex(subTokens[1].value, 8, op))
{
subTokens[0].td = TD_STR;
subTokens[1].td = TD_NUM;
return true;
}
}
else
expected("Register in argument 1");
}
}
else if(op == "lxi")
{
if(subTokenLength != 2)
error("Wrong number of arguments.");
else
{
if(isRegPair(subTokens[0].value))
{
if(isXBitHex(subTokens[1].value, 16, op))
{
subTokens[0].td = TD_STR;
subTokens[1].td = TD_BIG_NUM;
return true;
}
}
else
expected("Compatible register(pair) in argument 1");
}
}
else if(op == "lda")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "sta")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "lhld")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "shld")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "stax")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isRegPair(subTokens[0].value))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Valid Register");
}
}
else if(op == "xchg")
{
if(subTokenLength != 0)
error("Wrong number of arguments.");
else
return true;
}
//LOAD AND STORE---------------------------------
//ARITHMATIC-------------------------------------
else if(op == "add")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegisterOrMemory(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "adi")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 8, op))
{
subTokens[0].td = TD_NUM;
return true;
}
}
}
else if(op == "sub")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegisterOrMemory(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "inr")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegisterOrMemory(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "dcr")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegisterOrMemory(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "inx")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegPair(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "dcx")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegPair(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "dad")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegPair(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
else if(op == "sui")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 8, op))
{
subTokens[0].td = TD_NUM;
return true;
}
}
}
//ARITHMATIC-------------------------------------
//LOGICAL----------------------------------------
else if(op == "cma")
{
if(subTokenLength != 0)
error("Wrong number of arguments.");
else
return true;
}
else if(op == "cmp")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
std::string oper = subTokens[0].value;
if(isRegisterOrMemory(oper))
{
subTokens[0].td = TD_STR;
return true;
}
else
expected("Register or memory");
}
}
//LOGICAL----------------------------------------
//BRANCHING--------------------------------------
else if(op == "jmp")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "jc")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "jnc")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "jz")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
else if(op == "jnz")
{
if(subTokenLength != 1)
error("Wrong number of arguments.");
else
{
if(isXBitHex(subTokens[0].value, 16, op))
{
subTokens[0].td = TD_BIG_NUM;
return true;
}
}
}
//BRANCHING--------------------------------------
else if(op == "set")
{
if(subTokenLength != 2)
error("Wrong number of arguments.");
else if(isXBitHex(subTokens[0].value, 16, op))
{
if(isXBitHex(subTokens[1].value, 8, op))
{
subTokens[0].td = TD_BIG_NUM;
subTokens[1].td = TD_NUM;
return true;
}
}
}
else if(op == "hlt")
{
if(subTokenLength != 0)
error("Wrong number of arguments.");
else
return true;
}
return false;
}
std::string trim(char in[100])
{
int i = 0;
for(int i = 0; i < 100; i++)
{
if(in[i] == 10 || in[i] == 13 || in[i] == 15)
{
in[i] = (char)0;
break;
}
in[i] = tolower(in[i]);
}
return std::string(in);
}
| [
"usernameoftr@gmail.com"
] | usernameoftr@gmail.com |
ce1b28f21be12a8fd99f88e38bcf037909579b7c | 0dd97a2b3d9f2c8980b6134f582d6c0c56b1a6c4 | /CH16/BOGART/src/bogart.cpp | 5dfb15cc8d3edb820305489df593ff3a42888c05 | [
"MIT"
] | permissive | acastellanos95/AppCompPhys | 26a59d78750272621b3b9324c99ffebcbb93dc8b | 920a7ba707e92f1ef92fba9d97323863994f0b1a | refs/heads/master | 2020-07-25T12:40:16.362809 | 2019-09-13T15:48:41 | 2019-09-13T15:48:41 | 208,292,470 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,841 | cpp | #include "QatPlotWidgets/PlotView.h"
#include "QatPlotting/PlotHist1D.h"
#include "QatPlotting/PlotFunction1D.h"
#include "QatDataAnalysis/Hist1D.h"
#include "QatDataAnalysis/OptParse.h"
#include "QatGenericFunctions/ArgumentList.h"
#include "F2DViewerWidget.h"
#include "FourierCoefficientSet.h"
#include "FourierExpansion.h"
#include "DualFourierCoefficientSet.h"
#include "DualFourierExpansion.h"
#include "OrthogonalSeriesWidget.h"
#include <Inventor/Qt/SoQt.h>
#include <QApplication>
#include <QMainWindow>
#include <QToolBar>
#include <QAction>
#include <QPixmap>
#include <QImage>
#include <QLabel>
#include <cstdlib>
#include <iostream>
#include <string>
#include <random>
#include <complex>
#include "ImageFunction.h"
// Seems proper to use one random engine and
// make it global.
std::random_device dev;
std::mt19937 engine(dev());
// This routine samples a distribution using the throwaway
// method. It throws on the intervals [0,xmax], [0, ymax],
// and rejects on [0,zmax]. The number of points is determined
// by the size of the output vector argList, dimensioned before
// calling this routine.
void sampleDistribution (Genfun::GENFUNCTION function,
Genfun::ArgumentList & argList,
double xmax,
double ymax,
double zmax=1.0) {
std::uniform_real_distribution<double> uX(0,xmax), uY(0,ymax), uZ(0,zmax);
for (unsigned int i=0;i<argList.size();i++) {
while (1) {
Genfun::Argument arg(2); arg[0]=uX(engine); arg[1]=uY(engine);
if (uZ(engine) < function(arg)) {
argList[i]=arg;
break;
}
}
}
}
int main (int argc, char * * argv) {
// Automatically generated:-------------------------:
std::string usage= std::string("usage: ") + argv[0] + " [NPOINTS=val] [NMAX=val] [-f filename]";
unsigned int NPOINTS=10000;
unsigned int NMAX=5;
NumericInput input;
input.declare("NPOINTS", "Number of events", NPOINTS);
input.declare("NMAX", "Number of Fourier components", NMAX);
input.optParse(argc, argv);
NPOINTS = (unsigned int) (0.5 + input.getByName("NPOINTS"));
NMAX = (unsigned int) (0.5 + input.getByName("NMAX"));
std::string filename="bogart.jpg";
for (int i=1; i<argc;i++) {
if (std::string(argv[i])=="-f") {
i++;
filename=argv[i];
std::copy (argv+i+1, argv+argc, argv+i-1);
argc -=2;
i -=2;
}
}
if (argc!=1) {
std::cout << usage << std::endl;
}
QApplication app(argc,argv);
//
// We read in the image that will define a function ("ImageFunction")
//
Genfun::ImageFunction iFunction(filename);
int XMAX=iFunction.xmax();
int YMAX=iFunction.ymax();
//
// We sample this function
//
Genfun::ArgumentList aList(NPOINTS);
sampleDistribution (iFunction, aList, iFunction.xmax(), iFunction.ymax());
std::cout << "Sampling complete" << std::endl;
//
// Make some histograms
//
Hist1D hx("X", XMAX, 0, XMAX);
Hist1D hy("Y", YMAX, 0, YMAX);
for (unsigned int i=0;i<aList.size();i++) {
double x=aList[i][0],y=aList[i][1];
hx.accumulate(x);
hy.accumulate(y);
}
//
// Here we carry out the orthogonal series density estimation. In this
// demo it is done both in the joint PDF (x and y) and in both projections.
// (Alternately one could analyze the joint pdf and then project).
//
static const std::complex<double> I(0,1);
FourierCoefficientSet xCoefficients(NMAX),yCoefficients(NMAX);
DualFourierCoefficientSet xyCoefficients(NMAX,NMAX);
//
// X and Y projection
//
for (unsigned int i=0;i<aList.size();i++) {
double x=aList[i][0],y=aList[i][1];
std::complex<double> eX0=exp(I*(M_PI*x/XMAX)),eX1=conj(eX0), eX =pow(eX0,NMAX);
std::complex<double> eY0=exp(I*(M_PI*y/YMAX)),eY1=conj(eY0), eY =pow(eY0,NMAX);
for (int l1=-int(NMAX);l1<=int(NMAX);l1++) {
// Compute sums:
xCoefficients(l1) += sqrt(1.0/XMAX)/2.0 * eX; //exp(I*(-l1*M_PI*x/XMAX));
yCoefficients(l1) += sqrt(1.0/YMAX)/2.0 *eY; //exp(I*(-l1*M_PI*y/YMAX));
eX *= eX1;
eY *= eY1;
}
}
//
// XY Joint
//
for (unsigned int i=0;i<aList.size();i++) {
double x=aList[i][0],y=aList[i][1];
std::complex<double> eX0=exp(I*(M_PI*x/XMAX)),eX1=conj(eX0);
std::complex<double> eY0=exp(I*(M_PI*y/YMAX)),eY1=conj(eY0);
std::complex<double> eX =pow(eX0,NMAX);
for (int l1=-int(NMAX);l1<=int(NMAX);l1++) {
std::complex<double> eY =pow(eY0,NMAX);
for (int l2=-int(NMAX);l2<=int(NMAX);l2++) {
xyCoefficients(l1,l2) +=
1/(4.0*sqrt(XMAX)*sqrt(YMAX)) *
eX*eY;//exp(I*(-l1*M_PI*x/XMAX - l2*M_PI*y/YMAX));
eY*=eY1;
}
eX*=eX1;
}
}
//
// Reduce our sums to averages:
//
xCoefficients *= (1.0/NPOINTS);
yCoefficients *= (1.0/NPOINTS);
xyCoefficients *= (1.0/NPOINTS);
//
// Now we have coefficients of a double Fourier series and two simple
// Fourier series. Turn these into functions.
//
Genfun::FourierExpansion xFunction(xCoefficients,XMAX);
Genfun::FourierExpansion yFunction(yCoefficients,YMAX);
Genfun::DualFourierExpansion xyFunction(xyCoefficients,XMAX,YMAX);
Genfun::GENFUNCTION xyD=(XMAX*YMAX/2.0)*xyFunction;
std::cout << "Computation complete" << std::endl;
//
// Here we prepare to the graphics that we are going to plot:
//
PlotHist1D pHX=hx;
PlotHist1D pHY=hy;
PlotFunction1D pSX=NPOINTS*xFunction,pSY=NPOINTS*yFunction;
PlotFunction1D::Properties prop;
prop.pen.setWidth(3);
prop.pen.setColor("darkRed");
pSX.setProperties(prop);
pSY.setProperties(prop);
QGraphicsPixmapItem *pixItem[2]={new QGraphicsPixmapItem, new QGraphicsPixmapItem};;
for (int i=0;i<2;i++) {
pixItem[i]->setPixmap(*iFunction.pixmap());
pixItem[i]->setFlags(QGraphicsItem::ItemIsMovable);
pixItem[i]->setScale(0.1);
pixItem[i]->setPos(450,100);
}
//
// Here we plot the graphics in a custom widget and interact
//
{
SoQt::init("Orthogonal Series Density Estimation using Images");
OrthogonalSeriesWidget window;
window.getOriginal()->setSize(100, 0, XMAX, 100, 0, YMAX);
window.getOriginal()->setFunction(&iFunction);
window.getRealization()->setSize(100, 0, XMAX, 100, 0, YMAX);
for (unsigned int i=0;i<aList.size();i++) window.getRealization()->addPoint(aList[i][0],aList[i][1], 1);
window.getFit()->setSize(100, 0, XMAX, 100, 0, YMAX);
window.getFit()->setFunction(&xyD);
window.getXView()->setRect(pHX.rectHint());
window.getXView()->add(&pHX);
window.getXView()->add(&pSX);
window.getYView()->setRect(pHY.rectHint());
window.getYView()->add(&pHY);
window.getYView()->add(&pSY);
window.getXView()->scene()->addItem(pixItem[0]);
window.getYView()->scene()->addItem(pixItem[1]);
window.show();
app.exec();
}
return 0;
}
| [
"acastellanosaldama@gmail.com"
] | acastellanosaldama@gmail.com |
01b7287421d87c382d663383e6db5103fd53c85f | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5640146288377856_0/C++/ayon/A11.cpp | 6590b4fe7e6f5dc0f089769fcebd83235ad59ac3 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,082 | cpp | #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<assert.h>
#include<cmath>
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#include<limits.h>
using namespace std;
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define EPS 1e-9
#define asdf exit(0);
#define AB(a) ((a)<(0) ? (-(a)) : (a))
#define EQ(a,b) ( (fabs((a)-(b))<EPS) ? (1) : (0))
typedef long long LL;
//typedef __int64 LL;
int get(int n,int len)
{
int ret=(n/len);
if(n%len==0)
ret+=(len-1);
else ret+=len;
return ret;
}
int main()
{
freopen("A-small-attempt1.in","r",stdin);
freopen("A-small-attempt1.out","w",stdout);
int i,j,k,T,cs,n,m,len;
scanf("%d",&T);
for(cs=1;cs<=T;cs++)
{
printf("Case #%d: ",cs);
scanf("%d %d %d",&n,&m,&len);
int ans=(n-1)*(m/len);
if(m%len) ans+=(n-1);
printf("%d\n",ans+get(m,len));
}
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
9047465060334eca5f4fe6f83ed26cab7e2a2ce1 | df60444f7e6512ea2fe432b4023e9cf279d5c213 | /genesis/source/switch_block.cpp | 166ad722281e00fe7c40cd44409616d31ccf93af | [
"MIT"
] | permissive | SeadexGmbH/genesis | 2413f3edd354ccbfcda095f2eaee210e6b30057f | 2a84ccf3c60f19715f581275cbf440bde4f40108 | refs/heads/master | 2023-05-30T19:04:06.824597 | 2020-01-07T16:00:23 | 2023-05-10T09:21:56 | 88,970,361 | 3 | 0 | null | 2017-12-19T16:08:25 | 2017-04-21T10:01:02 | C++ | UTF-8 | C++ | false | false | 1,728 | cpp | // Copyright (c) 2017-, Seadex GmbH
// The Seadex GmbH licenses this file to you under the MIT license.
// The license file can be found in the license directory of this project.
// This file is part of the Seadex genesis library (http://genesis.seadex.de).
#include "switch_block.hpp"
#include "recipe_callback.hpp"
namespace sx
{
namespace genesis
{
switch_block::switch_block( const std::string& _switch_name ) :
recipe_block(),
switch_name_( _switch_name ),
current_case_index_(),
switch_cases_(),
default_()
{
// Nothing to do...
}
switch_block::~switch_block() noexcept
{
// Nothing to do...
}
void switch_block::create( recipe_callback& _recipe_callback, std::stringstream& _ostream, const int _indent )
{
current_case_index_ = _recipe_callback.get_switch_case( switch_name_ );
create_children( _recipe_callback, _ostream, _indent);
}
void switch_block::create_children( recipe_callback& _recipe_callback, std::stringstream& _ostream, const int _indent )
{
if( current_case_index_ >= 0 )
{
std::vector< std::unique_ptr<recipe_step> >& children_steps = switch_cases_[current_case_index_];
for(std::unique_ptr<recipe_step>& child : children_steps )
{
child->create( _recipe_callback, _ostream, _indent );
}
}
else
{
for( std::unique_ptr<recipe_step>& child : default_ )
{
child->create( _recipe_callback, _ostream, _indent );
}
}
}
void switch_block::add_child( std::unique_ptr<recipe_step>&& _child )
{
if( current_case_index_ >= 0 )
{
switch_cases_[current_case_index_].push_back( std::move( _child ) );
}
else
{
default_.push_back( std::move( _child ) );
}
}
void switch_block::set_case_index( const int _index )
{
current_case_index_ = _index;
}
}
}
| [
"tm@seadex.de"
] | tm@seadex.de |
410cd69565032df2e0a357520cb3af698b094a44 | 12ddfd65087bfad6223c58f89bd5549ea8f5be6c | /CCC/2015/Senior/greedy for pies.cpp | 73b02ea42866af0303f265dbeaf282cb9e33c4d9 | [] | no_license | BenRitmicoCode/Olympiad-Preparation | 285ef73fa812c4b230276fb082d407197124b2c4 | b09b2edcd4eb14ebb5fe356c577a61e6ac92eff2 | refs/heads/master | 2021-05-11T08:36:36.170277 | 2019-08-17T19:22:37 | 2019-08-17T19:22:37 | 118,057,369 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,680 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
const int MAXN = 3010;
int a[MAXN];
int dp[MAXN][110][110][3];
vector<int> b;
int rec(int i,int j,int k,int l){
// cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
if(dp[i][j][k][l]!=-1){
return dp[i][j][k][l];
}
if(i>=n && j>k){
return 0;
}
else if(i<n && j<=k && m!=0){
dp[i][j][k][l] = 0;
if(l){
dp[i][j][k][l] = max(rec(i+1,j,k,1-l),rec(i,j,k-1,1-l));
}else{
dp[i][j][k][l] = max(rec(i+1,j,k,l),max(a[i]+rec(i+1,j,k,1-l),b[j]+rec(i,j+1,k,1-l)));
}
return dp[i][j][k][l];
}
else if(i<n ||m==0){
dp[i][j][k][l] = 0;
if(l){
dp[i][j][k][l] = rec(i+1,j,k,1-l);
}else{
dp[i][j][k][l] = max(rec(i+1,j,k,l),a[i]+rec(i+1,j,k,1-l));
}
return dp[i][j][k][l];
}else{
dp[i][j][k][l] = 0;
if(l){
dp[i][j][k][l] = rec(i,j,k-1,1-l);
}else{
dp[i][j][k][l] = b[j]+rec(i,j+1,k,1-l);;
}
return dp[i][j][k][l];
}
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<=3000;i++){
for(int j=0;j<=101;j++){
for(int k=0;k<=101;k++){
for(int l=0;l<=2;l++){
dp[i][j][k][l] = -1;
}
}
}
}
cin>>m;
b.resize(m+2);
for(int j=1;j<=m;j++){
cin>>b[j];
}
sort(b.begin(),b.end());
reverse(b.begin()+1,b.end());
if(m == 0){
cout<<rec(0,0,0,0)<<endl;
return 0;
}
cout<<rec(0,1,m,0)<<endl;
}
| [
"noreply@github.com"
] | noreply@github.com |
8ac617d7ab2e68a18bdab403ec0b462a25866ece | 0ff5c3178e87a28a82165bfa908d9319cf7a2323 | /28. Codechef Problems/Point_Of_Impact.cpp | 02a07a4371aa6833710b09dfd48b7a45b16c81ed | [
"MIT"
] | permissive | SR-Sunny-Raj/Hacktoberfest2021-DSA | 40bf8385ed976fd81d27340514579b283c339c1f | 116526c093ed1ac7907483d001859df63c902cb3 | refs/heads/master | 2023-01-31T07:46:26.016367 | 2023-01-26T12:45:32 | 2023-01-26T12:45:32 | 262,236,251 | 261 | 963 | MIT | 2023-03-25T14:22:10 | 2020-05-08T05:36:07 | C++ | UTF-8 | C++ | false | false | 1,480 | cpp | // Problem Link: https://www.codechef.com/JAN21C/problems/BILLRD
#include <iostream>
using namespace std;
int main()
{
int t = 0;
cin >> t;
while (t >= 1)
{
int n = 0, c = 0, h = 0, k = 0;
cin >> n >> c >> h >> k;
if (h == k)
{
cout << n << " " << n << "\n";
}
else if ((n - k) > (n - h))
{
int hit_wall = c % 4;
int x=0,y=0;
switch (hit_wall)
{
case 1:
x=n;
y=n-h+k;
break;
case 2:
x=n-h+k;
y=n;
break;
case 3:
x=0;
y=h-k;
break;
case 0:
x=h-k;
y=0;
break;
}
cout << x << " " << y << "\n";
}
else
{
int hit_wall = c%4;
int x=0,y=0;
switch (hit_wall)
{
case 1:
x=n-k+h;
y=n;
break;
case 2:
x=n;
y=n-k+h;
break;
case 3:
x=k-h;
y=0;
break;
case 0:
x=0;
y=k-h;
break;
}
cout << x << " " << y << "\n";
}
t--;
}
return 0;
} | [
"anuragkushwaahan@gmail.com"
] | anuragkushwaahan@gmail.com |
6592bf74020b8171582e43475594d5b65f79f4fc | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/242/123/CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_42.cpp | bc771009dcd97a86b85f113e20705c6fc7a923f3 | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446957 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,177 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_42.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete_array.label.xml
Template File: sources-sinks-42.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: calloc Allocate data using calloc()
* GoodSource: Allocate data using new []
* Sinks:
* GoodSink: Deallocate data using free()
* BadSink : Deallocate data using delete []
* Flow Variant: 42 Data flow: data returned from one function to another in the same source file
*
* */
#include "std_testcase.h"
namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_42
{
#ifndef OMITBAD
static long * badSource(long * data)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (long *)calloc(100, sizeof(long));
if (data == NULL) {exit(-1);}
return data;
}
void bad()
{
long * data;
/* Initialize data*/
data = NULL;
data = badSource(data);
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete [] data;
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static long * goodG2BSource(long * data)
{
/* FIX: Allocate memory using new [] */
data = new long[100];
return data;
}
static void goodG2B()
{
long * data;
/* Initialize data*/
data = NULL;
data = goodG2BSource(data);
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete [] data;
}
/* goodB2G() uses the BadSource with the GoodSink */
static long * goodB2GSource(long * data)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (long *)calloc(100, sizeof(long));
if (data == NULL) {exit(-1);}
return data;
}
static void goodB2G()
{
long * data;
/* Initialize data*/
data = NULL;
data = goodB2GSource(data);
/* FIX: Free memory using free() */
free(data);
}
void good()
{
goodG2B();
goodB2G();
}
#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 CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_42; /* 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
| [
"frank@fischer.com.mt"
] | frank@fischer.com.mt |
5809492c19fa23a2669cbb0bbc66a146c63839f7 | 5ea17e38c6df158fea6c1a1ec6123791534f4888 | /STL list and vectors/SortedVector.h | 114f29e3ba13ef5d6f5909e70ff785c32f3a8716 | [] | no_license | anc15791/Data-Structures-and-algorithms-in-c- | b5e71e7212f75a392ea52c42b352d70fa9ff8df9 | bf6c7695ae2a825be621aaa98c5ba9ecc77a56f9 | refs/heads/master | 2021-01-22T01:42:44.305801 | 2018-02-12T02:23:41 | 2018-02-12T02:23:41 | 102,226,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 675 | h | #ifndef SORTEDVECTOR_H_
#define SORTEDVECTOR_H_
#include <vector>
#include <iterator>
#include "Node.h"
using namespace std;
/***** Modify this file if necessary. *****/
/**
* A sorted vector of Node objects.
*/
class SortedVector
{
public:
SortedVector();
virtual ~SortedVector();
int size() const;
bool check() const;
void prepend(const long value);
void append(const long value);
void remove(const int index);
void insert(const long value);
Node at(const int index) const;
vector<Node> get_vector()const;
void size_reserve(int size);
//void print();
private:
vector<Node> data;
};
#endif /* SORTEDVECTOR_H_ */
| [
"anc15791@gmail.com"
] | anc15791@gmail.com |
5bf02f7cf381af9ef8c26470d8298f5f0ceecf9a | a8ff19e442d726e48af3df97e0309332e63eb968 | /2_1-RemoveDuplicate.cpp | e3311c96e31d8e3052d2e13336ebbc9745cef86f | [] | no_license | homano/cracking_coding_interview_cpp | 3c7a4be946a338db1e11ee3675d93960430c819f | be5821d7fc8dd74a1db95840ab172adc7ae2d6c5 | refs/heads/master | 2020-05-27T11:08:29.938734 | 2014-06-22T23:33:16 | 2014-06-22T23:33:16 | 21,108,397 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,557 | cpp | //remove the duplicated elements in an unsorted linked list
// if a temporary buffer is no allowed, how would you solve this?
#include <iostream>
using namespace std;
typedef struct node
{
int data; // will store information
node *next; // the reference to the next node
} node ;
node* init(int a[], int n)
{
node *head, *p;
for (int i = 0; i < n; ++i)
{
node *nd = new node();
nd -> data = a[i];
if(i == 0)
{
head = p = nd;
}
else
{
p -> next = nd;
p = nd;
}
}
p -> next = NULL;
return head;
}
void RemoveDuplicate(node *head)
{
if(head == NULL) return;
bool hash[100] = {0};
node *previous = NULL, *n = head;
while(n != NULL)
{
int d = n->data;
if (hash[d])
{
previous -> next = n -> next;
n = previous -> next;
}
else
{
hash[d] = 1;
previous = n;
n = n -> next;
}
}
}
void RemoveDuplicate1(node* head)
{
if(head == NULL) return;
node *current = head, *runner = NULL;
while(current != NULL)
{
runner = current; // this is extremely important. you can set runner = current->next;
while(runner -> next != NULL)
{
if (runner -> next -> data == current -> data)
{
runner -> next = runner -> next -> next;
}
else
{
runner = runner -> next;
}
}
current = current -> next;
}
}
int main()
{
int a[14] = {1,2,3,4,5,6,7,8,9,10,2,3,5,16};
node *head = init(a, 14);
RemoveDuplicate(head);
while(head != NULL)
{
cout << head -> data << ' ';
head = head -> next;
}
cout << endl;
return 0;
} | [
"faogao@nat-oitwireless-inside-vapornet100-e-631.princeton.edu"
] | faogao@nat-oitwireless-inside-vapornet100-e-631.princeton.edu |
b249a9e52b9ec5a64228e01089c086b22a5546d9 | d17a0eedbaa0a33ddf7234e6e6f60fda63f78d87 | /jeff/day-15/part-1-dfs.cpp | 1a8cf512fc61663b324129bc28907f1c9832939b | [
"MIT"
] | permissive | jeffphi/advent-of-code-2018 | 9c18cb56ff33f0c72c03b06a32a6d449c9b21833 | 8e54bd23ebfe42fcbede315f0ab85db903551532 | refs/heads/master | 2020-04-08T00:44:20.617771 | 2018-12-30T19:23:38 | 2018-12-30T19:23:38 | 158,864,802 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,985 | cpp | #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include "jefflib.h"
#include <unordered_map>
#include <ncurses.h>
using namespace std;
enum UnitKind { elf, goblin };
enum CellKind { open, wall };
struct Unit {
UnitKind kind;
int hp = 200;
int pwr = 3;
bool hasMoved = false;
};
struct Cell {
CellKind kind;
Unit *pUnit = NULL;
};
#define ELF_PAIR 1
#define CYAN_PAIR 2
#define RED_PAIR 3
#define GOBLIN_PAIR 4
// Globals!
int current_best;
struct pair_hash {
template <class T1, class T2>
std::size_t operator () (const std::pair<T1,T2> &p) const {
auto h1 = std::hash<T1>{}(p.first);
auto h2 = std::hash<T2>{}(p.second);
// Mainly for demonstration purposes, i.e. works but is overly simple
// In the real world, use sth. like boost.hash_combine
return h1 ^ h2;
}
};
void printDebug(vector< vector<Cell> >& grid, string msg){
mvprintw(grid.size()+2, 0, msg.c_str());
}
void printCave(vector< vector<Cell> >& grid, int round){
clear();
for(int r = 0; r < grid.size(); r++){
stringstream rowStream;
for(int c = 0; c < grid[0].size(); c++){
if(grid[r][c].pUnit != NULL){
if(grid[r][c].pUnit->kind == elf) {
//attron(A_BOLD);
attron(COLOR_PAIR(ELF_PAIR));
mvaddch(r,c,'E');
attroff(COLOR_PAIR(ELF_PAIR));
//attroff(A_BOLD);
rowStream << "E(" << grid[r][c].pUnit->hp << ") ";
}
if(grid[r][c].pUnit->kind == goblin) {
attron(COLOR_PAIR(GOBLIN_PAIR));
mvaddch(r,c,'G');
attroff(COLOR_PAIR(GOBLIN_PAIR));
rowStream << "G(" << grid[r][c].pUnit->hp << ") ";
}
}
else{
if(grid[r][c].kind == open) mvaddch(r,c,'.');
if(grid[r][c].kind == wall) mvaddch(r,c,'#');
}
}
mvprintw(r, grid[0].size()+1, rowStream.str().c_str());
}
mvprintw(grid.size()+1, 0,"Number of Rounds: %d", round);
}
bool Done(vector< vector<Cell> >& grid, int rounds){
int numElves = 0;
int numGoblins = 0;
int totalHP = 0;
for(int r = 0; r < grid.size(); r++){
for(int c = 0; c < grid[0].size(); c++){
if(grid[r][c].pUnit != NULL){
if(grid[r][c].pUnit->kind == elf){
numElves++;
}
else{
numGoblins++;
}
totalHP += grid[r][c].pUnit->hp;
}
}
}
if(numElves == 0 || numGoblins == 0){
stringstream ss;
ss << "Done! Full rounds: " << rounds << ", Remaining HP: " << totalHP << ", Score: " << (rounds*totalHP);
printDebug(grid, ss.str());
return true;
}
return false;
}
void CheckIfDead(vector< vector<Cell> >& grid, int r, int c){
if(grid[r][c].pUnit->hp <= 0){
grid[r][c].pUnit = NULL;
}
}
bool AttackedEnemy(vector< vector<Cell> >& grid, int r, int c){
Unit *curUnit = grid[r][c].pUnit;
// Look around in reading order
if(grid[r-1][c].pUnit != NULL && grid[r-1][c].pUnit->kind != curUnit->kind){
grid[r-1][c].pUnit->hp -= curUnit->pwr;
CheckIfDead(grid, r-1, c);
return true;
}
if(grid[r][c-1].pUnit != NULL && grid[r][c-1].pUnit->kind != curUnit->kind){
grid[r][c-1].pUnit->hp -= curUnit->pwr;
CheckIfDead(grid, r, c-1);
return true;
}
if(grid[r][c+1].pUnit != NULL && grid[r][c+1].pUnit->kind != curUnit->kind){
grid[r][c+1].pUnit->hp -= curUnit->pwr;
CheckIfDead(grid, r, c+1);
return true;
}
if(grid[r+1][c].pUnit != NULL && grid[r+1][c].pUnit->kind != curUnit->kind){
grid[r+1][c].pUnit->hp -= curUnit->pwr;
CheckIfDead(grid, r+1, c);
return true;
}
return false;
}
void ClearMoved(vector< vector<Cell> >& grid){
for(int r = 0; r < grid.size(); r++){
for(int c = 0; c < grid[0].size(); c++){
if(grid[r][c].pUnit != NULL){
grid[r][c].pUnit->hasMoved = false;
}
}
}
}
int GetClosest(vector< vector<Cell> >& grid, UnitKind kind, int r, int c, unordered_map<pair<int,int>, int, pair_hash> list){
int maxRow = grid.size();
int maxCol = grid[0].size();
// Avoid excessive searching...
if(list.size() > current_best){
return INT_MAX;
}
// Check if this is a legit cell
if(grid[r][c].pUnit != NULL || grid[r][c].kind != open){
return INT_MAX;
}
//printCave(grid, -1);
//getch();
//printDebug(grid, ss.str());
//stringstream ss;
//ss << "Looking down: pUnit:"<<grid[r+1][c].pUnit<<", myKind:"<<kind;
//printDebug(grid, ss.str());
//getch();
/*
stringstream ss;
ss << "GetClosest r:"<<r<<" c:"<<c<<" count:"<<count;
printDebug(grid, ss.str());
getch();
*/
// If next to an ememy, done.
if(r>0 && grid[r-1][c].pUnit != NULL && grid[r-1][c].pUnit->kind != kind){
current_best = list.size();
return list.size();
}
if(c>0 && grid[r][c-1].pUnit != NULL && grid[r][c-1].pUnit->kind != kind){
current_best = list.size();
return list.size();
}
if(c<maxCol &&grid[r][c+1].pUnit != NULL && grid[r][c+1].pUnit->kind != kind){
current_best = list.size();
return list.size();
}
if(r<maxRow && grid[r+1][c].pUnit != NULL && grid[r+1][c].pUnit->kind != kind){
current_best = list.size();
return list.size();
}
// If we can move in a direction, return the lowest value...
int u = INT_MAX;
int l = INT_MAX;
int rt = INT_MAX;
int d = INT_MAX;
pair<int,int> tempPair = make_pair(r-1, c);
bool marked = list.find(tempPair) != list.end();
if(r>0 && grid[r-1][c].kind == open && grid[r-1][c].pUnit == NULL && !marked){
unordered_map<pair<int,int>, int, pair_hash> newList = list;
newList[make_pair(r-1,c)] = 0;
u = GetClosest(grid, kind, r-1, c, newList);
}
tempPair = make_pair(r, c-1);
marked = list.find(tempPair) != list.end();
if(c>0 &&grid[r][c-1].kind == open && grid[r][c-1].pUnit == NULL && !marked){
unordered_map<pair<int,int>, int, pair_hash> newList = list;
newList[make_pair(r,c-1)];
l = GetClosest(grid, kind, r, c-1, newList);
}
tempPair = make_pair(r, c+1);
marked = list.find(tempPair) != list.end();
if(c<maxCol && grid[r][c+1].kind == open && grid[r][c+1].pUnit == NULL && !marked){
unordered_map<pair<int,int>, int, pair_hash> newList = list;
newList[make_pair(r,c+1)];
rt = GetClosest(grid, kind, r, c+1, newList);
}
tempPair = make_pair(r+1, c);
marked = list.find(tempPair) != list.end();
if(r<maxRow && grid[r+1][c].kind == open && grid[r+1][c].pUnit == NULL && !marked){
unordered_map<pair<int,int>, int, pair_hash> newList = list;
newList[make_pair(r+1,c)];
d = GetClosest(grid, kind, r+1, c, newList);
}
// Return the lowest score
if(u<=rt && u<=l && u<=d) return u;
if(l<=rt && l<=d ) return l;
if(rt <= d) return rt;
return d;
}
bool Moved(vector< vector<Cell> >& grid, int r, int c, int& newRow, int& newCol){
/*
stringstream ss;
ss << "Moved...";
printDebug(grid, ss.str());
getch();
*/
Unit *curUnit = grid[r][c].pUnit;
curUnit->hasMoved = true;
UnitKind myKind = curUnit->kind;
unordered_map<pair<int,int>, int, pair_hash> upList;
upList[make_pair(r,c)] = 0;
unordered_map<pair<int,int>, int, pair_hash> leftList = upList;
unordered_map<pair<int,int>, int, pair_hash> rightList = leftList;
unordered_map<pair<int,int>, int, pair_hash> downList = rightList;
current_best = INT_MAX;
int distUp = GetClosest(grid, myKind, r-1, c, upList);
current_best = INT_MAX;
int distLeft = GetClosest(grid, myKind, r, c-1, leftList);
current_best = INT_MAX;
int distRight = GetClosest(grid, myKind, r, c+1, rightList);
current_best = INT_MAX;
int distDown = GetClosest(grid, myKind, r+1, c, downList);
//stringstream ss;
//ss << "In Moved: r: "<<r<<", c:"<<c<<" u: "<<distUp<<" l:"<<distLeft<<" r:"<<distRight<<" d:"<<distDown;
//printDebug(grid, ss.str());
//getch();
if(distUp <= distLeft && distUp <= distRight && distUp <= distDown && distUp < INT_MAX){
grid[r][c].pUnit = NULL;
grid[r-1][c].pUnit = curUnit;
newRow = r-1;
newCol = c;
return true;
}
else if(distLeft <= distRight && distLeft <= distDown && distLeft < INT_MAX){
grid[r][c].pUnit = NULL;
grid[r][c-1].pUnit = curUnit;
newRow = r;
newCol = c-1;
return true;
}
else if(distRight <= distDown && distRight < INT_MAX){
grid[r][c].pUnit = NULL;
grid[r][c+1].pUnit = curUnit;
newRow = r;
newCol = c+1;
return true;
}
else if(distDown < INT_MAX){
grid[r][c].pUnit = NULL;
grid[r+1][c].pUnit = curUnit;
newRow = r+1;
newCol = c;
return true;
}
return false;
}
int main()
{
vector<string> input;
if(GetStringInput(input)){
cout << "Got data!" << endl;
cout << endl;
}
else {
cout << "Failed to read input :( " << endl;
return -1;
}
initscr();
cbreak();
noecho();
curs_set(0);
start_color();
init_pair(ELF_PAIR, COLOR_YELLOW, COLOR_BLACK);
init_pair(CYAN_PAIR, COLOR_CYAN, COLOR_BLACK);
init_pair(RED_PAIR, COLOR_RED, COLOR_BLACK);
init_pair(GOBLIN_PAIR, COLOR_GREEN, COLOR_BLACK);
clear();
int numRows = input.size();
vector< vector<Cell> > grid;
for(int row = 0; row < numRows; row++){
vector<Cell> tempRow;
Cell tempCell;
string curRow = input[row];
for(int col = 0; col < curRow.size(); col++){
char s = curRow[col];
if(s == 'E'){
Unit* u = new Unit;
u->kind = elf;
u->hasMoved = false;
tempCell.pUnit = u;
tempCell.kind = open;
} else if(s == 'G'){
Unit* u = new Unit;
u->kind = goblin;
u->hasMoved = false;
tempCell.pUnit = u;
tempCell.kind = open;
} else if(s == '#'){
tempCell.pUnit = NULL;
tempCell.kind = wall;
} else if(s == '.'){
tempCell.pUnit = NULL;
tempCell.kind = open;
}
tempRow.push_back(tempCell);
}
grid.push_back(tempRow);
}
// Let the battle begin!
int numRounds = 0;
while(true){
printCave(grid, numRounds);
// Process each Unit in reading order
for(int r = 0; r < grid.size(); r++){
for(int c = 0; c < grid[0].size(); c++){
if(grid[r][c].pUnit != NULL){
// Are we right next to an enemy?
if(!grid[r][c].pUnit->hasMoved && AttackedEnemy(grid, r, c)){
continue;
}
// Otherwise, move and then try to attack
int newRow;
int newCol;
if(!grid[r][c].pUnit->hasMoved && Moved(grid, r, c, newRow, newCol)){
AttackedEnemy(grid, newRow, newCol);
}
}
}
}
numRounds++;
//if(getch() == 'q') break;
ClearMoved(grid);
if(Done(grid, numRounds-1)) break;
}
getch();
endwin();
return 0;
}
| [
"jeffphi@gmail.com"
] | jeffphi@gmail.com |
37fa501a707ed28b627a049b4c79fe2cd099340a | a7764174fb0351ea666faa9f3b5dfe304390a011 | /inc/TDF_ClosureMode.hxx | edbf2d8e49fca0cac52db57c5233d58aeab8e942 | [] | no_license | uel-dataexchange/Opencascade_uel | f7123943e9d8124f4fa67579e3cd3f85cfe52d91 | 06ec93d238d3e3ea2881ff44ba8c21cf870435cd | refs/heads/master | 2022-11-16T07:40:30.837854 | 2020-07-08T01:56:37 | 2020-07-08T01:56:37 | 276,290,778 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,312 | hxx | // This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#ifndef _TDF_ClosureMode_HeaderFile
#define _TDF_ClosureMode_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
//! This class provides options closure management. <br>
class TDF_ClosureMode {
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
//! Creates an objet with all modes set to <aMode>. <br>
Standard_EXPORT TDF_ClosureMode(const Standard_Boolean aMode = Standard_True);
//! Sets the mode "Descendants" to <aStatus>. <br>
//! <br>
//! "Descendants" mode means we add to the data set <br>
//! the children labels of each USER GIVEN label. We <br>
//! do not do that with the labels found applying <br>
//! UpToFirstLevel option. <br>
//! <br>
void Descendants(const Standard_Boolean aStatus) ;
//! Returns true if the mode "Descendants" is set. <br>
//! <br>
Standard_Boolean Descendants() const;
//! Sets the mode "References" to <aStatus>. <br>
//! <br>
//! "References" mode means we add to the data set <br>
//! the descendants of an attribute, by calling the <br>
//! attribute method Descendants(). <br>
//! <br>
void References(const Standard_Boolean aStatus) ;
//! Returns true if the mode "References" is set. <br>
//! <br>
Standard_Boolean References() const;
protected:
private:
Standard_Integer myFlags;
};
#include <TDF_ClosureMode.lxx>
// other Inline functions and methods (like "C++: function call" methods)
#endif
| [
"shoka.sho2@excel.co.jp"
] | shoka.sho2@excel.co.jp |
693b95ed3fd2b222c3d684331c5d09a673085d91 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc | e307242f8d392055d2eb92b39f7316a8d2b85fb3 | [
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webrtc",
"MIT",
"GPL-1.0-or-later",
"LicenseRef-scancode-takuya-ooura",
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference",
"MS-LPL",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"LGPL-2.0-or-later",
"Apa... | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 8,084 | cc | /*
* Copyright (c) 2013 The WebRTC 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 in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_WIN
#include <sys/types.h>
#include <unistd.h>
#endif
#include <algorithm>
#include <sstream>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/random.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
#include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h"
#include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
#include "webrtc/test/testsupport/fileutils.h"
using std::string;
namespace webrtc {
namespace testing {
namespace bwe {
// This test fixture is used to instantiate tests running with adaptive video
// senders.
class BweFeedbackTest
: public BweTest,
public ::testing::TestWithParam<BandwidthEstimatorType> {
public:
#ifdef WEBRTC_WIN
BweFeedbackTest()
: BweTest(), random_(Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
#else
BweFeedbackTest()
: BweTest(),
// Multiply the time by a random-ish odd number derived from the PID.
random_((getpid() | 1) *
Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
#endif
virtual ~BweFeedbackTest() {}
protected:
Random random_;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(BweFeedbackTest);
};
INSTANTIATE_TEST_CASE_P(VideoSendersTest,
BweFeedbackTest,
::testing::Values(kRembEstimator,
kFullSendSideEstimator));
TEST_P(BweFeedbackTest, ConstantCapacity) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);
PacedVideoSender sender(&uplink_, &source, GetParam());
ChokeFilter filter(&uplink_, 0);
RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
const int kCapacityKbps = 1000;
filter.set_capacity_kbps(kCapacityKbps);
filter.set_max_delay_ms(500);
RunFor(180 * 1000);
PrintResults(kCapacityKbps, counter.GetBitrateStats(), 0,
receiver.GetDelayStats(), counter.GetBitrateStats());
}
TEST_P(BweFeedbackTest, Choke1000kbps500kbps1000kbps) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);
PacedVideoSender sender(&uplink_, &source, GetParam());
ChokeFilter filter(&uplink_, 0);
RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
const int kHighCapacityKbps = 1000;
const int kLowCapacityKbps = 500;
filter.set_capacity_kbps(kHighCapacityKbps);
filter.set_max_delay_ms(500);
RunFor(60 * 1000);
filter.set_capacity_kbps(kLowCapacityKbps);
RunFor(60 * 1000);
filter.set_capacity_kbps(kHighCapacityKbps);
RunFor(60 * 1000);
PrintResults((2 * kHighCapacityKbps + kLowCapacityKbps) / 3.0,
counter.GetBitrateStats(), 0, receiver.GetDelayStats(),
counter.GetBitrateStats());
}
TEST_P(BweFeedbackTest, Choke200kbps30kbps200kbps) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);
PacedVideoSender sender(&uplink_, &source, GetParam());
ChokeFilter filter(&uplink_, 0);
RateCounterFilter counter(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
const int kHighCapacityKbps = 200;
const int kLowCapacityKbps = 30;
filter.set_capacity_kbps(kHighCapacityKbps);
filter.set_max_delay_ms(500);
RunFor(60 * 1000);
filter.set_capacity_kbps(kLowCapacityKbps);
RunFor(60 * 1000);
filter.set_capacity_kbps(kHighCapacityKbps);
RunFor(60 * 1000);
PrintResults((2 * kHighCapacityKbps + kLowCapacityKbps) / 3.0,
counter.GetBitrateStats(), 0, receiver.GetDelayStats(),
counter.GetBitrateStats());
}
TEST_P(BweFeedbackTest, Verizon4gDownlinkTest) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);
VideoSender sender(&uplink_, &source, GetParam());
RateCounterFilter counter1(&uplink_, 0, "sender_output",
bwe_names[GetParam()]);
TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
RunFor(22 * 60 * 1000);
PrintResults(filter.GetBitrateStats().GetMean(), counter2.GetBitrateStats(),
0, receiver.GetDelayStats(), counter2.GetBitrateStats());
}
// webrtc:3277
TEST_P(BweFeedbackTest, GoogleWifiTrace3Mbps) {
AdaptiveVideoSource source(0, 30, 300, 0, 0);
VideoSender sender(&uplink_, &source, GetParam());
RateCounterFilter counter1(&uplink_, 0, "sender_output",
bwe_names[GetParam()]);
TraceBasedDeliveryFilter filter(&uplink_, 0, "link_capacity");
filter.set_max_delay_ms(500);
RateCounterFilter counter2(&uplink_, 0, "Receiver", bwe_names[GetParam()]);
PacketReceiver receiver(&uplink_, 0, GetParam(), false, false);
ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
RunFor(300 * 1000);
PrintResults(filter.GetBitrateStats().GetMean(), counter2.GetBitrateStats(),
0, receiver.GetDelayStats(), counter2.GetBitrateStats());
}
TEST_P(BweFeedbackTest, PacedSelfFairness50msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 50, kRttMs,
kMaxJitterMs, offset_ms);
}
TEST_P(BweFeedbackTest, PacedSelfFairness500msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 500, kRttMs,
kMaxJitterMs, offset_ms);
}
TEST_P(BweFeedbackTest, PacedSelfFairness1000msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 1000, kRttMs,
kMaxJitterMs, offset_ms);
}
TEST_P(BweFeedbackTest, TcpFairness50msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 50, kRttMs, kMaxJitterMs,
offset_ms);
}
TEST_P(BweFeedbackTest, TcpFairness500msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 500, kRttMs, kMaxJitterMs,
offset_ms);
}
TEST_P(BweFeedbackTest, TcpFairness1000msTest) {
int64_t kRttMs = 100;
int64_t kMaxJitterMs = 15;
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 1000, kRttMs, kMaxJitterMs,
offset_ms);
}
} // namespace bwe
} // namespace testing
} // namespace webrtc
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
778ef6d810cb361551f1114023bcd424d5936d11 | 4c6ebdc4b6af073298c72698558b36b2cfa990d5 | /AulasLogicaFatec/ex14Porcentagem.cpp | 01c00071c29f703b8cb7786eba1f916ff4ec65fb | [
"MIT"
] | permissive | jonfisik/LogicaFatec | 0153a59dff4ea43c0809d1a0c993cb83fab2a7f0 | fb37d7f77c251154471b7db56eb1b57bf83bf3f2 | refs/heads/main | 2023-08-01T12:57:15.168443 | 2021-09-14T20:48:12 | 2021-09-14T20:48:12 | 350,490,645 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 550 | cpp | #include<stdio.h>
main(){
float caixa, quantidade, preco;
float valorCompra, limite, valorPagar;
printf("Qual o valor em caixa? R$ ");
scanf("%f", &caixa);
printf("Qual a quantidade? R$ ");
scanf("%f", &quantidade);
printf("Qual o preco? R$ ");
scanf("%f", &preco);
valorCompra = quantidade * preco;
limite = caixa * 0.8;
if(valorCompra > limite){
valorPagar = valorCompra * 1.10;
printf("Compra a prazo R$ %f.", valorPagar);
}else{
valorPagar = valorCompra * 0.95;
printf("Compra a vista R$ %f.", valorPagar);
}
}
| [
"development.wj@outlook.com"
] | development.wj@outlook.com |
99c0aaf36ace73e7ed7e9446676bc50ff68b2300 | 1da4db7a70f2a49e2534225f152ae52093d15e04 | /libraries/chain/include/graphene/chain/db_with.hpp | 349c3fa30a22bfca03c20ee2fcc6f7a7577e9f49 | [
"MIT"
] | permissive | JWOCC/core | 04a13b90b071b2e3f5adda17ef70207a9e3f4271 | 590c3cc7156a37494a501bb3852fbdb17fc56655 | refs/heads/master | 2023-04-12T21:48:32.369136 | 2021-04-19T04:04:49 | 2021-04-19T04:04:49 | 359,304,629 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,392 | hpp | /*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT 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.
*/
#pragma once
#include <graphene/chain/database.hpp>
#include <iostream>
/*
* This file provides with() functions which modify the database
* temporarily, then restore it. These functions are mostly internal
* implementation detail of the database.
*
* Essentially, we want to be able to use "finally" to restore the
* database regardless of whether an exception is thrown or not, but there
* is no "finally" in C++. Instead, C++ requires us to create a struct
* and put the finally block in a destructor. Aagh!
*/
namespace graphene { namespace chain { namespace detail {
/**
* Class used to help the with_skip_flags implementation.
* It must be defined in this header because it must be
* available to the with_skip_flags implementation,
* which is a template and therefore must also be defined
* in this header.
*/
struct skip_flags_restorer
{
skip_flags_restorer( node_property_object& npo, uint32_t old_skip_flags )
: _npo( npo ), _old_skip_flags( old_skip_flags )
{}
~skip_flags_restorer()
{
_npo.skip_flags = _old_skip_flags;
}
node_property_object& _npo;
uint32_t _old_skip_flags; // initialized in ctor
};
/**
* Class used to help the without_pending_transactions
* implementation.
*
* TODO: Change the name of this class to better reflect the fact
* that it restores popped transactions as well as pending transactions.
*/
struct pending_transactions_restorer
{
pending_transactions_restorer( database& db, std::vector<processed_transaction>&& pending_transactions )
: _db(db), _pending_transactions( std::move(pending_transactions) )
{
_db.clear_pending();
_db._push_transaction_tx_ids.clear();
}
~pending_transactions_restorer()
{
for( const auto& tx : _db._popped_tx )
{
try {
if(_db._push_transaction_tx_ids.count( tx.id()) == 0 ){
// if( !_db.is_known_transaction( tx.id() ) ) {
// since push_transaction() takes a signed_transaction,
// the operation_results field will be ignored.
_db.push_transaction(tx,_db.get_node_properties().skip_flags|database::validation_steps::skip_contract_exec);
//_db._push_transaction( tx );
}
} catch ( const fc::exception& ) {
}
}
_db.broad_trxs(_db._popped_tx);
_db._popped_tx.clear();
for( const processed_transaction& tx : _pending_transactions )
{
try
{
if( !_db.is_known_transaction( tx.id() ) ) {
// since push_transaction() takes a signed_transaction,
// the operation_results field will be ignored.
//_db._push_transaction( tx );
_db.push_transaction(tx, _db.get_node_properties().skip_flags | database::validation_steps::skip_contract_exec);
}
}
catch( const fc::exception& e )
{
/*
wlog( "Pending transaction became invalid after switching to block ${b} ${t}", ("b", _db.head_block_id())("t",_db.head_block_time()) );
wlog( "The invalid pending transaction caused exception ${e}", ("e", e.to_detail_string() ) );
*/
}
}
}
database& _db;
std::vector< processed_transaction > _pending_transactions;
};
/**
* Set the skip_flags to the given value, call callback,
* then reset skip_flags to their previous value after
* callback is done.
*/
template< typename Lambda >
void with_skip_flags(
database& db,
uint32_t skip_flags,
Lambda callback )
{
node_property_object& npo = db.node_properties();
skip_flags_restorer restorer( npo, npo.skip_flags );
npo.skip_flags = skip_flags;
callback();
return;
}
/**
* Empty pending_transactions, call callback,
* then reset pending_transactions after callback is done.
*
* Pending transactions which no longer validate will be culled.
*/
template< typename Lambda >
void without_pending_transactions(
database& db,
std::vector<processed_transaction>&& pending_transactions,
Lambda callback )
{
pending_transactions_restorer restorer( db, std::move(pending_transactions) );
callback();
return;
}
} } } // graphene::chain::detail
| [
"leadswap@protonmail.com"
] | leadswap@protonmail.com |
ed0dadb7a365aeab4a56afc5a546b2c81311b39d | 7b9c471c211e72c284798947e6bcea5dd8c3ff20 | /src/TicTacGame.cpp | 11311bb654793a6271fcb0c0aa37b01b97374552 | [] | no_license | lymanZerga11/tictactoe | 6dbd3ba8d3e48f294d8abe2562ae0a9b53578bdd | 2d3f833672f02b32d2fa034823688d6dad1f0043 | refs/heads/master | 2021-03-24T11:03:39.887590 | 2018-02-26T03:18:18 | 2018-02-26T03:18:18 | 122,820,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,491 | cpp | #include "TicTacGame.h"
#include "constants.h"
#include <iomanip>
bool TicTacGame::is_valid (int i, int j) {
return i >= 0 && j >=0 && i < matrix.size() && j < matrix.size();
}
void TicTacGame::init () {
std::cout << "Enter name for Player 1:" << std::endl;
std::getline (std::cin, player_names[0]);
std::cout << "Enter name for Player 2:" << std::endl;
std::getline (std::cin, player_names[1]);
}
bool TicTacGame::fill_cell (int i, int j, int player) {
if (is_valid(i, j) && matrix[i][j] != PLAYER_MATRIX_CODE[0] && matrix[i][j] != PLAYER_MATRIX_CODE[1])
matrix[i][j] = PLAYER_MATRIX_CODE[player];
else
return false;
return true;
}
bool TicTacGame::check_win (int x, int y, int player) {
bool win = true;
for (auto &POSITION_GENERATOR : POSITION_GENERATORS) {
for (int i=0; i<POSITION_GENERATOR.size(); i++) {
win = true;
for (int j=0; j<TIC_SIZE; j++) {
int x_pos = POSITION_GENERATOR[i][j][0] + x;
int y_pos = POSITION_GENERATOR[i][j][1] + y;
if (!is_valid (x_pos, y_pos) || matrix[x_pos][y_pos] != PLAYER_MATRIX_CODE[player]) win = false;
}
if (win) return true;
}
}
return false;
}
TicTacGame::TicTacGame (const int N) : current_turn(0), finished(false), turns_left(N*N-1) {
for (int i=0; i<N; i++) {
matrix.push_back (std::vector<int> (N, 0));
for (int j=0; j<N; j++) {
matrix[i][j] = (i * N) + j + 1;
}
}
}
const std::string & TicTacGame::player_name (int player) const {
return player_names[player];
}
const std::string & TicTacGame::win_message (int player) const {
std::string str = "Congratulations " + player_names[player] + "! You have won.\n";
return std::move(str);
}
const std::string & TicTacGame::request_message (int player) const {
std::string str = player_names[player] + ", choose a box to place an '" + PLAYER_SYMBOL [player] + "' into: \n";
return std::move(str);
}
void TicTacGame::pretty_print (std::ostream & os) const {
int i=0,j=0;
for (i=0; i<matrix.size(); i++) {
for (j=0; j<matrix.size()-1; j++) {
if (matrix[i][j] >= 0)
os << " " << std::left << std::setfill(' ') << std::setw(3) << matrix[i][j] << " " << "|";
else os << " " << std::left << std::setfill(' ') << std::setw(3) << PLAYER_CODE_TO_SYMBOL [matrix[i][j]] << " " << "|";
}
if (matrix[i][j] >= 0)
os << " " << std::left << std::setfill(' ') << std::setw(3) << matrix[i][j] << " " << std::endl;
else os << " " << std::left << std::setfill(' ') << std::setw(3) << PLAYER_CODE_TO_SYMBOL [matrix[i][j]] << " " << std::endl;
os << "---------------------------" << std::endl;
}
}
void TicTacGame::play_next_turn () {
int position = -1;
std::cout << request_message (current_turn);
std::string number_string;
std::getline (std::cin, number_string);
position = std::stoi (number_string);
int i = (position - 1) / matrix.size();
int j = (position - 1) % matrix.size();
if (!fill_cell (i, j, current_turn)) {
current_turn = 1 - current_turn;
std::cerr << "Invalid position" << std::endl;
++turns_left;
}
if (check_win (i, j, current_turn)) {
pretty_print (std::cout);
std::cout << win_message (current_turn);
finished = true;
}
std::cout << turns_left <<std::endl;
if (turns_left <= 0) {
pretty_print (std::cout);
std::cout << "Game Over! It's a tie" << std::endl;
finished = true;
}
--turns_left;
current_turn = 1 - current_turn;
}
| [
"jacobsunny@Jacobs-MacBook-Pro.local"
] | jacobsunny@Jacobs-MacBook-Pro.local |
72c70ff896eb9cd613ed27d65c5fba151ee28799 | 89dedd7f3c7acc81d12e2bcb2e716f9af9e5fa04 | /net/tools/quic/quic_dispatcher.h | 33d8777d3afef6df56f991c733ea48b1c1a0fd7c | [
"BSD-3-Clause"
] | permissive | bino7/chromium | 8d26f84a1b6e38a73d1b97fea6057c634eff68cb | 4666a6bb6fdcb1114afecf77bdaa239d9787b752 | refs/heads/master | 2022-12-22T14:31:53.913081 | 2016-09-06T10:05:11 | 2016-09-06T10:05:11 | 67,410,510 | 1 | 3 | BSD-3-Clause | 2022-12-17T03:08:52 | 2016-09-05T10:11:59 | null | UTF-8 | C++ | false | false | 14,479 | h | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A server side dispatcher which dispatches a given client's data to their
// stream.
#ifndef NET_TOOLS_QUIC_QUIC_DISPATCHER_H_
#define NET_TOOLS_QUIC_QUIC_DISPATCHER_H_
#include <memory>
#include <unordered_map>
#include <vector>
#include "base/macros.h"
#include "net/base/ip_endpoint.h"
#include "net/base/linked_hash_map.h"
#include "net/quic/core/crypto/quic_compressed_certs_cache.h"
#include "net/quic/core/crypto/quic_random.h"
#include "net/quic/core/quic_blocked_writer_interface.h"
#include "net/quic/core/quic_buffered_packet_store.h"
#include "net/quic/core/quic_connection.h"
#include "net/quic/core/quic_protocol.h"
#include "net/quic/core/quic_server_session_base.h"
#include "net/tools/quic/quic_process_packet_interface.h"
#include "net/tools/quic/quic_time_wait_list_manager.h"
namespace net {
class QuicConfig;
class QuicCryptoServerConfig;
class QuicServerSessionBase;
namespace test {
class QuicDispatcherPeer;
} // namespace test
class QuicDispatcher : public QuicServerSessionBase::Visitor,
public ProcessPacketInterface,
public QuicBlockedWriterInterface,
public QuicFramerVisitorInterface,
public QuicBufferedPacketStore::VisitorInterface {
public:
// Ideally we'd have a linked_hash_set: the boolean is unused.
typedef linked_hash_map<QuicBlockedWriterInterface*,
bool,
QuicBlockedWriterInterfacePtrHash>
WriteBlockedList;
QuicDispatcher(const QuicConfig& config,
const QuicCryptoServerConfig* crypto_config,
QuicVersionManager* version_manager,
std::unique_ptr<QuicConnectionHelperInterface> helper,
std::unique_ptr<QuicServerSessionBase::Helper> session_helper,
std::unique_ptr<QuicAlarmFactory> alarm_factory);
~QuicDispatcher() override;
// Takes ownership of |writer|.
void InitializeWithWriter(QuicPacketWriter* writer);
// Process the incoming packet by creating a new session, passing it to
// an existing session, or passing it to the time wait list.
void ProcessPacket(const IPEndPoint& server_address,
const IPEndPoint& client_address,
const QuicReceivedPacket& packet) override;
// Called when the socket becomes writable to allow queued writes to happen.
void OnCanWrite() override;
// Returns true if there's anything in the blocked writer list.
virtual bool HasPendingWrites() const;
// Sends ConnectionClose frames to all connected clients.
void Shutdown();
// QuicServerSessionBase::Visitor interface implementation:
// Ensure that the closed connection is cleaned up asynchronously.
void OnConnectionClosed(QuicConnectionId connection_id,
QuicErrorCode error,
const std::string& error_details) override;
// Queues the blocked writer for later resumption.
void OnWriteBlocked(QuicBlockedWriterInterface* blocked_writer) override;
// Called whenever the time wait list manager adds a new connection to the
// time-wait list.
void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override;
typedef std::unordered_map<QuicConnectionId, QuicServerSessionBase*>
SessionMap;
const SessionMap& session_map() const { return session_map_; }
// Deletes all sessions on the closed session list and clears the list.
virtual void DeleteSessions();
// The largest packet number we expect to receive with a connection
// ID for a connection that is not established yet. The current design will
// send a handshake and then up to 50 or so data packets, and then it may
// resend the handshake packet up to 10 times. (Retransmitted packets are
// sent with unique packet numbers.)
static const QuicPacketNumber kMaxReasonableInitialPacketNumber = 100;
static_assert(kMaxReasonableInitialPacketNumber >=
kInitialCongestionWindow + 10,
"kMaxReasonableInitialPacketNumber is unreasonably small "
"relative to kInitialCongestionWindow.");
// QuicFramerVisitorInterface implementation. Not expected to be called
// outside of this class.
void OnPacket() override;
// Called when the public header has been parsed.
bool OnUnauthenticatedPublicHeader(
const QuicPacketPublicHeader& header) override;
// Called when the private header has been parsed of a data packet that is
// destined for the time wait manager.
bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override;
void OnError(QuicFramer* framer) override;
bool OnProtocolVersionMismatch(QuicVersion received_version) override;
// The following methods should never get called because
// OnUnauthenticatedPublicHeader() or OnUnauthenticatedHeader() (whichever
// was called last), will return false and prevent a subsequent invocation
// of these methods. Thus, the payload of the packet is never processed in
// the dispatcher.
void OnPublicResetPacket(const QuicPublicResetPacket& packet) override;
void OnVersionNegotiationPacket(
const QuicVersionNegotiationPacket& packet) override;
void OnDecryptedPacket(EncryptionLevel level) override;
bool OnPacketHeader(const QuicPacketHeader& header) override;
bool OnStreamFrame(const QuicStreamFrame& frame) override;
bool OnAckFrame(const QuicAckFrame& frame) override;
bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override;
bool OnPaddingFrame(const QuicPaddingFrame& frame) override;
bool OnPingFrame(const QuicPingFrame& frame) override;
bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override;
bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override;
bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override;
bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
bool OnBlockedFrame(const QuicBlockedFrame& frame) override;
bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override;
void OnPacketComplete() override;
// QuicBufferedPacketStore::VisitorInterface implementation.
void OnExpiredPackets(QuicConnectionId connection_id,
QuicBufferedPacketStore::BufferedPacketList
early_arrived_packets) override;
// Create connections for previously buffered CHLOs as many as allowed.
virtual void ProcessBufferedChlos(size_t max_connections_to_create);
// Return true if there is CHLO buffered.
virtual bool HasChlosBuffered() const;
protected:
virtual QuicServerSessionBase* CreateQuicSession(
QuicConnectionId connection_id,
const IPEndPoint& client_address) = 0;
// Called when a connection is rejected statelessly.
virtual void OnConnectionRejectedStatelessly();
// Called when a connection is closed statelessly.
virtual void OnConnectionClosedStatelessly(QuicErrorCode error);
// Returns true if cheap stateless rejection should be attempted.
virtual bool ShouldAttemptCheapStatelessRejection();
// Values to be returned by ValidityChecks() to indicate what should be done
// with a packet. Fates with greater values are considered to be higher
// priority, in that if one validity check indicates a lower-valued fate and
// another validity check indicates a higher-valued fate, the higher-valued
// fate should be obeyed.
enum QuicPacketFate {
// Process the packet normally, which is usually to establish a connection.
kFateProcess,
// Put the connection ID into time-wait state and send a public reset.
kFateTimeWait,
// Buffer the packet.
kFateBuffer,
// Drop the packet (ignore and give no response).
kFateDrop,
};
// This method is called by OnUnauthenticatedHeader on packets not associated
// with a known connection ID. It applies validity checks and returns a
// QuicPacketFate to tell what should be done with the packet.
virtual QuicPacketFate ValidityChecks(const QuicPacketHeader& header);
// Create and return the time wait list manager for this dispatcher, which
// will be owned by the dispatcher as time_wait_list_manager_
virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager();
// Called when |current_packet_| is a data packet that has arrived before
// the CHLO. Buffers the current packet until the CHLO arrives.
void BufferEarlyPacket(QuicConnectionId connection_id);
// Called when |current_packet_| is a CHLO packet. Creates a new connection
// and delivers any buffered packets for that connection id.
void ProcessChlo();
QuicTimeWaitListManager* time_wait_list_manager() {
return time_wait_list_manager_.get();
}
const QuicVersionVector& GetSupportedVersions();
QuicConnectionId current_connection_id() { return current_connection_id_; }
const IPEndPoint& current_server_address() { return current_server_address_; }
const IPEndPoint& current_client_address() { return current_client_address_; }
const QuicReceivedPacket& current_packet() { return *current_packet_; }
const QuicConfig& config() const { return config_; }
const QuicCryptoServerConfig* crypto_config() const { return crypto_config_; }
QuicCompressedCertsCache* compressed_certs_cache() {
return &compressed_certs_cache_;
}
QuicFramer* framer() { return &framer_; }
QuicConnectionHelperInterface* helper() { return helper_.get(); }
QuicServerSessionBase::Helper* session_helper() {
return session_helper_.get();
}
QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); }
QuicPacketWriter* writer() { return writer_.get(); }
// Creates per-connection packet writers out of the QuicDispatcher's shared
// QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must
// always be the same as the shared writer's IsWriteBlocked(), or else the
// QuicDispatcher::OnCanWrite logic will not work. (This will hopefully be
// cleaned up for bug 16950226.)
virtual QuicPacketWriter* CreatePerConnectionWriter();
// Returns true if a session should be created for a connection with an
// unknown version identified by |version_tag|.
virtual bool ShouldCreateSessionForUnknownVersion(QuicTag version_tag);
void SetLastError(QuicErrorCode error);
// Called when the public header has been parsed and the session has been
// looked up, and the session was not found in the active list of sessions.
// Returns false if processing should stop after this call.
virtual bool OnUnauthenticatedUnknownPublicHeader(
const QuicPacketPublicHeader& header);
// Called when a new connection starts to be handled by this dispatcher.
// Either this connection is created or its packets is buffered while waiting
// for CHLO.
virtual void OnNewConnectionAdded(QuicConnectionId connection_id);
bool HasBufferedPackets(QuicConnectionId connection_id);
// Called when BufferEarlyPacket() fail to buffer the packet.
virtual void OnBufferPacketFailure(
QuicBufferedPacketStore::EnqueuePacketResult result,
QuicConnectionId connection_id);
private:
friend class net::test::QuicDispatcherPeer;
// Removes the session from the session map and write blocked list, and adds
// the ConnectionId to the time-wait list. If |session_closed_statelessly| is
// true, any future packets for the ConnectionId will be black-holed.
void CleanUpSession(SessionMap::iterator it, bool session_closed_statelessly);
bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header);
// Attempts to reject the connection statelessly, if stateless rejects are
// possible and if the current packet contains a CHLO message.
// Returns a fate which describes what subsequent processing should be
// performed on the packets, like ValidityChecks.
QuicPacketFate MaybeRejectStatelessly(QuicConnectionId connection_id,
const QuicPacketHeader& header);
// Deliver |packets| to |session| for further processing.
void DeliverPacketsToSession(
const std::list<QuicBufferedPacketStore::BufferedPacket>& packets,
QuicServerSessionBase* session);
void set_new_sessions_allowed_per_event_loop(
int16_t new_sessions_allowed_per_event_loop) {
new_sessions_allowed_per_event_loop_ = new_sessions_allowed_per_event_loop;
}
const QuicConfig& config_;
const QuicCryptoServerConfig* crypto_config_;
// The cache for most recently compressed certs.
QuicCompressedCertsCache compressed_certs_cache_;
// The list of connections waiting to write.
WriteBlockedList write_blocked_list_;
SessionMap session_map_;
// Entity that manages connection_ids in time wait state.
std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_;
// The list of closed but not-yet-deleted sessions.
std::vector<QuicServerSessionBase*> closed_session_list_;
// The helper used for all connections.
std::unique_ptr<QuicConnectionHelperInterface> helper_;
// The helper used for all sessions.
std::unique_ptr<QuicServerSessionBase::Helper> session_helper_;
// Creates alarms.
std::unique_ptr<QuicAlarmFactory> alarm_factory_;
// An alarm which deletes closed sessions.
std::unique_ptr<QuicAlarm> delete_sessions_alarm_;
// The writer to write to the socket with.
std::unique_ptr<QuicPacketWriter> writer_;
// Packets which are buffered until a connection can be created to handle
// them.
QuicBufferedPacketStore buffered_packets_;
// Information about the packet currently being handled.
IPEndPoint current_client_address_;
IPEndPoint current_server_address_;
const QuicReceivedPacket* current_packet_;
QuicConnectionId current_connection_id_;
// Used to get the supported versions based on flag. Does not own.
QuicVersionManager* version_manager_;
QuicFramer framer_;
// The last error set by SetLastError(), which is called by
// framer_visitor_->OnError().
QuicErrorCode last_error_;
// A backward counter of how many new sessions can be create within current
// event loop. When reaches 0, it means can't create sessions for now.
int16_t new_sessions_allowed_per_event_loop_;
DISALLOW_COPY_AND_ASSIGN(QuicDispatcher);
};
} // namespace net
#endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_
| [
"bino.zh@gmail.com"
] | bino.zh@gmail.com |
fad72278950e4060ba87d66e996a29bcddcb4871 | f0c872eb0b60bef25a7534078bb98fe402b541da | /chrome/browser/alternate_nav_url_fetcher.cc | d2bf6f1e01fe38540f42ee8a3438687f5b9ee934 | [
"BSD-3-Clause"
] | permissive | aYukiSekiguchi/ACCESS-Chromium | f31c3795889c5ace66eb750a235105fe2466c116 | bec8149e84800b81aa0c98b5556ec8f46cb9db47 | refs/heads/master | 2020-06-01T19:31:30.180217 | 2012-07-26T08:54:49 | 2012-07-26T08:55:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,450 | cc | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/alternate_nav_url_fetcher.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/link_infobar_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/url_fetcher.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
#include "net/base/registry_controlled_domain.h"
#include "net/url_request/url_request.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
using content::NavigationController;
using content::OpenURLParams;
using content::Referrer;
// AlternateNavInfoBarDelegate ------------------------------------------------
class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate {
public:
AlternateNavInfoBarDelegate(InfoBarTabHelper* owner,
const GURL& alternate_nav_url);
virtual ~AlternateNavInfoBarDelegate();
private:
// LinkInfoBarDelegate
virtual gfx::Image* GetIcon() const OVERRIDE;
virtual Type GetInfoBarType() const OVERRIDE;
virtual string16 GetMessageTextWithOffset(size_t* link_offset) const OVERRIDE;
virtual string16 GetLinkText() const OVERRIDE;
virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
GURL alternate_nav_url_;
DISALLOW_COPY_AND_ASSIGN(AlternateNavInfoBarDelegate);
};
AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate(
InfoBarTabHelper* owner,
const GURL& alternate_nav_url)
: LinkInfoBarDelegate(owner),
alternate_nav_url_(alternate_nav_url) {
}
AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() {
}
gfx::Image* AlternateNavInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_ALT_NAV_URL);
}
InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const {
return PAGE_ACTION_TYPE;
}
string16 AlternateNavInfoBarDelegate::GetMessageTextWithOffset(
size_t* link_offset) const {
const string16 label = l10n_util::GetStringFUTF16(
IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset);
return label;
}
string16 AlternateNavInfoBarDelegate::GetLinkText() const {
return UTF8ToUTF16(alternate_nav_url_.spec());
}
bool AlternateNavInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
OpenURLParams params(
alternate_nav_url_, Referrer(), disposition,
// Pretend the user typed this URL, so that navigating to
// it will be the default action when it's typed again in
// the future.
content::PAGE_TRANSITION_TYPED,
false);
owner()->web_contents()->OpenURL(params);
// We should always close, even if the navigation did not occur within this
// TabContents.
return true;
}
// AlternateNavURLFetcher -----------------------------------------------------
AlternateNavURLFetcher::AlternateNavURLFetcher(
const GURL& alternate_nav_url)
: alternate_nav_url_(alternate_nav_url),
controller_(NULL),
state_(NOT_STARTED),
navigated_to_entry_(false) {
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_INSTANT_COMMITTED,
content::NotificationService::AllSources());
}
AlternateNavURLFetcher::~AlternateNavURLFetcher() {
}
void AlternateNavURLFetcher::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_NAV_ENTRY_PENDING: {
// If we've already received a notification for the same controller, we
// should delete ourselves as that indicates that the page is being
// re-loaded so this instance is now stale.
NavigationController* controller =
content::Source<NavigationController>(source).ptr();
if (controller_ == controller) {
delete this;
} else if (!controller_) {
// Start listening for the commit notification.
DCHECK(controller->GetPendingEntry());
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<NavigationController>(
controller));
StartFetch(controller);
}
break;
}
case chrome::NOTIFICATION_INSTANT_COMMITTED: {
// See above.
NavigationController* controller =
&content::Source<TabContentsWrapper>(source)->
web_contents()->GetController();
if (controller_ == controller) {
delete this;
} else if (!controller_) {
navigated_to_entry_ = true;
StartFetch(controller);
}
break;
}
case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
// The page was navigated, we can show the infobar now if necessary.
registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<NavigationController>(controller_));
navigated_to_entry_ = true;
ShowInfobarIfPossible();
// WARNING: |this| may be deleted!
break;
case content::NOTIFICATION_TAB_CLOSED:
// We have been closed. In order to prevent the URLFetcher from trying to
// access the controller that will be invalid, we delete ourselves.
// This deletes the URLFetcher and insures its callback won't be called.
delete this;
break;
default:
NOTREACHED();
}
}
void AlternateNavURLFetcher::OnURLFetchComplete(
const content::URLFetcher* source) {
DCHECK_EQ(fetcher_.get(), source);
SetStatusFromURLFetch(
source->GetURL(), source->GetStatus(), source->GetResponseCode());
ShowInfobarIfPossible();
// WARNING: |this| may be deleted!
}
void AlternateNavURLFetcher::StartFetch(NavigationController* controller) {
controller_ = controller;
registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED,
content::Source<NavigationController>(controller_));
DCHECK_EQ(NOT_STARTED, state_);
state_ = IN_PROGRESS;
fetcher_.reset(content::URLFetcher::Create(
GURL(alternate_nav_url_), content::URLFetcher::HEAD, this));
fetcher_->SetRequestContext(
controller_->GetBrowserContext()->GetRequestContext());
fetcher_->Start();
}
void AlternateNavURLFetcher::SetStatusFromURLFetch(
const GURL& url,
const net::URLRequestStatus& status,
int response_code) {
if (!status.is_success() ||
// HTTP 2xx, 401, and 407 all indicate that the target address exists.
(((response_code / 100) != 2) &&
(response_code != 401) && (response_code != 407)) ||
// Fail if we're redirected to a common location.
// This happens for ISPs/DNS providers/etc. who return
// provider-controlled pages to arbitrary user navigation attempts.
// Because this can result in infobars on large fractions of user
// searches, we don't show automatic infobars for these. Note that users
// can still choose to explicitly navigate to or search for pages in
// these domains, and can still get infobars for cases that wind up on
// other domains (e.g. legit intranet sites), we're just trying to avoid
// erroneously harassing the user with our own UI prompts.
net::RegistryControlledDomainService::SameDomainOrHost(url,
IntranetRedirectDetector::RedirectOrigin())) {
state_ = FAILED;
return;
}
state_ = SUCCEEDED;
}
void AlternateNavURLFetcher::ShowInfobarIfPossible() {
if (!navigated_to_entry_ || state_ != SUCCEEDED) {
if (state_ == FAILED)
delete this;
return;
}
InfoBarTabHelper* infobar_helper =
TabContentsWrapper::GetCurrentWrapperForContents(
controller_->GetWebContents())->infobar_tab_helper();
infobar_helper->AddInfoBar(
new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_));
delete this;
}
| [
"yuki.sekiguchi@access-company.com"
] | yuki.sekiguchi@access-company.com |
48014d1d6d31d0898dd7adae4d3e475925763aa9 | c6907f3adc9e3a930a124c852604f19efb359165 | /src/qt/rpcconsole.cpp | 481c08722fc1ee5a432f37bd4dd49e6d5d7c5e20 | [
"MIT"
] | permissive | omnistoreservice/omnistorecoin | c489a1e323251addbc15971f51ae4edb510ea03a | ca157bbd52d719f2c84e38bf0b4bfe8a4a652270 | refs/heads/master | 2020-07-12T04:34:17.834882 | 2019-09-02T10:30:42 | 2019-09-02T10:30:42 | 204,719,354 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,594 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2018 The OmniStoreCoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "rpcconsole.h"
#include "ui_rpcconsole.h"
#include "bantablemodel.h"
#include "clientmodel.h"
#include "guiutil.h"
#include "peertablemodel.h"
#include "chainparams.h"
#include "main.h"
#include "rpc/client.h"
#include "rpc/server.h"
#include "util.h"
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif // ENABLE_WALLET
#include <openssl/crypto.h>
#include <univalue.h>
#ifdef ENABLE_WALLET
#include <db_cxx.h>
#endif
#include <QDir>
#include <QKeyEvent>
#include <QMenu>
#include <QScrollBar>
#include <QSignalMapper>
#include <QThread>
#include <QTime>
#include <QTimer>
#include <QStringList>
#include <QDesktopServices>
// TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented)
// TODO: receive errors and debug messages through ClientModel
const int CONSOLE_HISTORY = 50;
const QSize ICON_SIZE(24, 24);
const int INITIAL_TRAFFIC_GRAPH_MINS = 30;
// Repair parameters
const QString SALVAGEWALLET("-salvagewallet");
const QString RESCAN("-rescan");
const QString ZAPTXES1("-zapwallettxes=1");
const QString ZAPTXES2("-zapwallettxes=2");
const QString UPGRADEWALLET("-upgradewallet");
const QString REINDEX("-reindex");
const QString RESYNC("-resync");
const struct {
const char* url;
const char* source;
} ICON_MAPPING[] = {
{"cmd-request", ":/icons/tx_input"},
{"cmd-reply", ":/icons/tx_output"},
{"cmd-error", ":/icons/tx_output"},
{"misc", ":/icons/tx_inout"},
{NULL, NULL}};
/* Object for executing console RPC commands in a separate thread.
*/
class RPCExecutor : public QObject
{
Q_OBJECT
public slots:
void request(const QString& command);
signals:
void reply(int category, const QString& command);
};
/** Class for handling RPC timers
* (used for e.g. re-locking the wallet after a timeout)
*/
class QtRPCTimerBase: public QObject, public RPCTimerBase
{
Q_OBJECT
public:
QtRPCTimerBase(boost::function<void(void)>& func, int64_t millis):
func(func)
{
timer.setSingleShot(true);
connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
timer.start(millis);
}
~QtRPCTimerBase() {}
private slots:
void timeout() { func(); }
private:
QTimer timer;
boost::function<void(void)> func;
};
class QtRPCTimerInterface: public RPCTimerInterface
{
public:
~QtRPCTimerInterface() {}
const char *Name() { return "Qt"; }
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
{
return new QtRPCTimerBase(func, millis);
}
};
#include "rpcconsole.moc"
/**
* Split shell command line into a list of arguments. Aims to emulate \c bash and friends.
*
* - Arguments are delimited with whitespace
* - Extra whitespace at the beginning and end and between arguments will be ignored
* - Text can be "double" or 'single' quoted
* - The backslash \c \ is used as escape character
* - Outside quotes, any character can be escaped
* - Within double quotes, only escape \c " and backslashes before a \c " or another backslash
* - Within single quotes, no escaping is possible and no special interpretation takes place
*
* @param[out] args Parsed arguments will be appended to this list
* @param[in] strCommand Command line to split
*/
bool parseCommandLine(std::vector<std::string>& args, const std::string& strCommand)
{
enum CmdParseState {
STATE_EATING_SPACES,
STATE_ARGUMENT,
STATE_SINGLEQUOTED,
STATE_DOUBLEQUOTED,
STATE_ESCAPE_OUTER,
STATE_ESCAPE_DOUBLEQUOTED
} state = STATE_EATING_SPACES;
std::string curarg;
foreach (char ch, strCommand) {
switch (state) {
case STATE_ARGUMENT: // In or after argument
case STATE_EATING_SPACES: // Handle runs of whitespace
switch (ch) {
case '"':
state = STATE_DOUBLEQUOTED;
break;
case '\'':
state = STATE_SINGLEQUOTED;
break;
case '\\':
state = STATE_ESCAPE_OUTER;
break;
case ' ':
case '\n':
case '\t':
if (state == STATE_ARGUMENT) // Space ends argument
{
args.push_back(curarg);
curarg.clear();
}
state = STATE_EATING_SPACES;
break;
default:
curarg += ch;
state = STATE_ARGUMENT;
}
break;
case STATE_SINGLEQUOTED: // Single-quoted string
switch (ch) {
case '\'':
state = STATE_ARGUMENT;
break;
default:
curarg += ch;
}
break;
case STATE_DOUBLEQUOTED: // Double-quoted string
switch (ch) {
case '"':
state = STATE_ARGUMENT;
break;
case '\\':
state = STATE_ESCAPE_DOUBLEQUOTED;
break;
default:
curarg += ch;
}
break;
case STATE_ESCAPE_OUTER: // '\' outside quotes
curarg += ch;
state = STATE_ARGUMENT;
break;
case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text
if (ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself
curarg += ch;
state = STATE_DOUBLEQUOTED;
break;
}
}
switch (state) // final state
{
case STATE_EATING_SPACES:
return true;
case STATE_ARGUMENT:
args.push_back(curarg);
return true;
default: // ERROR to end in one of the other states
return false;
}
}
void RPCExecutor::request(const QString& command)
{
std::vector<std::string> args;
if (!parseCommandLine(args, command.toStdString())) {
emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
return;
}
if (args.empty())
return; // Nothing to do
try {
std::string strPrint;
// Convert argument list to JSON objects in method-dependent way,
// and pass it along with the method name to the dispatcher.
UniValue result = tableRPC.execute(
args[0],
RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end())));
// Format result reply
if (result.isNull())
strPrint = "";
else if (result.isStr())
strPrint = result.get_str();
else
strPrint = result.write(2);
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
} catch (UniValue& objError) {
try // Nice formatting for standard-format error
{
int code = find_value(objError, "code").get_int();
std::string message = find_value(objError, "message").get_str();
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
} catch (std::runtime_error&) // raised when converting to invalid type, i.e. missing code or message
{ // Show raw JSON object
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(objError.write()));
}
} catch (std::exception& e) {
emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
}
}
RPCConsole::RPCConsole(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
ui(new Ui::RPCConsole),
clientModel(0),
historyPtr(0),
cachedNodeid(-1),
peersTableContextMenu(0),
banTableContextMenu(0)
{
ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
#ifndef Q_OS_MAC
ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
#endif
// Install event filter for up and down arrow
ui->lineEdit->installEventFilter(this);
ui->messagesWidget->installEventFilter(this);
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
// Wallet Repair Buttons
connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(walletSalvage()));
connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(walletRescan()));
connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(walletZaptxes1()));
connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(walletZaptxes2()));
connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(walletUpgrade()));
connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(walletReindex()));
connect(ui->btn_resync, SIGNAL(clicked()), this, SLOT(walletResync()));
// set library version labels
ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
#ifdef ENABLE_WALLET
std::string strPathCustom = GetArg("-backuppath", "");
std::string strzOMNSPathCustom = GetArg("-zomnsbackuppath", "");
int nCustomBackupThreshold = GetArg("-custombackupthreshold", DEFAULT_CUSTOMBACKUPTHRESHOLD);
if(!strPathCustom.empty()) {
ui->wallet_custombackuppath->setText(QString::fromStdString(strPathCustom));
ui->wallet_custombackuppath_label->show();
ui->wallet_custombackuppath->show();
}
if(!strzOMNSPathCustom.empty()) {
ui->wallet_customzomnsbackuppath->setText(QString::fromStdString(strzOMNSPathCustom));
ui->wallet_customzomnsbackuppath_label->setVisible(true);
ui->wallet_customzomnsbackuppath->setVisible(true);
}
if((!strPathCustom.empty() || !strzOMNSPathCustom.empty()) && nCustomBackupThreshold > 0) {
ui->wallet_custombackupthreshold->setText(QString::fromStdString(std::to_string(nCustomBackupThreshold)));
ui->wallet_custombackupthreshold_label->setVisible(true);
ui->wallet_custombackupthreshold->setVisible(true);
}
ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
ui->wallet_path->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", "wallet.dat")));
#else
ui->label_berkeleyDBVersion->hide();
ui->berkeleyDBVersion->hide();
#endif
// Register RPC timer interface
rpcTimerInterface = new QtRPCTimerInterface();
RPCRegisterTimerInterface(rpcTimerInterface);
startExecutor();
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
clear();
}
RPCConsole::~RPCConsole()
{
GUIUtil::saveWindowGeometry("nRPCConsoleWindow", this);
emit stopExecutor();
RPCUnregisterTimerInterface(rpcTimerInterface);
delete rpcTimerInterface;
delete ui;
}
bool RPCConsole::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::KeyPress) // Special key handling
{
QKeyEvent* keyevt = static_cast<QKeyEvent*>(event);
int key = keyevt->key();
Qt::KeyboardModifiers mod = keyevt->modifiers();
switch (key) {
case Qt::Key_Up:
if (obj == ui->lineEdit) {
browseHistory(-1);
return true;
}
break;
case Qt::Key_Down:
if (obj == ui->lineEdit) {
browseHistory(1);
return true;
}
break;
case Qt::Key_PageUp: /* pass paging keys to messages widget */
case Qt::Key_PageDown:
if (obj == ui->lineEdit) {
QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
return true;
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
// forward these events to lineEdit
if(obj == autoCompleter->popup()) {
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
return true;
}
break;
default:
// Typing in messages widget brings focus to line edit, and redirects key there
// Exclude most combinations and keys that emit no text, except paste shortcuts
if (obj == ui->messagesWidget && ((!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) {
ui->lineEdit->setFocus();
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
return true;
}
}
}
return QDialog::eventFilter(obj, event);
}
void RPCConsole::setClientModel(ClientModel* model)
{
clientModel = model;
ui->trafficGraph->setClientModel(model);
if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) {
// Keep up to date with client
setNumConnections(model->getNumConnections());
connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(model->getNumBlocks());
connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
setMasternodeCount(model->getMasternodeCountString());
connect(model, SIGNAL(strMasternodesChanged(QString)), this, SLOT(setMasternodeCount(QString)));
updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent());
connect(model, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
// set up peer table
ui->peerWidget->setModel(model->getPeerTableModel());
ui->peerWidget->verticalHeader()->hide();
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
// create peer table context menu actions
QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
QAction* banAction1h = new QAction(tr("Ban Node for") + " " + tr("1 &hour"), this);
QAction* banAction24h = new QAction(tr("Ban Node for") + " " + tr("1 &day"), this);
QAction* banAction7d = new QAction(tr("Ban Node for") + " " + tr("1 &week"), this);
QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 &year"), this);
// create peer table context menu
peersTableContextMenu = new QMenu();
peersTableContextMenu->addAction(disconnectAction);
peersTableContextMenu->addAction(banAction1h);
peersTableContextMenu->addAction(banAction24h);
peersTableContextMenu->addAction(banAction7d);
peersTableContextMenu->addAction(banAction365d);
// Add a signal mapping to allow dynamic context menu arguments.
// We need to use int (instead of int64_t), because signal mapper only supports
// int or objects, which is okay because max bantime (1 year) is < int_max.
QSignalMapper* signalMapper = new QSignalMapper(this);
signalMapper->setMapping(banAction1h, 60*60);
signalMapper->setMapping(banAction24h, 60*60*24);
signalMapper->setMapping(banAction7d, 60*60*24*7);
signalMapper->setMapping(banAction365d, 60*60*24*365);
connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(banSelectedNode(int)));
// peer table context menu signals
connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&)));
connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode()));
// peer table signal handling - update peer details when selecting new node
connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &)));
// peer table signal handling - update peer details when new nodes are added to the model
connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged()));
// set up ban table
ui->banlistWidget->setModel(model->getBanTableModel());
ui->banlistWidget->verticalHeader()->hide();
ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
// create ban table context menu action
QAction* unbanAction = new QAction(tr("&Unban Node"), this);
// create ban table context menu
banTableContextMenu = new QMenu();
banTableContextMenu->addAction(unbanAction);
// ban table context menu signals
connect(ui->banlistWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBanTableContextMenu(const QPoint&)));
connect(unbanAction, SIGNAL(triggered()), this, SLOT(unbanSelectedNode()));
// ban table signal handling - clear peer details when clicking a peer in the ban table
connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clearSelectedNode()));
// ban table signal handling - ensure ban table is shown or hidden (if empty)
connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, SLOT(showOrHideBanTableIfRequired()));
showOrHideBanTableIfRequired();
// Provide initial values
ui->clientVersion->setText(model->formatFullVersion());
ui->clientName->setText(model->clientName());
ui->buildDate->setText(model->formatBuildDate());
ui->startupTime->setText(model->formatClientStartupTime());
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
//Setup autocomplete and attach it
QStringList wordList;
std::vector<std::string> commandList = tableRPC.listCommands();
for (size_t i = 0; i < commandList.size(); ++i)
{
wordList << commandList[i].c_str();
}
autoCompleter = new QCompleter(wordList, this);
ui->lineEdit->setCompleter(autoCompleter);
// clear the lineEdit after activating from QCompleter
autoCompleter->popup()->installEventFilter(this);
}
}
static QString categoryClass(int category)
{
switch (category) {
case RPCConsole::CMD_REQUEST:
return "cmd-request";
break;
case RPCConsole::CMD_REPLY:
return "cmd-reply";
break;
case RPCConsole::CMD_ERROR:
return "cmd-error";
break;
default:
return "misc";
}
}
/** Restart wallet with "-salvagewallet" */
void RPCConsole::walletSalvage()
{
buildParameterlist(SALVAGEWALLET);
}
/** Restart wallet with "-rescan" */
void RPCConsole::walletRescan()
{
buildParameterlist(RESCAN);
}
/** Restart wallet with "-zapwallettxes=1" */
void RPCConsole::walletZaptxes1()
{
buildParameterlist(ZAPTXES1);
}
/** Restart wallet with "-zapwallettxes=2" */
void RPCConsole::walletZaptxes2()
{
buildParameterlist(ZAPTXES2);
}
/** Restart wallet with "-upgradewallet" */
void RPCConsole::walletUpgrade()
{
buildParameterlist(UPGRADEWALLET);
}
/** Restart wallet with "-reindex" */
void RPCConsole::walletReindex()
{
buildParameterlist(REINDEX);
}
/** Restart wallet with "-resync" */
void RPCConsole::walletResync()
{
QString resyncWarning = tr("This will delete your local blockchain folders and the wallet will synchronize the complete Blockchain from scratch.<br /><br />");
resyncWarning += tr("This needs quite some time and downloads a lot of data.<br /><br />");
resyncWarning += tr("Your transactions and funds will be visible again after the download has completed.<br /><br />");
resyncWarning += tr("Do you want to continue?.<br />");
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm resync Blockchain"),
resyncWarning,
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if (retval != QMessageBox::Yes) {
// Resync canceled
return;
}
// Restart and resync
buildParameterlist(RESYNC);
}
/** Build command-line parameter list for restart */
void RPCConsole::buildParameterlist(QString arg)
{
// Get command-line arguments and remove the application name
QStringList args = QApplication::arguments();
args.removeFirst();
// Remove existing repair-options
args.removeAll(SALVAGEWALLET);
args.removeAll(RESCAN);
args.removeAll(ZAPTXES1);
args.removeAll(ZAPTXES2);
args.removeAll(UPGRADEWALLET);
args.removeAll(REINDEX);
// Append repair parameter to command line.
args.append(arg);
// Send command-line arguments to BitcoinGUI::handleRestart()
emit handleRestart(args);
}
void RPCConsole::clear()
{
ui->messagesWidget->clear();
history.clear();
historyPtr = 0;
ui->lineEdit->clear();
ui->lineEdit->setFocus();
// Add smoothly scaled icon images.
// (when using width/height on an img, Qt uses nearest instead of linear interpolation)
for (int i = 0; ICON_MAPPING[i].url; ++i) {
ui->messagesWidget->document()->addResource(
QTextDocument::ImageResource,
QUrl(ICON_MAPPING[i].url),
QImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
// Set default style sheet
ui->messagesWidget->document()->setDefaultStyleSheet(
"table { }"
"td.time { color: #808080; padding-top: 3px; } "
"td.message { font-family: Courier, Courier New, Lucida Console, monospace; font-size: 12px; } " // Todo: Remove fixed font-size
"td.cmd-request { color: #006060; } "
"td.cmd-error { color: red; } "
"b { color: #006060; } ");
message(CMD_REPLY, (tr("Welcome to the OmniStoreCoin RPC console.") + "<br>" +
tr("Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.") + "<br>" +
tr("Type <b>help</b> for an overview of available commands.")),
true);
}
void RPCConsole::reject()
{
// Ignore escape keypress if this is not a seperate window
if (windowType() != Qt::Widget)
QDialog::reject();
}
void RPCConsole::message(int category, const QString& message, bool html)
{
QTime time = QTime::currentTime();
QString timeString = time.toString();
QString out;
out += "<table><tr><td class=\"time\" width=\"65\">" + timeString + "</td>";
out += "<td class=\"icon\" width=\"32\"><img src=\"" + categoryClass(category) + "\"></td>";
out += "<td class=\"message " + categoryClass(category) + "\" valign=\"middle\">";
if (html)
out += message;
else
out += GUIUtil::HtmlEscape(message, true);
out += "</td></tr></table>";
ui->messagesWidget->append(out);
}
void RPCConsole::setNumConnections(int count)
{
if (!clientModel)
return;
QString connections = QString::number(count) + " (";
connections += tr("In:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_IN)) + " / ";
connections += tr("Out:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_OUT)) + ")";
ui->numberOfConnections->setText(connections);
}
void RPCConsole::setNumBlocks(int count)
{
ui->numberOfBlocks->setText(QString::number(count));
if (clientModel)
ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
}
void RPCConsole::setMasternodeCount(const QString& strMasternodes)
{
ui->masternodeCount->setText(strMasternodes);
}
void RPCConsole::on_lineEdit_returnPressed()
{
QString cmd = ui->lineEdit->text();
ui->lineEdit->clear();
if (!cmd.isEmpty()) {
message(CMD_REQUEST, cmd);
emit cmdRequest(cmd);
// Remove command, if already in history
history.removeOne(cmd);
// Append command to history
history.append(cmd);
// Enforce maximum history size
while (history.size() > CONSOLE_HISTORY)
history.removeFirst();
// Set pointer to end of history
historyPtr = history.size();
// Scroll console view to end
scrollToEnd();
}
}
void RPCConsole::browseHistory(int offset)
{
historyPtr += offset;
if (historyPtr < 0)
historyPtr = 0;
if (historyPtr > history.size())
historyPtr = history.size();
QString cmd;
if (historyPtr < history.size())
cmd = history.at(historyPtr);
ui->lineEdit->setText(cmd);
}
void RPCConsole::startExecutor()
{
QThread* thread = new QThread;
RPCExecutor* executor = new RPCExecutor();
executor->moveToThread(thread);
// Replies from executor object must go to this object
connect(executor, SIGNAL(reply(int, QString)), this, SLOT(message(int, QString)));
// Requests from this object must go to executor
connect(this, SIGNAL(cmdRequest(QString)), executor, SLOT(request(QString)));
// On stopExecutor signal
// - queue executor for deletion (in execution thread)
// - quit the Qt event loop in the execution thread
connect(this, SIGNAL(stopExecutor()), executor, SLOT(deleteLater()));
connect(this, SIGNAL(stopExecutor()), thread, SLOT(quit()));
// Queue the thread for deletion (in this thread) when it is finished
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
// Default implementation of QThread::run() simply spins up an event loop in the thread,
// which is what we want.
thread->start();
}
void RPCConsole::on_tabWidget_currentChanged(int index)
{
if (ui->tabWidget->widget(index) == ui->tab_console) {
ui->lineEdit->setFocus();
} else if (ui->tabWidget->widget(index) != ui->tab_peers) {
clearSelectedNode();
}
}
void RPCConsole::on_openDebugLogfileButton_clicked()
{
GUIUtil::openDebugLogfile();
}
void RPCConsole::scrollToEnd()
{
QScrollBar* scrollbar = ui->messagesWidget->verticalScrollBar();
scrollbar->setValue(scrollbar->maximum());
}
void RPCConsole::on_sldGraphRange_valueChanged(int value)
{
const int multiplier = 5; // each position on the slider represents 5 min
int mins = value * multiplier;
setTrafficGraphRange(mins);
}
QString RPCConsole::FormatBytes(quint64 bytes)
{
if (bytes < 1024)
return QString(tr("%1 B")).arg(bytes);
if (bytes < 1024 * 1024)
return QString(tr("%1 KB")).arg(bytes / 1024);
if (bytes < 1024 * 1024 * 1024)
return QString(tr("%1 MB")).arg(bytes / 1024 / 1024);
return QString(tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
}
void RPCConsole::setTrafficGraphRange(int mins)
{
ui->trafficGraph->setGraphRangeMins(mins);
ui->lblGraphRange->setText(GUIUtil::formatDurationStr(mins * 60));
}
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
{
ui->lblBytesIn->setText(FormatBytes(totalBytesIn));
ui->lblBytesOut->setText(FormatBytes(totalBytesOut));
}
void RPCConsole::showInfo()
{
ui->tabWidget->setCurrentIndex(0);
show();
}
void RPCConsole::showConsole()
{
ui->tabWidget->setCurrentIndex(1);
show();
}
void RPCConsole::showNetwork()
{
ui->tabWidget->setCurrentIndex(2);
show();
}
void RPCConsole::showPeers()
{
ui->tabWidget->setCurrentIndex(3);
show();
}
void RPCConsole::showRepair()
{
ui->tabWidget->setCurrentIndex(4);
show();
}
void RPCConsole::showConfEditor()
{
GUIUtil::openConfigfile();
}
void RPCConsole::showMNConfEditor()
{
GUIUtil::openMNConfigfile();
}
void RPCConsole::openOmniStoreWebsite()
{
QDesktopServices::openUrl(QUrl("https://omnistore.org", QUrl::TolerantMode));
}
void RPCConsole::openOmniStoreTwitter()
{
QDesktopServices::openUrl(QUrl("https://twitter.com/omnistoreonline", QUrl::TolerantMode));
}
void RPCConsole::openOmniStoreDiscord()
{
QDesktopServices::openUrl(QUrl("https://discord.gg/t7Pk7fk", QUrl::TolerantMode));
}
void RPCConsole::peerSelected(const QItemSelection& selected, const QItemSelection& deselected)
{
Q_UNUSED(deselected);
if (!clientModel || !clientModel->getPeerTableModel() || selected.indexes().isEmpty())
return;
const CNodeCombinedStats* stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
if (stats)
updateNodeDetail(stats);
}
void RPCConsole::peerLayoutChanged()
{
if (!clientModel || !clientModel->getPeerTableModel())
return;
const CNodeCombinedStats* stats = NULL;
bool fUnselect = false;
bool fReselect = false;
if (cachedNodeid == -1) // no node selected yet
return;
// find the currently selected row
int selectedRow = -1;
QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
if (!selectedModelIndex.isEmpty()) {
selectedRow = selectedModelIndex.first().row();
}
// check if our detail node has a row in the table (it may not necessarily
// be at selectedRow since its position can change after a layout change)
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
if (detailNodeRow < 0) {
// detail node dissapeared from table (node disconnected)
fUnselect = true;
} else {
if (detailNodeRow != selectedRow) {
// detail node moved position
fUnselect = true;
fReselect = true;
}
// get fresh stats on the detail node.
stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
}
if (fUnselect && selectedRow >= 0) {
clearSelectedNode();
}
if (fReselect) {
ui->peerWidget->selectRow(detailNodeRow);
}
if (stats)
updateNodeDetail(stats);
}
void RPCConsole::updateNodeDetail(const CNodeCombinedStats* stats)
{
// Update cached nodeid
cachedNodeid = stats->nodeStats.nodeid;
// update the detail ui with latest node information
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
if (!stats->nodeStats.addrLocal.empty())
peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
ui->peerHeading->setText(peerAddrDetails);
ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastSend) : tr("never"));
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastRecv) : tr("never"));
ui->peerBytesSent->setText(FormatBytes(stats->nodeStats.nSendBytes));
ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes));
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected));
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion)));
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
ui->peerHeight->setText(QString("%1").arg(QString::number(stats->nodeStats.nStartingHeight)));
ui->peerWhitelisted->setText(stats->nodeStats.fWhitelisted ? tr("Yes") : tr("No"));
// This check fails for example if the lock was busy and
// nodeStateStats couldn't be fetched.
if (stats->fNodeStateStatsAvailable) {
// Ban score is init to 0
ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior));
// Sync height is init to -1
if (stats->nodeStateStats.nSyncHeight > -1)
ui->peerSyncHeight->setText(QString("%1").arg(stats->nodeStateStats.nSyncHeight));
else
ui->peerSyncHeight->setText(tr("Unknown"));
// Common height is init to -1
if (stats->nodeStateStats.nCommonHeight > -1)
ui->peerCommonHeight->setText(QString("%1").arg(stats->nodeStateStats.nCommonHeight));
else
ui->peerCommonHeight->setText(tr("Unknown"));
}
ui->detailWidget->show();
}
void RPCConsole::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
}
void RPCConsole::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
if (!clientModel || !clientModel->getPeerTableModel())
return;
// start PeerTableModel auto refresh
clientModel->getPeerTableModel()->startAutoRefresh();
}
void RPCConsole::hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
if (!clientModel || !clientModel->getPeerTableModel())
return;
// stop PeerTableModel auto refresh
clientModel->getPeerTableModel()->stopAutoRefresh();
}
void RPCConsole::showBackups()
{
GUIUtil::showBackups();
}
void RPCConsole::showPeersTableContextMenu(const QPoint& point)
{
QModelIndex index = ui->peerWidget->indexAt(point);
if (index.isValid())
peersTableContextMenu->exec(QCursor::pos());
}
void RPCConsole::showBanTableContextMenu(const QPoint& point)
{
QModelIndex index = ui->banlistWidget->indexAt(point);
if (index.isValid())
banTableContextMenu->exec(QCursor::pos());
}
void RPCConsole::disconnectSelectedNode()
{
// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
// Find the node, disconnect it and clear the selected node
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
bannedNode->CloseSocketDisconnect();
clearSelectedNode();
}
}
void RPCConsole::banSelectedNode(int bantime)
{
if (!clientModel)
return;
// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
// Find possible nodes, ban it and clear the selected node
if (FindNode(strNode.toStdString())) {
std::string nStr = strNode.toStdString();
std::string addr;
int port = 0;
SplitHostPort(nStr, port, addr);
CNode::Ban(CNetAddr(addr), BanReasonManuallyAdded, bantime);
clearSelectedNode();
clientModel->getBanTableModel()->refresh();
}
}
void RPCConsole::unbanSelectedNode()
{
if (!clientModel)
return;
// Get currently selected ban address
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address);
CSubNet possibleSubnet(strNode.toStdString());
if (possibleSubnet.IsValid())
{
CNode::Unban(possibleSubnet);
clientModel->getBanTableModel()->refresh();
}
}
void RPCConsole::clearSelectedNode()
{
ui->peerWidget->selectionModel()->clearSelection();
cachedNodeid = -1;
ui->detailWidget->hide();
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
}
void RPCConsole::showOrHideBanTableIfRequired()
{
if (!clientModel)
return;
bool visible = clientModel->getBanTableModel()->shouldShow();
ui->banlistWidget->setVisible(visible);
ui->banHeading->setVisible(visible);
}
| [
"debian@debian"
] | debian@debian |
5a3947843544fb0e5726eec4634ba83054908e17 | 589dbe5bbbc286c991fd443a4fca6a6a26f362d7 | /Tests/lib231.cpp | b3270ec09e330551d099a2253a570271d246b79f | [] | no_license | TrevenHu/Course-Projects-of-Advanced-Compiler | 42996751896c573157009576f04cd48c5aaf489e | 7875e2dafe508787ec6c7260fedff7ffdaffed2d | refs/heads/master | 2020-03-25T00:44:07.402206 | 2018-08-01T20:07:14 | 2018-08-01T20:07:14 | 143,202,897 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,418 | cpp | #include <iostream>
#include <map>
#include <stdint.h>
#include <stdlib.h>
std::map<unsigned, unsigned> instr_map;
int branch_count[2];
const char *mapCodeToName(unsigned Op) {
if (Op == 1)
return "ret";
if (Op == 2)
return "br";
if (Op == 3)
return "switch";
if (Op == 4)
return "indirectbr";
if (Op == 5)
return "invoke";
if (Op == 6)
return "resume";
if (Op == 7)
return "unreachable";
if (Op == 8)
return "cleanupret";
if (Op == 9)
return "catchret";
if (Op == 10)
return "catchswitch";
if (Op == 11)
return "add";
if (Op == 12)
return "fadd";
if (Op == 13)
return "sub";
if (Op == 14)
return "fsub";
if (Op == 15)
return "mul";
if (Op == 16)
return "fmul";
if (Op == 17)
return "udiv";
if (Op == 18)
return "sdiv";
if (Op == 19)
return "fdiv";
if (Op == 20)
return "urem";
if (Op == 21)
return "srem";
if (Op == 22)
return "frem";
if (Op == 23)
return "shl";
if (Op == 24)
return "lshr";
if (Op == 25)
return "ashr";
if (Op == 26)
return "and";
if (Op == 27)
return "or";
if (Op == 28)
return "xor";
if (Op == 29)
return "alloca";
if (Op == 30)
return "load";
if (Op == 31)
return "store";
if (Op == 32)
return "getelementptr";
if (Op == 33)
return "fence";
if (Op == 34)
return "cmpxchg";
if (Op == 35)
return "atomicrmw";
if (Op == 36)
return "trunc";
if (Op == 37)
return "zext";
if (Op == 38)
return "sext";
if (Op == 39)
return "fptoui";
if (Op == 40)
return "fptosi";
if (Op == 41)
return "uitofp";
if (Op == 42)
return "sitofp";
if (Op == 43)
return "fptrunc";
if (Op == 44)
return "fpext";
if (Op == 45)
return "ptrtoint";
if (Op == 46)
return "inttoptr";
if (Op == 47)
return "bitcast";
if (Op == 48)
return "addrspacecast";
if (Op == 49)
return "cleanuppad";
if (Op == 50)
return "catchpad";
if (Op == 51)
return "icmp";
if (Op == 52)
return "fcmp";
if (Op == 53)
return "phi";
if (Op == 54)
return "call";
if (Op == 55)
return "select";
if (Op == 56)
return "<Invalid operator>";
if (Op == 57)
return "<Invalid operator>";
if (Op == 58)
return "va_arg";
if (Op == 59)
return "extractelement";
if (Op == 60)
return "insertelement";
if (Op == 61)
return "shufflevector";
if (Op == 62)
return "extractvalue";
if (Op == 63)
return "insertvalue";
if (Op == 64)
return "landingpad";
return "<Invalid operator>";
}
// For section 2
// num: the number of unique instructions in the basic block. It is the length of keys and values.
// keys: the array of the opcodes of the instructions
// values: the array of the counts of the instructions
extern "C" __attribute__((visibility("default")))
void updateInstrInfo(uint32_t num, uint32_t * keys, uint32_t * values) {
int i;
uint32_t key;
uint32_t value;
for (i=0; i<num; i++) {
key = keys[i];
value = values[i];
if (instr_map.count(key) == 0)
instr_map.insert(std::pair<uint32_t, uint32_t>(key, value));
else
instr_map[key] = instr_map[key] + value;
}
return;
}
// For section 3
// If taken is true, then a conditional branch is taken;
// If taken is false, then a conditional branch is not taken.
extern "C" __attribute__((visibility("default")))
void updateBranchInfo(bool taken) {
if (taken)
branch_count[0] ++;
branch_count[1] ++;
return;
}
// For section 2
extern "C" __attribute__((visibility("default")))
void printOutInstrInfo() {
for (std::map<uint32_t, uint32_t>::iterator it=instr_map.begin(); it!=instr_map.end(); ++it)
std::cerr << mapCodeToName(it->first) << '\t' << it->second << '\n';
instr_map.clear();
return;
}
// For section 3
extern "C" __attribute__((visibility("default")))
void printOutBranchInfo() {
std::cerr << "taken\t" << branch_count[0] << '\n';
std::cerr << "total\t" << branch_count[1] << '\n';
branch_count[0] = 0;
branch_count[1] = 0;
return;
}
| [
"hzy1994@bupt.edu.cn"
] | hzy1994@bupt.edu.cn |
f5e07558ff959e82ee39cedf3a86b196ad48394b | 1bc3d74e3e6bea1fba9b33616fd4896d0e605187 | /includes/acl/sjson/sjson_parser_error.h | cb356e742ee56c121765c2ecdcbb0f5667cd3557 | [
"MIT"
] | permissive | dfbrown/acl | 361630711b5f8511f19e8c6bccd78a1a7cb159a5 | 24506dce3c3b02be4f23ef0c5167dec48dd1af27 | refs/heads/master | 2021-07-09T21:08:47.350862 | 2017-09-10T15:58:27 | 2017-09-10T15:58:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,637 | h | #pragma once
////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2017 Nicholas Frechette & Animation Compression Library contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
////////////////////////////////////////////////////////////////////////////////
namespace acl
{
struct SJSONParserError
{
SJSONParserError()
: error(SJSONParserError::None)
, line()
, column()
{
}
enum : uint32_t
{
None,
InputTruncated,
OpeningBraceExpected,
ClosingBraceExpected,
EqualSignExpected,
OpeningBracketExpected,
ClosingBracketExpected,
CommaExpected,
CommentBeginsIncorrectly,
CannotUseQuotationMarkInUnquotedString,
KeyExpected,
IncorrectKey,
TrueOrFalseExpected,
QuotationMarkExpected,
NumberExpected,
NumberIsTooLong,
InvalidNumber,
NumberCouldNotBeConverted,
UnexpectedContentAtEnd,
Last
};
uint32_t error;
uint32_t line;
uint32_t column;
virtual const char* const get_description() const
{
switch (error)
{
case None:
return "None";
case InputTruncated:
return "The file ended sooner than expected";
case OpeningBraceExpected:
return "An opening { is expected here";
case ClosingBraceExpected:
return "A closing } is expected here";
case EqualSignExpected:
return "An equal sign is expected here";
case OpeningBracketExpected:
return "An opening [ is expected here";
case ClosingBracketExpected:
return "A closing ] is expected here";
case CommaExpected:
return "A comma is expected here";
case CommentBeginsIncorrectly:
return "Comments must start with either // or /*";
case CannotUseQuotationMarkInUnquotedString:
return "Quotation marks cannot be used in unquoted strings";
case KeyExpected:
return "The name of a key is expected here";
case IncorrectKey:
return "A different key is expected here";
case TrueOrFalseExpected:
return "Only the literals true or false are allowed here";
case QuotationMarkExpected:
return "A quotation mark is expected here";
case NumberExpected:
return "A number is expected here";
case NumberIsTooLong:
return "The number is too long; increase SJSONParser::MAX_NUMBER_LENGTH";
case InvalidNumber:
return "This number has an invalid format";
case NumberCouldNotBeConverted:
return "This number could not be converted";
case UnexpectedContentAtEnd:
return "There should not be any more content in this file";
default:
return "Unknown error";
}
}
};
}
| [
"cody.dw.jones@gmail.com"
] | cody.dw.jones@gmail.com |
5d1e10063ae48ec42e039e2eadcc1b62360a0e25 | 55d0224c99ce313246c6d7aada74458923d57822 | /example/ext/boost/mpl/integral_c/integral_constant.cpp | 31e5b2b309104639f1a5c901e56c667c534a5323 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | boostorg/hana | 94535aadaa43cb88f09dde9172a578b2b049dc95 | d3634a3e9ce49a2207bd7870407c05e74ce29ef5 | refs/heads/master | 2023-08-24T11:47:37.357757 | 2023-03-17T14:00:22 | 2023-03-17T14:00:22 | 19,887,998 | 1,480 | 245 | BSL-1.0 | 2023-08-08T05:39:22 | 2014-05-17T14:06:06 | C++ | UTF-8 | C++ | false | false | 880 | cpp | // Copyright Louis Dionne 2013-2022
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <boost/hana/assert.hpp>
#include <boost/hana/equal.hpp>
#include <boost/hana/ext/boost/mpl/integral_c.hpp>
#include <boost/hana/not_equal.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/long.hpp>
namespace hana = boost::hana;
namespace mpl = boost::mpl;
static_assert(hana::value(mpl::integral_c<int, 3>{}) == 3, "");
static_assert(mpl::integral_c<int, 3>::value == 3, "");
BOOST_HANA_CONSTANT_CHECK(hana::equal(mpl::integral_c<int, 3>{}, mpl::int_<3>{}));
BOOST_HANA_CONSTANT_CHECK(hana::equal(mpl::integral_c<int, 3>{}, mpl::long_<3>{}));
BOOST_HANA_CONSTANT_CHECK(hana::not_equal(mpl::integral_c<int, 3>{}, mpl::int_<0>{}));
int main() { }
| [
"ldionne.2@gmail.com"
] | ldionne.2@gmail.com |
9d340cd85c5ade10c289ae8b43e6cbeda3395a51 | 711e5c8b643dd2a93fbcbada982d7ad489fb0169 | /XPSP1/NT/inetcore/outlookexpress/mailnews/rules/rulesmgr.cpp | a3e01a47128fb2a6f17a871b2730fd3437b0552a | [] | no_license | aurantst/windows-XP-SP1 | 629a7763c082fd04d3b881e0d32a1cfbd523b5ce | d521b6360fcff4294ae6c5651c539f1b9a6cbb49 | refs/heads/master | 2023-03-21T01:08:39.870106 | 2020-09-28T08:10:11 | 2020-09-28T08:10:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 75,532 | cpp | ///////////////////////////////////////////////////////////////////////////////
//
// RulesMgr.cpp
//
///////////////////////////////////////////////////////////////////////////////
#include <pch.hxx>
#include "rulesmgr.h"
#include "ruleutil.h"
#include "rule.h"
#include "junkrule.h"
#include <msgfldr.h>
#include <goptions.h>
#include <instance.h>
#include "demand.h"
CRulesManager::CRulesManager() : m_cRef(0), m_dwState(STATE_LOADED_INIT),
m_pMailHead(NULL), m_pNewsHead(NULL), m_pFilterHead(NULL),
m_pIRuleSenderMail(NULL),m_pIRuleSenderNews(NULL),
m_pIRuleJunk(NULL)
{
// Thread Safety
InitializeCriticalSection(&m_cs);
}
CRulesManager::~CRulesManager()
{
AssertSz(m_cRef == 0, "Somebody still has a hold of us!!");
if (NULL != m_pMailHead)
{
_HrFreeRules(RULE_TYPE_MAIL);
}
if (NULL != m_pNewsHead)
{
_HrFreeRules(RULE_TYPE_NEWS);
}
if (NULL != m_pFilterHead)
{
_HrFreeRules(RULE_TYPE_FILTER);
}
SafeRelease(m_pIRuleSenderMail);
SafeRelease(m_pIRuleSenderNews);
SafeRelease(m_pIRuleJunk);
// Thread Safety
DeleteCriticalSection(&m_cs);
}
STDMETHODIMP_(ULONG) CRulesManager::AddRef()
{
return ::InterlockedIncrement(&m_cRef);
}
STDMETHODIMP_(ULONG) CRulesManager::Release()
{
LONG cRef = 0;
cRef = ::InterlockedDecrement(&m_cRef);
if (0 == cRef)
{
delete this;
return cRef;
}
return cRef;
}
STDMETHODIMP CRulesManager::QueryInterface(REFIID riid, void ** ppvObject)
{
HRESULT hr = S_OK;
// Check the incoming params
if (NULL == ppvObject)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*ppvObject = NULL;
if ((riid == IID_IUnknown) || (riid == IID_IOERulesManager))
{
*ppvObject = static_cast<IOERulesManager *>(this);
}
else
{
hr = E_NOINTERFACE;
goto exit;
}
reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CRulesManager::Initialize(DWORD dwFlags)
{
HRESULT hr = S_OK;
// Check the incoming params
if (0 != dwFlags)
{
hr = E_INVALIDARG;
goto exit;
}
// Set the proper return value
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CRulesManager::GetRule(RULEID ridRule, RULE_TYPE type, DWORD dwFlags, IOERule ** ppIRule)
{
HRESULT hr = S_OK;
RULENODE * pNodeWalk = NULL;
IOERule * pIRule = NULL;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if (RULEID_INVALID == ridRule)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize the ougoing params
if (NULL != ppIRule)
{
*ppIRule = NULL;
}
// Check to see if we already loaded the rules
hr = _HrLoadRules(type);
if (FAILED(hr))
{
goto exit;
}
// Check the special types
if (RULEID_SENDERS == ridRule)
{
if (RULE_TYPE_MAIL == type)
{
pIRule = m_pIRuleSenderMail;
}
else if (RULE_TYPE_NEWS == type)
{
pIRule = m_pIRuleSenderNews;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
}
else if (RULEID_JUNK == ridRule)
{
if (RULE_TYPE_MAIL != type)
{
hr = E_INVALIDARG;
goto exit;
}
pIRule = m_pIRuleJunk;
}
else
{
// Walk the proper list
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == type)
{
pNodeWalk = m_pFilterHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
for (; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext)
{
if (ridRule == pNodeWalk->ridRule)
{
pIRule = pNodeWalk->pIRule;
break;
}
}
}
// Did we find something?
if (NULL == pIRule)
{
hr = E_FAIL;
goto exit;
}
// Set the outgoing param
if (NULL != ppIRule)
{
*ppIRule = pIRule;
(*ppIRule)->AddRef();
}
// Set the proper return value
hr = S_OK;
exit:
// Thread Safety
LeaveCriticalSection(&m_cs);
return hr;
}
STDMETHODIMP CRulesManager::FindRule(LPCSTR pszRuleName, RULE_TYPE type, IOERule ** ppIRule)
{
HRESULT hr = S_OK;
RULENODE * pNodeWalk = NULL;
PROPVARIANT propvar;
ZeroMemory(&propvar, sizeof(propvar));
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if ((NULL == pszRuleName) || (NULL == ppIRule))
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize the ougoing params
*ppIRule = NULL;
// Check to see if we already loaded the rules
hr = _HrLoadRules(type);
if (FAILED(hr))
{
goto exit;
}
// Walk the proper list
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == type)
{
pNodeWalk = m_pFilterHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
while (NULL != pNodeWalk)
{
// Check to see if the name of the rule is the same
hr = pNodeWalk->pIRule->GetProp(RULE_PROP_NAME , 0, &propvar);
if (FAILED(hr))
{
continue;
}
if (0 == lstrcmpi(propvar.pszVal, pszRuleName))
{
*ppIRule = pNodeWalk->pIRule;
(*ppIRule)->AddRef();
break;
}
// Move to the next one
PropVariantClear(&propvar);
pNodeWalk = pNodeWalk->pNext;
}
// Set the proper return value
if (NULL == pNodeWalk)
{
hr = E_FAIL;
}
else
{
hr = S_OK;
}
exit:
PropVariantClear(&propvar);
// Thread Safety
LeaveCriticalSection(&m_cs);
return hr;
}
STDMETHODIMP CRulesManager::GetRules(DWORD dwFlags, RULE_TYPE typeRule, RULEINFO ** ppinfoRule, ULONG * pcpinfoRule)
{
HRESULT hr = S_OK;
ULONG cpinfoRule = 0;
RULEINFO * pinfoRuleAlloc = NULL;
IOERule * pIRuleSender = NULL;
RULENODE * prnodeList = NULL;
RULENODE * prnodeWalk = NULL;
ULONG ulIndex = 0;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if (NULL == ppinfoRule)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize the outgoing param
*ppinfoRule = NULL;
if (NULL != pcpinfoRule)
{
*pcpinfoRule = 0;
}
// Check to see if we already loaded the rules
hr = _HrLoadRules(typeRule);
if (FAILED(hr))
{
goto exit;
}
// Figure out which type of rules to work on
switch (typeRule)
{
case RULE_TYPE_MAIL:
prnodeList = m_pMailHead;
break;
case RULE_TYPE_NEWS:
prnodeList = m_pNewsHead;
break;
case RULE_TYPE_FILTER:
prnodeList = m_pFilterHead;
break;
default:
hr = E_INVALIDARG;
goto exit;
}
// Count the number of rules
prnodeWalk = prnodeList;
for (cpinfoRule = 0; NULL != prnodeWalk; prnodeWalk = prnodeWalk->pNext)
{
// Check to see if we should add this item
if (RULE_TYPE_FILTER == typeRule)
{
if (0 != (dwFlags & GETF_POP3))
{
if (RULEID_VIEW_DOWNLOADED == prnodeWalk->ridRule)
{
continue;
}
}
}
cpinfoRule++;
}
// Allocate space to hold the rules
if (0 != cpinfoRule)
{
hr = HrAlloc((VOID **) &pinfoRuleAlloc, cpinfoRule * sizeof(*pinfoRuleAlloc));
if (FAILED(hr))
{
goto exit;
}
// Initialize it to known values
ZeroMemory(pinfoRuleAlloc, cpinfoRule * sizeof(*pinfoRuleAlloc));
// Fill up the info
for (ulIndex = 0, prnodeWalk = prnodeList; NULL != prnodeWalk; prnodeWalk = prnodeWalk->pNext)
{
// Check to see if we should add this item
if (RULE_TYPE_FILTER == typeRule)
{
if (0 != (dwFlags & GETF_POP3))
{
if (RULEID_VIEW_DOWNLOADED == prnodeWalk->ridRule)
{
continue;
}
}
}
pinfoRuleAlloc[ulIndex].ridRule = prnodeWalk->ridRule;
pinfoRuleAlloc[ulIndex].pIRule = prnodeWalk->pIRule;
pinfoRuleAlloc[ulIndex].pIRule->AddRef();
ulIndex++;
}
}
// Set the outgoing values
*ppinfoRule = pinfoRuleAlloc;
pinfoRuleAlloc = NULL;
if (NULL != pcpinfoRule)
{
*pcpinfoRule = cpinfoRule;
}
// Set the proper return type
hr = S_OK;
exit:
SafeMemFree(pinfoRuleAlloc);
// Thread Safety
LeaveCriticalSection(&m_cs);
return S_OK;
}
STDMETHODIMP CRulesManager::SetRules(DWORD dwFlags, RULE_TYPE typeRule, RULEINFO * pinfoRule, ULONG cpinfoRule)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
IOERule * pIRuleSender = NULL;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if ((NULL == pinfoRule) && (0 != cpinfoRule))
{
hr = E_INVALIDARG;
goto exit;
}
// Check to see if we already loaded the rules
hr = _HrLoadRules(typeRule);
if (FAILED(hr))
{
goto exit;
}
// Do we have to free all the current rules
if (0 != (dwFlags & SETF_SENDER))
{
if (RULE_TYPE_MAIL == typeRule)
{
SafeRelease(m_pIRuleSenderMail);
m_pIRuleSenderMail = pinfoRule->pIRule;
if (NULL != m_pIRuleSenderMail)
{
m_pIRuleSenderMail->AddRef();
}
}
else if (RULE_TYPE_NEWS == typeRule)
{
SafeRelease(m_pIRuleSenderNews);
m_pIRuleSenderNews = pinfoRule->pIRule;
if (NULL != m_pIRuleSenderNews)
{
m_pIRuleSenderNews->AddRef();
}
}
else
{
hr = E_INVALIDARG;
goto exit;
}
}
else if (0 != (dwFlags & SETF_JUNK))
{
if (RULE_TYPE_MAIL != typeRule)
{
hr = E_INVALIDARG;
goto exit;
}
SafeRelease(m_pIRuleJunk);
m_pIRuleJunk = pinfoRule->pIRule;
if (NULL != m_pIRuleJunk)
{
m_pIRuleJunk->AddRef();
}
}
else
{
if (0 != (dwFlags & SETF_CLEAR))
{
_HrFreeRules(typeRule);
}
// for each new rule
for (ulIndex = 0; ulIndex < cpinfoRule; ulIndex++)
{
if (0 != (dwFlags & SETF_REPLACE))
{
// Add the rule to the list
hr = _HrReplaceRule(pinfoRule[ulIndex].ridRule, pinfoRule[ulIndex].pIRule, typeRule);
if (FAILED(hr))
{
goto exit;
}
}
else
{
// Add the rule to the list
hr = _HrAddRule(pinfoRule[ulIndex].ridRule, pinfoRule[ulIndex].pIRule, typeRule);
if (FAILED(hr))
{
goto exit;
}
}
}
}
// Save the rules
hr = _HrSaveRules(typeRule);
if (FAILED(hr))
{
goto exit;
}
if ((0 == (dwFlags & SETF_SENDER)) && (0 == (dwFlags & SETF_JUNK)))
{
// Fix up the rule ids
hr = _HrFixupRuleInfo(typeRule, pinfoRule, cpinfoRule);
if (FAILED(hr))
{
goto exit;
}
}
// Set the proper return value
hr = S_OK;
exit:
// Thread Safety
LeaveCriticalSection(&m_cs);
return hr;
}
STDMETHODIMP CRulesManager::EnumRules(DWORD dwFlags, RULE_TYPE type, IOEEnumRules ** ppIEnumRules)
{
HRESULT hr = S_OK;
CEnumRules * pEnumRules = NULL;
RULENODE rnode;
RULENODE * prnode = NULL;
IOERule * pIRuleSender = NULL;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if (NULL == ppIEnumRules)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing params
*ppIEnumRules = NULL;
// Check to see if we already loaded the rules
hr = _HrLoadRules(type);
if (FAILED(hr))
{
goto exit;
}
// Create the rules enumerator object
pEnumRules = new CEnumRules;
if (NULL == pEnumRules)
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Initialize the rules enumerator
if (0 != (dwFlags & ENUMF_SENDER))
{
if (RULE_TYPE_MAIL == type)
{
pIRuleSender = m_pIRuleSenderMail;
}
else if (RULE_TYPE_NEWS == type)
{
pIRuleSender = m_pIRuleSenderNews;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
if (NULL != pIRuleSender)
{
ZeroMemory(&rnode, sizeof(rnode));
rnode.pIRule = pIRuleSender;
prnode = &rnode;
}
else
{
prnode = NULL;
}
}
else
{
if (RULE_TYPE_MAIL == type)
{
prnode = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
prnode = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == type)
{
prnode = m_pFilterHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
}
hr = pEnumRules->_HrInitialize(0, type, prnode);
if (FAILED(hr))
{
goto exit;
}
// Get the rules enumerator interface
hr = pEnumRules->QueryInterface(IID_IOEEnumRules, (void **) ppIEnumRules);
if (FAILED(hr))
{
goto exit;
}
pEnumRules = NULL;
hr = S_OK;
exit:
if (NULL != pEnumRules)
{
delete pEnumRules;
}
// Thread Safety
LeaveCriticalSection(&m_cs);
return hr;
}
STDMETHODIMP CRulesManager::ExecRules(DWORD dwFlags, RULE_TYPE type, IOEExecRules ** ppIExecRules)
{
HRESULT hr = S_OK;
CExecRules * pExecRules = NULL;
RULENODE rnode;
RULENODE * prnodeList = NULL;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check the incoming params
if (NULL == ppIExecRules)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing params
*ppIExecRules = NULL;
// Check to see if we already loaded the rules
hr = _HrLoadRules(type);
if (FAILED(hr))
{
goto exit;
}
// Create the rules enumerator object
pExecRules = new CExecRules;
if (NULL == pExecRules)
{
hr = E_OUTOFMEMORY;
goto exit;
}
if (RULE_TYPE_MAIL == type)
{
prnodeList = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
prnodeList = m_pNewsHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize the rules enumerator
hr = pExecRules->_HrInitialize(ERF_ONLY_ENABLED | ERF_ONLY_VALID, prnodeList);
if (FAILED(hr))
{
goto exit;
}
// Get the rules enumerator interface
hr = pExecRules->QueryInterface(IID_IOEExecRules, (void **) ppIExecRules);
if (FAILED(hr))
{
goto exit;
}
pExecRules = NULL;
hr = S_OK;
exit:
if (NULL != pExecRules)
{
delete pExecRules;
}
// Thread Safety
LeaveCriticalSection(&m_cs);
return hr;
}
STDMETHODIMP CRulesManager::ExecuteRules(RULE_TYPE typeRule, DWORD dwFlags, HWND hwndUI, IOEExecRules * pIExecRules,
MESSAGEINFO * pMsgInfo, IMessageFolder * pFolder, IMimeMessage * pIMMsg)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
RULENODE * prnodeHead = NULL;
PROPVARIANT propvar = {0};
ACT_ITEM * pActions = NULL;
ULONG cActions = 0;
ACT_ITEM * pActionsList = NULL;
ULONG cActionsList = 0;
ACT_ITEM * pActionsNew = NULL;
ULONG cActionsNew = 0;
BOOL fStopProcessing = FALSE;
BOOL fMatch = FALSE;
// Thread Safety
EnterCriticalSection(&m_cs);
// Check incoming params
if ((NULL == pIExecRules) || (NULL == pMsgInfo))
{
hr = E_INVALIDARG;
goto exit;
}
// Check to see if we already loaded the rules
hr = _HrLoadRules(typeRule);
if (FAILED(hr))
{
goto exit;
}
// Figure out which list to use
switch (typeRule)
{
case RULE_TYPE_MAIL:
prnodeHead = m_pMailHead;
break;
case RULE_TYPE_NEWS:
prnodeHead = m_pNewsHead;
break;
default:
Assert(FALSE);
hr = E_INVALIDARG;
goto exit;
}
// For each rule
for (; NULL != prnodeHead; prnodeHead = prnodeHead->pNext)
{
// Skip if we don't have a rule
if (NULL == prnodeHead)
{
continue;
}
// Skip if it isn't enabled
hr = prnodeHead->pIRule->GetProp(RULE_PROP_DISABLED, 0, &propvar);
Assert(VT_BOOL == propvar.vt);
if (FAILED(hr) || (FALSE != propvar.boolVal))
{
continue;
}
// Execute rule
hr = prnodeHead->pIRule->Evaluate(pMsgInfo->pszAcctId, pMsgInfo, pFolder,
NULL, pIMMsg, pMsgInfo->cbMessage, &pActions, &cActions);
if (FAILED(hr))
{
goto exit;
}
// Did we have a match
if (S_OK == hr)
{
// We've matched at least once
fMatch = TRUE;
// If these are server actions
if ((1 == cActions) && ((ACT_TYPE_DELETESERVER == pActions[ulIndex].type) ||
(ACT_TYPE_DONTDOWNLOAD == pActions[ulIndex].type)))
{
// If this is our only action
if (0 == cActionsList)
{
// Save the action
pActionsList = pActions;
pActions = NULL;
cActionsList = cActions;
// We are done
fStopProcessing = TRUE;
}
else
{
// We already have to do something with it
// so skip over this action
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
continue;
}
}
else
{
// Should we stop after merging these?
for (ulIndex = 0; ulIndex < cActions; ulIndex++)
{
if (ACT_TYPE_STOP == pActions[ulIndex].type)
{
fStopProcessing = TRUE;
break;
}
}
// Merge these items with the previous ones
hr = RuleUtil_HrMergeActions(pActionsList, cActionsList, pActions, cActions, &pActionsNew, &cActionsNew);
if (FAILED(hr))
{
goto exit;
}
// Free up the previous ones
RuleUtil_HrFreeActionsItem(pActionsList, cActionsList);
SafeMemFree(pActionsList);
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
// Save off the new ones
pActionsList = pActionsNew;
pActionsNew = NULL;
cActionsList = cActionsNew;
}
// Should we continue...
if (FALSE != fStopProcessing)
{
break;
}
}
}
// Apply the actions if need be
if ((FALSE != fMatch) && (NULL != pActionsList) && (0 != cActionsList))
{
if (FAILED(RuleUtil_HrApplyActions(hwndUI, pIExecRules, pMsgInfo, pFolder, pIMMsg,
(RULE_TYPE_MAIL != typeRule) ? DELETE_MESSAGE_NOTRASHCAN : 0, pActionsList, cActionsList, NULL, NULL)))
{
hr = E_FAIL;
goto exit;
}
}
// Set the return value
hr = (FALSE != fMatch) ? S_OK : S_FALSE;
exit:
// Thread Safety
RuleUtil_HrFreeActionsItem(pActionsNew, cActionsNew);
SafeMemFree(pActionsNew);
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
RuleUtil_HrFreeActionsItem(pActionsList, cActionsList);
SafeMemFree(pActionsList);
LeaveCriticalSection(&m_cs);
return hr;
}
HRESULT CRulesManager::_HrLoadRules(RULE_TYPE type)
{
HRESULT hr = S_OK;
LPCSTR pszSubKey = NULL;
LPSTR pszOrderAlloc = NULL;
LPSTR pszOrder = NULL;
LPSTR pszWalk = NULL;
HKEY hkeyRoot = NULL;
DWORD dwDisp = 0;
LONG lErr = 0;
ULONG cbData = 0;
IOERule * pIRule = NULL;
DWORD dwData = 0;
CHAR rgchRulePath[MAX_PATH];
ULONG cchRulePath = 0;
PROPVARIANT propvar = {0};
RULEID ridRule = RULEID_INVALID;
CHAR rgchTagBuff[CCH_INDEX_MAX + 2];
// Check to see if we're already initialized
if (RULE_TYPE_MAIL == type)
{
if (0 != (m_dwState & STATE_LOADED_MAIL))
{
hr = S_FALSE;
goto exit;
}
// Make sure we loaded the sender rules
_HrLoadSenders();
// Make sure we loaded the junk rule
if (0 != (g_dwAthenaMode & MODE_JUNKMAIL))
{
_HrLoadJunk();
}
// Set the key path
pszSubKey = c_szRulesMail;
}
else if (RULE_TYPE_NEWS == type)
{
if (0 != (m_dwState & STATE_LOADED_NEWS))
{
hr = S_FALSE;
goto exit;
}
// Make sure we loaded the sender rules
_HrLoadSenders();
// Set the key path
pszSubKey = c_szRulesNews;
}
else if (RULE_TYPE_FILTER == type)
{
if (0 != (m_dwState & STATE_LOADED_FILTERS))
{
hr = S_FALSE;
goto exit;
}
// Set the key path
pszSubKey = c_szRulesFilter;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
// Check to see if the Rule node already exists
lErr = AthUserCreateKey(pszSubKey, KEY_ALL_ACCESS, &hkeyRoot, &dwDisp);
if (ERROR_SUCCESS != lErr)
{
hr = HRESULT_FROM_WIN32(lErr);
goto exit;
}
// Check the current version
cbData = sizeof(dwData);
lErr = RegQueryValueEx(hkeyRoot, c_szRulesVersion, NULL, NULL, (BYTE *) &dwData, &cbData);
if (ERROR_SUCCESS != lErr)
{
// Push out the correct rules manager version
dwData = RULESMGR_VERSION;
lErr = RegSetValueEx(hkeyRoot, c_szRulesVersion, 0, REG_DWORD, (CONST BYTE *) &dwData, sizeof(dwData));
if (ERROR_SUCCESS != lErr)
{
hr = HRESULT_FROM_WIN32(lErr);
goto exit;
}
}
Assert(RULESMGR_VERSION == dwData);
// Create the default rules if needed
hr = RuleUtil_HrUpdateDefaultRules(type);
if (FAILED(hr))
{
goto exit;
}
// Figure out the size of the order
lErr = AthUserGetValue(pszSubKey, c_szRulesOrder, NULL, NULL, &cbData);
if ((ERROR_SUCCESS != lErr) && (ERROR_FILE_NOT_FOUND != lErr))
{
hr = E_FAIL;
goto exit;
}
if (ERROR_FILE_NOT_FOUND != lErr)
{
// Allocate the space to hold the order
hr = HrAlloc((void **) &pszOrderAlloc, cbData);
if (FAILED(hr))
{
goto exit;
}
// Get the order from the registry
lErr = AthUserGetValue(pszSubKey, c_szRulesOrder, NULL, (LPBYTE) pszOrderAlloc, &cbData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Build up the rule registry path
lstrcpy(rgchRulePath, pszSubKey);
lstrcat(rgchRulePath, g_szBackSlash);
cchRulePath = lstrlen(rgchRulePath);
// Initialize the rule tag buffer
rgchTagBuff[0] = '0';
rgchTagBuff[1] = 'X';
// Parse the order string to create the rules
pszOrder = pszOrderAlloc;
while ('\0' != *pszOrder)
{
SafeRelease(pIRule);
// Create a new rule
hr = HrCreateRule(&pIRule);
if (FAILED(hr))
{
goto exit;
}
// Find the name of the new rule
pszWalk = StrStr(pszOrder, g_szSpace);
if (NULL != pszWalk)
{
*pszWalk = '\0';
pszWalk++;
}
// Build the path to the rule
lstrcpy(rgchRulePath + cchRulePath, pszOrder);
// Load the rule
hr = pIRule->LoadReg(rgchRulePath);
if (SUCCEEDED(hr))
{
// Build the correct hex string
lstrcpy(rgchTagBuff + 2, pszOrder);
// Get the new rule handle
ridRule = ( ( RULEID ) 0);
SideAssert(FALSE != StrToIntEx(rgchTagBuff, STIF_SUPPORT_HEX, (INT *) &ridRule));
// Add the new rule to the manager
hr = _HrAddRule(ridRule, pIRule, type);
if (FAILED(hr))
{
goto exit;
}
}
// Move to the next item in the order
if (NULL == pszWalk)
{
pszOrder += lstrlen(pszOrder);
}
else
{
pszOrder = pszWalk;
}
}
}
// We've loaded the rules successfully
if (RULE_TYPE_MAIL == type)
{
m_dwState |= STATE_LOADED_MAIL;
}
else if (RULE_TYPE_NEWS == type)
{
m_dwState |= STATE_LOADED_NEWS;
}
else
{
m_dwState |= STATE_LOADED_FILTERS;
}
// Set the return value
hr = S_OK;
exit:
SafeMemFree(pszOrderAlloc);
SafeRelease(pIRule);
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrLoadSenders(VOID)
{
HRESULT hr = S_OK;
HKEY hkeyRoot = NULL;
DWORD dwDisp = 0;
DWORD dwData = 0;
LONG lErr = 0;
ULONG cbData = 0;
IOERule * pIRule = NULL;
CHAR rgchSenderPath[MAX_PATH];
// Do we have anything to do?
if (0 != (m_dwState & STATE_LOADED_SENDERS))
{
hr = S_FALSE;
goto exit;
}
// Let's get access to the sender root key
lErr = AthUserCreateKey(c_szSenders, KEY_ALL_ACCESS, &hkeyRoot, &dwDisp);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Are the senders the correct version?
cbData = sizeof(dwData);
lErr = RegQueryValueEx(hkeyRoot, c_szSendersVersion, 0, NULL, (BYTE *) &dwData, &cbData);
if ((ERROR_SUCCESS != lErr) && (ERROR_FILE_NOT_FOUND != lErr))
{
hr = E_FAIL;
goto exit;
}
if (ERROR_FILE_NOT_FOUND == lErr)
{
dwData = RULESMGR_VERSION;
cbData = sizeof(dwData);
lErr = RegSetValueEx(hkeyRoot, c_szSendersVersion, 0, REG_DWORD, (BYTE *) &dwData, cbData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
}
Assert(dwData == RULESMGR_VERSION);
// Is there anything to do?
if (REG_CREATED_NEW_KEY != dwDisp)
{
// Create the path to the sender
lstrcpy(rgchSenderPath, c_szSenders);
lstrcat(rgchSenderPath, g_szBackSlash);
lstrcat(rgchSenderPath, c_szMailDir);
// Create the mail sender rule
hr = RuleUtil_HrLoadSender(rgchSenderPath, 0, &pIRule);
if (FAILED(hr))
{
goto exit;
}
// Save the loaded rule
if (S_OK == hr)
{
m_pIRuleSenderMail = pIRule;
pIRule = NULL;
}
// Create the path to the sender
lstrcpy(rgchSenderPath, c_szSenders);
lstrcat(rgchSenderPath, g_szBackSlash);
lstrcat(rgchSenderPath, c_szNewsDir);
// Create the news sender rule
hr = RuleUtil_HrLoadSender(rgchSenderPath, 0, &pIRule);
if (FAILED(hr))
{
goto exit;
}
// Save the loaded rule
if (S_OK == hr)
{
m_pIRuleSenderNews = pIRule;
pIRule = NULL;
}
}
// Note that we've loaded the senders
m_dwState |= STATE_LOADED_SENDERS;
// Set the return value
hr = S_OK;
exit:
SafeRelease(pIRule);
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrLoadJunk(VOID)
{
HRESULT hr = S_OK;
HKEY hkeyRoot = NULL;
DWORD dwDisp = 0;
DWORD dwData = 0;
ULONG cbData = 0;
LONG lErr = 0;
IOERule * pIRule = NULL;
// Do we have anything to do?
if (0 != (m_dwState & STATE_LOADED_JUNK))
{
hr = S_FALSE;
goto exit;
}
// Let's get access to the Junk mail root key
lErr = AthUserCreateKey(c_szRulesJunkMail, KEY_ALL_ACCESS, &hkeyRoot, &dwDisp);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Is the junk mail the correct version?
cbData = sizeof(dwData);
lErr = RegQueryValueEx(hkeyRoot, c_szRulesVersion, 0, NULL, (BYTE *) &dwData, &cbData);
if ((ERROR_SUCCESS != lErr) && (ERROR_FILE_NOT_FOUND != lErr))
{
hr = E_FAIL;
goto exit;
}
if (ERROR_FILE_NOT_FOUND == lErr)
{
dwData = RULESMGR_VERSION;
cbData = sizeof(dwData);
lErr = RegSetValueEx(hkeyRoot, c_szRulesVersion, 0, REG_DWORD, (BYTE *) &dwData, cbData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
}
Assert(dwData == RULESMGR_VERSION);
// Create the rule
hr = HrCreateJunkRule(&pIRule);
if (FAILED(hr))
{
goto exit;
}
// Load the junk rule
hr = pIRule->LoadReg(c_szRulesJunkMail);
if (FAILED(hr))
{
goto exit;
}
m_pIRuleJunk = pIRule;
pIRule = NULL;
// Note that we've loaded the junk rule
m_dwState |= STATE_LOADED_JUNK;
// Set the return value
hr = S_OK;
exit:
SafeRelease(pIRule);
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrSaveRules(RULE_TYPE type)
{
HRESULT hr = S_OK;
LPCSTR pszRegPath = NULL;
DWORD dwData = 0;
LONG lErr = 0;
RULENODE * pRuleNode = NULL;
RULENODE * pNodeWalk = NULL;
ULONG cpIRule = 0;
LPSTR pszOrder = NULL;
HKEY hkeyRoot = NULL;
DWORD dwIndex = 0;
CHAR rgchOrder[CCH_INDEX_MAX];
ULONG cchOrder = 0;
CHAR rgchRulePath[MAX_PATH];
ULONG cchRulePath = 0;
BOOL fNewRule = FALSE;
ULONG ulRuleID = 0;
HKEY hkeyDummy = NULL;
LONG cSubKeys = 0;
// Make sure we loaded the sender rules
_HrSaveSenders();
// Make sure we loaded the junk rules
if (0 != (g_dwAthenaMode & MODE_JUNKMAIL))
{
_HrSaveJunk();
}
// Check to see if we have anything to save
if (RULE_TYPE_MAIL == type)
{
if (0 == (m_dwState & STATE_LOADED_MAIL))
{
hr = S_FALSE;
goto exit;
}
// Set the key path
pszRegPath = c_szRulesMail;
pRuleNode = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
if (0 == (m_dwState & STATE_LOADED_NEWS))
{
hr = S_FALSE;
goto exit;
}
// Set the key path
pszRegPath = c_szRulesNews;
pRuleNode = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == type)
{
if (0 == (m_dwState & STATE_LOADED_FILTERS))
{
hr = S_FALSE;
goto exit;
}
// Set the key path
pszRegPath = c_szRulesFilter;
pRuleNode = m_pFilterHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
lErr = AthUserCreateKey(pszRegPath, KEY_ALL_ACCESS, &hkeyRoot, &dwData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Save out the rules version
dwData = RULESMGR_VERSION;
lErr = RegSetValueEx(hkeyRoot, c_szRulesVersion, 0, REG_DWORD, (CONST BYTE *) &dwData, sizeof(dwData));
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Get the number of rules
cpIRule = 0;
for (pNodeWalk = pRuleNode; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext)
{
cpIRule++;
}
// Allocate space to hold the order
hr = HrAlloc((void **) &pszOrder, (cpIRule * CCH_INDEX_MAX) + 1);
if (FAILED(hr))
{
goto exit;
}
pszOrder[0] = '\0';
// Delete all the old rules
lErr = SHQueryInfoKey(hkeyRoot, (LPDWORD) (&cSubKeys), NULL, NULL, NULL);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Delete all the old rules
for (cSubKeys--; cSubKeys >= 0; cSubKeys--)
{
cchOrder = sizeof(rgchOrder);
lErr = SHEnumKeyEx(hkeyRoot, cSubKeys, rgchOrder, &cchOrder);
if (ERROR_NO_MORE_ITEMS == lErr)
{
break;
}
if (ERROR_SUCCESS != lErr)
{
continue;
}
SHDeleteKey(hkeyRoot, rgchOrder);
}
// Delete the old order string
RegDeleteValue(hkeyRoot, c_szRulesOrder);
// Build up the rule registry path
lstrcpy(rgchRulePath, pszRegPath);
lstrcat(rgchRulePath, g_szBackSlash);
cchRulePath = lstrlen(rgchRulePath);
// Write out the rules with good tags
for (dwIndex = 0, pNodeWalk = pRuleNode; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext, dwIndex++)
{
if (RULEID_INVALID == pNodeWalk->ridRule)
{
fNewRule = TRUE;
continue;
}
// Get a new index from the order
wsprintf(rgchOrder, "%03X", pNodeWalk->ridRule);
// Build the path to the rule
lstrcpy(rgchRulePath + cchRulePath, rgchOrder);
// Save the rule
hr = pNodeWalk->pIRule->SaveReg(rgchRulePath, TRUE);
if (FAILED(hr))
{
goto exit;
}
}
// Fill in the new tags
if (FALSE != fNewRule)
{
ulRuleID = 0;
// Write out the updated rule
for (dwIndex = 0, pNodeWalk = pRuleNode; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext, dwIndex++)
{
if (RULEID_INVALID != pNodeWalk->ridRule)
{
continue;
}
// Find the first open entry
for (; ulRuleID < PtrToUlong(RULEID_JUNK); ulRuleID++)
{
// Get a new index from the order
wsprintf(rgchOrder, "%03X", ulRuleID);
lErr = RegOpenKeyEx(hkeyRoot, rgchOrder, 0, KEY_READ, &hkeyDummy);
if (ERROR_SUCCESS == lErr)
{
RegCloseKey(hkeyDummy);
}
else
{
break;
}
}
if (ERROR_FILE_NOT_FOUND != lErr)
{
hr = E_FAIL;
goto exit;
}
// Set the rule tag
pNodeWalk->ridRule = (RULEID) IntToPtr(ulRuleID);
// Build the path to the rule
lstrcpy(rgchRulePath + cchRulePath, rgchOrder);
// Save the rule
hr = pNodeWalk->pIRule->SaveReg(rgchRulePath, TRUE);
if (FAILED(hr))
{
goto exit;
}
}
}
// Write out the new order string
for (dwIndex = 0, pNodeWalk = pRuleNode; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext, dwIndex++)
{
// Get a new index from the order
wsprintf(rgchOrder, "%03X", pNodeWalk->ridRule);
// Add rule to the order
if ('\0' != pszOrder[0])
{
lstrcat(pszOrder, g_szSpace);
}
lstrcat(pszOrder, rgchOrder);
}
// Save the order string
if (ERROR_SUCCESS != AthUserSetValue(pszRegPath, c_szRulesOrder, REG_SZ, (CONST BYTE *) pszOrder, lstrlen(pszOrder) + 1))
{
hr = E_FAIL;
goto exit;
}
// Set the return value
hr = S_OK;
exit:
SafeMemFree(pszOrder);
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrSaveSenders(VOID)
{
HRESULT hr = S_OK;
DWORD dwData = 0;
LONG lErr = 0;
HKEY hkeyRoot = NULL;
DWORD dwIndex = 0;
CHAR rgchSenderPath[MAX_PATH];
// Check to see if we have anything to save
if (0 == (m_dwState & STATE_LOADED_SENDERS))
{
hr = S_FALSE;
goto exit;
}
lErr = AthUserCreateKey(c_szSenders, KEY_ALL_ACCESS, &hkeyRoot, &dwData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Save out the senders version
dwData = RULESMGR_VERSION;
lErr = RegSetValueEx(hkeyRoot, c_szSendersVersion, 0, REG_DWORD, (CONST BYTE *) &dwData, sizeof(dwData));
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Delete the old sender list
SHDeleteKey(hkeyRoot, c_szMailDir);
// Build up the sender registry path
lstrcpy(rgchSenderPath, c_szSenders);
lstrcat(rgchSenderPath, g_szBackSlash);
lstrcat(rgchSenderPath, c_szMailDir);
// Save the rule
if (NULL != m_pIRuleSenderMail)
{
hr = m_pIRuleSenderMail->SaveReg(rgchSenderPath, TRUE);
if (FAILED(hr))
{
goto exit;
}
}
// Delete the old sender list
SHDeleteKey(hkeyRoot, c_szNewsDir);
// Build up the sender registry path
lstrcpy(rgchSenderPath, c_szSenders);
lstrcat(rgchSenderPath, g_szBackSlash);
lstrcat(rgchSenderPath, c_szNewsDir);
// Save the rule
if (NULL != m_pIRuleSenderNews)
{
hr = m_pIRuleSenderNews->SaveReg(rgchSenderPath, TRUE);
if (FAILED(hr))
{
goto exit;
}
}
// Set the return value
hr = S_OK;
exit:
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrSaveJunk(VOID)
{
HRESULT hr = S_OK;
DWORD dwData = 0;
LONG lErr = 0;
HKEY hkeyRoot = NULL;
DWORD dwIndex = 0;
CHAR rgchSenderPath[MAX_PATH];
// Check to see if we have anything to save
if (0 == (m_dwState & STATE_LOADED_JUNK))
{
hr = S_FALSE;
goto exit;
}
lErr = AthUserCreateKey(c_szRulesJunkMail, KEY_ALL_ACCESS, &hkeyRoot, &dwData);
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Save out the senders version
dwData = RULESMGR_VERSION;
lErr = RegSetValueEx(hkeyRoot, c_szRulesVersion, 0, REG_DWORD, (CONST BYTE *) &dwData, sizeof(dwData));
if (ERROR_SUCCESS != lErr)
{
hr = E_FAIL;
goto exit;
}
// Save the rule
if (NULL != m_pIRuleJunk)
{
hr = m_pIRuleJunk->SaveReg(c_szRulesJunkMail, TRUE);
if (FAILED(hr))
{
goto exit;
}
}
// Set the return value
hr = S_OK;
exit:
if (NULL != hkeyRoot)
{
RegCloseKey(hkeyRoot);
}
return hr;
}
HRESULT CRulesManager::_HrFreeRules(RULE_TYPE type)
{
HRESULT hr = S_OK;
RULENODE * pNodeWalk = NULL;
RULENODE * pNodeNext = NULL;
// Initialize the params
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
pNodeNext = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
pNodeNext = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == type)
{
pNodeWalk = m_pFilterHead;
pNodeNext = m_pFilterHead;
}
else
{
hr = E_FAIL;
goto exit;
}
// Walk the list and free each item
while (NULL != pNodeWalk)
{
// Save off the next item
pNodeNext = pNodeWalk->pNext;
// Release the rule
AssertSz(NULL != pNodeWalk->pIRule, "Where the heck is the rule???");
pNodeWalk->pIRule->Release();
// Free up the node
delete pNodeWalk;
// Move to the next item
pNodeWalk = pNodeNext;
}
// Clear out the list head
if (RULE_TYPE_MAIL == type)
{
m_pMailHead = NULL;
}
else if (RULE_TYPE_NEWS == type)
{
m_pNewsHead = NULL;
}
else
{
m_pFilterHead = NULL;
}
exit:
// Set the return param
return hr;
}
HRESULT CRulesManager::_HrAddRule(RULEID ridRule, IOERule * pIRule, RULE_TYPE type)
{
HRESULT hr = S_OK;
RULENODE * pRuleNode = NULL;
RULENODE * pNodeWalk = NULL;
// Check incoming params
if (NULL == pIRule)
{
hr = E_INVALIDARG;
goto exit;
}
// Create a new rule node
pRuleNode = new RULENODE;
if (NULL == pRuleNode)
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Initialize the node
pRuleNode->pNext = NULL;
pRuleNode->ridRule = ridRule;
pRuleNode->pIRule = pIRule;
pRuleNode->pIRule->AddRef();
// Add the node to the proper list
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
}
else
{
pNodeWalk = m_pFilterHead;
}
if (NULL == pNodeWalk)
{
if (RULE_TYPE_MAIL == type)
{
m_pMailHead = pRuleNode;
}
else if (RULE_TYPE_NEWS == type)
{
m_pNewsHead = pRuleNode;
}
else
{
m_pFilterHead = pRuleNode;
}
pRuleNode = NULL;
}
else
{
while (NULL != pNodeWalk->pNext)
{
pNodeWalk = pNodeWalk->pNext;
}
pNodeWalk->pNext = pRuleNode;
pRuleNode = NULL;
}
// Set return values
hr = S_OK;
exit:
if (NULL != pRuleNode)
{
pRuleNode->pIRule->Release();
delete pRuleNode;
}
return hr;
}
HRESULT CRulesManager::_HrReplaceRule(RULEID ridRule, IOERule * pIRule, RULE_TYPE type)
{
HRESULT hr = S_OK;
RULENODE * pNodeWalk = NULL;
RULENODE * pNodePrev = NULL;
// Nothing to do if we don't have a rule
if (NULL == pIRule)
{
hr = E_FAIL;
goto exit;
}
// Initialize the params
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
}
else
{
pNodeWalk = m_pFilterHead;
}
// Walk the list and free each item
for (; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext)
{
if (pNodeWalk->ridRule == ridRule)
{
// We found it
break;
}
}
// Couldn't find the rule in the list
if (NULL == pNodeWalk)
{
hr = E_FAIL;
goto exit;
}
// Replace the rule
SafeRelease(pNodeWalk->pIRule);
pNodeWalk->pIRule = pIRule;
pNodeWalk->pIRule->AddRef();
// Set the return param
hr = S_OK;
exit:
return hr;
}
HRESULT CRulesManager::_HrRemoveRule(IOERule * pIRule, RULE_TYPE type)
{
HRESULT hr = S_OK;
RULENODE * pNodeWalk = NULL;
RULENODE * pNodePrev = NULL;
// Initialize the params
if (RULE_TYPE_MAIL == type)
{
pNodeWalk = m_pMailHead;
}
else if (RULE_TYPE_NEWS == type)
{
pNodeWalk = m_pNewsHead;
}
else
{
pNodeWalk = m_pFilterHead;
}
// Walk the list and free each item
pNodePrev = NULL;
while (NULL != pNodeWalk)
{
if (pNodeWalk->pIRule == pIRule)
{
// We found it
break;
}
// Save off the next item
pNodePrev = pNodeWalk;
// Move to the next item
pNodeWalk = pNodeWalk->pNext;
}
// Couldn't find the rule in the list
if (NULL == pNodeWalk)
{
hr = E_FAIL;
goto exit;
}
if (NULL == pNodePrev)
{
// Clear out the list head
if (RULE_TYPE_MAIL == type)
{
m_pMailHead = pNodeWalk->pNext;
}
else if (RULE_TYPE_NEWS == type)
{
m_pNewsHead = pNodeWalk->pNext;
}
else
{
m_pFilterHead = pNodeWalk->pNext;
}
}
else
{
pNodePrev->pNext = pNodeWalk->pNext;
}
// Free up the node
pNodeWalk->pIRule->Release();
pNodeWalk->pNext = NULL;
delete pNodeWalk;
// Set the return param
hr = S_OK;
exit:
return hr;
}
HRESULT CRulesManager::_HrFixupRuleInfo(RULE_TYPE typeRule, RULEINFO * pinfoRule, ULONG cpinfoRule)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
RULENODE * pNodeHead = NULL;
RULENODE * pNodeWalk = NULL;
// Check incoming args
if ((NULL == pinfoRule) && (0 != cpinfoRule))
{
hr = E_INVALIDARG;
goto exit;
}
// Walk the proper list
if (RULE_TYPE_MAIL == typeRule)
{
pNodeHead = m_pMailHead;
}
else if (RULE_TYPE_NEWS == typeRule)
{
pNodeHead = m_pNewsHead;
}
else if (RULE_TYPE_FILTER == typeRule)
{
pNodeHead = m_pFilterHead;
}
else
{
hr = E_INVALIDARG;
goto exit;
}
// Search the rule info list for an unknown ruleid
for (ulIndex = 0; ulIndex < cpinfoRule; ulIndex++)
{
// If the rule id is invalid try to find it
if (RULEID_INVALID == pinfoRule[ulIndex].ridRule)
{
for (pNodeWalk = pNodeHead; NULL != pNodeWalk; pNodeWalk = pNodeWalk->pNext)
{
// Check to see if the rule is the same
if (pNodeWalk->pIRule == pinfoRule[ulIndex].pIRule)
{
pinfoRule[ulIndex].ridRule = pNodeWalk->ridRule;
break;
}
}
if (NULL == pNodeWalk)
{
hr = E_FAIL;
goto exit;
}
}
}
// Set the return value
hr = S_OK;
exit:
return hr;
}
CEnumRules::CEnumRules()
{
m_cRef = 0;
m_pNodeHead = NULL;
m_pNodeCurr = NULL;
m_dwFlags = 0;
m_typeRule = RULE_TYPE_MAIL;
}
CEnumRules::~CEnumRules()
{
RULENODE * pNodeNext = NULL;
AssertSz(m_cRef == 0, "Somebody still has a hold of us!!");
// Walk the list and free each item
while (NULL != m_pNodeHead)
{
// Save off the next item
pNodeNext = m_pNodeHead->pNext;
// Release the rule
AssertSz(NULL != m_pNodeHead->pIRule, "Where the heck is the rule???");
m_pNodeHead->pIRule->Release();
// Free up the node
delete m_pNodeHead;
// Move to the next item
m_pNodeHead = pNodeNext;
}
}
STDMETHODIMP_(ULONG) CEnumRules::AddRef()
{
return ::InterlockedIncrement(&m_cRef);
}
STDMETHODIMP_(ULONG) CEnumRules::Release()
{
LONG cRef = 0;
cRef = ::InterlockedDecrement(&m_cRef);
if (0 == cRef)
{
delete this;
return cRef;
}
return cRef;
}
STDMETHODIMP CEnumRules::QueryInterface(REFIID riid, void ** ppvObject)
{
HRESULT hr = S_OK;
// Check the incoming params
if (NULL == ppvObject)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*ppvObject = NULL;
if ((riid == IID_IUnknown) || (riid == IID_IOEEnumRules))
{
*ppvObject = static_cast<IOEEnumRules *>(this);
}
else
{
hr = E_NOINTERFACE;
goto exit;
}
reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CEnumRules::Next(ULONG cpIRule, IOERule ** rgpIRule, ULONG * pcpIRuleFetched)
{
HRESULT hr = S_OK;
ULONG cpIRuleRet = 0;
// Check incoming params
if (NULL == rgpIRule)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing params
*rgpIRule = NULL;
if (NULL != pcpIRuleFetched)
{
*pcpIRuleFetched = 0;
}
// If we're at the end then just return
if (NULL == m_pNodeCurr)
{
hr = S_FALSE;
goto exit;
}
for (cpIRuleRet = 0; cpIRuleRet < cpIRule; cpIRuleRet++)
{
rgpIRule[cpIRuleRet] = m_pNodeCurr->pIRule;
(rgpIRule[cpIRuleRet])->AddRef();
m_pNodeCurr = m_pNodeCurr->pNext;
if (NULL == m_pNodeCurr)
{
cpIRuleRet++;
break;
}
}
// Set outgoing params
if (NULL != pcpIRuleFetched)
{
*pcpIRuleFetched = cpIRuleRet;
}
// Set return value
hr = (cpIRuleRet == cpIRule) ? S_OK : S_FALSE;
exit:
return hr;
}
STDMETHODIMP CEnumRules::Skip(ULONG cpIRule)
{
HRESULT hr = S_OK;
ULONG cpIRuleWalk = 0;
for (cpIRuleWalk = 0; cpIRuleWalk < cpIRule; cpIRuleWalk++)
{
if (NULL == m_pNodeCurr)
{
break;
}
m_pNodeCurr = m_pNodeCurr->pNext;
}
hr = (cpIRuleWalk == cpIRule) ? S_OK : S_FALSE;
return hr;
}
STDMETHODIMP CEnumRules::Reset(void)
{
HRESULT hr = S_OK;
m_pNodeCurr = m_pNodeHead;
return hr;
}
STDMETHODIMP CEnumRules::Clone(IOEEnumRules ** ppIEnumRules)
{
HRESULT hr = S_OK;
CEnumRules * pEnumRules = NULL;
// Check incoming params
if (NULL == ppIEnumRules)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing params
*ppIEnumRules = NULL;
pEnumRules = new CEnumRules;
if (NULL == pEnumRules)
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Initialize the rules enumerator
hr = pEnumRules->_HrInitialize(m_dwFlags, m_typeRule, m_pNodeHead);
if (FAILED(hr))
{
goto exit;
}
// Set the state of the new one to match the current one
pEnumRules->m_pNodeCurr = m_pNodeHead;
// Get the rules enumerator interface
hr = pEnumRules->QueryInterface(IID_IOEEnumRules, (void **) ppIEnumRules);
if (FAILED(hr))
{
goto exit;
}
pEnumRules = NULL;
hr = S_OK;
exit:
if (NULL != pEnumRules)
{
delete pEnumRules;
}
return hr;
}
HRESULT CEnumRules::_HrInitialize(DWORD dwFlags, RULE_TYPE typeRule, RULENODE * pNodeHead)
{
HRESULT hr = S_OK;
RULENODE * pNodeNew = NULL;
RULENODE * pNodeWalk = NULL;
if (NULL == pNodeHead)
{
hr = S_FALSE;
goto exit;
}
m_dwFlags = dwFlags;
m_typeRule = typeRule;
for (pNodeWalk = m_pNodeHead; NULL != pNodeHead; pNodeHead = pNodeHead->pNext)
{
// Check to see if we should add this item
if (RULE_TYPE_FILTER == m_typeRule)
{
if (0 != (dwFlags & ENUMF_POP3))
{
if (RULEID_VIEW_DOWNLOADED == pNodeHead->ridRule)
{
continue;
}
}
}
pNodeNew = new RULENODE;
if (NULL == pNodeNew)
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Initialize new node
pNodeNew->pNext = NULL;
pNodeNew->pIRule = pNodeHead->pIRule;
pNodeNew->pIRule->AddRef();
// Add the new node to the list
if (NULL == pNodeWalk)
{
m_pNodeHead = pNodeNew;
pNodeWalk = pNodeNew;
}
else
{
pNodeWalk->pNext = pNodeNew;
pNodeWalk = pNodeNew;
}
pNodeNew = NULL;
}
// Set the current to the front of the chain
m_pNodeCurr = m_pNodeHead;
// Set return value
hr = S_OK;
exit:
if (pNodeNew)
delete pNodeNew;
return hr;
}
// The Rule Executor object
CExecRules::~CExecRules()
{
RULENODE * pNodeNext = NULL;
AssertSz(m_cRef == 0, "Somebody still has a hold of us!!");
// Walk the list and free each item
while (NULL != m_pNodeHead)
{
// Save off the next item
pNodeNext = m_pNodeHead->pNext;
// Release the rule
AssertSz(NULL != m_pNodeHead->pIRule, "Where the heck is the rule???");
m_pNodeHead->pIRule->Release();
// Free up the node
delete m_pNodeHead;
// Move to the next item
m_pNodeHead = pNodeNext;
}
// Free up the cached objects
_HrReleaseFolderObjects();
_HrReleaseFileObjects();
_HrReleaseSoundFiles();
// Free the folder list
SafeMemFree(m_pRuleFolder);
m_cRuleFolderAlloc = 0;
// Free the file list
SafeMemFree(m_pRuleFile);
m_cRuleFileAlloc = 0;
// Free the file list
SafeMemFree(m_ppszSndFile);
m_cpszSndFileAlloc = 0;
}
STDMETHODIMP_(ULONG) CExecRules::AddRef()
{
return ::InterlockedIncrement(&m_cRef);
}
STDMETHODIMP_(ULONG) CExecRules::Release()
{
LONG cRef = 0;
cRef = ::InterlockedDecrement(&m_cRef);
if (0 == cRef)
{
delete this;
return cRef;
}
return cRef;
}
STDMETHODIMP CExecRules::QueryInterface(REFIID riid, void ** ppvObject)
{
HRESULT hr = S_OK;
// Check the incoming params
if (NULL == ppvObject)
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*ppvObject = NULL;
if ((riid == IID_IUnknown) || (riid == IID_IOEExecRules))
{
*ppvObject = static_cast<IOEExecRules *>(this);
}
else
{
hr = E_NOINTERFACE;
goto exit;
}
reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CExecRules::GetState(DWORD * pdwState)
{
HRESULT hr = S_OK;
// Check incoming params
if (NULL == pdwState)
{
hr = E_INVALIDARG;
goto exit;
}
*pdwState = m_dwState;
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CExecRules::ExecuteRules(DWORD dwFlags, LPCSTR pszAcct, MESSAGEINFO * pMsgInfo,
IMessageFolder * pFolder, IMimePropertySet * pIMPropSet,
IMimeMessage * pIMMsg, ULONG cbMsgSize,
ACT_ITEM ** ppActions, ULONG * pcActions)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
RULENODE * pNodeWalk = NULL;
ACT_ITEM * pActions = NULL;
ULONG cActions = 0;
ACT_ITEM * pActionsList = NULL;
ULONG cActionsList = 0;
ACT_ITEM * pActionsNew = NULL;
ULONG cActionsNew = 0;
BOOL fStopProcessing = FALSE;
BOOL fMatch = FALSE;
DWORD dwState = 0;
// Check incoming params
if (((NULL == pMsgInfo) && (NULL == pIMPropSet)) ||
(0 == cbMsgSize) || (NULL == ppActions) || (NULL == pcActions))
{
hr = E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*ppActions = NULL;
*pcActions = 0;
// Should we skip partial messages?
if ((NULL != pIMPropSet) &&
(S_OK == pIMPropSet->IsContentType(STR_CNT_MESSAGE, STR_SUB_PARTIAL)) &&
(0 != (dwFlags & ERF_SKIPPARTIALS)))
{
hr = S_FALSE;
goto exit;
}
// Walk the list of rules executing each one
pNodeWalk = m_pNodeHead;
while (NULL != pNodeWalk)
{
Assert(NULL != pNodeWalk->pIRule);
// If we are only checking server rules
// Bail if we need more information...
if (0 != (dwFlags & ERF_ONLYSERVER))
{
hr = pNodeWalk->pIRule->GetState(&dwState);
if (FAILED(hr))
{
goto exit;
}
// Do we need more information...
if (0 != (dwState & CRIT_STATE_ALL))
{
hr = S_FALSE;
break;
}
}
// Evaluate the rule
hr = pNodeWalk->pIRule->Evaluate(pszAcct, pMsgInfo, pFolder, pIMPropSet, pIMMsg, cbMsgSize, &pActions, &cActions);
if (FAILED(hr))
{
goto exit;
}
// Did we have a match
if (S_OK == hr)
{
// We've matched at least once
fMatch = TRUE;
ulIndex = 0;
// If these are server actions
if ((1 == cActions) && ((ACT_TYPE_DELETESERVER == pActions[ulIndex].type) ||
(ACT_TYPE_DONTDOWNLOAD == pActions[ulIndex].type)))
{
// If this is our only action
if (0 == cActionsList)
{
// Save the action
pActionsList = pActions;
pActions = NULL;
cActionsList = cActions;
// We are done
fStopProcessing = TRUE;
}
else
{
// We already have to do something with it
// so skip over this action
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
// Move to the next rule
pNodeWalk = pNodeWalk->pNext;
continue;
}
}
else
{
// Should we stop after merging these?
for (ulIndex = 0; ulIndex < cActions; ulIndex++)
{
if (ACT_TYPE_STOP == pActions[ulIndex].type)
{
fStopProcessing = TRUE;
break;
}
}
// Merge these items with the previous ones
hr = RuleUtil_HrMergeActions(pActionsList, cActionsList, pActions, cActions, &pActionsNew, &cActionsNew);
if (FAILED(hr))
{
goto exit;
}
// Free up the previous ones
RuleUtil_HrFreeActionsItem(pActionsList, cActionsList);
SafeMemFree(pActionsList);
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
// Save off the new ones
pActionsList = pActionsNew;
pActionsNew = NULL;
cActionsList = cActionsNew;
}
// Should we continue...
if (FALSE != fStopProcessing)
{
break;
}
}
// Move to the next rule
pNodeWalk = pNodeWalk->pNext;
}
// Set outgoing param
*ppActions = pActionsList;
pActionsList = NULL;
*pcActions = cActionsList;
// Set the return value
hr = (FALSE != fMatch) ? S_OK : S_FALSE;
exit:
RuleUtil_HrFreeActionsItem(pActionsNew, cActionsNew);
SafeMemFree(pActionsNew);
RuleUtil_HrFreeActionsItem(pActions, cActions);
SafeMemFree(pActions);
RuleUtil_HrFreeActionsItem(pActionsList, cActionsList);
SafeMemFree(pActionsList);
return hr;
}
STDMETHODIMP CExecRules::ReleaseObjects(VOID)
{
// Free up the folders
_HrReleaseFolderObjects();
// Free up the files
_HrReleaseFileObjects();
// Free up the sound files
_HrReleaseSoundFiles();
return S_OK;
}
STDMETHODIMP CExecRules::GetRuleFolder(FOLDERID idFolder, DWORD_PTR * pdwFolder)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
RULE_FOLDER * pRuleFolderWalk = NULL;
IMessageFolder *pFolder = NULL;
// Check incoming param
if ((FOLDERID_INVALID == idFolder) || (NULL == pdwFolder))
{
hr =E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*pdwFolder = NULL;
// Let's search for the folder
for (ulIndex = 0; ulIndex < m_cRuleFolder; ulIndex++)
{
pRuleFolderWalk = &(m_pRuleFolder[ulIndex]);
if (idFolder == pRuleFolderWalk->idFolder)
{
Assert(NULL != pRuleFolderWalk->pFolder);
break;
}
}
// If we didn't find it then let's open it and lock it...
if (ulIndex >= m_cRuleFolder)
{
// Do we need to alloc any more spaces
if (m_cRuleFolder >= m_cRuleFolderAlloc)
{
hr = HrRealloc((LPVOID *) &m_pRuleFolder, sizeof(*m_pRuleFolder) * (m_cRuleFolderAlloc + RULE_FOLDER_ALLOC));
if (FAILED(hr))
{
goto exit;
}
// Initialize the new rule folders
ZeroMemory(m_pRuleFolder + m_cRuleFolderAlloc, sizeof(*m_pRuleFolder) * RULE_FOLDER_ALLOC);
for (ulIndex = m_cRuleFolderAlloc; ulIndex < (m_cRuleFolderAlloc + RULE_FOLDER_ALLOC); ulIndex++)
{
m_pRuleFolder[ulIndex].idFolder = FOLDERID_INVALID;
}
m_cRuleFolderAlloc += RULE_FOLDER_ALLOC;
}
// Open the folder
hr = g_pStore->OpenFolder(idFolder, NULL, NOFLAGS, &pFolder);
if (FAILED(hr))
{
goto exit;
}
m_pRuleFolder[m_cRuleFolder].idFolder = idFolder;
m_pRuleFolder[m_cRuleFolder].pFolder = pFolder;
pFolder = NULL;
pRuleFolderWalk = &(m_pRuleFolder[m_cRuleFolder]);
m_cRuleFolder++;
}
*pdwFolder = (DWORD_PTR) (pRuleFolderWalk->pFolder);
// Set the proper return value
hr = S_OK;
exit:
if (NULL != pFolder)
pFolder->Release();
return hr;
}
STDMETHODIMP CExecRules::GetRuleFile(LPCSTR pszFile, IStream ** ppstmFile, DWORD * pdwType)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
RULE_FILE * pRuleFileWalk = NULL;
IStream * pIStmFile = NULL;
LPSTR pszExt = NULL;
DWORD dwType = RFT_FILE;
// Check incoming param
if ((NULL == pszFile) || (NULL == ppstmFile) || (NULL == pdwType))
{
hr =E_INVALIDARG;
goto exit;
}
// Initialize outgoing param
*ppstmFile = NULL;
*pdwType = NULL;
// Let's search for the file
for (ulIndex = 0; ulIndex < m_cRuleFile; ulIndex++)
{
pRuleFileWalk = &(m_pRuleFile[ulIndex]);
if (0 == lstrcmpi(pRuleFileWalk->pszFile, pszFile))
{
Assert(NULL != pRuleFileWalk->pstmFile);
break;
}
}
// If we didn't find it then let's open it...
if (ulIndex >= m_cRuleFile)
{
// Do we need to alloc any more space
if (m_cRuleFile >= m_cRuleFileAlloc)
{
hr = HrRealloc((LPVOID *) &m_pRuleFile, sizeof(*m_pRuleFile) * (m_cRuleFileAlloc + RULE_FILE_ALLOC));
if (FAILED(hr))
{
goto exit;
}
// Initialize the new rule file
ZeroMemory(m_pRuleFile + m_cRuleFileAlloc, sizeof(*m_pRuleFile) * RULE_FILE_ALLOC);
m_cRuleFileAlloc += RULE_FILE_ALLOC;
}
// Open a stream on the file
hr = CreateStreamOnHFile((LPTSTR) pszFile, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL, &pIStmFile);
if (FAILED(hr))
{
goto exit;
}
// Lets split the file name and get the extension
pszExt = PathFindExtension(pszFile);
if ((0 == lstrcmpi(pszExt, c_szHtmExt)) || (0 == lstrcmpi(pszExt, c_szHtmlExt)))
{
dwType = RFT_HTML;
}
// Text File...
else if (0 == lstrcmpi(pszExt, c_szTxtExt))
{
dwType = RFT_TEXT;
}
// Else .nws or .eml file...
else if ((0 == lstrcmpi(pszExt, c_szEmlExt)) || (0 == lstrcmpi(pszExt, c_szNwsExt)))
{
dwType = RFT_MESSAGE;
}
// Otherwise, its an attachment
else
{
dwType = RFT_FILE;
}
// Save off the info
m_pRuleFile[m_cRuleFile].pszFile = PszDupA(pszFile);
if (NULL == m_pRuleFile[m_cRuleFile].pszFile)
{
hr = E_OUTOFMEMORY;
goto exit;
}
m_pRuleFile[m_cRuleFile].pstmFile = pIStmFile;
pIStmFile = NULL;
m_pRuleFile[m_cRuleFile].dwType = dwType;
pRuleFileWalk = &(m_pRuleFile[m_cRuleFile]);
m_cRuleFile++;
}
*ppstmFile = pRuleFileWalk->pstmFile;
(*ppstmFile)->AddRef();
*pdwType = pRuleFileWalk->dwType;
// Set the proper return value
hr = S_OK;
exit:
SafeRelease(pIStmFile);
return hr;
}
STDMETHODIMP CExecRules::AddSoundFile(DWORD dwFlags, LPCSTR pszSndFile)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
// Check incoming param
if (NULL == pszSndFile)
{
hr = E_INVALIDARG;
goto exit;
}
// Let's search for the file
for (ulIndex = 0; ulIndex < m_cpszSndFile; ulIndex++)
{
Assert(NULL != m_ppszSndFile[ulIndex]);
if (0 == lstrcmpi(m_ppszSndFile[ulIndex], pszSndFile))
{
break;
}
}
// If we didn't find it then let's open it...
if (ulIndex >= m_cpszSndFile)
{
// Do we need to alloc any more space
if (m_cpszSndFile >= m_cpszSndFileAlloc)
{
hr = HrRealloc((LPVOID *) &m_ppszSndFile, sizeof(*m_ppszSndFile) * (m_cpszSndFileAlloc + SND_FILE_ALLOC));
if (FAILED(hr))
{
goto exit;
}
// Initialize the new rule file
ZeroMemory(m_ppszSndFile + m_cpszSndFileAlloc, sizeof(*m_ppszSndFile) * SND_FILE_ALLOC);
m_cpszSndFileAlloc += SND_FILE_ALLOC;
}
// Save off the info
m_ppszSndFile[m_cpszSndFile] = PszDupA(pszSndFile);
if (NULL == m_ppszSndFile[m_cpszSndFile])
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Should we play it?
if (0 != (dwFlags & ASF_PLAYIFNEW))
{
sndPlaySound(m_ppszSndFile[m_cpszSndFile], SND_NODEFAULT | SND_SYNC);
}
m_cpszSndFile++;
}
// Set the proper return value
hr = S_OK;
exit:
return hr;
}
STDMETHODIMP CExecRules::PlaySounds(DWORD dwFlags)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
// Let's search for the file
for (ulIndex = 0; ulIndex < m_cpszSndFile; ulIndex++)
{
Assert(NULL != m_ppszSndFile[ulIndex]);
sndPlaySound(m_ppszSndFile[ulIndex], SND_NODEFAULT | SND_SYNC);
}
return hr;
}
HRESULT CExecRules::_HrReleaseFolderObjects(VOID)
{
RULE_FOLDER * pRuleFolder = NULL;
ULONG ulIndex = 0;
for (ulIndex = 0; ulIndex < m_cRuleFolder; ulIndex++)
{
pRuleFolder = &(m_pRuleFolder[ulIndex]);
Assert(FOLDERID_INVALID != pRuleFolder->idFolder);
// If we have the folder opened then close it
SafeRelease(pRuleFolder->pFolder);
// Reset the folder list
pRuleFolder->idFolder = FOLDERID_INVALID;
}
// Let's clear out the number of messages
m_cRuleFolder = 0;
return S_OK;
}
HRESULT CExecRules::_HrReleaseFileObjects(VOID)
{
RULE_FILE * pRuleFile = NULL;
ULONG ulIndex = 0;
for (ulIndex = 0; ulIndex < m_cRuleFile; ulIndex++)
{
pRuleFile = &(m_pRuleFile[ulIndex]);
Assert(NULL != pRuleFile->pszFile);
// If we have the file opened then close it
SafeRelease(pRuleFile->pstmFile);
// Clear the file
SafeMemFree(pRuleFile->pszFile);
pRuleFile->dwType = RFT_FILE;
}
// Let's clear out the number of file
m_cRuleFile = 0;
return S_OK;
}
HRESULT CExecRules::_HrReleaseSoundFiles(VOID)
{
ULONG ulIndex = 0;
for (ulIndex = 0; ulIndex < m_cpszSndFile; ulIndex++)
{
Assert(NULL != m_ppszSndFile[ulIndex]);
// Clear the file
SafeMemFree(m_ppszSndFile[ulIndex]);
}
// Let's clear out the number of file
m_cpszSndFile = 0;
return S_OK;
}
HRESULT CExecRules::_HrInitialize(DWORD dwFlags, RULENODE * pNodeHead)
{
HRESULT hr = S_OK;
RULENODE * pNodeNew = NULL;
RULENODE * pNodeWalk = NULL;
DWORD dwState = 0;
PROPVARIANT propvar;
if (NULL == pNodeHead)
{
hr = S_FALSE;
goto exit;
}
for (pNodeWalk = m_pNodeHead; NULL != pNodeHead; pNodeHead = pNodeHead->pNext)
{
// Skip rules that are disabled
if (0 != (dwFlags & ERF_ONLY_ENABLED))
{
hr = pNodeHead->pIRule->GetProp(RULE_PROP_DISABLED, 0, &propvar);
Assert(VT_BOOL == propvar.vt);
if (FAILED(hr) || (FALSE != propvar.boolVal))
{
continue;
}
}
// Skip rules that are invalid
if (0 != (dwFlags & ERF_ONLY_VALID))
{
hr = pNodeHead->pIRule->Validate(dwFlags);
if (FAILED(hr) || (S_FALSE == hr))
{
continue;
}
}
pNodeNew = new RULENODE;
if (NULL == pNodeNew)
{
hr = E_OUTOFMEMORY;
goto exit;
}
// Initialize new node
pNodeNew->pNext = NULL;
pNodeNew->pIRule = pNodeHead->pIRule;
pNodeNew->pIRule->AddRef();
// Add the new node to the list
if (NULL == pNodeWalk)
{
m_pNodeHead = pNodeNew;
pNodeWalk = pNodeNew;
}
else
{
pNodeWalk->pNext = pNodeNew;
pNodeWalk = pNodeNew;
}
pNodeNew = NULL;
// Calculate state from message
if (SUCCEEDED(pNodeWalk->pIRule->GetState(&dwState)))
{
// Let's set the proper Criteria state
if ((m_dwState & CRIT_STATE_MASK) < (dwState & CRIT_STATE_MASK))
{
m_dwState = (m_dwState & ~CRIT_STATE_MASK) | (dwState & CRIT_STATE_MASK);
}
// Let's set the proper Action state
if (0 != (dwState & ACT_STATE_MASK))
{
m_dwState |= (dwState & ACT_STATE_MASK);
}
}
}
// Set return value
hr = S_OK;
exit:
if (pNodeNew)
delete pNodeNew;
return hr;
}
| [
"112426112@qq.com"
] | 112426112@qq.com |
4eab70cf6f5c426cb0cde3bed8af5d5bfe9399d8 | 57072dd22f20eb2feaba2ba65aed85286059a418 | /network/trainer.cpp | 88a0227fc548a3bfa71311e32a49e2005c9e0c20 | [] | no_license | dolan212/FirstANN | f7cf414995644aeb80b1b1416027bbd9528649c0 | 4198fd0cc0d9c7fdb6fd326251e2ade6be63875f | refs/heads/master | 2021-07-05T04:48:05.890146 | 2017-09-22T19:42:52 | 2017-09-22T19:42:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,194 | cpp | #include "trainer.h"
#include <iostream>
#include <iomanip>
NetworkTrainer::NetworkTrainer(TrainerSettings set, Network * net)
{
network = net;
learningRate = set.learningRate;
momentum = set.momentum;
maxEpochs = set.maxEpochs;
desiredAccuracy = set.desiredAccuracy;
deltaIH = new float[(net->numInput + 1) * (net->numHidden + 1)];
deltaHO = new float[(net->numHidden + 1) * net->numOutput];
errorGradientsHidden = new float[net->numHidden + 1];
errorGradientsOutput = new float[net->numOutput];
currentEpoch = 0;
}
NetworkTrainer::~NetworkTrainer()
{
delete [] deltaIH;
delete [] deltaHO;
delete [] errorGradientsHidden;
delete [] errorGradientsOutput;
}
float NetworkTrainer::getHiddenErrorGradient(int hidden)
{
float weightedSum = 0;
for(int o = 0; o < network->numOutput; o++)
{
int index = network->getHOIndex(hidden, o);
weightedSum += network->weightsHO[index] * errorGradientsOutput[o];
}
return network->hiddens[hidden] * (1 - network->hiddens[hidden]) * weightedSum;
}
void NetworkTrainer::backPropagate(std::vector<float> expected)
{
for(int o = 0; o < network->numOutput; o++)
{
errorGradientsOutput[o] = getOutputErrorGradient(expected[o], network->outputs[o]);
for(int h = 0; h <= network->numHidden; h++)
{
int index = network->getHOIndex(h, o);
deltaHO[index] = learningRate * network->hiddens[h] * errorGradientsOutput[o] + momentum * deltaHO[index];
}
}
for(int h = 0; h <= network->numHidden; h++)
{
errorGradientsHidden[h] = getHiddenErrorGradient(h);
for(int i = 0; i <= network->numInput; i++)
{
int index = network->getIHIndex(i, h);
deltaIH[index] = learningRate * network->inputs[h] * errorGradientsHidden[h] + momentum * deltaIH[index];
}
}
updateWeights();
}
void NetworkTrainer::updateWeights()
{
for(int i = 0; i <= network->numInput; i++)
{
for(int h = 0; h <= network->numHidden; h++)
{
int index = network->getIHIndex(i, h);
network->weightsIH[index] += deltaIH[index];
}
}
for(int h = 0; h <= network->numHidden; h++)
{
for(int o = 0; o < network->numOutput; o++)
{
int index = network->getHOIndex(h, o);
network->weightsHO[index] += deltaHO[index];
}
}
}
float NetworkTrainer::runEpoch(TrainingSet trainingSet)
{
float accuracy = 0;
for(TrainingEntry entry : trainingSet)
{
float inputs[entry.inputs.size()];
for(int i = 0; i < entry.inputs.size(); i++)
inputs[i] = entry.inputs[i];
network->evaluate(inputs);
backPropagate(entry.expectedOut);
bool correct = true;
for(int o = 0; o < network->numOutput; o++)
{
if(network->clampedOutputs[o] != entry.expectedOut[o])
{
correct = false;
break;
}
}
if(correct)
accuracy++;
}
accuracy = (accuracy / (float)trainingSet.size()) * 100;
return accuracy;
}
void NetworkTrainer::train(TrainingData data)
{
std::cout << std::right;
std::cout << "==============================" << std::endl;
std::cout << "|" << std::setw(10) << "Beginning Training" << std::setw(10) << "|" << std::endl;
std::cout << "|" << std::setw(10) << "------------------" << std::setw(10) << "|" << std::endl;
std::cout << "|" << std::setw(10) << "desiredAccuracy = " << desiredAccuracy << std::setw(10) << "|" << std::endl;
std::cout << "|" << std::setw(10) << "maxEpochs = " << maxEpochs << std::setw(10) << "|" << std::endl;
std::cout << "==============================" << std::endl;
float trainingAccuracy = 0;
while(currentEpoch < maxEpochs && trainingAccuracy < desiredAccuracy)
{
trainingAccuracy = runEpoch(data.trainingSet);
float genAccuracy = runEpoch(data.generalizationSet);
std::cout << "Epoch: " << currentEpoch
<< " | Training Set Accuracy: " << trainingAccuracy
<< " | Generalization Set Accuracy: " << genAccuracy
<< std::endl;
currentEpoch++;
}
std::cout << "===========================" << std::endl;
std::cout << "| Training Complete |" << std::endl;
std::cout << "===========================" << std::endl;
float valAccuracy = 0;
for(TrainingEntry entry : data.validationSet)
{
float inputs[entry.inputs.size()];
for(int i = 0; i < entry.inputs.size(); i++)
inputs[i] = entry.inputs[i];
network->evaluate(inputs);
bool correct = true;
for(int o = 0; o < network->numOutput; o++)
{
if(network->clampedOutputs[o] != entry.expectedOut[o])
{
correct = false;
break;
}
}
if(correct) valAccuracy++;
}
valAccuracy = (valAccuracy / (float)data.validationSet.size()) * 100;
std::cout << "Validation Set Accuracy: " << valAccuracy << std::endl;
}
| [
"u16081758@tuks.co.za"
] | u16081758@tuks.co.za |
1c64c3079274a8b50bcbe58248e3fe34af626233 | fcfe59fb8654509fd1748820915ef49f39227fce | /2019/movie_night_update/main/cpp/Robot.cpp | 0a7d34508fd1736a15e670b6b566c2d7a3431837 | [] | no_license | AnishGDev/FirstRobotics | cd6f4205721dd5b2ebdbecc97266fa793b5fa1ea | d6eb857d4dae8d8b3e1e0d988b821ac209ce5cb8 | refs/heads/master | 2020-04-15T14:57:39.374335 | 2019-08-31T12:30:34 | 2019-08-31T12:30:34 | 164,774,815 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,886 | cpp | /*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "Robot.h"
#include <frc/WPILib.h>
#include <frc/commands/Scheduler.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include "commands/driveCommand.h"
#include "frc/smartdashboard/SmartDashboard.h"
#include <CameraServer.h>
#include <networktables/NetworkTableInstance.h>
ExampleSubsystem Robot::m_subsystem;
//driveSubsystem Robot::m_drive;
//OI Robot::m_oi;
//frc::DigitalInput* limitSwitch;
void Robot::RobotInit() {
CommandBase::init();
teleopchooser = new frc::SendableChooser<frc::Command*>;
teleopchooser->SetDefaultOption("Tank Driving", new driveCommand());
//limitSwitch = new frc::DigitalInput(1);
frc::SmartDashboard::PutData("Teleop Modes", teleopchooser);
//frc::CameraServer::GetInstance()->StartAutomaticCapture();
camera1 = frc::CameraServer::GetInstance()->StartAutomaticCapture(0);
camera2 = frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
}
/**
* This function is called every robot packet, no matter the mode. Use
* this for items like diagnostics that you want ran during disabled,
* autonomous, teleoperated and test.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
*/
void Robot::RobotPeriodic() {
}
/**
* This function is called once each time the robot enters Disabled mode. You
* can use it to reset any subsystem information you want to clear when the
* robot is disabled.
*/
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() { frc::Scheduler::GetInstance()->Run(); }
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable chooser
* code works with the Java SmartDashboard. If you prefer the LabVIEW Dashboard,
* remove all of the chooser code and uncomment the GetString code to get the
* auto name from the text box below the Gyro.
*
* You can add additional auto modes by adding additional commands to the
* chooser code above (like the commented example) or additional comparisons to
* the if-else structure below with additional strings & commands.
*/
void Robot::AutonomousInit() {
teleopCommand = (frc::Command *) teleopchooser->GetSelected();
if (teleopCommand != nullptr) {
teleopCommand->Start();
}
/*
// std::string autoSelected = frc::SmartDashboard::GetString(
// "Auto Selector", "Default");
// if (autoSelected == "My Auto") {
// m_autonomousCommand = &m_myAuto;
// } else {
// m_autonomousCommand = &m_defaultAuto;
// }
m_autonomousCommand = m_chooser.GetSelected();
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Start();
}
*/
}
void Robot::AutonomousPeriodic() { frc::Scheduler::GetInstance()->Run(); }
void Robot::TeleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
/*
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Cancel();
m_autonomousCommand = nullptr;
}
*/
teleopCommand = (frc::Command *) teleopchooser->GetSelected();
if (teleopCommand != nullptr) {
teleopCommand->Start();
}
}
void Robot::TeleopPeriodic() {
frc::Scheduler::GetInstance()->Run();
/* if (oi->logiStick->GetRawButton(8)) {
printf("Setting camera 2\n");
nt::NetworkTableInstance::GetDefault().GetTable("")->PutString("CameraSelection", camera2.GetName());
} else if (!oi->logiStick->GetRawButton(8)) {
printf("Setting camera 1\n");
nt::NetworkTableInstance::GetDefault().GetTable("")->PutString("CameraSelection", camera1.GetName());
} */
}
void Robot::TestInit() {
// JUST COPIED THE TELEOPINIT HERE.
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Cancel();
m_autonomousCommand = nullptr;
}
teleopCommand = (frc::Command *) teleopchooser->GetSelected();
if (teleopCommand != nullptr) {
teleopCommand->Start();
}
}
void Robot::TestPeriodic() {
frc::Scheduler::GetInstance()->Run();
}
#ifndef RUNNING_FRC_TESTS
int main() { return frc::StartRobot<Robot>(); }
#endif
| [
"ashwinr2k2@gmail.com"
] | ashwinr2k2@gmail.com |
7a6c856de72370186b738886f040e27365cbf1d7 | 5a8e51549d159a749e540fd3bf214da7470faf0a | /OOP 02-02.1 Mann-Frau-Heirat(orientalisch)/Mann.h | 7ef2782f1710e5db20bbd542cac8215e89eb7e27 | [] | no_license | modernrio/Schulaufgaben | 1b9784934bac7c480195ce55213dd5fd4146a792 | 596a90fce7892143e8e2da91e2b5c1e1f54e24db | refs/heads/master | 2021-01-10T21:49:37.917286 | 2015-07-05T10:20:37 | 2015-07-05T10:20:37 | 26,983,137 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 454 | h | #pragma once
class Mann
{
public:
Mann();
Mann(string name, int alter);
~Mann();
void SetName(string name);
void SetAlter(int a);
void SetFrau(Frau *f, int n);
string GetName();
int GetAlter();
Frau* GetFrau(int n);
int GetTemp();
bool Heiraten(Frau *f);
bool Scheiden(int n);
void HeiratsStatus(bool status);
bool IstVerheiratet();
private:
string m_name;
int m_alter;
bool m_verheiratet;
Frau* m_frauen[100];
int m_temp;
};
| [
"schneider.markus@outlook.com"
] | schneider.markus@outlook.com |
66f77def3ac7d0e465e4a1dab0b731679826039e | f3f2acfd1d9bae6f9c11e00a714e1c7dedd92815 | /OurPaint3D/src/main.cpp | 5109f456d23ee0e65270b3ce1713b5d3296eb7df | [] | no_license | remtori/OurPaint3D | 5dd361aa337f10fa054e88607e54738fd3895646 | 2fccaa92730d70f3dd5433cc7edff643de54cda7 | refs/heads/master | 2020-11-27T02:35:04.505858 | 2020-02-19T16:54:41 | 2020-02-19T16:54:41 | 229,274,721 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 320 | cpp | #include "pch.h"
#include "OurPaint3D/OurPaint3D.h"
#ifdef _WIN32
int CALLBACK WinMain(
__in HINSTANCE hInstance,
__in HINSTANCE hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow
)
#else
int main()
#endif
{
Log::Init();
Application* app = new OurPaint3D();
app->Run();
delete app;
} | [
"lqv.remtori@gmail.com"
] | lqv.remtori@gmail.com |
464391222882cd2651b6ff3399b40cd852d3d6e6 | 11fc42a4d1b62fae8fff4666a0fb0f5b896e07cc | /compiler/pda.h | b9e264b0bb468464ac894f68432b60f387f72af1 | [] | no_license | Mojgeek/compilerProject | 0773ccfc32ff6779cae86caf5dc7210b9d12ba39 | db1830fc04626cc4b297fbd600f57ffe6ecd56f0 | refs/heads/master | 2020-05-28T06:05:12.049556 | 2019-09-01T21:38:24 | 2019-09-01T21:38:24 | 188,903,322 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,365 | h | //********************************************************************************
//
// Author: Mojgan Mehrabi
// Compiler project dfa.cpp
//
// Date Created: 03/25/2019
// Date Completed: 08/30/2019
//
// Description: This is the object file for the DFA class. An object of
// this class is instantiated with a queue of chars as an
// argument. The characters are assembled into strings and
// stored on a deque of structs which hold
// the string and an enum attribute describing the word's
// type as an identifier, operation, integer, or statement.
// Statement represents the end of a line (the end of a
// statement line).
//
// Sample Output: A reference to the deque<struct> wordlist
// object is returned using the getWordlist() method.
//
//********************************************************************************
#ifndef PDA_H
#define PDA_h
#include<stack>
#include"dfa.h"
class pda
{
public:
pda(queue<MyStruct> &wordlist);
private:
void state();
void accept();
void reject();
queue<MyStruct>wordlist;
stack<MyStruct, list<MyStruct>> pdaStack;
MyStruct wordconainer;
};
#endif // !PDA_H
| [
"mojgan.mehrabi@wayne.edu"
] | mojgan.mehrabi@wayne.edu |
5cccc9ac00aa948c049480fe2031a5e0729bb949 | b7f5801aedd56905b938cd6fd71e896afee22ab4 | /Hard Level Problems/Alien Dictionary.cpp | 27629b84aa9f736dfecf2eb1bd78c616cb473508 | [] | no_license | Sanket-Mathur/100-days-of-code | e892d59d0630e2d4d0583be0773112610f7b2623 | e23257475686b428cf54cbe2ff465c5d51a52d99 | refs/heads/main | 2023-08-31T11:53:59.280689 | 2021-10-16T07:46:38 | 2021-10-16T07:46:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,266 | cpp | // { Driver Code Starts
// Initial Template for C++
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution{
public:
string findOrder(string dict[], int N, int K) {
unordered_set<int> adj[K];
for (int i = 0; i < N-1; ++i) {
for (int j = 0; j < min(dict[i].length(), dict[i+1].length()); ++j) {
if (dict[i][j] != dict[i+1][j]) {
adj[dict[i][j] - 'a'].insert(dict[i+1][j] - 'a');
break;
}
}
}
string result;
vector<bool> visited(K, false);
for (int i = 0; i < K; ++i) {
if (!visited[i]) {
topological(adj, i, visited, result);
}
}
return result;
}
void topological(unordered_set<int> adj[], int i, vector<bool> &visited, string &result) {
visited[i] = true;
for (int v : adj[i]) {
if (!visited[v]) {
topological(adj, v, visited, result);
}
}
result.insert(result.begin(), (char)i + 'a');
}
};
// { Driver Code Starts.
string order;
bool f(string a, string b) {
int p1 = 0;
int p2 = 0;
for (int i = 0; i < min(a.size(), b.size()) and p1 == p2; i++) {
p1 = order.find(a[i]);
p2 = order.find(b[i]);
// cout<<p1<<" "<<p2<<endl;
}
if (p1 == p2 and a.size() != b.size()) return a.size() < b.size();
return p1 < p2;
}
// Driver program to test above functions
int main() {
int t;
cin >> t;
while (t--) {
int N, K;
cin >> N >> K;
string dict[N];
for (int i = 0; i < N; i++) cin >> dict[i];
Solution obj;
string ans = obj.findOrder(dict, N, K);
order = "";
for (int i = 0; i < ans.size(); i++) order += ans[i];
string temp[N];
std::copy(dict, dict + N, temp);
sort(temp, temp + N, f);
bool f = true;
for (int i = 0; i < N; i++)
if (dict[i] != temp[i]) f = false;
if(f)cout << 1;
else cout << 0;
cout << endl;
}
return 0;
}
// } Driver Code Ends | [
"rajeev.sanket@gmail.com"
] | rajeev.sanket@gmail.com |
2a129424156681bef86cbb4259cfc958e29b1c76 | 203cb634ac98633692cb5583a758a842bf707a7b | /MYPROJECT_snake/Game.cpp | 0f9a712864ced861e91ce9a6f6d3e1335a97e318 | [] | no_license | huynhminhtan/game-snake-console | 9cf5fd4a4b44371e7c3104102fc7c2613e7c17ac | 68860d3798b7ea31b1d82698c39409e882995cce | refs/heads/master | 2021-06-14T21:17:40.996641 | 2017-03-24T12:15:28 | 2017-03-24T12:15:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,297 | cpp | #include "Game.h"
CGame::CGame()
{
m_height = 20;
m_width = 70;
// init handle
myconsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
// hide cursor
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(myconsoleHandle, &info);
// draw windows
this->drawWindows();
}
CGame::CGame(int _width, int _height)
{
m_width = _width;
m_height = _height;
// init handle
myconsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
// hide cursor
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(myconsoleHandle, &info);
// draw windows
this->drawWindows();
}
CGame::~CGame()
{
}
void CGame::drawWindows()
{
COORD temp;
// draw horizontal
for (int i = 0; i < m_width + 1; i++)
{
temp.X = i;
temp.Y = m_height;
SetConsoleCursorPosition(myconsoleHandle, temp);
printf("0");
}
// draw vertical
for (int i = 0; i < m_height +1; i++)
{
temp.X = m_width;
temp.Y = i;
SetConsoleCursorPosition(myconsoleHandle, temp);
printf("0");
}
}
void CGame::gameLoop()
{
CPrey prey;
CSnake mySnake;
// draw prey
prey.drawPrey(myconsoleHandle, m_width, m_height);
while (true)
{
mySnake.input(myconsoleHandle);
mySnake.crawling(myconsoleHandle);
mySnake.drawSnake(myconsoleHandle);
this->eatPrey(mySnake, prey);
this->gameExit(mySnake);
Sleep(100);
}
}
void CGame::eatPrey(CSnake& _snake, CPrey& _prey)
{
if (_snake.getHeadSnake()->getX() == _prey.getX() &&
_snake.getHeadSnake()->getY() == _prey.getY())
{
// add node snack
_snake.addNodeSnakeTail();
// draw prey
_prey.drawPrey(myconsoleHandle, m_width, m_height);
}
}
void CGame::gameExit(CSnake& _snake)
{
// dung windows
if (_snake.getHeadSnake()->getX() == m_width ||
_snake.getHeadSnake()->getY() == m_height ||
_snake.getHeadSnake()->getX() == 0 ||
_snake.getHeadSnake()->getY() == 0)
{
MessageBox(
NULL,
"GAME oVeR !!!",
"THUA ROI",
NULL
);
exit(0);
}
// dung duoi
CSnake::CNodeSnake* p = _snake.getHeadSnake()->getpNext();
while (p != nullptr)
{
if (_snake.getHeadSnake()->getX() == p->getX() &&
_snake.getHeadSnake()->getY() == p->getY())
{
MessageBox(
NULL,
"game over!",
"thua roi",
NULL
);
exit(0);
}
p = p->getpNext();
}
}
| [
"minhtan.itdev@gmail.com"
] | minhtan.itdev@gmail.com |
203aae52a5cd8569acd947bae6b06f6395114961 | 56e0b3b90f0d5ab945ea5d622a2545cab07d4621 | /cpp/vs_prj/initial_prj/initial_prj/fifo_wr_if.h | b976cf0c584e1a2b7b8159624b71a87e73fa00f3 | [] | no_license | ottohorvath/thesis | 77e7d92952dcc2e65cff6eb77821c576236265ca | 81080f3cb5fe57331f4c901fe24963e003601880 | refs/heads/master | 2021-05-01T11:11:55.651205 | 2018-05-17T14:07:35 | 2018-05-17T14:07:35 | 121,114,849 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,430 | h | //-------------------------------------------------------------------------
//
// Author: Otto Horvath
//
//-------------------------------------------------------------------------
//
// Description:
//
//
//
//
//-------------------------------------------------------------------------
#ifndef FIFO_WR_IF_H
#define FIFO_WR_IF_H
//Define status words
const uint32_t FIFO_WR_IF_IDLE = 0x02;
const uint32_t FIFO_WR_IF_ENABLED = 0x01;
const uint32_t FIFO_WR_IF_RCVD_DATA = 0x07;
//Define command words
const uint32_t FIFO_WR_IF_CMD_EN = 0x01;
const uint32_t FIFO_WR_IF_CMD_CLR = 0x02;
const uint32_t FIFO_WR_IF_CMD_SHOW_DATA = 0x04;
class fifo_wr_if: public simple_component
{
public:
//==================================
// Constructor
BASIC_CONSTRUCTOR(fifo_wr_if, simple_component)
//==================================
//==================================
// Enable the module
virtual void enable(){
// Write the command
write_data(FIFO_WR_IF_CMD_EN);
// Waiting for the component to be updated
while( read_data() != FIFO_WR_IF_ENABLED ){}
// Update status field
set_enabled(0x1);
}
//==================================
//==================================
// Send back the module to idle
virtual void clear(){
// Write the command
write_data(FIFO_WR_IF_CMD_CLR);
// Waiting for the component to be updated
while( read_data() != FIFO_WR_IF_IDLE ){}
// Update status field
set_enabled(0x0);
}
//==================================
//==================================
// Poll the control register until it is enabled
virtual void wait_until_enabled(){
// Waiting for the component to be enabled
while( read_data() != FIFO_WR_IF_ENABLED ){}
}
//==================================
//==================================
// Poll the control register until it is enabled
virtual void wait_until_cleared(){
// Waiting for the component to be cleared
while( read_data() != FIFO_WR_IF_IDLE ){}
}
//=================================
//==================================
// Check if it is in IDLE state
bool is_idle(){
return (read_data() == FIFO_WR_IF_IDLE)?(true):(false);
}
//==================================
//==================================
// Check if it is in 'ENABLED' state
bool is_enabled(){
return (read_data() == FIFO_WR_IF_ENABLED)?(true):(false);
}
//==================================
//==================================
// Check if it is in 'RCVD_DATA' state
bool is_rcvd_data(){
return (read_data() == FIFO_WR_IF_RCVD_DATA)?(true):(false);
}
//==================================
//==================================
// Send the module to 'SHOW_DATA' state
void show_data(){
// Write in the related command
write_data(FIFO_WR_IF_CMD_SHOW_DATA);
}
//==================================
//==================================
// Reading data out from module
// This method assumes that the
// module in 'SHOW_DATA' state
uint32_t read_out(){
return read_data();
}
//==================================
};
#endif//FIFO_WR_IF_H | [
"tt.hrvth@gmail.com"
] | tt.hrvth@gmail.com |
1a7a74da49dd9bbfb1abc466fad9fd16e983d126 | 5c24d32f2c74c8549cf4effdda67bc8843d469c0 | /designpattern/factory/Factory.cpp | 89a6664c87f3626a83c8375725aa42fdbdfa8fba | [] | no_license | tommy85/test | 03d37423e0989db56f3ad113955ac966a89cec88 | 5ecbcd966e80a6a29cfc2990ba6bc40f3616e0c1 | refs/heads/master | 2020-05-19T09:29:25.697757 | 2015-05-14T02:11:19 | 2015-05-14T02:11:19 | 31,691,342 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,040 | cpp | /**//********************************************************************
created: 2006/06/30
filename: Factory.cpp
author: 李创
http://www.cppblog.com/converse/
purpose: Factory模式的演示代码
*********************************************************************/
#include "Factory.h"
#include <iostream>
using namespace std;
ConcreateProduct::ConcreateProduct()
{
std::cout << "construction of ConcreateProductn";
}
ConcreateProduct::~ConcreateProduct()
{
std::cout << "destruction of ConcreateProductn";
}
void Creator::AnOperation()
{
Product* p = FactoryMethod();
std::cout << "an operation of productn";
}
ConcreateCreator::ConcreateCreator()
{
std::cout << "construction of ConcreateCreatorn";
}
ConcreateCreator::~ConcreateCreator()
{
std::cout << "destruction of ConcreateCreatorn";
}
Product* ConcreateCreator::FactoryMethod()
{
return new ConcreateProduct();
}
| [
"xiha85@yahoo.co.jp"
] | xiha85@yahoo.co.jp |
93ea055147c438ef2b70521f203abdebbd5f6e86 | fb95534e8519acb3670ee9743ddb15bf09232e70 | /src/xtd.core/include/xtd/internal/__parse.h | dc2169fc189645bff7721db19c4d4baa00a89c94 | [
"MIT"
] | permissive | niansa/xtd | a5050e27fda1f092cea85db264820d6518994893 | 4d412ab046f51da2e5baf782f9f2f5bb23c49840 | refs/heads/master | 2023-09-01T01:13:25.592979 | 2021-10-28T14:30:05 | 2021-10-28T14:30:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,113 | h | /// @file
/// @brief Contains parse methods.
#pragma once
/// @cond
#ifndef __XTD_CORE_INTERNAL__
#error "Do not include this file: Internal use only"
#endif
/// @endcond
#include <locale>
#include <string>
#include <sstream>
#include "../number_styles.h"
/// @cond
void __throw_parse_format_exception(const std::string& message);
void __throw_parse_overflow_exception();
template <typename char_t>
inline std::basic_string<char_t> __parse_remove_decorations(const std::basic_string<char_t>& s, xtd::number_styles styles) {
std::basic_string<char_t> str(s);
if ((styles & xtd::number_styles::allow_leading_white) == xtd::number_styles::allow_leading_white) {
while(str.size() > 0 && (str[0] == 9 || str[0] == 10 || str[0] == 11 || str[0] == 12 || str[0] == 13 || str[0] == 32))
str.erase(0, 1);
}
if ((styles & xtd::number_styles::allow_trailing_white) == xtd::number_styles::allow_trailing_white) {
while(str.size() > 0 && (str[str.size() - 1] == 9 || str[str.size() - 1] == 10 || str[str.size() - 1] == 11 || str[str.size() - 1] == 12 || str[str.size() - 1] == 13 || str[str.size() - 1] == 32))
str.erase(str.size() - 1, 1);
}
if ((styles & xtd::number_styles::allow_currency_symbol) == xtd::number_styles::allow_currency_symbol && str.find(std::use_facet<std::moneypunct<char_t>>(std::locale()).curr_symbol()) == 0) str.erase(0, std::use_facet<std::moneypunct<char_t>>(std::locale()).curr_symbol().size());
if ((styles & xtd::number_styles::allow_currency_symbol) == xtd::number_styles::allow_currency_symbol && str.rfind(std::use_facet<std::moneypunct<char_t>>(std::locale()).curr_symbol()) + std::use_facet<std::moneypunct<char_t>>(std::locale()).curr_symbol().size() == str.size()) str = str.substr(0, str.size() - std::use_facet<std::moneypunct<char_t>>(std::locale()).curr_symbol().size());
if ((styles & xtd::number_styles::allow_binary_specifier) == xtd::number_styles::allow_binary_specifier && (str.find("0b") == 0 || str.find("0B") == 0)) str.erase(0, 2);
if ((styles & xtd::number_styles::allow_octal_specifier) == xtd::number_styles::allow_octal_specifier && str.find('0') == 0) str.erase(0, 1);
if ((styles & xtd::number_styles::allow_hex_specifier) == xtd::number_styles::allow_hex_specifier && (str.find("0x") == 0 || str.find("0X") == 0)) str.erase(0, 2);
return str;
}
template <typename char_t>
inline int __parse_remove_signs(std::basic_string<char_t>& str, xtd::number_styles styles) {
int sign = 0;
while ((styles & xtd::number_styles::allow_leading_sign) == xtd::number_styles::allow_leading_sign && str.find("+") == 0) {
if (sign != 0) __throw_parse_format_exception("String contains more than one sign");
str = str.substr(1, str.size()-1);
sign += 1;
}
while ((styles & xtd::number_styles::allow_leading_sign) == xtd::number_styles::allow_leading_sign && str.find("-") == 0) {
if (sign != 0) __throw_parse_format_exception("String contains more than one sign");
str = str.substr(1, str.size()-1);
sign -= 1;
}
while ((styles & xtd::number_styles::allow_trailing_sign) == xtd::number_styles::allow_trailing_sign && str.rfind("+") + 1 == str.size()) {
if (sign != 0) __throw_parse_format_exception("String contains more than one sign");
str = str.substr(0, str.size()-1);
sign += 1;
}
while ((styles & xtd::number_styles::allow_trailing_sign) == xtd::number_styles::allow_trailing_sign && str.rfind("-") + 1 == str.size()) {
if (sign != 0) __throw_parse_format_exception("String contains more than one sign");
str = str.substr(0, str.size()-1);
sign -= 1;
}
while ((styles & xtd::number_styles::allow_parentheses) == xtd::number_styles::allow_parentheses && str.find("(") == 0 && str.rfind(")") + 1 == str.size()) {
str = str.substr(1, str.size()-2);
if (sign != 0) __throw_parse_format_exception("String contains more than one sign");
sign -= 1;
}
return sign;
}
template <typename char_t>
inline void __parse_check_valid_characters(const std::basic_string<char_t>& str, xtd::number_styles styles) {
std::basic_string<char_t> valid_characters = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
if ((styles & xtd::number_styles::allow_binary_specifier) == xtd::number_styles::allow_binary_specifier) valid_characters.erase(2);
if ((styles & xtd::number_styles::allow_octal_specifier) == xtd::number_styles::allow_octal_specifier) valid_characters.erase(7);
if ((styles & xtd::number_styles::allow_hex_specifier) == xtd::number_styles::allow_hex_specifier) valid_characters += std::basic_string<char_t> {'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'};
if ((styles & xtd::number_styles::allow_decimal_point) == xtd::number_styles::allow_decimal_point) valid_characters += std::basic_string<char_t> {std::use_facet<std::numpunct<char_t>>(std::locale()).decimal_point(), '.'};
if ((styles & xtd::number_styles::allow_thousands) == xtd::number_styles::allow_thousands) valid_characters += std::use_facet<std::numpunct<char_t>>(std::locale()).thousands_sep();
if ((styles & xtd::number_styles::allow_exponent) == xtd::number_styles::allow_exponent) valid_characters += std::basic_string<char_t> {'E', 'e', '+', '-'};
for (auto c : str) {
if (valid_characters.find(c) == std::basic_string<char_t>::npos)
__throw_parse_format_exception("invalid character found");
}
if ((styles & xtd::number_styles::allow_decimal_point) == xtd::number_styles::allow_decimal_point) {
size_t index = str.find(std::use_facet<std::numpunct<char_t>>(std::locale()).decimal_point());
if (index != std::basic_string<char_t>::npos && str.find(std::use_facet<std::numpunct<char_t>>(std::locale()).decimal_point(), index + 1) != std::basic_string<char_t>::npos)
__throw_parse_format_exception("invalid character found");
}
if ((styles & xtd::number_styles::allow_thousands) == xtd::number_styles::allow_thousands) {
size_t index = 1;
while((index = str.find(std::use_facet<std::numpunct<char_t>>(std::locale()).thousands_sep(), index)) != std::basic_string<char_t>::npos) {
if (str[index - 1] == std::use_facet<std::numpunct<char_t>>(std::locale()).thousands_sep())
__throw_parse_format_exception("invalid character found");
++index;
}
}
if ((styles & xtd::number_styles::allow_exponent) == xtd::number_styles::allow_exponent) {
size_t index = str.find('+');
if (index == std::basic_string<char_t>::npos) index = str.find('-');
if (index != std::basic_string<char_t>::npos && str[index - 1] != 'e' && str[index - 1] != 'E')
__throw_parse_format_exception("invalid character found");
}
}
template <typename value_t, typename char_t>
inline value_t __parse_floating_point(const std::basic_string<char_t>& str, int sign, xtd::number_styles styles) {
long double result;
if ((styles & xtd::number_styles::allow_thousands) != xtd::number_styles::allow_thousands)
result = std::stold(str, nullptr);
else {
std::stringstream ss(str);
ss.imbue(std::locale());
ss >> result;
}
result = sign < 0 ? -result : result;
if (result < std::numeric_limits<value_t>::lowest() || result > std::numeric_limits<value_t>::max()) __throw_parse_overflow_exception();
return static_cast<value_t>(result);
}
template <typename value_t, typename char_t>
inline value_t __parse_signed(const std::basic_string<char_t>& str, int base, int sign, xtd::number_styles styles) {
long long result;
if ((styles & xtd::number_styles::allow_thousands) != xtd::number_styles::allow_thousands)
result = std::stoll(str, nullptr, base);
else {
std::stringstream ss(str);
ss.imbue(std::locale());
ss >> result;
}
result = sign < 0 ? -result : result;
if (result < std::numeric_limits<value_t>::lowest() || result > std::numeric_limits<value_t>::max()) __throw_parse_overflow_exception();
return static_cast<value_t>(result);
}
template <typename value_t, typename char_t>
inline value_t __parse_unsigned(const std::basic_string<char_t>& str, int base, xtd::number_styles styles) {
unsigned long long result = 0;
if ((styles & xtd::number_styles::allow_thousands) != xtd::number_styles::allow_thousands)
result = std::stoull(str, nullptr, base);
else{
std::stringstream ss(str);
ss.imbue(std::locale());
ss >> result;
}
if (result > std::numeric_limits<value_t>::max()) __throw_parse_overflow_exception();
return static_cast<value_t>(result);
}
template <typename value_t, typename char_t>
inline value_t __parse_floating_point_number(const std::basic_string<char_t>& s, xtd::number_styles styles) {
if ((styles & xtd::number_styles::binary_number) == xtd::number_styles::binary_number) __throw_parse_format_exception("xtd::number_styles::binary_number not supported by floating point");
if ((styles & xtd::number_styles::octal_number) == xtd::number_styles::octal_number) __throw_parse_format_exception("xtd::number_styles::octal_number not supported by floating point");
if ((styles & xtd::number_styles::hex_number) == xtd::number_styles::hex_number) __throw_parse_format_exception("xtd::number_styles::hex_number not supported by floating point");
std::basic_string<char_t> str = __parse_remove_decorations(s, styles);
int sign = __parse_remove_signs(str, styles);
__parse_check_valid_characters(str, styles);
long double result;
if ((styles & xtd::number_styles::allow_thousands) != xtd::number_styles::allow_thousands)
result = std::stold(str, nullptr);
else {
std::stringstream ss(str);
ss.imbue(std::locale());
ss >> result;
}
result = sign < 0 ? -result : result;
if (result < std::numeric_limits<value_t>::lowest() || result > std::numeric_limits<value_t>::max()) __throw_parse_overflow_exception();
return static_cast<value_t>(result);
}
template <typename value_t, typename char_t>
inline value_t __parse_number(const std::basic_string<char_t>& s, xtd::number_styles styles) {
if ((styles & xtd::number_styles::allow_binary_specifier) == xtd::number_styles::allow_binary_specifier && (styles - xtd::number_styles::binary_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
if ((styles & xtd::number_styles::allow_octal_specifier) == xtd::number_styles::allow_octal_specifier && (styles - xtd::number_styles::octal_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
if ((styles & xtd::number_styles::allow_hex_specifier) == xtd::number_styles::allow_hex_specifier && (styles - xtd::number_styles::hex_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
int base = 10;
if ((styles & xtd::number_styles::binary_number) == xtd::number_styles::binary_number) base = 2;
if ((styles & xtd::number_styles::octal_number) == xtd::number_styles::octal_number) base = 8;
if ((styles & xtd::number_styles::hex_number) == xtd::number_styles::hex_number) base = 16;
std::basic_string<char_t> str = __parse_remove_decorations(s, styles);
int sign = __parse_remove_signs(str, styles);
__parse_check_valid_characters(str, styles);
if (std::is_floating_point<value_t>::value || (styles & xtd::number_styles::allow_exponent) == xtd::number_styles::allow_exponent) return __parse_floating_point<value_t>(str, sign, styles);
return __parse_signed<value_t>(str, base, sign, styles);
}
template <typename value_t, typename char_t>
inline value_t __parse_unsigned_number(const std::basic_string<char_t>& s, xtd::number_styles styles) {
if ((styles & xtd::number_styles::allow_binary_specifier) == xtd::number_styles::allow_binary_specifier && (styles - xtd::number_styles::binary_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
if ((styles & xtd::number_styles::allow_octal_specifier) == xtd::number_styles::allow_octal_specifier && (styles - xtd::number_styles::octal_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
if ((styles & xtd::number_styles::allow_hex_specifier) == xtd::number_styles::allow_hex_specifier && (styles - xtd::number_styles::hex_number) != xtd::number_styles::none) __throw_parse_format_exception("Invalid xtd::number_styles flags");
int base = 10;
if ((styles & xtd::number_styles::binary_number) == xtd::number_styles::binary_number) base = 2;
if ((styles & xtd::number_styles::octal_number) == xtd::number_styles::octal_number) base = 8;
if ((styles & xtd::number_styles::hex_number) == xtd::number_styles::hex_number) base = 16;
std::basic_string<char_t> str = __parse_remove_decorations(s, styles);
if (__parse_remove_signs(str, styles) < 0) __throw_parse_format_exception("unsigned type can't have minus sign");
__parse_check_valid_characters(str, styles);
if ((styles & xtd::number_styles::allow_exponent) == xtd::number_styles::allow_exponent) return __parse_floating_point<value_t>(str, 0, styles);
return __parse_unsigned<value_t>(str, base, styles);
}
/// @endcond
| [
"gammasoft71@gmail.com"
] | gammasoft71@gmail.com |
b913e0a2337bace72920c42fbcbcd176e1493faf | 2e6285e6bcf305260b3a22fdcce144ff3f0dc494 | /src/Rs2StreamProps.cpp | b60ef9e947ab3772f2ddf34b41b43a1e2bf85521 | [] | no_license | PaloAlto-Group/RealSense-OpenNI2-Wrapper | 72a13e6b9bca7b22b0c37a7bb3a9f22dcafac724 | 6de9e3b3ded7de9927d3b4bcc7cdedaab07669f3 | refs/heads/master | 2020-03-28T06:27:58.111366 | 2018-09-07T14:46:01 | 2018-09-07T14:46:01 | 147,836,497 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,783 | cpp | #include "Rs2Driver.h"
#include "PS1080.h"
#include "D2S.h"
#include "S2D.h"
static const unsigned long long GAIN_VAL = 42;
static const unsigned long long CONST_SHIFT_VAL = 200;
static const unsigned long long MAX_SHIFT_VAL = 2047;
static const unsigned long long PARAM_COEFF_VAL = 4;
static const unsigned long long SHIFT_SCALE_VAL = 10;
static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120;
static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836;
static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5;
namespace oni { namespace driver {
OniStatus Rs2Stream::setProperty(int propertyId, const void* data, int dataSize)
{
SCOPED_PROFILER;
rsTraceFunc("propertyId=%d dataSize=%d", propertyId, dataSize);
switch (propertyId)
{
case ONI_STREAM_PROPERTY_VIDEO_MODE:
{
if (data && (dataSize == sizeof(OniVideoMode)))
{
OniVideoMode* mode = (OniVideoMode*)data;
rsLogDebug("set video mode: %dx%d @%d format=%d",
(int)mode->resolutionX, (int)mode->resolutionY, (int)mode->fps, (int)mode->pixelFormat);
if (isVideoModeSupported(mode))
{
m_videoMode = *mode;
return ONI_STATUS_OK;
}
}
break;
}
case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE:
{
if (data && dataSize == sizeof(OniBool) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = (float)*((OniBool*)data);
rs2_set_option((const rs2_options*)m_sensor, RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, value, &e);
if (e.success()) return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_AUTO_EXPOSURE:
{
if (data && dataSize == sizeof(OniBool) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = (float)*((OniBool*)data);
rs2_set_option((const rs2_options*)m_sensor, RS2_OPTION_ENABLE_AUTO_EXPOSURE, value, &e);
if (e.success()) return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_EXPOSURE:
{
if (data && dataSize == sizeof(int) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = (float)*((int*)data);
rs2_set_option((const rs2_options*)m_sensor, RS2_OPTION_EXPOSURE, value, &e);
if (e.success()) return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_GAIN:
{
if (data && dataSize == sizeof(int) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = (float)*((int*)data);
rs2_set_option((const rs2_options*)m_sensor, RS2_OPTION_GAIN, value, &e);
if (e.success()) return ONI_STATUS_OK;
}
break;
}
default:
{
#if defined(RS2_TRACE_NOT_SUPPORTED_PROPS)
rsTraceError("Not supported: propertyId=%d", propertyId);
#endif
return ONI_STATUS_NOT_SUPPORTED;
}
}
rsTraceError("propertyId=%d dataSize=%d", propertyId, dataSize);
return ONI_STATUS_ERROR;
}
OniStatus Rs2Stream::getProperty(int propertyId, void* data, int* dataSize)
{
SCOPED_PROFILER;
switch (propertyId)
{
case ONI_STREAM_PROPERTY_CROPPING:
{
if (data && dataSize && *dataSize == sizeof(OniCropping))
{
OniCropping value;
value.enabled = false;
value.originX = 0;
value.originY = 0;
value.width = m_videoMode.resolutionX;
value.height = m_videoMode.resolutionY;
*((OniCropping*)data) = value;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_HORIZONTAL_FOV:
{
if (data && dataSize && *dataSize == sizeof(float))
{
*((float*)data) = m_fovX * 0.01745329251994329576923690768489f;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_VERTICAL_FOV:
{
if (data && dataSize && *dataSize == sizeof(float))
{
*((float*)data) = m_fovY * 0.01745329251994329576923690768489f;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_VIDEO_MODE:
{
if (data && dataSize && *dataSize == sizeof(OniVideoMode))
{
*((OniVideoMode*)data) = m_videoMode;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_MAX_VALUE:
{
if (data && dataSize && *dataSize == sizeof(int) && m_oniType == ONI_SENSOR_DEPTH)
{
*((int*)data) = ONI_MAX_DEPTH;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_MIN_VALUE:
{
if (data && dataSize && *dataSize == sizeof(int) && m_oniType == ONI_SENSOR_DEPTH)
{
*((int*)data) = 0;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_STRIDE:
{
if (data && dataSize && *dataSize == sizeof(int))
{
*((int*)data) = m_videoMode.resolutionX * getPixelFormatBytes(convertPixelFormat(m_videoMode.pixelFormat));
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_MIRRORING:
{
if (data && dataSize && *dataSize == sizeof(OniBool))
{
*((OniBool*)data) = false;
return ONI_STATUS_OK;
}
break;
}
case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE:
{
if (data && dataSize && *dataSize == sizeof(OniBool) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = rs2_get_option((const rs2_options*)m_sensor, RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, &e);
if (e.success())
{
*((OniBool*)data) = (int)value ? true : false;
return ONI_STATUS_OK;
}
}
break;
}
case ONI_STREAM_PROPERTY_AUTO_EXPOSURE:
{
if (data && dataSize && *dataSize == sizeof(OniBool) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = rs2_get_option((const rs2_options*)m_sensor, RS2_OPTION_ENABLE_AUTO_EXPOSURE, &e);
if (e.success())
{
*((OniBool*)data) = (int)value ? true : false;
return ONI_STATUS_OK;
}
}
break;
}
case ONI_STREAM_PROPERTY_EXPOSURE:
{
if (data && dataSize && *dataSize == sizeof(int) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = rs2_get_option((const rs2_options*)m_sensor, RS2_OPTION_EXPOSURE, &e);
if (e.success())
{
*((int*)data) = (int)value;
return ONI_STATUS_OK;
}
}
break;
}
case ONI_STREAM_PROPERTY_GAIN:
{
if (data && dataSize && *dataSize == sizeof(int) && m_oniType == ONI_SENSOR_COLOR)
{
Rs2Error e;
float value = rs2_get_option((const rs2_options*)m_sensor, RS2_OPTION_GAIN, &e);
if (e.success())
{
*((int*)data) = (int)value;
return ONI_STATUS_OK;
}
}
break;
}
case XN_STREAM_PROPERTY_GAIN:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = GAIN_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_CONST_SHIFT:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = CONST_SHIFT_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_MAX_SHIFT:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = MAX_SHIFT_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_PARAM_COEFF:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = PARAM_COEFF_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_SHIFT_SCALE:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = SHIFT_SCALE_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE:
{
if (data && dataSize && *dataSize == sizeof(unsigned long long) && m_oniType == ONI_SENSOR_DEPTH)
{
*((unsigned long long*)data) = ZERO_PLANE_DISTANCE_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE:
{
if (data && dataSize && *dataSize == sizeof(double) && m_oniType == ONI_SENSOR_DEPTH)
{
*((double*)data) = ZERO_PLANE_PIXEL_SIZE_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE:
{
if (data && dataSize && *dataSize == sizeof(double) && m_oniType == ONI_SENSOR_DEPTH)
{
*((double*)data) = EMITTER_DCMOS_DISTANCE_VAL;
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_S2D_TABLE:
{
if (data && dataSize && *dataSize >= sizeof(S2D) && m_oniType == ONI_SENSOR_DEPTH)
{
memcpy(data, S2D, sizeof(S2D));
*dataSize = sizeof(S2D);
return ONI_STATUS_OK;
}
break;
}
case XN_STREAM_PROPERTY_D2S_TABLE:
{
if (data && dataSize && *dataSize >= sizeof(D2S) && m_oniType == ONI_SENSOR_DEPTH)
{
memcpy(data, D2S, sizeof(D2S));
*dataSize = sizeof(D2S);
return ONI_STATUS_OK;
}
break;
}
default:
{
#if defined(RS2_TRACE_NOT_SUPPORTED_PROPS)
rsTraceError("Not supported: propertyId=%d", propertyId);
#endif
return ONI_STATUS_NOT_SUPPORTED;
}
}
rsTraceError("propertyId=%d dataSize=%d", propertyId, *dataSize);
return ONI_STATUS_ERROR;
}
OniBool Rs2Stream::isPropertySupported(int propertyId)
{
switch (propertyId)
{
case ONI_STREAM_PROPERTY_CROPPING: // OniCropping*
case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians
case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians
case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode*
case ONI_STREAM_PROPERTY_MAX_VALUE: // int
case ONI_STREAM_PROPERTY_MIN_VALUE: // int
case ONI_STREAM_PROPERTY_STRIDE: // int
case ONI_STREAM_PROPERTY_MIRRORING: // OniBool
return true;
case ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES: // int
return false;
case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool
case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool
case ONI_STREAM_PROPERTY_EXPOSURE: // int
case ONI_STREAM_PROPERTY_GAIN: // int
return true;
case XN_STREAM_PROPERTY_GAIN:
case XN_STREAM_PROPERTY_CONST_SHIFT:
case XN_STREAM_PROPERTY_MAX_SHIFT:
case XN_STREAM_PROPERTY_PARAM_COEFF:
case XN_STREAM_PROPERTY_SHIFT_SCALE:
case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE:
case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE:
case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE:
case XN_STREAM_PROPERTY_S2D_TABLE:
case XN_STREAM_PROPERTY_D2S_TABLE:
return true;
default:
return false;
}
}
}} // namespace
| [
"felixpochta@gmail.com"
] | felixpochta@gmail.com |
1bf4d2aa66922694c22298005afb8079089af58f | 02ba9f130074c966bbd919b290d10e6279ce467d | /src/ServerSocket.cpp | a867157b14c71ffa016d6eb91ee8bd1f24cb169c | [] | no_license | hockey-for-NOI/NaiveChat | 0f2c1984a6994984fb18ffbfa7919b0516460bb0 | 6b8ab92d6861abea6010ab39da507f9a93051413 | refs/heads/master | 2021-09-01T05:59:37.880133 | 2017-12-25T07:29:40 | 2017-12-25T07:29:40 | 114,636,305 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | cpp | #include "ServerSocket.h"
namespace NaiveChat
{
bool ServerSocket::bindport(int port)
{
if (m_sid == -1) return 0;
m_addr.sin_family = AF_INET;
m_addr.sin_addr.s_addr = INADDR_ANY;
m_addr.sin_port = htons(port);
return bind(m_sid, (sockaddr*)&m_addr, sizeof(sockaddr)) != -1;
}
bool ServerSocket::listento() const
{
if (m_sid == -1) return 0;
return listen(m_sid, MAX_USER) != -1;
}
bool ServerSocket::acceptconn(ServerSocket& new_s) const
{
int tmp = sizeof(sockaddr);
return (new_s.m_sid = accept(m_sid, (sockaddr*)&m_addr, (socklen_t*)&tmp)) != -1;
}
} // end namespace NaiveChat
| [
"hq15@mails.tsinghua.edu.cn"
] | hq15@mails.tsinghua.edu.cn |
c366ce33d4641bccced0e67c8b53fef42070c4f5 | ca2c894d370c1c517d18c930f8bffd3e91f22321 | /ejer22.cpp | fc6fa6a0b37e776446ef96abb21174ac9ce77d69 | [] | no_license | LDAA99/ejercicio22 | 480dc96935e82c658e3c7d190d0748d0274ef31b | d0a4e0ef270d8c9f8120559487732ff532ff0a7f | refs/heads/master | 2020-03-12T22:47:16.808123 | 2018-04-24T12:54:43 | 2018-04-24T12:54:43 | 130,853,624 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 731 | cpp | #include <iostream>
using std::cout;
using std::cin;
using std::endl;
float gauss(float x);
float gauss(float x){
float sig=0.1, x0=1.0;
float w=2*sig*sig;
int i;
float v=(x-x0)*(x-x0)/w
return exp(-v)
}
void avanza(double x; double *uant, double *uneo, int nx, double deltat, double deltax, int D){
if(x==0.0 || x=2.0){
uneo[i]=0.0;
uant[i]=0.0;
}
else{
for(i=1; i<nx-1; i++){
uneo[i]=uant[i]+(deltat*D)*((1.0/(deltax*deltax))*(uant[i+1]-2*uant[i]+uant[i-1]));
uneo[i]=uant[i];
}
}
}
int main(){
int D=1.0, i;
double deltat=0.01, T=0.5, t=0.0;
double minx=0.0, maxx=2.0, deltax=0.01;
int nx=(maxx-minx)/(deltax-1);
double *uant, *uneo;
uant=new double[nx];
uneo= new double[nx];
}
| [
"noreply@github.com"
] | noreply@github.com |
a8ea3505d9b07038351e9ac57ddcedccbcd390c5 | a81c07a5663d967c432a61d0b4a09de5187be87b | /chrome/browser/chromeos/policy/scheduled_update_checker/device_scheduled_update_checker.h | eafafcf948b2e43f57f3d48eacdfe7fca6977d94 | [
"BSD-3-Clause"
] | permissive | junxuezheng/chromium | c401dec07f19878501801c9e9205a703e8643031 | 381ce9d478b684e0df5d149f59350e3bc634dad3 | refs/heads/master | 2023-02-28T17:07:31.342118 | 2019-09-03T01:42:42 | 2019-09-03T01:42:42 | 205,967,014 | 2 | 0 | BSD-3-Clause | 2019-09-03T01:48:23 | 2019-09-03T01:48:23 | null | UTF-8 | C++ | false | false | 7,616 | h | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_SCHEDULED_UPDATE_CHECKER_DEVICE_SCHEDULED_UPDATE_CHECKER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_SCHEDULED_UPDATE_CHECKER_DEVICE_SCHEDULED_UPDATE_CHECKER_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/policy/scheduled_update_checker/os_and_policies_update_checker.h"
#include "chrome/browser/chromeos/policy/scheduled_update_checker/scoped_wake_lock.h"
#include "chrome/browser/chromeos/policy/scheduled_update_checker/task_executor_with_retries.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/dbus/power/native_timer.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/settings/timezone_settings.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "third_party/icu/source/i18n/unicode/calendar.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
namespace service_manager {
class Connector;
} // namespace service_manager
namespace policy {
// This class listens for changes in the scheduled update check policy and then
// manages recurring update checks based on the policy.
class DeviceScheduledUpdateChecker
: public chromeos::system::TimezoneSettings::Observer {
public:
DeviceScheduledUpdateChecker(
chromeos::CrosSettings* cros_settings,
chromeos::NetworkStateHandler* network_state_handler,
service_manager::Connector* connector);
~DeviceScheduledUpdateChecker() override;
// Frequency at which the update check should occur.
enum class Frequency {
kDaily,
kWeekly,
kMonthly,
};
// Holds the data associated with the current scheduled update check policy.
struct ScheduledUpdateCheckData {
ScheduledUpdateCheckData();
ScheduledUpdateCheckData(const ScheduledUpdateCheckData&);
~ScheduledUpdateCheckData();
// Corresponds to UCAL_HOUR_OF_DAY in icu::Calendar.
int hour;
// Corresponds to UCAL_MINUTE in icu::Calendar.
int minute;
Frequency frequency;
// Only set when frequency is |kWeekly|. Corresponds to UCAL_DAY_OF_WEEK in
// icu::Calendar. Values between 1 (SUNDAY) to 7 (SATURDAY).
base::Optional<UCalendarDaysOfWeek> day_of_week;
// Only set when frequency is |kMonthly|. Corresponds to UCAL_DAY_OF_MONTH
// in icu::Calendar i.e. values between 1 to 31.
base::Optional<int> day_of_month;
// Absolute time ticks when the next update check (i.e. |UpdateCheck|) will
// happen.
base::TimeTicks next_update_check_time_ticks;
};
// chromeos::system::TimezoneSettings::Observer implementation.
void TimezoneChanged(const icu::TimeZone& time_zone) override;
protected:
// Called when |update_check_timer_| fires. Triggers an update check and
// schedules the next update check based on |scheduled_update_check_data_|.
virtual void OnUpdateCheckTimerExpired();
// Calculates the delay from |cur_time| at which |update_check_timer_| should
// run next. Returns 0 delay if the calculation failed due to a concurrent DST
// or Time Zone change. Requires |scheduled_update_check_data_| to be set.
virtual base::TimeDelta CalculateNextUpdateCheckTimerDelay(
base::Time cur_time);
// Called when |os_and_policies_update_checker_| has finished successfully or
// unsuccessfully after retrying.
virtual void OnUpdateCheckCompletion(ScopedWakeLock scoped_wake_lock,
bool result);
private:
// Callback triggered when scheduled update check setting has changed.
void OnScheduledUpdateCheckDataChanged();
// Must only be run via |start_update_check_timer_task_executor_|. Sets
// |update_check_timer_| based on |scheduled_update_check_data_|. If the
// |update_check_timer_| can't be started due to an error in
// |CalculateNextUpdateCheckTimerDelay| then reschedules itself via
// |start_update_check_timer_task_executor_|. Requires
// |scheduled_update_check_data_| to be set.
void StartUpdateCheckTimer(ScopedWakeLock scoped_wake_lock);
// Called upon starting |update_check_timer_|. Indicates whether or not the
// timer was started successfully.
void OnUpdateCheckTimerStartResult(ScopedWakeLock scoped_wake_lock,
bool result);
// Called when |start_update_check_timer_task_executor_|'s retry limit has
// been reached.
void OnStartUpdateCheckTimerRetryFailure();
// Starts or retries |StartUpdateCheckTimer| via
// |start_update_check_timer_task_executor_| based on |is_retry|.
void MaybeStartUpdateCheckTimer(ScopedWakeLock scoped_wake_lock,
bool is_retry);
// Reset all state and cancel all pending tasks
void ResetState();
// Returns current time.
virtual base::Time GetCurrentTime();
// Returns time ticks from boot including time ticks spent during sleeping.
virtual base::TimeTicks GetTicksSinceBoot();
// Returns the current time zone.
virtual const icu::TimeZone& GetTimeZone();
// Used to retrieve Chrome OS settings. Not owned.
chromeos::CrosSettings* const cros_settings_;
// Owned by chromeos::assistant::Service.
service_manager::Connector* const connector_;
// Used to observe when settings change.
std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
cros_settings_observer_;
// Currently active scheduled update check policy.
base::Optional<ScheduledUpdateCheckData> scheduled_update_check_data_;
// Used to run and retry |StartUpdateCheckTimer| if it fails.
TaskExecutorWithRetries start_update_check_timer_task_executor_;
// Used to initiate update checks when |update_check_timer_| fires.
OsAndPoliciesUpdateChecker os_and_policies_update_checker_;
// Timer that is scheduled to check for updates.
std::unique_ptr<chromeos::NativeTimer> update_check_timer_;
base::WeakPtrFactory<DeviceScheduledUpdateChecker> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DeviceScheduledUpdateChecker);
};
namespace update_checker_internal {
// The maximum iterations allowed to start an update check timer if the
// operation fails.
constexpr int kMaxStartUpdateCheckTimerRetryIterations = 5;
// Time to call |StartUpdateCheckTimer| again in case it failed.
constexpr base::TimeDelta kStartUpdateCheckTimerRetryTime =
base::TimeDelta::FromMinutes(1);
// Used as canonical value for timer delay calculations.
constexpr base::TimeDelta kInvalidDelay = base::TimeDelta();
// Parses |value| into a |ScheduledUpdateCheckData|. Returns nullopt if there
// is any error while parsing |value|.
base::Optional<DeviceScheduledUpdateChecker::ScheduledUpdateCheckData>
ParseScheduledUpdate(const base::Value& value);
// Converts an icu::Calendar to base::Time. Assumes |time| is valid.
base::Time IcuToBaseTime(const icu::Calendar& time);
// Calculates the difference in milliseconds of |a| - |b|. Caller has to ensure
// |a| >= |b|.
base::TimeDelta GetDiff(const icu::Calendar& a, const icu::Calendar& b);
// Converts |cur_time| to ICU time in the time zone |tz|.
std::unique_ptr<icu::Calendar> ConvertUtcToTzIcuTime(base::Time cur_time,
const icu::TimeZone& tz);
} // namespace update_checker_internal
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_SCHEDULED_UPDATE_CHECKER_DEVICE_SCHEDULED_UPDATE_CHECKER_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
35d377f2f82e3b47fd589b0117dcdc0d26bb6eb9 | fe5acc18af838cec51a43ec8a8635cfae99631a5 | /Hukimasu2/vmath.h | e84a392b24d3b3d02324677e2c0638e8b056b9b6 | [] | no_license | wdevore/Hukimasu2 | 008fbfc01ced539f17788f932c61e419320b94f9 | 2c2bf5dad1bce106684fa0de03190bfe64bbd04d | refs/heads/master | 2021-01-15T23:28:12.618600 | 2017-08-10T15:24:27 | 2017-08-10T15:24:27 | 99,936,811 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 100,195 | h | /* -*- C++ -*- */
/*
* vmath, set of classes for computer graphics mathemtics.
* Copyright (c) 2005-2011, Jan Bartipan < barzto at gmail dot com >
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the 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.
*/
/**
* @mainpage Vector mathemtics for computer graphics
*
* @section Features
* <ul>
* <li> basic aritemetic operations - using operators </li>
* <li> basic linear algebra operations - such as transpose, dot product, etc. </li>
* <li> aliasis for vertex coordinates - it means:
* <pre>
* Vector3f v;
* // use vertex coordinates
* v.x = 1; v.y = 2; v.z = -1;
*
* // use texture coordinates
* v.s = 0; v.t = 1; v.u = 0.5;
* // use color coordinates
* v.r = 1; v.g = 0.5; v.b = 0;
* </pre>
* </li>
* <li> conversion constructor and assign operators - so you can assign a value of Vector3<T1> type
* to a variable of Vector3<T2> type for any convertable T1, T2 type pairs. In other words, you can do this:
* <pre>
*
* Vector3f f3; Vector3d d3 = f3;
* ...
* f3 = d3;
* </pre>
* </li>
* </ul>
*/
#ifndef __vmath_Header_File__
#define __vmath_Header_File__
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#ifdef VMATH_NAMESPACE
namespace VMATH_NAMESPACE
{
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#define DEG2RAD(x) ((x * M_PI) / 180.0)
//#define EPSILON (4.37114e-07)
const double epsilon = 4.37114e-05;
#define EPSILON epsilon
/**
* Class for two dimensional vector.
*/
template <class T>
class Vector2
{
public:
union
{
/**
* First element of vector, alias for X-coordinate.
*/
T x;
/**
* First element of vector, alias for S-coordinate.
* For textures notation.
*/
T s;
};
union
{
/**
* Second element of vector, alias for Y-coordinate.
*/
T y;
/**
* Second element of vector, alias for T-coordinate.
* For textures notation.
*/
T t;
};
//----------------[ constructors ]--------------------------
/**
* Creates and sets to (0,0)
*/
Vector2() : x(0),y(0)
{ }
/**
* Creates and sets to (x,y)
* @param nx intial x-coordinate value
* @param ny intial y-coordinate value
*/
Vector2(T nx, T ny) : x(nx), y(ny)
{ }
/**
* Copy constructor.
* @param src Source of data for new created instace.
*/
Vector2(const Vector2<T>& src)
: x(src.x), y(src.y)
{ }
/**
* Copy casting constructor.
* @param src Source of data for new created instace.
*/
template <class FromT>
Vector2(const Vector2<FromT>& src)
: x(static_cast<T>(src.x)),
y(static_cast<T>(src.y))
{ }
//----------------[ access operators ]-------------------
/**
* Copy casting operator
* @param rhs Right hand side argument of binary operator.
*/
template <class FromT>
Vector2<T>& operator=(const Vector2<FromT>& rhs)
{
x = static_cast<T>(rhs.x);
y = static_cast<T>(rhs.y);
return * this;
}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator=(const Vector2<T>& rhs)
{
x = rhs.x;
y = rhs.y;
return * this;
}
/**
* Array access operator
* @param n Array index
* @return For n = 0, reference to x coordinate, else reference to y
* y coordinate.
*/
T& operator[](int n)
{
assert(n >= 0 && n <= 1);
if (0 == n) return x;
else
return y;
}
//---------------[ vector aritmetic operator ]--------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator+(const Vector2<T>& rhs) const
{
return Vector2<T> (x + rhs.x, y + rhs.y);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator-(const Vector2<T>& rhs) const
{
return Vector2<T> (x - rhs.x, y - rhs.y);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator*(const Vector2<T>& rhs) const
{
return Vector2<T> (x * rhs.x, y * rhs.y);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator/(const Vector2<T>& rhs) const
{
return Vector2<T> (x / rhs.x, y / rhs.y);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator+=(const Vector2<T>& rhs)
{
x += rhs.x;
y += rhs.y;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator-=(const Vector2<T>& rhs)
{
x -= rhs.x;
y -= rhs.y;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator*=(const Vector2<T>& rhs)
{
x *= rhs.x;
y *= rhs.y;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator/=(const Vector2<T>& rhs)
{
x /= rhs.x;
y /= rhs.y;
return * this;
}
//--------------[ scalar vector operator ]--------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator+(T rhs) const
{
return Vector2<T> (x + rhs, y + rhs);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator-(T rhs) const
{
return Vector2<T> (x - rhs, y - rhs);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator*(T rhs) const
{
return Vector2<T> (x * rhs, y * rhs);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T> operator/(T rhs) const
{
return Vector2<T> (x / rhs, y / rhs);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator+=(T rhs)
{
x += rhs;
y += rhs;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator-=(T rhs)
{
x -= rhs;
y -= rhs;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator*=(T rhs)
{
x *= rhs;
y *= rhs;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector2<T>& operator/=(T rhs)
{
x /= rhs;
y /= rhs;
return * this;
}
//--------------[ equality operator ]------------------------
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition | lws.x - rhs.y | < EPSILON,
* same for y-coordinate.
*/
bool operator==(const Vector2<T>& rhs) const
{
return (std::abs(x - rhs.x) < EPSILON) && (std::abs(y - rhs.y) < EPSILON);
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Vector2<T>& rhs) const { return ! (*this == rhs); }
//-------------[ unary operations ]--------------------------
/**
* Unary negate operator
* @return negated vector
*/
Vector2<T> operator-() const
{
return Vector2<T>(-x, -y);
}
//-------------[ size operations ]---------------------------
/**
* Get lenght of vector.
* @return lenght of vector
*/
T length() const
{
return (T)std::sqrt(x * x + y * y);
}
/**
* Normalize vector
*/
void normalize()
{
T s = length();
x /= s;
y /= s;
}
/**
* Return square of length.
* @return lenght ^ 2
* @note This method is faster then length(). For comparsion
* of length of two vector can be used just this value, instead
* of computionaly more expensive length() method.
*/
T lengthSq() const
{
return x * x + y * y;
}
//--------------[ misc. operations ]-----------------------
/**
* Linear interpolation of two vectors
* @param fact Factor of interpolation. For translation from positon
* of this vector to vector r, values of factor goes from 0.0 to 1.0.
* @param r Second Vector for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Vector2<T> lerp(T fact, const Vector2<T>& r) const
{
return (*this) + (r - (*this)) * fact;
}
//-------------[ conversion ]-----------------------------
/**
* Conversion to pointer operator
* @return Pointer to internaly stored (in managment of class Vector2<T>)
* used for passing Vector2<T> values to gl*2[fd] functions.
*/
operator T*(){ return (T*) this; }
/**
* Conversion to pointer operator
* @return Constant Pointer to internaly stored (in managment of class Vector2<T>)
* used for passing Vector2<T> values to gl*2[fd] functions.
*/
operator const T*() const { return (const T*) this; }
//-------------[ output operator ]------------------------
/**
* Output to stream operator
* @param lhs Left hand side argument of operator (commonly ostream instance).
* @param rhs Right hand side argument of operator.
* @return Left hand side argument - the ostream object passed to operator.
*/
friend std::ostream& operator<<(std::ostream& lhs, const Vector2<T>& rhs)
{
lhs << "[" << rhs.x << "," << rhs.y << "]";
return lhs;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
//--------------------------------------
// Typedef shortcuts for 2D vector
//-------------------------------------
/// Two dimensional Vector of floats
typedef class Vector2 <float> Vector2f;
/// Two dimensional Vector of doubles
typedef class Vector2 <double> Vector2d;
/**
* Class for three dimensional vector.
*/
template <class T>
class Vector3
{
public:
//T x, y, z;
union
{
/**
* First element of vector, alias for X-coordinate.
*/
T x;
/**
* First element of vector, alias for S-coordinate.
* For textures notation.
*/
T s;
/**
* First element of vector, alias for R-coordinate.
* For color notation.
*/
T r;
};
union
{
/**
* Second element of vector, alias for Y-coordinate.
*/
T y;
/**
* Second element of vector, alias for T-coordinate.
* For textures notation.
*/
T t;
/**
* Second element of vector, alias for G-coordinate.
* For color notation.
*/
T g;
};
union
{
/**
* Third element of vector, alias for Z-coordinate.
*/
T z;
/**
* Third element of vector, alias for U-coordinate.
* For textures notation.
*/
T u;
/**
* Third element of vector, alias for B-coordinate.
* For color notation.
*/
T b;
};
//----------------[ constructors ]--------------------------
/**
* Creates and sets to (0,0,0)
*/
Vector3() : x(0),y(0),z(0)
{ }
/**
* Creates and sets to (x,y,z)
* @param nx intial x-coordinate value
* @param ny intial y-coordinate value
* @param nz intial z-coordinate value
*/
Vector3(T nx, T ny, T nz) : x(nx),y(ny),z(nz)
{ }
/**
* Copy constructor.
* @param src Source of data for new created Vector3 instance.
*/
Vector3(const Vector3<T>& src)
: x(src.x), y(src.y), z(src.z)
{}
/**
* Copy casting constructor.
* @param src Source of data for new created Vector3 instance.
*/
template <class FromT>
Vector3(const Vector3<FromT>& src)
: x(static_cast<T>(src.x)),
y(static_cast<T>(src.y)),
z(static_cast<T>(src.z))
{}
//----------------[ access operators ]-------------------
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator=(const Vector3<T>& rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
return * this;
}
/**
* Copy casting operator.
* @param rhs Right hand side argument of binary operator.
*/
template <class FromT>
Vector3<T> operator=(const Vector3<FromT>& rhs)
{
x = static_cast<T>(rhs.x);
y = static_cast<T>(rhs.y);
z = static_cast<T>(rhs.z);
return * this;
}
/**
* Array access operator
* @param n Array index
* @return For n = 0, reference to x coordinate, n = 1
* reference to y, else reference to z
* y coordinate.
*/
T & operator[](int n)
{
assert(n >= 0 && n <= 2);
if (0 == n) return x;
else if (1 == n) return y;
else
return z;
}
//---------------[ vector aritmetic operator ]--------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator+(const Vector3<T>& rhs) const
{
return Vector3<T> (x + rhs.x, y + rhs.y, z + rhs.z);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator-(const Vector3<T>& rhs) const
{
return Vector3<T> (x - rhs.x, y - rhs.y, z - rhs.z);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator*(const Vector3<T>& rhs) const
{
return Vector3<T> (x * rhs.x, y * rhs.y, z * rhs.z);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator/(const Vector3<T>& rhs) const
{
return Vector3<T> (x / rhs.x, y / rhs.y, z / rhs.z);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator+=(const Vector3<T>& rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator-=(const Vector3<T>& rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator*=(const Vector3<T>& rhs)
{
x *= rhs.x;
y *= rhs.y;
z *= rhs.z;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator/=(const Vector3<T>& rhs)
{
x /= rhs.x;
y /= rhs.y;
z /= rhs.z;
return * this;
}
/**
* Dot product of two vectors.
* @param rhs Right hand side argument of binary operator.
*/
T dotProduct(const Vector3<T>& rhs) const
{
return x * rhs.x + y * rhs.y + z * rhs.z;
}
/**
* Cross product opertor
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> crossProduct(const Vector3<T>& rhs) const
{
return Vector3<T> (y * rhs.z - rhs.y * z, z * rhs.x - rhs.z * x, x * rhs.y - rhs.x * y);
}
//--------------[ scalar vector operator ]--------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator+(T rhs) const
{
return Vector3<T> (x + rhs, y + rhs, z + rhs);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator-(T rhs) const
{
return Vector3<T> (x - rhs, y - rhs, z - rhs);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator*(T rhs) const
{
return Vector3<T> (x * rhs, y * rhs, z * rhs);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator/(T rhs) const
{
return Vector3<T> (x / rhs, y / rhs, z / rhs);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator+=(T rhs)
{
x += rhs;
y += rhs;
z += rhs;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator-=(T rhs)
{
x -= rhs;
y -= rhs;
z -= rhs;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator*=(T rhs)
{
x *= rhs;
y *= rhs;
z *= rhs;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T>& operator/=(T rhs)
{
x /= rhs;
y /= rhs;
z /= rhs;
return * this;
}
//--------------[ equiality operator ]------------------------
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition | lws.x - rhs.y | < EPSILON,
* same for y-coordinate, and z-coordinate.
*/
bool operator==(const Vector3<T>& rhs) const
{
return std::fabs(x - rhs.x) < EPSILON
&& std::fabs(y - rhs.y) < EPSILON
&& std::fabs(z - rhs.z) < EPSILON;
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Vector3<T>& rhs) const { return !(*this == rhs); }
//-------------[ unary operations ]--------------------------
/**
* Unary negate operator
* @return negated vector
*/
Vector3<T> operator-() const
{
return Vector3<T>(-x, -y, -z);
}
//-------------[ size operations ]---------------------------
/**
* Get lenght of vector.
* @return lenght of vector
*/
T length() const
{
return (T)std::sqrt(x * x + y * y + z * z);
}
/**
* Return square of length.
* @return lenght ^ 2
* @note This method is faster then length(). For comparsion
* of length of two vector can be used just this value, instead
* of computionaly more expensive length() method.
*/
T lengthSq() const
{
return x * x + y * y + z * z;
}
/**
* Normalize vector
*/
void normalize()
{
T s = length();
x /= s;
y /= s;
z /= s;
}
//------------[ other operations ]---------------------------
/**
* Rotate vector around three axis.
* @param ax Angle (in degrees) to be rotated around X-axis.
* @param ay Angle (in degrees) to be rotated around Y-axis.
* @param az Angle (in degrees) to be rotated around Z-axis.
*/
void rotate(T ax, T ay, T az)
{
T a = cos(DEG2RAD(ax));
T b = sin(DEG2RAD(ax));
T c = cos(DEG2RAD(ay));
T d = sin(DEG2RAD(ay));
T e = cos(DEG2RAD(az));
T f = sin(DEG2RAD(az));
T nx = c * e * x - c * f * y + d * z;
T ny = (a * f + b * d * e) * x + (a * e - b * d * f) * y - b * c * z;
T nz = (b * f - a * d * e) * x + (a * d * f + b * e) * y + a * c * z;
x = nx; y = ny; z = nz;
}
/**
* Linear interpolation of two vectors
* @param fact Factor of interpolation. For translation from positon
* of this vector to vector r, values of factor goes from 0.0 to 1.0.
* @param r Second Vector for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Vector3<T> lerp(T fact, const Vector3<T>& r) const
{
return (*this) + (r - (*this)) * fact;
}
//-------------[ conversion ]-----------------------------
/**
* Conversion to pointer operator
* @return Pointer to internaly stored (in managment of class Vector3<T>)
* used for passing Vector3<T> values to gl*3[fd] functions.
*/
operator T*(){ return (T*) this; }
/**
* Conversion to pointer operator
* @return Constant Pointer to internaly stored (in managment of class Vector3<T>)
* used for passing Vector3<T> values to gl*3[fd] functions.
*/
operator const T*() const { return (const T*) this; }
//-------------[ output operator ]------------------------
/**
* Output to stream operator
* @param lhs Left hand side argument of operator (commonly ostream instance).
* @param rhs Right hand side argument of operator.
* @return Left hand side argument - the ostream object passed to operator.
*/
friend std::ostream& operator<<(std::ostream& lhs, const Vector3<T> rhs)
{
lhs << "[" << rhs.x << "," << rhs.y << "," << rhs.z << "]";
return lhs;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
/// Three dimensional Vector of floats
typedef Vector3 <float> Vector3f;
/// Three dimensional Vector of doubles
typedef Vector3 <double> Vector3d;
/**
* Class for four dimensional vector.
*/
template <class T>
class Vector4{
public:
union
{
/**
* First element of vector, alias for R-coordinate.
* For color notation.
*/
T r
/**
* First element of vector, alias for X-coordinate.
*/;
T x;
};
union
{
/**
* Second element of vector, alias for G-coordinate.
* For color notation.
*/
T g;
/**
* Second element of vector, alias for Y-coordinate.
*/
T y;
};
union
{
/**
* Third element of vector, alias for B-coordinate.
* For color notation.
*/
T b;
/**
* Third element of vector, alias for Z-coordinate.
*/
T z;
};
union
{
/**
* Fourth element of vector, alias for A-coordinate.
* For color notation. This represnt aplha chanell
*/
T a;
/**
* First element of vector, alias for W-coordinate.
* @note For vectors (such as normals) should be set to 0.0
* For vertices should be set to 1.0
*/
T w;
};
//----------------[ constructors ]--------------------------
/**
* Creates and sets to (0,0,0,0)
*/
Vector4() : x(0),y(0),z(0),w(0)
{ }
/**
* Creates and sets to (x,y,z,z)
* @param nx intial x-coordinate value (R)
* @param ny intial y-coordinate value (G)
* @param nz intial z-coordinate value (B)
* @param nw intial w-coordinate value (Aplha)
*/
Vector4(T nx, T ny, T nz, T nw) : x(nx), y(ny), z(nz), w(nw)
{ }
/**
* Copy constructor.
* @param src Source of data for new created Vector4 instance.
*/
Vector4(const Vector4<T>& src)
: x(src.x), y(src.y), z(src.z), w(src.w)
{}
/**
* Copy casting constructor.
* @param src Source of data for new created Vector4 instance.
*/
template <class FromT>
Vector4(const Vector4<FromT>& src)
: x(static_cast<T>(src.x)),
y(static_cast<T>(src.y)),
z(static_cast<T>(src.z)),
w(static_cast<T>(src.w))
{}
//----------------[ access operators ]-------------------
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator=(const Vector4<T>& rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
w = rhs.w;
return * this;
}
/**
* Copy casting operator
* @param rhs Right hand side argument of binary operator.
*/
template<class FromT>
Vector4<T> operator=(const Vector4<FromT>& rhs)
{
x = static_cast<T>(rhs.x);
y = static_cast<T>(rhs.y);
z = static_cast<T>(rhs.z);
w = static_cast<T>(rhs.w);
return * this;
}
/**
* Array access operator
* @param n Array index
* @return For n = 0, reference to x coordinate, n = 1
* reference to y coordinate, n = 2 reference to z,
* else reference to w coordinate.
*/
T & operator[](int n)
{
assert(n >= 0 && n <= 3);
if (0 == n) return x;
else if (1 == n) return y;
else if (2 == n) return z;
else return w;
}
//---------------[ vector aritmetic operator ]--------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator+(const Vector4<T>& rhs) const
{
return Vector4<T> (x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator-(const Vector4<T>& rhs) const
{
return Vector4<T> (x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator*(const Vector4<T> rhs) const
{
return Vector4<T> (x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator/(const Vector4<T>& rhs) const
{
return Vector4<T> (x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator+=(const Vector4<T>& rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
w += rhs.w;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator-=(const Vector4<T>& rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
w -= rhs.w;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator*=(const Vector4<T>& rhs)
{
x *= rhs.x;
y *= rhs.y;
z *= rhs.z;
w *= rhs.w;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator/=(const Vector4<T>& rhs)
{
x /= rhs.x;
y /= rhs.y;
z /= rhs.z;
w /= rhs.w;
return * this;
}
//--------------[ equiality operator ]------------------------
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition | lws.x - rhs.y | < EPSILON,
* same for y-coordinate, z-coordinate, and w-coordinate.
*/
bool operator==(const Vector4<T>& rhs) const
{
return std::fabs(x - rhs.x) < EPSILON
&& std::fabs(y - rhs.y) < EPSILON
&& std::fabs(z - rhs.z) < EPSILON
&& std::fabs(w - rhs.w) < EPSILON;
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Vector4<T>& rhs) const { return ! (*this == rhs); }
//-------------[ unary operations ]--------------------------
/**
* Unary negate operator
* @return negated vector
*/
Vector4<T> operator-() const
{
return Vector4<T>(-x, -y, -z, -w);
}
//--------------[ scalar vector operator ]--------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator+(T rhs) const
{
return Vector4<T> (x + rhs, y + rhs, z + rhs, w + rhs);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator-(T rhs) const
{
return Vector4<T> (x - rhs, y - rhs, z - rhs, w - rhs);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator*(T rhs) const
{
return Vector4<T> (x * rhs, y * rhs, z * rhs, w * rhs);
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator/(T rhs) const
{
return Vector4<T> (x / rhs, y / rhs, z / rhs, w / rhs);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator+=(T rhs)
{
x += rhs;
y += rhs;
z += rhs;
w += rhs;
return * this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator-=(T rhs)
{
x -= rhs;
y -= rhs;
z -= rhs;
w -= rhs;
return * this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator*=(T rhs)
{
x *= rhs;
y *= rhs;
z *= rhs;
w *= rhs;
return * this;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T>& operator/=(T rhs)
{
x /= rhs;
y /= rhs;
z /= rhs;
w /= rhs;
return * this;
}
//-------------[ size operations ]---------------------------
/**
* Get lenght of vector.
* @return lenght of vector
*/
T length() const
{
return (T)std::sqrt(x * x + y * y + z * z + w * w);
}
/**
* Normalize vector
*/
void normalize()
{
T s = length();
x /= s;
y /= s;
z /= s;
w /= s;
}
/**
* Return square of length.
* @return lenght ^ 2
* @note This method is faster then length(). For comparsion
* of length of two vector can be used just this value, instead
* of computionaly more expensive length() method.
*/
T lengthSq() const
{
return x * x + y * y + z * z + w * w;
}
//--------------[ misc. operations ]-----------------------
/**
* Linear interpolation of two vectors
* @param fact Factor of interpolation. For translation from positon
* of this vector to vector r, values of factor goes from 0.0 to 1.0.
* @param r Second Vector for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Vector4<T> lerp(T fact, const Vector4<T>& r) const
{
return (*this) + (r - (*this)) * fact;
}
//-------------[ conversion ]-----------------------------
/**
* Conversion to pointer operator
* @return Pointer to internaly stored (in managment of class Vector4<T>)
* used for passing Vector4<T> values to gl*4[fd] functions.
*/
operator T*(){ return (T*) this; }
/**
* Conversion to pointer operator
* @return Constant Pointer to internaly stored (in managment of class Vector4<T>)
* used for passing Vector4<T> values to gl*4[fd] functions.
*/
operator const T*() const { return (const T*) this; }
//-------------[ output operator ]------------------------
/**
* Output to stream operator
* @param lhs Left hand side argument of operator (commonly ostream instance).
* @param rhs Right hand side argument of operator.
* @return Left hand side argument - the ostream object passed to operator.
*/
friend std::ostream& operator<<(std::ostream& lhs, const Vector4<T>& rhs)
{
lhs << "[" << rhs.x << "," << rhs.y << "," << rhs.z << "," << rhs.w << "]";
return lhs;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
/// Three dimensional Vector of floats
typedef Vector4<float> Vector4f;
/// Three dimensional Vector of doubles
typedef Vector4<double> Vector4d;
/**
* Class for matrix 3x3.
* @note Data stored in this matrix are in column major order. This arrangement suits OpenGL.
* If you're using row major matrix, consider using fromRowMajorArray as way for construction
* Matrix3<T> instance.
*/
template <class T>
class Matrix3
{
public:
/// Data stored in column major order
T data[9];
//--------------------------[ constructors ]-------------------------------
/**
* Creates identity matrix
*/
Matrix3()
{
for (int i = 0; i < 9; i++)
data[i] = (i % 4) ? 0 : 1;
}
/**
* Copy matrix values from array (these data must be in column
* major order!)
*/
Matrix3(const T * dt)
{
std::memcpy(data, dt, sizeof(T) * 9);
}
/**
* Copy constructor.
* @param src Data source for new created instance of Matrix3
*/
Matrix3(const Matrix3<T>& src)
{
std::memcpy(data, src.data, sizeof(T) * 9);
}
/**
* Copy casting constructor.
* @param src Data source for new created instance of Matrix3
*/
template<class FromT>
Matrix3(const Matrix3<FromT>& src)
{
for (int i = 0; i < 9; i++)
{
data[i] = static_cast<T>(src.data[i]);
}
}
/**
* Resets matrix to be identity matrix
*/
void identity()
{
for (int i = 0; i < 9; i++)
data[i] = (i % 4) ? 0 : 1;
}
/**
* Creates rotation matrix by rotation around axis.
* @param a Angle (in radians) of rotation around axis X.
* @param b Angle (in radians) of rotation around axis Y.
* @param c Angle (in radians) of rotation around axis Z.
*/
static Matrix3<T> createRotationAroundAxis(T a, T b, T c)
{
Matrix3<T> ma, mb, mc;
float ac = cos(a);
float as = sin(a);
float bc = cos(b);
float bs = sin(b);
float cc = cos(c);
float cs = sin(c);
ma.at(1,1) = ac;
ma.at(2,1) = as;
ma.at(1,2) = -as;
ma.at(2,2) = ac;
mb.at(0,0) = bc;
mb.at(2,0) = -bs;
mb.at(0,2) = bs;
mb.at(2,2) = bc;
mc.at(0,0) = cc;
mc.at(1,0) = cs;
mc.at(0,1) = -cs;
mc.at(1,1) = cc;
Matrix3<T> ret = ma * mb * mc;
return ret;
}
/**
* Creates roation matrix from ODE Matrix.
*/
template <class It>
static Matrix3<T> fromOde(const It* mat)
{
Matrix3<T> ret;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
ret.at(i,j) = static_cast<T>(mat[j * 4 + i]);
}
}
return ret;
}
/**
* Creates new matrix 3x3 from array that represents such matrix 3x3
* as array of tightly packed elements in row major order.
* @param arr An array of elements for 3x3 matrix in row major order.
* @return An instance of Matrix3<T> representing @a arr
*/
template <class FromT>
static Matrix3<T> fromRowMajorArray(const FromT* arr)
{
const T retData[] =
{
static_cast<T>(arr[0]), static_cast<T>(arr[3]), static_cast<T>(arr[6]),
static_cast<T>(arr[1]), static_cast<T>(arr[4]), static_cast<T>(arr[7]),
static_cast<T>(arr[2]), static_cast<T>(arr[5]), static_cast<T>(arr[8])
};
return retData;
}
/**
* Creates new matrix 3x3 from array that represents such matrix 3x3
* as array of tightly packed elements in column major order.
* @param arr An array of elements for 3x3 matrix in column major order.
* @return An instance of Matrix3<T> representing @a arr
*/
template <class FromT>
static Matrix3<T> fromColumnMajorArray(const FromT* arr)
{
const T retData[] =
{
static_cast<T>(arr[0]), static_cast<T>(arr[1]), static_cast<T>(arr[2]),
static_cast<T>(arr[3]), static_cast<T>(arr[4]), static_cast<T>(arr[5]),
static_cast<T>(arr[6]), static_cast<T>(arr[7]), static_cast<T>(arr[8])
};
return retData;
}
//---------------------[ equiality operators ]------------------------------
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition all elements of matrix
* | lws[i] - rhs[i] | < EPSILON,
* same for y-coordinate, z-coordinate, and w-coordinate.
*/
bool operator==(const Matrix3<T>& rhs) const
{
for (int i = 0; i < 9; i++)
{
if (std::fabs(data[i] - rhs.data[i]) >= EPSILON)
return false;
}
return true;
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Matrix3<T>& rhs) const
{
return !(*this == rhs);
}
//---------------------[ access operators ]---------------------------------
/**
* Get reference to element at postion (x,y).
* @param x Number of column (0..2)
* @param y Number of row (0..2)
*/
T& at(int x, int y)
{
assert(x >= 0 && x < 3);
assert(y >= 0 && y < 3);
return data[x * 3 + y];
}
/**
* Get constant reference to element at postion (x,y).
* @param x Number of column (0..2)
* @param y Number of row (0..2)
*/
const T& at(int x, int y) const
{
assert(x >= 0 && x < 3);
assert(y >= 0 && y < 3);
return data[x * 3 + y];
}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T>& operator=(const Matrix3<T>& rhs)
{
std::memcpy(data, rhs.data, sizeof(T) * 9);
return * this;
}
/**
* Copy casting operator
* @param rhs Right hand side argument of binary operator.
*/
template<class FromT>
Matrix3<T>& operator=(const Matrix3<FromT>& rhs)
{
for (int i = 0; i < 9; i++)
{
data[i] = static_cast<T>(rhs.data[i]);
}
return * this;
}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T>& operator=(const T* rhs)
{
std::memcpy(data, rhs, sizeof(T) * 9);
return * this;
}
/*Matrix3<T> & operator=(const double* m)
{
for (int i = 0; i < 9; i++) data[i] = (T)m[i];
return * this;
}*/
//--------------------[ matrix with matrix operations ]---------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator+(const Matrix3<T>& rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] + rhs.data[i];
return ret;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator-(const Matrix3<T>& rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] - rhs.data[i];
return ret;
}
//--------------------[ matrix with scalar operations ]---------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator+(T rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] + rhs;
return ret;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator-(T rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] - rhs;
return ret;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator*(T rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] * rhs;
return ret;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator/(T rhs) const
{
Matrix3<T> ret;
for (int i = 0; i < 9; i++)
ret.data[i] = data[i] / rhs;
return ret;
}
//--------------------[ multiply operators ]--------------------------------
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator*(const Vector3<T>& rhs) const
{
return Vector3<T>(
data[0] * rhs.x + data[3] * rhs.y + data[6] * rhs.z,
data[1] * rhs.x + data[4] * rhs.y + data[7] * rhs.z,
data[2] * rhs.x + data[5] * rhs.y + data[8] * rhs.z
);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix3<T> operator*(Matrix3<T> rhs) const
{
static Matrix3<T> w;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
T n = 0;
for (int k = 0; k < 3; k++) n += rhs.at(i, k) * at(k, j);
w.at(i, j) = n;
}
}
return w;
}
//---------------------------[ misc operations ]----------------------------
/**
* Transpose matrix.
*/
Matrix3<T> transpose()
{
Matrix3<T> ret;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
ret.at(i,j) = at(j,i);
}
}
return ret;
}
/**
* Linear interpolation of two vectors
* @param fact Factor of interpolation. For translation from positon
* of this matrix (lhs) to matrix rhs, values of factor goes from 0.0 to 1.0.
* @param rhs Second Matrix for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Matrix3<T> lerp(T fact, const Matrix3<T>& rhs) const
{
Matrix3<T> ret = (*this) + (rhs - (*this)) * fact;
return ret;
}
T det()
{
return
+at(0,0) * at(1,1) * at(2,2)
+at(0,1) * at(1,2) * at(2,0)
+at(0,2) * at(1,0) * at(2,1)
-at(0,0) * at(1,2) * at(2,1)
-at(0,1) * at(1,0) * at(2,2)
-at(0,2) * at(1,1) * at(2,0)
;
}
/**
* Computes inverse matrix
* @return Inverse matrix of this matrix.
*/
Matrix3<T> inverse()
{
Matrix3<T> ret;
ret.at(0,0) = at(1,1)*at(2,2) - at(2,1)*at(1,2);
ret.at(0,1) = at(2,1)*at(0,2) - at(0,1)*at(2,2);
ret.at(0,2) = at(0,1)*at(1,2) - at(1,1)*at(0,2);
ret.at(1,0) = at(2,0)*at(1,2) - at(1,0)*at(2,2);
ret.at(1,1) = at(0,0)*at(2,2) - at(2,0)*at(0,2);
ret.at(1,2) = at(1,0)*at(0,2) - at(0,0)*at(1,2);
ret.at(2,0) = at(1,0)*at(2,1) - at(2,0)*at(1,1);
ret.at(2,1) = at(2,0)*at(0,1) - at(0,0)*at(2,1);
ret.at(2,2) = at(0,0)*at(1,1) - at(1,0)*at(0,1);
return ret * (1.0f / det());
}
//-------------[ conversion ]-----------------------------
/**
* Conversion to pointer operator
* @return Pointer to internaly stored (in managment of class Matrix3<T>)
* used for passing Matrix3<T> values to gl*[fd]v functions.
*/
operator T*(){ return (T*) data; }
/**
* Conversion to pointer operator
* @return Constant Pointer to internaly stored (in managment of class Matrix3<T>)
* used for passing Matrix3<T> values to gl*[fd]v functions.
*/
operator const T*() const { return (const T*) data; }
//----------[ output operator ]----------------------------
/**
* Output to stream operator
* @param lhs Left hand side argument of operator (commonly ostream instance).
* @param rhs Right hand side argument of operator.
* @return Left hand side argument - the ostream object passed to operator.
*/
friend std::ostream& operator << (std::ostream& lhs, const Matrix3<T>& rhs)
{
for (int i = 0; i < 3; i++)
{
lhs << "|\t";
for (int j = 0; j < 3; j++)
{
lhs << rhs.at(j,i) << "\t";
}
lhs << "|" << std::endl;
}
return lhs;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
/// Matrix 3x3 of floats
typedef Matrix3<float> Matrix3f;
/// Matrix 3x3 of doubles
typedef Matrix3<double> Matrix3d;
/**
* Class for matrix 4x4
* @note Data stored in this matrix are in column major order. This arrangement suits OpenGL.
* If you're using row major matrix, consider using fromRowMajorArray as way for construction
* Matrix4<T> instance.
*/
template <class T>
class Matrix4
{
public:
/// Data stored in column major order
T data[16];
//--------------------------[ constructors ]-------------------------------
/**
*Creates identity matrix
*/
Matrix4()
{
for (int i = 0; i < 16; i++)
data[i] = (i % 5) ? 0 : 1;
}
/**
* Copy matrix values from array (these data must be in column
* major order!)
*/
Matrix4(const T * dt)
{
std::memcpy(data, dt, sizeof(T) * 16);
}
/**
* Copy constructor.
* @param src Data source for new created instance of Matrix4.
*/
Matrix4(const Matrix4<T>& src)
{
std::memcpy(data, src.data, sizeof(T) * 16);
}
/**
* Copy casting constructor.
* @param src Data source for new created instance of Matrix4.
*/
template <class FromT>
Matrix4(const Matrix4<FromT>& src)
{
for (int i = 0; i < 16; i++)
{
data[i] = static_cast<T>(src.data[i]);
}
}
/**
* Resets matrix to be identity matrix
*/
void identity()
{
for (int i = 0; i < 16; i++)
data[i] = (i % 5) ? 0 : 1;
}
/**
* Creates rotation matrix by rotation around axis.
* @param a Angle (in radians) of rotation around axis X.
* @param b Angle (in radians) of rotation around axis Y.
* @param c Angle (in radians) of rotation around axis Z.
*/
static Matrix4<T> createRotationAroundAxis(T a, T b, T c)
{
Matrix4<T> ma, mb, mc;
float ac = cos(a);
float as = sin(a);
float bc = cos(b);
float bs = sin(b);
float cc = cos(c);
float cs = sin(c);
ma.at(1,1) = ac;
ma.at(2,1) = as;
ma.at(1,2) = -as;
ma.at(2,2) = ac;
mb.at(0,0) = bc;
mb.at(2,0) = -bs;
mb.at(0,2) = bs;
mb.at(2,2) = bc;
mc.at(0,0) = cc;
mc.at(1,0) = cs;
mc.at(0,1) = -cs;
mc.at(1,1) = cc;
/*std::cout << "RotVec = " << a << "," << b << "," << c << std::endl;
std::cout << "Rx = " << std::endl << ma;
std::cout << "Ry = " << std::endl << mb;
std::cout << "Rz = " << std::endl << mc;*/
Matrix4<T> ret = ma * mb * mc;
//std::cout << "Result = " << std::endl << ma * (mb * mc);
return ret;
}
/// Creates translation matrix
/**
* Creates translation matrix.
* @param x X-direction translation
* @param y Y-direction translation
* @param z Z-direction translation
* @param w for W-coordinate translation (impictily set to 1)
*/
static Matrix4<T> createTranslation(T x, T y, T z, T w = 1)
{
Matrix4 ret;
ret.at(3,0) = x;
ret.at(3,1) = y;
ret.at(3,2) = z;
ret.at(3,3) = w;
return ret;
}
/**
* Creates new matrix 4x4 from array that represents such matrix 4x4
* as array of tightly packed elements in row major order.
* @param arr An array of elements for 4x4 matrix in row major order.
* @return An instance of Matrix4<T> representing @a arr
*/
template <class FromT>
static Matrix4<T> fromRowMajorArray(const FromT* arr)
{
const T retData[] =
{
static_cast<T>(arr[0]), static_cast<T>(arr[4]), static_cast<T>(arr[ 8]), static_cast<T>(arr[12]),
static_cast<T>(arr[1]), static_cast<T>(arr[5]), static_cast<T>(arr[ 9]), static_cast<T>(arr[13]),
static_cast<T>(arr[2]), static_cast<T>(arr[6]), static_cast<T>(arr[10]), static_cast<T>(arr[14]),
static_cast<T>(arr[3]), static_cast<T>(arr[7]), static_cast<T>(arr[11]), static_cast<T>(arr[15])
};
return retData;
}
/**
* Creates new matrix 4x4 from array that represents such matrix 4x4
* as array of tightly packed elements in column major order.
* @param arr An array of elements for 4x4 matrix in column major order.
* @return An instance of Matrix4<T> representing @a arr
*/
template <class FromT>
static Matrix4<T> fromColumnMajorArray(const FromT* arr)
{
const T retData[] =
{
static_cast<T>(arr[ 0]), static_cast<T>(arr[ 1]), static_cast<T>(arr[ 2]), static_cast<T>(arr[ 3]),
static_cast<T>(arr[ 4]), static_cast<T>(arr[ 5]), static_cast<T>(arr[ 6]), static_cast<T>(arr[ 7]),
static_cast<T>(arr[ 8]), static_cast<T>(arr[ 9]), static_cast<T>(arr[10]), static_cast<T>(arr[11]),
static_cast<T>(arr[12]), static_cast<T>(arr[13]), static_cast<T>(arr[14]), static_cast<T>(arr[15])
};
return retData;
}
//---------------------[ equiality operators ]------------------------------
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition all elements of matrix
* | lws[i] - rhs[i] | < EPSILON,
* same for y-coordinate, z-coordinate, and w-coordinate.
*/
bool operator==(const Matrix4<T>& rhs) const
{
for (int i = 0; i < 16; i++)
{
if (std::fabs(data[i] - rhs.data[i]) >= EPSILON)
return false;
}
return true;
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Matrix4<T>& rhs) const
{
return !(*this == rhs);
}
//---------------------[ access operators ]---------------------------------
/**
* Get reference to element at postion (x,y).
* @param x Number of column (0..3)
* @param y Number of row (0..3)
*/
T& at(int x, int y)
{
assert(x >= 0 && x < 4);
assert(y >= 0 && y < 4);
return data[x * 4 + y];
}
/**
* Get constant reference to element at postion (x,y).
* @param x Number of column (0..3)
* @param y Number of row (0..3)
*/
const T& at(int x, int y) const
{
assert(x >= 0 && x < 4);
assert(y >= 0 && y < 4);
return data[x * 4 + y];
}
/**
* Sets translation part of matrix.
*
* @param v Vector of translation to be set.
*/
void setTranslation(const Vector3<T>& v)
{
at(3,0) = v.x;
at(3,1) = v.y;
at(3,2) = v.z;
at(3,3) = 1;
}
/**
* Sets translation part of matrix.
*
* @param v Vector of translation to be set.
*/
void setTranslation(const float x, const float y, const float z)
{
at(3,0) = x;
at(3,1) = y;
at(3,2) = z;
at(3,3) = 1;
}
/**
* Sets scale part of matrix.
*
* @param v Vector of scale to be set.
*/
void setScale(const Vector3<T>& v)
{
at(0,0) = v.x;
at(1,1) = v.y;
at(2,2) = v.z;
at(3,3) = 1;
}
/**
* Sets scale part of matrix.
*
* @param v Vector of scale to be set.
*/
void setScale(const float x, const float y, const float z)
{
at(0,0) = x;
at(1,1) = y;
at(2,2) = z;
at(3,3) = 1;
}
/**
* Sets scale part of matrix ONLY.
*
* @param v Vector of scale to be set.
*/
void setScale(const float s)
{
at(0,0) = s;
at(1,1) = s;
at(2,2) = s;
at(3,3) = 1;
}
T getUniformScale()
{
return at(0,0);
}
Vector3<T> getTranslation()
{ return Vector3<T>(at(3,0),at(3,1),at(3,2)); }
/**
* Sets roation part (matrix 3x3) of matrix.
*
* @param m Rotation part of matrix
*/
void setRotation(const Matrix3<T>& m)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
at(i,j) = m.at(i,j);
}
}
}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T>& operator=(const Matrix4<T>& rhs)
{
std::memcpy(data, rhs.data, sizeof(T) * 16);
return * this;
}
/**
* Copy casting operator
* @param rhs Right hand side argument of binary operator.
*/
template <class FromT>
Matrix4<T>& operator=(const Matrix4<FromT>& rhs)
{
for (int i = 0; i < 16; i++)
{
data[i] = static_cast<T>(rhs.data[i]);
}
return * this;
}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T>& operator=(const T* rhs)
{
std::memcpy(data, rhs, sizeof(T) * 16);
return * this;
}
/*Matrix4<T> & operator=(const double* m)
{
for (int i = 0; i < 16; i++) data[i] = (T)m[i];
return * this;
}*/
//--------------------[ matrix with matrix operations ]---------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator+(const Matrix4<T>& rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] + rhs.data[i];
return ret;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator-(const Matrix4<T>& rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] - rhs.data[i];
return ret;
}
//--------------------[ matrix with scalar operations ]---------------------
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator+(T rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] + rhs;
return ret;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator-(T rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] - rhs;
return ret;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator*(T rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] * rhs;
return ret;
}
/**
* Division operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator/(T rhs) const
{
Matrix4<T> ret;
for (int i = 0; i < 16; i++)
ret.data[i] = data[i] / rhs;
return ret;
}
//--------------------[ multiply operators ]--------------------------------
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector4<T> operator*(const Vector4<T>& rhs) const
{
return Vector4<T>(
data[0] * rhs.x + data[4] * rhs.y + data[8] * rhs.z + data[12] * rhs.w,
data[1] * rhs.x + data[5] * rhs.y + data[9] * rhs.z + data[13] * rhs.w,
data[2] * rhs.x + data[6] * rhs.y + data[10] * rhs.z + data[14] * rhs.w,
data[3] * rhs.x + data[7] * rhs.y + data[11] * rhs.z + data[15] * rhs.w
);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Vector3<T> operator*(const Vector3<T>& rhs) const
{
return Vector3<T>(
data[0] * rhs.x + data[4] * rhs.y + data[8] * rhs.z,
data[1] * rhs.x + data[5] * rhs.y + data[9] * rhs.z,
data[2] * rhs.x + data[6] * rhs.y + data[10] * rhs.z
);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Matrix4<T> operator*(Matrix4<T> rhs) const
{
static Matrix4<T> w;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
T n = 0;
for (int k = 0; k < 4; k++) n += rhs.at(i, k) * at(k, j);
w.at(i, j) = n;
}
}
return w;
}
//---------------------------[ misc operations ]----------------------------
/**
* Computes determinant of matrix
* @return Determinant of matrix
* @note This function does 3 * 4 * 6 mul, 3 * 6 add.
*/
T det()
{
return
+ at(3,0) * at(2,1) * at(1,2) * at(0,3)
- at(2,0) * at(3,1) * at(1,2) * at(0,3)
- at(3,0) * at(1,1) * at(2,2) * at(0,3)
+ at(1,0) * at(3,1) * at(2,2) * at(0,3)
+ at(2,0) * at(1,1) * at(3,2) * at(0,3)
- at(1,0) * at(2,1) * at(3,2) * at(0,3)
- at(3,0) * at(2,1) * at(0,2) * at(1,3)
+ at(2,0) * at(3,1) * at(0,2) * at(1,3)
+ at(3,0) * at(0,1) * at(2,2) * at(1,3)
- at(0,0) * at(3,1) * at(2,2) * at(1,3)
- at(2,0) * at(0,1) * at(3,2) * at(1,3)
+ at(0,0) * at(2,1) * at(3,2) * at(1,3)
+ at(3,0) * at(1,1) * at(0,2) * at(2,3)
- at(1,0) * at(3,1) * at(0,2) * at(2,3)
- at(3,0) * at(0,1) * at(1,2) * at(2,3)
+ at(0,0) * at(3,1) * at(1,2) * at(2,3)
+ at(1,0) * at(0,1) * at(3,2) * at(2,3)
- at(0,0) * at(1,1) * at(3,2) * at(2,3)
- at(2,0) * at(1,1) * at(0,2) * at(3,3)
+ at(1,0) * at(2,1) * at(0,2) * at(3,3)
+ at(2,0) * at(0,1) * at(1,2) * at(3,3)
- at(0,0) * at(2,1) * at(1,2) * at(3,3)
- at(1,0) * at(0,1) * at(2,2) * at(3,3)
+ at(0,0) * at(1,1) * at(2,2) * at(3,3);
}
/**
* Computes inverse matrix
* @return Inverse matrix of this matrix.
* @note This is a little bit time consuming operation
* (16 * 6 * 3 mul, 16 * 5 add + det() + mul() functions)
*/
Matrix4<T> inverse()
{
Matrix4<T> ret;
ret.at(0,0) =
+ at(2,1) * at(3,2) * at(1,3)
- at(3,1) * at(2,2) * at(1,3)
+ at(3,1) * at(1,2) * at(2,3)
- at(1,1) * at(3,2) * at(2,3)
- at(2,1) * at(1,2) * at(3,3)
+ at(1,1) * at(2,2) * at(3,3);
ret.at(1,0) =
+ at(3,0) * at(2,2) * at(1,3)
- at(2,0) * at(3,2) * at(1,3)
- at(3,0) * at(1,2) * at(2,3)
+ at(1,0) * at(3,2) * at(2,3)
+ at(2,0) * at(1,2) * at(3,3)
- at(1,0) * at(2,2) * at(3,3);
ret.at(2,0) =
+ at(2,0) * at(3,1) * at(1,3)
- at(3,0) * at(2,1) * at(1,3)
+ at(3,0) * at(1,1) * at(2,3)
- at(1,0) * at(3,1) * at(2,3)
- at(2,0) * at(1,1) * at(3,3)
+ at(1,0) * at(2,1) * at(3,3);
ret.at(3,0) =
+ at(3,0) * at(2,1) * at(1,2)
- at(2,0) * at(3,1) * at(1,2)
- at(3,0) * at(1,1) * at(2,2)
+ at(1,0) * at(3,1) * at(2,2)
+ at(2,0) * at(1,1) * at(3,2)
- at(1,0) * at(2,1) * at(3,2);
ret.at(0,1) =
+ at(3,1) * at(2,2) * at(0,3)
- at(2,1) * at(3,2) * at(0,3)
- at(3,1) * at(0,2) * at(2,3)
+ at(0,1) * at(3,2) * at(2,3)
+ at(2,1) * at(0,2) * at(3,3)
- at(0,1) * at(2,2) * at(3,3);
ret.at(1,1) =
+ at(2,0) * at(3,2) * at(0,3)
- at(3,0) * at(2,2) * at(0,3)
+ at(3,0) * at(0,2) * at(2,3)
- at(0,0) * at(3,2) * at(2,3)
- at(2,0) * at(0,2) * at(3,3)
+ at(0,0) * at(2,2) * at(3,3);
ret.at(2,1) =
+ at(3,0) * at(2,1) * at(0,3)
- at(2,0) * at(3,1) * at(0,3)
- at(3,0) * at(0,1) * at(2,3)
+ at(0,0) * at(3,1) * at(2,3)
+ at(2,0) * at(0,1) * at(3,3)
- at(0,0) * at(2,1) * at(3,3);
ret.at(3,1) =
+ at(2,0) * at(3,1) * at(0,2)
- at(3,0) * at(2,1) * at(0,2)
+ at(3,0) * at(0,1) * at(2,2)
- at(0,0) * at(3,1) * at(2,2)
- at(2,0) * at(0,1) * at(3,2)
+ at(0,0) * at(2,1) * at(3,2);
ret.at(0,2) =
+ at(1,1) * at(3,2) * at(0,3)
- at(3,1) * at(1,2) * at(0,3)
+ at(3,1) * at(0,2) * at(1,3)
- at(0,1) * at(3,2) * at(1,3)
- at(1,1) * at(0,2) * at(3,3)
+ at(0,1) * at(1,2) * at(3,3);
ret.at(1,2) =
+ at(3,0) * at(1,2) * at(0,3)
- at(1,0) * at(3,2) * at(0,3)
- at(3,0) * at(0,2) * at(1,3)
+ at(0,0) * at(3,2) * at(1,3)
+ at(1,0) * at(0,2) * at(3,3)
- at(0,0) * at(1,2) * at(3,3);
ret.at(2,2) =
+ at(1,0) * at(3,1) * at(0,3)
- at(3,0) * at(1,1) * at(0,3)
+ at(3,0) * at(0,1) * at(1,3)
- at(0,0) * at(3,1) * at(1,3)
- at(1,0) * at(0,1) * at(3,3)
+ at(0,0) * at(1,1) * at(3,3);
ret.at(3,2) =
+ at(3,0) * at(1,1) * at(0,2)
- at(1,0) * at(3,1) * at(0,2)
- at(3,0) * at(0,1) * at(1,2)
+ at(0,0) * at(3,1) * at(1,2)
+ at(1,0) * at(0,1) * at(3,2)
- at(0,0) * at(1,1) * at(3,2);
ret.at(0,3) =
+ at(2,1) * at(1,2) * at(0,3)
- at(1,1) * at(2,2) * at(0,3)
- at(2,1) * at(0,2) * at(1,3)
+ at(0,1) * at(2,2) * at(1,3)
+ at(1,1) * at(0,2) * at(2,3)
- at(0,1) * at(1,2) * at(2,3);
ret.at(1,3) =
+ at(1,0) * at(2,2) * at(0,3)
- at(2,0) * at(1,2) * at(0,3)
+ at(2,0) * at(0,2) * at(1,3)
- at(0,0) * at(2,2) * at(1,3)
- at(1,0) * at(0,2) * at(2,3)
+ at(0,0) * at(1,2) * at(2,3);
ret.at(2,3) =
+ at(2,0) * at(1,1) * at(0,3)
- at(1,0) * at(2,1) * at(0,3)
- at(2,0) * at(0,1) * at(1,3)
+ at(0,0) * at(2,1) * at(1,3)
+ at(1,0) * at(0,1) * at(2,3)
- at(0,0) * at(1,1) * at(2,3);
ret.at(3,3) =
+ at(1,0) * at(2,1) * at(0,2)
- at(2,0) * at(1,1) * at(0,2)
+ at(2,0) * at(0,1) * at(1,2)
- at(0,0) * at(2,1) * at(1,2)
- at(1,0) * at(0,1) * at(2,2)
+ at(0,0) * at(1,1) * at(2,2);
return ret / det();
}
/**
* Transpose matrix.
*/
Matrix4<T> transpose()
{
Matrix4<T> ret;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
ret.at(i,j) = at(j,i);
}
}
return ret;
}
/**
* Linear interpolation of two vectors
* @param fact Factor of interpolation. For translation from positon
* of this matrix (lhs) to matrix rhs, values of factor goes from 0.0 to 1.0.
* @param rhs Second Matrix for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Matrix4<T> lerp(T fact, const Matrix4<T>& rhs) const
{
Matrix4<T> ret = (*this) + (rhs - (*this)) * fact;
return ret;
}
//-------------[ conversion ]-----------------------------
/**
* Conversion to pointer operator
* @return Pointer to internaly stored (in managment of class Matrix4<T>)
* used for passing Matrix4<T> values to gl*[fd]v functions.
*/
operator T*(){ return (T*) data; }
/**
* Conversion to pointer operator
* @return Constant Pointer to internaly stored (in managment of class Matrix4<T>)
* used for passing Matrix4<T> values to gl*[fd]v functions.
*/
operator const T*() const { return (const T*) data; }
//----------[ output operator ]----------------------------
/**
* Output to stream operator
* @param lhs Left hand side argument of operator (commonly ostream instance).
* @param rhs Right hand side argument of operator.
* @return Left hand side argument - the ostream object passed to operator.
*/
friend std::ostream& operator << (std::ostream& lhs, const Matrix4<T>& rhs)
{
for (int i = 0; i < 4; i++)
{
lhs << "|\t";
for (int j = 0; j < 4; j++)
{
lhs << rhs.at(j,i) << "\t";
}
lhs << "|" << std::endl;
}
return lhs;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
/// Matrix 4x4 of floats
typedef Matrix4<float> Matrix4f;
/// Matrix 4x4 of doubles
typedef Matrix4<double> Matrix4d;
/**
* Quaternion class implementing some quaternion algebra operations.
* Quaternion is kind of complex number it consists of its real part (w)
* and its complex part v. This complex part has three elements, so we
* can express it as xi + yj + zk . Note that coordinates of (x,y,z) are
* hold inside v field.
*/
template <class T>
class Quaternion
{
public:
/**
* Real part of quaternion.
*/
T w;
/**
* Complex part of quaternion.
*/
Vector3<T> v;
/**
* Quaternion constructor, sets quaternion to (0 + 0i + 0j + 0k).
*/
Quaternion(): w(0), v(0,0,0){}
/**
* Copy constructor.
*/
Quaternion(const Quaternion<T>& q): w(q.w), v(q.v){ }
/**
* Copy casting constructor.
*/
template <class FromT>
Quaternion(const Quaternion<FromT>& q)
: w(static_cast<T>(q.w)),
v(q.v){ }
/**
* Creates quaternion object from real part w_ and complex part v_.
* @param w_ Real part of quaternion.
* @param v_ Complex part of quaternion (xi + yj + zk).
*/
Quaternion(T w_, const Vector3<T>& v_): w(w_), v(v_){}
/**
* Creates quaternion object from value (w_ + xi + yj + zk).
* @param w_ Real part of quaternion.
* @param x Complex cooeficinet for i complex constant.
* @param y Complex cooeficinet for j complex constant.
* @param z Complex cooeficinet for k complex constant.
*/
Quaternion(T w_, T x, T y, T z): w(w_), v(x,y,z){}
/**
* Copy operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T>& operator= (const Quaternion<T>& rhs)
{
v = rhs.v;
w = rhs.w;
return *this;
}
/**
* Copy convert operator
* @param rhs Right hand side argument of binary operator.
*/
template<class FromT>
Quaternion<T>& operator= (const Quaternion<FromT>& rhs)
{
v = rhs.v;
w = static_cast<T>(rhs.w);
return *this;
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T> operator+ (const Quaternion<T>& rhs) const
{
const Quaternion<T>& lhs = *this;
return Quaternion<T>(lhs.w + rhs.w, lhs.v + rhs.v);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T> operator* (const Quaternion<T>& rhs) const
{
const Quaternion<T>& lhs = *this;
return Quaternion<T>(
lhs.w * rhs.w - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z,
lhs.w * rhs.v.x + lhs.v.x * rhs.w + lhs.v.y * rhs.v.z - lhs.v.z * rhs.v.y,
lhs.w * rhs.v.y - lhs.v.x * rhs.v.z + lhs.v.y * rhs.w + lhs.v.z * rhs.v.x,
lhs.w * rhs.v.z + lhs.v.x * rhs.v.y - lhs.v.y * rhs.v.x + lhs.v.z * rhs.w
);
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T> operator* (T rhs) const
{
return Quaternion<T>(w*rhs, v*rhs);
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T> operator- (const Quaternion<T>& rhs) const
{
const Quaternion<T>& lhs = *this;
return Quaternion<T>(lhs.w - rhs.w, lhs.v - rhs.v);
}
/**
* Addition operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T>& operator+= (const Quaternion<T>& rhs)
{
w += rhs.w;
v += rhs.v;
return *this;
}
/**
* Substraction operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T>& operator-= (const Quaternion<T>& rhs)
{
w -= rhs.w;
v -= rhs.v;
return *this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T>& operator*= (const Quaternion<T>& rhs)
{
Quaternion q = (*this) * rhs;
v = q.v;
w = q.w;
return *this;
}
/**
* Multiplication operator
* @param rhs Right hand side argument of binary operator.
*/
Quaternion<T>& operator*= (T rhs)
{
w *= rhs;
v *= rhs;
return *this;
}
/**
* Equality test operator
* @param rhs Right hand side argument of binary operator.
* @note Test of equality is based of threshold EPSILON value. To be two
* values equal, must satisfy this condition | lws - rhs | < EPSILON,
* for all quaternion coordinates.
*/
bool operator==(const Quaternion<T>& rhs) const
{
const Quaternion<T>& lhs = *this;
return (std::fabs(lhs.w - rhs.w) < EPSILON) && lhs.v == rhs.v;
}
/**
* Inequality test operator
* @param rhs Right hand side argument of binary operator.
* @return not (lhs == rhs) :-P
*/
bool operator!=(const Quaternion<T>& rhs) const { return ! (*this == rhs); }
//-------------[ unary operations ]--------------------------
/**
* Unary negate operator
* @return negated quaternion
*/
Quaternion<T> operator-() const
{
return Quaternion<T>(-w, -v);
}
/**
* Unary conjugate operator
* @return conjugated quaternion
*/
Quaternion<T> operator~() const
{
return Quaternion<T>(w, -v);
}
/**
* Get lenght of quaternion.
* @return Length of quaternion.
*/
T length() const
{
return (T)std::sqrt(w*w + v.lengthSq());
}
/**
* Return square of length.
* @return lenght ^ 2
* @note This method is faster then length(). For comparsion
* of length of two quaternion can be used just this value, instead
* of computionaly more expensive length() method.
*/
T lengthSq() const
{
return w * w + v.lengthSq();
}
/**
* Normalize quaternion
*/
void normalize()
{
T len = length();
w /= len;
v /= len;
}
/**
* Creates quaternion for eulers angles.
* @param x Rotation around x axis (in degrees).
* @param y Rotation around y axis (in degrees).
* @param z Rotation around z axis (in degrees).
* @return Quaternion object representing transoformation.
*/
static Quaternion<T> fromEulerAngles(T x, T y, T z)
{
Quaternion<T> ret = fromAxisRot(Vector3<T>(1,0,0), x)
* fromAxisRot(Vector3<T>(0,1,0),y) * fromAxisRot(Vector3<T>(0,0,1),z);
return ret;
}
/**
* Creates quaternion as rotation around axis.
* @param axis Unit vector expressing axis of rotation.
* @param angleDeg Angle of rotation around axis (in degrees).
*/
static Quaternion<T> fromAxisRot(Vector3<T> axis, float angleDeg)
{
double angleRad = DEG2RAD(angleDeg);
double sa2 = std::sin(angleRad/2);
double ca2 = std::cos(angleRad/2);
return Quaternion<T>( ca2, axis * sa2);
}
/**
* Converts quaternion into rotation matrix.
* @return Rotation matrix expresing this quaternion.
*/
Matrix3<T> rotMatrix()
{
Matrix3<T> ret;
/*ret.at(0,0) = 1 - 2*v.y*v.y - 2*v.z*v.z;
ret.at(1,0) = 2*v.x*v.y - 2*w*v.z;
ret.at(2,0) = 2*v.x*v.z - 2*w*v.y;
ret.at(0,1) = 2*v.x*v.y + 2*w*v.z;
ret.at(1,1) = 1 - 2*v.x*v.x - 2*v.z*v.z;
ret.at(2,1) = 2*v.y*v.z - 2*w*v.x;
ret.at(0,2) = 2*v.x*v.z - 2*w*v.y;
ret.at(1,2) = 2*v.y*v.z + 2*w*v.x;
ret.at(2,2) = 1 - 2*v.x*v.x - 2*v.y*v.y;*/
T xx = v.x * v.x;
T xy = v.x * v.y;
T xz = v.x * v.z;
T xw = v.x * w;
T yy = v.y * v.y;
T yz = v.y * v.z;
T yw = v.y * w;
T zz = v.z * v.z;
T zw = v.z * w;
ret.at(0,0) = 1 - 2 * (yy + zz);
ret.at(1,0) = 2 * (xy - zw);
ret.at(2,0) = 2 * (xz + yw);
ret.at(0,1) = 2 * (xy + zw);
ret.at(1,1) = 1 - 2 * (xx + zz);
ret.at(2,1) = 2 * (yz - xw);
ret.at(0,2) = 2 * (xz - yw);
ret.at(1,2) = 2 * (yz + xw);
ret.at(2,2) = 1 - 2 * (xx + yy);
return ret;
}
/**
* Converts quaternion into transformation matrix.
* @note This method performs same operation as rotMatrix()
* conversion method. But returns Matrix of 4x4 elements.
* @return Transformation matrix expressing this quaternion.
*/
Matrix4<T> transform()
{
Matrix4<T> ret;
T xx = v.x * v.x;
T xy = v.x * v.y;
T xz = v.x * v.z;
T xw = v.x * w;
T yy = v.y * v.y;
T yz = v.y * v.z;
T yw = v.y * w;
T zz = v.z * v.z;
T zw = v.z * w;
ret.at(0,0) = 1 - 2 * (yy + zz);
ret.at(1,0) = 2 * (xy - zw);
ret.at(2,0) = 2 * (xz + yw);
ret.at(3,0) = 0;
ret.at(0,1) = 2 * (xy + zw);
ret.at(1,1) = 1 - 2 * (xx + zz);
ret.at(2,1) = 2 * (yz - xw);
ret.at(3,1) = 0;
ret.at(0,2) = 2 * (xz - yw);
ret.at(1,2) = 2 * (yz + xw);
ret.at(2,2) = 1 - 2 * (xx + yy);
ret.at(3,2) = 0;
ret.at(0,3) = 0;
ret.at(1,3) = 0;
ret.at(2,3) = 0;
ret.at(3,3) = 1;
return ret;
}
/**
* Linear interpolation of two quaternions
* @param fact Factor of interpolation. For translation from positon
* of this vector to quaternion rhs, values of factor goes from 0.0 to 1.0.
* @param rhs Second Quaternion for interpolation
* @note Hovewer values of fact parameter are reasonable only in interval
* [0.0 , 1.0], you can pass also values outside of this interval and you
* can get result (extrapolation?)
*/
Quaternion<T> lerp(T fact, const Quaternion<T>& rhs) const
{
return Quaternion<T>((1-fact) * w + fact * rhs.w, v.lerp(fact, rhs.v));
}
/**
* Provides output to standard output stream.
*/
friend std::ostream& operator << (std::ostream& oss, const Quaternion<T>& q)
{
oss << "Re: " << q.w << " Im: " << q.v;
return oss;
}
/**
* Creates quaternion from transform matrix.
*
* @param m Transfrom matrix used to compute quaternion.
* @return Quaternion representing rotation of matrix m.
*/
static Quaternion<T> fromMatrix(const Matrix4<T>& m)
{
Quaternion<T> q;
T tr,s;
tr = m.at(0,0) + m.at(1,1) + m.at(2,2);
if (tr >= epsilon)
{
s = (T)sqrt(tr + 1);
q.w = 0.5 * s;
s = 0.5 / s;
q.v.x = (m.at(1,2) - m.at(2,1)) * s;
q.v.y = (m.at(2,0) - m.at(0,2)) * s;
q.v.z = (m.at(0,1) - m.at(1,0)) * s;
}
else
{
T d0 = m.at(0,0);
T d1 = m.at(1,1);
T d2 = m.at(2,2);
char bigIdx = (d0 > d1) ? ((d0 > d2)? 0 : 2) : ((d1 > d2) ? 1 : 2);
if (bigIdx == 0)
{
s = (T)sqrt((d0 - (d1 + d2)) + 1);
q.v.x = 0.5 * s;
s = 0.5 / s;
q.v.y = (m.at(1,0) + m.at(0,1)) * s;
q.v.z = (m.at(2,0) + m.at(0,2)) * s;
q.w = (m.at(1,2) - m.at(2,1)) * s;
}
else if (bigIdx == 1)
{
s = (T)sqrt(1 + d1 - (d0 + d2));
q.v.y = 0.5 * s;
s = 0.5 / s;
q.v.z = (m.at(2,1) + m.at(1,2)) / s;
q.w = (m.at(2,0) - m.at(0,2)) / s;
q.v.x = (m.at(1,0) + m.at(0,1)) / s;
}
else
{
s = (T)sqrt(1 + d2 - (d0 + d1));
q.v.z = 0.5 * s;
s = 0.5 / s;
q.w = (m.at(0,1) - m.at(1,0)) / s;
q.v.x = (m.at(2,0) + m.at(0,2)) / s;
q.v.y = (m.at(2,1) + m.at(1,2)) / s;
}
}
return q;
}
/**
* Creates quaternion from rotation matrix.
*
* @param m Rotation matrix used to compute quaternion.
* @return Quaternion representing rotation of matrix m.
*/
static Quaternion<T> fromMatrix(const Matrix3<T>& m)
{
Quaternion<T> q;
T tr,s;
tr = m.at(0,0) + m.at(1,1) + m.at(2,2);
// if trace is greater or equal then zero
if (tr >= epsilon)
{
s = (T)sqrt(tr + 1);
q.w = 0.5 * s;
s = 0.5 / s;
q.v.x = (m.at(1,2) - m.at(2,1)) * s;
q.v.y = (m.at(2,0) - m.at(0,2)) * s;
q.v.z = (m.at(0,1) - m.at(1,0)) * s;
}
else
{
T d0 = m.at(0,0);
T d1 = m.at(1,1);
T d2 = m.at(2,2);
// find greates diagonal number
char bigIdx = (d0 > d1) ? ((d0 > d2)? 0 : 2) : ((d1 > d2) ? 1 : 2);
if (bigIdx == 0)
{
s = (T)sqrt((d0 - (d1 + d2)) + 1);
q.v.x = 0.5 * s;
s = 0.5 / s;
q.v.y = (m.at(1,0) + m.at(0,1)) * s;
q.v.z = (m.at(2,0) + m.at(0,2)) * s;
q.w = (m.at(1,2) - m.at(2,1)) * s;
}
else if (bigIdx == 1)
{
s = (T)sqrt(1 + d1 - (d0 + d2));
q.v.y = 0.5 * s;
s = 0.5 / s;
q.v.z = (m.at(2,1) + m.at(1,2)) / s;
q.w = (m.at(2,0) - m.at(0,2)) / s;
q.v.x = (m.at(1,0) + m.at(0,1)) / s;
}
else
{
s = (T)sqrt(1 + d2 - (d0 + d1));
q.v.z = 0.5 * s;
s = 0.5 / s;
q.w = (m.at(0,1) - m.at(1,0)) / s;
q.v.x = (m.at(2,0) + m.at(0,2)) / s;
q.v.y = (m.at(2,1) + m.at(1,2)) / s;
}
}
return q;
}
/**
* Computes spherical interpolation between quaternions (this, q2)
* using coeficient of interpolation r (in [0, 1]).
*
* @param r The ratio of interpolation form this (r = 0) to q2 (r = 1).
* @param q2 Second quaternion for interpolation.
* @return Result of interpolation.
*/
Quaternion<T> slerp(T r, const Quaternion<T>& q2) const
{
Quaternion<T> ret;
T cosTheta = w * q2.w + v.x * q2.v.x + v.y *q2.v.y + v.z * q2.v.z;
T theta = (T) acos(cosTheta);
if (fabs(theta) < epsilon)
{
ret = *this;
}
else
{
T sinTheta = (T)sqrt(1.0 - cosTheta * cosTheta);
if (fabs(sinTheta) < epsilon)
{
ret.w = 0.5 * w + 0.5 * q2.w;
ret.v = v.lerp(0.5, q2.v);
}
else
{
T rA = (T)sin((1.0 - r) * theta) / sinTheta;
T rB = (T)sin(r * theta) / sinTheta;
ret.w = w * rA + q2.w * rB;
ret.v.x = v.x * rA + q2.v.x * rB;
ret.v.y = v.y * rA + q2.v.y * rB;
ret.v.z = v.z * rA + q2.v.z * rB;
}
}
return ret;
}
/**
* Gets string representation.
*/
std::string toString() const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
};
typedef Quaternion<float> Quatf;
typedef Quaternion<double> Quatd;
#ifdef VMATH_NAMESPACE
}
#endif
#endif // __vmath_Header_File__
| [
"william.quartz@gmail.com"
] | william.quartz@gmail.com |
4aef349a562b7786d0fcc3419f3b5a418eb3aa86 | d7b84a31cafb72a3cb71b3a3cc724a68119ba18e | /Kvasir/0.4/T | 165b3b1190d77400116bf120b7c3eb47348a2eda | [] | no_license | benroque/Ragnorak | 6cc7c68db801f9281a4ac241da754bce88ef6caf | a1bfc2430cccb207192792acebdd1530f1388a4c | refs/heads/master | 2021-01-14T08:13:18.774988 | 2017-02-20T08:32:53 | 2017-02-20T08:32:53 | 82,008,402 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 96,852 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.4";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField nonuniform List<scalar>
18000
(
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54023
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54114
1.28061
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54157
1.28078
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54169
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54174
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54176
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54175
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54168
1.28078
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54138
1.28063
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5406
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54112
1.28061
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54167
1.28094
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54186
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54192
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54195
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54191
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54177
1.28093
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5413
1.28062
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54153
1.28077
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54184
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54193
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54186
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54156
1.28077
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54164
1.2808
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54189
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54195
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54187
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54161
1.2808
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54167
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5419
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54198
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54193
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54187
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54163
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54167
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5419
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54198
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54193
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54187
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54163
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54164
1.2808
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54189
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54195
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54187
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54161
1.2808
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54153
1.28077
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54184
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54193
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54196
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54197
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28098
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54186
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54156
1.28077
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54112
1.28061
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54167
1.28094
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54186
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54192
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54195
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54194
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54191
1.28097
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54177
1.28093
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5413
1.28062
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54023
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54114
1.28061
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54157
1.28078
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54169
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54174
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54176
1.28082
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54175
1.28081
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54168
1.28078
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.54138
1.28063
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.5406
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27975
1.27995
1.27996
1.27996
1.27997
1.27997
1.27998
1.27998
1.27998
1.28002
1.27977
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27998
1.27998
1.28002
1.27979
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.27998
1.28001
1.27981
1.27995
1.27996
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.28001
1.27983
1.27995
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.28
1.27985
1.27995
1.27995
1.27996
1.27996
1.27996
1.27997
1.27997
1.27997
1.27999
1.27987
1.27995
1.27995
1.27995
1.27996
1.27996
1.27996
1.27996
1.27997
1.27999
1.27989
1.27995
1.27995
1.27995
1.27995
1.27996
1.27996
1.27996
1.27996
1.27998
1.27991
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27996
1.27997
1.27993
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27995
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28034
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28033
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28038
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28041
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28044
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28047
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28051
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28056
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28017
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28024
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28011
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28023
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.2801
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28015
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28003
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28015
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28019
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28023
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27994
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27984
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2798
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27976
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27971
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27965
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27959
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28026
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27984
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27979
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27974
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27968
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2796
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27942
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2793
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27916
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27899
1.28021
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27976
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27969
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27961
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27941
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27928
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27913
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27893
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27869
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27838
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27962
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27953
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27942
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27929
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27913
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27893
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27869
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27838
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27797
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.2797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27962
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27953
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27942
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27929
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27913
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27893
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27869
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27838
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27797
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27976
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27969
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27961
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27941
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27928
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27913
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27893
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27869
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27838
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27984
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27979
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27974
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27968
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2796
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27942
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2793
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27916
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27899
1.28021
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27984
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2798
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27976
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27971
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27965
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27959
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27952
1.28026
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28003
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28015
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28019
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28023
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.2801
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28015
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28013
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28014
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28023
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28021
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28017
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28024
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28011
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28034
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28033
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28038
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28041
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28044
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28047
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28051
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28056
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27975
1.27995
1.27996
1.27996
1.27997
1.27997
1.27998
1.27998
1.27998
1.28002
1.27977
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27998
1.27998
1.28002
1.27979
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.27998
1.28001
1.27981
1.27995
1.27996
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.28001
1.27983
1.27995
1.27995
1.27996
1.27996
1.27997
1.27997
1.27997
1.27997
1.28
1.27985
1.27995
1.27995
1.27996
1.27996
1.27996
1.27997
1.27997
1.27997
1.27999
1.27987
1.27995
1.27995
1.27995
1.27996
1.27996
1.27996
1.27996
1.27997
1.27999
1.27989
1.27995
1.27995
1.27995
1.27995
1.27996
1.27996
1.27996
1.27996
1.27998
1.27991
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27996
1.27997
1.27993
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27995
1.28002
1.27998
1.27998
1.27998
1.27997
1.27997
1.27996
1.27996
1.27995
1.27975
1.28002
1.27998
1.27998
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27977
1.28001
1.27998
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27979
1.28001
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27996
1.27995
1.27981
1.28
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27995
1.27983
1.27999
1.27997
1.27997
1.27997
1.27996
1.27996
1.27996
1.27995
1.27995
1.27985
1.27999
1.27997
1.27996
1.27996
1.27996
1.27996
1.27995
1.27995
1.27995
1.27987
1.27998
1.27996
1.27996
1.27996
1.27996
1.27995
1.27995
1.27995
1.27995
1.27989
1.27997
1.27996
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27991
1.27995
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28034
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28033
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28038
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28041
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28044
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28047
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28051
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28056
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28017
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28011
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28024
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28023
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28021
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28021
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28021
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28013
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28015
1.28005
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28015
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28019
1.27988
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28023
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27984
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.2798
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.27976
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.27971
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.27965
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.27959
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28026
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.27984
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27979
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27974
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27968
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.2796
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.27942
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.2793
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.27916
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28021
1.27899
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27976
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27969
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27961
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.27941
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27928
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27913
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27893
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27869
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.27838
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27962
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27953
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27942
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27929
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27913
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.27893
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.27869
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.27838
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.27797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27962
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27953
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27942
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27929
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.27913
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.27893
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.27869
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.27838
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.27797
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27975
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27969
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27961
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.27941
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27928
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27912
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27893
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27869
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.27838
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.27984
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27979
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27974
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27968
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.2796
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.27942
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.2793
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.27916
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28021
1.27899
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27984
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.2798
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.27975
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.27971
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28016
1.27965
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2802
1.27959
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28026
1.27952
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28015
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28019
1.27988
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28023
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28008
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2801
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28012
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28015
1.28005
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28018
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28013
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28013
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28013
1.28014
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28019
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28008
1.28018
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28016
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28023
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28021
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28021
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28021
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28006
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28007
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28009
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.2801
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28011
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28012
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28017
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.2802
1.28011
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28024
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28034
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28033
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28035
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28038
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28041
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28044
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28047
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28051
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28056
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28002
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28004
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28005
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28003
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27988
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27992
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27995
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27986
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27987
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27989
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.2799
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27991
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27994
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27996
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28002
1.27998
1.27998
1.27998
1.27997
1.27997
1.27996
1.27996
1.27995
1.27975
1.28002
1.27998
1.27998
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27977
1.28001
1.27998
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27979
1.28001
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27996
1.27995
1.27981
1.28
1.27997
1.27997
1.27997
1.27997
1.27996
1.27996
1.27995
1.27995
1.27983
1.27999
1.27997
1.27997
1.27997
1.27996
1.27996
1.27996
1.27995
1.27995
1.27985
1.27999
1.27997
1.27996
1.27996
1.27996
1.27996
1.27995
1.27995
1.27995
1.27987
1.27998
1.27996
1.27996
1.27996
1.27996
1.27995
1.27995
1.27995
1.27995
1.27989
1.27997
1.27996
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27995
1.27991
1.27995
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27994
1.27993
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27983
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28001
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27983
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27999
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27998
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27997
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.28
1.27985
)
;
boundaryField
{
walls
{
type zeroGradient;
}
nozzleExt
{
type zeroGradient;
}
nozzleInt
{
type zeroGradient;
}
inlet
{
type fixedValue;
value uniform 1;
}
outlet
{
type zeroGradient;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"benroque94@gmail.com"
] | benroque94@gmail.com | |
1a047a72fbcdcd53eaee91c5c79a20116782a76e | 0e0b90f3250534f2572efd22a63b9addb02b0a0d | /ExternalMemoryAlgorithms/ExternalSort.h | 0129a728f13ef4e9aae3b3c2d6973c120440d5be | [] | no_license | Qwertenx/external-memory-algos | 226e6251dcddc5648f0f15fdaa9424a7a390fde5 | 60a66f575276692651f03c597e5bf98c813dcf78 | refs/heads/master | 2023-02-10T13:06:42.322978 | 2021-01-03T21:54:20 | 2021-01-03T21:54:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 329 | h | #pragma once
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <fstream>
#include <iostream>
#include "BufferedIntReader.h"
#include "BufferedIntWriter.h"
bool externalSort(std::string inputFilePath, std::string outputFilePath, std::string tempFileDirectory, int availableRAM); | [
"valshavel@gmai.com"
] | valshavel@gmai.com |
0a7e3626e57a18291a35cca4adcf65d5d5ca663f | 3ba43599a0aa935cc3959f50a909703d79e96e8f | /src/Game/button1.h | cbdb0c0cb57c60079ce657c1e0eae78962c81d42 | [] | no_license | gienekart/Simple-bug-saper | 5af9ee168bcbb1de5634e78e025f286cc0a32495 | 30ac12786c11490fd8675b32b1adc7d79124bb00 | refs/heads/master | 2021-01-19T20:29:46.535176 | 2011-12-28T17:43:34 | 2011-12-28T17:43:34 | 2,715,461 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 249 | h | //#pragma once
#include "Game/button.h"
#pragma once
class InfoButton: public Button
{
public:
InfoButton(const char* howMany);
virtual ~InfoButton();
virtual void Update(float detlatime);
private:
static const float changeSpeed;
};
| [
"wojciech.raq@gmail.com"
] | wojciech.raq@gmail.com |
bcc649a173b3745794ed39f1131cde4fb74ddf44 | 2a32873a84618f4d93d4604072ad1bd27a1ee3c2 | /src-atex/version.hpp | ff9bcea973dd2c8a124f68013a79583071f0af3c | [
"MIT"
] | permissive | magicmoremagic/bengine-tools-gfx | 040c39bd5351ee3fde28151c25330ab24e714155 | 71dda096b026319b34e24ac4c2570b1fcb56096a | refs/heads/master | 2021-09-03T06:10:03.649405 | 2018-01-06T07:13:19 | 2018-01-06T07:13:19 | 79,631,639 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 688 | hpp | #pragma once
#ifndef BE_ATEX_VERSION_HPP_
#define BE_ATEX_VERSION_HPP_
#include <be/core/macros.hpp>
#define BE_ATEX_VERSION_MAJOR 0
#define BE_ATEX_VERSION_MINOR 1
#define BE_ATEX_VERSION_REV 0
/*!! include('common/version', 'BE_ATEX', 'atex') !! 6 */
/* ################# !! GENERATED CODE -- DO NOT MODIFY !! ################# */
#define BE_ATEX_VERSION (BE_ATEX_VERSION_MAJOR * 100000 + BE_ATEX_VERSION_MINOR * 1000 + BE_ATEX_VERSION_REV)
#define BE_ATEX_VERSION_STRING "atex " BE_STRINGIFY(BE_ATEX_VERSION_MAJOR) "." BE_STRINGIFY(BE_ATEX_VERSION_MINOR) "." BE_STRINGIFY(BE_ATEX_VERSION_REV)
/* ######################### END OF GENERATED CODE ######################### */
#endif
| [
"ben@magicmoremagic.com"
] | ben@magicmoremagic.com |
89142246f7628e884116751c706b462a89d48913 | faf940641a408c06f0816264b89e1c21e0cc5f25 | /Legendy.Source/ClientSource/Client/EterImageLib/StdAfx.h | 47d75a9ed66ec972ea649e803157885a2eb19f0e | [] | no_license | nkuprens27/LegendySF-V2 | 90c49a0c3670eab5f3698385ec7c9f772d51988e | 7f9205448fd76bde7bff7b7aac568e795659b0be | refs/heads/main | 2023-07-18T03:57:57.258546 | 2021-09-08T20:59:37 | 2021-09-08T20:59:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,241 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_)
#define AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma warning(disable:4786)
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
//#include <crtdbg.h>
#include "../UserInterface/Locale_inc.h"
#include <windows.h>
#include <assert.h>
#pragma warning(push, 3)
#include <string>
#include <vector>
#pragma warning(pop)
inline void _TraceForImage(const char* c_szFormat, ...)
{
va_list args;
va_start(args, c_szFormat);
static char szBuf[1024];
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
#ifdef _DEBUG
OutputDebugString(szBuf);
#endif
va_end(args);
printf(szBuf);
}
#pragma warning(default:4018)
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_)
| [
"burakdayanc41@gmail.com"
] | burakdayanc41@gmail.com |
c53c370892ecc43fc7e9e8b3dc8234acb124440b | 82171fe7bd54815c24dbb9eb5614c6a22c40ee97 | /class_objects_in_cpp.cpp | be45401ea849a0ae531557d92753b2d38718945f | [] | no_license | Dhivya-Dharani-S/practise_coding | d2659b20a42abc622b60e97a671fa95549d759cd | cd8a03cf48aa005d12da76aba4222b346da18463 | refs/heads/main | 2023-07-16T14:55:51.985770 | 2021-08-19T16:48:49 | 2021-08-19T16:48:49 | 332,743,529 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,335 | cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
class Student
{
private:
int scores[5];
public:
void input()
{
for (int i = 0; i < 5; i++)
{
cin >> scores[i];
}
}
int calculateTotalScore()
{
int count = 0;
for (int i = 0; i < 5; i++)
{
count += scores[i];
}
return count;
}
};
int main() {
int n; // number of students
cin >> n;
Student *s = new Student[n]; // an array of n students
for(int i = 0; i < n; i++){
s[i].input();
}
// calculate kristen's score
int kristen_score = s[0].calculateTotalScore();
// determine how many students scored higher than kristen
int count = 0;
for(int i = 1; i < n; i++){
int total = s[i].calculateTotalScore();
if(total > kristen_score){
count++;
}
}
// print result
cout << count;
return 0;
}
/*Here it compares the value of the first student once. after that it checks that how many students scored higher than the already calculated one student's value
if it is greater it keeps the count varible to maintaining how many students are higher and returning that value*/
| [
"noreply@github.com"
] | noreply@github.com |
b1ee39e3aaca9f5e149755ef13af2f1fbf75028a | d8979a5d8318a37b6ecf7e3756f0280484529b39 | /Memory_King_bj.cpp | 3b2058e7ffeb8e2af94ccdba758182cdd14cd8c3 | [] | no_license | ImTurtle35/Baekjoon | 6757a9edb7d9d046d298dadbfd5f04c8abbf7a71 | 255f85beb4378bcf373dc500b9bdbef77f258609 | refs/heads/master | 2020-07-26T21:36:39.891307 | 2020-01-31T15:43:26 | 2020-01-31T15:43:26 | 208,772,602 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 604 | cpp | // baekjoon 2776
// bineary_search
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int T, N, M, save;
vector<int>Note_1;
vector<int>Note_2;
int main(){
cin >> T;
for (int i{ 0 }; i < T; i++) {
Note_1.clear();
Note_2.clear();
cin >> N;
for (int j{ 0 }; j < N; j++) {
cin >> save;
Note_1.push_back(save);
}
cin >> M;
for (int j{ 0 }; j < M; j++) {
cin >> save;
Note_2.push_back(save);
}
sort(Note_1.begin(), Note_1.end());
for (int j{ 0 }; j < M; j++) {
cout << binary_search(Note_1.begin(), Note_1.end(), Note_2[j]) << "\n";
}
}
} | [
"kjjgo35@gmail.com"
] | kjjgo35@gmail.com |
6c22c821c339b4ba8e5e885d11f6debfa7211590 | cac4d8e092525af81232c3ae49dfe9a5b0f61510 | /DistributedObjectServer/DistributedObjectServer/DOSMainThread.cpp | aacc64c1cb90ca83122e0e12f13661e583eec534 | [] | no_license | wincc0823/EasyGameLibs | e84145bfe9310a6d7de74d5e115f1a3256fe7918 | 17791e6197e0cbc4a530c66d46dfe90c6c6e340f | refs/heads/master | 2020-08-02T19:37:14.862698 | 2019-09-05T09:35:36 | 2019-09-05T09:35:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 63,440 | cpp | #include "stdafx.h"
#ifndef WIN32
#include <sys/wait.h>
#endif
#define SERVER_STAT_TIME (5*60*1000)
IMPLEMENT_CLASS_INFO_STATIC(CDOSMainThread,CDOSServerThread);
CDOSMainThread::CDOSMainThread(void)
{
FUNCTION_BEGIN;
m_Status = STATUS_NONE;
m_hMCSOutRead = NULL;
m_hMCSOutWrite = NULL;
m_hMCSInRead = NULL;
m_hMcsInWrite = NULL;
m_hMcsErrWrite = NULL;
m_pMonoMainDomain = NULL;
FUNCTION_END;
}
CDOSMainThread::~CDOSMainThread(void)
{
}
BOOL CDOSMainThread::OnStart()
{
FUNCTION_BEGIN;
CDOSServerThread::SetConfig(CDOSConfig::GetInstance()->GetDOSConfig());
if (!MonoInit())
return FALSE;
if(!CDOSServerThread::OnStart())
return FALSE;
if(!m_PluginObjectManager.Init(GetObjectManager(),CDOSConfig::GetInstance()->GetPluginObjectPoolConfig()))
{
Log("初始化插件对象管理器失败");
return FALSE;
}
CompileLibs();
m_ESFactionList.AddCFunction("ShowObjectCount",0,this,&CDOSMainThread::ShowObjectCount);
m_ESFactionList.AddCFunction("ShowGroupInfo",0,this,&CDOSMainThread::ShowGroupInfo);
m_ESFactionList.AddCFunction("ListPlugin",0,this,&CDOSMainThread::ListPlugin);
m_ESFactionList.AddCFunction("ReleasePlugin",1,this,&CDOSMainThread::ReleasePlugin);
m_PluginReleaseCheckTimer.SaveTime();
return TRUE;
FUNCTION_END;
return FALSE;
}
int CDOSMainThread::Update(int ProcessPacketLimit)
{
FUNCTION_BEGIN;
int Process=0;
Process+=CDOSServerThread::Update(SERVER_UPDATE_LIMIT);
bool IsCompiling = false;
switch (m_Status)
{
case STATUS_COMPILE_LIBS:
{
for (UINT i = 0; i < m_LibList.GetCount(); i++)
{
LIB_INFO& LibInfo = m_LibList[i];
if (LibInfo.Status == LIB_COMPILE_STATE_COMPILING)
{
IsCompiling = true;
if (LibInfo.hMCSProcess != NULL)
{
#ifdef WIN32
DWORD ExitCode = 0;
if (GetExitCodeProcess(LibInfo.hMCSProcess, &ExitCode))
{
if (ExitCode == STILL_ACTIVE)
{
break;
}
else
{
LogMono("MCS已退出%d", ExitCode);
LibInfo.Status = LIB_COMPILE_STATE_COMPILED;
CloseHandle(LibInfo.hMCSProcess);
LibInfo.hMCSProcess = NULL;
}
}
else
{
LogMono("获取MCS进程退出码失败%d", GetLastError());
LibInfo.Status = LIB_COMPILE_STATE_ERROR;
CloseHandle(LibInfo.hMCSProcess);
LibInfo.hMCSProcess = NULL;
}
#else
int ExitCode = 0;
int Err = waitpid((pid_t)(ptrdiff_t)LibInfo.hMCSProcess, &ExitCode, WNOHANG);
if (Err == -1)
{
LogMono("等待MCS出错%d", errno);
LibInfo.Status = LIB_COMPILE_STATE_ERROR;
LibInfo.hMCSProcess = NULL;
signal(SIGCHLD, SIG_IGN);
}
else if (Err != 0)
{
ExitCode = WEXITSTATUS(ExitCode);
LogMono("MCS已退出%d", ExitCode);
LibInfo.Status = LIB_COMPILE_STATE_COMPILED;
LibInfo.hMCSProcess = NULL;
signal(SIGCHLD, SIG_IGN);
}
#endif
}
else
{
LogMono("库[%s]编译状态异常", (LPCTSTR)LibInfo.LibName);
LibInfo.Status = LIB_COMPILE_STATE_ERROR;
}
}
else if (LibInfo.Status == LIB_COMPILE_STATE_NEED_COMPILE)
{
CompileCSharpLib(LibInfo);
IsCompiling = true;
break;
}
}
if (!IsCompiling)
m_Status = STATUS_PLUGIN_LOAD;
}
break;
case STATUS_PLUGIN_LOAD:
{
LoadProxyPlugins();
LoadPlugins();
m_Status = STATUS_WORKING;
}
break;
case STATUS_WORKING:
{
if (m_PluginReleaseCheckTimer.IsTimeOut(PLUGIN_RELASE_CHECK_TIME))
{
m_PluginReleaseCheckTimer.SaveTime();
CAutoLock Lock(m_PluginReleaseLock);
for (int i = (int)m_PluginReleaseList.GetCount() - 1; i >= 0; i--)
{
if (FreePlugin(m_PluginReleaseList[i]))
{
m_PluginReleaseList.Delete(i);
}
}
}
UINT RunningPluginCount = 0;
for (UINT i = 0; i < m_PluginList.GetCount(); i++)
{
PLUGIN_INFO& PluginInfo = m_PluginList[i];
if (PluginInfo.PluginStatus == PLUGIN_STATUS_COMPILEING)
{
IsCompiling = true;
if (PluginInfo.hMCSProcess != NULL)
{
#ifdef WIN32
DWORD ExitCode = 0;
if (GetExitCodeProcess(PluginInfo.hMCSProcess, &ExitCode))
{
if (ExitCode != STILL_ACTIVE)
{
LogMono("MCS已退出%d", ExitCode);
if (ExitCode == 0)
{
PluginInfo.PluginStatus = PLUGIN_STATUS_COMPILED;
LoadCSharpPlugin(PluginInfo);
}
else
{
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
}
CloseHandle(PluginInfo.hMCSProcess);
PluginInfo.hMCSProcess = NULL;
}
}
else
{
LogMono("获取MCS进程退出码失败%d", GetLastError());
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
CloseHandle(PluginInfo.hMCSProcess);
PluginInfo.hMCSProcess = NULL;
}
#else
int ExitCode = 0;
int Err = waitpid((pid_t)(ptrdiff_t)PluginInfo.hMCSProcess, &ExitCode, WNOHANG);
if (Err == -1)
{
LogMono("等待MCS出错%d", errno);
}
else if (Err != 0)
{
ExitCode = WEXITSTATUS(ExitCode);
LogMono("MCS已退出%d", ExitCode);
if (ExitCode == 0)
{
PluginInfo.PluginStatus = PLUGIN_STATUS_COMPILED;
LoadCSharpPlugin(PluginInfo);
}
else
{
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
}
PluginInfo.hMCSProcess = NULL;
}
#endif
}
else
{
LogMono("插件[%s]编译状态异常", (LPCTSTR)PluginInfo.PluginName);
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
}
}
if (PluginInfo.PluginStatus != PLUGIN_STATUS_NONE && PluginInfo.PluginStatus != PLUGIN_STATUS_ERROR)
{
RunningPluginCount++;
}
}
if (RunningPluginCount == 0 && CDOSConfig::GetInstance()->ExistWhenNoPlugin())
{
Log("CMainThread::Update:已无活动插件存在,服务器关闭");
QueryShowDown();
}
}
break;
}
if (m_hMCSOutRead&&IsCompiling)
{
char Buff[2100];
#ifdef WIN32
DWORD ReadSize = 0;
if (PeekNamedPipe(m_hMCSOutRead, NULL, 0, NULL, &ReadSize, NULL))
{
if (ReadSize)
{
if (ReadFile(m_hMCSOutRead, Buff, 2048, &ReadSize, NULL))
{
if (ReadSize)
{
Buff[ReadSize] = 0;
PrintMCSMsg(Buff);
}
}
}
}
#else
Buff[0] = 0;
size_t ReadSize = read((int)(ptrdiff_t)m_hMCSOutRead, Buff, 2048);
if (ReadSize>0&&ReadSize<2048)
{
Buff[ReadSize] = 0;
PrintMCSMsg(Buff);
}
#endif
}
if (CDOSConfig::GetInstance()->GetMonoConfig().EnableMono)
{
if (m_MonoFullGCTimer.IsTimeOut())
{
m_MonoFullGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().FullGCInterval);
mono_gc_collect(mono_gc_max_generation());
}
else if (m_MonoAdvanceGCTimer.IsTimeOut())
{
m_MonoAdvanceGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().BaseGCInterval*CDOSConfig::GetInstance()->GetMonoConfig().AdvanceGCMul);
mono_gc_collect(CDOSConfig::GetInstance()->GetMonoConfig().AdvanceGCMul - 1);
}
else if (m_MonoBaseGCTimer.IsTimeOut())
{
m_MonoBaseGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().BaseGCInterval);
mono_gc_collect(0);
}
}
return Process;
FUNCTION_END;
return 1;
}
void CDOSMainThread::OnBeginTerminate()
{
FUNCTION_BEGIN;
FUNCTION_END;
}
BOOL CDOSMainThread::OnTerminating()
{
FUNCTION_BEGIN;
FUNCTION_END;
return false;
}
void CDOSMainThread::OnTerminate()
{
FUNCTION_BEGIN;
//GetObjectManager()->SuspendAllGroup();
//GetObjectManager()->WaitForSuspend(60000);
CDOSServerThread::OnTerminate();
FreePlugins();
m_PluginObjectManager.Destory();
if (m_pMonoMainDomain)
{
mono_jit_cleanup(m_pMonoMainDomain);
m_pMonoMainDomain = NULL;
}
if (m_hMCSOutRead)
{
#ifdef WIN32
CloseHandle(m_hMCSOutRead);
#else
close((int)(ptrdiff_t)m_hMCSOutRead);
#endif
m_hMCSOutRead = NULL;
}
if (m_hMCSOutWrite)
{
#ifdef WIN32
CloseHandle(m_hMCSOutWrite);
#else
close((int)(ptrdiff_t)m_hMCSOutWrite);
#endif
m_hMCSOutWrite = NULL;
}
if (m_hMCSInRead)
{
#ifdef WIN32
CloseHandle(m_hMCSInRead);
#endif
m_hMCSInRead = NULL;
}
if (m_hMcsInWrite)
{
#ifdef WIN32
CloseHandle(m_hMcsInWrite);
#endif
m_hMcsInWrite = NULL;
}
if (m_hMcsErrWrite)
{
#ifdef WIN32
CloseHandle(m_hMcsErrWrite);
#endif
m_hMcsErrWrite = NULL;
}
FUNCTION_END;
}
int CDOSMainThread::GetClientCount()
{
FUNCTION_BEGIN;
FUNCTION_END;
return 0;
}
LPCTSTR CDOSMainThread::GetConfigFileName()
{
FUNCTION_BEGIN;
return CONFIG_FILE_NAME;
FUNCTION_END;
return "";
}
bool CDOSMainThread::QueryFreePlugin(UINT PluginID)
{
LogDebug("请求释放插件%u", PluginID);
CAutoLock Lock(m_PluginReleaseLock);
bool IsExist = false;
for (UINT i = 0; i < m_PluginReleaseList.GetCount(); i++)
{
if (m_PluginReleaseList[i] == PluginID)
{
IsExist = true;
break;
}
}
if (!IsExist)
{
m_PluginReleaseList.Add(PluginID);
return true;
}
else
{
return false;
}
}
bool CDOSMainThread::DosGroupInitFn(UINT GroupIndex)
{
//if (CDOSMainThread::GetInstance()->m_pMonoMainDomain)
//{
// MonoThread * pMonoThread = mono_thread_attach(CDOSMainThread::GetInstance()->m_pMonoMainDomain);
// if (pMonoThread)
// LogMono("已将对象组%u的线程关联到mono", GroupIndex);
// else
// LogMono("将对象组%u的线程关联到mono失败", GroupIndex);
//}
//else
//{
// LogMono("mono还未初始化");
//}
return true;
}
bool CDOSMainThread::DosGroupDestoryFn(UINT GroupIndex)
{
//MonoThread * pMonoThread = mono_thread_current();
//if (pMonoThread)
//{
// mono_thread_detach(pMonoThread);
// mono_thread_info_detach();
// //mono_thread_cleanup();
// LogMono("对象组线程%u执行mono_thread_detach", GroupIndex);
//}
//else
//{
// LogMono("对象组线程%u没有关联到mono", GroupIndex);
//}
return true;
}
MONO_DOMAIN_INFO * CDOSMainThread::GetMonoDomainInfo(UINT PluginID)
{
for (UINT i = 0; i < m_PluginList.GetCount(); i++)
{
if (m_PluginList[i].ID == PluginID&&m_PluginList[i].PluginType == PLUGIN_TYPE_CSHARP)
{
return &m_PluginList[i].MonoDomainInfo;
}
}
return NULL;
}
bool CDOSMainThread::IsMonoArrayElementTypeMatch(MonoArray * pArray, MonoClass * pClass)
{
MonoClass * pArrayClass = mono_object_get_class((MonoObject *)pArray);
if (pArrayClass)
{
MonoClass * pElementClass = mono_class_get_element_class(pArrayClass);
if (pElementClass)
{
return mono_class_get_type_token(pElementClass) == mono_class_get_type_token(pClass);
}
}
return false;
}
MonoArray * CDOSMainThread::MonoCreateByteArray(MONO_DOMAIN_INFO& DomainInfo, const void * pData, size_t DataSize)
{
if (DomainInfo.pMonoDomain)
{
MonoArray * pArray = mono_array_new(DomainInfo.pMonoDomain, mono_get_byte_class(), DataSize);
if (pArray)
{
if (pData && DataSize)
{
char * pBuff = mono_array_addr_with_size(pArray, sizeof(BYTE), 0);
if (pBuff)
{
memcpy(pBuff, pData, DataSize);
}
else
{
Log("CDOSMainThread::MonoCreateByteArray:获得字节数组内存地址失败");
}
}
return pArray;
}
else
{
Log("CDOSMainThread::MonoCreateByteArray:无法创建字节数组");
}
}
return NULL;
}
BYTE * CDOSMainThread::MonoGetByteArray(MonoArray * pArray, size_t& DataSize)
{
DataSize = mono_array_length(pArray);
if (DataSize)
{
return (BYTE *)mono_array_addr_with_size(pArray, sizeof(BYTE), 0);
}
return NULL;
}
MSG_ID_TYPE * CDOSMainThread::MonoGetMsgIDArray(MonoArray * pArray, size_t& DataSize)
{
DataSize = mono_array_length(pArray);
if (DataSize)
{
return (MSG_ID_TYPE *)mono_array_addr_with_size(pArray, sizeof(MSG_ID_TYPE), 0);
}
return NULL;
}
//MonoObject * CDOSMainThread::MonoCreateDOSObjectID(MONO_DOMAIN_INFO& DomainInfo, OBJECT_ID ObjectID)
//{
// if (DomainInfo.pMonoDomain && DomainInfo.pMonoClass_ObjectID && DomainInfo.pMonoClassMethod_ObjectID_Ctor)
// {
// MonoObject * pObject = mono_object_new(DomainInfo.pMonoDomain, DomainInfo.pMonoClass_ObjectID);
// if (pObject)
// {
// MonoObject * pException = NULL;
// void * Params[1];
// Params[0] = &ObjectID.ID;
// mono_runtime_invoke(DomainInfo.pMonoClassMethod_ObjectID_Ctor, pObject, Params, &pException);
// if (pException)
// {
// MonoString * pMsg = mono_object_to_string(pException, NULL);
// if (pMsg)
// {
// char * pBuff = mono_string_to_utf8(pMsg);
// LogMono("%s", pBuff);
// mono_free(pBuff);
// }
// }
// else
// {
// return pObject;
// }
// }
// else
// {
// LogMono("CDOSMainThread::MonoCreateDOSObjectID:创建对象失败");
// }
// }
// return NULL;
//}
OBJECT_ID CDOSMainThread::MonoGetObjectID(MONO_DOMAIN_INFO& DomainInfo, MonoObject * pObjectID)
{
if (DomainInfo.pMonoClass_ObjectID&&DomainInfo.pMonoClassField_ObjectID_ID&&pObjectID)
{
MonoClass * pClass = mono_object_get_class(pObjectID);
if (pClass)
{
if (mono_class_get_type_token(DomainInfo.pMonoClass_ObjectID) == mono_class_get_type_token(pClass))
{
OBJECT_ID ObjectID;
mono_field_get_value(pObjectID, DomainInfo.pMonoClassField_ObjectID_ID, &ObjectID.ID);
return ObjectID;
}
else
{
LogMono("CDOSMainThread::MonoGetObjectID:对象类型不符合");
}
}
else
{
LogMono("CDOSMainThread::MonoGetObjectID:无法获取对象的类");
}
}
return 0;
}
MonoString * CDOSMainThread::MonoCreateString(MONO_DOMAIN_INFO& DomainInfo, LPCTSTR szStr, size_t StrLen)
{
if (DomainInfo.pMonoDomain)
{
if (StrLen <= 0)
StrLen = _tcslen(szStr);
return mono_string_new_len(DomainInfo.pMonoDomain, szStr, (UINT)StrLen);
}
return NULL;
}
MonoObject * CDOSMainThread::MonoCreateDistributedObjectOperator(MONO_DOMAIN_INFO& DomainInfo, CDistributedObjectOperator * pOperator)
{
if (DomainInfo.pMonoDomain&&DomainInfo.pMonoClass_DistributedObjectOperator&&DomainInfo.pMonoClassMethod_DistributedObjectOperator_Ctor)
{
MonoObject * pObject = mono_object_new(DomainInfo.pMonoDomain, DomainInfo.pMonoClass_DistributedObjectOperator);
if (pObject)
{
MonoObject * pException = NULL;
void * Params[1];
Params[0] = &pOperator;
mono_runtime_invoke(DomainInfo.pMonoClassMethod_DistributedObjectOperator_Ctor, pObject, Params, &pException);
if (pException)
{
ProcessMonoException(pException);
}
else
{
return pObject;
}
}
else
{
LogMono("CDOSMainThread::MonoCreateDistributedObjectOperator:创建对象失败");
}
}
return NULL;
}
bool CDOSMainThread::MonoGetDORI(MONO_DOMAIN_INFO& DomainInfo, MonoObject * pObject, DOS_OBJECT_REGISTER_INFO_FOR_CS& RegisterInfo)
{
DOS_OBJECT_REGISTER_INFO_FOR_CS Info;
if (DomainInfo.MonoClassInfo_DORI.IsValid())
{
MonoClass * pClass = mono_object_get_class(pObject);
if (pClass)
{
if (mono_class_get_type_token(DomainInfo.MonoClassInfo_DORI.pClass) == mono_class_get_type_token(pClass))
{
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildObjectID, &RegisterInfo.ObjectID);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildWeight, &RegisterInfo.Weight);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildObjectGroupIndex, &RegisterInfo.ObjectGroupIndex);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildMsgQueueSize, &RegisterInfo.MsgQueueSize);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildMsgProcessLimit, &RegisterInfo.MsgProcessLimit);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildFlag, &RegisterInfo.Flag);
mono_field_get_value(pObject, DomainInfo.MonoClassInfo_DORI.pFeildObject, &RegisterInfo.pObject);
return true;
}
else
{
LogMono("CDOSMainThread::MonoGetDORI:对象类型不符合");
}
}
else
{
LogMono("CDOSMainThread::MonoGetDORI:无法获取对象的类");
}
}
return false;
}
bool CDOSMainThread::MonoGetObjectIDList(MONO_DOMAIN_INFO& DomainInfo, MonoArray * pArray, CEasyArray<OBJECT_ID>& ObjectIDList)
{
if (DomainInfo.pMonoDomain&&DomainInfo.pMonoClass_ObjectID&&DomainInfo.pMonoClassMethod_ObjectID_Ctor)
{
size_t Len = mono_array_length(pArray);
if (Len)
{
ObjectIDList.Resize(Len);
for (size_t i = 0; i < Len; i++)
{
MonoObject * pObject = (MonoObject *)mono_array_addr_with_size(pArray, sizeof(MonoObject *), i);
if (pObject)
{
ObjectIDList[i] = MonoGetObjectID(DomainInfo, pObject);
}
}
}
return true;
}
return false;
}
bool CDOSMainThread::LoadPlugins()
{
FUNCTION_BEGIN;
m_PluginList = CDOSConfig::GetInstance()->GetPluginList();
Log("一共有%u个插件", m_PluginList.GetCount());
for (UINT i = 0; i < m_PluginList.GetCount(); i++)
{
PLUGIN_INFO& PluginInfo = m_PluginList[i];
PluginInfo.ID = i + 1;
PluginInfo.LogChannel = PLUGIN_LOG_CHANNEL_START + i + 1;
PluginInfo.PluginStatus = PLUGIN_STATUS_NONE;
LoadPlugin(PluginInfo);
}
Log("插件装载完毕");
#ifdef WIN32
CExceptionParser::GetInstance()->OnFinishModuleLoad();
#endif
return true;
FUNCTION_END;
return false;
}
void CDOSMainThread::FreePlugins()
{
FUNCTION_BEGIN;
for(size_t i=0;i<m_PluginList.GetCount();i++)
{
FreePlugin(m_PluginList[i]);
}
FUNCTION_END;
}
void CDOSMainThread::CompileLibs()
{
FUNCTION_BEGIN;
m_Status = STATUS_COMPILE_LIBS;
m_LibList = CDOSConfig::GetInstance()->GetLibList();
for (UINT i = 0; i < m_LibList.GetCount(); i++)
{
CompileCSharpLib(m_LibList[i]);
break;
}
FUNCTION_END;
}
bool CDOSMainThread::LoadProxyPlugins()
{
const CEasyArray<CLIENT_PROXY_PLUGIN_INFO>& PluginList = CDOSConfig::GetInstance()->GetProxyPluginList();
Log("一共有%u个代理", PluginList.GetCount());
for (UINT i = 0; i < PluginList.GetCount(); i++)
{
CLIENT_PROXY_PLUGIN_INFO PluginInfo = PluginList[i];
if (PluginInfo.ProxyMode == CLIENT_PROXY_MODE_CUSTOM)
{
PluginInfo.ID = i + 1;
PluginInfo.LogChannel = PROXY_PLUGIN_LOG_CHANNEL_START + i + 1;
PluginInfo.PluginStatus = PLUGIN_STATUS_NONE;
CDOSObjectProxyServiceCustom * pProxy = new CDOSObjectProxyServiceCustom();
if (GetProxyManager()->RegisterProxyService(pProxy))
{
if (!pProxy->Init(this, PluginInfo))
{
GetProxyManager()->UnregisterProxyService(pProxy->GetID());
}
}
else
{
SAFE_RELEASE(pProxy);
}
}
}
Log("代理插件装载完毕");
return true;
}
bool CDOSMainThread::LoadPlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
//检查配置目录和日志目录
if (PluginInfo.ConfigDir.IsEmpty())
{
PluginInfo.ConfigDir = CFileTools::GetModulePath(NULL);
}
else
{
if (CFileTools::IsAbsolutePath(PluginInfo.ConfigDir))
PluginInfo.ConfigDir = CFileTools::MakeFullPath(PluginInfo.ConfigDir);
else
PluginInfo.ConfigDir = CFileTools::MakeModuleFullPath(NULL, PluginInfo.ConfigDir);
}
if (PluginInfo.LogDir.IsEmpty())
{
PluginInfo.LogDir = CFileTools::MakeModuleFullPath(NULL, "Log");
}
else
{
if (CFileTools::IsAbsolutePath(PluginInfo.LogDir))
PluginInfo.LogDir = CFileTools::MakeFullPath(PluginInfo.LogDir);
else
PluginInfo.LogDir = CFileTools::MakeModuleFullPath(NULL, PluginInfo.LogDir);
}
if (!CFileTools::IsDirExist(PluginInfo.LogDir))
{
if (!CFileTools::CreateDirEx(PluginInfo.LogDir))
{
Log("无法创建日志目录:%s", (LPCTSTR)PluginInfo.LogDir);
return false;
}
}
switch (PluginInfo.PluginType)
{
case PLUGIN_TYPE_NATIVE:
return LoadNativePlugin(PluginInfo);
break;
case PLUGIN_TYPE_CSHARP:
return LoadCSharpPlugin(PluginInfo);
break;
default:
Log("CMainThread::LoadPlugin:不支持的插件类型%d,%s", PluginInfo.PluginType, (LPCTSTR)PluginInfo.PluginName);
}
FUNCTION_END;
return false;
}
bool CDOSMainThread::FreePlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
switch (PluginInfo.PluginType)
{
case PLUGIN_TYPE_NATIVE:
return FreeNativePlugin(PluginInfo);
break;
case PLUGIN_TYPE_CSHARP:
return FreeCSharpPlugin(PluginInfo);
break;
default:
Log("CMainThread::FreePlugin:不支持的插件类型%d,%s", PluginInfo.PluginType, (LPCTSTR)PluginInfo.PluginName);
}
return false;
FUNCTION_END;
return false;
}
bool CDOSMainThread::FreePlugin(UINT PluginID)
{
FUNCTION_BEGIN;
for(size_t i=0;i<m_PluginList.GetCount();i++)
{
if (m_PluginList[i].ID == PluginID)
{
LogDebug("释放插件(%u)%s",
m_PluginList[i].ID, (LPCTSTR)m_PluginList[i].PluginName);
if (FreePlugin(m_PluginList[i]))
{
LogDebug("插件释放成功(%u)%s", m_PluginList[i].ID, (LPCTSTR)m_PluginList[i].PluginName);
m_PluginList.Delete(i);
return true;
}
else
{
LogDebug("插件释放失败(%u)%s", m_PluginList[i].ID, (LPCTSTR)m_PluginList[i].PluginName);
return false;
}
}
}
Log("插件%u未找到",PluginID);
FUNCTION_END;
return false;
}
bool CDOSMainThread::LoadNativePlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
if (PluginInfo.ModuleFileName.IsEmpty())
#ifdef _DEBUG
PluginInfo.ModuleFileName = PluginInfo.PluginName + "D";
#else
PluginInfo.ModuleFileName = PluginInfo.PluginName;
#endif
#ifndef WIN32
PluginInfo.ModuleFileName.Replace('\\', '/');
#endif
PluginInfo.ModuleFileName = CFileTools::MakeModuleFullPath(NULL, PluginInfo.ModuleFileName);
//扩展名补足
CEasyString FileExt = CFileTools::GetPathFileExtName(PluginInfo.ModuleFileName);
if (FileExt.GetLength() <= 1)
{
#ifdef WIN32
PluginInfo.ModuleFileName = PluginInfo.ModuleFileName + ".dll";
#else
PluginInfo.ModuleFileName = PluginInfo.ModuleFileName + ".so";
#endif
}
if (PluginInfo.PluginName.IsEmpty())
PluginInfo.PluginName = CFileTools::GetPathFileName(PluginInfo.ModuleFileName);
Log("开始装载插件(%u)%s,配置目录:%s,日志目录:%s",
PluginInfo.ID,
(LPCTSTR)PluginInfo.ModuleFileName,
(LPCTSTR)PluginInfo.ConfigDir,
(LPCTSTR)PluginInfo.LogDir);
#ifdef WIN32
PluginInfo.hModule = LoadLibrary(PluginInfo.ModuleFileName);
#else
PluginInfo.hModule = dlopen(PluginInfo.ModuleFileName, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
#endif
if (PluginInfo.hModule)
{
#ifdef WIN32
if (CSystemConfig::GetInstance()->IsPreLoadModuleSym())
{
CExceptionParser::GetInstance()->SymLoadFromModule(PluginInfo.ModuleFileName);
}
PluginInfo.pInitFN = (PLUGIN_INIT_FN)GetProcAddress(PluginInfo.hModule, PLUGIN_INIT_FN_NAME);
PluginInfo.pCheckReleaseFN = (PLUGIN_CHECK_RELEASE_FN)GetProcAddress(PluginInfo.hModule, PLUGIN_CHECK_RELEASE_FN_NAME);
if (PluginInfo.pInitFN&&PluginInfo.pCheckReleaseFN)
#else
//dlerror();
PluginInfo.pInitFN = (PLUGIN_INIT_FN)dlsym(PluginInfo.hModule, PLUGIN_INIT_FN_NAME);
LPCTSTR InitFNError = dlerror();
PluginInfo.pCheckReleaseFN = (PLUGIN_CHECK_RELEASE_FN)dlsym(PluginInfo.hModule, PLUGIN_CHECK_RELEASE_FN_NAME);
LPCTSTR CheckReleaseFNError = dlerror();
if (InitFNError == NULL&&CheckReleaseFNError == NULL&&PluginInfo.pInitFN&&PluginInfo.pCheckReleaseFN)
#endif
{
CEasyString LogFileName;
CServerLogPrinter * pLog;
LogFileName.Format("%s/Plugin.%s", (LPCTSTR)PluginInfo.LogDir, (LPCTSTR)CFileTools::GetPathFileName(PluginInfo.PluginName));
pLog = new CServerLogPrinter(this, CServerLogPrinter::LOM_CONSOLE | CServerLogPrinter::LOM_FILE,
CSystemConfig::GetInstance()->GetLogLevel(), LogFileName, CSystemConfig::GetInstance()->GetLogCacheSize());
CLogManager::GetInstance()->AddChannel(PluginInfo.LogChannel, pLog);
SAFE_RELEASE(pLog);
if ((*(PluginInfo.pInitFN))(&m_PluginObjectManager, PluginInfo.ID, PluginInfo.LogChannel, PluginInfo.ConfigDir, PluginInfo.LogDir))
{
PluginInfo.PluginStatus = PLUGIN_STATUS_RUNNING;
Log("插件装载成功%s", (LPCTSTR)PluginInfo.ModuleFileName);
return true;
}
else
{
Log("插件初始化失败%s", (LPCTSTR)PluginInfo.ModuleFileName);
}
}
else
{
Log("不合法的插件%s", (LPCTSTR)PluginInfo.ModuleFileName);
#ifndef WIN32
Log("InitFN错误信息:%s", InitFNError);
Log("CheckReleaseFN错误信息:%s", CheckReleaseFNError);
#endif
}
}
else
{
Log("无法装载插件(%d)%s", GetLastError(), (LPCTSTR)PluginInfo.ModuleFileName);
#ifndef WIN32
Log("错误信息:%s", dlerror());
#endif
}
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
FUNCTION_END;
return false;
}
bool CDOSMainThread::FreeNativePlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
if (PluginInfo.pCheckReleaseFN)
return (*(PluginInfo.pCheckReleaseFN))();
else
Log("没有插件释放检测函数");
return false;
FUNCTION_END;
return false;
}
bool CDOSMainThread::LoadCSharpPlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
if (m_pMonoMainDomain == NULL)
{
LogMono("MonoDomain未初始化");
return false;
}
if (PluginInfo.ModuleFileName.IsEmpty())
#ifdef _DEBUG
PluginInfo.ModuleFileName = PluginInfo.PluginName + "D";
#else
PluginInfo.ModuleFileName = PluginInfo.PluginName;
#endif
#ifndef WIN32
PluginInfo.ModuleFileName.Replace('\\', '/');
#endif
//扩展名补足
CEasyString FileExt = CFileTools::GetPathFileExtName(PluginInfo.ModuleFileName);
if (FileExt.GetLength() <= 1)
{
PluginInfo.ModuleFileName = PluginInfo.ModuleFileName + ".dll";
}
PluginInfo.ModuleFileName = CFileTools::MakeModuleFullPath(NULL, PluginInfo.ModuleFileName);
if (PluginInfo.PluginName.IsEmpty())
PluginInfo.PluginName = CFileTools::GetPathFileName(PluginInfo.ModuleFileName);
if (PluginInfo.LoadType == PLUGIN_LOAD_TYPE_SOURCE_CODE&&PluginInfo.PluginStatus != PLUGIN_STATUS_COMPILED)
{
//需要进行源码编译
CompileCSharpPlugin(PluginInfo);
return true;
}
else
{
Log("开始装载插件(%u)%s,配置目录:%s,日志目录:%s",
PluginInfo.ID,
(LPCTSTR)PluginInfo.ModuleFileName,
(LPCTSTR)PluginInfo.ConfigDir,
(LPCTSTR)PluginInfo.LogDir);
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
if (InitPluginDomain(PluginInfo.MonoDomainInfo, PluginInfo.PluginName))
{
mono_domain_set(PluginInfo.MonoDomainInfo.pMonoDomain, FALSE);
PluginInfo.pCSPluginAssembly = mono_domain_assembly_open(PluginInfo.MonoDomainInfo.pMonoDomain, PluginInfo.ModuleFileName);
if (PluginInfo.pCSPluginAssembly)
{
bool Ret = false;
MonoClass * pClass = mono_class_from_name(mono_assembly_get_image(PluginInfo.pCSPluginAssembly),
PluginInfo.MainClassNameSpace, PluginInfo.MainClass);
if (pClass)
{
MonoObject * pMainObj = mono_object_new(PluginInfo.MonoDomainInfo.pMonoDomain, pClass);
if (pMainObj)
{
MonoMethod * pCtorMethod = mono_class_get_method_from_name(pClass, ".ctor", 0);
if (pCtorMethod)
{
MonoObject * pException = NULL;
mono_runtime_invoke(pCtorMethod, pMainObj, NULL, &pException);
if (pException)
{
ProcessMonoException(pException);
}
else
{
MonoMethod * pInitMethod;
pInitMethod = mono_class_get_method_from_name(pClass, PLUGIN_INIT_FN_NAME, 4);
if (pInitMethod)
{
CEasyString LogFileName;
CServerLogPrinter * pLog;
LogFileName.Format("%s/Plugin.%s", (LPCTSTR)PluginInfo.LogDir, (LPCTSTR)CFileTools::GetPathFileName(PluginInfo.PluginName));
pLog = new CServerLogPrinter(this, CServerLogPrinter::LOM_CONSOLE | CServerLogPrinter::LOM_FILE,
CSystemConfig::GetInstance()->GetLogLevel(), LogFileName, CSystemConfig::GetInstance()->GetLogCacheSize());
CLogManager::GetInstance()->AddChannel(PluginInfo.LogChannel, pLog);
SAFE_RELEASE(pLog);
pException = NULL;
LPVOID Params[4];
Params[0] = &PluginInfo.ID;
Params[1] = &PluginInfo.LogChannel;
Params[2] = CDOSMainThread::GetInstance()->MonoCreateString(PluginInfo.MonoDomainInfo,
PluginInfo.ConfigDir, PluginInfo.ConfigDir.GetLength());
Params[3] = CDOSMainThread::GetInstance()->MonoCreateString(PluginInfo.MonoDomainInfo,
PluginInfo.LogDir, PluginInfo.LogDir.GetLength());
MonoObject * pReturnValue = mono_runtime_invoke(pInitMethod, pMainObj, Params, &pException);
if (pException)
{
ProcessMonoException(pException);
}
else if (pReturnValue)
{
void * pValue = mono_object_unbox(pReturnValue);
if (pValue)
{
Ret = *((bool *)pValue);
if (Ret)
{
PluginInfo.hCSMainObj = mono_gchandle_new(pMainObj, false);
PluginInfo.PluginStatus = PLUGIN_STATUS_RUNNING;
Log("插件装载成功%s", (LPCTSTR)PluginInfo.ModuleFileName);
return true;
}
}
else
{
Log("插件初始化函数返回值类型不正确");
}
}
else
{
LogMono("插件初始化函数没有返回值");
}
}
else
{
LogMono("无法找到插件初始化函数");
}
}
}
else
{
LogMono("无法找到构造函数");
}
}
else
{
LogMono("无法创建插件对象");
}
}
else
{
LogMono("无法找到插件类[%s.%s]", (LPCTSTR)PluginInfo.MainClassNameSpace, (LPCTSTR)PluginInfo.MainClass);
}
}
else
{
LogMono("无法加载模块%s", (LPCTSTR)PluginInfo.ModuleFileName);
}
ReleasePluginDomain(PluginInfo);
}
else
{
LogMono("无法初始化模块domain%s", (LPCTSTR)PluginInfo.ModuleFileName);
}
}
FUNCTION_END;
return false;
}
bool CDOSMainThread::CompileCSharpPlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
CEasyArray<CEasyString> SourceList;
for (UINT i = 0; i < PluginInfo.SourceDirs.GetCount(); i++)
{
CEasyString RootDir = CFileTools::MakeModuleFullPath(NULL, PluginInfo.SourceDirs[i]);
SourceList.Add(RootDir);
FetchDirs(RootDir, SourceList);
}
for (UINT i = 0; i < SourceList.GetCount(); i++)
{
SourceList[i] = SourceList[i] + DIR_SLASH + "*.cs";
}
CEasyArray<CEasyString> LibList;
FetchFiles(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir), _T(".dll"), LibList);
CEasyString OutFileName = PluginInfo.ModuleFileName;
if (CDOSConfig::GetInstance()->GetMonoConfig().CreateProj)
CreateCSProj(PluginInfo.PluginName, PluginInfo.PrjDir, PluginInfo.SourceDirs, OutFileName);
if (CallMCS(SourceList, LibList, PluginInfo.ModuleFileName, CDOSConfig::GetInstance()->GetMonoConfig().EnableDebug, PluginInfo.hMCSProcess))
{
PluginInfo.PluginStatus = PLUGIN_STATUS_COMPILEING;
return true;
}
PluginInfo.PluginStatus = PLUGIN_STATUS_ERROR;
FUNCTION_END;
return false;
}
bool CDOSMainThread::FreeCSharpPlugin(PLUGIN_INFO& PluginInfo)
{
FUNCTION_BEGIN;
if (PluginInfo.pCSPluginAssembly)
{
bool Ret = false;
mono_domain_set(PluginInfo.MonoDomainInfo.pMonoDomain, FALSE);
MonoClass * pClass = mono_class_from_name(mono_assembly_get_image(PluginInfo.pCSPluginAssembly),
PluginInfo.MainClassNameSpace, PluginInfo.MainClass);
if (pClass && PluginInfo.hCSMainObj)
{
MonoObject * pMainObj = mono_gchandle_get_target(PluginInfo.hCSMainObj);
if (pMainObj)
{
MonoMethod * pReleaseMethod;
pReleaseMethod = mono_class_get_method_from_name(pClass, PLUGIN_CHECK_RELEASE_FN_NAME, 0);
if (pReleaseMethod)
{
MonoObject * pException = NULL;
MonoObject * pReturnValue = mono_runtime_invoke(pReleaseMethod, pMainObj, NULL, &pException);
if (pException)
{
ProcessMonoException(pException);
}
else if (pReturnValue)
{
void * pValue = mono_object_unbox(pReturnValue);
if (pValue)
{
Ret = *((bool *)pValue);
}
else
{
Log("返回值类型不正确");
}
}
else
{
LogMono("插件释放检测函数没有返回值");
}
}
else
{
LogMono("CDOSMainThread::FreeCSharpPlugin:无法找到插件[%s]释放检测函数",
(LPCTSTR)PluginInfo.ModuleFileName);
}
}
}
else
{
LogMono("CDOSMainThread::FreeCSharpPlugin:无法找到插件[%s]类[%s.%s]",
(LPCTSTR)PluginInfo.ModuleFileName, (LPCTSTR)PluginInfo.MainClassNameSpace, (LPCTSTR)PluginInfo.MainClass);
}
if (Ret)
{
if (PluginInfo.hCSMainObj)
{
mono_gchandle_free(PluginInfo.hCSMainObj);
PluginInfo.hCSMainObj = 0;
}
//mono_assembly_close(PluginInfo.pCSPluginAssembly);
//PluginInfo.pCSPluginAssembly = NULL;
ReleasePluginDomain(PluginInfo);
LogMono("CDOSMainThread::FreeCSharpPlugin:插件[%s]已释放", (LPCTSTR)PluginInfo.ModuleFileName);
}
return Ret;
}
else
{
LogMono("CDOSMainThread::FreeCSharpPlugin:插件[%s]未加载", (LPCTSTR)PluginInfo.ModuleFileName);
return false;
}
FUNCTION_END;
return false;
}
bool CDOSMainThread::CompileCSharpLib(LIB_INFO& LibInfo)
{
FUNCTION_BEGIN;
if (!LibInfo.NeedCompile)
{
LibInfo.Status = LIB_COMPILE_STATE_COMPILED;
return true;
}
Log("开始编译库[%s]", (LPCTSTR)LibInfo.LibName);
CEasyString OutFileName;
OutFileName.Format("%s/%s.dll", (LPCTSTR)CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir, (LPCTSTR)LibInfo.LibName);
OutFileName = CFileTools::MakeModuleFullPath(NULL, OutFileName);
CEasyArray<CEasyString> SourceList;
for (UINT i = 0; i < LibInfo.SourceDirs.GetCount(); i++)
{
CEasyString RootDir = CFileTools::MakeModuleFullPath(NULL, LibInfo.SourceDirs[i]);
SourceList.Add(RootDir);
FetchDirs(RootDir, SourceList);
}
for (UINT i = 0; i < SourceList.GetCount(); i++)
{
SourceList[i] = SourceList[i] + DIR_SLASH + "*.cs";
}
CEasyArray<CEasyString> LibList;
FetchFiles(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir), _T(".dll"), LibList);
if (CDOSConfig::GetInstance()->GetMonoConfig().CreateProj)
CreateCSProj(LibInfo.LibName, LibInfo.PrjDir, LibInfo.SourceDirs, OutFileName);
if (CallMCS(SourceList, LibList, OutFileName, CDOSConfig::GetInstance()->GetMonoConfig().EnableDebug, LibInfo.hMCSProcess))
{
LibInfo.Status = LIB_COMPILE_STATE_COMPILING;
return true;
}
FUNCTION_END;
return false;
}
int CDOSMainThread::ShowObjectCount(CESThread * pESThread,ES_BOLAN* pResult,ES_BOLAN* pParams,int ParamCount)
{
FUNCTION_BEGIN;
GetDistributedObjectManager()->PrintObjectCount();
FUNCTION_END;
return 0;
}
int CDOSMainThread::ShowGroupInfo(CESThread * pESThread,ES_BOLAN* pResult,ES_BOLAN* pParams,int ParamCount)
{
FUNCTION_BEGIN;
GetObjectManager()->PrintGroupInfo(SERVER_LOG_CHANNEL);
FUNCTION_END;
return 0;
}
int CDOSMainThread::ListPlugin(CESThread * pESThread,ES_BOLAN* pResult,ES_BOLAN* pParams,int ParamCount)
{
FUNCTION_BEGIN;
for(size_t i=0;i<m_PluginList.GetCount();i++)
{
Log("ID=%u,Name=%s,File=%s", m_PluginList[i].ID, (LPCTSTR)m_PluginList[i].PluginName, (LPCTSTR)m_PluginList[i].ModuleFileName);
}
FUNCTION_END;
return 0;
}
int CDOSMainThread::ReleasePlugin(CESThread * pESThread,ES_BOLAN* pResult,ES_BOLAN* pParams,int ParamCount)
{
FUNCTION_BEGIN;
FreePlugin(pParams[0]);
FUNCTION_END;
return 0;
}
void CDOSMainThread::MonoLog(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
{
PrintImportantLog("[MonoLog][%s]%s", log_level, message);
}
void CDOSMainThread::MonoPrint(const char *string, mono_bool is_stdout)
{
PrintImportantLog("[MonoPrint]%s", string);
}
void CDOSMainThread::MonoPrintErr(const char *string, mono_bool is_stdout)
{
PrintImportantLog("[MonoPrintErr]%s", string);
}
bool CDOSMainThread::MonoInit()
{
FUNCTION_BEGIN;
if (!CDOSConfig::GetInstance()->GetMonoConfig().EnableMono)
{
Log("mono未开启");
return true;
}
m_MonoBaseGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().BaseGCInterval);
m_MonoAdvanceGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().BaseGCInterval*CDOSConfig::GetInstance()->GetMonoConfig().AdvanceGCMul);
m_MonoFullGCTimer.SetTimeOut(CDOSConfig::GetInstance()->GetMonoConfig().FullGCInterval);
#ifdef WIN32
//初始化接管MCS标准输入输出的管道
SECURITY_ATTRIBUTES Attr;
Attr.nLength = sizeof(SECURITY_ATTRIBUTES);
Attr.lpSecurityDescriptor = NULL;
Attr.bInheritHandle = TRUE;
if (!CreatePipe(&m_hMCSInRead, &m_hMcsInWrite, &Attr, 0))
{
LogMono("创建MCS输入管道失败%d", GetLastError());
}
if (!CreatePipe(&m_hMCSOutRead, &m_hMCSOutWrite, &Attr, 0))
{
LogMono("创建MCS输出管道失败%d");
}
if (!DuplicateHandle(GetCurrentProcess(), m_hMCSOutWrite, GetCurrentProcess(), &m_hMcsErrWrite, 0, TRUE, DUPLICATE_SAME_ACCESS))
{
LogMono("复制MCS输出管道失败%d");
}
#else
int fds[2];
if (pipe(fds) == 0)
{
m_hMCSOutRead = (HANDLE)fds[0];
m_hMCSOutWrite = (HANDLE)fds[1];
int Flag=fcntl((int)(ptrdiff_t)m_hMCSOutRead, F_GETFL, 0);
Flag=Flag|O_NONBLOCK;
fcntl((int)(ptrdiff_t)m_hMCSOutRead, F_SETFL, Flag);
}
else
{
LogMono("创建MCS输出管道失败%d", errno);
}
#endif
mono_trace_set_log_handler(MonoLog, this);
mono_trace_set_print_handler(MonoPrint);
mono_trace_set_printerr_handler(MonoPrintErr);
if (!CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir.IsEmpty())
mono_set_assemblies_path(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir));
if (!CDOSConfig::GetInstance()->GetMonoConfig().RunDir.IsEmpty())
mono_set_config_dir(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().RunDir));
if (!CDOSConfig::GetInstance()->GetMonoConfig().ConfigFilePath.IsEmpty())
mono_config_parse(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().ConfigFilePath));
if (CDOSConfig::GetInstance()->GetMonoConfig().EnableDebug)
{
CEasyString DebugConfigStr;
DebugConfigStr.Format("transport=dt_socket,address=%s:%u,server=y,suspend=%s",
CDOSConfig::GetInstance()->GetMonoConfig().DebugAgentListenAddress.GetIPString(),
CDOSConfig::GetInstance()->GetMonoConfig().DebugAgentListenAddress.GetPort(),
CDOSConfig::GetInstance()->GetMonoConfig().IsDebugSuspend ? "y" : "n");
mono_debugger_agent_parse_options(DebugConfigStr);
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
}
m_pMonoMainDomain = mono_jit_init_version("DistributedObjectServer", "v4.0.30319");
if (m_pMonoMainDomain)
{
RegisterMonoFunctions();
theApp.ReInitSignals();
LogMono("mono初始化完毕");
return true;
}
else
{
LogMono("MonoDomain创建失败");
}
FUNCTION_END;
return false;
}
void CDOSMainThread::RegisterMonoFunctions()
{
FUNCTION_BEGIN;
mono_add_internal_call("DOSSystem.Logger::InternalLog(uint,string)", (void *)CDOSMainThread::MonoInternalCallLog);
mono_add_internal_call("DOSSystem.Logger::InternalLogDebug(uint,string)", (void *)CDOSMainThread::MonoInternalCallLogDebug);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallGetRouterID()",
(void *)CDistributedObjectOperator::InternalCallGetRouterID);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallGetObjectID(intptr)",
(void *)CDistributedObjectOperator::InternalCallGetObjectID);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallGetGroupIndex(intptr)",
(void *)CDistributedObjectOperator::InternalCallGetGroupIndex);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallSendMessage(intptr,DOSSystem.OBJECT_ID,uint,uint16,byte[],int,int)",
(void *)CDistributedObjectOperator::InternalCallSendMessage);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallSendMessageMulti(intptr,DOSSystem.OBJECT_ID[],bool,uint,uint16,byte[],int,int)",
(void *)CDistributedObjectOperator::InternalCallSendMessageMulti);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterMsgMap(intptr,DOSSystem.OBJECT_ID,uint[])",
(void *)CDistributedObjectOperator::InternalCallRegisterMsgMap);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallUnregisterMsgMap(intptr,DOSSystem.OBJECT_ID,uint[])",
(void *)CDistributedObjectOperator::InternalCallUnregisterMsgMap);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterGlobalMsgMap(intptr,uint16,byte,uint,int)",
(void *)CDistributedObjectOperator::InternalCallRegisterGlobalMsgMap);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallUnregisterGlobalMsgMap(intptr,uint16,byte,uint)",
(void *)CDistributedObjectOperator::InternalCallUnregisterGlobalMsgMap);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallSetUnhanleMsgReceiver(intptr,uint16,byte)",
(void *)CDistributedObjectOperator::InternalCallSetUnhanleMsgReceiver);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallAddConcernedObject(intptr,DOSSystem.OBJECT_ID,bool)",
(void *)CDistributedObjectOperator::InternalCallAddConcernedObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallDeleteConcernedObject(intptr,DOSSystem.OBJECT_ID,bool)",
(void *)CDistributedObjectOperator::InternalCallDeleteConcernedObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallFindObject(intptr,uint)",
(void *)CDistributedObjectOperator::InternalCallFindObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallReportObject(intptr,DOSSystem.OBJECT_ID,byte[],int,int)",
(void *)CDistributedObjectOperator::InternalCallReportObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallCloseProxyObject(intptr,DOSSystem.OBJECT_ID,uint)",
(void *)CDistributedObjectOperator::InternalCallCloseProxyObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRequestProxyObjectIP(intptr,DOSSystem.OBJECT_ID)",
(void *)CDistributedObjectOperator::InternalCallRequestProxyObjectIP);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterObject(uint,DOSSystem.DOS_OBJECT_REGISTER_INFO_EX)",
(void *)CDistributedObjectOperator::InternalCallRegisterObjectStatic);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterObject(intptr,DOSSystem.DOS_OBJECT_REGISTER_INFO_EX)",
(void *)CDistributedObjectOperator::InternalCallRegisterObject);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRelease(intptr)",
(void *)CDistributedObjectOperator::InternalCallRelease);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallQueryShutDown(intptr,DOSSystem.OBJECT_ID,byte,uint)",
(void *)CDistributedObjectOperator::InternalCallQueryShutDown);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallShutDown(intptr,uint)",
(void *)CDistributedObjectOperator::InternalCallShutDown);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterLogger(uint,string)",
(void *)CDistributedObjectOperator::InternalCallRegisterLogger);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterCSVLogger(uint,string,string)",
(void *)CDistributedObjectOperator::InternalCallRegisterCSVLogger);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallRegisterCommandReceiver(intptr)",
(void *)CDistributedObjectOperator::InternalCallRegisterCommandReceiver);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallUnregisterCommandReceiver(intptr)",
(void *)CDistributedObjectOperator::InternalCallUnregisterCommandReceiver);
mono_add_internal_call("DOSSystem.DistributedObjectOperator::InternalCallSetServerWorkStatus(intptr,byte)",
(void *)CDistributedObjectOperator::InternalCallSetServerWorkStatus);
FUNCTION_END;
}
void CDOSMainThread::FetchFiles(LPCTSTR szDir, LPCTSTR szFileExt, CEasyArray<CEasyString>& FileList)
{
FUNCTION_BEGIN;
CFileSearcher FileSearcher;
CEasyString SearchPattern = szDir;
SearchPattern += "/*.*";
FileSearcher.FindFirst(SearchPattern);
while (FileSearcher.FindNext())
{
if (FileSearcher.IsDirectory() && (!FileSearcher.IsDots()))
{
FetchFiles(FileSearcher.GetFilePath(), szFileExt, FileList);
}
else if (FileSearcher.GetFileExt().CompareNoCase(szFileExt) == 0)
{
FileList.Add(FileSearcher.GetFilePath());
}
}
FUNCTION_END;
}
void CDOSMainThread::FetchDirs(LPCTSTR szDir, CEasyArray<CEasyString>& DirList)
{
FUNCTION_BEGIN;
CFileSearcher FileSearcher;
CEasyString SearchPattern = szDir;
SearchPattern += "/*.*";
FileSearcher.FindFirst(SearchPattern);
while (FileSearcher.FindNext())
{
if (FileSearcher.IsDirectory() && (!FileSearcher.IsDots()))
{
DirList.Add(FileSearcher.GetFilePath());
FetchDirs(FileSearcher.GetFilePath(), DirList);
}
}
FUNCTION_END;
}
MonoClass * CDOSMainThread::MonoGetClass(MonoAssembly * pMonoAssembly, LPCTSTR szNameSpace, LPCTSTR szClassName)
{
MonoClass * pMonoClass = NULL;
FUNCTION_BEGIN;
pMonoClass = mono_class_from_name(mono_assembly_get_image(pMonoAssembly),
szNameSpace, szClassName);
if (pMonoClass == NULL)
{
LogMono("CDOSMainThread::MonoGetClass:无法找到类[%s.%s]",
szNameSpace, szClassName);
}
FUNCTION_END;
return pMonoClass;
}
MonoClassField * CDOSMainThread::MonoGetClassField(MonoClass * pMonoClass, LPCTSTR szFieldName)
{
MonoClassField * pMonoClassField = NULL;
FUNCTION_BEGIN;
pMonoClassField = mono_class_get_field_from_name(pMonoClass, szFieldName);
if (pMonoClassField == NULL)
{
LogMono("CDOSMainThread::MonoGetClassField:无法在类[%s]中找到成员[%s]", mono_class_get_name(pMonoClass), szFieldName);
}
FUNCTION_END;
return pMonoClassField;
}
MonoMethod * CDOSMainThread::MonoGetClassMethod(MonoClass * pMonoClass, LPCTSTR szMethodName, int ParamCount)
{
MonoMethod * pMonoMethod = NULL;
FUNCTION_BEGIN;
pMonoMethod = mono_class_get_method_from_name(pMonoClass, szMethodName, ParamCount);
if (pMonoMethod == NULL)
{
LogMono("无法在类[%s]中找到成员函数[%s,%d]", mono_class_get_name(pMonoClass), szMethodName, ParamCount);
}
FUNCTION_END;
return pMonoMethod;
}
void CDOSMainThread::ProcessMonoException(MonoObject * pException)
{
CAutoLock Lock(m_MonoExcpetionLock);
MonoString * pMsg = mono_object_to_string(pException, NULL);
if (pMsg)
{
char * pBuff = mono_string_to_utf8(pMsg);
LogMono("%s", pBuff);
mono_free(pBuff);
}
}
bool CDOSMainThread::AddConsoleCommandReceiver(CDistributedObjectOperator * pOperator)
{
for (UINT i = 0; i < m_ConsoleCommandReceiverList.GetCount(); i++)
{
if (m_ConsoleCommandReceiverList[i] == pOperator)
return false;
}
m_ConsoleCommandReceiverList.Add(pOperator);
Log("对象0x%llX已注册为控制台命令接收者", pOperator->GetObjectID());
return true;
}
bool CDOSMainThread::DeleteConsoleCommandReceiver(CDistributedObjectOperator * pOperator)
{
for (UINT i = 0; i < m_ConsoleCommandReceiverList.GetCount(); i++)
{
if (m_ConsoleCommandReceiverList[i] == pOperator)
{
m_ConsoleCommandReceiverList.Delete(i);
Log("控制台命令接收者0x%llX已注销", pOperator->GetObjectID());
return true;
}
}
return false;
}
void CDOSMainThread::MonoInternalCallLog(UINT LogChannel, MonoString * pMsg)
{
char * szMsg = mono_string_to_utf8(pMsg);
if (szMsg)
{
ILogPrinter * pLogPrinter = CLogManager::GetInstance()->GetChannel(LogChannel);
if (pLogPrinter == NULL)
{
pLogPrinter = CLogManager::GetInstance()->GetChannel(LOG_MONO_CHANNEL);
}
pLogPrinter->PrintLogDirect(ILogPrinter::LOG_LEVEL_NORMAL, 0, szMsg);
mono_free(szMsg);
}
}
void CDOSMainThread::MonoInternalCallLogDebug(UINT LogChannel, MonoString * pMsg)
{
char * szMsg = mono_string_to_utf8(pMsg);
if (szMsg)
{
ILogPrinter * pLogPrinter = CLogManager::GetInstance()->GetChannel(LogChannel);
if (pLogPrinter == NULL)
{
pLogPrinter = CLogManager::GetInstance()->GetChannel(LOG_MONO_CHANNEL);
}
pLogPrinter->PrintLogDirect(ILogPrinter::LOG_LEVEL_DEBUG, 0, szMsg);
mono_free(szMsg);
}
}
bool CDOSMainThread::InitPluginDomain(MONO_DOMAIN_INFO& MonoDomainInfo, LPCTSTR szName)
{
if (m_pMonoMainDomain)
{
MonoDomainInfo.pMonoDomain = mono_domain_create_appdomain((char *)szName,
(CDOSConfig::GetInstance()->GetMonoConfig().ConfigFilePath.IsEmpty() ? NULL : (char *)((LPCTSTR)CDOSConfig::GetInstance()->GetMonoConfig().ConfigFilePath)));
if (MonoDomainInfo.pMonoDomain)
{
CEasyString SystemDllFileName = CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir + DIR_SLASH + MONO_ASSEMBLY_DOSSYSTEM);
MonoDomainInfo.pMonoAssembly_DOSSystem = mono_domain_assembly_open(MonoDomainInfo.pMonoDomain, SystemDllFileName);
if (MonoDomainInfo.pMonoAssembly_DOSSystem)
{
MonoDomainInfo.pMonoClass_ObjectID = MonoGetClass(MonoDomainInfo.pMonoAssembly_DOSSystem, MONO_NAME_SPACE_DOSSYSTEM, MONO_CLASS_NAME_OBJECT_ID);
if (MonoDomainInfo.pMonoClass_ObjectID)
{
MonoDomainInfo.pMonoClassField_ObjectID_ID = MonoGetClassField(MonoDomainInfo.pMonoClass_ObjectID, MONO_CLASS_FIELD_NAME_OBJECT_ID_ID);
MonoDomainInfo.pMonoClassMethod_ObjectID_Ctor = MonoGetClassMethod(MonoDomainInfo.pMonoClass_ObjectID,
MONO_CLASS_METHOD_NAME_OBJECT_ID_CTOR, MONO_CLASS_METHOD_PARAM_OBJECT_ID_CTOR);
}
MonoDomainInfo.pMonoClass_DistributedObjectOperator = MonoGetClass(MonoDomainInfo.pMonoAssembly_DOSSystem, MONO_NAME_SPACE_DOSSYSTEM, MONO_CLASS_NAME_DISTRIBUTED_OBJECT_OPERATOR);
if (MonoDomainInfo.pMonoClass_DistributedObjectOperator)
{
MonoDomainInfo.pMonoClassMethod_DistributedObjectOperator_Ctor = MonoGetClassMethod(MonoDomainInfo.pMonoClass_DistributedObjectOperator,
MONO_CLASS_METHOD_NAME_DOO_CTOR, MONO_CLASS_METHOD_PARAM_DOO_CTOR);
}
MonoDomainInfo.MonoClassInfo_DORI.pClass = MonoGetClass(MonoDomainInfo.pMonoAssembly_DOSSystem, MONO_NAME_SPACE_DOSSYSTEM, MONO_CLASS_NAME_DOS_OBJECT_REGISTER_INFO_EX);
if (MonoDomainInfo.MonoClassInfo_DORI.pClass)
{
MonoDomainInfo.MonoClassInfo_DORI.pFeildObjectID = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_OBJECT_ID);
MonoDomainInfo.MonoClassInfo_DORI.pFeildWeight = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_WEIGHT);
MonoDomainInfo.MonoClassInfo_DORI.pFeildObjectGroupIndex = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_OBJECT_GROUP_INDEX);
MonoDomainInfo.MonoClassInfo_DORI.pFeildMsgQueueSize = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_MSG_QUEUE_SIZE);
MonoDomainInfo.MonoClassInfo_DORI.pFeildMsgProcessLimit = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_MSG_PROCESS_LIMIT);
MonoDomainInfo.MonoClassInfo_DORI.pFeildFlag = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_FLAG);
MonoDomainInfo.MonoClassInfo_DORI.pFeildObject = MonoGetClassField(MonoDomainInfo.MonoClassInfo_DORI.pClass, MONO_CLASS_FIELD_NAME_DORI_OBJECT);
}
return true;
}
else
{
LogMono("无法加载系统库%s", (LPCTSTR)SystemDllFileName);
}
}
else
{
LogMono("无法创建Domain");
}
}
else
{
LogMono("Mono未初始化");
}
return false;
}
bool CDOSMainThread::ReleasePluginDomain(PLUGIN_INFO& PluginInfo)
{
if (PluginInfo.MonoDomainInfo.pMonoDomain)
{
//目前调用mono_domain_unload会导致assert,所以只能不调用,似乎最终虚拟机释放时也会被释放
//mono_domain_set(PluginInfo.MonoDomainInfo.pMonoDomain, FALSE);
mono_domain_finalize(PluginInfo.MonoDomainInfo.pMonoDomain, MONO_DOMAIN_FINALIZE_TIMEOUT);
//mono_domain_unload(PluginInfo.MonoDomainInfo.pMonoDomain);
PluginInfo.MonoDomainInfo.pMonoAssembly_DOSSystem = NULL;
PluginInfo.MonoDomainInfo.pMonoDomain = NULL;
}
PluginInfo.pCSPluginAssembly = NULL;
return true;
}
CEasyString CDOSMainThread::GetProjectGUID(LPCTSTR PrjName)
{
pug::xml_parser Xml;
Xml.parse_file(PrjName, pug::parse_trim_attribute);
xml_node Project = Xml.document();
if (Project.moveto_child(_T("Project")))
{
for (UINT i = 0; i < Project.children(); i++)
{
xml_node PropertyGroup = Project.child(i);
if (_tcsncmp(PropertyGroup.name(), _T("PropertyGroup"), 13) == 0)
{
xml_node ProjectGuid = PropertyGroup;
if (ProjectGuid.moveto_child(_T("ProjectGuid")))
{
return ProjectGuid.child_value();
}
}
}
}
return _T("");
}
bool CDOSMainThread::CreateCSProj(LPCTSTR szPrjName, LPCTSTR szPrjDir, const CEasyArray<CEasyString>& SourceDirs, LPCTSTR szOutFileName)
{
CEasyString PrjDir = CFileTools::MakeModuleFullPath(NULL, szPrjDir);
CEasyString PrjFilePath;
PrjFilePath.Format(_T("%s/%s.csproj"), (LPCTSTR)PrjDir, szPrjName);
PrjFilePath = CFileTools::MakeFullPath(PrjFilePath);
CEasyString PrjGUIDStr = GetProjectGUID(PrjFilePath);
if (PrjGUIDStr.IsEmpty())
{
#ifdef WIN32
GUID guid;
CoCreateGuid(&guid);
PrjGUIDStr.Format(_T("{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}"),
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
#else
uuid_t guid;
uuid_generate(reinterpret_cast<unsigned char *>(&guid));
PrjGUIDStr.Format(_T("{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}"),
guid[3], guid[2], guid[1], guid[0],
guid[5], guid[4],
guid[7], guid[6],
guid[8], guid[9],
guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
#endif
}
pug::xml_parser Xml;
Xml.create();
xml_node Doc;
Doc = Xml.document();
xml_node pi = Doc.append_child(node_pi);
pi.name(_T("xml"));
pi.attribute(_T("version")) = _T("1.0");
pi.attribute(_T("encoding")) = _T("utf-8");
xml_node Project = Doc.append_child(node_element, _T("Project"));
Project.append_attribute(_T("ToolsVersion"), _T("4.0"));
Project.append_attribute(_T("DefaultTargets"), _T("Build"));
Project.append_attribute(_T("xmlns"), _T("http://schemas.microsoft.com/developer/msbuild/2003"));
{
xml_node PropertyGroup = Project.append_child(node_element, _T("PropertyGroup"));
xml_node Configuration = PropertyGroup.append_child(node_element, _T("Configuration"));
Configuration.append_attribute(_T("Condition"), _T(" '$(Configuration)' == '' "));
Configuration.set_child_value(node_pcdata, _T("Debug"));
xml_node Platform = PropertyGroup.append_child(node_element, _T("Platform"));
Platform.append_attribute(_T("Condition"), _T(" '$(Platform)' == '' "));
Platform.set_child_value(node_pcdata, _T("AnyCPU"));
xml_node ProjectGuid = PropertyGroup.append_child(node_element, _T("ProjectGuid"));
ProjectGuid.set_child_value(node_pcdata, PrjGUIDStr);
xml_node OutputType = PropertyGroup.append_child(node_element, _T("OutputType"));
OutputType.set_child_value(node_pcdata, _T("Library"));
//xml_node ProjectTypeGuids = PropertyGroup.append_child(node_element, _T("ProjectTypeGuids"));
//ProjectTypeGuids.set_child_value(node_pcdata, _T("{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"));
}
{
xml_node PropertyGroup = Project.append_child(node_element, _T("PropertyGroup"));
PropertyGroup.append_attribute(_T("Condition"), _T("'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "));
xml_node DebugType = PropertyGroup.append_child(node_element, _T("DebugType"));
DebugType.set_child_value(node_pcdata, _T("pdbonly"));
xml_node Optimize = PropertyGroup.append_child(node_element, _T("Optimize"));
Optimize.set_child_value(node_pcdata, _T("false"));
xml_node OutputPath = PropertyGroup.append_child(node_element, _T("OutputPath"));
OutputPath.set_child_value(node_pcdata, _T("bin/debug"));
xml_node IntermediateOutputPath = PropertyGroup.append_child(node_element, _T("IntermediateOutputPath"));
IntermediateOutputPath.set_child_value(node_pcdata, _T("bin/debug/obj"));
xml_node WarningLevel = PropertyGroup.append_child(node_element, _T("WarningLevel"));
WarningLevel.set_child_value(node_pcdata, _T("4"));
xml_node DefineConstants = PropertyGroup.append_child(node_element, _T("DefineConstants"));
DefineConstants.set_child_value(node_pcdata, _T("DEBUG;TRACE"));
xml_node AllowUnsafeBlocks = PropertyGroup.append_child(node_element, _T("AllowUnsafeBlocks"));
AllowUnsafeBlocks.set_child_value(node_pcdata, _T("true"));
}
{
xml_node PropertyGroup = Project.append_child(node_element, _T("PropertyGroup"));
PropertyGroup.append_attribute(_T("Condition"), _T("'$(Configuration)|$(Platform)' == 'Release|AnyCPU' "));
xml_node DebugType = PropertyGroup.append_child(node_element, _T("DebugType"));
DebugType.set_child_value(node_pcdata, _T("pdbonly"));
xml_node Optimize = PropertyGroup.append_child(node_element, _T("Optimize"));
Optimize.set_child_value(node_pcdata, _T("false"));
xml_node OutputPath = PropertyGroup.append_child(node_element, _T("OutputPath"));
OutputPath.set_child_value(node_pcdata, _T("bin/release"));
xml_node IntermediateOutputPath = PropertyGroup.append_child(node_element, _T("IntermediateOutputPath"));
IntermediateOutputPath.set_child_value(node_pcdata, _T("bin/release/obj"));
xml_node WarningLevel = PropertyGroup.append_child(node_element, _T("WarningLevel"));
WarningLevel.set_child_value(node_pcdata, _T("4"));
xml_node DefineConstants = PropertyGroup.append_child(node_element, _T("DefineConstants"));
DefineConstants.set_child_value(node_pcdata, _T("TRACE"));
xml_node AllowUnsafeBlocks = PropertyGroup.append_child(node_element, _T("AllowUnsafeBlocks"));
AllowUnsafeBlocks.set_child_value(node_pcdata, _T("true"));
}
{
CEasyArray<CEasyString> FileList;
FetchFiles(CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().LibraryDir), _T(".dll"), FileList);
xml_node ItemGroup = Project.append_child(node_element, _T("ItemGroup"));
//{
// xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
// Reference.append_attribute(_T("Include"), _T("mscorlib"));
//}
//{
// xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
// Reference.append_attribute(_T("Include"), _T("System"));
//}
//{
// xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
// Reference.append_attribute(_T("Include"), _T("System.XML"));
//}
//{
// xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
// Reference.append_attribute(_T("Include"), _T("System.Core"));
//}
//{
// xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
// Reference.append_attribute(_T("Include"), _T("System.Xml.Linq"));
//}
for (UINT i = 0; i < FileList.GetCount(); i++)
{
if (FileList[i].CompareNoCase(szOutFileName) != 0)
{
xml_node Reference = ItemGroup.append_child(node_element, _T("Reference"));
Reference.append_attribute(_T("Include"), (LPCTSTR)CFileTools::GetPathFileName(FileList[i]));
xml_node HintPath = Reference.append_child(node_element, _T("HintPath"));
CEasyString FilePath = CFileTools::GetRelativePath(PrjDir, FileList[i]);
HintPath.set_child_value(node_pcdata, FilePath);
}
}
}
{
CEasyArray<CEasyString> FileList;
for (UINT i = 0; i < SourceDirs.GetCount(); i++)
{
FetchFiles(CFileTools::MakeModuleFullPath(NULL, SourceDirs[i]), _T(".cs"), FileList);
}
xml_node ItemGroup = Project.append_child(node_element, _T("ItemGroup"));
for (UINT i = 0; i < FileList.GetCount(); i++)
{
xml_node Reference = ItemGroup.append_child(node_element, _T("Compile"));
CEasyString FilePath = CFileTools::GetRelativePath(PrjDir, FileList[i]);
Reference.append_attribute(_T("Include"), (LPCTSTR)FilePath);
}
}
{
xml_node Import = Project.append_child(node_element, _T("Import"));
Import.append_attribute(_T("Project"), _T("$(MSBuildToolsPath)\\Microsoft.CSharp.targets"));
}
return Xml.SaveToFile(Doc, PrjFilePath);
}
void CDOSMainThread::PrintMCSMsg(LPTSTR szMsg)
{
LPTSTR szMonoMsg = szMsg;
while (*szMsg)
{
if ((*szMsg) == '\r' || *szMsg == '\n')
{
if (szMsg - szMonoMsg > 1)
{
*szMsg = 0;
LogMono("MCS:%s", szMonoMsg);
}
szMonoMsg = szMsg + 1;
}
szMsg++;
}
if (szMsg - szMonoMsg > 1)
{
LogMono("MCS:%s", szMonoMsg);
}
}
bool CDOSMainThread::CallMCS(CEasyArray<CEasyString>& SourceList, CEasyArray<CEasyString>& LibList, LPCTSTR szOutFileName, bool IsDebug, HANDLE& hMCSProcess)
{
FUNCTION_BEGIN;
CEasyString Sources;
CEasyString Libs;
for (UINT i = 0; i < SourceList.GetCount(); i++)
{
Sources += SourceList[i];
Sources += " ";
}
Sources.Trim();
int LibCount = 0;
for (UINT i = 0; i < LibList.GetCount(); i++)
{
if (LibList[i].CompareNoCase(szOutFileName) != 0)
{
if (LibCount)
Libs += "," + LibList[i];
else
Libs += LibList[i];
LibCount++;
}
}
if (!Libs.IsEmpty())
Libs = "-r:" + Libs;
LPCTSTR szDebugSwitch = "";
if (IsDebug)
szDebugSwitch = "-debug";
CEasyString OutFileName = "-out:";
OutFileName += szOutFileName;
#ifdef WIN32
CEasyString WorkDir = CFileTools::GetModulePath(NULL);
CEasyString Cmd;
CEasyString CompilerPath = CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().CompilerPath);
CEasyString FileExt = CFileTools::GetPathFileExtName(CompilerPath);
if (FileExt.IsEmpty())
{
//没有扩展名,补个.exe
CompilerPath += ".exe";
}
Cmd.Format("%s %s %s %s -nostdlib -target:library %s",
(LPCTSTR)CompilerPath,
(LPCTSTR)Sources, (LPCTSTR)szDebugSwitch, (LPCTSTR)Libs, (LPCTSTR)OutFileName);
LogMono("开始生成:%s", (LPCTSTR)Cmd);
STARTUPINFO StartInfo;
ZeroMemory(&StartInfo, sizeof(STARTUPINFO));
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.dwFlags |= STARTF_USESHOWWINDOW;
StartInfo.dwFlags |= STARTF_USESTDHANDLES;
StartInfo.hStdOutput = m_hMCSOutWrite;
StartInfo.hStdError = m_hMcsErrWrite;
StartInfo.hStdInput = m_hMCSInRead;
StartInfo.wShowWindow = SW_HIDE;
PROCESS_INFORMATION ProcessInfo;
if (!CreateProcess(NULL,
Cmd, // 子进程的命令行
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
WorkDir, // use parent's current directory
&StartInfo, // STARTUPINFO pointer
&ProcessInfo) // receives PROCESS_INFORMATION
)
{
LogMono("运行MCS失败%d", GetLastError());
}
else
{
hMCSProcess = ProcessInfo.hProcess;
CloseHandle(ProcessInfo.hThread);
return true;
}
#else
//恢复对SIGCHLD的屏蔽
signal(SIGCHLD, SIG_DFL);
CEasyString CompilerPath = CFileTools::MakeModuleFullPath(NULL, CDOSConfig::GetInstance()->GetMonoConfig().CompilerPath);
LogMono("开始生成:%s %s %s %s -nostdlib -target:library %s",
(LPCTSTR)CompilerPath, (LPCTSTR)Sources, (LPCTSTR)Libs, (LPCTSTR)szDebugSwitch, (LPCTSTR)OutFileName);
pid_t pid = fork();
if (pid > 0)
{
LogMono("MCS进程pid=%d", pid);
hMCSProcess = (HANDLE)pid;
return true;
}
else if (pid == 0)
{
dup2((int)(ptrdiff_t)m_hMCSOutWrite, STDOUT_FILENO);
dup2((int)(ptrdiff_t)m_hMCSOutWrite, STDERR_FILENO);
execlp((LPCTSTR)CompilerPath, (LPCTSTR)CompilerPath, (LPCTSTR)Sources, (LPCTSTR)Libs, (LPCTSTR)szDebugSwitch, "-nostdlib", "-target:library", (LPCTSTR)OutFileName, NULL);
printf("运行MCS失败%d", errno);
exit(2);
}
else
{
LogMono("新建进程失败%d", errno);
}
#endif
FUNCTION_END;
return false;
}
| [
"sagasarate@sina.com"
] | sagasarate@sina.com |
52a715f327eed58337ccb60b2f310916b6eb4482 | 8bd3d670113de704fea66a844798a0247b518975 | /PointCloudTool/pct_core/src/exception.h | 65fc8ec9520180c209c5f14a98369b26ec8e5ac8 | [] | no_license | dj-boy/PointCloudTool-1 | d7f5a6fddbf4906903123951a1610fba190077f0 | 8e89760f3742bd396dbeb0c7d2e0db2961ccbc9f | refs/heads/master | 2021-01-08T03:17:28.042123 | 2018-12-03T10:02:27 | 2018-12-03T10:02:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 584 | h | #include "common.h"
#include <stdexcept>
namespace pct
{
namespace core
{
class PCT_DLL Exception:public std::runtime_error
{
public:
Exception(char const * in_info) : std::runtime_error(in_info) { }
};
class PCT_DLL DivideByZeroException:public Exception
{
public:
DivideByZeroException(char const * in_info = "Attempted to divide a number by zero.") :
Exception(in_info) {}
};
class PCT_DLL IndexOutofRange :public Exception
{
public:
IndexOutofRange(char const * in_info = "The input index is out of range"):
Exception(in_info){}
};
}
} | [
"wen.c.y@bimtechnologie.com"
] | wen.c.y@bimtechnologie.com |
d64ec04a46671fade109e5a2f08985341928f450 | ce92564b56eba0ad05030264705b9e888dec8746 | /SakuraEngine/StaticBuilds/GraphicsInterface/GraphicsCommon/CGD.h | 2056fc863f639699d0a531fa543d7e87f806d076 | [
"MIT"
] | permissive | hackflame/SakuraEngine | 43af47e31f80f7cddcf0484dd53a50fce2c2f0b2 | 443c5c2dcd25e83bf2e69756530754f41a277a40 | refs/heads/master | 2022-04-16T21:41:15.169069 | 2020-04-17T07:07:41 | 2020-04-17T07:07:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,432 | h | /*
* @CopyRight: MIT License
* Copyright (c) 2020 SaeruHikari
* 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 THESOFTWARE.
*
*
* @Description:
* @Version: 0.1.0
* @Autor: SaeruHikari
* @Date: 2020-02-25 22:25:59
* @LastEditTime: 2020-03-30 00:15:22
*/
#pragma once
#include "Core/CoreMinimal/sinterface.h"
#include "Core/CoreMinimal/SDefination.h"
#include "CommandObjects/CommandContext.h"
#include "SakuraEngine/Core/EngineUtils/log.h"
#include "Flags/CommonFeatures.h"
#include "ResourceObjects/Shader.h"
#include "Flags/ResourceFlags.h"
#include "GraphicsObjects/GraphicsPipeline.h"
#include "GraphicsObjects/RenderPass.h"
#include "GraphicsObjects/RootSignature.h"
namespace Sakura::Graphics
{
sinterface SwapChain;
sinterface ResourceView;
sinterface GpuResource;
sinterface GpuBuffer;
sinterface GpuTexture;
sinterface Fence;
sinterface ComputePipeline;
struct BufferCreateInfo;
struct TextureCreateInfo;
struct ResourceViewCreateInfo;
struct SamplerCreateInfo;
struct ComputePipelineCreateInfo;
}
namespace Sakura::Math
{
struct Matrix4x4;
}
namespace Sakura::Graphics
{
struct CGDInfo
{
bool enableDebugLayer = false;
std::vector<const char*> extentionNames;
PhysicalDeviceFeatures physicalDeviceFeatures;
};
enum TargetGraphicsinterface
{
CGD_TARGET_DIRECT3D12,
CGD_TARGET_VULKAN,
CGD_TARGET_METAL,
CGD_TARGET_NUMS
};
inline static uint32_t CalculateMipLevels(uint32_t texWidth, uint32_t texHeight)
{
auto mipLevels = static_cast<uint32_t>(
std::floor(std::log2(std::max(texWidth, texHeight)))) + 1;
return mipLevels;
}
sinterface CGD
{
virtual ~CGD() = default;
virtual void Initialize(CGDInfo info) = 0;
virtual void InitializeDevice(void* mainSurface) = 0;
virtual [[nodiscard]] SwapChain* CreateSwapChain(
const int width, const int height, void* mainSurface) = 0;
virtual void Present(SwapChain* chain) = 0;
virtual void Destroy() = 0;
virtual std::unique_ptr<Shader> CreateShader(
const char*, std::size_t) = 0;
virtual const char* CompileShader(const char*, std::size_t) = 0;
virtual [[nodiscard]] RenderPass* CreateRenderPass(
const RenderPassCreateInfo& info) const = 0;
virtual [[nodiscard]] GraphicsPipeline* CreateGraphicsPipeline(
const GraphicsPipelineCreateInfo& info,
const RenderPass& progress) const = 0;
virtual [[nodiscard]] ComputePipeline* CreateComputePipeline(
const ComputePipelineCreateInfo& info) const = 0;
// Create & Destroy Command Contexts
virtual CommandContext* CreateContext(
ECommandType type, bool bTransiant = true) const = 0;
virtual CommandContext* AllocateContext(
ECommandType type, bool bTransiant = true) = 0;
virtual void FreeContext(CommandContext* context) = 0;
virtual void FreeAllContexts(ECommandType typeToDestroy) = 0;
virtual [[nodiscard]] ResourceView* ViewIntoResource(
const GpuResource&, const ResourceViewCreateInfo&) const = 0;
virtual [[nodiscard]] ResourceView* ViewIntoTexture(
const GpuTexture&, const Format, const ImageAspectFlags,
uint32 mipLevels = 1, uint32 baseMip = 0,
uint32 layerCount = 1, uint32 baseArrayLayer = 0) const;
virtual CommandQueue* GetGraphicsQueue(void) const = 0;
virtual CommandQueue* GetComputeQueue(void) const = 0;
virtual CommandQueue* GetCopyQueue(void) const = 0;
virtual [[nodiscard]] CommandQueue* AllocQueue(ECommandType type) const = 0;
virtual [[nodiscard]] GpuBuffer* CreateGpuResource(
const BufferCreateInfo&) const = 0;
virtual [[nodiscard]] GpuTexture* CreateGpuResource(
const TextureCreateInfo&) const = 0;
virtual void Wait(Fence* toWait, uint64 until) const = 0;
virtual void WaitIdle() const = 0;
virtual [[nodiscard]] Fence* AllocFence(void) = 0;
virtual [[nodiscard]] RootSignature*
CreateRootSignature(const RootSignatureCreateInfo& sigInfo) const = 0;
virtual const TargetGraphicsinterface GetBackEndAPI(void) const = 0;
virtual [[nodiscard]] Sampler* CreateSampler(
const SamplerCreateInfo&) const = 0;
virtual const Format FindDepthFormat(void) const = 0;
public:
virtual [[nodiscard]] GpuBuffer* CreateUploadBuffer(
const std::size_t bufferSize) const;
virtual [[nodiscard]] GpuTexture* CreateGpuTexture(const Format format,
const uint32 width, const uint32 height,
ImageUsages imageUsages, uint32 mipLevels = 1) const;
virtual [[nodiscard]] GpuBuffer* CreateGpuBuffer(const uint64 size,
BufferUsages bufferUsages, CPUAccessFlags cpuAccess) const;
public:
const uint64 contextNum() const {return contextPools[0].size();}
protected:
std::vector<std::unique_ptr<CommandContext>>
contextPools[ECommandType::CommandContext_Count];
std::queue<CommandContext*>
availableContexts[ECommandType::CommandContext_Count];
std::mutex contextAllocationMutex;
};
} | [
"39457738+misakaXunyan@users.noreply.github.com"
] | 39457738+misakaXunyan@users.noreply.github.com |
9628f8d34205fcfbf388f5225e09d1e17ce5ef33 | c301c81f7560125e130a9eb67f5231b3d08a9d67 | /lc/lc/2021_target/companies/fb/hf/multiply_strings.cpp | 6d4a27219e03f41bc5a6a82bd0d0ed8d788b20d4 | [] | no_license | vikashkumarjha/missionpeace | f55f593b52754c9681e6c32d46337e5e4b2d5f8b | 7d5db52486c55b48fe761e0616d550439584f199 | refs/heads/master | 2021-07-11T07:34:08.789819 | 2021-07-06T04:25:18 | 2021-07-06T04:25:18 | 241,745,271 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 664 | cpp | string multiply(string num1, string num2) {
int m = num1.length();
int n = num2.length();
vector<int> data(m+n, 0);
for ( int i = m - 1; i >= 0; i--) {
for (int j = n -1 ; j >= 0; j--) {
int mul = (num1[i] - '0') * ( num2[j] - '0');
int p1 = i + j; // carry
int p2 = i + j + 1;
int sum = mul + data[p2];
data[p2] = sum % 10;
data[p1] = pos[p1] + ( sum / 10);
}
}
string result;
for (int p : data)
if (!(result.length() == 0 && p == 0))
result = result + to_string(p);
return result.length() == 0 ? "0" : result;
}
| [
"viksrepo@gmail.com"
] | viksrepo@gmail.com |
83237d7a1de668498ede1daadbaeab71614346b8 | dc20532c823df56c109bdd2e03a72603ea95ebf6 | /mts/tp/bpipe/include/blpapi_topiclist.h | 7f0d1b7ceb17b5ab62fed6d076512a85c899a753 | [] | no_license | tt9024/kr | e528055b75303328496e6fc9bb312c9241251f6d | 07a63234c70ae5bb63ac6e7933695970672d56b7 | refs/heads/master | 2023-05-10T22:29:12.020702 | 2023-04-30T23:29:42 | 2023-04-30T23:29:42 | 134,997,404 | 0 | 1 | null | 2022-02-02T18:09:21 | 2018-05-26T21:59:19 | C++ | UTF-8 | C++ | false | false | 11,715 | h | /* Copyright 2012. Bloomberg Finance L.P.
*
* 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.
*/
// blpapi_topiclist.h -*-C++-*-
#ifndef INCLUDED_BLPAPI_TOPICLIST
#define INCLUDED_BLPAPI_TOPICLIST
//@PURPOSE: Provide a representation of a list of topics.
//
//@CLASSES:
// blpapi::TopicList: Represents a list of topics
//
//@DESCRIPTION: This component implements a list of topics which require
// topic creation.
#ifndef INCLUDED_BLPAPI_TYPES
#include <blpapi_types.h>
#endif
#ifndef INCLUDED_BLPAPI_CORRELATIONID
#include <blpapi_correlationid.h>
#endif
#ifndef INCLUDED_BLPAPI_DEFS
#include <blpapi_defs.h>
#endif
#ifndef INCLUDED_BLPAPI_ELEMENT
#include <blpapi_element.h>
#endif
#ifndef INCLUDED_BLPAPI_NAME
#include <blpapi_name.h>
#endif
#ifndef INCLUDED_BLPAPI_MESSAGE
#include <blpapi_message.h>
#endif
#ifndef INCLUDED_BLPAPI_RESOLUTIONLIST
#include <blpapi_resolutionlist.h>
#endif
struct blpapi_TopicList;
typedef struct blpapi_TopicList blpapi_TopicList_t;
#ifdef __cplusplus
extern "C" {
#endif
BLPAPI_EXPORT
blpapi_TopicList_t* blpapi_TopicList_create(
blpapi_TopicList_t* from);
BLPAPI_EXPORT
void blpapi_TopicList_destroy(
blpapi_TopicList_t *list);
BLPAPI_EXPORT
int blpapi_TopicList_add(
blpapi_TopicList_t* list,
const char* topic,
const blpapi_CorrelationId_t *correlationId);
BLPAPI_EXPORT
int blpapi_TopicList_addFromMessage(
blpapi_TopicList_t* list,
const blpapi_Message_t* topic,
const blpapi_CorrelationId_t *correlationId);
BLPAPI_EXPORT
int blpapi_TopicList_correlationIdAt(
const blpapi_TopicList_t* list,
blpapi_CorrelationId_t* result,
size_t index);
BLPAPI_EXPORT
int blpapi_TopicList_topicString(
const blpapi_TopicList_t* list,
const char** topic,
const blpapi_CorrelationId_t* id);
BLPAPI_EXPORT
int blpapi_TopicList_topicStringAt(
const blpapi_TopicList_t* list,
const char** topic,
size_t index);
BLPAPI_EXPORT
int blpapi_TopicList_status(
const blpapi_TopicList_t* list,
int* status,
const blpapi_CorrelationId_t* id);
BLPAPI_EXPORT
int blpapi_TopicList_statusAt(
const blpapi_TopicList_t* list,
int* status,
size_t index);
BLPAPI_EXPORT
int blpapi_TopicList_message(
const blpapi_TopicList_t* list,
blpapi_Message_t** element,
const blpapi_CorrelationId_t* id);
BLPAPI_EXPORT
int blpapi_TopicList_messageAt(
const blpapi_TopicList_t* list,
blpapi_Message_t** element,
size_t index);
BLPAPI_EXPORT
int blpapi_TopicList_size(
const blpapi_TopicList_t* list);
#ifdef __cplusplus
}
#ifndef INCLUDED_BLPAPI_EXCEPTION
#include <blpapi_exception.h>
#endif
namespace BloombergLP {
namespace blpapi {
class ResolutionList;
// ===============
// class TopicList
// ===============
class TopicList {
// Contains a list of topics which require creation.
//
// Created from topic strings or from TOPIC_SUBSCRIBED or
// RESOLUTION_SUCCESS messages.
// This is passed to a createTopics() call or createTopicsAsync()
// call on a ProviderSession. It is updated and returned by the
// createTopics() call.
blpapi_TopicList_t *d_handle_p;
public:
enum Status {
NOT_CREATED = BLPAPI_TOPICLIST_NOT_CREATED,
CREATED = BLPAPI_TOPICLIST_CREATED,
FAILURE = BLPAPI_TOPICLIST_FAILURE
};
// CLASS METHODS
TopicList();
// Create an empty TopicList.
TopicList(const ResolutionList& original);
// Create a topic list from ResolutionList.
// User has previously resolved topics in ResolutionList
// and wants to now createTopics.
TopicList(const TopicList& original);
// Copy constructor.
virtual ~TopicList();
// Destroy this TopicList.
// MANIPULATORS
virtual int add(const char* topic,
const CorrelationId& correlationId=CorrelationId());
// Add the specified 'topic' to this list, optionally
// specifying a 'correlationId'. Returns 0 on success or
// negative number on failure. After a successful call to
// add() the status for this entry is NOT_CREATED.
virtual int add(Message const& message,
const CorrelationId& correlationId=CorrelationId());
// Add the topic contained in the specified
// 'topicSubscribedMessage' or 'resolutionSuccessMessage'
// to this list, optionally specifying a 'correlationId'.
// Returns 0 on success or a negative number on failure.
// After a successful call to add()
// the status for this entry is NOT_CREATED.
// ACCESSORS
virtual CorrelationId correlationIdAt(size_t index) const;
// Returns the CorrelationId of the specified 'index'th entry in
// this TopicList. If 'index' >= size() an exception is
// thrown.
virtual const char* topicString(const CorrelationId& correlationId) const;
// Returns a pointer to the topic of the entry identified by
// the specified 'correlationId'. If the 'correlationId' does
// not identify an entry in this TopicList then an
// exception is thrown.
virtual const char* topicStringAt(size_t index) const;
// Returns a pointer to the topic of the specified 'index'th
// entry. If 'index' >= size() an exception is thrown.
virtual int status(const CorrelationId& correlationId) const;
// Returns the status of the entry in this TopicList
// identified by the specified 'correlationId'. This may be
// NOT_CREATED, CREATED and FAILURE.
// If the 'correlationId' does not identify an entry in this
// TopicList then an exception is thrown.
virtual int statusAt(size_t index) const;
// Returns the status of the specified 'index'th entry in this
// TopicList. This may be NOT_CREATED, CREATED and FAILURE.
// If 'index' > size() an exception is thrown.
virtual Message const message(const CorrelationId& correlationId) const;
// Returns the value of the message received during
// creation of the topic identified by the specified
// 'correlationId'. If 'correlationId' does not identify an
// entry in this TopicList, an exception is thrown.
//
// The message returned can be used when creating an instance
// of Topic.
virtual Message const messageAt(size_t index) const;
// Returns the value of the message received during creation
// of the specified 'index'th entry in this TopicList. If
// 'index' >= size(), an exception is thrown.
//
// The message returned can be used when creating an instance
// of Topic.
virtual size_t size() const;
// Returns the number of entries in this list.
const blpapi_TopicList_t* impl() const;
blpapi_TopicList_t* impl();
};
// ============================================================================
// INLINE FUNCTION DEFINITIONS
// ============================================================================
// ---------------
// class TopicList
// ---------------
inline
TopicList::TopicList()
: d_handle_p(blpapi_TopicList_create(0))
{
}
inline
TopicList::TopicList(
const TopicList& original)
: d_handle_p(blpapi_TopicList_create(original.d_handle_p))
{
}
inline
TopicList::TopicList(
const ResolutionList& original)
: d_handle_p(blpapi_TopicList_create(
reinterpret_cast<blpapi_TopicList_t*>(
const_cast<blpapi_ResolutionList_t*>(original.impl()))))
{
}
inline
TopicList::~TopicList()
{
blpapi_TopicList_destroy(d_handle_p);
}
inline
int TopicList::add(const char* topic,
const CorrelationId& correlationId)
{
return blpapi_TopicList_add(d_handle_p, topic, &correlationId.impl());
}
inline
int TopicList::add(const Message& newMessage,
const CorrelationId& correlationId)
{
return blpapi_TopicList_addFromMessage(d_handle_p,
newMessage.impl(),
&correlationId.impl());
}
inline
CorrelationId TopicList::correlationIdAt(size_t index) const
{
blpapi_CorrelationId_t correlationId;
ExceptionUtil::throwOnError(
blpapi_TopicList_correlationIdAt(d_handle_p, &correlationId, index));
return CorrelationId(correlationId);
}
inline
const char* TopicList::topicString(const CorrelationId& correlationId) const
{
const char* topic;
ExceptionUtil::throwOnError(
blpapi_TopicList_topicString(d_handle_p,
&topic,
&correlationId.impl()));
return topic;
}
inline
const char* TopicList::topicStringAt(size_t index) const
{
const char* topic;
ExceptionUtil::throwOnError(
blpapi_TopicList_topicStringAt(d_handle_p, &topic, index));
return topic;
}
inline
int TopicList::status(const CorrelationId& correlationId) const
{
int result;
ExceptionUtil::throwOnError(
blpapi_TopicList_status(d_handle_p, &result, &correlationId.impl()));
return result;
}
inline
int TopicList::statusAt(size_t index) const
{
int result;
ExceptionUtil::throwOnError(
blpapi_TopicList_statusAt(d_handle_p, &result, index));
return result;
}
inline
Message const TopicList::message(const CorrelationId& correlationId) const
{
blpapi_Message_t* messageByCid;
ExceptionUtil::throwOnError(
blpapi_TopicList_message(d_handle_p,
&messageByCid,
&correlationId.impl()));
BLPAPI_CALL_MESSAGE_ADDREF(messageByCid);
return Message(messageByCid, true);
}
inline
Message const TopicList::messageAt(size_t index) const
{
blpapi_Message_t* messageByIndex;
ExceptionUtil::throwOnError(
blpapi_TopicList_messageAt(d_handle_p, &messageByIndex, index));
BLPAPI_CALL_MESSAGE_ADDREF(messageByIndex);
return Message(messageByIndex, true);
}
inline
size_t TopicList::size() const
{
return static_cast<size_t>(blpapi_TopicList_size(d_handle_p));
}
inline
const blpapi_TopicList_t* TopicList::impl() const
{
return d_handle_p;
}
inline
blpapi_TopicList_t* TopicList::impl()
{
return d_handle_p;
}
} // close namespace blpapi
} // close namespace BloombergLP
#endif // ifdef __cplusplus
#endif // #ifndef INCLUDED_BLPAPI_TOPICLIST
| [
"joy@joy.com"
] | joy@joy.com |
41cc109545cb239c62f78b1d0d82412b3c733b7f | 7434d238644f0e0107ffb00d0807ba611d8f635c | /Stammbaum/mainwindow.cpp | e1bf39f347a1af4adb97988a1a041b48bd7204ef | [] | no_license | JN710/Stammbaum | 52f2e54ee0032b25e2c0c99d1d2dc80160db284b | 5404e8f0a1f7c1915a70ab910fbbec7bee351a64 | refs/heads/master | 2023-08-12T03:48:22.913368 | 2021-10-12T17:50:30 | 2021-10-12T17:50:30 | 339,775,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,077 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
#include <ctype.h>
#include "secdialog.h"
#include <QDebug>
#include <QtWidgets>
#include <QSqlDatabase>
#include <QSqlDriver>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QSql>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Datenbank-Funktionen
datenbankConnect();
datenbankSynchronisieren();
//datenbankInput();
ui->comboBox_bearbeiten->setDisabled(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setName(QString n)
{
name = n;
}
QString MainWindow::getName()
{
return name;
}
/////////////////////// Datenbank ////////////////////////////////////
void MainWindow::datenbankConnect()
{
QString dbName("stammbaumdatenbank.db3");
QFile::remove(dbName);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbName);
if(!db.open())
qWarning() << "ERROR beim oeffnen der Datenbank: " << db.lastError();
// Tabelle erstellen
query = QSqlQuery(db);
if(!query.exec("CREATE TABLE vorfahren (id INTEGER PRIMARY KEY, vorname TEXT, nachname TEXT, geburtsname TEXT, geburtsdatum DATE, geburtsort TEXT, gestorben DATE, begraben TEXT, beruf TEXT, kinder INTEGER, geschlecht TEXT, vater TEXT, mutter TEXT)")){
qWarning() << "ERROR query beim erstellen: " << query.lastError().text();
}
}
void MainWindow::datenbankInput(QString vn, QString nn, QString gn, QString gd, QString go, QString ge, QString be, QString bf, int k, QString g, QString v, QString m)
{
// Daten in die Tabelle eingeben (aktuell noch feste Werte)
query.prepare("INSERT INTO vorfahren (vorname, nachname, geburtsname, geburtsdatum, geburtsort, gestorben, begraben, beruf, kinder, geschlecht, vater, mutter) VALUES(:vorname, :nachname, :geburtsname, :geburtsdatum, :geburtsort, :gestorben, :begraben, :beruf, :kinder, :geschlecht, :vater, :mutter)");
query.bindValue(":vorname", vn);
query.bindValue(":nachname", nn);
query.bindValue(":geburtsname", gn);
query.bindValue(":geburtsdatum", gd);
query.bindValue(":geburtsort", go);
query.bindValue(":gestorben", ge);
query.bindValue(":begraben", be);
query.bindValue(":beruf", bf);
query.bindValue(":kinder", k);
query.bindValue(":geschlecht", g);
query.bindValue(":vater", v);
query.bindValue(":mutter", m);
if(!query.exec()){
qWarning() << "ERROR query beim einfuegen: " << query.lastError().text();
}
}
void MainWindow::datenbankSynchronisieren()
{
// Kommando vorbereiten und ausführen
query.prepare("SELECT * FROM vorfahren");
query.exec();
// Index vom query abfragen
int idVorname = query.record().indexOf("vorname");
int idNachname = query.record().indexOf("nachname");
int idGeburtsname = query.record().indexOf("geburtsname");
// Leeren der gesamten ComboBox
ui->comboBox_bearbeiten->clear();
while(query.next())
{
ui->comboBox_bearbeiten->addItem(query.value(idVorname).toString() + " " + query.value(idNachname).toString() + query.value(idGeburtsname).toString());
}
}
void MainWindow::datenbankUpdate()
{
// Text aktueller Dropdown herauslesen und filtern
QString vname, nname, gname, vn, nn, gn, gebOrt, begraben, beruf, geschlecht;
int anzKinder;
QString text = ui->comboBox_bearbeiten->currentText();
QString t = ui->lineEdit_1_name->text();
int c = 0, d = 0;
// Name trennen und überprüfen aktuelle ComboBox
gname = " ";
for(int i=0; i<text.count(); i++){
if (!(text[i] == ' ') && c == 0){
vname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 1){
nname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 2){
gname[d] = text[i];
d++;
}
else {
c++;
d = 0;
}
}
// Name trennen und überprüfen aktuelle Textfelder
gn = " ";
c = 0;
d = 0;
for(int i=0; i<t.count(); i++){
if (!(t[i] == ' ') && c == 0){
vn[d] = t[i];
d++;
}
else if (!(t[i] == ' ') && c == 1){
nn[d] = t[i];
d++;
}
else if (!(t[i] == ' ') && c == 2){
gn[d] = t[i];
d++;
}
else {
c++;
d = 0;
}
}
gebOrt = ui->lineEdit_3_ort->text();
begraben = ui->lineEdit_5_begraben->text();
beruf = ui->lineEdit_6_beruf->text();
anzKinder = ui->lineEdit_7_kinder->text().toInt();
if(ui->radioButton_maennlich->isChecked())
geschlecht = "m";
else
geschlecht = "w";
//Eltern
QString vater, mutter;
vater = ui->comboBox_vater->currentText();
mutter = ui->comboBox_mutter->currentText();
qDebug() << vater;
qDebug() << mutter;
// Aktualiseren des Datensatzes
query.exec("UPDATE vorfahren SET vorname = '" + vn + "', nachname = '" + nn + "', geburtsname = '" + gn + "', geburtsort = '" + gebOrt + "', begraben = '" + begraben + "', beruf = '" + beruf + "', kinder = 7, geschlecht = '" + geschlecht + "', vater = '" + vater + "', mutter = '" + mutter + "' WHERE vorname = '" + vname + "' AND nachname = '" + nname + "'");
//Aktualisieren des Dropdown-Menüs
datenbankSynchronisieren();
}
void MainWindow::datenbankDelete()
{
query.exec("DELETE FROM vorfahren WHERE id = 2");
}
void MainWindow::datenbankgetOutput()
{
// Text aktueller Dropdown herauslesen und filtern
QString vname, nname, gname;
QString text = ui->comboBox_bearbeiten->currentText();
int c = 0, d = 0;
// Name trennen und überprüfen
gname = " ";
for(int i=0; i<text.count(); i++){
if (!(text[i] == ' ') && c == 0){
vname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 1){
nname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 2){
gname[d] = text[i];
d++;
}
else {
c++;
d = 0;
}
}
// Kommando vorbereiten und ausführen
query.prepare("SELECT * FROM vorfahren WHERE vorname = '" + vname + "' AND nachname = '" +nname + "'");
query.exec();
// Index vom query abfragen
int idVorname = query.record().indexOf("vorname");
int idNachname = query.record().indexOf("nachname");
int idGeburtsname = query.record().indexOf("geburtsname");
int idGeburtsdatum = query.record().indexOf("geburtsdatum");
int idGeburtsort = query.record().indexOf("geburtsort");
int idGestorben = query.record().indexOf("gestorben");
int idBegraben = query.record().indexOf("begraben");
int idBeruf = query.record().indexOf("beruf");
int idKinder = query.record().indexOf("kinder");
int idVater = query.record().indexOf("vater");
int idMutter = query.record().indexOf("mutter");
// query-Index erhöhen
query.next();
// Zuordnen und Ausgabe
ui->lineEdit_1_name->setText("" + query.value(idVorname).toString() + " " + query.value(idNachname).toString() + query.value(idGeburtsname).toString());
ui->dateEdit_2_geb->setDate(query.value(idGeburtsdatum).toDate());
ui->lineEdit_3_ort->setText(query.value(idGeburtsort).toString());
ui->dateEdit_4_gestorben->setDate(query.value(idGestorben).toDate());
ui->lineEdit_5_begraben->setText(query.value(idBegraben).toString());
ui->lineEdit_6_beruf->setText(query.value(idBeruf).toString());
ui->lineEdit_7_kinder->setText(query.value(idKinder).toString());
ui->comboBox_vater->setCurrentText(query.value(idVater).toString());
ui->comboBox_mutter->setCurrentText(query.value(idMutter).toString());
}
/////////////////////// Buttons //////////////////////////////////////
void MainWindow::on_button_accept_clicked()
{
qDebug() << ui->radioButton_neu->isChecked();
// Radiobutton neuer Benutzer
if (ui->radioButton_neu->isChecked()) {
// Combobox zum bearbeiten deaktivieren
ui->comboBox_bearbeiten->setDisabled(true);
// Variablen
bool eingabenKorrekt = true;
int c = 0, d = 0; // für Überprüfung der Namen
QString vorname, nachname, geburtsname, text, geburtsdatum, gestorben, geschlecht;
// Datum überprüfen
geburtsdatum = ui->dateEdit_2_geb->text();
gestorben = ui->dateEdit_4_gestorben->text();
//ui->dateEdit_2_geb->setReadOnly(true);
//ui->dateEdit_4_gestorben->setReadOnly(true);
// Name trennen und überprüfen
text = ui->lineEdit_1_name->text();
geburtsname = " ";
for(int i=0; i<text.count(); i++){
if (!(text[i] == ' ') && c == 0){
vorname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 1){
nachname[d] = text[i];
d++;
}
else if (!(text[i] == ' ') && c == 2){
geburtsname[d] = text[i];
d++;
}
else {
c++;
d = 0;
}
}
//ui->lineEdit_1_name->setReadOnly(true);
setName(ui->lineEdit_1_name->text());
// Geburtsort überprüfen
QString geburtsort = ui->lineEdit_3_ort->text();
for (int i=0; i<geburtsort.count(); i++)
{
if((geburtsort[i] >= 'A' && geburtsort[i] <= 'Z') || (geburtsort[i] >= 'a' && geburtsort[i] <= 'z'))
{
//ui->lineEdit_3_ort->setReadOnly(true);
}
else
{
ui->lineEdit_3_ort->setReadOnly(false);
ui->lineEdit_3_ort->setText("Keine Zahlen oder Sonderzeichen!");
eingabenKorrekt = false;
break;
}
}
// Begraben überprüfen
QString begraben = ui->lineEdit_5_begraben->text();
for (int i=0; i<begraben.count(); i++)
{
if((begraben[i] >= 'A' && begraben[i] <= 'Z') || (begraben[i] >= 'a' && begraben[i] <= 'z'))
{
//ui->lineEdit_5_begraben->setReadOnly(true);
}
else
{
ui->lineEdit_5_begraben->setReadOnly(false);
ui->lineEdit_5_begraben->setText("Keine Zahlen oder Sonderzeichen!");
eingabenKorrekt = false;
break;
}
}
// Beruf übeprüfen
QString beruf = ui->lineEdit_6_beruf->text();
for (int i=0; i<beruf.count(); i++)
{
if((beruf[i] >= 'A' && beruf[i] <= 'Z') || (beruf[i] >= 'a' && beruf[i] <= 'z'))
{
//ui->lineEdit_6_beruf->setReadOnly(true);
}
else
{
ui->lineEdit_6_beruf->setReadOnly(false);
ui->lineEdit_6_beruf->setText("Keine Zahlen oder Sonderzeichen!");
eingabenKorrekt = false;
break;
}
}
// Anzahl Kinder überprüfen
QString anzKinder = ui->lineEdit_7_kinder->text();
for(int i=0; i<anzKinder.count(); i++)
{
if(anzKinder[i] >= '0' && anzKinder[i] <= '9')
{
//ui->lineEdit_7_kinder->setReadOnly(true);
}
else
{
ui->lineEdit_7_kinder->setReadOnly(false);
ui->lineEdit_7_kinder->setText("Dieses Feld darf nur Zahlen enthalten!");
eingabenKorrekt = false;
break;
}
}
// Geschlecht
if(ui->radioButton_maennlich->isChecked()) {
geschlecht = "m";
}
else {
geschlecht = "w";
}
// Vater und Mutter überprüfen
QString vater = ui->comboBox_vater->currentText();
QString mutter = ui->comboBox_mutter->currentText();
if(eingabenKorrekt){
datenbankInput(vorname, nachname, geburtsname, geburtsdatum, geburtsort, gestorben, begraben, beruf, anzKinder.toInt(), geschlecht, vater, mutter);
ui->comboBox_bearbeiten->addItem(vorname + " " + nachname + " " + geburtsname);
if(ui->radioButton_maennlich->isChecked()) {
ui->comboBox_vater->addItem(ui->lineEdit_1_name->text());
}
else {
ui->comboBox_mutter->addItem(ui->lineEdit_1_name->text());
}
clearLineEdit();
}
}
// Radiobutton bearbeiten
if(ui->radioButton_bearbeiten->isChecked()){
datenbankUpdate();
qDebug() << "Radiobutton bearbeiten";
}
}
void MainWindow::on_button_cancel_clicked()
{
//datenbankUpdate();
}
void MainWindow::on_pushButton_clicked()
{
SecDialog secDialog;
secDialog.setModal(true);
secDialog.exec();
}
void MainWindow::on_radioButton_neu_clicked()
{
ui->comboBox_bearbeiten->setDisabled(true);
// LineEdits und DateEdits leeren
clearLineEdit();
ui->button_accept->setText("Bestätigen");
}
void MainWindow::on_radioButton_bearbeiten_clicked()
{
ui->comboBox_bearbeiten->setDisabled(false);
// LineEdits und DateEdits leeren
clearLineEdit();
ui->button_accept->setText("Daten abrufen");
}
void MainWindow::clearLineEdit()
{
ui->lineEdit_1_name->clear();
//ui->dateEdit_2_geb->clear(); //funktioniert noch nicht
ui->lineEdit_3_ort->clear();
//ui->dateEdit_4_gestorben->clear(); //funktioniert noch nicht
ui->lineEdit_5_begraben->clear();
ui->lineEdit_6_beruf->clear();
ui->lineEdit_7_kinder->clear();
}
//Dropdown-Menü beim auswählen
void MainWindow::on_comboBox_bearbeiten_textActivated(const QString &arg1)
{
// Datensätze aus der Datenbank auslesen und in Textbox ausgeben
datenbankgetOutput();
// Buttontext ändern
ui->button_accept->setText("Eingaben speichern");
}
| [
"julian-neumann@gmx.de"
] | julian-neumann@gmx.de |
7b82eafa95cb1ad2492855e2e03537da1d45182c | 5a44b5f9712ae3cead027d735bc5568a6c132679 | /testing/old_openFoam/openfoam2/re_20_mesh_2/4/p | b1034f22dffa3667bf30a19b1b803b5cd9a87088 | [] | no_license | georgenewman10/cfd | d12e86198ac8e8bf7345a0fc20311c0b94bbeda0 | 1d8faa9d852545f16920c2b02273a68af9db19ae | refs/heads/master | 2022-01-06T00:26:14.191816 | 2019-05-23T14:54:09 | 2019-05-23T14:54:09 | 170,887,037 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 81,960 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6.0
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "4";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
8000
(
-0.355106
-0.360028
-0.362831
-0.364395
-0.365246
-0.365474
-0.365174
-0.364439
-0.363345
-0.361956
-0.360322
-0.358488
-0.356493
-0.35437
-0.352148
-0.349858
-0.347519
-0.345096
-0.342578
-0.340538
-0.355944
-0.360793
-0.363539
-0.365054
-0.365858
-0.366042
-0.3657
-0.364926
-0.363796
-0.36237
-0.360702
-0.358836
-0.356809
-0.354656
-0.352406
-0.350088
-0.347724
-0.345276
-0.342733
-0.340686
-0.357615
-0.362319
-0.364951
-0.366367
-0.367078
-0.367174
-0.366749
-0.365896
-0.364691
-0.363195
-0.361459
-0.359527
-0.357437
-0.355222
-0.352914
-0.350542
-0.348126
-0.345628
-0.343033
-0.340975
-0.360116
-0.364601
-0.367063
-0.368331
-0.3689
-0.368864
-0.368314
-0.367344
-0.366027
-0.364424
-0.362584
-0.360553
-0.358367
-0.35606
-0.353663
-0.351207
-0.348713
-0.346138
-0.343465
-0.341391
-0.363441
-0.367635
-0.369869
-0.370938
-0.371318
-0.371105
-0.370389
-0.369261
-0.367795
-0.366048
-0.36407
-0.361904
-0.359588
-0.357156
-0.354638
-0.352068
-0.349467
-0.346786
-0.344008
-0.341916
-0.367584
-0.371412
-0.373361
-0.37418
-0.374324
-0.373888
-0.372964
-0.371639
-0.369984
-0.368057
-0.365904
-0.363569
-0.361088
-0.358495
-0.355821
-0.353104
-0.350365
-0.347547
-0.344634
-0.342523
-0.372539
-0.375926
-0.37753
-0.378047
-0.377906
-0.377202
-0.376027
-0.374466
-0.372585
-0.370439
-0.368076
-0.365534
-0.362851
-0.36006
-0.357195
-0.354293
-0.35138
-0.348388
-0.345307
-0.343179
-0.378299
-0.381167
-0.382365
-0.382527
-0.382051
-0.381036
-0.379568
-0.37773
-0.375586
-0.373185
-0.370573
-0.367788
-0.364864
-0.361836
-0.358737
-0.355609
-0.352481
-0.349273
-0.345985
-0.34384
-0.384859
-0.387125
-0.387853
-0.387607
-0.386747
-0.385374
-0.383573
-0.381421
-0.378975
-0.376285
-0.373388
-0.37032
-0.367116
-0.363806
-0.360428
-0.357028
-0.353635
-0.350159
-0.346615
-0.344452
-0.392211
-0.393788
-0.39398
-0.393271
-0.391978
-0.390204
-0.388029
-0.385525
-0.382745
-0.379729
-0.376512
-0.373125
-0.369598
-0.365962
-0.362254
-0.358525
-0.354808
-0.351
-0.347137
-0.344944
-0.400349
-0.401142
-0.400729
-0.399501
-0.397727
-0.395507
-0.392922
-0.390033
-0.386885
-0.383513
-0.379943
-0.3762
-0.372309
-0.368298
-0.364203
-0.36008
-0.355967
-0.351742
-0.347475
-0.345229
-0.409258
-0.409169
-0.40808
-0.406278
-0.403973
-0.401267
-0.398236
-0.394931
-0.391389
-0.387634
-0.383683
-0.379551
-0.375256
-0.370819
-0.366273
-0.36168
-0.357079
-0.352329
-0.347537
-0.345186
-0.418924
-0.417846
-0.416009
-0.413576
-0.410694
-0.407464
-0.403956
-0.40021
-0.396251
-0.392093
-0.387739
-0.383192
-0.378457
-0.373544
-0.36848
-0.363326
-0.358122
-0.352704
-0.347216
-0.344664
-0.429318
-0.427144
-0.424486
-0.421368
-0.417864
-0.414075
-0.410063
-0.405856
-0.401467
-0.396894
-0.392125
-0.387147
-0.381946
-0.376513
-0.37086
-0.365043
-0.359095
-0.352815
-0.346384
-0.343457
-0.440404
-0.437025
-0.433475
-0.429621
-0.425454
-0.421075
-0.416537
-0.411857
-0.407033
-0.402045
-0.396865
-0.391456
-0.385778
-0.379796
-0.373492
-0.3669
-0.360037
-0.352633
-0.344885
-0.341283
-0.452131
-0.447443
-0.442933
-0.438296
-0.433429
-0.428435
-0.423357
-0.418199
-0.412944
-0.407557
-0.401988
-0.396173
-0.39004
-0.38351
-0.376518
-0.369053
-0.361079
-0.352208
-0.342593
-0.337819
-0.46443
-0.45834
-0.452811
-0.44735
-0.441753
-0.436123
-0.430497
-0.424865
-0.419198
-0.413445
-0.407536
-0.401378
-0.394861
-0.387849
-0.380206
-0.37184
-0.362621
-0.351945
-0.339738
-0.332954
-0.477221
-0.469651
-0.463054
-0.456735
-0.450384
-0.444104
-0.437928
-0.431835
-0.425787
-0.419721
-0.413552
-0.407162
-0.400401
-0.39307
-0.384934
-0.375783
-0.36534
-0.352568
-0.336522
-0.325587
-0.490406
-0.4813
-0.4736
-0.4664
-0.459279
-0.452341
-0.445618
-0.439084
-0.432696
-0.426391
-0.420076
-0.413623
-0.406849
-0.399486
-0.391165
-0.38147
-0.369757
-0.35385
-0.330333
-0.309593
-0.503881
-0.493207
-0.484385
-0.47629
-0.46839
-0.460793
-0.453531
-0.446579
-0.439901
-0.433446
-0.427144
-0.420892
-0.414537
-0.407826
-0.400369
-0.391607
-0.380373
-0.362815
-0.332405
-0.301615
-0.517532
-0.505288
-0.49534
-0.486349
-0.477669
-0.469415
-0.461621
-0.454267
-0.447334
-0.4408
-0.434649
-0.428869
-0.423462
-0.418458
-0.413971
-0.410282
-0.407691
-0.406319
-0.409896
-0.434148
-0.531251
-0.517458
-0.506399
-0.496521
-0.487068
-0.47816
-0.469835
-0.462077
-0.454881
-0.448251
-0.442211
-0.436811
-0.432142
-0.428364
-0.425759
-0.424762
-0.425815
-0.429736
-0.441118
-0.467871
-0.54493
-0.529634
-0.517494
-0.506749
-0.496538
-0.486984
-0.478126
-0.469951
-0.46246
-0.455672
-0.449632
-0.444416
-0.440146
-0.437007
-0.43528
-0.435327
-0.43745
-0.442262
-0.452978
-0.47268
-0.558471
-0.541735
-0.528557
-0.516978
-0.506032
-0.495844
-0.486454
-0.477845
-0.470017
-0.462997
-0.456831
-0.4516
-0.44742
-0.444458
-0.442938
-0.443109
-0.44512
-0.449362
-0.458066
-0.471884
-0.571783
-0.553681
-0.53952
-0.527148
-0.515497
-0.504694
-0.494774
-0.485712
-0.477505
-0.470171
-0.463752
-0.45831
-0.45394
-0.450759
-0.44892
-0.448552
-0.449671
-0.452508
-0.458748
-0.467818
-0.584777
-0.565393
-0.550309
-0.537192
-0.524873
-0.513477
-0.503031
-0.493499
-0.484866
-0.477139
-0.470341
-0.464512
-0.45971
-0.456003
-0.453468
-0.452144
-0.451951
-0.453038
-0.45676
-0.46183
-0.597366
-0.576784
-0.560845
-0.547034
-0.534088
-0.522122
-0.511154
-0.501132
-0.492027
-0.483827
-0.476536
-0.470165
-0.464734
-0.460267
-0.456783
-0.454254
-0.452552
-0.451789
-0.453094
-0.454745
-0.609458
-0.587763
-0.571037
-0.556588
-0.543055
-0.530543
-0.519054
-0.508521
-0.498895
-0.490147
-0.482257
-0.475211
-0.468996
-0.463598
-0.458997
-0.455123
-0.451831
-0.449222
-0.448247
-0.446946
-0.62095
-0.598226
-0.580783
-0.565751
-0.551672
-0.538634
-0.526624
-0.515555
-0.505361
-0.495994
-0.487412
-0.479578
-0.472457
-0.466008
-0.460185
-0.454899
-0.450007
-0.445611
-0.442507
-0.438648
-0.631725
-0.608056
-0.589967
-0.574408
-0.55982
-0.546275
-0.53374
-0.52211
-0.511301
-0.501247
-0.491892
-0.483182
-0.475064
-0.467483
-0.460381
-0.453666
-0.447207
-0.441112
-0.43604
-0.42997
-0.641652
-0.617126
-0.59846
-0.582427
-0.567367
-0.553329
-0.540264
-0.528046
-0.516576
-0.505777
-0.49558
-0.485923
-0.476745
-0.467986
-0.459585
-0.451457
-0.443495
-0.435808
-0.428933
-0.420967
-0.650583
-0.625289
-0.606119
-0.589665
-0.574167
-0.55965
-0.546045
-0.533211
-0.521039
-0.509444
-0.498352
-0.487696
-0.477418
-0.46746
-0.457769
-0.448272
-0.438888
-0.429729
-0.421218
-0.41164
-0.658354
-0.632391
-0.61279
-0.595967
-0.580062
-0.565076
-0.550923
-0.537449
-0.524539
-0.512105
-0.500075
-0.488388
-0.476992
-0.465838
-0.454886
-0.444083
-0.433373
-0.422865
-0.412886
-0.401958
-0.66479
-0.638262
-0.618308
-0.601168
-0.584886
-0.56944
-0.55473
-0.540594
-0.526915
-0.51361
-0.500616
-0.487881
-0.475367
-0.46304
-0.450876
-0.438842
-0.426911
-0.415182
-0.4039
-0.391858
-0.669703
-0.642725
-0.622498
-0.605093
-0.588465
-0.57257
-0.557296
-0.542479
-0.528008
-0.513812
-0.499839
-0.486056
-0.47244
-0.458979
-0.445666
-0.432489
-0.419446
-0.406627
-0.3942
-0.381258
-0.6729
-0.645597
-0.625181
-0.607565
-0.590622
-0.574288
-0.558446
-0.542936
-0.52766
-0.512561
-0.49761
-0.482793
-0.468109
-0.453567
-0.439178
-0.424955
-0.410914
-0.397132
-0.383715
-0.370068
-0.674182
-0.646691
-0.626174
-0.608401
-0.591175
-0.574416
-0.558006
-0.541799
-0.525712
-0.509714
-0.493798
-0.477976
-0.462271
-0.446713
-0.431334
-0.416166
-0.401244
-0.386626
-0.372365
-0.358188
-0.673353
-0.645819
-0.625295
-0.607421
-0.589946
-0.572778
-0.555808
-0.538905
-0.522014
-0.505131
-0.488278
-0.471494
-0.454828
-0.438331
-0.422055
-0.40605
-0.390365
-0.375037
-0.360072
-0.345521
-0.670218
-0.642797
-0.622361
-0.604447
-0.58676
-0.569204
-0.551686
-0.5341
-0.516423
-0.498682
-0.480933
-0.463244
-0.445689
-0.428341
-0.411269
-0.394539
-0.37821
-0.362294
-0.346758
-0.331977
-0.664594
-0.637448
-0.6172
-0.599305
-0.581447
-0.563531
-0.545486
-0.527239
-0.508804
-0.490247
-0.471657
-0.453133
-0.434773
-0.416672
-0.398911
-0.381571
-0.364716
-0.348333
-0.332353
-0.317471
-0.656308
-0.629605
-0.609648
-0.591836
-0.57385
-0.555607
-0.537064
-0.51819
-0.499041
-0.479723
-0.46036
-0.441082
-0.422013
-0.403262
-0.384926
-0.367093
-0.349832
-0.3331
-0.316797
-0.301931
-0.645194
-0.619107
-0.599546
-0.581883
-0.56382
-0.54529
-0.52629
-0.506835
-0.487027
-0.467016
-0.446963
-0.427026
-0.407352
-0.388065
-0.369271
-0.351066
-0.333519
-0.316554
-0.300042
-0.285299
-0.631112
-0.605818
-0.586759
-0.569314
-0.551228
-0.53246
-0.513053
-0.493074
-0.472677
-0.452056
-0.431407
-0.410917
-0.390751
-0.371048
-0.351918
-0.333463
-0.315747
-0.298663
-0.282053
-0.267529
-0.613942
-0.589618
-0.571167
-0.554012
-0.535962
-0.517014
-0.497261
-0.47683
-0.455927
-0.43479
-0.413652
-0.392724
-0.37219
-0.352194
-0.332855
-0.314271
-0.296505
-0.279414
-0.262809
-0.248593
-0.593587
-0.570409
-0.552672
-0.53588
-0.517933
-0.498871
-0.478845
-0.458046
-0.436733
-0.415188
-0.393679
-0.372439
-0.351663
-0.331506
-0.312084
-0.293495
-0.275796
-0.258805
-0.242304
-0.228474
-0.569978
-0.548116
-0.5312
-0.514847
-0.497075
-0.477974
-0.45776
-0.436688
-0.415074
-0.393242
-0.371489
-0.350069
-0.329189
-0.309003
-0.289627
-0.271156
-0.253637
-0.236853
-0.220551
-0.207176
-0.543071
-0.522693
-0.506701
-0.490867
-0.473349
-0.454294
-0.433988
-0.412752
-0.390957
-0.368967
-0.347108
-0.325648
-0.304802
-0.284723
-0.265523
-0.247291
-0.230065
-0.213591
-0.197576
-0.184714
-0.512854
-0.494122
-0.479155
-0.463922
-0.446742
-0.427827
-0.407535
-0.386255
-0.364411
-0.342404
-0.320582
-0.299228
-0.278558
-0.258724
-0.239829
-0.221956
-0.205132
-0.189068
-0.173423
-0.161125
-0.479348
-0.462415
-0.448573
-0.434023
-0.417272
-0.3986
-0.378439
-0.357245
-0.335492
-0.313615
-0.291982
-0.270883
-0.250535
-0.231083
-0.212622
-0.195226
-0.178912
-0.163353
-0.148156
-0.13646
-0.442605
-0.427616
-0.414994
-0.401213
-0.384987
-0.366669
-0.346765
-0.325795
-0.304282
-0.282689
-0.2614
-0.240709
-0.220829
-0.201898
-0.183998
-0.167194
-0.151495
-0.136535
-0.121859
-0.110792
-0.402712
-0.389801
-0.378492
-0.365566
-0.349966
-0.332119
-0.312604
-0.292005
-0.270886
-0.249737
-0.22895
-0.208821
-0.189557
-0.171284
-0.154073
-0.137976
-0.122994
-0.108725
-0.0946389
-0.0842154
-0.359788
-0.34908
-0.339171
-0.327188
-0.312317
-0.295064
-0.276076
-0.255999
-0.235434
-0.214889
-0.194765
-0.175353
-0.156851
-0.139375
-0.122979
-0.107705
-0.0935421
-0.080056
-0.0666279
-0.0568524
-0.313987
-0.305595
-0.297168
-0.286215
-0.27218
-0.255646
-0.237328
-0.217927
-0.198075
-0.178297
-0.158994
-0.140454
-0.122863
-0.106321
-0.090868
-0.0765332
-0.0632966
-0.0506903
-0.0379913
-0.0288592
-0.265498
-0.259521
-0.252653
-0.242815
-0.229723
-0.214035
-0.19653
-0.177958
-0.158979
-0.140127
-0.121804
-0.104287
-0.087751
-0.0722823
-0.0579045
-0.0446318
-0.0324362
-0.0208186
-0.00893315
-0.00043461
-0.214541
-0.211066
-0.205827
-0.197185
-0.185142
-0.170426
-0.153875
-0.136282
-0.118329
-0.100558
-0.0833651
-0.0670196
-0.0516828
-0.037427
-0.0242605
-0.0121838
-0.00116156
0.00933237
0.0202888
0.0281591
-0.161369
-0.160466
-0.156918
-0.149552
-0.138659
-0.125037
-0.109575
-0.0931038
-0.0763238
-0.0597775
-0.0438565
-0.0288205
-0.0148197
-0.00191487
0.0098978
0.0206293
0.0303177
0.0395068
0.0493575
0.0565739
-0.106264
-0.10799
-0.106186
-0.100167
-0.0905218
-0.0781081
-0.0638618
-0.0486454
-0.0331699
-0.0179777
-0.00345406
0.0101501
0.0226922
0.0341179
0.0444363
0.0536641
0.0618342
0.0694852
0.0779475
0.084381
-0.0495383
-0.053931
-0.0539145
-0.0493093
-0.0409999
-0.029901
-0.0169858
-0.00314117
0.0109152
0.0246446
0.0376689
0.0497434
0.0607287
0.0705672
0.0792613
0.0868238
0.0932719
0.0990633
0.105564
0.110745
0.00847275
0.00139192
-0.000411709
0.00272302
0.00961619
0.0193053
0.0307878
0.04316
0.055704
0.0678882
0.0793426
0.089827
0.0991977
0.107379
0.11434
0.120063
0.124495
0.127746
0.130739
0.133169
0.0674085
0.057638
0.0539933
0.0556097
0.0610168
0.069213
0.0791757
0.0899934
0.100955
0.111542
0.121398
0.130292
0.13808
0.144663
0.149971
0.153942
0.156358
0.156462
0.153921
0.151747
0.126887
0.114446
0.108952
0.109013
0.112875
0.119507
0.127877
0.137073
0.1464
0.155361
0.163623
0.170982
0.177318
0.182565
0.186705
0.189812
0.191785
0.191292
0.187362
0.193027
0.186537
0.171456
0.164114
0.162589
0.164857
0.169865
0.176578
0.184095
0.19174
0.199045
0.205705
0.211545
0.216479
0.220484
0.223604
0.226002
0.227704
0.227795
0.226277
0.234297
0.245954
0.228286
0.219108
0.21598
0.216616
0.219951
0.224956
0.230744
0.236665
0.242278
0.247308
0.251605
0.255109
0.257821
0.259808
0.261238
0.262145
0.261797
0.260442
0.267513
0.304739
0.284551
0.273563
0.268826
0.267804
0.269429
0.272685
0.276706
0.280867
0.284757
0.288128
0.29085
0.292883
0.294241
0.295
0.295317
0.295214
0.294046
0.29208
0.297508
0.362494
0.339869
0.327107
0.320765
0.318074
0.317967
0.31945
0.321677
0.324054
0.326199
0.327886
0.329006
0.32953
0.329479
0.328931
0.328028
0.326777
0.324602
0.32179
0.325551
0.418827
0.393862
0.379374
0.371445
0.367086
0.365241
0.36494
0.365364
0.365949
0.366341
0.366335
0.365839
0.364832
0.363342
0.361441
0.359255
0.356783
0.353511
0.349755
0.351869
0.473357
0.446159
0.430003
0.420517
0.414508
0.410937
0.40886
0.407489
0.406292
0.404939
0.40325
0.401144
0.398609
0.395675
0.39241
0.388927
0.385216
0.38083
0.376102
0.376597
0.525713
0.4964
0.478646
0.467645
0.460019
0.45475
0.450926
0.447789
0.444838
0.441771
0.438427
0.434739
0.430701
0.426344
0.421735
0.416971
0.412042
0.406563
0.400872
0.399796
0.57554
0.54424
0.524966
0.512507
0.503314
0.496393
0.490868
0.486013
0.481358
0.476628
0.471679
0.466456
0.460961
0.455226
0.449314
0.443311
0.437209
0.43068
0.424056
0.42147
0.622502
0.589349
0.568643
0.554795
0.5441
0.535594
0.528434
0.521929
0.515639
0.509315
0.50283
0.49614
0.489253
0.482202
0.475047
0.467866
0.460651
0.453131
0.445617
0.441595
0.666279
0.631416
0.609377
0.59422
0.582105
0.572095
0.563386
0.555318
0.547481
0.53965
0.531715
0.523642
0.515444
0.507157
0.498836
0.49055
0.482295
0.473853
0.465503
0.460131
0.706575
0.670152
0.646885
0.630513
0.617073
0.60566
0.595504
0.585977
0.576698
0.567465
0.558182
0.548825
0.539413
0.52998
0.52058
0.511275
0.502064
0.492775
0.48365
0.477027
0.743117
0.70529
0.680909
0.663427
0.648772
0.63607
0.624585
0.61372
0.60312
0.592603
0.582089
0.571561
0.56104
0.550565
0.540184
0.529954
0.519877
0.509823
0.499993
0.492227
0.775657
0.736587
0.711214
0.692737
0.676989
0.663127
0.650447
0.638378
0.626593
0.614924
0.603306
0.59173
0.58022
0.568814
0.557558
0.546503
0.535657
0.524925
0.514466
0.505676
0.803972
0.763827
0.73759
0.718242
0.701536
0.686655
0.672926
0.659802
0.646977
0.634301
0.621719
0.609227
0.596853
0.584635
0.572618
0.560846
0.549332
0.538011
0.527003
0.517318
0.827871
0.786821
0.759856
0.739768
0.722249
0.706502
0.69188
0.677861
0.664153
0.650624
0.637224
0.623957
0.610853
0.597949
0.585289
0.572913
0.560836
0.54902
0.537548
0.527104
0.84719
0.805412
0.777857
0.757169
0.738988
0.722537
0.707191
0.692443
0.67802
0.663797
0.649735
0.635841
0.622145
0.608687
0.595507
0.582643
0.570112
0.557897
0.546049
0.534989
0.861796
0.81947
0.791468
0.770326
0.751642
0.734657
0.71876
0.703459
0.688493
0.673745
0.659181
0.644812
0.630669
0.616792
0.603219
0.589985
0.577112
0.564596
0.552464
0.540936
0.871591
0.828896
0.800596
0.779148
0.760126
0.742781
0.726514
0.710842
0.695511
0.68041
0.665509
0.650821
0.636378
0.622219
0.608383
0.594902
0.581799
0.569082
0.556759
0.544917
0.876506
0.833627
0.805177
0.783575
0.764383
0.746858
0.730404
0.714546
0.699031
0.683753
0.668683
0.653835
0.639241
0.624941
0.610973
0.597368
0.58415
0.571332
0.558913
0.546913
0.876508
0.83363
0.805179
0.783577
0.764386
0.74686
0.730406
0.714548
0.699033
0.683755
0.668685
0.653836
0.639242
0.624943
0.610974
0.597369
0.584151
0.571333
0.558914
0.546914
0.871597
0.828903
0.800603
0.779154
0.760132
0.742787
0.726519
0.710847
0.695516
0.680415
0.665514
0.650825
0.636382
0.622223
0.608387
0.594905
0.581802
0.569085
0.556762
0.54492
0.861807
0.81948
0.791479
0.770336
0.751652
0.734666
0.718769
0.703468
0.688501
0.673753
0.659188
0.644818
0.630675
0.616798
0.603225
0.589991
0.577117
0.564601
0.552469
0.540941
0.847205
0.805427
0.777872
0.757184
0.739002
0.72255
0.707203
0.692455
0.678031
0.663808
0.649745
0.63585
0.622154
0.608696
0.595516
0.58265
0.570119
0.557904
0.546056
0.534995
0.82789
0.78684
0.759875
0.739787
0.722266
0.706519
0.691896
0.677876
0.664168
0.650637
0.637237
0.62397
0.610865
0.597961
0.5853
0.572923
0.560846
0.54903
0.537557
0.527112
0.803995
0.763849
0.737613
0.718264
0.701558
0.686676
0.672945
0.659821
0.646995
0.634318
0.621735
0.609242
0.596868
0.584649
0.572631
0.560859
0.549344
0.538022
0.527014
0.517328
0.775683
0.736613
0.71124
0.692762
0.677014
0.663151
0.65047
0.6384
0.626614
0.614944
0.603326
0.591749
0.580237
0.56883
0.557573
0.546518
0.535671
0.524938
0.514478
0.505688
0.743147
0.70532
0.680938
0.663456
0.648801
0.636097
0.624611
0.613745
0.603145
0.592626
0.582111
0.571582
0.56106
0.550584
0.540202
0.52997
0.519893
0.509838
0.500008
0.492241
0.706609
0.670185
0.646918
0.630546
0.617105
0.605691
0.595534
0.586005
0.576726
0.567491
0.558207
0.548849
0.539435
0.530001
0.5206
0.511294
0.502082
0.492792
0.483666
0.477042
0.666316
0.631453
0.609413
0.594256
0.58214
0.572129
0.563419
0.55535
0.547512
0.539679
0.531743
0.523669
0.51547
0.507181
0.498858
0.490571
0.482316
0.473872
0.465521
0.460148
0.622543
0.589389
0.568683
0.554834
0.544138
0.535631
0.528471
0.521964
0.515673
0.509347
0.50286
0.496169
0.48928
0.482229
0.475072
0.46789
0.460673
0.453152
0.445637
0.441614
0.575585
0.544284
0.525009
0.512549
0.503355
0.496434
0.490908
0.486052
0.481395
0.476663
0.471713
0.466488
0.460991
0.455255
0.449341
0.443337
0.437233
0.430703
0.424078
0.421491
0.525761
0.496448
0.478693
0.467691
0.460064
0.454794
0.450968
0.44783
0.444877
0.44181
0.438464
0.434773
0.430733
0.426375
0.421764
0.416999
0.412069
0.406588
0.400896
0.399819
0.473409
0.44621
0.430054
0.420566
0.414556
0.410983
0.408905
0.407533
0.406334
0.40498
0.403289
0.401181
0.398644
0.395708
0.392442
0.388957
0.385245
0.380858
0.376127
0.376622
0.418883
0.393917
0.379428
0.371497
0.367137
0.365291
0.364988
0.365411
0.365994
0.366384
0.366376
0.365878
0.36487
0.363378
0.361475
0.359288
0.356814
0.353541
0.349783
0.351895
0.362553
0.339927
0.327164
0.320821
0.318128
0.31802
0.319501
0.321726
0.324102
0.326245
0.32793
0.329048
0.32957
0.329518
0.328968
0.328062
0.32681
0.324633
0.32182
0.325579
0.304801
0.284612
0.273622
0.268884
0.26786
0.269484
0.272739
0.276758
0.280917
0.284806
0.288174
0.290895
0.292926
0.294282
0.295039
0.295354
0.295249
0.29408
0.292112
0.297538
0.246018
0.228349
0.21917
0.216041
0.216676
0.220008
0.225012
0.230798
0.236717
0.242328
0.247357
0.251652
0.255155
0.257864
0.259849
0.261277
0.262182
0.261833
0.260476
0.267544
0.186603
0.171522
0.164178
0.162653
0.164919
0.169925
0.176637
0.184152
0.191795
0.199098
0.205756
0.211594
0.216527
0.22053
0.223648
0.226043
0.227744
0.227833
0.226313
0.23433
0.126956
0.114514
0.109019
0.109078
0.112939
0.11957
0.127938
0.137133
0.146457
0.155416
0.163677
0.171034
0.177368
0.182613
0.186751
0.189856
0.191827
0.191332
0.1874
0.193063
0.067479
0.0577076
0.0540621
0.0556775
0.0610835
0.0692781
0.0792392
0.090055
0.101014
0.1116
0.121454
0.130346
0.138132
0.144713
0.150019
0.153988
0.156402
0.156504
0.153961
0.151785
0.00854525
0.00146349
-0.000340926
0.00279293
0.00968497
0.0193726
0.0308534
0.0432238
0.0557659
0.067948
0.0794004
0.0898828
0.0992515
0.107431
0.11439
0.120111
0.124542
0.127791
0.130781
0.133209
-0.0494639
-0.0538576
-0.0538419
-0.0492375
-0.0409292
-0.0298316
-0.0169181
-0.0030753
0.0109791
0.0247065
0.0377288
0.0498013
0.0607846
0.0706213
0.0793135
0.0868742
0.0933205
0.09911
0.105608
0.110788
-0.106188
-0.107915
-0.106112
-0.100094
-0.0904493
-0.078037
-0.0637922
-0.0485775
-0.0331039
-0.0179138
-0.00339214
0.01021
0.0227501
0.0341739
0.0444905
0.0537164
0.0618847
0.0695338
0.0779941
0.084426
-0.161291
-0.160389
-0.156842
-0.149477
-0.138585
-0.124964
-0.109503
-0.0930341
-0.0762559
-0.0597116
-0.0437926
-0.0287587
-0.0147599
-0.00185703
0.00995377
0.0206835
0.0303699
0.0395572
0.049406
0.0566206
-0.214462
-0.210987
-0.205749
-0.197108
-0.185066
-0.170351
-0.153802
-0.13621
-0.11826
-0.10049
-0.0832994
-0.0669559
-0.0516212
-0.0373674
-0.0242029
-0.0121281
-0.00110773
0.00938428
0.0203387
0.0282074
-0.265417
-0.259441
-0.252574
-0.242737
-0.229646
-0.213959
-0.196456
-0.177885
-0.158908
-0.140058
-0.121736
-0.104221
-0.0876878
-0.0722211
-0.0578453
-0.0445746
-0.0323809
-0.0207652
-0.00888181
-0.000384986
-0.313905
-0.305514
-0.297088
-0.286136
-0.272102
-0.255569
-0.237252
-0.217852
-0.198002
-0.178226
-0.158925
-0.140387
-0.122798
-0.106258
-0.0908073
-0.0764746
-0.06324
-0.0506357
-0.0379387
-0.0288084
-0.359704
-0.348998
-0.339089
-0.327107
-0.312237
-0.294985
-0.275999
-0.255923
-0.235359
-0.214816
-0.194694
-0.175284
-0.156785
-0.139311
-0.122917
-0.107645
-0.0934842
-0.0800001
-0.066574
-0.0568004
-0.402627
-0.389718
-0.378409
-0.365485
-0.349885
-0.332039
-0.312525
-0.291927
-0.27081
-0.249663
-0.228878
-0.208751
-0.189489
-0.171218
-0.154009
-0.137915
-0.122935
-0.108668
-0.0945839
-0.0841622
-0.44252
-0.427531
-0.414911
-0.401131
-0.384905
-0.366588
-0.346684
-0.325716
-0.304204
-0.282614
-0.261327
-0.240638
-0.22076
-0.201831
-0.183934
-0.167132
-0.151435
-0.136477
-0.121803
-0.110738
-0.479262
-0.46233
-0.448489
-0.43394
-0.417189
-0.398518
-0.378358
-0.357165
-0.335413
-0.313538
-0.291907
-0.270811
-0.250465
-0.231015
-0.212556
-0.195162
-0.178851
-0.163294
-0.148099
-0.136405
-0.512768
-0.494037
-0.479071
-0.463838
-0.446658
-0.427744
-0.407453
-0.386174
-0.364331
-0.342326
-0.320506
-0.299155
-0.278487
-0.258655
-0.239762
-0.221891
-0.20507
-0.189007
-0.173365
-0.161069
-0.542984
-0.522608
-0.506616
-0.490783
-0.473265
-0.45421
-0.433904
-0.412669
-0.390876
-0.368888
-0.347031
-0.325574
-0.304729
-0.284653
-0.265455
-0.247225
-0.230001
-0.213529
-0.197517
-0.184658
-0.569892
-0.548031
-0.531115
-0.514763
-0.496991
-0.47789
-0.457677
-0.436605
-0.414992
-0.393162
-0.371411
-0.349994
-0.329115
-0.308932
-0.289558
-0.271089
-0.253573
-0.236791
-0.220491
-0.207118
-0.593502
-0.570324
-0.552588
-0.535796
-0.517849
-0.498786
-0.478761
-0.457962
-0.43665
-0.415108
-0.3936
-0.372362
-0.351589
-0.331434
-0.312014
-0.293428
-0.275731
-0.258742
-0.242244
-0.228416
-0.613856
-0.589533
-0.571083
-0.553927
-0.535878
-0.516929
-0.497177
-0.476747
-0.455845
-0.434709
-0.413573
-0.392647
-0.372114
-0.352122
-0.332784
-0.314203
-0.29644
-0.27935
-0.262748
-0.248534
-0.631026
-0.605734
-0.586675
-0.56923
-0.551143
-0.532376
-0.512969
-0.492991
-0.472595
-0.451974
-0.431327
-0.410839
-0.390675
-0.370974
-0.351847
-0.333394
-0.315681
-0.2986
-0.281992
-0.267471
-0.645109
-0.619023
-0.599462
-0.5818
-0.563736
-0.545206
-0.526207
-0.506752
-0.486945
-0.466935
-0.446883
-0.426948
-0.407275
-0.387991
-0.3692
-0.350997
-0.333452
-0.31649
-0.299981
-0.28524
-0.656224
-0.629522
-0.609565
-0.591753
-0.573767
-0.555524
-0.536981
-0.518108
-0.498959
-0.479642
-0.46028
-0.441004
-0.421936
-0.403188
-0.384854
-0.367024
-0.349766
-0.333036
-0.316735
-0.301872
-0.664511
-0.637366
-0.617118
-0.599223
-0.581364
-0.563449
-0.545404
-0.527158
-0.508723
-0.490167
-0.471578
-0.453054
-0.434697
-0.416597
-0.398839
-0.381501
-0.364649
-0.348268
-0.332291
-0.317412
-0.670137
-0.642716
-0.62228
-0.604365
-0.586678
-0.569123
-0.551605
-0.534019
-0.516342
-0.498602
-0.480853
-0.463165
-0.445612
-0.428267
-0.411197
-0.39447
-0.378143
-0.362229
-0.346696
-0.331917
-0.673272
-0.645739
-0.625215
-0.607341
-0.589866
-0.572698
-0.555728
-0.538825
-0.521934
-0.505051
-0.488199
-0.471416
-0.454751
-0.438257
-0.421983
-0.405981
-0.390298
-0.374973
-0.36001
-0.345462
-0.674103
-0.646613
-0.626095
-0.608322
-0.591096
-0.574336
-0.557927
-0.54172
-0.525633
-0.509635
-0.49372
-0.477899
-0.462195
-0.446639
-0.431262
-0.416097
-0.401177
-0.386562
-0.372303
-0.358128
-0.672822
-0.64552
-0.625104
-0.607487
-0.590544
-0.574209
-0.558368
-0.542858
-0.527582
-0.512483
-0.497533
-0.482716
-0.468034
-0.453493
-0.439107
-0.424886
-0.410848
-0.397068
-0.383653
-0.370008
-0.669627
-0.642649
-0.622422
-0.605016
-0.588388
-0.572493
-0.557219
-0.542402
-0.527931
-0.513735
-0.499763
-0.48598
-0.472366
-0.458907
-0.445595
-0.432421
-0.41938
-0.406563
-0.394138
-0.381199
-0.664716
-0.638188
-0.618233
-0.601093
-0.58481
-0.569365
-0.554654
-0.540518
-0.526839
-0.513534
-0.50054
-0.487807
-0.475293
-0.462968
-0.450806
-0.438774
-0.426845
-0.415119
-0.403839
-0.391799
-0.658282
-0.632318
-0.612717
-0.595894
-0.579988
-0.565001
-0.550848
-0.537374
-0.524464
-0.51203
-0.500001
-0.488315
-0.476919
-0.465768
-0.454817
-0.444016
-0.433308
-0.422802
-0.412826
-0.4019
-0.650511
-0.625218
-0.606048
-0.589593
-0.574094
-0.559576
-0.545972
-0.533138
-0.520966
-0.509371
-0.498279
-0.487625
-0.477347
-0.467391
-0.457701
-0.448206
-0.438824
-0.429667
-0.421159
-0.411583
-0.641582
-0.617056
-0.59839
-0.582356
-0.567295
-0.553258
-0.540192
-0.527974
-0.516504
-0.505706
-0.49551
-0.485853
-0.476676
-0.467918
-0.459518
-0.451392
-0.443431
-0.435747
-0.428875
-0.42091
-0.631657
-0.607988
-0.589898
-0.574338
-0.55975
-0.546205
-0.53367
-0.52204
-0.511231
-0.501178
-0.491823
-0.483114
-0.474996
-0.467417
-0.460316
-0.453602
-0.447145
-0.441052
-0.435983
-0.429915
-0.620883
-0.598159
-0.580715
-0.565684
-0.551604
-0.538565
-0.526556
-0.515488
-0.505294
-0.495927
-0.487345
-0.479512
-0.472392
-0.465944
-0.460121
-0.454837
-0.449946
-0.445552
-0.442451
-0.438593
-0.609392
-0.587697
-0.570971
-0.556522
-0.542989
-0.530476
-0.518988
-0.508455
-0.49883
-0.490083
-0.482193
-0.475147
-0.468932
-0.463535
-0.458935
-0.455063
-0.451772
-0.449165
-0.448192
-0.446892
-0.597302
-0.57672
-0.560781
-0.54697
-0.534023
-0.522058
-0.51109
-0.501069
-0.491964
-0.483765
-0.476474
-0.470103
-0.464673
-0.460206
-0.456723
-0.454196
-0.452495
-0.451733
-0.45304
-0.454692
-0.584714
-0.56533
-0.550246
-0.537128
-0.52481
-0.513414
-0.502969
-0.493438
-0.484806
-0.477079
-0.470281
-0.464453
-0.459651
-0.455944
-0.45341
-0.452087
-0.451895
-0.452984
-0.456708
-0.461779
-0.57172
-0.553619
-0.539458
-0.527086
-0.515436
-0.504633
-0.494714
-0.485654
-0.477447
-0.470114
-0.463695
-0.458254
-0.453883
-0.450703
-0.448864
-0.448497
-0.449617
-0.452455
-0.458697
-0.467768
-0.55841
-0.541674
-0.528496
-0.516918
-0.505973
-0.495785
-0.486396
-0.477788
-0.469962
-0.462942
-0.456776
-0.451545
-0.447366
-0.444403
-0.442884
-0.443056
-0.445069
-0.449311
-0.458016
-0.471835
-0.54487
-0.529574
-0.517435
-0.506691
-0.496481
-0.486927
-0.478071
-0.469897
-0.462407
-0.45562
-0.44958
-0.444364
-0.440094
-0.436955
-0.435228
-0.435277
-0.4374
-0.442213
-0.45293
-0.472632
-0.531192
-0.517399
-0.506342
-0.496464
-0.487013
-0.478105
-0.469781
-0.462025
-0.45483
-0.448201
-0.442162
-0.436761
-0.432092
-0.428314
-0.42571
-0.424713
-0.425768
-0.429689
-0.441073
-0.467826
-0.517474
-0.505231
-0.495284
-0.486294
-0.477616
-0.469362
-0.46157
-0.454218
-0.447285
-0.440752
-0.434602
-0.428822
-0.423415
-0.418411
-0.413924
-0.410236
-0.407645
-0.406275
-0.409854
-0.434106
-0.503824
-0.493152
-0.48433
-0.476236
-0.468338
-0.460742
-0.453482
-0.446531
-0.439854
-0.4334
-0.427099
-0.420847
-0.414492
-0.407782
-0.400325
-0.391563
-0.38033
-0.362772
-0.332364
-0.301574
-0.490351
-0.481246
-0.473547
-0.466348
-0.459229
-0.452293
-0.445571
-0.439038
-0.432652
-0.426347
-0.420033
-0.413581
-0.406806
-0.399443
-0.391123
-0.381428
-0.369716
-0.35381
-0.330293
-0.309553
-0.477167
-0.469599
-0.463003
-0.456685
-0.450336
-0.444058
-0.437882
-0.431791
-0.425744
-0.41968
-0.413511
-0.407122
-0.400361
-0.39303
-0.384895
-0.375744
-0.365301
-0.35253
-0.336485
-0.32555
-0.464378
-0.45829
-0.452762
-0.447302
-0.441707
-0.436078
-0.430453
-0.424824
-0.419158
-0.413406
-0.407497
-0.40134
-0.394823
-0.387812
-0.380169
-0.371804
-0.362585
-0.351909
-0.339703
-0.332919
-0.45208
-0.447394
-0.442885
-0.43825
-0.433385
-0.428392
-0.423316
-0.41816
-0.412906
-0.40752
-0.401952
-0.396138
-0.390005
-0.383475
-0.376483
-0.369018
-0.361044
-0.352174
-0.342561
-0.337786
-0.440356
-0.436978
-0.433429
-0.429577
-0.425411
-0.421034
-0.416498
-0.41182
-0.406997
-0.40201
-0.396831
-0.391422
-0.385745
-0.379763
-0.373459
-0.366868
-0.360005
-0.352602
-0.344855
-0.341252
-0.429272
-0.427099
-0.424442
-0.421326
-0.417824
-0.414037
-0.410026
-0.405821
-0.401433
-0.396861
-0.392093
-0.387116
-0.381915
-0.376482
-0.37083
-0.365013
-0.359065
-0.352785
-0.346355
-0.343429
-0.418879
-0.417803
-0.415968
-0.413537
-0.410656
-0.407428
-0.403921
-0.400177
-0.39622
-0.392062
-0.387709
-0.383162
-0.378428
-0.373515
-0.368451
-0.363298
-0.358094
-0.352676
-0.347189
-0.344637
-0.409216
-0.409128
-0.408042
-0.406241
-0.403937
-0.401234
-0.398204
-0.394901
-0.39136
-0.387605
-0.383655
-0.379524
-0.375229
-0.370792
-0.366247
-0.361654
-0.357053
-0.352304
-0.347512
-0.345161
-0.400309
-0.401104
-0.400693
-0.399467
-0.397694
-0.395476
-0.392892
-0.390004
-0.386858
-0.383486
-0.379917
-0.376175
-0.372284
-0.368273
-0.364178
-0.360056
-0.355943
-0.351719
-0.347452
-0.345205
-0.392174
-0.393753
-0.393946
-0.393239
-0.391948
-0.390175
-0.388002
-0.385499
-0.38272
-0.379705
-0.376488
-0.373102
-0.369575
-0.365939
-0.362231
-0.358503
-0.354786
-0.350978
-0.347116
-0.344923
-0.384825
-0.387093
-0.387822
-0.387578
-0.38672
-0.385348
-0.383549
-0.381397
-0.378953
-0.376263
-0.373366
-0.370299
-0.367095
-0.363786
-0.360408
-0.357008
-0.353615
-0.350139
-0.346596
-0.344432
-0.378268
-0.381138
-0.382337
-0.382501
-0.382027
-0.381012
-0.379546
-0.377709
-0.375565
-0.373166
-0.370554
-0.367769
-0.364846
-0.361817
-0.358718
-0.355591
-0.352463
-0.349255
-0.345967
-0.343822
-0.372511
-0.375901
-0.377506
-0.378024
-0.377884
-0.377182
-0.376008
-0.374447
-0.372567
-0.370422
-0.368059
-0.365517
-0.362835
-0.360044
-0.357178
-0.354277
-0.351364
-0.348372
-0.345292
-0.343163
-0.36756
-0.37139
-0.373341
-0.37416
-0.374305
-0.37387
-0.372947
-0.371623
-0.369969
-0.368042
-0.36589
-0.363554
-0.361074
-0.358481
-0.355808
-0.35309
-0.350351
-0.347533
-0.344621
-0.34251
-0.363421
-0.367616
-0.369852
-0.370922
-0.371303
-0.37109
-0.370375
-0.369248
-0.367782
-0.366035
-0.364058
-0.361892
-0.359577
-0.357144
-0.354626
-0.352056
-0.349456
-0.346775
-0.343997
-0.341905
-0.360101
-0.364587
-0.36705
-0.368318
-0.368888
-0.368852
-0.368303
-0.367333
-0.366017
-0.364414
-0.362575
-0.360543
-0.358357
-0.356051
-0.353653
-0.351198
-0.348704
-0.346129
-0.343457
-0.341382
-0.357604
-0.362309
-0.364941
-0.366358
-0.367069
-0.367165
-0.366741
-0.365889
-0.364684
-0.363188
-0.361452
-0.35952
-0.35743
-0.355216
-0.352907
-0.350535
-0.34812
-0.345622
-0.343027
-0.340968
-0.355937
-0.360787
-0.363533
-0.365049
-0.365853
-0.366037
-0.365695
-0.364921
-0.363791
-0.362366
-0.360698
-0.358832
-0.356805
-0.354652
-0.352402
-0.350084
-0.34772
-0.345272
-0.342729
-0.340682
-0.355104
-0.360026
-0.362829
-0.364393
-0.365244
-0.365473
-0.365172
-0.364437
-0.363344
-0.361954
-0.36032
-0.358487
-0.356492
-0.354369
-0.352147
-0.349857
-0.347518
-0.345095
-0.342577
-0.340536
-0.328614
-0.156729
-0.0923312
-0.00792633
0.00548424
0.0201334
0.0160543
0.0140597
0.00982369
0.0072337
0.00499384
0.00354833
0.00247406
0.00174892
0.00121536
0.000853566
0.000566455
0.000395483
0.000187524
0.000141467
-0.329177
-0.157172
-0.0926799
-0.00818361
0.00535986
0.0200476
0.0160198
0.0140374
0.00981439
0.00722801
0.00499119
0.00354674
0.00247301
0.00174812
0.00121504
0.000853284
0.000566148
0.000395394
0.000187646
0.000141241
-0.330288
-0.158047
-0.0933703
-0.00869592
0.00511182
0.0198759
0.0159504
0.0139927
0.00979561
0.00721631
0.00498567
0.00354328
0.00247084
0.00174656
0.00121424
0.000852714
0.000565686
0.000395086
0.000187681
0.000140912
-0.33192
-0.159339
-0.0943928
-0.00945999
0.00474198
0.0196194
0.0158465
0.0139263
0.00976764
0.00719883
0.00497738
0.00353802
0.00246765
0.00174434
0.00121296
0.000851854
0.000565105
0.000394544
0.000187584
0.000140515
-0.334037
-0.161027
-0.0957321
-0.0104706
0.00425273
0.0192791
0.0157083
0.0138379
0.00973036
0.00717555
0.00496628
0.00353094
0.00246344
0.00174144
0.00121119
0.000850675
0.000564362
0.000393803
0.0001874
0.000140016
-0.33659
-0.163087
-0.0973694
-0.0117212
0.00364728
0.0188567
0.015536
0.013728
0.00968385
0.00714661
0.0049524
0.00352211
0.00245824
0.00173787
0.00120895
0.00084916
0.00056342
0.000392904
0.000187175
0.000139384
-0.339524
-0.165489
-0.0992822
-0.0132035
0.00292937
0.018354
0.0153298
0.0135968
0.0096281
0.00711205
0.00493574
0.00351153
0.00245205
0.00173362
0.00120625
0.000847308
0.00056228
0.00039185
0.000186909
0.00013862
-0.342778
-0.168206
-0.101445
-0.0149084
0.00210329
0.0177734
0.0150903
0.0134448
0.00956314
0.00707193
0.00491631
0.00349921
0.00244487
0.0017287
0.00120308
0.000845124
0.000560941
0.00039064
0.000186603
0.000137728
-0.346285
-0.17121
-0.103832
-0.0168251
0.00117373
0.0171174
0.0148178
0.0132724
0.009489
0.00702634
0.00489413
0.00348518
0.0024367
0.0017231
0.00119947
0.000842611
0.0005594
0.000389272
0.000186259
0.000136707
-0.349972
-0.174476
-0.106413
-0.0189422
0.000145663
0.0163889
0.0145127
0.0130802
0.00940572
0.00697535
0.00486921
0.00346946
0.00242755
0.00171685
0.0011954
0.000839773
0.000557657
0.000387749
0.000185879
0.000135561
-0.35376
-0.177982
-0.109161
-0.0212472
-0.000975657
0.0155911
0.0141756
0.0128687
0.00931336
0.00691907
0.00484156
0.00345205
0.00241741
0.00170993
0.0011909
0.000836613
0.000555711
0.00038607
0.000185461
0.000134293
-0.35756
-0.181713
-0.112049
-0.0237267
-0.00218487
0.0147275
0.0138071
0.0126385
0.009212
0.00685759
0.00481121
0.003433
0.00240629
0.00170236
0.00118596
0.000833134
0.00055356
0.000384237
0.000185009
0.000132903
-0.361267
-0.185657
-0.115052
-0.0263681
-0.00347716
0.0138014
0.0134078
0.0123902
0.00910171
0.00679101
0.00477816
0.00341232
0.00239419
0.00169414
0.00118058
0.00082934
0.000551204
0.00038225
0.000184522
0.000131395
-0.364748
-0.189811
-0.118153
-0.0291604
-0.00484889
0.0128159
0.0129781
0.0121243
0.0089825
0.00671942
0.00474244
0.00339003
0.00238112
0.00168528
0.00117479
0.000825235
0.000548642
0.00038011
0.000184
0.000129772
-0.36781
-0.194158
-0.121326
-0.0320878
-0.00629387
0.011775
0.0125186
0.0118416
0.00885447
0.00664292
0.00470404
0.00336615
0.00236709
0.00167578
0.00116857
0.000820821
0.000545873
0.000377817
0.000183445
0.000128035
-0.37022
-0.198629
-0.124512
-0.0351087
-0.00779285
0.0106899
0.0120334
0.0115442
0.0087185
0.00656198
0.00466315
0.00334076
0.0023521
0.00166565
0.00116193
0.000816093
0.000542893
0.000375365
0.000182857
0.000126184
-0.371842
-0.203208
-0.127696
-0.0381888
-0.00933135
0.00957392
0.0115284
0.0112358
0.00857598
0.00647731
0.00462004
0.00331401
0.00233624
0.00165493
0.00115488
0.000811063
0.0005397
0.000372767
0.00018222
0.000124234
-0.372444
-0.208316
-0.131196
-0.0415105
-0.0110087
0.00838344
0.0109833
0.0109073
0.00842246
0.00638692
0.00457386
0.00328566
0.00231949
0.0016437
0.00114751
0.00080582
0.000536331
0.000370087
0.000181516
0.000122229
-0.370081
-0.214365
-0.135439
-0.0454681
-0.0130337
0.00698191
0.0103288
0.0105212
0.00824046
0.00628244
0.00452115
0.00325433
0.00230145
0.00163191
0.0011399
0.000800455
0.000532893
0.000367349
0.000180844
0.000120119
-0.360151
-0.218105
-0.138395
-0.0490047
-0.0148477
0.00557458
0.0096441
0.0101046
0.00804251
0.00616842
0.00446312
0.00321923
0.00228093
0.0016183
0.00113118
0.000794142
0.000529101
0.000363916
0.000180513
0.00011741
-0.314773
-0.217052
-0.139315
-0.0549137
-0.016876
0.00327722
0.00883059
0.00959789
0.0079093
0.00607909
0.00442217
0.00317409
0.00224422
0.00158407
0.00110519
0.000771376
0.000515482
0.000348745
0.000180798
0.000105193
-0.276036
-0.204499
-0.131743
-0.0586475
-0.0212387
-0.00190962
0.0051199
0.00690445
0.00620508
0.00497553
0.00373863
0.00273737
0.00196658
0.00140244
0.000986688
0.000691905
0.000465121
0.000314043
0.000166219
9.02462e-05
-0.245194
-0.183966
-0.119574
-0.0591523
-0.0248173
-0.00635484
0.00159096
0.00430916
0.00448303
0.00384736
0.00301664
0.00226875
0.00166118
0.00120001
0.000852297
0.00060145
0.000406569
0.00027486
0.000146907
7.72162e-05
-0.211166
-0.160489
-0.10603
-0.0576116
-0.0272415
-0.00984832
-0.00142887
0.00200368
0.00288868
0.00277214
0.00230479
0.00179424
0.00134394
0.000985691
0.000707662
0.000502952
0.000342058
0.000231579
0.000124884
6.43274e-05
-0.177881
-0.137849
-0.0932434
-0.0549001
-0.0286726
-0.0125688
-0.00403174
-9.27254e-05
0.00136964
0.00171327
0.00158289
0.00130293
0.00100981
0.000757287
0.000551996
0.000396359
0.000271671
0.000184581
0.00010033
5.11234e-05
-0.147697
-0.117692
-0.0819641
-0.0516517
-0.0293326
-0.0146447
-0.00624253
-0.00197389
-5.53691e-05
0.000687296
0.000864431
0.000804352
0.000665427
0.000519259
0.000388304
0.000283704
0.000196749
0.000134748
7.37665e-05
3.75686e-05
-0.121843
-0.100362
-0.0722609
-0.0482519
-0.0294123
-0.0161721
-0.00807444
-0.00362292
-0.0013593
-0.000282396
0.000167344
0.000310969
0.00031928
0.000277241
0.000220341
0.000167447
0.00011893
8.30465e-05
4.58528e-05
2.37377e-05
-0.100241
-0.0856733
-0.063953
-0.0449068
-0.0290737
-0.0172465
-0.00956251
-0.0050447
-0.00253197
-0.00118283
-0.000496567
-0.000168072
-2.19013e-05
3.59839e-05
5.14146e-05
4.98348e-05
3.97478e-05
3.04113e-05
1.71987e-05
9.76559e-06
-0.0824677
-0.0732997
-0.056834
-0.0417267
-0.0284516
-0.0179586
-0.0107514
-0.00625537
-0.0035728
-0.00200719
-0.00111923
-0.000625681
-0.000352508
-0.000200344
-0.000115463
-6.70263e-05
-3.9342e-05
-2.22345e-05
-1.16268e-05
-4.16555e-06
-0.0679319
-0.062911
-0.0507229
-0.0387682
-0.0276521
-0.0183879
-0.0116853
-0.00727444
-0.00448551
-0.00275195
-0.00169479
-0.00105612
-0.000667711
-0.000427995
-0.000277503
-0.000181143
-0.000116946
-7.39862e-05
-4.00826e-05
-1.78483e-05
-0.0560945
-0.0542146
-0.0454767
-0.0360604
-0.0267575
-0.0186024
-0.0124056
-0.00812248
-0.00527658
-0.00341617
-0.00221933
-0.00145491
-0.000963457
-0.000643675
-0.000432181
-0.000290664
-0.000191755
-0.000123977
-6.76587e-05
-3.10687e-05
-0.0464809
-0.0469623
-0.0409839
-0.0336178
-0.025831
-0.0186598
-0.0129501
-0.00882015
-0.00595425
-0.00400091
-0.00269055
-0.00181868
-0.00123643
-0.00084455
-0.00057725
-0.000393908
-0.00026256
-0.000171392
-9.38814e-05
-4.36177e-05
-0.0387061
-0.0409481
-0.0371583
-0.0314473
-0.0249213
-0.0186084
-0.0133527
-0.00938719
-0.00652759
-0.00450852
-0.00310738
-0.00214504
-0.00148398
-0.00102823
-0.000710748
-0.000489365
-0.000328266
-0.000215483
-0.000118317
-5.52973e-05
-0.0324575
-0.0360027
-0.0339323
-0.0295517
-0.0240654
-0.0184882
-0.013643
-0.00984186
-0.00700575
-0.00494216
-0.00346962
-0.00243232
-0.00170402
-0.00119271
-0.000830985
-0.000575708
-0.000387892
-0.00025557
-0.000140577
-6.59247e-05
-0.0274889
-0.0319887
-0.0312529
-0.0279313
-0.0232912
-0.0183319
-0.0138466
-0.0102005
-0.00739748
-0.00530532
-0.00377769
-0.00267942
-0.00189493
-0.00133636
-0.000936529
-0.000651785
-0.000440583
-0.000291054
-0.000160317
-7.5334e-05
-0.0236066
-0.0287961
-0.0290782
-0.026585
-0.0226198
-0.0181656
-0.0139848
-0.0104774
-0.0077108
-0.00560153
-0.00403237
-0.00288572
-0.0020555
-0.00145787
-0.0010262
-0.000716626
-0.000485605
-0.000321417
-0.000177239
-8.3378e-05
-0.0206624
-0.0263384
-0.0273755
-0.0255112
-0.0220667
-0.0180097
-0.014075
-0.0106844
-0.00795266
-0.00583407
-0.00423458
-0.00305087
-0.00218484
-0.00155622
-0.00109903
-0.000769432
-0.00052235
-0.000346228
-0.000191091
-8.99282e-05
-0.0185447
-0.0245499
-0.0261201
-0.0247081
-0.0216429
-0.0178799
-0.014131
-0.0108312
-0.00812882
-0.00600578
-0.00438526
-0.00317473
-0.00228232
-0.00163061
-0.00115428
-0.000809578
-0.000550334
-0.000365144
-0.000201673
-9.48658e-05
-0.0171746
-0.023382
-0.025294
-0.0241744
-0.0213563
-0.0177873
-0.0141628
-0.010925
-0.0082437
-0.00611893
-0.00448521
-0.00325728
-0.00234751
-0.0016805
-0.00119141
-0.000836589
-0.000569206
-0.00037788
-0.000208894
-9.80482e-05
-0.0165015
-0.0228025
-0.0248846
-0.0239094
-0.0212125
-0.0177399
-0.0141776
-0.010971
-0.00830043
-0.00617507
-0.00453498
-0.00329848
-0.00238012
-0.00170547
-0.00121005
-0.000850104
-0.000578752
-0.000384156
-0.000212785
-9.9348e-05
-0.260889
-0.272169
-0.28279
-0.292853
-0.302485
-0.31184
-0.321103
-0.330486
-0.340236
-0.350624
-0.361943
-0.374498
-0.388598
-0.404544
-0.422617
-0.44299
-0.465693
-0.49176
-0.524236
-0.551319
-0.176963
-0.18694
-0.196641
-0.206059
-0.215187
-0.224018
-0.232544
-0.240761
-0.248677
-0.256311
-0.263709
-0.270949
-0.278152
-0.2855
-0.293243
-0.30167
-0.311102
-0.322559
-0.33855
-0.353537
-0.133242
-0.140696
-0.148017
-0.155224
-0.16234
-0.169388
-0.176392
-0.183377
-0.190363
-0.197372
-0.204418
-0.211513
-0.218662
-0.225868
-0.233134
-0.240449
-0.247795
-0.255436
-0.264252
-0.271693
-0.0946394
-0.100427
-0.106116
-0.111707
-0.117202
-0.122603
-0.127915
-0.133143
-0.138296
-0.143386
-0.148426
-0.153437
-0.158439
-0.163459
-0.168526
-0.173661
-0.178878
-0.184312
-0.190345
-0.195699
-0.0721005
-0.0767436
-0.0813226
-0.0858395
-0.0902958
-0.0946929
-0.0990317
-0.103313
-0.107538
-0.111705
-0.115815
-0.119867
-0.123862
-0.1278
-0.131684
-0.135515
-0.139294
-0.143074
-0.146987
-0.150504
-0.052869
-0.0565996
-0.0602852
-0.0639261
-0.0675227
-0.071075
-0.0745839
-0.07805
-0.0814741
-0.084857
-0.0881997
-0.0915031
-0.0947681
-0.0979955
-0.101186
-0.104339
-0.107453
-0.110546
-0.113656
-0.116574
-0.0400519
-0.0431556
-0.0462249
-0.0492592
-0.0522588
-0.0552228
-0.0581513
-0.0610439
-0.0639002
-0.06672
-0.0695027
-0.0722483
-0.0749562
-0.0776265
-0.0802589
-0.0828531
-0.0854093
-0.0879321
-0.090429
-0.0928537
-0.0295688
-0.0321676
-0.0347409
-0.0372881
-0.0398094
-0.0423042
-0.0447725
-0.047214
-0.0496286
-0.052016
-0.0543759
-0.0567082
-0.0590126
-0.061289
-0.063537
-0.0657565
-0.0679472
-0.0701079
-0.0722384
-0.0743634
-0.0219142
-0.0241367
-0.0263382
-0.0285182
-0.0306766
-0.0328122
-0.0349251
-0.0370146
-0.0390805
-0.0411224
-0.0431398
-0.0451327
-0.0471007
-0.0490437
-0.0509617
-0.0528546
-0.0547225
-0.056562
-0.0583713
-0.0602077
-0.0157523
-0.0176713
-0.0195733
-0.0214575
-0.023324
-0.0251717
-0.0270004
-0.0288097
-0.0305992
-0.0323683
-0.0341168
-0.0358444
-0.0375507
-0.0392355
-0.0408987
-0.0425402
-0.0441597
-0.045753
-0.047319
-0.0489238
-0.0110165
-0.0126973
-0.0143634
-0.016014
-0.0176489
-0.0192671
-0.0208684
-0.0224521
-0.0240179
-0.0255653
-0.0270939
-0.0286033
-0.0300933
-0.0315635
-0.0330136
-0.0344439
-0.0358538
-0.0372392
-0.0385996
-0.0399989
-0.00721844
-0.00870574
-0.0101803
-0.0116414
-0.0130888
-0.0145213
-0.0159387
-0.0173405
-0.0187261
-0.0200952
-0.0214473
-0.022782
-0.0240989
-0.0253976
-0.026678
-0.0279399
-0.0291828
-0.0304032
-0.031601
-0.0328318
-0.00423311
-0.00556532
-0.00688609
-0.00819465
-0.00949076
-0.0107733
-0.012042
-0.0132964
-0.0145359
-0.0157601
-0.0169684
-0.0181606
-0.019336
-0.0204946
-0.0216358
-0.0227597
-0.0238658
-0.024951
-0.026016
-0.0271052
-0.00185394
-0.00306052
-0.00425679
-0.00544193
-0.00661574
-0.00777709
-0.00892574
-0.0100612
-0.0111829
-0.0122903
-0.013383
-0.0144605
-0.0155225
-0.0165686
-0.0175985
-0.0186121
-0.0196089
-0.0205867
-0.0215462
-0.0225208
1.1372e-05
-0.0010945
-0.00219092
-0.00327719
-0.00435305
-0.00541734
-0.00646979
-0.00750987
-0.00853706
-0.00955084
-0.0105508
-0.0115364
-0.0125075
-0.0134636
-0.0144044
-0.0153299
-0.0162394
-0.0171315
-0.0180068
-0.0188887
0.00146126
0.000435049
-0.000582372
-0.00159025
-0.00258838
-0.00357571
-0.00455198
-0.00551665
-0.00646921
-0.00740916
-0.0083361
-0.00924962
-0.0101494
-0.0110351
-0.0119063
-0.012763
-0.0136047
-0.0144302
-0.0152404
-0.0160499
0.00255442
0.00158965
0.000633122
-0.000314443
-0.00125286
-0.00218107
-0.00309884
-0.00400567
-0.00490107
-0.00578458
-0.00665579
-0.00751432
-0.00835983
-0.00919199
-0.0100105
-0.0108151
-0.0116054
-0.0123809
-0.013142
-0.0138968
0.00333802
0.00241896
0.00150774
0.00060507
-0.000288904
-0.00117323
-0.00204769
-0.00291185
-0.00376523
-0.00460743
-0.00543803
-0.00625666
-0.00706298
-0.00785667
-0.00863742
-0.00940498
-0.010159
-0.0108992
-0.0116261
-0.0123426
0.00384647
0.00295762
0.00207626
0.0012031
0.000338242
-0.000517396
-0.00136365
-0.00220009
-0.00302628
-0.00384182
-0.0046463
-0.00543938
-0.00622071
-0.00698998
-0.00774688
-0.00849116
-0.00922252
-0.00994083
-0.0106466
-0.0113395
0.00409368
0.00322402
0.00236157
0.00150693
0.000660119
-0.000177988
-0.00100729
-0.00182743
-0.00263801
-0.00343867
-0.00422907
-0.0050089
-0.00577784
-0.0065356
-0.00728192
-0.00801649
-0.00873903
-0.00944946
-0.0101482
-0.0108335
0.133623
0.111141
0.0847058
0.0597124
0.0353005
0.0109774
-0.012957
-0.0362432
-0.0587842
-0.0805289
-0.101431
-0.121453
-0.140572
-0.158775
-0.176054
-0.192411
-0.207852
-0.222392
-0.236054
-0.248871
0.0971055
0.0786823
0.0589246
0.0417734
0.0258652
0.0102674
-0.00497817
-0.0197294
-0.0339898
-0.0478092
-0.0612224
-0.0742519
-0.0869177
-0.0992388
-0.111232
-0.122912
-0.134292
-0.14538
-0.156184
-0.166711
0.0638796
0.0496527
0.036245
0.0246191
0.0135854
0.00266714
-0.00806383
-0.0185217
-0.0287076
-0.0386445
-0.0483437
-0.057809
-0.0670431
-0.0760497
-0.0848331
-0.0933987
-0.101753
-0.109903
-0.11786
-0.125635
0.0474076
0.037424
0.0285249
0.0206405
0.0129684
0.00531741
-0.0022309
-0.00962865
-0.016881
-0.0240009
-0.0309947
-0.0378652
-0.0446153
-0.0512484
-0.0577677
-0.0641763
-0.0704769
-0.0766718
-0.0827628
-0.0887516
0.0381182
0.0305574
0.0240341
0.0181218
0.0122612
0.00639054
0.000585789
-0.00512476
-0.0107467
-0.0162866
-0.021746
-0.0271251
-0.0324245
-0.0376453
-0.0427886
-0.0478557
-0.0528479
-0.0577668
-0.062614
-0.0673912
0.0328635
0.0270599
0.0221862
0.0177049
0.0132144
0.00870772
0.00424725
-0.000151569
-0.00449546
-0.00878932
-0.0130341
-0.0172298
-0.0213771
-0.0254765
-0.0295286
-0.0335338
-0.0374926
-0.0414053
-0.0452721
-0.0490933
0.029591
0.0250022
0.0211974
0.0176464
0.0140547
0.0104386
0.00684898
0.00329604
-0.00022534
-0.00371764
-0.00718032
-0.0106124
-0.0140134
-0.0173828
-0.0207202
-0.0240253
-0.0272975
-0.0305366
-0.0337421
-0.0369141
0.0276484
0.0239666
0.0209183
0.0180401
0.0151156
0.0121677
0.00923667
0.00632947
0.0034422
0.000573401
-0.00227614
-0.00510544
-0.00791386
-0.0107009
-0.013466
-0.0162086
-0.0189283
-0.0216246
-0.024297
-0.0269453
0.0263397
0.0233199
0.0208014
0.0183995
0.0159534
0.0134856
0.0110273
0.0085835
0.00615151
0.00373061
0.00132177
-0.00107391
-0.00345555
-0.0058224
-0.00817371
-0.0105087
-0.0128267
-0.015127
-0.0174087
-0.0196715
0.0254503
0.022941
0.0208187
0.0187778
0.0166993
0.0146024
0.0125106
0.0104281
0.00835277
0.00628449
0.00422419
0.00217291
0.000131523
-0.0018992
-0.00391848
-0.00592554
-0.00791964
-0.00990008
-0.0118661
-0.0138171
0.0247742
0.022656
0.0208306
0.0190625
0.0172638
0.0154496
0.0136377
0.0118311
0.0100287
0.00823062
0.00643767
0.00465089
0.00287115
0.00109927
-0.000663943
-0.00241767
-0.00416109
-0.00589347
-0.00761392
-0.00932196
0.0242447
0.0224345
0.0208406
0.0192867
0.0177089
0.0161185
0.0145286
0.0129416
0.0113569
0.00977483
0.00819616
0.00662184
0.00505273
0.0034896
0.00193327
0.000384513
-0.00115587
-0.00268715
-0.00420844
-0.00571924
0.0238018
0.0222333
0.0208204
0.019435
0.0180312
0.0166172
0.0152024
0.0137888
0.0123763
0.0109652
0.00955628
0.00815045
0.00674852
0.00535127
0.00395949
0.00257395
0.00119546
-0.000175284
-0.00153739
-0.00289037
0.0234279
0.0220506
0.0207815
0.0195305
0.0182654
0.0169921
0.0157173
0.0144427
0.0131682
0.0118944
0.010622
0.00935185
0.00808468
0.00682127
0.00556237
0.00430876
0.00306119
0.00182037
0.000587174
-0.000637954
0.0231084
0.0218806
0.0207249
0.0195802
0.0184247
0.0172627
0.0160987
0.014934
0.013769
0.0126041
0.0114402
0.0102778
0.00911783
0.00796096
0.00680792
0.00565946
0.00451631
0.00337916
0.00224888
0.00112593
0.0228403
0.0217279
0.0206604
0.0195988
0.018529
0.0174539
0.0163766
0.0152983
0.0142192
0.01314
0.0120613
0.010984
0.00990857
0.00883586
0.00776655
0.00670133
0.00564094
0.00458602
0.00353739
0.00249546
0.0226235
0.0215971
0.020596
0.0195973
0.0185923
0.017583
0.0165716
0.0155588
0.0145452
0.0135313
0.0125179
0.0115056
0.010495
0.0094868
0.00848175
0.00748049
0.0064837
0.00549202
0.00450622
0.00352669
0.0224565
0.0214897
0.0205353
0.0195808
0.0186217
0.0176592
0.0166948
0.0157291
0.0147627
0.0137962
0.0128302
0.0118654
0.0109023
0.00994172
0.00898416
0.00803029
0.00708077
0.00613616
0.00519718
0.00426416
0.0223467
0.0214169
0.0204913
0.0195646
0.0186345
0.017702
0.0167678
0.0158327
0.0148971
0.0139616
0.0130267
0.0120932
0.0111615
0.0102324
0.00930625
0.0083838
0.00746561
0.00655222
0.00564428
0.00474208
0.0222833
0.0213658
0.0204494
0.019532
0.0186126
0.0176918
0.0167703
0.0158487
0.0149274
0.0140072
0.0130883
0.0121715
0.0112572
0.0103459
0.00943822
0.00853454
0.00763542
0.00674129
0.00585273
0.00496994
0.224218
0.224489
0.225306
0.226703
0.228647
0.231104
0.234037
0.237389
0.241068
0.244939
0.248798
0.252347
0.255151
0.256581
0.255734
0.251349
0.241652
0.224342
0.196444
0.154519
0.210322
0.210503
0.211008
0.211847
0.212978
0.214348
0.215894
0.217532
0.219142
0.220559
0.22156
0.221844
0.221007
0.218519
0.21369
0.205646
0.193317
0.175446
0.150971
0.117603
0.19523
0.195293
0.195468
0.195749
0.196095
0.196447
0.196733
0.196858
0.196694
0.196079
0.194804
0.192609
0.189165
0.184076
0.176858
0.166947
0.153695
0.136358
0.114215
0.0857926
0.179694
0.179662
0.179572
0.179405
0.179125
0.178679
0.177995
0.176981
0.175521
0.173471
0.170655
0.166864
0.16185
0.155325
0.146963
0.136406
0.123276
0.107194
0.087824
0.064934
0.164362
0.164262
0.163983
0.163493
0.162765
0.161757
0.160404
0.158629
0.156335
0.153407
0.149711
0.145091
0.139373
0.132366
0.123866
0.113668
0.101575
0.087429
0.0710645
0.0525888
0.149684
0.14954
0.149134
0.148429
0.147407
0.146036
0.144265
0.142033
0.139264
0.135874
0.131765
0.12683
0.120955
0.11402
0.105907
0.0965061
0.0857248
0.0735135
0.0597836
0.0447813
0.13596
0.135789
0.135308
0.134477
0.133284
0.131709
0.129715
0.127255
0.124274
0.120713
0.116506
0.111582
0.105869
0.0992992
0.0918067
0.0833397
0.0738618
0.063375
0.0518288
0.0394959
0.123367
0.123185
0.122668
0.121777
0.120507
0.118848
0.116772
0.114246
0.111234
0.107695
0.103586
0.0988655
0.0934906
0.0874242
0.0806359
0.0731068
0.0648314
0.0558357
0.0460943
0.0358701
0.111993
0.111808
0.111283
0.11038
0.1091
0.107438
0.105376
0.102894
0.0999648
0.0965652
0.0926696
0.0882538
0.0832962
0.0777798
0.0716947
0.0650406
0.0578275
0.0500897
0.0418142
0.0332277
0.101855
0.101673
0.10116
0.100277
0.0990292
0.0974174
0.0954312
0.0930564
0.0902782
0.0870827
0.0834565
0.0793882
0.074869
0.069895
0.0644678
0.0585969
0.0522996
0.0456113
0.0385282
0.0312402
0.092928
0.0927545
0.092263
0.0914192
0.0902299
0.0886992
0.086822
0.08459
0.0819954
0.0790316
0.0756936
0.0719779
0.0678841
0.0634156
0.0585806
0.0533935
0.047874
0.0420555
0.0359397
0.0296796
0.0851598
0.0849962
0.0845329
0.0837381
0.08262
0.0811852
0.0794319
0.0773561
0.0749549
0.0722266
0.0691714
0.0657911
0.0620902
0.0580764
0.0537611
0.0491605
0.0442949
0.0391944
0.0338648
0.0284279
0.0784839
0.0783311
0.0778979
0.0771554
0.0761124
0.0747767
0.0731493
0.0712289
0.0690157
0.0665113
0.0637193
0.0606446
0.0572944
0.0536787
0.0498103
0.0457058
0.0413848
0.0368738
0.0321816
0.0274028
0.0728293
0.0726869
0.0722833
0.0715918
0.0706214
0.0693809
0.0678727
0.0660975
0.0640575
0.0617564
0.0591996
0.0563939
0.0533482
0.0500731
0.0465822
0.0428914
0.0390191
0.0349889
0.0308114
0.0265597
0.0681264
0.0679935
0.0676171
0.0669722
0.0660681
0.0649139
0.0635128
0.0618669
0.0599796
0.0578558
0.0555021
0.0529263
0.0501377
0.0471475
0.043969
0.0406173
0.0371097
0.0334669
0.0297009
0.0258678
0.0643111
0.0641866
0.0638337
0.0632294
0.0623827
0.0613028
0.0599935
0.0584577
0.0566994
0.0547244
0.0525398
0.0501537
0.0475758
0.0448173
0.0418908
0.0388109
0.0355935
0.0322571
0.0288148
0.0253091
0.061328
0.0612103
0.0608767
0.0603056
0.0595059
0.0584866
0.057252
0.0558052
0.0541508
0.0522949
0.0502448
0.0480089
0.0455968
0.0430195
0.0402892
0.0374195
0.0344256
0.0313241
0.0281288
0.0248723
0.0591312
0.0590188
0.0587
0.0581542
0.0573902
0.0564169
0.0552386
0.0538589
0.0522825
0.0505157
0.0485659
0.0464415
0.044152
0.041708
0.0391216
0.0364056
0.0335742
0.0306431
0.0276263
0.0245491
0.0576862
0.0575771
0.0572683
0.0567396
0.0559995
0.055057
0.0539164
0.0525815
0.0510571
0.0493495
0.0474662
0.0454155
0.0432068
0.0408506
0.0383584
0.0357429
0.0330177
0.0301977
0.0272972
0.0243374
0.0569702
0.0568625
0.0565585
0.0560385
0.0553105
0.0543833
0.0532617
0.0519491
0.0504507
0.0487726
0.0469224
0.0449083
0.0427397
0.040427
0.0379814
0.0354155
0.0327425
0.0299769
0.027133
0.0242292
0.251574
0.251826
0.253207
0.255478
0.258704
0.262938
0.268243
0.274705
0.28243
0.291551
0.302229
0.314665
0.329089
0.345815
0.365144
0.387595
0.413465
0.443651
0.478204
0.518066
0.251462
0.251712
0.253092
0.25536
0.258582
0.262811
0.26811
0.274563
0.282277
0.291382
0.302039
0.314448
0.328835
0.345512
0.36477
0.387128
0.412851
0.442857
0.477078
0.516607
0.251237
0.251486
0.252862
0.255126
0.25834
0.262559
0.267845
0.27428
0.281971
0.291046
0.301662
0.314016
0.328329
0.344907
0.364024
0.386194
0.411628
0.441274
0.474832
0.513699
0.250901
0.251147
0.252519
0.254774
0.257978
0.262183
0.267448
0.273858
0.281513
0.290542
0.301097
0.31337
0.327573
0.344002
0.362909
0.384798
0.409797
0.438906
0.471472
0.509356
0.250454
0.250697
0.252062
0.254308
0.257498
0.261683
0.266922
0.273296
0.280906
0.289874
0.300348
0.312513
0.326569
0.3428
0.361428
0.382944
0.407368
0.435764
0.467012
0.503603
0.249898
0.250136
0.251495
0.253728
0.2569
0.261061
0.266268
0.272599
0.280151
0.289043
0.299417
0.311447
0.325321
0.341307
0.359587
0.380638
0.404347
0.43186
0.461465
0.496468
0.249233
0.249467
0.250817
0.253035
0.256187
0.260319
0.265487
0.271767
0.279251
0.288053
0.298306
0.310177
0.323833
0.339525
0.357392
0.377889
0.400747
0.427207
0.454853
0.487988
0.24846
0.24869
0.250031
0.252233
0.255361
0.25946
0.264584
0.270804
0.278209
0.286906
0.297021
0.308706
0.322111
0.337463
0.354852
0.374706
0.396581
0.421822
0.447199
0.478205
0.247582
0.247808
0.249138
0.251323
0.254425
0.258487
0.26356
0.269713
0.277028
0.285607
0.295564
0.307039
0.32016
0.335126
0.351975
0.371098
0.391865
0.415722
0.438532
0.467166
0.2466
0.246823
0.248143
0.250308
0.253381
0.257402
0.262419
0.268497
0.275713
0.284161
0.293942
0.305183
0.317987
0.332523
0.348771
0.367077
0.386616
0.408926
0.428885
0.45492
0.245516
0.245738
0.247046
0.24919
0.252232
0.256209
0.261165
0.267161
0.274268
0.282571
0.29216
0.303143
0.315598
0.329661
0.345251
0.362655
0.380854
0.401452
0.4183
0.441513
0.244333
0.244554
0.245851
0.247974
0.250983
0.254911
0.259801
0.265708
0.272697
0.280843
0.290223
0.300925
0.313003
0.326551
0.341426
0.357846
0.374602
0.393317
0.406822
0.42699
0.243051
0.243275
0.244562
0.246662
0.249636
0.253514
0.258333
0.264145
0.271006
0.278983
0.288137
0.298538
0.310209
0.323201
0.337311
0.352665
0.367884
0.384539
0.394507
0.411387
0.241675
0.241904
0.243181
0.245259
0.248196
0.25202
0.256764
0.262474
0.2692
0.276997
0.285911
0.29599
0.307227
0.319625
0.33292
0.347129
0.360727
0.375138
0.381422
0.394723
0.240205
0.240444
0.241711
0.243767
0.246667
0.250434
0.255099
0.260701
0.267283
0.274888
0.283547
0.293284
0.30406
0.315827
0.328258
0.341248
0.353148
0.365122
0.367637
0.376993
0.238644
0.238897
0.240156
0.24219
0.24505
0.248756
0.253337
0.258825
0.265253
0.272654
0.281041
0.290412
0.300698
0.311794
0.323313
0.335006
0.345137
0.354478
0.353216
0.358163
0.236995
0.23727
0.238521
0.240534
0.243354
0.246999
0.251492
0.25686
0.263128
0.270313
0.278415
0.287403
0.297174
0.307567
0.318129
0.328462
0.336761
0.343279
0.338295
0.338238
0.235265
0.235571
0.236822
0.238821
0.241608
0.2452
0.249615
0.254874
0.260993
0.267979
0.27581
0.284432
0.293704
0.303406
0.313019
0.321977
0.328413
0.331928
0.323262
0.317114
0.233451
0.233804
0.23506
0.237054
0.239819
0.243368
0.247719
0.252886
0.258878
0.265685
0.273271
0.281552
0.29035
0.299377
0.308039
0.31558
0.320056
0.320291
0.307999
0.293634
0.23152
0.231904
0.233127
0.23507
0.237751
0.241183
0.245375
0.250332
0.256049
0.262499
0.269617
0.277285
0.285276
0.29323
0.300479
0.306094
0.308103
0.304664
0.289184
0.26668
0.231535
0.231918
0.233142
0.235084
0.237766
0.241197
0.245388
0.250346
0.256063
0.262513
0.269631
0.277299
0.285292
0.293247
0.300497
0.306112
0.308122
0.304685
0.289208
0.266708
0.233465
0.233817
0.235074
0.237068
0.239832
0.243382
0.247732
0.2529
0.258891
0.265699
0.273285
0.281566
0.290365
0.299392
0.308055
0.315597
0.320075
0.320312
0.308022
0.293662
0.235278
0.235585
0.236836
0.238834
0.241621
0.245213
0.249627
0.254886
0.261006
0.267991
0.275822
0.284445
0.293718
0.303421
0.313035
0.321994
0.328431
0.331948
0.323284
0.317141
0.237008
0.237282
0.238534
0.240546
0.243366
0.247011
0.251504
0.256872
0.263139
0.270325
0.278427
0.287416
0.297187
0.30758
0.318143
0.328478
0.336778
0.343298
0.338316
0.338263
0.238656
0.238909
0.240168
0.242202
0.245061
0.248768
0.253348
0.258836
0.265265
0.272665
0.281052
0.290424
0.30071
0.311807
0.323326
0.335021
0.345153
0.354496
0.353236
0.358187
0.240216
0.240455
0.241722
0.243778
0.246678
0.250444
0.255109
0.260711
0.267294
0.274898
0.283558
0.293295
0.304071
0.315839
0.328271
0.341261
0.353163
0.365139
0.367657
0.377015
0.241685
0.241914
0.243191
0.245269
0.248206
0.25203
0.256774
0.262484
0.26921
0.277006
0.285921
0.296
0.307237
0.319637
0.332932
0.347142
0.360741
0.375154
0.38144
0.394744
0.243061
0.243285
0.244571
0.246672
0.249646
0.253523
0.258342
0.264153
0.271015
0.278992
0.288147
0.298548
0.310219
0.323212
0.337322
0.352677
0.367897
0.384554
0.394524
0.411406
0.244342
0.244563
0.24586
0.247983
0.250991
0.25492
0.25981
0.265717
0.272705
0.280851
0.290231
0.300934
0.313012
0.32656
0.341436
0.357857
0.374614
0.39333
0.406837
0.427008
0.245525
0.245746
0.247054
0.249198
0.25224
0.256216
0.261172
0.267168
0.274275
0.282579
0.292168
0.303151
0.315607
0.32967
0.34526
0.362665
0.380865
0.401464
0.418314
0.441529
0.246608
0.246831
0.24815
0.250315
0.253388
0.257409
0.262426
0.268504
0.27572
0.284168
0.29395
0.30519
0.317994
0.332531
0.348779
0.367086
0.386626
0.408937
0.428899
0.454934
0.247589
0.247815
0.249145
0.251329
0.254431
0.258493
0.263566
0.269719
0.277034
0.285614
0.295571
0.307046
0.320167
0.335134
0.351982
0.371106
0.391874
0.415733
0.438544
0.46718
0.248466
0.248696
0.250036
0.252239
0.255367
0.259466
0.264589
0.270809
0.278214
0.286912
0.297027
0.308712
0.322117
0.337469
0.354859
0.374713
0.396589
0.421831
0.44721
0.478217
0.249238
0.249472
0.250822
0.25304
0.256192
0.260324
0.265492
0.271772
0.279256
0.288058
0.298311
0.310182
0.323839
0.339531
0.357398
0.377896
0.400755
0.427215
0.454862
0.487998
0.249902
0.250141
0.251499
0.253732
0.256904
0.261065
0.266272
0.272603
0.280155
0.289048
0.299421
0.311452
0.325326
0.341311
0.359592
0.380644
0.404353
0.431867
0.461473
0.496476
0.250458
0.2507
0.252066
0.254311
0.257501
0.261686
0.266925
0.2733
0.280909
0.289878
0.300352
0.312517
0.326573
0.342804
0.361432
0.382948
0.407373
0.43577
0.467018
0.50361
0.250904
0.25115
0.252522
0.254777
0.257981
0.262185
0.267451
0.27386
0.281516
0.290545
0.3011
0.313373
0.327576
0.344005
0.362912
0.384801
0.409801
0.438911
0.471477
0.509362
0.251239
0.251488
0.252864
0.255127
0.258342
0.262561
0.267846
0.274282
0.281972
0.291048
0.301664
0.314018
0.328332
0.344909
0.364027
0.386196
0.41163
0.441277
0.474835
0.513703
0.251463
0.251714
0.253093
0.255361
0.258583
0.262812
0.268111
0.274564
0.282278
0.291384
0.30204
0.314449
0.328836
0.345513
0.364772
0.387129
0.412853
0.442859
0.47708
0.51661
0.251575
0.251826
0.253208
0.255479
0.258704
0.262938
0.268243
0.274705
0.28243
0.291552
0.302229
0.314665
0.329089
0.345815
0.365145
0.387596
0.413465
0.443652
0.478204
0.518067
0.0569946
0.0568869
0.0565829
0.0560629
0.0553349
0.0544077
0.053286
0.0519734
0.0504749
0.0487968
0.0469465
0.0449324
0.0427638
0.040451
0.0380054
0.0354394
0.0327664
0.0300008
0.0271568
0.0242529
0.0577105
0.0576015
0.0572926
0.0567639
0.0560238
0.0550813
0.0539407
0.0526057
0.0510813
0.0493737
0.0474903
0.0454396
0.0432308
0.0408746
0.0383823
0.0357668
0.0330415
0.0302215
0.0273209
0.0243611
0.0591556
0.0590431
0.0587243
0.0581785
0.0574144
0.0564411
0.0552628
0.053883
0.0523066
0.0505398
0.0485899
0.0464655
0.0441759
0.041732
0.0391454
0.0364294
0.033598
0.0306669
0.02765
0.0245727
0.0613522
0.0612345
0.0609009
0.0603298
0.0595301
0.0585108
0.0572761
0.0558292
0.0541748
0.0523188
0.0502687
0.0480328
0.0456207
0.0430433
0.040313
0.0374433
0.0344493
0.0313477
0.0281524
0.0248958
0.0643352
0.0642107
0.0638578
0.0632534
0.0624067
0.0613268
0.0600175
0.0584816
0.0567233
0.0547483
0.0525636
0.0501775
0.0475996
0.044841
0.0419145
0.0388346
0.0356171
0.0322806
0.0288383
0.0253325
0.0681503
0.0680174
0.067641
0.0669961
0.066092
0.0649377
0.0635366
0.0618907
0.0600033
0.0578795
0.0555258
0.0529499
0.0501613
0.0471711
0.0439925
0.0406408
0.0371331
0.0334903
0.0297243
0.025891
0.072853
0.0727106
0.072307
0.0716154
0.070645
0.0694046
0.0678963
0.0661211
0.064081
0.0617799
0.0592231
0.0564174
0.0533716
0.0500966
0.0466057
0.0429148
0.0390425
0.0350122
0.0308346
0.0265829
0.0785073
0.0783544
0.0779213
0.0771788
0.0761357
0.0748001
0.0731727
0.0712523
0.069039
0.0665347
0.0637427
0.0606679
0.0573177
0.053702
0.0498337
0.0457292
0.0414081
0.0368971
0.0322048
0.027426
0.0851828
0.0850192
0.0845559
0.0837612
0.0826431
0.0812083
0.079455
0.0773793
0.074978
0.0722498
0.0691946
0.0658143
0.0621135
0.0580997
0.0537844
0.0491838
0.0443182
0.0392177
0.0338881
0.0284511
0.0929506
0.092777
0.0922856
0.0914419
0.0902526
0.088722
0.0868449
0.0846129
0.0820183
0.0790546
0.0757166
0.0720009
0.0679072
0.0634388
0.0586039
0.0534168
0.0478973
0.0420788
0.035963
0.0297029
0.101877
0.101696
0.101182
0.100299
0.0990515
0.0974398
0.0954537
0.093079
0.0903009
0.0871054
0.0834793
0.079411
0.074892
0.069918
0.0644909
0.0586202
0.0523229
0.0456347
0.0385516
0.0312637
0.112015
0.111829
0.111305
0.110402
0.109122
0.10746
0.105399
0.102916
0.0999871
0.0965876
0.0926921
0.0882764
0.0833189
0.0778027
0.0717177
0.0650638
0.0578509
0.0501132
0.0418378
0.0332514
0.123389
0.123206
0.122689
0.121798
0.120528
0.118869
0.116793
0.114268
0.111256
0.107717
0.103608
0.0988878
0.0935131
0.0874469
0.0806588
0.07313
0.0648548
0.0558594
0.0461182
0.0358943
0.13598
0.13581
0.135329
0.134497
0.133305
0.13173
0.129736
0.127276
0.124296
0.120735
0.116527
0.111604
0.105892
0.0993217
0.0918295
0.0833629
0.0738853
0.0633988
0.051853
0.0395205
0.149704
0.14956
0.149154
0.148449
0.147427
0.146056
0.144285
0.142053
0.139285
0.135894
0.131786
0.126852
0.120977
0.114042
0.10593
0.0965292
0.0857484
0.0735376
0.0598082
0.0448065
0.164381
0.164281
0.164002
0.163512
0.162785
0.161776
0.160424
0.158649
0.156355
0.153428
0.149731
0.145112
0.139395
0.132388
0.123889
0.113691
0.101599
0.0874533
0.0710896
0.0526146
0.179713
0.17968
0.17959
0.179423
0.179143
0.178697
0.178014
0.177
0.17554
0.17349
0.170675
0.166885
0.161871
0.155346
0.146985
0.136429
0.1233
0.107218
0.0878495
0.0649606
0.195247
0.195311
0.195486
0.195767
0.196112
0.196465
0.196751
0.196876
0.196712
0.196097
0.194823
0.192628
0.189185
0.184096
0.17688
0.166969
0.153718
0.136382
0.114241
0.0858202
0.210338
0.21052
0.211024
0.211864
0.212995
0.214364
0.215911
0.217549
0.219159
0.220577
0.221578
0.221862
0.221025
0.218538
0.213711
0.205668
0.19334
0.17547
0.150997
0.117632
0.224234
0.224504
0.225322
0.226718
0.228662
0.23112
0.234053
0.237404
0.241084
0.244955
0.248815
0.252365
0.255169
0.256599
0.255753
0.25137
0.241674
0.224367
0.196471
0.15455
0.0223069
0.0213891
0.0204724
0.0195546
0.0186348
0.0177136
0.0167917
0.0158697
0.0149481
0.0140275
0.0131083
0.0121912
0.0112765
0.0103649
0.00945686
0.00855283
0.00765332
0.00675882
0.00586979
0.00498669
0.0223701
0.0214401
0.0205142
0.0195872
0.0186568
0.0177238
0.0167893
0.0158537
0.0149178
0.013982
0.0130468
0.012113
0.011181
0.0102515
0.00932511
0.00840233
0.00748378
0.00657002
0.00566163
0.00475915
0.0224799
0.0215129
0.0205582
0.0196034
0.018644
0.0176811
0.0167163
0.0157502
0.0147835
0.0138167
0.0128504
0.0118852
0.0109219
0.00996096
0.00900311
0.00804895
0.0070991
0.00615419
0.00521481
0.00428158
0.0226469
0.0216202
0.0206189
0.0196198
0.0186145
0.0176049
0.0165931
0.01558
0.014566
0.0135518
0.0125381
0.0115254
0.0105145
0.00950605
0.00850072
0.0074992
0.00650213
0.00551019
0.00452403
0.00354429
0.0228635
0.0217508
0.0206831
0.0196212
0.0185511
0.0174757
0.0163981
0.0153194
0.0142401
0.0131605
0.0120815
0.0110038
0.00992809
0.00885505
0.00778541
0.00671987
0.00565915
0.00460395
0.00355495
0.00251283
0.0231314
0.0219034
0.0207474
0.0196025
0.0184468
0.0172845
0.0161202
0.0149553
0.01379
0.0126248
0.0114604
0.0102977
0.00913739
0.00798016
0.00682677
0.00567798
0.00453451
0.00339709
0.00226646
0.00114331
0.0234508
0.0220733
0.020804
0.0195528
0.0182875
0.0170139
0.0157389
0.014464
0.0131893
0.0119152
0.0106424
0.00937193
0.00810441
0.00684066
0.00558143
0.0043275
0.00307962
0.00183854
0.000604998
-0.000620285
0.0238247
0.0222561
0.020843
0.0194575
0.0180535
0.0166392
0.0152242
0.0138104
0.0123977
0.0109863
0.0095771
0.008171
0.00676878
0.00537123
0.00397917
0.00259336
0.00121459
-0.000156366
-0.00151876
-0.00287185
0.0242678
0.0224575
0.0208633
0.0193093
0.0177313
0.0161407
0.0145506
0.0129634
0.0113786
0.00979628
0.0082174
0.00664286
0.00507352
0.00351017
0.00195361
0.000404639
-0.00113596
-0.00266741
-0.00418896
-0.00569987
0.0247974
0.0226791
0.0208535
0.0190853
0.0172865
0.0154721
0.01366
0.0118533
0.0100507
0.00825245
0.00645932
0.00467236
0.00289243
0.00112036
-0.000643044
-0.00239697
-0.00414061
-0.00587318
-0.00759392
-0.00930209
0.0254738
0.0229643
0.0208417
0.0188007
0.0167221
0.014625
0.0125331
0.0104504
0.00837493
0.00630651
0.00424606
0.00219464
0.000153089
-0.0018778
-0.00389726
-0.00590452
-0.00789882
-0.00987944
-0.0118457
-0.0137968
0.0263635
0.0233436
0.0208249
0.0184228
0.0159766
0.0135086
0.0110501
0.00860617
0.00617403
0.00375298
0.00134399
-0.00105183
-0.00343363
-0.00580065
-0.00815213
-0.0104873
-0.0128054
-0.0151058
-0.0173877
-0.0196505
0.0276727
0.0239909
0.0209424
0.0180639
0.0151392
0.0121911
0.00925986
0.00635247
0.003465
0.000595991
-0.00225377
-0.00508329
-0.00789194
-0.0106792
-0.0134445
-0.0161873
-0.0189072
-0.0216038
-0.0242764
-0.0269247
0.029616
0.0250271
0.0212219
0.0176707
0.0140788
0.0104624
0.00687262
0.00331948
-0.000202114
-0.00369464
-0.00715755
-0.0105899
-0.0139911
-0.0173606
-0.0206982
-0.0240034
-0.0272758
-0.0305151
-0.0337209
-0.0368929
0.0328892
0.0270856
0.0222117
0.0177301
0.0132393
0.0087325
0.00427184
-0.000127191
-0.00447131
-0.00876538
-0.0130103
-0.0172063
-0.0213538
-0.0254533
-0.0295056
-0.033511
-0.03747
-0.0413828
-0.0452498
-0.0490711
0.0381448
0.030584
0.0240605
0.018148
0.0122872
0.00641652
0.00061168
-0.00509899
-0.010721
-0.016261
-0.0217206
-0.0270998
-0.0323994
-0.0376203
-0.0427636
-0.0478308
-0.0528231
-0.057742
-0.0625892
-0.0673666
0.0474352
0.0374517
0.0285524
0.020668
0.0129959
0.005345
-0.00220324
-0.00960097
-0.0168533
-0.0239733
-0.0309671
-0.0378376
-0.0445878
-0.0512209
-0.0577403
-0.064149
-0.0704497
-0.0766446
-0.0827357
-0.0887245
0.0639088
0.0496824
0.0362751
0.0246495
0.0136159
0.00269812
-0.00803253
-0.0184901
-0.0286759
-0.0386126
-0.0483117
-0.0577769
-0.0670109
-0.0760173
-0.0848007
-0.0933662
-0.10172
-0.109871
-0.117828
-0.125602
0.097136
0.0787134
0.0589564
0.0418059
0.0258984
0.0103015
-0.00494343
-0.0196941
-0.0339542
-0.0477733
-0.0611862
-0.0742155
-0.0868811
-0.0992021
-0.111195
-0.122876
-0.134255
-0.145342
-0.156147
-0.166674
0.133657
0.111178
0.0847449
0.0597535
0.035343
0.0110213
-0.0129122
-0.0361976
-0.058738
-0.080482
-0.101383
-0.121405
-0.140524
-0.158726
-0.176005
-0.192361
-0.207802
-0.222342
-0.236004
-0.248821
0.00410998
0.00324009
0.00237746
0.0015225
0.000675619
-0.000162797
-0.000992368
-0.00181273
-0.00262352
-0.0034244
-0.00421504
-0.00499512
-0.00576432
-0.00652236
-0.00726894
-0.00800377
-0.00872655
-0.00943719
-0.0101361
-0.0108216
0.00386314
0.00297411
0.0020926
0.0012191
0.000354093
-0.000501943
-0.00134856
-0.00218531
-0.00301178
-0.00382757
-0.0046323
-0.00542562
-0.00620719
-0.0069767
-0.00773386
-0.00847839
-0.00921001
-0.00992857
-0.0106345
-0.0113277
0.00335506
0.00243584
0.00152446
0.000621466
-0.00027263
-0.00115733
-0.00203215
-0.00289664
-0.00375035
-0.00459287
-0.0054238
-0.00624277
-0.00704942
-0.00784343
-0.0086245
-0.00939234
-0.0101466
-0.0108871
-0.0116141
-0.0123308
0.00257161
0.0016066
0.000649853
-0.000298041
-0.00123652
-0.00216506
-0.00308314
-0.00399027
-0.00488598
-0.00576983
-0.00664141
-0.00750032
-0.0083462
-0.00917871
-0.00999754
-0.0108024
-0.011593
-0.0123686
-0.01313
-0.0138849
0.00147825
0.000451866
-0.000565708
-0.00157386
-0.00257202
-0.00355963
-0.00453614
-0.00550104
-0.00645386
-0.00739412
-0.0083214
-0.00923529
-0.0101354
-0.0110214
-0.011893
-0.01275
-0.0135919
-0.0144177
-0.0152281
-0.0160377
2.83423e-05
-0.00107778
-0.00217441
-0.00326092
-0.00433671
-0.00540119
-0.00645383
-0.00749409
-0.00852146
-0.00953547
-0.0105357
-0.0115217
-0.012493
-0.0134495
-0.0143906
-0.0153164
-0.0162262
-0.0171185
-0.0179941
-0.0188762
-0.0018366
-0.00304327
-0.00423962
-0.00542501
-0.00659883
-0.00776048
-0.00890939
-0.010045
-0.0111669
-0.0122745
-0.0133674
-0.0144451
-0.0155074
-0.0165538
-0.0175841
-0.018598
-0.0195952
-0.0205733
-0.021533
-0.0225078
-0.00421491
-0.00554724
-0.00686817
-0.00817704
-0.00947322
-0.0107561
-0.0120251
-0.0132798
-0.0145195
-0.0157439
-0.0169524
-0.0181447
-0.0193204
-0.0204791
-0.0216207
-0.0227449
-0.0238513
-0.0249369
-0.0260022
-0.0270918
-0.00719943
-0.00868692
-0.0101617
-0.0116231
-0.0130705
-0.0145034
-0.0159211
-0.0173232
-0.0187091
-0.0200784
-0.0214307
-0.0227656
-0.0240827
-0.0253816
-0.0266622
-0.0279244
-0.0291677
-0.0303884
-0.0315866
-0.0328178
-0.010997
-0.0126778
-0.0143441
-0.015995
-0.01763
-0.0192486
-0.0208501
-0.0224342
-0.0240002
-0.0255479
-0.0270768
-0.0285865
-0.0300766
-0.0315471
-0.0329975
-0.034428
-0.0358382
-0.0372239
-0.0385846
-0.0399843
-0.0157322
-0.0176513
-0.0195534
-0.021438
-0.0233046
-0.0251526
-0.0269816
-0.0287912
-0.0305808
-0.0323502
-0.034099
-0.0358269
-0.0375335
-0.0392186
-0.040882
-0.0425238
-0.0441436
-0.0457372
-0.0473035
-0.0489087
-0.0218936
-0.0241163
-0.0263181
-0.0284984
-0.0306568
-0.0327928
-0.0349058
-0.0369956
-0.0390616
-0.0411036
-0.0431213
-0.0451144
-0.0470827
-0.049026
-0.0509442
-0.0528374
-0.0547056
-0.0565454
-0.0583552
-0.0601919
-0.0295484
-0.032147
-0.0347202
-0.0372676
-0.039789
-0.0422841
-0.0447526
-0.0471944
-0.0496091
-0.0519966
-0.0543568
-0.0566893
-0.0589939
-0.0612705
-0.0635188
-0.0657385
-0.0679295
-0.0700905
-0.0722213
-0.0743466
-0.0400309
-0.0431347
-0.0462039
-0.0492384
-0.0522379
-0.0552021
-0.0581307
-0.0610235
-0.0638799
-0.0666999
-0.0694828
-0.0722286
-0.0749368
-0.0776073
-0.08024
-0.0828345
-0.0853909
-0.087914
-0.0904112
-0.092836
-0.0528469
-0.0565776
-0.0602632
-0.0639041
-0.0675006
-0.0710531
-0.0745621
-0.0780284
-0.0814527
-0.0848358
-0.0881787
-0.0914823
-0.0947475
-0.0979752
-0.101166
-0.104319
-0.107433
-0.110527
-0.113637
-0.116556
-0.0720759
-0.0767191
-0.0812981
-0.0858149
-0.0902711
-0.0946682
-0.0990071
-0.103289
-0.107513
-0.111681
-0.115791
-0.119844
-0.123839
-0.127777
-0.131662
-0.135493
-0.139272
-0.143052
-0.146966
-0.150483
-0.0946123
-0.1004
-0.106089
-0.11168
-0.117175
-0.122576
-0.127888
-0.133116
-0.138269
-0.143359
-0.1484
-0.153411
-0.158413
-0.163434
-0.1685
-0.173636
-0.178853
-0.184288
-0.190321
-0.195675
-0.133209
-0.140663
-0.147984
-0.155191
-0.162306
-0.169354
-0.176358
-0.183343
-0.190329
-0.197338
-0.204385
-0.21148
-0.218629
-0.225836
-0.233102
-0.240417
-0.247764
-0.255405
-0.264222
-0.271663
-0.176925
-0.186903
-0.196603
-0.206021
-0.21515
-0.223981
-0.232506
-0.240724
-0.248639
-0.256274
-0.263672
-0.270912
-0.278116
-0.285465
-0.293208
-0.301635
-0.311067
-0.322525
-0.338517
-0.353503
-0.260838
-0.272118
-0.282739
-0.292802
-0.302434
-0.311789
-0.321051
-0.330434
-0.340184
-0.350572
-0.361891
-0.374445
-0.388545
-0.404491
-0.422564
-0.442937
-0.46564
-0.491707
-0.524183
-0.551266
-0.0164906
-0.0227933
-0.0248774
-0.0239042
-0.0212091
-0.0177375
-0.0141758
-0.0109693
-0.00829865
-0.00617322
-0.00453312
-0.00329672
-0.00237854
-0.00170411
-0.00120894
-0.000849167
-0.000578076
-0.00038361
-0.00021251
-9.91946e-05
-0.0171636
-0.0233728
-0.0252868
-0.0241692
-0.0213528
-0.017785
-0.014161
-0.0109233
-0.00824194
-0.00611708
-0.00448336
-0.00325553
-0.00234594
-0.00167914
-0.00119031
-0.00083565
-0.000568531
-0.000377334
-0.000208625
-9.78933e-05
-0.0185335
-0.0245406
-0.0261129
-0.0247029
-0.0216395
-0.0178776
-0.0141291
-0.0108295
-0.00812706
-0.00600395
-0.00438343
-0.003173
-0.00228076
-0.00162927
-0.00115318
-0.000808637
-0.00054966
-0.000364598
-0.00020141
-9.47116e-05
-0.020651
-0.026329
-0.0273682
-0.0255061
-0.0220633
-0.0180075
-0.0140733
-0.0106828
-0.00795091
-0.00583225
-0.00423277
-0.00304915
-0.0021833
-0.00155488
-0.00109793
-0.00076849
-0.000521681
-0.00034568
-0.000190835
-8.97765e-05
-0.023595
-0.0287865
-0.0290708
-0.02658
-0.0226166
-0.0181634
-0.0139831
-0.0104758
-0.00770906
-0.00559973
-0.00403058
-0.00288402
-0.00205399
-0.00145656
-0.00102511
-0.000715685
-0.000484944
-0.000320872
-0.00017699
-8.32268e-05
-0.0274769
-0.0319789
-0.0312455
-0.0279262
-0.023288
-0.0183298
-0.0138449
-0.0101989
-0.00739576
-0.00530354
-0.00377593
-0.00267776
-0.00189345
-0.00133507
-0.000935467
-0.000650858
-0.000439937
-0.000290515
-0.000160077
-7.51781e-05
-0.0324453
-0.0359926
-0.0339248
-0.0295467
-0.0240623
-0.0184862
-0.0136414
-0.00984027
-0.00700404
-0.0049404
-0.00346788
-0.00243068
-0.00170257
-0.00119144
-0.000829951
-0.000574808
-0.000387269
-0.000255036
-0.000140345
-6.57596e-05
-0.0386936
-0.0409377
-0.0371506
-0.0314423
-0.0249182
-0.0186064
-0.0133511
-0.00938561
-0.0065259
-0.00450679
-0.00310566
-0.00214344
-0.00148257
-0.00102698
-0.000709745
-0.000488497
-0.000327669
-0.000214953
-0.000118094
-5.51214e-05
-0.0464681
-0.0469515
-0.0409761
-0.0336128
-0.025828
-0.0186578
-0.0129485
-0.00881859
-0.00595258
-0.0039992
-0.00268887
-0.00181712
-0.00123506
-0.000843336
-0.000576274
-0.000393065
-0.000261992
-0.000170871
-9.36704e-05
-4.3431e-05
-0.0560813
-0.0542032
-0.0454687
-0.0360555
-0.0267544
-0.0186004
-0.012404
-0.00812095
-0.00527492
-0.00341449
-0.00221768
-0.00145338
-0.000962118
-0.000642489
-0.000431231
-0.000289843
-0.000191217
-0.000123471
-6.74634e-05
-3.0872e-05
-0.0679181
-0.062899
-0.0507147
-0.0387633
-0.027649
-0.0183858
-0.0116837
-0.00727292
-0.00448387
-0.00275029
-0.00169317
-0.00105464
-0.000666403
-0.000426841
-0.000276584
-0.000180343
-0.000116438
-7.35018e-05
-3.99041e-05
-1.7642e-05
-0.0824531
-0.0732869
-0.0568255
-0.0417217
-0.0284484
-0.0179565
-0.0107498
-0.00625388
-0.00357119
-0.00200557
-0.00111765
-0.000624238
-0.000351234
-0.000199226
-0.000114581
-6.62527e-05
-3.88633e-05
-2.17719e-05
-1.1463e-05
-3.95047e-06
-0.100225
-0.0856592
-0.063944
-0.0449017
-0.0290705
-0.0172444
-0.00956091
-0.00504324
-0.00253039
-0.00118126
-0.00049503
-0.000166671
-2.06695e-05
3.70598e-05
5.22538e-05
5.05776e-05
4.01998e-05
3.08539e-05
1.73517e-05
9.98808e-06
-0.121825
-0.100346
-0.072251
-0.0482464
-0.029409
-0.01617
-0.00807289
-0.00362152
-0.00135777
-0.000280884
0.000168831
0.000312315
0.000320457
0.00027827
0.000221139
0.000168157
0.000119357
8.34713e-05
4.5999e-05
2.39653e-05
-0.147677
-0.117673
-0.0819528
-0.0516457
-0.0293292
-0.0146427
-0.00624108
-0.00197256
-5.39084e-05
0.000688737
0.000865854
0.000805631
0.000666537
0.000520233
0.000389063
0.000284381
0.000197154
0.000135155
7.39078e-05
3.77978e-05
-0.177856
-0.137826
-0.0932298
-0.0548931
-0.0286693
-0.012567
-0.00403047
-9.15115e-05
0.00137102
0.00171463
0.00158423
0.00130413
0.00101084
0.000758195
0.000552712
0.000397
0.000272056
0.000184965
0.000100465
5.13487e-05
-0.211135
-0.160461
-0.106013
-0.0576033
-0.0272383
-0.00984685
-0.00142782
0.00200475
0.00288997
0.00277342
0.00230604
0.00179535
0.00134488
0.000986518
0.000708323
0.000503548
0.00034242
0.000231928
0.000125011
6.45411e-05
-0.245156
-0.18393
-0.119552
-0.0591423
-0.0248142
-0.00635381
0.0015917
0.00431006
0.00448419
0.00384855
0.00301779
0.00226976
0.00166203
0.00120075
0.000852898
0.000601996
0.000406907
0.000275159
0.000147024
7.74092e-05
-0.275993
-0.204452
-0.131715
-0.0586355
-0.0212361
-0.00190934
0.00512007
0.00690496
0.00620593
0.00497652
0.00373961
0.00273828
0.00196734
0.00140312
0.000987259
0.000692424
0.000465455
0.000314279
0.000166333
9.04101e-05
-0.314729
-0.216997
-0.13928
-0.0548995
-0.0168737
0.00327671
0.00883003
0.00959783
0.00790969
0.0060798
0.00442288
0.00317484
0.00224486
0.00158465
0.00110572
0.000771869
0.000515815
0.000348904
0.000180922
0.000105316
-0.360112
-0.218052
-0.13836
-0.0489896
-0.0148433
0.00557615
0.00964517
0.0101058
0.00804364
0.00616965
0.00446391
0.00321984
0.00228134
0.0016186
0.00113144
0.000794392
0.000529313
0.000363934
0.000180609
0.0001175
-0.370042
-0.214313
-0.135405
-0.0454531
-0.0130292
0.00698347
0.0103299
0.0105224
0.00824158
0.00628366
0.00452188
0.0032549
0.0023018
0.00163215
0.00114015
0.000800662
0.000533097
0.000367348
0.000180946
0.000120207
-0.372404
-0.208264
-0.131162
-0.0414964
-0.0110048
0.00838457
0.0109841
0.0109083
0.00842338
0.00638799
0.00457445
0.00328614
0.00231976
0.00164387
0.00114777
0.000805993
0.000536535
0.00037008
0.000181626
0.000122316
-0.371801
-0.203156
-0.127663
-0.0381754
-0.00932786
0.00957478
0.0115291
0.0112367
0.00857679
0.00647828
0.00462053
0.00331441
0.00233645
0.00165506
0.00115515
0.000811206
0.000539907
0.000372758
0.000182327
0.000124321
-0.370179
-0.198577
-0.12448
-0.0350959
-0.00778968
0.0106906
0.0120339
0.0115449
0.00871914
0.00656279
0.00466349
0.00334107
0.00235225
0.00166572
0.00116218
0.0008162
0.000543107
0.000375348
0.000182947
0.000126269
-0.367769
-0.194107
-0.121294
-0.0320757
-0.00629098
0.0117755
0.0125189
0.0118422
0.008855
0.00664361
0.00470425
0.00336637
0.00236719
0.0016758
0.0011688
0.000820894
0.0005461
0.000377789
0.000183509
0.000128119
-0.364708
-0.189761
-0.118122
-0.029149
-0.0048463
0.0128162
0.0129784
0.012125
0.00898294
0.00671999
0.00474251
0.00339017
0.00238118
0.00168526
0.00117498
0.000825279
0.00054889
0.00038007
0.000184027
0.000129857
-0.361229
-0.185609
-0.115023
-0.0263574
-0.00347487
0.0138016
0.0134081
0.0123908
0.00910208
0.00679147
0.00477813
0.00341239
0.00239423
0.00169409
0.00118073
0.000829358
0.00055148
0.000382194
0.000184505
0.000131482
-0.357522
-0.181666
-0.112021
-0.0237168
-0.00218289
0.0147276
0.0138073
0.012639
0.00921232
0.00685795
0.00481107
0.003433
0.00240632
0.00170229
0.00118605
0.000833131
0.00055387
0.000384164
0.00018494
0.000132994
-0.353724
-0.177938
-0.109135
-0.021238
-0.000973983
0.0155911
0.0141758
0.0128692
0.00931364
0.00691934
0.00484134
0.00345198
0.00241744
0.00170985
0.00119093
0.000836594
0.000556058
0.000385977
0.000185335
0.00013439
-0.349938
-0.174434
-0.106389
-0.0189339
0.000147038
0.0163888
0.0145128
0.0130807
0.00940598
0.00697554
0.00486891
0.00346932
0.00242758
0.00171677
0.00119537
0.000839745
0.000558043
0.000387633
0.00018569
0.00013567
-0.346253
-0.171171
-0.103809
-0.0168176
0.00117482
0.0171172
0.0148179
0.013273
0.00948924
0.00702645
0.00489377
0.003485
0.00243674
0.00172304
0.00119938
0.000842581
0.000559826
0.000389131
0.000186007
0.000136831
-0.342749
-0.168171
-0.101425
-0.0149017
0.00210414
0.0177731
0.0150904
0.0134453
0.00956338
0.00707197
0.00491591
0.00349898
0.00244492
0.00172865
0.00120293
0.000845097
0.000561404
0.000390469
0.000186286
0.000137872
-0.339498
-0.165458
-0.0992645
-0.0131978
0.00293
0.0183537
0.0153299
0.0135973
0.00962834
0.00711201
0.00493531
0.00351124
0.0024521
0.0017336
0.00120604
0.000847292
0.000562777
0.000391646
0.000186526
0.000138791
-0.336567
-0.163059
-0.0973542
-0.0117164
0.00364773
0.0188562
0.015536
0.0137285
0.00968408
0.00714649
0.00495197
0.00352178
0.00245828
0.00173788
0.0012087
0.000849162
0.000563944
0.000392662
0.000186729
0.000139587
-0.334017
-0.161004
-0.0957195
-0.0104667
0.00425305
0.0192786
0.0157082
0.0138385
0.00973057
0.00717534
0.00496586
0.00353057
0.00246345
0.00174149
0.0012109
0.000850703
0.000564906
0.000393515
0.000186895
0.000140259
-0.331905
-0.159321
-0.0943829
-0.00945701
0.00474218
0.0196188
0.0158464
0.0139268
0.00976782
0.00719852
0.00497699
0.0035376
0.00246763
0.00174443
0.00121264
0.000851914
0.000565661
0.000394205
0.000187024
0.000140807
-0.330277
-0.158034
-0.0933634
-0.0086939
0.00511196
0.0198754
0.0159502
0.0139934
0.00979581
0.00721599
0.00498535
0.00354287
0.0024708
0.0017467
0.00121393
0.000852791
0.000566209
0.000394731
0.000187115
0.00014123
-0.32917
-0.157164
-0.0926756
-0.00818237
0.00535987
0.0200471
0.0160195
0.0140377
0.00981443
0.00722766
0.00499092
0.00354638
0.00247293
0.00174822
0.00121479
0.000853343
0.000566527
0.000395114
0.000187212
0.000141493
-0.328612
-0.156727
-0.09233
-0.007926
0.00548434
0.0201334
0.0160544
0.01406
0.00982384
0.00723367
0.0049938
0.00354824
0.00247405
0.00174897
0.00121528
0.000853596
0.000566598
0.000395381
0.000187366
0.000141563
)
;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
cylinder
{
type zeroGradient;
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"george.newman10@gmail.com"
] | george.newman10@gmail.com | |
caa111bf15ad0e40b7ca1310da3d3d08b5d2ec03 | d1e41c4cf7057237654125eb77547502ec2622af | /codeProjet/src/symboles/SymboleVar.hpp | f9105121cb79717c439115dedfc500833e0e275d | [] | no_license | juliansebline/PascalCompiler | 94941197f722d4b83ba272a1cf35291440ee1e56 | ba11f7dad3651b91bab5e0b3664ef59b04580ad7 | refs/heads/master | 2021-01-10T20:56:46.055413 | 2014-11-24T13:10:22 | 2014-11-24T13:10:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 541 | hpp | #ifndef SYMBOLEVAR_HPP
#define SYMBOLEVAR_HPP
#include "Symbole.hpp"
#include <map>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <unistd.h>
class SymboleVar : public Symbole {
private:
const char * _nomVar;
const char * _typeVar;
public:
SymboleVar();
virtual ~SymboleVar();
virtual const char *getNom();
virtual void setNom(const char *);
virtual void afficher();
virtual const char * getType();
void setType(const char *);
};
#endif
| [
"julian@localhost.localdomain"
] | julian@localhost.localdomain |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.