hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
sequencelengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
sequencelengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
sequencelengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
efac67313dd9bd9f69caae66d56b1ffaf67e9911 | 1,591 | hpp | C++ | internal/o80_internal/controllers_manager.hpp | luator/o80 | 65fe75bc6d375db0e4a2fe075c097a54dde7b571 | [
"BSD-3-Clause"
] | null | null | null | internal/o80_internal/controllers_manager.hpp | luator/o80 | 65fe75bc6d375db0e4a2fe075c097a54dde7b571 | [
"BSD-3-Clause"
] | null | null | null | internal/o80_internal/controllers_manager.hpp | luator/o80 | 65fe75bc6d375db0e4a2fe075c097a54dde7b571 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (C) 2019 Max Planck Gesellschaft
// Author : Vincent Berenz
#pragma once
#include <memory>
#include "command.hpp"
#include "controller.hpp"
#include "o80/states.hpp"
#include "time_series/multiprocess_time_series.hpp"
namespace o80
{
template <int NB_ACTUATORS, int QUEUE_SIZE, class STATE>
class ControllersManager
{
public:
typedef std::array<Controller<STATE>, NB_ACTUATORS> Controllers;
typedef time_series::MultiprocessTimeSeries<Command<STATE>>
CommandsTimeSeries;
typedef time_series::MultiprocessTimeSeries<int>
CompletedCommandsTimeSeries;
public:
ControllersManager(std::string segment_id);
void process_commands(long int current_iteration);
STATE get_desired_state(int dof,
long int current_iteration,
const TimePoint &time_now,
const STATE ¤t_state);
int get_current_command_id(int dof) const;
void get_newly_executed_commands(std::queue<int> &get);
bool reapplied_desired_states() const;
CommandsTimeSeries &get_commands_time_series();
CompletedCommandsTimeSeries &get_completed_commands_time_series();
private:
std::string segment_id_;
CommandsTimeSeries commands_;
long int pulse_id_;
time_series::Index commands_index_;
CompletedCommandsTimeSeries completed_commands_;
Controllers controllers_;
States<NB_ACTUATORS, STATE> previous_desired_states_;
std::array<bool, NB_ACTUATORS> initialized_;
long int relative_iteration_;
};
}
#include "controllers_manager.hxx"
| 27.912281 | 70 | 0.733501 | luator |
eface07d49cd2d31155cbaf2a0de6163d32bde90 | 5,470 | cc | C++ | nacl/net/rtp/rtp_sender.cc | maxsong11/nacld | c4802cc7d9bda03487bde566a3003e8bc0f574d3 | [
"BSD-3-Clause"
] | 9 | 2015-12-23T21:18:28.000Z | 2018-11-25T10:10:12.000Z | nacl/net/rtp/rtp_sender.cc | maxsong11/nacld | c4802cc7d9bda03487bde566a3003e8bc0f574d3 | [
"BSD-3-Clause"
] | 1 | 2016-01-08T20:56:21.000Z | 2016-01-08T20:56:21.000Z | nacl/net/rtp/rtp_sender.cc | maxsong11/nacld | c4802cc7d9bda03487bde566a3003e8bc0f574d3 | [
"BSD-3-Clause"
] | 6 | 2015-12-04T18:23:49.000Z | 2018-11-06T03:52:58.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Copyright 2015 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/rtp/rtp_sender.h"
#include "base/big_endian.h"
#include "base/logger.h"
#include "base/ptr_utils.h"
#include "base/rand_util.h"
#include "sharer_defines.h"
namespace sharer {
namespace {
// If there is only one reference to the packet then copy the
// reference and return.
// Otherwise return a deep copy of the packet.
PacketRef FastCopyPacket(const PacketRef& packet) {
if (packet.unique()) return packet;
return std::make_shared<Packet>(*packet);
}
} // namespace
RtpSender::RtpSender(PacedSender* const transport) : transport_(transport) {
// Randomly set sequence number start value.
config_.sequence_number = base::RandInt(0, 65535);
}
RtpSender::~RtpSender() {}
bool RtpSender::Initialize(const SharerTransportRtpConfig& config) {
config_.ssrc = config.ssrc;
config_.payload_type = config.rtp_payload_type;
packetizer_ = make_unique<RtpPacketizer>(transport_, &storage_, config_);
return true;
}
void RtpSender::SendFrame(const EncodedFrame& frame) {
PP_DCHECK(packetizer_);
packetizer_->SendFrameAsPackets(frame);
if (storage_.GetNumberOfStoredFrames() > kMaxUnackedFrames) {
// TODO: Change to LOG_IF
DERR()
<< "Possible bug: Frames are not being actively released from storage.";
}
}
void RtpSender::ResendPackets(
const std::string& addr,
const MissingFramesAndPacketsMap& missing_frames_and_packets,
bool cancel_rtx_if_not_in_list, const DedupInfo& dedup_info) {
// Iterate over all frames in the list.
for (MissingFramesAndPacketsMap::const_iterator it =
missing_frames_and_packets.begin();
it != missing_frames_and_packets.end(); ++it) {
SendPacketVector packets_to_resend;
uint32_t frame_id = it->first;
// Set of packets that the receiver wants us to re-send.
// If empty, we need to re-send all packets for this frame.
const PacketIdSet& missing_packet_set = it->second;
bool resend_all = missing_packet_set.find(kRtcpSharerAllPacketsLost) !=
missing_packet_set.end();
bool resend_last = missing_packet_set.find(kRtcpSharerLastPacket) !=
missing_packet_set.end();
const SendPacketVector* stored_packets = storage_.GetFrame32(frame_id);
if (!stored_packets) {
DERR() << "Can't resend " << missing_packet_set.size()
<< " packets for frame:" << frame_id;
continue;
}
for (SendPacketVector::const_iterator it = stored_packets->begin();
it != stored_packets->end(); ++it) {
const PacketKey& packet_key = it->first;
const uint16_t packet_id = packet_key.second.second;
// Should we resend the packet?
bool resend = resend_all;
// Should we resend it because it's in the missing_packet_set?
if (!resend &&
missing_packet_set.find(packet_id) != missing_packet_set.end()) {
resend = true;
}
// If we were asked to resend the last packet, check if it's the
// last packet.
if (!resend && resend_last && (it + 1) == stored_packets->end()) {
resend = true;
}
if (resend) {
// Resend packet to the network.
DINF() << "Resend " << static_cast<int>(frame_id) << ":" << packet_id
<< ", dest: " << addr;
// Set a unique incremental sequence number for every packet.
PacketRef packet_copy = FastCopyPacket(it->second);
UpdateSequenceNumber(packet_copy);
packets_to_resend.push_back(std::make_pair(packet_key, packet_copy));
} else if (cancel_rtx_if_not_in_list) {
transport_->CancelSendingPacket(addr, it->first);
}
}
transport_->ResendPackets(addr, packets_to_resend, dedup_info);
}
}
void RtpSender::ResendFrameForKickstart(uint32_t frame_id,
base::TimeDelta dedupe_window) {
// Send the last packet of the encoded frame to kick start
// retransmission. This gives enough information to the receiver what
// packets and frames are missing.
MissingFramesAndPacketsMap missing_frames_and_packets;
PacketIdSet missing;
missing.insert(kRtcpSharerLastPacket);
missing_frames_and_packets.insert(std::make_pair(frame_id, missing));
// Sending this extra packet is to kick-start the session. There is
// no need to optimize re-transmission for this case.
DedupInfo dedup_info;
dedup_info.resend_interval = dedupe_window;
// ResendPackets(missing_frames_and_packets, false, dedup_info);
}
void RtpSender::UpdateSequenceNumber(PacketRef packet) {
// TODO(miu): This is an abstraction violation. This needs to be a part of
// the overall packet (de)serialization consolidation.
static const int kByteOffsetToSequenceNumber = 2;
BigEndianWriter big_endian_writer(
reinterpret_cast<char*>((packet->data()) + kByteOffsetToSequenceNumber),
sizeof(uint16_t));
big_endian_writer.WriteU16(packetizer_->NextSequenceNumber());
}
int64_t RtpSender::GetLastByteSentForFrame(uint32_t frame_id) {
const SendPacketVector* stored_packets = storage_.GetFrame32(frame_id);
if (!stored_packets) return 0;
PacketKey last_packet_key = stored_packets->rbegin()->first;
return transport_->GetLastByteSentForPacket(last_packet_key);
}
} // namespace sharer
| 36.711409 | 80 | 0.706399 | maxsong11 |
efae40771253fa3bfb27b1ee80c55f32c9e089be | 3,140 | cpp | C++ | minesweeper_v1/Instructions.cpp | sangpham2710/CS161-Project | 7051cc17bc64bdcb128884ef02ec70e1552c982e | [
"MIT"
] | 6 | 2021-12-28T08:07:16.000Z | 2022-03-13T06:17:45.000Z | minesweeper_v1/Instructions.cpp | sangpham2710/CS161-Project | 7051cc17bc64bdcb128884ef02ec70e1552c982e | [
"MIT"
] | null | null | null | minesweeper_v1/Instructions.cpp | sangpham2710/CS161-Project | 7051cc17bc64bdcb128884ef02ec70e1552c982e | [
"MIT"
] | 1 | 2021-12-24T07:19:16.000Z | 2021-12-24T07:19:16.000Z | #include "instructions.h"
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include "cmanip.h"
#include "game_model.h"
#include "global.h"
#include "main_utils.h"
#include "scene_manager.h"
#include "windows.h"
const long long MAX_TIME = (long long)1e18;
int PADDING_INSTRUCTIONS_X, PADDING_INSTRUCTIONS_Y;
// 3 che do
// 0 0 0 0 0 0 0 0 0 0
// 0 0 0 0 0 0 0 0 0 0
// 0 0 0 0 0 0 0 0 0 0
const std::vector<std::string> instructions = {
R"([WASD]/[Arrow keys])",
"Move Cursor",
"[J]/[Enter]",
"Select | Open A Cell",
"[K]",
"Open Neighboring Cells",
"[L]",
"Flag A Cell",
"[O]",
"Save Game",
"[R]",
"Replay Game",
"[Y]",
"Yes",
"[N]",
"No",
R"([Escape])",
R"(Quit Game | Back to Menu)",
};
int instructionsWidth =
strlen(R"( [Escape]: Quit Game | Back to Menu)");
int instructionsHeight = instructions.size() / 2;
std::vector<std::string> getInstructionHeaderText() {
return {
R"( _ _ ___ __ __ _____ ___ ___ _ _ __ __)",
R"(| || | / _ \\ \ / / |_ _|/ _ \ | _ \| | /_\\ \ / /)",
R"(| __ || (_) |\ \/\/ / | | | (_) | | _/| |__ / _ \\ V / )",
R"(|_||_| \___/ \_/\_/ |_| \___/ |_| |____|/_/ \_\|_| )",
};
}
int getInstructionsPosition() { return PADDING_INSTRUCTIONS_Y + 1; }
void displayInstructionsHeaderAndFooter() {
std::vector<std::string> headerText = getInstructionHeaderText();
const int spacing = 1;
for (int i = 0; i < headerText.size(); i++)
printCenteredText(headerText[i], 3 + i);
printCenteredText(R"([J] Back to Menu)", getWindowHeight() - 2);
}
int Instructions() {
setupInstructionsDisplay();
displayInstructions();
while (true) {
int action = getUserAction();
if (action == MOUSE1 || action == ESCAPE) return WELCOME;
}
}
void displayInstructions() {
resetConsoleScreen();
int cellWidth = instructions[0].size();
displayInstructionsHeaderAndFooter();
for (int i = 0; i < instructions.size(); i++) {
setConsoleCursorPosition(
PADDING_INSTRUCTIONS_X + (cellWidth - instructions[i].size()) / 2 - 5,
PADDING_INSTRUCTIONS_Y + i / 2 + 2);
std::cout << instructions[i];
setConsoleCursorPosition(PADDING_INSTRUCTIONS_X + cellWidth - 2,
PADDING_INSTRUCTIONS_Y + i / 2 + 2);
std::cout << " : " << instructions[i + 1];
// printCenteredText(std::string((cellWidth - instruction[i].size()) / 2, '
// ') + instruction[i] + std::string((cellWidth - instruction[i].size()) /
// 2, ' ') + std::string(instructionWidth - cellWidth, ' '),
// PADDING_INSTRUCTION_Y + i / 2 + 2);
// printCenteredText(std::string(instruction[i].size(), ' ') + instruction[i
// + 1] + std::string(instructionWidth - instruction[i].size() -
// instruction[i + 1].size(), ' '), PADDING_INSTRUCTION_Y + i / 2 + 2);
i++;
}
}
void setupInstructionsDisplay() {
PADDING_INSTRUCTIONS_X = (getWindowWidth() - instructionsWidth) / 2;
PADDING_INSTRUCTIONS_Y = (getWindowHeight() - instructionsHeight) / 2;
}
| 28.545455 | 80 | 0.58758 | sangpham2710 |
efafcec13c75a40f7bfe2a3549a569f79f732878 | 83,097 | cc | C++ | protobufs/c_peer2peer_netmessages.pb.cc | devilesk/dota-replay-parser | e83b96ee513a7193e6703615df4f676e27b1b8a0 | [
"0BSD"
] | 2 | 2017-02-03T16:57:17.000Z | 2020-10-28T21:13:12.000Z | protobufs/c_peer2peer_netmessages.pb.cc | invokr/dota-replay-parser | 6260aa834fb47f0f1a8c713f4edada6baeb9dcfa | [
"0BSD"
] | 1 | 2017-02-03T22:44:17.000Z | 2017-02-04T08:58:13.000Z | protobufs/c_peer2peer_netmessages.pb.cc | invokr/dota-replay-parser | 6260aa834fb47f0f1a8c713f4edada6baeb9dcfa | [
"0BSD"
] | 2 | 2017-02-03T17:51:57.000Z | 2021-05-22T02:40:00.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: c_peer2peer_netmessages.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "c_peer2peer_netmessages.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.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)
namespace {
const ::google::protobuf::Descriptor* CP2P_TextMessage_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_TextMessage_reflection_ = NULL;
const ::google::protobuf::Descriptor* CSteam_Voice_Encoding_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CSteam_Voice_Encoding_reflection_ = NULL;
const ::google::protobuf::Descriptor* CP2P_Voice_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_Voice_reflection_ = NULL;
const ::google::protobuf::EnumDescriptor* CP2P_Voice_Handler_Flags_descriptor_ = NULL;
const ::google::protobuf::Descriptor* CP2P_Ping_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_Ping_reflection_ = NULL;
const ::google::protobuf::Descriptor* CP2P_VRAvatarPosition_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_VRAvatarPosition_reflection_ = NULL;
const ::google::protobuf::Descriptor* CP2P_VRAvatarPosition_COrientation_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_VRAvatarPosition_COrientation_reflection_ = NULL;
const ::google::protobuf::Descriptor* CP2P_WatchSynchronization_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
CP2P_WatchSynchronization_reflection_ = NULL;
const ::google::protobuf::EnumDescriptor* P2P_Messages_descriptor_ = NULL;
} // namespace
void protobuf_AssignDesc_c_5fpeer2peer_5fnetmessages_2eproto() {
protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"c_peer2peer_netmessages.proto");
GOOGLE_CHECK(file != NULL);
CP2P_TextMessage_descriptor_ = file->message_type(0);
static const int CP2P_TextMessage_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_TextMessage, text_),
};
CP2P_TextMessage_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_TextMessage_descriptor_,
CP2P_TextMessage::default_instance_,
CP2P_TextMessage_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_TextMessage, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_TextMessage, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_TextMessage));
CSteam_Voice_Encoding_descriptor_ = file->message_type(1);
static const int CSteam_Voice_Encoding_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CSteam_Voice_Encoding, voice_data_),
};
CSteam_Voice_Encoding_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CSteam_Voice_Encoding_descriptor_,
CSteam_Voice_Encoding::default_instance_,
CSteam_Voice_Encoding_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CSteam_Voice_Encoding, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CSteam_Voice_Encoding, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CSteam_Voice_Encoding));
CP2P_Voice_descriptor_ = file->message_type(2);
static const int CP2P_Voice_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Voice, audio_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Voice, broadcast_group_),
};
CP2P_Voice_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_Voice_descriptor_,
CP2P_Voice::default_instance_,
CP2P_Voice_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Voice, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Voice, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_Voice));
CP2P_Voice_Handler_Flags_descriptor_ = CP2P_Voice_descriptor_->enum_type(0);
CP2P_Ping_descriptor_ = file->message_type(3);
static const int CP2P_Ping_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Ping, send_time_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Ping, is_reply_),
};
CP2P_Ping_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_Ping_descriptor_,
CP2P_Ping::default_instance_,
CP2P_Ping_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Ping, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_Ping, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_Ping));
CP2P_VRAvatarPosition_descriptor_ = file->message_type(4);
static const int CP2P_VRAvatarPosition_offsets_[4] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, body_parts_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, hat_id_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, scene_id_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, world_scale_),
};
CP2P_VRAvatarPosition_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_VRAvatarPosition_descriptor_,
CP2P_VRAvatarPosition::default_instance_,
CP2P_VRAvatarPosition_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_VRAvatarPosition));
CP2P_VRAvatarPosition_COrientation_descriptor_ = CP2P_VRAvatarPosition_descriptor_->nested_type(0);
static const int CP2P_VRAvatarPosition_COrientation_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition_COrientation, pos_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition_COrientation, ang_),
};
CP2P_VRAvatarPosition_COrientation_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_VRAvatarPosition_COrientation_descriptor_,
CP2P_VRAvatarPosition_COrientation::default_instance_,
CP2P_VRAvatarPosition_COrientation_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition_COrientation, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_VRAvatarPosition_COrientation, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_VRAvatarPosition_COrientation));
CP2P_WatchSynchronization_descriptor_ = file->message_type(5);
static const int CP2P_WatchSynchronization_offsets_[8] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, demo_tick_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, paused_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, tv_listen_voice_indices_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, dota_spectator_mode_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, dota_spectator_watching_broadcaster_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, dota_spectator_hero_index_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, dota_spectator_autospeed_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, dota_replay_speed_),
};
CP2P_WatchSynchronization_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
CP2P_WatchSynchronization_descriptor_,
CP2P_WatchSynchronization::default_instance_,
CP2P_WatchSynchronization_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CP2P_WatchSynchronization, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(CP2P_WatchSynchronization));
P2P_Messages_descriptor_ = file->enum_type(0);
}
namespace {
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
inline void protobuf_AssignDescriptorsOnce() {
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
&protobuf_AssignDesc_c_5fpeer2peer_5fnetmessages_2eproto);
}
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_TextMessage_descriptor_, &CP2P_TextMessage::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CSteam_Voice_Encoding_descriptor_, &CSteam_Voice_Encoding::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_Voice_descriptor_, &CP2P_Voice::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_Ping_descriptor_, &CP2P_Ping::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_VRAvatarPosition_descriptor_, &CP2P_VRAvatarPosition::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_VRAvatarPosition_COrientation_descriptor_, &CP2P_VRAvatarPosition_COrientation::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
CP2P_WatchSynchronization_descriptor_, &CP2P_WatchSynchronization::default_instance());
}
} // namespace
void protobuf_ShutdownFile_c_5fpeer2peer_5fnetmessages_2eproto() {
delete CP2P_TextMessage::default_instance_;
delete CP2P_TextMessage_reflection_;
delete CSteam_Voice_Encoding::default_instance_;
delete CSteam_Voice_Encoding_reflection_;
delete CP2P_Voice::default_instance_;
delete CP2P_Voice_reflection_;
delete CP2P_Ping::default_instance_;
delete CP2P_Ping_reflection_;
delete CP2P_VRAvatarPosition::default_instance_;
delete CP2P_VRAvatarPosition_reflection_;
delete CP2P_VRAvatarPosition_COrientation::default_instance_;
delete CP2P_VRAvatarPosition_COrientation_reflection_;
delete CP2P_WatchSynchronization::default_instance_;
delete CP2P_WatchSynchronization_reflection_;
}
void protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto() {
static bool already_here = false;
if (already_here) return;
already_here = true;
GOOGLE_PROTOBUF_VERIFY_VERSION;
::protobuf_AddDesc_netmessages_2eproto();
::protobuf_AddDesc_networkbasetypes_2eproto();
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\035c_peer2peer_netmessages.proto\032\021netmess"
"ages.proto\032\026networkbasetypes.proto\" \n\020CP"
"2P_TextMessage\022\014\n\004text\030\001 \001(\014\"+\n\025CSteam_V"
"oice_Encoding\022\022\n\nvoice_data\030\001 \001(\014\"h\n\nCP2"
"P_Voice\022\036\n\005audio\030\001 \001(\0132\017.CMsgVoiceAudio\022"
"\027\n\017broadcast_group\030\002 \001(\r\"!\n\rHandler_Flag"
"s\022\020\n\014Played_Audio\020\001\"0\n\tCP2P_Ping\022\021\n\tsend"
"_time\030\001 \002(\004\022\020\n\010is_reply\030\002 \002(\010\"\313\001\n\025CP2P_V"
"RAvatarPosition\0227\n\nbody_parts\030\001 \003(\0132#.CP"
"2P_VRAvatarPosition.COrientation\022\016\n\006hat_"
"id\030\002 \001(\005\022\020\n\010scene_id\030\003 \001(\005\022\023\n\013world_scal"
"e\030\004 \001(\005\032B\n\014COrientation\022\030\n\003pos\030\001 \001(\0132\013.C"
"MsgVector\022\030\n\003ang\030\002 \001(\0132\013.CMsgQAngle\"\211\002\n\031"
"CP2P_WatchSynchronization\022\021\n\tdemo_tick\030\001"
" \001(\005\022\016\n\006paused\030\002 \001(\010\022\037\n\027tv_listen_voice_"
"indices\030\003 \001(\005\022\033\n\023dota_spectator_mode\030\004 \001"
"(\005\022+\n#dota_spectator_watching_broadcaste"
"r\030\005 \001(\005\022!\n\031dota_spectator_hero_index\030\006 \001"
"(\005\022 \n\030dota_spectator_autospeed\030\007 \001(\005\022\031\n\021"
"dota_replay_speed\030\010 \001(\005*}\n\014P2P_Messages\022"
"\024\n\017p2p_TextMessage\020\200\002\022\016\n\tp2p_Voice\020\201\002\022\r\n"
"\010p2p_Ping\020\202\002\022\031\n\024p2p_VRAvatarPosition\020\203\002\022"
"\035\n\030p2p_WatchSynchronization\020\204\002B\003\200\001\000", 915);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"c_peer2peer_netmessages.proto", &protobuf_RegisterTypes);
CP2P_TextMessage::default_instance_ = new CP2P_TextMessage();
CSteam_Voice_Encoding::default_instance_ = new CSteam_Voice_Encoding();
CP2P_Voice::default_instance_ = new CP2P_Voice();
CP2P_Ping::default_instance_ = new CP2P_Ping();
CP2P_VRAvatarPosition::default_instance_ = new CP2P_VRAvatarPosition();
CP2P_VRAvatarPosition_COrientation::default_instance_ = new CP2P_VRAvatarPosition_COrientation();
CP2P_WatchSynchronization::default_instance_ = new CP2P_WatchSynchronization();
CP2P_TextMessage::default_instance_->InitAsDefaultInstance();
CSteam_Voice_Encoding::default_instance_->InitAsDefaultInstance();
CP2P_Voice::default_instance_->InitAsDefaultInstance();
CP2P_Ping::default_instance_->InitAsDefaultInstance();
CP2P_VRAvatarPosition::default_instance_->InitAsDefaultInstance();
CP2P_VRAvatarPosition_COrientation::default_instance_->InitAsDefaultInstance();
CP2P_WatchSynchronization::default_instance_->InitAsDefaultInstance();
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_c_5fpeer2peer_5fnetmessages_2eproto);
}
// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer_c_5fpeer2peer_5fnetmessages_2eproto {
StaticDescriptorInitializer_c_5fpeer2peer_5fnetmessages_2eproto() {
protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
}
} static_descriptor_initializer_c_5fpeer2peer_5fnetmessages_2eproto_;
const ::google::protobuf::EnumDescriptor* P2P_Messages_descriptor() {
protobuf_AssignDescriptorsOnce();
return P2P_Messages_descriptor_;
}
bool P2P_Messages_IsValid(int value) {
switch(value) {
case 256:
case 257:
case 258:
case 259:
case 260:
return true;
default:
return false;
}
}
// ===================================================================
#ifndef _MSC_VER
const int CP2P_TextMessage::kTextFieldNumber;
#endif // !_MSC_VER
CP2P_TextMessage::CP2P_TextMessage()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_TextMessage)
}
void CP2P_TextMessage::InitAsDefaultInstance() {
}
CP2P_TextMessage::CP2P_TextMessage(const CP2P_TextMessage& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_TextMessage)
}
void CP2P_TextMessage::SharedCtor() {
::google::protobuf::internal::GetEmptyString();
_cached_size_ = 0;
text_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_TextMessage::~CP2P_TextMessage() {
// @@protoc_insertion_point(destructor:CP2P_TextMessage)
SharedDtor();
}
void CP2P_TextMessage::SharedDtor() {
if (text_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete text_;
}
if (this != default_instance_) {
}
}
void CP2P_TextMessage::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_TextMessage::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_TextMessage_descriptor_;
}
const CP2P_TextMessage& CP2P_TextMessage::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_TextMessage* CP2P_TextMessage::default_instance_ = NULL;
CP2P_TextMessage* CP2P_TextMessage::New() const {
return new CP2P_TextMessage;
}
void CP2P_TextMessage::Clear() {
if (has_text()) {
if (text_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
text_->clear();
}
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_TextMessage::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_TextMessage)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bytes text = 1;
case 1: {
if (tag == 10) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_text()));
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_TextMessage)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_TextMessage)
return false;
#undef DO_
}
void CP2P_TextMessage::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_TextMessage)
// optional bytes text = 1;
if (has_text()) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
1, this->text(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_TextMessage)
}
::google::protobuf::uint8* CP2P_TextMessage::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_TextMessage)
// optional bytes text = 1;
if (has_text()) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
1, this->text(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_TextMessage)
return target;
}
int CP2P_TextMessage::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional bytes text = 1;
if (has_text()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
this->text());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_TextMessage::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_TextMessage* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_TextMessage*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_TextMessage::MergeFrom(const CP2P_TextMessage& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_text()) {
set_text(from.text());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_TextMessage::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_TextMessage::CopyFrom(const CP2P_TextMessage& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_TextMessage::IsInitialized() const {
return true;
}
void CP2P_TextMessage::Swap(CP2P_TextMessage* other) {
if (other != this) {
std::swap(text_, other->text_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_TextMessage::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_TextMessage_descriptor_;
metadata.reflection = CP2P_TextMessage_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int CSteam_Voice_Encoding::kVoiceDataFieldNumber;
#endif // !_MSC_VER
CSteam_Voice_Encoding::CSteam_Voice_Encoding()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CSteam_Voice_Encoding)
}
void CSteam_Voice_Encoding::InitAsDefaultInstance() {
}
CSteam_Voice_Encoding::CSteam_Voice_Encoding(const CSteam_Voice_Encoding& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CSteam_Voice_Encoding)
}
void CSteam_Voice_Encoding::SharedCtor() {
::google::protobuf::internal::GetEmptyString();
_cached_size_ = 0;
voice_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CSteam_Voice_Encoding::~CSteam_Voice_Encoding() {
// @@protoc_insertion_point(destructor:CSteam_Voice_Encoding)
SharedDtor();
}
void CSteam_Voice_Encoding::SharedDtor() {
if (voice_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete voice_data_;
}
if (this != default_instance_) {
}
}
void CSteam_Voice_Encoding::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CSteam_Voice_Encoding::descriptor() {
protobuf_AssignDescriptorsOnce();
return CSteam_Voice_Encoding_descriptor_;
}
const CSteam_Voice_Encoding& CSteam_Voice_Encoding::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CSteam_Voice_Encoding* CSteam_Voice_Encoding::default_instance_ = NULL;
CSteam_Voice_Encoding* CSteam_Voice_Encoding::New() const {
return new CSteam_Voice_Encoding;
}
void CSteam_Voice_Encoding::Clear() {
if (has_voice_data()) {
if (voice_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
voice_data_->clear();
}
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CSteam_Voice_Encoding::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CSteam_Voice_Encoding)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bytes voice_data = 1;
case 1: {
if (tag == 10) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_voice_data()));
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CSteam_Voice_Encoding)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CSteam_Voice_Encoding)
return false;
#undef DO_
}
void CSteam_Voice_Encoding::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CSteam_Voice_Encoding)
// optional bytes voice_data = 1;
if (has_voice_data()) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
1, this->voice_data(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CSteam_Voice_Encoding)
}
::google::protobuf::uint8* CSteam_Voice_Encoding::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CSteam_Voice_Encoding)
// optional bytes voice_data = 1;
if (has_voice_data()) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
1, this->voice_data(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CSteam_Voice_Encoding)
return target;
}
int CSteam_Voice_Encoding::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional bytes voice_data = 1;
if (has_voice_data()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
this->voice_data());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CSteam_Voice_Encoding::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CSteam_Voice_Encoding* source =
::google::protobuf::internal::dynamic_cast_if_available<const CSteam_Voice_Encoding*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CSteam_Voice_Encoding::MergeFrom(const CSteam_Voice_Encoding& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_voice_data()) {
set_voice_data(from.voice_data());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CSteam_Voice_Encoding::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CSteam_Voice_Encoding::CopyFrom(const CSteam_Voice_Encoding& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CSteam_Voice_Encoding::IsInitialized() const {
return true;
}
void CSteam_Voice_Encoding::Swap(CSteam_Voice_Encoding* other) {
if (other != this) {
std::swap(voice_data_, other->voice_data_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CSteam_Voice_Encoding::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CSteam_Voice_Encoding_descriptor_;
metadata.reflection = CSteam_Voice_Encoding_reflection_;
return metadata;
}
// ===================================================================
const ::google::protobuf::EnumDescriptor* CP2P_Voice_Handler_Flags_descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_Voice_Handler_Flags_descriptor_;
}
bool CP2P_Voice_Handler_Flags_IsValid(int value) {
switch(value) {
case 1:
return true;
default:
return false;
}
}
#ifndef _MSC_VER
const CP2P_Voice_Handler_Flags CP2P_Voice::Played_Audio;
const CP2P_Voice_Handler_Flags CP2P_Voice::Handler_Flags_MIN;
const CP2P_Voice_Handler_Flags CP2P_Voice::Handler_Flags_MAX;
const int CP2P_Voice::Handler_Flags_ARRAYSIZE;
#endif // _MSC_VER
#ifndef _MSC_VER
const int CP2P_Voice::kAudioFieldNumber;
const int CP2P_Voice::kBroadcastGroupFieldNumber;
#endif // !_MSC_VER
CP2P_Voice::CP2P_Voice()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_Voice)
}
void CP2P_Voice::InitAsDefaultInstance() {
audio_ = const_cast< ::CMsgVoiceAudio*>(&::CMsgVoiceAudio::default_instance());
}
CP2P_Voice::CP2P_Voice(const CP2P_Voice& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_Voice)
}
void CP2P_Voice::SharedCtor() {
_cached_size_ = 0;
audio_ = NULL;
broadcast_group_ = 0u;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_Voice::~CP2P_Voice() {
// @@protoc_insertion_point(destructor:CP2P_Voice)
SharedDtor();
}
void CP2P_Voice::SharedDtor() {
if (this != default_instance_) {
delete audio_;
}
}
void CP2P_Voice::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_Voice::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_Voice_descriptor_;
}
const CP2P_Voice& CP2P_Voice::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_Voice* CP2P_Voice::default_instance_ = NULL;
CP2P_Voice* CP2P_Voice::New() const {
return new CP2P_Voice;
}
void CP2P_Voice::Clear() {
if (_has_bits_[0 / 32] & 3) {
if (has_audio()) {
if (audio_ != NULL) audio_->::CMsgVoiceAudio::Clear();
}
broadcast_group_ = 0u;
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_Voice::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_Voice)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional .CMsgVoiceAudio audio = 1;
case 1: {
if (tag == 10) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_audio()));
} else {
goto handle_unusual;
}
if (input->ExpectTag(16)) goto parse_broadcast_group;
break;
}
// optional uint32 broadcast_group = 2;
case 2: {
if (tag == 16) {
parse_broadcast_group:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
input, &broadcast_group_)));
set_has_broadcast_group();
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_Voice)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_Voice)
return false;
#undef DO_
}
void CP2P_Voice::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_Voice)
// optional .CMsgVoiceAudio audio = 1;
if (has_audio()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->audio(), output);
}
// optional uint32 broadcast_group = 2;
if (has_broadcast_group()) {
::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->broadcast_group(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_Voice)
}
::google::protobuf::uint8* CP2P_Voice::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_Voice)
// optional .CMsgVoiceAudio audio = 1;
if (has_audio()) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
1, this->audio(), target);
}
// optional uint32 broadcast_group = 2;
if (has_broadcast_group()) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->broadcast_group(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_Voice)
return target;
}
int CP2P_Voice::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional .CMsgVoiceAudio audio = 1;
if (has_audio()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->audio());
}
// optional uint32 broadcast_group = 2;
if (has_broadcast_group()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt32Size(
this->broadcast_group());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_Voice::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_Voice* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_Voice*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_Voice::MergeFrom(const CP2P_Voice& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_audio()) {
mutable_audio()->::CMsgVoiceAudio::MergeFrom(from.audio());
}
if (from.has_broadcast_group()) {
set_broadcast_group(from.broadcast_group());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_Voice::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_Voice::CopyFrom(const CP2P_Voice& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_Voice::IsInitialized() const {
return true;
}
void CP2P_Voice::Swap(CP2P_Voice* other) {
if (other != this) {
std::swap(audio_, other->audio_);
std::swap(broadcast_group_, other->broadcast_group_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_Voice::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_Voice_descriptor_;
metadata.reflection = CP2P_Voice_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int CP2P_Ping::kSendTimeFieldNumber;
const int CP2P_Ping::kIsReplyFieldNumber;
#endif // !_MSC_VER
CP2P_Ping::CP2P_Ping()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_Ping)
}
void CP2P_Ping::InitAsDefaultInstance() {
}
CP2P_Ping::CP2P_Ping(const CP2P_Ping& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_Ping)
}
void CP2P_Ping::SharedCtor() {
_cached_size_ = 0;
send_time_ = GOOGLE_ULONGLONG(0);
is_reply_ = false;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_Ping::~CP2P_Ping() {
// @@protoc_insertion_point(destructor:CP2P_Ping)
SharedDtor();
}
void CP2P_Ping::SharedDtor() {
if (this != default_instance_) {
}
}
void CP2P_Ping::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_Ping::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_Ping_descriptor_;
}
const CP2P_Ping& CP2P_Ping::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_Ping* CP2P_Ping::default_instance_ = NULL;
CP2P_Ping* CP2P_Ping::New() const {
return new CP2P_Ping;
}
void CP2P_Ping::Clear() {
#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
&reinterpret_cast<CP2P_Ping*>(16)->f) - \
reinterpret_cast<char*>(16))
#define ZR_(first, last) do { \
size_t f = OFFSET_OF_FIELD_(first); \
size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
::memset(&first, 0, n); \
} while (0)
ZR_(send_time_, is_reply_);
#undef OFFSET_OF_FIELD_
#undef ZR_
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_Ping::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_Ping)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required uint64 send_time = 1;
case 1: {
if (tag == 8) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
input, &send_time_)));
set_has_send_time();
} else {
goto handle_unusual;
}
if (input->ExpectTag(16)) goto parse_is_reply;
break;
}
// required bool is_reply = 2;
case 2: {
if (tag == 16) {
parse_is_reply:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &is_reply_)));
set_has_is_reply();
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_Ping)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_Ping)
return false;
#undef DO_
}
void CP2P_Ping::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_Ping)
// required uint64 send_time = 1;
if (has_send_time()) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->send_time(), output);
}
// required bool is_reply = 2;
if (has_is_reply()) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->is_reply(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_Ping)
}
::google::protobuf::uint8* CP2P_Ping::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_Ping)
// required uint64 send_time = 1;
if (has_send_time()) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->send_time(), target);
}
// required bool is_reply = 2;
if (has_is_reply()) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->is_reply(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_Ping)
return target;
}
int CP2P_Ping::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// required uint64 send_time = 1;
if (has_send_time()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
this->send_time());
}
// required bool is_reply = 2;
if (has_is_reply()) {
total_size += 1 + 1;
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_Ping::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_Ping* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_Ping*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_Ping::MergeFrom(const CP2P_Ping& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_send_time()) {
set_send_time(from.send_time());
}
if (from.has_is_reply()) {
set_is_reply(from.is_reply());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_Ping::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_Ping::CopyFrom(const CP2P_Ping& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_Ping::IsInitialized() const {
if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
return true;
}
void CP2P_Ping::Swap(CP2P_Ping* other) {
if (other != this) {
std::swap(send_time_, other->send_time_);
std::swap(is_reply_, other->is_reply_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_Ping::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_Ping_descriptor_;
metadata.reflection = CP2P_Ping_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int CP2P_VRAvatarPosition_COrientation::kPosFieldNumber;
const int CP2P_VRAvatarPosition_COrientation::kAngFieldNumber;
#endif // !_MSC_VER
CP2P_VRAvatarPosition_COrientation::CP2P_VRAvatarPosition_COrientation()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_VRAvatarPosition.COrientation)
}
void CP2P_VRAvatarPosition_COrientation::InitAsDefaultInstance() {
pos_ = const_cast< ::CMsgVector*>(&::CMsgVector::default_instance());
ang_ = const_cast< ::CMsgQAngle*>(&::CMsgQAngle::default_instance());
}
CP2P_VRAvatarPosition_COrientation::CP2P_VRAvatarPosition_COrientation(const CP2P_VRAvatarPosition_COrientation& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_VRAvatarPosition.COrientation)
}
void CP2P_VRAvatarPosition_COrientation::SharedCtor() {
_cached_size_ = 0;
pos_ = NULL;
ang_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_VRAvatarPosition_COrientation::~CP2P_VRAvatarPosition_COrientation() {
// @@protoc_insertion_point(destructor:CP2P_VRAvatarPosition.COrientation)
SharedDtor();
}
void CP2P_VRAvatarPosition_COrientation::SharedDtor() {
if (this != default_instance_) {
delete pos_;
delete ang_;
}
}
void CP2P_VRAvatarPosition_COrientation::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_VRAvatarPosition_COrientation::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_VRAvatarPosition_COrientation_descriptor_;
}
const CP2P_VRAvatarPosition_COrientation& CP2P_VRAvatarPosition_COrientation::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_VRAvatarPosition_COrientation* CP2P_VRAvatarPosition_COrientation::default_instance_ = NULL;
CP2P_VRAvatarPosition_COrientation* CP2P_VRAvatarPosition_COrientation::New() const {
return new CP2P_VRAvatarPosition_COrientation;
}
void CP2P_VRAvatarPosition_COrientation::Clear() {
if (_has_bits_[0 / 32] & 3) {
if (has_pos()) {
if (pos_ != NULL) pos_->::CMsgVector::Clear();
}
if (has_ang()) {
if (ang_ != NULL) ang_->::CMsgQAngle::Clear();
}
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_VRAvatarPosition_COrientation::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_VRAvatarPosition.COrientation)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional .CMsgVector pos = 1;
case 1: {
if (tag == 10) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_pos()));
} else {
goto handle_unusual;
}
if (input->ExpectTag(18)) goto parse_ang;
break;
}
// optional .CMsgQAngle ang = 2;
case 2: {
if (tag == 18) {
parse_ang:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_ang()));
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_VRAvatarPosition.COrientation)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_VRAvatarPosition.COrientation)
return false;
#undef DO_
}
void CP2P_VRAvatarPosition_COrientation::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_VRAvatarPosition.COrientation)
// optional .CMsgVector pos = 1;
if (has_pos()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->pos(), output);
}
// optional .CMsgQAngle ang = 2;
if (has_ang()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->ang(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_VRAvatarPosition.COrientation)
}
::google::protobuf::uint8* CP2P_VRAvatarPosition_COrientation::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_VRAvatarPosition.COrientation)
// optional .CMsgVector pos = 1;
if (has_pos()) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
1, this->pos(), target);
}
// optional .CMsgQAngle ang = 2;
if (has_ang()) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
2, this->ang(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_VRAvatarPosition.COrientation)
return target;
}
int CP2P_VRAvatarPosition_COrientation::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional .CMsgVector pos = 1;
if (has_pos()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->pos());
}
// optional .CMsgQAngle ang = 2;
if (has_ang()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->ang());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_VRAvatarPosition_COrientation::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_VRAvatarPosition_COrientation* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_VRAvatarPosition_COrientation*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_VRAvatarPosition_COrientation::MergeFrom(const CP2P_VRAvatarPosition_COrientation& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_pos()) {
mutable_pos()->::CMsgVector::MergeFrom(from.pos());
}
if (from.has_ang()) {
mutable_ang()->::CMsgQAngle::MergeFrom(from.ang());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_VRAvatarPosition_COrientation::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_VRAvatarPosition_COrientation::CopyFrom(const CP2P_VRAvatarPosition_COrientation& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_VRAvatarPosition_COrientation::IsInitialized() const {
return true;
}
void CP2P_VRAvatarPosition_COrientation::Swap(CP2P_VRAvatarPosition_COrientation* other) {
if (other != this) {
std::swap(pos_, other->pos_);
std::swap(ang_, other->ang_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_VRAvatarPosition_COrientation::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_VRAvatarPosition_COrientation_descriptor_;
metadata.reflection = CP2P_VRAvatarPosition_COrientation_reflection_;
return metadata;
}
// -------------------------------------------------------------------
#ifndef _MSC_VER
const int CP2P_VRAvatarPosition::kBodyPartsFieldNumber;
const int CP2P_VRAvatarPosition::kHatIdFieldNumber;
const int CP2P_VRAvatarPosition::kSceneIdFieldNumber;
const int CP2P_VRAvatarPosition::kWorldScaleFieldNumber;
#endif // !_MSC_VER
CP2P_VRAvatarPosition::CP2P_VRAvatarPosition()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_VRAvatarPosition)
}
void CP2P_VRAvatarPosition::InitAsDefaultInstance() {
}
CP2P_VRAvatarPosition::CP2P_VRAvatarPosition(const CP2P_VRAvatarPosition& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_VRAvatarPosition)
}
void CP2P_VRAvatarPosition::SharedCtor() {
_cached_size_ = 0;
hat_id_ = 0;
scene_id_ = 0;
world_scale_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_VRAvatarPosition::~CP2P_VRAvatarPosition() {
// @@protoc_insertion_point(destructor:CP2P_VRAvatarPosition)
SharedDtor();
}
void CP2P_VRAvatarPosition::SharedDtor() {
if (this != default_instance_) {
}
}
void CP2P_VRAvatarPosition::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_VRAvatarPosition::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_VRAvatarPosition_descriptor_;
}
const CP2P_VRAvatarPosition& CP2P_VRAvatarPosition::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_VRAvatarPosition* CP2P_VRAvatarPosition::default_instance_ = NULL;
CP2P_VRAvatarPosition* CP2P_VRAvatarPosition::New() const {
return new CP2P_VRAvatarPosition;
}
void CP2P_VRAvatarPosition::Clear() {
#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
&reinterpret_cast<CP2P_VRAvatarPosition*>(16)->f) - \
reinterpret_cast<char*>(16))
#define ZR_(first, last) do { \
size_t f = OFFSET_OF_FIELD_(first); \
size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
::memset(&first, 0, n); \
} while (0)
ZR_(hat_id_, world_scale_);
#undef OFFSET_OF_FIELD_
#undef ZR_
body_parts_.Clear();
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_VRAvatarPosition::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_VRAvatarPosition)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .CP2P_VRAvatarPosition.COrientation body_parts = 1;
case 1: {
if (tag == 10) {
parse_body_parts:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_body_parts()));
} else {
goto handle_unusual;
}
if (input->ExpectTag(10)) goto parse_body_parts;
if (input->ExpectTag(16)) goto parse_hat_id;
break;
}
// optional int32 hat_id = 2;
case 2: {
if (tag == 16) {
parse_hat_id:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &hat_id_)));
set_has_hat_id();
} else {
goto handle_unusual;
}
if (input->ExpectTag(24)) goto parse_scene_id;
break;
}
// optional int32 scene_id = 3;
case 3: {
if (tag == 24) {
parse_scene_id:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &scene_id_)));
set_has_scene_id();
} else {
goto handle_unusual;
}
if (input->ExpectTag(32)) goto parse_world_scale;
break;
}
// optional int32 world_scale = 4;
case 4: {
if (tag == 32) {
parse_world_scale:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &world_scale_)));
set_has_world_scale();
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_VRAvatarPosition)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_VRAvatarPosition)
return false;
#undef DO_
}
void CP2P_VRAvatarPosition::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_VRAvatarPosition)
// repeated .CP2P_VRAvatarPosition.COrientation body_parts = 1;
for (int i = 0; i < this->body_parts_size(); i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->body_parts(i), output);
}
// optional int32 hat_id = 2;
if (has_hat_id()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->hat_id(), output);
}
// optional int32 scene_id = 3;
if (has_scene_id()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->scene_id(), output);
}
// optional int32 world_scale = 4;
if (has_world_scale()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->world_scale(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_VRAvatarPosition)
}
::google::protobuf::uint8* CP2P_VRAvatarPosition::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_VRAvatarPosition)
// repeated .CP2P_VRAvatarPosition.COrientation body_parts = 1;
for (int i = 0; i < this->body_parts_size(); i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
1, this->body_parts(i), target);
}
// optional int32 hat_id = 2;
if (has_hat_id()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->hat_id(), target);
}
// optional int32 scene_id = 3;
if (has_scene_id()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->scene_id(), target);
}
// optional int32 world_scale = 4;
if (has_world_scale()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->world_scale(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_VRAvatarPosition)
return target;
}
int CP2P_VRAvatarPosition::ByteSize() const {
int total_size = 0;
if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) {
// optional int32 hat_id = 2;
if (has_hat_id()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->hat_id());
}
// optional int32 scene_id = 3;
if (has_scene_id()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->scene_id());
}
// optional int32 world_scale = 4;
if (has_world_scale()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->world_scale());
}
}
// repeated .CP2P_VRAvatarPosition.COrientation body_parts = 1;
total_size += 1 * this->body_parts_size();
for (int i = 0; i < this->body_parts_size(); i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->body_parts(i));
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_VRAvatarPosition::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_VRAvatarPosition* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_VRAvatarPosition*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_VRAvatarPosition::MergeFrom(const CP2P_VRAvatarPosition& from) {
GOOGLE_CHECK_NE(&from, this);
body_parts_.MergeFrom(from.body_parts_);
if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {
if (from.has_hat_id()) {
set_hat_id(from.hat_id());
}
if (from.has_scene_id()) {
set_scene_id(from.scene_id());
}
if (from.has_world_scale()) {
set_world_scale(from.world_scale());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_VRAvatarPosition::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_VRAvatarPosition::CopyFrom(const CP2P_VRAvatarPosition& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_VRAvatarPosition::IsInitialized() const {
return true;
}
void CP2P_VRAvatarPosition::Swap(CP2P_VRAvatarPosition* other) {
if (other != this) {
body_parts_.Swap(&other->body_parts_);
std::swap(hat_id_, other->hat_id_);
std::swap(scene_id_, other->scene_id_);
std::swap(world_scale_, other->world_scale_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_VRAvatarPosition::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_VRAvatarPosition_descriptor_;
metadata.reflection = CP2P_VRAvatarPosition_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int CP2P_WatchSynchronization::kDemoTickFieldNumber;
const int CP2P_WatchSynchronization::kPausedFieldNumber;
const int CP2P_WatchSynchronization::kTvListenVoiceIndicesFieldNumber;
const int CP2P_WatchSynchronization::kDotaSpectatorModeFieldNumber;
const int CP2P_WatchSynchronization::kDotaSpectatorWatchingBroadcasterFieldNumber;
const int CP2P_WatchSynchronization::kDotaSpectatorHeroIndexFieldNumber;
const int CP2P_WatchSynchronization::kDotaSpectatorAutospeedFieldNumber;
const int CP2P_WatchSynchronization::kDotaReplaySpeedFieldNumber;
#endif // !_MSC_VER
CP2P_WatchSynchronization::CP2P_WatchSynchronization()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:CP2P_WatchSynchronization)
}
void CP2P_WatchSynchronization::InitAsDefaultInstance() {
}
CP2P_WatchSynchronization::CP2P_WatchSynchronization(const CP2P_WatchSynchronization& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:CP2P_WatchSynchronization)
}
void CP2P_WatchSynchronization::SharedCtor() {
_cached_size_ = 0;
demo_tick_ = 0;
paused_ = false;
tv_listen_voice_indices_ = 0;
dota_spectator_mode_ = 0;
dota_spectator_watching_broadcaster_ = 0;
dota_spectator_hero_index_ = 0;
dota_spectator_autospeed_ = 0;
dota_replay_speed_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
CP2P_WatchSynchronization::~CP2P_WatchSynchronization() {
// @@protoc_insertion_point(destructor:CP2P_WatchSynchronization)
SharedDtor();
}
void CP2P_WatchSynchronization::SharedDtor() {
if (this != default_instance_) {
}
}
void CP2P_WatchSynchronization::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CP2P_WatchSynchronization::descriptor() {
protobuf_AssignDescriptorsOnce();
return CP2P_WatchSynchronization_descriptor_;
}
const CP2P_WatchSynchronization& CP2P_WatchSynchronization::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_c_5fpeer2peer_5fnetmessages_2eproto();
return *default_instance_;
}
CP2P_WatchSynchronization* CP2P_WatchSynchronization::default_instance_ = NULL;
CP2P_WatchSynchronization* CP2P_WatchSynchronization::New() const {
return new CP2P_WatchSynchronization;
}
void CP2P_WatchSynchronization::Clear() {
#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
&reinterpret_cast<CP2P_WatchSynchronization*>(16)->f) - \
reinterpret_cast<char*>(16))
#define ZR_(first, last) do { \
size_t f = OFFSET_OF_FIELD_(first); \
size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
::memset(&first, 0, n); \
} while (0)
if (_has_bits_[0 / 32] & 255) {
ZR_(demo_tick_, dota_replay_speed_);
}
#undef OFFSET_OF_FIELD_
#undef ZR_
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool CP2P_WatchSynchronization::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:CP2P_WatchSynchronization)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional int32 demo_tick = 1;
case 1: {
if (tag == 8) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &demo_tick_)));
set_has_demo_tick();
} else {
goto handle_unusual;
}
if (input->ExpectTag(16)) goto parse_paused;
break;
}
// optional bool paused = 2;
case 2: {
if (tag == 16) {
parse_paused:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &paused_)));
set_has_paused();
} else {
goto handle_unusual;
}
if (input->ExpectTag(24)) goto parse_tv_listen_voice_indices;
break;
}
// optional int32 tv_listen_voice_indices = 3;
case 3: {
if (tag == 24) {
parse_tv_listen_voice_indices:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &tv_listen_voice_indices_)));
set_has_tv_listen_voice_indices();
} else {
goto handle_unusual;
}
if (input->ExpectTag(32)) goto parse_dota_spectator_mode;
break;
}
// optional int32 dota_spectator_mode = 4;
case 4: {
if (tag == 32) {
parse_dota_spectator_mode:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &dota_spectator_mode_)));
set_has_dota_spectator_mode();
} else {
goto handle_unusual;
}
if (input->ExpectTag(40)) goto parse_dota_spectator_watching_broadcaster;
break;
}
// optional int32 dota_spectator_watching_broadcaster = 5;
case 5: {
if (tag == 40) {
parse_dota_spectator_watching_broadcaster:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &dota_spectator_watching_broadcaster_)));
set_has_dota_spectator_watching_broadcaster();
} else {
goto handle_unusual;
}
if (input->ExpectTag(48)) goto parse_dota_spectator_hero_index;
break;
}
// optional int32 dota_spectator_hero_index = 6;
case 6: {
if (tag == 48) {
parse_dota_spectator_hero_index:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &dota_spectator_hero_index_)));
set_has_dota_spectator_hero_index();
} else {
goto handle_unusual;
}
if (input->ExpectTag(56)) goto parse_dota_spectator_autospeed;
break;
}
// optional int32 dota_spectator_autospeed = 7;
case 7: {
if (tag == 56) {
parse_dota_spectator_autospeed:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &dota_spectator_autospeed_)));
set_has_dota_spectator_autospeed();
} else {
goto handle_unusual;
}
if (input->ExpectTag(64)) goto parse_dota_replay_speed;
break;
}
// optional int32 dota_replay_speed = 8;
case 8: {
if (tag == 64) {
parse_dota_replay_speed:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &dota_replay_speed_)));
set_has_dota_replay_speed();
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:CP2P_WatchSynchronization)
return true;
failure:
// @@protoc_insertion_point(parse_failure:CP2P_WatchSynchronization)
return false;
#undef DO_
}
void CP2P_WatchSynchronization::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:CP2P_WatchSynchronization)
// optional int32 demo_tick = 1;
if (has_demo_tick()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->demo_tick(), output);
}
// optional bool paused = 2;
if (has_paused()) {
::google::protobuf::internal::WireFormatLite::WriteBool(2, this->paused(), output);
}
// optional int32 tv_listen_voice_indices = 3;
if (has_tv_listen_voice_indices()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->tv_listen_voice_indices(), output);
}
// optional int32 dota_spectator_mode = 4;
if (has_dota_spectator_mode()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->dota_spectator_mode(), output);
}
// optional int32 dota_spectator_watching_broadcaster = 5;
if (has_dota_spectator_watching_broadcaster()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->dota_spectator_watching_broadcaster(), output);
}
// optional int32 dota_spectator_hero_index = 6;
if (has_dota_spectator_hero_index()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->dota_spectator_hero_index(), output);
}
// optional int32 dota_spectator_autospeed = 7;
if (has_dota_spectator_autospeed()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->dota_spectator_autospeed(), output);
}
// optional int32 dota_replay_speed = 8;
if (has_dota_replay_speed()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(8, this->dota_replay_speed(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:CP2P_WatchSynchronization)
}
::google::protobuf::uint8* CP2P_WatchSynchronization::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:CP2P_WatchSynchronization)
// optional int32 demo_tick = 1;
if (has_demo_tick()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->demo_tick(), target);
}
// optional bool paused = 2;
if (has_paused()) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->paused(), target);
}
// optional int32 tv_listen_voice_indices = 3;
if (has_tv_listen_voice_indices()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->tv_listen_voice_indices(), target);
}
// optional int32 dota_spectator_mode = 4;
if (has_dota_spectator_mode()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->dota_spectator_mode(), target);
}
// optional int32 dota_spectator_watching_broadcaster = 5;
if (has_dota_spectator_watching_broadcaster()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->dota_spectator_watching_broadcaster(), target);
}
// optional int32 dota_spectator_hero_index = 6;
if (has_dota_spectator_hero_index()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->dota_spectator_hero_index(), target);
}
// optional int32 dota_spectator_autospeed = 7;
if (has_dota_spectator_autospeed()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->dota_spectator_autospeed(), target);
}
// optional int32 dota_replay_speed = 8;
if (has_dota_replay_speed()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(8, this->dota_replay_speed(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:CP2P_WatchSynchronization)
return target;
}
int CP2P_WatchSynchronization::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional int32 demo_tick = 1;
if (has_demo_tick()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->demo_tick());
}
// optional bool paused = 2;
if (has_paused()) {
total_size += 1 + 1;
}
// optional int32 tv_listen_voice_indices = 3;
if (has_tv_listen_voice_indices()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->tv_listen_voice_indices());
}
// optional int32 dota_spectator_mode = 4;
if (has_dota_spectator_mode()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->dota_spectator_mode());
}
// optional int32 dota_spectator_watching_broadcaster = 5;
if (has_dota_spectator_watching_broadcaster()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->dota_spectator_watching_broadcaster());
}
// optional int32 dota_spectator_hero_index = 6;
if (has_dota_spectator_hero_index()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->dota_spectator_hero_index());
}
// optional int32 dota_spectator_autospeed = 7;
if (has_dota_spectator_autospeed()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->dota_spectator_autospeed());
}
// optional int32 dota_replay_speed = 8;
if (has_dota_replay_speed()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->dota_replay_speed());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void CP2P_WatchSynchronization::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const CP2P_WatchSynchronization* source =
::google::protobuf::internal::dynamic_cast_if_available<const CP2P_WatchSynchronization*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void CP2P_WatchSynchronization::MergeFrom(const CP2P_WatchSynchronization& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_demo_tick()) {
set_demo_tick(from.demo_tick());
}
if (from.has_paused()) {
set_paused(from.paused());
}
if (from.has_tv_listen_voice_indices()) {
set_tv_listen_voice_indices(from.tv_listen_voice_indices());
}
if (from.has_dota_spectator_mode()) {
set_dota_spectator_mode(from.dota_spectator_mode());
}
if (from.has_dota_spectator_watching_broadcaster()) {
set_dota_spectator_watching_broadcaster(from.dota_spectator_watching_broadcaster());
}
if (from.has_dota_spectator_hero_index()) {
set_dota_spectator_hero_index(from.dota_spectator_hero_index());
}
if (from.has_dota_spectator_autospeed()) {
set_dota_spectator_autospeed(from.dota_spectator_autospeed());
}
if (from.has_dota_replay_speed()) {
set_dota_replay_speed(from.dota_replay_speed());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void CP2P_WatchSynchronization::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void CP2P_WatchSynchronization::CopyFrom(const CP2P_WatchSynchronization& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool CP2P_WatchSynchronization::IsInitialized() const {
return true;
}
void CP2P_WatchSynchronization::Swap(CP2P_WatchSynchronization* other) {
if (other != this) {
std::swap(demo_tick_, other->demo_tick_);
std::swap(paused_, other->paused_);
std::swap(tv_listen_voice_indices_, other->tv_listen_voice_indices_);
std::swap(dota_spectator_mode_, other->dota_spectator_mode_);
std::swap(dota_spectator_watching_broadcaster_, other->dota_spectator_watching_broadcaster_);
std::swap(dota_spectator_hero_index_, other->dota_spectator_hero_index_);
std::swap(dota_spectator_autospeed_, other->dota_spectator_autospeed_);
std::swap(dota_replay_speed_, other->dota_replay_speed_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata CP2P_WatchSynchronization::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = CP2P_WatchSynchronization_descriptor_;
metadata.reflection = CP2P_WatchSynchronization_reflection_;
return metadata;
}
// @@protoc_insertion_point(namespace_scope)
// @@protoc_insertion_point(global_scope)
| 33.944853 | 133 | 0.703118 | devilesk |
efb2eb3e96f6020c3d91536886f463811a9693f3 | 36 | cpp | C++ | Chapter-3-Tree/Homework/Chapter-3-Tree-Homework-1/main.cpp | jubgjf/DataStructuresAndAlgorithms | 48c7fa62e618ddbefa760229ce677cdfc822b53f | [
"MIT"
] | 2 | 2020-10-18T07:36:25.000Z | 2021-07-31T23:34:49.000Z | Chapter-3-Tree/Homework/Chapter-3-Tree-Homework-1/main.cpp | jubgjf/DataStructuresAndAlgorithms | 48c7fa62e618ddbefa760229ce677cdfc822b53f | [
"MIT"
] | null | null | null | Chapter-3-Tree/Homework/Chapter-3-Tree-Homework-1/main.cpp | jubgjf/DataStructuresAndAlgorithms | 48c7fa62e618ddbefa760229ce677cdfc822b53f | [
"MIT"
] | null | null | null | #include "header.h"
int main()
{
}
| 6 | 19 | 0.583333 | jubgjf |
efb9f6507df42e6e4b450ae84d187d9bfc4a6c6c | 818 | cpp | C++ | Problem Solving/Algorithms/Strings/Making Anagrams/making anagrams.cpp | IsaacAsante/hackerrank | 76c430b341ce1e2ab427eda57508eb309d3b215b | [
"MIT"
] | 108 | 2021-03-29T05:04:16.000Z | 2022-03-19T15:11:52.000Z | Problem Solving/Algorithms/Strings/Making Anagrams/making anagrams.cpp | IsaacAsante/hackerrank | 76c430b341ce1e2ab427eda57508eb309d3b215b | [
"MIT"
] | null | null | null | Problem Solving/Algorithms/Strings/Making Anagrams/making anagrams.cpp | IsaacAsante/hackerrank | 76c430b341ce1e2ab427eda57508eb309d3b215b | [
"MIT"
] | 32 | 2021-03-30T03:56:54.000Z | 2022-03-27T14:41:32.000Z | /* Author: Isaac Asante
* HackerRank URL for this exercise: https://www.hackerrank.com/challenges/making-anagrams/problem
* Original video explanation: https://www.youtube.com/watch?v=05mznZNMjvY
* Last verified on: May 19, 2021
*/
/* IMPORTANT:
* This code is meant to be used as a solution on HackerRank (link above).
* It is not meant to be executed as a standalone program.
*/
int makingAnagrams(string s1, string s2) {
int alphabet[26] = { 0 }; // All counts initialized to zero
int sum = 0;
for (int i = 0; i < s1.size(); i++)
--alphabet[s1[i] - 'a']; // Decrease for s1
for (int i = 0; i < s2.size(); i++)
++alphabet[s2[i] - 'a']; // Increase for s2
for (int i = 0; i < 26; i++)
sum += abs(alphabet[i]); // Get the sum of abs values
return sum;
}
| 31.461538 | 98 | 0.617359 | IsaacAsante |
efbb5ba8d03dba10a5d87893ddf82b2ff52cb452 | 1,396 | hpp | C++ | include/jules/array/math.hpp | verri/jules | 5370c533a68bb670ae937967e024428c705215f8 | [
"Zlib"
] | 8 | 2016-12-07T21:47:48.000Z | 2019-11-25T14:26:27.000Z | include/jules/array/math.hpp | verri/jules | 5370c533a68bb670ae937967e024428c705215f8 | [
"Zlib"
] | 23 | 2016-12-07T21:22:24.000Z | 2019-09-02T13:58:42.000Z | include/jules/array/math.hpp | verri/jules | 5370c533a68bb670ae937967e024428c705215f8 | [
"Zlib"
] | 3 | 2017-01-18T02:11:32.000Z | 2018-04-16T01:40:36.000Z | // Copyright (c) 2017-2019 Filipe Verri <[email protected]>
#ifndef JULES_ARRAY_MATH_H
#define JULES_ARRAY_MATH_H
#include <jules/array/functional.hpp>
#include <jules/base/math.hpp>
#include <cmath>
namespace jules
{
template <typename Array>
auto normal_pdf(const common_array_base<Array>& array, typename Array::value_type mu, typename Array::value_type sigma)
{
return apply(array, [mu = std::move(mu), sigma = std::move(sigma)](const auto& x) { return normal_pdf(x, mu, sigma); });
}
template <typename Array> auto abs(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return abs(v); });
}
template <typename Array> auto sqrt(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return sqrt(v); });
}
template <typename Array> auto log(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return log(v); });
}
template <typename Array> auto sin(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return sin(v); });
}
template <typename Array> auto cos(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return cos(v); });
}
template <typename Array> auto tanh(const common_array_base<Array>& array)
{
return apply(array, [](const auto& v) { return tanh(v); });
}
} // namespace jules
#endif // JULES_ARRAY_MATH_H
| 26.339623 | 122 | 0.709169 | verri |
efc35cabfe9d8082842d0bb0d67189eec5730142 | 33,561 | cpp | C++ | src/lib/safe_storage.cpp | imaginatho/safestorage | a2581a1ec4e2e52b39f1f8f7f08afa9c566ee127 | [
"MIT"
] | 8 | 2015-07-04T04:06:15.000Z | 2015-07-10T07:43:41.000Z | src/lib/safe_storage.cpp | imaginatho/safestorage | a2581a1ec4e2e52b39f1f8f7f08afa9c566ee127 | [
"MIT"
] | null | null | null | src/lib/safe_storage.cpp | imaginatho/safestorage | a2581a1ec4e2e52b39f1f8f7f08afa9c566ee127 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <syslog.h>
#include <iostream>
#include <sstream>
#include <string>
#include <exception>
using namespace std;
#include <log.h>
#include <safe_storage_imp.h>
#include <safe_storage_listener.h>
static const char *__safe_storage_extensions [] = {"", ".idx", ".rlg", ".st"};
#define CSTORAGE_SIGNATURE 0x51213298
#define CSTORAGE_SIGNATURE_MASK 0x00000007
#define DECLARE_STRUCT(X,Y) X Y; memset(&Y, 0, sizeof(Y));
#define DECLARE_DEFAULT_STRUCT(X,Y) X __##Y; if (!Y) { memset(&__##Y, 0, sizeof(__##Y)); Y=&__##Y; };
#define CSTORAGE_MODE_STANDARD 0
#define CSTORAGE_MODE_REBUILD 1
template <class R>
bool cmp_struct_field(R st1, R st2, const char *st1_name, const char *st2_name, const char *fieldname, int32_t pos )
{
if (st1 == st2) return true;
std::stringstream msg;
msg << "Field " << fieldname << "of structures " << st1_name;
if (pos >= 0) {
msg << "[" << pos << "]";
}
msg << "(" << st1 << ") and " << st2_name;
if (pos >= 0) {
msg << "[" << pos << "]";
}
msg << "(" << st2 << ") are different";
C_LOG_ERR(msg.str().c_str());
return false;
}
#define CMP_STRUCT_FIELD(ST1,ST2,FIELD,R)\
R |= cmp_struct_field<__typeof__(ST1.FIELD)>(ST1.FIELD,ST2.FIELD,#ST1,#ST2,#FIELD,-1);
#define CMP_STRUCT_ARRAY_FIELD(ST1,ST2,FIELD,R)\
for (int32_t __##FIELD##__index__=0; __##FIELD##__index__ < (int32_t)(sizeof(ST1.FIELD)/sizeof(ST1.FIELD[0])); ++__##FIELD##__index__ ) {\
R |= cmp_struct_field<__typeof__(ST1.FIELD[0])>(\
ST1.FIELD[__##FIELD##__index__],\
ST2.FIELD[__##FIELD##__index__],\
#ST1,#ST2,#FIELD,__##FIELD##__index__);\
}\
typedef union
{
CSafeStorageIndexReg index;
CSafeStorageDataReg data;
CSafeStorageLogReg log;
uint32_t hash_key;
} CSafeStorageHashReg;
/*
* Constructor class CSafeStorage, this method initialize structures, and create list of
* safe files managed with object. These files are added in list files.
*/
CSafeStorage::CSafeStorage ( void )
: findex(0, D_CSTORAGE_INDEX_CACHE),
flog(0, D_CSTORAGE_LOG_CACHE),
fdata(0,0, D_CSTORAGE_DATA_INIT_SIZE, D_CSTORAGE_DATA_DELTA_SIZE /*, 16*/),
fstate(0,0)
{
cursor = -1;
rdwr = false;
dirtySerials = NULL;
dirtySerialSize = 0;
dirtySerialIndex = 0;
mode = CSTORAGE_MODE_STANDARD;
memset(&state, 0, sizeof(state));
files.push_back(&fdata);
files.push_back(&findex);
files.push_back(&flog);
files.push_back(&fstate);
}
/*
* Destructor, that close all files.
*/
CSafeStorage::~CSafeStorage ()
{
close();
if (dirtySerials) free(dirtySerials);
}
/*
* Method that close all file, using list file, close each file.
*/
int32_t CSafeStorage::close ( uint32_t flags )
{
CBaseSafeFileList::iterator it = files.begin();
saveState(true);
while (it != files.end())
{
(*it)->close();
++it;
}
clearDirtySerials();
if (rdwr) sync(true);
fauto_commit = false;
return E_CSTORAGE_OK;
}
/*
* Open a new environment, a list of files in one directory.
*
* @param filename prefix, filename without extension
* @param flags flags that applies to this operation. Current, no flags defined for this operation.
*
* @return 0 if no errors, error code if error occurs.
*/
int32_t CSafeStorage::open ( const string &filename, uint32_t flags, uint32_t hash_key )
{
string _filename;
fauto_commit = false;
try
{
flags |= F_CSFILE_EXCEPTIONS;
int32_t index = 0;
// Check if all file exists
string basename = normalizeFilename(filename);
rdwr = (flags & F_CSTORAGE_WR);
int32_t count = checkFilesPresent(basename, (flags & F_CSTORAGE_WR) ? (R_OK|W_OK):R_OK);
if (count > 0) {
if (count == (int32_t)files.size() && (flags & F_CSTORAGE_CREATE)) return create(basename, flags, hash_key);
return E_CSTORAGE_OPEN_FILE_NO_ACCESS;
}
CBaseSafeFileList::iterator it = files.begin();
// for each file open file
while (it != files.end())
{
_filename = basename + __safe_storage_extensions[index++];
(*it)->open(_filename, flags);
++it;
}
loadState();
// check if hash of all files it's the same.
int32_t result = checkHashKey();
if (result != E_CSTORAGE_OK)
CEXP_CODE(result);
if (flags & F_CSTORAGE_AUTO_COMMIT) {
C_LOG_INFO("Setting autocommit on (flgs:%08X)", flags);
fauto_commit = true;
}
}
catch (const CException &e)
{
// if error found, all files must be closed
C_LOG_ERR("e.getResult()=%d", e.getResult());
close();
return e.getResult();
}
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::setFlags ( uint32_t flags )
{
string _filename;
CBaseSafeFileList::iterator it = files.begin();
for (int _loop = 0; _loop < 2; ++_loop) {
while (it != files.end())
{
_filename = (*it)->getFilename();
// _filename += __safe_storage_extensions[index++];
int result = (*it)->setFlags(flags | (_loop == 0 ? F_CSFILE_CHECK_FLAGS : 0));
if (_loop == 0 && result < 0) {
return E_CSTORAGE_ERROR;
}
++it;
}
}
return 0;
}
string CSafeStorage::normalizeFilename ( const string &filename )
{
int extlen = strlen(__safe_storage_extensions[0]);
if (filename.compare(filename.size() - extlen, extlen, __safe_storage_extensions[0]) == 0) {
return filename.substr(0, filename.size() - extlen);
}
return filename;
}
/*
* Method to create all files
*
* @param filename prefix, filename without extension
* @param flags flags that applies to this operation. Current, no flags defined for this operation.
*
* @return 0 if no errors, error code if error occurs.
*/
int32_t CSafeStorage::create ( const string &filename, uint32_t flags, uint32_t hash_key )
{
C_LOG_DEBUG("create(%s, %04X)", filename.c_str(), flags);
fauto_commit = false;
string basename = normalizeFilename(filename);
if (mode != CSTORAGE_MODE_REBUILD) {
// Check if any file is created
if (checkAnyFilePresent(basename)) {
C_LOG_ERR("FileExists");
return E_CSTORAGE_CREATE_FILE_EXISTS;
}
}
string _filename;
try
{
CBaseSafeFileList::iterator it = files.begin();
int32_t index = 0;
uint32_t nflags = flags | (F_CSFILE_EXCEPTIONS|F_CSFILE_CREATE|F_CSFILE_WR|F_CSFILE_TRUNCATE);
// list of files is created on constructor, array _safe_storage_extensions
// contains extension for each type of file
while (it != files.end())
{
_filename = basename + __safe_storage_extensions[index++];
(*it)->open(_filename, ((*it) == &fdata && (mode == CSTORAGE_MODE_REBUILD)) ? flags : nflags);
++it;
}
// to link all files and avoid that one of them was replaced, renamed, etc.. generate
// a hash key and this key is stored in all files.
if (mode == CSTORAGE_MODE_REBUILD) {
getHashKey(hash_key);
}
else if ((flags & F_CSTORAGE_SET_HASH_KEY) == 0) {
hash_key = generateHashKey();
}
writeHashKey(hash_key, flags);
if (flags & F_CSTORAGE_AUTO_COMMIT) {
C_LOG_INFO("Setting autocommit on (flgs:%08X)", flags);
fauto_commit = true;
}
}
catch (CException &e)
{
// if error found, all files must be closed
C_LOG_ERR("CException %d on %s:%d", e.getResult(), e.getFile(), e.getLine());
close();
return e.getResult();
}
return 0;
}
int32_t CSafeStorage::rebuild ( const string &filename, uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageDataReg, r_data)
// donde tenemos guardaa
C_LOG_DEBUG("rebuild(%s, %04X)", filename.c_str(), flags);
mode = CSTORAGE_MODE_REBUILD;
int32_t result = CSafeStorage::create(filename, flags);
if (result != E_CSTORAGE_OK) {
return result;
}
DECLARE_STRUCT(CSafeStorageState, _state)
DECLARE_STRUCT(CSafeStorageHashReg, h)
uint8_t *data = (uint8_t *)malloc(1024*1024);
result = fdata.read(0, h.data);
if (result < 0)
{
C_LOG_ERR("Internal error %d reading data 0", result);
return E_CSTORAGE_DATA_READ;
}
// TODO: Rebuild, gestion del rebuild
while ((result = fdata.read(C_CSFILE_CURRPOS, r_data, data, 1024*1024)) > 0)
{
printf("%08X %8d %8d %6d %02X\n", r_data.signature, r_data.serial, r_data.sequence, r_data.len, r_data.flags);
writeFiles(r_data, data, r_data.len);
}
printf("end rebuild (%d)\n", result);
mode = CSTORAGE_MODE_STANDARD;
saveState(false);
sync(true);
return result;
}
/*
* Check if any file is accessible
*
* @param filename prefix of files, name without extension
* @param mode mode for access check.
*
* @return number of files accessible. If returns 0 means files no exists.
*/
int32_t CSafeStorage::checkFilesPresent ( const string &filename, int32_t mode )
{
string _filename;
int32_t index = 0;
int32_t result = 0;
// for each file
while (index < (int32_t)files.size())
{
// generate filename of each file
_filename = filename + __safe_storage_extensions[index++];
// if file is accessible increment counter result.
if (access(_filename.c_str(), mode)!= 0)
{
C_LOG_DEBUG("checking file %s (not found)", _filename.c_str());
++result;
}
else {
C_LOG_DEBUG("checking file %s (found)", _filename.c_str());
}
}
C_LOG_DEBUG("result=%d", result);
return result;
}
int32_t CSafeStorage::checkAnyFilePresent ( const string &filename )
{
return (files.size() - checkFilesPresent(filename, R_OK));
}
/*
* Sync of all files
*/
void CSafeStorage::sync ( bool full )
{
if (mode == CSTORAGE_MODE_REBUILD) return;
fdata.sync();
if (!full) return;
findex.sync();
flog.sync();
fstate.sync();
}
/*
* Method to make a commit of all made from last commit or rollback. This method
* add commit as data (to recover), as commit as log, and updated status
*
* @return 0 means Ok, otherwise means error.
*/
int32_t CSafeStorage::commit ( void )
{
DECLARE_STRUCT(CSafeStorageDataReg,r_data)
if (fauto_commit)
{
C_LOG_DEBUG("Ignore commit because we are in auto-commit mode");
return E_CSTORAGE_OK;
}
C_LOG_DEBUG("CSafeStorage::commit()");
r_data.signature = CSTORAGE_SIGNATURE | T_CSTORAGE_COMMIT;
r_data.sequence = state.last_sequence + 1;
int32_t result = writeFiles(r_data);
// TO-DO: open transactions, make a rollback?
clearDirtySerials();
sync();
return result;
}
void CSafeStorage::clearDirtySerials ( void )
{
dirtySerialIndex = 0;
}
void CSafeStorage::addDirtySerial ( tserial_t serial )
{
if (dirtySerialIndex >= dirtySerialSize) {
dirtySerialSize += C_DIRTY_SERIAL_SIZE;
if (!dirtySerials) dirtySerials = (tserial_t *)malloc(dirtySerialSize * sizeof(tserial_t));
else dirtySerials = (tserial_t *)realloc(dirtySerials, dirtySerialSize * sizeof(tserial_t));
}
dirtySerials[dirtySerialIndex++] = serial;
}
/*
* Method to make a rollback of all write made from last commit or rollback. This method make following steps:
* 1) add rollback (begin) as data
* 2) add rollback (begin) as log
* 3) save state and synchronize all data, log, and state
* 4) update all index of rollback, setting offset -1.
* 5) synchronize index
* 6) add rollback (end) as data linked to last index updated
* 7) add rollback (end) as log linked to last index updated
* 8) save state and synchronize all data, log, and state
*
* @return 0 means Ok, otherwise means error.
*/
int32_t CSafeStorage::rollback ( void )
{
C_LOG_INFO("rollback");
DECLARE_STRUCT(CSafeStorageDataReg,r_data)
int32_t result = E_CSTORAGE_OK;
if (fauto_commit)
{
C_LOG_DEBUG("Rollback disabled in auto-commit mode");
return E_CSTORAGE_NO_ROLLBACK_IN_AUTOCOMMIT;
}
C_LOG_DEBUG("CSafeStorage::rollback()");
r_data.signature = CSTORAGE_SIGNATURE | T_CSTORAGE_ROLLBACK_BEGIN;
r_data.sequence = state.last_sequence + 1;
int32_t dlen = (dirtySerialIndex+1) * sizeof(tserial_t);
tserial_t *serials = (tserial_t *)malloc(dlen);
serials[0] = dirtySerialIndex;
for (uint32_t index = 0; index < dirtySerialIndex; ++index ) serials[index+1] = dirtySerials[index];
result = writeFiles(r_data, serials, dlen);
free(serials);
// asociated to rollback_end stored last index modified, todo a check integrity
// beetween index and data.
memset(&r_data, 0, sizeof(r_data));
r_data.sequence = state.last_sequence + 1;
r_data.signature = CSTORAGE_SIGNATURE | T_CSTORAGE_ROLLBACK_END;
result = writeFiles(r_data);
clearDirtySerials();
return result;
}
/*
* Method used to verify content of data, recalculate all information and check it with index
* state, and log files
*
* @return 0 means verify was ok, error in otherwise.
*/
int32_t CSafeStorage::verify ( uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageDataReg, r_data)
DECLARE_STRUCT(CSafeStorageState, _state)
int32_t result = fdata.read(0, r_data);
if (result > 0)
{
C_LOG_ERR("Internal error %d reading data 0", result);
return E_CSTORAGE_DATA_READ;
}
while ((result = fdata.read(C_CSFILE_CURRPOS, r_data)) > 0)
{
uint32_t type = r_data.signature & CSTORAGE_SIGNATURE_MASK;
switch(type)
{
// _state.last_offset_index;
// _state.last_offsets;
case T_CSTORAGE_COMMIT:
{
_state.last_close_sequence = r_data.sequence;
_state.last_close_offset = fdata.lastOffset();
_state.last_commit_sequence = r_data.sequence;
++_state.commit_count;
break;
}
case T_CSTORAGE_WRITE:
{
++_state.data_count;
break;
}
case T_CSTORAGE_ROLLBACK_BEGIN:
{
++_state.rollback_begin_count;
break;
}
case T_CSTORAGE_ROLLBACK_END:
{
_state.last_close_sequence = r_data.sequence;
_state.last_close_offset = fdata.lastOffset();
++_state.rollback_end_count;
break;
}
case T_CSTORAGE_STATUS:
{
break;
}
default:
{
C_LOG_ERR("Internal error: Non expected data type (0x%08X) was found", type);
return E_CSTORAGE_DATA_READ;
}
}
_state.last_sequence = r_data.sequence;
++_state.count;
}
CMP_STRUCT_FIELD(state,_state,count,result);
CMP_STRUCT_FIELD(state,_state,data_count,result);
CMP_STRUCT_FIELD(state,_state,commit_count,result);
CMP_STRUCT_FIELD(state,_state,rollback_begin_count,result);
CMP_STRUCT_FIELD(state,_state,rollback_end_count,result);
CMP_STRUCT_FIELD(state,_state,last_offset_index,result);
CMP_STRUCT_FIELD(state,_state,last_commit_sequence,result);
CMP_STRUCT_FIELD(state,_state,last_rollback_sequence,result);
CMP_STRUCT_FIELD(state,_state,last_close_sequence,result);
CMP_STRUCT_FIELD(state,_state,last_sequence,result);
CMP_STRUCT_ARRAY_FIELD(state,_state,last_offsets,result);
return result;
}
int32_t CSafeStorage::recoverDirtySerials ( void )
{
DECLARE_STRUCT(CSafeStorageDataReg ,r_data)
uint64_t offset = state.last_close_offset;
clearDirtySerials();
int32_t result = fdata.read(offset, r_data);
if (result > 0)
{
C_LOG_ERR("Internal error %d reading data on offset %lld", result, offset);
return E_CSTORAGE_DATA_READ;
}
uint32_t type = r_data.signature & CSTORAGE_SIGNATURE_MASK;
if (type != T_CSTORAGE_COMMIT && type != T_CSTORAGE_ROLLBACK_BEGIN && type != T_CSTORAGE_ROLLBACK_END)
{
C_LOG_ERR("Internal error: On offset %llld non expected data type (0x%08X) was found", offset, type);
return E_CSTORAGE_DATA_READ;
}
while ((result = fdata.read(C_CSFILE_CURRPOS, r_data)) > 0)
{
type = r_data.signature & CSTORAGE_SIGNATURE_MASK;
if (type != T_CSTORAGE_WRITE)
{
C_LOG_ERR("Internal error: Non expected data type (0x%08X) was found", offset, type);
return E_CSTORAGE_DATA_READ;
}
if ((r_data.flags & F_CSTORAGE_DF_AUTO_COMMIT) == 0)
addDirtySerial(r_data.serial);
}
return result;
}
int32_t CSafeStorage::read ( tserial_t &serial, void *data, uint32_t dlen, uint32_t flags )
{
C_LOG_DEBUG("read(%ld, %p, %d, %08X)", serial, data, dlen, flags);
DECLARE_STRUCT(CSafeStorageIndexReg ,r_index)
DECLARE_STRUCT(CSafeStorageDataReg ,r_data)
cursor = serial;
if (!rdwr) loadState();
int32_t result = findex.readIndex(serial, r_index);
if (result == E_CSFILE_EMPTY_DATA)
return E_CSTORAGE_SERIAL_NOT_FOUND;
if (result < 0)
return result;
/* verify if offset error, or offset not initialized (=0) or deleted (=-1) */
last_offset = getLastOffset(r_index, serial, flags);
if (last_offset <= 0)
return E_CSTORAGE_SERIAL_NOT_FOUND;
C_LOG_DEBUG("try to read %d bytes on offset %lld", dlen, last_offset);
result = fdata.read(last_offset, r_data, data, dlen);
if (result < 0)
return result;
if (C_LOG_DEBUG_ENABLED) {
if (result > 1024) { C_LOG_DEBUG("data(%p): %s...%s", data, c_log_data2hex(data, 0, 256), c_log_data2hex(data, result - 256, 256)); }
else { C_LOG_DEBUG("data(%p): %s", data, c_log_data2hex(data, 0, result)); };
}
result = result - sizeof(r_data);
C_LOG_DEBUG("state.last_commit_sequence:%d r_data.sequence:%d autocommit:%s", state.last_commit_sequence, r_data.sequence,
(r_data.flags & F_CSTORAGE_DF_AUTO_COMMIT)? "true":"false");
if (C_LOG_DEBUG_ENABLED) {
if (result > 1024) { C_LOG_DEBUG("data(%p): %s...%s", data, c_log_data2hex(data, 0, 256), c_log_data2hex(data, result - 256, 256)); }
else { C_LOG_DEBUG("data(%p): %s", data, c_log_data2hex(data, 0, result)); };
}
return result;
}
int32_t CSafeStorage::readLog ( tseq_t seq, void *data, uint32_t dlen, uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageLogReg ,r_log)
if (!rdwr) loadState();
int32_t result = flog.readIndex(seq, r_log);
if (result < 0) return result;
if (result == E_CSFILE_EMPTY_DATA)
return E_CSTORAGE_SEQUENCE_NOT_FOUND;
if (result < 0)
return result;
int64_t offset = r_log.offset;
if (offset < 0)
return E_CSTORAGE_SEQUENCE_NOT_FOUND;
if (dlen < sizeof(CSafeStorageDataReg))
return E_CSTORAGE_NOT_ENOUGH_DATA;
uint8_t *d_data = ((uint8_t *)data) + sizeof(CSafeStorageDataReg);
result = fdata.read(offset, *((CSafeStorageDataReg *)data), d_data, dlen - sizeof(CSafeStorageDataReg));
if (result < 0)
return result;
return result;
}
/*
* Method to access to log
*
* @param seq sequence of log to read
* @param serial out parameter, if it isn't null was stored serial number of this sequence
* @param type out parameter, if it isn't null was stored type of action of this sequence
* (write, commit, rollback-begin, rollback-end)
*
* @return 0 Ok, error in otherwise.
*/
int32_t CSafeStorage::readLogReg ( tseq_t seq, tserial_t &serial, uint8_t &type, uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageLogReg ,r_log)
int32_t result = flog.readIndex(seq, r_log);
if (result < 0) return result;
serial = r_log.serial;
type = r_log.type;
return 0;
}
/*
* Write a hash (mark) in all files, to link them, to avoid that
* one of files was replaced with another.
*/
int32_t CSafeStorage::writeHashKey ( uint32_t hash_key, uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageHashReg, h)
C_LOG_TRACE("writeHashKey %08X", hash_key);
// store hash in structure
h.hash_key = hash_key;
// write hash in files
if (mode != CSTORAGE_MODE_REBUILD) {
fdata.write(0, h.data);
}
flog.write(0, h.log);
findex.write(0, h.index);
// set hash in state structure, and save it.
state.hash_key = hash_key;
saveState(false);
sync();
return 0;
}
/*
* Check that all files are liked, when files was created an random hash of 4 bytes was generated
* and copy in all files. With this feature it's possible detect when files was replace by other
* incorrect or old file. Data hash is considered how master hash. This information about hash is
* stored in first record.
*
* @return if checks is passed return 0, if not return value that was an OR of all hash that fails.
*/
int32_t CSafeStorage::checkHashKey ( void )
{
DECLARE_STRUCT(CSafeStorageHashReg, h)
uint32_t hash_key;
int32_t result = E_CSTORAGE_OK;
fdata.read(0, h.data);
hash_key = h.hash_key;
C_LOG_DEBUG("CheckHashKey %08X", hash_key);
flog.read(0, h.log);
if (h.hash_key != hash_key) {
C_LOG_ERR("CheckHashKey Log [FAILS] (Data: %08X / Log: %08X)", hash_key, h.hash_key);
result |= E_CSTORAGE_FAIL_HK_LOG;
}
findex.read(0, h.index);
if (h.hash_key != hash_key) {
C_LOG_ERR("CheckHashKey Index [FAILS] (Data: %08X / Index: %08X)", hash_key, h.hash_key);
result |= E_CSTORAGE_FAIL_HK_INDEX;
}
if (!rdwr) loadState();
if (state.hash_key != hash_key) {
C_LOG_ERR("CheckHashKey State [FAILS] (Data: %08X / State: %08X)", hash_key, state.hash_key);
result |= E_CSTORAGE_FAIL_HK_STATE;
}
C_LOG_DEBUG("CheckHashKey [%s] result = %08X", result == E_CSTORAGE_OK ? "OK":"FAILS", result);
return result;
}
int32_t CSafeStorage::write ( tserial_t serial, const void *data, uint32_t dlen, uint32_t flags )
{
DECLARE_STRUCT(CSafeStorageDataReg ,r_data)
C_LOG_DEBUG("CSafeStorage::write(%d, %p, %d) lseq:%d", serial, data, dlen, state.last_sequence);
r_data.signature = CSTORAGE_SIGNATURE | T_CSTORAGE_WRITE;
r_data.serial = serial;
r_data.sequence = state.last_sequence + 1;
r_data.len = dlen;
if (fauto_commit)
r_data.flags |= F_CSTORAGE_DF_AUTO_COMMIT;
return writeFiles(r_data, data, dlen);
}
int32_t CSafeStorage::applyLog ( const void *data, uint32_t dlen, uint32_t flags )
{
if (dlen < sizeof(CSafeStorageDataReg))
return E_CSTORAGE_NOT_ENOUGH_DATA;
uint8_t *d_data = ((uint8_t *)data) + sizeof(CSafeStorageDataReg);
return writeFiles(*((CSafeStorageDataReg *)data), d_data, dlen - sizeof(CSafeStorageDataReg));
}
int32_t CSafeStorage::writeFiles ( CSafeStorageDataReg &r_data, const void *data, uint32_t dlen )
{
DECLARE_STRUCT(CSafeStorageIndexReg ,r_index)
DECLARE_STRUCT(CSafeStorageLogReg ,r_log)
int32_t result = E_CSTORAGE_OK;
int32_t type = r_data.signature & CSTORAGE_SIGNATURE_MASK;
++state.count;
state.last_sequence = r_data.sequence;
r_log.serial = r_data.serial;
r_log.type = type;
C_LOG_DEBUG("type:%08X dlen:%d", type, dlen);
switch (type)
{
case T_CSTORAGE_WRITE:
{
// prepare log register related to write
r_log.offset = writeData(r_data, data, dlen);
++state.data_count;
// prepare index related to write
setOldestOffset(r_index, r_data.serial, r_log.offset, r_data.sequence, r_data.flags, findex.readIndex(r_data.serial, r_index) < 0);
// if error in data write, abort this write and returns error
if (r_log.offset < 0LL) {
return -1;
}
if (!fauto_commit)
addDirtySerial(r_data.serial);
// save state with information
saveState();
flog.writeIndex(r_data.sequence, r_log);
findex.writeIndex(r_data.serial, r_index);
result = dlen;
break;
}
case T_CSTORAGE_ROLLBACK_BEGIN:
{
writeData(r_data, data, dlen);
writeSyncStateLogSync(r_log);
// mark offset of all indexes as -1
tserial_t *serials = (tserial_t *) data;
int32_t count = serials[0];
// must: dlen / sizeof(tserial_t) == serials[0]+1
int32_t index = 1;
while (index <= count)
{
findex.readIndex(serials[index], r_index);
setNewestOffset(r_index, serials[index], -1, 0, 0);
int32_t result = findex.writeIndex(serials[index], r_index);
if (result < 0)
C_LOG_ERR("CSafeStorage::rollBack Error saving index %d of rollback", serials[index]);
++index;
}
if (count > 0 && mode != CSTORAGE_MODE_REBUILD)
{
findex.sync();
}
break;
}
case T_CSTORAGE_ROLLBACK_END:
{
writeData(r_data);
writeSyncStateLogSync(r_log);
break;
}
case T_CSTORAGE_COMMIT:
{
r_log.offset = writeData(r_data);
++state.commit_count;
state.last_commit_sequence = r_data.sequence;
writeSyncStateLogSync(r_log);
break;
}
}
// check if store a status snapshot
if (state.count % C_STORAGE_STATUS_FREQ == (C_STORAGE_STATUS_FREQ - 1)) {
DECLARE_STRUCT(CSafeStorageDataReg,r_state_data)
r_state_data.signature = CSTORAGE_SIGNATURE | T_CSTORAGE_STATUS;
r_state_data.sequence = state.last_sequence + 1;
memset(&r_log, 0, sizeof(r_log));
++state.count;
state.last_sequence = r_state_data.sequence;
r_log.serial = r_state_data.serial;
r_log.type = T_CSTORAGE_STATUS;
r_log.offset = writeData(r_state_data);
flog.writeIndex(state.last_sequence, r_log);
saveState();
}
return result;
}
void CSafeStorage::writeSyncStateLogSync ( CSafeStorageLogReg &r_log )
{
flog.writeIndex(state.last_sequence, r_log);
/*
if (mode != CSTORAGE_MODE_REBUILD) fdata.sync();
saveState();
if (mode != CSTORAGE_MODE_REBUILD) flog.sync();*/
}
void CSafeStorage::saveState ( bool sync )
{
if (mode == CSTORAGE_MODE_REBUILD || !rdwr) return;
fstate.write(0, state);
/* if (sync)
fstate.sync();*/
}
void CSafeStorage::loadState ( void)
{
fstate.read(0, state);
}
uint32_t CSafeStorage::generateHashKey ( void )
{
int32_t fd;
uint32_t result = 0;
fd = ::open("/dev/random", O_RDONLY);
if (fd >= 0)
{
if (::read(fd, &result, sizeof(result)) != sizeof(result))
fd = -1;
::close(fd);
}
if (fd < 0) {
srand ( time(NULL) );
result = rand();
}
return result;
}
int32_t CSafeStorage::getInfo ( CSafeStorageInfo &info )
{
info.hash_key = state.hash_key;
info.last_updated = state.last_updated;
info.version = 0;
info.count = state.count;
info.commit_count = state.commit_count;
info.rollback_begin_count = state.rollback_begin_count;
info.rollback_end_count = state.rollback_end_count;
info.last_commit_sequence = state.last_commit_sequence;
info.last_rollback_sequence = state.last_rollback_sequence;
info.last_sequence = state.last_sequence;
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::getHashKey ( uint32_t &hash_key )
{
DECLARE_STRUCT(CSafeStorageHashReg, h)
int32_t result = fdata.read(0, h.data);
if (result == sizeof(h.data)) {
result = E_CSTORAGE_OK;
hash_key = h.hash_key;
}
return result;
}
void CSafeStorage::dumpState ( void )
{
int32_t index;
printf("[state]\n");
printf("hash_key: %08X\n", state.hash_key);
printf("last_updated: %d\n", state.last_updated);
printf("count: %d\n", state.count);
printf("commit_count: %d\n", state.commit_count);
printf("rollback_begin_count: %d\n", state.rollback_begin_count);
printf("rollback_end_count: %d\n", state.rollback_end_count);
printf("last_offset_index: %d\n", state.last_offset_index);
printf("last_commit_sequence: %u\n", state.last_commit_sequence);
printf("last_rollback_sequence: %u\n", state.last_rollback_sequence);
printf("last_close_sequence: %d\n", state.last_close_sequence);
printf("last_sequence: %d\n", state.last_sequence);
printf("last_close_offset: %lld\n", state.last_close_offset);
printf("last_offsets[%d]:", sizeof(state.last_offsets)/sizeof(state.last_offsets[0]));
for (index = 0; index < (int32_t)(sizeof(state.last_offsets)/sizeof(state.last_offsets[0])); ++index) {
printf("%s%lld", index?",":"", state.last_offsets[index]);
}
printf("\n");
}
int64_t CSafeStorage::writeData ( CSafeStorageDataReg &r_data, const void *data, uint32_t dlen )
{
if (mode != CSTORAGE_MODE_REBUILD) {
int64_t result = fdata.write(r_data, data, dlen);
if (result < 0) {
C_LOG_ERR("Error writting data (%p,%p,%d) result %d", &r_data, data, dlen, (int32_t)result);
return result;
}
}
state.last_offset_index = (state.last_offset_index + 1) % (sizeof(state.last_offsets)/sizeof(state.last_offsets[0]));
state.last_offsets[state.last_offset_index] = fdata.lastOffset();
return state.last_offsets[state.last_offset_index];
}
int32_t CSafeStorage::removeFiles ( const string &filename )
{
string _filename;
int32_t index = 0;
int32_t result = 0;
int32_t count = sizeof(__safe_storage_extensions)/sizeof(char *);
// for each file
while (index < count)
{
// generate filename of each file
_filename = filename + __safe_storage_extensions[index++];
C_LOG_DEBUG("deleting file %s", _filename.c_str());
if (unlink(_filename.c_str()))
--result;
}
return result;
}
void CSafeStorage::setOldestOffset ( CSafeStorageIndexReg &index, tserial_t serial, int64_t offset, tseq_t sequence, uint32_t flags, bool init )
{
C_LOG_TRACE("In #:%ld off:%lld seq:%d flgs:%08X init:%d 0:[%d,%lld] 1:[%d,%lld]", serial, offset, sequence, flags, init?1:0, index.sequences[0], index.offsets[0],index.sequences[1], index.offsets[1]);
if (init) {
memset(&index, 0, sizeof(index));
index.offsets[0] = offset;
index.sequences[0] = sequence;
index.flags[0] = flags;
index.offsets[1] = -1;
index.sequences[1] = 0;
index.flags[1] = 0;
}
else {
int32_t pos = (index.sequences[1] > index.sequences[0] ? 0 : 1);
index.offsets[pos] = offset;
index.sequences[pos] = sequence;
index.flags[pos] = flags;
}
C_LOG_TRACE("Out #:%ld 0:[%d,%lld] 1:[%d,%lld]", serial, index.sequences[0], index.offsets[0],index.sequences[1], index.offsets[1]);
}
void CSafeStorage::setNewestOffset ( CSafeStorageIndexReg &index, tserial_t serial, int64_t offset, tseq_t sequence, uint32_t flags )
{
C_LOG_TRACE("In #:%ld off:%lld seq:%d flgs:%08X 0:[%d,%lld] 1:[%d,%lld]", serial, offset, sequence, flags, index.sequences[0], index.offsets[0],index.sequences[1], index.offsets[1]);
int32_t pos = (index.sequences[1] > index.sequences[0] ? 1 : 0);
index.offsets[pos] = offset;
index.sequences[pos] = offset;
index.flags[pos] = flags;
C_LOG_TRACE("Out #:%ld 0:[%d,%lld] 1:[%d,%lld]", serial, index.sequences[0], index.offsets[0],index.sequences[1], index.offsets[1]);
}
int64_t CSafeStorage::getLastOffset ( CSafeStorageIndexReg &index, tserial_t serial, uint32_t flags )
{
int64_t result = -1;
tseq_t lastseq = 0;
uint32_t dirtyRead = (flags & F_CSTORAGE_READ_MODE_MASK) || rdwr;
for ( int32_t i = 0; i < 2; ++i ) {
// check if current position is autocommited if not, check that index is commited, current sequence is lower or equal
// last transaccion commited, if not, check if read in dirty read. Compare with lastseq to avoid read a old register.
if (index.sequences[i] >= lastseq && ((index.flags[i] & F_CSTORAGE_DF_AUTO_COMMIT) ||
index.sequences[i] <= state.last_commit_sequence || dirtyRead)) {
result = index.offsets[i];
lastseq = index.sequences[i];
}
}
C_LOG_INFO("0:[%02X, %d,%lld] 1:[%02X, %d,%lld] S:%u FLGS:%08X R:%lld LCS:%u RDWR:%d",
index.flags[0], index.sequences[0], index.offsets[0], index.flags[1], index.sequences[1], index.offsets[1],
serial, flags, result, state.last_commit_sequence, rdwr);
return result;
}
int64_t CSafeStorage::getLastOffset ( void )
{
return last_offset;
}
int32_t CSafeStorage::goTop ( uint32_t flags )
{
cursor = -1;
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::goPos ( tserial_t serial, uint32_t flags )
{
cursor = serial < 0 ? -1 : serial-1;
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::getParam ( const string &name )
{
if (name == "index_cache_size") return findex.getCacheSize();
else if (name == "log_cache_size") return flog.getCacheSize();
return -1;
}
int32_t CSafeStorage::setParam ( const string &name, int32_t value )
{
if (name == "index_cache_size") findex.setCacheSize(value);
else if (name == "log_cache_size") flog.setCacheSize(value);
else if (name == "c_log_level") c_log_set_level(value);
else return -1;
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::createListener ( const string ¶ms, ISafeStorageListener **ltn )
{
// syslog(LOG_ERR | LOG_USER, "createListener(%s)", params.c_str());
CSafeStorageListener *listener = new CSafeStorageListener(params);
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::createReplica ( const string ¶ms, ISafeStorageReplica **rpl )
{
// syslog(LOG_ERR | LOG_USER, "createReplica(%s)", params.c_str());
return E_CSTORAGE_OK;
}
int32_t CSafeStorage::setCallback ( tsafestorage_callback_t cb )
{
// syslog(LOG_ERR | LOG_USER, "setCallback");
cb(E_CB_REPLICA_FAIL, NULL);
return E_CSTORAGE_OK;
}
void CSafeStorage::findLastSignatureReg ( int32_t max_size )
{
fdata.findLastSignatureReg(max_size, CSTORAGE_SIGNATURE, CSTORAGE_SIGNATURE_SIGN_MASK, sizeof(uint32_t));
}
int32_t ISafeStorage::getLogReg ( const void *data, uint32_t dlen, CSafeStorageLogInfo &linfo )
{
if (sizeof(CSafeStorageDataReg) > dlen) {
return E_CSTORAGE_NOT_VALID_DATA;
}
const CSafeStorageDataReg *dreg = (const CSafeStorageDataReg *)data;
if ((dreg->signature & CSTORAGE_SIGNATURE_SIGN_MASK) != CSTORAGE_SIGNATURE) {
return E_CSTORAGE_NOT_VALID_DATA;
}
memset(&linfo, 0, sizeof(linfo));
linfo.sequence = dreg->sequence;
linfo.serial = dreg->serial;
linfo.type = (dreg->signature & CSTORAGE_SIGNATURE_TYPE_MASK);
linfo.len = dreg->len;
linfo.flags = dreg->flags;
return E_CSTORAGE_OK;
}
| 29.491213 | 201 | 0.678615 | imaginatho |
efc3a216bf2f72dbbbc86f4644ef0f02ab9552b3 | 2,540 | cpp | C++ | src/components/UIElement.cpp | KirmesBude/REGoth-bs | 2e13dc3b9005744fccd7cea9c7e7cc1f94809e4a | [
"MIT"
] | 399 | 2019-01-06T17:55:18.000Z | 2022-03-21T17:41:18.000Z | src/components/UIElement.cpp | KirmesBude/REGoth-bs | 2e13dc3b9005744fccd7cea9c7e7cc1f94809e4a | [
"MIT"
] | 101 | 2019-04-18T21:03:53.000Z | 2022-01-08T13:27:01.000Z | src/components/UIElement.cpp | KirmesBude/REGoth-bs | 2e13dc3b9005744fccd7cea9c7e7cc1f94809e4a | [
"MIT"
] | 56 | 2019-04-10T10:18:27.000Z | 2022-02-08T01:23:31.000Z | #include "UIElement.hpp"
#include <GUI/BsCGUIWidget.h>
#include <GUI/BsGUIPanel.h>
#include <Image/BsSpriteTexture.h>
#include <RTTI/RTTI_UIElement.hpp>
#include <exception/Throw.hpp>
#include <gui/skin_gothic.hpp>
#include <log/logging.hpp>
#include <original-content/OriginalGameResources.hpp>
namespace REGoth
{
UIElement::UIElement(const bs::HSceneObject& parent, bs::HCamera camera)
: bs::Component(parent)
{
setName("UIElement");
auto guiWidget = SO()->addComponent<bs::CGUIWidget>(camera);
guiWidget->setSkin(REGoth::GUI::getGothicStyleSkin());
mGuiLayout = guiWidget->getPanel();
}
UIElement::UIElement(const bs::HSceneObject& parent, HUIElement parentUiElement,
bs::GUILayout* layout)
: bs::Component(parent)
, mParentUiElement(parentUiElement)
, mGuiLayout(layout)
{
setName("UIElement");
if (parentUiElement->SO() != parent->getParent())
{
REGOTH_THROW(InvalidParametersException, "Parent UIElement must be attached to parent SO");
}
parentLayout().addElement(mGuiLayout);
}
UIElement::~UIElement()
{
}
void UIElement::show()
{
layout().setVisible(true);
}
void UIElement::hide()
{
layout().setVisible(false);
}
bs::HSceneObject UIElement::addChildSceneObject(const bs::String& name)
{
auto so = bs::SceneObject::create(name);
so->setParent(SO());
return so;
}
bs::GUILayout& UIElement::layout() const
{
if (!mGuiLayout)
{
REGOTH_THROW(InvalidStateException, "No Layout available?");
}
return *mGuiLayout;
}
bs::GUILayout& UIElement::parentLayout() const
{
if (!mParentUiElement)
{
REGOTH_THROW(InvalidStateException, "No parent available?");
}
return mParentUiElement->layout();
}
bs::Camera& UIElement::camera() const
{
if (!layout()._getParentWidget())
{
REGOTH_THROW(InvalidStateException, "No parent widget available?");
}
auto camera = layout()._getParentWidget()->getCamera();
if (!camera)
{
REGOTH_THROW(InvalidStateException, "No camera available?");
}
return *camera;
}
bs::HSpriteTexture UIElement::loadSprite(const bs::String& texture)
{
bs::HTexture t = gOriginalGameResources().texture(texture);
if (!t)
{
REGOTH_LOG(Warning, Uncategorized, "[UIElement] Failed to load texture: {0}", texture);
return {};
}
return bs::SpriteTexture::create(t);
}
REGOTH_DEFINE_RTTI(UIElement)
} // namespace REGoth
| 21.896552 | 97 | 0.658268 | KirmesBude |
efc6f35430fffde57adff0d36b3155817d6d4ba5 | 379 | hpp | C++ | src/lib/common/Utility.hpp | genome/diagnose_dups | 17f63ed3d07c63f9b55dc7431f6528707d30709f | [
"MIT"
] | 8 | 2015-05-13T12:40:44.000Z | 2018-03-09T15:10:21.000Z | src/lib/common/Utility.hpp | genome/diagnose_dups | 17f63ed3d07c63f9b55dc7431f6528707d30709f | [
"MIT"
] | 5 | 2015-03-22T00:58:44.000Z | 2017-12-08T18:21:49.000Z | src/lib/common/Utility.hpp | genome/diagnose_dups | 17f63ed3d07c63f9b55dc7431f6528707d30709f | [
"MIT"
] | 4 | 2015-08-04T01:11:54.000Z | 2017-04-11T10:27:42.000Z | #pragma once
#include <sam.h>
#include <stdint.h>
#include <vector>
namespace cigar {
std::vector<uint32_t> parse_string_to_cigar_vector(char const* cigar_string);
int32_t calculate_right_offset(bam1_t const* record);
int32_t calculate_right_offset(char const* cigar);
int32_t calculate_left_offset(bam1_t const* record);
int32_t calculate_left_offset(char const* cigar);
}
| 22.294118 | 77 | 0.802111 | genome |
efcb3c623f09b27de5e5af4d73f99e82b6b7561c | 2,181 | cpp | C++ | src/kernel/io/KPrintf.cpp | jameskingstonclarke/arctic | 6fec04809d6175689477abfe21416f33e63cb177 | [
"MIT"
] | 1 | 2021-02-01T19:28:02.000Z | 2021-02-01T19:28:02.000Z | src/kernel/io/KPrintf.cpp | jameskingstonclarke/arctic | 6fec04809d6175689477abfe21416f33e63cb177 | [
"MIT"
] | 9 | 2021-02-07T15:46:11.000Z | 2021-02-18T08:25:42.000Z | src/kernel/io/KPrintf.cpp | jameskingstonclarke/arctic | 6fec04809d6175689477abfe21416f33e63cb177 | [
"MIT"
] | null | null | null | #include "KPrintf.h"
#include "../utils/Math.h"
#include "../Types.h"
#include "../driver/VGAGraphics.h"
#include "Serial.h"
namespace IO{
void kinfo(const char * info){
Driver::VGAGraphics::vga_driver.colour(Driver::VGAGraphics::vga_green);
kprintf("[INFO] ");
kprintf(info);
}
void kwarn(const char * warn){
Driver::VGAGraphics::vga_driver.colour(Driver::VGAGraphics::vga_red);
kprintf("[WARNING] ");
kprintf(warn);
}
void kerr(const char * err){
Driver::VGAGraphics::vga_driver.colour(Driver::VGAGraphics::vga_red);
kprintf("[ERROR] ");
kprintf(err);
}
void kprintf(const char * msg){
unsigned int j = 0;
/* this loop writes the string to video memory */
while(msg[j] != '\0') {
switch(msg[j]){
case '%':
{
switch(msg[j+1]){
case 'd': {
// print a decimal
}
default: {
kprint_c(msg[j]);
++j;
break;
};
}
}
default: {
kprint_c(msg[j]);
++j;
break;
}
}
}
}
void kprintf(String msg){
kprintf(msg.cstr());
}
void kprint_c(const char c){
switch(c){
default:{
Driver::VGAGraphics::vga_driver.putc(c);
}
}
}
void kprint_int(int i){
char buffer[50];
if(i==0){
buffer[0]='0';
buffer[1]='\0';
IO::kprint_str(buffer);
}
bool is_neg = i<0;
if(is_neg)i*=-1;
//!@TODO for integers larger than 10
int j =0;
while(i>0){
buffer[j]=(i%10)+'0';
i/=10;
j++;
}
if(is_neg) buffer[j++]='-';
buffer[j]='\0';
int start = 0;
int end = j-1;
while(start<end){
char a, b;
a = *(buffer+start);
b = *(buffer+end);
*(buffer+start)=b;
*(buffer+end)=a;
start++;
end--;
}
kprint_str(buffer);
}
void kprint_f(float f, int prescision){
// extract integer part
volatile s32 i_part = (s32)f;
// extraft float part
//float f_part = (float)f;
//kprint_int(i_part);
//kprint_c('.');
//kprint_int((int)(f_part*Utils::Math::pow(f_part, prescision)));
}
void kprint_str(const char * str){
for(int i = 0;str[i];i++)
kprint_c(str[i]);
}
} | 19.300885 | 74 | 0.538285 | jameskingstonclarke |
efd1f73832af8201c5c3a93fc34f1c6446bfe8ce | 752 | hpp | C++ | include/RED4ext/Types/generated/community/CommunityEntryPhaseTimePeriodData.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | 1 | 2021-02-01T23:07:50.000Z | 2021-02-01T23:07:50.000Z | include/RED4ext/Types/generated/community/CommunityEntryPhaseTimePeriodData.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | null | null | null | include/RED4ext/Types/generated/community/CommunityEntryPhaseTimePeriodData.hpp | Cyberpunk-Extended-Development-Team/RED4ext.SDK | 2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae | [
"MIT"
] | null | null | null | #pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/REDhash.hpp>
#include <RED4ext/CName.hpp>
#include <RED4ext/DynArray.hpp>
#include <RED4ext/Types/generated/world/GlobalNodeID.hpp>
namespace RED4ext
{
namespace community {
struct CommunityEntryPhaseTimePeriodData
{
static constexpr const char* NAME = "communityCommunityEntryPhaseTimePeriodData";
static constexpr const char* ALIAS = NAME;
CName periodName; // 00
DynArray<world::GlobalNodeID> spotNodeIds; // 08
bool isSequence; // 18
uint8_t unk19[0x20 - 0x19]; // 19
};
RED4EXT_ASSERT_SIZE(CommunityEntryPhaseTimePeriodData, 0x20);
} // namespace community
} // namespace RED4ext
| 26.857143 | 85 | 0.757979 | Cyberpunk-Extended-Development-Team |
efd409501cd105af4876885427bae9752ac9f537 | 2,329 | cpp | C++ | src/Crane.cpp | ithamsteri/towerblocks | 584c37e43dea91ffb789883e873884b9279e7dcb | [
"MIT"
] | null | null | null | src/Crane.cpp | ithamsteri/towerblocks | 584c37e43dea91ffb789883e873884b9279e7dcb | [
"MIT"
] | null | null | null | src/Crane.cpp | ithamsteri/towerblocks | 584c37e43dea91ffb789883e873884b9279e7dcb | [
"MIT"
] | null | null | null | #include "Crane.h"
#include "Resource.h"
#include <cmath>
spSprite
Crane::doThrowBlock()
{
if (_state != States::Working) {
return nullptr;
}
_block->detach();
_block->setPosition(_view->getPosition());
// return crane to base
auto t = _view->addTween(TweenDummy(), 50);
t->addEventListener(TweenEvent::DONE, [this](Event*) { moveToBase(); });
return _block;
}
void
Crane::start()
{
_state = States::FromBase;
_block = getNewBlock();
_block->attachTo(_view);
// reset all parameters for pendulum
_velocity = 0.0f;
_acceleration = 0.0f;
_angle = -0.5f * pi;
// TODO: "Don't Repeat Yourself (DRY)"
float x = _basePosition.x + std::sin(_angle) * _length;
float y = std::cos(_angle) * 0.5f * _length;
auto t = _view->addTween(Actor::TweenPosition(x, y), speedAnimation);
t->addEventListener(TweenEvent::DONE, [this](Event*) { _state = States::Working; });
}
void
Crane::stop()
{
_state = States::Stopped;
auto t = _view->addTween(Actor::TweenPosition(_basePosition), speedAnimation);
}
void
Crane::_init()
{
spSprite magnit = new Sprite;
magnit->setResAnim(res::ui.getResAnim("Game_CraneMagnet"));
magnit->setAnchor(0.5f, 1.0f);
magnit->attachTo(_view);
magnit->setPriority(50);
// save base position for crane
_basePosition = _view->getPosition();
// set length rope of crane
_length = _basePosition.x - _basePosition.x * 2 * 0.20f;
start();
}
void
Crane::_update(const UpdateState& us)
{
if (_state != States::Working) {
return;
}
// TODO: Make Oxygine Tween for pendulum move
_acceleration = gravity / _length * std::sin(_angle);
_velocity += _acceleration / us.dt * _speed;
_angle += _velocity / us.dt * _speed;
float x = _basePosition.x + std::sin(_angle) * _length;
float y = std::cos(_angle) * 0.5f * _length;
_view->setPosition(x, y);
}
void
Crane::moveToBase()
{
_state = States::ToBase;
auto t = _view->addTween(Actor::TweenPosition(_basePosition), speedAnimation);
t->addEventListener(TweenEvent::DONE, [this](Event*) { this->start(); });
}
spSprite
Crane::getNewBlock() const
{
int blockNum = static_cast<int>(scalar::randFloat(0.0f, 7.0f)) + 1;
auto block = new Sprite;
block->setResAnim(res::ui.getResAnim("Block" + std::to_string(blockNum)));
block->setAnchor(0.5f, 0.25f);
return block;
} | 22.180952 | 86 | 0.668957 | ithamsteri |
efd502b3ded485b3ba8eb91a2671450db283faa4 | 3,520 | cpp | C++ | tests/altium_crap/Soft Designs/C++/NB3000 C++ Tetris/Embedded/input.cpp | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | 1 | 2020-06-08T11:17:46.000Z | 2020-06-08T11:17:46.000Z | tests/altium_crap/Soft Designs/C++/NB3000 C++ Tetris/Embedded/input.cpp | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | null | null | null | tests/altium_crap/Soft Designs/C++/NB3000 C++ Tetris/Embedded/input.cpp | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
] | null | null | null | // Logger thread
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <mqueue.h>
#include "devices.h"
#include "drv_ioport.h"
#include "tetris.h"
Buttons::Buttons(const int id)
{
_port = ioport_open(BUTTONS);
for (int i = 0; i < BUTTON_COUNT; ++i)
{
_switchIsUp[i] = true;
_switchUpCount[i] = 0;
}
}
Buttons::button_kind_t Buttons::GetValue()
{
char buttons;
int i;
char button_value;
char result = 0;
buttons = ioport_get_value(_port, 0);
buttons = ~buttons & 0x1F;
for (i = 0; i < BUTTON_COUNT; i++)
{
// for each button, it registers an event when it first goes down,
// as long as it has been up DEBOUNCE times
button_value = (buttons >> i) & 0x01;
if (!button_value)
{
// button is up
_switchUpCount[i]++;
if (_switchUpCount[i] >= DEBOUNCE)
{
_switchIsUp[i] = true;
}
}
else
{
// button is down
_switchUpCount[i] = 0;
if (_switchIsUp[i])
{
result = result | (1 << i);
_switchIsUp[i] = false;
}
}
}
switch (result)
{
case 0x01: return BTN_LEFT;
case 0x02: return BTN_RIGHT;
case 0x04: return BTN_ROTATE;
case 0x08: return BTN_DROP;
case 0x10: return BTN_PAUSE;
}
return BTN_NONE;
}
InputThread::InputThread() : ThreadBase()
{
}
void InputThread::Setup()
{
struct sched_param schedparam;
// base setup function
ThreadBase::Setup();
// initialize pthread attributes
pthread_attr_init(& _attr);
pthread_attr_setinheritsched(& _attr, PTHREAD_EXPLICIT_SCHED);
// initialize scheduling priority
schedparam.sched_priority = INPUT_THREAD_PRIORITY;
pthread_attr_setschedparam(& _attr, & schedparam);
// initialize thread stack
pthread_attr_setstackaddr(& _attr, (void *) & _stack[0]);
pthread_attr_setstacksize(& _attr, sizeof(_stack));
}
void * InputThread::Execute(void * arg)
{
Buttons buttons(BUTTONS);
volatile int stop = 0;
TetrisGame * theGame;
mqd_t mq;
Buttons::button_kind_t kind;
theGame = (TetrisGame *) arg;
mq = theGame->GetSendQueue();
while (!stop)
{
kind = buttons.GetValue();
// stroke actions
if (StrokeAction(theGame, kind) == false)
{
// send exit msg to logger
#define ENDED_BY_USER "\n ended by user"
mq_send(mq, ENDED_BY_USER, sizeof(ENDED_BY_USER) - 1, MSG_EXIT);
}
}
return NULL;
}
bool InputThread::StrokeAction(TetrisGame * theGame, Buttons::button_kind_t kind)
{
switch (kind)
{
case Buttons::BTN_LEFT:
theGame->GetTetrisThread().Kill(SIGBUTTON1);
break;
case Buttons::BTN_RIGHT:
theGame->GetTetrisThread().Kill(SIGBUTTON2);
break;
case Buttons::BTN_ROTATE:
theGame->GetTetrisThread().Kill(SIGBUTTON3);
break;
case Buttons::BTN_DROP:
theGame->GetTetrisThread().Kill(SIGBUTTON4);
break;
case Buttons::BTN_PAUSE:
theGame->GetTetrisThread().Kill(SIGBUTTON5);
break;
default:
break;
}
return true;
}
| 22.709677 | 81 | 0.552841 | hanun2999 |
efdcd15d96899c50a32173b6c3761e27d4a3bf75 | 8,702 | hpp | C++ | src/Providers/UNIXProviders/BlockStatisticsManifest/UNIX_BlockStatisticsManifest_AIX.hpp | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | 1 | 2020-10-12T09:00:09.000Z | 2020-10-12T09:00:09.000Z | src/Providers/UNIXProviders/BlockStatisticsManifest/UNIX_BlockStatisticsManifest_ZOS.hpp | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | null | null | null | src/Providers/UNIXProviders/BlockStatisticsManifest/UNIX_BlockStatisticsManifest_ZOS.hpp | brunolauze/openpegasus-providers-old | b00f1aad575bae144b8538bf57ba5fd5582a4ec7 | [
"MIT"
] | null | null | null | //%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////
//
//%/////////////////////////////////////////////////////////////////////////
UNIX_BlockStatisticsManifest::UNIX_BlockStatisticsManifest(void)
{
}
UNIX_BlockStatisticsManifest::~UNIX_BlockStatisticsManifest(void)
{
}
Boolean UNIX_BlockStatisticsManifest::getInstanceID(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INSTANCE_ID, getInstanceID());
return true;
}
String UNIX_BlockStatisticsManifest::getInstanceID() const
{
return String ("");
}
Boolean UNIX_BlockStatisticsManifest::getCaption(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_CAPTION, getCaption());
return true;
}
String UNIX_BlockStatisticsManifest::getCaption() const
{
return String ("");
}
Boolean UNIX_BlockStatisticsManifest::getDescription(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_DESCRIPTION, getDescription());
return true;
}
String UNIX_BlockStatisticsManifest::getDescription() const
{
return String ("");
}
Boolean UNIX_BlockStatisticsManifest::getElementName(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_ELEMENT_NAME, getElementName());
return true;
}
String UNIX_BlockStatisticsManifest::getElementName() const
{
return String("BlockStatisticsManifest");
}
Boolean UNIX_BlockStatisticsManifest::getElementType(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_ELEMENT_TYPE, getElementType());
return true;
}
Uint16 UNIX_BlockStatisticsManifest::getElementType() const
{
return Uint16(0);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeStartStatisticTime(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_START_STATISTIC_TIME, getIncludeStartStatisticTime());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeStartStatisticTime() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeStatisticTime(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_STATISTIC_TIME, getIncludeStatisticTime());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeStatisticTime() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOs(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_TOTAL_I_OS, getIncludeTotalIOs());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOs() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferred(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_TRANSFERRED, getIncludeKBytesTransferred());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferred() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeIOTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_I_O_TIME_COUNTER, getIncludeIOTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeIOTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOs(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_READ_I_OS, getIncludeReadIOs());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOs() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOs(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_READ_HIT_I_OS, getIncludeReadHitIOs());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOs() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_READ_I_O_TIME_COUNTER, getIncludeReadIOTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_READ_HIT_I_O_TIME_COUNTER, getIncludeReadHitIOTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesRead(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_READ, getIncludeKBytesRead());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesRead() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOs(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_WRITE_I_OS, getIncludeWriteIOs());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOs() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOs(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_WRITE_HIT_I_OS, getIncludeWriteHitIOs());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOs() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_WRITE_I_O_TIME_COUNTER, getIncludeWriteIOTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_WRITE_HIT_I_O_TIME_COUNTER, getIncludeWriteHitIOTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWritten(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_WRITTEN, getIncludeKBytesWritten());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWritten() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeIdleTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_IDLE_TIME_COUNTER, getIncludeIdleTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeIdleTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOp(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_MAINT_OP, getIncludeMaintOp());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOp() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::getIncludeMaintTimeCounter(CIMProperty &p) const
{
p = CIMProperty(PROPERTY_INCLUDE_MAINT_TIME_COUNTER, getIncludeMaintTimeCounter());
return true;
}
Boolean UNIX_BlockStatisticsManifest::getIncludeMaintTimeCounter() const
{
return Boolean(false);
}
Boolean UNIX_BlockStatisticsManifest::initialize()
{
return false;
}
Boolean UNIX_BlockStatisticsManifest::load(int &pIndex)
{
return false;
}
Boolean UNIX_BlockStatisticsManifest::finalize()
{
return false;
}
Boolean UNIX_BlockStatisticsManifest::find(Array<CIMKeyBinding> &kbArray)
{
CIMKeyBinding kb;
String instanceIDKey;
for(Uint32 i = 0; i < kbArray.size(); i++)
{
kb = kbArray[i];
CIMName keyName = kb.getName();
if (keyName.equal(PROPERTY_INSTANCE_ID)) instanceIDKey = kb.getValue();
}
/* EXecute find with extracted keys */
return false;
}
| 26.29003 | 97 | 0.78729 | brunolauze |
efe0371b0fc4ddd4c1bde0c167444d0d3a5643d1 | 1,589 | hpp | C++ | kernel/include/Sigma/types/hash_map.hpp | thomtl/Sigma | 30da9446a1f1b5cae4eff77bf9917fae1446ce85 | [
"BSD-2-Clause"
] | 46 | 2019-09-30T18:40:06.000Z | 2022-02-20T12:54:59.000Z | kernel/include/Sigma/types/hash_map.hpp | thomtl/Sigma | 30da9446a1f1b5cae4eff77bf9917fae1446ce85 | [
"BSD-2-Clause"
] | 11 | 2019-08-18T18:31:11.000Z | 2021-09-14T22:34:16.000Z | kernel/include/Sigma/types/hash_map.hpp | thomtl/Sigma | 30da9446a1f1b5cae4eff77bf9917fae1446ce85 | [
"BSD-2-Clause"
] | 1 | 2020-01-20T16:55:13.000Z | 2020-01-20T16:55:13.000Z | #ifndef SIGMA_TYPES_HASH_MAP_H
#define SIGMA_TYPES_HASH_MAP_H
#include <Sigma/common.h>
#include <Sigma/types/linked_list.h>
#include <klibcxx/utility.hpp>
#include <Sigma/arch/x86_64/misc/spinlock.h>
namespace types
{
template<typename T>
struct nop_hasher {
using hash_result = T;
hash_result operator()(T item){
return item;
}
};
// TODO: Seriously, this is the best hash_map you can think of, just, make something doable, not this monstrosity
template<typename Key, typename Value, typename Hasher>
class hash_map {
public:
hash_map() = default;
hash_map(hash_map&& other){
this->list = std::move(other.list);
this->hasher = std::move(other.hasher);
}
hash_map& operator=(hash_map&& other){
this->list = std::move(other.list);
this->hasher = std::move(other.hasher);
return *this;
}
void push_back(Key key, Value value){
auto hash = this->hasher(key);
this->list.push_back({hash, value});
}
Value& operator[](Key key){
auto hash = this->hasher(key);
for(auto& entry : list)
if(entry.first == hash)
return entry.second;
PANIC("Hash not in map");
while(1)
;
}
private:
using entry = std::pair<typename Hasher::hash_result, Value>;
types::linked_list<entry> list;
Hasher hasher;
};
} // namespace types
#endif | 24.446154 | 117 | 0.56073 | thomtl |
efe16d7cfa75b0fb9545eab906506513fb6c1f5f | 19,369 | cpp | C++ | src/drivers/common/driver_base.cpp | Dwedit/sdlretro | 521c5558cb55d4028210529e336d8a8622037358 | [
"MIT"
] | null | null | null | src/drivers/common/driver_base.cpp | Dwedit/sdlretro | 521c5558cb55d4028210529e336d8a8622037358 | [
"MIT"
] | null | null | null | src/drivers/common/driver_base.cpp | Dwedit/sdlretro | 521c5558cb55d4028210529e336d8a8622037358 | [
"MIT"
] | null | null | null | #include "driver_base.h"
#include "logger.h"
#include "cfg.h"
#include "video_base.h"
#include "buffered_audio.h"
#include "input_base.h"
#include "throttle.h"
#include "util.h"
#include <variables.h>
#include <core.h>
#include <cstring>
#include <cmath>
#include <memory>
#include <fstream>
namespace libretro {
extern struct retro_vfs_interface vfs_interface;
}
namespace drivers {
#ifdef _WIN32
#define PATH_SEPARATOR_CHAR "\\"
#else
#define PATH_SEPARATOR_CHAR "/"
#endif
inline void lowered_string(std::string &s) {
for (char &c: s) {
if (c <= ' ' || c == '\\' || c == '/' || c == ':' || c == '*' || c == '"' || c == '<' || c == '>' || c == '|')
c = '_';
else
c = std::tolower(c);
}
}
inline std::string get_base_name(const std::string &path) {
std::string basename = path;
auto pos = basename.find_last_of("/\\");
if (pos != std::string::npos) {
basename = basename.substr(pos + 1);
}
pos = basename.find_last_of('.');
if (pos != std::string::npos)
basename.erase(pos);
return basename;
}
driver_base *current_driver = nullptr;
driver_base::driver_base() {
frame_throttle = std::make_shared<throttle>();
variables = std::make_unique<libretro::retro_variables>();
}
driver_base::~driver_base() {
deinit_internal();
if (core) {
core_unload(core);
core = nullptr;
}
current_driver = nullptr;
}
void driver_base::set_dirs(const std::string &static_root, const std::string &config_root) {
static_dir = static_root;
config_dir = config_root;
system_dir = config_root + PATH_SEPARATOR_CHAR "system";
util_mkdir(system_dir.c_str());
save_dir = config_root + PATH_SEPARATOR_CHAR "saves";
util_mkdir(save_dir.c_str());
}
void driver_base::run(std::function<void()> in_game_menu_cb) {
while (!shutdown_driver && run_frame(in_game_menu_cb, video->frame_drawn())) {
auto check = g_cfg.get_save_check();
if (check) {
if (!save_check_countdown) {
check_save_ram();
save_check_countdown = lround(check * fps);
} else {
save_check_countdown--;
}
}
core->retro_run();
video->message_frame_pass();
}
}
bool RETRO_CALLCONV retro_environment_cb(unsigned cmd, void *data) {
if (!current_driver) return false;
return current_driver->env_callback(cmd, data);
}
void RETRO_CALLCONV log_printf(enum retro_log_level level, const char *fmt, ...) {
#if defined(NDEBUG) || !defined(LIBRETRO_DEBUG_LOG)
if (level >= RETRO_LOG_DEBUG)
return;
#endif
va_list l;
va_start(l, fmt);
log_vprintf((int)level, fmt, l);
va_end(l);
}
static void RETRO_CALLCONV retro_video_refresh_cb(const void *data, unsigned width, unsigned height, size_t pitch) {
if (!data) return;
current_driver->get_video()->render(data, width, height, pitch);
}
static void RETRO_CALLCONV retro_audio_sample_cb(int16_t left, int16_t right) {
int16_t samples[2] = {left, right};
current_driver->get_audio()->write_samples(samples, 2);
}
static size_t RETRO_CALLCONV retro_audio_sample_batch_cb(const int16_t *data, size_t frames) {
current_driver->get_audio()->write_samples(data, frames * 2);
return frames;
}
static void RETRO_CALLCONV retro_input_poll_cb() {
current_driver->get_input()->input_poll();
}
static int16_t RETRO_CALLCONV retro_input_state_cb(unsigned port, unsigned device, unsigned index, unsigned id) {
return current_driver->get_input()->input_state(port, device, index, id);
}
static bool RETRO_CALLCONV retro_set_rumble_state_cb(unsigned port, enum retro_rumble_effect effect, uint16_t strength) {
return false;
}
inline bool read_file(const std::string filename, std::vector<uint8_t> &data) {
std::ifstream ifs(filename, std::ios_base::binary | std::ios_base::in);
if (!ifs.good()) return false;
ifs.seekg(0, std::ios_base::end);
size_t sz = ifs.tellg();
if (!sz) {
ifs.close();
return false;
}
data.resize(sz);
ifs.seekg(0, std::ios_base::beg);
ifs.read((char *)data.data(), sz);
ifs.close();
return true;
}
bool driver_base::load_game(const std::string &path) {
retro_game_info info = {};
info.path = path.c_str();
if (!need_fullpath) {
std::ifstream ifs(path, std::ios_base::binary | std::ios_base::in);
if (!ifs.good()) {
logger(LOG_ERROR) << "Unable to load " << path << std::endl;
return false;
}
ifs.seekg(0, std::ios_base::end);
game_data.resize(ifs.tellg());
ifs.seekg(0, std::ios_base::beg);
ifs.read(&game_data[0], game_data.size());
ifs.close();
info.data = &game_data[0];
info.size = game_data.size();
}
if (!core->retro_load_game(&info)) {
logger(LOG_ERROR) << "Unable to load " << path << std::endl;
return false;
}
game_path = path;
post_load();
return true;
}
bool driver_base::load_game_from_mem(const std::string &path, const std::string ext, const std::vector<uint8_t> &data) {
retro_game_info info = {};
if (!need_fullpath) {
game_data.assign(data.begin(), data.end());
info.path = path.c_str();
info.data = &game_data[0];
info.size = game_data.size();
} else {
std::string basename = get_base_name(path);
temp_file = config_dir + PATH_SEPARATOR_CHAR "tmp";
util_mkdir(temp_file.c_str());
temp_file = temp_file + PATH_SEPARATOR_CHAR + basename + "." + ext;
std::ofstream ofs(temp_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
if (!ofs.good()) return false;
ofs.write((const char*)&data[0], data.size());
if (ofs.bad()) {
ofs.close();
remove(temp_file.c_str());
return false;
}
ofs.close();
info.path = temp_file.c_str();
}
if (!core->retro_load_game(&info)) {
logger(LOG_ERROR) << "Unable to load " << path << std::endl;
return false;
}
game_path = path;
post_load();
return true;
}
void driver_base::unload_game() {
shutdown_driver = false;
check_save_ram();
game_path.clear();
game_base_name.clear();
game_save_path.clear();
game_rtc_path.clear();
save_data.clear();
rtc_data.clear();
core->retro_unload_game();
audio->stop();
unload();
if (!temp_file.empty()) {
remove(temp_file.c_str());
temp_file.clear();
}
}
void driver_base::reset() {
core->retro_reset();
}
bool driver_base::env_callback(unsigned cmd, void *data) {
switch (cmd) {
case RETRO_ENVIRONMENT_SET_ROTATION:
break;
case RETRO_ENVIRONMENT_GET_OVERSCAN:
*(bool*)data = false;
return true;
case RETRO_ENVIRONMENT_GET_CAN_DUPE:
*(bool*)data = true;
return true;
case RETRO_ENVIRONMENT_SET_MESSAGE: {
const auto *msg = (const retro_message*)data;
video->set_message(msg->msg, msg->frames);
return true;
}
case RETRO_ENVIRONMENT_SHUTDOWN:
shutdown_driver = true;
return true;
case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL:
return true;
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
*(const char**)data = system_dir.c_str();
return true;
case RETRO_ENVIRONMENT_SET_PIXEL_FORMAT: {
auto new_format = (unsigned)*(const enum retro_pixel_format *)data;
if (new_format != pixel_format) {
pixel_format = new_format;
video->resolution_changed(base_width, base_height, pixel_format == RETRO_PIXEL_FORMAT_XRGB8888 ? 32 : 16);
}
return true;
}
case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS: {
const auto *inp = (const retro_input_descriptor*)data;
while (inp->description != nullptr) {
input->add_button(inp->port, inp->device, inp->index, inp->id, inp->description);
++inp;
}
return true;
}
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
case RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE:
case RETRO_ENVIRONMENT_SET_HW_RENDER:
break;
case RETRO_ENVIRONMENT_GET_VARIABLE: {
variables->set_variables_updated(false);
auto *var = (retro_variable *)data;
auto *vari = variables->get_variable(var->key);
if (vari) {
var->value = vari->options[vari->curr_index].first.c_str();
return true;
}
return false;
}
case RETRO_ENVIRONMENT_SET_VARIABLES: {
const auto *vars = (const retro_variable*)data;
variables->load_variables(vars);
variables->load_variables_from_cfg(core_cfg_path);
return true;
}
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE:
*(bool*)data = variables->get_variables_updated();
return true;
case RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME:
support_no_game = *(bool*)data;
return true;
case RETRO_ENVIRONMENT_GET_LIBRETRO_PATH:
*(const char**)data = nullptr;
return true;
case RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK:
case RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK:
break;
case RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE: {
auto *ri = (retro_rumble_interface*)data;
ri->set_rumble_state = retro_set_rumble_state_cb;
return true;
}
case RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES:
*(uint64_t*)data = (1ULL << RETRO_DEVICE_JOYPAD) | (1ULL << RETRO_DEVICE_ANALOG);
return true;
case RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE:
case RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE:
break;
case RETRO_ENVIRONMENT_GET_LOG_INTERFACE: {
((retro_log_callback*)data)->log = log_printf;
return true;
}
case RETRO_ENVIRONMENT_GET_PERF_INTERFACE:
case RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE:
case RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY:
break;
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
*(const char**)data = core_save_dir.empty() ? nullptr : core_save_dir.c_str();
return true;
case RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO:
case RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK:
case RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO:
break;
case RETRO_ENVIRONMENT_SET_CONTROLLER_INFO: {
const auto *info = (const retro_controller_info*)data;
return true;
}
case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: {
const auto *memmap = (const retro_memory_map*)data;
for (unsigned i = 0; i < memmap->num_descriptors; ++i) {
/* TODO: store info of memory map for future use */
}
return true;
}
case RETRO_ENVIRONMENT_SET_GEOMETRY: {
const auto *geometry = (const retro_game_geometry*)data;
base_width = geometry->base_width;
base_height = geometry->base_height;
max_width = geometry->max_width;
max_height = geometry->max_height;
aspect_ratio = geometry->aspect_ratio;
video->resolution_changed(base_width, base_height, pixel_format == RETRO_PIXEL_FORMAT_XRGB8888 ? 32 : 16);
return true;
}
case RETRO_ENVIRONMENT_GET_USERNAME:
*(const char**)data = "sdlretro";
return true;
case RETRO_ENVIRONMENT_GET_LANGUAGE:
*(unsigned*)data = RETRO_LANGUAGE_ENGLISH;
return true;
case RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER:
/*
{
auto *fb = (retro_framebuffer*)data;
fb->data = video->get_framebuffer(&fb->width, &fb->height, &fb->pitch, (int*)&fb->format);
if (fb->data)
return true;
}
*/
return false;
case RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE:
break;
case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS:
support_achivements = data ? *(bool*)data : true;
return true;
case RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE:
case RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS:
case RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT:
break;
case RETRO_ENVIRONMENT_GET_VFS_INTERFACE: {
auto *info = (struct retro_vfs_interface_info *)data;
if (info->required_interface_version > 3) return false;
info->iface = &libretro::vfs_interface;
return true;
}
case RETRO_ENVIRONMENT_GET_LED_INTERFACE:
case RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE:
case RETRO_ENVIRONMENT_GET_MIDI_INTERFACE:
case RETRO_ENVIRONMENT_GET_FASTFORWARDING:
case RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE:
break;
case RETRO_ENVIRONMENT_GET_INPUT_BITMASKS:
if (data) *(bool*)data = true;
return true;
case RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION:
*(unsigned*)data = RETRO_API_VERSION;
return true;
case RETRO_ENVIRONMENT_SET_CORE_OPTIONS: {
variables->load_variables((const retro_core_option_definition*)data);
variables->load_variables_from_cfg(core_cfg_path);
return true;
}
case RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL: {
variables->load_variables(((const retro_core_options_intl*)data)->us);
variables->load_variables_from_cfg(core_cfg_path);
return true;
}
case RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY: {
const auto *opt = (const retro_core_option_display*)data;
variables->set_variable_visible(opt->key, opt->visible);
return true;
}
case RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER:
default:
break;
}
if (cmd & RETRO_ENVIRONMENT_EXPERIMENTAL) {
logger(LOG_INFO) << "Unhandled env: " << (cmd & 0xFFFFU) << "(EXPERIMENTAL)" << std::endl;
} else {
logger(LOG_INFO) << "Unhandled env: " << cmd << std::endl;
}
return false;
}
void driver_base::save_variables_to_cfg() {
variables->save_variables_to_cfg(core_cfg_path);
}
bool driver_base::load_core(const std::string &path) {
core = core_load(path.c_str());
if (!core) return false;
current_driver = this;
core_cfg_path = config_dir + PATH_SEPARATOR_CHAR + "cfg";
util_mkdir(core_cfg_path.c_str());
retro_system_info sysinfo = {};
core->retro_get_system_info(&sysinfo);
library_name = sysinfo.library_name;
library_version = sysinfo.library_version;
need_fullpath = sysinfo.need_fullpath;
std::string name = sysinfo.library_name;
lowered_string(name);
core_cfg_path = core_cfg_path + PATH_SEPARATOR_CHAR + name + ".cfg";
core_save_dir = save_dir + PATH_SEPARATOR_CHAR + name;
util_mkdir(core_save_dir.c_str());
init_internal();
return true;
}
bool driver_base::init_internal() {
if (inited) return true;
if (!init()) {
return false;
}
shutdown_driver = false;
core->retro_set_environment(retro_environment_cb);
core->retro_init();
core->retro_set_video_refresh(retro_video_refresh_cb);
core->retro_set_audio_sample(retro_audio_sample_cb);
core->retro_set_audio_sample_batch(retro_audio_sample_batch_cb);
core->retro_set_input_poll(retro_input_poll_cb);
core->retro_set_input_state(retro_input_state_cb);
inited = true;
return true;
}
void driver_base::deinit_internal() {
if (!inited) return;
core->retro_deinit();
/* reset all variables to default value */
library_name.clear();
library_version.clear();
need_fullpath = false;
pixel_format = 0;
support_no_game = false;
base_width = 0;
base_height = 0;
max_width = 0;
max_height = 0;
aspect_ratio = 0.f;
game_data.clear();
variables->reset();
inited = false;
}
void driver_base::check_save_ram() {
// TODO: use progressive check for large sram?
size_t sram_size = core->retro_get_memory_size(RETRO_MEMORY_SAVE_RAM);
if (sram_size) {
void *sram = core->retro_get_memory_data(RETRO_MEMORY_SAVE_RAM);
if (sram_size != save_data.size() || memcmp(sram, save_data.data(), sram_size) != 0) {
std::ofstream ofs(game_save_path, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
ofs.write((const char*)sram, sram_size);
ofs.close();
save_data.assign((uint8_t*)sram, (uint8_t*)sram + sram_size);
}
}
size_t rtc_size = core->retro_get_memory_size(RETRO_MEMORY_RTC);
if (rtc_size) {
void *rtc = core->retro_get_memory_data(RETRO_MEMORY_RTC);
if (rtc_size != rtc_data.size() || memcmp(rtc, rtc_data.data(), rtc_size) != 0) {
std::ofstream ofs(game_rtc_path, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
ofs.write((const char*)rtc, rtc_size);
ofs.close();
rtc_data.assign((uint8_t*)rtc, (uint8_t*)rtc + rtc_size);
}
}
}
void driver_base::post_load() {
game_base_name = get_base_name(game_path);
game_save_path = (core_save_dir.empty() ? "" : (core_save_dir + PATH_SEPARATOR_CHAR)) + game_base_name + ".sav";
game_rtc_path = (core_save_dir.empty() ? "" : (core_save_dir + PATH_SEPARATOR_CHAR)) + game_base_name + ".rtc";
read_file(game_save_path, save_data);
read_file(game_rtc_path, rtc_data);
if (!save_data.empty()) {
size_t sz = core->retro_get_memory_size(RETRO_MEMORY_SAVE_RAM);
if (sz > save_data.size()) sz = save_data.size();
if (sz) memcpy(core->retro_get_memory_data(RETRO_MEMORY_SAVE_RAM), save_data.data(), sz);
}
if (!rtc_data.empty()) {
size_t sz = core->retro_get_memory_size(RETRO_MEMORY_RTC);
if (sz > rtc_data.size()) sz = rtc_data.size();
if (sz) memcpy(core->retro_get_memory_data(RETRO_MEMORY_RTC), rtc_data.data(), sz);
}
retro_system_av_info av_info = {};
core->retro_get_system_av_info(&av_info);
base_width = av_info.geometry.base_width;
base_height = av_info.geometry.base_height;
max_width = av_info.geometry.max_width;
max_height = av_info.geometry.max_height;
aspect_ratio = av_info.geometry.aspect_ratio;
fps = av_info.timing.fps;
audio->start(g_cfg.get_mono_audio(), av_info.timing.sample_rate, g_cfg.get_sample_rate(), av_info.timing.fps);
frame_throttle->reset(fps);
core->retro_set_controller_port_device(0, RETRO_DEVICE_JOYPAD);
video->resolution_changed(base_width, base_height, pixel_format == RETRO_PIXEL_FORMAT_XRGB8888 ? 32 : 16);
char library_message[256];
snprintf(library_message, 256, "Loaded core: %s", library_name.c_str());
video->set_message(library_message, lround(fps * 5));
}
}
| 34.403197 | 122 | 0.634674 | Dwedit |
efe23776cdeb4c1b4199c11404b11748f3439077 | 4,835 | cpp | C++ | libs/evolvo/test/tests.cpp | rufus-stone/genetic-algo-cpp | 5e31f080d30ffc204fa7891883703183302b2954 | [
"MIT"
] | null | null | null | libs/evolvo/test/tests.cpp | rufus-stone/genetic-algo-cpp | 5e31f080d30ffc204fa7891883703183302b2954 | [
"MIT"
] | null | null | null | libs/evolvo/test/tests.cpp | rufus-stone/genetic-algo-cpp | 5e31f080d30ffc204fa7891883703183302b2954 | [
"MIT"
] | null | null | null | #include "evolvo/chromosome.hpp"
#include "evolvo/crossover.hpp"
#include "evolvo/individual.hpp"
#include "evolvo/population.hpp"
#include "evolvo/selection.hpp"
#define CATCH_CONFIG_MAIN // This tells the Catch2 header to generate a main
#include "catch.hpp"
#include <random>
#include <vector>
#include <map>
#include <spdlog/spdlog.h>
#include <evolvo/ga.hpp>
////////////////////////////////////////////////////////////////
TEST_CASE("Chromosome", "[ga][chromosome]")
{
auto const chromo = ga::Chromosome{{1.1, 2.0, -3.3, 4.6}};
REQUIRE_THAT(chromo, Catch::Matchers::Approx(std::vector<double>{1.1, 2.0, -3.3, 4.6}));
REQUIRE(chromo[0] == Approx(1.1));
REQUIRE(chromo.size() == 4);
}
////////////////////////////////////////////////////////////////
TEST_CASE("Individual", "[ga][individual]")
{
// Create a Chromosome and a fitness
auto const chromo = ga::Chromosome{{1.1, 2.0, -3.3, 4.6}};
double const fitness = 1.0;
// Create a new Individual from the Chromosome
auto const individual1 = ga::Individual{chromo};
// Check that it was created correctly
REQUIRE(individual1.chromosome() == chromo);
REQUIRE_THAT(individual1.chromosome(), Catch::Matchers::Approx(std::vector<double>{1.1, 2.0, -3.3, 4.6}));
REQUIRE(individual1.fitness() == 0.0);
// Create a new Individual from the fitness
auto const individual2 = ga::Individual{fitness};
// Check that it was created correctly
REQUIRE(individual2.chromosome().empty() == true);
REQUIRE(individual2.fitness() == 1.0);
// Create a new Individual from the Chromosome and the fitness
auto const individual3 = ga::Individual{chromo, fitness};
// Check that it was created correctly
REQUIRE(individual3.chromosome() == chromo);
REQUIRE_THAT(individual3.chromosome(), Catch::Matchers::Approx(std::vector<double>{1.1, 2.0, -3.3, 4.6}));
REQUIRE(individual3.fitness() == 1.0);
}
////////////////////////////////////////////////////////////////
TEST_CASE("Selection", "[ga][individual]")
{
// Seed an mt19937 prng for a predictable "random" number to use for testing
auto prng = std::mt19937{42};
// Create a RouletteWheelSelection SelectionMethod
auto roulette_wheel = ga::RouletteWheelSelection{};
// Create a new Population from a collection of Individuals with the specified fitnesses to ride the wheel
auto const population = ga::Population{{ga::Individual{2.0}, ga::Individual{1.0}, ga::Individual{4.0}, ga::Individual{3.0}}};
// Spin the wheel 1000 times and see how many times each individual is chosen
auto results = std::map<int, int>{};
constexpr std::size_t spins = 1000;
for (std::size_t i = 0; i < spins; ++i)
{
std::size_t const choice = roulette_wheel.select(prng, population);
// Make a note of the fitness that was chosen
auto fitness = static_cast<std::size_t>(population[choice].fitness());
results[fitness] += 1;
}
for (auto const &[fitness, times_chosen] : results)
{
spdlog::info("Individual with fitness score {} chosen {} of 1000 times ({:.2f}%)", fitness, times_chosen, (static_cast<double>(times_chosen) / spins) * 100);
}
// Given the specified Population and their fitness scores, after 1000 spins of the wheel we expect the each Individual to have been selected the following number of times based on their fitness scores
auto const expected = std::map<int, int>{{1, 104}, {2, 176}, {3, 294}, {4, 426}};
// Check that the results matched what we expected
REQUIRE(results == expected);
}
////////////////////////////////////////////////////////////////
TEST_CASE("Crossover", "[ga][crossover]")
{
// Seed an mt19937 prng for a predictable "random" number to use for testing
auto prng = std::mt19937{42};
// Create a UniformCrossover CrossoverMethod
auto uniform_crossover = ga::UniformCrossover{};
// Create a pair of Chromosomes to use as parents
auto parent_a = ga::Chromosome{{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}};
auto parent_b = ga::Chromosome{{-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0}};
// Create a child by using the UniformCrossover method
auto child = uniform_crossover.crossover(prng, parent_a, parent_b);
// A UniformCrossover has an even 50/50 chance that a gene will come from either parent
auto const expected = ga::Chromosome{{-1.0, 2.0, 3.0, -4.0, 5.0, 6.0, 7.0, 8.0, -9.0, -10.0}};
// Check that the results matched what we expected
REQUIRE(child == expected);
}
////////////////////////////////////////////////////////////////
TEST_CASE("Genetic Algorithm", "[ga][genetic_algorithm]")
{
auto selection_method = std::make_unique<ga::RouletteWheelSelection>();
auto crossover_method = std::make_unique<ga::UniformCrossover>();
auto ga = ga::GeneticAlgorithm{std::move(selection_method), std::move(crossover_method)};
REQUIRE(1 == 1);
}
| 36.908397 | 203 | 0.64757 | rufus-stone |
efe5281be27fba8ce55da7b1321e1d3fdd27f082 | 9,860 | hpp | C++ | naos/includes/kernel/util/str.hpp | kadds/NaOS | ea5eeed6f777b8f62acf3400b185c94131b6e1f0 | [
"BSD-3-Clause"
] | 14 | 2020-02-12T11:07:58.000Z | 2022-02-02T00:05:08.000Z | naos/includes/kernel/util/str.hpp | kadds/NaOS | ea5eeed6f777b8f62acf3400b185c94131b6e1f0 | [
"BSD-3-Clause"
] | null | null | null | naos/includes/kernel/util/str.hpp | kadds/NaOS | ea5eeed6f777b8f62acf3400b185c94131b6e1f0 | [
"BSD-3-Clause"
] | 4 | 2020-02-27T09:53:53.000Z | 2021-11-07T17:43:44.000Z | #pragma once
#include "array.hpp"
#include "assert.hpp"
#include "common.hpp"
#include "hash.hpp"
#include "iterator.hpp"
#include "kernel/mm/allocator.hpp"
#include "formatter.hpp"
#include "memory.hpp"
#include <utility>
namespace util
{
/// \brief compair two string
/// \return 0 if equal
int strcmp(const char *str1, const char *str2);
/// \brief copy src to dst (include \\0) same as 'strcopy(char *, const char *)'
i64 strcopy(char *dst, const char *src, i64 max_len);
/// \brief copy src to dst (include \\0)
/// \param dst copy to
/// \param src copy from
/// \return copy char count (not include \\0)
i64 strcopy(char *dst, const char *src);
/// \brief get string length (not include \\0)
i64 strlen(const char *str);
/// \brief find substring in str
/// \return -1 if not found
i64 strfind(const char *str, const char *pat);
class string;
template <typename CE> class base_string_view
{
private:
struct value_fn
{
CE operator()(CE val) { return val; }
};
struct prev_fn
{
CE operator()(CE val) { return val - 1; }
};
struct next_fn
{
CE operator()(CE val) { return val + 1; }
};
public:
using iterator = base_bidirectional_iterator<CE, value_fn, prev_fn, next_fn>;
base_string_view()
: ptr(nullptr)
, len(0)
{
}
base_string_view(CE ptr, u64 len)
: ptr(ptr)
, len(len)
{
}
CE data() {
return ptr;
}
string to_string(memory::IAllocator *allocator);
iterator begin() { return iterator(ptr); }
iterator end() { return iterator(ptr + len); }
bool to_int(i64 &out) const
{
const char *beg = ptr;
const char *end = ptr + len;
return formatter::str2int(beg, end, out) != beg;
}
bool to_uint(u64 &out) const {
const char *beg = ptr;
const char *end = ptr + len;
return formatter::str2uint(beg, end, out) != beg;
}
bool to_int_ext(i64 &out, base_string_view &last) const {
CE beg = ptr;
CE end = ptr + len;
beg = formatter::str2int(beg, end, out);
last = base_string_view(beg, len - (beg - ptr));
return beg != ptr;
}
bool to_uint_ext(u64 &out, base_string_view &last) const {
CE beg = ptr;
CE end = ptr + len;
beg = const_cast<CE>(formatter::str2uint(beg, end, out));
last = base_string_view(beg, len - (beg - ptr));
return beg != ptr;
}
void split2(base_string_view &v0, base_string_view &v1, iterator iter)
{
v0 = base_string_view(ptr, iter.get() - ptr);
v1 = base_string_view(iter.get() + 1, len - (iter.get() - ptr));
}
array<base_string_view<CE>> split(char c, memory::IAllocator *vec_allocator)
{
array<base_string_view<CE>> vec(vec_allocator);
CE p = ptr;
CE prev = p;
for (u64 i = 0; i < len; i++)
{
if (*p == c)
{
if (prev < p)
{
vec.push_back(base_string_view<CE>(prev, p - prev));
}
prev = p + 1;
}
p++;
}
if (prev < p)
{
vec.push_back(base_string_view<CE>(prev, p - prev));
}
return vec;
}
private:
CE ptr;
u64 len;
};
using string_view = base_string_view<char *>;
using const_string_view = base_string_view<const char *>;
/// \brief kernel string type, use it everywhere
///
class string
{
private:
template <typename N> struct value_fn
{
N operator()(N val) { return val; }
};
template <typename N> struct prev_fn
{
N operator()(N val) { return val - 1; }
};
template <typename N> struct next_fn
{
N operator()(N val) { return val + 1; }
};
using CE = const char *;
using NE = char *;
public:
using const_iterator = base_bidirectional_iterator<CE, value_fn<CE>, prev_fn<CE>, next_fn<CE>>;
using iterator = base_bidirectional_iterator<NE, value_fn<NE>, prev_fn<NE>, next_fn<NE>>;
string(const string &rhs) { copy(rhs); }
string(string &&rhs) { move(std::move(rhs)); }
///\brief init empty string ""
string(memory::IAllocator *allocator);
///\brief init from char array
/// no_shared
string(memory::IAllocator *allocator, const char *str, i64 len = -1) { init(allocator, str, len); }
///\brief init from char array lit
/// readonly & shared
string(const char *str) { init_lit(str); }
~string() { free(); }
string &operator=(const string &rhs);
string &operator=(string &&rhs);
u64 size() const { return get_count(); }
u64 capacity() const
{
if (likely(is_sso()))
{
return stack.get_cap();
}
else
{
return head.get_cap();
}
}
u64 hash() const { return murmur_hash2_64(data(), get_count(), 0); }
iterator begin() { return iterator(data()); }
iterator end() { return iterator(data() + size()); }
const_iterator begin() const { return const_iterator(data()); }
const_iterator end() const { return const_iterator(data() + size()); }
string_view view() { return string_view(data(), size()); }
const_string_view view() const { return const_string_view(data(), size()); }
bool is_shared() const
{
if (likely(is_sso()))
{
return false;
}
else
{
return head.get_allocator() == nullptr;
}
}
char *data()
{
if (likely(is_sso()))
{
return stack.get_buffer();
}
else
{
return head.get_buffer();
}
}
const char *data() const
{
if (likely(is_sso()))
{
return stack.get_buffer();
}
else
{
return head.get_buffer();
}
}
void append(const string &rhs);
void append_buffer(const char *buf, u64 length);
void push_back(char ch);
char pop_back();
void remove_at(u64 index, u64 end_index);
void remove(iterator beg, iterator end)
{
u64 index = beg.get() - data();
u64 index_end = end.get() - data();
remove_at(index, index_end);
}
char at(u64 index) const
{
cassert(index < get_count());
return data()[index];
}
string &operator+=(const string &rhs)
{
append(rhs);
return *this;
}
bool operator==(const string &rhs) const;
bool operator!=(const string &rhs) const { return !operator==(rhs); }
private:
// littel endian machine
// 0x0
// |-----------------|---------------|
// | count(63) | char(64) 8 |
// | flag_shared(1) | |
// |-----------------|---------------|
// | buffer(64) | char(64) 8 |
// |----------------|----------------|
// | cap(63) | char(56) 7 |
// | none(1) | count(5) |
// |----------------|----------------|
// | flag_type(1)0 | flag_type(1)1 |
// | allocator(63) | allocator(63) |
// |----------------|----------------|
// 0x1F
struct head_t
{
u64 count;
char *buffer;
u64 cap;
memory::IAllocator *allocator;
u64 get_count() const { return count & ((1UL << 63) - 1); }
void set_count(u64 c) { count = (c & ((1UL << 63) - 1)) | (count & (1UL << 63)); };
u64 get_cap() const { return cap & ((1UL << 63) - 1); }
void set_cap(u64 c) { cap = (c & ((1UL << 63) - 1)) | (cap & (1UL << 63)); }
char *get_buffer() { return buffer; }
const char *get_buffer() const { return buffer; }
void set_buffer(char *b) { buffer = b; }
memory::IAllocator *get_allocator() const { return allocator; }
void set_allocator(memory::IAllocator *alc)
{
cassert((reinterpret_cast<u64>(alc) & 0x1) == 0); // bit 0
allocator = alc;
}
void init()
{
count = 0;
buffer = nullptr;
cap = 0;
allocator = 0;
}
};
struct stack_t
{
byte data[24];
memory::IAllocator *allocator;
public:
u64 get_count() const { return get_cap() - static_cast<u64>(data[23]); }
void set_count(u64 c) { data[23] = static_cast<byte>(get_cap() - c); }
u64 get_cap() const { return 23; }
char *get_buffer() { return reinterpret_cast<char *>(data); }
const char *get_buffer() const { return reinterpret_cast<const char *>(data); }
memory::IAllocator *get_allocator() const
{
return reinterpret_cast<memory::IAllocator *>(reinterpret_cast<u64>(allocator) & ~0x1);
}
void set_allocator(memory::IAllocator *alc)
{
allocator = reinterpret_cast<memory::IAllocator *>(reinterpret_cast<u64>(alc) | 0x1);
}
bool is_stack() const { return reinterpret_cast<u64>(allocator) & 0x1; }
};
union
{
stack_t stack;
head_t head;
};
static_assert(sizeof(stack_t) == sizeof(head_t));
private:
u64 select_capacity(u64 capacity);
void free();
void copy(const string &rhs);
void move(string &&rhs);
void init(memory::IAllocator *allocator, const char *str, i64 len = -1);
void init_lit(const char *str);
u64 get_count() const
{
if (likely(is_sso()))
return stack.get_count();
else
return head.get_count();
}
private:
bool is_sso() const { return stack.is_stack(); }
};
template <typename CE> string base_string_view<CE>::to_string(memory::IAllocator *allocator)
{
return string(allocator, ptr, len);
}
} // namespace util
| 25.025381 | 103 | 0.535497 | kadds |
efe6ee13015e03dd9051e0633494633c358b2e37 | 622 | cc | C++ | code/qttoolkit/contentbrowser/code/main.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 67 | 2015-03-30T19:56:16.000Z | 2022-03-11T13:52:17.000Z | code/qttoolkit/contentbrowser/code/main.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 5 | 2015-04-15T17:17:33.000Z | 2016-02-11T00:40:17.000Z | code/qttoolkit/contentbrowser/code/main.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 34 | 2015-03-30T15:08:00.000Z | 2021-09-23T05:55:10.000Z | //------------------------------------------------------------------------------
#include "stdneb.h"
#include "contentbrowserwindow.h"
#include "contentbrowserapp.h"
#include "extlibs/libqimg/qdevilplugin.h"
Q_IMPORT_PLUGIN(qdevil);
//------------------------------------------------------------------------------
/**
*/
int __cdecl
main(int argc, const char** argv)
{
Util::CommandLineArgs args(argc, argv);
ContentBrowser::ContentBrowserApp app;
app.SetCompanyName("gscept");
app.SetAppTitle("NebulaT Content Browser");
app.SetCmdLineArgs(args);
if (app.Open())
{
app.Run();
app.Close();
}
app.Exit();
} | 23.037037 | 80 | 0.530547 | gscept |
efec806f461fd802325dd210f9399cbef4211775 | 503 | hpp | C++ | source/ashes/renderer/TestRenderer/Sync/TestEvent.hpp | DragonJoker/Ashes | a6ed950b3fd8fb9626c60b4291fbd52ea75ac66e | [
"MIT"
] | 227 | 2018-09-17T16:03:35.000Z | 2022-03-19T02:02:45.000Z | source/ashes/renderer/TestRenderer/Sync/TestEvent.hpp | DragonJoker/RendererLib | 0f8ad8edec1b0929ebd10247d3dd0a9ee8f8c91a | [
"MIT"
] | 39 | 2018-02-06T22:22:24.000Z | 2018-08-29T07:11:06.000Z | source/ashes/renderer/TestRenderer/Sync/TestEvent.hpp | DragonJoker/Ashes | a6ed950b3fd8fb9626c60b4291fbd52ea75ac66e | [
"MIT"
] | 8 | 2019-05-04T10:33:32.000Z | 2021-04-05T13:19:27.000Z | /*
This file belongs to Ashes.
See LICENSE file in root folder
*/
#pragma once
#include "renderer/TestRenderer/TestRendererPrerequisites.hpp"
namespace ashes::test
{
class Event
{
public:
Event( VkDevice device );
/**
*\copydoc ashes::Event::getStatus
*/
VkResult getStatus()const;
/**
*\copydoc ashes::Event::getStatus
*/
VkResult set()const;
/**
*\copydoc ashes::Event::getStatus
*/
VkResult reset()const;
private:
mutable VkResult m_status{ VK_EVENT_RESET };
};
}
| 15.71875 | 62 | 0.683897 | DragonJoker |
efefffccc5b2dfe52e8eaa70f4732ce12a45df5e | 6,280 | cpp | C++ | src/ui/radio.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 1 | 2020-07-14T07:29:18.000Z | 2020-07-14T07:29:18.000Z | src/ui/radio.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 2 | 2019-01-01T22:35:56.000Z | 2022-03-14T07:34:00.000Z | src/ui/radio.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 2 | 2021-03-07T11:40:42.000Z | 2021-12-26T21:40:39.000Z | /*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on
* the source.
*/
/*
* $Logfile: /Freespace2/code/UI/RADIO.cpp $
* $Revision: 307 $
* $Date: 2010-02-08 09:09:13 +0100 (Mon, 08 Feb 2010) $
* $Author: taylor $
*
* Code to handle radio buttons.
*
* $Log$
* Revision 1.3 2004/09/20 01:31:45 theoddone33
* GCC 3.4 fixes.
*
* Revision 1.2 2002/06/09 04:41:29 relnev
* added copyright header
*
* Revision 1.1.1.1 2002/05/03 03:28:11 root
* Initial import.
*
*
* 4 12/02/98 5:47p Dave
* Put in interface xstr code. Converted barracks screen to new format.
*
* 3 10/13/98 9:29a Dave
* Started neatening up freespace.h. Many variables renamed and
* reorganized. Added AlphaColors.[h,cpp]
*
* 2 10/07/98 10:54a Dave
* Initial checkin.
*
* 1 10/07/98 10:51a Dave
*
* 9 3/10/98 4:19p John
* Cleaned up graphics lib. Took out most unused gr functions. Made D3D
* & Glide have popups and print screen. Took out all >8bpp software
* support. Made Fred zbuffer. Made zbuffer allocate dynamically to
* support Fred. Made zbuffering key off of functions rather than one
* global variable.
*
* 8 2/03/98 4:21p Hoffoss
* Made UI controls draw white text when disabled.
*
* 7 1/14/98 6:44p Hoffoss
* Massive changes to UI code. A lot cleaner and better now. Did all
* this to get the new UI_DOT_SLIDER to work properly, which the old code
* wasn't flexible enough to handle.
*
* 6 6/12/97 12:39p John
* made ui use freespace colors
*
* 5 6/11/97 1:13p John
* Started fixing all the text colors in the game.
*
* 4 5/26/97 10:26a Lawrance
* get slider control working 100%
*
* 3 1/01/97 6:46p Lawrance
* changed text color of radio button to green from black
*
* 2 11/15/96 11:43a John
*
* 1 11/14/96 6:55p John
*
* $NoKeywords: $
*/
#include "uidefs.h"
#include "ui.h"
#include "alphacolors.h"
void UI_RADIO::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state, int _group )
{
int _w, _h;
// gr_get_string_size( &_w, &_h, "X" );
_w = 18;
_h = 18;
if (_text)
text = strdup(_text);
else
text = NULL;
base_create( wnd, UI_KIND_RADIO, _x, _y, _w, _h );
position = 0;
pressed_down = 0;
flag = _state;
group = _group;
};
void UI_RADIO::destroy()
{
if (text)
free(text);
UI_GADGET::destroy();
}
void UI_RADIO::draw()
{
int offset;
if ( uses_bmaps ) {
if ( disabled_flag ) {
if ( flag ) {
if ( bmap_ids[RADIO_DISABLED_MARKED] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_DISABLED_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
else {
if ( bmap_ids[RADIO_DISABLED_CLEAR] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_DISABLED_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
}
else { // not disabled
if ( position == 0 ) { // up
if ( flag ) { // marked
if ( bmap_ids[RADIO_UP_MARKED] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_UP_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
else { // not marked
if ( bmap_ids[RADIO_UP_CLEAR] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_UP_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
}
else { // down
if ( flag ) { // marked
if ( bmap_ids[RADIO_DOWN_MARKED] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_DOWN_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
else { // not marked
if ( bmap_ids[RADIO_DOWN_CLEAR] != -1 ) {
gr_set_bitmap(bmap_ids[RADIO_DOWN_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
gr_bitmap(x,y);
}
}
}
}
}
else {
gr_set_font(my_wnd->f_id);
gr_set_clip( x, y, w, h );
if (position == 0 ) {
ui_draw_box_out( 0, 0, w-1, h-1 );
offset = 0;
} else {
ui_draw_box_in( 0, 0, w-1, h-1 );
offset = 1;
}
if (disabled_flag)
gr_set_color_fast(&CDARK_GRAY);
else if (my_wnd->selected_gadget == this)
gr_set_color_fast(&CBRIGHT_GREEN);
else
gr_set_color_fast(&CGREEN);
// if (flag)
// ui_string_centered( Middle(w)+offset, Middle(h)+offset, "*" );
// else
// ui_string_centered( Middle(w)+offset, Middle(h)+offset, "o" );
if (flag) {
gr_circle( Middle(w)+offset, Middle(h)+offset, 8 );
} else {
gr_circle( Middle(w)+offset, Middle(h)+offset, 8 );
gr_set_color_fast( &CWHITE );
gr_circle( Middle(w)+offset, Middle(h)+offset, 4 );
}
if (disabled_flag)
gr_set_color_fast(&CDARK_GRAY);
else if (my_wnd->selected_gadget == this)
gr_set_color_fast(&CBRIGHT_GREEN);
else
gr_set_color_fast(&CGREEN);
if ( text ) {
gr_reset_clip();
gr_string( x+w+4, y+2, text );
}
}
}
void UI_RADIO::process(int focus)
{
int OnMe, oldposition;
if (disabled_flag) {
position = 0;
return;
}
if (my_wnd->selected_gadget == this)
focus = 1;
OnMe = is_mouse_on();
oldposition = position;
if (B1_PRESSED && OnMe) {
position = 1;
} else {
position = 0;
}
if (my_wnd->keypress == hotkey) {
position = 2;
my_wnd->last_keypress = 0;
}
if ( focus && ((my_wnd->keypress == KEY_SPACEBAR) || (my_wnd->keypress == KEY_ENTER)) )
position = 2;
if (focus)
if ( (oldposition == 2) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER]) )
position = 2;
pressed_down = 0;
if (position) {
if ( (oldposition == 1) && OnMe )
pressed_down = 1;
if ( (oldposition == 2) && focus )
pressed_down = 1;
}
if (pressed_down && user_function) {
user_function();
}
if (pressed_down && (flag == 0)) {
UI_GADGET *tmp = (UI_GADGET *) next;
UI_RADIO *tmpr;
while (tmp != this) {
if (tmp->kind == UI_KIND_RADIO) {
tmpr = (UI_RADIO *) tmp;
if ((tmpr->group == group) && tmpr->flag) {
tmpr->flag = 0;
tmpr->pressed_down = 0;
}
}
tmp = tmp->next;
}
flag = 1;
}
}
int UI_RADIO::changed()
{
return pressed_down;
}
int UI_RADIO::checked()
{
return flag;
}
| 22.269504 | 109 | 0.62086 | ptitSeb |
eff0238aa7ff1bec34896371a361d58922c057d1 | 2,097 | cpp | C++ | nori-base-2019/src/lightDepthArea.cpp | TamerMograbi/ShadowNet | 99a9fb4522546e58817bbdd373f63d6996685e21 | [
"BSD-3-Clause"
] | null | null | null | nori-base-2019/src/lightDepthArea.cpp | TamerMograbi/ShadowNet | 99a9fb4522546e58817bbdd373f63d6996685e21 | [
"BSD-3-Clause"
] | null | null | null | nori-base-2019/src/lightDepthArea.cpp | TamerMograbi/ShadowNet | 99a9fb4522546e58817bbdd373f63d6996685e21 | [
"BSD-3-Clause"
] | 1 | 2020-01-22T11:55:43.000Z | 2020-01-22T11:55:43.000Z | #include <nori/integrator.h>
#include <nori/scene.h>
#include <nori/bsdf.h>
NORI_NAMESPACE_BEGIN
class lightDepthAreaIntegrator : public Integrator {
public:
lightDepthAreaIntegrator(const PropertyList &props)
{
}
void preprocess(const Scene *scene)
{
emitterMeshes = scene->getEmitterMeshes();
const MatrixXf vertices = emitterMeshes[0]->getVertexPositions();
for (int colIdx = 0; colIdx < vertices.cols(); colIdx++)
{
meshCenter += vertices.col(colIdx);
}
meshCenter /= vertices.cols();
}
//point x will be visible only if light reaches it
//bool visiblity(const Scene *scene, Point3f x) const
//{
// Vector3f dir = position - x;//direction from point to light source
// dir.normalize();
// Ray3f ray(x, dir);
// return !scene->rayIntersect(ray);//if ray intersects, then it means that it hit another point in the mesh
// //while on it's way to the light source. so x won't recieve light
//}
//scale value x from range [-1,1] to [a,b]
float scaleToAB(float x, float a, float b) const
{
return (b - a)*(x + 1) / 2 + a;
}
Color3f Li(const Scene *scene, Sampler *sampler, const Ray3f &ray) const
{
Intersection its;
if (!scene->rayIntersect(ray, its))
{
return Color3f(0.f);
}
Point3f x = its.p; //where the ray hits the mesh
Vector3f intersectionToLight = (meshCenter - x).normalized();
float scaledX = scaleToAB(intersectionToLight[0], 0, 1);
float scaledY = scaleToAB(intersectionToLight[1], 0, 1);
float scaledZ = scaleToAB(intersectionToLight[2], 0, 1);
//we scale from -1 to 1 (which is the range that the coordinates of a normalized direction can be in) to 0 2
return Color3f(scaledX, scaledY, scaledZ);
}
std::string toString() const {
return "lightDepthAreaIntegrator[]";
}
EIntegratorType getIntegratorType() const
{
return EIntegratorType::ELightDepthArea;
}
std::vector<Mesh *> emitterMeshes;
Point3f meshCenter;
};
NORI_REGISTER_CLASS(lightDepthAreaIntegrator, "lightDepthArea");
NORI_NAMESPACE_END | 29.957143 | 116 | 0.674297 | TamerMograbi |
eff414eb37b93f36a5e9cd4a7a03fea2fdf00899 | 4,837 | hpp | C++ | libs/Core/include/argos-Core/Syntax/SyntaxParenthesizedExpression.hpp | henrikfroehling/interlinck | d9d947b890d9286c6596c687fcfcf016ef820d6b | [
"MIT"
] | null | null | null | libs/Core/include/argos-Core/Syntax/SyntaxParenthesizedExpression.hpp | henrikfroehling/interlinck | d9d947b890d9286c6596c687fcfcf016ef820d6b | [
"MIT"
] | 19 | 2021-12-01T20:37:23.000Z | 2022-02-14T21:05:43.000Z | libs/Core/include/argos-Core/Syntax/SyntaxParenthesizedExpression.hpp | henrikfroehling/interlinck | d9d947b890d9286c6596c687fcfcf016ef820d6b | [
"MIT"
] | null | null | null | #ifndef ARGOS_CORE_SYNTAX_SYNTAXPARENTHESIZEDEXPRESSION_H
#define ARGOS_CORE_SYNTAX_SYNTAXPARENTHESIZEDEXPRESSION_H
#include <string>
#include "argos-Core/argos_global.hpp"
#include "argos-Core/Syntax/ExpressionKinds.hpp"
#include "argos-Core/Syntax/ISyntaxParenthesizedExpression.hpp"
#include "argos-Core/Syntax/SyntaxExpression.hpp"
#include "argos-Core/Syntax/SyntaxVariant.hpp"
#include "argos-Core/Types.hpp"
namespace argos::Core::Syntax
{
class ISyntaxExpression;
class ISyntaxToken;
/**
* @brief Base class implementation for <code>ISyntaxParenthesizedExpression</code>.
*/
class ARGOS_CORE_API SyntaxParenthesizedExpression : public virtual ISyntaxParenthesizedExpression,
public SyntaxExpression
{
public:
SyntaxParenthesizedExpression() = delete;
/**
* @brief Creates a <code>SyntaxParenthesizedExpression</code> instance.
* @param expressionKind The <code>ExpressionKind</code> of the <code>SyntaxParenthesizedExpression</code>.
* @param openParenthesisToken The left sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
* @param expression The <code>ISyntaxExpression</code> in the parenthesized expression.
* @param closeParenthesisToken The right sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
*/
explicit SyntaxParenthesizedExpression(ExpressionKind expressionKind,
const ISyntaxToken* openParenthesisToken,
const ISyntaxExpression* expression,
const ISyntaxToken* closeParenthesisToken) noexcept;
~SyntaxParenthesizedExpression() noexcept override = default;
/**
* @brief Returns the children count of the parenthesized expression.
* @return The children count of the parenthesized expression.
*/
argos_size childCount() const noexcept override;
/**
* @brief Returns the child item of the parenthesized expression at the given <code>index</code>.
* @param index The index for which a child item will be returned.
* @return The child item of the parenthesized expression at the given <code>index</code>.
*/
SyntaxVariant child(argos_size index) const noexcept final;
/**
* @brief Returns the first child item of the parenthesized expression.
* @return The first child item of the parenthesized expression.
*/
SyntaxVariant first() const noexcept override;
/**
* @brief Returns the last child item of the parenthesized expression.
* @return The last child item of the parenthesized expression.
*/
SyntaxVariant last() const noexcept override;
/**
* @brief Returns a string representation of theparenthesized expression with basic data.
* @return A string representation of the parenthesized expression with basic data.
*/
std::string toString() const noexcept override;
/**
* @brief Returns a short string representation of the parenthesized expression with basic data.
* @return A short string representation of the parenthesized expression with basic data.
*/
std::string toShortString() const noexcept override;
/**
* @brief Returns the type name (e.g. the specific class name) of the parenthesized expression.
* @return The type name (e.g. the specific class name) of the parenthesized expression.
*/
std::string typeName() const noexcept override;
/**
* @brief Returns whether the expression is a parenthesized expression.
* @return Returns true.
*/
bool isParenthesizedExpression() const noexcept final;
/**
* @brief Returns the left sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
* @return The left sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
*/
const ISyntaxToken* openParenthesisToken() const noexcept final;
/**
* @brief Returns the <code>ISyntaxExpression</code> in the parenthesized expression.
* @return The <code>ISyntaxExpression</code> in the parenthesized expression.
*/
const ISyntaxExpression* expression() const noexcept final;
/**
* @brief Returns the right sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
* @return The right sided open parenthesis <code>ISyntaxToken</code> of the parenthesized expression.
*/
const ISyntaxToken* closeParenthesisToken() const noexcept final;
protected:
const ISyntaxToken* _openParenthesisToken;
const ISyntaxExpression* _expression;
const ISyntaxToken* _closeParenthesisToken;
};
} // end namespace argos::Core::Syntax
#endif // ARGOS_CORE_SYNTAX_SYNTAXBINARYEXPRESSION_H
| 40.991525 | 127 | 0.716767 | henrikfroehling |
56068b094935639c12ba5efca575ca59056eb0b4 | 8,551 | hpp | C++ | Unidad 4/src/biblioteca/funciones/strings.hpp | Franeiro/AyED | a53142ac0c92fb74e62064e26fb4a4f86bace388 | [
"Xnet",
"X11"
] | null | null | null | Unidad 4/src/biblioteca/funciones/strings.hpp | Franeiro/AyED | a53142ac0c92fb74e62064e26fb4a4f86bace388 | [
"Xnet",
"X11"
] | null | null | null | Unidad 4/src/biblioteca/funciones/strings.hpp | Franeiro/AyED | a53142ac0c92fb74e62064e26fb4a4f86bace388 | [
"Xnet",
"X11"
] | null | null | null | #ifndef _TSTRINGS_T_
#define _TSTRINGS_T_
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
int length(string s)
{
int i;
for (i = 0; s[i] != '\0'; i++)
{
}
return i;
}
int charCount(string s, char c)
{
int i, veces;
veces = 0;
for (i = 0; i < length(s); i++)
{
if (s[i] == c)
{
veces++;
}
}
return veces;
}
string substring(string s, int d, int h)
{
int i = 0;
string aux;
for (i = d; i < h; i++)
{
aux += s[i];
}
return aux;
}
string substring(string s, int d) // ok
{
int i = 0;
string aux;
for (i = d; i < length(s); i++)
{
aux += s[i];
}
return aux;
return "";
}
int indexOf(string s, char c) // ok
{
int i;
for (i = 0; s[i] != '\0'; i++)
{
if (s[i] == c)
{
return i;
}
}
return -1;
}
int indexOf(string s, char c, int offSet) // ok
{
int i;
for (i = 0; s[i] != '\0'; i++)
{
if (i > offSet && s[i] == c)
{
return i;
}
}
return 0;
}
int indexOf(string s, string toSearch)
{
int a, j = 0;
for (int i = 0; i <= length(s); i++)
{
if (s[i] == toSearch[0])
{
a = i;
while (s[i] == toSearch[j] && j < length(toSearch))
{
i++;
j++;
if (j == length(toSearch))
{
return a;
break;
}
}
i = a;
}
}
return -1;
}
int indexOf(string s, string toSearch, int offset) // ok
{
int i, a, j = 0;
for (i = 0; i <= length(s); i++)
{
if (i > offset && s[i] == toSearch[0])
{
a = i;
while (s[i] == toSearch[j] && j < length(toSearch))
{
i++;
j++;
if (j == length(toSearch))
{
return a;
break;
}
}
i = a;
}
}
return 0;
}
int lastIndexOf(string s, char c)
{
int i;
for (i = length(s); i >= 0; i--)
{
if (s[i] == c)
{
return i;
break;
}
}
return -1;
}
int indexOfN(string s, char c, int n)
{
int i, veces = 0;
for (i = 0; i <= length(s); i++)
{
if (s[i] == c)
{
veces++;
if (veces == n)
{
return i;
break;
}
}
}
return -1;
}
int charToInt(char c)
{
/*
int numero;
numero = c - 48;
return numero;
*/
int i = '0';
int n = c;
int resultado = n - i;
return resultado;
}
char intToChar(int i)
{
char caracter;
caracter = (i + 48);
return caracter;
}
int potencia(int x, int y) // CREO FUNCION PARA CALCULAR POTENCIAS
{
if (y == 0)
{
return 1;
}
else
{
if (int(y % 2) == 0)
{
return (potencia(x, int(y / 2)) * potencia(x, int(y / 2)));
}
else
{
return (x * potencia(x, int(y / 2)) * potencia(x, int(y / 2)));
}
}
}
int getDigit(int n, int i)
{
int p = potencia(10, i);
int q = n / p;
return q % 10;
}
int digitCount(int n)
{
int a = 0, t;
for (t = 0; n / (long)potencia(10, t) >= 1; t++)
{
a++;
}
return a;
}
string intToString(int i)
{
int n = digitCount(i);
string parse = "";
for (int j = 0; j < n; j++)
{
int f = (n - j) - 1;
int digito = getDigit(i, f);
char c = digito + 48;
parse += c;
}
return parse;
}
int stringToInt(string s, int b) // ok
{
int parseInt, j;
int longitud = length(s) - 1;
char i = 0;
for (j = longitud; j >= 0; j--)
{
int x;
if (s[j] >= '0' and s[j] <= '9')
{
x = '0';
}
else
{
x = 'A' - 10;
}
parseInt = parseInt + (s[j] - x) * potencia(b, i);
i++;
}
return parseInt;
}
int stringToInt(string s) // ok
{
int parseInt = 0, j = 0;
int longitud = length(s) - 1;
int i = 0;
for (j = longitud; j >= 0; j--)
{
parseInt = parseInt + (charToInt(s[j]) * potencia(10, i));
i++;
}
return parseInt;
}
string charToString(char c)
{
string a;
a += c;
return a;
}
char stringToChar(string s)
{
char a;
a = s[0];
return a;
}
string stringToString(string s)
{
string a;
a = s;
return a;
}
string doubleToString(double d) // saltear
{
char x[100];
sprintf(x, "%f", d); // esto es de lenguaje C, no se usa
string ret = x;
return ret;
}
double stringToDouble(string s) // No se hace
{
return 1.1;
}
bool isEmpty(string s)
{
bool a;
string verdad;
a = s == "";
if (a == 0)
{
verdad = "false";
}
else
{
verdad = "true";
}
return a;
}
bool startsWith(string s, string x)
{
int coincidencia;
for (int i = 0; i <= length(x); i++)
{
if (x[i] == s[i])
{
coincidencia++;
}
}
if (coincidencia == length(x))
{
return true;
}
else
{
return false;
}
}
bool endsWith(string s, string x)
{
int coincidencia;
int posX = length(x);
for (int i = length(s); posX >= 0; i--)
{
if (x[posX] == s[i])
{
coincidencia++;
}
posX--;
}
if (coincidencia - 1 == length(x))
{
return true;
}
else
{
return false;
}
}
bool contains(string s, char c)
{
int coincidencia;
for (int i = 0; i <= length(s); i++)
{
if (s[i] == c)
{
coincidencia = 1;
}
}
if (coincidencia == 1)
{
return true;
}
else
{
return false;
}
}
string replace(string s, char oldChar, char newChar)
{
for (int i = 0; i <= length(s); i++)
{
if (s[i] == oldChar)
{
s[i] = newChar;
}
}
return s;
}
string insertAt(string s, int pos, char c)
{
string r = substring(s, 0, pos) + c + substring(s, pos);
return r;
}
string removeAt(string s, int pos)
{
string r = substring(s, 0, pos) + substring(s, pos + 1);
return r;
}
string ltrim(string s)
{
int largo = length(s);
int i = 0;
while (s[i] == ' ')
{
i++;
}
return substring(s, i, largo);
}
string rtrim(string s)
{
int largo = length(s) - 1;
while (s[largo] == ' ')
{
largo--;
}
return substring(s, 0, largo + 1);
}
string trim(string s)
{
return rtrim(ltrim(s));
}
string replicate(char c, int n)
{
string a;
for (int i = 0; i <= n; i++)
{
a += c;
}
return a;
}
string spaces(int n)
{
string a;
for (int i = 0; i <= n; i++)
{
a += ' ';
}
return a;
}
string lpad(string s, int n, char c)
{
string a;
for (int i = 0; i <= n; i++)
{
a += c;
}
a += s;
return a;
}
string rpad(string s, int n, char c)
{
string a;
a += s;
for (int i = 0; i <= n; i++)
{
a += c;
}
return a;
}
string cpad(string s, int n, char c)
{
string a;
int espacio = (n - length(s));
for (int i = 0; i <= espacio; i++)
{
if (i < (espacio / 2))
{
a += c;
}
if (i == (espacio / 2))
{
a += s;
}
if (i > (espacio / 2))
{
a += c;
}
}
return a;
}
bool isDigit(char c)
{
if (c >= 48 && c <= 57)
{
return true;
}
else
{
return false;
}
}
bool isLetter(char c)
{
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
{
return true;
}
else
{
return false;
}
}
bool isUpperCase(char c)
{
if ((c >= 65 && c <= 90))
{
return true;
}
else
{
return false;
}
}
bool isLowerCase(char c)
{
if ((c >= 97 && c <= 122))
{
return true;
}
else
{
return false;
}
}
char toUpperCase(char c)
{
if (c >= 97 && c <= 122)
{
c -= 32;
}
else
{
return c;
}
return c;
}
char toLowerCase(char c)
{
if (c >= 65 && c <= 90)
{
c += 32;
}
else
{
return c;
}
return c;
}
string toUpperCase(string s)
{
for (int i = 0; i <= length(s); i++)
{
if (s[i] >= 97 && s[i] <= 122)
{
s[i] -= 32;
}
else
{
s[i] = s[i];
}
}
return s;
}
string toLowerCase(string s)
{
for (int i = 0; i <= length(s); i++)
{
if (s[i] >= 65 && s[i] <= 90)
{
s[i] += 32;
}
else
{
s[i] = s[i];
}
}
return s;
}
#endif
| 12.303597 | 72 | 0.422758 | Franeiro |
560df1042a482b6fc705bf40aaae20c8924c6231 | 8,066 | cpp | C++ | test/math.t.cpp | ltjax/replay | 33680beae225c9c388f33e3f7ffd7e8bae4643e9 | [
"MIT"
] | 1 | 2015-09-15T19:52:50.000Z | 2015-09-15T19:52:50.000Z | test/math.t.cpp | ltjax/replay | 33680beae225c9c388f33e3f7ffd7e8bae4643e9 | [
"MIT"
] | 3 | 2017-12-03T21:53:09.000Z | 2019-11-23T02:11:50.000Z | test/math.t.cpp | ltjax/replay | 33680beae225c9c388f33e3f7ffd7e8bae4643e9 | [
"MIT"
] | null | null | null | #include <catch2/catch.hpp>
#include <replay/math.hpp>
#include <replay/matrix2.hpp>
#include <replay/minimal_sphere.hpp>
#include <replay/vector_math.hpp>
#include <boost/math/constants/constants.hpp>
#include <random>
namespace
{
// FIXME: this is somewhat generically useful - lift it to a visible namespace?
replay::vector3f polar_to_model(float latitude, float longitude)
{
latitude = replay::math::convert_to_radians(latitude);
longitude = replay::math::convert_to_radians(longitude);
float cw = std::cos(latitude);
float sw = std::sin(latitude);
float ch = std::cos(longitude);
float sh = std::sin(longitude);
return {cw * ch, sw * ch, sh};
}
template <class IteratorType>
float distance_to_sphere(const IteratorType point_begin,
const IteratorType point_end,
const replay::vector3f& center,
const float square_radius)
{
float max_sqr_distance = 0.f;
for (IteratorType i = point_begin; i != point_end; ++i)
{
const float sqr_distance = (center - (*i)).squared();
max_sqr_distance = std::max(max_sqr_distance, sqr_distance);
}
float radius = std::sqrt(square_radius);
return std::max(0.f, std::sqrt(max_sqr_distance) - radius);
}
} // namespace
TEST_CASE("matrix2_operations")
{
using namespace replay;
matrix2 Rotation = matrix2::make_rotation(boost::math::constants::pi<float>() * 0.25f); // 45deg rotation
matrix2 Inv = Rotation;
REQUIRE(Inv.invert());
using math::fuzzy_equals;
using math::fuzzy_zero;
matrix2 I = Rotation * Inv;
// This should be identity
REQUIRE(fuzzy_equals(I[0], 1.f));
REQUIRE(fuzzy_zero(I[1]));
REQUIRE(fuzzy_zero(I[2]));
REQUIRE(fuzzy_equals(I[3], 1.f));
I = Inv * Rotation;
// This should be identity
REQUIRE(fuzzy_equals(I[0], 1.f));
REQUIRE(fuzzy_zero(I[1]));
REQUIRE(fuzzy_zero(I[2]));
REQUIRE(fuzzy_equals(I[3], 1.f));
}
// This test verifies integer arithmetic with a vector3.
// Hopefully, floating-point math will behave correct if this does.
TEST_CASE("vector3_integer_operations")
{
using namespace replay;
typedef vector3<int> vec3;
const vec3 a(-1, -67, 32);
const vec3 b(7777, 0, -111);
const vec3 c(a - b);
REQUIRE(c - a == -b);
const vec3 all_one(1, 1, 1);
REQUIRE(all_one.sum() == 3);
REQUIRE(all_one.squared() == 3);
int checksum = dot(a, all_one);
REQUIRE(checksum == a.sum());
checksum = dot(b, all_one);
REQUIRE(checksum == b.sum());
REQUIRE(a.sum() - b.sum() == c.sum());
REQUIRE((a * 42).sum()== a.sum() * 42);
const vec3 all_two(2, 2, 2);
REQUIRE(all_one * 2== all_two);
REQUIRE(all_one + all_one== all_two);
}
TEST_CASE("quadratic_equation_solver")
{
using namespace replay;
using range_type = std::uniform_real_distribution<float>;
// Attempt to solve a few equations of the form (x-b)(x-a)=0 <=> x^2+(-a-b)*x+b*a=0
std::mt19937 rng;
range_type range(-100.f, 300.f);
auto die = [&] { return range(rng); };
for (std::size_t i = 0; i < 32; ++i)
{
float a = die();
float b = die();
if (replay::math::fuzzy_equals(a, b))
continue;
interval<> r;
// FIXME: use a relative epsilon
math::solve_quadratic_eq(1.f, -a - b, a * b, r, 0.001f);
if (a > b)
std::swap(a, b);
REQUIRE(r[0] == Approx(a).margin(0.01f));
REQUIRE(r[1] == Approx(b).margin(0.01f));
}
}
TEST_CASE("matrix4_determinant_simple")
{
using namespace replay;
matrix4 M(0.f, 0.f, 3.f, 0.f, 4.f, 0.f, 0.f, 0.f, 0.f, 2.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
float d = M.determinant();
REQUIRE(d == Approx(24.f).margin(0.0001f));
matrix4 N(2.f, 1.f, 0.f, 0.f, 1.f, 2.f, 1.f, 0.f, 0.f, 1.f, 2.f, 1.f, 0.f, 0.f, 1.f, 2.f);
float e = N.determinant();
REQUIRE(e == Approx(5.f).margin(0.0001f));
}
TEST_CASE("circumcircle")
{
using namespace replay;
// Construct a rotational matrix
vector3f x = polar_to_model(177.f, -34.f);
vector3f y = normalized(math::construct_perpendicular(x));
matrix3 M(x, y, cross(x, y));
// Construct three points on a circle and rotate them
const float radius = 14.f;
float angle = math::convert_to_radians(34.f);
vector3f a = M * (vector3f(std::cos(angle), std::sin(angle), 0.f) * radius);
angle = math::convert_to_radians(134.f);
vector3f b = M * (vector3f(std::cos(angle), std::sin(angle), 0.f) * radius);
angle = math::convert_to_radians(270.f);
vector3f c = M * (vector3f(std::cos(angle), std::sin(angle), 0.f) * radius);
// Move the circle
const vector3f center(45.f, 32.f, -37.f);
a += center;
b += center;
c += center;
// Reconstruct it
equisphere<float, 3> s(1e-16f);
REQUIRE(s.push(a.ptr()));
REQUIRE(s.push(b.ptr()));
REQUIRE(s.push(c.ptr()));
vector3f equisphere_center(vector3f::cast(s.get_center()));
vector3f center_delta = center - equisphere_center;
REQUIRE(center_delta.squared() < 0.001f);
REQUIRE(std::sqrt(s.get_squared_radius()) == Approx(radius).margin(0.001f));
}
// Simple test case directly testing the minimal ball solver in 3D
TEST_CASE("minimal_ball")
{
using namespace replay;
typedef vector3f vec3;
using range_type = std::uniform_real_distribution<float>;
// setup random number generators
std::mt19937 rng;
auto random_latitude = [&] { return range_type(-180.f, 180.f)(rng); };
auto random_longitude = [&] { return range_type(-90.f, 90.f)(rng); };
auto random_scale = [&] { return range_type(0.f, 1.0f)(rng); };
// setup a simple point set
std::list<vec3> points{ vec3(1.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f), vec3(0.f, 0.f, 1.f), vec3(0.f, -1.f, 0.f) };
for (std::size_t i = 0; i < 32; ++i)
{
vector3f t = polar_to_model(random_latitude(), random_longitude());
float s = random_scale();
points.push_back(t * s);
}
// run the solver
replay::minimal_ball<float, replay::vector3f, 3> ball(points, 1e-15f);
// check correctness
REQUIRE(ball.square_radius() == Approx(1.f).margin(0.001f));
REQUIRE(ball.center().squared() < 0.001f);
REQUIRE(distance_to_sphere(points.begin(), points.end(), ball.center(), ball.square_radius()) < 0.001f);
}
// Slightly more sophisticated test for the minimal ball routines using
// the wrapper from vector_math.hpp and an std::vector
TEST_CASE("minimal_sphere")
{
using namespace replay;
using range_type = std::uniform_real_distribution<float>;
std::mt19937 rng;
auto random_coord = [&] { return range_type(-100.f, 100.f)(rng); };
auto random_radius = [&] { return range_type(1.f, 3.f)(rng); };
auto random_latitude = [&] { return range_type(-180.f, 180.f)(rng); };
auto random_longitude = [&] { return range_type(-90.f, 90.f)(rng); };
auto random_scale = [&] { return range_type(0.0f, 1.0f)(rng); };
std::vector<vector3f> p(64);
for (std::size_t i = 0; i < 16; ++i)
{
const vector3f center(random_coord(), random_coord(), random_coord());
const float radius = random_radius();
std::size_t boundary_n = 2 + rng() % 3;
for (std::size_t j = 0; j < boundary_n; ++j)
p[j] = center + polar_to_model(random_latitude(), random_longitude()) * radius;
for (std::size_t j = boundary_n; j < 64; ++j)
p[j] = center + polar_to_model(random_latitude(), random_longitude()) * (random_scale() * radius);
std::shuffle(p.begin(), p.end(), rng);
auto const [result_center, result_square_radius] = math::minimal_sphere(p);
float square_radius = radius * radius;
// The generated boundary doesn't necessarily define the minimal ball, but it's an upper bound
REQUIRE(result_square_radius <= Approx(square_radius).margin(0.0001));
REQUIRE(distance_to_sphere(p.begin(), p.end(), result_center, result_square_radius) < 0.001f);
}
} | 31.263566 | 114 | 0.621994 | ltjax |
562072287f24126f19d8fae38014768b89bbfb53 | 6,232 | cpp | C++ | EndGame/EndGame/Src/SubSystems/RenderSubSystem/Renderer2D.cpp | siddharthgarg4/EndGame | ba608714b3eacb5dc05d0c852db573231c867d8b | [
"MIT"
] | null | null | null | EndGame/EndGame/Src/SubSystems/RenderSubSystem/Renderer2D.cpp | siddharthgarg4/EndGame | ba608714b3eacb5dc05d0c852db573231c867d8b | [
"MIT"
] | null | null | null | EndGame/EndGame/Src/SubSystems/RenderSubSystem/Renderer2D.cpp | siddharthgarg4/EndGame | ba608714b3eacb5dc05d0c852db573231c867d8b | [
"MIT"
] | null | null | null | //
// Renderer2D.cpp
//
//
// Created by Siddharth on 09/07/20.
//
#include "Renderer2D.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include <EndGame/Src/SubSystems/RenderSubSystem/RenderCommand.h>
#include <EndGame/Src/SubSystems/RenderSubSystem/RenderApiFactory.hpp>
namespace EndGame {
Renderer2DStorage *Renderer2D::storage = nullptr;
void Renderer2D::init() {
//init storage
storage = new Renderer2DStorage();
storage->quadVertexArray = RenderApiFactory::createVertexArray();
//vertex buffer
storage->quadVertexBuffer = RenderApiFactory::createVertexBuffer(storage->maxQuadVerticesPerDraw * sizeof(QuadVertexData));
storage->quadVertexBuffer->setLayout({
{ShaderDataType::Float3, "attrPosition"},
{ShaderDataType::Float4, "attrColor"},
{ShaderDataType::Float2, "attrTextureCoord"},
{ShaderDataType::Float, "attrTextureIndex"},
{ShaderDataType::Float, "attrTilingFactor"}
});
storage->quadVertexArray->addVertexBuffer(storage->quadVertexBuffer);
//index buffer
uint32_t *quadIndices = new uint32_t[storage->maxQuadIndicesPerDraw];
for (uint32_t offset=0, i=0; i<storage->maxQuadIndicesPerDraw; i+=6) {
quadIndices[i+0] = offset+0;
quadIndices[i+1] = offset+1;
quadIndices[i+2] = offset+2;
quadIndices[i+3] = offset+2;
quadIndices[i+4] = offset+3;
quadIndices[i+5] = offset+0;
offset+=4;
}
std::shared_ptr<IndexBuffer> quadIndexBuffer = RenderApiFactory::createIndexBuffer(storage->maxQuadIndicesPerDraw * sizeof(uint32_t), quadIndices);
storage->quadVertexArray->setIndexBuffer(quadIndexBuffer);
delete[] quadIndices;
//shader
storage->quadShader = RenderApiFactory::createShader("Sandbox/Quad.glsl");
storage->quadShader->bind();
//setting sampler slots
std::shared_ptr<int32_t> samplers(new int32_t[storage->maxFragmentTextureSlots], std::default_delete<int[]>());
for (int32_t i=0; i<storage->maxFragmentTextureSlots; i++) {
samplers.get()[i] = i;
}
storage->quadShader->uploadUniform("u_textures", samplers, storage->maxFragmentTextureSlots);
}
void Renderer2D::shutdown() {
delete storage;
}
void Renderer2D::beginScene(const OrthographicCamera &camera) {
storage->quadShader->bind();
storage->quadShader->uploadUniform("u_viewProjection", camera.getViewProjectionMatrix());
beginNewBatch();
}
void Renderer2D::endScene() {
flushVertexBuffer();
}
void Renderer2D::flushVertexBuffer() {
//sort quadVertexBufferData by z-index to render textures with lower z index first
std::sort(storage->quadVertexBufferData.begin(), storage->quadVertexBufferData.begin() + storage->quadVertexBufferDataSize, [](const QuadVertexData &first, const QuadVertexData &second){
return first.position.z < second.position.z;
});
storage->quadShader->bind();
storage->quadVertexBuffer->setData(storage->quadVertexBufferDataSize * sizeof(QuadVertexData), storage->quadVertexBufferData.data());
storage->quadVertexArray->bind();
//bind all texture slots
for (uint32_t i=0; i<storage->textureSlotsDataSize; i++) {
storage->textureSlots[i]->bind(i);
}
//each quad is 6 indices (2 triangles)
uint32_t numberOfQuads = storage->quadVertexBufferDataSize/4;
RenderCommand::drawIndexed(storage->quadVertexArray, numberOfQuads*6);
}
void Renderer2D::drawQuad(QuadRendererData data, bool shouldRotate) {
//pushing to local buffer until data can be accomodated
if (storage->quadVertexBufferDataSize >= storage->maxQuadVerticesPerDraw ||
storage->textureSlotsDataSize >= storage->maxFragmentTextureSlots) {
//flush if we reach max quads or max textures
flushVertexBuffer();
beginNewBatch();
}
//transforms
glm::mat4 transform = glm::translate(glm::mat4(1.0f), data.position);
if (shouldRotate) {
transform *= glm::rotate(glm::mat4(1.0f), glm::radians(data.rotation), {0, 0, 1});
}
transform *= glm::scale(glm::mat4(1.0f), {data.size.x, data.size.y, 1.0f});
//textures - switch in shader defaults to no texture
float textureIndex = -1.0f;
if (data.texture != nullptr) {
//if quad has texture
for (uint32_t i=0; i<storage->textureSlotsDataSize; i++) {
if (*storage->textureSlots[i].get() == *data.texture.get()) {
textureIndex = (float)i;
break;
}
}
//texture hasn't been used before
if (textureIndex == -1.0f) {
textureIndex = (float)storage->textureSlotsDataSize;
addTextureSlot(data.texture);
}
}
addQuadVertexData(QuadVertexData(transform * storage->quadVertexDefaultPositions[0], data.color, {0.0f, 0.0f}, textureIndex, data.tilingFactor));
addQuadVertexData(QuadVertexData(transform * storage->quadVertexDefaultPositions[1], data.color, {1.0f, 0.0f}, textureIndex, data.tilingFactor));
addQuadVertexData(QuadVertexData(transform * storage->quadVertexDefaultPositions[2], data.color, {1.0f, 1.0f}, textureIndex, data.tilingFactor));
addQuadVertexData(QuadVertexData(transform * storage->quadVertexDefaultPositions[3], data.color, {0.0f, 1.0f}, textureIndex, data.tilingFactor));
}
void Renderer2D::beginNewBatch() {
storage->quadVertexBufferDataSize = 0;
storage->textureSlotsDataSize = 0;
}
void Renderer2D::addQuadVertexData(const QuadVertexData &data) {
storage->quadVertexBufferData[storage->quadVertexBufferDataSize] = data;
storage->quadVertexBufferDataSize++;
}
void Renderer2D::addTextureSlot(std::shared_ptr<Texture2D> texture) {
storage->textureSlots[storage->textureSlotsDataSize] = texture;
storage->textureSlotsDataSize++;
}
} | 45.823529 | 194 | 0.648748 | siddharthgarg4 |
56223febd33a024d24f2bee3f67e5889466d8b60 | 1,923 | cpp | C++ | intro/knight_scape.cpp | eder-matheus/programming_challenges | 9d318bf5b8df18f732c07e60aa72b302ea887419 | [
"BSD-3-Clause"
] | null | null | null | intro/knight_scape.cpp | eder-matheus/programming_challenges | 9d318bf5b8df18f732c07e60aa72b302ea887419 | [
"BSD-3-Clause"
] | null | null | null | intro/knight_scape.cpp | eder-matheus/programming_challenges | 9d318bf5b8df18f732c07e60aa72b302ea887419 | [
"BSD-3-Clause"
] | 1 | 2021-08-24T17:18:54.000Z | 2021-08-24T17:18:54.000Z | // knight scape
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
const int dimension = 8;
const int num_pieces = 9;
void findKnightMoviments(int row, int col, std::vector<std::pair<int, int> >& movements) {
for (int r = -2; r <= 2; r++) {
for (int c = -2; c <= 2; c++) {
if ((abs(r) == 2 && abs(c) == 1) ||
(abs(r) == 1 && abs(c) == 2)) {
if (((row + r) >= 0 && (row + r) < dimension) &&
((col + c) >= 0 && (col + c) < dimension)) {
movements.push_back(std::pair<int, int>(row+r, col+c));
}
}
}
}
}
void findPawnsAttacks(int row, int col, std::vector<std::pair<int, int> >& movements) {
int attack_row = row - 1;
int attack_col1 = col + 1;
int attack_col2 = col - 1;
if (attack_row < dimension) {
if (attack_col1 < dimension) {
movements.erase(
std::remove(
movements.begin(),
movements.end(),
std::pair<int, int>(attack_row, attack_col1)),
movements.end());
}
if (attack_col2 >= 0) {
movements.erase(
std::remove(
movements.begin(),
movements.end(),
std::pair<int, int>(attack_row, attack_col2)),
movements.end());
}
}
}
int main() {
int row = -1;
char column;
std::vector<std::pair<int, int> > movements;
int cnt = 0;
int test = 1;
while (row != 0) {
scanf("%d%c", &row, &column);
int col = (int)column - 96;
// first row of input --> knight position
if (cnt == 0) {
findKnightMoviments(row-1, col-1, movements);
} else { // other rows --> pawns position
findPawnsAttacks(row-1, col-1, movements);
}
cnt++;
if (cnt == num_pieces) {
std::cout << "Caso de Teste #" << test << ": " << movements.size() << " movimento(s).\n";
cnt = 0;
test++;
movements.clear();
}
}
return 0;
}
| 24.341772 | 95 | 0.514301 | eder-matheus |
5622aa0f33e74cba4f4bb881ff2fc714394f2d5d | 4,264 | cpp | C++ | wnd/block_info_dlg.cpp | HyperBlockChain/Hyperchain-Core-YH | 2a7c4ac23f27c2034a678e61c2474e0008f5135e | [
"MIT"
] | 1 | 2019-08-30T07:36:33.000Z | 2019-08-30T07:36:33.000Z | wnd/block_info_dlg.cpp | HyperBlockChain/Hyperchain-Core-YH | 2a7c4ac23f27c2034a678e61c2474e0008f5135e | [
"MIT"
] | null | null | null | wnd/block_info_dlg.cpp | HyperBlockChain/Hyperchain-Core-YH | 2a7c4ac23f27c2034a678e61c2474e0008f5135e | [
"MIT"
] | 2 | 2019-11-01T03:39:57.000Z | 2020-03-26T06:21:22.000Z | /*Copyright 2016-2018 hyperchain.net (Hyperchain)
Distributed under the MIT software license, see the accompanying
file COPYING or https://opensource.org/licenses/MIT
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 "block_info_dlg.h"
#include "customui/base_frameless_wnd.h"
#include "channel/block_info_channel.h"
#include <QTextCodec>
#include <QtWebEngineWidgets/QWebEngineSettings>
#include <QtWebEngineWidgets/QWebEngineView>
#include <QtWebChannel/QWebChannel>
#include <QApplication>
#include <QVariantMap>
#include <QDebug>
block_info_dlg::block_info_dlg(QObject *parent) : QObject(parent)
{
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
init();
}
void block_info_dlg::show(bool bShow)
{
dlg_->setHidden(!bShow);
}
void block_info_dlg::setGeometry(QRect rect)
{
dlg_->setGeometry(rect);
}
void block_info_dlg::refreshNodeInfo(QSharedPointer<TBLOCKINFO> pNodeInfo)
{
static int64 MAX_TIME_S = 9999999999;
QVariantMap m;
m["blockNum"] = (qint64)(pNodeInfo->iBlockNo);
m["fileName"] = QString::fromStdString(pNodeInfo->tPoeRecordInfo.cFileName);
m["customInfo"] = QString::fromStdString(pNodeInfo->tPoeRecordInfo.cCustomInfo);
m["rightOwner"] = QString::fromStdString(pNodeInfo->tPoeRecordInfo.cRightOwner);
m["fileHash"] = QString::fromStdString(pNodeInfo->tPoeRecordInfo.cFileHash);
m["regTime"] = (qint64)(pNodeInfo->tPoeRecordInfo.tRegisTime);
m["fileSize"] = (qint64)(pNodeInfo->tPoeRecordInfo.iFileSize);
m["fileState"] = pNodeInfo->tPoeRecordInfo.iFileState;
emit reg_->sigNewBlockInfo(m);
}
bool block_info_dlg::hasFcous()
{
return dlg_->hasFocus();
}
void block_info_dlg::setFocus()
{
dlg_->setFocus();
}
void block_info_dlg::setLanguage(int lang)
{
reg_->sigChangeLang(lang);
}
void block_info_dlg::onMouseEnter(QEvent *event)
{
mouseEnter_ = true;
}
void block_info_dlg::onMouseLeave(QEvent *event)
{
mouseEnter_ = false;
dlg_->hide();
}
void block_info_dlg::init()
{
dlg_ = QSharedPointer<base_frameless_wnd>(new base_frameless_wnd());
dlg_->setScale(false);
dlg_->showTitleBar(false);
dlg_->setGeometry(QRect(0,0,200,300));
dlg_->hide();
connect(dlg_.data(), &base_frameless_wnd::sigEnter, this, &block_info_dlg::onMouseEnter);
connect(dlg_.data(), &base_frameless_wnd::sigLeave, this, &block_info_dlg::onMouseLeave);
Qt::WindowFlags flags = dlg_->windowFlags();
flags |= Qt::ToolTip;
dlg_->setWindowFlags(flags);
view_ = new QWebEngineView((QWidget*)dlg_.data()->content_);
view_->setAcceptDrops(false);
dlg_->addWidget(view_);
QWebChannel *channel = new QWebChannel(this);
reg_ = new block_info_channel(this);
channel->registerObject(QString("qBlockInfo"), reg_);
view_->page()->setWebChannel(channel);
#ifdef QT_DEBUG
#if defined (Q_OS_WIN)
QString str = QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("../../ui/view/blockinfo.html");
#else
QString str = QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("../ui/view/blockinfo.html");
#endif
#else
QString str = QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("ui/view/blockinfo.html");
#endif
view_->page()->load(QUrl(str));
}
| 30.457143 | 123 | 0.739212 | HyperBlockChain |
562dd6271c974c01c0876e325eb533931807e451 | 159 | cpp | C++ | CPP_Projects/Studying/ConsoleApplication1/ConsoleApplication1/pr1.cpp | GUNU-GO/SNUPI | a73137699d9fc6ae8fa3d1522f341c04d8d43052 | [
"MIT"
] | null | null | null | CPP_Projects/Studying/ConsoleApplication1/ConsoleApplication1/pr1.cpp | GUNU-GO/SNUPI | a73137699d9fc6ae8fa3d1522f341c04d8d43052 | [
"MIT"
] | null | null | null | CPP_Projects/Studying/ConsoleApplication1/ConsoleApplication1/pr1.cpp | GUNU-GO/SNUPI | a73137699d9fc6ae8fa3d1522f341c04d8d43052 | [
"MIT"
] | null | null | null | #include <stdio.h>
int main() {
int num;
scanf_s("%d", &num);
for(int i = 1; i <= num; i++) {
if (num % i == 0) {
printf("%d, ",i);
}
}
}W | 9.9375 | 32 | 0.415094 | GUNU-GO |
562f2b292e7b632be0821c80de2481a80dc30153 | 3,701 | hpp | C++ | include/haz/Tools/EnumFlag.hpp | Hazurl/Framework-haz | 370348801cd969ce8521264653069923a255e0b0 | [
"MIT"
] | null | null | null | include/haz/Tools/EnumFlag.hpp | Hazurl/Framework-haz | 370348801cd969ce8521264653069923a255e0b0 | [
"MIT"
] | null | null | null | include/haz/Tools/EnumFlag.hpp | Hazurl/Framework-haz | 370348801cd969ce8521264653069923a255e0b0 | [
"MIT"
] | null | null | null | #ifndef __HAZ_ENUM_FLAG
#define __HAZ_ENUM_FLAG
#include <haz/Tools/Macro.hpp>
#include <type_traits>
#define ENUM_FLAG(name, bloc_enum...)\
BEG_NAMESPACE_HAZ_HIDDEN namespace enumFlagNamespace { \
enum class UNIQUE_NAME(name) \
bloc_enum; \
} END_NAMESPACE_HAZ_HIDDEN \
typedef haz::__hide::enumFlagNamespace::UNIQUE_NAME(name) name
#define ENUM_FLAG_NESTED(beg_ns, end_ns, name, bloc_enum...)\
BEG_NAMESPACE_HAZ_HIDDEN namespace enumFlagNamespace { \
enum class UNIQUE_NAME(name) \
bloc_enum; \
} END_NAMESPACE_HAZ_HIDDEN \
beg_ns typedef haz::__hide::enumFlagNamespace::UNIQUE_NAME(name) name; end_ns
BEG_NAMESPACE_HAZ_HIDDEN
namespace enumFlagNamespace {
#define TEMPLATE_RESTRICTIONS(T) typename = typename std::enable_if<std::is_enum<T>::value, T>::type
#define CAST_UNDER_TYPE(T) static_cast<typename std::underlying_type<T>::type>
template<typename T, TEMPLATE_RESTRICTIONS(T)>
class auto_bool
{
T value;
public:
constexpr auto_bool(T value) : value(value) {}
constexpr operator T() const { return value; }
constexpr operator bool() const
{
return CAST_UNDER_TYPE(T)(value) != 0;
}
};
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr auto_bool<T> operator&(T lhs, T rhs) {
return static_cast<T>(CAST_UNDER_TYPE(T)(lhs) & CAST_UNDER_TYPE(T)(rhs));
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T operator|(T lhs, T rhs) {
return static_cast<T>(CAST_UNDER_TYPE(T)(lhs) | CAST_UNDER_TYPE(T)(rhs));
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T operator^(T lhs, T rhs) {
return static_cast<T>(CAST_UNDER_TYPE(T)(lhs) ^ CAST_UNDER_TYPE(T)(rhs));
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T& operator|=(T& lhs, T rhs) {
return lhs = (lhs | rhs);
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T& operator&=(T& lhs, T rhs) {
return lhs = (lhs & rhs);
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T& operator^=(T& lhs, T rhs) {
return lhs = (lhs ^ rhs);
}
template<typename T, TEMPLATE_RESTRICTIONS(T)>
constexpr T operator~(T t) {
return static_cast<T>(~ CAST_UNDER_TYPE(T)(t));
}
}
#define IMPLM_ENUM_FLAP_OP(name) \
inline constexpr ::haz::__hide::enumFlagNamespace::auto_bool<name> operator & (name lhs, name rhs) { \
return static_cast<name>( \
static_cast<typename std::underlying_type<name>::type>(lhs) \
& static_cast<typename std::underlying_type<name>::type>(rhs) \
); \
} \
inline constexpr name operator | (name lhs, name rhs) { \
return static_cast<name>( \
static_cast<typename std::underlying_type<name>::type>(lhs) \
| static_cast<typename std::underlying_type<name>::type>(rhs) \
); \
} \
inline constexpr name operator ^ (name lhs, name rhs) { \
return static_cast<name>( \
static_cast<typename std::underlying_type<name>::type>(lhs) \
^ static_cast<typename std::underlying_type<name>::type>(rhs) \
); \
} \
inline constexpr name& operator &= (name& lhs, name rhs) { \
return lhs = (lhs & rhs); \
} \
inline constexpr name& operator |= (name& lhs, name rhs) { \
return lhs = (lhs | rhs); \
} \
inline constexpr name& operator ^= (name& lhs, name rhs) { \
return lhs = (lhs ^ rhs); \
} \
inline constexpr name operator ~ (name lhs) { \
return static_cast<name>( \
~ static_cast<typename std::underlying_type<name>::type>(lhs) \
); \
}
#undef TEMPLATE_RESTRICTIONS
#undef CAST_UNDER_TYPE
END_NAMESPACE_HAZ_HIDDEN
#endif | 31.905172 | 102 | 0.663334 | Hazurl |
5631846960b9848c74957911364c8b9b629890bf | 13,072 | cc | C++ | google/cloud/apigateway/api_gateway_client.cc | jmouradi-google/google-cloud-cpp | 7bd738251a80e9520d7a7de4cc14558f161c8edc | [
"Apache-2.0"
] | null | null | null | google/cloud/apigateway/api_gateway_client.cc | jmouradi-google/google-cloud-cpp | 7bd738251a80e9520d7a7de4cc14558f161c8edc | [
"Apache-2.0"
] | null | null | null | google/cloud/apigateway/api_gateway_client.cc | jmouradi-google/google-cloud-cpp | 7bd738251a80e9520d7a7de4cc14558f161c8edc | [
"Apache-2.0"
] | null | null | null | // Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://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.
// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/apigateway/v1/apigateway_service.proto
#include "google/cloud/apigateway/api_gateway_client.h"
#include "google/cloud/apigateway/internal/api_gateway_option_defaults.h"
#include <memory>
namespace google {
namespace cloud {
namespace apigateway {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
ApiGatewayServiceClient::ApiGatewayServiceClient(
std::shared_ptr<ApiGatewayServiceConnection> connection, Options options)
: connection_(std::move(connection)),
options_(internal::MergeOptions(
std::move(options),
apigateway_internal::ApiGatewayServiceDefaultOptions(
connection_->options()))) {}
ApiGatewayServiceClient::~ApiGatewayServiceClient() = default;
StreamRange<google::cloud::apigateway::v1::Gateway>
ApiGatewayServiceClient::ListGateways(std::string const& parent,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::ListGatewaysRequest request;
request.set_parent(parent);
return connection_->ListGateways(request);
}
StreamRange<google::cloud::apigateway::v1::Gateway>
ApiGatewayServiceClient::ListGateways(
google::cloud::apigateway::v1::ListGatewaysRequest request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->ListGateways(std::move(request));
}
StatusOr<google::cloud::apigateway::v1::Gateway>
ApiGatewayServiceClient::GetGateway(std::string const& name, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::GetGatewayRequest request;
request.set_name(name);
return connection_->GetGateway(request);
}
StatusOr<google::cloud::apigateway::v1::Gateway>
ApiGatewayServiceClient::GetGateway(
google::cloud::apigateway::v1::GetGatewayRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->GetGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::Gateway>>
ApiGatewayServiceClient::CreateGateway(
std::string const& parent,
google::cloud::apigateway::v1::Gateway const& gateway,
std::string const& gateway_id, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::CreateGatewayRequest request;
request.set_parent(parent);
*request.mutable_gateway() = gateway;
request.set_gateway_id(gateway_id);
return connection_->CreateGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::Gateway>>
ApiGatewayServiceClient::CreateGateway(
google::cloud::apigateway::v1::CreateGatewayRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->CreateGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::Gateway>>
ApiGatewayServiceClient::UpdateGateway(
google::cloud::apigateway::v1::Gateway const& gateway,
google::protobuf::FieldMask const& update_mask, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::UpdateGatewayRequest request;
*request.mutable_gateway() = gateway;
*request.mutable_update_mask() = update_mask;
return connection_->UpdateGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::Gateway>>
ApiGatewayServiceClient::UpdateGateway(
google::cloud::apigateway::v1::UpdateGatewayRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->UpdateGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteGateway(std::string const& name,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::DeleteGatewayRequest request;
request.set_name(name);
return connection_->DeleteGateway(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteGateway(
google::cloud::apigateway::v1::DeleteGatewayRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->DeleteGateway(request);
}
StreamRange<google::cloud::apigateway::v1::Api>
ApiGatewayServiceClient::ListApis(std::string const& parent, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::ListApisRequest request;
request.set_parent(parent);
return connection_->ListApis(request);
}
StreamRange<google::cloud::apigateway::v1::Api>
ApiGatewayServiceClient::ListApis(
google::cloud::apigateway::v1::ListApisRequest request, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->ListApis(std::move(request));
}
StatusOr<google::cloud::apigateway::v1::Api> ApiGatewayServiceClient::GetApi(
std::string const& name, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::GetApiRequest request;
request.set_name(name);
return connection_->GetApi(request);
}
StatusOr<google::cloud::apigateway::v1::Api> ApiGatewayServiceClient::GetApi(
google::cloud::apigateway::v1::GetApiRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->GetApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::Api>>
ApiGatewayServiceClient::CreateApi(
std::string const& parent, google::cloud::apigateway::v1::Api const& api,
std::string const& api_id, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::CreateApiRequest request;
request.set_parent(parent);
*request.mutable_api() = api;
request.set_api_id(api_id);
return connection_->CreateApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::Api>>
ApiGatewayServiceClient::CreateApi(
google::cloud::apigateway::v1::CreateApiRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->CreateApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::Api>>
ApiGatewayServiceClient::UpdateApi(
google::cloud::apigateway::v1::Api const& api,
google::protobuf::FieldMask const& update_mask, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::UpdateApiRequest request;
*request.mutable_api() = api;
*request.mutable_update_mask() = update_mask;
return connection_->UpdateApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::Api>>
ApiGatewayServiceClient::UpdateApi(
google::cloud::apigateway::v1::UpdateApiRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->UpdateApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteApi(std::string const& name, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::DeleteApiRequest request;
request.set_name(name);
return connection_->DeleteApi(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteApi(
google::cloud::apigateway::v1::DeleteApiRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->DeleteApi(request);
}
StreamRange<google::cloud::apigateway::v1::ApiConfig>
ApiGatewayServiceClient::ListApiConfigs(std::string const& parent,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::ListApiConfigsRequest request;
request.set_parent(parent);
return connection_->ListApiConfigs(request);
}
StreamRange<google::cloud::apigateway::v1::ApiConfig>
ApiGatewayServiceClient::ListApiConfigs(
google::cloud::apigateway::v1::ListApiConfigsRequest request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->ListApiConfigs(std::move(request));
}
StatusOr<google::cloud::apigateway::v1::ApiConfig>
ApiGatewayServiceClient::GetApiConfig(std::string const& name,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::GetApiConfigRequest request;
request.set_name(name);
return connection_->GetApiConfig(request);
}
StatusOr<google::cloud::apigateway::v1::ApiConfig>
ApiGatewayServiceClient::GetApiConfig(
google::cloud::apigateway::v1::GetApiConfigRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->GetApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::ApiConfig>>
ApiGatewayServiceClient::CreateApiConfig(
std::string const& parent,
google::cloud::apigateway::v1::ApiConfig const& api_config,
std::string const& api_config_id, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::CreateApiConfigRequest request;
request.set_parent(parent);
*request.mutable_api_config() = api_config;
request.set_api_config_id(api_config_id);
return connection_->CreateApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::ApiConfig>>
ApiGatewayServiceClient::CreateApiConfig(
google::cloud::apigateway::v1::CreateApiConfigRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->CreateApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::ApiConfig>>
ApiGatewayServiceClient::UpdateApiConfig(
google::cloud::apigateway::v1::ApiConfig const& api_config,
google::protobuf::FieldMask const& update_mask, Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::UpdateApiConfigRequest request;
*request.mutable_api_config() = api_config;
*request.mutable_update_mask() = update_mask;
return connection_->UpdateApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::ApiConfig>>
ApiGatewayServiceClient::UpdateApiConfig(
google::cloud::apigateway::v1::UpdateApiConfigRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->UpdateApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteApiConfig(std::string const& name,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
google::cloud::apigateway::v1::DeleteApiConfigRequest request;
request.set_name(name);
return connection_->DeleteApiConfig(request);
}
future<StatusOr<google::cloud::apigateway::v1::OperationMetadata>>
ApiGatewayServiceClient::DeleteApiConfig(
google::cloud::apigateway::v1::DeleteApiConfigRequest const& request,
Options options) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(options), options_));
return connection_->DeleteApiConfig(request);
}
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace apigateway
} // namespace cloud
} // namespace google
| 38.789318 | 79 | 0.746558 | jmouradi-google |
56323b24a47b69b41fa0fd4d8431e279aaebc438 | 6,614 | hpp | C++ | OcularCore/include/Math/Bounds/BoundsOBB.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 8 | 2017-01-27T01:06:06.000Z | 2020-11-05T20:23:19.000Z | OcularCore/include/Math/Bounds/BoundsOBB.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 39 | 2016-06-03T02:00:36.000Z | 2017-03-19T17:47:39.000Z | OcularCore/include/Math/Bounds/BoundsOBB.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 4 | 2019-05-22T09:13:36.000Z | 2020-12-01T03:17:45.000Z | /**
* Copyright 2014-2017 Steven T Sell ([email protected])
*
* 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.
*/
#pragma once
#ifndef __H__OCULAR_MATH_BOUNDS_OBB__H__
#define __H__OCULAR_MATH_BOUNDS_OBB__H__
#include "Math/Bounds/Bounds.hpp"
#include "Math/Vector3.hpp"
//------------------------------------------------------------------------------------------
/**
* \addtogroup Ocular
* @{
*/
namespace Ocular
{
/**
* \addtogroup Math
* @{
*/
namespace Math
{
class Ray;
class BoundsSphere;
class BoundsAABB;
class Plane;
/**
* \class BoundsOBB
*
* Implementation of an Oriented Bounding Box.
*
* Essentially an OBB is an AABB that can be arbitrarily rotated.
* They are more expensive to create and their intersection tests
* are more complicated, but have the benefit of not needing to
* be recalculated every time their contents are rotated.
*
* Additionally, in most cases an OBB will also provide a tighter
* fit than an AABB.
*/
class BoundsOBB : public Bounds
{
public:
BoundsOBB(Vector3f const& center, Vector3f const& extents, Vector3f const& xDir, Vector3f const& yDir, Vector3f const& zDir);
BoundsOBB();
~BoundsOBB();
/**
* Returns the center of the bounding box.
*/
Vector3f const& getCenter() const;
/**
* /param[in] center
*/
void setCenter(Vector3f const& center);
/**
* Returns the positive half-lengths of the box.
* These are the distances along each local axis to the box edge.
*/
Vector3f const& getExtents() const;
/**
* /param[in] extents
*/
void setExtents(Vector3f const& extents);
/**
* Returns the normalized direction of the x-axis of the bounding box.
*/
Vector3f const& getDirectionX() const;
/**
* /param[in] dirX
*/
void setDirectionX(Vector3f const& dirX);
/**
* Returns the normalized direction of the y-axis of the bounding box.
*/
Vector3f const& getDirectionY() const;
/**
* /param[in] dirY
*/
void setDirectionY(Vector3f const& dirY);
/**
* Returns the normalized direction of the z-axis of the bounding box.
*/
Vector3f const& getDirectionZ() const;
/**
* /param[in] dirZ
*/
void setDirectionZ(Vector3f const& dirZ);
//------------------------------------------------------------------------------
// Intersection and Containment Testing
//------------------------------------------------------------------------------
/**
* Performs an intersection test on a ray and OBB.
*
* \param[in] ray
* \return TRUE if the ray and OBB intersect.
*/
bool intersects(Ray const& ray) const;
/**
* Performs an intersection test on a bounding sphere and OBB.
*
* \param[in] bounds
* \return TRUE if the bounding sphere and OBB intersect.
*/
bool intersects(BoundsSphere const& bounds) const;
/**
* Performs an intersection test on a AABB and OBB.
*
* \param[in] bounds
* \return TRUE if the AABB and OBB intersect.
*/
bool intersects(BoundsAABB const& bounds) const;
/**
* Performs an intersection test on two OBBs.
*
* \param[in] bounds
* \return TRUE if the two OBBs intersect.
*/
bool intersects(BoundsOBB const& bounds) const;
/**
* Performs an intersection test on a plane and OBB.
*
* If the result is Inside, then the OBB is located entirely within the plane's positive half space. <br/>
* If the result is Outside, then the OBB is located entirely outside the plane's positive half space.
*
* The positive half space of the plane is the direction that the plane is facing, as described by it's normal.
*
* As an example, say we have the plane defined as:
*
* Point: (0.0, 0.0, 0.0)
* Normal: (0.0, 1.0, 0.0)
*
* The plane is 'facing up' along the world origin.
*
* If the intersection test returns Outside, then the AABB is entirely in the +y world space. <br/>
* If the intersection test returns Inside, then the AABB is entirely in the -y world space.
*
* \param[in] plane
* \param[out] result Detailed intersection result.
*
* \return TRUE if the plane and OBB intersects, otherwise FALSE.
*/
bool intersects(Plane const& plane, IntersectionType* result = nullptr) const;
protected:
private:
Vector3f m_Center; ///< Center point of the box
Vector3f m_Extents; ///< Positive half-lengths
Vector3f m_DirectionX; ///< Normalized direction of the X side direction
Vector3f m_DirectionY; ///< Normalized direction of the Y side direction
Vector3f m_DirectionZ; ///< Normalized direction of the Z side direction
};
}
/**
* @} End of Doxygen Groups
*/
}
/**
* @} End of Doxygen Groups
*/
//------------------------------------------------------------------------------------------
#endif | 33.40404 | 137 | 0.508164 | ssell |
563b8cea31f72e9688e73cb8ae99652284e35afc | 8,870 | hpp | C++ | roller_eye/test/bist/BistNode.hpp | lorenzo-bianchi/Scout-open-source | ca20d3112388f47a36a245de5de1a35673afd260 | [
"MIT"
] | 35 | 2022-03-12T01:36:17.000Z | 2022-03-28T14:56:13.000Z | roller_eye/test/bist/BistNode.hpp | lorenzo-bianchi/Scout-open-source | ca20d3112388f47a36a245de5de1a35673afd260 | [
"MIT"
] | null | null | null | roller_eye/test/bist/BistNode.hpp | lorenzo-bianchi/Scout-open-source | ca20d3112388f47a36a245de5de1a35673afd260 | [
"MIT"
] | 9 | 2022-03-12T01:39:43.000Z | 2022-03-31T20:54:19.000Z | #include <iostream>
#include <cstdlib>
#include <thread> // std::thread
#include <mutex> // std::mutex, std::unique_lock
#include <condition_variable>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/select.h>
#include <linux/input.h>
#include "zlog.h"
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
#include "roller_eye/ros_tools.h"
#include "roller_eye/motor.h"
#include "roller_eye/plt_assert.h"
#include <iostream>
#include <fstream>
#include "roller_eye/camera_handle.hpp"
#include "roller_eye/algo_utils.h"
#include "roller_eye/status_publisher.h"
#include "roller_eye/cv_img_stream.h"
#include "roller_eye/SensorBase.h"
#include "roller_eye/plt_tools.h"
#include "roller_eye/plt_config.h"
#include "roller_eye/wifi_ops.h"
#include "sensor_msgs/Illuminance.h"
#include "roller_eye/cv_img_stream.h"
#include "std_msgs/Int32.h"
#include "roller_eye/track_trace.h"
#include "roller_eye/recorder_mgr.h"
#include <roller_eye/wifi_ops.h>
#include "roller_eye/sound_effects_mgr.h"
#include "roller_eye/start_bist.h"
#include "roller_eye/get_bist_result.h"
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/core/core.hpp>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Geometry>
#include <cv_bridge/cv_bridge.h>
using namespace roller_eye;
#define DETECT_ROLL_SPEED (1.5)
#define BIST_BOOT_ERROR 1
#define BIST_WFI_ERROR 2
#define BIST_KEY_PRESSING_ERROR 3
#define BIST_LIGHT_SENSOR_ERROR 4
#define BIST_SOUND_ERROR 5
#define BIST_TOF_ERROR 6
#define BIST_IMU_ERROR 7
#define BIST_MOTOR_WHEELS_ERROR 8
#define BIST_CAMERA_RESOLUTION_ERROR 9
#define BIST_CAMERA_DISTORTION_ERROR 10
#define BIST_BATTERY_ERROR 11
#define BIST_IRLIGHT_ERROR 12
#define BIST_BATTERY_WIFIANTENNA_ERROR 13
#define BIST_MEMERY_ERROR 14
#define BIST_DISK_ERROR 15
#define RESET_KEY_LONG_PRESS_TIME (500)
#define WIFI_KEY_LONG_PRESS_TIME (500)
#define POWER_KEY_LONGPRESS_TIME (500)
#define BIST_DETECT_W 640
#define BIST_DETECT_H 480
#define BIST_DETECT "/var/roller_eye/devAudio/got_new_instruction/got_new_instrction.wav"
#define NAV_OUT_SPEED 0.4
#define BIST_MOVE_DIST 0.5
#define CHESSBAORD_ROW 5
#define CHESSBAORD_COL 5
#define CHESSBAORD_SIZE 0.0065
#define CAM_K_FX 720.5631606
#define CAM_K_FY 723.6323653
#define CAM_K_CX 659.39411452
#define CAM_K_CY 369.00731648
#define DISTRO_K1 -0.36906219
#define DISTRO_K2 0.16914887
#define DISTRO_P1 -0.00147033
#define DISTRO_P2 -0.00345135
#define CAR_LENGTH (0.1)
#define ALIGN_DISTANCE 0.16
#define MEM_SIZE 900000
#define DISK_SIZE 7.0 //GB
class CompGreater
{
public:
bool operator ()(const WiFiInFo& info1, const WiFiInFo& info2)
{
return info1.signal > info2.signal;
}
};
class BistNode{
public:
BistNode();
~BistNode();
private:
void MotorWheelCB(const detectConstPtr& obj);
void tofDataCB(const sensor_msgs::RangeConstPtr &r);
void odomRelativeCB(const nav_msgs::Odometry::ConstPtr& msg);
void BatteryStatusCB(const statusConstPtr &s);
void IlluminanceCB(const sensor_msgs::IlluminanceConstPtr& ptr);
void IRLightCB(const sensor_msgs::IlluminanceConstPtr& ptr);
void imuCB(const sensor_msgs::Imu::ConstPtr& msg);
void VideoDataCB(roller_eye::frameConstPtr frame);
void calDistanceAndAngle(Eigen::Quaterniond& q,Eigen::Vector3d& pos,Eigen::Vector3d &goal,double &angle,double &distance);
void LEDControl(int id,int flag)
{
static const char* ids[]={"gpio02_","gpio03_","gpio04_","gpio05_"};
static const char* flags[]={"0", "1"};
char buff[16];
//PLOG_INFO("bist","LEDControl %d",id);
snprintf(buff,sizeof(buff),"%s%s\n",ids[id],flags[flag]);
ofstream of(LED_PATH);
if(!of){
PLOG_ERROR("bist","can't not open %s\n",LED_PATH.c_str());
return;
}
of<<buff<<std::flush;
}
void logInit(){
log_t arg = {
confpath: "/var/roller_eye/config/log/bist.cfg",
levelpath: "/var/roller_eye/config/log/bist.level",
logpath: "/var/log/node/bistNode.log",
cname: "bist"
};
int ret = dzlogInit(&arg,2);
system("echo 20 > /var/roller_eye/config/log/bist.level");
printf("dzlogInit:%d\r\n",ret);
zlog_category_t *zc = zlog_get_category("bist");
zlog_level_switch(zc,20);
}
void LEDProcess(int flag);
void LEDStatus(int flag);
void LEDAllON();
void LEDAllOFF();
void IrLightOn();
void IrLightOff();
void PCMAnalysis(int type = 0);
void PCMgeneration();
float ImagArticulation(const cv::Mat &image);
int pcm2wave(const char *pcmpath, int channels, int sample_rate, const char *wavepath);
void BistSaveImage();
void JpgCallback(roller_eye::frameConstPtr frame);
void getPose(float &lastX,float &lastY,float &angle);
//void GreyImagCallback(const sensor_msgs::ImageConstPtr& msg);
void BistVideoDetect();
void BistTofDetect();
void BistSpeakerMicrophoneDetect();
void BistKeyDetect();
void BistWIFIDetect();
void BistBatteryDetect();
void BistLightDetect();
void BistIMUDetect();
void BistMotorWheelsDetect();
void BistIRLightDetect();
void BistWIFIAntennaDetect();
void BistMemDetect();
void BistDiskDetect();
void BistDriveMotor();
void BistPCBIMUDetect();
void BistPCBTofDetect();
void BistMicrophoneDetect();
void BistPCBVideoDetect();
AlgoUtils mAlgo;
float mRange = 0.0;
float mPCBRange = 0.0;
double mDistance = 0.0;
double mAngle = 0.0;
int mCharging = -1;
double mArticulation = 0.0;
//mutex mBistMutex;
std::mutex mtx;
std::condition_variable cv;
const string LED_PATH="/proc/driver/gpioctl";
const string LOG_CFG="/var/roller_eye/config/log.conf";
const string LOG_LEVEL="/var/roller_eye/config/log.level";
const string PCMFILE="/tmp/test.pcm";
const string PCM2WAVFILE="/tmp/pcm2wav.wav";
const string WAVFILE="/tmp/test.wav";
const string BistImage="/userdata/Bist.jpg";
int mPcmHzs[3] = {0};
bool mIllumMin = false;
bool mIllumMax = false;
//ir light off
int mIRLightOffValu = 0;
int mIRLightOffCount = 0;
bool mIrLightOff = false;
//ir light on
int mIRLightOnValu = 0;
int mIRLightOnCount = 0;
bool mIrLightOn = false;
//key
int mWiFiFD;
int mResetFD;
int mPowerFD;
int IllumCount;
const string WIFI_KEY_TYPE="rk29-keypad";
const string RESET_KEY_TYPE = "adc-keys";
const string POWER_KEY_TYPE = "rk8xx_pwrkey";
struct timeval mLastResetTime;
struct timeval mLastWifiTime;
struct timeval mLastPowerTime;
bool mWiFiKey = false;
bool mResetKey = false;
bool mPowerKey = false;
void processResetKey();
void processWiFiKey();
void processPowerKey();
void KeyStatusLoop();
void BistLoop();
void BistReset();
void BistStatus();
void scanWiFilist(vector<WiFiInFo>& wifis );
void scanWiFiQuality(vector<WiFiInFo>& wifis );
void BistGreyImage();
void BistMatImage();
void JpgMatCb(roller_eye::frameConstPtr frame);
bool start(roller_eye::start_bistRequest &req, roller_eye::start_bistResponse &resp);
bool getResult(roller_eye::get_bist_resultRequest &req, roller_eye::get_bist_resultResponse &resp);
int mBistType;
bool mBistStartDetct = false;
bool mBistAllPassed = false;
bool mBistVideoRes = false;
bool mBistVideoDis = false;
bool mBistVideoJpg = false;
bool mBistTof = false;
bool mSpeakerMicrophone = false;
bool mKey = false;
bool mWifi = false;
bool mWIFIAntenna = false;
bool mBattery = false;
bool mLight = false;
bool mIRLight = false;
bool mIMU = false;
bool mMotorWheel = false;
bool mMemery = false;
bool mDisk = false;
bool mDetectRunning = false;
Eigen::Quaterniond mCurPose;
Eigen::Vector3d mCurPostion;
//CVGreyImageStream mGreyStream;
ros::Subscriber m_subJPG;
ros::Subscriber m_BistJPG;
ros::Subscriber m_subGrey;
cv::Mat m_BistGrey;
vector<uint8_t> mGreyData;
ros::Subscriber mTof;
ros::Subscriber mVideo;
ros::Subscriber mOdomRelative;
ros::Subscriber mBatteryStatus;
ros::Subscriber mScrLight;
ros::Subscriber mScrIMU;
ros::ServiceClient mImuClient;
shared_ptr<ros::NodeHandle> mGlobal;
ros::Publisher mSysEvtPub;
ros::Publisher mPub;
ros::Publisher mCmdVel;
ros::NodeHandle mGlobal2;
ros::Subscriber mSwitch;
ros::Publisher mCmdVel3;
ros::ServiceServer mStartBistSrv;
ros::ServiceServer mGetBistResSrv;
//ros::NodeHandle mGlobal1;
};
| 29.177632 | 123 | 0.700225 | lorenzo-bianchi |
563bce5a28baa6518a4d23f7c19f34b17e37eea5 | 1,843 | cpp | C++ | src/arduino_signalbox.cpp | dniklaus/arduino-signalbox | 8c4a2be46b69cb1d74278f8c76690a531fec4776 | [
"MIT"
] | null | null | null | src/arduino_signalbox.cpp | dniklaus/arduino-signalbox | 8c4a2be46b69cb1d74278f8c76690a531fec4776 | [
"MIT"
] | null | null | null | src/arduino_signalbox.cpp | dniklaus/arduino-signalbox | 8c4a2be46b69cb1d74278f8c76690a531fec4776 | [
"MIT"
] | null | null | null | // Do not remove the include below
#include "arduino_signalbox.h"
#include "Timer.h" // https://github.com/dniklaus/arduino-utils-timer
#include "ToggleButton.h" // https://github.com/dniklaus/arduino-toggle-button
#include "Blanking.h" // https://github.com/dniklaus/arduino-utils-blanking
#include "Point.h"
const int cPt05BtnDev = 32;
const int cPt05BtnStr = 33;
const int cPt05IndDev = 34;
const int cPt05IndStr = 35;
const int cPt20BtnDev = 44;
const int cPt20BtnStr = 45;
const int cPt20IndDev = 46;
const int cPt20IndStr = 47;
const int cPt21BtnDev = 40;
const int cPt21BtnStr = 41;
const int cPt21IndDev = 42;
const int cPt21IndStr = 43;
const int cPt22BtnDev = 36;
const int cPt22BtnStr = 37;
const int cPt22IndDev = 38;
const int cPt22IndStr = 39;
const int cPt23BtnDev = 22;
const int cPt23BtnStr = 23;
const int cPt23Ind1 = 27;
const int cPt23Ind2 = 26;
const int cPt23Ind3 = 24;
const int cPt23Ind4 = 25;
const int cPt24BtnDev = 28;
const int cPt24BtnStr = 29;
const int cPt24IndDev = 30;
const int cPt24IndStr = 31;
class Point* pt05;
class Point* pt20;
class Point* pt21;
class Point* pt22;
class Point* pt23;
class Point* pt24;
//-----------------------------------------------------------------------------
void setup()
{
Serial.begin(115200);
Serial.println(F("Hello from Signal Box Arduino Application!\n"));
pt05 = new Point(cPt05BtnDev, cPt05BtnStr, cPt05IndDev, cPt05IndStr);
pt20 = new Point(cPt20BtnDev, cPt20BtnStr, cPt20IndDev, cPt20IndStr);
pt21 = new Point(cPt21BtnDev, cPt21BtnStr, cPt21IndDev, cPt21IndStr);
pt22 = new Point(cPt22BtnDev, cPt22BtnStr, cPt22IndDev, cPt22IndStr);
pt23 = new Crossing(cPt23BtnDev, cPt23BtnStr, cPt23Ind1, cPt23Ind2, cPt23Ind3, cPt23Ind4);
pt24 = new Point(cPt24BtnDev, cPt24BtnStr, cPt24IndDev, cPt24IndStr);
}
void loop()
{
yield();
}
| 27.507463 | 92 | 0.705372 | dniklaus |
563fb5522362017893114feea9c10dd8d3558c7b | 999 | hpp | C++ | src/image.hpp | robotjandal/image_processor | 02eb861082212249e958acf0dbd2ac0144cac458 | [
"BSD-3-Clause"
] | null | null | null | src/image.hpp | robotjandal/image_processor | 02eb861082212249e958acf0dbd2ac0144cac458 | [
"BSD-3-Clause"
] | null | null | null | src/image.hpp | robotjandal/image_processor | 02eb861082212249e958acf0dbd2ac0144cac458 | [
"BSD-3-Clause"
] | null | null | null | #ifndef CMAKE_IMAGE_H
#define CMAKE_IMAGE_H
#include <string>
#include <opencv4/opencv2/opencv.hpp>
#include <boost/filesystem.hpp>
namespace ImageProcessor {
struct Image {
Image(){};
Image(cv::Mat const image, std::string const filename,
std::string const output_folder)
: image_{image}, filename_{boost::filesystem::path{filename}},
output_folder_{output_folder} {};
Image(cv::Mat const image, boost::filesystem::path const filename,
std::string const output_folder)
: image_{image}, filename_{filename}, output_folder_{output_folder} {};
bool operator==(const Image &other) const;
bool image_exists() const;
std::string get_filename() const { return filename_.filename().string(); };
std::string get_stem() const { return filename_.stem().string(); };
std::string get_extension() const { return filename_.extension().string(); };
cv::Mat image_;
boost::filesystem::path filename_;
std::string output_folder_{"output"};
};
}
#endif | 30.272727 | 79 | 0.707708 | robotjandal |
5641c03f6019abd5d472656ac044d16f49b21347 | 252 | cpp | C++ | tests/main.cpp | mincardona/cppscratch | 159e3757bc373245defc77c34930c0d7b1d925de | [
"MIT"
] | null | null | null | tests/main.cpp | mincardona/cppscratch | 159e3757bc373245defc77c34930c0d7b1d925de | [
"MIT"
] | null | null | null | tests/main.cpp | mincardona/cppscratch | 159e3757bc373245defc77c34930c0d7b1d925de | [
"MIT"
] | null | null | null | #include <iostream>
#include <mji/algorithm.hpp>
#include <mji/math.hpp>
#include <mji/memory.hpp>
#include <mji/xplat.hpp>
int main(int argc, char** argv) {
(void)argc;
(void)argv;
std::cout << "tests passed!" << '\n';
return 0;
}
| 15.75 | 41 | 0.615079 | mincardona |
5641da34fc830fd337d475424076c9acdb665662 | 708 | cpp | C++ | main.cpp | Qanora/mstack-cpp | a1b6de6983404558e46b87d0e81da715fcdccd55 | [
"MIT"
] | 15 | 2020-07-20T12:32:38.000Z | 2022-03-24T19:24:02.000Z | main.cpp | Qanora/mstack-cpp | a1b6de6983404558e46b87d0e81da715fcdccd55 | [
"MIT"
] | null | null | null | main.cpp | Qanora/mstack-cpp | a1b6de6983404558e46b87d0e81da715fcdccd55 | [
"MIT"
] | 5 | 2020-07-20T12:42:58.000Z | 2021-01-16T10:13:39.000Z | #include <future>
#include <iostream>
#include "api.hpp"
int main(int argc, char* argv[]) {
auto stack = std::async(std::launch::async, mstack::init_stack, argc, argv);
int fd = mstack::socket(0x06, mstack::ipv4_addr_t("192.168.1.1"), 30000);
mstack::listen(fd);
char buf[2000];
int size = 2000;
int cfd = mstack::accept(fd);
while (true) {
size = 2000;
mstack::read(cfd, buf, size);
std::cout << "read size: " << size << std::endl;
for (int i = 0; i < size; i++) {
std::cout << buf[i];
}
std::cout << std::endl;
}
} | 33.714286 | 85 | 0.461864 | Qanora |
564274f3fdb5851743ed4756bdc8bf7224735d77 | 63 | cpp | C++ | src/Utility_Test.cpp | AlbertoLeonardi/Open_SXD_Absorption | 3d0353676dada2e6826de583355c5e35a93fa791 | [
"BSD-3-Clause"
] | null | null | null | src/Utility_Test.cpp | AlbertoLeonardi/Open_SXD_Absorption | 3d0353676dada2e6826de583355c5e35a93fa791 | [
"BSD-3-Clause"
] | null | null | null | src/Utility_Test.cpp | AlbertoLeonardi/Open_SXD_Absorption | 3d0353676dada2e6826de583355c5e35a93fa791 | [
"BSD-3-Clause"
] | null | null | null | // Utility Functions :: Test
//
#include "Utility_Test.h"
| 12.6 | 29 | 0.634921 | AlbertoLeonardi |
56462c507604830c90548b7dd8baeb644686fd66 | 6,490 | cpp | C++ | Core/STL/OS/Posix/PosixSyncPrimitives.cpp | azhirnov/GraphicsGenFramework-modular | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | 12 | 2017-12-23T14:24:57.000Z | 2020-10-02T19:52:12.000Z | Core/STL/OS/Posix/PosixSyncPrimitives.cpp | azhirnov/ModularGraphicsFramework | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | null | null | null | Core/STL/OS/Posix/PosixSyncPrimitives.cpp | azhirnov/ModularGraphicsFramework | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt'
#include "Core/STL/Common/Platforms.h"
#if defined( PLATFORM_BASE_POSIX ) and defined( GX_USE_NATIVE_API )
#include "Core/STL/OS/Posix/SyncPrimitives.h"
namespace GX_STL
{
namespace OS
{
/*
=================================================
constructor
=================================================
*/
Mutex::Mutex ()
{
static const pthread_mutex_t tmp = PTHREAD_MUTEX_INITIALIZER;
_mutex = tmp;
# if 1
::pthread_mutex_init( OUT &_mutex, null ) == 0;
# else
pthread_mutexattr_t attr;
::pthread_mutexattr_init( &attr );
::pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
::pthread_mutex_init( &_mutex, &attr ) == 0;
# endif
}
/*
=================================================
destructor
=================================================
*/
Mutex::~Mutex ()
{
::pthread_mutex_destroy( &_mutex );
}
/*
=================================================
Lock
=================================================
*/
void Mutex::Lock ()
{
bool res = ::pthread_mutex_lock( &_mutex ) == 0;
ASSERT( res );
}
/*
=================================================
TryLock
=================================================
*/
bool Mutex::TryLock ()
{
return ::pthread_mutex_trylock( &_mutex ) == 0;
}
/*
=================================================
Unlock
=================================================
*/
void Mutex::Unlock ()
{
bool res = ::pthread_mutex_unlock( &_mutex ) == 0;
ASSERT( res );
}
//-----------------------------------------------------------------------------
/*
=================================================
constructor
=================================================
*/
ReadWriteSync::ReadWriteSync ()
{
::pthread_rwlock_init( OUT &_rwlock, null );
}
/*
=================================================
destructor
=================================================
*/
ReadWriteSync::~ReadWriteSync ()
{
::pthread_rwlock_destroy( &_rwlock );
}
/*
=================================================
LockWrite
=================================================
*/
void ReadWriteSync::LockWrite ()
{
bool res = ::pthread_rwlock_wrlock( &_rwlock ) == 0;
ASSERT( res );
}
/*
=================================================
TryLockWrite
=================================================
*/
bool ReadWriteSync::TryLockWrite ()
{
return ::pthread_rwlock_trywrlock( &_rwlock ) == 0;
}
/*
=================================================
UnlockWrite
=================================================
*/
void ReadWriteSync::UnlockWrite ()
{
bool res = ::pthread_rwlock_unlock( &_rwlock ) == 0;
ASSERT( res );
}
/*
=================================================
LockRead
=================================================
*/
void ReadWriteSync::LockRead ()
{
bool res = ::pthread_rwlock_rdlock( &_rwlock ) == 0;
ASSERT( res );
}
/*
=================================================
TryLockRead
=================================================
*/
bool ReadWriteSync::TryLockRead ()
{
return ::pthread_rwlock_tryrdlock( &_rwlock ) == 0;
}
/*
=================================================
UnlockRead
=================================================
*/
void ReadWriteSync::UnlockRead ()
{
bool res = ::pthread_rwlock_unlock( &_rwlock ) == 0;
ASSERT( res );
}
//-----------------------------------------------------------------------------
/*
=================================================
constructor
=================================================
*/
ConditionVariable::ConditionVariable ()
{
::pthread_cond_init( OUT &_cv, null );
}
/*
=================================================
destructor
=================================================
*/
ConditionVariable::~ConditionVariable ()
{
::pthread_cond_destroy( &_cv );
}
/*
=================================================
Signal
=================================================
*/
void ConditionVariable::Signal ()
{
bool res = ::pthread_cond_signal( &_cv ) == 0;
ASSERT( res );
}
/*
=================================================
Broadcast
=================================================
*/
void ConditionVariable::Broadcast ()
{
bool res = ::pthread_cond_broadcast( &_cv ) == 0;
ASSERT( res );
}
/*
=================================================
Wait
=================================================
*/
bool ConditionVariable::Wait (Mutex &cs)
{
return ::pthread_cond_wait( &_cv, &cs._mutex ) == 0;
}
/*
=================================================
Wait
=================================================
*/
bool ConditionVariable::Wait (Mutex &cs, TimeL time)
{
struct timespec currTime;
::clock_gettime( CLOCK_REALTIME, OUT &currTime );
// TODO: check
currTime.tv_nsec += time.MilliSeconds() * 1000;
currTime.tv_sec += currTime.tv_nsec / 1000000000;
return ::pthread_cond_timedwait( &_cv, &cs._mutex, &currTime );
}
//-----------------------------------------------------------------------------
/*
=================================================
constructor
=================================================
*/
Semaphore::Semaphore (GXTypes::uint initialValue)
{
::sem_init( OUT &_sem, 0, initialValue );
}
/*
=================================================
destructor
=================================================
*/
Semaphore::~Semaphore ()
{
::sem_destroy( &_sem );
}
/*
=================================================
Lock
=================================================
*/
void Semaphore::Lock ()
{
int result = ::sem_wait( &_sem );
ASSERT( result == 0 );
}
/*
=================================================
TryLock
=================================================
*/
bool Semaphore::TryLock ()
{
int result = ::sem_trywait( &_sem );
return result == 0;
}
/*
=================================================
Unlock
=================================================
*/
void Semaphore::Unlock ()
{
int result = ::sem_post( &_sem );
ASSERT( result == 0 );
}
/*
=================================================
GetValue
=================================================
*/
GXTypes::uint Semaphore::GetValue ()
{
int value = 0;
int result = ::sem_getvalue( &_sem, &value );
ASSERT( result == 0 );
return value;
}
} // OS
} // GX_STL
#endif // PLATFORM_BASE_POSIX and GX_USE_NATIVE_API
| 20.868167 | 79 | 0.362096 | azhirnov |
5646b3b326d2c2b9566bf4b7824be6668dd58e77 | 1,078 | cpp | C++ | examples/tutorial/hello_job_world.cpp | saga-project/saga-cpp | 7376c0de0529e7d7b80cf08b94ec484c2e56d38e | [
"BSL-1.0"
] | 5 | 2015-09-15T16:24:14.000Z | 2021-08-12T11:05:55.000Z | examples/tutorial/hello_job_world.cpp | saga-project/saga-cpp | 7376c0de0529e7d7b80cf08b94ec484c2e56d38e | [
"BSL-1.0"
] | null | null | null | examples/tutorial/hello_job_world.cpp | saga-project/saga-cpp | 7376c0de0529e7d7b80cf08b94ec484c2e56d38e | [
"BSL-1.0"
] | 3 | 2016-11-17T04:38:38.000Z | 2021-04-10T17:23:52.000Z | // Copyright (c) 2011 Ole Weidner, Louisiana State University
//
// This is part of the code examples on the SAGA website:
// http://saga-project.org/documentation/tutorials/job-api
#include <saga/saga.hpp>
int main(int argc, char* argv[])
{
try
{
// create an "echo 'hello, world' job"
saga::job::description jd;
jd.set_attribute("Interactive", "True");
jd.set_attribute("Executable", "/bin/echo");
std::vector<std::string> args;
args.push_back("Hello, World!");
jd.set_vector_attribute("Arguments", args);
// connect to the local job service
saga::job::service js("fork://localhost");
// submit the job
saga::job::job job = js.create_job(jd);
job.run();
//wait for the job to complete
job.wait(-1);
// print the job's output
saga::job::istream output = job.get_stdout();
std::string line;
while ( ! std::getline (output, line).eof () )
{
std::cout << line << std::endl;
}
}
catch(saga::exception const & e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
| 24.5 | 62 | 0.611317 | saga-project |
5649ef306425c4e66478968eedf4b5296864a7e2 | 8,692 | cpp | C++ | src/lock_free_set.cpp | cconklin/nonblocking-tables | 82acacbb16342ad36156931b9969674d85114d21 | [
"MIT"
] | null | null | null | src/lock_free_set.cpp | cconklin/nonblocking-tables | 82acacbb16342ad36156931b9969674d85114d21 | [
"MIT"
] | null | null | null | src/lock_free_set.cpp | cconklin/nonblocking-tables | 82acacbb16342ad36156931b9969674d85114d21 | [
"MIT"
] | null | null | null | #include <lock_free_set.hpp>
namespace nonblocking
{
template<> versioned<lock_free_set::bucket_state>::versioned(unsigned int version, lock_free_set::bucket_state value) : _version{version}
{
switch (value)
{
case lock_free_set::bucket_state::empty: _value = 0; break;
case lock_free_set::bucket_state::busy: _value = 1; break;
case lock_free_set::bucket_state::collided: _value = 2; break;
case lock_free_set::bucket_state::visible: _value = 3; break;
case lock_free_set::bucket_state::inserting: _value = 4; break;
case lock_free_set::bucket_state::member: _value = 5; break;
}
}
template<> versioned<lock_free_set::bucket_state>::versioned() noexcept : _version{0}, _value{0} {}
template<> bool versioned<lock_free_set::bucket_state>::operator==(versioned<lock_free_set::bucket_state> other)
{
return (_version == other._version) && (_value == other._value);
}
template<> lock_free_set::bucket_state versioned<lock_free_set::bucket_state>::value()
{
switch (_value)
{
case 0: return lock_free_set::bucket_state::empty;
case 1: return lock_free_set::bucket_state::busy;
case 2: return lock_free_set::bucket_state::collided;
case 3: return lock_free_set::bucket_state::visible;
case 4: return lock_free_set::bucket_state::inserting;
case 5: return lock_free_set::bucket_state::member;
default: return lock_free_set::bucket_state::busy;
}
}
template<> unsigned int versioned<lock_free_set::bucket_state>::version()
{
return _version;
}
lock_free_set::bucket::bucket(unsigned int key, unsigned int version, lock_free_set::bucket_state state) : key{key}, vs(versioned<lock_free_set::bucket_state>(version, state)) {}
lock_free_set::bucket::bucket() : key{0}, vs(versioned<lock_free_set::bucket_state>()) {}
lock_free_set::bucket* lock_free_set::bucket_at(unsigned int h, int index)
{
return &buckets[(h+index*(index+1)/2)%size];
}
bool lock_free_set::does_bucket_contain_collision(unsigned int h, int index)
{
auto state = bucket_at(h, index)->vs.load(std::memory_order_acquire);
if ((state.value() == visible) || (state.value() == inserting) || (state.value() == member))
{
if (hash(bucket_at(h, index)->key.load(std::memory_order_acquire)) == h)
{
auto state2 = bucket_at(h, index)->vs.load(std::memory_order_relaxed);
if ((state2.value() == visible) || (state2.value() == inserting) || (state2.value() == member))
{
if (state2.version() == state.version())
{
return true;
}
}
}
}
return false;
}
lock_free_set::lock_free_set(unsigned int size) : base(size)
{
buckets = new bucket[size];
std::atomic_thread_fence(std::memory_order_release);
}
bool lock_free_set::lookup(unsigned int key)
{
unsigned int h = hash(key);
auto max = get_probe_bound(h);
for (unsigned int i = 0; i <= max; ++i)
{
auto state = bucket_at(h, i)->vs.load(std::memory_order_acquire);
if ((state.value() == member) && (bucket_at(h, i)->key.load(std::memory_order_acquire) == key))
{
auto state2 = bucket_at(h, i)->vs.load(std::memory_order_relaxed);
if (state == state2)
{
return true;
}
}
}
return false;
}
bool lock_free_set::erase(unsigned int key)
{
unsigned int h = hash(key);
auto max = get_probe_bound(h);
for (unsigned int i = 0; i <= max; ++i)
{
auto* bucket = bucket_at(h, i);
auto state = bucket->vs.load(std::memory_order_acquire);
if ((state.value() == member) && (bucket->key.load(std::memory_order_acquire) == key))
{
if (std::atomic_compare_exchange_strong_explicit(&bucket->vs, &state, versioned<bucket_state>(state.version(), busy), std::memory_order_release, std::memory_order_relaxed))
{
conditionally_lower_bound(h, i);
bucket->vs.store(versioned<bucket_state>(state.version() + 1, empty), std::memory_order_release);
return true;
}
}
}
return false;
}
bool lock_free_set::insert(unsigned int key)
{
unsigned int h = hash(key);
int i = -1;
unsigned int version;
versioned<bucket_state> old_vs;
versioned<bucket_state> new_vs;
do
{
if (++i >= size)
{
throw "Table full";
}
version = bucket_at(h, i)->vs.load(std::memory_order_acquire).version();
old_vs = versioned<bucket_state>(version, empty);
new_vs = versioned<bucket_state>(version, busy);
}
while (!std::atomic_compare_exchange_strong_explicit(&bucket_at(h, i)->vs, &old_vs, new_vs, std::memory_order_release, std::memory_order_relaxed));
bucket_at(h, i)->key.store(key, std::memory_order_relaxed);
while (true)
{
bucket_at(h, i)->vs.store(versioned<bucket_state>(version, visible), std::memory_order_release);
conditionally_raise_bound(h, i);
bucket_at(h, i)->vs.store(versioned<bucket_state>(version, inserting), std::memory_order_release);
auto r = assist(key, h, i, version);
if (!(bucket_at(h, i)->vs.load(std::memory_order_acquire) == versioned<bucket_state>(version, collided)))
{
return true;
}
if (!r)
{
conditionally_lower_bound(h, i);
bucket_at(h, i)->vs.store(versioned<bucket_state>(version+1, empty), std::memory_order_release);
return false;
}
version++;
}
}
bool lock_free_set::assist(unsigned int key, unsigned int h, int i, unsigned int ver_i)
{
auto max = get_probe_bound(h);
versioned<bucket_state> old_vs(ver_i, inserting);
for (unsigned int j = 0; j <= max; j++)
{
if (i != j)
{
auto* bkt_at = bucket_at(h, j);
auto state = bkt_at->vs.load(std::memory_order_acquire);
if ((state.value() == inserting) && (bkt_at->key.load(std::memory_order_acquire) == key))
{
if (j < i)
{
auto j_state = bkt_at->vs.load(std::memory_order_relaxed);
if (j_state == state)
{
std::atomic_compare_exchange_strong_explicit(&bucket_at(h, i)->vs, &old_vs, versioned<bucket_state>(ver_i, collided), std::memory_order_relaxed, std::memory_order_relaxed);
return assist(key, h, j, state.version());
}
}
else
{
auto i_state = bucket_at(h, i)->vs.load(std::memory_order_acquire);
if (i_state == versioned<bucket_state>(ver_i, inserting))
{
std::atomic_compare_exchange_strong_explicit(&bkt_at->vs, &state, versioned<bucket_state>(state.version(), collided), std::memory_order_relaxed, std::memory_order_relaxed);
}
}
}
auto new_state = bkt_at->vs.load(std::memory_order_acquire);
if ((new_state.value() == member) && (bkt_at->key.load(std::memory_order_acquire) == key))
{
if (bkt_at->vs.load(std::memory_order_relaxed) == new_state)
{
std::atomic_compare_exchange_strong_explicit(&bucket_at(h, i)->vs, &old_vs, versioned<bucket_state>(ver_i, collided), std::memory_order_relaxed, std::memory_order_relaxed);
return false;
}
}
}
}
std::atomic_compare_exchange_strong_explicit(&bucket_at(h, i)->vs, &old_vs, versioned<bucket_state>(ver_i, member), std::memory_order_release, std::memory_order_relaxed);
return true;
}
lock_free_set::~lock_free_set()
{
delete buckets;
}
}
| 41.788462 | 200 | 0.554648 | cconklin |
5649f39794bcb8d696576f12970d330136ab6d9e | 955 | cpp | C++ | src/CaseCreator/UIComponents/CharacterTab/CharacterDialogSpritesPage.cpp | Thisisderpys/my-little-investigations | 0689f2ca3e808ba39864f024280abd2e77f8ad20 | [
"MIT"
] | 41 | 2015-01-24T17:33:16.000Z | 2022-01-08T19:36:40.000Z | src/CaseCreator/UIComponents/CharacterTab/CharacterDialogSpritesPage.cpp | Thisisderpys/my-little-investigations | 0689f2ca3e808ba39864f024280abd2e77f8ad20 | [
"MIT"
] | 15 | 2015-01-05T21:00:41.000Z | 2016-10-18T14:37:03.000Z | src/CaseCreator/UIComponents/CharacterTab/CharacterDialogSpritesPage.cpp | Thisisderpys/my-little-investigations | 0689f2ca3e808ba39864f024280abd2e77f8ad20 | [
"MIT"
] | 6 | 2016-01-14T21:07:22.000Z | 2020-11-28T09:51:15.000Z | #include "CharacterDialogSpritesPage.h"
#include <QVBoxLayout>
CharacterDialogSpritesPage::CharacterDialogSpritesPage(QWidget *parent) :
Page<Character>(parent)
{
isActive = false;
QVBoxLayout *pMainLayout = new QVBoxLayout();
pEmotionManipulator = new ListManipulator<Character::DialogEmotion>();
pMainLayout->addWidget(pEmotionManipulator);
setLayout(pMainLayout);
}
void CharacterDialogSpritesPage::Init(Character *pObject)
{
if (pObject == NULL)
{
return;
}
Page<Character>::Init(pObject);
pEmotionManipulator->SetParentObject(pObject);
}
void CharacterDialogSpritesPage::Reset()
{
pEmotionManipulator->Reset();
}
bool CharacterDialogSpritesPage::GetIsActive()
{
return isActive;
}
void CharacterDialogSpritesPage::SetIsActive(bool isActive)
{
if (this->isActive != isActive)
{
this->isActive = isActive;
pEmotionManipulator->SetIsActive(isActive);
}
}
| 20.319149 | 74 | 0.71623 | Thisisderpys |
871cfb6e6280a3cc476906643eb4d3e0a1ce5d5a | 36,782 | cxx | C++ | libbuild2/cc/module.cxx | build2/build2 | af662849b756ef2ff0f3d5148a6771acab78fd80 | [
"MIT"
] | 422 | 2018-05-30T12:00:00.000Z | 2022-03-29T07:29:56.000Z | libbuild2/cc/module.cxx | build2/build2 | af662849b756ef2ff0f3d5148a6771acab78fd80 | [
"MIT"
] | 183 | 2018-07-02T20:38:30.000Z | 2022-03-31T09:54:35.000Z | libbuild2/cc/module.cxx | build2/build2 | af662849b756ef2ff0f3d5148a6771acab78fd80 | [
"MIT"
] | 14 | 2019-01-09T12:34:02.000Z | 2021-03-16T09:10:53.000Z | // file : libbuild2/cc/module.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
#include <libbuild2/cc/module.hxx>
#include <iomanip> // left, setw()
#include <libbuild2/scope.hxx>
#include <libbuild2/function.hxx>
#include <libbuild2/diagnostics.hxx>
#include <libbuild2/bin/target.hxx>
#include <libbuild2/cc/target.hxx> // pc*
#include <libbuild2/config/utility.hxx>
#include <libbuild2/install/utility.hxx>
#include <libbuild2/cc/guess.hxx>
using namespace std;
using namespace butl;
namespace build2
{
namespace cc
{
void config_module::
guess (scope& rs, const location& loc, const variable_map&)
{
tracer trace (x, "guess_init");
bool cc_loaded (cast_false<bool> (rs["cc.core.guess.loaded"]));
// Adjust module priority (compiler). Also order cc module before us
// (we don't want to use priorities for that in case someone manages
// to slot in-between).
//
if (!cc_loaded)
config::save_module (rs, "cc", 250);
config::save_module (rs, x, 250);
auto& vp (rs.var_pool ());
// Must already exist.
//
const variable& config_c_poptions (vp["config.cc.poptions"]);
const variable& config_c_coptions (vp["config.cc.coptions"]);
const variable& config_c_loptions (vp["config.cc.loptions"]);
// Configuration.
//
using config::lookup_config;
// config.x
//
strings mode;
{
// Normally we will have a persistent configuration and computing the
// default value every time will be a waste. So try without a default
// first.
//
lookup l (lookup_config (new_config, rs, config_x));
if (!l)
{
// If there is a config.x value for one of the modules that can hint
// us the toolchain, load it's .guess module. This makes sure that
// the order in which we load the modules is unimportant and that
// the user can specify the toolchain using any of the config.x
// values.
//
if (!cc_loaded)
{
for (const char* const* pm (x_hinters); *pm != nullptr; ++pm)
{
string m (*pm);
// Must be the same as in module's init().
//
const variable& v (vp.insert<strings> ("config." + m));
if (rs[v].defined ())
{
init_module (rs, rs, m + ".guess", loc);
cc_loaded = true;
break;
}
}
}
// If cc.core.guess is already loaded then use its toolchain id,
// (optional) pattern, and mode to guess an appropriate default
// (e.g., for {gcc, *-4.9 -m64} we will get g++-4.9 -m64).
//
strings d;
if (cc_loaded)
d = guess_default (x_lang,
cast<string> (rs["cc.id"]),
cast<string> (rs["cc.pattern"]),
cast<strings> (rs["cc.mode"]));
else
{
// Note that we don't have the default mode: it doesn't feel
// correct to default to, say, -m64 simply because that's how
// build2 was built.
//
d.push_back (x_default);
if (d.front ().empty ())
fail << "not built with default " << x_lang << " compiler" <<
info << "use " << config_x << " to specify";
}
// If this value was hinted, save it as commented out so that if the
// user changes the source of the pattern/mode, this one will get
// updated as well.
//
l = lookup_config (new_config,
rs,
config_x,
move (d),
cc_loaded ? config::save_default_commented : 0);
}
// Split the value into the compiler path and mode.
//
const strings& v (cast<strings> (l));
path xc;
{
const string& s (v.empty () ? empty_string : v.front ());
try { xc = path (s); } catch (const invalid_path&) {}
if (xc.empty ())
fail << "invalid path '" << s << "' in " << config_x;
}
mode.assign (++v.begin (), v.end ());
// Save original path/mode in *.config.path/mode.
//
rs.assign (x_c_path) = xc;
rs.assign (x_c_mode) = mode;
// Figure out which compiler we are dealing with, its target, etc.
//
// Note that we could allow guess() to modify mode to support
// imaginary options (such as /MACHINE for cl.exe). Though it's not
// clear what cc.mode would contain (original or modified). Note that
// we are now folding *.std options into mode options.
//
x_info = &build2::cc::guess (
x, x_lang,
rs.root_extra->environment_checksum,
move (xc),
cast_null<string> (lookup_config (rs, config_x_id)),
cast_null<string> (lookup_config (rs, config_x_version)),
cast_null<string> (lookup_config (rs, config_x_target)),
mode,
cast_null<strings> (rs[config_c_poptions]),
cast_null<strings> (rs[config_x_poptions]),
cast_null<strings> (rs[config_c_coptions]),
cast_null<strings> (rs[config_x_coptions]),
cast_null<strings> (rs[config_c_loptions]),
cast_null<strings> (rs[config_x_loptions]));
}
const compiler_info& xi (*x_info);
// Split/canonicalize the target. First see if the user asked us to use
// config.sub.
//
target_triplet tt;
{
string ct;
if (config_sub)
{
ct = run<string> (3,
*config_sub,
xi.target.c_str (),
[] (string& l, bool) {return move (l);});
l5 ([&]{trace << "config.sub target: '" << ct << "'";});
}
try
{
tt = target_triplet (ct.empty () ? xi.target : ct);
l5 ([&]{trace << "canonical target: '" << tt.string () << "'; "
<< "class: " << tt.class_;});
}
catch (const invalid_argument& e)
{
// This is where we suggest that the user specifies --config-sub to
// help us out.
//
fail << "unable to parse " << x_lang << " compiler target '"
<< xi.target << "': " << e <<
info << "consider using the --config-sub option";
}
}
// Hash the environment (used for change detection).
//
// Note that for simplicity we use the combined checksum for both
// compilation and linking (which may compile, think LTO).
//
{
sha256 cs;
hash_environment (cs, xi.compiler_environment);
hash_environment (cs, xi.platform_environment);
env_checksum = cs.string ();
}
// Assign values to variables that describe the compiler.
//
rs.assign (x_path) = process_path_ex (
xi.path, x_name, xi.checksum, env_checksum);
const strings& xm (cast<strings> (rs.assign (x_mode) = move (mode)));
rs.assign (x_id) = xi.id.string ();
rs.assign (x_id_type) = to_string (xi.id.type);
rs.assign (x_id_variant) = xi.id.variant;
rs.assign (x_class) = to_string (xi.class_);
auto assign_version = [&rs] (const variable** vars,
const compiler_version* v)
{
rs.assign (vars[0]) = v != nullptr ? value (v->string) : value ();
rs.assign (vars[1]) = v != nullptr ? value (v->major) : value ();
rs.assign (vars[2]) = v != nullptr ? value (v->minor) : value ();
rs.assign (vars[3]) = v != nullptr ? value (v->patch) : value ();
rs.assign (vars[4]) = v != nullptr ? value (v->build) : value ();
};
assign_version (&x_version, &xi.version);
assign_version (&x_variant_version,
xi.variant_version ? &*xi.variant_version : nullptr);
rs.assign (x_signature) = xi.signature;
rs.assign (x_checksum) = xi.checksum;
// Also enter as x.target.{cpu,vendor,system,version,class} for
// convenience of access.
//
rs.assign (x_target_cpu) = tt.cpu;
rs.assign (x_target_vendor) = tt.vendor;
rs.assign (x_target_system) = tt.system;
rs.assign (x_target_version) = tt.version;
rs.assign (x_target_class) = tt.class_;
rs.assign (x_target) = move (tt);
rs.assign (x_pattern) = xi.pattern;
if (!x_stdlib.alias (c_stdlib))
rs.assign (x_stdlib) = xi.x_stdlib;
// Load cc.core.guess.
//
if (!cc_loaded)
{
// Prepare configuration hints.
//
variable_map h (rs.ctx);
// Note that all these variables have already been registered.
//
h.assign ("config.cc.id") = cast<string> (rs[x_id]);
h.assign ("config.cc.hinter") = string (x);
h.assign ("config.cc.target") = cast<target_triplet> (rs[x_target]);
if (!xi.pattern.empty ())
h.assign ("config.cc.pattern") = xi.pattern;
if (!xm.empty ())
h.assign ("config.cc.mode") = xm;
h.assign (c_runtime) = xi.runtime;
h.assign (c_stdlib) = xi.c_stdlib;
init_module (rs, rs, "cc.core.guess", loc, false, h);
}
else
{
// If cc.core.guess is already loaded, verify its configuration
// matched ours since it could have been loaded by another c-family
// module.
//
const auto& h (cast<string> (rs["cc.hinter"]));
auto check = [&loc, &h, this] (const auto& cv,
const auto& xv,
const char* what,
bool error = true)
{
if (cv != xv)
{
diag_record dr (error ? fail (loc) : warn (loc));
dr << h << " and " << x << " module " << what << " mismatch" <<
info << h << " is '" << cv << "'" <<
info << x << " is '" << xv << "'" <<
info << "consider explicitly specifying config." << h
<< " and config." << x;
}
};
check (cast<string> (rs["cc.id"]),
cast<string> (rs[x_id]),
"toolchain");
// We used to not require that patterns match assuming that if the
// toolchain id and target are the same, then where exactly the tools
// come from doesn't really matter. But in most cases it will be the
// g++-7 vs gcc kind of mistakes. So now we warn since even if
// intentional, it is still probably a bad idea.
//
// Note also that it feels right to allow different modes (think
// -fexceptions for C or -fno-rtti for C++).
//
check (cast<string> (rs["cc.pattern"]),
cast<string> (rs[x_pattern]),
"toolchain pattern",
false);
check (cast<target_triplet> (rs["cc.target"]),
cast<target_triplet> (rs[x_target]),
"target");
check (cast<string> (rs["cc.runtime"]),
xi.runtime,
"runtime");
check (cast<string> (rs["cc.stdlib"]),
xi.c_stdlib,
"c standard library");
}
}
#ifndef _WIN32
static const dir_path usr_inc ("/usr/include");
static const dir_path usr_loc_lib ("/usr/local/lib");
static const dir_path usr_loc_inc ("/usr/local/include");
# ifdef __APPLE__
static const dir_path a_usr_inc (
"/Library/Developer/CommandLineTools/SDKs/MacOSX*.sdk/usr/include");
# endif
#endif
// Extracting search dirs can be expensive (we may need to run the
// compiler several times) so we cache the result.
//
struct search_dirs
{
pair<dir_paths, size_t> lib;
pair<dir_paths, size_t> hdr;
};
static global_cache<search_dirs> dirs_cache;
void config_module::
init (scope& rs, const location& loc, const variable_map&)
{
tracer trace (x, "config_init");
const compiler_info& xi (*x_info);
const target_triplet& tt (cast<target_triplet> (rs[x_target]));
// Load cc.core.config.
//
if (!cast_false<bool> (rs["cc.core.config.loaded"]))
{
variable_map h (rs.ctx);
if (!xi.bin_pattern.empty ())
h.assign ("config.bin.pattern") = xi.bin_pattern;
init_module (rs, rs, "cc.core.config", loc, false, h);
}
// Configuration.
//
using config::lookup_config;
// config.x.{p,c,l}options
// config.x.libs
//
// These are optional. We also merge them into the corresponding
// x.* variables.
//
// The merging part gets a bit tricky if this module has already
// been loaded in one of the outer scopes. By doing the straight
// append we would just be repeating the same options over and
// over. So what we are going to do is only append to a value if
// it came from this scope. Then the usage for merging becomes:
//
// @@ There are actually two cases to this issue:
//
// 1. The module is loaded in the outer project (e.g., tests inside a
// project). It feels like this should be handled with project
// variable visibility. And now it is with the project being the
// default. Note that this is the reason we don't need any of this
// for the project configuration: there the config.* variables are
// always set on the project root.
//
// 2. The module is loaded in the outer scope within the same
// project. We are currently thinking whether we should even
// support loading of modules in non-root scopes.
//
// x.coptions = <overridable options> # Note: '='.
// using x
// x.coptions += <overriding options> # Note: '+='.
//
rs.assign (x_poptions) += cast_null<strings> (
lookup_config (rs, config_x_poptions, nullptr));
rs.assign (x_coptions) += cast_null<strings> (
lookup_config (rs, config_x_coptions, nullptr));
rs.assign (x_loptions) += cast_null<strings> (
lookup_config (rs, config_x_loptions, nullptr));
rs.assign (x_aoptions) += cast_null<strings> (
lookup_config (rs, config_x_aoptions, nullptr));
rs.assign (x_libs) += cast_null<strings> (
lookup_config (rs, config_x_libs, nullptr));
// config.x.std overrides x.std
//
strings& mode (cast<strings> (rs.assign (x_mode))); // Set by guess.
{
lookup l (lookup_config (rs, config_x_std));
const string* v;
if (l.defined ())
{
v = cast_null<string> (l);
rs.assign (x_std) = v;
}
else
v = cast_null<string> (rs[x_std]);
// Translate x_std value (if any) to the compiler option(s) (if any)
// and fold them into the compiler mode.
//
translate_std (xi, tt, rs, mode, v);
}
// config.x.internal.scope
//
// Note: save omitted.
//
// The effective internal_scope value is chosen based on the following
// priority list:
//
// 1. config.x.internal.scope
//
// 2. config.cc.internal.scope
//
// 3. effective value from bundle amalgamation
//
// 4. x.internal.scope
//
// 5. cc.internal.scope
//
// Note also that we only update x.internal.scope (and not cc.*) to
// reflect the effective value.
//
const string* iscope_str (nullptr);
{
if (lookup l = lookup_config (rs, config_x_internal_scope)) // 1
{
iscope_str = &cast<string> (l);
if (*iscope_str == "current")
fail << "'current' value in " << config_x_internal_scope;
}
else if (lookup l = rs["config.cc.internal.scope"]) // 2
{
iscope_str = &cast<string> (l);
}
else // 3
{
const scope& as (*rs.bundle_scope ());
if (as != rs)
{
// Only use the value if the corresponding module is loaded.
//
bool xl (cast_false<bool> (as[string (x) + ".config.loaded"]));
if (xl)
iscope_str = cast_null<string> (as[x_internal_scope]);
if (iscope_str == nullptr)
{
if (xl || cast_false<bool> (as["cc.core.config.loaded"]))
iscope_str = cast_null<string> (as["cc.internal.scope"]);
}
if (iscope_str != nullptr && *iscope_str == "current")
iscope_current = &as;
}
}
lookup l;
if (iscope_str == nullptr)
{
iscope_str = cast_null<string> (l = rs[x_internal_scope]); // 4
if (iscope_str == nullptr)
iscope_str = cast_null<string> (rs["cc.internal.scope"]); // 5
}
if (iscope_str != nullptr)
{
const string& s (*iscope_str);
// Assign effective.
//
if (!l)
rs.assign (x_internal_scope) = s;
if (s == "current")
{
iscope = internal_scope::current;
if (iscope_current == nullptr)
iscope_current = &rs;
}
else if (s == "base") iscope = internal_scope::base;
else if (s == "root") iscope = internal_scope::root;
else if (s == "bundle") iscope = internal_scope::bundle;
else if (s == "strong") iscope = internal_scope::strong;
else if (s == "weak") iscope = internal_scope::weak;
else if (s == "global")
; // Nothing to translate;
else
fail << "invalid " << x_internal_scope << " value '" << s << "'";
}
}
// config.x.translate_include
//
// It's still fuzzy whether specifying (or maybe tweaking) this list in
// the configuration will be a common thing to do so for now we use
// omitted.
//
if (x_translate_include != nullptr)
{
if (lookup l = lookup_config (rs, *config_x_translate_include))
{
// @@ MODHDR: if(modules) ? Yes.
//
rs.assign (x_translate_include).prepend (
cast<translatable_headers> (l));
}
}
// Extract system header/library search paths from the compiler and
// determine if we need any additional search paths.
//
// Note that for now module search paths only come from compiler_info.
//
pair<dir_paths, size_t> lib_dirs;
pair<dir_paths, size_t> hdr_dirs;
const optional<pair<dir_paths, size_t>>& mod_dirs (xi.sys_mod_dirs);
if (xi.sys_lib_dirs && xi.sys_hdr_dirs)
{
lib_dirs = *xi.sys_lib_dirs;
hdr_dirs = *xi.sys_hdr_dirs;
}
else
{
string key;
{
sha256 cs;
cs.append (static_cast<size_t> (x_lang));
cs.append (xi.path.effect_string ());
append_options (cs, mode);
key = cs.string ();
}
// Because the compiler info (xi) is also cached, we can assume that
// if dirs come from there, then they do so consistently.
//
const search_dirs* sd (dirs_cache.find (key));
if (xi.sys_lib_dirs)
lib_dirs = *xi.sys_lib_dirs;
else if (sd != nullptr)
lib_dirs = sd->lib;
else
{
switch (xi.class_)
{
case compiler_class::gcc:
lib_dirs = gcc_library_search_dirs (xi.path, rs);
break;
case compiler_class::msvc:
lib_dirs = msvc_library_search_dirs (xi.path, rs);
break;
}
}
if (xi.sys_hdr_dirs)
hdr_dirs = *xi.sys_hdr_dirs;
else if (sd != nullptr)
hdr_dirs = sd->hdr;
else
{
switch (xi.class_)
{
case compiler_class::gcc:
hdr_dirs = gcc_header_search_dirs (xi.path, rs);
break;
case compiler_class::msvc:
hdr_dirs = msvc_header_search_dirs (xi.path, rs);
break;
}
}
if (sd == nullptr)
{
search_dirs sd;
if (!xi.sys_lib_dirs) sd.lib = lib_dirs;
if (!xi.sys_hdr_dirs) sd.hdr = hdr_dirs;
dirs_cache.insert (move (key), move (sd));
}
}
sys_lib_dirs_mode = lib_dirs.second;
sys_hdr_dirs_mode = hdr_dirs.second;
sys_mod_dirs_mode = mod_dirs ? mod_dirs->second : 0;
sys_lib_dirs_extra = lib_dirs.first.size ();
sys_hdr_dirs_extra = hdr_dirs.first.size ();
#ifndef _WIN32
// Add /usr/local/{include,lib}. We definitely shouldn't do this if we
// are cross-compiling. But even if the build and target are the same,
// it's possible the compiler uses some carefully crafted sysroot and by
// adding /usr/local/* we will just mess things up. So the heuristics
// that we will use is this: if the compiler's system include directories
// contain /usr[/local]/include then we add /usr/local/*.
//
// Note that similar to GCC we also check for the directory existence.
// Failed that, we can end up with some bizarre yo-yo'ing cases where
// uninstall removes the directories which in turn triggers a rebuild
// on the next invocation.
//
{
auto& is (hdr_dirs.first);
auto& ls (lib_dirs.first);
bool ui (find (is.begin (), is.end (), usr_inc) != is.end ());
bool uli (find (is.begin (), is.end (), usr_loc_inc) != is.end ());
#ifdef __APPLE__
// On Mac OS starting from 10.14 there is no longer /usr/include.
// Instead we get the following:
//
// Homebrew GCC 9:
//
// /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
//
// Apple Clang 10.0.1:
//
// /Library/Developer/CommandLineTools/usr/include
// /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
//
// What exactly all this means is anyone's guess, of course (see
// homebrew-core issue #46393 for some background). So for now we
// will assume that anything that matches this pattern:
//
// /Library/Developer/CommandLineTools/SDKs/MacOSX*.sdk/usr/include
//
// Is Apple's /usr/include.
//
if (!ui && !uli)
{
for (const dir_path& d: is)
{
if (path_match (d, a_usr_inc))
{
ui = true;
break;
}
}
}
#endif
if (ui || uli)
{
bool ull (find (ls.begin (), ls.end (), usr_loc_lib) != ls.end ());
// Many platforms don't search in /usr/local/lib by default (but do
// for headers in /usr/local/include). So add it as the last option.
//
if (!ull && exists (usr_loc_lib, true /* ignore_error */))
ls.push_back (usr_loc_lib);
// FreeBSD is at least consistent: it searches in neither. Quoting
// its wiki: "FreeBSD can't even find libraries that it installed."
// So let's help it a bit.
//
if (!uli && exists (usr_loc_inc, true /* ignore_error */))
is.push_back (usr_loc_inc);
}
}
#endif
// If this is a configuration with new values, then print the report
// at verbosity level 2 and up (-v).
//
if (verb >= (new_config ? 2 : 3))
{
diag_record dr (text);
{
dr << x << ' ' << project (rs) << '@' << rs << '\n'
<< " " << left << setw (11) << x << xi.path << '\n';
}
if (!mode.empty ())
{
dr << " mode "; // One space short.
for (const string& o: mode)
dr << ' ' << o;
dr << '\n';
}
{
dr << " id " << xi.id << '\n'
<< " version " << xi.version.string << '\n'
<< " major " << xi.version.major << '\n'
<< " minor " << xi.version.minor << '\n'
<< " patch " << xi.version.patch << '\n';
}
if (!xi.version.build.empty ())
{
dr << " build " << xi.version.build << '\n';
}
if (xi.variant_version)
{
dr << " variant:" << '\n'
<< " version " << xi.variant_version->string << '\n'
<< " major " << xi.variant_version->major << '\n'
<< " minor " << xi.variant_version->minor << '\n'
<< " patch " << xi.variant_version->patch << '\n';
}
if (xi.variant_version && !xi.variant_version->build.empty ())
{
dr << " build " << xi.variant_version->build << '\n';
}
{
const string& ct (tt.string ()); // Canonical target.
dr << " signature " << xi.signature << '\n'
<< " checksum " << xi.checksum << '\n'
<< " target " << ct;
if (ct != xi.original_target)
dr << " (" << xi.original_target << ")";
dr << "\n runtime " << xi.runtime
<< "\n stdlib " << xi.x_stdlib;
if (!x_stdlib.alias (c_stdlib))
dr << "\n c stdlib " << xi.c_stdlib;
}
if (!xi.pattern.empty ()) // Note: bin_pattern printed by bin
{
dr << "\n pattern " << xi.pattern;
}
auto& mods (mod_dirs ? mod_dirs->first : dir_paths ());
auto& incs (hdr_dirs.first);
auto& libs (lib_dirs.first);
if (verb >= 3 && iscope)
{
dr << "\n int scope ";
if (*iscope == internal_scope::current)
dr << iscope_current->out_path ();
else
dr << *iscope_str;
}
if (verb >= 3 && !mods.empty ())
{
dr << "\n mod dirs";
for (const dir_path& d: mods)
{
dr << "\n " << d;
}
}
if (verb >= 3 && !incs.empty ())
{
dr << "\n hdr dirs";
for (size_t i (0); i != incs.size (); ++i)
{
if (i == sys_hdr_dirs_extra)
dr << "\n --";
dr << "\n " << incs[i];
}
}
if (verb >= 3 && !libs.empty ())
{
dr << "\n lib dirs";
for (size_t i (0); i != libs.size (); ++i)
{
if (i == sys_lib_dirs_extra)
dr << "\n --";
dr << "\n " << libs[i];
}
}
}
rs.assign (x_sys_lib_dirs) = move (lib_dirs.first);
rs.assign (x_sys_hdr_dirs) = move (hdr_dirs.first);
config::save_environment (rs, xi.compiler_environment);
config::save_environment (rs, xi.platform_environment);
}
// Global cache of ad hoc importable headers.
//
// The key is a hash of the system header search directories
// (sys_hdr_dirs) where we search for the headers.
//
static map<string, importable_headers> importable_headers_cache;
static mutex importable_headers_mutex;
void module::
init (scope& rs,
const location& loc,
const variable_map&,
const compiler_info& xi)
{
tracer trace (x, "init");
context& ctx (rs.ctx);
// Register the module function family if this is the first instance of
// this modules.
//
if (!function_family::defined (ctx.functions, x))
{
function_family f (ctx.functions, x);
compile_rule::functions (f, x);
link_rule::functions (f, x);
}
// Load cc.core. Besides other things, this will load bin (core) plus
// extra bin.* modules we may need.
//
load_module (rs, rs, "cc.core", loc);
// Search include translation headers and groups.
//
if (modules)
{
{
sha256 k;
for (const dir_path& d: sys_hdr_dirs)
k.append (d.string ());
mlock l (importable_headers_mutex);
importable_headers = &importable_headers_cache[k.string ()];
}
auto& hs (*importable_headers);
ulock ul (hs.mutex);
if (hs.group_map.find (header_group_std) == hs.group_map.end ())
guess_std_importable_headers (xi, sys_hdr_dirs, hs);
// Process x.translate_include.
//
const variable& var (*x_translate_include);
if (auto* v = cast_null<translatable_headers> (rs[var]))
{
for (const auto& p: *v)
{
const string& k (p.first);
if (k.front () == '<' && k.back () == '>')
{
if (path_pattern (k))
{
size_t n (hs.insert_angle_pattern (sys_hdr_dirs, k));
l5 ([&]{trace << "pattern " << k << " searched to " << n
<< " headers";});
}
else
{
// What should we do if not found? While we can fail, this
// could be too drastic if, for example, the header is
// "optional" and may or may not be present/used. So for now
// let's ignore (we could have also removed it from the map as
// an indication).
//
const auto* r (hs.insert_angle (sys_hdr_dirs, k));
l5 ([&]{trace << "header " << k << " searched to "
<< (r ? r->first.string ().c_str () : "<none>");});
}
}
else if (path_traits::find_separator (k) == string::npos)
{
// Group name.
//
if (k != header_group_all_importable &&
k != header_group_std_importable &&
k != header_group_all &&
k != header_group_std)
fail (loc) << "unknown header group '" << k << "' in " << var;
}
else
{
// Absolute and normalized header path.
//
if (!path_traits::absolute (k))
fail (loc) << "relative header path '" << k << "' in " << var;
}
}
}
}
// Register target types and configure their "installability".
//
bool install_loaded (cast_false<bool> (rs["install.loaded"]));
{
using namespace install;
rs.insert_target_type (x_src);
auto insert_hdr = [&rs, install_loaded] (const target_type& tt)
{
rs.insert_target_type (tt);
// Install headers into install.include.
//
if (install_loaded)
install_path (rs, tt, dir_path ("include"));
};
// Note: module (x_mod) is in x_hdr.
//
for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht)
insert_hdr (**ht);
// Also register the C header for C-derived languages.
//
if (*x_hdr != &h::static_type)
insert_hdr (h::static_type);
rs.insert_target_type<pc> ();
rs.insert_target_type<pca> ();
rs.insert_target_type<pcs> ();
if (install_loaded)
install_path<pc> (rs, dir_path ("pkgconfig"));
}
// Register rules.
//
{
using namespace bin;
// If the target doesn't support shared libraries, then don't register
// the corresponding rules.
//
bool s (tsys != "emscripten");
auto& r (rs.rules);
const compile_rule& cr (*this);
const link_rule& lr (*this);
// We register for configure so that we detect unresolved imports
// during configuration rather that later, e.g., during update.
//
r.insert<obje> (perform_update_id, x_compile, cr);
r.insert<obje> (perform_clean_id, x_compile, cr);
r.insert<obje> (configure_update_id, x_compile, cr);
r.insert<obja> (perform_update_id, x_compile, cr);
r.insert<obja> (perform_clean_id, x_compile, cr);
r.insert<obja> (configure_update_id, x_compile, cr);
if (s)
{
r.insert<objs> (perform_update_id, x_compile, cr);
r.insert<objs> (perform_clean_id, x_compile, cr);
r.insert<objs> (configure_update_id, x_compile, cr);
}
if (modules)
{
r.insert<bmie> (perform_update_id, x_compile, cr);
r.insert<bmie> (perform_clean_id, x_compile, cr);
r.insert<bmie> (configure_update_id, x_compile, cr);
r.insert<hbmie> (perform_update_id, x_compile, cr);
r.insert<hbmie> (perform_clean_id, x_compile, cr);
r.insert<hbmie> (configure_update_id, x_compile, cr);
r.insert<bmia> (perform_update_id, x_compile, cr);
r.insert<bmia> (perform_clean_id, x_compile, cr);
r.insert<bmia> (configure_update_id, x_compile, cr);
r.insert<hbmia> (perform_update_id, x_compile, cr);
r.insert<hbmia> (perform_clean_id, x_compile, cr);
r.insert<hbmia> (configure_update_id, x_compile, cr);
if (s)
{
r.insert<bmis> (perform_update_id, x_compile, cr);
r.insert<bmis> (perform_clean_id, x_compile, cr);
r.insert<bmis> (configure_update_id, x_compile, cr);
r.insert<hbmis> (perform_update_id, x_compile, cr);
r.insert<hbmis> (perform_clean_id, x_compile, cr);
r.insert<hbmis> (configure_update_id, x_compile, cr);
}
}
r.insert<libue> (perform_update_id, x_link, lr);
r.insert<libue> (perform_clean_id, x_link, lr);
r.insert<libue> (configure_update_id, x_link, lr);
r.insert<libua> (perform_update_id, x_link, lr);
r.insert<libua> (perform_clean_id, x_link, lr);
r.insert<libua> (configure_update_id, x_link, lr);
if (s)
{
r.insert<libus> (perform_update_id, x_link, lr);
r.insert<libus> (perform_clean_id, x_link, lr);
r.insert<libus> (configure_update_id, x_link, lr);
}
r.insert<exe> (perform_update_id, x_link, lr);
r.insert<exe> (perform_clean_id, x_link, lr);
r.insert<exe> (configure_update_id, x_link, lr);
r.insert<liba> (perform_update_id, x_link, lr);
r.insert<liba> (perform_clean_id, x_link, lr);
r.insert<liba> (configure_update_id, x_link, lr);
if (s)
{
r.insert<libs> (perform_update_id, x_link, lr);
r.insert<libs> (perform_clean_id, x_link, lr);
r.insert<libs> (configure_update_id, x_link, lr);
}
// Note that while libu*{} are not installable, we need to see through
// them in case they depend on stuff that we need to install (see the
// install rule implementations for details).
//
if (install_loaded)
{
const install_rule& ir (*this);
r.insert<exe> (perform_install_id, x_install, ir);
r.insert<exe> (perform_uninstall_id, x_uninstall, ir);
r.insert<liba> (perform_install_id, x_install, ir);
r.insert<liba> (perform_uninstall_id, x_uninstall, ir);
if (s)
{
r.insert<libs> (perform_install_id, x_install, ir);
r.insert<libs> (perform_uninstall_id, x_uninstall, ir);
}
const libux_install_rule& lr (*this);
r.insert<libue> (perform_install_id, x_install, lr);
r.insert<libue> (perform_uninstall_id, x_uninstall, lr);
r.insert<libua> (perform_install_id, x_install, lr);
r.insert<libua> (perform_uninstall_id, x_uninstall, lr);
if (s)
{
r.insert<libus> (perform_install_id, x_install, lr);
r.insert<libus> (perform_uninstall_id, x_uninstall, lr);
}
}
}
}
}
}
| 32.958781 | 81 | 0.520635 | build2 |
8721d1a22273035cf5721033a04becee7caa421b | 1,068 | cc | C++ | libs/crypto/legacy-test-pkcs5.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | libs/crypto/legacy-test-pkcs5.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | libs/crypto/legacy-test-pkcs5.cc | sandtreader/obtools | 2382e2d90bb62c9665433d6d01bbd31b8ad66641 | [
"MIT"
] | null | null | null | //==========================================================================
// ObTools::Crypto: test-pkcs5.cc
//
// Test harness for Crypto library PKCS5 padding functions
//
// Copyright (c) 2006 Paul Clark. All rights reserved
// This code comes with NO WARRANTY and is subject to licence agreement
//==========================================================================
#include "ot-crypto.h"
#include "ot-misc.h"
#include <iostream>
using namespace std;
using namespace ObTools;
//--------------------------------------------------------------------------
// Main
int main(int argc, char **argv)
{
Misc::Dumper dumper(cout, 16, 4, true);
const char *s = (argc>1)?argv[1]:"ABCD";
int length = strlen(s);
unsigned char *ps = Crypto::PKCS5::pad(
reinterpret_cast<const unsigned char *>(s),
length, 8);
cout << "Padded:\n";
dumper.dump(ps, length);
cout << "Original length is " << Crypto::PKCS5::original_length(ps, length)
<< endl;
free(ps);
return 0;
}
| 24.837209 | 77 | 0.481273 | sandtreader |
87232c2882af6dadaade39d821c6436e24b74a84 | 577 | cpp | C++ | cap03/cap03-01-01-test_search_value.cpp | ggaaaff/think_like_a_programmer--test_code | fb081d24d70db6dd503608562625b84607c7a3ab | [
"MIT"
] | 1 | 2020-12-08T10:54:39.000Z | 2020-12-08T10:54:39.000Z | cap03/cap03-01-01-test_search_value.cpp | ggaaaff/think_like_a_programmer--test_code | fb081d24d70db6dd503608562625b84607c7a3ab | [
"MIT"
] | null | null | null | cap03/cap03-01-01-test_search_value.cpp | ggaaaff/think_like_a_programmer--test_code | fb081d24d70db6dd503608562625b84607c7a3ab | [
"MIT"
] | null | null | null | //2014.02.09 Gustaf - CTG.
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "TEST Searching for a Specific Value \n";
const int ARRAY_SIZE = 10;
int intArray[ARRAY_SIZE] = {4, 5, 9, 12, -4, 0, -57, 30987, -287, 1};
int targetValue = 12;
int targetPos = 0;
while ((intArray[targetPos] != targetValue) && (targetPos < ARRAY_SIZE))
targetPos++;
if (targetPos < ARRAY_SIZE)
{
cout << targetValue << " Target Value Finded \n";
}
else
{
cout << targetValue << " Target Value NOT Finded \n";
}
return 0;
}
| 17.484848 | 74 | 0.613518 | ggaaaff |
872b2005306393fab82c78a2703a3027748461a7 | 2,358 | cpp | C++ | tutorial/test_async_stop_token.cpp | tearshark/librf | 4299e2ff264aac9bcd9e4788e528de80044252c8 | [
"Apache-2.0"
] | 434 | 2017-09-24T06:41:06.000Z | 2022-03-29T10:24:14.000Z | tutorial/test_async_stop_token.cpp | tearshark/librf | 4299e2ff264aac9bcd9e4788e528de80044252c8 | [
"Apache-2.0"
] | 7 | 2017-12-06T13:08:33.000Z | 2021-12-01T07:46:12.000Z | tutorial/test_async_stop_token.cpp | tearshark/librf | 4299e2ff264aac9bcd9e4788e528de80044252c8 | [
"Apache-2.0"
] | 95 | 2017-09-24T06:14:04.000Z | 2022-03-22T06:23:14.000Z | #include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include "librf.h"
using namespace resumef;
using namespace std::chrono;
//_Ctype签名:void(bool, int64_t)
template<class _Ctype, typename=std::enable_if_t<std::is_invocable_v<_Ctype, bool, int64_t>>>
static void callback_get_long_with_stop(stop_token token, int64_t val, _Ctype&& cb)
{
std::thread([val, token = std::move(token), cb = std::forward<_Ctype>(cb)]
{
for (int i = 0; i < 10; ++i)
{
if (token.stop_requested())
{
cb(false, 0);
return;
}
std::this_thread::sleep_for(10ms);
}
//有可能未检测到token的停止要求
//如果使用stop_callback来停止,则务必保证检测到的退出要求是唯一的,且线程安全的
//否则,多次调用cb,会导致协程在半退出状态下,外部的awaitable_t管理的state获取跟root出现错误。
cb(true, val * val);
}).detach();
}
//token触发后,设置canceled_exception异常。
static future_t<int64_t> async_get_long_with_stop(stop_token token, int64_t val)
{
awaitable_t<int64_t> awaitable;
//在这里通过stop_callback来处理退出,并将退出转化为error_code::stop_requested异常。
//则必然会存在线程竞争问题,导致协程提前于callback_get_long_with_stop的回调之前而退出。
//同时,callback_get_long_with_stop还未必一定能检测到退出要求----毕竟只是一个要求,而不是强制。
callback_get_long_with_stop(token, val, [awaitable](bool ok, int64_t val)
{
if (ok)
awaitable.set_value(val);
else
awaitable.throw_exception(canceled_exception{error_code::stop_requested});
});
return awaitable.get_future();
}
//如果关联的协程被取消了,则触发canceled_exception异常。
static future_t<int64_t> async_get_long_with_stop(int64_t val)
{
task_t* task = current_task();
co_return co_await async_get_long_with_stop(task->get_stop_token(), val);
}
//测试取消协程
static void test_get_long_with_stop(int64_t val)
{
//异步获取值的协程
task_t* task = GO
{
try
{
int64_t result = co_await async_get_long_with_stop(val);
std::cout << result << std::endl;
}
catch (const std::logic_error& e)
{
std::cout << e.what() << std::endl;
}
};
//task的生命周期只在task代表的协程生存期间存在。
//但通过复制与其关联的stop_source,生存期可以超过task的生存期。
stop_source stops = task->get_stop_source();
//取消上一个协程的延迟协程
GO
{
co_await sleep_for(1ms * (rand() % 300));
stops.request_stop();
};
this_scheduler()->run_until_notask();
}
void resumable_main_stop_token()
{
srand((int)time(nullptr));
for (int i = 0; i < 10; ++i)
test_get_long_with_stop(i);
std::cout << "OK - stop_token!" << std::endl;
}
int main()
{
resumable_main_stop_token();
return 0;
}
| 22.673077 | 93 | 0.719254 | tearshark |
872bcde54549bdee3ba77e4d5909035efc2bb063 | 34,879 | cpp | C++ | PVPersonal.cpp | nardinan/vulture | d4be5b028d9fab4c0d23797ceb95d22f5a33cb75 | [
"FTL"
] | null | null | null | PVPersonal.cpp | nardinan/vulture | d4be5b028d9fab4c0d23797ceb95d22f5a33cb75 | [
"FTL"
] | null | null | null | PVPersonal.cpp | nardinan/vulture | d4be5b028d9fab4c0d23797ceb95d22f5a33cb75 | [
"FTL"
] | null | null | null | /* PSYCHO GAMES(C) STUDIOS - 2007 www.psychogames.net
* Project: Vulture(c)
* Author : Andrea Nardinocchi
* eMail : [email protected]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PVPersonal.h"
int PVpersonal::login(void) {
FILE *configurationfile = NULL;
char *pathname = NULL;
int length = 0;
int times = 0;
if (infos.player->logics.hasvalue("STATUS", "Account") == 0) {
if ((pathname = (char *) pvmalloc(length = (sizeof (_PVFILES "players/") + strlen(infos.message) + sizeof (".dp") + 1)))) {
snprintf(pathname, (length), _PVFILES "players/%s.dp", infos.message);
if ((configurationfile = fopen(pathname, "r"))) {
if (!(pvulture.characters.gamecharacters.getaccount(infos.message))) {
if (infos.player->load(configurationfile, pvulture.objects.gameobjects, pvulture.map.gamemap) > 0) return 1;
else {
if (infos.player->setaccount(infos.message) > 0) return 1;
if (infos.player->opvsend(pvulture.server, "[reset][bold][green]Account esistente![n]Password:[hide]") > 0) return 1;
if (infos.player->logics.delvalue("STATUS", "Account") > 0) LOG_ERROR("Unable to find STATUS->Account Logic");
if (infos.player->logics.addvalue("STATUS", "Password", 1) > 0) LOG_ERROR("Unable to add STATUS->Password Logic");
}
} else if (infos.player->opvsend(pvulture.server, "[reset][bold][red]Account gia' in uso![n]Account:") > 0) return 1;
fclose(configurationfile);
} else {
if (infos.player->opvsend(pvulture.server, "[reset][bold][red]Account non esistente![n]") > 0) return 1;
times = getvalue("TIMES", "Account", infos.player->logics, 0);
if (++times >= logintries) {
if (infos.player->opvsend(pvulture.server, "[reset][red]hai sbagliato account per %d volte![n]", logintries) > 0) return 1;
if (pathname) {
pvfree(pathname);
pathname = NULL;
}
return -1;
} else {
infos.player->logics.addvalue("TIMES", "Account", times);
if (infos.player->opvsend(pvulture.server, "Account:") > 0) return 1;
}
}
} else return 1;
if (pathname) {
pvfree(pathname);
pathname = NULL;
}
} else if (infos.player->logics.hasvalue("STATUS", "Password") == 0) {
if (compare.vcmpcase(infos.message, LSTRSIZE(infos.player->getpassword())) == 0) {
if (infos.player->opvsend(pvulture.server, "[reset][bold][green]Password corretta![n]") > 0) return 1;
if (infos.player->logics.delvalue("STATUS", "Password") > 0) LOG_ERROR("Unable to delete STATUS->Password Logic");
if (infos.player->logics.addvalue("STATUS", "Online", pvulture.stopwatch.pause()) > 0) LOG_ERROR("Unable to add STATUS->Online Logic");
if (!infos.player->position) {
if (!(infos.player->position = pvulture.map.gamemap.gettilesroot()->tile)) return 1;
}
infos.player->setonline();
if (infos.player->setlogging(true) > 0) LOG_ERROR("Unable to run SETLOGGING()");
if (infos.player->logics.hasvalue("STATUS", "Hide") != 0) {
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name entra in gioco[n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
}
if (environmentcommands.lookenvironment() > 0) return 1;
if (players.hasvalue(infos.player->getID()) != 0) {
if (players.addvalue(pvulture.characters.getsimplename(infos.player), infos.player->getID()) > 0) return 1;
else if (infos.player->pvsend(pvulture.server, "[reset][green]sei stato aggiunto alla lista utenti di gioco![n]") > 0) return 1;
}
if (infos.player->logics.hascategory("GROUP") == 0) {
if (groups.hasvalue(infos.player->logics.getvalue("GROUP", 3)) != 0) {
if (infos.player->logics.delcategory("GROUP") > 0) return 1;
if (infos.player->pvsend(pvulture.server, "[reset][red]il tuo gruppo si e' sciolto![n]") > 0) return 1;
}
}
if (infos.player->spvsend(pvulture.server, sshell) > 0) return 1;
} else {
if (infos.player->opvsend(pvulture.server, "[reset][bold][red]Password Errata![n]") > 0) return 1;
times = getvalue("TIMES", "Password", infos.player->logics, 0);
if (++times >= logintries) {
if (infos.player->opvsend(pvulture.server, "[reset][red]hai sbagliato password per %d volte![n]", logintries) > 0) return 1;
return -1;
} else {
infos.player->logics.addvalue("TIMES", "Password", times);
if (infos.player->opvsend(pvulture.server, "Password:[hide]") > 0) return 1;
}
}
}
return 0;
}
int PVpersonal::logout(bool message) {
if (compare.vcmpcase(infos.player->getaccount(), CSTRSIZE("###")) != 0) {
infos.player->logics.delvalue("STATUS", "Online");
infos.player->logics.delvalue("STATUS", "Last");
if (infos.player->logics.hascategory("FIGHT") == 0)
if (infos.player->logics.delcategory("FIGHT") > 0) LOG_ERROR("Unable to delete FIGHT Category");
if (infos.player->logics.hascategory("TIMES") == 0)
if (infos.player->logics.delcategory("TIMES") > 0) LOG_ERROR("Unable to delete TIMES Category");
if (infos.player->logics.hascategory("FOLLOW") == 0)
if (infos.player->logics.delcategory("FOLLOW") > 0) LOG_ERROR("Unable to delete FOLLOW Category");
if (pvulture.characters.gamecharacters.saveplayer(infos.player->getID(), _PVFILES "players/", pvulture.objects.gameobjects) > 0) return 1;
if (infos.player->position) {
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (message) {
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name esce dal gioco[n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
}
}
}
if (pvulture.server.unload(infos.player->getsocketID()) > 0) return 1;
if (pvulture.characters.gamecharacters.delplayer(infos.player->getID()) > 0) return 1;
infos.player = NULL;
return 0;
}
int PVpersonal::status(void) {
char *command = NULL;
char *message = NULL;
Cplayer *player = NULL;
Cmob *mob = NULL;
int value = 0;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if ((command = strings.vpop(&message)) &&
((!message) || ((infos.player->logics.hasvalue("RANK", "Admin") != 0) &&
(infos.player->logics.hasvalue("RANK", "Moderator") != 0)))) {
value = status(infos.player);
} else {
if ((player = pvulture.characters.getplayer(message, infos.player->position))) {
value = status(player);
} else if ((mob = pvulture.characters.getmob(message, infos.player->position))) {
value = status(mob);
} else if (infos.player->pvsend(pvulture.server, "[reset]non vedi nessuno con quel nome![n]") > 0) return 1;
}
} else return 1;
if (message) {
pvfree(message);
message = NULL;
}
if (command) {
pvfree(command);
command = NULL;
}
return value;
}
int PVpersonal::status(Cplayer *player) {
char *charactername = NULL;
char *backup = NULL;
int index = 0;
if (infos.player->getID() != player->getID()) {
if (infos.player->pvsend(pvulture.server, "Lo status di %s e' il seguente:[n]", charactername = pvulture.characters.gettargetname(player, infos.player)) > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
}
if (infos.player->pvsend(pvulture.server, "Livello Vita %s[n]", (backup = funny.vbar(getvalue("STATS", "LPoints", player->logics, 0), 100)) ? backup : "") > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
if (infos.player->pvsend(pvulture.server, "Livello Stamina %s[n]", (backup = funny.vbar(getvalue("STATS", "SPoints", player->logics, 0), 100)) ? backup : "") > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
if (infos.player->pvsend(pvulture.server, "[reset][n][bold]ABILITA':[n]") > 0) return 1;
while (compare.vcmpcase(chacharas[index].representation, CSTRSIZE("NULL")) != 0) {
if ((backup = pvulture.characters.getability(player, chacharas[index].representation))) {
if (infos.player->pvsend(pvulture.server, backup) > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
}
index++;
}
return 0;
}
int PVpersonal::status(Cmob *mob) {
char *charactername = NULL;
char *backup = NULL;
int index = 0;
if (infos.player->pvsend(pvulture.server, "Lo status di %s e' il seguente:[n]", charactername = pvulture.characters.gettargetname(mob, infos.player)) > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
if (infos.player->pvsend(pvulture.server, "Livello Vita %s[n]", (backup = funny.vbar(getvalue("STATS", "LPoints", mob->logics, 0), 100)) ? backup : "") > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
if (infos.player->pvsend(pvulture.server, "Livello Stamina %s[n]", (backup = funny.vbar(getvalue("STATS", "SPoints", mob->logics, 0), 100)) ? backup : "") > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
if (infos.player->pvsend(pvulture.server, "[reset][n][bold]ABILITA':[n]") > 0) return 1;
while (compare.vcmpcase(chacharas[index].representation, CSTRSIZE("NULL")) != 0) {
if ((backup = pvulture.characters.getability(mob, chacharas[index].representation))) {
if (infos.player->pvsend(pvulture.server, backup) > 0) return 1;
if (backup) {
pvfree(backup);
backup = NULL;
}
}
index++;
}
return 0;
}
int PVpersonal::position(void) {
if (compare.vcmpcase(infos.message, CSTRSIZE("alza")) == 0) {
if (getvalue("STATS", "Legs", infos.player->logics, 0) > 0) {
if ((infos.player->logics.hasvalue("STATUS", "Seated") == 0) ||
(infos.player->logics.hasvalue("STATUS", "Stretched") == 0)) {
infos.player->logics.delvalue("STATUS", "Seated");
infos.player->logics.delvalue("STATUS", "Stretched");
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][green]ti alzi in piedi[n]") > 0) return 1;
if (infos.player->logics.hasvalue("STATUS", "Hide") != 0) {
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name si alza in piedi[n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
}
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
} else if (infos.player->pvsend(pvulture.server, "[reset]sei gia' in piedi![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]hai le gambe distrutte! non riesci a muoverti![n]") > 0) return 1;
} else if (compare.vcmpcase(infos.message, CSTRSIZE("siedi")) == 0) {
if ((infos.player->logics.hasvalue("STATUS", "Seated") != 0) ||
(infos.player->logics.hasvalue("STATUS", "Stretched") == 0)) {
infos.player->logics.addvalue("STATUS", "Seated", 1);
infos.player->logics.delvalue("STATUS", "Stretched");
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][green]ti metti a sedere[n]") > 0) return 1;
if (infos.player->logics.hasvalue("STATUS", "Hide") != 0) {
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name si siede a terra[n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
}
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
} else if (infos.player->pvsend(pvulture.server, "[reset]sei gia' sedut%s![n]", (infos.player->getsex() != MALE) ? "a" : "o") > 0) return 1;
} else {
if ((infos.player->logics.hasvalue("STATUS", "Seated") == 0) ||
(infos.player->logics.hasvalue("STATUS", "Stretched") != 0)) {
infos.player->logics.delvalue("STATUS", "Seated");
infos.player->logics.addvalue("STATUS", "Stretched", 1);
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][green]ti sdrai a terra[n]") > 0) return 1;
if (infos.player->logics.hasvalue("STATUS", "Hide") != 0) {
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name si sdraia a terra[n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
}
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
} else if (infos.player->pvsend(pvulture.server, "[reset]sei gia' sdraiat%s![n]", (infos.player->getsex() != MALE) ? "a" : "o") > 0) return 1;
}
return 0;
}
int PVpersonal::inventory(void) {
char *message = NULL;
char *command = NULL;
char *backup = NULL;
char *charactername = NULL;
Cplayer *player = NULL;
Cmob *mob = NULL;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if ((command = strings.vpop(&message)) &&
((!message) || ((infos.player->logics.hasvalue("RANK", "Admin") != 0) &&
(infos.player->logics.hasvalue("RANK", "Moderator") != 0)))) {
if (!(backup = pvulture.objects.getinventory(infos.player)))
return 1;
} else {
if ((player = pvulture.characters.getplayer(message, infos.player->position))) {
if (!(backup = pvulture.objects.getinventory(player)))
return 1;
} else if ((mob = pvulture.characters.getmob(message, infos.player->position))) {
if (!(backup = pvulture.objects.getinventory(mob)))
return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]non vedi nessuno con quel nome![n]") > 0)
return 1;
}
}
if (backup) {
if (mob) {
if (infos.player->pvsend(pvulture.server, "%s sta' portando:[n]", charactername = pvulture.characters.gettargetname(mob, infos.player)) > 0)
return 1;
} else if (player) {
if (player->getID() != infos.player->getID()) {
if (infos.player->pvsend(pvulture.server, "%s sta' portando:[n]", charactername = pvulture.characters.gettargetname(player, infos.player)) > 0)
return 1;
} else
if (infos.player->pvsend(pvulture.server, "stai portando:[n]") > 0)
return 1;
} else
if (infos.player->pvsend(pvulture.server, "stai portando:[n]") > 0)
return 1;
if (infos.player->pvsend(pvulture.server, backup) > 0)
return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
pvfree(backup);
backup = NULL;
}
if (message) {
pvfree(message);
message = NULL;
}
if (command) {
pvfree(command);
command = NULL;
}
return 0;
}
int PVpersonal::points(void) {
char *command = NULL;
char *message = NULL;
char *text = NULL;
char *pointer = NULL;
Cplayer *player = NULL;
Cmob *mob = NULL;
int value = 0;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if ((command = strings.vpop(&message)) && (message)) {
if ((pointer = strchr(message, ':'))) {
for (text = pointer + 1; *text == ' '; text++);
do {
*pointer-- = '\0';
} while ((pointer > message) && (*pointer == ' '));
if (strlen(text) > 0) {
if ((player = pvulture.characters.getplayer(message, infos.player->position))) {
value = points(player, text);
} else if ((mob = pvulture.characters.getmob(message, infos.player->position))) {
value = points(mob, text);
} else if (infos.player->pvsend(pvulture.server, "[reset]non vedi nessuno con quel nome qui![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]e' necessario specificare una categoria e un punteggio[n]") > 0) return 1;
} else {
value = points(infos.player, message);
}
} else if (infos.player->pvsend(pvulture.server, "[reset]e' necessario specificare una categoria e un punteggio[n]") > 0) return 1;
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
} else return 1;
if (command) {
pvfree(command);
command = NULL;
}
if (message) {
pvfree(message);
message = NULL;
}
return 0;
}
int PVpersonal::points(Cplayer *player, char *message) {
char *charactername = NULL;
char *category = NULL;
char *key = NULL;
int value = 0;
if ((strings.vsscanf(message, '.', "ssd", &category, &key, &value) == 0) &&
(player->logics.hasvalue(category, key) == 0)) {
if (player->logics.delvalue(category, key) > 0) LOG_ERROR("Unable to delete %s->%s Logic", category, key);
else if (player->logics.addvalue(category, key, value) > 0) LOG_ERROR("Unable to add %s->%s Logic", category, key);
else if (player->getID() != infos.player->getID()) {
if (infos.player->pvsend(pvulture.server, "[reset][green]hai modificato il valore di %s.%s di %s in %d[n]", category, key, charactername = pvulture.characters.gettargetname(player, infos.player), value) > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
} else if (infos.player->pvsend(pvulture.server, "[reset][green]hai modificato il tuo valore di %s.%s in %d[n]", category, key, value) > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]non esiste una simile categoria/chiave nella logica[n]") > 0) return 1;
if (key) {
pvfree(key);
key = NULL;
}
if (category) {
pvfree(category);
category = NULL;
}
return 0;
}
int PVpersonal::points(Cmob *mob, char *message) {
char *charactername = NULL;
char *category = NULL;
char *key = NULL;
int value = 0;
if ((strings.vsscanf(message, '.', "ssd", &category, &key, &value) == 0) &&
(mob->logics.hasvalue(category, key) == 0)) {
if (mob->logics.delvalue(category, key) > 0) LOG_ERROR("Unable to delete %s->%s Logic", category, key);
else if (mob->logics.addvalue(category, key, value) > 0) LOG_ERROR("Unable to add %s->%s Logic", category, key);
else if (mob->getID() != infos.player->getID()) {
if (infos.player->pvsend(pvulture.server, "[reset]hai modificato il valore di %s.%s di %s in %d[n]", category, key, charactername = pvulture.characters.gettargetname(mob, infos.player), value) > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
} else if (infos.player->pvsend(pvulture.server, "[reset][green]hai modificato il tuo valore di %s.%s in %d[n]", category, key, value) > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]non esiste una simile categoria/chiave nella logica[n]") > 0) return 1;
if (key) {
pvfree(key);
key = NULL;
}
if (category) {
pvfree(category);
category = NULL;
}
return 0;
}
int PVpersonal::password(void) {
char *message = NULL;
char *command = NULL;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if ((command = strings.vpop(&message)) && (message)) {
if (infos.player->setpassword(message) > 0) {
if (infos.player->pvsend(pvulture.server, "[reset]la password e' troppo corta![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset][green]hai cambiato la password![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]devi specificare la nuova password![n]") > 0) return 1;
} else return 1;
if (message) {
pvfree(message);
message = NULL;
}
if (command) {
pvfree(command);
command = NULL;
}
return 0;
}
int PVpersonal::appearance(void) {
int position = 0;
char *message = NULL;
char *command = NULL;
char *completename = NULL;
char *smalldescription = NULL;
char *largedescription = NULL;
char *race = NULL;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if ((command = strings.vpop(&message)) && (message)) {
position = getvalue("SYSTEM", "Position", infos.player->logics, 0);
if (strings.vsscanf(message, ':', "ssss", &completename, &smalldescription, &largedescription, &race) == 0) {
if (infos.player->logics.hasvalue("RACE", 0) == 0) {
if (infos.player->logics.delvalue("RACE", 0) > 0) LOG_ERROR("Unable to delete RACE->%s Logic", race);
}
if (infos.player->logics.addvalue("RACE", race, 0) > 0) LOG_ERROR("Unable to add RACE->%s Logic", race);
if (infos.player->descriptions.deldescription(position) == 0) {
infos.player->descriptions.adddescription(position, completename, smalldescription, largedescription);
if (infos.player->pvsend(pvulture.server, "[reset][green]hai cambiato il tuo aspetto e la tua razza![n]") > 0) return 1;
} else return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]devi specificare un nuovo aspetto per il tuo personaggio![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]devi specificare un nuovo aspetto per il tuo personaggio![n]") > 0) return 1;
} else return 1;
if (message) {
pvfree(message);
message = NULL;
}
if (command) {
pvfree(command);
command = NULL;
}
if (completename) {
pvfree(completename);
completename = NULL;
}
if (smalldescription) {
pvfree(smalldescription);
smalldescription = NULL;
}
if (largedescription) {
pvfree(largedescription);
largedescription = NULL;
}
if (race) {
pvfree(race);
race = NULL;
}
return 0;
}
int PVpersonal::emoticon(void) {
char *message = NULL;
char *text = NULL;
char *emoticon = NULL;
char *buffer = NULL;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
emoticon = getemoticon(&message);
for (text = message + 1; *text == ' '; text++);
if (strlen(text) > 0) {
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][green]ti vedi mentre il tuo [bold]'io'[reset][green], %s %s[n]", text, (emoticon) ? emoticon : "") > 0) return 1;
if (infos.player->logics.hasvalue("STATUS", "Hide") != 0) {
if (spvsend(pvulture.server, infos.player->position, (buffer = allocate.vsalloc("[n][yellow]$name %s %s[n]", text, (emoticon) ? emoticon : "")), (Ccharacter *) infos.player) > 0) return 1;
}
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
} else if (infos.player->pvsend(pvulture.server, "[reset]devi specificare un'azione![n]") > 0) return 1;
} else return 1;
if (message) {
pvfree(message);
message = NULL;
}
if (emoticon) {
pvfree(emoticon);
emoticon = NULL;
}
if (buffer) {
pvfree(buffer);
buffer = NULL;
}
return 0;
}
int PVpersonal::meet(void) {
char *command = NULL;
char *message = NULL;
Cplayer *player = NULL;
Cmob *mob = NULL;
int value = 0;
if ((message = (char *) pvmalloc(strlen(infos.message) + 1))) {
strcpy(message, infos.message);
message[strlen(infos.message)] = '\0';
if ((command = strings.vpop(&message)) && (message)) {
if ((player = pvulture.characters.getplayer(message, infos.player->position))) {
value = meet(player);
} else if ((mob = pvulture.characters.getmob(message, infos.player->position))) {
value = meet(mob);
} else if (infos.player->pvsend(pvulture.server, "[reset]non vedi nessuno con quel nome qui![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]e' necessario specificare un nome![n]") > 0) return 1;
} else return 1;
if (message) {
pvfree(message);
message = NULL;
}
if (command) {
pvfree(command);
command = NULL;
}
return value;
}
int PVpersonal::meet(Cplayer *player) {
char *charactername = NULL;
if (player->getID() != infos.player->getID()) {
if (!(player->getcharacter(infos.player->getID(), PLAYER))) {
if (player->addcharacter(infos.player->getID(), PLAYER) > 0) return 1;
if (infos.player->pvsend(pvulture.server, "[reset][yellow]ti presenti a %s[n]", charactername = pvulture.characters.gettargetname(player, infos.player)) > 0) return 1;
if (player->pvsend(pvulture.server, "[reset][n][yellow]%s ti si presenta[n]", pvulture.characters.getsimplename(infos.player)) > 0) return 1;
if (player->spvsend(pvulture.server, sshell) > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]da quel che sembra, lui ti conosce di gia'![n]") > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]stai parlando di te stess%s![n]", (infos.player->getsex() != MALE) ? "a" : "o") > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
return 0;
}
int PVpersonal::meet(Cmob *mob) {
char *charactername = NULL;
if (!(mob->getcharacter(infos.player->getID(), PLAYER))) {
if (mob->addcharacter(infos.player->getID(), PLAYER) > 0) return 1;
if (infos.player->pvsend(pvulture.server, "[reset][yellow]ti presenti a %s[n]", charactername = pvulture.characters.gettargetname(mob, infos.player)) > 0) return 1;
if (intelligenceevents.meet(mob, infos.player) > 0) return 1;
} else if (infos.player->pvsend(pvulture.server, "[reset]da quel che sembra, lui ti conosce di gia'![n]") > 0) return 1;
if (charactername) {
pvfree(charactername);
charactername = NULL;
}
return 0;
}
int PVpersonal::hide(void) {
if (infos.player->logics.hasvalue("STATUS", "Hide") == 0) {
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][yellow]spunti fuori dall'ombra![n]") > 0) return 1;
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name appare da una nuvola di fumo![n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
if (infos.player->logics.delvalue("STATUS", "Hide") > 0) LOG_ERROR("Unable to delete STATUS->Hide Logic");
} else {
if (infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->delplayer(infos.player->getID()) > 0) return 1;
}
if (infos.player->pvsend(pvulture.server, "[reset][yellow]ti nascondi nell'ombra![n]") > 0) return 1;
if (spvsend(pvulture.server, infos.player->position, "[reset][n][yellow]$name scompare in una nuvola di fumo![n]", (Ccharacter *) infos.player) > 0) return 1;
if (infos.player->position->spvsend(pvulture.server, sshell) > 0) return 1;
if (!infos.player->position->getplayer(infos.player->getID())) {
if (infos.player->position->addplayer(infos.player) > 0) return 1;
}
if (infos.player->logics.addvalue("STATUS", "Hide", 1) > 0) LOG_ERROR("Unable to add STATUS->Hide Logic");
}
return 0;
}
PVpersonal personalcommands;
int personal(void) {
if (compare.vcmpcase(infos.message, CSTRSIZE("status")) == 0) {
if (personalcommands.status() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.STATUS()");
} else if (compare.vcmpcase(infos.message, CSTRSIZE("inventario")) == 0) {
if (personalcommands.inventory() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.INVENTORY()");
} else if (compare.vcmpcase(infos.message, CSTRSIZE("passwd")) == 0) {
if (personalcommands.password() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.PASSWORD()");
} else if ((compare.vcmpcase(infos.message, CSTRSIZE("alza")) == 0) ||
(compare.vcmpcase(infos.message, CSTRSIZE("siedi")) == 0) ||
(compare.vcmpcase(infos.message, CSTRSIZE("sdraia")) == 0)) {
if (personalcommands.position() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.POSITION()");
} else if ((compare.vcmpcase(infos.message, CSTRSIZE("aspetto")) == 0) &&
((infos.player->logics.hasvalue("RANK", "Admin") == 0) ||
(infos.player->logics.hasvalue("RANK", "Moderator") == 0))) {
if (personalcommands.appearance() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.APPEARANCE()");
} else if ((compare.vcmpcase(infos.message, CSTRSIZE("valore")) == 0) &&
((infos.player->logics.hasvalue("RANK", "Admin") == 0) ||
(infos.player->logics.hasvalue("RANK", "Moderator") == 0))) {
if (personalcommands.points() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.POINTS()");
} else if (compare.vcmpcase(infos.message, CSTRSIZE(":")) == 0) {
if (personalcommands.emoticon() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.EMOTICON()");
} else if (compare.vcmpcase(infos.message, CSTRSIZE("presenta")) == 0) {
if (personalcommands.meet() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.MEET()");
} else if ((compare.vcmpcase(infos.message, CSTRSIZE("nascondi")) == 0) &&
((infos.player->logics.hasvalue("RANK", "Admin") == 0) ||
(infos.player->logics.hasvalue("RANK", "Moderator") == 0))) {
if (personalcommands.hide() > 0) LOG_ERROR("Unable to run PERSONALCOMMANDS.HIDE()");
} else if (infos.player->pvsend(pvulture.server, "[reset]prego?[n]") > 0) return 1;
return 0;
}
| 50.918248 | 229 | 0.579718 | nardinan |
872d353085923567ca1f97e3c39511c08b594fde | 5,076 | cpp | C++ | csapex_sample_consensus/src/nodes/ransac.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 2 | 2016-09-02T15:33:22.000Z | 2019-05-06T22:09:33.000Z | csapex_sample_consensus/src/nodes/ransac.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 1 | 2021-02-14T19:53:30.000Z | 2021-02-14T19:53:30.000Z | csapex_sample_consensus/src/nodes/ransac.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 6 | 2016-10-12T00:55:23.000Z | 2021-02-10T17:49:25.000Z | /// PROJECT
#include "sample_consensus.hpp"
namespace csapex
{
using namespace connection_types;
class Ransac : public SampleConsensus
{
public:
Ransac() = default;
void setupParameters(Parameterizable& parameters) override
{
SampleConsensus::setupParameters(parameters);
parameters.addParameter(param::factory::declareBool("use outlier probability", false), ransac_parameters_.use_outlier_probability);
parameters.addConditionalParameter(param::factory::declareRange("outlier probability", 0.01, 1.0, 0.9, 0.01), [this]() { return ransac_parameters_.use_outlier_probability; },
ransac_parameters_.outlier_probability);
parameters.addParameter(param::factory::declareValue("random seed", -1), std::bind(&Ransac::setupRandomGenerator, this));
parameters.addParameter(param::factory::declareRange("maximum sampling retries", 1, 1000, 100, 1), ransac_parameters_.maximum_sampling_retries);
}
virtual void process() override
{
PointCloudMessage::ConstPtr msg(msg::getMessage<PointCloudMessage>(in_cloud_));
boost::apply_visitor(PointCloudMessage::Dispatch<Ransac>(this, msg), msg->value);
}
template <class PointT>
void inputCloud(typename pcl::PointCloud<PointT>::ConstPtr cloud)
{
std::shared_ptr<std::vector<pcl::PointIndices>> out_inliers(new std::vector<pcl::PointIndices>);
std::shared_ptr<std::vector<pcl::PointIndices>> out_outliers(new std::vector<pcl::PointIndices>);
std::shared_ptr<std::vector<ModelMessage>> out_models(new std::vector<ModelMessage>);
/// retrieve the model to use
auto model = getModel<PointT>(cloud);
/// get indices of points to use
std::vector<int> prior_inlier;
std::vector<int> prior_outlier;
getInidicesFromInput(prior_inlier);
if (prior_inlier.empty()) {
if (keep_invalid_as_outlier_)
getIndices<PointT>(cloud, prior_inlier, prior_outlier);
else
getIndices<PointT>(cloud, prior_inlier);
}
/// prepare algorithm
ransac_parameters_.assign(sac_parameters_);
typename csapex_sample_consensus::Ransac<PointT>::Ptr sac(new csapex_sample_consensus::Ransac<PointT>(prior_inlier, ransac_parameters_, rng_));
pcl::PointIndices outliers;
pcl::PointIndices inliers;
inliers.header = cloud->header;
outliers.header = cloud->header;
if (fit_multiple_models_) {
outliers.indices = sac->getIndices();
int model_searches = 0;
while ((int)outliers.indices.size() >= minimum_residual_cloud_size_) {
auto working_model = model->clone();
sac->computeModel(working_model);
if (working_model) {
inliers.indices.clear();
outliers.indices.clear();
working_model->getInliersAndOutliers(ransac_parameters_.model_search_distance, inliers.indices, outliers.indices);
if ((int)inliers.indices.size() > minimum_model_cloud_size_)
out_inliers->emplace_back(inliers);
else
out_outliers->emplace_back(inliers);
sac->setIndices(outliers.indices);
}
++model_searches;
if (maximum_model_count_ != -1 && model_searches >= maximum_model_count_)
break;
}
out_outliers->emplace_back(outliers);
} else {
sac->computeModel(model);
if (model) {
model->getInliersAndOutliers(prior_inlier, ransac_parameters_.model_search_distance, inliers.indices, outliers.indices);
if ((int)inliers.indices.size() > minimum_model_cloud_size_) {
out_inliers->emplace_back(inliers);
} else {
out_outliers->emplace_back(inliers);
}
outliers.indices.insert(outliers.indices.end(), prior_outlier.begin(), prior_outlier.end());
out_outliers->emplace_back(outliers);
}
}
msg::publish<GenericVectorMessage, pcl::PointIndices>(out_inlier_indices_, out_inliers);
msg::publish<GenericVectorMessage, pcl::PointIndices>(out_outlier_indices_, out_outliers);
msg::publish<GenericVectorMessage, ModelMessage>(out_models_, out_models);
}
protected:
csapex_sample_consensus::RansacParameters ransac_parameters_;
std::default_random_engine rng_; /// keep the random engine alive for better number generation
inline void setupRandomGenerator()
{
int seed = readParameter<int>("random seed");
if (seed >= 0) {
rng_ = std::default_random_engine(seed);
} else {
std::random_device rd;
rng_ = std::default_random_engine(rd());
}
}
};
} // namespace csapex
CSAPEX_REGISTER_CLASS(csapex::Ransac, csapex::Node)
| 40.608 | 182 | 0.635737 | AdrianZw |
873b2b9ba23dd7eaec97f9dbf040f79215dfd8a4 | 3,904 | hpp | C++ | kernel/integration/x64/amd/arch_support.hpp | lusceu/hypervisor | 012a2d16f96dcfc256a3cac9aa22e238c8160a0c | [
"MIT"
] | null | null | null | kernel/integration/x64/amd/arch_support.hpp | lusceu/hypervisor | 012a2d16f96dcfc256a3cac9aa22e238c8160a0c | [
"MIT"
] | null | null | null | kernel/integration/x64/amd/arch_support.hpp | lusceu/hypervisor | 012a2d16f96dcfc256a3cac9aa22e238c8160a0c | [
"MIT"
] | null | null | null | /// @copyright
/// Copyright (C) 2020 Assured Information Security, Inc.
///
/// @copyright
/// 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:
///
/// @copyright
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// @copyright
/// 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.
#ifndef ARCH_SUPPORT_HPP
#define ARCH_SUPPORT_HPP
#include <mk_interface.hpp>
#include <bsl/convert.hpp>
#include <bsl/debug.hpp>
#include <bsl/discard.hpp>
#include <bsl/errc_type.hpp>
#include <bsl/safe_integral.hpp>
#include <bsl/unlikely.hpp>
namespace integration
{
/// <!-- description -->
/// @brief Initializes a VPS with architecture specific stuff.
///
/// <!-- inputs/outputs -->
/// @param handle the handle to use
/// @param vpsid the VPS being intialized
/// @return Returns bsl::errc_success on success and bsl::errc_failure
/// on failure.
///
[[nodiscard]] constexpr auto
init_vps(syscall::bf_handle_t &handle, bsl::safe_uint16 const &vpsid) noexcept -> bsl::errc_type
{
bsl::errc_type ret{};
/// NOTE:
/// - Set up ASID
///
constexpr bsl::safe_uint64 guest_asid_idx{bsl::to_u64(0x0058U)};
constexpr bsl::safe_uint32 guest_asid_val{bsl::to_u32(0x1U)};
ret = syscall::bf_vps_op_write32(handle, vpsid, guest_asid_idx, guest_asid_val);
if (bsl::unlikely(!ret)) {
bsl::print<bsl::V>() << bsl::here();
return ret;
}
/// NOTE:
/// - Set up intercept controls. On AMD, we need to intercept
/// VMRun, and CPUID if we plan to support reporting and stopping.
///
constexpr bsl::safe_uint64 intercept_instruction1_idx{bsl::to_u64(0x000CU)};
constexpr bsl::safe_uint32 intercept_instruction1_val{bsl::to_u32(0x00040000U)};
constexpr bsl::safe_uint64 intercept_instruction2_idx{bsl::to_u64(0x0010U)};
constexpr bsl::safe_uint32 intercept_instruction2_val{bsl::to_u32(0x00000001U)};
ret = syscall::bf_vps_op_write32(
handle, vpsid, intercept_instruction1_idx, intercept_instruction1_val);
if (bsl::unlikely(!ret)) {
bsl::print<bsl::V>() << bsl::here();
return ret;
}
ret = syscall::bf_vps_op_write32(
handle, vpsid, intercept_instruction2_idx, intercept_instruction2_val);
if (bsl::unlikely(!ret)) {
bsl::print<bsl::V>() << bsl::here();
return ret;
}
/// NOTE:
/// - Report success. Specifically, when we return to the root OS,
/// setting RAX tells the loader that the hypervisor was successfully
/// set up.
///
ret = syscall::bf_vps_op_write_reg(
handle, vpsid, syscall::bf_reg_t::bf_reg_t_rax, bsl::ZERO_UMAX);
if (bsl::unlikely(!ret)) {
bsl::print<bsl::V>() << bsl::here();
return ret;
}
return ret;
}
}
#endif
| 36.148148 | 100 | 0.649078 | lusceu |
873caa37bbce2f14d1786d96714d740dd2881fc6 | 3,233 | cpp | C++ | Problems/LongestSubstringWithoutRepeatingCharacters/LongestSubstringWithoutRepeatingCharacters.cpp | avramidis/leetcode-problems | 66bf8eecdebe8d2b6bb45a23897a0c1938725116 | [
"BSL-1.0"
] | null | null | null | Problems/LongestSubstringWithoutRepeatingCharacters/LongestSubstringWithoutRepeatingCharacters.cpp | avramidis/leetcode-problems | 66bf8eecdebe8d2b6bb45a23897a0c1938725116 | [
"BSL-1.0"
] | null | null | null | Problems/LongestSubstringWithoutRepeatingCharacters/LongestSubstringWithoutRepeatingCharacters.cpp | avramidis/leetcode-problems | 66bf8eecdebe8d2b6bb45a23897a0c1938725116 | [
"BSL-1.0"
] | null | null | null | #define CATCH_CONFIG_MAIN
#include <iostream>
#include "catch.hpp"
class Solution {
public:
bool uniquestring(std::string s, int start, int end) {
for (int i = start; i < end; i++) {
for (int j = i + 1; j <= end; j++) {
if (s[i] == s[j]) {
return false;
}
}
}
return true;
}
int lengthOfLongestSubstring(std::string s) {
if (s.size() == 0)
{
return 0;
}
if (s.size() == 1)
{
return 1;
}
int result = 1;
for (size_t i = 0; i < s.size(); i++) {
for (size_t j = i + result; j < s.size(); j++) {
if (uniquestring(s, i, j)) {
if (j - i + 1 > result) {
result = j - i + 1;
}
}
}
}
return result;
}
};
TEST_CASE("Unique characters in string")
{
Solution solution;
SECTION("Input set 1") {
std::string input = "abcabcbb";
bool result = false;
BENCHMARK("Check if the string is made of unique characters")
{
result = solution.uniquestring(input, 0, 7);
}
REQUIRE(result == false);
}
SECTION("Input set 2") {
std::string input = "a";
bool result = false;
BENCHMARK("Check if the string is made of unique characters")
{
result = solution.uniquestring(input, 0, 0);
}
REQUIRE(result == true);
}
SECTION("Input set 3") {
std::string input = "au";
bool result = false;
BENCHMARK("Check if the string is made of unique characters")
{
result = solution.uniquestring(input, 0, 1);
}
REQUIRE(result == true);
}
}
TEST_CASE("Longest Substring Without Repeating Characters")
{
Solution solution;
SECTION("Input set 1") {
std::string input = "abcabcbb";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 3);
}
SECTION("Input set 2") {
std::string input = "bbbbb";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 1);
}
SECTION("Input set 3") {
std::string input = "pwwkew";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 3);
}
SECTION("Input set 4") {
std::string input = "c";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 1);
}
SECTION("Input set 5") {
std::string input = "au";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 2);
}
SECTION("Input set 6") {
std::string input = "";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 0);
}
SECTION("Input set 6") {
std::string input = "dvdf";
int result = 0;
BENCHMARK("Calculate length of the longest substring with unique characters")
{
result = solution.lengthOfLongestSubstring(input);
}
REQUIRE(result == 3);
}
} | 20.993506 | 79 | 0.63656 | avramidis |
8750c0266c8d52d61c41c50a4592b2709ca57cc0 | 27,434 | cpp | C++ | experiment.cpp | ChristophKuhfuss/stneatexperiment | ca754fb679658072f4dacc4354a319db3faf660b | [
"BSD-3-Clause"
] | null | null | null | experiment.cpp | ChristophKuhfuss/stneatexperiment | ca754fb679658072f4dacc4354a319db3faf660b | [
"BSD-3-Clause"
] | null | null | null | experiment.cpp | ChristophKuhfuss/stneatexperiment | ca754fb679658072f4dacc4354a319db3faf660b | [
"BSD-3-Clause"
] | null | null | null | #include <iostream>
#include <string.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <sstream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <sstream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <chrono>
#include <sys/stat.h>
#include <sqlite3.h>
#include "experiment.hpp"
#include <signal.h>
string Experiment::temp_pop_filename = "temp_pop";
string Experiment::db_filename = "neat.db";
int Experiment::max_db_retry = 100;
int Experiment::db_sleeptime = 50;
string Experiment::path_to_supertux_executable = "./bin/build/supertux2";
int Experiment::cur_gen = 0;
bool Experiment::new_top = true;
int Experiment::top_genome_gen_id = 0;
int Experiment::top_genome_id = 0;
double Experiment::top_fitness = 0;
int Experiment::num_winner_genomes = 0;
float Experiment::fitness_sum = 0;
float Experiment::airtime_sum = 0;
float Experiment::groundtime_sum = 0;
int Experiment::jump_sum = 0;
double Experiment::evaluation_time = 0;
Parameters Experiment::params;
vector<Genome*> Experiment::genomes;
vector<PhenotypeBehavior> Experiment::archive;
int main(int argc, char **argv) {
std::cout << "SuperTux + NEAT interface and experiment code by Christoph Kuhfuss 2018" << std::endl;
std::cout << "Using the original SuperTux source and the MultiNEAT framework by Peter Chervenski (https://github.com/peter-ch/MultiNEAT)" << std::endl;
Experiment::parse_commandline_arguments(argc, argv);
Experiment::fix_filenames();
Experiment::parse_experiment_parameters();
Experiment::params = Experiment::init_params();
Experiment experiment;
experiment.run_evolution();
return 0;
}
Experiment::Experiment() :
start_genome(0, ExperimentParameters::AMOUNT_RANGE_SENSORS + ExperimentParameters::AMOUNT_DEPTH_SENSORS + ExperimentParameters::AMOUNT_PIESLICE_SENSORS * 2 + 1, ExperimentParameters::num_hidden_start_neurons,
6, false, UNSIGNED_SIGMOID, UNSIGNED_SIGMOID, 1, params),
pop(strcmp(ExperimentParameters::pop_filename.c_str(), "") ?
Population(ExperimentParameters::pop_filename.c_str()) : Population(start_genome, params, true, 2.0, (ExperimentParameters::using_seed ? ExperimentParameters::seed : (int) time(0)))),
total_gen_time(0)
{
if (ExperimentParameters::hyperneat)
{
generate_substrate();
}
}
Experiment::~Experiment()
{
}
void Experiment::run_evolution() {
std::remove(db_filename.c_str());
init_db();
for (int i = 1; i <= ExperimentParameters::max_gens; i++) {
std::cout << "Working on generation #" << i << "..." << std::endl;
Experiment::new_top = false;
num_winner_genomes = 0;
fitness_sum = 0;
airtime_sum = 0;
groundtime_sum = 0;
jump_sum = 0;
evaluation_time = 0;
cur_gen = i;
refresh_genome_list();
if (ExperimentParameters::novelty_search) {
std::vector<PhenotypeBehavior>* behaviors = new std::vector<PhenotypeBehavior>();
for (int i = 0; i < genomes.size(); i++)
behaviors->push_back(Behavior());
pop.InitPhenotypeBehaviorData(behaviors, &archive);
}
// Prepare db file...
update_db();
// Run supertux processes...
start_processes();
// ... and get the fitness values from the db file
// Also update info about the generation
set_fitness_values();
update_gen_info();
std::cout << "Done. Top fitness: " << top_fitness << " by individual #" << top_genome_id << ", generation #" << top_genome_gen_id << std::endl;
std::cout << "Evaluation time: " << (int) (evaluation_time / 60) << "min" << (int) evaluation_time % 60 << "sec" << std::endl;
std::cout << num_winner_genomes << " genome(s) out of " << genomes.size() << " finished the level (" << num_winner_genomes / (double) genomes.size() * 100 << "%)" << std::endl;
if (ExperimentParameters::autosave_best && Experiment::new_top) {
std::ostringstream ss;
ss << "./neat_gen" << cur_gen;
save_pop(ss.str().c_str());
}
else if (!ExperimentParameters::autosave_best && i % ExperimentParameters::autosave_interval == 0) {
std::ostringstream ss;
ss << "./neat_gen" << cur_gen;
save_pop(ss.str().c_str());
}
std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
pop.Epoch();
std::chrono::time_point<std::chrono::high_resolution_clock> finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
total_gen_time += elapsed.count();
}
}
void Experiment::start_processes()
{
// Save pop to single file for all child processes to read
pop.Save(temp_pop_filename.c_str());
// Distribute genomes as evenly as possible
int remaining_genome_count = genomes.size();
int cores_left = ExperimentParameters::num_cores;
std::vector<int> startindices;
std::vector<int> endindices;
int curindex = 0;
for (int j = 0; j < ExperimentParameters::num_cores; j++) {
startindices.push_back(++curindex - 1);
int single_genome_count = remaining_genome_count / cores_left;
if (remaining_genome_count % cores_left)
single_genome_count++;
remaining_genome_count -= single_genome_count;
cores_left--;
curindex += single_genome_count - 1;
endindices.push_back(curindex - 1);
}
// Build the GNU parallel command, include all parameter files and the levelfile
std::stringstream ss;
ss << "parallel --no-notice --xapply ";
ss << path_to_supertux_executable;
ss << " --neat";
// if (Experiment::novelty_search) ss << " --noveltysearch";
if (ExperimentParameters::hyperneat) ss << " --hyperneat";
// All child processes read from the same population file
ss << " --popfile " << boost::filesystem::canonical(temp_pop_filename);
// Only add experiment and MultiNEAT param files if they're configured...
if (strcmp(ExperimentParameters::experimentparam_filename.c_str(), "")) ss << " --experimentparamfile " << ExperimentParameters::experimentparam_filename;
if (strcmp(ExperimentParameters::param_filename.c_str(), "")) ss << " --paramfile " << ExperimentParameters::param_filename;
ss << " --dbfile " << boost::filesystem::canonical(db_filename);
ss << " --curgen " << cur_gen;
ss << " --fromtogenome ::: ";
for (std::vector<int>::iterator it = startindices.begin(); it != startindices.end(); ++it) {
ss << *it << " ";
}
ss << "::: ";
for (std::vector<int>::iterator it = endindices.begin(); it != endindices.end(); ++it) {
ss << *it << " ";
}
ss << "::: '";
ss << ExperimentParameters::path_to_level;
ss << "'";
// std::cout << ss.str() << std::endl;
// Ready to rumble, don't forget to measure the time
std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
std::system(ss.str().c_str());
std::chrono::time_point<std::chrono::high_resolution_clock> finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
evaluation_time = elapsed.count();
// Remove temporary population file. If we have to, we'll make a new one
std::remove(temp_pop_filename.c_str());
}
void Experiment::init_db()
{
sqlite3* db;
sqlite3_open("neat.db", &db);
sqlite3_busy_handler(db, busy_handler, (void*) nullptr);
char* err;
std::stringstream ss;
ss << "CREATE TABLE RUN_INFO (id INT PRIMARY KEY NOT NULL, num_genomes INT, avg_fitness REAL, time REAL, avg_airtime REAL, avg_groundtime REAL, avg_jumps REAL, top_fitness REAL, amt_winners INT);";
sqlite3_exec(db, ss.str().c_str(), 0, 0, &err);
sqlite3_close(db);
}
void Experiment::update_db()
{
sqlite3* db;
sqlite3_open("neat.db", &db);
sqlite3_busy_handler(db, busy_handler, (void*) nullptr);
char* err;
std::stringstream ss;
ss.str("");
ss << "CREATE TABLE GEN" << cur_gen << "(id INT PRIMARY KEY NOT NULL, fitness REAL, airtime REAL, groundtime REAL, num_jumps INT, qLeft REAL, qRight REAL, qUp REAL, qDown REAL, qJump REAL, qAction REAL, won INT);";
sqlite3_exec(db, ss.str().c_str(), 0, 0, &err);
for(std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it) {
ss.str("");
// Negative fitness if not evaluated yet. If fitness values stay negative, NEAT might just break
// Last values are for ns behavior
ss << "INSERT INTO GEN" << cur_gen << " VALUES(" << (*it)->GetID() << ", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);";
sqlite3_exec(db, ss.str().c_str(), 0, 0, &err);
}
sqlite3_close(db);
}
void Experiment::set_fitness_values()
{
sqlite3* db;
sqlite3_open("neat.db", &db);
sqlite3_busy_handler(db, busy_handler, (void*) nullptr);
char* err;
std::stringstream ss;
ss << "SELECT * FROM gen" << cur_gen << ";";
sqlite3_exec(db, ss.str().c_str(), (ExperimentParameters::novelty_search ? select_handler_ns : select_handler), 0, &err);
if (ExperimentParameters::novelty_search) {
for (std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it) {
if ((*it)->m_PhenotypeBehavior->m_Data[0].size() == 0) {
std::cout << "ERROR OCCURED WITH GENOME #" << (*it)->GetID() << std::endl;
}
}
update_sparsenesses();
}
sqlite3_close(db);
}
void Experiment::update_gen_info()
{
sqlite3* db;
sqlite3_open("neat.db", &db);
sqlite3_busy_handler(db, busy_handler, (void*) nullptr);
char* err;
std::stringstream ss;
ss << "INSERT INTO RUN_INFO VALUES(" << cur_gen << ", " << genomes.size() << ", " << fitness_sum / genomes.size() << ", " << evaluation_time << ", " << (airtime_sum / (double) genomes.size()) << ", " << (groundtime_sum / (double) genomes.size()) << ", " << ((double) jump_sum) / genomes.size() << ", " << top_fitness << ", " << num_winner_genomes << ");";
sqlite3_exec(db, ss.str().c_str(), 0, 0, &err);
sqlite3_close(db);
}
void Experiment::refresh_genome_list()
{
genomes.clear();
for (unsigned int i = 0; i < pop.m_Species.size(); i++) {
Species* cur = &pop.m_Species[i];
// std::cout << "Species #" << cur->ID() << " has " << cur->m_Individuals.size() << " individuals" << std::endl;
for (unsigned int j = 0; j < cur->m_Individuals.size(); j++) {
cur->m_Individuals[j].m_PhenotypeBehavior = new Behavior();
genomes.push_back(&cur->m_Individuals[j]);
}
// Probably unneccessary
sort(genomes.begin(), genomes.end(), [ ](const Genome* lhs, const Genome* rhs)
{
return lhs->GetID() < rhs->GetID();
});
}
}
double Experiment::sparseness(Genome* g)
{
std::vector<double> distances;
double sum = 0;
int amt = 0;
for (std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it) {
//std::cout << "Calculating distance between genomes #" << g->GetID() << " and #" << (*it)->GetID() << std::endl;
amt++;
distances.push_back(g->m_PhenotypeBehavior->Distance_To((*it)->m_PhenotypeBehavior));
}
for (std::vector<PhenotypeBehavior>::iterator it = archive.begin(); it != archive.end(); ++it) {
amt++;
distances.push_back(g->m_PhenotypeBehavior->Distance_To(&(*it)));
}
sort(distances.begin(), distances.end(), [ ](const double lhs, const double rhs)
{
return lhs < rhs;
});
for (int i = 0; i < params.NoveltySearch_K; i++) {
sum += distances[i];
}
// std::cout << "Sparseness for genome #" << g->GetID() << " is " << sum / amt << std::endl;
if (amt > 0) {
double sparseness = sum / amt;
if (sparseness > params.NoveltySearch_P_min) {
archive.push_back(*(g->m_PhenotypeBehavior));
}
return sum / amt;
}
else
return 0;
}
void Experiment::update_sparsenesses()
{
for (std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it)
{
(*it)->SetFitness(pop.ComputeSparseness(*(*it)));
(*it)->SetEvaluated();
}
}
void Experiment::generate_substrate()
{
SensorManager sm;
sm.initSensors();
std::vector<std::vector<double>> input_coords;
std::vector<std::vector<double>> hidden_coords; // TODO: Add support for hidden neurons (third dimension, arrange in a circle)
std::vector<std::vector<double>> output_coords;
std::vector<std::shared_ptr<RangeFinderSensor>>* rfsensors = sm.get_cur_rangefinder_sensors();
std::vector<std::shared_ptr<DepthFinderSensor>>* dfsensors = sm.get_cur_depthfinder_sensors();
std::vector<std::shared_ptr<PieSliceSensor>>* pssensors = sm.get_cur_pieslice_sensors();
double inputZ = -1;
double outputZ = 1;
double hiddenZ = 0;
// First, calculate maximum x and y coordinates so we can normalize substrate coordinates to (-1, 1)
int maxX = 0;
int maxY = 0;
if (ExperimentParameters::num_hidden_start_neurons > 0) {
std::vector<double> coords;
if (ExperimentParameters::num_hidden_start_neurons == 1) {
// If there is only one hidden start neuron, place it in the center and be done with it
coords.push_back(0);
coords.push_back(0);
coords.push_back(hiddenZ);
hidden_coords.push_back(coords);
} else {
// If there are more than one, arrange in a circle
coords.push_back(1);
coords.push_back(0);
coords.push_back(hiddenZ);
double cur_angle = 0;
// How many neurons per full rotation?
double angle_step = 2 * M_PI / ExperimentParameters::num_hidden_start_neurons;
for (int i = 0; i < ExperimentParameters::num_hidden_start_neurons - 1; i++) {
// Push back coordinates, rotate by the angle step each iteration
hidden_coords.push_back(coords);
std::vector<double> coords_new;
coords_new.push_back(coords.at(0) * cos(angle_step) + coords.at(1) * sin(angle_step));
coords_new.push_back(coords.at(1) * cos(angle_step) - coords.at(0) * sin(angle_step));
coords_new.push_back(hiddenZ);
coords = coords_new;
}
}
}
for (std::vector<std::shared_ptr<RangeFinderSensor>>::iterator it = rfsensors->begin(); it != rfsensors->end(); ++it)
{
Vector v = (*it)->get_offset();
// Get middle point of the RangeFinderSensor
int x = abs(v.x / 2.0);
int y = abs(v.y);
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
}
for (std::vector<std::shared_ptr<DepthFinderSensor>>::iterator it = dfsensors->begin(); it != dfsensors->end(); ++it)
{
Vector v = (*it)->get_offset();
// Get middle point of the DepthFinderSensor
int x = abs(v.x);
int y = abs(v.y / 2.0);
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
}
for (std::vector<std::shared_ptr<PieSliceSensor>>::iterator it = pssensors->begin(); it != pssensors->end(); ++it)
{
Vector v1 = (*it)->get_offset();
Vector v2 = (*it)->get_offset2();
// Get middle point of the PieSliceSensor
// Divide by three because both vectors form a triangle with (0, 0) as the third point
int x = abs((v1.x + v2.x) / 3.0);
int y = abs((v1.y + v2.y) / 3.0);
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
}
for (std::vector<std::shared_ptr<RangeFinderSensor>>::iterator it = rfsensors->begin(); it != rfsensors->end(); ++it)
{
std::vector<double> coords;
Vector v = (*it)->get_offset();
// Normalize between (0, 1) and then between (-1, 1)
coords.push_back(v.x / (double) maxX);
coords.push_back(v.y / (double) maxY);
coords.push_back(v.x);
coords.push_back(v.y);
if (ExperimentParameters::num_hidden_start_neurons > 0) coords.push_back(inputZ);
input_coords.push_back(coords);
}
for (std::vector<std::shared_ptr<DepthFinderSensor>>::iterator it = dfsensors->begin(); it != dfsensors->end(); ++it)
{
std::vector<double> coords;
Vector v = (*it)->get_offset();
coords.push_back((v.x / (double) maxX));
coords.push_back((v.y / (double) maxY));
coords.push_back(v.x);
coords.push_back(v.y);
if (ExperimentParameters::num_hidden_start_neurons > 0) coords.push_back(inputZ);
input_coords.push_back(coords);
}
for (std::vector<std::shared_ptr<PieSliceSensor>>::iterator it = pssensors->begin(); it != pssensors->end(); ++it)
{
std::vector<double> coords;
Vector v1 = (*it)->get_offset();
Vector v2 = (*it)->get_offset2();
// Same procedure as above, third point is (0, 0)
coords.push_back(((v1.x + v2.x) / 3.0) / (double) maxX);
coords.push_back(((v1.y + v2.y) / 3.0) / (double) maxY);
if (ExperimentParameters::num_hidden_start_neurons > 0) coords.push_back(inputZ);
input_coords.push_back(coords);
}
std::vector<double> bias;
bias.push_back(0);
bias.push_back(0);
if (ExperimentParameters::num_hidden_start_neurons > 0) bias.push_back(inputZ);
input_coords.push_back(bias);
std::vector<double> output;
// Arrange output substrate coordinates around Tux
// UP should be above Tux, DOWN below, etc. with Tux "being" at (0, 0)
// UP
output.push_back(0);
output.push_back(1);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
output.clear();
// DOWN
output.push_back(0);
output.push_back(-1);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
output.clear();
// LEFT
output.push_back(-1);
output.push_back(0);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
output.clear();
// RIGHT
output.push_back(1);
output.push_back(0);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
output.clear();
// JUMP
output.push_back(0);
output.push_back(0.8);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
output.clear();
// ACTION
output.push_back(0);
output.push_back(0.1);
if (ExperimentParameters::num_hidden_start_neurons > 0) output.push_back(outputZ);
output_coords.push_back(output);
// Parameters taken from MultiNEAT's HyperNEAT example
substrate = Substrate(input_coords, hidden_coords, output_coords);
substrate.m_allow_hidden_hidden_links = false;
substrate.m_allow_hidden_output_links = true;
substrate.m_allow_input_hidden_links = true;
substrate.m_allow_input_output_links = true;
substrate.m_allow_looped_hidden_links = false;
substrate.m_allow_looped_output_links = false;
substrate.m_allow_output_hidden_links = false;
substrate.m_allow_output_output_links = false;
substrate.m_query_weights_only = true;
substrate.m_max_weight_and_bias = 8;
substrate.m_hidden_nodes_activation = ActivationFunction::SIGNED_SIGMOID;
substrate.m_output_nodes_activation = ActivationFunction::UNSIGNED_SIGMOID;
start_genome = Genome(0, substrate.GetMinCPPNInputs(), ExperimentParameters::num_hidden_start_neurons_cppn,
substrate.GetMinCPPNOutputs(), false, TANH, TANH, 0, params);
pop = strcmp(ExperimentParameters::pop_filename.c_str(), "") ? Population(ExperimentParameters::pop_filename.c_str()) : Population(start_genome, params, true, 1.0, (ExperimentParameters::using_seed ? ExperimentParameters::seed : (int) time(0)));
}
int Experiment::select_handler(void* data, int argc, char** argv, char** colNames)
{
int id = std::stoi(argv[0]);
double fitness = std::stod(argv[1]);
for (std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it) {
if ((*it)->GetID() == id) {
(*it)->SetFitness((ExperimentParameters::novelty_search) ? sparseness(*it) : fitness);
(*it)->SetEvaluated();
if (fitness > top_fitness) {
new_top = true;
top_fitness = fitness;
top_genome_id = id;
top_genome_gen_id = cur_gen;
}
break;
}
}
fitness_sum += std::stod(argv[1]);
airtime_sum += std::stod(argv[2]);
groundtime_sum += std::stod(argv[3]);
jump_sum += std::stoi(argv[4]);
if (std::stod(argv[11]) > 0) num_winner_genomes++;
return 0;
}
int Experiment::select_handler_ns(void* data, int argc, char** argv, char** colNames)
{
int id = std::stoi(argv[0]);
double fitness = std::stod(argv[1]);
for (std::vector<Genome*>::iterator it = genomes.begin(); it != genomes.end(); ++it) {
if ((*it)->GetID() == id) {
for (int i = 5; i < 11; i++) {
(*it)->m_PhenotypeBehavior->m_Data[0][i - 5] = std::stod(argv[i]);
}
if (fitness > top_fitness) {
new_top = true;
top_fitness = fitness;
top_genome_id = id;
top_genome_gen_id = cur_gen;
}
break;
}
}
fitness_sum += std::stod(argv[1]);
airtime_sum += std::stod(argv[2]);
groundtime_sum += std::stod(argv[3]);
jump_sum += std::stoi(argv[4]);
if (std::stod(argv[11]) > 0) num_winner_genomes++;
return 0;
}
void Experiment::parse_commandline_arguments(int argc, char** argv)
{
for (int i = 0; i < argc; i++) {
string arg = argv[i];
if (arg == "--help")
{
print_usage();
exit(0);
}
else if (arg == "--experimentparamfile")
{
if (i + 1 < argc)
{
ExperimentParameters::experimentparam_filename = argv[++i];
}
else
{
std::cout << "Please specify path to experiment parameter file after using --experimentparamfile" << std::endl;
}
}
else if (arg == "--paramfile")
{
if (i + 1 < argc)
{
ExperimentParameters::param_filename = argv[++i];
}
else
{
std::cout << "Please specify path to MultiNEAT parameter file after using --paramfile" << std::endl;
}
}
else if (arg == "--popfile")
{
if (i + 1 < argc)
{
ExperimentParameters::pop_filename = argv[++i];
}
else
{
std::cout << "Please specify path to population file after using --popfile" << std::endl;
}
}
// We'll take seeds as a console argument for convenience,
// i.e. start multiple experiments via shellscript
else if (arg == "--seed")
{
int seed = 0;
if (i + 1 < argc && sscanf(argv[i + 1], "%d", &seed) == 1) {
ExperimentParameters::using_seed = true;
} else {
std::cout << "Please specify a proper seed after '--seed'" << std::endl;
}
}
else if (arg == "--noveltysearch")
{
ExperimentParameters::novelty_search = true;
}
else if (arg == "--hyperneat")
{
ExperimentParameters::hyperneat = true;
}
else if (i > 0 && arg[0] != '-')
{
ExperimentParameters::path_to_level = arg;
}
}
}
Parameters Experiment::init_params()
{
Parameters res;
if (strcmp(ExperimentParameters::param_filename.c_str(), "") != 0) {
res.Load(ExperimentParameters::param_filename.c_str());
}
return res;
}
void Experiment::parse_experiment_parameters()
{
string line, s;
double d;
std::ifstream stream(ExperimentParameters::experimentparam_filename);
while (std::getline(stream, line)) {
stringstream ss;
ss << line;
if (!(ss >> s >> d)) continue;
if (s == "maxgens") ExperimentParameters::max_gens = (int) d;
else if (s == "numcores") ExperimentParameters::num_cores = (int) d;
else if (s == "randseed") {
ExperimentParameters::using_seed = true;
ExperimentParameters::seed = (int) d;
}
else if (s == "autosaveinterval")
if ((int) d == 0) ExperimentParameters::autosave_best = true;
else ExperimentParameters::autosave_interval = (int) d;
else if (s == "numrangesensors") ExperimentParameters::AMOUNT_RANGE_SENSORS = (int) d;
else if (s == "numdepthsensors") ExperimentParameters::AMOUNT_DEPTH_SENSORS = (int) d;
else if (s == "numpiesensors") ExperimentParameters::AMOUNT_PIESLICE_SENSORS = (int) d;
else if (s == "spacingdepthsensors") ExperimentParameters::SPACING_DEPTH_SENSORS = (int) d;
else if (s == "radiuspiesensors") ExperimentParameters::RADIUS_PIESLICE_SENSORS = (int) d;
else if (s == "numhiddenstartneurons") ExperimentParameters::num_hidden_start_neurons = (int) d;
else if (s == "numhiddenstartneuronscppn") ExperimentParameters::num_hidden_start_neurons_cppn = (int) d;
else if (s == "noveltysearch" && (int) d) ExperimentParameters::novelty_search = true;
else if (s == "hyperneat" && (int) d) ExperimentParameters::hyperneat = true;
}
}
void Experiment::save_pop(string filename)
{
mkdir("popfiles", S_IRWXU);
std::stringstream ss = std::stringstream();
ss << "popfiles/";
ss << filename;
pop.Save(ss.str().c_str());
}
void Experiment::fix_filenames()
{
try {
ExperimentParameters::path_to_level = boost::filesystem::canonical(ExperimentParameters::path_to_level).string();
} catch (const std::exception& e) {
std::cerr << "Bad level file specified" << std::endl;
exit(-1);
}
if (strcmp(ExperimentParameters::pop_filename.c_str(), "")) {
try {
ExperimentParameters::pop_filename = boost::filesystem::canonical(ExperimentParameters::pop_filename).string();
} catch (const std::exception& e) {
std::cerr << "Bad population file specified" << std::endl;
exit(-1);
}
}
if (strcmp(ExperimentParameters::param_filename.c_str(), "")) {
try {
ExperimentParameters::param_filename = boost::filesystem::canonical(ExperimentParameters::param_filename).string();
} catch (const std::exception& e) {
std::cerr << "Bad parameter file specified" << std::endl;
exit(-1);
}
}
if (strcmp(ExperimentParameters::experimentparam_filename.c_str(), "")) {
try {
ExperimentParameters::experimentparam_filename = boost::filesystem::canonical(ExperimentParameters::experimentparam_filename).string();
} catch (const std::exception& e) {
std::cerr << "Bad experiment parameter file specified" << std::endl;
exit(-1);
}
}
}
int Experiment::busy_handler(void *data, int retry)
{
std::cout << "Busy handler";
if (retry < max_db_retry) {
std::cout << ", try #" << retry << std::endl;
sqlite3_sleep(db_sleeptime);
return 1;
} else {
return 0;
}
}
void Experiment::print_usage()
{
stringstream ss;
ss << std::endl;
ss << "====================================================" << std::endl;
ss << "== Help for SuperTux + NEAT experiment executable ==" << std::endl;
ss << "== Available arguments: ==" << std::endl;
ss << "====================================================" << std::endl;
ss << "--paramfile\t\tMultiNEAT parameter file" << std::endl;
ss << "--experimentparamfile\tCustom experiment parameter file. Check README for usage" << std::endl;
ss << std::endl;
ss << "The following arguments can be overriden by the experiment parameter file:" << std::endl;
ss << "--seed\t\t\tSeed for MultiNEAT" << std::endl;
ss << "--noveltysearch\t\tUse Novelty Search instead of objective-based fitness for evolution" << std::endl;
std::cout << ss.str();
} | 30.516129 | 357 | 0.640082 | ChristophKuhfuss |
875281638813f52013ee2ac0ad9bab0cc0c37e9e | 10,910 | cpp | C++ | src/core/Film.cpp | IDragnev/pbrt | 0eef2a23fb840a73d70c888b4eb2ad5caa278d63 | [
"MIT"
] | null | null | null | src/core/Film.cpp | IDragnev/pbrt | 0eef2a23fb840a73d70c888b4eb2ad5caa278d63 | [
"MIT"
] | null | null | null | src/core/Film.cpp | IDragnev/pbrt | 0eef2a23fb840a73d70c888b4eb2ad5caa278d63 | [
"MIT"
] | null | null | null | #include "pbrt/core/Film.hpp"
#include "pbrt/core/geometry/Utility.hpp"
#include "pbrt/memory/Memory.hpp"
namespace idragnev::pbrt {
Film::Film(const Point2i& resolution,
const Bounds2f& cropWindow,
std::unique_ptr<const Filter> filt,
Float diagonal,
const std::string& filename,
Float scale,
Float maxSampleLuminance)
: fullResolution(resolution)
, diagonal(Float(diagonal * 0.001))
, filter(std::move(filt))
, filename(filename)
// clang-format off
, croppedPixelBounds(Bounds2i(
Point2i(static_cast<int>(std::ceil(fullResolution.x * cropWindow.min.x)),
static_cast<int>(std::ceil(fullResolution.y * cropWindow.min.y))),
Point2i(static_cast<int>(std::ceil(fullResolution.x * cropWindow.max.x)),
static_cast<int>(std::ceil(fullResolution.y * cropWindow.max.y)))))
// clang-format on
, pixels(new Pixel[croppedPixelBounds.area()])
, scale(scale)
, maxSampleLuminance(maxSampleLuminance) {
/*TODO: log resolution, crop window and cropped bounds */
const Float invTableExt = 1.f / static_cast<Float>(FILTER_TABLE_EXTENT);
std::size_t offset = 0;
for (int y = 0; y < FILTER_TABLE_EXTENT; ++y) {
for (int x = 0; x < FILTER_TABLE_EXTENT; ++x) {
// clang-format off
Point2f p;
p.x = (static_cast<Float>(x) + 0.5f) * invTableExt * filter->radius.x;
p.y = (static_cast<Float>(y) + 0.5f) * invTableExt * filter->radius.y;
// clang-format on
filterTable[offset++] = filter->eval(p);
}
}
}
Film::Pixel& Film::getPixel(const Point2i& p) {
assert(insideExclusive(p, croppedPixelBounds));
const int width = croppedPixelBounds.max.x - croppedPixelBounds.min.x;
const int offset = (p.x - croppedPixelBounds.min.x) +
(p.y - croppedPixelBounds.min.y) * width;
return pixels[offset];
}
Bounds2i Film::getSampleBounds() const {
Point2i min(math::floor(Point2f(croppedPixelBounds.min) +
Vector2f(0.5f, 0.5f) - filter->radius));
Point2i max(math::ceil(Point2f(croppedPixelBounds.max) -
Vector2f(0.5f, 0.5f) + filter->radius));
Bounds2i bounds;
bounds.min = min;
bounds.max = max;
return bounds;
}
Bounds2f Film::getPhysicalExtent() const {
const Float aspect = static_cast<Float>(fullResolution.y) /
static_cast<Float>(fullResolution.x);
const Float x =
std::sqrt(diagonal * diagonal / (1.f + aspect * aspect));
const Float y = aspect * x;
return Bounds2f{Point2f(-x / 2.f, -y / 2.f), Point2f(x / 2.f, y / 2.f)};
}
std::unique_ptr<FilmTile> Film::getFilmTile(const Bounds2i& sampleBounds) {
const Bounds2f floatBounds{sampleBounds};
const Point2i p0{
math::ceil(toDiscrete(floatBounds.min) - filter->radius)};
const Point2i p1 =
Point2i{math::floor(toDiscrete(floatBounds.max) + filter->radius)} +
Vector2i(1, 1);
Bounds2i tilePixelBounds =
intersectionOf(Bounds2i(p0, p1), croppedPixelBounds);
return std::unique_ptr<FilmTile>(new FilmTile(
tilePixelBounds,
filter->radius,
std::span<const Float>(filterTable,
FILTER_TABLE_EXTENT * FILTER_TABLE_EXTENT),
FILTER_TABLE_EXTENT,
maxSampleLuminance));
}
void Film::mergeFilmTile(std::unique_ptr<FilmTile> tile) {
// TODO: Log tile->pixelBounds ...
std::lock_guard<std::mutex> lock(mutex);
for (const Point2i pixel : tile->getPixelBounds()) {
const FilmTilePixel& tilePixel = tile->getPixel(pixel);
const std::array<Float, 3> xyz = tilePixel.contribSum.toXYZ();
Pixel& filmPixel = this->getPixel(pixel);
for (std::size_t i = 0; i < 3; ++i) {
filmPixel.xyz[i] += xyz[i];
}
filmPixel.filterWeightSum += tilePixel.filterWeightSum;
}
}
void Film::setImage(const std::span<Spectrum> imagePixels) const {
if (const int filmPixels = croppedPixelBounds.area();
filmPixels == static_cast<int>(imagePixels.size()))
{
const std::size_t nPixels = imagePixels.size();
for (std::size_t i = 0; i < nPixels; ++i) {
const std::array xyz = imagePixels[i].toXYZ();
Pixel& filmPixel = this->pixels[i];
filmPixel.xyz[0] = xyz[0];
filmPixel.xyz[1] = xyz[1];
filmPixel.xyz[2] = xyz[2];
filmPixel.filterWeightSum = 1.f;
filmPixel.splatXYZ[0] = 0.f;
filmPixel.splatXYZ[1] = 0.f;
filmPixel.splatXYZ[2] = 0.f;
}
}
else {
// TODO : Log ...
assert(false);
}
}
void Film::clear() {
for (const Point2i p : croppedPixelBounds) {
Pixel& filmPixel = getPixel(p);
filmPixel.xyz[0] = 0.f;
filmPixel.xyz[1] = 0.f;
filmPixel.xyz[2] = 0.f;
filmPixel.filterWeightSum = 0.f;
filmPixel.splatXYZ[0] = 0.f;
filmPixel.splatXYZ[1] = 0.f;
filmPixel.splatXYZ[2] = 0.f;
}
}
void
FilmTile::addSample(Point2f pFilm, Spectrum L, const Float sampleWeight) {
if (L.y() > maxSampleLuminance) {
L *= maxSampleLuminance / L.y();
}
pFilm = toDiscrete(pFilm);
auto p0 = Point2i{math::ceil(pFilm - filterRadius)};
auto p1 = Point2i{math::floor(pFilm + filterRadius)} + Vector2i(1, 1);
p0 = math::max(p0, pixelBounds.min);
p1 = math::min(p1, pixelBounds.max);
std::size_t* const filterXOffsets =
PBRT_ALLOCA(std::size_t, std::max(p1.x - p0.x, 1));
for (int x = p0.x; x < p1.x; ++x) {
const Float fx = std::abs((x - pFilm.x) * invFilterRadius.x *
static_cast<Float>(filterTableExtent));
filterXOffsets[x - p0.x] =
std::min(static_cast<std::size_t>(std::floor(fx)),
filterTableExtent - 1);
}
std::size_t* const filterYOffsets =
PBRT_ALLOCA(std::size_t, std::max(p1.y - p0.y, 1));
for (int y = p0.y; y < p1.y; ++y) {
const Float fy = std::abs((y - pFilm.y) * invFilterRadius.y *
static_cast<Float>(filterTableExtent));
filterYOffsets[y - p0.y] =
std::min(static_cast<std::size_t>(std::floor(fy)),
filterTableExtent - 1);
}
for (int y = p0.y; y < p1.y; ++y) {
for (int x = p0.x; x < p1.x; ++x) {
std::size_t offset =
filterYOffsets[y - p0.y] * filterTableExtent +
filterXOffsets[x - p0.x];
const Float filterWeight = filterTable[offset];
FilmTilePixel& pixel = getPixel(Point2i(x, y));
pixel.contribSum += L * sampleWeight * filterWeight;
pixel.filterWeightSum += filterWeight;
}
}
}
void Film::addSplat(const Point2f& p, Spectrum v) {
if (v.hasNaNs()) {
// TODO: log nans
return;
}
else if (v.y() < Float(0)) {
// log negative luminace
return;
}
else if (std::isinf(v.y())) {
// log inf luminace
return;
}
const Point2i pi(math::floor(p));
if (insideExclusive(pi, croppedPixelBounds)) {
if (v.y() > maxSampleLuminance) {
v *= maxSampleLuminance / v.y();
}
const std::array xyz = v.toXYZ();
Pixel& pixel = getPixel(pi);
pixel.splatXYZ[0].add(xyz[0]);
pixel.splatXYZ[1].add(xyz[1]);
pixel.splatXYZ[2].add(xyz[2]);
}
}
void Film::writeImage(const Float splatScale) {
// TODO: Log info: "Converting image to RGB and computing final weighted pixel values..."
const int nPixels = croppedPixelBounds.area();
std::unique_ptr<Float[]> imageRGB(new Float[3 * nPixels]);
for (std::size_t pixelIndex = 0; const Point2i p : croppedPixelBounds) {
const std::span<Float, 3> pixelRGB{&(imageRGB[3 * pixelIndex]), 3};
Pixel& pixel = getPixel(p);
const std::array arrRGB =
XYZToRGB(std::span<const Float, 3>{pixel.xyz});
pixelRGB[0] = arrRGB[0];
pixelRGB[1] = arrRGB[1];
pixelRGB[2] = arrRGB[2];
// normalize pixel with weight sum
if (pixel.filterWeightSum != 0.f) {
const Float invWt = Float(1) / pixel.filterWeightSum;
pixelRGB[0] = std::max(Float(0), pixelRGB[0] * invWt);
pixelRGB[1] = std::max(Float(0), pixelRGB[1] * invWt);
pixelRGB[2] = std::max(Float(0), pixelRGB[2] * invWt);
}
const Float splatXYZ[3] = {pixel.splatXYZ[0],
pixel.splatXYZ[1],
pixel.splatXYZ[2]};
const std::array splatRGB = XYZToRGB(splatXYZ);
pixelRGB[0] += splatScale * splatRGB[0];
pixelRGB[1] += splatScale * splatRGB[1];
pixelRGB[2] += splatScale * splatRGB[2];
pixelRGB[0] *= scale;
pixelRGB[1] *= scale;
pixelRGB[2] *= scale;
++pixelIndex;
}
// TODO: log_info("Writing image to {}. bounds = {}, scale = {}, splatScale = {}",
// filename, croppedPixelBounds, scale, splatScale)
// pbrt::writeImage(filename, &imageRGB[0], croppedPixelBounds, fullResolution);
}
FilmTilePixel& FilmTile::getPixel(const Point2i& p) {
assert(insideExclusive(p, pixelBounds));
int width = pixelBounds.max.x - pixelBounds.min.x;
int offset = (p.y - pixelBounds.min.y) * width +
(p.x - pixelBounds.min.x);
return pixels[offset];
}
const FilmTilePixel& FilmTile::getPixel(const Point2i& p) const {
assert(insideExclusive(p, pixelBounds));
int width = pixelBounds.max.x - pixelBounds.min.x;
int offset = (p.y - pixelBounds.min.y) * width +
(p.x - pixelBounds.min.x);
return pixels[offset];
}
} // namespace idragnev::pbrt | 36.366667 | 97 | 0.528323 | IDragnev |
875325064a37bb256fef9507b5a7598a2bfe6fe6 | 2,824 | cc | C++ | UX/src/LogView.cc | frankencode/CoreComponents | 4c66d7ff9fc5be19222906ba89ba0e98951179de | [
"Zlib"
] | null | null | null | UX/src/LogView.cc | frankencode/CoreComponents | 4c66d7ff9fc5be19222906ba89ba0e98951179de | [
"Zlib"
] | null | null | null | UX/src/LogView.cc | frankencode/CoreComponents | 4c66d7ff9fc5be19222906ba89ba0e98951179de | [
"Zlib"
] | null | null | null | /*
* Copyright (C) 2022 Frank Mertens.
*
* Distribution and use is allowed under the terms of the zlib license
* (see cc/LICENSE-zlib).
*
*/
#include <cc/LogView>
#include <cc/Text>
#include <cc/LineSource>
#include <cc/Format>
namespace cc {
struct LogView::State final: public ListView::State
{
State()
{
font([this]{ return style().defaultFont(); });
margin([this]{
double m = style().flickableIndicatorThickness();
return Size{m, m};
});
leadSpace([this]{ return margin()[1]; });
tailSpace([this]{ return margin()[1]; });
font.onChanged([this]{ reload(); });
}
void reload()
{
ListView::State::deplete();
for (const String &line: lines_) {
appendLine(line);
}
}
void appendText(const String &text)
{
bool carrierAtEnd =
carrier().height() <= height() ||
carrier().pos()[1] <= height() - carrier().height() + sp(42);
for (const String &line: LineSource{text}) {
appendLine(line);
}
if (carrierAtEnd && height() < carrier().height()) {
if (carrier().moving()) carrierStop();
carrier().pos(Point{0, height() - carrier().height()});
}
}
void appendLine(const String &line)
{
carrier().add(
Text{line, font()}
.margin([this]{ return Size{margin()[0], 0}; })
.maxWidth([this]{ return width(); })
);
}
void clearText()
{
ListView::State::deplete();
lines_.deplete();
}
Property<Font> font;
Property<Size> margin;
List<String> lines_;
};
LogView::LogView():
ListView{onDemand<State>}
{}
LogView::LogView(double width, double height):
ListView{new State}
{
size(width, height);
}
LogView &LogView::associate(Out<LogView> self)
{
return View::associate<LogView>(self);
}
Font LogView::font() const
{
return me().font();
}
LogView &LogView::font(Font newValue)
{
me().font(newValue);
return *this;
}
LogView &LogView::font(Definition<Font> &&f)
{
me().font(move(f));
return *this;
}
Size LogView::margin() const
{
return me().margin();
}
LogView &LogView::margin(Size newValue)
{
me().margin(newValue);
return *this;
}
LogView &LogView::margin(Definition<Size> &&f)
{
me().margin(move(f));
return *this;
}
LogView &LogView::appendText(const String &text)
{
me().appendText(text);
return *this;
}
void LogView::clearText()
{
me().clearText();
}
List<String> LogView::textLines() const
{
return me().lines_;
}
LogView::State &LogView::me()
{
return Object::me.as<State>();
}
const LogView::State &LogView::me() const
{
return Object::me.as<State>();
}
} // namespace cc
| 18.337662 | 73 | 0.56551 | frankencode |
875bdcc9c2e25b38fd819a6bff10e7a0970c52a1 | 10,674 | cpp | C++ | src/libc9/loader.cpp | stormbrew/channel9 | 626b42c208ce1eb54fff09ebd9f9e9fd0311935d | [
"MIT"
] | 1 | 2015-02-13T02:03:29.000Z | 2015-02-13T02:03:29.000Z | src/libc9/loader.cpp | stormbrew/channel9 | 626b42c208ce1eb54fff09ebd9f9e9fd0311935d | [
"MIT"
] | null | null | null | src/libc9/loader.cpp | stormbrew/channel9 | 626b42c208ce1eb54fff09ebd9f9e9fd0311935d | [
"MIT"
] | null | null | null | #include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "json/json.h"
#include "json/reader.h"
#include "c9/loader.hpp"
#include "c9/script.hpp"
#include "c9/istream.hpp"
#include "c9/variable_frame.hpp"
#include "c9/context.hpp"
namespace Channel9
{
class NothingChannel : public CallableContext
{
public:
NothingChannel(){}
~NothingChannel(){}
void send(Environment *env, const Value &val, const Value &ret)
{
}
std::string inspect() const
{
return "Nothing Channel";
}
};
NothingChannel *nothing_channel = new NothingChannel;
template <typename tRight>
loader_error operator<<(const loader_error &left, const tRight &right)
{
std::stringstream stream;
stream << left.reason;
stream << right;
return loader_error(stream.str());
}
Value convert_json(const Json::Value &val);
Value convert_json_array(const Json::Value &arr)
{
std::vector<Value> vals(arr.size());
std::vector<Value>::iterator oiter = vals.begin();
Json::Value::const_iterator iiter = arr.begin();
while (iiter != arr.end())
*oiter++ = convert_json(*iiter++);
return value(new_tuple(vals.begin(), vals.end()));
}
Value convert_json_complex(const Json::Value &obj)
{
if (!obj["undef"].isNull())
{
return Undef;
} else if (obj["message_id"].isString()) {
return value((int64_t)make_message_id(obj["message_id"].asString()));
} else if (obj["protocol_id"].isString()) {
return value((int64_t)make_protocol_id(obj["protocol_id"].asString()));
}
throw loader_error("Unknown complex object ") << obj.toStyledString();
}
Value convert_json(const Json::Value &val)
{
using namespace Json;
switch (val.type())
{
case nullValue:
return Nil;
case intValue:
return value(val.asInt64());
case uintValue:
return value((int64_t)val.asUInt64());
case realValue:
return value(val.asDouble());
case stringValue:
return value(val.asString());
case booleanValue:
return bvalue(val.asBool());
case arrayValue:
return convert_json_array(val);
case objectValue:
return convert_json_complex(val);
default:
throw loader_error("Invalid value encountered while parsing json");
}
}
GCRef<RunnableContext*> load_program(Environment *env, const Json::Value &code)
{
using namespace Channel9;
GCRef<IStream*> istream = new IStream;
int num = 0;
for (Json::Value::const_iterator it = code.begin(); it != code.end(); it++, num++)
{
const Json::Value &line = *it;
if (!line.isArray() || line.size() < 1)
{
throw loader_error("Malformed line ") << num << ": not an array or not enough elements";
}
const Json::Value &ival = line[0];
if (!ival.isString())
{
throw loader_error("Instruction on line ") << num << " was not a string (" << ival.toStyledString() << ")";
}
const std::string &instruction = ival.asString();
if (instruction == "line")
{
if (line.size() > 1)
{
std::string file = "(unknown)", extra;
uint64_t lineno = 0, linepos = 0;
file = line[1].asString();
if (line.size() > 2)
lineno = line[2].asUInt64();
if (line.size() > 3)
linepos = line[3].asUInt64();
if (line.size() > 4)
extra = line[4].asString();
(*istream)->set_source_pos(SourcePos(file, lineno, linepos, extra));
}
} else if (instruction == "set_label") {
if (line.size() != 2 || !line[1].isString())
{
throw loader_error("Invalid set_label line at ") << num;
}
(*istream)->set_label(line[1].asString());
} else {
INUM insnum = inum(instruction);
if (insnum == INUM_INVALID)
{
throw loader_error("Invalid instruction ") << instruction << " at " << num;
}
Instruction ins = {insnum};
InstructionInfo info = iinfo(ins);
if (line.size() - 1 < info.argc)
{
throw loader_error("Instruction ") << instruction << " takes "
<< info.argc << "arguments, but was given " << line.size() - 1
<< " at line " << num;
}
if (info.argc > 0)
ins.arg1 = convert_json(line[1]);
if (info.argc > 1)
ins.arg2 = convert_json(line[2]);
if (info.argc > 2)
ins.arg3 = convert_json(line[3]);
(*istream)->add(ins);
}
}
(*istream)->normalize();
GCRef<VariableFrame*> frame = new_variable_frame(*istream);
GCRef<RunnableContext*> ctx = new_context(*istream, *frame);
return ctx;
}
GCRef<RunnableContext*> load_bytecode(Environment *env, const std::string &filename)
{
std::ifstream file(filename.c_str());
if (file.is_open())
{
Json::Reader reader;
Json::Value body;
if (reader.parse(file, body, false))
{
Json::Value code = body["code"];
if (!code.isArray())
{
throw loader_error("No code block in ") << filename;
}
return load_program(env, code);
} else {
throw loader_error("Failed to parse json in ") << filename << ":\n"
<< reader.getFormattedErrorMessages();
}
} else {
throw loader_error("Could not open file ") << filename;
}
}
GCRef<RunnableContext*> load_bytecode(Environment *env, const std::string &filename, const std::string &str)
{
Json::Reader reader;
Json::Value body;
if (reader.parse(str, body, false))
{
Json::Value code = body["code"];
if (!code.isArray())
{
throw loader_error("No code block in ") << filename;
}
return load_program(env, code);
} else {
throw loader_error("Failed to parse json in ") << filename << ":\n"
<< reader.getFormattedErrorMessages();
}
}
int run_bytecode(Environment *env, const std::string &filename)
{
GCRef<RunnableContext*> ctx = load_bytecode(env, filename);
channel_send(env, value(*ctx), Nil, value(nothing_channel));
return 0;
}
GCRef<RunnableContext*> load_c9script(Environment *env, const std::string &filename)
{
GCRef<IStream*> istream = new IStream;
script::compile_file(filename, **istream);
(*istream)->normalize();
GCRef<VariableFrame*> frame = new_variable_frame(*istream);
GCRef<RunnableContext*> ctx = new_context(*istream, *frame);
return ctx;
}
int run_c9script(Environment *env, const std::string &filename)
{
GCRef<RunnableContext*> ctx = load_c9script(env, filename);
channel_send(env, value(*ctx), Nil, value(nothing_channel));
return 0;
}
int run_list(Environment *env, const std::string &filename)
{
std::ifstream file(filename.c_str());
if (file.is_open())
{
while (!file.eof())
{
std::string line;
std::getline(file, line);
if (line.size() > 0)
{
if (line[0] != '/')
{
// if the path is not absolute it's relative
// to the c9l file.
size_t last_slash_pos = filename.rfind('/');
if (last_slash_pos == std::string::npos)
run_file(env, line);
else
run_file(env, filename.substr(0, last_slash_pos+1) + line);
}
} else {
break;
}
}
return 0;
} else {
throw loader_error("Could not open file ") << filename << ".";
}
}
typedef int (*entry_point)(Environment*, const std::string&);
int run_shared_object(Environment *env, std::string filename)
{
#ifdef __APPLE__
// on macs change the .so to .dylib
filename.replace(filename.length()-3, std::string::npos, ".dylib");
#endif
void *shobj = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL);
if (!shobj)
{
throw loader_error("Could not load shared object ") << filename;
}
entry_point shobj_entry = (entry_point)dlsym(shobj, "Channel9_environment_initialize");
if (!shobj_entry)
{
throw loader_error("Could not load entry point to shared object ") << filename;
}
return shobj_entry(env, filename);
}
void set_argv(Environment *env, int argc, const char **argv)
{
std::vector<Channel9::Value> args;
for (int i = 0; i < argc; i++)
{
args.push_back(Channel9::value(Channel9::new_string(argv[i])));
}
env->set_special_channel("argv", Channel9::value(Channel9::new_tuple(args.begin(), args.end())));
}
int load_environment_and_run(Environment *env, std::string program, int argc, const char **argv, bool trace_loaded)
{
// let the program invocation override the filename (ie. c9.rb always runs ruby)
// but if the exe doesn't match the exact expectation, use the first argument's
// extension to decide what to do.
size_t slash_pos = program.rfind('/');
if (slash_pos != std::string::npos)
program = program.substr(slash_pos + 1, std::string::npos);
if (program.length() < 3 || !std::equal(program.begin(), program.begin()+3, "c9."))
{
if (argc < 1)
throw loader_error("No program file specified.");
program = argv[0];
}
std::string ext = "";
size_t ext_pos = program.rfind('.');
if (ext_pos != std::string::npos)
ext = program.substr(ext_pos);
if (ext == "")
throw loader_error("Can't discover environment for file with no extension.");
if (ext == ".c9s" || ext == ".c9b" || ext == ".c9l" || ext == ".so")
{
// chop off the c9x file so it doesn't try to load itself.
set_argv(env, argc-1, argv+1);
return run_file(env, program);
} else {
// get the path of libc9.so. We expect c9 environments to be near it.
// They'll be at dirname(libc9.so)/c9-env/ext/ext.c9l.
Dl_info fninfo;
dladdr((void*)load_environment_and_run, &fninfo);
std::string search_path = std::string(fninfo.dli_fname);
search_path = search_path.substr(0, search_path.find_last_of('/') + 1);
search_path += "c9-env/";
std::string extname = ext.substr(1, std::string::npos);
search_path += extname + "/" + extname + ".c9l";
// find a matching module
struct stat match = {0};
if (stat(search_path.c_str(), &match) != 0)
throw loader_error("Could not find c9-env loader at ") << search_path;
// include the program name argument so it knows what to load.
set_argv(env, argc, argv);
env->set_special_channel("trace_loaded", bvalue(trace_loaded));
return run_file(env, search_path);
}
return 1;
}
int run_file(Environment *env, const std::string &filename)
{
// find the extension
std::string ext = "";
size_t ext_pos = filename.rfind('.');
if (ext_pos != std::string::npos)
ext = filename.substr(ext_pos);
if (ext == ".c9s")
{
return run_c9script(env, filename);
} else if (ext == ".c9b")
{
return run_bytecode(env, filename);
} else if (ext == ".c9l") {
return run_list(env, filename);
} else if (ext == ".so") {
return run_shared_object(env, filename);
} else if (ext == "") {
throw loader_error("Don't know what to do with no extension.");
} else {
throw loader_error("Don't know what to do with extension `") << ext << "`";
}
}
}
| 28.089474 | 116 | 0.643152 | stormbrew |
875d513837ce2208a4dbad201f5696b50d67f6b7 | 2,279 | hpp | C++ | library/L1_Peripheral/lpc17xx/i2c.hpp | SJSURoboticsTeam/urc-control_systems-2020 | 35dff34c1bc0beecc94ad6b8f2d4b551969c6854 | [
"Apache-2.0"
] | 1 | 2020-02-22T20:26:41.000Z | 2020-02-22T20:26:41.000Z | library/L1_Peripheral/lpc17xx/i2c.hpp | SJSURoboticsTeam/urc-control_systems-2020 | 35dff34c1bc0beecc94ad6b8f2d4b551969c6854 | [
"Apache-2.0"
] | null | null | null | library/L1_Peripheral/lpc17xx/i2c.hpp | SJSURoboticsTeam/urc-control_systems-2020 | 35dff34c1bc0beecc94ad6b8f2d4b551969c6854 | [
"Apache-2.0"
] | 4 | 2019-10-17T03:42:03.000Z | 2020-05-23T20:32:03.000Z | #pragma once
#include "L1_Peripheral/lpc17xx/pin.hpp"
#include "L1_Peripheral/lpc17xx/system_controller.hpp"
#include "L1_Peripheral/lpc40xx/i2c.hpp"
namespace sjsu
{
namespace lpc17xx
{
// Bring in and using the LPC40xx driver as it is compatible with the lpc17xx
// peripheral.
using ::sjsu::lpc40xx::I2c;
/// Structure used as a namespace for predefined I2C Bus definitions.
struct I2cBus // NOLINT
{
private:
inline static lpc17xx::Pin i2c0_sda_pin = lpc17xx::Pin(0, 27);
inline static lpc17xx::Pin i2c0_scl_pin = lpc17xx::Pin(0, 28);
inline static lpc17xx::Pin i2c1_sda_pin = lpc17xx::Pin(0, 0);
inline static lpc17xx::Pin i2c1_scl_pin = lpc17xx::Pin(0, 1);
inline static lpc17xx::Pin i2c2_sda_pin = lpc17xx::Pin(0, 10);
inline static lpc17xx::Pin i2c2_scl_pin = lpc17xx::Pin(0, 11);
inline static I2c::Transaction_t transaction_i2c0;
inline static I2c::Transaction_t transaction_i2c1;
inline static I2c::Transaction_t transaction_i2c2;
public:
// Definition for I2C bus 0 for LPC17xx.
/// NOTE: I2C0 is not available for the 80-pin package.
inline static const lpc40xx::I2c::Bus_t kI2c0 = {
.registers = reinterpret_cast<lpc40xx::LPC_I2C_TypeDef *>(LPC_I2C0),
.id = SystemController::Peripherals::kI2c0,
.irq_number = I2C0_IRQn,
.transaction = transaction_i2c0,
.sda_pin = i2c0_sda_pin,
.scl_pin = i2c0_scl_pin,
.pin_function = 0b01,
};
/// Definition for I2C bus 1 for LPC17xx.
inline static const lpc40xx::I2c::Bus_t kI2c1 = {
.registers = reinterpret_cast<lpc40xx::LPC_I2C_TypeDef *>(LPC_I2C1),
.id = SystemController::Peripherals::kI2c1,
.irq_number = I2C1_IRQn,
.transaction = transaction_i2c1,
.sda_pin = i2c1_sda_pin,
.scl_pin = i2c1_scl_pin,
.pin_function = 0b11,
};
/// Definition for I2C bus 2 for LPC17xx.
inline static const lpc40xx::I2c::Bus_t kI2c2 = {
.registers = reinterpret_cast<lpc40xx::LPC_I2C_TypeDef *>(LPC_I2C2),
.id = SystemController::Peripherals::kI2c2,
.irq_number = I2C2_IRQn,
.transaction = transaction_i2c2,
.sda_pin = i2c2_sda_pin,
.scl_pin = i2c2_scl_pin,
.pin_function = 0b10,
};
};
} // namespace lpc17xx
} // namespace sjsu
| 33.028986 | 77 | 0.69197 | SJSURoboticsTeam |
876034cd377244f6c74963ed63ac430e03463d8b | 477 | cpp | C++ | src/exchange/offer.cpp | cvauclair/marketsim | 3ce669716a7c061fe05a6e4765c07808f4a89138 | [
"MIT"
] | null | null | null | src/exchange/offer.cpp | cvauclair/marketsim | 3ce669716a7c061fe05a6e4765c07808f4a89138 | [
"MIT"
] | 1 | 2021-02-10T14:12:34.000Z | 2021-02-10T22:42:57.000Z | src/exchange/offer.cpp | cvauclair/marketsim | 3ce669716a7c061fe05a6e4765c07808f4a89138 | [
"MIT"
] | null | null | null | #include "offer.h"
unsigned int Offer::offerCounter = 0;
Offer::Offer(OfferType type, const std::string &symbol, unsigned int quantity, float price, unsigned int accountId)
{
this->offerId = ++offerCounter;
this->symbol_ = symbol;
this->quantity = quantity;
this->price = Offer::round(price);
this->accountId_ = accountId;
this->status_ = Offer::PENDING;
this->type_ = type;
}
float Offer::round(float price)
{
return std::floor(1000.0f * price + 0.5f)/1000.0f;
}
| 21.681818 | 115 | 0.704403 | cvauclair |
87722eeb4905a7d547f6a2faaecd8eb968ada488 | 1,281 | cc | C++ | leetcode/1300-critical-connections-in-a-network.cc | Magic07/online-judge-solutions | 02a289dd7eb52d7eafabc97bd1a043213b65f70a | [
"MIT"
] | null | null | null | leetcode/1300-critical-connections-in-a-network.cc | Magic07/online-judge-solutions | 02a289dd7eb52d7eafabc97bd1a043213b65f70a | [
"MIT"
] | null | null | null | leetcode/1300-critical-connections-in-a-network.cc | Magic07/online-judge-solutions | 02a289dd7eb52d7eafabc97bd1a043213b65f70a | [
"MIT"
] | null | null | null | #include <vector>
class Solution {
public:
int currentDfn;
vector<vector<int>> answer;
void dfs(int start,
const vector<vector<int>>& graph,
vector<int>& dfn,
vector<int>& low,
int parent) {
for (const auto& v : graph[start]) {
if (v == parent) {
continue;
}
if (dfn[v] == -1) {
low[v] = currentDfn;
dfn[v] = currentDfn++;
dfs(v, graph, dfn, low, start);
low[start] = min(low[start], low[v]);
if (low[v] > dfn[start]) {
answer.push_back({start, v});
}
} else {
low[start] = min(low[start], dfn[v]);
}
}
}
void resizeAndFill(vector<int>& v, int n) {
v.resize(n);
fill(v.begin(), v.end(), -1);
}
vector<vector<int>> criticalConnections(int n,
vector<vector<int>>& connections) {
vector<vector<int>> graph;
vector<int> dfn, low;
graph.resize(n);
resizeAndFill(dfn, n);
resizeAndFill(low, n);
currentDfn = 0;
for (const auto& con : connections) {
graph[con[0]].push_back(con[1]);
graph[con[1]].push_back(con[0]);
}
dfs(0, graph, dfn, low, 0);
return answer;
}
}; | 26.6875 | 78 | 0.489461 | Magic07 |
8776383a5697804b88328a7a61733778662837a1 | 1,400 | hpp | C++ | src/cf_libs/dskcf/ScaleChangeObserver.hpp | liguanqun/Test_code | 523f4ed4c29b2b2092b40a8c9c3ce1ddbcf0737b | [
"Apache-2.0"
] | null | null | null | src/cf_libs/dskcf/ScaleChangeObserver.hpp | liguanqun/Test_code | 523f4ed4c29b2b2092b40a8c9c3ce1ddbcf0737b | [
"Apache-2.0"
] | null | null | null | src/cf_libs/dskcf/ScaleChangeObserver.hpp | liguanqun/Test_code | 523f4ed4c29b2b2092b40a8c9c3ce1ddbcf0737b | [
"Apache-2.0"
] | null | null | null | #ifndef _SCALECHANGEOBSERVER_HPP_
#define _SCALECHANGEOBSERVER_HPP_
/*
This class represents a C++ implementation of the DS-KCF Tracker [1]. In particular
the scaling system presented in [1] is implemented within this class
References:
[1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. Burghardt, A. Paiement, L. Tao,
DS-KCF: A ~real-time tracker for RGB-D data, Journal of Real-Time Image Processing
*/
#include "Typedefs.hpp"
/**
* ScaleChangeObserver is an abstract class.
* This class is designed to be derived by any class which needs to observe
* a ScaleAnalyser. An instance of ScaleChangeObserver should only be
* registered to observe a single ScaleAnalyser.
*/
class ScaleChangeObserver
{
public:
/**
* onScaleChange is called whenever a scale change has been detected.
* @param targetSize The new size of the target object's bounding box.
* @param windowSize The new padded size of the bounding box around the target.
* @param yf The new gaussian shaped labels for this scale.
* @param cosineWindow The new cosine window for this scale.
*
* @warning If an instance of this class is registered to observe multiple
* ScaleAnalyser, then this method will likely cause a crash.
*/
virtual void onScaleChange(const Size & targetSize, const Size & windowSize, const cv::Mat2d & yf, const cv::Mat1d & cosineWindow) = 0;
};
#endif
| 36.842105 | 137 | 0.738571 | liguanqun |
8778b21cc3238d4b53bd280e8c3e1765e1cd28c2 | 1,879 | cpp | C++ | src/tools/dnd/targets/ContainerFileTransitiveDataTarget.cpp | etrange02/Fux | 2f49bcd8ec82eb521092c9162e01c8b0d00222ab | [
"CECILL-B"
] | 2 | 2016-03-21T10:48:34.000Z | 2017-03-17T19:50:34.000Z | src/tools/dnd/targets/ContainerFileTransitiveDataTarget.cpp | etrange02/Fux | 2f49bcd8ec82eb521092c9162e01c8b0d00222ab | [
"CECILL-B"
] | null | null | null | src/tools/dnd/targets/ContainerFileTransitiveDataTarget.cpp | etrange02/Fux | 2f49bcd8ec82eb521092c9162e01c8b0d00222ab | [
"CECILL-B"
] | null | null | null | /***************************************************************
* Name: ContainerFileTransitiveDataTarget.cpp
* Purpose: Code for Fu(X) 2.0
* Author: David Lecoconnier ([email protected])
* Created: 2015-06-26
* Copyright: David Lecoconnier (http://www.getfux.fr)
* License:
**************************************************************/
#include "tools/dnd/targets/ContainerFileTransitiveDataTarget.h"
#include "explorer/state/FileDriveManagerState.h"
#include "tools/dnd/dataObjects/ContainerFileTransitiveData.h"
#include <algorithm>
using namespace dragAndDrop;
/** @brief Constructor.
*/
ContainerFileTransitiveDataTarget::ContainerFileTransitiveDataTarget(DroppedMarkedLineListCtrl& source, explorer::FileDriveManagerState& managerState) :
TransitiveDataTarget(source),
m_managerState(managerState)
{
}
/** @brief Destructor.
*/
ContainerFileTransitiveDataTarget::~ContainerFileTransitiveDataTarget()
{
}
bool ContainerFileTransitiveDataTarget::isSameKind() const
{
if (m_data == NULL)
return false;
return m_data->isContainerFileKind();
}
void ContainerFileTransitiveDataTarget::doCopyProcessing(const wxArrayString& data, const long position)
{
m_managerState.insertElements(data, position);
}
void ContainerFileTransitiveDataTarget::doCutProcessing(TransitiveData& transitiveData, const long position)
{
ContainerFileTransitiveData& fileTransitiveData = static_cast<ContainerFileTransitiveData&>(transitiveData);
const unsigned long pos = position;
const std::vector<unsigned long>& items = fileTransitiveData.getItems();
std::vector<unsigned long>::const_iterator iter = std::find(items.begin(), items.end(), pos);
if (iter == items.end())
return;
m_managerState.insertElements(fileTransitiveData.getFilenames(), position);
fileTransitiveData.deleteFromSource();
}
| 33.553571 | 152 | 0.717935 | etrange02 |
877e5cb185a7fc44f80c03ed816965492643bb6a | 3,555 | hpp | C++ | frame/object.hpp | joydit/solidframe | 0539b0a1e77663ac4c701a88f56723d3e3688e8c | [
"BSL-1.0"
] | null | null | null | frame/object.hpp | joydit/solidframe | 0539b0a1e77663ac4c701a88f56723d3e3688e8c | [
"BSL-1.0"
] | null | null | null | frame/object.hpp | joydit/solidframe | 0539b0a1e77663ac4c701a88f56723d3e3688e8c | [
"BSL-1.0"
] | null | null | null | // frame/object.hpp
//
// Copyright (c) 2007, 2008 Valentin Palade (vipalade @ gmail . com)
//
// This file is part of SolidFrame framework.
//
// 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 SOLID_FRAME_OBJECT_HPP
#define SOLID_FRAME_OBJECT_HPP
#include "system/timespec.hpp"
#include "frame/common.hpp"
#include "utility/dynamictype.hpp"
#include "utility/dynamicpointer.hpp"
#include <boost/concept_check.hpp>
#ifdef HAS_STDATOMIC
#include <atomic>
#else
#include "boost/atomic.hpp"
#endif
namespace solid{
class Mutex;
namespace frame{
class Manager;
class Service;
class ObjectPointerBase;
class Message;
class SelectorBase;
class Object;
class Object: public Dynamic<Object, DynamicShared<> >{
public:
struct ExecuteContext{
enum RetValE{
WaitRequest,
WaitUntilRequest,
RescheduleRequest,
CloseRequest,
LeaveRequest,
};
size_t eventMask()const{
return evsmsk;
}
const TimeSpec& currentTime()const{
return rcrttm;
}
void reschedule();
void close();
void leave();
void wait();
void waitUntil(const TimeSpec &_rtm);
void waitFor(const TimeSpec &_rtm);
protected:
ExecuteContext(
const size_t _evsmsk,
const TimeSpec &_rcrttm
): evsmsk(_evsmsk), rcrttm(_rcrttm), retval(WaitRequest){}
size_t evsmsk;
const TimeSpec &rcrttm;
RetValE retval;
TimeSpec waittm;
};
struct ExecuteController: ExecuteContext{
ExecuteController(
const size_t _evsmsk,
const TimeSpec &_rcrttm
): ExecuteContext(_evsmsk, _rcrttm){}
const RetValE returnValue()const{
return this->retval;
}
const TimeSpec& waitTime()const{
return this->waittm;
}
};
static const TimeSpec& currentTime();
//!Get the object associated to the current thread
/*!
\see Object::associateToCurrentThread
*/
static Object& specific();
//! Returns true if the object is signaled
bool notified() const;
bool notified(size_t _s) const;
//! Get the id of the object
IndexT id() const;
/**
* Returns true if the signal should raise the object ASAP
* \param _smask The signal bitmask
*/
bool notify(size_t _smask);
//! Signal the object with a signal
virtual bool notify(DynamicPointer<Message> &_rmsgptr);
protected:
friend class Service;
friend class Manager;
friend class SelectorBase;
//! Constructor
Object();
//! Grab the signal mask eventually leaving some bits set- CALL this inside lock!!
size_t grabSignalMask(size_t _leave = 0);
//! Virtual destructor
virtual ~Object();//only objptr base can destroy an object
void unregister();
bool isRegistered()const;
virtual void doStop();
private:
static void doSetCurrentTime(const TimeSpec *_pcrtts);
//! Set the id
void id(const IndexT &_fullid);
//! Gets the id of the thread the object resides in
IndexT threadId()const;
//! Assigns the object to the current thread
/*!
This is usualy called by the pool's Selector.
*/
void associateToCurrentThread();
//! Executes the objects
/*!
This method is calle by selectpools with support for
events and timeouts
*/
virtual void execute(ExecuteContext &_rexectx);
void stop();
//! Set the thread id
void threadId(const IndexT &_thrid);
private:
IndexT fullid;
ATOMIC_NS::atomic<size_t> smask;
ATOMIC_NS::atomic<IndexT> thrid;
};
inline IndexT Object::id() const {
return fullid;
}
#ifndef NINLINES
#include "frame/object.ipp"
#endif
}//namespace frame
}//namespace solid
#endif
| 20.084746 | 89 | 0.719269 | joydit |
8781a3e7aec776a34a38c7f30aac146996651ab0 | 53 | cpp | C++ | xperf/vc_parallel_compiles/Group1_A.cpp | ariccio/main | c1dce7b2f4b2682a984894cce995fadee0fe717a | [
"MIT"
] | 17 | 2015-03-02T18:19:24.000Z | 2021-07-26T11:20:24.000Z | xperf/vc_parallel_compiles/Group1_A.cpp | ariccio/main | c1dce7b2f4b2682a984894cce995fadee0fe717a | [
"MIT"
] | 3 | 2015-03-02T04:14:25.000Z | 2015-09-05T23:04:42.000Z | xperf/vc_parallel_compiles/Group1_B.cpp | randomascii/main | e5c3a1f84922b912edc1f859c455e1f80a9b0f83 | [
"MIT"
] | 6 | 2015-02-08T04:19:57.000Z | 2016-04-22T11:34:26.000Z | #include "stdafx.h"
static int s_value = CALC_FIB1;
| 13.25 | 31 | 0.735849 | ariccio |
8781f7120eeb763696c4e9a344e0b5c1ec458bba | 12,049 | cpp | C++ | MediaCodecRT/DllLoader.cpp | gaobowen/MediaCodecRT | 8c0136eaf9c6cec50c9e4106d60988bdd0957e59 | [
"MIT"
] | 2 | 2019-02-18T09:25:46.000Z | 2019-04-19T08:05:58.000Z | MediaCodecRT/DllLoader.cpp | gaobowen/MediaCodecRT | 8c0136eaf9c6cec50c9e4106d60988bdd0957e59 | [
"MIT"
] | null | null | null | MediaCodecRT/DllLoader.cpp | gaobowen/MediaCodecRT | 8c0136eaf9c6cec50c9e4106d60988bdd0957e59 | [
"MIT"
] | null | null | null | #include "pch.h"
#include "DllLoader.h"
using namespace MediaCodecRT;
HMODULE avutil_55_mod;
HMODULE avcodec_57_mod;
HMODULE avformat_57_mod;
HMODULE swscale_4_mod;
HMODULE swresample_2_mod;
HMODULE avdevice_57_mod;
HMODULE avfilter_6_mod;
HMODULE kernelAddr;
def_av_register_all * m_av_register_all;
def_av_malloc* m_av_malloc;
def_avio_alloc_context* m_avio_alloc_context;
def_avformat_alloc_context* m_avformat_alloc_context;
def_avformat_open_input* m_avformat_open_input;
def_av_dict_free* m_av_dict_free;
def_avformat_find_stream_info* m_avformat_find_stream_info;
def_av_find_best_stream* m_av_find_best_stream;
def_avcodec_alloc_context3* m_avcodec_alloc_context3;
//def_avcodec_parameters_to_context* m_avcodec_parameters_to_context;
def_avcodec_open2* m_avcodec_open2;
def_av_frame_free* m_av_frame_free;
def_av_frame_alloc* m_av_frame_alloc;
def_av_image_get_buffer_size* m_av_image_get_buffer_size;
def_av_image_fill_arrays* m_av_image_fill_arrays;
def_sws_getContext* m_sws_getContext;
def_av_seek_frame* m_av_seek_frame;
def_avcodec_flush_buffers* m_avcodec_flush_buffers;
def_av_read_frame* m_av_read_frame;
def_av_packet_unref* m_av_packet_unref;
def_avcodec_decode_video2* m_avcodec_decode_video2;
def_sws_scale* m_sws_scale;
def_avcodec_close* m_avcodec_close;
def_avformat_close_input* m_avformat_close_input;
def_av_free* m_av_free;
def_avcodec_free_context* m_avcodec_free_context;
def_avcodec_find_decoder* m_avcodec_find_decoder;
def_avcodec_find_decoder_by_name* m_avcodec_find_decoder_by_name;
def_av_guess_format* m_av_guess_format;
def_avformat_alloc_output_context2* m_avformat_alloc_output_context2;
def_avformat_new_stream* m_avformat_new_stream;
def_avcodec_encode_video2* m_avcodec_encode_video2;
def_av_write_frame* m_av_write_frame;;
def_av_write_trailer* m_av_write_trailer;
def_avio_close* m_avio_close;
def_avformat_free_context* m_avformat_free_context;
def_avformat_write_header* m_avformat_write_header;
def_av_new_packet* m_av_new_packet;
def_avcodec_find_encoder* m_avcodec_find_encoder;
def_avcodec_find_encoder_by_name* m_avcodec_find_encoder_by_name;
def_avcodec_register_all* m_avcodec_register_all;
def_av_codec_next* m_av_codec_next;
//def_avio_alloc_context* m_static_avio_alloc_context;
//def_avformat_alloc_context* m_static_avformat_alloc_context;
//def_avcodec_open2* m_static_avcodec_open2;
//def_av_guess_format* m_static_av_guess_format;
//def_avformat_alloc_output_context2* m_static_avformat_alloc_output_context2;
//def_avformat_new_stream* m_static_avformat_new_stream;
//def_avcodec_encode_video2* m_static_avcodec_encode_video2;
//def_av_write_frame* m_static_av_write_frame;
//def_av_write_trailer* m_static_av_write_trailer;
//def_avio_close* m_static_avio_close;
//def_avformat_free_context* m_static_avformat_free_context;
//def_avformat_write_header* m_static_avformat_write_header;
//def_avcodec_find_encoder* m_static_avcodec_find_encoder;
//def_avcodec_find_encoder_by_name* m_static_avcodec_find_encoder_by_name;
//def_av_malloc* m_static_av_malloc;
//def_av_frame_alloc* m_static_av_frame_alloc;
//def_av_new_packet* m_static_av_new_packet;
//def_av_packet_unref * m_static_av_packet_unref;
//def_avcodec_close* m_static_avcodec_close;
//def_av_free* m_static_av_free;
//def_av_register_all * my_static_av_register_all;
DllLoader::DllLoader()
{
}
bool MediaCodecRT::DllLoader::LoadAll()
{
MEMORY_BASIC_INFORMATION info = {};
if (VirtualQuery(VirtualQuery, &info, sizeof(info)))
{
kernelAddr = (HMODULE)info.AllocationBase;
auto loadlibraryPtr = (int64_t)GetProcAddress(kernelAddr, "LoadLibraryExW");
auto loadLibrary = (LoadLibraryExWPtr*)loadlibraryPtr;
auto user32_mod = loadLibrary(L"user32.dll", nullptr, 0);
//auto kernel32Addr = loadLibrary(L"kernel32.dll", nullptr, 0);
//auto allfmpeg = loadLibrary(L"ffmpeg.adll", nullptr, 0);
//m_av_malloc/av_frame_free/av_frame_alloc/av_image_get_buffer_size/av_image_fill_arrays/
avutil_55_mod = loadLibrary(L"avutil-55.dll", nullptr, 0);
//avutil_55_mod = allfmpeg;
m_av_malloc = (def_av_malloc*)GetProcAddress(avutil_55_mod, "av_malloc");
m_av_frame_free = (def_av_frame_free*)GetProcAddress(avutil_55_mod, "av_frame_free");
m_av_frame_alloc = (def_av_frame_alloc*)GetProcAddress(avutil_55_mod, "av_frame_alloc");
m_av_image_get_buffer_size = (def_av_image_get_buffer_size*)GetProcAddress(avutil_55_mod, "av_image_get_buffer_size");
m_av_image_fill_arrays = (def_av_image_fill_arrays*)GetProcAddress(avutil_55_mod, "av_image_fill_arrays");
m_av_free = (def_av_free*)GetProcAddress(avutil_55_mod, "av_free");
m_av_dict_free = (def_av_dict_free*)GetProcAddress(avutil_55_mod, "av_dict_free");
//avcodec_alloc_context3/avcodec_find_decoder/avcodec_open2/avcodec_flush_buffers/av_packet_unref/avcodec_decode_video2
avcodec_57_mod = loadLibrary(L"avcodec-57.dll", nullptr, 0);
//avcodec_57_mod = allfmpeg;
m_avcodec_alloc_context3 = (def_avcodec_alloc_context3*)GetProcAddress(avcodec_57_mod, "avcodec_alloc_context3");
m_avcodec_find_decoder = (def_avcodec_find_decoder*)GetProcAddress(avcodec_57_mod, "avcodec_find_decoder");
m_avcodec_open2 = (def_avcodec_open2*)GetProcAddress(avcodec_57_mod, "avcodec_open2");
m_avcodec_flush_buffers = (def_avcodec_flush_buffers*)GetProcAddress(avcodec_57_mod, "avcodec_flush_buffers");
m_av_packet_unref = (def_av_packet_unref*)GetProcAddress(avcodec_57_mod, "av_packet_unref");
m_avcodec_decode_video2 = (def_avcodec_decode_video2*)GetProcAddress(avcodec_57_mod, "avcodec_decode_video2");
//m_avcodec_parameters_to_context = (def_avcodec_parameters_to_context*)GetProcAddress(avcodec_57_mod, "avcodec_parameters_to_context");
m_avcodec_free_context = (def_avcodec_free_context*)GetProcAddress(avcodec_57_mod, "avcodec_free_context");
m_avcodec_find_decoder_by_name = (def_avcodec_find_decoder_by_name*)GetProcAddress(avcodec_57_mod, "avcodec_find_decoder_by_name");
m_avcodec_close = (def_avcodec_close*)GetProcAddress(avcodec_57_mod, "avcodec_close");
m_avcodec_find_encoder = (def_avcodec_find_encoder*)GetProcAddress(avcodec_57_mod, "avcodec_find_encoder");
m_avcodec_encode_video2 = (def_avcodec_encode_video2*)GetProcAddress(avcodec_57_mod, "avcodec_encode_video2");
m_av_new_packet = (def_av_new_packet*)GetProcAddress(avcodec_57_mod, "av_new_packet");
m_avcodec_find_encoder_by_name = (def_avcodec_find_encoder_by_name*)GetProcAddress(avcodec_57_mod, "avcodec_find_encoder_by_name");
m_avcodec_register_all = (def_avcodec_register_all*)GetProcAddress(avcodec_57_mod, "avcodec_register_all");
m_av_codec_next = (def_av_codec_next*)GetProcAddress(avcodec_57_mod, "av_codec_next");
//m_av_register_all/avio_alloc_context/avformat_alloc_context/avformat_open_input/avformat_find_stream_info/av_find_best_stream
//av_seek_frame/av_read_frame
avformat_57_mod = loadLibrary(L"avformat-57.dll", nullptr, 0);
//avformat_57_mod = allfmpeg;
m_av_register_all = (def_av_register_all*)GetProcAddress(avformat_57_mod, "av_register_all");
m_avio_alloc_context = (def_avio_alloc_context*)GetProcAddress(avformat_57_mod, "avio_alloc_context");
m_avformat_alloc_context = (def_avformat_alloc_context*)GetProcAddress(avformat_57_mod, "avformat_alloc_context");
m_avformat_open_input = (def_avformat_open_input*)GetProcAddress(avformat_57_mod, "avformat_open_input");
m_avformat_find_stream_info = (def_avformat_find_stream_info*)GetProcAddress(avformat_57_mod, "avformat_find_stream_info");
m_av_find_best_stream = (def_av_find_best_stream*)GetProcAddress(avformat_57_mod, "av_find_best_stream");
m_av_seek_frame = (def_av_seek_frame*)GetProcAddress(avformat_57_mod, "av_seek_frame");
m_av_read_frame = (def_av_read_frame*)GetProcAddress(avformat_57_mod, "av_read_frame");
m_avformat_close_input = (def_avformat_close_input*)GetProcAddress(avformat_57_mod, "avformat_close_input");
m_av_guess_format = (def_av_guess_format*)GetProcAddress(avformat_57_mod, "av_guess_format");
m_avformat_alloc_output_context2 = (def_avformat_alloc_output_context2*)GetProcAddress(avformat_57_mod, "avformat_alloc_output_context2");
m_avformat_new_stream = (def_avformat_new_stream*)GetProcAddress(avformat_57_mod, "avformat_new_stream");
m_avio_close = (def_avio_close*)GetProcAddress(avformat_57_mod, "avio_close");
m_avformat_free_context = (def_avformat_free_context*)GetProcAddress(avformat_57_mod, "avformat_free_context");
m_avformat_write_header = (def_avformat_write_header*)GetProcAddress(avformat_57_mod, "avformat_write_header");
m_av_write_frame = (def_av_write_frame*)GetProcAddress(avformat_57_mod, "av_write_frame");
m_av_write_trailer = (def_av_write_trailer*)GetProcAddress(avformat_57_mod, "av_write_trailer");
//sws_getContext/sws_scale
swscale_4_mod = loadLibrary(L"swscale-4.dll", nullptr, 0);
//swscale_4_mod = allfmpeg;
m_sws_getContext = (def_sws_getContext*)GetProcAddress(swscale_4_mod, "sws_getContext");
m_sws_scale = (def_sws_scale*)GetProcAddress(swscale_4_mod, "sws_scale");
//swresample_2_mod = loadLibrary(L"swresample-2.dll", nullptr, 0);
//avdevice_57_mod = loadLibrary(L"avdevice-57.dll", nullptr, 0);
//avfilter_6_mod = loadLibrary(L"avfilter-6.dll", nullptr, 0);
if (avutil_55_mod != nullptr && avcodec_57_mod != nullptr&& avformat_57_mod != nullptr&& swscale_4_mod != nullptr)
{
m_avcodec_register_all();
//AVCodec *c = m_av_codec_next(NULL);
//AVCodec* bbb = m_avcodec_find_encoder_by_name("mjpeg");
//decodec->
//if (encodec == NULL)
//{
// return false;
//}
//auto allfmpeg = loadLibrary(L"ffmpeg.txt", nullptr, 0);
//if (allfmpeg != NULL)
//{
// my_static_av_register_all = (def_av_register_all*)GetProcAddress(allfmpeg, "av_register_all");
// m_static_avio_alloc_context = (def_avio_alloc_context*)GetProcAddress(allfmpeg, "avio_alloc_context");
// m_static_avformat_alloc_context = (def_avformat_alloc_context*)GetProcAddress(allfmpeg, "avformat_alloc_context");
// m_static_avcodec_open2 = (def_avcodec_open2*)GetProcAddress(allfmpeg, "avcodec_open2");
// m_static_av_guess_format = (def_av_guess_format*)GetProcAddress(allfmpeg, "av_guess_format");
// m_static_avformat_alloc_output_context2 = (def_avformat_alloc_output_context2*)GetProcAddress(allfmpeg, "avformat_alloc_output_context2");
// m_static_avformat_new_stream = (def_avformat_new_stream*)GetProcAddress(allfmpeg, "avformat_new_stream");
// m_static_avcodec_encode_video2 = (def_avcodec_encode_video2*)GetProcAddress(allfmpeg, "avcodec_encode_video2");
// m_static_av_write_frame = (def_av_write_frame*)GetProcAddress(allfmpeg, "av_write_frame");
// m_static_av_write_trailer = (def_av_write_trailer*)GetProcAddress(allfmpeg, "av_write_trailer");
// m_static_avio_close = (def_avio_close*)GetProcAddress(allfmpeg, "avio_close");
// m_static_avformat_free_context = (def_avformat_free_context*)GetProcAddress(allfmpeg, "avformat_free_context");
// m_static_avformat_write_header = (def_avformat_write_header*)GetProcAddress(allfmpeg, "avformat_write_header");
// m_static_avcodec_find_encoder = (def_avcodec_find_encoder*)GetProcAddress(allfmpeg, "avcodec_find_encoder");
// m_static_avcodec_find_encoder_by_name = (def_avcodec_find_encoder_by_name*)GetProcAddress(allfmpeg, "avcodec_find_encoder_by_name");
// m_static_av_malloc = (def_av_malloc*)GetProcAddress(allfmpeg, "av_malloc");
// m_static_av_frame_alloc = (def_av_frame_alloc*)GetProcAddress(allfmpeg, "av_frame_alloc");
// m_static_av_new_packet = (def_av_new_packet*)GetProcAddress(allfmpeg, "av_new_packet");
// m_static_av_packet_unref = (def_av_packet_unref*)GetProcAddress(allfmpeg, "av_packet_unref");
// m_static_avcodec_close = (def_avcodec_close*)GetProcAddress(allfmpeg, "avcodec_close");
// m_static_av_free = (def_av_free*)GetProcAddress(allfmpeg, "av_free");
//}
return true;
}
}
return false;
}
DllLoader::~DllLoader()
{
}
| 54.768182 | 144 | 0.822226 | gaobowen |
8784146ac13d6b974322b8364facab1e6964f0b1 | 2,947 | cpp | C++ | actividades/sesion4/OSalvador/Actividad1/Vectores final.cpp | gsosad/Programacion-I | 16bba6989fa09f6c9801a1092cf4ab4a2833876e | [
"MIT"
] | 1 | 2019-01-12T18:13:54.000Z | 2019-01-12T18:13:54.000Z | actividades/sesion4/OSalvador/Actividad1/Vectores final.cpp | gsosad/Programacion-I | 16bba6989fa09f6c9801a1092cf4ab4a2833876e | [
"MIT"
] | 1 | 2018-10-14T18:12:28.000Z | 2018-10-14T18:12:28.000Z | actividades/sesion4/OSalvador/Actividad1/Vectores final.cpp | gsosad/Programacion-I | 16bba6989fa09f6c9801a1092cf4ab4a2833876e | [
"MIT"
] | null | null | null | #include <iostream>
#include <math.h>
using namespace std;
class Vector3D{
private:
float x,y,z;
float a,b,c;
public:
Vector3D(float _x, float _y, float _z){
x = _x;
y = _y;
z = _z;
}
void getCoordinates(float &a, float &b, float &c){
a = x;
b = y;
c = z;
}
//no dar valores de las coordenadas, llamar al vector
void scalarMultiplyBy(float num){
//x* = num es un atajo de x = x * num
x*= num;
y*= num;
z*= num;
}
//no estoy seguro de que el resultado del modulo sea correcto, pero la formula parece estar bien
float module(){
return sqrt(pow(x,2)+pow(y,2)+pow(z,2));
}
void add (Vector3D a ){
x = x + a.x;
y = y + a.y;
z = z + a.z;
}
void vectorMultiplyBy (Vector3D a ){
x = x * a.x;
y = y * a.y;
z = z * a.z;
}
};
int main(){
//declaracion de vectores y modulo
float x,y,z;
cout << "Introduce las coordenadas un primer vector: " << endl;
cin >> x >> y >> z;
Vector3D VectorUno(x,y,z);
VectorUno.getCoordinates(x,y,z);
cout << "El primer vector tiene coordenadas "<< "x: " << x << ", y: " << y << ", z: " << z << endl;
cout << "El modulo del vector vale: " << VectorUno.module() << endl;
float operador;
cout << "Por que numero quieres multiplicar tu vector?" << endl;
cin >> operador;
cout << "El resultado es: " << endl;
VectorUno.scalarMultiplyBy(operador);
//getCoordinates lo que hace es sobreescribir los valores de x,y,z con los x,y,z del vector
VectorUno.getCoordinates(x,y,z);
cout << "x: " << x << ", y: " << y << ", z: " << z << endl << endl;
cout << "Introduce las coordernadas de un segundo vector por el que multiplicar al primero: " << endl;
cin >> x >> y >> z;
Vector3D VectorDos(x,y,z);
VectorDos.getCoordinates(x,y,z);
cout << "Las coordenadas del segundo vector valen "<< "x: " << x << ", y: " << y << ", z: " << z << endl;
cout << "El modulo del segundo vector vale: " << VectorDos.module() << endl;
cout << "Introduce las coordernadas de un tercer vector que suma al segundo: " << endl;
cin >> x >> y >> z;
Vector3D VectorTres(x,y,z);
VectorTres.getCoordinates(x,y,z);
cout << "Las coordenadas del tercer vector valen "<< "x: " << x << ", y: " << y << ", z: " << z << endl;
cout << "El modulo del tercer vector vale: " << VectorTres.module() << endl;
//operaciones de vectores
VectorUno.vectorMultiplyBy(VectorDos);
VectorUno.getCoordinates(x,y,z);
cout << "El producto del primer y segundo vectores es el vector de coordenadas x: " << x << ", y:" << y << ", z:" << z << endl;
VectorDos.add(VectorTres);
VectorDos.getCoordinates(x,y,z);
cout << "La suma del segundo y tercer vectores es el vector de coordenadas x: " << x << ", y: " << y << ", z: " << z << endl;
return 0;
}
| 27.287037 | 130 | 0.556159 | gsosad |
8784aced478528d638b9691c26e77057c0b11a1f | 10,048 | cpp | C++ | editor/src/window/window.cpp | TSAVideoGame/Skidibidipop | 62a8f949266df13cd759e3b98e36e16e05aabd11 | [
"Zlib"
] | 1 | 2020-12-26T21:52:59.000Z | 2020-12-26T21:52:59.000Z | editor/src/window/window.cpp | TSAVideoGame/Skidibidipop | 62a8f949266df13cd759e3b98e36e16e05aabd11 | [
"Zlib"
] | 2 | 2021-01-15T04:05:00.000Z | 2021-03-03T18:37:08.000Z | editor/src/window/window.cpp | TSAVideoGame/Skidibidipop | 62a8f949266df13cd759e3b98e36e16e05aabd11 | [
"Zlib"
] | null | null | null | #include "window.h"
#include "constants.h"
#include <ctime>
#include <SDL2/SDL_ttf.h>
bool Editor::Window::running = true;
SDLW::Window* Editor::Window::window;
SDLW::Renderer* Editor::Window::renderer;
Editor::Inputs Editor::Window::inputs;
Editor::Tool::Manager* Editor::Window::tool_manager;
std::string Editor::Window::current_file;
SDLW::Texture* Editor::Window::current_file_tex;
std::string Editor::Window::queue_file;
std::uint16_t Editor::Window::current_section = 0;
std::uint16_t Editor::Window::queue_section = current_section;
unsigned int Editor::Window::current_zoom = 1;
Data::Save::Data Editor::Window::data = Data::Save::load("res/default.sbbd");
SDLW::Texture* Editor::Window::spritesheet;
size_t Editor::Window::firstTile; // Top-left most tile
Editor::Tool::Base* Editor::Window::selected_tool = nullptr;
void Editor::Window::init()
{
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
window = new SDLW::Window("SBB Editor", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Constants::Window.width, Constants::Window.height, 0);
renderer = new SDLW::Renderer(window);
inputs = {false, false, 0, 0, 0, 0, 0, 0, 0};
spritesheet = new SDLW::Texture("res/spritesheet.png", renderer);
// The default file name is SBBD_time.sbbd
char timeNameBuffer[20];
std::time_t rawtime;
time(&rawtime);
std::tm* timeinfo = localtime(&rawtime);
strftime(timeNameBuffer, sizeof(timeNameBuffer), "%Y_%m_%d_%T", timeinfo);
current_file = "SBBD_";
current_file.append(timeNameBuffer);
current_file += ".sbbd";
current_file_tex = nullptr;
create_current_file_texture();
queue_file = current_file;
firstTile = 0;
tool_manager = new Tool::Manager(renderer);
}
void Editor::Window::close()
{
delete spritesheet;
delete current_file_tex;
delete tool_manager;
delete renderer;
delete window;
TTF_Quit();
SDL_Quit();
}
void Editor::Window::input()
{
inputs.oldMouseDown = inputs.mouseDown;
inputs.oldMouseX = inputs.mouseX;
inputs.oldMouseY = inputs.mouseY;
inputs.mouseWheelY = 0;
SDL_Event e;
while(SDL_PollEvent(&e))
{
switch (e.type)
{
case SDL_QUIT:
{
running = false;
break;
}
case SDL_MOUSEBUTTONDOWN:
{
switch (e.button.button)
{
case SDL_BUTTON_LEFT:
{
inputs.mouseDown = true;
if (!inputs.oldMouseDown)
SDL_GetMouseState(&inputs.clickMouseX, &inputs.clickMouseY);
break;
}
}
break;
}
case SDL_MOUSEBUTTONUP:
{
switch (e.button.button)
{
case SDL_BUTTON_LEFT:
{
inputs.mouseDown = false;
break;
}
}
break;
}
case SDL_MOUSEWHEEL:
{
inputs.mouseWheelY = e.wheel.y;
break;
}
case SDL_WINDOWEVENT:
{
if (SDL_GetWindowID(window->get_SDL()) != e.window.windowID)
{
inputs.mouseDown = false;
}
break;
}
}
}
SDL_GetMouseState(&inputs.mouseX, &inputs.mouseY);
}
void Editor::Window::update()
{
if (queue_file != current_file)
{
update_current_file();
}
if (queue_section != current_section)
{
update_current_section();
}
static unsigned int tempFirstTile = firstTile, tempViewX = firstTile % data.map.sections[current_section].size.x, tempViewY = firstTile / data.map.sections[current_section].size.y;
tool_manager->update(MouseState::HOVER);
if (inputs.mouseDown)
{
if (!inputs.oldMouseDown) // Click
{
tool_manager->update(MouseState::CLICK);
}
// Drag
if (selected_tool != nullptr)
{
tool_manager->update(MouseState::DRAG);
}
// This camera movement is all broken
else
{
int maxDrag = 29; // This will help in solving overflow messes
int y = -((inputs.mouseY - inputs.clickMouseY) / Constants::Grid.size);
int x = ((inputs.mouseX - inputs.clickMouseX) / Constants::Grid.size);
// Make y within bounds
if (tempFirstTile / data.map.sections[current_section].size.x < maxDrag && static_cast<int>(tempFirstTile / data.map.sections[current_section].size.x) + y < 0)
y = -(tempFirstTile / data.map.sections[current_section].size.x);
else if (tempFirstTile / data.map.sections[current_section].size.x + y >= data.map.sections[current_section].size.y)
y = (data.map.sections[current_section].size.y - 1) - (tempFirstTile / data.map.sections[current_section].size.x);
// Make x within bounds
if (tempFirstTile % data.map.sections[current_section].size.x < maxDrag && static_cast<int>(tempFirstTile % data.map.sections[current_section].size.x) + x < 0)
x = -(tempFirstTile % data.map.sections[current_section].size.x);
else if (tempFirstTile % data.map.sections[current_section].size.x + x >= data.map.sections[current_section].size.x)
x = (data.map.sections[current_section].size.x - 1) - (tempFirstTile % data.map.sections[current_section].size.x);
// Change firstTile
firstTile = tempFirstTile + data.map.sections[current_section].size.x * y + x;
}
}
// Release
if (!inputs.mouseDown && inputs.oldMouseDown)
{
if (selected_tool == nullptr)
{
tempFirstTile = firstTile;
tempViewX = firstTile % data.map.sections[current_section].size.x;
tempViewY = firstTile / data.map.sections[current_section].size.y;
}
}
// Scroll
if (std::abs(inputs.mouseWheelY) > 0)
{
if (inputs.mouseWheelY > 0) // Decrease zoom
{
if (current_zoom > 0)
--current_zoom;
}
else // Increase zoom
{
if (current_zoom < 4)
++current_zoom;
}
}
}
static void drawGrid(SDL_Renderer* renderer)
{
int size = 32;
SDL_SetRenderDrawColor(renderer, 36, 82, 94, 255);
// Draw vertical lines
for (int i = 1; i < Editor::Constants::Window.width / size; i++)
SDL_RenderDrawLine(renderer, i * size, 0, i * size, Editor::Constants::Window.height);
// Draw horizontal lines
for (int i = 1; i < Editor::Constants::Window.height / size; i++)
SDL_RenderDrawLine(renderer, 0, i * size, Editor::Constants::Window.width, i * size);
}
void Editor::Window::draw_tiles()
{
int size = Constants::Grid.size / std::pow(2, current_zoom);
SDL_Rect dRect = {0, 0, size, size};
SDL_Rect sRect = {0, 0, 32, 32};
unsigned int windowXTiles = Constants::Window.width / size;
unsigned int maxXTiles = data.map.sections[current_section].size.x - (firstTile % data.map.sections[current_section].size.x) < windowXTiles ? data.map.sections[current_section].size.x - (firstTile % data.map.sections[current_section].size.x) : windowXTiles;
unsigned int windowYTiles = (Constants::Window.height - Constants::Window.toolBarHeight) / size;
unsigned int maxYTiles = data.map.sections[current_section].size.y - (firstTile / data.map.sections[current_section].size.x) < windowYTiles ? data.map.sections[current_section].size.y - (firstTile / data.map.sections[current_section].size.x) : windowYTiles;
for (unsigned int row = 0; row < maxYTiles; ++row)
{
for (unsigned int col = 0; col < maxXTiles; ++col)
{
// Draw tile (id)
sRect.x = data.map.sections[current_section].tiles[firstTile + (row * data.map.sections[current_section].size.x) + col].id * 32;
sRect.y = 0;
renderer->copy(spritesheet, &sRect, &dRect);
// Draw tile objects (state)
sRect.x = data.map.sections[current_section].tiles[firstTile + (row * data.map.sections[current_section].size.x) + col].state * 32;
sRect.y = 32;
renderer->copy(spritesheet, &sRect, &dRect);
// Increment dRect
dRect.x += size;
}
dRect.x = 0;
dRect.y += size;
}
}
void Editor::Window::draw()
{
renderer->set_draw_color(10, 56, 69, 255);
renderer->clear();
// Draw map stuff
drawGrid(renderer->get_SDL());
draw_tiles();
// Draw tool stuff
// Draw the toolbar
SDL_Color c = tool_manager->getColor();
renderer->set_draw_color(c.r, c.g, c.b, 255);
SDL_Rect toolbar = {0, Constants::Window.height - Constants::Window.toolBarHeight, Constants::Window.width, Constants::Window.toolBarHeight};
SDL_RenderFillRect(renderer->get_SDL(), &toolbar);
tool_manager->draw();
// Draw the current file
SDL_Rect dRect = {4, Constants::Window.height - 24, 0, 0};
SDL_QueryTexture(current_file_tex->get_SDL(), 0, 0, &dRect.w, &dRect.h);
renderer->copy(current_file_tex, 0, &dRect);
renderer->present();
}
void Editor::Window::create_current_file_texture()
{
std::string displayText = "File: " + current_file;
TTF_Font* font = TTF_OpenFont("res/fonts/open-sans/OpenSans-Regular.ttf", 16);
SDL_Surface* txtSurface = TTF_RenderText_Blended(font, displayText.c_str(), {255, 255, 255});
if (current_file_tex != nullptr)
delete current_file_tex;
current_file_tex = new SDLW::Texture(SDL_CreateTextureFromSurface(renderer->get_SDL(), txtSurface));
SDL_FreeSurface(txtSurface);
TTF_CloseFont(font);
}
void Editor::Window::update_current_file()
{
current_file = queue_file;
create_current_file_texture();
data = Data::Save::load(current_file);
}
void Editor::Window::update_current_section()
{
if (queue_section < 0 || queue_section > data.map.sections.size() - 1)
{
queue_section = current_section;
return; // Queue is invalid
}
current_section = queue_section;
}
void Editor::Window::set_current_file(const std::string& new_file)
{
queue_file = new_file;
}
void Editor::Window::set_current_section(std::uint16_t new_section)
{
queue_section = new_section;
}
bool Editor::Window::is_running() { return running; }
Editor::Inputs Editor::Window::get_inputs() { return inputs; }
std::string Editor::Window::get_current_file() { return current_file; };
size_t Editor::Window::get_first_tile() { return firstTile; };
std::uint16_t Editor::Window::get_current_section() { return current_section; }
unsigned int Editor::Window::get_current_zoom() { return current_zoom; }
| 31.012346 | 259 | 0.670681 | TSAVideoGame |
878a5b9179b13aeab45163038d767f436d87e349 | 2,140 | cpp | C++ | Algorithms Design and Analysis II/knapsack.cpp | cbrghostrider/Coursera | 0b509adb57f2e96e0d7b4119d50cdf2e555abafe | [
"MIT"
] | null | null | null | Algorithms Design and Analysis II/knapsack.cpp | cbrghostrider/Coursera | 0b509adb57f2e96e0d7b4119d50cdf2e555abafe | [
"MIT"
] | null | null | null | Algorithms Design and Analysis II/knapsack.cpp | cbrghostrider/Coursera | 0b509adb57f2e96e0d7b4119d50cdf2e555abafe | [
"MIT"
] | null | null | null | // -------------------------------------------------------------------------------------
// Author: Sourabh S Joshi (cbrghostrider); Copyright - All rights reserved.
// For email, run on linux (perl v5.8.5):
// perl -e 'print pack "H*","736f75726162682e732e6a6f73686940676d61696c2e636f6d0a"'
// -------------------------------------------------------------------------------------
#include <iostream>
#include <cstdio>
#include <vector>
struct Item {
unsigned long long value;
unsigned long long weight;
Item (unsigned long long v, unsigned long long w) : value(v), weight(w) {}
};
void readProblem (std::vector<Item>& items, unsigned long long& wt)
{
unsigned int number;
std::cin >> wt >> number;
for (unsigned int i=0;i<number; i++) {
unsigned long long value=0, weight=0;
std::cin >> value >> weight;
items.push_back(Item(value, weight));
}
}
unsigned long long solveProblem (const std::vector<Item>& items, unsigned long long weight)
{
unsigned long long ** arr = new unsigned long long*[2];
arr[0] = new unsigned long long[weight];
arr[1] = new unsigned long long[weight];
for (unsigned int w=0; w<weight+1; w++) {
arr[0][w] = 0;
}
unsigned int last_iter = 0;
unsigned int this_iter = 1;
for (unsigned int i=1; i<items.size()+1; i++) {
for (unsigned int w=0; w<weight+1; w++) {
unsigned int ci = i-1;
unsigned long long opt1 = arr[last_iter][w];
unsigned long long opt2 = (w < items[ci].weight ) ? 0 : arr[last_iter][w-items[ci].weight] + items[ci].value;
arr[this_iter][w] = opt1 > opt2 ? opt1 : opt2;
}
last_iter = 1 - last_iter;
this_iter = 1 - this_iter;
}
unsigned long long ret = arr[last_iter][weight];
delete [] arr[1];
delete [] arr[0];
delete [] arr;
return ret;
}
int main()
{
std::vector<Item> items;
unsigned long long weight=0;
readProblem(items, weight);
unsigned long long answer = solveProblem(items, weight);
std::cout << "Answer = " << answer << std::endl;
}
| 30.571429 | 121 | 0.55 | cbrghostrider |
878abcf148a3850557bb810a51b4c8dc7ddef060 | 2,372 | cpp | C++ | src/main.cpp | mystery124/MilestoneRoomController | 1101c110f25d1cc348cf7da304dd9fe5d33a5876 | [
"MIT"
] | null | null | null | src/main.cpp | mystery124/MilestoneRoomController | 1101c110f25d1cc348cf7da304dd9fe5d33a5876 | [
"MIT"
] | 7 | 2020-03-23T17:48:57.000Z | 2020-04-21T19:48:20.000Z | src/main.cpp | mystery124/MilestoneRoomController | 1101c110f25d1cc348cf7da304dd9fe5d33a5876 | [
"MIT"
] | null | null | null | #include <Arduino.h>
#include <Ticker.h>
#define LOGGING_SERIAL
#include "Logger.h"
#include "WifiManager.h"
#include "BME280Sensor.h"
/*
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
//local
#include <OTAHandler.h>
#define SEALEVELPRESSURE_HPA (1013.25)
OTAHandler otaHandler;
ESP8266WebServer server(80);
Adafruit_BME280 bme;
// hold uploaded file
File fsUploadFile;
void handleFileUpload(){
HTTPUpload& upload = server.upload();
if(upload.status == UPLOAD_FILE_START)
{
String filename = upload.filename;
if(!filename.startsWith("/"))
filename = "/d/"+filename;
Serial.print("handleFileUpload Name: "); Serial.println(filename);
fsUploadFile = SPIFFS.open(filename, "w+");
} else if(upload.status == UPLOAD_FILE_WRITE)
{
if(fsUploadFile)
fsUploadFile.write(upload.buf, upload.currentSize);
} else if(upload.status == UPLOAD_FILE_END)
{
if(fsUploadFile)
fsUploadFile.close();
Serial.print("handleFileUpload Size: "); Serial.println(upload.totalSize);
}
}
*/
void pinOn();
void readSensorAndPrint();
void goToSleep();
WiFiManagment::WifiManager wifiService;
Sensors::BME280Sensor bmeSensor;
bool sendFlag = false;
Ticker tick;
void setup(){
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
LOGGER
bmeSensor.init();
LOG("Start WIFI");
wifiService.attachConnectionHandler(pinOn);
wifiService.attachConnectionHandler(readSensorAndPrint);
wifiService.startWifi();
LOG("config WIFI done");
tick.attach(30, goToSleep);
}
void loop(){
wifiService.handleClient();
//otaHandler.handleOTA();
//server.handleClient();
LOGGER;
if(sendFlag){
goToSleep();
}
}
void goToSleep(){
int val = 60;
LOG("Going Sleep");
ESP.deepSleep(val*1000*1000);
}
void readSensorAndPrint(){
LOGGER;
bmeSensor.setMode(Adafruit_BME280::MODE_NORMAL);
Sensors::BME20SensorData data = bmeSensor.read();
bmeSensor.setMode(Adafruit_BME280::MODE_SLEEP);
LOG("Temp: ");
LOG(data.temperature);
LOG("Humidity: ");
LOG(data.humidity);
LOG("Pressure: ");
LOG(data.pressure);
sendFlag = true;
};
void pinOn(){
digitalWrite(LED_BUILTIN, LOW);
}; | 20.448276 | 82 | 0.673693 | mystery124 |
879f573b97bc57846b43a90f84ea7574c8208275 | 561 | cpp | C++ | codeforces/1385C.cpp | mhilmyh/algo-data-struct | 6a9b1e5220e3c4e4a41200a09cb27f3f55560693 | [
"MIT"
] | null | null | null | codeforces/1385C.cpp | mhilmyh/algo-data-struct | 6a9b1e5220e3c4e4a41200a09cb27f3f55560693 | [
"MIT"
] | null | null | null | codeforces/1385C.cpp | mhilmyh/algo-data-struct | 6a9b1e5220e3c4e4a41200a09cb27f3f55560693 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int solve(int n, vector<int> &a)
{
if (n == 1)
return 0;
bool asc = true;
int i;
for (i = n - 1; i > 0; i--)
{
if (asc && a[i] > a[i - 1])
asc = false;
else if (!asc && a[i] < a[i - 1])
break;
}
return i;
};
int main()
{
int t, n;
cin >> t;
while (t--)
{
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
cout << solve(n, a) << "\n";
}
return 0;
} | 15.583333 | 41 | 0.367201 | mhilmyh |
87a4b78e9d2044e990eec03989d946dad3d6c1eb | 312 | cpp | C++ | homework6/merge_sort/readFile.cpp | mxprshn/homework | 809635858a5bf01af7f63f398fe47fba7c688ecc | [
"Apache-2.0"
] | null | null | null | homework6/merge_sort/readFile.cpp | mxprshn/homework | 809635858a5bf01af7f63f398fe47fba7c688ecc | [
"Apache-2.0"
] | null | null | null | homework6/merge_sort/readFile.cpp | mxprshn/homework | 809635858a5bf01af7f63f398fe47fba7c688ecc | [
"Apache-2.0"
] | 2 | 2018-11-06T19:31:20.000Z | 2018-12-17T19:39:07.000Z | #include "list.h"
#include <fstream>
#include <string>
bool readFile(std::ifstream &file, List *list)
{
if (!file.is_open())
{
return false;
}
while (!file.eof())
{
std::string name;
std::string number;
getline(file, name);
getline(file, number);
add(list, name, number);
}
return true;
} | 13 | 46 | 0.63141 | mxprshn |
87a6137215523a94877098b08bedb8addcdd866b | 1,086 | hpp | C++ | bg/curves/euriborcurve.hpp | bondgeek/pybg | 046a25074b78409c6d29302177aeac581ade90d1 | [
"Unlicense",
"MIT"
] | 1 | 2017-03-14T05:39:15.000Z | 2017-03-14T05:39:15.000Z | bg/curves/euriborcurve.hpp | bondgeek/pybg | 046a25074b78409c6d29302177aeac581ade90d1 | [
"Unlicense",
"MIT"
] | null | null | null | bg/curves/euriborcurve.hpp | bondgeek/pybg | 046a25074b78409c6d29302177aeac581ade90d1 | [
"Unlicense",
"MIT"
] | null | null | null | /*
* euriborcurve.hpp
* pybg
*
* Created by Bart Mosley on 7/2/12.
* Copyright 2012 BG Research LLC. All rights reserved.
*
*/
#ifndef EURIBORCURVE_HPP
#define EURIBORCURVE_HPP
#include <bg/curvebase.hpp>
#include <bg/date_utilities.hpp>
using namespace QuantLib;
namespace bondgeek {
class EURiborCurve : public CurveBase {
protected:
public:
EURiborCurve():
CurveBase(boost::shared_ptr<IborIndex>(new Euribor(Period(6, Months))),
2,
Annual,
Unadjusted,
Thirty360(Thirty360::European),
ActualActual(ActualActual::ISDA)
)
{}
EURiborCurve(string tenor, Frequency fixedFrequency=Annual):
CurveBase(boost::shared_ptr<IborIndex>(new Euribor( Tenor(tenor) )),
2,
fixedFrequency,
Unadjusted,
Thirty360(Thirty360::European),
ActualActual(ActualActual::ISDA)
)
{
}
};
}
#endif | 24.133333 | 79 | 0.54512 | bondgeek |
87a79139386d672e8b4c8a45dbdb6efffa951bca | 3,398 | cpp | C++ | RUNETag/hirestimer.cpp | GeReV/RUNEtag | e8319a132e325d73cdd7759a0d8a5f45f26dd129 | [
"MIT"
] | 31 | 2017-12-29T16:39:07.000Z | 2022-03-25T03:26:29.000Z | RUNETag/hirestimer.cpp | GeReV/RUNEtag | e8319a132e325d73cdd7759a0d8a5f45f26dd129 | [
"MIT"
] | 7 | 2018-06-29T07:30:14.000Z | 2021-02-16T23:19:20.000Z | RUNETag/hirestimer.cpp | GeReV/RUNEtag | e8319a132e325d73cdd7759a0d8a5f45f26dd129 | [
"MIT"
] | 13 | 2018-09-27T13:19:12.000Z | 2022-03-02T08:48:42.000Z | /**
* RUNETag fiducial markers library
*
* -----------------------------------------------------------------------------
* The MIT License (MIT)
*
* Copyright (c) 2015 Filippo Bergamasco
*
* 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 "hirestimer.hpp"
HiresTimer::HiresTimer(void)
{
started = false;
stopped = true;
}
HiresTimer::~HiresTimer(void)
{
}
#ifdef WIN32
/*
* Win32 Hi-res timer code
*/
double LI1D(LARGE_INTEGER *i) {
return(i->LowPart+(i->HighPart*4294967296.0));
}
void HiresTimer::start() {
started = true;
stopped = false;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&start_time);
}
double HiresTimer::elapsed() {
if( !started )
return 0.0;
if( !stopped ) {
LARGE_INTEGER end_time;
QueryPerformanceCounter(&end_time);
elapsed_time = (LI1D(&end_time) - LI1D(&start_time)) / LI1D(&frequency);
}
return elapsed_time;
}
void HiresTimer::stop() {
LARGE_INTEGER end_time;
QueryPerformanceCounter(&end_time);
elapsed_time = (LI1D(&end_time) - LI1D(&start_time)) / LI1D(&frequency);
stopped = true;
}
void HiresTimer::reset() {
started = false;
stopped = false;
}
#else
#ifdef UNIX
/*
* Unix Hi-res timer code
*/
void HiresTimer::start() {
started = true;
stopped = false;
start_time = 0.0;
struct timeval start_timeval;
gettimeofday( &start_timeval, NULL );
start_time = (double)start_timeval.tv_sec + (double)start_timeval.tv_usec/1000000.0;
}
double HiresTimer::elapsed() {
if( !started )
return 0.0;
if( !stopped ) {
struct timeval end_timeval;
gettimeofday( &end_timeval, NULL );
double tnow = (double)end_timeval.tv_sec + (double)end_timeval.tv_usec/1000000.0;
elapsed_time = tnow-start_time;
}
return elapsed_time;
}
void HiresTimer::stop() {
struct timeval end_timeval;
gettimeofday( &end_timeval, NULL );
double tnow = (double)end_timeval.tv_sec + (double)end_timeval.tv_usec/1000000.0;
elapsed_time = tnow-start_time;
stopped = true;
}
void HiresTimer::reset() {
started = false;
stopped = false;
}
#else
/*
* Standard timer (NOT yet implemented)
*/
//#error Default standard timer not yet implemented. You see this error probably because you are trying to compile against an unsupported platform
#endif
#endif
| 24.985294 | 147 | 0.685992 | GeReV |
87a95e3db8fcbb1816a328097c375065212d8b99 | 24,965 | cpp | C++ | api/src/SAM_Windpower.cpp | nickdiorio/SAM | 4288d4261f4f88f44106867b561b81c2ba480c85 | [
"BSD-3-Clause"
] | null | null | null | api/src/SAM_Windpower.cpp | nickdiorio/SAM | 4288d4261f4f88f44106867b561b81c2ba480c85 | [
"BSD-3-Clause"
] | null | null | null | api/src/SAM_Windpower.cpp | nickdiorio/SAM | 4288d4261f4f88f44106867b561b81c2ba480c85 | [
"BSD-3-Clause"
] | null | null | null | #include <string>
#include <utility>
#include <vector>
#include <memory>
#include <iostream>
#include <ssc/sscapi.h>
#include "SAM_api.h"
#include "ErrorHandler.h"
#include "SAM_Windpower.h"
SAM_EXPORT SAM_Windpower SAM_Windpower_construct(const char* def, SAM_error* err){
SAM_Windpower result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_create();
});
return result;
}
SAM_EXPORT int SAM_Windpower_execute(SAM_Windpower data, int verbosity, SAM_error* err){
int n_err = 0;
translateExceptions(err, [&]{
n_err += SAM_module_exec("windpower", data, verbosity, err);
});
return n_err;
}
SAM_EXPORT void SAM_Windpower_destruct(SAM_Windpower system)
{
ssc_data_free(system);
}
SAM_EXPORT void SAM_Windpower_Resource_weibull_k_factor_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "weibull_k_factor", number);
});
}
SAM_EXPORT void SAM_Windpower_Resource_weibull_reference_height_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "weibull_reference_height", number);
});
}
SAM_EXPORT void SAM_Windpower_Resource_weibull_wind_speed_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "weibull_wind_speed", number);
});
}
SAM_EXPORT void SAM_Windpower_Resource_wind_resource_data_tset(SAM_Windpower ptr, SAM_table tab, SAM_error *err){
SAM_table_set_table(ptr, "wind_resource_data", tab, err);
}
SAM_EXPORT void SAM_Windpower_Resource_wind_resource_distribution_mset(SAM_Windpower ptr, double* mat, int nrows, int ncols, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_matrix(ptr, "wind_resource_distribution", mat, nrows, ncols);
});
}
SAM_EXPORT void SAM_Windpower_Resource_wind_resource_filename_sset(SAM_Windpower ptr, const char* str, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_string(ptr, "wind_resource_filename", str);
});
}
SAM_EXPORT void SAM_Windpower_Resource_wind_resource_model_choice_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_resource_model_choice", number);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_resource_shear_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_resource_shear", number);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_turbine_hub_ht_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_turbine_hub_ht", number);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_turbine_max_cp_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_turbine_max_cp", number);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_turbine_powercurve_powerout_aset(SAM_Windpower ptr, double* arr, int length, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_array(ptr, "wind_turbine_powercurve_powerout", arr, length);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_turbine_powercurve_windspeeds_aset(SAM_Windpower ptr, double* arr, int length, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_array(ptr, "wind_turbine_powercurve_windspeeds", arr, length);
});
}
SAM_EXPORT void SAM_Windpower_Turbine_wind_turbine_rotor_diameter_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_turbine_rotor_diameter", number);
});
}
SAM_EXPORT void SAM_Windpower_Farm_system_capacity_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "system_capacity", number);
});
}
SAM_EXPORT void SAM_Windpower_Farm_wind_farm_wake_model_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_farm_wake_model", number);
});
}
SAM_EXPORT void SAM_Windpower_Farm_wind_farm_xCoordinates_aset(SAM_Windpower ptr, double* arr, int length, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_array(ptr, "wind_farm_xCoordinates", arr, length);
});
}
SAM_EXPORT void SAM_Windpower_Farm_wind_farm_yCoordinates_aset(SAM_Windpower ptr, double* arr, int length, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_array(ptr, "wind_farm_yCoordinates", arr, length);
});
}
SAM_EXPORT void SAM_Windpower_Farm_wind_resource_turbulence_coeff_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wind_resource_turbulence_coeff", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_avail_bop_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "avail_bop_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_avail_grid_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "avail_grid_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_avail_turb_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "avail_turb_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_elec_eff_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "elec_eff_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_en_icing_cutoff_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "en_icing_cutoff", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_en_low_temp_cutoff_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "en_low_temp_cutoff", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_env_degrad_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "env_degrad_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_env_exposure_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "env_exposure_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_env_ext_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "env_ext_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_env_icing_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "env_icing_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_icing_cutoff_rh_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "icing_cutoff_rh", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_icing_cutoff_temp_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "icing_cutoff_temp", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_low_temp_cutoff_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "low_temp_cutoff", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_ops_env_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "ops_env_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_ops_grid_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "ops_grid_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_ops_load_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "ops_load_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_ops_strategies_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "ops_strategies_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_turb_generic_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "turb_generic_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_turb_hysteresis_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "turb_hysteresis_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_turb_perf_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "turb_perf_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_turb_specific_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "turb_specific_loss", number);
});
}
SAM_EXPORT void SAM_Windpower_Losses_wake_loss_nset(SAM_Windpower ptr, double number, SAM_error *err){
translateExceptions(err, [&]{
ssc_data_set_number(ptr, "wake_loss", number);
});
}
SAM_EXPORT double SAM_Windpower_Resource_weibull_k_factor_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "weibull_k_factor", &result))
make_access_error("SAM_Windpower", "weibull_k_factor");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Resource_weibull_reference_height_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "weibull_reference_height", &result))
make_access_error("SAM_Windpower", "weibull_reference_height");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Resource_weibull_wind_speed_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "weibull_wind_speed", &result))
make_access_error("SAM_Windpower", "weibull_wind_speed");
});
return result;
}
SAM_EXPORT SAM_table SAM_Windpower_Resource_wind_resource_data_tget(SAM_Windpower ptr, SAM_error *err){
SAM_table result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_table(ptr, "wind_resource_data");
if (!result)
make_access_error("SAM_Windpower", "wind_resource_data");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Resource_wind_resource_distribution_mget(SAM_Windpower ptr, int* nrows, int* ncols, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_matrix(ptr, "wind_resource_distribution", nrows, ncols);
if (!result)
make_access_error("SAM_Windpower", "wind_resource_distribution");
});
return result;
}
SAM_EXPORT const char* SAM_Windpower_Resource_wind_resource_filename_sget(SAM_Windpower ptr, SAM_error *err){
const char* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_string(ptr, "wind_resource_filename");
if (!result)
make_access_error("SAM_Windpower", "wind_resource_filename");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Resource_wind_resource_model_choice_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_resource_model_choice", &result))
make_access_error("SAM_Windpower", "wind_resource_model_choice");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Turbine_wind_resource_shear_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_resource_shear", &result))
make_access_error("SAM_Windpower", "wind_resource_shear");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Turbine_wind_turbine_hub_ht_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_turbine_hub_ht", &result))
make_access_error("SAM_Windpower", "wind_turbine_hub_ht");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Turbine_wind_turbine_max_cp_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_turbine_max_cp", &result))
make_access_error("SAM_Windpower", "wind_turbine_max_cp");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Turbine_wind_turbine_powercurve_powerout_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_turbine_powercurve_powerout", length);
if (!result)
make_access_error("SAM_Windpower", "wind_turbine_powercurve_powerout");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Turbine_wind_turbine_powercurve_windspeeds_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_turbine_powercurve_windspeeds", length);
if (!result)
make_access_error("SAM_Windpower", "wind_turbine_powercurve_windspeeds");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Turbine_wind_turbine_rotor_diameter_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_turbine_rotor_diameter", &result))
make_access_error("SAM_Windpower", "wind_turbine_rotor_diameter");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Farm_system_capacity_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "system_capacity", &result))
make_access_error("SAM_Windpower", "system_capacity");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Farm_wind_farm_wake_model_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_farm_wake_model", &result))
make_access_error("SAM_Windpower", "wind_farm_wake_model");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Farm_wind_farm_xCoordinates_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_farm_xCoordinates", length);
if (!result)
make_access_error("SAM_Windpower", "wind_farm_xCoordinates");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Farm_wind_farm_yCoordinates_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_farm_yCoordinates", length);
if (!result)
make_access_error("SAM_Windpower", "wind_farm_yCoordinates");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Farm_wind_resource_turbulence_coeff_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wind_resource_turbulence_coeff", &result))
make_access_error("SAM_Windpower", "wind_resource_turbulence_coeff");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_avail_bop_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "avail_bop_loss", &result))
make_access_error("SAM_Windpower", "avail_bop_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_avail_grid_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "avail_grid_loss", &result))
make_access_error("SAM_Windpower", "avail_grid_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_avail_turb_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "avail_turb_loss", &result))
make_access_error("SAM_Windpower", "avail_turb_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_elec_eff_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "elec_eff_loss", &result))
make_access_error("SAM_Windpower", "elec_eff_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_en_icing_cutoff_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "en_icing_cutoff", &result))
make_access_error("SAM_Windpower", "en_icing_cutoff");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_en_low_temp_cutoff_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "en_low_temp_cutoff", &result))
make_access_error("SAM_Windpower", "en_low_temp_cutoff");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_env_degrad_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "env_degrad_loss", &result))
make_access_error("SAM_Windpower", "env_degrad_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_env_exposure_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "env_exposure_loss", &result))
make_access_error("SAM_Windpower", "env_exposure_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_env_ext_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "env_ext_loss", &result))
make_access_error("SAM_Windpower", "env_ext_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_env_icing_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "env_icing_loss", &result))
make_access_error("SAM_Windpower", "env_icing_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_icing_cutoff_rh_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "icing_cutoff_rh", &result))
make_access_error("SAM_Windpower", "icing_cutoff_rh");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_icing_cutoff_temp_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "icing_cutoff_temp", &result))
make_access_error("SAM_Windpower", "icing_cutoff_temp");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_low_temp_cutoff_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "low_temp_cutoff", &result))
make_access_error("SAM_Windpower", "low_temp_cutoff");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_ops_env_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "ops_env_loss", &result))
make_access_error("SAM_Windpower", "ops_env_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_ops_grid_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "ops_grid_loss", &result))
make_access_error("SAM_Windpower", "ops_grid_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_ops_load_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "ops_load_loss", &result))
make_access_error("SAM_Windpower", "ops_load_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_ops_strategies_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "ops_strategies_loss", &result))
make_access_error("SAM_Windpower", "ops_strategies_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_turb_generic_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "turb_generic_loss", &result))
make_access_error("SAM_Windpower", "turb_generic_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_turb_hysteresis_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "turb_hysteresis_loss", &result))
make_access_error("SAM_Windpower", "turb_hysteresis_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_turb_perf_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "turb_perf_loss", &result))
make_access_error("SAM_Windpower", "turb_perf_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_turb_specific_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "turb_specific_loss", &result))
make_access_error("SAM_Windpower", "turb_specific_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Losses_wake_loss_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "wake_loss", &result))
make_access_error("SAM_Windpower", "wake_loss");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Outputs_annual_energy_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "annual_energy", &result))
make_access_error("SAM_Windpower", "annual_energy");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Outputs_annual_gross_energy_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "annual_gross_energy", &result))
make_access_error("SAM_Windpower", "annual_gross_energy");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Outputs_capacity_factor_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "capacity_factor", &result))
make_access_error("SAM_Windpower", "capacity_factor");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Outputs_cutoff_losses_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "cutoff_losses", &result))
make_access_error("SAM_Windpower", "cutoff_losses");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_gen_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "gen", length);
if (!result)
make_access_error("SAM_Windpower", "gen");
});
return result;
}
SAM_EXPORT double SAM_Windpower_Outputs_kwh_per_kw_nget(SAM_Windpower ptr, SAM_error *err){
double result;
translateExceptions(err, [&]{
if (!ssc_data_get_number(ptr, "kwh_per_kw", &result))
make_access_error("SAM_Windpower", "kwh_per_kw");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_monthly_energy_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "monthly_energy", length);
if (!result)
make_access_error("SAM_Windpower", "monthly_energy");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_pressure_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "pressure", length);
if (!result)
make_access_error("SAM_Windpower", "pressure");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_temp_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "temp", length);
if (!result)
make_access_error("SAM_Windpower", "temp");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_turbine_output_by_windspeed_bin_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "turbine_output_by_windspeed_bin", length);
if (!result)
make_access_error("SAM_Windpower", "turbine_output_by_windspeed_bin");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_wind_direction_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_direction", length);
if (!result)
make_access_error("SAM_Windpower", "wind_direction");
});
return result;
}
SAM_EXPORT double* SAM_Windpower_Outputs_wind_speed_aget(SAM_Windpower ptr, int* length, SAM_error *err){
double* result = nullptr;
translateExceptions(err, [&]{
result = ssc_data_get_array(ptr, "wind_speed", length);
if (!result)
make_access_error("SAM_Windpower", "wind_speed");
});
return result;
}
| 28.995354 | 141 | 0.779852 | nickdiorio |
87ab8ec991ad3bfaf9c59a402180820e98d05ecc | 5,853 | hpp | C++ | Include/FishEngine/Serialization/CloneArchive.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | 1 | 2018-12-20T02:38:44.000Z | 2018-12-20T02:38:44.000Z | Include/FishEngine/Serialization/CloneArchive.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | null | null | null | Include/FishEngine/Serialization/CloneArchive.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | 1 | 2018-10-25T19:40:22.000Z | 2018-10-25T19:40:22.000Z | #pragma once
#include <FishEngine/Serialization/Archive.hpp>
#include <set>
#include <vector>
#include <FishEngine/Prefab.hpp>
namespace FishEngine
{
class CollectObjectsArchive : public OutputArchive
{
public:
void Collect(Object* obj)
{
if (obj->Is<Prefab>())
return;
this->SerializeObject(obj);
}
void CollectPrefab(Prefab* prefab)
{
prefab->Serialize(*this);
}
protected:
virtual void Serialize(short t) override {}
virtual void Serialize(unsigned short t) override {}
virtual void Serialize(int t) override {}
virtual void Serialize(unsigned int t) override {}
virtual void Serialize(long t) override {}
virtual void Serialize(unsigned long t) override {}
virtual void Serialize(long long t) override {}
virtual void Serialize(unsigned long long t) override {}
virtual void Serialize(float t) override {}
virtual void Serialize(double t) override {}
virtual void Serialize(bool t) override {}
virtual void Serialize(std::string const & t) override {}
virtual void SerializeNullPtr() override {} // nullptr
void SerializeObject(Object* t) override
{
auto it = m_Objects.find(t);
if (it == m_Objects.end())
{
m_Objects.insert(t);
t->Serialize(*this);
}
}
void MapKey(const char* name) override {}
public:
std::set<Object*> m_Objects;
};
class CloneOutputArchive : public OutputArchive
{
public:
void AssertEmpty()
{
assert(m_IntValues.empty());
assert(m_UIntValues.empty());
assert(m_FloatValues.empty());
assert(m_StringValues.empty());
assert(m_ObjectValues.empty());
assert(m_MapKeys.empty());
}
protected:
virtual void Serialize(short t) override { m_IntValues.push_back(t); }
virtual void Serialize(unsigned short t) override { m_UIntValues.push_back(t); }
virtual void Serialize(int t) override { m_IntValues.push_back(t); }
virtual void Serialize(unsigned int t) override { m_UIntValues.push_back(t); }
virtual void Serialize(long t) override { m_IntValues.push_back(t); }
virtual void Serialize(unsigned long t) override { m_UIntValues.push_back(t); }
virtual void Serialize(long long t) override { m_IntValues.push_back(t); }
virtual void Serialize(unsigned long long t) override { m_UIntValues.push_back(t); }
virtual void Serialize(float t) override { m_FloatValues.push_back(t); }
virtual void Serialize(double t) override { m_FloatValues.push_back(t); }
virtual void Serialize(bool t) override { m_IntValues.push_back(t ? 1 : 0); }
virtual void Serialize(std::string const & t) override { m_StringValues.push_back(t); }
virtual void SerializeNullPtr() override { m_ObjectValues.push_back(nullptr); } // nullptr
virtual void SerializeObject(Object* t) override { m_ObjectValues.push_back(t); };
void MapKey(const char* name) override
{
m_MapKeys.push_back(name);
}
//// Map
//virtual void AfterValue() {}
//// Sequence
virtual void BeginSequence(int size) override
{
m_SequenceSize.push_back(size);
}
//virtual void BeforeSequenceItem() {}
//virtual void AfterSequenceItem() {}
//virtual void EndSequence() {}
public:
std::deque<int64_t> m_IntValues;
std::deque<uint64_t> m_UIntValues;
std::deque<double> m_FloatValues;
std::deque<std::string> m_StringValues;
std::deque<Object*> m_ObjectValues;
std::deque<const char*> m_MapKeys;
std::deque<int> m_SequenceSize;
};
class CloneInputArchive : public InputArchive
{
public:
CloneOutputArchive & values;
std::map<Object*, Object*> & objectMemo;
CloneInputArchive(CloneOutputArchive& values, std::map<Object*, Object*>& objectMemo)
: values(values), objectMemo(objectMemo)
{
}
protected:
virtual void Deserialize(short & t) override { t = values.m_IntValues.front(); values.m_IntValues.pop_front(); }
virtual void Deserialize(unsigned short & t) override { t = values.m_UIntValues.front(); values.m_UIntValues.pop_front(); }
virtual void Deserialize(int & t) override { t = values.m_IntValues.front(); values.m_IntValues.pop_front(); }
virtual void Deserialize(unsigned int & t) override { t = values.m_UIntValues.front(); values.m_UIntValues.pop_front(); }
virtual void Deserialize(long & t) override { t = values.m_IntValues.front(); values.m_IntValues.pop_front(); }
virtual void Deserialize(unsigned long & t) override { t = values.m_UIntValues.front(); values.m_UIntValues.pop_front(); }
virtual void Deserialize(long long & t) override { t = values.m_IntValues.front(); values.m_IntValues.pop_front(); }
virtual void Deserialize(unsigned long long & t) override { t = values.m_UIntValues.front(); values.m_UIntValues.pop_front(); }
virtual void Deserialize(float & t) override { t = values.m_FloatValues.front(); values.m_FloatValues.pop_front(); }
virtual void Deserialize(double & t) override { t = values.m_FloatValues.front(); values.m_FloatValues.pop_front(); }
virtual void Deserialize(bool & t) override { t = values.m_IntValues.front(); values.m_IntValues.pop_front(); }
virtual void Deserialize(std::string & t) override { t = values.m_StringValues.front(); values.m_StringValues.pop_front(); }
virtual Object* DeserializeObject() override
{
auto obj = values.m_ObjectValues.front();
values.m_ObjectValues.pop_front();
if (obj != nullptr)
{
obj = this->objectMemo[obj];
}
return obj;
}
// Map
virtual bool MapKey(const char* name) override {
assert(values.m_MapKeys.front() == std::string(name));
values.m_MapKeys.pop_front();
return true;
}
virtual void AfterValue() override {}
// Sequence
virtual int BeginSequence() override {
int size = values.m_SequenceSize.front();
values.m_SequenceSize.pop_front();
return size;
}
virtual void BeginSequenceItem() override {}
virtual void AfterSequenceItem() override {}
virtual void EndSequence() override {}
};
}
| 34.429412 | 129 | 0.718606 | yushroom |
87b089091f45aaf7a85fa23dfb980553b5aeff5b | 1,138 | cpp | C++ | UVA/10189.cpp | DT3264/ProgrammingContestsSolutions | a297f2da654c2ca2815b9aa375c2b4ca0052269d | [
"MIT"
] | null | null | null | UVA/10189.cpp | DT3264/ProgrammingContestsSolutions | a297f2da654c2ca2815b9aa375c2b4ca0052269d | [
"MIT"
] | null | null | null | UVA/10189.cpp | DT3264/ProgrammingContestsSolutions | a297f2da654c2ca2815b9aa375c2b4ca0052269d | [
"MIT"
] | null | null | null | #include<stdio.h>
int x, y;
int i, j;
char t;
char arr[100][100];
int prob[100][100];
void mine(){
if(i-1>=0 && j-1>=0) prob[i-1][j-1]++;
if(i-1>=0) prob[i-1][j]++;
if(i-1>=0 && j+1<y) prob[i-1][j+1]++;
///
if(j-1>=0) prob[i][j-1]++;
if(j+1<y) prob[i][j+1]++;
///
if(i+1<x && j-1>=0) prob[i+1][j-1]++;
if(i+1<x) prob[i+1][j]++;
if(i+1<x && j+1<y) prob[i+1][j+1]++;
}
void printPath(){
int i, j;
for(i=0; i<x; i++){
for(j=0; j<y; j++){
if(arr[i][j]=='*') printf("*");
else printf("%d", prob[i][j]);
}
printf("\n");
}
}
int main(){
int cont=1;
while(scanf("%d %d", &x, &y) && x!=0 && y!=0){
if(cont>1) printf("\n");
for(i=0; i<x; i++){
for(j=0; j<y; j++){
prob[i][j]=0;
}
}
printf("Field #%d:\n", cont++);
for(i=0; i<x; i++){
for(j=0; j<y; j++){
scanf(" %c", &arr[i][j]);
if(arr[i][j]=='*'){
mine();
}
}
}
printPath();
}
return 0;
}
| 21.074074 | 50 | 0.339192 | DT3264 |
87b235e46241c19f5544be53b2589737713ffef8 | 1,403 | cpp | C++ | friend.cpp | OmairK/OOP_LAB | 2cf73a7764529a68e210f2f8c9b65c441577a670 | [
"MIT"
] | null | null | null | friend.cpp | OmairK/OOP_LAB | 2cf73a7764529a68e210f2f8c9b65c441577a670 | [
"MIT"
] | null | null | null | friend.cpp | OmairK/OOP_LAB | 2cf73a7764529a68e210f2f8c9b65c441577a670 | [
"MIT"
] | null | null | null | #include <iostream>
#include <fstream>
using namespace std;
void readName(string filename){
ifstream file;
file.open(filename, ios::in);
string line;
if (file.is_open())
{
while (getline(file, line))
{
cout << line << endl;
}
}
file.close();
}
class Box{
public:
float length,breadth,height;
Box(){}
Box(float l,float b,float h):length(l),breadth(b),height(h){}
friend double Volume(Box box);
friend double SurfaceArea(Box box);
inline void display();
};
inline void Box::display(){
cout<<"\n Dimensions \n Height: "<<height<<"\n Length: "<<length<<"\n Breadth: "<<breadth<<endl;
}
double volume(Box box){
return(box.length*box.height*box.breadth);
}
double surfaceArea(Box box){
return(2*(box.length*box.height + box.breadth*box.height + box.length*box.breadth));
}
int main(){
float len,bre,hei;
cout<<"Enter the dimensions of the box"<<endl;
cout<<"Enter the length"<<endl;
cin>>len;
cout<<"Enter the breadth"<<endl;
cin>>bre;
cout<<"Enter the height"<<endl;
cin>>hei;
Box box = Box(len,bre,hei);
box.display();
cout<<"The surface area is "<<surfaceArea(box)<<endl;
cout<<"The volume is "<<volume(box)<<endl;
readName("name.txt");
return 1;
} | 21.257576 | 118 | 0.568068 | OmairK |
87b455f92a2a238c2f2a245f15e6126c6553e68b | 18,473 | cpp | C++ | LibCarla/source/carla/trafficmanager/CollisionStage.cpp | pirate-lofy/carla | b46117685e2e037dd6c0e6246998e5988bdc2bfb | [
"MIT"
] | 1 | 2019-12-17T12:28:57.000Z | 2019-12-17T12:28:57.000Z | LibCarla/source/carla/trafficmanager/CollisionStage.cpp | Tarfand123/carla | b46117685e2e037dd6c0e6246998e5988bdc2bfb | [
"MIT"
] | null | null | null | LibCarla/source/carla/trafficmanager/CollisionStage.cpp | Tarfand123/carla | b46117685e2e037dd6c0e6246998e5988bdc2bfb | [
"MIT"
] | null | null | null | // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "CollisionStage.h"
namespace carla {
namespace traffic_manager {
namespace CollisionStageConstants {
static const float VERTICAL_OVERLAP_THRESHOLD = 2.0f;
static const float BOUNDARY_EXTENSION_MINIMUM = 2.0f;
static const float EXTENSION_SQUARE_POINT = 7.5f;
static const float TIME_HORIZON = 0.5f;
static const float HIGHWAY_SPEED = 50.0f / 3.6f;
static const float HIGHWAY_TIME_HORIZON = 5.0f;
static const float CRAWL_SPEED = 10.0f / 3.6f;
static const float BOUNDARY_EDGE_LENGTH = 2.0f;
static const float MAX_COLLISION_RADIUS = 100.0f;
} // namespace CollisionStageConstants
using namespace CollisionStageConstants;
CollisionStage::CollisionStage(
std::string stage_name,
std::shared_ptr<LocalizationToCollisionMessenger> localization_messenger,
std::shared_ptr<CollisionToPlannerMessenger> planner_messenger,
cc::World &world,
Parameters ¶meters,
cc::DebugHelper &debug_helper)
: PipelineStage(stage_name),
localization_messenger(localization_messenger),
planner_messenger(planner_messenger),
world(world),
parameters(parameters),
debug_helper(debug_helper){
// Initializing clock for checking unregistered actors periodically.
last_world_actors_pass_instance = chr::system_clock::now();
// Initializing output array selector.
frame_selector = true;
// Initializing messenger states.
localization_messenger_state = localization_messenger->GetState();
// Initializing this messenger to preemptively write since it precedes
// motion planner stage.
planner_messenger_state = planner_messenger->GetState() - 1;
// Initializing the number of vehicles to zero in the beginning.
number_of_vehicles = 0u;
}
CollisionStage::~CollisionStage() {}
void CollisionStage::Action() {
const auto current_planner_frame = frame_selector ? planner_frame_a : planner_frame_b;
// Handle vehicles not spawned by TrafficManager.
const auto current_time = chr::system_clock::now();
const chr::duration<double> diff = current_time - last_world_actors_pass_instance;
// Periodically check for actors not spawned by TrafficManager.
if (diff.count() > 1.0f) {
const auto world_actors = world.GetActors()->Filter("vehicle.*");
const auto world_walker = world.GetActors()->Filter("walker.*");
// Scanning for vehicles.
for (auto actor: *world_actors.get()) {
const auto unregistered_id = actor->GetId();
if (vehicle_id_to_index.find(unregistered_id) == vehicle_id_to_index.end() &&
unregistered_actors.find(unregistered_id) == unregistered_actors.end()) {
unregistered_actors.insert({unregistered_id, actor});
}
}
// Scanning for pedestrians.
for (auto walker: *world_walker.get()) {
const auto unregistered_id = walker->GetId();
if (unregistered_actors.find(unregistered_id) == unregistered_actors.end()) {
unregistered_actors.insert({unregistered_id, walker});
}
}
// Regularly update unregistered actors.
std::vector<ActorId> actor_ids_to_erase;
for (auto actor_info: unregistered_actors) {
if (actor_info.second->IsAlive()) {
vicinity_grid.UpdateGrid(actor_info.second);
} else {
vicinity_grid.EraseActor(actor_info.first);
actor_ids_to_erase.push_back(actor_info.first);
}
}
for (auto actor_id: actor_ids_to_erase) {
unregistered_actors.erase(actor_id);
}
last_world_actors_pass_instance = current_time;
}
// Looping over registered actors.
for (uint64_t i = 0u; i < number_of_vehicles; ++i) {
const LocalizationToCollisionData &data = localization_frame->at(i);
const Actor ego_actor = data.actor;
const ActorId ego_actor_id = ego_actor->GetId();
// Retrieve actors around the path of the ego vehicle.
std::unordered_set<ActorId> actor_id_list = GetPotentialVehicleObstacles(ego_actor);
bool collision_hazard = false;
// Generate number between 0 and 100
const int r = rand() % 101;
// Continue only if random number is lower than our %, default is 0.
if (parameters.GetPercentageIgnoreActors(boost::shared_ptr<cc::Actor>(ego_actor)) <= r) {
// Check every actor in the vicinity if it poses a collision hazard.
for (auto j = actor_id_list.begin(); (j != actor_id_list.end()) && !collision_hazard; ++j) {
const ActorId actor_id = *j;
try {
Actor actor = nullptr;
if (vehicle_id_to_index.find(actor_id) != vehicle_id_to_index.end()) {
actor = localization_frame->at(vehicle_id_to_index.at(actor_id)).actor;
} else if (unregistered_actors.find(actor_id) != unregistered_actors.end()) {
actor = unregistered_actors.at(actor_id);
}
const cg::Location ego_location = ego_actor->GetLocation();
const cg::Location other_location = actor->GetLocation();
if (actor_id != ego_actor_id &&
(cg::Math::DistanceSquared(ego_location, other_location)
< std::pow(MAX_COLLISION_RADIUS, 2)) &&
(std::abs(ego_location.z - other_location.z) < VERTICAL_OVERLAP_THRESHOLD)) {
if (parameters.GetCollisionDetection(ego_actor, actor) &&
NegotiateCollision(ego_actor, actor)) {
collision_hazard = true;
}
}
} catch (const std::exception &e) {
carla::log_warning("Encountered problem while determining collision \n");
carla::log_info("Actor might not be alive \n");
}
}
}
CollisionToPlannerData &message = current_planner_frame->at(i);
message.hazard = collision_hazard;
}
}
void CollisionStage::DataReceiver() {
const auto packet = localization_messenger->ReceiveData(localization_messenger_state);
localization_frame = packet.data;
localization_messenger_state = packet.id;
if (localization_frame != nullptr) {
// Connecting actor ids to their position indices on data arrays.
// This map also provides us the additional benefit of being able to
// quickly identify
// if a vehicle id is registered with the traffic manager or not.
uint64_t index = 0u;
for (auto &element: *localization_frame.get()) {
vehicle_id_to_index.insert({element.actor->GetId(), index++});
}
// Allocating new containers for the changed number of registered
// vehicles.
if (number_of_vehicles != (*localization_frame.get()).size()) {
number_of_vehicles = static_cast<uint>((*localization_frame.get()).size());
// Allocating output arrays to be shared with motion planner stage.
planner_frame_a = std::make_shared<CollisionToPlannerFrame>(number_of_vehicles);
planner_frame_b = std::make_shared<CollisionToPlannerFrame>(number_of_vehicles);
}
}
}
void CollisionStage::DataSender() {
const DataPacket<std::shared_ptr<CollisionToPlannerFrame>> packet{
planner_messenger_state,
frame_selector ? planner_frame_a : planner_frame_b
};
frame_selector = !frame_selector;
planner_messenger_state = planner_messenger->SendData(packet);
}
bool CollisionStage::NegotiateCollision(const Actor &reference_vehicle, const Actor &other_vehicle) const {
bool hazard = false;
auto& data_packet = localization_frame->at(vehicle_id_to_index.at(reference_vehicle->GetId()));
Buffer& waypoint_buffer = data_packet.buffer;
auto& other_packet = localization_frame->at(vehicle_id_to_index.at(other_vehicle->GetId()));
Buffer& other_buffer = other_packet.buffer;
const cg::Location reference_location = reference_vehicle->GetLocation();
const cg::Location other_location = other_vehicle->GetLocation();
const cg::Vector3D reference_heading = reference_vehicle->GetTransform().GetForwardVector();
cg::Vector3D reference_to_other = other_location - reference_location;
reference_to_other = reference_to_other.MakeUnitVector();
const auto reference_vehicle_ptr = boost::static_pointer_cast<cc::Vehicle>(reference_vehicle);
const auto other_vehicle_ptr = boost::static_pointer_cast<cc::Vehicle>(other_vehicle);
if (waypoint_buffer.front()->CheckJunction() &&
other_buffer.front()->CheckJunction()) {
const Polygon reference_geodesic_polygon = GetPolygon(GetGeodesicBoundary(reference_vehicle));
const Polygon other_geodesic_polygon = GetPolygon(GetGeodesicBoundary(other_vehicle));
const Polygon reference_polygon = GetPolygon(GetBoundary(reference_vehicle));
const Polygon other_polygon = GetPolygon(GetBoundary(other_vehicle));
const double reference_vehicle_to_other_geodesic = bg::distance(reference_polygon, other_geodesic_polygon);
const double other_vehicle_to_reference_geodesic = bg::distance(other_polygon, reference_geodesic_polygon);
const auto inter_geodesic_distance = bg::distance(reference_geodesic_polygon, other_geodesic_polygon);
const auto inter_bbox_distance = bg::distance(reference_polygon, other_polygon);
const cg::Vector3D other_heading = other_vehicle->GetTransform().GetForwardVector();
cg::Vector3D other_to_reference = reference_vehicle->GetLocation() - other_vehicle->GetLocation();
other_to_reference = other_to_reference.MakeUnitVector();
// Whichever vehicle's path is farthest away from the other vehicle gets
// priority to move.
if (inter_geodesic_distance < 0.1 &&
((
inter_bbox_distance > 0.1 &&
reference_vehicle_to_other_geodesic > other_vehicle_to_reference_geodesic
) || (
inter_bbox_distance < 0.1 &&
cg::Math::Dot(reference_heading, reference_to_other) > cg::Math::Dot(other_heading, other_to_reference)
)) ) {
hazard = true;
}
} else if (!waypoint_buffer.front()->CheckJunction()) {
const float reference_vehicle_length = reference_vehicle_ptr->GetBoundingBox().extent.x;
const float other_vehicle_length = other_vehicle_ptr->GetBoundingBox().extent.x;
const float vehicle_length_sum = reference_vehicle_length + other_vehicle_length;
const float bbox_extension_length = GetBoundingBoxExtention(reference_vehicle);
if ((cg::Math::Dot(reference_heading, reference_to_other) > 0.0f) &&
(cg::Math::DistanceSquared(reference_location, other_location) <
std::pow(bbox_extension_length+vehicle_length_sum, 2))) {
hazard = true;
}
}
return hazard;
}
traffic_manager::Polygon CollisionStage::GetPolygon(const LocationList &boundary) const {
std::string boundary_polygon_wkt;
for (const cg::Location &location: boundary) {
boundary_polygon_wkt += std::to_string(location.x) + " " + std::to_string(location.y) + ",";
}
boundary_polygon_wkt += std::to_string(boundary[0].x) + " " + std::to_string(boundary[0].y);
traffic_manager::Polygon boundary_polygon;
bg::read_wkt("POLYGON((" + boundary_polygon_wkt + "))", boundary_polygon);
return boundary_polygon;
}
LocationList CollisionStage::GetGeodesicBoundary(const Actor &actor) const {
const LocationList bbox = GetBoundary(actor);
if (vehicle_id_to_index.find(actor->GetId()) != vehicle_id_to_index.end()) {
const cg::Location vehicle_location = actor->GetLocation();
float bbox_extension = GetBoundingBoxExtention(actor);
const float specific_distance_margin = parameters.GetDistanceToLeadingVehicle(actor);
if (specific_distance_margin > 0.0f) {
bbox_extension = std::max(specific_distance_margin, bbox_extension);
}
const auto &waypoint_buffer = localization_frame->at(vehicle_id_to_index.at(actor->GetId())).buffer;
LocationList left_boundary;
LocationList right_boundary;
const auto vehicle = boost::static_pointer_cast<cc::Vehicle>(actor);
const float width = vehicle->GetBoundingBox().extent.y;
const float length = vehicle->GetBoundingBox().extent.x;
SimpleWaypointPtr boundary_start = waypoint_buffer.front();
uint64_t boundary_start_index = 0u;
while (boundary_start->DistanceSquared(vehicle_location) < std::pow(length, 2) &&
boundary_start_index < waypoint_buffer.size() -1) {
boundary_start = waypoint_buffer.at(boundary_start_index);
++boundary_start_index;
}
SimpleWaypointPtr boundary_end = nullptr;
SimpleWaypointPtr current_point = waypoint_buffer.at(boundary_start_index);
const auto vehicle_reference = boost::static_pointer_cast<cc::Vehicle>(actor);
// At non-signalized junctions, we extend the boundary across the junction
// and in all other situations, boundary length is velocity-dependent.
bool reached_distance = false;
for (uint64_t j = boundary_start_index; !reached_distance && (j < waypoint_buffer.size()); ++j) {
if (boundary_start->DistanceSquared(current_point) > std::pow(bbox_extension, 2)) {
reached_distance = true;
}
if (boundary_end == nullptr ||
boundary_end->DistanceSquared(current_point) > std::pow(BOUNDARY_EDGE_LENGTH, 2) ||
reached_distance) {
const cg::Vector3D heading_vector = current_point->GetForwardVector();
const cg::Location location = current_point->GetLocation();
cg::Vector3D perpendicular_vector = cg::Vector3D(-heading_vector.y, heading_vector.x, 0.0f);
perpendicular_vector = perpendicular_vector.MakeUnitVector();
// Direction determined for the left-handed system.
const cg::Vector3D scaled_perpendicular = perpendicular_vector * width;
left_boundary.push_back(location + cg::Location(scaled_perpendicular));
right_boundary.push_back(location + cg::Location(-1.0f * scaled_perpendicular));
boundary_end = current_point;
}
current_point = waypoint_buffer.at(j);
}
// Connecting the geodesic path boundary with the vehicle bounding box.
LocationList geodesic_boundary;
// Reversing right boundary to construct clockwise (left-hand system)
// boundary. This is so because both left and right boundary vectors have
// the closest point to the vehicle at their starting index for the right
// boundary,
// we want to begin at the farthest point to have a clockwise trace.
std::reverse(right_boundary.begin(), right_boundary.end());
geodesic_boundary.insert(geodesic_boundary.end(), right_boundary.begin(), right_boundary.end());
geodesic_boundary.insert(geodesic_boundary.end(), bbox.begin(), bbox.end());
geodesic_boundary.insert(geodesic_boundary.end(), left_boundary.begin(), left_boundary.end());
return geodesic_boundary;
} else {
return bbox;
}
}
float CollisionStage::GetBoundingBoxExtention(const Actor &actor) const {
const float velocity = actor->GetVelocity().Length();
float bbox_extension = BOUNDARY_EXTENSION_MINIMUM;
if (velocity > HIGHWAY_SPEED) {
bbox_extension = HIGHWAY_TIME_HORIZON * velocity;
} else if (velocity < CRAWL_SPEED) {
bbox_extension = BOUNDARY_EXTENSION_MINIMUM;
} else {
bbox_extension = std::sqrt(
EXTENSION_SQUARE_POINT * velocity) +
velocity * TIME_HORIZON +
BOUNDARY_EXTENSION_MINIMUM;
}
return bbox_extension;
}
std::unordered_set<ActorId> CollisionStage::GetPotentialVehicleObstacles(const Actor &ego_vehicle) {
vicinity_grid.UpdateGrid(ego_vehicle);
const auto& data_packet = localization_frame->at(vehicle_id_to_index.at(ego_vehicle->GetId()));
const Buffer &waypoint_buffer = data_packet.buffer;
const float velocity = ego_vehicle->GetVelocity().Length();
std::unordered_set<ActorId> actor_id_list = data_packet.overlapping_actors;
if (waypoint_buffer.front()->CheckJunction() && velocity < HIGHWAY_SPEED) {
actor_id_list = vicinity_grid.GetActors(ego_vehicle);
} else {
actor_id_list = data_packet.overlapping_actors;
}
return actor_id_list;
}
LocationList CollisionStage::GetBoundary(const Actor &actor) const {
const auto actor_type = actor->GetTypeId();
cg::BoundingBox bbox;
cg::Location location;
cg::Vector3D heading_vector;
if (actor_type[0] == 'v') {
const auto vehicle = boost::static_pointer_cast<cc::Vehicle>(actor);
bbox = vehicle->GetBoundingBox();
location = vehicle->GetLocation();
heading_vector = vehicle->GetTransform().GetForwardVector();
} else if (actor_type[0] == 'w') {
const auto walker = boost::static_pointer_cast<cc::Walker>(actor);
bbox = walker->GetBoundingBox();
location = walker->GetLocation();
heading_vector = walker->GetTransform().GetForwardVector();
}
const cg::Vector3D extent = bbox.extent;
heading_vector.z = 0.0f;
const cg::Vector3D perpendicular_vector = cg::Vector3D(-heading_vector.y, heading_vector.x, 0.0f);
// Four corners of the vehicle in top view clockwise order (left-handed
// system).
const cg::Vector3D x_boundary_vector = heading_vector * extent.x;
const cg::Vector3D y_boundary_vector = perpendicular_vector * extent.y;
return {
location + cg::Location(x_boundary_vector - y_boundary_vector),
location + cg::Location(-1.0f * x_boundary_vector - y_boundary_vector),
location + cg::Location(-1.0f * x_boundary_vector + y_boundary_vector),
location + cg::Location(x_boundary_vector + y_boundary_vector),
};
}
void CollisionStage::DrawBoundary(const LocationList &boundary) const {
for (uint64_t i = 0u; i < boundary.size(); ++i) {
debug_helper.DrawLine(
boundary[i] + cg::Location(0.0f, 0.0f, 1.0f),
boundary[(i + 1) % boundary.size()] + cg::Location(0.0f, 0.0f, 1.0f),
0.1f, {255u, 0u, 0u}, 0.1f);
}
}
} // namespace traffic_manager
} // namespace carla
| 41.419283 | 115 | 0.69469 | pirate-lofy |
87b4ac8c46deb92a0c290e44da493eee0e0aee0d | 2,633 | hpp | C++ | src/base/LifeCycleComponent.hpp | inexorgame/entity-system | 230a6f116fb02caeace79bc9b32f17fe08687c36 | [
"MIT"
] | 19 | 2018-10-11T09:19:48.000Z | 2020-04-19T16:36:58.000Z | src/base/LifeCycleComponent.hpp | inexorgame-obsolete/entity-system-inactive | 230a6f116fb02caeace79bc9b32f17fe08687c36 | [
"MIT"
] | 132 | 2018-07-28T12:30:54.000Z | 2020-04-25T23:05:33.000Z | src/base/LifeCycleComponent.hpp | inexorgame-obsolete/entity-system-inactive | 230a6f116fb02caeace79bc9b32f17fe08687c36 | [
"MIT"
] | 3 | 2019-03-02T16:19:23.000Z | 2020-02-18T05:15:29.000Z | #pragma once
#include <cstdint>
#include <memory>
#include <tuple>
#include <vector>
#include <boost/range/adaptor/reversed.hpp>
#include <spdlog/spdlog.h>
namespace inexor {
/**
* Derived classes profits from automatic initialization and destruction
* of the sub components.
*/
class LifeCycleComponent
{
protected:
/// @brief Constructor.
template <class... LifeCycleComponents>
LifeCycleComponent(LifeCycleComponents... _sub_components) : sub_components{_sub_components...} {};
/// @brief Destructor.
~LifeCycleComponent() = default;
public:
virtual void pre_init() {}
void pre_init_components()
{
// Pre-Initialize before sub components are constructed
pre_init();
spdlog::trace("Pre-Initializing {} sub components of {}", sub_components.size(), this->get_component_name());
for (const std::shared_ptr<LifeCycleComponent> &sub_component : sub_components)
{
sub_component->pre_init_components();
}
}
virtual void init() {}
void init_components()
{
// Initialize before sub components are constructed
init();
spdlog::trace("Initializing {} sub components of {}", sub_components.size(), this->get_component_name());
for (const std::shared_ptr<LifeCycleComponent> &sub_component : sub_components)
{
sub_component->init_components();
}
}
virtual void destroy() {}
void destroy_components()
{
spdlog::trace("Destroying {} sub components of {}", sub_components.size(), this->get_component_name());
// Destruction in reverse order
for (const std::shared_ptr<LifeCycleComponent> &sub_component : boost::adaptors::reverse(sub_components))
{
sub_component->destroy_components();
}
// Destruction after sub components are destructed
destroy();
}
virtual void post_destroy() {}
void post_destroy_components()
{
spdlog::trace("Post-Destroying {} sub components of {}", sub_components.size(), this->get_component_name());
// Destruction in reverse order
for (const std::shared_ptr<LifeCycleComponent> &sub_component : boost::adaptors::reverse(sub_components))
{
sub_component->post_destroy_components();
}
// Destruction after sub components are destructed
post_destroy();
}
virtual std::string get_component_name()
{
return typeid(this).name();
}
private:
std::vector<std::shared_ptr<LifeCycleComponent>> sub_components;
};
} // namespace inexor
| 28.010638 | 117 | 0.651348 | inexorgame |
87b4fff92f1e8214a275f1a0536a306b57c090b5 | 796 | cpp | C++ | Array/Move_Even_Odd_Numbers.cpp | susantabiswas/placementPrep | 22a7574206ddc63eba89517f7b68a3d2f4d467f5 | [
"MIT"
] | 19 | 2018-12-02T05:59:44.000Z | 2021-07-24T14:11:54.000Z | Array/Move_Even_Odd_Numbers.cpp | susantabiswas/placementPrep | 22a7574206ddc63eba89517f7b68a3d2f4d467f5 | [
"MIT"
] | null | null | null | Array/Move_Even_Odd_Numbers.cpp | susantabiswas/placementPrep | 22a7574206ddc63eba89517f7b68a3d2f4d467f5 | [
"MIT"
] | 13 | 2019-04-25T16:20:00.000Z | 2021-09-06T19:50:04.000Z | //given an array.Arrange the elements st even nos. are at the begining and
//the odd nos. are the end
#include<iostream>
#include<vector>
using namespace std;
//moves the even and odd nums
void moveEvenOddNums(vector<int> &arr){
int i = 0; //this is for keeping track of even numbers
int j = arr.size()-1; //for keeping track of odd numbers
int temp = 0 ;//for swapping
while(i<j){
//when the num. is odd,move it to the odd number position
if(arr[i]%2 != 0){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
--j;
}
else
++i;
}
}
//for displaying the numbers
void disp(vector<int> &arr){
for (int i = 0; i < arr.size(); ++i)
{
cout<<arr[i]<<" ";
}
}
int main(){
vector<int> arr = {12,33,14,12411,23,134,443,77};
moveEvenOddNums(arr);
disp(arr);
return 0;
}
| 20.410256 | 74 | 0.626884 | susantabiswas |
87b695cf0ca441f75eb5d6ab731d9e0eed4e9e06 | 3,886 | cc | C++ | src/audio/synthesizer.cc | stanford-stagecast/pancake | e9cfd547edf2dd797f324b159252757190211ff2 | [
"Apache-2.0"
] | 2 | 2022-01-05T08:58:11.000Z | 2022-01-06T05:33:14.000Z | src/audio/synthesizer.cc | stanford-stagecast/pancake | e9cfd547edf2dd797f324b159252757190211ff2 | [
"Apache-2.0"
] | null | null | null | src/audio/synthesizer.cc | stanford-stagecast/pancake | e9cfd547edf2dd797f324b159252757190211ff2 | [
"Apache-2.0"
] | null | null | null | #include "synthesizer.hh"
#include <cmath>
#include <iostream>
constexpr unsigned int NUM_KEYS = 88;
constexpr unsigned int KEY_OFFSET = 21;
constexpr unsigned int KEY_DOWN = 144;
constexpr unsigned int KEY_UP = 128;
constexpr unsigned int SUSTAIN = 176;
using namespace std;
Synthesizer::Synthesizer( const string& sample_directory )
: note_repo( sample_directory )
{
for ( size_t i = 0; i < NUM_KEYS; i++ ) {
keys.push_back( { {}, {} } );
}
}
void Synthesizer::process_new_data( uint8_t event_type, uint8_t event_note, uint8_t event_velocity )
{
if ( event_type == SUSTAIN ) {
// std::cerr << (size_t) midi_processor.get_event_type() << " " << (size_t) event_note << " " <<
// (size_t)event_velocity << "\n";
if ( event_velocity == 127 )
sustain_down = true;
else
sustain_down = false;
} else if ( event_type == KEY_DOWN || event_type == KEY_UP ) {
bool direction = event_type == KEY_DOWN ? true : false;
auto& k = keys.at( event_note - KEY_OFFSET );
if ( !direction ) {
k.releases.push_back( { 0, event_velocity, 1.0, false } );
k.presses.back().released = true;
} else {
k.presses.push_back( { 0, event_velocity, 1.0, false } );
}
}
}
wav_frame_t Synthesizer::calculate_curr_sample() const
{
std::pair<float, float> total_sample = { 0, 0 };
for ( size_t i = 0; i < NUM_KEYS; i++ ) {
auto& k = keys.at( i );
size_t active_presses = k.presses.size();
size_t active_releases = k.releases.size();
for ( size_t j = 0; j < active_presses; j++ ) {
// auto t1 = high_resolution_clock::now();
float amplitude_multiplier = k.presses.at( j ).vol_ratio * 0.2; /* to avoid clipping */
const std::pair<float, float> curr_sample
= note_repo.get_sample( true, i, k.presses.at( j ).velocity, k.presses.at( j ).offset );
total_sample.first += curr_sample.first * amplitude_multiplier;
total_sample.second += curr_sample.second * amplitude_multiplier;
// auto t2 = high_resolution_clock::now();
// if (frames_processed % 50000 == 0) std::cerr << "Time to get one key press sample: " << duration_cast<nanoseconds>(t2 - t1).count() << "\n";
}
for ( size_t j = 0; j < active_releases; j++ ) {
//auto t1 = high_resolution_clock::now();
float amplitude_multiplier = exp10( -37 / 20.0 ) * 0.2; /* to avoid clipping */
const std::pair<float, float> curr_sample
= note_repo.get_sample( false, i, k.releases.at( j ).velocity, k.releases.at( j ).offset );
total_sample.first += curr_sample.first * amplitude_multiplier;
total_sample.second += curr_sample.second * amplitude_multiplier;
//auto t2 = high_resolution_clock::now();
//if (frames_processed % 50000 == 0) std::cerr << "Time to get one key release sample: " << duration_cast<nanoseconds>(t2 - t1).count() << "\n";
}
}
return total_sample;
}
void Synthesizer::advance_sample()
{
frames_processed++;
for ( size_t i = 0; i < NUM_KEYS; i++ ) {
auto& k = keys.at( i );
size_t active_presses = k.presses.size();
size_t active_releases = k.releases.size();
for ( size_t j = 0; j < active_presses; j++ ) {
k.presses.at( j ).offset++;
if ( note_repo.note_finished( true, i, k.presses.at( j ).velocity, k.presses.at( j ).offset ) ) {
k.presses.erase( k.presses.begin() );
j--;
active_presses--;
} else if ( ( k.presses.at( j ).released && !sustain_down ) & ( k.presses.at( j ).vol_ratio > 0 ) ) {
k.presses.at( j ).vol_ratio -= 0.0001;
}
}
for ( size_t j = 0; j < active_releases; j++ ) {
k.releases.at( j ).offset++;
if ( note_repo.note_finished( false, i, k.releases.at( j ).velocity, k.releases.at( j ).offset ) ) {
k.releases.erase( k.releases.begin() );
j--;
active_releases--;
}
}
}
}
| 33.791304 | 150 | 0.617859 | stanford-stagecast |
87b8a0aa6812d30e13c12400662c46eea59acae6 | 3,018 | cpp | C++ | Frameworks/Starboard/dlfcn.cpp | Art52123103/WinObjC | 5672d1c99851b6125514381c39f4243692514b0b | [
"MIT"
] | null | null | null | Frameworks/Starboard/dlfcn.cpp | Art52123103/WinObjC | 5672d1c99851b6125514381c39f4243692514b0b | [
"MIT"
] | null | null | null | Frameworks/Starboard/dlfcn.cpp | Art52123103/WinObjC | 5672d1c99851b6125514381c39f4243692514b0b | [
"MIT"
] | null | null | null | //******************************************************************************
//
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// 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 <dlfcn.h>
#include <windows.h>
#include <memory>
#include <string>
#include <string.h>
/**
@Status Caveat
@Notes This function can only find libraries in the root of the current
package. The mode parameter is ignored. In addition, error information
is not available on failure.
*/
void* dlopen(const char* path, int mode) {
try {
// We can only load libraries from within our own package or any dependent
// packages, so absolute paths are not much use to us. From whatever path
// we're given, just strip off everything but the leaf file name and try
// to load that. This isn't always correct, but it is sometimes correct.
std::wstring widePath(path, path + strlen(path));
DWORD pathLength = GetFullPathNameW(widePath.c_str(), 0, nullptr, nullptr);
auto fullPath = std::make_unique<WCHAR[]>(pathLength);
LPWSTR fileName = nullptr;
GetFullPathNameW(widePath.c_str(), pathLength, fullPath.get(), &fileName);
return LoadPackagedLibrary(fileName, 0);
} catch (...) {
}
return NULL;
}
/**
@Status Caveat
@Notes Error information is not available on failure
*/
void* dlsym(void* handle, const char* symbol) {
HMODULE module = static_cast<HMODULE>(handle);
// This platform doesn't represent Objective-C class symbols in the same way as
// the reference platform, so some mapping of symbols is necessary
static const char OUR_CLASS_PREFIX[] = "_OBJC_CLASS_";
static const char THEIR_CLASS_PREFIX[] = "OBJC_CLASS_$_";
static const size_t THEIR_CLASS_PREFIX_LENGTH = sizeof(THEIR_CLASS_PREFIX) - 1;
try {
if (0 == strncmp(symbol, THEIR_CLASS_PREFIX, THEIR_CLASS_PREFIX_LENGTH)) {
std::string transformedSymbol(OUR_CLASS_PREFIX);
transformedSymbol.append(symbol + THEIR_CLASS_PREFIX_LENGTH);
return GetProcAddress(module, transformedSymbol.c_str());
}
} catch (...) {
return nullptr;
}
return GetProcAddress(module, symbol);
}
/**
@Status Caveat
@Notes Error information is not available on failure
*/
int dlclose(void* handle) {
HMODULE module = static_cast<HMODULE>(handle);
return !FreeLibrary(module);
}
| 34.295455 | 83 | 0.66004 | Art52123103 |
87bddd84c173926dd88f416cdc59985934e6e6da | 906 | cpp | C++ | test/logger_test.cpp | OpenWinch/OpenWinch-C | efbce8f0c892927560f6b719d347578c85babade | [
"Apache-2.0"
] | 1 | 2020-11-23T23:52:19.000Z | 2020-11-23T23:52:19.000Z | test/logger_test.cpp | OpenWinch/OpenWinch-C | efbce8f0c892927560f6b719d347578c85babade | [
"Apache-2.0"
] | 3 | 2020-11-24T22:00:01.000Z | 2021-02-23T22:32:31.000Z | test/logger_test.cpp | OpenWinch/OpenWinch-C | efbce8f0c892927560f6b719d347578c85babade | [
"Apache-2.0"
] | null | null | null | /**
* @file logger_test.cpp
* @author Mickael GAILLARD ([email protected])
* @brief OpenWinch Project
*
* @copyright Copyright © 2020-2021
*/
#include "logger.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
class LoggerTest : public ::testing::Test {
protected:
Logger *logger = nullptr;
LoggerTest() { }
~LoggerTest() override { }
void SetUp() override {
this->logger = &Logger::get();
}
void TearDown() override { }
};
TEST_F(LoggerTest, MethodLive) {
this->logger->live("Log live.");
}
TEST_F(LoggerTest, MethodInfo) {
this->logger->info("Log info.");
}
TEST_F(LoggerTest, MethodDebug) {
this->logger->debug("Log debug.");
}
TEST_F(LoggerTest, MethodWarning) {
this->logger->warning("Log warning.");
}
TEST_F(LoggerTest, MethodError) {
this->logger->error("Log error.");
}
TEST_F(LoggerTest, MethodFatal) {
this->logger->fatal("Log fatal.");
}
| 18.489796 | 53 | 0.664459 | OpenWinch |
87c3980da828df91b88b169e33fcd02054647039 | 1,061 | cpp | C++ | Stack/parenthesis_matching.cpp | ahanavish/DSA-using-CPP | cc96ae5cabef1dfa4ac183c1ea1510f74e3f42d9 | [
"MIT"
] | null | null | null | Stack/parenthesis_matching.cpp | ahanavish/DSA-using-CPP | cc96ae5cabef1dfa4ac183c1ea1510f74e3f42d9 | [
"MIT"
] | null | null | null | Stack/parenthesis_matching.cpp | ahanavish/DSA-using-CPP | cc96ae5cabef1dfa4ac183c1ea1510f74e3f42d9 | [
"MIT"
] | 1 | 2021-11-29T06:12:05.000Z | 2021-11-29T06:12:05.000Z | #include <iostream>
#include <string.h>
using namespace std;
class stack
{
int size;
int top;
char *sta;
char *str;
public:
stack(char *s)
{
str = s;
size = strlen(s);
top = -1;
sta = new char[size];
}
~stack()
{
delete []sta;
sta = 0;
}
bool balance()
{
int i=0;
while(str[i] != '\0')
{
if(str[i] == '(')
push(str[i]);
else if(str[i] == ')')
if(pop() == 0)
return false;
i++;
}
if(top == -1)
return true;
else
return false;
}
void push(int n)
{
top++;
sta[top] = n;
}
int pop()
{
if(top == -1)
return 0;
sta[top] = -10;
top--;
return 1;
}
};
int main()
{
char s[] = "(a+b)*(c/6)";
stack st(s);
if(st.balance() == true)
cout<<"-> Balanced";
else
cout<<"-> Not balanced";
} | 15.157143 | 34 | 0.356268 | ahanavish |
d7acb86feb64b28b4c6bd8012f4577137f0defb3 | 1,450 | hpp | C++ | test/timer/classes.hpp | smart-cloud/actor-zeta | 9597d6c21843a5e24a7998d09ff041d2f948cc63 | [
"BSD-3-Clause"
] | 20 | 2016-01-07T07:37:52.000Z | 2019-06-02T12:04:25.000Z | test/timer/classes.hpp | smart-cloud/actor-zeta | 9597d6c21843a5e24a7998d09ff041d2f948cc63 | [
"BSD-3-Clause"
] | 30 | 2017-03-10T14:47:46.000Z | 2019-05-09T19:23:25.000Z | test/timer/classes.hpp | jinncrafters/actor-zeta | 9597d6c21843a5e24a7998d09ff041d2f948cc63 | [
"BSD-3-Clause"
] | 6 | 2017-03-10T14:06:01.000Z | 2018-08-13T18:19:37.000Z | #pragma once
#include <cassert>
#include <chrono>
#include <memory>
#include <vector>
#include <actor-zeta.hpp>
#include <actor-zeta/detail/memory_resource.hpp>
#include "tooltestsuites/scheduler_test.hpp"
#include "tooltestsuites/clock_test.hpp"
static std::atomic<uint64_t> alarm_counter{0};
using actor_zeta::detail::pmr::memory_resource;
/// non thread safe
constexpr static auto alarm_id = actor_zeta::make_message_id(0);
class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervisor_lite> {
public:
explicit supervisor_lite(memory_resource* ptr)
: cooperative_supervisor(ptr, "network")
, executor_(new actor_zeta::test::scheduler_test_t(1, 1)) {
add_handler(alarm_id, &supervisor_lite::alarm);
scheduler()->start();
}
auto clock() noexcept -> actor_zeta::test::clock_test& {
return executor_->clock();
}
~supervisor_lite() override = default;
void alarm() {
alarm_counter += 1;
}
protected:
auto scheduler_impl() noexcept -> actor_zeta::scheduler_abstract_t* final { return executor_.get(); }
auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
{
set_current_message(std::move(msg));
execute(this, current_message());
}
}
private:
std::unique_ptr<actor_zeta::test::scheduler_test_t> executor_;
std::vector<actor_zeta::actor> actors_;
}; | 29 | 105 | 0.696552 | smart-cloud |
d7afdb497afd4db9747e33ac791f78e58c0dcd1b | 77,409 | cpp | C++ | test_apps/STM32Cube_FW_F4_V1.24.0/Projects/STM32469I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CarouselMenu/st_menu_button_pressed.cpp | hwiwonl/ACES | 9b9a6766a177c531384b863854459a7e016dbdcc | [
"NCSA"
] | null | null | null | test_apps/STM32Cube_FW_F4_V1.24.0/Projects/STM32469I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CarouselMenu/st_menu_button_pressed.cpp | hwiwonl/ACES | 9b9a6766a177c531384b863854459a7e016dbdcc | [
"NCSA"
] | null | null | null | test_apps/STM32Cube_FW_F4_V1.24.0/Projects/STM32469I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CarouselMenu/st_menu_button_pressed.cpp | hwiwonl/ACES | 9b9a6766a177c531384b863854459a7e016dbdcc | [
"NCSA"
] | null | null | null | // Generated by imageconverter. Please, do not edit!
#include <touchgfx/hal/Config.hpp>
LOCATION_EXTFLASH_PRAGMA
KEEP extern const unsigned char _st_menu_button_pressed[] LOCATION_EXTFLASH_ATTRIBUTE = { // 62x62 ARGB8888 pixels.
0x18,0x0c,0x00,0x00,0x18,0x0c,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x0c,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x20,0x10,0x00,0x00,0x20,0x14,0x00,0x00,0x18,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,
0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,
0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x20,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0x18,0x0c,0x00,0x00,0x18,0x10,0x00,0x00,
0x18,0x0c,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x18,0x10,0x00,0x00,0x20,0x10,0x00,0x00,0x20,0x14,0x00,0x00,0x18,0x10,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,
0x28,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x08,0x28,0x1c,0x00,0x24,0x28,0x1c,0x00,0x3c,0x28,0x1c,0x00,0x55,0x28,0x1c,0x00,0x65,0x28,0x1c,0x00,0x71,0x28,0x1c,0x00,0x79,0x28,0x20,0x00,0x82,0x28,0x1c,0x00,0x82,0x28,0x1c,0x00,0x79,0x28,0x1c,0x00,0x71,
0x28,0x1c,0x00,0x65,0x28,0x1c,0x00,0x55,0x28,0x1c,0x00,0x3c,0x28,0x1c,0x00,0x24,0x28,0x1c,0x00,0x08,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0x18,0x10,0x00,0x00,0x18,0x0c,0x00,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0x28,0x1c,0x00,0x0c,0x28,0x1c,0x00,0x38,0x28,0x20,0x00,0x65,0x28,0x20,0x00,0x7d,0x28,0x20,0x00,0x82,0x28,0x20,0x00,0x82,0x28,0x20,0x00,0x82,0x30,0x20,0x00,0x82,0x30,0x20,0x00,0x7d,0x30,0x20,0x00,0x82,0x30,0x20,0x00,0x82,0x30,0x20,0x00,0x7d,0x30,0x20,0x00,0x82,0x28,0x20,0x00,0x82,0x30,0x20,0x00,0x82,0x28,0x20,0x00,0x82,
0x28,0x20,0x00,0x82,0x28,0x20,0x00,0x82,0x28,0x20,0x00,0x7d,0x28,0x20,0x00,0x61,0x28,0x1c,0x00,0x38,0x28,0x1c,0x00,0x10,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0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0x38,0x28,0x00,0x7d,0x30,0x24,0x00,0x08,0xf8,0xfc,0xf8,0x00,
0x30,0x20,0x00,0x00,0x48,0x3c,0x18,0x28,0x30,0x28,0x00,0x82,0x78,0x70,0x50,0x96,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xd0,0xcc,0xb8,0xc7,0x60,0x4c,0x08,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,
0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x54,0x10,0x82,0x90,0x80,0x50,0x96,0xd0,0xd0,0xb8,0xcb,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0x78,0x70,0x50,0x9a,0x30,0x28,0x00,0x82,0x48,0x3c,0x20,0x28,0xf8,0xfc,0xf8,0x00,
0x30,0x20,0x00,0x00,0x58,0x50,0x38,0x4d,
0x38,0x28,0x00,0x82,0xb0,0xa8,0x98,0xb6,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xb0,0xa8,0x88,0xae,
0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x7d,0x60,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x4c,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,
0x58,0x4c,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0xb0,0xa4,0x80,0xaa,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xb0,0xac,0xa0,0xb6,0x38,0x28,0x00,0x82,0x58,0x50,0x30,0x4d,0xf8,0xfc,0xf8,0x00,
0x30,0x24,0x00,0x00,0x58,0x4c,0x30,0x65,0x38,0x28,0x00,0x82,0xd0,0xc8,0xc0,0xcb,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xb8,0xac,0x90,0xb2,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,
0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x60,0x4c,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,
0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0xd8,0xd0,0xc0,0xcb,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xd0,0xc8,0xc0,0xcb,0x38,0x28,0x00,0x7d,0x58,0x4c,0x28,0x65,0xf8,0xfc,0xf8,0x00,
0x30,0x24,0x00,0x00,0x50,0x44,0x20,0x75,0x38,0x2c,0x00,0x82,0xe0,0xe0,0xd8,0xdf,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xd0,0xcc,0xb8,0xcb,0x60,0x50,0x08,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,
0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x58,0x4c,0x00,0x82,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x60,0x4c,0x00,0x82,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x82,
0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,0x60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8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0x98,0x90,0x60,0x9e,
0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x82,0x58,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x4c,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x4c,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x60,0x4c,0x00,0x7d,
0x90,0x84,0x50,0x96,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0x80,0x74,0x58,0x9a,0x38,0x2c,0x00,0x82,0x98,0x94,0x80,0x49,0xf8,0xfc,0xf8,0x00,
0x30,0x24,0x00,0x00,0xd8,0xd4,0xc8,0x24,0x40,0x30,0x00,0x7d,0x40,0x34,0x08,0x82,0xf8,0xf8,0xf8,0xf7,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,
0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x4c,0x00,0x7d,0x60,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x82,0x58,0x48,0x00,0x82,0xd8,0xd0,0xc0,0xcb,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xf8,0xf8,0xf7,0x40,0x34,0x00,0x82,0x40,0x30,0x00,0x7d,
0xd0,0xd0,0xc8,0x24,0xf8,0xfc,0xf8,0x00,
0x30,0x24,0x00,0x00,0xf8,0xfc,0xf8,0x04,0x60,0x58,0x30,0x79,0x40,0x30,0x00,0x82,0xd8,0xd4,0xc8,0xd3,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0x58,0x48,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x82,0x60,0x4c,0x00,0x7d,0x58,0x48,0x00,0x7d,
0x60,0x48,0x00,0x82,0x58,0x4c,0x00,0x82,0x58,0x48,0x00,0x7d,0x60,0x48,0x00,0x82,0x58,0x4c,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x82,0x60,0x48,0x00,0x7d,0x58,0x4c,0x00,0x7d,0xb0,0xa4,0x80,0xaa,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,
0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xf8,0xfc,0xf8,0xff,0xd8,0xd4,0xc8,0xd3,0x40,0x30,0x00,0x82,0x60,0x54,0x30,0x79,0xf8,0xfc,0xf8,0x08,0xf8,0xfc,0xf8,0x00,
0x30,0x24,0x00,0x00,0x38,0x28,0x00,0x00,0x90,0x88,0x70,0x65,0x40,0x2c,0x00,0x82,0x98,0x90,0x78,0xa6,0xf8,0xfc,0xf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38,0x00,0x7d,0x48,0x38,0x00,0x82,0x48,0x38,0x00,0x7d,0x48,0x38,0x00,0x82,0x48,0x38,0x00,0x82,0x48,0x38,0x00,0x82,0x48,0x38,0x00,0x7d,0x48,0x38,0x00,0x82,0x48,0x38,0x00,0x82,
0x48,0x38,0x00,0x7d,0x68,0x5c,0x30,0x79,0xa0,0x98,0x80,0x75,0xe0,0xe4,0xd8,0x6d,0xf8,0xfc,0xf8,0x49,0xf8,0xfc,0xf8,0x18,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0x18,0x10,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x1c,0x00,0x00,
0x28,0x1c,0x00,0x00,0x28,0x20,0x00,0x00,0x30,0x20,0x00,0x00,0x30,0x20,0x00,0x00,0x30,0x24,0x00,0x00,0x30,0x24,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x40,0x30,0x00,0x00,0xf8,0xfc,0xf8,0x0c,0xf8,0xfc,0xf8,0x30,0xf8,0xfc,0xf8,0x51,0xf0,0xf0,0xf0,0x69,
0xc0,0xbc,0xb0,0x71,0x98,0x94,0x78,0x75,0x78,0x70,0x48,0x75,0x68,0x58,0x30,0x79,0x58,0x4c,0x18,0x7d,0x50,0x40,0x10,0x7d,0x48,0x38,0x00,0x7d,0x48,0x38,0x08,0x7d,0x50,0x40,0x10,0x7d,0x58,0x4c,0x18,0x7d,0x68,0x58,0x30,0x79,0x78,0x70,0x48,0x79,0x98,0x94,0x78,0x75,0xc0,0xbc,0xb0,0x71,0xf0,0xf0,0xe8,0x69,0xf8,0xfc,0xf8,0x51,
0xf8,0xfc,0xf8,0x30,0xf8,0xfc,0xf8,0x0c,0x40,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x28,0x00,0x00,0x30,0x28,0x00,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0x18,0x10,0x00,0x00,0x18,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x14,0x00,0x00,0x20,0x18,0x00,0x00,0x20,0x18,0x00,0x00,0x28,0x18,0x00,0x00,0x28,0x1c,0x00,0x00,0x28,0x1c,0x00,0x00,
0x28,0x1c,0x00,0x00,0x28,0x20,0x00,0x00,0x30,0x20,0x00,0x00,0x30,0x24,0x00,0x00,0x30,0x24,0x00,0x00,0x30,0x28,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x30,0x00,0x00,0x40,0x30,0x00,0x00,0xf8,0xfc,0xf8,0x08,0xf8,0xfc,0xf8,0x1c,0xf8,0xfc,0xf8,0x34,
0xf8,0xfc,0xf8,0x45,0xf8,0xfc,0xf8,0x55,0xf8,0xfc,0xf8,0x5d,0xf8,0xfc,0xf8,0x65,0xf8,0xfc,0xf8,0x69,0xf8,0xfc,0xf8,0x69,0xf8,0xfc,0xf8,0x61,0xf8,0xfc,0xf8,0x5d,0xf8,0xfc,0xf8,0x55,0xf8,0xfc,0xf8,0x45,0xf8,0xfc,0xf8,0x34,0xf8,0xfc,0xf8,0x1c,0xf8,0xfc,0xf8,0x08,0x40,0x30,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,
0x38,0x2c,0x00,0x00,0x38,0x2c,0x00,0x00,0x38,0x28,0x00,0x00,0x38,0x28,0x00,0x00,0x30,0x24,0x00,0x00,0x30,0x24,0x00,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,
0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00,0xf8,0xfc,0xf8,0x00
};
| 254.634868 | 320 | 0.796949 | hwiwonl |
d7b77646f63e6a8074b6bf09160e7b8297afa4d4 | 1,376 | cpp | C++ | src/semana-10/Range-Minimum-Query.cpp | RicardoLopes1/desafios-prog-2021-1 | 1e698f0696b5636fa5608d669dd58d170f8049ea | [
"MIT"
] | null | null | null | src/semana-10/Range-Minimum-Query.cpp | RicardoLopes1/desafios-prog-2021-1 | 1e698f0696b5636fa5608d669dd58d170f8049ea | [
"MIT"
] | null | null | null | src/semana-10/Range-Minimum-Query.cpp | RicardoLopes1/desafios-prog-2021-1 | 1e698f0696b5636fa5608d669dd58d170f8049ea | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
// https://practice.geeksforgeeks.org/problems/range-minimum-query/1/
// Range Minimum Query
// Not completed
class SegmentTree{
private:
int n, t[4*10000];
map <string, int> rmq;
public:
SegmentTree( int * arr, int sz){
n = sz;
build(arr, 1, 0, n-1);
}
void build( int * arr, int idx, int tl, int tr){
if( tl == tr ){
t[idx] = arr[tl];
}else{
int tm = (tl+tr)/2;
build(arr, idx << 1, tl, tm);
build(arr, idx << 1 | 1 , tm+1, tr);
t[idx] = min(t[idx << 1], t[idx << 1 | 1]);
}
//printf("min(%d, %d) = %d\n", tl, tr, t[idx]);
rmq[to_string(tl) + to_string(tr)] = t[idx];
}
int searchRMQ(int l, int r){
if(l == r){
return rmq[to_string(l) + to_string(l)];
}else if(rmq[to_string(l) + to_string(r)] == 0){
int mid = (l + r)/2;
//cout << l << " - " << mid << endl;
int resl = searchRMQ(l, mid);
//cout << mid+1 << " - " << r << endl;
int resr = searchRMQ(mid+1, r);
return min(resl, resr);
}
return rmq[to_string(l) + to_string(r)];
}
};
int main(){
int arr[] = {3,2,4,2,4,3,7,1};
int n = sizeof(arr)/sizeof(int);
SegmentTree st(arr, n);
cout << "minimu between 0 and 4: " << st.searchRMQ(0, 4) << endl;
return 0;
} | 23.724138 | 69 | 0.494913 | RicardoLopes1 |
d7b806c937b4cbda5936c0e2d330a4a136c7d835 | 1,647 | cpp | C++ | Assignments/homework_03/main.cpp | Landon-Brown1/1063-DS-Brown | 64220948fbc69f7bfbd1ab234fe22da5de97fa6e | [
"MIT"
] | 1 | 2019-12-23T16:26:20.000Z | 2019-12-23T16:26:20.000Z | Assignments/homework_03/main.cpp | Landon-Brown1/1063-DS-Brown | 64220948fbc69f7bfbd1ab234fe22da5de97fa6e | [
"MIT"
] | null | null | null | Assignments/homework_03/main.cpp | Landon-Brown1/1063-DS-Brown | 64220948fbc69f7bfbd1ab234fe22da5de97fa6e | [
"MIT"
] | null | null | null | /*AUTHOR: Landon M. Brown
*ASSIGNMENT TITLE: homework_03
*ASSIGNMENT DESCRIPTION: Edit the ListStack and main so that the
* overloaded constructor is used instead of the default one.
*DUE DATE: 10/15/2019
*DATE CREATED: 10/12/2019
*DATE LAST MODIFIED: 10/12/2019
*/
#include <iostream>
#include <fstream>
#include "ListStack.h"
using namespace std;
int main(){
ifstream inFile; // input file of animal info
inFile.open("animals.txt");
ofstream outFile; // output results of main functions
outFile.open("output_file.dat");
Animal *a; // animal pointer used to hold popped animals
ListStack s; // List based stack object
while (!inFile.eof()) {
inFile >> a->name >> a->weight >> a->scary; // load animal with file data
Animal *b = new Animal(a->name, a->weight, a->scary); // allocate memory for an animal
s.Push(b);
}
inFile.close();
outFile << "INITIAL LIST:" << endl;
s.Print(outFile); // Print the stack
outFile << endl; // ummm
a = s.Pop(); // get animal off top of stack
outFile << "Pop -> " << a << endl; // print animal (cout operator overloaded)
a = s.Pop(); // get animal off top of stack again
outFile << "Pop -> " << a << endl; // print animal (cout operator overloaded)
outFile << endl; // ummm
outFile << "ENDING LIST:" << endl;
s.Print(outFile); // print the stack
outFile.close();
return 0;
} | 31.673077 | 97 | 0.549484 | Landon-Brown1 |
d7b9aadbf4f61c98406583b50fd3f0881c6aeaf5 | 37,820 | cpp | C++ | framegraph/Vulkan/CommandBuffer/VCmdBatch.cpp | zann1x/FrameGraph | ea06e28147a51f6d7cab219b4d8f30428a539faa | [
"BSD-2-Clause"
] | null | null | null | framegraph/Vulkan/CommandBuffer/VCmdBatch.cpp | zann1x/FrameGraph | ea06e28147a51f6d7cab219b4d8f30428a539faa | [
"BSD-2-Clause"
] | null | null | null | framegraph/Vulkan/CommandBuffer/VCmdBatch.cpp | zann1x/FrameGraph | ea06e28147a51f6d7cab219b4d8f30428a539faa | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) 2018-2019, Zhirnov Andrey. For more information see 'LICENSE'
#include "VCmdBatch.h"
#include "VFrameGraph.h"
namespace FG
{
/*
=================================================
constructor
=================================================
*/
VCmdBatch::VCmdBatch (VFrameGraph &fg, uint indexInPool) :
_state{ EState::Initial }, _frameGraph{ fg },
_indexInPool{ indexInPool }
{
STATIC_ASSERT( decltype(_state)::is_always_lock_free );
_counter.store( 0 );
_shaderDebugger.bufferAlign = BytesU{fg.GetDevice().GetDeviceLimits().minStorageBufferOffsetAlignment};
if ( FG_EnableShaderDebugging ) {
CHECK( fg.GetDevice().GetDeviceLimits().maxBoundDescriptorSets > FG_DebugDescriptorSet );
}
}
/*
=================================================
destructor
=================================================
*/
VCmdBatch::~VCmdBatch ()
{
EXLOCK( _drCheck );
CHECK( _counter.load( memory_order_relaxed ) == 0 );
}
/*
=================================================
Initialize
=================================================
*/
void VCmdBatch::Initialize (EQueueType type, ArrayView<CommandBuffer> dependsOn)
{
EXLOCK( _drCheck );
ASSERT( _dependencies.empty() );
ASSERT( _batch.commands.empty() );
ASSERT( _batch.signalSemaphores.empty() );
ASSERT( _batch.waitSemaphores.empty() );
ASSERT( _staging.hostToDevice.empty() );
ASSERT( _staging.deviceToHost.empty() );
ASSERT( _staging.onBufferLoadedEvents.empty() );
ASSERT( _staging.onImageLoadedEvents.empty() );
ASSERT( _resourcesToRelease.empty() );
ASSERT( _swapchains.empty() );
ASSERT( _shaderDebugger.buffers.empty() );
ASSERT( _shaderDebugger.modes.empty() );
ASSERT( _submitted == null );
ASSERT( _counter.load( memory_order_relaxed ) == 0 );
_queueType = type;
_state.store( EState::Initial, memory_order_relaxed );
for (auto& dep : dependsOn)
{
if ( auto* batch = Cast<VCmdBatch>(dep.GetBatch()) )
_dependencies.push_back( batch );
}
}
/*
=================================================
Release
=================================================
*/
void VCmdBatch::Release ()
{
EXLOCK( _drCheck );
CHECK( GetState() == EState::Complete );
ASSERT( _counter.load( memory_order_relaxed ) == 0 );
_frameGraph.RecycleBatch( this );
}
/*
=================================================
SignalSemaphore
=================================================
*/
void VCmdBatch::SignalSemaphore (VkSemaphore sem)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Submitted );
CHECK_ERR( _batch.signalSemaphores.size() < _batch.signalSemaphores.capacity(), void());
_batch.signalSemaphores.push_back( sem );
}
/*
=================================================
WaitSemaphore
=================================================
*/
void VCmdBatch::WaitSemaphore (VkSemaphore sem, VkPipelineStageFlags stage)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Submitted );
CHECK_ERR( _batch.waitSemaphores.size() < _batch.waitSemaphores.capacity(), void());
_batch.waitSemaphores.push_back( sem, stage );
}
/*
=================================================
PushFrontCommandBuffer / PushBackCommandBuffer
=================================================
*/
void VCmdBatch::PushFrontCommandBuffer (VkCommandBuffer cmd, const VCommandPool *pool)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Submitted );
CHECK_ERR( _batch.commands.size() < _batch.commands.capacity(), void());
_batch.commands.insert( 0, cmd, pool );
}
void VCmdBatch::PushBackCommandBuffer (VkCommandBuffer cmd, const VCommandPool *pool)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Submitted );
CHECK_ERR( _batch.commands.size() < _batch.commands.capacity(), void());
_batch.commands.push_back( cmd, pool );
}
/*
=================================================
AddDependency
=================================================
*/
void VCmdBatch::AddDependency (VCmdBatch *batch)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Backed );
CHECK_ERR( _dependencies.size() < _dependencies.capacity(), void());
_dependencies.push_back( batch );
}
/*
=================================================
DestroyPostponed
=================================================
*/
void VCmdBatch::DestroyPostponed (VkObjectType type, uint64_t handle)
{
EXLOCK( _drCheck );
ASSERT( GetState() < EState::Backed );
_readyToDelete.push_back({ type, handle });
}
/*
=================================================
_SetState
=================================================
*/
void VCmdBatch::_SetState (EState newState)
{
EXLOCK( _drCheck );
ASSERT( uint(newState) > uint(GetState()) );
_state.store( newState, memory_order_relaxed );
}
/*
=================================================
OnBegin
=================================================
*/
bool VCmdBatch::OnBegin (const CommandBufferDesc &desc)
{
EXLOCK( _drCheck );
_SetState( EState::Recording );
//_submitImmediatly = // TODO
_staging.hostWritableBufferSize = desc.hostWritableBufferSize;
_staging.hostReadableBufferSize = desc.hostWritableBufferSize;
_staging.hostWritebleBufferUsage = desc.hostWritebleBufferUsage | EBufferUsage::TransferSrc;
_statistic = Default;
return true;
}
/*
=================================================
OnBeginRecording
=================================================
*/
void VCmdBatch::OnBeginRecording (VkCommandBuffer cmd)
{
EXLOCK( _drCheck );
CHECK( GetState() == EState::Recording );
VDevice const& dev = _frameGraph.GetDevice();
VkQueryPool pool = _frameGraph.GetQueryPool();
dev.vkCmdWriteTimestamp( cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, pool, _indexInPool*2 );
_BeginShaderDebugger( cmd );
}
/*
=================================================
OnEndRecording
=================================================
*/
void VCmdBatch::OnEndRecording (VkCommandBuffer cmd)
{
EXLOCK( _drCheck );
CHECK( GetState() == EState::Recording );
_EndShaderDebugger( cmd );
VDevice const& dev = _frameGraph.GetDevice();
VkQueryPool pool = _frameGraph.GetQueryPool();
dev.vkCmdWriteTimestamp( cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, pool, _indexInPool*2 + 1 );
}
/*
=================================================
OnBaked
=================================================
*/
bool VCmdBatch::OnBaked (INOUT ResourceMap_t &resources)
{
EXLOCK( _drCheck );
_SetState( EState::Backed );
std::swap( _resourcesToRelease, resources );
return true;
}
/*
=================================================
OnReadyToSubmit
=================================================
*/
bool VCmdBatch::OnReadyToSubmit ()
{
EXLOCK( _drCheck );
_SetState( EState::Ready );
return true;
}
/*
=================================================
BeforeSubmit
=================================================
*/
bool VCmdBatch::BeforeSubmit (OUT VkSubmitInfo &submitInfo)
{
EXLOCK( _drCheck );
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.pNext = null;
submitInfo.pCommandBuffers = _batch.commands.get<0>().data();
submitInfo.commandBufferCount = uint(_batch.commands.size());
submitInfo.pSignalSemaphores = _batch.signalSemaphores.data();
submitInfo.signalSemaphoreCount = uint(_batch.signalSemaphores.size());
submitInfo.pWaitSemaphores = _batch.waitSemaphores.get<0>().data();
submitInfo.pWaitDstStageMask = _batch.waitSemaphores.get<1>().data();
submitInfo.waitSemaphoreCount = uint(_batch.waitSemaphores.size());
return true;
}
/*
=================================================
AfterSubmit
=================================================
*/
bool VCmdBatch::AfterSubmit (OUT Appendable<VSwapchain const*> swapchains, VSubmitted *ptr)
{
EXLOCK( _drCheck );
_SetState( EState::Submitted );
for (auto& sw : _swapchains) {
swapchains.push_back( sw );
}
_swapchains.clear();
_dependencies.clear();
_submitted = ptr;
return true;
}
/*
=================================================
OnComplete
=================================================
*/
bool VCmdBatch::OnComplete (VDebugger &debugger, const ShaderDebugCallback_t &shaderDbgCallback, INOUT Statistic_t &outStatistic)
{
EXLOCK( _drCheck );
ASSERT( _submitted );
_SetState( EState::Complete );
_FinalizeCommands();
_ParseDebugOutput( shaderDbgCallback );
_FinalizeStagingBuffers();
_ReleaseResources();
_ReleaseVkObjects();
debugger.AddBatchDump( std::move(_debugDump) );
debugger.AddBatchGraph( std::move(_debugGraph) );
_debugDump.clear();
_debugGraph = Default;
// read frame time
{
VDevice const& dev = _frameGraph.GetDevice();
VkQueryPool pool = _frameGraph.GetQueryPool();
uint64_t query_results[2];
VK_CALL( dev.vkGetQueryPoolResults( dev.GetVkDevice(), pool, _indexInPool*2, uint(CountOf(query_results)),
sizeof(query_results), OUT query_results,
sizeof(query_results[0]), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT ));
_statistic.renderer.gpuTime += Nanoseconds{query_results[1] - query_results[0]};
}
outStatistic.Merge( _statistic );
_submitted = null;
return true;
}
/*
=================================================
_FinalizeCommands
=================================================
*/
void VCmdBatch::_FinalizeCommands ()
{
for (size_t i = 0; i < _batch.commands.size(); ++i)
{
if ( auto* pool = _batch.commands.get<1>()[i] )
pool->RecyclePrimary( _batch.commands.get<0>()[i] );
}
_batch.commands.clear();
_batch.signalSemaphores.clear();
_batch.waitSemaphores.clear();
}
/*
=================================================
_FinalizeStagingBuffers
=================================================
*/
void VCmdBatch::_FinalizeStagingBuffers ()
{
using T = BufferView::value_type;
// map device-to-host staging buffers
for (auto& buf : _staging.deviceToHost)
{
// buffer may be recreated on defragmentation pass, so we need to obtain actual pointer every frame
CHECK( _MapMemory( INOUT buf ));
}
// trigger buffer events
for (auto& ev : _staging.onBufferLoadedEvents)
{
FixedArray< ArrayView<T>, MaxBufferParts > data_parts;
BytesU total_size;
for (auto& part : ev.parts)
{
ArrayView<T> view{ Cast<T>(part.buffer->mappedPtr + part.offset), size_t(part.size) };
data_parts.push_back( view );
total_size += part.size;
}
ASSERT( total_size == ev.totalSize );
ev.callback( BufferView{data_parts} );
}
_staging.onBufferLoadedEvents.clear();
// trigger image events
for (auto& ev : _staging.onImageLoadedEvents)
{
FixedArray< ArrayView<T>, MaxImageParts > data_parts;
BytesU total_size;
for (auto& part : ev.parts)
{
ArrayView<T> view{ Cast<T>(part.buffer->mappedPtr + part.offset), size_t(part.size) };
data_parts.push_back( view );
total_size += part.size;
}
ASSERT( total_size == ev.totalSize );
ev.callback( ImageView{ data_parts, ev.imageSize, ev.rowPitch, ev.slicePitch, ev.format, ev.aspect });
}
_staging.onImageLoadedEvents.clear();
// release resources
{
auto& rm = _frameGraph.GetResourceManager();
for (auto& sb : _staging.hostToDevice) {
rm.ReleaseResource( sb.bufferId.Release() );
}
_staging.hostToDevice.clear();
for (auto& sb : _staging.deviceToHost) {
rm.ReleaseResource( sb.bufferId.Release() );
}
_staging.deviceToHost.clear();
}
}
/*
=================================================
_ParseDebugOutput
=================================================
*/
void VCmdBatch::_ParseDebugOutput (const ShaderDebugCallback_t &cb)
{
if ( _shaderDebugger.buffers.empty() )
return;
ASSERT( cb );
auto& dev = _frameGraph.GetDevice();
auto& rm = _frameGraph.GetResourceManager();
VK_CHECK( dev.vkDeviceWaitIdle( dev.GetVkDevice() ), void());
// release descriptor sets
for (auto& ds : _shaderDebugger.descCache) {
rm.GetDescriptorManager().DeallocDescriptorSet( ds.second );
}
_shaderDebugger.descCache.clear();
// process shader debug output
if ( cb )
{
Array<String> temp_strings;
for (auto& dbg : _shaderDebugger.modes) {
_ParseDebugOutput2( cb, dbg, temp_strings );
}
}
_shaderDebugger.modes.clear();
// release storage buffers
for (auto& sb : _shaderDebugger.buffers)
{
rm.ReleaseResource( sb.shaderTraceBuffer.Release() );
rm.ReleaseResource( sb.readBackBuffer.Release() );
}
_shaderDebugger.buffers.clear();
}
/*
=================================================
_ParseDebugOutput2
=================================================
*/
bool VCmdBatch::_ParseDebugOutput2 (const ShaderDebugCallback_t &cb, const DebugMode &dbg, Array<String> &tempStrings) const
{
CHECK_ERR( dbg.modules.size() );
auto& rm = _frameGraph.GetResourceManager();
auto read_back_buf = _shaderDebugger.buffers[ dbg.sbIndex ].readBackBuffer.Get();
VBuffer const* buf = rm.GetResource( read_back_buf );
CHECK_ERR( buf );
VMemoryObj const* mem = rm.GetResource( buf->GetMemoryID() );
CHECK_ERR( mem );
VMemoryObj::MemoryInfo info;
CHECK_ERR( mem->GetInfo( rm.GetMemoryManager(), OUT info ));
CHECK_ERR( info.mappedPtr );
for (auto& shader : dbg.modules)
{
CHECK_ERR( shader->ParseDebugOutput( dbg.mode, ArrayView<uint8_t>{ Cast<uint8_t>(info.mappedPtr + dbg.offset), size_t(dbg.size) }, OUT tempStrings ));
cb( dbg.taskName, shader->GetDebugName(), dbg.shaderStages, tempStrings );
}
return true;
}
//-----------------------------------------------------------------------------
/*
=================================================
_MapMemory
=================================================
*/
bool VCmdBatch::_MapMemory (INOUT StagingBuffer &buf) const
{
VMemoryObj::MemoryInfo info;
auto& rm = _frameGraph.GetResourceManager();
if ( rm.GetResource( buf.memoryId )->GetInfo( rm.GetMemoryManager(),OUT info ) )
{
buf.mappedPtr = info.mappedPtr;
buf.memOffset = info.offset;
buf.mem = info.mem;
buf.isCoherent = EnumEq( info.flags, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT );
return true;
}
return false;
}
/*
=================================================
_ReleaseResources
=================================================
*/
void VCmdBatch::_ReleaseResources ()
{
auto& rm = _frameGraph.GetResourceManager();
for (auto[res, count] : _resourcesToRelease)
{
switch ( res.GetUID() )
{
case RawBufferID::GetUID() : rm.ReleaseResource( RawBufferID{ res.Index(), res.InstanceID() }, count ); break;
case RawImageID::GetUID() : rm.ReleaseResource( RawImageID{ res.Index(), res.InstanceID() }, count ); break;
case RawGPipelineID::GetUID() : rm.ReleaseResource( RawGPipelineID{ res.Index(), res.InstanceID() }, count ); break;
case RawMPipelineID::GetUID() : rm.ReleaseResource( RawMPipelineID{ res.Index(), res.InstanceID() }, count ); break;
case RawCPipelineID::GetUID() : rm.ReleaseResource( RawCPipelineID{ res.Index(), res.InstanceID() }, count ); break;
case RawRTPipelineID::GetUID() : rm.ReleaseResource( RawRTPipelineID{ res.Index(), res.InstanceID() }, count ); break;
case RawSamplerID::GetUID() : rm.ReleaseResource( RawSamplerID{ res.Index(), res.InstanceID() }, count ); break;
case RawDescriptorSetLayoutID::GetUID():rm.ReleaseResource( RawDescriptorSetLayoutID{ res.Index(), res.InstanceID() }, count ); break;
case RawPipelineResourcesID::GetUID() : rm.ReleaseResource( RawPipelineResourcesID{ res.Index(), res.InstanceID() }, count ); break;
case RawRTSceneID::GetUID() : rm.ReleaseResource( RawRTSceneID{ res.Index(), res.InstanceID() }, count ); break;
case RawRTGeometryID::GetUID() : rm.ReleaseResource( RawRTGeometryID{ res.Index(), res.InstanceID() }, count ); break;
case RawRTShaderTableID::GetUID() : rm.ReleaseResource( RawRTShaderTableID{ res.Index(), res.InstanceID() }, count ); break;
case RawSwapchainID::GetUID() : rm.ReleaseResource( RawSwapchainID{ res.Index(), res.InstanceID() }, count ); break;
case RawMemoryID::GetUID() : rm.ReleaseResource( RawMemoryID{ res.Index(), res.InstanceID() }, count ); break;
case RawPipelineLayoutID::GetUID() : rm.ReleaseResource( RawPipelineLayoutID{ res.Index(), res.InstanceID() }, count ); break;
case RawRenderPassID::GetUID() : rm.ReleaseResource( RawRenderPassID{ res.Index(), res.InstanceID() }, count ); break;
case RawFramebufferID::GetUID() : rm.ReleaseResource( RawFramebufferID{ res.Index(), res.InstanceID() }, count ); break;
default : CHECK( !"not supported" ); break;
}
}
_resourcesToRelease.clear();
}
/*
=================================================
_ReleaseVkObjects
=================================================
*/
void VCmdBatch::_ReleaseVkObjects ()
{
VDevice const& dev = _frameGraph.GetDevice();
VkDevice vdev = dev.GetVkDevice();
for (auto& pair : _readyToDelete)
{
switch ( pair.first )
{
case VK_OBJECT_TYPE_SEMAPHORE :
dev.vkDestroySemaphore( vdev, VkSemaphore(pair.second), null );
break;
case VK_OBJECT_TYPE_FENCE :
dev.vkDestroyFence( vdev, VkFence(pair.second), null );
break;
case VK_OBJECT_TYPE_DEVICE_MEMORY :
dev.vkFreeMemory( vdev, VkDeviceMemory(pair.second), null );
break;
case VK_OBJECT_TYPE_IMAGE :
dev.vkDestroyImage( vdev, VkImage(pair.second), null );
break;
case VK_OBJECT_TYPE_EVENT :
dev.vkDestroyEvent( vdev, VkEvent(pair.second), null );
break;
case VK_OBJECT_TYPE_QUERY_POOL :
dev.vkDestroyQueryPool( vdev, VkQueryPool(pair.second), null );
break;
case VK_OBJECT_TYPE_BUFFER :
dev.vkDestroyBuffer( vdev, VkBuffer(pair.second), null );
break;
case VK_OBJECT_TYPE_BUFFER_VIEW :
dev.vkDestroyBufferView( vdev, VkBufferView(pair.second), null );
break;
case VK_OBJECT_TYPE_IMAGE_VIEW :
dev.vkDestroyImageView( vdev, VkImageView(pair.second), null );
break;
case VK_OBJECT_TYPE_PIPELINE_LAYOUT :
dev.vkDestroyPipelineLayout( vdev, VkPipelineLayout(pair.second), null );
break;
case VK_OBJECT_TYPE_RENDER_PASS :
dev.vkDestroyRenderPass( vdev, VkRenderPass(pair.second), null );
break;
case VK_OBJECT_TYPE_PIPELINE :
dev.vkDestroyPipeline( vdev, VkPipeline(pair.second), null );
break;
case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT :
dev.vkDestroyDescriptorSetLayout( vdev, VkDescriptorSetLayout(pair.second), null );
break;
case VK_OBJECT_TYPE_SAMPLER :
dev.vkDestroySampler( vdev, VkSampler(pair.second), null );
break;
case VK_OBJECT_TYPE_DESCRIPTOR_POOL :
dev.vkDestroyDescriptorPool( vdev, VkDescriptorPool(pair.second), null );
break;
case VK_OBJECT_TYPE_FRAMEBUFFER :
dev.vkDestroyFramebuffer( vdev, VkFramebuffer(pair.second), null );
break;
case VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION :
dev.vkDestroySamplerYcbcrConversion( vdev, VkSamplerYcbcrConversion(pair.second), null );
break;
case VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE :
dev.vkDestroyDescriptorUpdateTemplate( vdev, VkDescriptorUpdateTemplate(pair.second), null );
break;
case VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV :
dev.vkDestroyAccelerationStructureNV( vdev, VkAccelerationStructureNV(pair.second), null );
break;
default :
FG_LOGE( "resource type is not supported" );
break;
}
}
_readyToDelete.clear();
}
/*
=================================================
_GetWritable
=================================================
*/
bool VCmdBatch::GetWritable (const BytesU srcRequiredSize, const BytesU blockAlign, const BytesU offsetAlign, const BytesU dstMinSize,
OUT RawBufferID &dstBuffer, OUT BytesU &dstOffset, OUT BytesU &outSize, OUT void* &mappedPtr)
{
EXLOCK( _drCheck );
ASSERT( blockAlign > 0_b and offsetAlign > 0_b );
ASSERT( dstMinSize == AlignToSmaller( dstMinSize, blockAlign ));
auto& staging_buffers = _staging.hostToDevice;
// search in existing
StagingBuffer* suitable = null;
StagingBuffer* max_available = null;
BytesU max_size;
for (auto& buf : staging_buffers)
{
const BytesU off = AlignToLarger( buf.size, offsetAlign );
const BytesU av = AlignToSmaller( buf.capacity - off, blockAlign );
if ( av >= srcRequiredSize )
{
suitable = &buf;
break;
}
if ( not max_available or av > max_size )
{
max_available = &buf;
max_size = av;
}
}
// no suitable space, try to use max available block
if ( not suitable and max_available and max_size >= dstMinSize )
{
suitable = max_available;
}
// allocate new buffer
if ( not suitable )
{
ASSERT( dstMinSize < _staging.hostWritableBufferSize );
CHECK_ERR( staging_buffers.size() < staging_buffers.capacity() );
BufferID buf_id = _frameGraph.CreateBuffer( BufferDesc{ _staging.hostWritableBufferSize, _staging.hostWritebleBufferUsage },
MemoryDesc{ EMemoryType::HostWrite }, "HostWriteBuffer" );
CHECK_ERR( buf_id );
RawMemoryID mem_id = _frameGraph.GetResourceManager().GetResource( buf_id.Get() )->GetMemoryID();
CHECK_ERR( mem_id );
staging_buffers.push_back({ std::move(buf_id), mem_id, _staging.hostWritableBufferSize });
suitable = &staging_buffers.back();
CHECK( _MapMemory( *suitable ));
}
// write data to buffer
dstOffset = AlignToLarger( suitable->size, offsetAlign );
outSize = Min( AlignToSmaller( suitable->capacity - dstOffset, blockAlign ), srcRequiredSize );
dstBuffer = suitable->bufferId.Get();
mappedPtr = suitable->mappedPtr + dstOffset;
suitable->size = dstOffset + outSize;
return true;
}
/*
=================================================
_AddPendingLoad
=================================================
*/
bool VCmdBatch::_AddPendingLoad (const BytesU srcRequiredSize, const BytesU blockAlign, const BytesU offsetAlign, const BytesU dstMinSize,
OUT RawBufferID &dstBuffer, OUT OnBufferDataLoadedEvent::Range &range)
{
ASSERT( blockAlign > 0_b and offsetAlign > 0_b );
ASSERT( dstMinSize == AlignToSmaller( dstMinSize, blockAlign ));
auto& staging_buffers = _staging.deviceToHost;
// search in existing
StagingBuffer* suitable = null;
StagingBuffer* max_available = null;
BytesU max_size;
for (auto& buf : staging_buffers)
{
const BytesU off = AlignToLarger( buf.size, offsetAlign );
const BytesU av = AlignToSmaller( buf.capacity - off, blockAlign );
if ( av >= srcRequiredSize )
{
suitable = &buf;
break;
}
if ( not max_available or av > max_size )
{
max_available = &buf;
max_size = av;
}
}
// no suitable space, try to use max available block
if ( not suitable and max_available and max_size >= dstMinSize )
{
suitable = max_available;
}
// allocate new buffer
if ( not suitable )
{
ASSERT( dstMinSize < _staging.hostReadableBufferSize );
CHECK_ERR( staging_buffers.size() < staging_buffers.capacity() );
BufferID buf_id = _frameGraph.CreateBuffer( BufferDesc{ _staging.hostReadableBufferSize, EBufferUsage::TransferDst },
MemoryDesc{ EMemoryType::HostRead }, "HostReadBuffer" );
CHECK_ERR( buf_id );
RawMemoryID mem_id = _frameGraph.GetResourceManager().GetResource( buf_id.Get() )->GetMemoryID();
CHECK_ERR( mem_id );
// TODO: make immutable because read after write happens after waiting for fences and it implicitly make changes visible to the host
staging_buffers.push_back({ std::move(buf_id), mem_id, _staging.hostReadableBufferSize });
suitable = &staging_buffers.back();
CHECK( _MapMemory( *suitable ));
}
// write data to buffer
range.buffer = suitable;
range.offset = AlignToLarger( suitable->size, offsetAlign );
range.size = Min( AlignToSmaller( suitable->capacity - range.offset, blockAlign ), srcRequiredSize );
dstBuffer = suitable->bufferId.Get();
suitable->size = range.offset + range.size;
return true;
}
/*
=================================================
AddPendingLoad
=================================================
*/
bool VCmdBatch::AddPendingLoad (const BytesU srcOffset, const BytesU srcTotalSize,
OUT RawBufferID &dstBuffer, OUT OnBufferDataLoadedEvent::Range &range)
{
EXLOCK( _drCheck );
// skip blocks less than 1/N of data size
const BytesU min_size = (srcTotalSize + MaxBufferParts-1) / MaxBufferParts;
return _AddPendingLoad( srcTotalSize - srcOffset, 1_b, 16_b, min_size, OUT dstBuffer, OUT range );
}
/*
=================================================
AddDataLoadedEvent
=================================================
*/
bool VCmdBatch::AddDataLoadedEvent (OnBufferDataLoadedEvent &&ev)
{
EXLOCK( _drCheck );
CHECK_ERR( ev.callback and not ev.parts.empty() );
_staging.onBufferLoadedEvents.push_back( std::move(ev) );
return true;
}
/*
=================================================
AddPendingLoad
=================================================
*/
bool VCmdBatch::AddPendingLoad (const BytesU srcOffset, const BytesU srcTotalSize, const BytesU srcPitch,
OUT RawBufferID &dstBuffer, OUT OnImageDataLoadedEvent::Range &range)
{
EXLOCK( _drCheck );
// skip blocks less than 1/N of total data size
const BytesU min_size = Max( (srcTotalSize + MaxImageParts-1) / MaxImageParts, srcPitch );
return _AddPendingLoad( srcTotalSize - srcOffset, srcPitch, 16_b, min_size, OUT dstBuffer, OUT range );
}
/*
=================================================
AddDataLoadedEvent
=================================================
*/
bool VCmdBatch::AddDataLoadedEvent (OnImageDataLoadedEvent &&ev)
{
EXLOCK( _drCheck );
CHECK_ERR( ev.callback and not ev.parts.empty() );
_staging.onImageLoadedEvents.push_back( std::move(ev) );
return true;
}
//-----------------------------------------------------------------------------
/*
=================================================
_BeginShaderDebugger
=================================================
*/
void VCmdBatch::_BeginShaderDebugger (VkCommandBuffer cmd)
{
if ( _shaderDebugger.buffers.empty() )
return;
auto& dev = _frameGraph.GetDevice();
auto& rm = _frameGraph.GetResourceManager();
// copy data
for (auto& dbg : _shaderDebugger.modes)
{
auto buf = rm.GetResource( _shaderDebugger.buffers[dbg.sbIndex].shaderTraceBuffer.Get() )->Handle();
BytesU size = rm.GetDebugShaderStorageSize( dbg.shaderStages ) + SizeOf<uint>; // per shader data + position
ASSERT( size <= BytesU::SizeOf(dbg.data) );
dev.vkCmdUpdateBuffer( cmd, buf, VkDeviceSize(dbg.offset), VkDeviceSize(size), dbg.data );
}
// add pipeline barriers
FixedArray< VkBufferMemoryBarrier, 16 > barriers;
VkPipelineStageFlags dst_stage_flags = 0;
for (auto& sb : _shaderDebugger.buffers)
{
VkBufferMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
barrier.buffer = rm.GetResource( sb.shaderTraceBuffer.Get() )->Handle();
barrier.offset = 0;
barrier.size = VkDeviceSize(sb.size);
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
dst_stage_flags |= sb.stages;
barriers.push_back( barrier );
if ( barriers.size() == barriers.capacity() )
{
dev.vkCmdPipelineBarrier( cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, dst_stage_flags, 0, 0, null, uint(barriers.size()), barriers.data(), 0, null );
barriers.clear();
}
}
if ( barriers.size() ) {
dev.vkCmdPipelineBarrier( cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, dst_stage_flags, 0, 0, null, uint(barriers.size()), barriers.data(), 0, null );
}
}
/*
=================================================
_EndShaderDebugger
=================================================
*/
void VCmdBatch::_EndShaderDebugger (VkCommandBuffer cmd)
{
if ( _shaderDebugger.buffers.empty() )
return;
auto& dev = _frameGraph.GetDevice();
auto& rm = _frameGraph.GetResourceManager();
// copy to staging buffer
for (auto& sb : _shaderDebugger.buffers)
{
VkBuffer src_buf = rm.GetResource( sb.shaderTraceBuffer.Get() )->Handle();
VkBuffer dst_buf = rm.GetResource( sb.readBackBuffer.Get() )->Handle();
VkBufferMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
barrier.buffer = src_buf;
barrier.offset = 0;
barrier.size = VkDeviceSize(sb.size);
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
dev.vkCmdPipelineBarrier( cmd, sb.stages, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, null, 1, &barrier, 0, null );
VkBufferCopy region = {};
region.size = VkDeviceSize(sb.size);
dev.vkCmdCopyBuffer( cmd, src_buf, dst_buf, 1, ®ion );
}
}
/*
=================================================
SetShaderModule
=================================================
*/
bool VCmdBatch::SetShaderModule (ShaderDbgIndex id, const SharedShaderPtr &module)
{
EXLOCK( _drCheck );
CHECK_ERR( uint(id) < _shaderDebugger.modes.size() );
auto& dbg = _shaderDebugger.modes[ uint(id) ];
dbg.modules.emplace_back( module );
return true;
}
/*
=================================================
GetDebugModeInfo
=================================================
*/
bool VCmdBatch::GetDebugModeInfo (ShaderDbgIndex id, OUT EShaderDebugMode &mode, OUT EShaderStages &stages) const
{
EXLOCK( _drCheck );
CHECK_ERR( uint(id) < _shaderDebugger.modes.size() );
auto& dbg = _shaderDebugger.modes[ uint(id) ];
mode = dbg.mode;
stages = dbg.shaderStages;
return true;
}
/*
=================================================
GetDescriptotSet
=================================================
*/
bool VCmdBatch::GetDescriptotSet (ShaderDbgIndex id, OUT uint &binding, OUT VkDescriptorSet &descSet, OUT uint &dynamicOffset) const
{
EXLOCK( _drCheck );
CHECK_ERR( uint(id) < _shaderDebugger.modes.size() );
auto& dbg = _shaderDebugger.modes[ uint(id) ];
binding = FG_DebugDescriptorSet;
descSet = dbg.descriptorSet;
dynamicOffset = uint(dbg.offset);
return true;
}
/*
=================================================
AppendShader
=================================================
*/
ShaderDbgIndex VCmdBatch::AppendShader (INOUT ArrayView<RectI> &, const TaskName_t &name, const _fg_hidden_::GraphicsShaderDebugMode &mode, BytesU size)
{
EXLOCK( _drCheck );
CHECK_ERR( FG_EnableShaderDebugging );
DebugMode dbg_mode;
dbg_mode.taskName = name;
dbg_mode.mode = mode.mode;
dbg_mode.shaderStages = mode.stages;
CHECK_ERR( _AllocStorage( INOUT dbg_mode, size ));
dbg_mode.data[0] = mode.fragCoord.x;
dbg_mode.data[1] = mode.fragCoord.y;
dbg_mode.data[2] = 0;
dbg_mode.data[3] = 0;
_shaderDebugger.modes.push_back( std::move(dbg_mode) );
return ShaderDbgIndex(_shaderDebugger.modes.size() - 1);
}
/*
=================================================
AppendShader
=================================================
*/
ShaderDbgIndex VCmdBatch::AppendShader (const TaskName_t &name, const _fg_hidden_::ComputeShaderDebugMode &mode, BytesU size)
{
EXLOCK( _drCheck );
CHECK_ERR( FG_EnableShaderDebugging );
DebugMode dbg_mode;
dbg_mode.taskName = name;
dbg_mode.mode = mode.mode;
dbg_mode.shaderStages = EShaderStages::Compute;
CHECK_ERR( _AllocStorage( INOUT dbg_mode, size ));
MemCopy( OUT dbg_mode.data, mode.globalID );
dbg_mode.data[3] = 0;
_shaderDebugger.modes.push_back( std::move(dbg_mode) );
return ShaderDbgIndex(_shaderDebugger.modes.size() - 1);
}
/*
=================================================
AppendShader
=================================================
*/
ShaderDbgIndex VCmdBatch::AppendShader (const TaskName_t &name, const _fg_hidden_::RayTracingShaderDebugMode &mode, BytesU size)
{
EXLOCK( _drCheck );
CHECK_ERR( FG_EnableShaderDebugging );
DebugMode dbg_mode;
dbg_mode.taskName = name;
dbg_mode.mode = mode.mode;
dbg_mode.shaderStages = EShaderStages::AllRayTracing;
CHECK_ERR( _AllocStorage( INOUT dbg_mode, size ));
MemCopy( OUT dbg_mode.data, mode.launchID );
dbg_mode.data[3] = 0;
_shaderDebugger.modes.push_back( std::move(dbg_mode) );
return ShaderDbgIndex(_shaderDebugger.modes.size() - 1);
}
/*
=================================================
_AllocStorage
=================================================
*/
bool VCmdBatch::_AllocStorage (INOUT DebugMode &dbgMode, const BytesU size)
{
VkPipelineStageFlags stage = 0;
for (EShaderStages s = EShaderStages(1); s <= dbgMode.shaderStages; s = EShaderStages(uint(s) << 1))
{
if ( not EnumEq( dbgMode.shaderStages, s ) )
continue;
ENABLE_ENUM_CHECKS();
switch ( s )
{
case EShaderStages::Vertex : stage = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT; break;
case EShaderStages::TessControl : stage = VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT; break;
case EShaderStages::TessEvaluation: stage = VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT; break;
case EShaderStages::Geometry : stage = VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT; break;
case EShaderStages::Fragment : stage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; break;
case EShaderStages::Compute : stage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; break;
case EShaderStages::MeshTask : stage = VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV; break;
case EShaderStages::Mesh : stage = VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV; break;
case EShaderStages::RayGen :
case EShaderStages::RayAnyHit :
case EShaderStages::RayClosestHit :
case EShaderStages::RayMiss :
case EShaderStages::RayIntersection:
case EShaderStages::RayCallable : stage = VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV; break;
case EShaderStages::_Last :
case EShaderStages::Unknown :
case EShaderStages::AllGraphics :
case EShaderStages::AllRayTracing :
case EShaderStages::All : // to shutup warnings
default : RETURN_ERR( "unknown shader type" );
}
DISABLE_ENUM_CHECKS();
}
dbgMode.size = Min( size, _shaderDebugger.bufferSize );
// find place in existing storage buffers
for (auto& sb : _shaderDebugger.buffers)
{
dbgMode.offset = AlignToLarger( sb.size, _shaderDebugger.bufferAlign );
if ( dbgMode.size <= (sb.capacity - dbgMode.offset) )
{
dbgMode.sbIndex = uint(Distance( _shaderDebugger.buffers.data(), &sb ));
sb.size = dbgMode.offset + size;
sb.stages |= stage;
break;
}
}
// create new storage buffer
if ( dbgMode.sbIndex == UMax )
{
StorageBuffer sb;
sb.capacity = _shaderDebugger.bufferSize * (1 + _shaderDebugger.buffers.size() / 2);
sb.shaderTraceBuffer = _frameGraph.CreateBuffer( BufferDesc{ sb.capacity, EBufferUsage::Storage | EBufferUsage::Transfer },
Default, "DebugOutputStorage" );
sb.readBackBuffer = _frameGraph.CreateBuffer( BufferDesc{ sb.capacity, EBufferUsage::TransferDst },
MemoryDesc{EMemoryType::HostRead}, "ReadBackDebugOutput" );
CHECK_ERR( sb.shaderTraceBuffer and sb.readBackBuffer );
dbgMode.sbIndex = uint(_shaderDebugger.buffers.size());
dbgMode.offset = 0_b;
sb.size = dbgMode.offset + size;
sb.stages |= stage;
_shaderDebugger.buffers.push_back( std::move(sb) );
}
CHECK_ERR( _AllocDescriptorSet( dbgMode.mode, dbgMode.shaderStages,
_shaderDebugger.buffers[dbgMode.sbIndex].shaderTraceBuffer.Get(),
dbgMode.size, OUT dbgMode.descriptorSet ));
return true;
}
/*
=================================================
_AllocDescriptorSet
=================================================
*/
bool VCmdBatch::_AllocDescriptorSet (EShaderDebugMode debugMode, EShaderStages stages, RawBufferID storageBuffer, BytesU size, OUT VkDescriptorSet &descSet)
{
auto& dev = _frameGraph.GetDevice();
auto& rm = _frameGraph.GetResourceManager();
auto layout_id = rm.GetDescriptorSetLayout( debugMode, stages );
auto* layout = rm.GetResource( layout_id );
auto* buffer = rm.GetResource( storageBuffer );
CHECK_ERR( layout and buffer );
// find descriptor set in cache
auto iter = _shaderDebugger.descCache.find({ storageBuffer, layout_id });
if ( iter != _shaderDebugger.descCache.end() )
{
descSet = iter->second.first;
return true;
}
// allocate descriptor set
{
VDescriptorSetLayout::DescriptorSet ds;
CHECK_ERR( rm.GetDescriptorManager().AllocDescriptorSet( layout->Handle(), OUT ds ));
descSet = ds.first;
_shaderDebugger.descCache.insert_or_assign( {storageBuffer, layout_id}, ds );
}
// update descriptor set
{
VkDescriptorBufferInfo buffer_desc = {};
buffer_desc.buffer = buffer->Handle();
buffer_desc.offset = 0;
buffer_desc.range = VkDeviceSize(size);
VkWriteDescriptorSet write = {};
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.dstSet = descSet;
write.dstBinding = 0;
write.descriptorCount = 1;
write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
write.pBufferInfo = &buffer_desc;
dev.vkUpdateDescriptorSets( dev.GetVkDevice(), 1, &write, 0, null );
}
return true;
}
} // FG
| 30.722989 | 158 | 0.6266 | zann1x |
d7bad70d390416bbdc5854f14fe5275cebb5a585 | 2,089 | cpp | C++ | Raven.CppClient.Tests/PutDocumentCommandTest.cpp | mlawsonca/ravendb-cpp-client | c3a3d4960c8b810156547f62fa7aeb14a121bf74 | [
"MIT"
] | 3 | 2019-04-24T02:34:53.000Z | 2019-08-01T08:22:26.000Z | Raven.CppClient.Tests/PutDocumentCommandTest.cpp | mlawsonca/ravendb-cpp-client | c3a3d4960c8b810156547f62fa7aeb14a121bf74 | [
"MIT"
] | 2 | 2019-03-21T09:00:02.000Z | 2021-02-28T23:49:26.000Z | Raven.CppClient.Tests/PutDocumentCommandTest.cpp | mlawsonca/ravendb-cpp-client | c3a3d4960c8b810156547f62fa7aeb14a121bf74 | [
"MIT"
] | 3 | 2019-03-04T11:58:54.000Z | 2021-03-01T00:25:49.000Z | #include "pch.h"
#include "RavenTestDriver.h"
#include "raven_test_definitions.h"
#include "DocumentSession.h"
#include "AdvancedSessionOperations.h"
#include "RequestExecutor.h"
#include "User.h"
#include "PutDocumentCommand.h"
namespace ravendb::client::tests::client::documents::commands
{
class PutDocumentCommandTest : public driver::RavenTestDriver
{
protected:
void customise_store(std::shared_ptr<ravendb::client::documents::DocumentStore> store) override
{
//store->set_before_perform(infrastructure::set_for_fiddler);
}
};
TEST_F(PutDocumentCommandTest, CanPutDocumentUsingCommand)
{
auto store = get_document_store(TEST_NAME);
auto user = std::make_shared<infrastructure::entities::User>();
user->name = "Alexander";
user->age = 38;
nlohmann::json json = *user;
auto command = ravendb::client::documents::commands::PutDocumentCommand("users/1", {}, json);
store->get_request_executor()->execute(command);
auto res = command.get_result();
ASSERT_EQ("users/1", res->id);
ASSERT_FALSE(res->change_vector.empty());
{
auto session = store->open_session();
auto loaded_user = session.load<infrastructure::entities::User>("users/1");
ASSERT_EQ("Alexander", loaded_user->name);
}
}
TEST_F(PutDocumentCommandTest, CanPutLargeDocumentUsingCommand)
{
auto store = get_document_store(TEST_NAME);
auto user = std::make_shared<infrastructure::entities::User>();
constexpr std::size_t LARGE_STRING_SIZE{ 1024 * 1024 };
user->name.reserve(LARGE_STRING_SIZE);
for(std::size_t i = 0; i < LARGE_STRING_SIZE/4; ++i)
{
user->name.append("AbCd");
}
nlohmann::json json = *user;
auto command = ravendb::client::documents::commands::PutDocumentCommand("users/1", {}, json);
store->get_request_executor()->execute(command);
auto res = command.get_result();
ASSERT_EQ("users/1", res->id);
ASSERT_FALSE(res->change_vector.empty());
{
auto session = store->open_session();
auto loaded_user = session.load<infrastructure::entities::User>("users/1");
ASSERT_EQ(user->name, loaded_user->name);
}
}
}
| 27.853333 | 97 | 0.721398 | mlawsonca |
d7bd45c05e0eec748467f5543c97fbf349a019c8 | 3,375 | hpp | C++ | examples/CBuilder/Compound/Locking/Server/comserv.hpp | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
] | 121 | 2020-09-22T10:46:20.000Z | 2021-11-17T12:33:35.000Z | examples/CBuilder/Compound/Locking/Server/comserv.hpp | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
] | 8 | 2020-09-23T12:32:23.000Z | 2021-07-28T07:01:26.000Z | examples/CBuilder/Compound/Locking/Server/comserv.hpp | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
] | 42 | 2020-09-22T14:37:20.000Z | 2021-10-04T10:24:12.000Z | // Borland C++ Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved
// (DO NOT EDIT: machine generated header) 'ComServ.pas' rev: 5.00
#ifndef ComServHPP
#define ComServHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <ComObj.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <ActiveX.hpp> // Pascal unit
#include <Messages.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Comserv
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TStartMode { smStandalone, smAutomation, smRegServer, smUnregServer };
#pragma option pop
typedef void __fastcall (__closure *TLastReleaseEvent)(bool &Shutdown);
class DELPHICLASS TComServer;
class PASCALIMPLEMENTATION TComServer : public Comobj::TComServerObject
{
typedef Comobj::TComServerObject inherited;
private:
int FObjectCount;
int FFactoryCount;
_di_ITypeLib FTypeLib;
AnsiString FServerName;
AnsiString FHelpFileName;
bool FIsInprocServer;
TStartMode FStartMode;
bool FStartSuspended;
bool FRegister;
bool FUIInteractive;
TLastReleaseEvent FOnLastRelease;
void __fastcall FactoryFree(TComObjectFactory* Factory);
void __fastcall FactoryRegisterClassObject(TComObjectFactory* Factory);
void __fastcall FactoryUpdateRegistry(TComObjectFactory* Factory);
void __fastcall LastReleased(void);
protected:
virtual int __fastcall CountObject(bool Created);
virtual int __fastcall CountFactory(bool Created);
virtual AnsiString __fastcall GetHelpFileName();
virtual AnsiString __fastcall GetServerFileName();
virtual AnsiString __fastcall GetServerKey();
virtual AnsiString __fastcall GetServerName();
virtual bool __fastcall GetStartSuspended(void);
virtual _di_ITypeLib __fastcall GetTypeLib();
virtual void __fastcall SetHelpFileName(const AnsiString Value);
public:
__fastcall TComServer(void);
__fastcall virtual ~TComServer(void);
void __fastcall Initialize(void);
void __fastcall LoadTypeLib(void);
void __fastcall SetServerName(const AnsiString Name);
void __fastcall UpdateRegistry(bool Register);
__property bool IsInprocServer = {read=FIsInprocServer, write=FIsInprocServer, nodefault};
__property int ObjectCount = {read=FObjectCount, nodefault};
__property TStartMode StartMode = {read=FStartMode, nodefault};
__property bool UIInteractive = {read=FUIInteractive, write=FUIInteractive, nodefault};
__property TLastReleaseEvent OnLastRelease = {read=FOnLastRelease, write=FOnLastRelease};
};
//-- var, const, procedure ---------------------------------------------------
extern PACKAGE TComServer* ComServer;
extern PACKAGE HRESULT __stdcall DllGetClassObject(const GUID &CLSID, const GUID &IID, void *Obj);
extern PACKAGE HRESULT __stdcall DllCanUnloadNow(void);
extern PACKAGE HRESULT __stdcall DllRegisterServer(void);
extern PACKAGE HRESULT __stdcall DllUnregisterServer(void);
} /* namespace Comserv */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Comserv;
#endif
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // ComServ
| 34.793814 | 98 | 0.740741 | LenakeTech |
d7c13f44bef3d292f68e382ce674ad2d932c8482 | 3,531 | cpp | C++ | samples/lab3/SphereRolling/sphere.cpp | wiali/opengl-labs | 8160bd495f38eacb46cd37847a8881a6dc7a8fe8 | [
"MIT"
] | 1 | 2021-05-05T15:24:49.000Z | 2021-05-05T15:24:49.000Z | samples/lab3/SphereRolling/sphere.cpp | wiali/opengl-labs | 8160bd495f38eacb46cd37847a8881a6dc7a8fe8 | [
"MIT"
] | null | null | null | samples/lab3/SphereRolling/sphere.cpp | wiali/opengl-labs | 8160bd495f38eacb46cd37847a8881a6dc7a8fe8 | [
"MIT"
] | null | null | null | /*
* Implementation of sphere
* Author: Weichen Xu
* Date: 11/10/2015
*/
#include "sphere.h"
WCX_sphere::WCX_sphere(){
this->radius = 1.0;
this->rollingSpeed = 0.02;
this->accumuRollingM = mat4();
}
void WCX_sphere::loadSphereFromFile(){
int Index = 0, triangleNum = 0;
std::string sphereFileName;
std::ifstream inputFile(sphereFileName);
std::string line;
while(!inputFile.is_open()){
std::cout<<"Please input the file name for the sphere info: "<<std::endl;
std::cin>>sphereFileName;
sphereFileName = "./"+sphereFileName;
inputFile.open(sphereFileName, std::ifstream::in);
if(!inputFile.is_open()){
std::cout<<"Can not open the file, do this again!"<<std::endl;
continue;
}
}
std::getline(inputFile, line);
char *chr = new char[line.size()+1];
strcpy_s(chr, line.length()+1, line.c_str());
triangleNum = atoi(chr);
this->vertex_size = triangleNum*3;
delete chr;
for(int i=0; i<triangleNum; i++){
// get each vertex info
// since all vertex, skip a readline which n = 3
std::getline(inputFile, line);
for(int j=0; j<3; j++){
std::getline(inputFile, line);
char *chr = NULL, *tok = NULL;
chr = new char[line.length()+1];
strcpy_s(chr,line.length()+1, line.c_str());
for(int k = 0; k<3; k++){
if(!k){
sphere_points[Index].x = atof(chr);
tok = std::strtok(chr, " ");
}
if(k == 1){sphere_points[Index].y = atof(tok);}
if(k == 2){
sphere_points[Index].z = atof(tok);
sphere_points[Index].w = 1.0;
}
tok = std::strtok(NULL, " ");
}
Index ++;
delete chr;
}
}
}
void WCX_sphere::setColor(color4 uniformColor){
for(int i=0; i<this->vertex_size; i++){
this->sphere_colors[i] = uniformColor;
}
}
int WCX_sphere::rollingFromAToB(point4 A, point4 B, mat4 lastRotateM){
accumuRollingM = lastRotateM;
this->rollingDirection = B-A;
this->rollingAxis = cross(vec4(0.0,1.0,0.0,0.0),rollingDirection);
this->rollingStart = A;
return int(length(A-B)/radius/rollingSpeed);
}
mat4 WCX_sphere::rollingFramePosition(int frame){
vec4 currentCenter = this->rollingStart + frame*this->rollingSpeed*this->radius*normalize(this->rollingDirection);
return Translate(currentCenter.x,currentCenter.y,currentCenter.z);
}
mat4 WCX_sphere::rollingFrameRotate(int frame){
mat4 currentRotateM = Rotate(this->rollingSpeed*frame*180/PI, rollingAxis.x, rollingAxis.y, rollingAxis.z);
return currentRotateM*accumuRollingM;
}
void WCX_sphere::setShadowColor(color4 sColor){
for(int i=0; i<this->vertex_size; i++){
this->shadow_colors[i] = sColor;
}
}
void WCX_sphere::setMaterial(){
this->lp.material_ambient = color4(0.2, 0.2, 0.2, 1.0);
this->lp.material_diffuse = color4(1.0, 0.84, 0.0, 1.0);
this->lp.material_specular = color4(1.0, 0.84, 0.0, 1.0);
this->lp.material_shininess = 125.0;
}
void WCX_sphere::setFlatNormals(){
for(int i=0; i<this->vertex_size/3; i++){
point4 a = this->sphere_points[i*3+1] - this->sphere_points[i*3];
point4 b = this->sphere_points[i*3+2] - this->sphere_points[i*3+1];
point3 a3(a.x, a.y, a.z), b3(b.x, b.y, b.z);
point3 vNormal = cross(a3,b3);
vNormal = normalize(vNormal);
for(int j=0; j<3; j++) this->sphere_normals[i*3+j] = vNormal;
}
}
/*
1: texture mapping for ground
2: vertical in obj frame
3: slanted in obj frame
4: vertical in eye frame
5: slanted in eye frame
in 2D, +4
default: no texture
*/
int WCX_sphere::getTextureAppFlag(){
if(!this->textureFlag || !this->fill_flag) return 0;
return this->textureCoordFrame+this->textureCoordDir+4*this->texture2D;
} | 31.247788 | 115 | 0.676012 | wiali |
d7c423c2acd7b2ced416356011573640a72a63a2 | 1,028 | cpp | C++ | Test/Header Generator/Sheet.cpp | BartoszMilewski/CodeCoop | 7d29f53ccf65b0d29ea7d6781a74507b52c08d0d | [
"MIT"
] | 67 | 2018-03-02T10:50:02.000Z | 2022-03-23T18:20:29.000Z | Test/Header Generator/Sheet.cpp | BartoszMilewski/CodeCoop | 7d29f53ccf65b0d29ea7d6781a74507b52c08d0d | [
"MIT"
] | null | null | null | Test/Header Generator/Sheet.cpp | BartoszMilewski/CodeCoop | 7d29f53ccf65b0d29ea7d6781a74507b52c08d0d | [
"MIT"
] | 9 | 2018-03-01T16:38:28.000Z | 2021-03-02T16:17:09.000Z | //---------------------------
// Sheet.cpp
// (c) Reliable Software 2000
//---------------------------
#include "HeaderDetails.h"
#include "GeneralPage.h"
#include "AddressPage.h"
#include "AddendumPage.h"
#include "DestinationPage.h"
#include "resource.h"
#include <Ctrl/PropertySheet.h>
bool CollectData (HINSTANCE hInst, HeaderDetails & details)
{
Property::Sheet sheet (hInst, "Script Generator", 5);
GeneralCtrl generalCtrl (details);
sheet.InitPage (0, IDD_GENERAL, generalCtrl, false, "General");
AddressCtrl senderAddressCtrl (details, false);
sheet.InitPage (1, IDD_ADDRESS, senderAddressCtrl, false, "Sender");
AddressCtrl recipAddressCtrl (details, true);
sheet.InitPage (2, IDD_ADDRESS, recipAddressCtrl, false, "Recipient");
AddendumCtrl addendumCtrl (details);
sheet.InitPage (3, IDD_ADDENDUM, addendumCtrl, false, "Addendums");
DestinationCtrl destinationCtrl (details);
sheet.InitPage (4, IDD_DESTINATION, destinationCtrl, false, "Destination");
return sheet.Run () && !details._wasCanceled;
}
| 34.266667 | 76 | 0.715953 | BartoszMilewski |
d7c52c07b55bbcdf6c475fff9bad6c8f03d98826 | 477 | cpp | C++ | PAT_B/PAT_B1038.cpp | EnhydraGod/PATCode | ff38ea33ba319af78b3aeba8aa6c385cc5e8329f | [
"BSD-2-Clause"
] | 3 | 2019-07-08T05:20:28.000Z | 2021-09-22T10:53:26.000Z | PAT_B/PAT_B1038.cpp | EnhydraGod/PATCode | ff38ea33ba319af78b3aeba8aa6c385cc5e8329f | [
"BSD-2-Clause"
] | null | null | null | PAT_B/PAT_B1038.cpp | EnhydraGod/PATCode | ff38ea33ba319af78b3aeba8aa6c385cc5e8329f | [
"BSD-2-Clause"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int n, tempScore;
int scores[110];
int main()
{
fill(scores, scores+110, 0);
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", &tempScore);
scores[tempScore]++;
}
int m;
scanf("%d", &m);
for (int i = 0; i < m; i++)
{
scanf("%d", &tempScore);
if(i == 0) printf("%d", scores[tempScore]);
else printf(" %d", scores[tempScore]);
}
return 0;
} | 20.73913 | 51 | 0.480084 | EnhydraGod |
d7ca74d143c157dbac612bcd2295f0ece5f07117 | 411 | cpp | C++ | c++/maratona/cultivando string/cultivando strings.cpp | felipeMachado92/programas-em-C- | 55d675110e495c7bcceb2b1bf2d32d582a445b40 | [
"MIT"
] | null | null | null | c++/maratona/cultivando string/cultivando strings.cpp | felipeMachado92/programas-em-C- | 55d675110e495c7bcceb2b1bf2d32d582a445b40 | [
"MIT"
] | null | null | null | c++/maratona/cultivando string/cultivando strings.cpp | felipeMachado92/programas-em-C- | 55d675110e495c7bcceb2b1bf2d32d582a445b40 | [
"MIT"
] | null | null | null | #include<iostream>
#include<string.h>
using namespace std;
string menorString(string vt[], int n){
string menor;
for(int i = 0; i < n; i++){
if((i == 0) || (menor.length()>vt[i].length())){
menor = vt[i];
}
}
return menor;
}
int main(){
int n=-1;
int contadorSeq=0;
while(n!=0){
cin>>n;
string vetorString[n];
for(int i = 0; i < n;i++){
cin>>vetorString[i];
}
}
return 0;
}
| 13.258065 | 50 | 0.557178 | felipeMachado92 |
d7d3baf1538d4aec4ab2a38d23f58c9d1a36c1fd | 2,936 | cpp | C++ | src/ast/ast_visitor.cpp | profelis/daScript | eea57f39dec4dd6168ee64c8ae5139cbcf2937bc | [
"BSD-3-Clause"
] | 421 | 2019-08-15T15:40:04.000Z | 2022-03-29T06:59:06.000Z | src/ast/ast_visitor.cpp | profelis/daScript | eea57f39dec4dd6168ee64c8ae5139cbcf2937bc | [
"BSD-3-Clause"
] | 55 | 2019-08-17T13:50:53.000Z | 2022-03-25T17:58:38.000Z | src/ast/ast_visitor.cpp | profelis/daScript | eea57f39dec4dd6168ee64c8ae5139cbcf2937bc | [
"BSD-3-Clause"
] | 58 | 2019-08-22T17:04:13.000Z | 2022-03-25T17:43:28.000Z | #include "daScript/misc/platform.h"
#include "daScript/ast/ast_visitor.h"
#include "daScript/ast/ast_expressions.h"
namespace das {
struct AstContextVisitor : Visitor {
AstContextVisitor ( Expression * expr )
: refExpr(expr) { }
AstContext astc, astr;
Expression * refExpr = nullptr;
int32_t count = 0;
// expression
virtual void preVisitExpression ( Expression * expr ) override {
Visitor::preVisitExpression(expr);
if ( expr==refExpr ) {
count ++;
if ( count==1 ) {
astr = astc;
astr.valid = true;
}
}
}
// function
virtual void preVisit ( Function * f ) override {
Visitor::preVisit(f);
astc.func = f;
}
virtual FunctionPtr visit ( Function * that ) override {
// if any of this asserts failed, there is logic error in how we pop
DAS_ASSERT(astc.loop.size()==0);
DAS_ASSERT(astc.scopes.size()==0);
DAS_ASSERT(astc.blocks.size()==0);
DAS_ASSERT(astc.with.size()==0);
astc.func.reset();
return Visitor::visit(that);
}
// ExprWith
virtual void preVisit ( ExprWith * expr ) override {
Visitor::preVisit(expr);
astc.with.push_back(expr);
}
virtual ExpressionPtr visit ( ExprWith * expr ) override {
astc.with.pop_back();
return Visitor::visit(expr);
}
// ExprFor
virtual void preVisit ( ExprFor * expr ) override {
Visitor::preVisit(expr);
astc.loop.push_back(expr);
}
virtual ExpressionPtr visit ( ExprFor * expr ) override {
astc.loop.pop_back();
return Visitor::visit(expr);
}
// ExprWhile
virtual void preVisit ( ExprWhile * expr ) override {
Visitor::preVisit(expr);
astc.loop.push_back(expr);
}
virtual ExpressionPtr visit ( ExprWhile * expr ) override {
astc.loop.pop_back();
return Visitor::visit(expr);
}
// ExprBlock
virtual void preVisit ( ExprBlock * block ) override {
Visitor::preVisit(block);
if ( block->isClosure ) {
astc.blocks.push_back(block);
}
astc.scopes.push_back(block);
}
virtual ExpressionPtr visit ( ExprBlock * block ) override {
astc.scopes.pop_back();
if ( block->isClosure ) {
astc.blocks.pop_back();
}
return Visitor::visit(block);
}
};
AstContext generateAstContext( const ProgramPtr & prog, Expression * expr ) {
AstContextVisitor acv(expr);
prog->visit(acv);
return acv.count==1 ? acv.astr : AstContext();
}
}
| 32.988764 | 81 | 0.530313 | profelis |
d7d7cb00808619b584c4f783452209d095657916 | 15,633 | cpp | C++ | src/test/test_parser_expr.cpp | paramah/hiphop-php-osx | 5ed8c24abe8ad9fd7bc6dd4c28b4ffff23e54362 | [
"PHP-3.01",
"Zend-2.0"
] | 1 | 2015-11-05T21:45:07.000Z | 2015-11-05T21:45:07.000Z | src/test/test_parser_expr.cpp | brion/hiphop-php | df70a236e6418d533ac474be0c01f0ba87034d7f | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | src/test/test_parser_expr.cpp | brion/hiphop-php | df70a236e6418d533ac474be0c01f0ba87034d7f | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include <test/test_parser_expr.h>
///////////////////////////////////////////////////////////////////////////////
bool TestParserExpr::RunTests(const std::string &which) {
bool ret = true;
RUN_TEST(TestExpressionList);
RUN_TEST(TestAssignmentExpression);
RUN_TEST(TestSimpleVariable);
RUN_TEST(TestDynamicVariable);
RUN_TEST(TestStaticMemberExpression);
RUN_TEST(TestArrayElementExpression);
RUN_TEST(TestStringOffsetExpression);
RUN_TEST(TestDynamicFunctionCall);
RUN_TEST(TestSimpleFunctionCall);
RUN_TEST(TestScalarExpression);
RUN_TEST(TestObjectPropertyExpression);
RUN_TEST(TestObjectMethodExpression);
RUN_TEST(TestListAssignment);
RUN_TEST(TestNewObjectExpression);
RUN_TEST(TestUnaryOpExpression);
RUN_TEST(TestBinaryOpExpression);
RUN_TEST(TestQOpExpression);
RUN_TEST(TestArrayPairExpression);
RUN_TEST(TestClassConstantExpression);
RUN_TEST(TestParameterExpression);
RUN_TEST(TestModifierExpression);
RUN_TEST(TestConstant);
RUN_TEST(TestEncapsListExpression);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
bool TestParserExpr::TestExpressionList() {
// TestUnsetStatement
// TestEchoStatement
// TestForStatement
// TestObjectPropertyExpression
// TestListAssignment
// TestUnaryOpExpression - internal_functions - isset_variables
return true;
}
bool TestParserExpr::TestAssignmentExpression() {
V("<?php $a = 1;", "$a = 1;\n");
V("<?php $a = &$b;", "$a = &$b;\n");
V("<?php $a = &new Test();", "$a = &new test();\n");
V("<?php $a = &new $b();", "$a = &new $b();\n");
V("<?php $a = &new $$b();", "$a = &new ${$b}();\n");
V("<?php $a = &new Test::$b();", "$a = &new test::$b();\n");
V("<?php $a = &new $b->c();", "$a = &new $b->c();\n");
V("<?php $a = &new $b->c->d();", "$a = &new $b->c->d();\n");
return true;
}
bool TestParserExpr::TestSimpleVariable() {
V("<?php $a = $a;", "$a = $a;\n");
return true;
}
bool TestParserExpr::TestDynamicVariable() {
V("<?php $a = ${$a + $b};", "$a = ${$a + $b};\n");
V("<?php $a = $$a;", "$a = ${$a};\n");
V("<?php $a = ${$a};", "$a = ${$a};\n");
V("<?php $a = $$$a;", "$a = ${${$a}};\n");
return true;
}
bool TestParserExpr::TestStaticMemberExpression() {
V("<?php $a = Test::$a;", "$a = test::$a;\n");
return true;
}
bool TestParserExpr::TestArrayElementExpression() {
V("<?php $a = $b[$a + $b];", "$a = $b[$a + $b];\n");
V("<?php $a = $b[];", "$a = $b[];\n");
return true;
}
bool TestParserExpr::TestStringOffsetExpression() {
V("<?php $a = $b{$a + $b};", "$a = $b[$a + $b];\n");
return true;
}
bool TestParserExpr::TestDynamicFunctionCall() {
V("<?php $test();", "$test();\n");
V("<?php Test::$test();", "test::$test();\n");
return true;
}
bool TestParserExpr::TestSimpleFunctionCall() {
V("<?php test();", "test();\n");
V("<?php Test::test();", "test::test();\n");
V("<?php test(&$a);", "test($a);\n");
return true;
}
bool TestParserExpr::TestScalarExpression() {
V("<?php A;", "A;\n"); // T_STRING
V("<?php \"$a[0xFF]\";", "$a[0xFF];\n"); // T_NUM_STRING
V("<?php 12;", "12;\n"); // T_LNUMBER
V("<?php 0xFF;", "0xFF;\n"); // T_LNUMBER
V("<?php 1.2;", "1.2;\n"); // T_DNUMBER
V("<?php 'A';", "'A';\n"); // T_CONSTANT_ENCAPSED_STRING
V("<?php \"A\";", "'A';\n"); // T_CONSTANT_ENCAPSED_STRING
V("<?php __LINE__;", "__LINE__;\n"); // T_LINE
V("<?php __FILE__;", "__FILE__;\n"); // T_FILE
V("<?php __CLASS__;", "__CLASS__;\n"); // T_CLASS_C
V("<?php __METHOD__;", "__METHOD__;\n"); // T_METHOD_C
V("<?php __FUNCTION__;", "__FUNCTION__;\n"); // T_FUNC_C
V("<?php \"${a}\";", "$a;\n"); // T_STRING_VARNAME
return true;
}
bool TestParserExpr::TestObjectPropertyExpression() {
V("<?php print $b->c;", "print $b->c;\n");
V("<?php print ${b}->c;", "print ${b}->c;\n");
V("<?php print ${$b}->c;", "print ${$b}->c;\n");
V("<?php print $b[]->c;", "print $b[]->c;\n");
V("<?php print $b[$a]->c;", "print $b[$a]->c;\n");
V("<?php print $b{$a}->c;", "print $b[$a]->c;\n");
V("<?php print $b{$a}[]->c;", "print $b[$a][]->c;\n");
V("<?php print $b{$a}[$c]->c;", "print $b[$a][$c]->c;\n");
V("<?php print $b{$a}[$c]{$d}->c;", "print $b[$a][$c][$d]->c;\n");
V("<?php print $b{$a}[$c]{$d}->c[];", "print $b[$a][$c][$d]->c[];\n");
V("<?php print $b{$a}[$c]{$d}->c[$e];", "print $b[$a][$c][$d]->c[$e];\n");
V("<?php print $b{$a}[$c]{$d}->c{$e};", "print $b[$a][$c][$d]->c[$e];\n");
V("<?php print $b{$a}[$c]{$d}->c{$e}->f;",
"print $b[$a][$c][$d]->c[$e]->f;\n");
V("<?php print $b{$a}[$c]{$d}->c{$e}->f[];",
"print $b[$a][$c][$d]->c[$e]->f[];\n");
return true;
}
bool TestParserExpr::TestObjectMethodExpression() {
V("<?php echo $b->c();", "echo $b->c();\n");
V("<?php echo ${b}->c();", "echo ${b}->c();\n");
V("<?php echo ${$b}->c();", "echo ${$b}->c();\n");
V("<?php echo $b[]->c();", "echo $b[]->c();\n");
V("<?php echo $b[$a]->c();", "echo $b[$a]->c();\n");
V("<?php echo $b{$a}->c();", "echo $b[$a]->c();\n");
V("<?php echo $b{$a}[]->c();", "echo $b[$a][]->c();\n");
V("<?php echo $b{$a}[$c]->c();", "echo $b[$a][$c]->c();\n");
V("<?php echo $b{$a}[$c]{$d}->c();", "echo $b[$a][$c][$d]->c();\n");
V("<?php echo $b{$a}[$c]{$d}->c[]();", "echo $b[$a][$c][$d]->c[]();\n");
V("<?php echo $b{$a}[$c]{$d}->c[$e]();", "echo $b[$a][$c][$d]->c[$e]();\n");
V("<?php echo $b{$a}[$c]{$d}->c{$e}();", "echo $b[$a][$c][$d]->c[$e]();\n");
V("<?php echo $b{$a}[$c]{$d}->c{$e}->f();",
"echo $b[$a][$c][$d]->c[$e]->f();\n");
V("<?php echo $b{$a}[$c]{$d}->c{$e}->f[]();",
"echo $b[$a][$c][$d]->c[$e]->f[]();\n");
V("<?php $b{$a}[$c]{$d}($p1,$p2)->c{$e}($p3,$p4)->f[]($p5,$p6);",
"$b[$a][$c][$d]($p1, $p2)->c[$e]($p3, $p4)->f[]($p5, $p6);\n");
return true;
}
bool TestParserExpr::TestListAssignment() {
V("<?php list() = 1;", "list() = 1;\n");
V("<?php list(,) = 1;", "list(, ) = 1;\n");
V("<?php list($a,) = 1;", "list($a, ) = 1;\n");
V("<?php list(,$b) = 1;", "list(, $b) = 1;\n");
V("<?php list($b) = 1;", "list($b) = 1;\n");
V("<?php list($a,$b) = 1;", "list($a, $b) = 1;\n");
V("<?php list($a,list($c),$b) = 1;", "list($a, list($c), $b) = 1;\n");
V("<?php list($a,list(),$b) = 1;", "list($a, list(), $b) = 1;\n");
return true;
}
bool TestParserExpr::TestNewObjectExpression() {
V("<?php new Test;", "new test();\n");
V("<?php new $b();", "new $b();\n");
V("<?php new $b;", "new $b();\n");
return true;
}
bool TestParserExpr::TestUnaryOpExpression() {
V("<?php clone $a;", "clone $a;\n");
V("<?php ++$a;", "++$a;\n");
V("<?php --$a;", "--$a;\n");
V("<?php $a++;", "$a++;\n");
V("<?php $a--;", "$a--;\n");
V("<?php +$a;", "+$a;\n");
V("<?php -$a;", "-$a;\n");
V("<?php !$a;", "!$a;\n");
V("<?php ~$a;", "~$a;\n");
V("<?php ($a);", "($a);\n");
V("<?php (int)$a;", "(int)$a;\n");
V("<?php (real)$a;", "(real)$a;\n");
V("<?php (string)$a;", "(string)$a;\n");
V("<?php (array)$a;", "(array)$a;\n");
V("<?php (object)$a;", "(object)$a;\n");
V("<?php (bool)$a;", "(bool)$a;\n");
V("<?php (unset)$a;", "(unset)$a;\n");
V("<?php exit;", "exit();\n");
V("<?php exit();", "exit();\n");
V("<?php exit($a);", "exit($a);\n");
V("<?php @$a;", "@$a;\n");
V("<?php array($a);", "array($a);\n");
V("<?php print $a;", "print $a;\n");
V("<?php isset($a);", "isset($a);\n");
V("<?php empty($a);", "empty($a);\n");
V("<?php include $a;", "include $a;\n");
V("<?php include_once 1;", "include_once 1;\n");
V("<?php eval($a);", "eval($a);\n");
V("<?php require $a;", "require $a;\n");
V("<?php require_once 1;", "require_once 1;\n");
return true;
}
bool TestParserExpr::TestBinaryOpExpression() {
V("<?php $a += A;", "$a += A;\n");
V("<?php $a -= A;", "$a -= A;\n");
V("<?php $a *= A;", "$a *= A;\n");
V("<?php $a /= A;", "$a /= A;\n");
V("<?php $a .= A;", "$a .= A;\n");
V("<?php $a %= A;", "$a %= A;\n");
V("<?php $a &= A;", "$a &= A;\n");
V("<?php $a |= A;", "$a |= A;\n");
V("<?php $a ^= A;", "$a ^= A;\n");
V("<?php $a <<= A;", "$a <<= A;\n");
V("<?php $a >>= A;", "$a >>= A;\n");
V("<?php $a || A;", "$a || A;\n");
V("<?php $a && A;", "$a && A;\n");
V("<?php $a or A;", "$a or A;\n");
V("<?php $a and A;", "$a and A;\n");
V("<?php $a xor A;", "$a xor A;\n");
V("<?php $a | A;", "$a | A;\n");
V("<?php $a & A;", "$a & A;\n");
V("<?php $a ^ A;", "$a ^ A;\n");
V("<?php $a . A;", "$a . A;\n");
V("<?php $a + A;", "$a + A;\n");
V("<?php $a - A;", "$a - A;\n");
V("<?php $a * A;", "$a * A;\n");
V("<?php $a / A;", "$a / A;\n");
V("<?php $a % A;", "$a % A;\n");
V("<?php $a << A;", "$a << A;\n");
V("<?php $a >> A;", "$a >> A;\n");
V("<?php $a === A;", "$a === A;\n");
V("<?php $a !== A;", "$a !== A;\n");
V("<?php $a == A;", "$a == A;\n");
V("<?php $a != A;", "$a != A;\n");
V("<?php $a < A;", "$a < A;\n");
V("<?php $a <= A;", "$a <= A;\n");
V("<?php $a > A;", "$a > A;\n");
V("<?php $a >= A;", "$a >= A;\n");
V("<?php $a instanceof A;", "$a instanceof A;\n");
return true;
}
bool TestParserExpr::TestQOpExpression() {
V("<?php $a ? 2 : 3;", "$a ? 2 : 3;\n");
return true;
}
bool TestParserExpr::TestArrayPairExpression() {
V("<?php array();", "array();\n");
V("<?php array($a);", "array($a);\n");
V("<?php array($a, $b);", "array($a, $b);\n");
V("<?php array($a, $b,);", "array($a, $b);\n");
V("<?php array($a => $b);", "array($a => $b);\n");
V("<?php array($a => $b, $c => $d);", "array($a => $b, $c => $d);\n");
V("<?php array($a => $b, $c => $d,);", "array($a => $b, $c => $d);\n");
V("<?php array(&$a);", "array(&$a);\n");
V("<?php array(&$a, &$b);", "array(&$a, &$b);\n");
V("<?php array($a => &$b);", "array($a => &$b);\n");
V("<?php array($a => &$b, $c => &$d);", "array($a => &$b, $c => &$d);\n");
V("<?php function a() { static $a = array();}",
"function a() {\n static $a = array();\n}\n");
V("<?php function a() { static $a = array(a);}",
"function a() {\n static $a = array(a);\n}\n");
V("<?php function a() { static $a = array(a, b);}",
"function a() {\n static $a = array(a, b);\n}\n");
V("<?php function a() { static $a = array(a, b,);}",
"function a() {\n static $a = array(a, b);\n}\n");
V("<?php function a() { static $a = array(a => b);}",
"function a() {\n static $a = array(a => b);\n}\n");
V("<?php function a() { static $a = array(a => b, c => d);}",
"function a() {\n static $a = array(a => b, c => d);\n}\n");
V("<?php function a() { static $a = array(a => b, c => d,);}",
"function a() {\n static $a = array(a => b, c => d);\n}\n");
return true;
}
bool TestParserExpr::TestClassConstantExpression() {
V("<?php function a() { static $a = A::b;}",
"function a() {\n static $a = a::b;\n}\n");
return true;
}
bool TestParserExpr::TestParameterExpression() {
V("<?php function a() {}", "function a() {\n}\n");
V("<?php function a($a) {}", "function a($a) {\n}\n");
V("<?php function a($a,$b) {}", "function a($a, $b) {\n}\n");
V("<?php function a(&$a) {}", "function a(&$a) {\n}\n");
V("<?php function a(&$a,$b) {}", "function a(&$a, $b) {\n}\n");
V("<?php function a($a,&$b) {}", "function a($a, &$b) {\n}\n");
V("<?php function a(TT $a) {}", "function a(tt $a) {\n}\n");
V("<?php function a(array $a) {}", "function a(array $a) {\n}\n");
V("<?php function a($a=1) {}", "function a($a = 1) {\n}\n");
V("<?php function a($a=1,$b) {}", "function a($a = 1, $b = null) {\n}\n");
V("<?php function a($a,$b=1) {}", "function a($a, $b = 1) {\n}\n");
return true;
}
bool TestParserExpr::TestModifierExpression() {
V("<?php class a { public $a;}", "class a {\n public $a = null;\n}\n");
V("<?php class a { protected $a;}", "class a {\n protected $a = null;\n}\n");
V("<?php class a { private $a;}", "class a {\n private $a = null;\n}\n");
V("<?php class a { static $a;}", "class a {\n static $a = null;\n}\n");
V("<?php class a { abstract $a;}", "class a {\n abstract $a = null;\n}\n");
V("<?php class a { final $a;}", "class a {\n final $a = null;\n}\n");
V("<?php class a { public static $a;}",
"class a {\n public static $a = null;\n}\n");
return true;
}
bool TestParserExpr::TestConstant() {
V("<?php class a { const A = 1;}", "class a {\n const A = 1;\n}\n");
V("<?php class a { const A=1,B=2;}","class a {\n const A = 1, B = 2;\n}\n");
return true;
}
bool TestParserExpr::TestEncapsListExpression() {
V("<?php '\\'\\\\\\\"';", "\"'\\\\\\\\\".'\"';\n");
V("<?php '$a$b';", "'$a$b';\n");
V("<?php \"$a$b\";", "$a . $b;\n");
V("<?php <<<EOM\n$a$b\nEOM;\n", "$a . $b . '';\n");
V("<?php `$a$b`;", "shell_exec($a . $b);\n");
V("<?php \"[\\b$/\";", "'['.\"\\\\\".'b$/';\n");
V("<?php \"]\\b$/\";", "']'.\"\\\\\".'b$/';\n");
V("<?php \"{\\b$/\";", "'{'.\"\\\\\".'b$/';\n");
V("<?php \"}\\b$/\";", "'}'.\"\\\\\".'b$/';\n");
V("<?php \"->\\b$/\";", "'->'.\"\\\\\".'b$/';\n");
V("<?php \"$a[b]\";", "$a['b'];\n");
V("<?php \"\\\"\";", "'\"';\n");
V("<?php \"\\n\";", "\"\\n\";\n");
V("<?php \"\\n$a\";", "\"\\n\" . $a;\n");
V("<?php \"\\\"$a\";", "'\"' . $a;\n");
V("<?php \"\\$a\";", "'$a';\n");
V("<?php \"${a}\";", "$a;\n");
return true;
}
| 42.024194 | 80 | 0.398196 | paramah |
d7d8c3d0b913511300546c46a03953144eb644bc | 1,121 | hpp | C++ | engine/include/xe/gfx/framebuffer.hpp | trbflxr/x808 | d5ab9e96c5a6109283151a591c261e4183628075 | [
"MIT"
] | null | null | null | engine/include/xe/gfx/framebuffer.hpp | trbflxr/x808 | d5ab9e96c5a6109283151a591c261e4183628075 | [
"MIT"
] | null | null | null | engine/include/xe/gfx/framebuffer.hpp | trbflxr/x808 | d5ab9e96c5a6109283151a591c261e4183628075 | [
"MIT"
] | null | null | null | //
// Created by FLXR on 8/8/2018.
//
#ifndef X808_FRAMEBUFFER_HPP
#define X808_FRAMEBUFFER_HPP
#include <unordered_map>
#include <xe/gfx/texture.hpp>
namespace xe {
namespace internal {
class PlatformFrameBuffer;
}
class XE_API FrameBuffer {
public:
explicit FrameBuffer(const string &name);
~FrameBuffer();
void load(const std::unordered_map<Attachment, const Texture *> &attachments);
void copy(FrameBuffer *dest);
void bindDrawAttachment(Attachment attachment) const;
void bindDrawAttachments(Attachment *attachments, uint size) const;
void bindReadAttachment(Attachment attachment) const;
void bindDraw(Attachment attachment) const;
void bindDraw(Attachment *attachments, uint size) const;
void bindRead(Attachment attachment) const;
void unbind() const;
void bindTexture(Attachment attachment, const Texture *texture) const;
uint getHandle() const;
const string &getName() const;
const Texture *getTexture(Attachment attachment) const;
private:
internal::PlatformFrameBuffer *buffer;
};
}
#endif //X808_FRAMEBUFFER_HPP
| 22.42 | 82 | 0.734166 | trbflxr |
d7da649564f7783142a2ed74288a07ebdf6b16c7 | 1,668 | hpp | C++ | EdenEngine/ComponentHeader/EditorGUI.hpp | HuajiKojima/EdenEngine | 9445df98b3735570ded80ca018c01db1819fc944 | [
"MIT"
] | null | null | null | EdenEngine/ComponentHeader/EditorGUI.hpp | HuajiKojima/EdenEngine | 9445df98b3735570ded80ca018c01db1819fc944 | [
"MIT"
] | null | null | null | EdenEngine/ComponentHeader/EditorGUI.hpp | HuajiKojima/EdenEngine | 9445df98b3735570ded80ca018c01db1819fc944 | [
"MIT"
] | null | null | null | // Eden Engine
#pragma once
#ifndef EDEN_EDITOR_GUI
#define EDEN_EDITOR_GUI
#include "DevelopmentKit/ImGui/imgui.h"
#include "DevelopmentKit/ImGui/imgui_impl_glfw.h"
#include "DevelopmentKit/ImGui/imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>
#define EDEN_GUI_CLASSIC 0
#define EDEN_GUI_DARK 1
#define EDEN_GUI_LIGHT 2
namespace EDEN
{
void GUIInit(GLFWwindow *window, int editorStyle, const char *editorFont);
void GUINewFrame();
void GUIRender();
void GUIShutdown();
void GUIInit(GLFWwindow *window, int editorStyle, const char *editorFont)
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO & io = ImGui::GetIO();
(void)io;
io.Fonts->AddFontFromFileTTF(editorFont, 24.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
// Init Editor Style
//-----------------------------------------------------------------------------------------------
switch (editorStyle)
{
case EDEN_GUI_CLASSIC:
ImGui::StyleColorsClassic();
break;
case EDEN_GUI_DARK:
ImGui::StyleColorsDark();
break;
case EDEN_GUI_LIGHT:
ImGui::StyleColorsLight();
break;
default:
// Throw the exception
break;
}
//-----------------------------------------------------------------------------------------------
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 330");
}
void GUINewFrame()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void GUIRender()
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
void GUIShutdown()
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
}
#endif | 23.166667 | 99 | 0.645084 | HuajiKojima |
d7e8f956541e660cb9911c92aba3612797edb98c | 1,623 | hpp | C++ | attic/src/main/include/fmp/utils.hpp | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | null | null | null | attic/src/main/include/fmp/utils.hpp | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | 8 | 2017-09-28T14:39:37.000Z | 2021-03-09T22:55:55.000Z | attic/src/main/include/fmp/utils.hpp | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | null | null | null | // Copyright Yamashta, Daisuke 2017
// 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)
#if !defined(FMP_34923AEE_9F31_49B2_AD8D_D975BE25512D)
#define FMP_34923AEE_9F31_49B2_AD8D_D975BE25512D
#include <fmp/primitive.hpp>
#include <fmp/utils_fwd.hpp>
#include <fmp/apply.hpp>
#include <fmp/sequence.hpp>
namespace fmp {
template <typename T>
using head_t = typename head<T>::type;
template <typename F>
struct get_mf {
using type = undefined_type;
};
template <template <class...> typename F,
typename... A>
struct get_mf<F<A...>> {
template <typename... P>
using type = F<P...>;
};
template <typename F, typename A0, typename A1>
struct flip {
using type = apply_t<F, A1, A0>;
};
template <template <class...> typename C,
typename... A>
using flipf = make_curried_hf<flip, C, A...>;
template <typename... T>
struct first {
using type = head_t<sequence<T...>>;
};
template <typename... T>
using first_t = typename first<T...>::type;
template <typename... Args>
struct apply_args {
template <typename... F>
using apply = id<apply_t<first_t<F...>, Args...>>;
};
template <template <class...> typename Src,
template <class...> typename Dest,
typename... P>
struct copy<Src<P...>, Dest> {
using type = Dest<P...>;
};
template <typename Src,
template <class...> typename Dest
>
using copy_t = typename copy<Src, Dest>::type;
} /* ns: fmp */
#endif /* if not defined 'FMP_34923AEE_9F31_49B2_AD8D_D975BE25512D' */
| 23.521739 | 70 | 0.661121 | yamasdais |
d7f0d2fc58ddbc364e7fd1e3b7727940141a5c29 | 2,767 | cpp | C++ | unity-screen-capture-plugin/dllmain.cpp | BillWCJ/unity-windows-screen-capture | a8cbadb7d0607b3d3f69673e2f5ded377d4cc620 | [
"MIT"
] | null | null | null | unity-screen-capture-plugin/dllmain.cpp | BillWCJ/unity-windows-screen-capture | a8cbadb7d0607b3d3f69673e2f5ded377d4cc620 | [
"MIT"
] | null | null | null | unity-screen-capture-plugin/dllmain.cpp | BillWCJ/unity-windows-screen-capture | a8cbadb7d0607b3d3f69673e2f5ded377d4cc620 | [
"MIT"
] | null | null | null | #include "pch.h"
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/*
// debug event
static FuncPtr s_debug;
extern "C" void UNITY_INTERFACE_EXPORT SetDebugFunction(FuncPtr debug) { s_debug = debug; }
// --------------------------------------------------------------------------
// UnitySetInterfaces
static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType eventType);
static IUnityInterfaces* s_UnityInterfaces = NULL;
static IUnityGraphics* s_Graphics = NULL;
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces * unityInterfaces)
{
std::cout << "Starting Plugin" << std::endl;
s_UnityInterfaces = unityInterfaces;
s_Graphics = s_UnityInterfaces->Get<IUnityGraphics>();
s_Graphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent);
// Run OnGraphicsDeviceEvent(initialize) manually on plugin load
OnGraphicsDeviceEvent(kUnityGfxDeviceEventInitialize);
}
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginUnload()
{
s_Graphics->UnregisterDeviceEventCallback(OnGraphicsDeviceEvent);
}
// --------------------------------------------------------------------------
// GraphicsDeviceEvent
static PluginManager* s_CurrentAPI = NULL;
static UnityGfxRenderer s_DeviceType = kUnityGfxRendererNull;
static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType eventType)
{
// Create graphics API implementation upon initialization
if (eventType == kUnityGfxDeviceEventInitialize)
{
assert(s_CurrentAPI == NULL);
s_DeviceType = s_Graphics->GetRenderer();
s_CurrentAPI = CreatePluginManager(s_DeviceType, s_debug, s_UnityInterfaces);
}
// Let the implementation process the device related events
if (s_CurrentAPI)
{
s_CurrentAPI->ProcessDeviceEvent(eventType, s_UnityInterfaces);
}
// Cleanup graphics API implementation upon shutdown
if (eventType == kUnityGfxDeviceEventShutdown)
{
delete s_CurrentAPI;
s_CurrentAPI = NULL;
s_DeviceType = kUnityGfxRendererNull;
}
}
static void UNITY_INTERFACE_API OnRenderEvent(int eventID)
{
// Unknown / unsupported graphics device type? Do nothing
if (s_CurrentAPI == NULL)
return;
//DrawColoredTriangle();
//ModifyTexturePixels();
//ModifyVertexBuffer();
}
// --------------------------------------------------------------------------
// GetRenderEventFunc, an example function we export which is used to get a rendering event callback function.
extern "C" UnityRenderingEvent UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetRenderEventFunc()
{
return OnRenderEvent;
}
*/ | 26.605769 | 110 | 0.73184 | BillWCJ |
d7f5defa2bf394c33ebe012669b294fe54c34af2 | 2,358 | hpp | C++ | src/hardware/memory/register.hpp | geaz/emu-gameboy | da8a3e6898a0075dcb4371eb772e31695300ae54 | [
"MIT"
] | 47 | 2019-10-12T14:23:47.000Z | 2022-03-22T03:31:43.000Z | src/hardware/memory/register.hpp | geaz/emu-gameboy | da8a3e6898a0075dcb4371eb772e31695300ae54 | [
"MIT"
] | null | null | null | src/hardware/memory/register.hpp | geaz/emu-gameboy | da8a3e6898a0075dcb4371eb772e31695300ae54 | [
"MIT"
] | 2 | 2021-09-20T20:47:21.000Z | 2021-10-12T12:10:46.000Z | #pragma once
#ifndef REGISTER_H
#define REGISTER_H
#include <string>
namespace GGB::Hardware
{
template <class T>
class Register
{
public:
Register(const T initialValue);
T read();
uint8_t readBit(const uint8_t bitNr);
void writeBit(const uint8_t bitNr, const bool bitValue);
void operator=(T newValue);
void operator+=(T addValue);
void operator-=(T subValue);
void operator++(int ignored);
void operator--(int ignored);
private:
T value = 0;
};
template<class T> Register<T>::Register(const T initialValue) : value(initialValue) { }
template<class T> T Register<T>::read() { return value; }
template<class T> uint8_t Register<T>::readBit(const uint8_t bitNr) { return (value >> bitNr) & 0x1; }
template<class T> void Register<T>::writeBit(const uint8_t bitNr, const bool bitValue) { if(bitValue) value |= (0x1 << bitNr); else value &= ~(0x1 << bitNr); }
template<class T> void Register<T>::operator=(T newValue) { value = newValue; }
template<class T> void Register<T>::operator+=(T addValue) { value += addValue; }
template<class T> void Register<T>::operator-=(T subValue) { value -= subValue; }
template<class T> void Register<T>::operator++(int ignored) { value ++; }
template<class T> void Register<T>::operator--(int ignored) { value --; }
class RegisterPair
{
public:
RegisterPair(Register<uint8_t>& high, Register<uint8_t>& low) : high(high), low(low) { }
void write(uint16_t newValue)
{
high = (newValue & 0xFF00) >> 8;
low = (newValue & 0x00FF);
}
uint16_t read()
{
return (high.read() << 8) | low.read();
}
void operator++(int ignored)
{
uint16_t combined = read();
combined++;
write(combined);
}
void operator--(int ignored)
{
uint16_t combined = read();
combined--;
write(combined);
}
private:
Register<uint8_t>& high;
Register<uint8_t>& low;
};
}
#endif // REGISTER_H | 31.44 | 163 | 0.534775 | geaz |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.