blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5824b2ee311c4c8e5e99a63ec262afe96ce47657
|
2b1b459706bbac83dad951426927b5798e1786fc
|
/sdk/ctf/tests/pkg/fidl/cpp/message_unittest.cc
|
33aa0573352b72962b1947ef52c6ef143c4ec77d
|
[
"BSD-2-Clause"
] |
permissive
|
gnoliyil/fuchsia
|
bc205e4b77417acd4513fd35d7f83abd3f43eb8d
|
bc81409a0527580432923c30fbbb44aba677b57d
|
refs/heads/main
| 2022-12-12T11:53:01.714113
| 2022-01-08T17:01:14
| 2022-12-08T01:29:53
| 445,866,010
| 4
| 3
|
BSD-2-Clause
| 2022-10-11T05:44:30
| 2022-01-08T16:09:33
|
C++
|
UTF-8
|
C++
| false
| false
| 4,601
|
cc
|
message_unittest.cc
|
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fidl/test/handles/cpp/fidl.h>
#include <lib/fidl/cpp/message.h>
#include <lib/zx/channel.h>
#include <lib/zx/event.h>
#include <zxtest/zxtest.h>
namespace {
TEST(Message, BasicTests) {
uint8_t byte_buffer[ZX_CHANNEL_MAX_MSG_BYTES];
zx_handle_info_t handle_info_buffer[ZX_CHANNEL_MAX_MSG_HANDLES];
zx_handle_disposition_t handle_disposition_buffer[ZX_CHANNEL_MAX_MSG_HANDLES];
fidl_message_header_t header = {
.txid = 5u,
.ordinal = 42u,
};
char data[4] = "abc";
fidl_string_t str = {
.size = 3,
.data = data,
};
memcpy(byte_buffer, &header, sizeof(header));
memcpy(byte_buffer + sizeof(header), &str, sizeof(str));
memcpy(byte_buffer + sizeof(header) + sizeof(str), data, 3);
memset(byte_buffer + sizeof(header) + sizeof(str), 0, 5);
fidl::HLCPPOutgoingMessage outgoing_message(
fidl::BytePart(byte_buffer, ZX_CHANNEL_MAX_MSG_BYTES, sizeof(header) + sizeof(str) + 8),
fidl::HandleDispositionPart(handle_disposition_buffer, ZX_CHANNEL_MAX_MSG_HANDLES));
EXPECT_EQ(outgoing_message.txid(), 5u);
EXPECT_EQ(outgoing_message.ordinal(), 42u);
fidl::BytePart payload = fidl::BytePart(outgoing_message.body_view().bytes(), 0);
fidl_string_t* payload_str = reinterpret_cast<fidl_string_t*>(payload.data());
EXPECT_EQ(3, payload_str->size);
EXPECT_STREQ("abc", payload_str->data);
zx::channel h1, h2;
EXPECT_EQ(zx::channel::create(0, &h1, &h2), ZX_OK);
ASSERT_EQ(ZX_OK, outgoing_message.Write(h1.get(), 0u));
memset(byte_buffer, 0, ZX_CHANNEL_MAX_MSG_BYTES);
EXPECT_EQ(outgoing_message.txid(), 0u);
EXPECT_EQ(outgoing_message.ordinal(), 0u);
fidl::HLCPPIncomingMessage incoming_message(
fidl::BytePart(byte_buffer, ZX_CHANNEL_MAX_MSG_BYTES),
fidl::HandleInfoPart(handle_info_buffer, ZX_CHANNEL_MAX_MSG_HANDLES));
ASSERT_EQ(ZX_OK, incoming_message.Read(h2.get(), 0u));
EXPECT_EQ(incoming_message.txid(), 5u);
EXPECT_EQ(incoming_message.ordinal(), 42u);
}
TEST(Message, ReadErrorCodes) {
// Create a Message buffer.
constexpr size_t kBufferSize = 100;
uint8_t byte_buffer[kBufferSize];
fidl::HLCPPIncomingMessage message(fidl::BytePart::WrapEmpty(byte_buffer),
fidl::HandleInfoPart());
// Create a channel.
zx::channel client, server;
EXPECT_OK(zx::channel::create(0, &client, &server));
// Read from an empty channel.
EXPECT_EQ(message.Read(client.get(), /*flags=*/0), ZX_ERR_SHOULD_WAIT);
// Read with invalid flags.
EXPECT_EQ(message.Read(client.get(), /*flags=*/~0), ZX_ERR_NOT_SUPPORTED);
// Read a message smaller than the FIDL header size.
{
uint8_t write_buffer[1] = {0};
EXPECT_OK(
server.write(/*flags=*/0, &write_buffer, sizeof(write_buffer), /*handles=*/nullptr, 0));
EXPECT_EQ(message.Read(client.get(), /*flags=*/0), ZX_ERR_INVALID_ARGS);
}
// Read a message larger than our receive buffer.
{
uint8_t write_buffer[kBufferSize + 1];
memset(write_buffer, 0xff, sizeof(write_buffer));
EXPECT_OK(
server.write(/*flags=*/0, &write_buffer, sizeof(write_buffer), /*handles=*/nullptr, 0));
EXPECT_EQ(message.Read(client.get(), /*flags=*/ZX_CHANNEL_READ_MAY_DISCARD),
ZX_ERR_BUFFER_TOO_SMALL);
}
// Read from closed channel.
server.reset();
EXPECT_EQ(message.Read(client.get(), /*flags=*/0), ZX_ERR_PEER_CLOSED);
}
TEST(MessagePart, IsStlContainerTest) {
EXPECT_EQ(sizeof(uint8_t), sizeof(fidl::BytePart::value_type));
EXPECT_EQ(sizeof(zx_handle_t), sizeof(fidl::HandlePart::value_type));
EXPECT_EQ(sizeof(const uint8_t*), sizeof(fidl::BytePart::const_iterator));
EXPECT_EQ(sizeof(const zx_handle_t*), sizeof(fidl::HandlePart::const_iterator));
}
TEST(MessagePart, Size) {
fidl::HLCPPOutgoingMessage message;
EXPECT_EQ(message.bytes().size(), 0u);
uint8_t dummy_msg[42];
fidl::MessagePart msg(dummy_msg, 42, 10);
EXPECT_EQ(msg.size(), 10u);
fidl::MessagePart new_msg = std::move(msg);
EXPECT_EQ(new_msg.size(), 10u);
EXPECT_EQ(msg.size(), 0u);
}
TEST(MessagePart, WrapArray) {
uint8_t dummy[42];
auto full = fidl::MessagePart<uint8_t>::WrapFull(dummy);
EXPECT_EQ(full.data(), dummy);
EXPECT_EQ(full.actual(), 42);
EXPECT_EQ(full.capacity(), 42);
auto empty = fidl::MessagePart<uint8_t>::WrapEmpty(dummy);
EXPECT_EQ(empty.data(), dummy);
EXPECT_EQ(empty.actual(), 0);
EXPECT_EQ(empty.capacity(), 42);
}
} // namespace
|
1cbd161fcbeafd569fad30141cc01de3da8488ff
|
a8736e4a3fe09707bcf4faab285af51a1dbc1c98
|
/src/hashing.cpp
|
7009e216fbc3d531fc0ec4e5d6beaac4ae9f0abd
|
[] |
no_license
|
bengsparks/state-machine
|
e5bd464c702c1d04377feaa7637a73eeb85d4c8f
|
5b3dfd1e0c5ded725ac3130818fb4b5c7087aa5c
|
refs/heads/master
| 2020-04-27T02:25:51.699079
| 2019-03-05T19:18:20
| 2019-03-05T19:18:20
| 173,993,728
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 617
|
cpp
|
hashing.cpp
|
#include "../include/hashing.hpp"
#include "../include/event.hpp"
#include "../include/state.hpp"
#include "../include/transition.hpp"
using namespace sm_ns;
auto std::hash<event>::operator()(const event& e) const noexcept -> std::size_t
{
return std::hash<std::string>()(e.name);
}
auto std::hash<state>::operator()(const state& s) const noexcept -> std::size_t
{
return std::hash<std::string>()(s.name);
}
auto std::hash<transition>::operator()(const transition& t) const noexcept -> std::size_t
{
return std::hash<state>()(t.from) +
std::hash<state>()(t.to) +
std::hash<event>()(t.trigger);
}
|
b804ed3ff26f95d6427f88392bf40a3aef256ce4
|
f5dfb0372291f9ba0c1dbcf054903c0f46443a9b
|
/PAT/A1067.cpp
|
f51409ace9351d00c7b4169e200c7c943b80ca20
|
[] |
no_license
|
liutao199527/PAT_Adveance
|
07d9fb0dfbc33f3bc317501c00e98b376db734fa
|
a839516dc4693dc32c7065df0d223b5c128b028c
|
refs/heads/master
| 2020-09-29T10:20:07.972592
| 2019-12-10T03:15:17
| 2019-12-10T03:15:17
| 227,017,755
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 492
|
cpp
|
A1067.cpp
|
//#include <iostream>
//#include <algorithm>
//
//using namespace std;
//const int maxv = 100010;
//
//int N;
//int pos[maxv];
//bool isIn[maxv] = { false };
//int index;
//
//int main() {
// cin >> N;
// for (int i = 0;i < N;i++) {
// cin >> pos[i];
// if (pos[i] == i) {
// pos[i] = true;
// }
// if (pos[i] == 0) {
// index = i;
// }
// }
// for (int i = 0;i < N;i++) {
// if (isIn[i] == false) {
// swap(pos[i],pos[index])
//
// }
//
// }
//
//}
|
ffdad20993896d7cae76a0009c29c5900b645cd5
|
6a20718718683df936088e91fc5bb51b5e940424
|
/include/avakar/atomic.h
|
96d7e2a2699d713cfc15793e520d8702748dbf38
|
[
"MIT"
] |
permissive
|
avakar/atomic_ref
|
b6e870e2ee413f742fc1ded03db9d9a354200028
|
bf1b16afbf3c98754d33fd601c3e53b892cd7cab
|
refs/heads/master
| 2023-08-29T17:01:12.112976
| 2020-05-21T10:26:15
| 2020-05-21T10:33:29
| 173,187,450
| 5
| 2
|
MIT
| 2022-08-07T18:17:31
| 2019-02-28T21:06:43
|
C++
|
UTF-8
|
C++
| false
| false
| 8,788
|
h
|
atomic.h
|
#ifndef AVAKAR_ATOMIC_h
#define AVAKAR_ATOMIC_h
#include <atomic>
#include <cstddef>
#if defined(_MSC_VER) && defined(_M_IX86)
#include "../../src/atomic_ref.msvc.x86.h"
#elif defined(_MSC_VER) && defined(_M_AMD64)
#include "../../src/atomic_ref.msvc.x64.h"
#elif defined(__GNUC__)
#include "../../src/atomic_ref.gcc.h"
#else
#error Unsupported platform
#endif
namespace avakar {
template <typename T, typename = void>
struct _atomic;
template <typename T>
using safe_atomic = _atomic<T>;
template <typename T>
struct atomic
: _atomic<T>
{
using difference_type = typename _atomic<T>::difference_type;
explicit atomic() noexcept
: _atomic<T>()
{
}
explicit atomic(T desired) noexcept
: _atomic<T>(desired)
{
}
operator T() const noexcept
{
return this->load();
}
T operator=(T desired) noexcept
{
this->store(desired);
return desired;
}
T operator++() noexcept
{
return this->fetch_add(1) + T(1);
}
T operator++(int) noexcept
{
return this->fetch_add(1);
}
T operator--() noexcept
{
return this->fetch_sub(1) - T(1);
}
T operator--(int) noexcept
{
return this->fetch_sub(1);
}
T operator+=(difference_type arg) noexcept
{
return this->fetch_add(arg) + arg;
}
T operator-=(difference_type arg) noexcept
{
return this->fetch_sub(arg) - arg;
}
T operator&=(T arg) noexcept
{
return this->fetch_and(arg) & arg;
}
T operator|=(T arg) noexcept
{
return this->fetch_or(arg) | arg;
}
T operator^=(T arg) noexcept
{
return this->fetch_xor(arg) ^ arg;
}
};
template <typename T, typename>
struct _atomic
{
static_assert(std::is_trivially_copyable<T>::value, "T must be TriviallyCopyable");
static constexpr bool is_always_lock_free = _avakar::atomic_ref::is_always_lock_free<T>::value;
static constexpr bool is_always_wait_free = _avakar::atomic_ref::is_always_wait_free<T>::value;
static constexpr std::size_t required_alignment = alignof(T);
using value_type = T;
_atomic() noexcept = default;
_atomic(_atomic const &) = delete;
_atomic & operator=(_atomic const &) = delete;
_atomic(T desired) noexcept
: _obj(desired)
{
}
value_type load(std::memory_order order = std::memory_order_seq_cst) const noexcept
{
return _avakar::atomic_ref::load(_obj, order);
}
void store(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
_avakar::atomic_ref::store(_obj, desired, order);
}
value_type exchange(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::exchange(_obj, desired, order);
}
bool compare_exchange_weak(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_weak(expected, desired, order, order);
}
bool compare_exchange_weak(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_weak(_obj, expected, desired, success, failure);
}
bool compare_exchange_strong(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_strong(expected, desired, order, order);
}
bool compare_exchange_strong(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_strong(_obj, expected, desired, success, failure);
}
private:
value_type _obj;
};
template <typename T>
struct _atomic<T *>
{
static constexpr bool is_always_lock_free = _avakar::atomic_ref::is_always_lock_free<T *>::value;
static constexpr bool is_always_wait_free = _avakar::atomic_ref::is_always_wait_free<T *>::value;
static constexpr std::size_t required_alignment = alignof(T *);
using value_type = T *;
using difference_type = std::ptrdiff_t;
_atomic() noexcept = default;
_atomic(_atomic const &) = delete;
_atomic & operator=(_atomic const &) = delete;
_atomic(value_type desired) noexcept
: _obj(desired)
{
}
value_type load(std::memory_order order = std::memory_order_seq_cst) const noexcept
{
return _avakar::atomic_ref::load(_obj, order);
}
void store(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
_avakar::atomic_ref::store(_obj, desired, order);
}
value_type exchange(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::exchange(_obj, desired, order);
}
bool compare_exchange_weak(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_weak(expected, desired, order, order);
}
bool compare_exchange_weak(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_weak(_obj, expected, desired, success, failure);
}
bool compare_exchange_strong(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_strong(expected, desired, order, order);
}
bool compare_exchange_strong(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_strong(_obj, expected, desired, success, failure);
}
value_type fetch_add(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_add(_obj, arg, order);
}
value_type fetch_sub(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_sub(_obj, arg, order);
}
private:
value_type _obj;
};
template <typename T>
struct _atomic<T, std::enable_if_t<std::is_integral<T>::value>>
{
static_assert(std::is_trivially_copyable<T>::value, "T must be TriviallyCopyable");
static constexpr bool is_always_lock_free = _avakar::atomic_ref::is_always_lock_free<T>::value;
static constexpr bool is_always_wait_free = _avakar::atomic_ref::is_always_wait_free<T>::value;
static constexpr std::size_t required_alignment = alignof(T);
using value_type = T;
using difference_type = T;
_atomic() noexcept = default;
_atomic(_atomic const &) = delete;
_atomic & operator=(_atomic const &) = delete;
_atomic(T desired) noexcept
: _obj(desired)
{
}
value_type load(std::memory_order order = std::memory_order_seq_cst) const noexcept
{
return _avakar::atomic_ref::load(_obj, order);
}
void store(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
_avakar::atomic_ref::store(_obj, desired, order);
}
value_type exchange(value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::exchange(_obj, desired, order);
}
bool compare_exchange_weak(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_weak(expected, desired, order, order);
}
bool compare_exchange_weak(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_weak(_obj, expected, desired, success, failure);
}
bool compare_exchange_strong(value_type & expected, value_type desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return this->compare_exchange_strong(expected, desired, order, order);
}
bool compare_exchange_strong(
value_type & expected, value_type desired,
std::memory_order success,
std::memory_order failure) noexcept
{
return _avakar::atomic_ref::compare_exchange_strong(_obj, expected, desired, success, failure);
}
value_type fetch_add(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_add(_obj, arg, order);
}
value_type fetch_sub(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_sub(_obj, arg, order);
}
value_type fetch_and(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_and(_obj, arg, order);
}
value_type fetch_or(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_or(_obj, arg, order);
}
value_type fetch_xor(difference_type arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return _avakar::atomic_ref::fetch_xor(_obj, arg, order);
}
private:
value_type _obj;
};
}
#endif // _h
|
5c51930353fbbf80803842822016c0ea842be4cb
|
2d2857f72ea80d92f6d26e56c6eabe2c0a280540
|
/scpcPractice/cf568C.cpp
|
b45eda501d77ef5740fcc50a6bd153f427188b72
|
[] |
no_license
|
kimkyuhwan/SCPC-Practice
|
cd63cce155dd62f1f1a4d353874f48528a94a374
|
f9ef04ccbe305636a38c42da0256a58f0ce2f593
|
refs/heads/master
| 2020-05-29T23:22:11.462542
| 2019-08-13T15:54:53
| 2019-08-13T15:54:53
| 189,432,083
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 575
|
cpp
|
cf568C.cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M, sum, cnt;
ll arr[200010];
priority_queue<ll> pq, temp;
int main() {
scanf("%lld %lld", &N, &M);
for (int i = 0; i < N; i++) {
scanf("%lld", &arr[i]);
sum += arr[i];
while (sum > M) {
sum -= pq.top();
temp.push(pq.top());
pq.pop();
cnt++;
}
printf("%lld ", cnt);
pq.push(arr[i]);
temp.push(arr[i]);
if (temp.top() == arr[i]) {
temp.pop();
while (!temp.empty()) {
sum += temp.top();
pq.push(temp.top());
temp.pop();
cnt--;
}
}
}
puts("");
}
|
eb0b25fe1d2965a7de12615ab318cc89f268da24
|
99209e2a06ff8bd48528f885f57fe8eacc0665d4
|
/2023/others/Exercises/CircularBufferUtilization.cpp
|
838ce4a7ade9b44d1c44499032531d3c13dda751
|
[] |
no_license
|
pbraga88/study
|
6fac30990059b481c97e558b143b068eca92bc42
|
fcc1fb7e0d11e264dadb7296ab201fad9a9b0140
|
refs/heads/master
| 2023-08-17T04:25:40.506116
| 2023-08-15T10:53:37
| 2023-08-15T10:53:37
| 155,830,216
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,999
|
cpp
|
CircularBufferUtilization.cpp
|
/* Circular buffer Utilization
A circular ring buffer is used to pass data between 2 threads; 1 Thread writes to the buffer whilst the other reads.
A state variable captures the current utilisation of the ring buffer, where each binary bit represents an entry in the buffer:
•
If a bit is 1, the corresponding position/entry in the ring buffer is used.
If a bit is 0, the corresponding position/entry in the ring buffer is unused.
The utilisation of the buffer is monitored as part of the background self-tests and diagnostics.
If 3 or more consecutive buffer entries are currently in use it indicates a performance issue with the system.
Write a function that checks a given state variable and returns true if there are 3 or more consecutive bits set and false otherwise.
Be careful: - Note the buffer is circular!
- The state variable is an unsigned type, of either 8 or 16 bits width.
Input format
The input format that you must use to provide custom input (available above the Compile and Test buttons) is as follows:
• A single unsigned integer value of either 8 or 16 bits width describing the buffer utilization state
Output format
Print the utilization result as integer 0 or 1
Sample input
186
Sample output
1
*/
#include <iostream>
#include <cstdint>
#include <limits>
#define LEAD_BITS_1 0x01 // 0000 0001
#define LEAD_BITS_2 0x03 // 0000 0011
#define LEAD_BITS_3 0x07 // 0000 0111
#define LEAD_BITS_4 0x0F // 0000 1111
#define LEAD_BITS_5 0x1F // 0001 1111
// template <typename T>
// bool check_buffer(T state) {
// // Create a mask with 3 consecutives set bits and 2 leading set bits
// // T mask = (1 << (sizeof(T) * 8 - 1)) | (1 << (sizeof(T) * 8 - 2)) | 1;
// T mask = (LEAD_BITS_2 << (sizeof(T) * 8 - 2)) | 1;
// // T mask = (1 << (sizeof(T) * 8 - 1)) | (1 << (sizeof(T) * 8 - 2)) | (1 << (sizeof(T) * 8 - 3));
// std::cout<<"DEBUG: state = "<<static_cast<uint16_t>(state)<<std::endl;
// std::cout<<"DEBUG: mask = "<<static_cast<uint16_t>(mask)<<std::endl;
// std::cout<<"DEBUG: sizeof(T) = "<<sizeof(T)<<std::endl;
// for (int i = 0; i < sizeof(T) * 8; i++) {
// // Check if 3 or more consecutive set bits are found
// if ((state & mask) == mask) {
// return true;
// }
// // Rotate the mask to the right
// mask = (mask >> 1) | ((mask & 1) << (sizeof(T) * 8 -1));
// }
// return false;
// }
template <typename T>
bool check_buffer(T state) {
if (state == ((LEAD_BITS_2 << sizeof(T) * 8 - 2) | 1) || // uint8_t: 1100 0001; uint16_t: 1100 0000 0000 0001
state == ((LEAD_BITS_1 << sizeof(T) * 8 - 1) | 3) || // uint8_t: 1000 0011; uint16_t: 1000 0000 0000 0011
(state & (state << 1) & (state << 2)) != 0 ) { // state: 1011 1001
return true; // (state << 1): 0111 0010
} // (state << 2): 1110 0100
return false; // result: 0010 0000
}
int main() {
// The two follow lines are used to optimize I/O performance.
// When using them, make sure not to mix C++ streams and C standard I/O functions (e.g scanf, printf, etc)
// in the same program. Also make sure to control the flushing of the output stream manually when needed.
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// Read an input state buffer
uint64_t num{0};
std::cin>>num;
// Reading input from STDIN
bool state_flag {false};
// Use a type appropriate the size of the value
if (num <= std::numeric_limits<uint8_t>::max()) {
uint8_t state = static_cast<uint8_t>(num);
state_flag = check_buffer(state);
}
else {
int16_t state = static_cast<uint16_t>(num);
state_flag = check_buffer(state);
}
// Finally, print the answer
std::cout<<state_flag<<std::endl;
return 0;
}
|
9f5621c3de5a7e98108353c5eb42aeec6f3b46b7
|
c7e580f3fb034a48d2542d5d04438dcd796125b9
|
/CS420_Project2_Wumpus/Agent.h
|
9f343bf390bd059dc78d45b1621e7323b02baa41
|
[] |
no_license
|
tchtrong/CS420_Project2_Wumpus
|
aa4e6cb38875bf3620d6071c7fa6ee839fa87441
|
f58c503619cad93525f925c40ccc1180518cab3c
|
refs/heads/master
| 2022-11-06T15:18:35.084278
| 2020-06-26T16:06:51
| 2020-06-26T16:06:51
| 274,125,645
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,950
|
h
|
Agent.h
|
#pragma once
#include "Board.h"
enum class Question {
SAFE,
NOT_UNSAFE,
WUMPUS,
UNVISITED,
};
enum class Direction {
UP,
DOWN,
LEFT,
RIGHT
};
Direction& operator++(Direction& d) {
switch (d)
{
case Direction::UP:
d = Direction::RIGHT;
break;
case Direction::DOWN:
d = Direction::LEFT;
break;
case Direction::LEFT:
d = Direction::UP;
break;
case Direction::RIGHT:
d = Direction::DOWN;
break;
default:
break;
}
return d;
}
Direction& operator--(Direction& d) {
switch (d)
{
case Direction::UP:
d = Direction::LEFT;
break;
case Direction::DOWN:
d = Direction::RIGHT;
break;
case Direction::LEFT:
d = Direction::DOWN;
break;
case Direction::RIGHT:
d = Direction::UP;
break;
default:
break;
}
return d;
}
class Agent {
public:
Agent(KB& kb_, Board& brd_, const Position& pos_, int limit):
kb(kb_),
brd(brd_),
pos(pos_),
limit(limit)
{}
void run() {
std::cout << "Agent start at:\n" << pos << brd.get_tile(pos);
while (limit) {
tell_kb(new_percepts(pos));
auto cur = brd.get_tile(pos);
if (cur.is_pit || cur.is_wumpus) {
std::cout << "Agent has died, game over\n";
point -= 10000;
std::cout << "Point: " << point;
break;
}
//Check for gold
if (cur.is_gold) {
std::cout << "Agent pick up a gold and receive 100 points\n";
point += 100;
}
std::cout << "Point: " << point << "\n\n";
//Get surrounding position that is safe
auto safe_direct = ask_possible_pos(Question::SAFE);
//Check for safe and unvisited locations
if (to_visit.empty()) {
auto unvisited_direct = ask_possible_pos(Question::UNVISITED);
std::vector<Position> pos_to_visit;
for (auto& s_dir : safe_direct) {
if (std::find(unvisited_direct.begin(), unvisited_direct.end(), s_dir)!=unvisited_direct.end()) {
pos_to_visit.emplace_back(s_dir);
}
}
size_t pos_added = pos_to_visit.size();
std::copy_if(
std::make_move_iterator(pos_to_visit.begin()), std::make_move_iterator(pos_to_visit.end()),
std::back_inserter(to_visit),
[&](auto p) {
return std::find(to_visit.begin(), to_visit.end(), p + pos) == to_visit.end();
}
);
std::transform(to_visit.begin(), to_visit.end(), to_visit.begin(),
[&](Position x) {
return x += pos;
}
);
}
//No safe location available: Kill wumpus if possible to get going
if (to_visit.empty()) {
auto wumpus_direct = ask_possible_pos(Question::WUMPUS);
if (wumpus_direct.size()) {
to_visit.emplace_back(std::move(wumpus_direct[0]) + pos);
}
}
//Cannot find any possible of wumpus nearby, choose to go to maybe safe location
if (to_visit.empty()) {
auto maybe_safe_direct = ask_possible_pos(Question::NOT_UNSAFE);
if (maybe_safe_direct.size()) {
to_visit.emplace_back(std::move(maybe_safe_direct[0]) + pos);
}
}
//If cannot make any further decision, break the loop
if (to_visit.empty()) {
std::cout << "Agent cannot move anymore\n";
break;
}
//Move
move(to_visit.back());
to_visit.pop_back();
}
}
private:
//Create percepts based on current position on the map
CNFSentence new_percepts(const Position& pos) {
Tile tile = brd.get_tile(pos);
CNFSentence res;
if (tile.is_breeze) {
res = std::move(res) & get_breeze(pos);
}
else {
res = std::move(res) & ~get_breeze(pos);
}
if (tile.is_wumpus) {
res = std::move(res) & get_wumpus(pos);
}
else {
res = std::move(res) & ~get_wumpus(pos);
}
if (tile.is_pit) {
res = std::move(res) & get_pit(pos);
}
else {
res = std::move(res) & ~get_pit(pos);
}
if (tile.is_stench) {
res = std::move(res) & get_stench(pos);
}
else {
res = std::move(res) & ~get_stench(pos);
}
return res;
}
CNFSentence get_safe(const Position& pos) {
return get_literal("~P", pos) & get_literal("~W", pos);
}
CNFSentence get_not_unsafe(const Position& pos) {
return ~get_safe(pos);
}
CNFSentence get_wumpus(const Position& pos) {
return get_literal("W", pos);
}
CNFSentence get_pit(const Position& pos) {
return get_literal("P", pos);
}
CNFSentence get_breeze(const Position& pos) {
return get_literal("B", pos);
}
CNFSentence get_stench(const Position& pos) {
return get_literal("S", pos);
}
//Interact with KB
bool ask_kb(const CNFSentence& percept) {
return kb.answer(percept);
}
void tell_kb(const CNFSentence& percept) {
kb.add_percepts(CNFSentence(percept));
}
std::vector<Position> ask_possible_pos(const Question& question) {
std::vector<Position> res;
res.reserve(4);
for (const auto& pos_ : possible_pos) {
const auto new_pos = pos_ + pos;
if (brd.is_valid(new_pos)) {
switch (question)
{
case Question::SAFE:
if (ask_kb(get_safe(new_pos))) res.emplace_back(new_pos);
break;
case Question::NOT_UNSAFE:
if (!ask_kb(get_not_unsafe(new_pos))) res.emplace_back(new_pos);
break;
case Question::WUMPUS:
if (!ask_kb(~get_wumpus(new_pos))) res.emplace_back(new_pos);
break;
case Question::UNVISITED:
if (!brd.get_tile(new_pos).is_visited) res.emplace_back(new_pos);
break;
default:
break;
}
}
}
return res;
}
//Actions
void move(const Position& location) {
--limit;
pos = location;
brd.mark_visited(pos);
std::cout << "Agent move to:\n" << pos << brd.get_tile(pos);
}
void shoot(const Position& direct) {
point -= 1000;
brd.check_shoot(pos, direct);
auto direct_ = [&]() {
if (direct == UP) {
return "top of the map";
}
if (direct == DOWN) {
return "bottom of the map";
}
if (direct == UP) {
return "left of the map";
}
if (direct == UP) {
return "right of the map";
}
}();
std::cout << "Agent shoot from " << pos << "to the " << direct_;
}
//Attributes
KB& kb;
Board& brd;
Position pos;
int limit;
int point = 0;
std::vector<Position> to_visit;
};
|
8c69777f69435aec23e7a58646a98bbff7363cb9
|
bcd810a6908f1d9cbf686d8f7b0312c7d5410b57
|
/client/test/writedir.cpp
|
8a919f4b2d72e35d5e14dd551027ea5081617c0e
|
[] |
no_license
|
qingdy/SURDFS
|
a1f7e6ec27d0c507aeaf459c91d705591f740235
|
1b2f9da4e7aff64bb231ef8e387b5c8df552148f
|
refs/heads/master
| 2016-09-11T03:33:03.418177
| 2013-09-05T02:00:49
| 2013-09-05T02:00:49
| 12,606,667
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,807
|
cpp
|
writedir.cpp
|
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include "time_util.h"
#include "log.h"
#include "bladestore_ops.h"
#include "blade_common_define.h"
#include "blade_file_info.h"
#include "client.h"
#ifdef PATH_MAX
static int pathmax = PATH_MAX;
#else
static int pathmax = 0;
#endif
#define SUSV3 200112L
static long posix_version = 0;
#define PATH_MAX_GUESS 1024
using namespace pandora;
using namespace bladestore::client;
using namespace bladestore::common;
using namespace bladestore::message;
static char *fullpath;
string sourcepath;
string destpath;
Client *client = NULL;
char *path_alloc(int *sizep)
{
char *ptr;
int size;
if (posix_version == 0)
posix_version = sysconf(_SC_VERSION);
if (pathmax == 0) {
errno = 0;
if ((pathmax = pathconf("/", _PC_PATH_MAX)) < 0) {
if (errno == 0) {
pathmax = PATH_MAX_GUESS;
} else {
printf("pathconf error for _PC_PATH_MAX.\n");
return NULL;
}
} else {
++pathmax;
}
}
if (posix_version < SUSV3)
size = pathmax + 1;
else
size = pathmax;
if ((ptr = (char *)malloc(size)) == NULL) {
printf("malloc error for pathname.\n");
return NULL;
}
if (sizep != NULL)
*sizep = size;
return (ptr);
}
int32_t writefiles(void *buf, int8_t issafewrite, int32_t buffersize)
{
int64_t localfid = open(fullpath, O_RDONLY);
// Create a file
char * tmp = fullpath + sourcepath.size();
string filename = destpath + tmp;
int64_t fid = client->Create(filename, issafewrite, 3);
LOGV(LL_INFO, "File created, filepath: %s, ID: %ld.", filename.c_str(), fid);
if (fid < 0) {
LOGV(LL_ERROR, "Create file error.");
return -1;
}
int64_t alreadyread = 0;
int64_t readlocallen = 0;
do {
readlocallen = read(localfid, buf, buffersize);
if (readlocallen < 0) {
LOGV(LL_ERROR, "read local file error.");
return -1;
} else if (readlocallen == 0) {
break;
}
int64_t writelen = client->Write(fid, buf, readlocallen);
if (writelen < 0) {
LOGV(LL_ERROR, "error in write");
return -1;
}
alreadyread += writelen;
} while (readlocallen > 0);
client->Close(fid);
close(localfid);
return 0;
}
int dopath(void *buf, int8_t issafewrite, int32_t buffersize)
{
struct stat statbuf;
struct dirent *dirp;
DIR *dp;
int ret;
char *ptr;
if (lstat(fullpath, &statbuf) < 0)
return -1;
if (S_ISDIR(statbuf.st_mode) == 0) {
int writeret = writefiles(buf, issafewrite, buffersize);
return writeret;
}
char * tmp = fullpath + sourcepath.size();
string dirname = destpath + tmp;
int mkdirret = client->MakeDirectory(dirname);
if (mkdirret != BLADE_SUCCESS && mkdirret != -RET_DIR_EXIST) {
LOGV(LL_ERROR, "Makedirectory %s error.", dirname.c_str());
return -1;
}
ptr = fullpath + strlen(fullpath);
*ptr++ = '/';
*ptr = 0;
if ((dp = opendir(fullpath)) == NULL)
return -1;
while ((dirp = readdir(dp)) != NULL) {
LOGV(LL_INFO, "the file name: %s .", dirp->d_name);
if (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0)
continue;
strcpy(ptr, dirp->d_name);
if ((ret = dopath(buf, issafewrite, buffersize)) != 0)
break;
}
ptr[-1] = 0;
if (closedir(dp) < 0)
return -1;
return ret;
}
int main (int argc, char **argv)
{
if (argc != 4) {
printf("%s issafewrite sourcepath destpath (0 for write, 1 for safewrite)\n", argv[0]);
return -1;
}
client = new Client();
int initret = client->Init();
if (BLADE_ERROR == initret)
abort();
int32_t issafewrite = atoi(argv[1]);
int32_t buffersize = 1048600;
char *buf = (char *)malloc(buffersize);
int len;
fullpath = path_alloc(&len);
sourcepath = argv[2];
destpath = argv[3];
//int mkdirret = client->MakeDirectory(destpath);
//if (mkdirret != BLADE_SUCCESS && mkdirret != -RET_DIR_EXIST) {
// LOGV(LL_ERROR, "Makedirectory destpath %s error.", destpath.c_str());
// return -1;
//}
strncpy(fullpath, sourcepath.c_str(), len);
fullpath[len - 1] = 0;
LOGV(LL_INFO, "fullpath: %s, sourcepath: %s, destpath: %s", fullpath, sourcepath.c_str(), destpath.c_str());
dopath(buf, issafewrite, buffersize);
free(buf);
delete client;
}
|
8f85f66867cf221ab54f32fb306f7371b672946a
|
896c6c76bac1226521aed8ea2c92d96f0cfd13b9
|
/C++/wskazniki.cpp
|
976734182c240bbf59b4c4368d0eb5472e56669e
|
[] |
no_license
|
marcelsawicki/Archive
|
e59a24d9f03030c9792f402c599e847b5802e233
|
8fee16156e2eb4e5b7dcaf4102be71380ef70464
|
refs/heads/master
| 2023-07-11T23:00:57.345335
| 2023-06-24T11:16:02
| 2023-06-24T11:16:02
| 94,013,821
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 375
|
cpp
|
wskazniki.cpp
|
/* wskazniki */
#include <iostream>
using namespace std;
main()
{
int ti[6];
float tf[6];
int *wi;
float *wf;
wi = &ti[0];
wf = &tf[0];
cout << "Oto jak przy inkrementacji wskaznik\n"
<< "zmieniaja sie ukryte w nich adresy:\n";
for(int i=0; i<6; i++, wi++, wf++)
{
cout << "i= " << i
<< ") wi= "
<< wi
<< ", wf= "
<< wf << endl;
}
}
|
a7c1811ca8469029732e639b21145a0f7d2353f6
|
b0bfa764aeb115888de5f88696cdc13b48e5be4d
|
/chapter05/Excercises/5.9/5.9.cpp
|
6606c0422672a6cc4ad717ef826ece3ba5f1eac6
|
[] |
no_license
|
Marco444/Accelerated-Cpp-Excercises
|
396cc2ed0459bd3a67854d5cbc34ff45e15ae3c8
|
ce66a28d1e9217a9a595737a57dd0bf686c3443c
|
refs/heads/master
| 2021-01-13T09:51:19.156540
| 2019-12-26T18:03:22
| 2019-12-26T18:03:22
| 69,895,701
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 926
|
cpp
|
5.9.cpp
|
#include <iostream>
#include <vector>
#include <cctype>
#include <iomanip>
using std::string; using std::vector;
using std::cin; using std::cout;
using std::getline; using std::istream;
// using std::endl; == '/n';
void vcat(vector<string>& ret, const vector<string>& bottom)
{
for (vector<string>::const_iterator it = bottom.begin();
it != bottom.end(); ++it)
ret.push_back(*it);
}
void read( vector<string>& words, const string& str, const istream& in)
{
while(in){
getline(in, str);
if (str != "-"){
words.push_back(str);
} else {
break;
}
}
}
int main()
{
vector<string> words;
vector<string>Words;
string str;
read(words, str, cin);
for(vector<string>::size_type i; i != words.size(); ++i){
string str;
string words[i] = str;
if ( isupper(str[0]) ){
Words.push_back(str);
}
}
vcat(Words, words);
return 0;
}
|
11c8e6b2399d67cbb1afcf7d06445595f029e02f
|
daf4d928af2ee0fa207739a76fdd7578360ff73f
|
/FEM/rf_fluid_momentum.h
|
5d84a3a4662ea5efec584a2fa6baf58f701845b5
|
[] |
no_license
|
UFZ-MJ/OGS_mHM
|
e735b411ccfdb5ff13b2f2c0e7e515191f722aed
|
91b972560b8566738dbacc61c2f05e9fc6e7932e
|
refs/heads/master
| 2021-01-19T17:31:13.764641
| 2018-02-08T10:27:59
| 2018-02-08T10:27:59
| 101,064,731
| 4
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,367
|
h
|
rf_fluid_momentum.h
|
////////////////////////////////////////////////////////////////
// Filename: rf_fluid_momentum.h
//
// written by PCH, 05/2005
////////////////////////////////////////////////////////////////
#include "Configure.h"
// C++ STL
#include <list>
#include <string>
#include <vector>
#include <fstream>
#include "rf_pcs.h"
//#include "rf_vel_new.h"
#include "fem_ele_std.h"
#include "fem_ele.h"
#ifndef NEW_EQS //WW. 06.11.2008
#include "matrix.h"
#endif
#include "mathlib.h"
using namespace FiniteElement;
class PlaneSet
{
public:
int eleIndex;
double ratio; // ratio: contribution of velocity to this plane.
double V[3];
double norm[3];
double Eele[3]; // The vector from the crossroad to the center of the connected element
// that lies in one of the connected planes.
// Constructor
PlaneSet(void);
PlaneSet&operator=(const PlaneSet& B)
{
eleIndex = B.eleIndex;
ratio = B.ratio;
for(int i=0; i<3; ++i)
{
V[i] = B.V[i];
norm[i] = B.norm[i];
}
return *this;
}
};
class CrossRoad
{
public:
int numOfThePlanes;
int Index; // This can be node or edge index
// depending on crossroad or edge
PlaneSet* plane;
// Constructor and destructor
CrossRoad(void);
~CrossRoad(void);
void CreatePlaneSet(const int index);
// Some operator overloading
CrossRoad& operator=(const CrossRoad& B)
{
Index = B.Index;
numOfThePlanes = B.numOfThePlanes;
plane = B.plane;
return *this;
};
};
class CFluidMomentum: public CRFProcess
{
public:
CFluidMomentum(void);
~CFluidMomentum(void);
int RWPTSwitch;
std::vector<CrossRoad*> crossroads;
std::vector<CrossRoad*> joints;
void Create(void);
virtual double Execute();
void SolveDarcyVelocityOnNode();
void ConstructFractureNetworkTopology();
void SolveForEdgeVelocity(void);
protected:
FiniteElement::CFiniteElementStd *fem;
private:
CRFProcess* m_pcs;
};
extern void FMRead(std::string pcs_name = "");
extern void DATWriteHETFile(const char *file_name);
|
c0705d13997f94c5f059cd756c5b14695690fc0b
|
f8ff2c591cb9c2767099759fa3e3deade78b43f5
|
/Amanda/lista_ex11.cpp
|
bf00a1f5602251d56632cc8e8332365116fa2d07
|
[] |
no_license
|
cecanho/PC2
|
4396d766c33668b9ea50c9bccc7a2971b073b21b
|
42cb46c201e277b42c4245e73f0368470941e951
|
refs/heads/master
| 2021-12-24T09:31:16.192744
| 2021-12-18T11:07:58
| 2021-12-18T11:07:58
| 190,442,981
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 697
|
cpp
|
lista_ex11.cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
/* 11. Fazer um programa em "C" que lê um conjunto de 10 valores inteiros e
verifica se algum dos valores é igual a média dos mesmos. */
using namespace std;
int main(){
int num, vector[10];
int i;
float media;
cout << "Digite 10 valores inteiros: " << endl;
for (i=0; i<10; i++){
cin >> num;
vector[i] = num;
media = media + vector[i];
}
system ("cls");
media = media /10;
cout << "A media dos valores digitados é: " << media << endl;
for (i=0; i<10;i++){
if (vector[i] == media)
cout << "A posicao numero " << i << " do vetor tem o mesmo valor que a media dos valores digitados!" << endl;
}
}
|
a59f7ab7beb2559e81b4565acf6aaeb750a07b69
|
0eff74b05b60098333ad66cf801bdd93becc9ea4
|
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_16147.cpp
|
41092c9cdeef800ad11273be2d441eb7e8b563c4
|
[] |
no_license
|
niuxu18/logTracker-old
|
97543445ea7e414ed40bdc681239365d33418975
|
f2b060f13a0295387fe02187543db124916eb446
|
refs/heads/master
| 2021-09-13T21:39:37.686481
| 2017-12-11T03:36:34
| 2017-12-11T03:36:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 35
|
cpp
|
Kitware_CMake_repos_basic_block_block_16147.cpp
|
memcpy(&bp[9], np->identifier, len)
|
b9da84c2c1225659a9d0fde18ba2b31ee295a0cd
|
c05bc1c96979107eeb1d1463a7fc01b5144452c8
|
/Medicina/Servers/MedicinaActiveSurfaceBoss/include/DevIOStatus.h
|
4bf20c4c162b6fdc42340ce8cba281a9cfb15ea6
|
[] |
no_license
|
discos/discos
|
1587604ae737d8301f10011d21bfa012dd3c411f
|
87dc57a160f3b122af46a9927ee6abb62fdf4159
|
refs/heads/master
| 2023-08-30T21:39:55.339786
| 2023-06-21T13:39:20
| 2023-06-21T13:39:20
| 87,530,078
| 4
| 4
| null | 2023-09-07T07:57:43
| 2017-04-07T09:37:08
|
C++
|
UTF-8
|
C++
| false
| false
| 2,203
|
h
|
DevIOStatus.h
|
#ifndef _MEDICINAACTIVESURFACEBOSSIMPLDEVIOSTATUS_H_
#define _MEDICINAACTIVESURFACEBOSSIMPLDEVIOSTATUS_H_
/* ************************************************************************************* */
/* OAC Osservatorio Astronomico di Cagliari */
/* $Id: DevIOStatus.h,v 1.1 2009-05-21 15:33:19 c.migoni Exp $ */
/* */
/* This code is under GNU General Public Licence (GPL). */
/* */
/* Who When What */
/* Carlo Migoni (migoni@ca.astro.it) 11/05/2008 Creation */
#include <baciDevIO.h>
#include <IRA>
using namespace baci;
/**
* This class is derived from the template DevIO. It is used by the status property.
* @author <a href=mailto:migoni@ca.astro.it>Carlo Migoni</a>,
* Osservatorio Astronomico di Cagliari, Italia<br>
*/
class MedicinaActiveSurfaceBossImplDevIOStatus: public virtual DevIO<Management::TSystemStatus>
{
public:
MedicinaActiveSurfaceBossImplDevIOStatus(IRA::CSecureArea<CMedicinaActiveSurfaceBossCore>* core): m_core(core) {
AUTO_TRACE("MedicinaActiveSurfaceBossImplDevIOStatus::MedicinaActiveSurfaceBossImplDevIOStatus()");
}
~MedicinaActiveSurfaceBossImplDevIOStatus() {
AUTO_TRACE("MedicinaActiveSurfaceBossImplDevIOStatus::~MedicinaActiveSurfaceBossImplDevIOStatus()");
}
bool initializeValue(){
return false;
}
Management::TSystemStatus read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) {
CSecAreaResourceWrapper<CMedicinaActiveSurfaceBossCore> resource=m_core->Get();
AUTO_TRACE("MedicinaActiveSurfaceBossImplDevIOStatus::read()");
timestamp=getTimeStamp();
return resource->getStatus();
}
void write(const CORBA::Long& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) {
AUTO_TRACE("MedicinaActiveSurfaceBossImplDevIOStatus::write()");
}
private:
IRA::CSecureArea<CMedicinaActiveSurfaceBossCore> *m_core;
};
#endif /*DEVIOSTATUS_H_*/
|
e071509da2c271baed4367f244ba9316fdea3be6
|
dd77f7ba87740bb6230f24a1cccc62c302ee23df
|
/server/include/bodies/receiver/receiver.h
|
ceaf2bcc55d8681e552aa483667320d9ec216c0e
|
[
"Apache-2.0"
] |
permissive
|
MarcosCouttulenc/Portal-Taller-de-Programacion-9508-FIUBA
|
014834fc844899d82853e6c5a1c7ce85d82cc340
|
6a642c02405a9409a936f1551cf2237639616825
|
refs/heads/master
| 2023-03-16T17:29:33.311013
| 2020-03-12T19:06:39
| 2020-03-12T19:06:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,458
|
h
|
receiver.h
|
#ifndef __RECEIVER_H__
#define __RECEIVER_H__
#include "../body.h"
#include "../../world.h"
#include "../../../../server/include/boolean_suppliers/boolean_supplier.h"
#include "../../../../server/include/bodies/gate/gateable.h"
class Bullet;
class Gate;
class Chell;
class Receiver: public Body, public Gateable {
private:
bool is_on;
Gate *gate;
const float WIDHT = 2.00;
const float HEIGHT = 2.00;
public:
/* Instancia un receptor en world en la posicion (x, y) */
Receiver(World *world, float x, float y);
~Receiver();
/* Indica si el receptor esta activado */
bool isOn() const;
/* Activa al receptor */
void turnOn();
/* Asigna una compuerta al receptor */
void setGate(Gate *gate);
/* Indica si el receptor esta activado */
virtual bool getAsBoolean() const;
/* Crea una update con el comando indicado */
virtual Update createUpdate(COMMAND command) const;
/* Maneja el inicio de contacto con otro cuerpo */
virtual void handleBeginContactWith(Body *other_body, b2Contact *contact);
/* Activa al receptor si es colisionado por una bala */
virtual void handleBeginContactWith(Bullet *bullet, b2Contact *contact);
/* Aterriza a chell */
virtual void handleBeginContactWith(Chell *chell, b2Contact *contact);
/* Maneja el fin de contacto con otro cuerpo */
virtual void handleEndContactWith(Body *other_body, b2Contact *contact);
};
#endif
|
4e0c3d8a281835ea1adeba32b35b17d69a63b1e1
|
84988f74a56fae40d01aa851dca83084612b055e
|
/Code/Enemies.cpp
|
cf9b94e4d5cf86784cd4ca897952e43faeb06f25
|
[] |
no_license
|
MariamAshrafA/OOPGridGame
|
977a70e92571aad2d257811f70779192247c247e
|
29d0887065af926130516a9d08a26d7b0f4725c6
|
refs/heads/master
| 2022-11-23T06:16:52.450788
| 2020-07-13T15:51:54
| 2020-07-13T15:51:54
| 279,139,734
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 608
|
cpp
|
Enemies.cpp
|
#include "Enemies.h"
#include "Grid.h"
#include "GUI.h"
Enemies::Enemies(Cell* pos)
{
PositionCell = pos;
slowed = false;
}
void Enemies::Move(Grid* pGrid)
{
if (counter > 0){
counter--;
}
else{
slowed = false;
}
// Check if the Move is Possible (No Obstacles)
pGrid->MoveCells(PositionCell); // creates random motion is possible
}
void Enemies::setPosition(Cell* pos)
{
PositionCell = pos;
}
Cell* Enemies::getPosition(){
return PositionCell;
}
void Enemies::makeSlow(){
slowed = true;
counter = 40;
}
bool Enemies::isSlowed(){
return slowed;
}
|
66c728c519becd2c6d117c5ae7f7fb9dc49c4e85
|
8e485b2283b0ec1e6d090fb4185f0fd93497e9fe
|
/DiscImageCreator/execScsiCmdforCD.cpp
|
4dcd8ded22dfc6eef5b9780ea7820d074653e636
|
[] |
no_license
|
gorgobacka/DiscImageCreator
|
90e4b4afddbcc88bd1efef28a42efc5e7646eb03
|
3252a2d58fd1395988844b1405fdc27a64552fed
|
refs/heads/master
| 2020-12-02T22:32:11.000180
| 2017-07-03T20:12:46
| 2017-07-03T20:12:46
| 96,146,792
| 0
| 0
| null | 2017-07-03T20:10:10
| 2017-07-03T20:10:09
| null |
UTF-8
|
C++
| false
| false
| 97,391
|
cpp
|
execScsiCmdforCD.cpp
|
/*
* This code is released under the Microsoft Public License (MS-PL). See License.txt, below.
*/
#include "struct.h"
#include "check.h"
#include "convert.h"
#include "execScsiCmd.h"
#include "execScsiCmdforCD.h"
#include "execIoctl.h"
#include "get.h"
#include "init.h"
#include "output.h"
#include "outputScsiCmdLog.h"
#include "outputScsiCmdLogforCD.h"
#include "set.h"
#include "_external/crc16ccitt.h"
// These global variable is set at prngcd.cpp
extern unsigned char scrambled_table[2352];
BOOL ExecSearchingOffset(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE lpCmd,
INT nLBA,
LPBYTE lpBuf,
DWORD dwBufSize,
BOOL bGetDriveOffset,
INT nDriveSampleOffset,
INT nDriveOffset,
BOOL bSubchOffset
)
{
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA
, lpBuf, dwBufSize, _T(__FUNCTION__), __LINE__)) {
if (*pExecType == gd) {
OutputErrorString(
_T("Couldn't read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n")
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
else {
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
OutputLogA(standardError | fileDrive,
"This drive doesn't support [OpCode: %#02x, SubCode: %x]\n", lpCmd[0], lpCmd[10]);
}
else {
OutputErrorString(
_T("This drive can't read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n")
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
}
return FALSE;
}
else {
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
OutputLogA(standardOut | fileDrive,
"This drive supports [OpCode: %#02x, SubCode: %x]\n", lpCmd[0], lpCmd[10]);
}
else {
if (*pExecType != data) {
OutputLogA(standardOut | fileDrive,
"This drive can read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n"
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
}
}
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
if (lpCmd[10] == CDFLAG::_PLXTR_READ_CDDA::MainQ ||
lpCmd[10] == CDFLAG::_PLXTR_READ_CDDA::Raw) {
// because check only
return TRUE;
}
OutputDiscLogA(
OUTPUT_DHYPHEN_PLUS_STR_WITH_SUBCH_F(Check Drive + CD offset), lpCmd[0], lpCmd[10]);
}
else if (!pExtArg->byD8 && !pDevice->byPlxtrDrive || pExtArg->byBe) {
if (lpCmd[10] == CDFLAG::_READ_CD::Q) {
// because check only
return TRUE;
}
OutputDiscLogA(
OUTPUT_DHYPHEN_PLUS_STR_WITH_C2_SUBCH_F(Check Drive + CD offset), lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
if (!pDisc->SCSI.byAudioOnly) {
if (pExtArg->byD8 || pDevice->byPlxtrDrive || *pExecType == gd) {
OutputCDMain(fileDisc, lpBuf, nLBA, CD_RAW_SECTOR_SIZE);
}
}
if (dwBufSize == CD_RAW_SECTOR_WITH_SUBCODE_SIZE ||
dwBufSize == CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE) {
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
if (dwBufSize == CD_RAW_SECTOR_WITH_SUBCODE_SIZE) {
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_SIZE, lpSubcode);
}
else if (dwBufSize == CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE) {
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_SIZE + CD_RAW_READ_C2_294_SIZE, lpSubcode);
}
OutputCDSub96Align(lpSubcode, nLBA);
if (bSubchOffset) {
pDisc->SUB.nSubchOffset = MSFtoLBA(BcdToDec(lpSubcode[19]),
BcdToDec(lpSubcode[20]), BcdToDec(lpSubcode[21])) - 150 - nLBA;
}
}
if (!pExtArg->byD8 && !pDevice->byPlxtrDrive && *pExecType != gd) {
if (pDisc->SUB.nSubchOffset != 0xff) {
OutputDiscLogA("\tSubch Offset: %d\n", pDisc->SUB.nSubchOffset);
}
}
else {
if (!pDisc->SCSI.byAudioOnly) {
BYTE aBuf[CD_RAW_SECTOR_SIZE * 2] = { 0 };
memcpy(aBuf, lpBuf, CD_RAW_SECTOR_SIZE);
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA + 1
, lpBuf, dwBufSize, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
OutputCDMain(fileDisc, lpBuf, nLBA + 1, CD_RAW_SECTOR_SIZE);
memcpy(aBuf + CD_RAW_SECTOR_SIZE, lpBuf, CD_RAW_SECTOR_SIZE);
if (!GetWriteOffset(pDisc, aBuf)) {
OutputErrorString(_T("Failed to get write-offset\n"));
return FALSE;
}
}
OutputCDOffset(pExtArg, pDisc, bGetDriveOffset
, nDriveSampleOffset, nDriveOffset, pDisc->SUB.nSubchOffset);
}
return TRUE;
}
INT GetLBAForSubOffset(
PEXT_ARG pExtArg,
PDEVICE pDevice,
LPBYTE lpCmd,
INT nLBA,
LPBYTE lpBuf,
DWORD dwBufLen
)
{
for (;;) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA
, lpBuf, dwBufLen, _T(__FUNCTION__), __LINE__)) {
break;
}
// check for sub offset
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
if (dwBufLen == CD_RAW_READ_SUBCODE_SIZE) {
AlignRowSubcode(lpBuf, lpSubcode);
}
else if (dwBufLen == CD_RAW_SECTOR_WITH_SUBCODE_SIZE) {
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_SIZE, lpSubcode);
}
#if 0
OutputCDSub96Align(lpSubcode, nLBA);
#endif
if ((lpSubcode[12] & 0x0f) == ADR_ENCODES_CURRENT_POSITION) {
break;
}
else {
nLBA++;
REVERSE_BYTES(&lpCmd[2], &nLBA);
}
}
return nLBA;
}
BOOL ReadCDForSearchingOffset(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
)
{
BOOL bRet = TRUE;
INT nDriveSampleOffset = 0;
BOOL bGetDriveOffset = GetDriveOffset(pDevice->szProductId, &nDriveSampleOffset);
#ifdef _DEBUG
if (pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX760A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX755A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX716AL ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX716A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX714A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX712A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX708A2 ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX708A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX704A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PREMIUM2 ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PREMIUM ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW5224A
) {
nDriveSampleOffset = 30;
bGetDriveOffset = TRUE;
}
else if (
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4824A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4012A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4012S
) {
nDriveSampleOffset = 98;
bGetDriveOffset = TRUE;
}
else if (!strncmp(pDevice->szProductId, "DVD-ROM TS-H353A", 16)) {
nDriveSampleOffset = 6;
bGetDriveOffset = TRUE;
}
#endif
if (!bGetDriveOffset) {
_TCHAR aBuf[6] = { 0 };
OutputString(
_T("This drive doesn't define in driveOffset.txt\n")
_T("Please input drive offset(Samples): "));
INT b = _tscanf(_T("%6[^\n]%*[^\n]"), aBuf);
b = _gettchar();
nDriveSampleOffset = _ttoi(aBuf);
}
INT nDriveOffset = nDriveSampleOffset * 4; // byte size * 4 = sample size
if (pDisc->SCSI.byAudioOnly) {
pDisc->MAIN.nCombinedOffset = nDriveOffset;
}
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
if (*pExecType == gd) {
pDisc->SCSI.nFirstLBAofDataTrack = FIRST_LBA_FOR_GD;
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::NoSub);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::Raw;
INT nLBA = pDisc->SCSI.nFirstLBAofDataTrack;
nLBA += GetLBAForSubOffset(pExtArg, pDevice, lpCmd, 0, lpBuf, CD_RAW_READ_SUBCODE_SIZE);
ZeroMemory(lpBuf, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE);
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::NoSub;
if (!pDisc->SCSI.byAudioOnly) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
bRet = FALSE;
}
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainQ;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainPack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
bRet = FALSE;
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_READ_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainC2Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
pExtArg->byC2 = FALSE;
pDevice->FEATURE.byC2ErrorData = FALSE;
// not return FALSE
}
}
else {
CDFLAG::_READ_CD::_EXPECTED_SECTOR_TYPE flg = CDFLAG::_READ_CD::CDDA;
// if (*pExecType == data) {
// flg = CDFLAG::_READ_CD::All;
// }
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(NULL, pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::NoC2, CDFLAG::_READ_CD::NoSub, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
INT nLBA = pDisc->SCSI.nFirstLBAofDataTrack;
nLBA += GetLBAForSubOffset(pExtArg, pDevice, lpCmd, 0, lpBuf, CD_RAW_SECTOR_WITH_SUBCODE_SIZE);
ZeroMemory(lpBuf, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
SetReadCDCommand(pExtArg, pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::byte294, CDFLAG::_READ_CD::NoSub, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
if (!pDisc->SCSI.byAudioOnly) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
bRet = FALSE;
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
// not return FALSE
}
if (!bRet) {
bRet = TRUE;
SetReadCDCommand(pExtArg, pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::byte296, CDFLAG::_READ_CD::NoSub, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
if (!pDisc->SCSI.byAudioOnly) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
bRet = FALSE;
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
// not return FALSE
}
}
}
else {
if (*pExecType != data && !pDisc->SCSI.byAudioOnly) {
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::NoSub;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
for(INT n = 1; n <= 10; n++) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
if (n == 10) {
bRet = FALSE;
break;
}
StartStopUnit(pExtArg, pDevice, STOP_UNIT_CODE, STOP_UNIT_CODE);
DWORD milliseconds = 30000;
OutputErrorString(_T("Retry %d/10 after %ld milliseconds\n"), n, milliseconds);
Sleep(milliseconds);
continue;
}
else {
break;
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, FALSE)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset, TRUE)) {
// not return FALSE
}
}
}
FreeAndNull(pBuf);
return bRet;
}
BOOL ReadCDForCheckingReadInOut(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
)
{
BOOL bRet = TRUE;
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainC2Raw);
}
else {
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainPack);
}
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
else {
// non plextor && support scrambled ripping
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(pExtArg, pDevice, &cdb, CDFLAG::_READ_CD::CDDA
, 1, CDFLAG::_READ_CD::byte294, CDFLAG::_READ_CD::NoSub, TRUE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
INT nLBA = 0;
if (pDisc->MAIN.nCombinedOffset < 0) {
OutputLogA(standardOut | fileDrive, "Checking reading lead-in -> ");
nLBA = -1;
}
else if (0 < pDisc->MAIN.nCombinedOffset) {
OutputLogA(standardOut | fileDrive, "Checking reading lead-out -> ");
nLBA = pDisc->SCSI.nAllLength;
}
// buffer is unused but buf null and size zero is semaphore error...
BYTE aBuf[CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE] = { 0 };
BYTE byScsiStatus = 0;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA, aBuf,
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
OutputLogA(standardOut | fileDrive, "OK\n");
#if 0
OutputCDMain(fileMainInfo, aBuf, nLBA, CD_RAW_SECTOR_SIZE);
#endif
return bRet;
}
BOOL ReadCDForCheckingSubQAdrFirst(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE* ppBuf,
LPBYTE* lpBuf,
LPBYTE lpCmd,
LPINT nOfs
)
{
if (!GetAlignedCallocatedBuffer(pDevice, ppBuf,
CD_RAW_SECTOR_WITH_SUBCODE_SIZE, lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainPack);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
*nOfs = pDisc->MAIN.nCombinedOffset % CD_RAW_SECTOR_SIZE;
if (pDisc->MAIN.nCombinedOffset < 0) {
*nOfs = CD_RAW_SECTOR_SIZE + *nOfs;
}
}
else {
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(NULL, pDevice, &cdb, CDFLAG::_READ_CD::All
, 1, CDFLAG::_READ_CD::byte294, CDFLAG::_READ_CD::Raw, TRUE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
return TRUE;
}
BOOL ReadCDForCheckingSubQAdr(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
LPBYTE lpCmd,
LPBYTE lpBuf,
INT nOfs,
BYTE byIdxOfTrack,
LPBYTE byMode,
BYTE bySessionNum,
FILE* fpCcd
)
{
BOOL bCheckMCN = FALSE;
BOOL bCheckISRC = FALSE;
CHAR szTmpCatalog[META_CATALOG_SIZE] = { 0 };
CHAR szTmpISRC[META_ISRC_SIZE] = { 0 };
INT nMCNIdx = 0;
INT nISRCIdx = 0;
INT nTmpMCNLBAList[9] = { -1 };
INT nTmpISRCLBAList[9] = { -1 };
INT nTmpLBA = pDisc->SCSI.lpFirstLBAListOnToc[byIdxOfTrack];
OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_TRACK_F(Check MCN and/or ISRC), lpCmd[0], lpCmd[10], byIdxOfTrack + 1);
for (INT nLBA = nTmpLBA; nLBA < nTmpLBA + 400; nLBA++) {
if (nLBA > pDisc->SCSI.nAllLength) {
bCheckMCN = FALSE;
bCheckISRC = FALSE;
break;
}
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA, lpBuf,
CD_RAW_SECTOR_WITH_SUBCODE_SIZE, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
LPBYTE lpBuf2 = lpBuf;
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
lpBuf2 = lpBuf + nOfs;
}
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_SIZE, lpSubcode);
#if 0
OutputCDMain(lpBuf2, nLBA, CD_RAW_SECTOR_SIZE);
OutputCDSub96Align(lpSubcode, nLBA);
#endif
if (nLBA == nTmpLBA) {
// this func is used to get a subch offset
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.present, lpSubcode);
BYTE byCtl = (BYTE)((lpSubcode[12] >> 4) & 0x0f);
*byMode = GetMode(lpBuf2, 0, byCtl, unscrambled);
}
BOOL bCRC = FALSE;
WORD crc16 = (WORD)GetCrc16CCITT(10, &lpSubcode[12]);
BYTE tmp1 = HIBYTE(crc16);
BYTE tmp2 = LOBYTE(crc16);
if (lpSubcode[22] == tmp1 && lpSubcode[23] == tmp2) {
bCRC = TRUE;
}
BYTE byAdr = (BYTE)(lpSubcode[12] & 0x0f);
if (byAdr == ADR_ENCODES_MEDIA_CATALOG) {
if (!bCRC) {
SetBufferFromMCN(pDisc, lpSubcode);
bCRC = TRUE;
}
BOOL bMCN = IsValidSubQMCN(lpSubcode);
if (!bMCN && bCRC) {
// force a invalid MCN to valid MCN
bMCN = bCRC;
}
if (bMCN && bCRC) {
nTmpMCNLBAList[nMCNIdx++] = nLBA;
CHAR szCatalog[META_CATALOG_SIZE] = { 0 };
if (!bCheckMCN) {
SetMCNToString(pDisc, lpSubcode, szCatalog, FALSE);
strncpy(szTmpCatalog, szCatalog, sizeof(szTmpCatalog) / sizeof(szTmpCatalog[0]));
szTmpCatalog[META_CATALOG_SIZE - 1] = 0;
bCheckMCN = bMCN;
}
else if (!pDisc->SUB.byCatalog) {
SetMCNToString(pDisc, lpSubcode, szCatalog, FALSE);
if (!strncmp(szTmpCatalog, szCatalog, sizeof(szTmpCatalog) / sizeof(szTmpCatalog[0]))) {
strncpy(pDisc->SUB.szCatalog, szCatalog, sizeof(pDisc->SUB.szCatalog) / sizeof(pDisc->SUB.szCatalog[0]));
pDisc->SUB.byCatalog = (BYTE)bMCN;
OutputCDSub96Align(lpSubcode, nLBA);
OutputDiscLogA("\tMCN: [%s]\n", szCatalog);
WriteCcdForDiscCatalog(pDisc, fpCcd);
}
}
}
}
else if (byAdr == ADR_ENCODES_ISRC) {
BOOL bISRC = IsValidSubQISRC(lpSubcode);
if (!bISRC && bCRC) {
// force a invalid ISRC to valid ISRC
bISRC = bCRC;
}
if (bISRC && bCRC) {
nTmpISRCLBAList[nISRCIdx++] = nLBA;
CHAR szISRC[META_ISRC_SIZE] = { 0 };
if (!bCheckISRC) {
SetISRCToString(pDisc, lpSubcode, szISRC, byIdxOfTrack, FALSE);
strncpy(szTmpISRC, szISRC, sizeof(szTmpISRC) / sizeof(szTmpISRC[0]));
szTmpISRC[META_ISRC_SIZE - 1] = 0;
bCheckISRC = bISRC;
}
else if (!pDisc->SUB.lpISRCList[byIdxOfTrack]) {
SetISRCToString(pDisc, lpSubcode, szISRC, byIdxOfTrack, FALSE);
if (!strncmp(szTmpISRC, szISRC, sizeof(szISRC) / sizeof(szISRC[0]))) {
strncpy(pDisc->SUB.pszISRC[byIdxOfTrack], szISRC, META_ISRC_SIZE);
pDisc->SUB.lpISRCList[byIdxOfTrack] = bISRC;
OutputCDSub96Align(lpSubcode, nLBA);
OutputDiscLogA("\tISRC: [%s]\n", szISRC);
}
}
}
}
}
if (bCheckMCN) {
SetLBAForFirstAdr(pDisc->SUB.nFirstLBAForMCN, pDisc->SUB.nRangeLBAForMCN,
"MCN", nTmpMCNLBAList, (BYTE)(bySessionNum - 1), pDevice->byPlxtrDrive);
}
if (bCheckISRC) {
SetLBAForFirstAdr(pDisc->SUB.nFirstLBAForISRC, pDisc->SUB.nRangeLBAForISRC,
"ISRC", nTmpISRCLBAList, (BYTE)(bySessionNum - 1), pDevice->byPlxtrDrive);
}
if (!bCheckMCN && !bCheckISRC) {
OutputDiscLogA("\tNothing\n");
}
return TRUE;
}
BOOL ReadCDForCheckingSubRtoW(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
)
{
BOOL bRet = TRUE;
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
BOOL bC2 = FALSE;
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainC2Raw);
bC2 = TRUE;
}
else {
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainPack);
}
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
else {
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(NULL, pDevice, &cdb, CDFLAG::_READ_CD::All,
1, CDFLAG::_READ_CD::NoC2, CDFLAG::_READ_CD::Raw, TRUE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
for (BYTE i = 0; i < pDisc->SCSI.toc.LastTrack; i++) {
try {
INT nTmpLBA = pDisc->SCSI.lpFirstLBAListOnToc[i] + 100;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nTmpLBA, lpBuf,
CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
BYTE lpSubcodeOrg[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
if (bC2) {
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, lpSubcode);
memcpy(lpSubcodeOrg, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, CD_RAW_READ_SUBCODE_SIZE);
}
else {
AlignRowSubcode(lpBuf + CD_RAW_SECTOR_SIZE, lpSubcode);
memcpy(lpSubcodeOrg, lpBuf + CD_RAW_SECTOR_SIZE, CD_RAW_READ_SUBCODE_SIZE);
}
OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_TRACK_F(Check CD+G), lpCmd[0], lpCmd[10], i + 1);
OutputCDSub96Align(lpSubcode, nTmpLBA);
SUB_R_TO_W scRW[4] = { 0 };
BYTE tmpCode[24] = { 0 };
INT nRtoW = 0;
BOOL bCDG = FALSE;
BOOL bCDEG = FALSE;
for (INT k = 0; k < 4; k++) {
for (INT j = 0; j < 24; j++) {
tmpCode[j] = (BYTE)(*(lpSubcodeOrg + (k * 24 + j)) & 0x3f);
}
memcpy(&scRW[k], tmpCode, sizeof(scRW[k]));
switch (scRW[k].command) {
case 0: // MODE 0, ITEM 0
break;
case 8: // MODE 1, ITEM 0
break;
case 9: // MODE 1, ITEM 1
bCDG = TRUE;
break;
case 10: // MODE 1, ITEM 2
bCDEG = TRUE;
break;
case 20: // MODE 2, ITEM 4
break;
case 24: // MODE 3, ITEM 0
break;
case 56: // MODE 7, ITEM 0
break;
default:
break;
}
}
INT nR = 0;
INT nS = 0;
INT nT = 0;
INT nU = 0;
INT nV = 0;
INT nW = 0;
for (INT j = 24; j < CD_RAW_READ_SUBCODE_SIZE; j++) {
if (24 <= j && j < 36) {
nR += lpSubcode[j];
}
else if (36 <= j && j < 48) {
nS += lpSubcode[j];
}
else if (48 <= j && j < 60) {
nT += lpSubcode[j];
}
else if (60 <= j && j < 72) {
nU += lpSubcode[j];
}
else if (72 <= j && j < 84) {
nV += lpSubcode[j];
}
else if (84 <= j && j < CD_RAW_READ_SUBCODE_SIZE) {
nW += lpSubcode[j];
}
nRtoW += lpSubcode[j];
}
// 0xff * 72 = 0x47b8
if (nRtoW == 0x47b8) {
// Why R-W bit is full? Basically, a R-W bit should be off except CD+G or CD-MIDI
// Alanis Morissette - Jagged Little Pill (UK)
// WipEout 2097: The Soundtrack
// and more..
// Sub Channel LBA 75
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P 00 00 00 00 00 00 00 00 00 00 00 00
// Q 01 01 01 00 01 00 00 00 03 00 2c b9
// R ff ff ff ff ff ff ff ff ff ff ff ff
// S ff ff ff ff ff ff ff ff ff ff ff ff
// T ff ff ff ff ff ff ff ff ff ff ff ff
// U ff ff ff ff ff ff ff ff ff ff ff ff
// V ff ff ff ff ff ff ff ff ff ff ff ff
// W ff ff ff ff ff ff ff ff ff ff ff ff
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0xff\n");
}
// (0x57 + 0x33 + 0x16) * 24 = 0xeb8
else if (nRtoW == 0xeb8) {
// [3DO] MegaRace (Japan) subch 0x02 on Plextor
// ========== LBA[000000, 0000000], Sub Channel ==========
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P ff ff ff ff ff ff ff ff ff ff ff ff
// Q 41 01 01 00 00 00 00 00 02 00 28 32
// R 57 33 13 57 33 13 57 33 13 57 33 13
// S 57 33 13 57 33 13 57 33 13 57 33 13
// T 57 33 13 57 33 13 57 33 13 57 33 13
// U 57 33 13 57 33 13 57 33 13 57 33 13
// V 57 33 13 57 33 13 57 33 13 57 33 13
// W 57 33 13 57 33 13 57 33 13 57 33 13
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0x57, 0x33, 0x13\n");
}
// 0x33 * 72 = 0xe58
else if (nRtoW == 0xe58) {
// [3DO] MegaRace (Japan) subch 0x08 on Plextor
// ========== LBA[000100, 0x00064], Sub Channel ==========
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P 00 00 00 00 00 00 00 00 00 00 00 00
// Q 41 01 01 00 01 25 00 00 03 25 01 87
// R 33 33 33 33 33 33 33 33 33 33 33 33
// S 33 33 33 33 33 33 33 33 33 33 33 33
// T 33 33 33 33 33 33 33 33 33 33 33 33
// U 33 33 33 33 33 33 33 33 33 33 33 33
// V 33 33 33 33 33 33 33 33 33 33 33 33
// W 33 33 33 33 33 33 33 33 33 33 33 33
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0x33\n");
}
else {
BOOL bAnyFull = FALSE;
// 0xff * 12 = 0xbf4
if (nR == 0xbf4) {
OutputDiscLogA("\tAll R is 0xff\n");
bAnyFull = TRUE;
}
if (nS == 0xbf4) {
OutputDiscLogA("\tAll S is 0xff\n");
bAnyFull = TRUE;
}
if (nT == 0xbf4) {
OutputDiscLogA("\tAll T is 0xff\n");
bAnyFull = TRUE;
}
if (nU == 0xbf4) {
OutputDiscLogA("\tAll U is 0xff\n");
bAnyFull = TRUE;
}
if (nV == 0xbf4) {
OutputDiscLogA("\tAll V is 0xff\n");
bAnyFull = TRUE;
}
if (nW == 0xbf4) {
OutputDiscLogA("\tAll W is 0xff\n");
bAnyFull = TRUE;
}
if (bAnyFull) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::AnyFull;
}
else {
if (bCDG && nRtoW > 0 && nRtoW != 0x200) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::CDG;
OutputDiscLogA("\tCD+G\n");
}
else if (bCDEG && nRtoW > 0 && nRtoW != 0x200) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::CDG;
OutputDiscLogA("\tCD+EG\n");
}
else if ((0 <= nR && nR <= 0x03) && (0 <= nS && nS <= 0x03) &&
(0 <= nT && nT <= 0x03) && (0 <= nU && nU <= 0x03) &&
(0 <= nV && nV <= 0x03) && (0 <= nW && nW <= 0x03) && nRtoW != 0) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::PSXSpecific;
OutputDiscLogA("\tRandom data exists (PSX)\n");
}
else {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Zero;
OutputDiscLogA("\tNothing\n");
}
}
}
}
catch (BOOL bErr) {
bRet = bErr;
}
OutputString(
_T("\rChecking SubRtoW (Track) %2u/%2u"), i + 1, pDisc->SCSI.toc.LastTrack);
}
OutputString(_T("\n"));
FreeAndNull(pBuf);
return bRet;
}
#if 0
LRESULT WINAPI CabinetCallback(
IN PVOID pMyInstallData,
IN UINT Notification,
IN UINT Param1,
IN UINT Param2
) {
UNREFERENCED_PARAMETER(Param2);
LRESULT lRetVal = NO_ERROR;
TCHAR szTarget[_MAX_PATH];
FILE_IN_CABINET_INFO *pInfo = NULL;
FILEPATHS *pFilePaths = NULL;
memcpy(szTarget, pMyInstallData, _MAX_PATH);
switch (Notification) {
case SPFILENOTIFY_CABINETINFO:
break;
case SPFILENOTIFY_FILEINCABINET:
pInfo = (FILE_IN_CABINET_INFO *)Param1;
lstrcat(szTarget, pInfo->NameInCabinet);
lstrcpy(pInfo->FullTargetName, szTarget);
lRetVal = FILEOP_DOIT; // Extract the file.
break;
case SPFILENOTIFY_NEEDNEWCABINET: // Unexpected.
break;
case SPFILENOTIFY_FILEEXTRACTED:
pFilePaths = (FILEPATHS *)Param1;
printf("Extracted %s\n", pFilePaths->Target);
break;
case SPFILENOTIFY_FILEOPDELAYED:
break;
}
return lRetVal;
}
BOOL IterateCabinet(
PTSTR pszCabFile
) {
_TCHAR szExtractdir[_MAX_PATH];
if (!GetCurrentDirectory(sizeof(szExtractdir) / sizeof(szExtractdir[0]), szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
lstrcat(szExtractdir, "\\extract_cab\\");
_TCHAR szExtractdirFind[_MAX_PATH];
memcpy(szExtractdirFind, szExtractdir, _MAX_PATH);
lstrcat(szExtractdirFind, "*");
if (PathFileExists(szExtractdir)) {
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(szExtractdirFind, &fd);
if (INVALID_HANDLE_VALUE == hFind) {
return FALSE;
}
do {
if (0 != _tcscmp(fd.cFileName, _T("."))
&& 0 != _tcscmp(fd.cFileName, _T(".."))) {
TCHAR szFoundFilePathName[_MAX_PATH];
_tcsncpy(szFoundFilePathName, szExtractdir, _MAX_PATH);
_tcsncat(szFoundFilePathName, fd.cFileName, _MAX_PATH);
if (!(FILE_ATTRIBUTE_DIRECTORY & fd.dwFileAttributes)) {
if (!DeleteFile(szFoundFilePathName)) {
FindClose(hFind);
return FALSE;
}
}
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
if (!MakeSureDirectoryPathExists(szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!SetupIterateCabinet(pszCabFile,
0, (PSP_FILE_CALLBACK)CabinetCallback, szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
return TRUE;
}
#endif
BOOL ReadCDForCheckingExe(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
CDB::_READ12* pCdb,
LPBYTE lpBuf
)
{
BOOL bRet = TRUE;
BYTE byTransferLen = 1;
DWORD dwSize = DISC_RAW_READ_SIZE;
SetCommandForTransferLength(pCdb, dwSize, &byTransferLen);
for (INT n = 0; pDisc->PROTECT.pExtentPosForExe[n] != 0; n++) {
#if 0
if (strstr(pDisc->PROTECT.pNameForExe[n], ".CAB") || strstr(pDisc->PROTECT.pNameForExe[n], ".cab")) {
// Get the absPath of cab file from path table
IterateCabinet(pDisc->PROTECT.pNameForExe[n]);
IterateCabinet("C:\\test\\disk1\\1.cab");
// Search exe, dll from extracted file
// Open exe, dll
// Read
}
else {
#endif
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)pCdb, pDisc->PROTECT.pExtentPosForExe[n],
lpBuf, dwSize, _T(__FUNCTION__), __LINE__)) {
// return FALSE;
// FIFA 99 (Europe) on PX-5224A
// LBA[000000, 0000000], [F:ReadCDForCheckingExe][L:734]
// OperationCode: 0xa8
// ScsiStatus: 0x02 = CHECK_CONDITION
// SenseData Key-Asc-Ascq: 03-02-83 = MEDIUM_ERROR - OTHER
// => The reason is unknown...
continue;
}
#if 0
}
#endif
WORD wMagic = MAKEWORD(lpBuf[0], lpBuf[1]);
if (wMagic == IMAGE_DOS_SIGNATURE) {
PIMAGE_DOS_HEADER pIDh = (PIMAGE_DOS_HEADER)&lpBuf[0];
if (dwSize < (DWORD)pIDh->e_lfanew) {
if (pDevice->dwMaxTransferLength < (DWORD)pIDh->e_lfanew) {
OutputVolDescLogA("%s: offset is very big (%lu). read skip [TODO]\n"
, pDisc->PROTECT.pNameForExe[n], pIDh->e_lfanew);
}
else {
SetCommandForTransferLength(pCdb, (DWORD)pIDh->e_lfanew, &byTransferLen);
dwSize = DWORD(DISC_RAW_READ_SIZE) * byTransferLen;
n--;
}
continue;
}
OutputVolDescLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_LBA
, pDisc->PROTECT.pExtentPosForExe[n], pDisc->PROTECT.pExtentPosForExe[n], pDisc->PROTECT.pNameForExe[n]);
OutputFsImageDosHeader(pIDh);
WORD wMagic2 = MAKEWORD(lpBuf[pIDh->e_lfanew], lpBuf[pIDh->e_lfanew + 1]);
if (wMagic2 == IMAGE_NT_SIGNATURE) {
PIMAGE_NT_HEADERS32 pINH = (PIMAGE_NT_HEADERS32)&lpBuf[pIDh->e_lfanew];
OutputFsImageNtHeader(pINH);
ULONG nOfs = pIDh->e_lfanew + sizeof(IMAGE_NT_HEADERS32);
for (INT i = 0; i < pINH->FileHeader.NumberOfSections; i++) {
OutputFsImageSectionHeader(pDisc, (PIMAGE_SECTION_HEADER)&lpBuf[nOfs]);
nOfs += sizeof(IMAGE_SECTION_HEADER);
}
}
else if (wMagic2 == IMAGE_OS2_SIGNATURE) {
OutputFsImageOS2Header((PIMAGE_OS2_HEADER)&lpBuf[pIDh->e_lfanew]);
}
else if (wMagic2 == IMAGE_OS2_SIGNATURE_LE) {
// TODO
}
else {
OutputVolDescLogA(
"%s: ImageNT,NE,LEHeader doesn't exist\n", pDisc->PROTECT.pNameForExe[n]);
}
}
else {
OutputVolDescLogA(
"%s: ImageDosHeader doesn't exist\n", pDisc->PROTECT.pNameForExe[n]);
}
OutputString(_T("\rChecking EXE %4d"), n + 1);
}
OutputString(_T("\n"));
return bRet;
}
BOOL ReadCDFor3DODirectory(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
CDB::_READ12* pCdb,
LPCH pPath,
INT nLBA
)
{
BOOL bRet = TRUE;
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
DISC_RAW_READ_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
try {
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)pCdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
LONG lOfs = THREEDO_DIR_HEADER_SIZE;
LONG lDirSize =
MAKELONG(MAKEWORD(lpBuf[15], lpBuf[14]), MAKEWORD(lpBuf[13], lpBuf[12]));
OutputFs3doDirectoryRecord(lpBuf, nLBA, pPath, lDirSize);
// next dir
CHAR szNewPath[_MAX_PATH] = { 0 };
CHAR fname[32] = { 0 };
while (lOfs < lDirSize) {
LPBYTE lpDirEnt = lpBuf + lOfs;
LONG lFlags = MAKELONG(
MAKEWORD(lpDirEnt[3], lpDirEnt[2]), MAKEWORD(lpDirEnt[1], lpDirEnt[0]));
strncpy(fname, (LPCH)&lpDirEnt[32], sizeof(fname));
LONG lastCopy = MAKELONG(
MAKEWORD(lpDirEnt[67], lpDirEnt[66]), MAKEWORD(lpDirEnt[65], lpDirEnt[64]));
lOfs += THREEDO_DIR_ENTRY_SIZE;
if ((lFlags & 0xff) == 7) {
sprintf(szNewPath, "%s%s/", pPath, fname);
if (!ReadCDFor3DODirectory(pExtArg, pDevice, pDisc, pCdb, szNewPath,
MAKELONG(MAKEWORD(lpDirEnt[71], lpDirEnt[70]), MAKEWORD(lpDirEnt[69], lpDirEnt[68])))) {
throw FALSE;
}
}
for (LONG i = 0; i < lastCopy; i++) {
lOfs += sizeof(LONG);
}
}
}
catch (BOOL bErr) {
bRet = bErr;
}
FreeAndNull(pBuf);
return bRet;
}
BOOL ReadCDForFileSystem(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
)
{
BOOL bRet = TRUE;
for (BYTE i = 0; i < pDisc->SCSI.toc.LastTrack; i++) {
if ((pDisc->SCSI.toc.TrackData[i].Control & AUDIO_DATA_TRACK) == AUDIO_DATA_TRACK) {
// for Label Gate CD, XCP
if (i > 1 && pDisc->SCSI.lpLastLBAListOnToc[i] - pDisc->SCSI.lpFirstLBAListOnToc[i] + 1 <= 750) {
return TRUE;
}
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
pDevice->dwMaxTransferLength, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
CDB::_READ12 cdb = { 0 };
cdb.OperationCode = SCSIOP_READ12;
cdb.LogicalUnitNumber = pDevice->address.Lun;
cdb.TransferLength[3] = 1;
BOOL bPVD = FALSE;
PDIRECTORY_RECORD pDirRec = NULL;
try {
// general data track disc
DWORD dwPathTblSize, dwPathTblPos, dwRootDataLen = 0;
if (!ReadVolumeDescriptor(pExtArg, pDevice, pDisc, i, &cdb
, lpBuf, &bPVD, &dwPathTblSize, &dwPathTblPos, &dwRootDataLen)) {
throw FALSE;
}
if (bPVD) {
// TODO: buf size
pDirRec = (PDIRECTORY_RECORD)calloc(8192, sizeof(DIRECTORY_RECORD));
if (!pDirRec) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
INT nDirPosNum = 0;
if (!ReadPathTableRecord(pExtArg, pDevice, pDisc, &cdb
, dwPathTblSize, dwPathTblPos, pDirRec, &nDirPosNum)) {
throw FALSE;
}
if (!ReadDirectoryRecord(pExtArg, pDevice, pDisc, &cdb
, lpBuf, dwRootDataLen, pDirRec, nDirPosNum)) {
throw FALSE;
}
if (!ReadCDForCheckingExe(pExtArg, pDevice, pDisc, &cdb, lpBuf)) {
throw FALSE;
}
if (pDisc->PROTECT.byExist) {
OutputLogA(standardOut | fileDisc, "Detected [%s], Skip error from %d to %d\n"
, pDisc->PROTECT.name, pDisc->PROTECT.ERROR_SECTOR.nExtentPos
, pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize);
}
}
else {
BOOL bOtherHeader = FALSE;
// for pce, pc-fx
INT nLBA = pDisc->SCSI.nFirstLBAofDataTrack;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (IsValidPceSector(lpBuf)) {
OutputFsPceStuff(lpBuf, nLBA);
nLBA = pDisc->SCSI.nFirstLBAofDataTrack + 1;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
OutputFsPceBootSector(lpBuf, nLBA);
bOtherHeader = TRUE;
}
else if (IsValidPcfxSector(lpBuf)) {
OutputFsPcfxHeader(lpBuf, nLBA);
nLBA = pDisc->SCSI.nFirstLBAofDataTrack + 1;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
OutputFsPcfxSector(lpBuf, nLBA);
bOtherHeader = TRUE;
}
if (!bOtherHeader) {
// for 3DO
nLBA = 0;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (IsValid3doDataHeader(lpBuf)) {
OutputFs3doHeader(lpBuf, nLBA);
if (!ReadCDFor3DODirectory(pExtArg, pDevice, pDisc, &cdb, "/",
MAKELONG(MAKEWORD(lpBuf[103], lpBuf[102]),
MAKEWORD(lpBuf[101], lpBuf[100])))) {
throw FALSE;
}
bOtherHeader = TRUE;
}
}
if (!bOtherHeader) {
// for MAC pattern 1
nLBA = 1;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (IsValidMacDataHeader(lpBuf + 1024)) {
OutputFsMasterDirectoryBlocks(lpBuf + 1024, nLBA);
bOtherHeader = TRUE;
}
else if (IsValidMacDataHeader(lpBuf + 512)) {
OutputFsMasterDirectoryBlocks(lpBuf + 512, nLBA);
bOtherHeader = TRUE;
}
// for MAC pattern 2
nLBA = 16;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, lpBuf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (IsValidMacDataHeader(lpBuf + 1024)) {
OutputFsMasterDirectoryBlocks(lpBuf + 1024, nLBA);
bOtherHeader = TRUE;
}
}
if (bOtherHeader) {
FreeAndNull(pBuf);
break;
}
}
}
catch (BOOL bErr) {
bRet = bErr;
}
FreeAndNull(pDirRec);
FreeAndNull(pBuf);
}
}
return bRet;
}
BOOL ExecCheckingByteOrder(
PEXT_ARG pExtArg,
PDEVICE pDevice,
CDFLAG::_READ_CD::_ERROR_FLAGS c2,
CDFLAG::_READ_CD::_SUB_CHANNEL_SELECTION sub
)
{
DWORD dwBufLen =
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE + pDevice->TRANSFER.dwAdditionalBufLen;
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
dwBufLen, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainC2Raw);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
else {
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(pExtArg, pDevice, &cdb
, CDFLAG::_READ_CD::All, 1, c2, sub, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
BOOL bRet = TRUE;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, 0, lpBuf, dwBufLen, _T(__FUNCTION__), __LINE__)) {
OutputLogA(standardError | fileDrive,
"This drive doesn't support [OpCode: %#02x, C2flag: %x, SubCode: %x]\n"
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
bRet = FALSE;
}
else {
OutputDriveLogA(OUTPUT_DHYPHEN_PLUS_STR(Check main+c2+sub));
OutputCDC2Error296(fileDrive, lpBuf + CD_RAW_SECTOR_SIZE, 0);
OutputCDSub96Raw(fileDrive, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, 0);
OutputDriveLogA(OUTPUT_DHYPHEN_PLUS_STR(Check main+sub+c2));
OutputCDSub96Raw(fileDrive, lpBuf + CD_RAW_SECTOR_SIZE, 0);
OutputCDC2Error296(fileDrive, lpBuf + CD_RAW_SECTOR_WITH_SUBCODE_SIZE, 0);
BYTE subcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
memcpy(subcode, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, CD_RAW_READ_SUBCODE_SIZE);
// check main + c2 + sub order
BOOL bMainSubC2 = TRUE;
for (INT i = 0; i < CD_RAW_READ_SUBCODE_SIZE; i++) {
if (subcode[i]) {
bMainSubC2 = FALSE;
break;
}
}
if (bMainSubC2) {
pDevice->driveOrder = DRIVE_DATA_ORDER::MainSubC2;
}
}
FreeAndNull(pBuf);
return bRet;
}
VOID ReadCDForCheckingByteOrder(
PEXT_ARG pExtArg,
PDEVICE pDevice,
CDFLAG::_READ_CD::_ERROR_FLAGS* c2
)
{
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::NoC2);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
*c2 = CDFLAG::_READ_CD::byte294;
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::MainC2Sub);
pDevice->driveOrder = DRIVE_DATA_ORDER::MainC2Sub;
CDFLAG::_READ_CD::_SUB_CHANNEL_SELECTION sub = CDFLAG::_READ_CD::Raw;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
BOOL bRet = FALSE;
if (!pExtArg->byD8 && !pDevice->byPlxtrDrive) {
bRet = TRUE;
sub = CDFLAG::_READ_CD::Q;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
sub = CDFLAG::_READ_CD::Pack;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
*c2 = CDFLAG::_READ_CD::byte296;
sub = CDFLAG::_READ_CD::Raw;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
bRet = FALSE;
}
sub = CDFLAG::_READ_CD::Q;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
sub = CDFLAG::_READ_CD::Pack;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
}
if (!bRet) {
OutputLogA(standardError | fileDrive,
"[WARNING] This drive doesn't support reporting C2 error. Disabled /c2\n");
*c2 = CDFLAG::_READ_CD::NoC2;
pDevice->driveOrder = DRIVE_DATA_ORDER::NoC2;
pDevice->FEATURE.byC2ErrorData = FALSE;
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::NoC2);
}
}
if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainSubC2) {
OutputDriveLogA(
"\tByte order of this drive is main + sub + c2\n");
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::MainSubC2);
}
else if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainC2Sub) {
OutputDriveLogA(
"\tByte order of this drive is main + c2 + sub\n");
}
}
#ifdef _DEBUG
OutputString(
_T("TransferLen %lu, BufLen %lubyte, AdditionalBufLen %lubyte, AllBufLen %lubyte, BufC2Offset %lubyte, BufSubOffset %lubyte\n"),
pDevice->TRANSFER.dwTransferLen, pDevice->TRANSFER.dwBufLen,
pDevice->TRANSFER.dwAdditionalBufLen, pDevice->TRANSFER.dwAllBufLen,
pDevice->TRANSFER.dwBufC2Offset, pDevice->TRANSFER.dwBufSubOffset);
#endif
}
BOOL ExecReadCDForC2(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
LPBYTE lpCmd,
INT nLBA,
LPBYTE lpBuf,
LPCTSTR pszFuncName,
LONG lLineNum
)
{
REVERSE_BYTES(&lpCmd[2], &nLBA);
BYTE byScsiStatus = 0;
if (!ScsiPassThroughDirect(pExtArg, pDevice, lpCmd, CDB12GENERIC_LENGTH, lpBuf,
pDevice->TRANSFER.dwBufLen + pDevice->TRANSFER.dwAdditionalBufLen, &byScsiStatus, pszFuncName, lLineNum)) {
if (pExtArg->byReadContinue) {
return RETURNED_CONTINUE;
}
else {
return RETURNED_FALSE;
}
}
if (byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
if (*pExecType != gd) {
return RETURNED_CONTINUE;
}
else {
return RETURNED_FALSE;
}
}
return RETURNED_NO_C2_ERROR_1ST;
}
// http://tmkk.undo.jp/xld/secure_ripping.html
// https://forum.dbpoweramp.com/showthread.php?33676
BOOL FlushDriveCache(
PEXT_ARG pExtArg,
PDEVICE pDevice,
INT nLBA
)
{
CDB::_READ12 cdb = { 0 };
cdb.OperationCode = SCSIOP_READ12;
cdb.ForceUnitAccess = TRUE;
cdb.LogicalUnitNumber = pDevice->address.Lun;
INT NextLBAAddress = nLBA + 1;
REVERSE_BYTES(&cdb.LogicalBlock, &NextLBAAddress);
BYTE byScsiStatus = 0;
if (!ScsiPassThroughDirect(pExtArg, pDevice, (LPBYTE)&cdb, CDB12GENERIC_LENGTH,
NULL, 0, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
return TRUE;
}
BOOL ProcessReadCD(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
PC2_ERROR_PER_SECTOR pC2ErrorPerSector,
UINT uiC2ErrorLBACnt,
LPBYTE lpCmd,
INT nLBA
)
{
BOOL bRet = RETURNED_NO_C2_ERROR_1ST;
if (*pExecType != gd && !pExtArg->byRawDump && pDevice->bySuccessReadTocFull) {
if (pDisc->SCSI.nFirstLBAof2ndSession != -1) {
if (pExtArg->byReverse) {
if (pDisc->SCSI.nFirstLBAof2ndSession == nLBA + 1) {
OutputMainInfoLogA(
"Skip from Leadout of Session 1 [%d, %#x] to Leadin of Session 2 [%d, %#x]\n",
pDisc->SCSI.nFirstLBAofLeadout, pDisc->SCSI.nFirstLBAofLeadout,
pDisc->SCSI.nFirstLBAof2ndSession - 1, pDisc->SCSI.nFirstLBAof2ndSession - 1);
pDiscPerSector->subQ.prev.nAbsoluteTime = nLBA - SESSION_TO_SESSION_SKIP_LBA - 150;
return RETURNED_SKIP_LBA;
}
}
else {
if (pDisc->MAIN.nFixFirstLBAofLeadout == nLBA) {
OutputMainInfoLogA(
"Skip from Leadout of Session 1 [%d, %#x] to Leadin of Session 2 [%d, %#x]\n",
pDisc->SCSI.nFirstLBAofLeadout, pDisc->SCSI.nFirstLBAofLeadout,
pDisc->SCSI.nFirstLBAof2ndSession - 1, pDisc->SCSI.nFirstLBAof2ndSession - 1);
if (pDisc->MAIN.nCombinedOffset > 0) {
pDiscPerSector->subQ.prev.nAbsoluteTime =
nLBA + SESSION_TO_SESSION_SKIP_LBA + 150 - pDisc->MAIN.nAdjustSectorNum - 1;
}
else if (pDisc->MAIN.nCombinedOffset < 0) {
pDiscPerSector->subQ.prev.nAbsoluteTime =
nLBA + SESSION_TO_SESSION_SKIP_LBA + 150 + pDisc->MAIN.nAdjustSectorNum;
}
return RETURNED_SKIP_LBA;
}
}
}
}
if (pExtArg->byFua) {
FlushDriveCache(pExtArg, pDevice, nLBA);
}
bRet = ExecReadCDForC2(pExecType, pExtArg, pDevice, lpCmd, nLBA,
pDiscPerSector->data.present, _T(__FUNCTION__), __LINE__);
#if 0
if (0 <= nLBA && nLBA <= 10) {
OutputCDMain(fileMainInfo, pDiscPerSector->data.present, nLBA, CD_RAW_SECTOR_SIZE);
}
#endif
if (bRet == RETURNED_NO_C2_ERROR_1ST) {
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
if (pC2ErrorPerSector && pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
if (pExtArg->byReadContinue && pDisc->PROTECT.byExist &&
(pDisc->PROTECT.ERROR_SECTOR.nExtentPos <= nLBA &&
nLBA <= pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize)) {
// skip check c2 error
ZeroMemory(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufC2Offset, CD_RAW_READ_C2_294_SIZE);
}
else {
bRet = ContainsC2Error(
pC2ErrorPerSector, pDevice, pDisc, pDiscPerSector->data.present, uiC2ErrorLBACnt);
}
}
if (!(pExtArg->byReadContinue && pDisc->PROTECT.byExist &&
(pDisc->PROTECT.ERROR_SECTOR.nExtentPos <= nLBA &&
nLBA <= pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize))) {
if (pDiscPerSector->data.next != NULL && 1 <= pExtArg->dwSubAddionalNum) {
ExecReadCDForC2(pExecType, pExtArg, pDevice, lpCmd,
nLBA + 1, pDiscPerSector->data.next, _T(__FUNCTION__), __LINE__);
AlignRowSubcode(pDiscPerSector->data.next + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.next);
if (pDiscPerSector->data.nextNext != NULL && 2 <= pExtArg->dwSubAddionalNum) {
ExecReadCDForC2(pExecType, pExtArg, pDevice, lpCmd,
nLBA + 2, pDiscPerSector->data.nextNext, _T(__FUNCTION__), __LINE__);
AlignRowSubcode(pDiscPerSector->data.nextNext + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.nextNext);
}
}
}
}
if (pExtArg->byReadContinue && pDisc->PROTECT.byExist &&
(pDisc->PROTECT.ERROR_SECTOR.nExtentPos <= nLBA &&
nLBA <= pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize)) {
if (bRet == RETURNED_CONTINUE) {
if (pC2ErrorPerSector && pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
// skip check c2 error
ZeroMemory(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufC2Offset, CD_RAW_READ_C2_294_SIZE);
}
}
// replace sub to sub of prev
ZeroMemory(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, CD_RAW_READ_SUBCODE_SIZE);
ZeroMemory(pDiscPerSector->subcode.present, CD_RAW_READ_SUBCODE_SIZE);
SetBufferFromTmpSubQData(pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present, 0);
if (pDiscPerSector->data.next != NULL && 1 <= pExtArg->dwSubAddionalNum) {
SetBufferFromTmpSubQData(pDiscPerSector->subQ.present, pDiscPerSector->subcode.next, 0);
if (pDiscPerSector->data.nextNext != NULL && 2 <= pExtArg->dwSubAddionalNum) {
SetBufferFromTmpSubQData(pDiscPerSector->subQ.next, pDiscPerSector->subcode.nextNext, 0);
}
}
}
return bRet;
}
BOOL ReadCDForRereadingSector(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
PC2_ERROR_PER_SECTOR pC2ErrorPerSector,
UINT uiC2ErrorLBACnt,
LPBYTE lpCmd,
FILE* fpImg
)
{
BOOL bProcessRet = RETURNED_NO_C2_ERROR_1ST;
UINT uiCnt = 0;
UINT uiContinueCnt = 0;
if (uiC2ErrorLBACnt > 0) {
if (pDevice->FEATURE.bySetCDSpeed) {
OutputString(
_T("\nChanged reading speed: %lux\n"), pExtArg->dwRereadSpeedNum);
SetDiscSpeed(pExecType, pExtArg, pDevice, pExtArg->dwRereadSpeedNum);
}
// forced fua ripping
if (!pExtArg->byFua) {
OutputString(_T("Set the force unit access\n"));
pExtArg->byFua = TRUE;
}
}
while (uiC2ErrorLBACnt > 0) {
if (uiCnt == pExtArg->dwMaxRereadNum) {
OutputString(_T("\nReread reached max: %u"), uiCnt);
bProcessRet = RETURNED_FALSE;
break;
}
UINT uiC2ErrorLBACntBackup = uiC2ErrorLBACnt;
uiC2ErrorLBACnt = 0;
SetC2ErrorBackup(pC2ErrorPerSector,
uiC2ErrorLBACntBackup, pDevice->TRANSFER.dwAllBufLen);
UINT i = 0;
for (INT nLBA = pC2ErrorPerSector[0].nErrorLBANumBackup; i < uiC2ErrorLBACntBackup; i++) {
OutputString(
_T("\rReread times: %4u, Error sector num: %4u/%4u"),
uiCnt + 1, i + 1, uiC2ErrorLBACntBackup);
nLBA = pC2ErrorPerSector[i].nErrorLBANumBackup;
bProcessRet = ProcessReadCD(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, pC2ErrorPerSector, uiC2ErrorLBACnt, lpCmd, nLBA);
//#define C2TEST
#if defined C2TEST
if (nLBA == 100 && uiCnt == 1) {
memset(pDiscPerSector->data.present, 0xff, 2352);
bProcessRet = RETURNED_EXIST_C2_ERROR;
}
#endif
if (bProcessRet == RETURNED_EXIST_C2_ERROR) {
SetC2ErrorData(pC2ErrorPerSector, nLBA, &uiC2ErrorLBACnt, FALSE);
}
else if (bProcessRet == RETURNED_NO_C2_ERROR_1ST) {
if (pC2ErrorPerSector[i].byErrorFlagBackup == RETURNED_NO_C2_ERROR_1ST) {
if (ContainsDiffByte(pC2ErrorPerSector, pDiscPerSector->data.present, i)) {
SetNoC2ErrorExistsByteErrorData(pC2ErrorPerSector, nLBA, &uiC2ErrorLBACnt);
}
else {
LONG lPos = LONG(CD_RAW_SECTOR_SIZE * nLBA - pDisc->MAIN.nCombinedOffset);
LONG lEndPos = lPos + CD_RAW_SECTOR_SIZE - 1;
INT nPosOrg = lPos + pDisc->MAIN.nCombinedOffset;
INT nEndPosOrg = lPos + pDisc->MAIN.nCombinedOffset + CD_RAW_SECTOR_SIZE - 1;
OutputC2ErrorWithLBALogA(
"BytePos[%d-%d, %#x-%#x] Reread data matched. Rewrote from [%ld, %#lx] to [%ld, %#lx]\n",
nLBA, nPosOrg, nEndPosOrg, nPosOrg, nEndPosOrg, lPos, lPos, lEndPos, lEndPos);
fseek(fpImg, lPos, SEEK_SET);
// Write track to scrambled again
WriteMainChannel(pExtArg, pDisc, pDiscPerSector->data.present, nLBA, fpImg);
}
}
else {
SetNoC2ErrorData(pC2ErrorPerSector, pDiscPerSector->data.present,
nLBA, pDevice->TRANSFER.dwAllBufLen, &uiC2ErrorLBACnt);
}
}
else if (bProcessRet == RETURNED_CONTINUE) {
uiContinueCnt++;
}
else if (bProcessRet == RETURNED_FALSE) {
break;
}
}
uiCnt++;
}
OutputString(_T("\n"));
if (uiCnt == 0 && uiC2ErrorLBACnt == 0) {
OutputLogA(standardOut | fileC2Error, "No C2 errors\n");
}
else if (uiCnt > 0 && uiC2ErrorLBACnt == 0 && uiContinueCnt == 0) {
OutputLogA(standardOut | fileC2Error,
"C2 errors was fixed at all\n"
"But please dump at least twice (if possible, using different drives)\n");
}
else if (uiC2ErrorLBACnt > 0 || uiContinueCnt > 0) {
OutputLogA(standardError | fileC2Error,
"There are unrecoverable errors: %d\n", uiC2ErrorLBACnt);
}
return bProcessRet;
}
VOID ExecEccEdc(
BYTE byReadContinue,
LPCTSTR pszImgPath,
_DISC::_PROTECT::_ERROR_SECTOR errorSector
)
{
CONST INT nCmdSize = 6;
CONST INT nStrSize = _MAX_PATH * 2 + nCmdSize;
_TCHAR str[nStrSize] = { 0 };
_TCHAR cmd[nCmdSize] = { _T("check") };
INT nStartLBA = errorSector.nExtentPos;
INT nEndLBA = errorSector.nExtentPos + errorSector.nSectorSize;
if (byReadContinue) {
_tcsncpy(cmd, _T("fix"), sizeof(cmd) / sizeof(cmd[0]));
}
if (GetEccEdcCmd(str, nStrSize, cmd, pszImgPath, nStartLBA, nEndLBA)) {
OutputString(_T("Exec %s\n"), str);
_tsystem(str);
}
}
VOID ProcessReturnedContinue(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
INT nLBA,
INT nMainDataType,
BYTE byCurrentTrackNum,
FILE* fpImg,
FILE* fpSub,
FILE* fpC2,
FILE* fpParse
)
{
#if 1
if ((pDiscPerSector->subQ.prev.byCtl & AUDIO_DATA_TRACK) == AUDIO_DATA_TRACK) {
OutputCDMain(fileMainError,
pDiscPerSector->mainHeader.present, nLBA, MAINHEADER_MODE1_SIZE);
}
#endif
UpdateTmpMainHeader(&pDiscPerSector->mainHeader,
(LPBYTE)&pDiscPerSector->mainHeader.prev, pDiscPerSector->subQ.prev.byCtl, nMainDataType);
WriteErrorBuffer(pExecType, pExtArg, pDevice, pDisc, pDiscPerSector,
scrambled_table, nLBA, byCurrentTrackNum, fpImg, fpSub, fpC2, fpParse);
#if 1
if ((pDiscPerSector->subQ.prev.byCtl & AUDIO_DATA_TRACK) == AUDIO_DATA_TRACK) {
if (pExtArg->byBe) {
OutputCDMain(fileMainError,
pDiscPerSector->mainHeader.present, nLBA, MAINHEADER_MODE1_SIZE);
}
else {
OutputCDMain(fileMainError,
pDiscPerSector->data.present + pDisc->MAIN.uiMainDataSlideSize, nLBA, MAINHEADER_MODE1_SIZE);
}
}
#endif
if (pDiscPerSector->subQ.prev.byIndex == 0) {
pDiscPerSector->subQ.prev.nRelativeTime--;
}
else {
pDiscPerSector->subQ.prev.nRelativeTime++;
}
pDiscPerSector->subQ.prev.nAbsoluteTime++;
}
BOOL ReadCDForCheckingSecuROM(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
LPBYTE lpCmd
)
{
#ifdef _DEBUG
WORD w = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.present[12]);
OutputSubInfoWithLBALogA(
"CRC-16 is original:[%02x%02x], recalc:[%04x] and XORed with 0x8001:[%02x%02x]\n"
, -1, 0, pDiscPerSector->subcode.present[22], pDiscPerSector->subcode.present[23]
, w, pDiscPerSector->subcode.present[22] ^ 0x80, pDiscPerSector->subcode.present[23] ^ 0x01);
#endif
if (pExtArg->byIntentionalSub && pDisc->PROTECT.byExist != securomV1 &&
(pDiscPerSector->subcode.present[12] == 0x41 || pDiscPerSector->subcode.present[12] == 0x61)) {
WORD crc16 = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.present[12]);
WORD bufcrc = MAKEWORD(pDiscPerSector->subcode.present[23], pDiscPerSector->subcode.present[22]);
INT nRLBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.present[15])
, BcdToDec(pDiscPerSector->subcode.present[16]), BcdToDec(pDiscPerSector->subcode.present[17]));
INT nALBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.present[19])
, BcdToDec(pDiscPerSector->subcode.present[20]), BcdToDec(pDiscPerSector->subcode.present[21]));
if (crc16 != bufcrc) {
OutputSubInfoWithLBALogA(
"Detected intentional error. CRC-16 is original:[%02x%02x] and XORed with 0x8001:[%02x%02x] "
, -1, 0, pDiscPerSector->subcode.present[22] ^ 0x80, pDiscPerSector->subcode.present[23] ^ 0x01
, pDiscPerSector->subcode.present[22], pDiscPerSector->subcode.present[23]);
OutputSubInfoLogA(
"RMSF[%02x:%02x:%02x] AMSF[%02x:%02x:%02x]\n"
, pDiscPerSector->subcode.present[15], pDiscPerSector->subcode.present[16], pDiscPerSector->subcode.present[17]
, pDiscPerSector->subcode.present[19], pDiscPerSector->subcode.present[20], pDiscPerSector->subcode.present[21]);
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA -1 => SecuROM Type4 (a.k.a. NEW)\n");
OutputIntentionalSubchannel(-1, &pDiscPerSector->subcode.present[12]);
pDisc->PROTECT.byExist = securomV4;
pDiscPerSector->subQ.prev.nRelativeTime = -1;
pDiscPerSector->subQ.prev.nAbsoluteTime = 149;
}
else if ((nRLBA == 167295 || nRLBA == 0) && nALBA == 150) {
OutputSubInfoWithLBALogA(
"Detected shifted sub. RMSF[%02x:%02x:%02x] AMSF[%02x:%02x:%02x]\n"
, -1, 0, pDiscPerSector->subcode.present[15], pDiscPerSector->subcode.present[16], pDiscPerSector->subcode.present[17]
, pDiscPerSector->subcode.present[19], pDiscPerSector->subcode.present[20], pDiscPerSector->subcode.present[21]);
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA -1 => SecuROM Type3 (a.k.a. NEW)\n");
OutputIntentionalSubchannel(-1, &pDiscPerSector->subcode.present[12]);
pDisc->PROTECT.byExist = securomV3;
if (pDisc->SUB.nSubchOffset) {
pDisc->SUB.nSubchOffset -= 1;
}
pDiscPerSector->subQ.prev.nRelativeTime = -1;
pDiscPerSector->subQ.prev.nAbsoluteTime = 149;
}
else if (pDisc->SCSI.nAllLength > 5000) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, 5000, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
nRLBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.present[15])
, BcdToDec(pDiscPerSector->subcode.present[16]), BcdToDec(pDiscPerSector->subcode.present[17]));
nALBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.present[19])
, BcdToDec(pDiscPerSector->subcode.present[20]), BcdToDec(pDiscPerSector->subcode.present[21]));
if (nRLBA == 5001 && nALBA == 5151) {
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA 5000 => SecuROM Type2 (a.k.a. NEW)\n");
pDisc->PROTECT.byExist = securomV2;
}
else if (pDisc->PROTECT.byExist == securomTmp) {
pDisc->PROTECT.byExist = securomV1;
}
else {
for (INT nTmpLBA = 40000; nTmpLBA < 45800; nTmpLBA++) {
if (pDisc->SCSI.nAllLength > nTmpLBA) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nTmpLBA, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
WORD reCalcCrc16 = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.present[12]);
WORD reCalcXorCrc16 = (WORD)(reCalcCrc16 ^ 0x0080);
if (pDiscPerSector->subcode.present[22] == HIBYTE(reCalcXorCrc16) &&
pDiscPerSector->subcode.present[23] == LOBYTE(reCalcXorCrc16)) {
OutputLogA(standardOut | fileDisc
, "Detected intentional subchannel in LBA %d => SecuROM Type1 (a.k.a. OLD)\n", nTmpLBA);
pDisc->PROTECT.byExist = securomV1;
break;
}
}
}
if (pDisc->PROTECT.byExist != securomV1) {
OutputLogA(standardOut | fileDisc, "SecuROM sector not found \n");
}
}
}
else {
OutputLogA(standardOut | fileDisc, "SecuROM sector not found \n");
}
}
return TRUE;
}
BOOL ReadCDAll(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
PC2_ERROR_PER_SECTOR pC2ErrorPerSector,
CDFLAG::_READ_CD::_ERROR_FLAGS c2,
LPCTSTR pszPath,
FILE* fpCcd,
FILE* fpC2
)
{
if (pDisc->SCSI.toc.FirstTrack < 1 || 99 < pDisc->SCSI.toc.FirstTrack ||
pDisc->SCSI.toc.LastTrack < 1 || 99 < pDisc->SCSI.toc.LastTrack) {
return FALSE;
}
FILE* fpImg = NULL;
_TCHAR pszOutReverseScmFile[_MAX_PATH] = { 0 };
_TCHAR pszOutScmFile[_MAX_PATH] = { 0 };
if (pExtArg->byReverse) {
if (NULL == (fpImg = CreateOrOpenFile(pszPath, _T("_reverse"),
pszOutReverseScmFile, NULL, NULL, _T(".scm"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
}
else {
if (NULL == (fpImg = CreateOrOpenFile(pszPath, NULL,
pszOutScmFile, NULL, NULL, _T(".scm"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
}
BOOL bRet = TRUE;
FILE* fpCue = NULL;
FILE* fpCueForImg = NULL;
FILE* fpParse = NULL;
FILE* fpSub = NULL;
LPBYTE pBuf = NULL;
LPBYTE pNextBuf = NULL;
LPBYTE pNextNextBuf = NULL;
INT nMainDataType = scrambled;
if (pExtArg->byBe) {
nMainDataType = unscrambled;
}
try {
// init start
if (NULL == (fpCue = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpCueForImg = CreateOrOpenFile(
pszPath, _T("_img"), NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpParse = CreateOrOpenFile(
pszPath, _T("_sub"), NULL, NULL, NULL, _T(".txt"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpSub = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".sub"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
// store main + (c2) + sub data all
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.present, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (1 <= pExtArg->dwSubAddionalNum) {
if (!GetAlignedCallocatedBuffer(pDevice, &pNextBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.next, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (2 <= pExtArg->dwSubAddionalNum) {
if (!GetAlignedCallocatedBuffer(pDevice, &pNextNextBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.nextNext, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
}
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
_TCHAR szSubCode[5] = { 0 };
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
_tcsncpy(szSubCode, _T("Raw"), sizeof(szSubCode) / sizeof(szSubCode[0]));
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainC2Raw);
}
else {
_tcsncpy(szSubCode, _T("Pack"), sizeof(szSubCode) / sizeof(szSubCode[0]));
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainPack);
}
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
else {
// non plextor && support scrambled ripping
CDB::_READ_CD cdb = { 0 };
CDFLAG::_READ_CD::_EXPECTED_SECTOR_TYPE type = CDFLAG::_READ_CD::CDDA;
if (pExtArg->byBe) {
type = CDFLAG::_READ_CD::All;
}
CDFLAG::_READ_CD::_SUB_CHANNEL_SELECTION sub = CDFLAG::_READ_CD::Raw;
_tcsncpy(szSubCode, _T("Raw"), sizeof(szSubCode) / sizeof(szSubCode[0]));
if (pExtArg->byPack) {
sub = CDFLAG::_READ_CD::Pack;
_tcsncpy(szSubCode, _T("Pack"), sizeof(szSubCode) / sizeof(szSubCode[0]));
}
SetReadCDCommand(pExtArg, pDevice, &cdb, type, 1, c2, sub, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
OutputLog(standardOut | fileDisc,
_T("Set OpCode: %#02x, SubCode: %x(%s)\n"), lpCmd[0], lpCmd[10], szSubCode);
BYTE lpPrevSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
// to get prevSubQ
if (pDisc->SUB.nSubchOffset) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, -2, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present);
if (!ExecReadCD(pExtArg, pDevice, lpCmd, -1, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.present, pDiscPerSector->subcode.present);
memcpy(lpPrevSubcode, pDiscPerSector->subcode.present, CD_RAW_READ_SUBCODE_SIZE);
}
else {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, -1, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present);
}
// special fix begin
if (pDiscPerSector->subQ.prev.byAdr != ADR_ENCODES_CURRENT_POSITION) {
// [PCE] 1552 Tenka Tairan
pDiscPerSector->subQ.prev.byAdr = ADR_ENCODES_CURRENT_POSITION;
pDiscPerSector->subQ.prev.byTrackNum = 1;
pDiscPerSector->subQ.prev.nAbsoluteTime = 149;
}
if (!ReadCDForCheckingSecuROM(pExtArg, pDevice, pDisc, pDiscPerSector, lpCmd)) {
throw FALSE;
}
// special fix end
for (UINT p = 0; p < pDisc->SCSI.toc.LastTrack; p++) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, pDisc->SCSI.lpFirstLBAListOnToc[p]
, pDiscPerSector->data.present, pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
pDisc->SUB.lpEndCtlList[p] = (BYTE)((pDiscPerSector->subcode.present[12] >> 4) & 0x0f);
OutputString(_T("\rChecking SubQ ctl (Track) %2u/%2u"), p + 1, pDisc->SCSI.toc.LastTrack);
}
OutputString(_T("\n"));
SetCDOffset(pExecType, pExtArg->byBe, pDevice->byPlxtrDrive, pDisc, 0, pDisc->SCSI.nAllLength);
BYTE byCurrentTrackNum = pDisc->SCSI.toc.FirstTrack;
INT nFirstLBAForSub = 0;
INT nFirstLBA = pDisc->MAIN.nOffsetStart;
INT nLastLBA = 0;
/*
if (pExtArg->byBe) {
nLastLBA = pDisc->SCSI.nAllLength;
}
else {
*/
nLastLBA = pDisc->SCSI.nAllLength + pDisc->MAIN.nOffsetEnd;
/*
}
*/
INT nLBA = nFirstLBA; // This value switches by /r option.
if (pExtArg->byReverse) {
SetCDOffset(pExecType, pExtArg->byBe, pDevice->byPlxtrDrive, pDisc, nLastLBA, pDisc->SCSI.nFirstLBAofDataTrack);
byCurrentTrackNum = pDisc->SCSI.byLastDataTrackNum;
nFirstLBA = pDisc->SCSI.nFirstLBAofDataTrack;
nLastLBA = pDisc->SCSI.nLastLBAofDataTrack + 1;
nLBA = nLastLBA;
if (pDisc->MAIN.nCombinedOffset > 0) {
pDiscPerSector->subQ.prev.nAbsoluteTime = 149 + nLastLBA;
}
else if (pDisc->MAIN.nCombinedOffset < 0) {
pDiscPerSector->subQ.prev.nAbsoluteTime = 150 + nLastLBA + pDisc->MAIN.nAdjustSectorNum;
}
else {
pDiscPerSector->subQ.prev.nAbsoluteTime = 149 + nLastLBA;
}
pDiscPerSector->subQ.prev.byCtl = pDisc->SUB.lpEndCtlList[pDisc->SCSI.byLastDataTrackNum - 1];
pDiscPerSector->subQ.prev.byAdr = ADR_ENCODES_CURRENT_POSITION;
pDiscPerSector->subQ.prev.byTrackNum = pDisc->SCSI.byLastDataTrackNum;
pDiscPerSector->subQ.prev.byIndex = pDisc->MAIN.nOffsetStart < 0 ? (BYTE)0 : (BYTE)1;
}
else if (pDisc->SUB.byIndex0InTrack1) {
nFirstLBAForSub = PREGAP_START_LBA;
nFirstLBA = PREGAP_START_LBA;
nLBA = nFirstLBA;
pDisc->MAIN.nOffsetStart = PREGAP_START_LBA;
}
// init end
FlushLog();
UINT uiC2ErrorLBACnt = 0;
BOOL bReadOK = pDisc->SUB.byIndex0InTrack1 ? FALSE : TRUE;
while (nFirstLBA < nLastLBA) {
BOOL bProcessRet = ProcessReadCD(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, pC2ErrorPerSector, uiC2ErrorLBACnt, lpCmd, nLBA);
//#define C2TEST
#if defined C2TEST
if (nLBA == 100 || nLBA == 200 || nLBA == 300) {
memset(pDiscPerSector->data.present, 0xff, 2352);
bProcessRet = RETURNED_EXIST_C2_ERROR;
}
#endif
if (pC2ErrorPerSector && bProcessRet == RETURNED_EXIST_C2_ERROR) {
OutputErrorString(
_T("\rLBA[%06d, %#07x] Detected C2 error \n"), nLBA, nLBA);
SetC2ErrorData(pC2ErrorPerSector, nLBA, &uiC2ErrorLBACnt, TRUE);
if (uiC2ErrorLBACnt == pExtArg->dwMaxC2ErrorNum) {
OutputErrorString(_T("C2 error Max: %u\n"), uiC2ErrorLBACnt);
throw FALSE;
}
#ifdef _DEBUG
OutputCDMain(fileMainError,
pDiscPerSector->data.present, nLBA, CD_RAW_SECTOR_SIZE);
#endif
}
else if (bProcessRet == RETURNED_SKIP_LBA) {
if (pExtArg->byReverse) {
nLBA = pDisc->SCSI.nFirstLBAof2ndSession - SESSION_TO_SESSION_SKIP_LBA;
}
else {
nLBA = pDisc->MAIN.nFixFirstLBAof2ndSession - 1;
nFirstLBA = nLBA;
}
}
else if (bProcessRet == RETURNED_CONTINUE) {
ProcessReturnedContinue(pExecType, pExtArg, pDevice, pDisc, pDiscPerSector
, nLBA, nMainDataType, byCurrentTrackNum, fpImg, fpSub, fpC2, fpParse);
}
else if (bProcessRet == RETURNED_FALSE) {
throw FALSE;
}
if (bProcessRet != RETURNED_CONTINUE &&
bProcessRet != RETURNED_SKIP_LBA) {
if (pDisc->SUB.nSubchOffset) {
if (!(pExtArg->byReadContinue && pDisc->PROTECT.byExist &&
(pDisc->PROTECT.ERROR_SECTOR.nExtentPos <= nLBA &&
nLBA <= pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize))) {
if (2 <= pExtArg->dwSubAddionalNum) {
memcpy(pDiscPerSector->subcode.nextNext
, pDiscPerSector->subcode.next, CD_RAW_READ_SUBCODE_SIZE);
}
if (1 <= pExtArg->dwSubAddionalNum) {
memcpy(pDiscPerSector->subcode.next
, pDiscPerSector->subcode.present, CD_RAW_READ_SUBCODE_SIZE);
}
memcpy(pDiscPerSector->subcode.present, lpPrevSubcode, CD_RAW_READ_SUBCODE_SIZE);
}
}
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.present, pDiscPerSector->subcode.present);
if (pDisc->SUB.byIndex0InTrack1 && PREGAP_START_LBA <= nLBA && nLBA <= -76) {
if (pDiscPerSector->subQ.present.byTrackNum == 1 &&
pDiscPerSector->subQ.present.nAbsoluteTime == 0) {
pDiscPerSector->subQ.prev.nRelativeTime = pDiscPerSector->subQ.present.nRelativeTime + 1;
pDiscPerSector->subQ.prev.nAbsoluteTime = -1;
pDisc->MAIN.nFixStartLBA = nLBA;
bReadOK = TRUE;
if (pDisc->MAIN.nAdjustSectorNum < 0 ||
1 < pDisc->MAIN.nAdjustSectorNum) {
for (INT i = 0; i < abs(pDisc->MAIN.nAdjustSectorNum) * CD_RAW_SECTOR_SIZE; i++) {
fputc(0, fpImg);
}
}
}
if (bReadOK) {
if (pDiscPerSector->subQ.present.byTrackNum == 1 &&
pDiscPerSector->subQ.present.nAbsoluteTime == 74) {
nFirstLBA = -76;
}
}
}
if (bReadOK) {
if (nFirstLBAForSub <= nLBA && nLBA < pDisc->SCSI.nAllLength) {
if (ExecCheckingSubchannnel(pExtArg, pDisc, nLBA)) {
BOOL bLibCrypt = IsValidLibCryptSector(pExtArg->byLibCrypt, nLBA);
BOOL bSecuRom = IsValidIntentionalSubSector(pExtArg->byIntentionalSub, pDisc, nLBA);
if (!pExtArg->byReverse) {
CheckAndFixSubChannel(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, byCurrentTrackNum, nLBA, bLibCrypt, bSecuRom);
BYTE lpSubcodeRaw[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
// fix raw subchannel
AlignColumnSubcode(pDiscPerSector->subcode.present, lpSubcodeRaw);
#if 0
OutputCDSub96Align(pDiscPerSector->subcode.present, nLBA);
#endif
#if 0
OutputCDSub96Raw(standardOut, lpSubcodeRaw, nLBA);
#endif
WriteSubChannel(pDisc, lpSubcodeRaw,
pDiscPerSector->subcode.present, nLBA, byCurrentTrackNum, fpSub, fpParse);
}
CheckAndFixMainHeader(pExtArg, pDisc
, pDiscPerSector, nLBA, byCurrentTrackNum, nMainDataType);
SetTrackAttribution(pExtArg, pDisc, nLBA,
&byCurrentTrackNum, &pDiscPerSector->mainHeader, &pDiscPerSector->subQ);
UpdateTmpSubQData(&pDiscPerSector->subQ, bLibCrypt, bSecuRom);
}
}
// Write track to scrambled
WriteMainChannel(pExtArg, pDisc, pDiscPerSector->data.present, nLBA, fpImg);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
WriteC2(pExtArg, pDisc, pDiscPerSector->data.present + pDevice->TRANSFER.dwBufC2Offset, nLBA, fpC2);
}
}
// for DEBUG begin
else {
BYTE lpSubcodeRaw[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
AlignColumnSubcode(pDiscPerSector->subcode.present, lpSubcodeRaw);
OutputCDSubToLog(pDisc, pDiscPerSector->subcode.present, lpSubcodeRaw, nLBA, byCurrentTrackNum, fpParse);
}
// for DEBUG end
if (pDisc->SUB.nSubchOffset) {
memcpy(lpPrevSubcode, pDiscPerSector->subcode.next, CD_RAW_READ_SUBCODE_SIZE);
}
}
if (pExtArg->byReverse) {
OutputString(_T("\rCreated img (LBA) %6d/%6d"), nLBA, pDisc->SCSI.nFirstLBAofDataTrack);
nLBA--;
}
else {
OutputString(_T("\rCreated img (LBA) %6d/%6d"), nLBA, pDisc->SCSI.nAllLength - 1);
if (nFirstLBA == -76) {
nLBA = nFirstLBA;
if (!bReadOK) {
bReadOK = TRUE;
}
}
nLBA++;
}
nFirstLBA++;
}
OutputString(_T("\n"));
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
FcloseAndNull(fpC2);
}
FcloseAndNull(fpParse);
FcloseAndNull(fpSub);
FlushLog();
if (!pExtArg->byReverse) {
if (pDisc->SCSI.toc.FirstTrack == pDisc->SCSI.toc.LastTrack) {
// [3DO] Jurassic Park Interactive (Japan)
if (pDisc->SUB.lpFirstLBAListOnSub[0][2] == -1) {
pDisc->SUB.lpFirstLBAListOnSub[0][1] = pDisc->SCSI.lpLastLBAListOnToc[0];
}
}
for (INT i = 0; i < pDisc->SCSI.toc.LastTrack; i++) {
if (pDisc->PROTECT.byExist == cds300 && i == pDisc->SCSI.toc.LastTrack - 1) {
break;
}
BOOL bErr = FALSE;
LONG lLine = 0;
if (pDisc->SUB.lpFirstLBAListOnSub[i][1] == -1) {
bErr = TRUE;
lLine = __LINE__;
}
else if ((pDisc->SCSI.toc.TrackData[i].Control & AUDIO_DATA_TRACK) == AUDIO_DATA_TRACK) {
if (pDisc->SUB.lpFirstLBAListOfDataTrackOnSub[i] == -1) {
bErr = TRUE;
lLine = __LINE__;
}
else if (pDisc->SUB.lpLastLBAListOfDataTrackOnSub[i] == -1) {
bErr = TRUE;
lLine = __LINE__;
}
}
if (bErr) {
OutputErrorString(
_T("[L:%ld] Internal error. Failed to analyze the subchannel. Track[%02u]/[%02u]\n"),
lLine, i + 1, pDisc->SCSI.toc.LastTrack);
throw FALSE;
}
}
}
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
if (!ReadCDForRereadingSector(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, pC2ErrorPerSector, uiC2ErrorLBACnt, lpCmd, fpImg)) {
throw FALSE;
}
}
FcloseAndNull(fpImg);
if (!pExtArg->byReverse) {
OutputTocWithPregap(pDisc);
}
else {
FILE* fpImg_r = NULL;
if (NULL == (fpImg_r = CreateOrOpenFile(
pszPath, _T("_reverse"), NULL, NULL, NULL, _T(".scm"), _T("rb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpImg = CreateOrOpenFile(
pszPath, NULL, pszOutScmFile, NULL, NULL, _T(".scm"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
OutputString(_T("Reversing _reverse.scm to .scm\n"));
BYTE rBuf[CD_RAW_SECTOR_SIZE] = { 0 };
DWORD dwRoop = GetFileSize(0, fpImg_r) - CD_RAW_SECTOR_SIZE * 2;
LONG lSeek = CD_RAW_SECTOR_SIZE - (LONG)pDisc->MAIN.uiMainDataSlideSize;
fseek(fpImg_r, -lSeek, SEEK_END);
fread(rBuf, sizeof(BYTE), (size_t)lSeek, fpImg_r);
fwrite(rBuf, sizeof(BYTE), (size_t)lSeek, fpImg);
fseek(fpImg_r, -lSeek, SEEK_CUR);
for (DWORD i = 0; i < dwRoop; i += CD_RAW_SECTOR_SIZE) {
fseek(fpImg_r, -CD_RAW_SECTOR_SIZE, SEEK_CUR);
fread(rBuf, sizeof(BYTE), CD_RAW_SECTOR_SIZE, fpImg_r);
fwrite(rBuf, sizeof(BYTE), CD_RAW_SECTOR_SIZE, fpImg);
fseek(fpImg_r, -CD_RAW_SECTOR_SIZE, SEEK_CUR);
}
rewind(fpImg_r);
fread(rBuf, sizeof(BYTE), pDisc->MAIN.uiMainDataSlideSize, fpImg_r);
fwrite(rBuf, sizeof(BYTE), pDisc->MAIN.uiMainDataSlideSize, fpImg);
FcloseAndNull(fpImg);
FcloseAndNull(fpImg_r);
}
_TCHAR pszNewPath[_MAX_PATH] = { 0 };
_tcsncpy(pszNewPath, pszOutScmFile, sizeof(pszNewPath) / sizeof(pszNewPath[0]));
pszNewPath[_MAX_PATH - 1] = 0;
// "PathRenameExtension" fails to rename if space is included in extension.
// e.g.
// no label. 2017-02-14_ 9-41-31 => no label. 2017-02-14_ 9-41-31.img
// no label.2017-02-14_9-41-31 => no label.img
if (!PathRenameExtension(pszNewPath, _T(".img"))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
// audio only -> from .scm to .img. other descramble img.
if (pExtArg->byBe || pDisc->SCSI.byAudioOnly) {
OutputString(_T("Moving .scm to .img\n"));
if (!MoveFileEx(pszOutScmFile, pszNewPath, MOVEFILE_REPLACE_EXISTING)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (pExtArg->byBe) {
ExecEccEdc(pExtArg->byReadContinue, pszNewPath, pDisc->PROTECT.ERROR_SECTOR);
}
}
else {
OutputString(_T("Copying .scm to .img\n"));
if (!CopyFile(pszOutScmFile, pszNewPath, FALSE)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
_TCHAR pszImgPath[_MAX_PATH] = { 0 };
if (NULL == (fpImg = CreateOrOpenFile(
pszPath, NULL, pszImgPath, NULL, NULL, _T(".img"), _T("rb+"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
DescrambleMainChannelAll(pExtArg, pDisc, scrambled_table, fpImg);
FcloseAndNull(fpImg);
ExecEccEdc(pExtArg->byReadContinue, pszImgPath, pDisc->PROTECT.ERROR_SECTOR);
}
if (pExtArg->byReverse) {
_TCHAR pszNewPath2[_MAX_PATH] = { 0 };
FILE* fpBin = CreateOrOpenFile(pszPath, NULL, pszNewPath2, NULL, NULL, _T(".bin"),
_T("wb"), pDisc->SCSI.byFirstDataTrackNum, pDisc->SCSI.byFirstDataTrackNum);
if (!fpBin) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
OutputString(_T("Copying .img to %s\n"), pszNewPath2);
if (!CopyFile(pszNewPath, pszNewPath2, FALSE)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
FcloseAndNull(fpBin);
}
else {
_TCHAR pszImgName[_MAX_FNAME] = { 0 };
if (NULL == (fpImg = CreateOrOpenFile(
pszPath, NULL, NULL, pszImgName, NULL, _T(".img"), _T("rb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (!CreateBinCueCcd(pExtArg, pDisc, pszPath, pszImgName,
pDevice->FEATURE.byCanCDText, fpImg, fpCue, fpCueForImg, fpCcd)) {
throw FALSE;
}
}
}
catch (BOOL ret) {
bRet = ret;
}
FcloseAndNull(fpImg);
FcloseAndNull(fpCueForImg);
FcloseAndNull(fpCue);
FcloseAndNull(fpParse);
FcloseAndNull(fpSub);
FreeAndNull(pBuf);
if (1 <= pExtArg->dwSubAddionalNum) {
FreeAndNull(pNextBuf);
if (2 <= pExtArg->dwSubAddionalNum) {
FreeAndNull(pNextNextBuf);
}
}
return bRet;
}
BOOL ReadCDPartial(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
PC2_ERROR_PER_SECTOR pC2ErrorPerSector,
CDFLAG::_READ_CD::_ERROR_FLAGS c2,
LPCTSTR pszPath,
INT nStart,
INT nEnd,
CDFLAG::_READ_CD::_EXPECTED_SECTOR_TYPE flg,
FILE* fpC2
)
{
CONST INT size = 8;
_TCHAR szPlusFnameSub[size] = { 0 };
_TCHAR szPlusFnameTxt[size] = { 0 };
_TCHAR szExt[size] = { 0 };
if (*pExecType == gd) {
_tcsncpy(szPlusFnameSub, _T("_gd"), size);
_tcsncpy(szPlusFnameTxt, _T("_sub_gd"), size);
_tcsncpy(szExt, _T(".scm2"), size);
}
else {
_tcsncpy(szPlusFnameTxt, _T("_sub"), size);
_tcsncpy(szExt, _T(".bin"), size);
}
_TCHAR pszBinPath[_MAX_PATH] = { 0 };
FILE* fpBin =
CreateOrOpenFile(pszPath, NULL, pszBinPath, NULL, NULL, szExt, _T("wb"), 0, 0);
if (!fpBin) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
BOOL bRet = TRUE;
FILE* fpParse = NULL;
FILE* fpSub = NULL;
LPBYTE pBuf = NULL;
LPBYTE pNextBuf = NULL;
LPBYTE pNextNextBuf = NULL;
INT nMainDataType = scrambled;
if (*pExecType == data || pExtArg->byBe) {
nMainDataType = unscrambled;
}
try {
// init start
if (NULL == (fpParse = CreateOrOpenFile(
pszPath, szPlusFnameTxt, NULL, NULL, NULL, _T(".txt"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpSub = CreateOrOpenFile(
pszPath, szPlusFnameSub, NULL, NULL, NULL, _T(".sub"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
// store main+(c2)+sub data
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.present, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (1 <= pExtArg->dwSubAddionalNum) {
if (!GetAlignedCallocatedBuffer(pDevice, &pNextBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.next, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
if (2 <= pExtArg->dwSubAddionalNum) {
if (!GetAlignedCallocatedBuffer(pDevice, &pNextNextBuf,
pDevice->TRANSFER.dwAllBufLen, &pDiscPerSector->data.nextNext, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
}
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = { 0 };
_TCHAR szSubCode[5] = { 0 };
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = { 0 };
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
_tcsncpy(szSubCode, _T("Raw"), sizeof(szSubCode) / sizeof(szSubCode[0]));
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainC2Raw);
}
else {
_tcsncpy(szSubCode, _T("Pack"), sizeof(szSubCode) / sizeof(szSubCode[0]));
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::MainPack);
}
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
else {
// non plextor && support scrambled ripping
CDB::_READ_CD cdb = { 0 };
_tcsncpy(szSubCode, _T("Raw"), sizeof(szSubCode) / sizeof(szSubCode[0]));
SetReadCDCommand(pExtArg, pDevice, &cdb, flg, 1, c2, CDFLAG::_READ_CD::Raw, FALSE);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
}
OutputLog(standardOut | fileDisc,
_T("Set OpCode: %#02x, SubCode: %x(%s)\n"), lpCmd[0], lpCmd[10], szSubCode);
BYTE lpPrevSubcode[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
if (pDisc->SUB.nSubchOffset) { // confirmed PXS88T, TS-H353A
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nStart - 2, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
if (nStart == 0) {
pDiscPerSector->subQ.present.nRelativeTime = 0;
pDiscPerSector->subQ.present.nAbsoluteTime = 149;
SetBufferFromTmpSubQData(pDiscPerSector->subQ.present, pDiscPerSector->subcode.present, 1);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present);
}
else {
throw FALSE;
}
}
else {
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present);
}
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nStart - 1, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
if (nStart == 0) {
pDiscPerSector->subQ.present.nRelativeTime = 0;
pDiscPerSector->subQ.present.nAbsoluteTime = 150;
SetBufferFromTmpSubQData(pDiscPerSector->subQ.present, pDiscPerSector->subcode.present, 1);
for (INT i = 0; i < 12; i++) {
pDiscPerSector->subcode.present[i] = 0xff;
}
}
else {
throw FALSE;
}
}
else {
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.present, pDiscPerSector->subcode.present);
}
memcpy(lpPrevSubcode, pDiscPerSector->subcode.present, CD_RAW_READ_SUBCODE_SIZE);
}
else {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nStart - 1, pDiscPerSector->data.present,
pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
}
else {
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.prev, pDiscPerSector->subcode.present);
}
}
if (*pExecType == gd) {
for (INT p = pDisc->GDROM_TOC.FirstTrack - 1; p < pDisc->GDROM_TOC.LastTrack; p++) {
pDisc->SUB.lpEndCtlList[p] = pDisc->GDROM_TOC.TrackData[p].Control;
}
}
else {
for (UINT p = 0; p < pDisc->SCSI.toc.LastTrack; p++) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, pDisc->SCSI.lpFirstLBAListOnToc[p]
, pDiscPerSector->data.present, pDevice->TRANSFER.dwAllBufLen, _T(__FUNCTION__), __LINE__)) {
throw FALSE;
}
AlignRowSubcode(pDiscPerSector->data.present + pDevice->TRANSFER.dwBufSubOffset, pDiscPerSector->subcode.present);
pDisc->SUB.lpEndCtlList[p] = (BYTE)((pDiscPerSector->subcode.present[12] >> 4) & 0x0f);
OutputString(_T("\rChecking SubQ ctl (Track) %2u/%2u"), p + 1, pDisc->SCSI.toc.LastTrack);
}
OutputString(_T("\n"));
}
SetCDOffset(pExecType, pExtArg->byBe, pDevice->byPlxtrDrive, pDisc, nStart, nEnd);
#ifdef _DEBUG
OutputString(_T("byBe: %d, nCombinedOffset: %d, uiMainDataSlideSize: %u, nOffsetStart: %u, nOffsetEnd: %u, nFixStartLBA: %u, nFixEndLBA: %u\n")
, pExtArg->byBe, pDisc->MAIN.nCombinedOffset, pDisc->MAIN.uiMainDataSlideSize
, pDisc->MAIN.nOffsetStart, pDisc->MAIN.nOffsetEnd, pDisc->MAIN.nFixStartLBA, pDisc->MAIN.nFixEndLBA);
#endif
BYTE byCurrentTrackNum = pDiscPerSector->subQ.prev.byTrackNum;
if (*pExecType == gd) {
byCurrentTrackNum = pDisc->GDROM_TOC.FirstTrack;
}
else if (byCurrentTrackNum < pDisc->SCSI.toc.FirstTrack || pDisc->SCSI.toc.LastTrack < byCurrentTrackNum) {
byCurrentTrackNum = pDisc->SCSI.toc.FirstTrack;
}
#ifdef _DEBUG
OutputString(_T("byBe: %d, nCombinedOffset: %d, uiMainDataSlideSize: %u, nOffsetStart: %u, nOffsetEnd: %u, nFixStartLBA: %u, nFixEndLBA: %u\n")
, pExtArg->byBe, pDisc->MAIN.nCombinedOffset, pDisc->MAIN.uiMainDataSlideSize
, pDisc->MAIN.nOffsetStart, pDisc->MAIN.nOffsetEnd, pDisc->MAIN.nFixStartLBA, pDisc->MAIN.nFixEndLBA);
#endif
INT nLastLBA = nEnd + pDisc->MAIN.nOffsetEnd;
INT nLBA = nStart + pDisc->MAIN.nOffsetStart;
// init end
FlushLog();
UINT uiC2ErrorLBACnt = 0;
INT nStoreLBA = 0;
INT nRetryCnt = 1;
while (nLBA < nLastLBA) {
BOOL bProcessRet = ProcessReadCD(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, pC2ErrorPerSector, uiC2ErrorLBACnt, lpCmd, nLBA);
if (pC2ErrorPerSector && bProcessRet == RETURNED_EXIST_C2_ERROR) {
OutputErrorString(
_T("\rLBA[%06d, %#07x] Detected C2 error \n"), nLBA, nLBA);
SetC2ErrorData(pC2ErrorPerSector, nLBA, &uiC2ErrorLBACnt, TRUE);
if (uiC2ErrorLBACnt == pExtArg->dwMaxC2ErrorNum) {
OutputErrorString(_T("C2 error Max: %u\n"), uiC2ErrorLBACnt);
throw FALSE;
}
}
else if (bProcessRet == RETURNED_SKIP_LBA) {
nLBA = pDisc->MAIN.nFixFirstLBAof2ndSession - 1;
}
else if (bProcessRet == RETURNED_CONTINUE) {
ProcessReturnedContinue(pExecType, pExtArg, pDevice, pDisc, pDiscPerSector
, nLBA, nMainDataType, byCurrentTrackNum, fpBin, fpSub, fpC2, fpParse);
}
else if (bProcessRet == RETURNED_FALSE) {
if (*pExecType == gd && nRetryCnt <= 10) {
OutputLog(standardError | fileMainError, _T("Retry %d/10\n"), nRetryCnt);
INT nTmpLBA = 0;
for (nTmpLBA = nLBA - 20000; 449849 <= nTmpLBA; nTmpLBA -= 20000) {
OutputString(_T("Reread %d sector\n"), nTmpLBA);
if (RETURNED_FALSE == ExecReadCDForC2(pExecType, pExtArg, pDevice, lpCmd, nTmpLBA,
pDiscPerSector->data.present, _T(__FUNCTION__), __LINE__)) {
if (nTmpLBA < 20000) {
break;
}
}
else {
break;
}
}
if (nStoreLBA == 0 && nRetryCnt == 1) {
nStoreLBA = nLBA;
}
nLBA = nTmpLBA;
nRetryCnt++;
continue;
}
else {
throw FALSE;
}
}
if (nRetryCnt > 1) {
if (nStoreLBA == nLBA) {
// init
nStoreLBA = 0;
nRetryCnt = 1;
OutputString(_T("\n"));
}
else {
OutputString(_T("\rReread %d sector"), nLBA);
nLBA++;
continue;
}
}
if (bProcessRet != RETURNED_CONTINUE &&
bProcessRet != RETURNED_SKIP_LBA) {
if (pDisc->SUB.nSubchOffset) {
if (!(pExtArg->byReadContinue && pDisc->PROTECT.byExist &&
(pDisc->PROTECT.ERROR_SECTOR.nExtentPos <= nLBA &&
nLBA <= pDisc->PROTECT.ERROR_SECTOR.nExtentPos + pDisc->PROTECT.ERROR_SECTOR.nSectorSize))) {
if (2 <= pExtArg->dwSubAddionalNum) {
memcpy(pDiscPerSector->subcode.nextNext, pDiscPerSector->subcode.next, CD_RAW_READ_SUBCODE_SIZE);
}
if (1 <= pExtArg->dwSubAddionalNum) {
memcpy(pDiscPerSector->subcode.next, pDiscPerSector->subcode.present, CD_RAW_READ_SUBCODE_SIZE);
}
memcpy(pDiscPerSector->subcode.present, lpPrevSubcode, CD_RAW_READ_SUBCODE_SIZE);
}
}
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.present, pDiscPerSector->subcode.present);
if (nStart <= nLBA && nLBA < nEnd) {
if (ExecCheckingSubchannnel(pExtArg, pDisc, nLBA)) {
CheckAndFixSubChannel(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, byCurrentTrackNum, nLBA, FALSE, FALSE);
BYTE lpSubcodeRaw[CD_RAW_READ_SUBCODE_SIZE] = { 0 };
// fix raw subchannel
AlignColumnSubcode(pDiscPerSector->subcode.present, lpSubcodeRaw);
#if 0
OutputCDSub96Align(pDiscPerSector->subcode.present, nLBA);
#endif
WriteSubChannel(pDisc, lpSubcodeRaw,
pDiscPerSector->subcode.present, nLBA, byCurrentTrackNum, fpSub, fpParse);
CheckAndFixMainHeader(pExtArg, pDisc
, pDiscPerSector, nLBA, byCurrentTrackNum, nMainDataType);
if (*pExecType == gd) {
byCurrentTrackNum = pDiscPerSector->subQ.present.byTrackNum;
}
else {
SetTrackAttribution(pExtArg, pDisc, nLBA,
&byCurrentTrackNum, &pDiscPerSector->mainHeader, &pDiscPerSector->subQ);
}
UpdateTmpSubQData(&pDiscPerSector->subQ, FALSE, FALSE);
}
}
// Write track to scrambled
WriteMainChannel(pExtArg, pDisc, pDiscPerSector->data.present, nLBA, fpBin);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
WriteC2(pExtArg, pDisc, pDiscPerSector->data.present + pDevice->TRANSFER.dwBufC2Offset, nLBA, fpC2);
}
if (pDisc->SUB.nSubchOffset) {
memcpy(lpPrevSubcode, pDiscPerSector->subcode.next, CD_RAW_READ_SUBCODE_SIZE);
}
}
OutputString(_T("\rCreating bin from %d to %d (LBA) %6d"),
nStart + pDisc->MAIN.nOffsetStart, nEnd + pDisc->MAIN.nOffsetEnd, nLBA);
nLBA++;
}
OutputString(_T("\n"));
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
FcloseAndNull(fpC2);
}
FcloseAndNull(fpParse);
FcloseAndNull(fpSub);
FlushLog();
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
if (!ReadCDForRereadingSector(pExecType, pExtArg, pDevice, pDisc
, pDiscPerSector, pC2ErrorPerSector, uiC2ErrorLBACnt, lpCmd, fpBin)) {
throw FALSE;
}
}
FcloseAndNull(fpBin);
if (*pExecType == data) {
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
if (NULL == (fpBin = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".bin"), _T("rb+"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
DescrambleMainChannelPartial(nStart, nEnd - 1, scrambled_table, fpBin);
FcloseAndNull(fpBin);
}
ExecEccEdc(pExtArg->byReadContinue, pszBinPath, pDisc->PROTECT.ERROR_SECTOR);
}
else if (*pExecType == gd) {
_TCHAR pszImgPath[_MAX_PATH] = { 0 };
if (!DescrambleMainChannelForGD(pszPath, pszImgPath)) {
throw FALSE;
}
ExecEccEdc(pExtArg->byReadContinue, pszImgPath, pDisc->PROTECT.ERROR_SECTOR);
if (!SplitFileForGD(pszPath)) {
throw FALSE;
}
}
}
catch (BOOL ret) {
bRet = ret;
}
FcloseAndNull(fpBin);
FcloseAndNull(fpParse);
FcloseAndNull(fpSub);
FreeAndNull(pBuf);
if (1 <= pExtArg->dwSubAddionalNum) {
FreeAndNull(pNextBuf);
if (2 <= pExtArg->dwSubAddionalNum) {
FreeAndNull(pNextNextBuf);
}
}
return bRet;
}
BOOL ReadCDForGDTOC(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
)
{
CDB::_READ_CD cdb = { 0 };
SetReadCDCommand(NULL, pDevice, &cdb,
CDFLAG::_READ_CD::CDDA, 1, CDFLAG::_READ_CD::NoC2, CDFLAG::_READ_CD::NoSub, TRUE);
BYTE aToc[CD_RAW_SECTOR_SIZE * 2] = { 0 };
INT nOffset = pDisc->MAIN.nAdjustSectorNum - 1;
if (pDisc->MAIN.nCombinedOffset < 0) {
nOffset = pDisc->MAIN.nAdjustSectorNum;
}
for(INT n = 1; n <= 10; n++) {
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, FIRST_LBA_FOR_GD + nOffset, aToc,
CD_RAW_SECTOR_SIZE, _T(__FUNCTION__), __LINE__)) {
if (n == 10) {
return FALSE;
}
StartStopUnit(pExtArg, pDevice, STOP_UNIT_CODE, STOP_UNIT_CODE);
DWORD milliseconds = 30000;
OutputErrorString(_T("Retry %d/10 after %ld milliseconds\n"), n, milliseconds);
Sleep(milliseconds);
continue;
}
else {
break;
}
}
BYTE bufDec[CD_RAW_SECTOR_SIZE] = { 0 };
INT idx = pDisc->MAIN.nCombinedOffset;
if (pDisc->MAIN.nCombinedOffset < 0) {
idx = CD_RAW_SECTOR_SIZE + pDisc->MAIN.nCombinedOffset;
}
for (INT j = 0; j < CD_RAW_SECTOR_SIZE; j++) {
bufDec[j] = (BYTE)(aToc[idx + j] ^ scrambled_table[j]);
}
// http://hwdocs.webs.com/dreamcast
/*
0x110 - 0x113: TOC1
0x114 - 0x116: LBA(little) |
0x117 : Ctl/Adr |
: |-> 100 track
: |
0x294 - 0x296: LBA(little) |
0x297 : Ctl/Adr |
0x298 - 0x299: Zero
0x29a : First track |-> alway "3"
0x29b : Ctl/Adr |-> alway "41"
0x29c - 0x29d: Zero
0x29e : Last track
0x29f : Ctl/Adr
0x2a0 - 0x2a2: Max LBA |-> alway "b4 61 08" (549300)
0x2a3 : Ctl/Adr |-> alway "41"
*/
OutputCDMain(fileMainInfo, bufDec, FIRST_LBA_FOR_GD + nOffset, CD_RAW_SECTOR_SIZE);
if (bufDec[0x110] != 'T' || bufDec[0x111] != 'O' ||
bufDec[0x112] != 'C' || bufDec[0x113] != '1') {
OutputErrorString(_T("No GD-ROM data\n"));
return FALSE;
}
pDisc->GDROM_TOC.FirstTrack = bufDec[0x29a];
pDisc->GDROM_TOC.LastTrack = bufDec[0x29e];
pDisc->GDROM_TOC.Length = MAKELONG(
MAKEWORD(bufDec[0x2a0], bufDec[0x2a1]), MAKEWORD(bufDec[0x2a2], 0));
for (INT i = pDisc->GDROM_TOC.FirstTrack - 1, j = 0; i < pDisc->GDROM_TOC.LastTrack; i++, j += 4) {
pDisc->GDROM_TOC.TrackData[i].Address = MAKELONG(
MAKEWORD(bufDec[0x114 + j], bufDec[0x115 + j]), MAKEWORD(bufDec[0x116 + j], 0));
pDisc->GDROM_TOC.TrackData[i].Control = BYTE((bufDec[0x117 + j]) >> 4 & 0x0f);
pDisc->GDROM_TOC.TrackData[i].Adr = BYTE((bufDec[0x117 + j]) & 0x0f);
pDisc->GDROM_TOC.TrackData[i].TrackNumber = (BYTE)(i + 1);
}
OutputTocForGD(pDisc);
return TRUE;
}
|
6312e1c492d7aa09173445ebc4394bdcc77af093
|
4b538d7e26f795220312190d4f134c166bd769d6
|
/Smoother.h
|
71256de099e3ae8360be35db14cd46c93c59f453
|
[] |
no_license
|
neohung/neosoccer
|
bb659d595107adf1d5e103b5f75ff015a0b406e3
|
a2b1665f9ce2a7400802c76652236d0f4bb93bca
|
refs/heads/master
| 2021-01-25T10:05:49.647329
| 2015-07-17T09:54:51
| 2015-07-17T09:54:51
| 39,179,202
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,340
|
h
|
Smoother.h
|
#ifndef SMOOTHER_H
#define SMOOTHER_H
//-----------------------------------------------------------------------
//Smoother宣告一個vector: m_History存放最大數量SampleSize,定義0向量為ZeroValue
//Smoother->Update()會傳回該vector所有物件的平均向量
template <class T>
class Smoother
{
private:
//this holds the history
std::vector<T> m_History;
T m_ZeroValue;
int m_iNextUpdateSlot;
//an example of the 'zero' value of the type to be smoothed. This
//would be something like Vector2D(0,0)
public:
Smoother(int SampleSize, T ZeroValue):
m_History(SampleSize, ZeroValue),
m_ZeroValue(ZeroValue),
m_iNextUpdateSlot(0)
{}
T Update(const T& MostRecentValue)
{
//overwrite the oldest value with the newest
m_History[m_iNextUpdateSlot++] = MostRecentValue;
//make sure m_iNextUpdateSlot wraps around.
if (m_iNextUpdateSlot == m_History.size()) m_iNextUpdateSlot = 0;
//now to calculate the average of the history list
T sum = m_ZeroValue;
typename std::vector<T>::iterator it;
for (it=m_History.begin(); it != m_History.end(); ++it)
{
sum += *it;
}
return sum / (double)m_History.size();
}
};
#endif
|
fb8cc6d03c5eb9644f9801b9060f0828ee4a1578
|
b22588340d7925b614a735bbbde1b351ad657ffc
|
/athena/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx
|
22ba1e11215e0399f0f694e18b5f70546d363fd5
|
[] |
no_license
|
rushioda/PIXELVALID_athena
|
90befe12042c1249cbb3655dde1428bb9b9a42ce
|
22df23187ef85e9c3120122c8375ea0e7d8ea440
|
refs/heads/master
| 2020-12-14T22:01:15.365949
| 2020-01-19T03:59:35
| 2020-01-19T03:59:35
| 234,836,993
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 36,465
|
cxx
|
MdtDqaTubeEfficiency.cxx
|
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 13.08.2008, AUTHOR: MAURO IODICE class rearranged from Efficiency by Steffen Kaiser
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS MdtDqaTubeEfficiency ::
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//::::::::::::::::::
//:: HEADER FILES ::
//::::::::::::::::::
// standard C++ //
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
// Athena //
// #include "GaudiKernel/MsgStream.h"
// #include "StoreGate/StoreGateSvc.h"
#include "Identifier/IdentifierHash.h"
#include "MuonIdHelpers/MdtIdHelper.h"
// MuonReadoutGeometry //
#include "MuonReadoutGeometry/MuonDetectorManager.h"
#include "MuonReadoutGeometry/MdtReadoutElement.h"
#include "MuonCalibITools/IIdToFixedIdTool.h"
#include "MdtCalibInterfaces/IMdtSegmentFitter.h"
#include "MdtCalibUtils/GlobalTimeFitter.h"
#include "MuonCalibStandAloneExtraTools/HistogramManager.h"
#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h"
// MuonCalib //
#include "MuonCalibEventBase/MuonCalibRawHitCollection.h"
#include "MuonCalibEventBase/MuonCalibRawMdtHit.h"
#include "MuonCalibEventBase/MuonCalibSegment.h"
#include "MdtCalibFitters/QuasianalyticLineReconstruction.h"
#include "MdtCalibFitters/DCSLFitter.h"
#include "MuonCalibEventBase/MuonCalibEvent.h"
// MdtDqaTubeEfficiency //
#include "MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h"
//this
#include "MuonCalibStandAloneBase/NtupleStationId.h"
#include "MuonCalibStandAloneBase/RegionSelectionSvc.h"
#include "MuonCalibStandAloneBase/MdtStationT0Container.h"
#include "MdtCalibData/IRtResolution.h"
//root
#include "TFile.h"
#include "TH1.h"
#include "TNtuple.h"
#include "TString.h"
#include "TDirectory.h"
//::::::::::::::::::::::::
//:: NAMESPACE SETTINGS ::
//::::::::::::::::::::::::
using namespace std;
namespace MuonCalib {
//*****************************************************************************
// constructor
MdtDqaTubeEfficiency::MdtDqaTubeEfficiency(float nsigma, float chi2Cut,
bool defaultResol, float adcCut, bool GTFitON,
bool useNewCalibConstants, bool useTimeCorrections) :
m_mdtIdHelper(NULL), m_detMgr(NULL), m_id_tool(NULL), p_reg_sel_svc(NULL), p_calib_input_svc(NULL),
m_histoManager(NULL),
//m_tfile(NULL), m_tfile_debug(NULL), m_hit_ntuple(NULL),
//m_cal_region(NULL),
m_qfitter(NULL),
//m_nb_trigger(-1),
m_nb_stations(-1)
//m_h_distance(NULL), m_h_nb_hit_tubes(NULL),
//m_h_layer_efficiency(NULL), m_h_layer_fakerate(NULL), m_h_chamber_efficiency(NULL),
//m_h_chamber_fakerate(NULL), m_h_chi2(NULL)
{
m_nsigma = nsigma;
m_chi2Cut = chi2Cut;
m_defaultResol = defaultResol;
m_adcCut = adcCut;
m_GTFitON = GTFitON;
m_useNewCalibConstants = useNewCalibConstants;
m_useTimeCorrections = useTimeCorrections;
}
//:::::::::::::::::
//:: METHOD init ::
//:::::::::::::::::
StatusCode MdtDqaTubeEfficiency::initialize(const MdtIdHelper *mdtIdHelper, const MuonGM::MuonDetectorManager *detMgr,
const MuonCalib::IIdToFixedIdTool *id_tool, RegionSelectionSvc *reg_sel_svc,
MdtCalibInputSvc *calib_input_svc, HistogramManager *histoManager) {
m_mdtIdHelper = mdtIdHelper;
m_detMgr = detMgr;
m_id_tool = id_tool;
p_reg_sel_svc = reg_sel_svc;
p_calib_input_svc = calib_input_svc;
m_histoManager = histoManager;
//ToString ts;
string RegionName = p_reg_sel_svc->GetRegionSelection();
//cout << " MdtDqaTubeEfficiency::initialize - RegionName: "<<RegionName<< endl;
const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions();
//----------------------------------//
//-- Create Root Files and Histos --//
//----------------------------------//
m_qfitter = NULL;
// loop over stations in region
m_nb_stations = stationsInRegion.size();
for (int istation=0;istation<m_nb_stations;istation++) {
for (int k=0;k<4;k++) m_nb_layers_tubes[istation][k] = -1;
}
//cout << " end of first for loop " << endl;
/*
std::vector<MuonCalib::NtupleStationId>::const_iterator itstation;
for (itstation = stationsInRegion.begin();
itstation!=stationsInRegion.end(); itstation++) {
cout << "in the loop. itest = "<<itest++ << endl;
string stationNameString = (itstation)->regionId();
cout << " stationName : "<< stationNameString << endl;
}
*/
for (int istation=0;istation<m_nb_stations;istation++) {
string stationNameString = stationsInRegion.at(istation).regionId();
// cout << " initializing vector m_nb_layers_tubes. istation : "<< istation
// << " stationName: "<< stationNameString << endl;
string chamberType = stationNameString.substr(0,3);
int phi_id = stationsInRegion.at(istation).GetPhi();
int eta_id = stationsInRegion.at(istation).GetEta();
// string fullStationName = chamberType+"_"+ts(phi_id)+"_"+ts(eta_id);
Identifier station_id = m_mdtIdHelper->elementID(chamberType, eta_id, phi_id);
int stationIntId = static_cast<int>(station_id.get_identifier32().get_compact());
int numberOfML = m_mdtIdHelper->numberOfMultilayers(station_id);
for (int multilayer=1;multilayer<=numberOfML; multilayer++) {
Identifier MdtML = m_mdtIdHelper->multilayerID(station_id, multilayer);
int layerMin = m_mdtIdHelper->tubeLayerMin(MdtML);
int layerMax = m_mdtIdHelper->tubeLayerMax(MdtML);
int tubeMin = m_mdtIdHelper->tubeMin(MdtML);
int tubeMax = m_mdtIdHelper->tubeMax(MdtML);
m_nb_layers_tubes[istation][0] = stationIntId;
m_nb_layers_tubes[istation][1] = layerMax-layerMin+1;
m_nb_layers_tubes[istation][1+multilayer] = tubeMax-tubeMin+1;
}
} //end loop on stations
return StatusCode::SUCCESS;
} //end MdtDqaTubeEfficiency::initialize
//*****************************************************************************
//:::::::::::::::::::::
//:: METHOD finalize ::
//:::::::::::::::::::::
StatusCode MdtDqaTubeEfficiency::finalize() {
/****
Here I have removed everything :
I don't know why the m_mdtIdHelper here gets corrupted!!!
****/
return StatusCode::SUCCESS;
}
//*****************************************************************************
//::::::::::::::::::::::::
//:: METHOD handleEvent ::
//::::::::::::::::::::::::
StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event,
int /*eventnumber*/,
const std::vector<MuonCalibSegment *> &segments,
unsigned int position) {
bool RPCTimeCorrection = false; // SHOULD BE SETVIA jobOption if useful in the future!
bool t0RefinementTimeCorrection = true; // SHOULD BE SET VIA jobOption if useful in the future!
if( RPCTimeCorrection && t0RefinementTimeCorrection ) return StatusCode::FAILURE;
if (segments.size()<=position) return StatusCode::SUCCESS;
DCSLFitter *fitter = new DCSLFitter();
GlobalTimeFitter *GTFitter = new GlobalTimeFitter(fitter);
const IRtRelation *calibRt(0);
// const IRtResolution * GTFitResol(0);
IRtRelation *GTFitRt(0);
if ( m_GTFitON ) {
if (!m_useNewCalibConstants ) {
GTFitRt = GTFitter->getDefaultRtRelation();
GTFitter->setRtRelation(GTFitRt);
}
}
for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS
MuonCalibSegment segment(*segments[k]);
// if (segment.fittedT0() == 0. ) {
// cout << "DEBUG DEBUG DEBUG segment failed t0 refinement " << endl;
// continue;
// }
//---------------//
//-- Variables --//
//---------------//
/*
if(m_qfitter==NULL){
m_qfitter = new QuasianalyticLineReconstruction();
}
*/
int nb_hits;
// station identifiers //
MuonFixedId Mid((segment.mdtHOT()[0])->identify());
MDTName chamb(Mid);
//this has to be set in order to get the m_detMgr->getMdtReadoutElement() method working correctly
//otherwise also for the first multilayer, the second is returned
//
// M.I. ----> ???? TO CHECK FURTHER !
Mid.setMdtMultilayer(1);
//
// Get REGION and STATION of the first hit of the segment :
//
// int stationNameId = Mid.stationName();
int phi = Mid.phi();
int eta = Mid.eta();
string stationNameStr = Mid.stationNameString();
//
// Check that all the hits in the segment belongs to the same chamber :
//
bool segInOneChamber = true;
for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) {
bool samestation( ((segment.mdtHOT()[l])->identify()).stationNameString()==stationNameStr );
bool samephi( ((segment.mdtHOT()[l])->identify()).phi()==phi );
bool sameeta( ((segment.mdtHOT()[l])->identify()).eta()==eta );
bool sameChamber = samestation && samephi && sameeta;
if (!sameChamber){
segInOneChamber = false;
// cout<< " DEBUG DEBUG segInOneChamber = false " << endl;
// cout<< " DEBUG DEBUG Station " << stationNameStr<<" "<< ((segment.mdtHOT()[l])->identify()).stationNameString() << endl;
// cout<< " DEBUG DEBUG phi "<< phi<<" "<<((segment.mdtHOT()[l])->identify()).phi() << endl;
// cout<< " DEBUG DEBUG eta "<< eta<<" "<<((segment.mdtHOT()[l])->identify()).eta() << endl;
// REINCLUDE THE BREAK !
break;
}
}
// WE SHOULD DECIDE IF A SEGMENT BUILT ON ADJACIENT CHAMBERS SHOULD BE SKIPPED
// ...now skipped
if (!segInOneChamber) continue;
//
// Get numberOfMultiLayers, numberOfLayers, numberOfTubes :
//
int stationIntId = static_cast<int>(m_mdtIdHelper-> elementID(stationNameStr,eta,phi).get_compact());
Identifier station_id = m_id_tool->fixedIdToId(Mid);
int numberOfML, numberOfLayers, numberOfTubes[2];
numberOfML = 0;
numberOfLayers = 0;
numberOfTubes[0] = 0;
numberOfTubes[1] = 0;
for (int ii=0; ii<m_nb_stations; ++ii) {
if (m_nb_layers_tubes[ii][0] == stationIntId) {
numberOfLayers = m_nb_layers_tubes[ii][1];
numberOfTubes[0] = m_nb_layers_tubes[ii][2];
numberOfTubes[1] = m_nb_layers_tubes[ii][3];
if (numberOfTubes[0]>0 || numberOfTubes[1]>0 ) numberOfML = 1;
if (numberOfTubes[0]>0 && numberOfTubes[1]>0 ) numberOfML = 2;
break;
}
}
// if (numberOfML == 1 ) return StatusCode::SUCCESS;
if (numberOfML == 1 ) continue; // GO TO NEXT SEGMENT
int minNumOfHits = numberOfLayers*2 - 1;
// if(segment.mdtHitsOnTrack()<minNumOfHits) return StatusCode::SUCCESS;
if((int)segment.mdtHitsOnTrack()<minNumOfHits) continue; // GO TO NEXT SEGMENT
// Get Histograms
TFile *mdtDqaRoot = m_histoManager->rootFile();
string region = chamb.getRegion();
//if ( stationNameStr.substr(0,1) == "E" ) region = "Endcap";
string side = chamb.getSide();
PhiEtaNameConverter phiEtaConverter;
//string chamberType = stationNameStr;
string chamberType = chamb.getName();
// string fullStationName = chamberType+"_"+ts(phi)+"_"+ts(eta);
// cout << " TEST TEST STATIONNAME : fullStationName = " << fullStationName << endl;
// int sector = phiEtaConverter.phi_8to16(stationNameId,phi);
string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb);
string effiDirName = chamberDirName+"/Efficiency";
string expertDirName = chamberDirName+"/Expert";
TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str());
TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str());
TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str());
if ( !chamberRootDir || !effiRootDir ) {
//cout << " ERROR : dqa Directory " << chamberDirName <<" does NOT EXIST "<< endl;
delete GTFitter; GTFitter=0;
return StatusCode::FAILURE;
}
string histoName;
TH1F* heffiEntries;
TH1F* heffiCounts;
TH2F* heffiVsRadius;
expertRootDir->cd();
histoName = "EfficiencyEntries";
heffiEntries = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str());
histoName = "EfficiencyCounts";
heffiCounts = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str());
if (!heffiEntries || !heffiCounts ) {
//cout << "MdtDqa Efficiency histogram :" << histoName<<" NOT FOUND " << endl;
delete GTFitter; GTFitter=0;
return StatusCode::FAILURE;
}
histoName = "EffiResidVsRadius";
heffiVsRadius = (TH2F*) m_histoManager->GetMdtHisto(histoName,chamb);
chamberRootDir->cd();
float toffset(-9999.);
float timeCorrection(-9999.);
if( m_useTimeCorrections && RPCTimeCorrection ) timeCorrection = segment.mdtHOT()[0]->timeOfFlight();
if( m_useTimeCorrections && t0RefinementTimeCorrection ) timeCorrection = segment.fittedT0();
if ( m_GTFitON ) {
MdtCalibHitBase *segHit = segment.mdtHOT()[0];
MuonFixedId id(segHit->identify());
if (m_useNewCalibConstants ) {
calibRt = p_calib_input_svc->GetRtRelation(id);
if (calibRt==NULL ) {
//cout << "MdtDqaTubeEfficiency:: WARNING Rt NOT FOUND - SEGMENT SKIPPED" << endl;
continue;
}
GTFitRt = const_cast<IRtRelation *> (calibRt);
// GTFitResol = p_calib_input_svc->GetResolution(id);
GTFitter->setRtRelation(GTFitRt);
// here a method on GTFitter should be implemented to setResolution !
// something like
// GlobalTimeFitter::setResolution( IRtResolution * GTFitResol)
}
toffset = GTFitter->GTFit(&segment);
if ((int)segment.mdtHitsOnTrack() < minNumOfHits ) continue;
// Recalibrate all rawhits on this chamber
const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection());
for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=
raw_hits->rawMdtHitCollectionBegin();
it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection
if (GTFitRt==NULL) {
//cout << "MdtDqaTubeEfficiency:: WARNING GTFitRt NOT FOUND - HIT SKIPPED" << endl;
continue;
}
MuonCalibRawMdtHit *hit = *it;
bool samestation( (hit->identify()).stationNameString()==stationNameStr );
bool samephi( (hit->identify()).phi()==phi );
bool sameeta( (hit->identify()).eta()==eta );
bool sameChamber = samestation && samephi && sameeta;
if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber ){
int rawTime = hit->tdcCount();
double newDriftTime = (double)rawTime*25./32. - toffset;
double newRadius = GTFitRt->radius(newDriftTime);
double newResol(9999.);
if (m_defaultResol) newResol = defaultResolution(newRadius);
if (!m_defaultResol) newResol = GTFitter->getDefaultResolution(newRadius); //it is in fact the same
hit->setDriftTime(newDriftTime);
hit->setDriftRadius(newRadius);
hit->setDriftRadiusError(newResol);
// cout << " DEBUG DEBUG : NEW time radius resol : "
// << newDriftTime<<" "<<newRadius<<" "<<newResol<< endl;
} // close IF the hit is in the same chamber
} // END LOOP OVER RawHitCollection
} //END IF GTFIT ON
// START DEBUG TO COMPARE t0-Refit Method with t0RPC timing corrections
//
/*
string histoType;
TH2F * h2;
histoType = "t0FitVst0RPC";
h2 = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType);
h2->Fill(toffset,toffset);
*/
//
// END DEBUG
// RECALIBRATION with NEW CALIB CONSTANTS if GTFIT is OFF
if (m_useNewCalibConstants && !m_GTFitON ) {
// Recalibrate all MdtCalibHitBase on the segment
// (in case calibrations used now are different from those of original segments)
for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { // LOOP OVER MdtCalibHitBase in the segment
MdtCalibHitBase * segHit = segment.mdtHOT()[l];
MuonFixedId id(segHit->identify());
const MdtStationT0Container *t0=p_calib_input_svc->GetT0(id);
const IRtRelation *rt_relation = p_calib_input_svc->GetRtRelation(id);
const IRtResolution *spat_res = p_calib_input_svc->GetResolution(id);
if (t0==NULL || rt_relation==NULL || spat_res==NULL) {
//cout << "MdtDqaTubeEfficiency:: WARNING calib constants NOT FOUND - HIT SKIPPED" << endl;
continue;
}
unsigned short rawTime = segHit->tdcCount();
double newDriftTime = (double)rawTime*25./32. - t0->t0(id.mdtMultilayer(),id.mdtTubeLayer(),id.mdtTube());
if( m_useTimeCorrections ) newDriftTime = newDriftTime - timeCorrection;
double newRadius = rt_relation->radius(newDriftTime);
double newResol(9999.);
if (!m_defaultResol) newResol = spat_res->resolution(newDriftTime);
if (m_defaultResol) newResol = defaultResolution(newRadius);
segHit->setDriftTime(newDriftTime);
segHit->setDriftRadius(newRadius, newResol);
} // END OVER MdtCalibHitBase in the segment
/*
double origSegdirY=segment.direction().y();
double origSegdirZ=segment.direction().z();
double origSegposY=segment.position().y();
double origSegposZ=segment.position().z();
double origSegaseg=0.;
double origSegbseg=0.;
if (origSegdirZ !=0. ) {
origSegaseg=origSegdirY/origSegdirZ;
origSegbseg= origSegposY - origSegaseg*origSegposZ;
}
*/
// Recalibrate all rawhits on this chamber
const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection());
for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=
raw_hits->rawMdtHitCollectionBegin();
it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection
MuonCalibRawMdtHit *hit = *it;
bool samestation( (hit->identify()).stationNameString()==stationNameStr );
bool samephi( (hit->identify()).phi()==phi );
bool sameeta( (hit->identify()).eta()==eta );
bool sameChamber = samestation && samephi && sameeta;
if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber ) {
const MuonFixedId & id(hit->identify());
const MdtStationT0Container *t0=p_calib_input_svc->GetT0(id);
const IRtRelation *rt_relation = p_calib_input_svc->GetRtRelation(id);
const IRtResolution *spat_res = p_calib_input_svc->GetResolution(id);
if (t0==NULL || rt_relation==NULL || spat_res==NULL) {
//cout << "MdtDqaTubeEfficiency:: WARNING calib constants NOT FOUND - HIT SKIPPED" << endl;
continue;
}
int rawTime = hit->tdcCount();
double newDriftTime = (double)rawTime*25./32. - t0->t0(id.mdtMultilayer(),id.mdtTubeLayer(),id.mdtTube());
newDriftTime = newDriftTime - timeCorrection;
double newRadius = rt_relation->radius(newDriftTime);
double newResol(9999.);
if (!m_defaultResol) newResol = spat_res->resolution(newDriftTime);
if (m_defaultResol) newResol = defaultResolution(newRadius);
hit->setDriftTime(newDriftTime);
hit->setDriftRadius(newRadius);
hit->setDriftRadiusError(newResol);
} // close IF the hit is in the same chamber
} // END LOOP OVER RawHitCollection
} // CLOSE If m_useNewCalibConstants
// END RECALIBRATION with NEW CALIB CONSTANTS
/*
// RECALIBRATION from GlobalTimeFit
if ( m_GTFitON ) {
// Recalibrate all MdtCalibHitBase on the segment
// (in case calibrations used now are different from those of original segments)
for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { // LOOP OVER MdtCalibHitBase in the segment
MdtCalibHitBase * segHit = segment.mdtHOT()[l];
MuonFixedId id(segHit->identify());
if (GTFitRt==NULL) {
cout << "MdtDqaTubeEfficiency:: WARNING GTFitRt NOT FOUND - HIT SKIPPED" << endl;
continue;
}
unsigned short rawTime = segHit->tdcCount();
double newDriftTime = (double)rawTime*25./32. - toffset;
double newRadius = GTFitRt->radius(newDriftTime);
double newResol(9999.);
if ( m_useNewCalibConstants ) {
if (!m_defaultResol) newResol = GTFitResol->resolution(newDriftTime);
if (m_defaultResol) newResol = defaultResolution(newRadius);
} else {
// newResol = GTFitter->getDefaultResolution(newRadius);
newResol = defaultResolution(newRadius);
}
segHit->setDriftTime(newDriftTime);
segHit->setDriftRadius(newRadius, newResol);
} // END OVER MdtCalibHitBase in the segment
// refit segment after recalibration
// (is this useful here? we refit anyway with excluded hits)
if (m_useNewCalibConstants || m_GTFitON ) fitter->fit(segment);
//
double origSegdirY=segment.direction().y();
double origSegdirZ=segment.direction().z();
double origSegposY=segment.position().y();
double origSegposZ=segment.position().z();
double origSegaseg=0.;
double origSegbseg=0.;
if (origSegdirZ !=0. ) {
origSegaseg=origSegdirY/origSegdirZ;
origSegbseg= origSegposY - origSegaseg*origSegposZ;
}
//
// Recalibrate all rawhits on this chamber
const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection());
for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=
raw_hits->rawMdtHitCollectionBegin();
it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection
if (GTFitRt==NULL) {
cout << "MdtDqaTubeEfficiency:: WARNING GTFitRt NOT FOUND - HIT SKIPPED" << endl;
continue;
}
MuonCalibRawMdtHit *hit = *it;
bool samestation( (hit->identify()).stationNameString()==stationNameStr );
bool samephi( (hit->identify()).phi()==phi );
bool sameeta( (hit->identify()).eta()==eta );
bool sameChamber = samestation && samephi && sameeta;
if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber ){
int rawTime = hit->tdcCount();
double newDriftTime = (double)rawTime*25./32. - toffset;
double newRadius = GTFitRt->radius(newDriftTime);
double newResol(9999.);
if (m_defaultResol) newResol = defaultResolution(newRadius);
if (!m_defaultResol) newResol = GTFitter->getDefaultResolution(newRadius); //it is in fact the same
hit->setDriftTime(newDriftTime);
hit->setDriftRadius(newRadius);
hit->setDriftRadiusError(newResol);
// cout << " DEBUG DEBUG : NEW time radius resol : "
// << newDriftTime<<" "<<newRadius<<" "<<newResol<< endl;
} // close IF the hit is in the same chamber
} // END LOOP OVER RawHitCollection
} // CLOSE If m_GTFitON
// END RECALIBRATION from GlobalTimeFit
*/
// Now everything is recalibrated and segments are ready.
// Will start to remove one hit per layer
MTStraightLine track0;
track0 = MTStraightLine(segment.position(),segment.direction(),
Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0));
// cout << " DEBUG DEBUG : Start analysis on a new segment --- " << endl;
// loop over MultiLayers
for (int multilayer=1; multilayer<=numberOfML; multilayer++) { // LOOP OVER MULTILAYERS
const MuonGM::MdtReadoutElement *MdtRoEl =
m_detMgr->getMdtReadoutElement( m_mdtIdHelper->channelID(station_id,multilayer,1,1) );
//loop over layers
for (int layer=1; layer<=numberOfLayers; layer++) { // LOOP OVER LAYERS
nb_hits = 0;
// hit selection vector for refits:
// Exclude hit in the current layer
IMdtSegmentFitter::HitSelection
hit_selection = IMdtSegmentFitter::HitSelection(segment.mdtHitsOnTrack());
for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) {
MuonFixedId id((segment.mdtHOT()[l])->identify());
if (id.mdtMultilayer() == multilayer &&
id.mdtTubeLayer() == layer) {
hit_selection[l] = 1;
} else {
hit_selection[l] = 0;
nb_hits = nb_hits+1;
}
}
if (nb_hits<minNumOfHits) continue; // GO TO NEXT LAYER
fitter->fit(segment,hit_selection);
/*
double newSegdirY=segment.direction().y();
double newSegdirZ=segment.direction().z();
double newSegposY=segment.position().y();
double newSegposZ=segment.position().z();
double newSegaseg=0.;
double newSegbseg=0.;
if (newSegdirZ !=0. ) {
newSegaseg=newSegdirY/newSegdirZ;
newSegbseg= newSegposY - newSegaseg*newSegposZ;
// cout<< " DEBUG DEBUG COMPARE ORIG vs NEW Segment " << endl
// << " ORIG a, b " << origSegaseg <<" " << origSegbseg << endl
// << " new a, b " << newSegaseg <<" " << newSegbseg << endl;
}
*/
if ((int)segment.mdtHitsOnTrack() < minNumOfHits ) continue;
if (segment.chi2()>m_chi2Cut) continue;
// counts the hits per Layers in the segment with the excluded layer
int hit_ML_Ly[2][4];
int totLayersWithHits = 0;
for (int iml=0; iml<2; iml++) {
for (int il=0; il<4; il++) hit_ML_Ly[iml][il]= 0;
}
for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) {
MuonFixedId id((segment.mdtHOT()[l])->identify());
hit_ML_Ly[id.mdtMultilayer()-1][id.mdtTubeLayer()-1]++;
}
for (int iml=0; iml<2; iml++) {
for (int il=0; il<4; il++) if (hit_ML_Ly[iml][il]>0) totLayersWithHits++;
}
if ( totLayersWithHits < minNumOfHits ) continue;
// NOW WE HAVE A SELECTED SEGMENT WITH EXCLUDED HIT
MTStraightLine track1;
track1 = MTStraightLine(segment.position(),segment.direction(),
Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0));
std::vector<int> traversed_tube(0);
std::vector<int> hit_tube(0);
std::vector<int> hit_found(0);
double distanceTraversedTube(0);
// find tubes which have been traversed by the track //
for (int k=0; k<numberOfTubes[multilayer-1]; k++) {
Amg::Vector3D TubePos =
MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,k+1));
Amg::Vector3D tube_position = Amg::Vector3D(TubePos.x(), TubePos.y(), TubePos.z());
Amg::Vector3D tube_direction = Amg::Vector3D(1,0,0);
MTStraightLine tube = MTStraightLine( tube_position, tube_direction,
Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) );
// DEBUG GEOMETRY :
// cout << " CHAMBER, eta, phi, ML, LY, TUBE, x, y, z : "<< stationNameStr<<" "<<eta<<" "<<phi
// << " " << multilayer <<" "<< layer <<" "<<k+1 <<" "
// << (MdtRoEl->tubePos(multilayer,layer,k+1)).x() <<" "
// << (MdtRoEl->tubePos(multilayer,layer,k+1)).y() <<" "
// << (MdtRoEl->tubePos(multilayer,layer,k+1)).z() <<" " << endl;
//debug: check geometry
//cout << "AMDpos: " << tube_position
// << ", mypos: " << wire_position[multilayer-1][layer-1][k] << endl;
double distance = TMath::Abs(track1.signDistFrom(tube));
if ( distance < (MdtRoEl->innerTubeRadius()) ){
int traversedTube = k+1;
traversed_tube.push_back(k+1);
distanceTraversedTube = distance;
// TRAVERSED TUBE FOUND! NOW CHECK WHETHER THERE IS A HIT IN THIS TUBE FROM THE RAW HIT COLLECTION:
bool hitFound = false;
const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection());
for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=
raw_hits->rawMdtHitCollectionBegin();
it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection
MuonCalibRawMdtHit *hit = *it;
bool samestation( (hit->identify()).stationNameString()==stationNameStr );
bool samephi( (hit->identify()).phi()==phi );
bool sameeta( (hit->identify()).eta()==eta );
bool sameChamber = samestation && samephi && sameeta;
if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber &&
(hit->identify()).mdtMultilayer() == multilayer &&
(hit->identify()).mdtTubeLayer() == layer) {
if ( hit->adcCount() < m_adcCut ) continue;
int tubeHit = (hit->identify()).mdtTube();
if (tubeHit == traversedTube) { // THE HIT IS FOUND
// check if the same hit was already found
bool alreadyThere = false;
//loop over hit tubes
for (unsigned int j=0; j<hit_found.size(); j++) {
if (tubeHit==hit_found[j]){
alreadyThere=true;
break;
}
}
if (!alreadyThere) { // A NEW HIT HAS BEEN FOUND
hitFound = true;
hit_found.push_back( tubeHit );
if ( m_nsigma < 0 ) hit_tube.push_back( tubeHit );
Amg::Vector3D TubePos =
MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,tubeHit));
Amg::Vector3D tube_position = Amg::Vector3D(TubePos.x(), TubePos.y(), TubePos.z());
Amg::Vector3D tube_direction = Amg::Vector3D(1,0,0);
MTStraightLine tube = MTStraightLine( tube_position, tube_direction,
Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) );
double distance = TMath::Abs(track1.signDistFrom(tube));
double hitRadius = TMath::Abs(hit->driftRadius());
double resol = hit->driftRadiusError();
double resid = distance-hitRadius;
if(heffiVsRadius) heffiVsRadius->Fill(distance, resid);
float averageExtrapolError = 0.090; // ..an educated guess!
float sig = sqrt(resol*resol + averageExtrapolError*averageExtrapolError);
if ( m_nsigma>0. && TMath::Abs(resid) < m_nsigma*sig ) hit_tube.push_back( tubeHit );
} // END NEW HIT FOUND
} // close IF the Hit is found
} // close IF the hit is in the same chamber, same layer
} // END LOOP OVER RawHitCollection
if (!hitFound) if(heffiVsRadius) heffiVsRadius->Fill(distanceTraversedTube,15.5);
} // Close IF Traversed Tube Found
} // END LOOP OVER ALL TUBES IN THE LAYER
// Efficiencies //
//loop over traversed tubes
for (unsigned int k=0; k<traversed_tube.size(); k++) {
int hit_flag = 0;
//loop over hit tubes
for (unsigned int j=0; j<hit_tube.size(); j++) {
if(traversed_tube[k]==hit_tube[j]){
hit_flag = 1;
break;
}
}
int offset=0;
if(multilayer==1) offset= m_histoManager->GetTubeOffsetML1(chamb.getOnlineName());
int offset_atend=0;
if(multilayer==1) offset_atend= m_histoManager->GetTubeOffsetAtEndML1(chamb.getOnlineName());
float iTube = traversed_tube[k];
float ibin = (multilayer-1)*numberOfLayers*numberOfTubes[multilayer-1]+
(layer-1)*(numberOfTubes[multilayer-1]+offset+offset_atend)+iTube+offset;
heffiEntries->Fill(ibin);
if ( hit_flag) heffiCounts->Fill(ibin);
}
} //end of loop over layers
} //end of loop over multilayers
} // end LOOP OVER SEGMENTS
delete fitter;
delete GTFitter;
return StatusCode::SUCCESS;
} //end MdtDqaTubeEfficiency::handleEvent
//*****************************************************************************
//::::::::::::::::::::::::::::
//:: METHOD analyseSegments ::
//::::::::::::::::::::::::::::
StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/) {
TFile *mdtDqaRoot = m_histoManager->rootFile();
const std::vector<MuonCalib::NtupleStationId> stationsInRegion =
p_reg_sel_svc->GetStationsInRegions();
ToString ts;
// cout << " TEST TEST Finalize : start loop over regions loop size: "<< stationsInRegion.size()<<endl;
//loop over stations in region
for ( int istation=0; istation<m_nb_stations; istation++ ) {
// int stationNameId = stationsInRegion.at(istation).GetStation();
int phi = stationsInRegion.at(istation).GetPhi();
int eta = stationsInRegion.at(istation).GetEta();
string stationNameString = stationsInRegion.at(istation).regionId();
string chamberType = stationNameString.substr(0,3);
MDTName chamb(chamberType,phi,eta);
// In the following lines the numberOfML, numberOfLayers, numberOfTubes
// are extracted RELYING on the order of the vector m_nb_layers_tubes[istation][]
// with istation following the same order of stationsInRegion.at(istation)
// ...if this is not the case, then the service m_mdtIdHelper should be used
// matching the stationIntId :
// int stationIntId = (int) m_mdtIdHelper->elementID(chamberType, eta, phi);
int numberOfML = 0;
int numberOfTubes[2];
int numberOfLayers = m_nb_layers_tubes[istation][1];
numberOfTubes[0] = m_nb_layers_tubes[istation][2];
numberOfTubes[1] = m_nb_layers_tubes[istation][3];
if (numberOfTubes[0]>0 || numberOfTubes[1]>0 ) numberOfML = 1;
if (numberOfTubes[0]>0 && numberOfTubes[1]>0 ) numberOfML = 2;
/*string region = "Barrel";
if ( stationNameString.substr(0,1) == "E" ) region = "Endcap";
string side = "A";
if (eta<0) side = "C";*/
string region= chamb.getRegion();
string side=chamb.getSide();
PhiEtaNameConverter phiEtaConverter;
// int sector = phiEtaConverter.phi_8to16(stationNameId,phi);
//string chamberDirName = m_histoManager->GetMdtDirectoryName( region, side,
// sector, chamberType, abs(eta) );
string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb);
string effiDirName = chamberDirName+"/Efficiency";
string expertDirName = chamberDirName+"/Expert";
TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str());
TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str());
TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str());
if ( !chamberRootDir || !effiRootDir ) {
//cout << " ERROR : dqa Directory " << chamberDirName <<" does NOT EXIST "<< endl;
return StatusCode::FAILURE;
}
string histoName;
TH1F *heffiEntries;
TH1F *heffiCounts;
// effiRootDir->cd();
expertRootDir->cd();
histoName = "EfficiencyEntries";
heffiEntries = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str());
histoName = "EfficiencyCounts";
heffiCounts = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str());
if (!heffiEntries || !heffiCounts ) {
//cout << "MdtDqa Efficiency histogram :" << histoName<<" NOT FOUND in "<<chamberDirName << endl;
return StatusCode::FAILURE;
}
chamberRootDir->cd();
TH1F *hg;
histoName = "UNDEFINED";
if (stationNameString.substr(1,1) == "I" ) histoName = "TubeEfficiency_Inner";
if (stationNameString.substr(1,1) == "M" ) histoName = "TubeEfficiency_Middle";
if (stationNameString.substr(1,1) == "O" ) histoName = "TubeEfficiency_Outer";
hg = (TH1F*) m_histoManager->GetMdtHisto(histoName,region,side);
// HERE NOW COMPUTE EFFICIENCY ERRORS AND FILL THE HISTOGRAMS
if (heffiEntries->GetEntries() != 0 ) {
//loop over multilayers
for (int k=0; k<numberOfML; k++) {
//loop over layers
for (int l=0; l<numberOfLayers; l++) {
//loop over tubes
for (int m=0; m<numberOfTubes[k]; m++) {
int iML = k+1;
int iLy = l+1;
int iTube = m+1;
int ibin = (iML-1)*numberOfLayers*numberOfTubes[k]+(iLy-1)*numberOfTubes[k]+iTube;
//calculate efficiency and errors
// HERE WE USE THE Efficiency definition and Error using the Bayesian Statistics:
//
float entries = heffiEntries->GetBinContent(ibin);
float counts = heffiCounts->GetBinContent(ibin);
float efficiency = (counts+1.)/(entries+2.);
float error = sqrt(efficiency*(1-efficiency))/sqrt(entries+3.);
//
// Fill MdtDqa Histos
//
string histoName;
TH1F *heffi;
chamberRootDir->cd();
histoName = "b_EfficiencyPerTube";
heffi = (TH1F*) chamberRootDir->FindObjectAny(histoName.c_str());
if (!heffi) {
//cout << "MdtDqa Efficiency histogram :" << histoName<<" NOT FOUND in " <<chamberDirName << endl;
continue;
}
heffi->SetBinContent(ibin,efficiency);
heffi->SetBinError(ibin,error);
histoName = "EffiPerTube_ML"+ts(iML)+"_L"+ts(iLy);
effiRootDir->cd();
heffi= (TH1F*) effiRootDir->FindObjectAny(histoName.c_str());
if (!heffi) {
//cout << "MdtDqa Efficiency histogram :" << histoName<<" NOT FOUND in " << effiDirName<< endl;
continue;
}
heffi->SetBinContent(iTube,efficiency);
heffi->SetBinError(iTube,error);
// Filling Global plots
if (hg && efficiency>0. && error >0. && error<0.05) hg->Fill(efficiency);
// HERE WE MUST ADD THE EFFICIENCY PER MULTILAYER
// and in case per chamber to put in a NEW overview plot!
// ...
//
} // loop over tube
} // loop over Layer
} // loop over ML
}
} //LOOP on istation
return StatusCode::SUCCESS;
} //end MdtDqaTubeEfficiency::analyseSegments
} // namespace MuonCalib
|
e8d00ef89edc941dbb3f30a11022553abe03f9de
|
ba0a1b19c3786a8d4142da4acdca766fd217cd08
|
/Verify/Common.cpp
|
2d6b8a104143f42730af843d7f504e7577c3c14d
|
[] |
no_license
|
Tc-yao/Verify
|
997cee8b442048769f2bc648b2ac2b036db810bf
|
ee77a5e4561fa5283d3064d26eff6365e5273f95
|
refs/heads/master
| 2020-12-30T13:09:03.276860
| 2017-05-26T06:55:45
| 2017-05-26T06:55:45
| 91,333,748
| 0
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 2,471
|
cpp
|
Common.cpp
|
#include "stdafx.h"
#include "Common.h"
#include <random>
#include <fstream>
#include <time.h>
#pragma comment(lib, "Iphlpapi.lib")
#ifndef _PRINTHEAD
#define _PRINTHEAD "Verify_Demo:%s\n"
#endif
#ifndef _WPRINTHEAD
#define _WPRINTHEAD L"Verify_Demo:%s\n"
#endif
class CWin32Excetion :public std::exception
{
public:
CWin32Excetion(DWORD);
~CWin32Excetion();
const char *what() const;
private:
char* m_lpMsgBuf;
};
const char *CWin32Excetion::what() const
{
return m_lpMsgBuf;
}
CWin32Excetion::CWin32Excetion(DWORD dwError)
{
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(char *)&m_lpMsgBuf,
0,
NULL
);
}
CWin32Excetion::~CWin32Excetion()
{
LocalFree(m_lpMsgBuf);
}
void MskThrowWin32Exception()
{
DWORD dwError = GetLastError();
if (0 != dwError)
throw CWin32Excetion(dwError);
}
void MyPrint(char *msg)
{
if (msg == 0) return;
char newmsg[1024] = { 0 };
sprintf_s(newmsg, _PRINTHEAD, msg);
OutputDebugStringA(newmsg);
}
void MyDbgPrint(const char *fmt, ...)
{
va_list ap;
char sz[1024];
va_start(ap, fmt);
vsprintf(sz, fmt, ap);
MyPrint(sz);
va_end(ap);
}
void MyDbgPrint(char *fmt, ...)
{
va_list ap;
char sz[1024];
va_start(ap, fmt);
vsprintf(sz, fmt, ap);
MyPrint(sz);
va_end(ap);
}
void MyDbgPrint(wchar_t *fmt, ...)
{
OutputDebugStringW(fmt);
return;
va_list ap;
wchar_t sz[1024];
va_start(ap, fmt);
vswprintf_s(sz, 1024, fmt, ap);
wsprintfW(sz, _WPRINTHEAD, sz);
OutputDebugStringW(sz);
va_end(ap);
}
void LogError(const char *fmt, ...)
{
#ifdef DEBUG
auto fp = fopen("Òì³£¼Ç¼.txt", "a");
if (fp == nullptr) return;
va_list ap;
char sz[1024] = { 0 };
va_start(ap, fmt);
vsprintf(sz, fmt, ap);
sz[strlen(sz)] = '\n';
fwrite(sz, strlen(sz), 1, fp);
fclose(fp);
va_end(ap);
#endif
}
int GetRandomNum(int iMin, int iMax)
{
static std::random_device rd;
static std::mt19937 mt(rd());
std::uniform_int_distribution<> dis(iMin, iMax);
return dis(mt);
}
std::string GetRandomString(int num)
{
if (num > 4095) num = 4095;
char buff[4096];
for (int i = 0; i < num; ++i) {
buff[i] = GetRandomNum('A', 'z');
if (buff[i] > 90 && buff[i] < 97) {
buff[i] = '_';
}
}
buff[num] = 0;
return buff;
}
void ThrowWin32Exception()
{
DWORD dwError = GetLastError();
if (0 != dwError)
throw CWin32Excetion(dwError);
}
|
a3d2416c782828b601e77a032a231bc7f8f7d17a
|
92a3a20f1451a35c0f118b117afaf0b1562ab07a
|
/steem/code/key_table.cpp
|
6270fe263ff6cbba01e8eec56a404a75feacfa05
|
[] |
no_license
|
larrykoubiak/steemsse
|
bde3dd0ddab3e08636a149857e82b8b9f48b1512
|
bf29624d84e8d4602ff627454b937336644a31ef
|
refs/heads/master
| 2021-04-28T07:30:24.516384
| 2018-02-20T15:58:24
| 2018-02-20T16:00:23
| 122,219,230
| 0
| 1
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 21,858
|
cpp
|
key_table.cpp
|
#if defined(SSE_BUILD)
#ifndef STEEMKEYTEST
// These are the characters that are produced by pressing Alt+[shift]+key.
// They were really hard to extract from TOS!
// BYTE(STCode),BYTE(Modifiers, bit 0=shift 1=alt),BYTE(STAscii code),BYTE(0)
DWORD AltKeys_French[8]={MAKELONG(MAKEWORD(0x1a,2),'['), MAKELONG(MAKEWORD(0x1b,2),']'),
MAKELONG(MAKEWORD(0x1a,3),'{'), MAKELONG(MAKEWORD(0x1b,3),'}'),
MAKELONG(MAKEWORD(0x2b,2),'@'), MAKELONG(MAKEWORD(0x2b,3),'~'),
MAKELONG(MAKEWORD(0x28,2),'\\'), 0};
DWORD AltKeys_German[7]={MAKELONG(MAKEWORD(0x1a,2),'@'), MAKELONG(MAKEWORD(0x1a,3),'\\'),
MAKELONG(MAKEWORD(0x27,2),'['), MAKELONG(MAKEWORD(0x28,2),']'),
MAKELONG(MAKEWORD(0x27,3),'{'), MAKELONG(MAKEWORD(0x28,3),'}'),
0};
DWORD AltKeys_Spanish[8]={MAKELONG(MAKEWORD(0x1a,2),'['), MAKELONG(MAKEWORD(0x1b,2),']'),
MAKELONG(MAKEWORD(0x1a,3),'{'), MAKELONG(MAKEWORD(0x1b,3),'}'),
MAKELONG(MAKEWORD(0x2b,2),'#'), MAKELONG(MAKEWORD(0x2b,3),'@'),
MAKELONG(MAKEWORD(0x28,2),129/*ü*/), 0};
DWORD AltKeys_Italian[8]={MAKELONG(MAKEWORD(0x1a,2),'['), MAKELONG(MAKEWORD(0x1b,2),']'),
MAKELONG(MAKEWORD(0x1a,3),'{'), MAKELONG(MAKEWORD(0x1b,3),'}'),
MAKELONG(MAKEWORD(0x2b,2),248/*°*/),MAKELONG(MAKEWORD(0x2b,3),'~'),
MAKELONG(MAKEWORD(0x60,2),'`'), 0};
DWORD AltKeys_Swedish[9]={MAKELONG(MAKEWORD(0x1a,2),'['), MAKELONG(MAKEWORD(0x1b,2),']'),
MAKELONG(MAKEWORD(0x1a,3),'{'), MAKELONG(MAKEWORD(0x1b,3),'}'),
MAKELONG(MAKEWORD(0x28,2),'`'), MAKELONG(MAKEWORD(0x28,3),'~'),
MAKELONG(MAKEWORD(0x2b,2),'^'), MAKELONG(MAKEWORD(0x2b,2),'@'),
0};
DWORD AltKeys_Swiss[10]={MAKELONG(MAKEWORD(0x1a,2),'@'), MAKELONG(MAKEWORD(0x1a,3),'\\'),
MAKELONG(MAKEWORD(0x1b,2),'#'),
MAKELONG(MAKEWORD(0x27,2),'['), MAKELONG(MAKEWORD(0x28,2),']'),
MAKELONG(MAKEWORD(0x27,3),'{'), MAKELONG(MAKEWORD(0x28,3),'}'),
MAKELONG(MAKEWORD(0x2b,2),'~'), MAKELONG(MAKEWORD(0x2b,3),'|'),
0};
///extern LANGID KeyboardLangID;
//---------------------------------------------------------------------------
void GetTOSKeyTableAddresses(MEM_ADDRESS *lpUnshiftTable,MEM_ADDRESS *lpShiftTable)
{
MEM_ADDRESS addr=0;
while (addr<tos_len){
if (ROM_PEEK(addr++)=='u'){
if (ROM_PEEK(addr)=='i'){
addr++;
if (ROM_PEEK(addr)=='o'){
addr++;
if (ROM_PEEK(addr)=='p'){
*lpUnshiftTable=addr-25;
break;
}
}
}
}
}
addr=(*lpUnshiftTable)+127;
while (addr<tos_len){
if (ROM_PEEK(addr++)==27){
*lpShiftTable=addr-2;
break;
}
}
}
//---------------------------------------------------------------------------
void GetAvailablePressChars(DynamicArray<DWORD> *lpChars)
{
MEM_ADDRESS UnshiftTableAddr,ShiftTableAddr;
GetTOSKeyTableAddresses(&UnshiftTableAddr,&ShiftTableAddr);
MEM_ADDRESS TableAddr=UnshiftTableAddr;
int Shift=0;
for (int t=0;t<2;t++){
// Go through every entry of both tables
for (int STCode=0;STCode<128;STCode++){
// Ignore keypad codes, they just confuse things and are the same on every ST
if ((STCode<0x63 || STCode>0x72) && STCode!=0x4a && STCode!=0x4e){
BYTE STAscii=ROM_PEEK(TableAddr+STCode);
if (STAscii>32 && STAscii!=127){ // Viewable character and not delete
DWORD Code=MAKELONG(MAKEWORD(STCode,Shift),STAscii);
lpChars->Add(Code);
}
}
}
TableAddr=ShiftTableAddr;
Shift=1;
}
// Handle characters typed while holding Alt, these aren't
// in any key table
DWORD *Alts=NULL;
switch (ROM_PEEK(0x1d)){ // Country code
case 5: Alts=AltKeys_French; break;
case 9: Alts=AltKeys_Spanish; break;
case 3: Alts=AltKeys_German; break;
case 11: Alts=AltKeys_Italian; break;
case 13: Alts=AltKeys_Swedish; break;
case 17: Alts=AltKeys_Swiss; break;
}
if (Alts){
while (*Alts) lpChars->Add(*(Alts++));
}
}
#endif//#ifndef STEEMKEYTEST
WORD *shift_key_table[4]={NULL,NULL,NULL,NULL};
bool EnableShiftSwitching=0,ShiftSwitchingAvailable=0;
//---------------------------------------------------------------------------
#ifdef WIN32
void SetSTKeys(char *Letters,int Val1,...)
{
int *lpVals=&Val1;
int l=0;
WORD Code;
do{
Code=VkKeyScan(Letters[l]);
if (HIBYTE(Code)==0){ //No shift required to type character #Letters[l]
#if defined(SSE_X64_390B)
key_table[LOBYTE(Code)]=LOBYTE(lpVals[l*2]); // each parameter takes 8 bytes
#else
key_table[LOBYTE(Code)]=LOBYTE(lpVals[l]);
#endif
}
}while (Letters[++l]);
}
#elif defined(UNIX)
KeyCode Key_Pause,Key_Quit;
void SetSTKeys(char *Letters,int Val1,...)
{
int *lpVals=&Val1;
int l=0;
KeyCode Code;
do{
// Somehow KeySym codes are exactly the same as Windows standard ASCII codes!
KeySym ks=(KeySym)((unsigned char)(Letters[l])); // Don't sign extend this!
Code=XKeysymToKeycode(XD,ks);
// Now assign this X scan code to the ST scan code, we should only do this if you
// do not need shift/alt to access the character. However, in a vain attempt to
// improve mapping, we assign it anyway if the code isn't already assigned.
if (XKeycodeToKeysym(XD,Code,0)==ks || key_table[LOBYTE(Code)]==0){
key_table[LOBYTE(Code)]=LOBYTE(lpVals[l]);
}
}while (Letters[++l]);
}
//---------------------------------------------------------------------------
void SetSTKey(KeySym Sym,BYTE STCode,bool CanOverwrite)
{
KeyCode Code=XKeysymToKeycode(XD,Sym);
if (key_table[BYTE(Code)]==0 || CanOverwrite){
key_table[BYTE(Code)]=STCode;
}
}
#endif
//---------------------------------------------------------------------------
#define PC_SHIFT 1
#define NO_PC_SHIFT 0
#define PC_ALT 2
#define NO_PC_ALT 0
#define ST_SHIFT 1
#define NO_ST_SHIFT 0
#define ST_ALT 2
#define NO_ST_ALT 0
void AddToShiftSwitchTable(int PCModifiers,int PCAscii,BYTE STModifier,BYTE STCode)
{
BYTE Code;
ShiftSwitchingAvailable=true;
#ifdef WIN32
Code=LOBYTE(VkKeyScan((BYTE)PCAscii));
#elif defined(UNIX)
Code=(BYTE)XKeysymToKeycode(XD,(KeySym)PCAscii);
#endif
if (shift_key_table[PCModifiers]) shift_key_table[PCModifiers][Code]=MAKEWORD(STCode,STModifier);
}
//---------------------------------------------------------------------------
/*
bool GetPCKeyForSTCode(bool ShiftTable,BYTE STCode,BYTE *VKCode,bool *NeedShift)
{
WORD Dat=0xffff;
BYTE Ascii=ROM_PEEK((MEM_ADDRESS)(ShiftTable ? tos_shift_key_table:tos_key_table) + STCode);
if (Ascii>127) Ascii=STCharToPCChar[Ascii-128];
if (Ascii>32){
Dat=VkKeyScan(Ascii);
if (Dat!=0xffff){
*VKCode=LOBYTE(Dat);
*NeedShift=HIBYTE(Dat) & 1;
return true;
}
}
return 0;
}
void GenerateAutomaticKeyTable()
{
bool DoShiftTable[128];
BYTE VKCode,Shift_VKCode;
bool NeedShift;
memset(DoShiftTable,0xff,sizeof(DoShiftTable));
for (int STCode=0;STCode<128;STCode++){
if (STCode ISNT_NUMPAD_KEY){
if (GetPCKeyForSTCode(0,STCode,&VKCode,&NeedShift)){
if (NeedShift==0){
key_table[VkCode]=STCode;
if (GetPCKeyForSTCode(true,STCode,&VKCode,&NeedShift)){
if (Shift_VKCode==VKCode && NeedShift) DoShiftTable[STCode]=0;
}
}else{
if (shift_key_table[1]) shift_key_table[1][VKCode]=STCode;
ShiftSwitchingAvailable=true;
}
}
}
}
for (int STCode=0;STCode<128;STCode++){
if (STCode ISNT_NUMPAD_KEY && DoShiftTable[STCode]){
if (GetPCKeyForSTCode(true,STCode,&VKCode,&NeedShift)){
int PCShift=int(NeedShift ? PC_SHIFT:NO_PC_SHIFT);
if (shift_key_table[PCShift]) shift_key_table[PCShift][VKCode]=STCode | ST_SHIFT;
ShiftSwitchingAvailable=true;
}
}
}
}
*/
//---------------------------------------------------------------------------
void DestroyKeyTable()
{
for (int i=0;i<4;i++){
if (shift_key_table[i]){
free(shift_key_table[i]);
shift_key_table[i]=NULL;
}
}
}
//---------------------------------------------------------------------------
void InitKeyTable()
{
long Language,SubLang;
DestroyKeyTable();
ShiftSwitchingAvailable=0;
if (EnableShiftSwitching){
for (int i=0;i<4;i++){
// i: BIT 0=shift, BIT 1=alt
shift_key_table[i]=(WORD*)malloc(sizeof(WORD)*256);
ZeroMemory(shift_key_table[i],sizeof(WORD)*256);
}
}
#ifdef WIN32
Language=PRIMARYLANGID(KeyboardLangID);
SubLang=SUBLANGID(KeyboardLangID);
/*
Any keys with VK_ constants plus 'A'-'Z' and '0' to '9' will be the same
on all keyboards/languages, these are set up in ikbd.h. The rest are put
into the key_table here.
NOTE: On Windows SetSTKeys doesn't put it in the table if modifiers are
required to produce the characters.
*/
SetSTKeys("-=[];" "\'",0x0c,0x0d,0x1a,0x1b,0x27, 0x28);
SetSTKeys("`#,./",0x29,0x2b,0x33,0x34,0x35);
#elif defined(UNIX)
Language=LOWORD(KeyboardLangID);
SubLang=HIWORD(KeyboardLangID);
ZeroMemory(key_table,sizeof(key_table));
SetSTKeys("1234567890-=",0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD);
SetSTKeys("qwertyuiop[]",0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B);
SetSTKeys("asdfghjkl;'",0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28);
SetSTKeys("zxcvbnm,./",0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35);
SetSTKey(XK_Escape,0x1);
SetSTKey(XK_grave,0x29);
SetSTKey(XK_BackSpace,0xE);
SetSTKey(XK_Tab,0xF);
SetSTKey(XK_Return,0x1C);
SetSTKey(XK_Delete,0x53);
key_table[VK_CONTROL]=0x1d;
SetSTKey(XK_Control_L,0x1D);
SetSTKey(XK_Control_R,0x1D);
// Should never get VK_SHIFT
SetSTKey(XK_Shift_L,0x2A);
SetSTKey(XK_Shift_R,0x36);
key_table[VK_MENU]=0x38;
SetSTKey(XK_Alt_L,0x38);
SetSTKey(XK_Alt_R,0x38);
SetSTKey(XK_space,0x39);
SetSTKey(XK_Caps_Lock,0x3A);
SetSTKey(XK_F1,0x3B);
SetSTKey(XK_F2,0x3C);
SetSTKey(XK_F3,0x3D);
SetSTKey(XK_F4,0x3E);
SetSTKey(XK_F5,0x3F);
SetSTKey(XK_F6,0x40);
SetSTKey(XK_F7,0x41);
SetSTKey(XK_F8,0x42);
SetSTKey(XK_F9,0x43);
SetSTKey(XK_F10,0x44);
SetSTKey(XK_Help,0x62);
SetSTKey(XK_Undo,0x61);
// If you don't have help and undo keys use Page Up and Page Down
SetSTKey(XK_Page_Up,0x62);
SetSTKey(XK_Page_Down,0x61);
SetSTKey(XK_Insert,0x52);
SetSTKey(XK_Home,0x47);
SetSTKey(XK_Up,0x48);
SetSTKey(XK_Left,0x4B);
SetSTKey(XK_Down,0x50);
SetSTKey(XK_Right,0x4D);
SetSTKey(XK_F11,0x63); // (
SetSTKey(XK_F12,0x64); // )
SetSTKey(XK_KP_Divide,0x65);
SetSTKey(XK_KP_Multiply,0x66);
SetSTKey(XK_KP_7,0x67);
SetSTKey(XK_KP_8,0x68);
SetSTKey(XK_KP_9,0x69);
SetSTKey(XK_KP_Subtract,0x4A);
SetSTKey(XK_KP_4,0x6A);
SetSTKey(XK_KP_5,0x6B);
SetSTKey(XK_KP_6,0x6C);
SetSTKey(XK_KP_Add,0x4E);
SetSTKey(XK_KP_1,0x6D);
SetSTKey(XK_KP_2,0x6E);
SetSTKey(XK_KP_3,0x6F);
SetSTKey(XK_KP_0,0x70);
SetSTKey(XK_KP_Decimal,0x71);
SetSTKey(XK_KP_Enter,0x72);
#endif
if (SubLang==SUBLANG_ENGLISH_UK){
SetSTKeys("\\" "#",0x60, 0x2b);
}else if (SubLang==SUBLANG_ENGLISH_AUS){
SetSTKeys("\\",0x60); // # not unshifted on Aus keyboard, might overwrite something if we map
}else{
SetSTKeys("\\",0x2b);
}
switch (Language){
case LANG_ENGLISH:
if (SubLang==SUBLANG_ENGLISH_AUS){
AddToShiftSwitchTable(PC_SHIFT, '2',ST_SHIFT,0x28); // Shift+"2" = Shift+"'" = "@"
AddToShiftSwitchTable(PC_SHIFT, '\'',ST_SHIFT,0x3); // Shift+"'" = Shift+"2" = "
AddToShiftSwitchTable(PC_SHIFT, '3',NO_ST_SHIFT,0x2b); // Shift+"3" = "#" = "#"
AddToShiftSwitchTable(PC_SHIFT, '`',ST_SHIFT,0x2b); // Shift+"`" = Shift+"#" = "~"
}
break;
case LANG_FRENCH:
if (SubLang==SUBLANG_FRENCH_BELGIAN){
SetSTKeys( "&" "é" "\"" "\'" "(" "§" "è" "!" "ç" "à" ")" "-",
0x2,0x3, 0x4, 0x5, 0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd);
SetSTKeys("az^$",0x10,0x11,0x1a,0x1b);
SetSTKeys("qmùµ",30,39,40,0x29);
SetSTKeys("<w,;:=",96,44,50,51,52,0x35);
AddToShiftSwitchTable(PC_ALT, '&',ST_SHIFT,0x2b); // |
AddToShiftSwitchTable(PC_ALT, 'é',ST_ALT,0x2b); // @
AddToShiftSwitchTable(PC_ALT,'\"',0,0x2b); // #
AddToShiftSwitchTable(PC_ALT, 'ç',ST_ALT+ST_SHIFT,0x1a); // {
AddToShiftSwitchTable(PC_ALT, 'à',ST_ALT+ST_SHIFT,0x1b); // }
AddToShiftSwitchTable(PC_ALT, '^',ST_ALT,0x1a); // [
AddToShiftSwitchTable(PC_ALT, '$',ST_ALT,0x1b); // ]
AddToShiftSwitchTable(PC_ALT, 'µ',0,0x29); // `
AddToShiftSwitchTable(PC_ALT, '<',ST_ALT,0x28); /* \ */
AddToShiftSwitchTable(PC_ALT, '=',ST_ALT+ST_SHIFT,0x2b); // ~
}else{
SetSTKeys( "&" "é" "\"" "\'" "(" "-" "è" "_" "ç" "à" ")" "=",
0x2,0x3, 0x4, 0x5, 0x6,0x7,0x8,0x9,0xa,0xb,0xc,0x35);
SetSTKeys("az^$",0x10,0x11,0x1a,0x1b);
SetSTKeys("qmù*",30,39,40,0x66);
SetSTKeys("<w,;:!",96,44,50,51,52,0x9);
AddToShiftSwitchTable(0,'-',0,0xd); // -
AddToShiftSwitchTable(PC_SHIFT,'-',ST_SHIFT,0x7); // 6
AddToShiftSwitchTable(0,'_',ST_SHIFT,0xd); // _
AddToShiftSwitchTable(PC_SHIFT,'_',ST_SHIFT,0x9); // 8
AddToShiftSwitchTable(0,'!',0,0x9); // !
AddToShiftSwitchTable(PC_SHIFT,'!',0,0x7); // §
AddToShiftSwitchTable(PC_SHIFT,'$',ST_SHIFT,0x29); // £
AddToShiftSwitchTable(PC_ALT, 'é',ST_ALT+ST_SHIFT,0x2b); // ~
AddToShiftSwitchTable(PC_ALT,'\"',0,0x2b); // #
AddToShiftSwitchTable(PC_ALT,'\'',ST_ALT+ST_SHIFT,0x1a); // {
AddToShiftSwitchTable(PC_ALT, '(',ST_ALT,0x1a); // [
AddToShiftSwitchTable(PC_ALT, '-',ST_SHIFT,0x2b); // |
AddToShiftSwitchTable(PC_ALT, 'è',0,0x29); // `
AddToShiftSwitchTable(PC_ALT, '_',ST_ALT,0x28); /* \ */
AddToShiftSwitchTable(PC_ALT, 'ç',0,0x1a); // ^
AddToShiftSwitchTable(PC_ALT, 'à',ST_ALT,0x2b); // @
AddToShiftSwitchTable(PC_ALT, ')',ST_ALT,0x1b); // ]
AddToShiftSwitchTable(PC_ALT, '=',ST_ALT+ST_SHIFT,0x1b); // }
AddToShiftSwitchTable(PC_ALT, '$',ST_SHIFT,0xc); // ¤ !
}
break;
case LANG_GERMAN:
{
SetSTKeys("ß" "\'" "zü+öä#~y-<",12, 13, 21,26,27,39,40,41,43,44,53,96);
/* ___
Key #220 = ASCII '^' (#94) = ST keycode 0x2b ; / ;
Key #221 = ASCII '´' (#180) = ST keycode 0xd #180=; ;
---
*/
#ifdef WIN32
SetSTKeys("^´",0x2b,0xd);
#else
SetSTKey(XK_dead_circumflex,0x2b,true);
SetSTKey(XK_dead_acute,0xd,true);
#endif
/*
Shift + Key #191 = ASCII '#' (#35) = ST keycode No Shift+ 0xd
No shift + Key #220 = ASCII '^' (#94) = ST keycode Shift+ 0x29
Shift + Key #220 = ASCII '^' (#94) = ST keycode No Shift+ 0x2b
*/
AddToShiftSwitchTable(PC_SHIFT,'#',NO_ST_SHIFT,0xd); // '
AddToShiftSwitchTable(NO_PC_SHIFT,'^',ST_SHIFT,0x29); // ^
AddToShiftSwitchTable(PC_SHIFT,'^',NO_ST_SHIFT,0x2b); // ~
// PC alt to no ST alt
AddToShiftSwitchTable(PC_ALT,'+',0,0x2b); /* ~ */
AddToShiftSwitchTable(PC_ALT,'<',ST_SHIFT,0x2b); /* | */
// PC alt to ST alt (but moved)
AddToShiftSwitchTable(PC_ALT,'Q',ST_ALT,0x1a); /* @ */
AddToShiftSwitchTable(PC_ALT,'ß',ST_ALT+ST_SHIFT,0x1a); /* \ */
AddToShiftSwitchTable(PC_ALT,'8',ST_ALT,0x27); /* [ */
AddToShiftSwitchTable(PC_ALT,'9',ST_ALT,0x28); /* ] */
AddToShiftSwitchTable(PC_ALT,'7',ST_ALT+ST_SHIFT,0x27); /* { */
AddToShiftSwitchTable(PC_ALT,'0',ST_ALT+ST_SHIFT,0x28); /* } */
break;
}
case LANG_SPANISH:
case LANG_CATALAN:
case LANG_BASQUE:
SetSTKeys("\'" "`´ñ;ç" "\\" ".°<[{^",26 ,0x1b,0x1a,39,40,41, 43, 0x34,0x35,0x60,0x0c,0x28,0x1b);
AddToShiftSwitchTable(PC_SHIFT,'1',ST_SHIFT,0x34); // !
AddToShiftSwitchTable(PC_SHIFT,'2',ST_SHIFT,0x1a); // "
AddToShiftSwitchTable(PC_SHIFT,'3',NO_ST_SHIFT,0x71); // · (central .)
AddToShiftSwitchTable(PC_SHIFT,'6',ST_SHIFT,0x8); // &
AddToShiftSwitchTable(PC_SHIFT,'7',ST_SHIFT,0x7); // /
AddToShiftSwitchTable(PC_SHIFT,'8',ST_SHIFT,0xa); // ( ___
AddToShiftSwitchTable(PC_SHIFT,'9',ST_SHIFT,0xb); // ) ; o ;
AddToShiftSwitchTable(PC_SHIFT, '\''/*39 */,ST_SHIFT,0x33); // ? ; ;
AddToShiftSwitchTable(NO_PC_SHIFT,'º' /*186*/,NO_ST_SHIFT,0x35); // º --- #186
AddToShiftSwitchTable(PC_SHIFT, 'º' /*186*/,NO_ST_SHIFT,0x2b); /* \ */
AddToShiftSwitchTable(NO_PC_SHIFT,'¡' /*161*/,ST_SHIFT, 0x2); // ¡
AddToShiftSwitchTable(PC_SHIFT, '¡' /*161*/,ST_SHIFT, 0x3); // ? (upside down)
AddToShiftSwitchTable(NO_PC_SHIFT,'+' /*43 */,ST_SHIFT, 0xd); // + ___
AddToShiftSwitchTable(PC_SHIFT, '+' /*43 */,NO_ST_SHIFT,0x66); // * ; . ;
AddToShiftSwitchTable(PC_SHIFT, ',' /*44 */,NO_ST_SHIFT,0x28); // ; ; | ;
AddToShiftSwitchTable(PC_SHIFT, '.' /*46 */,ST_SHIFT, 0x28); // : --- #161
AddToShiftSwitchTable(PC_SHIFT, '0', NO_ST_SHIFT,0x0d); // =
AddToShiftSwitchTable(PC_ALT,'º' /*186*/ ,0,0x2b); /* \ */
AddToShiftSwitchTable(PC_ALT,'1',ST_SHIFT,0x2b); // | ___
AddToShiftSwitchTable(PC_ALT,'2',ST_ALT+ST_SHIFT,0x2b); // @ ; C ;
AddToShiftSwitchTable(PC_ALT,'3',ST_ALT,0x2b); // # ; j ;
AddToShiftSwitchTable(PC_ALT,'`',ST_ALT,0x1a); // [ --- #231
AddToShiftSwitchTable(PC_ALT,'+',ST_ALT,0x1b); // ]
AddToShiftSwitchTable(PC_ALT,'´' /*180*/,ST_ALT+ST_SHIFT,0x1a); // { 180=horz flip `
AddToShiftSwitchTable(PC_ALT,'ç' /*231*/,ST_ALT+ST_SHIFT,0x1b); // }
break;
case LANG_ITALIAN:
SetSTKeys("ìèòàù\\.-<" "\'" "+",13,26,39,40,41,43,52,53,96, 12, 27);
break;
case LANG_SWEDISH:
SetSTKeys("+éåüöä" "\'" "\\" "-<",12,13,26,27,39,40, 41, 43, 53,96);
AddToShiftSwitchTable(PC_ALT,'+',NO_ST_SHIFT,0x2b); /* \ */
AddToShiftSwitchTable(PC_ALT,'2',ST_ALT,0x2b); // @
/*
AddToShiftSwitchTable(PC_ALT,'3',0,0); // £
AddToShiftSwitchTable(PC_ALT,'4',0,0); // $
AddToShiftSwitchTable(PC_ALT,'7',0,0); // {
AddToShiftSwitchTable(PC_ALT,'8',0,0); // [
AddToShiftSwitchTable(PC_ALT,'9',0,0); // ]
AddToShiftSwitchTable(PC_ALT,'0',0,0); // }
*/
break;
case LANG_NORWEGIAN:
SetSTKeys("ß'zü+öä#~y-<",12,13,0x2c,26,27,39,40,41,43,0x15,53,96);
{
/*
But the key #186 has a ^ shifted, not £. There is one key that didn't
come out: key 219 = \, and ` shifted, and one for which
I didn't find the right unshifted key: key #220, which is |, shifted §.
Key #186 = ASCII ¨ (#-88) = ST keycode 0x1b
Key #187 = ASCII + (#43) = ST keycode 0xc
Key #191 = ASCII ' (#39) = ST keycode 0x29
Key #192 = ASCII ø (#-8) = ST keycode 0x28
Key #221 = ASCII å (#-27) = ST keycode 0x1a
Key #222 = ASCII æ (#-26) = ST keycode 0x27
*/
#if defined(SSE_VS2008_WARNING_390)
#pragma warning (disable: 4310)
#endif
#if defined(SSE_COMPILER_WARNING) // stops a warning L2 in VC6
char char_list[]= {(char)168,43,39,(char)248,(char)229,(char)230,0};
#else
char char_list[]= {168,43,39,248,229,230,0};
#endif
SetSTKeys(char_list,0x1b,0xc,0x29,0x28,0x1a,0x27);
#pragma warning (default: 4310)
}
break;
}
#ifndef STEEMKEYTEST
if (ShiftSwitchingAvailable==0) DestroyKeyTable();
#endif
}
#ifdef UNIX
void UNIX_get_fake_VKs()
{
VK_LBUTTON=0xf0;VK_RBUTTON=0xf1;VK_MBUTTON=0xf2;
VK_F11=XKeysymToKeycode(XD,XK_F11);
VK_F12=XKeysymToKeycode(XD,XK_F12);
VK_END=XKeysymToKeycode(XD,XK_End);
VK_LEFT=XKeysymToKeycode(XD,XK_Left);
VK_RIGHT=XKeysymToKeycode(XD,XK_Right);
VK_UP=XKeysymToKeycode(XD,XK_Up);
VK_DOWN=XKeysymToKeycode(XD,XK_Down);
VK_TAB=XKeysymToKeycode(XD,XK_Tab);
VK_SHIFT=0xf3;
VK_LSHIFT=XKeysymToKeycode(XD,XK_Shift_L);
VK_RSHIFT=XKeysymToKeycode(XD,XK_Shift_R);
VK_CONTROL=0xf4;
VK_RCONTROL=XKeysymToKeycode(XD,XK_Control_R);
VK_LCONTROL=XKeysymToKeycode(XD,XK_Control_L);
VK_MENU=0xf5;
VK_LMENU=XKeysymToKeycode(XD,XK_Alt_L);
VK_RMENU=XKeysymToKeycode(XD,XK_Alt_R);
VK_SCROLL=0xf6;
VK_NUMLOCK=0xf7;
Key_Pause=XKeysymToKeycode(XD,XK_Pause);
}
#endif
#endif
|
ea5271a06a5aef5169ffe3792398c5cc4c79acaf
|
19f546bd37ea6222516f4e8742b6fb5b17a679a1
|
/include/sde/CJunctionViewFieldsInfo.h
|
a128cd2fe6fba8fd691770ecb29e7f5818635c20
|
[] |
no_license
|
caojianwudong/delerrorgit
|
d48ed862acecda7c979a0a5f7077f1e156595a4f
|
c416091f955398283495b2bb8ac0f2a1ef0d8996
|
refs/heads/master
| 2020-04-12T17:53:44.766853
| 2018-12-21T03:55:53
| 2018-12-21T03:55:53
| 162,661,227
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,653
|
h
|
CJunctionViewFieldsInfo.h
|
//## begin module%1.2%.codegen_version preserve=yes
// Read the documentation to learn more about C++ code generator
// versioning.
//## end module%1.2%.codegen_version
//## begin module%405A57A401BB.cm preserve=no
// %X% %Q% %Z% %W%
//## end module%405A57A401BB.cm
//## begin module%405A57A401BB.cp preserve=no
//## end module%405A57A401BB.cp
//## Module: CJunctionViewFieldsInfo%405A57A401BB; Pseudo Package specification
#ifndef CJunctionViewFieldsInfo_h
#define CJunctionViewFieldsInfo_h 1
//## begin module%405A57A401BB.additionalIncludes preserve=no
//## end module%405A57A401BB.additionalIncludes
//## begin module%405A57A401BB.includes preserve=yes
//## end module%405A57A401BB.includes
#include "CFieldsInfo.h"
#include "CAttachFieldsInfo.h"
//## begin module%405A57A401BB.additionalDeclarations preserve=yes
#include <string>
#include "commondef.h" // Added by ClassView
#include "CFields.h" // Added by ClassView
//## end module%405A57A401BB.additionalDeclarations
//## begin CJunctionViewFieldsInfo%405A57A401BB.preface preserve=yes
//## end CJunctionViewFieldsInfo%405A57A401BB.preface
//## Class: CJunctionViewFieldsInfo%405A57A401BB
//## Category: DataAccess%4056B67500D5
//## Persistence: Transient
//## Cardinality/Multiplicity: n
//##ModelId=46B7B836038B
class __declspec(dllexport) CJunctionViewFieldsInfo: public CAttachRoadFieldsInfo
{
//## begin CJunctionViewFieldsInfo%405A57A401BB.initialDeclarations preserve=yes
//## end CJunctionViewFieldsInfo%405A57A401BB.initialDeclarations
public:
//##ModelId=46B7B836039A
virtual bool CheckFieldsInfo();
//##ModelId=46B7B836039B
int GetCompoundJunctionIDIndex();
virtual int GetAttachFeatureIDIndex();
virtual int GetAttachFeatureMeshIDIndex();
//##ModelId=46B7B836039C
virtual int GetStartRoadIDIndex();
virtual int GetEndRoadIDIndex();
virtual int GetStartRoadMeshIDIndex();
virtual int GetEndRoadMeshIDIndex();
//##ModelId=46B7B836039E
int GetJunctionViewIDIndex();
virtual int GetIDIndex();
//## Constructors (generated)
//##ModelId=46B7B836039F
CJunctionViewFieldsInfo();
//## Destructor (generated)
//##ModelId=46B7B83603A0
~CJunctionViewFieldsInfo();
// Additional Public Declarations
//## begin CJunctionViewFieldsInfo%405A57A401BB.public preserve=yes
//## end CJunctionViewFieldsInfo%405A57A401BB.public
};
//## begin CJunctionViewFieldsInfo%405A57A401BB.postscript preserve=yes
//## end CJunctionViewFieldsInfo%405A57A401BB.postscript
// Class CJunctionViewFieldsInfo
//## begin module%405A57A401BB.epilog preserve=yes
//## end module%405A57A401BB.epilog
#endif
|
2d845c0f3d137b638513a29e419d370a3c06dd98
|
cf65adc6d4498dab5bc737052f042a304a623061
|
/462.cpp
|
8017c076507313e59ed4b92d97035a5c1c2118f6
|
[] |
no_license
|
orzzzl/uva
|
b8d5971961b21f428fe1aeb80834c8739fd07490
|
37d0188ad3c760ee0c919ac7d90b0b6c3cfac753
|
refs/heads/master
| 2016-08-05T18:33:36.215270
| 2015-12-28T05:54:08
| 2015-12-28T05:54:08
| 34,170,436
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,734
|
cpp
|
462.cpp
|
#include <bits/stdc++.h>
using namespace std;
int stop [10];
int cnt [10];
int card [20][20];
void clear () {
memset (card, 0, sizeof (card));
memset (cnt, 0, sizeof (cnt));
memset (stop, 0, sizeof (stop));
}
int main () {
char s [1000];
map <char, int> tran;
tran ['A'] = 1;
tran ['T'] = 10;
tran ['J'] = 11;
tran ['Q'] = 12;
tran ['K'] = 13;
tran ['S'] = 0;
tran ['H'] = 1;
tran ['D'] = 2;
tran ['C'] = 3;
while (gets (s)) {
clear ();
for (int i = 0; i < 13; i ++) {
cnt [tran [s[i * 3 + 1]]] ++;
if (s[i * 3] >= 0 && s [i * 3] <= 9) continue;
card [tran [s[i * 3]]] [tran [s[i * 3 + 1]]] = 1;
}
int pnt = 0;
for (int i = 0; i < 4; i ++) {
if (card [1][i]) {
pnt += 4;
stop [i] ++;
}
if (card [13][i]) {
pnt += 3;
if (cnt [i] == 1) pnt -= 1;
if (cnt [i] > 1) stop [i] ++;
}
if (card [12][i]) {
pnt += 2;
if (cnt [i] <= 2) pnt -= 1;
else stop [i] ++;
}
if (card [11][i]) {
pnt += 1;
if (cnt [i] <=3) pnt -= 1;
}
}
if (pnt >= 16 && stop [0] && stop [1] && stop [2] && stop [3]) {
puts ("BID NO-TRUMP");
continue;
}
for (int i = 0; i < 4; i ++) {
if (cnt [i] == 2)
pnt += 1;
if (cnt [i] == 1 || cnt [i] == 0)
pnt += 2;
}
if (pnt < 14) {
puts ("PASS");
continue;
}
int maxx = 0;
for (int i = 0; i < 4; i ++) {
maxx = max (cnt [i], maxx);
}
for (int i = 0; i < 4; i ++) {
if (cnt [i] == maxx) {
// cout << i << endl;
// cout << maxx << endl;
char ans = i == 3 ? 'C' : (i == 2 ? 'D' : (i == 1 ? 'H' : 'S'));
printf ("BID %c\n", ans);
break;
}
}
}
return 0;
}
|
13a582ec3cf875d686fa49480dfb464f17a840b5
|
de9f72a763a082499462e8267be5a7f1e68d8ea3
|
/source/ttblue/tt_overdrive.h
|
006d817464e0eebefd06205f0515f89de7de850d
|
[
"BSD-3-Clause"
] |
permissive
|
natcl/TapTools
|
d6ea9038834c1cfb48f32d20166cf7980c63adc4
|
30a8bdc83e3e8df3f3aac69f38f5dcd64681a4f2
|
refs/heads/master
| 2020-04-03T12:00:05.539483
| 2013-05-01T15:31:00
| 2013-05-01T15:31:00
| 9,793,935
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,341
|
h
|
tt_overdrive.h
|
/*
*******************************************************
* OVERDRIVE / SOFT SATURATION
* waveshaping object which uses the equation
* y = 1 - (1 - x)^n (positive quadrant only)
* to shape the input signal.
*******************************************************
* TapTools Blue Object
* copyright � 2003 by Timothy A. Place
*
*/
// Check against redundant including
#ifndef TT_OVERDRIVE_H
#define TT_OVERDRIVE_H
// Include appropriate headers
#include "tt_audio_base.h"
/********************************************************
CLASS INTERFACE/IMPLEMENTATION
The entire class is implemented inline for speed.
********************************************************/
class tt_overdrive:public tt_audio_base{
private:
// Function pointer for the ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib Loop (use this instead of branching for speed)
typedef void (tt_overdrive::*function_ptr_1in_1out)(tt_audio_signal *, tt_audio_signal *);
typedef void (tt_overdrive::*function_ptr_2in_2out)(tt_audio_signal *, tt_audio_signal *, tt_audio_signal *, tt_audio_signal *);
function_ptr_1in_1out dsp_executor_mono;
function_ptr_2in_2out dsp_executor_stereo;
// Attributes Values & Variables
tt_attribute_value_discrete mode;
tt_attribute_value drive;
tt_attribute_value_bool defeat_dcblocker;
double last_input1;
double last_output1;
double last_input2;
double last_output2;
float s, b, nb, z, scale;
float preamp_db;
float preamp_linear;
public:
enum selectors{
k_drive, // Attribute Selectors
k_defeat_dcblocker,
k_mode,
k_preamp
};
// OBJECT LIFE
tt_overdrive() // Constructor
{
mode = 0;
preamp_db = 0;
preamp_linear = 1.;
set_attr(k_drive, 3.0);
set_attr(k_defeat_dcblocker, 0.0);
clear();
}
~tt_overdrive() // Destructor
{
;
}
// ATTRIBUTES
void set_attr(tt_selector sel, tt_attribute_value val) // Set Attributes
{
switch (sel){
case k_drive:
drive = clip(val, float(1.0), float(10.0));
// the following only apply to mode 1...
{
float f = (drive - 0.999) * 0.111; // range is roughly [0.001 to 0.999]
int i;
z = pi * f;
s = 1.0 / sin(z);
b = 1.0 / f;
b = clip(b, 0.0f, 1.0f);
nb = b * -1;
i = int(f);
if(f-i > 0.5)
scale = sin(f * pi);
else
scale = 1.;
}
return;
case k_mode:
mode = (tt_attribute_value_discrete)val;
break;
case k_defeat_dcblocker:
defeat_dcblocker = val;
break;
case k_preamp:
preamp_db = val;
preamp_linear = decibels_to_amplitude(preamp_db);
break;
}
if(defeat_dcblocker && (mode == 0)){ // MODE 0 - no blocker
dsp_executor_mono = &tt_overdrive::dsp_vector_calc_mono_nodcblock;
dsp_executor_stereo = &tt_overdrive::dsp_vector_calc_stereo_nodcblock;
}
else if(mode == 0){ // MODE 0 - with blocker
dsp_executor_mono = &tt_overdrive::dsp_vector_calc_mono;
dsp_executor_stereo = &tt_overdrive::dsp_vector_calc_stereo;
}
else if(defeat_dcblocker){ // MODE 1 - no blocker
dsp_executor_mono = &tt_overdrive::dsp_vector_calc_mono_sine_nodcblock;
dsp_executor_stereo = &tt_overdrive::dsp_vector_calc_stereo_sine_nodcblock;
}
else{ // MODE 1 - with blocker
dsp_executor_mono = &tt_overdrive::dsp_vector_calc_mono_sine;
dsp_executor_stereo = &tt_overdrive::dsp_vector_calc_stereo_sine;
}
}
tt_attribute_value get_attr(tt_selector sel) // Get Attributes
{
switch (sel){
case k_drive:
return drive;
default:
return 0.0;
}
}
// METHOD: clear
void clear()
{
last_input1 = 0.0;
last_output1 = 0.0;
last_input2 = 0.0;
last_output2 = 0.0;
}
/*****************************************************
* ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib LOOPS
*****************************************************/
// Publically exposed interface for MONO dsp routine
void dsp_vector_calc(tt_audio_signal *in, tt_audio_signal *out)
{
(*this.*dsp_executor_mono)(in, out); // Run the function pointed to by our function pointer
}
// Publically exposed interface for STEREO dsp routine
void dsp_vector_calc(tt_audio_signal *in1, tt_audio_signal *in2, tt_audio_signal *out1, tt_audio_signal *out2)
{
(*this.*dsp_executor_stereo)(in1, in2, out1, out2); // Run the function pointed to by our function pointer
}
private:
// ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib LOOP: mono
void dsp_vector_calc_mono(tt_audio_signal *in, tt_audio_signal *out)
{
tt_sample_value temp;
temp_vs = in->vectorsize;
while(temp_vs--){
temp = *in->vector++ * preamp_linear;
// Integrated DC Blocker:
last_output1 = temp - last_input1 + (last_output1 * 0.9997);
last_input1 = temp;
temp = last_output1;
// Here starts the Overdrive:
float sign = 1.0;
// the equation only works in the positive quadrant...
// so we strip off the sign, apply the equation, and reapply the sign
if (temp < 0.0) {
temp = -temp;
sign = -1.0;
}
if (temp > 1.0){ // clip signal if it's out of range
*out->vector++ = clip(temp * sign, float(-1.0), float(1.0));
}
else{
*out->vector++ = sign * (1.0 - exp(drive * log(1.0 - temp)));
}
}
in->reset(); out->reset();
}
// ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib LOOP: stereo
void dsp_vector_calc_stereo(tt_audio_signal *in1, tt_audio_signal *in2,
tt_audio_signal *out1, tt_audio_signal *out2)
{
tt_sample_value temp_left, temp_right;
temp_vs = in1->vectorsize;
float sign_left, sign_right;
while(temp_vs--){
temp_left = *in1->vector++ * preamp_linear;
temp_right = *in2->vector++ * preamp_linear;
// Integrated DC Blocker:
last_output1 = temp_left - last_input1 + (last_output1 * 0.9997);
last_input1 = temp_left;
last_output2 = temp_right - last_input2 + (last_output2 * 0.9997);
last_input2 = temp_right;
temp_left = last_output1;
temp_right = last_output2;
// Here starts the Overdrive:
sign_left = 1.0;
sign_right = 1.0;
// the equation only works in the positive quadrant...
// so we strip off the sign, apply the equation, and reapply the sign
if(temp_left < 0.0){
temp_left = -temp_left;
sign_left = -1.0;
}
if(temp_right < 0.0){
temp_right = -temp_right;
sign_right = -1.0;
}
// LEFT CHANNEL
if(temp_left > 1.0) // clip signal if it's out of range
*out1->vector++ = clip(temp_left * sign_left, float(-1.0), float(1.0));
else
*out1->vector++ = sign_left * (1.0 - exp(drive * log(1.0 - temp_left)));
// RIGHT CHANNEL
if(temp_right > 1.0) // clip signal if it's out of range
*out2->vector++ = clip(temp_right * sign_right, float(-1.0), float(1.0));
else
*out2->vector++ = sign_right * (1.0 - exp(drive * log(1.0 - temp_right)));
}
in1->reset(); in2->reset(); out1->reset(); out2->reset();
}
// ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib LOOP: mono - no dc blocking
void dsp_vector_calc_mono_nodcblock(tt_audio_signal *in, tt_audio_signal *out)
{
tt_sample_value temp;
temp_vs = in->vectorsize;
while(temp_vs--){
temp = *in->vector++ * preamp_linear;
float sign = 1.0;
// the equation only works in the positive quadrant...
// so we strip off the sign, apply the equation, and reapply the sign
if (temp < 0.0) {
temp = -temp;
sign = -1.0;
}
if (temp > 1.0){ // clip signal if it's out of range
*out->vector++ = clip(temp * sign, float(-1.0), float(1.0));
}
else{
*out->vector++ = sign * (1.0 - exp(drive * log(1.0 - temp)));
}
}
in->reset(); out->reset();
}
// ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib LOOP: stereo - no dc blocking
void dsp_vector_calc_stereo_nodcblock(tt_audio_signal *in1, tt_audio_signal *in2,
tt_audio_signal *out1, tt_audio_signal *out2)
{
tt_sample_value temp_left, temp_right;
temp_vs = in1->vectorsize;
float sign_left, sign_right;
while(temp_vs--){
temp_left = *in1->vector++ * preamp_linear;
temp_right = *in2->vector++ * preamp_linear;
sign_left = 1.0;
sign_right = 1.0;
// the equation only works in the positive quadrant...
// so we strip off the sign, apply the equation, and reapply the sign
if(temp_left < 0.0){
temp_left = -temp_left;
sign_left = -1.0;
}
if(temp_right < 0.0){
temp_right = -temp_right;
sign_right = -1.0;
}
// LEFT CHANNEL
if(temp_left > 1.0) // clip signal if it's out of range
*out1->vector++ = clip(temp_left * sign_left, float(-1.0), float(1.0));
else
*out1->vector++ = sign_left * (1.0 - exp(drive * log(1.0 - temp_left)));
// RIGHT CHANNEL
if(temp_right > 1.0) // clip signal if it's out of range
*out2->vector++ = clip(temp_right * sign_right, float(-1.0), float(1.0));
else
*out2->vector++ = sign_right * (1.0 - exp(drive * log(1.0 - temp_right)));
}
in1->reset(); in2->reset(); out1->reset(); out2->reset();
}
void dsp_vector_calc_mono_sine_nodcblock(tt_audio_signal *in, tt_audio_signal *out)
{
tt_sample_value temp;
temp_vs = in->vectorsize;
while(temp_vs--){
temp = *in->vector++ * preamp_linear;
if(temp > b)
temp = 1.;
else if(temp < nb)
temp = -1.;
else
temp = sin(z * temp) * s;
*out->vector++ = temp * scale;
}
in->reset(); out->reset();
}
void dsp_vector_calc_stereo_sine_nodcblock(tt_audio_signal *in1, tt_audio_signal *in2, tt_audio_signal *out1, tt_audio_signal *out2)
{
tt_sample_value temp_left, temp_right;
temp_vs = in1->vectorsize;
while(temp_vs--){
temp_left = *in1->vector++ * preamp_linear;
temp_right = *in2->vector++ * preamp_linear;
if(temp_left > b)
temp_left = 1.;
else if(temp_left < nb)
temp_left = -1.;
else
temp_left = sin(z * temp_left) * s;
if(temp_right > b)
temp_right = 1.;
else if(temp_right < nb)
temp_right = -1.;
else
temp_right = sin(z * temp_right) * s;
*out1->vector++ = temp_left * scale;
*out2->vector++ = temp_right * scale;
}
in1->reset(); in2->reset(); out1->reset(); out2->reset();
}
void dsp_vector_calc_mono_sine(tt_audio_signal *in, tt_audio_signal *out)
{
tt_sample_value temp;
temp_vs = in->vectorsize;
while(temp_vs--){
temp = *in->vector++ * preamp_linear;
// Integrated DC Blocker:
last_output1 = temp - last_input1 + (last_output1 * 0.9997);
last_input1 = temp;
temp = last_output1;
// Here starts the Overdrive:
if(temp > b)
temp = 1.;
else if(temp < nb)
temp = -1.;
else
temp = sin(z * temp) * s;
*out->vector++ = temp * scale;
}
in->reset(); out->reset();
}
void dsp_vector_calc_stereo_sine(tt_audio_signal *in1, tt_audio_signal *in2, tt_audio_signal *out1, tt_audio_signal *out2)
{
tt_sample_value temp_left, temp_right;
temp_vs = in1->vectorsize;
while(temp_vs--){
temp_left = *in1->vector++ * preamp_linear;
temp_right = *in2->vector++ * preamp_linear;
// Integrated DC Blocker:
last_output1 = temp_left - last_input1 + (last_output1 * 0.9997);
last_input1 = temp_left;
last_output2 = temp_right - last_input2 + (last_output2 * 0.9997);
last_input2 = temp_right;
temp_left = last_output1;
temp_right = last_output2;
// Here starts the Overdrive:
if(temp_left > b)
temp_left = 1.;
else if(temp_left < nb)
temp_left = -1.;
else
temp_left = sin(z * temp_left) * s;
if(temp_right > b)
temp_right = 1.;
else if(temp_right < nb)
temp_right = -1.;
else
temp_right = sin(z * temp_right) * s;
*out1->vector++ = temp_left * scale;
*out2->vector++ = temp_right * scale;
}
in1->reset(); in2->reset(); out1->reset(); out2->reset();
}
};
#endif // TT_OVERDRIVE_H
|
292c1bf0301ce4cd147194a962221a24e973eb4b
|
ff5fd313a8b958a5f5039c54b36c4538a0221d12
|
/Source/MyFirstCoolTESTGame/Private/AI/Services/FCTCheckAmmoService.cpp
|
21c35af82091316a137372a8f4e52f4fbe1de370
|
[] |
no_license
|
YuriyKortev/MyFirstCoolTESTGame
|
1fdf236fa51469bdc09f05d5165c82c67a575885
|
46cca7bf86c3b89ece0128bd95f9208b35bf4f4f
|
refs/heads/master
| 2023-06-26T18:13:56.715925
| 2021-07-30T14:54:53
| 2021-07-30T14:54:53
| 369,049,375
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,207
|
cpp
|
FCTCheckAmmoService.cpp
|
// MyFirstCoolTESTGame. All rights RESRVED!
#include "AI/Services/FCTCheckAmmoService.h"
#include "Components/FCGWeaponComponent.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "AIController.h"
UFCTCheckAmmoService::UFCTCheckAmmoService()
{
NodeName = "CheckAmmo";
}
void UFCTCheckAmmoService::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
const auto Blackboard = OwnerComp.GetBlackboardComponent();
if (Blackboard)
{
const auto Controller = OwnerComp.GetAIOwner();
const auto Pawn = Controller->GetPawn();
const auto WeaponComponent = Pawn->FindComponentByClass<UFCGWeaponComponent>();
FAmmoData CurrentWeaponAmmo;
if (WeaponComponent && WeaponComponent->GetCurrentAmmoData(CurrentWeaponAmmo))
{
const bool BulletsCondition = CurrentWeaponAmmo.Bullets == 0;
Blackboard->SetValueAsBool(IsLastWeapon.SelectedKeyName, WeaponComponent->IsLastWeapon());
Blackboard->SetValueAsBool(ClipEmpty.SelectedKeyName, BulletsCondition);
Blackboard->SetValueAsBool(AmmoEmpty.SelectedKeyName,
BulletsCondition && CurrentWeaponAmmo.Clips == 0);
}
}
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
}
|
b0a98e1c2a24d6367dc25b42e4b9574cf365d811
|
849c31b85417aa5a7593bac965d81d98054e1ef1
|
/project2/Savings.cpp
|
51c998f6d97aaf5679c75314a525199297859a6f
|
[] |
no_license
|
neenar/COMPSCI256
|
4169a729262a6a28bd435eaecd510ce06c1f6821
|
120f6804fb216218e6a30ac1f77b474ba8590b6f
|
refs/heads/master
| 2022-04-30T04:12:51.134733
| 2022-04-11T06:07:24
| 2022-04-11T06:07:24
| 189,142,304
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,093
|
cpp
|
Savings.cpp
|
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include "Account.h"
#include "Savings.h"
using namespace std;
void Savings::DoWithdraw(int amount){
setBalance(getBalance() - amount);
this->withdraws.insert(this->withdraws.begin()+this->numWithDraws, amount);
this->numWithDraws++;
}
Savings::Savings(){
setName("Neena");
setTaxID(123456789);
setBalance(100.00);
}
Savings::Savings(string aname, long ataxID, double abalance){
setName(aname);
setTaxID(ataxID);
setBalance(abalance);
}
void Savings::display(){
cout << "Withdraws from savings: ";
for (vector<double>::reverse_iterator i = withdraws.rbegin();
i != withdraws.rend(); ++i ){
cout << "$" << *i << " | ";
}
cout << endl << "Deposits into checking: ";
for (vector<double>::reverse_iterator i = deposits.rbegin();
i != deposits.rend(); ++i ){
cout << "$" << *i << " | ";
}
cout << endl << endl;
}
|
b44dc48aea798da61987005134e4421fcdf50f97
|
cff8946ee6e4ea4c231c1b6dc7ebae3ed6bbcabd
|
/engine/modules/scene/terrain/terrain_material.cpp
|
407f87558012030be236ef7884d9ad41632284a9
|
[
"MIT"
] |
permissive
|
Pablo-Qt/echo
|
c71a7e3b0fdd5d6a044dcbdc3ca8927cb6dbe63e
|
724b53336856167c549d2aeb3b271aef3e1ef3fc
|
refs/heads/master
| 2021-03-10T23:33:01.944351
| 2020-03-07T11:51:56
| 2020-03-07T11:51:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,744
|
cpp
|
terrain_material.cpp
|
#include "terrain_material.h"
static const char* g_terrainVsCode = R"(#version 450
// uniforms
layout(binding = 0) uniform UBO
{
mat4 u_WorldMatrix;
mat4 u_WorldViewProjMatrix;
} vs_ubo;
// input
layout(location = 0) in vec3 a_Position;
layout(location = 1) in vec4 a_Normal;
layout(location = 2) in vec2 a_UV;
// outputs
layout(location = 0) out vec2 v_UV;
layout(location = 1) out vec3 v_Normal;
void main(void)
{
vec4 position = vs_ubo.u_WorldViewProjMatrix * vec4(a_Position, 1.0);
gl_Position = position;
v_UV = a_UV;
v_Normal = normalize(vec3(vs_ubo.u_WorldMatrix * vec4(a_Normal.xyz, 0.0)));
}
)";
static const char* g_terrainPsCode = R"(#version 450
precision mediump float;
// inputs
layout(location = 0) in vec2 v_UV;
layout(location = 1) in vec3 v_Normal;
// outputs
layout(location = 0) out vec4 o_FragColor;
void main(void)
{
mediump vec3 lightDir = normalize(vec3(1.0, 1.0, 1.0));
mediump vec3 lightColor = vec3(0.8, 0.8, 0.8);
mediump vec3 textureColor = max(dot(v_Normal, lightDir), 0.0) * lightColor + vec3(0.2, 0.2, 0.2);
o_FragColor = vec4(textureColor, 1.0);
}
)";
namespace Echo
{
ShaderProgramPtr TerrainMaterial::getDefaultShader()
{
ResourcePath shaderVirtualPath = ResourcePath("echo_terrain_default_shader");
ShaderProgramPtr shader = ECHO_DOWN_CAST<ShaderProgram*>(ShaderProgram::get(shaderVirtualPath));
if(!shader)
{
shader = ECHO_CREATE_RES(ShaderProgram);
shader->setPath(shaderVirtualPath.getPath());
shader->setType("glsl");
shader->setVsCode(g_terrainVsCode);
shader->setPsCode(g_terrainPsCode);
}
return shader;
}
}
|
e3a88179d899c3eba045e6f9478f70fe1c1d8896
|
2de6ea56de4ff689d5abc19c6ea932f9c48eecb7
|
/triangle/test.cpp
|
87c264b700149bb5c0b57110f9a909c58d623d46
|
[] |
no_license
|
KennySmith95/KatasC-
|
9f9a8e491f22b02eb2a187d517108a6b9d31eec6
|
6883d0461ad1bec33109a1632cb6f289338fe398
|
refs/heads/master
| 2020-03-09T22:44:57.602884
| 2018-04-11T05:59:01
| 2018-04-11T05:59:01
| 129,041,713
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,446
|
cpp
|
test.cpp
|
#include "triangle.h"
#include <assert.h>
#include <iostream>
int inOneOrder (std::string msg, int a , int b, int c, std::string expected) {
std::cout << msg << "(" << a <<", " << b << ", " << c << ")" << std::endl;
std::string result = testTriangle(a,b,c);
assert (result == expected);
return 0;
}
int inAllOrders (int a, int b, int c, std::string expected){
inOneOrder ("in specified order", a, b, c, expected);
inOneOrder ("rotated once", b, c, a, expected);
inOneOrder ("rotated twice", c, a, b, expected);
inOneOrder ("reversed", c, b, a, expected);
inOneOrder ("reversed and rotated once", b, a, c, expected);
inOneOrder ("reversed and rotated twice", a, c, b, expected);
return 0;
}
int main(){
inOneOrder ("Three equal segments", 5, 5, 5, "Equilateral");
std::cout << "Two equal segments and one unequal one" << std::endl;
inAllOrders (5, 5, 4, "Isosceles");
std::cout << "Two segments whose squares add to the square of the third" << std::endl;
inAllOrders (6, 8, 10, "Right");
std::cout << "Three segments that don't fit any classification except that they make a triangle" << std::endl;
inAllOrders (10, 11, 12, "Other");
std::cout << "One segment that's equal to the sum of the other two" << std::endl;
inAllOrders (7, 5, 12, "NotATriangle");
std::cout << "Three segments that appear isosceles except that they're actually not a triangle" << std::endl;
inAllOrders (4, 4, 8, "NotATriangle");
}
|
ccb6db8469a68a16c0e7ed5caaad9ed934f1827c
|
b449f16bf8a945eb25336ff9b40514984f647863
|
/ProjectHP/GameObject.cpp
|
cc8bffc4cf9a3b6f6dacdf5a5f42e0c7faebfc78
|
[] |
no_license
|
vino333/HarryPotter
|
89004d8b9b6669a9504352be6e007b133458aa34
|
cecc2fd940de9b645193a160bd71e5034673cffe
|
refs/heads/master
| 2020-08-06T00:10:55.502945
| 2019-10-04T11:01:02
| 2019-10-04T11:01:02
| 212,765,606
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 210
|
cpp
|
GameObject.cpp
|
#include "GameObject.h"
#include "Resources.h"
// game object c-tor
GameObject::GameObject(float i, float j)
{
m_currPosition = sf::Vector2f(j*SQUARE_SIZE, i*SQUARE_SIZE);
}
GameObject::~GameObject()
{
}
|
1af297969b64e0c1083084286130e4f59d250f53
|
357ebde0cc6e7b0e7529e2967a8fa724d0b072d7
|
/Language/C++/C++_learning/18.3.structure and function together.cpp
|
e68ab935fc20ca6af12a7759dcbb0edfbf7b28ed
|
[] |
no_license
|
Naveenprabaharan/Learning
|
0a54e7dd61ea9de5a04dfb5b44c576bb8de3b379
|
bd3f265e5d62ce162fce880c47a6e0e028c9a557
|
refs/heads/main
| 2023-06-24T14:53:44.272352
| 2021-07-29T09:48:07
| 2021-07-29T09:48:07
| 379,639,852
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 600
|
cpp
|
18.3.structure and function together.cpp
|
#include<iostream>
using namespace std;
struct person{
char name[50];
int age;
float salary;
};
void displayPerson(person p);
int main()
{
person p;
cout<<"Enter person Name:";
cin.get(p.name,sizeof(p.name));
cout<<"Enter person age:";
cin>>p.age;
cout<<"Enter person Salary:";
cin>>p.salary;
displayPerson(p);
return 0;
}
void displayPerson(person p)
{
cout<<"---Displaying Person Information---\n";
cout<<"Name: "<<p.name<<endl;
cout<<"Age: "<<p.age<<endl;
cout<<"Salary: "<<p.salary<<endl;
}
|
9da7277492cb4450b4a030e9c074428a602afc13
|
86bbef537ddfff74a71b3ae365bbacdb030d8097
|
/PS/BOJ/C++/15340.cc
|
6be7602849540f1592520b30c594534c75f821bb
|
[] |
no_license
|
gun2841/guno
|
5262a4cfb4d1d952d96875434a29e78549c8306a
|
32cdcdf2cfeccd07d83a9a1a72645bac4c365688
|
refs/heads/master
| 2022-05-05T03:49:22.164304
| 2022-03-30T03:49:49
| 2022-03-30T03:49:49
| 165,786,624
| 0
| 1
| null | 2020-09-02T21:05:10
| 2019-01-15T04:43:10
|
HTML
|
UTF-8
|
C++
| false
| false
| 385
|
cc
|
15340.cc
|
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int solve(int C, int D)
{
int a = 30 * C + 40 * D;
int b = 35 * C + 30 * D;
int c = 40 * C + 20 * D;
return min(min(a, b), min(a, c));
}
int main()
{
int C, D;
while (scanf("%d %d", &C, &D)) {
if (C == 0 && D == 0)
break;
cout << solve(C, D) << endl;
}
}
|
0c16937d259a10f7b6e7053fce6b22fb7428c2d0
|
1c3a0fe04d338653b827f7785603a835bb158431
|
/payment.cpp
|
27bfceb39b268245191522a409c2b85158c0740b
|
[] |
no_license
|
gautamrastogi/Flight-ReservationSystemC-
|
e18935517c61781ea6869ba426a614421bdbe93b
|
52195432bd34f6d49d59bc394f565562658f716f
|
refs/heads/master
| 2022-09-03T19:15:58.166362
| 2020-05-27T12:05:12
| 2020-05-27T12:05:12
| 262,391,257
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,909
|
cpp
|
payment.cpp
|
#include <iostream>
#include "payment.h"
using namespace std;
int payment::isNumberString(const string & s) {
int len = s.length();
for (int i = 0; i < len; i++) {
if (s[i] < '0' || s[i] > '9')
flag = 0;
}
flag++;
}
void payment::pay_detail() { //definition for payment method
cout << "\n\n\nHow would you like to pay?:\n";
cout << "\n\1.Debit Card(1) \n\2.Credit Card(2) \n\3.Net Banking(3)";
cout << "\n\nEnter your choice";
cin >> choice1;
switch (choice1) //switch case
{
case 1: //condition
while (flag == 0) {
cout << "\nEnter valid card no.:";
cin >> card;
if (!isNumberString(card)) {
cout << "Bad input! Input a Vaild card number. ";
flag = 0;
}
int len = card.length();
int doubleEvenSum = 0;
for (int i = len - 2; i >= 0; i = i - 2) {
int dbl = ((card[i] - 48) * 2);
if (dbl > 9) {
dbl = (dbl / 10) + (dbl % 10);
}
doubleEvenSum += dbl;
}
for (int i = len - 1; i >= 0; i = i - 2) {
doubleEvenSum += (card[i] - 48);
}
if (doubleEvenSum % 10 == 0) {
cout << "Card is Valid!" << endl;
flag++;
} else {
cout << "Invalid! Card. Input a Vaild card number" << endl;
flag = 0;
}
}
cout << "\nEnter expiry date:";
cin >> date;
cout << "\nEnter CVV no.:";
cin >> cvv;
cout << "\nTransaction Successful\n";
break;
case 2: //condition
while (flag == 0) {
cout << "\nEnter valid card no.:";
cin >> card;
if (!isNumberString(card)) {
cout << "Bad input! Input a Vaild card number. ";
flag = 0;
}
int len = card.length();
int doubleEvenSum = 0;
for (int i = len - 2; i >= 0; i = i - 2) {
int dbl = ((card[i] - 48) * 2);
if (dbl > 9) {
dbl = (dbl / 10) + (dbl % 10);
}
doubleEvenSum += dbl;
}
for (int i = len - 1; i >= 0; i = i - 2) {
doubleEvenSum += (card[i] - 48);
}
if (doubleEvenSum % 10 == 0) {
cout << "Card is Valid!" << endl;
flag++;
} else {
cout << "Invalid! Card. Input a Vaild card number" << endl;
flag = 0;
}
}
cout << "\nEnter expiry date:";
cin >> date;
cout << "\nEnter password:";
cin >> password;
cout << "\nTransaction Successful\n";
break;
case 3: //condition
cout << "Banks Available: \1.SEB(1) \2.Danske Bank(2) \3.Swebank(3) \4.Luminor Bank(4) \5.Others(5)";
cout << "\nSelect your bank:";
cin >> bank;
cout << "\nYou have selected:" << bank;
cout << "\nEnter user id:";
cin >> user_id;
cout << "\nEnter password:";
cin >> password;
cout << "\nTransaction Successful\n";
break;
default: //condition
cout << "\nWrong input entered.\nTry again\n\n";
return pay_detail();
}
};
|
c39452361fa92dd7e9eca2c10c503fc2ddbf1f6b
|
3a7dc88b1abbb96be27e08713befbbb4b71d0219
|
/src/Escola.h
|
48a8e4eac3989012424934c120febe33e5b52bab
|
[] |
no_license
|
AndreiaGouveia/AEDA-PROJ1
|
ff45aacc1a5cf312f07690990b5189c029e8181a
|
ee25dcb2d4b59a3c675855284aa80b641d02e41c
|
refs/heads/master
| 2020-04-03T19:27:43.652156
| 2019-01-10T10:19:40
| 2019-01-10T10:19:40
| 155,524,179
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,797
|
h
|
Escola.h
|
#include "Utente.h"
#include "Exceptions.h"
/**
* @class Escola
*
* @ingroup Escola
*
* @brief Classe para instanciar escolas
*
* Esta classe agrupa todas as caracteristicas de uma escola.
* Pertmite definir as escolas frequentadas pelos utentes da empresa de transportes,
* operando sobre elas:
* obter a zona onde se encontra,
* obter e modificar o nome e morado do diretor
* obter o codigo que a define,
* obter e modificar o vetor de utentes (adicionar, remover e alterar)
*/
class Escola
{
private:
vector<Utente*> utentes; ///< Vetor de apontadores para utentes que frequentam a escola e se encontram assinados ao serviço de transportes
string nome; ///< Nome da escola
unsigned codigo; ///< Codigo da escola
string nome_diretor; ///< Nome do diretor da escola
string morada_diretor; ///< Morada do diretor da escola
unsigned zona; ///< Zona da escola
public:
/**
* @brief Construtor da classe Escola
*
* @param nome Nome da Escola
* @param codigo Codigo da Escola
* @param nome_d Nome do diretor
* @param morada_d Morada do diretor
* @param zonaEsc Zona da escola
*/
Escola(string nome, unsigned codigo, string nome_d, string morada_d, unsigned zona);
/**
* @brief Devolve o nome da escola
*
* @return string A informação é devolvida numa string
*/
string getNome() const;
/**
* @brief Devolve os utentes que frequentam a escola
*
* @return vector<Utente*> A informação é devolvida num vetor de apontador de utentes
*/
vector<Utente*> getUtentes() const;
/**
* @brief Devolve a zona da escola
*
* @return unsigned A informação é devolvida num unsigned
*/
unsigned getZona() const;
/**
* @brief Devolve o codigo da escola
*
* @return unsigned A informação é devolvida num unsigned
*/
unsigned getCodigo() const;
/**
* @brief Devolve o nome e morada do diretor
*
* @return string A informação é devolvida num par de strings (primeiro o nome e segundo a morada)
*/
pair<string,string> getDiretorInfo() const;
/**
* @brief Altera as informações do diretor da escola
*
* @param nome Nome do diretor
* @param morada Morada do diretor
*/
void set_diretor(const string &nome, const string &morada);
/**
* @brief Adiciona um utente ao vetor de utentes
*
* @param ut Apontador para o Utente a ser adicionado
*/
void addUtente(Utente *ut);
/**
* @brief Remove um utente ao vetor de utentes
*
* @param ut Apontador para o Utente a ser removido
*/
void removeUtente(Utente *ut);
/**
* @brief Compara duas escolas, assinalando qual é a menor
*
* @return bool A funçao retorna 1 se a primeira escola for menor que a segunda, e 0 caso contrario
*/
bool operator<(const Escola &esc) const;
friend ostream& operator <<(ostream& out,const Escola &esc);
};
|
13838281b1f0b7999ba6c0d5a135070f2a6f9904
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/chrome/browser/extensions/chrome_extension_web_contents_observer.h
|
4128d08656c9a3d24494e2f45285965cc8bf0e87
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C++
| false
| false
| 2,226
|
h
|
chrome_extension_web_contents_observer.h
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_
#include <stdint.h>
#include <string>
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/extension_web_contents_observer.h"
#include "extensions/common/stack_frame.h"
namespace content {
class RenderFrameHost;
}
namespace extensions {
// An ExtensionWebContentsObserver that adds support for the extension error
// console, reloading crashed extensions, routing extension messages between
// renderers and updating autoplay policy.
class ChromeExtensionWebContentsObserver
: public ExtensionWebContentsObserver,
public content::WebContentsUserData<ChromeExtensionWebContentsObserver> {
public:
ChromeExtensionWebContentsObserver(
const ChromeExtensionWebContentsObserver&) = delete;
ChromeExtensionWebContentsObserver& operator=(
const ChromeExtensionWebContentsObserver&) = delete;
~ChromeExtensionWebContentsObserver() override;
// Creates and initializes an instance of this class for the given
// |web_contents|, if it doesn't already exist.
static void CreateForWebContents(content::WebContents* web_contents);
private:
friend class content::WebContentsUserData<ChromeExtensionWebContentsObserver>;
explicit ChromeExtensionWebContentsObserver(
content::WebContents* web_contents);
// ExtensionWebContentsObserver:
void InitializeRenderFrame(
content::RenderFrameHost* render_frame_host) override;
std::unique_ptr<ExtensionFrameHost> CreateExtensionFrameHost(
content::WebContents* web_contents) override;
// content::WebContentsObserver overrides.
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
// Reloads an extension if it is on the terminated list.
void ReloadIfTerminated(content::RenderFrameHost* render_frame_host);
WEB_CONTENTS_USER_DATA_KEY_DECL();
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
36aa39345653df36cd2c67cbd15c157b3cc22b1a
|
f8dc09bd08309239ae3357ee51569ef25c5c81c9
|
/152/main.cpp
|
d3159ad4858cface5829f2f6b9cb1f15d0c7b026
|
[] |
no_license
|
liusy58/Leetcode
|
58127f8d81dac7c79e0c5243c9a26cfc5a6da49a
|
36f02d51ef323f54461fa357db375f6cf6937ac2
|
refs/heads/master
| 2021-07-03T23:33:27.540465
| 2021-01-10T09:10:09
| 2021-01-10T09:10:09
| 216,967,067
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 418
|
cpp
|
main.cpp
|
int maxProduct(vector<int>& nums) {
int len=(int)nums.size();
vector<int>minn(nums);
vector<int>maxx(nums);
int res=nums[0];
for(int i=1;i<len;++i)
{
minn[i]=min(nums[i],min(minn[i-1]*nums[i],maxx[i-1]*nums[i]));
maxx[i]=max(nums[i],max(minn[i-1]*nums[i],maxx[i-1]*nums[i]));
res=max(res,maxx[i]);
}
return res;
}
|
7eb7296fa411bf4b2078d574c06cee91e94253ae
|
97b1e2d55f68bf593faa39542ac0cf21b99ded12
|
/12-FunctionOverloading/12-FunctionOverloading.cpp
|
d20ca03200376e6b2d1151817ee5df8d10c08938
|
[] |
no_license
|
dzy-monkey/C-StudyAdvance
|
f3b1222c2659387a1accb075354acf7fcf8054fe
|
6f1c9dcf3ac319342a281196f202432bb92f7c55
|
refs/heads/master
| 2021-05-24T17:34:18.788741
| 2020-04-14T08:20:44
| 2020-04-14T08:20:44
| 253,679,434
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,024
|
cpp
|
12-FunctionOverloading.cpp
|
/*
函数重载
*/
#include <iostream>
using namespace std;
void print(const char* cp);
void print(const int* beg, const int* end);
void print(const int ia[], size_t size);
int main()
{
char c = 'a';
//传递的实参是char类型的指针,所以会调用第一个函数
print(&c);
const size_t size = 5;
int arr[size] = { 2,3,3 };
//传递的实参是两个Int类型的指针,所以会调用第二个函数
print(&arr[2], &arr[size - 1]);
//传递的实参是数组和一个size_t类型的值,所以会调用第三个函数
print(arr, size);
//传递的实参是一个数组,但是没有和它相对应的参数列表的函数定义,所以会出错
//print(arr);
}
void print(const char* cp) {
cout << "1: " << *cp << endl;
}
void print(const int* beg, const int* end) {
int length = end - beg;
for (int i = 0; i <= length; i++)
{
cout << "2: " << *(beg + i) << endl;
}
}
void print(const int ia[], size_t size) {
for (int i = 0; i < size; i++)
{
cout << "3: " << ia[i] << endl;
}
}
|
77b8f27f1d0ade0a5a53e143405410e5ee6e30e9
|
98cdab33fe3ae0c16135b0e02710e3423cd1085a
|
/src/GeoSphere.h
|
c6b33447f050d3b45c7ae5320ad3d9291c024991
|
[] |
no_license
|
dsalt/pioneer
|
c76754a6af21d66a0e46fa596c91692b360ad249
|
aff37148f86f377bd6cab81b595d3fd593b25858
|
refs/heads/master
| 2021-01-15T17:29:40.865112
| 2012-12-02T02:36:20
| 2012-12-02T02:36:20
| 1,718,965
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,303
|
h
|
GeoSphere.h
|
// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
#ifndef _GEOSPHERE_H
#define _GEOSPHERE_H
#include <SDL_stdinc.h>
#include "vector3.h"
#include "mtrand.h"
#include "galaxy/StarSystem.h"
#include "graphics/Material.h"
#include "terrain/Terrain.h"
namespace Graphics { class Renderer; }
class SystemBody;
class GeoPatch;
class GeoPatchContext;
class GeoSphere {
public:
GeoSphere(const SystemBody *body);
~GeoSphere();
void Render(Graphics::Renderer *r, vector3d campos, const float radius, const float scale);
inline double GetHeight(vector3d p) {
const double h = m_terrain->GetHeight(p);
s_vtxGenCount++;
#ifdef DEBUG
// XXX don't remove this. Fix your fractals instead
// Fractals absolutely MUST return heights >= 0.0 (one planet radius)
// otherwise atmosphere and other things break.
assert(h >= 0.0);
#endif /* DEBUG */
return h;
}
friend class GeoPatch;
static void Init();
static void Uninit();
static void OnChangeDetailLevel();
// in sbody radii
double GetMaxFeatureHeight() const { return m_terrain->GetMaxHeight(); }
static int GetVtxGenCount() { return s_vtxGenCount; }
static void ClearVtxGenCount() { s_vtxGenCount = 0; }
private:
void BuildFirstPatches();
GeoPatch *m_patches[6];
const SystemBody *m_sbody;
/* all variables for GetHeight(), GetColor() */
Terrain *m_terrain;
///////////////////////////
// threading rubbbbbish
// update thread can't do it since only 1 thread can molest opengl
static int UpdateLODThread(void *data);
std::list<GLuint> m_vbosToDestroy;
SDL_mutex *m_vbosToDestroyLock;
void AddVBOToDestroy(GLuint vbo);
void DestroyVBOs();
vector3d m_tempCampos;
SDL_mutex *m_updateLock;
SDL_mutex *m_abortLock;
bool m_abort;
//////////////////////////////
inline vector3d GetColor(const vector3d &p, double height, const vector3d &norm) {
return m_terrain->GetColor(p, height, norm);
}
static int s_vtxGenCount;
static RefCountedPtr<GeoPatchContext> s_patchContext;
void SetUpMaterials();
ScopedPtr<Graphics::Material> m_surfaceMaterial;
ScopedPtr<Graphics::Material> m_atmosphereMaterial;
//special parameters for shaders
SystemBody::AtmosphereParameters m_atmosphereParameters;
};
#endif /* _GEOSPHERE_H */
|
60a8a759dad05cf5ec9125f8f902a972a395fd75
|
0b9944552a82b3742d36e336d6752418e041ff9d
|
/ZhuoRuiNTPC/network_common.cpp
|
b308a367e60ca773892138870922911927e1793a
|
[] |
no_license
|
kingtub/Qt_Projects
|
33a4efadfb056428c1665be4ac60340c756c5f86
|
1a317c8a39fa45d582f619def23abf3284a87872
|
refs/heads/main
| 2023-06-20T03:51:39.023675
| 2021-07-20T04:45:28
| 2021-07-20T04:45:28
| 331,601,981
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,176
|
cpp
|
network_common.cpp
|
#include "network_common.h"
NetworkCommon::NetworkCommon() {
}
NetworkCommon::~NetworkCommon() {
reqs.clear();
}
NetworkCommon* NetworkCommon::instance = Q_NULLPTR;
mutex NetworkCommon::mut;
NetworkCommon* NetworkCommon::getInstance()
{
if(instance == Q_NULLPTR) {
lock_guard<mutex> lm(mut);
if(instance == Q_NULLPTR) {
instance = new NetworkCommon;
}
}
return instance;
}
void NetworkCommon::destroyInstance()
{
if(instance != Q_NULLPTR) {
delete instance;
instance = Q_NULLPTR;
}
}
void NetworkCommon::postReq(const QString &url, const QJsonObject ¶ms, const function<void(const QString &, int, QJsonDocument &, const QString &)> &callback)
{
QString domain_url = DOMAIN_URL;
QNetworkRequest request;
// 发送https请求前准备工作。若是https,需要做一些配置。
if(domain_url.startsWith("https")) {
QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
conf.setProtocol(QSsl::TlsV1SslV3);
request.setSslConfiguration(conf);
}
QString url_final = domain_url + url;
request.setUrl(QUrl(url_final));
QMap<QString, QString> headersMap = generate_common_headers();
QMapIterator<QString, QString> i(headersMap);
while(i.hasNext()) {
i.next();
request.setRawHeader(i.key().toUtf8(), i.value().toUtf8());
}
QJsonDocument jdoc(params);
QString str = QString(jdoc.toJson());//QJsonDocument转QString
QByteArray content = str.toUtf8();
networkAccessManager.post(request, content);
connect(&networkAccessManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(onRequestFinished(QNetworkReply*)));
/*
reply = networkAccessManager.post(request, content);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(slotSslErrors(QList<QSslError>)));
connect(reply, SIGNAL(finished()), this, SLOT(onRequestFinished()));
*/
reqs.insert(url_final, callback);
}
void NetworkCommon::onRequestFinished(QNetworkReply* reply)
{
QVariant data = reply->readAll();//读取全部数据
QJsonParseError jsonError;
QJsonDocument document = QJsonDocument::fromJson(data.toByteArray(), &jsonError);
QString key = reply->url().toString();
if(reqs.contains(key)) {
bool good = !document.isNull() && (jsonError.error == QJsonParseError::NoError);
QString errStr = good?"":reply->errorString();
auto func = reqs.value(key);
func(key.mid(DOMAIN_URL.length()), good?0:1, document, errStr);
reqs.remove(key);
} else {
//qDebug()<<"Not contains key";
}
reply->deleteLater();
reply = Q_NULLPTR;
/*if (!document.isNull() && (jsonError.error == QJsonParseError::NoError)) {
qDebug()<<"JSON解析正常";
QJsonObject object = document.object();
QString code = object.value("code").toString();
QString msg = object.value("msg").toString();
qDebug()<<"code:"<<code;
qDebug()<<"msg:"<<msg;
if(object.contains("data")) {
QString data = object.value("data").toString();
qDebug()<<"data:"<<data;
}
} else {
if(document.isNull() == true) {
qDebug()<<"document.isNull:" + reply->errorString();
} else if(jsonError.error != QJsonParseError::NoError){
qDebug()<<"jsonError.error:" + reply->errorString();
}
}*/
}
// 域名
const QString NetworkCommon::DOMAIN_URL = "http://192.168.1.241";
// "https://ngpre.zr66.com";
// 发送短信
const char* const NetworkCommon::URL_SEND_SMS_CODE = "/as_notification/api/sms/v1/send_code";
const char* const NetworkCommon::URL_USER_LOGIN_CODE = "/as_user/api/user_account/v1/user_login_code";
const char* const NetworkCommon::URL_SET_LOGIN_PWD = "/as_user/api/user_account/v1/set_login_password";
const char* const NetworkCommon::URL_USER_LOGIN_PWD = "/as_user/api/user_account/v1/user_login_pwd";
|
4dfd505f5d1276f94ff1b47c59d72c21cd1d18a9
|
de8ff7af5bf2d2945cc82c38330623fd19ee409e
|
/SRC/NVCLASS/include/iniuser.hpp
|
afa7aa27735aa2b5b4d2d09ad04b21ee653b9040
|
[] |
no_license
|
OS2World/DEV-SAMPLES-NET-TCPIP_Programming
|
eef5876ac0ee158633e3c5b3d9196897a9314013
|
f9c3b45662e57b51774e6aa7bfc6c49c3df5c591
|
refs/heads/master
| 2016-09-06T15:12:25.087804
| 2014-10-31T14:37:55
| 2014-10-31T14:37:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 594
|
hpp
|
iniuser.hpp
|
//------------
// C_INI_USER \
//---------------------------------------------------------------------------
// All information contained in this file is Copyright (c) 1994-1995 by
// NeoLogic Inc. All Rights Reserved
//
// This source code shall not be implemented, duplicated or used as the basis
// for any product without prior written consent by NeoLogic Inc.
//
class C_INI_USER : public C_INI
{
public:
_Export C_INI_USER( char *szAppName );
void _Export Open( void );
#ifdef __BORLANDC__
virtual void _Export Close( void ) {};
#else
virtual void Close( void ) {};
#endif
};
|
57278fb88231162abdc7d4877264a40e09a3742d
|
260e5dec446d12a7dd3f32e331c1fde8157e5cea
|
/Indi/SDK/Indi_SelectedNotificationWidget_BP_parameters.hpp
|
51f3c3f3b79ea3bc4d0303db075dfb87e2dc3ca6
|
[] |
no_license
|
jfmherokiller/TheOuterWorldsSdkDump
|
6e140fde4fcd1cade94ce0d7ea69f8a3f769e1c0
|
18a8c6b1f5d87bb1ad4334be4a9f22c52897f640
|
refs/heads/main
| 2023-08-30T09:27:17.723265
| 2021-09-17T00:24:52
| 2021-09-17T00:24:52
| 407,437,218
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,817
|
hpp
|
Indi_SelectedNotificationWidget_BP_parameters.hpp
|
#pragma once
// TheOuterWorlds SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "Indi_SelectedNotificationWidget_BP_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.Construct
struct USelectedNotificationWidget_BP_C_Construct_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.PlayNotificationAnimation
struct USelectedNotificationWidget_BP_C_PlayNotificationAnimation_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.PlayFadeOutAnimation
struct USelectedNotificationWidget_BP_C_PlayFadeOutAnimation_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.StopFadeOutAnimation
struct USelectedNotificationWidget_BP_C_StopFadeOutAnimation_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.OnFadeRightAnimationFinished
struct USelectedNotificationWidget_BP_C_OnFadeRightAnimationFinished_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.OnFadeOutAnimationFinished
struct USelectedNotificationWidget_BP_C_OnFadeOutAnimationFinished_Params
{
};
// Function SelectedNotificationWidget_BP.SelectedNotificationWidget_BP_C.ExecuteUbergraph_SelectedNotificationWidget_BP
struct USelectedNotificationWidget_BP_C_ExecuteUbergraph_SelectedNotificationWidget_BP_Params
{
int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
b149402509da8b2a85dc47122a2c9d1b0860b17f
|
1106985164494c361c6ef017189cd6f53f6009d4
|
/zzz_Unsorted/CheckifChildSumProperty.cpp
|
99110d4bee1669e9f03b197cf07de60ce1e65e86
|
[] |
no_license
|
SlickHackz/famous-problems-cpp-solutions
|
b7f0066a03404a20c1a4b483acffda021595c530
|
f954b4a8ca856cc749e232bd9d8894a672637ae2
|
refs/heads/master
| 2022-08-25T23:14:11.975270
| 2022-07-17T22:07:03
| 2022-07-17T22:07:03
| 71,126,427
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,842
|
cpp
|
CheckifChildSumProperty.cpp
|
#include<iostream>
#include<queue>
using namespace std;
struct node
{
struct node *left;
int data;
struct node *right;
};
struct node *newNode(int a)
{
struct node *temp = new struct node();
temp->left = NULL;
temp->data = a;
temp->right = NULL;
return temp;
}
void createTree(struct node **root,int x)
{
if(*root!=NULL)
{
if(x < (*root)->data)
createTree(&(*root)->left,x);
else
createTree(&(*root)->right,x);
}
else
*root = newNode(x);
}
void _checkChildSum(struct node *root,bool *prop)
{
if(root==NULL)
return;
if(root->left==NULL && root->right!=NULL)
{
if(root->data != root->right->data )
*prop = false;
}
else if(root->right==NULL && root->left!=NULL)
{
if(root->data != root->left->data )
*prop = false;
}
else if(root->right!=NULL && root->left!=NULL)
{
if(root->data != root->left->data+root->right->data)
*prop = false;
}
_checkChildSum(root->left,prop);
_checkChildSum(root->right,prop);
}
bool checkChildSum(struct node *root)
{
if(root==NULL || (root->left==NULL && root->right==NULL)) // The leaf nodes,NULL nodes always satisfy CHILD SUM
return true;
int l=0 ; int r=0;
if(root->left!=NULL)
l = root->left->data;
if(root->right!=NULL)
r = root->right->data;
// Prefer checking using if conditions rather than separtely checking like if(l+r==root->data) { checkCHildSUm(left); checkchildSUm(right);}
if(l+r == root->data && checkChildSum(root->left) && checkChildSum(root->right))
return true;
else
return false;
}
int main()
{
struct node *Tree = NULL;
Tree = newNode(10);
Tree->left = newNode(8);
Tree->left->left = newNode(5);
Tree->left->right = newNode(3);
Tree->right = newNode(2);
Tree->right->left = newNode(1);
cout<<"\nFor every subtree, parent = left + right children: "<<checkChildSum(Tree);
cin.get();
return 0;
}
|
8dd6456a62c8d3eeaa4b8bae8be64b57add610e9
|
2424a498882bc520be88503b28899cf8733ace5e
|
/DIJKSTRA O((V+E) log V).cpp
|
de8d75342cf4b483bf0c792defb875bbf9854046
|
[] |
no_license
|
dhirajfx3/Algorithms
|
a8df457e10602eaa2a6a4300d7c6c691b6df2476
|
353a4fc9ece4444c99a7e6c4860c466e11bf3d55
|
refs/heads/master
| 2021-01-13T03:13:17.479824
| 2020-10-06T14:11:51
| 2020-10-06T14:11:51
| 77,627,559
| 3
| 5
| null | 2020-10-06T14:11:52
| 2016-12-29T17:10:10
|
C++
|
UTF-8
|
C++
| false
| false
| 1,573
|
cpp
|
DIJKSTRA O((V+E) log V).cpp
|
// Time complexity: O((V+E) log V )
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
vector<vector<int> > adj, W;
vector<int> sd;
int SIZE;
struct cmp
{
bool operator()(const int &p, const int &q)const
{
if (sd[p] < sd[q])
return true;
else
if (sd[p] == sd[q])
return p < q;
return false;
}
};
class DIJKSTRA
{
public:
bool add(int u, int v, int w = 1)
{
adj[u].push_back(v), W[u].push_back(w);
adj[v].push_back(u), W[v].push_back(w);
return true;
}
void run(int Source) // Zero indexed
{
sd[Source] = 0;
set<int, cmp> S;
S.insert(Source);
while (!S.empty())
{
int P = *S.begin();
S.erase(S.begin());
for (int i = 0; i<adj[P].size(); i++)
{
if (sd[adj[P][i]]>sd[P] + W[P][i])
{
S.erase(adj[P][i]);
sd[adj[P][i]] = sd[P] + W[P][i];
S.insert(adj[P][i]);
}
}
}
return;
}
void printsd(int y)
{
run(y);
for (int i = 0; i<sd.size(); i++)
if (i != y)
cout << ((sd[i] == 1e9) ? -1 : sd[i]) << " ";
cout << endl;
return;
}
};
void solve()
{
int N, M, u, v, w;
scanf("%d%d", &N, &M);
DIJKSTRA B;
SIZE = N;
adj = vector<vector<int > >(N);
W = vector<vector<int> >(N);
sd = vector<int>(N, 1e9);
for (int i = 0; i<M; i++)
{
scanf("%d%d%d", &u, &v, &w);
B.add(u - 1, v - 1, w);
}
scanf("%d", &N);
B.printsd(N - 1);
return;
}
int main()
{
int T = 1;
scanf("%d", &T);
while (T--)
{
solve();
}
return 0;
}
|
8b9e13ba4f3409fcee8da12ed7ead5fccfbe3142
|
f3bcdd00d5c826db811ad18fb6c73a87d656a881
|
/rpo.cpp
|
3cd0a78fb11969ecca633c25c751b4e3ef374d08
|
[] |
no_license
|
xorbit3024/C4
|
d703cf587448f0f499245e363cc6e5bc4807b29d
|
ce75d5f17727e19fc7d80eb3f6320a6addb0de9c
|
refs/heads/master
| 2022-04-08T16:32:50.983407
| 2020-03-17T19:32:13
| 2020-03-17T19:32:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 824
|
cpp
|
rpo.cpp
|
#include "rpo.h"
Board::z RpO::TakeTurn(const Board& b) noexcept
{
if (actions.count(b) == 0)
{
NewAction(b);
}
return actions[b].Select() + 1;
}
void RpO::Learn(const vector<pair<Board, Board::z>>& moveset, ASRLC4::Result result)
{
if (result == ASRLC4::Result::loss)
{
for (vector<pair<Board, Board::z>>::const_iterator moveIterator = moveset.cbegin();
moveIterator < moveset.cend();
moveIterator++)
{
Repress(moveIterator->first, moveIterator->second);
}
}
}
void RpO::NewAction(const Board& b) noexcept
{
PDist dist;
for (Board::z column = 0; column < 7; column++)
{
if (!b.IsFullColumn(column + 1))
{
dist[column] = 1;
}
}
actions[b] = dist;
}
void RpO::Repress(const Board& b, Board::z column)
{
actions[b][column - 1]--;
if (!actions[b].Sum())
{
actions.erase(b);
}
}
|
26d37ea3de3a8a69045f0f272512583b0b5cc0af
|
8f8f87c0ffacf8509ee5f32f74447f64887ef501
|
/problems/leetcode/16-3-sum-closest/main.cpp
|
314d587cfdd0872c3446f274290c38f8b7db6e5c
|
[] |
no_license
|
godcrampy/competitive
|
c32eb1baf355fa9697f4ea69bea1e8e2d346e14c
|
e42f3000296c7b40e6a4c368dd17241ebb678d18
|
refs/heads/master
| 2023-03-28T17:05:15.776334
| 2021-04-03T13:40:15
| 2021-04-03T13:40:15
| 206,922,544
| 6
| 3
| null | 2020-10-01T13:22:40
| 2019-09-07T05:51:30
|
C++
|
UTF-8
|
C++
| false
| false
| 968
|
cpp
|
main.cpp
|
#include <algorithm>
#include <vector>
using namespace std;
int threeSumClosest(vector<int>& nums, int target) {
if (nums.size() < 3) {
return 0;
}
int closest = nums[0] + nums[1] + nums[2];
sort(nums.begin(), nums.end());
for (int i = 0; i < nums.size() - 2; ++i) {
if (i == 0 || nums[i] != nums[i - 1]) {
int a = nums[i];
int l = i + 1;
int r = nums.size() - 1;
while (l < r) {
if (nums[l] + nums[r] + a < target) {
// small
if (abs(nums[l] + nums[r] + a - target) < abs(closest - target)) {
closest = nums[l] + nums[r] + a;
}
++l;
} else if (nums[l] + nums[r] + a > target) {
// big
if (abs(nums[l] + nums[r] + a - target) < abs(closest - target)) {
closest = nums[l] + nums[r] + a;
}
--r;
} else {
// found
return target;
}
}
}
}
return closest;
}
|
c78ffe9a0babc212b7b7574b01f7378f2845f484
|
645b5211c50b1a07a5d576b96624b22055802dc4
|
/sample_data/cavity/0.4/phi
|
9c8c8975dd37038daeff4c61d12573f10964f33c
|
[
"Apache-2.0"
] |
permissive
|
dealenx/hpccloud-kemsu
|
7c3a33e5ce01560d6fc7abcb9524e4526b9f4848
|
42fc44b06385c6eb25a979477dcea53fe66cfbfa
|
refs/heads/master
| 2023-02-05T21:13:07.328928
| 2021-06-25T04:56:39
| 2021-06-25T04:56:39
| 252,550,259
| 3
| 0
|
Apache-2.0
| 2023-01-24T23:21:39
| 2020-04-02T19:41:31
|
Python
|
UTF-8
|
C++
| false
| false
| 10,626
|
phi
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "0.4";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 3 -1 0 0 0 0];
internalField nonuniform List<scalar>
760
(
1.42358e-08
-1.42719e-08
-2.21729e-08
3.64087e-08
-1.14266e-07
9.20932e-08
-2.45514e-07
1.31248e-07
-3.96131e-07
1.50618e-07
-5.47408e-07
1.51277e-07
-6.8324e-07
1.35832e-07
-7.90717e-07
1.07477e-07
-8.60265e-07
6.95478e-08
-8.85701e-07
2.54356e-08
-8.64378e-07
-2.13218e-08
-7.97444e-07
-6.6934e-08
-6.90136e-07
-1.07309e-07
-5.52016e-07
-1.3812e-07
-3.96977e-07
-1.55039e-07
-2.42769e-07
-1.54209e-07
-1.09727e-07
-1.33042e-07
-1.83743e-08
-9.13524e-08
1.56825e-08
-3.40565e-08
1.56826e-08
-3.41901e-08
1.99183e-08
-1.80379e-07
1.82598e-07
-4.34004e-07
3.45718e-07
-7.64491e-07
4.61734e-07
-1.13232e-06
5.18451e-07
-1.49741e-06
5.16365e-07
-1.82355e-06
4.61975e-07
-2.08079e-06
3.64715e-07
-2.24656e-06
2.35313e-07
-2.30633e-06
8.52109e-08
-2.25419e-06
-7.34672e-08
-2.09331e-06
-2.27808e-07
-1.83649e-06
-3.64135e-07
-1.50622e-06
-4.6839e-07
-1.1342e-06
-5.27058e-07
-7.5958e-07
-5.28828e-07
-4.25415e-07
-4.67207e-07
-1.72697e-07
-3.44071e-07
-3.0764e-08
-1.75989e-07
-1.5081e-08
-9.22706e-08
1.12189e-07
-3.57043e-07
4.4737e-07
-7.64631e-07
7.53305e-07
-1.26861e-06
9.65712e-07
-1.81488e-06
1.06472e-06
-2.34929e-06
1.05077e-06
-2.82273e-06
9.3542e-07
-3.19429e-06
7.36269e-07
-3.43298e-06
4.7401e-07
-3.5189e-06
1.71127e-07
-3.44396e-06
-1.48413e-07
-3.21262e-06
-4.59148e-07
-2.84242e-06
-7.34328e-07
-2.36406e-06
-9.46749e-07
-1.82051e-06
-1.07061e-06
-1.26461e-06
-1.08472e-06
-7.54597e-07
-9.77226e-07
-3.47017e-07
-7.51651e-07
-8.7379e-08
-4.35627e-07
-1.0246e-07
-1.45244e-07
2.57432e-07
-5.25525e-07
8.27652e-07
-1.08174e-06
1.30952e-06
-1.74768e-06
1.63165e-06
-2.45457e-06
1.77161e-06
-3.13668e-06
1.73288e-06
-3.73565e-06
1.53439e-06
-4.20331e-06
1.20393e-06
-4.50336e-06
7.74054e-07
-4.61238e-06
2.80151e-07
-4.52071e-06
-2.40086e-07
-4.23316e-06
-7.46694e-07
-3.76975e-06
-1.19774e-06
-3.16597e-06
-1.55054e-06
-2.47214e-06
-1.76444e-06
-1.75125e-06
-1.8056e-06
-1.07463e-06
-1.65385e-06
-5.15205e-07
-1.31107e-06
-1.3935e-07
-8.11483e-07
-2.41809e-07
-1.93636e-07
4.51068e-07
-6.85072e-07
1.31909e-06
-1.38575e-06
2.0102e-06
-2.20745e-06
2.45334e-06
-3.06575e-06
2.62991e-06
-3.88413e-06
2.55126e-06
-4.59691e-06
2.24718e-06
-5.15104e-06
1.75806e-06
-5.50694e-06
1.12995e-06
-5.63903e-06
4.12245e-07
-5.53627e-06
-3.42854e-07
-5.20287e-06
-1.0801e-06
-4.65933e-06
-1.74127e-06
-3.94335e-06
-2.26652e-06
-3.11003e-06
-2.59777e-06
-2.23074e-06
-2.68489e-06
-1.38979e-06
-2.4948e-06
-6.78579e-07
-2.02229e-06
-1.87797e-07
-1.30226e-06
-4.29607e-07
-2.39968e-07
6.91035e-07
-8.40433e-07
1.91955e-06
-1.68345e-06
2.85322e-06
-2.6573e-06
3.42719e-06
-3.66116e-06
3.63377e-06
-4.60817e-06
3.49827e-06
-5.42682e-06
3.06583e-06
-6.06108e-06
2.39233e-06
-6.46991e-06
1.53878e-06
-6.62663e-06
5.68963e-07
-6.5189e-06
-4.5058e-07
-6.14937e-06
-1.44963e-06
-5.53707e-06
-2.35356e-06
-4.7194e-06
-3.08419e-06
-3.75386e-06
-3.56331e-06
-2.71878e-06
-3.71997e-06
-1.71174e-06
-3.50184e-06
-8.44765e-07
-2.88926e-06
-2.36214e-07
-1.91081e-06
-6.65821e-07
-2.86779e-07
9.77813e-07
-9.97188e-07
2.62996e-06
-1.98227e-06
3.8383e-06
-3.10523e-06
4.55015e-06
-4.24833e-06
4.77687e-06
-5.31527e-06
4.56521e-06
-6.23063e-06
3.98119e-06
-6.93774e-06
3.09944e-06
-7.39609e-06
1.99713e-06
-7.57925e-06
7.52125e-07
-7.4738e-06
-5.56029e-07
-7.07975e-06
-1.84368e-06
-6.4125e-06
-3.02082e-06
-5.50615e-06
-3.99054e-06
-4.41755e-06
-4.65191e-06
-3.22975e-06
-4.90776e-06
-2.05321e-06
-4.67838e-06
-1.02268e-06
-3.91979e-06
-2.88328e-07
-2.64516e-06
-9.5415e-07
-3.36374e-07
1.31419e-06
-1.1605e-06
3.45408e-06
-2.28825e-06
4.96605e-06
-3.55533e-06
5.81723e-06
-4.82704e-06
6.04858e-06
-5.99956e-06
5.73773e-06
-6.99658e-06
4.97821e-06
-7.76411e-06
3.86697e-06
-8.26511e-06
2.49813e-06
-8.47527e-06
9.62283e-07
-8.38064e-06
-6.5066e-07
-7.97758e-06
-2.24674e-06
-7.27526e-06
-3.72314e-06
-6.3006e-06
-4.9652e-06
-5.10525e-06
-5.84726e-06
-3.773e-06
-6.24001e-06
-2.42522e-06
-6.02616e-06
-1.22093e-06
-5.12408e-06
-3.47773e-07
-3.51832e-06
-1.30192e-06
-3.91014e-07
1.7052e-06
-1.33504e-06
4.39811e-06
-2.60525e-06
6.23626e-06
-4.00632e-06
7.2183e-06
-5.38727e-06
7.42953e-06
-6.64027e-06
6.99072e-06
-7.69299e-06
6.03094e-06
-8.49906e-06
4.67304e-06
-9.02904e-06
3.02811e-06
-9.26357e-06
1.19682e-06
-9.18933e-06
-7.24902e-07
-8.79819e-06
-2.63788e-06
-8.09009e-06
-4.43125e-06
-7.07974e-06
-5.97555e-06
-5.80699e-06
-7.12e-06
-4.34962e-06
-7.69739e-06
-2.83524e-06
-7.54055e-06
-1.44734e-06
-6.51198e-06
-4.1819e-07
-4.54747e-06
-1.72011e-06
-4.53529e-07
2.15873e-06
-1.52588e-06
5.47046e-06
-2.93521e-06
7.64559e-06
-4.45055e-06
8.73364e-06
-5.90682e-06
8.88581e-06
-7.19835e-06
8.28225e-06
-8.26422e-06
7.09681e-06
-9.07264e-06
5.48146e-06
-9.60747e-06
3.56294e-06
-9.85822e-06
1.44757e-06
-9.81409e-06
-7.69034e-07
-9.46209e-06
-2.98988e-06
-8.78986e-06
-5.10347e-06
-7.79378e-06
-6.97164e-06
-6.49297e-06
-8.42081e-06
-4.94866e-06
-9.2417e-06
-3.28565e-06
-9.20355e-06
-1.70901e-06
-8.08862e-06
-5.03714e-07
-5.75277e-06
-2.22383e-06
-5.28434e-07
2.68717e-06
-1.73991e-06
6.68194e-06
-3.27837e-06
9.18404e-06
-4.8721e-06
1.03274e-05
-6.34752e-06
1.03612e-05
-7.61133e-06
9.54606e-06
-8.62484e-06
8.11033e-06
-9.38016e-06
6.23678e-06
-9.88147e-06
4.06424e-06
-1.0132e-05
1.69814e-06
-1.01263e-05
-7.74737e-07
-9.84695e-06
-3.26926e-06
-9.26668e-06
-5.68374e-06
-8.3571e-06
-7.88122e-06
-7.1055e-06
-9.6724e-06
-5.54149e-06
-1.08057e-05
-3.77137e-06
-1.09737e-05
-2.01261e-06
-9.84738e-06
-6.09857e-07
-7.15551e-06
-2.83368e-06
-6.23781e-07
3.31095e-06
-1.9877e-06
8.04586e-06
-3.63238e-06
1.08287e-05
-5.24245e-06
1.19374e-05
-6.64807e-06
1.17668e-05
-7.78492e-06
1.06829e-05
-8.6514e-06
8.9768e-06
-9.27465e-06
6.86002e-06
-9.68686e-06
4.47645e-06
-9.91015e-06
1.92143e-06
-9.94761e-06
-7.37272e-07
-9.77905e-06
-3.43782e-06
-9.36146e-06
-6.10133e-06
-8.63631e-06
-8.60636e-06
-7.54719e-06
-1.07615e-05
-6.07244e-06
-1.22805e-05
-4.27505e-06
-1.2771e-05
-2.36419e-06
-1.17582e-05
-7.44978e-07
-8.77473e-06
-3.57866e-06
-7.54164e-07
4.06511e-06
-2.28471e-06
9.57641e-06
-3.98754e-06
1.25316e-05
-5.50963e-06
1.34595e-05
-6.71006e-06
1.29673e-05
-7.5789e-06
1.15517e-05
-8.17029e-06
9.56819e-06
-8.55778e-06
7.24752e-06
-8.80784e-06
4.72651e-06
-8.96515e-06
2.07875e-06
-9.04451e-06
-6.57915e-07
-9.02598e-06
-3.45636e-06
-8.85296e-06
-6.27435e-06
-8.43535e-06
-9.02397e-06
-7.6636e-06
-1.15333e-05
-6.44283e-06
-1.35012e-05
-4.75709e-06
-1.44568e-05
-2.76735e-06
-1.3748e-05
-9.22605e-07
-1.06195e-05
-4.50127e-06
-9.45102e-07
5.01021e-06
-2.64879e-06
1.12801e-05
-4.31151e-06
1.41943e-05
-5.57376e-06
1.47218e-05
-6.37099e-06
1.37645e-05
-6.7834e-06
1.19642e-05
-6.94047e-06
9.72526e-06
-6.96959e-06
7.27663e-06
-6.97256e-06
4.72948e-06
-7.01625e-06
2.12244e-06
-7.12837e-06
-5.45793e-07
-7.2936e-06
-3.29113e-06
-7.4486e-06
-6.11934e-06
-7.47803e-06
-8.99454e-06
-7.2183e-06
-1.1793e-05
-6.48334e-06
-1.42362e-05
-5.13413e-06
-1.5806e-05
-3.21544e-06
-1.56667e-05
-1.1643e-06
-1.26706e-05
-5.66556e-06
-1.23655e-06
6.24677e-06
-3.08322e-06
1.31268e-05
-4.50804e-06
1.56191e-05
-5.23471e-06
1.54485e-05
-5.35523e-06
1.3885e-05
-5.08164e-06
1.16906e-05
-4.63054e-06
9.27416e-06
-4.17878e-06
6.82487e-06
-3.85379e-06
4.40449e-06
-3.7364e-06
2.00506e-06
-3.8645e-06
-4.17694e-07
-4.23205e-06
-2.92358e-06
-4.78158e-06
-5.56981e-06
-5.3907e-06
-8.38542e-06
-5.85831e-06
-1.13254e-05
-5.90661e-06
-1.41879e-05
-5.23299e-06
-1.64796e-05
-3.66608e-06
-1.72336e-05
-1.49913e-06
-1.48376e-05
-7.1647e-06
-1.67129e-06
7.91806e-06
-3.51211e-06
1.49676e-05
-4.31503e-06
1.6422e-05
-4.0886e-06
1.5222e-05
-3.1926e-06
1.2989e-05
-1.99814e-06
1.04961e-05
-7.94417e-07
8.07044e-06
2.20164e-07
5.81029e-06
9.1913e-07
3.70552e-06
1.22656e-06
1.69763e-06
1.10305e-06
-2.94192e-07
5.42071e-07
-2.36259e-06
-4.21923e-07
-4.60582e-06
-1.69158e-06
-7.11576e-06
-3.07146e-06
-9.94551e-06
-4.2299e-06
-1.30295e-05
-4.69461e-06
-1.60149e-05
-3.96518e-06
-1.7963e-05
-1.94184e-06
-1.68609e-05
-9.10653e-06
-2.22282e-06
1.01409e-05
-3.58621e-06
1.6331e-05
-3.07644e-06
1.59122e-05
-1.34285e-06
1.34884e-05
8.98084e-07
1.07481e-05
3.15603e-06
8.23818e-06
5.13921e-06
6.08726e-06
6.68982e-06
4.25968e-06
7.727e-06
2.66834e-06
8.20777e-06
1.21686e-06
8.10517e-06
-1.91594e-07
7.40038e-06
-1.65781e-06
6.08829e-06
-3.29373e-06
4.20074e-06
-5.2282e-06
1.8559e-06
-7.60067e-06
-6.5966e-07
-1.05139e-05
-2.78934e-06
-1.38852e-05
-3.65618e-06
-1.70962e-05
-2.40209e-06
-1.8115e-05
-1.15086e-05
-2.54599e-06
1.26869e-05
-2.17785e-06
1.59628e-05
7.19297e-07
1.30151e-05
4.47087e-06
9.73686e-06
8.13473e-06
7.08422e-06
1.1303e-05
5.06989e-06
1.38305e-05
3.55978e-06
1.56895e-05
2.40071e-06
1.6893e-05
1.46477e-06
1.74563e-05
6.53626e-07
1.73778e-05
-1.1314e-07
1.66321e-05
-9.12043e-07
1.51689e-05
-1.83054e-06
1.29253e-05
-2.98467e-06
9.86372e-06
-4.53904e-06
6.0641e-06
-6.71429e-06
1.91507e-06
-9.73619e-06
-1.55179e-06
-1.36293e-05
-2.42765e-06
-1.72391e-05
-1.39363e-05
-8.39065e-07
1.35259e-05
4.07007e-06
1.10537e-05
1.02969e-05
6.78824e-06
1.57944e-05
4.23944e-06
2.01593e-05
2.7193e-06
2.34595e-05
1.76963e-06
2.58623e-05
1.15704e-06
2.75229e-05
7.40042e-07
2.85554e-05
4.32306e-07
2.90278e-05
1.81215e-07
2.89636e-05
-4.89258e-08
2.83402e-05
-2.887e-07
2.70834e-05
-5.73737e-07
2.50567e-05
-9.57926e-07
2.20531e-05
-1.5354e-06
1.78161e-05
-2.47733e-06
1.21714e-05
-4.09148e-06
5.46563e-06
-6.92358e-06
-1.88451e-07
-1.15851e-05
-1.41247e-05
1.35259e-05
2.45796e-05
3.13679e-05
3.56073e-05
3.83266e-05
4.00962e-05
4.12533e-05
4.19933e-05
4.24256e-05
4.26068e-05
4.25579e-05
4.22692e-05
4.16955e-05
4.07376e-05
3.92022e-05
3.67248e-05
3.26334e-05
2.57098e-05
1.41247e-05
)
;
boundaryField
{
movingWall
{
type calculated;
value uniform 0;
}
fixedWalls
{
type calculated;
value uniform 0;
}
frontAndBack
{
type empty;
value nonuniform 0();
}
}
// ************************************************************************* //
|
|
6cc7760785574fe0b33e19ae9914477caed662d9
|
843c051bffb7631307a402f263ecbee4a4a91fc1
|
/chap3/p5.cc
|
a14b9a58d7cfdc94895c8bcb805d6e438d5397cb
|
[] |
no_license
|
baolidakai/cppLab
|
869e3f4d253718e3beec8cd2dfef712ce0dc5293
|
6786bf0d0a8d2c073957b2e07e6a8f23329b943c
|
refs/heads/master
| 2021-01-10T14:04:15.808945
| 2016-04-12T07:08:03
| 2016-04-12T07:08:03
| 55,671,392
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 427
|
cc
|
p5.cc
|
// Implementation of
// 5. Using a stringstream, write a function that converts an int into a string.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
string intToString(int value) {
stringstream ss;
ss << value;
return ss.str();
}
int main() {
int value;
cout << "Enter an integer: ";
cin >> value;
string res = intToString(value);
cout << "The integer is " << res << endl;
return 0;
}
|
d5df4c157dc982653671b24b4aa3320c9c52a80b
|
1a72c4232cf836961c6ead34dcc5c8b05c23fa2c
|
/OdeloBattleSystem/OdeloBattleSystem/OthelloState.cpp
|
e166bb1b69a981ede2c845c7da07d023b23f9029
|
[] |
no_license
|
GomTangOng/Research-OthelloBattleSystem
|
07edc4dfdfd91b7f4213aa176eccddaff0273520
|
730833494ae5ed2c7351ece25c781bfc12fc8ce0
|
refs/heads/master
| 2021-08-28T06:48:52.180612
| 2017-12-11T13:20:34
| 2017-12-11T13:20:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,424
|
cpp
|
OthelloState.cpp
|
#include "OthelloState.h"
#include "OdeloBattleSystem.h"
#include "Action.h"
#define MAX_ACTIONS 60
OthelloState::OthelloState(const OthelloState & state)
{
memcpy(m_othello, state.m_othello, sizeof(COdeloBattleSytem));
m_nStoneType = state.m_nStoneType;
}
OthelloState::~OthelloState()
{
}
bool OthelloState::is_terminal() const
{
return !m_othello->IsPutStone(m_nStoneType);
}
int OthelloState::agent_id() const // ???
{
return 0;
}
void OthelloState::apply_action(const Action & action)
{
m_othello->PutStone(action.m_nPosX, action.m_nPosY, m_nStoneType);
m_nStoneType = (m_nStoneType == BLACK) ? WHITE : BLACK;
}
void OthelloState::get_actions(std::vector<Action>& actions) const
{
actions.resize(MAX_ACTIONS);
m_othello->GetPutPosition(actions, m_nStoneType);
}
bool OthelloState::get_random_action(Action & action)
{
std::vector<Action> actions;
if (m_othello->IsPutStone(m_nStoneType))
{
//m_othello->PutStone(action.m_nPosX, action.m_nPosY, m_nStoneType);
//m_nStoneType = (m_nStoneType == BLACK) ? WHITE : BLACK;
get_actions(actions);
action = actions[rand() % actions.size()];
return true;
}
return false;
}
const std::vector<float> OthelloState::evaluate() const // to do coding
{
std::vector<float> rewards(2);
if (m_othello->IsPutStone(m_nStoneType))
{
}
return 0; // game still going
}
std::string OthelloState::to_string() const
{
return std::string();
}
|
5477d82bf496d3f40e7d86812c4ef1d0c244e6d3
|
4b50e76c8c2d1184542b02ae166cac639878f92c
|
/PouEngine/include/PouEngine/system/XMLLoader.h
|
69bd46092ca730c3ab147d69de8f924e95a48d76
|
[] |
no_license
|
Hengle/PouEngine
|
3b5b6b2f4ef65a2be542ac5ab6eb5893c3a69edc
|
699b9a21f422d0ac4e2348b1772c3d76ee53e5b6
|
refs/heads/master
| 2022-12-09T14:49:20.709382
| 2020-09-11T15:33:05
| 2020-09-11T15:33:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 580
|
h
|
XMLLoader.h
|
#ifndef XMLLOADER_H
#define XMLLOADER_H
#include "tinyxml/tinyxml.h"
#include "PouEngine/Types.h"
namespace pou
{
namespace XMLLoader
{
bool loadFloat(float &v, TiXmlElement *element, const std::string &attName);
bool loadInt(int &v, TiXmlElement *element, const std::string &attName);
bool loadBool(bool &v, TiXmlElement *element, const std::string &attName);
bool loadColor(Color &color, TiXmlElement *element);
}
/*class XMLLoader
{
public:
XMLLoader();
virtual ~XMLLoader();
protected:
private:
};*/
}
#endif // XMLLOADER_H
|
64c630f92d34aeaab4ab74db557c6fe63d508807
|
5bca6ce6a47016cc8a738a9e06ce7ba069e5617c
|
/slave_md5cracker/gpuCracker.h
|
b1abbe6b1208a640eefc02f506e734d57a6a76e3
|
[] |
no_license
|
zhanying26252625/md5cracker
|
d26a9d946f05af3718dd821e79664bbcd33f9d51
|
90ad0376f4b2959b4bc6b85e242f8d7bdd5e0007
|
refs/heads/master
| 2020-05-18T13:48:53.166290
| 2013-05-08T16:37:38
| 2013-05-08T16:40:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 484
|
h
|
gpuCracker.h
|
#ifndef _GPU_CRACKER_H
#define _GPU_CRACKER_H
#include <pthread.h>
#include <vector>
using namespace std;
class SlaveMD5Cracker;
class CpuCracker;
class GpuCracker{
private:
enum{NUM_THREADS=4};
SlaveMD5Cracker* slaveCracker;
static void* workThreadFunc(void* arg);
vector<pthread_t> workThreads;
bool isGPUsupported();
friend class CpuCracker;
public:
GpuCracker();
bool init(SlaveMD5Cracker* sc);
bool terminate();
};
#endif
|
5b9db9ca23a93a4bf95cc4295b626f4b747bbc54
|
7ea8e3b5a660c328dbcce7f13a7b10f878a3f46e
|
/src/MacroNode.cpp
|
04977731846a389e85cd084651cc20408c78d0c7
|
[] |
no_license
|
PrincetonUniversity/MemFlow
|
512ca050896eff795858559bd8c21f54b259f8bd
|
3f85f17d78a87f7f5b20ec84d86635902894556c
|
refs/heads/master
| 2021-03-27T15:17:47.271500
| 2019-01-12T18:19:13
| 2019-01-12T18:19:13
| 80,735,247
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,907
|
cpp
|
MacroNode.cpp
|
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include "MacroNode.hpp"
#include "Setting.hpp"
using namespace std;
using namespace DRAMSim;
LoadStoreDblk::LoadStoreDblk(){
read_cb = new Callback<TransactionReceiver, void, unsigned, uint64_t, uint64_t>(&transactionReceiver, &TransactionReceiver::read_complete);
write_cb = new Callback<TransactionReceiver, void, unsigned, uint64_t, uint64_t>(&transactionReceiver, &TransactionReceiver::write_complete);
dram->RegisterCallbacks(read_cb, write_cb, NULL);
}
LoadStoreDblk::~LoadStoreDblk(){
delete read_cb;
delete write_cb;
}
void LoadStoreDblk::genTransactions(DataBlock* dblk, queue<uint64_t>& trans_addr){
//sweep all elements in the dblk
int i_start = dblk->blk_i*dblk->blk_dimi;
int i_end = (dblk->blk_i+1)*dblk->blk_dimi;
int j_start = dblk->blk_j*dblk->blk_dimj;
int j_end = (dblk->blk_j+1)*dblk->blk_dimj;
//map<uint64_t, map<int, int>> addr_bank;
set<uint64_t> addr;
for(int i=i_start; i<i_end; i++){
for(int j=j_start; j<j_end; j++){
//get address for this element
//cout << "i,j: " << i << "," << j << endl;
uint64_t phy_addr = data_arrays[dblk->matrix_name]->genPhysicalAddr(i,j);
//cout << "phy addr: " << phy_addr << endl;
//transaction addr
unsigned throwAwayBits = THROW_AWAY_BITS;
phy_addr >>= throwAwayBits;
phy_addr <<= throwAwayBits;
//cout << "tran addr: " << phy_addr << endl;
if(addr.find(phy_addr) == addr.end()){
addr.insert(phy_addr);
}
//get bank
//int bank = dblk->getElementSPAddr(i,j)[0];
//cout << "bank " << bank << endl;
//if(addr_bank.find(phy_addr) == addr_bank.end()){
// addr_bank[phy_addr][bank] = 1;
//}
//else{
// if(addr_bank[phy_addr].find(bank) == addr_bank[phy_addr].end()){
// addr_bank[phy_addr][bank] = 1;
//}
//else{
//addr_bank[phy_addr][bank]++;
//}
//}
}
}
for(auto &i: addr){
trans_addr.push(i);
}
//for(auto &tran: addr_bank){
// auto max_bank_use = max_element(tran.second.begin(), tran.second.end(), tran.second.value_comp());
// int num_batch = (max_bank_use->second%2==0)?max_bank_use->second/2:max_bank_use->second/2+1;
// for(int i=0; i<num_batch; i++){
// trans_addr.push(tran.first);
// }
//}
}
int LoadStoreDblk::loadDblk(DataBlock* dblk){
//cout << "create transaction receiver" << endl;
queue<uint64_t> trans_addr;
genTransactions(dblk, trans_addr);
//cout << "trans addr" << endl;
//for(auto &i: trans_addr){
//cout << hex << i << endl;
//}
int numCycles = INT_MAX;
bool pendingTrans = false;
Transaction* trans = NULL;
void* data = NULL;
int finish_cycle;
for(int i=0; i<numCycles; i++){
if(!pendingTrans){
if(!trans_addr.empty()){
//new tran
uint64_t addr = trans_addr.front();
//cout << "***tran addr " << addr << endl;
trans_addr.pop();
trans = new Transaction(DATA_READ, addr, data);
if(!dram->addTransaction(false, addr)){
pendingTrans = true;
}
else{
transactionReceiver.add_pending(*trans,i);
trans = NULL;
}
}
else{
pendingTrans = false;
}
}
else{
pendingTrans = !dram->addTransaction(false, trans->address);
if(!pendingTrans){
transactionReceiver.add_pending(*trans,i);
trans = NULL;
}
}
dram->update();
//has callback
transactionReceiver.cpu_callback(i);
//cout << "pending num: " << transactionReceiver.num_pending << endl;
if(transactionReceiver.num_pending == 0){
cout << "***************finish cycle " << i << endl;
finish_cycle = i;
break;
}
}
if(trans){
delete trans;
}
return finish_cycle;
}
int LoadStoreDblk::storeDblk(DataBlock* dblk){
//cout << "create transaction receiver" << endl;
queue<uint64_t> trans_addr;
genTransactions(dblk, trans_addr);
//cout << "generated trans size: " << trans_addr.size() << endl;
//cout << "trans addr" << endl;
//for(auto &i: trans_addr){
//cout << hex << i << endl;
//}
//cout << "in store dblk" << endl;
int numCycles = INT_MAX;
bool pendingTrans = false;
Transaction* trans = NULL;
void* data = NULL;
int finish_cycle;
for(int i=0; i<numCycles; i++){
if(!pendingTrans){
if(!trans_addr.empty()){
//new tran
uint64_t addr = trans_addr.front();
//cout << "***tran addr " << addr << endl;
trans_addr.pop();
trans = new Transaction(DATA_WRITE, addr, data);
if(!dram->addTransaction(true, addr)){
pendingTrans = true;
}
else{
transactionReceiver.add_pending(*trans,i);
trans = NULL;
}
}
else{
pendingTrans = false;
}
}
else{
pendingTrans = !dram->addTransaction(true, trans->address);
if(!pendingTrans){
transactionReceiver.add_pending(*trans,i);
trans = NULL;
}
}
dram->update();
transactionReceiver.cpu_callback(i);
//cout << "pending num: " << transactionReceiver.num_pending << endl;
if(transactionReceiver.num_pending == 0){
cout << "***************finish cycle " << i << endl;
finish_cycle = i;
break;
}
}
if(trans){
delete trans;
}
return finish_cycle;
}
MacroNode::MacroNode(MacroNodeTemplate* in_mn_temp):mn_temp(in_mn_temp){
name = mn_temp->name;
}
MacroNode::MacroNode(MacroNodeTemplate* in_mn_temp, int in_idx):mn_temp(in_mn_temp), idx(in_idx){
name = mn_temp->name;
}
MacroNode::MacroNode(int in_idx):idx(in_idx){
}
void MacroNode::BuildOpMap(vector<Tile> &real_tiles, vector<Operation> &real_ops){
//cout << endl << "mn " << idx << endl;
for(map<int,int>::iterator t=tile_map.begin(); t!=tile_map.end(); t++){
//cout << "real tile " << t->first << ": " << " tile in mn " << t->second << endl;
vector<int>::iterator op2 = mn_temp->p_cg->tiles[t->second].ops.begin();
for(vector<int>::iterator op1 = real_tiles[t->first].ops.begin(); op1!=real_tiles[t->first].ops.end(); op1++){
//cout << "op in real tile " << *op1 << endl;
//cout << "op in mn tile " << *op2 << endl;
vector<int>::iterator inop2 = mn_temp->p_cg->ops[*op2].in.begin();
for(vector<int>::iterator inop1 = real_ops[*op1].in.begin(); inop1!=real_ops[*op1].in.end(); inop1++){
//cout <<"inop in real tile " << *inop1 << endl;
//cout <<"inop in mn tile " << *inop2 << endl;
if(real_tiles[t->first].livein_ops.find(*inop1) != real_tiles[t->first].livein_ops.end()){
op_map[*inop2] = *inop1;
}
inop2++;
}
op2++;
}
vector<int>::iterator out_op1 = real_tiles[t->first].liveout_ops.begin();
for(vector<int>::iterator out_op2= mn_temp->p_cg->tiles[t->second].liveout_ops.begin(); out_op2!= mn_temp->p_cg->tiles[t->second].liveout_ops.end(); out_op2++){
if(op_map.find(*out_op2) == op_map.end()){
op_map[*out_op2] = *out_op1;
}
out_op1++;
}
}
}
|
e2386e4bed69bd281285bb199b7aa017259bedeb
|
50248f74c97d466542fc834b4c2117f8fd31bfe5
|
/mdf/ShareObject.cpp
|
6fb743a4af73688dfa61e1d383654fa38c35fbd9
|
[] |
no_license
|
lgshendy/mdf
|
7659730032606291a886d1369f672bb1fedd3ea7
|
92845415f8c6c0dbfc1178b7204e3916a2883d69
|
refs/heads/master
| 2022-04-09T05:18:39.706871
| 2020-03-19T09:25:02
| 2020-03-19T09:25:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 580
|
cpp
|
ShareObject.cpp
|
#include "../../include/mdf/ShareObject.h"
#include "../../include/mdf/atom.h"
#include <cstdio>
namespace mdf {
ShareObject::ShareObject() {
m_refCount = 1;
}
ShareObject::~ShareObject() {
}
void ShareObject::AddRef() {
if (NULL == this)
return;
mdf::AtomAdd(&m_refCount, 1);
}
void ShareObject::Release() {
if (NULL == this)
return;
if (1 != mdf::AtomDec(&m_refCount, 1))
return;
Delete();
}
void ShareObject::Delete() {
delete this;
}
}
|
dff0a739bf44eb9523cf65920ea0901b847801fd
|
6bf0252b2c0600cf8d9e664d8d677eee34746f72
|
/BaekjoonOnline/7579_app2.cpp
|
77820a982459f9808edb39cf441bb8a3134ec648
|
[] |
no_license
|
lja9702/JinAh-BOJ
|
18bfd3029c946e9d16039cc3ec813a6321c4e41c
|
eb6c16f7f315b8acbdc3c7532f49fbedb01dc43e
|
refs/heads/master
| 2021-04-28T14:35:50.179515
| 2018-08-19T05:54:20
| 2018-08-19T05:54:20
| 121,968,017
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 561
|
cpp
|
7579_app2.cpp
|
#include <cstdio>
#include <algorithm>
int n, m, cost[101], res = 1 << 29;
long long dp[10001] = {0}, app[101];
int main(){
scanf("%d %d", &n, &m);
for(int i = 1;i <= n;i++) scanf("%lld", &app[i]);
for(int i = 1;i <= n;i++) scanf("%d", &cost[i]);
for(int i = 1;i <= n;i++){
for(int j = 10000;j >= 0;j--){
if(dp[j]) dp[j + cost[i]] = std::max(dp[j + cost[i]], dp[j] + app[i]);
}
dp[cost[i]] = std::max(dp[cost[i]], app[i]);
}
for(int i = 0;i <= 10000;i++){
if(dp[i] >= m){
printf("%d\n", i);
return 0;
}
}
}
|
958c8f779d889d5fc83777014ba3df6ec2dda63a
|
ec4fd79e42f231cbaabb60c8fcac302d4200a033
|
/C++/electric_field/main.cpp
|
bc1b6e2c56b003cac0af9ada25f1ab6a1d10c4a5
|
[] |
no_license
|
urbanovez/CS_MIPT
|
3b7755e834fdfc20747bb7c5063e6eddf85ba24e
|
bd217fe2cba17479df48e3406fe8fac3d79e56cc
|
refs/heads/master
| 2022-06-08T20:40:09.369488
| 2020-05-07T21:04:13
| 2020-05-07T21:04:13
| 263,736,589
| 1
| 0
| null | 2020-05-13T20:31:03
| 2020-05-13T20:31:02
| null |
UTF-8
|
C++
| false
| false
| 2,272
|
cpp
|
main.cpp
|
#include <iostream>
#include <SFML\Graphics.hpp>
#include "charge.h"
int main()
{
sf::RenderWindow window(sf::VideoMode(1600, 900), "My Window");
sf::Event event;
static bool isPressed = false;
std::vector<ElectricCharge> charges;
std::vector<sf::VertexArray> lines;
while (window.isOpen())
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if (!isPressed)
{
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
ElectricCharge temp = {1, mousePos.x, mousePos.y};
charges.push_back(temp);
isPressed = true;
break;
}
}
else isPressed = false;
if (sf::Mouse::isButtonPressed(sf::Mouse::Right))
{
if (!isPressed)
{
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
ElectricCharge temp = { -1, mousePos.x, mousePos.y };
charges.push_back(temp);
isPressed = true;
break;
}
}
else isPressed = false;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
{
if (!isPressed)
{
sf::VertexArray linePlus(sf::LinesStrip, lineLength);
sf::VertexArray lineMinus(sf::LinesStrip, lineLength);
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
sf::Vector2f curPlus = sf::Vector2f(mousePos.x, mousePos.y);
sf::Vector2f curMinus = sf::Vector2f(mousePos.x, mousePos.y);
for (int i = 0; i < lineLength; i++)
{
linePlus[i].position = sf::Vector2f(curPlus.x, curPlus.y);
lineMinus[i].position = sf::Vector2f(curMinus.x, curMinus.y);
sf::Vector2f Eplus = getTension(curPlus, charges);
sf::Vector2f Eminus = getTension(curMinus, charges);
curPlus += Eplus;
curMinus -= Eminus;
}
lines.push_back(linePlus);
lines.push_back(lineMinus);
isPressed = true;
break;
}
else isPressed = false;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F))
{
charges.clear();
lines.clear();
}
}
for (auto it : charges)
window.draw(it.obj);
for (auto it : lines)
window.draw(it);
window.display();
window.clear();
}
return 0;
}
|
194628bb4d1520f80cbcb1b168dabde906f4c5d7
|
a7dfe8e648b86066000d3c985a18dbe066c42468
|
/덱/[1021]회전하는큐/이준규/rollinQ.cpp
|
a4b3fc90e26f32f7965e5e516ac7ed4d0b916fa8
|
[] |
no_license
|
jth2747/AlgorithmStudy
|
b74d2c9db051ea200d942493a00c58d4ead3d541
|
534ce4a3bc8b89dc2417d45ba5d77976281481b6
|
refs/heads/master
| 2023-01-22T06:40:49.756461
| 2020-11-24T11:42:02
| 2020-11-24T11:42:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,095
|
cpp
|
rollinQ.cpp
|
#include <iostream>
#include <deque>
#include <cmath>
using namespace std;
int main(){
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
deque<int> q;
int n , m, temp, count = 0, tempindex = 0;
cin>>n>>m;
for(int i = 0 ; i < n ; i++){
q.push_back(i+1);
}
for(int i = 0 ; i < m ; i++){
cin>>temp;
if(q.front() != temp){
for(int k = 0 ; k < q.size() ; k++){
if(q[k] == temp) tempindex = k+1;
}
if(tempindex > ceil((double)q.size()/2)){
for(int j = 0 ; j <= (q.size()-tempindex) ; j++){
q.push_front(q.back());
q.pop_back();
count++;
}
}
else{
for(int j = 0 ; j < (tempindex-1) ; j++){
q.push_back(q.front());
q.pop_front();
count++;
}
}
}
q.pop_front();
}
cout<<count;
}
|
38d91dd196171899892ed952f7a7acada02a57fe
|
cac973193c10223ba1e09ac2d36e8c10e31e4988
|
/Marut_and_strings.cpp
|
a3623c43eafcd7b546706288aea3bbb8a6e6a85b
|
[] |
no_license
|
gunjan01/Problems-HackerRank
|
055fdf06953b912bd2f764742d4a02df02a55e52
|
410630b109d9ba6019dc831d9027db181d42cafa
|
refs/heads/master
| 2021-03-24T11:02:28.481978
| 2017-10-22T14:39:34
| 2017-10-22T14:39:34
| 100,195,916
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 757
|
cpp
|
Marut_and_strings.cpp
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
if(t<1 || t>10) cout<<"Invalid Test"<<endl;
else
{
string s;
while(t!=0)
{
cin>>s;
int i,cntu=0,cntl=0;
if(s.length()>100 || s.length()==0 )
{
cout<<"Invalid Input"<<endl;
t--;
continue;
}
for(i=0;i<s.length();i++)
{
if(isupper(s[i])) cntu++;
else if(islower(s[i])) cntl++;
}
if(cntu==0 && cntl==0) cout<<"Invalid Input"<<endl;
else cout<<min(cntu,cntl)<<endl;
t--;
}
}
return 0;
}
|
cb2df76a3d9ac77453d4ffa77cc0d87cd211370f
|
97aa1181a8305fab0cfc635954c92880460ba189
|
/torch/csrc/jit/tensorexpr/var_substitutor.h
|
ba065d431bcdb0addbd6cb69e9cc78ba13aead99
|
[
"BSD-2-Clause"
] |
permissive
|
zhujiang73/pytorch_mingw
|
64973a4ef29cc10b96e5d3f8d294ad2a721ccacb
|
b0134a0acc937f875b7c4b5f3cef6529711ad336
|
refs/heads/master
| 2022-11-05T12:10:59.045925
| 2020-08-22T12:10:32
| 2020-08-22T12:10:32
| 123,688,924
| 8
| 4
|
NOASSERTION
| 2022-10-17T12:30:52
| 2018-03-03T12:15:16
|
C++
|
UTF-8
|
C++
| false
| false
| 2,192
|
h
|
var_substitutor.h
|
#pragma once
#include <unordered_map>
#include <vector>
#include <torch/csrc/jit/tensorexpr/ir.h>
#include <torch/csrc/jit/tensorexpr/ir_mutator.h>
#include <torch/csrc/jit/tensorexpr/ir_visitor.h>
#include <torch/csrc/jit/tensorexpr/reduction.h>
namespace torch {
namespace jit {
namespace tensorexpr {
using VarMapping = std::vector<std::pair<const Var*, const Expr*>>;
// Finds all Vars present in a subexpr.
class VarFinder : public IRVisitor {
public:
std::set<const Var*> findVars(const Expr* expr) {
vars_.clear();
expr->accept(this);
return vars_;
}
void visit(const Var* v) {
vars_.insert(v);
}
private:
std::set<const Var*> vars_;
};
class VarSubMutator : public IRMutator {
public:
VarSubMutator(const VarMapping& var_mapping) {
for (const auto& entry : var_mapping) {
const Var* key_var = entry.first;
const Expr* value = entry.second;
if (!key_var) {
throw malformed_input("missing key in VarSubMutator");
}
var_mapping_[key_var] = value;
}
}
const Expr* mutate(const Var* var) override {
auto iter = var_mapping_.find(var);
if (iter == var_mapping_.end()) {
return var;
}
return iter->second;
}
const Expr* mutate(const ReduceOp* var) override {
auto body = var->body().node()->accept_mutator(this);
std::vector<const Expr*> new_outer;
std::vector<const Var*> new_inner;
for (auto* v : var->output_args()) {
new_outer.push_back(v->accept_mutator(this));
}
for (auto* v : var->reduce_args()) {
const Expr* e = v->accept_mutator(this);
if (const Var* new_var = dynamic_cast<const Var*>(e)) {
new_inner.push_back(new_var);
} else {
VarFinder varFinder;
auto varlist = varFinder.findVars(e);
new_inner.insert(new_inner.end(), varlist.begin(), varlist.end());
}
}
return new ReduceOp(
const_cast<Buf*>(var->accumulator()),
ExprHandle(body),
var->interaction(),
new_outer,
new_inner);
}
private:
std::unordered_map<const Var*, const Expr*> var_mapping_;
};
} // namespace tensorexpr
} // namespace jit
} // namespace torch
|
b8a8474ee02f46a084d4e4c8005804ac77a876ef
|
45e9844eaf257786fc11bf762471932a52c369d4
|
/Node_Factory.cpp
|
d42b1b4c23c9644e50de734b4c59a62ff9bd6ad5
|
[] |
no_license
|
abjay/calculator-project
|
3fd5e276a4ff7241938039a72021c2a80dfe2a17
|
dcf782714f5b4f4f7dce6b7322154d09afcfaae2
|
refs/heads/master
| 2020-03-09T21:43:13.910114
| 2018-04-11T01:39:19
| 2018-04-11T01:39:19
| 129,016,495
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 252
|
cpp
|
Node_Factory.cpp
|
// Honor Pledge:
//
// I pledge that I have neither given nor receieved any help
// on this assignment.
#include"Node_Factory.h"
//
//Node_Factory
//
Node_Factory::Node_Factory(void)
{
}
//
//~Node_Factory
//
Node_Factory::~Node_Factory(void)
{
}
|
357c5eed6e536a11771892a7fa52d565c12a479b
|
49ff6718d9f956de0f8511db88d61d55df21ec8b
|
/emulator/lib/src/cpu_8080_logical.cpp
|
518699f1f6c5a3147fcc87d8c814cb6d76a33d1d
|
[] |
no_license
|
borgmanJeremy/emulator8080
|
9db0513d5c7907316b90dea9cd6e1e63b45547c3
|
d76c9814addbb96ef0173c28fd842ee18f2ffd3f
|
refs/heads/master
| 2020-08-22T13:14:29.614486
| 2019-11-30T20:02:41
| 2019-12-06T23:05:38
| 216,402,695
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,098
|
cpp
|
cpu_8080_logical.cpp
|
#include "cpu_8080.hpp"
void Cpu_8080::andRegToRegA(uint8_t to_and)
{
reg_.a = reg_.a & to_and;
setZeroFlag(reg_.a);
setSignFlag(reg_.a);
setParityFlag(reg_.a);
flags_.cy = 0;
flags_.ac = 0;
}
void Cpu_8080::orRegToRegA(uint8_t to_or)
{
reg_.a = reg_.a | to_or;
setZeroFlag(reg_.a);
setSignFlag(reg_.a);
setParityFlag(reg_.a);
flags_.cy = 0;
flags_.ac = 0;
}
void Cpu_8080::xorRegToRegA(uint8_t to_xor)
{
reg_.a = reg_.a ^ to_xor;
setZeroFlag(reg_.a);
setSignFlag(reg_.a);
setParityFlag(reg_.a);
flags_.cy = 0;
flags_.ac = 0;
}
void Cpu_8080::compRegToRegA(uint8_t to_comp)
{
auto result =
static_cast<unsigned int>(reg_.a) - static_cast<unsigned int>(to_comp);
setZeroFlag(result);
setSignFlag(result);
setParityFlag(result);
setCarryFlag(result);
uint8_t ac_test = (reg_.a & 0x0F) - (to_comp & 0x0F);
setAuxFlag(ac_test);
}
void Cpu_8080::addLogicalOperations()
{
instruction_set_.emplace_back(Instruction{0x2F, 0, "CMA", [this]() {
reg_.a = ~reg_.a;
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0x3F, 0, "CMC", [this]() {
flags_.cy =
(flags_.cy == 1) ? 0 : 1;
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA0, 0, "ANA B", [this]() {
andRegToRegA(reg_.b);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA1, 0, "ANA C", [this]() {
andRegToRegA(reg_.c);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA2, 0, "ANA D", [this]() {
andRegToRegA(reg_.d);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA3, 0, "ANA E", [this]() {
andRegToRegA(reg_.e);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA4, 0, "ANA H", [this]() {
andRegToRegA(reg_.h);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA5, 0, "ANA L", [this]() {
andRegToRegA(reg_.l);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA6, 0, "ANA M", [this]() {
auto addr = getAddressFromHL();
andRegToRegA(memory_[addr]);
reg_.pc++;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xE6, 1, "ANI D8", [this]() {
andRegToRegA(
memory_[reg_.pc + 1]);
reg_.pc += 2;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xA7, 0, "ANA A", [this]() {
andRegToRegA(reg_.a);
reg_.pc++;
cycle_count_ += 4;
}});
////////////
instruction_set_.emplace_back(Instruction{0xA8, 0, "XRA B", [this]() {
xorRegToRegA(reg_.b);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xA9, 0, "XRA C", [this]() {
xorRegToRegA(reg_.c);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xAA, 0, "XRA D", [this]() {
xorRegToRegA(reg_.d);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xAB, 0, "XRA E", [this]() {
xorRegToRegA(reg_.e);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xAC, 0, "XRA H", [this]() {
xorRegToRegA(reg_.h);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xAD, 0, "XRA L", [this]() {
xorRegToRegA(reg_.l);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xEE, 1, "XRI D8", [this]() {
xorRegToRegA(
memory_[reg_.pc + 1]);
reg_.pc += 2;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xAE, 0, "XRA M", [this]() {
auto addr = getAddressFromHL();
xorRegToRegA(memory_[addr]);
reg_.pc++;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xAF, 0, "XRA A", [this]() {
xorRegToRegA(reg_.a);
reg_.pc++;
cycle_count_ += 4;
}});
////////////
instruction_set_.emplace_back(Instruction{0xB0, 0, "ORA B", [this]() {
orRegToRegA(reg_.b);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB1, 0, "ORA C", [this]() {
orRegToRegA(reg_.c);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB2, 0, "ORA D", [this]() {
orRegToRegA(reg_.d);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB3, 0, "ORA E", [this]() {
orRegToRegA(reg_.e);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB4, 0, "ORA H", [this]() {
orRegToRegA(reg_.h);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB5, 0, "ORA L", [this]() {
orRegToRegA(reg_.l);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xf6, 1, "ORI D8", [this]() {
orRegToRegA(memory_[reg_.pc + 1]);
reg_.pc += 2;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xB6, 0, "ORA M", [this]() {
auto addr = getAddressFromHL();
orRegToRegA(memory_[addr]);
reg_.pc++;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xB7, 0, "ORA A", [this]() {
orRegToRegA(reg_.a);
reg_.pc++;
cycle_count_ += 4;
}});
////////////
instruction_set_.emplace_back(Instruction{0xB8, 0, "CMP B", [this]() {
compRegToRegA(reg_.b);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xB9, 0, "CMP C", [this]() {
compRegToRegA(reg_.c);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xBA, 0, "CMP D", [this]() {
compRegToRegA(reg_.d);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xBB, 0, "CMP E", [this]() {
compRegToRegA(reg_.e);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xBC, 0, "CMP H", [this]() {
compRegToRegA(reg_.h);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xBD, 0, "CMP L", [this]() {
compRegToRegA(reg_.l);
reg_.pc++;
cycle_count_ += 4;
}});
instruction_set_.emplace_back(Instruction{0xBE, 0, "CMP M", [this]() {
auto addr = getAddressFromHL();
compRegToRegA(memory_[addr]);
reg_.pc++;
cycle_count_ += 7;
}});
instruction_set_.emplace_back(Instruction{0xBF, 0, "CMP A", [this]() {
compRegToRegA(reg_.a);
reg_.pc++;
cycle_count_ += 4;
}});
}
|
c480dabeb4a761900dac2556c83ff3d2ad308932
|
0c7e20a002108d636517b2f0cde6de9019fdf8c4
|
/Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/widget/CDatePickerCalendarDelegateSavedState.h
|
d67d564e4f13cf81dd600e49e1ce587d2280b7ae
|
[
"Apache-2.0"
] |
permissive
|
kernal88/Elastos5
|
022774d8c42aea597e6f8ee14e80e8e31758f950
|
871044110de52fcccfbd6fd0d9c24feefeb6dea0
|
refs/heads/master
| 2021-01-12T15:23:52.242654
| 2016-10-24T08:20:15
| 2016-10-24T08:20:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 641
|
h
|
CDatePickerCalendarDelegateSavedState.h
|
#ifndef __ELASTOS_DROID_WIDGET_CDATEPICKERCALENDARDELEGATESAVEDSTATE_H__
#define __ELASTOS_DROID_WIDGET_CDATEPICKERCALENDARDELEGATESAVEDSTATE_H__
#include "_Elastos_Droid_Widget_CDatePickerCalendarDelegateSavedState.h"
#include "elastos/droid/widget/DatePickerCalendarDelegate.h"
namespace Elastos {
namespace Droid {
namespace Widget {
CarClass(CDatePickerCalendarDelegateSavedState)
, public DatePickerCalendarDelegate::DatePickerCalendarDelegateSavedState
{
public:
CAR_OBJECT_DECL()
};
}// namespace Elastos
}// namespace Droid
}// namespace Widget
#endif // __ELASTOS_DROID_WIDGET_CDATEPICKERCALENDARDELEGATESAVEDSTATE_H__
|
0fb6983fd14745de47e54bc8f8ae3188d7f1a82e
|
33924be8f34341ca37de794f07abca49f308d49d
|
/scm_core/src/scm/core/math/vec.inl
|
1997e7610a3bed806789ea8a1a2687b65d8e7919
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
mapoto/schism
|
59ef4ab83851bd606b4f603d5160fb7c7a60366b
|
784d53d723ae62ebc9acb3017db664794fd4413e
|
refs/heads/master
| 2021-02-26T04:31:18.595701
| 2020-03-14T10:50:06
| 2020-03-14T10:50:06
| 245,495,976
| 1
| 0
|
NOASSERTION
| 2020-03-06T19:00:09
| 2020-03-06T19:00:08
| null |
UTF-8
|
C++
| false
| false
| 7,276
|
inl
|
vec.inl
|
// Copyright (c) 2012 Christopher Lux <christopherlux@gmail.com>
// Distributed under the Modified BSD License, see license.txt.
namespace std {
template<typename scal_type, const unsigned dim>
inline void swap(scm::math::vec<scal_type, dim>& lhs,
scm::math::vec<scal_type, dim>& rhs)
{
lhs.swap(rhs);
}
} // namespace std
namespace scm {
namespace math {
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator++(vec<scal_type, dim>& v, int)
{
vec<scal_type, dim> tmp(v);
v += scal_type(1);
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline vec<scal_type, dim>&
operator++(vec<scal_type, dim>& v)
{
v += scal_type(1);
return (v);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator--(vec<scal_type, dim>& v, int)
{
vec<scal_type, dim> tmp(v);
v -= scal_type(1);
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline vec<scal_type, dim>&
operator--(vec<scal_type, dim>& v)
{
v -= scal_type(1);
return (v);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator-(const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(rhs);
tmp *= scal_type(-1);
return (tmp);
}
// binary operators
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator+(const vec<scal_type, dim>& lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp += rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator+(const vec<scal_type, dim>& lhs,
const scal_type rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp += rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator-(const vec<scal_type, dim>& lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp -= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator-(const vec<scal_type, dim>& lhs,
const scal_type rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp -= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const vec<scal_type, dim>& lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp *= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const scal_type lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(rhs);
tmp *= lhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const vec<scal_type, dim>& lhs,
const scal_type rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp *= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator/(const vec<scal_type, dim>& lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp /= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim>
operator/(const vec<scal_type, dim>& lhs,
const scal_type rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp /= rhs;
return (tmp);
}
// binary operators
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator+(const vec<scal_type, dim>& lhs,
const vec<rhs_scal_t, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp += rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator+(const vec<scal_type, dim>& lhs,
const rhs_scal_t rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp += rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator-(const vec<scal_type, dim>& lhs,
const vec<rhs_scal_t, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp -= rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator-(const vec<scal_type, dim>& lhs,
const rhs_scal_t rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp -= rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const vec<scal_type, dim>& lhs,
const vec<rhs_scal_t, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp *= rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const rhs_scal_t lhs,
const vec<scal_type, dim>& rhs)
{
vec<scal_type, dim> tmp(rhs);
tmp *= lhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator*(const vec<scal_type, dim>& lhs,
const rhs_scal_t rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp *= rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator/(const vec<scal_type, dim>& lhs,
const vec<rhs_scal_t, dim>& rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp /= rhs;
return (tmp);
}
template<typename scal_type,
typename rhs_scal_t,
const unsigned dim>
inline const vec<scal_type, dim>
operator/(const vec<scal_type, dim>& lhs,
const rhs_scal_t rhs)
{
vec<scal_type, dim> tmp(lhs);
tmp /= rhs;
return (tmp);
}
template<typename scal_type,
const unsigned dim>
inline vec<scal_type, dim> lerp(const vec<scal_type, dim>& min,
const vec<scal_type, dim>& max,
const scal_type a)
{
return max * a + min * (scal_type(1) - a);
}
template<typename scal_type,
const unsigned dim>
inline scal_type length_sqr(const vec<scal_type, dim>& lhs)
{
return (dot(lhs, lhs));
}
template<typename scal_type,
const unsigned dim>
inline scal_type length(const vec<scal_type, dim>& lhs)
{
return (std::sqrt(length_sqr(lhs)));
}
template<typename scal_type,
const unsigned dim>
inline const vec<scal_type, dim> normalize(const vec<scal_type, dim>& lhs)
{
return (lhs / length(lhs));
}
template<typename scal_type,
const unsigned dim>
inline scal_type distance(const vec<scal_type, dim>& lhs,
const vec<scal_type, dim>& rhs)
{
return (length(lhs - rhs));
}
} // namespace math
} // namespace scm
|
694e8db82032adfe370c18e3ea3d842b1c4ad541
|
acb8ebbd3c0cc5b067020eb15df63405feb6386d
|
/hw09_virtual_functions_and_abstract_classes/Rectangle.h
|
d548ca62399ecbfefaba932873498f8e529ec18c
|
[] |
no_license
|
Aizeke/CS1C-Summer-2020
|
bfd5c2889744ba836d079dadcc4a144dd5643a4f
|
c02517143603efd2f9600baecb8a8a6b6d96c581
|
refs/heads/master
| 2022-11-28T22:09:56.400671
| 2020-07-25T05:57:24
| 2020-07-25T05:57:24
| 269,172,975
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 460
|
h
|
Rectangle.h
|
#pragma once
#include "Shape.h"
// 1. Create sub classes of Shape called Rectangle
// and Triangle that inherited the pure virtual
// members above.
class Rectangle : public Shape {
public:
Rectangle();
~Rectangle() {};
Rectangle (float length, float width);
float calcPerimeter() override;
float calcArea() override;
void printPerimeter();
void printArea();
// Private Date Members;
private:
float length;
float width;
};
|
1f38715c3ddcb1cd88f8a4d531521207bdc4f35a
|
794e7d822b26c0692ec2ce1d30e54d43b82b8d4d
|
/wikipediagraphwidget.cpp
|
cf3dd88a8ab35074e9992da145b5c09bfa4dfced
|
[] |
no_license
|
phdowling/WikiGraph
|
5e7da9e79675d6dbee5a29ad6ebee7754854512b
|
34cc16b179efd3604e3f3da3521b92d6b71676f4
|
refs/heads/master
| 2021-01-04T14:07:26.877670
| 2014-08-13T08:37:14
| 2014-08-13T08:37:14
| 3,001,275
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,727
|
cpp
|
wikipediagraphwidget.cpp
|
#include "wikipediagraphwidget.h"
WikipediaGraphWidget::WikipediaGraphWidget(GraphLayout *layout, QWidget *parent) :
GraphWidget(layout, parent)
{
_expandTimer.setInterval(100);
connect(&_expandTimer, SIGNAL(timeout()), this, SLOT(expandNext()));
makeTestScene();
startForceCalculation();
}
Node *WikipediaGraphWidget::addNode(QPointF pos)
{
Node *newNode = new WikiNode(this);
newNode->setPos(pos);
newNode->setIndex(_nodeList.size());
_nodeList.append(newNode);
_scene->addItem(newNode);
return newNode;
}
Node *WikipediaGraphWidget::addNode(int x, int y)
{
return addNode(QPoint(x, y));
}
void WikipediaGraphWidget::expand(Node *node)
{
if(node->isExpanded()){
return;
}
node->setExpanded();
PageLoader *loader = new PageLoader(node->getData(), (void*)node, this);
connect(loader, SIGNAL(finished(PageLoader*)), this, SLOT(parseLinks(PageLoader*)));
}
void WikipediaGraphWidget::parseLinks(PageLoader *pageLoader)
{
QString pageString(pageLoader->getReply()->readAll());
WikiNode *expandedNode = (WikiNode*)pageLoader->getItem();
pageLoader->deleteLater();
int start = pageString.indexOf("<div id=\"bodyContent\">");
int end = pageString.indexOf("<ol class=\"references\">")+23 -pageString.indexOf("<div id=\"bodyContent\">");
pageString = pageString.mid(start,end);
int linkStartIndex;
int linkEndIndex;
QString workingString;
QString result;
for(int idx = 0; pageString.contains("<a href=\"/wiki/"); idx++)
{
linkStartIndex = pageString.indexOf("<a href=\"/wiki/")+15;
workingString = pageString.mid(linkStartIndex,
pageString.indexOf("<ol class=\"references\">")+23-linkStartIndex);
linkEndIndex = workingString.indexOf("\" ");
if(workingString.mid(0,linkEndIndex).contains(":") || expandedNode->countLinkedPages() >= _maxLinks){
pageString = pageString.mid(linkStartIndex,pageString.indexOf("<ol class=\"references\">")+23-linkStartIndex);
continue;
}
else{
result = "http://en.wikipedia.org/wiki/"+workingString.mid(0,linkEndIndex);
pageString = pageString.mid(linkStartIndex,pageString.indexOf("<ol class=\"references\">")+23-linkStartIndex);
expandedNode->addLinkedPage(result);
}
}
int numNodes = expandedNode->countLinkedPages();
int idx = 0;
bool connected;
QList<QString> linkedPages = expandedNode->getLinkedPages();
foreach(QString page, linkedPages) {
connected = false;
foreach(Node *otherNode, _nodeList){
if(otherNode->getData()==page) {
connectNodes(expandedNode, otherNode);
connected = true;
idx++;
break;
}
}
if(! connected){
Node *newNode = addNode(expandedNode->x(), expandedNode->y());
newNode->setData(page);
newNode->setText(page.mid(page.lastIndexOf("/") + 1));
newNode->setPos(QPoint(expandedNode->pos().x()+ qSin(2*3.14159/numNodes*idx)*50,
expandedNode->pos().y()+ qCos(2*3.14159/numNodes*idx)*50));
connectNodes(expandedNode, newNode);
idx ++;
}
}
this->setUpdateVelocity(true);
}
void WikipediaGraphWidget::makeTestScene()
{
Node *test = addNode(10, 10);
QString text = QInputDialog::getText(this,
tr("WikiGraph"),
tr("Enter page to display"),QLineEdit::Normal,
"http://en.wikipedia.org/wiki/Quicksort");
test->setText(text.mid(text.lastIndexOf("/")+1));
test->setData(text);//"http://en.wikipedia.org/wiki/Quicksort"
int links = QInputDialog::getInt(this,
tr("WikiGraph"),
tr("Enter maximum number of pagelinks per article"),QLineEdit::Normal,
5);
_maxLinks = links;
expand(test);
}
//void WikipediaGraphWidget::expandGeneration()
//{
// foreach(Node *node, _nodeList){
// expand(node);
// }
//}
void WikipediaGraphWidget::setMaxLinks(int links)
{
_maxLinks = links;
}
void WikipediaGraphWidget::expandGeneration()
{
_expandPos = 0;
_expandNum = 0;
foreach(Node* node, _nodeList){
if(!node->isExpanded()){
_expandNum++;
}
}
_expandTimer.start();
}
void WikipediaGraphWidget::expandNext()
{
if(_expandPos < _expandNum) {
expand(_nodeList[_expandPos]);
++_expandPos;
}
}
|
5edd8f6e3792324a72b9a1860b3d4b118229e864
|
f54d3c6f83f8c6398dcf00538e12209e17deeb98
|
/code/userprog/processtable.h
|
4808b8a248b0bff8778d032e73867fefa497e0a1
|
[] |
no_license
|
joseluisdiaz/nachos
|
0edfab92a31e569f505fc06a16e9fb2723f56d66
|
b2c3fdc7f2faf8c11ba842bdccbcf00898b262e3
|
refs/heads/master
| 2021-01-17T17:05:55.664050
| 2013-07-24T21:33:49
| 2013-07-24T21:33:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 522
|
h
|
processtable.h
|
// processtable.h
// Tabla de procesos para nachos (Header+Codigo)
// by Diaz-Racca, la delantera del mundial '86
#ifndef PROCTABLE_H
#define PROCTABLE_H
#include "syscall.h"
#include <map>
class ProcessTable {
public:
ProcessTable(){
lastId = 0;
};
~ProcessTable(){ };
SpaceId Add(Thread *thread) {
table[++lastId] = thread;
return lastId;
}
Thread *Get(SpaceId id) {
return table[id];
}
private:
int lastId;
std::map<SpaceId, Thread*> table;
};
#endif //PROCTABLE_H
|
924852654a0f97d584034932139675d4f3db05c6
|
326441ea10a9d73a9f9776c9aaacefa15706a191
|
/modules/Preferences.cpp
|
8a0d578eda29e68c835bac7bf2fe59b6049f9ca1
|
[] |
no_license
|
dtnaylor/session-management
|
1ff8338d279cedc9a3d11c7f721c1588e751b9f1
|
14633b49919e6471f797474b3522edfadb52d3c2
|
refs/heads/master
| 2021-01-22T13:42:14.935470
| 2014-06-16T13:13:23
| 2014-06-16T13:13:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 971
|
cpp
|
Preferences.cpp
|
/*
** Copyright 2014 Carnegie Mellon University
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include "Preferences.h"
bool Preferences::getCompress(Party party, const std::string &app) {
// Simulate preferences for compression
// (for now we're ignoring the app name...)
(void)app;
switch(party) {
case kUser:
return true;
case kAdmin:
return true;
case kApp:
return false;
default:
WARN("Unknown party");
return false;
}
}
|
82ed7f715b564b0423eefb63fad8181b1d6b8623
|
44313c3267c1b694970a7cffd50a486930fea285
|
/Soul.cpp
|
b0dd38ac63616d8b1ec5bb1a345d2b94afbf24cc
|
[] |
no_license
|
ehei1/maze-client
|
3bd08b40d8a02c760e0da631c9680a8375b514d8
|
3ca195e0cf21d2cf0c9c75b1374ffdaae3f88245
|
refs/heads/master
| 2022-10-28T13:38:27.971161
| 2020-06-15T12:33:24
| 2020-06-15T12:33:24
| 272,433,103
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 504
|
cpp
|
Soul.cpp
|
#include "StdAfx.h"
#include "Soul.h"
#include "Event.h"
#include "Body.h"
Soul::Soul(void) :
mIndex(0)
{
}
Soul::~Soul(void)
{
}
void Soul::AddEvent(Event* event)
{
/*
TODO: 루아 스크립트에 event를 보낸다. 스크립트는 이를 바탕으로 메시지를 Soul을 통해 생성하고, 바디에 전송하도록 한다
*/
if(nullptr != mBody)
{
mBody->Receive(*event);
}
}
void Soul::Run(const Body&, const Ogre::FrameEvent&)
{
// 정기적으로 상황을 처리한다... (
}
|
d88d065e9b0acd147560ff74b5aed7cd99b5ffcf
|
39689c7df24cb5df4155ccb6b2303cd730d6c949
|
/2576.cpp
|
db7bad2554cf303298da1f2c4ced328454f3eba1
|
[] |
no_license
|
kisang0365/baekjoonAlgorithm
|
7f154cfa3dd2a4f50112061973cd2914acd2c9aa
|
781e8473f158488cf2cab8cbba8800c0102271ac
|
refs/heads/master
| 2021-01-23T03:59:16.446254
| 2017-10-27T08:55:09
| 2017-10-27T08:55:09
| 86,140,982
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 521
|
cpp
|
2576.cpp
|
/*
* 2576.cpp
*
* Created on: 2017. 7. 2.
* Author: chokisang
*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
vector<int> v;
for(int i=0; i<7; i++){
int num;
cin >> num;
v.push_back(num);
}
sort(v.begin(), v.end(), greater<int>());
int ans = -1;
int sum = 0;
for(int i=0; i<v.size(); i++){
if(v[i] % 2 == 1){
ans = v[i];
sum += ans;
}
}
if(ans == -1) cout<<ans<<endl;
else{
cout<<sum<<endl<<ans<<endl;
}
}
|
71b40b02eb156fd35366cfaa029dd11b558ae7b3
|
e25e84de08dd6829f85ce9d63e7aa36fdbae6510
|
/a.cpp
|
4acc2bab3677a14fb9f28c543f8ceec8632f8aae
|
[] |
no_license
|
yatin17124/Codebook
|
07305f43b567f131cd317fd22608eef72f601962
|
847e2ed013876ef22f658fdf99ac36ddd3fd7311
|
refs/heads/master
| 2020-06-29T02:38:32.771554
| 2019-08-04T06:58:24
| 2019-08-04T06:58:24
| 200,414,544
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,821
|
cpp
|
a.cpp
|
/*input
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define FOR(i,n) for(int i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int power(int x, int y, int mod = 2e18)
{int ans = 1;x%=mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) os << v[i] << " "; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v) { for (auto it : v) os << it << " "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T, S>& v) { os << v.first << " " << v.second; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << "\n"; return os; }
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int const MOD = 1e9+7;
int const inf = 2e18;
int const N = 2e5+10;
signed main() {
IOS;
return 0;
}
|
c5f76334f7d9eab860560c80583ec8558d8918b0
|
3ff1fe3888e34cd3576d91319bf0f08ca955940f
|
/ssl/include/tencentcloud/ssl/v20191205/model/DescribeHostUpdateRecordRequest.h
|
6f98fb6bb2effd64e54560045d72bf122bcd4875
|
[
"Apache-2.0"
] |
permissive
|
TencentCloud/tencentcloud-sdk-cpp
|
9f5df8220eaaf72f7eaee07b2ede94f89313651f
|
42a76b812b81d1b52ec6a217fafc8faa135e06ca
|
refs/heads/master
| 2023-08-30T03:22:45.269556
| 2023-08-30T00:45:39
| 2023-08-30T00:45:39
| 188,991,963
| 55
| 37
|
Apache-2.0
| 2023-08-17T03:13:20
| 2019-05-28T08:56:08
|
C++
|
UTF-8
|
C++
| false
| false
| 5,306
|
h
|
DescribeHostUpdateRecordRequest.h
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_SSL_V20191205_MODEL_DESCRIBEHOSTUPDATERECORDREQUEST_H_
#define TENCENTCLOUD_SSL_V20191205_MODEL_DESCRIBEHOSTUPDATERECORDREQUEST_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Ssl
{
namespace V20191205
{
namespace Model
{
/**
* DescribeHostUpdateRecord请求参数结构体
*/
class DescribeHostUpdateRecordRequest : public AbstractModel
{
public:
DescribeHostUpdateRecordRequest();
~DescribeHostUpdateRecordRequest() = default;
std::string ToJsonString() const;
/**
* 获取分页偏移量,从0开始。
* @return Offset 分页偏移量,从0开始。
*
*/
uint64_t GetOffset() const;
/**
* 设置分页偏移量,从0开始。
* @param _offset 分页偏移量,从0开始。
*
*/
void SetOffset(const uint64_t& _offset);
/**
* 判断参数 Offset 是否已赋值
* @return Offset 是否已赋值
*
*/
bool OffsetHasBeenSet() const;
/**
* 获取每页数量,默认10。
* @return Limit 每页数量,默认10。
*
*/
uint64_t GetLimit() const;
/**
* 设置每页数量,默认10。
* @param _limit 每页数量,默认10。
*
*/
void SetLimit(const uint64_t& _limit);
/**
* 判断参数 Limit 是否已赋值
* @return Limit 是否已赋值
*
*/
bool LimitHasBeenSet() const;
/**
* 获取新证书ID
* @return CertificateId 新证书ID
*
*/
std::string GetCertificateId() const;
/**
* 设置新证书ID
* @param _certificateId 新证书ID
*
*/
void SetCertificateId(const std::string& _certificateId);
/**
* 判断参数 CertificateId 是否已赋值
* @return CertificateId 是否已赋值
*
*/
bool CertificateIdHasBeenSet() const;
/**
* 获取原证书ID
* @return OldCertificateId 原证书ID
*
*/
std::string GetOldCertificateId() const;
/**
* 设置原证书ID
* @param _oldCertificateId 原证书ID
*
*/
void SetOldCertificateId(const std::string& _oldCertificateId);
/**
* 判断参数 OldCertificateId 是否已赋值
* @return OldCertificateId 是否已赋值
*
*/
bool OldCertificateIdHasBeenSet() const;
private:
/**
* 分页偏移量,从0开始。
*/
uint64_t m_offset;
bool m_offsetHasBeenSet;
/**
* 每页数量,默认10。
*/
uint64_t m_limit;
bool m_limitHasBeenSet;
/**
* 新证书ID
*/
std::string m_certificateId;
bool m_certificateIdHasBeenSet;
/**
* 原证书ID
*/
std::string m_oldCertificateId;
bool m_oldCertificateIdHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_SSL_V20191205_MODEL_DESCRIBEHOSTUPDATERECORDREQUEST_H_
|
36cbc87f24e508d649bee75e310f5cbfc7827c61
|
6bbc993501c67b301cc3d92f62e08f69ddbbcb43
|
/1001-1100/1094.cpp
|
056b3e7925631c7e79f51cbd96b966bd6568db4c
|
[] |
no_license
|
CodeDiary18/CodeUp
|
5dbc6c7f8065c459ac6d3a9b24ce87c63bda0644
|
43ad933ea6f8eec3793b3de00be0840b346a36df
|
refs/heads/main
| 2023-01-23T07:04:07.256397
| 2020-11-21T15:25:18
| 2020-11-21T15:25:18
| 313,769,195
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 206
|
cpp
|
1094.cpp
|
#include <iostream>
using namespace std;
int i, k;
int arr[10000];
int main()
{
cin >> k;
for (i = 0; i < k; i++)
cin >> arr[i];
for (i = k - 1; i >= 0; i--)
cout << arr[i] << ' ';
return 0;
}
|
16f35f32c0da5d03deb2f6fa0dc80f3a82f0b3ea
|
e7504e796df90bfe606781c14442a564eb01754b
|
/src/input/VRFakeTrackerDevice.cpp
|
9765cda9ac777f726f5cabd3b5239849f3ec3fa0
|
[
"BSD-3-Clause"
] |
permissive
|
MinVR/MinVR
|
1dc4c007b10f184732d3a90e362175c8e950e95b
|
33386e6b49de6c6b75f735704ffa49ab6069f8bf
|
refs/heads/master
| 2022-06-28T19:50:09.692509
| 2022-05-17T21:44:13
| 2022-05-17T21:44:13
| 40,127,890
| 23
| 21
|
NOASSERTION
| 2022-05-17T21:44:14
| 2015-08-03T14:02:01
|
C++
|
UTF-8
|
C++
| false
| false
| 12,029
|
cpp
|
VRFakeTrackerDevice.cpp
|
#include "VRFakeTrackerDevice.h"
#include <math/VRMath.h>
#include <api/VRTrackerEvent.h>
namespace MinVR {
VRFakeTrackerDevice::VRFakeTrackerDevice(const std::string &trackerName,
const std::string &toggleOnOffEventName,
const std::string &rotateEventName,
const std::string &rollEventName,
const std::string &translateEventName,
const std::string &translateZEventName,
float xyScale,
float zScale,
float rotScale,
bool sticky,
bool seeker,
VRVector3 lookAtEye,
VRVector3 lookAtCenter,
VRVector3 lookAtUp)
{
_trackerName = trackerName;
_eventName = trackerName + "_Move";
_toggleEvent = toggleOnOffEventName;
_rotateOnEvent = rotateEventName + "_Down";
_rotateOffEvent = rotateEventName + "_Up";
_translateOnEvent = translateEventName + "_Down";
_translateOffEvent = translateEventName + "_Up";
_translateZOnEvent = translateZEventName + "_Down";
_translateZOffEvent = translateZEventName + "_Up";
_rollOnEvent = rollEventName + "_Down";
_rollOffEvent = rollEventName + "_Up";
_xyScale = xyScale;
_zScale = zScale;
_rScale = rotScale;
_sticky = sticky;
_seeker = seeker;
_tracking = false;
_state = VRFakeTrackerDevice::XYTranslating;
_statePos = lookAtEye;
VRVector3 forward = lookAtEye - lookAtCenter;
forward = forward.normalize();
VRVector3 x = lookAtUp.cross(forward).normalize();
VRVector3 up = forward.cross(x);
_stateRot = VRMatrix4::fromRowMajorElements( x[0], up[0], forward[0], 0,
x[1], up[1], forward[1], 0,
x[2], up[2], forward[2], 0,
0, 0, 0, 1);
_transform = VRMatrix4::translation(_statePos) * _stateRot;
VRDataIndex di = VRTrackerEvent::createValidDataIndex(_eventName, _transform.toVRFloatArray());
_pendingEvents.push(di);
// Explain how to use it, if we're logging.
VRLOG_H2("Initializing fake tracker: " + trackerName);
VRLOG_STATUS(printInstructions().c_str());
}
VRFakeTrackerDevice::~VRFakeTrackerDevice()
{
}
void VRFakeTrackerDevice::onVREvent(const VRDataIndex &eventData)
{
if (eventData.getName() == _toggleEvent) {
_tracking = !_tracking;
if (_tracking) {
if (_sticky) {
_state = VRFakeTrackerDevice::XYTranslating;
} else {
_state = VRFakeTrackerDevice::None;
}
}
}
else if (eventData.getName() == _translateZOnEvent) {
if (_state != VRFakeTrackerDevice::ZTranslating) {
_state = VRFakeTrackerDevice::ZTranslating;
} else {
_state = VRFakeTrackerDevice::None;
}
}
else if (eventData.getName() == _translateOnEvent) {
if (_state != VRFakeTrackerDevice::XYTranslating) {
_state = VRFakeTrackerDevice::XYTranslating;
} else {
_state = VRFakeTrackerDevice::None;
}
}
else if (eventData.getName() == _rotateOnEvent) {
if (_state != VRFakeTrackerDevice::Rotating) {
_state = VRFakeTrackerDevice::Rotating;
} else {
_state = VRFakeTrackerDevice::None;
}
}
else if (eventData.getName() == _rollOnEvent) {
if (_state != VRFakeTrackerDevice::Rolling) {
_state = VRFakeTrackerDevice::Rolling;
} else {
_state = VRFakeTrackerDevice::None;
}
}
else if (eventData.getName() == _translateZOffEvent && !_sticky) {
_state = VRFakeTrackerDevice::None;
}
else if (eventData.getName() == _translateOffEvent && !_sticky) {
_state = VRFakeTrackerDevice::None;
}
else if (eventData.getName() == _rotateOffEvent && !_sticky) {
_state = VRFakeTrackerDevice::None;
}
else if (eventData.getName() == _rollOffEvent && !_sticky) {
_state = VRFakeTrackerDevice::None;
}
else if (eventData.getName() == "Mouse_Move") {
const VRFloatArray screenPos = eventData.getValue("NormalizedPosition");
if (!screenPos.empty()) {
// Transform range from [0,1] to [-1,1].
float mousex = 2.0f * (screenPos[0] - 0.5f);
float mousey = 2.0f * ((1.0f - screenPos[1]) - 0.5f);
// If we're not currently tracking, ignore the mouse.
if (_tracking) {
float deltaX = mousex - _lastMouseX;
float deltaY = mousey - _lastMouseY;
if (_state == VRFakeTrackerDevice::ZTranslating) {
// If we're Z translating, that's up and down in the seeker mode, but
// forward and backward in the looker mode.
if (_seeker) {
_statePos = VRVector3(0, _zScale * deltaY, 0) + _statePos;
} else {
_statePos = VRVector3(0, 0, _zScale * deltaY) + _statePos;
}
}
else if (_state == VRFakeTrackerDevice::Rotating) {
// The seeker mode turns the viewer around in place, while the looker
// mode rotates the object in front of the viewer. More or less.
VRMatrix4 r;
if (_seeker) {
VRVector3 up = _stateRot * VRVector3(0.0f, 1.0f, 0.0f);
// Not sure why these coordinates have to be negated.
VRPoint3 here = VRPoint3(-_statePos[0], -_statePos[1], -_statePos[2]);
VRVector3 over = up.cross(_statePos);
r = VRMatrix4::rotation(here, up, _rScale * deltaX) *
VRMatrix4::rotation(here, over, _rScale * deltaY);
} else {
r = VRMatrix4::rotationY(_rScale * deltaX) *
VRMatrix4::rotationX(-_rScale * deltaY);
}
_stateRot = r * _stateRot;
}
else if (_state == VRFakeTrackerDevice::Rolling) {
VRMatrix4 r = VRMatrix4::rotationZ(_rScale * deltaX);
_stateRot = r * _stateRot;
}
else if (_state == VRFakeTrackerDevice::XYTranslating){
// The seeker mode moves us in the horizontal plane, while the looker
// mode moves us in a vertical plane.
if (_seeker) {
_statePos = _xyScale * VRVector3(deltaX, 0, deltaY) + _statePos;
} else {
_statePos = _xyScale * VRVector3(deltaX, deltaY, 0) + _statePos;
}
}
_transform = VRMatrix4::translation(_statePos) * _stateRot;
VRDataIndex di = VRTrackerEvent::createValidDataIndex(_eventName, _transform.toVRFloatArray());
_pendingEvents.push(di);
}
_lastMouseX = mousex;
_lastMouseY = mousey;
}
}
}
void VRFakeTrackerDevice::appendNewInputEventsSinceLastCall(VRDataQueue* inputEvents)
{
inputEvents->addQueue(_pendingEvents);
_pendingEvents.clear();
}
std::string VRFakeTrackerDevice::printInstructions() {
std::string out = "";
out += "Tracker " + _trackerName + " is listening to " + _eventName + " events.\n";
out += "Use " + _toggleEvent + " to toggle this tracker off and on.\n";
out += "Use " + _rotateOnEvent.substr(0, _rotateOnEvent.size() - 5);
out += std::string(" to rotate around X (pitch) and Y (yaw),");
out += " and " + _rollOnEvent.substr(0, _rollOnEvent.size() - 5);
out += std::string(" to rotate around Z (roll).\n");
out += "Use " + _translateOnEvent.substr(0, _translateOnEvent.size() - 5);
out += std::string(" to translate in X and Y,");
out += " and " + _translateZOnEvent.substr(0, _translateZOnEvent.size() - 5);
out += std::string(" to translate in Z.\n");
char tmp[50];
sprintf(tmp, "xyScale = %.3f, zScale = %.3f, rotation=%.3f",
_xyScale, _zScale, _rScale);
out += "The scale factors are: " + std::string(tmp) + "\n";
out += "Sticky mode is " + std::string(_sticky ? "on" : "off") + ",";
out += " and the observation style is '" + std::string(_seeker ? "seeker" : "looker") + "'.\n";
return out;
}
VRInputDevice*
VRFakeTrackerDevice::create(VRMainInterface *vrMain, VRDataIndex *config, const std::string &nameSpace) {
std::string devNameSpace = nameSpace;
// Find and/or set all the default values.
std::string trackerName = config->getValue("TrackerName", devNameSpace);
std::string toggleEvent = config->getValue("ToggleOnOffEvent", devNameSpace);
std::string rotateEvent = config->getValueWithDefault("RotateEvent",
std::string("Kbdr"),
devNameSpace);
std::string translateEvent = config->getValueWithDefault("TranslateEvent",
std::string("Kbdw"),
devNameSpace);
std::string translateZEvent = config->getValueWithDefault("TranslateZEvent",
std::string("Kbdz"),
devNameSpace);
std::string rollEvent = config->getValueWithDefault("RollEvent",
std::string("Kbde"),
devNameSpace);
float xyScale =
config->getValueWithDefault("XYTranslationScale", 1.0f, devNameSpace);
float zScale =
config->getValueWithDefault("ZTranslationScale", 1.0f, devNameSpace);
float rScale = config->getValueWithDefault("RotationScale",
3.1415926f, devNameSpace);
int sticky = config->getValueWithDefault("Sticky", 0, devNameSpace);
std::string style = config->getValueWithDefault("Style",
std::string("Looker"),
devNameSpace);
// We only have two styles, so we can use a boolean for it. (Note that the
// 'compare()' method returns a zero when the strings match.)
bool seeker = !style.compare("Seeker");
float pos[] = {0, 0, -1};
float ctr[] = {0, 0, 0};
float up[] = {0, 1, 0};
VRFloatArray defaultPos (pos, pos + sizeof(pos) / sizeof(pos[0]));
VRFloatArray defaultCtr (ctr, ctr + sizeof(ctr) / sizeof(ctr[0]));
VRFloatArray defaultUp (up, up + sizeof(up) / sizeof(up[0]));
VRVector3 startPos = config->getValueWithDefault("LookAtEye",
defaultPos, devNameSpace);
VRVector3 startCtr = config->getValueWithDefault("LookAtCenter",
defaultCtr, devNameSpace);
VRVector3 startUp = config->getValueWithDefault("LookAtUp",
defaultUp, devNameSpace);
// Make a new object.
VRFakeTrackerDevice *dev = new VRFakeTrackerDevice(trackerName,
toggleEvent,
rotateEvent,
rollEvent,
translateEvent,
translateZEvent,
xyScale,
zScale,
rScale,
sticky,
seeker,
startPos,
startCtr,
startUp);
vrMain->addEventHandler(dev);
return dev;
}
} // end namespace
|
c58d16ccc548517788e890c61cf00f0d915f16de
|
b1115ba5b162f7dba9324f53d09694857ffee313
|
/physics/src/Shapes.cpp
|
0de832422fb444a251bc56ea02ae18bdbc1d174b
|
[] |
no_license
|
eweitnauer/TangramRobot
|
cf0ec43f232252673c7a6a55ec5ef2c1f3c013c4
|
1c40e0b04dcb4fbf5876f06b4a28a0e2b7651be3
|
refs/heads/master
| 2016-09-06T00:49:38.596706
| 2010-08-26T09:14:10
| 2010-08-26T09:14:10
| 863,567
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,417
|
cpp
|
Shapes.cpp
|
// Copyright 2009 Erik Weitnauer
#include "Shapes.h"
#include <vector>
#include <LinearMath/btGeometryUtil.h>
#include <LinearMath/btAlignedObjectArray.h>
#include <iostream>
#include <stdexcept>
using namespace std;
float Shapes::sf_sq = 0.5411;
float Shapes::sf_pa = 0.5524;
float Shapes::sf_st = 0.461;
float Shapes::sf_mt = 0.461;
float Shapes::sf_lt = 0.461;
btVector3 Shapes::getInertiaTensor(ShapeType shape, float base_length, float height, float mass) {
float a = base_length;
float h = height;
switch(shape) {
case UNKNOWN:;
case SQUARE: return (mass/12.)*btVector3(a*a+h*h, 2.*a*a, a*a+h*h);
case PARALLELOGRAM: return (mass/12.)*btVector3(0.5*a*a+h*h, 3.*a*a, 2.5*a*a+h*h);
case SMALL_TRIANGLE: return (mass/8.)*btVector3((5./9.)*a*a+0.5*h*h, (65./36.)*a*a, (5./4.)*a*a+h*h);
case MEDIUM_TRIANGLE: return (mass/8.)*btVector3((10./9.)*a*a+0.5*h*h, (65./18.)*a*a, (5./2.)*a*a+h*h);
case LARGE_TRIANGLE: return (mass/8.)*btVector3((20./9.)*a*a+0.5*h*h, (65./9.)*a*a, 5.*a*a+h*h);
default: throw std::runtime_error("Undefined shape type.");
}
}
void Shapes::setCorrectShapeFactors(float sq, float pa, float st, float mt, float lt) {
sf_sq = sq; sf_pa = pa; sf_st = st; sf_mt = mt; sf_lt = lt;
}
float Shapes::getCorrectShapeFactor(ShapeType shape) {
switch(shape) {
case UNKNOWN: return 1.;
case SQUARE: return sf_sq;
case PARALLELOGRAM: return sf_pa;
case SMALL_TRIANGLE: return sf_st;
case MEDIUM_TRIANGLE: return sf_mt;
case LARGE_TRIANGLE: return sf_lt;
default: throw std::runtime_error("Undefined shape type.");
}
return 1;
}
btConvexHullShape* Shapes::createShape(ShapeType shape, float base_length, float height, float ground_scale, float collision_margin) {
if (ground_scale<=0) {
// use default ground scaling
switch(shape) {
case SQUARE: return createSquareShape(base_length, height);
case PARALLELOGRAM: return createParallelogramShape(base_length, height);
case SMALL_TRIANGLE: return createTriangleShape(base_length, height);
case MEDIUM_TRIANGLE: return createTriangleShape(sqrt(2)*base_length, height);
case LARGE_TRIANGLE: return createTriangleShape(2*base_length, height);
default: throw std::runtime_error("Unknown shape type.");
}
} else {
// used passed ground scaling
switch(shape) {
case SQUARE: return createSquareShape(base_length, height, ground_scale);
case PARALLELOGRAM: return createParallelogramShape(base_length, height, ground_scale);
case SMALL_TRIANGLE: return createTriangleShape(base_length, height, ground_scale);
case MEDIUM_TRIANGLE: return createTriangleShape(sqrt(2)*base_length, height, ground_scale);
case LARGE_TRIANGLE: return createTriangleShape(2*base_length, height, ground_scale);
default: throw std::runtime_error("Unknown shape type.");
}
}
return NULL;
}
std::vector<float> &Shapes::scale(std::vector<float> &vec, float a) {
for (unsigned int i=0; i<vec.size(); ++i) vec[i] *= a;
return vec;
}
std::vector<float> Shapes::getCorners(ShapeType shape, float base_length) {
static float sqrt2 = sqrt(2.);
static float sq[] = {-0.5,-0.5, -0.5,0.5, 0.5,0.5, 0.5,-0.5};
// static float pa[] = {-0.75*sqrt2,+0.25*sqrt2, +0.25*sqrt2,+0.25*sqrt2,
// +0.75*sqrt2,-0.25*sqrt2, -0.25*sqrt2,-0.25*sqrt2};
static float pa_[] = {-0.75*sqrt2,-0.25*sqrt2, +0.25*sqrt2,-0.25*sqrt2,
+0.75*sqrt2,+0.25*sqrt2, -0.25*sqrt2,+0.25*sqrt2};
static float tr[] = {-sqrt2/2.,-sqrt2/6., 0,sqrt2/3., sqrt2/2.,-sqrt2/6.};
static vector<float> v;
switch(shape) {
case SQUARE: v = vector<float>(sq,sq+8); return scale(v, base_length);
case PARALLELOGRAM: v = vector<float>(pa_,pa_+8); return scale(v, base_length);
case SMALL_TRIANGLE: v = vector<float>(tr,tr+6); return scale(v, base_length);
case MEDIUM_TRIANGLE: v = vector<float>(tr,tr+6); return scale(v, base_length*sqrt2);
case LARGE_TRIANGLE: v = vector<float>(tr,tr+6); return scale(v, base_length*2);
default: throw std::runtime_error("Unknown shape type.");
}
}
btConvexHullShape* Shapes::createFlatObject(const std::vector<float> &corners2d,
float base_length, float height, float ground_scale) {
btConvexHullShape* shape = new btConvexHullShape();
for (unsigned int i=0; i<corners2d.size()/2; i++) {
btVector3 vtx(corners2d[i*2]*base_length, 8*height/16, corners2d[i*2+1]*base_length);
shape->addPoint(vtx);
}
for (int i=corners2d.size()/2-1; i>=0; i--) {
btVector3 vtx(corners2d[i*2]*base_length, -6*height/16, corners2d[i*2+1]*base_length);
shape->addPoint(vtx);
}
for (int i=corners2d.size()/2-1; i>=0; i--) {
btVector3 vtx(corners2d[i*2]*base_length*ground_scale, -8*height/16, corners2d[i*2+1]*base_length*ground_scale);
shape->addPoint(vtx);
}
return shape;
}
btConvexHullShape* Shapes::createTriangleShape(float base_length, float height, float ground_scale, float collision_margin) {
if (collision_margin == 0)
return createFlatObject(getCorners(SMALL_TRIANGLE,1), base_length, height, ground_scale);
else return createFlatObjectInclCollMargin(getCorners(SMALL_TRIANGLE,1), base_length, height, ground_scale, collision_margin);
}
btConvexHullShape* Shapes::createSquareShape(float base_length, float height, float ground_scale, float collision_margin) {
if (collision_margin == 0)
return createFlatObject(getCorners(SQUARE,1), base_length, height, ground_scale);
else return createFlatObjectInclCollMargin(getCorners(SQUARE,1), base_length, height, ground_scale, collision_margin);
}
btConvexHullShape* Shapes::createParallelogramShape(float base_length, float height, float ground_scale, float collision_margin) {
if (collision_margin == 0)
return createFlatObject(getCorners(PARALLELOGRAM,1), base_length, height, ground_scale);
else return createFlatObjectInclCollMargin(getCorners(PARALLELOGRAM,1), base_length, height, ground_scale, collision_margin);
}
//btBoxShape* Shapes::createSquareShapeNative(float base_length, float height) {
// btBoxShape* shape = new btBoxShape(btVector3(base_length/2, height/2, base_length/2));
// return shape;
//}
btConvexHullShape* Shapes::createFlatObjectInclCollMargin(const std::vector<float> &corners2d, float base_length, float height, float ground_scale, float collision_margin) {
btAlignedObjectArray<btVector3> vertices;
for (unsigned int i=0; i<corners2d.size()/2; i++) {
btVector3 vtx(corners2d[i*2]*base_length, 8*height/16, corners2d[i*2+1]*base_length);
vertices.push_back(vtx);
}
for (int i=corners2d.size()/2-1; i>=0; i--) {
btVector3 vtx(corners2d[i*2]*base_length, -6*height/16, corners2d[i*2+1]*base_length);
vertices.push_back(vtx);
}
for (int i=corners2d.size()/2-1; i>=0; i--) {
btVector3 vtx(corners2d[i*2]*base_length*ground_scale, -8*height/16, corners2d[i*2+1]*base_length*ground_scale);
vertices.push_back(vtx);
}
btAlignedObjectArray<btVector3> planeEquations;
btGeometryUtil::getPlaneEquationsFromVertices(vertices,planeEquations);
btAlignedObjectArray<btVector3> shiftedPlaneEquations;
for (int p=0;p<planeEquations.size();p++) {
btVector3 plane = planeEquations[p];
plane[3] += collision_margin;
shiftedPlaneEquations.push_back(plane);
}
btAlignedObjectArray<btVector3> shiftedVertices;
btGeometryUtil::getVerticesFromPlaneEquations(shiftedPlaneEquations,shiftedVertices);
return new btConvexHullShape(&(shiftedVertices[0].getX()),shiftedVertices.size());
}
|
8351327b096d252ab800244e88dd294893a60f98
|
b1072cc3c2b32073466d530d6a3724fe2256da3e
|
/src/nedxml/nedyydefs.h
|
08d7fc54a55c7e041a2230d1a46c75be5c7847ff
|
[] |
no_license
|
ayjavaid/OMNET_OS3_UAVSim
|
e66af63ec5988d7b87684a80529690732986b558
|
2a002daa1b32bf3d6883271f0226b70076c32485
|
refs/heads/master
| 2021-05-15T01:32:08.590544
| 2018-09-25T18:02:42
| 2018-09-25T18:02:42
| 30,726,345
| 7
| 10
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,431
|
h
|
nedyydefs.h
|
//==========================================================================
// NEDYYDEFS.H - part of
//
// OMNeT++/OMNEST
// Discrete System Simulation in C++
//
//==========================================================================
/*--------------------------------------------------------------*
Copyright (C) 2002-2008 Andras Varga
Copyright (C) 2006-2008 OpenSim Ltd.
This file is distributed WITHOUT ANY WARRANTY. See the file
`license' for details on this and other legal matters.
*--------------------------------------------------------------*/
#ifndef __NEDYYDEFS_H
#define __NEDYYDEFS_H
#include "nedxmldefs.h"
//
// misc bison/flex related stuff, shared among *.lex, *.y and nedparser.cc/h files
//
NAMESPACE_BEGIN
class NEDElement;
class NEDParser;
NAMESPACE_END
#ifdef YYLTYPE
#error 'YYLTYPE defined before nedyydefs.h -- type clash?'
#endif
struct my_yyltype {
int dummy;
int first_line, first_column;
int last_line, last_column;
char *text;
};
#define YYLTYPE struct my_yyltype
#define YYSTYPE OPP::NEDElement*
NAMESPACE_BEGIN
typedef struct {int li; int co;} LineColumn;
extern LineColumn pos, prevpos;
NAMESPACE_END
OPP::NEDElement *doParseNED2(OPP::NEDParser *p, const char *nedtext);
OPP::NEDElement *doParseNED1(OPP::NEDParser *p, const char *nedtext);
OPP::NEDElement *doParseMSG2(OPP::NEDParser *p, const char *nedtext);
#endif
|
83ecca824b81106cb365e65faab124121dbc6a4c
|
d8c27c030c6666f9a61c2e4b96ae8a8ec2b7e0a3
|
/Jugador.h
|
952c278d1fa1128f43608ff694cb3b8823de8d63
|
[] |
no_license
|
alessadge/Alessandro_Grimaldi_lab10
|
cf269b5eb478fb836bc10a83cbfb3173395d5c2e
|
bb1ce2bd5a3f613134dcef97aad8340c96fb7eaf
|
refs/heads/master
| 2021-01-21T13:49:25.930692
| 2017-06-24T00:04:12
| 2017-06-24T00:04:12
| 95,248,685
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 540
|
h
|
Jugador.h
|
#include <iostream>
#include <string>
#include "Persona.h"
using namespace std;
#ifndef JUGADOR_H
#define JUGADOR_H
class Jugador:public Persona{
protected:
string procedencia;
string apodo;
int dinero;
public:
Jugador(string,int,int,string,string,int);
Jugador();
string getProcedencia();
void setProcedencia(string);
string getApodo();
void setApodo(string);
int getDinero();
void setDinero(int);
virtual void metodo();
};
#endif
|
4259e2c15e109cd6fd21d51adea393c273564b11
|
eb427f15f776628044d59b43d0b370b9c91dbee8
|
/direction_scanner.ino
|
3e5ab4ee73c36c513b30f16c90de69afcf34662f
|
[] |
no_license
|
eboiko8003/Team-334-project-repository
|
8c34cae6623e6d4d381385901de4db32cf298b82
|
50369ce2d4a12c4a2b37cc7fd3424509726f2723
|
refs/heads/master
| 2020-03-30T11:34:47.803725
| 2018-10-13T13:29:10
| 2018-10-13T13:29:10
| 151,181,310
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,093
|
ino
|
direction_scanner.ino
|
#include <Servo.h>
Servo myServo;
Servo servoLeft;
Servo servoRight;
int pingPin = 3;
float duration;
float left;
float right;
float front;
void setup() {
// put your setup code here, to run once:
myServo.attach(11);
servoLeft.attach(10);
servoRight.attach(12);
digitalWrite(2, HIGH);
Serial.begin(9600);
}
void loop() {
myServo.write(90);
pulse();
//Serial.println(duration);
servoRight.writeMicroseconds(1000);
servoLeft.writeMicroseconds(1600);
if(duration <1000){
halt();
scan();
if(left < right){
Serial.println("Go right");
turnRight(500);
}
else{
Serial.println("Go left");
turnLeft(500);
}
}
delay(750);
}
void pulse(){
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
}
void scan(){
myServo.write(0);
//Serial.println("Position 0");
delay(1000);
pulse();
right = duration;
//Serial.print("right is ");
//Serial.println(right);
delay(1000);
myServo.write(90);
//Serial.println("Position 90");
delay(1000);
pulse();
front = duration;
//Serial.print("front is ");
//Serial.println(front);
delay(1000);
myServo.write(180);
//Serial.println("Position 180");
delay(1000);
pulse();
left = duration;
//Serial.print("left is ");
//Serial.println(left);
delay(1000);
myServo.write(90);
}
/*void forward(){
servoRight.writeMicroseconds(1000);
servoLeft.writeMicroseconds(2000);
Serial.println("going forward");
}
*/
void backward(){
servoRight.writeMicroseconds(2000);
servoLeft.writeMicroseconds(1000);
}
void halt(){
servoLeft.writeMicroseconds(1500);
servoRight.writeMicroseconds(1500);
}
void turnLeft(int ms){
servoRight.writeMicroseconds(1000);
servoLeft.writeMicroseconds(1500);
delay(ms);
}
void turnRight(int ms){
servoRight.writeMicroseconds(1500);
servoLeft.writeMicroseconds(2000);
delay(ms);
}
|
61da2589faeb259550a6bbcc65631b42b3bbfe03
|
01446dd51317a23f28de5f56df2ae7485fe89f7c
|
/Classes/Game/Scene/Main/Tutorial.h
|
0cfbcc7ef94583ed5fdb97ae31215ec9c69b8b3c
|
[] |
no_license
|
TeamMBEnd/FishLight
|
98315516088e5ea8f4fc48212c24221244ac7d83
|
7e7f9e652101e5bdad04ef2313f9c1145e63180e
|
refs/heads/master
| 2016-09-06T02:26:33.101264
| 2015-07-31T08:56:05
| 2015-07-31T08:56:05
| 30,166,261
| 0
| 8
| null | 2015-03-14T13:29:28
| 2015-02-02T01:30:24
|
C++
|
UTF-8
|
C++
| false
| false
| 706
|
h
|
Tutorial.h
|
#ifndef TUTORIAL_H
#define TUTORIAL_H
#include "cocos2d.h"
USING_NS_CC;
class Player;
namespace Scenes{
/*-----------------------------------------------------
チュートリアル画面生成用クラス
ファイル名 Tutorial.h
作成者 小林 大峰
------------------------------------------------------*/
class Tutorial{
public:
/*----------------------------------------
チュートリアル画面を作成
・枠を作り、アニメーション用の
画像は子Nodeに追加
return Sprite* チュートリアル画面
----------------------------------------*/
Sprite* createWindow();
void update(Layer* layer, Player* player);
};
}
#endif
|
23542bc6fb59d7fa360e5a10530f1b47ad42c0e7
|
737bd9818fb712801371d3552a6ee41d92bbd33e
|
/src/MFCExt/DCGFApp.cpp
|
0097c05852b74c8c3e59f441cfb3f87d39f72e24
|
[
"MIT"
] |
permissive
|
segafan/wme1_jankavan_tlc_edition-repo
|
9bf8afb542d3a4a3949bf61c881927df4942410e
|
72163931f348d5a2132577930362d297cc375a26
|
refs/heads/master
| 2020-12-24T17:54:12.910112
| 2015-04-26T23:03:42
| 2015-04-26T23:03:42
| 38,780,832
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,426
|
cpp
|
DCGFApp.cpp
|
// DCGFApp.cpp : implementation file
//
#include "stdafx.h"
#include "DCGFApp.h"
#include "DCGFMDIChildWindow.h"
#include "DCGFView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDCGFApp
IMPLEMENT_DYNCREATE(CDCGFApp, CWinApp)
//////////////////////////////////////////////////////////////////////////
CDCGFApp::CDCGFApp()
{
m_Active = false;
}
//////////////////////////////////////////////////////////////////////////
CDCGFApp::~CDCGFApp()
{
}
//////////////////////////////////////////////////////////////////////////
BOOL CDCGFApp::InitInstance()
{
char CurrentDir[MAX_PATH+1];
GetCurrentDirectory(MAX_PATH, CurrentDir);
AddProjectRoot(CString(CurrentDir));
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
int CDCGFApp::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinApp::ExitInstance();
}
BEGIN_MESSAGE_MAP(CDCGFApp, CWinApp)
//{{AFX_MSG_MAP(CDCGFApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDCGFApp message handlers
//////////////////////////////////////////////////////////////////////////
BOOL CDCGFApp::OnIdle(LONG lCount)
{
if(m_Active){
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
if(pFrame==NULL) return FALSE;
// Get the active MDI child window.
CDCGFMDIChildWindow* pChild = (CDCGFMDIChildWindow*)pFrame->GetActiveFrame();
if(pChild==NULL || !pChild->IsKindOf(RUNTIME_CLASS(CDCGFMDIChildWindow))) return FALSE;
CView *pView = pChild->m_View;
if(pView==NULL || !pView->GetSafeHwnd()) return FALSE;
if(pView->IsKindOf(RUNTIME_CLASS(CDCGFView))) pView->Invalidate();
CWinApp::OnIdle(lCount);
return TRUE;
}
return CWinApp::OnIdle(lCount);
}
//////////////////////////////////////////////////////////////////////////
void CDCGFApp::AddProjectRoot(CString Folder)
{
if(Folder=="") return;
Folder.Replace('/', '\\');
if(Folder[Folder.GetLength()-1]!='\\') Folder+='\\';
for(int i=0; i<m_ProjectRoots.GetSize(); i++){
if(m_ProjectRoots[i]==Folder) return;
}
m_ProjectRoots.Add(Folder);
}
|
38d1269d3893d3fbfe7eff395e0a1d86bf9ed780
|
2b39e712e43b8b1209ce9a6f585a48a698510ef7
|
/cpp/find_starting_pos_in_map.cpp
|
5997c1b3e79d30517ce29c1f0b8e1eb492f36d85
|
[] |
no_license
|
nshahpazov/finals-preparation
|
ded39b0487ce71a15e027c98d80522924f409110
|
773f596ad9b2776796efb8a14a4704d2fe0dca4e
|
refs/heads/master
| 2020-03-22T20:07:55.825658
| 2018-09-09T11:02:53
| 2018-09-09T11:02:53
| 140,574,846
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,168
|
cpp
|
find_starting_pos_in_map.cpp
|
#include <iostream>
#include <string.h>
using namespace std;
/*
Дадена е квадратна матрица от цели числа с размери 10x10,
която описва лабиринт. Стойност 0 в дадена клетка означава „стена“,
а стойност 1 означа „проходима клетка“.
Даден е символен низ, съдържащ само буквите E, W, N и S,
които указват едностъпкови придвижвания в съответните географски посоки:
N – нагоре, E – надясно, S – надолу, W – наляво.
Да се напише функция walk, която получава матрица и символен низ от вида,
определен по-горе и проверява дали символният низ задава валиден път започващ
от някоя проходима клетка на лабиринта, състоящ се само от проходими клетки и
завършващ в долния десен ъгъл на лабиринта. Функцията да връща
булева стойност – истина, ако такава клетка има и даденият низ
задава валиден път и лъжа в противен случай.
*/
int map[10][10] = {
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,0,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1}
};
bool walk(int map[10][10], const char* commands)
{
size_t n = strlen(commands);
int i = 9;
int j = 9;
while (n--) {
j += commands[n] == 'W' ? 1 : (commands[n] == 'E' ? -1 : 0);
i += commands[n] == 'N' ? 1 : (commands[n] == 'S' ? -1 : 0);
if (map[i][j] == 0) {
return false;
}
}
return true;
}
int main()
{
cout << (walk(map, "SESESEE") ? "YES" : "NO") << endl;
return 0;
}
|
15a65cd6e99d3afb66b683fa3de90db28b46da15
|
9d455eae3c17f2f477cf6bee28a4d40a0c7e4b03
|
/include/audioworkspace.hh
|
804d518ec0d92aa20a171d6b5e5ec330d0cb41ad
|
[] |
no_license
|
gitGNU/gnu_aldo
|
fe523f92730c3e6ec6dcfb663c5ac82e4c639474
|
c2cbeb215a66a606ed01b58fc0be513ebb373e7c
|
refs/heads/master
| 2023-09-04T06:31:12.678175
| 2013-07-16T10:33:43
| 2013-07-16T10:33:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,452
|
hh
|
audioworkspace.hh
|
// -*- C++ -*-
/***************************************************************************
libaudiostream
--------------------
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Giuseppe "denever" Martino
begin : Sat 9 Mar 2002
email : denever@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef AUDIOWORKSPACE_H
#define AUDIOWORKSPACE_H
#include "wave.hh"
#include <string>
namespace libaudiostream
{
class oastream;
class AudioWorkSpace
{
public:
AudioWorkSpace(std::string);
AudioWorkSpace(size_type, size_type, size_type, size_type, std::string);
AudioWorkSpace(const Wave&);
virtual ~AudioWorkSpace();
oastream create_output_stream();
Wave gen_pause(size_type);
Wave gen_sine_wave(size_type, double, double);
private:
size_type m_bits;
size_type m_sample_rate;
size_type m_channels;
size_type m_byte_format;
std::string m_device;
};
}
#endif //AUDIOWORKSPACE_H
|
58ff14d7fa4b342a375f2753ffd4c10a9ccf37db
|
8b18a688f92121fea6b3bec6c47a14a964869e01
|
/lib/RecordWidget.cpp
|
61402b463700fdb42619f253dbe011608a91f7c7
|
[] |
no_license
|
wengsht/oh_my_life2
|
3fd98466c17ef6ca4406891f7eb313935fe6bfb7
|
b96468d76b8e05eeb83bb97734a85658f306f6a3
|
refs/heads/master
| 2016-09-05T16:22:11.385518
| 2014-03-12T08:45:48
| 2014-03-12T08:45:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,030
|
cpp
|
RecordWidget.cpp
|
#include "RecordWidget.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QWidget>
#include <QTableWidgeTItem>
#include <QMessageBox>
#include <string>
#include <iostream>
#include "QT.def"
using namespace std;
pair<int, int> RecordWidget::getLatestHM() {
#include "sql.def"
int nC = table->rowCount();
int h = 0, m = 0;
for(int I = 0; I < nC - 1; I++) {
int th = ((table->item(I, QT_ENDH_COLUMN))->text()).toInt();
int tm = ((table->item(I, QT_ENDM_COLUMN))->text()).toInt();
if(h < th || h == th && m < tm) {
h = th;
m = tm;
}
}
return make_pair(h, m);
}
void RecordWidget::addRecord() {
table->setRowCount(table->rowCount()+1);
Record newRecord;
pair<int, int> hm = getLatestHM();
newRecord.setBeginTime(today.year(), today.month(), today.day(), hm.first, hm.second);
newRecord.setEndTime(today.year(), today.month(), today.day(), hm.first, hm.second);
recordPocket->addRecord(newRecord);
relistRecord(table->rowCount() - 1);
}
void RecordWidget::tagsGenerate() {
QPushButton *senderButton = qobject_cast<QPushButton *>(sender());
if(senderButton == NULL) return ;
QModelIndex index = table->indexAt(QPoint(senderButton->frameGeometry().x(),senderButton->frameGeometry().y()));
int row = index.row();
#include "sql.def"
string name = ((table->item(row, QT_NAME_COLUMN))->text()).toStdString();
string tags = "";
db->getTagsStringByName(name, tags);
table->setItem(row, QT_TAGS_COLUMN, new QTableWidgetItem(tags.c_str()));
}
void RecordWidget::removeRow() {
int ret = QMessageBox::question(this, "删除记录", "确定删除本行?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if(ret == QMessageBox::Yes) {
QPushButton *senderButton = qobject_cast<QPushButton *>(sender());
if(senderButton == NULL) return ;
QModelIndex index = table->indexAt(QPoint(senderButton->frameGeometry().x(),senderButton->frameGeometry().y()));
int row = index.row();
table->removeRow(row);
recordPocket->removeRecord(row);
}
}
void RecordWidget::relistRecord(int I) {
#include "sql.def"
QPushButton * removeButton = new QPushButton("删除");
QPushButton * tagsButton = new QPushButton("推荐tags");
table->setCellWidget(I, QT_COLUMNS, removeButton);
table->setCellWidget(I, QT_COLUMNS+1, tagsButton);
QObject::connect(removeButton, SIGNAL(clicked()), this, SLOT(removeRow()));
QObject::connect(tagsButton, SIGNAL(clicked()), this, SLOT(tagsGenerate()));
#define TABLE_INIT_ITEM(J, text) \
table->setItem(I, J, new QTableWidgetItem(text));
TABLE_INIT_ITEM(0, (*recordPocket)[I].getName().c_str())
TABLE_INIT_ITEM(1, QString::number((*recordPocket)[I].getBeginH()))
TABLE_INIT_ITEM(2, QString::number((*recordPocket)[I].getBeginM()))
TABLE_INIT_ITEM(3, QString::number((*recordPocket)[I].getEndH()))
TABLE_INIT_ITEM(4, QString::number((*recordPocket)[I].getEndM()))
TABLE_INIT_ITEM(5, (*recordPocket)[I].getTagsAsString().c_str())
TABLE_INIT_ITEM(6, QString::number((*recordPocket)[I].getNums()))
TABLE_INIT_ITEM(7, (*recordPocket)[I].getComment().c_str())
}
void RecordWidget::relist() {
table->setRowCount(recordPocket->recordSize());
#include "sql.def"
string strs[] = { QT_COLUMN_LIST };
for(int I = 0; I < recordPocket->recordSize();I++) {
relistRecord(I);
}
}
void RecordWidget::reload() {
int ret = QMessageBox::question(this, "确认加载", "未保存修改将丢失,确认继续加载?", QMessageBox::Yes | QMessageBox::No , QMessageBox::No);
if(ret == QMessageBox::No)
return ;
today = calendar->selectedDate();
recordPocket->clear();
recordPocket->resetDate(today.year(), today.month(), today.day(), 1);
db->readInRecordPocket(*recordPocket);
relist();
}
void RecordWidget::updateRecord(int row) {
#define TABLE_UPDATE_ITEM(J, code, toSomeThing) \
(*recordPocket)[row].code(((table->item(row, J))->text()).toSomeThing());
TABLE_UPDATE_ITEM(0, setName, toStdString);
TABLE_UPDATE_ITEM(1, setBeginH, toInt);
TABLE_UPDATE_ITEM(2, setBeginM, toInt);
TABLE_UPDATE_ITEM(3, setEndH, toInt);
TABLE_UPDATE_ITEM(4, setEndM, toInt);
TABLE_UPDATE_ITEM(5, initTags, toStdString);
TABLE_UPDATE_ITEM(6, setNums, toDouble);
TABLE_UPDATE_ITEM(7, setComment, toStdString)
}
void RecordWidget::update() {
int ret = QMessageBox::question(this, "保存与否", "需要保存已修改数据?", QMessageBox::Yes | QMessageBox::No , QMessageBox::No);
if(ret == QMessageBox::No)
return ;
int I;
for(I = 0; I < recordPocket->recordSize(); I++) {
updateRecord(I);
}
db->updateDayRecord(*recordPocket);
}
RecordWidget::RecordWidget(DBm *db) : db(db) {
setFixedHeight(CENTRAL_HEIGHT);
QVBoxLayout *layout1 = new QVBoxLayout();
calendar = new QCalendarWidget();
today = calendar->selectedDate();
recordPocket = new RecordPocket(today.year(), today.month(), today.day(), 1);
db->readInRecordPocket(*recordPocket);
const int FixedLen = 300;
const double HP = 0.618;
calendar->setFixedWidth(FixedLen);
calendar->setFixedHeight(FixedLen * HP);
QHBoxLayout *layoutHead = new QHBoxLayout();
layoutHead->addWidget(calendar);
QPushButton *reloadButton = new QPushButton("加载");
QPushButton *updateButton = new QPushButton("保存");
QPushButton *addButton = new QPushButton("增添记录");
QObject::connect(reloadButton, SIGNAL(clicked()), this, SLOT(reload()));
QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(update()));
QObject::connect(addButton, SIGNAL(clicked()), this, SLOT(addRecord()));
reloadButton->setFixedWidth(HP * FixedLen );
reloadButton->setFixedHeight(HP * FixedLen );
updateButton->setFixedWidth(HP * FixedLen );
updateButton->setFixedHeight(HP * FixedLen );
addButton->setFixedWidth(HP * FixedLen );
addButton->setFixedHeight(HP * FixedLen );
QHBoxLayout *layoutButtons = new QHBoxLayout();
layoutButtons->addWidget(reloadButton);
layoutButtons->addWidget(updateButton);
layoutButtons->addWidget(addButton);
layoutHead->addLayout(layoutButtons);
QHBoxLayout *layoutTail = new QHBoxLayout();
initTable();
layoutTail->addWidget(table);
layout1->addLayout(layoutHead);
layout1->addLayout(layoutTail);
setLayout(layout1);
}
RecordWidget::~RecordWidget() {
}
void RecordWidget::initTable() {
table = new QTableWidget();
table->setRowCount(10);
table->setFixedWidth(1050);
table->setFixedHeight(400);
#include "sql.def"
table->setColumnCount(QT_COLUMNS+2);
QStringList *strList = new QStringList();
QString strs[] = { QT_COLUMN_LIST };
for(int I = 0; I < QT_COLUMNS; I++) {
strList->push_back(strs[I]);
}
table->setHorizontalHeaderLabels(*strList);
relist();
}
|
dc1da3263ec688dee80136fc009a6ec9cc8efec4
|
7fab117c5429000351bd0abc565451aab1882f3f
|
/leetcode_16_3SumCloest.cpp
|
8d64971856f8d3716daad1b21511385d384b59cc
|
[] |
no_license
|
BUPTxuxiangzi/xxz_leetcode
|
f7d180d66c8845f1131eeefe2b1b30d182ed5625
|
6a569a7a08e7632c12129bbd73b9f6b1fe1b037f
|
refs/heads/master
| 2020-06-06T14:56:42.673543
| 2015-06-01T14:48:44
| 2015-06-01T14:48:44
| 33,131,143
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,757
|
cpp
|
leetcode_16_3SumCloest.cpp
|
/*问题描述
3Sum Closest
Total Accepted: 33913 Total Submissions: 125849
Given an array S of n integers, find three integers in S such that the sum
is closest to a given number, target. Return the sum of the three integers.
You may assume that each input would have exactly one solution.
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
*/
///法一:暴力求解
//时间复杂度达到O(n3)
//结果:Time Limit Exceeded,所以这种方法是不可取的
class Solution {
public:
int threeSumClosest(vector<int> &num, int target)
{
int result = *num.begin() + *(num.begin() + 1) + *(num.begin() + 2);
int width = abs(target - result);
for (vector<int>::iterator i = num.begin(); i != num.end() - 2; i++)
{
for (vector<int>::iterator j = i + 1; j != num.end() - 1; j++)
{
for (vector<int>::iterator k = j + 1; k != num.end(); k++)
{
int t = *i + *j + *k;
int tmp = abs(target - t);
if (width > tmp)
{
result = tmp;
result = t;
}
}
}
}
return result;
}
};
/*
方法2,:先排序,在左右夹逼
时间复杂度O(nlogn + n2) = O(n2)
oj运行时间:54ms
*/
class Solution {
public:
int threeSumClosest(vector<int> &num, int target)
{
int result = 0;
int min_gap = INT_MAX;
sort(num.begin(), num.end());
for (auto a = num.begin(); a != prev(num.end(), 2); a++)
{
auto b = next(a);
auto c = prev(num.end());
while (b < c)
{
const int sum = *a + *b + *c;
const int gap = abs(target - sum);
if (gap < min_gap)
{
min_gap = gap;
result = sum;
}
if (sum < target) b++;
else c--;
}
}
return result;
}
};
|
897065a7ad7ad3f49177cfd2739d0d9e81ff945c
|
88b130d5ff52d96248d8b946cfb0faaadb731769
|
/vespalib/src/vespa/vespalib/test/make_tls_options_for_testing.h
|
0bc39deaeaf3b79342b5aa195585e71d57dcb1c0
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
vespa-engine/vespa
|
b8cfe266de7f9a9be6f2557c55bef52c3a9d7cdb
|
1f8213997718c25942c38402202ae9e51572d89f
|
refs/heads/master
| 2023-08-16T21:01:12.296208
| 2023-08-16T17:03:08
| 2023-08-16T17:03:08
| 60,377,070
| 4,889
| 619
|
Apache-2.0
| 2023-09-14T21:02:11
| 2016-06-03T20:54:20
|
Java
|
UTF-8
|
C++
| false
| false
| 977
|
h
|
make_tls_options_for_testing.h
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/tls/transport_security_options.h>
namespace vespalib::test {
/**
* Make a socket spec representing "tcp/localhost:123". Used by unit tests
* performing hostname verification against the tls options created
* below.
**/
SocketSpec make_local_spec();
/**
* Make security options allowing you to talk to yourself using
* TLS. This is intended for testing purposes only.
**/
vespalib::net::tls::TransportSecurityOptions make_tls_options_for_testing();
/**
* Make security options whose authz rules only grant the telemetry capability
* set to the included certificate.
*
* Only useful for testing capability propagation and filtering.
*/
vespalib::net::tls::TransportSecurityOptions make_telemetry_only_capability_tls_options_for_testing();
} // namespace vespalib::test
|
c99cd7ad7cc098fa784c868a6a2b4d0341619987
|
dd260bcbfdd75d10db13e3fd23f7499fb6639c38
|
/tests_scale_simple.cpp
|
584f8e92ac2019658ec1f3124b17e9ee4793026c
|
[] |
no_license
|
tr11/timescales
|
7fdedbd2a9f11978a2b3b2d208bbec2079cbf04f
|
813aae773d860c9670047b7c9f31a9f585606565
|
refs/heads/master
| 2021-01-18T21:33:35.774948
| 2013-12-12T22:13:05
| 2013-12-12T22:13:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,776
|
cpp
|
tests_scale_simple.cpp
|
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <iostream>
#include "timescales.hpp"
// using namespace timescales;
using boost::posix_time::ptime;
using boost::gregorian::date;
using boost::posix_time::time_duration;
using namespace timescales;
BOOST_AUTO_TEST_SUITE(tests_scales)
BOOST_AUTO_TEST_CASE(test_scales_scale_simple) {
const ptime p(date(2000,1,1));
const utc_days_scale sc(p);
{ // constructors
BOOST_CHECK_NO_THROW( utc_days_scale(p, 1) );
BOOST_CHECK_THROW( utc_days_scale(p, -1), std::logic_error );
BOOST_CHECK_THROW( utc_days_scale(boost::posix_time::not_a_date_time, 1), std::logic_error );
BOOST_CHECK_NO_THROW( utc_days_scale(p, p - time_duration(5,0,0), 1) );
BOOST_CHECK_THROW( utc_days_scale(p, p - time_duration(5,0,0), -1), std::logic_error );
BOOST_CHECK_THROW( utc_days_scale(boost::posix_time::not_a_date_time, p - time_duration(5,0,0), 1), std::logic_error );
BOOST_CHECK_NO_THROW( utc_days_scale(p).utc_time() );
BOOST_CHECK_EQUAL( utc_days_scale(sc), sc );
BOOST_CHECK_EQUAL( utc_days_scale(p - time_duration(5,0,0), sc), utc_days_scale(p - time_duration(5,0,0), p) );
}
{ // reference
BOOST_CHECK_EQUAL( utc_days_scale(p - time_duration(5,0,0), p).reference(), sc );
}
{ // assignment
utc_days_scale sc2(p + time_duration(24,0,0));
BOOST_CHECK_EQUAL( sc2 = sc, sc );
}
{ // arithmetic
utc_days_scale _sc = sc;
BOOST_CHECK_EQUAL( (++_sc).value(), 1 );
BOOST_CHECK_EQUAL( (_sc++).value(), 1 );
BOOST_CHECK_EQUAL( _sc.value(), 2 );
BOOST_CHECK_EQUAL( (--_sc).value(), 1 );
BOOST_CHECK_EQUAL( (_sc--).value(), 1 );
BOOST_CHECK_EQUAL( _sc.value(), 0 );
BOOST_CHECK_NO_THROW( _sc += 5 );
BOOST_CHECK_EQUAL( _sc.value(), 5 );
BOOST_CHECK_NO_THROW( _sc -= 2 );
BOOST_CHECK_EQUAL( _sc.value(), 3 );
BOOST_CHECK_EQUAL( (_sc + 10).value(), 13 );
BOOST_CHECK_EQUAL( (_sc - 10).value(), -7 );
}
{ // comparison
BOOST_CHECK_EQUAL(sc, sc);
BOOST_CHECK( sc != sc+1);
}
{ // length
utc_days_scale sc2(p + boost::posix_time::hours(24 * 20));
BOOST_CHECK_EQUAL( sc2 - sc, 20 );
BOOST_CHECK_EQUAL(sc.value(), 0);
BOOST_CHECK_EQUAL(sc2.value(), 0);
BOOST_CHECK_EQUAL((sc2+5).value(), 5);
}
{ // current time
BOOST_CHECK_EQUAL(sc.local_time().utc_time(), p);
BOOST_CHECK_EQUAL(sc.local_time().zone(), time_zone_const_ptr());
BOOST_CHECK_EQUAL(sc.utc_time(), p);
}
{ // string representation
std::stringstream out;
BOOST_CHECK_NO_THROW(out << sc);
BOOST_CHECK_EQUAL(out.str(), "20000101");
}
}
BOOST_AUTO_TEST_SUITE_END()
|
e12de3d2ab36c66fa2dac10bfb6b0d61cf842247
|
a25aa997816fd3f9f388e5901a401b068e4f6b8d
|
/pair_sw.h
|
8ac35f7969550d378c5cd13edd4339c3011166cb
|
[] |
no_license
|
plrodolfo/FluidFreeEnergyforLAMMPS
|
3488dc8b534da74dadbe397010ab68ff828cc7eb
|
8710015ea4d27d88c120bd5b03f5d5d9e31e71dc
|
refs/heads/master
| 2022-02-09T21:50:01.573499
| 2022-02-03T01:42:28
| 2022-02-03T01:42:28
| 144,865,731
| 21
| 12
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,623
|
h
|
pair_sw.h
|
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(sw,PairSW)
#else
#ifndef LMP_PAIR_SW_H
#define LMP_PAIR_SW_H
#include "pair.h"
namespace LAMMPS_NS {
class PairSW : public Pair {
public:
PairSW(class LAMMPS *);
virtual ~PairSW();
virtual void compute(int, int);
void settings(int, char **);
virtual void coeff(int, char **);
virtual double init_one(int, int);
virtual void init_style();
void *extract(const char *, int &);
struct Param {
double epsilon,sigma;
double littlea,lambda,gamma,costheta;
double biga,bigb;
double powerp,powerq;
double tol;
double cut,cutsq;
double sigma_gamma,lambda_epsilon,lambda_epsilon2;
double c1,c2,c3,c4,c5,c6;
int ielement,jelement,kelement;
};
protected:
double **fscale;
double cutmax; // max cutoff for all elements
int nelements; // # of unique elements
char **elements; // names of unique elements
int ***elem2param; // mapping from element triplets to parameters
int *map; // mapping from atom types to elements
int nparams; // # of stored parameter sets
int maxparam; // max # of parameter sets
Param *params; // parameter set for an I-J-K interaction
int maxshort; // size of short neighbor list array
int *neighshort; // short neighbor list array
virtual void allocate();
void read_file(char *);
virtual void setup_params();
void twobody(Param *, double, double &, int, double &);
void threebody(Param *, Param *, Param *, double, double, double *, double *,
double *, double *, int, double &);
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Incorrect args for pair coefficients
Self-explanatory. Check the input script or data file.
E: Pair style Stillinger-Weber requires atom IDs
This is a requirement to use the SW potential.
E: Pair style Stillinger-Weber requires newton pair on
See the newton command. This is a restriction to use the SW
potential.
E: All pair coeffs are not set
All pair coefficients must be set in the data file or by the
pair_coeff command before running a simulation.
E: Cannot open Stillinger-Weber potential file %s
The specified SW potential file cannot be opened. Check that the path
and name are correct.
E: Incorrect format in Stillinger-Weber potential file
Incorrect number of words per line in the potential file.
E: Illegal Stillinger-Weber parameter
One or more of the coefficients defined in the potential file is
invalid.
E: Potential file has duplicate entry
The potential file has more than one entry for the same element.
E: Potential file is missing an entry
The potential file does not have a needed entry.
*/
|
35909f6f72369d18af84578af8878ff5819a7cb4
|
6228b2b751fef71a37e81d186c790b966baaeabc
|
/ros-pkg/core/xpl_calibration/src/prog/offset_maker.cpp
|
47965daad5a62f17cc4c3a9862d6bea61b8fb999
|
[] |
no_license
|
teichman/phd-code
|
39bee20909f35cccb3c75fc2164fa1436a409f58
|
d04bbc54bdf6b658551b3561513ad8ce31f6433d
|
refs/heads/master
| 2020-03-28T21:54:55.526791
| 2014-06-26T00:50:04
| 2014-06-26T00:50:04
| 149,191,600
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,494
|
cpp
|
offset_maker.cpp
|
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/common/transforms.h>
#include <eigen_extensions/eigen_extensions.h>
#include <rgbd_sequence/stream_sequence_base.h>
using namespace std;
using namespace rgbd;
string usageString()
{
ostringstream oss;
oss << "Usage: offset_maker SEQ SEQ SYNC_OUT [SYNC_IN]" << endl;
oss << " where SEQ is a Sequence," << endl;
oss << " SYNC is the output 1x1 .eig.txt file with the time offset to add to"
<< " the timestamps of the second SEQ." << endl;
return oss.str();
}
int main(int argc, char** argv)
{
if(argc != 4 && argc != 5) {
cout << usageString() << endl;
return 0;
}
Eigen::VectorXd sync;
if(argc == 5)
eigen_extensions::loadASCII(argv[4], &sync);
else
sync = Eigen::VectorXd::Constant(1,0);
StreamSequenceBase::Ptr sseq0 = StreamSequenceBase::initializeFromDirectory(argv[1]);
StreamSequenceBase::Ptr sseq1 = StreamSequenceBase::initializeFromDirectory(argv[2]);
sseq1->applyTimeOffset(sync(0));
double thresh = 0.015;
ROS_WARN_STREAM("Showing images with dt of less than " << thresh << ".");
int i = 0;
while(true){
cout << "Current offset: " << sync(0) << endl;
cv::Mat3b image0 = sseq0->getImage(i);
double ts0 = sseq0->timestamps_[i];
cout << "ts0: " << setprecision(16) << ts0 << endl;
double dt;
cv::Mat3b image1 = sseq1->getImage(ts0, &dt);
cout << "dt = " << dt << endl;
cv::imshow("Image0", image0);
if(fabs(dt) < thresh){
cv::imshow("Image1", image1);
} else{
cv::imshow("Image1", cv::Mat3b::zeros(480,640) );
}
char inp = cv::waitKey(0);
double off_add;
switch(inp){
case '=':
//Increase dt by 1 milisecond
off_add = 0.005;
sseq1->applyTimeOffset(off_add);
sync(0) += off_add;
cout << "Increased offset by " << off_add << endl;
break;
case '-':
//Decrease dt by 1 milisecond
off_add = -0.005;
sseq1->applyTimeOffset(off_add);
sync(0) += off_add;
cout << "Decreased offset by " << off_add << endl;
break;
case 'd':
if(i < (int)sseq0->size()-1)
i += 1;
break;
case 'a':
if(i > 0)
i -= 1;
break;
case 's':
cout << "Saving to " << argv[3] << endl;
eigen_extensions::saveASCII(sync, argv[3]);
return 0;
break;
case 'q':
return 0;
break;
}
}
return 0;
}
|
8b08eecca4830557540c2cad1cf9c06f454a6ad7
|
412a08f5d43fcd9dc5e06d2f587efa578ea40e8a
|
/BOJ/Parsing/boj1388_바닥_장식.cpp
|
7c1f1095a31f05684c1de6a900ab082b448df74c
|
[] |
no_license
|
onww1/Problem-Solving
|
19b920f5f4caec50a3aded971e1f1e630e8b6c46
|
86cc8854ef0457f8f7741cbae401af5038f8ae05
|
refs/heads/master
| 2022-06-07T15:47:45.685775
| 2022-05-25T12:59:59
| 2022-05-25T12:59:59
| 130,528,244
| 6
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,155
|
cpp
|
boj1388_바닥_장식.cpp
|
/*
* BOJ 1388. 바닥 장식
*
* 바닥 장식에 대한 문자열을 입력 받으면서 장식의 첫 부분에서 s의 값을 증가시킵니다.
* '-' 모양은 첫 열이거나 이전 문자가 '-'가 아니면 장식의 첫 부분이므로 s를 증가시킵니다.
* '|' 모양은 첫 행이거나 이전 문자가 '|'이 아니면 장식의 첫 부분이므로 s를 증가시킵니다.
*
* P.S. 제출했는데 마지막 return문 다음 중괄호가 복사가 안돼서 컴파일 에러가 났네요 ㅋㅋㅋ
*/
#include <cstdio>
using namespace std;
char in[100][101];
int main(int argc, char *argv[]) {
int n, m, s = 0, i, j;
scanf("%d %d", &n, &m);
for (i = 0; i < n; ++i ){
scanf(" %s", in[i]);
for (j = 0; j < m; ++j) {
if (in[i][j] == '-') {
// 첫 열이거나 이전 문자가 '-'가 아니면 장식의 첫 부분이므로 s++
if (!j || in[i][j-1] != '-') ++s;
} else if (in[i][j] == '|') {
// 첫 행이거나 이전 문자가 '|'가 아니면 장식의 첫 부분이므로 s++
if (!i || in[i-1][j] != '|') ++s;
}
}
}
return !printf("%d\n", s);
}
|
3ddbccb0bf3a3dbaff4c2cbed08ba222c8297d52
|
184fedd9b15b150d3b9d1d2a6975f1a63792836c
|
/lhexam/TOptionFrm.h
|
198a665009361f24af742664607529b3c2260b1a
|
[] |
no_license
|
wanyuehan/bcbworkspace
|
abdb8f9f12459eb53d0712448fa98a02d472cd5e
|
0a85495013c7566470f1e295f66a244aa97c196e
|
refs/heads/master
| 2021-01-10T01:37:08.690690
| 2013-05-27T01:55:21
| 2013-05-27T01:55:21
| 50,320,878
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,376
|
h
|
TOptionFrm.h
|
//----------------------------------------------------------------------------
#ifndef TOptionFrmH
#define TOptionFrmH
//----------------------------------------------------------------------------
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include <StdCtrls.hpp>
#include <Controls.hpp>
#include <Forms.hpp>
#include <Graphics.hpp>
#include <Classes.hpp>
#include <SysUtils.hpp>
#include <Windows.hpp>
#include <System.hpp>
#include "tMainfrm.h"
#include "TSvrFrm.h"
//----------------------------------------------------------------------------
class TOptionFrm : public TForm
{
__published:
TButton *OKBtn;
TButton *CancelBtn;
TRadioGroup *rgKM;
TRadioGroup *rgTurns;
TButton *btAdmin;
void __fastcall OKBtnKeyPress(TObject *Sender, System::WideChar &Key);
void __fastcall FormCreate(TObject *Sender);
void __fastcall OKBtnClick(TObject *Sender);
void __fastcall CancelBtnClick(TObject *Sender);
void __fastcall btAdminClick(TObject *Sender);
private:
int FLAG_SUBJECT;
int FLAG_TURN;
bool FLAG_ADMIN;
TMainFrm *mainfrm;
TSvrFrm *SvrFrm;
public:
virtual __fastcall TOptionFrm(TComponent* AOwner);
};
//----------------------------------------------------------------------------
extern PACKAGE TOptionFrm *OptionFrm;
//----------------------------------------------------------------------------
#endif
|
8169fe07a73d5ac7a84c9d033d8aab29bfa19c7c
|
d6564258ddcf0552c09ef86ae2751b51495c7ed3
|
/Dynamic Programming/goldMineProblemDP.cpp
|
b5c8f536d4b6a3e4802e035bdc28672197a1c306
|
[] |
no_license
|
patiwwb/placementPreparation
|
f2c4ea38c5b4670b0b4d9e2c2c9d3bbfb40344ef
|
22229e50dca7bb033edca2c4eef8d573603ca277
|
refs/heads/master
| 2021-06-18T17:54:18.313729
| 2017-07-09T15:49:15
| 2017-07-09T15:49:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,068
|
cpp
|
goldMineProblemDP.cpp
|
#include<bits/stdc++.h>
using namespace std;
#define F(a,b,var) for(int var=a;var<b;var++)
int main()
{
//code
int T;
cin>>T;
while(T--)
{
int n,m;
cin>>n>>m;
int mat[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
cin>>mat[i][j];
}
int dp[n+1][m+1];
memset(dp,0,sizeof(dp));
for(int i=0;i<n;i++)
dp[i][0]=mat[i][0];
//cout<<i<<" "<<dp[i][0]<<" "<<mat[i][0]<<endl;
for(int i=1;i<m;i++){
for(int j=0;j<n;j++){
int x=(j>0)?dp[j-1][i-1]+mat[j][i]:0;
int y=(j<n-1)?dp[j+1][i-1]+mat[j][i]:0;
int z=dp[j][i-1]+mat[j][i];
// cout<<dp[j][i-1]<<" "<<mat[j][i-1]<<j<<i-1<<endl;
dp[j][i]=max(x,max(y,z));
//cout<<x<<" "<<y<<" "<<z<<endl;
}
}
int mx=0;
for(int i=0;i<n;i++)
mx=max(mx,dp[i][m-1]);
cout<<mx<<endl;
}
return 0;
}
|
afb72c329e3862f19e954c4209351f9eb44db141
|
dcc27fb68ef40c1b11b04d670e8c802cfe08e16e
|
/test/Unit.cpp
|
515c7db496c6843af0bed4865ed3dab894aca64b
|
[
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] |
permissive
|
danberindei/cpp-client
|
409c3785d82c0754641f891e60977019fe3c27d3
|
c9767c1a4db0d69336ab862a6d200e131f632e10
|
refs/heads/master
| 2021-01-17T11:40:20.569545
| 2015-09-01T13:20:34
| 2015-09-01T13:20:34
| 11,952,322
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 931
|
cpp
|
Unit.cpp
|
#include "infinispan/hotrod/ImportExport.h"
#include <stdio.h>
/* The tests using internal classes are compiled directly into the shared library/DLL,
this binary just runs them */
HR_EXTERN void threadTest();
HR_EXTERN void syncTest();
HR_EXTERN void runOnceTest();
HR_EXTERN void testTopologyChangeResponse();
HR_EXTERN void updateServersTest();
HR_EXTERN void consistentHashFactoryTests();
HR_EXTERN bool murmurHash2StringTest();
HR_EXTERN bool murmurHash3StringTest();
HR_EXTERN bool murmurHash2IntTest();
HR_EXTERN bool murmurHash3IntTest();
HR_EXTERN void runConcurrentCodecWritesTest();
int main(int, char**) {
runConcurrentCodecWritesTest();
threadTest();
syncTest();
runOnceTest();
testTopologyChangeResponse();
updateServersTest();
consistentHashFactoryTests();
murmurHash2StringTest();
murmurHash3StringTest();
murmurHash2IntTest();
murmurHash3IntTest();
return 0;
}
|
4c943faef872239f748f5710ff178fc25f1381c9
|
20d97c9093065566a072b7505908b1b8f53372a3
|
/Final Labwork/Banker's__Safety_&_ResourceRequestAlgorithm.cpp
|
79923296f45c925ac622b71859dc6e929bcd4578
|
[] |
no_license
|
Rubel2475/Operating-System-3Y2S
|
0fb288f0074d938d5be9e763682055fb0f0d3cdc
|
aef37286327a3d0b1cb48020ee4b23a8fdb20057
|
refs/heads/master
| 2020-09-16T03:01:31.647287
| 2020-03-03T18:38:26
| 2020-03-03T18:38:26
| 223,629,868
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,715
|
cpp
|
Banker's__Safety_&_ResourceRequestAlgorithm.cpp
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,j,k,s=0,e,r;
cout<< "Enter number of processes: ";
cin >> n;
cout<< "Enter number of resources: ";
cin>> m;
int Max[n][m], Allocation[n][m], Need[n][m],Request[n][m]; //Request[1][m]
int Available[m], Work[m], Finish[n], Sequence[n];
bool Flag, Unsafe=false;
cout<< "Enter available instances of each resources: ";
for(i=0; i<m; i++){
cin>> Available[i];
}
cout<<"Enter max demand of each resource: ";
for(i=0; i<n; i++){
for(j=0; j<m; j++){
cin >> Max[i][j];
}
}
cout<<"Enter allocated resources of each type: ";
for(i=0; i<n; i++){
for(j=0; j<m; j++){
cin >> Allocation[i][j];
Need[i][j] = Max[i][j]-Allocation[i][j];
Work[j] = Available[j];
}
Finish[i]=0;
}
safety:
for(i=0; i<n; i++){
for(j=0; j<n; j++){
Flag=true;
for(k=0; k<m; k++){
if(!(Finish[j]==0 && Need[j][k]<=Work[k])){
Flag=false;
}
}
if(Flag==true){
Finish[j]=1;
for(k=0; k<m; k++){
Work[k] = Work[k]+Allocation[j][k];
}
Sequence[s]=j;
s++;
}
}
}
for(i=0; i<n; i++){
if(Finish[i]==0){
Unsafe=true;
}
}
if(Unsafe==true){
cout<< "\nthe system is in unsafe state" << endl;
}
else{
cout<< "\nThe system is in safe state" << endl;
cout<< "the safe sequence is: ";
for(s=0; s<n; s++){
cout << "P[" << Sequence[s] << "]" << " ";
}
cout<<endl;
}
//Resource Request taking for a specific
cout<< "Enter 1 to request and 0 to end: ";
cin >> e;
if(e==1){
cout<< "enter request for process [0-"<<n-1 << "]: ";
cin>> r;
Unsafe=false;
s=0;
cout<<"Enter Instances of Resources for P["<<r<<"]: ";
for(j=0; j<m; j++){
cin>> Request[r][j];
Available[j] = Available[j]-Request[r][j];
Allocation[r][j] = Allocation[r][j]+Request[r][j];
Need[r][j] = Need[r][j]-Request[r][j];
Work[j]=Available[j];
}
for(i=0; i<n; i++){
Finish[i]=0;
}
goto safety;
}
else
return 0;
}
/*
5
3
3 3 2
7 5 3
3 2 2
9 0 2
2 2 2
4 3 3
0 1 0
2 0 0
3 0 2
2 1 1
0 2 2
*/
|
c378d50298358ecf585bd4d305ac8042c276f5b9
|
bae76888e633874c1278a43bb5773aae8201c44d
|
/CPSeis/spws_home/include/hardcopy/hardcopy_trace_plot.hh
|
d6f3e22cc2ca8a7dd86430fa90629cdf99e158ac
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
Chen-Zhihui/SeismicPackage
|
a242f9324c92d03383b06f068c9d2f64a47c5c3f
|
255d2311bdbbacad2cb19aa3b91ceb84a733a194
|
refs/heads/master
| 2020-08-16T05:28:19.283337
| 2016-11-25T02:24:14
| 2016-11-25T02:24:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,554
|
hh
|
hardcopy_trace_plot.hh
|
/*<license>
-------------------------------------------------------------------------------
Copyright (c) 2007 ConocoPhillips Company
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.
-------------------------------------------------------------------------------
</license>*/
#ifndef HARDCOPYTRACEPLOT_HH
#define HARDCOPYTRACEPLOT_HH
class HardCopyPlot;
class SeisPlot;
class HardCopyTracePlot {
public:
enum PlotType { Wiggle, WiggleFill, Color };
private:
enum DataType { DataIsFloat, DataIsByte };
HardCopyPlot *_hcp;
long _rp; // boolean value;
long _RtoL;
long _invert_yaxis;
float _ct;
float _is;
float _ti;
float _sr;
int _line_index_color;
float _trace_data;
DataType _data_type;
PlotType _ptype;
// float _x_offset;
float _y_offset;
float _plot_width;
public:
HardCopyTracePlot(HardCopyPlot *hcp);
void setRP(long g);
long rp() { return _rp; }
void setRtoL(long g) { _RtoL= g;}
long rToL() { return _RtoL; }
void setInvert(long g) { _invert_yaxis = g;}
long invert() { return _invert_yaxis; }
void setCT(float v) { _ct= v;}
float ct() { return _ct; }
void setIS(float is);
float is();
void setTI(float ti) { _ti= ti;}
float ti() { return _ti;}
void setPlotWidth(float w) {_plot_width= w;}
void plot(SeisPlot *sp,
long num_traces,
long num_samples,
long num_display_samp,
long first_trace,
int frame,
double max_amplitude);
void plot();
void setSampleRate(float sr) { _sr= sr;}
void setPlotType(PlotType ptype);
// void setXOffset(float xoff) { _x_offset= xoff;}
void setYOffset(float yoff) { _y_offset= yoff;}
// -------- not used --------
void setNumTraces(long t) { _num_traces= t;}
void setNumSamplesPerTrace(long s) { _num_samples= s;}
long _num_traces;
long _num_samples;
// -------- not used --------
};
#endif
|
2a8a38dba41bd9e64aee8e948471cf731bbbe89d
|
8f8899e5dfdb5a54bcb4c538949b4d58dbed4d12
|
/Codechef/CPP/Div2_May_cookoff_2020/CROADS.cpp
|
a8595787c7bcf51403b053630c71433cefa9120a
|
[
"MIT"
] |
permissive
|
kirito-udit/codeWith-hacktoberfest
|
0fb7780299ea099563cbac2aabfeb33bd9135349
|
175ed242e38ca25887350052335f13b0b0c0e303
|
refs/heads/main
| 2022-12-27T10:28:49.304226
| 2020-10-09T05:35:22
| 2020-10-09T05:35:22
| 302,606,983
| 1
| 0
|
MIT
| 2020-10-09T10:22:01
| 2020-10-09T10:22:00
| null |
UTF-8
|
C++
| false
| false
| 909
|
cpp
|
CROADS.cpp
|
#include<bits/stdc++.h>
using namespace std;
//#define ll long long
const int N = 2e5+100;
double eps=1e-6;
int main(){
int t;
cin>>t;
while(t--){
long long int n;
cin>>n;
//n=1000000000;
long long lpg=log2(n);
long long p=pow(2,lpg);
if(p==n && p!=1)cout<<-1<<endl;
else{
long long ans=0;
ans+=(n-1)/2;
long long int cond=1;
long long tn=n;
tn/=2;
long long i=0;
long long k=log2(tn);
while(i<=k){
long long x=pow(2,i);
long long adder=tn;
adder=adder-x;
adder=adder/(2*x);
adder=adder*(2*x);
ans+=adder+(2*x);
//cout<<tans<<endl;
i++;
}
cout<<ans<<endl;
}
}
return 0;
}
|
a9a5561f7e88008d0d7a3a6217f71a7d4c90d189
|
b2f54104efffba9d7c06e900b2eccaa58a847a1e
|
/Hindsight/src/main/cpp/Utility.h
|
9ecaa553bef14eb013faf11bfa7b36e4e7e8a6e0
|
[] |
no_license
|
Team2550/Robot-Code
|
349a43f6dd9a4c37818fa5149b7822d91616d9dc
|
dd4eec6a89ba74aad41f68e257c39c25ca06643b
|
refs/heads/main
| 2023-06-07T12:02:54.771202
| 2022-05-05T22:18:51
| 2022-05-05T22:18:51
| 159,417,730
| 4
| 1
| null | 2022-06-02T21:29:47
| 2018-11-28T00:05:33
|
C++
|
UTF-8
|
C++
| false
| false
| 1,640
|
h
|
Utility.h
|
#ifndef UTILITY_H
#define UTILITY_H
#include <frc/Joystick.h>
#include <math.h>
#include <vector>
#include <string>
#include "Xbox.h"
using namespace frc;
namespace Utility
{
enum RumbleSide { LEFT, RIGHT, BOTH };
/*=================================================
Name: deadzone
Desc: Zeroes out values within a certain "deadzone"
Arguments:
value (IO): value to deadzone
tolerance (I): deadzone
Return:
none
=================================================*/
float Deadzone(float value, float tolerance = 0.2);
/*=================================================
Name: splitString
Desc: Splits a string at delimiters
Arguments:
str (I): String to split
delimiter (I): Delimiter to split at
Return:
Vector containing substrings of original string
=================================================*/
std::vector<std::string> SplitString(std::string str, char delimiter);
/*=================================================
Name: strVectorToFloatVector
Desc: Converts a vector of strings to a vector of floats
Arguments:
strs (I): Vector of strings
Return:
Vector of floats
=================================================*/
std::vector<float> StrVectorToFloatVector(std::vector<std::string> strs);
/*=================================================
Name: setRumble
Desc: Rumbles an xbox controller
Arguments:
controller (I): controller to rumble
rumbleSide (I): side to rumble
rumbleAmount (I): rumble force [0, 1]
Return:
none
=================================================*/
void SetRumble(Joystick& controller, RumbleSide rumbleSide, float rumbleAmount);
}
#endif
|
76be84f8ccee895f9a8c14f01d078cd5bcd80c65
|
2b5d90789d879be27ddf4c8744b434f9d14db4ca
|
/Assignment2/Assignment2/TuitionAndFees.h
|
253d900efd52400c0e4c142be12d33e3f8b61724
|
[] |
no_license
|
Jrivera1625/Cpen333Assignment2
|
3932618f244a8625777efab99fa1353024f39260
|
0b7a9c67a7c97e8426b45c9889b29829b462f1a0
|
refs/heads/main
| 2023-01-31T11:56:37.401807
| 2020-12-04T22:44:08
| 2020-12-04T22:44:08
| 318,641,594
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 988
|
h
|
TuitionAndFees.h
|
#ifndef __TuitionAndFees__
#define __TuitionAndFees__
#include <stdio.h>
#include <iostream>
#include <list>
using namespace std;
class TuitionAndFees {
private:
int creditCard;
public:
int Fees; // attribute
// add fees for a course
void AddFees(int courseFee) {
Fees = Fees + courseFee;
cout << "Updated fees: " << Fees << endl;
}
// get total fees
int GetFees() {
cout << "Fees due:" << Fees << endl;
return Fees;
}
// enter bank details
void EnterBankDetails(int CreditCard) {
cout << "credit card was " << CreditCard << endl;
creditCard = CreditCard;
}
// submit payment and reset fees to 0
void SubmitFeePayment() {
cout << "Fee Payment Submitted" << endl;
// can now reset fees to 0
Fees = 0;
}
TuitionAndFees() {
cout << "TuitionAndFees default Constructor being called..." << endl;
Fees = 0; // initialize fees to 0
}
~TuitionAndFees() {
cout << "TuitionAndFees destructor is being called.." << endl;
}
};
#endif
|
04d01e3b2909f802a32f158e5f967a3b88b6703e
|
ff6bf9cbe1401c15de8fe6d2297ca36a6070ce37
|
/util/queue_test.cpp
|
d4d4b645e0d500e1100ae06139462cc1205e44c6
|
[] |
no_license
|
chuqingq/code_c
|
d4e4fc34ba945196a2ed0f32e20968033f63d8fc
|
45410b5487213a71953b6f425e495e27e4980a26
|
refs/heads/master
| 2023-06-09T01:42:32.003280
| 2023-06-04T08:40:12
| 2023-06-04T08:40:12
| 126,292,890
| 6
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 635
|
cpp
|
queue_test.cpp
|
#include "queue.hpp"
#include <iostream>
#include <thread>
int main() {
Queue<int> q(5);
std::thread th([&]() {
// 确保队列为空并且队列关闭时才退出
while (!q.closed()) {
while (!q.empty()) {
sleep(1);
auto v = q.pull_front();
std::cout << "recv " << v << std::endl;
}
}
});
for (int i = 0; i < 10; i++) {
q.push_back(i);
}
q.close();
th.join();
return 0;
}
// $ g++ -o queue_test queue_test.cpp -std=c++11 -Wall -g -lboost_thread
// ./queue_test
// recv 0
// recv 1
// recv 2
// recv 3
// recv 4
// recv 5
// recv 6
// recv 7
// recv 8
// recv 9
|
8324357315f6870a2c191f8963d207076edfa135
|
65e4995fbad46d2e4fc1fb7e26f10adc375071af
|
/Set_servo/Set_servo.ino
|
05a25d8ba5ab7bcae3bffdad3c32c75b91837510
|
[] |
no_license
|
Kenn3Th/DATA3750
|
938724c5835dc2764d421c86d9efc0dea231b593
|
eeebe9c796ad7623119d141b2611d3345584daa5
|
refs/heads/master
| 2021-01-15T07:49:17.872257
| 2020-03-03T10:45:10
| 2020-03-03T10:45:10
| 242,919,536
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 768
|
ino
|
Set_servo.ino
|
/***
Kode for å stille servoene til riktig posisjon
før montering av robot armen.
***/
#define servoPinLeft 6
#define servoPinRight A0
#define servoPinRotation A1
int myAngle;
int pulseWidth;
void setup() {
pinMode(servoPinLeft,OUTPUT);
pinMode(servoPinRight,OUTPUT);
pinMode(servoPinRotation,OUTPUT);
}
//Function to set the correct position
void servoPulse(int servo_pin, int angle) {
pulseWidth = (angle*11) + 500; //Converts the angle to pulsewidth value 500-2480
digitalWrite(servo_pin, HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(servo_pin, LOW);
delay(20-(pulseWidth/1000));
}
//Loop that sets the servo position
void loop() {
servoPulse(servoPinLeft, 180);
servoPulse(servoPinRight, 0);
servoPulse(servoPinRight, 80);
}
|
9ec25b71e216ca194f21f8a7688e4446162cfaf7
|
9dc9a2495de7e0be5929517628a787cd04917797
|
/samples/reflection/template.cpp
|
ba1bcf22b6bc3ea42a2d401137387a198bbc71fa
|
[
"Apache-2.0"
] |
permissive
|
cpgf/cpgf
|
e707c96b439cdcbbb8959abf26b4a4e257362b73
|
2590f6bfe85de4cba9645acac64460031739767f
|
refs/heads/master
| 2023-03-09T00:56:02.276678
| 2022-05-22T06:47:24
| 2022-05-22T06:47:24
| 16,725,840
| 201
| 52
| null | 2018-08-15T01:04:29
| 2014-02-11T09:28:40
|
C++
|
UTF-8
|
C++
| false
| false
| 1,601
|
cpp
|
template.cpp
|
#include "reflect_common.h"
namespace {
template <typename T>
class TestBase
{
public:
virtual ~TestBase() {
}
int getDouble() const {
return sizeof(T) * 2;
}
int value;
};
template <typename T, typename P>
class TestObject : public TestBase<T>
{
public:
int getSize() const {
return sizeof(T);
}
int n;
};
template <typename ClassType>
void lazyDefineClass(cpgf::GDefineMetaClass<ClassType> define)
{
define
._method("getSize", &ClassType::getSize)
._method("getDouble", &ClassType::getDouble)
;
}
G_AUTO_RUN_BEFORE_MAIN()
{
using namespace cpgf;
GDefineMetaClass<TestObject<char, int> >::lazy("template::TestObject_char_int", &lazyDefineClass<TestObject<char, int> >);
}
void doTest()
{
using namespace cpgf;
const GMetaClass * metaClass;
const GMetaMethod * method;
metaClass = findMetaClass("template::TestObject_char_int");
testCheckAssert(metaClass != nullptr);
std::cout << metaClass->getName() << std::endl;
{
void * obj = metaClass->createInstance();
method = metaClass->getMethodInHierarchy("getSize", &obj); testCheckAssert(method != nullptr);
testCheckEqual(fromVariant<unsigned int>(method->invoke(obj)), sizeof(char));
metaClass->destroyInstance(obj);
}
{
void * obj = metaClass->createInstance();
method = metaClass->getMethodInHierarchy("getDouble", &obj); testCheckAssert(method != nullptr);
testCheckEqual(fromVariant<unsigned int>(method->invoke(obj)), 2 * sizeof(char));
metaClass->destroyInstance(obj);
}
}
gTestCase(doTest);
}
|
b11d87a739025bf96bd72eeec7cfe0556e1a7e7a
|
d4d89bfe844dba307030410957c22b22d0a3d92e
|
/cpp_code/abc119/b.cpp
|
2d78fad3530b24e2f4204e92ce06329254d21962
|
[] |
no_license
|
Adaachill/atcoder
|
4dcb4435e0d9ca5c7363fe19f565e939ecfc056d
|
22af74e80fec95e77ce4d137eba6c7cc7e490ab3
|
refs/heads/master
| 2020-03-26T04:45:29.468222
| 2019-08-16T12:22:52
| 2019-08-16T12:22:52
| 144,521,344
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 296
|
cpp
|
b.cpp
|
#include <iostream>
#include <string>
using namespace std;
int main(){
int N;
cin >> N;
double x[N];
string u[N];
double sum = 0;
for(int i=0;i<N;i++){
cin >> x[i] >> u[i];
if(u[i] == "JPY") sum += x[i];
else sum += x[i]*380000.0;
}
cout << sum << endl;
return 0;
}
|
af4874120db926713c8b79080634c7503572e706
|
75a166c925f371dc1c09551cd015ed422c643301
|
/Cell.cpp
|
87e8e41ca966f490997b496eaf4b060ca1632bb8
|
[] |
no_license
|
tonyzheng6/Sudoku_Board_Solver
|
316ca30a59d47165177de574e5c8b425f38ce8ec
|
f0dd3131a319c2025931ca1666adabbfd510f337
|
refs/heads/master
| 2020-06-05T14:42:36.301274
| 2015-05-04T01:15:33
| 2015-05-04T01:15:33
| 34,967,809
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 904
|
cpp
|
Cell.cpp
|
/**
* Title: Cell.cpp
* Author: Tony Zheng
* Created on: 2/23/2014
* Modified on: 5/1/2015
* Description: A program that will generate solved Sudoku boards. The program starts by
* inserting a random number (between 1 and 9) in the top left cell of the grid
* and then places other numbers in the remaining cells to satisfy the constraints
* of the puzzle. The solution is done recursively and uses a backtracking algorithm
* Build with: To compile: g++ *.cpp -o run.me
* To run: ./run.me
*/
#include "Cell.h"
Cell::Cell() {
}
Cell::~Cell() {
}
/**
* Setters and getters for the Cell class.
*/
void Cell::setValue(int value) {
this->value = value;
};
int Cell::getValue() {
return value;
};
void Cell::setValid(bool valid) {
this->valid = valid;
};
bool Cell::getValid() {
return valid;
};
|
77369a4c8b635bc00b6d3164eb7bdf7552cfa9d2
|
245fbb17cf54ef40bd7e031434c5afd34ef7ebd2
|
/read_data_gals.cpp
|
ad46ba6c63a87f2390da9b382a0a4aaa8e3d7bda
|
[] |
no_license
|
laury13marian/MillenniumXXL_GGL
|
e9786b352fe07a6c23bf28167e4404c808d2ed70
|
807f1f3a0cef3d421a289402a8e6e3a3d7906f47
|
refs/heads/main
| 2023-07-11T15:43:22.659400
| 2021-08-12T10:14:02
| 2021-08-12T10:14:02
| 395,275,972
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 300
|
cpp
|
read_data_gals.cpp
|
#include "read_data.h"
using namespace std;
int main()
{
const string path_in = "/galformod/scratch/bmh20/SAM/Henriques2014/snaps/Guo10_bug_fix/MR/";
const double red=0.24;
read_galaxy_Millennium OB(red, path_in);
int sub=100;
OB.open_subfile(sub);
OB.deallocate(sub);
return 0;
}
|
19aa1d2a856569ceaf83f6771bdeec0912851cde
|
3536baec9b09d77449f4e86076ef469769b5ca24
|
/Classes/Card.h
|
ef9b1c3acb077d47ec9d1a7de4479519a46280cc
|
[] |
no_license
|
oyueduo/landlord
|
7d29afefa85fe65443b3d5ef38c83d9117469127
|
ac30aa39de942a85612da33b6d55a2989ee0e286
|
refs/heads/master
| 2020-12-24T20:10:21.761516
| 2017-04-07T15:21:25
| 2017-04-07T15:21:25
| 86,240,237
| 1
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,186
|
h
|
Card.h
|
#ifndef __CARD_H__
#define __CARD_H__
#include "cocos2d.h"
const double cardScale = 0.75;
const double cardSizeX = 129;
const double cardSizeY = 167;
////0代表大牌,1代表小牌
//enum CardSize
//{
// BIG_CARD,
// SMALL_CARD
//};
//颜色0黑1红2金
enum CardColor
{
BLACK,
RED,
GOLD
};
//牌的拥有者
enum CardOwner
{
FARM,
LANDLORD
};
//花色 0红心,1方块 2黑桃 3梅花 4空
enum CardFlower
{
HEART,
DIAMOND,
SPADE,
CLUB,
NONE
};
enum CardBody
{
BACKGROUND,
NUMBER,
FLOWER
};
class Card :public cocos2d::Sprite
{
public:
Card();
static Card* createCard( int number, CardColor color,CardFlower flower, CardOwner owner);
virtual bool init();
bool initData( int number, CardColor color,CardFlower flower, CardOwner owner);
int getCardNumber()const;
bool getCardTouched() const;
void setCardTouched(bool touched);
private:
cocos2d::Sprite* _flower;//花色
cocos2d::Sprite* _number;//数字
CardColor _cardColor;//数字和joker颜色
CardFlower _cardFlower;//花色
CardOwner _cardOwner;//y拥有者
int _cardNumber;//牌的大小
bool _touched;//是否被点击
};
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.