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 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 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 float64 1 77k ⌀ | 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 float64 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 653k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3564bdc5e8771b2b10469ece2af53e7b696679a2 | 5,968 | cpp | C++ | test.cpp | pnappa/subprocesscpp | cec20c81ebcb5823f5a5ca313ce47037b7fb7b15 | [
"MIT"
] | 5 | 2018-11-18T02:36:17.000Z | 2021-03-26T14:55:20.000Z | test.cpp | pnappa/subprocesscpp | cec20c81ebcb5823f5a5ca313ce47037b7fb7b15 | [
"MIT"
] | 6 | 2018-11-17T10:54:21.000Z | 2018-11-21T14:48:41.000Z | test.cpp | pnappa/subprocesscpp | cec20c81ebcb5823f5a5ca313ce47037b7fb7b15 | [
"MIT"
] | 1 | 2018-11-16T05:32:01.000Z | 2018-11-16T05:32:01.000Z |
/**
* Testing for the subprocess library.
* Uses the Catch2 testing library (https://github.com/catchorg/Catch2)
*/
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
#include "subprocess.hpp"
TEST_CASE("basic echo execution", "[subprocess::execute]") {
std::list<std::string> inputs;
std::vector<std::string> outputs;
subprocess::execute("/bin/echo", {"hello"}, inputs, [&](std::string s) { outputs.push_back(s); });
REQUIRE(outputs.size() == 1);
// echo appends a newline by default
REQUIRE(outputs.front() == "hello\n");
}
TEST_CASE("no trailing output newline echo execution", "[subprocess::execute]") {
std::list<std::string> inputs;
std::vector<std::string> outputs;
subprocess::execute("/bin/echo", {"-n", "hello"}, inputs, [&](std::string s) { outputs.push_back(s); });
REQUIRE(outputs.size() == 1);
REQUIRE(outputs.front() == "hello");
}
TEST_CASE("non existent executable", "[subprocess::execute]") {
// try and run a non-existent executable, what should happen..?
std::list<std::string> inputs;
std::vector<std::string> outputs;
int retval = subprocess::execute("/bin/wangwang", {}, inputs,
[](std::string) { FAIL("this functor should never have been called"); });
// process should have failed..?
REQUIRE(retval != 0);
REQUIRE(outputs.size() == 0);
}
TEST_CASE("stdin execute simple cat", "[subprocess::execute]") {
std::list<std::string> inputs = {"henlo wurld\n", "1,2,3,4\n"};
std::vector<std::string> outputs;
int retval = subprocess::execute("/bin/cat", {}, inputs, [&](std::string s) { outputs.push_back(s); });
REQUIRE(retval == 0);
REQUIRE(outputs.size() == 2);
REQUIRE(outputs.at(0) == "henlo wurld\n");
REQUIRE(outputs.at(1) == "1,2,3,4\n");
}
TEST_CASE("stdin execute simple cat no trailing newline for last input", "[subprocess::execute]") {
// executing a command with the last one missing a newline still should work the same, as the stdin stream gets closed.
std::list<std::string> inputs = {"henlo wurld\n", "1,2,3,4"};
std::vector<std::string> outputs;
int retval = subprocess::execute("/bin/cat", {}, inputs, [&](std::string s) { outputs.push_back(s); });
REQUIRE(retval == 0);
REQUIRE(outputs.size() == 2);
REQUIRE(outputs.at(0) == "henlo wurld\n");
REQUIRE(outputs.at(1) == "1,2,3,4");
}
TEST_CASE("checkOutput simple case cat", "[subprocess::checkOutput]") {
// execute bc and pass it some equations
std::list<std::string> inputs = {"1+1\n", "2^333\n", "32-32\n"};
// this one is interesting, there's more than one line of stdout for each input (bc line breaks after a certain number of characters)
std::vector<std::string> output_expected = {"2\n", "17498005798264095394980017816940970922825355447145699491406164851279\\\n", "623993595007385788105416184430592\n", "0\n"};
int retval;
std::vector<std::string> out = subprocess::checkOutput("/usr/bin/bc", {}, inputs, retval);
REQUIRE(retval == 0);
REQUIRE(out.size() == output_expected.size());
REQUIRE(out == output_expected);
}
TEST_CASE("asynchronous is actually asynchronous", "[subprocess::async]") {
std::list<std::string> inputs;
std::vector<std::string> outputs;
std::atomic<bool> isDone(false);
std::future<int> retval = subprocess::async("/usr/bin/time", {"sleep", "3"}, inputs, [&](std::string s) { isDone.store(true); outputs.push_back(s); });
// reaching here after the async starts, means that we prrroooooobbbaabbbly (unless the user has a very, very slow computer) won't be finished
REQUIRE(isDone.load() == false);
REQUIRE(retval.get() == 0);
// time has different outputs for different OSes, pluuus they will take different times to complete. all we need is some stdout.
REQUIRE(outputs.size() > 0);
}
TEST_CASE("output iterator contains everything", "[subprocess::ProcessStream]") {
// stream output from a process
std::list<std::string> inputs = {"12232\n", "hello, world\n", "Hello, world\n", "line: Hello, world!\n"};
subprocess::ProcessStream ps("/bin/grep", {"-i", "^Hello, world$"}, inputs);
std::vector<std::string> expectedOutput = {"hello, world\n", "Hello, world\n"};
std::vector<std::string> outputs;
for (std::string out : ps) {
outputs.push_back(out);
}
REQUIRE(outputs == expectedOutput);
}
TEST_CASE("output iterator handles empty output", "[subprocess::ProcessStream]") {
std::list<std::string> inputs = {"12232\n", "hello, world\n", "Hello, world\n", "line: Hello, world!\n"};
subprocess::ProcessStream ps("/bin/grep", {"-i", "^bingo bango bongo$"}, inputs);
std::vector<std::string> expectedOutput = {};
std::vector<std::string> outputs;
for (std::string out : ps) {
FAIL("why do we have output!!! - " << out);
outputs.push_back(out);
}
REQUIRE(outputs == expectedOutput);
}
TEST_CASE("output iterator all operator overload testing", "[subprocess::ProcessStream]") {
// stream output from a process
std::list<std::string> inputs = {"12232\n", "hello, world\n", "Hello, world\n", "line: Hello, world!\n"};
subprocess::ProcessStream ps("/bin/grep", {"-i", "Hello, world"}, inputs);
std::list<std::string> expectedOutput = {"hello, world\n", "Hello, world\n", "line: Hello, world!\n"};
auto beg = ps.begin();
auto end = ps.end();
REQUIRE(beg != end);
REQUIRE(*beg == expectedOutput.front());
expectedOutput.pop_front();
REQUIRE(beg != end);
++beg;
REQUIRE(*beg == expectedOutput.front());
expectedOutput.pop_front();
REQUIRE(beg != end);
beg++;
REQUIRE(*beg == expectedOutput.front());
expectedOutput.pop_front();
beg++;
REQUIRE(beg == end);
REQUIRE(expectedOutput.size() == 0);
}
// TODO: write more test cases (this seems pretty covering, let's see how coverage looks)
| 40.324324 | 177 | 0.645442 |
3565d7db77ec5a5a25550ce7576f1730494d0e6e | 1,446 | hpp | C++ | src/internal/ConversionModel.hpp | escherstair/qTsConverter | ef5c047f088d466544828d3878e808737771ae11 | [
"MIT"
] | 23 | 2020-04-10T19:37:40.000Z | 2022-03-09T07:59:04.000Z | src/internal/ConversionModel.hpp | escherstair/qTsConverter | ef5c047f088d466544828d3878e808737771ae11 | [
"MIT"
] | 21 | 2020-06-09T09:08:08.000Z | 2022-01-07T11:45:45.000Z | src/internal/ConversionModel.hpp | escherstair/qTsConverter | ef5c047f088d466544828d3878e808737771ae11 | [
"MIT"
] | 12 | 2019-01-10T07:38:29.000Z | 2020-03-26T11:19:54.000Z | #pragma once
#include <QAbstractListModel>
class ConversionModel final : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QString sourceMsg READ sourceMsg NOTIFY sourceMsgChanged)
public:
ConversionModel() = delete;
explicit ConversionModel(QObject *parent = nullptr);
ConversionModel(const ConversionModel &) = delete;
ConversionModel(ConversionModel &&) = delete;
~ConversionModel() override = default;
ConversionModel &operator=(const ConversionModel &) = delete;
ConversionModel &operator=(ConversionModel &&) = delete;
enum Roles { String = Qt::UserRole + 1 };
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void clearInput();
Q_INVOKABLE void addInput(const QString &value);
Q_INVOKABLE void setOutput(const QString &value);
Q_INVOKABLE QStringList input() noexcept;
Q_INVOKABLE void setIndex(const int &newIndex);
Q_INVOKABLE void openOutput();
Q_INVOKABLE void openOutputFolder();
QString sourceMsg() const;
signals:
void setComboBoxIndex(int index);
void sourceMsgChanged();
private:
QVector<QString> m_conversions;
QList<QString> m_input;
QString m_output;
QString m_sourceMsg;
bool inputHaveSameExtension() noexcept;
int currentIndex = 4;
};
| 26.777778 | 72 | 0.716459 |
8315eee6bdf842eba16b592ea4bdaeebf9dd2500 | 2,411 | cpp | C++ | ArrtSource/Rendering/ArrSettings.cpp | makototakemoto/azure-remote-rendering-asset-tool | 8aa05c0fc62c630e27b048c6e80e2ebecc81703b | [
"MIT"
] | null | null | null | ArrtSource/Rendering/ArrSettings.cpp | makototakemoto/azure-remote-rendering-asset-tool | 8aa05c0fc62c630e27b048c6e80e2ebecc81703b | [
"MIT"
] | null | null | null | ArrtSource/Rendering/ArrSettings.cpp | makototakemoto/azure-remote-rendering-asset-tool | 8aa05c0fc62c630e27b048c6e80e2ebecc81703b | [
"MIT"
] | null | null | null | #include "ArrSettings.h"
#include <QSettings>
void ArrSettings::SetVideoWidth(int width)
{
width = std::clamp(width, s_videoWidthMin, s_videoWidthMax);
if (m_videoWidth != width)
{
m_videoWidth = width;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SetVideoHeight(int height)
{
height = std::clamp(height, s_videoHeightMin, s_videoHeightMax);
if (m_videoHeight != height)
{
m_videoHeight = height;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SetVideoRefreshRate(int r)
{
if (m_videoRefreshRate != r)
{
m_videoRefreshRate = r;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SetFovAngle(int value)
{
if (m_fovAngle != value)
{
m_fovAngle = value;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SetCameraSpeedInPow2(int value)
{
if (m_cameraSpeedPow2 != value)
{
m_cameraSpeedPow2 = value;
Q_EMIT OptionsChanged();
}
}
float ArrSettings::GetCameraSpeedMetersPerSecond() const
{
return powf(2.0f, (float)m_cameraSpeedPow2) / 100.0f;
}
void ArrSettings::SetNearPlaneCM(int value)
{
if (m_nearPlaneCM != value)
{
m_nearPlaneCM = value;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SetFarPlaneCM(int value)
{
if (m_farPlaneCM != value)
{
m_farPlaneCM = value;
Q_EMIT OptionsChanged();
}
}
void ArrSettings::SaveSettings() const
{
QSettings s;
s.beginGroup("Video");
s.setValue("VideoWidth", m_videoWidth);
s.setValue("VideoHeight", m_videoHeight);
s.setValue("VideoRefreshRate", m_videoRefreshRate);
s.setValue("VideoFOV", m_fovAngle);
s.setValue("CameraNear", m_nearPlaneCM);
s.setValue("CameraFar", m_farPlaneCM);
s.setValue("CameraSpeed", m_cameraSpeedPow2);
s.endGroup();
}
void ArrSettings::LoadSettings()
{
QSettings s;
s.beginGroup("Video");
m_videoWidth = s.value("VideoWidth", m_videoWidth).toInt();
m_videoHeight = s.value("VideoHeight", m_videoHeight).toInt();
m_videoRefreshRate = s.value("VideoRefreshRate", m_videoRefreshRate).toInt();
m_fovAngle = s.value("VideoFOV", m_fovAngle).toInt();
m_nearPlaneCM = s.value("CameraNear", m_nearPlaneCM).toInt();
m_farPlaneCM = s.value("CameraFar", m_farPlaneCM).toInt();
m_cameraSpeedPow2 = s.value("CameraSpeed", m_cameraSpeedPow2).toInt();
s.endGroup();
}
| 23.407767 | 81 | 0.66321 |
831a7ea3291e33f19e983275f092015d8e42d978 | 7,697 | cc | C++ | src/simulation/curve.cc | kipje13/RLUtilities | eb887b312e33136b27a64516179ea812c366c2fa | [
"MIT"
] | null | null | null | src/simulation/curve.cc | kipje13/RLUtilities | eb887b312e33136b27a64516179ea812c366c2fa | [
"MIT"
] | null | null | null | src/simulation/curve.cc | kipje13/RLUtilities | eb887b312e33136b27a64516179ea812c366c2fa | [
"MIT"
] | null | null | null | #include "simulation/ogh.h"
#include "simulation/curve.h"
#include "mechanics/drive.h"
#include "misc/io.h"
float maximize_speed_with_throttle(float accel, float v0, float sf);
float maximize_speed_without_throttle(float accel, float v0, float sf);
void Curve::write_to_file(std::string prefix) {
write(points, prefix + std::string("_points.txt"));
write(tangents, prefix + std::string("_tangents.txt"));
write(curvatures, prefix + std::string("_curvatures.txt"));
write(distances, prefix + std::string("_distances.txt"));
write(max_speeds, prefix + std::string("_max_speeds.txt"));
}
Curve::Curve() {
length = -1.0f;
points = std::vector < vec3 >();
tangents = std::vector < vec3 >();
distances = std::vector < float >();
}
Curve::Curve(const std::vector<vec3> &_points) {
points = _points;
calculate_distances();
calculate_tangents();
}
Curve::Curve(std::vector< ControlPoint > info) {
// the maximum smoothing correction (radians)
// const float phi_max = 0.15f;
int ndiv = 16;
size_t num_segments = info.size() - 1;
points.reserve(ndiv * num_segments + 2);
tangents.reserve(ndiv * num_segments + 2);
curvatures.reserve(ndiv * num_segments + 2);
// apply some smoothing, since the paths that come
// from the LUT contain some wiggling as a consequence
// of coarse angular discretization
for (int i = 1; i < num_segments-1; i++) {
vec3 delta_before = normalize(info[i].p - info[i-1].p);
vec3 delta_after = normalize(info[i+1].p - info[i].p);
float phi_before = asin(dot(cross(info[i].t, delta_before), info[i].n));
float phi_after = asin(dot(cross(info[i].t, delta_after), info[i].n));
// if reasonable, apply a small rotation to control point
// tangents to smooth out unnecessary extrema
if (phi_before * phi_after > 0.0f) {
float phi;
if (fabs(phi_before) < fabs(phi_after)) {
phi = phi_before;
} else {
phi = phi_after;
}
info[i].t = dot(axis_to_rotation(info[i].n * phi), info[i].t);
}
}
for (int i = 0; i < num_segments; i++) {
vec3 P0 = info[i].p;
vec3 P1 = info[i+1].p;
vec3 V0 = info[i].t;
vec3 V1 = info[i+1].t;
vec3 N0 = info[i].n;
vec3 N1 = info[i+1].n;
OGH piece(P0, V0, P1, V1);
int is_last = (i == num_segments - 1);
for (int j = 0; j < (ndiv + is_last); j++) {
float t = float(j) / float(ndiv);
vec3 g = piece.evaluate(t);
vec3 dg = piece.tangent(t);
vec3 d2g = piece.acceleration(t);
// In rocket league, the only curvature that we care about
// is the component along the surface normal
float kappa = dot(cross(dg, d2g), normalize((1.0f - t) * N0 + t * N1)) /
(norm(dg) * norm(dg) * norm(dg));
points.push_back(g);
tangents.push_back(normalize(dg));
curvatures.push_back(kappa);
}
}
calculate_distances();
}
vec3 Curve::point_at(float s) {
s = clip(s, 0, distances[0]);
for (int i = 0; i < (points.size() - 1); i++) {
if (distances[i] >= s && s >= distances[i + 1]) {
float u = (s - distances[i + 1]) / (distances[i] - distances[i + 1]);
return lerp(points[i + 1], points[i], u);
}
}
return vec3{ 0.0f, 0.0f, 0.0f };
}
vec3 Curve::tangent_at(float s) {
s = clip(s, 0, distances[0]);
for (int i = 0; i < (points.size() - 1); i++) {
if (distances[i] >= s && s >= distances[i + 1]) {
float u = (s - distances[i + 1]) / (distances[i] - distances[i + 1]);
return normalize(lerp(tangents[i + 1], tangents[i], u));
}
}
return vec3{ 0.0f, 0.0f, 0.0f };
}
float Curve::curvature_at(float s) {
s = clip(s, 0, distances[0]);
for (int i = 0; i < (points.size() - 1); i++) {
if (distances[i] >= s && s >= distances[i + 1]) {
float delta_theta = angle_between(tangents[i + 1], tangents[i]);
float delta_s = distances[i] - distances[i + 1];
return delta_theta / delta_s;
}
}
return 0.0f;
}
float Curve::max_speed_at(float s) {
s = clip(s, 0, distances[0]);
for (int i = 0; i < (points.size() - 1); i++) {
if (distances[i] >= s && s >= distances[i + 1]) {
float u = (s - distances[i + 1]) / (distances[i] - distances[i + 1]);
return lerp(max_speeds[i + 1], max_speeds[i], u);
}
}
return 0.0f;
}
float Curve::find_nearest(const vec3 &c) {
float s = length;
float min_distance = norm(c - points[0]);
for (int i = 0; i < (points.size() - 1); i++) {
vec3 a = points[i];
vec3 b = points[i + 1];
float alpha = clip(dot(b - a, c - a) / dot(b - a, b - a), 0.0f, 1.0f);
float distance = norm(c - (a + alpha * (b - a)));
if (distance < min_distance) {
min_distance = distance;
s = lerp(distances[i], distances[i + 1], alpha);
}
}
return s;
}
void Curve::pop_front() {
if (points.size() > 0) {
points.erase(points.begin());
tangents.erase(tangents.begin());
distances.erase(distances.begin());
length = distances[0];
}
}
void Curve::calculate_distances() {
distances = std::vector<float>(points.size(), 0.0f);
int last = int(points.size() - 1);
// measure distances from the end of the curve
for (int i = last - 1; i >= 0; i--) {
distances[i] = distances[i + 1] + norm(points[i + 1] - points[i]);
}
length = distances[0];
}
void Curve::calculate_tangents() {
tangents = std::vector<vec3>(points.size());
size_t last = tangents.size() - 1;
tangents[0] = normalize(points[1] - points[0]);
for (size_t i = 1; i < last; i++) {
tangents[i] = normalize(points[i + 1] - points[i - 1]);
}
tangents[last] = normalize(points[last] - points[last - 1]);
}
float Curve::calculate_max_speeds(float v0, float vf) {
max_speeds = std::vector < float >(curvatures.size());
for (int i = 0; i < curvatures.size(); i++) {
max_speeds[i] = Drive::max_turning_speed(curvatures[i]);
}
max_speeds[0] = fminf(v0, max_speeds[0]);
max_speeds[max_speeds.size() - 1] = fminf(vf, max_speeds[max_speeds.size() - 1]);
for (int i = 1; i < curvatures.size(); i++) {
float ds = distances[i-1] - distances[i];
float attainable_speed = maximize_speed_with_throttle(
Drive::boost_accel, max_speeds[i-1], ds);
max_speeds[i] = fminf(max_speeds[i], attainable_speed);
}
float time = 0.0f;
for (int i = int(curvatures.size() - 2); i >= 0; i--) {
float ds = distances[i] - distances[i+1];
float attainable_speed = maximize_speed_without_throttle(
Drive::brake_accel, max_speeds[i+1], ds);
max_speeds[i] = fminf(max_speeds[i], attainable_speed);
time += ds / (0.5f * (max_speeds[i] + max_speeds[i+1]));
}
return time;
}
float maximize_speed_with_throttle(float accel, float v0, float sf) {
float dt = 0.008333f;
float s = 0.0f;
float v = v0;
for (int i = 0; i < 100; i++) {
float dv = (Drive::throttle_accel(v) + accel) * dt;
float ds = (v + 0.5f * dv) * dt;
v += dv;
s += ds;
if (s > sf) {
v -= (s - sf) * (dv / ds);
break;
}
}
return v;
}
float maximize_speed_without_throttle(float accel, float v0, float sf) {
float dt = 0.008333f;
float s = 0.0f;
float v = v0;
float dv = accel * dt;
for (int i = 0; i < 100; i++) {
float ds = (v + 0.5f * dv) * dt;
v += dv;
s += ds;
if (s > sf) {
v -= (s - sf) * (dv / ds);
break;
}
}
return v;
}
| 26.818815 | 84 | 0.561907 |
831ac6cfae5b232e050d907a7f6981e24e2e05ed | 104 | cc | C++ | foo/foo.cc | SoonyangZhang/ns3-static-library | 545f37fd0c2e6909a523e7fd4f2e0215ccc352b1 | [
"MIT"
] | null | null | null | foo/foo.cc | SoonyangZhang/ns3-static-library | 545f37fd0c2e6909a523e7fd4f2e0215ccc352b1 | [
"MIT"
] | null | null | null | foo/foo.cc | SoonyangZhang/ns3-static-library | 545f37fd0c2e6909a523e7fd4f2e0215ccc352b1 | [
"MIT"
] | null | null | null | #include "foo.h"
#include <iostream>
void Foo::Print(std::string content){
cb_->Print(content);
}
| 17.333333 | 38 | 0.663462 |
83242477d7238846ffa398c4f799cd29ac61a3af | 40,144 | cpp | C++ | inetsrv/msmq/src/trigger/trigserv/monitor.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | inetsrv/msmq/src/trigger/trigserv/monitor.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | inetsrv/msmq/src/trigger/trigserv/monitor.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //*******************************************************************************
//
// Class Name : CTriggerMonitor
//
// Author : James Simpson (Microsoft Consulting Services)
//
// Description : This class represents a worker thread that performs
// trigger monitoring and processing. Each instance of
// this class has it's own thread - and it derives from
// the CThread class.
//
// When | Who | Change Description
// ------------------------------------------------------------------
// 15/01/99 | jsimpson | Initial Release
//
//*******************************************************************************
#include "stdafx.h"
#include "Ev.h"
#include "monitor.hpp"
#include "mqsymbls.h"
#include "cmsgprop.hpp"
#include "triginfo.hpp"
#include "Tgp.h"
#include "mqtg.h"
#include "rwlock.h"
#include "ss.h"
#include "monitor.tmh"
#import "mqgentr.tlb" no_namespace
using namespace std;
static bool s_fReportedRuleHandlerCreationFailure = false;
static CSafeSet< _bstr_t > s_reportedRules;
static
void
ReportInvocationError(
const _bstr_t& name,
const _bstr_t& id,
HRESULT hr,
DWORD eventId
)
{
WCHAR errorVal[128];
swprintf(errorVal, L"0x%x", hr);
EvReport(
eventId,
3,
static_cast<LPCWSTR>(name),
static_cast<LPCWSTR>(id),
errorVal
);
}
//********************************************************************************
//
// Method : Constructor
//
// Description : Initializes a new trigger monitor class instance,
// and calls the constructor of the base class CThread.
//
//********************************************************************************
CTriggerMonitor::CTriggerMonitor(CTriggerMonitorPool * pMonitorPool,
IMSMQTriggersConfig * pITriggersConfig,
HANDLE * phICompletionPort,
CQueueManager * pQueueManager) : CThread(8000,CREATE_SUSPENDED,_T("CTriggerMonitor"),pITriggersConfig)
{
// Ensure that we have been given construction parameters
ASSERT(pQueueManager != NULL);
ASSERT(phICompletionPort != NULL);
// Initialise member variables.
m_phIOCompletionPort = phICompletionPort;
// Store a reference to the Queue lock manager.
pQueueManager->AddRef();
m_pQueueManager = pQueueManager;
// Store reference to the monitor pool object (parent)
pMonitorPool->AddRef();
m_pMonitorPool = pMonitorPool;
}
//********************************************************************************
//
// Method : Destructor
//
// Description : Destorys an instance of this class.
//
//********************************************************************************
CTriggerMonitor::~CTriggerMonitor()
{
}
//********************************************************************************
//
// Method : Init
//
// Description : This is an over-ride of the Init() method in the
// base class CThread. This method is called by the
// new thread prior to entering the normal-execution
// loop.
//
//********************************************************************************
bool CTriggerMonitor::Init()
{
//
// Only this TiggerMonitor thread should be executing the Init() method - check this.
//
ASSERT(this->GetThreadID() == (DWORD)GetCurrentThreadId());
TrTRACE(GENERAL, "Initialize trigger monitor ");
return (true);
}
//********************************************************************************
//
// Method : Run
//
// Description : This is an over-ride of the Init() method in the
// base class CThread. This method is called by the
// thread after calling Init(). This method contains the
// main processing loop of the worker thread. When the
// thread exits this method - it will begin shutdown
// processing.
//
// TODO notes about CQueueReference
//********************************************************************************
bool CTriggerMonitor::Run()
{
HRESULT hr = S_OK;
BOOL bGotPacket = FALSE;
DWORD dwBytesTransferred = 0;
ULONG_PTR dwCompletionKey = 0;
bool bRoutineWakeUp = false;
OVERLAPPED * pOverLapped = NULL;
// Only this TiggerMonitor thread should be executing the Run() method - check this.
ASSERT(this->GetThreadID() == (DWORD)GetCurrentThreadId());
// Write a trace message
TrTRACE(GENERAL, "Trigger monitor is runing");
while (this->IsRunning() && SUCCEEDED(hr))
{
bGotPacket = FALSE;
dwCompletionKey = 0;
// Notfiy the parent trigger pool that this thread is now entering a wait state.
MonitorEnteringWaitState(bRoutineWakeUp);
// Wait on the IO Completion port for a message to process
bGotPacket = GetQueuedCompletionStatus(
*m_phIOCompletionPort,
&dwBytesTransferred,
&dwCompletionKey,
&pOverLapped,
MONITOR_MAX_IDLE_TIME
);
// This wait is used to pause and resume the trigger service.
DWORD dwState = WaitForSingleObject(g_hServicePaused,INFINITE);
if(dwState == WAIT_FAILED)
{
TrTRACE(GENERAL, "WaitForSingleObject failed.Error code was %d.", GetLastError());
}
// Determine if this is a routine wake-up (due to either a time-out or a wake-up key being sent by the
// trigger monitor. Set a flag accordingly.
bRoutineWakeUp = ((dwCompletionKey == TRIGGER_MONITOR_WAKE_UP_KEY) || (pOverLapped == NULL));
// Notfiy the parent trigger pool that this thread is now in use.
MonitorExitingWaitState(bRoutineWakeUp);
if (bGotPacket == TRUE)
{
switch(dwCompletionKey)
{
case TRIGGER_MONITOR_WAKE_UP_KEY:
{
// we don't need to do anything here - this is simply a request
// by the administrator to 'wake-up' and check state. If this thread
// has been asked to stop, the IsRunning() controlling this loop will
// return false and we will exit this method.
break;
}
case TRIGGER_RETRY_KEY:
{
R<CQueue> pQueueRef = GetQueueReference(pOverLapped);
if(pQueueRef->IsTriggerExist())
{
TrTRACE(GENERAL, "Retry receive operation on queue: %ls", static_cast<LPCWSTR>(pQueueRef->m_bstrQueueName));
pQueueRef->RequestNextMessage(false, true);
}
break;
}
default:
{
//
// This reference indicates pending operation that ended
// At start of every pending operation AddRef() for the queue
// is performed. If the queue is valid, a real reference to
// the queue is received, in all other cases pQueueRef will
// be NULL.
//
R<CQueue> pQueueRef = GetQueueReference(pOverLapped);
if(pQueueRef->IsTriggerExist())
{
ProcessReceivedMsgEvent(pQueueRef.get());
}
break;
}
}
}
else //failed I/O operation
{
if (pOverLapped != NULL)
{
switch (pOverLapped->Internal)
{
case MQ_ERROR_QUEUE_DELETED:
{
// The completion packet was for an outstanding request on a queue that has
// been deleted. We do not need to do anything here.
TrTRACE(GENERAL, "Failed to receive message on queue because the queue has been deleted. Error 0x%Ix", pOverLapped->Internal);
// TODO - Remove queue from qmanager.
break;
}
case MQ_ERROR_BUFFER_OVERFLOW:
{
// This indicates that the buffer used for receiving the message body was not
// large enough. At this point we can attempt to re-peek the message after
// allocating a larger message body buffer.
//
// This reference indicates pending operation that ended
// At start of every pending operation AddRef() for the queue
// is performed. If the queue is valid, a real reference to
// the queue is received, in all other cases pQueueRef will
// be NULL.
//
R<CQueue> pQueueRef = GetQueueReference(pOverLapped);
TrTRACE(GENERAL, "Failed to receive message on a queue due to buffer overflow. Allocate a bigger buffer and re-peek the message");
if(pQueueRef->IsTriggerExist())
{
hr = pQueueRef->RePeekMessage();
if SUCCEEDED(hr)
{
ProcessReceivedMsgEvent(pQueueRef.get());
}
else
{
TrERROR(GENERAL, "Failed to repeek a message from queue %s. Error %!hresult!", pQueueRef->m_bstrQueueName, hr);
if(pQueueRef->IsTriggerExist())
{
//
// This will not create an infinite loop because we already allocated a big enough
// space for the message properties in RePeekMessage
//
pQueueRef->RequestNextMessage(false, false);
}
}
}
break;
}
case IO_OPERATION_CANCELLED:
{
//
// The io operation was cancelled, either the thread which initiated
// the io operation has exited or the CQueue object was removed from the
// m_pQueueManager
//
//
// This reference indicates pending operation that ended
// At start of every pending operation AddRef() for the queue
// is performed. If the queue is valid, a real reference to
// the queue is received, in all other cases pQueueRef will
// be NULL.
//
R<CQueue> pQueueRef = GetQueueReference(pOverLapped);
if(pQueueRef->IsTriggerExist())
{
TrTRACE(GENERAL, "Receive operation on queue: %ls was canceled", static_cast<LPCWSTR>(pQueueRef->m_bstrQueueName));
pQueueRef->RequestNextMessage(false, false);
}
break;
}
case E_HANDLE:
{
//
// This is a remote trigger and MSMQ on the remote machine was restarted.
//
TrERROR(GENERAL, "Failed to receive a message got E_HANDLE");
break;
}
default:
{
hr = static_cast<HRESULT>(pOverLapped->Internal);
R<CQueue> pQueueRef = GetQueueReference(pOverLapped);
TrERROR(GENERAL, "Receive operation on queue: %ls failed. Error: %!hresult!", static_cast<LPCWSTR>(pQueueRef->m_bstrQueueName), hr);
if(pQueueRef->IsTriggerExist())
{
pQueueRef->RequestNextMessage(false, false);
}
break;
}
} // end switch (pOverLapped->Internal)
} // end if (pOverLapped != NULL)
//
// Note that we do not specify an else clause for the case where pOverlapped
// is NULL. This is interpretted as the regular timeout that occurs with the
// call to GetQueuedCompletionStatus(). If this trigger monitor has been asked
// to stop - it will fall out of the outer-while loop because IsRunning() will
// return false. If this monitor has not be asked to stop, this thread will
// simply cycle around and reenter a blocked state by calling GetQueuedCompletionStatus()
//
} // end if (bGotPacket == TRUE) else clause
} // end while (this->IsRunning() && SUCCEEDED(hr))
return(SUCCEEDED(hr) ? true : false);
}
//********************************************************************************
//
// Method : Exit
//
// Description : This is an over-ride of the Exit() method in the
// base class CThread. This method is called by the
// CThread class after the Run() method has exited. It
// is used to clean up thread specific resources. In this
// case it cancels any outstanding IO requests made by
// this thread.
//
//********************************************************************************
bool CTriggerMonitor::Exit()
{
// Only this TiggerMonitor thread should be executing the Exit() method - check this.
ASSERT(this->GetThreadID() == (DWORD)GetCurrentThreadId());
//
// Cancel any outstanding IO requests from this thread on this queue handle.
//
m_pQueueManager->CancelQueuesIoOperation();
// Write a trace message
TrTRACE(GENERAL, "Exit trigger monitor");
return true;
}
//********************************************************************************
//
// Method : MonitorEnteringWaitState
//
// Description : Called by this thread before it enters a blocked
// state. It increments the count of waiting (available)
// monitor threads.
//
//********************************************************************************
void CTriggerMonitor::MonitorEnteringWaitState(bool bRoutineWakeUp)
{
LONG lWaitingMonitors = InterlockedIncrement(&(m_pMonitorPool->m_lNumberOfWaitingMonitors));
// record the tick count of when this thread last completed a request.
if (bRoutineWakeUp == false)
{
m_dwLastRequestTickCount = GetTickCount();
}
TrTRACE(GENERAL, "Entering wait state. There are now %d threads waiting trigger monitors.", lWaitingMonitors);
}
//********************************************************************************
//
// Method : MonitorExitingWaitState
//
// Description : Called by this thread immediately after it unblocks. It decrements
// the the count of waiting (available) monitor threads and conditionally
// requests that another monitor thread be created if the load on the
// system is perceived to be high.
//
//********************************************************************************
void CTriggerMonitor::MonitorExitingWaitState(bool bRoutineWakeup)
{
LONG lWaitingMonitors = InterlockedDecrement(&(m_pMonitorPool->m_lNumberOfWaitingMonitors));
// If this monitor thread was the last in the pool, then there is a possibility that we will want
// to inform the CTriggerMonitorPool instance that more threads are requried to handled the load.
// We request a new thread if and only if the following conditions have been met
//
// (a) the number of waiting monitors is 0,
// (b) the thread was unblocked due to message arrival, not routine time-out or wake-up request
// (c) the maximum number of monitors allowed is greater than one.
//
if ((lWaitingMonitors < 1) && (bRoutineWakeup == false) && (m_pITriggersConfig->GetMaxThreads() > 1))
{
TrTRACE(GENERAL, "Requesting the creation of a new monitor due to load.");
// Allocate a new CAdminMessage object instance.
CAdminMessage * pAdminMsg = new CAdminMessage(CAdminMessage::eMsgTypes::eNewThreadRequest);
// Ask the TriggerMonitorPool object to process this message
m_pMonitorPool->AcceptAdminMessage(pAdminMsg);
}
}
//********************************************************************************
//
// Method : GetQueueReference
//
// Description : This method is used to convert a pointer to an overlapped structure
// to a queue reference.
//
//********************************************************************************
CQueue* CTriggerMonitor::GetQueueReference(OVERLAPPED * pOverLapped)
{
ASSERT(("Invalid overlapped pointer", pOverLapped != NULL));
//
// Map the pOverLapped structure to the containing queue object
//
CQueue* pQueue = CONTAINING_RECORD(pOverLapped,CQueue,m_OverLapped);
//ASSERT(("Invalid queue object", pQueue->IsValid()));
//
// use the queue manager to determine if the pointer to the queue is valid and get
// a refernce to it.
// This method can return NULL in case the CQueue object was removed
//
return pQueue;
}
//********************************************************************************
// static
// Method : ReceiveMessage
//
// Description : Initializes a new trigger monitor class instance,
// and calls the constructor of the base class CThread.
//
//********************************************************************************
inline
HRESULT
ReceiveMessage(
VARIANT lookupId,
CQueue* pQueue
)
{
return pQueue->ReceiveMessageByLookupId(lookupId);
}
static CSafeSet< _bstr_t > s_reportedDownLevelQueue;
static
bool
IsValidDownLevelQueue(
CQueue* pQueue,
const CMsgProperties* pMessage
)
{
if (!pQueue->IsOpenedForReceive())
{
//
// The queue wasn't opened for receive. There is no issue with down-level queue
//
return true;
}
if (_wtoi64(pMessage->GetMsgLookupID().bstrVal) != 0)
{
//
// It's not down-level queue. Only for down-level queue the returned lookup-id is 0
//
return true;
}
//
// Report a message to event log if this is the first time
//
if (s_reportedDownLevelQueue.insert(pQueue->m_bstrQueueName))
{
EvReport(
MSMQ_TRIGGER_RETRIEVE_DOWNLEVL_QUEUE_FAILED,
1,
static_cast<LPCWSTR>(pQueue->m_bstrQueueName)
);
}
return false;
}
static
bool
IsDuplicateMessage(
CQueue* pQueue,
const CMsgProperties* pMessage
)
{
//
// This check is performed in order to eliminate duplicate last message
// handling. This may happen when transactional retrieval is aborted
// and a pending operation has already been initiated
//
if ((pQueue->GetLastMsgLookupID() == pMessage->GetMsgLookupID()) &&
//
// Down level client (W2K and NT4) doesn't support lookup id. As a result, the returned
// lookup id value is always 0.
//
(_wtoi64(pMessage->GetMsgLookupID().bstrVal) != 0)
)
{
return true;
}
//
// Update last message LookupID for this queue, before issuing any
// new pending operations
//
pQueue->SetLastMsgLookupID(pMessage->GetMsgLookupID());
return false;
}
void
CTriggerMonitor::ProcessAdminMessage(
CQueue* pQueue,
const CMsgProperties* pMessage
)
{
HRESULT hr = ProcessMessageFromAdminQueue(pMessage);
if (FAILED(hr))
return;
//
// Remove admin message from queue
//
_variant_t vLookupID = pMessage->GetMsgLookupID();
hr = ReceiveMessage(vLookupID, pQueue);
if (FAILED(hr))
{
TrERROR(GENERAL, "Failed to remove message from admin queue. Error=0x%x", hr);
}
}
void
CTriggerMonitor::ProcessTrigger(
CQueue* pQueue,
CRuntimeTriggerInfo* pTriggerInfo,
const CMsgProperties* pMessage
)
{
if (!pTriggerInfo->IsEnabled())
return;
TrTRACE(GENERAL, "Process message from queue %ls of trigger %ls", static_cast<LPCWSTR>(pTriggerInfo->m_bstrTriggerName), static_cast<LPCWSTR>(pTriggerInfo->m_bstrQueueName));
//
// Invoke the rule handlers for this trigger
//
HRESULT hr = InvokeMSMQRuleHandlers(const_cast<CMsgProperties*>(pMessage), pTriggerInfo, pQueue);
if (FAILED(hr))
{
TrERROR(GENERAL, "Failed to invoke rules on queue: %ls of trigger %ls", static_cast<LPCWSTR>(pTriggerInfo->m_bstrTriggerName), static_cast<LPCWSTR>(pTriggerInfo->m_bstrQueueName));
}
}
//********************************************************************************
//
// Method : ProcessReceivedMsgEvent
//
// Description : Called by the thread to process a message that has
// arrived on a monitored queuue. The key steps to
// processing a message are :
//
// (1) Detach the message from the queue object
// (2) If the firing trigger is not serialized, then
// request the next message on this queue.
// (3) If the firing trigger is our administration trigger,
// then defer this message to the TriggerMonitorPool class.
// (4) For each trigger attached to this queue, execute
// the CheckRuleCondition() method on its rule-handler
// (5) If the firing trigger is a serialized trigger,
// then request the next queue message now.
// (6) Delete the queue message.
//
//********************************************************************************
void CTriggerMonitor::ProcessReceivedMsgEvent(CQueue * pQueue)
{
P<CMsgProperties> pMessage = pQueue->DetachMessage();
ASSERT(this->GetThreadID() == (DWORD)GetCurrentThreadId());
TrTRACE(GENERAL, "Received message for processing from queue: %ls", static_cast<LPCWSTR>(pQueue->m_bstrQueueName));
//
// Check if this message already processed. If yes ignore it
//
if (IsDuplicateMessage(pQueue, pMessage))
{
TrTRACE(GENERAL, "Received duplicate message from queue: %ls. Message will be ignored.", (LPCWSTR)pQueue->m_bstrQueueName);
pQueue->RequestNextMessage(false, false);
return;
}
//
// Befor begin to process the message check that the queue isn't down level queue. For down-level queues
// MSMQ trigger can't recevie the message since it uses lookup-id mechanism. In such a case write
// event log messaeg and don't continue to process messages from this queue.
//
if (!IsValidDownLevelQueue(pQueue, pMessage))
{
return;
}
//
// If this is not a serialized queue, request the next message now.
//
bool fSerialized = pQueue->IsSerializedQueue();
if(!fSerialized)
{
pQueue->RequestNextMessage(false, false);
}
//
// Get the list of trigger that attached to the queue
//
RUNTIME_TRIGGERINFO_LIST triggerList = pQueue->GetTriggers();
for(RUNTIME_TRIGGERINFO_LIST::iterator it = triggerList.begin(); it != triggerList.end(); ++it)
{
R<CRuntimeTriggerInfo> pTriggerInfo = *it;
if (!pTriggerInfo->IsAdminTrigger())
{
ProcessTrigger(pQueue, pTriggerInfo.get(), pMessage);
}
else
{
ProcessAdminMessage(pQueue, pMessage);
}
}
//
// If this is a serialized queue, we request the next message after we have processed the triggers
//
if(fSerialized)
{
pQueue->RequestNextMessage(false, false);
}
}
bool s_fIssueCreateInstanceError = false;
static CSafeSet< _bstr_t > s_reportedTransactedTriggers;
static
void
ExecuteRulesInTransaction(
const _bstr_t& triggerId,
LPCWSTR registryPath,
IMSMQPropertyBagPtr& pPropertyBag,
DWORD dwRuleResult)
{
IMqGenObjPtr pGenObj;
HRESULT hr = pGenObj.CreateInstance(__uuidof(MqGenObj));
if (FAILED(hr))
{
if (!s_fIssueCreateInstanceError)
{
WCHAR errorVal[128];
swprintf(errorVal, L"0x%x", hr);
EvReport(MSMQ_TRIGGER_MQGENTR_CREATE_INSTANCE_FAILED, 1, errorVal);
s_fIssueCreateInstanceError = true;
}
TrTRACE(GENERAL, "Failed to create Generic Triggers Handler Object. Error=0x%x", hr);
throw bad_hresult(hr);
}
pGenObj->InvokeTransactionalRuleHandlers(triggerId, registryPath, pPropertyBag, dwRuleResult);
}
static
void
CreatePropertyBag(
const CMsgProperties* pMessage,
const CRuntimeTriggerInfo* pTriggerInfo,
const _bstr_t& bstrQueueFormatName,
IMSMQPropertyBagPtr& pIPropertyBag
)
{
HRESULT hr = pIPropertyBag.CreateInstance(__uuidof(MSMQPropertyBag));
if (FAILED(hr))
{
TrERROR(GENERAL, "Failed to create the MSMQPropertybag object. Error=0x%x",hr);
throw bad_hresult(hr);
}
// TODO - investigate possible memory leaks here.
// Populate the property bag with some useful information
pIPropertyBag->Write(_bstr_t(g_PropertyName_Label),pMessage->GetLabel());
pIPropertyBag->Write(_bstr_t(g_PropertyName_MsgID),pMessage->GetMessageID());
pIPropertyBag->Write(_bstr_t(g_PropertyName_MsgBody),pMessage->GetMsgBody());
pIPropertyBag->Write(_bstr_t(g_PropertyName_MsgBodyType),pMessage->GetMsgBodyType());
pIPropertyBag->Write(_bstr_t(g_PropertyName_CorID),pMessage->GetCorrelationID());
pIPropertyBag->Write(_bstr_t(g_PropertyName_MsgPriority),pMessage->GetPriority());
pIPropertyBag->Write(_bstr_t(g_PropertyName_ResponseQueueName),pMessage->GetResponseQueueName());
pIPropertyBag->Write(_bstr_t(g_PropertyName_AdminQueueName),pMessage->GetAdminQueueName());
pIPropertyBag->Write(_bstr_t(g_PropertyName_AppSpecific),pMessage->GetAppSpecific());
pIPropertyBag->Write(_bstr_t(g_PropertyName_QueueFormatname), bstrQueueFormatName);
pIPropertyBag->Write(_bstr_t(g_PropertyName_QueuePathname),pTriggerInfo->m_bstrQueueName);
pIPropertyBag->Write(_bstr_t(g_PropertyName_TriggerName),pTriggerInfo->m_bstrTriggerName);
pIPropertyBag->Write(_bstr_t(g_PropertyName_TriggerID),pTriggerInfo->m_bstrTriggerID);
pIPropertyBag->Write(_bstr_t(g_PropertyName_SentTime),pMessage->GetSentTime());
pIPropertyBag->Write(_bstr_t(g_PropertyName_ArrivedTime),pMessage->GetArrivedTime());
pIPropertyBag->Write(_bstr_t(g_PropertyName_SrcMachineId),pMessage->GetSrcMachineId());
pIPropertyBag->Write(_bstr_t(g_PropertyName_LookupId),pMessage->GetMsgLookupID());
}
static
IMSMQRuleHandlerPtr
GetRuleHandler(
CRuntimeRuleInfo* pRule
)
{
if (pRule->m_MSMQRuleHandler)
{
//
// There is an instance of MSMQRuleHandler - use it
//
return pRule->m_MSMQRuleHandler;
}
//
// Create the interface
//
IMSMQRuleHandlerPtr pMSQMRuleHandler;
HRESULT hr = pMSQMRuleHandler.CreateInstance(_T("MSMQTriggerObjects.MSMQRuleHandler"));
if ( FAILED(hr) )
{
TrERROR(GENERAL, "Failed to create MSMQRuleHandler instance for Rule: %ls. Error=0x%x",(LPCTSTR)pRule->m_bstrRuleName, hr);
if (!s_fReportedRuleHandlerCreationFailure)
{
ReportInvocationError(
pRule->m_bstrRuleName,
pRule->m_bstrRuleID,
hr,
MSMQ_TRIGGER_RULE_HANDLE_CREATION_FAILED
);
}
throw bad_hresult(hr);
}
try
{
//
// Initialise the MSMQRuleHandling object.
//
pMSQMRuleHandler->Init(
pRule->m_bstrRuleID,
pRule->m_bstrCondition,
pRule->m_bstrAction,
(BOOL)(pRule->m_fShowWindow)
);
CS lock(pRule->m_csRuleHandlerLock);
//
// We take here the lock because two threads might enter this function and try to assign the rulehandler
// to their member at the same time.
//
if (pRule->m_MSMQRuleHandler)
{
//
// There is an instance of MSMQRuleHandler - use it
//
return pRule->m_MSMQRuleHandler;
}
//
// Copy the local pointer to the rule store.
//
pRule->m_MSMQRuleHandler = pMSQMRuleHandler;
return pMSQMRuleHandler;
}
catch(const _com_error& e)
{
//
// Look if we already report about this problem. If no produce event log message
//
if (s_reportedRules.insert(pRule->m_bstrRuleID))
{
ReportInvocationError(
pRule->m_bstrRuleName,
pRule->m_bstrRuleID,
e.Error(),
MSMQ_TRIGGER_RULE_PARSING_FAILED
);
}
throw;
}
}
static
void
CheckRuleCondition(
CRuntimeRuleInfo* pRule,
IMSMQPropertyBagPtr& pIPropertyBag,
long& bConditionSatisfied
)
{
IMSMQRuleHandlerPtr pMSQMRuleHandler = GetRuleHandler(pRule);
//
// !!! This is the point at which the IMSMQRuleHandler component is invoked.
// Note: Rules are always serialized - next rule execution starts only after
// previous has completed its action
//
try
{
pMSQMRuleHandler->CheckRuleCondition(
pIPropertyBag.GetInterfacePtr(),
&bConditionSatisfied);
}
catch(const _com_error& e)
{
TrERROR(GENERAL, "Failed to process received message for rule: %ls. Error=0x%x",(LPCTSTR)pRule->m_bstrRuleName, e.Error());
//
// Look if we already report about this problem. If no produce event log message
//
if (s_reportedRules.insert(pRule->m_bstrRuleID))
{
ReportInvocationError(
pRule->m_bstrRuleName,
pRule->m_bstrRuleID,
e.Error(),
MSMQ_TRIGGER_RULE_INVOCATION_FAILED
);
}
throw;
}
TrTRACE(GENERAL, "Successfully checked condition for rule: %ls.",(LPCTSTR)pRule->m_bstrRuleName);
}
static
void
ExecuteRule(
CRuntimeRuleInfo* pRule,
IMSMQPropertyBagPtr& pIPropertyBag,
long& lRuleResult
)
{
IMSMQRuleHandlerPtr pMSQMRuleHandler = GetRuleHandler(pRule);
//
// !!! This is the point at which the IMSMQRuleHandler component is invoked.
// Note: Rules are always serialized - next rule execution starts only after
// previous has completed its action
//
try
{
pMSQMRuleHandler->ExecuteRule(
pIPropertyBag.GetInterfacePtr(),
TRUE, //serialized
&lRuleResult);
}
catch(const _com_error& e)
{
TrERROR(GENERAL, "Failed to process received message for rule: %ls. Error=0x%x",(LPCTSTR)pRule->m_bstrRuleName, e.Error());
//
// Look if we already report about this problem. If no produce event log message
//
if (s_reportedRules.insert(pRule->m_bstrRuleID))
{
ReportInvocationError(
pRule->m_bstrRuleName,
pRule->m_bstrRuleID,
e.Error(),
MSMQ_TRIGGER_RULE_INVOCATION_FAILED
);
}
throw;
}
TrTRACE(GENERAL, "Successfully pexecuted action for rule: %ls.",(LPCTSTR)pRule->m_bstrRuleName);
}
//********************************************************************************
//
// Method : InvokeRegularRuleHandlers
//
// Description : Invokes the method that will execute the rule handlers
// associated with the supplied trigger reference. This
// method also controls what information from the message
// will be copied into the property bag and passed to the
// rule-handler component(s).
//
// Note : Note that we create and populate only one instance of
// the MSMQPropertyBag object, and pass this to each
// Rule-Handler : this implies we trust each rule handler
// not to fool with the contents.
//
//********************************************************************************
HRESULT
CTriggerMonitor::InvokeRegularRuleHandlers(
IMSMQPropertyBagPtr& pIPropertyBag,
CRuntimeTriggerInfo * pTriggerInfo,
CQueue * pQueue
)
{
DWORD noOfRules = pTriggerInfo->GetNumberOfRules();
bool bExistsConditionSatisfied = false;
//
// For each rule, invoke it's associated IMSMQTriggerHandling interface.
//
for (DWORD lRuleCtr = 0; lRuleCtr < noOfRules; lRuleCtr++)
{
CRuntimeRuleInfo* pRule = pTriggerInfo->GetRule(lRuleCtr);
ASSERT(("Rule index is bigger than number of rules", pRule != NULL));
long bConditionSatisfied=false;
long lRuleResult=false;
CheckRuleCondition(
pRule,
pIPropertyBag,
bConditionSatisfied
);
if(bConditionSatisfied)
{
bExistsConditionSatisfied=true;
ExecuteRule(
pRule,
pIPropertyBag,
lRuleResult
);
if (s_reportedRules.erase(pRule->m_bstrRuleID) != 0)
{
EvReport(
MSMQ_TRIGGER_RULE_INVOCATION_SUCCESS,
2,
static_cast<LPCWSTR>(pRule->m_bstrRuleName),
static_cast<LPCWSTR>(pRule->m_bstrRuleID)
);
}
if(lRuleResult & xRuleResultStopProcessing)
{
TrTRACE(GENERAL, "Last processed rule (%ls) indicated to stop rules processing on Trigger (%ls). No further rules will be processed for this message.",(LPCTSTR)pRule->m_bstrRuleName,(LPCTSTR)pTriggerInfo->m_bstrTriggerName);
break;
}
}
}
//
// Receive message if at least one condition was satisdies
// and receive was requested
//
if (pTriggerInfo->GetMsgProcessingType() == RECEIVE_MESSAGE && bExistsConditionSatisfied)
{
_variant_t lookupId;
HRESULT hr = pIPropertyBag->Read(_bstr_t(g_PropertyName_LookupId), &lookupId);
ASSERT(("Can not read from property bag", SUCCEEDED(hr)));
hr = ReceiveMessage(lookupId, pQueue);
if ( FAILED(hr) )
{
TrERROR(GENERAL, "Failed to receive message after processing all rules");
return hr;
}
}
return S_OK;
}
void
ReportSucessfullInvocation(
CRuntimeTriggerInfo * pTriggerInfo,
bool reportRuleInvocation
)
{
if (reportRuleInvocation)
{
DWORD noOfRules = pTriggerInfo->GetNumberOfRules();
for (DWORD i = 0; i < noOfRules; ++i)
{
CRuntimeRuleInfo* pRule = pTriggerInfo->GetRule(i);
ASSERT(("Rule index is bigger than number of rules", pRule != NULL));
if (s_reportedRules.erase(pRule->m_bstrRuleID) != 0)
{
EvReport(
MSMQ_TRIGGER_RULE_INVOCATION_SUCCESS,
2,
static_cast<LPCWSTR>(pRule->m_bstrRuleName),
static_cast<LPCWSTR>(pRule->m_bstrRuleID)
);
}
}
}
if (s_reportedTransactedTriggers.erase(pTriggerInfo->m_bstrTriggerID) != 0)
{
EvReport(
MSMQ_TRIGGER_TRANSACTIONAL_INVOCATION_SUCCESS,
2,
static_cast<LPCWSTR>(pTriggerInfo->m_bstrTriggerName),
static_cast<LPCWSTR>(pTriggerInfo->m_bstrTriggerID)
);
}
}
//********************************************************************************
//
// Method : InvokeTransactionalRuleHandlers
//
// Description : Invokes the method that will execute the rule handlers
// associated with the supplied trigger reference. This
// method also controls what information from the message
// will be copied into the property bag and passed to the
// rule-handler component(s).
//
// Note : Note that we create and populate only one instance of
// the MSMQPropertyBag object, and pass this to each
// Rule-Handler : this implies we trust each rule handler
// not to fool with the contents.
//
//********************************************************************************
HRESULT
CTriggerMonitor::InvokeTransactionalRuleHandlers(
IMSMQPropertyBagPtr& pIPropertyBag,
CRuntimeTriggerInfo * pTriggerInfo
)
{
DWORD noOfRules = pTriggerInfo->GetNumberOfRules();
bool bExistsConditionSatisfied = false;
//
// For each rule, invoke it's associated IMSMQTriggerHandling interface.
//
DWORD dwRuleResult=0;
bool fNeedReportSuccessInvocation = false;
try
{
for (DWORD lRuleCtr = 0, RuleIndex=1; lRuleCtr < noOfRules; lRuleCtr++)
{
CRuntimeRuleInfo* pRule = pTriggerInfo->GetRule(lRuleCtr);
ASSERT(("Rule index is bigger than number of rules", pRule != NULL));
long bConditionSatisfied = false;
CheckRuleCondition(
pRule,
pIPropertyBag,
bConditionSatisfied
);
if(bConditionSatisfied)
{
bExistsConditionSatisfied = true;
dwRuleResult |= RuleIndex;
}
RuleIndex <<=1;
if (s_reportedRules.exist(pRule->m_bstrRuleID))
{
fNeedReportSuccessInvocation = true;
}
}
// Execute Rules && Receive message in Transaction if at least one condition was satisdies
// dwRuleResult contains the bitmask for the rules that has been satisfied (first 32 rules)
//
if (bExistsConditionSatisfied)
{
ExecuteRulesInTransaction(
pTriggerInfo->m_bstrTriggerID,
m_pMonitorPool->GetRegistryPath(),
pIPropertyBag,
dwRuleResult
);
ReportSucessfullInvocation(pTriggerInfo, fNeedReportSuccessInvocation);
}
}
catch(const _com_error& e)
{
if (s_reportedTransactedTriggers.insert(pTriggerInfo->m_bstrTriggerID))
{
ReportInvocationError(
pTriggerInfo->m_bstrTriggerName,
pTriggerInfo->m_bstrTriggerID,
e.Error(),
MSMQ_TRIGGER_TRANSACTIONAL_INVOCATION_FAILED
);
throw;
}
}
return S_OK;
}
//********************************************************************************
//
// Method : InvokeMSMQRuleHandlers
//
// Description : Invokes the method that will execute the rule handlers
// associated with the supplied trigger reference. This
// method also controls what information from the message
// will be copied into the property bag and passed to the
// rule-handler component(s).
//
// Note : Note that we create and populate only one instance of
// the MSMQPropertyBag object, and pass this to each
// Rule-Handler : this implies we trust each rule handler
// not to fool with the contents.
//
//********************************************************************************
HRESULT
CTriggerMonitor::InvokeMSMQRuleHandlers(
CMsgProperties * pMessage,
CRuntimeTriggerInfo * pTriggerInfo,
CQueue * pQueue
)
{
HRESULT hr;
try
{
TrTRACE(GENERAL, "Activate Trigger: %ls on queue: %ls.",(LPCTSTR)pTriggerInfo->m_bstrTriggerName,(LPCTSTR)pTriggerInfo->m_bstrQueueName);
//
// Create an instance of the property bag object we will pass to the rule handler,
// and populate it with the currently supported property values. Note that we pass
// the same property bag instance to all rule handlers.
//
IMSMQPropertyBagPtr pIPropertyBag;
CreatePropertyBag(pMessage, pTriggerInfo, pQueue->m_bstrFormatName, pIPropertyBag);
if (pTriggerInfo->GetMsgProcessingType() == RECEIVE_MESSAGE_XACT)
{
return InvokeTransactionalRuleHandlers(
pIPropertyBag,
pTriggerInfo
);
}
else
{
return InvokeRegularRuleHandlers(
pIPropertyBag,
pTriggerInfo,
pQueue
);
}
}
catch(const _com_error& e)
{
hr = e.Error();
}
catch(const bad_hresult& e)
{
hr = e.error();
}
catch(const bad_alloc&)
{
hr = MQTRIG_ERROR_INSUFFICIENT_RESOURCES;
}
TrERROR(GENERAL, "Failed to invoke rule handler. Error=0x%x.", hr);
return(hr);
}
//********************************************************************************
//
// Method : ProcessMessageFromAdminQueue
//
// Description : processes a message that has been received from an administration
// queue. In the current implementation this will be for messages
// indicating that underlying trigger data has changed. This method
// will construct a new admin message object and hand it over to the
// triggermonitorpool object for subsequent processing.
//
//********************************************************************************
HRESULT CTriggerMonitor::ProcessMessageFromAdminQueue(const CMsgProperties* pMessage)
{
_bstr_t bstrLabel;
CAdminMessage * pAdminMsg = NULL;
CAdminMessage::eMsgTypes eMsgType;
// Ensure that we have been passsed a valid message pointer
ASSERT(pMessage != NULL);
// get a copy of the message label
bstrLabel = pMessage->GetLabel();
// determine what sort of admin message we should be creating based on label.
if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_TRIGGERUPDATED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eTriggerUpdated;
}
else if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_TRIGGERADDED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eTriggerAdded;
}
else if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_TRIGGERDELETED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eTriggerDeleted;
}
else if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_RULEUPDATED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eRuleUpdated;
}
else if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_RULEADDED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eRuleAdded;
}
else if (_tcsstr((wchar_t*)bstrLabel,MSGLABEL_RULEDELETED) != NULL)
{
eMsgType = CAdminMessage::eMsgTypes::eRuleDeleted;
}
else
{
// unrecognized message label on an administrative message - log an error.
ASSERT(("unrecognized admin message type", 0));
// set a return code.
return E_FAIL;
}
// Allocate a new CAdminMessage object instance.
pAdminMsg = new CAdminMessage(eMsgType);
// Ask the TriggerMonitorPool object to process this message
return m_pMonitorPool->AcceptAdminMessage(pAdminMsg);
}
| 30.785276 | 247 | 0.620242 |
8325095eb50d42833b326ed5074e0ce3af0ed732 | 5,797 | hpp | C++ | include/hta/metric.hpp | metricq/hta | 36e822e965593858327c9e4cefd434977597941e | [
"BSD-3-Clause"
] | 2 | 2019-06-26T08:39:52.000Z | 2019-07-31T12:16:05.000Z | include/hta/metric.hpp | metricq/hta | 36e822e965593858327c9e4cefd434977597941e | [
"BSD-3-Clause"
] | 16 | 2018-10-11T15:45:34.000Z | 2021-09-30T12:33:18.000Z | include/hta/metric.hpp | metricq/hta | 36e822e965593858327c9e4cefd434977597941e | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2018, ZIH,
// Technische Universitaet Dresden,
// Federal Republic of Germany
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of metricq nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <hta/exception.hpp>
#include <hta/meta.hpp>
#include <hta/types.hpp>
#include <nlohmann/json_fwd.hpp>
#include <chrono>
#include <map>
#include <memory>
#include <type_traits>
#include <variant>
#include <vector>
namespace hta
{
using json = nlohmann::json;
namespace storage
{
class Metric;
class Directory;
} // namespace storage
class Level;
class Metric
{
protected:
// These classes should not be visible outside
class IntervalFactor
{
public:
IntervalFactor()
{
// needed for linking only
throw_exception("uninitialized IntervalFactor");
}
explicit IntervalFactor(int64_t factor) : factor_(factor)
{
}
Duration operator*(Duration duration) const
{
Duration::rep result;
if (__builtin_mul_overflow(factor_, duration.count(), &result))
{
throw_exception("integer overflow during interval multiplication");
}
return Duration(result);
}
Duration divide_by(Duration duration) const
{
if (duration.count() % factor_ != 0 || duration.count() <= 0)
{
throw_exception("interval ", duration.count(), " not divisible by ", factor_);
}
auto result = duration / factor_;
return Duration(result);
}
friend Duration operator*(Duration duration, IntervalFactor factor)
{
return factor * duration;
}
friend Duration operator/(Duration duration, IntervalFactor factor)
{
return factor.divide_by(duration);
}
private:
int64_t factor_;
};
public: // common
explicit Metric(std::unique_ptr<storage::Metric> storage_metric);
Metric(const Metric&) = delete;
Metric& operator=(const Metric&) = delete;
Metric(Metric&&);
Metric& operator=(Metric&&);
~Metric();
const Meta meta() const;
private: // common
void check_read() const;
void check_write() const;
public: // read
// infinity scopes are not supported here
std::vector<Row> retrieve(TimePoint begin, TimePoint end, uint64_t min_samples,
IntervalScope scope = IntervalScope{ Scope::extended, Scope::open });
std::vector<Row> retrieve(TimePoint begin, TimePoint end, Duration interval_max,
IntervalScope scope = IntervalScope{ Scope::extended, Scope::open });
std::vector<TimeValue> retrieve(TimePoint begin, TimePoint end,
IntervalScope scope = { Scope::closed, Scope::extended });
// TODO decide on proper name
std::variant<std::vector<Row>, std::vector<TimeValue>>
retrieve_flex(TimePoint begin, TimePoint end, Duration interval_max,
IntervalScope scope = IntervalScope{ Scope::extended, Scope::open },
bool smooth = true);
// technically this is IntervalScope{ Scope::closed, Scope::open } and used LAST semantics
Aggregate aggregate(TimePoint begin, TimePoint end);
size_t count(TimePoint begin, TimePoint end,
IntervalScope scope = { Scope::closed, Scope::extended });
size_t count();
std::pair<TimePoint, TimePoint> range();
private: // read
std::vector<Row> retrieve_raw_row(TimePoint begin, TimePoint end,
IntervalScope scope = IntervalScope{ Scope::closed,
Scope::extended });
public: // write
void insert(TimeValue tv);
void flush();
private: // write
void insert(Row row);
Level& get_level(Duration interval);
Level restore_level(Duration interval);
private: // common
std::unique_ptr<storage::Metric> storage_metric_;
Duration interval_min_;
Duration interval_max_;
IntervalFactor interval_factor_;
TimePoint previous_time_;
private: // write
std::map<Duration, Level> levels_;
};
static_assert(std::is_move_constructible_v<Metric>, "Metric is not movable.");
} // namespace hta
| 33.703488 | 99 | 0.656546 |
8326e6360a86c4f511e0aa48405d1956ee818a24 | 370 | cpp | C++ | test/test.cpp | xaxxon/v8toolk | 6cf23bfc0b7d20e4476aef5e0463b9316a818b90 | [
"MIT"
] | 41 | 2016-06-19T00:08:51.000Z | 2021-12-05T16:40:54.000Z | test/test.cpp | xaxxon/v8-class-wrapper | 6cf23bfc0b7d20e4476aef5e0463b9316a818b90 | [
"MIT"
] | 22 | 2016-07-03T21:23:27.000Z | 2019-12-26T15:16:36.000Z | test/test.cpp | xaxxon/v8-class-wrapper | 6cf23bfc0b7d20e4476aef5e0463b9316a818b90 | [
"MIT"
] | 7 | 2017-03-07T05:31:40.000Z | 2021-09-18T10:38:24.000Z | #include "testing.h"
#include "v8toolkit/javascript.h"
using namespace testing;
int main(int argc, char* argv[]) {
// std::cerr << fmt::format("platform::init") << std::endl;
v8toolkit::Platform::init(argc, argv, "../");
// std::cerr << fmt::format("platform::init done") << std::endl;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} | 28.461538 | 67 | 0.637838 |
8328acd8ac2648472608414f38fea4202e9411f0 | 798 | cpp | C++ | cpp/src/hackerrank/introduction/variable_sized_arrays.cpp | shunkakinoki/code | 4d67f7afb2f4c2afd39ddc7b4dd87a826ebc45a6 | [
"MIT"
] | null | null | null | cpp/src/hackerrank/introduction/variable_sized_arrays.cpp | shunkakinoki/code | 4d67f7afb2f4c2afd39ddc7b4dd87a826ebc45a6 | [
"MIT"
] | 3 | 2019-10-29T07:17:19.000Z | 2020-02-01T04:41:53.000Z | cpp/src/hackerrank/introduction/variable_sized_arrays.cpp | shunkakinoki/code | 4d67f7afb2f4c2afd39ddc7b4dd87a826ebc45a6 | [
"MIT"
] | null | null | null | // Copyright 2019 Shun Kakinoki.
// Reference: https://www.hackerrank.com/challenges/variable-sized-arrays/forum
#include <iostream>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
// Create 2d Array
int** a = new int*[n];
// Fill 2d Array with 1d Subarrays
for (int i = 0; i < n; i++) {
int k;
cin >> k;
// Create the 1d Subarray with the Given Length
int* i_arr = new int[k];
// Fill the Subarray with K Values
for (int j = 0; j < k; j++) {
cin >> i_arr[j];
}
a[i] = i_arr;
}
for (int q_num = 0; q_num < q; q_num++) {
int i, j;
cin >> i >> j;
cout << a[i][j] << endl;
}
// Delete 2d Array (Each Subarray Must Be Deleted)
for (int i = 0; i < n; i++) {
delete[] a[i];
}
delete[] a;
return 0;
}
| 17.733333 | 79 | 0.535088 |
832eee47f1b14961adee8992e6733fb907abb64b | 2,521 | cpp | C++ | plugins/community/repos/Valley/src/Common/Oneshot.cpp | guillaume-plantevin/VeeSeeVSTRack | 76fafc8e721613669d6f5ae82a0f58ce923a91e1 | [
"Zlib",
"BSD-3-Clause"
] | 233 | 2018-07-02T16:49:36.000Z | 2022-02-27T21:45:39.000Z | plugins/community/repos/Valley/src/Common/Oneshot.cpp | guillaume-plantevin/VeeSeeVSTRack | 76fafc8e721613669d6f5ae82a0f58ce923a91e1 | [
"Zlib",
"BSD-3-Clause"
] | 24 | 2018-07-09T11:32:15.000Z | 2022-01-07T01:45:43.000Z | plugins/community/repos/Valley/src/Common/Oneshot.cpp | guillaume-plantevin/VeeSeeVSTRack | 76fafc8e721613669d6f5ae82a0f58ce923a91e1 | [
"Zlib",
"BSD-3-Clause"
] | 24 | 2018-07-14T21:55:30.000Z | 2021-05-04T04:20:34.000Z | //
// Oneshot.cpp
// Author: Dale Johnson
// Contact: valley.audio.soft@gmail.com
// Date: 5/12/2017
//
// Copyright 2017 Dale Johnson
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "Oneshot.hpp"
Oneshot::Oneshot() {
_state = 0;
_sampleRate = 44100.0;
setDuration(0.100);
_elapsedTime = 0.0;
}
Oneshot::Oneshot(float duration, float sampleRate) {
_state = 0;
_sampleRate = sampleRate;
setDuration(duration);
_elapsedTime = 0.0;
}
void Oneshot::trigger() {
_state = 1;
_elapsedTime = 0.0;
}
void Oneshot::process() {
if(_elapsedTime >= _duration) {
_state = 0;
_elapsedTime = 0.0;
}
if(_state == 1) {
_elapsedTime += _deltaTime;
}
}
void Oneshot::setSampleRate(float sampleRate) {
_sampleRate = sampleRate;
_deltaTime = 1.0 / _sampleRate;
}
void Oneshot::setDuration(float duration) {
_duration = duration;
if(_duration < 0.0) {
_duration = 0.0;
}
_deltaTime = 1.0 / _sampleRate;
}
int Oneshot::getState() const {
return _state;
}
| 30.373494 | 80 | 0.713209 |
8331c091e60fd4f2cd8014bbab2cf4a9c3b66c92 | 982 | hpp | C++ | core/include/cubos/core/ecs/null_storage.hpp | GameDevTecnico/cubos | 51f89c9f3afc8afe502d167dadecab7dfe5b1c7b | [
"MIT"
] | 2 | 2021-09-28T14:13:27.000Z | 2022-03-26T11:36:48.000Z | core/include/cubos/core/ecs/null_storage.hpp | GameDevTecnico/cubos | 51f89c9f3afc8afe502d167dadecab7dfe5b1c7b | [
"MIT"
] | 72 | 2021-09-29T08:55:26.000Z | 2022-03-29T21:21:00.000Z | core/include/cubos/core/ecs/null_storage.hpp | GameDevTecnico/cubos | 51f89c9f3afc8afe502d167dadecab7dfe5b1c7b | [
"MIT"
] | null | null | null | #ifndef CUBOS_CORE_ECS_NULL_STORAGE_HPP
#define CUBOS_CORE_ECS_NULL_STORAGE_HPP
#include <cubos/core/ecs/storage.hpp>
namespace cubos::core::ecs
{
/// @brief NullStorage is a Storage implementation that doesn't keep any data, made for components
/// that don't hold any data and just work as tags.
/// @tparam T The type to be stored in the storage.
template <typename T> class NullStorage : public Storage<T>
{
public:
T* insert(uint32_t index, T value) override;
T* get(uint32_t index) override;
void erase(uint32_t index) override;
private:
T data;
};
template <typename T> T* NullStorage<T>::insert(uint32_t index, T value)
{
return &data;
}
template <typename T> T* NullStorage<T>::get(uint32_t index)
{
return &data;
}
template <typename T> void NullStorage<T>::erase(uint32_t index)
{
}
} // namespace cubos::core::ecs
#endif // ECS_NULL_STORAGE_HPP
| 24.55 | 102 | 0.657841 |
8333c2edf2802e96eea6b72e50754e66672de391 | 6,992 | cpp | C++ | firmware/Src/PHIL/DriveSystem.cpp | Northeastern-Micromouse/Master | 162d6153665da0cf58a572fc138abcd92579710d | [
"MIT"
] | null | null | null | firmware/Src/PHIL/DriveSystem.cpp | Northeastern-Micromouse/Master | 162d6153665da0cf58a572fc138abcd92579710d | [
"MIT"
] | null | null | null | firmware/Src/PHIL/DriveSystem.cpp | Northeastern-Micromouse/Master | 162d6153665da0cf58a572fc138abcd92579710d | [
"MIT"
] | null | null | null | #include "DriveSystem.h"
phil::DriveSystem::DriveSystem(
pal::Gpio* left_step,
pal::Gpio* left_dir,
pal::Gpio* right_step,
pal::Gpio* right_dir,
pal::Tim* us_tick,
float width,
float wheel_radius,
float radians_per_step):
WIDTH(width),
WHEEL_RADIUS(wheel_radius),
RADIANS_PER_STEP(radians_per_step),
left_step_(left_step),
left_dir_(left_dir),
right_step_(right_step),
right_dir_(right_dir),
us_tick_(us_tick) {
// Configure the timer to tick every us
us_tick_->SetTiming(1, 80000000 / 8000000);
}
void phil::DriveSystem::DriveEquidistant(float distance, float velocity) {
// Calculate us per step
// (rad/step) / (rad/s) = (s/step)
// Also calculate required angular velocity
// v = rw -> w = v/r
uint32_t period_us = (uint32_t)(RADIANS_PER_STEP /
(velocity / WHEEL_RADIUS) * 1000000.0);
// now figure out how long the whole move should take in us
//uint32_t time = distance / velocity * 1000000;
// now figure out how many steps should be taken
// steps = desiredDistance / (distance / step)
// = desiredDistance / (radius * radians/step)
uint32_t steps = distance / (WHEEL_RADIUS * RADIANS_PER_STEP);
// now actually drive, stopping when time is up
us_tick_->SetCount(0);
us_tick_->Enable();
ResetLeftStepCount();
ResetRightStepCount();
uint32_t us = 0;
uint32_t period_start = 0;
while (left_step_count_ < steps && right_step_count_ < steps) {
// first, update our us count using the timer count
if (us_tick_->GetUpdateFlag()) {
us++;
us_tick_->ClearUpdateFlag();
}
if (us % period_us == 0) {
// Time to raise the step pin
left_step_->Set(true);
right_step_->Set(true);
period_start = us;
}
else if (us == (period_start + STEPPER_MOTOR_STEP_TIME)) {
left_step_->Set(false);
right_step_->Set(false);
left_step_count_++;
right_step_count_++;
}
}
us_tick_->Disable();
}
void phil::DriveSystem::DriveStraight(float distance, float velocity) {
// Set both motors forward and drive an equal distance on each wheel
left_dir_->Set(false);
right_dir_->Set(true);
DriveEquidistant(distance, velocity);
}
void phil::DriveSystem::DriveRelative(
float left_distance,
float right_distance,
float average_velocity) {
left_dir_->Set(false);
right_dir_->Set(true);
// First, figure out how much time the entire operation will take using the
// given average velocity
float time = ((left_distance + right_distance) / 2.0) / average_velocity;
// Now compute the left and right velocities, and accordingly the time per
// step of the left and right wheels
float left_velocity = left_distance / time;
float right_velocity = right_distance / time;
// (rad/step) / (rad/s) = (s/step)
// Also calculate required angular velocity
// v = rw -> w = r/v
uint32_t left_period = (uint32_t)(RADIANS_PER_STEP /
(left_velocity / WHEEL_RADIUS) * 1000000.0);
uint32_t right_period = (uint32_t)(RADIANS_PER_STEP /
(right_velocity / WHEEL_RADIUS) * 1000000.0);
uint32_t left_steps = left_distance / (WHEEL_RADIUS * RADIANS_PER_STEP);
uint32_t right_steps = right_distance / (WHEEL_RADIUS * RADIANS_PER_STEP);
ResetLeftStepCount();
ResetRightStepCount();
// Now use the tick to drive the wheels with the appropriate timing
us_tick_->SetCount(0);
us_tick_->Enable();
uint32_t us = 0;
uint32_t left_period_start = 0;
uint32_t right_period_start = 0;
while (left_step_count_ < left_steps && right_step_count_ < right_steps) {
// first, update our us count using the timer count
if (us_tick_->GetUpdateFlag()) {
us++;
us_tick_->ClearUpdateFlag();
}
if (us % left_period == 0) {
// Time to raise the step pin
left_step_->Set(true);
left_period_start = us;
}
else if (us == (left_period_start + STEPPER_MOTOR_STEP_TIME)) {
left_step_->Set(false);
left_step_count_++;
}
if (us % right_period == 0) {
// Time to raise the step pin
right_step_->Set(true);
right_period_start = us;
}
else if (us == (right_period_start + STEPPER_MOTOR_STEP_TIME)) {
right_step_->Set(false);
right_step_count_++;
}
}
}
void phil::DriveSystem::DriveRadius(
float arc_length,
float radius,
float velocity) {
// We are basically driving each wheel along two different arcs, each at a
// slightly different radius based on the width of the robot. We can just
// compute the length of these arcs and call DriveRelative:
float angle = arc_length / fabs(radius);
float left_radius = fabs(radius) +
(radius > 0 ? 1.0 : -1.0) * WIDTH / 2.0;
float right_radius = fabs(radius) -
(radius > 0 ? 1.0 : -1.0) * WIDTH / 2.0;
DriveRelative(left_radius * angle, right_radius * angle, velocity);
}
void phil::DriveSystem::Turn(float radians, float angularVelocity) {
// Set motors in opposite directions and drive an equal distance on each
// wheel. Positive values for radians means a clockwise turn, negative
// means counter clockwise
left_dir_->Set(radians < 0);
right_dir_->Set(radians < 0);
// Calculate the distance each wheel needs to drive
// This is the arc length around the circle formed with the center being
// the midpoint of the bot and the radius being half the width of the drive
// system
// s = r*theta
float distance = (WIDTH / 2.0) * radians;
// Convert the angular velocity into linear velocity (being the linear
// velocity of the wheels travelling along the arc) by computing the time
// taken to travel the given number of degrees and dividing the computed
// arc length by this time
float time = radians / angularVelocity;
// Now simply drive the wheels
DriveEquidistant(distance, distance / time);
}
uint32_t phil::DriveSystem::GetLeftStepCount() const {
return left_step_count_;
}
uint32_t phil::DriveSystem::GetRightStepCount() const {
return right_step_count_;
}
void phil::DriveSystem::ResetLeftStepCount() {
left_step_count_ = 0;
}
void phil::DriveSystem::ResetRightStepCount() {
right_step_count_ = 0;
}
float phil::DriveSystem::GetWidth() const {
return WIDTH;
}
float phil::DriveSystem::GetWheelRadius() const {
return WHEEL_RADIUS;
}
| 31.638009 | 79 | 0.620566 |
8334b7c40e3b50c2589e7ad381540b3c2e397b78 | 19,662 | cpp | C++ | bmdplay.cpp | henriklied/decklink-ffmpeg | 81dd24c5021fb350a663985a02ae638e9edcde61 | [
"BSL-1.0"
] | 2 | 2015-04-26T19:52:59.000Z | 2018-12-14T07:49:46.000Z | bmdplay.cpp | henriklied/decklink-ffmpeg | 81dd24c5021fb350a663985a02ae638e9edcde61 | [
"BSL-1.0"
] | null | null | null | bmdplay.cpp | henriklied/decklink-ffmpeg | 81dd24c5021fb350a663985a02ae638e9edcde61 | [
"BSL-1.0"
] | null | null | null | /* -LICENSE-START-
** Copyright (c) 2009 Blackmagic Design
** Copyright (c) 2011 Luca Barbato
**
** Permission is hereby granted, free of charge, to any person or organization
** obtaining a copy of the software and accompanying documentation covered by
** this license (the "Software") to use, reproduce, display, distribute,
** execute, and transmit the Software, and to prepare derivative works of the
** Software, and to permit third-parties to whom the Software is furnished to
** do so, all subject to the following:
**
** The copyright notices in the Software and this entire statement, including
** the above license grant, this restriction and the following disclaimer,
** must be included in all copies of the Software, in whole or in part, and
** all derivative works of the Software, unless such copies or derivative
** works are solely in the form of machine-executable object code generated by
** a source language processor.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
** -LICENSE-END-
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <libgen.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <arpa/inet.h>
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#include "Play.h"
pthread_mutex_t sleepMutex;
pthread_cond_t sleepCond;
IDeckLinkConfiguration *deckLinkConfiguration;
AVFormatContext *ic;
AVFrame *avframe;
AVStream *audio_st = NULL;
AVStream *video_st = NULL;
DECLARE_ALIGNED(16,uint8_t,audio_buffer)[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
int data_size = sizeof(audio_buffer);
int offset = 0;
const unsigned long kAudioWaterlevel = 48000/4; /* small */
typedef struct PacketQueue {
AVPacketList *first_pkt, *last_pkt;
int nb_packets;
int size;
int abort_request;
pthread_mutex_t mutex;
pthread_cond_t cond;
} PacketQueue;
PacketQueue audioqueue;
PacketQueue videoqueue;
static int packet_queue_put(PacketQueue *q, AVPacket *pkt);
static void packet_queue_init(PacketQueue *q)
{
memset(q, 0, sizeof(PacketQueue));
pthread_mutex_init(&q->mutex, NULL);
pthread_cond_init(&q->cond, NULL);
// packet_queue_put(q, &flush_pkt);
}
static void packet_queue_flush(PacketQueue *q)
{
AVPacketList *pkt, *pkt1;
pthread_mutex_lock(&q->mutex);
for(pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
pkt1 = pkt->next;
av_free_packet(&pkt->pkt);
av_freep(&pkt);
}
q->last_pkt = NULL;
q->first_pkt = NULL;
q->nb_packets = 0;
q->size = 0;
pthread_mutex_unlock(&q->mutex);
}
static void packet_queue_end(PacketQueue *q)
{
packet_queue_flush(q);
pthread_mutex_destroy(&q->mutex);
pthread_cond_destroy(&q->cond);
}
static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
{
AVPacketList *pkt1;
/* duplicate the packet */
if (av_dup_packet(pkt) < 0)
return -1;
pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
if (!pkt1)
return -1;
pkt1->pkt = *pkt;
pkt1->next = NULL;
pthread_mutex_lock(&q->mutex);
if (!q->last_pkt)
q->first_pkt = pkt1;
else
q->last_pkt->next = pkt1;
q->last_pkt = pkt1;
q->nb_packets++;
q->size += pkt1->pkt.size + sizeof(*pkt1);
pthread_cond_signal(&q->cond);
pthread_mutex_unlock(&q->mutex);
return 0;
}
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block)
{
AVPacketList *pkt1;
int ret;
pthread_mutex_lock(&q->mutex);
for(;;) {
pkt1 = q->first_pkt;
if (pkt1) {
q->first_pkt = pkt1->next;
if (!q->first_pkt)
q->last_pkt = NULL;
q->nb_packets--;
q->size -= pkt1->pkt.size + sizeof(*pkt1);
*pkt = pkt1->pkt;
av_free(pkt1);
ret = 1;
break;
} else if (!block) {
ret = 0;
break;
} else {
pthread_cond_wait(&q->cond, &q->mutex);
}
}
pthread_mutex_unlock(&q->mutex);
return ret;
}
void *fill_queues(void *unused) {
AVPacket pkt;
AVStream *st;
while (1) {
int err = av_read_frame(ic, &pkt);
if (err) return NULL;
st = ic->streams[pkt.stream_index];
switch (st->codec->codec_type) {
case CODEC_TYPE_VIDEO:
packet_queue_put(&videoqueue, &pkt);
break;
case CODEC_TYPE_AUDIO:
packet_queue_put(&audioqueue, &pkt);
break;
}
/* while (videoqueue.nb_packets>10)
usleep(30); */
fprintf(stderr, "V %d A %d\n", videoqueue.nb_packets,
audioqueue.nb_packets);
}
return NULL;
}
void sigfunc (int signum)
{
pthread_cond_signal(&sleepCond);
}
int usage(int status)
{
HRESULT result;
int displayModeCount = 0;
fprintf(stderr,
"Usage: Capture -m <mode id> [OPTIONS]\n"
"\n"
" -m <mode id>:\n"
);
/*
while (displayModeIterator->Next(&displayMode) == S_OK)
{
char * displayModeString = NULL;
result = displayMode->GetName((const char **) &displayModeString);
if (result == S_OK)
{
BMDTimeValue frameRateDuration, frameRateScale;
displayMode->GetFrameRate(&frameRateDuration, &frameRateScale);
fprintf(stderr, " %2d: %-20s \t %li x %li \t %g FPS\n",
displayModeCount, displayModeString, displayMode->GetWidth(), displayMode->GetHeight(), (double)frameRateScale / (double)frameRateDuration);
free(displayModeString);
displayModeCount++;
}
// Release the IDeckLinkDisplayMode object to prevent a leak
displayMode->Release();
}
*/
fprintf(stderr,
" -I <input> Input connection:\n"
" 1: Composite video + analog audio\n"
" 2: Components video + analog audio\n"
" 3: HDMI video + audio\n"
" 4: SDI video + audio\n");
return status;
}
int main(int argc, char *argv[])
{
TestPattern generator;
int ch;
int videomode = 2;
int connection = 0;
int camera = 0;
char *filename=NULL;
while ((ch = getopt(argc, argv, "?hs:f:a:m:n:F:C:I:")) != -1)
{
switch (ch)
{
case 'f':
filename = strdup(optarg);
break;
case 'm':
videomode = atoi(optarg);
break;
case 'I':
connection = atoi(optarg);
break;
case 'C':
camera = atoi(optarg);
break;
case '?':
case 'h':
return usage(0);
}
}
if (!filename) return usage(1);
av_register_all();
ic = avformat_alloc_context();
av_open_input_file(&ic, filename, NULL, 0, NULL);
av_find_stream_info(ic);
for (int i =0; i<ic->nb_streams; i++) {
AVStream *st= ic->streams[i];
AVCodecContext *avctx = st->codec;
AVCodec *codec = avcodec_find_decoder(avctx->codec_id);
if (!codec || avcodec_open(avctx, codec) < 0)
fprintf(stderr, "cannot find codecs for %s\n",
(avctx->codec_type == CODEC_TYPE_AUDIO)? "Audio" : "Video");
if (avctx->codec_type == CODEC_TYPE_AUDIO) audio_st = st;
if (avctx->codec_type == CODEC_TYPE_VIDEO) video_st = st;
}
dump_format(ic, 0, filename, 0);
signal(SIGINT, sigfunc);
pthread_mutex_init(&sleepMutex, NULL);
pthread_cond_init(&sleepCond, NULL);
if (!generator.Init(videomode, connection, camera))
return 1;
return 0;
}
TestPattern::TestPattern()
{
m_audioChannelCount = 2;
m_audioSampleRate = bmdAudioSampleRate48kHz;
m_audioSampleDepth = 16;
m_running = false;
m_outputSignal = kOutputSignalDrop;
}
bool TestPattern::Init(int videomode, int connection, int camera)
{
// Initialize the DeckLink API
IDeckLinkIterator* deckLinkIterator = CreateDeckLinkIteratorInstance();
HRESULT result;
int i=0;
if (!deckLinkIterator)
{
fprintf(stderr, "This application requires the DeckLink drivers installed.\n");
goto bail;
}
do {
result = deckLinkIterator->Next(&m_deckLink);
} while(i++<camera);
if (result != S_OK)
{
fprintf(stderr, "No DeckLink PCI cards found\n");
goto bail;
}
// Obtain the audio/video output interface (IDeckLinkOutput)
if (m_deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&m_deckLinkOutput) != S_OK)
goto bail;
result = m_deckLink->QueryInterface(IID_IDeckLinkConfiguration, (void**)&deckLinkConfiguration);
if (result != S_OK)
{
fprintf(stderr, "Could not obtain the IDeckLinkConfiguration interface - result = %08x\n", result);
goto bail;
}
//XXX make it generic
switch (connection) {
case 1:
deckLinkConfiguration->SetInt(bmdDeckLinkConfigVideoInputConnection,
bmdVideoConnectionComposite);
deckLinkConfiguration->SetInt(bmdDeckLinkConfigAudioInputConnection,
bmdAudioConnectionAnalog);
break;
case 2:
deckLinkConfiguration->SetInt(bmdDeckLinkConfigVideoInputConnection,
bmdVideoConnectionComponent);
deckLinkConfiguration->SetInt(bmdDeckLinkConfigAudioInputConnection,
bmdAudioConnectionAnalog);
break;
case 3:
deckLinkConfiguration->SetInt(bmdDeckLinkConfigVideoInputConnection,
bmdVideoConnectionHDMI);
deckLinkConfiguration->SetInt(bmdDeckLinkConfigAudioInputConnection,
bmdAudioConnectionEmbedded);
break;
case 4:
deckLinkConfiguration->SetInt(bmdDeckLinkConfigVideoInputConnection,
bmdVideoConnectionSDI);
deckLinkConfiguration->SetInt(bmdDeckLinkConfigAudioInputConnection,
bmdAudioConnectionEmbedded);
break;
default:
// do not change it
break;
}
// Provide this class as a delegate to the audio and video output interfaces
m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
m_deckLinkOutput->SetAudioCallback(this);
avframe = avcodec_alloc_frame();
packet_queue_init(&audioqueue);
packet_queue_init(&videoqueue);
pthread_t th;
pthread_create(&th, NULL, fill_queues, NULL);
sleep(3);// You can add more than 1 second of buffer
// Start.
StartRunning(videomode);
pthread_mutex_lock(&sleepMutex);
pthread_cond_wait(&sleepCond, &sleepMutex);
pthread_mutex_unlock(&sleepMutex);
pthread_kill(th, 9);
fprintf(stderr, "Bailling out\n");
bail:
if (m_running == true)
{
StopRunning();
}
else
{
// Release any resources that were partially allocated
if (m_deckLinkOutput != NULL)
{
m_deckLinkOutput->Release();
m_deckLinkOutput = NULL;
}
//
if (m_deckLink != NULL)
{
m_deckLink->Release();
m_deckLink = NULL;
}
}
if (deckLinkIterator != NULL)
deckLinkIterator->Release();
return true;
}
IDeckLinkDisplayMode* TestPattern::GetDisplayModeByIndex(int selectedIndex)
{
// Populate the display mode combo with a list of display modes supported by the installed DeckLink card
IDeckLinkDisplayModeIterator* displayModeIterator;
IDeckLinkDisplayMode* deckLinkDisplayMode;
IDeckLinkDisplayMode* selectedMode = NULL;
int index = 0;
if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
goto bail;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK)
{
const char *modeName;
if (deckLinkDisplayMode->GetName(&modeName) == S_OK)
{
if (index == selectedIndex)
{
printf("Selected mode: %s\n", modeName);
selectedMode = deckLinkDisplayMode;
goto bail;
}
}
index++;
}
bail:
displayModeIterator->Release();
return selectedMode;
}
void TestPattern::StartRunning (int videomode)
{
IDeckLinkDisplayMode* videoDisplayMode = NULL;
unsigned long audioSamplesPerFrame;
// Get the display mode for 1080i 59.95
videoDisplayMode = GetDisplayModeByIndex(videomode);
if (!videoDisplayMode)
return;
m_frameWidth = videoDisplayMode->GetWidth();
m_frameHeight = videoDisplayMode->GetHeight();
videoDisplayMode->GetFrameRate(&m_frameDuration, &m_frameTimescale);
// Set the video output mode
if (m_deckLinkOutput->EnableVideoOutput(videoDisplayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
{
fprintf(stderr, "Failed to enable video output\n");
goto bail;
}
// Set the audio output mode
if (m_deckLinkOutput->EnableAudioOutput(bmdAudioSampleRate48kHz, m_audioSampleDepth, m_audioChannelCount, bmdAudioOutputStreamTimestamped) != S_OK)
/* bmdAudioOutputStreamTimestamped
bmdAudioOutputStreamContinuous */
{
fprintf(stderr, "Failed to enable audio output\n");
goto bail;
}
/*
// Generate one second of audio
m_audioBufferSampleLength = (unsigned long)((m_framesPerSecond * m_audioSampleRate * m_frameDuration) / m_frameTimescale);
m_audioBuffer = valloc(m_audioBufferSampleLength * m_audioChannelCount * (m_audioSampleDepth / 8));
if (m_audioBuffer == NULL)
{
fprintf(stderr, "Failed to allocate audio buffer memory\n");
goto bail;
}
// Zero the buffer (interpreted as audio silence)
audioSamplesPerFrame = (unsigned long)((m_audioSampleRate * m_frameDuration) / m_frameTimescale);
// Generate a frame of black
if (m_deckLinkOutput->CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrameBlack) != S_OK)
{
fprintf(stderr, "Failed to create video frame\n");
goto bail;
}
FillBlack(m_videoFrameBlack);
// Generate a frame of colour bars
if (m_deckLinkOutput->CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrameBars) != S_OK)
{
fprintf(stderr, "Failed to create video frame\n");
goto bail;
}
FillColourBars(m_videoFrameBars);
// Begin video preroll by scheduling a second of frames in hardware
m_totalFramesScheduled = 0;
*/
for (unsigned i = 0; i < 10; i++)
ScheduleNextFrame(true);
// Begin audio preroll. This will begin calling our audio callback, which will start the DeckLink output stream.
// m_audioBufferOffset = 0;
if (m_deckLinkOutput->BeginAudioPreroll() != S_OK)
{
fprintf(stderr, "Failed to begin audio preroll\n");
goto bail;
}
m_running = true;
return;
bail:
// *** Error-handling code. Cleanup any resources that were allocated. *** //
StopRunning();
}
void TestPattern::StopRunning ()
{
// Stop the audio and video output streams immediately
m_deckLinkOutput->StopScheduledPlayback(0, NULL, 0);
//
m_deckLinkOutput->DisableAudioOutput();
m_deckLinkOutput->DisableVideoOutput();
if (m_videoFrameBlack != NULL)
m_videoFrameBlack->Release();
m_videoFrameBlack = NULL;
if (m_videoFrameBars != NULL)
m_videoFrameBars->Release();
m_videoFrameBars = NULL;
if (m_audioBuffer != NULL)
free(m_audioBuffer);
m_audioBuffer = NULL;
// Success; update the UI
m_running = false;
}
void TestPattern::ScheduleNextFrame (bool prerolling)
{
AVPacket pkt;
packet_queue_get(&videoqueue, &pkt, 1);
IDeckLinkMutableVideoFrame *videoFrame;
m_deckLinkOutput->CreateVideoFrame(m_frameWidth,
m_frameHeight,
m_frameWidth*2,
bmdFormat8BitYUV,
bmdFrameFlagDefault,
&videoFrame);
void *frame;
int got_picture;
videoFrame->GetBytes(&frame);
avcodec_decode_video2(video_st->codec, avframe, &got_picture, &pkt);
if (got_picture) {
memcpy(frame, avframe->data[0],
avpicture_get_size(video_st->codec->pix_fmt,
video_st->codec->width,
video_st->codec->height));
if (m_deckLinkOutput->ScheduleVideoFrame(videoFrame,
pkt.pts,
pkt.duration,
video_st->codec->time_base.den) != S_OK)
fprintf(stderr, "Error scheduling frame\n");
}
av_free_packet(&pkt);
}
void TestPattern::WriteNextAudioSamples ()
{
uint32_t samplesWritten = 0;
AVPacket pkt = {0};
unsigned int bufferedSamples;
m_deckLinkOutput->GetBufferedAudioSampleFrameCount(&bufferedSamples);
if (bufferedSamples>kAudioWaterlevel) return;
if(!packet_queue_get(&audioqueue, &pkt, 0)) {
fprintf(stderr, "I'd quit now \n");
exit(0);
return;
}
data_size = sizeof(audio_buffer);
avcodec_decode_audio3(audio_st->codec,
(int16_t*)audio_buffer, &data_size, &pkt);
av_free_packet(&pkt);
if (m_deckLinkOutput->ScheduleAudioSamples(audio_buffer+offset,
data_size/4,
pkt.pts, 48000,
&samplesWritten) != S_OK)
fprintf(stderr, "error writing audio sample");
// offset = (samplesWritten + offset) % data_size;
fprintf(stderr, "Buffer %d, written %d, available %d offset %d\n",
bufferedSamples, samplesWritten, data_size-offset, offset);
}
/************************* DeckLink API Delegate Methods *****************************/
HRESULT TestPattern::ScheduledFrameCompleted (IDeckLinkVideoFrame* completedFrame, BMDOutputFrameCompletionResult result)
{
completedFrame->Release(); // We could recycle them probably
ScheduleNextFrame(false);
return S_OK;
}
HRESULT TestPattern::ScheduledPlaybackHasStopped ()
{
return S_OK;
}
HRESULT TestPattern::RenderAudioSamples (bool preroll)
{
// Provide further audio samples to the DeckLink API until our preferred buffer waterlevel is reached
WriteNextAudioSamples();
if (preroll)
{
// Start audio and video output
m_deckLinkOutput->StartScheduledPlayback(0, 100, 1.0);
}
return S_OK;
}
| 29.926941 | 156 | 0.616621 |
8336e89c3f1483f65210fdb034f3ae29349224b6 | 120 | cpp | C++ | app/src/main/cpp/demo.cpp | CameraKit/camerakit-android-jpegtools | 01a782f22bdb2fa9b2488731efc72693cd74f703 | [
"MIT"
] | 155 | 2018-01-22T19:14:47.000Z | 2022-03-22T03:47:48.000Z | app/src/main/cpp/demo.cpp | CameraKit/camerakit-android-jpegtools | 01a782f22bdb2fa9b2488731efc72693cd74f703 | [
"MIT"
] | 8 | 2018-03-22T23:40:28.000Z | 2021-05-31T17:43:23.000Z | app/src/main/cpp/demo.cpp | CameraKit/camerakit-android-jpegtools | 01a782f22bdb2fa9b2488731efc72693cd74f703 | [
"MIT"
] | 32 | 2018-01-29T05:05:32.000Z | 2022-03-22T03:47:50.000Z | #include <jni.h>
extern "C" JNIEXPORT void JNICALL
Java_com_jpegkit_app_MainActivity_init(JNIEnv *env, jobject obj) {
} | 24 | 66 | 0.791667 |
8338b8d9f0882b8dda0cf4e751c4f803e4450b2a | 1,820 | cpp | C++ | out/production/Hacktoberfest1/C++/mergeTwoSortedLL.cpp | bluey-crypto/Hacktoberfest | c826d5faf1d1c860dbffe665e6a7cf1e35ba76ba | [
"MIT"
] | 4 | 2019-10-12T13:54:20.000Z | 2021-07-06T22:41:12.000Z | out/production/Hacktoberfest1/C++/mergeTwoSortedLL.cpp | bluey-crypto/Hacktoberfest | c826d5faf1d1c860dbffe665e6a7cf1e35ba76ba | [
"MIT"
] | 1 | 2020-10-01T18:03:45.000Z | 2020-10-01T18:03:45.000Z | out/production/Hacktoberfest1/C++/mergeTwoSortedLL.cpp | bluey-crypto/Hacktoberfest | c826d5faf1d1c860dbffe665e6a7cf1e35ba76ba | [
"MIT"
] | 8 | 2019-10-14T17:20:09.000Z | 2020-10-03T17:27:49.000Z | #include<bits/stdc++.h>
using namespace std;
struct node {
int data;
node *next;
};
node *head1 = NULL, *head2 = NULL, *tail1 = NULL, *tail2 = NULL ;
node *temp1 = NULL, *temp2 = NULL, *temp = NULL;
void createNode1(int value){
node *temp = new node;
temp->data = value;
if(head1==NULL){
head1 = temp;
tail1 = temp;
} else {
tail1->next = temp;
tail1 = temp;
}
}
void createNode2(int value){
node *temp = new node;
temp->data = value;
if(head2==NULL){
head2 = temp;
tail2 = temp;
} else {
tail2->next = temp;
tail2 = temp;
}
}
void MoveNode(node** destRef, node** sourceRef) {
node* newNode = *sourceRef;
assert(newNode != NULL);
*sourceRef = newNode->next;
newNode->next = *destRef;
*destRef = newNode;
}
node* SortedMerge(node* a, node* b) {
node dummy;
node* tail = &dummy;
dummy.next = NULL;
while (1)
{
if (a == NULL) {
tail->next = b;
break;
}
else if (b == NULL) {
tail->next = a;
break;
}
if (a->data <= b->data)
MoveNode(&(tail->next), &a);
else
MoveNode(&(tail->next), &b);
tail = tail->next;
}
return(dummy.next);
}
void display(node *head) {
node *temp = new node;
temp = head;
while(temp != NULL){
cout<<temp -> data<<" ";
temp = temp -> next;
}
}
int main(){
for(int i=1;i<3;i++){
createNode1(i);
}
for(int i=1;i<6;i++){
createNode2(i);
}
node * head = SortedMerge(head1, head2);
display(head);
} | 21.411765 | 66 | 0.453846 |
833c211d4e2ca4b9236fb5327ad551adbcae2eab | 2,511 | cpp | C++ | Application/decode.cpp | TheRising-cxf/Test | 2b827482688446988e8c67ac5a099498ae810097 | [
"MIT"
] | null | null | null | Application/decode.cpp | TheRising-cxf/Test | 2b827482688446988e8c67ac5a099498ae810097 | [
"MIT"
] | null | null | null | Application/decode.cpp | TheRising-cxf/Test | 2b827482688446988e8c67ac5a099498ae810097 | [
"MIT"
] | null | null | null | /**
* @file decode.cpp
* @author Haoxuan Zhang (zhanghx59@mail2.sysu.edu.cn)
* @brief
* @version 0.1
* @date 2019-12-19
*
* @copyright Copyright (c) 2019
*
*/
#include "decode.h"
#include "ifft2d.h"
Mat getDecodeImg(fftPair *encode, fftPair *origin, vector<vector<float> > &vec){
int width = encode->img.cols;
int height = encode->img.rows;
Mat middle(height, width, CV_32FC3, Scalar(0));
for(int k = 0; k < 3; ++k){
for(int i = 0; i < height; ++i){
for(int j = 0; j < width; ++j){
float pixel = encode->result_real[k][j][i] - origin->result_real[k][j][i];
if(pixel <= 0) middle.at<Vec3f>(i, j)[k] = 0;
else if(pixel >= 1) middle.at<Vec3f>(i, j)[k] = 1;
else middle.at<Vec3f>(i, j)[k] = pixel;
}
}
}
int half_height = height / 2;
Mat res(height, width, CV_32FC3, Scalar(0));
for(int k = 0; k < 3; ++k){
for(int i = 0; i < half_height; ++i){
for(int j = 0; j < width; ++j){
res.at<Vec3f>(vec[0][i], vec[1][j])[k] = middle.at<Vec3f>(i, j)[k];
}
}
}
for(int k = 0; k < 3; ++k){
for(int i = 0; i < half_height; ++i){
for(int j = 0; j < width; ++j){
res.at<Vec3f>(height - 1 - i, width - 1 - j)[k] = res.at<Vec3f>(i, j)[k];
}
}
}
return res;
}
Mat decode(Mat &ifft_img, Mat &ori_img, vector<vector<float> > &vec){
fftPair origin(ori_img);
fftPair encode(ifft_img);
fft2d(&origin);
fft2d(&encode);
Mat res = getDecodeImg(&encode, &origin, vec);
return res;
}
// Interface
Mat decode(Mat img, Mat ori_img){
int ori_height = img.rows;
int ori_width = img.cols;
fftPair encode(img);
fftPair origin(ori_img);
fft2d(&encode);
fft2d(&origin);
int height = encode.img.rows;
int width = encode.img.cols;
int half_height = height / 2;
vector<vector<float> > vec;
vector<float> M;
vector<float> N;
for(int i = 0; i < half_height; ++i){
M.push_back(i);
}
for(int i = 0; i < width; ++i){
N.push_back(i);
}
getRandSequence(M, 0, half_height);
getRandSequence(N, 0, width);
vec.push_back(M);
vec.push_back(N);
Mat res = getDecodeImg(&encode, &origin, vec);
resize(res, res, Size(ori_width, ori_height));
if(res.type() != CV_8UC3){
res *= 255;
res.convertTo(res, CV_8UC3);
}
return res;
} | 26.15625 | 90 | 0.526483 |
833f3859eee6677a5ed2c79c24d3646f0f1adc37 | 1,703 | cc | C++ | datasource_c_api.cc | baiyicanggou/mapnik_mvt | 9bde52fa9958d81361c015c816858534ec0931bb | [
"Apache-2.0"
] | null | null | null | datasource_c_api.cc | baiyicanggou/mapnik_mvt | 9bde52fa9958d81361c015c816858534ec0931bb | [
"Apache-2.0"
] | null | null | null | datasource_c_api.cc | baiyicanggou/mapnik_mvt | 9bde52fa9958d81361c015c816858534ec0931bb | [
"Apache-2.0"
] | null | null | null | #include "datasource_c_api.h"
#include "datasource_impl.hh"
#include "cached_datasource.hh"
#include "datasource_impl.hh"
#include "feature_impl.hh"
#include "geometry_datasource.hh"
#include "make_geometry_datasource.hh"
#include "make_raster_datasource.hh"
#include "raster_datasource.hh"
#include "raster_impl.hh"
#ifdef __cplusplus
extern "C" {
#endif
mapnik_datasource_t *
mapnik_geometry_datasource(mapnik_feature_collection_t *feature) {
mapnik::datasource_ptr ptr =
flywave::nik::make_geometry_datasource(feature->fc);
mapnik_datasource_t *map = new mapnik_datasource_t{ptr};
return map;
}
mapnik_datasource_t *mapnik_raster_datasource(mapnik_raster_data_t *raster) {
mapnik::datasource_ptr ptr =
flywave::nik::make_raster_datasource(raster->ds, raster->tile_size);
mapnik_datasource_t *map = new mapnik_datasource_t{ptr};
return map;
}
mapnik_datasource_t *
mapnik_tiled_raster_datasource(raster_tiled_data_t *raster) {
mapnik::datasource_ptr ptr = flywave::nik::make_raster_datasource(
raster->ds, raster->extent, raster->row, raster->col, raster->tile_size);
mapnik_datasource_t *map = new mapnik_datasource_t{ptr};
return map;
}
int mapnik_datasource_type(mapnik_datasource_t *m) {
if (m != NULL) {
return m->ptr->type();
}
return -1;
}
double *mapnik_datasource_envelope(mapnik_datasource_t *m, double *bbox) {
if (m != NULL) {
mapnik::box2d<double> b = m->ptr->envelope();
bbox[0] = b.minx();
bbox[1] = b.miny();
bbox[2] = b.maxx();
bbox[3] = b.maxy();
return bbox;
}
return NULL;
}
void mapnik_datasource_free(mapnik_datasource_t *m) {
if (m != NULL) {
delete m;
}
}
#ifdef __cplusplus
}
#endif
| 25.044118 | 79 | 0.728127 |
83417e651b53a07e58a78f4b6b462e643afc026d | 1,369 | cpp | C++ | test/mpi/mpi_common.cpp | ricosjp/monolish-debian-package | 4e8087804e8ab03484d44106599233ed5080ba54 | [
"Apache-2.0"
] | 172 | 2021-04-05T10:04:40.000Z | 2022-03-28T14:30:38.000Z | test/mpi/mpi_common.cpp | ricosjp/monolish | 12757f93883830a89820507d44e2eea20b5026e1 | [
"Apache-2.0"
] | 96 | 2021-04-06T01:53:44.000Z | 2022-03-09T07:27:09.000Z | test/mpi/mpi_common.cpp | termoshtt/monolish | 1cba60864002b55bc666da9baa0f8c2273578e01 | [
"Apache-2.0"
] | 8 | 2021-04-05T13:21:07.000Z | 2022-03-09T23:24:06.000Z | #include "monolish_mpi.hpp"
template <typename T> T test_sum(std::vector<T> &vec) {
monolish::mpi::comm &comm = monolish::mpi::comm::get_instance();
double sum = 0;
for (size_t i = 0; i < vec.size(); i++) {
sum += vec[i];
}
return comm.Allreduce(sum);
}
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "error!, $1:vector size" << std::endl;
return 1;
}
size_t size = atoi(argv[1]);
std::cout << "size: " << size << std::endl;
// monolish::util::set_log_level(3);
// monolish::util::set_log_filename("./monolish_test_log.txt");
monolish::mpi::comm &comm = monolish::mpi::comm::get_instance();
comm.Init(argc, argv);
int rank = comm.get_rank();
int procs = comm.get_size();
std::cout << "I am" << rank << "/" << procs << std::endl;
std::vector<double> dvec(size, 1);
std::vector<float> fvec(size, 1);
std::vector<int> ivec(size, 1);
std::vector<size_t> svec(size, 1);
comm.Barrier();
if (test_sum(dvec) != size * procs) {
std::cout << "error in double" << std::endl;
}
if (test_sum(fvec) != size * procs) {
std::cout << "error in float" << std::endl;
}
if (test_sum(ivec) != size * procs) {
std::cout << "error in int" << std::endl;
}
if (test_sum(svec) != size * procs) {
std::cout << "error in size_t" << std::endl;
}
comm.Finalize();
return 0;
}
| 22.816667 | 66 | 0.578524 |
8343dbe73934f02650d375c56dab01cec36f0774 | 16,618 | cxx | C++ | ITS/AliITSPid.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 52 | 2016-12-11T13:04:01.000Z | 2022-03-11T11:49:35.000Z | ITS/AliITSPid.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 1,388 | 2016-11-01T10:27:36.000Z | 2022-03-30T15:26:09.000Z | ITS/AliITSPid.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 275 | 2016-06-21T20:24:05.000Z | 2022-03-31T13:06:19.000Z | //------------------------------------------------------------//
// Class for identification of pions,kaons and protons in ITS //
// Prior particles population (probabilities) are taken from //
// Hijing event generator. //
//------------------------------------------------------------//
// #include <stdlib.h>
#include "AliITSPid.h"
//#include "TMath.h"
#include <Riostream.h>
#include <TClonesArray.h>
#include <TVector.h>
#include "AliKalmanTrack.h"
#include "AliITSIOTrack.h"
#include "AliITStrackV2.h"
#include <TF1.h>
ClassImp(AliITSPid)
AliITSPid::AliITSPid(const AliITSPid &source) : TObject(source),
fMxtrs(source.fMxtrs),
fTrs(source.fTrs),
fWpi(source.fWpi),
fWk(source.fWk),
fWp(source.fWp),
fRpik(source.fRpik),
fRppi(source.fRppi),
fRpka(source.fRpka),
fRp(source.fRp),
fPcode(source.fPcode),
fSigmin(source.fSigmin),
fSilent(source.fSilent),
fCutKa(source.fCutKa),
fCutPr(source.fCutPr),
fggpi(source.fggpi),
fggka(source.fggka),
fggpr(source.fggpr){
// Copy constructor. This is a function which is not allowed to be
}
//______________________________________________________________________
AliITSPid& AliITSPid::operator=(const AliITSPid& source){
// Assignment operator. This is a function which is not allowed to be
this->~AliITSPid();
new(this) AliITSPid(source);
return *this;
}
//
Float_t AliITSPid::Qtrm(Int_t track) {
//
// This calculates truncated mean signal for given track.
//
TVector q(*( this->GetVec(track) ));
Int_t ml=(Int_t)q(0);
if(ml<1)return 0.;
if(ml>6)ml=6;
float vf[6];
Int_t nl=0; for(Int_t i=0;i<ml;i++){if(q(i)>fSigmin){vf[nl]=q(i+1);nl++;}}
if(nl==0)return 0.;
switch(nl){
case 1:q(6)=q(1); break;
case 2:q(6)=(q(1)+q(2))/2.; break;
default:
for(int fi=0;fi<2;fi++){
Int_t swap;
do{ swap=0; float qmin=vf[fi];
for(int j=fi+1;j<nl;j++)
if(qmin>vf[j]){qmin=vf[j];vf[j]=vf[fi];vf[fi]=qmin;swap=1;};
}while(swap==1);
}
q(6)= (vf[0]+vf[1])/2.;
break;
}
for(Int_t i=0;i<nl;i++){q(i+1)=vf[i];} this->SetVec(track,q);
return (q(6));
}
Float_t AliITSPid::Qtrm(Float_t qarr[6],Int_t narr) const{
//
//This calculates truncated mean signal for given signal set.
//
Float_t q[6],qm,qmin;
Int_t nl,ml;
if(narr>0&&narr<7){ml=narr;}else{return 0;};
nl=0; for(Int_t i=0;i<ml;i++){if(qarr[i]>fSigmin){q[nl]=qarr[i];nl++;}}
if(nl==0)return 0.;
switch(nl){
case 1:qm=q[0]; break;
case 2:qm=(q[0]+q[1])/2.; break;
default:
Int_t swap;
for(int fi=0;fi<2;fi++){
do{ swap=0; qmin=q[fi];
for(int j=fi+1;j<nl;j++)
if(qmin>q[j]){qmin=q[j];q[j]=q[fi];q[fi]=qmin;swap=1;};
}while(swap==1);
}
qm= (q[0]+q[1])/2.;
break;
}
return qm;
}
Int_t AliITSPid::Wpik(Float_t pm,Float_t q){
//Calcutates probabilityes of pions and kaons
//Returns particle code for dominant probability.
Double_t par[6];
for(int i=0;i<6;i++){par[i]=fGGpi[i]->Eval(pm);}
fggpi->SetParameters(par);
for(int i=0;i<3;i++){par[i]=fGGka[i]->Eval(pm);}
fggka->SetParameters(par);
Float_t ppi=fggpi->Eval(q);
Float_t pka=fggka->Eval(q);
Float_t p=ppi+pka;
/*
if(!fSilent){
fggka->Print();
fggpi->Print();
if(p>0)cout<<" ppi,pka="<<ppi/p<<" "<<pka/p<<endl;
}
*/
if(p>0){
ppi=ppi/p;
pka=pka/p;
fWp=0.; fWpi=ppi; fWk=pka;
if( pka>ppi){return fPcode=321;}else{return fPcode=211;}
}else{return 0;}
}
//-----------------------------------------------------------
Int_t AliITSPid::Wpikp(Float_t pm,Float_t q){
//
//Calcutates probabilityes of pions,kaons and protons.
//Returns particle code for dominant probability.
Double_t par[6];
for(int i=0;i<6;i++){par[i]=fGGpi[i]->Eval(pm);}
fggpi->SetParameters(par);
for(int i=0;i<3;i++){par[i]=fGGka[i]->Eval(pm);}
fggka->SetParameters(par);
for(int i=0;i<3;i++){par[i]=fGGpr[i]->Eval(pm);}
fggpr->SetParameters(par);
Float_t p,ppi,pka,ppr;
if( q>(fggpr->GetParameter(1)+fggpr->GetParameter(2)) )
{ p=1.0; ppr=1.0; ppi=pka=0.0;
}else{
ppi=fggpi->Eval(q);
pka=fggka->Eval(q);
ppr=fggpr->Eval(q);
p=ppi+pka+ppr;
}
if(p>0){
ppi=ppi/p;
pka=pka/p;
ppr=ppr/p;
fWp=ppr; fWpi=ppi; fWk=pka;
//if(!fSilent)cout<<" ppi,pka,ppr="<<ppi<<" "<<pka<<" "<<ppr<<endl;
if( ppi>pka&&ppi>ppr )
{return fPcode=211;}
else{ if(pka>ppr){return fPcode=321;}else{return fPcode=2212;}
}
}else{return 0;}
}
//-----------------------------------------------------------
Int_t AliITSPid::GetPcode(TClonesArray* rps,Float_t pm)
{
//Returns particle code
Info("GetPcode","method not implemented - Inputs TClonesArray *%x , Float_t %f",rps,pm);
return 0;
}
//-----------------------------------------------------------
Int_t AliITSPid::GetPcode(AliKalmanTrack *track)
{
//Returns particle code for given track.
Double_t xk,par[5]; track->GetExternalParameters(xk,par);
Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
Float_t lam=TMath::ATan(par[3]);
Float_t pt1=TMath::Abs(par[4]);
Float_t mom=1./(pt1*TMath::Cos(lam));
Float_t dedx=track->GetPIDsignal();
Int_t pcode=GetPcode(dedx/40.,mom);
// cout<<"TPCtrack dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
return pcode?pcode:211;
}
//------------------------------------------------------------
Int_t AliITSPid::GetPcode(AliITSIOTrack *track)
{
//Returns particle code for given track(V1).
Double_t px,py,pz;
px=track->GetPx();
py=track->GetPy();
pz=track->GetPz();
Float_t mom=TMath::Sqrt(px*px+py*py+pz*pz);
//???????????????????
// Float_t dedx=1.0;
Float_t dedx=track->GetdEdx();
//???????????????????
Int_t pcode=GetPcode(dedx,mom);
// cout<<"ITSV1 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
return pcode?pcode:211;
}
//-----------------------------------------------------------
Int_t AliITSPid::GetPcode(AliITStrackV2 *track)
{
//Returns particle code for given track(V2).
if(track==0)return 0;
// track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
track->PropagateTo(3.,0.0028,65.19);
//track->PropagateToVertex(); Not needed. (I.B.)
Double_t xk,par[5]; track->GetExternalParameters(xk,par);
Float_t lam=TMath::ATan(par[3]);
Float_t pt1=TMath::Abs(par[4]);
Float_t mom=0.;
if( (pt1*TMath::Cos(lam))!=0. ){ mom=1./(pt1*TMath::Cos(lam)); }else{mom=0.;};
Float_t dedx=track->GetdEdx();
// cout<<"lam,pt1,mom,dedx="<<lam<<","<<pt1<<","<<mom<<","<<dedx<<endl;
Int_t pcode=GetPcode(dedx,mom);
// cout<<"ITS V2 dedx,mom,pcode="<<dedx<<","<<mom<<","<<pcode<<endl;
return pcode?pcode:211;
}
//-----------------------------------------------------------
Int_t AliITSPid::GetPcode(Float_t q,Float_t pm)
{
//Returns particle code for given signal and momentum.
fWpi=fWk=fWp=0.; fPcode=0;
if ( pm<=0.400 )
{ if( q<fCutKa->Eval(pm) )
{return Pion();}
else{ if( q<fCutPr->Eval(pm) )
{return Kaon();}
else{return Proton();}
}
}
if ( pm<=0.750 ){
if ( q>fCutPr->Eval(pm) ){
return Proton();
}
else {
return Wpik(pm,q);
}
}
if( pm<=1.10 ){ return Wpikp(pm,q); }
return fPcode;
}
//-----------------------------------------------------------
void AliITSPid::SetCut(Int_t n,Float_t pm,Float_t pilo,Float_t pihi,
Float_t klo,Float_t khi,Float_t plo,Float_t phi)
{
// The cut-table initializer method.
fCut[n][0]=pm;
fCut[n][1]=pilo;
fCut[n][2]=pihi;
fCut[n][3]=klo;
fCut[n][4]=khi;
fCut[n][5]=plo;
fCut[n][6]=phi;
return ;
}
//------------------------------------------------------------
void AliITSPid::SetVec(Int_t ntrack,const TVector& info) const
{
//Store track info in tracls table
TClonesArray& arr=*fTrs;
new( arr[ntrack] ) TVector(info);
}
//-----------------------------------------------------------
TVector* AliITSPid::GetVec(Int_t ntrack) const
{
//Get given track from track table
TClonesArray& arr=*fTrs;
return (TVector*)arr[ntrack];
}
//-----------------------------------------------------------
void AliITSPid::SetEdep(Int_t track,Float_t Edep)
{
//Set dEdx for given track
TVector xx(0,11);
if( ((TVector*)fTrs->At(track))->IsValid() )
{TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
Int_t j=(Int_t)xx(0); if(j>4)return;
xx(++j)=Edep;xx(0)=j;
TClonesArray &arr=*fTrs;
new(arr[track])TVector(xx);
}
//-----------------------------------------------------------
void AliITSPid::SetPmom(Int_t track,Float_t Pmom)
{
//Set momentum for given track
TVector xx(0,11);
if( ((TVector*)fTrs->At(track))->IsValid() )
{TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
xx(10)=Pmom;
TClonesArray &arr=*fTrs;
new(arr[track])TVector(xx);
}
//-----------------------------------------------------------
void AliITSPid::SetPcod(Int_t track,Int_t partcode)
{
//Set particle code for given track
TVector xx(0,11);
if( ((TVector*)fTrs->At(track))->IsValid() )
{TVector yy( *((TVector*)fTrs->At(track)) );xx=yy; }
if(xx(11)==0)
{xx(11)=partcode; fMxtrs++;
TClonesArray &arr=*fTrs;
new(arr[track])TVector(xx);
}
}
//-----------------------------------------------------------
void AliITSPid::Print(Int_t track)
{
//Prints information for given track
cout<<fMxtrs<<" tracks in AliITSPid obj."<<endl;
if( ((TVector*)fTrs->At(track))->IsValid() )
{TVector xx( *((TVector*)fTrs->At(track)) );
xx.Print();
}
else
{cout<<"No data for track "<<track<<endl;return;}
}
//-----------------------------------------------------------
void AliITSPid::Tab(void)
{
//Make PID for tracks stored in tracks table
if(fTrs->GetEntries()==0){cout<<"No entries in TAB"<<endl;return;}
cout<<"------------------------------------------------------------------------"<<endl;
cout<<"Nq"<<" q1 "<<" q2 "<<" q3 "<<" q4 "<<" q5 "<<
" Qtrm " <<" Wpi "<<" Wk "<<" Wp "<<"Pmom "<<endl;
cout<<"------------------------------------------------------------------------"<<endl;
for(Int_t i=0;i<fTrs->GetEntries();i++)
{
TVector xxx( *((TVector*)fTrs->At(i)) );
if( xxx.IsValid() && xxx(0)>0 )
{
TVector xx( *((TVector*)fTrs->At(i)) );
if(xx(0)>=2)
{
// 1)Calculate Qtrm
xx(6)=(this->Qtrm(i));
}else{
xx(6)=xx(1);
}
// 2)Calculate Wpi,Wk,Wp
this->GetPcode(xx(6),xx(10)/1000.);
xx(7)=GetWpi();
xx(8)=GetWk();
xx(9)=GetWp();
// 3)Print table
if(xx(0)>0){
// cout<<xx(0)<<" ";
for(Int_t j=1;j<11;j++){
if(i<7){ cout.width(7);cout.precision(4);cout<<xx(j);}
if(i>7){ cout.width(7);cout.precision(5);cout<<xx(j);}
}
cout<<endl;
}
// 4)Update data in TVector
TClonesArray &arr=*fTrs;
new(arr[i])TVector(xx);
}
else
{/*cout<<"No data for track "<<i<<endl;*/}
}// End loop for tracks
}
void AliITSPid::Reset(void)
{
//Reset tracks table
for(Int_t i=0;i<fTrs->GetEntries();i++){
TVector xx(0,11);
TClonesArray &arr=*fTrs;
new(arr[i])TVector(xx);
}
}
//-----------------------------------------------------------
AliITSPid::AliITSPid(Int_t ntrack):
fMxtrs(0),
fTrs(0),
fWpi(0),
fWk(0),
fWp(0),
fRpik(0),
fRppi(0),
fRpka(0),
fRp(0),
fPcode(0),
fSigmin(0.01),
fSilent(0),
fCutKa(0),
fCutPr(0),
fggpi(0),
fggka(0),
fggpr(0){
//Constructor for AliITSPid class
fTrs = new TClonesArray("TVector",ntrack);
TClonesArray &arr=*fTrs;
for(Int_t i=0;i<ntrack;i++)new(arr[i])TVector(0,11);
//
fCutKa=new TF1("fcutka","pol4",0.05,0.4);
Double_t ka[5]={25.616, -161.59, 408.97, -462.17, 192.86};
fCutKa->SetParameters(ka);
//
fCutPr=new TF1("fcutpr","[0]/x/x+[1]",0.05,1.1);
Double_t pr[2]={0.70675,0.4455};
fCutPr->SetParameters(pr);
//
//---------- signal fit ----------
{//Pions
fGGpi[0]=new TF1("fp1pi","pol4",0.34,1.2);
Double_t parpi0[10]={ -1.9096471071e+03, 4.5354331545e+04, -1.1860738840e+05,
1.1405329025e+05, -3.8289694496e+04 };
fGGpi[0]->SetParameters(parpi0);
fGGpi[1]=new TF1("fp2pi","[0]/x/x+[1]",0.34,1.2);
Double_t parpi1[10]={ 1.0791668283e-02, 9.7347716496e-01 };
fGGpi[1]->SetParameters(parpi1);
fGGpi[2]=new TF1("fp3pi","[0]/x/x+[1]",0.34,1.2);
Double_t parpi2[10]={ 5.8191602279e-04, 9.7285601334e-02 };
fGGpi[2]->SetParameters(parpi2);
fGGpi[3]=new TF1("fp4pi","pol4",0.34,1.2);
Double_t parpi3[10]={ 6.6267353195e+02, 7.1595101104e+02, -5.3095111914e+03,
6.2900977606e+03, -2.2935862292e+03 };
fGGpi[3]->SetParameters(parpi3);
fGGpi[4]=new TF1("fp5pi","[0]/x/x+[1]",0.34,1.2);
Double_t parpi4[10]={ 9.0419011783e-03, 1.1628922525e+00 };
fGGpi[4]->SetParameters(parpi4);
fGGpi[5]=new TF1("fp6pi","[0]/x/x+[1]",0.34,1.2);
Double_t parpi5[10]={ 1.8324872519e-03, 2.1503968838e-01 };
fGGpi[5]->SetParameters(parpi5);
}//End Pions
{//Kaons
fGGka[0]=new TF1("fp1ka","pol4",0.24,1.2);
Double_t parka0[20]={
-1.1204243395e+02,4.6716191428e+01,2.2584059281e+03,
-3.7123338009e+03,1.6003647641e+03 };
fGGka[0]->SetParameters(parka0);
fGGka[1]=new TF1("fp2ka","[0]/x/x+[1]",0.24,1.2);
Double_t parka1[20]={
2.5181172905e-01,8.7566001814e-01 };
fGGka[1]->SetParameters(parka1);
fGGka[2]=new TF1("fp3ka","pol6",0.24,1.2);
Double_t parka2[20]={
8.6236021573e+00,-7.0970427531e+01,2.4846827669e+02,
-4.6094401290e+02,4.7546751408e+02,-2.5807112462e+02,
5.7545491696e+01 };
fGGka[2]->SetParameters(parka2);
}//End Kaons
{//Protons
fGGpr[0]=new TF1("fp1pr","pol4",0.4,1.2);
Double_t parpr0[10]={
6.0150106543e+01,-8.8176206410e+02,3.1222644604e+03,
-3.5269200901e+03,1.2859128345e+03 };
fGGpr[0]->SetParameters(parpr0);
fGGpr[1]=new TF1("fp2pr","[0]/x/x+[1]",0.4,1.2);
Double_t parpr1[10]={
9.4970837607e-01,7.3573504201e-01 };
fGGpr[1]->SetParameters(parpr1);
fGGpr[2]=new TF1("fp3pr","[0]/x/x+[1]",0.4,1.2);
Double_t parpr2[10]={
1.2498403757e-01,2.7845072306e-02 };
fGGpr[2]->SetParameters(parpr2);
}//End Protons
//----------- end fit -----------
fggpr=new TF1("ggpr","gaus",0.4,1.2);
fggpi=new TF1("ggpi","gaus+gaus(3)",0.4,1.2);
fggka=new TF1("ggka","gaus",0.4,1.2);
//-------------------------------------------------
const int kInf=10;
// Ncut Pmom pilo pihi klo khi plo phi
// cut[j] [0] [1] [2] [3] [4] [5] [6]
//----------------------------------------------------------------
SetCut( 1, 0.12 , 0. , 0. , kInf , kInf , kInf , kInf );
SetCut( 2, 0.20 , 0. , 6.0 , 6.0 , kInf , kInf , kInf );
SetCut( 3, 0.30 , 0. , 3.5 , 3.5 , 9.0 , 9.0 , kInf );
SetCut( 4, 0.41 , 0. , 1.9 , 1.9 , 4.0 , 4.0 , kInf );
//----------------------------------------------------------------
SetCut( 5, 0.47 , 0.935, 0.139, 1.738 , 0.498 , 3.5 , kInf ); //410-470
SetCut( 6, 0.53 , 0.914, 0.136, 1.493 , 0.436 , 3.0 , kInf ); //470-530
//----------------------------------------------------------------
SetCut( 7, 0.59 , 0.895, 0.131, 1.384 , 0.290 , 2.7 , kInf ); //530-590
SetCut( 8, 0.65 , 0.887, 0.121, 1.167 , 0.287 , 2.5 , kInf ); //590-650
SetCut( 9, 0.73 , 0.879, 0.120, 1.153 , 0.257 , 2.0 , kInf ); //650-730
//----------------------------------------------------------------
SetCut( 10, 0.83 , 0.880, 0.126, 1.164 , 0.204 , 2.308 , 0.297 ); //730-830
SetCut( 11, 0.93 , 0.918, 0.145, 1.164 , 0.204 , 2.00 , 0.168 ); //830-930
SetCut( 12, 1.03 , 0.899, 0.128, 1.164 , 0.204 ,1.80 , 0.168);
//------------------------ pi,K ---------------------
fAprob[0][0]=1212; fAprob[1][0]=33.; // fAprob[0][i] - const for pions,cut[i+5]
fAprob[0][1]=1022; fAprob[1][1]=46.2 ; // fAprob[1][i] - kaons
//---------------------------------------------------
fAprob[0][2]= 889.7; fAprob[1][2]=66.58; fAprob[2][2]=14.53;
fAprob[0][3]= 686.; fAprob[1][3]=88.8; fAprob[2][3]=19.27;
fAprob[0][4]= 697.; fAprob[1][4]=125.6; fAprob[2][4]=28.67;
//------------------------ pi,K,p -------------------
fAprob[0][5]= 633.7; fAprob[1][5]=100.1; fAprob[2][5]=37.99; // fAprob[2][i] - protons
fAprob[0][6]= 469.5; fAprob[1][6]=20.74; fAprob[2][6]=25.43;
fAprob[0][7]= 355.; fAprob[1][7]=
355.*(20.74/469.5); fAprob[2][7]=34.08;
}
//End AliITSPid.cxx
| 32.267961 | 97 | 0.526959 |
83456e667f22f00544aeb38fae96b3e6470b1bbc | 536 | cpp | C++ | shopaholic.cpp | nemo201/Kattis | 887711eece263965a4529048011847f7a2749fec | [
"MIT"
] | null | null | null | shopaholic.cpp | nemo201/Kattis | 887711eece263965a4529048011847f7a2749fec | [
"MIT"
] | null | null | null | shopaholic.cpp | nemo201/Kattis | 887711eece263965a4529048011847f7a2749fec | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
vi shop;
int n;
cin >> n;
rep(i,0,n){
int a;
cin >> a;
shop.push_back(a);
}
sort(shop.rbegin(), shop.rend());
int discount = 0;
for(int i=0; i<n; i++){
if(i%3 == 2)
discount += shop[i];
}
cout << discount << endl;
return 0;
}
| 17.290323 | 49 | 0.567164 |
83457675501cf3d38ee6c07385cfd4151b290a63 | 11,970 | cpp | C++ | src/LaneDetection/image_signal_processing.cpp | sajid-mohamed/imacs | 25810df31eeeb59c65dea71eb9467bec8fb23dd7 | [
"Apache-2.0"
] | 1 | 2021-03-22T11:18:10.000Z | 2021-03-22T11:18:10.000Z | src/LaneDetection/image_signal_processing.cpp | sajid-mohamed/imacs | 25810df31eeeb59c65dea71eb9467bec8fb23dd7 | [
"Apache-2.0"
] | null | null | null | src/LaneDetection/image_signal_processing.cpp | sajid-mohamed/imacs | 25810df31eeeb59c65dea71eb9467bec8fb23dd7 | [
"Apache-2.0"
] | 1 | 2021-03-16T20:01:45.000Z | 2021-03-16T20:01:45.000Z | /** @file image_signal_processing.cpp
* @brief source file for ISP pipeline
*
* Name : image_signal_processing.cpp
*
* Authors : Sayandip De (sayandip.de@tue.nl)
* Sajid Mohamed (s.mohamed@tue.nl)
*
* Date : March 26, 2020
*
* Function : run different approximate ISP versions
*
* History :
* 26-03-20 : Initial version.
* Code is modified from https://github.com/mbuckler/ReversiblePipeline [written by Mark Buckler].
*
*/
#include "image_signal_processing.hpp"
using namespace cv;
using namespace Halide;
using namespace Halide::Tools;
imageSignalProcessing::imageSignalProcessing(){} //!< constructor
imageSignalProcessing::~imageSignalProcessing(){} //!< destructor
Mat imageSignalProcessing::approximate_pipeline(Mat the_img_input, int the_pipe_version) {
using namespace std;
Mat img_rev, img_fwd, v0_rev, v0_fwd; //!< img_rev: image after applying approximated reverse pipeline
//!< img_fwd: image after applying approximated forward ISP pipeline
//!< v0_rev: image after applying reverse pipeline without approximation
//!< v0_fwd: image after applying forward ISP pipeline without approximation
//// Run ISP pipeline (reverse image from VREP/webots to obtain RAW and forward ISP pipeline to obtain *.jpg) for the original image (v0 in papers)
v0_rev = run_pipeline(false, the_img_input, 0); //!< v0_rev: image after applying reverse pipeline without approximation
v0_fwd = run_pipeline(true, v0_rev, 0); //!< v0_fwd: image after applying forward ISP pipeline without approximation
if (the_pipe_version != 0){ //!< image needs approximation
//// Run reverse pipeline for the original image from the simulator to obtain RAW image
img_rev = run_pipeline(false, v0_fwd, the_pipe_version);
if (the_pipe_version == 7) return img_rev;
//// Run forward pipeline for the RAW image
img_fwd = run_pipeline(true, img_rev, the_pipe_version);
} else { //!< no approximation required
img_rev = v0_rev;
img_fwd = v0_fwd;
}
//// save_images
imwrite(out_string+"/output_rev.png", img_rev);
imwrite(out_string+"/output_fwd_v"+to_string(the_pipe_version)+".png", img_fwd);
return img_fwd;
}
//// Reversible pipeline function
Mat imageSignalProcessing::run_pipeline(bool direction, Mat the_img_in, int the_pipe_version) {
using namespace std;
///////////////////////////////////////////////////////////////
/// Input Image Parameters
///////////////////////////////////////////////////////////////
Halide::Buffer<uint8_t> input1;
Halide::Runtime::Buffer<uint8_t> input;
/// convert input Mat to Image
if (the_pipe_version == 8 && direction){ //!< if the approximate_pipeline_version == 8
/// Convert the input Matrix image to RGB image in Halide::Buffer<uint8_t> format
input1 = Mat2Image <Halide::Buffer<uint8_t>, uint8_t> (&the_img_in);
Mat mat_input, mat_output;
int width = input1.width();
int height = input1.height();
/// make_scale the input1 image
Func scale = make_scale ( &input1);
/// scale.realize the opencv_in_image image to input image's (width, height, 3)
Buffer<float> opencv_in_image = scale.realize(width, height, 3);
/// Convert scaled RGB image to BGR Matrix
Mat opencv_in_mat = Image2Mat <Buffer<float>,float,323> (&opencv_in_image); // 323: OutMat(height,width,CV_32FC3);
/// OpenCV remosaic the BGR Matrix
OpenCV_remosaic(&opencv_in_mat);
/// Convert Matrix to RGB image
Halide::Runtime::Buffer<float> opencv_out = Mat2Image <Halide::Runtime::Buffer<float>,float> (&opencv_in_mat);
/// initialise output_n in Halide::Runtime::Buffer<uint8_t> format using input1 image details
Halide::Runtime::Buffer<uint8_t> output_n(input1.width(), input1.height(), input1.channels());
/// auto_schedule_dem_fwd()
auto_schedule_dem_fwd(opencv_out, output_n);
/// Convert output_n to Matrix form
mat_output = Image2Mat <Halide::Runtime::Buffer<uint8_t>,uint8_t,83> (&output_n); // 83: OutMat(height,width,CV_8UC3);
/// Write image to file
imwrite("out_imgs/img_v8.png", mat_output);
mat_input = imread("out_imgs/img_v8.png", IMREAD_COLOR);
/// Convert image Matrix to input image forcompression/perception stage
input = Mat2Image <Halide::Runtime::Buffer<uint8_t>,uint8_t> (&mat_input);
}
else{
input = Mat2Image <Halide::Runtime::Buffer<uint8_t>,uint8_t> (&the_img_in);
}
///////////////////////////////////////////////////////////////////////////////////////
/// Import and format model data: cpp -> halide format
/// Declare model parameters
vector<vector<float>> Ts, Tw, TsTw;
vector<vector<float>> ctrl_pts, weights, coefs;
vector<vector<float>> rev_tone;
/// Load model parameters from file
/// NOTE: Ts, Tw, and TsTw read only forward data
/// ctrl_pts, weights, and coefs are either forward or backward
/// tone mapping is always backward
/// This is due to the the camera model format
///////////////////////////////////////////////////////////////
/// Camera Model Parameters
///////////////////////////////////////////////////////////////
/// White balance index (select white balance from transform file)
/// The first white balance in the file has a wb_index of 1
/// For more information on model format see the readme
int wb_index = 3; /// Actual choice = Given no. + 1
/// Number of control points
const int num_ctrl_pts = 3702;
Ts = get_Ts (&cam_model_path[0]);
Tw = get_Tw (&cam_model_path[0], wb_index);
TsTw = get_TsTw (&cam_model_path[0], wb_index);
ctrl_pts = get_ctrl_pts (&cam_model_path[0], num_ctrl_pts, direction);
weights = get_weights (&cam_model_path[0], num_ctrl_pts, direction);
coefs = get_coefs (&cam_model_path[0], num_ctrl_pts, direction);
rev_tone = get_rev_tone (&cam_model_path[0]);
/// Take the transpose of the color map and white balance transform for later use
vector<vector<float>> TsTw_tran = transpose_mat (TsTw); /// source of segmentation error
/// If we are performing a backward implementation of the pipeline,
/// take the inverse of TsTw_tran
if (direction == 0) {
TsTw_tran = inv_3x3mat(TsTw_tran);
}
using namespace Halide;
using namespace Halide::Tools;
/// Convert control points to a Halide image
int width = ctrl_pts[0].size();
int length = ctrl_pts.size();
Halide::Runtime::Buffer<float> ctrl_pts_h(width,length);
for (int y=0; y<length; y++) {
for (int x=0; x<width; x++) {
ctrl_pts_h(x,y) = ctrl_pts[y][x];
}
}
/// Convert weights to a Halide image
width = weights[0].size();
length = weights.size();
Halide::Runtime::Buffer<float> weights_h(width,length);
for (int y=0; y<length; y++) {
for (int x=0; x<width; x++) {
weights_h(x,y) = weights[y][x];
}
}
/// Convert the reverse tone mapping function to a Halide image
width = 3;
length = 256;
Halide::Runtime::Buffer<float> rev_tone_h(width,length);
for (int y=0; y<length; y++) {
for (int x=0; x<width; x++) {
rev_tone_h(x,y) = rev_tone[y][x];
}
}
/// Convert the TsTw_tran to a Halide image
width = 3;
length = 3;
Halide::Runtime::Buffer<float> TsTw_tran_h(width,length);
for (int y=0; y<length; y++) {
for (int x=0; x<width; x++) {
TsTw_tran_h(x,y) = TsTw_tran[x][y];
}
}
/// Convert the coefs to a Halide image
width = 4;
length = 3; //4 [SD]
Halide::Runtime::Buffer<float> coefs_h(width,length);
for (int y=0; y<length; y++) {
for (int x=0; x<width; x++) {
coefs_h(x,y) = coefs[x][y];
}
}
///////////////////////////////////////////////////////////////////////////////////////
/// Declare image handle variables
Var x, y, c;
////////////////////////////////////////////////////////////////////////
/// run the generator
Halide::Runtime::Buffer<uint8_t> output(input.width(), input.height(), input.channels());
if (direction == 1) {
switch(the_pipe_version){
case 0: /// full rev + fwd skip 0 stages
auto_schedule_true_fwd_v0(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 1: /// rev + fwd_transform_tonemap skip 1 stage
auto_schedule_true_fwd_v1(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 2: /// rev + fwd_transform_gamut skip 1 stage
auto_schedule_true_fwd_v2(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 3: /// rev + fwd_gamut_tonemap skip 1 stage
auto_schedule_true_fwd_v3(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 4: /// rev + fwd_transform skip 2 stages
auto_schedule_true_fwd_v4(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 5: /// rev + fwd_gamut skip 2 stages
auto_schedule_true_fwd_v5(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 6: /// rev + fwd_tonemap skip 2 stages
auto_schedule_true_fwd_v6(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
break;
case 8: /// skip denoise
{auto_schedule_true_fwd_v0(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
/// cout << "here3.9" << endl;
break; }
default: /// should not happen
cout << "Approximate pipeline version not defined. Default branch taken, pls check.\n";
break;
}/// switch
} else {
auto_schedule_true_rev(input, ctrl_pts_h, weights_h, rev_tone_h, TsTw_tran_h, coefs_h, output);
}
///////////////////////////////////////////////////////////////////////
/// convert Image to Mat and return
Mat img_out;
img_out = Image2Mat <Halide::Runtime::Buffer<uint8_t>,uint8_t,83> (&output); //83: CV_8UC3 (DEFAULT for OutMat)
return img_out;
}
Halide::Func imageSignalProcessing::make_scale( Buffer<uint8_t> *in_img ) {
Var x, y, c;
/// Cast input to float and scale from 8 bit 0-255 range to 0-1 range
Func scale("scale");
scale(x,y,c) = cast<float>( (*in_img)(x,y,c) ) / 255;
return scale;
}
void imageSignalProcessing::OpenCV_remosaic (Mat *InMat ) {
vector<Mat> three_channels;
cv::split((*InMat), three_channels);
/// Re-mosaic aka re-bayer the image
/// B G
/// G R
/// Note: OpenCV stores as BGR not RGB
for (int y=0; y<(*InMat).rows; y++) {
for (int x=0; x<(*InMat).cols; x++) {
/// If an even row
if ( y%2 == 0 ) {
/// If an even column
if ( x%2 == 0 ) {
/// Green pixel, remove blue and red
three_channels[0].at<float>(y,x) = 0;
three_channels[2].at<float>(y,x) = 0;
/// Also divide the green by half to account
/// for interpolation reversal
three_channels[1].at<float>(y,x) =
three_channels[1].at<float>(y,x) / 2;
}
/// If an odd column
else {
/// Red pixel, remove blue and green
three_channels[0].at<float>(y,x) = 0;
three_channels[1].at<float>(y,x) = 0;
}
}
/// If an odd row
else {
/// If an even column
if ( x%2 == 0 ) {
/// Blue pixel, remove red and green
three_channels[2].at<float>(y,x) = 0;
three_channels[1].at<float>(y,x) = 0;
}
/// If an odd column
else {
/// Green pixel, remove blue and red
three_channels[0].at<float>(y,x) = 0;
three_channels[2].at<float>(y,x) = 0;
/// Also divide the green by half to account
/// for interpolation reversal
three_channels[1].at<float>(y,x) =
three_channels[1].at<float>(y,x) / 2;
}
}
}
}
cv::merge(three_channels, *InMat);
}
| 38.365385 | 148 | 0.621136 |
83458018ccf6f0cb28c4a6212476df7d9ffce49f | 839 | hpp | C++ | libs/fnd/type_traits/include/bksge/fnd/type_traits/add_rvalue_reference.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 4 | 2018-06-10T13:35:32.000Z | 2021-06-03T14:27:41.000Z | libs/fnd/type_traits/include/bksge/fnd/type_traits/add_rvalue_reference.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 566 | 2017-01-31T05:36:09.000Z | 2022-02-09T05:04:37.000Z | libs/fnd/type_traits/include/bksge/fnd/type_traits/add_rvalue_reference.hpp | myoukaku/bksge | 0f8b60e475a3f1709723906e4796b5e60decf06e | [
"MIT"
] | 1 | 2018-07-05T04:40:53.000Z | 2018-07-05T04:40:53.000Z | /**
* @file add_rvalue_reference.hpp
*
* @brief add_rvalue_reference の定義
*
* @author myoukaku
*/
#ifndef BKSGE_FND_TYPE_TRAITS_ADD_RVALUE_REFERENCE_HPP
#define BKSGE_FND_TYPE_TRAITS_ADD_RVALUE_REFERENCE_HPP
#include <type_traits>
namespace bksge
{
/**
* @brief 型に右辺値参照を追加する
*
* @tparam T
*
* Tがオブジェクト型もしくは関数型の場合(cv修飾や参照型でない)、T&&をメンバ型typeとして定義する。
* そうでない場合、Tをメンバ型typeとして定義する。
*
* 例)
* add_rvalue_reference<int>::type is int&&
* add_rvalue_reference<int&>::type is int&
* add_rvalue_reference<int&&>::type is int&&
*/
using std::add_rvalue_reference;
/**
* @brief add_rvalue_referenceのエイリアステンプレート
*/
template <typename T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
} // namespace bksge
#endif // BKSGE_FND_TYPE_TRAITS_ADD_RVALUE_REFERENCE_HPP
| 20.463415 | 71 | 0.719905 |
8347af25601a39e8c8006c5c730c755372e810d2 | 1,679 | cpp | C++ | SourceCode/ChainBlockerLibrary/Base64.cpp | jamesjohnmcguire/BuildingBlocks | be38f6afd9640e56bf5448d2e00870e0128dbad1 | [
"MIT"
] | null | null | null | SourceCode/ChainBlockerLibrary/Base64.cpp | jamesjohnmcguire/BuildingBlocks | be38f6afd9640e56bf5448d2e00870e0128dbad1 | [
"MIT"
] | null | null | null | SourceCode/ChainBlockerLibrary/Base64.cpp | jamesjohnmcguire/BuildingBlocks | be38f6afd9640e56bf5448d2e00870e0128dbad1 | [
"MIT"
] | null | null | null | #include "pch.h"
#include "Base64.h"
namespace ChainBlocker
{
std::vector<unsigned char> Base64::Decode(
std::string input, size_t inputLength, size_t* outputLength)
{
std::vector<unsigned char> output;
const unsigned char* inputBuffer =
reinterpret_cast<const unsigned char*>(input.c_str());
const size_t bufferLength = 3 * inputLength / 4;
unsigned char* rawBuffer =
reinterpret_cast<unsigned char*>(calloc(bufferLength, 1));
int inputBufferLength = static_cast<int>(inputLength);
int actualLength =
EVP_DecodeBlock(rawBuffer, inputBuffer, inputBufferLength);
if (actualLength > -1)
{
if (actualLength != bufferLength)
{
// log warning
}
size_t last = inputLength - 1;
while (input[last] == '=')
{
actualLength--;
last--;
}
*outputLength = actualLength;
output = std::vector<unsigned char>(
rawBuffer, rawBuffer + actualLength);
}
return output;
}
std::vector<char> Base64::Encode(
const unsigned char* input, size_t inputLength)
{
std::vector<char> output;
size_t encodeLength = 4 * ((inputLength + 2) / 3);
// +1 for the terminating null
encodeLength = encodeLength + 1;
void* buffer = calloc(encodeLength, 1);
char* charBuffer = reinterpret_cast<char*>(buffer);
unsigned char* encodeBuffer =
reinterpret_cast<unsigned char*>(charBuffer);
int bufferLength = static_cast<int>(inputLength);
int outputLength =
EVP_EncodeBlock(encodeBuffer, input, bufferLength);
if (outputLength > -1)
{
if (encodeLength != outputLength)
{
// log warning
}
output = std::vector<char>(charBuffer, charBuffer + outputLength);
}
return output;
}
} | 21.253165 | 69 | 0.681358 |
83496e37124bb04f9fe5fa9a6044fc384a12ea85 | 644 | cpp | C++ | include/hydro/compiler/hydro/ast/EmptyExpression.cpp | hydraate/hydro | 42037a8278dcfdca68fb5cceaf6988da861f0eff | [
"Apache-2.0"
] | null | null | null | include/hydro/compiler/hydro/ast/EmptyExpression.cpp | hydraate/hydro | 42037a8278dcfdca68fb5cceaf6988da861f0eff | [
"Apache-2.0"
] | null | null | null | include/hydro/compiler/hydro/ast/EmptyExpression.cpp | hydraate/hydro | 42037a8278dcfdca68fb5cceaf6988da861f0eff | [
"Apache-2.0"
] | null | null | null | //
// __ __ __
// / / / /__ __ ____/ /_____ ____
// / /_/ // / / // __ // ___// __ \
// / __ // /_/ // /_/ // / / /_/ /
// /_/ /_/ \__, / \__,_//_/ \____/
// /____/
//
// The Hydro Programming Language
//
#include "EmptyExpression.hpp"
namespace hydro::compiler
{
EmptyExpression::EmptyExpression(AST *owner) : Expression{owner} {}
EmptyExpression::~EmptyExpression() {}
void EmptyExpression::accept(ASTVisitor *visitor)
{
visitor->visit(this);
}
} // namespace hydro::compiler
| 24.769231 | 67 | 0.448758 |
834fc481fcc1666bca34655edf8786d76b67a8c0 | 5,233 | cc | C++ | tc/benchmarks/batchmatmul.cc | yaozhujia/TensorComprehensions | 220b5902645886fc2feac61770018419ca5411bc | [
"Apache-2.0"
] | 1,841 | 2018-02-14T01:35:40.000Z | 2022-03-21T04:45:27.000Z | tc/benchmarks/batchmatmul.cc | yaozhujia/TensorComprehensions | 220b5902645886fc2feac61770018419ca5411bc | [
"Apache-2.0"
] | 457 | 2018-02-14T09:28:12.000Z | 2021-01-11T03:49:11.000Z | tc/benchmarks/batchmatmul.cc | yaozhujia/TensorComprehensions | 220b5902645886fc2feac61770018419ca5411bc | [
"Apache-2.0"
] | 229 | 2018-02-14T01:43:23.000Z | 2022-02-21T23:53:32.000Z | /**
* Copyright (c) 2017-present, Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "batchmatmul.h"
#include <iostream>
#include <string>
#include <vector>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "tc/aten/aten.h"
#include "tc/aten/aten_compiler.h"
#include "tc/core/cuda/cuda_mapping_options.h"
#include "../test/caffe2/cuda/test_harness.h"
#include "../test/caffe2/test_harness.h"
#include "../test/test_harness_aten_cuda.h"
#include "benchmark_fixture.h"
#include "tc/c2/context.h"
#include "tc/core/cuda/cuda.h"
#include "tc/core/flags.h"
using namespace caffe2;
DEFINE_uint32(B, 500, "Batch size in Z(b, n, m) += X(b, n, kk) * Y(b, kk, m)");
DEFINE_uint32(N, 26, "N dimension in Z(b, n, m) += X(b, n, kk) * Y(b, kk, m)");
DEFINE_uint32(M, 72, "M dimension in Z(b, n, m) += X(b, n, kk) * Y(b, kk, m)");
DEFINE_uint32(K, 26, "K dimension in Z(b, n, m) += X(b, n, kk) * Y(b, kk, m)");
class BatchMatMul : public Benchmark {
protected:
uint32_t B, N, M, K;
public:
void Init(uint32_t b, uint32_t n, uint32_t m, uint32_t k) {
B = b;
N = n;
M = m;
K = k;
}
void runBatchMatMul(const tc::CudaMappingOptions& options);
void runCaffe2BatchMatMul();
void runATenBatchMatMul();
};
void BatchMatMul::runBatchMatMul(const tc::CudaMappingOptions& options) {
at::Tensor X = at::CUDA(at::kFloat).rand({B, N, M});
at::Tensor Y = at::CUDA(at::kFloat).rand({B, M, K});
auto ref_output = X.bmm(Y);
auto check_fun = [&, ref_output](
const std::vector<at::Tensor>& inputs,
const std::vector<at::Tensor>& outputs) {
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaDeviceSynchronize());
double prec = 3e-7;
std::cout << "Checking expected output relative precision @" << prec;
at::Tensor diff = outputs[0].sub(ref_output);
checkRtol(diff, inputs, M, prec);
return true;
};
std::vector<at::Tensor> inputs = {X, Y};
std::string tc = R"(
def batch_matmul(float(B, N, M) X, float(B, M, K) Y) -> (Z) {
Z(b, n, k) +=! X(b, n, r_m) * Y(b, r_m, k)
}
)";
std::string suffix = std::string("_B_") + std::to_string(FLAGS_B) +
std::string("_K_") + std::to_string(FLAGS_K) + std::string("_M_") +
std::to_string(FLAGS_M) + std::string("_N_") + std::to_string(FLAGS_N);
std::vector<tc::CudaMappingOptions> bestOptions{options};
if (FLAGS_autotune) {
bestOptions = autotune(tc, "batch_matmul", inputs, options, check_fun);
}
Check(tc, "batch_matmul", bestOptions[0], inputs, check_fun);
}
void BatchMatMul::runCaffe2BatchMatMul() {
Workspace w_ref;
auto AddInput = AddDeterministicallyRandomInput<caffe2::CUDABackend, float>;
AddInput(w_ref, {B, N, M}, "X");
AddInput(w_ref, {B, M, K}, "Y");
OperatorDef ref_def =
MakeOperatorDef<caffe2::CUDABackend>("BatchMatMul", {"X", "Y"}, {"Z"});
std::unique_ptr<OperatorBase> net(CreateOperator(ref_def, &w_ref));
Reference([&]() { return true; }, [&](bool flag) { net->Run(); });
}
void BatchMatMul::runATenBatchMatMul() {
at::Tensor X = at::CUDA(at::kFloat).rand({B, N, M});
at::Tensor Y = at::CUDA(at::kFloat).rand({B, M, K});
Reference(
[&]() { return bmm(X, Y); },
[&](at::Tensor& res) { bmm_out(res, X, Y); });
}
// Generic
TEST_F(BatchMatMul, TransposedBatchMatMul) {
Init(FLAGS_B, FLAGS_N, FLAGS_M, FLAGS_K);
runBatchMatMul(tc::CudaMappingOptions::makeNaiveMappingOptions());
}
// P100 TC
TEST_F(BatchMatMul, TransposedBatchMatMul_P100_autotuned_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runBatchMatMul(
tc::options_TransposedBatchMatMul_P100_autotuned_B_500_K_26_M_72_N_26);
}
// P100 ATen
TEST_F(BatchMatMul, TransposedBatchMatMul_ATen_P100_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runATenBatchMatMul();
}
// P100 Caffe2
TEST_F(BatchMatMul, TransposedBatchMatMul_Caffe2_P100_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runCaffe2BatchMatMul();
}
// V100 TC
TEST_F(BatchMatMul, TransposedBatchMatMul_V100_autotuned_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runBatchMatMul(
tc::options_TransposedBatchMatMul_V100_autotuned_B_500_K_26_M_72_N_26);
}
// V100 ATen
TEST_F(BatchMatMul, TransposedBatchMatMul_ATen_V100_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runATenBatchMatMul();
}
// V100 Caffe2
TEST_F(BatchMatMul, TransposedBatchMatMul_Caffe2_V100_B_500_K_26_M_72_N_26) {
Init(500, 26, 72, 26);
runCaffe2BatchMatMul();
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
::gflags::ParseCommandLineFlags(&argc, &argv, true);
::google::InitGoogleLogging(argv[0]);
tc::aten::setAtenSeed(tc::initRandomSeed(), at::Backend::CUDA);
return RUN_ALL_TESTS();
}
| 31.524096 | 80 | 0.679534 |
835093015bcabb2f9d4db41bc6c84e980d57812f | 51,830 | cpp | C++ | modules/jvm/src/generic/JVMForeignRuntime.cpp | AlexYaruki/nigiri | 13269e1f7a8f5aaec268fc1fb822aeb9e6f5e60e | [
"Apache-2.0"
] | null | null | null | modules/jvm/src/generic/JVMForeignRuntime.cpp | AlexYaruki/nigiri | 13269e1f7a8f5aaec268fc1fb822aeb9e6f5e60e | [
"Apache-2.0"
] | null | null | null | modules/jvm/src/generic/JVMForeignRuntime.cpp | AlexYaruki/nigiri | 13269e1f7a8f5aaec268fc1fb822aeb9e6f5e60e | [
"Apache-2.0"
] | null | null | null | #include <nigiri.h>
#include <vector>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include <bits/shared_ptr.h>
#include "JVMForeignRuntime.h"
#include "JVMPrimitives.h"
#include "JVMOpParams.h"
#include "JVMThread.h"
#include "JVMInternalWrappers.h"
namespace nigiri {
namespace internal {
// JVMType /////////////////////////////////////////////////////////////
JVMType::JVMType(FR_Id id, jclass type_, std::string typeName, std::string sName) {
type = type_;
runtimeId = id;
name = typeName;
signatureName = sName;
}
JVMType::~JVMType() {
std::cout << "JVMType " << name << " destroyed" << std::endl;
}
FR_Id JVMType::getRuntimeId() {
return runtimeId;
}
jclass JVMType::getType() const {
return type;
}
const std::string& JVMType::getName() {
return name;
}
const std::string& JVMType::getSignatureName() {
return signatureName;
}
bool JVMType::isPrimitive() {
return primitive;
}
bool JVMType::isGeneric() {
return false;
}
JVMGenericType::JVMGenericType(FR_Id id, jclass type_, std::string typeName, std::string sName) : JVMType(id, type_, typeName, sName) {
}
bool JVMGenericType::isGeneric() {
return true;
}
void JVMGenericType::setTypeParameterInfo(const std::map<std::string, std::vector<std::string>>&tPI) {
typeParameterInfo = tPI;
}
//TODO: Respect Java language scope
const StaticMethodCaller& JVMType::getStaticMethodCaller() {
static StaticMethodCaller caller = [](auto env, auto targetType, auto method, auto jniParams) {
auto obj = env->CallStaticObjectMethodA(targetType->getType(), method->getMethod(), jniParams);
auto jvmReturnType = std::static_pointer_cast<JVMType>(method->getReturnType());
return std::make_shared<JVMObject>(obj, jvmReturnType, targetType->getRuntimeId());
};
return caller;
}
//TODO: Respect Java language scope
const InstanceMethodCaller& JVMType::getInstanceMethodCaller() {
static InstanceMethodCaller caller = [](auto env, auto targetObject, auto method, auto jniParams) {
auto obj = env->CallObjectMethodA(targetObject->getObject(), method->getMethod(), jniParams);
auto jvmReturnType = std::static_pointer_cast<JVMType>(method->getReturnType());
return std::make_shared<JVMObject>(obj, jvmReturnType, targetObject->getRuntimeId());
};
return caller;
}
//TODO: Respect Java language scope
const StaticFieldAccessor& JVMType::getStaticFieldAccessor() {
static StaticFieldAccessor accessor = [](auto env, auto targetType, auto field) {
auto obj = env->GetStaticObjectField(targetType->getType(), field->getField());
auto jvmFieldType = std::static_pointer_cast<JVMType>(field->getType());
return std::make_shared<JVMObject>(obj, jvmFieldType, targetType->getRuntimeId());
};
return accessor;
}
//TODO: Respect Java language scope
const InstanceFieldAccessor& JVMType::getInstanceFieldAccessor() {
static InstanceFieldAccessor accessor = [](auto env, auto targetObject, auto field) {
auto obj = env->GetObjectField(targetObject->getObject(), field->getField());
auto jvmFieldType = std::static_pointer_cast<JVMType>(field->getType());
return std::make_shared<JVMObject>(obj, jvmFieldType, targetObject->getRuntimeId());
};
return accessor;
}
/////////////////////////////////////////////////////////////////////////
// JVMObjectBase ////////////////////////////////////////////////////////
std::shared_ptr<FR_Type> JVMObjectBase::getType() {
return type;
}
std::tuple<bool, uint16_t> JVMObjectBase::castToUInt16() {
return std::tuple<bool, uint16_t > ();
}
std::tuple<bool, bool> JVMObjectBase::castToBool() {
return std::tuple<bool, bool>();
}
std::tuple<bool, int8_t> JVMObjectBase::castToInt8() {
return std::tuple<bool, int8_t > ();
}
std::tuple<bool, int16_t> JVMObjectBase::castToInt16() {
return std::tuple<bool, int16_t > ();
}
std::tuple<bool, int32_t> JVMObjectBase::castToInt32() {
return std::tuple<bool, int32_t > ();
}
std::tuple<bool, int64_t> JVMObjectBase::castToInt64() {
return std::tuple<bool, int64_t > ();
}
std::tuple<bool, float> JVMObjectBase::castToFloat() {
return std::tuple<bool, float>();
}
std::tuple<bool, double> JVMObjectBase::castToDouble() {
return std::tuple<bool, double>();
}
FR_Id JVMObjectBase::getRuntimeId() {
return runtimeId;
}
/////////////////////////////////////////////////////////////////////////
// JVMObject ////////////////////////////////////////////////////////////
JVMObject::JVMObject(jobject o, std::shared_ptr<JVMType> t, FR_Id id) {
obj = o;
type = t;
runtimeId = id;
}
JVMObject::~JVMObject() {
std::cout << "JVMObject of type " << type->getName() << " destroyed" << std::endl;
}
jobject JVMObject::getObject() const {
return obj;
}
jvalue JVMObject::toValue() {
jvalue v;
v.l = obj;
return v;
}
/////////////////////////////////////////////////////////////////////////
// JVMMethod ////////////////////////////////////////////////////////////
JVMMethod::JVMMethod(FR_Id id, jmethodID method, std::shared_ptr<FR_Type> t, std::shared_ptr<FR_Type> rT) : runtimeId(id), method(method), type(t), returnType(rT) {
}
JVMMethod::~JVMMethod(){
std::cout << "Method destroyed" << std::endl;
}
jmethodID JVMMethod::getMethod() {
return method;
}
FR_Id JVMMethod::getRuntimeId() {
return runtimeId;
}
std::shared_ptr<FR_Type> JVMMethod::getType() {
return type;
}
std::shared_ptr<FR_Type> JVMMethod::getReturnType() {
return returnType;
}
/////////////////////////////////////////////////////////////////////////
// JVMField ////////////////////////////////////////////////////////////
JVMField::JVMField(FR_Id id, jfieldID field, std::shared_ptr<FR_Type> parentType, std::shared_ptr<FR_Type> type) :
runtimeId(id),
field(field),
parentType(parentType),
type(type) {
}
jfieldID JVMField::getField() {
return field;
}
FR_Id JVMField::getRuntimeId() {
return runtimeId;
}
std::shared_ptr<FR_Type> JVMField::getParentType() {
return parentType;
}
std::shared_ptr<FR_Type> JVMField::getType() {
return type;
}
/////////////////////////////////////////////////////////////////////////
JVMForeignRuntime::JVMForeignRuntime(FR_Id id_) {
id = id_;
TYPE_CHAR = std::make_shared<JVMType_Char>(getId(), nullptr);
TYPE_BOOLEAN = std::make_shared<JVMType_Boolean>(getId(), nullptr);
TYPE_INT8 = std::make_shared<JVMType_Int8>(getId(), nullptr);
TYPE_INT16 = std::make_shared<JVMType_Int16>(getId(), nullptr);
TYPE_INT32 = std::make_shared<JVMType_Int32>(getId(), nullptr);
TYPE_INT64 = std::make_shared<JVMType_Int64>(getId(), nullptr);
TYPE_FLOAT = std::make_shared<JVMType_Float>(getId(), nullptr);
TYPE_DOUBLE = std::make_shared<JVMType_Double>(getId(), nullptr);
controlData.workOperation = JVMWorkOperation::ExecuteOp;
controlData.stateMachine.registerStateToString(getStateString);
controlData.stateMachine.registerEventToString(getEventString);
controlData.stateMachine.addConnection(JVMState::Created, JVMEvent::Init_Error, JVMState::ErrorShutdown);
controlData.stateMachine.addConnection(JVMState::Created, JVMEvent::Init_Success, JVMState::Started);
controlData.stateMachine.addConnection(JVMState::Started, JVMEvent::JVM_Destroyed, JVMState::Shutdown);
controlData.stateMachine.addConnection(JVMState::Started, JVMEvent::Work_Prepared, JVMState::WorkPrepared);
controlData.stateMachine.addConnection(JVMState::WorkPrepared, JVMEvent::Work_Completed, JVMState::WorkCompleted);
controlData.stateMachine.addConnection(JVMState::WorkCompleted, JVMEvent::Work_Prepared, JVMState::WorkPrepared);
controlData.stateMachine.addConnection(JVMState::WorkCompleted, JVMEvent::Work_Idle, JVMState::Started);
typeCache.insert({"byte", TYPE_INT8});
typeCache.insert({"short", TYPE_INT16});
typeCache.insert({"int", TYPE_INT32});
typeCache.insert({"long", TYPE_INT64});
typeCache.insert({"float", TYPE_FLOAT});
typeCache.insert({"double", TYPE_DOUBLE});
typeCache.insert({"boolean", TYPE_BOOLEAN});
typeCache.insert({"char", TYPE_CHAR});
}
JVMForeignRuntime::~JVMForeignRuntime() {
typeCache.clear();
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "DEBUG - JVMForeignRuntime - dtor" << std::endl;
}
stop();
}
void JVMForeignRuntime::waitForInitialization() {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Waiting for JVM startup ..." << std::endl;
}
controlData.stateMachine.waitForStates({JVMState::Started, JVMState::ErrorShutdown});
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVM startup completed" << std::endl;
}
}
bool JVMForeignRuntime::start(const std::initializer_list<std::string>& resources) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Starting JVM ..." << std::endl;
}
jvmThread = std::thread([&resources](ControlData * controlData_) {
if (LOG_JVMTHREAD) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread - Start of JVMThread" << std::endl;
}
JVMThread jvmThread(controlData_);
bool jvmCreated = jvmThread.createJVM(resources);
if (!jvmCreated) {
if (LOG_JVMTHREAD) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread - JVM Cannot be created" << std::endl;
}
jvmThread.notifyRollback();
} else {
if (LOG_JVMTHREAD) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread - JVM Created" << std::endl;
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread - Starting work loop" << std::endl;
}
jvmThread.workLoop();
}
jvmThread.quit();
if (LOG_JVMTHREAD) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread - End of JVMThread" << std::endl;
}
}, &controlData);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMThread started" << std::endl;
}
waitForInitialization();
if (controlData.stateMachine.getState() == JVMState::Started) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVM is work-ready" << std::endl;
}
return true;
} else {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVM could not be started" << std::endl;
}
jvmThread.join();
return false;
}
}
bool JVMForeignRuntime::isRunning() {
JVMState state = controlData.stateMachine.getState();
return (state != JVMState::Created) &&
(state != JVMState::ErrorShutdown) &&
(state != JVMState::Shutdown);
}
void JVMForeignRuntime::stop() {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Beginning of JVMThread shutdown" << std::endl;
}
if (isRunning()) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVMThread is running" << std::endl;
}
controlData.workOperation = JVMWorkOperation::Shutdown;
notifyWorkPrepared();
//waitForWorkCompleted(); - On Windows, stoping in destructor happens when worker thread is already destroyed/vanished
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Joining JVM thread ..." << std::endl;
}
jvmThread.join();
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVM thread joined" << std::endl;
}
} else {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - JVMThread is not running" << std::endl;
}
}
}
FR_Id JVMForeignRuntime::getId() {
return id;
}
std::shared_ptr<FR_Type> JVMForeignRuntime::lookupType(const std::string& name) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Looking for type: (" << name << ")" << std::endl;
}
auto search = typeCache.find(name);
if (search != typeCache.end()) {
return search->second;
} else if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "Type " << name << " not found in cache" << std::endl;
}
std::shared_ptr<JVMOpParams_TypeLookup> params = std::make_shared<JVMOpParams_TypeLookup>();
params->typeName = name;
auto& localId = id;
JVMOp op = [this,localId](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "Started type lookup ..." << std::endl;
}
auto typeLookupParams = std::static_pointer_cast<JVMOpParams_TypeLookup>(opParams);
std::string javaTypeName = typeLookupParams->typeName;
std::replace(javaTypeName.begin(), javaTypeName.end(), '.', '/');
jclass type = env->FindClass(javaTypeName.c_str());
if (type != nullptr) {
javaTypeName = "L" + javaTypeName + ";";
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Type (" << typeLookupParams->typeName << ") found" << std::endl;
}
jmethodID method_GetClass = env->GetMethodID(type, "getClass", "()Ljava/lang/Class;");
assert(method_GetClass);
auto type_Class = env->CallObjectMethod(type, method_GetClass);
jclass clazzClass = env->GetObjectClass(type_Class);
assert(clazzClass);
jmethodID method_getTypeParameters = env->GetMethodID(clazzClass, "getTypeParameters", "()[Ljava/lang/reflect/TypeVariable;");
assert(method_getTypeParameters);
jobjectArray typeParameters = static_cast<jobjectArray> (env->CallObjectMethod(type_Class, method_getTypeParameters));
assert(typeParameters);
jsize typeParametersCount = env->GetArrayLength(typeParameters);
if (typeParametersCount == 0) {
typeLookupParams->type = std::shared_ptr<JVMType>(new JVMType(localId, type, typeLookupParams->typeName, javaTypeName), [ = ] (JVMType* jvmType) {
release(jvmType);
delete jvmType;
});
return;
}
jclass classClass = env->FindClass("java/lang/Class");
assert(classClass);
jmethodID class_getName = env->GetMethodID(classClass, "getName", "()Ljava/lang/String;");
assert(class_getName);
std::map<std::string, std::vector < std::string>> typeBoundsMap;
for (jsize i = 0; i < typeParametersCount; i++) {
wrappers::TypeVariable typeParameter(env, env->GetObjectArrayElement(typeParameters, i));
std::string name = typeParameter.getName();
jobjectArray bounds = typeParameter.getBounds();
jsize boundsCount = env->GetArrayLength(bounds);
std::vector<std::string> typeBounds;
for (jsize i = 0; i < boundsCount; i++) {
wrappers::Type type(env, env->GetObjectArrayElement(bounds, i));
typeBounds.push_back(std::move(type.getTypeName()));
}
typeBoundsMap.emplace(name, typeBounds);
}
auto jvmGenericType = std::make_shared<JVMGenericType>(localId, type, typeLookupParams->typeName, javaTypeName);
jvmGenericType->setTypeParameterInfo(typeBoundsMap);
typeLookupParams->type = jvmGenericType;
} else {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Type (" << typeLookupParams->typeName << ") not found" << std::endl;
}
typeLookupParams->type = nullptr;
}
};
std::cout << "Clinet - Op: " << op.target<void(JNIEnv*, std::shared_ptr<JVMOpParams>)>() << std::endl;
execute(op, params);
if (params->type != nullptr) {
typeCache.insert({name, params->type});
}
return params->type;
}
// Currently, type can be "accidently" retrofited with generic information.
// Should for example "ArrayList" and "ArrayList<Integer>" should be represented with same JVMType instace ?
// If yes, then must be decided how to distinct non-generic and generics calls and provide checks
// If class lookup without explicit type parameters, calls to generic methods/fields checked against type bounds
// If class lookup with explicit type parameters, calls to generic methods/fields checked against provided type parameters
// Behind, Generic and Non-generic versions of class will have handle to barebone class.
// Generic handling mode: JLS or Flexible
// Mode_JLS - As defined in Java Language Specification, for example:
// void work(List<Object> items);
// List<String> messages = new ArrayList<String>();
// //COMPILE_ERROR work(messages)
// Mode_Flexible - Takes type parameter hierarchy into consideration, for example:
// String message = "Test Message";
// Object obj = message; "String" extends "Object"
// >>> Then >>>
// void work(List<Object> items);
// List<String> messages = new ArrayList<String>();
// work(messages) // Valid in this mode
std::shared_ptr<FR_Type> JVMForeignRuntime::lookupGenericType(const std::string& name, std::initializer_list<std::shared_ptr<FR_Type>> typeParameters) {
//if(typeParameters.size() == 0) {
// return nullptr;
//}
//auto type = lookupType(name);
//auto jvmType = std::static_pointer_cast<JVMType>(type);
//auto typeParametersLookup = std::make_shared<JVMOpParams_TypeParametersLookup>();
//typeParametersLookup->target = jvmType;
//JVMOp op = [](JNIEnv* env,std::shared_ptr<JVMOpParams> opParams) {
// if(LOG_JVMFOREIGNRUNTIME) {
// std::cout << "Started type parameter lookup ..." << std::endl;
// }
// auto typeParametersLookup = std::static_pointer_cast<JVMOpParams_TypeParametersLookup>(opParams);
// auto jvmType = typeParametersLookup->target;
// jclass clazz = jvmType->getType();
// jmethodID method_GetClass = env->GetMethodID(clazz,"getClass","()Ljava/lang/Class;");
// assert(method_GetClass);
// jclass clazzClass = env->GetObjectClass(clazz);
// jmethodID method_getTypeParameters = env->GetMethodID(clazzClass,"getTypeParameters","()[Ljava/lang/reflect/TypeVariable;");
// assert(method_getTypeParameters);
// jobjectArray typeParameters = static_cast<jobjectArray>(env->CallObjectMethod(clazz,method_getTypeParameters));
// assert(typeParameters);
// jsize typeParametersCount = env->GetArrayLength(typeParameters);
// if (typeParametersCount == 0) {
// typeParametersLookup->target = nullptr;
// return;
// }
// std::cout << "Type parameters: " << typeParametersCount << std::endl;
// jclass classTypeParameter = env->FindClass("java/lang/reflect/TypeVariable");
// assert(classTypeParameter);
// jmethodID method_getName = env->GetMethodID(classTypeParameter,"getName","()Ljava/lang/String;");
// assert(method_getName);
// jmethodID method_getBounds = env->GetMethodID(classTypeParameter,"getBounds","()[Ljava/lang/reflect/Type;");
// assert(method_getBounds);
// jclass classClass = env->FindClass("java/lang/Class");
// assert(classClass);
// jmethodID class_getName = env->GetMethodID(classClass,"getName","()Ljava/lang/String;");
// assert(class_getName);
// std::map<jstring, std::vector<jobject>> typeBoundsMap;
// for(jsize i = 0; i < typeParametersCount; i++) {
// jobject typeParameter = env->GetObjectArrayElement(typeParameters,i);
// jstring name = static_cast<jstring>(env->CallObjectMethod(typeParameter,method_getName));
// jboolean isNameCopy;
// const char* nameNative = env->GetStringUTFChars(name,&isNameCopy);
// if(isNameCopy == JNI_TRUE) {
// env->ReleaseStringUTFChars(name,nameNative);
// }
// jobjectArray bounds = static_cast<jobjectArray>(env->CallObjectMethod(typeParameter,method_getBounds));
// assert(bounds);
// jsize boundsCount = env->GetArrayLength(bounds);
// std::vector<jobject> typeBounds;
// for(jsize i = 0; i < boundsCount; i++) {
// jobject bound = env->GetObjectArrayElement(bounds,i);
// typeBounds.push_back(bound);
// }
// typeBoundsMap.emplace(name, typeBounds);
// }
// auto jvmGenericType = std::make_shared<JVMGenericType>(jvmType->getRuntimeId(), jvmType->getType(), jvmType->getName(), jvmType->getSignatureName());
// jvmGenericType->setTypeParameterInfo(typeBoundsMap);
// typeParametersLookup->target = jvmGenericType;
//};
//execute(op,typeParametersLookup);
//return typeParametersLookup->target;
//// 1. Type parameters - count and namespace
//// 2. If count do not match with type count passed to method, return error
//// 2. If count do match with type count passed to method, assign types to parameter type names in order as passed to method;
//// 1. field lookup: if field has generic type (aka.: specified with parameter type name)
//// 2. method lookup
return nullptr;
}
std::string JVMForeignRuntime::prepareMethodSignature(const std::vector<std::shared_ptr<FR_Type>> ¶metersTypes, const std::shared_ptr<FR_Type> returnType) {
std::string signature;
signature.append("(");
for (std::vector<std::shared_ptr < FR_Type>>::size_type i = 0; i < parametersTypes.size(); i++) {
auto jvmType = std::static_pointer_cast<JVMType>(parametersTypes[i]);
signature.append(jvmType->getSignatureName());
}
signature.append(")");
if (returnType != nullptr) {
signature.append(std::static_pointer_cast<JVMType>(returnType)->getSignatureName());
} else {
signature.append("V");
}
return signature;
}
std::shared_ptr<FR_Method> JVMForeignRuntime::lookupConstructor(std::shared_ptr<FR_Type> targetType, const std::vector<std::shared_ptr<FR_Type>>¶metersTypes) {
check(targetType);
for (auto parameterType : parametersTypes) {
check(parameterType);
}
std::string methodSignature = prepareMethodSignature(parametersTypes, nullptr);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Signature: " << methodSignature << std::endl;
std::cout << ">>>> DEBUG: Looking for constructor ..." << std::endl;
}
auto params = std::make_shared<JVMOpParams_MethodLookup>();
params->type = targetType;
params->methodName = "<init>";
params->methodSignature = methodSignature;
auto op = [](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto methodLookupParams = std::static_pointer_cast<JVMOpParams_MethodLookup>(opParams);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Looking for constructor: (" << methodLookupParams->methodName << ")" << std::endl;
}
auto type = std::static_pointer_cast<JVMType>(methodLookupParams->type);
jmethodID method = env->GetMethodID(type->getType(), methodLookupParams->methodName.c_str(), methodLookupParams->methodSignature.c_str());
if (LOG_JVMFOREIGNRUNTIME) {
if (method != nullptr) {
std::cout << ">>>> DEBUG: Constructor found" << std::endl;
} else {
std::cout << ">>>> DEBUG: Constructor not found" << std::endl;
}
}
methodLookupParams->method = method;
};
execute(op, params);
if (params->method == nullptr) {
return nullptr;
}
return std::make_shared<JVMMethod>(getId(), params->method, targetType, nullptr);
}
std::shared_ptr<FR_Object> JVMForeignRuntime::createObject(std::shared_ptr<FR_Type> type, std::shared_ptr<FR_Method> constructor, const std::vector<std::shared_ptr<FR_Object>>¶meters) {
check(type);
check(constructor);
for (auto parameter : parameters) {
check(parameter);
}
if (constructor->getType() != type) {
}
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Creating object ..." << std::endl;
}
auto params = std::make_shared<JVMOpParams_ObjectConstruction>();
params->type = type;
params->constructor = constructor;
params->parameters = ¶meters;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto objectConstruction_params = std::static_pointer_cast<JVMOpParams_ObjectConstruction>(opParams);
auto jvmType = std::static_pointer_cast<JVMType>(objectConstruction_params->type);
auto jvmMethod = std::static_pointer_cast<JVMMethod>(objectConstruction_params->constructor);
jobject result;
if (objectConstruction_params->parameters->size() > 0) {
auto callParams = new jvalue[objectConstruction_params->parameters->size()];
for (size_t i = 0; i < objectConstruction_params->parameters->size(); i++) {
auto jvmParam = std::static_pointer_cast<JVMObjectBase>(objectConstruction_params->parameters->at(i));
callParams[i] = jvmParam->toValue();
}
auto returnType = jvmMethod->getReturnType();
result = env->NewObjectA(jvmType->getType(), jvmMethod->getMethod(), callParams);
delete[] callParams;
} else {
std::cout << "No argument constructor" << std::endl;
result = env->NewObject(jvmType->getType(), jvmMethod->getMethod());
}
JVMObject* x = new JVMObject(result, jvmType, getId());
objectConstruction_params->result = std::shared_ptr<JVMObject>(x, [ = ](JVMObject * obj){
release(obj);
delete obj;
});
};
execute(op, params);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Object created" << std::endl;
}
return params->result;
}
void JVMForeignRuntime::release(const FR_Object* obj) {
std::cout << "Releasing object ..." << std::endl;
if (obj == nullptr) {
return;
}
auto params = std::make_shared<JVMOpParams_ObjectRelease>();
params->obj = obj;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto objectReleaseParams = std::static_pointer_cast<JVMOpParams_ObjectRelease>(opParams);
auto jvmObj = static_cast<const JVMObject*> (objectReleaseParams->obj);
jobject jObj = jvmObj->getObject();
env->DeleteLocalRef(jObj);
};
execute(op, params);
std::cout << "Object released" << std::endl;
}
void JVMForeignRuntime::release(const FR_Type* type) {
std::cout << "Releasing type ..." << std::endl;
if (type == nullptr) {
return;
}
auto params = std::make_shared<JVMOpParams_TypeRelease>();
params->type = type;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto typeReleaseParams = std::static_pointer_cast<JVMOpParams_TypeRelease>(opParams);
auto jvmType = static_cast<const JVMType*> (typeReleaseParams->type);
auto jType = jvmType->getType();
env->DeleteLocalRef(jType);
};
execute(op, params);
std::cout << "Type released" << std::endl;
}
std::shared_ptr<FR_Field> JVMForeignRuntime::lookupField(std::shared_ptr<FR_Type> targetType, const std::string& name, const std::shared_ptr<FR_Type> fieldType) {
auto params = std::make_shared<JVMOpParams_FieldLookup>();
params->targetType = targetType;
params->name = name;
params->type = fieldType;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto fieldLookup = std::static_pointer_cast<JVMOpParams_FieldLookup>(opParams);
auto jvmTargetType = std::static_pointer_cast<JVMType>(fieldLookup->targetType);
auto jvmFieldType = std::static_pointer_cast<JVMType>(fieldLookup->type);
jfieldID field = env->GetStaticFieldID(jvmTargetType->getType(), fieldLookup->name.c_str(), jvmFieldType->getSignatureName().c_str());
if (field == nullptr) {
fieldLookup->field = nullptr;
} else {
fieldLookup->field = std::make_shared<JVMField>(jvmTargetType->getRuntimeId(),
field,
fieldLookup->targetType,
fieldLookup->type);
}
};
execute(op, params);
return params->field;
}
std::shared_ptr<FR_Field> JVMForeignRuntime::lookupField(std::shared_ptr<FR_Object> targetObject, const std::string& name, const std::shared_ptr<FR_Type> fieldType) {
return nullptr;
}
std::shared_ptr<FR_Object> JVMForeignRuntime::getField(std::shared_ptr<FR_Type> targetType, std::shared_ptr<FR_Field> field) {
auto params = std::make_shared<JVMOpParams_StaticFieldAccess>();
params->targetType = targetType;
params->field = field;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto staticFieldAccess = std::static_pointer_cast<JVMOpParams_StaticFieldAccess>(opParams);
auto jvmTargetType = std::static_pointer_cast<JVMType>(staticFieldAccess->targetType);
auto jvmField = std::static_pointer_cast<JVMField>(staticFieldAccess->field);
auto jvmFieldType = std::static_pointer_cast<JVMType>(jvmField->getType());
auto accessor = jvmFieldType->getStaticFieldAccessor();
staticFieldAccess->result = accessor(env, jvmTargetType, jvmField);
};
execute(op, params);
return params->result;
}
std::shared_ptr<FR_Object> JVMForeignRuntime::getField(std::shared_ptr<FR_Object> targetObject, std::shared_ptr<FR_Field> field) {
return nullptr;
}
std::shared_ptr<FR_Method> JVMForeignRuntime::lookupMethod(std::shared_ptr<FR_Object> targetObject, const std::string &name, const std::vector<std::shared_ptr<FR_Type>> ¶metersTypes, const std::shared_ptr<FR_Type> returnType) {
check(targetObject);
for (auto parameterType : parametersTypes) {
check(parameterType);
}
check(returnType);
std::string methodSignature = prepareMethodSignature(parametersTypes, returnType);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Signature: " << methodSignature << std::endl;
std::cout << ">>>> DEBUG: Looking for method: (" << name << ")" << std::endl;
}
auto params = std::make_shared<JVMOpParams_MethodLookup>();
params->type = targetObject->getType();
params->methodName = name;
params->methodSignature = methodSignature;
auto op = [](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto methodLookupParams = std::static_pointer_cast<JVMOpParams_MethodLookup>(opParams);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Looking for method: (" << methodLookupParams->methodName << ")" << std::endl;
}
auto type = std::static_pointer_cast<JVMType>(methodLookupParams->type);
jmethodID method = env->GetMethodID(type->getType(), methodLookupParams->methodName.c_str(), methodLookupParams->methodSignature.c_str());
if (LOG_JVMFOREIGNRUNTIME) {
if (method != nullptr) {
std::cout << ">>>> DEBUG: Method (" << methodLookupParams->methodName << ") found" << std::endl;
} else {
std::cout << ">>>> DEBUG: Method (" << methodLookupParams->methodName << ") not found" << std::endl;
}
}
methodLookupParams->method = method;
};
execute(op, params);
if (params->method == nullptr) {
return nullptr;
}
return std::make_shared<JVMMethod>(getId(), params->method, targetObject->getType(), returnType);
}
std::shared_ptr<FR_Method> JVMForeignRuntime::lookupMethod(std::shared_ptr<FR_Type> targetType, const std::string &name, const std::vector<std::shared_ptr<FR_Type>> ¶metersTypes, const std::shared_ptr<FR_Type> returnType) {
check(targetType);
for (auto parameterType : parametersTypes) {
check(parameterType);
}
check(returnType);
std::string methodSignature = prepareMethodSignature(parametersTypes, returnType);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Signature: " << methodSignature << std::endl;
std::cout << ">>>> DEBUG: Looking for method: (" << name << ")" << std::endl;
}
auto params = std::make_shared<JVMOpParams_MethodLookup>();
params->type = targetType;
params->methodName = name;
params->methodSignature = methodSignature;
auto op = [](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto methodLookupParams = std::static_pointer_cast<JVMOpParams_MethodLookup>(opParams);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Looking for method: (" << methodLookupParams->methodName << ")" << std::endl;
}
auto type = std::static_pointer_cast<JVMType>(methodLookupParams->type);
jmethodID method = env->GetStaticMethodID(type->getType(), methodLookupParams->methodName.c_str(), methodLookupParams->methodSignature.c_str());
//if(LOG_JVMFOREIGNRUNTIME) {
if (method != nullptr) {
std::cout << ">>>> DEBUG: Method (" << methodLookupParams->methodName << ") found" << std::endl;
} else {
std::cout << ">>>> DEBUG: Method (" << methodLookupParams->methodName << ") not found" << std::endl;
}
//}
methodLookupParams->method = method;
};
execute(op, params);
if (params->method == nullptr) {
return nullptr;
}
return std::make_shared<JVMMethod>(getId(), params->method, targetType, returnType);
}
std::shared_ptr<nigiri::FR_Object> JVMForeignRuntime::call(std::shared_ptr<FR_Object> targetObject, std::shared_ptr<FR_Method> method, const std::vector<std::shared_ptr<FR_Object>> ¶meters) {
check(targetObject);
check(method);
for (auto parameter : parameters) {
check(parameter);
}
auto targetObjectType = std::static_pointer_cast<JVMType>(targetObject->getType());
if (targetObjectType->isPrimitive()) {
throw "Attempt to call method on primitive type value";
}
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Invoking object method ..." << std::endl;
}
auto params = std::make_shared<JVMOpParams_InstanceMethodCall>();
params->object = targetObject;
params->method = method;
params->parameters = ¶meters;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto instanceMethodCall_params = std::static_pointer_cast<JVMOpParams_InstanceMethodCall>(opParams);
auto jvmObject = std::static_pointer_cast<JVMObject>(instanceMethodCall_params->object);
auto jvmMethod = std::static_pointer_cast<JVMMethod>(instanceMethodCall_params->method);
auto callParams = new jvalue[instanceMethodCall_params->parameters->size()];
for (size_t i = 0; i < instanceMethodCall_params->parameters->size(); i++) {
auto jvmParam = std::static_pointer_cast<JVMObjectBase>(instanceMethodCall_params->parameters->at(i));
callParams[i] = jvmParam->toValue();
}
auto returnType = std::static_pointer_cast<JVMType>(jvmMethod->getReturnType());
if (returnType == nullptr) {
env->CallVoidMethodA(jvmObject->getObject(), jvmMethod->getMethod(), callParams);
} else {
auto caller = returnType->getInstanceMethodCaller();
instanceMethodCall_params->result = caller(env, jvmObject, jvmMethod, callParams);
}
delete[] callParams;
};
execute(op, params);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Object method returned" << std::endl;
}
return params->result;
}
std::shared_ptr<nigiri::FR_Object> JVMForeignRuntime::call(std::shared_ptr<FR_Type> targetType, std::shared_ptr<FR_Method> method, const std::vector<std::shared_ptr<FR_Object>> ¶meters) {
check(targetType);
check(method);
for (auto parameter : parameters) {
check(parameter);
}
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Invoking type method ..." << std::endl;
}
auto params = std::make_shared<JVMOpParams_StaticMethodCall>();
params->type = targetType;
params->method = method;
params->parameters = ¶meters;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto staticMethodCall_params = std::static_pointer_cast<JVMOpParams_StaticMethodCall>(opParams);
auto jvmType = std::static_pointer_cast<JVMType>(staticMethodCall_params->type);
auto jvmMethod = std::static_pointer_cast<JVMMethod>(staticMethodCall_params->method);
auto callParams = new jvalue[staticMethodCall_params->parameters->size()];
for (size_t i = 0; i < staticMethodCall_params->parameters->size(); i++) {
auto jvmParam = std::static_pointer_cast<JVMObjectBase>(staticMethodCall_params->parameters->at(i));
callParams[i] = jvmParam->toValue();
}
auto returnType = std::static_pointer_cast<JVMType>(jvmMethod->getReturnType());
if (returnType == nullptr) {
env->CallStaticVoidMethodA(jvmType->getType(), jvmMethod->getMethod(), callParams);
} else {
auto caller = returnType->getStaticMethodCaller();
staticMethodCall_params->result = caller(env, jvmType, jvmMethod, callParams);
}
delete[] callParams;
};
execute(op, params);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Type method returned" << std::endl;
}
return params->result;
}
void JVMForeignRuntime::execute(JVMOp jvmOp, std::shared_ptr<JVMOpParams> params) {
controlData.jvmOp = jvmOp;
controlData.jvmOpParams = params;
notifyWorkPrepared();
waitForWorkCompleted();
}
void JVMForeignRuntime::notifyWorkPrepared() {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Work prepared" << std::endl;
}
controlData.stateMachine.submitEvent(JVMEvent::Work_Prepared);
}
void JVMForeignRuntime::waitForWorkCompleted() {
controlData.stateMachine.waitForState(JVMState::WorkCompleted);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - Work completed" << std::endl;
}
controlData.stateMachine.submitEvent(JVMEvent::Work_Idle);
controlData.jvmOpParams = nullptr;
}
bool JVMForeignRuntime::isAvailable() {
JVMState state = controlData.stateMachine.getState();
if (state == JVMState::Started || state == JVMState::WorkCompleted) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - System ready for work" << std::endl;
}
return true;
} else {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "[" << getThreadIdString(std::this_thread::get_id()) << "] JVMForeignRuntime - System not ready for work, current state: " << getStateString(state) << std::endl;
}
return false;
}
}
JVMForeignRuntime::ControlData::~ControlData() {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << "DEBUG - JVMForeignRuntime::ControlData - dtor" << std::endl;
}
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(uint16_t value) {
return std::make_shared<JVM_Char>(
value,
std::static_pointer_cast<JVMType_Char>(TYPE_CHAR),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(bool value) {
return std::make_shared<JVM_Boolean>(
value,
std::static_pointer_cast<JVMType_Boolean>(TYPE_BOOLEAN),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(int8_t value) {
return std::make_shared<JVM_Int8>(
value,
std::static_pointer_cast<JVMType_Int8>(TYPE_INT8),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(int16_t value) {
return std::make_shared<JVM_Int16>(
value,
std::static_pointer_cast<JVMType_Int16>(TYPE_INT16),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(int32_t value) {
return std::make_shared<JVM_Int32>(
value,
std::static_pointer_cast<JVMType_Int32>(TYPE_INT32),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(int64_t value) {
return std::make_shared<JVM_Int64>(
value,
std::static_pointer_cast<JVMType_Int64>(TYPE_INT64),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(float value) {
return std::make_shared<JVM_Float>(
value,
std::static_pointer_cast<JVMType_Float>(TYPE_FLOAT),
getId());
}
std::shared_ptr<FR_Object> JVMForeignRuntime::wrapPrimitive(double value) {
return std::make_shared<JVM_Double>(
value,
std::static_pointer_cast<JVMType_Double>(TYPE_DOUBLE),
getId());
}
std::string JVMForeignRuntime::extractString(std::shared_ptr<JVMObject> obj) {
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: Extracting string ..." << std::endl;
}
auto params = std::make_shared<JVMOpParams_StringExtraction>();
params->target = obj;
auto op = [this](JNIEnv* env, std::shared_ptr<JVMOpParams> opParams) {
auto opParams_StringExtraction = std::static_pointer_cast<JVMOpParams_StringExtraction>(opParams);
jstring jvmStr = static_cast<jstring> (opParams_StringExtraction->target->getObject());
jboolean isCopy;
const char* data = env->GetStringUTFChars(jvmStr, &isCopy);
opParams_StringExtraction->result = std::string(data);
if (isCopy == JNI_TRUE) {
env->ReleaseStringUTFChars(jvmStr, data);
}
};
execute(op, params);
if (LOG_JVMFOREIGNRUNTIME) {
std::cout << ">>>> DEBUG: String extracted" << std::endl;
}
return params->result;
}
std::string JVMForeignRuntime::toString(std::shared_ptr<FR_Object> obj) {
check(obj);
auto jvmObjectBase = std::static_pointer_cast<JVMObjectBase>(obj);
auto jvmType = std::static_pointer_cast<JVMType>(obj->getType());
if (jvmType->isPrimitive()) {
return "";
} else {
auto jvmObject = std::static_pointer_cast<JVMObject>(jvmObjectBase);
if (jvmType->getName().compare("java.lang.String") == 0) {
return extractString(jvmObject);
} else {
return "";
}
}
}
void JVMForeignRuntime::check(const std::shared_ptr<FR_Type>& type) {
if (type == nullptr) {
throw std::invalid_argument("Type is nullptr");
} else if (type->getRuntimeId() != getId()) {
throw std::invalid_argument("Provided type do not belongs to this foreign runtime");
}
}
void JVMForeignRuntime::check(const std::shared_ptr<FR_Method>& method) {
if (method == nullptr) {
throw std::invalid_argument("Method is nullptr");
} else if (method->getRuntimeId() != getId()) {
throw std::invalid_argument("Provided method do not belongs to this foreign runtime");
}
}
void JVMForeignRuntime::check(const std::shared_ptr<FR_Object>& object) {
if (object == nullptr) {
throw std::invalid_argument("Object is nullptr");
} else if (object->getRuntimeId() != getId()) {
throw std::invalid_argument("Provided object do not belongs to this foreign runtime");
}
}
std::string getThreadIdString(std::thread::id tid) {
static std::hash<std::thread::id> hasher;
auto hash = hasher(tid);
return std::to_string(hash);
}
}
}
| 49.035005 | 239 | 0.556859 |
835eeb9c421c54a05d8e97186d80551cc25a01ad | 21,869 | cpp | C++ | implementations/Vulkan/texture.cpp | rsayers/abstract-gpu | 48176fcb88bde7d56de662c9e49d3d0e562819e1 | [
"MIT"
] | 41 | 2016-03-25T18:14:37.000Z | 2022-01-20T11:16:52.000Z | implementations/Vulkan/texture.cpp | rsayers/abstract-gpu | 48176fcb88bde7d56de662c9e49d3d0e562819e1 | [
"MIT"
] | 4 | 2016-05-05T22:08:01.000Z | 2021-12-10T13:06:55.000Z | implementations/Vulkan/texture.cpp | rsayers/abstract-gpu | 48176fcb88bde7d56de662c9e49d3d0e562819e1 | [
"MIT"
] | 9 | 2016-05-23T01:51:25.000Z | 2021-08-21T15:32:37.000Z | #include <algorithm>
#include "texture.hpp"
#include "texture_format.hpp"
#include "texture_view.hpp"
#include "buffer.hpp"
#include "constants.hpp"
namespace AgpuVulkan
{
inline enum VkImageType mapImageType(agpu_texture_type type)
{
switch (type)
{
case AGPU_TEXTURE_2D: return VK_IMAGE_TYPE_2D;
case AGPU_TEXTURE_CUBE: return VK_IMAGE_TYPE_2D;
case AGPU_TEXTURE_3D: return VK_IMAGE_TYPE_3D;
case AGPU_TEXTURE_UNKNOWN:
case AGPU_TEXTURE_BUFFER:
case AGPU_TEXTURE_1D:
default: return VK_IMAGE_TYPE_1D;
}
}
inline enum VkImageViewType mapImageViewType(agpu_texture_type type, bool isArray)
{
switch (type)
{
case AGPU_TEXTURE_UNKNOWN:
case AGPU_TEXTURE_BUFFER:
case AGPU_TEXTURE_1D: return isArray ? VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D;
case AGPU_TEXTURE_2D: return isArray ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D;
case AGPU_TEXTURE_CUBE: return isArray ? VK_IMAGE_VIEW_TYPE_CUBE_ARRAY : VK_IMAGE_VIEW_TYPE_CUBE;
case AGPU_TEXTURE_3D: return VK_IMAGE_VIEW_TYPE_3D;
default: return VK_IMAGE_VIEW_TYPE_1D;
}
}
inline enum VkComponentSwizzle mapComponentSwizzle(agpu_component_swizzle swizzle)
{
switch (swizzle)
{
case AGPU_COMPONENT_SWIZZLE_IDENTITY: return VK_COMPONENT_SWIZZLE_IDENTITY;
case AGPU_COMPONENT_SWIZZLE_ONE: return VK_COMPONENT_SWIZZLE_ONE;
case AGPU_COMPONENT_SWIZZLE_ZERO: return VK_COMPONENT_SWIZZLE_ZERO;
case AGPU_COMPONENT_SWIZZLE_R: return VK_COMPONENT_SWIZZLE_R;
case AGPU_COMPONENT_SWIZZLE_G: return VK_COMPONENT_SWIZZLE_G;
case AGPU_COMPONENT_SWIZZLE_B: return VK_COMPONENT_SWIZZLE_B;
case AGPU_COMPONENT_SWIZZLE_A: return VK_COMPONENT_SWIZZLE_A;
default: return VK_COMPONENT_SWIZZLE_ZERO;
}
}
static VkExtent3D getLevelExtent(const agpu_texture_description &description, int level)
{
VkExtent3D extent;
extent.width = description.width >> level;
if (extent.width == 0)
extent.width = 1;
extent.height = description.height >> level;
if (description.type == AGPU_TEXTURE_1D || extent.height == 0)
extent.height = 1;
extent.depth = description.depth >> level;
if (description.type != AGPU_TEXTURE_3D || extent.depth == 0)
extent.depth = 1;
return extent;
}
static void computeBufferImageTransferLayout(const agpu_texture_description &description, int level, VkSubresourceLayout *layout, VkBufferImageCopy *copy)
{
auto extent = getLevelExtent(description, level);
memset(copy, 0, sizeof(*copy));
memset(layout, 0, sizeof(*layout));
// vkGetImageSubResource layout is not appropiate for this.
if(isCompressedTextureFormat(description.format))
{
auto compressedBlockSize = blockSizeOfCompressedTextureFormat(description.format);
auto compressedBlockWidth = blockWidthOfCompressedTextureFormat(description.format);
auto compressedBlockHeight = blockHeightOfCompressedTextureFormat(description.format);
auto alignedExtent = extent;
alignedExtent.width = (uint32_t)std::max(compressedBlockWidth, (extent.width + compressedBlockWidth - 1)/compressedBlockWidth*compressedBlockWidth);
alignedExtent.height = (uint32_t)std::max(compressedBlockHeight, (extent.height + compressedBlockHeight - 1)/compressedBlockHeight*compressedBlockHeight);
copy->imageExtent = extent;
copy->bufferRowLength = alignedExtent.width;
copy->bufferImageHeight = alignedExtent.height;
layout->rowPitch = copy->bufferRowLength / compressedBlockWidth * compressedBlockSize;
layout->depthPitch = layout->rowPitch * (copy->bufferImageHeight / compressedBlockHeight) ;
layout->size = layout->depthPitch * extent.depth;
}
else
{
copy->imageExtent = extent;
auto uncompressedPixelSize = pixelSizeOfTextureFormat(description.format);
layout->rowPitch = (extent.width*uncompressedPixelSize + 3) & -4;
layout->depthPitch = layout->rowPitch * extent.height;
layout->size = layout->depthPitch;
copy->bufferRowLength = uint32_t(layout->rowPitch / uncompressedPixelSize);
copy->bufferImageHeight = uint32_t(extent.height);
}
}
AVkTexture::AVkTexture(const agpu::device_ref &device)
: device(device)
{
image = VK_NULL_HANDLE;
owned = false;
}
AVkTexture::~AVkTexture()
{
if (!owned)
return;
if(image)
vmaDestroyImage(deviceForVk->sharedContext->memoryAllocator, image, memory);
}
agpu::texture_ref AVkTexture::create(const agpu::device_ref &device, agpu_texture_description *description)
{
if (!description)
return agpu::texture_ref();
if (description->type == AGPU_TEXTURE_CUBE && description->layers % 6 != 0)
return agpu::texture_ref();
auto isDepthStencil = (description->usage_modes & (AGPU_TEXTURE_USAGE_DEPTH_ATTACHMENT | AGPU_TEXTURE_USAGE_STENCIL_ATTACHMENT)) != 0;
// Create the image
VkImageCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
createInfo.imageType = mapImageType(description->type);
createInfo.format = mapTextureFormat(description->format, isDepthStencil);
createInfo.extent.width = description->width;
createInfo.extent.height = description->height;
createInfo.extent.depth = description->depth;
createInfo.arrayLayers = description->layers;
createInfo.mipLevels = description->miplevels;
createInfo.samples = mapSampleCount(description->sample_count);
createInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
auto initialUsageMode = AGPU_TEXTURE_USAGE_NONE;
if(description->type == AGPU_TEXTURE_CUBE)
createInfo.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
auto usageModes = description->usage_modes;
auto mainUsageMode = description->main_usage_mode;
//VkImageLayout initialLayout = mapTextureUsageModeToLayout(usageModes, mainUsageMode);
VkImageAspectFlags imageAspect = VK_IMAGE_ASPECT_COLOR_BIT;
if(usageModes & AGPU_TEXTURE_USAGE_SAMPLED)
createInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
if(usageModes & AGPU_TEXTURE_USAGE_STORAGE)
createInfo.usage |= VK_IMAGE_USAGE_STORAGE_BIT;
if (usageModes & AGPU_TEXTURE_USAGE_COLOR_ATTACHMENT)
createInfo.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (isDepthStencil)
{
createInfo.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
imageAspect = 0;
if (usageModes & (AGPU_TEXTURE_USAGE_DEPTH_ATTACHMENT))
imageAspect = VK_IMAGE_ASPECT_DEPTH_BIT;
if (usageModes & (AGPU_TEXTURE_USAGE_STENCIL_ATTACHMENT))
imageAspect |= VK_IMAGE_ASPECT_STENCIL_BIT;
}
createInfo.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VmaAllocationCreateInfo allocInfo = {};
allocInfo.usage = mapHeapType(description->heap_type);
VkImage image;
VmaAllocation textureMemory;
auto error = vmaCreateImage(deviceForVk->sharedContext->memoryAllocator, &createInfo, &allocInfo, &image, &textureMemory, nullptr);
if(error)
return agpu::texture_ref();
VkImageSubresourceRange wholeImageSubresource = {};
wholeImageSubresource.layerCount = createInfo.arrayLayers;
wholeImageSubresource.levelCount = description->miplevels;
wholeImageSubresource.aspectMask = imageAspect;
bool success = false;
auto& descriptionClearValue = description->clear_value;
VkClearColorValue colorClearValue = {};
colorClearValue.float32[0] = descriptionClearValue.color.r;
colorClearValue.float32[1] = descriptionClearValue.color.g;
colorClearValue.float32[2] = descriptionClearValue.color.b;
colorClearValue.float32[3] = descriptionClearValue.color.a;
if (usageModes & (AGPU_TEXTURE_USAGE_DEPTH_ATTACHMENT | AGPU_TEXTURE_USAGE_STENCIL_ATTACHMENT))
{
VkClearDepthStencilValue depthStencilClearValue = {};
depthStencilClearValue.depth = descriptionClearValue.depth_stencil.depth;
depthStencilClearValue.stencil = descriptionClearValue.depth_stencil.stencil;
deviceForVk->withSetupCommandListDo([&] (AVkImplicitResourceSetupCommandList &setupList) {
success =
setupList.setupCommandBuffer() &&
setupList.transitionImageUsageMode(image, usageModes, AGPU_TEXTURE_USAGE_NONE, AGPU_TEXTURE_USAGE_COPY_DESTINATION, wholeImageSubresource) &&
setupList.clearImageWithDepthStencil(image, wholeImageSubresource, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, &depthStencilClearValue) &&
setupList.transitionImageUsageMode(image, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, mainUsageMode, wholeImageSubresource) &&
setupList.submitCommandBuffer();
});
}
else if (usageModes == AGPU_TEXTURE_USAGE_COLOR_ATTACHMENT)
{
deviceForVk->withSetupCommandListDo([&] (AVkImplicitResourceSetupCommandList &setupList) {
success =
setupList.setupCommandBuffer() &&
setupList.transitionImageUsageMode(image, usageModes, initialUsageMode, AGPU_TEXTURE_USAGE_COPY_DESTINATION, wholeImageSubresource) &&
setupList.clearImageWithColor(image, wholeImageSubresource, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, &colorClearValue) &&
setupList.transitionImageUsageMode(image, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, mainUsageMode, wholeImageSubresource) &&
setupList.submitCommandBuffer();
});
}
else
{
if(!isCompressedTextureFormat(description->format))
{
deviceForVk->withSetupCommandListDo([&] (AVkImplicitResourceSetupCommandList &setupList) {
success =
setupList.setupCommandBuffer() &&
setupList.transitionImageUsageMode(image, usageModes, initialUsageMode, AGPU_TEXTURE_USAGE_COPY_DESTINATION, wholeImageSubresource) &&
setupList.clearImageWithColor(image, wholeImageSubresource, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, &colorClearValue) &&
setupList.transitionImageUsageMode(image, usageModes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, mainUsageMode, wholeImageSubresource) &&
setupList.submitCommandBuffer();
});
}
else
{
deviceForVk->withSetupCommandListDo([&] (AVkImplicitResourceSetupCommandList &setupList) {
success =
setupList.setupCommandBuffer() &&
setupList.transitionImageUsageMode(image, usageModes, initialUsageMode, mainUsageMode, wholeImageSubresource) &&
setupList.submitCommandBuffer();
});
}
}
if (!success)
{
vmaDestroyImage(deviceForVk->sharedContext->memoryAllocator, image, textureMemory);
return agpu::texture_ref();
}
auto result = agpu::makeObject<AVkTexture> (device);
auto texture = result.as<AVkTexture> ();
texture->description = *description;
texture->image = image;
texture->memory = textureMemory;
texture->owned = true;
texture->imageAspect = imageAspect;
if (isCompressedTextureFormat(description->format))
{
texture->texelSize = uint8_t(blockSizeOfCompressedTextureFormat(description->format));
texture->texelWidth = uint8_t(blockWidthOfCompressedTextureFormat(description->format));
texture->texelHeight = uint8_t(blockHeightOfCompressedTextureFormat(description->format));
}
else
{
texture->texelSize = pixelSizeOfTextureFormat(description->format);
texture->texelWidth = 1;
texture->texelHeight = 1;
}
return result;
}
agpu::texture_ref AVkTexture::createFromImage(const agpu::device_ref &device, agpu_texture_description *description, VkImage image)
{
auto result = agpu::makeObject<AVkTexture> (device);
auto texture = result.as<AVkTexture> ();
texture->description = *description;
texture->image = image;
return result;
}
agpu::texture_view_ptr AVkTexture::createView(agpu_texture_view_description* viewDescription)
{
if(!viewDescription) return nullptr;
if(viewDescription->type == AGPU_TEXTURE_CUBE && viewDescription->subresource_range.layer_count % 6 != 0) return nullptr;
bool isArray = viewDescription->type == AGPU_TEXTURE_CUBE
? viewDescription->subresource_range.layer_count > 6
: viewDescription->subresource_range.layer_count > 1;
VkImageViewCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
createInfo.image = image;
createInfo.viewType = mapImageViewType(viewDescription->type, isArray);
createInfo.format = mapTextureFormat(description.format, imageAspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
auto &components = createInfo.components;
components.r = mapComponentSwizzle(viewDescription->components.r);
components.g = mapComponentSwizzle(viewDescription->components.g);
components.b = mapComponentSwizzle(viewDescription->components.b);
components.a = mapComponentSwizzle(viewDescription->components.a);
auto &subresource = createInfo.subresourceRange;
subresource.baseMipLevel = viewDescription->subresource_range.base_miplevel;
subresource.levelCount = viewDescription->subresource_range.level_count;
subresource.baseArrayLayer = viewDescription->subresource_range.base_arraylayer;
subresource.layerCount = viewDescription->subresource_range.layer_count;
subresource.aspectMask = viewDescription->subresource_range.aspect;
VkImageView viewHandle;
auto error = vkCreateImageView(deviceForVk->device, &createInfo, nullptr, &viewHandle);
if (error)
return VK_NULL_HANDLE;
return AVkTextureView::create(device, refFromThis<agpu::texture> (), viewHandle, mapTextureUsageModeToLayout(viewDescription->usage_mode), *viewDescription).disown();
}
agpu::texture_view_ptr AVkTexture::getOrCreateFullView()
{
if(!fullTextureView)
{
agpu_texture_view_description fullTextureViewDescription = {};
getFullViewDescription(&fullTextureViewDescription);
fullTextureView = agpu::texture_view_ref(createView(&fullTextureViewDescription));
}
return fullTextureView.disownedNewRef();
}
agpu_error AVkTexture::getDescription(agpu_texture_description* description)
{
CHECK_POINTER(description);
*description = this->description;
return AGPU_OK;
}
agpu_error AVkTexture::getFullViewDescription(agpu_texture_view_description *viewDescription)
{
CHECK_POINTER(viewDescription);
memset(viewDescription, 0, sizeof(*viewDescription));
viewDescription->type = description.type;
viewDescription->format = description.format;
viewDescription->sample_count = description.sample_count;
viewDescription->components.r = AGPU_COMPONENT_SWIZZLE_R;
viewDescription->components.g = AGPU_COMPONENT_SWIZZLE_G;
viewDescription->components.b = AGPU_COMPONENT_SWIZZLE_B;
viewDescription->components.a = AGPU_COMPONENT_SWIZZLE_A;
viewDescription->usage_mode = description.main_usage_mode;
viewDescription->subresource_range.aspect = agpu_texture_aspect(imageAspect);
viewDescription->subresource_range.base_miplevel = 0;
viewDescription->subresource_range.level_count = description.miplevels;
viewDescription->subresource_range.base_arraylayer = 0;
viewDescription->subresource_range.layer_count = description.layers;
return AGPU_OK;
}
agpu_pointer AVkTexture::mapLevel(agpu_int level, agpu_int arrayIndex, agpu_mapping_access usageModes, agpu_region3d *region)
{
return nullptr;
}
agpu_error AVkTexture::unmapLevel()
{
return AGPU_UNIMPLEMENTED;
}
VkExtent3D AVkTexture::getLevelExtent(int level)
{
return AgpuVulkan::getLevelExtent(description, level);
}
void AVkTexture::computeBufferImageTransferLayout(int level, VkSubresourceLayout *layout, VkBufferImageCopy *copy)
{
return AgpuVulkan::computeBufferImageTransferLayout(description, level, layout, copy);
}
agpu_error AVkTexture::readTextureData(agpu_int level, agpu_int arrayIndex, agpu_int pitch, agpu_int slicePitch, agpu_pointer buffer)
{
return readTextureSubData(level, arrayIndex, pitch, slicePitch, nullptr, nullptr, buffer);
}
agpu_error AVkTexture::readTextureSubData(agpu_int level, agpu_int arrayIndex, agpu_int pitch, agpu_int slicePitch, agpu_region3d* sourceRegion, agpu_size3d* destSize, agpu_pointer buffer)
{
CHECK_POINTER(buffer);
if ((description.usage_modes & AGPU_TEXTURE_USAGE_READED_BACK) == 0)
{
return AGPU_INVALID_OPERATION;
}
VkImageSubresourceRange range;
memset(&range, 0, sizeof(range));
range.baseMipLevel = level;
range.baseArrayLayer = arrayIndex;
range.layerCount = 1;
range.levelCount = 1;
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
VkSubresourceLayout layout;
VkBufferImageCopy copy;
computeBufferImageTransferLayout(level, &layout, ©);
auto extent = getLevelExtent(level);
copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copy.imageSubresource.mipLevel = level;
copy.imageSubresource.baseArrayLayer = arrayIndex;
copy.imageSubresource.layerCount = 1;
copy.imageExtent = extent;
agpu_error resultCode = AGPU_ERROR;
deviceForVk->withReadbackCommandListDo(layout.size, 1, [&](AVkImplicitResourceReadbackCommandList &readbackList) {
if(readbackList.currentStagingBufferSize < layout.size)
{
resultCode = AGPU_OUT_OF_MEMORY;
return;
}
// Copy the image data into staging buffer.
auto success = readbackList.setupCommandBuffer() &&
readbackList.transitionImageUsageMode(image, description.usage_modes, description.main_usage_mode, AGPU_TEXTURE_USAGE_COPY_SOURCE, range) &&
readbackList.readbackImageDataToBuffer(image, copy) &&
readbackList.transitionImageUsageMode(image, description.usage_modes, AGPU_TEXTURE_USAGE_COPY_SOURCE, description.main_usage_mode, range) &&
readbackList.submitCommandBuffer();
if(success)
{
auto readbackPointer = readbackList.currentStagingBufferPointer;
if (agpu_uint(pitch) == layout.rowPitch && agpu_uint(slicePitch) == layout.depthPitch)
{
memcpy(buffer, readbackPointer, slicePitch);
}
else
{
auto srcRow = reinterpret_cast<uint8_t*> (readbackPointer);
auto dstRow = reinterpret_cast<uint8_t*> (buffer);
for (uint32_t y = 0; y < copy.imageExtent.height; ++y)
{
memcpy(dstRow, srcRow, pitch);
srcRow += layout.rowPitch;
dstRow += pitch;
}
}
}
resultCode = success ? AGPU_OK : AGPU_ERROR;
});
return resultCode;
}
agpu_error AVkTexture::uploadTextureData(agpu_int level, agpu_int arrayIndex, agpu_int pitch, agpu_int slicePitch, agpu_pointer data)
{
return uploadTextureSubData(level, arrayIndex, pitch, slicePitch, nullptr, nullptr, data);
}
agpu_error AVkTexture::uploadTextureSubData (agpu_int level, agpu_int arrayIndex, agpu_int pitch, agpu_int slicePitch, agpu_size3d* sourceSize, agpu_region3d* destRegion, agpu_pointer data )
{
CHECK_POINTER(data);
if ((description.usage_modes & AGPU_TEXTURE_USAGE_UPLOADED) == 0)
{
return AGPU_INVALID_OPERATION;
}
VkImageSubresourceRange range = {};
range.baseMipLevel = level;
range.baseArrayLayer = arrayIndex;
range.layerCount = 1;
range.levelCount = 1;
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
VkSubresourceLayout layout;
VkBufferImageCopy copy;
computeBufferImageTransferLayout(level, &layout, ©);
copy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copy.imageSubresource.mipLevel = level;
copy.imageSubresource.baseArrayLayer = arrayIndex;
copy.imageSubresource.layerCount = 1;
agpu_error resultCode = AGPU_OK;
deviceForVk->withUploadCommandListDo(layout.size, 1, [&](AVkImplicitResourceUploadCommandList &uploadList) {
if(uploadList.currentStagingBufferSize < layout.size)
{
resultCode = AGPU_OUT_OF_MEMORY;
return;
}
// Copy the image data into the staging buffer.
auto bufferPointer = uploadList.currentStagingBufferPointer;
auto &extent = copy.imageExtent;
if (agpu_uint(pitch) == layout.rowPitch && agpu_uint(slicePitch) == layout.depthPitch && !sourceSize && !destRegion)
{
memcpy(bufferPointer, data, slicePitch);
}
else
{
auto srcRow = reinterpret_cast<uint8_t*> (data);
auto dstRow = reinterpret_cast<uint8_t*> (bufferPointer);
for (uint32_t y = 0; y < extent.height; ++y)
{
memcpy(dstRow, srcRow, pitch);
srcRow += pitch;
dstRow += layout.rowPitch;
}
}
auto success = uploadList.setupCommandBuffer() &&
uploadList.transitionImageUsageMode(image, description.usage_modes, description.main_usage_mode, AGPU_TEXTURE_USAGE_COPY_DESTINATION, range) &&
uploadList.uploadBufferDataToImage(image, copy) &&
uploadList.transitionImageUsageMode(image, description.usage_modes, AGPU_TEXTURE_USAGE_COPY_DESTINATION, description.main_usage_mode, range) &&
uploadList.submitCommandBuffer();
resultCode = success ? AGPU_OK : AGPU_ERROR;
});
return resultCode;
}
} // End of namespace AgpuVulkan
| 42.136802 | 190 | 0.728063 |
835f55e717ee01d520b1b5fdafab84f9017a3aff | 953 | hpp | C++ | maxon_epos_driver/include/maxon_epos_driver/control/ControlModeBase.hpp | farshad-heravi/maxon_driver | 637688fd4cd1e6aabc4335bad53554f1bc3591bf | [
"MIT"
] | null | null | null | maxon_epos_driver/include/maxon_epos_driver/control/ControlModeBase.hpp | farshad-heravi/maxon_driver | 637688fd4cd1e6aabc4335bad53554f1bc3591bf | [
"MIT"
] | null | null | null | maxon_epos_driver/include/maxon_epos_driver/control/ControlModeBase.hpp | farshad-heravi/maxon_driver | 637688fd4cd1e6aabc4335bad53554f1bc3591bf | [
"MIT"
] | null | null | null | /**
* @file ModeBase
* @brief
* @author arwtyxouymz
* @date 2019-06-04 11:31:01
*/
#ifndef _ModeBase_HPP
#define _ModeBase_HPP
#include <string>
#include <vector>
#include <ros/ros.h>
#include "maxon_epos_driver/Device.hpp"
class ControlModeBase {
public:
std::string name;
virtual ~ControlModeBase();
virtual void init(ros::NodeHandle &motor_nh, NodeHandle &node_handle, const std::string &controller_name, const int &m_max_qc);
// activate operation mode
virtual void activate() = 0;
// read something required for operation mode
virtual void read(double &pos, double &vel, double &cur);
// write commands of operation mode
virtual void write(double &pos, double &vel, double &cur) = 0;
protected:
bool m_use_ros_unit;
int m_max_qc_;
NodeHandle m_epos_handle;
int current_pos_, current_vel_;
};
#endif // _ModeBase_HPP
| 23.825 | 135 | 0.655824 |
836029d5e6fe6b5f521d00fbbcd1dac74cc2a8c6 | 52,229 | cpp | C++ | src/JSystem/JUT/JUTFontData_Ascfont_fix12.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 33 | 2021-12-08T11:10:59.000Z | 2022-03-26T19:59:37.000Z | src/JSystem/JUT/JUTFontData_Ascfont_fix12.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 6 | 2021-12-22T17:54:31.000Z | 2022-01-07T21:43:18.000Z | src/JSystem/JUT/JUTFontData_Ascfont_fix12.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 2 | 2022-01-04T06:00:49.000Z | 2022-01-26T07:27:28.000Z | #include "types.h"
#include "JSystem/JUT/ResFONT.h"
const int JUTResFONT_Ascfont_fix12[] ATTRIBUTE_ALIGN(32)
= { 0x464F4E54, 0x62666E31, 0x00004160, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x494E4631, 0x00000020, 0x0000000C,
0x0000000C, 0x000C0000, 0x00000000, 0x9FFFFFFF, 0x7FFFFFFF, 0x57494431, 0x000000E0, 0x0000005F, 0x000C000C, 0x000C000C, 0x000C000C,
0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C,
0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C,
0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C,
0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C, 0x000C000C,
0x000C000C, 0xEFFFEFFC, 0xF7FFFFFF, 0xFFFFF57F, 0xFFFFFFFF, 0x7FFFFFFD, 0x4D415031, 0x00000020, 0x00000020, 0x007F0000, 0xFFFFFBFF,
0xFF5FFFBF, 0xDFFFBFFF, 0xFFFFFFFE, 0x474C5931, 0x00004020, 0x0000005F, 0x000C000C, 0x00004000, 0x0000002A, 0x00030200, 0x00400000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0x00000000, 0x00000000, 0xFFFF0FFF, 0xFFFF0FFF, 0x00FF000F, 0x0FFF00FF, 0xFFF00FFF, 0xFF000FF0, 0x00000000, 0x00000000, 0xF00000FF,
0xF00000FF, 0xF000FFFF, 0xF000FFFF, 0x000000FF, 0x000000FF, 0x0000FFFF, 0x0000FFFF, 0x00FF0000, 0x00FF0000, 0xFFFFFF00, 0xFFFFFF00,
0x00FF0000, 0x00FF0000, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x0FFFFFFF, 0xFFFFFFFF, 0xFF00FF00, 0xFFFFFFFF, 0x0FFFFFFF, 0x0000FF00,
0xFFFFFFFF, 0x00000FF0, 0xFF00FFFF, 0xFF00FFFF, 0x00000FF0, 0xF0000000, 0xFF00000F, 0xFF0000FF, 0xFF000FFF, 0x0000FF00, 0x000FFF00,
0x00FFF000, 0x0FFF0000, 0xFFF00000, 0xFF000000, 0xF00FF000, 0x00FFFF00, 0x00FFFFF0, 0x0FFFFFFF, 0x0FF000FF, 0x0FFF0FFF, 0x00FFFFF0,
0x0FFFFFF0, 0xFFF00FFF, 0xFF00FFFF, 0x000000FF, 0x000000FF, 0x00000000, 0x0000000F, 0x000000FF, 0xFF0000FF, 0xFF000000, 0xF0000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xF0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000FF0, 0x0000FFF0, 0x000FFF00,
0x000FF000, 0x000FF000, 0x000FF000, 0x000FF000, 0x000FFF00, 0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xF0000000, 0xFF000000, 0xFFF00000, 0x0FF00000, 0x0FF00000, 0x0FF00000, 0x0FF00000, 0xFFF00000, 0x0000FF00,
0xFF00FF00, 0xFFF0FF0F, 0x0FFFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x0FFFFFFF, 0xFFF0FF0F, 0x00000000, 0xFF000000, 0xFF000000, 0xF0000000,
0x0000FFFF, 0x0000FFFF, 0xF0000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000,
0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FFFF0, 0x000FFFF0, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x0000FFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000,
0xFFFFFF00, 0x00000F00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FFF00,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000F, 0x000000FF, 0x00000FFF, 0x0000FF00, 0x000FFF00, 0x00FFF000,
0x0FFF0000, 0xFFF00000, 0xFF000000, 0xF0000000, 0x00000000, 0x0FFFFFFF, 0xFFFFFFFF, 0xFF0000FF, 0xFF000FFF, 0xFF00FFF0, 0xFF0FFF00,
0xFFFFF000, 0xFFFF0000, 0xF0000000, 0xFF00000F, 0xFF00000F, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
0x0FFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xF000FFFF, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF0000FF, 0xF00000FF, 0x00000000,
0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0xFF00000F, 0xFF00000F,
0xFF00000F, 0xFF00000F, 0xFF00000F, 0xFF00000F, 0xFFFFFFFF, 0xFFFFFFFF, 0xF000FFFF, 0xF000FFFF, 0xF000FF00, 0xF000FF00, 0xF000FFFF,
0xF000FFFF, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00,
0x0FFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF00FFFF, 0xFF00FFFF, 0x00000000,
0x00000000, 0xF0000000, 0xFF000000, 0xFF000000, 0xFF00000F, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x000FFF00, 0x00FFF000, 0x0FFF0000,
0xFFF00000, 0xFF000000, 0x0FFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0x0FFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xF0000FFF,
0xFF00FFFF, 0xFF00FF00, 0xFF00FF00, 0xF000FFFF, 0xFF000FFF, 0xFF000000, 0xFF000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00,
0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000, 0x000FFF00, 0x000FFF00, 0x00000000, 0x00000000, 0x00000000,
0x000FFF00, 0x00000000, 0x00000000, 0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x0000000F, 0x00000000, 0x00000000,
0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0x000000FF, 0x00000FFF, 0x0000FFF0, 0x000FFF00, 0x00FFF000,
0x00FFF000, 0x000FFF00, 0x0000FFF0, 0x00000000, 0x00000000, 0x00000000, 0x000000FF, 0x000000FF, 0x00000000, 0x00000000, 0x000000FF,
0x00000000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFF000, 0x00000000, 0x00000000, 0xFFFFF000, 0x00FF0000, 0x00FFF000, 0x000FFF00,
0x0000FFF0, 0x00000FFF, 0x00000FFF, 0x0000FFF0, 0x000FFF00, 0x00000FFF, 0x0000FFFF, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0x0FFFFF00, 0xFFFFF000, 0xFF000000, 0x00000000, 0x00FFFFFF,
0x0FFFFFFF, 0xFFF0000F, 0xFF00FF00, 0xFF0FFFF0, 0xFF0FFFFF, 0xFF00FFFF, 0xFFF00000, 0x00000FFF, 0xF000FFFF, 0xFF00FF00, 0xFF00FF00,
0xFF00FF00, 0xFF00FFFF, 0xF000FFFF, 0x0000FF00, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFFF00,
0x0000FF00, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xF0000FFF, 0xFF00FFFF,
0xFF00FF00, 0xFF00FF00, 0xF000FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF00000F, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF00000F,
0x0000FFFF, 0xF000FFFF, 0xFF00FF00, 0xFF00FF00, 0xFF00FFFF, 0xFF00FFFF, 0xFF00FF00, 0xFF00FF00, 0xFFFFFF00, 0xFFFFFF00, 0x00000000,
0x00000000, 0xFFFFF000, 0xFFFFF000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF,
0xFF000000, 0xFF000000, 0xFF000FFF, 0xFF00FFFF, 0x0000FF00, 0x0000FF00, 0xF000FF00, 0xF000FF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00,
0xFFFFFF00, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000FFF, 0xFF000FFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0xFF000000, 0xFFFFF000, 0xFFFFF000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000FFF,
0x00000FFF, 0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0xF000FF00, 0xF000FF00,
0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x0000FF00, 0x000FFF00, 0x00FFF000, 0x0FFF0000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x000000FF, 0x000000FF, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FFF0,
0x0000FFFF, 0x0000FFFF, 0x00FF0000, 0x00FF0000, 0x00000000, 0x00000000, 0x0000FF00, 0x000FFF00, 0x00FFFF00, 0xFFFFFF00, 0xFFFFFFFF,
0x0000FF00, 0x00000000, 0x00000000, 0xFF000000, 0xFFF00000, 0xFFFF0000, 0xFFFFF000, 0xF000FFF0, 0x0000FF00, 0x00000000, 0x00000000,
0xFF000FFF, 0xFF00FFFF, 0xFF00FF00, 0xFF00FF00, 0x00FFFF00, 0x000FF000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00,
0x0000FF00, 0xFFFFFF0F, 0x0FFFF000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0x00000000, 0x00000000, 0xF0000FFF, 0xFF00FFFF, 0xFF00FF00, 0xFF00FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000,
0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0x0000FFF0, 0x00000FF0, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000,
0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0xF0000FFF, 0xFF00FFFF, 0xFF00FF00, 0xFF00FF00, 0xFF000000, 0xF0000000, 0x00000000,
0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0xFF00FF00, 0x0000FF00, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
0x0000FF00, 0x0000FF00, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0x0000FF00, 0x0000FF00, 0xFF000000,
0xFF000000, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x00000FF0, 0x0000FFF0, 0x000FFF00, 0x000FF000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00,
0xFF00FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x000FFF00, 0x000FFF00,
0x00000000, 0x00000000, 0xFF000000, 0xFFF0000F, 0x0FFF00FF, 0x00FFFFFF, 0x0000FFF0, 0x0000FF00, 0x00000000, 0x00000000, 0xFF00FF00,
0xFF00FFF0, 0xF0000FFF, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FF00, 0x000FFF00, 0x00FFF000, 0xFFFF0000,
0xFFFFFFFF, 0x0FFFFFFF, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x00000FFF, 0xFF00000F, 0xF000000F, 0x00000000,
0x00000000, 0xFF00000F, 0xFF00000F, 0xF000000F, 0x0000000F, 0xFFF00000, 0xFFF00000, 0x00000000, 0x00000000, 0xFFF00000, 0xFFF00000,
0xF0000000, 0xF0000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0xFF000000, 0xFFF00000, 0x0FFF0000, 0x00FFF000, 0xFF00FFFF,
0xFF00FFFF, 0x00000000, 0x00000000, 0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000,
0xFFF00000, 0xFFF00000, 0x0FF00000, 0x0FF00000, 0x0000000F, 0x0000000F, 0x00000000, 0x00000000, 0x0000FF00, 0x000FFFF0, 0x00FFFFFF,
0x0FFF00FF, 0xF000FFFF, 0xF000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000000, 0xFFFFFF00, 0xFFFFF000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x0FFFFFFF, 0x00000000, 0x00000000, 0x00FFFF00,
0x00FFFF00, 0x00FF0000, 0x00FFF000, 0xFF0000FF, 0xF00000FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FFFF, 0x0000FFFF,
0xF0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0xFFFFFFFF, 0x0FFFFFFF, 0x00000000,
0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF00FFFF, 0xF000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000FFF, 0xF000FFFF, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x000FFF00,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00FFFFFF, 0x000000FF, 0x000000FF, 0x00000000, 0x00000000,
0xFF000000, 0xFF000000, 0xFF000FFF, 0xFF00FFFF, 0xF0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000,
0xFFFFFF00, 0x00000FFF, 0x000000FF, 0x00000000, 0x00000000, 0x0000FFFF, 0x000FFFFF, 0x000FF000, 0x000FF000, 0x000000FF, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000FFF, 0x0000FFFF, 0xFFFFF000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00FFF000, 0x00FF0000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000000, 0xFF000000, 0xFF000000, 0x00000000,
0x00000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x0FFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000, 0x000000FF, 0x000000FF,
0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00,
0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FFF00, 0x00FFFF00, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0xFF00FFFF, 0xF0000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FFFF,
0x0000FFFF, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0xFFFFFFFF, 0xFFFFFFFF,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF000FFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xF0000FFF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00,
0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF, 0x00000FFF, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0xF0000FFF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0FF00FFF, 0x0FF0FFFF, 0xFF000FFF,
0xFF000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000FFF, 0xFF00FFFF, 0xFFFFF000, 0xFFFFF000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000F, 0x0000000F, 0xFF00000F, 0xFFF0000F, 0x0FFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000, 0xF000FFFF, 0xF000FFFF,
0xF000FF00, 0xF000FF00, 0xF000FF00, 0x0000FF00, 0x00000000, 0x00000000, 0xFFF00000, 0xFFF00000, 0x0FFF0000, 0x00FFF000, 0x000FFF00,
0x0000FF00, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
0x0000FF0F, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0xFF00FF00, 0xFF00FF00, 0x00000000, 0x00000000, 0xFFF0FF00, 0xFF00FF00, 0x0000FF00,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000, 0xFF0FFF00, 0xFF00FFF0, 0xFF000FFF, 0xFF0000FF, 0xFF00000F, 0xFF000000,
0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FFFF, 0xFF000FFF, 0x00000000, 0x00000000, 0x0000FF00,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000, 0xFF000000,
0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF00FF00, 0xF000FF00, 0x0000FF00, 0x0000FF00, 0x0000FFFF, 0x00000FFF, 0x00000000,
0x00000000, 0xFF00FF00, 0xFFF0FF00, 0x0FFFFF00, 0x00FFF000, 0xFFFFFF00, 0xFFF0FF00, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
0xFF000FFF, 0xFF0000FF, 0xFF00000F, 0xFF000000, 0x00000000, 0x00000000, 0xFF00FFFF, 0xF0000FFF, 0x00000000, 0xF0000000, 0xFF00FFFF,
0xFF00FFFF, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00,
0x0000FF00, 0x0000FFFF, 0x00000FFF, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000,
0x00000000, 0x00000000, 0xFF000000, 0xFFF0000F, 0x0FFF00FF, 0x00FFFFFF, 0x000FFFF0, 0x0000FF00, 0x00000000, 0x00000000, 0xFF00FF00,
0xFF00FF0F, 0xF000FFFF, 0x0000FFFF, 0x0000FFF0, 0x0000FF00, 0x00000000, 0x00000000, 0xFF00FF00, 0xFFF0FF00, 0xFFFFFF00, 0x00FFFF00,
0x000FFF00, 0x0000FF00, 0x00000000, 0x00000000, 0x000FFFF0, 0x000FFFF0, 0x00FFFFFF, 0x0FFF00FF, 0xFFF0000F, 0xFF000000, 0x00000000,
0x00000000, 0x0000000F, 0x00000000, 0x00000000, 0xF00000F0, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFFF00000, 0xFF000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x0000FFF0, 0x000FFF00, 0x00FFF000, 0x0FFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0x00000000, 0x00000000, 0x0000000F, 0x0000000F, 0x0000000F, 0x0000000F, 0xFF00000F, 0xFF00000F, 0x00000000, 0x00000000,
0xF0000000, 0xF0000000, 0xF0000000, 0xF0000000, 0xFFF00000, 0xFFF00000, 0x00000000, 0x00000000, 0x000FFF00, 0x0000FFF0, 0x00000FFF,
0x000000FF, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000000, 0xFF00000F, 0xFF00000F,
0x00000000, 0x00000000, 0x0FF00000, 0x0FF00000, 0x0FF00000, 0x0FF00000, 0xFFF00000, 0xFFF00000, 0x00000000, 0x00000000, 0x0FF0000F,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x0000FFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00,
0xFFFFFF00, 0x000FFF00, 0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000FFF,
0x0000FFFF, 0x0000FF00, 0x0000FFFF, 0x00000FFF, 0x00000000, 0x00000000, 0x0000FF00, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0xFFFFFF00,
0xFFFFFF00, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FFFF, 0xF0000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0x0FFFFFFF, 0x0FF00000, 0x0FF00000, 0x0FF00000, 0x0FFFFFFF, 0x00FFFFFF,
0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FFFF, 0xFF00FFFF, 0xFF00FF00, 0xFF00FFFF, 0xFF000FFF, 0x00000000, 0x00000000, 0x0000FF00,
0xFFFFFF00, 0xFFFFF000, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x000FF000, 0x000FF000,
0x000FF000, 0x000FF000, 0x00000000, 0x00000000, 0xF000FF00, 0xF000FF00, 0x0000FFFF, 0x00000FFF, 0x00000000, 0x00000000, 0x00000FFF,
0x00000FFF, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000, 0xFFFFFFFF, 0xFF000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000,
0xFF000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000,
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x0FF000FF, 0x0FFFFFFF, 0x00FFFFF0, 0x0000FF00, 0x0000FFFF, 0x0000FFFF,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000, 0x0FFF0000, 0xFFF00000, 0xFFF00000, 0x0FFF0000, 0x00FFFF00, 0x000FFF00,
0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FFFF, 0x00000FFF, 0x00000000, 0x00000000, 0x0000FF00,
0x0000FF00, 0x0000FF00, 0x0000FF00, 0xF000FF00, 0xF000FF00, 0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00,
0xFF00FF00, 0xFF00FF00, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0x00000000,
0x00000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FFFF, 0xFF000FFF, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00,
0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FFFF, 0xF0000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x0000FF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFFF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0FFFFF00, 0x0FFFF000, 0x0FFF0000,
0x0FF00000, 0x0FF00000, 0x0FF00000, 0x00000000, 0x00000000, 0xFF00FF00, 0x0000FFFF, 0x00000FFF, 0x00000000, 0x0000FFFF, 0x0000FFFF,
0x00000000, 0x00000000, 0x00000000, 0xFFFFF000, 0xFFFFFF00, 0x0000FF00, 0xFFFFFF00, 0xFFFFF000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FF000, 0x000FF000, 0xFFFFFFFF, 0xFFFFFFFF,
0x000FF000, 0x000FF000, 0x000FF000, 0x000FF000, 0x00000000, 0x00000000, 0xF000FF00, 0xF000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00,
0x0000FF00, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x00000000, 0x00000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFFF0000F, 0x0FFF00FF, 0x00FFFFFF, 0x00000000, 0x00000000, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00,
0xFF00FF0F, 0xF000FFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0xFF00FF00, 0xFFF0FF00, 0xFFFFFF00, 0x00FFFF00,
0x00000000, 0x00000000, 0xFF000000, 0xFFF0000F, 0x0FFF00FF, 0x00FFFFFF, 0x00FFFFFF, 0x0FFF00FF, 0x00000000, 0x00000000, 0xFF00FF00,
0xFF00FFF0, 0xF0000FFF, 0x000000FF, 0x0000000F, 0xF0000000, 0x00000000, 0x00000000, 0x0000FF00, 0x0000FF00, 0x000FFF00, 0xF0FFF000,
0xFFFF0000, 0xFFF00000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000FFF, 0x0000FFF0, 0x000FFF00, 0x00FFF000, 0x00000000,
0x00000000, 0xFF000000, 0xFF000000, 0x00000FFF, 0x00000FFF, 0x00000000, 0x00000000, 0x00FF0000, 0x0FFF0000, 0xFFF00000, 0xFF000000,
0xFF000000, 0xFF000000, 0xFF000000, 0xFFF00000, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00, 0x0000FF00,
0x0000FF00, 0x000000FF, 0x000000FF, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000F, 0x00000000, 0xF0000000,
0xFF000000, 0xFF000000, 0xFFFFF000, 0xFFFFF000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00FFF000, 0x0FFFFF0F,
0xFFF0FFFF, 0xFF000FFF, 0x00000000, 0x0000F0F0, 0x00000000, 0x0000F000, 0xFF000000, 0xFF00F000, 0xF0000000, 0x0000F000, 0x00000000,
0xF0F0F0F0, 0x00000000, 0x000000F0, 0x00000000, 0x000000F0, 0x00000000, 0x000000F0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x000FFFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FFFF,
0x00000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFF00, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FFFF0, 0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000FFF0, 0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000FFF00, 0x0000FF00,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFF0000F, 0xFF000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0xFF00000F, 0xFF0000FF, 0x00000FFF, 0x00000FF0, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFF000000, 0xF0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x0FFF0000, 0x00FF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FF00,
0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000FF, 0x000000FF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xF0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000F000, 0x00000000,
0x0000F0F0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000F0, 0x00000000, 0xF0F0F0F0, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000 };
| 134.958656 | 139 | 0.802753 |
83657a83df638e52db271108ef1b9c692a20ca10 | 8,178 | cpp | C++ | 10-11/JackTokenizer.cpp | jomiller/nand2tetris | 4be20996e1b5185654ef4de5234a9543f957d6fc | [
"MIT"
] | 1 | 2020-10-13T07:06:37.000Z | 2020-10-13T07:06:37.000Z | 10-11/JackTokenizer.cpp | jomiller/nand2tetris | 4be20996e1b5185654ef4de5234a9543f957d6fc | [
"MIT"
] | null | null | null | 10-11/JackTokenizer.cpp | jomiller/nand2tetris | 4be20996e1b5185654ef4de5234a9543f957d6fc | [
"MIT"
] | null | null | null | /*
* This file is part of Nand2Tetris.
*
* Copyright © 2013-2020 Jonathan Miller
*
* 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 "JackTokenizer.h"
#include "JackUtil.h"
#include <Assert.h>
#include <Util.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/lexical_cast.hpp>
#include <frozen/unordered_set.h>
#include <algorithm>
#include <locale>
#include <string_view>
#include <utility>
n2t::JackTokenizer::TokenizerFunction::TokenizerFunction(unsigned int* lineNumber) : m_lineNumber{lineNumber}
{
}
void n2t::JackTokenizer::TokenizerFunction::reset()
{
if (m_lineNumber)
{
*m_lineNumber = 0;
}
m_lineCount = 0;
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4706) // assignment within conditional expression
#endif
bool n2t::JackTokenizer::TokenizerFunction::operator()(std::istreambuf_iterator<char>& next,
std::istreambuf_iterator<char> end,
std::string& tok)
{
tok.clear();
if (m_lineNumber)
{
*m_lineNumber += m_lineCount;
}
m_lineCount = 0;
// skip past all whitespace and comments
bool isSpace = false;
std::locale loc;
while ((next != end) && ((isSpace = std::isspace(*next, loc)) || (*next == '/')))
{
if (isSpace)
{
if (*next == '\n')
{
++m_lineCount;
}
++next;
}
else // (*next == '/')
{
char curr = *next;
++next;
if (next == end)
{
tok += curr;
return true;
}
if (*next == '/') // comment to end of line
{
for (++next; (next != end) && (*next != '\n'); ++next)
{
}
if (next != end)
{
++m_lineCount;
++next;
}
}
else if (*next == '*') /* comment until closing */ /** or API documentation comment */
{
curr = *next;
++next;
if (next != end)
{
curr = *next;
}
for (++next; (next != end) && ((curr != '*') || (*next != '/')); ++next)
{
if (curr == '\n')
{
++m_lineCount;
}
curr = *next;
}
if (next != end)
{
++next;
}
}
else
{
tok += curr;
return true;
}
}
}
if (next == end)
{
return false;
}
if (isDelimiter(*next))
{
if (*next == '"') // string constant
{
do
{
tok += *next;
++next;
}
while ((next != end) && (*next != '\r') && (*next != '\n') && (*next != '"'));
if (*next == '"')
{
tok += *next;
++next;
}
}
else // delimiter character
{
tok += *next;
++next;
}
}
else
{
// append all the non-delimiter characters
for (; (next != end) && !std::isspace(*next, loc) && !isDelimiter(*next); ++next)
{
tok += *next;
}
}
return true;
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
bool n2t::JackTokenizer::TokenizerFunction::isDelimiter(char c)
{
static constexpr std::string_view delimiters{"{}()[].,;+-*/&|~<=>\""};
return (delimiters.find(c) != std::string_view::npos);
}
n2t::JackTokenizer::JackTokenizer(const std::filesystem::path& filename) :
m_filename{filename.filename().string()},
m_file{filename.string().data()}
{
throwUnless<std::runtime_error>(m_file.good(), "Could not open input file ({})", filename.string());
m_fileIter = boost::make_token_iterator<std::string>(
std::istreambuf_iterator<char>(m_file), std::istreambuf_iterator<char>(), TokenizerFunction(&m_lineNumber));
m_lineNumber = 1;
}
bool n2t::JackTokenizer::hasMoreTokens() const
{
static const TokenIterator fileEnd;
return (m_fileIter != fileEnd);
}
void n2t::JackTokenizer::advance()
{
auto currentToken = readNextToken();
const auto key = toKeyword(currentToken);
if (key.second)
{
m_tokenType = TokenType::Keyword;
m_keyword = key.first;
return;
}
// clang-format off
static constexpr auto symbols = frozen::make_unordered_set<char>(
{
'{', '}', '(', ')', '[', ']',
'.', ',', ';', '+', '-', '*', '/',
'&', '|', '~', '<', '=', '>'
});
// clang-format on
if (currentToken.length() == 1)
{
const auto iter = symbols.find(currentToken.front()); // NOLINT(readability-qualified-auto)
if (iter != symbols.end())
{
m_tokenType = TokenType::Symbol;
m_symbol = *iter;
return;
}
}
if (currentToken.front() == '"')
{
throwUnless(
currentToken.back() == '"', "Expected closing double quotation mark in string constant ({})", currentToken);
m_tokenType = TokenType::StringConst;
m_stringVal = currentToken.substr(/* __pos = */ 1, currentToken.length() - 2);
return;
}
if (std::all_of(currentToken.begin(), currentToken.end(), boost::is_digit()))
{
try
{
m_intVal = boost::lexical_cast<int16_t>(currentToken);
}
catch (const boost::bad_lexical_cast&)
{
throwAlways("Integer constant ({}) is too large", currentToken);
}
m_tokenType = TokenType::IntConst;
}
else
{
throwUnless(
!std::isdigit(currentToken.front(), std::locale{}), "Identifier ({}) begins with a digit", currentToken);
m_tokenType = TokenType::Identifier;
m_identifier = std::move(currentToken);
}
}
n2t::TokenType n2t::JackTokenizer::tokenType() const
{
return m_tokenType;
}
n2t::Keyword n2t::JackTokenizer::keyword() const
{
N2T_ASSERT(m_tokenType == TokenType::Keyword);
return m_keyword;
}
char n2t::JackTokenizer::symbol() const
{
N2T_ASSERT(m_tokenType == TokenType::Symbol);
return m_symbol;
}
const std::string& n2t::JackTokenizer::identifier() const
{
N2T_ASSERT(m_tokenType == TokenType::Identifier);
return m_identifier;
}
int16_t n2t::JackTokenizer::intVal() const
{
N2T_ASSERT(m_tokenType == TokenType::IntConst);
return m_intVal;
}
const std::string& n2t::JackTokenizer::stringVal() const
{
N2T_ASSERT(m_tokenType == TokenType::StringConst);
return m_stringVal;
}
std::string n2t::JackTokenizer::readNextToken()
{
throwUnless(hasMoreTokens(), "Unexpected end of file reached");
return *m_fileIter++;
}
| 26.638436 | 120 | 0.534483 |
83674a979c998d35be2cbf41aec0226e3adb034c | 4,397 | cpp | C++ | apps/PhotoconsistencyVisualOdometry/src/CRGBDGrabberRawlog.cpp | doctorwk007/photoconsistency-visual-odometry | 861706c27bba2993e775131b6622c66d3b663439 | [
"BSD-3-Clause"
] | 7 | 2017-01-09T16:58:50.000Z | 2021-08-23T15:44:51.000Z | apps/PhotoconsistencyVisualOdometry/src/CRGBDGrabberRawlog.cpp | doctorwk007/photoconsistency-visual-odometry | 861706c27bba2993e775131b6622c66d3b663439 | [
"BSD-3-Clause"
] | null | null | null | apps/PhotoconsistencyVisualOdometry/src/CRGBDGrabberRawlog.cpp | doctorwk007/photoconsistency-visual-odometry | 861706c27bba2993e775131b6622c66d3b663439 | [
"BSD-3-Clause"
] | 1 | 2019-11-23T09:40:49.000Z | 2019-11-23T09:40:49.000Z | /*
* Photoconsistency-Visual-Odometry
* Multiscale Photoconsistency Visual Odometry from RGBD Images
* Copyright (c) 2012, Miguel Algaba Borrego
*
* http://code.google.com/p/photoconsistency-visual-odometry/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the holder(s) nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "../include/CRGBDGrabberRawlog.h"
#include <iostream>
CRGBDGrabberRawlog::CRGBDGrabberRawlog(const std::string &rawlog_file = std::string())
{
//Open the rawlog file
dataset = new mrpt::utils::CFileGZInputStream();
if (!dataset->open(rawlog_file))
throw std::runtime_error("Couldn't open rawlog dataset file for input...");
// Set external images directory:
mrpt::utils::CImage::IMAGES_PATH_BASE = mrpt::slam::CRawlog::detectImagesDirectory(rawlog_file);
endGrabbing = false;
lastTimestamp = 0;
}
//CRGBDGrabberRawlog::~CRGBDGrabberRawlog(){}
void CRGBDGrabberRawlog::grab(CFrameRGBD* framePtr)
{
bool grabbed=false;
while(!grabbed)
{
//Read observations until we get a CObservation3DRangeScan
mrpt::slam::CObservationPtr obs;
do
{
try
{
*dataset >> obs;
}
catch (std::exception &e)
{
throw std::runtime_error( std::string("\nError reading from dataset file (EOF?):\n")+std::string(e.what()) );
}
} while (!IS_CLASS(obs,CObservation3DRangeScan));
// We have one observation:
currentObservationPtr = CObservation3DRangeScanPtr(obs);
if(currentObservationPtr->timestamp>lastTimestamp) //discard frames grabbed before
{
currentObservationPtr->load(); // *Important* This is needed to load the range image if stored as a separate file.
if (currentObservationPtr->hasRangeImage &&
currentObservationPtr->hasIntensityImage)
{
//Retain the RGB image of the current frame
cv::Mat rgbImage = cv::Mat((IplImage *) currentObservationPtr->intensityImage.getAs<IplImage>()).clone();
framePtr->setRGBImage(rgbImage);
//Retain the depth image of the current frame
cv::Mat depthImage(rgbImage.rows,rgbImage.cols,CV_32FC1);
mrpt::math::CMatrix depthImageMRPT = currentObservationPtr->rangeImage;
#pragma omp parallel for
for(int i=0;i<depthImage.rows;i++)
{
for(int j=0;j<depthImage.cols;j++)
{
depthImage.at<float>(i,j)=depthImageMRPT(i,j);
}
}
framePtr->setDepthImage(depthImage);
//Retain the timestamp of the current frame
framePtr->setTimeStamp(currentObservationPtr->timestamp);
grabbed=true;
}
}
}
}
| 40.33945 | 126 | 0.650216 |
83698a1cd3160d74beed9123c0bd2a3d5964362e | 2,998 | cpp | C++ | lib/timers/backends/src/win32/backend.cpp | voivoid/CppMockIO | 510318d188662166370fb16ba83faa1817e445bb | [
"MIT"
] | null | null | null | lib/timers/backends/src/win32/backend.cpp | voivoid/CppMockIO | 510318d188662166370fb16ba83faa1817e445bb | [
"MIT"
] | null | null | null | lib/timers/backends/src/win32/backend.cpp | voivoid/CppMockIO | 510318d188662166370fb16ba83faa1817e445bb | [
"MIT"
] | null | null | null | #include "CppMockIO/timers/backend.h"
#include <mutex>
#include <stdexcept>
#include <cassert>
#define WIN32_LEAN_AND_MEAN
#include <sdkddkver.h>
#include <Windows.h>
namespace CppMockIO
{
namespace timers
{
namespace backend
{
namespace
{
void safe_run_action(const runnable& runnable)
{
try
{
runnable.action();
}
catch (const std::exception & ex)
{
}
}
HANDLE TimerQueue = {};
VOID NTAPI scheduled_timer_callback( PVOID param, BOOLEAN )
{
std::unique_ptr<runnable> runnable( reinterpret_cast<runnable*>( param ) );
safe_run_action( *runnable );
while (!runnable->timer_handle){}
assert(TimerQueue);
const auto is_deleted = ::DeleteTimerQueueTimer(TimerQueue, runnable->timer_handle, NULL);
if (!is_deleted)
{
// TODO: handle error
}
}
VOID NTAPI timer_callback(PVOID param, BOOLEAN)
{
std::unique_ptr<runnable> runnable(reinterpret_cast<runnable*>(param));
safe_run_action(*runnable);
}
handle create_timer(timeout timeout, std::unique_ptr<runnable> runnable, bool is_scheduled)
{
assert(TimerQueue);
HANDLE timer_handle{};
const auto callback = is_scheduled ? &scheduled_timer_callback : &timer_callback;
BOOL created = ::CreateTimerQueueTimer( &timer_handle, TimerQueue, callback, runnable.get(), static_cast<DWORD>(timeout), 0, WT_EXECUTEONLYONCE );
if (!created)
{
throw std::runtime_error("::CreateTimerQueueTimer failed");
}
runnable->timer_handle = timer_handle;
runnable.release();
return timer_handle;
}
}
void init()
{
assert( !TimerQueue );
TimerQueue = ::CreateTimerQueue();
if ( !TimerQueue )
{
throw std::runtime_error( "::CreateTimerQueue failed" );
}
}
void deinit()
{
assert( TimerQueue );
BOOL is_deleted = ::DeleteTimerQueueEx( TimerQueue, NULL );
if ( !is_deleted )
{
throw std::runtime_error( "::DeleteTimerQueueEx failed" );
}
}
void schedule( timeout timeout, std::unique_ptr<runnable> runnable )
{
create_timer(timeout, std::move(runnable), false );
}
timer start( timeout timeout, std::unique_ptr<runnable> runnable )
{
auto timer = create_timer( timeout, std::move( runnable ), true );
return{ timer };
}
void stop( const timer& timer )
{
assert( TimerQueue );
BOOL is_deleted = ::DeleteTimerQueueTimer( TimerQueue, timer.handle, INVALID_HANDLE_VALUE );
if ( !is_deleted )
{
throw std::runtime_error( "::DeleteTimerQueueTimer failed" );
}
}
}
}
}
| 24.983333 | 156 | 0.56938 |
836c2a34119e0046901bd9d0f46ac6b369d56f94 | 5,996 | hxx | C++ | externals/src/moderngpu/loadstore.hxx | aka-chris/mini | 608751ff11f74e1ee59222399cbf6c9ee92208fb | [
"Apache-2.0"
] | 216 | 2021-07-21T02:24:54.000Z | 2021-07-30T03:33:10.000Z | externals/src/moderngpu/loadstore.hxx | aka-chris/mini | 608751ff11f74e1ee59222399cbf6c9ee92208fb | [
"Apache-2.0"
] | null | null | null | externals/src/moderngpu/loadstore.hxx | aka-chris/mini | 608751ff11f74e1ee59222399cbf6c9ee92208fb | [
"Apache-2.0"
] | 94 | 2021-07-21T02:24:56.000Z | 2021-07-24T23:50:38.000Z | // moderngpu copyright (c) 2016, Sean Baxter http://www.moderngpu.com
#pragma once
#include "types.hxx"
#include "intrinsics.hxx"
BEGIN_MGPU_NAMESPACE
////////////////////////////////////////////////////////////////////////////////
// reg<->shared
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE void reg_to_shared_thread(array_t<type_t, vt> x, int tid,
type_t (&shared)[shared_size], bool sync = true) {
static_assert(shared_size >= nt * vt,
"reg_to_shared_thread must have at least nt * vt storage");
thread_iterate<vt>([&](int i, int j) {
shared[j] = x[i];
}, tid);
if(sync) __syncthreads();
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> shared_to_reg_thread(
const type_t (&shared)[shared_size], int tid, bool sync = true) {
static_assert(shared_size >= nt * vt,
"reg_to_shared_thread must have at least nt * vt storage");
array_t<type_t, vt> x;
thread_iterate<vt>([&](int i, int j) {
x[i] = shared[j];
}, tid);
if(sync) __syncthreads();
return x;
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE void reg_to_shared_strided(array_t<type_t, vt> x, int tid,
type_t (&shared)[shared_size], bool sync = true) {
static_assert(shared_size >= nt * vt,
"reg_to_shared_strided must have at least nt * vt storage");
strided_iterate<nt, vt>([&](int i, int j) { shared[j] = x[i]; }, tid);
if(sync) __syncthreads();
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> shared_to_reg_strided(
const type_t (&shared)[shared_size], int tid, bool sync = true) {
static_assert(shared_size >= nt * vt,
"shared_to_reg_strided must have at least nt * vt storage");
array_t<type_t, vt> x;
strided_iterate<nt, vt>([&](int i, int j) { x[i] = shared[j]; }, tid);
if(sync) __syncthreads();
return x;
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> shared_gather(const type_t(&data)[shared_size],
array_t<int, vt> indices, bool sync = true) {
static_assert(shared_size >= nt * vt,
"shared_gather must have at least nt * vt storage");
array_t<type_t, vt> x;
iterate<vt>([&](int i) { x[i] = data[indices[i]]; });
if(sync) __syncthreads();
return x;
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> thread_to_strided(array_t<type_t, vt> x,
int tid, type_t (&shared)[shared_size]) {
reg_to_shared_thread<nt, vt>(x, tid, shared);
return shared_to_reg_strided<nt, vt>(shared, tid);
}
////////////////////////////////////////////////////////////////////////////////
// reg<->memory
template<int nt, int vt, int vt0 = vt, typename type_t, typename it_t>
MGPU_DEVICE void reg_to_mem_strided(array_t<type_t, vt> x, int tid,
int count, it_t mem) {
strided_iterate<nt, vt, vt0>([=](int i, int j) {
mem[j] = x[i];
}, tid, count);
}
template<int nt, int vt, int vt0 = vt, typename it_t>
MGPU_DEVICE array_t<typename std::iterator_traits<it_t>::value_type, vt>
mem_to_reg_strided(it_t mem, int tid, int count) {
typedef typename std::iterator_traits<it_t>::value_type type_t;
array_t<type_t, vt> x;
strided_iterate<nt, vt, vt0>([&](int i, int j) {
x[i] = mem[j];
}, tid, count);
return x;
}
template<int nt, int vt, int vt0 = vt, typename type_t, typename it_t,
int shared_size>
MGPU_DEVICE void reg_to_mem_thread(array_t<type_t, vt> x, int tid,
int count, it_t mem, type_t (&shared)[shared_size]) {
reg_to_shared_thread<nt>(x, tid, shared);
array_t<type_t, vt> y = shared_to_reg_strided<nt, vt>(shared, tid);
reg_to_mem_strided<nt, vt, vt0>(y, tid, count, mem);
}
template<int nt, int vt, int vt0 = vt, typename type_t, typename it_t,
int shared_size>
MGPU_DEVICE array_t<type_t, vt> mem_to_reg_thread(it_t mem, int tid,
int count, type_t (&shared)[shared_size]) {
array_t<type_t, vt> x = mem_to_reg_strided<nt, vt, vt0>(mem, tid, count);
reg_to_shared_strided<nt, vt>(x, tid, shared);
array_t<type_t, vt> y = shared_to_reg_thread<nt, vt>(shared, tid);
return y;
}
template<int nt, int vt, int vt0 = vt, typename input_it, typename output_it>
MGPU_DEVICE void mem_to_mem(input_it input, int tid, int count,
output_it output) {
typedef typename std::iterator_traits<input_it>::value_type type_t;
type_t x[vt];
strided_iterate<nt, vt, vt0>([&](int i, int j) {
x[i] = input[j];
}, tid, count);
strided_iterate<nt, vt, vt0>([&](int i, int j) {
output[j] = x[i];
}, tid, count);
}
////////////////////////////////////////////////////////////////////////////////
// memory<->memory
template<int nt, int vt, int vt0 = vt, typename type_t, typename it_t>
MGPU_DEVICE void mem_to_shared(it_t mem, int tid, int count, type_t* shared,
bool sync = true) {
array_t<type_t, vt> x = mem_to_reg_strided<nt, vt, vt0>(mem, tid, count);
strided_iterate<nt, vt, vt0>([&](int i, int j) {
shared[j] = x[i];
}, tid, count);
if(sync) __syncthreads();
}
template<int nt, int vt, typename type_t, typename it_t>
MGPU_DEVICE void shared_to_mem(const type_t* shared, int tid, int count,
it_t mem, bool sync = true) {
strided_iterate<nt, vt>([&](int i, int j) {
mem[j] = shared[j];
}, tid, count);
if(sync) __syncthreads();
}
////////////////////////////////////////////////////////////////////////////////
// reg<->reg
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> reg_thread_to_strided(array_t<type_t, vt> x,
int tid, type_t (&shared)[shared_size]) {
reg_to_shared_thread<nt>(x, tid, shared);
return shared_to_reg_strided<nt, vt>(shared, tid);
}
template<int nt, int vt, typename type_t, int shared_size>
MGPU_DEVICE array_t<type_t, vt> reg_strided_to_thread(array_t<type_t, vt> x,
int tid, type_t (&shared)[shared_size]) {
reg_to_shared_strided<nt>(x, tid, shared);
return shared_to_reg_thread<nt, vt>(shared, tid);
}
END_MGPU_NAMESPACE
| 31.724868 | 80 | 0.652435 |
836eb874f1fb2941574ca0484c4a4c6ad8c09358 | 3,595 | cxx | C++ | PMNS_Iter.cxx | NadjaLessing/OscProb | 78c0576fe942167d63dab1e4c0a386c5424ab62a | [
"MIT"
] | null | null | null | PMNS_Iter.cxx | NadjaLessing/OscProb | 78c0576fe942167d63dab1e4c0a386c5424ab62a | [
"MIT"
] | null | null | null | PMNS_Iter.cxx | NadjaLessing/OscProb | 78c0576fe942167d63dab1e4c0a386c5424ab62a | [
"MIT"
] | null | null | null | ////////////////////////////////////////////////////////////////////////
//
// Implementation of oscillations of neutrinos in matter in a
// three-neutrino framework.
//
// coelho@lal.in2p3.fr
////////////////////////////////////////////////////////////////////////
#include <iostream>
#include "PMNS_Iter.h"
using namespace OscProb;
//......................................................................
///
/// Constructor. \sa PMNS_Fast::PMNS_Fast
///
/// This class is restricted to 3 neutrino flavours.
///
PMNS_Iter::PMNS_Iter() : PMNS_Fast(), fPrec(0.1) {}
//......................................................................
///
/// Nothing to clean.
///
PMNS_Iter::~PMNS_Iter(){}
//......................................................................
///
/// Propagate neutrino through matter component.
///
void PMNS_Iter::SetExpVL(NuPath p)
{
double kr2GNe = kK2*M_SQRT2*kGf;
kr2GNe *= p.density * p.zoa; // Matter potential in eV
fVL = kr2GNe * kKm2eV * p.length;
fExpVL = complexD(cos(fVL), -sin(fVL));
}
//......................................................................
///
/// Propagate neutrino through matter component.
///
void PMNS_Iter::PropMatter()
{
fNuState[0] *= fExpVL;
}
//......................................................................
///
/// Just use the vacuum Hamiltonian to start.
///
void PMNS_Iter::SolveHam()
{
if(fGotES) return;
// Do vacuum oscillation in low density
SetVacuumEigensystem();
fGotES = true;
return;
}
//......................................................................
///
/// Propagate neutrino state through full path
///
void PMNS_Iter::Propagate()
{
for(int i=0; i<int(fNuPaths.size()); i++){
SplitPropagate(fNuPaths[i]);
}
}
//......................................................................
///
/// Set iterator precision
///
void PMNS_Iter::SetPrec(double prec)
{
fPrec = prec;
if(fPrec<=0) fPrec = 1e-3;
}
//......................................................................
///
/// Propagate neutrino state through split path
///
void PMNS_Iter::SplitPropagate(NuPath p)
{
SetExpVL(p);
double dm = 0;
for(int i=0; i<fNumNus; i++){
if(dm<fabs(fDm[i])) dm = fabs(fDm[i]);
}
dm *= kKm2eV * p.length / (2 * kGeV2eV * fEnergy);
int nsplit = sqrt(dm * fVL / fPrec);
nsplit++;
p.length /= nsplit;
SetExpVL(p);
for(int i=0; i<nsplit; i++){
PropagatePath(p);
PropMatter();
}
}
//.....................................................................
///
/// Set the eigensystem to the analytic solution in vacuum.
///
/// We know the vacuum eigensystem, so just write it explicitly
///
void PMNS_Iter::SetVacuumEigensystem()
{
if(!fBuiltHms){
double s12, s23, s13, c12, c23, c13;
complexD idelta(0.0, fDelta[0][2]);
if(fIsNuBar) idelta = conj(idelta);
s12 = sin(fTheta[0][1]); s23 = sin(fTheta[1][2]); s13 = sin(fTheta[0][2]);
c12 = cos(fTheta[0][1]); c23 = cos(fTheta[1][2]); c13 = cos(fTheta[0][2]);
fEvec[0][0] = c12*c13;
fEvec[0][1] = s12*c13;
fEvec[0][2] = s13*exp(-idelta);
fEvec[1][0] = -s12*c23-c12*s23*s13*exp(idelta);
fEvec[1][1] = c12*c23-s12*s23*s13*exp(idelta);
fEvec[1][2] = s23*c13;
fEvec[2][0] = s12*s23-c12*c23*s13*exp(idelta);
fEvec[2][1] = -c12*s23-s12*c23*s13*exp(idelta);
fEvec[2][2] = c23*c13;
}
fBuiltHms = true;
fEval[0] = 0;
fEval[1] = fDm[1] / (2 * kGeV2eV*fEnergy);
fEval[2] = fDm[2] / (2 * kGeV2eV*fEnergy);
}
////////////////////////////////////////////////////////////////////////
| 21.39881 | 80 | 0.462309 |
8370f0a0dbd447696b93fc7dd2c55b6cb6698e6b | 2,259 | cpp | C++ | third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp | xzhan96/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2021-01-07T18:51:03.000Z | 2021-01-07T18:51:03.000Z | third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp | emilio/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp | emilio/chromium.src | 1bd0cf3997f947746c0fc5406a2466e7b5f6159e | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/css/parser/CSSLazyParsingState.h"
#include "core/css/parser/CSSParserTokenRange.h"
#include "core/frame/UseCounter.h"
namespace blink {
CSSLazyParsingState::CSSLazyParsingState(const CSSParserContext& context,
Vector<String> escapedStrings,
const String& sheetText,
StyleSheetContents* contents)
: m_context(context),
m_escapedStrings(std::move(escapedStrings)),
m_sheetText(sheetText),
m_owningContents(contents) {}
const CSSParserContext& CSSLazyParsingState::context() {
DCHECK(m_owningContents);
UseCounter* sheetCounter = UseCounter::getFrom(m_owningContents);
if (sheetCounter != m_context.useCounter())
m_context = CSSParserContext(m_context, sheetCounter);
return m_context;
}
bool CSSLazyParsingState::shouldLazilyParseProperties(
const CSSSelectorList& selectors,
const CSSParserTokenRange& block) {
// Simple heuristic for an empty block. Note that |block| here does not
// include {} brackets. We avoid lazy parsing empty blocks so we can avoid
// considering them when possible for matching. Lazy blocks must always be
// considered. Three tokens is a reasonable minimum for a block:
// ident ':' <value>.
if (block.end() - block.begin() <= 2)
return false;
// Disallow lazy parsing for blocks which have before/after in their selector
// list. This ensures we don't cause a collectFeatures() when we trigger
// parsing for attr() functions which would trigger expensive invalidation
// propagation.
for (const auto* s = selectors.first(); s; s = CSSSelectorList::next(*s)) {
for (const CSSSelector* current = s; current;
current = current->tagHistory()) {
const CSSSelector::PseudoType type(current->getPseudoType());
if (type == CSSSelector::PseudoBefore || type == CSSSelector::PseudoAfter)
return false;
if (current->relation() != CSSSelector::SubSelector)
break;
}
}
return true;
}
} // namespace blink
| 39.631579 | 80 | 0.686144 |
8374c392966aff5692a7065530eee27c8c4b8785 | 2,687 | cpp | C++ | SpaceshIT!/SpaceshIT!/Queue.cpp | ColdSpotYZ/SpaceshIT | 8fe2dcdd202536b5127e14a140c5f833720b1eeb | [
"MIT"
] | null | null | null | SpaceshIT!/SpaceshIT!/Queue.cpp | ColdSpotYZ/SpaceshIT | 8fe2dcdd202536b5127e14a140c5f833720b1eeb | [
"MIT"
] | null | null | null | SpaceshIT!/SpaceshIT!/Queue.cpp | ColdSpotYZ/SpaceshIT | 8fe2dcdd202536b5127e14a140c5f833720b1eeb | [
"MIT"
] | null | null | null | /*
Team member: Lim Kai Xian
Group: CookieZ
studentID: S10195450H
*/
#pragma once
#include "stdafx.h"
#include "Queue.h"
#include <string>
using namespace std;
Queue::Queue() { size = 0; current = 0; salt = rand() % 512;}
Queue::~Queue()
{
while (!isEmpty())
{
dequeue_back();
}
current = NULL;
size = NULL;
}
bool Queue::enqueue_back(ItemType item)
{
if (size >= 4)
{
dequeue_front();
}
string hashoflocation = xhash((std::to_string(item.x) + std::to_string(item.y)));
locations[current] = item;
hashes[current] = hashoflocation;
size++;
current++;
current = current % 5;
return true;
}
bool Queue::enqueue_front(ItemType item)
{
if (size >= 4)
{
dequeue_back();
}
string hashoflocation = xhash((std::to_string(item.x) + std::to_string(item.y)));
locations[current] = item;
hashes[current] = hashoflocation;
size++;
current--;
current = current % 5;
return true;
}
bool Queue::dequeue_back()
{
bool success = !isEmpty();
if (success)
{
current++;
current = current % 5;
locations[current].x = NULL;
locations[current].y = NULL;
hashes[current] = "";
size--;
}
return success;
}
bool Queue::dequeue_back(ItemType& location, std::string& hash)
{
bool success = !isEmpty();
if (success)
{
current++;
current = current % 5;
location = locations[current];
hash = hashes[current];
locations[current].x = NULL;
locations[current].y = NULL;
hashes[current] = "";
size--;
}
return success;
}
bool Queue::dequeue_front()
{
bool success = !isEmpty();
if (success)
{
current--;
current = current % 5;
locations[current].x = NULL;
locations[current].y = NULL;
hashes[current] = "";
size--;
}
return success;
}
bool Queue::dequeue_front(ItemType& location, std::string& hash)
{
bool success = !isEmpty();
if (success)
{
current--;
current = current % 5;
location = locations[current];
hash = hashes[current];
locations[current].x = NULL;
locations[current].y = NULL;
hashes[current] = "";
size--;
}
return success;
}
void Queue::getFront(ItemType& location, std::string& hash)
{
if (!isEmpty())
{
if (size == 5) // When the array is full the front of the queue would be the next of the current
{
location = locations[current + 1];
hash = hashes[current + 1];
}
else
{
location = locations[current - size];
hash = hashes[current - size];
}
}
}
void Queue::getBack(ItemType& location, std::string& hash)
{
if (!isEmpty())
{
int temp = current - 1;
temp = temp % 5;
location = locations[temp];
hash = hashes[temp];
}
}
bool Queue::isEmpty()
{
if (size == 0)
return true;
else
return false;
}
int Queue::getNoOfElements()
{
return size;
} | 16.899371 | 98 | 0.639747 |
83778138193b88547af0fa4ece2272a9b3df8b2c | 2,290 | cpp | C++ | deps/reproc/reproc++/examples/cmake-help.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 135 | 2018-12-17T15:38:16.000Z | 2022-03-01T05:38:29.000Z | deps/reproc/reproc++/examples/cmake-help.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 185 | 2018-12-21T13:56:29.000Z | 2022-03-23T14:41:46.000Z | deps/reproc/reproc++/examples/cmake-help.cpp | Fookdies301/GrinPlusPlus | 981a99af0ae04633afbd02666894b5c199e06339 | [
"MIT"
] | 49 | 2018-12-23T12:05:51.000Z | 2022-03-26T14:24:49.000Z | #include <reproc++/reproc.hpp>
#include <reproc++/sink.hpp>
#include <array>
#include <iostream>
static int fail(std::error_code ec)
{
std::cerr << ec.message();
return 1;
}
// Uses reproc++ to print CMake's help page.
int main()
{
reproc::process process;
// The `process::start` method works with any container containing strings and
// takes care of converting the vector into the array of null-terminated
// strings expected by `reproc_start` (including adding the `NULL` value at
// the end of the array).
std::array<std::string, 2> argv = { "cmake", "--help" };
// reproc++ uses error codes to report errors. If exceptions are preferred,
// convert `std::error_code`'s to exceptions using `std::system_error`.
std::error_code ec = process.start(argv);
// reproc++ converts system errors to `std::error_code`'s of the system
// category. These can be matched against using values from the `std::errc`
// error condition. See https://en.cppreference.com/w/cpp/error/errc for more
// information.
if (ec == std::errc::no_such_file_or_directory) {
std::cerr << "cmake not found. Make sure it's available from the PATH.";
return 1;
} else if (ec) {
return fail(ec);
}
std::string output;
// `process::drain` reads from the stdout and stderr streams of the child
// process until both are closed or an error occurs. Providing it with a
// string sink makes it store all output in the string(s) passed to the string
// sink. Passing the same string to both the `out` and `err` arguments of
// `sink::string` causes the stdout and stderr output to get stored in the
// same string.
ec = process.drain(reproc::sink::string(output, output));
if (ec) {
return fail(ec);
}
std::cout << output << std::flush;
// It's easy to define your own sinks as well. Take a look at `sink.cpp` in
// the repository to see how `sink::string` and other sinks are implemented.
// The documentation of `process::drain` also provides more information on the
// requirements a sink should fulfill.
// By default, The `process` destructor waits indefinitely for the child
// process to exit to ensure proper cleanup. See the forward example for
// information on how this can be configured.
return EXIT_SUCCESS;
}
| 35.230769 | 80 | 0.69607 |
8378bd5c7770e1f67f5dc446fd971de0ecd8c729 | 6,625 | cpp | C++ | apps/heat/run.cpp | POETSII/jordmorr-tinsel | 39249538d532e4945d9916748346c261dc5ea75d | [
"BSD-2-Clause"
] | 31 | 2019-09-18T10:55:47.000Z | 2021-12-01T20:39:46.000Z | apps/heat/run.cpp | POETSII/jordmorr-tinsel | 39249538d532e4945d9916748346c261dc5ea75d | [
"BSD-2-Clause"
] | 26 | 2019-10-13T13:33:04.000Z | 2021-11-10T11:09:48.000Z | apps/heat/run.cpp | POETSII/jordmorr-tinsel | 39249538d532e4945d9916748346c261dc5ea75d | [
"BSD-2-Clause"
] | 1 | 2020-09-11T17:32:43.000Z | 2020-09-11T17:32:43.000Z | // SPDX-License-Identifier: BSD-2-Clause
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <sys/time.h>
#include <HostLink.h>
#include "heat.h"
// Magnification factor when displaying heat map
const int MAG = 2;
// 256 x RGB colours representing heat intensities
int heat[] = {
0x00, 0x00, 0x76, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x83,
0x00, 0x00, 0x88, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x91, 0x00, 0x00, 0x95,
0x00, 0x00, 0x9a, 0x00, 0x00, 0x9e, 0x00, 0x00, 0xa3, 0x00, 0x00, 0xa3,
0x00, 0x00, 0xa7, 0x00, 0x00, 0xac, 0x00, 0x00, 0xb0, 0x00, 0x00, 0xb5,
0x00, 0x00, 0xb9, 0x00, 0x00, 0xbe, 0x00, 0x00, 0xc2, 0x00, 0x00, 0xc7,
0x00, 0x00, 0xcb, 0x00, 0x00, 0xd0, 0x00, 0x00, 0xd4, 0x00, 0x00, 0xd9,
0x00, 0x00, 0xde, 0x00, 0x00, 0xe2, 0x00, 0x00, 0xe7, 0x00, 0x00, 0xeb,
0x00, 0x00, 0xf0, 0x00, 0x00, 0xf4, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xfd,
0x00, 0x03, 0xff, 0x00, 0x07, 0xff, 0x00, 0x0c, 0xff, 0x00, 0x10, 0xff,
0x00, 0x15, 0xff, 0x00, 0x19, 0xff, 0x00, 0x1e, 0xff, 0x00, 0x22, 0xff,
0x00, 0x27, 0xff, 0x00, 0x2b, 0xff, 0x00, 0x30, 0xff, 0x00, 0x34, 0xff,
0x00, 0x39, 0xff, 0x00, 0x3d, 0xff, 0x00, 0x42, 0xff, 0x00, 0x47, 0xff,
0x00, 0x4b, 0xff, 0x00, 0x50, 0xff, 0x00, 0x54, 0xff, 0x00, 0x59, 0xff,
0x00, 0x5d, 0xff, 0x00, 0x62, 0xff, 0x00, 0x66, 0xff, 0x00, 0x6b, 0xff,
0x00, 0x6f, 0xff, 0x00, 0x74, 0xff, 0x00, 0x78, 0xff, 0x00, 0x7d, 0xff,
0x00, 0x81, 0xff, 0x00, 0x86, 0xff, 0x00, 0x8a, 0xff, 0x00, 0x8f, 0xff,
0x00, 0x93, 0xff, 0x00, 0x98, 0xff, 0x00, 0x9c, 0xff, 0x00, 0xa1, 0xff,
0x00, 0xa5, 0xff, 0x00, 0xaa, 0xff, 0x00, 0xaf, 0xff, 0x00, 0xb3, 0xff,
0x00, 0xb8, 0xff, 0x00, 0xbc, 0xff, 0x00, 0xc1, 0xff, 0x00, 0xc5, 0xff,
0x00, 0xca, 0xff, 0x00, 0xce, 0xff, 0x00, 0xd3, 0xff, 0x00, 0xd7, 0xff,
0x00, 0xdc, 0xff, 0x00, 0xe0, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xe9, 0xff,
0x00, 0xee, 0xff, 0x00, 0xf2, 0xff, 0x00, 0xf7, 0xff, 0x00, 0xfb, 0xff,
0x00, 0xff, 0xff, 0x00, 0xff, 0xfa, 0x00, 0xff, 0xf5, 0x00, 0xff, 0xf1,
0x00, 0xff, 0xec, 0x00, 0xff, 0xe7, 0x00, 0xff, 0xe3, 0x00, 0xff, 0xde,
0x00, 0xff, 0xda, 0x00, 0xff, 0xd5, 0x00, 0xff, 0xd1, 0x00, 0xff, 0xcc,
0x00, 0xff, 0xc8, 0x00, 0xff, 0xc3, 0x00, 0xff, 0xbf, 0x00, 0xff, 0xba,
0x00, 0xff, 0xb6, 0x00, 0xff, 0xb1, 0x00, 0xff, 0xad, 0x00, 0xff, 0xa8,
0x00, 0xff, 0xa4, 0x00, 0xff, 0x9f, 0x00, 0xff, 0x9b, 0x00, 0xff, 0x96,
0x00, 0xff, 0x92, 0x00, 0xff, 0x8d, 0x00, 0xff, 0x89, 0x00, 0xff, 0x84,
0x00, 0xff, 0x80, 0x00, 0xff, 0x7b, 0x00, 0xff, 0x76, 0x00, 0xff, 0x72,
0x00, 0xff, 0x6d, 0x00, 0xff, 0x69, 0x00, 0xff, 0x64, 0x00, 0xff, 0x60,
0x00, 0xff, 0x5b, 0x00, 0xff, 0x57, 0x00, 0xff, 0x52, 0x00, 0xff, 0x4e,
0x00, 0xff, 0x49, 0x00, 0xff, 0x45, 0x00, 0xff, 0x40, 0x00, 0xff, 0x3c,
0x00, 0xff, 0x37, 0x00, 0xff, 0x33, 0x00, 0xff, 0x2e, 0x00, 0xff, 0x2a,
0x00, 0xff, 0x25, 0x00, 0xff, 0x21, 0x00, 0xff, 0x1c, 0x00, 0xff, 0x18,
0x00, 0xff, 0x13, 0x00, 0xff, 0x0e, 0x00, 0xff, 0x0a, 0x00, 0xff, 0x05,
0x00, 0xff, 0x01, 0x04, 0xff, 0x00, 0x08, 0xff, 0x00, 0x0d, 0xff, 0x00,
0x11, 0xff, 0x00, 0x16, 0xff, 0x00, 0x1a, 0xff, 0x00, 0x1f, 0xff, 0x00,
0x23, 0xff, 0x00, 0x28, 0xff, 0x00, 0x2c, 0xff, 0x00, 0x31, 0xff, 0x00,
0x35, 0xff, 0x00, 0x3a, 0xff, 0x00, 0x3e, 0xff, 0x00, 0x43, 0xff, 0x00,
0x47, 0xff, 0x00, 0x4c, 0xff, 0x00, 0x50, 0xff, 0x00, 0x55, 0xff, 0x00,
0x5a, 0xff, 0x00, 0x5e, 0xff, 0x00, 0x63, 0xff, 0x00, 0x67, 0xff, 0x00,
0x6c, 0xff, 0x00, 0x70, 0xff, 0x00, 0x75, 0xff, 0x00, 0x79, 0xff, 0x00,
0x7e, 0xff, 0x00, 0x82, 0xff, 0x00, 0x87, 0xff, 0x00, 0x8b, 0xff, 0x00,
0x90, 0xff, 0x00, 0x94, 0xff, 0x00, 0x99, 0xff, 0x00, 0x9d, 0xff, 0x00,
0xa2, 0xff, 0x00, 0xa6, 0xff, 0x00, 0xab, 0xff, 0x00, 0xaf, 0xff, 0x00,
0xb4, 0xff, 0x00, 0xb8, 0xff, 0x00, 0xbd, 0xff, 0x00, 0xc2, 0xff, 0x00,
0xc6, 0xff, 0x00, 0xcb, 0xff, 0x00, 0xcf, 0xff, 0x00, 0xd4, 0xff, 0x00,
0xd8, 0xff, 0x00, 0xdd, 0xff, 0x00, 0xe1, 0xff, 0x00, 0xe6, 0xff, 0x00,
0xea, 0xff, 0x00, 0xef, 0xff, 0x00, 0xf3, 0xff, 0x00, 0xf8, 0xff, 0x00,
0xfc, 0xff, 0x00, 0xff, 0xfd, 0x00, 0xff, 0xf9, 0x00, 0xff, 0xf4, 0x00,
0xff, 0xf0, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xe7, 0x00, 0xff, 0xe2, 0x00,
0xff, 0xde, 0x00, 0xff, 0xd9, 0x00, 0xff, 0xd5, 0x00, 0xff, 0xd0, 0x00,
0xff, 0xcb, 0x00, 0xff, 0xc7, 0x00, 0xff, 0xc2, 0x00, 0xff, 0xbe, 0x00,
0xff, 0xb9, 0x00, 0xff, 0xb5, 0x00, 0xff, 0xb0, 0x00, 0xff, 0xac, 0x00,
0xff, 0xa7, 0x00, 0xff, 0xa3, 0x00, 0xff, 0x9e, 0x00, 0xff, 0x9a, 0x00,
0xff, 0x95, 0x00, 0xff, 0x91, 0x00, 0xff, 0x8c, 0x00, 0xff, 0x88, 0x00,
0xff, 0x83, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x7a, 0x00, 0xff, 0x76, 0x00,
0xff, 0x71, 0x00, 0xff, 0x6d, 0x00, 0xff, 0x68, 0x00, 0xff, 0x63, 0x00,
0xff, 0x5f, 0x00, 0xff, 0x5a, 0x00, 0xff, 0x56, 0x00, 0xff, 0x51, 0x00,
0xff, 0x4d, 0x00, 0xff, 0x48, 0x00, 0xff, 0x44, 0x00, 0xff, 0x3f, 0x00,
0xff, 0x3b, 0x00, 0xff, 0x36, 0x00, 0xff, 0x32, 0x00, 0xff, 0x2d, 0x00,
0xff, 0x29, 0x00, 0xff, 0x24, 0x00, 0xff, 0x20, 0x00, 0xff, 0x1b, 0x00,
0xff, 0x17, 0x00, 0xff, 0x12, 0x00, 0xff, 0x0e, 0x00, 0xff, 0x09, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int main()
{
HostLink hostLink;
// Load application
hostLink.boot("code.v", "data.v");
// Start timer
struct timeval start, finish, diff;
gettimeofday(&start, NULL);
// Start application
hostLink.go();
// 2D grid
int NX = X_LEN*8;
int NY = Y_LEN*8;
int** grid = new int* [NY];
for (int i = 0; i < NY; i++) grid[i] = new int [NX];
// Initialise 2D grid
for (int y = 0; y < NY; y++)
for (int x = 0; x < NX; x++)
grid[y][x] = 0;
for (int n = 0; n < 1; n++) {
// Fill 2D grid
for (int i = 0; i < 8*X_LEN*Y_LEN; i++) {
HostMsg msg;
hostLink.recvMsg(&msg, sizeof(HostMsg));
for (int j = 0; j < 8; j++)
grid[msg.y][msg.x+j] = msg.temps[j];
}
FILE* fp = fopen("out.ppm", "w");
if (fp == NULL) {
fprintf(stderr, "Failed to open file 'out.ppm'\n");
}
// Emit PPM
int L = 8 * MAG;
fprintf(fp, "P3\n%i %i\n255\n", MAG*NX, MAG*NY);
for (int y = 0; y < MAG*NY; y++)
for (int x = 0; x < MAG*NX; x++) {
int t = grid[y/MAG][x/MAG];
if (((x%L) == 0 && (y&1)) || ((y%L) == 0 && (x&1)))
fprintf(fp, "0 0 0\n");
else
fprintf(fp, "%d %d %d\n", heat[t*3], heat[t*3+1], heat[t*3+2]);
}
fclose(fp);
}
// Stop timer
gettimeofday(&finish, NULL);
// Display time
timersub(&finish, &start, &diff);
double duration = (double) diff.tv_sec + (double) diff.tv_usec / 1000000.0;
printf("Time = %lf\n", duration);
return 0;
}
| 45.376712 | 77 | 0.618113 |
837c8b732b65fa6297e16029f409247ebb602f1f | 178,287 | cc | C++ | keynote-protos/gen/TSCHArchives.Common.pb.cc | eth-siplab/SVG2Keynote-lib | b7e6dfe5084911dac1fa6261a14254bfbbd8065b | [
"MIT"
] | 4 | 2021-11-24T14:27:32.000Z | 2022-03-14T07:52:44.000Z | keynote-protos/gen/TSCHArchives.Common.pb.cc | eth-siplab/SVG2Keynote-lib | b7e6dfe5084911dac1fa6261a14254bfbbd8065b | [
"MIT"
] | null | null | null | keynote-protos/gen/TSCHArchives.Common.pb.cc | eth-siplab/SVG2Keynote-lib | b7e6dfe5084911dac1fa6261a14254bfbbd8065b | [
"MIT"
] | null | null | null | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: TSCHArchives.Common.proto
#include "TSCHArchives.Common.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
namespace TSCH {
constexpr RectArchive::RectArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: origin_(nullptr)
, size_(nullptr){}
struct RectArchiveDefaultTypeInternal {
constexpr RectArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~RectArchiveDefaultTypeInternal() {}
union {
RectArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT RectArchiveDefaultTypeInternal _RectArchive_default_instance_;
constexpr ChartsNSNumberDoubleArchive::ChartsNSNumberDoubleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: number_archive_(0){}
struct ChartsNSNumberDoubleArchiveDefaultTypeInternal {
constexpr ChartsNSNumberDoubleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartsNSNumberDoubleArchiveDefaultTypeInternal() {}
union {
ChartsNSNumberDoubleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartsNSNumberDoubleArchiveDefaultTypeInternal _ChartsNSNumberDoubleArchive_default_instance_;
constexpr ChartsNSArrayOfNSNumberDoubleArchive::ChartsNSArrayOfNSNumberDoubleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: numbers_(){}
struct ChartsNSArrayOfNSNumberDoubleArchiveDefaultTypeInternal {
constexpr ChartsNSArrayOfNSNumberDoubleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartsNSArrayOfNSNumberDoubleArchiveDefaultTypeInternal() {}
union {
ChartsNSArrayOfNSNumberDoubleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartsNSArrayOfNSNumberDoubleArchiveDefaultTypeInternal _ChartsNSArrayOfNSNumberDoubleArchive_default_instance_;
constexpr DEPRECATEDChart3DFillArchive::DEPRECATEDChart3DFillArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: textureset_id_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, fill_(nullptr)
, lightingmodel_(nullptr)
, fill_type_(0)
, series_index_(0u){}
struct DEPRECATEDChart3DFillArchiveDefaultTypeInternal {
constexpr DEPRECATEDChart3DFillArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~DEPRECATEDChart3DFillArchiveDefaultTypeInternal() {}
union {
DEPRECATEDChart3DFillArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DEPRECATEDChart3DFillArchiveDefaultTypeInternal _DEPRECATEDChart3DFillArchive_default_instance_;
constexpr ChartStyleArchive::ChartStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartStyleArchiveDefaultTypeInternal {
constexpr ChartStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartStyleArchiveDefaultTypeInternal() {}
union {
ChartStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartStyleArchiveDefaultTypeInternal _ChartStyleArchive_default_instance_;
constexpr ChartNonStyleArchive::ChartNonStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartNonStyleArchiveDefaultTypeInternal {
constexpr ChartNonStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartNonStyleArchiveDefaultTypeInternal() {}
union {
ChartNonStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartNonStyleArchiveDefaultTypeInternal _ChartNonStyleArchive_default_instance_;
constexpr LegendStyleArchive::LegendStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct LegendStyleArchiveDefaultTypeInternal {
constexpr LegendStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~LegendStyleArchiveDefaultTypeInternal() {}
union {
LegendStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT LegendStyleArchiveDefaultTypeInternal _LegendStyleArchive_default_instance_;
constexpr LegendNonStyleArchive::LegendNonStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct LegendNonStyleArchiveDefaultTypeInternal {
constexpr LegendNonStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~LegendNonStyleArchiveDefaultTypeInternal() {}
union {
LegendNonStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT LegendNonStyleArchiveDefaultTypeInternal _LegendNonStyleArchive_default_instance_;
constexpr ChartAxisStyleArchive::ChartAxisStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartAxisStyleArchiveDefaultTypeInternal {
constexpr ChartAxisStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartAxisStyleArchiveDefaultTypeInternal() {}
union {
ChartAxisStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartAxisStyleArchiveDefaultTypeInternal _ChartAxisStyleArchive_default_instance_;
constexpr ChartAxisNonStyleArchive::ChartAxisNonStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartAxisNonStyleArchiveDefaultTypeInternal {
constexpr ChartAxisNonStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartAxisNonStyleArchiveDefaultTypeInternal() {}
union {
ChartAxisNonStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartAxisNonStyleArchiveDefaultTypeInternal _ChartAxisNonStyleArchive_default_instance_;
constexpr ChartSeriesStyleArchive::ChartSeriesStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartSeriesStyleArchiveDefaultTypeInternal {
constexpr ChartSeriesStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartSeriesStyleArchiveDefaultTypeInternal() {}
union {
ChartSeriesStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartSeriesStyleArchiveDefaultTypeInternal _ChartSeriesStyleArchive_default_instance_;
constexpr ChartSeriesNonStyleArchive::ChartSeriesNonStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ChartSeriesNonStyleArchiveDefaultTypeInternal {
constexpr ChartSeriesNonStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ChartSeriesNonStyleArchiveDefaultTypeInternal() {}
union {
ChartSeriesNonStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ChartSeriesNonStyleArchiveDefaultTypeInternal _ChartSeriesNonStyleArchive_default_instance_;
constexpr GridValue::GridValue(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: numeric_value_(0)
, date_value_1_0_(0)
, duration_value_(0)
, date_value_(0){}
struct GridValueDefaultTypeInternal {
constexpr GridValueDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~GridValueDefaultTypeInternal() {}
union {
GridValue _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GridValueDefaultTypeInternal _GridValue_default_instance_;
constexpr GridRow::GridRow(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: value_(){}
struct GridRowDefaultTypeInternal {
constexpr GridRowDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~GridRowDefaultTypeInternal() {}
union {
GridRow _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GridRowDefaultTypeInternal _GridRow_default_instance_;
constexpr ReferenceLineStyleArchive::ReferenceLineStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ReferenceLineStyleArchiveDefaultTypeInternal {
constexpr ReferenceLineStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ReferenceLineStyleArchiveDefaultTypeInternal() {}
union {
ReferenceLineStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ReferenceLineStyleArchiveDefaultTypeInternal _ReferenceLineStyleArchive_default_instance_;
constexpr ReferenceLineNonStyleArchive::ReferenceLineNonStyleArchive(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: super_(nullptr){}
struct ReferenceLineNonStyleArchiveDefaultTypeInternal {
constexpr ReferenceLineNonStyleArchiveDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ReferenceLineNonStyleArchiveDefaultTypeInternal() {}
union {
ReferenceLineNonStyleArchive _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ReferenceLineNonStyleArchiveDefaultTypeInternal _ReferenceLineNonStyleArchive_default_instance_;
} // namespace TSCH
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_TSCHArchives_2eCommon_2eproto[16];
static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[7];
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_TSCHArchives_2eCommon_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_TSCHArchives_2eCommon_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::TSCH::RectArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::RectArchive, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::RectArchive, origin_),
PROTOBUF_FIELD_OFFSET(::TSCH::RectArchive, size_),
0,
1,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartsNSNumberDoubleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartsNSNumberDoubleArchive, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartsNSNumberDoubleArchive, number_archive_),
0,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartsNSArrayOfNSNumberDoubleArchive, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartsNSArrayOfNSNumberDoubleArchive, numbers_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, fill_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, lightingmodel_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, textureset_id_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, fill_type_),
PROTOBUF_FIELD_OFFSET(::TSCH::DEPRECATEDChart3DFillArchive, series_index_),
1,
2,
0,
3,
4,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartNonStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartNonStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartNonStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartNonStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::LegendStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::LegendStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::LegendStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::LegendStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::LegendNonStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::LegendNonStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::LegendNonStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::LegendNonStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisNonStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisNonStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisNonStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartAxisNonStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesNonStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesNonStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesNonStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ChartSeriesNonStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, numeric_value_),
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, date_value_1_0_),
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, duration_value_),
PROTOBUF_FIELD_OFFSET(::TSCH::GridValue, date_value_),
0,
1,
2,
3,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::TSCH::GridRow, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::GridRow, value_),
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineStyleArchive, super_),
0,
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineNonStyleArchive, _has_bits_),
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineNonStyleArchive, _internal_metadata_),
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineNonStyleArchive, _extensions_),
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::TSCH::ReferenceLineNonStyleArchive, super_),
0,
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 7, sizeof(::TSCH::RectArchive)},
{ 9, 15, sizeof(::TSCH::ChartsNSNumberDoubleArchive)},
{ 16, -1, sizeof(::TSCH::ChartsNSArrayOfNSNumberDoubleArchive)},
{ 22, 32, sizeof(::TSCH::DEPRECATEDChart3DFillArchive)},
{ 37, 43, sizeof(::TSCH::ChartStyleArchive)},
{ 44, 50, sizeof(::TSCH::ChartNonStyleArchive)},
{ 51, 57, sizeof(::TSCH::LegendStyleArchive)},
{ 58, 64, sizeof(::TSCH::LegendNonStyleArchive)},
{ 65, 71, sizeof(::TSCH::ChartAxisStyleArchive)},
{ 72, 78, sizeof(::TSCH::ChartAxisNonStyleArchive)},
{ 79, 85, sizeof(::TSCH::ChartSeriesStyleArchive)},
{ 86, 92, sizeof(::TSCH::ChartSeriesNonStyleArchive)},
{ 93, 102, sizeof(::TSCH::GridValue)},
{ 106, -1, sizeof(::TSCH::GridRow)},
{ 112, 118, sizeof(::TSCH::ReferenceLineStyleArchive)},
{ 119, 125, sizeof(::TSCH::ReferenceLineNonStyleArchive)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_RectArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartsNSNumberDoubleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartsNSArrayOfNSNumberDoubleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_DEPRECATEDChart3DFillArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartNonStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_LegendStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_LegendNonStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartAxisStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartAxisNonStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartSeriesStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ChartSeriesNonStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_GridValue_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_GridRow_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ReferenceLineStyleArchive_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::TSCH::_ReferenceLineNonStyleArchive_default_instance_),
};
const char descriptor_table_protodef_TSCHArchives_2eCommon_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\031TSCHArchives.Common.proto\022\004TSCH\032\021TSPMe"
"ssages.proto\032\021TSKArchives.proto\032\021TSDArch"
"ives.proto\032\021TSSArchives.proto\032\024TSCH3DArc"
"hives.proto\"B\n\013RectArchive\022\032\n\006origin\030\001 \002"
"(\0132\n.TSP.Point\022\027\n\004size\030\002 \002(\0132\t.TSP.Size\""
"5\n\033ChartsNSNumberDoubleArchive\022\026\n\016number"
"_archive\030\001 \001(\001\"7\n$ChartsNSArrayOfNSNumbe"
"rDoubleArchive\022\017\n\007numbers\030\001 \003(\001\"\320\001\n\034DEPR"
"ECATEDChart3DFillArchive\022\036\n\004fill\030\001 \001(\0132\020"
".TSD.FillArchive\0228\n\rlightingmodel\030\002 \001(\0132"
"!.TSCH.Chart3DLightingModelArchive\022\025\n\rte"
"xtureset_id\030\003 \001(\t\022)\n\tfill_type\030\004 \001(\0162\026.T"
"SCH.FillPropertyType\022\024\n\014series_index\030\005 \001"
"(\r\"@\n\021ChartStyleArchive\022 \n\005super\030\001 \001(\0132\021"
".TSS.StyleArchive*\t\010\220N\020\200\200\200\200\002\"C\n\024ChartNon"
"StyleArchive\022 \n\005super\030\001 \001(\0132\021.TSS.StyleA"
"rchive*\t\010\220N\020\200\200\200\200\002\"A\n\022LegendStyleArchive\022"
" \n\005super\030\001 \001(\0132\021.TSS.StyleArchive*\t\010\220N\020\200"
"\200\200\200\002\"D\n\025LegendNonStyleArchive\022 \n\005super\030\001"
" \001(\0132\021.TSS.StyleArchive*\t\010\220N\020\200\200\200\200\002\"D\n\025Ch"
"artAxisStyleArchive\022 \n\005super\030\001 \001(\0132\021.TSS"
".StyleArchive*\t\010\220N\020\200\200\200\200\002\"G\n\030ChartAxisNon"
"StyleArchive\022 \n\005super\030\001 \001(\0132\021.TSS.StyleA"
"rchive*\t\010\220N\020\200\200\200\200\002\"F\n\027ChartSeriesStyleArc"
"hive\022 \n\005super\030\001 \001(\0132\021.TSS.StyleArchive*\t"
"\010\220N\020\200\200\200\200\002\"I\n\032ChartSeriesNonStyleArchive\022"
" \n\005super\030\001 \001(\0132\021.TSS.StyleArchive*\t\010\220N\020\200"
"\200\200\200\002\"f\n\tGridValue\022\025\n\rnumeric_value\030\001 \001(\001"
"\022\026\n\016date_value_1_0\030\002 \001(\001\022\026\n\016duration_val"
"ue\030\003 \001(\001\022\022\n\ndate_value\030\004 \001(\001\")\n\007GridRow\022"
"\036\n\005value\030\001 \003(\0132\017.TSCH.GridValue\"H\n\031Refer"
"enceLineStyleArchive\022 \n\005super\030\001 \001(\0132\021.TS"
"S.StyleArchive*\t\010\220N\020\200\200\200\200\002\"K\n\034ReferenceLi"
"neNonStyleArchive\022 \n\005super\030\001 \001(\0132\021.TSS.S"
"tyleArchive*\t\010\220N\020\200\200\200\200\002*\246\005\n\tChartType\022\026\n\022"
"undefinedChartType\020\000\022\025\n\021columnChartType2"
"D\020\001\022\022\n\016barChartType2D\020\002\022\023\n\017lineChartType"
"2D\020\003\022\023\n\017areaChartType2D\020\004\022\022\n\016pieChartTyp"
"e2D\020\005\022\034\n\030stackedColumnChartType2D\020\006\022\031\n\025s"
"tackedBarChartType2D\020\007\022\032\n\026stackedAreaCha"
"rtType2D\020\010\022\026\n\022scatterChartType2D\020\t\022\024\n\020mi"
"xedChartType2D\020\n\022\026\n\022twoAxisChartType2D\020\013"
"\022\025\n\021columnChartType3D\020\014\022\022\n\016barChartType3"
"D\020\r\022\023\n\017lineChartType3D\020\016\022\023\n\017areaChartTyp"
"e3D\020\017\022\022\n\016pieChartType3D\020\020\022\034\n\030stackedColu"
"mnChartType3D\020\021\022\031\n\025stackedBarChartType3D"
"\020\022\022\032\n\026stackedAreaChartType3D\020\023\022\036\n\032multiD"
"ataColumnChartType2D\020\024\022\033\n\027multiDataBarCh"
"artType2D\020\025\022\025\n\021bubbleChartType2D\020\026\022\037\n\033mu"
"ltiDataScatterChartType2D\020\027\022\036\n\032multiData"
"BubbleChartType2D\020\030\022\024\n\020donutChartType2D\020"
"\031\022\024\n\020donutChartType3D\020\032*j\n\010AxisType\022\025\n\021a"
"xis_type_unknown\020\000\022\017\n\013axis_type_x\020\001\022\017\n\013a"
"xis_type_y\020\002\022\021\n\raxis_type_pie\020\003\022\022\n\016axis_"
"type_size\020\004*g\n\rScatterFormat\022\032\n\026scatter_"
"format_unknown\020\000\022\035\n\031scatter_format_separ"
"ate_x\020\001\022\033\n\027scatter_format_shared_x\020\002*l\n\017"
"SeriesDirection\022\034\n\030series_direction_unkn"
"own\020\000\022\033\n\027series_direction_by_row\020\001\022\036\n\032se"
"ries_direction_by_column\020\002*\343\001\n\017NumberVal"
"ueType\022\032\n\026numberValueTypeDecimal\020\000\022\033\n\027nu"
"mberValueTypeCurrency\020\001\022\035\n\031numberValueTy"
"pePercentage\020\002\022\035\n\031numberValueTypeScienti"
"fic\020\003\022\033\n\027numberValueTypeFraction\020\004\022\027\n\023nu"
"mberValueTypeBase\020\005\022#\n\026numberValueTypeUn"
"known\020\231\370\377\377\377\377\377\377\377\001*\272\001\n\023NegativeNumberStyle"
"\022\034\n\030negativeNumberStyleMinus\020\000\022\032\n\026negati"
"veNumberStyleRed\020\001\022\"\n\036negativeNumberStyl"
"eParentheses\020\002\022(\n$negativeNumberStyleRed"
"AndParentheses\020\003\022\033\n\027negativeNumberStyleN"
"one\020\004*\353\002\n\020FractionAccuracy\022\037\n\033fractionAc"
"curacyConflicting\020\000\022)\n\034fractionAccuracyU"
"pToOneDigit\020\377\377\377\377\377\377\377\377\377\001\022*\n\035fractionAccura"
"cyUpToTwoDigits\020\376\377\377\377\377\377\377\377\377\001\022,\n\037fractionAc"
"curacyUpToThreeDigits\020\375\377\377\377\377\377\377\377\377\001\022\032\n\026frac"
"tionAccuracyHalves\020\002\022\034\n\030fractionAccuracy"
"Quarters\020\004\022\033\n\027fractionAccuracyEighths\020\010\022"
"\036\n\032fractionAccuracySixteenths\020\020\022\032\n\026fract"
"ionAccuracyTenths\020\n\022\036\n\032fractionAccuracyH"
"undredths\020d"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_TSCHArchives_2eCommon_2eproto_deps[5] = {
&::descriptor_table_TSCH3DArchives_2eproto,
&::descriptor_table_TSDArchives_2eproto,
&::descriptor_table_TSKArchives_2eproto,
&::descriptor_table_TSPMessages_2eproto,
&::descriptor_table_TSSArchives_2eproto,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_TSCHArchives_2eCommon_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_TSCHArchives_2eCommon_2eproto = {
false, false, 3171, descriptor_table_protodef_TSCHArchives_2eCommon_2eproto, "TSCHArchives.Common.proto",
&descriptor_table_TSCHArchives_2eCommon_2eproto_once, descriptor_table_TSCHArchives_2eCommon_2eproto_deps, 5, 16,
schemas, file_default_instances, TableStruct_TSCHArchives_2eCommon_2eproto::offsets,
file_level_metadata_TSCHArchives_2eCommon_2eproto, file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto, file_level_service_descriptors_TSCHArchives_2eCommon_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_TSCHArchives_2eCommon_2eproto_getter() {
return &descriptor_table_TSCHArchives_2eCommon_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_TSCHArchives_2eCommon_2eproto(&descriptor_table_TSCHArchives_2eCommon_2eproto);
namespace TSCH {
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ChartType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[0];
}
bool ChartType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AxisType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[1];
}
bool AxisType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ScatterFormat_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[2];
}
bool ScatterFormat_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SeriesDirection_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[3];
}
bool SeriesDirection_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NumberValueType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[4];
}
bool NumberValueType_IsValid(int value) {
switch (value) {
case -999:
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NegativeNumberStyle_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[5];
}
bool NegativeNumberStyle_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
return true;
default:
return false;
}
}
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FractionAccuracy_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_TSCHArchives_2eCommon_2eproto);
return file_level_enum_descriptors_TSCHArchives_2eCommon_2eproto[6];
}
bool FractionAccuracy_IsValid(int value) {
switch (value) {
case -3:
case -2:
case -1:
case 0:
case 2:
case 4:
case 8:
case 10:
case 16:
case 100:
return true;
default:
return false;
}
}
// ===================================================================
class RectArchive::_Internal {
public:
using HasBits = decltype(std::declval<RectArchive>()._has_bits_);
static const ::TSP::Point& origin(const RectArchive* msg);
static void set_has_origin(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static const ::TSP::Size& size(const RectArchive* msg);
static void set_has_size(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
static bool MissingRequiredFields(const HasBits& has_bits) {
return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0;
}
};
const ::TSP::Point&
RectArchive::_Internal::origin(const RectArchive* msg) {
return *msg->origin_;
}
const ::TSP::Size&
RectArchive::_Internal::size(const RectArchive* msg) {
return *msg->size_;
}
void RectArchive::clear_origin() {
if (origin_ != nullptr) origin_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
void RectArchive::clear_size() {
if (size_ != nullptr) size_->Clear();
_has_bits_[0] &= ~0x00000002u;
}
RectArchive::RectArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.RectArchive)
}
RectArchive::RectArchive(const RectArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
if (from._internal_has_origin()) {
origin_ = new ::TSP::Point(*from.origin_);
} else {
origin_ = nullptr;
}
if (from._internal_has_size()) {
size_ = new ::TSP::Size(*from.size_);
} else {
size_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.RectArchive)
}
inline void RectArchive::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&origin_) - reinterpret_cast<char*>(this)),
0, static_cast<size_t>(reinterpret_cast<char*>(&size_) -
reinterpret_cast<char*>(&origin_)) + sizeof(size_));
}
RectArchive::~RectArchive() {
// @@protoc_insertion_point(destructor:TSCH.RectArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void RectArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete origin_;
if (this != internal_default_instance()) delete size_;
}
void RectArchive::ArenaDtor(void* object) {
RectArchive* _this = reinterpret_cast< RectArchive* >(object);
(void)_this;
}
void RectArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void RectArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void RectArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.RectArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(origin_ != nullptr);
origin_->Clear();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(size_ != nullptr);
size_->Clear();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* RectArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// required .TSP.Point origin = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_origin(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// required .TSP.Size size = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr = ctx->ParseMessage(_internal_mutable_size(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* RectArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.RectArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required .TSP.Point origin = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::origin(this), target, stream);
}
// required .TSP.Size size = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
2, _Internal::size(this), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.RectArchive)
return target;
}
size_t RectArchive::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:TSCH.RectArchive)
size_t total_size = 0;
if (_internal_has_origin()) {
// required .TSP.Point origin = 1;
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*origin_);
}
if (_internal_has_size()) {
// required .TSP.Size size = 2;
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*size_);
}
return total_size;
}
size_t RectArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.RectArchive)
size_t total_size = 0;
if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present.
// required .TSP.Point origin = 1;
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*origin_);
// required .TSP.Size size = 2;
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*size_);
} else {
total_size += RequiredFieldsByteSizeFallback();
}
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData RectArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
RectArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*RectArchive::GetClassData() const { return &_class_data_; }
void RectArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<RectArchive *>(to)->MergeFrom(
static_cast<const RectArchive &>(from));
}
void RectArchive::MergeFrom(const RectArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.RectArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
_internal_mutable_origin()->::TSP::Point::MergeFrom(from._internal_origin());
}
if (cached_has_bits & 0x00000002u) {
_internal_mutable_size()->::TSP::Size::MergeFrom(from._internal_size());
}
}
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void RectArchive::CopyFrom(const RectArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.RectArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool RectArchive::IsInitialized() const {
if (_Internal::MissingRequiredFields(_has_bits_)) return false;
if (_internal_has_origin()) {
if (!origin_->IsInitialized()) return false;
}
if (_internal_has_size()) {
if (!size_->IsInitialized()) return false;
}
return true;
}
void RectArchive::InternalSwap(RectArchive* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(RectArchive, size_)
+ sizeof(RectArchive::size_)
- PROTOBUF_FIELD_OFFSET(RectArchive, origin_)>(
reinterpret_cast<char*>(&origin_),
reinterpret_cast<char*>(&other->origin_));
}
::PROTOBUF_NAMESPACE_ID::Metadata RectArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[0]);
}
// ===================================================================
class ChartsNSNumberDoubleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartsNSNumberDoubleArchive>()._has_bits_);
static void set_has_number_archive(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
ChartsNSNumberDoubleArchive::ChartsNSNumberDoubleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartsNSNumberDoubleArchive)
}
ChartsNSNumberDoubleArchive::ChartsNSNumberDoubleArchive(const ChartsNSNumberDoubleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
number_archive_ = from.number_archive_;
// @@protoc_insertion_point(copy_constructor:TSCH.ChartsNSNumberDoubleArchive)
}
inline void ChartsNSNumberDoubleArchive::SharedCtor() {
number_archive_ = 0;
}
ChartsNSNumberDoubleArchive::~ChartsNSNumberDoubleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartsNSNumberDoubleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartsNSNumberDoubleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
void ChartsNSNumberDoubleArchive::ArenaDtor(void* object) {
ChartsNSNumberDoubleArchive* _this = reinterpret_cast< ChartsNSNumberDoubleArchive* >(object);
(void)_this;
}
void ChartsNSNumberDoubleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartsNSNumberDoubleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartsNSNumberDoubleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartsNSNumberDoubleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
number_archive_ = 0;
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartsNSNumberDoubleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional double number_archive = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) {
_Internal::set_has_number_archive(&has_bits);
number_archive_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartsNSNumberDoubleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartsNSNumberDoubleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional double number_archive = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_number_archive(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartsNSNumberDoubleArchive)
return target;
}
size_t ChartsNSNumberDoubleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartsNSNumberDoubleArchive)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional double number_archive = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 + 8;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartsNSNumberDoubleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartsNSNumberDoubleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartsNSNumberDoubleArchive::GetClassData() const { return &_class_data_; }
void ChartsNSNumberDoubleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartsNSNumberDoubleArchive *>(to)->MergeFrom(
static_cast<const ChartsNSNumberDoubleArchive &>(from));
}
void ChartsNSNumberDoubleArchive::MergeFrom(const ChartsNSNumberDoubleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartsNSNumberDoubleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_number_archive()) {
_internal_set_number_archive(from._internal_number_archive());
}
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartsNSNumberDoubleArchive::CopyFrom(const ChartsNSNumberDoubleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartsNSNumberDoubleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartsNSNumberDoubleArchive::IsInitialized() const {
return true;
}
void ChartsNSNumberDoubleArchive::InternalSwap(ChartsNSNumberDoubleArchive* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(number_archive_, other->number_archive_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartsNSNumberDoubleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[1]);
}
// ===================================================================
class ChartsNSArrayOfNSNumberDoubleArchive::_Internal {
public:
};
ChartsNSArrayOfNSNumberDoubleArchive::ChartsNSArrayOfNSNumberDoubleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
numbers_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
}
ChartsNSArrayOfNSNumberDoubleArchive::ChartsNSArrayOfNSNumberDoubleArchive(const ChartsNSArrayOfNSNumberDoubleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
numbers_(from.numbers_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
}
inline void ChartsNSArrayOfNSNumberDoubleArchive::SharedCtor() {
}
ChartsNSArrayOfNSNumberDoubleArchive::~ChartsNSArrayOfNSNumberDoubleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartsNSArrayOfNSNumberDoubleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
void ChartsNSArrayOfNSNumberDoubleArchive::ArenaDtor(void* object) {
ChartsNSArrayOfNSNumberDoubleArchive* _this = reinterpret_cast< ChartsNSArrayOfNSNumberDoubleArchive* >(object);
(void)_this;
}
void ChartsNSArrayOfNSNumberDoubleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartsNSArrayOfNSNumberDoubleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartsNSArrayOfNSNumberDoubleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
numbers_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartsNSArrayOfNSNumberDoubleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated double numbers = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) {
ptr -= 1;
do {
ptr += 1;
_internal_add_numbers(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr));
ptr += sizeof(double);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<9>(ptr));
} else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) {
ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedDoubleParser(_internal_mutable_numbers(), ptr, ctx);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartsNSArrayOfNSNumberDoubleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated double numbers = 1;
for (int i = 0, n = this->_internal_numbers_size(); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_numbers(i), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
return target;
}
size_t ChartsNSArrayOfNSNumberDoubleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated double numbers = 1;
{
unsigned int count = static_cast<unsigned int>(this->_internal_numbers_size());
size_t data_size = 8UL * count;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_numbers_size());
total_size += data_size;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartsNSArrayOfNSNumberDoubleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartsNSArrayOfNSNumberDoubleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartsNSArrayOfNSNumberDoubleArchive::GetClassData() const { return &_class_data_; }
void ChartsNSArrayOfNSNumberDoubleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartsNSArrayOfNSNumberDoubleArchive *>(to)->MergeFrom(
static_cast<const ChartsNSArrayOfNSNumberDoubleArchive &>(from));
}
void ChartsNSArrayOfNSNumberDoubleArchive::MergeFrom(const ChartsNSArrayOfNSNumberDoubleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
numbers_.MergeFrom(from.numbers_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartsNSArrayOfNSNumberDoubleArchive::CopyFrom(const ChartsNSArrayOfNSNumberDoubleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartsNSArrayOfNSNumberDoubleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartsNSArrayOfNSNumberDoubleArchive::IsInitialized() const {
return true;
}
void ChartsNSArrayOfNSNumberDoubleArchive::InternalSwap(ChartsNSArrayOfNSNumberDoubleArchive* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
numbers_.InternalSwap(&other->numbers_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartsNSArrayOfNSNumberDoubleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[2]);
}
// ===================================================================
class DEPRECATEDChart3DFillArchive::_Internal {
public:
using HasBits = decltype(std::declval<DEPRECATEDChart3DFillArchive>()._has_bits_);
static const ::TSD::FillArchive& fill(const DEPRECATEDChart3DFillArchive* msg);
static void set_has_fill(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
static const ::TSCH::Chart3DLightingModelArchive& lightingmodel(const DEPRECATEDChart3DFillArchive* msg);
static void set_has_lightingmodel(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
static void set_has_textureset_id(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_fill_type(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
static void set_has_series_index(HasBits* has_bits) {
(*has_bits)[0] |= 16u;
}
};
const ::TSD::FillArchive&
DEPRECATEDChart3DFillArchive::_Internal::fill(const DEPRECATEDChart3DFillArchive* msg) {
return *msg->fill_;
}
const ::TSCH::Chart3DLightingModelArchive&
DEPRECATEDChart3DFillArchive::_Internal::lightingmodel(const DEPRECATEDChart3DFillArchive* msg) {
return *msg->lightingmodel_;
}
void DEPRECATEDChart3DFillArchive::clear_fill() {
if (fill_ != nullptr) fill_->Clear();
_has_bits_[0] &= ~0x00000002u;
}
void DEPRECATEDChart3DFillArchive::clear_lightingmodel() {
if (lightingmodel_ != nullptr) lightingmodel_->Clear();
_has_bits_[0] &= ~0x00000004u;
}
DEPRECATEDChart3DFillArchive::DEPRECATEDChart3DFillArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.DEPRECATEDChart3DFillArchive)
}
DEPRECATEDChart3DFillArchive::DEPRECATEDChart3DFillArchive(const DEPRECATEDChart3DFillArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
textureset_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (from._internal_has_textureset_id()) {
textureset_id_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_textureset_id(),
GetArenaForAllocation());
}
if (from._internal_has_fill()) {
fill_ = new ::TSD::FillArchive(*from.fill_);
} else {
fill_ = nullptr;
}
if (from._internal_has_lightingmodel()) {
lightingmodel_ = new ::TSCH::Chart3DLightingModelArchive(*from.lightingmodel_);
} else {
lightingmodel_ = nullptr;
}
::memcpy(&fill_type_, &from.fill_type_,
static_cast<size_t>(reinterpret_cast<char*>(&series_index_) -
reinterpret_cast<char*>(&fill_type_)) + sizeof(series_index_));
// @@protoc_insertion_point(copy_constructor:TSCH.DEPRECATEDChart3DFillArchive)
}
inline void DEPRECATEDChart3DFillArchive::SharedCtor() {
textureset_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&fill_) - reinterpret_cast<char*>(this)),
0, static_cast<size_t>(reinterpret_cast<char*>(&series_index_) -
reinterpret_cast<char*>(&fill_)) + sizeof(series_index_));
}
DEPRECATEDChart3DFillArchive::~DEPRECATEDChart3DFillArchive() {
// @@protoc_insertion_point(destructor:TSCH.DEPRECATEDChart3DFillArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void DEPRECATEDChart3DFillArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
textureset_id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete fill_;
if (this != internal_default_instance()) delete lightingmodel_;
}
void DEPRECATEDChart3DFillArchive::ArenaDtor(void* object) {
DEPRECATEDChart3DFillArchive* _this = reinterpret_cast< DEPRECATEDChart3DFillArchive* >(object);
(void)_this;
}
void DEPRECATEDChart3DFillArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void DEPRECATEDChart3DFillArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void DEPRECATEDChart3DFillArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.DEPRECATEDChart3DFillArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000007u) {
if (cached_has_bits & 0x00000001u) {
textureset_id_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(fill_ != nullptr);
fill_->Clear();
}
if (cached_has_bits & 0x00000004u) {
GOOGLE_DCHECK(lightingmodel_ != nullptr);
lightingmodel_->Clear();
}
}
if (cached_has_bits & 0x00000018u) {
::memset(&fill_type_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&series_index_) -
reinterpret_cast<char*>(&fill_type_)) + sizeof(series_index_));
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* DEPRECATEDChart3DFillArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSD.FillArchive fill = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_fill(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional .TSCH.Chart3DLightingModelArchive lightingmodel = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr = ctx->ParseMessage(_internal_mutable_lightingmodel(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional string textureset_id = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
auto str = _internal_mutable_textureset_id();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
#ifndef NDEBUG
::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "TSCH.DEPRECATEDChart3DFillArchive.textureset_id");
#endif // !NDEBUG
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional .TSCH.FillPropertyType fill_type = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
if (PROTOBUF_PREDICT_TRUE(::TSCH::FillPropertyType_IsValid(val))) {
_internal_set_fill_type(static_cast<::TSCH::FillPropertyType>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields());
}
} else goto handle_unusual;
continue;
// optional uint32 series_index = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
_Internal::set_has_series_index(&has_bits);
series_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* DEPRECATEDChart3DFillArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.DEPRECATEDChart3DFillArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSD.FillArchive fill = 1;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::fill(this), target, stream);
}
// optional .TSCH.Chart3DLightingModelArchive lightingmodel = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
2, _Internal::lightingmodel(this), target, stream);
}
// optional string textureset_id = 3;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_textureset_id().data(), static_cast<int>(this->_internal_textureset_id().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"TSCH.DEPRECATEDChart3DFillArchive.textureset_id");
target = stream->WriteStringMaybeAliased(
3, this->_internal_textureset_id(), target);
}
// optional .TSCH.FillPropertyType fill_type = 4;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
4, this->_internal_fill_type(), target);
}
// optional uint32 series_index = 5;
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(5, this->_internal_series_index(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.DEPRECATEDChart3DFillArchive)
return target;
}
size_t DEPRECATEDChart3DFillArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.DEPRECATEDChart3DFillArchive)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000001fu) {
// optional string textureset_id = 3;
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_textureset_id());
}
// optional .TSD.FillArchive fill = 1;
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*fill_);
}
// optional .TSCH.Chart3DLightingModelArchive lightingmodel = 2;
if (cached_has_bits & 0x00000004u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*lightingmodel_);
}
// optional .TSCH.FillPropertyType fill_type = 4;
if (cached_has_bits & 0x00000008u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_fill_type());
}
// optional uint32 series_index = 5;
if (cached_has_bits & 0x00000010u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32Size(
this->_internal_series_index());
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DEPRECATEDChart3DFillArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
DEPRECATEDChart3DFillArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DEPRECATEDChart3DFillArchive::GetClassData() const { return &_class_data_; }
void DEPRECATEDChart3DFillArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<DEPRECATEDChart3DFillArchive *>(to)->MergeFrom(
static_cast<const DEPRECATEDChart3DFillArchive &>(from));
}
void DEPRECATEDChart3DFillArchive::MergeFrom(const DEPRECATEDChart3DFillArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.DEPRECATEDChart3DFillArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x0000001fu) {
if (cached_has_bits & 0x00000001u) {
_internal_set_textureset_id(from._internal_textureset_id());
}
if (cached_has_bits & 0x00000002u) {
_internal_mutable_fill()->::TSD::FillArchive::MergeFrom(from._internal_fill());
}
if (cached_has_bits & 0x00000004u) {
_internal_mutable_lightingmodel()->::TSCH::Chart3DLightingModelArchive::MergeFrom(from._internal_lightingmodel());
}
if (cached_has_bits & 0x00000008u) {
fill_type_ = from.fill_type_;
}
if (cached_has_bits & 0x00000010u) {
series_index_ = from.series_index_;
}
_has_bits_[0] |= cached_has_bits;
}
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void DEPRECATEDChart3DFillArchive::CopyFrom(const DEPRECATEDChart3DFillArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.DEPRECATEDChart3DFillArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool DEPRECATEDChart3DFillArchive::IsInitialized() const {
if (_internal_has_fill()) {
if (!fill_->IsInitialized()) return false;
}
if (_internal_has_lightingmodel()) {
if (!lightingmodel_->IsInitialized()) return false;
}
return true;
}
void DEPRECATEDChart3DFillArchive::InternalSwap(DEPRECATEDChart3DFillArchive* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&textureset_id_, GetArenaForAllocation(),
&other->textureset_id_, other->GetArenaForAllocation()
);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(DEPRECATEDChart3DFillArchive, series_index_)
+ sizeof(DEPRECATEDChart3DFillArchive::series_index_)
- PROTOBUF_FIELD_OFFSET(DEPRECATEDChart3DFillArchive, fill_)>(
reinterpret_cast<char*>(&fill_),
reinterpret_cast<char*>(&other->fill_));
}
::PROTOBUF_NAMESPACE_ID::Metadata DEPRECATEDChart3DFillArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[3]);
}
// ===================================================================
class ChartStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartStyleArchive::_Internal::super(const ChartStyleArchive* msg) {
return *msg->super_;
}
void ChartStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartStyleArchive::ChartStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartStyleArchive)
}
ChartStyleArchive::ChartStyleArchive(const ChartStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartStyleArchive)
}
inline void ChartStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartStyleArchive::~ChartStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartStyleArchive::ArenaDtor(void* object) {
ChartStyleArchive* _this = reinterpret_cast< ChartStyleArchive* >(object);
(void)_this;
}
void ChartStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartStyleArchive)
return target;
}
size_t ChartStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartStyleArchive::GetClassData() const { return &_class_data_; }
void ChartStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartStyleArchive *>(to)->MergeFrom(
static_cast<const ChartStyleArchive &>(from));
}
void ChartStyleArchive::MergeFrom(const ChartStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartStyleArchive::CopyFrom(const ChartStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartStyleArchive::InternalSwap(ChartStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[4]);
}
// ===================================================================
class ChartNonStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartNonStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartNonStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartNonStyleArchive::_Internal::super(const ChartNonStyleArchive* msg) {
return *msg->super_;
}
void ChartNonStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartNonStyleArchive::ChartNonStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartNonStyleArchive)
}
ChartNonStyleArchive::ChartNonStyleArchive(const ChartNonStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartNonStyleArchive)
}
inline void ChartNonStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartNonStyleArchive::~ChartNonStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartNonStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartNonStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartNonStyleArchive::ArenaDtor(void* object) {
ChartNonStyleArchive* _this = reinterpret_cast< ChartNonStyleArchive* >(object);
(void)_this;
}
void ChartNonStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartNonStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartNonStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartNonStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartNonStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartNonStyleArchive)
return target;
}
size_t ChartNonStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartNonStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartNonStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartNonStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartNonStyleArchive::GetClassData() const { return &_class_data_; }
void ChartNonStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartNonStyleArchive *>(to)->MergeFrom(
static_cast<const ChartNonStyleArchive &>(from));
}
void ChartNonStyleArchive::MergeFrom(const ChartNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartNonStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartNonStyleArchive::CopyFrom(const ChartNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartNonStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartNonStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartNonStyleArchive::InternalSwap(ChartNonStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartNonStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[5]);
}
// ===================================================================
class LegendStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<LegendStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const LegendStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
LegendStyleArchive::_Internal::super(const LegendStyleArchive* msg) {
return *msg->super_;
}
void LegendStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
LegendStyleArchive::LegendStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.LegendStyleArchive)
}
LegendStyleArchive::LegendStyleArchive(const LegendStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.LegendStyleArchive)
}
inline void LegendStyleArchive::SharedCtor() {
super_ = nullptr;
}
LegendStyleArchive::~LegendStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.LegendStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void LegendStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void LegendStyleArchive::ArenaDtor(void* object) {
LegendStyleArchive* _this = reinterpret_cast< LegendStyleArchive* >(object);
(void)_this;
}
void LegendStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LegendStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void LegendStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.LegendStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LegendStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LegendStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.LegendStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.LegendStyleArchive)
return target;
}
size_t LegendStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.LegendStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData LegendStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
LegendStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*LegendStyleArchive::GetClassData() const { return &_class_data_; }
void LegendStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<LegendStyleArchive *>(to)->MergeFrom(
static_cast<const LegendStyleArchive &>(from));
}
void LegendStyleArchive::MergeFrom(const LegendStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.LegendStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void LegendStyleArchive::CopyFrom(const LegendStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.LegendStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LegendStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void LegendStyleArchive::InternalSwap(LegendStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata LegendStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[6]);
}
// ===================================================================
class LegendNonStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<LegendNonStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const LegendNonStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
LegendNonStyleArchive::_Internal::super(const LegendNonStyleArchive* msg) {
return *msg->super_;
}
void LegendNonStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
LegendNonStyleArchive::LegendNonStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.LegendNonStyleArchive)
}
LegendNonStyleArchive::LegendNonStyleArchive(const LegendNonStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.LegendNonStyleArchive)
}
inline void LegendNonStyleArchive::SharedCtor() {
super_ = nullptr;
}
LegendNonStyleArchive::~LegendNonStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.LegendNonStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void LegendNonStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void LegendNonStyleArchive::ArenaDtor(void* object) {
LegendNonStyleArchive* _this = reinterpret_cast< LegendNonStyleArchive* >(object);
(void)_this;
}
void LegendNonStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LegendNonStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void LegendNonStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.LegendNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LegendNonStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LegendNonStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.LegendNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.LegendNonStyleArchive)
return target;
}
size_t LegendNonStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.LegendNonStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData LegendNonStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
LegendNonStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*LegendNonStyleArchive::GetClassData() const { return &_class_data_; }
void LegendNonStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<LegendNonStyleArchive *>(to)->MergeFrom(
static_cast<const LegendNonStyleArchive &>(from));
}
void LegendNonStyleArchive::MergeFrom(const LegendNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.LegendNonStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void LegendNonStyleArchive::CopyFrom(const LegendNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.LegendNonStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LegendNonStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void LegendNonStyleArchive::InternalSwap(LegendNonStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata LegendNonStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[7]);
}
// ===================================================================
class ChartAxisStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartAxisStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartAxisStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartAxisStyleArchive::_Internal::super(const ChartAxisStyleArchive* msg) {
return *msg->super_;
}
void ChartAxisStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartAxisStyleArchive::ChartAxisStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartAxisStyleArchive)
}
ChartAxisStyleArchive::ChartAxisStyleArchive(const ChartAxisStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartAxisStyleArchive)
}
inline void ChartAxisStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartAxisStyleArchive::~ChartAxisStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartAxisStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartAxisStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartAxisStyleArchive::ArenaDtor(void* object) {
ChartAxisStyleArchive* _this = reinterpret_cast< ChartAxisStyleArchive* >(object);
(void)_this;
}
void ChartAxisStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartAxisStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartAxisStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartAxisStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartAxisStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartAxisStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartAxisStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartAxisStyleArchive)
return target;
}
size_t ChartAxisStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartAxisStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartAxisStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartAxisStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartAxisStyleArchive::GetClassData() const { return &_class_data_; }
void ChartAxisStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartAxisStyleArchive *>(to)->MergeFrom(
static_cast<const ChartAxisStyleArchive &>(from));
}
void ChartAxisStyleArchive::MergeFrom(const ChartAxisStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartAxisStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartAxisStyleArchive::CopyFrom(const ChartAxisStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartAxisStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartAxisStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartAxisStyleArchive::InternalSwap(ChartAxisStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartAxisStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[8]);
}
// ===================================================================
class ChartAxisNonStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartAxisNonStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartAxisNonStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartAxisNonStyleArchive::_Internal::super(const ChartAxisNonStyleArchive* msg) {
return *msg->super_;
}
void ChartAxisNonStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartAxisNonStyleArchive::ChartAxisNonStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartAxisNonStyleArchive)
}
ChartAxisNonStyleArchive::ChartAxisNonStyleArchive(const ChartAxisNonStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartAxisNonStyleArchive)
}
inline void ChartAxisNonStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartAxisNonStyleArchive::~ChartAxisNonStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartAxisNonStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartAxisNonStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartAxisNonStyleArchive::ArenaDtor(void* object) {
ChartAxisNonStyleArchive* _this = reinterpret_cast< ChartAxisNonStyleArchive* >(object);
(void)_this;
}
void ChartAxisNonStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartAxisNonStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartAxisNonStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartAxisNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartAxisNonStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartAxisNonStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartAxisNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartAxisNonStyleArchive)
return target;
}
size_t ChartAxisNonStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartAxisNonStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartAxisNonStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartAxisNonStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartAxisNonStyleArchive::GetClassData() const { return &_class_data_; }
void ChartAxisNonStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartAxisNonStyleArchive *>(to)->MergeFrom(
static_cast<const ChartAxisNonStyleArchive &>(from));
}
void ChartAxisNonStyleArchive::MergeFrom(const ChartAxisNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartAxisNonStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartAxisNonStyleArchive::CopyFrom(const ChartAxisNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartAxisNonStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartAxisNonStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartAxisNonStyleArchive::InternalSwap(ChartAxisNonStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartAxisNonStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[9]);
}
// ===================================================================
class ChartSeriesStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartSeriesStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartSeriesStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartSeriesStyleArchive::_Internal::super(const ChartSeriesStyleArchive* msg) {
return *msg->super_;
}
void ChartSeriesStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartSeriesStyleArchive::ChartSeriesStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartSeriesStyleArchive)
}
ChartSeriesStyleArchive::ChartSeriesStyleArchive(const ChartSeriesStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartSeriesStyleArchive)
}
inline void ChartSeriesStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartSeriesStyleArchive::~ChartSeriesStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartSeriesStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartSeriesStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartSeriesStyleArchive::ArenaDtor(void* object) {
ChartSeriesStyleArchive* _this = reinterpret_cast< ChartSeriesStyleArchive* >(object);
(void)_this;
}
void ChartSeriesStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartSeriesStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartSeriesStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartSeriesStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartSeriesStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartSeriesStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartSeriesStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartSeriesStyleArchive)
return target;
}
size_t ChartSeriesStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartSeriesStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartSeriesStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartSeriesStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartSeriesStyleArchive::GetClassData() const { return &_class_data_; }
void ChartSeriesStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartSeriesStyleArchive *>(to)->MergeFrom(
static_cast<const ChartSeriesStyleArchive &>(from));
}
void ChartSeriesStyleArchive::MergeFrom(const ChartSeriesStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartSeriesStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartSeriesStyleArchive::CopyFrom(const ChartSeriesStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartSeriesStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartSeriesStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartSeriesStyleArchive::InternalSwap(ChartSeriesStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartSeriesStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[10]);
}
// ===================================================================
class ChartSeriesNonStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ChartSeriesNonStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ChartSeriesNonStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ChartSeriesNonStyleArchive::_Internal::super(const ChartSeriesNonStyleArchive* msg) {
return *msg->super_;
}
void ChartSeriesNonStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ChartSeriesNonStyleArchive::ChartSeriesNonStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ChartSeriesNonStyleArchive)
}
ChartSeriesNonStyleArchive::ChartSeriesNonStyleArchive(const ChartSeriesNonStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ChartSeriesNonStyleArchive)
}
inline void ChartSeriesNonStyleArchive::SharedCtor() {
super_ = nullptr;
}
ChartSeriesNonStyleArchive::~ChartSeriesNonStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ChartSeriesNonStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ChartSeriesNonStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ChartSeriesNonStyleArchive::ArenaDtor(void* object) {
ChartSeriesNonStyleArchive* _this = reinterpret_cast< ChartSeriesNonStyleArchive* >(object);
(void)_this;
}
void ChartSeriesNonStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ChartSeriesNonStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ChartSeriesNonStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ChartSeriesNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ChartSeriesNonStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ChartSeriesNonStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ChartSeriesNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ChartSeriesNonStyleArchive)
return target;
}
size_t ChartSeriesNonStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ChartSeriesNonStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ChartSeriesNonStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ChartSeriesNonStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ChartSeriesNonStyleArchive::GetClassData() const { return &_class_data_; }
void ChartSeriesNonStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ChartSeriesNonStyleArchive *>(to)->MergeFrom(
static_cast<const ChartSeriesNonStyleArchive &>(from));
}
void ChartSeriesNonStyleArchive::MergeFrom(const ChartSeriesNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ChartSeriesNonStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ChartSeriesNonStyleArchive::CopyFrom(const ChartSeriesNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ChartSeriesNonStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ChartSeriesNonStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ChartSeriesNonStyleArchive::InternalSwap(ChartSeriesNonStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ChartSeriesNonStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[11]);
}
// ===================================================================
class GridValue::_Internal {
public:
using HasBits = decltype(std::declval<GridValue>()._has_bits_);
static void set_has_numeric_value(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_date_value_1_0(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
static void set_has_duration_value(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
static void set_has_date_value(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
};
GridValue::GridValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.GridValue)
}
GridValue::GridValue(const GridValue& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&numeric_value_, &from.numeric_value_,
static_cast<size_t>(reinterpret_cast<char*>(&date_value_) -
reinterpret_cast<char*>(&numeric_value_)) + sizeof(date_value_));
// @@protoc_insertion_point(copy_constructor:TSCH.GridValue)
}
inline void GridValue::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
reinterpret_cast<char*>(&numeric_value_) - reinterpret_cast<char*>(this)),
0, static_cast<size_t>(reinterpret_cast<char*>(&date_value_) -
reinterpret_cast<char*>(&numeric_value_)) + sizeof(date_value_));
}
GridValue::~GridValue() {
// @@protoc_insertion_point(destructor:TSCH.GridValue)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void GridValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
void GridValue::ArenaDtor(void* object) {
GridValue* _this = reinterpret_cast< GridValue* >(object);
(void)_this;
}
void GridValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void GridValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void GridValue::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.GridValue)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
::memset(&numeric_value_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&date_value_) -
reinterpret_cast<char*>(&numeric_value_)) + sizeof(date_value_));
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* GridValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional double numeric_value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) {
_Internal::set_has_numeric_value(&has_bits);
numeric_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
} else goto handle_unusual;
continue;
// optional double date_value_1_0 = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 17)) {
_Internal::set_has_date_value_1_0(&has_bits);
date_value_1_0_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
} else goto handle_unusual;
continue;
// optional double duration_value = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 25)) {
_Internal::set_has_duration_value(&has_bits);
duration_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
} else goto handle_unusual;
continue;
// optional double date_value = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 33)) {
_Internal::set_has_date_value(&has_bits);
date_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr);
ptr += sizeof(double);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* GridValue::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.GridValue)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional double numeric_value = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_numeric_value(), target);
}
// optional double date_value_1_0 = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(2, this->_internal_date_value_1_0(), target);
}
// optional double duration_value = 3;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(3, this->_internal_duration_value(), target);
}
// optional double date_value = 4;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(4, this->_internal_date_value(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.GridValue)
return target;
}
size_t GridValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.GridValue)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
// optional double numeric_value = 1;
if (cached_has_bits & 0x00000001u) {
total_size += 1 + 8;
}
// optional double date_value_1_0 = 2;
if (cached_has_bits & 0x00000002u) {
total_size += 1 + 8;
}
// optional double duration_value = 3;
if (cached_has_bits & 0x00000004u) {
total_size += 1 + 8;
}
// optional double date_value = 4;
if (cached_has_bits & 0x00000008u) {
total_size += 1 + 8;
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GridValue::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
GridValue::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GridValue::GetClassData() const { return &_class_data_; }
void GridValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<GridValue *>(to)->MergeFrom(
static_cast<const GridValue &>(from));
}
void GridValue::MergeFrom(const GridValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.GridValue)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
numeric_value_ = from.numeric_value_;
}
if (cached_has_bits & 0x00000002u) {
date_value_1_0_ = from.date_value_1_0_;
}
if (cached_has_bits & 0x00000004u) {
duration_value_ = from.duration_value_;
}
if (cached_has_bits & 0x00000008u) {
date_value_ = from.date_value_;
}
_has_bits_[0] |= cached_has_bits;
}
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void GridValue::CopyFrom(const GridValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.GridValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool GridValue::IsInitialized() const {
return true;
}
void GridValue::InternalSwap(GridValue* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(GridValue, date_value_)
+ sizeof(GridValue::date_value_)
- PROTOBUF_FIELD_OFFSET(GridValue, numeric_value_)>(
reinterpret_cast<char*>(&numeric_value_),
reinterpret_cast<char*>(&other->numeric_value_));
}
::PROTOBUF_NAMESPACE_ID::Metadata GridValue::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[12]);
}
// ===================================================================
class GridRow::_Internal {
public:
};
GridRow::GridRow(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
value_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.GridRow)
}
GridRow::GridRow(const GridRow& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
value_(from.value_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:TSCH.GridRow)
}
inline void GridRow::SharedCtor() {
}
GridRow::~GridRow() {
// @@protoc_insertion_point(destructor:TSCH.GridRow)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void GridRow::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
void GridRow::ArenaDtor(void* object) {
GridRow* _this = reinterpret_cast< GridRow* >(object);
(void)_this;
}
void GridRow::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void GridRow::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void GridRow::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.GridRow)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* GridRow::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// repeated .TSCH.GridValue value = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_value(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* GridRow::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.GridRow)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .TSCH.GridValue value = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_value_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(1, this->_internal_value(i), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.GridRow)
return target;
}
size_t GridRow::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.GridRow)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .TSCH.GridValue value = 1;
total_size += 1UL * this->_internal_value_size();
for (const auto& msg : this->value_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GridRow::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
GridRow::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GridRow::GetClassData() const { return &_class_data_; }
void GridRow::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<GridRow *>(to)->MergeFrom(
static_cast<const GridRow &>(from));
}
void GridRow::MergeFrom(const GridRow& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.GridRow)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
value_.MergeFrom(from.value_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void GridRow::CopyFrom(const GridRow& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.GridRow)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool GridRow::IsInitialized() const {
return true;
}
void GridRow::InternalSwap(GridRow* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
value_.InternalSwap(&other->value_);
}
::PROTOBUF_NAMESPACE_ID::Metadata GridRow::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[13]);
}
// ===================================================================
class ReferenceLineStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ReferenceLineStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ReferenceLineStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ReferenceLineStyleArchive::_Internal::super(const ReferenceLineStyleArchive* msg) {
return *msg->super_;
}
void ReferenceLineStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ReferenceLineStyleArchive::ReferenceLineStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ReferenceLineStyleArchive)
}
ReferenceLineStyleArchive::ReferenceLineStyleArchive(const ReferenceLineStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ReferenceLineStyleArchive)
}
inline void ReferenceLineStyleArchive::SharedCtor() {
super_ = nullptr;
}
ReferenceLineStyleArchive::~ReferenceLineStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ReferenceLineStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ReferenceLineStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ReferenceLineStyleArchive::ArenaDtor(void* object) {
ReferenceLineStyleArchive* _this = reinterpret_cast< ReferenceLineStyleArchive* >(object);
(void)_this;
}
void ReferenceLineStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ReferenceLineStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ReferenceLineStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ReferenceLineStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ReferenceLineStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ReferenceLineStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ReferenceLineStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ReferenceLineStyleArchive)
return target;
}
size_t ReferenceLineStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ReferenceLineStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ReferenceLineStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ReferenceLineStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ReferenceLineStyleArchive::GetClassData() const { return &_class_data_; }
void ReferenceLineStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ReferenceLineStyleArchive *>(to)->MergeFrom(
static_cast<const ReferenceLineStyleArchive &>(from));
}
void ReferenceLineStyleArchive::MergeFrom(const ReferenceLineStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ReferenceLineStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ReferenceLineStyleArchive::CopyFrom(const ReferenceLineStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ReferenceLineStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ReferenceLineStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ReferenceLineStyleArchive::InternalSwap(ReferenceLineStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ReferenceLineStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[14]);
}
// ===================================================================
class ReferenceLineNonStyleArchive::_Internal {
public:
using HasBits = decltype(std::declval<ReferenceLineNonStyleArchive>()._has_bits_);
static const ::TSS::StyleArchive& super(const ReferenceLineNonStyleArchive* msg);
static void set_has_super(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
};
const ::TSS::StyleArchive&
ReferenceLineNonStyleArchive::_Internal::super(const ReferenceLineNonStyleArchive* msg) {
return *msg->super_;
}
void ReferenceLineNonStyleArchive::clear_super() {
if (super_ != nullptr) super_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
ReferenceLineNonStyleArchive::ReferenceLineNonStyleArchive(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
_extensions_(arena) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:TSCH.ReferenceLineNonStyleArchive)
}
ReferenceLineNonStyleArchive::ReferenceLineNonStyleArchive(const ReferenceLineNonStyleArchive& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_extensions_.MergeFrom(from._extensions_);
if (from._internal_has_super()) {
super_ = new ::TSS::StyleArchive(*from.super_);
} else {
super_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:TSCH.ReferenceLineNonStyleArchive)
}
inline void ReferenceLineNonStyleArchive::SharedCtor() {
super_ = nullptr;
}
ReferenceLineNonStyleArchive::~ReferenceLineNonStyleArchive() {
// @@protoc_insertion_point(destructor:TSCH.ReferenceLineNonStyleArchive)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
inline void ReferenceLineNonStyleArchive::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
if (this != internal_default_instance()) delete super_;
}
void ReferenceLineNonStyleArchive::ArenaDtor(void* object) {
ReferenceLineNonStyleArchive* _this = reinterpret_cast< ReferenceLineNonStyleArchive* >(object);
(void)_this;
}
void ReferenceLineNonStyleArchive::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ReferenceLineNonStyleArchive::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ReferenceLineNonStyleArchive::Clear() {
// @@protoc_insertion_point(message_clear_start:TSCH.ReferenceLineNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_extensions_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(super_ != nullptr);
super_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* ReferenceLineNonStyleArchive::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional .TSS.StyleArchive super = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr = ctx->ParseMessage(_internal_mutable_super(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto success;
}
if ((80000u <= tag)) {
ptr = _extensions_.ParseField(tag, ptr,
internal_default_instance(), &_internal_metadata_, ctx);
CHK_(ptr != nullptr);
continue;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* ReferenceLineNonStyleArchive::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:TSCH.ReferenceLineNonStyleArchive)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .TSS.StyleArchive super = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
1, _Internal::super(this), target, stream);
}
// Extension range [10000, 536870912)
target = _extensions_._InternalSerialize(
10000, 536870912, target, stream);
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:TSCH.ReferenceLineNonStyleArchive)
return target;
}
size_t ReferenceLineNonStyleArchive::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:TSCH.ReferenceLineNonStyleArchive)
size_t total_size = 0;
total_size += _extensions_.ByteSize();
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// optional .TSS.StyleArchive super = 1;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*super_);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ReferenceLineNonStyleArchive::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
ReferenceLineNonStyleArchive::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ReferenceLineNonStyleArchive::GetClassData() const { return &_class_data_; }
void ReferenceLineNonStyleArchive::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<ReferenceLineNonStyleArchive *>(to)->MergeFrom(
static_cast<const ReferenceLineNonStyleArchive &>(from));
}
void ReferenceLineNonStyleArchive::MergeFrom(const ReferenceLineNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:TSCH.ReferenceLineNonStyleArchive)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_has_super()) {
_internal_mutable_super()->::TSS::StyleArchive::MergeFrom(from._internal_super());
}
_extensions_.MergeFrom(from._extensions_);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void ReferenceLineNonStyleArchive::CopyFrom(const ReferenceLineNonStyleArchive& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:TSCH.ReferenceLineNonStyleArchive)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ReferenceLineNonStyleArchive::IsInitialized() const {
if (!_extensions_.IsInitialized()) {
return false;
}
if (_internal_has_super()) {
if (!super_->IsInitialized()) return false;
}
return true;
}
void ReferenceLineNonStyleArchive::InternalSwap(ReferenceLineNonStyleArchive* other) {
using std::swap;
_extensions_.InternalSwap(&other->_extensions_);
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(super_, other->super_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ReferenceLineNonStyleArchive::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_TSCHArchives_2eCommon_2eproto_getter, &descriptor_table_TSCHArchives_2eCommon_2eproto_once,
file_level_metadata_TSCHArchives_2eCommon_2eproto[15]);
}
// @@protoc_insertion_point(namespace_scope)
} // namespace TSCH
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::TSCH::RectArchive* Arena::CreateMaybeMessage< ::TSCH::RectArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::RectArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartsNSNumberDoubleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartsNSNumberDoubleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartsNSNumberDoubleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartsNSArrayOfNSNumberDoubleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartsNSArrayOfNSNumberDoubleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartsNSArrayOfNSNumberDoubleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::DEPRECATEDChart3DFillArchive* Arena::CreateMaybeMessage< ::TSCH::DEPRECATEDChart3DFillArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::DEPRECATEDChart3DFillArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartNonStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartNonStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartNonStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::LegendStyleArchive* Arena::CreateMaybeMessage< ::TSCH::LegendStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::LegendStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::LegendNonStyleArchive* Arena::CreateMaybeMessage< ::TSCH::LegendNonStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::LegendNonStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartAxisStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartAxisStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartAxisStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartAxisNonStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartAxisNonStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartAxisNonStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartSeriesStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartSeriesStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartSeriesStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ChartSeriesNonStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ChartSeriesNonStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ChartSeriesNonStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::GridValue* Arena::CreateMaybeMessage< ::TSCH::GridValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::GridValue >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::GridRow* Arena::CreateMaybeMessage< ::TSCH::GridRow >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::GridRow >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ReferenceLineStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ReferenceLineStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ReferenceLineStyleArchive >(arena);
}
template<> PROTOBUF_NOINLINE ::TSCH::ReferenceLineNonStyleArchive* Arena::CreateMaybeMessage< ::TSCH::ReferenceLineNonStyleArchive >(Arena* arena) {
return Arena::CreateMessageInternal< ::TSCH::ReferenceLineNonStyleArchive >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 38.185265 | 194 | 0.74131 |
837d9f6d44723ba8afe7f9b91c002461cc41994c | 367 | cpp | C++ | FSM/TrafficLight/TrafficLightSystem.cpp | Labae/CK_2-2-Game_AI | a8d953835883fd0cf7f92ba5d86fa93785f373bc | [
"MIT"
] | null | null | null | FSM/TrafficLight/TrafficLightSystem.cpp | Labae/CK_2-2-Game_AI | a8d953835883fd0cf7f92ba5d86fa93785f373bc | [
"MIT"
] | null | null | null | FSM/TrafficLight/TrafficLightSystem.cpp | Labae/CK_2-2-Game_AI | a8d953835883fd0cf7f92ba5d86fa93785f373bc | [
"MIT"
] | null | null | null | #include "TrafficLightSystem.h"
#include "RedState.h"
TrafficLightSystem::TrafficLightSystem()
{
_currentState = RedState::GetInstance();
}
void TrafficLightSystem::Update()
{
_currentState->Execute(this);
}
void TrafficLightSystem::ChangeState(TrafficLightState* newState)
{
_currentState->Exit(this);
_currentState = newState;
_currentState->Enter(this);
}
| 18.35 | 65 | 0.773842 |
83848908769e44e2dd54352c19cf74b42dc858bd | 12,497 | cpp | C++ | uppdev/Decimal/decimal.cpp | dreamsxin/ultimatepp | 41d295d999f9ff1339b34b43c99ce279b9b3991c | [
"BSD-2-Clause"
] | 2 | 2016-04-07T07:54:26.000Z | 2020-04-14T12:37:34.000Z | uppdev/Decimal/decimal.cpp | dreamsxin/ultimatepp | 41d295d999f9ff1339b34b43c99ce279b9b3991c | [
"BSD-2-Clause"
] | null | null | null | uppdev/Decimal/decimal.cpp | dreamsxin/ultimatepp | 41d295d999f9ff1339b34b43c99ce279b9b3991c | [
"BSD-2-Clause"
] | null | null | null | #include "decimal.h"
decimal::decimal() {
ASSERT(_D_SIZE_>_D_PREC_);
parse_string=true;
memsetd(number, 0, _D_SIZE_);
sign=1;
trim_trailing_zeroes=true;
print_precision=DECIMAL_PRECISION;
rounding_mode=DEFAULT_ROUNDING;
parse_string=true;
}
void decimal::FromString(String s) {
int i=0, idx=-1, j=_D_SIZE_-_D_PREC_, length;
memsetd(number, 0, _D_SIZE_);
sign=1;
s=TrimLeft(TrimRight(s));
if(parse_string) {
length=s.GetCount();
if(s[i]=='-' || s[i]=='+') { length--; i++; }
while(i<s.GetCount() && IsDigit(s[i])) i++;
if(s[i]=='.') idx=i++;
while(i<s.GetCount() && IsDigit(s[i])) i++;
if(idx>=0) length--;
if(i<s.GetCount() || (length>_D_SIZE_*9)) { throw Exc("NUMBER TOO BIG TO FIT IN SPECIFIED FORMAT"); return; } // OVERFLOW
if(idx>=0 && (s.GetCount()-idx-1)>_D_PREC_*9) { throw Exc("NUMBER TOO BIG TO FIT IN SPECIFIED FORMAT"); return; } // OVERFLOW
}
if(s[0]=='-' || s[0]=='+') {
if(s[0]=='-') sign=-1;
s.Remove(0);
}
Vector<String> parts=Split(s, '.');
if(parts.GetCount()>0) {
String temp=parts[0];
length=temp.GetCount();
while(length>=9) { number[--j]=StrInt(temp.Right(9)); temp.Trim(length-=9); }
if(temp.GetCount()>0) number[--j]=StrInt(temp);
}
if(parts.GetCount()>1) {
String temp=parts[1];
j=_D_SIZE_-_D_PREC_;
length=temp.GetCount();
while(length>=9) { number[j++]=StrInt(temp.Left(9)); length-=9; temp=temp.Mid(9); }
if(temp.GetCount()>0) number[j++]=StrInt(temp+String('0', 9-temp.GetCount()));
}
j=0;
for(i=0;i<_D_SIZE_;i++) if(number[i]!=0) j++;
if(j==0) sign=1;
}
void decimal::PrintPrecision(int precision) {
print_precision=precision;
}
int decimal::PrintPrecision() {
return print_precision;
}
void decimal::RoundingMode(int rounding) {
rounding_mode=rounding;
}
int decimal::RoundingMode() {
return rounding_mode;
}
void decimal::TrimZeros(bool b) {
trim_trailing_zeroes=b;
}
bool decimal::TrimZeros() {
return trim_trailing_zeroes;
}
#define ROUND_DECIMAL(PREC, ROUND_MODE) \
switch(ROUND_MODE) { \
case ROUND_DOWN: { \
idx=s.GetCount()-_D_PREC_*9+PREC-1; \
if(s[idx+1]>'5') s.Set(idx, s[idx]+1); \
while(idx>0 && s[idx]>'9') { s.Set(idx, '0'); s.Set(--idx, s[idx]+1); } \
} \
break; \
case ROUND_UP: { \
idx=s.GetCount()-_D_PREC_*9+PREC-1; \
if(s[idx+1]>='5') s.Set(idx, s[idx]+1); \
while(idx>0 && s[idx]>'9') { s.Set(idx, '0'); s.Set(--idx, s[idx]+1); } \
} \
break; \
case ROUND_HALF_EVEN: { \
int temp=0; \
idx=s.GetCount()-_D_PREC_*9+PREC-1; \
if(s[idx+1]>'5') s.Set(idx, s[idx]+1); \
else \
if(s[idx+1]=='5') { \
if((s[idx]-'0')%2==1) s.Set(idx, s[idx]+1); \
else { \
for(int j=idx+2;j<s.GetCount();j++) temp+=(s[j]-'0'); \
if(temp>0) s.Set(idx, s[idx]+1); \
} \
} \
while(idx>0 && s[idx]>'9') { s.Set(idx, '0'); s.Set(--idx, s[idx]+1); } \
} \
break; }
decimal& decimal::Round(int precision, int rounding) {
if(IsNull(precision)) precision=print_precision;
if(IsNull(rounding)) rounding=rounding_mode;
if((precision<_D_PREC_*9)) {
String s="";
int i=0, idx;
if(sign<0) s="-";
for(;i<_D_SIZE_;i++) s+=Format("%09i", (int64)number[i]);
ROUND_DECIMAL(precision, rounding);
for(i=idx+1;i<s.GetCount();i++) s.Set(i, '0');
for(i=0;i<_D_SIZE_;i++) {
number[i]=StrInt(s.Left(9));
s=s.Mid(9);
}
}
return *this;
}
String decimal::ToString() const {
if(isnull()) return "";
String s="";
int i=0, idx;
if(sign<0) s="-";
for(;i<_D_SIZE_;i++) s+=Format("%09i", (int64)number[i]);
if(_D_PREC_>0) {
if(s!="0") {
if((print_precision<_D_PREC_*9) || IsNull(print_precision))
ROUND_DECIMAL(print_precision, rounding_mode);
s.Insert(s.GetCount()-_D_PREC_*9, '.');
s=s.Left(s.GetCount()-_D_PREC_*9+print_precision);
if(trim_trailing_zeroes) {
int i=s.GetCount();
while(s[i-1]=='0') i--;
if(s[i-1]=='.') i--;
s.Trim(i);
}
}
else if(!trim_trailing_zeroes) s+="."+String('0', _D_PREC_*9);
}
int j=0;
if(s[0]=='-') j=1;
i=j;
while(i<s.GetCount() && s[i]=='0') i++;
if(s[i]=='.' && i>0) i--;
s.Remove(j, i-j);
if(sign<0) {
i=1;
while(i<s.GetCount() && (s[i]=='0' || s[i]=='.')) i++;
if(i>=s.GetCount()) s=s.Mid(1);
}
if(*s.Last()=='.') s=s.Left(s.GetCount()-1);
// Round();
// parse_string=false;
/* FromString(s);
parse_string=true;*/
return s;
}
decimal& decimal::operator=(decimal d) {
memcpy(number, d.number, _D_SIZE_*sizeof(int));
sign=d.sign;
return *this;
}
int decimal::CompareTo(decimal d) const {
if(sign!=d.sign)
if(sign>d.sign) return 1;
if(sign<d.sign) return -1;
int i=0;
while(i<_D_SIZE_ && number[i]==d.number[i]) i++;
if(i>=_D_SIZE_) return 0;
if(number[i]>d.number[i]) return 1;
return -1;
}
bool decimal::operator==(decimal &d) {
return (CompareTo(d)==0);
}
bool decimal::operator!=(decimal &d) {
return (CompareTo(d)!=0);
}
bool decimal::operator>=(decimal &d) {
return (CompareTo(d)>=0);
}
bool decimal::operator>(decimal &d) {
return (CompareTo(d)>0);
}
bool decimal::operator<=(decimal &d) {
return (CompareTo(d)<=0);
}
bool decimal::operator<(decimal &d) {
return (CompareTo(d)<0);
}
decimal& decimal::operator+=(decimal &d) {
if(sign==d.sign) {
decimal temp(d);
int carry=0;
for(int i=_D_SIZE_-1;i>=0;i--) {
number[i]+=(temp.number[i]+carry);
if(number[i]>999999999) { number[i]-=(int32)1000000000; carry=1; }
else carry=0;
}
if(carry>0) { throw Exc("NUMERIC OVERFLOW"); return *this; } // OVERFLOW
return *this;
}
if(sign<0) { sign=1; decimal temp(*this); *this=d; return (*this-=temp); }
decimal temp(d); temp.sign=1;
return (*this-=temp);
}
decimal decimal::operator+(decimal &d) {
decimal temp(*this);
return (temp+=d);
}
decimal decimal::operator++(int) {
decimal temp(*this);
*this+=1;
return temp;
}
decimal& decimal::operator++() {
return (*this+=1);
}
decimal& decimal::operator-=(decimal &d) {
if(sign==d.sign && sign==1) {
decimal temp(d);
if(CompareTo(d)<0) { decimal temp2(*this); *this=temp; temp=temp2; sign*=-1; }
int carry=0;
for(int i=_D_SIZE_-1;i>=0;i--) {
number[i]-=(temp.number[i]+carry);
if(number[i]<0) { number[i]+=(int32)1000000000; carry=1; }
else carry=0;
}
return *this;
}
if(sign==d.sign) { decimal temp(*this); temp.sign=1; *this=d; sign=1; return (*this-=temp); }
if(sign<0) { decimal temp(d); temp.sign=1; sign=1; *this+=temp; sign=-1; return *this; }
decimal temp(d); temp.sign=1;
return (*this+=temp);
}
decimal decimal::operator-(decimal &d) {
decimal temp(*this);
return (temp-=d);
}
decimal decimal::operator-() {
decimal temp(*this);
temp.sign*=-1;
return temp;
}
decimal decimal::operator--(int) {
decimal temp(*this);
*this-=1;
return temp;
}
decimal& decimal::operator--() {
return (*this-=1);
}
decimal& decimal::operator*=(decimal &d) {
int64 accum[(_D_SIZE_ << 1)-1], carry=0;
int64 temp, mult;
memsetd(accum, 0, ((_D_SIZE_ << 1)-1) << 1);
int idx=(_D_SIZE_ << 1)-2;
for(int i=_D_SIZE_-1;i>=0;i--) {
mult=d.number[i];
for(int j=_D_SIZE_-1,k=idx;j>=0;j--,k--) {
temp=number[j];
accum[k]=temp*mult+accum[k];
}
idx--;
}
for(int i=(_D_SIZE_ << 1)-2;i>=0;i--) {
int64 temp=accum[i]+carry;
if(temp>=1000000000) { carry=temp/1000000000; accum[i]=temp%1000000000; }
else { carry=0; accum[i]=temp; }
}
for(int i=0;i<_D_SIZE_;i++) number[i]=(int32)accum[(_D_SIZE_-1-_D_PREC_)+i];
sign*=d.sign;
if(carry>0) { throw Exc("NUMERIC OVERFLOW"); return *this; } // OVERFLOW
return *this;
}
decimal decimal::operator*(decimal &d) {
decimal temp(*this);
return (temp*=d);
}
decimal& decimal::operator/=(decimal &d) {
if(d.CompareTo(decimal(0))==0) { throw Exc("DIVISION BY ZERO!"); return *this; }
if(d.CompareTo(decimal(1))==0) return *this;
if(d.CompareTo(decimal(-1))==0) { sign*=-1; return *this; }
if(d.CompareTo(decimal(*this))==0) { return decimal::ONE; }
if(d.CompareTo(decimal(2))==0) { ShiftRight(); return *this; }
if(d.CompareTo(decimal(4))==0) { ShiftRight(); return *this; }
int _sign=sign;
sign=1;
decimal l, m(*this), v;
bool found=false, repeat=false;
int cmp=0;
if(abs(d)<ONE) {
int i=0;
String temp=d.ToString();
temp=temp.Mid(temp.Find('.')+1);
m=10;
while(temp[i++]=='0') m*=10;
}
m>>=1; l=m;
while(!found) {
v=m;
v*=d;
cmp=CompareTo(v);
repeat=(l.CompareTo(decimal::ZERO)==0);
found=(cmp==0) || repeat;
if(!found) {
l>>=1;
if(cmp<0) m-=l;
else m+=l;
}
}
_sign=_sign*d.sign;
*this=m;
sign=_sign;
return *this;
}
decimal& decimal::Sqrt() {
if(sign<0) { throw Exc("NO SQRT FOR NEGATIV NUMBERS!"); return *this; }
if(CompareTo(decimal(0))==0) { *this=ZERO; return *this; }
if(CompareTo(decimal(1))==0) return *this;
decimal l, m(*this), v;
bool found=false, repeat=false;
int cmp=0;
if(m<ONE) m=1;
m>>=1; l=m;
while(!found) {
v=m;
v*=v;
cmp=CompareTo(v);
repeat=(l.CompareTo(decimal::ZERO)==0);
found=(cmp==0) || repeat;
if(!found) {
l>>=1;
if(cmp<0) m-=l;
else m+=l;
}
}
*this=m;
return *this;
}
decimal decimal::operator/(decimal &d) {
decimal temp(*this);
return (temp/=d);
}
decimal& decimal::ShiftLeft() {
int carry=0;
for(int i=_D_SIZE_-1;i>=0;i--) {
number[i]<<=1;
number[i]+=carry;
carry=(number[i]>=1000000000)?1:0;
if(carry) number[i]%=1000000000;
}
return *this;
}
decimal& decimal::ShiftRight() {
int carry=0, temp=0;
for(int i=0;i<_D_SIZE_;i++) {
temp=number[i]&1;
number[i]>>=1;
number[i]+=carry;
carry=(temp)?500000000:0;
}
return *this;
}
decimal& decimal::operator<<=(int n) {
for(int i=0;i<n;i++) ShiftLeft();
return *this;
}
decimal decimal::operator<<(int n) {
decimal temp(*this);
return (temp<<=n);
}
decimal& decimal::operator>>=(int n) {
for(int i=0;i<n;i++) ShiftRight();
return *this;
}
decimal decimal::operator>>(int n) {
decimal temp(*this);
return (temp>>=n);
}
decimal& decimal::operator^=(int n) {
decimal temp(*this);
for(int i=1;i<n;i++) *this*=temp;
return *this;
}
decimal decimal::operator^(int n) {
decimal temp(*this);
return (temp^=n);
}
bool decimal::isnull() const {
return (number[0]==1111111111);
}
decimal& decimal::Absolute() {
sign=1;
return *this;
}
decimal& decimal::Floor() {
int32 temp=0;
for(int i=_D_SIZE_-_D_PREC_;i<_D_SIZE_;i++) { temp|=number[i]; number[i]=0; }
if(sign>=0) return *this;
if(temp>0) --*this;
return *this;
}
decimal& decimal::Ceil() {
int32 temp=0;
for(int i=_D_SIZE_-_D_PREC_;i<_D_SIZE_;i++) { temp|=number[i]; number[i]=0; }
if(sign<0) return *this;
if(temp>0) ++*this;
return *this;
}
bool decimal::IsNullInstance() const { return isnull(); }
decimal::operator Value() const { return RichToValue(*this); }
decimal::decimal(const Value& v, int precision, int rounding) { FromString(AsString(v)); trim_trailing_zeroes=true; print_precision=precision; rounding_mode=rounding; }
int decimal::Compare(const Value& b) const { return CompareTo(b); }
void decimal::Serialize(Stream &s) { s.Put(ToString()); }
unsigned decimal::GetHashValue() const {
return ::GetHashValue(ToString());;
}
decimal abs(decimal d) {
return d.Absolute();
}
decimal floor(decimal d) {
return d.Floor();
}
decimal ceil(decimal d) {
return d.Ceil();
}
decimal sqrt(decimal d) {
return d.Sqrt();
}
decimal round(decimal d, int precision, int rounding) {
decimal temp(d);
return temp.Round(precision, rounding);
}
static decimal operator+(Value t, decimal d) {
decimal temp(t);
return (temp+=d);
}
static decimal operator-(Value t, decimal d) {
decimal temp(t);
return (temp-=d);
}
static decimal operator*(Value t, decimal d) {
decimal temp(t);
return (temp*=d);
}
static decimal operator/(Value t, decimal d) {
decimal temp(t);
return (temp/=d);
}
decimal decimal::ZERO=decimal(0);
decimal decimal::ONE=decimal(1);
decimal decimal::TWO=decimal(2);
decimal decimal::TEN=decimal(10);
| 23.099815 | 171 | 0.58238 |
83880c9a9e2fe889701fe33268bcd2629cf76c4e | 45,042 | cxx | C++ | Utilities/ImMapAttic/vtkFLTKOpenGLRenderWindow.cxx | NIRALUser/AtlasWerks | a074ca208ab41a6ed89c1f0b70004998f7397681 | [
"BSD-3-Clause"
] | 3 | 2016-04-26T05:06:06.000Z | 2020-08-01T09:46:54.000Z | Utilities/ImMapAttic/vtkFLTKOpenGLRenderWindow.cxx | scalphunters/AtlasWerks | 9d224bf8db628805368fcb7973ac578937b6b595 | [
"BSD-3-Clause"
] | 1 | 2018-11-27T21:53:48.000Z | 2019-05-13T15:21:31.000Z | Utilities/ImMapAttic/vtkFLTKOpenGLRenderWindow.cxx | scalphunters/AtlasWerks | 9d224bf8db628805368fcb7973ac578937b6b595 | [
"BSD-3-Clause"
] | 2 | 2019-01-24T02:07:17.000Z | 2019-12-11T17:27:42.000Z | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* $Id: vtkFLTKOpenGLRenderWindow.cxx,v 1.44 2005/04/27 02:47:07 xpxqx Exp $
*
* Copyright (c) 2002 - 2005 Sean McInerney
* All rights reserved.
*
* See Copyright.txt or http://vtkfltk.sourceforge.net/Copyright.html
* for details.
*
* This software is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the above copyright notice for more information.
*
*/
#include "vtkFLTKOpenGLRenderWindow.h"
#include "vtkFLTKRenderWindowInteractor.h"
#ifndef VTK_IMPLEMENT_MESA_CXX
# include "vtkOpenGLRenderer.h"
# include "vtkOpenGLProperty.h"
# include "vtkOpenGLTexture.h"
# include "vtkOpenGLCamera.h"
# include "vtkOpenGLLight.h"
# include "vtkOpenGLActor.h"
# include "vtkOpenGLPolyDataMapper.h"
#else
# include "MangleMesaInclude/osmesa.h"
#endif /* VTK_IMPLEMENT_MESA_CXX */
#include "vtkToolkits.h"
#ifndef VTK_IMPLEMENT_MESA_CXX
# ifdef VTK_OPENGL_HAS_OSMESA
# include <GL/osmesa.h>
# endif /* VTK_OPENGL_HAS_OSMESA */
#endif /* VTK_IMPLEMENT_MESA_CXX */
// FLTK
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/gl.h>
// Warning: whatever GLContextType is defined to must take
// exactly the same space in a structure as a void* !!!
#if defined(WIN32)
# if defined(_MSC_VER) || defined (__BORLANDC__)
# include <GL/glaux.h>
# endif
typedef HGLRC GLContextType;
typedef HWND WindowIdType;
#elif defined(APPLE)
# include <AGL/agl.h>
typedef AGLContext GLContextType;
typedef WindowRef WindowIdType;
#elif defined(UNIX)
# include "GL/glx.h"
typedef GLXContext GLContextType;
typedef Window WindowIdType;
#endif
// VTK Common
#include "vtkCommand.h"
#include "vtkIdList.h"
#include "vtkObjectFactory.h"
#include "vtkRendererCollection.h"
// vtkFLTK
#include "Fl_VTK_Window.H"
// Forwarded Standard C Library header.
#include <string.h>
// Standard C++ Library header.
#include <sstream>
class vtkFLTKOpenGLRenderWindow;
class vtkRenderWindow;
class vtkFLTKOpenGLRenderWindowInternal
{
friend class vtkFLTKOpenGLRenderWindow;
private:
vtkFLTKOpenGLRenderWindowInternal (vtkRenderWindow*);
#ifdef VTK_OPENGL_HAS_OSMESA
// OffScreen stuff
OSMesaContext OffScreenContextId;
void* OffScreenWindow;
int ScreenMapped;
// Looks like this just stores DoubleBuffer.
int ScreenDoubleBuffer;
#endif /* VTK_OPENGL_HAS_OSMESA */
};
vtkFLTKOpenGLRenderWindowInternal::vtkFLTKOpenGLRenderWindowInternal (
#ifdef VTK_OPENGL_HAS_OSMESA
vtkRenderWindow* a
#else
vtkRenderWindow* vtkNotUsed(a)
#endif /* VTK_OPENGL_HAS_OSMESA */
)
{
// OpenGL specific
#ifdef VTK_OPENGL_HAS_OSMESA
this->OffScreenContextId = 0;
this->OffScreenWindow = 0;
this->ScreenMapped = a->GetMapped();
this->ScreenDoubleBuffer = a->GetDoubleBuffer();
#endif /* VTK_OPENGL_HAS_OSMESA */
}
// ----------------------------------------------------------------------------
// v t k F L T K O p e n G L R e n d e r W i n d o w
// ----------------------------------------------------------------------------
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro (vtkFLTKOpenGLRenderWindow, "$Revision: 1.44 $");
vtkStandardNewMacro (vtkFLTKOpenGLRenderWindow);
#endif /* !VTK_IMPLEMENT_MESA_CXX */
#define MAX_LIGHTS 8
#ifdef VTK_OPENGL_HAS_OSMESA
// a couple of routines for offscreen rendering
void
vtkOSMesaDestroyWindow (void* aWindow)
{
free(aWindow);
}
void*
vtkOSMesaCreateWindow (int aWidth, int aHeight)
{
return malloc(aWidth * aHeight * 4);
}
#endif /* VTK_OPENGL_HAS_OSMESA */
// ----------------------------------------------------------------------------
vtkFLTKOpenGLRenderWindow::vtkFLTKOpenGLRenderWindow (void)
: Internal(new vtkFLTKOpenGLRenderWindowInternal(this)),
FlParent(NULL),
FlWindow(NULL),
Mode(-1),
OwnFlWindow(0),
CursorHidden(0),
ForceMakeCurrent(0),
UsingHardware(0),
Capabilities(NULL)
{
this->ScreenSize[0] = this->ScreenSize[1] = 0;
static const char* title = "vtkFLTK - OpenGL";
if (this->WindowName != NULL) delete [] this->WindowName;
this->WindowName = strcpy(new char[strlen(title)+1], title);
}
vtkFLTKOpenGLRenderWindow::~vtkFLTKOpenGLRenderWindow()
{
// close-down all system-specific drawing resources
this->Finalize();
delete this->Internal;
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::Frame (void)
{
vtkDebugMacro(<< "Frame() (subclass method)");
this->MakeCurrent();
if (!this->AbortRender && this->DoubleBuffer && this->SwapBuffers)
{
if (this->FlWindow != NULL)
{
this->FlWindow->swap_buffers();
vtkDebugMacro(<< "Frame(): Fl_Gl_Window::swap_buffers()");
}
}
}
// ----------------------------------------------------------------------------
vtkRenderWindowInteractor*
vtkFLTKOpenGLRenderWindow::MakeRenderWindowInteractor (void)
{
this->Interactor = vtkFLTKRenderWindowInteractor::New();
(static_cast<vtkFLTKRenderWindowInteractor*>(this->Interactor))->
SetWidget(this->FlWindow);
this->Interactor->SetRenderWindow(this);
return this->Interactor;
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetBorders (int a)
{
vtkDebugMacro(<< " setting Borders to " << a << ".");
if (this->Borders == a)
return;
if (this->FlWindow != NULL)
{
this->FlWindow->border(a);
if ((this->FlWindow->border() && a) || (!this->FlWindow->border() && !a))
{
this->Borders = a;
this->Modified();
}
else
{
vtkWarningMacro(<< "Border change request failed. This must usually"
<<" be performed before a window has been realized.");
}
}
else
{
this->Borders = a;
this->Modified();
}
}
void
vtkFLTKOpenGLRenderWindow::SetStereoCapableWindow (int a)
{
vtkDebugMacro(<< " setting StereoCapableWindow to " << a << ".");
if (this->StereoCapableWindow == a)
return;
if (!this->GetMapped())
{
this->StereoCapableWindow = a;
this->Modified();
}
else
{
vtkWarningMacro(<< "Requesting StereoCapableWindow must be performed "
<< "before a window is realized, i.e. before a render.");
}
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::WindowInitialize (void)
{
int x = 5, y = 5, w = 300, h = 300;
vtkDebugMacro(<< "WindowInitialize()");
if (this->FlWindow != NULL)
{
x = this->FlWindow->x();
y = this->FlWindow->y();
w = this->FlWindow->w();
h = this->FlWindow->h();
}
else
{
if (this->Position[0] >= 0) x = this->Position[0];
if (this->Position[1] >= 0) y = this->Position[1];
if (this->Size[0] > 0) w = this->Size[0];
if (this->Size[1] > 0) h = this->Size[1];
}
if (!this->OffScreenRendering)
{
// Ensure connection to the default display.
this->CheckDisplayConnection();
if (this->FlWindow == NULL) // Create our own window.
{
// NOTE: Fl_Gl_Window makes sure that a modifying call to resize()
// is made at the end of its constructor.
this->FlWindow = new Fl_VTK_Window(this, x, y, w, h, this->WindowName);
this->OwnFlWindow = 1;
if (this->FlParent != NULL)
{
this->FlParent->add(static_cast<Fl_Widget*>(this->FlWindow));
}
}
else // Use a supplied window.
{
if (this->FlParent != NULL && this->FlParent != this->FlWindow->parent())
{
this->FlParent->add(static_cast<Fl_Widget*>(this->FlWindow));
}
if (this->FlWindow->GetRenderWindow() != this)
{
this->FlWindow->SetRenderWindow(this);
}
this->FlWindow->resize_(x, y, w, h);
}
// Get the parent if one has not been set.
if (this->FlParent == NULL)
{
this->SetFlParent(this->FlWindow->parent());
}
// Sets the OpenGL capabilites of the window as a side effect.
(void) this->GetDesiredVisualMode();
this->FlWindow->border(this->Borders);
// Realize the widget.
if (this->FlParent != NULL)
this->FlParent->show();
else
this->FlWindow->show();
// Bring its GL context up to date.
this->MakeCurrent();
// Flushes the output buffer and wait until all requests
// have been received and processed by the server.
Fl::check();
this->Mapped = this->FlWindow->shown();
this->Position[0] = this->FlWindow->x();
this->Position[1] = this->FlWindow->y();
this->Size[0] = this->FlWindow->w();
this->Size[1] = this->FlWindow->h();
}
else
{
this->DoubleBuffer = 0;
#ifdef VTK_OPENGL_HAS_OSMESA
if (this->Internal->OffScreenWindow == NULL)
{
this->Internal->OffScreenWindow = vtkOSMesaCreateWindow(w,h);
this->Size[0] = w;
this->Size[1] = h;
this->OwnFlWindow = 1;
}
this->Internal->OffScreenContextId = OSMesaCreateContext(GL_RGBA, 0);
#endif /* VTK_OPENGL_HAS_OSMESA */
this->MakeCurrent();
this->Mapped = 0;
}
//
// Tell our renderers about us.
//
vtkRenderer* renderer;
for ( this->Renderers->InitTraversal();
(renderer = this->Renderers->GetNextItem()) != 0; )
{
// Each vtkProp in the renderer calls ReleaseGraphicsResources().
renderer->SetRenderWindow(NULL);
renderer->SetRenderWindow(this);
}
//
// Sets up OpenGL with MODELVIEW matrix mode, enabled LEQUAL depth test,
// a texture environment with texture function GL_MODULATE, enabled blending
// with GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA. Point, line, and polygon
// smoothing are then toggled according to their respective ivars.
// GL_NORMALIZE is enable and the light model set to GL_LIGHT_MODEL_TWO_SIDE.
//
this->OpenGLInit();
glAlphaFunc(GL_GREATER, 0);
}
void
vtkFLTKOpenGLRenderWindow::Initialize (void)
{
vtkDebugMacro(<< "Initialize()");
// Check to see if already been initialized.
if ( (this->FlWindow != NULL && this->FlWindow->context() != NULL)
#ifdef VTK_OPENGL_HAS_OSMESA
|| this->Internal->OffScreenContextId != NULL
#endif /* VTK_OPENGL_HAS_OSMESA */
)
{
return;
}
// Now initialize the window.
this->WindowInitialize();
}
void
vtkFLTKOpenGLRenderWindow::Finalize (void)
{
vtkDebugMacro(<< "Finalize()");
// make sure we have been initialized
if ( (this->FlWindow != NULL && this->FlWindow->context() != NULL)
#ifdef VTK_OPENGL_HAS_OSMESA
|| this->Internal->OffScreenContextId != NULL
#endif /* VTK_OPENGL_HAS_OSMESA */
)
{
this->MakeCurrent();
// tell each of the renderers that this render window/graphics context
// is being removed (the RendererCollection is removed by
// vtkRenderWindow's destructor)
vtkRenderer* ren;
for ( this->Renderers->InitTraversal();
(ren = this->Renderers->GetNextItem()) != NULL; )
{
// Each vtkProp in the renderer calls ReleaseGraphicsResources().
ren->SetRenderWindow(NULL);
}
// First, delete all the old lights.
for (short lighti=GL_LIGHT0; lighti<GL_LIGHT0+MAX_LIGHTS; lighti++)
{
glDisable(GLenum(lighti));
}
// Now delete all textures.
GLuint id;
glDisable(GL_TEXTURE_2D);
for (int i=1; i<this->TextureResourceIds->GetNumberOfIds(); i++)
{
id = GLuint(this->TextureResourceIds->GetId(i));
#ifdef GL_VERSION_1_1
if (glIsTexture(id))
{
glDeleteTextures(1, &id);
}
#else
if (glIsList(id))
{
glDeleteLists(id, 1);
}
#endif /* GL_VERSION_1_1 */
}
glFinish();
#ifdef VTK_OPENGL_HAS_OSMESA
if (this->OffScreenRendering && this->Internal->OffScreenContextId != NULL)
{
OSMesaDestroyContext(this->Internal->OffScreenContextId);
this->Internal->OffScreenContextId = NULL;
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
this->Internal->OffScreenWindow = NULL;
}
else
#endif /* VTK_OPENGL_HAS_OSMESA */
{
this->FlWindow->context(NULL, true/*destroy*/);
// then close the old window
if ( this->OwnFlWindow &&
#if !defined(APPLE)
fl_display != NULL &&
#endif /* APPLE */
this->FlWindow->shown() )
{
this->FlWindow->hide();
}
}
}
#if !defined(APPLE)
if (fl_display != NULL)
#endif /* APPLE */
{
Fl::check();
}
if (this->Capabilities != NULL)
{
delete [] this->Capabilities;
this->Capabilities = NULL;
}
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetFullScreen (int a)
{
vtkDebugMacro(<< "SetFullScreen(" << a << ") (subclass method)");
if (this->OffScreenRendering || (this->FullScreen == a))
{
return;
}
if (!this->GetMapped())
{
this->PrefFullScreen();
return;
}
// set the mode
if ((this->FullScreen = a) > 0)
{
// if window already up, get its values .
if (this->FlWindow != NULL)
{
this->OldScreen[0] = this->FlWindow->x();
this->OldScreen[1] = this->FlWindow->y();
this->OldScreen[2] = this->FlWindow->w();
this->OldScreen[3] = this->FlWindow->h();
this->OldScreen[4] = this->FlWindow->border();
this->PrefFullScreen();
}
}
else
{
this->Position[0] = this->OldScreen[0];
this->Position[1] = this->OldScreen[1];
this->Size[0] = this->OldScreen[2];
this->Size[1] = this->OldScreen[3];
this->Borders = this->OldScreen[4];
}
// remap the window
this->WindowRemap();
if (this->FlWindow != NULL)
{
// if full screen then grab the keyboard
if (this->FullScreen)
{
if (!this->FlWindow->take_focus())
{
vtkWarningMacro(<< "SetFullScreen(): "
<< "Failed to take focus before going to FullScreen!");
}
// Makes the window completely fill the screen, without any window
// manager border visible. You must use fullscreen_off() to undo this.
// This may not work with all window managers.
this->FlWindow->fullscreen();
}
else
{
// Turns off any side effects of fullscreen() and does resize(x,y,w,h).
this->FlWindow->fullscreen_off( this->OldScreen[0], this->OldScreen[1],
this->OldScreen[2], this->OldScreen[3] );
this->FlWindow->border(this->OldScreen[4]);
}
}
this->Modified();
}
void
vtkFLTKOpenGLRenderWindow::PrefFullScreen (void)
{
vtkDebugMacro(<< "PrefFullScreen()");
// use full screen
this->Position[0] = 0;
this->Position[1] = 0;
this->Size[0] = (this->OffScreenRendering ? 1280 : Fl::w());
this->Size[1] = (this->OffScreenRendering ? 1024 : Fl::h());
// don't show borders
this->Borders = 0;
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::WindowRemap (void)
{
vtkDebugMacro(<< "WindowRemap() (subclass method)");
// Shut everything down.
this->Finalize();
// Set everything up again.
this->Initialize();
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::Start (void)
{
vtkDebugMacro(<< "Start() (subclass method)");
// If the renderer has not been initialized, do so now.
if ( (this->FlWindow == NULL || this->FlWindow->context() == NULL)
#ifdef VTK_OPENGL_HAS_OSMESA
&& !this->Internal->OffScreenContextId
#endif /* VTK_OPENGL_HAS_OSMESA */
)
{
this->Initialize();
}
// Set the current window and bring it up to date.
this->MakeCurrent();
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetSize (int aWidth, int aHeight)
{
vtkDebugMacro(<< "SetSize(" << aWidth << "," << aHeight
<< ") (subclass method)");
// If not mapped or offscreen, then just the ivars are set.
if (this->Size[0] != aWidth || this->Size[1] != aHeight)
{
this->Size[0] = aWidth;
this->Size[1] = aHeight;
this->Modified();
}
if (this->OffScreenRendering
#ifdef VTK_OPENGL_HAS_OSMESA
&& this->Internal->OffScreenWindow != NULL
#endif /* VTK_OPENGL_HAS_OSMESA */
)
{
vtkRenderer* ren;
// Disconnect renderers from this render window.
vtkRendererCollection* renderers = this->Renderers;
renderers->Register(this);
this->Renderers->Delete();
this->Renderers = vtkRendererCollection::New();
for ( renderers->InitTraversal();
(ren = renderers->GetNextItem()) != NULL; )
{
ren->SetRenderWindow(NULL);
}
#ifdef VTK_OPENGL_HAS_OSMESA
OSMesaDestroyContext(this->Internal->OffScreenContextId);
this->Internal->OffScreenContextId = NULL;
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
this->Internal->OffScreenWindow = NULL;
#endif /* VTK_OPENGL_HAS_OSMESA */
this->WindowInitialize();
// Add the renders back into the render window.
for ( renderers->InitTraversal();
(ren = renderers->GetNextItem()) != NULL; )
{
this->AddRenderer(ren);
}
renderers->Delete();
}
else
{
if (this->FlWindow != NULL)
{
if ( this->Size[0] != this->FlWindow->w() ||
this->Size[1] != this->FlWindow->h() )
{
this->FlWindow->resize_( this->FlWindow->x(), this->FlWindow->y(),
this->Size[0], this->Size[1] );
if (this->FlWindow->shown()) Fl::flush();
this->Position[0] = this->FlWindow->x();
this->Position[1] = this->FlWindow->y();
}
}
}
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetMapped (int a)
{
vtkDebugMacro(<< "SetMapped(" << a << ") (subclass method)");
if (a != this->Mapped)
{
this->Mapped = a;
this->Modified();
}
if (this->FlWindow == NULL)
{
if (this->Mapped)
{
this->WindowRemap();
}
}
else
{
if (this->Mapped)
{
if (!this->FlWindow->shown())
{
this->WindowRemap();
}
}
else
{
if (this->FlWindow->shown())
{
this->FlWindow->hide();
}
}
}
}
int
vtkFLTKOpenGLRenderWindow::GetMapped (void)
{
if (this->FlWindow == NULL)
{
if (this->Mapped != 0)
{
this->Mapped = 0;
this->Modified();
}
}
else
{
if (this->Mapped != this->FlWindow->shown())
{
this->Mapped = this->FlWindow->shown();
this->Modified();
}
}
vtkDebugMacro(<< "GetMapped() returning " << this->Mapped << ".");
return this->Mapped;
}
// ----------------------------------------------------------------------------
int
vtkFLTKOpenGLRenderWindow::GetDesiredVisualMode (void)
{
int mode = Fl_VTK_Window::desired_mode( this->DoubleBuffer,
this->StereoCapableWindow,
this->MultiSamples );
if (mode != 0)
{
if (!Fl::gl_visual(mode) && this->Mode != 0)
{
mode = ( Fl::gl_visual(this->Mode)
? this->Mode
: FL_RGB|FL_DOUBLE|FL_DEPTH );
}
}
if (this->FlWindow != NULL && mode != 0)
{
this->FlWindow->mode(mode);
mode = this->FlWindow->mode();
}
this->Mode = mode;
vtkDebugMacro(<< "GetDesiredVisualMode(): returning ( "
<< ( (this->Mode & FL_INDEX) ? "FL_INDEX" :
( (this->Mode & FL_RGB8) ? "FL_RGB8" : "FL_RGB" ) )
<< ((this->Mode & FL_DOUBLE) ? " | FL_DOUBLE" : " | FL_SINGLE")
<< ((this->Mode & FL_ACCUM) ? " | FL_ACCUM" : "")
<< ((this->Mode & FL_ALPHA) ? " | FL_ALPHA" : "")
<< ((this->Mode & FL_DEPTH) ? " | FL_DEPTH" : "")
<< ((this->Mode & FL_STENCIL) ? " | FL_STENCIL" : "")
<< ((this->Mode & FL_MULTISAMPLE) ? " | FL_MULTISAMPLE" : "")
<< ((this->Mode & FL_STEREO) ? " | FL_STEREO" : "")
<< " )");
return this->Mode;
}
// ----------------------------------------------------------------------------
// the following can be useful for debugging XErrors
// When uncommented (along with the lines in MakeCurrent)
// it will cause a segfault upon an XError instead of
// the normal XError handler
#ifdef VTK_FLTK_OPENGL_RENDER_WINDOW_XERROR_DEBUG
extern "C"
{
int vtkXError (Display* vtkNotUsed(aDisplay), XErrorEvent* vtkNotUsed(aErr))
{
// cause a segfault
*(float *)(0x01) = 1.0;
return 1;
}
}
#endif /* VTK_FLTK_OPENGL_RENDER_WINDOW_XERROR_DEBUG */
void
vtkFLTKOpenGLRenderWindow::MakeCurrent (void)
{
// When debugging XErrors uncomment the following lines:
#if defined(VTK_FLTK_OPENGL_RENDERWINDOW_XERROR_DEBUG)&&!defined(APPLE)
if (fl_display != NULL)
{
XSynchronize(fl_display,1);
}
XSetErrorHandler(vtkXError);
#endif /* VTK_FLTK_OPENGL_RENDERWINDOW_XERROR_DEBUG */
#ifdef VTK_OPENGL_HAS_OSMESA
// set the current window
if (this->OffScreenRendering)
{
if (this->Internal->OffScreenContextId)
{
if (OSMesaMakeCurrent(this->Internal->OffScreenContextId,
this->Internal->OffScreenWindow, GL_UNSIGNED_BYTE,
this->Size[0], this->Size[1]) != GL_TRUE)
{
vtkWarningMacro("MakeCurrent(): Failed call to OSMesaMakeCurrent.");
}
}
}
else
#endif /* VTK_OPENGL_HAS_OSMESA */
{
if (this->GetMapped())
{
if ( this->ForceMakeCurrent ||
this->FlWindow->context() == NULL ||
this->FlWindow != Fl_Window::current() )
{
vtkDebugMacro(<< "MakeCurrent() (subclass method, "
<< (this->ForceMakeCurrent ? "is" : "not") << " forced, "
<< (this->FlWindow != Fl_Window::current() ?
"not" : "is") << " current, context: "
<< (void *) this->FlWindow->context() << ")");
this->FlWindow->make_current();
this->ForceMakeCurrent = 0;
}
}
}
}
void
vtkFLTKOpenGLRenderWindow::SetForceMakeCurrent (void)
{
vtkDebugMacro(<< "SetForceMakeCurrent() (subclass method)");
this->ForceMakeCurrent = 1;
}
// ----------------------------------------------------------------------------
void*
vtkFLTKOpenGLRenderWindow::GetGenericContext (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
void* ptr = NULL;
#if defined(MESA) && defined(VTK_OPENGL_HAS_OSMESA)
if (this->OffScreenRendering)
{
ptr = (void *) this->Internal->OffScreenContextId;
}
else
#endif /* MESA && VTK_OPENGL_HAS_OSMESA */
#if !defined(APPLE)
{
ptr = (void *) fl_gc;
}
#endif /* APPLE */
vtkDebugMacro(<< "GetGenericContext() returning " << ptr);
return ptr;
}
// ----------------------------------------------------------------------------
int
vtkFLTKOpenGLRenderWindow::GetEventPending (void)
{
#if defined(UNIX) && !defined(APPLE)
if ( (fl_xevent != NULL) &&
( fl_find( (reinterpret_cast<const XAnyEvent *>(fl_xevent))->
window ) == this->FlWindow ) &&
(fl_xevent->type == ButtonPress) )
{
vtkDebugMacro(<< "GetEventPending(): returning TRUE");
return 1;
}
vtkDebugMacro(<< "GetEventPending(): returning FALSE");
#else
vtkDebugMacro(<< "GetEventPending() not implemented");
#endif /* !UNIX */
return 0;
}
// ----------------------------------------------------------------------------
int*
vtkFLTKOpenGLRenderWindow::GetScreenSize (void)
{
this->ScreenSize[0] = Fl::w();
this->ScreenSize[1] = Fl::h();
vtkDebugMacro(<< "GetScreenSize(): returning ("
<< this->ScreenSize[0] << "," << this->ScreenSize[1] << ")");
return this->ScreenSize;
}
int*
vtkFLTKOpenGLRenderWindow::GetSize (void)
{
if (this->FlWindow != NULL)
{
// Find the current window size.
if ( (this->Size[0] != this->FlWindow->w()) ||
(this->Size[1] != this->FlWindow->h()) )
{
this->Size[0] = this->FlWindow->w();
this->Size[1] = this->FlWindow->h();
this->Modified();
}
}
// Now do the superclass stuff.
return this->Superclass::GetSize();
}
int*
vtkFLTKOpenGLRenderWindow::GetPosition (void)
{
if (this->FlWindow != NULL)
{
// Find the current window position.
if ( (this->Position[0] != this->FlWindow->x()) ||
(this->Position[1] != this->FlWindow->y()) )
{
this->Position[0] = this->FlWindow->x();
this->Position[1] = this->FlWindow->y();
this->Modified();
}
}
vtkDebugMacro(<< "GetPosition(): returning ("
<< this->Position[0] << ","
<< this->Position[1] << ")");
return this->Position;
}
// ----------------------------------------------------------------------------
Fl_Group*
vtkFLTKOpenGLRenderWindow::GetFlParent (void)
{
if (this->FlParent == NULL && this->FlWindow != NULL)
{
this->SetFlParent(this->FlWindow->parent());
}
vtkDebugMacro(<< "GetFlParent(): returning " << (void *) this->FlParent);
return this->FlParent;
}
Fl_VTK_Window*
vtkFLTKOpenGLRenderWindow::GetFlWindow (void)
{
vtkDebugMacro(<< "GetFlWindow(): returning " << (void *) this->FlWindow);
return this->FlWindow;
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetPosition (int aX, int aY)
{
vtkDebugMacro(<< "SetPosition(" << aX << "," << aY << ")");
// If not mapped, then just the ivars are set.
if (this->Position[0] != aX || this->Position[1] != aY)
{
this->Position[0] = aX;
this->Position[1] = aY;
this->Modified();
}
if (this->FlWindow != NULL)
{
if ( this->Position[0] != this->FlWindow->x() ||
this->Position[1] != this->FlWindow->y() )
{
this->FlWindow->resize_( this->Position[0], this->Position[0],
this->FlWindow->w(), this->FlWindow->h() );
if (this->FlWindow->shown()) Fl::check();
}
}
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetFlParent (Fl_Group* a)
{
if (this->FlParent != NULL)
{
vtkErrorMacro("FlParent is already set.");
return;
}
vtkDebugMacro(<< "SetFlParent(" << (void *) a << ")");
this->FlParent = a;
}
void
vtkFLTKOpenGLRenderWindow::SetFlWindow (Fl_VTK_Window* a)
{
vtkDebugMacro(<< "SetFlWindow(" << (void *) a << ")");
this->FlWindow = a;
if (this->CursorHidden)
{
this->CursorHidden = 0;
this->HideCursor();
}
}
void
vtkFLTKOpenGLRenderWindow::SetParentId (void* a)
{
#if !defined(APPLE)
vtkDebugMacro(<< "SetParentId(" << a << ")");
Fl_Window* window;
if ((window = fl_find(WindowIdType(a))) != NULL)
{
this->SetFlParent(static_cast<Fl_Group*>(window));
}
else
{
vtkWarningMacro(<< "SetParentId(): Fl_Window corresponding to window ID"
<< " ( " << a << " ) not found.");
}
#else
vtkDebugMacro(<< "SetParentId() not implemented.");
#endif
}
void
vtkFLTKOpenGLRenderWindow::SetWindowId (void* a)
{
#if !defined(APPLE)
vtkDebugMacro(<< "SetWindowId(" << a << ")");
Fl_Window* window;
if ((window = fl_find(WindowIdType(a))) != NULL)
{
if (window->type() == VTK_WINDOW_TYPE)
{
this->SetFlWindow(static_cast<Fl_VTK_Window*>(window));
}
else
{
vtkWarningMacro(<< "SetWindowId(): Fl_Window ( " << window
<< " ) corresponding to window ID"
<< " ( " << a << " ) is not a Fl_VTK_Window,");
}
}
else
{
vtkWarningMacro(<< "SetWindowId(): Fl_Window corresponding to window ID"
<< " ( " << a << " ) not found.");
}
#else
vtkDebugMacro(<< "SetWindowId() not implemented.");
#endif
}
void
vtkFLTKOpenGLRenderWindow::SetWindowInfo (char* aInfo)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
long tmp;
sscanf(aInfo, "%ld", &tmp);
this->SetWindowId((void *) tmp);
}
void
vtkFLTKOpenGLRenderWindow::SetParentInfo (char* a)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
long tmp;
sscanf(a, "%ld", &tmp);
this->SetParentId((void *) tmp);
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetNextWindowId (void* vtkNotUsed(a))
{
vtkWarningMacro("SetNextWindowId() not implemented.");
}
void
vtkFLTKOpenGLRenderWindow::SetNextWindowInfo (char* a)
{
long tmp;
sscanf(a, "%ld", &tmp);
this->SetNextWindowId((void *) tmp);
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetFlWindow (void* a)
{
this->SetFlWindow(reinterpret_cast<Fl_VTK_Window*>(a));
}
void
vtkFLTKOpenGLRenderWindow::SetFlParent (void* a)
{
this->SetFlParent(reinterpret_cast<Fl_Group*>(a));
}
//----------------------------------------------------------------------------
const char*
vtkFLTKOpenGLRenderWindow::ReportCapabilities (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
vtkDebugMacro(<< "ReportCapabilities() (subclass method)");
this->MakeCurrent();
ostrstream oss;
#if defined(WIN32)
#elif defined(APPLE)
#elif defined(UNIX)
const char* serverVendor =
glXQueryServerString(fl_display, fl_screen, GLX_VENDOR);
const char* serverVersion =
glXQueryServerString(fl_display, fl_screen, GLX_VERSION);
const char* serverExtensions =
glXQueryServerString(fl_display, fl_screen, GLX_EXTENSIONS);
const char* clientVendor =
glXGetClientString(fl_display, GLX_VENDOR);
const char* clientVersion =
glXGetClientString(fl_display, GLX_VERSION);
const char* clientExtensions =
glXGetClientString(fl_display, GLX_EXTENSIONS);
const char* glxExtensions =
glXQueryExtensionsString(fl_display, fl_screen);
if (serverVendor != NULL)
oss << "server glx vendor string: " << serverVendor << endl;
if (serverVersion != NULL)
oss << "server glx version string: " << serverVersion << endl;
if (serverExtensions != NULL)
oss << "server glx extensions: " << serverExtensions << endl;
if (clientVendor != NULL)
oss << "client glx vendor string: " << clientVendor << endl;
if (clientVersion != NULL)
oss << "client glx version string: " << clientVersion << endl;
if (clientExtensions != NULL)
oss << "client glx extensions: " << clientExtensions << endl;
if (glxExtensions != NULL)
oss << "glx extensions: " << glxExtensions << endl;
#endif
const char* glVendor =
reinterpret_cast<const char *>(glGetString(GL_VENDOR));
const char* glRenderer =
reinterpret_cast<const char *>(glGetString(GL_RENDERER));
const char* glVersion =
reinterpret_cast<const char *>(glGetString(GL_VERSION));
const char* glExtensions =
reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
if (glVendor != NULL)
oss << "OpenGL vendor string: " << glVendor << endl;
if (glRenderer != NULL)
oss << "OpenGL renderer string: " << glRenderer << endl;
if (glVersion != NULL)
oss << "OpenGL version string: " << glVersion << endl;
if (glExtensions != NULL)
oss << "OpenGL extensions: " << glExtensions << endl;
#if defined(UNIX) && !defined(APPLE)
oss << "X Extensions: ";
int n = 0;
char** extlist = XListExtensions(fl_display, &n);
for (int i=0; i<n; i++){
if (extlist[i] != NULL){
if (i != n-1)
oss << extlist[i] << ", ";
else
oss << extlist[i] << endl;
}
}
#endif
oss << ends;
if (this->Capabilities != NULL)
delete [] this->Capabilities;
this->Capabilities = strcpy(new char [strlen(oss.str())+1], oss.str());
return this->Capabilities;
}
int
vtkFLTKOpenGLRenderWindow::SupportsOpenGL (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
vtkDebugMacro(<< "SupportsOpenGL() (subclass method)");
this->MakeCurrent();
int value = 0;
if (this->GetDesiredVisualMode() != 0)
{
#if defined(WIN32)
int pixelFormat = GetPixelFormat(fl_gc);
PIXELFORMATDESCRIPTOR pfd;
DescribePixelFormat(fl_gc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR),&pfd);
value = (pfd.dwFlags & PFD_SUPPORT_OPENGL ? 1 : 0);
#elif defined(APPLE)
# if 0
GrafPtr port;
GDHandle device;
GetGWorld(&port, &device);
GLint attribs[] =
{AGL_ALL_RENDERERS, AGL_RGBA, AGL_DEPTH_SIZE,32, AGL_NONE};
AGLPixelFmtID pix = aglChoosePixelFmt(&device, 0, attribs);
aglGetConfig(pix, AGL_USE_GL, &value);
# endif /* 0 */
#elif defined(UNIX)
glXGetConfig(fl_display, fl_visual, GLX_USE_GL, &value);
#endif
}
vtkDebugMacro(<< "SupportsOpenGL(): returning " << value);
return value;
}
int
vtkFLTKOpenGLRenderWindow::IsDirect (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
vtkDebugMacro(<< "IsDirect() (subclass method)");
this->MakeCurrent();
if (this->FlWindow == NULL || this->FlWindow->context() == NULL)
{
return 0;
}
#if defined(WIN32)
int pixelFormat = GetPixelFormat(fl_gc);
PIXELFORMATDESCRIPTOR pfd;
DescribePixelFormat(fl_gc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
this->UsingHardware = (pfd.dwFlags & PFD_GENERIC_FORMAT ? 1 : 0);
#elif defined(APPLE)
# if 0
GrafPtr port;
GDHandle device;
GetGWorld(&port, &device);
GLint attribs[] =
{AGL_ALL_RENDERERS, AGL_RGBA, AGL_DEPTH_SIZE,32, AGL_FULLSCREEN, AGL_NONE};
AGLPixelFmtID pix = aglChoosePixelFmt(&device, 0, attribs);
this->UsingHardware = (pix ? 1 : 0);
# endif /* 0 */
#elif defined(UNIX)
this->UsingHardware =
(glXIsDirect(fl_display,GLXContext(this->FlWindow->context())) ?1:0);
#endif
vtkDebugMacro(<< "IsDirect(): returning " << this->UsingHardware);
return this->UsingHardware;
}
//----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetWindowName (const char* aName)
{
this->Superclass::SetWindowName(aName);
if (this->FlWindow != NULL)
{
this->FlWindow->label(this->WindowName);
}
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::CheckDisplayConnection (void)
{
#if !defined(APPLE)
if (fl_display == NULL)
#endif /* APPLE */
{
#if !defined(WIN32)
fl_open_display();
#endif /* WIN32 */
#if !defined(APPLE)
if (fl_display != NULL)
{
vtkDebugMacro(<< "Opened display " << (void *) fl_display);
}
else
{
vtkErrorMacro(<< "Bad Display connection.\n");
}
#endif /* APPLE */
}
}
void
vtkFLTKOpenGLRenderWindow::SetDisplayId (void* a)
{
#if !defined(APPLE)
if (fl_display == NULL)
#endif
{
#if defined(APPLE)
fl_open_display();
#elif !defined(WIN32)
fl_open_display(reinterpret_cast<Display*>(a));
#endif
#if !defined(APPLE)
if (fl_display != NULL)
{
vtkDebugMacro(<< "Opened display " << (void *) fl_display);
}
# if !defined(WIN32)
else
{
vtkErrorMacro(<< "Bad Display connection.\n");
}
# endif
#endif
}
#if !defined(APPLE)
else
{
vtkWarningMacro(<< "FLTK cannot change the Display ID"
<< " from an existing Display connection.\n");
}
#endif
}
void
vtkFLTKOpenGLRenderWindow::SetDisplayInfo (char* a)
{
#if !defined(APPLE)
if (fl_display == NULL)
#endif
{
Fl::display(static_cast<const char *>(a));
#if !defined(WIN32)
fl_open_display();
#endif
#if !defined(APPLE)
if (fl_display != NULL)
{
vtkDebugMacro(<< "Opened display " << (void *) fl_display);
}
# if !defined(WIN32)
else
{
vtkErrorMacro(<< "Bad Display connection.\n");
}
# endif
#endif
}
#if !defined(APPLE)
else
{
vtkWarningMacro(<< "FLTK cannot change the Display ID"
<< " from an existing Display connection.\n");
}
#endif
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::Render (void)
{
vtkDebugMacro(<< "Render() (subclass method)");
if (this->FlWindow != NULL)
{
// Find the current window position
this->Position[0] = this->FlWindow->x();
this->Position[1] = this->FlWindow->y();
// Find the current window size
this->Size[0] = this->FlWindow->w();
this->Size[1] = this->FlWindow->h();
}
// Now do the superclass stuff.
this->Superclass::Render();
}
void
vtkFLTKOpenGLRenderWindow::HideCursor (void)
{
vtkDebugMacro(<< "HideCursor()");
if (!this->CursorHidden && this->FlWindow != NULL)
{
this->FlWindow->cursor(FL_CURSOR_NONE);
}
this->CursorHidden = 1;
}
void
vtkFLTKOpenGLRenderWindow::ShowCursor (void)
{
vtkDebugMacro(<< "ShowCursor()");
if (this->CursorHidden && this->FlWindow != NULL)
{
this->FlWindow->cursor(FL_CURSOR_DEFAULT);
}
this->CursorHidden = 0;
}
//----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetOffScreenRendering (int aToggle)
{
vtkDebugMacro(<< "SetOffScreenRendering( " << aToggle << " )");
if (this->OffScreenRendering == aToggle)
{
return;
}
#ifdef VTK_OPENGL_HAS_OSMESA
// Invoke superclass method.
this->Superclass::SetOffScreenRendering(aToggle);
// setup everything
if (aToggle)
{
this->Internal->ScreenDoubleBuffer = this->DoubleBuffer;
this->DoubleBuffer = 0;
this->Internal->ScreenMapped = this->Mapped;
this->Mapped = 0;
if (this->Internal->OffScreenWindow == NULL)
{
this->WindowInitialize();
}
}
else
{
if (this->Internal->OffScreenWindow != NULL)
{
OSMesaDestroyContext(this->Internal->OffScreenContextId);
this->Internal->OffScreenContextId= NULL;
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
this->Internal->OffScreenWindow = NULL;
}
this->DoubleBuffer = this->Internal->ScreenDoubleBuffer;
this->Mapped = this->Internal->ScreenMapped;
this->MakeCurrent();
(void) this->GetSize(); // reset the size based on the screen window
this->WindowInitialize();
}
#endif /* VTK_OPENGL_HAS_OSMESA */
}
// ----------------------------------------------------------------------------
#if 0
void
vtkFLTKOpenGLRenderWindow::UnRegister (vtkObjectBase* o)
{
#if 1
if ( this->Interactor != NULL &&
this->Interactor->GetRenderWindow() == this &&
this->Interactor != o )
{
if (this->GetReferenceCount() + this->Interactor->GetReferenceCount() == 5)
{
this->SetFlWindow((Fl_VTK_Window *) NULL);
this->vtkObject::UnRegister(o);
vtkRenderWindowInteractor* tmp = this->Interactor;
tmp->Register(0);
this->Interactor->SetRenderWindow(NULL);
tmp->UnRegister(0);
return;
}
}
#endif
this->vtkObject::UnRegister(o);
}
#endif
// ----------------------------------------------------------------------------
void*
vtkFLTKOpenGLRenderWindow::GetGenericDisplayId (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
#if !defined(APPLE)
vtkDebugMacro(<< "GetGenericDisplayId(): returning "
<< (void *) fl_display);
return (void *) fl_display;
#else
vtkDebugMacro(<< "GetGenericDisplayId() not implemented");
return (void *) 0;
#endif /* APPLE */
}
void*
vtkFLTKOpenGLRenderWindow::GetGenericWindowId (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
void* ptr = NULL;
#ifdef VTK_OPENGL_HAS_OSMESA
if (this->OffScreenRendering)
{
ptr = (void *) this->Internal->OffScreenWindow;
}
else
#endif /* VTK_OPENGL_HAS_OSMESA */
{
if (this->GetMapped())
{
ptr = (void *) fl_xid(this->FlWindow);
}
}
vtkDebugMacro(<< "GetGenericWindowId(): returning " << ptr);
return ptr;
}
void*
vtkFLTKOpenGLRenderWindow::GetGenericParentId (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
void* ptr = NULL;
if ( this->GetFlParent() != NULL &&
this->FlParent->type() >= FL_WINDOW )
{
Fl_Window* parent = static_cast<Fl_Window*>(this->FlParent);
if (parent->shown())
{
ptr = (void *) fl_xid(parent);
}
}
else
{
vtkWarningMacro(<< "GetGenericParentId(): Parent ("
<< (void *) this->FlParent
<< ") is not a Fl_Window subclass.");
}
vtkDebugMacro(<< "GetGenericParentId(): returning " << ptr);
return ptr;
}
void*
vtkFLTKOpenGLRenderWindow::GetGenericDrawable (void)
{
// Ensure existence of the default display connection.
this->CheckDisplayConnection();
void* ptr = NULL;
if (this->GetMapped())
{
ptr = (void *) fl_xid(this->FlWindow);
}
vtkDebugMacro(<< "GetGenericDrawable(): returning " << ptr);
return ptr;
}
//----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::SetCurrentCursor (int aShape)
{
vtkDebugMacro(<< "SetCurrentCursor(" << aShape << ") (subclass method)");
if (this->InvokeEvent(vtkCommand::CursorChangedEvent, &aShape))
{
return;
}
this->Superclass::SetCurrentCursor(aShape);
if (this->FlWindow == NULL)
{
return;
}
//
// Under X you can get any XC_cursor value by passing:
// this->FlWindow->cursor(Fl_Cursor((XC_foo/2)+1));
//
switch (aShape)
{
case VTK_CURSOR_DEFAULT:
this->FlWindow->cursor(FL_CURSOR_DEFAULT);
break;
case VTK_CURSOR_ARROW:
this->FlWindow->cursor(FL_CURSOR_ARROW);
break;
case VTK_CURSOR_SIZEALL:
this->FlWindow->cursor(FL_CURSOR_MOVE);
break;
case VTK_CURSOR_SIZENS:
this->FlWindow->cursor(FL_CURSOR_NS);
break;
case VTK_CURSOR_SIZEWE:
this->FlWindow->cursor(FL_CURSOR_WE);
break;
case VTK_CURSOR_SIZENE:
this->FlWindow->cursor(FL_CURSOR_NESW);
break;
case VTK_CURSOR_SIZENW:
this->FlWindow->cursor(FL_CURSOR_NWSE);
break;
case VTK_CURSOR_SIZESE:
this->FlWindow->cursor(FL_CURSOR_NWSE);
break;
case VTK_CURSOR_SIZESW:
this->FlWindow->cursor(FL_CURSOR_NESW);
break;
} // switch (shape)
}
// ----------------------------------------------------------------------------
void
vtkFLTKOpenGLRenderWindow::PrintSelf (ostream& aTarget, vtkIndent aIndent)
{
this->Superclass::PrintSelf(aTarget,aIndent);
#ifdef VTK_OPENGL_HAS_OSMESA
aTarget << aIndent << "OffScreenContextId: "
<< this->Internal->OffScreenContextId << endl;
#endif /* VTK_OPENGL_HAS_OSMESA */
aTarget << aIndent << "FlParent: " << (void *) this->FlParent
<< endl;
aTarget << aIndent << "FlWindow: " << (void *) this->FlWindow
<< endl;
aTarget << aIndent << "Mode: ( "
<< ( (this->Mode & FL_INDEX) ? "FL_INDEX":
((this->Mode & FL_RGB8) ? "FL_RGB8" : "FL_RGB") )
<< ((this->Mode & FL_DOUBLE) ? " | FL_DOUBLE" : " | FL_SINGLE")
<< ((this->Mode & FL_ACCUM) ? " | FL_ACCUM" : "")
<< ((this->Mode & FL_ALPHA) ? " | FL_ALPHA" : "")
<< ((this->Mode & FL_DEPTH) ? " | FL_DEPTH" : "")
<< ((this->Mode & FL_STENCIL) ? " | FL_STENCIL" : "")
<< ((this->Mode & FL_MULTISAMPLE) ? " | FL_MULTISAMPLE" : "")
<< ((this->Mode & FL_STEREO) ? " | FL_STEREO" : "")
<< " )" << endl;
aTarget << aIndent << "OwnFlWindow: "
<< (this->OwnFlWindow ? "Yes" : "No") << endl;
aTarget << aIndent << "ScreenSize: ( " << this->ScreenSize[0]
<< ", " << this->ScreenSize[1] << " )" << endl;
aTarget << aIndent << "CursorHidden: "
<< (this->CursorHidden ? "Yes" : "No") << endl;
aTarget << aIndent << "ForceMakeCurrent: "
<< (this->ForceMakeCurrent ? "Yes" : "No") << endl;
aTarget << aIndent << "UsingHardware: "
<< (this->UsingHardware ? "Yes" : "No") << endl;
const char* p;
aTarget << aIndent << "Capabilities: \n\""
<< ((p = this->ReportCapabilities())!=0 ? p : "") << "\"" << endl;
}
/*
* End of: $Id: vtkFLTKOpenGLRenderWindow.cxx,v 1.44 2005/04/27 02:47:07 xpxqx Exp $.
*
*/
| 25.960807 | 85 | 0.581946 |
838d5e516f5c1b72570cf8634f230a938a2f0103 | 1,811 | cpp | C++ | src/editor/core/BFDataManager.cpp | RLefrancoise/BlackFox | 7814c58dca5c11cb9a80f42d4ed5f43ea7745875 | [
"MIT"
] | 3 | 2020-04-23T06:50:48.000Z | 2022-03-14T17:50:37.000Z | src/editor/core/BFDataManager.cpp | RLefrancoise/BlackFox | 7814c58dca5c11cb9a80f42d4ed5f43ea7745875 | [
"MIT"
] | 1 | 2019-11-29T14:21:11.000Z | 2019-11-29T19:35:53.000Z | src/editor/core/BFDataManager.cpp | RLefrancoise/BlackFox | 7814c58dca5c11cb9a80f42d4ed5f43ea7745875 | [
"MIT"
] | null | null | null | #include "BFDataManager.h"
#include <utility>
namespace BlackFox::Editor
{
BFDataManager::BFDataManager(IBFResourcesHolder::Ptr resourcesHolder)
: m_resourcesHolder(std::move(resourcesHolder))
{
}
BFDataManager::BFDataManager(BFDataManager&& dataManager) noexcept
: m_resourcesHolder(std::move(dataManager.m_resourcesHolder))
, m_projectData(std::move(dataManager.m_projectData))
, m_editorData(std::move(dataManager.m_editorData))
{
}
BFDataManager& BFDataManager::operator=(BFDataManager&& dataManager) noexcept
{
m_resourcesHolder = std::move(dataManager.m_resourcesHolder);
m_projectData = std::move(dataManager.m_projectData);
m_editorData = std::move(dataManager.m_editorData);
return *this;
}
bool BFDataManager::hasActiveProject() const
{
return m_projectData.get() != nullptr;
}
BFProjectData::Ptr BFDataManager::getActiveProject() const
{
return m_projectData;
}
void BFDataManager::setActiveProject(BFProjectData::Ptr projectData)
{
m_projectData = std::move(projectData);
BF_PRINT(*m_projectData);
publish<BFProjectChangedEvent>(m_projectData);
}
void BFDataManager::closeActiveProject()
{
const std::shared_ptr<BFProjectData> emptyData;
m_projectData = emptyData;
BF_PRINT("Closed project");
publish<BFProjectClosedEvent>();
}
bool BFDataManager::hasEditorData() const
{
return m_editorData.get() != nullptr;
}
BFEditorData::Ptr BFDataManager::getEditorData() const
{
return m_editorData;
}
void BFDataManager::setEditorData(BFEditorData::Ptr editorData)
{
m_editorData = std::move(editorData);
BF_PRINT(*m_editorData);
}
TextureHandle BFDataManager::getTextureResource(const entt::hashed_string& resource) const
{
return m_resourcesHolder->loadTexture(m_editorData->config.resourcesPath / resource.data());
}
}
| 24.808219 | 94 | 0.767532 |
838e8dec8f1d5233f656f598d5b753e55ab36237 | 2,757 | cpp | C++ | src/interpreter/ReplyTemplateInterpreter.cpp | open-intent-io/open-intent | 57d8c4fc89c038f51138d51e776880e728152194 | [
"MIT"
] | 47 | 2016-07-05T15:20:33.000Z | 2021-08-06T05:38:33.000Z | src/interpreter/ReplyTemplateInterpreter.cpp | open-intent-io/open-intent | 57d8c4fc89c038f51138d51e776880e728152194 | [
"MIT"
] | 30 | 2016-07-03T22:42:11.000Z | 2017-11-17T15:58:10.000Z | src/interpreter/ReplyTemplateInterpreter.cpp | open-intent-io/open-intent | 57d8c4fc89c038f51138d51e776880e728152194 | [
"MIT"
] | 8 | 2016-07-22T20:07:58.000Z | 2017-11-05T10:40:29.000Z | /*
|---------------------------------------------------------|
| ___ ___ _ _ |
| / _ \ _ __ ___ _ __ |_ _|_ __ | |_ ___ _ __ | |_ |
| | | | | '_ \ / _ \ '_ \ | || '_ \| __/ _ \ '_ \| __| |
| | |_| | |_) | __/ | | || || | | | || __/ | | | |_ |
| \___/| .__/ \___|_| |_|___|_| |_|\__\___|_| |_|\__| |
| |_| |
| |
| - The users first... |
| |
| Authors: |
| - Clement Michaud |
| - Sergei Kireev |
| |
| Version: 1.0.0 |
| |
|---------------------------------------------------------|
The MIT License (MIT)
Copyright (c) 2016 - Clement Michaud, Sergei Kireev
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 "intent/interpreter/ReplyTemplateInterpreter.hpp"
#include "intent/interpreter/Interpreter.hpp"
namespace intent {
const std::string ReplyTemplateInterpreter::ARG_MARKER("_");
void ReplyTemplateInterpreter::adapt(std::string& replyTemplate) {
int counter = 0;
for (size_t i = 0; i < replyTemplate.size(); ++i) {
std::string templateArgMarker = "${" + std::to_string(counter) + "}";
if (replyTemplate.substr(i, ARG_MARKER.size()) == ARG_MARKER) {
replyTemplate.replace(i, ARG_MARKER.size(), templateArgMarker);
++counter;
i += templateArgMarker.size() - ARG_MARKER.size() - 1;
}
}
}
}
| 45.95 | 79 | 0.524846 |
83923ef0a3b9ba4cb4d8c79dd2262b28ca8427e8 | 287 | cpp | C++ | 01-basic/G-compile-flags/main.cpp | LexcaliburR/cmake_examples | 804e7d19f6070bc757ce4329f50903ffd07cc502 | [
"MIT"
] | 1 | 2021-11-23T11:41:20.000Z | 2021-11-23T11:41:20.000Z | 01-basic/G-compile-flags/main.cpp | LexcaliburR/cmake_examples | 804e7d19f6070bc757ce4329f50903ffd07cc502 | [
"MIT"
] | null | null | null | 01-basic/G-compile-flags/main.cpp | LexcaliburR/cmake_examples | 804e7d19f6070bc757ce4329f50903ffd07cc502 | [
"MIT"
] | null | null | null | #include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello World Cmake Flag" << std::endl;
#ifdef EX2
std::cout << "define flags EX2 succeed! " << std::endl;
#endif
#ifdef EX3
std::cout << "define flags EX3 succeed! " << std::endl;
#endif
return 0;
} | 16.882353 | 59 | 0.602787 |
8b52c4f1949b2dd7ff759d0181339ab34a39ea60 | 3,514 | cpp | C++ | LabB/RensselaerArduinoSupportPackageLibrary/RASPlib/src/HCSR04wrapper.cpp | zachtyll/R7003E | f31f314e52b805cb0fa9a65fdc1ceb7548fc2ce8 | [
"MIT"
] | null | null | null | LabB/RensselaerArduinoSupportPackageLibrary/RASPlib/src/HCSR04wrapper.cpp | zachtyll/R7003E | f31f314e52b805cb0fa9a65fdc1ceb7548fc2ce8 | [
"MIT"
] | null | null | null | LabB/RensselaerArduinoSupportPackageLibrary/RASPlib/src/HCSR04wrapper.cpp | zachtyll/R7003E | f31f314e52b805cb0fa9a65fdc1ceb7548fc2ce8 | [
"MIT"
] | null | null | null | // HCSR04wrapper.cpp
#include "NewPing.h"
// setup for max of 3 sonar readings:
NewPing sonar1(0,0,0); // NewPing setup of pins and maximum distance.
NewPing sonar2(0,0,0); // NewPing setup of pins and maximum distance.
NewPing sonar3(0,0,0); // NewPing setup of pins and maximum distance.
extern "C" void HCSR04Sonar_Init(int trigger_pin, int echo_pin, int Sonar )
{
//uint8_t trigger_pin=7;
//uint8_t echo_pin=8;
int max_cm_distance=200;
switch (Sonar){
case 1:
sonar1._triggerBit = digitalPinToBitMask(trigger_pin); // Get the port register bitmask for the trigger pin.
sonar1._echoBit = digitalPinToBitMask(echo_pin); // Get the port register bitmask for the echo pin.
sonar1._triggerOutput = portOutputRegister(digitalPinToPort(trigger_pin)); // Get the output port register for the trigger pin.
sonar1._echoInput = portInputRegister(digitalPinToPort(echo_pin)); // Get the input port register for the echo pin.
sonar1._triggerMode = (uint8_t *) portModeRegister(digitalPinToPort(trigger_pin)); // Get the port mode register for the trigger pin.
sonar1._maxEchoTime = min(max_cm_distance, MAX_SENSOR_DISTANCE) * US_ROUNDTRIP_CM + (US_ROUNDTRIP_CM / 2); // Calculate the maximum distance in uS.
break;
case 2:
sonar2._triggerBit = digitalPinToBitMask(trigger_pin); // Get the port register bitmask for the trigger pin.
sonar2._echoBit = digitalPinToBitMask(echo_pin); // Get the port register bitmask for the echo pin.
sonar2._triggerOutput = portOutputRegister(digitalPinToPort(trigger_pin)); // Get the output port register for the trigger pin.
sonar2._echoInput = portInputRegister(digitalPinToPort(echo_pin)); // Get the input port register for the echo pin.
sonar2._triggerMode = (uint8_t *) portModeRegister(digitalPinToPort(trigger_pin)); // Get the port mode register for the trigger pin.
sonar2._maxEchoTime = min(max_cm_distance, MAX_SENSOR_DISTANCE) * US_ROUNDTRIP_CM + (US_ROUNDTRIP_CM / 2); // Calculate the maximum distance in uS.
break;
case 3:
sonar3._triggerBit = digitalPinToBitMask(trigger_pin); // Get the port register bitmask for the trigger pin.
sonar3._echoBit = digitalPinToBitMask(echo_pin); // Get the port register bitmask for the echo pin.
sonar3._triggerOutput = portOutputRegister(digitalPinToPort(trigger_pin)); // Get the output port register for the trigger pin.
sonar3._echoInput = portInputRegister(digitalPinToPort(echo_pin)); // Get the input port register for the echo pin.
sonar3._triggerMode = (uint8_t *) portModeRegister(digitalPinToPort(trigger_pin)); // Get the port mode register for the trigger pin.
sonar3._maxEchoTime = min(max_cm_distance, MAX_SENSOR_DISTANCE) * US_ROUNDTRIP_CM + (US_ROUNDTRIP_CM / 2); // Calculate the maximum distance in uS.
break;
}
#if DISABLE_ONE_PIN == true
*_triggerMode |= _triggerBit; // Set trigger pin to output.
#endif
}
extern "C" int HCSR04Sonar_Read(int Sonar)
{
switch (Sonar){
case 1:
return sonar1.ping_cm();// US_ROUNDTRIP_CM;
break;
case 2:
return sonar2.ping_cm();// US_ROUNDTRIP_CM;
break;
case 3:
return sonar3.ping_cm();// US_ROUNDTRIP_CM;
break;
}
}
| 54.90625 | 159 | 0.67786 |
8b55e101684c32b0bb4881f21702911da48a3b45 | 574 | cpp | C++ | PAT/A1067.cpp | iphelf/Programming-Practice | 2a95bb7153957b035427046b250bf7ffc6b00906 | [
"WTFPL"
] | null | null | null | PAT/A1067.cpp | iphelf/Programming-Practice | 2a95bb7153957b035427046b250bf7ffc6b00906 | [
"WTFPL"
] | null | null | null | PAT/A1067.cpp | iphelf/Programming-Practice | 2a95bb7153957b035427046b250bf7ffc6b00906 | [
"WTFPL"
] | null | null | null | #include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1e5;
int N,a[MAXN];
int main(void) {
// freopen("in.txt","r",stdin);
scanf("%d",&N);
for(int i=0; i<N; i++)
scanf("%d",&a[i]);
int cnt=0;
for(int i=0; i<N; i++) {
if(a[i]==i) continue;
if(i>0) {
swap(a[0],a[i]);
cnt++;
}
while(a[0]!=0) {
swap(a[0],a[a[0]]);
cnt++;
}
}
printf("%d\n",cnt);
return 0;
}
/*
10
3 5 7 2 6 4 9 0 8 1
9
*/
| 15.513514 | 35 | 0.38676 |
8b57247b3d5ba35d83fb2aeedeab57aa499de0af | 2,318 | cpp | C++ | src/main/cpp/base/HostInfo.cpp | lizhanhui/rocketmq-client-cpp | d2001836e40d4f1da29ae7b2848fdfe0077ed1bf | [
"Apache-2.0"
] | null | null | null | src/main/cpp/base/HostInfo.cpp | lizhanhui/rocketmq-client-cpp | d2001836e40d4f1da29ae7b2848fdfe0077ed1bf | [
"Apache-2.0"
] | null | null | null | src/main/cpp/base/HostInfo.cpp | lizhanhui/rocketmq-client-cpp | d2001836e40d4f1da29ae7b2848fdfe0077ed1bf | [
"Apache-2.0"
] | 1 | 2021-09-16T06:31:07.000Z | 2021-09-16T06:31:07.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "HostInfo.h"
#include "absl/strings/match.h"
#include "rocketmq/RocketMQ.h"
#include <cstdlib>
#include <cstring>
ROCKETMQ_NAMESPACE_BEGIN
const char* HostInfo::ENV_LABEL_SITE = "SIGMA_APP_SITE";
const char* HostInfo::ENV_LABEL_UNIT = "SIGMA_APP_UNIT";
const char* HostInfo::ENV_LABEL_APP = "SIGMA_APP_NAME";
const char* HostInfo::ENV_LABEL_STAGE = "SIGMA_APP_STAGE";
HostInfo::HostInfo() {
getEnv(ENV_LABEL_SITE, site_);
getEnv(ENV_LABEL_UNIT, unit_);
getEnv(ENV_LABEL_APP, app_);
getEnv(ENV_LABEL_STAGE, stage_);
}
void HostInfo::getEnv(const char* env, std::string& holder) {
if (!strlen(env)) {
return;
}
char* value = getenv(env);
if (nullptr != value) {
holder.clear();
holder.append(value);
}
}
bool HostInfo::hasHostInfo() const {
return !unit_.empty() && !stage_.empty();
}
std::string HostInfo::queryString() const {
if (!hasHostInfo()) {
return std::string();
}
std::string query_string("labels=");
appendLabel(query_string, "site", site_);
appendLabel(query_string, "unit", unit_);
appendLabel(query_string, "app", app_);
appendLabel(query_string, "stage", stage_);
return query_string;
}
void HostInfo::appendLabel(std::string& query_string, const char* key, const std::string& value) {
if (value.empty()) {
return;
}
if (absl::EndsWith(query_string, "=")) {
query_string.append(key).append(":").append(value);
} else {
query_string.append(",").append(key).append(":").append(value);
}
}
ROCKETMQ_NAMESPACE_END | 30.103896 | 98 | 0.715272 |
8b583dfd582163e186490f7b4bedb6e34a10d010 | 1,935 | cc | C++ | android_webview/native/intercepted_request_data_impl.cc | iplo/Chain | 8bc8943d66285d5258fffc41bed7c840516c4422 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 231 | 2015-01-08T09:04:44.000Z | 2021-12-30T03:03:10.000Z | android_webview/native/intercepted_request_data_impl.cc | j4ckfrost/android_external_chromium_org | a1a3dad8b08d1fcf6b6b36c267158ed63217c780 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2017-02-14T21:55:58.000Z | 2017-02-14T21:55:58.000Z | android_webview/native/intercepted_request_data_impl.cc | j4ckfrost/android_external_chromium_org | a1a3dad8b08d1fcf6b6b36c267158ed63217c780 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 268 | 2015-01-21T05:53:28.000Z | 2022-03-25T22:09:01.000Z | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "android_webview/native/intercepted_request_data_impl.h"
#include "android_webview/native/input_stream_impl.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "jni/InterceptedRequestData_jni.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
using base::android::ScopedJavaLocalRef;
namespace android_webview {
InterceptedRequestDataImpl::InterceptedRequestDataImpl(
const base::android::JavaRef<jobject>& obj)
: java_object_(obj) {
}
InterceptedRequestDataImpl::~InterceptedRequestDataImpl() {
}
scoped_ptr<InputStream>
InterceptedRequestDataImpl::GetInputStream(JNIEnv* env) const {
ScopedJavaLocalRef<jobject> jstream =
Java_InterceptedRequestData_getData(env, java_object_.obj());
if (jstream.is_null())
return scoped_ptr<InputStream>();
return make_scoped_ptr<InputStream>(new InputStreamImpl(jstream));
}
bool InterceptedRequestDataImpl::GetMimeType(JNIEnv* env,
std::string* mime_type) const {
ScopedJavaLocalRef<jstring> jstring_mime_type =
Java_InterceptedRequestData_getMimeType(env, java_object_.obj());
if (jstring_mime_type.is_null())
return false;
*mime_type = ConvertJavaStringToUTF8(jstring_mime_type);
return true;
}
bool InterceptedRequestDataImpl::GetCharset(
JNIEnv* env, std::string* charset) const {
ScopedJavaLocalRef<jstring> jstring_charset =
Java_InterceptedRequestData_getCharset(env, java_object_.obj());
if (jstring_charset.is_null())
return false;
*charset = ConvertJavaStringToUTF8(jstring_charset);
return true;
}
bool RegisterInterceptedRequestData(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace android_webview
| 32.25 | 76 | 0.767442 |
8b5d56fa1d1ffb753838142c830fcee19891e72b | 6,209 | cpp | C++ | EScript/Objects/Type.cpp | antifermion/EScript | eca6765c28e319eb77b4da81125bdbb2510c9add | [
"MIT"
] | 3 | 2017-06-01T15:58:43.000Z | 2019-08-07T05:36:44.000Z | EScript/Objects/Type.cpp | antifermion/EScript | eca6765c28e319eb77b4da81125bdbb2510c9add | [
"MIT"
] | 4 | 2015-01-23T18:17:50.000Z | 2019-02-10T11:48:55.000Z | EScript/Objects/Type.cpp | antifermion/EScript | eca6765c28e319eb77b4da81125bdbb2510c9add | [
"MIT"
] | 12 | 2015-01-04T16:07:45.000Z | 2020-10-06T15:42:46.000Z | // Type.cpp
// This file is part of the EScript programming language (https://github.com/EScript)
//
// Copyright (C) 2011-2013 Claudius Jähn <ClaudiusJ@live.de>
// Copyright (C) 2012 Benjamin Eikel <benjamin@eikel.org>
//
// Licensed under the MIT License. See LICENSE file for details.
// ---------------------------------------------------------------------------------
#include "Type.h"
#include "../Basics.h"
#include "../StdObjects.h"
#include "Exception.h"
namespace EScript{
//! (static)
Type * Type::getTypeObject(){
struct factory{ // use factory for static one time initialization
Type * operator()(){
// This object defines the type of all 'Type' objects.
// It inherits from Object and the type of the object is defined by itthisObj.
Type * typeObject = new Type(Object::getTypeObject(),nullptr);
typeObject->typeRef = typeObject;
return typeObject;
}
};
static Type * typeObject = factory()();
return typeObject;
}
//! initMembers
void Type::init(EScript::Namespace & globals) {
// [Type] ---|> [Object]
Type * typeObject = getTypeObject();
initPrintableName(typeObject,getClassName());
declareConstant(&globals,getClassName(),typeObject);
//! [ESMF] Type new Type( [BaseType = ExtObject] )
ES_CONSTRUCTOR(typeObject,0,1,{
Type * baseType = parameter.count() == 0 ? ExtObject::getTypeObject() : assertType<Type>(rt,parameter[0]);
if(!baseType->allowsUserInheritance()){
rt.setException("Basetype '"+baseType->toString()+"' does not allow user inheritance.");
return nullptr;
}
Type * newType = new Type(baseType);
newType->allowUserInheritance(true); // user defined Types allow user inheritance per default.
return newType;
})
//! [ESMF] Type Type.getBaseType()
ES_MFUN(typeObject,const Type,"getBaseType",0,0, thisObj->getBaseType())
// attrMap_t is declared outside of the getObjAttributes declaration as it otherwise leads to a strange
// preprocessor error on gcc.
typedef std::unordered_map<StringId, Object *> attrMap_t;
//! [ESMF] Map Type.getObjAttributes()
ES_MFUNCTION(typeObject,const Type,"getObjAttributes",0,0,{
attrMap_t attrs;
thisObj->collectObjAttributes(attrs);
return Map::create(attrs);
})
//! [ESMF] Map Type.getTypeAttributes()
ES_MFUNCTION(typeObject,const Type,"getTypeAttributes",0,0,{
attrMap_t attrs;
thisObj->collectTypeAttributes(attrs);
return Map::create(attrs);
})
//! [ESMF] Type Type.hasBase(Type)
ES_MFUN(typeObject,const Type,"hasBase",1,1, thisObj->hasBase(parameter[0].to<Type*>(rt)))
//! [ESMF] Type Type.isBaseOf(Type)
ES_MFUN(typeObject,const Type,"isBaseOf",1,1, thisObj->isBaseOf(parameter[0].to<Type*>(rt)))
}
//---
//! (ctor)
Type::Type():
Object(Type::getTypeObject()),flags(0),baseType(Object::getTypeObject()) {
//ctor
}
//! (ctor)
Type::Type(Type * _baseType):
Object(Type::getTypeObject()),flags(0),baseType(_baseType) {
if(getBaseType()!=nullptr)
getBaseType()->copyObjAttributesTo(this);
//ctor
}
//! (ctor)
Type::Type(Type * _baseType,Type * typeOfType):
Object(typeOfType),flags(0),baseType(_baseType) {
if(getBaseType()!=nullptr)
getBaseType()->copyObjAttributesTo(this);
//ctor
}
//! (dtor)
Type::~Type() {
//dtor
}
//! ---|> [Object]
Object * Type::clone() const{
return new Type(getBaseType(),getType());
}
static const char * typeAttrErrorHint =
"This may be a result of: Adding object attributes to a Type AFTER inheriting from that Type, "
"adding object attributes to a Type AFTER creating instances of that Type, "
"or adding object attributes to a Type whose instances cannot store object attributes. ";
Attribute * Type::findTypeAttribute(const StringId & id){
Type * t = this;
do{
Attribute * attr = t->attributes.accessAttribute(id);
if( attr != nullptr ){
if( attr->isObjAttribute() ){
std::string message = "(findTypeAttribute) type-attribute expected but object-attribute found. ('";
message += id.toString() + "')\n" + typeAttrErrorHint;
throw new Exception(message);
}
return attr;
}
t = t->getBaseType();
}while(t!=nullptr);
return nullptr;
}
//! ---|> Object
Attribute * Type::_accessAttribute(const StringId & id,bool localOnly){
// is local attribute?
Attribute * attr = attributes.accessAttribute(id);
if(attr!=nullptr || localOnly)
return attr;
// try to find the attribute along the inherited path...
if(getBaseType()!=nullptr){
attr = getBaseType()->findTypeAttribute(id);
if(attr!=nullptr)
return attr;
}
// try to find the attribute from this type's type.
return getType()!=nullptr ? getType()->findTypeAttribute(id) : nullptr;
}
//! ---|> Object
bool Type::setAttribute(const StringId & id,const Attribute & attr){
attributes.setAttribute(id,attr);
if(attr.isObjAttribute())
setFlag(FLAG_CONTAINS_OBJ_ATTRS,true);
return true;
}
void Type::copyObjAttributesTo(Object * instance){
// init member vars of type
if(getFlag(FLAG_CONTAINS_OBJ_ATTRS)){
for(const auto & keyValuePair : attributes) {
const Attribute & a = keyValuePair.second;
if( a.isNull() || a.isTypeAttribute() )
continue;
instance->setAttribute(keyValuePair.first, Attribute(a.getValue()->getRefOrCopy(),a.getProperties()));
}
}
}
void Type::collectTypeAttributes(std::unordered_map<StringId,Object *> & attrs)const{
for(const auto & keyValuePair : attributes) {
if(keyValuePair.second.isTypeAttribute()) {
attrs[keyValuePair.first] = keyValuePair.second.getValue();
}
}
}
void Type::collectObjAttributes(std::unordered_map<StringId,Object *> & attrs)const{
for(const auto & keyValuePair : attributes) {
if(keyValuePair.second.isObjAttribute()) {
attrs[keyValuePair.first] = keyValuePair.second.getValue();
}
}
}
//! ---|> Object
void Type::collectLocalAttributes(std::unordered_map<StringId,Object *> & attrs){
for(const auto & keyValuePair : attributes) {
attrs[keyValuePair.first] = keyValuePair.second.getValue();
}
}
bool Type::hasBase(const Type * type) const {
for(const Type * t = this; t; t = t->getBaseType()){
if(t==type)
return true;
}
return false;
}
bool Type::isBaseOf(const Type * type) const {
while(type){
if(type==this)
return true;
type = type->getBaseType();
}
return false;
}
}
| 27.968468 | 108 | 0.692543 |
8b612dd0b54e11f296b684877d4b2728f2c7298e | 1,081 | cpp | C++ | geotrans3.7/CCS/src/dtcc/CoordinateSystemParameters/CoordinateSystemParameters.cpp | mjj203/tippecanoe | 140ae1da6438a23d82f41e9c7b7b129107bf6e2d | [
"BSD-2-Clause"
] | 1 | 2021-07-05T07:40:49.000Z | 2021-07-05T07:40:49.000Z | geotrans3.7/CCS/src/dtcc/CoordinateSystemParameters/CoordinateSystemParameters.cpp | mjj203/tippecanoe | 140ae1da6438a23d82f41e9c7b7b129107bf6e2d | [
"BSD-2-Clause"
] | 1 | 2015-01-13T10:08:35.000Z | 2015-01-13T10:08:35.000Z | geotrans3.7/CCS/src/dtcc/CoordinateSystemParameters/CoordinateSystemParameters.cpp | mjj203/tippecanoe | 140ae1da6438a23d82f41e9c7b7b129107bf6e2d | [
"BSD-2-Clause"
] | 2 | 2017-07-24T13:34:49.000Z | 2017-11-14T16:52:38.000Z | // CLASSIFICATION: UNCLASSIFIED
#include "CoordinateSystemParameters.h"
#include "CoordinateType.h"
using namespace MSP::CCS;
CoordinateSystemParameters::CoordinateSystemParameters() :
_coordinateType( CoordinateType::geodetic )
{
}
CoordinateSystemParameters::CoordinateSystemParameters( MSP::CCS::CoordinateType::Enum __coordinateType ) :
_coordinateType( __coordinateType )
{
}
CoordinateSystemParameters::CoordinateSystemParameters( const CoordinateSystemParameters &csp )
{
_coordinateType = csp._coordinateType;
}
CoordinateSystemParameters::~CoordinateSystemParameters()
{
}
CoordinateSystemParameters& CoordinateSystemParameters::operator=( const CoordinateSystemParameters &csp )
{
if( this != &csp )
{
_coordinateType = csp._coordinateType;
}
return *this;
}
void CoordinateSystemParameters::setCoordinateType( MSP::CCS::CoordinateType::Enum __coordinateType )
{
_coordinateType = __coordinateType;
}
CoordinateType::Enum CoordinateSystemParameters::coordinateType() const
{
return _coordinateType;
}
// CLASSIFICATION: UNCLASSIFIED
| 19.654545 | 107 | 0.794635 |
8b61628ab559bc8a80489b06dfbb9f4bebd11da6 | 65 | cpp | C++ | shared/src/shared/state/player_input.cpp | dumheter/wind_simulation | adf731847cb6145a85792a0ebceacc725a3acf9e | [
"MIT"
] | 1 | 2021-04-26T11:24:02.000Z | 2021-04-26T11:24:02.000Z | shared/src/shared/state/player_input.cpp | dumheter/wind_simulation | adf731847cb6145a85792a0ebceacc725a3acf9e | [
"MIT"
] | 1 | 2020-06-09T08:53:07.000Z | 2020-06-16T13:37:15.000Z | shared/src/shared/state/player_input.cpp | dumheter/wind_simulation | adf731847cb6145a85792a0ebceacc725a3acf9e | [
"MIT"
] | null | null | null | #include "player_input.hpp"
namespace wind {} // namespace wind
| 16.25 | 35 | 0.738462 |
8b62211d5d084f24cfc854b4e2fb56e49c8acf61 | 282 | cpp | C++ | src/c++ primer 5th/ch13-content/ch_13.6.3_cont_test.cpp | aparesse/Eudemonia | cb2d9cde5e9ab60a8f62747a9c48d7a44eabe8d1 | [
"MIT"
] | null | null | null | src/c++ primer 5th/ch13-content/ch_13.6.3_cont_test.cpp | aparesse/Eudemonia | cb2d9cde5e9ab60a8f62747a9c48d7a44eabe8d1 | [
"MIT"
] | null | null | null | src/c++ primer 5th/ch13-content/ch_13.6.3_cont_test.cpp | aparesse/Eudemonia | cb2d9cde5e9ab60a8f62747a9c48d7a44eabe8d1 | [
"MIT"
] | null | null | null | #include "ch_13.6.3_cont.h"
#include <string>
using std::string;
int main()
{
StrVec vec; //空StrVec
string s = "some string or another";
vec.push_back(s); //调用push_back(const string&)
vec.push_back("done"); //调用push_back(string&&) 字面值是右值,此处是(从"done"创建的临时string)
return 0;
}
| 18.8 | 78 | 0.695035 |
8b64f8b5c10ae0516dfa29dcad7ddd7f38a5510e | 3,225 | cxx | C++ | src/main.cxx | nshcat/fractal | 6be4c9684c25520b231375006a51428e37cf56bc | [
"MIT"
] | null | null | null | src/main.cxx | nshcat/fractal | 6be4c9684c25520b231375006a51428e37cf56bc | [
"MIT"
] | null | null | null | src/main.cxx | nshcat/fractal | 6be4c9684c25520b231375006a51428e37cf56bc | [
"MIT"
] | null | null | null | #include <cl.hxx>
#include <log.hxx>
#include <ut/integral.hxx>
#include <application.hxx>
using namespace ut::literals;
fractal::configuration g_config{ };
lg::severity_level g_logLevel{ };
bool g_verbose{ };
cl::handler g_handler{
cl::application_name("fractal"),
cl::help_argument{ },
cl::integer_argument<unsigned>{
cl::long_name("width"),
cl::short_name('W'),
cl::description("Sets the width of the main window"),
cl::category("Graphics"),
cl::reference(g_config.m_WindowSize.x)
},
cl::integer_argument<unsigned>{
cl::long_name("height"),
cl::short_name('H'),
cl::description("Sets the height of the main window"),
cl::category("Graphics"),
cl::reference(g_config.m_WindowSize.y)
},
cl::integer_argument<::std::size_t>{
cl::long_name("thread-count"),
cl::short_name('t'),
cl::description("Sets the number of threads used by the rendering thread pool"),
cl::reference(g_config.m_ThreadCount),
cl::min(1_sz),
cl::max(32_sz)
},
cl::integer_argument<::std::size_t>{
cl::long_name("iterations"),
cl::short_name('i'),
cl::description("Sets the number of iterations spent analyzing each pixel"),
cl::category("Graphics"),
cl::reference(g_config.m_Iterations),
cl::min(8_sz),
cl::max(20000_sz)
},
cl::integer_argument<::std::size_t>{
cl::long_name("divisions"),
cl::short_name('d'),
cl::description("Sets how many times the image is divided into subimage for multithreading"),
cl::reference(g_config.m_Divisions)
},
cl::enum_argument<lg::severity_level>{
cl::long_name("verbosity"),
cl::category("Logger"),
cl::short_name('V'),
cl::description("Sets the threshold for log messages to be shown"),
cl::default_value(lg::severity_level::info),
cl::ignore_case,
cl::reference(g_logLevel),
cl::enum_key_value("all", lg::severity_level::debug),
cl::enum_key_value("debug", lg::severity_level::debug),
cl::enum_key_value("info", lg::severity_level::info),
cl::enum_key_value("warning", lg::severity_level::warning),
cl::enum_key_value("error", lg::severity_level::error),
cl::enum_key_value("fatal", lg::severity_level::fatal)
},
cl::boolean_argument
{
cl::long_name("verbose"),
cl::category("Logger"),
cl::short_name('v'),
cl::default_value(false),
cl::reference(g_verbose),
cl::description("Enables verbose mode. Equivalent to \"-Vdebug\"")
},
cl::boolean_argument
{
cl::long_name("no-graphics"),
cl::category("Graphics"),
cl::short_name('N'),
cl::reference(g_config.m_NoGraphics),
cl::description("Disables display of fractal in GUI")
},
cl::string_argument
{
cl::long_name("to-file"),
cl::short_name('f'),
cl::reference(g_config.m_ImagePath),
cl::description("Write to image file with given path instead of screen")
}
};
int main(int argc, const char** argv)
{
// Parse command line
g_handler.read(argc, argv);
// Initialize logger
lg::logger::null_init();
const auto t_level = g_verbose ? lg::severity_level::debug : g_logLevel;
lg::console_target<lg::clang_formatter> t_target{ t_level };
lg::logger::add_target(&t_target);
// Run application
fractal::application t_app{ g_config };
t_app.run();
// Shutdown logger
lg::logger::shutdown();
}
| 26.219512 | 95 | 0.693023 |
8b6937d811b405de19f167bc80d4a06cf35db50b | 4,450 | cpp | C++ | src/concepts.cpp | SammyEnigma/blog | f0f3ef44ea4fd622befae81d2f4e5e6a607acfd1 | [
"0BSD"
] | 94 | 2019-02-17T09:25:28.000Z | 2022-03-31T03:25:14.000Z | src/concepts.cpp | SammyEnigma/blog | f0f3ef44ea4fd622befae81d2f4e5e6a607acfd1 | [
"0BSD"
] | 5 | 2020-09-05T09:38:59.000Z | 2021-11-29T15:38:57.000Z | src/concepts.cpp | SammyEnigma/blog | f0f3ef44ea4fd622befae81d2f4e5e6a607acfd1 | [
"0BSD"
] | 29 | 2019-02-17T09:25:36.000Z | 2022-03-17T08:53:38.000Z | #include <iostream>
#include <concepts>
#include <type_traits>
template<typename T> concept always_true = true;
template<typename T> concept always_true_2 = requires { requires true; };
template<typename T> requires always_true<T> void good(T) {} // ALWAYS compiles
template<typename T> requires always_true_2<T> void good_2(T) {} // ALWAYS compiles
template<typename T> concept always_false = false;
template<typename T> concept always_false_2 = requires { requires false; };
template<typename T> requires always_false<T> void bad(T) {} // NEVER compiles
template<typename T> requires always_false_2<T> void bad_2(T) {} // NEVER compiles
template<typename T> concept can_add = requires (T a)
{
requires std::integral<T>;
requires sizeof(T) >= sizeof(int);
{ a + a } noexcept -> std::same_as<T>;
};
template<typename T> requires can_add<T> // ONE 'requires' needed
T add(T x, T y) noexcept { return x + y; }
template<typename T> concept can_sub = requires (T a)
{
requires can_add<T>;
{ a * -1 } noexcept -> std::same_as<T>;
{ add<T>(a, a) } noexcept -> std::same_as<T>;
};
template<can_sub T> // NO 'requires' needed because 'can_sub' used instead of 'typename'
T sub(T x, T y) noexcept { return add(x, y * -1); }
template<typename T> concept can_add_and_sub = requires (T a)
{
requires can_add<T> and can_sub<T>; // SECOND 'requires' needed
{ sub<T>(a, a) } noexcept -> std::same_as<T>; // nothrow invocable AND returns type T, OR...
requires std::is_nothrow_invocable_r_v<T, decltype(sub<T>), T, T>; // same as above
};
template<can_add_and_sub T>
T add_sub(T x, T y, T z) noexcept { return x + y - z; }
template<typename T> concept can_add_and_sub_2 =
can_add<T> and can_sub<T> and
std::is_nothrow_invocable_r_v<T, decltype(sub<T>), T, T>;
template<typename T> requires can_add_and_sub_2<T>
T sub_add(T x, T y, T z) noexcept { return x - y + z; }
template<typename T> requires(std::integral<T> and sizeof(T) >= 4) // ACCEPT any integral type 32-bit or larger
void foo(T t) { std::cout << "1st foo overload called with t = " << t << std::endl; }
template<std::integral T> requires std::same_as<T, short> // ACCEPT only 'short'
void foo(T t) { std::cout << "2nd foo overload called with t = " << t << std::endl; }
void foo(auto t) requires std::same_as<decltype(t), char> // ACCEPT only 'char'
{ std::cout << "3rd foo overload called with t = " << (int)t << std::endl; }
void bar(std::integral auto t) // ACCEPT any integral type
{ std::cout << "1st bar overload called with t = " << t << std::endl; }
void bar(std::floating_point auto t) // ACCEPT any floating point type
{ std::cout << "2nd bar overload called with t = " << t << std::endl; }
template<typename T> requires std::integral<T>
struct S // ACCEPT only integral types
{
S(T) {}
template<typename U> requires std::floating_point<U>
void func(U) {} // ACCEPT only floating point types
};
template<typename T> auto qaz(T t) { return t; } // RETURN the type/value passed in
// RESTRICT global variable types to integral and floating point
[[maybe_unused]] std::integral auto g_i = qaz(3); // ACCEPT only integral types
[[maybe_unused]] std::floating_point auto g_f = qaz(3.14159); // ACCEPT only floating point types
int main()
{
good(11); // ALWAYS GOOD because 'always_true' concept used
good_2(11); // ALWAYS GOOD because 'always_true_2' concept used
// bad(14); // ALWAYS ERROR because 'always_false' concept used
// bad_2(14); // ALWAYS ERROR because 'always_false_2' concept used
add(1, 2);
// add<short>(1, 2); // ERROR because of 'requires sizeof(T) >= sizeof(int);' in 'can_add'
sub(3, 4);
// sub<const char*>("3", "4"); // ERROR because 'requires std::integral<T>;' in 'can_add'
add_sub<long long>(5, 6, 7);
sub_add<long long>(5, 6, 7);
foo(11); // calls 1st overload
foo(short{14}); // calls 2nd overload
foo(char{17}); // calls 3rd overload
bar(20); // calls 1st overload
bar(23.f); // calls 2nd overload
// RESTRICT local variable types to integral and floating point
[[maybe_unused]] std::integral auto i = 11; // int
[[maybe_unused]] std::floating_point auto f = 11.f; // float
[[maybe_unused]] std::floating_point auto d = 11.; // double
// std::integral auto i2 = 11.f; // ERROR because 'int' is expected
// std::floating_point auto f2 = 11; // ERROR because 'float' is expected
S s{ 123 }; // ACCEPT only integral types
s.func(1.0); // ACCEPT only floating point types
}
| 33.458647 | 111 | 0.679775 |
8b6f97c47533331472e402ceeb20e539641a54fa | 725 | hh | C++ | src/mem/ruby/profiler/XactVisualizer.hh | rtitos/gem5 | a9668f91d9f96aafc4a36453e3ba1242c60776a6 | [
"BSD-3-Clause"
] | null | null | null | src/mem/ruby/profiler/XactVisualizer.hh | rtitos/gem5 | a9668f91d9f96aafc4a36453e3ba1242c60776a6 | [
"BSD-3-Clause"
] | 1 | 2022-01-31T13:15:08.000Z | 2022-01-31T13:15:08.000Z | src/mem/ruby/profiler/XactVisualizer.hh | rtitos/gem5 | a9668f91d9f96aafc4a36453e3ba1242c60776a6 | [
"BSD-3-Clause"
] | null | null | null | /*
Copyright (C) 2016-2021 Rubén Titos <rtitos@um.es>
Universidad de Murcia
GPLv2, see file LICENSE.
*/
#ifndef __MEM_RUBY_HTM_XACTVISUALIZER_HH__
#define __MEM_RUBY_HTM_XACTVISUALIZER_HH__
#include <ostream>
#include <vector>
#include "mem/ruby/profiler/annotated_regions.h"
#include "mem/ruby/system/Sequencer.hh"
namespace gem5
{
namespace ruby
{
class XactProfiler;
class XactVisualizer {
public:
XactVisualizer(XactProfiler* profiler, std::ostream* output);
~XactVisualizer();
void printAnnotatedRegions(std::string& extraStr);
XactProfiler *m_xact_profiler;
Cycles lastPrintCycle;
std::ostream* m_xact_visualizer_output_file_ptr;
};
} // namespace ruby
} // namespace gem5
#endif
| 16.860465 | 63 | 0.757241 |
8b7096e9227912d4a345aceaf3dacf8ccc93c7a6 | 4,405 | cpp | C++ | tic-tac-toe (1).cpp | Weaam-Yehiaa/tic_tac_toe | d46b6171a4429d9fa200aca8da96db3ae68ae980 | [
"MIT"
] | null | null | null | tic-tac-toe (1).cpp | Weaam-Yehiaa/tic_tac_toe | d46b6171a4429d9fa200aca8da96db3ae68ae980 | [
"MIT"
] | null | null | null | tic-tac-toe (1).cpp | Weaam-Yehiaa/tic_tac_toe | d46b6171a4429d9fa200aca8da96db3ae68ae980 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
const int N = 3;
const char marks[2] = {'X', 'O'};
char grid[N][N];
vector<pair<int,int > > v;
//This function prints the grid of Tic-Tac-Toe Game as the game progresses
void print_grid() {
cout << "Player 1: " << marks[0] << " vs Player 2: " << marks[1] << "\n";
cout << "--";
for (int i = 0; i < N; cout << "---", i++);
cout << "--\n";
for (int i = 0; i < N; i++) {
cout << "| ";
for (int j = 0; j < N; j++)
cout << grid[i][j] << " ";
cout << "|\n";
cout << "--";
for (int i = 0; i < N; cout << "---", i++);
cout << "--\n";
}
}
//This function checks if the game has a win state or not
bool check_win() {
for(int i=0;i<N;++i)
{
if(grid[i][0]==grid[i][1]&&grid[i][1]==grid[i][2]&&grid[i][2]!='.')return true;
}
for(int j=0;j<N;++j)
{
if(grid[0][j]==grid[1][j]&&grid[1][j]==grid[2][j]&&grid[2][j]!='.')return true;
}
if(grid[0][0]==grid[1][1]&&grid[1][1]==grid[2][2]&&grid[0][0]!='.')return true;
if(grid[2][0]==grid[1][1]&&grid[1][1]==grid[0][2]&&grid[0][2]!='.')return true;
return false;
}
//This function checks if the game has a tie state or not for the given mark
bool check_tie_player(char mark){
for(int i=0;i<N;++i)
{
for(int j=0;j<N;++j)
{
if(grid[i][j]=='.')
{
grid[i][j]=mark;
v.push_back(make_pair(i,j));
}
}
}
if(!check_win()){
for(int x=0;x<v.size();++x)
{ pair<int,int >vv=v[x];
int i=vv.first,j=vv.second;
grid[i][j]='.';
}
v.clear();
return true;
}
else
{
for(int x=0;x<v.size();++x)
{ pair<int,int >vv=v[x];
int i=vv.first,j=vv.second;
grid[i][j]='.';
}
v.clear();
return false;
}
}
//This function checks if the game has a tie state or not
bool check_tie() {
bool all_tie = true;
for (int i = 0; i < 2; i++)
if (!check_tie_player(marks[i]))
all_tie = false;
return all_tie;
}
//This function checks if given cell is empty or not
bool check_empty(int i, int j) {
if(grid[i][j]=='.')return true;
else return false;
}
//This function checks if given position is valid or not
bool check_valid_position(int i, int j) {
if(i<=N&&j<=N&&i>=0&&j>=0)return true;
else return false;
}
//This function sets the given mark to the given cell
void set_cell(int i, int j, char mark) {
grid[i][j]=mark;
}
//This function clears the game structures
void grid_clear() {
memset(grid,'.',sizeof(grid));
}
//This function reads a valid position input
void read_input(int &i, int &j) {
cout << "Enter the row index and column index: ";
cin >> i >> j;
while (!check_valid_position(i, j) || !check_empty(i, j)) {
cout << "Enter a valid row index and a valid column index: ";
cin >> i >> j;
}
}
//MAIN FUNCTION
void play_game() {
cout << "Tic-Tac-Toe Game!\n";
cout << "Welcome...\n";
cout << "============================\n";
bool player = 0;
while (true) {
//Prints the grid
print_grid();
//Read an input position from the player
cout << "Player " << marks[player] << " is playing now\n";
int i, j;
read_input(i, j);
//Set the player mark in the input position
set_cell(i, j, marks[player]);
//Check if the grid has a win state
if (check_win()) {
//Prints the grid
print_grid();
//Announcement of the final statement
cout << "Congrats, Player " << marks[player] << " is won!\n";
break;
}
//Check if the grid has a tie state
if (check_tie()) {
//Prints the grid
print_grid();
//Announcement of the final statement
cout << "Woah! That's a tie!\n";
break;
}
//Player number changes after each turn
player = 1 - player;
}
}
int main() {
while (true) {
grid_clear();
play_game();
char c;
cout << "Play Again [Y/N] ";
cin >> c;
if (c != 'y' && c != 'Y')
break;
}
}
| 27.879747 | 87 | 0.481725 |
8b73558a32d9f636f6a856662a4624643fe7b508 | 3,926 | cpp | C++ | src/WS2812SDCard.cpp | vmlopezr/modular-ws2812-display-esp32 | b27d262598cf1ab2cb9bb909452052224197de7e | [
"MIT"
] | 1 | 2021-01-02T13:48:42.000Z | 2021-01-02T13:48:42.000Z | src/WS2812SDCard.cpp | vmlopezr/modular-ws2812-display-esp32 | b27d262598cf1ab2cb9bb909452052224197de7e | [
"MIT"
] | null | null | null | src/WS2812SDCard.cpp | vmlopezr/modular-ws2812-display-esp32 | b27d262598cf1ab2cb9bb909452052224197de7e | [
"MIT"
] | null | null | null | #include "WS2812SDCard.h"
/**
@brief Opens a given file and reads the frame data into the matrix display array.
Note: The first row of all frame files is used to give file information.
- When reading such files, skip the first row.
- The led data begins on the second row. Every 6 characters is the string value for the
pixel color. e.g. "RRGGBB", this will then get converted to a hex unsigned integer.
- Start populating the matrix display array from index 0 up to its length - 1.
@param Leds The LED control object. Contains the matrix display array.
@param filename The filename that is opened and read.
*/
void loadDataToMatrixDisplay(Esp32CtrlLed &Leds, const char *filename)
{
File file = SD.open((const char *)filename);
if (!file)
{
Serial.printf("Failed to open file for reading\n");
return;
}
char temp;
// Move file pointer to the second line.
do
{
temp = file.read();
if (temp == '\n' || temp == '\r')
{
break;
}
} while (file.available());
int char_count = 0;
char data[6];
size_t index = 0;
size_t color;
// Read the rest of the data and set the matrix display array
while (file.available())
{
if (char_count >= 6)
{
// convert the data array into a 32-bit unsigned integer
char_count = 0;
color = strtol((const char *)data, NULL, 16);
Leds.setPixelRGB(index, color);
index++;
}
temp = file.read();
// Extract every 6 numeric characters
if (temp != '\n' && temp != '\r' && temp != ' ')
{
data[char_count] = temp;
char_count++;
}
}
file.close();
}
/**
@brief Opens a given file and reads the frame data into the buffer array.
Note: The first row of all frame files is used to give file information.
- When reading such files, skip the first row.
- The led data begins on the second row. Every 6 characters is the string value for the
pixel color. e.g. "RRGGBB", this will then get converted to a hex unsigned integer.
- Start populating the matrix display array from index 0 up to its length - 1.
@param buffer The buffer array; contains the data for the next frame to be displayed.
@param filename The filename that is opened and read.
*/
void loadDataToBuffer(uint32_t *buffer, const char *filename)
{
File file = SD.open((const char *)filename);
if (!file)
{
Serial.printf("Failed to open file for reading\n");
return;
}
char temp;
// Move file pointer to the second line.
do
{
temp = file.read();
if (temp == '\n' || temp == '\r')
{
break;
}
} while (file.available());
int char_count = 0;
char data[6];
size_t index = 0;
// Read the rest of the data and load it into the buffer array
while (file.available())
{
if (char_count >= 6)
{
// convert the data array into a 32-bit unsigned integer
char_count = 0;
if (index <= matrix.NUM_LEDS)
{
buffer[index] = strtol((const char *)data, NULL, 16);
}
index++;
}
temp = file.read();
// Extract every 6 numeric characters
if (temp != '\n' && temp != '\r' && temp != ' ')
{
data[char_count] = temp;
char_count++;
}
}
file.close();
}
/**
@brief Write the data of the next frame stored on the buffer array, to the
matrix display array. Copies the buffer into the display array.
@param buffer The buffer array; contains the data for the next frame to be displayed.
*/
void writeBufferToLed(uint32_t *buffer)
{
for (int i = 0; i < matrix.NUM_LEDS; i++)
{
matrix.setPixelRGB(i, LEDBuffer1[i]);
}
} | 29.969466 | 90 | 0.584055 |
8b75b54a1e0b4a61562fc217f92759f34e03bbe6 | 1,590 | cpp | C++ | P/1066-WA.cpp | langonginc/cfile | 46458897b8a4a8d58a2bc63ecb6ef84f76bdb61f | [
"MIT"
] | 1 | 2020-09-13T02:51:25.000Z | 2020-09-13T02:51:25.000Z | P/1066-WA.cpp | langonginc/cfile | 46458897b8a4a8d58a2bc63ecb6ef84f76bdb61f | [
"MIT"
] | null | null | null | P/1066-WA.cpp | langonginc/cfile | 46458897b8a4a8d58a2bc63ecb6ef84f76bdb61f | [
"MIT"
] | 1 | 2021-06-05T03:37:57.000Z | 2021-06-05T03:37:57.000Z | #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define mms(tpp,xgg) memset(tpp,xgg,sizeof(tpp))
typedef long long ll;
const ll inf=30001;
// 1.计算质数
ll prime[inf],ta[inf],pc;
void pt()
{
for(ll i=2;i<inf;i++)
{
ta[i]=1;
}
for(ll i=2;i<inf;i++)
{
if(ta[i])
{
prime[pc++]=i;
}
for(ll j=0;j<pc&&i*prime[j]<inf;j++)
{
ta[i*prime[j]]=0;
if(i%prime[j]==0)
{
break;
}
}
}
}
ll a[inf],b[inf],sum[inf];
inline short factor(ll n,short flag)
{
for(int x=2;x<=n;x++)
{
int tx=x;
for(int i=0;i<pc && tx>1;i++)
{
while(tx%prime[i]==0)
{
tx/=prime[i];
a[i]+=flag;
}
}
}
return flag;
}
void gc(ll n,ll m)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
factor(n,1),
factor(m,-1),
factor(n-m,-1);//约分
b[0]=1;
for(int i=0;i<pc;i++)
{
for(int j=0;j<a[i];j++)
{
for(int ti=0;ti<205;ti++)
b[ti]*=prime[i];
for(int ti=0;ti<205;ti++){
b[ti+1]+=b[ti]/10,b[ti]%=10;
}
}
}
for(int i=0;i<205;sum[i]+=b[i],i++);
for(int i=0;i<205;sum[i+1]+=sum[i]/10,sum[i]%=10,i++);
}
int main()
{
ll k,w;
// scanf("%lld%lld",&k,&w);
cin>>k>>w;
pt();
ll m=k/w,ma=(1<<k)-1;
for(int i=2;i<=m;i++)
{
if(ma>=i)
{
gc(ma,i);
}
}
if(w%k!=0 && m>=1)
{
ll temp=(1<<(w%k))-1;
for(int i=1;i<=temp && ma-i>=m;i++)
{
gc(ma-i,m);
}
}
ll p=204;
while(sum[p]==0)p--;
//p++;
for(ll i=p;i>=0;i--)
{
printf("%lld",sum[i]);
}
return 0;
}
| 14.859813 | 56 | 0.445283 |
8b77a33c92cd8291fd3734d3574080171b76f068 | 1,778 | cpp | C++ | test/test1.cpp | iirthw/quick_tracer | 23ac768c029bef0183b3736b6c9c08b66efd0588 | [
"MIT"
] | null | null | null | test/test1.cpp | iirthw/quick_tracer | 23ac768c029bef0183b3736b6c9c08b66efd0588 | [
"MIT"
] | null | null | null | test/test1.cpp | iirthw/quick_tracer | 23ac768c029bef0183b3736b6c9c08b66efd0588 | [
"MIT"
] | null | null | null | //#include "this/package/foo.h"
#include "gtest/gtest.h"
//#include "../engine/public/color.h"
//#include "engine/public/color.h"
#include "color.h"
#include "bmp/bmp.h"
namespace tinytracer
{
namespace
{
// The fixture for testing class Foo.
class FooTest : public ::testing::Test
{
protected:
// You can remove any or all of the following functions if their bodies would
// be empty.
FooTest()
{
// You can do set-up work for each test here.
}
~FooTest() override
{
// You can do clean-up work that doesn't throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
void SetUp() override
{
// Code here will be called immediately after the constructor (right
// before each test).
}
void TearDown() override
{
// Code here will be called immediately after each test (right
// before the destructor).
}
// Class members declared here can be used by all tests in the test suite
// for Foo.
};
// Tests that the Foo::Bar() method does Abc.
TEST_F(FooTest, MethodBarDoesAbc)
{
const std::string input_filepath = "this/package/testdata/myinputfile.dat";
const std::string output_filepath = "this/package/testdata/myoutputfile.dat";
// Foo f;
EXPECT_EQ(input_filepath.length(), output_filepath.length() - 1);
}
// Tests that Foo does Xyz.
TEST_F(FooTest, DoesXyz)
{
color::RGBA c;
// Exercises the Xyz feature of Foo.
}
} // namespace
} // namespace my project | 26.147059 | 84 | 0.598988 |
8b78836e2b09e573c82493a200bb35bcd80286bd | 10,207 | cpp | C++ | src/lib/huffman_enc.cpp | Special-graphic-formats/himg | 62859ca604f33629239d0da5fbf2dceae9fc4b8b | [
"Unlicense"
] | 17 | 2015-09-08T09:08:02.000Z | 2019-05-11T06:08:18.000Z | src/lib/huffman_enc.cpp | Special-graphic-formats/himg | 62859ca604f33629239d0da5fbf2dceae9fc4b8b | [
"Unlicense"
] | 3 | 2015-09-14T09:00:49.000Z | 2021-12-16T11:47:01.000Z | src/lib/huffman_enc.cpp | Special-graphic-formats/himg | 62859ca604f33629239d0da5fbf2dceae9fc4b8b | [
"Unlicense"
] | 3 | 2015-06-13T22:04:31.000Z | 2019-12-29T11:22:49.000Z | //-----------------------------------------------------------------------------
// HIMG, by Marcus Geelnard, 2015
//
// This is free and unencumbered software released into the public domain.
//
// See LICENSE for details.
//-----------------------------------------------------------------------------
#include "huffman_enc.h"
#include <algorithm>
#include <vector>
#include "huffman_common.h"
namespace himg {
namespace {
// The maximum size of the tree representation (there are two additional bits
// per leaf node, representing the branches in the tree).
const int kMaxTreeDataSize = ((2 + kSymbolSize) * kNumSymbols + 7) / 8;
class OutBitstream {
public:
// Initialize a bitstream.
explicit OutBitstream(uint8_t *buf)
: m_base_ptr(buf), m_byte_ptr(buf), m_bit_pos(0) {}
// Write bits to a bitstream.
void WriteBits(uint32_t x, int bits) {
// Get current stream state.
uint8_t *buf = m_byte_ptr;
int bit = m_bit_pos;
// Append bits.
// TODO(m): Optimize this!
while (bits--) {
*buf = (*buf & (0xff ^ (1 << bit))) | ((x & 1) << bit);
x >>= 1;
bit = (bit + 1) & 7;
if (!bit) {
++buf;
}
}
// Store new stream state.
m_byte_ptr = buf;
m_bit_pos = bit;
}
// Align the stream to a byte boundary (do nothing if already aligned).
void AlignToByte() {
if (m_bit_pos) {
m_bit_pos = 0;
++m_byte_ptr;
}
}
// Advance N bytes.
void AdvanceBytes(int N) {
m_byte_ptr += N;
}
int Size() const {
int total_bytes = static_cast<int>(m_byte_ptr - m_base_ptr);
if (m_bit_pos > 0) {
++total_bytes;
}
return total_bytes;
}
uint8_t *byte_ptr() {
return m_byte_ptr;
}
private:
uint8_t *m_base_ptr;
uint8_t *m_byte_ptr;
int m_bit_pos;
};
// Used by the encoder for building the optimal Huffman tree.
struct SymbolInfo {
Symbol symbol;
int count;
uint32_t code;
int bits;
};
struct EncodeNode {
EncodeNode *child_a, *child_b;
int count;
int symbol;
};
// Calculate (sorted) histogram for a block of data.
void Histogram(const uint8_t *in,
SymbolInfo *symbols,
int size,
int block_size) {
// Clear/init histogram.
for (int k = 0; k < kNumSymbols; ++k) {
symbols[k].symbol = static_cast<Symbol>(k);
symbols[k].count = 0;
symbols[k].code = 0;
symbols[k].bits = 0;
}
// Build the histogram for all blocks.
const uint8_t *in_end = in + size;
for (const uint8_t *block = in; block < in_end; block += block_size) {
// Build the histogram for this block.
for (int k = 0; k < block_size;) {
Symbol symbol = static_cast<Symbol>(block[k]);
// Possible RLE?
if (symbol == 0) {
int zeros;
for (zeros = 1; zeros < 16662 && (k + zeros) < block_size; ++zeros) {
if (block[k + zeros] != 0)
break;
}
if (zeros == 1) {
symbols[0].count++;
} else if (zeros == 2) {
symbols[kSymTwoZeros].count++;
} else if (zeros <= 6) {
symbols[kSymUpTo6Zeros].count++;
} else if (zeros <= 22) {
symbols[kSymUpTo22Zeros].count++;
} else if (zeros <= 278) {
symbols[kSymUpTo278Zeros].count++;
} else {
symbols[kSymUpTo16662Zeros].count++;
}
k += zeros;
} else {
symbols[symbol].count++;
k++;
}
}
}
}
// Store a Huffman tree in the output stream and in a look-up-table (a symbol
// array).
void StoreTree(EncodeNode *node,
SymbolInfo *symbols,
OutBitstream *stream,
uint32_t code,
int bits) {
// Is this a leaf node?
if (node->symbol >= 0) {
// Append symbol to tree description.
stream->WriteBits(1, 1);
stream->WriteBits(static_cast<uint32_t>(node->symbol), kSymbolSize);
// Find symbol index.
int sym_idx;
for (sym_idx = 0; sym_idx < kNumSymbols; ++sym_idx) {
if (symbols[sym_idx].symbol == static_cast<Symbol>(node->symbol))
break;
}
// Store code info in symbol array.
symbols[sym_idx].code = code;
symbols[sym_idx].bits = bits;
return;
} else {
// This was not a leaf node.
stream->WriteBits(0, 1);
}
// Branch A.
StoreTree(node->child_a, symbols, stream, code, bits + 1);
// Branch B.
StoreTree(node->child_b, symbols, stream, code + (1 << bits), bits + 1);
}
// Generate a Huffman tree.
void MakeTree(SymbolInfo *sym, OutBitstream *stream) {
// Initialize all leaf nodes.
EncodeNode nodes[kMaxTreeNodes];
int num_symbols = 0;
for (int k = 0; k < kNumSymbols; ++k) {
if (sym[k].count > 0) {
nodes[num_symbols].symbol = static_cast<int>(sym[k].symbol);
nodes[num_symbols].count = sym[k].count;
nodes[num_symbols].child_a = nullptr;
nodes[num_symbols].child_b = nullptr;
++num_symbols;
}
}
// Build tree by joining the lightest nodes until there is only one node left
// (the root node).
EncodeNode *root = nullptr;
int nodes_left = num_symbols;
int next_idx = num_symbols;
while (nodes_left > 1) {
// Find the two lightest nodes.
EncodeNode *node_1 = nullptr;
EncodeNode *node_2 = nullptr;
for (int k = 0; k < next_idx; ++k) {
if (nodes[k].count > 0) {
if (!node_1 || (nodes[k].count <= node_1->count)) {
node_2 = node_1;
node_1 = &nodes[k];
} else if (!node_2 || (nodes[k].count <= node_2->count)) {
node_2 = &nodes[k];
}
}
}
// Join the two nodes into a new parent node.
root = &nodes[next_idx];
root->child_a = node_1;
root->child_b = node_2;
root->count = node_1->count + node_2->count;
root->symbol = -1;
node_1->count = 0;
node_2->count = 0;
++next_idx;
--nodes_left;
}
// Store the tree in the output stream, and in the sym[] array (the latter is
// used as a look-up-table for faster encoding).
if (root) {
StoreTree(root, sym, stream, 0, 0);
} else {
// Special case: only one symbol => no binary tree.
root = &nodes[0];
StoreTree(root, sym, stream, 0, 1);
}
}
} // namespace
int HuffmanEnc::MaxCompressedSize(int uncompressed_size) {
return uncompressed_size + kMaxTreeDataSize;
}
int HuffmanEnc::Compress(uint8_t *out,
const uint8_t *in,
int in_size,
int block_size) {
// Do we have anything to compress?
if (in_size < 1)
return 0;
if (block_size < 1)
block_size = in_size;
const bool use_blocks = block_size < in_size;
// Sanity check: Do the blocks add up the the entire input buffer?
if (in_size % block_size != 0)
return 0;
// Initialize bitstream.
OutBitstream stream(out);
// Calculate and sort histogram for input data.
SymbolInfo symbols[kNumSymbols];
Histogram(in, symbols, in_size, block_size);
// Build Huffman tree.
MakeTree(symbols, &stream);
stream.AlignToByte();
// Sort histogram - first symbol first (bubble sort).
// TODO(m): Quick-sort.
bool swaps;
do {
swaps = false;
for (int k = 0; k < kNumSymbols - 1; ++k) {
if (symbols[k].symbol > symbols[k + 1].symbol) {
SymbolInfo tmp = symbols[k];
symbols[k] = symbols[k + 1];
symbols[k + 1] = tmp;
swaps = true;
}
}
} while (swaps);
std::vector<uint8_t> block_buffer(block_size);
// Encode input stream.
const uint8_t *in_end = in + in_size;
for (const uint8_t *block = in; block < in_end; block += block_size) {
// Create a temporary output stream for this block.
OutBitstream block_stream(block_buffer.data());
// Encode this block.
for (int k = 0; k < block_size;) {
uint8_t symbol = block[k];
// Possible RLE?
if (symbol == 0) {
int zeros;
for (zeros = 1; zeros < 16662 && (k + zeros) < block_size; ++zeros) {
if (block[k + zeros] != 0)
break;
}
if (zeros == 1) {
block_stream.WriteBits(symbols[0].code, symbols[0].bits);
} else if (zeros == 2) {
block_stream.WriteBits(symbols[kSymTwoZeros].code,
symbols[kSymTwoZeros].bits);
} else if (zeros <= 6) {
uint32_t count = static_cast<uint32_t>(zeros - 3);
block_stream.WriteBits(symbols[kSymUpTo6Zeros].code,
symbols[kSymUpTo6Zeros].bits);
block_stream.WriteBits(count, 2);
} else if (zeros <= 22) {
uint32_t count = static_cast<uint32_t>(zeros - 7);
block_stream.WriteBits(symbols[kSymUpTo22Zeros].code,
symbols[kSymUpTo22Zeros].bits);
block_stream.WriteBits(count, 4);
} else if (zeros <= 278) {
uint32_t count = static_cast<uint32_t>(zeros - 23);
block_stream.WriteBits(symbols[kSymUpTo278Zeros].code,
symbols[kSymUpTo278Zeros].bits);
block_stream.WriteBits(count, 8);
} else {
uint32_t count = static_cast<uint32_t>(zeros - 279);
block_stream.WriteBits(symbols[kSymUpTo16662Zeros].code,
symbols[kSymUpTo16662Zeros].bits);
block_stream.WriteBits(count, 14);
}
k += zeros;
} else {
block_stream.WriteBits(symbols[symbol].code, symbols[symbol].bits);
k++;
}
}
const int packed_size = block_stream.Size();
if (use_blocks) {
// Write the packed size (in bytes) as two or four bytes (depending on the
// size).
stream.AlignToByte();
if (packed_size <= 0x7fff) {
stream.WriteBits(packed_size, 16);
} else {
stream.WriteBits((packed_size & 0x7fff) | 0x8000, 16);
stream.WriteBits(packed_size >> 15, 16);
}
}
// Append the block stream to the output stream.
std::copy(block_buffer.data(),
block_buffer.data() + packed_size,
stream.byte_ptr());
stream.AdvanceBytes(packed_size);
}
// Calculate size of output data.
return stream.Size();
}
} // namespace himg
| 27.887978 | 80 | 0.573332 |
8b7c2505e253e7c8be5fe3c50767d8c9eabad505 | 31,881 | cpp | C++ | studio/ResourcesDoc.cpp | mmcguill/disasm-legacy | 1bc3a459fd943ef03ad2bf38b3dac11dabaab8f1 | [
"MIT"
] | null | null | null | studio/ResourcesDoc.cpp | mmcguill/disasm-legacy | 1bc3a459fd943ef03ad2bf38b3dac11dabaab8f1 | [
"MIT"
] | null | null | null | studio/ResourcesDoc.cpp | mmcguill/disasm-legacy | 1bc3a459fd943ef03ad2bf38b3dac11dabaab8f1 | [
"MIT"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Studio.h"
#include "ResourcesDoc.h"
#include ".\resourcesdoc.h"
/////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CResBaseDoc, CWorkspaceItemBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CResBaseDoc::CResBaseDoc()
{
m_pData = NULL;
m_dwSize = 0;
m_pItemInfo = NULL;
}
/////////////////////////////////////////////////////////////////////////////
CResBaseDoc::~CResBaseDoc()
{
ASSERT(m_pItemInfo); // Shouldnt have doc without this!
if(m_pItemInfo)
{
delete m_pItemInfo;
}
if(m_pData)
{
delete[] m_pData;
}
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CResBaseDoc, CWorkspaceItemBaseDoc)
//{{AFX_MSG_MAP(CResBaseDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
ON_COMMAND(ID_CTXT_VIEWHEX, OnCtxtViewhex)
ON_COMMAND(ID_CTXT_VIEWWITH, OnCtxtViewwith)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CResBaseDoc::OnCtxtViewhex()
{
STUDIODOCTYPE sdt;
sdt.major = StudioMajorTypeResource;
sdt.minor = StudioDocTypeHex;
((CStudioApp*)AfxGetApp())->
CreateOrActivateViewOfWorkspaceItem(m_pItemInfo,&sdt);
}
///////////////////////////////////////////////////////////////////////////////
void CResBaseDoc::OnCtxtViewwith()
{
STUDIODOCTYPE sdt;
sdt.major = StudioMajorTypeResource;
sdt.minor = StudioDocTypeUnknown; // This will invoke view chooser
((CStudioApp*)AfxGetApp())->
CreateOrActivateViewOfWorkspaceItem(m_pItemInfo,&sdt);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CResBaseDoc::SetWorkspaceItemInfo(CStudioWorkspaceItemInfo* pItemInfo)
{
CStudioWorkspaceResourceItemInfo* pInfo =
(CStudioWorkspaceResourceItemInfo*)pItemInfo;
// Make Local Copy of Item Info
m_pItemInfo = new CStudioWorkspaceResourceItemInfo(pInfo);
ASSERT(m_pItemInfo);
// Initialize using this data
return InitDoc();
}
/////////////////////////////////////////////////////////////////////////////
BOOL CResBaseDoc::InitDoc()
{
ASSERT(m_pItemInfo);
if(!m_pItemInfo)
{
return FALSE;
}
// TODO: Clear previous - shouldn't happen but be safe
if(m_pData){
delete[] m_pData;
m_pData = NULL;
m_dwSize = 0;
}
CPERes *pPE = m_pItemInfo->GetWorkspaceDoc()->GetResourceParser();
ASSERT(pPE);
DWORD dwRoot = pPE->ResGetRootDir();
if(!dwRoot)
{
return FALSE;
}
DWORD dwTypeDir;
pPE->ResGetDirObj(dwRoot,m_pItemInfo->GetPEIndex(),&dwTypeDir);
//Now Find obj with specified ID or Name
DWORD dwNumIDrName, dwID;
CString strName;
BOOL bFound = FALSE;
pPE->ResGetNumObj(dwTypeDir,&dwNumIDrName);
for(DWORD x=0;x<dwNumIDrName && !bFound;x++)
{
if(m_pItemInfo->GetID())
{
pPE->ResGetObjID(dwTypeDir,x,&dwID);
if(m_pItemInfo->GetID() == dwID) bFound = TRUE;
}
else
{ //Named
if(NULL == m_pItemInfo->GetResourceName())
{
ASSERT(FALSE);
return FALSE;
}
TCHAR szTmp[MAX_PATH] = {0};
pPE->ResGetObjName(dwTypeDir,x,szTmp);
strName = szTmp;
if((*(m_pItemInfo->GetResourceName())) == strName)
{
bFound = TRUE;
}
}
}
if(!bFound)
{
return FALSE;
}
// decrement x
x--;
// Now Find Language
bFound = FALSE;
DWORD dwIDDir, dwLang, dwNumLangs;
pPE->ResGetDirObj(dwTypeDir,x,&dwIDDir);
pPE->ResGetNumObj(dwIDDir,&dwNumLangs);
for(DWORD y=0;y<dwNumLangs && !bFound;y++)
{
pPE->ResGetObjID(dwIDDir,y,&dwLang);
if(m_pItemInfo->GetLanguage() == dwLang) bFound = TRUE;
}
if(!bFound)
{
return FALSE;
}
y--;
pPE->ResGetObjDataSize(dwIDDir,y,&m_dwSize);
m_pData = new unsigned char[m_dwSize];
pPE->ResGetObjData(dwIDDir,y,m_pData);
// Give Me A 'Nice' Title
if(!SetNiceTitle())
{
ASSERT(FALSE);
return FALSE;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
CStudioWorkspaceItemInfo* CResBaseDoc::GetWorkspaceItemInfo() const
{
return (CStudioWorkspaceItemInfo*)m_pItemInfo;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CResBaseDoc::SetNiceTitle()
{
// Find The Default Doc Template For this item and get string for type
BOOL bFound = FALSE;
Assert(m_pItemInfo);
CPERes *pPE = m_pItemInfo->GetWorkspaceDoc()->GetResourceParser();
ASSERT(pPE);
CStudioDocTemplate* pCurDT;
POSITION p = AfxGetApp()->GetFirstDocTemplatePosition();
if(p == NULL)
{
ASSERT(FALSE); // Serious Problem if this happens
return FALSE;
}
do
{
pCurDT = static_cast<CStudioDocTemplate*>(AfxGetApp()->GetNextDocTemplate(p));
ASSERT(pCurDT);
if(m_pItemInfo->GetDefaultDocType()->minor == pCurDT->GetStudioDocType()->minor)
{
bFound = TRUE;
break; // Got Template, Bail Out
}
}while(NULL != p);
if(!bFound && m_pItemInfo->GetDefaultDocType()->minor != StudioDocTypeUnknown)
{
ASSERT(FALSE); // Couldnt find a template for this item
return FALSE;
}
//CString strType;
//
//if(m_pItemInfo->GetDefaultDocType()->minor != StudioDocTypeUnknown)
//{
// pCurDT->GetDocString(strType,CDocTemplate::windowTitle);
//}
//else
//{
// strType.LoadString(IDS_RESOURCE_TYPE_UNKNOWN);
//}
CString strID;
TCHAR szLang[256];
pPE->ResGetLangStringFromID(m_pItemInfo->GetLanguage(),szLang);
if(0 == m_pItemInfo->GetID())
{
ASSERT(m_pItemInfo->GetResourceName());
if(NULL == m_pItemInfo->GetResourceName())
{
return FALSE;
}
strID = *m_pItemInfo->GetResourceName();
}
else
{
strID.Format(_T("0x%X (%d)"),m_pItemInfo->GetID(),m_pItemInfo->GetID());
}
CString strTitle;
ASSERT(m_pItemInfo->GetResourceTypeString());
strTitle.Format(IDS_FORMAT_RESDOCTITLE,
*m_pItemInfo->GetResourceTypeString(),
strID,
szLang);
SetTitle(strTitle);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
void CResBaseDoc::OnCloseDocument()
{
if(m_pData)
{
delete[] m_pData;
m_pData = NULL;
}
m_dwSize = 0;
CDocument::OnCloseDocument();
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CStringTableDoc
IMPLEMENT_DYNCREATE(CStringTableDoc,CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CStringTableDoc::CStringTableDoc()
{
m_pFirst = NULL;
m_dwStrCount = 0;
}
/////////////////////////////////////////////////////////////////////////////
CStringTableDoc::~CStringTableDoc()
{
if(m_pFirst) DeleteAllStrings(m_pFirst);
}
/////////////////////////////////////////////////////////////////////////////
void CStringTableDoc::DeleteAllStrings(STRING_TABLE_ITEM* pEntry)
{
if(pEntry->pNext) DeleteAllStrings(pEntry->pNext);
delete pEntry;
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CStringTableDoc,CResBaseDoc)
//{{AFX_MSG_MAP(CStringTableDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CStringTableDoc diagnostics
#ifdef _DEBUG
void CStringTableDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CStringTableDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
///////////////////////////////////////////////////////////////////////////
BOOL CStringTableDoc::SetNiceTitle()
{
ASSERT(m_pItemInfo);
CPERes *pPE = m_pItemInfo->GetWorkspaceDoc()->GetResourceParser();
ASSERT(pPE);
// TODO: Get a proper string length for this
TCHAR szLang[256];
if(!pPE->ResGetLangStringFromID(m_pItemInfo->GetLanguage(),szLang))
{
ASSERT(FALSE);
return FALSE;
}
CString strTitle;
strTitle.Format(IDS_FORMAT_RESTREE_STRINGTABLE,szLang);
SetTitle(strTitle);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////
BOOL CStringTableDoc::InitDoc()
{
ASSERT(m_pItemInfo);
CPERes *pPE = m_pItemInfo->GetWorkspaceDoc()->GetResourceParser();
ASSERT(pPE);
DWORD dwRoot = pPE->ResGetRootDir();
DWORD dwStringDir;
pPE->ResGetDirObj(dwRoot,m_pItemInfo->GetPEIndex(),&dwStringDir);
DWORD dwNumObj;
pPE->ResGetNumObj(dwStringDir,&dwNumObj);
DWORD dwID;
for(DWORD x=0;x<dwNumObj;x++){
pPE->ResGetObjID(dwStringDir,x,&dwID);
DWORD dwLangDir;
pPE->ResGetDirObj(dwStringDir,x,&dwLangDir);
//Find Correct language
DWORD dwNumLang;
pPE->ResGetNumObj(dwLangDir,&dwNumLang);
DWORD dwLang;
for(DWORD y=0;y<dwNumLang;y++){
pPE->ResGetObjID(dwLangDir,y,&dwLang);
if(dwLang == m_pItemInfo->GetLanguage())
{
DWORD dwSize;
if(!pPE->ResGetObjDataSize(dwLangDir,y,&dwSize)) return FALSE;
BYTE* pData = new unsigned char[dwSize];
if(!pData) return FALSE;
if(!pPE->ResGetObjData(dwLangDir,y,pData)) return FALSE;
ProcessStringBlock((WORD*)pData,(WORD)dwID);
delete[] pData;
break;
}
}
}
// TODO: Whys this here?
UpdateAllViews(NULL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
void CStringTableDoc::GetString(DWORD str, CString &strString, WORD* pwID)
{
if(str > m_dwStrCount) return;
STRING_TABLE_ITEM* pTmp = m_pFirst;
for(DWORD x=0;x<str;x++){
pTmp = pTmp->pNext;
}
if(pTmp){
strString = pTmp->strText;
*pwID = pTmp->wID;
}
}
/////////////////////////////////////////////////////////////////////////////
void CStringTableDoc::ProcessStringBlock(WORD *pStr, WORD wID)
{
for(int x=0;x<16;x++){
if(*pStr != 0x0000){
WORD wLen = *pStr;
pStr++;
char* pszText = new char[wLen+1];
int nCh = WideCharToMultiByte(CP_ACP,0,(LPCWSTR)pStr,wLen,pszText,wLen,NULL,NULL);
pszText[nCh] = 0;
// Add String
STRING_TABLE_ITEM* pTemp = m_pFirst;
if(pTemp){
while(pTemp->pNext){
pTemp = pTemp->pNext;
}
pTemp->pNext = new STRING_TABLE_ITEM;
pTemp->pNext->pNext = NULL;
pTemp->pNext->strText = pszText;
pTemp->pNext->wID = ((wID-1) << 4) + x;
m_dwStrCount++;
}
else{
m_pFirst = new STRING_TABLE_ITEM;
m_pFirst->pNext = NULL;
m_pFirst->strText = pszText;
m_pFirst->wID = ((wID-1) << 4) + x;
m_dwStrCount++;
}
pStr += nCh;
if(pszText) delete[] pszText;
}
else pStr++;
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CAccelDoc
IMPLEMENT_DYNCREATE(CAccelDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CAccelDoc::CAccelDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
CAccelDoc::~CAccelDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CAccelDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CAccelDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CAccelDoc diagnostics
#ifdef _DEBUG
void CAccelDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CAccelDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CAccelDoc commands
BOOL CAccelDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// TODO: Whys This Here?
UpdateAllViews(NULL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
void CAccelDoc::GetVirtKeyString(WORD wKey, CString &str)
{
if(wKey >= _T('0') && wKey <= _T('9')){
str.Format(_T("%c"),wKey);
return;
}
if(wKey >= _T('A') && wKey <= _T('Z')){
str.Format(_T("%c"),wKey);
return;
}
switch(wKey){
case VK_ACCEPT:
str = _T("VK_ACCEPT");
break;
case VK_ADD:
str = _T("VK_ADD");
break;
case VK_BACK:
str = _T("VK_BACK");
break;
case VK_CANCEL:
str = _T("VK_CANCEL");
break;
case VK_CLEAR:
str = _T("VK_CLEAR");
break;
case VK_CONVERT:
str = _T("VK_CONVERT");
break;
case VK_DECIMAL:
str = _T("VK_DECIMAL");
break;
case VK_DELETE:
str = _T("VK_DELETE");
break;
case VK_DIVIDE:
str = _T("VK_DIVIDE");
break;
case VK_DOWN:
str = _T("VK_DOWN");
break;
case VK_END:
str = _T("VK_END");
break;
case VK_ESCAPE:
str = _T("VK_ESCAPE");
break;
case VK_F1:
str = _T("VK_F1");
break;
case VK_F10:
str = _T("VK_F10");
break;
case VK_F11:
str = _T("VK_F11");
break;
case VK_F12:
str = _T("VK_F12");
break;
case VK_F2:
str = _T("VK_F2");
break;
case VK_F3:
str = _T("VK_F3");
break;
case VK_F4:
str = _T("VK_F4");
break;
case VK_F5:
str = _T("VK_F5");
break;
case VK_F6:
str = _T("VK_F6");
break;
case VK_F7:
str = _T("VK_F7");
break;
case VK_F8:
str = _T("VK_F8");
break;
case VK_F9:
str = _T("VK_F9");
break;
case VK_FINAL:
str = _T("VK_FINAL");
break;
case VK_HELP:
str = _T("VK_HELP");
break;
case VK_HOME:
str = _T("VK_HOME");
break;
case VK_INSERT:
str = _T("VK_INSERT");
break;
case VK_KANA:
str = _T("VK_KANA");
break;
case VK_KANJI:
str = _T("VK_KANJI");
break;
case VK_LEFT:
str = _T("VK_LEFT");
break;
case VK_MODECHANGE:
str = _T("VK_MODECHANGE");
break;
case VK_MULTIPLY:
str = _T("VK_MULTIPLY");
break;
case VK_NONCONVERT:
str = _T("VK_NONCONVERT");
break;
case VK_NUMPAD0:
str = _T("VK_NUMPAD0");
break;
case VK_NUMPAD1:
str = _T("VK_NUMPAD1");
break;
case VK_NUMPAD2:
str = _T("VK_NUMPAD2");
break;
case VK_NUMPAD3:
str = _T("VK_NUMPAD3");
break;
case VK_NUMPAD4:
str = _T("VK_NUMPAD4");
break;
case VK_NUMPAD5:
str = _T("VK_NUMPAD5");
break;
case VK_NUMPAD6:
str = _T("VK_NUMPAD6");
break;
case VK_NUMPAD7:
str = _T("VK_NUMPAD7");
break;
case VK_NUMPAD8:
str = _T("VK_NUMPAD8");
break;
case VK_NUMPAD9:
str = _T("VK_NUMPAD9");
break;
case VK_PAUSE:
str = _T("VK_PAUSE");
break;
case VK_RETURN:
str = _T("VK_RETURN");
break;
case VK_RIGHT:
str = _T("VK_RIGHT");
break;
case VK_SPACE:
str = _T("VK_SPACE");
break;
case VK_SUBTRACT:
str = _T("VK_SUBTRACT");
break;
case VK_TAB:
str = _T("VK_TAB");
break;
case VK_UP:
str = _T("VK_UP");
break;
case VK_LBUTTON:
str = _T("VK_LBUTTON");
break;
case VK_RBUTTON:
str = _T("VK_RBUTTON");
break;
case VK_MBUTTON:
str = _T("VK_MBUTTON");
break;
case VK_SHIFT:
str = _T("VK_SHIFT");
break;
case VK_CONTROL:
str = _T("VK_CONTROL");
break;
case VK_MENU:
str = _T("VK_MENU");
break;
case VK_CAPITAL:
str = _T("VK_CAPITAL");
break;
case VK_JUNJA:
str = _T("VK_JUNJA");
break;
case VK_PRIOR:
str = _T("VK_PRIOR");
break;
case VK_NEXT:
str = _T("VK_NEXT");
break;
case VK_SELECT:
str = _T("VK_SELECT");
break;
case VK_PRINT:
str = _T("VK_PRINT");
break;
case VK_EXECUTE:
str = _T("VK_EXECUTE");
break;
case VK_SNAPSHOT:
str = _T("VK_SNAPSHOT");
break;
case VK_LWIN:
str = _T("VK_LWIN");
break;
case VK_RWIN:
str = _T("VK_RWIN");
break;
case VK_APPS:
str = _T("VK_APPS");
break;
case VK_SEPARATOR:
str = _T("VK_SEPARATOR");
break;
case VK_F13:
str = _T("VK_F13");
break;
case VK_F14:
str = _T("VK_F14");
break;
case VK_F15:
str = _T("VK_F15");
break;
case VK_F16:
str = _T("VK_F16");
break;
case VK_F17:
str = _T("VK_F17");
break;
case VK_F18:
str = _T("VK_F18");
break;
case VK_F19:
str = _T("VK_F19");
break;
case VK_F20:
str = _T("VK_F20");
break;
case VK_F21:
str = _T("VK_F21");
break;
case VK_F22:
str = _T("VK_F22");
break;
case VK_F23:
str = _T("VK_F23");
break;
case VK_F24:
str = _T("VK_F24");
break;
case VK_NUMLOCK:
str = _T("VK_NUMLOCK");
break;
case VK_SCROLL:
str = _T("VK_SCROLL");
break;
case VK_LSHIFT:
str = _T("VK_LSHIFT");
break;
case VK_RSHIFT:
str = _T("VK_RSHIFT");
break;
case VK_LCONTROL:
str = _T("VK_LCONTROL");
break;
case VK_RCONTROL:
str = _T("VK_RCONTROL");
break;
case VK_LMENU:
str = _T("VK_LMENU");
break;
case VK_RMENU:
str = _T("VK_RMENU");
break;
case VK_PROCESSKEY:
str = _T("VK_PROCESSKEY");
break;
case VK_ATTN:
str = _T("VK_ATTN");
break;
case VK_CRSEL:
str = _T("VK_CRSEL");
break;
case VK_EXSEL:
str = _T("VK_EXSEL");
break;
case VK_EREOF:
str = _T("VK_EREOF");
break;
case VK_PLAY:
str = _T("VK_PLAY");
break;
case VK_ZOOM:
str = _T("VK_ZOOM");
break;
case VK_NONAME:
str = _T("VK_NONAME");
break;
case VK_PA1:
str = _T("VK_PA1");
break;
case VK_OEM_CLEAR:
str = _T("VK_OEM_CLEAR");
break;
}
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CBmpDoc
IMPLEMENT_DYNCREATE(CBmpDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CBmpDoc::CBmpDoc()
{
m_hBmp = NULL;
m_szBmp.SetSize(0,0);
}
/////////////////////////////////////////////////////////////////////////////
CBmpDoc::~CBmpDoc()
{
if(m_hBmp)
{
DeleteObject(m_hBmp);
}
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CBmpDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CBmpDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CBmpDoc diagnostics
#ifdef _DEBUG
void CBmpDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CBmpDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CBmpDoc commands
BOOL CBmpDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
m_hBmp = NULL;
m_szBmp.SetSize(0,0);
ASSERT(m_pItemInfo);
CString& strPath = m_pItemInfo->GetWorkspaceDoc()->GetFilePath();
HINSTANCE hInst = (HINSTANCE)LoadLibraryEx(strPath,NULL,LOAD_LIBRARY_AS_DATAFILE);
ASSERT(hInst);
if(NULL == hInst)
{
return FALSE;
}
m_hBmp = LoadImage(hInst,
(m_pItemInfo->GetID() ?
MAKEINTRESOURCE(m_pItemInfo->GetID()) :
*m_pItemInfo->GetResourceName()),
IMAGE_BITMAP,
0,0,LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
FreeLibrary(hInst);
ASSERT(m_hBmp);
if(!m_hBmp)
{
return FALSE;
}
// Get Size
PBITMAPINFO pbinfo = (PBITMAPINFO)m_pData;
m_szBmp.cx = pbinfo->bmiHeader.biWidth;
m_szBmp.cy = pbinfo->bmiHeader.biHeight;
// TODO: Whys This Here
UpdateAllViews(NULL);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CDlgDoc
IMPLEMENT_DYNCREATE(CDlgDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CDlgDoc::CDlgDoc()
{
m_bValid = FALSE;
}
/////////////////////////////////////////////////////////////////////////////
CDlgDoc::~CDlgDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CDlgDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CDlgDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CDlgDoc diagnostics
#ifdef _DEBUG
void CDlgDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CDlgDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CDlgDoc commands
BOOL CDlgDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// Initialise helper
if(!m_dlgHelp.Init(m_pData,m_dwSize))
{
return FALSE;
}
m_bValid = TRUE;
// TODO: Whys THis Here?
UpdateAllViews(NULL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CDlgDoc::IsValid()
{
return m_bValid;
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CHexDoc
IMPLEMENT_DYNCREATE(CHexDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CHexDoc::CHexDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
CHexDoc::~CHexDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CHexDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CHexDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CHexDoc diagnostics
#ifdef _DEBUG
void CHexDoc::AssertValid() const
{
CDocument::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CHexDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CHexDoc commands
BOOL CHexDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// TODO: Whys This Here?
UpdateAllViews(NULL);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CIconDoc
IMPLEMENT_DYNCREATE(CIconDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CIconDoc::CIconDoc()
{
m_nIconCount = 0;
m_cx = m_cy = 0;
m_hIcon = NULL;
m_bIcon = FALSE;
m_ptHot.x = m_ptHot.y = 0;
}
/////////////////////////////////////////////////////////////////////////////
CIconDoc::~CIconDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CIconDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CIconDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CIconDoc diagnostics
#ifdef _DEBUG
void CIconDoc::AssertValid() const
{
CDocument::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CIconDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CIconDoc commands
BOOL CIconDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// Parse data
GROUP_ICON_HEADER* pgih;
pgih = (GROUP_ICON_HEADER*)m_pData;
m_bIcon = (pgih->wType == 1); // Icon or Cursor?
m_nIconCount = pgih->wCount;
SetIconIndex(0); //Set To First
// TODO: Whys This Here?
UpdateAllViews(NULL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CIconDoc::GetIconInfo(int nIcon, int *pcx, int *pcy,int* pnBase, int *pNumColors /*= NULL*/)
{
GROUP_ICON_RESOURCE* pgrh;
GROUP_CURSOR_RESOURCE* pgcr;
pgrh = (GROUP_ICON_RESOURCE*)(m_pData + sizeof(GROUP_ICON_HEADER));
pgcr = (GROUP_CURSOR_RESOURCE*)(m_pData + sizeof(GROUP_ICON_HEADER));
// Move to icon
if(m_bIcon){
pgrh+=nIcon;
*pnBase = pgrh->wNameOrdinal;
*pcx = pgrh->bWidth;
*pcy = pgrh->bHeight;
if(pNumColors) *pNumColors = (1 << pgrh->wBitCount);
}
else{
pgcr+=nIcon;
*pnBase = pgcr->wNameOrdinal;
*pcx = pgcr->bWidth;
*pcy = pgcr->bHeight / 2;
if(pNumColors) *pNumColors = (1 << pgcr->wBitCount);
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CIconDoc::SetIconIndex(int nIcon)
{
Assert(m_pItemInfo);
CPERes *pPE = m_pItemInfo->GetWorkspaceDoc()->GetResourceParser();
ASSERT(pPE);
if(m_hIcon) DeleteObject(m_hIcon);
DWORD dwRoot = pPE->ResGetRootDir();
DWORD dwNumObj, dwID;
pPE->ResGetNumObj(dwRoot,&dwNumObj);
BOOL bFound = FALSE;
for(DWORD x=0;x<dwNumObj && !bFound;x++){
if(pPE->ResGetObjID(dwRoot,x,&dwID)){
if(dwID == (m_bIcon ? (DWORD_PTR)RT_ICON : (DWORD_PTR)RT_CURSOR)) bFound = TRUE;
}
}
if(!bFound) return FALSE;
x--;
DWORD dwIconDir;
pPE->ResGetDirObj(dwRoot,x,&dwIconDir);
DWORD nBase;
GetIconInfo(nIcon,&m_cx,&m_cy,(int*)&nBase);
pPE->ResGetNumObj(dwIconDir,&dwNumObj);
bFound = FALSE;
for(x=0;x<dwNumObj && !bFound;x++){
if(pPE->ResGetObjID(dwIconDir,x,&dwID)){
if(dwID == nBase) bFound = TRUE;
}
}
if(!bFound) return FALSE;
x--;
DWORD dwLangDir;
pPE->ResGetDirObj(dwIconDir,x,&dwLangDir);
DWORD nSize;
if(!pPE->ResGetObjDataSize(dwLangDir,0,&nSize)) return FALSE;
BYTE* pData = new unsigned char[nSize];
if(!pData) return NULL;
if(!pPE->ResGetObjData(dwLangDir,0,pData)){
delete[] pData;
return FALSE;
}
// Set HotSpot
if(!m_bIcon){
m_ptHot.x = *(WORD*)(pData);
m_ptHot.y = *(WORD*)(pData+2);
}
// Create Icon Or Cursor
m_hIcon = CreateIconFromResourceEx(pData,nSize,m_bIcon,0x00030000,m_cx,m_cy,LR_DEFAULTCOLOR);
delete[] pData;
pData = NULL;
if(m_hIcon) return TRUE;
else return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CMenuDoc
IMPLEMENT_DYNCREATE(CMenuDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CMenuDoc::CMenuDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
CMenuDoc::~CMenuDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CMenuDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CMenuDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CMenuDoc diagnostics
#ifdef _DEBUG
void CMenuDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CMenuDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CMenuDoc commands
BOOL CMenuDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// TODO: Whys This Here?
UpdateAllViews(NULL);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CVersionDoc
IMPLEMENT_DYNCREATE(CVersionDoc, CResBaseDoc)
/////////////////////////////////////////////////////////////////////////////
CVersionDoc::CVersionDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
CVersionDoc::~CVersionDoc()
{
}
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CVersionDoc, CResBaseDoc)
//{{AFX_MSG_MAP(CVersionDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CVersionDoc diagnostics
#ifdef _DEBUG
void CVersionDoc::AssertValid() const
{
CResBaseDoc::AssertValid();
}
/////////////////////////////////////////////////////////////////////////////
void CVersionDoc::Dump(CDumpContext& dc) const
{
CResBaseDoc::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CVersionDoc commands
BOOL CVersionDoc::InitDoc()
{
if(!__super::InitDoc())
{
return FALSE;
}
// TODO: Whys This Here?
UpdateAllViews(NULL);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
| 22.341275 | 98 | 0.458674 |
8b7c60ee28b53894d3d5a881de10a3594f676700 | 2,054 | cpp | C++ | beast_king/server_threaded.cpp | handicraftsman/beast_king | c429d1637ac21e6b2384f514669d9e73b68be1ae | [
"MIT"
] | 1 | 2019-02-19T05:38:43.000Z | 2019-02-19T05:38:43.000Z | beast_king/server_threaded.cpp | handicraftsman/beast_king | c429d1637ac21e6b2384f514669d9e73b68be1ae | [
"MIT"
] | null | null | null | beast_king/server_threaded.cpp | handicraftsman/beast_king | c429d1637ac21e6b2384f514669d9e73b68be1ae | [
"MIT"
] | 1 | 2020-03-04T05:08:03.000Z | 2020-03-04T05:08:03.000Z | #include "server_threaded.hpp"
#include "log.hpp"
#include <chrono>
#include <iostream>
#include <regex>
#include <stdexcept>
#include <string>
#include <thread>
using tcp = boost::asio::ip::tcp;
BeastKing::ServerThreaded::ServerThreaded(AppPtr app, const std::string& addr)
: BeastKing::Server(app, addr)
{}
BeastKing::ServerThreaded::~ServerThreaded() {}
void BeastKing::ServerThreaded::runner() {
std::regex rgx("(.+):(\\d{1,5})");
std::smatch m;
if (!std::regex_match(addr, m, rgx)) {
throw std::runtime_error("Unable to parse address");
}
std::string host = m[1];
int port = std::stoi(m[2]);
std::shared_ptr<boost::asio::io_context> ioc(new boost::asio::io_context { 1 });
tcp::acceptor acceptor(
*ioc.get(),
tcp::acceptor::endpoint_type(
boost::asio::ip::make_address(host),
static_cast<unsigned short>(port)
)
);
BOOST_LOG(app->logger) << "Serving on " << host << ":" << port;
for (;;) {
std::shared_ptr<tcp::socket> sock(new tcp::socket(*ioc.get()));
acceptor.accept(*sock);
std::thread thr([this, ioc, sock] () {
try {
BeastKing::ContextPtr ctx(new BeastKing::Context(ioc, sock));
using tp_t = std::chrono::time_point<std::chrono::system_clock>;
using dr_t = std::chrono::duration<std::chrono::system_clock>;
tp_t t1 = std::chrono::system_clock::now();
app->handle(ctx);
tp_t t2 = std::chrono::system_clock::now();
auto d = t2 - t1;
auto dv = std::chrono::duration_cast<std::chrono::milliseconds>(d);
BOOST_LOG(app->logger)
<< "> "
<< ctx->req->method()
<< " "
<< ctx->url->pathname()
<< " "
<< ctx->res->result_int()
<< " "
<< dv.count()
<< "ms";
} catch (const std::exception& exc) {
char* exc_name = abi::__cxa_demangle(typeid(exc).name(), nullptr, nullptr, nullptr);
std::cout << exc_name << " - " << exc.what() << std::endl;
}
});
thr.detach();
}
} | 25.358025 | 92 | 0.572541 |
8b7e8ed58a6d1116de57374978914c72f171a5d9 | 2,629 | hh | C++ | src/Simulation.hh | arafin-lab/FaultSim-A-Memory-Reliability-Simulator | 4caee9ffd6d8fae2a0db34c743d94107e618723d | [
"BSD-3-Clause"
] | 2 | 2016-04-05T00:57:49.000Z | 2017-03-16T21:54:04.000Z | src/Simulation.hh | arafin-lab/FaultSim-A-Memory-Reliability-Simulator | 4caee9ffd6d8fae2a0db34c743d94107e618723d | [
"BSD-3-Clause"
] | 1 | 2020-04-19T21:40:12.000Z | 2020-04-19T21:41:06.000Z | src/Simulation.hh | arafin-lab/FaultSim-A-Memory-Reliability-Simulator | 4caee9ffd6d8fae2a0db34c743d94107e618723d | [
"BSD-3-Clause"
] | 9 | 2015-09-04T16:36:16.000Z | 2021-12-01T09:15:36.000Z | /*
Copyright (c) 2015, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SIMULATION_HH_
#define SIMULATION_HH_
#include "FaultDomain.hh"
class Simulation {
public:
Simulation( uint64_t interval_t, uint64_t scrub_interval_t, double fit_factor_t, uint test_mode_t, bool debug_mode_t, bool cont_running_t, uint64_t output_bucket_t );
void init( uint64_t max_s );
void reset( void );
void finalize( void );
void simulate( uint64_t max_time, uint64_t n_sims, int verbose, std::string output_file);
virtual uint64_t runOne( uint64_t max_time, int verbose, uint64_t bin_length );
void addDomain( FaultDomain *domain );
void getFaultCounts( uint64_t *pTrans, uint64_t *pPerm );
void resetStats( void );
void printStats( void ); // output end-of-run stats
protected:
uint64_t m_interval;
uint64_t m_iteration;
uint64_t m_scrub_interval;
double m_fit_factor;
uint test_mode;
bool debug_mode;
bool cont_running;
uint64_t m_output_bucket;
uint64_t stat_total_failures, stat_total_sims, stat_sim_seconds;
uint64_t *fail_time_bins;
uint64_t *fail_uncorrectable;
uint64_t *fail_undetectable;
list<FaultDomain*> m_domains;
};
#endif /* SIMULATION_HH_ */
| 49.603774 | 755 | 0.79574 |
8b817af602c7933198707586d5005581f5a6f022 | 3,533 | cpp | C++ | src/Odom.cpp | matheusbg8/aracati2017 | bb00a847e02087f012c9094126120ea5f0a9324c | [
"MIT"
] | 1 | 2022-03-24T04:46:50.000Z | 2022-03-24T04:46:50.000Z | src/Odom.cpp | matheusbg8/aracati2017 | bb00a847e02087f012c9094126120ea5f0a9324c | [
"MIT"
] | null | null | null | src/Odom.cpp | matheusbg8/aracati2017 | bb00a847e02087f012c9094126120ea5f0a9324c | [
"MIT"
] | 1 | 2022-01-01T04:28:31.000Z | 2022-01-01T04:28:31.000Z | #include "Odom.h"
void Odom::publishInitialPose(const ros::Time &time,
double x, double y, double yaw)
{
geometry_msgs::PoseWithCovarianceStamped msg;
msg.header.stamp = time;
msg.header.frame_id = worldFrameId;
msg.pose.pose.position.x = x;
msg.pose.pose.position.y = y;
msg.pose.pose.position.z = 0.0;
tf2::Quaternion quat_tf;
quat_tf.setRPY(0.0,0.0,yaw);
tf2::convert(quat_tf,msg.pose.pose.orientation);
double *m = msg.pose.covariance.elems;
for(uint i = 0; i < 36;i++)
m[i]=0.0;
m[6*0+0] = 0.5*0.5; // CovX
m[6*1+1] = 0.5*0.5; // CovY
m[6*3+3] = 0.4*0.4; // CovYaw
// Publish Initial Pose
pubIniPose.publish(msg);
}
void Odom::CmdVelCallback(const geometry_msgs::TwistStamped &msg)
{
double time = msg.header.stamp.toSec();
// Update odometry with fake local velocity
odom.updateVelocity(time,
msg.twist.linear.x,
msg.twist.linear.y,
msg.twist.angular.z);
double odomX,odomY,odomYaw;
// Predict odometry on time
if(odom.predict(time,odomX,odomY,odomYaw))
{
// Pose msg
geometry_msgs::PoseStamped msg;
msg.header.stamp = ros::Time(time);
msg.header.frame_id = odomFrameId;
msg.pose.position.x = odomX;
msg.pose.position.y = odomY;
msg.pose.position.z = 0.0;
tf2::Quaternion quat_tf;
quat_tf.setRPY(0.0,0.0,odomYaw);
tf2::convert(quat_tf,msg.pose.orientation);
// Publish odom
pubOdom.publish(msg);
// Publish TF
geometry_msgs::TransformStamped tf_odom;
tf_odom.header.stamp = msg.header.stamp;
tf_odom.header.frame_id = odomFrameId;
tf_odom.child_frame_id = baseLinkFrameId;
tf_odom.transform.translation.x = odomX;
tf_odom.transform.translation.y = odomY;
tf_odom.transform.translation.z = 0.0;
tf_odom.transform.rotation = tf2::toMsg(quat_tf);
tfBroadcastOdom.sendTransform(tf_odom);
}
}
void Odom::initROS()
{
subCmdVel = n.subscribe("/cmd_vel",5,
&Odom::CmdVelCallback,this);
pubOdom = n.advertise<geometry_msgs::PoseStamped>("/odom_pose",1);
pubIniPose = n.advertise<geometry_msgs::PoseWithCovarianceStamped>("/initialpose",1);
ros::NodeHandle nh("~");
nh.param<string>("world_frame_id", worldFrameId, "map");
nh.param<string>("odom_frame_id", odomFrameId, "odom");
nh.param<string>("base_frame_id", baseLinkFrameId, "son");
// We assume the initial vehicle position
// is know in order to generate odometry
// so the referential of our ground truth
// and the odom are the same.
// Receiving first vehicle pose
ROS_INFO("Waiting first vehicle pose.");
geometry_msgs::PoseStamped::ConstPtr msg = ros::topic::waitForMessage<geometry_msgs::PoseStamped>("/pose_gt");
if (msg != nullptr)
{
// Get yaw
tf::Quaternion q;
tf::quaternionMsgToTF(msg->pose.orientation,q);
tf::Matrix3x3 mat(q);
double yaw=tf2::getYaw(msg->pose.orientation),
time = msg->header.stamp.toSec(),
x = msg->pose.position.x,
y = msg->pose.position.y;
odom.setInitialPose(time,x,y,yaw);
publishInitialPose(msg->header.stamp,
x,y,yaw);
}
else
{
ROS_ERROR("No initial position received!");
ros::Time time = ros::Time::now();
odom.setInitialPose(time.toSec(),
0.0, 0.0,0.0);
publishInitialPose(msg->header.stamp,
0.0,0.0,0.0);
}
}
Odom::Odom()
{
initROS();
}
void Odom::start()
{
ros::spin();
}
| 25.601449 | 112 | 0.638834 |
8b848057633509ceb19b8e8b0c955831243b8e61 | 4,455 | cpp | C++ | module_02/ex02/Fixed.cpp | laisarena/CPP_piscine | 47831fa443116d2b37e1081a3eddf8ca40fc954f | [
"MIT"
] | null | null | null | module_02/ex02/Fixed.cpp | laisarena/CPP_piscine | 47831fa443116d2b37e1081a3eddf8ca40fc954f | [
"MIT"
] | null | null | null | module_02/ex02/Fixed.cpp | laisarena/CPP_piscine | 47831fa443116d2b37e1081a3eddf8ca40fc954f | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfrasson <lfrasson@student.42sp.org.b +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/27 10:43:50 by lfrasson #+# #+# */
/* Updated: 2021/11/01 21:18:24 by lfrasson ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fixed.hpp"
Fixed::Fixed(void) : _fixedPointValue(0)
{
return;
}
Fixed::Fixed(int const integerValue)
{
this->_fixedPointValue = integerValue << this->_numberOfFractionalBits;
}
Fixed::Fixed(float const floatValue)
{
this->_fixedPointValue = roundf(floatValue *
(1 << this->_numberOfFractionalBits));
}
Fixed::Fixed(Fixed const &object)
{
*this = object;
}
Fixed::~Fixed(void)
{
return;
}
int Fixed::getRawBits(void) const
{
return this->_fixedPointValue;
}
void Fixed::setRawBits(int const raw)
{
this->_fixedPointValue = raw;
}
float Fixed::toFloat(void) const
{
float floatValue;
int fixedPointConverter;
fixedPointConverter = 1 << this->_numberOfFractionalBits;
floatValue = (float)this->_fixedPointValue / (float)fixedPointConverter;
return floatValue;
}
int Fixed::toInt(void) const
{
return this->_fixedPointValue >> this->_numberOfFractionalBits;
}
Fixed &Fixed::operator=(Fixed const &rightSideObject)
{
this->_fixedPointValue = rightSideObject.getRawBits();
return *this;
}
Fixed Fixed::operator+(Fixed const &rightSideObject)
{
Fixed result(*this);
result.setRawBits(result.getRawBits() + rightSideObject.getRawBits());
return result;
}
Fixed Fixed::operator-(Fixed const &rightSideObject)
{
Fixed result(*this);
result.setRawBits(result.getRawBits() - rightSideObject.getRawBits());
return result;
}
Fixed Fixed::operator*(Fixed const &rightSideObject)
{
Fixed result(*this);
int rawBits;
rawBits = result.getRawBits() * rightSideObject.getRawBits();
result.setRawBits(rawBits >> this->_numberOfFractionalBits);
return result;
}
Fixed Fixed::operator/(Fixed const &rightSideObject)
{
Fixed result(*this);
int rawBits;
rawBits = result.getRawBits()
/ (rightSideObject.getRawBits() >> this->_numberOfFractionalBits);
result.setRawBits(rawBits);
return result;
}
Fixed &Fixed::operator++(void)
{
this->_fixedPointValue++;
return *this;
}
Fixed Fixed::operator++(int)
{
Fixed temp = *this;
this->_fixedPointValue++;
return temp;
}
Fixed &Fixed::operator--(void)
{
this->_fixedPointValue--;
return *this;
}
Fixed Fixed::operator--(int)
{
Fixed temp = *this;
this->_fixedPointValue--;
return temp;
}
bool Fixed::operator>(Fixed const &rightSideObject) const
{
return this->_fixedPointValue > rightSideObject.getRawBits();
}
bool Fixed::operator<(Fixed const &rightSideObject) const
{
return this->_fixedPointValue < rightSideObject.getRawBits();
}
bool Fixed::operator>=(Fixed const &rightSideObject) const
{
return this->_fixedPointValue >= rightSideObject.getRawBits();
}
bool Fixed::operator<=(Fixed const &rightSideObject) const
{
return this->_fixedPointValue <= rightSideObject.getRawBits();
}
bool Fixed::operator==(Fixed const &rightSideObject) const
{
return this->_fixedPointValue == rightSideObject.getRawBits();
}
bool Fixed::operator!=(Fixed const &rightSideObject) const
{
return this->_fixedPointValue != rightSideObject.getRawBits();
}
Fixed &Fixed::min(Fixed &value1, Fixed &value2)
{
if (value1 > value2)
return value2;
return value1;
}
Fixed const &Fixed::min(Fixed const &value1, Fixed const &value2)
{
if (value1 > value2)
return value2;
return value1;
}
Fixed &Fixed::max(Fixed &value1, Fixed &value2)
{
if (value1 < value2)
return value2;
return value1;
}
Fixed const &Fixed::max(Fixed const &value1, Fixed const &value2)
{
if (value1 < value2)
return value2;
return value1;
}
std::ostream & operator<<(std::ostream &output, Fixed const &rightSideObject)
{
output << rightSideObject.toFloat();
return output;
}
| 22.5 | 80 | 0.60853 |
8b8596a1d5c2715ce3b0fb6ccb81447b0362935d | 5,034 | hpp | C++ | SDK/ARKSurvivalEvolved_DinoAttackStateFollowSpline_parameters.hpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 10 | 2020-02-17T19:08:46.000Z | 2021-07-31T11:07:19.000Z | SDK/ARKSurvivalEvolved_DinoAttackStateFollowSpline_parameters.hpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 9 | 2020-02-17T18:15:41.000Z | 2021-06-06T19:17:34.000Z | SDK/ARKSurvivalEvolved_DinoAttackStateFollowSpline_parameters.hpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 3 | 2020-07-22T17:42:07.000Z | 2021-06-19T17:16:13.000Z | #pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_DinoAttackStateFollowSpline_classes.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.OnTickEvent
struct UDinoAttackStateFollowSpline_C_OnTickEvent_Params
{
float* DeltaSeconds; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.OnBeginEvent
struct UDinoAttackStateFollowSpline_C_OnBeginEvent_Params
{
class UPrimalAIState** InParentState; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.ShouldSkipIntervalCheckEvent
struct UDinoAttackStateFollowSpline_C_ShouldSkipIntervalCheckEvent_Params
{
bool ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.EndAnimationStateEvent
struct UDinoAttackStateFollowSpline_C_EndAnimationStateEvent_Params
{
struct FName* CustomEventName; // (Parm, ZeroConstructor, IsPlainOldData)
TEnumAsByte<ENetRole>* Role; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.OnChildStateEndedEvent
struct UDinoAttackStateFollowSpline_C_OnChildStateEndedEvent_Params
{
class UPrimalAIState** PrimalAIState; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.StartAnimationStateEvent
struct UDinoAttackStateFollowSpline_C_StartAnimationStateEvent_Params
{
struct FName* CustomEventName; // (Parm, ZeroConstructor, IsPlainOldData)
TEnumAsByte<ENetRole>* Role; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.TickAnimationStateEvent
struct UDinoAttackStateFollowSpline_C_TickAnimationStateEvent_Params
{
float* DeltaTime; // (Parm, ZeroConstructor, IsPlainOldData)
struct FName* CustomEventName; // (Parm, ZeroConstructor, IsPlainOldData)
TEnumAsByte<ENetRole>* Role; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.OnCanUseStateEvent
struct UDinoAttackStateFollowSpline_C_OnCanUseStateEvent_Params
{
bool ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.OnEndEvent
struct UDinoAttackStateFollowSpline_C_OnEndEvent_Params
{
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.TickRangedState
struct UDinoAttackStateFollowSpline_C_TickRangedState_Params
{
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.GotoNextSpline
struct UDinoAttackStateFollowSpline_C_GotoNextSpline_Params
{
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.UpgradePawnAcceleration
struct UDinoAttackStateFollowSpline_C_UpgradePawnAcceleration_Params
{
bool Upgrade; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.FindDragonSplines
struct UDinoAttackStateFollowSpline_C_FindDragonSplines_Params
{
bool found; // (Parm, OutParm, ZeroConstructor, IsPlainOldData)
};
// Function DinoAttackStateFollowSpline.DinoAttackStateFollowSpline_C.ExecuteUbergraph_DinoAttackStateFollowSpline
struct UDinoAttackStateFollowSpline_C_ExecuteUbergraph_DinoAttackStateFollowSpline_Params
{
int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 47.046729 | 173 | 0.617004 |
8b8c4a360560e547f838d7eb2d00d5fec99f42d4 | 6,760 | cpp | C++ | source/Irrlicht/rtc/mediahandlerelement.cpp | MagicAtom/irrlicht-ce | b94ea7f97d7d0d3000d5a8c9c7c712debef1e55d | [
"IJG"
] | null | null | null | source/Irrlicht/rtc/mediahandlerelement.cpp | MagicAtom/irrlicht-ce | b94ea7f97d7d0d3000d5a8c9c7c712debef1e55d | [
"IJG"
] | null | null | null | source/Irrlicht/rtc/mediahandlerelement.cpp | MagicAtom/irrlicht-ce | b94ea7f97d7d0d3000d5a8c9c7c712debef1e55d | [
"IJG"
] | null | null | null | /**
* Copyright (c) 2020 Filip Klembara (in2core)
*
* This library 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.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if RTC_ENABLE_MEDIA
#include "mediahandlerelement.hpp"
#include "impl/internals.hpp"
#include <cassert>
namespace rtc {
ChainedMessagesProduct make_chained_messages_product() {
return std::make_shared<std::vector<binary_ptr>>();
}
ChainedMessagesProduct make_chained_messages_product(message_ptr msg) {
std::vector<binary_ptr> msgs = {msg};
return std::make_shared<std::vector<binary_ptr>>(msgs);
}
ChainedOutgoingProduct::ChainedOutgoingProduct(ChainedMessagesProduct messages, message_ptr control)
: messages(messages), control(control) {}
ChainedIncomingProduct::ChainedIncomingProduct(ChainedMessagesProduct incoming,
ChainedMessagesProduct outgoing)
: incoming(incoming), outgoing(outgoing) {}
ChainedIncomingControlProduct::ChainedIncomingControlProduct(
message_ptr incoming, optional<ChainedOutgoingProduct> outgoing)
: incoming(incoming), outgoing(outgoing) {}
MediaHandlerElement::MediaHandlerElement() {}
void MediaHandlerElement::removeFromChain() {
if (upstream) {
upstream->downstream = downstream;
}
if (downstream) {
downstream->upstream = upstream;
}
upstream = nullptr;
downstream = nullptr;
}
void MediaHandlerElement::recursiveRemoveChain() {
if (downstream) {
// `recursiveRemoveChain` removes last strong reference to downstream element
// we need to keep strong reference to prevent deallocation of downstream element
// during `recursiveRemoveChain`
auto strongDownstreamPtr = downstream;
downstream->recursiveRemoveChain();
}
removeFromChain();
}
optional<ChainedOutgoingProduct>
MediaHandlerElement::processOutgoingResponse(ChainedOutgoingProduct messages) {
if (messages.messages) {
if (upstream) {
auto msgs = upstream->formOutgoingBinaryMessage(
ChainedOutgoingProduct(messages.messages, messages.control));
if (msgs.has_value()) {
return msgs.value();
} else {
LOG_ERROR << "Generating outgoing message failed";
return nullopt;
}
} else {
return messages;
}
} else if (messages.control) {
if (upstream) {
auto control = upstream->formOutgoingControlMessage(messages.control);
if (control) {
return ChainedOutgoingProduct(nullptr, control);
} else {
LOG_ERROR << "Generating outgoing control message failed";
return nullopt;
}
} else {
return messages;
}
} else {
return ChainedOutgoingProduct();
}
}
void MediaHandlerElement::prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing,
std::function<bool(ChainedOutgoingProduct)> send) {
if (outgoing.has_value()) {
auto message = outgoing.value();
auto response = processOutgoingResponse(message);
if (response.has_value()) {
if (!send(response.value())) {
LOG_DEBUG << "Send failed";
}
} else {
LOG_DEBUG << "No response to send";
}
}
}
message_ptr
MediaHandlerElement::formIncomingControlMessage(message_ptr message,
std::function<bool(ChainedOutgoingProduct)> send) {
assert(message);
auto product = processIncomingControlMessage(message);
prepareAndSendResponse(product.outgoing, send);
if (product.incoming) {
if (downstream) {
return downstream->formIncomingControlMessage(product.incoming, send);
} else {
return product.incoming;
}
} else {
return nullptr;
}
}
ChainedMessagesProduct
MediaHandlerElement::formIncomingBinaryMessage(ChainedMessagesProduct messages,
std::function<bool(ChainedOutgoingProduct)> send) {
assert(messages && !messages->empty());
auto product = processIncomingBinaryMessage(messages);
prepareAndSendResponse(product.outgoing, send);
if (product.incoming) {
if (downstream) {
return downstream->formIncomingBinaryMessage(product.incoming, send);
} else {
return product.incoming;
}
} else {
return nullptr;
}
}
message_ptr MediaHandlerElement::formOutgoingControlMessage(message_ptr message) {
assert(message);
auto newMessage = processOutgoingControlMessage(message);
assert(newMessage);
if (!newMessage) {
LOG_ERROR << "Failed to generate outgoing message";
return nullptr;
}
if (upstream) {
return upstream->formOutgoingControlMessage(newMessage);
} else {
return newMessage;
}
}
optional<ChainedOutgoingProduct>
MediaHandlerElement::formOutgoingBinaryMessage(ChainedOutgoingProduct product) {
assert(product.messages && !product.messages->empty());
auto newProduct = processOutgoingBinaryMessage(product.messages, product.control);
assert(!product.control || newProduct.control);
assert(newProduct.messages && !newProduct.messages->empty());
if (product.control && !newProduct.control) {
LOG_ERROR << "Outgoing message must not remove control message";
return nullopt;
}
if (!newProduct.messages || newProduct.messages->empty()) {
LOG_ERROR << "Failed to generate message";
return nullopt;
}
if (upstream) {
return upstream->formOutgoingBinaryMessage(newProduct);
} else {
return newProduct;
}
}
ChainedIncomingControlProduct
MediaHandlerElement::processIncomingControlMessage(message_ptr messages) {
return {messages};
}
message_ptr MediaHandlerElement::processOutgoingControlMessage(message_ptr messages) {
return messages;
}
ChainedIncomingProduct
MediaHandlerElement::processIncomingBinaryMessage(ChainedMessagesProduct messages) {
return {messages};
}
ChainedOutgoingProduct
MediaHandlerElement::processOutgoingBinaryMessage(ChainedMessagesProduct messages,
message_ptr control) {
return {messages, control};
}
shared_ptr<MediaHandlerElement>
MediaHandlerElement::chainWith(shared_ptr<MediaHandlerElement> upstream) {
assert(this->upstream == nullptr);
assert(upstream->downstream == nullptr);
this->upstream = upstream;
upstream->downstream = shared_from_this();
return upstream;
}
} // namespace rtc
#endif /* RTC_ENABLE_MEDIA */
| 30.45045 | 100 | 0.735503 |
8b8cadbface4d6ed93e5ac29f89a3ad868911280 | 2,771 | cc | C++ | tool/SecVerilog-1.0/SecVerilog/symbol_search.cc | gokulprasath7c/secure_i2c_using_ift | 124384983ba70e8164b7217db70c43dfdf302d4b | [
"MIT"
] | 1 | 2019-01-28T21:23:37.000Z | 2019-01-28T21:23:37.000Z | tool/SecVerilog-1.0/SecVerilog/symbol_search.cc | gokulprasath7c/secure_i2c_using_ift | 124384983ba70e8164b7217db70c43dfdf302d4b | [
"MIT"
] | null | null | null | tool/SecVerilog-1.0/SecVerilog/symbol_search.cc | gokulprasath7c/secure_i2c_using_ift | 124384983ba70e8164b7217db70c43dfdf302d4b | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "netlist.h"
# include "netmisc.h"
# include <cassert>
/*
* Search for the hierarchical name.
*/
NetScope*symbol_search(const LineInfo*li, Design*des, NetScope*scope,
pform_name_t path,
NetNet*&net,
const NetExpr*&par,
NetEvent*&eve,
const NetExpr*&ex1, const NetExpr*&ex2)
{
assert(scope);
bool hier_path = false;
/* Get the tail name of the object we are looking for. */
perm_string key = peek_tail_name(path);
path.pop_back();
/* Initialize output argument to cleared. */
net = 0;
par = 0;
eve = 0;
/* If the path has a scope part, then search for the specified
scope that we are supposed to search. */
if (! path.empty()) {
list<hname_t> path_list = eval_scope_path(des, scope, path);
assert(path_list.size() <= path.size());
// If eval_scope_path returns a short list, then some
// part of the scope was not found. Abort.
if (path_list.size() < path.size())
return 0;
scope = des->find_scope(scope, path_list);
if (scope && scope->is_auto() && li) {
cerr << li->get_fileline() << ": error: Hierarchical "
"reference to automatically allocated item "
"`" << key << "' in path `" << path << "'" << endl;
des->errors += 1;
}
hier_path = true;
}
while (scope) {
if ( (net = scope->find_signal(key)) )
return scope;
if ( (eve = scope->find_event(key)) )
return scope;
if ( (par = scope->get_parameter(key, ex1, ex2)) )
return scope;
/* We can't look up if we are at the enclosing module scope
* or if a hierarchical path was given. */
if ((scope->type() == NetScope::MODULE) || hier_path)
scope = 0;
else
scope = scope->parent();
}
return 0;
}
| 30.788889 | 79 | 0.600505 |
8b8f7fbb4a0a214789c515488ab2a453f8c5f6f4 | 5,434 | cpp | C++ | test/lexer/number.cpp | p-ranav/jsonlint | 2d1428274f05fe3d443cf8642c39d65b6b7025ac | [
"MIT"
] | 28 | 2019-11-15T09:11:17.000Z | 2021-09-05T01:44:12.000Z | test/lexer/number.cpp | p-ranav/jsonlint | 2d1428274f05fe3d443cf8642c39d65b6b7025ac | [
"MIT"
] | 1 | 2019-11-27T14:33:32.000Z | 2019-11-27T14:33:32.000Z | test/lexer/number.cpp | p-ranav/jsonlint | 2d1428274f05fe3d443cf8642c39d65b6b7025ac | [
"MIT"
] | 1 | 2019-11-18T17:52:27.000Z | 2019-11-18T17:52:27.000Z | #include <catch2/catch.hpp>
#include <clocale>
#include <jsonlint/lexer.hpp>
using namespace jsonlint;
TEST_CASE("Integer '0'", "[lexer]") {
std::string filename = "";
std::string source = "0";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "0");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 2);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Integer '5'", "[lexer]") {
std::string filename = "";
std::string source = "5";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "5");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 2);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Integer '42'", "[lexer]") {
std::string filename = "";
std::string source = "42";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "42");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 3);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Integer '-96'", "[lexer]") {
std::string filename = "";
std::string source = "-96";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 3);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::MINUS);
REQUIRE(tokens[0].literal == "-");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 2);
REQUIRE(tokens[1].type == TokenType::NUMBER);
REQUIRE(tokens[1].literal == "96");
REQUIRE(tokens[2].filename == "");
REQUIRE(tokens[2].line == 1);
REQUIRE(tokens[2].cursor_start == 4);
REQUIRE(tokens[2].type == TokenType::EOF_);
REQUIRE(tokens[2].literal == "");
}
TEST_CASE("Double '0.0'", "[lexer]") {
std::string filename = "";
std::string source = "0.0";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "0.0");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 4);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Double '3.14'", "[lexer]") {
std::string filename = "";
std::string source = "3.14";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "3.14");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 5);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Double '2.71828'", "[lexer]") {
std::string filename = "";
std::string source = "2.71828";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "2.71828");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 8);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
TEST_CASE("Double '1.61803398875'", "[lexer]") {
std::string filename = "";
std::string source = "1.61803398875";
Lexer lexer{"", 0, "", 1, 1};
lexer.filename = filename;
lexer.source = source;
auto tokens = Tokenize(lexer);
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0].filename == "");
REQUIRE(tokens[0].line == 1);
REQUIRE(tokens[0].cursor_start == 1);
REQUIRE(tokens[0].type == TokenType::NUMBER);
REQUIRE(tokens[0].literal == "1.61803398875");
REQUIRE(tokens[1].filename == "");
REQUIRE(tokens[1].line == 1);
REQUIRE(tokens[1].cursor_start == 14);
REQUIRE(tokens[1].type == TokenType::EOF_);
REQUIRE(tokens[1].literal == "");
}
| 31.964706 | 48 | 0.622194 |
8b94bb6ce666de5540e96fc22118d5ca7855910e | 8,154 | cpp | C++ | src/test/key_tests.cpp | gwangjin2/gwangcoin-core | 588e357e13c385906729d9078b796dd740745445 | [
"MIT"
] | null | null | null | src/test/key_tests.cpp | gwangjin2/gwangcoin-core | 588e357e13c385906729d9078b796dd740745445 | [
"MIT"
] | null | null | null | src/test/key_tests.cpp | gwangjin2/gwangcoin-core | 588e357e13c385906729d9078b796dd740745445 | [
"MIT"
] | null | null | null | #include <boost/test/unit_test.hpp>
#include <string>
#include <vector>
#include "key.h"
#include "base58.h"
#include "uint256.h"
#include "util.h"
using namespace std;
/*
* make from gwangcoin/contrib/pycoin
~/Projects/gwangcoin/contrib/pycoin $ ku -nGW 1
input : 1
network : Gwangcoin mainnet
netcode : GW
secret exponent : 1
hex : 1
wif : eRhXeqAbHtnnXvMLvArwR2wDxvq3CsbvBmbyZvexE4g5FFMGBQju
uncompressed : 9UoLdfZ5be7J7Z2SMf2oK8gvgrogUACY5hvEiu2oVnh7rYK5xSM
public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240
public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424
x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
y parity : even
key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\
483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6
uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5
Gwangcoin address : sUvfdj9d7cnHNVcpHDkASXSKoAeTsKojEm
Gwangcoin address uncompressed : sXXmeff54XxS9YfnPVmxNu5PPojcrHpixP
~/Projects/gwangcoin/contrib/pycoin $ ku -nGW 2
input : 2
network : Gwangcoin mainnet
netcode : GW
secret exponent : 2
hex : 2
wif : eRhXeqAbHtnnXvMLvArwR2wDxvq3CsbvBmbyZvexE4g5FkG9gW1b
uncompressed : 9UoLdfZ5be7J7Z2SMf2oK8gvgrogUACY5hvEiu2oVnh7rcUUCbZ
public pair x : 89565891926547004231252920425935692360644145829622209833684329913297188986597
public pair y : 12158399299693830322967808612713398636155367887041628176798871954788371653930
x as hex : c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
y as hex : 1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
y parity : even
key pair as sec : 02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
uncompressed : 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\
1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
hash160 : 06afd46bcdfd22ef94ac122aa11f241244a37ecc
uncompressed : d6c8e828c1eca1bba065e1b83e1dc2a36e387a42
Gwangcoin address : sJrkmbH9318FAcZPw2DatoBUd3qvCt6D55
Gwangcoin address uncompressed : sdq5Mt131X81FgRgRj8gHihsw7fMS1MFu8
*/
static const string strSecret1C ("eRhXeqAbHtnnXvMLvArwR2wDxvq3CsbvBmbyZvexE4g5FFMGBQju");
static const string strSecret1 ("9UoLdfZ5be7J7Z2SMf2oK8gvgrogUACY5hvEiu2oVnh7rYK5xSM");
static const string strSecret2C ("eRhXeqAbHtnnXvMLvArwR2wDxvq3CsbvBmbyZvexE4g5FkG9gW1b");
static const string strSecret2 ("9UoLdfZ5be7J7Z2SMf2oK8gvgrogUACY5hvEiu2oVnh7rcUUCbZ");
static const CBitcoinAddress addr1C("sUvfdj9d7cnHNVcpHDkASXSKoAeTsKojEm");
static const CBitcoinAddress addr1 ("sXXmeff54XxS9YfnPVmxNu5PPojcrHpixP");
static const CBitcoinAddress addr2C("sJrkmbH9318FAcZPw2DatoBUd3qvCt6D55");
static const CBitcoinAddress addr2 ("sdq5Mt131X81FgRgRj8gHihsw7fMS1MFu8");
static const string strAddressBad("LRjyUS2uuieEPkhZNdQz8hE5YycxVEqSXA");
#ifdef KEY_TESTS_DUMPINFO
void dumpKeyInfo(uint256 privkey)
{
CKey key;
key.resize(32);
memcpy(&secret[0], &privkey, 32);
vector<unsigned char> sec;
sec.resize(32);
memcpy(&sec[0], &secret[0], 32);
printf(" * secret (hex): %s\n", HexStr(sec).c_str());
for (int nCompressed=0; nCompressed<2; nCompressed++)
{
bool fCompressed = nCompressed == 1;
printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed");
CBitcoinSecret bsecret;
bsecret.SetSecret(secret, fCompressed);
printf(" * secret (base58): %s\n", bsecret.ToString().c_str());
CKey key;
key.SetSecret(secret, fCompressed);
vector<unsigned char> vchPubKey = key.GetPubKey();
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
}
}
#endif
BOOST_AUTO_TEST_SUITE(key_tests)
BOOST_AUTO_TEST_CASE(key_test1)
{
CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1;
BOOST_CHECK( bsecret1.SetString (strSecret1));
BOOST_CHECK( bsecret2.SetString (strSecret2));
BOOST_CHECK( bsecret1C.SetString(strSecret1C));
BOOST_CHECK( bsecret2C.SetString(strSecret2C));
BOOST_CHECK(!baddress1.SetString(strAddressBad));
CKey key1 = bsecret1.GetKey();
BOOST_CHECK(key1.IsCompressed() == false);
CKey key2 = bsecret2.GetKey();
BOOST_CHECK(key2.IsCompressed() == false);
CKey key1C = bsecret1C.GetKey();
BOOST_CHECK(key1C.IsCompressed() == true);
CKey key2C = bsecret2C.GetKey();
BOOST_CHECK(key1C.IsCompressed() == true);
CPubKey pubkey1 = key1. GetPubKey();
CPubKey pubkey2 = key2. GetPubKey();
CPubKey pubkey1C = key1C.GetPubKey();
CPubKey pubkey2C = key2C.GetPubKey();
BOOST_CHECK(addr1.Get() == CTxDestination(pubkey1.GetID()));
BOOST_CHECK(addr2.Get() == CTxDestination(pubkey2.GetID()));
BOOST_CHECK(addr1C.Get() == CTxDestination(pubkey1C.GetID()));
BOOST_CHECK(addr2C.Get() == CTxDestination(pubkey2C.GetID()));
for (int n=0; n<16; n++)
{
string strMsg = strprintf("Very secret message %i: 11", n);
uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
// normal signatures
vector<unsigned char> sign1, sign2, sign1C, sign2C;
BOOST_CHECK(key1.Sign (hashMsg, sign1));
BOOST_CHECK(key2.Sign (hashMsg, sign2));
BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C));
// compact signatures (with key recovery)
vector<unsigned char> csign1, csign2, csign1C, csign2C;
BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
CPubKey rkey1, rkey2, rkey1C, rkey2C;
BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1));
BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2));
BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C));
BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C));
BOOST_CHECK(rkey1 == pubkey1);
BOOST_CHECK(rkey2 == pubkey2);
BOOST_CHECK(rkey1C == pubkey1C);
BOOST_CHECK(rkey2C == pubkey2C);
}
}
BOOST_AUTO_TEST_SUITE_END()
| 41.815385 | 110 | 0.680034 |
8b973a205c4634d3ce7ea4c375189c9bbe8e0733 | 15,254 | cpp | C++ | src/OE_Error.cpp | antsouchlos/OxygenEngine2 | 5a123a2dacbc3b66ba9e97b9e5db7d8c17490ddb | [
"MIT"
] | null | null | null | src/OE_Error.cpp | antsouchlos/OxygenEngine2 | 5a123a2dacbc3b66ba9e97b9e5db7d8c17490ddb | [
"MIT"
] | 22 | 2020-05-19T18:18:45.000Z | 2022-03-31T12:11:08.000Z | src/OE_Error.cpp | antsouchlos/OxygenEngine2 | 5a123a2dacbc3b66ba9e97b9e5db7d8c17490ddb | [
"MIT"
] | null | null | null | #include <OE_Error.h>
#include <OE_TaskManager.h>
#include <Events/OE_Event.h>
#include <types/OE_Libs.h>
using namespace std;
// This is where events' error handling is happening
int OE_Event::internal_call(){
/***************************/
///generic handling
if (!this->has_init_){
this->task_ = OE_Task(this->name_, 0, 0, SDL_GetTicks());
this->has_init_ = true;
}
task_.update();
try {
func_(task_, name_);
}
catch(oe::api_error& e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in event: '" + this->name_ + "', event invocation counter: " + std::to_string(this->task_.GetCounter()) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(csl::parser_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in event: '" + this->name_ + "', event invocation counter: " + std::to_string(this->task_.GetCounter()) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(csl::interpreter_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in event: '" + this->name_ + "', event invocation counter: " + std::to_string(this->task_.GetCounter()) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(std::exception& e){
std::string error_str = "[OE Error] std::exception variant thrown in event: '" + this->name_ + "', event invocation counter: " + std::to_string(this->task_.GetCounter()) + "\n";
error_str += "\t" + string(e.what()) + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(...){
std::string error_str = "[OE Error] Exception thrown in event: '" + this->name_ + "', event invocation counter: " + std::to_string(this->task_.GetCounter());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
return 0;
/**************************/
}
// error handling functions
int OE_TaskManager::tryRun_unsync_thread(OE_UnsyncThreadData* actual_data){
int output = 1;
OE_Task unsync_task = OE_Task(actual_data->name, 0, 0, actual_data->taskMgr->getTicks());
try{
output = actual_data->func(unsync_task);
}
catch(oe::api_error& e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in unsync thread: '" + unsync_task.GetName() + "'" +"\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(csl::parser_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in unsync thread: '" + unsync_task.GetName() + "'" +"\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(csl::interpreter_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in unsync thread: '" + unsync_task.GetName() + "'" +"\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(oe::networking_error& e){
std::string error_str = "[SLC Error] " + e.name_ + " thrown in unsync thread: '" + unsync_task.GetName() + "'" +"\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(std::exception& e){
std::string error_str = "[OE Error] std::exception variant thrown in unsync thread: '" + unsync_task.GetName() + "'" +"\n";
error_str += "\t" + string(e.what()) + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch (...){
std::string error_str = "[OE Error] Exception thrown in unsync thread: '" + unsync_task.GetName() + "'";
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
return output;
}
int OE_TaskManager::tryRun_task(const std::string& name, OE_Task& task){
int output = 0;
try{
if (this->threads[name].functions[task.name] != nullptr)
output = this->threads[name].functions[task.name](task);
}
catch(oe::api_error& e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in task: '" + task.name + "', thread: '" + name;
error_str += "', invocation: " + std::to_string(task.counter) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
output = 1;
}
catch(csl::parser_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in task: '" + task.name + "', thread: '" + name;
error_str += "', invocation: " + std::to_string(task.counter) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
output = 1;
}
catch(csl::interpreter_error& e){
std::string error_str = "[CSL Error] " + e.name_ + " thrown in task: '" + task.name + "', thread: '" + name;
error_str += "', invocation: " + std::to_string(task.counter) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
output = 1;
}
catch(std::exception& e){
std::string error_str = "[OE Error] " + string(typeid(e).name()) + " thrown in task: '" + task.name + "', thread: '" + name;
error_str += "', invocation: " + std::to_string(task.counter) + "\n";
error_str += "\t" + string(e.what()) + "\n";
cout << error_str;
OE_WriteToLog(error_str);
output = 1;
}
catch(...){
/// universal error handling. will catch any exception
/// feel free to add specific handling for specific errors
string outputa = string("[OE Error] Exception thrown in task: '" + task.name + "', thread: '" + name);
outputa += "', invocation: " + std::to_string(task.counter);
cout << outputa << endl;
OE_WriteToLog(outputa + "\n");
output = 1;
}
return output;
}
void OE_TaskManager::tryRun_physics_updateMultiThread(const std::string &name, const int& comp_threads_copy){
try{
this->physics->updateMultiThread(&this->threads[name].physics_task, comp_threads_copy);
}
catch(oe::api_error& e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in updateMultiThread in thread: '" + name + "', thread_num: " + std::to_string(comp_threads_copy);
error_str += ", invocation: " + std::to_string(this->threads[name].physics_task.counter) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(oe::physics_error& e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in updateMultiThread in thread: '" + name + "', thread_num: " + std::to_string(comp_threads_copy);
error_str += ", invocation: " + std::to_string(this->threads[name].physics_task.counter) + "\n";
error_str += "\t" + e.what() + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(std::exception& e){
std::string error_str = "[OE Error] " + string(typeid(e).name()) + " thrown in updateMultiThread in thread: '" + name + "', thread_num: " + std::to_string(comp_threads_copy);
error_str += ", invocation: " + std::to_string(this->threads[name].physics_task.counter) + "\n";
error_str += "\t" + string(e.what()) + "\n";
cout << error_str;
OE_WriteToLog(error_str);
}
catch(...){
/// universal error handling. will catch any exception
/// feel free to add specific handling for specific errors
auto task = this->threads[name].physics_task;
string outputa = string("[OE Error] Physics exception thrown in updateMultiThread in thread: '" + name + "', thread_num: " + std::to_string(comp_threads_copy));
outputa += ", invocation: " + std::to_string(task.counter);
cout << outputa << endl;
OE_WriteToLog(outputa + "\n");
}
}
bool OE_TaskManager::tryRun_renderer_updateSingleThread(){
bool output = false;
try{
output = this->renderer->updateSingleThread();
}
catch(oe::api_error &e){
std::string error_str = "[NRE Error] " + e.name_ + " thrown in updateSingleThread, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(oe::renderer_error &e){
std::string error_str = "[NRE Error] " + e.name_ + " thrown in updateSingleThread, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[NRE Error] " + string(typeid(e).name()) + " thrown in updateSingleThread, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[NRE Error] Renderer exception thrown in updateSingleThread, invocation: " + std::to_string(this->countar);
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
return output;
}
void OE_TaskManager::tryRun_renderer_updateData(){
try{
this->renderer->updateData();
}
catch(oe::api_error &e){
std::string error_str = "[NRE Error] " + e.name_ + " thrown in updateData, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(oe::renderer_error &e){
std::string error_str = "[NRE Error] " + e.name_ + " thrown in updateData, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[NRE Error] " + string(typeid(e).name()) + " thrown in updateData, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[NRE Error] Renderer exception thrown in updateData, invocation: " + std::to_string(this->countar);
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
}
bool OE_TaskManager::tryRun_winsys_update(){
bool output = true;
try{
output = this->window->update();
}
catch(oe::winsys_error &e){
std::string error_str = "[OE WINSYS Error] " + e.name_ + " thrown in winsys update, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[OE WINSYS Error] " + string(typeid(e).name()) + " thrown in winsys update, invocation: " + std::to_string(this->countar);
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[OE WINSYS Error] Exception thrown in winsys update, invocation: " + std::to_string(this->countar);
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
return output;
}
void OE_TaskManager::tryRun_winsys_init(int x, int y, std::string titlea, bool fullscreen, void* params){
try{
this->window->init(x, y, titlea, fullscreen, params);
}
catch(oe::winsys_error &e){
std::string error_str = "[OE WINSYS Error] " + e.name_ + " thrown in window system initialization";
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[OE WINSYS Error] " + string(typeid(e).name()) + " thrown in window system initialization";
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[OE WINSYS Error] Could not initialize window system due to thrown exception in window->init()";
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
}
void OE_TaskManager::tryRun_physics_init(){
try{
this->physics->init();
}
catch(oe::physics_error &e){
std::string error_str = "[OE Error] " + e.name_ + " thrown in physics engine initialization";
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[OE Error] " + string(typeid(e).name()) + " thrown in physics engine initialization";
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[OE Error] Could not initialize physics engine due to thrown exception in physics->init()";
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
}
void OE_TaskManager::tryRun_renderer_init(){
try{
this->renderer->init();
}
catch(oe::renderer_error &e){
std::string error_str = "[NRE Error] " + e.name_ + " thrown in renderer initialization";
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[NRE Error] " + string(typeid(e).name()) + " thrown in renderer initialization";
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[NRE Error] Could not initialize renderer due to thrown exception in renderer->init()";
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
}
void OE_TaskManager::tryRun_network_init(){
try{
this->network->init();
}
catch(oe::networking_error &e){
std::string error_str = "[SLC Error] " + e.name_ + " thrown in networking initialization";
error_str += "\n\t" + e.what();
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(std::exception &e){
std::string error_str = "[SLC Error] " + string(typeid(e).name()) + " thrown in networking initialization";
error_str += "\n\t" + string(e.what());
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
catch(...){
std::string error_str = "[SLC Error] Could not initialize networking due to thrown exception in network->init()";
cout << error_str << endl;
OE_WriteToLog(error_str + "\n");
}
}
| 40.569149 | 185 | 0.570932 |
8ba3f9d3d85228fcbeadc4203f705466973a827a | 1,206 | cpp | C++ | ImageProcessing/Dispatcher/DispatchManager.cpp | theradeonxt/FastImageEditor | 6b1a18393402cf2aa44ff9a399d1bb819a7aa971 | [
"MIT"
] | 3 | 2016-11-07T16:20:28.000Z | 2016-11-08T21:18:25.000Z | ImageProcessing/Dispatcher/DispatchManager.cpp | theradeonxt/FastImageEditor | 6b1a18393402cf2aa44ff9a399d1bb819a7aa971 | [
"MIT"
] | 6 | 2015-10-11T20:38:10.000Z | 2016-11-27T19:24:43.000Z | ImageProcessing/Dispatcher/DispatchManager.cpp | theradeonxt/FastImageEditor | 6b1a18393402cf2aa44ff9a399d1bb819a7aa971 | [
"MIT"
] | null | null | null |
#include "DispatchManager.h"
#include "Common.h"
#include "ConfigManager.h"
#include "ModuleConfig.h"
DispatchManager& g_DispatchManager()
{
static DispatchManager* ans = new DispatchManager();
return *ans;
}
void DispatchManager::Register(std::string entryPointKey, std::function<int(void**)> entryPoint)
{
if (ContainsKey(entryPointKey))
{
return;
}
dispatcher[entryPointKey] = entryPoint;
}
int32_t DispatchManager::Run(std::string moduleName, void** args)
{
Config::ModuleConfig* config;
bool configFound = Config::g_ConfigManager().getSingleConfig(moduleName, config);
if (configFound)
{
return dispatcher.at(config->m_DispatcherKey)(args);
}
return OperationFailed;
}
int32_t DispatchManager::RunFallback(const std::string& moduleName, void** args)
{
Config::ModuleConfig* config;
bool configFound = Config::g_ConfigManager().getSingleConfig(moduleName, config);
if (configFound)
{
return dispatcher.at(moduleName + Config::g_CodepathSuffix[None])(args);
}
return OperationFailed;
}
bool DispatchManager::ContainsKey(const std::string& key)
{
return dispatcher.find(key) != dispatcher.end();
}
| 25.125 | 96 | 0.708126 |
8ba536f73324eda4aa4a0583e5ff469d54cf166b | 2,597 | cpp | C++ | .experimentals/src/amtrs/android/application.cpp | isaponsoft/libamtrs | 5adf821ee15592fc3280985658ca8a4b175ffcaa | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2019-12-10T02:12:49.000Z | 2019-12-10T02:12:49.000Z | .experimentals/src/amtrs/android/application.cpp | isaponsoft/libamtrs | 5adf821ee15592fc3280985658ca8a4b175ffcaa | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | .experimentals/src/amtrs/android/application.cpp | isaponsoft/libamtrs | 5adf821ee15592fc3280985658ca8a4b175ffcaa | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | /* Copyright (c) 2019, isaponsoft (Isao Shibuya) All rights reserved. *
* Use of this source code is governed by a BSD-style license that *
* can be found in the LICENSE file. */
#include <amtrs/application.hpp>
#include <amtrs/.driver/android-api-android_app.hpp>
#include <amtrs/.driver/android-api-amtrs_activity.hpp>
#include <amtrs/java/java/io/File.hpp>
#include <amtrs/java/java/lang/String.hpp>
#include <amtrs/java/android/app/Activity.hpp>
#include <amtrs/java/android/content/Context.hpp>
#include <amtrs/java/android/content/pm/ApplicationInfo.hpp>
#include <amtrs/java/android/content/Intent.hpp>
#include <amtrs/java/android/os/Environment.hpp>
#include <amtrs/java/android/os/storage/StorageManager.hpp>
#include <amtrs/java/android/os/storage/StorageVolume.hpp>
#include <amtrs/java/android/view/Window.hpp>
#include <amtrs/java/android/view/WindowManager.hpp>
AMTRS_NAMESPACE_BEGIN
void application::foreground()
{
os::android::get_activity().foreground();
}
std::string application::cache_dir() const
{
if (mCacheDir.empty())
{
auto external = os::android::get_activity().getExternalFilesDir(java::jobj<java::classes::java::lang::String>());
auto absPath = external.getAbsolutePath();
mCacheDir = std::to_string((jstring)absPath.get());
}
return mCacheDir;
}
std::string application::documents_dir() const
{
if (mDocumentsDir.empty())
{
using Environment = java::classes::android::os::Environment;
auto clsEnv = Environment::find();
auto external = os::android::get_activity().getExternalFilesDir(clsEnv.get_DIRECTORY_PICTURES());
auto absPath = external.getAbsolutePath();
mDocumentsDir = std::to_string((jstring)absPath.get());
}
return mDocumentsDir;
}
std::string application::files_dir(bool _external) const
{
if (mFilesDir.empty())
{
auto dir = os::android::get_activity().getFilesDir().getPath();
mFilesDir = std::to_string((jstring)dir.get());
}
return mFilesDir;
}
void application::set_sleep_enable(bool _enable)
{
using lp = java::classes::android::view::WindowManager::LayoutParams;
auto cls = lp::find();
if (_enable)
{
int flags = cls.get_FLAG_KEEP_SCREEN_ON()
| cls.get_FLAG_TURN_SCREEN_ON()
| cls.get_FLAG_DISMISS_KEYGUARD()
;
os::android::get_activity().getWindow().clearFlags(flags);
}
else
{
int flags = cls.get_FLAG_KEEP_SCREEN_ON()
| cls.get_FLAG_TURN_SCREEN_ON()
| cls.get_FLAG_DISMISS_KEYGUARD()
| cls.get_FLAG_SHOW_WHEN_LOCKED()
;
os::android::get_activity().getWindow().addFlags(flags);
}
}
AMTRS_NAMESPACE_END
| 28.855556 | 115 | 0.723912 |
8ba7c5c2e0f37c988226176c3c9ed02e3da25e26 | 127 | cpp | C++ | src/multiply.cpp | markuspg/minimal_cmake_cpp_lib_sample | 6258bc7f148f3e2b401e678b615196bfbe397d5f | [
"MIT"
] | null | null | null | src/multiply.cpp | markuspg/minimal_cmake_cpp_lib_sample | 6258bc7f148f3e2b401e678b615196bfbe397d5f | [
"MIT"
] | null | null | null | src/multiply.cpp | markuspg/minimal_cmake_cpp_lib_sample | 6258bc7f148f3e2b401e678b615196bfbe397d5f | [
"MIT"
] | null | null | null | #include "multiply.h"
uint32_t multiply(uint32_t multiplicant, uint32_t multiplier) {
return multiplicant * multiplier;
}
| 21.166667 | 63 | 0.771654 |
8ba83653da54aac72acdfad36a5caca5b72ca812 | 924 | hpp | C++ | MEX/src/cpp/vision/min_max_filter.hpp | umariqb/3D_Pose_Estimation_CVPR2016 | 83f6bf36aa68366ea8fa078eea6d91427e28503b | [
"BSD-3-Clause"
] | 47 | 2016-07-25T00:48:59.000Z | 2021-02-17T09:19:03.000Z | MEX/src/cpp/vision/min_max_filter.hpp | umariqb/3D_Pose_Estimation_CVPR2016 | 83f6bf36aa68366ea8fa078eea6d91427e28503b | [
"BSD-3-Clause"
] | 5 | 2016-09-17T19:40:46.000Z | 2018-11-07T06:49:02.000Z | MEX/src/cpp/vision/min_max_filter.hpp | iqbalu/3D_Pose_Estimation_CVPR2016 | 83f6bf36aa68366ea8fa078eea6d91427e28503b | [
"BSD-3-Clause"
] | 35 | 2016-07-21T09:13:15.000Z | 2019-05-13T14:11:37.000Z | /*
* min_max_filter.hpp
*
* Created on: Oct 6, 2013
* Author: mdantone
*/
#ifndef MIN_MAX_FILTER_HPP_
#define MIN_MAX_FILTER_HPP_
#include "opencv2/core/core.hpp"
namespace vision {
class MinMaxFilter {
public:
static void maxfilt(cv::Mat &src, unsigned int width);
static void minfilt(cv::Mat &src, cv::Mat &dst, unsigned int width);
static void maxfilt(uchar* data, uchar* maxvalues, unsigned int step,
unsigned int size, unsigned int width);
static void maxfilt(uchar* data, unsigned int step, unsigned int size,
unsigned int width);
static void minfilt(uchar* data, uchar* minvalues, unsigned int step,
unsigned int size, unsigned int width);
static void minfilt(uchar* data, unsigned int step, unsigned int size,
unsigned int width);
};
} /* namespace vision */
#endif /* MIN_MAX_FILTER_HPP_ */
| 23.692308 | 72 | 0.655844 |
8baafec697dbe26c18f448d174f7e97d7ddba75a | 1,163 | cpp | C++ | 150.cpp | pengzhezhe/LeetCode | 305ec0c5b4cb5ea7cd244b3308132dee778138bc | [
"Apache-2.0"
] | null | null | null | 150.cpp | pengzhezhe/LeetCode | 305ec0c5b4cb5ea7cd244b3308132dee778138bc | [
"Apache-2.0"
] | null | null | null | 150.cpp | pengzhezhe/LeetCode | 305ec0c5b4cb5ea7cd244b3308132dee778138bc | [
"Apache-2.0"
] | null | null | null | //
// Created by pzz on 2021/10/30.
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
class Solution {
public:
int evalRPN(vector<string> &tokens) {
stack<int> stack;
for (const string &s: tokens) {
if (s == "+" || s == "-" || s == "*" || s == "/") {
int num1 = stack.top();
stack.pop();
int num2 = stack.top();
stack.pop();
if (s == "+") {
stack.push(num2 + num1);
}
if (s == "-") {
stack.push(num2 - num1);
}
if (s == "*") {
stack.push(num2 * num1);
}
if (s == "/") {
stack.push(num2 / num1);
}
} else {
stack.push(stoi(s));
}
}
return stack.top();
}
};
int main() {
vector<string> tokens = {"10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"};
Solution solution;
cout << solution.evalRPN(tokens);
return 0;
} | 24.229167 | 98 | 0.363715 |
8bafebf9900c1ceb8fe131bda5974ac113392ab4 | 1,322 | cpp | C++ | software/embedded/libraries/MotionHandler/MotionHandler.cpp | seanwatson/ece4416-project | ce048d84d2bc054fdb24848a32bb0219c4708fdc | [
"MIT"
] | 1 | 2020-07-26T12:55:27.000Z | 2020-07-26T12:55:27.000Z | software/embedded/libraries/MotionHandler/MotionHandler.cpp | seanwatson/ece4416-project | ce048d84d2bc054fdb24848a32bb0219c4708fdc | [
"MIT"
] | null | null | null | software/embedded/libraries/MotionHandler/MotionHandler.cpp | seanwatson/ece4416-project | ce048d84d2bc054fdb24848a32bb0219c4708fdc | [
"MIT"
] | null | null | null | /*
* File: MotionHandler.cpp
* Author: Sean Watson
* Date: Feb 2013
*
* Description: Implementation file for MotionHandler library
*
* Copyright (c) 2013 Sean Watson
* Licensed under the MIT license
*
*/
#include "MotionHandler.h"
MotionHandler::MotionHandler(const Accelerometer* const accel, HardwareSerial* const output):
_accel(accel),
_output(output),
_num_motions(0)
{
}
void MotionHandler::process() const{
// Vars to store angles of each motion as its checked
static int mx, my, mz;
// Take a reading
static float readings[3];
_accel->take_reading_angle(readings);
// Loop through all of the detectable motions
for(int i = 0; i < _num_motions; ++i){
mx = _motions[i]->x();
my = _motions[i]->y();
mz = _motions[i]->z();
// Check if the reading matches the motion
if(readings[0] > mx - TOLERANCE && readings[0] < mx + TOLERANCE &&
readings[1] > my - TOLERANCE && readings[1] < my + TOLERANCE &&
readings[2] > mz - TOLERANCE && readings[2] < mz + TOLERANCE){
_output->print(_motions[i]->code());
}
}
}
void MotionHandler::add_motion(const Motion& mot){
// Check if there is still space in the list
if(_num_motions < MAX_MOTIONS){
// Add the motion to the list
_motions[_num_motions] = &mot;
++_num_motions;
}
}
| 23.607143 | 93 | 0.653555 |
8bb2aa03ed6364ae984e2955f63ce226a55e0d21 | 1,246 | cpp | C++ | nd-coursework/books/cpp/FoundationsOfQtDev/Chapter02/listdialog.cpp | crdrisko/nd-grad | f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44 | [
"MIT"
] | 1 | 2020-09-26T12:38:55.000Z | 2020-09-26T12:38:55.000Z | nd-coursework/books/cpp/FoundationsOfQtDev/Chapter02/listdialog.cpp | crdrisko/nd-research | f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44 | [
"MIT"
] | null | null | null | nd-coursework/books/cpp/FoundationsOfQtDev/Chapter02/listdialog.cpp | crdrisko/nd-research | f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44 | [
"MIT"
] | null | null | null | #include "listdialog.h"
#include "editdialog.h"
#include "ui_listdialog.h"
// Listing 2-3: Constructor of the ListDialog class
ListDialog::ListDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ListDialog)
{
ui->setupUi(this);
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addItem()));
connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editItem()));
connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteItem()));
}
ListDialog::~ListDialog() { delete ui; }
// Listing 2-4: Adding a new item to the list
void ListDialog::addItem()
{
EditDialog dlg(this);
if (dlg.exec() == DialogCode::Accepted)
ui->list->addItem(dlg.name() + " -- " + dlg.number());
}
// Listing 2-5: Deleting an item of the list
void ListDialog::deleteItem() { delete ui->list->currentItem(); }
// Listing 2-6: Editing an item of the list
void ListDialog::editItem()
{
if (!ui->list->currentItem())
return;
QStringList parts = ui->list->currentItem()->text().split("--");
EditDialog dlg(this);
dlg.setName(parts[0].trimmed());
dlg.setNumber(parts[1].trimmed());
if (dlg.exec() == DialogCode::Accepted)
ui->list->currentItem()->setText(dlg.name() + " -- " + dlg.number());
}
| 27.688889 | 81 | 0.645265 |
8bb37a46d296ac3055a349429e346e10f3abc0d9 | 3,541 | cpp | C++ | src/main.cpp | kingsamchen/CPU_Utilization_Plot | d651df76b0e3b556dd2d9cf40304070310ef0578 | [
"MIT"
] | 1 | 2019-04-15T13:32:39.000Z | 2019-04-15T13:32:39.000Z | src/main.cpp | kingsamchen/CPU_Utilization_Plot | d651df76b0e3b556dd2d9cf40304070310ef0578 | [
"MIT"
] | null | null | null | src/main.cpp | kingsamchen/CPU_Utilization_Plot | d651df76b0e3b556dd2d9cf40304070310ef0578 | [
"MIT"
] | null | null | null | /*
@ Kingsley Chen
*/
#include <Windows.h>
#include <conio.h>
#include <process.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include "kbase\command_line.h"
#include "kbase\memory\scoped_handle.h"
#include "kbase\sys_info.h"
const unsigned long kDefaultTimeUnit = 1000;
const wchar_t kPlotSwitchName[] = L"plot_type";
const wchar_t kSineCurve[] = L"sine";
const wchar_t kHorizon[] = L"horizon";
using PlotFunc = unsigned int (WINAPI *)(void*);
// The time unit corresponds to CPU utilization sample frequency.
// The whole utilization curve consists of curve in several time units.
void PlotTimeUnit(unsigned long time_unit, double busy_percent)
{
unsigned long busy_span = static_cast<unsigned long>(time_unit * busy_percent);
unsigned long time_unit_begin = GetTickCount();
while (time_unit_begin + busy_span > GetTickCount()) {
;
}
Sleep(time_unit - busy_span);
}
unsigned int WINAPI PlotHorizontalLine(void* param)
{
unsigned long& busy_percent_num = *static_cast<unsigned long*>(param);
double busy_percent = static_cast<double>(busy_percent_num) / 100;
while (true) {
PlotTimeUnit(kDefaultTimeUnit, busy_percent);
};
return 0;
}
unsigned int WINAPI PlotSineCurve(void* dummy)
{
const double kPi = 3.14;
const unsigned long kSineCurveTimeUnit = 500;
while (true) {
for (double x = 0.0; x < 2 * kPi; x += 0.1) {
double busy_percent = std::sin(x) / 2 + 0.5;
PlotTimeUnit(kSineCurveTimeUnit, busy_percent);
}
}
return 0;
}
inline void PrintUsage()
{
std::cout << "Usage:\nCPU_Utilization_Plot.exe -plot_type=[sinecurve|horizon"
" {num, 20 <= num <= 80}]\n" << std::endl;
}
std::vector<kbase::ScopedSysHandle> SetupThreads(PlotFunc fn, void* param)
{
std::vector<kbase::ScopedSysHandle> threads;
auto core_count = kbase::SysInfo::NumberOfProcessors();
for (size_t i = 0; i < core_count; ++i) {
auto handle = _beginthreadex(nullptr, 0, fn, param, CREATE_SUSPENDED,
nullptr);
threads.emplace_back(reinterpret_cast<HANDLE>(handle));
SetThreadAffinityMask(threads[i].Get(), 1U << i);
}
return threads;
}
int main(int argc, char* argv[])
{
auto& commandline = kbase::CommandLine::ForCurrentProcess();
std::wstring plot_type;
if (!commandline.GetSwitchValue(kPlotSwitchName, &plot_type)) {
std::cout << "Invalid instructions!" << std::endl;
PrintUsage();
return 1;
}
PlotFunc plot_fn;
unsigned long plot_param = 0;
if (plot_type == kHorizon) {
auto&& arg_list = commandline.GetParameters();
if (arg_list.empty()) {
std::cout << "Invalid instructions!" << std::endl;
PrintUsage();
return 1;
}
plot_fn = PlotHorizontalLine;
plot_param = std::stoul(arg_list[0]);
if (plot_param < 20 || plot_param > 80) {
std::cerr << "Utilization percentage number for horizontal line must "
"range from 20 to 80" << std::endl;
PrintUsage();
return 1;
}
} else {
plot_fn = PlotSineCurve;
}
std::vector<kbase::ScopedSysHandle> threads = SetupThreads(plot_fn, &plot_param);
std::cout << "Press any key to start if you are ready" << std::endl;
_getch();
std::for_each(threads.begin(), threads.end(), ResumeThread);
WaitForSingleObject(threads.front(), INFINITE);
return 0;
} | 27.88189 | 85 | 0.635414 |
8bb72ddf572bf5d942ac7462a4f4888f5d6b2a22 | 1,879 | cpp | C++ | OJ/LeetCode/leetcode/problems/283.cpp | ONGOING-Z/DataStructure | 9099393d1c7dfabc3e2939586ea6d1d254631eb2 | [
"MIT"
] | null | null | null | OJ/LeetCode/leetcode/problems/283.cpp | ONGOING-Z/DataStructure | 9099393d1c7dfabc3e2939586ea6d1d254631eb2 | [
"MIT"
] | 2 | 2021-10-31T10:05:45.000Z | 2022-02-12T15:17:53.000Z | OJ/LeetCode/leetcode/283.cpp | ONGOING-Z/Learn-Algorithm-and-DataStructure | 3a512bd83cc6ed5035ac4550da2f511298b947c0 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
/* Leetcode */
/* Type: array */
/* 题目信息 */
/*
*283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Example:
Input: [0,1,0,3,12]
Output: [1,3,12,0,0]
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
*/
/* my solution */
/* better solution */
// 下边这种做法并没有用到in-place算法,只是另外用了一个数组,虽然通过,但并不适合。
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int len = nums.size();
vector<int> res;
// find out the non-zero and the push it to res
for (int i = 0; i < len; i++)
{
if (nums[i] != 0)
res.push_back(nums[i]);
}
printf("res's size = %d\n", res.size());
// find out the zero's freq
int zeros = 0;
for (int i = 0; i < len; i++)
{
if (nums[i] == 0)
zeros++;
}
printf("zeros = %d\n", zeros);
// push 0 to res
while (zeros--)
res.push_back(0);
// res to nums
for (int i = 0; i < len; i++)
{
nums[i] = res[i];
}
}
};
// 符合题意的in-place解法 better
// ✓
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int lastNonZeroFoundAt = 0;
for (int i = 0; i < nums.size(); i++)
{
// 当前元素不为0,则将当前元素值赋值给最后的0元素位置
if (nums[i] != 0)
nums[lastNonZeroFoundAt++] = nums[i];
}
for (int i = lastNonZeroFoundAt; i < nums.size(); i++)
{
nums[i] = 0;
}
}
};
/* 一些总结 */
// 1. 题意:
//
// 需要注意的点:
// 1. 如果没有返回类型的话,代表要在原数组上修改,但是在过程中可以新开一个数组存储,最后在赋值回去。
// 2.
// 3.
| 21.11236 | 133 | 0.503459 |
8bb828f009beb8a5ec87dd3ba0d320694f75d127 | 909 | cpp | C++ | NacloEngine/ResourceMesh.cpp | JoanValiente/NacloEngine | 44eb9901a9f5337d19f3fe3b5d061099ea4e7fa0 | [
"MIT"
] | 1 | 2019-09-09T10:04:14.000Z | 2019-09-09T10:04:14.000Z | NacloEngine/ResourceMesh.cpp | JoanValiente/NacloEngine | 44eb9901a9f5337d19f3fe3b5d061099ea4e7fa0 | [
"MIT"
] | null | null | null | NacloEngine/ResourceMesh.cpp | JoanValiente/NacloEngine | 44eb9901a9f5337d19f3fe3b5d061099ea4e7fa0 | [
"MIT"
] | null | null | null | #include "ResourceMesh.h"
#include "ModuleResources.h"
ResourceMesh::ResourceMesh(uint uid, Resource_Type type) : Resource(uid, type)
{
}
ResourceMesh::~ResourceMesh()
{
}
bool ResourceMesh::LoadInMemory()
{
bool ret = false;
glGenBuffers(1, (GLuint*) &(id_vertices));
glBindBuffer(GL_ARRAY_BUFFER, id_vertices);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * num_vertices, vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, (GLuint*) &(id_indices));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id_indices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint) * num_indices, indices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glGenBuffers(1, (GLuint*) &(id_texture));
glBindBuffer(GL_ARRAY_BUFFER, id_texture);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 2 * num_texture, texture, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return ret;
}
| 26.735294 | 92 | 0.770077 |
8bbcd31e573b9c6f2f42655f7c6d407c646e2cb3 | 1,211 | cpp | C++ | src/vertex.cpp | JamesGriffin/3D-Rasterizer | 3a9840845bb92279d0c07fd5197dd9879e97f4ec | [
"MIT"
] | 13 | 2017-11-18T01:05:04.000Z | 2021-12-25T10:47:45.000Z | src/vertex.cpp | JamesGriffin/3D-Rasterizer | 3a9840845bb92279d0c07fd5197dd9879e97f4ec | [
"MIT"
] | 2 | 2018-07-19T14:09:46.000Z | 2021-01-15T10:35:43.000Z | src/vertex.cpp | JamesGriffin/3D-Rasterizer | 3a9840845bb92279d0c07fd5197dd9879e97f4ec | [
"MIT"
] | 5 | 2018-03-05T04:40:21.000Z | 2021-06-11T03:40:54.000Z | #include "vertex.h"
// Represents a vertex in 3D space
Vertex::Vertex (Vector4 position, Vector4 normal)
: m_position(position), m_normal(normal) {}
Vertex::Vertex(float x, float y, float z, float w) {
m_position = Vector4(x, y, z, w);
m_normal = Vector4(0, 0, 0, 0);
}
// Perspective divide by w component
Vertex Vertex::perspectiveDivide() {
float w_inv = 1.0f / getW();
return Vertex(
Vector4(
getX() * w_inv,
getY() * w_inv,
getZ() * w_inv,
getW()
),
m_normal
);
}
Vector4 Vertex::getPos() {
return m_position;
}
Vector4 Vertex::getNormal() {
return m_normal;
}
Vertex Vertex::transform(Matrix4 m, Matrix4 n) {
return Vertex(m.transform(m_position), n.transform(m_normal));
}
float Vertex::getX() {
return m_position.x;
}
float Vertex::getY() {
return m_position.y;
}
float Vertex::getZ() {
return m_position.z;
}
float Vertex::getW() {
return m_position.w;
}
void Vertex::setX(float x) {
m_position.x = x;
}
void Vertex::setY(float y) {
m_position.y = y;
}
void Vertex::setZ(float z) {
m_position.z = z;
}
void Vertex::setW(float w) {
m_position.w = w;
}
| 17.3 | 66 | 0.606936 |
8bbf37cc4accb326337f2b3e630a01b6cc33fe16 | 680 | cpp | C++ | modules/imgproc/src/accum.dispatch.cpp | thisisgopalmandal/opencv | 4e2ef8c8f57644ccb8e762a37f70a61007c6be1c | [
"BSD-3-Clause"
] | 56,632 | 2016-07-04T16:36:08.000Z | 2022-03-31T18:38:14.000Z | modules/imgproc/src/accum.dispatch.cpp | thisisgopalmandal/opencv | 4e2ef8c8f57644ccb8e762a37f70a61007c6be1c | [
"BSD-3-Clause"
] | 13,593 | 2016-07-04T13:59:03.000Z | 2022-03-31T21:04:51.000Z | modules/imgproc/src/accum.dispatch.cpp | thisisgopalmandal/opencv | 4e2ef8c8f57644ccb8e762a37f70a61007c6be1c | [
"BSD-3-Clause"
] | 54,986 | 2016-07-04T14:24:38.000Z | 2022-03-31T22:51:18.000Z | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "precomp.hpp"
#include "accum.simd.hpp"
#include "accum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
namespace cv {
DEF_ACC_INT_FUNCS(8u32f, uchar, float)
DEF_ACC_INT_FUNCS(8u64f, uchar, double)
DEF_ACC_INT_FUNCS(16u32f, ushort, float)
DEF_ACC_INT_FUNCS(16u64f, ushort, double)
DEF_ACC_FLT_FUNCS(32f, float, float)
DEF_ACC_FLT_FUNCS(32f64f, float, double)
DEF_ACC_FLT_FUNCS(64f, double, double)
} //cv::hal | 34 | 125 | 0.782353 |
8bbf6dcce3c8444f3985e023875c663d546c3fb1 | 1,437 | cpp | C++ | graphics/vsrtl_multiplexergraphic.cpp | mortbopet/vsrtl | 8fd0bce6f5fcf27b89b33cf995b0428b8436ccdf | [
"MIT"
] | 52 | 2019-03-18T02:23:19.000Z | 2022-03-10T00:45:54.000Z | graphics/vsrtl_multiplexergraphic.cpp | mortbopet/vsrtl | 8fd0bce6f5fcf27b89b33cf995b0428b8436ccdf | [
"MIT"
] | 48 | 2019-02-28T22:05:54.000Z | 2021-11-19T11:33:10.000Z | graphics/vsrtl_multiplexergraphic.cpp | mortbopet/vsrtl | 8fd0bce6f5fcf27b89b33cf995b0428b8436ccdf | [
"MIT"
] | 10 | 2019-03-18T02:23:23.000Z | 2022-03-11T19:46:42.000Z | #include "vsrtl_multiplexergraphic.h"
#include "vsrtl_portgraphic.h"
#include <QPainter>
namespace vsrtl {
MultiplexerGraphic::MultiplexerGraphic(SimComponent* c, ComponentGraphic* parent) : ComponentGraphic(c, parent) {
// Make changes in the select signal trigger a redraw of the multiplexer (and its input signal markings)
wrapSimSignal(getSelect()->changed);
}
SimPort* MultiplexerGraphic::getSelect() {
// Simulator component must have set the select port to special port 0
return m_component->getSpecialPort(GFX_MUX_SELECT);
}
void MultiplexerGraphic::paintOverlay(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
// Mark input IO with circles, highlight selected input with green
painter->save();
const auto inputPorts = m_component->getPorts<SimPort::PortType::in>();
const auto* select = getSelect();
const unsigned int index = select->uValue();
Q_ASSERT(static_cast<long>(index) < m_inputPorts.size());
for (const auto& ip : qAsConst(m_inputPorts)) {
const auto* p_base = ip->getPort();
if (p_base != select) {
if (p_base == inputPorts[index]) {
painter->setBrush(Qt::green);
} else {
painter->setBrush(Qt::white);
}
paintIndicator(painter, ip, p_base == inputPorts[index] ? Qt::green : Qt::white);
}
}
painter->restore();
}
} // namespace vsrtl
| 33.418605 | 113 | 0.668754 |
8bc0c28346f9eef89dc210f5af99fe75b093b6e1 | 420 | hpp | C++ | sources/cards/lands/Swamp.hpp | angeluriot/Magic_royal | a337ce4ad6c3215bbdec8c376d6e88fe97f48f94 | [
"MIT"
] | 1 | 2022-02-02T21:41:59.000Z | 2022-02-02T21:41:59.000Z | sources/cards/lands/Swamp.hpp | angeluriot/Magic_royal | a337ce4ad6c3215bbdec8c376d6e88fe97f48f94 | [
"MIT"
] | null | null | null | sources/cards/lands/Swamp.hpp | angeluriot/Magic_royal | a337ce4ad6c3215bbdec8c376d6e88fe97f48f94 | [
"MIT"
] | 2 | 2022-02-01T12:59:57.000Z | 2022-03-05T12:50:27.000Z | #ifndef SWAMP_HPP
#define SWAMP_HPP
#include "cards/Land.hpp"
class Swamp : public Land
{
public:
Swamp();
Swamp(const Swamp& other) = default;
~Swamp();
Swamp& operator=(const Swamp& other) = default;
std::string get_full_type() const override;
Color get_color() const override;
std::string get_name() const override;
std::string get_description() const override;
Card* clone() const override;
};
#endif
| 17.5 | 48 | 0.721429 |
8bc43125a215bc61387fbefc81c6dd3fcd991128 | 12,357 | cpp | C++ | CodeForces-Solution/1545E2.cpp | Tech-Intellegent/CodeForces-Solution | 2f291a38b80b8ff2a2595b2e526716468ff26bf8 | [
"MIT"
] | 1 | 2022-01-23T07:18:07.000Z | 2022-01-23T07:18:07.000Z | CodeForces-Solution/1545E2.cpp | Tech-Intellegent/CodeForces-Solution | 2f291a38b80b8ff2a2595b2e526716468ff26bf8 | [
"MIT"
] | null | null | null | CodeForces-Solution/1545E2.cpp | Tech-Intellegent/CodeForces-Solution | 2f291a38b80b8ff2a2595b2e526716468ff26bf8 | [
"MIT"
] | 1 | 2022-02-05T11:53:04.000Z | 2022-02-05T11:53:04.000Z | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double; // or double, if TL is tight
using str = string; // yay python!
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
#define tcT template<class T
#define tcTU tcT, class U
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;
// pairs
#define mp make_pair
#define f first
#define s second
// vectors
// oops size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
#define rtn return
#define lb lower_bound
#define ub upper_bound
tcT> int lwb(V<T>& a, const T& b) { return int(lb(all(a),b)-bg(a)); }
// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const db PI = acos((db)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
// bitwise ops
// also see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { // assert(x >= 0); // make C++11 compatible until USACO updates ...
return x == 0 ? 0 : 31-__builtin_clz(x); } // floor(log2(x))
constexpr int p2(int x) { return 1<<x; }
constexpr int msk2(int x) { return p2(x)-1; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
tcT> bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0; }
tcTU> T fstTrue(T lo, T hi, U f) {
hi ++; assert(lo <= hi); // assuming f is increasing
while (lo < hi) { // find first index such that f is true
T mid = lo+(hi-lo)/2;
f(mid) ? hi = mid : lo = mid+1;
}
return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
lo --; assert(lo <= hi); // assuming f is decreasing
while (lo < hi) { // find first index such that f is true
T mid = lo+(hi-lo+1)/2;
f(mid) ? lo = mid : hi = mid-1;
}
return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
auto it = t.find(u); assert(it != end(t));
t.erase(it); } // element that doesn't exist from (multi)set
#define tcTUU tcT, class ...U
inline namespace Helpers {
//////////// is_iterable
// https://stackoverflow.com/questions/13830158/check-if-a-variable-type-is-iterable
// this gets used only when we can call begin() and end() on that type
tcT, class = void> struct is_iterable : false_type {};
tcT> struct is_iterable<T, void_t<decltype(begin(declval<T>())),
decltype(end(declval<T>()))
>
> : true_type {};
tcT> constexpr bool is_iterable_v = is_iterable<T>::value;
//////////// is_readable
tcT, class = void> struct is_readable : false_type {};
tcT> struct is_readable<T,
typename std::enable_if_t<
is_same_v<decltype(cin >> declval<T&>()), istream&>
>
> : true_type {};
tcT> constexpr bool is_readable_v = is_readable<T>::value;
//////////// is_printable
// // https://nafe.es/posts/2020-02-29-is-printable/
tcT, class = void> struct is_printable : false_type {};
tcT> struct is_printable<T,
typename std::enable_if_t<
is_same_v<decltype(cout << declval<T>()), ostream&>
>
> : true_type {};
tcT> constexpr bool is_printable_v = is_printable<T>::value;
}
inline namespace Input {
tcT> constexpr bool needs_input_v = !is_readable_v<T> && is_iterable_v<T>;
tcTUU> void re(T& t, U&... u);
tcTU> void re(pair<T,U>& p); // pairs
// re: read
tcT> typename enable_if<is_readable_v<T>,void>::type re(T& x) { cin >> x; } // default
tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; } // complex
tcT> typename enable_if<needs_input_v<T>,void>::type re(T& i); // ex. vectors, arrays
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> typename enable_if<needs_input_v<T>,void>::type re(T& i) {
each(x,i) re(x); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); } // read multiple
// rv: resize and read vectors
void rv(size_t) {}
tcTUU> void rv(size_t N, V<T>& t, U&... u);
template<class...U> void rv(size_t, size_t N2, U&... u);
tcTUU> void rv(size_t N, V<T>& t, U&... u) {
t.rsz(N); re(t);
rv(N,u...); }
template<class...U> void rv(size_t, size_t N2, U&... u) {
rv(N2,u...); }
// dumb shortcuts to read in ints
void decrement() {} // subtract one from each
tcTUU> void decrement(T& t, U&... u) { --t; decrement(u...); }
#define ints(...) int __VA_ARGS__; re(__VA_ARGS__);
#define int1(...) ints(__VA_ARGS__); decrement(__VA_ARGS__);
}
inline namespace ToString {
tcT> constexpr bool needs_output_v = !is_printable_v<T> && is_iterable_v<T>;
// ts: string representation to print
tcT> typename enable_if<is_printable_v<T>,str>::type ts(T v) {
stringstream ss; ss << fixed << setprecision(15) << v;
return ss.str(); } // default
tcT> str bit_vec(T t) { // bit vector to string
str res = "{"; F0R(i,sz(t)) res += ts(t[i]);
res += "}"; return res; }
str ts(V<bool> v) { return bit_vec(v); }
template<size_t SZ> str ts(bitset<SZ> b) { return bit_vec(b); } // bit vector
tcTU> str ts(pair<T,U> p); // pairs
tcT> typename enable_if<needs_output_v<T>,str>::type ts(T v); // vectors, arrays
tcTU> str ts(pair<T,U> p) { return "("+ts(p.f)+", "+ts(p.s)+")"; }
tcT> typename enable_if<is_iterable_v<T>,str>::type ts_sep(T v, str sep) {
// convert container to string w/ separator sep
bool fst = 1; str res = "";
for (const auto& x: v) {
if (!fst) res += sep;
fst = 0; res += ts(x);
}
return res;
}
tcT> typename enable_if<needs_output_v<T>,str>::type ts(T v) {
return "{"+ts_sep(v,", ")+"}"; }
// for nested DS
template<int, class T> typename enable_if<!needs_output_v<T>,vs>::type
ts_lev(const T& v) { return {ts(v)}; }
template<int lev, class T> typename enable_if<needs_output_v<T>,vs>::type
ts_lev(const T& v) {
if (lev == 0 || !sz(v)) return {ts(v)};
vs res;
for (const auto& t: v) {
if (sz(res)) res.bk += ",";
vs tmp = ts_lev<lev-1>(t);
res.ins(end(res),all(tmp));
}
F0R(i,sz(res)) {
str bef = " "; if (i == 0) bef = "{";
res[i] = bef+res[i];
}
res.bk += "}";
return res;
}
}
inline namespace Output {
template<class T> void pr_sep(ostream& os, str, const T& t) { os << ts(t); }
template<class T, class... U> void pr_sep(ostream& os, str sep, const T& t, const U&... u) {
pr_sep(os,sep,t); os << sep; pr_sep(os,sep,u...); }
// print w/ no spaces
template<class ...T> void pr(const T&... t) { pr_sep(cout,"",t...); }
// print w/ spaces, end with newline
void ps() { cout << "\n"; }
template<class ...T> void ps(const T&... t) { pr_sep(cout," ",t...); ps(); }
// debug to cerr
template<class ...T> void dbg_out(const T&... t) {
pr_sep(cerr," | ",t...); cerr << endl; }
void loc_info(int line, str names) {
cerr << "Line(" << line << ") -> [" << names << "]: "; }
template<int lev, class T> void dbgl_out(const T& t) {
cerr << "\n\n" << ts_sep(ts_lev<lev>(t),"\n") << "\n" << endl; }
#ifdef LOCAL
#define dbg(...) loc_info(__LINE__,#__VA_ARGS__), dbg_out(__VA_ARGS__)
#define dbgl(lev,x) loc_info(__LINE__,#x), dbgl_out<lev>(x)
#else // don't actually submit with this
#define dbg(...) 0
#define dbgl(lev,x) 0
#endif
}
inline namespace FileIO {
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void setIO(str s = "") {
cin.tie(0)->sync_with_stdio(0); // unsync C / C++ I/O streams
// cin.exceptions(cin.failbit);
// throws exception when do smth illegal
// ex. try to read letter into int
if (sz(s)) setIn(s+".in"), setOut(s+".out"); // for old USACO
}
}
using dpl = deque<pl>; // OK
int N,X; // OK
map<pl,dpl> ranges;
int cur_time;
void attempt_add_left(pair<pl,dpl>& p, ll best_left) {
ll L = p.f.f;
if (!sz(p.s) || p.s.ft.s+(p.s.ft.f+cur_time)-L > best_left)
p.s.push_front({L-cur_time,best_left});
}
void attempt_add_right(pair<pl,dpl>& p, ll best_right) {
ll R = p.f.s;
if (!sz(p.s) || p.s.bk.s+R-(p.s.bk.f+cur_time) > best_right)
p.s.pb({R-cur_time,best_right});
}
void cleanup(pair<pl,dpl>& p) {
ll best_right = INF;
ll R = p.f.s;
while (sz(p.s)) {
ll dif = (p.s.bk.f+cur_time)-R;
if (dif <= 0) break;
best_right = p.s.bk.s+dif;
p.s.pop_back();
}
attempt_add_right(p,best_right);
}
map<int,int> start_cnt, end_cnt;
void ban(int L, int R) {
dbg("BAN",L,R);
++start_cnt[L], ++end_cnt[R];
auto it = ranges.ub({L,INF});
if (it != begin(ranges) && prev(it)->f.s > L) --it;
while (it != end(ranges) && it->f.f < R) {
pair<pl,dpl> t = *(it++); cleanup(t);
ranges.erase(prev(it));
if (t.f.f <= L) {
pair<pl,dpl> nt; nt.f = {t.f.f,L};
each(u,t.s) {
if (u.f+cur_time <= L) nt.s.pb(u);
else {
attempt_add_right(nt,u.s+(u.f+cur_time)-L);
break;
}
}
ranges[nt.f] = nt.s;
}
if (R <= t.f.s) {
pair<pl,dpl> nt; nt.f = {R,t.f.s};
ll min_lef = INF;
each(u,t.s) {
if (u.f+cur_time < R) {
min_lef = u.s+R-(u.f+cur_time);
} else nt.s.pb(u);
}
attempt_add_left(nt,min_lef);
ranges[nt.f] = nt.s;
}
}
}
void subtract(map<int,int>& m, int x) {
--m[x];
assert(m[x] >= 0);
if (m[x] == 0) m.erase(x);
}
int get_next_start(int L) {
auto it = start_cnt.lb(L);
if (it == end(start_cnt)) return MOD;
return it->f;
}
int get_prev_end(int R) {
auto it = end_cnt.ub(R);
if (it == begin(end_cnt)) return -MOD;
return prev(it)->f;
}
dpl merge_deques(dpl l, dpl r) {
while (sz(l) && sz(r)) {
assert(l.bk.f < r.ft.f);
ll dif = r.ft.f-l.bk.f;
if (l.bk.s >= r.ft.s+dif) {
l.pop_back();
continue;
}
if (r.ft.s >= l.bk.s+dif) {
r.pop_front();
continue;
}
break;
}
l.ins(end(l),all(r));
return l;
}
void revert(int L, int R) {
// dbg("REVERT",L,R);
subtract(start_cnt,L), subtract(end_cnt,R);
int LL = get_next_start(L), RR = get_prev_end(R);
// dbg("GOT",L,R,LL,RR);
auto it = ranges.ub({L,INF});
bool flag = 0;
if (it != begin(ranges) && prev(it)->f.s == L) {
pair<pl,dpl> t = *prev(it); ranges.erase(prev(it));
cleanup(t);
t.f.s = LL; ranges[t.f] = t.s;
flag = (LL >= R);
}
if (it != end(ranges) && it->f.f == R) {
pair<pl,dpl> t = *it; cleanup(t);
if (flag) {
assert(it != begin(ranges));
ranges.erase(it--);
assert(RR <= L);
assert(it->f.s == t.f.s);
assert(RR == it->f.f);
it->s = merge_deques(it->s,t.s);
} else {
ranges.erase(it);
t.f.f = RR;
ranges[t.f] = t.s;
}
}
}
int main() {
setIO();
re(N,X);
ranges[{-MOD,MOD}] = {{X,0}}; // OK
V<tuple<int,int,int,int>> mod;
rep(N) {
ints(TL,TR,L,R);
--TL, ++TR, --L, ++R;
mod.pb({TL,1,L,R});
mod.pb({TR,-1,L,R});
}
sor(mod);
each(t,mod) {
auto [_time, ad, L, R] = t;
cur_time = _time;
if (ad == 1) ban(L,R);
else revert(L,R);
}
assert(sz(start_cnt) == 0 && sz(end_cnt) == 0);
assert(sz(ranges) == 1);
V<pair<pl,dpl>> franges(all(ranges));
each(t,franges) cleanup(t);
ll ans = INF;
each(t,franges[0].s) ckmin(ans,t.s);
ps(ans);
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/ | 29.351544 | 95 | 0.590596 |
8bc5d66d1742eaa867d308a6885208b0faf27876 | 715 | cpp | C++ | LogTargetmanager.cpp | WallyCZ/CLogger | 117b1ef9dc1469069a2de1cb5cadb4402eccd355 | [
"Apache-2.0"
] | 1 | 2022-01-19T19:15:22.000Z | 2022-01-19T19:15:22.000Z | LogTargetmanager.cpp | WallyCZ/CLogger | 117b1ef9dc1469069a2de1cb5cadb4402eccd355 | [
"Apache-2.0"
] | null | null | null | LogTargetmanager.cpp | WallyCZ/CLogger | 117b1ef9dc1469069a2de1cb5cadb4402eccd355 | [
"Apache-2.0"
] | null | null | null | #include "pch.h"
#include "LogTargetManager.h"
#include <string>
#include <memory>
#include <cstdarg>
namespace CLogger
{
std::vector<std::shared_ptr<ILogTarget>> LogTargetManager::m_targets;
std::mutex LogTargetManager::m_mtx;
DLLEXPORT void LogTargetManager::AddLogTarget(std::shared_ptr<ILogTarget> logTarget)
{
m_targets.push_back(logTarget);
}
DLLEXPORT void LogTargetManager::WriteToAllTargets(const wchar_t * str)
{
m_mtx.lock();
for (auto target : m_targets)
{
target->OutStringW(str);
}
m_mtx.unlock();
}
DLLEXPORT void LogTargetManager::ReleaseAllTargets()
{
m_mtx.lock();
for (auto target : m_targets)
{
target.reset();
}
m_targets.clear();
m_mtx.unlock();
}
} | 19.861111 | 85 | 0.716084 |
8bca5521c02bad6dc700113c1a52db3a22f1ba77 | 3,157 | cc | C++ | libs/xml/test-config.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | libs/xml/test-config.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | libs/xml/test-config.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | //==========================================================================
// ObTools::XML: test-config.cc
//
// Test harness for ObTools XML configuration
//
// Copyright (c) 2017 Paul Clark. All rights reserved
// This code comes with NO WARRANTY and is subject to licence agreement
//==========================================================================
#include "ot-xml.h"
#include "ot-file.h"
#include "ot-log.h"
#include <iostream>
#include <gtest/gtest.h>
namespace {
using namespace std;
using namespace ObTools;
const auto test_dir = string{"/tmp/ot-config"};
const auto toplevel_config_file = test_dir + "/toplevel.xml";
const auto sub1_config_file = test_dir + "/sub1.xml";
const auto sub2_config_file = test_dir + "/sub2.xml";
const auto toplevel_config = R"(
<toplevel>
<element attr="foo"/>
</toplevel>
)";
const auto toplevel_config_with_include = R"(
<toplevel>
<include file="sub1.xml"/>
<element attr="foo"/>
</toplevel>
)";
const auto toplevel_config_with_pattern = R"(
<toplevel>
<include file="sub*.xml"/>
<element attr="foo"/>
</toplevel>
)";
const auto sub1_config = R"(
<toplevel>
<element attr="bar"/>
</toplevel>
)";
const auto sub2_config = R"(
<toplevel>
<element id="different" attr="NOTME"/>
<element2 attr2="bar2"/>
</toplevel>
)";
class ConfigurationTest: public ::testing::Test
{
protected:
virtual void SetUp()
{
File::Directory dir(test_dir);
dir.ensure(true);
}
virtual void TearDown()
{
File::Directory state(test_dir);
state.erase();
}
public:
ConfigurationTest() {}
};
TEST_F(ConfigurationTest, TestReadConfig)
{
File::Path toplevel_path(toplevel_config_file);
toplevel_path.write_all(toplevel_config);
Log::Streams log;
XML::Configuration config(toplevel_config_file, log.error);
ASSERT_TRUE(config.read("toplevel"));
EXPECT_EQ("foo", config["element/@attr"]);
}
TEST_F(ConfigurationTest, TestIncludeSub1Config)
{
File::Path toplevel_path(toplevel_config_file);
toplevel_path.write_all(toplevel_config_with_include);
File::Path sub1_path(sub1_config_file);
sub1_path.write_all(sub1_config);
Log::Streams log;
XML::Configuration config(toplevel_config_file, log.error);
ASSERT_TRUE(config.read("toplevel"));
config.process_includes();
EXPECT_EQ("bar", config["element/@attr"]);
}
TEST_F(ConfigurationTest, TestIncludePatternConfig)
{
File::Path toplevel_path(toplevel_config_file);
toplevel_path.write_all(toplevel_config_with_pattern);
File::Path sub1_path(sub1_config_file);
sub1_path.write_all(sub1_config);
File::Path sub2_path(sub2_config_file);
sub2_path.write_all(sub2_config);
Log::Streams log;
XML::Configuration config(toplevel_config_file, log.error);
ASSERT_TRUE(config.read("toplevel"));
config.process_includes();
EXPECT_EQ("bar", config["element/@attr"]);
EXPECT_EQ("bar2", config["element2/@attr2"]);
}
} // anonymous namespace
int main(int argc, char **argv)
{
if (argc > 1 && string(argv[1]) == "-v")
{
auto chan_out = new Log::StreamChannel{&cout};
Log::logger.connect(chan_out);
}
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 23.043796 | 76 | 0.682293 |
8bcc1a15219788dde9f41068705f5027441c502b | 832 | hpp | C++ | src/rogue-card/scene/QuickActionBar.hpp | padawin/RogueCard | 7a5d04fa2d7be47c1542b6d4908e277ccbbd01fc | [
"MIT"
] | null | null | null | src/rogue-card/scene/QuickActionBar.hpp | padawin/RogueCard | 7a5d04fa2d7be47c1542b6d4908e277ccbbd01fc | [
"MIT"
] | null | null | null | src/rogue-card/scene/QuickActionBar.hpp | padawin/RogueCard | 7a5d04fa2d7be47c1542b6d4908e277ccbbd01fc | [
"MIT"
] | null | null | null | #ifndef __QUICK_ACTION_BAR__
#define __QUICK_ACTION_BAR__
#include <string.h>
#include "sdl2/Renderer.hpp"
#include "game/SceneState.hpp"
#include "rogue-card/coordinates.hpp"
#include "Player.hpp"
class QuickActionBarScene : public SceneState {
private:
std::shared_ptr<SDL2Renderer> m_renderer;
Player &m_player;
std::shared_ptr<ObjectCard> m_card = nullptr;
int m_cursorPosition = 0;
S_Coordinates m_mCursorPositions[ACTION_BAR_SIZE] = {};
void _renderBackground() const;
void _renderCards() const;
void _renderCursor() const;
public:
QuickActionBarScene(
UserActions &userActions,
Player &player,
std::shared_ptr<ObjectCard> card,
std::shared_ptr<SDL2Renderer> renderer
);
bool onEnter();
void update(StateMachine<SceneState> &stateMachine);
void render();
std::string getStateID() const;
};
#endif
| 23.111111 | 56 | 0.766827 |
8bd1cdb01ca9f674a6e03ec579f70decc0f0639f | 4,278 | cpp | C++ | lib/NetworkManager/NetworkManager.cpp | JDuchniewicz/BIBoP | 4a9b59f79ee1f2fd1fd503bb3d6f90a0ba423570 | [
"MIT"
] | null | null | null | lib/NetworkManager/NetworkManager.cpp | JDuchniewicz/BIBoP | 4a9b59f79ee1f2fd1fd503bb3d6f90a0ba423570 | [
"MIT"
] | null | null | null | lib/NetworkManager/NetworkManager.cpp | JDuchniewicz/BIBoP | 4a9b59f79ee1f2fd1fd503bb3d6f90a0ba423570 | [
"MIT"
] | null | null | null | #include "NetworkManager.h"
NetworkManager::NetworkManager(BearSSLClient& sslLambda, MqttClient& mqttClient, Config& config) : sslLambda(sslLambda), mqttClient(mqttClient), m_config(config)
{
}
NetworkManager::~NetworkManager()
{
}
int NetworkManager::init()
{
if (!ECCX08.begin())
{
print("Could not initialize ECCX08!\n");
return -1;
}
ArduinoBearSSL.onGetTime(NetworkManager::getTime);
sslLambda.setEccSlot(0, m_config.certificate);
if (WiFi.status() == WL_NO_MODULE)
{
print("Communication with WiFi module failed!\n");
return -1;
}
mqttClient.setId("BIBOP0");
mqttClient.onMessage(NetworkManager::onMqttMessageTrampoline);
mqttClient.registerOwner(this);
mqttClient.setConnectionTimeout(50 * 1000L); // connection timeout?
mqttClient.setCleanSession(false);
return 0;
}
void NetworkManager::reconnectWiFi()
{
while (WiFi.status() != WL_CONNECTED)
{
print("WiFi is disconected! Reconnecting\n");
connectWiFi();
}
}
int NetworkManager::postWiFi(Batch& batch)
{
prepareMessage(batch);
publishMessage(MESSAGE_BUFFER);
return 0;
}
void NetworkManager::readWiFi()
{
if (!mqttClient.connected())
{
print("%d", mqttClient.connectError());
connectMqtt();
}
mqttClient.poll();
}
bool NetworkManager::serverDisconnectedWiFi()
{
if (!sslLambda.connected())
{
sslLambda.stop();
return true;
}
return false;
}
//TODO: extend this printing?
void NetworkManager::printWifiData()
{
IPAddress ip = WiFi.localIP();
print("IPAddress: %s\n", ip); // not a string lol
}
void NetworkManager::printCurrentNet()
{
print("SSID: %s\n", WiFi.SSID());
}
void NetworkManager::connectWiFi()
{
int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED)
{
print("Attempting to connect to WPA SSID: %s\n", m_config.ssid);
status = WiFi.begin(m_config.ssid, m_config.pass);
delay(7000);
}
print("Success!\n");
//printWifiData(); // no need to print it
}
void NetworkManager::connectMqtt()
{
print("Attempting connection to MQTT broker: %s \n", m_config.broker);
while (!mqttClient.connect(m_config.broker, 8883))
{
// failed, retry
print(".");
delay(1000);
}
print("You're connected to the MQTT broker\n");
// subscribe to a topic
mqttClient.subscribe(m_config.incomingTopic);
}
void NetworkManager::publishMessage(const char* buffer)
{
print("Publishing message %s\n", m_config.outgoingTopic);
// send message, the Print interface can be used to set the message contents
mqttClient.beginMessage(m_config.outgoingTopic, false, 1);
//mqttClient.print("{\"data\": \"hello world\"}");
mqttClient.print(buffer);
mqttClient.endMessage();
}
void NetworkManager::prepareMessage(Batch& batch)
{
print("preparing message\n");
// we could create it using a library, let's do it by hand
// write beginning
char* buffer_pos = MESSAGE_BUFFER;
uint8_t len = 0;
len = sprintf(buffer_pos, "%s", JSON_BEGIN);
buffer_pos += len;
// write the array body
for (uint8_t i = 0; i < INFERENCE_BUFSIZE; ++i)
{
len = sprintf(buffer_pos, "%lu", batch.ppg_red[batch.start_idx + i]);
buffer_pos += len;
len = sprintf(buffer_pos, "%s", ", ");
buffer_pos += len;
}
buffer_pos -= 2; // remove last ", "
// end the array and add string termination
len = sprintf(buffer_pos, "%s", JSON_END);
buffer_pos += len;
sprintf(buffer_pos, "%s", "\0");
// TO SMALL print buffer for printing via my
//print(MESSAGE_BUFFER);
}
unsigned long NetworkManager::getTime()
{
return WiFi.getTime();
}
void NetworkManager::onMqttMessageTrampoline(void* context, int messageLength)
{
return reinterpret_cast<NetworkManager*>(context)->onMqttMessage(messageLength);
}
void NetworkManager::onMqttMessage(int messageLength)
{
// we received a message, print out the topic and contents
print("Received a message with topic '%s', length %d, bytes: \n", mqttClient.messageTopic().c_str(), messageLength);
// use the Stream interface to print the contents
while (mqttClient.available())
{
print("%c", (char)mqttClient.read());
}
print("\n");
}
| 23.766667 | 161 | 0.664095 |
8bd3923a1f206f5181b38bedc643edd41003880e | 800 | cpp | C++ | leetcode/monthly-challenge/2021/06-june/Jump-Game-VI.cpp | leohr/competitive-programming | f97488e0cb777c1df78257ce2644ac4ff8191267 | [
"MIT"
] | 1 | 2020-10-08T19:28:40.000Z | 2020-10-08T19:28:40.000Z | leetcode/monthly-challenge/2021/06-june/Jump-Game-VI.cpp | leohr/competitive-programming | f97488e0cb777c1df78257ce2644ac4ff8191267 | [
"MIT"
] | null | null | null | leetcode/monthly-challenge/2021/06-june/Jump-Game-VI.cpp | leohr/competitive-programming | f97488e0cb777c1df78257ce2644ac4ff8191267 | [
"MIT"
] | 1 | 2020-10-24T02:32:27.000Z | 2020-10-24T02:32:27.000Z | class Solution {
public:
int maxResult(vector<int>& nums, int k) {
int n = nums.size();
priority_queue<pair<int, int>> q;
vector<int> ans(n, -1e9);
for (int i = 0; i < n; ++i) {
if (i == 0) {
ans[i] = nums[i];
q.push({ans[i], i});
} else if (i <= k) {
auto top = q.top();
ans[i] = top.first + nums[i];
q.push({ans[i], i});
} else {
auto top = q.top();
while (i - top.second > k) {
q.pop();
top = q.top();
}
ans[i] = top.first + nums[i];
q.push({ans[i], i});
}
}
return ans[n-1];
}
}; | 29.62963 | 46 | 0.32625 |
8bd8fe8f26629cd8be731da7672b210e93aa76c9 | 123 | cpp | C++ | 4rth_Sem_c++_backup/PRACTICE/Syllabus/reactive/a.cpp | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 16 | 2018-11-26T08:39:42.000Z | 2019-05-08T10:09:52.000Z | 4rth_Sem_c++_backup/PRACTICE/Syllabus/reactive/a.cpp | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 8 | 2020-05-04T06:29:26.000Z | 2022-02-12T05:33:16.000Z | 4rth_Sem_c++_backup/PRACTICE/Syllabus/reactive/a.cpp | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 5 | 2020-02-11T16:02:21.000Z | 2021-02-05T07:48:30.000Z | #include<iostream>
using namespace std;
int main()
{
string s = "My name is Jimut";
system("s > file1");
return 0;
}
| 10.25 | 31 | 0.634146 |
8bd927a52d16e30855525b6dc2926dbcca429807 | 4,721 | cpp | C++ | math/polynomial/old/NTT.cpp | searchstar2017/acmtool | 03392b8909a3d45f10c2711ca4ad9ba69f64a481 | [
"MIT"
] | null | null | null | math/polynomial/old/NTT.cpp | searchstar2017/acmtool | 03392b8909a3d45f10c2711ca4ad9ba69f64a481 | [
"MIT"
] | null | null | null | math/polynomial/old/NTT.cpp | searchstar2017/acmtool | 03392b8909a3d45f10c2711ca4ad9ba69f64a481 | [
"MIT"
] | null | null | null | //g = 3
//998244353, img = 86583718
//1004535809 = 479*2^21+1, img = 483363861
//469762049, img = 19610091
//tp == false means NTT^-1
void NTT(int a[], int n, bool tp) {
for (int i = 0, j = 0; i < n; ++i) {
if (i > j) swap(a[i], a[j]);
for (int k = n >> 1; (j ^= k) < k; k >>= 1);
}
for (int i = 2; i <= n; i <<= 1) {
int wn = mpow(3, tp ? (p - 1) / i : p - 1 - (p-1)/i, p);
for (int pa = i >> 1, j = 0; j < n; j += i) {
for (int w = 1, k = 0; k < pa; ++k, w = (LL)w * wn % p) {
int t = (LL)w * a[j + k + pa] % p;
a[j + k + pa] = Sub(a[j + k] - t, p);
AddMod(a[j + k] += t, p);
}
}
}
if (!tp)
for (int i = 0, n1 = mpow(n, p-2, p); i < n; ++i)
a[i] = (LL)a[i] * n1 % p;
}
int FindPowOf2(int to) {
int n;
for (n = 1; n < to; n <<= 1);
return n;
}
void Fill(int a[], int na, int n) {
for (; na < n; ++na)
a[na] = 0;
}
//a and b are destroyed
//Allow c == a or b
void Mul(int c[], int a[], int na, int b[], int nb) {
int n = FindPowOf2(na + nb); //in FFT
Fill(a, na, n);
Fill(b, nb, n);
NTT(a, n, true);
NTT(b, n, true);
for (int i = 0; i < n; ++i)
c[i] = (LL)a[i] * b[i] % p;
NTT(c, n, false);
}
//n == 2^k
//mod x^n
//b != a
//Do not need Initialize b
//The upper n elements of b is 0
void Inv(int b[], const int a[], int n) {
static int t[MAX2N];
if (n == 1) {
b[0] = mpow(a[0], p - 2, p);
b[1] = 0; //necessary?
return;
}
Inv(b, a, n >> 1);
memset(b + n, 0, n * sizeof(b[0]));
NTT(b, n << 1, true);
memcpy(t, a, n * sizeof(int));
memset(t + n, 0, n * sizeof(int));
NTT(t, n << 1, true);
for (int i = 0, r = n << 1; i < r; ++i)
b[i] = (LL)b[i] * Sub(2 - (LL)t[i] * b[i] % p, p) % p;
NTT(b, n << 1, false);
memset(b+n, 0, n * sizeof(int));
}
//quo = a / b
//Allow quo == a or b
//b[0...nb-1] is reversed
//quo[i] != 0 if i >= nq
void Div(int quo[], int& nq, int a[], int na, int b[], int nb) {
static int t[MAX2N];
nq = na - nb + 1; //length of quo
reverse(a, a + na);
reverse(b, b + nb);
int len = FindPowOf2(nq);
Fill(b, nb, len);
Inv(t, b, len);
Fill(a, na, len);
Mul(quo, a, len, t, len);
reverse(quo, quo + nq);
}
//quo != a && quo != b
//rem != a
//Allow rem == b
//quo[i] != 0 if i >= nq
//len(rem) == nb - 1
void DivMod(int quo[], int& nq, int rem[], const int a[], int na, int b[], int nb) {
static int t[MAX2N];
memcpy(t, a, na * sizeof(a[0]));
Div(quo, nq, t, na, b, nb);
reverse(b, b + nb); //reverse back
memcpy(t, quo, nq * sizeof(t[0]));
Mul(rem, t, nq, b, nb);
for (int i = 0; i < nb - 1; ++i)
rem[i] = Sub(a[i] - rem[i], p);
}
//Allow b == a
void Derivation(int b[], int a[], int n) {
for (int i = 1; i < n; ++i)
b[i-1] = (LL)i * a[i] % p;
b[n-1] = 0;
}
//Allow b == a
//mod x ^ n
void Integral(int b[], int a[], int n) {
for (int i = n - 1; i; --i)
b[i] = (LL)a[i-1] * Inv(i, p) % p;
b[0] = 0;
}
//b = ln(a) mod x ^ n
//n == 2 ^ k
//Allow b == a
void ln(int b[], int a[], int n) {
static int t[MAX2N];
Inv(t, a, n);
Derivation(a, a, n);
Mul(a, a, n, t, n);
Integral(b, a, n);
}
//O(nlog n)
//If a[0] == 0, then b0 == 1
//n == 2^k
//b != a
//The upper n elements of b is 0
void exp(int b[], int b0, const int a[], int n) {
static int t[MAX2N];
if (1 == n) {
b[0] = b0;
b[1] = 0;
} else {
exp(b, b0, a, n >> 1);
memcpy(t, b, n * sizeof(b[0]));
ln(t, t, n);
t[0] = Sub(Add(1 + a[0], p) - t[0], p);
for (int i = 1; i < n; ++i)
t[i] = Sub(a[i] - t[i], p);
Mul(b, b, n, t, n);
memset(b + n, 0, n * sizeof(b[0]));
}
}
//pg is the primitive root of p
int KthRoot(int x, int k, int p, int pg) {
int ret = mpow(pg, BSGS(pg, x, p) / k, p);
return min(ret, p - ret);
}
//Exists b0 such that b0^k = a0 (mod p)
//n == 2^kk
//b != a
void KthRoot(int b[], int a[], int n, int k) {
int b0 = KthRoot(a[0], k, p, 3);
ln(a, a, n);
int tmp = Inv(k, p);
for (int i = 0; i < n; ++i)
a[i] = (LL)a[i] * tmp % p;
exp(b, b0, a, n);
}
//a[0] != 0
//O(nlgn)
//n == 2^kk
//b != a
void pow(int b[], int a[], int n, int k) {
int b0 = mpow(a[0], k, p);
ln(a, a, n);
for (int i = 0; i < n; ++i)
a[i] = (LL)a[i] * k % p;
exp(b, b0, a, n);
}
//Allow a[0] == 0
//Allow n != 2^kk
//mod x^na
void pow(int a[], int na, int k) {
static int t[MAX2N];
int l0;
for (l0 = 0; l0 < na && 0 == a[l0]; ++l0);
memmove(a, a + l0, (na - l0) * sizeof(a[0]));
int n = FindPowOf2(na - l0); //if na == 0, then n == 1
Fill(a, na - l0, n);
pow(t, a, n, k);
Fill(t, n, na);
l0 = min((LL)l0 * k, (LL)na);
memset(a, 0, l0 * sizeof(a[0]));
memcpy(a + l0, t, (na - l0) * sizeof(a[0]));
}
| 23.843434 | 84 | 0.446304 |
8bdd72e6b0116540e8a2096bbf6c57c328c7a394 | 9,861 | cpp | C++ | src/pylink.cpp | dnaroma/texture2ddecoder | 26bc56b2b655e2ea41ff41bbef7b6c55e44bbf60 | [
"MIT"
] | 7 | 2020-07-30T14:30:33.000Z | 2022-01-30T12:20:48.000Z | src/pylink.cpp | dnaroma/texture2ddecoder | 26bc56b2b655e2ea41ff41bbef7b6c55e44bbf60 | [
"MIT"
] | 1 | 2020-09-14T07:48:47.000Z | 2020-09-14T07:48:47.000Z | src/pylink.cpp | dnaroma/texture2ddecoder | 26bc56b2b655e2ea41ff41bbef7b6c55e44bbf60 | [
"MIT"
] | 6 | 2020-08-01T00:41:05.000Z | 2021-10-01T07:56:31.000Z | #define PY_SSIZE_T_CLEAN
#pragma once
#include <Python.h>
#include "bcn.h"
#include "pvrtc.h"
#include "etc.h"
#include "atc.h"
#include "astc.h"
#include "crunch.h"
#include "unitycrunch.h"
/*
*************************************************
*
* general decoder function headers
*
************************************************
*/
static PyObject *decode(PyObject *self, PyObject *args, int (*func)(const uint8_t *, const long, const long, uint32_t *));
static PyObject *decode_bc(PyObject *self, PyObject *args, int (*func)(const uint8_t *, uint32_t, uint32_t, uint32_t *));
/*
*************************************************
*
* decoder functions
* which use the general decoders
************************************************
*/
static PyObject *_decode_bc1(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_bc1);
}
static PyObject *_decode_bc3(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_bc3);
}
static PyObject *_decode_etc1(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_etc1);
}
static PyObject *_decode_etc2(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_etc2);
}
static PyObject *_decode_etc2a1(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_etc2a1);
}
static PyObject *_decode_etc2a8(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_etc2a8);
}
static PyObject *_decode_eacr(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_eacr);
}
static PyObject *_decode_eacr_signed(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_eacr_signed);
}
static PyObject *_decode_eacrg(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_eacrg);
}
static PyObject *_decode_eacrg_signed(PyObject *self, PyObject *args)
{
return decode(self, args, &decode_eacrg_signed);
}
static PyObject *_decode_bc4(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_bc4);
}
static PyObject *_decode_bc5(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_bc5);
}
static PyObject *_decode_bc6(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_bc6);
}
static PyObject *_decode_bc7(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_bc7);
}
static PyObject *_decode_atc_rgb4(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_atc_rgb4);
}
static PyObject *_decode_atc_rgba8(PyObject *self, PyObject *args)
{
return decode_bc(self, args, &decode_atc_rgba8);
}
/*
*************************************************
*
* decoder functions
* which don't use the general decoders
************************************************
*/
static PyObject *_decode_pvrtc(PyObject *self, PyObject *args)
{
// define vars
const uint8_t *data;
size_t data_size;
uint32_t width, height;
bool is2bpp = 0;
if (!PyArg_ParseTuple(args, "y#ii|b", &data, &data_size, &width, &height, &is2bpp))
return NULL;
// reserve return image
uint32_t *buf = (uint32_t *)malloc(width * height * 4); // always BGRA
if (buf == NULL)
return PyErr_NoMemory();
// decode
if (!decode_pvrtc(data, width, height, buf, is2bpp ? 1 : 0))
return NULL;
// return
PyObject *res = Py_BuildValue("y#", buf, width * height * 4);
free(buf);
return res;
}
static PyObject *_decode_astc(PyObject *self, PyObject *args)
{
// define vars
const uint8_t *data;
size_t data_size;
uint32_t width, height, block_width, block_height;
if (!PyArg_ParseTuple(args, "y#iiii", &data, &data_size, &width, &height, &block_width, &block_height))
return NULL;
// reserve return image
uint32_t *buf = (uint32_t *)malloc(width * height * 4); // always RGBA
if (buf == NULL)
return PyErr_NoMemory();
// decode
if (!decode_astc(data, width, height, block_width, block_height, buf))
return NULL;
// return
PyObject *res = Py_BuildValue("y#", buf, width * height * 4);
free(buf);
return res;
}
static PyObject *_unpack_crunch(PyObject *self, PyObject *args)
{
// define vars
const uint8_t *data;
uint32_t data_size;
if (!PyArg_ParseTuple(args, "y#", &data, &data_size))
return NULL;
void *ret;
uint32_t retSize;
if (!crunch_unpack_level(data, data_size, 0, &ret, &retSize))
{
return NULL;
}
PyObject *res = Py_BuildValue("y#", ret, retSize);
delete ret;
return res;
}
static PyObject *_unpack_unity_crunch(PyObject *self, PyObject *args)
{
// define vars
const uint8_t *data;
uint32_t data_size;
if (!PyArg_ParseTuple(args, "y#", &data, &data_size))
return NULL;
void *ret;
uint32_t retSize;
if (!unity_crunch_unpack_level(data, data_size, 0, &ret, &retSize))
{
return NULL;
}
PyObject *res = Py_BuildValue("y#", ret, retSize);
delete ret;
return res;
}
/*
*************************************************
*
* general decoder functions
*
************************************************
*/
static PyObject *decode(PyObject *self, PyObject *args, int (*func)(const uint8_t *, const long, const long, uint32_t *))
{
// define vars
const uint8_t *data;
size_t data_size;
uint32_t width, height;
if (!PyArg_ParseTuple(args, "y#ii", &data, &data_size, &width, &height))
return NULL;
// reserve return image
uint32_t *buf = (uint32_t *)malloc(width * height * 4); // always RGBA
if (buf == NULL)
return PyErr_NoMemory();
// decode
if (!func(data, width, height, buf))
return NULL;
// return
PyObject *res = Py_BuildValue("y#", buf, width * height * 4);
free(buf);
return res;
}
static PyObject *decode_bc(PyObject *self, PyObject *args, int (*func)(const uint8_t *, uint32_t, uint32_t, uint32_t *))
{
// define vars
const uint8_t *data;
size_t data_size;
uint32_t width, height;
if (!PyArg_ParseTuple(args, "y#ii", &data, &data_size, &width, &height))
return NULL;
// reserve return image
uint32_t *buf = (uint32_t *)malloc(width * height * 4); // always RGBA
if (buf == NULL)
return PyErr_NoMemory();
// decode
if (!func(data, width, height, buf))
return NULL;
// return
PyObject *res = Py_BuildValue("y#", buf, width * height * 4);
free(buf);
return res;
}
/*
*************************************************
*
* python connection
*
************************************************
*/
// Exported methods are collected in a table
static struct PyMethodDef method_table[] = {
{"decode_bc1",
(PyCFunction)_decode_bc1,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_bc3",
(PyCFunction)_decode_bc3,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_pvrtc",
(PyCFunction)_decode_pvrtc,
METH_VARARGS,
"bytes data, long w, long h, bytes image, bool is2bpp"},
{"decode_etc1",
(PyCFunction)_decode_etc1,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_etc2",
(PyCFunction)_decode_etc2,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_etc2a1",
(PyCFunction)_decode_etc2a1,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_etc2a8",
(PyCFunction)_decode_etc2a8,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_eacr",
(PyCFunction)_decode_eacr,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_eacr_signed",
(PyCFunction)_decode_eacr_signed,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_eacrg",
(PyCFunction)_decode_eacrg,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_eacrg_signed",
(PyCFunction)_decode_eacrg_signed,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_bc4",
(PyCFunction)_decode_bc4,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_bc5",
(PyCFunction)_decode_bc5,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_bc6",
(PyCFunction)_decode_bc6,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_bc7",
(PyCFunction)_decode_bc7,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_atc_rgb4",
(PyCFunction)_decode_atc_rgb4,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_atc_rgba8",
(PyCFunction)_decode_atc_rgba8,
METH_VARARGS,
"bytes data, long w, long h, bytes image"},
{"decode_astc",
(PyCFunction)_decode_astc,
METH_VARARGS,
"bytes data, long w, long h, int bw, int bh, bytes image"},
{"unpack_crunch",
(PyCFunction)_unpack_crunch,
METH_VARARGS,
"bytes data"},
{"unpack_unity_crunch",
(PyCFunction)_unpack_unity_crunch,
METH_VARARGS,
"bytes data"},
{NULL,
NULL,
0,
NULL} // Sentinel value ending the table
};
// A struct contains the definition of a module
static PyModuleDef texture2ddecoder_module = {
PyModuleDef_HEAD_INIT,
"texture2ddecoder", // Module name
"a python wrapper for Perfare's Texture2DDecoder",
-1, // Optional size of the module state memory
method_table,
NULL, // Optional slot definitions
NULL, // Optional traversal function
NULL, // Optional clear function
NULL // Optional module deallocation function
};
// The module init function
PyMODINIT_FUNC PyInit_texture2ddecoder(void)
{
return PyModule_Create(&texture2ddecoder_module);
} | 25.612987 | 122 | 0.621945 |
8be25858f3e7b9b7e9b266288f67868a4b5d33f4 | 122 | hxx | C++ | src/Providers/UNIXProviders/MoreRoleInfo/UNIX_MoreRoleInfo_FREEBSD.hxx | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | 1 | 2020-10-12T09:00:09.000Z | 2020-10-12T09:00:09.000Z | src/Providers/UNIXProviders/MoreRoleInfo/UNIX_MoreRoleInfo_FREEBSD.hxx | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | null | null | null | src/Providers/UNIXProviders/MoreRoleInfo/UNIX_MoreRoleInfo_FREEBSD.hxx | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | null | null | null | #ifdef PEGASUS_OS_FREEBSD
#ifndef __UNIX_MOREROLEINFO_PRIVATE_H
#define __UNIX_MOREROLEINFO_PRIVATE_H
#endif
#endif
| 10.166667 | 37 | 0.844262 |
8be26060043e9e577dbd7dd61d6427a1eef90c5e | 2,555 | cpp | C++ | gametitle.cpp | Mokona/Caterbuino | d7c0382f6769472584d8c3afb2b673005efa4b32 | [
"MIT"
] | null | null | null | gametitle.cpp | Mokona/Caterbuino | d7c0382f6769472584d8c3afb2b673005efa4b32 | [
"MIT"
] | null | null | null | gametitle.cpp | Mokona/Caterbuino | d7c0382f6769472584d8c3afb2b673005efa4b32 | [
"MIT"
] | null | null | null | #include "gametitle.h"
#include "buttonwidget.h"
#include "data_title.h"
#include "gamecredits.h"
#include "gamerunning.h"
#include "gamebuino_fix.h"
#include <cassert>
namespace {
uint16_t gameStartSound[] = {
0x0005,
0x178, 0x17A, 0x27C, 0x17E, 0x180, 0x286, 0x188,
0x0000
};
const char* PLAY_TEXT = "PLAY";
ButtonWidget::Parameters startWidgetParameters = {
{ 25, 47 },
{ 5, 52 },
ButtonWidget::BLINK_A,
PLAY_TEXT
};
const char* CREDITS_TEXT = "CREDITS";
ButtonWidget::Parameters creditWidgetParameters = {
{ 30, 47 },
{ 2, 52 },
ButtonWidget::BLINK_MENU,
CREDITS_TEXT
};
uint8_t TIME_FOR_ALTERNATE_WIDGET = 50;
}
GameTitle::GameTitle()
: titleImage(new Gamebuino_Meta::Image(getTitleData()))
, startGameDisplay(new ButtonWidget(startWidgetParameters))
, goToCreditsDisplay(new ButtonWidget(creditWidgetParameters))
, alternateTimer(TIME_FOR_ALTERNATE_WIDGET)
{
gb.sound.play(gameStartSound);
}
void GameTitle::update()
{
gb.display.drawImage(0, 0, *titleImage);
gb.display.setColor(Color::gray);
gb.display.setFontSize(1);
gb.display.setCursor(64, 59);
gb.display.println("v0.9");
widgetUpdateAndDisplay();
if (gb.buttons.pressed(BUTTON_A)) {
start_game();
} else if (gb.buttons.pressed(BUTTON_MENU)) {
start_credits();
}
}
void GameTitle::widgetUpdateAndDisplay()
{
if (alternateTimer == 0) {
alternateTimer = TIME_FOR_ALTERNATE_WIDGET;
currentWidgetDisplayed = currentWidgetDisplayed == 0 ? 1 : 0;
} else {
alternateTimer -= 1;
}
if (currentWidgetDisplayed == 0) {
startGameDisplay->update();
startGameDisplay->display();
} else {
goToCreditsDisplay->update();
goToCreditsDisplay->display();
}
}
void GameTitle::start_game()
{
action = GO_TO_GAME;
}
void GameTitle::start_credits()
{
action = GO_TO_CREDITS;
}
bool GameTitle::finished()
{
return action != STAY_HERE;
}
std::unique_ptr<GameState> GameTitle::new_state()
{
assert(finished());
auto& take_action = action;
auto state = [take_action]() -> std::unique_ptr<GameState> {
switch (take_action) {
case GO_TO_GAME:
return std::unique_ptr<GameState>(new GameRunning());
case GO_TO_CREDITS:
return std::unique_ptr<GameState>(new GameCredits());
}
return {};
}();
action = STAY_HERE;
return state;
};
| 22.025862 | 69 | 0.631703 |
8be4b026bf77bd09921dacc33943207f05634cf9 | 5,083 | cpp | C++ | src/mainwindow.cpp | vnord/yet-another-spotify-tray | 1b7791112999e887f24ea0d3bae6037bbc1f8cd6 | [
"MIT"
] | 4 | 2021-11-29T11:08:06.000Z | 2022-03-06T16:44:48.000Z | src/mainwindow.cpp | vnord/yet-another-spotify-tray | 1b7791112999e887f24ea0d3bae6037bbc1f8cd6 | [
"MIT"
] | 3 | 2021-12-19T16:17:24.000Z | 2022-03-07T13:53:58.000Z | src/mainwindow.cpp | vnord/yet-another-spotify-tray | 1b7791112999e887f24ea0d3bae6037bbc1f8cd6 | [
"MIT"
] | 2 | 2021-12-19T17:15:27.000Z | 2022-03-06T20:55:24.000Z | #include <QtCore>
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.hpp"
MainWindow::MainWindow()
: dbus("org.mpris.MediaPlayer2.spotify",
"/org/mpris/MediaPlayer2",
"org.mpris.MediaPlayer2.Player",
QDBusConnection::sessionBus()) {
setWindowTitle(tr("Spotify"));
setWindowIcon(QIcon(":/icons/spotify-client.png"));
trayIcon = new QSystemTrayIcon(QIcon(":/icons/spotify-intray.png"), this);
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated);
quitAction = new QAction(QIcon::fromTheme("application-exit"), tr("&Quit Spotify"), this);
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
prevAction = new QAction(QIcon::fromTheme("media-skip-backward"), tr("Pre&vious Track"), this);
connect(prevAction, &QAction::triggered, this, &MainWindow::prev);
nextAction = new QAction(QIcon::fromTheme("media-skip-forward"), tr("&Next Track"), this);
connect(nextAction, &QAction::triggered, this, &MainWindow::next);
playAction = new QAction(QIcon::fromTheme("media-playback-start"), tr("P&lay"), this);
connect(playAction, &QAction::triggered, this, &MainWindow::play);
pauseAction = new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause"), this);
pauseAction->setVisible(false);
connect(pauseAction, &QAction::triggered, this, &MainWindow::pause);
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(prevAction);
trayIconMenu->addAction(playAction);
trayIconMenu->addAction(pauseAction);
trayIconMenu->addAction(nextAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
QDBusConnection::sessionBus().connect(nullptr, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties",
"PropertiesChanged", this,
SLOT(dbusPropertiesChanged(QString, QVariantMap, QStringList)));
trayIcon->setToolTip(tr("Spotify"));
trayIcon->setContextMenu(trayIconMenu);
trayIcon->show();
}
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) {
switch (reason) {
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::DoubleClick:
if (isVisible()) {
hide();
} else {
show();
raise();
activateWindow();
}
break;
case QSystemTrayIcon::MiddleClick: break;
default:;
}
}
void MainWindow::closeEvent(QCloseEvent* event) {
if (trayIcon->isVisible()) {
hide();
event->ignore();
}
}
void MainWindow::prev() { dbus.call("Previous"); }
void MainWindow::next() { dbus.call("Next"); }
void MainWindow::play() { dbus.call("Play"); }
void MainWindow::pause() { dbus.call("Pause"); }
void MainWindow::dbusPropertiesChanged(const QString& name, const QVariantMap& properties, const QStringList&) {
if (name == "org.mpris.MediaPlayer2.Player") {
if (properties.contains("PlaybackStatus")) {
QString status = properties["PlaybackStatus"].toString();
if (status == "Playing") {
playAction->setVisible(false);
pauseAction->setVisible(true);
} else {
playAction->setVisible(true);
pauseAction->setVisible(false);
}
}
if (properties.contains("Metadata")) {
QVariantMap metadata;
if (properties["Metadata"].type() == QVariant::Map) {
metadata = properties["Metadata"].toMap();
} else {
properties["Metadata"].value<QDBusArgument>() >> metadata;
}
// for (QVariantMap::const_iterator it = metadata.cbegin(), end = metadata.cend(); it != end; ++it) {
// qDebug() << "metadata: " << it.key() << " value: " << it.value();
// }
QString title = metadata["xesam:title"].toString();
QString artist = metadata["xesam:artist"].toStringList().join(", ");
// QString album = metadata["xesam:album"].toString();
if (title.isEmpty()) {
title = artist;
artist = "";
}
if (!title.isEmpty()) {
if (!artist.isEmpty())
trayIcon->setToolTip(tr("Spotify - %1 - %2").arg(title).arg(artist));
else
trayIcon->setToolTip(tr("Spotify - %1").arg(title));
} else {
trayIcon->setToolTip(tr("Spotify"));
}
// QString cover = metadata["mpris:artUrl"].toString();
// if (!cover.isEmpty()) {
// QPixmap pixmap;
// pixmap.loadFromData(QByteArray::fromBase64(cover.toUtf8()));
// trayIcon->setIcon(pixmap);
// } else {
// trayIcon->setIcon(QIcon::fromTheme("spotify", QIcon("/usr/share/pixmaps/spotify-client.png")));
// }
}
}
}
| 36.307143 | 114 | 0.577808 |
8be613f577fd369a92cf747a51ff5fc0ac3c9ded | 678 | hpp | C++ | include/sprout/preprocessor/u16str.hpp | thinkoid/Sprout | a5a5944bb1779d3bb685087c58c20a4e18df2f39 | [
"BSL-1.0"
] | 4 | 2021-12-29T22:17:40.000Z | 2022-03-23T11:53:44.000Z | dsp/lib/sprout/sprout/preprocessor/u16str.hpp | TheSlowGrowth/TapeLooper | ee8d8dccc27e39a6f6f6f435847e4d5e1b97c264 | [
"MIT"
] | 16 | 2021-10-31T21:41:09.000Z | 2022-01-22T10:51:34.000Z | include/sprout/preprocessor/u16str.hpp | thinkoid/Sprout | a5a5944bb1779d3bb685087c58c20a4e18df2f39 | [
"BSL-1.0"
] | null | null | null | /*=============================================================================
Copyright (c) 2011-2019 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
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)
=============================================================================*/
#ifndef SPROUT_PREPROCESSOR_U16STR_HPP
#define SPROUT_PREPROCESSOR_U16STR_HPP
#include <sprout/config.hpp>
//
// SPROUT_PP_U16STR
//
#define SPROUT_PP_U16STR(str) SPROUT_PP_U16STR_I(str)
#define SPROUT_PP_U16STR_I(str) u ## str
#endif // #ifndef SPROUT_PREPROCESSOR_U16STR_HPP
| 33.9 | 79 | 0.60767 |
8bf4ae03c6a823d072c08f0afd8d61fbadebcccc | 13,444 | cpp | C++ | ssc/cmod_pv6parmod.cpp | gjsoto/ssc | 70ef4fdafb9afe0418a9c552485a7116a1b3a743 | [
"BSD-3-Clause"
] | 61 | 2017-08-09T15:10:59.000Z | 2022-02-15T21:45:31.000Z | ssc/cmod_pv6parmod.cpp | gjsoto/ssc | 70ef4fdafb9afe0418a9c552485a7116a1b3a743 | [
"BSD-3-Clause"
] | 462 | 2017-07-31T21:26:46.000Z | 2022-03-30T22:53:50.000Z | ssc/cmod_pv6parmod.cpp | gjsoto/ssc | 70ef4fdafb9afe0418a9c552485a7116a1b3a743 | [
"BSD-3-Clause"
] | 73 | 2017-08-24T17:39:31.000Z | 2022-03-28T08:37:47.000Z | /**
BSD-3-Clause
Copyright 2019 Alliance for Sustainable Energy, LLC
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER, CONTRIBUTORS, UNITED STATES GOVERNMENT OR UNITED STATES
DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#ifndef M_PI
#define M_PI 3.141592653589793238462643
#endif
#include "core.h"
#include "lib_cec6par.h"
#include "lib_irradproc.h"
static var_info _cm_vtab_pv6parmod[] = {
/* VARTYPE DATATYPE NAME LABEL UNITS META GROUP REQUIRED_IF CONSTRAINTS UI_HINTS*/
{ SSC_INPUT, SSC_ARRAY, "poa_beam", "Incident direct normal radiation","W/m2", "", "Weather", "*", "", "" },
{ SSC_INPUT, SSC_ARRAY, "poa_skydiff", "Incident sky diffuse radiation", "W/m2", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "poa_gnddiff", "Incident ground diffuse irradiance","W/m2","", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "tdry", "Dry bulb temperature", "'C", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "wspd", "Wind speed", "m/s", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "wdir", "Wind direction", "deg", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "sun_zen", "Sun zenith angle", "deg", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "incidence", "Incidence angle to surface", "deg", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_ARRAY, "surf_tilt", "Surface tilt angle", "deg", "", "Weather", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_INPUT, SSC_NUMBER, "elev", "Site elevation", "m", "", "Weather", "*", "", "" },
{ SSC_INPUT, SSC_ARRAY, "opvoltage", "Module operating voltage", "Volt", "", "CEC 6 Parameter PV Module Model", "?" "", "" },
{ SSC_INPUT, SSC_NUMBER, "area", "Module area", "m2", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Vmp", "Maximum power point voltage", "V", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Imp", "Maximum power point current", "A", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Voc", "Open circuit voltage", "V", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Isc", "Short circuit current", "A", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "alpha_isc", "Temp coeff of current at SC", "A/'C", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "beta_voc", "Temp coeff of voltage at OC", "V/'C", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "gamma_pmp", "Temp coeff of power at MP", "%/'C", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "tnoct", "NOCT cell temperature", "'C", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "a", "Modified nonideality factor", "1/V", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Il", "Light current", "A", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Io", "Saturation current", "A", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Rs", "Series resistance", "ohm", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Rsh", "Shunt resistance", "ohm", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "Adj", "OC SC temp coeff adjustment", "%", "", "CEC 6 Parameter PV Module Model", "*", "", "" },
{ SSC_INPUT, SSC_NUMBER, "standoff", "Mounting standoff option", "0..6", "0=bipv, 1= >3.5in, 2=2.5-3.5in, 3=1.5-2.5in, 4=0.5-1.5in, 5= <0.5in, 6=ground/rack", "CEC 6 Parameter PV Module Model", "?=6", "INTEGER,MIN=0,MAX=6", "" },
{ SSC_INPUT, SSC_NUMBER, "height", "System installation height", "0/1", "0=less than 22ft, 1=more than 22ft", "CEC 6 Parameter PV Module Model", "?=0", "INTEGER,MIN=0,MAX=1", "" },
{ SSC_OUTPUT, SSC_ARRAY, "tcell", "Cell temperature", "'C", "", "CEC 6 Parameter PV Module Model", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_OUTPUT, SSC_ARRAY, "dc_voltage", "DC module voltage", "Volt", "", "CEC 6 Parameter PV Module Model", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_OUTPUT, SSC_ARRAY, "dc_current", "DC module current", "Ampere", "", "CEC 6 Parameter PV Module Model", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_OUTPUT, SSC_ARRAY, "eff", "Conversion efficiency", "0..1", "", "CEC 6 Parameter PV Module Model", "*", "LENGTH_EQUAL=poa_beam", "" },
{ SSC_OUTPUT, SSC_ARRAY, "dc", "DC power output", "Watt", "", "CEC 6 Parameter PV Module Model", "*", "LENGTH_EQUAL=poa_beam", "" },
var_info_invalid };
class cm_pv6parmod : public compute_module
{
private:
public:
cm_pv6parmod()
{
add_var_info( _cm_vtab_pv6parmod );
}
void exec( )
{
size_t arr_len;
ssc_number_t *p_poabeam = as_array( "poa_beam", &arr_len );
ssc_number_t *p_poaskydiff = as_array( "poa_skydiff", &arr_len );
ssc_number_t *p_poagnddiff = as_array( "poa_gnddiff", &arr_len );
ssc_number_t *p_tdry = as_array( "tdry", &arr_len );
ssc_number_t *p_wspd = as_array( "wspd", &arr_len );
ssc_number_t *p_wdir = as_array( "wdir", &arr_len );
ssc_number_t *p_inc = as_array( "incidence", &arr_len );
ssc_number_t *p_zen = as_array( "sun_zen", &arr_len );
ssc_number_t *p_stilt = as_array( "surf_tilt", &arr_len );
double site_elevation = as_double("elev");
cec6par_module_t mod;
mod.Area = as_double("area");
mod.Vmp = as_double("Vmp");
mod.Imp = as_double("Imp");
mod.Voc = as_double("Voc");
mod.Isc = as_double("Isc");
mod.alpha_isc = as_double("alpha_isc");
mod.beta_voc = as_double("beta_voc");
mod.a = as_double("a");
mod.Il = as_double("Il");
mod.Io = as_double("Io");
mod.Rs = as_double("Rs");
mod.Rsh = as_double("Rsh");
mod.Adj = as_double("Adj");
noct_celltemp_t tc;
tc.Tnoct = as_double("tnoct");
int standoff = as_integer("standoff");
tc.standoff_tnoct_adj = 0;
switch(standoff)
{ //source for standoff adjustment constants: https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/1985/850330.pdf page 12
case 2: tc.standoff_tnoct_adj = 2; break; // between 2.5 and 3.5 inches
case 3: tc.standoff_tnoct_adj = 6; break; // between 1.5 and 2.5 inches
case 4: tc.standoff_tnoct_adj = 11; break; // between 0.5 and 1.5 inches
case 5: tc.standoff_tnoct_adj = 18; break; // less than 0.5 inches
// note: all others, standoff_tnoct_adj = 0;
}
int height = as_integer("height");
tc.ffv_wind = 0.51;
if ( height == 1 )
tc.ffv_wind = 0.61;
ssc_number_t *opvoltage = 0;
if ( is_assigned("opvoltage") )
{
size_t opvlen = 0;
opvoltage = as_array( "opvoltage", &opvlen );
if ( opvlen != arr_len )
throw general_error("operating voltage array must be same length as input vectors");
}
ssc_number_t *p_tcell = allocate("tcell", arr_len);
ssc_number_t *p_volt = allocate("dc_voltage", arr_len);
ssc_number_t *p_amp = allocate("dc_current", arr_len);
ssc_number_t *p_eff = allocate("eff", arr_len);
ssc_number_t *p_dc = allocate("dc", arr_len);
for (size_t i = 0; i < arr_len; i++ )
{
pvinput_t in;
in.Ibeam = (double) p_poabeam[i];
in.Idiff = (double) p_poaskydiff[i];
in.Ignd = (double) p_poagnddiff[i];
in.Tdry = (double) p_tdry[i];
in.Wspd = (double) p_wspd[i];
in.Wdir = (double) p_wdir[i];
in.Zenith = (double) p_zen[i];
in.IncAng = (double) p_inc[i];
in.Elev = site_elevation;
in.Tilt = (double) p_stilt[i];
pvoutput_t out;
double opv = -1; // by default, calculate MPPT
if ( opvoltage != 0 )
opv = opvoltage[i];
double tcell = in.Tdry;
if (! tc( in, mod, opv, tcell ) ) throw general_error("error calculating cell temperature", (float)i);
if (! mod( in, tcell, opv, out ) ) throw general_error( "error calculating module power and temperature with given parameters", (float) i);
p_tcell[i] = (ssc_number_t)out.CellTemp;
p_volt[i] = (ssc_number_t)out.Voltage;
p_amp[i] = (ssc_number_t)out.Current;
p_eff[i] = (ssc_number_t)out.Efficiency;
p_dc[i] = (ssc_number_t)out.Power;
}
}
};
DEFINE_MODULE_ENTRY( pv6parmod, "CEC 6 Parameter PV module model performance calculator. Does not include weather file reading or irradiance processing, or inverter (DC to AC) modeling.", 1 )
| 73.065217 | 280 | 0.484677 |