hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10fcb69233b3531647312d2f824d66dcc1921eda
| 337
|
hpp
|
C++
|
source/ashes/renderer/GlRenderer/Command/Commands/GlDrawIndirectCommand.hpp
|
DragonJoker/Ashes
|
a6ed950b3fd8fb9626c60b4291fbd52ea75ac66e
|
[
"MIT"
] | 227
|
2018-09-17T16:03:35.000Z
|
2022-03-19T02:02:45.000Z
|
source/ashes/renderer/GlRenderer/Command/Commands/GlDrawIndirectCommand.hpp
|
DragonJoker/RendererLib
|
0f8ad8edec1b0929ebd10247d3dd0a9ee8f8c91a
|
[
"MIT"
] | 39
|
2018-02-06T22:22:24.000Z
|
2018-08-29T07:11:06.000Z
|
source/ashes/renderer/GlRenderer/Command/Commands/GlDrawIndirectCommand.hpp
|
DragonJoker/Ashes
|
a6ed950b3fd8fb9626c60b4291fbd52ea75ac66e
|
[
"MIT"
] | 8
|
2019-05-04T10:33:32.000Z
|
2021-04-05T13:19:27.000Z
|
/*
This file belongs to Ashes.
See LICENSE file in root folder
*/
#pragma once
#include "renderer/GlRenderer/Command/Commands/GlCommandBase.hpp"
namespace ashes::gl
{
void buildDrawIndirectCommand( VkBuffer buffer
, VkDeviceSize offset
, uint32_t drawCount
, uint32_t stride
, VkPrimitiveTopology mode
, CmdList & list );
}
| 18.722222
| 65
| 0.756677
|
DragonJoker
|
10fd90847f0149ef1041ca034a8751cf0bc4150d
| 599
|
cc
|
C++
|
pixel-standalone/main_cuda.cc
|
lauracappelli/pixeltrack-standalone-test-oneapi
|
5832b6680ea0327f124afcfac801addbea458203
|
[
"Apache-2.0"
] | null | null | null |
pixel-standalone/main_cuda.cc
|
lauracappelli/pixeltrack-standalone-test-oneapi
|
5832b6680ea0327f124afcfac801addbea458203
|
[
"Apache-2.0"
] | null | null | null |
pixel-standalone/main_cuda.cc
|
lauracappelli/pixeltrack-standalone-test-oneapi
|
5832b6680ea0327f124afcfac801addbea458203
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
#include <memory>
#include "analyzer_cuda.h"
#include "input.h"
#include "modules.h"
#include "output.h"
int main(int argc, char** argv) {
Input input = read_input();
std::cout << "Got " << input.cablingMap.size << " for cabling, wordCounter " << input.wordCounter << std::endl;
std::unique_ptr<Output> output = std::make_unique<Output>();
double totaltime = 0;
cuda::analyze(input, *output, totaltime);
std::cout << "Output: " << countModules(output->moduleInd, input.wordCounter) << " modules in " << totaltime << " us"
<< std::endl;
return 0;
}
| 27.227273
| 119
| 0.647746
|
lauracappelli
|
800b89559fa8c25641afa66383c52d14fd764e4c
| 6,134
|
hpp
|
C++
|
firmware/library/L2_HAL/displays/oled/ssd1306.hpp
|
Adam-D-Sanchez/SJSU-Dev2
|
ecb5bb01912f6f85a76b6715d0e72f2d3062ceed
|
[
"Apache-2.0"
] | null | null | null |
firmware/library/L2_HAL/displays/oled/ssd1306.hpp
|
Adam-D-Sanchez/SJSU-Dev2
|
ecb5bb01912f6f85a76b6715d0e72f2d3062ceed
|
[
"Apache-2.0"
] | null | null | null |
firmware/library/L2_HAL/displays/oled/ssd1306.hpp
|
Adam-D-Sanchez/SJSU-Dev2
|
ecb5bb01912f6f85a76b6715d0e72f2d3062ceed
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <cstddef>
#include <cstdint>
#include "config.hpp"
#include "L1_Drivers/gpio.hpp"
#include "L1_Drivers/ssp.hpp"
#include "L2_HAL/displays/pixel_display.hpp"
#include "utility/log.hpp"
class Ssd1306 : public PixelDisplayInterface
{
public:
static constexpr size_t kColumns = 128;
static constexpr size_t kWidth = kColumns; // pixels
static constexpr size_t kColumnHeight = 8; // bits
static constexpr size_t kHeight = 64; // pixels
static constexpr size_t kPages = kHeight / kColumnHeight; // rows
static constexpr size_t kRows = kPages;
enum class Transaction
{
kCommand = 0,
kData = 1
};
constexpr Ssd1306()
: ssp_(&ssp1_),
cs_(&cs_gpio_),
dc_(&dc_gpio_),
ssp1_(Ssp::Peripheral::kSsp1),
cs_gpio_(1, 22),
dc_gpio_(1, 25),
bitmap_{}
{
}
constexpr Ssd1306(Ssp * ssp, Gpio * cs, Gpio * dc)
: ssp_(ssp),
cs_(cs),
dc_(dc),
ssp1_(),
cs_gpio_(1, 22),
dc_gpio_(1, 25),
bitmap_{}
{
}
size_t GetWidth() final override
{
return kWidth;
}
size_t GetHeight() final override
{
return kHeight;
}
Color_t AvailableColors() final override
{
return Color_t(/* Red = */ 1,
/* Green = */ 1,
/* Blue = */ 1,
/* Alpha = */ 1,
/* Color Bits = */ 1,
/* Monochrome = */ true);
}
void Write(uint32_t data, Transaction transaction, size_t size = 1)
{
dc_->Set(static_cast<Gpio::State>(transaction));
cs_->SetLow();
for (size_t i = 0; i < size; i++)
{
uint8_t send = static_cast<uint8_t>(data >> (((size - 1) - i) * 8));
if (transaction == Transaction::kCommand)
{
LOG_DEBUG("send = 0x%X", send);
}
ssp_->Transfer(send);
}
cs_->SetHigh();
}
void InitializationPanel()
{
// This sequence of commands was found in:
// datasheets/OLED-display/ER-OLED0.96-1_Series_Datasheet.pdf, page 15
// turn off oled panel
Write(0xAE, Transaction::kCommand);
// set display clock divide ratio/oscillator frequency
// set divide ratio
Write(0xD5'80, Transaction::kCommand, 2);
// set multiplex ratio(1 to 64)
// 1/64 duty
Write(0xA8'3F, Transaction::kCommand, 2);
// set display offset = not offset
Write(0xD3'00, Transaction::kCommand, 2);
// Set display start line
Write(0x40, Transaction::kCommand);
// Disable Charge Pump
Write(0x8D'14, Transaction::kCommand, 2);
// set segment re-map 128 to 0
Write(0xA1, Transaction::kCommand);
// Set COM Output Scan Direction 64 to 0
Write(0xC8, Transaction::kCommand);
// set com pins hardware configuration
Write(0xDA'12, Transaction::kCommand, 2);
// set contrast control register
Write(0x81'CF, Transaction::kCommand, 2);
// Set pre-charge period
Write(0xD9'F1, Transaction::kCommand, 2);
// Set Vcomh
Write(0xDB'40, Transaction::kCommand, 2);
SetHorizontalAddressMode();
// Enable entire display
Write(0xA4, Transaction::kCommand);
// Set display to normal colors
Write(0xA6, Transaction::kCommand);
// Set Display On
Write(0xAF, Transaction::kCommand);
}
void Initialize() final override
{
cs_->SetAsOutput();
dc_->SetAsOutput();
cs_->SetHigh();
dc_->SetHigh();
ssp_->SetPeripheralMode(Ssp::MasterSlaveMode::kMaster, Ssp::FrameMode::kSpi,
Ssp::DataSize::kEight);
// Set speed to 1Mhz by dividing by 1 * ClockFrequencyInMHz.
ssp_->SetClock(false, false, 100, config::kSystemClockRateMhz);
ssp_->Initialize();
Clear();
InitializationPanel();
}
void SetHorizontalAddressMode()
{
// Set Addressing mode
// Addressing mode = Horizontal Mode (0b00)
Write(0x20'00, Transaction::kCommand, 2);
// Set Column Addresses
// Set Column Address start = Column 0
// Set Column Address start = Column 127
Write(0x21'00'7F, Transaction::kCommand, 3);
// Set Page Addresses
// Set Page Address start = Page 0
// Set Page Address start = Page 7
Write(0x22'00'07, Transaction::kCommand, 3);
}
/// Clears the internal bitmap_ to zero (or a user defined clear_value)
void Clear() final override
{
memset(bitmap_, 0x00, sizeof(bitmap_));
}
void Fill()
{
memset(bitmap_, 0xFF, sizeof(bitmap_));
}
void DrawPixel(int32_t x, int32_t y, Color_t color) final override
{
// The 3 least significant bits hold the bit position within the byte
uint32_t bit_position = y & 0b111;
// Each byte makes up a vertical column.
// Shifting by 3, which also divides by 8 (the 8-bits of a column), will
// be the row that we need to edit.
uint32_t row = y >> 3;
// Mask to clear the bit
uint32_t clear_mask = ~(1 << bit_position);
// Mask to set the bit, if color.alpha != 0
bool pixel_is_on = (color.alpha != 0);
uint32_t set_mask = pixel_is_on << bit_position;
// Address of the pixel column to edit
uint8_t * pixel_column = &(bitmap_[row][x]);
// Read pixel column and update the pixel
uint32_t result = (*pixel_column & clear_mask) | set_mask;
// Update pixel with the result of this operation
*pixel_column = static_cast<uint8_t>(result);
}
/// Writes internal bitmap_ to the screen
void Update() final override
{
SetHorizontalAddressMode();
for (size_t row = 0; row < kRows; row++)
{
for (size_t column = 0; column < kColumns; column++)
{
Write(bitmap_[row][column], Transaction::kData);
}
}
}
void InvertScreenColor() __attribute__((used))
{
Write(0xA7, Transaction::kCommand);
}
void NormalScreenColor() __attribute__((used))
{
Write(0xA6, Transaction::kCommand);
}
private:
Ssp * ssp_;
Gpio * cs_;
Gpio * dc_;
Ssp ssp1_;
Gpio cs_gpio_;
Gpio dc_gpio_;
uint8_t bitmap_[kRows + 5][kColumns + 5];
};
| 26.669565
| 80
| 0.610205
|
Adam-D-Sanchez
|
800dde40d565d7c0a93918f0b54ebdc223576c86
| 864
|
cpp
|
C++
|
source/FAST/Examples/DataImport/clariusStreaming.cpp
|
andreped/FAST
|
361819190ea0ae5a2f068e7bd808a1c70af5a171
|
[
"BSD-2-Clause"
] | null | null | null |
source/FAST/Examples/DataImport/clariusStreaming.cpp
|
andreped/FAST
|
361819190ea0ae5a2f068e7bd808a1c70af5a171
|
[
"BSD-2-Clause"
] | null | null | null |
source/FAST/Examples/DataImport/clariusStreaming.cpp
|
andreped/FAST
|
361819190ea0ae5a2f068e7bd808a1c70af5a171
|
[
"BSD-2-Clause"
] | null | null | null |
/**
* @example clariusStreaming.cpp
*/
#include <FAST/Streamers/ClariusStreamer.hpp>
#include <FAST/Visualization/SimpleWindow.hpp>
#include <FAST/Visualization/ImageRenderer/ImageRenderer.hpp>
#include <FAST/Tools/CommandLineParser.hpp>
using namespace fast;
int main(int argc, char**argv) {
CommandLineParser parser("Clarius streaming example");
parser.addVariable("port", "5858", "Port to use for clarius connection");
parser.addVariable("ip", "192.168.1.1", "Address to use for clarius connection");
parser.parse(argc, argv);
auto streamer = ClariusStreamer::create(parser.get("ip"), parser.get<int>("port"));
auto renderer = ImageRenderer::create()
->connect(streamer);
auto window = SimpleWindow2D::create()
->connect(renderer);
window->getView()->setAutoUpdateCamera(true);
window->run();
}
| 33.230769
| 87
| 0.701389
|
andreped
|
801015bf1c7bc7153e57400a0fa9be4abb286cd6
| 4,199
|
cc
|
C++
|
plugins/src/PairConvFilter.cc
|
omar-moreno/simulation-formerly-known-as-slic
|
331d0452d05762e2f4554f0ace6fe46922a7333c
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
plugins/src/PairConvFilter.cc
|
omar-moreno/simulation-formerly-known-as-slic
|
331d0452d05762e2f4554f0ace6fe46922a7333c
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
plugins/src/PairConvFilter.cc
|
omar-moreno/simulation-formerly-known-as-slic
|
331d0452d05762e2f4554f0ace6fe46922a7333c
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
#include "PairConvFilter.hh"
//------------//
// Geant4 //
//------------//
#include "G4RunManager.hh"
namespace slic {
G4ClassificationOfNewTrack PairConvFilter::stackingClassifyNewTrack(
const G4Track *track, const G4ClassificationOfNewTrack ¤tTrackClass) {
if (track == currentTrack_) {
currentTrack_ = nullptr;
// std::cout << "[ PairConvFilter ]: Pushing track to waiting stack."
// << std::endl;
return fWaiting;
}
// Use current classification by default so values from other plugins are
// not overridden.
return currentTrackClass;
}
void PairConvFilter::stepping(const G4Step *step) {
if (hasPairConv_) return;
// Get the track associated with this step.
auto track{step->GetTrack()};
// Get the particle type.
auto particleName{track->GetParticleDefinition()->GetParticleName()};
// Get the kinetic energy of the particle.
auto incidentParticleEnergy{step->GetPostStepPoint()->GetTotalEnergy()};
auto pdgID{track->GetParticleDefinition()->GetPDGEncoding()};
// Get the volume the particle is in.
auto volume{track->GetVolume()};
auto volumeName{volume->GetName()};
/*
std::cout << "*******************************" << std::endl;
std::cout << "* Step " << track->GetCurrentStepNumber() << std::endl;
std::cout << "********************************\n"
<< "\tTotal energy of " << particleName << " ( PDG ID: " << pdgID
<< " ) : " << incidentParticleEnergy << " MeV\n"
<< "\tTrack ID: " << track->GetTrackID() << "\n"
<< "\tParticle currently in " << volumeName << "\n"
<< "\tPost step process: "
<< step->GetPostStepPoint()->GetStepStatus() << std::endl;*/
// Get the PDG ID of the track and make sure it's a photon. If another
// particle type is found, push it to the waiting stack until the photon has
// been processed.
if (pdgID != 22) {
currentTrack_ = track;
track->SetTrackStatus(fSuspend);
return;
}
// Only conversions that happen in the target, and layers 1-3
// of the tracker are of interest. If the photon has propagated past
// the second layer and didn't convert, kill the event.
// TODO: OM: This really should be done with regions.
if (volumeName.find("module_L4") != std::string::npos) {
// std::cout << "[ PairConvFilter ]: Photon is beyond the sensitive"
// << " detectors of interest. Killing event." << std::endl;
track->SetTrackStatus(fKillTrackAndSecondaries);
G4RunManager::GetRunManager()->AbortEvent();
return;
} else if ((volumeName.find("module_L1") == std::string::npos) &&
(volumeName.find("module_L2") == std::string::npos) &&
(volumeName.find("module_L3") == std::string::npos)) {
// std::cout << "[ PairConvFilter ]: Photon is not within sensitive "
// << " detectors of interest." << std::endl;
return;
}
// Check if any secondaries were produced in the volume.
const std::vector<const G4Track *> *secondaries =
step->GetSecondaryInCurrentStep();
// std::cout << "[ PairConvFilter ]: "
// << particleName << " produced " << secondaries->size()
// << " secondaries." << std::endl;
// If the particle didn't produce any secondaries, stop processing
// the event.
if (secondaries->size() == 0) {
// std::cout << "[ PairConvFilter ]: "
// << "Primary did not produce secondaries!"
// << std::endl;
return;
}
auto processName{(*secondaries)[0]->GetCreatorProcess()->GetProcessName()};
if (processName.compareTo("conv") == 0) {
hasPairConv_ = true;
++pairConvCount_;
std::cout << "[ PairConvFilter ]: "
<< "WAB converted in " << volumeName << std::endl;
} else {
track->SetTrackStatus(fKillTrackAndSecondaries);
G4RunManager::GetRunManager()->AbortEvent();
return;
}
}
void PairConvFilter::endEvent(const G4Event *) { hasPairConv_ = false; }
void PairConvFilter::endRun(const G4Run *run) {
std::cout << "[ PairConvFilter ]: "
<< "Total number of pair conversions: " << pairConvCount_
<< std::endl;
}
} // namespace slic
DECLARE_PLUGIN(slic, PairConvFilter)
| 34.418033
| 80
| 0.618242
|
omar-moreno
|
80113427fd80ee179df6ecd8a9649896a9ca6f07
| 413
|
cc
|
C++
|
sentinel-core/test/mock/flow/mock.cc
|
windrunner123/sentinel-cpp
|
7957e692466db0b7b83b7218602757113e9f2d22
|
[
"Apache-2.0"
] | 121
|
2019-02-22T06:50:31.000Z
|
2022-01-22T23:23:42.000Z
|
sentinel-core/test/mock/flow/mock.cc
|
windrunner123/sentinel-cpp
|
7957e692466db0b7b83b7218602757113e9f2d22
|
[
"Apache-2.0"
] | 24
|
2019-05-07T08:58:38.000Z
|
2022-01-26T02:36:06.000Z
|
sentinel-core/test/mock/flow/mock.cc
|
windrunner123/sentinel-cpp
|
7957e692466db0b7b83b7218602757113e9f2d22
|
[
"Apache-2.0"
] | 36
|
2019-03-19T09:46:08.000Z
|
2021-11-24T13:20:56.000Z
|
#include "sentinel-core/test/mock/flow/mock.h"
namespace Sentinel {
namespace Flow {
MockTrafficShapingChecker::MockTrafficShapingChecker() = default;
MockTrafficShapingChecker::~MockTrafficShapingChecker() = default;
MockTrafficShapingCalculator::MockTrafficShapingCalculator() = default;
MockTrafficShapingCalculator::~MockTrafficShapingCalculator() = default;
} // namespace Flow
} // namespace Sentinel
| 29.5
| 72
| 0.813559
|
windrunner123
|
80135360f9ed8dac2676aee65e4550af78b0ca6b
| 6,104
|
cpp
|
C++
|
build/qCC/CloudCompare_autogen/include_Debug/EWIEGA46WW/moc_ccOverlayDialog.cpp
|
ohanlonl/qCMAT
|
f6ca04fa7c171629f094ee886364c46ff8b27c0b
|
[
"BSD-Source-Code"
] | null | null | null |
build/qCC/CloudCompare_autogen/include_Debug/EWIEGA46WW/moc_ccOverlayDialog.cpp
|
ohanlonl/qCMAT
|
f6ca04fa7c171629f094ee886364c46ff8b27c0b
|
[
"BSD-Source-Code"
] | null | null | null |
build/qCC/CloudCompare_autogen/include_Debug/EWIEGA46WW/moc_ccOverlayDialog.cpp
|
ohanlonl/qCMAT
|
f6ca04fa7c171629f094ee886364c46ff8b27c0b
|
[
"BSD-Source-Code"
] | 1
|
2019-02-03T12:19:42.000Z
|
2019-02-03T12:19:42.000Z
|
/****************************************************************************
** Meta object code from reading C++ file 'ccOverlayDialog.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.11.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../../../qCC/ccOverlayDialog.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ccOverlayDialog.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.11.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_ccOverlayDialog_t {
QByteArrayData data[9];
char stringdata0[100];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_ccOverlayDialog_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_ccOverlayDialog_t qt_meta_stringdata_ccOverlayDialog = {
{
QT_MOC_LITERAL(0, 0, 15), // "ccOverlayDialog"
QT_MOC_LITERAL(1, 16, 15), // "processFinished"
QT_MOC_LITERAL(2, 32, 0), // ""
QT_MOC_LITERAL(3, 33, 8), // "accepted"
QT_MOC_LITERAL(4, 42, 17), // "shortcutTriggered"
QT_MOC_LITERAL(5, 60, 3), // "key"
QT_MOC_LITERAL(6, 64, 5), // "shown"
QT_MOC_LITERAL(7, 70, 22), // "onLinkedWindowDeletion"
QT_MOC_LITERAL(8, 93, 6) // "object"
},
"ccOverlayDialog\0processFinished\0\0"
"accepted\0shortcutTriggered\0key\0shown\0"
"onLinkedWindowDeletion\0object"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_ccOverlayDialog[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
5, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
3, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 39, 2, 0x06 /* Public */,
4, 1, 42, 2, 0x06 /* Public */,
6, 0, 45, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
7, 1, 46, 2, 0x09 /* Protected */,
7, 0, 49, 2, 0x29 /* Protected | MethodCloned */,
// signals: parameters
QMetaType::Void, QMetaType::Bool, 3,
QMetaType::Void, QMetaType::Int, 5,
QMetaType::Void,
// slots: parameters
QMetaType::Void, QMetaType::QObjectStar, 8,
QMetaType::Void,
0 // eod
};
void ccOverlayDialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
ccOverlayDialog *_t = static_cast<ccOverlayDialog *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->processFinished((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 1: _t->shortcutTriggered((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: _t->shown(); break;
case 3: _t->onLinkedWindowDeletion((*reinterpret_cast< QObject*(*)>(_a[1]))); break;
case 4: _t->onLinkedWindowDeletion(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (ccOverlayDialog::*)(bool );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ccOverlayDialog::processFinished)) {
*result = 0;
return;
}
}
{
using _t = void (ccOverlayDialog::*)(int );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ccOverlayDialog::shortcutTriggered)) {
*result = 1;
return;
}
}
{
using _t = void (ccOverlayDialog::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ccOverlayDialog::shown)) {
*result = 2;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject ccOverlayDialog::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_ccOverlayDialog.data,
qt_meta_data_ccOverlayDialog, qt_static_metacall, nullptr, nullptr}
};
const QMetaObject *ccOverlayDialog::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *ccOverlayDialog::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_ccOverlayDialog.stringdata0))
return static_cast<void*>(this);
return QDialog::qt_metacast(_clname);
}
int ccOverlayDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 5)
qt_static_metacall(this, _c, _id, _a);
_id -= 5;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 5)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 5;
}
return _id;
}
// SIGNAL 0
void ccOverlayDialog::processFinished(bool _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void ccOverlayDialog::shortcutTriggered(int _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
// SIGNAL 2
void ccOverlayDialog::shown()
{
QMetaObject::activate(this, &staticMetaObject, 2, nullptr);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| 33.723757
| 106
| 0.589613
|
ohanlonl
|
8015799e7c2ea7a9160385aaf2808ed69370238e
| 1,708
|
cpp
|
C++
|
jni/application/Crosshair.cpp
|
clarkdonald/eecs494explore3d
|
fd4086d2c5482a289d51ef71c5f1ae20347db80a
|
[
"BSD-2-Clause"
] | null | null | null |
jni/application/Crosshair.cpp
|
clarkdonald/eecs494explore3d
|
fd4086d2c5482a289d51ef71c5f1ae20347db80a
|
[
"BSD-2-Clause"
] | null | null | null |
jni/application/Crosshair.cpp
|
clarkdonald/eecs494explore3d
|
fd4086d2c5482a289d51ef71c5f1ae20347db80a
|
[
"BSD-2-Clause"
] | null | null | null |
//
// Crosshair.cpp
// game
//
// Created by Donald Clark on 10/27/13.
//
//
#include "Crosshair.h"
#include "Utility.h"
#include "Player.h"
#include <zenilib.h>
using namespace Zeni;
Crosshair::Crosshair()
: radius(25.0f)
{}
Crosshair::~Crosshair() {}
void Crosshair::render(const bool &is_wielding_weapon, Player* player) {
String texture = is_wielding_weapon ? "weapon_crosshair" : "normal_crosshair";
float center_x = VIDEO_DIMENSION.second.x/2;
float center_y = VIDEO_DIMENSION.second.y/2;
render_image(texture,
Point2f(center_x-radius, center_y-radius),
Point2f(center_x+radius, center_y+radius));
//render the hearts
float x_val = 0.0f;
int k;
for(k = 0; k < player->get_health(); k++){
render_image("filled_heart", Point2f(x_val, 0.0f), Point2f(x_val + 32.0f, 32.0f));
x_val += 32.0f;
}
while(k < 5){
render_image("empty_heart", Point2f(x_val, 0.0f), Point2f(x_val + 32.0f, 32.0f));
x_val += 32;
k++;
}
x_val = 0;
if(player -> can_lift()){
render_image("yellow_pill", Point2f(x_val, 32.0f), Point2f(x_val + 32.0f, 64.0f));
x_val += 32;
}
if(player -> can_walk_through_fire()){
render_image("blue_pill", Point2f(x_val, 32.0f), Point2f(x_val + 32.0f, 64.0f));
x_val += 32;
}
if(player -> can_walk_through_terrain()){
render_image("white_pill", Point2f(x_val, 32.0f), Point2f(x_val + 32.0f, 64.0f));
x_val += 32;
}
if(player -> can_jump()){
render_image("green_pill", Point2f(x_val, 32.0f), Point2f(x_val + 32.0f, 64.0f));
x_val += 32;
}
if(player -> is_lifting_terrain()){
render_image("CRATE.PNG", Point2f(x_val, 32.0f), Point2f(x_val + 32.0f, 64.0f));
x_val += 32;
}
}
| 26.276923
| 86
| 0.641101
|
clarkdonald
|
801ff9d16ae2b4b5dc73660bd69ff45251b5c18d
| 93
|
cpp
|
C++
|
keyword/extern/main.cpp
|
learnMachining/cplus2test
|
8cc0048627724bb967f27d5cd9860dbb5804a7d9
|
[
"Apache-2.0"
] | null | null | null |
keyword/extern/main.cpp
|
learnMachining/cplus2test
|
8cc0048627724bb967f27d5cd9860dbb5804a7d9
|
[
"Apache-2.0"
] | null | null | null |
keyword/extern/main.cpp
|
learnMachining/cplus2test
|
8cc0048627724bb967f27d5cd9860dbb5804a7d9
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
using namespace std;
extern double PI;
int main() {
cout<<PI<<endl;
}
| 10.333333
| 20
| 0.677419
|
learnMachining
|
80218a628bb37821b34b2d14050b4b3d67a7a68e
| 8,076
|
cpp
|
C++
|
Code/WolfEngine/Math/Matrix.cpp
|
Wolfos/WolfEngine
|
8034c2f5456c34b59be68f2855d4a6cab3b829f2
|
[
"Apache-2.0"
] | 4
|
2015-01-09T00:11:54.000Z
|
2021-03-29T13:17:24.000Z
|
Code/WolfEngine/Math/Matrix.cpp
|
Wolfos/WolfEngine
|
8034c2f5456c34b59be68f2855d4a6cab3b829f2
|
[
"Apache-2.0"
] | 2
|
2015-01-28T14:06:39.000Z
|
2017-08-02T06:54:34.000Z
|
Code/WolfEngine/Math/Matrix.cpp
|
Wolfos/WolfEngine
|
8034c2f5456c34b59be68f2855d4a6cab3b829f2
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by Robin on 01/01/2018.
//
#include "Matrix.h"
#include <cstring>
#include "WolfMath.h"
Matrix::Matrix()
{
SetIdentity();
}
const float* Matrix::GetData() const
{
return data;
}
void Matrix::SetIdentity()
{
memset(data, 0, sizeof(float) * 16);
data[0] = 1;
data[5] = 1;
data[10] = 1;
data[15] = 1;
}
void Matrix::SetPerspective(float angle, float aspect, float clipMin, float clipMax)
{
float tangent = WolfMath::Tan(WolfMath::DegToRad(angle / 2));
memset(data, 0, sizeof(float) * 16);
data[0] = 0.5f / tangent;
data[5] = 0.5f * aspect / tangent;
data[10] = -(clipMax + clipMin) / (clipMax - clipMin);
data[11] = -1;
data[14] = (-2 * clipMax * clipMin) / (clipMax - clipMin);
}
void Matrix::SetOrtho(float left, float right, float top, float bottom, float clipMin, float clipMax)
{
memset(data, 0, sizeof(float) * 16);
data[0] = 2 / (right - left);
data[5] = 2 / (bottom - top);
data[10] = -2 / (clipMax - clipMin);
data[15] = 1;
}
void Matrix::ViewInverse()
{
data[0] = -data[0];
data[1] = -data[1];
data[2] = -data[2];
data[4] = -data[4];
data[5] = -data[5];
data[6] = -data[6];
data[8] = -data[8];
data[9] = -data[9];
data[10] = -data[10];
data[12] = -data[12];
data[13] = -data[13];
data[14] = -data[14];
}
void Matrix::Invert()
{
Matrix temp;
float det;
int i;
temp.data[0] = data[5] * data[10] * data[15] -
data[5] * data[11] * data[14] -
data[9] * data[6] * data[15] +
data[9] * data[7] * data[14] +
data[13] * data[6] * data[11] -
data[13] * data[7] * data[10];
temp.data[4] = -data[4] * data[10] * data[15] +
data[4] * data[11] * data[14] +
data[8] * data[6] * data[15] -
data[8] * data[7] * data[14] -
data[12] * data[6] * data[11] +
data[12] * data[7] * data[10];
temp.data[8] = data[4] * data[9] * data[15] -
data[4] * data[11] * data[13] -
data[8] * data[5] * data[15] +
data[8] * data[7] * data[13] +
data[12] * data[5] * data[11] -
data[12] * data[7] * data[9];
temp.data[12] = -data[4] * data[9] * data[14] +
data[4] * data[10] * data[13] +
data[8] * data[5] * data[14] -
data[8] * data[6] * data[13] -
data[12] * data[5] * data[10] +
data[12] * data[6] * data[9];
temp.data[1] = -data[1] * data[10] * data[15] +
data[1] * data[11] * data[14] +
data[9] * data[2] * data[15] -
data[9] * data[3] * data[14] -
data[13] * data[2] * data[11] +
data[13] * data[3] * data[10];
temp.data[5] = data[0] * data[10] * data[15] -
data[0] * data[11] * data[14] -
data[8] * data[2] * data[15] +
data[8] * data[3] * data[14] +
data[12] * data[2] * data[11] -
data[12] * data[3] * data[10];
temp.data[9] = -data[0] * data[9] * data[15] +
data[0] * data[11] * data[13] +
data[8] * data[1] * data[15] -
data[8] * data[3] * data[13] -
data[12] * data[1] * data[11] +
data[12] * data[3] * data[9];
temp.data[13] = data[0] * data[9] * data[14] -
data[0] * data[10] * data[13] -
data[8] * data[1] * data[14] +
data[8] * data[2] * data[13] +
data[12] * data[1] * data[10] -
data[12] * data[2] * data[9];
temp.data[2] = data[1] * data[6] * data[15] -
data[1] * data[7] * data[14] -
data[5] * data[2] * data[15] +
data[5] * data[3] * data[14] +
data[13] * data[2] * data[7] -
data[13] * data[3] * data[6];
temp.data[6] = -data[0] * data[6] * data[15] +
data[0] * data[7] * data[14] +
data[4] * data[2] * data[15] -
data[4] * data[3] * data[14] -
data[12] * data[2] * data[7] +
data[12] * data[3] * data[6];
temp.data[10] = data[0] * data[5] * data[15] -
data[0] * data[7] * data[13] -
data[4] * data[1] * data[15] +
data[4] * data[3] * data[13] +
data[12] * data[1] * data[7] -
data[12] * data[3] * data[5];
temp.data[14] = -data[0] * data[5] * data[14] +
data[0] * data[6] * data[13] +
data[4] * data[1] * data[14] -
data[4] * data[2] * data[13] -
data[12] * data[1] * data[6] +
data[12] * data[2] * data[5];
temp.data[3] = -data[1] * data[6] * data[11] +
data[1] * data[7] * data[10] +
data[5] * data[2] * data[11] -
data[5] * data[3] * data[10] -
data[9] * data[2] * data[7] +
data[9] * data[3] * data[6];
temp.data[7] = data[0] * data[6] * data[11] -
data[0] * data[7] * data[10] -
data[4] * data[2] * data[11] +
data[4] * data[3] * data[10] +
data[8] * data[2] * data[7] -
data[8] * data[3] * data[6];
temp.data[11] = -data[0] * data[5] * data[11] +
data[0] * data[7] * data[9] +
data[4] * data[1] * data[11] -
data[4] * data[3] * data[9] -
data[8] * data[1] * data[7] +
data[8] * data[3] * data[5];
temp.data[15] = data[0] * data[5] * data[10] -
data[0] * data[6] * data[9] -
data[4] * data[1] * data[10] +
data[4] * data[2] * data[9] +
data[8] * data[1] * data[6] -
data[8] * data[2] * data[5];
det = data[0] * temp.data[0] + data[1] * temp.data[4] + data[2] * temp.data[8] + data[3] * temp.data[12];
if (det == 0) return;
det = 1.0 / det;
for (i = 0; i < 16; i++)
data[i] = temp.data[i] * det;
}
void Matrix::Translate(Vector3<float> direction)
{
data[12] += direction.x;
data[13] += direction.y;
data[14] += direction.z;
}
void Matrix::Scale(Vector3<float> scale)
{
data[0] = scale.x;
data[5] = scale.y;
data[10] = scale.z;
}
Matrix Matrix::operator * (const Matrix& m) const {
Matrix ret;
ret.data[0] = ((data[0]*m.data[0])+(data[1]*m.data[4])+(data[2]*m.data[8])+(data[3]*m.data[12]));
ret.data[1] = ((data[0]*m.data[1])+(data[1]*m.data[5])+(data[2]*m.data[9])+(data[3]*m.data[13]));
ret.data[2] = ((data[0]*m.data[2])+(data[1]*m.data[6])+(data[2]*m.data[10])+(data[3]*m.data[14]));
ret.data[3] = ((data[0]*m.data[3])+(data[1]*m.data[7])+(data[2]*m.data[11])+(data[3]*m.data[15]));
ret.data[4] = ((data[4]*m.data[0])+(data[5]*m.data[4])+(data[6]*m.data[8])+(data[7]*m.data[12]));
ret.data[5] = ((data[4]*m.data[1])+(data[5]*m.data[5])+(data[6]*m.data[9])+(data[7]*m.data[13]));
ret.data[6] = ((data[4]*m.data[2])+(data[5]*m.data[6])+(data[6]*m.data[10])+(data[7]*m.data[14]));
ret.data[7] = ((data[4]*m.data[3])+(data[5]*m.data[7])+(data[6]*m.data[11])+(data[7]*m.data[15]));
ret.data[8] = ((data[8]*m.data[0])+(data[9]*m.data[4])+(data[10]*m.data[8])+(data[11]*m.data[12]));
ret.data[9] = ((data[8]*m.data[1])+(data[9]*m.data[5])+(data[10]*m.data[9])+(data[11]*m.data[13]));
ret.data[10] = ((data[8]*m.data[2])+(data[9]*m.data[6])+(data[10]*m.data[10])+(data[11]*m.data[14]));
ret.data[11] = ((data[8]*m.data[3])+(data[9]*m.data[7])+(data[10]*m.data[11])+(data[11]*m.data[15]));
ret.data[12] = ((data[12]*m.data[0])+(data[13]*m.data[4])+(data[14]*m.data[8])+(data[15]*m.data[12]));
ret.data[13] = ((data[12]*m.data[1])+(data[13]*m.data[5])+(data[14]*m.data[9])+(data[15]*m.data[13]));
ret.data[14] = ((data[12]*m.data[2])+(data[13]*m.data[6])+(data[14]*m.data[10])+(data[15]*m.data[14]));
ret.data[15] = ((data[12]*m.data[3])+(data[13]*m.data[7])+(data[14]*m.data[11])+(data[15]*m.data[15]));
return ret;
}
void Matrix::FromQuat(Quaternion *q, Vector3<float> pivot)
{
SetIdentity();
float sqw = q->w*q->w;
float sqx = q->x*q->x;
float sqy = q->y*q->y;
float sqz = q->z*q->z;
data[0] = sqx - sqy - sqz + sqw; // since sqw + sqx + sqy + sqz =1
data[5] = -sqx + sqy - sqz + sqw;
data[10] = -sqx - sqy + sqz + sqw;
float tmp1 = q->x*-q->y;
float tmp2 = q->z*q->w;
data[4] = 2 * (tmp1 + tmp2);
data[1] = 2 * (tmp1 - tmp2);
tmp1 = q->x*q->z;
tmp2 = q->y*q->w;
data[8] = 2 * (tmp1 - tmp2);
data[2] = 2 * (tmp1 + tmp2);
tmp1 = q->y*q->z;
tmp2 = q->x*q->w;
data[9] = 2 * (tmp1 + tmp2);
data[6] = 2 * (tmp1 - tmp2);
float a1 = pivot.x;
float a2 = pivot.y;
float a3 = pivot.z;
data[12] = a1 - a1 * data[0] - a2 * data[4] - a3 * data[8];
data[13] = a2 - a1 * data[1] - a2 * data[5] - a3 * data[9];
data[14] = a3 - a1 * data[2] - a2 * data[6] - a3 * data[10];
data[3] = data[7] = data[11] = 0.0;
data[15] = 1.0;
}
| 29.911111
| 106
| 0.516097
|
Wolfos
|
8022e8f3acdb43eec1bf00a7fdde581e3651bf66
| 3,544
|
cpp
|
C++
|
tests/nameof.cpp
|
RodrigoHolztrattner/ctti
|
b4d5dc59a412c1dc28dd4480df28cb20e7fffcb1
|
[
"MIT"
] | 471
|
2015-08-05T04:20:11.000Z
|
2022-03-17T10:10:28.000Z
|
tests/nameof.cpp
|
RodrigoHolztrattner/ctti
|
b4d5dc59a412c1dc28dd4480df28cb20e7fffcb1
|
[
"MIT"
] | 31
|
2015-08-05T18:35:17.000Z
|
2021-07-09T13:13:39.000Z
|
tests/nameof.cpp
|
RodrigoHolztrattner/ctti
|
b4d5dc59a412c1dc28dd4480df28cb20e7fffcb1
|
[
"MIT"
] | 51
|
2015-08-05T13:43:46.000Z
|
2021-11-30T13:09:25.000Z
|
#include <ctti/nameof.hpp>
#include "catch.hpp"
using namespace ctti;
namespace foo
{
struct Foo {};
namespace bar
{
struct Bar {};
}
inline namespace inline_quux
{
struct Quux {};
}
}
namespace bar
{
struct Bar {};
constexpr ctti::detail::cstring ctti_nameof(ctti::type_tag<Bar>)
{
return "Bar"; // without namespace
}
enum class Enum
{
A, B, C
};
constexpr ctti::detail::cstring ctti_nameof(CTTI_STATIC_VALUE(Enum::C))
{
return "Enum::Si";
}
}
class MyClass
{
public:
class InnerClass {};
};
struct MyStruct
{
struct InnerStruct {};
};
enum ClassicEnum { A, B, C };
enum class EnumClass { A, B, C };
TEST_CASE("nameof")
{
SECTION("basic types")
{
REQUIRE(nameof<int>() == "int");
REQUIRE(nameof<bool>() == "bool");
REQUIRE(nameof<char>() == "char");
REQUIRE(nameof<void>() == "void");
}
SECTION("class types")
{
REQUIRE(nameof<MyClass>() == "MyClass");
REQUIRE(nameof<MyClass::InnerClass>() == "MyClass::InnerClass");
}
SECTION("struct types")
{
REQUIRE(nameof<MyStruct>() == "MyStruct");
REQUIRE(nameof<MyStruct::InnerStruct>() == "MyStruct::InnerStruct");
}
SECTION("enum types")
{
REQUIRE(nameof<ClassicEnum>() == "ClassicEnum");
REQUIRE(nameof<EnumClass>() == "EnumClass");
}
SECTION("with namespaces")
{
REQUIRE(nameof<foo::Foo>() == "foo::Foo");
REQUIRE(nameof<foo::bar::Bar>() == "foo::bar::Bar");
SECTION("inline namespaces")
{
REQUIRE(nameof<foo::inline_quux::Quux>() == "foo::inline_quux::Quux");
REQUIRE(nameof<foo::Quux>() == "foo::inline_quux::Quux");
}
SECTION("std")
{
REQUIRE(nameof<std::string>() == "std::string");
}
}
SECTION("with custom ctti_nameof()")
{
SECTION("intrusive customize")
{
struct Foo
{
static constexpr const char* ctti_nameof()
{
return "Foobar";
}
};
REQUIRE(nameof<Foo>() == "Foobar");
}
SECTION("non-intrusive customize")
{
REQUIRE(nameof<bar::Bar>() == "Bar");
REQUIRE(nameof<CTTI_STATIC_VALUE(bar::Enum::C)>() == "Enum::Si");
}
}
#ifdef CTTI_HAS_VARIABLE_TEMPLATES
SECTION("variable templates")
{
REQUIRE(ctti::nameof_v<int> == nameof<int>());
REQUIRE(ctti::nameof_value_v<int, 42> == nameof<int, 42>());
}
#endif // CTTI_HAS_VARIABLE_TEMPLATES
}
TEST_CASE("nameof.enums", "[!mayfail]")
{
#ifdef CTTI_HAS_ENUM_AWARE_PRETTY_FUNCTION
SECTION("enum values")
{
REQUIRE(nameof<CTTI_STATIC_VALUE(ClassicEnum::A)>() == "ClassicEnum::A");
REQUIRE(nameof<CTTI_STATIC_VALUE(EnumClass::A)>() == "EnumClass::A");
REQUIRE(nameof<CTTI_STATIC_VALUE(ClassicEnum::A)>() == "ClassicEnum::A");
}
#else
SECTION("enum values")
{
WARN("Thie section may fail in GCC due to 'u' suffix in integer literals. "
"It seems that some GCC versions use unsigned int as default enum underlying type");
REQUIRE(nameof<CTTI_STATIC_VALUE(ClassicEnum::A)>() == "(ClassicEnum)0");
REQUIRE(nameof<CTTI_STATIC_VALUE(EnumClass::A)>() == "(EnumClass)0");
REQUIRE(nameof<CTTI_STATIC_VALUE(ClassicEnum::A)>() == "(ClassicEnum)0");
}
#endif
}
| 23.012987
| 96
| 0.55474
|
RodrigoHolztrattner
|
8028d2add352db7f39ceccb7f5d3a8e9f0ead6d7
| 4,904
|
hpp
|
C++
|
samples/golf/src/icon.hpp
|
fallahn/crogine
|
f6cf3ade1f4e5de610d52e562bf43e852344bca0
|
[
"FTL",
"Zlib"
] | 41
|
2017-08-29T12:14:36.000Z
|
2022-02-04T23:49:48.000Z
|
samples/golf/src/icon.hpp
|
fallahn/crogine
|
f6cf3ade1f4e5de610d52e562bf43e852344bca0
|
[
"FTL",
"Zlib"
] | 11
|
2017-09-02T15:32:45.000Z
|
2021-12-27T13:34:56.000Z
|
samples/golf/src/icon.hpp
|
fallahn/crogine
|
f6cf3ade1f4e5de610d52e562bf43e852344bca0
|
[
"FTL",
"Zlib"
] | 5
|
2020-01-25T17:51:45.000Z
|
2022-03-01T05:20:30.000Z
|
static const unsigned char icon[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc8, 0xb8, 0x9f, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0xc8, 0xb8, 0x9f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
| 272.444444
| 360
| 0.576468
|
fallahn
|
802af22302204a6bf086d0dffd01d52ed60258c0
| 3,300
|
cpp
|
C++
|
xyuv/src/config-parser/minicalc/operations.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 5
|
2015-08-13T18:46:45.000Z
|
2018-04-18T18:51:43.000Z
|
xyuv/src/config-parser/minicalc/operations.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 18
|
2015-08-19T13:25:30.000Z
|
2017-05-08T10:55:48.000Z
|
xyuv/src/config-parser/minicalc/operations.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 3
|
2016-07-21T12:18:06.000Z
|
2018-05-19T05:32:32.000Z
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Stian Valentin Svedenborg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdexcept>
#include "operations.h"
// Evaluator functions:
int minicalc_add(int lhs, int rhs) {
return lhs + rhs;
}
int minicalc_sub(int lhs, int rhs) {
return lhs - rhs;
}
int minicalc_mul(int lhs, int rhs) {
return lhs * rhs;
}
int minicalc_div(int lhs, int rhs) {
if (rhs == 0) {
throw std::runtime_error("Divide by 0");
}
return lhs / rhs;
}
int minicalc_mod(int lhs, int rhs) {
if (rhs == 0) {
throw std::runtime_error("Divide by 0");
}
return lhs % rhs;
}
int minicalc_pow(int base, int exponent) {
int result = 1;
while (exponent > 0) {
result *= base;
--exponent;
}
return result;
}
int minicalc_negate(int v) {
return -v;
}
int minicalc_next_multiple(int base, int multiplier) {
int quotient_ceil = (base + (multiplier-1)) / multiplier;
return quotient_ceil*multiplier;
}
int minicalc_abs(int v) {
return v < 0 ? -v : v;
}
int minicalc_gcd(int lhs, int rhs) {
if (lhs <= 0 || rhs <=0 ) {
throw std::runtime_error("gcd() must have positive, non-zero operands");
}
if (lhs > rhs) {
return minicalc_gcd(lhs-rhs, rhs);
} else if (lhs < rhs) {
return minicalc_gcd(lhs, rhs-lhs);
}
else {
return lhs;
}
}
int minicalc_lcm(int lhs, int rhs) {
if (lhs <= 0 || rhs <=0 ) {
throw std::runtime_error("lcm() must have positive, non-zero operands");
}
return lhs * rhs / minicalc_gcd(lhs, rhs);
}
int minicalc_logic_eq(int lhs, int rhs) {
return int(lhs == rhs);
}
int minicalc_logic_ne(int lhs, int rhs) {
return int(lhs != rhs);
}
int minicalc_logic_lt(int lhs, int rhs) {
return int(lhs < rhs);
}
int minicalc_logic_gt(int lhs, int rhs) {
return int(lhs > rhs);
}
int minicalc_logic_le(int lhs, int rhs) {
return int(lhs <= rhs);
}
int minicalc_logic_ge(int lhs, int rhs) {
return int(lhs >= rhs);
}
int minicalc_logic_and(int lhs, int rhs){
return int(lhs && rhs);
}
int minicalc_logic_or(int lhs, int rhs) {
return int(lhs || rhs);
}
int minicalc_logic_neg(int bool_expr) {
return int(!bool_expr);
}
| 25.984252
| 80
| 0.662727
|
stian-svedenborg
|
802e48289708f2cf57236d5b295089aef1c3bf34
| 1,293
|
hh
|
C++
|
include/WCSimFitterInterface.hh
|
chipsneutrino/chips-reco
|
0d9e7e8a1dd749a2b0b0d64eabf0b32d895f19ba
|
[
"MIT"
] | null | null | null |
include/WCSimFitterInterface.hh
|
chipsneutrino/chips-reco
|
0d9e7e8a1dd749a2b0b0d64eabf0b32d895f19ba
|
[
"MIT"
] | null | null | null |
include/WCSimFitterInterface.hh
|
chipsneutrino/chips-reco
|
0d9e7e8a1dd749a2b0b0d64eabf0b32d895f19ba
|
[
"MIT"
] | null | null | null |
/*
* WCSimFitterInterface.hh
*
* Created on: 31 Oct 2014
* Author: andy
*/
#pragma once
#include <TString.h>
#include "WCSimTrackParameterEnums.hh"
class WCSimLikelihoodFitter;
class WCSimFitterConfig;
class WCSimFitterPlots;
class WCSimOutputTree;
class WCSimPiZeroFitter;
class WCSimCosmicFitter;
class WCSimFitterInterface
{
public:
virtual ~WCSimFitterInterface();
WCSimFitterInterface();
void SetInputFileName(const char *inputfile, bool modifyFile);
void SetMakeFits(bool makeFits);
void AddFitterConfig(WCSimFitterConfig *config);
void AddFitterPlots(WCSimFitterPlots *plots);
void InitFitter(WCSimFitterConfig *config);
void LoadWCSimData();
void InitFitterPlots(TString outputName, WCSimFitterConfig *config);
void Run();
private:
// Fit configuration parameters
int fNumFits;
std::vector<WCSimFitterConfig *> fFitterConfigs;
// Input file parameters
bool fModifyInputFile;
TString fFileName;
TString fOutputName;
// Fitters, selections, particle identification, output etc...
WCSimLikelihoodFitter *fFitter;
WCSimPiZeroFitter *fPiZeroFitter;
WCSimCosmicFitter *fCosmicFitter;
WCSimOutputTree *fOutputTree;
bool fMakeFits;
bool fMakePlots;
TString fPlotsName;
WCSimFitterPlots *fFitterPlots;
ClassDef(WCSimFitterInterface, 0)
};
| 19.892308
| 69
| 0.78809
|
chipsneutrino
|
803423d1e5c719bda57888babcca905836a0c056
| 2,334
|
cpp
|
C++
|
src/main.cpp
|
Embedded-AMS/EmbeddedProto_Example_Makefile
|
4e8440c887835f27b8343baa95193618eaf9b6c7
|
[
"CECILL-B"
] | 4
|
2020-11-11T15:17:28.000Z
|
2021-06-12T10:25:10.000Z
|
src/main.cpp
|
Embedded-AMS/EmbeddedProto_Example_Makefile
|
4e8440c887835f27b8343baa95193618eaf9b6c7
|
[
"CECILL-B"
] | null | null | null |
src/main.cpp
|
Embedded-AMS/EmbeddedProto_Example_Makefile
|
4e8440c887835f27b8343baa95193618eaf9b6c7
|
[
"CECILL-B"
] | 1
|
2020-11-11T17:16:25.000Z
|
2020-11-11T17:16:25.000Z
|
// Includes
#include <stm32f4xx.h>
#include <main.h>
#include <reply.h>
#include <request.h>
#include <DemoWriteBuffer.h>
#include <DemoReadBuffer.h>
// Construction of the messages.
demo::reply reply_msg;
demo::request request_msg;
// Construction of the write and read buffer objects.
demo::WriteBuffer<50> send_buffer;
demo::ReadBuffer read_buffer;
int main(void)
{
SystemInit();
uint32_t request_counter = 0;
while (1)
{
// Increment the request counter each iteration and alternate between request A and B.
request_msg.set_msgId(++request_counter);
request_msg.set_selection((request_counter & 0x01) ? demo::types::A
: demo::types::B);
if(request_msg.serialize(send_buffer))
{
// Serialization is successful. We can now use the buffer to send the data via a peripheral.
}
else
{
// Serialization failed for some reason.
}
// For demo purposes manually set the demo data.
if(request_counter & 0x01)
{
// Data for A
constexpr uint32_t RESPONS_SIZE_A = 10;
uint8_t demo_response_A[RESPONS_SIZE_A] = {0x08, 0x01, 0x12, 0x06, 0x08, 0x0A, 0x10, 0x14,
0x18, 0x1E};
read_buffer.set_demo_data(demo_response_A, RESPONS_SIZE_A);
}
else
{
// Data for B
constexpr uint32_t RESPONS_SIZE_B = 31;
uint8_t demo_response_B[RESPONS_SIZE_B] = {0x08, 0x02, 0x1A, 0x1B, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x59, 0x40, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x40,
0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x72, 0x40};
read_buffer.set_demo_data(demo_response_B, RESPONS_SIZE_B);
}
// Obtain from the buffer the reply message.
if(reply_msg.deserialize(read_buffer))
{
// Now we can use it.
switch(reply_msg.get_which_type())
{
case demo::reply::id::A:
{
// Do something with the data.
uint32_t ans_a = reply_msg.a().x() + reply_msg.a().y() + reply_msg.a().z();
break;
}
case demo::reply::id::B:
{
// Do something with the data.
uint32_t ans_b = reply_msg.b().u() * reply_msg.b().v() * reply_msg.b().w();
break;
}
default:
break;
}
}
}
}
| 26.224719
| 98
| 0.606255
|
Embedded-AMS
|
8036fc4b63770a35dee077bfd84863330de05316
| 413
|
cpp
|
C++
|
Chapter 9. Sequential Containers/Codes/9.31_1 Solution.cpp
|
Yunxiang-Li/Cpp_Primer
|
b5c857e3f6be993b2ff8fc03f634141ae24925fc
|
[
"MIT"
] | null | null | null |
Chapter 9. Sequential Containers/Codes/9.31_1 Solution.cpp
|
Yunxiang-Li/Cpp_Primer
|
b5c857e3f6be993b2ff8fc03f634141ae24925fc
|
[
"MIT"
] | null | null | null |
Chapter 9. Sequential Containers/Codes/9.31_1 Solution.cpp
|
Yunxiang-Li/Cpp_Primer
|
b5c857e3f6be993b2ff8fc03f634141ae24925fc
|
[
"MIT"
] | 1
|
2021-09-30T14:08:03.000Z
|
2021-09-30T14:08:03.000Z
|
#include <iostream>
#include <list>
int main() {
std::list<int> myList{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto iter = myList.begin();
while (iter != myList.end()) {
if (*iter % 2) {
iter = myList.insert(iter, *iter);
std::advance(iter, 2);
}
else {
iter = myList.erase(iter);
}
}
for (const int element : myList) {
std::cout << element << ' ';
}
return 0;
}
| 17.208333
| 55
| 0.510896
|
Yunxiang-Li
|
80384bdac5914041b43cdf7a3d960e6ad18d31c1
| 368
|
cpp
|
C++
|
Pbinfo/cifra_control_comuna.cpp
|
Al3x76/cpp
|
08a0977d777e63e0d36d87fcdea777de154697b7
|
[
"MIT"
] | 7
|
2019-01-06T19:10:14.000Z
|
2021-10-16T06:41:23.000Z
|
Pbinfo/cifra_control_comuna.cpp
|
Al3x76/cpp
|
08a0977d777e63e0d36d87fcdea777de154697b7
|
[
"MIT"
] | null | null | null |
Pbinfo/cifra_control_comuna.cpp
|
Al3x76/cpp
|
08a0977d777e63e0d36d87fcdea777de154697b7
|
[
"MIT"
] | 6
|
2019-01-06T19:17:30.000Z
|
2020-02-12T22:29:17.000Z
|
#include <iostream>
using namespace std;
int sum_cifra_control(int a, int b){
int k=0;
if(a>b) swap(b, a);
if(a==9){
for(int i=a; i<=b; i++)
if(i%9==0) k++;
}
else for(int i=a; i<=b; i++)
if(i%9==a) k++;
return k;
}
int main()
{
int a, b;
cin>>a>>b;
cout<<sum_cifra_control(a, b);
return 0;
}
| 13.142857
| 36
| 0.464674
|
Al3x76
|
8039a5613e3d99d4b6c17c084c5b584c0c66a22e
| 231
|
hpp
|
C++
|
packets/PKT_SPM_RemoveListener.hpp
|
HoDANG/OGLeague2
|
21efea8ea480972a6d686c4adefea03d57da5e9d
|
[
"MIT"
] | 1
|
2022-03-27T10:21:41.000Z
|
2022-03-27T10:21:41.000Z
|
packets/PKT_SPM_RemoveListener.hpp
|
HoDANG/OGLeague2
|
21efea8ea480972a6d686c4adefea03d57da5e9d
|
[
"MIT"
] | null | null | null |
packets/PKT_SPM_RemoveListener.hpp
|
HoDANG/OGLeague2
|
21efea8ea480972a6d686c4adefea03d57da5e9d
|
[
"MIT"
] | 3
|
2019-07-20T03:59:10.000Z
|
2022-03-27T10:20:09.000Z
|
#ifndef HPP_110_PKT_SPM_RemoveListener_HPP
#define HPP_110_PKT_SPM_RemoveListener_HPP
#include "base.hpp"
#pragma pack(push, 1)
struct PKT_SPM_RemoveListener_s : DefaultPacket<PKT_SPM_RemoveListener>
{
};
#pragma pack(pop)
#endif
| 21
| 71
| 0.831169
|
HoDANG
|
d9a2d2d4c3d82150466ecd93f0e234bbe514155f
| 5,494
|
cpp
|
C++
|
AndroidClient/math/collision/BoundingBox.cpp
|
aviskumar/speedo
|
758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa
|
[
"BSD-3-Clause"
] | 77
|
2015-01-28T17:21:49.000Z
|
2022-02-17T17:59:21.000Z
|
AndroidClient/math/collision/BoundingBox.cpp
|
aviskumar/speedo
|
758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa
|
[
"BSD-3-Clause"
] | 5
|
2015-03-22T23:14:54.000Z
|
2020-09-18T13:26:03.000Z
|
AndroidClient/math/collision/BoundingBox.cpp
|
aviskumar/speedo
|
758e8ac1fdeeb0b72c3a57742032ca5c79f0b2fa
|
[
"BSD-3-Clause"
] | 24
|
2015-02-12T04:34:37.000Z
|
2021-06-19T17:05:23.000Z
|
/*
Copyright 2011 Aevum Software aevum @ aevumlab.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@author Victor Vicente de Carvalho victor.carvalho@aevumlab.com
@author Ozires Bortolon de Faria ozires@aevumlab.com
*/
#include <algorithm>
#include <limits>
#include <sstream>
#include <string>
#include "BoundingBox.hpp"
#include "gdx-cpp/math/Vector3.hpp"
namespace gdx {
class Matrix4;
} // namespace gdx
using namespace gdx;
BoundingBox::BoundingBox() {
crn_dirty = true;
for (int l_idx = 0; l_idx < 8; l_idx++) {
crn.push_back(Vector3());
}
clr();
}
BoundingBox::BoundingBox (const BoundingBox& bounds) : crn_dirty(true) {
this->crn.reserve(8);
this->set(bounds);
}
Vector3& BoundingBox::getCenter () {
return cnt;
}
void BoundingBox::updateCorners () {
if (!crn_dirty) return;
crn[0].set(min.x, min.y, min.z);
crn[1].set(max.x, min.y, min.z);
crn[2].set(max.x, max.y, min.z);
crn[3].set(min.x, max.y, min.z);
crn[4].set(min.x, min.y, max.z);
crn[5].set(max.x, min.y, max.z);
crn[6].set(max.x, max.y, max.z);
crn[7].set(min.x, max.y, max.z);
crn_dirty = false;
}
const std::vector< Vector3 >& BoundingBox::getCorners () {
updateCorners();
return crn;
}
Vector3& BoundingBox::getDimensions () {
return dim;
}
Vector3& BoundingBox::getMin () {
return min;
}
Vector3& BoundingBox::getMax () {
return max;
}
BoundingBox& BoundingBox::set (const BoundingBox& bounds) {
crn_dirty = true;
return this->set(bounds.min, bounds.max);
}
BoundingBox& BoundingBox::set (const Vector3& minimum,const Vector3& maximum) {
min.set(minimum.x < maximum.x ? minimum.x : maximum.x, minimum.y < maximum.y ? minimum.y : maximum.y,
minimum.z < maximum.z ? minimum.z : maximum.z);
max.set(minimum.x > maximum.x ? minimum.x : maximum.x, minimum.y > maximum.y ? minimum.y : maximum.y,
minimum.z > maximum.z ? minimum.z : maximum.z);
cnt.set(min).add(max).mul(0.5f);
dim.set(max).sub(min);
crn_dirty = true;
return *this;
}
BoundingBox& BoundingBox::set (const std::vector<Vector3>& points) {
this->inf();
auto it = points.begin();
auto end = points.end();
for (; it != end; ++it)
this->ext(*it);
crn_dirty = true;
return *this;
}
BoundingBox& BoundingBox::inf () {
//TODO: not sure if this works
min.set(std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity());
max.set(-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity());
cnt.set(0, 0, 0);
dim.set(0, 0, 0);
crn_dirty = true;
return *this;
}
BoundingBox& BoundingBox::ext (const Vector3& point) {
crn_dirty = true;
return this->set(min.set(_min(min.x, point.x), _min(min.y, point.y), _min(min.z, point.z)),
max.set(std::max(max.x, point.x), std::max(max.y, point.y), std::max(max.z, point.z)));
}
BoundingBox& BoundingBox::clr () {
crn_dirty = true;
return this->set(min.set(0, 0, 0), max.set(0, 0, 0));
}
bool BoundingBox::isValid () {
return !(min.x == max.x && min.y == max.y && min.z == max.z);
}
BoundingBox& BoundingBox::ext (const BoundingBox& a_bounds) {
crn_dirty = true;
return this->set(min.set(_min(min.x, a_bounds.min.x), _min(min.y, a_bounds.min.y), _min(min.z, a_bounds.min.z)),
max.set(_max(max.x, a_bounds.max.x), _max(max.y, a_bounds.max.y), _max(max.z, a_bounds.max.z)));
}
BoundingBox& BoundingBox::mul (const Matrix4& matrix) {
updateCorners();
this->inf();
for ( int i = 0; i < 8; ++i) {
crn[i].mul(matrix);
min.set(_min(min.x, crn[i].x), _min(min.y, crn[i].y), _min(min.z, crn[i].z));
max.set(_max(max.x, crn[i].x), _max(max.y, crn[i].y), _max(max.z, crn[i].z));
}
crn_dirty = true;
return this->set(min, max);
}
bool BoundingBox::contains (const BoundingBox& bounds) {
if (!isValid()) return true;
if (min.x > bounds.max.x) return false;
if (min.y > bounds.max.y) return false;
if (min.z > bounds.max.z) return false;
if (max.x < bounds.min.x) return false;
if (max.y < bounds.min.y) return false;
if (max.z < bounds.min.z) return false;
return true;
}
bool BoundingBox::contains (const Vector3& v) {
if (min.x > v.x) return false;
if (max.x < v.x) return false;
if (min.y > v.y) return false;
if (max.y < v.y) return false;
if (min.z > v.z) return false;
if (max.z < v.z) return false;
return true;
}
std::string BoundingBox::toString () {
std::stringstream ss;
ss << "[" + min.toString() << "|" + max.toString() << "]";
return ss.str();
}
BoundingBox& BoundingBox::ext (float x,float y,float z) {
crn_dirty = true;
return this->set(min.set(_min(min.x, x), _min(min.y, y), _min(min.z, z)), max.set(_max(max.x, x), _max(max.y, y), _max(max.z, z)));
}
| 28.915789
| 135
| 0.626866
|
aviskumar
|
d9a3207d357980280637637846369c3263cc35a9
| 22
|
cpp
|
C++
|
src/Game/zNPCGlyph.cpp
|
DarkRTA/bfbbdecomp
|
e2105e94b8da26f6e6e2dfcf1f004aaaeed9799e
|
[
"OLDAP-2.7"
] | null | null | null |
src/Game/zNPCGlyph.cpp
|
DarkRTA/bfbbdecomp
|
e2105e94b8da26f6e6e2dfcf1f004aaaeed9799e
|
[
"OLDAP-2.7"
] | 6
|
2022-01-16T05:29:01.000Z
|
2022-01-18T01:10:29.000Z
|
src/Game/zNPCGlyph.cpp
|
DarkRTA/bfbbdecomp
|
e2105e94b8da26f6e6e2dfcf1f004aaaeed9799e
|
[
"OLDAP-2.7"
] | 1
|
2022-01-16T00:04:23.000Z
|
2022-01-16T00:04:23.000Z
|
#include "zNPCGlyph.h"
| 22
| 22
| 0.772727
|
DarkRTA
|
d9a5f9e8791b9e4055bc100df05bf5a4cc14875a
| 1,346
|
cpp
|
C++
|
luves/buffer.cpp
|
Leviathan1995/Luves
|
c8c64faf7130cd0dc58a1ffd2c7be24caedecbd2
|
[
"MIT"
] | 19
|
2016-07-27T14:23:17.000Z
|
2021-03-14T08:10:45.000Z
|
luves/buffer.cpp
|
Leviathan1995/Luves
|
c8c64faf7130cd0dc58a1ffd2c7be24caedecbd2
|
[
"MIT"
] | 1
|
2016-09-25T18:03:24.000Z
|
2016-10-01T06:29:59.000Z
|
luves/buffer.cpp
|
Leviathan1995/Luves
|
c8c64faf7130cd0dc58a1ffd2c7be24caedecbd2
|
[
"MIT"
] | 5
|
2016-08-02T06:55:19.000Z
|
2021-05-05T14:15:20.000Z
|
//
// Buffer.cpp
// Luves
//
// Created by leviathan on 16/6/1.
// Copyright © 2016年 leviathan. All rights reserved.
//
#include "buffer.h"
namespace luves {
//
//Buffer
//
void Buffer::Append(Buffer & buffer)
{
buffer_.insert(buffer_.end(), buffer.buffer_[buffer.GetReadIndex()], buffer.buffer_[0]);
write_index_ += buffer.GetReadIndex();
INFO_LOG("Append %d bytes to buffer.", buffer.GetReadIndex() );
}
void Buffer::Append(const std::string & msg)
{
for (auto s:msg)
{
buffer_[read_index_] = s;
write_index_++;
}
INFO_LOG("Append %d bytes to buffer.", msg.length());
}
int Buffer::ReadImp(int fd) // in
{
buffer_.clear();
read_index_ = 0;
int n = int(read(fd, &buffer_[0], 1024));
INFO_LOG("Receive %d bytes.",n);
if(n>0)
read_index_ += n;
return n;
}
int Buffer::WriteImp(int fd) // out
{
int n = int(write(fd, buffer_.data(), write_index_));
INFO_LOG("Write %d bytes.", n);
buffer_.clear();
write_index_ = 0;
return n;
}
std::ostream & operator <<(std::ostream & os, Buffer & buffer)
{
for (auto data:buffer.buffer_)
os<<data;
return os;
}
}
| 21.709677
| 96
| 0.52526
|
Leviathan1995
|
d9a7a5ffc12d6c001e55bfbef3eeddee1a46f3d6
| 2,993
|
hpp
|
C++
|
INCLUDE/Vcl/httputil.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | 1
|
2022-01-13T01:03:55.000Z
|
2022-01-13T01:03:55.000Z
|
INCLUDE/Vcl/httputil.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null |
INCLUDE/Vcl/httputil.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null |
// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved
// (DO NOT EDIT: machine generated header) 'HTTPUtil.pas' rev: 6.00
#ifndef HTTPUtilHPP
#define HTTPUtilHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Classes.hpp> // Pascal unit
#include <Types.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Httputil
{
//-- type declarations -------------------------------------------------------
__interface IStringTokenizer;
typedef System::DelphiInterface<IStringTokenizer> _di_IStringTokenizer;
__interface INTERFACE_UUID("{8C216E9D-984E-4E38-893F-0A222AC547DA}") IStringTokenizer : public IInterface
{
public:
virtual int __fastcall getTokenCounts(void) = 0 ;
virtual bool __fastcall hasMoreTokens(void) = 0 ;
virtual WideString __fastcall nextToken(void) = 0 ;
__property int countTokens = {read=getTokenCounts};
};
__interface IStreamLoader;
typedef System::DelphiInterface<IStreamLoader> _di_IStreamLoader;
__interface INTERFACE_UUID("{395CDFB2-1D10-4A37-AC16-393D569676F0}") IStreamLoader : public IInterface
{
public:
virtual void __fastcall Load(const WideString WSDLFileName, Classes::TMemoryStream* Stream) = 0 ;
virtual AnsiString __fastcall GetProxy(void) = 0 ;
virtual void __fastcall SetProxy(const AnsiString Proxy) = 0 ;
virtual AnsiString __fastcall GetUserName(void) = 0 ;
virtual void __fastcall SetUserName(const AnsiString UserName) = 0 ;
virtual AnsiString __fastcall GetPassword(void) = 0 ;
virtual void __fastcall SetPassword(const AnsiString Password) = 0 ;
__property AnsiString Proxy = {read=GetProxy, write=SetProxy};
__property AnsiString UserName = {read=GetUserName, write=SetUserName};
__property AnsiString Password = {read=GetPassword, write=SetPassword};
};
//-- var, const, procedure ---------------------------------------------------
extern PACKAGE _di_IStreamLoader __fastcall GetDefaultStreamLoader();
extern PACKAGE bool __fastcall StartsWith(const AnsiString str, const AnsiString sub);
extern PACKAGE int __fastcall FirstDelimiter(const AnsiString delimiters, const AnsiString Str)/* overload */;
extern PACKAGE int __fastcall FirstDelimiter(const WideString delimiters, const WideString Str)/* overload */;
extern PACKAGE _di_IStringTokenizer __fastcall StringTokenizer(const AnsiString str, const AnsiString delim);
extern PACKAGE TStringDynArray __fastcall StringToStringArray(const AnsiString str, const AnsiString delim);
extern PACKAGE AnsiString __fastcall HTMLEscape(const AnsiString Str);
} /* namespace Httputil */
using namespace Httputil;
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // HTTPUtil
| 42.757143
| 111
| 0.709322
|
earthsiege2
|
d9b000386041b16f5b4c6c1b773db1722d224b75
| 2,758
|
cpp
|
C++
|
src/parser.cpp
|
hanilr/ed
|
38c66d2376aa08fe20686d129cd901423aad1a46
|
[
"MIT"
] | 1
|
2021-12-22T07:30:05.000Z
|
2021-12-22T07:30:05.000Z
|
src/parser.cpp
|
hanilr/ed
|
38c66d2376aa08fe20686d129cd901423aad1a46
|
[
"MIT"
] | null | null | null |
src/parser.cpp
|
hanilr/ed
|
38c66d2376aa08fe20686d129cd901423aad1a46
|
[
"MIT"
] | null | null | null |
// PARSER MAIN FILE //
// STANDARD LIBRARY
#include <iostream>
#include <algorithm>
// DIY LIBRARY
#include "lib/parser.hpp"
#include "lib/util.hpp"
#include "lib/config.hpp"
std::string parser_term(std::string term)
{
std::replace(term.begin(), term.end(), 46, 13);
return term;
}
int parser_int(char const *rule_name, int line, int temp_state)
{
std::string rule = fetchr(rule_name, line);
int rule_number = (int) rule[2] - 48;
if(linstr(rule, "+") == 0) { return (temp_state + rule_number); }
if(linstr(rule, "-") == 0) { return (temp_state - rule_number); }
if(linstr(rule, "*") == 0) { return (temp_state * rule_number); }
if(linstr(rule, "/") == 0) { return (temp_state / rule_number); }
if(linstr(rule, "#") == 0) { return (temp_state); }
}
int reverse_parser_int(char const *rule_name, int line, int temp_state)
{
std::string rule = fetchr(rule_name, line);
int rule_number = (int) rule[2] - 48;
if(linstr(rule, "+") == 0) { return (temp_state - rule_number); }
if(linstr(rule, "-") == 0) { return (temp_state + rule_number); }
if(linstr(rule, "*") == 0) { return (temp_state / rule_number); }
if(linstr(rule, "/") == 0) { return (temp_state * rule_number); }
if(linstr(rule, "#") == 0) { return (temp_state); }
}
std::string parser_str(char const *rule_name, int line, std::string temp_state)
{
std::string temp_conv, rule = fetchr(rule_name, line);
int temp_int, state_len = temp_state.length(), rule_number = (int) rule[2] - 48;
for(int i = 0; state_len>i; i+=1)
{
temp_int = temp_state[i];
if(linstr(rule, "+") == 0) { temp_int += rule_number; }
if(linstr(rule, "-") == 0) { temp_int -= rule_number; }
if(linstr(rule, "*") == 0) { temp_int *= rule_number; }
if(linstr(rule, "/") == 0) { temp_int /= rule_number; }
if(linstr(rule, "#") == 0) { temp_int += 0; }
temp_conv += temp_int;
}
return temp_conv;
}
std::string reverse_parser_str(char const *rule_name, int line, std::string temp_state)
{
std::string temp_conv, rule = fetchr(rule_name, line);
int temp_int, state_len = temp_state.length(), rule_number = (int) rule[2] - 48;
for(int i = 0; state_len>i; i+=1)
{
temp_int = temp_state[i];
if(linstr(rule, "+") == 0) { temp_int -= rule_number; }
if(linstr(rule, "-") == 0) { temp_int += rule_number; }
if(linstr(rule, "*") == 0) { temp_int /= rule_number; }
if(linstr(rule, "/") == 0) { temp_int *= rule_number; }
if(linstr(rule, "#") == 0) { temp_int += 0; }
temp_conv += temp_int;
}
return temp_conv;
}
// MADE BY @hanilr //
| 34.475
| 88
| 0.573604
|
hanilr
|
d9b3f8c78faec9e298ccbd90b4008ac908dbd36a
| 13,758
|
cpp
|
C++
|
src/frameworks/wilhelm/src/ThreadPool.cpp
|
dAck2cC2/m3e
|
475b89b59d5022a94e00b636438b25e27e4eaab2
|
[
"Apache-2.0"
] | null | null | null |
src/frameworks/wilhelm/src/ThreadPool.cpp
|
dAck2cC2/m3e
|
475b89b59d5022a94e00b636438b25e27e4eaab2
|
[
"Apache-2.0"
] | null | null | null |
src/frameworks/wilhelm/src/ThreadPool.cpp
|
dAck2cC2/m3e
|
475b89b59d5022a94e00b636438b25e27e4eaab2
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ThreadPool */
#include "sles_allinclusive.h"
// Entry point for each worker thread
static void *ThreadPool_start(void *context)
{
ThreadPool *tp = (ThreadPool *) context;
assert(NULL != tp);
for (;;) {
Closure *pClosure = ThreadPool_remove(tp);
// closure is NULL when thread pool is being destroyed
if (NULL == pClosure) {
break;
}
// make a copy of parameters, then free the parameters
const Closure closure = *pClosure;
free(pClosure);
// extract parameters and call the right method depending on kind
ClosureKind kind = closure.mKind;
void *context1 = closure.mContext1;
void *context2 = closure.mContext2;
int parameter1 = closure.mParameter1;
switch (kind) {
case CLOSURE_KIND_PPI:
{
ClosureHandler_ppi handler_ppi = closure.mHandler.mHandler_ppi;
assert(NULL != handler_ppi);
(*handler_ppi)(context1, context2, parameter1);
}
break;
case CLOSURE_KIND_PPII:
{
ClosureHandler_ppii handler_ppii = closure.mHandler.mHandler_ppii;
assert(NULL != handler_ppii);
int parameter2 = closure.mParameter2;
(*handler_ppii)(context1, context2, parameter1, parameter2);
}
break;
case CLOSURE_KIND_PIIPP:
{
ClosureHandler_piipp handler_piipp = closure.mHandler.mHandler_piipp;
assert(NULL != handler_piipp);
int parameter2 = closure.mParameter2;
void *context3 = closure.mContext3;
(*handler_piipp)(context1, parameter1, parameter2, context2, context3);
}
break;
default:
SL_LOGE("Unexpected callback kind %d", kind);
assert(false);
break;
}
}
return NULL;
}
#define INITIALIZED_NONE 0
#define INITIALIZED_MUTEX 1
#define INITIALIZED_CONDNOTFULL 2
#define INITIALIZED_CONDNOTEMPTY 4
#define INITIALIZED_ALL 7
static void ThreadPool_deinit_internal(ThreadPool *tp, unsigned initialized, unsigned nThreads);
// Initialize a ThreadPool
// maxClosures defaults to CLOSURE_TYPICAL if 0
// maxThreads defaults to THREAD_TYPICAL if 0
SLresult ThreadPool_init(ThreadPool *tp, unsigned maxClosures, unsigned maxThreads)
{
assert(NULL != tp);
memset(tp, 0, sizeof(ThreadPool));
tp->mShutdown = SL_BOOLEAN_FALSE;
unsigned initialized = INITIALIZED_NONE; // which objects were successfully initialized
unsigned nThreads = 0; // number of threads successfully created
int err;
SLresult result;
// initialize mutex and condition variables
err = pthread_mutex_init(&tp->mMutex, (const pthread_mutexattr_t *) NULL);
result = err_to_result(err);
if (SL_RESULT_SUCCESS != result)
goto fail;
initialized |= INITIALIZED_MUTEX;
err = pthread_cond_init(&tp->mCondNotFull, (const pthread_condattr_t *) NULL);
result = err_to_result(err);
if (SL_RESULT_SUCCESS != result)
goto fail;
initialized |= INITIALIZED_CONDNOTFULL;
err = pthread_cond_init(&tp->mCondNotEmpty, (const pthread_condattr_t *) NULL);
result = err_to_result(err);
if (SL_RESULT_SUCCESS != result)
goto fail;
initialized |= INITIALIZED_CONDNOTEMPTY;
// use default values for parameters, if not specified explicitly
tp->mWaitingNotFull = 0;
tp->mWaitingNotEmpty = 0;
if (0 == maxClosures)
maxClosures = CLOSURE_TYPICAL;
tp->mMaxClosures = maxClosures;
if (0 == maxThreads)
maxThreads = THREAD_TYPICAL;
tp->mMaxThreads = maxThreads;
// initialize circular buffer for closures
if (CLOSURE_TYPICAL >= maxClosures) {
tp->mClosureArray = tp->mClosureTypical;
} else {
tp->mClosureArray = (Closure **) malloc((maxClosures + 1) * sizeof(Closure *));
if (NULL == tp->mClosureArray) {
result = SL_RESULT_RESOURCE_ERROR;
goto fail;
}
}
tp->mClosureFront = tp->mClosureArray;
tp->mClosureRear = tp->mClosureArray;
// initialize thread pool
if (THREAD_TYPICAL >= maxThreads) {
tp->mThreadArray = tp->mThreadTypical;
} else {
tp->mThreadArray = (pthread_t *) malloc(maxThreads * sizeof(pthread_t));
if (NULL == tp->mThreadArray) {
result = SL_RESULT_RESOURCE_ERROR;
goto fail;
}
}
unsigned i;
for (i = 0; i < maxThreads; ++i) {
int err = pthread_create(&tp->mThreadArray[i], (const pthread_attr_t *) NULL,
ThreadPool_start, tp);
result = err_to_result(err);
if (SL_RESULT_SUCCESS != result)
goto fail;
++nThreads;
}
tp->mInitialized = initialized;
// done
return SL_RESULT_SUCCESS;
// here on any kind of error
fail:
ThreadPool_deinit_internal(tp, initialized, nThreads);
return result;
}
static void ThreadPool_deinit_internal(ThreadPool *tp, unsigned initialized, unsigned nThreads)
{
int ok;
assert(NULL != tp);
// Destroy all threads
if (0 < nThreads) {
assert(INITIALIZED_ALL == initialized);
ok = pthread_mutex_lock(&tp->mMutex);
assert(0 == ok);
tp->mShutdown = SL_BOOLEAN_TRUE;
ok = pthread_cond_broadcast(&tp->mCondNotEmpty);
assert(0 == ok);
ok = pthread_cond_broadcast(&tp->mCondNotFull);
assert(0 == ok);
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
unsigned i;
for (i = 0; i < nThreads; ++i) {
ok = pthread_join(tp->mThreadArray[i], (void **) NULL);
assert(ok == 0);
}
// Empty out the circular buffer of closures
ok = pthread_mutex_lock(&tp->mMutex);
assert(0 == ok);
Closure **oldFront = tp->mClosureFront;
while (oldFront != tp->mClosureRear) {
Closure **newFront = oldFront;
if (++newFront == &tp->mClosureArray[tp->mMaxClosures + 1])
newFront = tp->mClosureArray;
Closure *pClosure = *oldFront;
assert(NULL != pClosure);
*oldFront = NULL;
tp->mClosureFront = newFront;
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
free(pClosure);
ok = pthread_mutex_lock(&tp->mMutex);
assert(0 == ok);
}
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
// Note that we can't be sure when mWaitingNotFull will drop to zero
}
// destroy the mutex and condition variables
if (initialized & INITIALIZED_CONDNOTEMPTY) {
ok = pthread_cond_destroy(&tp->mCondNotEmpty);
assert(0 == ok);
}
if (initialized & INITIALIZED_CONDNOTFULL) {
ok = pthread_cond_destroy(&tp->mCondNotFull);
assert(0 == ok);
}
if (initialized & INITIALIZED_MUTEX) {
ok = pthread_mutex_destroy(&tp->mMutex);
assert(0 == ok);
}
tp->mInitialized = INITIALIZED_NONE;
// release the closure circular buffer
if (tp->mClosureTypical != tp->mClosureArray && NULL != tp->mClosureArray) {
free(tp->mClosureArray);
tp->mClosureArray = NULL;
}
// release the thread pool
if (tp->mThreadTypical != tp->mThreadArray && NULL != tp->mThreadArray) {
free(tp->mThreadArray);
tp->mThreadArray = NULL;
}
}
void ThreadPool_deinit(ThreadPool *tp)
{
ThreadPool_deinit_internal(tp, tp->mInitialized, tp->mMaxThreads);
}
// Enqueue a closure to be executed later by a worker thread.
// Note that this raw interface requires an explicit "kind" and full parameter list.
// There are convenience methods below that make this easier to use.
SLresult ThreadPool_add(ThreadPool *tp, ClosureKind kind, ClosureHandler_generic handler,
void *context1, void *context2, void *context3, int parameter1, int parameter2)
{
assert(NULL != tp);
assert(NULL != handler);
Closure *closure = (Closure *) malloc(sizeof(Closure));
if (NULL == closure) {
return SL_RESULT_RESOURCE_ERROR;
}
closure->mKind = kind;
switch (kind) {
case CLOSURE_KIND_PPI:
closure->mHandler.mHandler_ppi = (ClosureHandler_ppi)handler;
break;
case CLOSURE_KIND_PPII:
closure->mHandler.mHandler_ppii = (ClosureHandler_ppii)handler;
break;
case CLOSURE_KIND_PIIPP:
closure->mHandler.mHandler_piipp = (ClosureHandler_piipp)handler;
break;
default:
SL_LOGE("ThreadPool_add() invalid closure kind %d", kind);
assert(false);
}
closure->mContext1 = context1;
closure->mContext2 = context2;
closure->mContext3 = context3;
closure->mParameter1 = parameter1;
closure->mParameter2 = parameter2;
int ok;
ok = pthread_mutex_lock(&tp->mMutex);
assert(0 == ok);
// can't enqueue while thread pool shutting down
if (tp->mShutdown) {
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
free(closure);
return SL_RESULT_PRECONDITIONS_VIOLATED;
}
for (;;) {
Closure **oldRear = tp->mClosureRear;
Closure **newRear = oldRear;
if (++newRear == &tp->mClosureArray[tp->mMaxClosures + 1])
newRear = tp->mClosureArray;
// if closure circular buffer is full, then wait for it to become non-full
if (newRear == tp->mClosureFront) {
++tp->mWaitingNotFull;
ok = pthread_cond_wait(&tp->mCondNotFull, &tp->mMutex);
assert(0 == ok);
// can't enqueue while thread pool shutting down
if (tp->mShutdown) {
assert(0 < tp->mWaitingNotFull);
--tp->mWaitingNotFull;
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
free(closure);
return SL_RESULT_PRECONDITIONS_VIOLATED;
}
continue;
}
assert(NULL == *oldRear);
*oldRear = closure;
tp->mClosureRear = newRear;
// if a worker thread was waiting to dequeue, then suggest that it try again
if (0 < tp->mWaitingNotEmpty) {
--tp->mWaitingNotEmpty;
ok = pthread_cond_signal(&tp->mCondNotEmpty);
assert(0 == ok);
}
break;
}
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
return SL_RESULT_SUCCESS;
}
// Called by a worker thread when it is ready to accept the next closure to execute
Closure *ThreadPool_remove(ThreadPool *tp)
{
Closure *pClosure;
int ok;
ok = pthread_mutex_lock(&tp->mMutex);
assert(0 == ok);
for (;;) {
// fail if thread pool is shutting down
if (tp->mShutdown) {
pClosure = NULL;
break;
}
Closure **oldFront = tp->mClosureFront;
// if closure circular buffer is empty, then wait for it to become non-empty
if (oldFront == tp->mClosureRear) {
++tp->mWaitingNotEmpty;
ok = pthread_cond_wait(&tp->mCondNotEmpty, &tp->mMutex);
assert(0 == ok);
// try again
continue;
}
// dequeue the closure at front of circular buffer
Closure **newFront = oldFront;
if (++newFront == &tp->mClosureArray[tp->mMaxClosures + 1]) {
newFront = tp->mClosureArray;
}
pClosure = *oldFront;
assert(NULL != pClosure);
*oldFront = NULL;
tp->mClosureFront = newFront;
// if a client thread was waiting to enqueue, then suggest that it try again
if (0 < tp->mWaitingNotFull) {
--tp->mWaitingNotFull;
ok = pthread_cond_signal(&tp->mCondNotFull);
assert(0 == ok);
}
break;
}
ok = pthread_mutex_unlock(&tp->mMutex);
assert(0 == ok);
return pClosure;
}
// Convenience methods for applications
SLresult ThreadPool_add_ppi(ThreadPool *tp, ClosureHandler_ppi handler,
void *context1, void *context2, int parameter1)
{
// function pointers are the same size so this is a safe cast
return ThreadPool_add(tp, CLOSURE_KIND_PPI, (ClosureHandler_generic) handler,
context1, context2, NULL, parameter1, 0);
}
SLresult ThreadPool_add_ppii(ThreadPool *tp, ClosureHandler_ppii handler,
void *context1, void *context2, int parameter1, int parameter2)
{
// function pointers are the same size so this is a safe cast
return ThreadPool_add(tp, CLOSURE_KIND_PPII, (ClosureHandler_generic) handler,
context1, context2, NULL, parameter1, parameter2);
}
SLresult ThreadPool_add_piipp(ThreadPool *tp, ClosureHandler_piipp handler,
void *cntxt1, int param1, int param2, void *cntxt2, void *cntxt3)
{
// function pointers are the same size so this is a safe cast
return ThreadPool_add(tp, CLOSURE_KIND_PIIPP, (ClosureHandler_generic) handler,
cntxt1, cntxt2, cntxt3, param1, param2);
}
| 34.918782
| 96
| 0.619567
|
dAck2cC2
|
d9b6b0ce1b6f9e664e1e8f739cd8375097c6b43c
| 4,102
|
cpp
|
C++
|
projects/Test_ComputeShader/src/main.cpp
|
codeonwort/pathosengine
|
ea568afeac9af3ebe3f2e53cc5abeecb40714466
|
[
"MIT"
] | 11
|
2016-08-30T12:01:35.000Z
|
2021-12-29T15:34:03.000Z
|
projects/Test_ComputeShader/src/main.cpp
|
codeonwort/pathosengine
|
ea568afeac9af3ebe3f2e53cc5abeecb40714466
|
[
"MIT"
] | 9
|
2016-05-19T03:14:22.000Z
|
2021-01-17T05:45:52.000Z
|
projects/Test_ComputeShader/src/main.cpp
|
codeonwort/pathosengine
|
ea568afeac9af3ebe3f2e53cc5abeecb40714466
|
[
"MIT"
] | null | null | null |
#include "pathos/core_minimal.h"
#include "pathos/shader/shader.h"
using namespace pathos;
#include <stdio.h>
void initComputeShader();
int main(int argc, char** argv) {
EngineConfig config;
config.windowWidth = 800;
config.windowHeight = 600;
config.rendererType = ERendererType::Deferred;
config.title = "Test: Compute Shader";
Engine::init(argc, argv, config);
initComputeShader();
gEngine->start();
return 0;
}
void initComputeShader() {
// benchmark
GLint workGroupSizeX, workGroupSizeY, workGroupSizeZ;
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &workGroupSizeX);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &workGroupSizeY);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, &workGroupSizeZ);
GLint maxInvocation;
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &maxInvocation);
GLint sharedVariableLimit;
glGetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &sharedVariableLimit);
//void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
//glBindImageTexture(0, tex_input, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F)
//glBindImageTexture(1, tex_output, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F)
LOG(LogInfo, "===== Compute Shader Capabilities =====");
LOG(LogInfo, "max work group size: (%d, %d, %d)", workGroupSizeX, workGroupSizeY, workGroupSizeZ);
LOG(LogInfo, "max work group invocations: %d", maxInvocation);
LOG(LogInfo, "max shared memory (kb): %d", sharedVariableLimit);
LOG(LogInfo, "=======================================");
/* backup
string cshader = R"(
#version 430 core
layout (local_size_x = 32, local_size_y = 32) in;
//layout (binding = 0, rgba32f) uniform image2D img_in;
//layout (binding = 1) uniform image2D img_out;
void main() {
//ivec2 p = ivec2(gl_GlobalInvocationID.xy);
//vec4 texel = imageLoad(img_in, p);
//texel = vec4(1.0) - texel;
//imageStore(img_out, p, texel);
}
)";
*/
// test compute shader
std::string cshader = R"(
#version 430 core
layout (local_size_x = 128) in;
layout (binding = 0) coherent buffer block1 {
uint input_data[gl_WorkGroupSize.x];
};
layout (binding = 1) coherent buffer block2 {
uint output_data[gl_WorkGroupSize.x];
};
shared uint shared_data[gl_WorkGroupSize.x * 2];
void main() {
uint id = gl_LocalInvocationID.x;
uint rd_id, wr_id, mask;
const uint steps = uint(log2(gl_WorkGroupSize.x)) + 1;
uint step = 0;
shared_data[id * 2] = input_data[id * 2];
shared_data[id * 2 + 1] = input_data[id * 2 + 1];
barrier();
memoryBarrierShared();
for(step = 0; step < steps ; step++){
mask = (1 << step) - 1;
rd_id = ((id >> step) << (step + 1)) + mask;
wr_id = rd_id + 1 + (id & mask);
shared_data[wr_id] += shared_data[rd_id];
barrier();
memoryBarrierShared();
}
output_data[id * 2] = shared_data[id * 2];
output_data[id * 2 + 1] = shared_data[id * 2 + 1];
}
)";
GLuint computeProgram = pathos::createComputeProgram(cshader, "CS_Test");
CHECK(computeProgram);
// test data
std::vector<GLuint> subsum_data(128, 1);
GLuint buf_in;
glGenBuffers(1, &buf_in);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buf_in);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(GLuint) * subsum_data.size(), &subsum_data[0], GL_DYNAMIC_COPY);
GLuint buf_out;
glGenBuffers(1, &buf_out);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buf_out);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(GLuint) * subsum_data.size(), NULL, GL_DYNAMIC_COPY);
// run subsum shader
glUseProgram(computeProgram);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, buf_in);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, buf_out);
glDispatchCompute(128, 1, 1);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
// validation
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buf_out);
GLuint* subsum_result = reinterpret_cast<GLuint*>(glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY));
for (int i = 0; i < 128; ++i) {
//assert(subsum_result[i] == i + 1);
printf("%d ", subsum_result[i]);
}
puts("");
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}
| 29.092199
| 131
| 0.720868
|
codeonwort
|
d9b881e155db767076c9396697b46290c9f2ff5b
| 291
|
cpp
|
C++
|
arduino-libs/Pacman/src/IGameState.cpp
|
taylorsmithatnominet/BSidesCBR-2021-Badge
|
df3f13d780d6fb1b6d03d08e9bdd72f507f69aa6
|
[
"MIT"
] | null | null | null |
arduino-libs/Pacman/src/IGameState.cpp
|
taylorsmithatnominet/BSidesCBR-2021-Badge
|
df3f13d780d6fb1b6d03d08e9bdd72f507f69aa6
|
[
"MIT"
] | null | null | null |
arduino-libs/Pacman/src/IGameState.cpp
|
taylorsmithatnominet/BSidesCBR-2021-Badge
|
df3f13d780d6fb1b6d03d08e9bdd72f507f69aa6
|
[
"MIT"
] | null | null | null |
#include "IGameState.h"
#include "ServiceLocator.h"
#include "DrawManager.h"
namespace pacman {
IGameState::IGameState(GameStateData * p_data)
: m_datawPtr(p_data)
{
m_drawManagerwPtr = ServiceLocator<DrawManager>::GetService();
}
IGameState::~IGameState()
{
}
}; // namespace pacman
| 15.315789
| 63
| 0.742268
|
taylorsmithatnominet
|
d9b9c31e843efbbd08c65d935240a4df46964f82
| 2,873
|
cpp
|
C++
|
Game/Client/CEGUIFalagardEx/FalImageListProperties.cpp
|
hackerlank/SourceCode
|
b702c9e0a9ca5d86933f3c827abb02a18ffc9a59
|
[
"MIT"
] | 4
|
2021-07-31T13:56:01.000Z
|
2021-11-13T02:55:10.000Z
|
Game/Client/CEGUIFalagardEx/FalImageListProperties.cpp
|
shacojx/SourceCodeGameTLBB
|
e3cea615b06761c2098a05427a5f41c236b71bf7
|
[
"MIT"
] | null | null | null |
Game/Client/CEGUIFalagardEx/FalImageListProperties.cpp
|
shacojx/SourceCodeGameTLBB
|
e3cea615b06761c2098a05427a5f41c236b71bf7
|
[
"MIT"
] | 7
|
2021-08-31T14:34:23.000Z
|
2022-01-19T08:25:58.000Z
|
#include "falagardimagelistitem.h"
#include "FalImageListProperties.h"
#include "CEGUIPropertyHelper.h"
#include <stdio.h>
namespace CEGUI
{
namespace FalagardImageListBoxProperties
{
//////////////////////////////////////////////////////////////////////////////////////
String ImageNormal::get(const PropertyReceiver* receiver) const
{
return "";//PropertyHelper::imageToString(static_cast<const FalagardImageListBox*>(receiver)->setNormalImage());
}
void ImageNormal::set(PropertyReceiver* receiver, const String& value)
{
static_cast<FalagardImageListBox*>(receiver)->setNormalImage(PropertyHelper::stringToImage(value));
}
//////////////////////////////////////////////////////////////////////////////////////
String ImageHorver::get(const PropertyReceiver* receiver) const
{
return "";//PropertyHelper::boolToString(static_cast<const FalagardImageListBox*>(receiver)->setHorverImage());
}
void ImageHorver::set(PropertyReceiver* receiver, const String& value)
{
static_cast<FalagardImageListBox*>(receiver)->setHorverImage(PropertyHelper::stringToImage(value));
}
//////////////////////////////////////////////////////////////////////////////////////
String ImageChecked::get(const PropertyReceiver* receiver) const
{
return "";//PropertyHelper::boolToString(static_cast<const FalagardImageListBox*>(receiver)->isEmpty());
}
void ImageChecked::set(PropertyReceiver* receiver, const String& value)
{
static_cast<FalagardImageListBox*>(receiver)->setCheckedImage(PropertyHelper::stringToImage(value));
}
//////////////////////////////////////////////////////////////////////////////////////
String ImageDisable::get(const PropertyReceiver* receiver) const
{
return "";//PropertyHelper::boolToString(static_cast<const FalagardImageListBox*>(receiver)->isEmpty());
}
void ImageDisable::set(PropertyReceiver* receiver, const String& value)
{
static_cast<FalagardImageListBox*>(receiver)->setDisabledImage(PropertyHelper::stringToImage(value));
}
////////////////////////////////////////////////////////////////////////////////////////
String AddItem::get(const PropertyReceiver* receiver) const
{
return "";
}
void AddItem::set(PropertyReceiver* receiver, const String& value)
{
char text[128];
int nID = 0;
sscanf(value.c_str(), "id=%d text=%s", &nID, text );
FalagardImageListBoxItem* pItem = new FalagardImageListBoxItem( text, nID );
FalagardImageListBox *pParent = static_cast<FalagardImageListBox*>(receiver);
if( pItem && pParent )
{
pItem->SetNormalImage( (Image*)pParent->getNormalImage() );
pItem->SetHorverImage( (Image*)pParent->getHorverImage() );
pItem->SetCheckedImage( (Image*)pParent->getCheckedImage() );
pItem->SetDisableImage( (Image*)pParent->getDisabledImage() );
pParent->addItem( pItem );
}
}
}
}
| 37.311688
| 115
| 0.626523
|
hackerlank
|
d9bb54e82f921ac2851cf90c1629d9e1fcdb21e6
| 5,147
|
cpp
|
C++
|
src/RenderFarmUI/RF_TerraTool.cpp
|
rromanchuk/xptools
|
deff017fecd406e24f60dfa6aae296a0b30bff56
|
[
"X11",
"MIT"
] | 71
|
2015-12-15T19:32:27.000Z
|
2022-02-25T04:46:01.000Z
|
src/RenderFarmUI/RF_TerraTool.cpp
|
rromanchuk/xptools
|
deff017fecd406e24f60dfa6aae296a0b30bff56
|
[
"X11",
"MIT"
] | 19
|
2016-07-09T19:08:15.000Z
|
2021-07-29T10:30:20.000Z
|
src/RenderFarmUI/RF_TerraTool.cpp
|
rromanchuk/xptools
|
deff017fecd406e24f60dfa6aae296a0b30bff56
|
[
"X11",
"MIT"
] | 42
|
2015-12-14T19:13:02.000Z
|
2022-03-01T15:15:03.000Z
|
/*
* Copyright (c) 2004, Laminar Research.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "RF_TerraTool.h"
#include "RF_MapZoomer.h"
#include "PCSBSocket.h"
#include "TerraServer.h"
#include "GUI_GraphState.h"
#if APL
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
class AsyncImage;
inline long long hash_xy(int x, int y) { return ((long long) x << 32) + (long long) y; }
RF_TerraTool::RF_TerraTool(RF_MapZoomer * inZoomer) :
RF_MapTool(inZoomer)
{
static bool first_time = true;
if (first_time)
PCSBSocket::StartupNetworking(true);
first_time = false;
mPool = new AsyncConnectionPool(4,5);
mLocator = new AsyncImageLocator(mPool);
mHas = 0;
mRes = 4;
mData = "1";
}
RF_TerraTool::~RF_TerraTool()
{
for (map<long long, AsyncImage *>::iterator i = mImages.begin(); i != mImages.end(); ++i)
delete i->second;
delete mLocator;
}
void RF_TerraTool::DrawFeedbackUnderlay(
GUI_GraphState * inState,
bool inCurrent)
{
if (!inCurrent && !mHas) return;
double s, n, e, w;
GetZoomer()->GetMapVisibleBounds(w, s, e, n);
string status;
if (mLocator->GetLocation(ResString(), mData.c_str(), w, s, e, n, mX1, mX2, mY1, mY2, mDomain, status))
{
mHas = 1;
for (int x = mX1; x < mX2; ++x)
for (int y = mY1; y < mY2; ++y)
{
long long h = hash_xy(x,y);
if (mImages.count(h) == 0)
{
mImages[h] = new AsyncImage(mPool, ResString(), mData.c_str(), mDomain, x, y);
}
AsyncImage * i = mImages[h];
if (!i->HasErr())
{
ImageInfo * bits = i->GetImage();
if (bits)
{
double coords[4][2];
if (i->GetCoords(coords))
{
for (int n = 0; n < 4; ++n)
{
coords[n][0] = GetZoomer()->LatToYPixel(coords[n][0]);
coords[n][1] = GetZoomer()->LonToXPixel(coords[n][1]);
}
i->Draw(coords,inState);
}
}
}
}
} else
mHas = 0;
}
void RF_TerraTool::DrawFeedbackOverlay(
GUI_GraphState * inState,
bool inCurrent)
{
}
bool RF_TerraTool::HandleClick(
XPLMMouseStatus inStatus,
int inX,
int inY,
int inButton,
GUI_KeyFlags inModifiers)
{
return false;
}
int RF_TerraTool::GetNumProperties(void)
{
return 1;
}
void RF_TerraTool::GetNthPropertyName(int n, string& s)
{
s = "Res (m):";
}
double RF_TerraTool::GetNthPropertyValue(int)
{
return mRes;
}
void RF_TerraTool::SetNthPropertyValue(int, double v)
{
mRes = v;
if (mRes < 1) mRes = 1;
NthButtonPressed(1);
}
int RF_TerraTool::GetNumButtons(void)
{
return 5;
}
void RF_TerraTool::GetNthButtonName(int n, string& s)
{
switch(n) {
case 0: s = "Retry"; break;
case 1: s = "Clear"; break;
case 2: s = "Photo"; break;
case 3: s = "Ortho"; break;
case 4: s = "Urban"; break;
}
}
void RF_TerraTool::NthButtonPressed(int n)
{
set<long long> nuke;
switch(n) {
case 0:
{
for (map<long long, AsyncImage *>::iterator i = mImages.begin(); i != mImages.end(); ++i)
if (i->second->HasErr())
{
delete i->second;
nuke.insert(i->first);
}
for (set<long long>::iterator j = nuke.begin(); j != nuke.end(); ++j)
mImages.erase(*j);
}
break;
case 1:
case 2:
case 3:
case 4:
{
mLocator->Purge();
mHas = 0;
for (map<long long, AsyncImage *>::iterator i = mImages.begin(); i != mImages.end(); ++i)
delete i->second;
mImages.clear();
switch(n) {
case 2: mData = "1"; break;
case 3: mData = "2"; break;
case 4: mData = "4"; break;
}
}
break;
}
}
char * RF_TerraTool::GetStatusText(int x, int y)
{
int total = 0, done = 0, pending = 0, bad = 0;
for (map<long long, AsyncImage *>::iterator i = mImages.begin(); i != mImages.end(); ++i)
{
if (i->second->HasErr()) ++bad;
else if (i->second->IsDone()) ++done;
else ++pending;
++total;
}
static char buf[1024];
if (mHas)
sprintf(buf, "Domain=%d, X=%d-%d,Y=%d-%d Done=%d Pending=%d Bad=%d Total=%d", mDomain, mX1,mX2,mY1,mY2, done, pending, bad, total);
else
sprintf(buf, "No area established.");
return buf;
}
const char * RF_TerraTool::ResString(void)
{
static char resbuf[256];
sprintf(resbuf, "%dm", mRes);
return resbuf;
}
| 23.395455
| 133
| 0.642704
|
rromanchuk
|
d9bd35e18e8d8d40091d67985382764a270e1a65
| 1,359
|
cpp
|
C++
|
src/pacman/EventRunner.cpp
|
197708156EQUJ5/pac-man
|
30501ac43b9bcdd94b3cbb848c597882fc268492
|
[
"MIT"
] | null | null | null |
src/pacman/EventRunner.cpp
|
197708156EQUJ5/pac-man
|
30501ac43b9bcdd94b3cbb848c597882fc268492
|
[
"MIT"
] | null | null | null |
src/pacman/EventRunner.cpp
|
197708156EQUJ5/pac-man
|
30501ac43b9bcdd94b3cbb848c597882fc268492
|
[
"MIT"
] | null | null | null |
#include "pacman/EventRunner.hpp"
namespace pacman
{
EventRunner::~EventRunner()
{
board->release();
release();
}
bool EventRunner::init()
{
board = std::make_unique<Board>();
if (board->init())
{
renderer = board->getRenderer();
return true;
}
return true;
}
void EventRunner::gameLoop()
{
std::cout << "Entering game loop" << std::endl;
bool quit = false;
SDL_Event event;
while (!quit)
{
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderClear(renderer);
//Handle events on queue
while(SDL_PollEvent(&event) != 0)
{
switch(event.type)
{
/* Keyboard event */
/* Pass the event data onto PrintKeyInfo() */
case SDL_KEYDOWN:
case SDL_KEYUP:
//PrintKeyInfo( &event.key );
break;
/* SDL_QUIT event (window release) */
case SDL_QUIT:
quit = 1;
break;
default:
break;
}
board->paintComponents();
}
//Update screen
SDL_RenderPresent(renderer);
}
}
void EventRunner::release()
{
renderer = NULL;
}
} // namespace pacman
| 19.985294
| 65
| 0.486387
|
197708156EQUJ5
|
d9be3f062da62c24c3c0cfeb3347895b14b38587
| 436
|
hpp
|
C++
|
library/ATF/$012304FDD17B496AFBE8BAC81FBABAAE.hpp
|
lemkova/Yorozuya
|
f445d800078d9aba5de28f122cedfa03f26a38e4
|
[
"MIT"
] | 29
|
2017-07-01T23:08:31.000Z
|
2022-02-19T10:22:45.000Z
|
library/ATF/$012304FDD17B496AFBE8BAC81FBABAAE.hpp
|
kotopes/Yorozuya
|
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
|
[
"MIT"
] | 90
|
2017-10-18T21:24:51.000Z
|
2019-06-06T02:30:33.000Z
|
library/ATF/$012304FDD17B496AFBE8BAC81FBABAAE.hpp
|
kotopes/Yorozuya
|
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
|
[
"MIT"
] | 44
|
2017-12-19T08:02:59.000Z
|
2022-02-24T23:15:01.000Z
|
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <tagBinaryParam.hpp>
START_ATF_NAMESPACE
union $012304FDD17B496AFBE8BAC81FBABAAE
{
char *AnsiString;
wchar_t *UnicodeString;
int LVal;
__int16 SVal;
unsigned __int64 PVal;
tagBinaryParam BVal;
};
END_ATF_NAMESPACE
| 21.8
| 108
| 0.690367
|
lemkova
|
d9cf293f3eab99383b4ccc21d94936107c4d39fe
| 582
|
cpp
|
C++
|
_includes/leet638/leet638_1.cpp
|
mingdaz/leetcode
|
64f2e5ad0f0446d307e23e33a480bad5c9e51517
|
[
"MIT"
] | null | null | null |
_includes/leet638/leet638_1.cpp
|
mingdaz/leetcode
|
64f2e5ad0f0446d307e23e33a480bad5c9e51517
|
[
"MIT"
] | 8
|
2019-12-19T04:46:05.000Z
|
2022-02-26T03:45:22.000Z
|
_includes/leet638/leet638_1.cpp
|
mingdaz/leetcode
|
64f2e5ad0f0446d307e23e33a480bad5c9e51517
|
[
"MIT"
] | null | null | null |
class Solution {
public:
int shoppingOffers(vector<int>& price, vector<vector<int>>& special, vector<int>& needs) {
int res = 0;
int n = needs.size();
for (int i = 0; i < n; i++) {
res += price[i] * needs[i];
}
for (int i = 0; i < special.size(); i++) {
bool ok = true;
for (int j = 0; j < n; j++) {
if (needs[j] < special[i][j]) ok = false;
needs[j] -= special[i][j];
}
if (ok) {
res = min(res, special[i][n] + shoppingOffers(price, special, needs));
}
for (int j = 0; j < n; j++) needs[j] += special[i][j];
}
return res;
}
};
| 26.454545
| 94
| 0.517182
|
mingdaz
|
d9cfd8789dbfee41741e5eddd84bcf31bc4e77a6
| 3,023
|
cpp
|
C++
|
src/transactions/test/test_helper/SetOptionsTestHelper.cpp
|
RomanTkachenkoDistr/SwarmCore
|
db0544758e7bb3c879778cfdd6946b9a72ba23ab
|
[
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
src/transactions/test/test_helper/SetOptionsTestHelper.cpp
|
RomanTkachenkoDistr/SwarmCore
|
db0544758e7bb3c879778cfdd6946b9a72ba23ab
|
[
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
src/transactions/test/test_helper/SetOptionsTestHelper.cpp
|
RomanTkachenkoDistr/SwarmCore
|
db0544758e7bb3c879778cfdd6946b9a72ba23ab
|
[
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
#include "SetOptionsTestHelper.h"
#include "ledger/ReviewableRequestHelper.h"
#include "transactions/SetOptionsOpFrame.h"
#include "test/test_marshaler.h"
namespace stellar
{
namespace txtest
{
SetOptionsTestHelper::SetOptionsTestHelper(TestManager::pointer testManager) : TxHelper(testManager)
{
}
TransactionFramePtr
SetOptionsTestHelper::createSetOptionsTx(Account &source, ThresholdSetter *thresholdSetter, Signer *signer,
TrustData *trustData, LimitsUpdateRequestData *limitsUpdateRequestData)
{
Operation op;
op.body.type(OperationType::SET_OPTIONS);
SetOptionsOp& setOptionsOp = op.body.setOptionsOp();
if (thresholdSetter)
{
if (thresholdSetter->masterWeight)
setOptionsOp.masterWeight.activate() = *thresholdSetter->masterWeight;
if (thresholdSetter->lowThreshold)
setOptionsOp.lowThreshold.activate() = *thresholdSetter->lowThreshold;
if (thresholdSetter->medThreshold)
setOptionsOp.medThreshold.activate() = *thresholdSetter->medThreshold;
if (thresholdSetter->highThreshold)
setOptionsOp.highThreshold.activate() = *thresholdSetter->highThreshold;
}
if (signer)
setOptionsOp.signer.activate() = *signer;
if (trustData)
setOptionsOp.trustData.activate() = *trustData;
if (limitsUpdateRequestData)
setOptionsOp.limitsUpdateRequestData.activate() = *limitsUpdateRequestData;
return TxHelper::txFromOperation(source, op, nullptr);
}
void
SetOptionsTestHelper::applySetOptionsTx(Account &source, ThresholdSetter *thresholdSetter, Signer *signer,
TrustData *trustData, LimitsUpdateRequestData *limitsUpdateRequestData,
SetOptionsResultCode expectedResult, SecretKey *txSigner)
{
Database& db = mTestManager->getDB();
TransactionFramePtr txFrame;
txFrame = createSetOptionsTx(source, thresholdSetter, signer, trustData,
limitsUpdateRequestData);
if (txSigner)
{
txFrame->getEnvelope().signatures.clear();
txFrame->addSignature(*txSigner);
}
mTestManager->applyCheck(txFrame);
if(limitsUpdateRequestData)
{
auto txResult = txFrame->getResult();
auto opResult = txResult.result.results()[0];
SetOptionsResult setOptionsResult = opResult.tr().setOptionsResult();
auto limitsUpdateRequestID = setOptionsResult.success().limitsUpdateRequestID;
auto request = ReviewableRequestHelper::Instance()->loadRequest(limitsUpdateRequestID, db);
REQUIRE(!!request);
}
REQUIRE(SetOptionsOpFrame::getInnerCode(
txFrame->getResult().result.results()[0]) == expectedResult);
}
}
}
| 37.320988
| 116
| 0.640754
|
RomanTkachenkoDistr
|
d9d1072c6cab88f061fe52382162364f6575baa1
| 849
|
cpp
|
C++
|
src/libais/ais10.cpp
|
SkyTruth/libais
|
b9e10156d99994d18ce11c43ec04e7b0875db135
|
[
"Apache-2.0"
] | null | null | null |
src/libais/ais10.cpp
|
SkyTruth/libais
|
b9e10156d99994d18ce11c43ec04e7b0875db135
|
[
"Apache-2.0"
] | null | null | null |
src/libais/ais10.cpp
|
SkyTruth/libais
|
b9e10156d99994d18ce11c43ec04e7b0875db135
|
[
"Apache-2.0"
] | null | null | null |
// : UTC and date query
#include "ais.h"
namespace libais {
Ais10::Ais10(const char *nmea_payload, const size_t pad)
: AisMsg(nmea_payload, pad), spare(0), dest_mmsi(0), spare2(0) {
assert(message_id == 10);
if (pad != 0 || num_chars != 12) {
status = AIS_ERR_BAD_BIT_COUNT;
return;
}
AisBitset bs;
const AIS_STATUS r = bs.ParseNmeaPayload(nmea_payload, pad);
if (r != AIS_OK) {
status = r;
return;
}
bs.SeekTo(38);
spare = bs.ToUnsignedInt(38, 2);
dest_mmsi = bs.ToUnsignedInt(40, 30);
spare2 = bs.ToUnsignedInt(70, 2);
assert(bs.GetRemaining() == 0);
status = AIS_OK;
}
ostream& operator<< (ostream &o, const Ais10 &msg) {
return o << msg.message_id << ": " << msg.mmsi
<< " dest=" << msg.dest_mmsi
<< " " << msg.spare << " " << msg.spare2;
}
} // namespace libais
| 20.707317
| 68
| 0.599529
|
SkyTruth
|
d9d2b75dc44d2ea053bfdb7994f68aaefe1503a4
| 5,316
|
cpp
|
C++
|
test/src/test_csv_line_reader.cpp
|
mguid65/csvio
|
933c11e71d3f796932808da879c89524688b3895
|
[
"MIT"
] | null | null | null |
test/src/test_csv_line_reader.cpp
|
mguid65/csvio
|
933c11e71d3f796932808da879c89524688b3895
|
[
"MIT"
] | 3
|
2019-07-16T23:53:29.000Z
|
2019-09-20T03:28:13.000Z
|
test/src/test_csv_line_reader.cpp
|
mguid65/csvio
|
933c11e71d3f796932808da879c89524688b3895
|
[
"MIT"
] | 3
|
2019-07-10T20:09:28.000Z
|
2019-07-16T21:00:46.000Z
|
/*
* MIT License
*
* Copyright (c) 2019 Matthew Guidry
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include <sstream>
#include "csv_io.hpp"
#include "gtest/gtest.h"
namespace {
TEST(CSVLineReaderTest, ConstructorFromIStream) {
std::istringstream data("");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ(0u, csv_lr.lcount());
EXPECT_EQ(true, csv_lr.good());
EXPECT_EQ("", csv_lr.readline());
}
TEST(CSVLineReaderTest, ReadOneBlankLine) {
std::istringstream data("");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("", csv_lr.readline());
EXPECT_EQ(1u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadOneSampleCSVLine) {
std::istringstream data("1,1,1,1,1,1,1,1\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("1,1,1,1,1,1,1,1\n", csv_lr.readline());
EXPECT_EQ(1u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadOneSampleNoNewline) {
std::istringstream data("1,1,1,1,1,1,1,1");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("1,1,1,1,1,1,1,1", csv_lr.readline());
EXPECT_EQ(1u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, CheckGood) {
std::istringstream data("1,1,1,1,1,1,1,1\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("1,1,1,1,1,1,1,1\n", csv_lr.readline());
EXPECT_EQ("", csv_lr.readline());
EXPECT_EQ(2u, csv_lr.lcount()); // not sure if I should let this be 1 or 2
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadTwoSampleCSVLines) {
std::istringstream data(
"1,1,1,1,1,1,1,1\n"
"2,2,2,2,2,2,2,2\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("1,1,1,1,1,1,1,1\n", csv_lr.readline());
EXPECT_EQ("2,2,2,2,2,2,2,2\n", csv_lr.readline());
EXPECT_EQ(2u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadOneSampleCSVLineAllNewLines) {
std::istringstream data("\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\"\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\"\n", csv_lr.readline());
EXPECT_EQ(1u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadOneSampleLineHardParse) {
std::istringstream data(
"\"\"\"one\"\"\",\"tw\n"
"o\",\"\"\"th,r\n"
"ee\"\"\",\"\"\"fo\n"
"u\"\"r\"\"\",5,6,7,8\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ(
"\"\"\"one\"\"\",\"tw\n"
"o\",\"\"\"th,r\n"
"ee\"\"\",\"\"\"fo\n"
"u\"\"r\"\"\",5,6,7,8\n",
csv_lr.readline());
EXPECT_EQ("", csv_lr.readline());
EXPECT_EQ(2u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadOnePrematureEOF) {
std::istringstream data("1,1,1,\"1\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("", csv_lr.readline());
EXPECT_EQ(0u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadMultiMixed) {
std::istringstream data(
"\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\"\n"
"1,1,1,1,1,1,1,1\n"
"2,2,2,2,2,2,2,2\n"
"\"\"\"one\"\"\",\"tw\n"
"o\",\"\"\"th,r\n"
"ee\"\"\",\"\"\"fo\n"
"u\"\"r\"\"\",5,6,7,8\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\",\"1\n\"\n", csv_lr.readline());
EXPECT_EQ("1,1,1,1,1,1,1,1\n", csv_lr.readline());
EXPECT_EQ("2,2,2,2,2,2,2,2\n", csv_lr.readline());
EXPECT_EQ(
"\"\"\"one\"\"\",\"tw\n"
"o\",\"\"\"th,r\n"
"ee\"\"\",\"\"\"fo\n"
"u\"\"r\"\"\",5,6,7,8\n",
csv_lr.readline());
EXPECT_EQ("", csv_lr.readline());
EXPECT_EQ(5u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
TEST(CSVLineReaderTest, ReadTwoLinesCRLF) {
std::istringstream data(
"1,1,1,1,1,1,1,1\r\n"
"2,2,2,2,2,2,2,2\r\n");
csvio::util::CSVLineReader csv_lr(data);
EXPECT_EQ("1,1,1,1,1,1,1,1\r\n", csv_lr.readline());
EXPECT_EQ("2,2,2,2,2,2,2,2\r\n", csv_lr.readline());
EXPECT_EQ(2u, csv_lr.lcount());
EXPECT_EQ(false, csv_lr.good());
}
} // namespace
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 30.906977
| 100
| 0.626223
|
mguid65
|
d9d68dc37e878c506047a12804f6c23a03ac6c95
| 4,319
|
cpp
|
C++
|
service/nametag/piles.cpp
|
zostay/Mysook
|
3611ddf0a116d18ebc58a3050f9fe35c2684c906
|
[
"Artistic-2.0"
] | 3
|
2019-06-30T04:15:18.000Z
|
2019-12-19T17:32:07.000Z
|
service/nametag/piles.cpp
|
zostay/Mysook
|
3611ddf0a116d18ebc58a3050f9fe35c2684c906
|
[
"Artistic-2.0"
] | null | null | null |
service/nametag/piles.cpp
|
zostay/Mysook
|
3611ddf0a116d18ebc58a3050f9fe35c2684c906
|
[
"Artistic-2.0"
] | null | null | null |
#include <inttypes.h>
#include "ops.h"
#define PILES 6
#define UPDATE_PIXEL 1
uint32_t program[] = {
OP_SUB, 1, OP_PUSH, 3, OP_READARG, OP_PUSH, 0, OP_EQ, OP_NOT, OP_PUSH, 2,
OP_CMP, OP_PUSH, 0, OP_FOREGROUND, OP_SUB, 2, OP_PUSH, 3, OP_READARG,
OP_PUSH, 1, OP_EQ, OP_NOT, OP_PUSH, 3, OP_CMP, OP_PUSH, 255,
OP_FOREGROUND, OP_SUB, 3, OP_PUSH, 3, OP_READARG, OP_PUSH, 2, OP_EQ,
OP_NOT, OP_PUSH, 4, OP_CMP, OP_PUSH, 16776960, OP_FOREGROUND, OP_SUB, 4,
OP_PUSH, 3, OP_READARG, OP_PUSH, 3, OP_EQ, OP_NOT, OP_PUSH, 5, OP_CMP,
OP_PUSH, 16711680, OP_FOREGROUND, OP_SUB, 5, OP_PUSH, 1, OP_READARG,
OP_PUSH, 2, OP_READARG, OP_PIXEL, OP_RETURN, OP_SUB, 6, OP_PUSH, 0,
OP_PUSH, 0, OP_PUSH, 0, OP_WIDTH, OP_HEIGHT, OP_MUL, OP_PUSH, 0, OP_SWAP,
OP_ALLOC, OP_PUSH, 10, OP_BRIGHTNESS, OP_PUSH, 1, OP_URGENCY, OP_PUSH, 0,
OP_FOREGROUND, OP_FILL, OP_TICK, OP_SUB, 7, OP_RAND, OP_WIDTH, OP_MOD,
OP_PUSH, 0, OP_WRITE, OP_RAND, OP_HEIGHT, OP_MOD, OP_PUSH, 1, OP_WRITE,
OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_READ, OP_WIDTH, OP_MUL, OP_ADD,
OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 2, OP_READ, OP_PUSH,
3, OP_ADD, OP_READ, OP_PUSH, 1, OP_ADD, OP_SWAP, OP_PUSH, 3, OP_ADD,
OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3, OP_ADD, OP_READ, OP_PUSH, 1,
OP_READ, OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_GOSUB, OP_POP, OP_POP,
OP_POP, OP_PUSH, 0, OP_PUSH, 1, OP_WRITE, OP_SUB, 9, OP_PUSH, 1, OP_READ,
OP_HEIGHT, OP_GE, OP_NOT, OP_PUSH, 11, OP_CMP, OP_PUSH, 10, OP_GOTO,
OP_SUB, 11, OP_PUSH, 0, OP_PUSH, 0, OP_WRITE, OP_SUB, 12, OP_PUSH, 0,
OP_READ, OP_WIDTH, OP_GE, OP_NOT, OP_PUSH, 14, OP_CMP, OP_PUSH, 13,
OP_GOTO, OP_SUB, 14, OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_READ, OP_WIDTH,
OP_MUL, OP_ADD, OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3,
OP_ADD, OP_READ, OP_PUSH, 4, OP_GE, OP_NOT, OP_PUSH, 15, OP_CMP, OP_PUSH,
2, OP_READ, OP_PUSH, 0, OP_SWAP, OP_PUSH, 3, OP_ADD, OP_WRITE, OP_PUSH, 0,
OP_READ, OP_PUSH, 0, OP_GT, OP_NOT, OP_PUSH, 16, OP_CMP, OP_PUSH, 0,
OP_READ, OP_PUSH, 1, OP_MIN, OP_PUSH, 1, OP_READ, OP_WIDTH, OP_MUL,
OP_ADD, OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 2, OP_READ,
OP_PUSH, 3, OP_ADD, OP_READ, OP_PUSH, 1, OP_ADD, OP_SWAP, OP_PUSH, 3,
OP_ADD, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3, OP_ADD, OP_READ,
OP_PUSH, 1, OP_READ, OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_MIN, OP_PUSH, 1,
OP_GOSUB, OP_POP, OP_POP, OP_POP, OP_SUB, 16, OP_PUSH, 1, OP_READ,
OP_PUSH, 0, OP_GT, OP_NOT, OP_PUSH, 17, OP_CMP, OP_PUSH, 0, OP_READ,
OP_PUSH, 1, OP_READ, OP_PUSH, 1, OP_MIN, OP_WIDTH, OP_MUL, OP_ADD,
OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 2, OP_READ, OP_PUSH,
3, OP_ADD, OP_READ, OP_PUSH, 1, OP_ADD, OP_SWAP, OP_PUSH, 3, OP_ADD,
OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3, OP_ADD, OP_READ, OP_PUSH, 1,
OP_READ, OP_PUSH, 1, OP_MIN, OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_GOSUB,
OP_POP, OP_POP, OP_POP, OP_SUB, 17, OP_PUSH, 0, OP_READ, OP_WIDTH,
OP_PUSH, 1, OP_MIN, OP_LT, OP_NOT, OP_PUSH, 18, OP_CMP, OP_PUSH, 0,
OP_READ, OP_PUSH, 1, OP_ADD, OP_PUSH, 1, OP_READ, OP_WIDTH, OP_MUL,
OP_ADD, OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 2, OP_READ,
OP_PUSH, 3, OP_ADD, OP_READ, OP_PUSH, 1, OP_ADD, OP_SWAP, OP_PUSH, 3,
OP_ADD, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3, OP_ADD, OP_READ,
OP_PUSH, 1, OP_READ, OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_ADD, OP_PUSH, 1,
OP_GOSUB, OP_POP, OP_POP, OP_POP, OP_SUB, 18, OP_PUSH, 1, OP_READ,
OP_HEIGHT, OP_PUSH, 1, OP_MIN, OP_LT, OP_NOT, OP_PUSH, 19, OP_CMP,
OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_READ, OP_PUSH, 1, OP_ADD, OP_WIDTH,
OP_MUL, OP_ADD, OP_PUSH, 2, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 2,
OP_READ, OP_PUSH, 3, OP_ADD, OP_READ, OP_PUSH, 1, OP_ADD, OP_SWAP,
OP_PUSH, 3, OP_ADD, OP_WRITE, OP_PUSH, 2, OP_READ, OP_PUSH, 3, OP_ADD,
OP_READ, OP_PUSH, 1, OP_READ, OP_PUSH, 1, OP_ADD, OP_PUSH, 0, OP_READ,
OP_PUSH, 1, OP_GOSUB, OP_POP, OP_POP, OP_POP, OP_SUB, 19, OP_SUB, 15,
OP_PUSH, 0, OP_READ, OP_PUSH, 1, OP_ADD, OP_PUSH, 0, OP_WRITE, OP_PUSH,
12, OP_GOTO, OP_SUB, 13, OP_PUSH, 1, OP_READ, OP_PUSH, 1, OP_ADD, OP_PUSH,
1, OP_WRITE, OP_PUSH, 9, OP_GOTO, OP_SUB, 10, OP_TICK, OP_PUSH, 7,
OP_GOTO, OP_SUB, 8, OP_RETURN, OP_HALT, OP_HALT
};
| 65.439394
| 78
| 0.686038
|
zostay
|
d9da38530ac9b7e28f6f2a4f4907aaedebe8ecae
| 6,299
|
cpp
|
C++
|
src/renderer-backend-egl.cpp
|
ceyusa/WPEBackend-fdo
|
e4c578f23359dba4d5abbd14b108f59e1b0701c1
|
[
"BSD-2-Clause"
] | 16
|
2018-06-26T13:37:04.000Z
|
2022-03-11T14:08:22.000Z
|
src/renderer-backend-egl.cpp
|
ceyusa/WPEBackend-fdo
|
e4c578f23359dba4d5abbd14b108f59e1b0701c1
|
[
"BSD-2-Clause"
] | 118
|
2018-03-07T11:01:45.000Z
|
2022-02-01T19:44:14.000Z
|
src/renderer-backend-egl.cpp
|
ceyusa/WPEBackend-fdo
|
e4c578f23359dba4d5abbd14b108f59e1b0701c1
|
[
"BSD-2-Clause"
] | 16
|
2018-02-20T19:31:13.000Z
|
2021-02-23T21:10:57.000Z
|
/*
* Copyright (C) 2017, 2018 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
// Should be included early to force through the Wayland EGL platform
#include <wayland-egl.h>
#include <epoxy/egl.h>
#include <wpe/wpe-egl.h>
#include "egl-client.h"
#include "egl-client-dmabuf-pool.h"
#include "egl-client-wayland.h"
#include "interfaces.h"
#include "ws-client.h"
namespace {
class Backend final : public WS::BaseBackend {
public:
Backend(int hostFD)
: WS::BaseBackend(hostFD)
{
switch (type()) {
case WS::ClientImplementationType::Invalid:
g_error("Backend: invalid valid client implementation");
break;
case WS::ClientImplementationType::DmabufPool:
m_impl = WS::EGLClient::BackendImpl::create<WS::EGLClient::BackendDmabufPool>(*this);
break;
case WS::ClientImplementationType::Wayland:
m_impl = WS::EGLClient::BackendImpl::create<WS::EGLClient::BackendWayland>(*this);
break;
}
}
~Backend() = default;
using WS::BaseBackend::display;
std::unique_ptr<WS::EGLClient::BackendImpl> m_impl;
};
class Target final : public WS::BaseTarget, public WS::BaseTarget::Impl {
public:
Target(struct wpe_renderer_backend_egl_target* target, int hostFD)
: WS::BaseTarget(hostFD, *this)
, m_target(target)
{ }
~Target()
{
m_impl = nullptr;
m_target = nullptr;
}
void initialize(Backend& backend, uint32_t width, uint32_t height)
{
WS::BaseTarget::initialize(backend);
switch (backend.type()) {
case WS::ClientImplementationType::Invalid:
g_error("Target: invalid valid client implementation");
break;
case WS::ClientImplementationType::DmabufPool:
m_impl = WS::EGLClient::TargetImpl::create<WS::EGLClient::TargetDmabufPool>(*this, width, height);
break;
case WS::ClientImplementationType::Wayland:
m_impl = WS::EGLClient::TargetImpl::create<WS::EGLClient::TargetWayland>(*this, width, height);
break;
}
}
using WS::BaseTarget::requestFrame;
std::unique_ptr<WS::EGLClient::TargetImpl> m_impl;
private:
// WS::BaseTarget::Impl
void dispatchFrameComplete() override
{
wpe_renderer_backend_egl_target_dispatch_frame_complete(m_target);
}
struct wpe_renderer_backend_egl_target* m_target { nullptr };
};
} // namespace
struct wpe_renderer_backend_egl_interface fdo_renderer_backend_egl = {
// create
[](int host_fd) -> void*
{
return new Backend(host_fd);
},
// destroy
[](void* data)
{
auto* backend = reinterpret_cast<Backend*>(data);
delete backend;
},
// get_native_display
[](void* data) -> EGLNativeDisplayType
{
auto& backend = *reinterpret_cast<Backend*>(data);
return backend.m_impl->nativeDisplay();
},
// get_platform
[](void* data) -> uint32_t
{
auto& backend = *reinterpret_cast<Backend*>(data);
return backend.m_impl->platform();
},
};
struct wpe_renderer_backend_egl_target_interface fdo_renderer_backend_egl_target = {
// create
[](struct wpe_renderer_backend_egl_target* target, int host_fd) -> void*
{
return new Target(target, host_fd);
},
// destroy
[](void* data)
{
auto* target = reinterpret_cast<Target*>(data);
delete target;
},
// initialize
[](void* data, void* backend_data, uint32_t width, uint32_t height)
{
auto& target = *reinterpret_cast<Target*>(data);
auto& backend = *reinterpret_cast<Backend*>(backend_data);
target.initialize(backend, width, height);
},
// get_native_window
[](void* data) -> EGLNativeWindowType
{
auto& target = *reinterpret_cast<Target*>(data);
return target.m_impl->nativeWindow();
},
// resize
[](void* data, uint32_t width, uint32_t height)
{
auto& target = *reinterpret_cast<Target*>(data);
target.m_impl->resize(width, height);
},
// frame_will_render
[](void* data)
{
auto& target = *reinterpret_cast<Target*>(data);
target.m_impl->frameWillRender();
},
// frame_rendered
[](void* data)
{
auto& target = *reinterpret_cast<Target*>(data);
target.m_impl->frameRendered();
},
#if WPE_CHECK_VERSION(1,9,1)
// deinitialize
[](void* data)
{
auto& target = *reinterpret_cast<Target*>(data);
target.m_impl->deinitialize();
},
#endif
};
struct wpe_renderer_backend_egl_offscreen_target_interface fdo_renderer_backend_egl_offscreen_target = {
// create
[]() -> void*
{
return nullptr;
},
// destroy
[](void* data)
{
},
// initialize
[](void* data, void* backend_data)
{
},
// get_native_window
[](void* data) -> EGLNativeWindowType
{
return nullptr;
},
};
| 29.995238
| 110
| 0.650897
|
ceyusa
|
d9defd706fc158d22c70ec08eb89617f14f9cd4b
| 35,644
|
cpp
|
C++
|
Nana.Cpp03/source/gui/programming_interface.cpp
|
gfannes/nana
|
3b8d33f9a98579684ea0440b6952deabe61bd978
|
[
"BSL-1.0"
] | 1
|
2018-02-09T21:25:13.000Z
|
2018-02-09T21:25:13.000Z
|
Nana.Cpp03/source/gui/programming_interface.cpp
|
gfannes/nana
|
3b8d33f9a98579684ea0440b6952deabe61bd978
|
[
"BSL-1.0"
] | null | null | null |
Nana.Cpp03/source/gui/programming_interface.cpp
|
gfannes/nana
|
3b8d33f9a98579684ea0440b6952deabe61bd978
|
[
"BSL-1.0"
] | null | null | null |
/*
* Nana GUI Programming Interface Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/programming_interface.cpp
*/
#include <nana/gui/programming_interface.hpp>
#include <nana/system/platform.hpp>
namespace nana{ namespace gui{
//restrict
// this name is only visible for this compiling-unit
namespace restrict
{
typedef gui::detail::bedrock::core_window_t core_window_t;
typedef gui::detail::bedrock::interface_type interface_type;
gui::detail::bedrock& bedrock = gui::detail::bedrock::instance();
gui::detail::bedrock::window_manager_t& window_manager = bedrock.wd_manager;
}
namespace effects
{
class effects_accessor
{
public:
static bground_interface * create(const bground_factory_interface& factory)
{
return factory.create();
}
};
}
namespace API
{
void effects_edge_nimbus(window wd, effects::edge_nimbus::t en)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
restrict::core_window_t::edge_nimbus_container & cont = iwd->root_widget->other.attribute.root->effects_edge_nimbus;
if(en)
{
if(iwd->effect.edge_nimbus == effects::edge_nimbus::none)
{
restrict::core_window_t::edge_nimbus_action act = {iwd};
cont.push_back(act);
}
iwd->effect.edge_nimbus = static_cast<effects::edge_nimbus::t>(iwd->effect.edge_nimbus | en);
}
else
{
if(iwd->effect.edge_nimbus)
{
for(restrict::core_window_t::edge_nimbus_container::iterator i = cont.begin(); i != cont.end(); ++i)
{
if(i->window == iwd)
{
cont.erase(i);
break;
}
}
}
iwd->effect.edge_nimbus = effects::edge_nimbus::none;
}
}
}
}
effects::edge_nimbus::t effects_edge_nimbus(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return iwd->effect.edge_nimbus;
}
return effects::edge_nimbus::none;
}
void effects_bground(window wd, const effects::bground_factory_interface& factory, double fade_rate)
{
if(0 == wd)
return;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
effects::bground_interface* new_effect_ptr = effects::effects_accessor::create(factory);
if(0 == new_effect_ptr)
return;
delete iwd->effect.bground;
iwd->effect.bground = new_effect_ptr;
iwd->effect.bground_fade_rate = fade_rate;
restrict::window_manager.enable_effects_bground(iwd, true);
API::refresh_window(wd);
}
}
bground_mode::t effects_bground_mode(window wd)
{
if(0 == wd) return bground_mode::none;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->effect.bground)
return (iwd->effect.bground_fade_rate <= 0.009 ? bground_mode::basic : bground_mode::blend);
return bground_mode::none;
}
void effects_bground_remove(window wd)
{
if(0 == wd) return;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
delete iwd->effect.bground;
iwd->effect.bground = 0;
iwd->effect.bground_fade_rate = 0;
restrict::window_manager.enable_effects_bground(iwd, false);
API::refresh_window(wd);
}
}
namespace dev
{
void attach_drawer(window wd, drawer_trigger& dr)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
iwd->drawer.graphics.make(iwd->dimension.width, iwd->dimension.height);
iwd->drawer.graphics.rectangle(iwd->color.background, true);
iwd->drawer.attached(dr);
make_drawer_event<events::size>(wd);
iwd->drawer.refresh(); //Always redrawe no matter it is visible or invisible. This can make the graphics data correctly.
}
}
}
void detach_drawer(window wd)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
reinterpret_cast<restrict::core_window_t*>(wd)->drawer.detached();
}
}
void umake_drawer_event(window wd)
{
restrict::bedrock.evt_manager.umake(wd, true);
}
nana::string window_caption(window wd)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
if(iwd->other.category == category::flags::root)
return restrict::interface_type::window_caption(iwd->root);
return iwd->title;
}
}
return nana::string();
}
void window_caption(window wd, const nana::string& title)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
iwd->title = title;
if(iwd->other.category == category::flags::root)
restrict::interface_type::window_caption(iwd->root, title);
}
restrict::window_manager.update(iwd, true, false);
}
}
window create_window(window owner, bool nested, const rectangle& r, const appearance& ap)
{
return reinterpret_cast<window>(restrict::window_manager.create_root(reinterpret_cast<restrict::core_window_t*>(owner), nested, r, ap));
}
window create_widget(window parent, const rectangle& r)
{
return reinterpret_cast<window>(restrict::window_manager.create_widget(reinterpret_cast<restrict::core_window_t*>(parent), r, false));
}
window create_lite_widget(window parent, const rectangle& r)
{
return reinterpret_cast<window>(restrict::window_manager.create_widget(reinterpret_cast<restrict::core_window_t*>(parent), r, true));
}
window create_frame(window parent, const rectangle& r)
{
return reinterpret_cast<window>(restrict::window_manager.create_frame(reinterpret_cast<restrict::core_window_t*>(parent), r));
}
paint::graphics * window_graphics(window wd)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return &reinterpret_cast<restrict::core_window_t*>(wd)->drawer.graphics;
}
return 0;
}
}//end namespace dev
//exit
//close all windows in current thread
void exit()
{
internal_scope_guard isg;
std::vector<restrict::core_window_t*> v;
restrict::window_manager.all_handles(v);
if(v.size())
{
std::vector<native_window_type> roots;
native_window_type root = 0;
unsigned tid = nana::system::this_thread_id();
for(std::vector<restrict::core_window_t*>::iterator i = v.begin(), end = v.end(); i != end; ++i)
{
restrict::core_window_t * wd = *i;
if((wd->thread_id == tid) && (wd->root != root))
{
root = wd->root;
if(roots.end() == std::find(roots.begin(), roots.end(), root))
roots.push_back(root);
}
}
std::for_each(roots.begin(), roots.end(), restrict::interface_type::close_window);
}
}
//transform_shortkey_text
//@brief: This function searchs whether the text contains a '&' and removes the character for transforming.
// If the text contains more than one '&' charachers, the others are ignored. e.g
// text = "&&a&bcd&ef", the result should be "&abcdef", shortkey = 'b', and pos = 2.
//@param, text: the text is transformed.
//@param, shortkey: the character which indicates a short key.
//@param, skpos: retrives the shortkey position if it is not a null_ptr;
nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos)
{
shortkey = 0;
nana::string::size_type off = 0;
while(true)
{
nana::string::size_type pos = text.find_first_of('&', off);
if(pos != nana::string::npos)
{
text.erase(pos, 1);
if(shortkey == 0 && pos < text.length())
{
shortkey = text.at(pos);
if(shortkey == '&') //This indicates the text contains "&&", it means the symbol have to be ignored.
shortkey = 0;
else if(skpos)
*skpos = pos;
}
off = pos + 1;
}
else
break;
}
return text;
}
bool register_shortkey(window wd, unsigned long key)
{
return restrict::window_manager.register_shortkey(reinterpret_cast<restrict::core_window_t*>(wd), key);
}
void unregister_shortkey(window wd)
{
restrict::window_manager.unregister_shortkey(reinterpret_cast<restrict::core_window_t*>(wd));
}
nana::size screen_size()
{
return restrict::interface_type::screen_size();
}
rectangle screen_area_from_point(const point& pos)
{
return restrict::interface_type::screen_area_from_point(pos);
}
point cursor_position()
{
return restrict::interface_type::cursor_position();
}
rectangle make_center(unsigned width, unsigned height)
{
nana::size screen = restrict::interface_type::screen_size();
nana::rectangle result(
width > screen.width? 0: (screen.width - width)>>1,
height > screen.height? 0: (screen.height - height)>> 1,
width, height
);
return result;
}
nana::rectangle make_center(window wd, unsigned width, unsigned height)
{
nana::rectangle r = make_center(width, height);
nana::point pos(r.x, r.y);
calc_window_point(wd, pos);
r.x = pos.x;
r.y = pos.y;
return r;
}
void window_icon_default(const paint::image& img)
{
restrict::window_manager.default_icon(img);
}
void window_icon(window wd, const paint::image& img)
{
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), img);
}
bool empty_window(window wd)
{
return (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)) == false);
}
native_window_type root(window wd)
{
return restrict::bedrock.root(reinterpret_cast<restrict::core_window_t*>(wd));
}
window root(native_window_type wd)
{
return reinterpret_cast<window>(restrict::window_manager.root(wd));
}
bool enabled_double_click(window wd, bool dbl)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
bool result = iwd->flags.dbl_click;
iwd->flags.dbl_click = dbl;
return result;
}
}
return false;
}
void fullscreen(window wd, bool v)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
reinterpret_cast<restrict::core_window_t*>(wd)->flags.fullscreen = v;
}
}
bool insert_frame(window frame, native_window_type native_window)
{
return restrict::window_manager.insert_frame(reinterpret_cast<restrict::core_window_t*>(frame), native_window);
}
native_window_type frame_container(window frame)
{
if(frame)
{
internal_scope_guard isg;
if(reinterpret_cast<restrict::core_window_t*>(frame)->other.category == category::flags::frame)
return reinterpret_cast<restrict::core_window_t*>(frame)->other.attribute.frame->container;
}
return 0;
}
native_window_type frame_element(window frame, unsigned index)
{
if(frame)
{
internal_scope_guard isg;
if(reinterpret_cast<restrict::core_window_t*>(frame)->other.category == category::flags::frame)
{
if(index < reinterpret_cast<restrict::core_window_t*>(frame)->other.attribute.frame->attach.size())
return reinterpret_cast<restrict::core_window_t*>(frame)->other.attribute.frame->attach.at(index);
}
}
return 0;
}
void close_window(window wd)
{
restrict::window_manager.close(reinterpret_cast<restrict::core_window_t*>(wd));
}
void show_window(window wd, bool show)
{
restrict::window_manager.show(reinterpret_cast<restrict::core_window_t*>(wd), show);
}
bool visible(window wd)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
if(iwd->other.category == category::flags::root)
return restrict::interface_type::is_window_visible(iwd->root);
return iwd->visible;
}
}
return false;
}
void restore_window(window wd)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
if(iwd->other.category == category::flags::root)
restrict::interface_type::restore_window(iwd->root);
}
}
}
void zoom_window(window wd, bool ask_for_max)
{
if(wd)
{
restrict::core_window_t* core_wd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard lock;
if(restrict::window_manager.available(core_wd))
{
if(category::flags::root == core_wd->other.category)
restrict::interface_type::zoom_window(core_wd->root, ask_for_max);
}
}
}
window get_parent_window(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return reinterpret_cast<window>(iwd->other.category == category::flags::root ? iwd->owner : iwd->parent);
}
return 0;
}
window get_owner_window(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && (iwd->other.category == category::flags::root))
{
native_window_type owner = restrict::interface_type::get_owner_window(iwd->root);
if(owner)
return reinterpret_cast<window>(restrict::window_manager.root(owner));
}
}
return 0;
}
void umake_event(window wd)
{
restrict::bedrock.evt_manager.umake(wd, false);
}
void umake_event(event_handle eh)
{
restrict::bedrock.evt_manager.umake(eh);
}
nana::point window_position(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
return ( (iwd->other.category == category::flags::root) ?
restrict::interface_type::window_position(iwd->root) : iwd->pos_owner);
}
}
return nana::point();
}
void move_window(window wd, int x, int y)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.move(iwd, x, y, false))
{
if(category::flags::root != iwd->other.category)
iwd = reinterpret_cast<restrict::core_window_t*>(API::get_parent_window(wd));
restrict::window_manager.update(iwd, false, false);
}
}
void move_window(window wd, int x, int y, unsigned width, unsigned height)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.move(iwd, x, y, width, height))
{
if(category::flags::root != iwd->other.category)
iwd = reinterpret_cast<restrict::core_window_t*>(API::get_parent_window(wd));
restrict::window_manager.update(iwd, false, false);
}
}
bool set_window_z_order(window wd, window wd_after, z_order_action::t action_if_no_wd_after)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
if(category::flags::root == iwd->other.category)
{
if(wd_after)
{
restrict::core_window_t * const iwd_after = reinterpret_cast<restrict::core_window_t*>(wd_after);
if(restrict::window_manager.available(iwd_after) && (iwd_after->other.category == category::flags::root))
{
restrict::interface_type::set_window_z_order(iwd->root, iwd_after->root, z_order_action::none);
return true;
}
}
else
{
restrict::interface_type::set_window_z_order(iwd->root, 0, action_if_no_wd_after);
return true;
}
}
}
}
return false;
}
nana::size window_size(window wd)
{
nana::rectangle r;
API::window_rectangle(wd, r);
return nana::size(r.width, r.height);
}
void window_size(window wd, unsigned width, unsigned height)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.size(iwd, width, height, false, false))
{
if(category::flags::root != iwd->other.category)
iwd = reinterpret_cast<restrict::core_window_t*>(API::get_parent_window(wd));
restrict::window_manager.update(iwd, false, false);
}
}
bool window_rectangle(window wd, rectangle& r)
{
if(0 == wd) return false;
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(false == restrict::window_manager.available(iwd))
return false;
r = iwd->pos_owner;
r = iwd->dimension;
return true;
}
bool track_window_size(window wd, const nana::size& sz, bool true_for_max)
{
if(0 == wd) return false;
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) == false) return false;
nana::size & ts = (true_for_max ? iwd->max_track_size : iwd->min_track_size);
if(sz.width && sz.height)
{
if(true_for_max)
{
if(iwd->min_track_size.width <= sz.width && iwd->min_track_size.height <= sz.height)
{
ts = restrict::interface_type::check_track_size(sz, iwd->extra_width, iwd->extra_height, true);
return true;
}
}
else
{
if((iwd->max_track_size.width == 0 && iwd->max_track_size.height == 0) || (iwd->max_track_size.width >= sz.width && iwd->max_track_size.height >= sz.height))
{
ts = restrict::interface_type::check_track_size(sz, iwd->extra_width, iwd->extra_height, false);
return true;
}
}
return false;
}
else
ts.width = ts.height = 0;
return true;
}
void window_enabled(window wd, bool enabled)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && (iwd->flags.enabled != enabled))
{
iwd->flags.enabled = enabled;
restrict::window_manager.update(iwd, true, false);
if(category::flags::root == iwd->other.category)
restrict::interface_type::enable_window(iwd->root, enabled);
}
}
}
bool window_enabled(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
return (restrict::window_manager.available(iwd) ? iwd->flags.enabled : false);
}
return false;
}
//lazy_refresh:
//@brief: A widget drawer draws the widget surface in answering an event. This function will tell the drawer to copy the graphics into window after event answering.
void lazy_refresh()
{
restrict::bedrock.thread_context_lazy_refresh();
}
//refresh_window
//@brief: Refresh the window and display it immediately.
void refresh_window(window wd)
{
restrict::window_manager.update(reinterpret_cast<restrict::core_window_t*>(wd), true, false);
}
void refresh_window_tree(window wd)
{
restrict::window_manager.refresh_tree(reinterpret_cast<restrict::core_window_t*>(wd));
}
//update_window
//@brief: it displays a window immediately without refreshing.
void update_window(window wnd)
{
restrict::window_manager.update(reinterpret_cast<restrict::core_window_t*>(wnd), false, true);
}
void window_caption(window wd, const nana::string& title)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
restrict::window_manager.signal_fire_caption(iwd, title.c_str());
}
}
nana::string window_caption(window wd)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return restrict::window_manager.signal_fire_caption(iwd);
}
return nana::string();
}
void window_cursor(window wd, cursor::t cur)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
iwd->predef_cursor = cur;
restrict::bedrock.update_cursor(iwd);
}
}
}
cursor::t window_cursor(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return iwd->predef_cursor;
}
return cursor::arrow;
}
bool tray_insert(native_window_type wd, const nana::char_t* tip, const nana::char_t* ico)
{
return restrict::interface_type::notify_icon_add(wd, tip, ico);
}
bool tray_delete(native_window_type wd)
{
return restrict::interface_type::notify_icon_delete(wd);
}
void tray_tip(native_window_type wd, const char_t* text)
{
restrict::interface_type::notify_tip(wd, text);
}
void tray_icon(native_window_type wd, const char_t* icon)
{
restrict::interface_type::notify_icon(wd, icon);
}
bool tray_make_event(native_window_type wd, unsigned identifier, const nana::functor<void(const eventinfo&)> & f)
{
return restrict::window_manager.tray_make_event(wd, identifier, f);
}
void tray_umake_event(native_window_type wd)
{
restrict::window_manager.tray_umake_event(wd);
}
bool is_focus_window(window wd)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return (iwd->root_widget->other.attribute.root->focus == iwd);
}
return false;
}
window focus_window()
{
internal_scope_guard isg;
return reinterpret_cast<window>(restrict::bedrock.focus());
}
void focus_window(window wd)
{
restrict::window_manager.set_focus(reinterpret_cast<restrict::core_window_t*>(wd));
restrict::window_manager.update(reinterpret_cast<restrict::core_window_t*>(wd), false, false);
}
window capture_window()
{
return reinterpret_cast<window>(restrict::window_manager.capture_window());
}
window capture_window(window wd, bool value)
{
return reinterpret_cast<window>(
restrict::window_manager.capture_window(reinterpret_cast<restrict::core_window_t*>(wd), value)
);
}
void capture_ignore_children(bool ignore)
{
restrict::window_manager.capture_ignore_children(ignore);
}
void modal_window(window wd)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
wd = 0;
if(restrict::window_manager.available(iwd))
{
if((iwd->other.category == category::flags::root) && (iwd->flags.modal == false))
{
iwd->flags.modal = true;
#if defined(NANA_X11)
restrict::interface_type::set_modal(iwd->root);
#endif
restrict::window_manager.show(iwd, true);
wd = reinterpret_cast<window>(iwd);
}
}
}
if(wd)
{
//modal has to guarantee that does not lock the wnd_mgr_lock_ before invokeing the pump_event,
//otherwise, the modal will prevent the other thread access the window.
restrict::bedrock.pump_event(wd);
}
}
nana::color_t foreground(window wd)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->color.foreground;
}
return 0;
}
color_t foreground(window wd, color_t col)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->color.foreground;
if(prev != col)
{
iwd->color.foreground = col;
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
}
return 0;
}
color_t background(window wd)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->color.background;
}
return 0;
}
color_t background(window wd, color_t col)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->color.background;
if(prev != col)
{
iwd->color.background = col;
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
}
return 0;
}
color_t active(window wd)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->color.active;
}
return 0;
}
color_t active(window wd, color_t col)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->color.active;
if(prev != col)
{
iwd->color.active = col;
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
}
return 0;
}
void create_caret(window wd, unsigned width, unsigned height)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && (0 == iwd->together.caret))
iwd->together.caret = new detail::caret_descriptor(iwd, width, height);
}
}
void destroy_caret(window wd)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
detail::caret_descriptor* p = iwd->together.caret;
iwd->together.caret = 0;
delete p;
}
}
}
void caret_pos(window wd, int x, int y)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
iwd->together.caret->position(x, y);
}
}
nana::point caret_pos(window wd)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
return iwd->together.caret->position();
}
return point();
}
void caret_effective_range(window wd, const nana::rectangle& rect)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
iwd->together.caret->effective_range(rect);
}
}
void caret_size(window wd, const nana::size& sz)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
iwd->together.caret->size(sz);
}
}
nana::size caret_size(window wd)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
return iwd->together.caret->size();
}
return nana::size();
}
void caret_visible(window wd, bool is_show)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
iwd->together.caret->visible(is_show);
}
}
bool caret_visible(window wd)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && iwd->together.caret)
return iwd->together.caret->visible();
}
return false;
}
void tabstop(window wnd)
{
restrict::window_manager.tabstop(reinterpret_cast<restrict::core_window_t*>(wnd));
}
//eat_tabstop
//@brief: set a eating tab window that it processes a pressing of tab itself
void eat_tabstop(window wd, bool eat)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
if(eat)
iwd->flags.tab |= detail::tab_type::eating;
else
iwd->flags.tab &= ~detail::tab_type::eating;
}
}
}
window move_tabstop(window wd, bool next)
{
restrict::core_window_t* ts_wd;
if(next)
ts_wd = restrict::window_manager.tabstop_next(reinterpret_cast<restrict::core_window_t*>(wd));
else
ts_wd = restrict::window_manager.tabstop_prev(reinterpret_cast<restrict::core_window_t*>(wd));
restrict::window_manager.set_focus(ts_wd);
restrict::window_manager.update(ts_wd, false, false);
return reinterpret_cast<window>(ts_wd);
}
//glass_window
//@brief: Test a window whether it is a glass attribute.
bool glass_window(window wd)
{
return (bground_mode::basic == effects_bground_mode(wd));
}
bool glass_window(window wd, bool isglass)
{
if(isglass)
effects_bground(wd, effects::bground_transparent(0), 0);
else
effects_bground_remove(wd);
return true;
}
void take_active(window wd, bool active, window take_if_active_false)
{
if(wd)
{
restrict::core_window_t * const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
restrict::core_window_t * take_if_false = reinterpret_cast<restrict::core_window_t*>(take_if_active_false);
internal_scope_guard isg;
if(active || (take_if_false && (restrict::window_manager.available(take_if_false) == false)))
take_if_false = 0;
if(restrict::window_manager.available(iwd) == false) return;
iwd->flags.take_active = active;
iwd->other.active_window = take_if_false;
}
}
bool window_graphics(window wd, nana::paint::graphics& graph)
{
return restrict::window_manager.get_graphics(reinterpret_cast<restrict::core_window_t*>(wd), graph);
}
bool root_graphics(window wd, nana::paint::graphics& graph)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
graph = *(iwd->root_graph);
return true;
}
}
return false;
}
bool get_visual_rectangle(window wd, nana::rectangle& r)
{
return restrict::window_manager.get_visual_rectangle(reinterpret_cast<restrict::core_window_t*>(wd), r);
}
void typeface(window wd, const nana::paint::font& font)
{
if(wd)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
iwd->drawer.graphics.typeface(font);
restrict::window_manager.update(iwd, true, false);
}
}
}
nana::paint::font typeface(window wd)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
return iwd->drawer.graphics.typeface();
}
return nana::paint::font();
}
bool calc_screen_point(window wd, nana::point& pos)
{
if(wd)
{
restrict::core_window_t* iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd))
{
pos.x += iwd->pos_root.x;
pos.y += iwd->pos_root.y;
return restrict::interface_type::calc_screen_point(iwd->root, pos);
}
}
return false;
}
bool calc_window_point(window wd, nana::point& pos)
{
return restrict::window_manager.calc_window_point(reinterpret_cast<restrict::core_window_t*>(wd), pos);
}
window find_window(const nana::point& pos)
{
native_window_type wd = restrict::interface_type::find_window(pos.x, pos.y);
if(wd)
{
nana::point clipos(pos.x, pos.y);
restrict::interface_type::calc_window_point(wd, clipos);
return reinterpret_cast<window>(
restrict::window_manager.find_window(wd, clipos.x, clipos.y));
}
return 0;
}
void register_menu_window(window wd, bool has_keyboard)
{
if(wd)
{
internal_scope_guard isg;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
restrict::bedrock.set_menu(reinterpret_cast<restrict::core_window_t*>(wd)->root, has_keyboard);
}
}
bool attach_menubar(window menubar)
{
if(menubar)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(menubar);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) && (0 == iwd->root_widget->other.attribute.root->menubar))
{
iwd->root_widget->other.attribute.root->menubar = iwd;
return true;
}
}
return false;
}
void detach_menubar(window menubar)
{
if(menubar)
{
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(menubar);
internal_scope_guard isg;
if(restrict::window_manager.available(iwd) == false) return;
if(iwd->root_widget->other.attribute.root->menubar == iwd)
iwd->root_widget->other.attribute.root->menubar = 0;
}
}
void restore_menubar_taken_window()
{
restrict::core_window_t * wd = restrict::bedrock.get_menubar_taken();
if(wd)
{
internal_scope_guard isg;
restrict::window_manager.set_focus(wd);
restrict::window_manager.update(wd, true, false);
}
}
bool is_window_zoomed(window wd, bool ask_for_max)
{
internal_scope_guard isg;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
if(restrict::window_manager.available(iwd))
return detail::bedrock::interface_type::is_window_zoomed(iwd->root, ask_for_max);
return false;
}
gui::mouse_action::t mouse_action(window wd)
{
internal_scope_guard isg;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
if(restrict::window_manager.available(iwd))
return iwd->flags.action;
return nana::gui::mouse_action::normal;
}
nana::gui::element_state::t element_state(window wd)
{
internal_scope_guard isg;
restrict::core_window_t * iwd = reinterpret_cast<restrict::core_window_t*>(wd);
if(restrict::window_manager.available(iwd))
{
const bool is_focused = (iwd->root_widget->other.attribute.root->focus == iwd);
switch(iwd->flags.action)
{
case gui::mouse_action::normal:
return (is_focused ? gui::element_state::focus_normal : gui::element_state::normal);
case gui::mouse_action::over:
return (is_focused ? gui::element_state::focus_hovered : gui::element_state::hovered);
case gui::mouse_action::pressed:
return gui::element_state::pressed;
default:
if(false == iwd->flags.enabled)
return gui::element_state::disabled;
}
}
return gui::element_state::normal;
}
}//end namespace API
}//end namespace gui
}//end namespace nana
| 27.229947
| 165
| 0.70441
|
gfannes
|
d9e6fa82ad49f15ac3fddfc821eb45cf42bf2d37
| 132
|
cc
|
C++
|
udemy/modern_cpp/06-more-bazel-concepts/e01/src/Main.cc
|
e-dnx/courses
|
d21742a51447496f541dc8ec32b0df79d709dbff
|
[
"MIT"
] | null | null | null |
udemy/modern_cpp/06-more-bazel-concepts/e01/src/Main.cc
|
e-dnx/courses
|
d21742a51447496f541dc8ec32b0df79d709dbff
|
[
"MIT"
] | null | null | null |
udemy/modern_cpp/06-more-bazel-concepts/e01/src/Main.cc
|
e-dnx/courses
|
d21742a51447496f541dc8ec32b0df79d709dbff
|
[
"MIT"
] | null | null | null |
#include "e01/Greeter.h"
#include <iostream>
int
main()
{
Greeter greeter;
greeter.sayHello();
return EXIT_SUCCESS;
}
| 11
| 24
| 0.659091
|
e-dnx
|
d9e803ff49925b27ef8ec609f69a9a2a79ba81e5
| 3,056
|
cpp
|
C++
|
core123/ut/ut_datetimeutils.cpp
|
fennm/fs123
|
559b97659352620ce16030824f9acd26f590f4e1
|
[
"BSD-3-Clause"
] | 22
|
2019-04-10T18:05:35.000Z
|
2021-12-30T12:26:39.000Z
|
core123/ut/ut_datetimeutils.cpp
|
fennm/fs123
|
559b97659352620ce16030824f9acd26f590f4e1
|
[
"BSD-3-Clause"
] | 13
|
2019-04-09T00:19:29.000Z
|
2021-11-04T15:57:13.000Z
|
core123/ut/ut_datetimeutils.cpp
|
fennm/fs123
|
559b97659352620ce16030824f9acd26f590f4e1
|
[
"BSD-3-Clause"
] | 4
|
2019-04-07T16:33:44.000Z
|
2020-07-02T02:58:51.000Z
|
#include "core123/sew.hpp"
#include "core123/datetimeutils.hpp"
#include "core123/strutils.hpp"
#include <iostream>
#include <vector>
#include <utility>
using core123::str;
using core123::timet_to_httpdate;
using core123::httpdate_to_timet;
namespace sew = core123::sew;
int
main(int, char **)
{
struct timespec now1, now2, now3;
sew::clock_gettime(CLOCK_REALTIME, &now1);
auto s1 = str(now1);
now2 = now1;
auto s2 = str(now2);
if (now1 == now2) {
if (s1 != s2)
throw std::runtime_error("timespec string mismatch \""+s1+"\" != \""+s2+"\"");
sew::clock_gettime(CLOCK_REALTIME, &now3);
auto s3 = str(now3);
if (now1 != now3) {
if (now1 < now3) {
std::cout << "OK, timespec \"" << s1 << "\" < \"" << s3 << "\"\n";
} else {
throw std::runtime_error("timespec failed lt \"" + s1 + "\" \"" + s3 + "\"\n");
}
} else {
throw std::runtime_error("timespec failed ne \"" + s1 + "\" \"" + s3 + "\"\n");
}
} else {
throw std::runtime_error("timespec fail eq \""+s1+"\" \""+s2+"\"");
}
// Enhancement request: this should work
// str("the time is now: ", std::chrono::system_clock::now());
// but it doesn't. We have to str-ify the time_point.
str("the time is now: ", str(std::chrono::system_clock::now()));
// The fix is *possibly* a partial specialization of
// 'core123::detail::insertone' for time_point (and duration), but
// it seems to require a bit of re-engineering of insertone.
// date -u '%s %c' => 1524747193 Thu 26 Apr 2018 12:53:13 PM UTC
const std::vector<std::pair<time_t,std::string> > tests{
{1524747193, "Thu, 26 Apr 2018 12:53:13 GMT"},
{0, "Thu, 01 Jan 1970 00:00:00 GMT"},
{1, "Thu, 01 Jan 1970 00:00:01 GMT"},
{86400, "Fri, 02 Jan 1970 00:00:00 GMT"},
{INT32_MAX, "Tue, 19 Jan 2038 03:14:07 GMT"},
};
for (const auto &t : tests) {
auto s = timet_to_httpdate(t.first);
if (s != t.second) {
std::cerr << "ERROR: timet_to_httpdate mismatch, got " << s << " for " << t.first << '\n';
std::cerr << " expected " << t.second << std::endl;
return 1;
}
auto tt = httpdate_to_timet(t.second.c_str());
if(tt != t.first) {
std::cerr << "ERROR: httpdate_to_timet mismatch, got " << s << " for " << t.first << '\n';
std::cerr << " expected " << t.second << std::endl;
return 1;
}
}
bool caught = false;
try{
httpdate_to_timet("19 Jan 2038 03:14:07");
}catch(std::system_error& se){
caught = true;
std::cout << "OK, intentionally bad call to httpdate_timet threw: what:" << se.what() << "\n";
}
if(!caught){
std::cerr << "ERROR: expected httpdate_to_timet to throw";
return 1;
}
std::cout << "OK, " << tests.size() << " tests passed" << std::endl;
return 0;
}
| 36.380952
| 102
| 0.531741
|
fennm
|
d9ef562f5553a943567d02dd8e10f99dcfaef609
| 209
|
cpp
|
C++
|
src/netlist/gate_library/enums/pin_direction.cpp
|
emsec/HAL
|
608e801896e1b5254b28ce0f29d4d898b81b0f77
|
[
"MIT"
] | 407
|
2019-04-26T10:45:52.000Z
|
2022-03-31T15:52:30.000Z
|
src/netlist/gate_library/enums/pin_direction.cpp
|
emsec/HAL
|
608e801896e1b5254b28ce0f29d4d898b81b0f77
|
[
"MIT"
] | 219
|
2019-04-29T16:42:01.000Z
|
2022-03-11T22:57:41.000Z
|
src/netlist/gate_library/enums/pin_direction.cpp
|
emsec/HAL
|
608e801896e1b5254b28ce0f29d4d898b81b0f77
|
[
"MIT"
] | 53
|
2019-05-02T21:23:35.000Z
|
2022-03-11T19:46:05.000Z
|
#include "hal_core/netlist/gate_library/enums/pin_direction.h"
namespace hal
{
template<>
std::vector<std::string> EnumStrings<PinDirection>::data = {"none", "input", "output", "inout", "internal"};
}
| 29.857143
| 112
| 0.698565
|
emsec
|
d9f1d5d53ef635cbc1830031389a67d30b6146e9
| 1,167
|
cxx
|
C++
|
painty/core/test/src/ThreadPoolTest.cxx
|
lindemeier/painty
|
792cac6655b3707805ffc68d902f0e675a7770b8
|
[
"MIT"
] | 15
|
2020-04-22T15:18:28.000Z
|
2022-03-24T07:48:28.000Z
|
painty/core/test/src/ThreadPoolTest.cxx
|
lindemeier/painty
|
792cac6655b3707805ffc68d902f0e675a7770b8
|
[
"MIT"
] | 25
|
2020-04-18T18:55:50.000Z
|
2021-05-30T21:26:39.000Z
|
painty/core/test/src/ThreadPoolTest.cxx
|
lindemeier/painty
|
792cac6655b3707805ffc68d902f0e675a7770b8
|
[
"MIT"
] | 2
|
2020-09-16T05:55:54.000Z
|
2021-01-09T12:09:43.000Z
|
/**
* @file ThreadPoolTest.cxx
* @author thomas lindemeier
*
* @brief
*
* @date 2020-10-20
*
*/
#include "gtest/gtest.h"
#include "painty/core/ThreadPool.hxx"
TEST(ThreadPoolTest, Construct) {
{
painty::ThreadPool singleThread(1U);
std::cout << "Hello World from main thread: " << std::this_thread::get_id()
<< std::endl;
std::vector<std::future<void>> futures;
for (auto i = 0U; i < 10U; i++) {
futures.push_back(singleThread.add_back([]() {
std::cout << "Hello World from thread: " << std::this_thread::get_id()
<< std::endl;
}));
}
for (const auto& f : futures) {
f.wait();
}
}
{
painty::ThreadPool multiThread(10U);
std::cout << "Hello World from main thread: " << std::this_thread::get_id()
<< std::endl;
std::vector<std::future<void>> futures;
for (auto i = 0U; i < 10U; i++) {
futures.push_back(multiThread.add_back([]() {
std::cout << "Hello World from thread: " << std::this_thread::get_id()
<< std::endl;
}));
}
for (const auto& f : futures) {
f.wait();
}
}
}
| 22.018868
| 79
| 0.538132
|
lindemeier
|
d9f52f06a2cef864a54e8a7fe3d34112f354a7ae
| 318
|
cpp
|
C++
|
Ass3/Q4.cpp
|
nitishgarg2002/DSA-assignments
|
34ec3e77e6bb00bc2ab86d2960a18d9e53300c06
|
[
"MIT"
] | null | null | null |
Ass3/Q4.cpp
|
nitishgarg2002/DSA-assignments
|
34ec3e77e6bb00bc2ab86d2960a18d9e53300c06
|
[
"MIT"
] | null | null | null |
Ass3/Q4.cpp
|
nitishgarg2002/DSA-assignments
|
34ec3e77e6bb00bc2ab86d2960a18d9e53300c06
|
[
"MIT"
] | null | null | null |
#include<iostream>
using namespace std;
int factorial(int n){
if (n == 0)
return 1;
return n * factorial(n - 1);
}
int nCr(int n,int r){
return factorial(n) / (factorial(r) * factorial(n - r));
}
int main() {
int n,r;
cin>>n>>r;
if(n>=r){
cout<<nCr(n,r);
}
else {
cout<<"Invalid values";
}
}
| 14.454545
| 57
| 0.562893
|
nitishgarg2002
|
d9f5dac229134746071f859ba31ca5650c3c6390
| 2,558
|
cpp
|
C++
|
firmware/robot2015/hw-test/i2c-test.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | 1
|
2018-09-25T20:28:58.000Z
|
2018-09-25T20:28:58.000Z
|
firmware/robot2015/hw-test/i2c-test.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | null | null | null |
firmware/robot2015/hw-test/i2c-test.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | null | null | null |
#include <mbed.h>
#include <rtos.h>
#include <vector>
#include <algorithm>
#include <helper-funcs.hpp>
#include "robot-devices.hpp"
DigitalOut good(LED1, 0);
DigitalOut bad1(LED2, 0);
DigitalOut bad2(LED3, 0);
DigitalOut pwr(LED4, 1);
Serial pc(RJ_SERIAL_RXTX);
I2C i2c(RJ_I2C_BUS);
bool testPass = false;
bool batchedResult = false;
std::vector<unsigned int> freq1;
std::vector<unsigned int> freq2;
int main() {
char buf[2] = {0x00};
pc.baud(57600);
pc.printf("START========= STARTING TEST =========\r\n\r\n");
pwr = 0;
RtosTimer live_light(imAlive, osTimerPeriodic, (void*)&pwr);
live_light.start(250);
pc.printf("-- Testing address space using 100kHz\r\n");
// Test on low bus frequency
i2c.frequency(100000);
for (unsigned int i = 0; i < 0xFF; i++) {
bool ack, nack = false;
ack = i2c.write(i);
nack = i2c.read(i, buf, 2);
if (ack && !nack) {
freq1.push_back(i);
}
}
pc.printf("-- Testing address space using 400kHz\r\n");
// Test on high bus frequency
i2c.frequency(400000);
for (unsigned int i = 0; i < 0xFF; i++) {
bool ack, nack = false;
ack = i2c.write(i);
nack = i2c.read(i, buf, 2);
if (ack && !nack) {
freq2.push_back(i);
}
}
// Test results
pc.printf("\r\n100kHz Test:\t%s\r\n", freq1.empty() ? "FAIL" : "PASS");
pc.printf("400kHz Test:\t%s\r\n", freq2.empty() ? "FAIL" : "PASS");
// Merge the 2 vectors together & remove duplicate values
freq1.insert(freq1.end(), freq2.begin(), freq2.end());
sort(freq1.begin(), freq1.end());
freq1.erase(unique(freq1.begin(), freq1.end()), freq1.end());
pc.printf("ADDRS PASS:\t%u\r\nADDRS FAIL:\t%u\r\n", freq1.size(),
0xFF - freq1.size());
if (freq1.size() > 0xF0) {
batchedResult = true;
}
for (std::vector<unsigned int>::iterator it = freq1.begin();
it != freq1.end(); ++it)
pc.printf(" 0x%02X\r\n", *it);
// Final results of the test
testPass = (!freq1.empty()) && (!batchedResult);
pc.printf("\r\n=================================\r\n");
pc.printf("========== TEST %s ==========\r\n",
testPass ? "PASSED" : "FAILED");
pc.printf("=================================DONE");
// Turn on the corresponding LED(s)
good = testPass;
bad1 = !testPass;
bad2 = !testPass;
live_light.stop();
pwr = testPass;
while (true) {
// Never return
wait(2.0);
}
}
| 24.834951
| 75
| 0.543002
|
JNeiger
|
d9f8e71da0995d3e41d80a2ba36c51c5d7e6c6f1
| 831
|
cpp
|
C++
|
BaekJoon/14569.cpp
|
falconlee236/Algorithm_Practice
|
4e6e380a0e6c840525ca831a05c35253eeaaa25c
|
[
"MIT"
] | null | null | null |
BaekJoon/14569.cpp
|
falconlee236/Algorithm_Practice
|
4e6e380a0e6c840525ca831a05c35253eeaaa25c
|
[
"MIT"
] | null | null | null |
BaekJoon/14569.cpp
|
falconlee236/Algorithm_Practice
|
4e6e380a0e6c840525ca831a05c35253eeaaa25c
|
[
"MIT"
] | null | null | null |
/*14569*/
/*Got it!*/
/*39:42*/
#include <iostream>
using namespace std;
typedef unsigned long long ull;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
ull sub[1001] = {0, };
ull student[10001] = {0, };
int n; cin >> n;
for(int i = 0; i < n; i++){
int num; cin >> num;
for(int j = 0; j < num; j++){
int p; cin >> p;
sub[i] |= ((ull)1 << p);
}
}
int m; cin >> m;
for(int i = 0; i < m; i++){
int num; cin >> num;
for(int j = 0; j < num; j++){
int p; cin >> p;
student[i] |= ((ull)1 << p);
}
}
for(int i = 0; i < m; i++){
int ans = 0;
for(int j = 0; j < n; j++){
if(sub[j] == (student[i] & sub[j])) ans++;
}
cout << ans << "\n";
}
}
| 22.459459
| 54
| 0.391095
|
falconlee236
|
d9f9d9d60882dde41977388426afaf1aadf52383
| 1,285
|
cpp
|
C++
|
PRACTICE/KPRIME.cpp
|
prasantmahato/CP-Practice
|
54ca79117fcb0e2722bfbd1007b972a3874bef03
|
[
"MIT"
] | null | null | null |
PRACTICE/KPRIME.cpp
|
prasantmahato/CP-Practice
|
54ca79117fcb0e2722bfbd1007b972a3874bef03
|
[
"MIT"
] | null | null | null |
PRACTICE/KPRIME.cpp
|
prasantmahato/CP-Practice
|
54ca79117fcb0e2722bfbd1007b972a3874bef03
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
/*
OBJECTIVE:-
The game is called Count K-Primes. A number is a k-prime if it has exactly k distinct prime factors.
The game is quite simple. Alice will give three numbers A, B & K to Bob.
Bob needs to tell Alice the number of K-prime numbers between A & B (both inclusive).
If Bob gives the correct answer, he gets a point. If not, Alice gets a point.
They play this game T times.
INPUT:-
First line of input contains a single integer T, the number of times they play.
Each game is described in a single line containing the three numbers A,B & K.
OUTPUT:-
For each game, output on a separate line the number of K-primes between A & B.
Constraints:
1 ≤ T ≤ 10000
2 ≤ A ≤ B ≤ 100000
1 ≤ K ≤ 5
*/
int main()
{
int rounds=1;
cin>> rounds;
while(rounds--)
{
int a,b,kp;
a=b=kp=0;
cin>>a>>b>>kp;
int p_factors[b+1] = { 0 };
int count=0;
for (int p = 2; p <= b; p++)
if (p_factors[p] == 0)
for (int i = p; i <= b; i += p)
p_factors[i]++;
for (int i = a; i <= b; i++)
if (p_factors[i] == kp)
count++;
cout<<count<<endl;
}
return 0;
}
| 23.796296
| 101
| 0.557198
|
prasantmahato
|
d9fa353463b6068760b36ddb7ff99c0df133ebca
| 1,956
|
cpp
|
C++
|
src/apps/orbiter/orbiter.cpp
|
abetten/orbiter
|
5994d0868a26c37676d6aadfc66a1f1bcb715c4b
|
[
"RSA-MD"
] | 15
|
2016-10-27T15:18:28.000Z
|
2022-02-09T11:13:07.000Z
|
src/apps/orbiter/orbiter.cpp
|
abetten/orbiter
|
5994d0868a26c37676d6aadfc66a1f1bcb715c4b
|
[
"RSA-MD"
] | 4
|
2019-12-09T11:49:11.000Z
|
2020-07-30T17:34:45.000Z
|
src/apps/orbiter/orbiter.cpp
|
abetten/orbiter
|
5994d0868a26c37676d6aadfc66a1f1bcb715c4b
|
[
"RSA-MD"
] | 15
|
2016-06-10T20:05:30.000Z
|
2020-12-18T04:59:19.000Z
|
// orbiter.cpp
//
// by Anton Betten
//
// started: 4/3/2020
//
#include "orbiter.h"
using namespace std;
using namespace orbiter;
using namespace orbiter::top_level;
int build_number =
#include "../../../build_number"
;
int main(int argc, const char **argv)
{
//cout << "orbiter.out main" << endl;
orbiter_top_level_session Top_level_session;
int i;
The_Orbiter_top_level_session = &Top_level_session;
// setup:
cout << "Welcome to Orbiter! Your build number is " << build_number << "." << endl;
cout << "A user's guide is available here: " << endl;
cout << "https://www.math.colostate.edu/~betten/orbiter/users_guide.pdf" << endl;
cout << "The sources are available here: " << endl;
cout << "https://github.com/abetten/orbiter" << endl;
cout << "An example makefile with many commands from the user's guide is here: " << endl;
cout << "https://github.com/abetten/orbiter/tree/master/examples/users_guide/makefile" << endl;
#ifdef SYSTEMUNIX
cout << "SYSTEMUNIX is defined" << endl;
#endif
#ifdef SYSTEMWINDOWS
cout << "SYSTEMWINDOWS is defined" << endl;
#endif
#ifdef SYSTEM_IS_MACINTOSH
cout << "SYSTEM_IS_MACINTOSH is defined" << endl;
#endif
cout << "sizeof(int)=" << sizeof(int) << endl;
cout << "sizeof(long int)=" << sizeof(long int) << endl;
std::string *Argv;
string_tools ST;
ST.convert_arguments(argc, argv, Argv);
// argc has changed!
i = Top_level_session.startup_and_read_arguments(argc, Argv, 1);
int verbose_level;
verbose_level = Top_level_session.Orbiter_session->verbose_level;
//int f_v = (verbose_level > 1);
if (FALSE) {
cout << "main, before Top_level_session.handle_everything" << endl;
}
Top_level_session.handle_everything(argc, Argv, i, verbose_level);
if (FALSE) {
cout << "main, after Top_level_session.handle_everything" << endl;
}
cout << "Orbiter session is finished." << endl;
cout << "User time: ";
the_end(Top_level_session.Orbiter_session->t0);
}
| 21.494505
| 96
| 0.692229
|
abetten
|
d9faa845153642cf03657a1c95a0f4b2ae74fe51
| 516
|
cpp
|
C++
|
src/drawablecomponentmanager.cpp
|
sch-gamedev/hentes
|
7381ebc25d0db4ad528deb876afe81059d7e2118
|
[
"Zlib"
] | 1
|
2018-08-01T12:16:45.000Z
|
2018-08-01T12:16:45.000Z
|
src/drawablecomponentmanager.cpp
|
sch-gamedev/hentes
|
7381ebc25d0db4ad528deb876afe81059d7e2118
|
[
"Zlib"
] | null | null | null |
src/drawablecomponentmanager.cpp
|
sch-gamedev/hentes
|
7381ebc25d0db4ad528deb876afe81059d7e2118
|
[
"Zlib"
] | null | null | null |
/* Copyright (C) 2012 KSZK GameDev
* For conditions of distribution and use, see copyright notice in main.cpp
*/
#include "drawablecomponentmanager.h"
void DrawableComponentManager::Update()
{
RemoveMarkedComponents();
for( std::list<DrawableComponent*>::iterator i = Components.begin(); i != Components.end(); i++ )
{
(*i)->Update();
}
}
void DrawableComponentManager::Draw()
{
for( std::list<DrawableComponent*>::iterator i = Components.begin(); i != Components.end(); i++ )
{
(*i)->Draw();
}
}
| 22.434783
| 98
| 0.676357
|
sch-gamedev
|
8a0293953680b037cfdd3de5074709eab487e381
| 294
|
cpp
|
C++
|
QuickPushQuizWin/MouseController.cpp
|
AinoMegumi/QuickPushQuiz
|
7fc858d898001b2ac31e9c1e4778c4dc548430d9
|
[
"MIT"
] | null | null | null |
QuickPushQuizWin/MouseController.cpp
|
AinoMegumi/QuickPushQuiz
|
7fc858d898001b2ac31e9c1e4778c4dc548430d9
|
[
"MIT"
] | null | null | null |
QuickPushQuizWin/MouseController.cpp
|
AinoMegumi/QuickPushQuiz
|
7fc858d898001b2ac31e9c1e4778c4dc548430d9
|
[
"MIT"
] | null | null | null |
#include "MouseController.hpp"
#include "DxLib.h"
void MouseController::UpdateCurrentPos() {
GetMousePoint(&this->Current.x, &this->Current.y);
}
bool MouseController::Clicked() {
return Core::LeftHandMouse
? GetMouseInput() & MOUSE_INPUT_RIGHT
: GetMouseInput() & MOUSE_INPUT_LEFT;
}
| 22.615385
| 51
| 0.741497
|
AinoMegumi
|
8a052f0375fdd07c275f90c44e76293d0eedc7dd
| 1,281
|
cpp
|
C++
|
src/clipMaker/src/main.cpp
|
kothiga/Embodied-Social-Interface
|
4545e07b3d575f48dea5b42cde93ef81484e9567
|
[
"MIT"
] | null | null | null |
src/clipMaker/src/main.cpp
|
kothiga/Embodied-Social-Interface
|
4545e07b3d575f48dea5b42cde93ef81484e9567
|
[
"MIT"
] | null | null | null |
src/clipMaker/src/main.cpp
|
kothiga/Embodied-Social-Interface
|
4545e07b3d575f48dea5b42cde93ef81484e9567
|
[
"MIT"
] | null | null | null |
/* ================================================================================
* Copyright: (C) 2022, SIRRL Social and Intelligent Robotics Research Laboratory,
* University of Waterloo, All rights reserved.
*
* Authors:
* Austin Kothig <austin.kothig@uwaterloo.ca>
*
* CopyPolicy: Released under the terms of the MIT License.
* See the accompanying LICENSE file for details.
* ================================================================================
*/
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <yarp/os/Network.h>
#include <yarp/os/LogStream.h>
#include <clipMaker.hpp>
int main (int argc, char **argv) {
//-- Init the yarp network.
yarp::os::Network yarp;
if (!yarp.checkNetwork()) {
yError() << "Cannot make connection with the YARP server!!";
return EXIT_FAILURE;
}
//-- Config the resource finder.
yarp::os::ResourceFinder rf;
rf.setVerbose(false);
rf.setDefaultConfigFile("config.ini"); // overridden by --from parameter
rf.setDefaultContext("clip_maker"); // overridden by --context parameter
rf.configure(argc,argv);
//-- Run the interface and return its status.
ClipMaker clip_maker;
return clip_maker.runModule(rf);
}
| 29.113636
| 83
| 0.587041
|
kothiga
|
8a084ae985f5aecf82771e2f66800875a29f1b6c
| 2,251
|
cpp
|
C++
|
ProblemSum/Problem_Time.cpp
|
kravitz/transims4
|
ea0848bf3dc71440d54724bb3ecba3947b982215
|
[
"NASA-1.3"
] | 2
|
2018-04-27T11:07:02.000Z
|
2020-04-24T06:53:21.000Z
|
ProblemSum/Problem_Time.cpp
|
idkravitz/transims4
|
ea0848bf3dc71440d54724bb3ecba3947b982215
|
[
"NASA-1.3"
] | null | null | null |
ProblemSum/Problem_Time.cpp
|
idkravitz/transims4
|
ea0848bf3dc71440d54724bb3ecba3947b982215
|
[
"NASA-1.3"
] | null | null | null |
//*********************************************************
// Problem_Time.cpp - write the problem time file
//*********************************************************
#include "ProblemSum.hpp"
//---------------------------------------------------------
// Problem_Time
//---------------------------------------------------------
void ProblemSum::Problem_Time (void)
{
int i, j, time, type, num, total, num_inc, *num_time, nout;
int type_field, time_field, start_field;
char buffer [FIELD_BUFFER];
Range_Data *range_ptr;
//---- summarize the problem times ----
type_field = problem_db.Required_Field ("PROBLEM", "STATUS");
time_field = problem_db.Optional_Field ("TIME", "TOD");
start_field = problem_db.Optional_Field ("START", "START_TIME");
Show_Message ("Writing %s -- Record", time_file.File_Type ());
Set_Progress (10000);
nout = 0;
num_inc = times.Num_Ranges ();
num_time = new int [num_inc];
i = ((num_types > 1) ? 0 : 1);
for (; i < MAX_PROBLEM; i++) {
if (num_problems [i] == 0) continue;
num = 0;
memset (num_time, '\0', num_inc * sizeof (int));
problem_db.Rewind ();
while (problem_db.Read_Record ()) {
if (i > 0) {
problem_db.Get_Field (type_field, &type);
if (i != type) continue;
}
if (time_field > 0) {
problem_db.Get_Field (time_field, buffer);
time = times.Step (buffer);
} else {
time = 0;
}
if (time == 0) {
problem_db.Get_Field (start_field, buffer);
time = times.Step (buffer);
}
time = times.In_Increment (time) - 1;
if (num_time [time] == 0) num++;
num_time [time]++;
}
if (num == 0) continue;
total = num_problems [i];
for (j=0; j < num_inc; j++) {
Show_Progress ();
range_ptr = times [j+1];
time_file.Put_Field (1, i);
time_file.Put_Field (2, times.Format_Step (range_ptr->Low ()));
time_file.Put_Field (3, times.Format_Step (range_ptr->High () + 1));
time_file.Put_Field (4, num_time [j]);
time_file.Put_Field (5, ((100.0 * num_time [j]) / total));
if (!time_file.Write ()) {
Error ("Writing %s", time_file.File_Type ());
}
nout++;
}
}
End_Progress ();
time_file.Close ();
delete [] num_time;
Print (2, "Number of %s Records = %d", time_file.File_Type (), nout);
}
| 24.204301
| 71
| 0.557086
|
kravitz
|
8a092f62819ba59c2f2fb5cbedc7dff5b916f172
| 6,573
|
hpp
|
C++
|
src/impl/meta_utils.hpp
|
thequickf/graph
|
fff8f514b3cb3e48f4b6dfd1dd4679bcf102e7de
|
[
"MIT"
] | 3
|
2021-01-26T08:42:17.000Z
|
2021-02-15T11:55:05.000Z
|
src/impl/meta_utils.hpp
|
thequickf/graph
|
fff8f514b3cb3e48f4b6dfd1dd4679bcf102e7de
|
[
"MIT"
] | 5
|
2021-01-23T20:44:39.000Z
|
2021-02-18T08:09:12.000Z
|
src/impl/meta_utils.hpp
|
thequickf/graph
|
fff8f514b3cb3e48f4b6dfd1dd4679bcf102e7de
|
[
"MIT"
] | null | null | null |
#ifndef IMPL_META_UTILS_HPP
#define IMPL_META_UTILS_HPP
#include <graph_traits.hpp>
#include <impl/graph_traits.hpp>
#include <concepts>
#include <type_traits>
namespace graph_meta {
template<typename...>
struct list;
template<typename Node>
using abstract_trait_replacements = list<
list<graph::Net, graph_impl::Net<Node> >
>;
template<typename, typename> struct list_concat_impl;
template<typename... LHTs, typename... RHTs>
struct list_concat_impl<list<LHTs...>, list<RHTs...>> {
using type = list<LHTs..., RHTs...>;
};
template<template<typename> class, typename...>
struct filter_impl;
template<template<typename> class Condition>
struct filter_impl<Condition> {
using type = list<>;
};
template<template<typename> class Condition, typename Head, typename... Tail>
struct filter_impl<Condition, Head, Tail...> {
using type = typename list_concat_impl<
std::conditional_t<
Condition<Head>::value,
list<Head>,
list<>
>,
typename filter_impl<Condition, Tail...>::type
>::type;
};
template<template<typename> class Condition, typename... Ts>
using filter_t = typename filter_impl<Condition, Ts...>::type;
template<template<typename> class, typename>
struct filter_list_impl;
template<template<typename> class Condition, typename... Ts>
struct filter_list_impl<Condition, list<Ts...> > {
using type = filter_t<Condition, Ts...>;
};
template<template<typename> class Condition, typename List>
using filter_list_t = filter_list_impl<Condition, List>::type;
template<typename, typename, typename...>
struct replace_impl;
template<typename SourceT, typename TargetT>
struct replace_impl<SourceT, TargetT> {
using type = list<>;
};
template<typename SourceT, typename TargetT, typename Head, typename... Tail>
struct replace_impl<SourceT, TargetT, Head, Tail...> {
using type = typename list_concat_impl<
std::conditional_t<
std::is_same_v<Head, SourceT>,
list<TargetT>,
list<Head>
>,
typename replace_impl<SourceT, TargetT, Tail...>::type
>::type;
};
template<typename, typename, typename>
struct replace;
template<typename SourceT, typename TargetT, typename... Ts>
struct replace<SourceT, TargetT, list<Ts...> > {
using type = replace_impl<SourceT, TargetT, Ts...>::type;
};
template<typename SourceT, typename TargetT, typename List>
using replace_t = replace<SourceT, TargetT, List>::type;
template<typename, typename...>
struct replace_all_impl;
template<typename TraitList>
struct replace_all_impl<TraitList> {
using type = TraitList;
};
template<
typename TraitList, typename SourceT, typename TargetT, typename... Tail>
struct replace_all_impl<TraitList, list<SourceT, TargetT>, Tail...> {
using type =
replace_all_impl<replace_t<SourceT, TargetT, TraitList>, Tail...>::type;
};
template<typename, typename>
struct replace_all;
template<typename TraitList, typename... Replacements>
struct replace_all<TraitList, list<Replacements...> > {
using type = replace_all_impl<TraitList, Replacements...>::type;
};
template<typename TraitList, typename... Replacements>
using replace_all_t = replace_all<TraitList, Replacements...>::type;
template<typename, typename, typename...>
struct contains_type_impl;
template<typename Result, typename T>
struct contains_type_impl<Result, T> {
using value = Result;
};
template<typename Result, typename T, typename Head, typename... Tail>
struct contains_type_impl<Result, T, Head, Tail...> {
using value = contains_type_impl<
std::disjunction<Result, std::is_same<T, Head> >, T, Tail...>::value;
};
template<typename Node, typename TraitList>
using replace_abstract_traits =
replace_all<TraitList, abstract_trait_replacements<Node> >;
template<typename Node, typename TraitList>
using replace_abstract_traits_t =
replace_all_t<TraitList, abstract_trait_replacements<Node> >;
template<class Derived>
using graph_trait_condition = std::is_base_of<graph::GraphTrait, Derived>;
template<class Derived>
using edge_trait_condition = std::is_base_of<graph::EdgeTrait, Derived>;
template<class Derived>
using constructible_trait_condition =
std::negation<std::is_base_of<graph::NoConstructorTrait, Derived> >;
template<typename T, typename... Ts>
using contains_type = contains_type_impl<std::false_type, T, Ts...>::value;
template <typename T, typename... Ts>
inline constexpr bool contains_type_v = contains_type<T, Ts...>::value;
template<typename Node, typename... Traits>
using build_graph_traits =
replace_abstract_traits_t<
Node, filter_t<graph_trait_condition, Traits...> >;
template<typename Node, typename... Traits>
using build_edge_traits =
replace_abstract_traits_t<
Node, filter_t<edge_trait_condition, Traits...> >;
template<typename Node, typename... Traits>
using constructible_graph_traits =
filter_list_t<constructible_trait_condition,
build_graph_traits<Node, Traits...> >;
template<typename Node, typename... Traits>
using constructible_edge_traits =
filter_list_t<constructible_trait_condition,
build_edge_traits<Node, Traits...> >;
template<typename T>
concept EdgeTrait = std::is_base_of_v<graph::EdgeTrait, T>;
template<typename T>
concept GraphTrait = std::is_base_of_v<graph::GraphTrait, T>;
template<typename T>
concept Trait = GraphTrait<T> || EdgeTrait<T>;
template<typename T>
concept Hashable =
requires(const std::remove_reference_t<T>& a,
const std::remove_reference_t<T>& b) {
{ std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
{ a == b } -> std::convertible_to<bool>;
};
template<typename T>
concept Comparable =
requires(const std::remove_reference_t<T>& a,
const std::remove_reference_t<T>& b) {
{ a < b } -> std::convertible_to<bool>;
};
template<typename Node, typename... GraphTraits>
concept HashBaseConsistent =
Hashable<Node> && contains_type_v<graph::HashTableBased, GraphTraits...>;
template<typename Node, typename... GraphTraits>
concept RBTreeBaseConsistent =
Comparable<Node> && !contains_type_v<graph::HashTableBased, GraphTraits...>;
template<typename Node, typename... GraphTraits>
concept BaseConsistent =
HashBaseConsistent<Node, GraphTraits...> ||
RBTreeBaseConsistent<Node, GraphTraits...>;
template<typename... Traits>
concept CorrectDSUTraits =
sizeof...(Traits) == 0 ||
sizeof...(Traits) == 1 && contains_type_v<graph::HashTableBased, Traits...>;
} // graph_meta
#endif // IMPL_META_UTILS_HPP
| 29.742081
| 80
| 0.726761
|
thequickf
|
8a0a7d33d2fdce20335c993ef4ee73f18de6b426
| 4,382
|
cpp
|
C++
|
source/rt_stark.cpp
|
cloudy-astrophysics/cloudy_lfs
|
aed1d6d78042b93f17ea497a37b35a524f3d3e2e
|
[
"Zlib"
] | null | null | null |
source/rt_stark.cpp
|
cloudy-astrophysics/cloudy_lfs
|
aed1d6d78042b93f17ea497a37b35a524f3d3e2e
|
[
"Zlib"
] | null | null | null |
source/rt_stark.cpp
|
cloudy-astrophysics/cloudy_lfs
|
aed1d6d78042b93f17ea497a37b35a524f3d3e2e
|
[
"Zlib"
] | null | null | null |
/* This file is part of Cloudy and is copyright (C)1978-2019 by Gary J. Ferland and
* others. For conditions of distribution and use see copyright notice in license.txt */
/*RT_stark compute stark broadening escape probabilities using Puetter formalism */
#include "cddefines.h"
#include "iso.h"
#include "dense.h"
#include "phycon.h"
#include "rt.h"
STATIC realnum strkar( long nLo, long nHi );
void RT_stark(void)
{
long int ipLo,
ipHi;
double aa , ah,
stark,
strkla;
DEBUG_ENTRY( "RT_stark()" );
/* only evaluate one time per zone */
static long int nZoneEval=-1;
if( nzone==nZoneEval )
return;
nZoneEval = nzone;
for( long ipISO=ipH_LIKE; ipISO<NISO; ++ipISO )
{
/* loop over all iso-electronic sequences */
for( long nelem=ipISO; nelem<LIMELM; ++nelem )
{
if( !dense.lgElmtOn[nelem] )
continue;
t_iso_sp* sp = &iso_sp[ipISO][nelem];
if( !rt.lgStarkON )
{
for( ipHi=0; ipHi < sp->numLevels_max; ipHi++ )
{
for( ipLo=0; ipLo < sp->numLevels_max; ipLo++ )
{
sp->ex[ipHi][ipLo].pestrk = 0.;
sp->ex[ipHi][ipLo].pestrk_up = 0.;
}
}
continue;
}
/* evaluate Stark escape probability from
* >>ref Puetter Ap.J. 251, 446. */
/* coefficients for Stark broadening escape probability
* to be Puetters AH, equation 9b, needs factor of (Z^-4.5 * (nu*nl)^3 * xl) */
ah = 6.9e-6*1000./1e12/(phycon.sqrte*phycon.te10*phycon.te10*
phycon.te03*phycon.te01*phycon.te01)*dense.eden;
/* include Z factor */
ah *= powpq( (double)(nelem+1), -9, 2 );
/* coefficient for all lines except Ly alpha */
/* equation 10b, except missing tau^-0.6 */
stark = 0.264*pow(ah,0.4);
/* coefficient for Ly alpha */
/* first few factors resemble equation 13c...what about the rest? */
strkla = 0.538*ah*4.*9.875*(phycon.sqrte/phycon.te10/phycon.te03);
long ipHi = iso_ctrl.nLyaLevel[ipISO];
/* Lyman lines always have outer optical depths */
/* >>chng 02 mar 31, put in max, crashed on some first iteration
* with negative optical depths,
* NB did not understand why neg optical depths started */
aa = (realnum)max(0.,sp->trans(ipHi,0).Emis().TauIn());
aa = powpq( aa, -3, 4 );
sp->ex[ipHi][0].pestrk_up = strkla/2.*MAX2(1.,aa);
/**\todo 2 - Stark is disabled for now since Lya escape causes density dependent
* feedback on the radiative transfer. Would need to redo the escape
* probs every time the electron density is updated - see blr89.in for an
* example */
sp->ex[ipHi][0].pestrk_up =
MIN2(.01,sp->ex[ipHi][0].pestrk_up);
sp->ex[ipHi][0].pestrk_up = 0.;
sp->ex[ipHi][0].pestrk = sp->ex[ipHi][0].pestrk_up *
sp->trans(ipHi,0).Emis().Aul();
/* >>chng 06 aug 28, from numLevels_max to _local. */
for( ipHi=3; ipHi < sp->numLevels_local; ipHi++ )
{
if( sp->trans(ipHi,0).ipCont() <= 0 )
continue;
sp->ex[ipHi][0].pestrk_up = stark / 2. *
strkar( sp->st[0].n(), sp->st[ipHi].n() ) *
powpq(MAX2(1.,sp->trans(ipHi,0).Emis().TauIn()),-3,4);
sp->ex[ipHi][0].pestrk_up = MIN2(.01,sp->ex[ipHi][0].pestrk_up);
sp->ex[ipHi][0].pestrk = sp->trans(ipHi,0).Emis().Aul()*
sp->ex[ipHi][0].pestrk_up;
}
/* zero out rates above iso.numLevels_local */
for( ipHi=sp->numLevels_local; ipHi < sp->numLevels_max; ipHi++ )
{
sp->ex[ipHi][0].pestrk_up = 0.;
sp->ex[ipHi][0].pestrk = 0.;
}
/* all other lines */
for( ipLo=ipH2s; ipLo < (sp->numLevels_local - 1); ipLo++ )
{
for( ipHi=ipLo + 1; ipHi < sp->numLevels_local; ipHi++ )
{
if( sp->trans(ipHi,ipLo).ipCont() <= 0 )
continue;
aa = stark *
strkar( sp->st[ipLo].n(), sp->st[ipHi].n() ) *
powpq(MAX2(1.,sp->trans(ipHi,ipLo).Emis().TauIn()),-3,4);
sp->ex[ipHi][ipLo].pestrk_up =
(realnum)MIN2(.01,aa);
sp->ex[ipHi][ipLo].pestrk = sp->trans(ipHi,ipLo).Emis().Aul()*
sp->ex[ipHi][ipLo].pestrk_up;
}
}
/* zero out rates above iso.numLevels_local */
for( ipLo=(sp->numLevels_local - 1); ipLo<(sp->numLevels_max - 1); ipLo++ )
{
for( ipHi=ipLo + 1; ipHi < sp->numLevels_max; ipHi++ )
{
sp->ex[ipHi][ipLo].pestrk_up = 0.;
sp->ex[ipHi][ipLo].pestrk = 0.;
}
}
}
}
return;
}
STATIC realnum strkar( long nLo, long nHi )
{
return (realnum)pow((realnum)( nLo * nHi ),(realnum)1.2f);
}
| 29.019868
| 89
| 0.606801
|
cloudy-astrophysics
|
8a0aad71238b49ec961a34ce84ac3b43ead05882
| 3,211
|
cpp
|
C++
|
SeqScript.cpp
|
Sgw32/R3E
|
8a55dd137d9e102cf4c9c2fee3d89901bdefa3cd
|
[
"MIT"
] | 7
|
2017-11-27T15:15:08.000Z
|
2021-03-29T16:53:22.000Z
|
SeqScript.cpp
|
Sgw32/R3E
|
8a55dd137d9e102cf4c9c2fee3d89901bdefa3cd
|
[
"MIT"
] | null | null | null |
SeqScript.cpp
|
Sgw32/R3E
|
8a55dd137d9e102cf4c9c2fee3d89901bdefa3cd
|
[
"MIT"
] | 4
|
2017-11-28T02:53:19.000Z
|
2021-01-29T10:37:52.000Z
|
/////////////////////////////////////////////////////////////////////
///////////////Original file by:Fyodor Zagumennov aka Sgw32//////////
///////////////Copyright(c) 2010 Fyodor Zagumennov //////////
/////////////////////////////////////////////////////////////////////
#include "SeqScript.h"
//#include "Event.h"
SeqScript::SeqScript()
{
time = 0;
tim2=0;
mInf=false;
started =false;
wait_before_start=0;
disposed = false;
first=false;
elapsedt=0;
lastt=0;
time=0;
}
SeqScript::~SeqScript()
{
}
void SeqScript::assign(Vector3 pos,Real length,String name,bool freezebefore,bool unfreezeafter,bool splineanims,bool hidehud)
{
mName = name;
this->length=length;
mStartPosition =pos;
fb=freezebefore;
unfreeze=unfreezeafter;
//mCamera->setPosition(pos);
mSceneMgr = global::getSingleton().getSceneManager();
// Spline it for nice curves
// Create a track to animate the camera's node
hhud=hidehud;
}
String SeqScript::getname()
{
return mName;
}
void SeqScript::setWait(Real wait)
{
wait_before_start = wait;
}
void SeqScript::addFrame(Real seconds)
{
}
void SeqScript::start()
{
first=true;
started =true;
time=0;
}
void SeqScript::stop()
{
if (started)
{
time=0;
started=false;
}
}
bool SeqScript::frameStarted(const Ogre::FrameEvent &evt)
{
// if we called START
/*if (started)
mAnimState->addTime(evt.timeSinceLastFrame);
if (!(tim2>wait_before_start))
tim2=tim2+evt.timeSinceLastFrame;
if (tim2>wait_before_start)
{
if (!started)
start();
time=time+evt.timeSinceLastFrame;
if (!(time>length))
{
}
if (time>length)
{
dispose();
}
}*/
if (wait_before_start==0)
{
if (started)
{
/*if (first)
{*/
vector<Real>::iterator j;
vector<String>::iterator k;
for (i=0;i!=scripts.size();i++)
{
if (time>scripts_s[i])
{
LogManager::getSingleton().logMessage("SeqScript: Running lua script!");
RunLuaScript(global::getSingleton().getLuaState(), scripts[i].c_str());
scripts_s[i]=-1;
//first=false;
}
}
bool stop=true;
while (stop)
{
stop=false;
i=0;
for (j=scripts_s.begin();j!=scripts_s.end();j++)
{
if (!stop)
{
if ((*j)==-1)
{
LogManager::getSingleton().logMessage("Erasing a lua script...");
scripts_s.erase(j);
k=scripts.begin();
advance(k,i);
scripts.erase(k);
stop=true;
}
i++;
if (stop)
break;
}
}
}
//}
if (evt.timeSinceLastFrame<3.0f) //discrapency!!!
time+=evt.timeSinceLastFrame;
//}
if ((time>=length)&&!mInf)
{
dispose();
}
if ((time>length)&&mInf)
{
time=0.1f;
}
}
}
else
{
if (!(tim2>wait_before_start))
tim2+=evt.timeSinceLastFrame;
if (tim2>wait_before_start)
{
start();
wait_before_start=0;
}
}
return true;
}
void SeqScript::dispose()
{
if (!disposed)
{
if (first)
{
LogManager::getSingleton().logMessage("Disposing SeqScript. It has been used ingame");
started =false;
disposed=true;
}
else
{
LogManager::getSingleton().logMessage("Disposing SeqScript. It wasn't used ingame");
disposed=true;
}
}
}
| 16.723958
| 126
| 0.580193
|
Sgw32
|
8a0ea18187e60ea7f6ee587e479ce6ef684cdab2
| 1,594
|
hpp
|
C++
|
include/visualization/scorep_substrate_rrl.hpp
|
umbreensabirmain/readex-rrl
|
0cb73b3a3c6948a8dbdce96c240b24d8e992c2fe
|
[
"BSD-3-Clause"
] | 1
|
2019-10-09T09:15:47.000Z
|
2019-10-09T09:15:47.000Z
|
include/visualization/scorep_substrate_rrl.hpp
|
readex-eu/readex-rrl
|
ac8722c44f84d65668e2a60e4237ebf51b298c9b
|
[
"BSD-3-Clause"
] | null | null | null |
include/visualization/scorep_substrate_rrl.hpp
|
readex-eu/readex-rrl
|
ac8722c44f84d65668e2a60e4237ebf51b298c9b
|
[
"BSD-3-Clause"
] | 1
|
2018-07-13T11:31:05.000Z
|
2018-07-13T11:31:05.000Z
|
/*
* scorep_substrate_rrl.hpp
*
* Created on: Feb 21, 2017
* Author: mian
*/
#ifndef INCLUDE_VISUALIZATION_SCOREP_SUBSTRATE_RRL_HPP_
#define INCLUDE_VISUALIZATION_SCOREP_SUBSTRATE_RRL_HPP_
#include <scorep/plugin/plugin.hpp>
namespace spp = scorep::plugin::policy;
using scorep_clock = scorep::chrono::measurement_clock;
using scorep::plugin::log::logging;
namespace rrl
{
// Our metric handle.
struct visualization_metric
{
visualization_metric(const std::string &name_, int value_) : name(name_), value(value_)
{
}
std::string name;
int value;
};
template <typename T, typename P>
using visualization_object_id = spp::object_id<visualization_metric, T, P>;
class scorep_substrate_rrl : public scorep::plugin::base<scorep_substrate_rrl,
spp::per_process,
spp::sync,
spp::scorep_clock,
visualization_object_id>
{
public:
scorep_substrate_rrl();
~scorep_substrate_rrl();
void add_metric(visualization_metric &handle);
template <typename P> void get_optional_value(visualization_metric &handle, P &proxy);
std::vector<scorep::plugin::metric_property> get_metric_properties(
const std::string &metric_name);
private:
std::hash<std::string> metric_name_hash; /**< function to hash the names of the metrics */
static const std::string atp_prefix_;
scorep::plugin::metric_property add_metric_property(const std::string &name);
};
}
#endif /* INCLUDE_VISUALIZATION_SCOREP_SUBSTRATE_RRL_HPP_ */
| 31.88
| 94
| 0.69197
|
umbreensabirmain
|
8a18f59907a1f99ab38f599025f1ddd08fa8e14b
| 11,693
|
cpp
|
C++
|
src/core/OTData.cpp
|
grealish/opentxs
|
614999063079f5843428abcaa62974f5f19f88a1
|
[
"Apache-2.0"
] | 1
|
2015-01-23T13:24:07.000Z
|
2015-01-23T13:24:07.000Z
|
src/core/OTData.cpp
|
grealish/opentxs
|
614999063079f5843428abcaa62974f5f19f88a1
|
[
"Apache-2.0"
] | null | null | null |
src/core/OTData.cpp
|
grealish/opentxs
|
614999063079f5843428abcaa62974f5f19f88a1
|
[
"Apache-2.0"
] | null | null | null |
/************************************************************
*
* OTData.cpp
*
*/
/************************************************************
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
* OPEN TRANSACTIONS
*
* Financial Cryptography and Digital Cash
* Library, Protocol, API, Server, CLI, GUI
*
* -- Anonymous Numbered Accounts.
* -- Untraceable Digital Cash.
* -- Triple-Signed Receipts.
* -- Cheques, Vouchers, Transfers, Inboxes.
* -- Basket Currencies, Markets, Payment Plans.
* -- Signed, XML, Ricardian-style Contracts.
* -- Scripted smart contracts.
*
* Copyright (C) 2010-2013 by "Fellow Traveler" (A pseudonym)
*
* EMAIL:
* FellowTraveler@rayservers.net
*
* BITCOIN: 1NtTPVVjDsUfDWybS4BwvHpG2pdS9RnYyQ
*
* KEY FINGERPRINT (PGP Key in license file):
* 9DD5 90EB 9292 4B48 0484 7910 0308 00ED F951 BB8E
*
* OFFICIAL PROJECT WIKI(s):
* https://github.com/FellowTraveler/Moneychanger
* https://github.com/FellowTraveler/Open-Transactions/wiki
*
* WEBSITE:
* http://www.OpenTransactions.org/
*
* Components and licensing:
* -- Moneychanger..A Java client GUI.....LICENSE:.....GPLv3
* -- otlib.........A class library.......LICENSE:...LAGPLv3
* -- otapi.........A client API..........LICENSE:...LAGPLv3
* -- opentxs/ot....Command-line client...LICENSE:...LAGPLv3
* -- otserver......Server Application....LICENSE:....AGPLv3
* Github.com/FellowTraveler/Open-Transactions/wiki/Components
*
* All of the above OT components were designed and written by
* Fellow Traveler, with the exception of Moneychanger, which
* was contracted out to Vicky C (bitcointrader4@gmail.com).
* The open-source community has since actively contributed.
*
* -----------------------------------------------------
*
* LICENSE:
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* ADDITIONAL PERMISSION under the GNU Affero GPL version 3
* section 7: (This paragraph applies only to the LAGPLv3
* components listed above.) If you modify this Program, or
* any covered work, by linking or combining it with other
* code, such other code is not for that reason alone subject
* to any of the requirements of the GNU Affero GPL version 3.
* (==> This means if you are only using the OT API, then you
* don't have to open-source your code--only your changes to
* Open-Transactions itself must be open source. Similar to
* LGPLv3, except it applies to software-as-a-service, not
* just to distributing binaries.)
*
* Extra WAIVER for OpenSSL, Lucre, and all other libraries
* used by Open Transactions: This program is released under
* the AGPL with the additional exemption that compiling,
* linking, and/or using OpenSSL is allowed. The same is true
* for any other open source libraries included in this
* project: complete waiver from the AGPL is hereby granted to
* compile, link, and/or use them with Open-Transactions,
* according to their own terms, as long as the rest of the
* Open-Transactions terms remain respected, with regard to
* the Open-Transactions code itself.
*
* Lucre License:
* This code is also "dual-license", meaning that Ben Lau-
* rie's license must also be included and respected, since
* the code for Lucre is also included with Open Transactions.
* See Open-Transactions/src/otlib/lucre/LUCRE_LICENSE.txt
* The Laurie requirements are light, but if there is any
* problem with his license, simply remove the Lucre code.
* Although there are no other blind token algorithms in Open
* Transactions (yet. credlib is coming), the other functions
* will continue to operate.
* See Lucre on Github: https://github.com/benlaurie/lucre
* -----------------------------------------------------
* You should have received a copy of the GNU Affero General
* Public License along with this program. If not, see:
* http://www.gnu.org/licenses/
*
* If you would like to use this software outside of the free
* software license, please contact FellowTraveler.
* (Unfortunately many will run anonymously and untraceably,
* so who could really stop them?)
*
* DISCLAIMER:
* 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 Affero General Public License for
* more details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQIcBAEBAgAGBQJRSsfJAAoJEAMIAO35UbuOQT8P/RJbka8etf7wbxdHQNAY+2cC
vDf8J3X8VI+pwMqv6wgTVy17venMZJa4I4ikXD/MRyWV1XbTG0mBXk/7AZk7Rexk
KTvL/U1kWiez6+8XXLye+k2JNM6v7eej8xMrqEcO0ZArh/DsLoIn1y8p8qjBI7+m
aE7lhstDiD0z8mwRRLKFLN2IH5rAFaZZUvj5ERJaoYUKdn4c+RcQVei2YOl4T0FU
LWND3YLoH8naqJXkaOKEN4UfJINCwxhe5Ke9wyfLWLUO7NamRkWD2T7CJ0xocnD1
sjAzlVGNgaFDRflfIF4QhBx1Ddl6wwhJfw+d08bjqblSq8aXDkmFA7HeunSFKkdn
oIEOEgyj+veuOMRJC5pnBJ9vV+7qRdDKQWaCKotynt4sWJDGQ9kWGWm74SsNaduN
TPMyr9kNmGsfR69Q2Zq/FLcLX/j8ESxU+HYUB4vaARw2xEOu2xwDDv6jt0j3Vqsg
x7rWv4S/Eh18FDNDkVRChiNoOIilLYLL6c38uMf1pnItBuxP3uhgY6COm59kVaRh
nyGTYCDYD2TK+fI9o89F1297uDCwEJ62U0Q7iTDp5QuXCoxkPfv8/kX6lS6T3y9G
M9mqIoLbIQ1EDntFv7/t6fUTS2+46uCrdZWbQ5RjYXdrzjij02nDmJAm2BngnZvd
kamH0Y/n11lCvo1oQxM+
=uSzz
-----END PGP SIGNATURE-----
**************************************************************/
#include <opentxs/core/OTData.hpp>
#include <opentxs/core/crypto/OTASCIIArmor.hpp>
#include <opentxs/core/crypto/OTPassword.hpp>
#include <opentxs/core/util/Assert.hpp>
#include <utility>
#include <cstring>
#include <cstdint>
namespace opentxs
{
OTData::OTData()
: data_(nullptr)
, position_(0)
, size_(0)
{
}
OTData::OTData(const OTData& source)
: data_(nullptr)
, position_(0)
, size_(0)
{
Assign(source);
}
OTData::OTData(const OTASCIIArmor& source)
: data_(nullptr)
, position_(0)
, size_(0)
{
if (source.Exists()) {
source.GetData(*this);
}
}
OTData::OTData(const void* data, uint32_t size)
: data_(nullptr)
, position_(0)
, size_(0)
{
Assign(data, size);
}
OTData::~OTData()
{
Release();
}
bool OTData::operator==(const OTData& rhs) const
{
if (size_ != rhs.size_) {
return false;
}
if (size_ == 0 && rhs.size_ == 0) {
return true;
}
// TODO security: replace memcmp with a more secure
// version. Still, though, I am managing it internal to
// the class.
if (std::memcmp(data_, rhs.data_, size_) == 0) {
return true;
}
return false;
}
bool OTData::operator!=(const OTData& rhs) const
{
return !operator==(rhs);
}
// First use reset() to set the internal position to 0.
// Then you pass in the buffer where the results go.
// You pass in the length of that buffer.
// It returns how much was actually read.
// If you start at position 0, and read 100 bytes, then
// you are now on position 100, and the next OTfread will
// proceed from that position. (Unless you reset().)
uint32_t OTData::OTfread(uint8_t* data, uint32_t size)
{
OT_ASSERT(data != nullptr && size > 0);
uint32_t sizeToRead = 0;
if (data_ != nullptr && position_ < GetSize()) {
// If the size is 20, and position is 5 (I've already read the first 5
// bytes) then the size remaining to read is 15. That is, GetSize()
// minus position_.
sizeToRead = GetSize() - position_;
if (size < sizeToRead) {
sizeToRead = size;
}
OTPassword::safe_memcpy(
data, size, static_cast<uint8_t*>(data_) + position_, sizeToRead);
position_ += sizeToRead;
}
return sizeToRead;
}
void OTData::zeroMemory() const
{
if (data_ != nullptr) {
OTPassword::zeroMemory(data_, size_);
}
}
void OTData::Release()
{
if (data_ != nullptr) {
// For security reasons, we clear the memory to 0 when deleting the
// object. (Seems smart.)
OTPassword::zeroMemory(data_, size_);
delete[] static_cast<uint8_t*>(data_);
// If data_ was already nullptr, no need to re-Initialize().
Initialize();
}
}
OTData& OTData::operator=(OTData rhs)
{
swap(rhs);
return *this;
}
void OTData::swap(OTData& rhs)
{
std::swap(data_, rhs.data_);
std::swap(position_, rhs.position_);
std::swap(size_, rhs.size_);
}
void OTData::Assign(const OTData& source)
{
// can't assign to self.
if (&source == this) {
return;
}
if (!source.IsEmpty()) {
Assign(source.data_, source.size_);
}
else {
// Otherwise if it's empty, then empty this also.
Release();
}
}
bool OTData::IsEmpty() const
{
return size_ < 1;
}
void OTData::Assign(const void* data, uint32_t size)
{
// This releases all memory and zeros out all members.
Release();
if (data != nullptr && size > 0) {
data_ = static_cast<void*>(new uint8_t[size]);
OT_ASSERT(data_ != nullptr);
OTPassword::safe_memcpy(data_, size, data, size);
size_ = size;
}
// TODO: else error condition. Could just ASSERT() this.
}
bool OTData::Randomize(uint32_t size)
{
Release(); // This releases all memory and zeros out all members.
if (size > 0) {
data_ = static_cast<void*>(new uint8_t[size]);
OT_ASSERT(data_ != nullptr);
if (!OTPassword::randomizeMemory_uint8(static_cast<uint8_t*>(data_),
size)) {
// randomizeMemory already logs, so I'm not logging again twice
// here.
delete[] static_cast<uint8_t*>(data_);
data_ = nullptr;
return false;
}
size_ = size;
return true;
}
// else error condition. Could just ASSERT() this.
return false;
}
void OTData::Concatenate(const void* data, uint32_t size)
{
OT_ASSERT(data != nullptr);
OT_ASSERT(size > 0);
if (size == 0) {
return;
}
if (size_ == 0) {
Assign(data, size);
return;
}
void* newData = nullptr;
uint32_t newSize = GetSize() + size;
if (newSize > 0) {
newData = static_cast<void*>(new uint8_t[newSize]);
OT_ASSERT(newData != nullptr);
OTPassword::zeroMemory(newData, newSize);
}
// If there's a new memory buffer (for the combined..)
if (newData != nullptr) {
// if THIS object has data inside of it...
if (!IsEmpty()) {
// Copy THIS object into the new
// buffer, starting at the
// beginning.
OTPassword::safe_memcpy(newData, newSize, data_, GetSize());
}
// Next we copy the data being appended...
OTPassword::safe_memcpy(static_cast<uint8_t*>(newData) + GetSize(),
newSize - GetSize(), data, size);
}
if (data_ != nullptr) {
delete[] static_cast<uint8_t*>(data_);
}
data_ = newData;
size_ = newSize;
}
OTData& OTData::operator+=(const OTData& rhs)
{
if (rhs.GetSize() > 0) {
Concatenate(rhs.data_, rhs.GetSize());
}
return *this;
}
void OTData::SetSize(uint32_t size)
{
Release();
if (size > 0) {
data_ = static_cast<void*>(new uint8_t[size]);
OT_ASSERT(data_ != nullptr);
OTPassword::zeroMemory(data_, size);
size_ = size;
}
}
} // namespace opentxs
| 29.829082
| 78
| 0.635252
|
grealish
|
8a1f108fb7792e52e56938e92c576707b6dd88aa
| 674
|
cpp
|
C++
|
examples/TailExample.cpp
|
sbeanie/Glasgow-MicroStream
|
eb0e214b0c16b22ff59b1633db4f76be380948d4
|
[
"Apache-2.0"
] | 1
|
2019-06-17T20:52:56.000Z
|
2019-06-17T20:52:56.000Z
|
examples/TailExample.cpp
|
sbeanie/Glasgow-MicroStream
|
eb0e214b0c16b22ff59b1633db4f76be380948d4
|
[
"Apache-2.0"
] | null | null | null |
examples/TailExample.cpp
|
sbeanie/Glasgow-MicroStream
|
eb0e214b0c16b22ff59b1633db4f76be380948d4
|
[
"Apache-2.0"
] | null | null | null |
#include "Stream.hpp"
using namespace glasgow_ustream;
int main (int, char**) {
void (*print_int_list) (std::list<int>) = [] (std::list<int> values) {
std::cout << "Tail stream outputted: [";
for (auto &val : values) {
std::cout << val << ",";
}
std::cout << "]" << std::endl;
};
// Create a topology with networking disabled.
Topology topology = Topology(true);
FixedDataSource<int>* source = topology.addFixedDataSource(std::list<int>{1,2,3,4,5,6,7});
TailStream<int>* tail_stream = source->tail(3);
tail_stream->sink(print_int_list);
topology.run_with_threads();
topology.shutdown();
}
| 28.083333
| 94
| 0.60089
|
sbeanie
|
8a1fdcc115ffb19336a2570347aa0ceb87fbdb93
| 1,296
|
cpp
|
C++
|
cpp/library/benchmark/main.cpp
|
KaiserLancelot/Cpp-Primer
|
a4791a6765f0b6c864e8881e6a5328e2a3d68974
|
[
"MIT"
] | 2
|
2019-12-21T00:53:47.000Z
|
2020-01-01T10:36:30.000Z
|
cpp/library/benchmark/main.cpp
|
KaiserLancelot/Cpp-Primer
|
a4791a6765f0b6c864e8881e6a5328e2a3d68974
|
[
"MIT"
] | null | null | null |
cpp/library/benchmark/main.cpp
|
KaiserLancelot/Cpp-Primer
|
a4791a6765f0b6c864e8881e6a5328e2a3d68974
|
[
"MIT"
] | null | null | null |
#include <algorithm>
#include <cstdint>
#include <random>
#include <vector>
#include <benchmark/benchmark.h>
void dense_range(benchmark::State& state) {
for (auto _ : state) {
std::vector<int> v(state.range(0), state.range(0));
// 下面两个防止优化
benchmark::DoNotOptimize(v.data());
// TODO ClobberMemory ???
benchmark::ClobberMemory();
}
}
// 从范围中挑选几个数运行 benchmark, 默认为 8 的倍数(8, 64, 512)
// 可以用 RangeMultiplier 修改默认倍数
BENCHMARK(dense_range)->Range(8, 512);
// 对范围中每一个数运行 benchmark
BENCHMARK(dense_range)->DenseRange(0, 256, 128);
void sort_vector(benchmark::State& state) {
std::default_random_engine e{std::random_device{}()};
for (auto _ : state) {
state.PauseTiming();
std::vector<std::int32_t> v;
v.reserve(state.range(0));
for (std::int32_t i{0}; i < state.range(0); ++i) {
v.push_back(e());
}
state.ResumeTiming();
std::sort(std::begin(v), std::end(v));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK(sort_vector)
->RangeMultiplier(2)
->Range(1 << 10, 1 << 18)
// 计算时间复杂度
->Complexity();
// --benchmark_format=<console|json|csv>
// --benchmark_out=<filename>
// 禁用/启用 CPU频率缩放
// sudo cpupower frequency-set --governor performance
// sudo cpupower frequency-set --governor powersave
BENCHMARK_MAIN();
| 24
| 55
| 0.660494
|
KaiserLancelot
|
8a21344249d71c7972478fc4dfe504ab2b43f7f2
| 653
|
hpp
|
C++
|
include/yukihttp/mime.hpp
|
Yuki-cpp/yuki-http
|
07fc0d194ab528f4554aef25813c565a9fce6542
|
[
"MIT"
] | null | null | null |
include/yukihttp/mime.hpp
|
Yuki-cpp/yuki-http
|
07fc0d194ab528f4554aef25813c565a9fce6542
|
[
"MIT"
] | null | null | null |
include/yukihttp/mime.hpp
|
Yuki-cpp/yuki-http
|
07fc0d194ab528f4554aef25813c565a9fce6542
|
[
"MIT"
] | null | null | null |
#pragma once
#include <string>
#include <vector>
#include <memory>
namespace yuki::http
{
class part;
class mime
{
friend class request;
public:
mime() = default;
mime(const mime&) = delete;
mime& operator=(const mime&) = delete;
mime(mime&&) = default;
mime& operator=(mime && ) = default;
~mime() = default;
void add_data_part(const std::string & name, const std::string & data);
void add_file_part(const std::string & name, const std::string & content, const std::string & file_name);
void add_file_part(const std::string & name, const std::string & path);
private:
std::vector<std::unique_ptr<yuki::http::part>> m_parts;
};
}
| 17.648649
| 106
| 0.684533
|
Yuki-cpp
|
8a257902f7bf9c601eaabe904b47d194e7b42e7d
| 989
|
hh
|
C++
|
include/rediswraps/utils.hh
|
woldaker/hiredis-cpp
|
545c8479944a678777c17a39614cecfa1dc35cd8
|
[
"BSD-3-Clause"
] | 1
|
2020-07-04T23:35:59.000Z
|
2020-07-04T23:35:59.000Z
|
include/rediswraps/utils.hh
|
woldaker/hiredis-cpp
|
545c8479944a678777c17a39614cecfa1dc35cd8
|
[
"BSD-3-Clause"
] | null | null | null |
include/rediswraps/utils.hh
|
woldaker/hiredis-cpp
|
545c8479944a678777c17a39614cecfa1dc35cd8
|
[
"BSD-3-Clause"
] | null | null | null |
#ifndef REDISWRAPS_UTILS_HH
#define REDISWRAPS_UTILS_HH
#include <string>
#include <type_traits>
namespace rediswraps {
namespace utils {
template<typename Token,
typename ArgConstructibleFromString = typename std::enable_if<
std::is_constructible<std::string, Token>::value
>::type,
typename Dummy = void
>
std::string ToString(Token const &item);
template<typename Token,
typename ArgNotConstructibleFromString = typename std::enable_if<
!std::is_constructible<std::string, Token>::value
>::type
>
std::string ToString(Token const &item);
template<typename TargetType,
typename ReturnsNonVoidDefaultConstructible = typename std::enable_if<
std::is_default_constructible<TargetType>::value &&
!std::is_void<TargetType>::value
>::type
>
TargetType Convert(std::string const &target);
std::string const ReadFile(std::string const &filepath);
} // namespace utils
} // namespace rediswraps
#include <rediswraps/utils.inl>
#endif
| 23.547619
| 74
| 0.741153
|
woldaker
|
8a264ac95f1ea7e968c72bea81e7155e5b33fa58
| 1,736
|
cc
|
C++
|
descriptor/tunnel_desc.cc
|
chris-nada/simutrans-extended
|
71c0c4f78cb3170b1fa1c68d8baafa9a7269ef6f
|
[
"Artistic-1.0"
] | 38
|
2017-07-26T14:48:12.000Z
|
2022-03-24T23:48:55.000Z
|
descriptor/tunnel_desc.cc
|
chris-nada/simutrans-extended
|
71c0c4f78cb3170b1fa1c68d8baafa9a7269ef6f
|
[
"Artistic-1.0"
] | 74
|
2017-03-15T21:07:34.000Z
|
2022-03-18T07:53:11.000Z
|
descriptor/tunnel_desc.cc
|
chris-nada/simutrans-extended
|
71c0c4f78cb3170b1fa1c68d8baafa9a7269ef6f
|
[
"Artistic-1.0"
] | 43
|
2017-03-10T15:27:28.000Z
|
2022-03-05T10:55:38.000Z
|
/*
* This file is part of the Simutrans-Extended project under the Artistic License.
* (see LICENSE.txt)
*/
#include <stdio.h>
#include "../dataobj/ribi.h"
#include "tunnel_desc.h"
#include "../network/checksum.h"
int tunnel_desc_t::slope_indices[81] = {
-1, // 0:
-1, // 1:
-1, // 2:
-1, // 3:
1, // 4:north slope
-1, // 5:
-1, // 6:
-1, // 7:
1, // 8:north slope
-1, // 9:
-1, // 10:
-1, // 11:
2, // 12:west slope
-1, // 13:
-1, // 14:
-1, // 15:
-1, // 16:
-1, // 17:
-1, // 18:
-1, // 19:
-1, // 20:
-1, // 21:
-1, // 22:
-1, // 23:
2, // 24:west slope
-1, // 25:
-1, // 26:
-1, // 27:
3, // 28:east slope
-1, // 29:
-1, // 30:
-1, // 31:
-1, // 32:
-1, // 33:
-1, // 34:
-1, // 35:
0, // 36:south slope
-1, // 37:
-1, // 38:
-1, // 39:
-1, // 40:
-1, // 41:
-1, // 42:
-1, // 43:
-1, // 44:
-1, // 45:
-1, // 46:
-1, // 47:
-1, // 48:
-1, // 49:
-1, // 50:
-1, // 51:
-1, // 52:
-1, // 53:
-1, // 54:
-1, // 55:
3, // 56:east slope
-1, // 57:
-1, // 58:
-1, // 59:
-1, // 60:
-1, // 61:
-1, // 62:
-1, // 63:
-1, // 64:
-1, // 65:
-1, // 66:
-1, // 67:
-1, // 68:
-1, // 69:
-1, // 70:
-1, // 71:
0, // 72:south slope
-1, // 73:
-1, // 74:
-1, // 75:
-1, // 76:
-1, // 77:
-1, // 78:
-1, // 79:
-1 // 80:
};
void tunnel_desc_t::calc_checksum(checksum_t *chk) const
{
obj_desc_transport_infrastructure_t::calc_checksum(chk);
//Extended settings
//chk->input(max_axle_load);
chk->input(way_constraints.get_permissive());
chk->input(way_constraints.get_prohibitive());
}
waytype_t tunnel_desc_t::get_finance_waytype() const
{
return ((get_way_desc() && (get_way_desc()->get_styp() == type_tram)) ? tram_wt : get_waytype()) ;
}
| 15.63964
| 99
| 0.46947
|
chris-nada
|
8a26b9b2b384b4431ec6210bbb1ae9c7a87225ef
| 2,089
|
cpp
|
C++
|
1304-D.cpp
|
ankiiitraj/questionsSolved
|
8452b120935a9c3d808b45f27dcdc05700d902fc
|
[
"MIT"
] | null | null | null |
1304-D.cpp
|
ankiiitraj/questionsSolved
|
8452b120935a9c3d808b45f27dcdc05700d902fc
|
[
"MIT"
] | 1
|
2020-02-24T19:45:57.000Z
|
2020-02-24T19:45:57.000Z
|
1304-D.cpp
|
ankiiitraj/questionsSolved
|
8452b120935a9c3d808b45f27dcdc05700d902fc
|
[
"MIT"
] | null | null | null |
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Author : Ankit Raj
// Problem Name : Cow and Secret Message
// Problem Link : https://codeforces.com/contest/1304/problem/D
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include <bits/stdc++.h>
#define int long long int
#define len length
#define pb push_back
#define F first
#define S second
#define debug cout << "Debugging . . .\n";
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
vector <int> adj[200005];
vector <int> BFS(int s, int dest, int n)
{
bool visited[n +1] = {0};
vector <int> dist(n +1, 0);
queue <int> q;
q.push(s); dist[s] = 0;
visited[s] = 1;
while(!q.empty())
{
int cur = q.front(); q.pop();
for(auto itr: adj[cur])
{
if(visited[itr] == 0)
{
q.push(itr);
dist[itr] = dist[cur] +1;
visited[itr] = 1;
}
}
}
return dist;
}
int32_t main()
{
faster;
#ifndef ONLINE_JUDGE
freopen("ip.txt", "r", stdin);
freopen("op.txt", "w", stdout);
#endif
// int t; cin >> t; while(t--)
{
int n, m, k, x, y, temp;
cin >> n >> m >> k;
for (int i = 0; i < n; ++i)
adj[i].clear();
int a[k];
for (int i = 0; i < k; ++i)
{
cin >> a[i];
}
for (int i = 0; i < m; ++i)
{
cin >> x >> y;
adj[x].pb(y);
adj[y].pb(x);
}
vector <int> fromOne, fromN;
fromOne = BFS(1, n, n);
fromN = BFS(n, 1, n);
map<int, int> mScore;
for(int i = 0; i < k; ++i)
{
mScore.insert({fromOne[a[i]] - fromN[a[i]], a[i]});
}
// sort(mScore.begin(), mScore.end());
int _max = -1000000000000, longestShortestPath = 0;
for(auto &itr:mScore)
{
longestShortestPath = max(longestShortestPath, _max + fromN[itr.second]);
_max = max(_max, fromOne[itr.second]);
}
cout << min(longestShortestPath +1, fromOne[n]) << endl;
}
return 0;
}
| 23.738636
| 91
| 0.471996
|
ankiiitraj
|
8a2804ac58cb8794eb53f820c2a1f78af57ae4c9
| 1,696
|
cpp
|
C++
|
October 2021/October 4, 2021/max_and_min_mileage_of_cars/main.cpp
|
thismrojek/hard_school_exercises
|
1108b5e5c67625ad95b04c9390d05c334c601218
|
[
"MIT"
] | null | null | null |
October 2021/October 4, 2021/max_and_min_mileage_of_cars/main.cpp
|
thismrojek/hard_school_exercises
|
1108b5e5c67625ad95b04c9390d05c334c601218
|
[
"MIT"
] | null | null | null |
October 2021/October 4, 2021/max_and_min_mileage_of_cars/main.cpp
|
thismrojek/hard_school_exercises
|
1108b5e5c67625ad95b04c9390d05c334c601218
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int carsMileage[3][4] = {
{
35000,
22145,
45981,
31012
},
{
26771,
34121,
36900,
22096
},
{
45332,
41100,
39498,
44128
}
};
int sumaricCarsMileage[3];
int carWithMinMileage, carWithMaxMileage;
for (int car = 0; car < 3; car++) {
for (int month = 0; month < 4; month++) {
sumaricCarsMileage[car] += carsMileage[car][month];
}
}
for (int car = 0; car < 3; car++) {
if (sumaricCarsMileage[car] > sumaricCarsMileage[car + 1]) {
carWithMaxMileage = car;
} else if (sumaricCarsMileage[car] < sumaricCarsMileage[car + 1]) {
carWithMinMileage = car;
}
}
cout << "Auto z najwiekszym przebiegiem: " << (carWithMaxMileage + 1) << endl;
cout << "Auto z najmniejszym przebiegiem: " << (carWithMinMileage + 1) << endl;
for (int car = 0; car < 3; car++) {
cout << "Laczny przebieg auta nr: " << (car + 1) << " wynosi: " << sumaricCarsMileage[car] << ", a sredni przebieg miesieczny: " << (sumaricCarsMileage[car] / 4) << endl;
}
for (int car = 0; car < 3; car++) {
if (carsMileage[car][0] % 2 == 0 &&
carsMileage[car][1] % 2 == 0 &&
carsMileage[car][2] % 2 == 0 &&
carsMileage[car][3] % 2 == 0
) {
cout << "Samochod nr: " << (car + 1) << "posiada wszystkie wartosci przebiegu jako liczbe patrzysta." << endl;
}
}
return 0;
}
| 27.803279
| 178
| 0.482311
|
thismrojek
|
8a2835f30a01491588b28b84034e9507c3c5dfce
| 3,559
|
hpp
|
C++
|
src/wrapper/AmxInstanceManager.hpp
|
eupedroosouza/ShoebillPlugin
|
49bc98348061f08c8ec6e1ce9919d6736656bee9
|
[
"Apache-2.0"
] | 6
|
2016-06-18T02:06:02.000Z
|
2020-10-17T12:25:54.000Z
|
src/wrapper/AmxInstanceManager.hpp
|
eupedroosouza/ShoebillPlugin
|
49bc98348061f08c8ec6e1ce9919d6736656bee9
|
[
"Apache-2.0"
] | 13
|
2015-11-13T13:00:33.000Z
|
2021-12-09T13:49:52.000Z
|
src/wrapper/AmxInstanceManager.hpp
|
eupedroosouza/ShoebillPlugin
|
49bc98348061f08c8ec6e1ce9919d6736656bee9
|
[
"Apache-2.0"
] | 7
|
2017-03-01T15:02:34.000Z
|
2022-03-13T16:22:21.000Z
|
/**
* Copyright (C) 2014 MK124
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __AMXINSTANCEMANAGER__
#define __AMXINSTANCEMANAGER__
#include <unordered_set>
#include "amx/amx.h"
#include <map>
#include <vector>
class AmxInstanceManager
{
public:
static AmxInstanceManager &GetInstance()
{
static AmxInstanceManager instance;
return instance;
}
AmxInstanceManager()
{ }
~AmxInstanceManager()
{ }
void RegisterAmx(AMX *amx)
{
if (!IsValid(amx))
{
amxInstances.insert(amx);
registeredFunctions[amx] = std::map<std::string, std::vector<std::string>>();
}
}
void UnregisterAmx(AMX *amx)
{
if (IsValid(amx))
{
registeredFunctions.erase(registeredFunctions.find(amx));
amxInstances.erase(amx);
if (mainAmx == amx) mainAmx = nullptr;
}
}
bool IsValid(AMX *amx)
{
return amxInstances.find(amx) != amxInstances.end();
}
void MarkAsMainAmx(AMX *amx)
{
if (!IsValid(amx)) return;
mainAmx = amx;
}
bool RegisteredFunctionExists(AMX *amx, std::string functionName)
{
return registeredFunctions[amx].find(functionName) != registeredFunctions[amx].end();
}
bool RegisterFunction(AMX *amx, std::string functionName, std::vector<std::string> types)
{
if (RegisteredFunctionExists(amx, functionName))
return false;
registeredFunctions[amx][functionName] = types;
return true;
}
std::vector<std::string> GetParameterTypes(AMX *amx, std::string functionName)
{
if (!RegisteredFunctionExists(amx, functionName))
return std::vector<std::string>();
return registeredFunctions[amx][functionName];
}
bool UnregisterFunction(AMX *amx, std::string functionName)
{
if (!RegisteredFunctionExists(amx, functionName))
return false;
registeredFunctions[amx].erase(registeredFunctions[amx].find(functionName));
return true;
}
AMX *GetMainAmx() const
{
return mainAmx;
}
AMX *GetAvailableAmx()
{
if (mainAmx != nullptr) return mainAmx;
if (amxInstances.empty()) return nullptr;
return *amxInstances.begin();
}
std::unordered_set<AMX *> GetInstances()
{
std::unordered_set<AMX *> copyOfInstances;
for (auto it = amxInstances.begin(); it != amxInstances.end(); ++it)
{
copyOfInstances.insert(*it);
}
return copyOfInstances;
}
private:
std::unordered_set<AMX *> amxInstances;
AMX *mainAmx = nullptr;
std::map<AMX *, std::map<std::string, std::vector<std::string>>> registeredFunctions;
AmxInstanceManager(const AmxInstanceManager &) = delete;
AmxInstanceManager &operator=(const AmxInstanceManager &) = delete;
};
#endif
| 27.589147
| 94
| 0.615341
|
eupedroosouza
|
8a2a9b91a6b38fbe768b27a6744e9f288061e93f
| 389
|
cpp
|
C++
|
WaveSabreCore/src/AllPassDelay.cpp
|
LeStahL/WaveSabre
|
2a603ac1b3e9c30390a977f5bfb71766552e9c62
|
[
"MIT"
] | 228
|
2019-02-18T19:13:31.000Z
|
2022-03-30T00:52:55.000Z
|
WaveSabreCore/src/AllPassDelay.cpp
|
LeStahL/WaveSabre
|
2a603ac1b3e9c30390a977f5bfb71766552e9c62
|
[
"MIT"
] | 64
|
2019-02-20T17:38:47.000Z
|
2022-01-25T20:21:00.000Z
|
WaveSabreCore/src/AllPassDelay.cpp
|
thijskruithof/WaveSabre
|
d2d0c76432284a86780deda45b35a9aa9377d79e
|
[
"MIT"
] | 31
|
2019-02-20T14:16:40.000Z
|
2022-01-05T11:25:52.000Z
|
#include <WaveSabreCore/AllPassDelay.h>
#include <WaveSabreCore/Helpers.h>
#include <math.h>
namespace WaveSabreCore
{
AllPassDelay::AllPassDelay()
{
a1 = 0.0f;
zm1 = 0.0f;
}
void AllPassDelay::Delay(float delay)
{
a1 = (1.f - delay) / (1.f + delay);
}
float AllPassDelay::Update(float inSamp)
{
float y = inSamp * -a1 + zm1;
zm1 = y * a1 + inSamp;
return y;
}
}
| 14.407407
| 41
| 0.634961
|
LeStahL
|
8a2d5f60a15ee8f2c3ceba648e815e7427209038
| 1,012
|
cpp
|
C++
|
0600/00/602a.cpp
|
actium/cf
|
d7be128c3a9adb014a231a399f1c5f19e1ab2a38
|
[
"Unlicense"
] | 1
|
2020-07-03T15:55:52.000Z
|
2020-07-03T15:55:52.000Z
|
0600/00/602a.cpp
|
actium/cf
|
d7be128c3a9adb014a231a399f1c5f19e1ab2a38
|
[
"Unlicense"
] | null | null | null |
0600/00/602a.cpp
|
actium/cf
|
d7be128c3a9adb014a231a399f1c5f19e1ab2a38
|
[
"Unlicense"
] | 3
|
2020-10-01T14:55:28.000Z
|
2021-07-11T11:33:58.000Z
|
#include <iostream>
#include <vector>
using integer = unsigned long long;
template <typename T>
std::istream& operator >>(std::istream& input, std::vector<T>& v)
{
for (T& a : v)
input >> a;
return input;
}
void answer(char v)
{
std::cout << v << '\n';
}
integer convert(const std::vector<unsigned>& x, unsigned b)
{
integer y = 0;
for (const unsigned d : x) {
y *= b;
y += d;
}
return y;
}
void solve(const std::vector<unsigned>& x, unsigned bx, const std::vector<unsigned>& y, unsigned by)
{
const integer u = convert(x, bx);
const integer v = convert(y, by);
if (u == v)
return answer('=');
answer(u < v ? '<' : '>');
}
int main()
{
size_t n;
std::cin >> n;
unsigned bx;
std::cin >> bx;
std::vector<unsigned> x(n);
std::cin >> x;
size_t m;
std::cin >> m;
unsigned by;
std::cin >> by;
std::vector<unsigned> y(m);
std::cin >> y;
solve(x, bx, y, by);
return 0;
}
| 15.333333
| 100
| 0.527668
|
actium
|
8a308f674be5fcc99893e10bec4f21f21e7219f3
| 3,352
|
cpp
|
C++
|
rom.cpp
|
PJBoy/Fusion-level-editor
|
bf2779f5ab634fb6a3d499ee9c220c8d77992478
|
[
"0BSD"
] | 4
|
2018-09-27T17:31:33.000Z
|
2021-12-24T12:46:14.000Z
|
rom.cpp
|
PJBoy/Metroid-level-editor
|
bf2779f5ab634fb6a3d499ee9c220c8d77992478
|
[
"0BSD"
] | null | null | null |
rom.cpp
|
PJBoy/Metroid-level-editor
|
bf2779f5ab634fb6a3d499ee9c220c8d77992478
|
[
"0BSD"
] | null | null | null |
//#include "sm.h"
#include "global.h"
import rom;
import mf;
import mzm;
import Sm;
Rom::Reader::Reader(std::filesystem::path filepath, index_t address /* = 0*/)
try
: f(filepath, std::ios::binary)
{
f.exceptions(std::ios::badbit | std::ios::failbit);
seek(address);
}
LOG_RETHROW
Rom::Rom(std::filesystem::path filepath)
try
: filepath(filepath)
{}
LOG_RETHROW
Rom::Reader Rom::makeReader(index_t address /* = 0*/) const
try
{
return Rom::Reader(filepath, address);
}
LOG_RETHROW
std::ifstream Rom::makeIfstream() const
try
{
std::ifstream f(filepath, std::ios::binary);
f.exceptions(std::ios::badbit | std::ios::failbit);
return f;
}
LOG_RETHROW
bool Rom::verifyRom(std::filesystem::path filepath) noexcept
try
{
loadRom(filepath);
return true;
}
catch (const std::exception&)
{
return false;
}
std::unique_ptr<Rom> Rom::loadRom(std::filesystem::path filepath)
try
{
try
{
return std::make_unique<Sm>(filepath);
}
catch (const std::exception&)
{}
try
{
return std::make_unique<Mf>(filepath);
}
catch (const std::exception&)
{}
try
{
return std::make_unique<Mzm>(filepath);
}
catch (const std::exception&)
{}
throw std::runtime_error("Not a valid ROM"s);
}
LOG_RETHROW
/*
void Rom::drawLevelView(Cairo::RefPtr<Cairo::Surface> p_surface, unsigned, unsigned) const
try
{
Cairo::RefPtr<Cairo::ImageSurface> p_tile(Cairo::ImageSurface::create(Cairo::Format::FORMAT_ARGB32, 32, 32));
{
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_tile));
p_context->set_source_rgb(0, 1, 0);
p_context->rectangle(4, 8, 28, 24);
p_context->fill();
}
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_surface));
p_context->set_source(p_tile, 32, 64);
p_context->paint();
}
LOG_RETHROW
void Rom::drawSpritemapView(Cairo::RefPtr<Cairo::Surface> p_surface, unsigned, unsigned) const
try
{
Cairo::RefPtr<Cairo::ImageSurface> p_tile(Cairo::ImageSurface::create(Cairo::Format::FORMAT_ARGB32, 32, 32));
{
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_tile));
p_context->set_source_rgb(0, 1, 0);
p_context->rectangle(4, 8, 28, 24);
p_context->fill();
}
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_surface));
p_context->set_source(p_tile, 32, 64);
p_context->paint();
}
LOG_RETHROW
void Rom::drawSpritemapTilesView(Cairo::RefPtr<Cairo::Surface> p_surface, unsigned, unsigned) const
try
{
Cairo::RefPtr<Cairo::ImageSurface> p_tile(Cairo::ImageSurface::create(Cairo::Format::FORMAT_ARGB32, 32, 32));
{
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_tile));
p_context->set_source_rgb(0, 1, 0);
p_context->rectangle(4, 8, 28, 24);
p_context->fill();
}
Cairo::RefPtr<Cairo::Context> p_context(Cairo::Context::create(p_surface));
p_context->set_source(p_tile, 32, 64);
p_context->paint();
}
LOG_RETHROW
*/
auto Rom::getRoomList() const -> std::vector<RoomList>
{
return {};
}
auto Rom::getLevelViewDimensions() const -> Dimensions
{
return {};
}
void Rom::loadLevelData(std::vector<long>)
{}
void Rom::loadSpritemap(index_t, index_t, index_t, index_t, index_t)
{}
| 22.052632
| 113
| 0.660203
|
PJBoy
|
8a321b59d767b2421bed5ffe12cd0fcf4dcae987
| 7,448
|
hpp
|
C++
|
Tests/TaskTypeTests.hpp
|
iarebwan/TaskScheduler
|
f21a7c1823f9dfe1e495596666d072ca08b234b7
|
[
"MIT"
] | null | null | null |
Tests/TaskTypeTests.hpp
|
iarebwan/TaskScheduler
|
f21a7c1823f9dfe1e495596666d072ca08b234b7
|
[
"MIT"
] | null | null | null |
Tests/TaskTypeTests.hpp
|
iarebwan/TaskScheduler
|
f21a7c1823f9dfe1e495596666d072ca08b234b7
|
[
"MIT"
] | 1
|
2022-01-27T05:15:36.000Z
|
2022-01-27T05:15:36.000Z
|
#ifndef __TASK_TYPE_TESTS_HPP__
#define __TASK_TYPE_TESTS_HPP__
#include "../OrderTasks.hpp"
#include "../OrderByTaskType.hpp"
#include <vector>
#include <iostream>
#include "gtest/gtest.h"
using namespace std;
void printTasks(vector<Task*>& ListOfTasks, OrderTasks* orderType, string classification = "") {
orderType->display(ListOfTasks, classification);
}
void test_printByClassification(vector<Task*>& ListOfTasks, string classification) {
OrderTasks* orderTaskType = new OrderByTaskType();
printTasks(ListOfTasks, orderTaskType, classification);
}
TEST(OrderByTaskTypeTest, OneTask){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("work");
ListOfTasks.push_back(task1);
EXPECT_EQ(test_printByClassification(ListOfTasks, "work"), "1. Title: Task 1, TaskType(classification): work\n");
}
TEST(OrderByTaskTypeTest, WorkTest){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("academic");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("personal");
ListOfTasks.push_back(task2);
Task* task3 = new Task();
task3->setTaskTitle("Task 3");
task3->setTaskType("work");
ListOfTasks.push_back(task3);
EXPECT_EQ(test_printByClassification(ListOfTasks, "work"), "1. Title: Task 3, TaskType(classification): work\n2. Title: Task 1, TaskType(classification): academic\n3. Title: Task 2, TaskType(classification): personal\n");
}
TEST(OrderByTaskTypeTest, PersonalTest){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("academic");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("personal");
ListOfTasks.push_back(task2);
Task* task3 = new Task();
task3->setTaskTitle("Task 3");
task3->setTaskType("work");
ListOfTasks.push_back(task3);
EXPECT_EQ(test_printByClassification(ListOfTasks, "personal"), "1. Title: Task 2, TaskType(classification): personal\n2. Title: Task 1, TaskType(classification): academic\n3. Title: Task 3, TaskType(classification): work\n");
}
TEST(OrderByTaskTypeTest, academicTest){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("personal");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("academic");
ListOfTasks.push_back(task2);
Task* task3 = new Task();
task3->setTaskTitle("Task 3");
task3->setTaskType("work");
ListOfTasks.push_back(task3);
EXPECT_EQ(test_printByClassification(ListOfTasks, "personal"), "1. Title: Task 2, TaskType(classification): academic\n2. Title: Task 1, TaskType(classification): personal\n3. Title: Task 3, TaskType(classification): work\n");
}
TEST(OrderByTaskTypeTest, OneTaskTypeEntry){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("work");
ListOfTasks.push_back(task2);
EXPECT_EQ(test_printByClassification(ListOfTasks, "work"), "1. Title: Task 2, TaskType(classification): work\n2. Title: Task 1\n");
}
TEST(OrderByTaskTypeTest, NoTaskTypeEntry){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
ListOfTasks.push_back(task2);
EXPECT_EQ(test_printByClassification(ListOfTasks, ""), "1. Title: Task 1\n2. Title: Task 2\n");
}
TEST(OrderByTaskTypeTest, NoTaskTypeEntry2){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("work");
ListOfTasks.push_back(task2);
EXPECT_EQ(test_printByClassification(ListOfTasks, ""), "1. Title: Task 1\n2. Title: Task 2, TaskType(classification): work\n");
}
TEST(OrderByTaskTypeTest, SameTaskTypeEntry){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("personal");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("personal");
ListOfTasks.push_back(task2);
EXPECT_EQ(test_printByClassification(ListOfTasks, "personal"), "1. Title: Task 1, TaskType(classification): personal\n2. Title: Task 2, TaskType(classification): personal\n";
}
TEST(OrderByTaskTypeTest, SameTaskTypeEntry2){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("work");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("work");
ListOfTasks.push_back(task2);
Task* task3 = new Task();
task3->setTaskTitle("Task 3");
task3->setTaskType("work");
ListOfTasks.push_back(task3);
EXPECT_EQ(test_printByClassification(ListOfTasks, "work"), "1. Title: Task 1, TaskType(classification): work\n2. Title: Task 2, TaskType(classification): work\n3. Title: Task 3, TaskType(classification): work\n");
}
TEST(OrderByTaskTypeTest, LotsOfPriorities){
vector<Task*> ListOfTasks;
Task* task1 = new Task();
task1->setTaskTitle("Task 1");
task1->setTaskType("work");
ListOfTasks.push_back(task1);
Task* task2 = new Task();
task2->setTaskTitle("Task 2");
task2->setTaskType("personal");
ListOfTasks.push_back(task2);
Task* task3 = new Task();
task3->setTaskTitle("Task 3");
task3->setTaskType("academic");
ListOfTasks.push_back(task3);
Task* task4 = new Task();
task4->setTaskTitle("Task 4");
task4->setTaskType("work");
ListOfTasks.push_back(task4);
Task* task5 = new Task();
task5->setTaskTitle("Task 5");
task5->setTaskType("personal");
ListOfTasks.push_back(task5);
Task* task6 = new Task();
task6->setTaskTitle("Task 6");
task6->setTaskType("academic");
ListOfTasks.push_back(task6);
Task* task7 = new Task();
task7->setTaskTitle("Task 7");
task7->setTaskType("work");
ListOfTasks.push_back(task7);
Task* task8 = new Task();
task8->setTaskTitle("Task 8");
task8->setTaskType("personal");
ListOfTasks.push_back(task8);
Task* task9 = new Task();
task9->setTaskTitle("Task 9");
task9->setTaskType("academic");
ListOfTasks.push_back(task9);
EXPECT_EQ(test_printByClassification(ListOfTasks, "work"), "1. Title: Task 1, TaskType(classification): work\n2. Title: Task 4, TaskType(classification): work\n3. Title: Task 7, TaskType(classification): work\n4. Title: Task 2, TaskType(classification): personal\n5. Title: Task 3, TaskType(classification): academic\n6. Title: Task 5, TaskType(classification): personal\n7. Title: Task 6, TaskType(classification): academic\n8. Title: Task 8, TaskType(classification): personal\n9. Title: Task 9, TaskType(classification): academic\n");
}
//int main(int argc, char **argv) {
// ::testing::InitGoogleTest(&argc, argv);
// return RUN_ALL_TESTS();
//}
#endif
| 32.242424
| 541
| 0.692132
|
iarebwan
|
8a3582f6d37055f6fdaf63fdced671951853af76
| 160
|
hpp
|
C++
|
src/libmlog/global.hpp
|
publiqnet/mesh.pp
|
a85e393c0de82b5b477b48bf23f0b89f6ac82c26
|
[
"MIT"
] | 1
|
2020-02-22T16:50:11.000Z
|
2020-02-22T16:50:11.000Z
|
src/libmlog/global.hpp
|
publiqnet/mesh.pp
|
a85e393c0de82b5b477b48bf23f0b89f6ac82c26
|
[
"MIT"
] | null | null | null |
src/libmlog/global.hpp
|
publiqnet/mesh.pp
|
a85e393c0de82b5b477b48bf23f0b89f6ac82c26
|
[
"MIT"
] | null | null | null |
#pragma once
#include <mesh.pp/global.hpp>
#if defined(LOG_LIBRARY)
#define MLOGSHARED_EXPORT MESH_EXPORT
#else
#define MLOGSHARED_EXPORT MESH_IMPORT
#endif
| 14.545455
| 37
| 0.80625
|
publiqnet
|
8a37d15e458aa1e8e9e37c6141d85242a84e8b03
| 6,530
|
cpp
|
C++
|
Dynamic Programming/576. Out of Boundary Paths.cpp
|
beckswu/Leetcode
|
480e8dc276b1f65961166d66efa5497d7ff0bdfd
|
[
"MIT"
] | 138
|
2020-02-08T05:25:26.000Z
|
2021-11-04T11:59:28.000Z
|
Dynamic Programming/576. Out of Boundary Paths.cpp
|
beckswu/Leetcode
|
480e8dc276b1f65961166d66efa5497d7ff0bdfd
|
[
"MIT"
] | null | null | null |
Dynamic Programming/576. Out of Boundary Paths.cpp
|
beckswu/Leetcode
|
480e8dc276b1f65961166d66efa5497d7ff0bdfd
|
[
"MIT"
] | 24
|
2021-01-02T07:18:43.000Z
|
2022-03-20T08:17:54.000Z
|
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
static const long long M = 1000000007;
vector<vector<long long>>table(m, vector<long long>(n,0));
table[i][j] = 1; long long res = 0;
for(long long k = 0; k<N; k++){
vector<vector<long long>>newtable(m, vector<long long>(n,0));
for(long long a = 0; a<m; a++){
for(long long b = 0; b<n; b++){
if(table[a][b]) {
if(a-1<0){
res = (res+table[a][b])%M;
}
else{
newtable[a-1][b] += table[a][b]%M;
}
if(a+1>=m){
res = (res+table[a][b])%M;
}
else{
newtable[a+1][b] += table[a][b]%M;
}
if(b-1<0){
res = (res+table[a][b])%M;
}
else{
newtable[a][b-1] += table[a][b]%M;
}
if(b+1>=n){
res = (res+table[a][b])%M;
}
else{
newtable[a][b+1] += table[a][b]%M;
}
table[a][b] = 0;
}
}
}
table = newtable;
}
return res%M;
}
};
/*
dfs with memoization, dp[i][j][k] 表示到达i,j后还剩k步,可以最多out of boundary 数量
*/
class Solution {
public:
long long dp[51][51][51];
int m, n;
long long M;
int findPaths(int m, int n, int N, int i, int j) {
M = 1000000007;
memset(dp, -1, sizeof(dp));
this->m = m; this->n = n;
return dfs(i, j, N);
}
long long dfs(int i, int j, int k){
if(i < 0 || j < 0 || i >= m || j>=n){
return 1;
}
else if(k==0)
return 0;
if(dp[i][j][k]>=0)
return dp[i][j][k];
dp[i][j][k] = ( dfs(i, j+1, k-1)%M+ dfs(i, j-1, k-1)%M + dfs(i+1, j, k-1)%M + dfs(i-1, j, k-1)%M)%M;
return dp[i][j][k];
}
};
//Bottom-up DP
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
vector<vector<long long>>dp(m, vector<long long>(n));
dp[i][j] = 1;
int mod = pow(10,9)+7;
vector<vector<int>>move = {{-1,0},{0,-1}, {1,0}, {0,1}};
long long res = 0 ;
for(int z = 0; z<N; ++z){
vector<vector<long long>>tmp(m, vector<long long>(n));
for(int ii = 0 ; ii<m; ++ii){
for(int jj = 0; jj<n; ++jj){
if(dp[ii][jj]){
for(auto nxt: move){
int nxt_i = nxt[0] + ii;
int nxt_j = nxt[1] + jj;
if(nxt_i <0 || nxt_j < 0 || nxt_i >= m || nxt_j >= n)
res = (res + dp[ii][jj]) % mod;
else
tmp[nxt_i][nxt_j] = (tmp[nxt_i][nxt_j] + dp[ii][jj])%mod;
}
}
}
}
dp = tmp;
}
return res;
}
};
//DP
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
uint dp[51][50][50] = {};
for (auto Ni = 1; Ni <= N; ++Ni)
for (auto mi = 0; mi < m; ++mi)
for (auto ni = 0; ni < n; ++ni)
dp[Ni][mi][ni] = ((mi == 0 ? 1 : dp[Ni - 1][mi - 1][ni]) + (mi == m - 1? 1 : dp[Ni - 1][mi + 1][ni])
+ (ni == 0 ? 1 : dp[Ni - 1][mi][ni - 1]) + (ni == n - 1 ? 1 : dp[Ni - 1][mi][ni + 1])) % 1000000007;
return dp[N][i][j];
}
};
//reduce the memory usage by using two grids instead of N
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
unsigned int g[2][50][50] = {};
while (N-- > 0)
for (auto k = 0; k < m; ++k)
for (auto l = 0, nc = (N + 1) % 2, np = N % 2; l < n; ++l)
g[nc][k][l] = ((k == 0 ? 1 : g[np][k - 1][l]) + (k == m - 1 ? 1 : g[np][k + 1][l])
+ (l == 0 ? 1 : g[np][k][l - 1]) + (l == n - 1 ? 1 : g[np][k][l + 1])) % 1000000007;
return g[1][i][j];
}
};
//DFS
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
vector<vector<vector<long>>>dp(m, vector<vector<long>>(n, vector<long>(N+1,-1)));
return dfs(dp, m, n, i, j, N);
}
int dfs(vector<vector<vector<long>>>&dp, int m, int n, int i, int j, int N ){
if(N<0)
return 0;
if(i < 0 || j<0 || i>=m || j>=n)
return 1;
if(dp[i][j][N] >= 0)
return dp[i][j][N];
vector<vector<int>>move = {{-1,0},{0,-1}, {1,0}, {0,1}};
int mod = pow(10,9)+7;
long long res = 0;
for(auto nxt: move){
int nxt_i = nxt[0] + i;
int nxt_j = nxt[1] + j;
res = (res + dfs(dp, m, n, nxt_i, nxt_j, N-1))%mod;
} return dp[i][j][N] = res;
}
};
//BFS
class Solution {
public:
int findPaths(int m, int n, int N, int i, int j) {
vector<vector<int>>move = {{-1,0},{0,-1}, {1,0}, {0,1}};
int mod = pow(10,9)+7;
vector<vector<long>>dp(m, vector<long>(n));
queue<vector<int>>q;
q.push({i,j});
long res = 0;
int size = 1;
dp[i][j] = 1;
while((size = q.size()) && N--){
vector<vector<long>>tmp(m, vector<long>(n));
for(int z = 0; z< size; ++z){
vector<int>cur = q.front(); q.pop();
int ii = cur[0], jj = cur[1];
for(auto nxt: move){
int nxt_i = nxt[0] + ii;
int nxt_j = nxt[1] + jj;
if(nxt_i <0 || nxt_j < 0 || nxt_i >= m || nxt_j >= n)
res = (res + dp[ii][jj]) % mod;
else{
if(tmp[nxt_i][nxt_j] == 0)
q.push({nxt_i, nxt_j});
tmp[nxt_i][nxt_j] = (tmp[nxt_i][nxt_j] + dp[ii][jj])%mod;
}
}
}
dp = tmp;
}
return res;
}
};
| 32.009804
| 116
| 0.35758
|
beckswu
|
8a406738a4aaae078f2ac1eb3c0b61a583180d8c
| 742
|
hpp
|
C++
|
src/MainWindow.hpp
|
ricardobtez/gtkmm-application
|
6af746c11f6577cfd12d93fa692c2fad548de538
|
[
"MIT"
] | null | null | null |
src/MainWindow.hpp
|
ricardobtez/gtkmm-application
|
6af746c11f6577cfd12d93fa692c2fad548de538
|
[
"MIT"
] | 1
|
2020-10-22T20:37:33.000Z
|
2020-10-22T20:40:12.000Z
|
src/MainWindow.hpp
|
ricardobtez/gtkmm-application
|
6af746c11f6577cfd12d93fa692c2fad548de538
|
[
"MIT"
] | null | null | null |
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <gtkmm/applicationwindow.h>
#include <gtkmm/box.h>
#include <gtkmm/builder.h>
class MainWindow : public Gtk::ApplicationWindow
{
public:
MainWindow(void);
virtual ~MainWindow();
protected:
// Signal handlers
void on_menu_others(void);
void on_menu_choices_other(const int parameter);
void on_menu_toggle();
// Child widgets
Gtk::Box m_box;
Glib::RefPtr<Gtk::Builder> m_refBuilder;
//Two sets of choices:
Glib::RefPtr<Gio::SimpleAction> m_refChoice;
Glib::RefPtr<Gio::SimpleAction> m_refChoiceOther;
Glib::RefPtr<Gio::SimpleAction> m_refToggle;
private:
void on_menu_preferences_options(void);
};
#endif /* MAIN_WINDOW_H */
| 20.054054
| 53
| 0.715633
|
ricardobtez
|
8a52281d0d28206e88109bb087e388cbf970c4f5
| 1,024
|
cpp
|
C++
|
TimeEntry.cpp
|
ChristianLightServices/ClockifyTrayIcons
|
568f9635ff1b304773e7fe8f143c1044c7b94ad4
|
[
"MIT"
] | 1
|
2021-09-17T08:09:32.000Z
|
2021-09-17T08:09:32.000Z
|
TimeEntry.cpp
|
ChristianLightServices/ClockifyTrayIcons
|
568f9635ff1b304773e7fe8f143c1044c7b94ad4
|
[
"MIT"
] | null | null | null |
TimeEntry.cpp
|
ChristianLightServices/ClockifyTrayIcons
|
568f9635ff1b304773e7fe8f143c1044c7b94ad4
|
[
"MIT"
] | null | null | null |
#include "TimeEntry.h"
#include "ClockifyManager.h"
#include "JsonHelper.h"
TimeEntry::TimeEntry(nlohmann::json entry, QObject *parent)
: QObject{parent}
{
try
{
m_id = entry["id"].get<QString>();
auto projectId = entry["projectId"].get<QString>();
m_project = {projectId, ClockifyManager::instance()->projectName(projectId), entry["description"].get<QString>()};
m_userId = entry["userId"].get<QString>();
m_start = entry["timeInterval"]["start"].get<QDateTime>();
m_end = entry["timeInterval"]["end"].get<QDateTime>();
m_isValid = true;
}
catch (const std::exception &)
{
// TODO: do something here?
}
}
TimeEntry::TimeEntry()
: QObject{nullptr},
m_isValid{false}
{
}
TimeEntry::TimeEntry(const TimeEntry &that)
: QObject{that.parent()}
{
*this = that;
}
TimeEntry &TimeEntry::operator=(const TimeEntry &other)
{
m_id = other.m_id;
m_project = other.m_project;
m_userId = other.m_userId;
m_start = other.m_start;
m_end = other.m_end;
m_isValid = other.m_isValid;
return *this;
}
| 20.897959
| 116
| 0.6875
|
ChristianLightServices
|
8a524ae537a83365004b3acc5b57c39dd2b3b14e
| 422
|
hpp
|
C++
|
plugin-sdk/include/piga/daemon/sdk/AppManager.hpp
|
Pigaco/daemon
|
df28306a7f8cdd2d263ab8f5663eefc1aabe876f
|
[
"Apache-2.0"
] | 1
|
2016-11-17T07:13:18.000Z
|
2016-11-17T07:13:18.000Z
|
plugin-sdk/include/piga/daemon/sdk/AppManager.hpp
|
Pigaco/daemon
|
df28306a7f8cdd2d263ab8f5663eefc1aabe876f
|
[
"Apache-2.0"
] | null | null | null |
plugin-sdk/include/piga/daemon/sdk/AppManager.hpp
|
Pigaco/daemon
|
df28306a7f8cdd2d263ab8f5663eefc1aabe876f
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <unordered_map>
#include <memory>
#include <string>
#include <piga/daemon/sdk/App.hpp>
namespace piga
{
namespace daemon
{
namespace sdk
{
class AppManager
{
public:
typedef std::shared_ptr<App> AppPtr;
typedef std::unordered_map<std::string, AppPtr> AppMap;
virtual AppPtr operator[](const std::string &name) = 0;
virtual AppPtr getApp(const std::string &name) = 0;
};
}
}
}
| 15.62963
| 59
| 0.696682
|
Pigaco
|
8a529df2caf2691ea9692c833b11885976700c0d
| 659
|
cpp
|
C++
|
Clases Virtuales.cpp
|
monicastle/C_PDC_06
|
e5447d853ae2702341a33cec1448ac500a356540
|
[
"MIT"
] | null | null | null |
Clases Virtuales.cpp
|
monicastle/C_PDC_06
|
e5447d853ae2702341a33cec1448ac500a356540
|
[
"MIT"
] | null | null | null |
Clases Virtuales.cpp
|
monicastle/C_PDC_06
|
e5447d853ae2702341a33cec1448ac500a356540
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
class B{
public:
void fun1(){
cout << "base-2\n";
}
virtual void fun2() {
cout << "base-2\n";
}
virtual void fun3() {
cout << "base-3\n";
}
virtual void fun4() {
cout << "base-4\n";
}
};
class D: public B{
public:
void fun1() {
cout << "delivered-1\n";
}
void fun2() {
cout << "delivered-2\n";
}
void fun4(int x) {
cout << "delivered-4\n";
}
};
int main(){
B* p;
D obj1;
p = &obj1;
p->fun1();
p->fun2();
p->fun3();
p->fun4();
p->fun4();
obj1.fun4(5);
}
| 16.475
| 33
| 0.427921
|
monicastle
|
a43a82d7fb087d35421c8b56b8b3d1f3cff6ccbb
| 3,229
|
hpp
|
C++
|
Tests/kext/FromEvent/ParamsUnion.hpp
|
gkb/Karabiner
|
f47307d4fc89a4c421d10157d059293c508f721a
|
[
"Unlicense"
] | 3,405
|
2015-01-01T04:57:52.000Z
|
2022-03-24T06:05:30.000Z
|
Tests/kext/FromEvent/ParamsUnion.hpp
|
Hasimir/Karabiner
|
6181ef9c9a6aeecd4162720884fbbaa2596ee03a
|
[
"Unlicense"
] | 606
|
2015-01-04T03:21:16.000Z
|
2020-10-09T23:55:10.000Z
|
Tests/kext/FromEvent/ParamsUnion.hpp
|
Hasimir/Karabiner
|
6181ef9c9a6aeecd4162720884fbbaa2596ee03a
|
[
"Unlicense"
] | 335
|
2015-01-06T16:43:16.000Z
|
2022-02-13T11:12:52.000Z
|
#ifndef PARAMSUNION_HPP
#define PARAMSUNION_HPP
#include "CallBackWrapper.hpp"
namespace org_pqrs_KeyRemap4MacBook {
class ParamsUnion {
public:
explicit ParamsUnion(const Params_KeyboardEventCallBack& p);
explicit ParamsUnion(const Params_UpdateEventFlagsCallback& p);
explicit ParamsUnion(const Params_KeyboardSpecialEventCallback& p);
explicit ParamsUnion(const Params_RelativePointerEventCallback& p);
explicit ParamsUnion(const Params_ScrollWheelEventCallback& p);
explicit ParamsUnion(const Params_Wait& p);
~ParamsUnion(void);
enum Type {
KEYBOARD,
UPDATE_FLAGS,
KEYBOARD_SPECIAL,
RELATIVE_POINTER,
SCROLL_WHEEL,
WAIT,
};
const Type type;
Params_KeyboardEventCallBack* get_Params_KeyboardEventCallBack(void) const {
if (type != KEYBOARD) return NULL;
return params_.params_KeyboardEventCallBack;
}
Params_UpdateEventFlagsCallback* get_Params_UpdateEventFlagsCallback(void) const {
if (type != UPDATE_FLAGS) return NULL;
return params_.params_UpdateEventFlagsCallback;
}
Params_KeyboardSpecialEventCallback* get_Params_KeyboardSpecialEventCallback(void) const {
if (type != KEYBOARD_SPECIAL) return NULL;
return params_.params_KeyboardSpecialEventCallback;
}
Params_RelativePointerEventCallback* get_Params_RelativePointerEventCallback(void) const {
if (type != RELATIVE_POINTER) return NULL;
return params_.params_RelativePointerEventCallback;
}
Params_ScrollWheelEventCallback* get_Params_ScrollWheelEventCallback(void) const {
if (type != SCROLL_WHEEL) return NULL;
return params_.params_ScrollWheelEventCallback;
}
Params_Wait* get_Params_Wait(void) const {
if (type != WAIT) return NULL;
return params_.params_Wait;
}
bool iskeydown(bool& output) const {
output = false;
switch (type) {
case KEYBOARD: {
Params_KeyboardEventCallBack* p = get_Params_KeyboardEventCallBack();
if (p) {
output = p->ex_iskeydown;
return true;
}
break;
}
case KEYBOARD_SPECIAL: {
Params_KeyboardSpecialEventCallback* p = get_Params_KeyboardSpecialEventCallback();
if (p) {
output = p->ex_iskeydown;
return true;
}
break;
}
case RELATIVE_POINTER: {
Params_RelativePointerEventCallback* p = get_Params_RelativePointerEventCallback();
if (p) {
output = p->ex_isbuttondown;
return true;
}
break;
}
case UPDATE_FLAGS:
case SCROLL_WHEEL:
case WAIT:
break;
}
return false;
}
private:
union {
Params_KeyboardEventCallBack* params_KeyboardEventCallBack;
Params_UpdateEventFlagsCallback* params_UpdateEventFlagsCallback;
Params_KeyboardSpecialEventCallback* params_KeyboardSpecialEventCallback;
Params_RelativePointerEventCallback* params_RelativePointerEventCallback;
Params_ScrollWheelEventCallback* params_ScrollWheelEventCallback;
Params_Wait* params_Wait;
} params_;
};
}
#endif
| 30.752381
| 94
| 0.690307
|
gkb
|
a43c69b1e413f9bd56c76b3af84396d0c9fb1618
| 10,720
|
cpp
|
C++
|
common/src/utils/IntCodeMachine.cpp
|
bielskij/AOC-2019
|
e98d660412037b3fdac4a6b49adcb9230f518c99
|
[
"MIT"
] | null | null | null |
common/src/utils/IntCodeMachine.cpp
|
bielskij/AOC-2019
|
e98d660412037b3fdac4a6b49adcb9230f518c99
|
[
"MIT"
] | null | null | null |
common/src/utils/IntCodeMachine.cpp
|
bielskij/AOC-2019
|
e98d660412037b3fdac4a6b49adcb9230f518c99
|
[
"MIT"
] | null | null | null |
#include <stdexcept>
#include <utils/IntCodeMachine.h>
#include <utils/utils.h>
#define DEBUG_LEVEL 5
#include "common/debug.h"
IntCodeMachine::IntCodeMachine(const std::vector<int64_t> &program) : memory(program), program(program) {
this->pc = 0;
this->eop = false;
this->relativeBase = 0;
this->memory.resize(64 * 1024);
}
IntCodeMachine::~IntCodeMachine() {
}
bool IntCodeMachine::onOut(int64_t value) {
WRN(("%s(): Default implementation!", __func__));
return false;
}
bool IntCodeMachine::onIn(int64_t &value) {
WRN(("%s(): Default implementation!", __func__));
return false;
}
void IntCodeMachine::onMemoryWrite(int64_t address, int64_t currentValue, int64_t newValue) {
WRN(("%s(): Default implementation!", __func__));
}
void IntCodeMachine::onMemoryRead(int64_t address, int64_t currentValue) {
WRN(("%s(): Default implementation!", __func__));
}
#define _I(x) ((int)x)
#define _IP PRId64
std::string IntCodeMachine::_addrToAsm(const std::vector<int64_t> &program, int argMode, int64_t arg, bool readPositionParameters) {
std::string ret;
if (argMode == ADDRESS_IMMEDIATE) {
ret = utils::toString(arg);
} else {
if (readPositionParameters) {
ret = "mem[" + utils::toString(program[arg]);
} else {
ret = "mem[mem[" + utils::toString(arg);
}
if (argMode == ADDRESS_RELATIVE) {
ret += " + _rel";
}
if (! readPositionParameters) {
ret += "]";
}
ret += "]";
}
return ret;
}
std::string IntCodeMachine::_opcodeToAsm(const std::vector<int64_t> &program, int pc, int code, int arg1Mode, int64_t arg1, int arg2Mode, int64_t arg2, int arg3Mode, int64_t arg3, int &codeSize, bool rpp) {
std::string _asm = utils::toString(pc);
switch (code) {
case 1:
case 2:
{
if (code == 1) {
_asm += " add ";
} else {
_asm += " mul ";
}
_asm += _addrToAsm(program, arg3Mode, arg3, rpp) + " := " + _addrToAsm(program, arg1Mode, arg1, rpp) + ", " + _addrToAsm(program, arg2Mode, arg2, rpp);
codeSize = 4;
}
break;
case 3:
{
_asm += " in " + _addrToAsm(program, arg1Mode, arg1, rpp);
codeSize = 2;
}
break;
case 4:
{
_asm += " out " + _addrToAsm(program, arg1Mode, arg1, rpp);
codeSize = 2;
}
break;
case 5:
{
_asm += " jmp_gtz " + _addrToAsm(program, arg1Mode, arg1, rpp) + ", " + _addrToAsm(program, arg2Mode, arg2, rpp);
codeSize = 3;
}
break;
case 6:
{
_asm += " jmp_eqz " + _addrToAsm(program, arg1Mode, arg1, rpp) + ", " + _addrToAsm(program, arg2Mode, arg2, rpp);
codeSize = 3;
}
break;
case 7:
{
_asm += " cmp_lt " + _addrToAsm(program, arg3Mode, arg3, rpp) + " := " + _addrToAsm(program, arg1Mode, arg1, rpp) + ", " + _addrToAsm(program, arg2Mode, arg2, rpp);
codeSize = 4;
}
break;
case 8:
{
_asm += " cmp_eq " + _addrToAsm(program, arg3Mode, arg3, rpp) + " := " + _addrToAsm(program, arg1Mode, arg1, rpp) + ", " + _addrToAsm(program, arg2Mode, arg2, rpp);
codeSize = 4;
}
break;
case 9:
{
_asm += " rel " + _addrToAsm(program, arg1Mode, arg1, rpp);
codeSize = 2;
}
break;
case 99:
{
_asm += " halt";
codeSize = 1;
}
break;
}
return _asm;
}
void IntCodeMachine::_memWrite(int64_t address, int64_t value) {
if (! this->watchedAddresses.empty()) {
int64_t currentValue = this->memory[address];
if (this->watchedAddresses.find(address) != this->watchedAddresses.end()) {
this->onMemoryWrite(address, currentValue, value);
}
}
this->memory[address] = value;
}
int64_t IntCodeMachine::_memRead(int64_t address) {
int64_t val = this->memory[address];
if (! this->watchedAddresses.empty()) {
if (this->watchedAddresses.find(address) != this->watchedAddresses.end()) {
this->onMemoryRead(address, val);
}
}
return val;
}
bool IntCodeMachine::handleOpcode(int code, int64_t arg1, int64_t arg2, int64_t arg3) {
switch (code) {
case 1:
case 2:
{
int64_t noun = _memRead(arg1);
int64_t verb = _memRead(arg2);
int64_t result;
if (code == 1) {
result = noun + verb;
} else {
result = noun * verb;
}
DBG(("[%" _IP "] %s m[%" _IP "] (%" _IP ") = m[%" _IP "] (%" _IP ") + m[%" _IP "] (%" _IP ")", this->pc, code == 1 ? "ADD" : "MUL", arg3, result, arg1, noun, arg2, verb));
_memWrite(arg3, result);
this->pc += 4;
}
break;
case 3:
{
int64_t inVal;
if (! this->onIn(inVal)) {
return false;
} else {
_memWrite(arg1, inVal);
DBG(("[%" _IP "] IN m[%" _IP "] = %" _IP, this->pc, arg1, inVal));
pc += 2;
}
}
break;
case 4:
{
int64_t val = _memRead(arg1);
if (! this->onOut(val)) {
return false;
} else {
DBG(("[%" _IP "] OUT m[%" _IP "] = %" _IP, this->pc, arg1, val));
pc += 2;
}
}
break;
case 5:
{
int64_t arg1Val = _memRead(arg1);
int64_t arg2Val = _memRead(arg2);
DBG(("[%" _IP "] m[%" _IP "] (%" _IP ") JMP_GT 0 PC <- m[%" _IP "] (%" _IP ")", this->pc, arg1, arg1Val, arg2, arg2Val));
if (arg1Val > 0) {
pc = arg2Val;
} else {
pc += 3;
}
}
break;
case 6:
{
int64_t arg1Val = _memRead(arg1);
int64_t arg2Val = _memRead(arg2);
DBG(("[%" _IP "] m[%" _IP "] (%" _IP ") JMP_EQ 0 PC <- m[%" _IP "] (%" _IP ")", this->pc, arg1, arg1Val, arg2, arg2Val));
if (arg1Val == 0) {
pc = arg2Val;
} else {
pc += 3;
}
}
break;
case 7:
{
int64_t arg1Val = _memRead(arg1);
int64_t arg2Val = _memRead(arg2);
int64_t outVal = (arg1Val < arg2Val) ? 1 : 0;
DBG(("[%" _IP "] m[%" _IP "] (%" _IP ") LT m[%" _IP "] (%" _IP ") m[%" _IP "] = %" _IP,
this->pc, arg1, arg1Val, arg2, arg2Val, arg3, outVal
));
_memWrite(arg3, outVal);
pc += 4;
}
break;
case 8:
{
int64_t arg1Val = _memRead(arg1);
int64_t arg2Val = _memRead(arg2);
int64_t outVal = (arg1Val == arg2Val) ? 1 : 0;
DBG(("[%" _IP "] m[%" _IP "] (%" _IP ") EQ m[%" _IP "] (%" _IP ") m[%" _IP "] = %" _IP,
this->pc, arg1, arg1Val, arg2, arg2Val, arg3, outVal
));
_memWrite(arg3, outVal);
pc += 4;
}
break;
case 9:
{
this->relativeBase += _memRead(arg1);
this->pc += 2;
}
break;
default:
ERR(("Not supported code: %d", code));
throw std::runtime_error("Not supported opcode!");
}
return true;
}
bool IntCodeMachine::step() {
if (this->finished()) {
return false;
}
int64_t num = this->memory.at(this->pc);
switch (num) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
if (! this->handleOpcode(num, memory[this->pc + 1], memory[this->pc + 2], memory[this->pc + 3])) {
return false;
}
break;
case 99:
this->eop = true;
break;
default:
{
if (num > 100) {
int64_t opcode = num % 100;
int64_t arg1 = this->pc + 1;
int64_t arg2 = this->pc + 2;
int64_t arg3 = this->pc + 3;
switch ((num / 100) % 10) {
case 0: arg1 = memory[arg1]; break;
case 1: break;
case 2: arg1 = memory[arg1] + this->relativeBase; break;
}
switch ((num / 1000) % 10) {
case 0: arg2 = memory[arg2]; break;
case 1: break;
case 2: arg2 = memory[arg2] + this->relativeBase; break;
}
switch ((num / 10000) % 10) {
case 0: arg3 = memory[arg3]; break;
case 1: break;
case 2: arg3 = memory[arg3] + this->relativeBase; break;
}
if (! this->handleOpcode(opcode, arg1, arg2, arg3)) {
return false;
}
} else {
ERR(("Not supported code: %" PRId64 ", at: %" PRId64, num, this->pc));
throw std::runtime_error("Not supported opcode!");
}
}
break;
}
return true;
}
bool IntCodeMachine::run() {
int64_t num;
if (this->finished()) {
return false;
}
do {
if (! this->step()) {
return false;
}
} while (! this->finished());
return true;
}
void IntCodeMachine::reset() {
this->pc = 0;
this->eop = false;
this->relativeBase = 0;
std::copy(this->program.begin(), this->program.end(), this->memory.begin());
}
bool IntCodeMachine::finished() const {
return this->eop;
}
std::vector<int64_t> &IntCodeMachine::getMemory() {
return this->memory;
}
std::string IntCodeMachine::getAsm(bool readPositionAddresses) {
std::string ret;
for (int i = 0; i < this->program.size(); i++) {
int64_t num = this->program.at(i);
int codeSize;
switch (num) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 99:
ret += _opcodeToAsm(this->program, i, num, ADDRESS_POSITION, i + 1, ADDRESS_POSITION, i + 2, ADDRESS_POSITION, i + 3, codeSize, readPositionAddresses);
break;
default:
{
if (num > 100) {
int64_t opcode = num % 100;
int64_t arg1 = i + 1;
int64_t arg2 = i + 2;
int64_t arg3 = i + 3;
ret += _opcodeToAsm(this->program, i, opcode, (num / 100) % 10, arg1, (num / 1000) % 10, arg2, (num / 10000) % 10, arg3, codeSize, readPositionAddresses);
} else {
codeSize = 0;
}
}
break;
}
if (codeSize > 0) {
ret += "\n";
i += (codeSize - 1);
}
}
return ret;
}
void IntCodeMachine::setPc(int64_t pc) {
this->pc = pc;
}
void IntCodeMachine::addMemoryWatch(int64_t address) {
this->watchedAddresses.insert(address);
}
void IntCodeMachine::save(SaveSlot &slot) {
slot.memory = this->memory;
slot.pc = this->pc;
slot.relativeBase = this->relativeBase;
slot.eop = this->eop;
}
void IntCodeMachine::load(SaveSlot &slot) {
this->memory = slot.memory;
this->pc = slot.pc;
this->relativeBase = slot.relativeBase;
this->eop = slot.eop;
}
void IntCodeMachine::dumpMemory() {
int i;
int lineLength = 32;
int bufferSize = this->memory.size();
int offset = 0;
char asciiBuffer[lineLength + 1];
for (i = 0; i < bufferSize; i++) {
if (i % lineLength == 0) {
if (i != 0) {
printf(" %s\n", asciiBuffer);
}
printf("%04x: ", i + offset);
}
printf(" %02x", (unsigned char) this->memory.at(i));
if (! isprint((char) this->memory.at(i))) {
asciiBuffer[i % lineLength] = '.';
} else {
asciiBuffer[i % lineLength] = this->memory.at(i);
}
asciiBuffer[(i % lineLength) + 1] = '\0';
}
while ((i % 16) != 0) {
printf(" ");
i++;
}
printf(" %s\n", asciiBuffer);
}
| 20.037383
| 206
| 0.553918
|
bielskij
|
a443ffec551c537c2fb926db12254f23c465a34d
| 4,832
|
cpp
|
C++
|
socketio/client/src/rtsp/ffmpeg/mpegaudiodata.cpp
|
eagle3dstreaming/webrtc
|
fef9b3652f7744f722785fc1f4cc6b099f4c7aa7
|
[
"BSD-3-Clause"
] | null | null | null |
socketio/client/src/rtsp/ffmpeg/mpegaudiodata.cpp
|
eagle3dstreaming/webrtc
|
fef9b3652f7744f722785fc1f4cc6b099f4c7aa7
|
[
"BSD-3-Clause"
] | null | null | null |
socketio/client/src/rtsp/ffmpeg/mpegaudiodata.cpp
|
eagle3dstreaming/webrtc
|
fef9b3652f7744f722785fc1f4cc6b099f4c7aa7
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* MPEG Audio common tables
* copyright (c) 2002 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* mpeg audio layer common tables.
*/
#include <cmath>
#include "mpegaudiodata.h"
const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = {
{ {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
{ {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
}
};
const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 };
/*******************************************************/
/* layer 2 tables */
const int ff_mpa_sblimit_table[5] = { 27 , 30 , 8, 12 , 30 };
const int ff_mpa_quant_steps[17] = {
3, 5, 7, 9, 15,
31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383,
32767, 65535
};
/* we use a negative value if grouped */
const int ff_mpa_quant_bits[17] = {
-5, -7, 3, -10, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14,
15, 16
};
/* encoding tables which give the quantization index. Note how it is
possible to store them efficiently ! */
static const unsigned char alloc_table_1[] = {
4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
3, 0, 1, 2, 3, 4, 5, 16,
2, 0, 1, 16,
2, 0, 1, 16,
2, 0, 1, 16,
2, 0, 1, 16,
2, 0, 1, 16,
2, 0, 1, 16,
2, 0, 1, 16,
};
static const unsigned char alloc_table_3[] = {
4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
};
static const unsigned char alloc_table_4[] = {
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
3, 0, 1, 3, 4, 5, 6, 7,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
2, 0, 1, 3,
};
const unsigned char * const ff_mpa_alloc_tables[5] =
{ alloc_table_1, alloc_table_1, alloc_table_3, alloc_table_3, alloc_table_4, };
| 32.42953
| 80
| 0.457161
|
eagle3dstreaming
|
a448dbe327562ef0827330e5e6811a52a3a6e8eb
| 5,568
|
cpp
|
C++
|
src/event_base_tests.cpp
|
Lizb3th/rpt
|
edd5e3055ee2fbad03c92900aa8e9cec6c0d2ee4
|
[
"MIT"
] | null | null | null |
src/event_base_tests.cpp
|
Lizb3th/rpt
|
edd5e3055ee2fbad03c92900aa8e9cec6c0d2ee4
|
[
"MIT"
] | null | null | null |
src/event_base_tests.cpp
|
Lizb3th/rpt
|
edd5e3055ee2fbad03c92900aa8e9cec6c0d2ee4
|
[
"MIT"
] | null | null | null |
// This is a part of the RPT (Realy Poor Tech) Framework.
// Copyright (C) Elizabeth Williams
// All rights reserved.
#include "pch.h"
#include "detail/event_base.hpp"
#include <vector>
#include <future>
#include <optional>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace rpt::event_detail_tests {
using rpt::event_detail::event_base;
using rpt::event_detail::listener_base;
TEST_CLASS(event_base_tests) {
public:
TEST_METHOD(construct);
TEST_METHOD(empty);
TEST_METHOD(add_remove_listener);
TEST_METHOD(repudiate_delay);
TEST_METHOD(clear_delay);
TEST_METHOD(clear_one);
TEST_METHOD(clear_many);
TEST_METHOD(clear_complex);
};
void event_base_tests::construct() {
auto test = event_base<>{};
}
void event_base_tests::empty() {
auto test = event_base<>{};
Assert::IsTrue(test.empty());
}
void event_base_tests::add_remove_listener() {
auto test = event_base<>{};
auto test_litener = listener_base<>{ { [](auto p) {} } };
Assert::IsTrue(test.empty());
test.subscribe(test_litener);
Assert::IsFalse(test.empty());
test.repudiate(test_litener);
Assert::IsTrue(test.empty());
}
struct event_base_test_listener : listener_base<> {
event_base_test_listener()
: listener_base<>({
[](auto& p) {},
[](auto& p) {
static_cast<event_base_test_listener&>(p).attached = false;
return true;
}
})
{}
bool attached{ true };
};
void event_base_tests::clear_one() {
auto test = event_base<>{};
auto test_litener = event_base_test_listener();
test.subscribe(test_litener);
Assert::IsFalse(test.empty());
Assert::IsTrue(test_litener.attached);
test.clear();
//Assert::IsTrue(test.empty());
Assert::IsFalse(test_litener.attached);
}
void event_base_tests::clear_many() {
auto test = event_base<>{};
auto test_liteners = std::vector<event_base_test_listener>(10, event_base_test_listener{} );
for(auto& test_litener : test_liteners)
test.subscribe(test_litener);
Assert::IsFalse(test.empty());
for (auto& test_litener : test_liteners)
Assert::IsTrue(test_litener.attached);
test.clear();
//Assert::IsTrue(test.empty());
for (auto& test_litener : test_liteners)
Assert::IsFalse(test_litener.attached);
}
void event_base_tests::repudiate_delay() {
auto test = event_base<>{};
auto test_litener = event_base_test_listener{};
test.subscribe(test_litener);
auto view = test.view_lock();
Assert::AreEqual(1ull, view.size());
std::thread([view = std::move(view)]() {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}).detach();
auto time = std::chrono::system_clock::now();
test.repudiate(test_litener);
auto delay = std::chrono::system_clock::now() - time;
Assert::IsTrue(delay > std::chrono::milliseconds(1));
}
void event_base_tests::clear_delay() {
auto test = event_base<>{};
auto test_litener = event_base_test_listener{};
test.subscribe(test_litener);
auto view = test.view_lock();
Assert::AreEqual(1ull, view.size());
std::thread([view = std::move(view)]() {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}).detach();
auto time = std::chrono::system_clock::now();
test.repudiate(test_litener);
auto delay = std::chrono::system_clock::now() - time;
Assert::IsTrue(delay > std::chrono::milliseconds(1));
}
void event_base_tests::clear_complex() {
auto thread_count = std::thread::hardware_concurrency();
auto test_liteners = std::vector<event_base_test_listener>(thread_count, event_base_test_listener{});
auto times = std::vector<std::chrono::microseconds>();
//auto threads = std::vector<std::thread>{};
//threads.reserve(10);
auto futures = std::vector<std::future<void>>();
futures.reserve(thread_count);
auto test = event_base<>{};
auto view = std::make_optional(test.view_lock());
try
{
std::mutex mutex;
auto cv_mutex = std::mutex{};
auto cv = std::condition_variable{};
auto counter = std::atomic<int>{ 0 };
for (auto& test_litener : test_liteners) {
//threads.push_back(std::thread(
futures.push_back(std::async(std::launch::async,
[&]() mutable {
counter++;
{
auto lock = std::lock_guard{ cv_mutex };
}
cv.notify_all();
auto time = std::chrono::system_clock::now();
test.subscribe(test_litener);
auto lock = std::lock_guard(mutex);
times.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - time));
//auto view = test.view_lock();
}));
}
{
auto lock = std::lock_guard(mutex);
Assert::IsTrue(times.empty());
}
//std::this_thread::sleep_for(std::chrono::milliseconds{ 40 });
{
auto waiter = std::unique_lock{ cv_mutex };
cv.wait(waiter, [&] { return counter >= static_cast<std::size_t>(thread_count); });
}
while(test.view_lock().size() != thread_count) {
std::this_thread::yield();
}
Assert::AreEqual<std::size_t>(test.view_lock().size(), thread_count);
std::this_thread::sleep_for(std::chrono::milliseconds{ 5 });
view.reset();
//for (auto& thread : threads)
// thread.join();
for (auto& future : futures)
future.wait();
Assert::IsTrue(times.size() == thread_count);
test_liteners.clear();
//auto lock = std::lock_guard(mutex);
//threads.clear();
futures.clear();
}
catch (const std::exception& e)
{
auto what = e.what();
assert(0);
}
for (auto& time : times)
Assert::IsTrue(time > std::chrono::milliseconds{ 5 });
}
}
| 22.361446
| 117
| 0.668822
|
Lizb3th
|
a44bd8fdbd3e5b4ddcb338a00d63eb81b28af541
| 967
|
cpp
|
C++
|
Engine2D/TestCameraScript.cpp
|
FroKCreativeTM/FroKEngine
|
a1e61a0982919efa42bfcbd1e93aacc049966afd
|
[
"BSD-3-Clause"
] | 1
|
2022-01-10T13:00:27.000Z
|
2022-01-10T13:00:27.000Z
|
Engine2D/TestCameraScript.cpp
|
FroKCreativeTM/FroKEngine
|
a1e61a0982919efa42bfcbd1e93aacc049966afd
|
[
"BSD-3-Clause"
] | null | null | null |
Engine2D/TestCameraScript.cpp
|
FroKCreativeTM/FroKEngine
|
a1e61a0982919efa42bfcbd1e93aacc049966afd
|
[
"BSD-3-Clause"
] | null | null | null |
#include "pch.h"
#include "TestCameraScript.h"
#include "Transform.h"
#include "Camera.h"
#include "GameObject.h"
#include "Input.h"
#include "Timer.h"
#include "SceneManager.h"
#include "CollisionManager.h"
TestCameraScript::TestCameraScript()
{
}
TestCameraScript::~TestCameraScript()
{
}
void TestCameraScript::LateUpdate()
{
Vec3 pos = GetTransform()->GetLocalPosition();
if (INPUT->GetButton(KEY_TYPE::W))
pos.y += GetTransform()->GetWorldPosition().y * DELTA_TIME;
if (INPUT->GetButton(KEY_TYPE::S))
pos.y -= GetTransform()->GetWorldPosition().y * DELTA_TIME;
if (INPUT->GetButton(KEY_TYPE::A))
pos.x -= GetTransform()->GetWorldPosition().x * DELTA_TIME;
if (INPUT->GetButton(KEY_TYPE::D))
pos.x += GetTransform()->GetWorldPosition().x * DELTA_TIME;
if (INPUT->GetButtonDown(KEY_TYPE::LBUTTON))
{
const POINT& pos = INPUT->GetMousePos();
GET_SINGLE(CollisionManager)->Pick(pos.x, pos.y);
}
GetTransform()->SetLocalPosition(pos);
}
| 22.488372
| 61
| 0.711479
|
FroKCreativeTM
|
a44be3be92826e920fd75ce827b41170f0f8b49a
| 2,148
|
cpp
|
C++
|
Train/El_Sageer/El_Sageer_Pupil/08 - 14 - [SP]/11 - 12 - [SP] Greedy/12 - [SP] Greedy/onTopic/4.UVa [11157].cpp
|
mohamedGamalAbuGalala/Practice
|
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
|
[
"MIT"
] | 1
|
2019-12-19T06:51:20.000Z
|
2019-12-19T06:51:20.000Z
|
Train/El_Sageer/El_Sageer_Pupil/08 - 14 - [SP]/11 - 12 - [SP] Greedy/12 - [SP] Greedy/onTopic/4.UVa [11157].cpp
|
mohamedGamalAbuGalala/Practice
|
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
|
[
"MIT"
] | null | null | null |
Train/El_Sageer/El_Sageer_Pupil/08 - 14 - [SP]/11 - 12 - [SP] Greedy/12 - [SP] Greedy/onTopic/4.UVa [11157].cpp
|
mohamedGamalAbuGalala/Practice
|
2a5fa3bdaf995d0c304f04231e1a69e6960f72c8
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
// input handle
#define iln() scanf("\n") //scan new line
#define in(n) scanf("%d",&n) //scan int
#define ins(n) scanf("%s",n) //scan char[]
#define inc(n) scanf("%c ",&n) //scan char
#define inf(n) scanf("%lf",&n) //scan double/float
#define inl(n) scanf("%lld",&n) //scan long long int
#define ot(x) printf("%d", x) //output int
#define sp() printf(" ") //output single space
#define ots(x) printf("%s", x) //output char[] ( be careful using it may have some issue )
#define otc(x) printf("%c", x) //output char
#define ln() printf("\n") //output new line
#define otl(x) printf("%lld", x)//output long long int
#define otf(x) printf("%.2lf", x)// output double/float with 0.00
// helpers defines
#define all(v) v.begin(), v.end()
#define sz(v) ((int)((v).size())) // eg... vector<int> v; sz(v)
#define ssz(s) ((int)strlen(s)) // eg... char s[10]; ssz(s)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
//helpers
void file() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
// freopen("ot.txt", "w", stdout);
#else
// freopen("jumping.in", "r", stdin); // HERE
#endif
}
// constants
#define EPS 1e-9
#define PI acos(-1.0) // important constant; alternative #define PI (2.0 * acos(0.0))
const int MN = 1e6 + 1e2;
const int MW = 1e3 + 5;
typedef long long int lli;
const int OO = 1e9 + 5;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef pair<lli, string> lls;
int main() {
file(); // TODO
int n, pp[105], T, l;
bool sm[105], v[105];
char type, sep;
in(T);
for (int t = 1; t <= T; ++t) {
in(n), in(l);
for (int i = 0; i < n and cin >> type >> sep >> pp[i];
sm[i] = (type == 'S'), v[i] = 0, ++i)
;
sm[n] = 0, pp[n] = l, v[n] = 0;
int mx = pp[0];
for (int i = 0; i < n; ++i) {
v[i] = 1;
if (!sm[i + 1])
mx = max(mx, pp[i + 1] - pp[i]);
else
mx = max(mx, pp[i + 2] - pp[i]), ++i;
}
for (int i = n; i > 0; --i)
if (!v[i - 1] or !sm[i - 1])
mx = max(mx, pp[i] - pp[i - 1]);
else
mx = max(mx, pp[i] - pp[i - 2]), --i;
printf("Case %d: %d\n", t, mx);
}
return 0;
}
| 29.027027
| 91
| 0.562849
|
mohamedGamalAbuGalala
|
a45797c83e6a8429b39081fcae5a55821ce06a4d
| 3,325
|
cpp
|
C++
|
test/context.cpp
|
selfienetworks/COSE-C
|
97d1805e71b7a6770093c5e6790d46611680d563
|
[
"BSD-3-Clause"
] | 25
|
2016-07-15T12:11:42.000Z
|
2021-11-19T20:52:46.000Z
|
test/context.cpp
|
selfienetworks/COSE-C
|
97d1805e71b7a6770093c5e6790d46611680d563
|
[
"BSD-3-Clause"
] | 96
|
2015-09-04T05:12:01.000Z
|
2021-12-30T08:39:56.000Z
|
test/context.cpp
|
selfienetworks/COSE-C
|
97d1805e71b7a6770093c5e6790d46611680d563
|
[
"BSD-3-Clause"
] | 21
|
2015-05-27T03:27:21.000Z
|
2021-08-10T15:10:10.000Z
|
#include <stdlib.h>
#ifdef _MSC_VER
#endif
#include <stdio.h>
#include <memory.h>
#include <assert.h>
#include <cn-cbor/cn-cbor.h>
#include <cose/cose.h>
#ifdef USE_CBOR_CONTEXT
#include "context.h"
typedef struct {
cn_cbor_context context;
byte *pFirst;
int iFailLeft;
int allocCount;
} MyContext;
typedef struct _MyItem {
int allocNumber;
struct _MyItem *pNext;
size_t size;
byte pad[4];
byte data[4];
} MyItem;
bool CheckMemory(MyContext *pContext)
{
MyItem *p = nullptr;
// Walk memory and check every block
for (p = (MyItem *)pContext->pFirst; p != nullptr; p = p->pNext) {
if (p->pad[0] == (byte)0xab) {
// Block has been freed
for (unsigned i = 0; i < p->size + 8; i++) {
if (p->pad[i] != (byte)0xab) {
fprintf(stderr, "Freed block is modified");
assert(false);
}
}
}
else if (p->pad[0] == (byte)0xef) {
for (unsigned i = 0; i < 4; i++) {
if ((p->pad[i] != (byte)0xef) ||
(p->pad[i + 4 + p->size] != (byte)0xef)) {
fprintf(stderr, "Current block was overrun");
assert(false);
}
}
}
else {
fprintf(stderr, "Incorrect pad value");
assert(false);
}
}
return true;
}
void *MyCalloc(size_t count, size_t size, void *context)
{
MyItem *pb = nullptr;
MyContext *myContext = (MyContext *)context;
CheckMemory(myContext);
if (myContext->iFailLeft != -1) {
if (myContext->iFailLeft == 0) {
return nullptr;
}
myContext->iFailLeft--;
}
pb = (MyItem *)malloc(sizeof(MyItem) + count * size);
memset(pb, 0xef, sizeof(MyItem) + count * size);
memset(&pb->data, 0, count * size);
pb->pNext = (struct _MyItem *)myContext->pFirst;
myContext->pFirst = (byte *)pb;
pb->size = count * size;
pb->allocNumber = myContext->allocCount++;
return &pb->data;
}
void MyFree(void *ptr, void *context)
{
MyItem *pb = (MyItem *)((byte *)ptr - sizeof(MyItem) + 4);
MyContext *myContext = (MyContext *)context;
MyItem *pItem = nullptr;
CheckMemory(myContext);
if (ptr == nullptr) {
return;
}
for (pItem = (MyItem *)myContext->pFirst; pItem != nullptr;
pItem = pItem->pNext) {
if (pItem == pb) {
break;
}
}
if (pItem == nullptr) {
// Not an item we allocated
assert(false);
return;
}
if (pItem->pad[0] == (byte)0xab) {
// already freed.
assert(false);
}
memset(&pb->pad, 0xab, pb->size + 8);
}
cn_cbor_context *CreateContext(int iFailPoint)
{
MyContext *p = (MyContext *)malloc(sizeof(MyContext));
p->context.calloc_func = MyCalloc;
p->context.free_func = MyFree;
p->context.context = p;
p->pFirst = nullptr;
p->iFailLeft = iFailPoint;
p->allocCount = 0;
return &p->context;
}
void FreeContext(cn_cbor_context *pContext)
{
MyContext *myContext = (MyContext *)pContext;
MyItem *pItem;
MyItem *pItem2;
CheckMemory(myContext);
for (pItem = (MyItem *)myContext->pFirst; pItem != nullptr;
pItem = pItem2) {
pItem2 = pItem->pNext;
free(pItem);
}
free(myContext);
}
int IsContextEmpty(cn_cbor_context *pContext)
{
MyContext *myContext = (MyContext *)pContext;
int i = 0;
// Walk memory and check every block
for (MyItem *p = (MyItem *)myContext->pFirst; p != nullptr; p = p->pNext) {
if (p->pad[0] == (byte)0xab) {
// Block has been freed
}
else {
// This block has not been freed
i += 1;
}
}
return i;
}
#endif // USE_CBOR_CONTEXT
| 19.219653
| 76
| 0.628271
|
selfienetworks
|
a45a5498565e04e84c82759356634ba7a02f1d32
| 3,074
|
cpp
|
C++
|
NostaleLogin/dllmain.cpp
|
hatz02/NostaleLogin
|
3961be0622d4621af7a95a6a8864ca90ab5ba6c8
|
[
"MIT"
] | null | null | null |
NostaleLogin/dllmain.cpp
|
hatz02/NostaleLogin
|
3961be0622d4621af7a95a6a8864ca90ab5ba6c8
|
[
"MIT"
] | null | null | null |
NostaleLogin/dllmain.cpp
|
hatz02/NostaleLogin
|
3961be0622d4621af7a95a6a8864ca90ab5ba6c8
|
[
"MIT"
] | null | null | null |
#include "NewServerSelectWidget.h"
#include <string>
int main()
{
const int BUFFER_SIZE = 2;
const char* pipeName = "\\\\.\\pipe\\GflessClient";
int language, server, channel;
HANDLE hPipe;
DWORD dwMode;
BOOL fSuccess;
std::string message;
char readBuffer[BUFFER_SIZE];
NewServerSelectWidget newServerSelectWidget;
// Set up a pipe to communicate with the Gfless Client
// and receive the values for the language server,
// the server and the channel
hPipe = CreateFileA(pipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hPipe == INVALID_HANDLE_VALUE)
if (!WaitNamedPipeA(pipeName, 20000))
return EXIT_FAILURE;
dwMode = PIPE_READMODE_BYTE | PIPE_WAIT;
fSuccess = SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
// Send the server language message
message = "ServerLanguage";
fSuccess = WriteFile(hPipe, message.c_str(), message.size(), NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
ZeroMemory(readBuffer, BUFFER_SIZE);
fSuccess = ReadFile(hPipe, readBuffer, BUFFER_SIZE, NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
language = readBuffer[0] - 0x30;
// Send the server message
message = "Server";
fSuccess = WriteFile(hPipe, message.c_str(), message.size(), NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
ZeroMemory(readBuffer, BUFFER_SIZE);
fSuccess = ReadFile(hPipe, readBuffer, BUFFER_SIZE, NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
server = readBuffer[0] - 0x30;
// Send the channel message
message = "Channel";
fSuccess = WriteFile(hPipe, message.c_str(), message.size(), NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
ZeroMemory(readBuffer, BUFFER_SIZE);
fSuccess = ReadFile(hPipe, readBuffer, BUFFER_SIZE, NULL, NULL);
if (!fSuccess)
return EXIT_FAILURE;
channel = readBuffer[0] - 0x30;
// Wait for the login widget to be visible
// and log into the desired server and channel
while (!newServerSelectWidget.isVisible())
Sleep(500);
newServerSelectWidget.selectLanguage(language);
Sleep(3000);
while (!newServerSelectWidget.isVisible())
Sleep(500);
newServerSelectWidget.selectServer(server);
Sleep(1000);
newServerSelectWidget.selectChannel(channel);;
return EXIT_SUCCESS;
}
DWORD WINAPI DllStart(LPVOID param)
{
FreeLibraryAndExitThread((HMODULE)param, main());
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
HANDLE hThread;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
hThread = CreateThread(NULL, NULL, DllStart, hModule, NULL, NULL);
if (hThread != NULL) CloseHandle(hThread);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
| 25.831933
| 97
| 0.672414
|
hatz02
|
a4676837163ed602733b36b27d3fd29ba3bf4f1d
| 647
|
cpp
|
C++
|
src/ui/ScrollBar.cpp
|
alikins/Rack
|
614c6d09883569563bc8a7c41513390babf2cabb
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] | null | null | null |
src/ui/ScrollBar.cpp
|
alikins/Rack
|
614c6d09883569563bc8a7c41513390babf2cabb
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] | null | null | null |
src/ui/ScrollBar.cpp
|
alikins/Rack
|
614c6d09883569563bc8a7c41513390babf2cabb
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] | null | null | null |
#include "ui.hpp"
#include "window.hpp"
namespace rack {
void ScrollBar::draw(NVGcontext *vg) {
bndScrollBar(vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size);
}
void ScrollBar::onDragStart(EventDragStart &e) {
state = BND_ACTIVE;
windowCursorLock();
}
void ScrollBar::onDragMove(EventDragMove &e) {
ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent);
assert(scrollWidget);
if (orientation == HORIZONTAL)
scrollWidget->offset.x += e.mouseRel.x;
else
scrollWidget->offset.y += e.mouseRel.y;
}
void ScrollBar::onDragEnd(EventDragEnd &e) {
state = BND_DEFAULT;
windowCursorUnlock();
}
} // namespace rack
| 19.606061
| 73
| 0.718702
|
alikins
|
a46d0c80798e7154762f31345a834ab66e790d40
| 1,935
|
cpp
|
C++
|
test.cpp
|
wisd0me/plog-converter
|
e534fa5873c9036f5193a28be19e1ded9738586a
|
[
"Apache-2.0"
] | null | null | null |
test.cpp
|
wisd0me/plog-converter
|
e534fa5873c9036f5193a28be19e1ded9738586a
|
[
"Apache-2.0"
] | null | null | null |
test.cpp
|
wisd0me/plog-converter
|
e534fa5873c9036f5193a28be19e1ded9738586a
|
[
"Apache-2.0"
] | null | null | null |
// 2006-2008 (c) Viva64.com Team
// 2008-2020 (c) OOO "Program Verification Systems"
// 2020 (c) PVS-Studio LLC
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include "warning.h"
#include "application.h"
using namespace PlogConverter;
TEST_CASE("Warning::GetErrorCode")
{
Warning msg;
msg.code = "V112";
REQUIRE(msg.GetErrorCode() == 112);
msg.code = "V001";
REQUIRE(msg.GetErrorCode() == 1);
}
TEST_CASE("Warning::GetType")
{
Warning msg;
msg.code = "V112";
REQUIRE(msg.GetType() == AnalyzerType::Viva64);
msg.code = "V001";
REQUIRE(msg.GetType() == AnalyzerType::Fail);
}
TEST_CASE("Warning::GetVivaUrl")
{
Warning msg;
msg.code = "V001";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v001/");
msg.code = "V101";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v101/");
msg.code = "V1001";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/w/v1001/");
msg.code = "Renew";
REQUIRE(msg.GetVivaUrl() == "https://www.viva64.com/en/renewal/");
}
TEST_CASE("plog-converter -a")
{
std::vector<Analyzer> analyzers;
ParseEnabledAnalyzers("all", analyzers);
REQUIRE(analyzers.empty());
ParseEnabledAnalyzers("ALL", analyzers);
REQUIRE(analyzers.empty());
ParseEnabledAnalyzers("GA:1,2;64:1;OP:1,2,3;CS:1;MISRA:1,2", analyzers);
REQUIRE(analyzers.size() == 5);
REQUIRE(analyzers[0].type == AnalyzerType::General);
REQUIRE(analyzers[0].levels == (std::vector<int>{1, 2}));
REQUIRE(analyzers[1].type == AnalyzerType::Viva64);
REQUIRE(analyzers[1].levels == (std::vector<int>{1}));
REQUIRE(analyzers[2].type == AnalyzerType::Optimization);
REQUIRE(analyzers[2].levels == (std::vector<int>{1, 2, 3}));
REQUIRE(analyzers[3].type == AnalyzerType::CustomerSpecific);
REQUIRE(analyzers[3].levels == (std::vector<int>{1}));
REQUIRE(analyzers[4].type == AnalyzerType::Misra);
REQUIRE(analyzers[4].levels == (std::vector<int>{1, 2}));
}
| 26.148649
| 74
| 0.668217
|
wisd0me
|
a46d47446e8c45c95d951bd91a24368a7ba08853
| 415
|
cpp
|
C++
|
trabalhos/trab1/paises.cpp
|
senapk/fup_2014_2
|
5fc2986724f2e5fb912524b6208744b7295c6347
|
[
"Apache-2.0"
] | null | null | null |
trabalhos/trab1/paises.cpp
|
senapk/fup_2014_2
|
5fc2986724f2e5fb912524b6208744b7295c6347
|
[
"Apache-2.0"
] | null | null | null |
trabalhos/trab1/paises.cpp
|
senapk/fup_2014_2
|
5fc2986724f2e5fb912524b6208744b7295c6347
|
[
"Apache-2.0"
] | null | null | null |
/*
Faça um código que receba um dos países abaixo e retorne o continente
em que ele se encontra. Use o comando switch.
*/
#include <iostream>
using namespace std;
enum Pais { Brasil, Italia, EUA, Japao, Australia};
enum Continente { AmericaSul, AmericaNorte, Europa, Asia, Australia };
Continente acharLocalizacao( Pais pais){
//faça seu código aqui
}
int main ()
{
//faça seu teste aqui
return 0;
}
| 20.75
| 70
| 0.715663
|
senapk
|
a46fb1e2117cae5873e3a18f93694220ac78f257
| 1,782
|
cpp
|
C++
|
src/ScreenCaptureLib/ScreenCapture.cpp
|
Postrediori/OceanSimulation
|
ff836f9c92f43e62a3e5c2befc065784d3c36ce0
|
[
"MIT"
] | 14
|
2017-12-18T08:22:12.000Z
|
2021-04-12T13:05:42.000Z
|
src/ScreenCaptureLib/ScreenCapture.cpp
|
Postrediori/OceanSimulation
|
ff836f9c92f43e62a3e5c2befc065784d3c36ce0
|
[
"MIT"
] | 4
|
2017-12-20T09:41:15.000Z
|
2020-06-26T10:56:48.000Z
|
src/ScreenCaptureLib/ScreenCapture.cpp
|
Postrediori/OceanSimulation
|
ff836f9c92f43e62a3e5c2befc065784d3c36ce0
|
[
"MIT"
] | 2
|
2018-01-31T13:11:28.000Z
|
2019-05-20T04:04:28.000Z
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
#include "stdafx.h"
#include "ScreenCapture.h"
std::string ScreenCapture::GetNextFileName(ScreenCaptureFormat format) {
static int counter = 0;
std::stringstream s;
s << "capture" << (counter++);
if (format == ScreenCaptureFormat::Png) {
s << ".png";
}
else if (format == ScreenCaptureFormat::Jpg) {
s << ".jpg";
}
return s.str();
}
bool ScreenCapture::SaveToFile(ScreenCaptureFormat format, int width, int height) {
static const size_t ScreenCaptureBpp = 3;
static const GLenum ScreenCaptureFormat = GL_RGB;
std::vector<uint8_t> pixelBuffer(width * height * ScreenCaptureBpp);
glReadPixels(0, 0, width, height, ScreenCaptureFormat, GL_UNSIGNED_BYTE, pixelBuffer.data());
stbi_flip_vertically_on_write(1); // flag is non-zero to flip data vertically
std::string fileName = ScreenCapture::GetNextFileName(format);
static const int ScreenCaptureComp = ScreenCaptureBpp; // 1=Y, 2=YA, 3=RGB, 4=RGBA
int result = 0;
if (format == ScreenCaptureFormat::Png) {
int screenCaptureStride = width * ScreenCaptureBpp;
result = stbi_write_png(fileName.c_str(), width, height, ScreenCaptureComp, pixelBuffer.data(), screenCaptureStride);
}
else if (format == ScreenCaptureFormat::Jpg) {
static const int ScreenCaptureQuality = 90;
result = stbi_write_jpg(fileName.c_str(), width, height, ScreenCaptureComp, pixelBuffer.data(), ScreenCaptureQuality);
}
if (!result) {
LOGE << "Unable to capture screen to file " << fileName;
return false;
}
LOGI << "Saved screen capture to file " << fileName << " (" << width << "x" << height << " pixels)";
return true;
}
| 33.622642
| 126
| 0.673962
|
Postrediori
|
a4707414405f82069bd4a6783a2f0f6b0c55b20a
| 252
|
hpp
|
C++
|
Examples/ViewFactor/ViewFactorProcessData.hpp
|
FilipovicLado/ViennaLS
|
39d97c2fc0d36f250bebaaa6879747eb9a7ed23a
|
[
"MIT"
] | null | null | null |
Examples/ViewFactor/ViewFactorProcessData.hpp
|
FilipovicLado/ViennaLS
|
39d97c2fc0d36f250bebaaa6879747eb9a7ed23a
|
[
"MIT"
] | null | null | null |
Examples/ViewFactor/ViewFactorProcessData.hpp
|
FilipovicLado/ViennaLS
|
39d97c2fc0d36f250bebaaa6879747eb9a7ed23a
|
[
"MIT"
] | null | null | null |
#pragma once
#include <array>
#include <limits>
template <class T> struct ViewFactorProcessDataType {
double gridDelta = 0.;
T trenchDiameter;
T trenchDepth;
T topRate;
T processTime;
T timeStep;
hrleVectorType<double, 2> taperAngle;
};
| 18
| 53
| 0.72619
|
FilipovicLado
|
a475881ea7a61bde038340060a7786eb7384cbd2
| 318
|
cc
|
C++
|
tests/ManufacturerTest.cc
|
martind1111/wifi_pi_survey
|
9a28f47a6096df2f596b9e62bb984a0922712cf8
|
[
"MIT"
] | null | null | null |
tests/ManufacturerTest.cc
|
martind1111/wifi_pi_survey
|
9a28f47a6096df2f596b9e62bb984a0922712cf8
|
[
"MIT"
] | null | null | null |
tests/ManufacturerTest.cc
|
martind1111/wifi_pi_survey
|
9a28f47a6096df2f596b9e62bb984a0922712cf8
|
[
"MIT"
] | null | null | null |
#include <gtest/gtest.h>
#include <netinet/ether.h>
#include "HardwareHelper.h"
// Test the manufacturer API.
TEST(ManufacturerTest, GetManufacturer) {
ether_addr addr = { 0x00, 0x03, 0x93, 0x01, 0x02, 0x03 };
const char* manuf = HardwareHelper::GetManufacturer(&addr);
EXPECT_STREQ(manuf, "Apple");
}
| 22.714286
| 63
| 0.704403
|
martind1111
|
a47f0a07dd3e298d314efa97b9c94980000b7248
| 10,653
|
cpp
|
C++
|
src/physics/bullet/bullet_physics_system.cpp
|
irisengine/iris
|
0deb12f5d00c67bf0dde1a702344a2cf73925db6
|
[
"BSL-1.0"
] | 85
|
2021-10-16T14:58:23.000Z
|
2022-03-26T11:05:37.000Z
|
src/physics/bullet/bullet_physics_system.cpp
|
MaximumProgrammer/iris
|
cbc2f571bd8d485cdd04f903dcb867e699314682
|
[
"BSL-1.0"
] | null | null | null |
src/physics/bullet/bullet_physics_system.cpp
|
MaximumProgrammer/iris
|
cbc2f571bd8d485cdd04f903dcb867e699314682
|
[
"BSL-1.0"
] | 2
|
2021-10-17T16:57:13.000Z
|
2021-11-14T19:11:30.000Z
|
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#include "physics/bullet/bullet_physics_system.h"
#include <chrono>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <vector>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btMotionState.h>
#include <LinearMath/btQuaternion.h>
#include <LinearMath/btTransform.h>
#include <LinearMath/btVector3.h>
#include <btBulletDynamicsCommon.h>
#include "core/error_handling.h"
#include "core/quaternion.h"
#include "core/vector3.h"
#include "graphics/render_entity.h"
#include "log/log.h"
#include "physics/basic_character_controller.h"
#include "physics/bullet/bullet_box_collision_shape.h"
#include "physics/bullet/bullet_capsule_collision_shape.h"
#include "physics/bullet/bullet_collision_shape.h"
#include "physics/bullet/bullet_rigid_body.h"
#include "physics/bullet/debug_draw.h"
#include "physics/character_controller.h"
#include "physics/rigid_body.h"
namespace
{
/**
* Helper function to remove a rigid body from a bullet dynamics world.
*
* @param body
* Body to remove.
*
* @param world
* World to remove from.
*/
void remove_body_from_world(iris::RigidBody *body, btDynamicsWorld *world)
{
auto *bullet_body = static_cast<iris::BulletRigidBody *>(body);
if (body->type() == iris::RigidBodyType::GHOST)
{
auto *bullet_ghost = static_cast<::btGhostObject *>(bullet_body->handle());
world->removeCollisionObject(bullet_ghost);
}
else
{
auto *bullet_rigid = static_cast<::btRigidBody *>(bullet_body->handle());
world->removeRigidBody(bullet_rigid);
}
}
}
namespace iris
{
/**
* Saved information about a rigid body. Used in PhysicsState.
*/
struct RigidBodyState
{
RigidBodyState(const btTransform &transform, const btVector3 &linear_velocity, const btVector3 &angular_velocity)
: transform(transform)
, linear_velocity(linear_velocity)
, angular_velocity(angular_velocity)
{
}
btTransform transform;
btVector3 linear_velocity;
btVector3 angular_velocity;
};
/**
* Struct for saving the state of the physics simulation. It simply stores
* RigidBodyState for all rigid bodies. Note that collision information is
* *not* saved.
*/
struct BulletPhysicsState : public PhysicsState
{
~BulletPhysicsState() override = default;
std::map<btRigidBody *, RigidBodyState> bodies;
};
BulletPhysicsSystem::BulletPhysicsSystem()
: PhysicsSystem()
, broadphase_(nullptr)
, ghost_pair_callback_(nullptr)
, collision_config_(nullptr)
, collision_dispatcher_(nullptr)
, solver_(nullptr)
, world_(nullptr)
, bodies_()
, ignore_()
, character_controllers_()
, debug_draw_(nullptr)
, collision_shapes_()
{
collision_config_ = std::make_unique<::btDefaultCollisionConfiguration>();
collision_dispatcher_ = std::make_unique<::btCollisionDispatcher>(collision_config_.get());
broadphase_ = std::make_unique<::btDbvtBroadphase>();
solver_ = std::make_unique<::btSequentialImpulseConstraintSolver>();
world_ = std::make_unique<::btDiscreteDynamicsWorld>(
collision_dispatcher_.get(), broadphase_.get(), solver_.get(), collision_config_.get());
ghost_pair_callback_ = std::make_unique<::btGhostPairCallback>();
broadphase_->getOverlappingPairCache()->setInternalGhostPairCallback(ghost_pair_callback_.get());
world_->setGravity({0.0f, -10.0f, 0.0f});
debug_draw_ = nullptr;
}
BulletPhysicsSystem::~BulletPhysicsSystem()
{
try
{
for (const auto &body : bodies_)
{
remove_body_from_world(body.get(), world_.get());
}
for (const auto &controller : character_controllers_)
{
remove_body_from_world(controller->rigid_body(), world_.get());
}
}
catch (...)
{
LOG_ERROR("physics_system", "exception caught during dtor");
}
}
void BulletPhysicsSystem::step(std::chrono::milliseconds time_step)
{
const auto ticks = static_cast<float>(time_step.count());
world_->stepSimulation(ticks / 1000.0f, 1);
if (debug_draw_)
{
// tell bullet to draw debug world
world_->debugDrawWorld();
// now we pass bullet debug information to our render system
debug_draw_->render();
}
}
RigidBody *BulletPhysicsSystem::create_rigid_body(
const Vector3 &position,
CollisionShape *collision_shape,
RigidBodyType type)
{
bodies_.emplace_back(
std::make_unique<BulletRigidBody>(position, static_cast<BulletCollisionShape *>(collision_shape), type));
auto *body = static_cast<BulletRigidBody *>(bodies_.back().get());
if (body->type() == RigidBodyType::GHOST)
{
auto *bullet_ghost = static_cast<btGhostObject *>(body->handle());
world_->addCollisionObject(bullet_ghost);
}
else
{
auto *bullet_rigid = static_cast<btRigidBody *>(body->handle());
world_->addRigidBody(bullet_rigid);
}
return body;
}
CharacterController *BulletPhysicsSystem::create_character_controller()
{
character_controllers_.emplace_back(std::make_unique<BasicCharacterController>(this));
return character_controllers_.back().get();
}
CollisionShape *BulletPhysicsSystem::create_box_collision_shape(const Vector3 &half_size)
{
collision_shapes_.emplace_back(std::make_unique<BulletBoxCollisionShape>(half_size));
return collision_shapes_.back().get();
}
CollisionShape *BulletPhysicsSystem::create_capsule_collision_shape(float width, float height)
{
collision_shapes_.emplace_back(std::make_unique<BulletCapsuleCollisionShape>(width, height));
return collision_shapes_.back().get();
}
void BulletPhysicsSystem::remove(RigidBody *body)
{
remove_body_from_world(body, world_.get());
bodies_.erase(
std::remove_if(
std::begin(bodies_), std::end(bodies_), [body](const auto &element) { return element.get() == body; }),
std::end(bodies_));
}
void BulletPhysicsSystem::remove(CharacterController *character)
{
remove_body_from_world(character->rigid_body(), world_.get());
character_controllers_.erase(
std::remove_if(
std::begin(character_controllers_),
std::end(character_controllers_),
[character](const auto &element) { return element.get() == character; }),
std::end(character_controllers_));
}
std::optional<std::tuple<RigidBody *, Vector3>> BulletPhysicsSystem::ray_cast(
const Vector3 &origin,
const Vector3 &direction) const
{
std::optional<std::tuple<RigidBody *, Vector3>> hit;
// bullet does ray tracing between two vectors, so we create an end vector
// some great distance away
btVector3 from{origin.x, origin.y, origin.z};
const auto far_away = origin + (direction * 10000.0f);
btVector3 to{far_away.x, far_away.y, far_away.z};
btCollisionWorld::AllHitsRayResultCallback callback{from, to};
world_->rayTest(from, to, callback);
if (callback.hasHit())
{
auto min = std::numeric_limits<float>::max();
btVector3 hit_position{};
const btRigidBody *body = nullptr;
// find the closest hit object excluding any ignored objects
for (auto i = 0; i < callback.m_collisionObjects.size(); ++i)
{
const auto distance = from.distance(callback.m_hitPointWorld[i]);
if ((distance < min) && (ignore_.count(callback.m_collisionObjects[i]) == 0))
{
min = distance;
hit_position = callback.m_hitPointWorld[i];
body = static_cast<const btRigidBody *>(callback.m_collisionObjects[i]);
}
}
if (body != nullptr)
{
hit = {
static_cast<RigidBody *>(body->getUserPointer()),
{hit_position.x(), hit_position.y(), hit_position.z()}};
}
}
return hit;
}
void BulletPhysicsSystem::ignore_in_raycast(RigidBody *body)
{
auto *bullet_body = static_cast<iris::BulletRigidBody *>(body);
ignore_.emplace(bullet_body->handle());
}
std::unique_ptr<PhysicsState> BulletPhysicsSystem::save()
{
auto state = std::make_unique<BulletPhysicsState>();
// save data for all rigid bodies
for (const auto &body : bodies_)
{
auto *bullet_body = static_cast<iris::BulletRigidBody *>(body.get());
auto *bullet_rigid = static_cast<btRigidBody *>(bullet_body->handle());
state->bodies.try_emplace(
bullet_rigid,
bullet_rigid->getWorldTransform(),
bullet_rigid->getLinearVelocity(),
bullet_rigid->getAngularVelocity());
}
// save data for all character controllers
for (const auto &character : character_controllers_)
{
auto *bullet_body = static_cast<iris::BulletRigidBody *>(character->rigid_body());
auto *bullet_rigid = static_cast<btRigidBody *>(bullet_body->handle());
state->bodies.try_emplace(
bullet_rigid,
bullet_rigid->getWorldTransform(),
bullet_rigid->getLinearVelocity(),
bullet_rigid->getAngularVelocity());
}
return state;
}
void BulletPhysicsSystem::load(const PhysicsState *state)
{
const auto *bullet_state = static_cast<const BulletPhysicsState *>(state);
// restore state for each rigid body
for (const auto &[bullet_body, body_state] : bullet_state->bodies)
{
bullet_body->clearForces();
bullet_body->setWorldTransform(body_state.transform);
bullet_body->setCenterOfMassTransform(body_state.transform);
bullet_body->setLinearVelocity(body_state.linear_velocity);
bullet_body->setAngularVelocity(body_state.angular_velocity);
}
}
void BulletPhysicsSystem::enable_debug_draw(RenderEntity *entity)
{
expect(!debug_draw_, "debug draw already enabled");
// create debug drawer, only draw wireframe as that's what we support
debug_draw_ = std::make_unique<DebugDraw>(entity);
debug_draw_->setDebugMode(
btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits);
world_->setDebugDrawer(debug_draw_.get());
}
}
| 31.705357
| 118
| 0.673989
|
irisengine
|
a48173204e89a9dc161c13550ce8b842efe3ae8c
| 2,821
|
hpp
|
C++
|
android-31/java/io/PrintStream.hpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/java/io/PrintStream.hpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-29/java/io/PrintStream.hpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#pragma once
#include "./FilterOutputStream.hpp"
class JByteArray;
class JCharArray;
class JObjectArray;
namespace java::io
{
class BufferedWriter;
}
namespace java::io
{
class File;
}
namespace java::io
{
class OutputStream;
}
namespace java::io
{
class OutputStreamWriter;
}
class JString;
class JObject;
class JString;
namespace java::nio::charset
{
class Charset;
}
namespace java::util
{
class Formatter;
}
namespace java::util
{
class Locale;
}
namespace java::io
{
class PrintStream : public java::io::FilterOutputStream
{
public:
// Fields
// QJniObject forward
template<typename ...Ts> explicit PrintStream(const char *className, const char *sig, Ts...agv) : java::io::FilterOutputStream(className, sig, std::forward<Ts>(agv)...) {}
PrintStream(QJniObject obj);
// Constructors
PrintStream(java::io::File arg0);
PrintStream(java::io::OutputStream arg0);
PrintStream(JString arg0);
PrintStream(java::io::File arg0, JString arg1);
PrintStream(java::io::File arg0, java::nio::charset::Charset arg1);
PrintStream(java::io::OutputStream arg0, jboolean arg1);
PrintStream(JString arg0, JString arg1);
PrintStream(JString arg0, java::nio::charset::Charset arg1);
PrintStream(java::io::OutputStream arg0, jboolean arg1, JString arg2);
PrintStream(java::io::OutputStream arg0, jboolean arg1, java::nio::charset::Charset arg2);
// Methods
java::io::PrintStream append(jchar arg0) const;
java::io::PrintStream append(JString arg0) const;
java::io::PrintStream append(JString arg0, jint arg1, jint arg2) const;
jboolean checkError() const;
void close() const;
void flush() const;
java::io::PrintStream format(JString arg0, JObjectArray arg1) const;
java::io::PrintStream format(java::util::Locale arg0, JString arg1, JObjectArray arg2) const;
void print(JCharArray arg0) const;
void print(jboolean arg0) const;
void print(jchar arg0) const;
void print(jdouble arg0) const;
void print(jfloat arg0) const;
void print(jint arg0) const;
void print(JObject arg0) const;
void print(JString arg0) const;
void print(jlong arg0) const;
java::io::PrintStream printf(JString arg0, JObjectArray arg1) const;
java::io::PrintStream printf(java::util::Locale arg0, JString arg1, JObjectArray arg2) const;
void println() const;
void println(JCharArray arg0) const;
void println(jboolean arg0) const;
void println(jchar arg0) const;
void println(jdouble arg0) const;
void println(jfloat arg0) const;
void println(jint arg0) const;
void println(JObject arg0) const;
void println(JString arg0) const;
void println(jlong arg0) const;
void write(JByteArray arg0) const;
void write(jint arg0) const;
void write(JByteArray arg0, jint arg1, jint arg2) const;
void writeBytes(JByteArray arg0) const;
};
} // namespace java::io
| 28.21
| 173
| 0.734491
|
YJBeetle
|
a482833e6c7c6f5ca5abb6619aef6deb3578a372
| 7,794
|
cpp
|
C++
|
tsf/src/v20180326/model/MonitorOverview.cpp
|
sinjoywong/tencentcloud-sdk-cpp
|
1b931d20956a90b15a6720f924e5c69f8786f9f4
|
[
"Apache-2.0"
] | null | null | null |
tsf/src/v20180326/model/MonitorOverview.cpp
|
sinjoywong/tencentcloud-sdk-cpp
|
1b931d20956a90b15a6720f924e5c69f8786f9f4
|
[
"Apache-2.0"
] | null | null | null |
tsf/src/v20180326/model/MonitorOverview.cpp
|
sinjoywong/tencentcloud-sdk-cpp
|
1b931d20956a90b15a6720f924e5c69f8786f9f4
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/tsf/v20180326/model/MonitorOverview.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Tsf::V20180326::Model;
using namespace std;
MonitorOverview::MonitorOverview() :
m_invocationCountOfDayHasBeenSet(false),
m_invocationCountHasBeenSet(false),
m_errorCountOfDayHasBeenSet(false),
m_errorCountHasBeenSet(false),
m_successRatioOfDayHasBeenSet(false),
m_successRatioHasBeenSet(false)
{
}
CoreInternalOutcome MonitorOverview::Deserialize(const rapidjson::Value &value)
{
string requestId = "";
if (value.HasMember("InvocationCountOfDay") && !value["InvocationCountOfDay"].IsNull())
{
if (!value["InvocationCountOfDay"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.InvocationCountOfDay` IsString=false incorrectly").SetRequestId(requestId));
}
m_invocationCountOfDay = string(value["InvocationCountOfDay"].GetString());
m_invocationCountOfDayHasBeenSet = true;
}
if (value.HasMember("InvocationCount") && !value["InvocationCount"].IsNull())
{
if (!value["InvocationCount"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.InvocationCount` IsString=false incorrectly").SetRequestId(requestId));
}
m_invocationCount = string(value["InvocationCount"].GetString());
m_invocationCountHasBeenSet = true;
}
if (value.HasMember("ErrorCountOfDay") && !value["ErrorCountOfDay"].IsNull())
{
if (!value["ErrorCountOfDay"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.ErrorCountOfDay` IsString=false incorrectly").SetRequestId(requestId));
}
m_errorCountOfDay = string(value["ErrorCountOfDay"].GetString());
m_errorCountOfDayHasBeenSet = true;
}
if (value.HasMember("ErrorCount") && !value["ErrorCount"].IsNull())
{
if (!value["ErrorCount"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.ErrorCount` IsString=false incorrectly").SetRequestId(requestId));
}
m_errorCount = string(value["ErrorCount"].GetString());
m_errorCountHasBeenSet = true;
}
if (value.HasMember("SuccessRatioOfDay") && !value["SuccessRatioOfDay"].IsNull())
{
if (!value["SuccessRatioOfDay"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.SuccessRatioOfDay` IsString=false incorrectly").SetRequestId(requestId));
}
m_successRatioOfDay = string(value["SuccessRatioOfDay"].GetString());
m_successRatioOfDayHasBeenSet = true;
}
if (value.HasMember("SuccessRatio") && !value["SuccessRatio"].IsNull())
{
if (!value["SuccessRatio"].IsString())
{
return CoreInternalOutcome(Error("response `MonitorOverview.SuccessRatio` IsString=false incorrectly").SetRequestId(requestId));
}
m_successRatio = string(value["SuccessRatio"].GetString());
m_successRatioHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
void MonitorOverview::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const
{
if (m_invocationCountOfDayHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "InvocationCountOfDay";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_invocationCountOfDay.c_str(), allocator).Move(), allocator);
}
if (m_invocationCountHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "InvocationCount";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_invocationCount.c_str(), allocator).Move(), allocator);
}
if (m_errorCountOfDayHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "ErrorCountOfDay";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_errorCountOfDay.c_str(), allocator).Move(), allocator);
}
if (m_errorCountHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "ErrorCount";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_errorCount.c_str(), allocator).Move(), allocator);
}
if (m_successRatioOfDayHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "SuccessRatioOfDay";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_successRatioOfDay.c_str(), allocator).Move(), allocator);
}
if (m_successRatioHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "SuccessRatio";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_successRatio.c_str(), allocator).Move(), allocator);
}
}
string MonitorOverview::GetInvocationCountOfDay() const
{
return m_invocationCountOfDay;
}
void MonitorOverview::SetInvocationCountOfDay(const string& _invocationCountOfDay)
{
m_invocationCountOfDay = _invocationCountOfDay;
m_invocationCountOfDayHasBeenSet = true;
}
bool MonitorOverview::InvocationCountOfDayHasBeenSet() const
{
return m_invocationCountOfDayHasBeenSet;
}
string MonitorOverview::GetInvocationCount() const
{
return m_invocationCount;
}
void MonitorOverview::SetInvocationCount(const string& _invocationCount)
{
m_invocationCount = _invocationCount;
m_invocationCountHasBeenSet = true;
}
bool MonitorOverview::InvocationCountHasBeenSet() const
{
return m_invocationCountHasBeenSet;
}
string MonitorOverview::GetErrorCountOfDay() const
{
return m_errorCountOfDay;
}
void MonitorOverview::SetErrorCountOfDay(const string& _errorCountOfDay)
{
m_errorCountOfDay = _errorCountOfDay;
m_errorCountOfDayHasBeenSet = true;
}
bool MonitorOverview::ErrorCountOfDayHasBeenSet() const
{
return m_errorCountOfDayHasBeenSet;
}
string MonitorOverview::GetErrorCount() const
{
return m_errorCount;
}
void MonitorOverview::SetErrorCount(const string& _errorCount)
{
m_errorCount = _errorCount;
m_errorCountHasBeenSet = true;
}
bool MonitorOverview::ErrorCountHasBeenSet() const
{
return m_errorCountHasBeenSet;
}
string MonitorOverview::GetSuccessRatioOfDay() const
{
return m_successRatioOfDay;
}
void MonitorOverview::SetSuccessRatioOfDay(const string& _successRatioOfDay)
{
m_successRatioOfDay = _successRatioOfDay;
m_successRatioOfDayHasBeenSet = true;
}
bool MonitorOverview::SuccessRatioOfDayHasBeenSet() const
{
return m_successRatioOfDayHasBeenSet;
}
string MonitorOverview::GetSuccessRatio() const
{
return m_successRatio;
}
void MonitorOverview::SetSuccessRatio(const string& _successRatio)
{
m_successRatio = _successRatio;
m_successRatioHasBeenSet = true;
}
bool MonitorOverview::SuccessRatioHasBeenSet() const
{
return m_successRatioHasBeenSet;
}
| 30.928571
| 148
| 0.715679
|
sinjoywong
|
a4830eed7cacc0372727720736166d2bb897188c
| 13,846
|
cpp
|
C++
|
PlatformIO/esp32-r4ge-pro-prong/src/main.cpp
|
DigiTorus86/ESP32-R4ge-Pro
|
786127b87491dcdd2bbc928b1a68968a97038aac
|
[
"MIT"
] | 1
|
2021-01-08T23:09:58.000Z
|
2021-01-08T23:09:58.000Z
|
PlatformIO/esp32-r4ge-pro-prong/src/main.cpp
|
DigiTorus86/ESP32-R4ge-Pro
|
786127b87491dcdd2bbc928b1a68968a97038aac
|
[
"MIT"
] | null | null | null |
PlatformIO/esp32-r4ge-pro-prong/src/main.cpp
|
DigiTorus86/ESP32-R4ge-Pro
|
786127b87491dcdd2bbc928b1a68968a97038aac
|
[
"MIT"
] | 2
|
2021-06-28T06:27:04.000Z
|
2022-01-11T12:57:55.000Z
|
/***************************************************
ESP32 R4ge Prong
Requires:
- ESP32 R4ge Pro
Copyright (c) 2020 Paul Pagel
This is free software; see the license.txt file for more information.
There is no warranty; not even for merchantability or fitness for a particular purpose.
*****************************************************/
#include "esp32_r4ge_pro.h"
#include "driver/i2s.h"
#include "freertos/queue.h"
#include "Ball.h"
#include "Player.h"
#include "Title.h"
#include "Bounce_wav.h"
#include "Score_wav.h"
#define LINE_COLOR ILI9341_GREEN
#define BALL_COLOR ILI9341_WHITE
#define PADDLE_COLOR ILI9341_YELLOW
#define SCORE_COLOR ILI9341_WHITE
#define TOP_LINE 20
#define NET_LINE 160
#define SCORE_DELAY_MS 1000
enum game_state_type {
STATE_TITLE,
STATE_START,
STATE_PLAY,
STATE_SCORE,
STATE_PAUSE,
STATE_GAME_OVER
};
enum game_state_type game_state, prev_game_state;
bool btn_pressed[8], btn_released[8];
bool btnA_pressed, btnB_pressed, btnX_pressed, btnY_pressed;
bool btnUp_pressed, btnDown_pressed, btnLeft_pressed, btnRight_pressed;
bool spkrLeft_on, spkrRight_on;
bool btnTouch_pressed, btnTouch_released;
int16_t joy_x_left, joy_y_left, joy_x_right, joy_y_right;
uint32_t state_start_time;
const uint8_t *audio_wav;
bool audio_playing, audio_right, audio_left;
uint16_t wav_length, sample_pos;
int16_t ball_x, ball_y;
double ball_x_dir, ball_y_dir;
uint8_t num_players = 1;
Player player[2];
Ball ball;
// i2s configuration
// See https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/driver/driver/i2s.h
int i2s_port_num = 0;
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 11025,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // (i2s_bits_per_sample_t) 8
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //I2S_CHANNEL_FMT_ONLY_RIGHT, I2S_CHANNEL_FMT_RIGHT_LEFT
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB), // | I2S_COMM_FORMAT_PCM
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // high interrupt priority. See esp_intr_alloc.h for more
.dma_buf_count = 6,
.dma_buf_len = 60,
.use_apll = false, // I2S using APLL as main I2S clock, enable it to get accurate clock
.tx_desc_auto_clear = 0, // helps in avoiding noise in case of data unavailability
.fixed_mclk = 0
};
i2s_pin_config_t pin_config = {
.bck_io_num = I2S_BCLK, // bit clock pin - to BCK pin on I2S DAC/PCM5102
.ws_io_num = I2S_LRCK, // left right select - to LCK pin on I2S DAC
.data_out_num = I2S_DOUT, // DATA output pin - to DIN pin on I2S DAC
.data_in_num = -1 // Not used
};
#define BUFFER_SIZE 1024
#define SAMPLES_PER_BUFFER 512 // 2 bytes per sample (16bit x 2 channels for stereo)
uint8_t audio_buffer[BUFFER_SIZE];
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup();
bool initAudioI2S();
void playAudio(const uint8_t *wav, uint16_t length, bool play_right, bool play_left);
void updateAudio();
void playBounceWall();
void playBouncePaddle(bool play_right, bool play_left);
void playScore(bool play_right, bool play_left);
void drawTitle();
void startGame(int players);
void drawScore();
void drawPause();
void erasePause();
void drawGameOver();
void checkButtonPresses();
void checkJoysticks();
void loop(void) ;
void handleTitle();
void handleStart();
void handlePlay();
void handlePause();
void handleGameOver();
void handleScore();
/*
* Set up the board
*/
void setup()
{
Serial.begin(115200);
Serial.println("ESP32 R4ge Prong");
delay(100);
// Set up shift register pins
pinMode(SR_PL, OUTPUT);
pinMode(SR_CP, OUTPUT);
pinMode(SR_Q7, INPUT);
// Set up the joysticks
pinMode(JOYX_L, INPUT);
pinMode(JOYY_L, INPUT);
pinMode(JOYX_R, INPUT);
pinMode(JOYY_R, INPUT);
// Set up the TFT backlight brightness control
pinMode(TFT_LED, OUTPUT);
digitalWrite(TFT_LED, LOW);
delay(100);
// Set up the TFT
tft.begin();
tft.setRotation(SCREEN_ROT);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
drawTitle();
game_state = STATE_TITLE;
}
/*
* Initialize the I2S audio output
*/
bool initAudioI2S()
{
esp_err_t err;
err = i2s_driver_install((i2s_port_t)i2s_port_num, &i2s_config, 0, NULL);
if (err != ESP_OK)
{
Serial.print("I2S driver install fail: ");
Serial.println(err);
return false;
}
i2s_set_pin((i2s_port_t)i2s_port_num, &pin_config);
i2s_set_clk((i2s_port_t)i2s_port_num, 11025, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_STEREO);
return true;
}
/*
* Plays the audio sample through either or both speaker channels.
* Does not return until sample is done playing.
*/
void playAudio(const uint8_t *wav, uint16_t length, bool play_right, bool play_left)
{
if (!play_right && !play_left) return; // not playing anything, so bail
audio_playing = initAudioI2S();
audio_wav = wav;
wav_length = length;
audio_right = play_right;
audio_left = play_left;
sample_pos = 40; // skip RIFF header, could detect & skip(?)
updateAudio();
}
void updateAudio()
{
int16_t buff_pos;
uint8_t temp, temp_msb;
size_t bytes_out;
if (!audio_playing) return;
// Fill I2S transfer audio buffer from sample buffer
for (int i = 0; i < SAMPLES_PER_BUFFER - 1; i+= 2)
{
if (sample_pos + i < wav_length - 1)
{
temp = audio_wav[sample_pos + i];
temp_msb = audio_wav[sample_pos + i + 1];
}
else
{
temp = 0;
temp_msb = 0;
}
buff_pos = i * 2; // right + left channel samples
// If using I2S_CHANNEL_FMT_ONLY_RIGHT
//audio_buffer[buff_pos] = temp;
//audio_buffer[buff_pos + 1] = (uint8_t)temp_msb;
if (audio_left) // put sound data into right channel
{
audio_buffer[buff_pos] = temp;
audio_buffer[buff_pos + 1] = (uint8_t)temp_msb;
}
else
{
audio_buffer[buff_pos] = 0;
audio_buffer[buff_pos + 1] = 0;
}
if (audio_right) // put sound data into left channel
{
audio_buffer[buff_pos + 2] = (uint8_t)temp & 0xff;
audio_buffer[buff_pos + 3] = (uint8_t)temp_msb;
}
else
{
audio_buffer[buff_pos + 2] = 0;
audio_buffer[buff_pos + 3] = 0;
}
}
// Write data to I2S DMA buffer. Blocking call, last parameter = ticks to wait or portMAX_DELAY for no timeout
i2s_write((i2s_port_t)i2s_port_num, (const char *)&audio_buffer, sizeof(audio_buffer), &bytes_out, 100);
if (bytes_out != sizeof(audio_buffer)) Serial.println("I2S write timeout");
sample_pos += SAMPLES_PER_BUFFER;
if (sample_pos >= wav_length - 1)
{
// Stop audio playback
i2s_driver_uninstall((i2s_port_t)i2s_port_num);
audio_playing = false;
}
}
void playBounceWall()
{
playAudio(bounce3_wav, BOUNCE_LENGTH, true, true);
}
void playBouncePaddle(bool play_right, bool play_left)
{
playAudio(bounce1_wav, BOUNCE_LENGTH, play_right, play_left);
}
void playScore(bool play_right, bool play_left)
{
playAudio(score_wav, BOUNCE_LENGTH, play_right, play_left);
}
/*
* Draws the game title/splash screen
*/
void drawTitle()
{
tft.fillScreen(ILI9341_BLACK);
tft.drawRGBBitmap(40, 60, (uint16_t *)prong_title, 240, 78);
tft.setTextSize(2);
tft.setTextColor(ILI9341_DARKGREY);
tft.setCursor(80, 180);
tft.print("[X] 1 Player");
tft.setCursor(80, 200);
tft.print("[Y] 2 Player");
}
/*
* Initializes the game variables and draws the main gameplay screen
*/
void startGame(int players)
{
tft.fillScreen(ILI9341_BLACK);
tft.drawLine(0, TOP_LINE, SCREEN_WD, TOP_LINE, LINE_COLOR);
for (int i = TOP_LINE; i < SCREEN_HT; i+= 8)
{
tft.drawLine(NET_LINE, i, NET_LINE, i+3, LINE_COLOR);
}
ball.setLimits(TOP_LINE + 1, SCREEN_HT - 1);
player[0].setLimits(TOP_LINE + 1, SCREEN_HT - 1);
player[1].setLimits(TOP_LINE + 1, SCREEN_HT - 1);
player[0].begin(1, PADDLE_COLOR, (bool)(players > 0));
player[1].begin(2, PADDLE_COLOR, (bool)(players > 1));
drawScore();
}
/*
* Draw the score for both players
*/
void drawScore()
{
uint16_t score = player[0].getScore();
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
tft.setCursor(60, 0);
tft.print(score);
score = player[1].getScore();
tft.setCursor(230, 0);
tft.print(score);
}
/*
* Draws a Paused message on the screen
*/
void drawPause()
{
//tft.fillRect(124, 0, 112, 20, ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_RED);
tft.setCursor(124, 0);
tft.print("PAUSED");
delay(200);
game_state = STATE_PAUSE;
}
/*
* Erases the Paused message
*/
void erasePause()
{
tft.fillRect(124, 0, 112, 20, ILI9341_BLACK);
delay(200);
game_state = STATE_PLAY;
}
/*
* Draws the Game Over screen
*/
void drawGameOver()
{
tft.fillRect (80, 70, 160, 55, ILI9341_BLACK); // clear msg area
tft.drawRect (80, 70, 160, 55, ILI9341_YELLOW); // border
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(105, 80);
tft.print("GAME OVER");
tft.setTextSize(1);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(105, 110);
tft.print("PRESS [Y] TO START");
}
/*
* Check button presses connected to the shift register
*/
void checkButtonPresses()
{
bool pressed = false;
digitalWrite(SR_CP, LOW);
digitalWrite(SR_PL, LOW);
delay(5);
digitalWrite(SR_PL, HIGH);
for(uint8_t i = 0; i < 8; i++)
{
pressed = (digitalRead(SR_Q7) == LOW ? 1: 0);// read the state of the SO:
btn_released[i] = !pressed && btn_pressed[i];
btn_pressed[i] = pressed;
// Shift the next button pin value into the serial data out
digitalWrite(SR_CP, LOW);
delay(1);
digitalWrite(SR_CP, HIGH);
delay(1);
//Serial.print(i); Serial.print(": "); Serial.println(btn_pressed[i]);
}
}
/*
* Check the analog joystick values
*/
void checkJoysticks()
{
// Joystick result value will be between -15 and +15
//joy_x_left = (analogRead(JOYX_L) >> 7) - JOY_5BIT_CTR;
if (btn_pressed[BTN_UP])
{
joy_y_left = 6;
}
else if (btn_pressed[BTN_DOWN])
{
joy_y_left = -6;
}
else
{
joy_y_left = (analogRead(JOYY_L) >> 7) - JOY_5BIT_CTR;
}
if (btn_pressed[BTN_Y])
{
joy_y_right = 6;
}
else if (btn_pressed[BTN_A])
{
joy_y_right = -6;
}
else
{
joy_y_right = (analogRead(JOYY_R) >> 7) - JOY_5BIT_CTR;
}
}
/*
* Main program loop. Called continuously after setup.
*/
void loop(void)
{
checkButtonPresses();
checkJoysticks();
if (prev_game_state != game_state)
{
state_start_time = millis(); // track when the state change started
// Do initial screen drawing for new game state
switch(game_state)
{
case STATE_TITLE:
drawTitle();
break;
case STATE_START:
startGame(num_players);
break;
case STATE_PLAY:
if (ball.isDead()) ball.begin(BALL_COLOR);
break;
case STATE_SCORE:
drawScore();
ball.erase(&tft);
break;
case STATE_PAUSE:
drawPause();
break;
case STATE_GAME_OVER:
drawGameOver();
break;
}
}
prev_game_state = game_state;
// Update the screen based on the game state
switch(game_state)
{
case STATE_TITLE:
handleTitle();
break;
case STATE_START:
handleStart();
break;
case STATE_PLAY:
handlePlay();
break;
case STATE_SCORE:
handleScore();
break;
case STATE_PAUSE:
handlePause();
break;
case STATE_GAME_OVER:
handleGameOver();
break;
}
updateAudio();
//delay(1);
}
/*
* Handles the STATE_TITLE game state logic
*/
void handleTitle()
{
if (btn_released[BTN_X])
{
num_players = 1;
game_state = STATE_START;
return;
}
if (btn_released[BTN_Y])
{
num_players = 2;
game_state = STATE_START;
return;
}
}
/*
* Handles the STATE_START game state logic
*/
void handleStart()
{
game_state = STATE_PLAY;
}
/*
* Handles the STATE_PLAYING game state logic
*/
void handlePlay()
{
// player controls logic
if (btn_released[BTN_X])
{
drawPause();
return;
}
// Do update logic and checks
update_result_type result;
result = ball.update();
switch(result)
{
case RESULT_BOUNCE:
playBounceWall();
break;
case RESULT_SCORE1:
player[0].changeScore(1);
playScore(false, true);
game_state = STATE_SCORE;
break;
case RESULT_SCORE2:
player[1].changeScore(1);
playScore(true, false);
game_state = STATE_SCORE;
break;
default:
break;
}
if (game_state != STATE_PLAY) return;
// Redraw net - TODO: still gaps too long
int16_t ball_y = ball.getY() - 4;
for (int i = ball_y; i < ball_y + 4; i++)
{
if (i & 0x0004) tft.drawPixel(NET_LINE, i, LINE_COLOR);
}
result = player[0].update(joy_y_left, &ball);
if (result == RESULT_BOUNCE) playBouncePaddle(true, false);
result = player[1].update(joy_y_right, &ball);
if (result == RESULT_BOUNCE) playBouncePaddle(false, true);
// Draw results to the screen
ball.draw(&tft);
player[0].draw(&tft);
player[1].draw(&tft);
}
/*
* Handles the STATE_PAUSED game state logic
*/
void handlePause()
{
if (btn_released[BTN_X])
{
erasePause();
}
}
/*
* Handles the STATE_GAME_OVER game state logic
*/
void handleGameOver()
{
if (btn_released[BTN_Y])
{
drawTitle();
}
}
/*
* Handles the STATE_SCORE game state logic
*/
void handleScore()
{
if (millis() - state_start_time >= SCORE_DELAY_MS)
{
game_state = STATE_PLAY;
return;
}
player[0].update(joy_y_left, &ball);
player[1].update(joy_y_right, &ball);
player[0].draw(&tft);
player[1].draw(&tft);
}
| 22.296296
| 123
| 0.664524
|
DigiTorus86
|
a4872d9a660d3f47f1c639a2a71dd46c6679986c
| 5,289
|
cpp
|
C++
|
evolutionary_prototype(final code)/collision_controller.cpp
|
egeorgiev1/UR10_motion_planner
|
e51228f88626eb4be8d9d98c25b37050dc9c8b31
|
[
"Apache-2.0"
] | 1
|
2021-11-17T01:02:05.000Z
|
2021-11-17T01:02:05.000Z
|
evolutionary_prototype(final code)/collision_controller.cpp
|
egeorgiev1/UR10_motion_planner
|
e51228f88626eb4be8d9d98c25b37050dc9c8b31
|
[
"Apache-2.0"
] | null | null | null |
evolutionary_prototype(final code)/collision_controller.cpp
|
egeorgiev1/UR10_motion_planner
|
e51228f88626eb4be8d9d98c25b37050dc9c8b31
|
[
"Apache-2.0"
] | null | null | null |
#include "test_fcl_utility.h"
#include "collision_controller.h"
#include <iostream>
using namespace std;
CollisionController::CollisionController(
CollisionModel* robot_collision_model,
PointCloudView* point_cloud_view,
fcl::BroadPhaseCollisionManager<double>* scene_collision_manager
) :
_robot_collision_model(robot_collision_model),
_point_cloud_view(point_cloud_view),
_scene_collision_manager(scene_collision_manager)
{}
void CollisionController::schedule_collision_detection() {
_must_perform_collision_detection = true;
}
void CollisionController::frameRendered(const Ogre::FrameEvent& evt) {
if(_must_perform_collision_detection) {
_must_perform_collision_detection = false;
// Perform collision detection here, display contact points (TODO: BE ABLE TO DISABLE THIS!!!)
// NOTE: FCL works so that a single CollisionData object could be used to
// accummulate the results from multiple collision detection tasks!!!
fcl::test::CollisionData<double> self_collision_data;
self_collision_data.request.enable_contact = true;
self_collision_data.request.num_max_contacts = 10'000;
fcl::test::CollisionData<double> scene_collision_data;
scene_collision_data.request.enable_contact = true;
scene_collision_data.request.num_max_contacts = 10'000;
// TEST(To separate in another class(must not be done for self-collision detection???))
fcl::test::DistanceData<double> scene_distance_data;
scene_distance_data.request.enable_nearest_points = true;
auto robot_collision_manager = _robot_collision_model->get_broadphase_managers();
cout << "Number of managed robot collision meshes" << robot_collision_manager->size() << endl;
cout << "Number of managed scene collision meshes" << _scene_collision_manager->size() << endl;
robot_collision_manager->collide(
robot_collision_manager,
&self_collision_data,
CollisionModel::self_collision_function<double>
//fcl::test::defaultCollisionFunction<double>
);
cout << "I CRASH AFTER THIS" << endl;
robot_collision_manager->collide(
_scene_collision_manager,
&scene_collision_data,
CollisionModel::scene_collision_function<double> // FOR LOGGING!!!
//fcl::test::defaultCollisionFunction<double>
);
cout << "I CRASH AFTER THIS" << endl;
// TEST(To separate in another class(must not be done for self-collision detection???))
robot_collision_manager->distance(
_scene_collision_manager,
&scene_distance_data,
//CollisionModel::scene_collision_function<double> // FOR LOGGING!!!
fcl::test::defaultDistanceFunction<double>
);
cout << "I CRASH AFTER THIS" << endl;
cout << endl;
cout << "Self-collision points: " << self_collision_data.result.numContacts() << endl;
cout << "Robot-scene points: " << scene_collision_data.result.numContacts() << endl;
cout << "Min-distance from scene: " << scene_distance_data.result.min_distance << endl; // TEST
cout << endl;
// Contact points aggregation
points_array_t contact_points;
// TEST(add to result contacts)
contact_points.push_back(
{{
scene_distance_data.result.nearest_points[0].x(),
scene_distance_data.result.nearest_points[0].y(),
scene_distance_data.result.nearest_points[0].z()
}}
);
contact_points.push_back(
{{
scene_distance_data.result.nearest_points[1].x(),
scene_distance_data.result.nearest_points[1].y(),
scene_distance_data.result.nearest_points[1].z()
}}
);
// SAMPLING_BOUNDS_DEBUG_OUTPUT
// TEST - ORIGINAL
// {{ 0.6, 0, 0 }},
// {{ -0.6, 0.6, 0.6 }},
// TEST - TRANSFORMED FOR OGRE3D COORDINATE SYSTEM
// {{ -0.6, 0, 0 }},
// {{ 0.6, 0.6, 0.6 }},
// contact_points.push_back(
// {{ -0.6, 0, 0 }}
// );
// contact_points.push_back(
// {{ 0.6, 0.6, 0.6 }}
// );
// Add self-collision contact points
for(size_t i = 0; i < self_collision_data.result.numContacts(); i++) {
contact_points.push_back(
{{
self_collision_data.result.getContact(i).pos.x(),
self_collision_data.result.getContact(i).pos.y(),
self_collision_data.result.getContact(i).pos.z()
}}
);
}
// Add robot-scene collision contact points
for(size_t i = 0; i < scene_collision_data.result.numContacts(); i++) {
contact_points.push_back(
{{
scene_collision_data.result.getContact(i).pos.x(),
scene_collision_data.result.getContact(i).pos.y(),
scene_collision_data.result.getContact(i).pos.z()
}}
);
}
// Show contact points
_point_cloud_view->set_points(contact_points);
}
}
| 37.778571
| 103
| 0.619966
|
egeorgiev1
|
a4878ef2f2de4abfd9cb382340719f9b4f1d0ba4
| 805
|
cpp
|
C++
|
Queue/InbuiltQueue.cpp
|
sohamnandi77/Cpp-Data-Structures-And-Algorithm
|
f29a14760964103a5b58cfff925cd8f7ed5aa6c1
|
[
"MIT"
] | 2
|
2021-05-21T17:10:02.000Z
|
2021-05-29T05:13:06.000Z
|
Queue/InbuiltQueue.cpp
|
sohamnandi77/Cpp-Data-Structures-And-Algorithm
|
f29a14760964103a5b58cfff925cd8f7ed5aa6c1
|
[
"MIT"
] | null | null | null |
Queue/InbuiltQueue.cpp
|
sohamnandi77/Cpp-Data-Structures-And-Algorithm
|
f29a14760964103a5b58cfff925cd8f7ed5aa6c1
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <queue>
using namespace std;
// # Application of Queue
// -> Single Resource and Multiple Consumers
// -> Synchronization between slow and fast devices
// -> In Operating System (Semaphores, FCFS Sheduling,Spooling, buffers for devices like Keyboard)
// -> In computer Networks (Routers/Switches and mail Queues)
// -> Variations: Deque, Priority Queue(Heap),Doubly Ended Priority Queue
int main()
{
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
q.push(60);
cout << q.front() << endl;
q.pop();
q.pop();
q.pop();
cout << q.size() << endl;
cout << q.empty() << endl;
// print the queue
while (!q.empty())
{
cout << q.front() << endl;
q.pop();
}
return 0;
}
| 21.184211
| 98
| 0.590062
|
sohamnandi77
|
a493ba13372e556f1a83390d71e5ef075334c55c
| 4,846
|
cxx
|
C++
|
plugins/cg_fltk/fltk_layout_group.cxx
|
MarioHenze/cgv
|
bacb2d270b1eecbea1e933b8caad8d7e11d807c2
|
[
"BSD-3-Clause"
] | 11
|
2017-09-30T12:21:55.000Z
|
2021-04-29T21:31:57.000Z
|
plugins/cg_fltk/fltk_layout_group.cxx
|
MarioHenze/cgv
|
bacb2d270b1eecbea1e933b8caad8d7e11d807c2
|
[
"BSD-3-Clause"
] | 2
|
2017-07-11T11:20:08.000Z
|
2018-03-27T12:09:02.000Z
|
plugins/cg_fltk/fltk_layout_group.cxx
|
MarioHenze/cgv
|
bacb2d270b1eecbea1e933b8caad8d7e11d807c2
|
[
"BSD-3-Clause"
] | 24
|
2018-03-27T11:46:16.000Z
|
2021-05-01T20:28:34.000Z
|
#include "fltk_layout_group.h"
#include <cgv/utils/scan.h>
#include <cgv/gui/provider.h>
using namespace cgv::base;
using namespace cgv::gui;
#ifdef WIN32
#pragma warning (disable:4311)
#endif
#include <fltk/Group.h>
#include <fltk/draw.h>
#include <fltk/Cursor.h>
#include <fltk/events.h>
#include <fltk/ScrollGroup.h>
#include <fltk/PackedGroup.h>
#include <fltk/Button.h>
#ifdef WIN32
#pragma warning (default:4311)
#endif
fltk_layout_group::fltk_layout_group(int x, int y, int w, int h, const std::string& _name) :
cgv::gui::gui_group(_name), CG<fltk::Group>(x, y, w, h, "")
{
label(get_name().c_str());
user_data(static_cast<cgv::base::base*>(this));
}
/// only uses the implementation of fltk_base
std::string fltk_layout_group::get_property_declarations()
{
std::string decl = fltk_base::get_property_declarations();
decl+=";layout:string;border-style:string;";
if (formatter)
decl+=formatter->get_property_declarations();
return decl;
}
/// abstract interface for the setter
bool fltk_layout_group::set_void(const std::string& property, const std::string& value_type, const void* value_ptr)
{
if (property == "layout") {
get_variant(formatter_name, value_type, value_ptr);
if (formatter_name == "table")
formatter = new layout_table(cgv::base::group_ptr(this));
if (formatter_name == "inline")
formatter = new layout_inline(cgv::base::group_ptr(this));
} else
if (property == "border-style") {
get_variant(border_style, value_type, value_ptr);
update_box_type();
redraw();
} else
if (formatter && formatter->set_void(property, value_type, value_ptr))
return true;
else {
fltk_base::set_void(this, this, property, value_type, value_ptr);
}
return true;
}
/// abstract interface for the getter
bool fltk_layout_group::get_void(const std::string& property, const std::string& value_type, void* value_ptr)
{
if (property == "layout")
set_variant(formatter_name, value_type, value_ptr);
else
if (property == "border-style")
set_variant(border_style, value_type, value_ptr);
else
if (formatter && formatter->get_void(property, value_type, value_ptr))
return true;
else {
// if (property == "label") {
// std::cout << "layout label" << std::endl;
// }
return fltk_base::get_void(this, this, property, value_type, value_ptr);
}
return true;
}
void fltk_layout_group::update_box_type()
{
if (border_style == "sunken")
box(fltk::DOWN_BOX);
else
if (border_style == "lifted")
box(fltk::UP_BOX);
else
if (border_style == "thinsunken")
box(fltk::THIN_DOWN_BOX);
else
if (border_style == "thinlifted")
box(fltk::THIN_UP_BOX);
else
if (border_style == "framed")
box(fltk::BORDER_BOX);
// more types can be added using:
// http://www.fltk.org/doc-2.0/html/group__boxes.html
}
/// return a fltk::Widget pointer that can be cast into a fltk::Group
void* fltk_layout_group::get_user_data() const
{
return (fltk::Widget*)(this);
}
/// put default sizes into dimension fields and set inner_group to be active
void fltk_layout_group::prepare_new_element(cgv::gui::gui_group_ptr ggp, int& x, int& y, int& w, int& h)
{
x = 0;
y = 0;
w = 200;
h = 20;
begin();
}
/// overload to trigger initialization of alignment
void fltk_layout_group::remove_all_children(cgv::gui::gui_group_ptr ggp)
{
fltk_gui_group::remove_all_children(ggp);
}
/// align last element and add element to group
void fltk_layout_group::finalize_new_element(cgv::gui::gui_group_ptr ggp, const std::string& _align, cgv::base::base_ptr element)
{
end();
// save the alignment information
element->set<std::string>("alignment", _align);
// the default width and height
element->set<int>("dw", element->get<int>("w"));
element->set<int>("dh", element->get<int>("h"));
cgv::base::group::append_child(element);
}
void fltk_layout_group::register_object(base_ptr object, const std::string& options)
{
if (!cgv::utils::is_element(get_name(),options))
return;
provider* p = object->get_interface<cgv::gui::provider>();
if (p && get_provider_parent(p).empty()) {
set_provider_parent(p,gui_group_ptr(this));
p->create_gui();
}
}
///
void fltk_layout_group::unregister_object(cgv::base::base_ptr object, const std::string& options)
{
if (!options.empty() && !cgv::utils::is_element(get_name(),options))
return;
provider* p = object->get_interface<cgv::gui::provider>();
if (p && get_provider_parent(p) == this)
remove_all_children();
}
void fltk_layout_group::layout()
{
if (!formatter.empty())
formatter->resize(w(), h());
// relayout children
//for (int i=0; i<fltk::Group::children(); i++)
// fltk::Group::child(i)->layout();
// fltk::Group::layout();
}
| 25.640212
| 130
| 0.677466
|
MarioHenze
|
a49b585d1de37a01b3dce14c750ecb09dcbeec0d
| 155
|
hh
|
C++
|
include/cppti/Utils.hh
|
Ethiraric/cpptalksindex
|
0f342f944d3da6d456694bee199e89570b07588f
|
[
"MIT"
] | 4
|
2020-10-06T10:12:59.000Z
|
2021-05-22T07:41:29.000Z
|
include/cppti/Utils.hh
|
Ethiraric/cpptalksindex
|
0f342f944d3da6d456694bee199e89570b07588f
|
[
"MIT"
] | null | null | null |
include/cppti/Utils.hh
|
Ethiraric/cpptalksindex
|
0f342f944d3da6d456694bee199e89570b07588f
|
[
"MIT"
] | null | null | null |
#ifndef CPPTI_UTILS_HH_
#define CPPTI_UTILS_HH_
#include <string>
namespace cppti
{
void toSnakeCase(std::string& str);
}
#endif /* !CPPTI_UTILS_HH_ */
| 12.916667
| 35
| 0.748387
|
Ethiraric
|
a49ca13224da26d48fc919448637421a355fa7fc
| 10,177
|
cpp
|
C++
|
utils/preprocess/beer.cpp
|
charlespnh/shortest-beer-path
|
c133969bbfd977498623f39e665e60e66890b998
|
[
"MIT"
] | 1
|
2021-09-13T04:01:12.000Z
|
2021-09-13T04:01:12.000Z
|
utils/preprocess/beer.cpp
|
Phuc2002/shortest-beer-path
|
c133969bbfd977498623f39e665e60e66890b998
|
[
"MIT"
] | null | null | null |
utils/preprocess/beer.cpp
|
Phuc2002/shortest-beer-path
|
c133969bbfd977498623f39e665e60e66890b998
|
[
"MIT"
] | null | null | null |
#include <algorithm>
#include <utility>
#include <cstdio>
#include <iostream>
using namespace std;
#include "../../include/preprocess/beer.h"
#include "../../include/outerplanar.h"
#include "../../include/graph/dcel.h"
double beer::weightB(struct halfedge* e) { return dcel::edgeB(e)->distB; }
double beer::weightB(struct vertex* v) { return dcel::edgeB(v)->distB; }
struct vertex* beer::originB(struct halfedge* e) { return dcel::edgeB(e)->u; }
struct vertex* beer::targetB(struct halfedge* e) { return dcel::edgeB(e)->v; }
struct vertex* beer::originB(struct vertex* v) { return v; }
struct vertex* beer::targetB(struct vertex* v) { return v; }
struct b_edge* beer::get_edgeB(struct vertex* u, struct vertex* v){
if (u == v) return dcel::edgeB(u);
struct halfedge* uv = graph::get_edge(u, v);
if (uv) return dcel::edgeB(uv);
return NULL;
}
// post-order traversal of D(G)
// compute distB(a, b, G\R)
void beer::beerDistNotRoot(struct node* F){
if (F == NULL) return;
struct halfedge* ab = dcel::edge(F);
struct halfedge* ac = dcel::prev(ab);
struct halfedge* bc = dcel::next(ab);
beer::beerDistNotRoot(dcel::left(F));
beer::beerDistNotRoot(dcel::right(F));
// for all v in face F
for (int i = 0; i < 3; i++, ab = dcel::next(ab)){
struct halfedge* uv = ab;
struct halfedge* vw = bc;
struct vertex* v = dcel::target(uv);
struct vertex* u = dcel::origin(uv);
struct vertex* w = dcel::target(vw);
v->beer_edge->distB = min(beer::weightB(v), min(2 * dcel::weight(uv) + beer::weightB(u),
2 * dcel::weight(vw) + beer::weightB(w)));
if (beer::weightB(v) == 2 * dcel::weight(uv) + beer::weightB(u))
v->beer_edge->pathB = make_pair(u, 0);
else if (beer::weightB(v) == 2 * dcel::weight(vw) + beer::weightB(w))
v->beer_edge->pathB = make_pair(w, 0);
}
// distB(a, b, G\R)
struct vertex* a = dcel::target(ac);
struct vertex* b = dcel::target(ab);
struct vertex* c = dcel::target(bc);
if (beer::originB(ab) != a) swap(ab->beer_edge->u, ab->beer_edge->v);
ab->beer_edge->distB = min(min(dcel::weight(ab) + beer::weightB(a), dcel::weight(ab) + beer::weightB(b)),
min(beer::weightB(ac) + dcel::weight(bc), dcel::weight(ac) + beer::weightB(bc)));
if (beer::weightB(ab) == dcel::weight(ab) + beer::weightB(a))
ab->beer_edge->pathB = make_pair(a, 0);
else if (beer::weightB(ab) == dcel::weight(ab) + beer::weightB(b))
ab->beer_edge->pathB = make_pair(b, 1);
else if (beer::weightB(ab) == beer::weightB(ac) + dcel::weight(bc))
ab->beer_edge->pathB = make_pair(c, 0);
else ab->beer_edge->pathB = make_pair(c, 1);
}
// compute beer dist for edge E in subgraph G not R
void beer::computeBeerDistNotRoot(struct node* R){
struct halfedge* E = dcel::edge(R);
struct halfedge* traverse_e = dcel::twin(E);
struct vertex *u, *v, *w;
struct halfedge *uv, *vw;
// Base case post-order traversal: for all v in V(G)
do {
v = dcel::target(traverse_e);
if (dcel::beer(v))
v->beer_edge->distB = 0;
// v->beer_edge->beer = NIL;
// else v->beer->distB = INF;
traverse_e = dcel::next(traverse_e);
} while(traverse_e != dcel::twin(E));
// Base case post-order traversal: for all exterior edge (u, v) in E(G)
do {
uv = traverse_e;
u = dcel::origin(uv);
v = dcel::target(uv);
if (dcel::beer(u) || dcel::beer(v))
uv->beer_edge->distB = dcel::weight(uv);
// uv->beer_edge->pathB = NIL;
// else uv->beer_edge->distB = INF;
traverse_e = dcel::next(traverse_e);
} while(traverse_e != dcel::twin(E));
// Recurrence: for all interior edges in face R
for (int i = 0; i < 3; i++, E = dcel::next(E))
beer::beerDistNotRoot(dcel::face(dcel::twin(E)));
// Base case pre-order traversal: for all v in face R
for (int i = 0; i < 3; i++, E = dcel::next(E)){
uv = E;
vw = dcel::next(E);
v = dcel::target(uv); /* (u -> v) v */
u = dcel::origin(uv); /* (w -> u) / R \ */
w = dcel::target(vw); /* (v -> w) w --- u */
v->beer_edge->distB = min(beer::weightB(v), min(2 * dcel::weight(uv) + beer::weightB(u),
2 * dcel::weight(vw) + beer::weightB(w)));
if (beer::weightB(v) == 2 * dcel::weight(uv) + beer::weightB(u))
v->beer_edge->pathB = make_pair(u, 0);
else if (beer::weightB(v) == 2 * dcel::weight(vw) + beer::weightB(w))
v->beer_edge->pathB = make_pair(w, 0);
}
}
// pre-order traversal of D(G)
void beer::beerDistRoot(struct node* F){
// distB(a, b, G_R) is already computed (in previous recursive call during pre-order traversal)
if (F == NULL) return;
struct halfedge* ab = dcel::edge(F);
struct halfedge* ac = dcel::prev(ab);
struct halfedge* bc = dcel::next(ab);
struct vertex* a = dcel::target(ac);
struct vertex* b = dcel::target(ab);
struct vertex* c = dcel::target(bc);
double tmp;
c->beer_edge->distB = min(beer::weightB(c), min(2 * dcel::weight(ac) + beer::weightB(a),
2 * dcel::weight(bc) + beer::weightB(b)));
if (beer::weightB(c) == 2 * dcel::weight(ac) + beer::weightB(a))
c->beer_edge->pathB = make_pair(a, 0);
else if (beer::weightB(c) == 2 * dcel::weight(bc) + beer::weightB(b))
c->beer_edge->pathB = make_pair(b, 0);
// compute distB(c, a, G_R)
bool relax = true;
tmp = beer::weightB(ac);
ac->beer_edge->distB = min(beer::weightB(ac), min(min(dcel::weight(ac) + beer::weightB(a), dcel::weight(ac) + beer::weightB(c)),
min(beer::weightB(ab) + dcel::weight(bc), dcel::weight(ab) + beer::weightB(bc))));
if (beer::weightB(ac) == tmp) relax = false;
else if (beer::weightB(ac) == dcel::weight(ac) + beer::weightB(a))
ac->beer_edge->pathB = make_pair(a, 1);
else if (beer::weightB(ac) == dcel::weight(ac) + beer::weightB(c))
ac->beer_edge->pathB = make_pair(c, 0);
else if (beer::weightB(ac) == beer::weightB(ab) + dcel::weight(bc))
ac->beer_edge->pathB = make_pair(b, 1);
else
ac->beer_edge->pathB = make_pair(b, 0);
if (relax && beer::originB(ac) != c)
swap(ac->beer_edge->u, ac->beer_edge->v);
// compute distB(b, c, G_R)
relax = true;
tmp = beer::weightB(bc);
bc->beer_edge->distB = min(beer::weightB(bc), min(min(dcel::weight(bc) + beer::weightB(b), dcel::weight(bc) + beer::weightB(c)),
min(beer::weightB(ab) + dcel::weight(ac), dcel::weight(ab) + beer::weightB(ac))));
if (beer::weightB(bc) == tmp) relax = false;
else if (beer::weightB(bc) == dcel::weight(bc) + beer::weightB(b))
bc->beer_edge->pathB = make_pair(b, 0);
else if (beer::weightB(bc) == dcel::weight(bc) + beer::weightB(c))
bc->beer_edge->pathB = make_pair(c, 1);
else if (beer::weightB(bc) == beer::weightB(ab) + dcel::weight(ac))
bc->beer_edge->pathB = make_pair(a, 0);
else
bc->beer_edge->pathB = make_pair(a, 1);
if (relax && beer::originB(bc) != b)
swap(bc->beer_edge->u, bc->beer_edge->v);
beer::beerDistRoot(dcel::left(F));
beer::beerDistRoot(dcel::right(F));
}
// compute beer dist for all edge E in subgraph G with R
void beer::computeBeerDistRoot(struct node* R){
// Base case pre-order traversal: for all v in face R... computed during post-order traversal
// Base case pre-order traversal: for all edge (u, v) in face R
struct halfedge* E = dcel::edge(R);
for (int i = 0; i < 3; i++, E = dcel::next(E)){
struct halfedge* uv = E;
struct halfedge* uw = dcel::prev(E);
struct halfedge* wv = dcel::next(E);
struct vertex* v = dcel::target(uv);
struct vertex* u = dcel::target(uw);
struct vertex* w = dcel::target(wv);
double tmp;
bool relax = true;
tmp = beer::weightB(uv);
uv->beer_edge->distB = min(beer::weightB(uv), min(min(dcel::weight(uv) + beer::weightB(u), dcel::weight(uv) + beer::weightB(v)),
min(beer::weightB(uw) + dcel::weight(wv), dcel::weight(uw) + beer::weightB(wv))));
if (beer::weightB(uv) == tmp) relax = false;
else if (beer::weightB(uv) == dcel::weight(uv) + beer::weightB(u))
uv->beer_edge->pathB = make_pair(u, 0);
else if (beer::weightB(uv) == dcel::weight(uv) + beer::weightB(v))
uv->beer_edge->pathB = make_pair(v, 1);
else if (beer::weightB(uv) == beer::weightB(uw) + dcel::weight(wv))
uv->beer_edge->pathB = make_pair(w, 0);
else
uv->beer_edge->pathB = make_pair(w, 1);
if (relax && beer::originB(uv) != u)
swap(uv->beer_edge->u, uv->beer_edge->v);
}
for (int i = 0; i < 3; i++, E = dcel::next(E))
beer::beerDistRoot(dcel::face(dcel::twin(E)));
}
vector<struct vertex*> beer::print_beer_path(struct vertex* v){
return print_beer_subpath(dcel::edgeB(v));
}
vector<struct vertex*> beer::print_beer_path(struct halfedge* uv){
vector<struct vertex*> pathB = beer::print_beer_path(dcel::edgeB(uv));
if (dcel::origin(uv) != pathB.front())
reverse(pathB.begin(), pathB.end());
return pathB;
}
vector<struct vertex*> beer::print_beer_path(struct b_edge* uv){
vector<struct vertex*> pathB = {uv->u};
vector<struct vertex*> subPathB = beer::print_beer_subpath(uv);
pathB.insert(pathB.end(), subPathB.begin(), subPathB.end());
return pathB;
}
vector<struct vertex*> beer::print_beer_subpath(struct b_edge* e){
if (dcel::beer(e->u) || dcel::beer(e->v))
return {e->v};
// u - w - v
vector<struct vertex*> path;
auto [w, beerLoc] = e->pathB;
if (beerLoc == 0){
struct b_edge* subpathB = beer::get_edgeB(e->u, w);
if (subpathB->u != e->u && subpathB->v != w){
swap(subpathB->u, subpathB->v);
subpathB->pathB.second = !subpathB->pathB.second;
}
// u - w is the beer subpath
path = print_beer_subpath(subpathB);
path.push_back(e->v);
}
else{
struct b_edge* subpathB = beer::get_edgeB(w, e->v);
if (subpathB->u != w && subpathB->v != e->v){
swap(subpathB->u, subpathB->v);
subpathB->pathB.second = !subpathB->pathB.second;
}
// w - v is the beer subpath
vector<struct vertex*> sub_path = beer::print_beer_subpath(subpathB);
path = {w};
path.insert(path.end(), sub_path.begin(), sub_path.end());
}
return path;
}
| 34.498305
| 132
| 0.606466
|
charlespnh
|
a49faf9c953fe1d6822b9a12c44d27de9e4c127c
| 49
|
cpp
|
C++
|
SFINAE/Foo.cpp
|
dave-c/workspace-snippets
|
f1ace623023f185f972fa35ac57c9fe8a651ffae
|
[
"MIT"
] | null | null | null |
SFINAE/Foo.cpp
|
dave-c/workspace-snippets
|
f1ace623023f185f972fa35ac57c9fe8a651ffae
|
[
"MIT"
] | null | null | null |
SFINAE/Foo.cpp
|
dave-c/workspace-snippets
|
f1ace623023f185f972fa35ac57c9fe8a651ffae
|
[
"MIT"
] | null | null | null |
#include "Foo.h"
Foo::Foo()
{}
Foo::~Foo()
{}
| 5.444444
| 16
| 0.469388
|
dave-c
|
a4a033c6333d8f5f3e2c8352e30ad9a27b386729
| 1,043
|
hpp
|
C++
|
src/controllers/npc_controller.hpp
|
astrellon/simple-space
|
20e98d4f562a78b1efeaedb0a0012f3c9306ac7e
|
[
"MIT"
] | 1
|
2020-09-23T11:17:35.000Z
|
2020-09-23T11:17:35.000Z
|
src/controllers/npc_controller.hpp
|
astrellon/simple-space
|
20e98d4f562a78b1efeaedb0a0012f3c9306ac7e
|
[
"MIT"
] | null | null | null |
src/controllers/npc_controller.hpp
|
astrellon/simple-space
|
20e98d4f562a78b1efeaedb0a0012f3c9306ac7e
|
[
"MIT"
] | null | null | null |
#pragma once
#include <queue>
#include <memory>
#include <SFML/System.hpp>
#include "character_controller.hpp"
#include "npc_needs.hpp"
#include "actions/npc_action.hpp"
namespace space
{
class Dialogue;
class Interaction;
class NpcController : public CharacterController
{
public:
// Fields
// Constructor
NpcController(GameSession &session);
// Methods
static const std::string ControllerType() { return "npc"; }
virtual std::string type() const { return ControllerType(); }
NpcNeeds &needs() { return _needs; }
virtual void update(sf::Time dt);
void dialogue(const Dialogue *dialogue);
const Dialogue *dialogue() const { return _dialogue; }
protected:
// Fields
NpcNeeds _needs;
std::queue<std::unique_ptr<NpcAction>> _highLevelActions;
const Dialogue *_dialogue;
Interaction *_startDialogueAction;
};
} // space
| 23.704545
| 73
| 0.598274
|
astrellon
|
a4a3913af3c0ffda6de292fffe348340d1e9e651
| 24,242
|
cpp
|
C++
|
src/org/apache/poi/sl/draw/SLGraphics.cpp
|
pebble2015/cpoi
|
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
|
[
"Apache-2.0"
] | null | null | null |
src/org/apache/poi/sl/draw/SLGraphics.cpp
|
pebble2015/cpoi
|
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
|
[
"Apache-2.0"
] | null | null | null |
src/org/apache/poi/sl/draw/SLGraphics.cpp
|
pebble2015/cpoi
|
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
|
[
"Apache-2.0"
] | null | null | null |
// Generated from /POI/java/org/apache/poi/sl/draw/SLGraphics.java
#include <org/apache/poi/sl/draw/SLGraphics.hpp>
#include <java/awt/BasicStroke.hpp>
#include <java/awt/Color.hpp>
#include <java/awt/Font.hpp>
#include <java/awt/FontMetrics.hpp>
#include <java/awt/Graphics.hpp>
#include <java/awt/GraphicsConfiguration.hpp>
#include <java/awt/GraphicsDevice.hpp>
#include <java/awt/GraphicsEnvironment.hpp>
#include <java/awt/Image.hpp>
#include <java/awt/Paint.hpp>
#include <java/awt/Polygon.hpp>
#include <java/awt/Rectangle.hpp>
#include <java/awt/RenderingHints_Key.hpp>
#include <java/awt/RenderingHints.hpp>
#include <java/awt/Shape.hpp>
#include <java/awt/Stroke.hpp>
#include <java/awt/Toolkit.hpp>
#include <java/awt/font/FontRenderContext.hpp>
#include <java/awt/font/GlyphVector.hpp>
#include <java/awt/font/TextLayout.hpp>
#include <java/awt/geom/AffineTransform.hpp>
#include <java/awt/geom/Arc2D_Double.hpp>
#include <java/awt/geom/Arc2D.hpp>
#include <java/awt/geom/Ellipse2D_Double.hpp>
#include <java/awt/geom/Ellipse2D.hpp>
#include <java/awt/geom/GeneralPath.hpp>
#include <java/awt/geom/Line2D_Double.hpp>
#include <java/awt/geom/Line2D.hpp>
#include <java/awt/geom/Path2D_Double.hpp>
#include <java/awt/geom/RoundRectangle2D_Double.hpp>
#include <java/awt/geom/RoundRectangle2D.hpp>
#include <java/awt/image/BufferedImage.hpp>
#include <java/awt/image/BufferedImageOp.hpp>
#include <java/awt/image/ImageObserver.hpp>
#include <java/lang/Boolean.hpp>
#include <java/lang/Class.hpp>
#include <java/lang/ClassCastException.hpp>
#include <java/lang/CloneNotSupportedException.hpp>
#include <java/lang/Double.hpp>
#include <java/lang/Math.hpp>
#include <java/lang/NullPointerException.hpp>
#include <java/lang/Object.hpp>
#include <java/lang/RuntimeException.hpp>
#include <java/lang/String.hpp>
#include <java/lang/Throwable.hpp>
#include <java/util/List.hpp>
#include <java/util/Map.hpp>
#include <org/apache/poi/sl/draw/DrawPaint.hpp>
#include <org/apache/poi/sl/usermodel/FreeformShape.hpp>
#include <org/apache/poi/sl/usermodel/GroupShape.hpp>
#include <org/apache/poi/sl/usermodel/Insets2D.hpp>
#include <org/apache/poi/sl/usermodel/PaintStyle_SolidPaint.hpp>
#include <org/apache/poi/sl/usermodel/PaintStyle.hpp>
#include <org/apache/poi/sl/usermodel/SimpleShape.hpp>
#include <org/apache/poi/sl/usermodel/StrokeStyle_LineDash.hpp>
#include <org/apache/poi/sl/usermodel/TextBox.hpp>
#include <org/apache/poi/sl/usermodel/TextParagraph.hpp>
#include <org/apache/poi/sl/usermodel/TextRun.hpp>
#include <org/apache/poi/sl/usermodel/VerticalAlignment.hpp>
#include <org/apache/poi/util/POILogFactory.hpp>
#include <org/apache/poi/util/POILogger.hpp>
#include <Array.hpp>
#include <ObjectArray.hpp>
template<typename T, typename U>
static T java_cast(U* u)
{
if(!u) return static_cast<T>(nullptr);
auto t = dynamic_cast<T>(u);
if(!t) throw new ::java::lang::ClassCastException();
return t;
}
template<typename T>
static T* npc(T* t)
{
if(!t) throw new ::java::lang::NullPointerException();
return t;
}
poi::sl::draw::SLGraphics::SLGraphics(const ::default_init_tag&)
: super(*static_cast< ::default_init_tag* >(0))
{
clinit();
}
poi::sl::draw::SLGraphics::SLGraphics(::poi::sl::usermodel::GroupShape* group)
: SLGraphics(*static_cast< ::default_init_tag* >(0))
{
ctor(group);
}
void poi::sl::draw::SLGraphics::init()
{
log = ::poi::util::POILogFactory::getLogger(static_cast< ::java::lang::Class* >(this->getClass()));
}
void poi::sl::draw::SLGraphics::ctor(::poi::sl::usermodel::GroupShape* group)
{
super::ctor();
init();
this->_group = group;
_transform = new ::java::awt::geom::AffineTransform();
_stroke = new ::java::awt::BasicStroke();
_paint = ::java::awt::Color::black();
_font = new ::java::awt::Font(u"Arial"_j, ::java::awt::Font::PLAIN, int32_t(12));
_background = ::java::awt::Color::black();
_foreground = ::java::awt::Color::white();
_hints = new ::java::awt::RenderingHints(nullptr);
}
poi::sl::usermodel::GroupShape* poi::sl::draw::SLGraphics::getShapeGroup()
{
return _group;
}
java::awt::Font* poi::sl::draw::SLGraphics::getFont()
{
return _font;
}
void poi::sl::draw::SLGraphics::setFont(::java::awt::Font* font)
{
this->_font = font;
}
java::awt::Color* poi::sl::draw::SLGraphics::getColor()
{
return _foreground;
}
void poi::sl::draw::SLGraphics::setColor(::java::awt::Color* c)
{
setPaint(static_cast< ::java::awt::Paint* >(c));
}
java::awt::Stroke* poi::sl::draw::SLGraphics::getStroke()
{
return _stroke;
}
void poi::sl::draw::SLGraphics::setStroke(::java::awt::Stroke* s)
{
this->_stroke = s;
}
java::awt::Paint* poi::sl::draw::SLGraphics::getPaint()
{
return _paint;
}
void poi::sl::draw::SLGraphics::setPaint(::java::awt::Paint* paint)
{
if(paint == nullptr)
return;
this->_paint = paint;
if(dynamic_cast< ::java::awt::Color* >(paint) != nullptr)
_foreground = java_cast< ::java::awt::Color* >(paint);
}
java::awt::geom::AffineTransform* poi::sl::draw::SLGraphics::getTransform()
{
return new ::java::awt::geom::AffineTransform(_transform);
}
void poi::sl::draw::SLGraphics::setTransform(::java::awt::geom::AffineTransform* Tx)
{
_transform = new ::java::awt::geom::AffineTransform(Tx);
}
void poi::sl::draw::SLGraphics::draw(::java::awt::Shape* shape)
{
auto path = new ::java::awt::geom::Path2D_Double(npc(_transform)->createTransformedShape(shape));
auto p = npc(_group)->createFreeform();
npc(p)->setPath(path);
npc(p)->setFillColor(nullptr);
applyStroke(p);
if(dynamic_cast< ::java::awt::Color* >(_paint) != nullptr) {
npc(p)->setStrokeStyle(new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(java_cast< ::java::awt::Color* >(_paint))}));
}
}
void poi::sl::draw::SLGraphics::drawString(::java::lang::String* s, float x, float y)
{
auto txt = npc(_group)->createTextBox();
::poi::sl::usermodel::TextRun* rt = java_cast< ::poi::sl::usermodel::TextRun* >(java_cast< ::java::lang::Object* >(npc(npc(java_cast< ::poi::sl::usermodel::TextParagraph* >(npc(npc(txt)->getTextParagraphs())->get(0)))->getTextRuns())->get(0)));
npc(rt)->setFontSize(::java::lang::Double::valueOf(static_cast< double >(npc(_font)->getSize())));
npc(rt)->setFontFamily(npc(_font)->getFamily());
if(getColor() != nullptr)
npc(rt)->setFontColor(static_cast< ::poi::sl::usermodel::PaintStyle* >(DrawPaint::createSolidPaint(getColor())));
if(npc(_font)->isBold())
npc(rt)->setBold(true);
if(npc(_font)->isItalic())
npc(rt)->setItalic(true);
npc(txt)->setText(s);
npc(txt)->setInsets(new ::poi::sl::usermodel::Insets2D(int32_t(0), int32_t(0), int32_t(0), int32_t(0)));
npc(txt)->setWordWrap(false);
npc(txt)->setHorizontalCentered(::java::lang::Boolean::valueOf(false));
npc(txt)->setVerticalAlignment(::poi::sl::usermodel::VerticalAlignment::MIDDLE);
auto layout = new ::java::awt::font::TextLayout(s, _font, getFontRenderContext());
auto ascent = npc(layout)->getAscent();
auto width = static_cast< float >(::java::lang::Math::floor(npc(layout)->getAdvance()));
auto height = ascent * int32_t(2);
y -= height / int32_t(2) + ascent / int32_t(2);
npc(txt)->setAnchor(new ::java::awt::Rectangle(static_cast< int32_t >(x), static_cast< int32_t >(y), static_cast< int32_t >(width), static_cast< int32_t >(height)));
}
void poi::sl::draw::SLGraphics::fill(::java::awt::Shape* shape)
{
auto path = new ::java::awt::geom::Path2D_Double(npc(_transform)->createTransformedShape(shape));
auto p = npc(_group)->createFreeform();
npc(p)->setPath(path);
applyPaint(p);
npc(p)->setStrokeStyle(new ::java::lang::ObjectArray());
}
void poi::sl::draw::SLGraphics::translate(int32_t x, int32_t y)
{
npc(_transform)->translate(x, y);
}
void poi::sl::draw::SLGraphics::clip(::java::awt::Shape* s)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
java::awt::Shape* poi::sl::draw::SLGraphics::getClip()
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return nullptr;
}
void poi::sl::draw::SLGraphics::scale(double sx, double sy)
{
npc(_transform)->scale(sx, sy);
}
void poi::sl::draw::SLGraphics::drawRoundRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t arcWidth, int32_t arcHeight)
{
::java::awt::geom::RoundRectangle2D* rect = new ::java::awt::geom::RoundRectangle2D_Double(x, y, width, height, arcWidth, arcHeight);
draw(static_cast< ::java::awt::Shape* >(rect));
}
void poi::sl::draw::SLGraphics::drawString(::java::lang::String* str, int32_t x, int32_t y)
{
drawString(str, static_cast< float >(x), static_cast< float >(y));
}
void poi::sl::draw::SLGraphics::fillOval(int32_t x, int32_t y, int32_t width, int32_t height)
{
::java::awt::geom::Ellipse2D* oval = new ::java::awt::geom::Ellipse2D_Double(x, y, width, height);
fill(static_cast< ::java::awt::Shape* >(oval));
}
void poi::sl::draw::SLGraphics::fillRoundRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t arcWidth, int32_t arcHeight)
{
::java::awt::geom::RoundRectangle2D* rect = new ::java::awt::geom::RoundRectangle2D_Double(x, y, width, height, arcWidth, arcHeight);
fill(static_cast< ::java::awt::Shape* >(rect));
}
void poi::sl::draw::SLGraphics::fillArc(int32_t x, int32_t y, int32_t width, int32_t height, int32_t startAngle, int32_t arcAngle)
{
::java::awt::geom::Arc2D* arc = new ::java::awt::geom::Arc2D_Double(x, y, width, height, startAngle, arcAngle, ::java::awt::geom::Arc2D::PIE);
fill(static_cast< ::java::awt::Shape* >(arc));
}
void poi::sl::draw::SLGraphics::drawArc(int32_t x, int32_t y, int32_t width, int32_t height, int32_t startAngle, int32_t arcAngle)
{
::java::awt::geom::Arc2D* arc = new ::java::awt::geom::Arc2D_Double(x, y, width, height, startAngle, arcAngle, ::java::awt::geom::Arc2D::OPEN);
draw(static_cast< ::java::awt::Shape* >(arc));
}
void poi::sl::draw::SLGraphics::drawPolyline(::int32_tArray* xPoints, ::int32_tArray* yPoints, int32_t nPoints)
{
if(nPoints > 0) {
auto path = new ::java::awt::geom::GeneralPath();
npc(path)->moveTo(static_cast< float >((*xPoints)[int32_t(0)]), static_cast< float >((*yPoints)[int32_t(0)]));
for (auto i = int32_t(1); i < nPoints; i++)
npc(path)->lineTo(static_cast< float >((*xPoints)[i]), static_cast< float >((*yPoints)[i]));
draw(static_cast< ::java::awt::Shape* >(path));
}
}
void poi::sl::draw::SLGraphics::drawOval(int32_t x, int32_t y, int32_t width, int32_t height)
{
::java::awt::geom::Ellipse2D* oval = new ::java::awt::geom::Ellipse2D_Double(x, y, width, height);
draw(static_cast< ::java::awt::Shape* >(oval));
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t x, int32_t y, ::java::awt::Color* bgcolor, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t x, int32_t y, int32_t width, int32_t height, ::java::awt::Color* bgcolor, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t dx1, int32_t dy1, int32_t dx2, int32_t dy2, int32_t sx1, int32_t sy1, int32_t sx2, int32_t sy2, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t dx1, int32_t dy1, int32_t dx2, int32_t dy2, int32_t sx1, int32_t sy1, int32_t sx2, int32_t sy2, ::java::awt::Color* bgcolor, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t x, int32_t y, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
void poi::sl::draw::SLGraphics::dispose()
{
}
void poi::sl::draw::SLGraphics::drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
{
::java::awt::geom::Line2D* line = new ::java::awt::geom::Line2D_Double(x1, y1, x2, y2);
draw(static_cast< ::java::awt::Shape* >(line));
}
void poi::sl::draw::SLGraphics::fillPolygon(::int32_tArray* xPoints, ::int32_tArray* yPoints, int32_t nPoints)
{
auto polygon = new ::java::awt::Polygon(xPoints, yPoints, nPoints);
fill(static_cast< ::java::awt::Shape* >(polygon));
}
void poi::sl::draw::SLGraphics::fillRect(int32_t x, int32_t y, int32_t width, int32_t height)
{
auto rect = new ::java::awt::Rectangle(x, y, width, height);
fill(static_cast< ::java::awt::Shape* >(rect));
}
void poi::sl::draw::SLGraphics::drawRect(int32_t x, int32_t y, int32_t width, int32_t height)
{
auto rect = new ::java::awt::Rectangle(x, y, width, height);
draw(static_cast< ::java::awt::Shape* >(rect));
}
void poi::sl::draw::SLGraphics::drawPolygon(::int32_tArray* xPoints, ::int32_tArray* yPoints, int32_t nPoints)
{
auto polygon = new ::java::awt::Polygon(xPoints, yPoints, nPoints);
draw(static_cast< ::java::awt::Shape* >(polygon));
}
void poi::sl::draw::SLGraphics::clipRect(int32_t x, int32_t y, int32_t width, int32_t height)
{
clip(static_cast< ::java::awt::Shape* >(new ::java::awt::Rectangle(x, y, width, height)));
}
void poi::sl::draw::SLGraphics::setClip(::java::awt::Shape* clip)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
java::awt::Rectangle* poi::sl::draw::SLGraphics::getClipBounds()
{
auto c = getClip();
if(c == nullptr) {
return nullptr;
}
return npc(c)->getBounds();
}
void poi::sl::draw::SLGraphics::drawString(::java::text::AttributedCharacterIterator* iterator, int32_t x, int32_t y)
{
drawString(iterator, static_cast< float >(x), static_cast< float >(y));
}
void poi::sl::draw::SLGraphics::clearRect(int32_t x, int32_t y, int32_t width, int32_t height)
{
auto paint = getPaint();
setColor(getBackground());
fillRect(x, y, width, height);
setPaint(paint);
}
void poi::sl::draw::SLGraphics::copyArea(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy)
{
}
void poi::sl::draw::SLGraphics::setClip(int32_t x, int32_t y, int32_t width, int32_t height)
{
setClip(static_cast< ::java::awt::Shape* >(new ::java::awt::Rectangle(x, y, width, height)));
}
void poi::sl::draw::SLGraphics::rotate(double theta)
{
npc(_transform)->rotate(theta);
}
void poi::sl::draw::SLGraphics::rotate(double theta, double x, double y)
{
npc(_transform)->rotate(theta, x, y);
}
void poi::sl::draw::SLGraphics::shear(double shx, double shy)
{
npc(_transform)->shear(shx, shy);
}
java::awt::font::FontRenderContext* poi::sl::draw::SLGraphics::getFontRenderContext()
{
auto isAntiAliased = npc(::java::awt::RenderingHints::VALUE_TEXT_ANTIALIAS_ON())->equals(getRenderingHint(::java::awt::RenderingHints::KEY_TEXT_ANTIALIASING()));
auto usesFractionalMetrics = npc(::java::awt::RenderingHints::VALUE_FRACTIONALMETRICS_ON())->equals(getRenderingHint(::java::awt::RenderingHints::KEY_FRACTIONALMETRICS()));
return new ::java::awt::font::FontRenderContext(new ::java::awt::geom::AffineTransform(), isAntiAliased, usesFractionalMetrics);
}
void poi::sl::draw::SLGraphics::transform(::java::awt::geom::AffineTransform* Tx)
{
npc(_transform)->concatenate(Tx);
}
void poi::sl::draw::SLGraphics::drawImage(::java::awt::image::BufferedImage* img, ::java::awt::image::BufferedImageOp* op, int32_t x, int32_t y)
{
img = npc(op)->filter(img, nullptr);
drawImage(static_cast< ::java::awt::Image* >(img), x, y, static_cast< ::java::awt::image::ImageObserver* >(nullptr));
}
void poi::sl::draw::SLGraphics::setBackground(::java::awt::Color* color)
{
if(color == nullptr)
return;
_background = color;
}
java::awt::Color* poi::sl::draw::SLGraphics::getBackground()
{
return _background;
}
void poi::sl::draw::SLGraphics::setComposite(::java::awt::Composite* comp)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
java::awt::Composite* poi::sl::draw::SLGraphics::getComposite()
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return nullptr;
}
java::lang::Object* poi::sl::draw::SLGraphics::getRenderingHint(::java::awt::RenderingHints_Key* hintKey)
{
return npc(_hints)->get(static_cast< ::java::lang::Object* >(hintKey));
}
void poi::sl::draw::SLGraphics::setRenderingHint(::java::awt::RenderingHints_Key* hintKey, ::java::lang::Object* hintValue)
{
npc(_hints)->put(static_cast< ::java::lang::Object* >(hintKey), hintValue);
}
void poi::sl::draw::SLGraphics::drawGlyphVector(::java::awt::font::GlyphVector* g, float x, float y)
{
auto glyphOutline = npc(g)->getOutline(x, y);
fill(glyphOutline);
}
java::awt::GraphicsConfiguration* poi::sl::draw::SLGraphics::getDeviceConfiguration()
{
return npc(npc(::java::awt::GraphicsEnvironment::getLocalGraphicsEnvironment())->getDefaultScreenDevice())->getDefaultConfiguration();
}
void poi::sl::draw::SLGraphics::addRenderingHints(::java::util::Map* hints)
{
npc(this->_hints)->putAll(static_cast< ::java::util::Map* >(hints));
}
void poi::sl::draw::SLGraphics::translate(double tx, double ty)
{
npc(_transform)->translate(tx, ty);
}
void poi::sl::draw::SLGraphics::drawString(::java::text::AttributedCharacterIterator* iterator, float x, float y)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
bool poi::sl::draw::SLGraphics::hit(::java::awt::Rectangle* rect, ::java::awt::Shape* s, bool onStroke)
{
if(onStroke) {
s = npc(getStroke())->createStrokedShape(s);
}
s = npc(getTransform())->createTransformedShape(s);
return npc(s)->intersects(rect);
}
java::awt::RenderingHints* poi::sl::draw::SLGraphics::getRenderingHints()
{
return _hints;
}
void poi::sl::draw::SLGraphics::setRenderingHints(::java::util::Map* hints)
{
this->_hints = new ::java::awt::RenderingHints(nullptr);
npc(this->_hints)->putAll(static_cast< ::java::util::Map* >(hints));
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, ::java::awt::geom::AffineTransform* xform, ::java::awt::image::ImageObserver* obs)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
bool poi::sl::draw::SLGraphics::drawImage(::java::awt::Image* img, int32_t x, int32_t y, int32_t width, int32_t height, ::java::awt::image::ImageObserver* observer)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
return false;
}
java::awt::Graphics* poi::sl::draw::SLGraphics::create()
{
try {
return java_cast< ::java::awt::Graphics* >(clone());
} catch (::java::lang::CloneNotSupportedException* e) {
throw new ::java::lang::RuntimeException(static_cast< ::java::lang::Throwable* >(e));
}
}
java::awt::FontMetrics* poi::sl::draw::SLGraphics::getFontMetrics(::java::awt::Font* f)
{
return npc(::java::awt::Toolkit::getDefaultToolkit())->getFontMetrics(f);
}
void poi::sl::draw::SLGraphics::setXORMode(::java::awt::Color* c1)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
void poi::sl::draw::SLGraphics::setPaintMode()
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
void poi::sl::draw::SLGraphics::drawRenderedImage(::java::awt::image::RenderedImage* img, ::java::awt::geom::AffineTransform* xform)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
void poi::sl::draw::SLGraphics::drawRenderableImage(::java::awt::image::renderable::RenderableImage* img, ::java::awt::geom::AffineTransform* xform)
{
if(npc(log)->check(::poi::util::POILogger::WARN)) {
npc(log)->log(::poi::util::POILogger::WARN, new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(u"Not implemented"_j)}));
}
}
void poi::sl::draw::SLGraphics::applyStroke(::poi::sl::usermodel::SimpleShape* shape)
{
if(dynamic_cast< ::java::awt::BasicStroke* >(_stroke) != nullptr) {
auto bs = java_cast< ::java::awt::BasicStroke* >(_stroke);
npc(shape)->setStrokeStyle(new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(::java::lang::Double::valueOf(static_cast< double >(npc(bs)->getLineWidth())))}));
auto dash = npc(bs)->getDashArray_();
if(dash != nullptr) {
npc(shape)->setStrokeStyle(new ::java::lang::ObjectArray({static_cast< ::java::lang::Object* >(::poi::sl::usermodel::StrokeStyle_LineDash::DASH)}));
}
}
}
void poi::sl::draw::SLGraphics::applyPaint(::poi::sl::usermodel::SimpleShape* shape)
{
if(dynamic_cast< ::java::awt::Color* >(_paint) != nullptr) {
npc(shape)->setFillColor(java_cast< ::java::awt::Color* >(_paint));
}
}
extern java::lang::Class *class_(const char16_t *c, int n);
java::lang::Class* poi::sl::draw::SLGraphics::class_()
{
static ::java::lang::Class* c = ::class_(u"org.apache.poi.sl.draw.SLGraphics", 33);
return c;
}
java::awt::Graphics* poi::sl::draw::SLGraphics::create(int32_t x, int32_t y, int32_t width, int32_t height)
{
return super::create(x, y, width, height);
}
void poi::sl::draw::SLGraphics::drawPolygon(::java::awt::Polygon* p)
{
super::drawPolygon(p);
}
void poi::sl::draw::SLGraphics::fillPolygon(::java::awt::Polygon* p)
{
super::fillPolygon(p);
}
java::awt::Rectangle* poi::sl::draw::SLGraphics::getClipBounds(::java::awt::Rectangle* r)
{
return super::getClipBounds(r);
}
java::awt::FontMetrics* poi::sl::draw::SLGraphics::getFontMetrics()
{
return super::getFontMetrics();
}
java::lang::Class* poi::sl::draw::SLGraphics::getClass0()
{
return class_();
}
| 37.067278
| 248
| 0.671397
|
pebble2015
|
a4a3ad70c3c2f5b520fa2905d19efaea8f3b71f7
| 3,399
|
cpp
|
C++
|
uart.cpp
|
jekhor/pneumatic-tc-firmware
|
a532d78a154cc963d98c239c916485f5383f3dcf
|
[
"CC-BY-3.0"
] | 1
|
2018-10-08T13:28:32.000Z
|
2018-10-08T13:28:32.000Z
|
uart.cpp
|
jekhor/pneumatic-tc-firmware
|
a532d78a154cc963d98c239c916485f5383f3dcf
|
[
"CC-BY-3.0"
] | 9
|
2019-08-21T18:07:49.000Z
|
2019-09-30T19:48:28.000Z
|
uart.cpp
|
jekhor/pneumatic-tc-firmware
|
a532d78a154cc963d98c239c916485f5383f3dcf
|
[
"CC-BY-3.0"
] | null | null | null |
#include <stdio.h>
#include "uart.h"
#include <HardwareSerial.h>
//#define FULL_TERM_SUPPORT
FILE uartstream;
#define RX_BUFSIZE 80
int uart_putchar(char c, FILE *stream)
{
if (c == '\n')
Serial.write('\r');
Serial.write(c);
return 0;
}
#ifdef FULL_TERM_SUPPORT
/*
* Receive a character from the UART Rx.
*
* This features a simple line-editor that allows to delete and
* re-edit the characters entered, until either CR or NL is entered.
* Printable characters entered will be echoed using uart_putchar().
*
* Editing characters:
*
* . \b (BS) or \177 (DEL) delete the previous character
* . ^u kills the entire input buffer
* . ^w deletes the previous word
* . ^r sends a CR, and then reprints the buffer
* . \t will be replaced by a single space
*
* All other control characters will be ignored.
*
* The internal line buffer is RX_BUFSIZE (80) characters long, which
* includes the terminating \n (but no terminating \0). If the buffer
* is full (i. e., at RX_BUFSIZE-1 characters in order to keep space for
* the trailing \n), any further input attempts will send a \a to
* uart_putchar() (BEL character), although line editing is still
* allowed.
*
* Input errors while talking to the UART will cause an immediate
* return of -1 (error indication). Notably, this will be caused by a
* framing error (e. g. serial line "break" condition), by an input
* overrun, and by a parity error (if parity was enabled and automatic
* parity recognition is supported by hardware).
*
* Successive calls to uart_getchar() will be satisfied from the
* internal buffer until that buffer is emptied again.
*/
int
uart_getchar(FILE *stream)
{
uint8_t c;
char *cp, *cp2;
static char b[RX_BUFSIZE];
static char *rxp;
if (rxp == 0)
for (cp = b;;)
{
while (Serial.available() <= 0) {};
c = Serial.read();
/* behaviour similar to Unix stty ICRNL */
if (c == '\r')
c = '\n';
if (c == '\n')
{
*cp = c;
uart_putchar(c, stream);
rxp = b;
break;
}
else if (c == '\t')
c = ' ';
if ((c >= (uint8_t)' ' && c <= (uint8_t)'\x7e') ||
c >= (uint8_t)'\xa0')
{
if (cp == b + RX_BUFSIZE - 1)
uart_putchar('\a', stream);
else
{
*cp++ = c;
uart_putchar(c, stream);
}
continue;
}
switch (c)
{
case 'c' & 0x1f:
return -1;
case '\b':
case '\x7f':
if (cp > b)
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
case 'r' & 0x1f:
uart_putchar('\r', stream);
for (cp2 = b; cp2 < cp; cp2++)
uart_putchar(*cp2, stream);
break;
case 'u' & 0x1f:
while (cp > b)
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
case 'w' & 0x1f:
while (cp > b && cp[-1] != ' ')
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
}
}
c = *rxp++;
if (c == '\n')
rxp = 0;
return c;
}
#else
int
uart_getchar(FILE *stream)
{
uint8_t c;
while (Serial.available() <= 0) {};
c = Serial.read();
return c;
}
#endif
void setup_uart() {
fdev_setup_stream(&uartstream, uart_putchar, uart_getchar, _FDEV_SETUP_RW);
stdout = &uartstream;
stdin = &uartstream;
}
| 20.72561
| 76
| 0.594881
|
jekhor
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.