blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
sequencelengths
1
1
author
stringlengths
0
119
f67e783f5cc932de8d5dd8e278802266ec97b5f9
12f441018818dc2dcb1a8a89bccd946d87e0ac9e
/cppwinrt/winrt/impl/Windows.ApplicationModel.Calls.0.h
367a03a52d25152ec69e554fb80e1e4ad096478a
[ "MIT" ]
permissive
dlech/bleak-winrt
cc7dd76fca9453b7415d65a428e22b2cbfe36209
a6c1f3fd073a7b5678304ea6bc08b9b067544320
refs/heads/main
2022-09-12T00:15:01.497572
2022-09-09T22:57:53
2022-09-09T22:57:53
391,440,675
10
1
null
null
null
null
UTF-8
C++
false
false
124,661
h
// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.220608.4 #pragma once #ifndef WINRT_Windows_ApplicationModel_Calls_0_H #define WINRT_Windows_ApplicationModel_Calls_0_H WINRT_EXPORT namespace winrt::Windows::ApplicationModel::Contacts { struct Contact; struct ContactPhone; } WINRT_EXPORT namespace winrt::Windows::Foundation { template <typename T> struct __declspec(empty_bases) EventHandler; struct EventRegistrationToken; struct IAsyncAction; template <typename T> struct __declspec(empty_bases) IReference; template <typename TSender, typename TResult> struct __declspec(empty_bases) TypedEventHandler; struct Uri; } WINRT_EXPORT namespace winrt::Windows::Foundation::Collections { template <typename T> struct __declspec(empty_bases) IIterable; } WINRT_EXPORT namespace winrt::Windows::System { struct User; } WINRT_EXPORT namespace winrt::Windows::UI { struct Color; } WINRT_EXPORT namespace winrt::Windows::ApplicationModel::Calls { enum class CellularDtmfMode : int32_t { Continuous = 0, Burst = 1, }; enum class DtmfKey : int32_t { D0 = 0, D1 = 1, D2 = 2, D3 = 3, D4 = 4, D5 = 5, D6 = 6, D7 = 7, D8 = 8, D9 = 9, Star = 10, Pound = 11, }; enum class DtmfToneAudioPlayback : int32_t { Play = 0, DoNotPlay = 1, }; enum class PhoneAudioRoutingEndpoint : int32_t { Default = 0, Bluetooth = 1, Speakerphone = 2, }; enum class PhoneCallAudioDevice : int32_t { Unknown = 0, LocalDevice = 1, RemoteDevice = 2, }; enum class PhoneCallDirection : int32_t { Unknown = 0, Incoming = 1, Outgoing = 2, }; enum class PhoneCallHistoryEntryMedia : int32_t { Audio = 0, Video = 1, }; enum class PhoneCallHistoryEntryOtherAppReadAccess : int32_t { Full = 0, SystemOnly = 1, }; enum class PhoneCallHistoryEntryQueryDesiredMedia : uint32_t { None = 0, Audio = 0x1, Video = 0x2, All = 0xffffffff, }; enum class PhoneCallHistoryEntryRawAddressKind : int32_t { PhoneNumber = 0, Custom = 1, }; enum class PhoneCallHistorySourceIdKind : int32_t { CellularPhoneLineId = 0, PackageFamilyName = 1, }; enum class PhoneCallHistoryStoreAccessType : int32_t { AppEntriesReadWrite = 0, AllEntriesLimitedReadWrite = 1, AllEntriesReadWrite = 2, }; enum class PhoneCallMedia : int32_t { Audio = 0, AudioAndVideo = 1, AudioAndRealTimeText = 2, }; enum class PhoneCallOperationStatus : int32_t { Succeeded = 0, OtherFailure = 1, TimedOut = 2, ConnectionLost = 3, InvalidCallState = 4, }; enum class PhoneCallStatus : int32_t { Lost = 0, Incoming = 1, Dialing = 2, Talking = 3, Held = 4, Ended = 5, }; enum class PhoneLineNetworkOperatorDisplayTextLocation : int32_t { Default = 0, Tile = 1, Dialer = 2, InCallUI = 3, }; enum class PhoneLineOperationStatus : int32_t { Succeeded = 0, OtherFailure = 1, TimedOut = 2, ConnectionLost = 3, InvalidCallState = 4, }; enum class PhoneLineTransport : int32_t { Cellular = 0, VoipApp = 1, Bluetooth = 2, }; enum class PhoneLineWatcherStatus : int32_t { Created = 0, Started = 1, EnumerationCompleted = 2, Stopped = 3, }; enum class PhoneNetworkState : int32_t { Unknown = 0, NoSignal = 1, Deregistered = 2, Denied = 3, Searching = 4, Home = 5, RoamingInternational = 6, RoamingDomestic = 7, }; enum class PhoneSimState : int32_t { Unknown = 0, PinNotRequired = 1, PinUnlocked = 2, PinLocked = 3, PukLocked = 4, NotInserted = 5, Invalid = 6, Disabled = 7, }; enum class PhoneVoicemailType : int32_t { None = 0, Traditional = 1, Visual = 2, }; enum class TransportDeviceAudioRoutingStatus : int32_t { Unknown = 0, CanRouteToLocalDevice = 1, CannotRouteToLocalDevice = 2, }; enum class VoipPhoneCallMedia : uint32_t { None = 0, Audio = 0x1, Video = 0x2, }; enum class VoipPhoneCallRejectReason : int32_t { UserIgnored = 0, TimedOut = 1, OtherIncomingCall = 2, EmergencyCallExists = 3, InvalidCallState = 4, }; enum class VoipPhoneCallResourceReservationStatus : int32_t { Success = 0, ResourcesNotAvailable = 1, }; enum class VoipPhoneCallState : int32_t { Ended = 0, Held = 1, Active = 2, Incoming = 3, Outgoing = 4, }; struct ICallAnswerEventArgs; struct ICallRejectEventArgs; struct ICallStateChangeEventArgs; struct IMuteChangeEventArgs; struct IPhoneCall; struct IPhoneCallBlockingStatics; struct IPhoneCallHistoryEntry; struct IPhoneCallHistoryEntryAddress; struct IPhoneCallHistoryEntryAddressFactory; struct IPhoneCallHistoryEntryQueryOptions; struct IPhoneCallHistoryEntryReader; struct IPhoneCallHistoryManagerForUser; struct IPhoneCallHistoryManagerStatics; struct IPhoneCallHistoryManagerStatics2; struct IPhoneCallHistoryStore; struct IPhoneCallInfo; struct IPhoneCallManagerStatics; struct IPhoneCallManagerStatics2; struct IPhoneCallStatics; struct IPhoneCallStore; struct IPhoneCallVideoCapabilities; struct IPhoneCallVideoCapabilitiesManagerStatics; struct IPhoneCallsResult; struct IPhoneDialOptions; struct IPhoneLine; struct IPhoneLine2; struct IPhoneLine3; struct IPhoneLineCellularDetails; struct IPhoneLineConfiguration; struct IPhoneLineDialResult; struct IPhoneLineStatics; struct IPhoneLineTransportDevice; struct IPhoneLineTransportDevice2; struct IPhoneLineTransportDeviceStatics; struct IPhoneLineWatcher; struct IPhoneLineWatcherEventArgs; struct IPhoneVoicemail; struct IVoipCallCoordinator; struct IVoipCallCoordinator2; struct IVoipCallCoordinator3; struct IVoipCallCoordinator4; struct IVoipCallCoordinatorStatics; struct IVoipPhoneCall; struct IVoipPhoneCall2; struct IVoipPhoneCall3; struct CallAnswerEventArgs; struct CallRejectEventArgs; struct CallStateChangeEventArgs; struct MuteChangeEventArgs; struct PhoneCall; struct PhoneCallBlocking; struct PhoneCallHistoryEntry; struct PhoneCallHistoryEntryAddress; struct PhoneCallHistoryEntryQueryOptions; struct PhoneCallHistoryEntryReader; struct PhoneCallHistoryManager; struct PhoneCallHistoryManagerForUser; struct PhoneCallHistoryStore; struct PhoneCallInfo; struct PhoneCallManager; struct PhoneCallStore; struct PhoneCallVideoCapabilities; struct PhoneCallVideoCapabilitiesManager; struct PhoneCallsResult; struct PhoneDialOptions; struct PhoneLine; struct PhoneLineCellularDetails; struct PhoneLineConfiguration; struct PhoneLineDialResult; struct PhoneLineTransportDevice; struct PhoneLineWatcher; struct PhoneLineWatcherEventArgs; struct PhoneVoicemail; struct VoipCallCoordinator; struct VoipPhoneCall; } namespace winrt::impl { template <> struct category<winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCall>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallBlockingStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddressFactory>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallStore>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilitiesManagerStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLine>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLine2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLine3>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDeviceStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator3>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator4>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinatorStatics>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall2>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall3>{ using type = interface_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::CallAnswerEventArgs>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::CallRejectEventArgs>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::MuteChangeEventArgs>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCall>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallBlocking>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryAddress>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryOptions>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryReader>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryManager>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryManagerForUser>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStore>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallInfo>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallManager>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallStore>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallVideoCapabilities>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallVideoCapabilitiesManager>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallsResult>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneDialOptions>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLine>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineCellularDetails>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineConfiguration>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineDialResult>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneVoicemail>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipCallCoordinator>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall>{ using type = class_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::CellularDtmfMode>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::DtmfKey>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::DtmfToneAudioPlayback>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneAudioRoutingEndpoint>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallAudioDevice>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallDirection>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryMedia>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryOtherAppReadAccess>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryDesiredMedia>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryRawAddressKind>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistorySourceIdKind>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStoreAccessType>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallMedia>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallOperationStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneCallStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineNetworkOperatorDisplayTextLocation>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineOperationStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineTransport>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneNetworkState>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneSimState>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::PhoneVoicemailType>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::TransportDeviceAudioRoutingStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallRejectReason>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallResourceReservationStatus>{ using type = enum_category; }; template <> struct category<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallState>{ using type = enum_category; }; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::CallAnswerEventArgs> = L"Windows.ApplicationModel.Calls.CallAnswerEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::CallRejectEventArgs> = L"Windows.ApplicationModel.Calls.CallRejectEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> = L"Windows.ApplicationModel.Calls.CallStateChangeEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::MuteChangeEventArgs> = L"Windows.ApplicationModel.Calls.MuteChangeEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCall> = L"Windows.ApplicationModel.Calls.PhoneCall"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallBlocking> = L"Windows.ApplicationModel.Calls.PhoneCallBlocking"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntry"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryAddress> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryAddress"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryOptions> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryQueryOptions"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryReader> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryReader"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryManager> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryManager"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryManagerForUser> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryManagerForUser"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStore> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryStore"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallInfo> = L"Windows.ApplicationModel.Calls.PhoneCallInfo"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallManager> = L"Windows.ApplicationModel.Calls.PhoneCallManager"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallStore> = L"Windows.ApplicationModel.Calls.PhoneCallStore"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallVideoCapabilities> = L"Windows.ApplicationModel.Calls.PhoneCallVideoCapabilities"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallVideoCapabilitiesManager> = L"Windows.ApplicationModel.Calls.PhoneCallVideoCapabilitiesManager"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallsResult> = L"Windows.ApplicationModel.Calls.PhoneCallsResult"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneDialOptions> = L"Windows.ApplicationModel.Calls.PhoneDialOptions"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLine> = L"Windows.ApplicationModel.Calls.PhoneLine"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineCellularDetails> = L"Windows.ApplicationModel.Calls.PhoneLineCellularDetails"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineConfiguration> = L"Windows.ApplicationModel.Calls.PhoneLineConfiguration"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineDialResult> = L"Windows.ApplicationModel.Calls.PhoneLineDialResult"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice> = L"Windows.ApplicationModel.Calls.PhoneLineTransportDevice"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher> = L"Windows.ApplicationModel.Calls.PhoneLineWatcher"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> = L"Windows.ApplicationModel.Calls.PhoneLineWatcherEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneVoicemail> = L"Windows.ApplicationModel.Calls.PhoneVoicemail"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipCallCoordinator> = L"Windows.ApplicationModel.Calls.VoipCallCoordinator"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall> = L"Windows.ApplicationModel.Calls.VoipPhoneCall"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::CellularDtmfMode> = L"Windows.ApplicationModel.Calls.CellularDtmfMode"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::DtmfKey> = L"Windows.ApplicationModel.Calls.DtmfKey"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::DtmfToneAudioPlayback> = L"Windows.ApplicationModel.Calls.DtmfToneAudioPlayback"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneAudioRoutingEndpoint> = L"Windows.ApplicationModel.Calls.PhoneAudioRoutingEndpoint"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallAudioDevice> = L"Windows.ApplicationModel.Calls.PhoneCallAudioDevice"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallDirection> = L"Windows.ApplicationModel.Calls.PhoneCallDirection"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryMedia> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryMedia"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryOtherAppReadAccess> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryOtherAppReadAccess"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryDesiredMedia> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryQueryDesiredMedia"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryRawAddressKind> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryEntryRawAddressKind"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistorySourceIdKind> = L"Windows.ApplicationModel.Calls.PhoneCallHistorySourceIdKind"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStoreAccessType> = L"Windows.ApplicationModel.Calls.PhoneCallHistoryStoreAccessType"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallMedia> = L"Windows.ApplicationModel.Calls.PhoneCallMedia"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallOperationStatus> = L"Windows.ApplicationModel.Calls.PhoneCallOperationStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneCallStatus> = L"Windows.ApplicationModel.Calls.PhoneCallStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineNetworkOperatorDisplayTextLocation> = L"Windows.ApplicationModel.Calls.PhoneLineNetworkOperatorDisplayTextLocation"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineOperationStatus> = L"Windows.ApplicationModel.Calls.PhoneLineOperationStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineTransport> = L"Windows.ApplicationModel.Calls.PhoneLineTransport"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherStatus> = L"Windows.ApplicationModel.Calls.PhoneLineWatcherStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneNetworkState> = L"Windows.ApplicationModel.Calls.PhoneNetworkState"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneSimState> = L"Windows.ApplicationModel.Calls.PhoneSimState"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::PhoneVoicemailType> = L"Windows.ApplicationModel.Calls.PhoneVoicemailType"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::TransportDeviceAudioRoutingStatus> = L"Windows.ApplicationModel.Calls.TransportDeviceAudioRoutingStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia> = L"Windows.ApplicationModel.Calls.VoipPhoneCallMedia"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallRejectReason> = L"Windows.ApplicationModel.Calls.VoipPhoneCallRejectReason"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallResourceReservationStatus> = L"Windows.ApplicationModel.Calls.VoipPhoneCallResourceReservationStatus"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::VoipPhoneCallState> = L"Windows.ApplicationModel.Calls.VoipPhoneCallState"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs> = L"Windows.ApplicationModel.Calls.ICallAnswerEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs> = L"Windows.ApplicationModel.Calls.ICallRejectEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs> = L"Windows.ApplicationModel.Calls.ICallStateChangeEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs> = L"Windows.ApplicationModel.Calls.IMuteChangeEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCall> = L"Windows.ApplicationModel.Calls.IPhoneCall"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallBlockingStatics> = L"Windows.ApplicationModel.Calls.IPhoneCallBlockingStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryEntry"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryEntryAddress"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddressFactory> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryEntryAddressFactory"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryEntryQueryOptions"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryEntryReader"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryManagerForUser"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryManagerStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics2> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryManagerStatics2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore> = L"Windows.ApplicationModel.Calls.IPhoneCallHistoryStore"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo> = L"Windows.ApplicationModel.Calls.IPhoneCallInfo"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics> = L"Windows.ApplicationModel.Calls.IPhoneCallManagerStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2> = L"Windows.ApplicationModel.Calls.IPhoneCallManagerStatics2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallStatics> = L"Windows.ApplicationModel.Calls.IPhoneCallStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallStore> = L"Windows.ApplicationModel.Calls.IPhoneCallStore"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities> = L"Windows.ApplicationModel.Calls.IPhoneCallVideoCapabilities"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilitiesManagerStatics> = L"Windows.ApplicationModel.Calls.IPhoneCallVideoCapabilitiesManagerStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult> = L"Windows.ApplicationModel.Calls.IPhoneCallsResult"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions> = L"Windows.ApplicationModel.Calls.IPhoneDialOptions"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine> = L"Windows.ApplicationModel.Calls.IPhoneLine"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine2> = L"Windows.ApplicationModel.Calls.IPhoneLine2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine3> = L"Windows.ApplicationModel.Calls.IPhoneLine3"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails> = L"Windows.ApplicationModel.Calls.IPhoneLineCellularDetails"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration> = L"Windows.ApplicationModel.Calls.IPhoneLineConfiguration"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult> = L"Windows.ApplicationModel.Calls.IPhoneLineDialResult"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineStatics> = L"Windows.ApplicationModel.Calls.IPhoneLineStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice> = L"Windows.ApplicationModel.Calls.IPhoneLineTransportDevice"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2> = L"Windows.ApplicationModel.Calls.IPhoneLineTransportDevice2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDeviceStatics> = L"Windows.ApplicationModel.Calls.IPhoneLineTransportDeviceStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher> = L"Windows.ApplicationModel.Calls.IPhoneLineWatcher"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs> = L"Windows.ApplicationModel.Calls.IPhoneLineWatcherEventArgs"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail> = L"Windows.ApplicationModel.Calls.IPhoneVoicemail"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator> = L"Windows.ApplicationModel.Calls.IVoipCallCoordinator"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator2> = L"Windows.ApplicationModel.Calls.IVoipCallCoordinator2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator3> = L"Windows.ApplicationModel.Calls.IVoipCallCoordinator3"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator4> = L"Windows.ApplicationModel.Calls.IVoipCallCoordinator4"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinatorStatics> = L"Windows.ApplicationModel.Calls.IVoipCallCoordinatorStatics"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall> = L"Windows.ApplicationModel.Calls.IVoipPhoneCall"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall2> = L"Windows.ApplicationModel.Calls.IVoipPhoneCall2"; template <> inline constexpr auto& name_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall3> = L"Windows.ApplicationModel.Calls.IVoipPhoneCall3"; template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs>{ 0xFD789617,0x2DD7,0x4C8C,{ 0xB2,0xBD,0x95,0xD1,0x7A,0x5B,0xB7,0x33 } }; // FD789617-2DD7-4C8C-B2BD-95D17A5BB733 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs>{ 0xDA47FAD7,0x13D4,0x4D92,{ 0xA1,0xC2,0xB7,0x78,0x11,0xEE,0x37,0xEC } }; // DA47FAD7-13D4-4D92-A1C2-B77811EE37EC template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs>{ 0xEAB2349E,0x66F5,0x47F9,{ 0x9F,0xB5,0x45,0x9C,0x51,0x98,0xC7,0x20 } }; // EAB2349E-66F5-47F9-9FB5-459C5198C720 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs>{ 0x8585E159,0x0C41,0x432C,{ 0x81,0x4D,0xC5,0xF1,0xFD,0xF5,0x30,0xBE } }; // 8585E159-0C41-432C-814D-C5F1FDF530BE template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCall>{ 0xC14ED0F8,0xC17D,0x59D2,{ 0x96,0x28,0x66,0xE5,0x45,0xB6,0xCD,0x21 } }; // C14ED0F8-C17D-59D2-9628-66E545B6CD21 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallBlockingStatics>{ 0x19646F84,0x2B79,0x26F1,{ 0xA4,0x6F,0x69,0x4B,0xE0,0x43,0xF3,0x13 } }; // 19646F84-2B79-26F1-A46F-694BE043F313 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry>{ 0xFAB0E129,0x32A4,0x4B85,{ 0x83,0xD1,0xF9,0x0D,0x8C,0x23,0xA8,0x57 } }; // FAB0E129-32A4-4B85-83D1-F90D8C23A857 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress>{ 0x30F159DA,0x3955,0x4042,{ 0x84,0xE6,0x66,0xEE,0xBF,0x82,0xE6,0x7F } }; // 30F159DA-3955-4042-84E6-66EEBF82E67F template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddressFactory>{ 0xFB0FADBA,0xC7F0,0x4BB6,{ 0x9F,0x6B,0xBA,0x5D,0x73,0x20,0x9A,0xCA } }; // FB0FADBA-C7F0-4BB6-9F6B-BA5D73209ACA template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions>{ 0x9C5FE15C,0x8BED,0x40CA,{ 0xB0,0x6E,0xC4,0xCA,0x8E,0xAE,0x5C,0x87 } }; // 9C5FE15C-8BED-40CA-B06E-C4CA8EAE5C87 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader>{ 0x61ECE4BE,0x8D86,0x479F,{ 0x84,0x04,0xA9,0x84,0x69,0x20,0xFE,0xE6 } }; // 61ECE4BE-8D86-479F-8404-A9846920FEE6 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser>{ 0xD925C523,0xF55F,0x4353,{ 0x9D,0xB4,0x02,0x05,0xA5,0x26,0x5A,0x55 } }; // D925C523-F55F-4353-9DB4-0205A5265A55 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics>{ 0xF5A6DA39,0xB31F,0x4F45,{ 0xAC,0x8E,0x1B,0x08,0x89,0x3C,0x1B,0x50 } }; // F5A6DA39-B31F-4F45-AC8E-1B08893C1B50 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics2>{ 0xEFD474F0,0xA2DB,0x4188,{ 0x9E,0x92,0xBC,0x3C,0xFA,0x68,0x13,0xCF } }; // EFD474F0-A2DB-4188-9E92-BC3CFA6813CF template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore>{ 0x2F907DB8,0xB40E,0x422B,{ 0x85,0x45,0xCB,0x19,0x10,0xA6,0x1C,0x52 } }; // 2F907DB8-B40E-422B-8545-CB1910A61C52 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo>{ 0x22B42577,0x3E4D,0x5DC6,{ 0x89,0xC2,0x46,0x9F,0xE5,0xFF,0xC1,0x89 } }; // 22B42577-3E4D-5DC6-89C2-469FE5FFC189 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics>{ 0x60EDAC78,0x78A6,0x4872,{ 0xA3,0xEF,0x98,0x32,0x5E,0xC8,0xB8,0x43 } }; // 60EDAC78-78A6-4872-A3EF-98325EC8B843 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2>{ 0xC7E3C8BC,0x2370,0x431C,{ 0x98,0xFD,0x43,0xBE,0x5F,0x03,0x08,0x6D } }; // C7E3C8BC-2370-431C-98FD-43BE5F03086D template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallStatics>{ 0x2218EEAB,0xF60B,0x53E7,{ 0xBA,0x13,0x5A,0xEA,0xFB,0xC2,0x29,0x57 } }; // 2218EEAB-F60B-53E7-BA13-5AEAFBC22957 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallStore>{ 0x5F610748,0x18A6,0x4173,{ 0x86,0xD1,0x28,0xBE,0x9D,0xC6,0x2D,0xBA } }; // 5F610748-18A6-4173-86D1-28BE9DC62DBA template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities>{ 0x02382786,0xB16A,0x4FDB,{ 0xBE,0x3B,0xC4,0x24,0x0E,0x13,0xAD,0x0D } }; // 02382786-B16A-4FDB-BE3B-C4240E13AD0D template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilitiesManagerStatics>{ 0xF3C64B56,0xF00B,0x4A1C,{ 0xA0,0xC6,0xEE,0x19,0x10,0x74,0x9C,0xE7 } }; // F3C64B56-F00B-4A1C-A0C6-EE1910749CE7 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult>{ 0x1BFAD365,0x57CF,0x57DD,{ 0x98,0x6D,0xB0,0x57,0xC9,0x1E,0xAC,0x33 } }; // 1BFAD365-57CF-57DD-986D-B057C91EAC33 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions>{ 0xB639C4B8,0xF06F,0x36CB,{ 0xA8,0x63,0x82,0x37,0x42,0xB5,0xF2,0xD4 } }; // B639C4B8-F06F-36CB-A863-823742B5F2D4 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine>{ 0x27C66F30,0x6A69,0x34CA,{ 0xA2,0xBA,0x65,0x30,0x25,0x30,0xC3,0x11 } }; // 27C66F30-6A69-34CA-A2BA-65302530C311 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine2>{ 0x0167F56A,0x5344,0x5D64,{ 0x8A,0xF3,0xA3,0x1A,0x95,0x0E,0x91,0x6A } }; // 0167F56A-5344-5D64-8AF3-A31A950E916A template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLine3>{ 0xE2E33CF7,0x2406,0x57F3,{ 0x82,0x6A,0xE5,0xA5,0xF4,0x0D,0x6F,0xB5 } }; // E2E33CF7-2406-57F3-826A-E5A5F40D6FB5 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails>{ 0x192601D5,0x147C,0x4769,{ 0xB6,0x73,0x98,0xA5,0xEC,0x84,0x26,0xCB } }; // 192601D5-147C-4769-B673-98A5EC8426CB template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration>{ 0xFE265862,0xF64F,0x4312,{ 0xB2,0xA8,0x4E,0x25,0x77,0x21,0xAA,0x95 } }; // FE265862-F64F-4312-B2A8-4E257721AA95 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult>{ 0xE825A30A,0x5C7F,0x546F,{ 0xB9,0x18,0x3A,0xD2,0xFE,0x70,0xFB,0x34 } }; // E825A30A-5C7F-546F-B918-3AD2FE70FB34 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineStatics>{ 0xF38B5F23,0xCEB0,0x404F,{ 0xBC,0xF2,0xBA,0x9F,0x69,0x7D,0x8A,0xDF } }; // F38B5F23-CEB0-404F-BCF2-BA9F697D8ADF template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice>{ 0xEFA8F889,0xCFFA,0x59F4,{ 0x97,0xE4,0x74,0x70,0x5B,0x7D,0xC4,0x90 } }; // EFA8F889-CFFA-59F4-97E4-74705B7DC490 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2>{ 0x64C885F2,0xECF4,0x5761,{ 0x8C,0x04,0x3C,0x24,0x8C,0xE6,0x16,0x90 } }; // 64C885F2-ECF4-5761-8C04-3C248CE61690 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDeviceStatics>{ 0x0F3121AC,0xD609,0x51A1,{ 0x96,0xF3,0xFB,0x00,0xD1,0x81,0x92,0x52 } }; // 0F3121AC-D609-51A1-96F3-FB00D1819252 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>{ 0x8A45CD0A,0x6323,0x44E0,{ 0xA6,0xF6,0x9F,0x21,0xF6,0x4D,0xC9,0x0A } }; // 8A45CD0A-6323-44E0-A6F6-9F21F64DC90A template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs>{ 0xD07C753E,0x9E12,0x4A37,{ 0x82,0xB7,0xAD,0x53,0x5D,0xAD,0x6A,0x67 } }; // D07C753E-9E12-4A37-82B7-AD535DAD6A67 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail>{ 0xC9CE77F6,0x6E9F,0x3A8B,{ 0xB7,0x27,0x6E,0x0C,0xF6,0x99,0x82,0x24 } }; // C9CE77F6-6E9F-3A8B-B727-6E0CF6998224 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator>{ 0x4F118BCF,0xE8EF,0x4434,{ 0x9C,0x5F,0xA8,0xD8,0x93,0xFA,0xFE,0x79 } }; // 4F118BCF-E8EF-4434-9C5F-A8D893FAFE79 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator2>{ 0xBEB4A9F3,0xC704,0x4234,{ 0x89,0xCE,0xE8,0x8C,0xC0,0xD2,0x8F,0xBE } }; // BEB4A9F3-C704-4234-89CE-E88CC0D28FBE template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator3>{ 0x338D0CBF,0x9B55,0x4021,{ 0x87,0xCA,0xE6,0x4B,0x9B,0xD6,0x66,0xC7 } }; // 338D0CBF-9B55-4021-87CA-E64B9BD666C7 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator4>{ 0x83737239,0x9311,0x468F,{ 0xBB,0x49,0x47,0xE0,0xDF,0xB5,0xD9,0x3E } }; // 83737239-9311-468F-BB49-47E0DFB5D93E template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinatorStatics>{ 0x7F5D1F2B,0xE04A,0x4D10,{ 0xB3,0x1A,0xA5,0x5C,0x92,0x2C,0xC2,0xFB } }; // 7F5D1F2B-E04A-4D10-B31A-A55C922CC2FB template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>{ 0x6CF1F19A,0x7794,0x4A5A,{ 0x8C,0x68,0xAE,0x87,0x94,0x7A,0x69,0x90 } }; // 6CF1F19A-7794-4A5A-8C68-AE87947A6990 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall2>{ 0x741B46E1,0x245F,0x41F3,{ 0x93,0x99,0x31,0x41,0xD2,0x5B,0x52,0xE3 } }; // 741B46E1-245F-41F3-9399-3141D25B52E3 template <> inline constexpr guid guid_v<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall3>{ 0x0D891522,0xE258,0x4AA9,{ 0x90,0x7A,0x1A,0xA4,0x13,0xC2,0x55,0x23 } }; // 0D891522-E258-4AA9-907A-1AA413C25523 template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::CallAnswerEventArgs>{ using type = winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::CallRejectEventArgs>{ using type = winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs>{ using type = winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::MuteChangeEventArgs>{ using type = winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCall>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCall; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryAddress>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryOptions>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryReader>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryManagerForUser>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStore>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallInfo>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallStore>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallStore; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallVideoCapabilities>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneCallsResult>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneDialOptions>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLine>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLine; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineCellularDetails>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineConfiguration>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineDialResult>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::PhoneVoicemail>{ using type = winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::VoipCallCoordinator>{ using type = winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator; }; template <> struct default_interface<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall>{ using type = winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_AcceptedMedia(uint32_t*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_RejectReason(int32_t*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_State(int32_t*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_Muted(bool*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCall> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall add_StatusChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_StatusChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_AudioDeviceChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_AudioDeviceChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_IsMutedChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_IsMutedChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall get_CallId(void**) noexcept = 0; virtual int32_t __stdcall get_IsMuted(bool*) noexcept = 0; virtual int32_t __stdcall get_Status(int32_t*) noexcept = 0; virtual int32_t __stdcall get_AudioDevice(int32_t*) noexcept = 0; virtual int32_t __stdcall GetPhoneCallInfo(void**) noexcept = 0; virtual int32_t __stdcall GetPhoneCallInfoAsync(void**) noexcept = 0; virtual int32_t __stdcall End(int32_t*) noexcept = 0; virtual int32_t __stdcall EndAsync(void**) noexcept = 0; virtual int32_t __stdcall SendDtmfKey(int32_t, int32_t, int32_t*) noexcept = 0; virtual int32_t __stdcall SendDtmfKeyAsync(int32_t, int32_t, void**) noexcept = 0; virtual int32_t __stdcall AcceptIncoming(int32_t*) noexcept = 0; virtual int32_t __stdcall AcceptIncomingAsync(void**) noexcept = 0; virtual int32_t __stdcall Hold(int32_t*) noexcept = 0; virtual int32_t __stdcall HoldAsync(void**) noexcept = 0; virtual int32_t __stdcall ResumeFromHold(int32_t*) noexcept = 0; virtual int32_t __stdcall ResumeFromHoldAsync(void**) noexcept = 0; virtual int32_t __stdcall Mute(int32_t*) noexcept = 0; virtual int32_t __stdcall MuteAsync(void**) noexcept = 0; virtual int32_t __stdcall Unmute(int32_t*) noexcept = 0; virtual int32_t __stdcall UnmuteAsync(void**) noexcept = 0; virtual int32_t __stdcall RejectIncoming(int32_t*) noexcept = 0; virtual int32_t __stdcall RejectIncomingAsync(void**) noexcept = 0; virtual int32_t __stdcall ChangeAudioDevice(int32_t, int32_t*) noexcept = 0; virtual int32_t __stdcall ChangeAudioDeviceAsync(int32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallBlockingStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_BlockUnknownNumbers(bool*) noexcept = 0; virtual int32_t __stdcall put_BlockUnknownNumbers(bool) noexcept = 0; virtual int32_t __stdcall get_BlockPrivateNumbers(bool*) noexcept = 0; virtual int32_t __stdcall put_BlockPrivateNumbers(bool) noexcept = 0; virtual int32_t __stdcall SetCallBlockingListAsync(void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_Id(void**) noexcept = 0; virtual int32_t __stdcall get_Address(void**) noexcept = 0; virtual int32_t __stdcall put_Address(void*) noexcept = 0; virtual int32_t __stdcall get_Duration(void**) noexcept = 0; virtual int32_t __stdcall put_Duration(void*) noexcept = 0; virtual int32_t __stdcall get_IsCallerIdBlocked(bool*) noexcept = 0; virtual int32_t __stdcall put_IsCallerIdBlocked(bool) noexcept = 0; virtual int32_t __stdcall get_IsEmergency(bool*) noexcept = 0; virtual int32_t __stdcall put_IsEmergency(bool) noexcept = 0; virtual int32_t __stdcall get_IsIncoming(bool*) noexcept = 0; virtual int32_t __stdcall put_IsIncoming(bool) noexcept = 0; virtual int32_t __stdcall get_IsMissed(bool*) noexcept = 0; virtual int32_t __stdcall put_IsMissed(bool) noexcept = 0; virtual int32_t __stdcall get_IsRinging(bool*) noexcept = 0; virtual int32_t __stdcall put_IsRinging(bool) noexcept = 0; virtual int32_t __stdcall get_IsSeen(bool*) noexcept = 0; virtual int32_t __stdcall put_IsSeen(bool) noexcept = 0; virtual int32_t __stdcall get_IsSuppressed(bool*) noexcept = 0; virtual int32_t __stdcall put_IsSuppressed(bool) noexcept = 0; virtual int32_t __stdcall get_IsVoicemail(bool*) noexcept = 0; virtual int32_t __stdcall put_IsVoicemail(bool) noexcept = 0; virtual int32_t __stdcall get_Media(int32_t*) noexcept = 0; virtual int32_t __stdcall put_Media(int32_t) noexcept = 0; virtual int32_t __stdcall get_OtherAppReadAccess(int32_t*) noexcept = 0; virtual int32_t __stdcall put_OtherAppReadAccess(int32_t) noexcept = 0; virtual int32_t __stdcall get_RemoteId(void**) noexcept = 0; virtual int32_t __stdcall put_RemoteId(void*) noexcept = 0; virtual int32_t __stdcall get_SourceDisplayName(void**) noexcept = 0; virtual int32_t __stdcall get_SourceId(void**) noexcept = 0; virtual int32_t __stdcall put_SourceId(void*) noexcept = 0; virtual int32_t __stdcall get_SourceIdKind(int32_t*) noexcept = 0; virtual int32_t __stdcall put_SourceIdKind(int32_t) noexcept = 0; virtual int32_t __stdcall get_StartTime(int64_t*) noexcept = 0; virtual int32_t __stdcall put_StartTime(int64_t) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_ContactId(void**) noexcept = 0; virtual int32_t __stdcall put_ContactId(void*) noexcept = 0; virtual int32_t __stdcall get_DisplayName(void**) noexcept = 0; virtual int32_t __stdcall put_DisplayName(void*) noexcept = 0; virtual int32_t __stdcall get_RawAddress(void**) noexcept = 0; virtual int32_t __stdcall put_RawAddress(void*) noexcept = 0; virtual int32_t __stdcall get_RawAddressKind(int32_t*) noexcept = 0; virtual int32_t __stdcall put_RawAddressKind(int32_t) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddressFactory> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall Create(void*, int32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_DesiredMedia(uint32_t*) noexcept = 0; virtual int32_t __stdcall put_DesiredMedia(uint32_t) noexcept = 0; virtual int32_t __stdcall get_SourceIds(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall ReadBatchAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall RequestStoreAsync(int32_t, void**) noexcept = 0; virtual int32_t __stdcall get_User(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall RequestStoreAsync(int32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetForUser(void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetEntryAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall GetEntryReader(void**) noexcept = 0; virtual int32_t __stdcall GetEntryReaderWithOptions(void*, void**) noexcept = 0; virtual int32_t __stdcall SaveEntryAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall DeleteEntryAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall DeleteEntriesAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall MarkEntryAsSeenAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall MarkEntriesAsSeenAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall GetUnseenCountAsync(void**) noexcept = 0; virtual int32_t __stdcall MarkAllAsSeenAsync(void**) noexcept = 0; virtual int32_t __stdcall GetSourcesUnseenCountAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall MarkSourcesAsSeenAsync(void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_LineId(winrt::guid*) noexcept = 0; virtual int32_t __stdcall get_IsHoldSupported(bool*) noexcept = 0; virtual int32_t __stdcall get_StartTime(int64_t*) noexcept = 0; virtual int32_t __stdcall get_PhoneNumber(void**) noexcept = 0; virtual int32_t __stdcall get_DisplayName(void**) noexcept = 0; virtual int32_t __stdcall get_CallDirection(int32_t*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall ShowPhoneCallUI(void*, void*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall add_CallStateChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_CallStateChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall get_IsCallActive(bool*) noexcept = 0; virtual int32_t __stdcall get_IsCallIncoming(bool*) noexcept = 0; virtual int32_t __stdcall ShowPhoneCallSettingsUI() noexcept = 0; virtual int32_t __stdcall RequestStoreAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetFromId(void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallStore> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall IsEmergencyPhoneNumberAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall GetDefaultLineAsync(void**) noexcept = 0; virtual int32_t __stdcall RequestLineWatcher(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_IsVideoCallingCapable(bool*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilitiesManagerStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetCapabilitiesAsync(void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_OperationStatus(int32_t*) noexcept = 0; virtual int32_t __stdcall get_AllActivePhoneCalls(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_Number(void**) noexcept = 0; virtual int32_t __stdcall put_Number(void*) noexcept = 0; virtual int32_t __stdcall get_DisplayName(void**) noexcept = 0; virtual int32_t __stdcall put_DisplayName(void*) noexcept = 0; virtual int32_t __stdcall get_Contact(void**) noexcept = 0; virtual int32_t __stdcall put_Contact(void*) noexcept = 0; virtual int32_t __stdcall get_ContactPhone(void**) noexcept = 0; virtual int32_t __stdcall put_ContactPhone(void*) noexcept = 0; virtual int32_t __stdcall get_Media(int32_t*) noexcept = 0; virtual int32_t __stdcall put_Media(int32_t) noexcept = 0; virtual int32_t __stdcall get_AudioEndpoint(int32_t*) noexcept = 0; virtual int32_t __stdcall put_AudioEndpoint(int32_t) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLine> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall add_LineChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_LineChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall get_Id(winrt::guid*) noexcept = 0; virtual int32_t __stdcall get_DisplayColor(struct struct_Windows_UI_Color*) noexcept = 0; virtual int32_t __stdcall get_NetworkState(int32_t*) noexcept = 0; virtual int32_t __stdcall get_DisplayName(void**) noexcept = 0; virtual int32_t __stdcall get_Voicemail(void**) noexcept = 0; virtual int32_t __stdcall get_NetworkName(void**) noexcept = 0; virtual int32_t __stdcall get_CellularDetails(void**) noexcept = 0; virtual int32_t __stdcall get_Transport(int32_t*) noexcept = 0; virtual int32_t __stdcall get_CanDial(bool*) noexcept = 0; virtual int32_t __stdcall get_SupportsTile(bool*) noexcept = 0; virtual int32_t __stdcall get_VideoCallingCapabilities(void**) noexcept = 0; virtual int32_t __stdcall get_LineConfiguration(void**) noexcept = 0; virtual int32_t __stdcall IsImmediateDialNumberAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall Dial(void*, void*) noexcept = 0; virtual int32_t __stdcall DialWithOptions(void*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLine2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall EnableTextReply(bool) noexcept = 0; virtual int32_t __stdcall get_TransportDeviceId(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLine3> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall DialWithResult(void*, void*, void**) noexcept = 0; virtual int32_t __stdcall DialWithResultAsync(void*, void*, void**) noexcept = 0; virtual int32_t __stdcall GetAllActivePhoneCalls(void**) noexcept = 0; virtual int32_t __stdcall GetAllActivePhoneCallsAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_SimState(int32_t*) noexcept = 0; virtual int32_t __stdcall get_SimSlotIndex(int32_t*) noexcept = 0; virtual int32_t __stdcall get_IsModemOn(bool*) noexcept = 0; virtual int32_t __stdcall get_RegistrationRejectCode(int32_t*) noexcept = 0; virtual int32_t __stdcall GetNetworkOperatorDisplayText(int32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_IsVideoCallingEnabled(bool*) noexcept = 0; virtual int32_t __stdcall get_ExtendedProperties(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_DialCallStatus(int32_t*) noexcept = 0; virtual int32_t __stdcall get_DialedCall(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall FromIdAsync(winrt::guid, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_DeviceId(void**) noexcept = 0; virtual int32_t __stdcall get_Transport(int32_t*) noexcept = 0; virtual int32_t __stdcall RequestAccessAsync(void**) noexcept = 0; virtual int32_t __stdcall RegisterApp() noexcept = 0; virtual int32_t __stdcall RegisterAppForUser(void*) noexcept = 0; virtual int32_t __stdcall UnregisterApp() noexcept = 0; virtual int32_t __stdcall UnregisterAppForUser(void*) noexcept = 0; virtual int32_t __stdcall IsRegistered(bool*) noexcept = 0; virtual int32_t __stdcall Connect(bool*) noexcept = 0; virtual int32_t __stdcall ConnectAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_AudioRoutingStatus(int32_t*) noexcept = 0; virtual int32_t __stdcall add_AudioRoutingStatusChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_AudioRoutingStatusChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall get_InBandRingingEnabled(bool*) noexcept = 0; virtual int32_t __stdcall add_InBandRingingEnabledChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_InBandRingingEnabledChanged(winrt::event_token) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDeviceStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall FromId(void*, void**) noexcept = 0; virtual int32_t __stdcall GetDeviceSelector(void**) noexcept = 0; virtual int32_t __stdcall GetDeviceSelectorForPhoneLineTransport(int32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall Start() noexcept = 0; virtual int32_t __stdcall Stop() noexcept = 0; virtual int32_t __stdcall add_LineAdded(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_LineAdded(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_LineRemoved(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_LineRemoved(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_LineUpdated(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_LineUpdated(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_EnumerationCompleted(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_EnumerationCompleted(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_Stopped(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_Stopped(winrt::event_token) noexcept = 0; virtual int32_t __stdcall get_Status(int32_t*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_LineId(winrt::guid*) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_Number(void**) noexcept = 0; virtual int32_t __stdcall get_MessageCount(int32_t*) noexcept = 0; virtual int32_t __stdcall get_Type(int32_t*) noexcept = 0; virtual int32_t __stdcall DialVoicemailAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall ReserveCallResourcesAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall add_MuteStateChanged(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_MuteStateChanged(winrt::event_token) noexcept = 0; virtual int32_t __stdcall RequestNewIncomingCall(void*, void*, void*, void*, void*, void*, void*, void*, uint32_t, int64_t, void**) noexcept = 0; virtual int32_t __stdcall RequestNewOutgoingCall(void*, void*, void*, uint32_t, void**) noexcept = 0; virtual int32_t __stdcall NotifyMuted() noexcept = 0; virtual int32_t __stdcall NotifyUnmuted() noexcept = 0; virtual int32_t __stdcall RequestOutgoingUpgradeToVideoCall(winrt::guid, void*, void*, void*, void**) noexcept = 0; virtual int32_t __stdcall RequestIncomingUpgradeToVideoCall(void*, void*, void*, void*, void*, void*, void*, void*, int64_t, void**) noexcept = 0; virtual int32_t __stdcall TerminateCellularCall(winrt::guid) noexcept = 0; virtual int32_t __stdcall CancelUpgrade(winrt::guid) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall SetupNewAcceptedCall(void*, void*, void*, void*, uint32_t, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator3> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall RequestNewAppInitiatedCall(void*, void*, void*, void*, uint32_t, void**) noexcept = 0; virtual int32_t __stdcall RequestNewIncomingCallWithContactRemoteId(void*, void*, void*, void*, void*, void*, void*, void*, uint32_t, int64_t, void*, void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator4> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall ReserveOneProcessCallResourcesAsync(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinatorStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetDefault(void**) noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall add_EndRequested(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_EndRequested(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_HoldRequested(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_HoldRequested(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_ResumeRequested(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_ResumeRequested(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_AnswerRequested(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_AnswerRequested(winrt::event_token) noexcept = 0; virtual int32_t __stdcall add_RejectRequested(void*, winrt::event_token*) noexcept = 0; virtual int32_t __stdcall remove_RejectRequested(winrt::event_token) noexcept = 0; virtual int32_t __stdcall NotifyCallHeld() noexcept = 0; virtual int32_t __stdcall NotifyCallActive() noexcept = 0; virtual int32_t __stdcall NotifyCallEnded() noexcept = 0; virtual int32_t __stdcall get_ContactName(void**) noexcept = 0; virtual int32_t __stdcall put_ContactName(void*) noexcept = 0; virtual int32_t __stdcall get_StartTime(int64_t*) noexcept = 0; virtual int32_t __stdcall put_StartTime(int64_t) noexcept = 0; virtual int32_t __stdcall get_CallMedia(uint32_t*) noexcept = 0; virtual int32_t __stdcall put_CallMedia(uint32_t) noexcept = 0; virtual int32_t __stdcall NotifyCallReady() noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall TryShowAppUI() noexcept = 0; }; }; template <> struct abi<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall3> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall NotifyCallAccepted(uint32_t) noexcept = 0; }; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_ICallAnswerEventArgs { [[nodiscard]] auto AcceptedMedia() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::ICallAnswerEventArgs> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_ICallAnswerEventArgs<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_ICallRejectEventArgs { [[nodiscard]] auto RejectReason() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::ICallRejectEventArgs> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_ICallRejectEventArgs<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_ICallStateChangeEventArgs { [[nodiscard]] auto State() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::ICallStateChangeEventArgs> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_ICallStateChangeEventArgs<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IMuteChangeEventArgs { [[nodiscard]] auto Muted() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IMuteChangeEventArgs> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IMuteChangeEventArgs<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCall { auto StatusChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; using StatusChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneCall>::remove_StatusChanged>; [[nodiscard]] auto StatusChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; auto StatusChanged(winrt::event_token const& token) const noexcept; auto AudioDeviceChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; using AudioDeviceChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneCall>::remove_AudioDeviceChanged>; [[nodiscard]] auto AudioDeviceChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; auto AudioDeviceChanged(winrt::event_token const& token) const noexcept; auto IsMutedChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; using IsMutedChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneCall>::remove_IsMutedChanged>; [[nodiscard]] auto IsMutedChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneCall, winrt::Windows::Foundation::IInspectable> const& handler) const; auto IsMutedChanged(winrt::event_token const& token) const noexcept; [[nodiscard]] auto CallId() const; [[nodiscard]] auto IsMuted() const; [[nodiscard]] auto Status() const; [[nodiscard]] auto AudioDevice() const; auto GetPhoneCallInfo() const; auto GetPhoneCallInfoAsync() const; auto End() const; auto EndAsync() const; auto SendDtmfKey(winrt::Windows::ApplicationModel::Calls::DtmfKey const& key, winrt::Windows::ApplicationModel::Calls::DtmfToneAudioPlayback const& dtmfToneAudioPlayback) const; auto SendDtmfKeyAsync(winrt::Windows::ApplicationModel::Calls::DtmfKey const& key, winrt::Windows::ApplicationModel::Calls::DtmfToneAudioPlayback const& dtmfToneAudioPlayback) const; auto AcceptIncoming() const; auto AcceptIncomingAsync() const; auto Hold() const; auto HoldAsync() const; auto ResumeFromHold() const; auto ResumeFromHoldAsync() const; auto Mute() const; auto MuteAsync() const; auto Unmute() const; auto UnmuteAsync() const; auto RejectIncoming() const; auto RejectIncomingAsync() const; auto ChangeAudioDevice(winrt::Windows::ApplicationModel::Calls::PhoneCallAudioDevice const& endpoint) const; auto ChangeAudioDeviceAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallAudioDevice const& endpoint) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCall> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCall<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallBlockingStatics { [[nodiscard]] auto BlockUnknownNumbers() const; auto BlockUnknownNumbers(bool value) const; [[nodiscard]] auto BlockPrivateNumbers() const; auto BlockPrivateNumbers(bool value) const; auto SetCallBlockingListAsync(param::async_iterable<hstring> const& phoneNumberList) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallBlockingStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallBlockingStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntry { [[nodiscard]] auto Id() const; [[nodiscard]] auto Address() const; auto Address(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryAddress const& value) const; [[nodiscard]] auto Duration() const; auto Duration(winrt::Windows::Foundation::IReference<winrt::Windows::Foundation::TimeSpan> const& value) const; [[nodiscard]] auto IsCallerIdBlocked() const; auto IsCallerIdBlocked(bool value) const; [[nodiscard]] auto IsEmergency() const; auto IsEmergency(bool value) const; [[nodiscard]] auto IsIncoming() const; auto IsIncoming(bool value) const; [[nodiscard]] auto IsMissed() const; auto IsMissed(bool value) const; [[nodiscard]] auto IsRinging() const; auto IsRinging(bool value) const; [[nodiscard]] auto IsSeen() const; auto IsSeen(bool value) const; [[nodiscard]] auto IsSuppressed() const; auto IsSuppressed(bool value) const; [[nodiscard]] auto IsVoicemail() const; auto IsVoicemail(bool value) const; [[nodiscard]] auto Media() const; auto Media(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryMedia const& value) const; [[nodiscard]] auto OtherAppReadAccess() const; auto OtherAppReadAccess(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryOtherAppReadAccess const& value) const; [[nodiscard]] auto RemoteId() const; auto RemoteId(param::hstring const& value) const; [[nodiscard]] auto SourceDisplayName() const; [[nodiscard]] auto SourceId() const; auto SourceId(param::hstring const& value) const; [[nodiscard]] auto SourceIdKind() const; auto SourceIdKind(winrt::Windows::ApplicationModel::Calls::PhoneCallHistorySourceIdKind const& value) const; [[nodiscard]] auto StartTime() const; auto StartTime(winrt::Windows::Foundation::DateTime const& value) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntry> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntry<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryAddress { [[nodiscard]] auto ContactId() const; auto ContactId(param::hstring const& value) const; [[nodiscard]] auto DisplayName() const; auto DisplayName(param::hstring const& value) const; [[nodiscard]] auto RawAddress() const; auto RawAddress(param::hstring const& value) const; [[nodiscard]] auto RawAddressKind() const; auto RawAddressKind(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryRawAddressKind const& value) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddress> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryAddress<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryAddressFactory { auto Create(param::hstring const& rawAddress, winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryRawAddressKind const& rawAddressKind) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryAddressFactory> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryAddressFactory<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryQueryOptions { [[nodiscard]] auto DesiredMedia() const; auto DesiredMedia(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryDesiredMedia const& value) const; [[nodiscard]] auto SourceIds() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryQueryOptions> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryQueryOptions<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryReader { auto ReadBatchAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryEntryReader> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryEntryReader<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerForUser { auto RequestStoreAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStoreAccessType const& accessType) const; [[nodiscard]] auto User() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerForUser> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerForUser<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerStatics { auto RequestStoreAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryStoreAccessType const& accessType) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerStatics2 { auto GetForUser(winrt::Windows::System::User const& user) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryManagerStatics2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryManagerStatics2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryStore { auto GetEntryAsync(param::hstring const& callHistoryEntryId) const; auto GetEntryReader() const; auto GetEntryReader(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntryQueryOptions const& queryOptions) const; auto SaveEntryAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry const& callHistoryEntry) const; auto DeleteEntryAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry const& callHistoryEntry) const; auto DeleteEntriesAsync(param::async_iterable<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry> const& callHistoryEntries) const; auto MarkEntryAsSeenAsync(winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry const& callHistoryEntry) const; auto MarkEntriesAsSeenAsync(param::async_iterable<winrt::Windows::ApplicationModel::Calls::PhoneCallHistoryEntry> const& callHistoryEntries) const; auto GetUnseenCountAsync() const; auto MarkAllAsSeenAsync() const; auto GetSourcesUnseenCountAsync(param::async_iterable<hstring> const& sourceIds) const; auto MarkSourcesAsSeenAsync(param::async_iterable<hstring> const& sourceIds) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallHistoryStore> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallHistoryStore<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallInfo { [[nodiscard]] auto LineId() const; [[nodiscard]] auto IsHoldSupported() const; [[nodiscard]] auto StartTime() const; [[nodiscard]] auto PhoneNumber() const; [[nodiscard]] auto DisplayName() const; [[nodiscard]] auto CallDirection() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallInfo> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallInfo<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallManagerStatics { auto ShowPhoneCallUI(param::hstring const& phoneNumber, param::hstring const& displayName) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallManagerStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallManagerStatics2 { auto CallStateChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const& handler) const; using CallStateChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2>::remove_CallStateChanged>; [[nodiscard]] auto CallStateChanged(auto_revoke_t, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const& handler) const; auto CallStateChanged(winrt::event_token const& token) const noexcept; [[nodiscard]] auto IsCallActive() const; [[nodiscard]] auto IsCallIncoming() const; auto ShowPhoneCallSettingsUI() const; auto RequestStoreAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallManagerStatics2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallManagerStatics2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallStatics { auto GetFromId(param::hstring const& callId) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallStore { auto IsEmergencyPhoneNumberAsync(param::hstring const& number) const; auto GetDefaultLineAsync() const; auto RequestLineWatcher() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallStore> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallStore<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallVideoCapabilities { [[nodiscard]] auto IsVideoCallingCapable() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilities> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallVideoCapabilities<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallVideoCapabilitiesManagerStatics { auto GetCapabilitiesAsync(param::hstring const& phoneNumber) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallVideoCapabilitiesManagerStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallVideoCapabilitiesManagerStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneCallsResult { [[nodiscard]] auto OperationStatus() const; [[nodiscard]] auto AllActivePhoneCalls() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneCallsResult> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneCallsResult<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneDialOptions { [[nodiscard]] auto Number() const; auto Number(param::hstring const& value) const; [[nodiscard]] auto DisplayName() const; auto DisplayName(param::hstring const& value) const; [[nodiscard]] auto Contact() const; auto Contact(winrt::Windows::ApplicationModel::Contacts::Contact const& value) const; [[nodiscard]] auto ContactPhone() const; auto ContactPhone(winrt::Windows::ApplicationModel::Contacts::ContactPhone const& value) const; [[nodiscard]] auto Media() const; auto Media(winrt::Windows::ApplicationModel::Calls::PhoneCallMedia const& value) const; [[nodiscard]] auto AudioEndpoint() const; auto AudioEndpoint(winrt::Windows::ApplicationModel::Calls::PhoneAudioRoutingEndpoint const& value) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneDialOptions> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneDialOptions<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLine { auto LineChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLine, winrt::Windows::Foundation::IInspectable> const& handler) const; using LineChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLine, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLine>::remove_LineChanged>; [[nodiscard]] auto LineChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLine, winrt::Windows::Foundation::IInspectable> const& handler) const; auto LineChanged(winrt::event_token const& token) const noexcept; [[nodiscard]] auto Id() const; [[nodiscard]] auto DisplayColor() const; [[nodiscard]] auto NetworkState() const; [[nodiscard]] auto DisplayName() const; [[nodiscard]] auto Voicemail() const; [[nodiscard]] auto NetworkName() const; [[nodiscard]] auto CellularDetails() const; [[nodiscard]] auto Transport() const; [[nodiscard]] auto CanDial() const; [[nodiscard]] auto SupportsTile() const; [[nodiscard]] auto VideoCallingCapabilities() const; [[nodiscard]] auto LineConfiguration() const; auto IsImmediateDialNumberAsync(param::hstring const& number) const; auto Dial(param::hstring const& number, param::hstring const& displayName) const; auto DialWithOptions(winrt::Windows::ApplicationModel::Calls::PhoneDialOptions const& options) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLine> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLine<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLine2 { auto EnableTextReply(bool value) const; [[nodiscard]] auto TransportDeviceId() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLine2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLine2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLine3 { auto DialWithResult(param::hstring const& number, param::hstring const& displayName) const; auto DialWithResultAsync(param::hstring const& number, param::hstring const& displayName) const; auto GetAllActivePhoneCalls() const; auto GetAllActivePhoneCallsAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLine3> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLine3<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineCellularDetails { [[nodiscard]] auto SimState() const; [[nodiscard]] auto SimSlotIndex() const; [[nodiscard]] auto IsModemOn() const; [[nodiscard]] auto RegistrationRejectCode() const; auto GetNetworkOperatorDisplayText(winrt::Windows::ApplicationModel::Calls::PhoneLineNetworkOperatorDisplayTextLocation const& location) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineCellularDetails> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineCellularDetails<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineConfiguration { [[nodiscard]] auto IsVideoCallingEnabled() const; [[nodiscard]] auto ExtendedProperties() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineConfiguration> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineConfiguration<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineDialResult { [[nodiscard]] auto DialCallStatus() const; [[nodiscard]] auto DialedCall() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineDialResult> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineDialResult<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineStatics { auto FromIdAsync(winrt::guid const& lineId) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDevice { [[nodiscard]] auto DeviceId() const; [[nodiscard]] auto Transport() const; auto RequestAccessAsync() const; auto RegisterApp() const; auto RegisterAppForUser(winrt::Windows::System::User const& user) const; auto UnregisterApp() const; auto UnregisterAppForUser(winrt::Windows::System::User const& user) const; auto IsRegistered() const; auto Connect() const; auto ConnectAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDevice<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDevice2 { [[nodiscard]] auto AudioRoutingStatus() const; auto AudioRoutingStatusChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice, winrt::Windows::Foundation::IInspectable> const& handler) const; using AudioRoutingStatusChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2>::remove_AudioRoutingStatusChanged>; [[nodiscard]] auto AudioRoutingStatusChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice, winrt::Windows::Foundation::IInspectable> const& handler) const; auto AudioRoutingStatusChanged(winrt::event_token const& token) const noexcept; [[nodiscard]] auto InBandRingingEnabled() const; auto InBandRingingEnabledChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice, winrt::Windows::Foundation::IInspectable> const& handler) const; using InBandRingingEnabledChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2>::remove_InBandRingingEnabledChanged>; [[nodiscard]] auto InBandRingingEnabledChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineTransportDevice, winrt::Windows::Foundation::IInspectable> const& handler) const; auto InBandRingingEnabledChanged(winrt::event_token const& token) const noexcept; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDevice2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDevice2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDeviceStatics { auto FromId(param::hstring const& id) const; auto GetDeviceSelector() const; auto GetDeviceSelector(winrt::Windows::ApplicationModel::Calls::PhoneLineTransport const& transport) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineTransportDeviceStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineTransportDeviceStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineWatcher { auto Start() const; auto Stop() const; auto LineAdded(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; using LineAdded_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>::remove_LineAdded>; [[nodiscard]] auto LineAdded(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; auto LineAdded(winrt::event_token const& token) const noexcept; auto LineRemoved(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; using LineRemoved_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>::remove_LineRemoved>; [[nodiscard]] auto LineRemoved(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; auto LineRemoved(winrt::event_token const& token) const noexcept; auto LineUpdated(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; using LineUpdated_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>::remove_LineUpdated>; [[nodiscard]] auto LineUpdated(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::ApplicationModel::Calls::PhoneLineWatcherEventArgs> const& handler) const; auto LineUpdated(winrt::event_token const& token) const noexcept; auto EnumerationCompleted(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::Foundation::IInspectable> const& handler) const; using EnumerationCompleted_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>::remove_EnumerationCompleted>; [[nodiscard]] auto EnumerationCompleted(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::Foundation::IInspectable> const& handler) const; auto EnumerationCompleted(winrt::event_token const& token) const noexcept; auto Stopped(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::Foundation::IInspectable> const& handler) const; using Stopped_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher>::remove_Stopped>; [[nodiscard]] auto Stopped(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::PhoneLineWatcher, winrt::Windows::Foundation::IInspectable> const& handler) const; auto Stopped(winrt::event_token const& token) const noexcept; [[nodiscard]] auto Status() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcher> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineWatcher<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneLineWatcherEventArgs { [[nodiscard]] auto LineId() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneLineWatcherEventArgs> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneLineWatcherEventArgs<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IPhoneVoicemail { [[nodiscard]] auto Number() const; [[nodiscard]] auto MessageCount() const; [[nodiscard]] auto Type() const; auto DialVoicemailAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IPhoneVoicemail> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IPhoneVoicemail<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator { auto ReserveCallResourcesAsync(param::hstring const& taskEntryPoint) const; auto MuteStateChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipCallCoordinator, winrt::Windows::ApplicationModel::Calls::MuteChangeEventArgs> const& muteChangeHandler) const; using MuteStateChanged_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator>::remove_MuteStateChanged>; [[nodiscard]] auto MuteStateChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipCallCoordinator, winrt::Windows::ApplicationModel::Calls::MuteChangeEventArgs> const& muteChangeHandler) const; auto MuteStateChanged(winrt::event_token const& token) const noexcept; auto RequestNewIncomingCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& contactNumber, winrt::Windows::Foundation::Uri const& contactImage, param::hstring const& serviceName, winrt::Windows::Foundation::Uri const& brandingImage, param::hstring const& callDetails, winrt::Windows::Foundation::Uri const& ringtone, winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media, winrt::Windows::Foundation::TimeSpan const& ringTimeout) const; auto RequestNewOutgoingCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& serviceName, winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media) const; auto NotifyMuted() const; auto NotifyUnmuted() const; auto RequestOutgoingUpgradeToVideoCall(winrt::guid const& callUpgradeGuid, param::hstring const& context, param::hstring const& contactName, param::hstring const& serviceName) const; auto RequestIncomingUpgradeToVideoCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& contactNumber, winrt::Windows::Foundation::Uri const& contactImage, param::hstring const& serviceName, winrt::Windows::Foundation::Uri const& brandingImage, param::hstring const& callDetails, winrt::Windows::Foundation::Uri const& ringtone, winrt::Windows::Foundation::TimeSpan const& ringTimeout) const; auto TerminateCellularCall(winrt::guid const& callUpgradeGuid) const; auto CancelUpgrade(winrt::guid const& callUpgradeGuid) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator2 { auto SetupNewAcceptedCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& contactNumber, param::hstring const& serviceName, winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator3 { auto RequestNewAppInitiatedCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& contactNumber, param::hstring const& serviceName, winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media) const; auto RequestNewIncomingCall(param::hstring const& context, param::hstring const& contactName, param::hstring const& contactNumber, winrt::Windows::Foundation::Uri const& contactImage, param::hstring const& serviceName, winrt::Windows::Foundation::Uri const& brandingImage, param::hstring const& callDetails, winrt::Windows::Foundation::Uri const& ringtone, winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media, winrt::Windows::Foundation::TimeSpan const& ringTimeout, param::hstring const& contactRemoteId) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator3> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator3<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator4 { auto ReserveCallResourcesAsync() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinator4> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipCallCoordinator4<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipCallCoordinatorStatics { auto GetDefault() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipCallCoordinatorStatics> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipCallCoordinatorStatics<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipPhoneCall { auto EndRequested(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; using EndRequested_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>::remove_EndRequested>; [[nodiscard]] auto EndRequested(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; auto EndRequested(winrt::event_token const& token) const noexcept; auto HoldRequested(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; using HoldRequested_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>::remove_HoldRequested>; [[nodiscard]] auto HoldRequested(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; auto HoldRequested(winrt::event_token const& token) const noexcept; auto ResumeRequested(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; using ResumeRequested_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>::remove_ResumeRequested>; [[nodiscard]] auto ResumeRequested(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallStateChangeEventArgs> const& handler) const; auto ResumeRequested(winrt::event_token const& token) const noexcept; auto AnswerRequested(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallAnswerEventArgs> const& acceptHandler) const; using AnswerRequested_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>::remove_AnswerRequested>; [[nodiscard]] auto AnswerRequested(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallAnswerEventArgs> const& acceptHandler) const; auto AnswerRequested(winrt::event_token const& token) const noexcept; auto RejectRequested(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallRejectEventArgs> const& rejectHandler) const; using RejectRequested_revoker = impl::event_revoker<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall, &impl::abi_t<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall>::remove_RejectRequested>; [[nodiscard]] auto RejectRequested(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::ApplicationModel::Calls::VoipPhoneCall, winrt::Windows::ApplicationModel::Calls::CallRejectEventArgs> const& rejectHandler) const; auto RejectRequested(winrt::event_token const& token) const noexcept; auto NotifyCallHeld() const; auto NotifyCallActive() const; auto NotifyCallEnded() const; [[nodiscard]] auto ContactName() const; auto ContactName(param::hstring const& value) const; [[nodiscard]] auto StartTime() const; auto StartTime(winrt::Windows::Foundation::DateTime const& value) const; [[nodiscard]] auto CallMedia() const; auto CallMedia(winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& value) const; auto NotifyCallReady() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipPhoneCall<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipPhoneCall2 { auto TryShowAppUI() const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall2> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipPhoneCall2<D>; }; template <typename D> struct consume_Windows_ApplicationModel_Calls_IVoipPhoneCall3 { auto NotifyCallAccepted(winrt::Windows::ApplicationModel::Calls::VoipPhoneCallMedia const& media) const; }; template <> struct consume<winrt::Windows::ApplicationModel::Calls::IVoipPhoneCall3> { template <typename D> using type = consume_Windows_ApplicationModel_Calls_IVoipPhoneCall3<D>; }; } #endif
cbc00332dd19018a4edb1e25d60bbd9f67068b09
b5a5f2a290092cc45a976daaf84f00d8bf37245a
/src/rendering/Texture.cpp
88e45869927f6b753de280a78877d4743f67028d
[]
no_license
pianoman373/voxel-game
bab13463d78ecd6abe26a9c3e96d85ad1f189766
085c2d1292fa9ee2013775105b6d9ce7d303c8d9
refs/heads/master
2021-01-18T17:33:48.507534
2020-05-05T21:45:20
2020-05-05T21:45:20
80,967,631
10
0
null
2019-03-05T03:38:43
2017-02-05T04:04:16
C
UTF-8
C++
false
false
9,008
cpp
#include "rendering/Texture.hpp" #include "rendering/Renderer.hpp" #include "rendering/Mesh.hpp" #include "rendering/Resources.hpp" #include <stb_image.h> #include <glad/glad.h> void Texture::load(const unsigned char *data, int width, int height, bool pixelated, bool singleChannel) { glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); if (singleChannel) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Disable byte-alignment restriction glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, data); } else { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); } if (pixelated) { glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); } else { glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8); } glBindTexture(GL_TEXTURE_2D, 0); } void Texture::load(const Path &file) { stbi_set_flip_vertically_on_load(false); int width, height, components; unsigned char* image = stbi_load(file.toString().c_str(), &width, &height, &components, STBI_rgb_alpha); if (image) { this->load(image, width, height, true, false); stbi_image_free(image); } else { std::cerr << "error loading texture: " << file << std::endl; } } void Texture::loadFromSingleColor(const vec4 &color) { unsigned char image[4] = {(unsigned char)(color.x * 255.0f), (unsigned char)(color.y * 255.0f), (unsigned char)(color.z * 255.0f), (unsigned char)(color.w * 255.0f)}; glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); glBindTexture(GL_TEXTURE_2D, 0); } void Texture::bind(unsigned int unit) const { glActiveTexture(GL_TEXTURE0 + unit); glBindTexture(GL_TEXTURE_2D, id); } unsigned int Texture::getID() const { return id; } void Texture::setID(unsigned int id) { this->id = id; } void Texture::destroy() { glDeleteTextures(1, &id); id = 0; } void Texture::bindNull(unsigned int unit) { glActiveTexture(GL_TEXTURE0 + unit); glBindTexture(GL_TEXTURE_2D, 0); } void TextureArray::load(const unsigned char *data, int width, int height, int layers, bool pixelated, bool singleChannel) { glGenTextures(1,&id); glBindTexture(GL_TEXTURE_2D_ARRAY, id); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, // mipmap level GL_RGBA8, // gpu texel format width, // width height, // height layers, // depth 0, // border GL_RGBA, // cpu pixel format GL_UNSIGNED_BYTE, // cpu pixel coord type data); // pixel data glGenerateMipmap(GL_TEXTURE_2D_ARRAY); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 4); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } void TextureArray::bind(unsigned int unit) const { glActiveTexture(GL_TEXTURE0 + unit); glBindTexture(GL_TEXTURE_2D_ARRAY, id); } unsigned int TextureArray::getID() const { return id; } void TextureArray::destroy() { glDeleteTextures(1, &id); id = 0; } void Cubemap::load(const Path &file1, const Path &file2, const Path &file3, const Path &file4, const Path &file5, const Path &file6) { stbi_set_flip_vertically_on_load(false); glGenTextures(1, &id); glBindTexture(GL_TEXTURE_CUBE_MAP, id); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 10); //stbi_set_flip_vertically_on_load(false); const char *files[] = {file1.toString().c_str(), file2.toString().c_str(), file3.toString().c_str(), file4.toString().c_str(), file5.toString().c_str(), file6.toString().c_str()}; //iterate over all 6 textures and send their raw data to the cubemap for (int i = 0; i < 6; i++) { int width, height; float* image = stbi_loadf(files[i], &width, &height, 0, STBI_rgb); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, width, height, 0, GL_RGB, GL_FLOAT, image); } //interpolation settings and texture wrapping for the texture glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glGenerateMipmap(GL_TEXTURE_CUBE_MAP); } void Cubemap::loadEquirectangular(const Path &file, int resolution) { unsigned int hdrTexture; unsigned int envCubemap; glDepthFunc(GL_LEQUAL); static mat4 captureProjection = perspective(90.0f, 1.0f, 0.1f, 10000.0f); static mat4 captureViews[] = { LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(1.0f, 0.0f, 0.0f), vec3(0.0f, -1.0f, 0.0f)), LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(-1.0f, 0.0f, 0.0f), vec3(0.0f, -1.0f, 0.0f)), LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f)), LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, -1.0f, 0.0f), vec3(0.0f, 0.0f, -1.0f)), LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f), vec3(0.0f, -1.0f, 0.0f)), LookAt(vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 0.0f, -1.0f), vec3(0.0f, -1.0f, 0.0f)) }; stbi_set_flip_vertically_on_load(true); int width, height, nrComponents; float *data = stbi_loadf(file.toString().c_str(), &width, &height, &nrComponents, 0); if (data) { glGenTextures(1, &hdrTexture); glBindTexture(GL_TEXTURE_2D, hdrTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, width, height, 0, GL_RGB, GL_FLOAT, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); stbi_image_free(data); } else { std::cout << "Failed to load HDR image." << std::endl; } unsigned int captureFBO, captureRBO; glGenFramebuffers(1, &captureFBO); glGenRenderbuffers(1, &captureRBO); glBindFramebuffer(GL_FRAMEBUFFER, captureFBO); glBindRenderbuffer(GL_RENDERBUFFER, captureRBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, resolution, resolution); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, captureRBO); glGenTextures(1, &envCubemap); glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap); for (unsigned int i = 0; i < 6; ++i) { // note that we store each face with 16 bit floating point values glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, resolution, resolution, 0, GL_RGB, GL_FLOAT, nullptr); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // convert HDR equirectangular environment map to cubemap equivalent Resources::eq2cubeShader.bind(); Resources::eq2cubeShader.uniformMat4("projection", captureProjection); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, hdrTexture); glViewport(0, 0, resolution, resolution); // don't forget to configure the viewport to the capture dimensions. glBindFramebuffer(GL_FRAMEBUFFER, captureFBO); for (unsigned int i = 0; i < 6; ++i) { Resources::eq2cubeShader.uniformMat4("view", captureViews[i]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, envCubemap, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Resources::cubemapMesh.render(); // renders a 1x1 cube } glBindFramebuffer(GL_FRAMEBUFFER, 0); glDeleteFramebuffers(1, &captureFBO); glDeleteRenderbuffers(1, &captureRBO); this->setID(envCubemap); } void Cubemap::bind(unsigned int unit) const { glActiveTexture(GL_TEXTURE0 + unit); glBindTexture(GL_TEXTURE_CUBE_MAP, id); } unsigned int Cubemap::getID() const { return id; } void Cubemap::setID(unsigned int id) { this->id = id; }
55a9b1e8aab0968b0647bae320cf39084e39611e
343bf12e255b02d2e46fef1662cfb50ffefe1c2d
/main.cpp
3485f05885429eba9298fbbb879ea5f0947b1bca
[ "Apache-2.0" ]
permissive
TimothyZero/Qt-Markdown-Editor
bdc589c05ebe26481f89b4946bda8b0ecbed31a9
7352aaabb64999891a1e0dc51502086fa450ac7e
refs/heads/main
2023-04-19T17:18:29.658079
2021-04-24T11:52:15
2021-04-24T11:52:15
361,142,895
7
1
null
null
null
null
UTF-8
C++
false
false
1,860
cpp
#include "mdeditor.h" #include <QApplication> #include <QDesktopWidget> int main(int argc, char *argv[]) { QApplication app(argc, argv); MDEditor w; w.setMarkdownText(u8R"( 成都市 骨骼 我让 你 [Baidu](https://www.baidu.com/) [测试](https://m/) # 哈哈哈哈 **粗体** *gggg* ++gffff++ *斜体* ~~删除线~~ ++下划线++ H~2~O 2^10^ 1. 有序列表 - 无序列表 - 子列表 sublist - that is very easy to use ## Typographic replacements Enable typographer option to see result. (c) (C) (r) (R) (tm) (TM) (p) (P) +- test.. test... test..... test?..... test!.... !!!!!! ???? ,, -- --- "Smartypants, double quotes" and 'single quotes' ## Emphasis **This is bold text** __This is bold text__ *This is italic text* _This is italic text_ ~~Strikethrough~~ [链接标题](链接地址) this is inline code such as `QPainter` is the way to realize `paintevent` of `HTMLViewer` `代码`高亮可以提示我们阅读重点 ``` w.setTitle("Markdown Test"); w.setTitleFont(QFont(u8"Helvetica,方正悠黑简体 505L",16,57)); w.setEditStyleSheet("background-color:white;color:#333333;"); ``` <table cellpadding="15"> <tr> <td>123</td> <td>123</td> <td>123</td> </tr> </table> )"); w.setTitle("Markdown Test"); w.setTitleFont(QFont(u8"Helvetica,方正悠黑简体 508R",16,57)); // w.setTitleHide(true); QFont font(u8"Helvetica,方正悠黑简体 508R"); font.setPixelSize(14); w.setEditFont(font); w.setPreviewFont(font); // w.setPreviewFont(QFont(u8"portada,方正舒体",14)); w.setEditStyleSheet("background-color:white;color:#333333;"); w.setPreviewStyleSheet("background-color:#FFFFFF;color:#333333;"); w.setStyleSheet("QWidget#MDEditor{background-color:#F8F8F8;}"); w.toPreviewMode(); w.show(); return app.exec(); }
95a6b41761a89796a3dd09b8ab5f81ed218defb5
8c096e28b755defa6c60da44d43e060756796d18
/src/qt/walletview.h
99616a770c068ac508de7aeb7c816b4e5e19058b
[ "MIT" ]
permissive
twairgroup/wondercoin
b9599deae3e1acb40dcaa5f5db3fd89985ba9736
c075c2d0c1a4927d9f04d5100106e369a85128e5
refs/heads/master
2022-07-30T05:46:30.125814
2021-06-13T21:08:03
2021-06-13T21:08:03
361,614,184
1
1
MIT
2021-06-13T08:45:10
2021-04-26T04:13:04
C++
UTF-8
C++
false
false
4,543
h
// Copyright (c) 2011-2016 The Bitcoin Core developers // Copyright (c) 2021 The Wondercoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef WONDERCOIN_QT_WALLETVIEW_H #define WONDERCOIN_QT_WALLETVIEW_H #include "amount.h" #include <QStackedWidget> class WondercoinGUI; class ClientModel; class OverviewPage; class PlatformStyle; class ReceiveCoinsDialog; class SendCoinsDialog; class SendCoinsRecipient; class TransactionView; class WalletModel; class AddressBookPage; QT_BEGIN_NAMESPACE class QModelIndex; class QProgressDialog; QT_END_NAMESPACE /* WalletView class. This class represents the view to a single wallet. It was added to support multiple wallet functionality. Each wallet gets its own WalletView instance. It communicates with both the client and the wallet models to give the user an up-to-date view of the current core state. */ class WalletView : public QStackedWidget { Q_OBJECT public: explicit WalletView(const PlatformStyle *platformStyle, QWidget *parent); ~WalletView(); void setWondercoinGUI(WondercoinGUI *gui); /** Set the client model. The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel *clientModel); /** Set the wallet model. The wallet model represents a wondercoin wallet, and offers access to the list of transactions, address book and sending functionality. */ void setWalletModel(WalletModel *walletModel); bool handlePaymentRequest(const SendCoinsRecipient& recipient); void showOutOfSyncWarning(bool fShow); private: ClientModel *clientModel; WalletModel *walletModel; OverviewPage *overviewPage; QWidget *transactionsPage; ReceiveCoinsDialog *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; AddressBookPage *usedSendingAddressesPage; AddressBookPage *usedReceivingAddressesPage; TransactionView *transactionView; QProgressDialog *progressDialog; const PlatformStyle *platformStyle; public Q_SLOTS: /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to receive coins page */ void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); /** Show incoming transaction notification for new transactions. The new items are those between start and end inclusive, under the given parent item. */ void processNewTransaction(const QModelIndex& parent, int start, int /*end*/); /** Encrypt the wallet */ void encryptWallet(bool status); /** Backup the wallet */ void backupWallet(); /** Change encrypted wallet passphrase */ void changePassphrase(); /** Ask for passphrase to unlock wallet temporarily */ void unlockWallet(); /** Show used sending addresses */ void usedSendingAddresses(); /** Show used receiving addresses */ void usedReceivingAddresses(); /** Re-emit encryption status signal */ void updateEncryptionStatus(); /** Show progress dialog e.g. for rescan */ void showProgress(const QString &title, int nProgress); /** User has requested more information about the out of sync state */ void requestedSyncWarningInfo(); Q_SIGNALS: /** Signal that we want to show the main window */ void showNormalIfMinimized(); /** Fired when a message should be reported to the user */ void message(const QString &title, const QString &message, unsigned int style); /** Encryption status of wallet changed */ void encryptionStatusChanged(int status); /** HD-Enabled status of wallet changed (only possible during startup) */ void hdEnabledStatusChanged(int hdEnabled); /** Notify that a new transaction appeared */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label); /** Notify that the out of sync warning icon has been pressed */ void outOfSyncWarningClicked(); }; #endif // WONDERCOIN_QT_WALLETVIEW_H
f9108fa32ee10a1d34293318232c80ba70df51b3
468067fbc1cba8379bbf1a11dee3ae5e527d122e
/FinalProduct/archive/PUimage/Manification.h
e4373fdeb5d585ab2c4f3d237a25ce560b768cfc
[]
no_license
noticeable/MscProject
b675c87b04892af574082bfceea87027030e1cc3
0aca2d34c9736fc02f0f5a330a63d8653c84490e
refs/heads/master
2020-04-16T22:47:57.775032
2016-10-23T07:46:16
2016-10-23T07:46:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,799
h
#pragma once /*************************************Includes ******************************/ #include <stdio.h> #include <conio.h> #include <iostream> #include <vector> #include <math.h> #include <list> #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgcodecs.hpp" #include "opencv2/opencv.hpp" /****************************************************************************/ #define OUTPUT_FILE "Video_Magnified.avi" #define OUT_WINDOW "After Eulerian Magnification Window" using namespace cv; using namespace std; class Manification { private: int alpha; float lambda_c; float fl; float fh; float chromAttenuation; public: Manification(int _alpha, float _lambda_c, float _fl, float _fh, float _chromAttenuation); ~Manification(); float delta = 0; float lambda = 0; int levels = 5; int length = 0; double rate = 22; std::vector<cv::Mat> lowpass1; std::vector<cv::Mat> lowpass2; int curLevel = 0; float exaggeration_factor = 3.0; void test(); bool buildGaussianPyramid(const Mat &img, const int levels, vector<Mat> &pyramid); bool buildLaplacianPyramid(const Mat &img, const int levels, vector<Mat> &pyramid); void concat(const vector<Mat> &frames, Mat &dst); void createIdealBandpassFilter(cv::Mat &filter, double fl, double fh, double rate); void temporalIdealFilter(const Mat &src, Mat &dst); void deConcat(const Mat &src, const Size &frameSize, vector<cv::Mat> &frames); void amplify2(const Mat &src, Mat &dst); void upsamplingFromGaussianPyramid(const Mat &src, const int levels, Mat &dst); void reconImgFromLaplacianPyramid(const std::vector<cv::Mat> &pyramid, const int levels,cv::Mat &dst); void colorManification(const string& filename); };
4b934c6b3aa20cb8e532bafd2982378b620fa530
440f814f122cfec91152f7889f1f72e2865686ce
/src/game_server/server/event/game_system_event_constants.cpp
d0aac09a802fe5fa0d490952a99d137a67011456
[]
no_license
hackerlank/buzz-server
af329efc839634d19686be2fbeb700b6562493b9
f76de1d9718b31c95c0627fd728aba89c641eb1c
refs/heads/master
2020-06-12T11:56:06.469620
2015-12-05T08:03:25
2015-12-05T08:03:25
null
0
0
null
null
null
null
UTF-8
C++
false
true
380
cpp
/** * Autogenerated by Thrift Compiler (0.9.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "game_system_event_constants.h" namespace game { namespace server { namespace event { const game_system_eventConstants g_game_system_event_constants; game_system_eventConstants::game_system_eventConstants() { } }}} // namespace
f10e90f5ae7e6b84863edac1937f88ba677667c5
ee24ef7aaa7d4ab6a66c56e95953414306302df3
/Cpp/SDK/MagicLeapAR_classes.h
0258c03006fac4ad1eca7f6a9da21bfa04915cfa
[]
no_license
zH4x-SDK/zAWL-SDK
bfc0573125d3398d892c85eac05a6575592db187
3d7001585dab120480e0d16fc24396f61a1d46c6
refs/heads/main
2023-07-15T11:05:51.834741
2021-08-31T15:10:19
2021-08-31T15:10:19
401,745,502
0
0
null
null
null
null
UTF-8
C++
false
false
1,592
h
#pragma once // Name: AWL, Version: 4.24.3 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // Class MagicLeapAR.LuminARUObjectManager // 0x0000 class ULuminARUObjectManager : public UObject { public: static UClass* StaticClass() { static UClass* ptr = UObject::FindClass("Class MagicLeapAR.LuminARUObjectManager"); return ptr; } }; // Class MagicLeapAR.LuminARSessionFunctionLibrary // 0x0000 class ULuminARSessionFunctionLibrary : public UBlueprintFunctionLibrary { public: static UClass* StaticClass() { static UClass* ptr = UObject::FindClass("Class MagicLeapAR.LuminARSessionFunctionLibrary"); return ptr; } void StartLuminARSession(); }; // Class MagicLeapAR.LuminARFrameFunctionLibrary // 0x0000 class ULuminARFrameFunctionLibrary : public UBlueprintFunctionLibrary { public: static UClass* StaticClass() { static UClass* ptr = UObject::FindClass("Class MagicLeapAR.LuminARFrameFunctionLibrary"); return ptr; } void LuminARLineTrace(); void GetTrackingState(); void GetLightEstimation(); }; // Class MagicLeapAR.LuminARSessionConfig // 0x0000 class ULuminARSessionConfig : public UARSessionConfig { public: static UClass* StaticClass() { static UClass* ptr = UObject::FindClass("Class MagicLeapAR.LuminARSessionConfig"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
b1639fc99ddc49d220cc4acc4005dfcb5c0fcf61
5eb7fa95b99d215178696e271e1f5f5627ff2726
/P3d_Arduino/C_Control.cpp
2cd2c4170356b38ad827cab875df8a4b9d9a40a2
[]
no_license
sebascarm/ArduinoP3D
443a1c15bd3c4f4e2c4f0e8e4904d6d111fb4c20
16bad8eb0fa7e52c38df042d86cb946b8a5ed3ee
refs/heads/master
2020-03-12T03:14:26.935009
2018-04-21T04:43:22
2018-04-21T04:43:22
130,420,389
0
0
null
null
null
null
UTF-8
C++
false
false
906
cpp
// // // #include "C_Control.h" #include "C_Comunicacion.h" //Constructor de la clase C_Control::C_Control(TipoControl Tipo) { V_Tipo = Tipo; } void C_Control::AsignarChip(byte Chip, byte Posicion) { V_Chip = Chip; V_Posicion = Posicion; } void C_Control::ComandoSerie(String Comando) { V_Comando = Comando; } // Acciones void C_Control::EnviarComando() { // Cargar Valor desde el chip V_Valor = bitRead(V_Chip, V_Posicion); switch (V_Tipo) { // Enviar SWITCH - Solo cuando los valores son distintos case Switch: if (V_Valor != V_ValorAnt) { V_Comunicacion.Enviar(V_Comando, V_Valor); V_ValorAnt = V_Valor; } break; // Enviar PULSADOR - Solo cuando los valores son distintos y es 1 case Pulsador: if (V_Valor != V_Valor) { V_ValorAnt = V_Valor; if (V_Valor == 1) { V_Comunicacion.Enviar(V_Comando, V_Valor); } } break; default: break; } }
269aec09ee3b2cc8740c906d29912ab1ff3fc417
dc0c9ea3fa7498b0552b5f0cdd121489404cb07a
/project euler/487.cpp
b42adbbd221b9d7cd6a3ca9cbfad070b884e1841
[]
no_license
alaneos777/club
226e7e86983da7f87d87efbfd47d42326872dd25
47da01e884d6324aa1c9f701d6f70b8b978a0e18
refs/heads/master
2023-08-05T02:43:33.428365
2023-07-29T02:43:58
2023-07-29T02:43:58
143,675,419
2
2
null
null
null
null
UTF-8
C++
false
false
1,460
cpp
#include <bits/stdc++.h> using namespace std; using lli = long long int; bool isPrime(lli n){ if(n == 1) return false; for(lli d = 2; d*d <= n; ++d){ if(n % d == 0) return false; } return true; } lli power(lli a, lli b, lli m){ a %= m; if(a < 0) a += m; lli ans = 1; while(b){ if(b & 1) ans = ans * a % m; b >>= 1; a = a * a % m; } return ans % m; } lli f(lli n, int k, lli p){ lli acum = 0; vector<lli> pol(k+2); for(int i = 0; i <= k+1; ++i){ pol[i] = acum; acum += power(i+1, k, p); if(acum >= p) acum -= p; } if(n <= k+1) return pol[n]; lli prod = 1; for(int i = 0; i <= k+1; ++i){ prod = prod * (n%p - i) % p; if(prod < 0) prod += p; } if((k+1)%2 == 1) prod = (p - prod) % p; lli sum = 0; lli alt = 1; lli fact_a = 1, fact_b = 1; for(int i = 1; i <= k+1; ++i){ fact_b = fact_b * i % p; } for(int i = 0; i <= k+1; ++i){ assert((n%p - i) % p != 0); sum += pol[i] * alt % p * power(n - i, p-2, p) % p * power(fact_a, p-2, p) % p * power(fact_b, p-2, p) % p; if(sum >= p) sum -= p; alt = p - alt; fact_a = fact_a * (i + 1) % p; fact_b = fact_b * power(k+1-i, p-2, p) % p; } return sum * prod % p; } lli S(lli n, int k, lli p){ n %= p; lli ans = (n+1)*f(n, k, p) % p - f(n, k+1, p); if(ans < 0) ans += p; return ans; } int main(){ int n = 2e9; lli ans = 0; for(lli p = n; p <= n+2000; ++p){ if(!isPrime(p)) continue; ans += S(lli(1e12), 10000, p); } cout << ans << "\n"; return 0; }
03a735ba6662dcad9539fbae78d76cad6e9f400d
44ce80cbdf6bb75f6131e83029febfc97915ebda
/main.cpp
53c6079e3d081ed12d87901a373b9bb0cf65a63c
[]
no_license
utec-ads-2019-2/joseph-305-Fgarcia19
bfa1ed14ae4dd8b5133dac7981ec4e4535fc80e7
feb94667ac59698ac11f73922ea7236ecbb0c0be
refs/heads/master
2020-08-14T17:45:11.989775
2019-10-16T05:28:43
2019-10-16T05:28:43
215,210,126
0
0
null
null
null
null
UTF-8
C++
false
false
707
cpp
#include <iostream> #include <map> #include <iterator> #include <vector> using namespace std; map<int,int>anteriores; int me(int k){ int m=k,matar,eliminados; while (true){ eliminados=0; matar=(m-1)%(2*k-eliminados); while (matar>=k && eliminados<k){ eliminados++; matar = (matar-1+m)%(2*k-eliminados); } if (eliminados==k){ anteriores[k]=m; break; } m++; } return m; } int main() { int k; cin>>k; while (k!=0){ if(anteriores[k]){ cout<<anteriores[k]<<endl; } else cout<<me(k)<<endl; cin>>k; } return 0; }
754a7eee203c517c219991f6fdf5be76a04c09fd
156de3c57af4c6541b0c1cabfc933fb622aef44f
/.RootCoreBin/include/xAODRootAccess/tools/TIncident.h
3afabfa258f54dbf526b0b79b6cc6ddb5a85c4a5
[]
no_license
Crashtime/ATLAS-JetCleaning
704937a36e2b7c1d6908745eef1d02923b274447
442f298bfcd9196bef86b978588cce0c430507d7
refs/heads/master
2021-01-21T09:06:30.007753
2016-09-16T21:48:22
2016-09-16T21:48:22
68,410,571
0
1
null
null
null
null
UTF-8
C++
false
false
2,369
h
// Dear emacs, this is -*- c++ -*- // $Id: TIncident.h 676314 2015-06-18 12:07:05Z krasznaa $ #ifndef XAODROOTACCESS_TOOLS_TINCIDENT_H #define XAODROOTACCESS_TOOLS_TINCIDENT_H // System include(s): #include <iosfwd> // ROOT include(s): #include <Rtypes.h> namespace xAOD { /// Namespace mirroring Gaudi's IncidentType namespace /// /// This namespace holds the helper values for identifying the different /// type of incidents that are dispatched from TEvent. /// namespace IncidentType { /// A new input file was just opened static const ::Int_t BeginInputFile = 1; /// A new event was just loaded static const ::Int_t BeginEvent = 2; /// The metadata for the output file should be written out static const ::Int_t MetaDataStop = 3; /// The processing of an input file has finished /// /// Note that this is not a "reliable" incident. The code doesn't force /// the user to process all events from a file before switching to the /// next file. The incident is just here to allow a dual-use /// implementation for the luminosity handling code. But regular analysis /// code should not be written to rely on this incident. /// static const ::Int_t EndInputFile = 4; } // namespace IncidentType /// Class describing a certain "incident" that is communicated to user code /// /// Objects of this type are dispached to all user objects that implement /// the TVirtualIncidentListener interface, and have registered themselves /// to receive notifications from the TEvent object when certain things /// happen. /// /// Naturally, this is very much just a copy of Gaudi's Incident class. /// /// @author Attila Krasznahorkay <[email protected]> /// /// $Revision: 676314 $ /// $Date: 2015-06-18 14:07:05 +0200 (Thu, 18 Jun 2015) $ /// class TIncident { public: /// Constructor with a type TIncident( ::Int_t type ); /// Return the type of the incident ::Int_t type() const; private: /// The type of this incident ::Int_t m_type; }; // class TIncident } // namespace xAOD /// Convenience print operator for xAOD::TIncident objects std::ostream& operator<< ( std::ostream& out, const xAOD::TIncident& inc ); #endif // XAODROOTACCESS_TOOLS_TINCIDENT_H
062d2177264e1905a06e112974c8816034fad329
96cdd688d382b4625d3dbcdda9c3fd2a72ac71cb
/src/test/test_globalboost.cpp
16785b7c4707294414c6c0d505a84bbdb42858a2
[ "MIT" ]
permissive
getcoin/globalboosty
fecb7a11156cc2ea1a72ac70506a8ce2fc0807bd
42ff9cd61185301c9dcf236bbfbfd1aa453a3e68
refs/heads/master
2021-01-18T14:15:45.810413
2014-07-16T00:11:19
2014-07-16T00:11:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,235
cpp
// Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #define BOOST_TEST_MODULE Bitcoin Test Suite #include "main.h" #include "txdb.h" #include "ui_interface.h" #include "util.h" #ifdef ENABLE_WALLET #include "db.h" #include "wallet.h" #endif #include <boost/filesystem.hpp> #include <boost/test/unit_test.hpp> CWallet* pwalletMain; extern bool fPrintToConsole; extern void noui_connect(); struct TestingSetup { CCoinsViewDB *pcoinsdbview; boost::filesystem::path pathTemp; boost::thread_group threadGroup; TestingSetup() { fPrintToDebugLog = false; // don't want to write to debug.log file noui_connect(); #ifdef ENABLE_WALLET bitdb.MakeMock(); #endif pathTemp = GetTempPath() / strprintf("test_globalboost_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); boost::filesystem::create_directories(pathTemp); mapArgs["-datadir"] = pathTemp.string(); pblocktree = new CBlockTreeDB(1 << 20, true); pcoinsdbview = new CCoinsViewDB(1 << 23, true); pcoinsTip = new CCoinsViewCache(*pcoinsdbview); InitBlockIndex(); #ifdef ENABLE_WALLET bool fFirstRun; pwalletMain = new CWallet("wallet.dat"); pwalletMain->LoadWallet(fFirstRun); RegisterWallet(pwalletMain); #endif nScriptCheckThreads = 3; for (int i=0; i < nScriptCheckThreads-1; i++) threadGroup.create_thread(&ThreadScriptCheck); RegisterNodeSignals(GetNodeSignals()); } ~TestingSetup() { threadGroup.interrupt_all(); threadGroup.join_all(); UnregisterNodeSignals(GetNodeSignals()); #ifdef ENABLE_WALLET delete pwalletMain; pwalletMain = NULL; #endif delete pcoinsTip; delete pcoinsdbview; delete pblocktree; #ifdef ENABLE_WALLET bitdb.Flush(true); #endif boost::filesystem::remove_all(pathTemp); } }; BOOST_GLOBAL_FIXTURE(TestingSetup); void Shutdown(void* parg) { exit(0); } void StartShutdown() { exit(0); } bool ShutdownRequested() { return false; }
[ "bst32@bst32-virtual-machine.(none)" ]
bst32@bst32-virtual-machine.(none)
39793e23df5e13bb1e63111d97daf687e7291b31
92580cb7b00714ef3427dcb6905ce6e0a1a226b3
/Code/object.h
768c9b805117e7d60d031d17e4ac8bb35056db73
[ "MIT" ]
permissive
Theys96/Raytracer_2
948a02f57b442205232273b8aa3b7484bc0a25ff
d00c9ea6968e55d69fce9f565b9c122bfd815e63
refs/heads/master
2021-04-26T22:21:30.954893
2018-03-11T20:29:41
2018-03-11T20:29:41
124,077,956
0
0
null
2018-03-11T20:21:57
2018-03-06T12:52:21
C++
UTF-8
C++
false
false
559
h
#ifndef OBJECT_H_ #define OBJECT_H_ #include "material.h" // not really needed here, but deriving classes may need them #include "hit.h" #include "ray.h" #include "triple.h" #include <memory> class Object; typedef std::shared_ptr<Object> ObjectPtr; class Object { public: Material material; virtual ~Object() = default; virtual Color colorAt(Point const &point) = 0; virtual Hit intersect(Ray const &ray) = 0; // must be implemented // in derived class }; #endif
1aca75f33eeb89a254626ace90dfce14a498021d
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5738606668808192_0/C++/krzysobusiak/c.cpp
1881c654af1e255b9b0f1c13f94f1184fd88305e
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,968
cpp
#include <iostream> #include <bitset> #include <string> #include <vector> using namespace std; typedef unsigned long long ull; vector<int> primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541 }; int get_divisor(ull num) { for (int p: primes) { if ((num % p) == 0) return p; } return 0; } vector<int> get_divisors(string s) { vector<int> divs; for (int base = 2; base <= 10; base++) { ull num = strtoull(s.c_str(), NULL, base); int div = get_divisor(num); if (!div) return vector<int>(); // divs.push_back(base); // divs.push_back(num); divs.push_back(div); } return divs; } int main() { int t; cin >> t; for (int i = 1; i <= t; i++) { int n, j; cin >> n >> j; cout << "Case #" << i << ":" << endl; unsigned bin = (1 << (n - 1)) + 1; while (j > 0) { string s = bitset<16>(bin).to_string(); vector<int> divs = get_divisors(s); if (!divs.empty()) { cout << s; for (int d: divs) cout << " " << d; cout << endl; j--; } bin += 2; } } return 0; }
0f675829c5e55fb40a5a9f3bcc66337dccd11bf6
e76ea38dbe5774fccaf14e1a0090d9275cdaee08
/src/chrome/test/base/interactive_test_utils_win.cc
7a4f747aaaa3303683c1be4b0752f876bb201450
[ "BSD-3-Clause" ]
permissive
eurogiciel-oss/Tizen_Crosswalk
efc424807a5434df1d5c9e8ed51364974643707d
a68aed6e29bd157c95564e7af2e3a26191813e51
refs/heads/master
2021-01-18T19:19:04.527505
2014-02-06T13:43:21
2014-02-06T13:43:21
16,070,101
1
3
null
null
null
null
UTF-8
C++
false
false
1,986
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/test/base/interactive_test_utils.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "chrome/browser/ui/window_snapshot/window_snapshot.h" #include "ui/base/test/ui_controls.h" #include "ui/base/win/foreground_helper.h" #include "ui/views/focus/focus_manager.h" #if defined(USE_AURA) #include "chrome/browser/ui/host_desktop.h" #include "chrome/test/base/interactive_test_utils_aura.h" #include "ui/aura/root_window.h" #endif namespace ui_test_utils { void HideNativeWindow(gfx::NativeWindow window) { #if defined(USE_AURA) if (chrome::GetHostDesktopTypeForNativeWindow(window) == chrome::HOST_DESKTOP_TYPE_ASH) { HideNativeWindowAura(window); return; } HWND hwnd = window->GetDispatcher()->GetAcceleratedWidget(); #else HWND hwnd = window; #endif ::ShowWindow(hwnd, SW_HIDE); } bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { #if defined(USE_AURA) if (chrome::GetHostDesktopTypeForNativeWindow(window) == chrome::HOST_DESKTOP_TYPE_ASH) ShowAndFocusNativeWindowAura(window); window->Show(); // Always make sure the window hosting ash is visible and focused. HWND hwnd = window->GetDispatcher()->GetAcceleratedWidget(); #else HWND hwnd = window; #endif ::ShowWindow(hwnd, SW_SHOW); if (GetForegroundWindow() != hwnd) { VLOG(1) << "Forcefully refocusing front window"; ui::ForegroundHelper::SetForeground(hwnd); } // ShowWindow does not necessarily activate the window. In particular if a // window from another app is the foreground window then the request to // activate the window fails. See SetForegroundWindow for details. return GetForegroundWindow() == hwnd; } } // namespace ui_test_utils
693fcdecb9216523f4555f640b9974e167473ea3
615bd336a8026dc73c7b48f885dbae32f3799ec9
/codeforces/71/A.cpp
5bbea47882926ae237b9b5bdd92ad762fdf5eaa6
[]
no_license
yash-gupta2000/CP_Codeforces
82c842a8775229a1ab6da027f8b2471bbfc849f9
c22b8ebe57f705c239a075def7a479192213c266
refs/heads/master
2023-02-09T02:04:42.817749
2018-12-14T05:50:00
2020-12-21T07:49:38
323,261,076
0
0
null
null
null
null
UTF-8
C++
false
false
406
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=0;i<n;i++) { string s; cin>>s; int counter; int l; l=s.length()-1; if(s.length()>10) { counter=s.length()-2; cout<<s[0]; cout<<counter; cout<<s[l]<<endl; } else { cout<<s<<endl; } } return 0; }
d3c4e12b53aeb95c714711ecc6967bb59a1236a4
040d1bac5443524d6207a98c2ac8b7e9741e534f
/testqmlview.h
4527f21cf8f38ca68544370a70360a7a1a52ded2
[]
no_license
sapr-bntu/chmEditorQml
8c58cb90b54c59bdd9dc6a6a91cf78ae779af646
e2327eccd0baf58e552d5b2f4b6b0227d988375f
refs/heads/master
2021-01-01T05:49:00.282928
2012-05-04T09:45:42
2012-05-04T09:45:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
641
h
#ifndef TESTQMLVIEW_H #define TESTQMLVIEW_H #include <QWidget> #include <QDeclarativeView> #include <QToolBar> namespace Ui { class TestQmlView; } class TestQmlView : public QWidget { Q_OBJECT public: explicit TestQmlView(QWidget *parent = 0); ~TestQmlView(); void setQml(const QUrl & url); QDeclarativeView * declarativeView() const { return dview; } protected: void changeEvent(QEvent *e); signals: void goUp(); void goDown(); private: Ui::TestQmlView *ui; QDeclarativeView * dview; QToolBar * toolbar; QAction * up; QAction * down; }; #endif // TESTQMLVIEW_H
3268158041acce8570a63f4faea538b4b9722842
e3a3ab7183a7d3301344f139830513a2336f3bef
/code/Window.cpp
963e5bb5b0fe3f9eb830bd00094f51c06029d703
[ "MIT" ]
permissive
gtnardy/flappy_cow
1c29fd61b1bdcf343d8f857e93a83c2c421108bf
bde49ac7e67194355e0011a53b88cf99ecd5ab83
refs/heads/master
2021-09-07T02:18:25.631255
2018-02-15T18:17:18
2018-02-15T18:17:18
111,725,161
0
0
null
null
null
null
UTF-8
C++
false
false
1,606
cpp
#include "Window.h" #include <iostream> #include <SDL_image.h> #include <SDL_mixer.h> #include <SDL_ttf.h> SDL_Renderer *Window::renderer = nullptr; Window::Window(const std::string & title, int width, int height): _title(title), _height(height), _width(width) { _closed = !init(); } Window::~Window() { SDL_DestroyRenderer(renderer); SDL_DestroyWindow(_window); SDL_Quit(); IMG_Quit(); TTF_Quit(); Mix_Quit(); } void Window::pollEvents(SDL_Event &event) { switch (event.type) { case SDL_QUIT: _closed = true; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_ESCAPE: _closed = true; break; } break; default: break; } } bool Window::init() { if (SDL_Init(SDL_INIT_VIDEO || SDL_INIT_AUDIO) != 0) { std::cerr << "Erro"; return false; } if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { std::cerr << "Erro Som"; return 0; } if (IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG) { std::cerr << "Erro imagem"; return false; } if (TTF_Init() == -1) { std::cerr << "Erro ttf"; return false; } _window = SDL_CreateWindow( _title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _width, _height, SDL_WINDOW_SHOWN ); if (_window == nullptr) { std::cerr << "Erro2"; return false; } renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (renderer == nullptr) { std::cerr << "Erro3"; } return true; } void Window::clear() const { SDL_RenderPresent(renderer); SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); SDL_RenderClear(renderer); }
cd9f0fb076f61b71da0c1da1b9e986aba5ff32bf
3b1d6d067672a0c9762e88982f52cf1518468bcd
/src/librealsense/device.cpp
41d2e81b2d5e8cf92970fdb872d0f64ac88d1d9e
[ "MIT" ]
permissive
tingshao/node-realsense-1
69c05c6cc796c71a7bd9a912d443afbdabdd045e
cf888a183b17e309976e1b587aed30031674133f
refs/heads/master
2020-04-06T04:43:52.932733
2017-02-23T05:32:17
2017-02-23T05:32:17
82,892,004
1
0
null
2017-02-23T06:20:09
2017-02-23T06:20:09
null
UTF-8
C++
false
false
3,828
cpp
// Copyright (c) 2016 Intel Corporation. All rights reserved. // Use of this source code is governed by a MIT-style license that can be // found in the LICENSE file. #include "device.h" #include <functional> #include "common/task/async_task_runner_instance.h" #include "device_runner.h" #include "gen/mode.h" #include "rs_payload.h" #include "rs_task.h" #define POST_DEVICE_PROMISE_TASK(type, method, message, ...) \ auto payload = new RSPayload<type>(); \ return AsyncTaskRunnerInstance::GetInstance()->PostPromiseTask( \ new RSPromiseTask<type>( \ std::bind(&DeviceRunner::method, device_runner_.get(), \ ##__VA_ARGS__)), \ payload, \ #message); \ Device::Device() : device_runner_(nullptr) { } Device::Device(const Device& rhs) { // TODO(widl-nan): copy from rhs if you want this behavior // Or mark ctor = delete in device.h } Device::~Device() { // TODO(widl-nan): do cleanup if necessary } Device& Device::operator = (const Device& rhs) { if (&rhs != this) { // TODO(widl-nan): copy members from rhs } return *this; } v8::Handle<v8::Promise> Device::getName() { POST_DEVICE_PROMISE_TASK(std::string, GetName, {{GET_NAME MESSAGE}}) } v8::Handle<v8::Promise> Device::getSerial() { POST_DEVICE_PROMISE_TASK(std::string, GetSerial, {{GET_SERIAL MESSAGE}}); } v8::Handle<v8::Promise> Device::getFirmwareVersion() { POST_DEVICE_PROMISE_TASK(std::string, GetFirmwareVersion, {{GET_FRIMWARE_VERSION MESSAGE}}); } v8::Handle<v8::Promise> Device::getDepthScale() { POST_DEVICE_PROMISE_TASK(double, GetDepthScale, {{GET_DEPTH_SCALE MESSAGE}}); } v8::Handle<v8::Promise> Device::isStreaming() { POST_DEVICE_PROMISE_TASK(bool, IsStreaming, {{GET_DEPTH_SCALE MESSAGE}}); } v8::Handle<v8::Promise> Device::supportsOption(const std::string& option) { POST_DEVICE_PROMISE_TASK(bool, SupportsOption, {{GET_OPTION_SUPPORT MESSAGE}}, option); } v8::Handle<v8::Promise> Device::getStreamModeCount(const std::string& stream) { POST_DEVICE_PROMISE_TASK(int, GetStreamModeCount, {{GET_STREAM_MODE_COUNT MESSAGE}}, stream); } v8::Handle<v8::Promise> Device::getStreamMode(const std::string& stream, const int32_t& index) { POST_DEVICE_PROMISE_TASK(DictionaryMode, GetStreamMode, {{GET_STREAM_MODE MESSAGE}}, stream, index);} v8::Handle<v8::Promise> Device::isStreamEnabled(const std::string& stream) { POST_DEVICE_PROMISE_TASK(bool, IsStreamEnabled, {{GET_STREAM_ENABLE MESSAGE}}, stream); } v8::Handle<v8::Promise> Device::enableStream(const std::string& stream, const Mode& mode) { DictionaryMode dictMode(mode); POST_DEVICE_PROMISE_TASK(void, EnableStream, {{ENABLE_STREAM MESSAGE}}, stream, dictMode); } v8::Handle<v8::Promise> Device::getStreamWidth(const std::string& stream) { POST_DEVICE_PROMISE_TASK(int, GetStreamWidth, {{GET_STREAM_WIDTH MESSAGE}}, stream); } v8::Handle<v8::Promise> Device::getStreamHeight(const std::string& stream) { POST_DEVICE_PROMISE_TASK(int, GetStreamHeight, {{GET_STREAM_HEIGHT MESSAGE}}, stream); } v8::Handle<v8::Promise> Device::getFrameTimeStamp(const std::string& stream) { POST_DEVICE_PROMISE_TASK(int, GetFrameTimeStamp, {{GET_FRAME_TIMESTAMP MESSAGE}}, stream); } v8::Handle<v8::Promise> Device::start() { POST_DEVICE_PROMISE_TASK(void, Start, {{START_DEVICE MESSAGE}}); } v8::Handle<v8::Promise> Device::stop() { POST_DEVICE_PROMISE_TASK(void, Stop, {{STOP_DEVICE MESSAGE}}); } void Device::SetDeviceRunner(DeviceRunner* runner) { device_runner_.reset(runner); runner->SetJavaScriptThis(Nan::New(js_this_)); } void Device::SetJavaScriptThis(v8::Local<v8::Object> obj) { js_this_.Reset(obj); device_runner_->SetJavaScriptThis(obj); }
c62a69db13e612e7bbaebb6791f733efad2dca56
5d2ba61e213a9330ee51b0fa55ac3f3ca2ccc579
/TestGame/ThreatsObject.cpp
a3eb542380072b715cdabe6e9411e430c5d3b86f
[]
no_license
nghiachaunamdinh/API_BTL
7ff0ee996bb66c1531f7021be747e388774f6198
8ab4a63fdabc7dd159b1afd3403ae8e7f576347b
refs/heads/master
2022-11-23T04:02:13.143951
2020-08-01T03:35:26
2020-08-01T03:35:26
284,179,545
1
0
null
null
null
null
UTF-8
C++
false
false
1,686
cpp
#include"ThreatsObject.h" ThreatsOject::ThreatsOject() { rect_.x = SCREEN_WIDTH*0.5; rect_.y =0; rect_.w = 70; rect_.h = 70; x_val_ = 0; y_val_ = 0; } ThreatsOject::~ThreatsOject() { } void ThreatsOject::InitAmo(AmoObject* p_amo) { if (p_amo) { bool ret = p_amo->LoadImg("sphere.png"); if (ret) { p_amo->set_is_move(true); p_amo->SetWidthHeight(WIDTH_SPHERE, HEIGHT_SPHERE); p_amo->set_type(AmoObject::SPHERE); p_amo->setRect(rect_.x+rect_.w*0.5, rect_.y); p_amo_list_.push_back(p_amo); } } } void ThreatsOject::MakeAmo(SDL_Surface* des, const int& x_limit, const int& y_limit) { for (int i = 0; i < p_amo_list_.size(); ++i) { AmoObject* p_amo = p_amo_list_.at(i); if (p_amo) { if (p_amo->get_is_move()) { p_amo->show(des); p_amo->HandleMoveSearch(3); } else { p_amo->set_is_move(true); p_amo->setRect(rect_.x +x_val_, rect_.y+y_val_); } } } } void ThreatsOject::HandleMove(const int& x_border, const int& y_border) { //SDL_Delay(5); rect_.y += y_val_; if (rect_.y > SCREEN_HEIGHT) { rect_.y = 0; int rand_x = rand() % 400; if (rand_x > SCREEN_WIDTH - 20) { rand_x = SCREEN_WIDTH * 0.3; } rect_.x = rand_x; } } void ThreatsOject::HandleInputAction(SDL_Event events) { } void ThreatsOject::Reset(const int& yborder) { rect_.y = yborder; int rand_x = rand() % 400; if (rand_x > SCREEN_WIDTH) { rand_x = SCREEN_WIDTH * 0.3; } rect_.x = rand_x; for (int i = 0; i < p_amo_list_.size(); ++i) { AmoObject* p_amo = p_amo_list_.at(i); if (p_amo) { ResetAmo(p_amo); } } } void ThreatsOject::ResetAmo(AmoObject* p_amo) { p_amo->setRect(rect_.x + rect_.w*0.5, rect_.y); }
[ "nghiachaunghiahung.com" ]
nghiachaunghiahung.com
aa1e2bb25e107c8ab0f2f18f0135c5f614aff1d7
7cb47a1edbc5a74a00af0e9e7b67cacf448994f0
/pfm/msvc/src/main.hpp
b0132f80f1f53a5526c891fd293290388a29033c
[ "MIT" ]
permissive
indigoabstract/techno-globe
2c24819abe9774309fa7a9175c1c63676c31571a
1f01b231bece534282344fa660d5f9a8cc07262e
refs/heads/master
2021-04-06T10:25:27.866859
2018-04-11T12:18:42
2018-04-11T12:18:42
125,355,507
0
0
null
null
null
null
UTF-8
C++
false
false
2,273
hpp
#pragma once #include "pfm.hpp" #if defined PLATFORM_WINDOWS_PC #define _UNICODE #define UNICODE #define NOMINMAX #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include "pfm.hpp" #include <windows.h> #include <shellapi.h> enum lnk_subsystem { subsys_console, subsys_windows, }; class msvc_main : public pfm_main { public: virtual ~msvc_main(); static shared_ptr<msvc_main> get_instance(); static shared_ptr<pfm_impl::pfm_file_impl> new_pfm_file_impl(const std::string& ifilename, const std::string& iroot_dir); virtual void init() override; virtual void start() override; virtual void run() override; virtual int get_screen_dpi()const; virtual void write_text(const char* text)const; virtual void write_text_nl(const char* text)const; virtual void write_text(const wchar_t* text)const; virtual void write_text_nl(const wchar_t* text)const; virtual void write_text_v(const char* iformat, ...)const; virtual std::string get_writable_path()const; umf_list get_directory_listing(const std::string& idirectory, umf_list iplist, bool is_recursive); bool init_app(int argc, char** argv); int main_loop(); void set_params(HINSTANCE ihinstance, bool incmd_show, lnk_subsystem isubsys); HWND get_hwnd(); HMENU get_hmenu(); void set_hmenu(HMENU ihmenu); UINT get_taskbar_created_msg(); void minimize_window(); void restore_window(); bool is_full_screen_mode(); void set_full_screen_mode(bool ienabled); RECT get_window_coord(); private: msvc_main(); void init_notify_icon_data(); int console_main_loop(); int win_main_loop(); bool create_open_gl_context(); bool create_open_gl_es_ctx(); bool create_open_gl_glew_ctx(); void destroy_open_gl_context(); static shared_ptr<msvc_main> instance; bool is_fullscreen; RECT window_coord; bool disable_paint; lnk_subsystem subsys; bool app_has_window; HINSTANCE hinstance; bool ncmd_show; HWND hwnd; HMENU hmenu; NOTIFYICONDATA notify_icon_data; UINT wm_taskbarcreated; HDC hdc_window; HANDLE console_handle; #if defined USES_OPENGL_ES EGLDisplay egl_display; EGLConfig egl_config; EGLSurface egl_surface; EGLContext egl_context; NativeWindowType egl_window; EGLint pi32_config_attribs[128]; #else HGLRC hgl_rendering_context; #endif }; #endif
71483824c0f59133c278bb044209ee232882be55
812e76ad3d7c399f22d32fadb8e423872cd4ceec
/Source/MyProject/UI/DocumentPicker/DocumentPicker.cpp
c82702058065daf4fd8e0da56b020d062e3f8438
[]
no_license
LiamKujawski/MyProject
107508baa9366b3c12592aa846b9988427af07b5
1ae24e8cc7ad8a62f3ec617f81ee69a47d0ff126
refs/heads/master
2023-05-13T18:07:36.018981
2021-06-03T23:34:32
2021-06-03T23:34:32
372,963,081
0
0
null
null
null
null
UTF-8
C++
false
false
1,359
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "DocumentPicker.h" #include "../../Saving/UICreatorSaveGameIndex.h" #include "ActionBar.h" #include "DocumentGrid.h" // Sets default values ADocumentPicker::ADocumentPicker() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root")); SetRootComponent(Root); DocumentGrid = CreateDefaultSubobject<UWidgetComponent>(TEXT("DocumentGrid")); DocumentGrid->SetupAttachment(GetRootComponent()); ActionBar = CreateDefaultSubobject<UWidgetComponent>(TEXT("ActionBar")); ActionBar->SetupAttachment(GetRootComponent()); } // Called when the game starts or when spawned void ADocumentPicker::BeginPlay() { Super::BeginPlay(); // Grab docment grid widget, cast it to document grid and add it as child UDocumentGrid* DocumentGridWidget = Cast<UDocumentGrid>(DocumentGrid->GetUserWidgetObject()); if (!DocumentGrid) return; UActionBar* ActionBarWidget = Cast<UActionBar>(ActionBar->GetUserWidgetObject()); if (!DocumentGrid) return; int32 Index = 0; for (FString SlotName : UUICreatorSaveGameIndex::Load()->GetSlotNames()) { DocumentGridWidget->AddDocument(Index, SlotName); ++Index; } }
d636a5676d97087da994c1f462510e2e9872728f
2567f17c8bd80467aec9c729ddbad2ebb9b0c6ec
/RPG Coursework/stateSplash.h
635fd40f37fa60f96528aecaf0cfd8e53a8ca668
[]
no_license
RBrNx/GED-RPG-Coursework
05f84a03a30973374ee37142ba28a4a780cfb418
b4f354ec5dbf6a7c2f93b6e39e114814d6d3e64c
refs/heads/master
2021-01-10T16:09:00.555742
2018-05-29T15:40:52
2018-05-29T15:40:52
51,334,729
0
0
null
null
null
null
UTF-8
C++
false
false
494
h
#pragma once #include "gameState.h" #include "Label.h" class stateSplash: public GameState { private: Label * titleText; TTF_Font* textFont; TTF_Font* textFont72; public: stateSplash(); void HandleSDLEvent(SDL_Event const &sdlEvent, Game &context); void Draw(SDL_Window * window); void Init(Game * context); void Init(Game &context); void Update(Game &context); void Enter(); void Exit(); bool GetContinuable(); bool GetGameStarted(); void SetGameStarted(); ~stateSplash(); };
b43d5ff0c3ab6152cc711c40c65480116b1f33a7
3e903f6dcb4b51102a81f8140ff38bec28937285
/mfc相关/010加载Dll实现画图板EXE/010加载Dll实现画图板EXE.h
79b43db843e9665583387746e3ae27c269c8045a
[]
no_license
fengjixuchui/WindowsPlatform
e4f2fb69a2b4e9c286dfc210a5b80eb200eb7cde
c96e10960e8a181dfbadb3276787d2874a3a6302
refs/heads/master
2022-07-25T05:23:35.690051
2022-07-16T12:47:51
2022-07-16T12:47:51
173,962,114
0
1
null
2022-07-16T12:47:51
2019-03-05T14:30:08
C++
GB18030
C++
false
false
608
h
// 010加载Dll实现画图板EXE.h : PROJECT_NAME 应用程序的主头文件 // #pragma once #ifndef __AFXWIN_H__ #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" #endif #include "resource.h" // 主符号 // CMy010加载Dll实现画图板EXEApp: // 有关此类的实现,请参阅 010加载Dll实现画图板EXE.cpp // class CMy010加载Dll实现画图板EXEApp : public CWinApp { public: CMy010加载Dll实现画图板EXEApp(); // 重写 public: virtual BOOL InitInstance(); // 实现 DECLARE_MESSAGE_MAP() }; extern CMy010加载Dll实现画图板EXEApp theApp;
bc856c098955b57ecd85c9b6abed3370d5e95521
124acfb0f29ddf8629236008f079a02e1985137f
/Classify/app/skype/skype.h
5ffd621f3975ba5655b37cad3935de0aced4b470
[]
no_license
seraph02/servicetask
13af8952be8ac84ce307d9e48dd6c208b17ffe09
07624e4d6553ad39fdc62127646245464735b1dc
refs/heads/master
2023-01-13T00:35:46.627050
2020-11-13T03:24:53
2020-11-13T03:24:53
181,698,373
0
0
null
null
null
null
UTF-8
C++
false
false
201
h
#ifndef SKYPEAPP_H #define SKYPEAPP_H #include<iostream> #include "absapp.h" #include "abscontrol.h" class SKYPE:public absAPP { public: SKYPE(); virtual ~SKYPE(); }; #endif // SKYPEAPP_H
[ "ser@ser" ]
ser@ser
3538b49ac72b1980f6fa86bc36ad83a6d0d55eab
112d4a263c3e9fc775fa82288a20a34b1efbe52d
/Material/RobertLafore_Book/Book_SourceCode/Progs/Ch10/Ptrtostr.cpp
ad16b6fa8566aa24ff668afdbf4fc5def66197dc
[ "MIT" ]
permissive
hpaucar/OOP-C-plus-plus-repo
369e788eb451f7d5804aadc1eb5bd2afb0758100
e1fedd376029996a53d70d452b7738d9c43173c0
refs/heads/main
2023-02-03T12:23:19.095175
2020-12-26T03:07:54
2020-12-26T03:07:54
324,466,086
4
0
null
null
null
null
UTF-8
C++
false
false
453
cpp
// ptrtostr.cpp // an array of pointers to strings #include <iostream> using namespace std; const int DAYS = 7; //number of pointers in array int main() { //array of pointers to char char* arrptrs[DAYS] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; for(int j=0; j<DAYS; j++) //display every string cout << arrptrs[j] << endl; return 0; }
a2c4e2fc34ef1f72b67db94ccc50f40dc226632c
c6f23c907ddb56fc16810bdce8bc9f7f0ef181b9
/Fan.cpp
5c46e763d5633ce958a0596e106623bfac0ad75e
[]
no_license
Andromem/poor-mans-smu
6046852f6b88cd83e943815914806d610dc2ff81
b5f2a292ebabe4cc69a4a9395c3261bd4e3ebd6d
refs/heads/master
2021-01-04T11:29:08.869034
2020-02-10T15:21:02
2020-02-10T15:21:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,729
cpp
// Ref also https://forum.pjrc.com/threads/34606-4-pin-PWM-Fan-Controller-(port-form-UNO-to-teensy-3-2) #include "Fan.h" #include "Arduino.h" FanClass FAN; volatile uint32_t _PWMFanWidth; void FanClass::init() { int fanPin = 23; // TODO: Move to global definitions int fanSpeedPin = 2; // TODO: Move to global definitions pinMode(fanPin,OUTPUT); digitalWriteFast(9,LOW); pinMode(fanSpeedPin,INPUT); attachInterrupt(fanSpeedPin, fanSpeedInterruptHandler, CHANGE); // For now, just hardcode a value for testing analogWriteFrequency(fanPin,25000); analogWrite(fanPin,100); } int FanClass::getFanWidth() { int fanSpeed = (int)_PWMFanWidth; return fanSpeed; } // TODO: Test !!! uint16_t FanClass::getPWMFanRPM(){ __disable_irq(); uint32_t width=_PWMFanWidth; //_PWMFanWidth=0UL; __enable_irq(); if (width==0UL) { return 0; } // width seems to be the ms period of a complete pulse (includes on and off) // 4 wire fan speed defines 2 pulses pr revolution. return (uint16_t)(1000000/width)/2; //TODO: check this calculation. Does not agree with the original one commented out below //return (uint16_t)(30000000UL/width); } void FanClass::fanSpeedInterruptHandler() { static uint32_t timestamp; static uint8_t state=0; uint8_t current = (CORE_PIN2_PINREG & _BV(CORE_PIN2_BIT)) ? 1 : 0;//check tach pin is high or low if (state==current) return; state=current; if (state) { uint32_t t = micros(); _PWMFanWidth= t - timestamp; timestamp=t; } } uint16_t FanClass::getRPMValueFiltered() { if (timeSinceLastRPMReadout + 1000 < millis()) { storedPWMFanSpeed = getPWMFanRPM(); timeSinceLastRPMReadout = millis(); } return storedPWMFanSpeed; }
ac7fd169b0c327652436a17ea8409091d69b0274
77f1531964358fabc4923b42750c10d4d07c02b9
/src/desktopoverlay.cpp
b8a0304e1fa1ff105310ac517292ef90548aca3b
[ "MIT" ]
permissive
OneMoreGres/screendose
a60068660405369eafaf6e70a76618324f66e537
2ea5210d43337c8c7e0d506772d1e2ab58920345
refs/heads/master
2022-06-05T04:54:46.854650
2022-04-28T18:34:25
2022-04-28T18:34:25
172,188,979
0
2
null
null
null
null
UTF-8
C++
false
false
1,113
cpp
#include "desktopoverlay.h" #include "screenoverlay.h" #include <QGuiApplication> #include <QScreen> DesktopOverlay::DesktopOverlay(Manager &manager) : isVisible_(false) , manager_(manager) { } DesktopOverlay::~DesktopOverlay() = default; void DesktopOverlay::ensureVisible(const QString &text) { isVisible_ = true; const auto screens = QGuiApplication::screens(); const auto screensSize = screens.size(); int overlaysSize = overlays_.size(); if (screensSize > overlaysSize) overlays_.reserve(screensSize); for (auto i = 0ll, end = screensSize; i < end; ++i) { if (i == overlaysSize) { overlays_.emplace_back(new ScreenOverlay(manager_)); ++overlaysSize; } const auto screen = screens[i]; auto &overlay = overlays_[i]; if (!overlay->isVisible()) { overlay->setGeometry(screen->geometry()); overlay->show(); overlay->activateWindow(); } overlay->setText(text); } } void DesktopOverlay::ensureHidden() { for (const auto &overlay : overlays_) { if (overlay->isVisible()) overlay->hide(); } isVisible_ = false; }
fef221e21bf8f7dcdb78b3eb5bad8c6ea8bdb629
55a2a9ac4b7beafad0ce3dbedab8afb180145ed0
/src/qt/sendcoinsdialog.cpp
ca8d7f6c522600ef7cb6ee5df85298ec520d5fca
[ "MIT" ]
permissive
buynowcoin/buynowcoin
0f5e0e62ca2b2bc84273053dbbdce4e85cc62122
2a729bb57d0a201cea0708b9d710cc2a7324b5c8
refs/heads/master
2016-08-06T05:59:59.093013
2014-07-19T02:55:37
2014-07-19T02:55:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,902
cpp
#include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" #include "init.h" #include "walletmodel.h" #include "addresstablemodel.h" #include "addressbookpage.h" #include "bitcoinunits.h" #include "addressbookpage.h" #include "optionsmodel.h" #include "sendcoinsentry.h" #include "guiutil.h" #include "askpassphrasedialog.h" #include "coincontrol.h" #include "coincontroldialog.h" #include <QMessageBox> #include <QLocale> #include <QTextDocument> #include <QScrollBar> #include <QClipboard> SendCoinsDialog::SendCoinsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SendCoinsDialog), model(0) { ui->setupUi(this); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->addButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon()); #endif #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a buynowcoin address (e.g. Ler4HNAEfwYhBmGXcFP2Po1NpRUEiK8km2)")); #endif addEntry(); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // Coin Control ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont()); connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority())); connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); ui->labelCoinControlPriority->addAction(clipboardPriorityAction); ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); fNewRecipientAllowed = true; } void SendCoinsDialog::setModel(WalletModel *model) { this->model = model; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setModel(model); } } if(model && model->getOptionsModel()) { setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64))); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); // Coin Control connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels())); ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); } } SendCoinsDialog::~SendCoinsDialog() { delete ui; } void SendCoinsDialog::on_sendButton_clicked() { QList<SendCoinsRecipient> recipients; bool valid = true; if(!model) return; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); } fNewRecipientAllowed = false; QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } WalletModel::SendCoinsReturn sendstatus; if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) sendstatus = model->sendCoins(recipients); else sendstatus = model->sendCoins(recipients, CoinControlDialog::coinControl); switch(sendstatus.status) { case WalletModel::InvalidAddress: QMessageBox::warning(this, tr("Send Coins"), tr("The recipient address is not valid, please recheck."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::InvalidAmount: QMessageBox::warning(this, tr("Send Coins"), tr("The amount to pay must be larger than 0."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The amount exceeds your balance."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountWithFeeExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The total exceeds your balance when the %1 transaction fee is included."). arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendstatus.fee)), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::DuplicateAddress: QMessageBox::warning(this, tr("Send Coins"), tr("Duplicate address found, can only send to each address once per send operation."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCreationFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: Transaction creation failed."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCommitFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::Aborted: // User aborted, nothing to do break; case WalletModel::OK: accept(); CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); break; } fNewRecipientAllowed = true; } void SendCoinsDialog::clear() { // Remove entries until only one left while(ui->entries->count()) { delete ui->entries->takeAt(0)->widget(); } addEntry(); updateRemoveEnabled(); ui->sendButton->setDefault(true); } void SendCoinsDialog::reject() { clear(); } void SendCoinsDialog::accept() { clear(); } SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(this); entry->setModel(model); ui->entries->addWidget(entry); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); updateRemoveEnabled(); // Focus the field, so that entry can start immediately entry->clear(); entry->setFocus(); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); QCoreApplication::instance()->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); return entry; } void SendCoinsDialog::updateRemoveEnabled() { // Remove buttons are enabled as soon as there is more than one send-entry bool enabled = (ui->entries->count() > 1); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setRemoveEnabled(enabled); } } setupTabChain(0); coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { delete entry; updateRemoveEnabled(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { prev = entry->setupTabChain(prev); } } QWidget::setTabOrder(prev, ui->addButton); QWidget::setTabOrder(ui->addButton, ui->sendButton); return ui->sendButton; } void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) { if(!fNewRecipientAllowed) return; SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setValue(rv); } bool SendCoinsDialog::handleURI(const QString &uri) { SendCoinsRecipient rv; // URI has to be valid if (GUIUtil::parseBitcoinURI(uri, &rv)) { CBitcoinAddress address(rv.address.toStdString()); if (!address.IsValid()) return false; pasteEntry(rv); return true; } return false; } void SendCoinsDialog::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance) { Q_UNUSED(stake); Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); if(!model || !model->getOptionsModel()) return; int unit = model->getOptionsModel()->getDisplayUnit(); ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); } void SendCoinsDialog::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update labelBalance with the current balance and the current unit ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance())); } } // Coin Control: copy label "Quantity" to clipboard void SendCoinsDialog::coinControlClipboardQuantity() { QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text()); } // Coin Control: copy label "Amount" to clipboard void SendCoinsDialog::coinControlClipboardAmount() { QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); } // Coin Control: copy label "Fee" to clipboard void SendCoinsDialog::coinControlClipboardFee() { QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" "))); } // Coin Control: copy label "After fee" to clipboard void SendCoinsDialog::coinControlClipboardAfterFee() { QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" "))); } // Coin Control: copy label "Bytes" to clipboard void SendCoinsDialog::coinControlClipboardBytes() { QApplication::clipboard()->setText(ui->labelCoinControlBytes->text()); } // Coin Control: copy label "Priority" to clipboard void SendCoinsDialog::coinControlClipboardPriority() { QApplication::clipboard()->setText(ui->labelCoinControlPriority->text()); } // Coin Control: copy label "Low output" to clipboard void SendCoinsDialog::coinControlClipboardLowOutput() { QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text()); } // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" "))); } // Coin Control: settings menu - coin control enabled/disabled by user void SendCoinsDialog::coinControlFeatureChanged(bool checked) { ui->frameCoinControl->setVisible(checked); if (!checked && model) // coin control features disabled CoinControlDialog::coinControl->SetNull(); } // Coin Control: button inputs -> show actual coin control dialog void SendCoinsDialog::coinControlButtonClicked() { CoinControlDialog dlg; dlg.setModel(model); dlg.exec(); coinControlUpdateLabels(); } // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { if (model) { if (state == Qt::Checked) CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get(); else CoinControlDialog::coinControl->destChange = CNoDestination(); } ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed void SendCoinsDialog::coinControlChangeEdited(const QString & text) { if (model) { CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get(); // label for the change address ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); if (text.isEmpty()) ui->labelCoinControlChangeLabel->setText(""); else if (!CBitcoinAddress(text.toStdString()).IsValid()) { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid buynowcoin address")); } else { QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); if (!associatedLabel.isEmpty()) ui->labelCoinControlChangeLabel->setText(associatedLabel); else { CPubKey pubkey; CKeyID keyid; CBitcoinAddress(text.toStdString()).GetKeyID(keyid); if (model->getPubKey(keyid, pubkey)) ui->labelCoinControlChangeLabel->setText(tr("(no label)")); else { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address")); } } } } } // Coin Control: update labels void SendCoinsDialog::coinControlUpdateLabels() { if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) return; // set pay amounts CoinControlDialog::payAmounts.clear(); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) CoinControlDialog::payAmounts.append(entry->getValue().amount); } if (CoinControlDialog::coinControl->HasSelected()) { // actual coin control calculation CoinControlDialog::updateLabels(model, this); // show coin control stats ui->labelCoinControlAutomaticallySelected->hide(); ui->widgetCoinControl->show(); } else { // hide coin control stats ui->labelCoinControlAutomaticallySelected->show(); ui->widgetCoinControl->hide(); ui->labelCoinControlInsuffFunds->hide(); } }
83405e4e74f063b28539c972f53ba925591ddf2c
95bbfb9b31c51e0d7fb1f59b7121c98e87c840e1
/Lab7_Recursion/listrec.h
a0fef97501ac95944e7681ecc3f5412dde14d9d5
[]
no_license
ParkEunBit/Data-Structure
065f9c2ea9ea2656fd27ab73f23b7b751f9d56b6
b774cd5656ebec4a073d554810752adf3f6c4d79
refs/heads/master
2021-09-02T08:43:54.216054
2018-01-01T04:25:38
2018-01-01T04:25:38
115,897,921
1
0
null
null
null
null
UTF-8
C++
false
false
2,830
h
//-------------------------------------------------------------------- // // Laboratory 10 listrec.h // // Class declarations for a partial linked list implementation of // the List ADT with additional recursive linked list functions // //-------------------------------------------------------------------- template < class LE > class ListNode; template < class LE > class List; template < class LE > class ListNode // Facilitator class for the List class { private: // Constructor ListNode(const LE &elem, ListNode *nextPtr); // Data members LE element; // List element ListNode *next; // Pointer to the next element friend class List<LE>; }; //-------------------------------------------------------------------- template < class LE > class List { public: // Constructor List(int ignored = 0); // Destructor ~List(); // List manipulation functions void insert(const LE &newElement); // Insert after cursor void clear(); // Clear list // Output the list structure -- used in testing/debugging void showStructure() const; // Prelab functions void write() const; // Output list elements void insertEnd(const LE &newElement); // Insert at end void writeMirror() const; // Mirror view of list void reverse(); // Reverse list void deleteEnd(); // Delete from end int length() const; // Length of list // Bridge functions void unknown1() const; // Bridge Exercise void unknown2(); // Bridge Exercise // In-lab functions void iterReverse(); // In-lab Exercise 1 void stackWriteMirror() const; // In-lab Exercise 1 void cRemove(); // In-lab Exercise 2 void aBeforeb(); // In-lab Exercise 3 private: // Recursive partners of the Prelab functions void writeSub(ListNode<LE> *p) const; void insertEndSub(ListNode<LE> *&p, const LE &newElement); void writeMirrorSub(ListNode<LE> *p) const; void reverseSub(ListNode<LE> *p, ListNode<LE> *nextP); void deleteEndSub(ListNode<LE> *&p); int lengthSub(ListNode<LE> *p) const; // Recursive partners of the Bridge functions void unknown1Sub(ListNode<LE> *p) const; void unknown2Sub(ListNode<LE> *&p); // Recursive partners of the In-lab functions void cRemoveSub(ListNode<LE> *&p); // In-lab Exercise 2 void aBeforebSub(ListNode<LE> *&p); // In-lab Exercise 3 private: // Data members ListNode<LE> *head, // Pointer to the beginning of the list *cursor; // Cursor pointer };
4b97608f1f2d47a9388bc675a990970e14a17ba3
24f26275ffcd9324998d7570ea9fda82578eeb9e
/ios/chrome/browser/overlays/public/overlay_request_cancel_handler.h
72f7bf2ddf068429f818210647de7856eb8319af
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
1,034
h
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_REQUEST_CANCEL_HANDLER_H_ #define IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_REQUEST_CANCEL_HANDLER_H_ #include <memory> class OverlayRequest; class OverlayRequestQueue; // Handles the cancellation of OverlayRequests added to an OverlayRequestQueue. class OverlayRequestCancelHandler { public: virtual ~OverlayRequestCancelHandler() = default; protected: // Constructor for a cancellation handler that cancels |request| from |queue|. OverlayRequestCancelHandler(OverlayRequest* request, OverlayRequestQueue* queue); // Called by subclasses to cancel the associated request. void CancelRequest(); private: OverlayRequest* request_ = nullptr; OverlayRequestQueue* queue_ = nullptr; }; #endif // IOS_CHROME_BROWSER_OVERLAYS_PUBLIC_OVERLAY_REQUEST_CANCEL_HANDLER_H_
b3d6caa25002013736c639b1a050fb45513c7e15
b3b4e26e4613972f28ed774d4b11660b585e7eac
/linkded lists/doubly linked lists/variable number of nodes/main.cpp
119b775f2bf8000ee840c6deee50cdd4bf58adfd
[]
no_license
Sukhdev841/Data-Structures
d454f7b2bec6649044e2fc3265128d727801faaa
38afddea6f0b79895f735e268f8f797817248861
refs/heads/master
2018-08-28T05:29:11.399076
2018-06-03T16:09:02
2018-06-03T16:09:02
120,790,705
0
0
null
null
null
null
UTF-8
C++
false
false
158
cpp
#include <iostream> #include"vnode.h" using namespace std; int main() { vptr p; create(p); cout<<"\n"; print(p); return 0; }
85cb76ef4a47e723fb025c524aa41aab61eccfa5
785fd47cc93c4ef4f0eec8d6f2610917410889dc
/dlut_rgbd/camera_laser_calibration/src/basicData/Point3d.cpp
eb1ec0bacb770e20ec56723081fd2f97834ff5a2
[]
no_license
ZhuangYanDLUT/dlut-ros-pkg
a5bcaa0a8e1cc52e77951bc5bd529cca33b3c452
416df80fd1457fd538d7a092cac5ca8716465607
refs/heads/master
2020-05-29T19:57:45.825982
2014-02-21T08:13:15
2014-02-21T08:13:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,130
cpp
/********************************************************************* * Software License Agreement (BSD License) * Copyright (c) 2013, Intelligent Robotics Lab, DLUT. * All rights reserved. * Author:Intelligent Robotics Lab, DLUT. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Intelligent Robotics Lab nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ #include "Point3d.h" #include <cmath> ////////////////////////////////////////////////////////////////////////// CPoint3d::CPoint3d (void) :x (0), y (0), z (0) { } CPoint3d::CPoint3d (float x, float y, float z) { this->x = x; this->y = y; this->z = z; } CPoint3d::~CPoint3d (void) { } CPoint3d::CPoint3d (const CPoint3d & tmpP) { this->x = tmpP.x; this->y = tmpP.y; this->z = tmpP.z; } ////////////////////////////////////////////////////////////////////////// CPoint3d & CPoint3d::operator += (const CPoint3d & p) { this->x += p.x; this->y += p.y; this->z += p.z; return *this; } CPoint3d & CPoint3d::operator -= (const CPoint3d & p) { this->x -= p.x; this->y -= p.y; this->z -= p.z; return *this; } CPoint3d & CPoint3d::operator *= (float s) { this->x *= s; this->y *= s; this->z *= s; return *this; } CPoint3d & CPoint3d::operator /= (float s) { this->x /= s; this->y /= s; this->z /= s; return *this; } CPoint3d operator + (const CPoint3d & p1, const CPoint3d & p2) { CPoint3d po; po.x = p1.x + p2.x; po.y = p1.y + p2.y; po.z = p1.z + p2.z; return po; } CPoint3d operator - (const CPoint3d & p1, const CPoint3d & p2) { CPoint3d po; po.x = p1.x - p2.x; po.y = p1.y - p2.y; po.z = p1.z - p2.z; return po; } CPoint3d operator * (const CPoint3d & p, float s) { CPoint3d po; po.x = p.x * s; po.y = p.y * s; po.z = p.z * s; return po; } float operator * (const CPoint3d & p1, const CPoint3d & p2) { return (p1.x * p2.x + p1.y * p2.y + p1.z * p2.z); } CPoint3d operator / (const CPoint3d & p, float num) { if (num != 0) { CPoint3d po; po.x = p.x / num; po.y = p.y / num; po.z = p.z / num; return po; } else { return CPoint3d (0, 0, 0); } } CPoint3d operator ^ (const CPoint3d & p1, const CPoint3d & p2) { CPoint3d po ( p1.y * p2.z - p1.z * p2.y, p1.z * p2.x - p1.x * p2.z, p1.x * p2.y - p1.y * p2.x ); return po; } bool operator < (const CPoint3d & p1, const CPoint3d & p2) { return (p1.z != p2.z) ? (p1.z < p2.z) : (p1.y != p2.y) ? (p1.y < p2.y) : (p1.x < p2.x); } bool operator > (const CPoint3d & p1, const CPoint3d & p2) { return (p1.z != p2.z) ? (p1.z > p2.z) : (p1.y != p2.y) ? (p1.y > p2.y) : (p1.x > p2.x); } bool operator == (const CPoint3d & p1, const CPoint3d & p2) { if (p1.x == p2.x && p1.y == p2.y && p1.z == p2.z) return true; else return false; } bool operator != (const CPoint3d & p1, const CPoint3d & p2) { if (p1.x == p2.x && p1.y == p2.y && p1.z == p2.z) return false; else return true; } ////////////////////////////////////////////////////////////////////////// float CPoint3d::cpDist (void) const { return sqrt (x * x + y * y + z * z); } float CPoint3d::cpSquaredNorm () const { return (this->x * this->x + this->y * this->y + this->z * this->z); } float CPoint3d::cpDot (const CPoint3d & p) const { return (*this) * p; } CPoint3d & CPoint3d::cpNormalize () { float n = float (sqrt (this->x * this->x + this->y * this->y + this->z * this->z)); if (n > float (0)) { this->x /= n; this->y /= n; this->z /= n; } return *this; }
4283c66ed1bfdf63871d5f49568c39b162f306e9
f4e573db298e59c453356c116d9a93ddc4b8f0f2
/UI/Preferences.h
21ba3ed4f056132e24d9e68191ded5b2d416869c
[ "MIT" ]
permissive
JaatSoft/WhisperBeNet
de8dd57c2f0cf9ddc3d5b6c3561f5c9255bee4f2
56515401b1eab401a3b2390196f85d70aedaaedf
refs/heads/master
2021-06-18T20:47:56.196206
2017-06-25T19:05:49
2017-06-25T19:05:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,957
h
#ifndef _Preferences_h #define _Preferences_h // for the preferences file #include <FindDirectory.h> #include <Directory.h> #include <Path.h> #include <File.h> #include <string.h> class Preferences { public: static Preferences* Instance(); ~Preferences(); void Load(); void Save(); // UI void ShowOscilloscope(bool state) {m_showOscilloscope = state;} bool ShowOscilloscope() {return m_showOscilloscope;} void ShowSoundControls(bool state) {m_showSoundControls = state;} bool ShowSoundControls() {return m_showSoundControls;} void ShowConnection(bool state) {m_showConnection = state;} bool ShowConnection() {return m_showConnection;} void ShowBookmarks(bool state) {m_showBookmarks = state;} bool ShowBookmarks() {return m_showBookmarks;} void ShowOutput(bool state) {m_showOutput = state;} bool ShowOutput() {return m_showOutput;} // Audio void RecordVolume(int32 volume) {m_recordVolume = volume;} int32 RecordVolume() {return m_recordVolume;} void PlayVolume(int32 volume) {m_playVolume = volume;} int32 PlayVolume() {return m_playVolume;} void UseModemQuality(bool state) {m_audioUseModemQuality = state;} bool UseModemQuality() {return m_audioUseModemQuality;} void UseCodec(bool state) {m_audioUseCodec = state;} bool UseCodec() {return m_audioUseCodec;} void Compression(int32 comp) {m_compression = comp;} int32 Compression() {return m_compression;} // Network void OnlineOnStartup(bool online) {m_OnlineOnStartup = online;} bool OnlineOnStartup() {return m_OnlineOnStartup;} void ConnectionTimeout(int timeout) {m_connectionTimeout = timeout;} bool ConnectionTimeout() {return m_connectionTimeout;} void ServerIP(char* ip) {strcpy(m_serverIP, ip); strcat(m_serverIP, "\0");} char* ServerIP() {return m_serverIP;} void ServerPort(int port) {m_serverPort = port;} int ServerPort() {return m_serverPort;} // Windows coordinates void MainX(float x) {m_mainX = x;} float MainX() {return m_mainX;} void MainY(float y) {m_mainY = y;} float MainY() {return m_mainY;} void BookmarksX(float x) {m_bookmarksX = x;} float BookmarksX() {return m_bookmarksX;} void BookmarksY(float y) {m_bookmarksY = y;} float BookmarksY() {return m_bookmarksY;} void BookmarksW(float w) {m_bookmarksW = w;} float BookmarksW() {return m_bookmarksW;} void BookmarksH(float h) {m_bookmarksH = h;} float BookmarksH() {return m_bookmarksH;} void PreferencesX(float x) {m_preferencesX = x;} float PreferencesX() {return m_preferencesX;} void PreferencesY(float y) {m_preferencesY = y;} float PreferencesY() {return m_preferencesY;} void MailX(float x) {m_mailX = x;} float MailX() {return m_mailX;} void MailY(float y) {m_mailY = y;} float MailY() {return m_mailY;} void RemoteUserX(float x) {m_remoteUserX = x;} float RemoteUserX() {return m_remoteUserX;} void RemoteUserY(float y) {m_remoteUserY = y;} float RemoteUserY() {return m_remoteUserY;} void OutputX(float x) {m_outputX = x;} float OutputX() {return m_outputX;} void OutputY(float y) {m_outputY = y;} float OutputY() {return m_outputY;} // UserInfo void FirstName(char* name) {strcpy(m_firstName, name); strcat(m_firstName, "\0");} char* FirstName() {return m_firstName;} void LastName(char* name) {strcpy(m_lastName, name); strcat(m_lastName, "\0");} char* LastName() {return m_lastName;} void Email(char* email) {strcpy(m_email, email); strcat(m_email, "\0");} char* Email() {return m_email;} private: // functions Preferences(); // singleton implementation private: // data static Preferences* m_instance; BFile m_preferencesFile; BDirectory m_directory; BPath m_path; // UI bool m_showOscilloscope; bool m_showSoundControls; bool m_showConnection; bool m_showBookmarks; bool m_showOutput; // Audio bool m_audioUseModemQuality; bool m_audioUseCodec; int32 m_recordVolume; int32 m_playVolume; int32 m_compression; // OliverESP: let´s play // Network bool m_OnlineOnStartup; int m_connectionTimeout; char m_serverIP[16]; int m_serverPort; // Windows coordinates float m_mainX; float m_mainY; float m_bookmarksX; float m_bookmarksY; float m_bookmarksW; float m_bookmarksH; float m_preferencesX; float m_preferencesY; float m_mailX; float m_mailY; float m_remoteUserX; float m_remoteUserY; float m_outputX; float m_outputY; // UserInfo char m_firstName[64]; char m_lastName[64]; char m_email[128]; }; #endif // _Preferences_h
[ "urnenfeld@7abbd682-e24f-0410-8bcd-ba4258e35a8b" ]
urnenfeld@7abbd682-e24f-0410-8bcd-ba4258e35a8b
b5a89e34ccd1d7dc4779c65a127e3354d8243692
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/DashIsoMpdManifestBandwidthType.h
05c4d2f65218d6df279dd8f247f10dd6e66f16ad
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
792
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/mediaconvert/MediaConvert_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace MediaConvert { namespace Model { enum class DashIsoMpdManifestBandwidthType { NOT_SET, AVERAGE, MAX }; namespace DashIsoMpdManifestBandwidthTypeMapper { AWS_MEDIACONVERT_API DashIsoMpdManifestBandwidthType GetDashIsoMpdManifestBandwidthTypeForName(const Aws::String& name); AWS_MEDIACONVERT_API Aws::String GetNameForDashIsoMpdManifestBandwidthType(DashIsoMpdManifestBandwidthType value); } // namespace DashIsoMpdManifestBandwidthTypeMapper } // namespace Model } // namespace MediaConvert } // namespace Aws
c4bd3435cae11df55e430de014edd5d32815746c
fc73264e6a2632dc229962e2e55e8f7e51af646a
/solid/system/test/test_thread.cpp
83bb004a5ef330a8f40dbb0e926e37a641bb43bf
[ "BSL-1.0" ]
permissive
zodsoft/solidframe
8b259b208bda99bd85029664d92a05a0f254420c
136e913027cd94a54bff3dee4b0a6673f2123a7f
refs/heads/master
2021-01-12T23:59:56.403982
2016-12-22T09:50:52
2016-12-22T09:50:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
125
cpp
#include <iostream> using namespace std; int test_thread(int argc, char **argv){ cout<<"test_thread"<<endl; return 0; }
2156023de79fb036202b108702a56f28811cee42
0bde333e0b611457eabf84075eb5ae437053eeaf
/USBMemoryStickDialog.cpp
3ee800cf7e13ba2460abde77a9414163d5eb70d7
[]
no_license
radtek/scanTracSingle2013
39d643e1898b97c097bc1dfc931a3d31aa97798b
e26a7f08184807d8c43c82528dd687dde54acf09
refs/heads/master
2021-03-04T04:19:01.819977
2019-12-28T02:32:48
2019-12-28T02:32:48
246,008,002
1
0
null
2020-03-09T10:38:40
2020-03-09T10:38:39
null
UTF-8
C++
false
false
77,037
cpp
// USBMemoryStickDialog.cpp : implementation file // #include "stdafx.h" #include "ScanTrac.h" #include "USBMemoryStickDialog.h" #include "afxdialogex.h" #include "SelectItemDialog.h" #include "YesNoDialog.h" // CUSBMemoryStickDialog dialog IMPLEMENT_DYNAMIC(CUSBMemoryStickDialog, CDialogEx) extern bool vGlobalInWindowsDialog; extern DWORD vGlobalCopyFileCount; extern BYTE vGlobalCopyDone; extern CString vGlobalCurrentDirectory; extern double vGlobalHardDriveTotalBytes; extern int vGlobalPasswordLevel; extern BYTE vGlobalShiftKeyDown; extern unsigned long vGlobalDialogTitleColor; CUSBMemoryStickDialog::CUSBMemoryStickDialog(CWnd* pParent /*=NULL*/) : CDialogEx(CUSBMemoryStickDialog::IDD, pParent) { vOldDriveNameC = "Drive 1"; vOldDriveNameD = "Drive 2"; vOldDriveNameE = "Drive 3"; vOldDriveNameF = "Drive 4"; vOldDriveNameG = "Drive 5"; vOldDriveNameH = "Drive 6"; vOldDriveNameI = "Drive 7"; vNeedToBackupSetup = false; vNeedToCopyAllScreenShots = false; vCopyProgress = 0; vLastSourceDirectory = "-"; vLastDestinationDirectory = "-"; vMemoryStickDriveLetter = "None"; vNumberOfPossibleMemorySticks = 0; vOldNumberOfPossibleMemorySticks = 0; vHaveAUSBMemoryStick = false; vOldHaveAUSBMemoryStick = false; vUpdateDisplayTimerHandle = 31315; vOldXRayOnNotice = false; vOldCSize = 0; vOldDSize = 0; vOldESize = 0; vOldFSize = 0; vOldGSize = 0; vOldHSize = 0; vOldISize = 0; vOldCFreeSpace = 0; vOldDFreeSpace = 0; vOldEFreeSpace = 0; vOldFFreeSpace = 0; vOldGFreeSpace = 0; vOldHFreeSpace = 0; vOldIFreeSpace = 0; vLocalCWndCollection.Add(this); vLocalCWndCollection.Add(&m_PleaseWait); vLocalCWndCollection.Add(&m_AllFilesLabel); vLocalCWndCollection.Add(&m_Background); vLocalCWndCollection.Add(&m_DialogTitleStaticText1); vLocalCWndCollection.Add(&m_DriveFreeSpace1); vLocalCWndCollection.Add(&m_DriveFreeSpace2); vLocalCWndCollection.Add(&m_DriveFreeSpace3); vLocalCWndCollection.Add(&m_DriveFreeSpace4); vLocalCWndCollection.Add(&m_DriveFreeSpace5); vLocalCWndCollection.Add(&m_DriveFreeSpace6); vLocalCWndCollection.Add(&m_DriveFreeSpace7); vLocalCWndCollection.Add(&m_DriveFreeSpaceLabel); vLocalCWndCollection.Add(&m_DriveLetter1); vLocalCWndCollection.Add(&m_DriveLetter2); vLocalCWndCollection.Add(&m_DriveLetter3); vLocalCWndCollection.Add(&m_DriveLetter4); vLocalCWndCollection.Add(&m_DriveLetter5); vLocalCWndCollection.Add(&m_DriveLetter6); vLocalCWndCollection.Add(&m_DriveLetter7); vLocalCWndCollection.Add(&m_DriveLetterLabel); vLocalCWndCollection.Add(&m_DriveName1); vLocalCWndCollection.Add(&m_DriveName2); vLocalCWndCollection.Add(&m_DriveName3); vLocalCWndCollection.Add(&m_DriveName4); vLocalCWndCollection.Add(&m_DriveName5); vLocalCWndCollection.Add(&m_DriveName6); vLocalCWndCollection.Add(&m_DriveName7); vLocalCWndCollection.Add(&m_DriveNameLabel); vLocalCWndCollection.Add(&m_DriveSize1); vLocalCWndCollection.Add(&m_DriveSize2); vLocalCWndCollection.Add(&m_DriveSize3); vLocalCWndCollection.Add(&m_DriveSize4); vLocalCWndCollection.Add(&m_DriveSize5); vLocalCWndCollection.Add(&m_DriveSize6); vLocalCWndCollection.Add(&m_DriveSize7); vLocalCWndCollection.Add(&m_DriveSizeLabel); vLocalCWndCollection.Add(&m_Function1Button); vLocalCWndCollection.Add(&m_Function2Button); vLocalCWndCollection.Add(&m_Function3Button); vLocalCWndCollection.Add(&m_Function4Button); vLocalCWndCollection.Add(&m_Function5Button); vLocalCWndCollection.Add(&m_MemoryStickDriveLabel); vLocalCWndCollection.Add(&m_SubFunction1Button); vLocalCWndCollection.Add(&m_SubFunction2Button); vLocalCWndCollection.Add(&m_SubFunction3Button); vLocalCWndCollection.Add(&m_SubFunction4Button); vLocalCWndCollection.Add(&m_SubFunction5Button); vLocalCWndCollection.Add(&m_SubFunction6Button); vLocalCWndCollection.Add(&m_SubFunction7Button); vLocalCWndCollection.Add(&m_SubFunction8Button); vLocalCWndCollection.Add(&m_TodaysFilesLabel); vLocalCWndCollection.Add(&m_XRaysOn); } CUSBMemoryStickDialog::~CUSBMemoryStickDialog() { } void CUSBMemoryStickDialog::OnShowWindow(BOOL bShow, UINT nStatus) { CDialogEx::OnShowWindow(bShow, nStatus); m_Background.SetWindowPos(NULL,cMainBackgroundLeft, cMainBackgroundTop,cMainBackgroundLength, cMainBackgroundHeight,SWP_NOZORDER); // TODO: Add your message handler code here UpdateDisplay(); this->SetWindowText(_T("USB Memory")); ::SetupMenu(vLocalCWndCollection); int TempTimerResult = SetTimer(vUpdateDisplayTimerHandle,1000,NULL); if (!TempTimerResult) ReportErrorMessage("Error-Display Timer Failed",cEMailInspx,32000); } void CUSBMemoryStickDialog::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_AllFilesLabel, m_AllFilesLabel); DDX_Control(pDX, IDC_Background, m_Background); DDX_Control(pDX, IDC_DialogTitleStaticText1, m_DialogTitleStaticText1); DDX_Control(pDX, IDC_DriveFreeSpace1, m_DriveFreeSpace1); DDX_Control(pDX, IDC_DriveFreeSpace2, m_DriveFreeSpace2); DDX_Control(pDX, IDC_DriveFreeSpace3, m_DriveFreeSpace3); DDX_Control(pDX, IDC_DriveFreeSpace4, m_DriveFreeSpace4); DDX_Control(pDX, IDC_DriveFreeSpace5, m_DriveFreeSpace5); DDX_Control(pDX, IDC_DriveFreeSpace6, m_DriveFreeSpace6); DDX_Control(pDX, IDC_DriveFreeSpace7, m_DriveFreeSpace7); DDX_Control(pDX, IDC_DriveFreeSpaceLabel, m_DriveFreeSpaceLabel); DDX_Control(pDX, IDC_DriveLetter1, m_DriveLetter1); DDX_Control(pDX, IDC_DriveLetter2, m_DriveLetter2); DDX_Control(pDX, IDC_DriveLetter3, m_DriveLetter3); DDX_Control(pDX, IDC_DriveLetter4, m_DriveLetter4); DDX_Control(pDX, IDC_DriveLetter5, m_DriveLetter5); DDX_Control(pDX, IDC_DriveLetter6, m_DriveLetter6); DDX_Control(pDX, IDC_DriveLetter7, m_DriveLetter7); DDX_Control(pDX, IDC_DriveLetterLabel, m_DriveLetterLabel); DDX_Control(pDX, IDC_DriveName1, m_DriveName1); DDX_Control(pDX, IDC_DriveName2, m_DriveName2); DDX_Control(pDX, IDC_DriveName3, m_DriveName3); DDX_Control(pDX, IDC_DriveName4, m_DriveName4); DDX_Control(pDX, IDC_DriveName5, m_DriveName5); DDX_Control(pDX, IDC_DriveName6, m_DriveName6); DDX_Control(pDX, IDC_DriveName7, m_DriveName7); DDX_Control(pDX, IDC_DriveNameLabel, m_DriveNameLabel); DDX_Control(pDX, IDC_DriveSize1, m_DriveSize1); DDX_Control(pDX, IDC_DriveSize2, m_DriveSize2); DDX_Control(pDX, IDC_DriveSize3, m_DriveSize3); DDX_Control(pDX, IDC_DriveSize4, m_DriveSize4); DDX_Control(pDX, IDC_DriveSize5, m_DriveSize5); DDX_Control(pDX, IDC_DriveSize6, m_DriveSize6); DDX_Control(pDX, IDC_DriveSize7, m_DriveSize7); DDX_Control(pDX, IDC_DriveSizeLabel, m_DriveSizeLabel); DDX_Control(pDX, IDC_Function1Button, m_Function1Button); DDX_Control(pDX, IDC_Function2Button, m_Function2Button); DDX_Control(pDX, IDC_Function3Button, m_Function3Button); DDX_Control(pDX, IDC_Function4Button, m_Function4Button); DDX_Control(pDX, IDC_Function5Button, m_Function5Button); DDX_Control(pDX, IDC_MemoryStickDriveLabel, m_MemoryStickDriveLabel); DDX_Control(pDX, IDC_SubFunction1Button, m_SubFunction1Button); DDX_Control(pDX, IDC_SubFunction2Button, m_SubFunction2Button); DDX_Control(pDX, IDC_SubFunction3Button, m_SubFunction3Button); DDX_Control(pDX, IDC_SubFunction4Button, m_SubFunction4Button); DDX_Control(pDX, IDC_SubFunction5Button, m_SubFunction5Button); DDX_Control(pDX, IDC_SubFunction6Button, m_SubFunction6Button); DDX_Control(pDX, IDC_SubFunction7Button, m_SubFunction7Button); DDX_Control(pDX, IDC_SubFunction8Button, m_SubFunction8Button); DDX_Control(pDX, IDC_TodaysFilesLabel, m_TodaysFilesLabel); DDX_Control(pDX, IDC_XRaysOn, m_XRaysOn); DDX_Control(pDX, IDC_PleaseWait, m_PleaseWait); } BEGIN_MESSAGE_MAP(CUSBMemoryStickDialog, CDialogEx) ON_STN_CLICKED(IDC_Function1Button, &CUSBMemoryStickDialog::OnStnClickedFunction1button) ON_STN_CLICKED(IDC_Function2Button, &CUSBMemoryStickDialog::OnStnClickedFunction2button) ON_STN_CLICKED(IDC_Function3Button, &CUSBMemoryStickDialog::OnStnClickedFunction3button) ON_STN_CLICKED(IDC_Function4Button, &CUSBMemoryStickDialog::OnStnClickedFunction4button) ON_STN_CLICKED(IDC_Function5Button, &CUSBMemoryStickDialog::OnStnClickedFunction5button) ON_STN_CLICKED(IDC_SubFunction1Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction1button) ON_STN_CLICKED(IDC_SubFunction2Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction2button) ON_STN_CLICKED(IDC_SubFunction3Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction3button) ON_STN_CLICKED(IDC_SubFunction4Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction4button) ON_STN_CLICKED(IDC_SubFunction5Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction5button) ON_STN_CLICKED(IDC_SubFunction6Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction6button) ON_STN_CLICKED(IDC_SubFunction7Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction7button) ON_STN_CLICKED(IDC_SubFunction8Button, &CUSBMemoryStickDialog::OnStnClickedSubfunction8button) ON_WM_CTLCOLOR() ON_WM_SHOWWINDOW() ON_WM_TIMER() ON_STN_CLICKED(IDC_DialogTitleStaticText1, &CUSBMemoryStickDialog::OnStnClickedDialogtitlestatictext1) END_MESSAGE_MAP() // CUSBMemoryStickDialog message handlers void CUSBMemoryStickDialog::OnStnClickedFunction1button() { // Main Menu Button Pressed CDialog::EndDialog(10); } void CUSBMemoryStickDialog::OnStnClickedFunction2button() { // copy all folders //OnStnClickedSubfunction2button(); //OnStnClickedSubfunction3button(); //OnStnClickedSubfunction4button(); //OnStnClickedFunction5button(); OnStnClickedSubfunction1button(); //production report gets everything in one file CopyFilesToUSBStick(vLocalConfigurationData->vScanTracEventLogDirectory, false); CopySavedImagesToUSBStick(vLocalConfigurationData->vScanTracRejectedImagesDirectory, false); CopyFilesToUSBStick(vLocalConfigurationData->vScanTracScreenShotDirectory, false); OnStnClickedFunction5button(); } void CUSBMemoryStickDialog::OnStnClickedFunction3button() { // Restore Setup Files From USB Stick if (vLocalSystemData->vSystemRunMode != cStoppedSystemMode) { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nX-Rays must be off\nto restore program and setup files from USB Drive"; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } else { CYesNoDialog TempYesNoDialog; TempYesNoDialog.vNoticeText = _T("Do you want to restore ScanTrac program and\nsetup files from USB Memory Stick?\nThis will reboot computer to complete.\nAny changes to setups after backup was made\nwill be lost."); TempYesNoDialog.vQuestionType = cConfirmAbandon; TempYesNoDialog.vYesButtonText = "Continue"; TempYesNoDialog.vNoButtonText = "Abort"; int TempResult = TempYesNoDialog.DoModal(); //if user said OK if (TempResult == IDOK) RestoreSetupsFromBackup(); } } void CUSBMemoryStickDialog::OnStnClickedFunction4button() { //Select drive button pressed when more than one drive available if (vNumberOfPossibleMemorySticks > 1) { CSelectItemDialog ISelectItemDialog; //Set dialog box data titles and number value ISelectItemDialog.vTitleString = "Choose USB Memory Stick"; ISelectItemDialog.m_DialogTitleStaticText2 = ""; ISelectItemDialog.m_DialogTitleStaticText3 = ""; ISelectItemDialog.vBackgroundColor = cGreen; //ISelectItemDialog.vGreenItem = 1; ISelectItemDialog.vShowExit = 0; ISelectItemDialog.vInAutoSetup = vLocalSystemData->vInAutoSetup; ISelectItemDialog.vNumberOfItems = vNumberOfPossibleMemorySticks; BYTE TempIndexToUse = 0; double TempDriveSpaceFree = CheckDiskSpaceFree("C:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte if (vGlobalHardDriveTotalBytes < 20000000000) //less than 35 gigabytes ISelectItemDialog.vItems[TempIndexToUse++] = "C:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("D:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte if (vGlobalHardDriveTotalBytes < 35000000000) //less than 35 gigabytes ISelectItemDialog.vItems[TempIndexToUse++] = "D:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("E:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte ISelectItemDialog.vItems[TempIndexToUse++] = "E:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("F:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte ISelectItemDialog.vItems[TempIndexToUse++] = "F:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("G:\\"); ISelectItemDialog.vItems[TempIndexToUse++] = "G:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("H:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte ISelectItemDialog.vItems[TempIndexToUse++] = "H:\\"; TempDriveSpaceFree = CheckDiskSpaceFree("I:\\"); ISelectItemDialog.vItems[TempIndexToUse++] = "I:\\"; //ISelectItemDialog.vMakeTitle3Big = true; ISelectItemDialog.m_DialogTitleStaticText3 = "Original Value: " + vMemoryStickDriveLetter; //Pass control to dialog box and display int nResponse = ISelectItemDialog.DoModal(); //dialog box is now closed, if user pressed select do this //if user pressed cancel, do nothing if (nResponse == IDOK) { vMemoryStickDriveLetter = ISelectItemDialog.vItems[ISelectItemDialog.vItemNumberSelected - 1]; SetDlgItemText(IDC_MemoryStickDriveLabel, "Memory Stick on Drive Letter " + vMemoryStickDriveLetter); } else if (nResponse == 10) { //Main Menu button pressed Sleep(1); CDialog::EndDialog(10); } } else { CNoticeDialog TempNoticeDialog; if (vNumberOfPossibleMemorySticks == 0) TempNoticeDialog.vNoticeText = "\n\n\nNo USB Drives Detected"; else TempNoticeDialog.vNoticeText = "\n\n\nOnly USB Drive Detected is Selected"; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } } void CUSBMemoryStickDialog::OnStnClickedFunction5button() { //backup setup files if (vGlobalCopyDone) vNeedToBackupSetup = true; else { CString TempSourceDirectory = vGlobalCurrentDirectory; CString TempDestinationFolder = " ScanTrac Backup"; CTime TempTime = CTime::GetCurrentTime(); CString TempTimeString = TempTime.Format("%Y-%m-%d"); TempDestinationFolder = TempTimeString + TempDestinationFolder; vGlobalCopyFileCount = 0; //setup variables to give message when done vGlobalCopyDone = 0xAA; vLastSourceDirectory = TempSourceDirectory; vLastDestinationDirectory = vMemoryStickDriveLetter + TempDestinationFolder; CopyFolderToUSBStick(TempSourceDirectory, TempDestinationFolder); } } void CUSBMemoryStickDialog::OnStnClickedSubfunction1button() { //Copy todays production reports to Memory Stick CString TempSourceDirectory = vLocalConfigurationData->vScanTracProductionReportDirectory; CString TempDestinationFolder = vLocalConfigurationData->vScanTracProductionReportDirectory; TempDestinationFolder.Delete(0, 3); //TempDestinationFolder.Delete(TempDestinationFolder.GetLength() - 1, 2); CString TempFileName = "ScanTracProductionReportSummary.CSV"; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileName); CopyFileToUSBStick(TempSourceDirectory, TempFileName, TempDestinationFolder); Sleep(1000); m_PleaseWait.ShowWindow(SW_HIDE); } void CUSBMemoryStickDialog::OnStnClickedSubfunction2button() { CopyFilesToUSBStick(vLocalConfigurationData->vScanTracScreenShotDirectory, false); //Copy Today's Screen Shots //CString TempSourceDirectory = vLocalConfigurationData->vScanTracScreenShotDirectory; //CString TempDestinationFolder = vLocalConfigurationData->vScanTracScreenShotDirectory; //TempDestinationFolder.Delete(0, 3); //remove the c: //TempDestinationFolder.Delete(TempDestinationFolder.GetLength() - 1, 2); ////TempDestinationFolder = vMemoryStickDriveLetter + TempDestinationFolder; //TempSourceDirectory.Delete(TempSourceDirectory.GetLength() - 1, 2); //CTime TempTime = CTime::GetCurrentTime(); //CString TempTodaysDateString = TempTime.Format("%Y-%m-%d"); //CString TempSourceFindDirectory = vLocalConfigurationData->vScanTracScreenShotDirectory + "*" + TempTodaysDateString + "*.*"; //WIN32_FIND_DATA FindFileData; //HANDLE hFind; //LPTSTR TempDirectoryName = TempSourceFindDirectory.GetBuffer(TempSourceFindDirectory.GetLength()); //hFind = FindFirstFile(TempDirectoryName, &FindFileData); //if (hFind == INVALID_HANDLE_VALUE) //{ // CNoticeDialog TempNoticeDialog; // TempNoticeDialog.vNoticeText = "\n\n\nNo files to copy in\n" + TempSourceFindDirectory; // TempNoticeDialog.vType = cInformationMessage; // TempNoticeDialog.DoModal(); //} //else //{ // CString TempFileNameString = FindFileData.cFileName; // if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // { // //int TempPosition = TempFileNameString.Find(TempTodaysDateString); // //if (TempPosition >= 0) // //{ // CString TempFileNameText = FindFileData.cFileName; // m_PleaseWait.ShowWindow(SW_SHOW); // SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); // CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); // //} // } // while (FindNextFile(hFind, &FindFileData)) // { // CString TempFileNameString = FindFileData.cFileName; // if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // { // //int TempPosition = TempFileNameString.Find(TempTodaysDateString); // //if (TempPosition >= 0) // //{ // CString TempFileNameText = FindFileData.cFileName; // m_PleaseWait.ShowWindow(SW_SHOW); // SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); // CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); // Sleep(10); // //if (vMainWindowPointer) // // vMainWindowPointer->TickleWatchDog(); // //} // } // } //} //FindClose(hFind); //Sleep(1000); //m_PleaseWait.ShowWindow(SW_HIDE); } void CUSBMemoryStickDialog::OnStnClickedSubfunction3button() { // Copy todays saved images // Copy todays saved images CopySavedImagesToUSBStick(vLocalConfigurationData->vScanTracRejectedImagesDirectory, false); //CTime TempTime = CTime::GetCurrentTime(); //CString TempString = TempTime.Format("%Y-%m-%d"); //CString TempSourceDirectory = vLocalConfigurationData->vScanTracRejectedImagesDirectory + TempString; //CString TempDestinationFolder = vLocalConfigurationData->vScanTracRejectedImagesDirectory + TempString; //TempDestinationFolder.Delete(0, 3); ////make sure USB Stick has ScanTracRejectedImages folder //CString TempPrimaryFolderName = vLocalConfigurationData->vScanTracRejectedImagesDirectory; //TempPrimaryFolderName.Delete(0, 3); //TempPrimaryFolderName.Delete(TempPrimaryFolderName.GetLength() - 1, 2); //TempPrimaryFolderName = vMemoryStickDriveLetter + TempPrimaryFolderName; //CFile TempFile; //CFileStatus TempFileStatus; //bool TempDestinationDirectoryOK = true; //if (!CFile::GetStatus(TempPrimaryFolderName, TempFileStatus)) //if (!CreateDirectory(TempPrimaryFolderName,NULL)) //{ // TempDestinationDirectoryOK = false; // CNoticeDialog TempNoticeDialog1; // CString TempText("\n\nError, Could not create directory:\n"); // TempText = TempText + TempPrimaryFolderName; // TempNoticeDialog1.vNoticeText = TempText; // TempNoticeDialog1.vType = cErrorMessage; // TempNoticeDialog1.DoModal(); //} //if (TempDestinationDirectoryOK) //{ // vGlobalCopyFileCount = 0; //setup variables to give message when done // vGlobalCopyDone = 0xAA; // vLastSourceDirectory = TempSourceDirectory; // vLastDestinationDirectory = vMemoryStickDriveLetter + TempDestinationFolder; // CopyFolderToUSBStick(TempSourceDirectory, TempDestinationFolder); //} } void CUSBMemoryStickDialog::OnStnClickedSubfunction4button() { //Copy Today's Event logs CopyFilesToUSBStick(vLocalConfigurationData->vScanTracEventLogDirectory, false); //CString TempSourceDirectory = vLocalConfigurationData->vScanTracEventLogDirectory; //CString TempDestinationFolder = vLocalConfigurationData->vScanTracEventLogDirectory; //TempDestinationFolder.Delete(0, 3); //remove the c: //TempDestinationFolder.Delete(TempDestinationFolder.GetLength() - 1, 2); //TempSourceDirectory.Delete(TempSourceDirectory.GetLength() - 1, 2); //CTime TempTime = CTime::GetCurrentTime(); //CString TempTodaysDateString = TempTime.Format("%Y-%m-%d"); //CString TempSourceFindDirectory = vLocalConfigurationData->vScanTracEventLogDirectory + "*" + TempTodaysDateString + "*.*"; //WIN32_FIND_DATA FindFileData; //HANDLE hFind; //LPTSTR TempDirectoryName = TempSourceFindDirectory.GetBuffer(TempSourceFindDirectory.GetLength()); //hFind = FindFirstFile(TempDirectoryName, &FindFileData); //if (hFind == INVALID_HANDLE_VALUE) //{ // CNoticeDialog TempNoticeDialog; // TempNoticeDialog.vNoticeText = "\n\n\nNo files to copy in\n" + TempSourceFindDirectory; // TempNoticeDialog.vType = cInformationMessage; // TempNoticeDialog.DoModal(); //} //else //{ // CString TempFileNameString = FindFileData.cFileName; // if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // { // CString TempFileNameText = FindFileData.cFileName; // m_PleaseWait.ShowWindow(SW_SHOW); // SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); // CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); // } // while (FindNextFile(hFind, &FindFileData)) // { // CString TempFileNameString = FindFileData.cFileName; // if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // { // CString TempFileNameText = FindFileData.cFileName; // m_PleaseWait.ShowWindow(SW_SHOW); // SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); // CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); // Sleep(10); // } // } //} //FindClose(hFind); //Sleep(1000); //m_PleaseWait.ShowWindow(SW_HIDE); } void CUSBMemoryStickDialog::OnStnClickedSubfunction5button() { //copy all folders OnStnClickedSubfunction6button(); OnStnClickedSubfunction7button(); OnStnClickedFunction5button(); } void CUSBMemoryStickDialog::OnStnClickedSubfunction6button() { //Copy All Files production reports to Memory Stick CString TempSourceDirectory = vLocalConfigurationData->vScanTracProductionReportDirectory; CString TempDestinationFolder = vLocalConfigurationData->vScanTracProductionReportDirectory; TempDestinationFolder.Delete(0, 3); //remove the c:\ vGlobalCopyFileCount = 0; //setup variables to give message when done vGlobalCopyDone = 0xAA; vLastSourceDirectory = TempSourceDirectory; vLastDestinationDirectory = vMemoryStickDriveLetter + TempDestinationFolder; CopyFolderToUSBStick(TempSourceDirectory, TempDestinationFolder); } void CUSBMemoryStickDialog::OnStnClickedSubfunction7button() { if (vGlobalCopyDone) vNeedToCopyAllScreenShots = true; else { //Copy All Screen Shots CString TempSourceDirectory = vLocalConfigurationData->vScanTracScreenShotDirectory; CString TempDestinationFolder = vLocalConfigurationData->vScanTracScreenShotDirectory; TempDestinationFolder.Delete(0, 3); //remove the c:\ vGlobalCopyFileCount = 0; //setup variables to give message when done vGlobalCopyDone = 0xAA; vLastSourceDirectory = TempSourceDirectory; vLastDestinationDirectory = vMemoryStickDriveLetter + TempDestinationFolder; CopyFolderToUSBStick(TempSourceDirectory, TempDestinationFolder); } } void CUSBMemoryStickDialog::OnStnClickedSubfunction8button() { // copy Yesterdays files OnStnClickedSubfunction1button(); //production report gets everything in one file CopyFilesToUSBStick(vLocalConfigurationData->vScanTracEventLogDirectory, true); CopyFilesToUSBStick(vLocalConfigurationData->vScanTracScreenShotDirectory, true); CopySavedImagesToUSBStick(vLocalConfigurationData->vScanTracRejectedImagesDirectory, true); OnStnClickedFunction5button(); //production report gets everything in one file } HBRUSH CUSBMemoryStickDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here HWND TempDialogHwnd = this->m_hWnd; int TextSize; pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); if (pWnd->GetDlgCtrlID() == IDC_DialogTitleStaticText1) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DialogTitleStaticText1, 8); //5 is medium large if (vGlobalShiftKeyDown) pDC->SetTextColor(cBlack); else pDC->SetTextColor(vGlobalDialogTitleColor); } if (pWnd->GetDlgCtrlID() == IDC_Function1Button) { TextSize = SetTextSizeFunctionButton(TempDialogHwnd, pWnd, pDC, &m_Function1Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_Function2Button) { TextSize = SetTextSizeFunctionButton(TempDialogHwnd, pWnd, pDC, &m_Function2Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_Function3Button) { TextSize = SetTextSizeFunctionButton(TempDialogHwnd, pWnd, pDC, &m_Function3Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); if (vLocalSystemData->vSystemRunMode == cStoppedSystemMode) pDC->SetTextColor(cButtonTextColor); else pDC->SetTextColor(cGray); return vLocalSystemData->vYellowBrush; } if (pWnd->GetDlgCtrlID() == IDC_Function4Button) { TextSize = SetTextSizeFunctionButton(TempDialogHwnd, pWnd, pDC, &m_Function4Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_Function5Button) { TextSize = SetTextSizeFunctionButton(TempDialogHwnd, pWnd, pDC, &m_Function5Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction1Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction1Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction2Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction2Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction3Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction3Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction4Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction4Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction5Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction5Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction6Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction6Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction7Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction7Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_SubFunction8Button) { TextSize = SetTextSizeSubFunctionButton(TempDialogHwnd, pWnd, pDC, &m_SubFunction8Button, 5); //5 is medium large pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cButtonTextColor); return vGlobalButtonColorBrush; } if (pWnd->GetDlgCtrlID() == IDC_Background) { pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_XRaysOn) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_XRaysOn, 7); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cYellow); pDC->SetBkColor(cRed); return vLocalSystemData->vRedBrush; } if (pWnd->GetDlgCtrlID() == IDC_PleaseWait) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_PleaseWait, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cRed); return vLocalSystemData->vYellowBrush; } if (pWnd->GetDlgCtrlID() == IDC_AllFilesLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_AllFilesLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); //return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace1) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace1, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace2) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace2, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace3) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace3, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace4) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace4, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace5) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace5, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace6) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace6, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpace7) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpace7, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveFreeSpaceLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveFreeSpaceLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter1) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter1, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter2) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter2, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter3) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter3, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter4) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter4, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter5) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter5, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter6) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter6, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetter7) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetter7, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveLetterLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveLetterLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName1) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName1, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName2) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName2, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName3) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName3, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName4) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName4, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName5) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName5, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName6) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName6, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveName7) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveName7, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveNameLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveNameLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize1) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize1, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize2) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize2, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize3) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize3, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize4) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize4, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize5) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize5, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize6) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize6, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSize7) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSize7, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_DriveSizeLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_DriveSizeLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_MemoryStickDriveLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_MemoryStickDriveLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); return vLocalSystemData->vLightBrownBrush; } if (pWnd->GetDlgCtrlID() == IDC_TodaysFilesLabel) { TextSize = SetTextSizeSingleLineDisplay(TempDialogHwnd, pWnd, pDC, &m_TodaysFilesLabel, 4); pDC->SetAttribDC(pDC->m_hDC); pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(cBlack); //return vLocalSystemData->vLightBrownBrush; } // TODO: Return a different brush if the default is not desired return hbr; } void CUSBMemoryStickDialog::OnTimer(UINT_PTR nIDEvent) { // TODO: Add your message handler code here and/or call default if (nIDEvent == vUpdateDisplayTimerHandle) UpdateDisplay(); CDialogEx::OnTimer(nIDEvent); } BOOL CUSBMemoryStickDialog::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == cUpdateTitleBarMessage) { CWnd *TempWindow = CWnd::GetDlgItem(IDC_DialogTitleStaticText1); if (TempWindow) TempWindow->Invalidate(false); return true; //true indicates it has been handled, so do not process } else if (pMsg->message == WM_KEYDOWN) { CWnd *TempWindow = NULL; if (vGlobalShiftKeyDown) PostThreadMessage(vGlobalCallingThreadID,cHiddenKeyPressed, 0, pMsg->wParam); else switch (pMsg->wParam) { //case 35: // End Key, Left Right on duo but new Image Key on Universal Overlays, Image Button // OnTestdacsbutton(); //break; case 113: // F2: OnStnClickedSubfunction5button(); break; case 114: // F3: OnStnClickedSubfunction6button(); break; case 115: // F4: OnStnClickedSubfunction7button(); break; case 116: // F5: OnStnClickedSubfunction1button(); break; case 117: // F6 Key - Function 5: OnStnClickedSubfunction4button(); break; case 118: // F7 Key - Sub Function 1: OnStnClickedFunction1button(); break; case 119: // F8 Key - Sub Function 2: OnStnClickedSubfunction8button(); break; case 120: // F9 Key - Sub Function 3: OnStnClickedSubfunction2button(); break; case 122: // F11 Key - Sub Function 4: OnStnClickedSubfunction3button(); break; case 111: // / Key - Sub Function 5: OnStnClickedFunction2button(); break; case 106: // * Key - Sub Function 6: OnStnClickedFunction4button(); break; case 109: // - Key - Sub Function 7 Decimal Point: OnStnClickedFunction3button(); break; case 107: // + Key - Sub Function 8: OnStnClickedFunction5button(); break; case cPageUp: // Clear, but do inspx hidden dialog { if (vGlobalPasswordLevel) { PasswordOK(cNoPassword, false); //todo, search on PasswordOK (cNoPassword) } else { PasswordOK(cAnyPasswordToEnter, true); } } break; case 16: // Shift Key case 0x60: //0 key on KeyPad PostThreadMessage(vGlobalCallingThreadID,cHiddenKeyPressed, 1, 0); break; case 36: //Home key, Screen Capture vGlobalShiftKeyDown = true; vGlobalDialogTitleColor = cBlack; TempWindow = CWnd::GetDlgItem(IDC_DialogTitleStaticText1); if (TempWindow) TempWindow->Invalidate(false); PostThreadMessage(vGlobalCallingThreadID,cHiddenKeyPressed, 0, 0x61); break; case cPageDown: // Help PostThreadMessage(vGlobalCallingThreadID, cShowHelp, 43, 0); TempWindow = CWnd::GetDlgItem(IDC_DialogTitleStaticText1); if (TempWindow) TempWindow->Invalidate(false); break; case 27: // Escape ::PostThreadMessage(vGlobalCallingThreadID, cStartChatWindowMessage, 0,0); break; } return true; //true indicates it has been handled, so do not process } return CDialogEx::PreTranslateMessage(pMsg); } void CUSBMemoryStickDialog::UpdateDisplay() { CString TempSourceFileName = "*.*"; //CFileStatus TempFileStatus; //if (CFile::GetStatus(TempSourceFileName, TempFileStatus)) // SetDlgItemText(IDC_DriveName1, TempFileStatus.m_szFullName); //WIN32_FIND_DATA FindFileData; //HANDLE hFind; //CString TempString = "\\\\"; //hFind = FindFirstFile(TempString, &FindFileData); //if (hFind == INVALID_HANDLE_VALUE) //{ // CNoticeDialog TempNoticeDialog; // TempNoticeDialog.vNoticeText = "\n\n\nNo files in image directory to delete"; // TempNoticeDialog.vType = cInformationMessage; // TempNoticeDialog.DoModal(); //} //else // SetDlgItemText(IDC_DriveName1, FindFileData.cFileName); // UINT TempDriveType GetDriveType("C:\\"); //To determine whether a drive is a USB-type drive, call SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY property. TCHAR volumeName[MAX_PATH + 1] = { 0 }; TCHAR fileSystemName[MAX_PATH + 1] = { 0 }; DWORD serialNumber = 0; DWORD maxComponentLen = 0; DWORD fileSystemFlags = 0; //BOOL SetupDiGetDeviceRegistryProperty( // _In_ HDEVINFO DeviceInfoSet, // _In_ PSP_DEVINFO_DATA DeviceInfoData, // _In_ DWORD Property, // _Out_opt_ PDWORD PropertyRegDataType, // _Out_opt_ PBYTE PropertyBuffer, // _In_ DWORD PropertyBufferSize, // _Out_opt_ PDWORD RequiredSize //); // //if (!SetupDiGetDeviceRegistryProperty(hDevInfo, // &spDevInfoData, // SPDRP_CLASS, //Retrieve property type, // 0L, // (PBYTE)szBuf, // 2048, // 0)) { // wIndex++; // continue; //if (GetVolumeInformation(_T("C:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) //{ // if (vOldDriveNameC != volumeName) // { // vOldDriveNameC = volumeName; // SetDlgItemText(IDC_DriveName1, volumeName); // } //} // _In_opt_ LPCTSTR lpRootPathName, // _Out_opt_ LPTSTR lpVolumeNameBuffer, // _In_ DWORD nVolumeNameSize, // _Out_opt_ LPDWORD lpVolumeSerialNumber, // _Out_opt_ LPDWORD lpMaximumComponentLength, // _Out_opt_ LPDWORD lpFileSystemFlags, // _Out_opt_ LPTSTR lpFileSystemNameBuffer, // _In_ DWORD nFileSystemNameSize //); if ((vGlobalCopyDone == 0x55) || (vGlobalCopyDone == 0x54)) //most recent copy operation finished 55=done, copied files, 54=done error so no files copied { if (vGlobalCopyDone == 0x55) { vGlobalCopyDone = 0; CNoticeDialog TempNoticeDialog1; CString TempText = "\n\n" + dtoa(vGlobalCopyFileCount, 0) + " Files Copied\nFrom: " + vLastSourceDirectory + "\nTo: " + vLastDestinationDirectory; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cInformationMessage; TempNoticeDialog1.DoModal(); } m_PleaseWait.ShowWindow(SW_HIDE); vGlobalCopyDone = 0; if (vNeedToCopyAllScreenShots) { vNeedToCopyAllScreenShots = false; OnStnClickedSubfunction7button(); } else if (vNeedToBackupSetup) { vNeedToBackupSetup = false; OnStnClickedFunction5button(); } } if (vGlobalCopyDone == 0xAA) //copying files { vCopyProgress++; if (vCopyProgress > 10) vCopyProgress = 0; CString TempText = ""; for (BYTE TempLoop = 0; TempLoop < vCopyProgress; TempLoop++) TempText = TempText + "."; TempText = "Copying Files, Please Wait" + TempText; SetDlgItemText(IDC_PleaseWait, TempText); } if (vOldXRayOnNotice != vLocalSystemData->vXRayOnNotice) { vOldXRayOnNotice = vLocalSystemData->vXRayOnNotice; if (vOldXRayOnNotice) m_XRaysOn.ShowWindow(SW_SHOW); else m_XRaysOn.ShowWindow(SW_HIDE); } CString TempNewDriveLetter = "None"; vHaveAUSBMemoryStick = false; vNumberOfPossibleMemorySticks = 0; double TempDriveSpaceFree = CheckDiskSpaceFree("C:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte if (vGlobalHardDriveTotalBytes < 20000000000) //less than 35 gigabytes { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "C:\\"; vNumberOfPossibleMemorySticks++; } if (vOldCFreeSpace != TempDriveSpaceFree) { vOldCFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace1, dtoaWithCommas(vOldCFreeSpace / 1000000, 0)); } if (vOldCSize != vGlobalHardDriveTotalBytes) { vOldCSize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize1, dtoaWithCommas(vOldCSize / 1000000, 0)); if (!vOldCSize) SetDlgItemText(IDC_DriveName1, _T("Drive 1")); else if (GetVolumeInformation(_T("C:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName1, volumeName); } } TempDriveSpaceFree = CheckDiskSpaceFree("D:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte if (vGlobalHardDriveTotalBytes < 35000000000) //less than 35 gigabytes { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "D:\\"; vNumberOfPossibleMemorySticks++; } if (vOldDFreeSpace != TempDriveSpaceFree) { vOldDFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace2, dtoaWithCommas(vOldDFreeSpace / 1000000, 0)); } if (vOldDSize != vGlobalHardDriveTotalBytes) { vOldDSize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize2, dtoaWithCommas(vOldDSize / 1000000, 0)); if (!vOldDSize) SetDlgItemText(IDC_DriveName2, _T("Drive 2")); else if (GetVolumeInformation(_T("D:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName2, volumeName); } } TempDriveSpaceFree = CheckDiskSpaceFree("E:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "E:\\"; vNumberOfPossibleMemorySticks++; } if (vOldEFreeSpace != TempDriveSpaceFree) { vOldEFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace3, dtoaWithCommas(vOldEFreeSpace / 1000000, 0)); } if (vOldESize != vGlobalHardDriveTotalBytes) { vOldESize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize3, dtoaWithCommas(vOldESize / 1000000, 0)); if (!vOldESize) SetDlgItemText(IDC_DriveName3, _T("Drive 3")); else if (GetVolumeInformation(_T("E:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName3, volumeName); } } TempDriveSpaceFree = CheckDiskSpaceFree("F:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "F:\\"; vNumberOfPossibleMemorySticks++; } if (vOldFFreeSpace != TempDriveSpaceFree) { vOldFFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace4, dtoaWithCommas(vOldFFreeSpace / 1000000, 0)); } if (vOldFSize != vGlobalHardDriveTotalBytes) { vOldFSize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize4, dtoaWithCommas(vOldFSize / 1000000, 0)); if (!vOldFSize) SetDlgItemText(IDC_DriveName4, _T("Drive 4")); else if (GetVolumeInformation(_T("F:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName4, volumeName); } } TempDriveSpaceFree = CheckDiskSpaceFree("G:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "G:\\"; vNumberOfPossibleMemorySticks++; } if (vOldGFreeSpace != TempDriveSpaceFree) { vOldGFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace5, dtoaWithCommas(vOldGFreeSpace / 1000000, 0)); } if (vOldGSize != vGlobalHardDriveTotalBytes) { vOldGSize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize5, dtoaWithCommas(vOldGSize / 1000000, 0)); if (!vOldGSize) SetDlgItemText(IDC_DriveName5, _T("Drive 5")); else if (GetVolumeInformation(_T("G:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName5, volumeName); } } TempDriveSpaceFree = CheckDiskSpaceFree("H:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "H:\\"; vNumberOfPossibleMemorySticks++; } if (vOldHFreeSpace != TempDriveSpaceFree) { vOldHFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace6, dtoaWithCommas(vOldHFreeSpace / 1000000, 0)); } if (vOldHSize != TempDriveSpaceFree) { vOldHSize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize6, dtoaWithCommas(vOldHSize / 1000000, 0)); if (!vOldHSize) SetDlgItemText(IDC_DriveName6, _T("Drive 6")); else if (GetVolumeInformation(_T("H:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName6, vOldDriveNameH); } } TempDriveSpaceFree = CheckDiskSpaceFree("I:\\"); if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte { vHaveAUSBMemoryStick = true; TempNewDriveLetter = "I:\\"; vNumberOfPossibleMemorySticks++; } if (vOldIFreeSpace != TempDriveSpaceFree) { vOldIFreeSpace = TempDriveSpaceFree; SetDlgItemText(IDC_DriveFreeSpace7, dtoaWithCommas(vOldIFreeSpace / 1000000, 0)); } if (vOldISize != vGlobalHardDriveTotalBytes) { vOldISize = vGlobalHardDriveTotalBytes; SetDlgItemText(IDC_DriveSize7, dtoaWithCommas(vOldISize / 1000000, 0)); if (!vOldISize) SetDlgItemText(IDC_DriveName7, _T("Drive 7")); else if (GetVolumeInformation(_T("I:\\"), volumeName, ARRAYSIZE(volumeName), &serialNumber, &maxComponentLen, &fileSystemFlags, fileSystemName, ARRAYSIZE(fileSystemName))) { SetDlgItemText(IDC_DriveName7, volumeName); } } //TempDriveSpaceFree = CheckDiskSpaceFree("J:\\"); //if (vGlobalHardDriveTotalBytes > 1000000) //greater than a megabyte //{ // vHaveAUSBMemoryStick = true; // TempNewDriveLetter = "J:\\"; //} //if (vOldDFreeSpace != TempDriveSpaceFree) //{ // vOldDFreeSpace = TempDriveSpaceFree; // SetDlgItemText(IDC_DriveFreeSpace1, dtoaWithCommas(vOldDFreeSpace, 0)); //} //if (vOldDSize != vGlobalHardDriveTotalBytes) //{ // vOldDSize = vGlobalHardDriveTotalBytes; // SetDlgItemText(IDC_DriveSize2, dtoaWithCommas(vOldDSize, 0)); //} if (vOldNumberOfPossibleMemorySticks != vNumberOfPossibleMemorySticks) { if ((vOldHaveAUSBMemoryStick != vHaveAUSBMemoryStick) || (vMemoryStickDriveLetter != TempNewDriveLetter)) { vOldHaveAUSBMemoryStick = vHaveAUSBMemoryStick; vMemoryStickDriveLetter = TempNewDriveLetter; if (vOldHaveAUSBMemoryStick) SetDlgItemText(IDC_MemoryStickDriveLabel, "Memory Stick on Drive Letter " + vMemoryStickDriveLetter); else SetDlgItemText(IDC_MemoryStickDriveLabel, _T("No USB Memory Stick Detected")); } vOldNumberOfPossibleMemorySticks = vNumberOfPossibleMemorySticks; if (vOldNumberOfPossibleMemorySticks > 1) m_Function4Button.ShowWindow(SW_SHOW); else { m_Function4Button.ShowWindow(SW_HIDE); this->InvalidateRect(&m_Function4Button.GetRectToInvalidateArrow()); } } } //void CUSBMemoryStickDialog::UpdateButtons() //{ //} void CUSBMemoryStickDialog::CopyFileToUSBStick(CString TempSourceFolder, CString TempFileName, CString TempDestinationFolder) { //source should have drive letter and \\ at end. Destination just has folder name without \\ at end if ((vNumberOfPossibleMemorySticks) && (vMemoryStickDriveLetter.GetLength())) { if (TempSourceFolder.Right(1) != "\\") TempSourceFolder = TempSourceFolder + "\\"; if (TempDestinationFolder.Right(1) != "\\") TempDestinationFolder = TempDestinationFolder + "\\"; CString TempDestinationFileName = vMemoryStickDriveLetter + TempDestinationFolder + TempFileName; CString TempDestinationFolderName = vMemoryStickDriveLetter + TempDestinationFolder; TempDestinationFolderName.Delete(TempDestinationFolderName.GetLength() - 1, 2); CString TempSourceFileName = TempSourceFolder + TempFileName; CFile TempFile; CFileStatus TempFileStatus; if (CFile::GetStatus(TempSourceFileName, TempFileStatus)) { SetFileAttributes(TempSourceFileName,FILE_ATTRIBUTE_NORMAL); bool TempDestinationDirectoryOK = true; if (!CFile::GetStatus(TempDestinationFolderName, TempFileStatus)) if (!CreateDirectory(TempDestinationFolderName,NULL)) { TempDestinationDirectoryOK = false; CNoticeDialog TempNoticeDialog1; CString TempText("\n\nError, Could not create directory:\n"); TempText = TempText + TempDestinationFolderName; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cErrorMessage; TempNoticeDialog1.DoModal(); } LPTSTR TempSourceName = TempSourceFileName.GetBuffer(TempSourceFileName.GetLength()); LPTSTR TempDestinationName = TempDestinationFileName.GetBuffer(TempDestinationFileName.GetLength()); if (TempDestinationDirectoryOK) if (!CopyFile(TempSourceName, TempDestinationName, false)) { DWORD ErrorNow = GetLastError(); // system error codes http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85) //ReportErrorMessage("Copy File Error: " + dtoa(ErrorNow) +" File: " + TempFileName + " to " + TempDestinationName, cEMailInspx, 32000); CNoticeDialog TempNoticeDialog; if ((ErrorNow == 3) || (ErrorNow == 112)) TempNoticeDialog.vNoticeText = "\nUSB Copy File Error: "+ dtoa(ErrorNow) +"-Drive Full.\nFile: " + TempFileName + "\nto: " + vMemoryStickDriveLetter + TempDestinationFolder; else TempNoticeDialog.vNoticeText = "\nUSB Copy File Error: "+ dtoa(ErrorNow) +"\nFile: " + TempFileName + "\nto: " + vMemoryStickDriveLetter + TempDestinationFolder; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } //else //{ // CNoticeDialog TempNoticeDialog; // TempNoticeDialog.vNoticeText = "\n\nCopy Successful\nFile: " + TempFileName + "\nto " + TempDestinationFolderName; // TempNoticeDialog.vType = cInformationMessage; // TempNoticeDialog.DoModal(); //} } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nFile: " +TempFileName + "\n\nNot Found"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nNo USB Memory Stick to copy to"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } void CUSBMemoryStickDialog::CopyFolderToUSBStick(CString TempSourceDirectory, CString TempDestinationDirectory) { if ((vNumberOfPossibleMemorySticks) && (vMemoryStickDriveLetter.GetLength())) { CString TempDestinationFolderName = vMemoryStickDriveLetter + TempDestinationDirectory; CFile TempFile; CFileStatus TempFileStatus; if (CFile::GetStatus(TempSourceDirectory, TempFileStatus)) { //SetFileAttributes(TempSourceDirectory,FILE_ATTRIBUTE_NORMAL); bool TempDestinationDirectoryOK = true; if (!CFile::GetStatus(TempDestinationFolderName, TempFileStatus)) if (!CreateDirectory(TempDestinationFolderName,NULL)) { TempDestinationDirectoryOK = false; vGlobalCopyDone = 0x54; //done with this copy, it failed CNoticeDialog TempNoticeDialog1; CString TempText("\n\nError, Could not create directory:\n"); TempText = TempText + TempDestinationFolderName; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cErrorMessage; TempNoticeDialog1.DoModal(); } if (TempDestinationDirectoryOK) { if (TempSourceDirectory.Right(1) == "\\") TempSourceDirectory.Delete(TempSourceDirectory.GetLength() - 1, 2); if (TempDestinationFolderName.Right(1) == "\\") TempDestinationFolderName.Delete(TempDestinationFolderName.GetLength() - 1, 2); //if (TempDestinationFolderName.Right(1) != "\\") // TempDestinationFolderName = TempDestinationFolderName + "\\"; vGlobalCopyDone = 0xAA; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, _T("Copying Files. Please Wait")); if (vMainWindowPointer) vMainWindowPointer->CopyFilesInDirectoryToDirectory(TempSourceDirectory, TempDestinationFolderName); } } else { vGlobalCopyDone = 0x54; //done with this copy, it failed CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nFolder: " +TempSourceDirectory + "\n\nNot Found"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } else { vGlobalCopyDone = 0x54; //done with this copy, it failed CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nNo USB Memory Stick to copy to"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } void CUSBMemoryStickDialog::OnStnClickedDialogtitlestatictext1() { if (vGlobalShiftKeyDown) { if (PasswordOK(cTemporaryInspxPassword,false)) { LPCTSTR szFilter = _T("All Files (*.*)|*.*||; //CSV Files (*.CSV)|*.CSV|Text Files (*.TXT)|*.TXT||"); CString TempFileString = ""; CFileDialog *TempFileDialog = new CFileDialog(true, NULL, TempFileString, OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_EXPLORER, szFilter, this); vGlobalInWindowsDialog = true; int nResponse = TempFileDialog->DoModal(); vGlobalInWindowsDialog = false; //if (nResponse == IDOK) //{ // TempPath = TempFileDialog->GetPathName(); // TempReturn = TempFileDialog->GetFileName(); //} delete TempFileDialog; } } else { BYTE TempHiddenKeys = 8; if (!PasswordOK(cTemporaryInspxPassword,false)) TempHiddenKeys = 10; PostThreadMessage(vGlobalCallingThreadID, cDisplaySoftKeyMenu, TempHiddenKeys, TempHiddenKeys); } } void CUSBMemoryStickDialog::RestoreSetupsFromBackup() { CString TempFolderNames[100]; BYTE TempNumberOfBackupFoldersToPickFrom = 0; WIN32_FIND_DATA FindFileData; HANDLE hFind; CString TempSearchName = vMemoryStickDriveLetter + "*ScanTrac Backup"; LPTSTR TempDirectoryName = TempSearchName.GetBuffer(TempSearchName.GetLength()); hFind = FindFirstFile(TempDirectoryName, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\n\nNo ScanTrac backups found on USB Memory Stick to restore"; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } else { CString TempFileNameString = FindFileData.cFileName; if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { TempFolderNames[TempNumberOfBackupFoldersToPickFrom] = FindFileData.cFileName; TempNumberOfBackupFoldersToPickFrom++; } while (FindNextFile(hFind, &FindFileData)) { CString TempFileNameString = FindFileData.cFileName; if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { if (TempNumberOfBackupFoldersToPickFrom < 100) { TempFolderNames[TempNumberOfBackupFoldersToPickFrom] = FindFileData.cFileName; TempNumberOfBackupFoldersToPickFrom++; } } } } FindClose(hFind); if (TempNumberOfBackupFoldersToPickFrom) { int TempBackupFolderChoice = 0; if (TempNumberOfBackupFoldersToPickFrom == 1) { CYesNoDialog TempYesNoDialog; CString TempText = "Do you want to restore ScanTrac program and\nsetup files from backup folder: " + TempFolderNames[0] + "?\nThis will reboot computer to complete.\nAny changes to setups after backup was made\nwill be lost."; TempYesNoDialog.vNoticeText =TempText; TempYesNoDialog.vQuestionType = cConfirmAbandon; TempYesNoDialog.vYesButtonText = "Continue"; TempYesNoDialog.vNoButtonText = "Abort"; int TempResult = TempYesNoDialog.DoModal(); //if user said OK if (TempResult != IDOK) TempBackupFolderChoice = -1; } else if (TempNumberOfBackupFoldersToPickFrom > 1) { CSelectItemDialog ISelectItemDialog; //Set dialog box data titles and number value ISelectItemDialog.vTitleString = "Choose folder to restore ScanTrac configuration files and program from"; ISelectItemDialog.m_DialogTitleStaticText2 = ""; ISelectItemDialog.m_DialogTitleStaticText3 = ""; ISelectItemDialog.vBackgroundColor = cGreen; ISelectItemDialog.vInAutoSetup = vLocalSystemData->vInAutoSetup; ISelectItemDialog.vNumberOfItems = TempNumberOfBackupFoldersToPickFrom; for (BYTE TempLoop = 0; TempLoop < TempNumberOfBackupFoldersToPickFrom; TempLoop++) ISelectItemDialog.vItems[TempLoop] = TempFolderNames[TempLoop]; //ISelectItemDialog.m_DialogTitleStaticText3 = "Original Value: " + vMemoryStickDriveLetter; //Pass control to dialog box and display int nResponse = ISelectItemDialog.DoModal(); //dialog box is now closed, if user pressed select do this //if user pressed cancel, do nothing if (nResponse == IDOK) { TempBackupFolderChoice = ISelectItemDialog.vItemNumberSelected - 1; } else if (nResponse == 10) { //Main Menu button pressed Sleep(1); CDialog::EndDialog(10); } else TempBackupFolderChoice = -1; } if (TempBackupFolderChoice >= 0) { //do restore from USB backup CopyFolderToRestoreBackup(TempFolderNames[TempBackupFolderChoice]); } } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\n\nNo ScanTrac backups found on USB Memory Stick to restore"; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } } void CUSBMemoryStickDialog::CopyFolderToRestoreBackup(CString TempBackupFolderName) { if ((vNumberOfPossibleMemorySticks) && (vMemoryStickDriveLetter.GetLength())) { WORD TempFilesCopied = 0; CString TempSourceFolderName = vMemoryStickDriveLetter + TempBackupFolderName; CFile TempFile; CFileStatus TempFileStatus; if (CFile::GetStatus(TempSourceFolderName, TempFileStatus)) { bool TempDestinationDirectoryOK = true; //SetFileAttributes(TempSourceDirectory,FILE_ATTRIBUTE_NORMAL); CString TempDestinationFolder = "C:\\ScanTracExtra\\ScanTrac_New_Release"; if (!CFile::GetStatus(TempDestinationFolder, TempFileStatus)) if (!CreateDirectory(TempDestinationFolder,NULL)) { TempDestinationDirectoryOK = false; CNoticeDialog TempNoticeDialog1; CString TempText("\n\nError, Could not create directory:\n"); TempText = TempText + TempDestinationFolder; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cErrorMessage; TempNoticeDialog1.DoModal(); } TempDestinationFolder = TempDestinationFolder + "\\"; CString TempCheckFileName = TempSourceFolderName + "\\Products.STR"; if (TempDestinationDirectoryOK) if (!CFile::GetStatus(TempCheckFileName, TempFileStatus)) { CNoticeDialog TempNoticeDialog1; CString TempText("\n\nError, Could not find Products.STR\nin: "); TempText = TempText + TempSourceFolderName; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cErrorMessage; TempNoticeDialog1.DoModal(); } else { //restore from backup on USB Stick WIN32_FIND_DATA FindFileData; HANDLE hFind; CString TempCopyFileName = TempSourceFolderName + "\\*.*"; LPTSTR TempDirectoryName = TempCopyFileName.GetBuffer(TempCopyFileName.GetLength()); hFind = FindFirstFile(TempDirectoryName, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { CNoticeDialog TempNoticeDialog; CString TempString = "\n\nNo files to copy in\n"; TempString = TempString + TempDirectoryName; TempNoticeDialog.vNoticeText = TempString; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } else { CString TempFileNameString = FindFileData.cFileName; if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CString TempFileNameText = FindFileData.cFileName; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); CString TempSourceNameString = TempSourceFolderName + "\\" + FindFileData.cFileName; CString TempDestinationNameString = TempDestinationFolder + FindFileData.cFileName; LPTSTR TempSourceName = TempSourceNameString.GetBuffer(TempSourceNameString.GetLength()); LPTSTR TempDestinationName = TempDestinationNameString.GetBuffer(TempDestinationNameString.GetLength()); if (!CopyFile(TempSourceName, TempDestinationName, false)) { DWORD ErrorNow = GetLastError(); // system error codes http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85) CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\nUSB Copy File Error: "+ dtoa(ErrorNow) +"\nFile: " + TempFileNameText + "\nto: " + TempDestinationFolder; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } else TempFilesCopied++; } while (FindNextFile(hFind, &FindFileData)) { CString TempFileNameString = FindFileData.cFileName; if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CString TempFileNameText = FindFileData.cFileName; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); CString TempSourceNameString = TempSourceFolderName + "\\" + FindFileData.cFileName; CString TempDestinationNameString = TempDestinationFolder + FindFileData.cFileName; LPTSTR TempSourceName = TempSourceNameString.GetBuffer(TempSourceNameString.GetLength()); LPTSTR TempDestinationName = TempDestinationNameString.GetBuffer(TempDestinationNameString.GetLength()); if (!CopyFile(TempSourceName, TempDestinationName, false)) { DWORD ErrorNow = GetLastError(); // system error codes http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85) CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\nUSB Copy File Error: "+ dtoa(ErrorNow) +"\nFile: " + TempFileNameText + "\nto: " + TempDestinationFolder; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } else TempFilesCopied++; } } } FindClose(hFind); m_PleaseWait.ShowWindow(SW_SHOW); if (TempFilesCopied) { SetDlgItemText(IDC_PleaseWait, dtoa(TempFilesCopied, 0) + " Files Copied, Preparing ScanTrac Software/Setup Restore"); bool TempAllOK = true; //copy files to update folder then reboot BOOL ZipFileExists = PathFileExists(_T("C:\\ScanTracExtra\\ScanTrac_New_Release\\ScanTrac.exe")); BOOL UnZipExeFileExists = PathFileExists(_T("C:\\ScanTracExtra\\ScanTrac_New_Release\\Products.STR")); if ((ZipFileExists == TRUE) && (UnZipExeFileExists == TRUE)) { try { HANDLE hBatchFileConfigInfo = CreateFile(_T("C:\\ScanTracExtra\\ScanTrac_New_Release\\Restore.bat"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ |FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (hBatchFileConfigInfo != INVALID_HANDLE_VALUE) // returns invalid handle if file exists, don't need ((ErrorMsg = GetLastError()) != ERROR_FILE_EXISTS)) { // if file does not exist, write it CString BufferToWrite = "echo OFF"; BufferToWrite += _T("\n cls"); BufferToWrite += _T("\n echo Please Wait, Copying Files..."); BufferToWrite += _T("\n PING 127.0.0.1 -n 10 >nul"); BufferToWrite += _T("\n del /q C:\\ScanTracExtra\\ScanTracPreRestoreBackup\\*.*"); BufferToWrite += _T("\n xcopy C:\\ScanTrac\\*.* C:\\ScanTracExtra\\ScanTracPreRestoreBackup\\*.*"); BufferToWrite += _T("\n del /q C:\\ScanTrac\\*.*"); BufferToWrite += _T("\n xcopy C:\\ScanTracExtra\\ScanTrac_New_Release\\*.* C:\\ScanTrac\\*.*"); //BufferToWrite += _T("\n del /q C:\\ScanTracExtra\\ScanTrac_New_Release\\*.*"); BufferToWrite += _T("\n shutdown.exe /r /t 5"); DWORD BytesWritten = 0; USES_CONVERSION; LPSTR TempStringToWrite = W2A(BufferToWrite); WriteFile(hBatchFileConfigInfo, TempStringToWrite, BufferToWrite.GetLength(), &BytesWritten, NULL); } CloseHandle(hBatchFileConfigInfo); //NOTE FILE NAME IN OVERLAYDETAIL.BAT MUST MATCH file name in CString FileNameToDisplay = "FBWFOverlayDetail.txt" //NOTE DIRECTORY NAME IN OVERLAYDETAIL.BAT MUST MATCH directory name in cLogDirectory c:\ScanTracLogs // OverlayDetail batch file is -- fbwfmgr /overlaydetail >C:\ScanTracLogs\FBWFOverlayDetail.txt intptr_t TempSpawnOk = _spawnl(_P_NOWAIT, "C:\\ScanTracExtra\\ScanTrac_New_Release\\Restore.bat", "C:\\ScanTracExtra\\ScanTrac_New_Release\\Restore.bat", NULL); if (TempSpawnOk != NULL) { vMainWindowPointer->ExitProgram(); CDialog::EndDialog(10); } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nCould not restore ScanTrac program and setup files from USB Backup"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); SetDlgItemText(IDC_PleaseWait, _T("Could not restore ScanTrac program and setup files from USB Backup")); } } catch ( char *strException) { CNoticeDialog TempNoticeDialog; CString TempAString; CString TempNoticeString; TempAString.Format(_T("\nException raised: %s"), strException); TempNoticeString = "\nUnzip file caused an Exception error." + TempAString + "\nCall Service"; TempNoticeDialog.vNoticeText = TempNoticeString; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nCould not restore ScanTrac program and setup files from USB Backup"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); SetDlgItemText(IDC_PleaseWait, _T("Could not restore ScanTrac program and setup files from USB Backup")); } } else SetDlgItemText(IDC_PleaseWait, _T("No Files Copied, canTrac Software/Setup Restore Failed")); } } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nFolder: " +TempSourceFolderName + "\n\nNot Found"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); } } else { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\nNo USB Memory Stick to copy to"; TempNoticeDialog.vType = cErrorMessage; TempNoticeDialog.DoModal(); vGlobalCopyDone = 0x54; //done with this copy, it failed } } void CUSBMemoryStickDialog::CopyFilesToUSBStick(CString TempFolder, bool TempYesterday) { //Copy Today's Screen Shots CString TempSourceDirectory = TempFolder; CString TempDestinationFolder = TempFolder; TempDestinationFolder.Delete(0, 3); //remove the c: TempDestinationFolder.Delete(TempDestinationFolder.GetLength() - 1, 2); TempSourceDirectory.Delete(TempSourceDirectory.GetLength() - 1, 2); CTime TempTime = CTime::GetCurrentTime(); if (TempYesterday) { CTimeSpan TempTimeForOneDay = 86400; TempTime = TempTime - TempTimeForOneDay; //subtract one day } CString TempTodaysDateString = TempTime.Format("%Y-%m-%d"); CString TempSourceFindDirectory = TempFolder + "*" + TempTodaysDateString + "*.*"; WIN32_FIND_DATA FindFileData; HANDLE hFind; LPTSTR TempDirectoryName = TempSourceFindDirectory.GetBuffer(TempSourceFindDirectory.GetLength()); hFind = FindFirstFile(TempDirectoryName, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { CNoticeDialog TempNoticeDialog; TempNoticeDialog.vNoticeText = "\n\n\nNo files to copy in\n" + TempSourceFindDirectory; TempNoticeDialog.vType = cInformationMessage; TempNoticeDialog.DoModal(); } else { CString TempFileNameString = FindFileData.cFileName; if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CString TempFileNameText = FindFileData.cFileName; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); } while (FindNextFile(hFind, &FindFileData)) { CString TempFileNameString = FindFileData.cFileName; if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CString TempFileNameText = FindFileData.cFileName; m_PleaseWait.ShowWindow(SW_SHOW); SetDlgItemText(IDC_PleaseWait, "Copying: " + TempFileNameText); CopyFileToUSBStick(TempSourceDirectory, TempFileNameText, TempDestinationFolder); Sleep(10); } } } FindClose(hFind); Sleep(1000); m_PleaseWait.ShowWindow(SW_HIDE); } void CUSBMemoryStickDialog::CopySavedImagesToUSBStick(CString TempFolder, bool TempYesterday) { CTime TempTime = CTime::GetCurrentTime(); if (TempYesterday) { CTimeSpan TempTimeForOneDay = 86400; TempTime = TempTime - TempTimeForOneDay; //subtract one day } CString TempString = TempTime.Format("%Y-%m-%d"); CString TempSourceDirectory = TempFolder + TempString; CString TempDestinationFolder = TempFolder + TempString; TempDestinationFolder.Delete(0, 3); //make sure USB Stick has ScanTracRejectedImages folder CString TempPrimaryFolderName = TempFolder; TempPrimaryFolderName.Delete(0, 3); TempPrimaryFolderName.Delete(TempPrimaryFolderName.GetLength() - 1, 2); TempPrimaryFolderName = vMemoryStickDriveLetter + TempPrimaryFolderName; CFile TempFile; CFileStatus TempFileStatus; bool TempDestinationDirectoryOK = true; if (!CFile::GetStatus(TempPrimaryFolderName, TempFileStatus)) if (!CreateDirectory(TempPrimaryFolderName,NULL)) { TempDestinationDirectoryOK = false; CNoticeDialog TempNoticeDialog1; CString TempText("\n\nError, Could not create directory:\n"); TempText = TempText + TempPrimaryFolderName; TempNoticeDialog1.vNoticeText = TempText; TempNoticeDialog1.vType = cErrorMessage; TempNoticeDialog1.DoModal(); } if (TempDestinationDirectoryOK) { vGlobalCopyFileCount = 0; //setup variables to give message when done vGlobalCopyDone = 0xAA; vLastSourceDirectory = TempSourceDirectory; vLastDestinationDirectory = vMemoryStickDriveLetter + TempDestinationFolder; CopyFolderToUSBStick(TempSourceDirectory, TempDestinationFolder); } }
e045b77ce0eb989adf94459c8037013f67fe4877
9be0baa3d53e460fb9088280b2f38d6352a4097e
/nmlmsgs/include/obsDetCfg.hh
8458c56378189b12f1c4d468679a998db1c2edbc
[ "LicenseRef-scancode-public-domain" ]
permissive
usnistgov/rcslib
480cd9f97b9abe83c23dcddc1dd4db253084ff13
f26d07fd14e068a1a5bfb97b0dc6ba5afefea0a1
refs/heads/master
2023-04-06T13:35:53.884499
2023-04-03T20:01:08
2023-04-03T20:01:08
32,079,125
35
22
NOASSERTION
2020-10-12T22:03:48
2015-03-12T13:43:52
Java
UTF-8
C++
false
false
3,118
hh
/** * @file obsDetCfg.hh * * @remark ~ NML data structure for Obstacle Detection Configuration. * * @author ~ Will Shackleford * * @verbatim * ,--------------------------------------------------------------------. * . THIS software was developed at the National Institute of . * . Standards and Technology by employees of the Federal Government . * . in the course of their official duties. Pursuant to title 17 . * . Section 105 of the United States Code this software is not . * . subject to copyright protection and is in the public . * . domain. NIST's [intelligent mobility] software is an experimental . * . system. NIST assumes no responsibility whatsoever for its use by . * . other parties, and makes no guarantees, expressed or implied, . * . about its quality, reliability, or any other characteristic. We . * . would appreciate acknowledgement if the software is used. This . * . software can be redistributed and/or modified freely provided . * . that any derivative works bear some notice that they are derived . * . from it, and any modified versions bear some notice that they . * . have been modified. . * `------------------------------------------------------------------- * @endverbatim * * @par Created by Will Shackleford, 2008-09-25 **/ #ifndef OBSDETCFG_HH #define OBSDETCFG_HH // generate_symbol_lookups=true /*----------------------------------* * Preprocessor and Include Headers * \*--------------------------------*/ #include "rcs.hh" // Common RCS definitions #include "nmlOffsets.hh" // OBSDETCFG_BASE /*-----------------* * Macro Constants * \*---------------*/ #define OBSTACLE_DET_CONFIG_TYPE OBSDETCFG_BASE /*-----------------* * Data Structures * \*---------------*/ class OBSTACLE_DET_CONFIG : public NMLmsg { public: OBSTACLE_DET_CONFIG(); void update(CMS *); bool enforce_min_intensity; float min_intensity; bool enforce_max_intensity; float max_intensity; //default=1.0 bool enforce_min_range; float min_range; bool enforce_max_range; float max_range; //default=10.0 double roll; double pitch; double yaw; bool enforce_floor_threshold; double floor_threshold; bool apply_isolated_obstacle_filter; int isolated_obstacle_filter_window; int isolated_obstacle_filter_min; bool apply_smoothing; int smoothing_size; double max_smoothing_diff; //default=1.0 bool enable_x_minimum; float x_minimum; //default=-10.0 bool enable_x_maximum; float x_maximum; //default=+10.0 bool enable_y_minimum; float y_minimum; //default=-10.0 bool enable_y_maximum; float y_maximum; //default=+10.0 bool enable_z_minimum; float z_minimum; //default=-10.0 bool enable_z_maximum; float z_maximum; //default=+10.0 int stop_at_obs_pixel; }; /*--------------------* * Function Prototype * \*------------------*/ int obsDetCfg_format (NMLTYPE type, void *buf, CMS *cms); #endif // OBSDETCFG_HH
11576f2f2f7ee54a44bf7c4790c5a48c3b521072
1999ef094653d4e48d4283021e73dc398af32326
/src/jag/draw/PixelStore.cpp
01cf4ab566752bd0b744bba1dde9454854d91a8c
[]
no_license
pmartz/jag-3d
76e69a93504d8088f788ee7766645e0b3637c07f
53bb0d98f1a67f27224d56f304cce3be3bed755b
refs/heads/master
2020-05-20T05:52:55.150484
2014-07-16T16:33:57
2014-07-16T16:33:57
32,233,835
0
1
null
null
null
null
UTF-8
C++
false
false
2,721
cpp
/*************** <auto-copyright.rb BEGIN do not edit this line> ************** Copyright 2012-2014 by Ames Laboratory and Skew Matrix Software, LLC Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. *************** <auto-copyright.rb END do not edit this line> ***************/ #include <jag/draw/PixelStore.h> #include <jag/draw/PlatformOpenGL.h> namespace jag { namespace draw { PixelStore::PixelStore() : _swapBytes( GL_FALSE ), _lsbFirst( GL_FALSE ), _rowLength( 0 ), _skipRows( 0 ), _skipPixels( 0 ), _alignment( 4 ), _imageHeight( 0 ), _skipImages( 0 ) { } PixelStore::PixelStore( const PixelStore& rhs ) : _swapBytes( rhs._swapBytes ), _lsbFirst( rhs._lsbFirst ), _rowLength( rhs._rowLength ), _skipRows( rhs._skipRows ), _skipPixels( rhs._skipPixels ), _alignment( rhs._alignment ), _imageHeight( rhs._imageHeight ), _skipImages( rhs._skipImages ) { } PixelStore::~PixelStore() { } void PixelStore::pack() { glPixelStorei( GL_PACK_ROW_LENGTH, _rowLength ); glPixelStorei( GL_PACK_SKIP_ROWS, _skipRows ); glPixelStorei( GL_PACK_SKIP_PIXELS, _skipPixels ); glPixelStorei( GL_PACK_ALIGNMENT, _alignment ); #ifndef JAG3D_USE_GLES3 glPixelStorei( GL_PACK_SWAP_BYTES, (GLint)_swapBytes ); glPixelStorei( GL_PACK_LSB_FIRST, (GLint)_lsbFirst ); glPixelStorei( GL_PACK_IMAGE_HEIGHT, _imageHeight ); glPixelStorei( GL_PACK_SKIP_IMAGES, _skipImages ); #endif } void PixelStore::unpack() { glPixelStorei( GL_UNPACK_ROW_LENGTH, _rowLength ); glPixelStorei( GL_UNPACK_SKIP_ROWS, _skipRows ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, _skipPixels ); glPixelStorei( GL_UNPACK_ALIGNMENT, _alignment ); #ifndef JAG3D_USE_GLES3 glPixelStorei( GL_UNPACK_SWAP_BYTES, (GLint)_swapBytes ); glPixelStorei( GL_UNPACK_LSB_FIRST, (GLint)_lsbFirst ); glPixelStorei( GL_UNPACK_IMAGE_HEIGHT, _imageHeight ); glPixelStorei( GL_UNPACK_SKIP_IMAGES, _skipImages ); #endif } // namespace jag::draw:: } }
[ "pmartz@localhost" ]
pmartz@localhost
9c3739a60bc5c7206aa05667aa0033edd0d560e6
f45599da2e919e306a7a545d2678a2bd47dc5dac
/src/qt/messagemodel.h
1ee6b11cfdf4ad23839a4f3e0f53e76f7385c224
[ "MIT" ]
permissive
Ethernodes-org/eunowallet
3cc92669eb0f6a2460a97bb97f30ab8f064ef2ba
90bdcccda9eb0eee66e8b7f7d5c637afe27efaf3
refs/heads/master
2022-03-09T02:27:39.073059
2019-09-04T20:08:52
2019-09-04T20:08:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,399
h
#ifndef MESSAGEMODEL_H #define MESSAGEMODEL_H #include "uint256.h" #include <vector> #include "allocators.h" /* for SecureString */ #include "smessage.h" #include <map> #include <QSortFilterProxyModel> #include <QAbstractTableModel> #include <QStringList> #include <QDateTime> class MessageTablePriv; class InvoiceTableModel; class InvoiceItemTableModel; class ReceiptTableModel; class CWallet; class WalletModel; class OptionsModel; class SendMessagesRecipient { public: QString address; QString label; QString pubkey; QString message; }; struct MessageTableEntry { enum Type { Sent, Received }; std::vector<unsigned char> chKey; Type type; QString label; QString to_address; QString from_address; QDateTime sent_datetime; QDateTime received_datetime; QString message; MessageTableEntry() {} MessageTableEntry(std::vector<unsigned char> &chKey, Type type, const QString &label, const QString &to_address, const QString &from_address, const QDateTime &sent_datetime, const QDateTime &received_datetime, const QString &message): chKey(chKey), type(type), label(label), to_address(to_address), from_address(from_address), sent_datetime(sent_datetime), received_datetime(received_datetime), message(message) { } }; /** Interface to euno Secure Messaging from Qt view code. */ class MessageModel : public QAbstractTableModel { Q_OBJECT public: explicit MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent = 0); ~MessageModel(); enum StatusCode // Returned by sendMessages { OK, InvalidAddress, InvalidMessage, DuplicateAddress, MessageCreationFailed, // Error returned when DB is still locked MessageCommitFailed, Aborted, FailedErrorShown }; enum ColumnIndex { Type = 0, /**< Sent/Received */ SentDateTime = 1, /**< Time Sent */ ReceivedDateTime = 2, /**< Time Received */ Label = 3, /**< User specified label */ ToAddress = 4, /**< To Bitcoin address */ FromAddress = 5, /**< From Bitcoin address */ Message = 6, /**< Plaintext */ TypeInt = 7, /**< Plaintext */ Key = 8, /**< chKey */ HTML = 9, /**< HTML Formatted Data */ }; /** Roles to get specific information from a message row. These are independent of column. */ enum RoleIndex { /** Type of message */ TypeRole = Qt::UserRole, /** Date and time this message was sent */ /** message key */ KeyRole, SentDateRole, /** Date and time this message was received */ ReceivedDateRole, /** From Address of message */ FromAddressRole, /** To Address of message */ ToAddressRole, /** Filter address related to message */ FilterAddressRole, /** Label of address related to message */ LabelRole, /** Full Message */ MessageRole, /** Short Message */ ShortMessageRole, /** HTML Formatted */ HTMLRole, /** Ambiguous bool */ Ambiguous }; static const QString Sent; /**< Specifies sent message */ static const QString Received; /**< Specifies sent message */ //QList<QString> ambiguous; /**< Specifies Ambiguous addresses */ /** @name Methods overridden from QAbstractTableModel @{*/ int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; QModelIndex index(int row, int column, const QModelIndex & parent) const; bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); Qt::ItemFlags flags(const QModelIndex & index) const; /*@}*/ /* Look up row index of a message in the model. Return -1 if not found. */ int lookupMessage(const QString &message) const; WalletModel *getWalletModel(); OptionsModel *getOptionsModel(); void resetFilter(); bool getAddressOrPubkey( QString &Address, QString &Pubkey) const; // Send messages to a list of recipients StatusCode sendMessages(const QList<SendMessagesRecipient> &recipients); StatusCode sendMessages(const QList<SendMessagesRecipient> &recipients, const QString &addressFrom); QSortFilterProxyModel *proxyModel; private: CWallet *wallet; WalletModel *walletModel; OptionsModel *optionsModel; MessageTablePriv *priv; QStringList columns; void subscribeToCoreSignals(); void unsubscribeFromCoreSignals(); public slots: /* Check for new messages */ void newMessage(const SecMsgStored& smsg); void newOutboxMessage(const SecMsgStored& smsg); void walletUnlocked(); void setEncryptionStatus(int status); friend class MessageTablePriv; signals: // Asynchronous error notification void error(const QString &title, const QString &message, bool modal); }; #endif // MESSAGEMODEL_H
d4cff695e47cdfd037ca7d06794dcffd3f8b9380
f69cd7e9b3400e533255ef256d3682c5f3bafbf5
/422串口发数软件/ComSenderCB6 - for - HuaBin/skin/Spreg.hpp
190e67ce7885637e9e3d207799948c92c66c5915
[]
no_license
cloudandzack007/Tools
ca8f66904b215af9f7e1db8bbecd86a7c540147c
4ed6575100cd3d6fc065d27f6e4300870e0b9507
refs/heads/master
2020-09-05T13:36:57.308881
2020-03-16T07:59:50
2020-03-16T07:59:50
220,119,707
0
0
null
null
null
null
UTF-8
C++
false
false
3,447
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'spreg.pas' rev: 6.00 #ifndef spregHPP #define spregHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <DesignIntf.hpp> // Pascal unit #include <DesignEditors.hpp> // Pascal unit #include <TypInfo.hpp> // Pascal unit #include <Controls.hpp> // Pascal unit #include <Forms.hpp> // Pascal unit #include <Dialogs.hpp> // Pascal unit #include <Menus.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Spreg { //-- type declarations ------------------------------------------------------- class DELPHICLASS TspSkinStatusBarEditor; class PASCALIMPLEMENTATION TspSkinStatusBarEditor : public Designeditors::TDefaultEditor { typedef Designeditors::TDefaultEditor inherited; public: virtual void __fastcall ExecuteVerb(int Index); virtual AnsiString __fastcall GetVerb(int Index); virtual int __fastcall GetVerbCount(void); public: #pragma option push -w-inl /* TComponentEditor.Create */ inline __fastcall virtual TspSkinStatusBarEditor(Classes::TComponent* AComponent, Designintf::_di_IDesigner ADesigner) : Designeditors::TDefaultEditor(AComponent, ADesigner) { } #pragma option pop public: #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TspSkinStatusBarEditor(void) { } #pragma option pop }; class DELPHICLASS TspSkinToolBarEditor; class PASCALIMPLEMENTATION TspSkinToolBarEditor : public Designeditors::TDefaultEditor { typedef Designeditors::TDefaultEditor inherited; public: virtual void __fastcall ExecuteVerb(int Index); virtual AnsiString __fastcall GetVerb(int Index); virtual int __fastcall GetVerbCount(void); public: #pragma option push -w-inl /* TComponentEditor.Create */ inline __fastcall virtual TspSkinToolBarEditor(Classes::TComponent* AComponent, Designintf::_di_IDesigner ADesigner) : Designeditors::TDefaultEditor(AComponent, ADesigner) { } #pragma option pop public: #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TspSkinToolBarEditor(void) { } #pragma option pop }; class DELPHICLASS TspSkinPageControlEditor; class PASCALIMPLEMENTATION TspSkinPageControlEditor : public Designeditors::TDefaultEditor { typedef Designeditors::TDefaultEditor inherited; public: virtual void __fastcall ExecuteVerb(int Index); virtual AnsiString __fastcall GetVerb(int Index); virtual int __fastcall GetVerbCount(void); public: #pragma option push -w-inl /* TComponentEditor.Create */ inline __fastcall virtual TspSkinPageControlEditor(Classes::TComponent* AComponent, Designintf::_di_IDesigner ADesigner) : Designeditors::TDefaultEditor(AComponent, ADesigner) { } #pragma option pop public: #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TspSkinPageControlEditor(void) { } #pragma option pop }; //-- var, const, procedure --------------------------------------------------- extern PACKAGE void __fastcall Register(void); } /* namespace Spreg */ using namespace Spreg; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // spreg
8272ca42e211a686a55cb340cd4e0796815e2e43
922d5487bc18dd4d044d41d6b81cd14eb952c591
/install/include/object_grabber/object_grabberGoal.h
8f8b487e4f241cb4833b6e98a2013cc749f645da
[]
no_license
hanbincho/ros_ws
21b747f115cee85a3b8a578028ac44e069721c31
d92feebd845a69bb8535e8c48592caf2b94d6497
refs/heads/master
2020-04-02T15:45:16.395227
2018-11-07T04:09:07
2018-11-07T04:09:07
149,820,985
0
0
null
null
null
null
UTF-8
C++
false
false
15,295
h
// Generated by gencpp from file object_grabber/object_grabberGoal.msg // DO NOT EDIT! #ifndef OBJECT_GRABBER_MESSAGE_OBJECT_GRABBERGOAL_H #define OBJECT_GRABBER_MESSAGE_OBJECT_GRABBERGOAL_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <geometry_msgs/PoseStamped.h> namespace object_grabber { template <class ContainerAllocator> struct object_grabberGoal_ { typedef object_grabberGoal_<ContainerAllocator> Type; object_grabberGoal_() : action_code(0) , object_id(0) , grasp_option(0) , approach_strategy(0) , lift_object_strategy(0) , dropoff_strategy(0) , dropoff_withdraw_strategy(0) , object_frame() , speed_factor(0.0) , gripper_test_params() { } object_grabberGoal_(const ContainerAllocator& _alloc) : action_code(0) , object_id(0) , grasp_option(0) , approach_strategy(0) , lift_object_strategy(0) , dropoff_strategy(0) , dropoff_withdraw_strategy(0) , object_frame(_alloc) , speed_factor(0.0) , gripper_test_params(_alloc) { (void)_alloc; } typedef int32_t _action_code_type; _action_code_type action_code; typedef int32_t _object_id_type; _object_id_type object_id; typedef int32_t _grasp_option_type; _grasp_option_type grasp_option; typedef int32_t _approach_strategy_type; _approach_strategy_type approach_strategy; typedef int32_t _lift_object_strategy_type; _lift_object_strategy_type lift_object_strategy; typedef int32_t _dropoff_strategy_type; _dropoff_strategy_type dropoff_strategy; typedef int32_t _dropoff_withdraw_strategy_type; _dropoff_withdraw_strategy_type dropoff_withdraw_strategy; typedef ::geometry_msgs::PoseStamped_<ContainerAllocator> _object_frame_type; _object_frame_type object_frame; typedef double _speed_factor_type; _speed_factor_type speed_factor; typedef std::vector<double, typename ContainerAllocator::template rebind<double>::other > _gripper_test_params_type; _gripper_test_params_type gripper_test_params; enum { TEST_CODE = 0, MOVE_TO_WAITING_POSE = 1, PLAN_MOVE_TO_GRASP_POSE = 2, PLAN_MOVE_FINE_TO_GRASP_POSE = 3, PLAN_MOVE_OBJECT_JSPACE = 4, PLAN_MOVE_OBJECT_CSPACE = 5, PLAN_MOVE_FINE_OBJECT_CSPACE = 6, PLAN_WITHDRAW_FROM_OBJECT = 7, PLAN_WITHDRAW_FINE_FROM_OBJECT = 8, PLAN_OBJECT_GRASP = 9, CART_MOVE_CURRENT_TO_CART_GOAL = 10, GRAB_OBJECT = 101, DROPOFF_OBJECT = 102, STRADDLE_OBJECT = 103, SET_SPEED_FACTOR = 10, DEFAULT_GRASP_STRATEGY = 0, EXECUTE_PLANNED_MOVE = 100, GRIPPER_PREPARE_GRASP_OBJECT = 20, GRIPPER_GRASP_OBJECT = 21, GRIPPER_RELEASE_OBJECT = 22, GRIPPER_IS_OBJECT_GRASPED = 23, }; typedef boost::shared_ptr< ::object_grabber::object_grabberGoal_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::object_grabber::object_grabberGoal_<ContainerAllocator> const> ConstPtr; }; // struct object_grabberGoal_ typedef ::object_grabber::object_grabberGoal_<std::allocator<void> > object_grabberGoal; typedef boost::shared_ptr< ::object_grabber::object_grabberGoal > object_grabberGoalPtr; typedef boost::shared_ptr< ::object_grabber::object_grabberGoal const> object_grabberGoalConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::object_grabber::object_grabberGoal_<ContainerAllocator> & v) { ros::message_operations::Printer< ::object_grabber::object_grabberGoal_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace object_grabber namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'roscpp': ['/opt/ros/kinetic/share/roscpp/cmake/../msg'], 'actionlib_msgs': ['/opt/ros/kinetic/share/actionlib_msgs/cmake/../msg'], 'arm7dof_traj_as': ['/home/hanbin/ros_ws/devel/share/arm7dof_traj_as/msg'], 'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'actionlib': ['/opt/ros/kinetic/share/actionlib/cmake/../msg'], 'trajectory_msgs': ['/opt/ros/kinetic/share/trajectory_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'baxter_core_msgs': ['/home/hanbin/ros_ws/src/learning_ros_external_pkgs_kinetic/baxter_common/baxter_core_msgs/msg'], 'object_grabber': ['/home/hanbin/ros_ws/devel/share/object_grabber/msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg', '/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'tf': ['/opt/ros/kinetic/share/tf/cmake/../msg'], 'cartesian_planner': ['/home/hanbin/ros_ws/devel/share/cartesian_planner/msg'], 'baxter_trajectory_streamer': ['/home/hanbin/ros_ws/devel/share/baxter_trajectory_streamer/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::object_grabber::object_grabberGoal_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::object_grabber::object_grabberGoal_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::object_grabber::object_grabberGoal_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::object_grabber::object_grabberGoal_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::object_grabber::object_grabberGoal_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::object_grabber::object_grabberGoal_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::object_grabber::object_grabberGoal_<ContainerAllocator> > { static const char* value() { return "be483bfd87df74289719d347ad9709f1"; } static const char* value(const ::object_grabber::object_grabberGoal_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0xbe483bfd87df7428ULL; static const uint64_t static_value2 = 0x9719d347ad9709f1ULL; }; template<class ContainerAllocator> struct DataType< ::object_grabber::object_grabberGoal_<ContainerAllocator> > { static const char* value() { return "object_grabber/object_grabberGoal"; } static const char* value(const ::object_grabber::object_grabberGoal_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::object_grabber::object_grabberGoal_<ContainerAllocator> > { static const char* value() { return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ #object_grabber action message\n\ #pass in an object code and the object's frame (w/rt named frame_id)\n\ #object_grabber will plan approach, grasp and lift of object\n\ #returns codes regarding outcome\n\ \n\ #action codes:\n\ int32 TEST_CODE = 0 #a simple \"ping\" to action server\n\ int32 MOVE_TO_WAITING_POSE = 1 #move to a pose, defined on param server, that is convenient\n\ #e.g., prepared to approach a surface, but out of way of sensors\n\ int32 PLAN_MOVE_TO_GRASP_POSE =2 #expects parameters of current_object_pose, object_ID, grasp_option, approach_option\n\ #must send separate \"grasp\" command to gripper\n\ int32 PLAN_MOVE_FINE_TO_GRASP_POSE =3 #as above, but finer/slower approach motion\n\ int32 PLAN_MOVE_OBJECT_JSPACE =4 #move a grasped object to a destination pose using simple, joint-space move\n\ #expects params: des_object_pose, object_ID, grasp_option (need to know how object is grasped)\n\ int32 PLAN_MOVE_OBJECT_CSPACE = 5 #move a grasped object with Cartesian motion to a desired object pose\n\ #params: des_object_pose, object_ID, grasp_option\n\ int32 PLAN_MOVE_FINE_OBJECT_CSPACE = 6 #as above, but w/ finer, slower motion\n\ \n\ int32 PLAN_WITHDRAW_FROM_OBJECT = 7 #with object grasp released, perform departure from object using specified depart strategy\n\ #params: object_ID, grasp_option, depart_option\n\ int32 PLAN_WITHDRAW_FINE_FROM_OBJECT = 8 #as above, but slower/more precise motion\n\ \n\ int32 PLAN_OBJECT_GRASP = 9 #combine multiple elements above to acquire an object\n\ \n\ int32 CART_MOVE_CURRENT_TO_CART_GOAL = 10 #plan and execute a move from current pose to a cartesian goal, to be specified in \"geometry_msgs/PoseStamped object_frame\"\n\ \n\ int32 GRAB_OBJECT = 101 #plan and attempt to execute object acquisition, including grasp and lift\n\ int32 DROPOFF_OBJECT = 102 #plan and attempt to execute object placement and arm withdrawal\n\ int32 STRADDLE_OBJECT = 103 #plan and attempt to execute part of GRAB_OBJECT: move to grasp pose, then halt\n\ \n\ int32 SET_SPEED_FACTOR = 10 #use arg speed_factor to change time scale of trajectory plan; larger than 1.0--> slower\n\ \n\ #manipulation strategy options:\n\ int32 DEFAULT_GRASP_STRATEGY = 0\n\ #has corresponding default approach and depart strategies\n\ \n\ int32 EXECUTE_PLANNED_MOVE = 100 #accept arm-motion plan and enable its execution\n\ \n\ #generalized gripper commands:\n\ int32 GRIPPER_PREPARE_GRASP_OBJECT = 20 #may require gripper to prepare for grasp approach, e.g. open fingers\n\ int32 GRIPPER_GRASP_OBJECT = 21 #command to perform appropriate action to grasp object, \n\ #assumes gripper is in appropriate pose, prepared to grasp object\n\ #client does not need to know what type of gripper is used\n\ int32 GRIPPER_RELEASE_OBJECT = 22 #command to gripper to release a grasped object\n\ #params: object ID and grasp option used; \n\ int32 GRIPPER_IS_OBJECT_GRASPED = 23 #a query; may require object_ID, grasp option used, and/or corresponding grasp test parameters; \n\ #should return true/false\n\ \n\ #goal:\n\ int32 action_code\n\ int32 object_id\n\ int32 grasp_option\n\ int32 approach_strategy\n\ int32 lift_object_strategy\n\ int32 dropoff_strategy\n\ int32 dropoff_withdraw_strategy\n\ geometry_msgs/PoseStamped object_frame #should be w/rt system_ref_frame, or have tf to this frame available\n\ float64 speed_factor #default to 1.0\n\ float64[] gripper_test_params\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/PoseStamped\n\ # A Pose with reference coordinate frame and timestamp\n\ Header header\n\ Pose pose\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Pose\n\ # A representation of pose in free space, composed of position and orientation. \n\ Point position\n\ Quaternion orientation\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Point\n\ # This contains the position of a point in free space\n\ float64 x\n\ float64 y\n\ float64 z\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Quaternion\n\ # This represents an orientation in free space in quaternion form.\n\ \n\ float64 x\n\ float64 y\n\ float64 z\n\ float64 w\n\ "; } static const char* value(const ::object_grabber::object_grabberGoal_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::object_grabber::object_grabberGoal_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.action_code); stream.next(m.object_id); stream.next(m.grasp_option); stream.next(m.approach_strategy); stream.next(m.lift_object_strategy); stream.next(m.dropoff_strategy); stream.next(m.dropoff_withdraw_strategy); stream.next(m.object_frame); stream.next(m.speed_factor); stream.next(m.gripper_test_params); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct object_grabberGoal_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::object_grabber::object_grabberGoal_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::object_grabber::object_grabberGoal_<ContainerAllocator>& v) { s << indent << "action_code: "; Printer<int32_t>::stream(s, indent + " ", v.action_code); s << indent << "object_id: "; Printer<int32_t>::stream(s, indent + " ", v.object_id); s << indent << "grasp_option: "; Printer<int32_t>::stream(s, indent + " ", v.grasp_option); s << indent << "approach_strategy: "; Printer<int32_t>::stream(s, indent + " ", v.approach_strategy); s << indent << "lift_object_strategy: "; Printer<int32_t>::stream(s, indent + " ", v.lift_object_strategy); s << indent << "dropoff_strategy: "; Printer<int32_t>::stream(s, indent + " ", v.dropoff_strategy); s << indent << "dropoff_withdraw_strategy: "; Printer<int32_t>::stream(s, indent + " ", v.dropoff_withdraw_strategy); s << indent << "object_frame: "; s << std::endl; Printer< ::geometry_msgs::PoseStamped_<ContainerAllocator> >::stream(s, indent + " ", v.object_frame); s << indent << "speed_factor: "; Printer<double>::stream(s, indent + " ", v.speed_factor); s << indent << "gripper_test_params[]" << std::endl; for (size_t i = 0; i < v.gripper_test_params.size(); ++i) { s << indent << " gripper_test_params[" << i << "]: "; Printer<double>::stream(s, indent + " ", v.gripper_test_params[i]); } } }; } // namespace message_operations } // namespace ros #endif // OBJECT_GRABBER_MESSAGE_OBJECT_GRABBERGOAL_H
2224cc7c182438052dcb9613c76a02d49bb4ac31
c0caed81b5b3e1498cbca4c1627513c456908e38
/src/numeric/xyz.json.hh
22ee127eca134d22411d61a8106b01c7c17bab98
[]
no_license
malaifa/source
5b34ac0a4e7777265b291fc824da8837ecc3ee84
fc0af245885de0fb82e0a1144422796a6674aeae
refs/heads/master
2021-01-19T22:10:22.942155
2017-04-19T14:13:07
2017-04-19T14:13:07
88,761,668
0
2
null
null
null
null
UTF-8
C++
false
false
1,495
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington UW TechTransfer, email: [email protected]. /// @file src/numeric/xyz.json.hh /// @author Sam DeLuca #ifndef INCLUDED_numeric_xyz_json_hh #define INCLUDED_numeric_xyz_json_hh #include <numeric/xyzVector.hh> #include <utility/tools/make_vector.hh> #include <utility/json_spirit/json_spirit_value.h> namespace numeric { /// @brief Convert vector to a json_spirit Value /// @note Format is a list in the form [x,y,z] template<typename T> inline utility::json_spirit::Value serialize(xyzVector<T> coords) { utility::json_spirit::Value x(coords.x()); utility::json_spirit::Value y(coords.y()); utility::json_spirit::Value z(coords.z()); return utility::json_spirit::Value(utility::tools::make_vector(x,y,z)); } template<typename T> inline xyzVector<T> deserialize(utility::json_spirit::mArray data) { xyzVector<T> coords; coords.x(data[0].get_value<T>()); coords.y(data[1].get_value<T>()); coords.z(data[2].get_value<T>()); return coords; } } #endif /* XYZ_JSON_HH_ */
a46b017e39599a361b958069c56e1ea0992aeccc
631c85ee48043c076032170fda7b09cc80c9816e
/modAlphaCipher1.cpp
71e4a88c6df6593e3d518318e909774d25a7b97a
[]
no_license
DreamofNik1/Laba_1
29dd37926d81e5fa7306dd734a1961eb98917cdb
68bbeb1093b28cb83ed5d03f517ab5068b398019
refs/heads/main
2023-04-16T15:08:34.595245
2021-04-24T06:54:24
2021-04-24T06:54:24
360,940,398
0
0
null
null
null
null
UTF-8
C++
false
false
2,408
cpp
#include "modAlphaCipher.h" modAlphaCipher::modAlphaCipher(const string& skey) { locale loc("ru_RU.UTF-8"); // русская локаль для корректной смены регистра wstring_convert<codecvt_utf8<wchar_t>, wchar_t> codec; //кодек UTF-8 wstring ws = codec.from_bytes(numAlpha); // перекодируем for (unsigned i=0; i<ws.size(); i++) { alphaNum[ws[i]]=i; } key = convert(skey); } string modAlphaCipher::encrypt(const string& open_text) { vector<int> work = convert(open_text); for(unsigned i=0; i < work.size(); i++) { work[i] = (work[i] + key[i % key.size()]) % alphaNum.size(); } return convert(work); } string modAlphaCipher::decrypt(const string& cipher_text) { vector<int> work = convert(cipher_text); for(unsigned i=0; i < work.size(); i++) { work[i] = (work[i] + alphaNum.size() - key[i % key.size()]) % alphaNum.size(); } return convert(work); } inline vector<int> modAlphaCipher::convert(const string& s) { vector<int> result; locale loc("ru_RU.UTF-8"); // русская локаль для корректной смены регистра wstring_convert<codecvt_utf8<wchar_t>, wchar_t> codec; //кодек UTF-8 wstring ws = codec.from_bytes(s); // перекодируем for (unsigned i=0; i<ws.size(); i++) { result.push_back(alphaNum[ws[i]]); } return result; } inline string modAlphaCipher::convert(const vector<int>& v) { string result; locale loc("ru_RU.UTF-8"); // русская локаль для корректной смены регистра wstring_convert<codecvt_utf8<wchar_t>, wchar_t> codec; //кодек UTF-8 wstring ws = codec.from_bytes(numAlpha); wstring result_s = codec.from_bytes(""); for (unsigned i=0; i<v.size(); i++) { result_s.push_back(ws[v[i]]); } result = codec.to_bytes(result_s); return result; } std::string result; locale loc("ru_RU.UTF-8"); // русская локаль для корректной смены регистра wstring_convert<codecvt_utf8<wchar_t>, wchar_t> codec; //кодек UTF-8 wstring ws = codec.from_bytes(numAlpha); wstring result_s = codec.from_bytes(""); for (unsigned i=0; i<v.size(); i++) { result_s.push_back(ws[v[i]]); } result = codec.to_bytes(result_s); return result; }
69276240cd3e87b5a75e18129e04615b13655e27
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5631989306621952_1/C++/w93163red/Round_1A_1.cpp
ccc86a19bbae77e738a26d40f35d91627f082782
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
793
cpp
// Round_1A_1.cpp : Defines the entry point for the console application. // //#include "stdafx.h" #include <deque> #include <iostream> #include <string> #include <fstream> using namespace std; int main() { int t; ifstream ifile; ofstream ofile; ofile.open("ans.txt"); ifile.open("A-large.in"); //cin >> t; ifile >> t; for (int n = 1; n <= t; n++) { string str; //cin >> str; ifile >> str; deque<char> q; for (int i = 0; i < str.size(); i++) { if (q.empty()) q.push_back(str[i]); else { if (str[i] >= q.front()) q.push_front(str[i]); else q.push_back(str[i]); } } ofile << "Case #" << n << ": "; for (char c : q) ofile << c; ofile << endl; } return 0; }
097f45c2038a656b07602becf0f8befa11454ff8
4d19de464af38491d69db0c95ed316040fb9960c
/GameEngine/Component.cpp
f9355f45c29f660b1d5f95240cacae84416fa9af
[]
no_license
kravtsovguy/BaseEngine
cdf3011b9b74a40845b6af48f7f559b68ce66ec0
751391ae6b040dfdd71ac207186fb84715775760
refs/heads/master
2021-04-30T16:33:22.253069
2017-02-19T23:51:39
2017-02-19T23:51:39
80,064,505
0
0
null
null
null
null
UTF-8
C++
false
false
174
cpp
// // Component.cpp // GameEngine // // Created by Matvey Kravtsov on 19/01/2017. // Copyright © 2017 Matvey Kravtsov. All rights reserved. // #include "Component.hpp"
42861e371b31ff559a74cc8ba3a3d1755f177559
72328633f1b4640868c2ba7af81adcca6350e7da
/00-每日一题/20200304_102.cpp
15fc7e1407e2fa744e6f4e57427612a01413239b
[]
no_license
qiaozhi827/leetcode-1
a9f10192c74a6de498bce0fa7e1d995bf67edec4
1d1ffe25d8b49832acc1791261c959ce436a6362
refs/heads/master
2022-11-06T19:39:32.792946
2020-07-05T06:23:27
2020-07-05T06:23:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,661
cpp
// // Created by zanbo on 2020/3/4. // #include <vector> #include <stdlib.h> #include <iostream> #include <map> #include <unordered_map> #include <set> #include <queue> #include <stack> #include <algorithm> #include <stdio.h> using namespace std; struct ListNode { int val; ListNode* next; ListNode(int x): val(x),next(NULL){}; }; /** * Definition for a binary tree node. * */ struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: vector<vector<int>> levelOrder(TreeNode* root) { vector<vector<int>> res; if(!root) return res; queue<TreeNode*> q; int curlevel = 1; // 弹出一个节点 值-- 值为0时表示到了下一层 值由nextlevel替换 next置0 int nextlevel = 0; //push一个节点 值++ //先放根结点 q.push(root); vector<int> temp; while(!q.empty()) { TreeNode* tempNode = q.front(); temp.push_back(tempNode->val); if(tempNode->left) { q.push(tempNode->left); nextlevel++; } if(tempNode->right) { q.push(tempNode->right); nextlevel++; } q.pop(); curlevel--; if(curlevel==0) { //先把前一层放入结果集 再清空temp res.push_back(temp); temp.clear(); curlevel = nextlevel; nextlevel=0; } } return res; } };
048fbad45863f3a946c81bb753d2750d6b11f2fc
94e5a9e157d3520374d95c43fe6fec97f1fc3c9b
/Codeforces/EDU 38/C.cpp
f8a5a83dcf32f9bfacb46c0b662b5a425aeddd86
[ "MIT" ]
permissive
dipta007/Competitive-Programming
0127c550ad523884a84eb3ea333d08de8b4ba528
998d47f08984703c5b415b98365ddbc84ad289c4
refs/heads/master
2021-01-21T14:06:40.082553
2020-07-06T17:40:46
2020-07-06T17:40:46
54,851,014
8
4
null
2020-05-02T13:14:41
2016-03-27T22:30:02
C++
UTF-8
C++
false
false
5,155
cpp
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <iomanip> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using namespace std; const double EPS = 1e-9; const int INF = 0x7f7f7f7f; const double PI=acos(-1.0); #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) #define MP(x, y) make_pair(x, y) #define PB(x) push_back(x) #define rep(i,n) for(int i = 1 ; i<=(n) ; i++) #define repI(i,n) for(int i = 0 ; i<(n) ; i++) #define FOR(i,L,R) for (int i = (int)(L); i <= (int)(R); i++) #define ROF(i,L,R) for (int i = (int)(L); i >= (int)(R); i--) #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define ALL(p) p.begin(),p.end() #define ALLR(p) p.rbegin(),p.rend() #define SET(p) memset(p, -1, sizeof(p)) #define CLR(p) memset(p, 0, sizeof(p)) #define MEM(p, v) memset(p, v, sizeof(p)) #define getI(a) scanf("%d", &a) #define getII(a,b) scanf("%d%d", &a, &b) #define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c) #define getL(a) scanf("%lld",&a) #define getLL(a,b) scanf("%lld%lld",&a,&b) #define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define getC(n) scanf("%c",&n) #define getF(n) scanf("%lf",&n) #define getS(n) scanf("%s",n) #define bitCheck(N,in) ((bool)(N&(1<<(in)))) #define bitOff(N,in) (N&(~(1<<(in)))) #define bitOn(N,in) (N|(1<<(in))) #define bitFlip(a,k) (a^(1<<(k))) #define bitCount(a) __builtin_popcount(a) #define bitCountLL(a) __builtin_popcountll(a) #define bitLeftMost(a) (63-__builtin_clzll((a))) #define bitRightMost(a) (__builtin_ctzll(a)) #define iseq(a,b) (fabs(a-b)<EPS) #define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end()) #define vi vector < int > #define vii vector < vector < int > > #define pii pair< int, int > #define ff first #define ss second #define ll long long #define ull unsigned long long #define POPCOUNT __builtin_popcount #define POPCOUNTLL __builtin_popcountll #define RIGHTMOST __builtin_ctzll #define LEFTMOST(x) (63-__builtin_clzll((x))) template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); } template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); } template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); } #define dipta00 #ifdef dipta007 #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;} #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::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 debug(args...) /// Just strip off all debug tokens #define trace(...) ///yeeeee #endif struct debugger{ template<typename T> debugger& operator , (const T& v){ cerr<<v<<" "; return *this; } }dbg; ///****************** template ends here **************** // g++ -g -O2 -std=gnu++11 A.cpp // ./a.out int main() { #ifdef dipta007 //READ("in.txt"); //WRITE("out.txt"); #endif // dipta007 // ios_base::sync_with_stdio(0);cin.tie(0); int t; getI(t); FOR(ci,1,t) { ll n; getL(n); ll in = 1; while(in*in < n) in++; //debug(in) int flg = 0; for(ll i=in,k=1; k<=10000;i++, k++) { //if(i==100000) debug(i, i*i); ll low = 0, high = i; ll res = -1; while(low <= high) { ll mid = (low + high) / 2; ll baki = i*i - (floor((double)i/mid) * floor((double)i/mid)); if(baki == n) { res = mid; break; } else if(baki < n) { low = mid + 1; } else high = mid - 1; } if(res != -1) { flg = 1; printf("%lld %lld\n", i, res); break; } } if(flg == 0) printf("-1\n"); } return 0; }
38a8a0625cf89c393ec93a903f5ba9aa11ec8e6c
405c7cedaa2d962d086999946fddbde0753a0951
/tair/common/file_list_factory.hpp
c47167c35757ba72b68a5b7f14d91dfcdc427e30
[]
no_license
yinguoliang/tb-common-utils
5426483d968b97560eaa071ccf0afb0e2936b03d
a81f09426bb23d4b339473263062501d04e7ca7a
refs/heads/master
2021-01-16T21:24:35.029942
2017-08-25T05:21:16
2017-08-25T05:21:16
100,228,228
0
0
null
null
null
null
UTF-8
C++
false
false
5,829
hpp
/* * (C) 2007-2010 Alibaba Group Holding Limited * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * * save or load rec from seq file. * * */ #ifndef TAIR_FILE_LIST_FACTORY_H #define TAIR_FILE_LIST_FACTORY_H #include <stdint.h> #include <ext/hash_map> #include <tbsys.h> #include <tbnet.h> #include "file_op.hpp" #include "define.hpp" #include "log.hpp" namespace tair{ namespace common{ #define LOG_RECORD_HEAD_SIZE 0 #define LOG_RECORD_SIZE 1024 template <class T> class RecordLogFile { public: RecordLogFile(); ~RecordLogFile(); public: bool start(const std::string& file_name,bool try_replay=true); bool check_init(); bool clear(); public: int append(T* value); bool get(T& value); bool get(unsigned int index,T& value); bool batch_get(unsigned int max_count,std::vector<T *>& _item_vector); uint64_t get_count(); private: tair::common::FileOperation* file_; int64_t file_offset_; int last_read_index; }; template <class T> RecordLogFile<T>::RecordLogFile():file_(NULL),file_offset_(0),last_read_index(0) { } template <class T> bool RecordLogFile<T>::start(const std::string& name,bool try_replay) { if(name.size()<=0) return false; if (file_ !=NULL) { log_warn("RecordLogFile already init, filename: %s", file_->get_file_name()); return true; } bool need_new_log = !try_replay || ::access(name.c_str(), F_OK) != 0; file_ = new tair::common::FileOperation(name); if (file_->open_file() < 0) { log_error("open log file %s fail, error: %s", name.c_str(), strerror(errno)); return false; } log_debug("open log file %s", name.c_str()); //check file size and rescure the log file. if(!need_new_log) { file_offset_=get_count()*LOG_RECORD_SIZE; }else{ if(0!=file_->ftruncate_file(0)) { log_error("ftruncate_file file %s failed.", name.c_str()); return false; } } return true; } template <class T> RecordLogFile<T>::~RecordLogFile() { if (!file_ ) delete file_; } template <class T> bool RecordLogFile<T>::check_init() { return file_ != NULL; } template <class T> int RecordLogFile<T>::append(T* value) { if (!check_init()) return TAIR_RETURN_REMOTE_NOTINIT; tbnet::DataBuffer _output; _output.ensureFree(LOG_RECORD_SIZE); value->encode(&_output); int32_t write_len = file_->pwrite_file(_output.getData(),LOG_RECORD_SIZE, file_offset_); if (write_len != LOG_RECORD_SIZE) { log_error("add record fail, write fail. ret: %d", write_len); return TAIR_RETURN_REMOTE_DISKSAVE_FAILED; } else { file_offset_ += LOG_RECORD_SIZE; } return 0; } template <class T> bool RecordLogFile<T>::get(T& value) { return get(last_read_index++,value); } //if(!pnew_node) pnew_node= new request_sync(); template <class T> bool RecordLogFile<T>::batch_get(unsigned int max_count,std::vector<T *>& _item_vector) { if(!check_init()) return false; int64_t offset=LOG_RECORD_SIZE*last_read_index; char * puffer= new char[LOG_RECORD_SIZE*max_count]; int32_t read_len=file_->pread_file(puffer,LOG_RECORD_SIZE * max_count, offset); if(read_len<LOG_RECORD_SIZE) { log_error("read logfile faild. read_len: %d", read_len); delete [] puffer; return false; } int _count=read_len/LOG_RECORD_SIZE; last_read_index+=_count; for(int i=0;i<_count;i++) { tbnet::DataBuffer _input; _input.ensureFree(LOG_RECORD_SIZE); memcpy(_input.getFree(),puffer+i*LOG_RECORD_SIZE,_input.getFreeLen()); _input.pourData(LOG_RECORD_SIZE); T *value =new T; if(value->decode(&_input)) { _item_vector.push_back(value); } else { delete value; value=NULL; } } delete [] puffer; return true; } template <class T> bool RecordLogFile<T>::get(unsigned int index,T& value) { if(!check_init()) return false; uint32_t record_count = get_count(); if (record_count <=0 || record_count<index) { log_error("get index out of range,file %s is invalid", file_->get_file_name()); return false; } //read one. tbnet::DataBuffer _input; _input.ensureFree(LOG_RECORD_SIZE); int32_t read_len = 0; int64_t offset= LOG_RECORD_SIZE* index; if ((read_len = file_->pread_file(_input.getFree(), LOG_RECORD_SIZE, offset)) != LOG_RECORD_SIZE ) { log_error("read logfile faild. read_len: %d", read_len); return false; } _input.pourData(read_len); value.decode(&_input); return true; } template <class T> uint64_t RecordLogFile<T>::get_count() { //must return 0 or uint64_t if (!check_init()) return 0; int32_t count = 0; int64_t file_size = file_->get_file_size(); if (file_size <= 0) { log_debug("get log file size=%d, ignore",file_size); count = 0; } else { if ((file_size ) % LOG_RECORD_SIZE != 0) { log_error("gc log file maybe conflict. filesize: %"PRI64_PREFIX"d, replay most", file_size); } count = (file_size)/LOG_RECORD_SIZE; } log_info("record file size: %"PRI64_PREFIX"d, record count: %d,last_read_index=%d", file_size, count,last_read_index); return count; } template <class T> bool RecordLogFile<T>::clear() { log_info("now clear record file,offset=%"PRI64_PREFIX"d,read_index=%d",file_offset_,last_read_index); file_offset_=0; last_read_index=0; return 0==file_->ftruncate_file(0); } } } #endif
e20a918f97e0a5e17d068e293c907f87553952da
17fd3c3da5e03b7daabe50099ac3bf42acdbcf14
/tests/UTCommon.h
ecca608e2e95b4d851498ece30084b79097bb801
[ "MIT" ]
permissive
fossabot/tarm-io
508ba8ffed089145509df3bfec638cb577923300
e91d4f0f61a841f1adea545afa27a226ac51f6b1
refs/heads/master
2022-10-29T14:37:15.860720
2020-06-10T17:21:48
2020-06-10T17:21:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
285
h
#pragma once #include "LogRedirector.h" #include <gtest/gtest.h> #include <boost/filesystem.hpp> #ifdef GTEST_SKIP #define IO_TEST_SKIP() GTEST_SKIP() #else #define IO_TEST_SKIP() return #endif std::string create_temp_test_directory(); boost::filesystem::path exe_path();
381d192d11487f6eb9ac8a589f83b2ae8644d277
e98e505de1a1a3542189125ef4bdde147f9c77cd
/chrome/browser/safe_browsing/incident_reporting/module_load_analyzer_win_unittest.cc
834ce4f95ebc0dd4461cc0698a076a60cf10687a
[ "BSD-3-Clause" ]
permissive
jesonlay/chromium
b98fca219ab71d230df9a758252058a18e075a06
292532fedbb55d68a83b46c106fd04849a47571d
refs/heads/master
2022-12-16T15:25:13.723395
2017-03-20T14:36:34
2017-03-20T15:37:49
158,929,892
0
0
NOASSERTION
2018-11-24T11:32:20
2018-11-24T11:32:19
null
UTF-8
C++
false
false
4,502
cc
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/safe_browsing/incident_reporting/module_load_analyzer.h" #include <string> #include "base/files/file_path.h" #include "base/memory/ptr_util.h" #include "base/memory/scoped_vector.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/scoped_native_library.h" #include "base/strings/string_util.h" #include "chrome/browser/safe_browsing/incident_reporting/incident.h" #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" #include "chrome/browser/safe_browsing/incident_reporting/mock_incident_receiver.h" #include "components/safe_browsing/csd.pb.h" #include "components/safe_browsing_db/database_manager.h" #include "components/safe_browsing_db/test_database_manager.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::Return; using ::testing::StrictMock; using ::testing::_; namespace safe_browsing { namespace { const char kWhitelistedModuleName[] = "USER32.dll"; const char kNonWhitelistedModuleName[] = "blacklist_test_dll_1.dll"; class MockSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager { public: MockSafeBrowsingDatabaseManager() {} MOCK_METHOD1(MatchModuleWhitelistString, bool(const std::string&)); private: ~MockSafeBrowsingDatabaseManager() override {} DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingDatabaseManager); }; class ModuleLoadAnalayzerTest : public testing::Test { protected: ModuleLoadAnalayzerTest() : mock_incident_receiver_( new StrictMock<safe_browsing::MockIncidentReceiver>()), mock_safe_browsing_database_manager_( new MockSafeBrowsingDatabaseManager()) { // Accept all dlls except kNonWhitelistedModuleName. EXPECT_CALL(*mock_safe_browsing_database_manager_, MatchModuleWhitelistString(_)) .WillRepeatedly(Return(true)); } void ExpectIncident(const std::string& module_to_load) { base::FilePath current_dir; ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir)); base::ScopedNativeLibrary dll1(current_dir.AppendASCII(module_to_load)); std::unique_ptr<Incident> incident; EXPECT_CALL(*mock_incident_receiver_, DoAddIncidentForProcess(_)) .WillOnce(TakeIncident(&incident)); VerifyModuleLoadState(mock_safe_browsing_database_manager_, base::WrapUnique(mock_incident_receiver_)); base::RunLoop().RunUntilIdle(); content::RunAllBlockingPoolTasksUntilIdle(); ASSERT_TRUE(incident); std::unique_ptr<ClientIncidentReport_IncidentData> incident_data = incident->TakePayload(); ASSERT_TRUE(incident_data->has_suspicious_module()); const ClientIncidentReport_IncidentData_SuspiciousModuleIncident& suspicious_module_incident = incident_data->suspicious_module(); EXPECT_TRUE(suspicious_module_incident.has_digest()); EXPECT_TRUE(base::EndsWith(suspicious_module_incident.path(), module_to_load, base::CompareCase::SENSITIVE)); } void ExpectNoIncident(const std::string& module_to_load) { base::FilePath current_dir; ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir)); base::ScopedNativeLibrary dll1(current_dir.AppendASCII(module_to_load)); EXPECT_CALL(*mock_incident_receiver_, DoAddIncidentForProcess(_)).Times(0); VerifyModuleLoadState(mock_safe_browsing_database_manager_, base::WrapUnique(mock_incident_receiver_)); base::RunLoop().RunUntilIdle(); content::RunAllBlockingPoolTasksUntilIdle(); } content::TestBrowserThreadBundle browser_thread_bundle_; StrictMock<safe_browsing::MockIncidentReceiver>* mock_incident_receiver_; scoped_refptr<MockSafeBrowsingDatabaseManager> mock_safe_browsing_database_manager_; }; } // namespace TEST_F(ModuleLoadAnalayzerTest, TestWhitelistedDLLs) { ExpectNoIncident(kWhitelistedModuleName); } TEST_F(ModuleLoadAnalayzerTest, TestNonWhitelistedDLLs) { EXPECT_CALL(*mock_safe_browsing_database_manager_, MatchModuleWhitelistString(kNonWhitelistedModuleName)) .WillOnce(Return(false)); ExpectIncident(kNonWhitelistedModuleName); } } // namespace safe_browsing
d09991ddbd900f493533480c0d8262f4de85c6a4
34304ccfcbe4e6df9fa0cfcd9b824767a1d00099
/trashbin/try-consensus/src/test_paxos.cc
6d633e5871af07d02a32e768bafd9a527f806f6e
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
xanpeng/snippets
91ecf798f842544e5bc6b0cddaca470c4c33fd21
e7d3cfaa333c72118eede11e6922725cc525cb0f
refs/heads/master
2021-01-16T23:47:31.668918
2020-04-16T16:03:46
2020-04-16T16:03:46
17,583,682
5
2
null
null
null
null
UTF-8
C++
false
false
18,606
cc
/* * Copyright (C) 2011 Colin Patrick McCabe <[email protected]> * * This is licensed under the Apache License, Version 2.0. See file COPYING. */ #include "limits.h" #include "util.h" #include "worker.h" #include <muduo/base/Logging.h> #include <errno.h> #include <semaphore.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /************************ constants ********************************/ enum { MMM_DO_PROPOSE = 2000, MMM_DO_TIMEOUT, MMM_PROPOSE = 3000, MMM_REJECT, MMM_ACCEPT, MMM_COMMIT, MMM_COMMIT_RESP, }; enum node_state { NODE_STATE_INIT = 0, NODE_STATE_PROPOSING, NODE_STATE_COMMITTING, }; enum remote_state { REMOTE_STATE_NO_RESP = 0, REMOTE_STATE_FAILED, REMOTE_STATE_ACCEPTED, REMOTE_STATE_REJECTED, }; /************************ types ********************************/ struct node_data { /** node id */ int id; /** current node state */ enum node_state state; /** Perceived state of remote nodes */ uint8_t remotes[MAX_ACCEPTORS]; /** The highest paxos sequence number we've seen so far */ uint64_t seen_pseq; /** In NODE_STATE_PROPOSING, the paxos sequence number we are currently * proposing */ uint64_t prop_pseq; /** The highest leader we've accept yet, or -1 if none has been proposed */ int prop_leader; /** who we believe is the current leader, or -1 if there is none */ int leader; }; struct mmm_do_propose { struct worker_msg base; }; struct mmm_do_timeout { struct worker_msg base; uint64_t prop_pseq; }; struct mmm_propose { struct worker_msg base; /** ID of sender */ int src; /** The value being proposed */ int prop_leader; /** Paxos sequence ID of this propsal */ uint64_t prop_pseq; }; struct mmm_resp { struct worker_msg base; /** ID of sender */ int src; /** Value of the highest-numbered proposal that this node has already * accepted */ int leader; }; struct mmm_reject { struct worker_msg base; /** ID of sender */ int src; /** Sequence number of the highest proposal we've seen */ uint64_t seen_pseq; }; struct mmm_accept { struct worker_msg base; /** ID of sender */ int src; /** The leader that we are accepting */ int prop_leader; /** The sequence number of the coordinator from which we heard this * prop_leader */ uint64_t seen_pseq; }; struct mmm_commit { struct worker_msg base; /** ID of sender */ int src; /** The value to commit */ int prop_leader; /** Paxos sequence ID of this propsal */ uint64_t prop_pseq; }; struct mmm_commit_resp { struct worker_msg base; /** ID of sender */ int src; /** nonzero if this is an affirmative response */ int ack; /** Paxos sequence ID of the commit propsal we're responding to */ uint64_t prop_pseq; }; /************************ globals ********************************/ /** enable debugging spew */ static int g_verbose; /** acceptor nodes */ static struct worker *g_nodes[MAX_ACCEPTORS]; /** acceptor node data */ static struct node_data g_node_data[MAX_ACCEPTORS]; /** number of acceptors */ static int g_num_nodes; static sem_t g_sem_accept_leader; /** True if acceptors are running */ static int g_start; /** Lock that protects g_start */ pthread_mutex_t g_start_lock; /** Condition variable associated with g_start */ pthread_cond_t g_start_cond; /************************ functions ********************************/ static const char *msg_type_to_str(int ty) { switch (ty) { case MMM_DO_PROPOSE: return "MMM_DO_PROPOSE"; case MMM_DO_TIMEOUT: return "MMM_DO_TIMEOUT"; case MMM_PROPOSE: return "MMM_PROPOSE"; case MMM_REJECT: return "MMM_REJECT"; case MMM_ACCEPT: return "MMM_ACCEPT"; case MMM_COMMIT: return "MMM_COMMIT"; case MMM_COMMIT_RESP: return "MMM_COMMIT_RESP"; default: return "(unknown)"; } } static int node_is_dead(struct node_data *me, int id) { if (id < 0) return 1; return me->remotes[id] == REMOTE_STATE_FAILED; } static uint64_t outbid(uint64_t pseq, int id) { uint64_t tmp; tmp = pseq >> 8; tmp++; tmp <<= 8; if (id > 0xff) abort(); return tmp | id; } static void reset_remotes(uint8_t *remotes) { int i; for (i = 0; i < g_num_nodes; ++i) { switch (remotes[i]) { case REMOTE_STATE_ACCEPTED: case REMOTE_STATE_REJECTED: remotes[i] = REMOTE_STATE_NO_RESP; } } } static int check_acceptor_resp(const struct node_data *me, int ty, int src) { if (me->state != NODE_STATE_PROPOSING) { if (g_verbose) { LOG_DEBUG << me->id << ": got " << msg_type_to_str(ty) << " message from " << src << ", but we are not proposing."; } return 1; } if (me->remotes[src] != REMOTE_STATE_NO_RESP) { LOG_DEBUG << me->id << ": got " << msg_type_to_str(ty) << " message from " << src << ", but remote_state for that node is already " << me->remotes[src]; return 1; } return 0; } static int have_majority_of_acceptors(const struct node_data *me) { int i, num_acc; num_acc = 0; for (i = 0; i < g_num_nodes; ++i) { if (me->remotes[i] == REMOTE_STATE_ACCEPTED) num_acc++; } return (num_acc > (g_num_nodes / 2)); } static int cannot_have_majority_of_acceptors(const struct node_data *me) { int i, num_rej; num_rej = 0; for (i = 0; i < g_num_nodes; ++i) { if (me->remotes[i] == REMOTE_STATE_REJECTED) num_rej++; } return (num_rej >= (g_num_nodes / 2)); } static void send_delayed_do_propose(struct node_data *me) { struct mmm_do_propose *mdop; int delay; mdop = static_cast<mmm_do_propose*>(xcalloc(1, sizeof(struct mmm_do_propose))); mdop->base.ty = static_cast<worker_msg_ty>(MMM_DO_PROPOSE); delay = random() % 100; worker_sendmsg_deferred_ms(g_nodes[me->id], mdop, delay); } static void send_do_propose(int node_id) { struct mmm_do_propose *mdop; mdop = static_cast<mmm_do_propose*>(xcalloc(1, sizeof(struct mmm_do_propose))); mdop->base.ty = static_cast<worker_msg_ty>(MMM_DO_PROPOSE); worker_sendmsg_or_free(g_nodes[node_id], mdop); } static void send_commits(struct node_data *me) { int i; for (i = 0; i < g_num_nodes; ++i) { struct mmm_commit *mcom; if (i == me->id) continue; mcom = static_cast<mmm_commit*>(xcalloc(1, sizeof(struct mmm_commit))); mcom->base.ty = static_cast<worker_msg_ty>(MMM_COMMIT); mcom->src = me->id; mcom->prop_leader = me->prop_leader; mcom->prop_pseq = me->prop_pseq; if (g_verbose) { LOG_DEBUG << me->id << ": sending COMMIT (prop_leader=" << mcom->prop_leader << ", prop_pseq=0x" << std::hex << mcom->prop_pseq << " message to " << i; } if (worker_sendmsg_or_free(g_nodes[i], mcom)) { LOG_DEBUG << me->id << ": declaring node " << i << " as failed"; me->remotes[i] = REMOTE_STATE_FAILED; } else { me->remotes[i] = REMOTE_STATE_NO_RESP; } } } static int check_commit_resp(const struct node_data *me, const struct mmm_commit_resp *mresp) { if (me->state != NODE_STATE_COMMITTING) { if (g_verbose) { LOG_DEBUG << me->id << ": got MMM_COMMIT_RESP from " << mresp->src << ", but we are not commiting anymore."; } return 1; } if (mresp->prop_pseq != me->prop_pseq) { if (g_verbose) { LOG_DEBUG << me->id << ": got MMM_COMMIT_RESP from " << mresp->src << ", but mresp->prop_pseq is 0x" << std::hex << mresp->prop_pseq << ", not 0x" << me->prop_pseq; } return 1; } return 0; } static void accept_leader(struct node_data *me, int leader) { me->prop_leader = leader; me->leader = leader; sem_post(&g_sem_accept_leader); me->state = NODE_STATE_INIT; if (g_verbose) { LOG_DEBUG << me->id << ": accepted leader " << leader; } } static void abandon_proposal(struct node_data *me, const char *why) { if (g_verbose) { LOG_DEBUG << me->id << ": abandoning proposal 0x" << std::hex << me->prop_pseq << " " << why; } me->prop_pseq = -1; me->state = NODE_STATE_INIT; reset_remotes(me->remotes); /* Wait a bit, then try to propose ourselves as the * leader again. */ send_delayed_do_propose(me); } static int paxos_handle_msg(struct worker_msg *m, void *v) { struct node_data *me = (struct node_data*)v; struct mmm_propose *mprop; struct mmm_do_timeout *mtimeo; struct mmm_accept *macc; struct mmm_reject *mrej; struct mmm_commit *mcom; struct mmm_commit_resp *mresp; int i; pthread_mutex_lock(&g_start_lock); while (g_start == 0) pthread_cond_wait(&g_start_cond, &g_start_lock); pthread_mutex_unlock(&g_start_lock); switch (m->ty) { case MMM_DO_PROPOSE: if ((me->state != NODE_STATE_INIT) || !node_is_dead(me, me->leader)) { if (g_verbose) { LOG_DEBUG << me->id << ": ignoring do_propose"; } break; } reset_remotes(me->remotes); me->prop_pseq = me->seen_pseq = outbid(me->seen_pseq, me->id); me->prop_leader = me->id; for (i = 0; i < g_num_nodes; ++i) { if (i == me->id) continue; mprop = static_cast<mmm_propose*>(xcalloc(1, sizeof(struct mmm_propose))); mprop->base.ty = static_cast<worker_msg_ty>(MMM_PROPOSE); mprop->src = me->id; mprop->prop_leader = me->id; mprop->prop_pseq = me->prop_pseq; if (worker_sendmsg_or_free(g_nodes[i], mprop)) { LOG_DEBUG << me->id << ": declaring node " << i << " as failed"; me->remotes[i] = REMOTE_STATE_FAILED; } else { if (g_verbose) { LOG_DEBUG << me->id << ": sent MMM_PROPOSE to node " << i; } me->remotes[i] = REMOTE_STATE_NO_RESP; } } mtimeo = static_cast<mmm_do_timeout*>(xcalloc(1, sizeof(struct mmm_do_timeout))); mtimeo->base.ty = static_cast<worker_msg_ty>(MMM_DO_TIMEOUT); mtimeo->prop_pseq = me->prop_pseq; worker_sendmsg_deferred_ms(g_nodes[me->id], mtimeo, 1000); me->state = NODE_STATE_PROPOSING; break; case MMM_DO_TIMEOUT: mtimeo = (struct mmm_do_timeout*)m; if ((mtimeo->prop_pseq != me->prop_pseq) || (me->state != NODE_STATE_PROPOSING)) { if (g_verbose) { LOG_DEBUG << me->id << ": ignoring timeout for defunct pseq 0x" << std::hex << mtimeo->prop_pseq; } break; } abandon_proposal(me, "because of timeout"); break; case MMM_PROPOSE: mprop = (struct mmm_propose *)m; if ((!node_is_dead(me, me->leader)) || (mprop->prop_pseq <= me->seen_pseq)) { struct mmm_reject *mrej; mrej = static_cast<mmm_reject*>(xcalloc(1, sizeof(struct mmm_reject))); mrej->base.ty = static_cast<worker_msg_ty>(MMM_REJECT); mrej->src = me->id; mrej->seen_pseq = me->seen_pseq; if (worker_sendmsg_or_free(g_nodes[mprop->src], mrej)) { me->remotes[mprop->src] = REMOTE_STATE_FAILED; } if (g_verbose) { LOG_DEBUG << me->id << ": rejected proposal (mprop->leader=" << mprop->prop_leader << ", mprop->seen_pseq=0x" << std::hex << mprop->prop_pseq << " from " << mprop->src << "(me->leader=" << me->leader << ", me->seen_pseq=0x" << std::hex << me->seen_pseq << ")"; } } else { macc = static_cast<mmm_accept*>(xcalloc(1, sizeof(struct mmm_accept))); if (me->prop_leader == -1) { macc->prop_leader = -1; macc->seen_pseq = 0; } else { macc->prop_leader = me->prop_leader; macc->seen_pseq = me->seen_pseq; } me->prop_leader = mprop->prop_leader; me->seen_pseq = mprop->prop_pseq; macc->base.ty = static_cast<worker_msg_ty>(MMM_ACCEPT); macc->src = me->id; if (worker_sendmsg_or_free(g_nodes[mprop->src], macc)) { me->remotes[mprop->src] = REMOTE_STATE_FAILED; } if (me->state != NODE_STATE_INIT) { if (g_verbose) { LOG_DEBUG << me->id << ": giving up on proposing because node " << mprop->src << " had a proposal with a higher sequence number"; } me->state = NODE_STATE_INIT; } } break; case MMM_ACCEPT: macc = (struct mmm_accept *)m; if (check_acceptor_resp(me, MMM_ACCEPT, macc->src)) break; if (g_verbose) { LOG_DEBUG << me->id << ": got MMM_ACCEPT(prop_leader=" << macc->prop_leader << ") from " << macc->src; } me->remotes[macc->src] = REMOTE_STATE_ACCEPTED; if (!have_majority_of_acceptors(me)) break; send_commits(me); me->state = NODE_STATE_COMMITTING; break; case MMM_REJECT: mrej = (struct mmm_reject *)m; if (check_acceptor_resp(me, MMM_REJECT, mrej->src)) break; if (g_verbose) { LOG_DEBUG << me->id << ": got MMM_REJECT(seen_pseq=0x" << std::hex << mrej->seen_pseq << ") from " << mrej->src; } me->remotes[mrej->src] = REMOTE_STATE_REJECTED; if (cannot_have_majority_of_acceptors(me)) abandon_proposal(me, " because of too much rejection"); break; case MMM_COMMIT: mcom = (struct mmm_commit*)m; mresp = static_cast<mmm_commit_resp*>(xcalloc(1, sizeof(struct mmm_commit_resp))); mresp->base.ty = static_cast<worker_msg_ty>(MMM_COMMIT_RESP); mresp->src = me->id; mresp->prop_pseq = mcom->prop_pseq; if ((me->state != NODE_STATE_INIT) || (mcom->prop_leader != me->prop_leader) || (mcom->prop_pseq < me->prop_pseq)) { mresp->ack = 0; } else { mresp->ack = 1; accept_leader(me, mcom->prop_leader); } if (g_verbose) { LOG_DEBUG << me->id << ": sending commit " << (mresp->ack ? "ACK" : "NACK") << " back to " << mcom->src; } if (worker_sendmsg_or_free(g_nodes[mcom->src], mresp)) { me->remotes[mcom->src] = REMOTE_STATE_FAILED; } break; case MMM_COMMIT_RESP: mresp = (struct mmm_commit_resp *)m; if (check_commit_resp(me, mresp)) break; if (!mresp->ack) { me->remotes[mresp->src] = REMOTE_STATE_REJECTED; break; } me->remotes[mresp->src] = REMOTE_STATE_ACCEPTED; if (!have_majority_of_acceptors(me)) break; accept_leader(me, me->prop_leader); if (g_verbose) { LOG_DEBUG << me->id << ": considering protocol terminated"; } break; default: LOG_DEBUG << me->id << ": invalid message type " << m->ty; abort(); break; } return 0; } static int check_leaders(void) { int i, leader, conflict; leader = -1; conflict = 0; for (i = 0; i < g_num_nodes; ++i) { if (leader == -1) leader = g_node_data[i].leader; else { if (leader != g_node_data[i].leader) { conflict = 1; } } } if (!conflict) { printf("successfully elected node %d as leader.\n", leader); return 0; } for (i = 0; i < g_num_nodes; ++i) { LOG_DEBUG << i << ": leader=" << g_node_data[i].leader; } return 1; } static int run_paxos(int duelling_proposers) { int i; struct timespec ts; if (sem_init(&g_sem_accept_leader, 0, 0)) abort(); if (pthread_mutex_init(&g_start_lock, 0)) abort(); if (pthread_cond_init(&g_start_cond, 0)) abort(); g_start = 0; memset(g_nodes, 0, sizeof(g_nodes)); memset(g_node_data, 0, sizeof(g_node_data)); for (i = 0; i < g_num_nodes; ++i) { char name[WORKER_NAME_MAX]; snprintf(name, WORKER_NAME_MAX, "node_%3d", i); g_node_data[i].id = i; g_node_data[i].state = NODE_STATE_INIT; reset_remotes(g_node_data[i].remotes); g_node_data[i].seen_pseq = 0; g_node_data[i].prop_pseq = 0; g_node_data[i].prop_leader = -1; g_node_data[i].leader = -1; g_nodes[i] = worker_start(name, paxos_handle_msg, NULL, &g_node_data[i]); if (!g_nodes[i]) { LOG_ERROR << "failed to allocate node " << i; abort(); } } if (g_num_nodes < 3) abort(); send_do_propose(2); if (duelling_proposers) { send_do_propose(0); send_do_propose(1); } /* start acceptors */ pthread_mutex_lock(&g_start_lock); g_start = 1; pthread_cond_broadcast(&g_start_cond); pthread_mutex_unlock(&g_start_lock); /* Wait for consensus. * We only actually need more than half the nodes. However, to make * debugging a little nicer, we'll wait 10 seconds for all the remaining * nodes rather than exiting immediately after we get half. */ for (i = 0; i < 1 + (g_num_nodes / 2); ++i) { TEMP_FAILURE_RETRY(sem_wait(&g_sem_accept_leader)); } if (clock_gettime(CLOCK_REALTIME, &ts) == -1) abort(); ts.tv_sec += 10; for (; i < g_num_nodes; ++i) { TEMP_FAILURE_RETRY(sem_timedwait(&g_sem_accept_leader, &ts)); } /* cleanup */ for (i = 0; i < g_num_nodes; ++i) { worker_stop(g_nodes[i]); } for (i = 0; i < g_num_nodes; ++i) { worker_join(g_nodes[i]); } pthread_cond_destroy(&g_start_cond); g_start = 0; pthread_mutex_destroy(&g_start_lock); sem_destroy(&g_sem_accept_leader); return check_leaders(); } static void usage(const char *argv0, int retcode) { LOG_ERROR << argv0 << ": a consensus protocol demo."; LOG_ERROR << "options:"; LOG_ERROR << "-h: this help message"; LOG_ERROR << "-n <num-nodes> set the number of acceptors" << " (default: " << DEFAULT_NUM_NODES << ")"; LOG_ERROR << "-v enabel verbose debug messages"; exit(retcode); } static void parse_argv(int argc, char **argv) { int c; g_num_nodes = DEFAULT_NUM_NODES; g_verbose = 0; while ((c = getopt(argc, argv, "hn:v")) != -1) { switch (c) { case 'h': usage(argv[0], EXIT_SUCCESS); break; case 'n': g_num_nodes = atoi(optarg); break; case 'v': g_verbose = 1; break; default: LOG_ERROR << "failed to parse argument"; usage(argv[0], EXIT_FAILURE); break; } } if (g_num_nodes < 3) { LOG_ERROR << "num_nodes=" << g_num_nodes << ", but we can't run with num_nodes<3"; usage(argv[0], EXIT_FAILURE); } } int main(int argc, char **argv) { int ret; parse_argv(argc, argv); /* seed random number generator */ srandom(time(NULL)); worker_init(); muduo::Logger::setLogLevel(muduo::Logger::DEBUG); LOG_INFO << "testing single-proposer case..."; ret = run_paxos(0); if (ret) { LOG_ERROR << "run_paxos(0) failed with error code " << ret; return EXIT_FAILURE; } LOG_INFO << "testing multi-proposer case..."; ret = run_paxos(1); if (ret) { LOG_ERROR << "run_paxos(1) failed with error code " << ret; return EXIT_FAILURE; } return EXIT_SUCCESS; }
0cd30a02c411a685eb681ca2cb3eabc85f514f01
83934c40b2bd835464732345fa516b2c657a6259
/RcsPySim/src/cpp/core/observation/OMManipulabilityIndex.h
ddbf9fa80fe84ed193ad1481e63c30db9d4662b9
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
1abner1/SimuRLacra
e0427bf4f2459dcb992206d3b2f347beab68a5b4
d7e9cd191ccb318d5f1e580babc2fc38b5b3675a
refs/heads/master
2023-05-25T04:52:17.917649
2021-06-07T07:26:44
2021-06-07T07:26:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,992
h
/******************************************************************************* Copyright (c) 2020, Fabio Muratore, Honda Research Institute Europe GmbH, and Technical University of Darmstadt. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Fabio Muratore, Honda Research Institute Europe GmbH, or Technical University of Darmstadt, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FABIO MURATORE, HONDA RESEARCH INSTITUTE EUROPE GMBH, OR TECHNICAL UNIVERSITY OF DARMSTADT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #ifndef _OMMANIPULABILITYINDEX_H #define _OMMANIPULABILITYINDEX_H #include "ObservationModel.h" #include "../action/ActionModelIK.h" namespace Rcs { /** * Observes the manipulability index of the graph. */ class OMManipulabilityIndex : public ObservationModel { private: // controller used to compute the manipulability. ControllerBase* controller; // observed graph RcsGraph* observedGraph; public: /** * Create from action model * @param ikModel action model to copy controller tasks from * @param observeCurrent true to observe the current graph instead of the desired graph. */ explicit OMManipulabilityIndex(ActionModelIK* ikModel, bool observeCurrent = false); ~OMManipulabilityIndex() override; unsigned int getStateDim() const override; unsigned int getVelocityDim() const override; void computeObservation(double* state, double* velocity, const MatNd* currentAction, double dt) const override; std::vector<std::string> getStateNames() const override; }; } #endif //_OMMANIPULABILITYINDEX_H
835fcff56f260c552eba254f0673a0bc614bb5fe
c11485499c9b62481dfdfe56fa39374e36876dcd
/build/lua-gameplay/src/Export.h
35432ddd0f8136973101edbaf7ec15f05ffbaae4
[]
no_license
mengtest/TH_Game
92c519f8e83a4bf5bce64edc9fe718a16427555c
f36d0c07571b31a128eae322408c480b6ad1f70a
refs/heads/master
2022-12-09T14:11:54.539133
2020-08-26T16:25:27
2020-08-26T16:25:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,084
h
#pragma once #include <string_view> #include "Actions.h" #include "lua.hpp" struct PlayerS; struct PawnD; struct BuffD; class Combat; namespace Export { //导出给CS的一些api //获取到一个buff的实例对象(展示对象) BuffD* get_buff(int combatId, int buffId); //获取到一个pawn的实例对象(展示对象) PawnD* get_pawn(int combatId, int pawnId); //获取到一个玩家的实例对象(展示对象) PlayerS* get_player(int combatId, int uid); //创建一个房间,返回创建出来的战斗系统实例的id号 int create_combat(); //初始化核心类库 void init(std::string_view root,lua_State* L); //还需要导出两个api给cs去释放以及加载core导出部分的内存 void load_export(); //释放内存 void release_export(); void release_all(); void export_lua(lua_State* L); Config* get_config(); //cpp端的lua栈肯定是唯一的 void* get_lua_state(); void entry_lua(); void lua_init(); void set_update_fun(UpdateAction fun); void set_notice_fun(NoticeFunction fun); Combat* get_combat(int id); }
0cf7df0c6e098dd5c12221d1f8c0a7861e96a793
150936abf1a4ba3c9862631bbe45259256027d76
/Codeforces/Educational/Educational Codeforces Round 79/B. Verse For Santa.cpp
b9c0cce83b1ec3b4e8b2c6b4029f4858bf6a9b6e
[]
no_license
btdat2506/IT.CLA.K18---CP---btdat2506
4a6242c637b28b6126e294f5cb1802b7ea4ea850
3adc76eebf81c799e5f82dfb946752cb65866a55
refs/heads/master
2021-07-04T21:48:13.054696
2020-12-01T15:18:46
2020-12-01T15:18:46
205,774,038
1
1
null
2019-09-05T02:13:13
2019-09-02T04:01:48
C++
UTF-8
C++
false
false
872
cpp
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; #define For(i, a, b) for(ll i = a; i <= b; i++) ll n, s, arr[100010]; void process() { arr[n+1] = 1e12; ll res = 0, id_max = 1; bool removed = 0; For(i, 1, n) { //cộng arr[i] vào, nếu xóa mà vẫn +arr[i+1] được thì xóa, xcòn không thì trả lạilại id_max = (!removed && arr[i] > arr[id_max]) ? i : id_max; res += arr[i]; if (res >= s) { if (!removed && res - arr[id_max] + arr[i+1] <= s) res = res - arr[id_max], removed = 1; else if (removed) break; } } cout << ((removed) ? id_max : 0) << "\n"; } void input() { cin >> n >> s; For(i, 1, n) cin >> arr[i]; } int main() { ios::sync_with_stdio(0); cin.tie(0); freopen("test.in", "r", stdin); freopen("test.ok", "w", stdout); ll t; cin >> t; while(t--) { input(); process(); } }
12cd6ef62781e5cb3ee616680a6771b10dc3f660
3055574eab5cdbb52e5c0ff89c07bf539bf7bef5
/clam/.svn/pristine/12/12cd6ef62781e5cb3ee616680a6771b10dc3f660.svn-base
f2cbcb50a95c6c535ce1f05b1b240115d1fdb751
[]
no_license
royedwards/3rdPartyAudio
e2c46e97e49561d95dc726b0cb7433fcf7097c51
e24250bd2b7167b68d51dcc1e0b914217262b998
refs/heads/master
2020-03-23T16:56:06.816045
2018-08-25T03:11:13
2018-08-25T03:11:13
141,834,203
1
1
null
null
null
null
UTF-8
C++
false
false
6,982
/* * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG) * UNIVERSITAT POMPEU FABRA * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <cstdlib> #include <cstring> #include "LadspaProcessingExporter.hxx" // LADSPA call backs extern "C" { static LADSPA_Handle Instantiate(const struct _LADSPA_Descriptor * descriptor, unsigned long sampleRate) { std::string className = std::string(descriptor->Name).substr(5); CLAM::Hidden::ProcessingClass2LadspaBase * adapter = new CLAM::Hidden::ProcessingClass2LadspaBase(className); adapter->Instantiate(); return adapter; } static void ConnectPort(LADSPA_Handle instance, unsigned long port, LADSPA_Data * data) { CLAM::Hidden::ProcessingClass2LadspaBase * adapter = (CLAM::Hidden::ProcessingClass2LadspaBase*)instance; adapter->ConnectPort(port, data); } static void Activate(LADSPA_Handle instance) { CLAM::Hidden::ProcessingClass2LadspaBase* adapter = (CLAM::Hidden::ProcessingClass2LadspaBase*)instance; adapter->Activate(); } static void Run(LADSPA_Handle instance, unsigned long sampleCount) { CLAM::Hidden::ProcessingClass2LadspaBase * adapter = (CLAM::Hidden::ProcessingClass2LadspaBase*)instance; adapter->Run(sampleCount); } static void Deactivate(LADSPA_Handle instance) { CLAM::Hidden::ProcessingClass2LadspaBase * adapter = (CLAM::Hidden::ProcessingClass2LadspaBase*)instance; adapter->Deactivate(); } static void CleanUp(LADSPA_Handle instance) { CLAM::Hidden::ProcessingClass2LadspaBase * adapter = (CLAM::Hidden::ProcessingClass2LadspaBase*)instance; delete adapter; } } namespace CLAM { namespace Hidden { LADSPA_Descriptor * ProcessingClass2LadspaBase::CreateDescriptor(unsigned long id, const std::string & maker, const std::string & copyright) { LADSPA_Descriptor * descriptor = new LADSPA_Descriptor; std::string className = _proc->GetClassName(); descriptor->UniqueID = id; descriptor->Label = LadspaLibrary::dupstr(("CLAM_"+className).c_str()); descriptor->Name = LadspaLibrary::dupstr(("CLAM "+className).c_str()); descriptor->Maker = LadspaLibrary::dupstr(maker.c_str()); descriptor->Copyright = LadspaLibrary::dupstr(copyright.c_str()); descriptor->Properties = LADSPA_PROPERTY_HARD_RT_CAPABLE; //? descriptor->PortCount = NPorts(); descriptor->instantiate = ::Instantiate; descriptor->connect_port = ::ConnectPort; descriptor->activate = ::Activate; descriptor->run = ::Run; descriptor->run_adding = 0; descriptor->set_run_adding_gain = 0; descriptor->deactivate = ::Deactivate; descriptor->cleanup = ::CleanUp; SetPortsAndControls(descriptor); return descriptor; } void ProcessingClass2LadspaBase::SetPortsAndControls(LADSPA_Descriptor *& descriptor) { LADSPA_PortDescriptor *& portDescriptors = const_cast<LADSPA_PortDescriptor*&>(descriptor->PortDescriptors); const char **& portNames = const_cast<const char **&>(descriptor->PortNames); LADSPA_PortRangeHint *& portRangeHints = const_cast<LADSPA_PortRangeHint *&>(descriptor->PortRangeHints); typedef const char * ConstCharPtr; portNames = new ConstCharPtr[NPorts()]; portDescriptors = new LADSPA_PortDescriptor[NPorts()]; portRangeHints = new LADSPA_PortRangeHint[NPorts()]; unsigned i=0; for(unsigned j=0; j<_nInControls; i++, j++) { portDescriptors[i] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; portNames[i] = LadspaLibrary::dupstr(GetInControlName(j)); portRangeHints[i].HintDescriptor = 0; } for(unsigned j=0; j<_nOutControls; i++, j++) { portDescriptors[i] = LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL; portNames[i] = LadspaLibrary::dupstr(GetOutControlName(j)); portRangeHints[i].HintDescriptor = 0; } for(unsigned j=0; j<_nInPorts; i++, j++) { portDescriptors[i] = LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO; portNames[i] = LadspaLibrary::dupstr(GetInPortName(j)); portRangeHints[i].HintDescriptor = 0; } for(unsigned j=0; j<_nOutPorts; i++, j++) { portDescriptors[i] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; portNames[i] = LadspaLibrary::dupstr(GetOutPortName(j)); portRangeHints[i].HintDescriptor = 0; } /* // pitch portRangeHints[0].HintDescriptor = ( LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_SAMPLE_RATE | LADSPA_HINT_LOGARITHMIC | LADSPA_HINT_DEFAULT_440); portRangeHints[0].LowerBound = 0; portRangeHints[0].UpperBound = 0.5; // amplitude portRangeHints[1].HintDescriptor = ( LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1); portRangeHints[1].LowerBound = 0; portRangeHints[1].UpperBound = 1; // audio output portRangeHints[2] = 0; */ } void ProcessingClass2LadspaBase::DoControls() { for(unsigned i=0;i<_nInControls;i++) SendFloatToInControl(*_proc, i,(CLAM::TData)*_incontrolBuffers[i]); // TODO: No output controls! } void ProcessingClass2LadspaBase::SetPortSizes(int size) { for(unsigned i=0;i<_nInControls;i++) { if(_proc->GetInPort(i).GetSize() == size ) continue; _proc->GetInPort(i).SetSize( size ); mWrappersList[i]->SetSize( size ); } for(unsigned i=0;i<_nOutPorts;i++) { if(_proc->GetOutPort(i).GetSize() == size ) continue; _proc->GetOutPort(i).SetSize( size ); } } void ProcessingClass2LadspaBase::DoProc(unsigned long nSamples) { for(unsigned i=0;i<_nInPorts;i++) { memcpy( &(mWrappersList[i]->GetData()), _inportBuffers[i], nSamples*sizeof(CLAM::TData) ); mWrappersList[i]->Produce(); } std::vector<CLAM::TData*> dataList(_nOutPorts); for(unsigned i=0;i<_nOutPorts;i++) { CLAM::OutPortBase & port = _proc->GetOutPort(i); CLAM::AudioOutPort & audioPort = dynamic_cast<CLAM::AudioOutPort&>(port); dataList[i] = &(audioPort.GetData()); } _proc->Do(); for(unsigned i=0; i<_nOutControls; i++) memcpy(_outcontrolBuffers[i], dataList[i], nSamples*sizeof(CLAM::TData) ); } const char * ProcessingClass2LadspaBase::GetInControlName(int id) const { return _proc->GetInControl(id).GetName().c_str(); } const char * ProcessingClass2LadspaBase::GetOutControlName(int id) const { return _proc->GetOutControl(id).GetName().c_str(); } const char * ProcessingClass2LadspaBase::GetInPortName(int id) const { return _proc->GetInPort(id).GetName().c_str(); } const char * ProcessingClass2LadspaBase::GetOutPortName(int id) const { return _proc->GetOutPort(id).GetName().c_str(); } } }
ad926bddeee633b168f144d176c4716a0d46efb3
b8d9b80800c8d7a6fb6c2e18a3a7396f07ac9d4f
/MyDarwin/CommonUtilitiesLib/SDPUtils.h
4153ba505a54ae7491b853e9f95f634f131ca053
[]
no_license
wangscript007/StreamingServer
f0eafc6e806f295d1c6bef1fe867fcc525a5b589
f87627a20e1fb78935e73e906454e87f92f54c1e
refs/heads/master
2021-09-20T10:49:51.960521
2018-08-08T09:50:23
2018-08-08T09:50:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,239
h
/* * * @APPLE_LICENSE_HEADER_START@ * * Copyright (c) 1999-2008 Apple Inc. All Rights Reserved. * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ * */ /* File: SDPUtils.h Contains: Some static routines for dealing with SDPs */ #ifndef __SDPUtilsH__ #define __SDPUtilsH__ #include "OS.h" #include "StrPtrLen.h" #include "ResizeableStringFormatter.h" #include "StringParser.h" #include "OSMemory.h" class SDPLine : public StrPtrLen { public: SDPLine() {} virtual ~SDPLine() {} char GetHeaderType() {if (Ptr && Len) return this->Ptr[0]; return 0;} }; class SDPContainer { enum { kBaseLines = 20, kLineTypeArraySize = 256}; enum { kVPos = 0, kSPos, kTPos, kOPos }; enum { kV = 1 << kVPos, kS = 1 << kSPos, kT = 1 << kTPos, kO = 1 << kOPos, kAllReq = kV | kS | kT | kO }; public: SDPContainer(UInt32 numStrPtrs = SDPContainer::kBaseLines) : fNumSDPLines(numStrPtrs), fSDPLineArray(NULL) { Initialize(); } ~SDPContainer() {delete [] fSDPLineArray;} void Initialize(); SInt32 AddHeaderLine (StrPtrLen *theLinePtr); SInt32 FindHeaderLineType(char id, SInt32 start); SDPLine* GetNextLine(); SDPLine* GetLine(SInt32 lineIndex); void SetLine(SInt32 index); void Parse(); Bool16 SetSDPBuffer(char *sdpBuffer); Bool16 SetSDPBuffer(StrPtrLen *sdpBufferPtr); Bool16 IsSDPBufferValid() {return fValid;} Bool16 HasReqLines() { return (Bool16) (fReqLines == kAllReq) ; } Bool16 HasLineType( char lineType ) { return (Bool16) (lineType == fFieldStr[ (UInt8) lineType]) ; } char* GetReqLinesArray; void PrintLine(SInt32 lineIndex); void PrintAllLines(); SInt32 GetNumLines() { return fNumUsedLines; } SInt32 fCurrentLine; SInt32 fNumSDPLines; SInt32 fNumUsedLines; SDPLine* fSDPLineArray; Bool16 fValid; StrPtrLen fSDPBuffer; UInt16 fReqLines; char fFieldStr[kLineTypeArraySize]; // char* fLineSearchTypeArray; }; class SDPLineSorter { public: SDPLineSorter(): fSessionLineCount(0),fSDPSessionHeaders(NULL,0), fSDPMediaHeaders(NULL,0) {}; SDPLineSorter(SDPContainer *rawSDPContainerPtr, Float32 adjustMediaBandwidthPercent = 1.0, SDPContainer *insertMediaLinesArray = NULL); StrPtrLen* GetSessionHeaders() { return &fSessionHeaders; } StrPtrLen* GetMediaHeaders() { return &fMediaHeaders; } char* GetSortedSDPCopy(); Bool16 ValidateSessionHeader(StrPtrLen *theHeaderLinePtr); StrPtrLen fullSDPBuffSPL; SInt32 fSessionLineCount; SDPContainer fSessionSDPContainer; ResizeableStringFormatter fSDPSessionHeaders; ResizeableStringFormatter fSDPMediaHeaders; StrPtrLen fSessionHeaders; StrPtrLen fMediaHeaders; static char sSessionOrderedLines[];// = "vosiuepcbtrzka"; // chars are order dependent: declared by rfc 2327 static char sessionSingleLines[];// = "vosiuepcbzk"; // return only 1 of each of these session field types static StrPtrLen sEOL; static StrPtrLen sMaxBandwidthTag; }; #endif
c52124162e3ef7b7765b58160212180dd69ee411
3f8cf4adc18c1b0a90652b28fe0ff275a2f30b1d
/src/screens/ending.cpp
388d8c81aa6d5e264acf914c4632c20a624f2912
[ "MIT" ]
permissive
Minhoquinha/pk2
9c359a6f1acb1f7720e35ec91b05679940be86fc
91aa1dc76f21b18b641e8523d209c0a2980f45ee
refs/heads/master
2021-01-01T22:04:15.267448
2020-01-31T21:10:08
2020-01-31T21:10:08
239,362,448
1
0
MIT
2020-02-09T19:36:31
2020-02-09T19:36:29
null
UTF-8
C++
false
false
4,191
cpp
//######################### //Pekka Kana 2 //Copyright (c) 2003 Janne Kivilahti //######################### #include "screens/screens.hpp" #include "gfx/text.hpp" #include "gui.hpp" #include "game/game.hpp" #include "language.hpp" #include "system.hpp" #include "settings.hpp" #include "engine/PDraw.hpp" #include "engine/PInput.hpp" #include "engine/PSound.hpp" #include "engine/PUtils.hpp" #include "engine/types.hpp" u32 loppulaskuri = 0; bool siirry_lopusta_menuun = false; int Draw_EndGame_Image(int x, int y, int tyyppi, int plus, int rapytys){ int frm = 0; int yk = 0; if (tyyppi == 1){ // Pekka frm = 1; if ((degree/10)%10==rapytys) frm = 0; yk = (int)sin_table[(degree%360)]; PDraw::image_cutclip(bg_screen,x+3,y+56, 4, 63, 29, 69); if (yk < 0){ y+=yk; frm = 2; } PDraw::image_cutclip(bg_screen,x,y, 1+frm*35, 1, 32+frm*35, 59); } if (tyyppi == 2){ // kana (katse oikealle) frm = 0; if ((degree/10)%10==rapytys) frm = 1; yk = (int)cos_table[((degree+plus)%360)]; PDraw::image_cutclip(bg_screen,x+3,y+36, 4, 63, 29, 69); if (yk < 0) { y+=yk; frm = 2; } PDraw::image_cutclip(bg_screen,x,y, 106+frm*37, 1, 139+frm*37, 38); } if (tyyppi == 3){ // kana (katse vasemmalle) frm = 0; if ((degree/10)%10==rapytys) frm = 1; yk = (int)cos_table[((degree+plus)%360)]; PDraw::image_cutclip(bg_screen,x+3,y+36, 4, 63, 29, 69); if (yk < 0) { y+=yk; frm = 2; } PDraw::image_cutclip(bg_screen,x,y, 106+frm*37, 41, 139+frm*37, 77); } if (tyyppi == 4){ // pikkukana (katse oikealle) frm = 0; if ((degree/10)%10==rapytys) frm = 1; yk = (int)sin_table[(((degree*2)+plus)%360)]; PDraw::image_cutclip(bg_screen,x+3,y+27, 4, 63, 29, 69); if (yk < 0) { y+=yk; frm = 2; } PDraw::image_cutclip(bg_screen,x,y, 217+frm*29, 1, 243+frm*29, 29); } if (tyyppi == 5){ // pikkukana (katse vasemmalle) frm = 0; if ((degree/10)%10==rapytys) frm = 1; yk = (int)sin_table[(((degree*2)+plus)%360)]; PDraw::image_cutclip(bg_screen,x,y+27, 4, 63, 29, 69); if (yk < 0) { y+=yk; frm = 2; } PDraw::image_cutclip(bg_screen,x,y, 217+frm*29, 33, 243+frm*29, 61); } return 0; } int Draw_EndGame(){ u32 onnittelut_alku = 300; u32 onnittelut_loppu = onnittelut_alku + 1000; u32 the_end_alku = onnittelut_loppu + 80; u32 the_end_loppu = the_end_alku + 3000; PDraw::image_cutclip(bg_screen,320-233/2,240-233/2, 6, 229, 239, 462); Draw_EndGame_Image(345, 244, 3, 30, 2); Draw_EndGame_Image(276, 230, 2, 50, 3); Draw_EndGame_Image(217, 254, 4, 0, 4); Draw_EndGame_Image(305, 240, 1, 0, 1); Draw_EndGame_Image(270, 284, 2, 20, 1); Draw_EndGame_Image(360, 284, 5, 60, 2); if (loppulaskuri > onnittelut_alku) { CreditsText_Draw(tekstit->Get_Text(PK_txt.end_congratulations), fontti2, 220, 380, onnittelut_alku, onnittelut_loppu, loppulaskuri); CreditsText_Draw(tekstit->Get_Text(PK_txt.end_chickens_saved), fontti1, 220, 402, onnittelut_alku+30, onnittelut_loppu+30, loppulaskuri); } if (loppulaskuri > the_end_alku) { CreditsText_Draw(tekstit->Get_Text(PK_txt.end_the_end), fontti2, 280, 190, the_end_alku, the_end_loppu, loppulaskuri); } return 0; } int Screen_Ending_Init() { if(PUtils::Is_Mobile()) GUI_Change(UI_TOUCH_TO_START); PDraw::set_xoffset(Settings.isWide? 80 : 0); PDraw::image_load(bg_screen, PFile::Path("gfx" PE_SEP "ending.bmp"), true); if (PSound::start_music(PFile::Path("music" PE_SEP "intro.xm")) == -1) PK2_Error("Can't load intro.xm"); PSound::set_musicvolume(Settings.music_max_volume); loppulaskuri = 0; siirry_lopusta_menuun = false; PDraw::fade_in(PDraw::FADE_FAST); return 0; } int Screen_Ending(){ Draw_EndGame(); degree = 1 + degree % 360; loppulaskuri++; //introlaskuri = loppulaskuri; // introtekstej� varten if (siirry_lopusta_menuun && !PDraw::is_fading()) { PSound::set_musicvolume_now(Settings.music_max_volume); //next_screen = SCREEN_MENU; next_screen = SCREEN_MAP; } if (key_delay == 0) { if (PInput::Keydown(PInput::RETURN) || PInput::Keydown(PInput::SPACE) || Gui_touch) { siirry_lopusta_menuun = true; PSound::set_musicvolume(0); PDraw::fade_out(PDraw::FADE_SLOW); } } return 0; }
03c51d5ce956d51c82dec7a4425dd9ad9bf322f2
aff95ec4050bb261604d8fcacc2249ef20203760
/OpenGlBack/OPENGL/Chapter01/OBJ File Loader/Obj.cpp
d0a0e7f4beb0f215a02bd628fe18a6eb1985152b
[]
no_license
TwTravel/OpenGLRefCode
b82ee644259e27817a6451d8cbed494eec0fa265
daa11168a098108a21ae9df9aa71b34b20fc09f0
refs/heads/master
2020-04-01T16:35:12.391700
2018-10-17T07:24:22
2018-10-17T07:24:22
153,388,135
1
1
null
null
null
null
GB18030
C++
false
false
12,459
cpp
#include "main.h" #include "Obj.h" // 下面的函数的功能是将obj文件的信息读入指定的模型中 bool CLoadObj::ImportObj(t3DModel *pModel, char *strFileName) { char strMessage[255] = {0}; // 用于显示错误信息 // 判断是否是一个合法的模型和文件类型 if(!pModel || !strFileName) return false; // 以只读方式打开文件,返回文件指针 m_FilePointer = fopen(strFileName, "r"); // 判断文件指针是否正确 if(!m_FilePointer) { // 如果文件指针不正确,则显示错误信息 sprintf(strMessage, "Unable to find or open the file: %s", strFileName); MessageBox(NULL, strMessage, "Error", MB_OK); return false; } // 读入文件信息 ReadObjFile(pModel); // 计算顶点的法向量,用于光照 ComputeNormals(pModel); // 关闭打开的文件 fclose(m_FilePointer); return true; } // 读入obj文件中的对象到模型中 void CLoadObj::ReadObjFile(t3DModel *pModel) { char strLine[255] = {0}; char ch = 0; while(!feof(m_FilePointer)) { float x = 0.0f, y = 0.0f, z = 0.0f; // 获得obj文件中的当前行的第一个字符 ch = fgetc(m_FilePointer); switch(ch) { case 'v': // 读入的是'v' (后续的数据可能是顶点/法向量/纹理坐标) // 如果在前面读入的是面的行,那么现在进入的是另一个对象,因此在读入下一个对象之前, // 需要将最后对象的数据写入到模型结构体中 if(m_bJustReadAFace) { // 将最后对象的信息保存到模型结构中 FillInObjectInfo(pModel); } // 读入点的信息,要区分顶点 ("v")、法向量 ("vn")、纹理坐标 ("vt") ReadVertexInfo(); break; case 'f': // 读入的是'f' // 读入面的信息 ReadFaceInfo(); break; default: // 略过该行的内容 fgets(strLine, 100, m_FilePointer); break; } } // 保存最后读入的对象 FillInObjectInfo(pModel); } // 下面的函数读入顶点信息('v'是指顶点,'vt'指UV坐标) void CLoadObj::ReadVertexInfo() { CVector3 vNewVertex = {0}; CVector2 vNewTexCoord = {0}; char strLine[255] = {0}; char ch = 0; // 读入第一个字符,判断读入的是否顶点/法向量/UV坐标 ch = fgetc(m_FilePointer); if(ch == ' ') // 如果是空格,则必是顶点("v") { // 读入顶点坐标,格式是"v x y z" fscanf(m_FilePointer, "%f %f %f", &vNewVertex.x, &vNewVertex.y, &vNewVertex.z); // 读入该行中余下的内容,则文件指针到下一行 fgets(strLine, 100, m_FilePointer); // 添加一个新的顶点到顶点链表中 m_pVertices.push_back(vNewVertex); } else if(ch == 't') // 如果是't',则必定是纹理坐标("vt") { // 读入纹理坐标,格式是"vt u v" fscanf(m_FilePointer, "%f %f", &vNewTexCoord.x, &vNewTexCoord.y); // 读入该行余下的内容,则文件指针指向下一行 fgets(strLine, 100, m_FilePointer); // 添加一个新的纹理坐标到链表中 m_pTextureCoords.push_back(vNewTexCoord); // 设置对象具有纹理坐标为true m_bObjectHasUV = true; } else // 否则可能是法向量("vn") { // 由于在最后计算各点的法向量,在这里略过 fgets(strLine, 100, m_FilePointer); } } // 下面的函数读入面信息 void CLoadObj::ReadFaceInfo() { tFace newFace = {0}; char strLine[255] = {0}; // 判断对象是否具有纹理坐标 if(m_bObjectHasUV ) { // 读入对象的顶点和纹理坐标索引,格式是"顶点1/纹理坐标1 顶点2/纹理坐标2 顶点3/纹理坐标3" fscanf(m_FilePointer, "%d/%d %d/%d %d/%d", &newFace.vertIndex[0], &newFace.coordIndex[0], &newFace.vertIndex[1], &newFace.coordIndex[1], &newFace.vertIndex[2], &newFace.coordIndex[2]); } else // 对象无纹理坐标 { // 读入对象的顶点索引,格式是"顶点1 顶点2 顶点3" fscanf(m_FilePointer, "%d %d %d", &newFace.vertIndex[0], &newFace.vertIndex[1], &newFace.vertIndex[2]); } // 读入该行余下的内容,则文件指针指向下一行 fgets(strLine, 100, m_FilePointer); // 添加一个新面到面链表中 m_pFaces.push_back(newFace); // 设置刚才读入的是面 m_bJustReadAFace = true; } // 下面的函数将读入对象的信息写入模型结构体中 void CLoadObj::FillInObjectInfo(t3DModel *pModel) { t3DObject newObject = {0}; int textureOffset = 0, vertexOffset = 0; int i = 0; // 模型中对象计数器递增 pModel->numOfObjects++; // 添加一个新对象到模型的对象链表中 pModel->pObject.push_back(newObject); // 获得当前对象的指针 t3DObject *pObject = &(pModel->pObject[pModel->numOfObjects - 1]); // 获得面的数量、顶点的数量和纹理坐标的数量 pObject->numOfFaces = m_pFaces.size(); pObject->numOfVerts = m_pVertices.size(); pObject->numTexVertex = m_pTextureCoords.size(); // 如果读入了面 if(pObject->numOfFaces) { // 分配保存面的存储空间 pObject->pFaces = new tFace [pObject->numOfFaces]; } // 如果读入了点 if(pObject->numOfVerts) { // 分配保存点的存储空间 pObject->pVerts = new CVector3 [pObject->numOfVerts]; } // 如果读入了纹理坐标 if(pObject->numTexVertex) { pObject->pTexVerts = new CVector2 [pObject->numTexVertex]; pObject->bHasTexture = true; } // 遍历所有的面 for(i = 0; i < pObject->numOfFaces; i++) { // 拷贝临时的面链表到模型链表中 pObject->pFaces[i] = m_pFaces[i]; // 判断是否是对象的第一个面 if(i == 0) { // 如果第一索引不是1,则必须略过第一个对象 if(pObject->pFaces[0].vertIndex[0] != 1) { vertexOffset = pObject->pFaces[0].vertIndex[0] - 1; // 对于纹理坐标,也进行同样的操作 if(pObject->numTexVertex > 0) { // 当前的索引剪去1 textureOffset = pObject->pFaces[0].coordIndex[0] - 1; } } } for(int j = 0; j < 3; j++) { // 对于每一个索引,必须将其减去1 pObject->pFaces[i].vertIndex[j] -= 1 + vertexOffset; pObject->pFaces[i].coordIndex[j] -= 1 + textureOffset; } } // 遍历对象中的所有点 for(i = 0; i < pObject->numOfVerts; i++) { // 将当前的顶点从临时链表中拷贝到模型链表中 pObject->pVerts[i] = m_pVertices[i]; } // 遍历对象中所有的纹理坐标 for(i = 0; i < pObject->numTexVertex; i++) { // 将当前的纹理坐标从临时链表中拷贝到模型链表中 pObject->pTexVerts[i] = m_pTextureCoords[i]; } // 由于OBJ文件中没有材质,因此将materialID设置为-1,必须手动设置材质 pObject->materialID = -1; // 清除所有的临时链表 m_pVertices.clear(); m_pFaces.clear(); m_pTextureCoords.clear(); // 设置所有的布尔值为false m_bObjectHasUV = false; m_bJustReadAFace = false; } // 下面的函数为对象序列中的对象赋予具体的材质 void CLoadObj::SetObjectMaterial(t3DModel *pModel, int whichObject, int materialID) { // 确保模型合法 if(!pModel) return; // 确保对象合法 if(whichObject >= pModel->numOfObjects) return; // 给对象赋予材质ID pModel->pObject[whichObject].materialID = materialID; } // 下面的函数给模型手动添加材质 void CLoadObj::AddMaterial(t3DModel *pModel, char *strName, char *strFile, int r, int g, int b) { tMaterialInfo newMaterial = {0}; // 设置材质的RGB值[0 - RED 1 - GREEN 2 - BLUE] newMaterial.color[0] = r; newMaterial.color[1] = g; newMaterial.color[2] = b; // 如果具有文件名称,则将其拷贝到材质结构体中 if(strFile) { strcpy(newMaterial.strFile, strFile); } // 如果具有材质名称,则将其拷贝到材质结构体中 if(strName) { strcpy(newMaterial.strName, strName); } // 将材质加入到模型链表中 pModel->pMaterials.push_back(newMaterial); // 材质数量递增 pModel->numOfMaterials++; } // 下面的这些函数主要用来计算顶点的法向量,顶点的法向量主要用来计算光照 // 下面的宏定义计算一个矢量的长度 #define Mag(Normal) (sqrt(Normal.x*Normal.x + Normal.y*Normal.y + Normal.z*Normal.z)) // 下面的函数求两点决定的矢量 CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2) { CVector3 vVector; vVector.x = vPoint1.x - vPoint2.x; vVector.y = vPoint1.y - vPoint2.y; vVector.z = vPoint1.z - vPoint2.z; return vVector; } // 下面的函数两个矢量相加 CVector3 AddVector(CVector3 vVector1, CVector3 vVector2) { CVector3 vResult; vResult.x = vVector2.x + vVector1.x; vResult.y = vVector2.y + vVector1.y; vResult.z = vVector2.z + vVector1.z; return vResult; } // 下面的函数处理矢量的缩放 CVector3 DivideVectorByScaler(CVector3 vVector1, float Scaler) { CVector3 vResult; vResult.x = vVector1.x / Scaler; vResult.y = vVector1.y / Scaler; vResult.z = vVector1.z / Scaler; return vResult; } // 下面的函数返回两个矢量的叉积 CVector3 Cross(CVector3 vVector1, CVector3 vVector2) { CVector3 vCross; vCross.x = ((vVector1.y * vVector2.z) - (vVector1.z * vVector2.y)); vCross.y = ((vVector1.z * vVector2.x) - (vVector1.x * vVector2.z)); vCross.z = ((vVector1.x * vVector2.y) - (vVector1.y * vVector2.x)); return vCross; } // 下面的函数规范化矢量 CVector3 Normalize(CVector3 vNormal) { double Magnitude; Magnitude = Mag(vNormal); // 获得矢量的长度 vNormal.x /= (float)Magnitude; vNormal.y /= (float)Magnitude; vNormal.z /= (float)Magnitude; return vNormal; } // 下面的函数用于计算对象的法向量 void CLoadObj::ComputeNormals(t3DModel *pModel) { CVector3 vVector1, vVector2, vNormal, vPoly[3]; // 如果模型中没有对象,则返回 if(pModel->numOfObjects <= 0) return; // 遍历模型中所有的对象 for(int index = 0; index < pModel->numOfObjects; index++) { // 获得当前的对象 t3DObject *pObject = &(pModel->pObject[index]); // 分配需要的存储空间 CVector3 *pNormals = new CVector3 [pObject->numOfFaces]; CVector3 *pTempNormals = new CVector3 [pObject->numOfFaces]; pObject->pNormals = new CVector3 [pObject->numOfVerts]; // 遍历对象的所有面 for(int i=0; i < pObject->numOfFaces; i++) { vPoly[0] = pObject->pVerts[pObject->pFaces[i].vertIndex[0]]; vPoly[1] = pObject->pVerts[pObject->pFaces[i].vertIndex[1]]; vPoly[2] = pObject->pVerts[pObject->pFaces[i].vertIndex[2]]; // 计算面的法向量 vVector1 = Vector(vPoly[0], vPoly[2]); // 获得多边形的矢量 vVector2 = Vector(vPoly[2], vPoly[1]); // 获得多边形的第二个矢量 vNormal = Cross(vVector1, vVector2); // 获得两个矢量的叉积 pTempNormals[i] = vNormal; // 保存非规范化法向量 vNormal = Normalize(vNormal); // 规范化获得的叉积 pNormals[i] = vNormal; // 将法向量添加到法向量列表中 } // 下面求顶点法向量 CVector3 vSum = {0.0, 0.0, 0.0}; CVector3 vZero = vSum; int shared=0; // 遍历所有的顶点 for (i = 0; i < pObject->numOfVerts; i++) { for (int j = 0; j < pObject->numOfFaces; j++) // 遍历所有的三角形面 { // 判断该点是否与其它的面共享 if (pObject->pFaces[j].vertIndex[0] == i || pObject->pFaces[j].vertIndex[1] == i || pObject->pFaces[j].vertIndex[2] == i) { vSum = AddVector(vSum, pTempNormals[j]); shared++; } } pObject->pNormals[i] = DivideVectorByScaler(vSum, float(-shared)); // 规范化最后的顶点法向 pObject->pNormals[i] = Normalize(pObject->pNormals[i]); vSum = vZero; shared = 0; } // 释放存储空间,开始下一个对象 delete [] pTempNormals; delete [] pNormals; } }
22ab97601764ebb34dd396b8e2552aa349538f77
9cab70573d036160d411a5498bc11bac6b833e3d
/接话茬.cpp
62ce16ea56aed64a2b2eb2b37039705974757035
[]
no_license
HeroIsUseless/c
a1a4f36ee2211e32119d38eabf90b8ed05babc15
13e357b095c49dc6a50be8982216616816fb2f80
refs/heads/master
2021-06-13T15:25:35.727101
2021-02-18T12:20:31
2021-02-18T12:20:31
140,438,352
3
0
null
2018-11-07T03:58:12
2018-07-10T13:43:39
C
UTF-8
C++
false
false
1,084
cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> using namespace std; #define MAXSIZE 1000000 void GetNext(char cps[], int cpn[]) { int i=1, j=0, cpsn; cpn[0] = -1; cpsn = strlen(cps); while(i < cpsn) { if(cps[i]==cps[j] || j==-1) { i++;j++; cpn[i] = j; } else { j = cpn[j]; } } } int GetResult(char* ps1, char* ps2, int* pn) { int i=0, j=0; int ps1n, ps2n; ps1n = strlen(ps1);ps2n = strlen(ps2); if(ps1n > ps2n) i = ps1n-ps2n; while(i < ps1n) { if(ps1[i] == ps2[j]) {i++;j++;} else if(ps1[i]!=ps2[j] && j==0) i++; else j = pn[j]; } return j; } char ps[MAXSIZE],cs[MAXSIZE],xs[MAXSIZE]; int nextc[MAXSIZE],nextx[MAXSIZE]; int main() { cin >> ps >> cs >> xs; GetNext(cs,nextc); GetNext(xs,nextx); int a, b; a = GetResult(ps, cs, nextc); b = GetResult(ps, xs, nextx); cout << a << " " << b << endl; return 0; }
212d43453b46a3e80f3db23a4f91df06524b64ec
c8a38e65e71de888fc5b22fbd027bbaa0f3f6ef1
/Cpp/86.cpp
26d89051904f167b1420a83fb9a83ba5e419c70c
[]
no_license
skywhat/leetcode
e451a10cdab0026d884b8ed2b03e305b92a3ff0f
6aaf58b1e1170a994affd6330d90b89aaaf582d9
refs/heads/master
2023-03-30T15:54:27.062372
2023-03-30T06:51:20
2023-03-30T06:51:20
90,644,891
82
27
null
null
null
null
UTF-8
C++
false
false
1,140
cpp
// Given a linked list and a value x, partition it such that all nodes less than // x come before nodes greater than or equal to x. // // You should preserve the original relative order of the nodes in each of the // two partitions. // // Example: // // Input: head = 1->4->3->2->5->2, x = 3 // Output: 1->2->2->4->3->5 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* partition(ListNode* head, int x) { ListNode LessHead(-1); ListNode* prevLess = &LessHead; ListNode GreaterHead(-1); ListNode* prevGreater = &GreaterHead; while (head) { if (head->val < x) { prevLess->next = head; prevLess = prevLess->next; } else { prevGreater->next = head; prevGreater = prevGreater->next; } head = head->next; } prevLess->next = GreaterHead.next; prevGreater->next = nullptr; return LessHead.next; } };
057986c4cc591a0b992744fe3ff512a39014b04a
68057a3152a6e9fb5f9352b536c89374b9c4d333
/perftest/queues/queuetest.cpp
d3601e9a60d5e28c3e9e34156da615ccc36ccbe3
[ "ISC" ]
permissive
mashavorob/lfds
b9ce3a0f839e7c47ac44319112f25b7725bdfd6e
3890472a8a9996ce35d9a28f185df4c2f219a2bd
refs/heads/master
2016-09-06T18:33:20.121328
2015-06-05T18:22:18
2015-06-05T18:22:18
28,824,065
0
0
null
null
null
null
UTF-8
C++
false
false
1,548
cpp
/* * queuetest.cpp * * Created on: Jun 2, 2015 * Author: masha */ #include <xtomic/queue.hpp> #include <xtomic/aux/inttypes.hpp> #include <vector> #include "testfactory.hpp" #include "queuetest.hpp" #include "stdqueue.hpp" namespace xtomic { namespace perftest { namespace queues { typedef xtomic::uint64_t item_type; typedef xtomic::queue<item_type, xtomic::Queue::FixedSize, xtomic::Queue::OneProducer, xtomic::Queue::OneConsumer> wait_free_queue_type; typedef xtomic::queue<item_type, xtomic::Queue::FixedSize, xtomic::Queue::ManyProducers, xtomic::Queue::OneConsumer> lock_free_one_consumer_queue_type; typedef xtomic::queue<item_type, xtomic::Queue::FixedSize, xtomic::Queue::ManyProducers, xtomic::Queue::ManyConsumers> lock_free_many_consumers_queue_type; typedef adapter::stdqueue<item_type> stl_queue_type; template<typename Queue> class Registrar { private: typedef Queue queue_type; typedef BandwithTester<queue_type> tester_type; typedef PerfTestFactoryImpl<tester_type> factory_type; public: Registrar(const char* queue_name) : m_factory("queues", queue_name, "bandwith", "MItems/sec") { } private: factory_type m_factory; }; static Registrar<wait_free_queue_type> s_wfq("wait free queue"); static Registrar<lock_free_one_consumer_queue_type> s_lfscq("lock free single consumer queue"); static Registrar<lock_free_many_consumers_queue_type> s_lfmcq("lock free many consumers queue"); static Registrar<stl_queue_type> s_stdq("std::queue"); } } }
bcf11641dff202c1a85e75d19791a07c0ab5c03c
a93bb0f268cf5e2de2dd745c86a160ca60fada86
/源代码/Thirdparty/UGC/inc/FileParser/UGFileRasterBmp.h
24c45efc502694af00db07aeef006d073a3afc00
[ "Apache-2.0" ]
permissive
15831944/Fdo_SuperMap
ea22b74ecfc5f983f2decefe4c2cf29007b85bf6
3d4309d0f45fa63abcde188825a997077dd444f4
refs/heads/master
2021-05-29T09:57:19.433966
2015-05-22T09:03:56
2015-05-22T09:03:56
null
0
0
null
null
null
null
GB18030
C++
false
false
3,517
h
/*! ************************************************************************************** \file UGFileRasterBmp.h ************************************************************************************** \author 艾国 \brief BMP文件解析类 \remarks 它从 UGFileRaster类继承 <br> ----------------------------------------------------------------------------------<br> Revision History : <br> 2005-04-22 艾国 Initial Version. <br> <br> ----------------------------------------------------------------------------------<br> Copyright (c) 1996-2004 SuperMap GIS Technologies,Inc. <br> ----------------------------------------------------------------------------------<br> ************************************************************************************** */ #if !defined(AFX_UGFILERASTERBMP_H__A42B6B70_BD1B_4C71_8676_2BB3AFD97FD6__INCLUDED_) #define AFX_UGFILERASTERBMP_H__A42B6B70_BD1B_4C71_8676_2BB3AFD97FD6__INCLUDED_ #include "UGFileParseRaster.h" #include "FileParser/UGFileLibBmp.h" #include "Base/UGFileStream.h" #include "Base/UGMemoryStream.h" namespace UGC { class UGImgScanline; class UGImage; class FILEPARSER_API UGFileRasterBmp : public UGFileParseRaster { public: UGFileRasterBmp(); virtual ~UGFileRasterBmp(); public: //! \brief 输出UGImage内容到PNG文件. //! \return UGbool //! \param strFileName 输出的文件路径 //! \param pImage //! \remarks UGbool OutputDirect(UGString strFileName, UGImage* pImage); public: ////////////////////////////////////////////////////////////////////////// // 读去函数 ////////////////////////////////////////////////////////////////////////// //! \brief 准备读取一个数据文件 virtual UGbool OpenForRead(const UGString& strFileName); //! \brief 准备开始读取栅格数据,在调用ReadData之前必须调用 virtual UGbool BeginRead(UGint nIndex = 1); //! \brief 读取一个扫描行的数据 virtual UGbool ReadScanLine(UGImgScanline& imgScanline, UGint nRowIndex, UGint nBandIndex = 0); //! \brief 结束读取栅格数据,在调用ReadData之后必须调用(释放东东) virtual void EndRead(); ////////////////////////////////////////////////////////////////////////// // 写入函数 ////////////////////////////////////////////////////////////////////////// //! \brief 准备写入一个数据文件 virtual UGbool OpenForWrite(const UGString& strFileName); //! \brief 准备开始写数据,在调用WriteData之前必须调用 virtual UGbool BeginWrite(); //! \brief 写入一个扫描行的数据 virtual UGbool WriteScanLine(UGint nRowIndex, UGImgScanline& imgScanline); //! \brief 结束写数据,在调用WriteData之后必须调用 virtual void EndWrite(); //! \brief 关闭数据 virtual void Close(); private: //! \brief 读取一个扫描行的数据 UGuchar *pBmpData; //! \brief 读写文件类 UGFileLibBmp m_bmp; //! \brief Bmp的象素格式或称类型 BitmapType m_type; //! \brief 存储对照表(ColorTable) UGuchar *pColorTable; }; } //namespace UGC #endif // !defined(AFX_UGFILERASTERBMP_H__A42B6B70_BD1B_4C71_8676_2BB3AFD97FD6__INCLUDED_)
44ed583e81350a64bb3e2f07f7b8e7e0c4545a4e
9b55a3f9fa33644aa1b42e99dee1e0c714af29ed
/src/graphics/EmitterModifier.cpp
62d59bada3846c6f28259fba924d8e0bfcf977fc
[ "BSD-2-Clause" ]
permissive
jpd002/Palleon
56597af91e7878a3311b0cc08d556a6e348d9d4e
ddcd68d0a0b572a820066a74c19d36633dbb0245
refs/heads/master
2021-04-09T17:40:42.634899
2016-11-27T21:58:18
2016-11-27T21:58:18
18,983,388
2
3
null
null
null
null
UTF-8
C++
false
false
383
cpp
#include "palleon/graphics/EmitterModifier.h" using namespace Palleon; CEmitterModifier::CEmitterModifier() { } CEmitterModifier::~CEmitterModifier() { } void CEmitterModifier::Update(float dt) { m_animationController.Update(this, dt); } EmitterModifierAnimationController& CEmitterModifier::GetAnimationController() { return m_animationController; }
[ "jpd002@e658db38-2ae6-4b1c-8a17-0a8554443f32" ]
jpd002@e658db38-2ae6-4b1c-8a17-0a8554443f32
2a7f202cecdd41d2e2bcab99c5653ea3e935b6e4
8e567498a9224d7c6bf71cfe66ec5360e056ec02
/mars/boost/config/compiler/sunpro_cc.hpp
53b3a21887a1d9fc0e8aadcbfc6fa67c3feab02d
[ "MIT", "Zlib", "LicenseRef-scancode-unknown-license-reference", "OpenSSL", "BSD-3-Clause", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "BSL-1.0", "Apache-2.0", "BSD-2-Clause" ]
permissive
Tencent/mars
db31afeeb5c0325bfceede594038381bce3c1635
6c7028fffe01e2b49a66c221b1ac2f548649053f
refs/heads/master
2023-08-31T07:29:50.430084
2023-08-09T07:24:42
2023-08-09T07:24:42
76,222,419
18,118
3,828
NOASSERTION
2023-09-12T07:37:07
2016-12-12T04:39:54
C++
UTF-8
C++
false
false
6,764
hpp
// (C) Copyright John Maddock 2001. // (C) Copyright Jens Maurer 2001 - 2003. // (C) Copyright Peter Dimov 2002. // (C) Copyright Aleksey Gurtovoy 2002 - 2003. // (C) Copyright David Abrahams 2002. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. // Sun C++ compiler setup: # if __SUNPRO_CC <= 0x500 # define BOOST_NO_MEMBER_TEMPLATES # define BOOST_NO_FUNCTION_TEMPLATE_ORDERING # endif # if (__SUNPRO_CC <= 0x520) // // Sunpro 5.2 and earler: // // although sunpro 5.2 supports the syntax for // inline initialization it often gets the value // wrong, especially where the value is computed // from other constants (J Maddock 6th May 2001) # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION // Although sunpro 5.2 supports the syntax for // partial specialization, it often seems to // bind to the wrong specialization. Better // to disable it until suppport becomes more stable // (J Maddock 6th May 2001). # define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # endif # if (__SUNPRO_CC <= 0x530) // Requesting debug info (-g) with Boost.Python results // in an internal compiler error for "static const" // initialized in-class. // >> Assertion: (../links/dbg_cstabs.cc, line 611) // while processing ../test.cpp at line 0. // (Jens Maurer according to Gottfried Ganssauge 04 Mar 2002) # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION // SunPro 5.3 has better support for partial specialization, // but breaks when compiling std::less<shared_ptr<T> > // (Jens Maurer 4 Nov 2001). // std::less specialization fixed as reported by George // Heintzelman; partial specialization re-enabled // (Peter Dimov 17 Jan 2002) //# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // integral constant expressions with 64 bit numbers fail # define BOOST_NO_INTEGRAL_INT64_T # endif # if (__SUNPRO_CC < 0x570) # define BOOST_NO_TEMPLATE_TEMPLATES // see http://lists.boost.org/MailArchives/boost/msg47184.php // and http://lists.boost.org/MailArchives/boost/msg47220.php # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION # define BOOST_NO_SFINAE # define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS # endif # if (__SUNPRO_CC <= 0x580) # define BOOST_NO_IS_ABSTRACT # endif # if (__SUNPRO_CC <= 0x5100) // Sun 5.10 may not correctly value-initialize objects of // some user defined types, as was reported in April 2010 // (CR 6947016), and confirmed by Steve Clamage. // (Niels Dekker, LKEB, May 2010). # define BOOST_NO_COMPLETE_VALUE_INITIALIZATION # endif // // Dynamic shared object (DSO) and dynamic-link library (DLL) support // #if __SUNPRO_CC > 0x500 # define BOOST_SYMBOL_EXPORT __global # define BOOST_SYMBOL_IMPORT __global # define BOOST_SYMBOL_VISIBLE __global #endif #if (__SUNPRO_CC < 0x5130) // C++03 features in 12.4: #define BOOST_NO_TWO_PHASE_NAME_LOOKUP #define BOOST_NO_SFINAE_EXPR #define BOOST_NO_ADL_BARRIER #define BOOST_NO_CXX11_VARIADIC_MACROS #endif #if (__SUNPRO_CC < 0x5130) || (__cplusplus < 201100) // C++11 only featuires in 12.4: #define BOOST_NO_CXX11_AUTO_DECLARATIONS #define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS #define BOOST_NO_CXX11_CHAR16_T #define BOOST_NO_CXX11_CHAR32_T #define BOOST_NO_CXX11_CONSTEXPR #define BOOST_NO_CXX11_DECLTYPE #define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS #define BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS #define BOOST_NO_CXX11_EXTERN_TEMPLATE #define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS #define BOOST_NO_CXX11_HDR_INITIALIZER_LIST #define BOOST_NO_CXX11_LAMBDAS #define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS #define BOOST_NO_CXX11_NOEXCEPT #define BOOST_NO_CXX11_NULLPTR #define BOOST_NO_CXX11_RANGE_BASED_FOR #define BOOST_NO_CXX11_RAW_LITERALS #define BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_NO_CXX11_SCOPED_ENUMS #define BOOST_NO_CXX11_STATIC_ASSERT #define BOOST_NO_CXX11_TEMPLATE_ALIASES #define BOOST_NO_CXX11_UNICODE_LITERALS #define BOOST_NO_CXX11_ALIGNAS #define BOOST_NO_CXX11_TRAILING_RESULT_TYPES #define BOOST_NO_CXX11_INLINE_NAMESPACES #define BOOST_NO_CXX11_FINAL #endif #if (__SUNPRO_CC < 0x5140) || (__cplusplus < 201103) #define BOOST_NO_CXX11_VARIADIC_TEMPLATES #define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX #define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS #define BOOST_NO_CXX11_DECLTYPE_N3276 #define BOOST_NO_CXX11_USER_DEFINED_LITERALS #define BOOST_NO_CXX11_REF_QUALIFIERS #endif #define BOOST_NO_COMPLETE_VALUE_INITIALIZATION // // C++0x features // # define BOOST_HAS_LONG_LONG // C++ 14: #if !defined(__cpp_aggregate_nsdmi) || (__cpp_aggregate_nsdmi < 201304) # define BOOST_NO_CXX14_AGGREGATE_NSDMI #endif #if !defined(__cpp_binary_literals) || (__cpp_binary_literals < 201304) # define BOOST_NO_CXX14_BINARY_LITERALS #endif #if !defined(__cpp_constexpr) || (__cpp_constexpr < 201304) # define BOOST_NO_CXX14_CONSTEXPR #endif #if !defined(__cpp_decltype_auto) || (__cpp_decltype_auto < 201304) # define BOOST_NO_CXX14_DECLTYPE_AUTO #endif #if (__cplusplus < 201304) // There's no SD6 check for this.... # define BOOST_NO_CXX14_DIGIT_SEPARATORS #endif #if !defined(__cpp_generic_lambdas) || (__cpp_generic_lambdas < 201304) # define BOOST_NO_CXX14_GENERIC_LAMBDAS #endif #if !defined(__cpp_init_captures) || (__cpp_init_captures < 201304) # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES #endif #if !defined(__cpp_return_type_deduction) || (__cpp_return_type_deduction < 201304) # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION #endif #if !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif // // Version // #define BOOST_COMPILER "Sun compiler version " BOOST_STRINGIZE(__SUNPRO_CC) // // versions check: // we don't support sunpro prior to version 4: #if __SUNPRO_CC < 0x400 #error "Compiler not supported or configured - please reconfigure" #endif // // last known and checked version is 0x590: #if (__SUNPRO_CC > 0x590) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # endif #endif
522d713a9c737d5da82c49dfdd84ab10a3169675
8a606ff67be1e597ada82d36743b65d7b70f474f
/Movie.cpp
ba9f42e4bc7b1b78f9b2aa1cdd32e8509185fbba
[]
no_license
cnguy/CS-A250-DArray-Class-with-Movie-Class
26e297117f69851fd3d3735fcf388310cee1816a
a5e9f2fe8446b5c73a383ea4964f2b30c78d215b
refs/heads/master
2021-05-30T15:43:58.653902
2016-04-16T22:51:20
2016-04-16T22:51:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
865
cpp
#include "Movie.h" Movie::Movie() { movieTitle = "N/A"; productionYear = 0; } Movie::Movie(const string& newMovieTitle, int newProductionYear) { movieTitle = newMovieTitle; productionYear = newProductionYear; } ostream& operator<<(ostream& out, const Movie& movie) { out << "Movie Title: " << movie.movieTitle << endl << "Production Year: " << movie.productionYear << endl; return out; } void Movie::printMovieDetails() const { cout << "Movie Title: " << movieTitle << "; Production Year: " << productionYear << endl; } string Movie::getMovieTitle() const { return movieTitle; } int Movie::getProductionYear() const { return productionYear; } void Movie::setMovieTitle(const string& newMovieTitle) { movieTitle = newMovieTitle; } void Movie::setProductionYear(int newProductionYear) { productionYear = newProductionYear; } Movie::~Movie() { }
0dbff80a74924beb84268b8b1f292d98f63c07f1
12df840337a0a1f22d92d0d5d575305aafcbf613
/Include/substance/framework/preset.h
d838f5d4f96c0b315f81b6266f72457d0223ed2e
[]
no_license
SubstanceSource/SubstanceSource
9be733c09d8cc0382e4f97f134cdf5d7626d4759
93992457b1c3802d69141421595ecbe155ce6112
refs/heads/master
2021-07-05T09:50:04.845309
2021-04-11T03:18:16
2021-04-11T03:18:16
231,140,767
1
0
null
null
null
null
UTF-8
C++
false
false
3,875
h
//! @file preset.h //! @brief Substance Air preset definitions //! @author Christophe Soum - Allegorithmic //! @copyright Allegorithmic. All rights reserved. #ifndef _SUBSTANCE_AIR_FRAMEWORK_PRESET_H #define _SUBSTANCE_AIR_FRAMEWORK_PRESET_H #include "typedefs.h" #include <substance/inputdesc.h> #include <iostream> namespace SubstanceAir { class GraphInstance; //! @brief Class that represents a preset of inputs //! Presets can be loaded from a preset file (.SBSPRS) or can be embedded in a //! graph description (GraphDesc::getPresets()) struct Preset { //! @brief One input value structure struct InputValue { //! @brief 32 bits unsigned Unique Identifier //! Used for exact match. UInt mUid; //! @brief User-readable identifier of the input //! Used for matching a preset created from a graph to an another one. string mIdentifier; //! @brief Type of the input //! Used to check values types consistency. //! @see SubstanceIOType enum in substance/iotype.h SubstanceIOType mType; //! @brief Value/filepath of the input, stored as string string mValue; }; //! @brief Container of input values typedef vector<InputValue> InputValues; //! @brief Apply mode, used by apply() enum ApplyMode { Apply_Reset, //!< Graph inputs not listed in input values are reset Apply_Merge //!< Non concerned graph inputs are not reset }; //! @brief URL of the graph corresponding to this preset //! A preset can be applied to any graph, only input values that match per //! identifier and per type are effectively set. string mPackageUrl; //! @brief Label of this preset (UI) UTF8 format string mLabel; //! @brief Description of this preset (UI) UTF8 format string mDescription; //! @brief List of preset inputs //! Only non default input values are recorded. InputValues mInputValues; //! @brief Apply this preset to a graph instance //! @param graph The target graph instance to apply this preset //! @param mode Reset to default other inputs of merge w/ previous values //! @note In order to load input image defined in the preset, the //! GlobalCallbacks::loadInputImage callback must be defined. //! @return Return true whether at least one input value is applied bool apply(GraphInstance& graph,ApplyMode mode = Apply_Reset) const; //! @brief Fill this preset from a graph instance input values //! @param graph The source graph instance. //! @note In order to serialize input image filepaths, the //! GlobalCallbacks::getImageFilepath callback must be defined. //! //! 'mInputValues' is filled w/ non default input values of 'graph'. //! 'mPackageUrl' is also set. All other members are not modified (label //! and description). void fill(const GraphInstance& graph); }; //! @brief Preset serialization (to UTF8 XML description) stream operator std::ostream& operator<<(std::ostream& os,const Preset& preset); //! @brief Parse preset from a XML preset element (\<sbspreset>) //! @param[out] preset Preset description to fill from XML string //! @param xmlString Pointer on UTF8 Null terminated string that contains //! serialized XML preset element \<sbspreset> //! @return Return whether preset parsing succeed bool parsePreset(Preset &preset,const char* xmlString); //! @brief Container of presets typedef vector<Preset> Presets; //! @brief Presets serialization (to UTF8 XML description) stream operator std::ostream& operator<<(std::ostream& os,const Presets& presets); //! @brief Parse presets from a XML preset file (.SBSPRS) //! @param[out] presets Container filled with loaded presets //! @param xmlString Pointer on UTF8 Null terminated string that contains //! presets XML description //! @return Return whether preset parsing succeed bool parsePresets(Presets &presets,const char* xmlString); } // namespace SubstanceAir #endif //_SUBSTANCE_AIR_FRAMEWORK_PRESET_H
f650b90562530db2340cffcbd1366bb86c131da4
fa7587f9f4a7097d6f449e113cf5906fc3068d53
/master/ServerBase/ServerCommand.cpp
fe0a2d8feabfdc7e98dc4b5ce4b5cd2f3720858c
[]
no_license
cash2one/XStudio
5bb6eb726b8fd7b59614e2af901a353fd17b6d33
77304f932cf634f628eadc4df71a5c4fcd3544eb
refs/heads/master
2021-01-21T16:38:38.645054
2015-12-15T08:50:53
2015-12-15T08:50:53
null
0
0
null
null
null
null
GB18030
C++
false
false
27,196
cpp
#include "stdafx.h" #include "ServerCommand.h" #include "protoevent.h" #include "ServerBase.h" #include <sys/stat.h> #define ECHO_MESSAGE_LENGTH 4096 extern xgc_lpcstr GetConfPath( xgc_lpstr szPath, xgc_size nSize, xgc_lpcstr lpRelativePath, ... ); namespace DebugCommand { /// /// 子指令表 /// [12/29/2014] create by albert.xu /// struct Command { xgc_bool mConfirm; xgc_map < xgc_string, struct Command*, string_case_less > mChildrens; }; /// /// 权限表 /// [12/29/2014] create by albert.xu /// struct Group { xgc_uint32 mLevel; xgc_string mName; struct Command *mCommands; }; /// /// 指令入口信息 /// [12/29/2014] create by albert.xu /// struct CommandInstance { /// @var 配置名 xgc_lpcstr mEntryName; /// @var 配置文件路径 xgc_char mConfigPath[_MAX_PATH]; /// @var 批处理文件路径 xgc_char mScriptPath[_MAX_PATH]; /// @var 权限映射表 xgc_map< xgc_uint32, Group > mGroupMap; /// @var 别名映射表 xgc_map< xgc_string, xgc_string, string_case_less > mAliasMap; /// @var 入口指令表 CommandTable *mEntryTable; /// @var 信息输出回调 fnSendMessage mSendMessage; }; /// /// 缓存信息 /// [12/29/2014] create by zhangyupeng /// struct CommandCache { xgc_string mCmd; xgc_uint32 mUpdateTime; }; /// @var 当前角色 static CommandOperator const * gpCurrent = xgc_nullptr; /// @var 当前指令表实例 static CommandInstance * gpInstance = xgc_nullptr; } /// @var 指令表名映射 static xgc_unordered_map< xgc_string, DebugCommand::CommandInstance* > gCommandInstMap; /// @var 指令表缓存,用来二次确认命令 static xgc_unordered_map< xgc_string, DebugCommand::CommandCache > gCommandInstCache; /// /// 清理指令表 /// [7/29/2015] create by albert.xu /// static xgc_void FiniDebugCmd( DebugCommand::Command* pCommands ); /// /// 读取一条指令权限配置 /// [10/7/2014] create by albert.xu /// static struct DebugCommand::Command* ReadAllCommands( DebugCommand::CommandTable* lpCmdTable, xgc_unordered_map< xgc_string, xgc_bool >& mapConfirm ) { struct DebugCommand::Command *pCommands = XGC_NEW DebugCommand::Command; struct DebugCommand::CommandInfo *pCmdInfo = lpCmdTable->pFirst; pCommands->mConfirm = false; while( pCmdInfo != lpCmdTable->pLast ) { if( pCmdInfo->lpSubCommands ) { // 存在子指令表 struct DebugCommand::Command * pSubCommands = ReadAllCommands( pCmdInfo->lpSubCommands, mapConfirm ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } else { // 不存在子指令表 struct DebugCommand::Command *pSubCommands = XGC_NEW DebugCommand::Command; //只有子指令才会二次确认判断 auto iter = mapConfirm.find( pCmdInfo->lpCmdString ); pSubCommands->mConfirm = ( iter != mapConfirm.end() ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } ++pCmdInfo; } return pCommands; } /// /// 读取一条指令权限配置 /// [10/7/2014] create by albert.xu /// static struct DebugCommand::Command* ReadCommands( CMarkupSTL &xml, DebugCommand::CommandTable* lpCmdTable, xgc_uint32 nLayer, xgc_unordered_map< xgc_string, xgc_bool >& mapConfirm ) { if( false == xml.IntoElem() ) return xgc_nullptr; struct DebugCommand::Command *pCommands = XGC_NEW DebugCommand::Command; pCommands->mConfirm = false; if( xml.FindElem( "cmd" ) ) { do { xgc_string strCmd = xml.GetAttrib( "name" ); // 验证指令是否存在 // 查找输入的指令,这里的匹配算法为头匹配。 // 即,只要有和输入的字符串结束符前的全部匹配则认为匹配。 DebugCommand::CommandInfo* pCmdInfo = std::lower_bound( lpCmdTable->pFirst, lpCmdTable->pLast, strCmd.c_str(), []( const DebugCommand::CommandInfo& lhs, xgc_lpcstr lpCmdString ){ return _stricmp( lhs.lpCmdString, lpCmdString ) < 0; } ); if( pCmdInfo != lpCmdTable->pLast && _stricmp( pCmdInfo->lpCmdString, strCmd.c_str() ) == 0 ) { if( pCmdInfo->lpSubCommands ) { // 存在子指令表 struct DebugCommand::Command * pSubCommands = ReadCommands( xml, pCmdInfo->lpSubCommands, nLayer + 1, mapConfirm ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } else { // 不存在子指令表 struct DebugCommand::Command *pSubCommands = XGC_NEW DebugCommand::Command; //只有子指令才会二次确认判断 auto iter = mapConfirm.find( pCmdInfo->lpCmdString ); pSubCommands->mConfirm = ( iter != mapConfirm.end() ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } } } while( xml.FindElem( "cmd" ) ); } else if( nLayer && lpCmdTable ) { struct DebugCommand::CommandInfo *pCmdInfo = lpCmdTable->pFirst; while( pCmdInfo != lpCmdTable->pLast ) { if( pCmdInfo->lpSubCommands ) { // 存在子指令表 struct DebugCommand::Command * pSubCommands = ReadAllCommands( pCmdInfo->lpSubCommands, mapConfirm ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } else { // 不存在子指令表 struct DebugCommand::Command *pSubCommands = XGC_NEW DebugCommand::Command; //只有子指令才会二次确认判断 auto iter = mapConfirm.find( pCmdInfo->lpCmdString ); pSubCommands->mConfirm = ( iter != mapConfirm.end() ); auto ib = pCommands->mChildrens.insert( std::make_pair( pCmdInfo->lpCmdString, pSubCommands ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的指令名 %s", pCmdInfo->lpCmdString ); if( false == ib.second ) { FiniDebugCmd( pSubCommands ); } } ++pCmdInfo; } } xml.OutOfElem(); return pCommands; } /// /// 清理指令表实例中的数据 /// [12/30/2014] create by albert.xu /// static xgc_void FiniDebugCmd( DebugCommand::Command* pCommands ) { XGC_ASSERT_RETURN( pCommands, XGC_NONE ); for each( auto &it in pCommands->mChildrens ) { FiniDebugCmd( it.second ); } pCommands->mChildrens.clear(); SAFE_DELETE( pCommands ); } /// /// 清理指令表实例中的数据 /// [12/30/2014] create by albert.xu /// static xgc_void FiniDebugCmd( DebugCommand::CommandInstance* pInst ) { XGC_ASSERT_RETURN( pInst, XGC_NONE ); for each( auto it in pInst->mGroupMap ) { FiniDebugCmd( it.second.mCommands ); } pInst->mGroupMap.clear(); pInst->mAliasMap.clear(); } /// /// 重载GM指令配置 /// [12/4/2014] create by albert.xu /// static xgc_bool ReloadDebugCmd( DebugCommand::CommandInstance* pInst ) { FiniDebugCmd( pInst ); CMarkupSTL xml; if( !xml.Load( pInst->mConfigPath ) ) { USR_ERROR( "Load %s failed. error = %s.", pInst->mConfigPath, xml.GetError().c_str() ); return false; } xgc_bool bRet = xml.FindElem( "Groups" ); XGC_ASSERT_RETURN( bRet, false ); xml.IntoElem(); //读取二次确认GM指令表 xgc_unordered_map< xgc_string, xgc_bool > mapConfirm; while( xml.FindElem( "NeedConfirm" ) ) { xgc_string strName = xml.GetAttrib( "name" ); mapConfirm.insert( make_pair( strName, true ) ); } while( xml.FindNode( CMarkupSTL::MNT_ELEMENT ) ) { if( xml.GetTagName() == "Group" ) { xgc_uint32 nLevel = 0; bRet = GetXMLAttribInteger( xml, "level", nLevel ); XGC_ASSERT_CONTINUE( bRet ); xgc_char szName[64] = { 0 }; bRet = GetXMLAttribString( xml, "name", szName, sizeof( szName ) ); XGC_ASSERT_CONTINUE( bRet ); DebugCommand::Group group; group.mLevel = nLevel; group.mName = szName; group.mCommands = ReadCommands( xml, pInst->mEntryTable, 0, mapConfirm ); auto ib = pInst->mGroupMap.insert( std::make_pair( nLevel, group ) ); XGC_ASSERT_MESSAGE( ib.second, "发现重复的权限组标识 %u - %s", nLevel, szName ); if( false == ib.second ) { FiniDebugCmd( group.mCommands ); } } else if( xml.GetTagName() == "Alias" ) { xgc_string strName = xml.GetAttrib( "name" ); xgc_string strCmd = xml.GetAttrib( "cmd" ); if( !strName.empty() && !strCmd.empty() ) pInst->mAliasMap[strName] = strCmd; } } xml.OutOfElem(); return true; } /// /// 初始化指令表 /// [10/7/2014] create by albert.xu /// xgc_bool InitDebugCmd( IniFile &ini ) { FUNCTION_BEGIN; // 遍历所有指令表配置 for( auto pEntry = DebugCommand::GetCommandEntry(); pEntry && pEntry->lpEntryName; ++pEntry ) { xgc_lpcstr lpConfigPath = ini.GetItemValue( "Debug", pEntry->lpEntryName, xgc_nullptr ); xgc_lpcstr lpScriptPath = ini.GetItemValue( "Debug", "ScriptPath", "" ); if( !( lpConfigPath && lpConfigPath[0] ) ) { continue; } // 创建指令表实例 DebugCommand::CommandInstance *pInstance = XGC_NEW DebugCommand::CommandInstance; pInstance->mEntryName = pEntry->lpEntryName; pInstance->mEntryTable = pEntry->lpEntryTable; pInstance->mSendMessage = pEntry->lpEntryPrint; // 此处指令表可以不放在配置文件中 if( xgc_nullptr == GetNormalPath( pInstance->mConfigPath, sizeof( pInstance->mConfigPath ), "%s", lpConfigPath ) ) { SYS_INFO( "%s%s", "调试指令中发现无效的路径配置", lpConfigPath ); SAFE_DELETE( pInstance ); } // 批处理的运行路径 if( xgc_nullptr == GetNormalPath( pInstance->mScriptPath, sizeof( pInstance->mScriptPath ), "%s", lpScriptPath ) ) { SYS_INFO( "%s%s", "调试指令中发现无效的路径配置", lpScriptPath ); SAFE_DELETE( pInstance ); } // 载入指令表配置,包括权限,别名等 if( false == ReloadDebugCmd( pInstance ) ) { SYS_INFO( "%s%s", "载入配置错误。", lpConfigPath ); SAFE_DELETE( pInstance ); FiniDebugCmd(); return false; } // 将指令表和表名进行映射 auto ib = gCommandInstMap.insert( std::make_pair( pEntry->lpEntryName, pInstance ) ); XGC_ASSERT( ib.second ); } return true; FUNCTION_END; return false; } /// /// 重载GM指令配置 /// [12/4/2014] create by albert.xu /// xgc_bool ReloadDebugCmd( xgc_lpcstr lpTableName ) { if( xgc_nullptr == lpTableName ) { for each( auto &it in gCommandInstMap ) { if( false == ReloadDebugCmd( it.second ) ) return false; } return true; } auto it = gCommandInstMap.find( lpTableName ); if( it == gCommandInstMap.end() ) return false; return ReloadDebugCmd( it->second ); } xgc_void FiniDebugCmd() { for each( auto it in gCommandInstMap ) { FiniDebugCmd( it.second ); SAFE_DELETE( it.second ); } gCommandInstMap.clear(); } namespace DebugCommand { static xgc_uint16 OnCmd_Authorised( xgc_size argc, xgc_lpstr const *argv, xgc_bool bConfirmed ) { auto it = gpInstance->mGroupMap.find( gpCurrent->group ); if( it != gpInstance->mGroupMap.end() ) { xgc_uint16 nAuthorised = 0; Command *pCommand = it->second.mCommands; if( pCommand->mChildrens.size() == 0 ) { nAuthorised = -1; return nAuthorised; } while( argc && pCommand->mChildrens.size() ) { if( argv[0][0] != '-' ) { auto itc = pCommand->mChildrens.find( argv[0] ); if( itc == pCommand->mChildrens.end() ) { nAuthorised = -1; break; } //子指令返回是否需要二次确认 if( bConfirmed == false && itc->second->mConfirm ) { nAuthorised = 1; } pCommand = itc->second; } ++argv; --argc; } return nAuthorised; } return -1; } /// /// 发送消息到客户端 /// [8/8/2014] create by albert.xu /// xgc_bool PrintClient( xgc_lpcstr lpFmt, ... ) { if( xgc_nullptr == gpCurrent ) return false; if( xgc_nullptr == gpInstance ) return false; fnSendMessage Print = gpInstance->mSendMessage; if( xgc_nullptr != gpCurrent->print ) Print = gpCurrent->print; if( xgc_nullptr == Print ) return false; xgc_char szMessage[4096]; va_list args; va_start( args, lpFmt ); int cnt = _vsnprintf_s( szMessage, sizeof(szMessage) -1, lpFmt, args ); if( cnt > 0 ) Print( gpCurrent->user, szMessage ); va_end( args ); return true; } /// /// 发送指令帮助到客户端 /// [8/8/2014] create by albert.xu /// xgc_bool PrintUsage( const CommandInfo* pCmdInfo ) { bool bRet = true; bRet = bRet && PrintClient( "%s", pCmdInfo->lpIntroduction ); bRet = bRet && PrintClient( "usage : %s", pCmdInfo->lpUsage ); return bRet; } /// /// 初始化命令行表,对表进行排序。 /// [8/8/2014] create by albert.xu /// xgc_bool InitCmdTable( CommandTable* lpCmdTable ) { std::sort( lpCmdTable->pFirst, lpCmdTable->pLast, []( const CommandInfo& lhs, const CommandInfo& rhs ){ return _stricmp( lhs.lpCmdString, rhs.lpCmdString ) < 0; } ); return true; } /// /// GM指令处理入口 /// [8/8/2014] create by albert.xu /// xgc_bool OnCmd_CommandExec( CommandTable* lpCmdTable, xgc_size argc, xgc_lpstr const *argv ) { while( argc > 0 ) { // 略过指令参数 if( argv[0][0] == '-' ) { ++argv; --argc; continue; } // 查找输入的指令,这里的匹配算法为头匹配。 // 即,只要有和输入的字符串结束符前的全部匹配则认为匹配。 CommandInfo* pCmdInfo = std::lower_bound( lpCmdTable->pFirst, lpCmdTable->pLast, argv[0], []( const CommandInfo& lhs, xgc_lpcstr lpCmdString ){ return _stricmp( lhs.lpCmdString, lpCmdString ) < 0; } ); // 验证是否找到,lower_bound返回等于或者大于 if( pCmdInfo == lpCmdTable->pLast ) break; if( _strnicmp( argv[0], pCmdInfo->lpCmdString, strlen( argv[0] ) ) == 0 ) { // 该指令有额外参数的,则处理参数 if( pCmdInfo->pfnCmd && false == pCmdInfo->pfnCmd( argc, argv, pCmdInfo ) ) return false; // 有子指令表的,继续处理子指令 if( pCmdInfo->lpSubCommands && pCmdInfo->lpSubCommands->bAutoProcess ) { ++argv; --argc; lpCmdTable = pCmdInfo->lpSubCommands; continue; } // 没有子指令表的则返回 true else { return true; } } break; } // 有子指令表,但是没找到指令的,给出最后查找的指令 if( lpCmdTable ) { OnCmd_CommandHelp( lpCmdTable, 0, xgc_nullptr ); } return false; } /// /// 显示帮助 /// [10/9/2014] create by albert.xu /// xgc_bool OnCmd_CommandHelp( CommandTable* lpCmdTable, xgc_size argc, xgc_lpstr const *argv ) { CommandInfo* pCmdInfo = xgc_nullptr; while( argc > 1 ) { pCmdInfo = std::lower_bound( lpCmdTable->pFirst, lpCmdTable->pLast, argv[1], []( const CommandInfo& lhs, xgc_lpcstr lpCmdString ){ return _stricmp( lhs.lpCmdString, lpCmdString ) < 0; } ); // 验证是否找到,lower_bound返回等于或者大于 if( pCmdInfo == lpCmdTable->pLast ) { PrintClient( "请求的指令不存在!" ); break; } ++argv; --argc; lpCmdTable = pCmdInfo->lpSubCommands; if( _strnicmp( argv[0], pCmdInfo->lpCmdString, strlen( argv[0] ) ) == 0 ) { // 没有子指令了,直接显示该语句的帮助 PrintUsage( pCmdInfo ); break; } } if( lpCmdTable ) { // 显示所有子指令及参数帮助 for( CommandInfo* pCmdInfo = lpCmdTable->pFirst; pCmdInfo != lpCmdTable->pLast; ++pCmdInfo ) { PrintClient( "------------------" ); PrintClient( "%s - %s", pCmdInfo->lpCmdString, pCmdInfo->lpIntroduction ); PrintClient( "Usage : %s", pCmdInfo->lpUsage ); } } return true; } /// /// GM指令处理入口 /// [8/8/2014] create by albert.xu /// @param lpConfName 配置名,与配置文件中Debug节里的配置一一对应 /// @param lpCurrent 操作角色 /// @param lpCmdString 指令串 static xgc_bool ProcessDebugCmd( const CommandOperator *lpCurrent, xgc_lpcstr lpCmdString ) { FUNCTION_BEGIN; XGC_ASSERT_RETURN( lpCmdString, false ); xgc_lpcstr lpCmdEnd = lpCmdString; while( *lpCmdEnd && xgc_nullptr == strchr( " ,", *lpCmdEnd ) ) ++lpCmdEnd; xgc_char szCmdString[ECHO_MESSAGE_LENGTH] = { 0 }; // 处理别名 auto it1 = gpInstance->mAliasMap.find( xgc_string( lpCmdString, lpCmdEnd ) ); if( it1 != gpInstance->mAliasMap.end() ) { // 找到别名指令 sprintf_s( szCmdString, "%s%s", it1->second.c_str(), lpCmdEnd ); } else { // 未找到别名 strncpy_s( szCmdString, lpCmdString, xgc_countof( szCmdString ) - 1 ); } gpCurrent = lpCurrent; //缓存指令二次确认,不需要验证权限 xgc_lpcstr lpRoleName = gpCurrent->name ? gpCurrent->name : ""; //验证是否通过 xgc_bool bConfirmed = true; if( stricmp( szCmdString, "y" ) == 0 ) { auto iter = gCommandInstCache.find( lpRoleName ); if( iter == gCommandInstCache.end() ) { PrintClient( "没有缓存的指令。" ); return true; } if( current_time() - iter->second.mUpdateTime > 15 ) { PrintClient( "指令确认超时,请重新输入指令", szCmdString ); gCommandInstCache.erase( iter ); return true; } strncpy_s( szCmdString, iter->second.mCmd.c_str(), sizeof( szCmdString ) ); bConfirmed = true; } xgc_size argc = 0; xgc_lpstr argv[64]; xgc_char szCmdTmpString[ECHO_MESSAGE_LENGTH] = { 0 }; strcpy_s( szCmdTmpString, szCmdString ); xgc_lpstr str = szCmdTmpString; enum state { new_token, match_end, match_quote, match_quote2 }; state s = new_token; do { switch( s ) { case new_token: { if( *str == '\'' ) { s = match_quote; argv[argc++] = ++str; } else if( *str == '\"' ) { s = match_quote2; argv[argc++] = ++str; } else if( !isblank( *str ) && ( isprint( *str ) || _ismbslead( (xgc_byte*) str, (xgc_byte*) str ) ) ) { s = match_end; argv[argc++] = str; } } break; case match_end: if( isblank( *str ) ) { *str = 0; s = new_token; } break; case match_quote: if( *str == '\'' ) { *str = 0; s = match_end; } break; case match_quote2: if( *str == '\"' ) { *str = 0; s = match_end; } break; } } while( argc < xgc_countof( argv ) && *++str ); USR_INFO( "角色请求执行GM指令 Role = %s GM = %d, Execute = %s", lpRoleName, gpCurrent->group, szCmdString ); switch( OnCmd_Authorised( argc, argv, bConfirmed ) ) { case 0: // 验证通过 if( OnCmd_CommandExec( gpInstance->mEntryTable, argc, argv ) ) { PrintClient( "%s", szCmdString ); PrintClient( "指令执行成功!" ); //ADD_EVTLOG UseGmCmdEvent evt = { 0 }; strcpy_s( evt.szRoleName, lpCurrent->name ); strcpy_s( evt.szGmCmd, lpCmdString ); evt.byGmLevel = lpCurrent->group; evt.byresult = 0; LogEvent(MsgUseGmCmdEvent, evt); gCommandInstCache.erase( lpRoleName ); return true; } break; case 1: // 需要二次确认 { //GD指令角色名字为空,不需要二次确认 CommandCache info; info.mCmd = szCmdString; info.mUpdateTime = (xgc_uint32) time( xgc_nullptr ); gCommandInstCache[lpRoleName] = info; PrintClient( "请求指令:%s", szCmdString ); PrintClient( "确认执行请输入 @y " ); //ADD_EVTLOG UseGmCmdEvent evt = { 0 }; strcpy_s( evt.szRoleName, lpCurrent->name ); strcpy_s( evt.szGmCmd, lpCmdString ); evt.byGmLevel = lpCurrent->group; evt.byresult = 1; LogEvent(MsgUseGmCmdEvent, evt); return true; } break; default: { USR_INFO( "指令权限未通过验证。 Role = %s GM = %d", gpCurrent->name, gpCurrent->group ); //ADD_EVTLOG UseGmCmdEvent evt = { 0 }; strcpy_s(evt.szRoleName, lpCurrent->name); strcpy_s( evt.szGmCmd, lpCmdString ); evt.byGmLevel = lpCurrent->group; evt.byresult = -1; LogEvent(MsgUseGmCmdEvent, evt); return false; } break; } return false; FUNCTION_END; return false; } /// /// GM指令处理入口 /// [8/8/2014] create by albert.xu /// @param lpConfName 配置名,与配置文件中Debug节里的配置一一对应 /// @param lpCurrent 操作角色 /// @param lpCmdString 指令串 xgc_bool ProcessDebugCmd( xgc_lpcstr lpConfName, const CommandOperator *lpCurrent, xgc_lpcstr lpCmdString ) { FUNCTION_BEGIN; XGC_ASSERT_RETURN( lpCmdString, false ); auto it0 = gCommandInstMap.find( lpConfName ); if( it0 == gCommandInstMap.end() ) return false; gpInstance = it0->second; XGC_ASSERT_RETURN( gpInstance, false ); return ProcessDebugCmd( lpCurrent, lpCmdString ); FUNCTION_END; return false; } xgc_void GetAlias( xgc_vector< xgc_string >& Container, xgc_lpcstr lpConfName ) { FUNCTION_BEGIN; if( lpConfName ) { auto it0 = gCommandInstMap.find( lpConfName ); if( it0 == gCommandInstMap.end() ) return; gpInstance = it0->second; } if( gpInstance ) { for each( auto &it in gpInstance->mAliasMap ) Container.push_back( it.first + "=" + it.second ); } FUNCTION_END; } xgc_bool GetAlias( const xgc_string &strName, xgc_lpstr lpValue, xgc_size nSize, xgc_lpcstr lpConfName ) { FUNCTION_BEGIN; if( lpConfName ) { auto it0 = gCommandInstMap.find( lpConfName ); if( it0 == gCommandInstMap.end() ) return false; gpInstance = it0->second; } if( gpInstance ) { auto it = gpInstance->mAliasMap.find( strName ); if( it == gpInstance->mAliasMap.end() ) return false; strncpy_s( lpValue, nSize, it->second.c_str(), nSize - 1 ); return true; } FUNCTION_END; return false; } xgc_void SetAlias( const xgc_string &strName, xgc_lpcstr lpValue, xgc_lpcstr lpConfName ) { FUNCTION_BEGIN; if( lpConfName ) { auto it0 = gCommandInstMap.find( lpConfName ); if( it0 == gCommandInstMap.end() ) return; gpInstance = it0->second; } if( gpInstance ) { if( lpValue == xgc_nullptr || lpValue[0] == 0 ) gpInstance->mAliasMap.erase( strName ); else gpInstance->mAliasMap[strName] = lpValue; } FUNCTION_END; } } ////////////////////////////////////////////////////////////////////////// // 框架调试指令表,用于框架调试 ////////////////////////////////////////////////////////////////////////// extern const char* __version__; namespace DebugCommand { /// /// 查看服务器版本号 /// [11/25/2014] create by wuhailin.jerry /// xgc_bool OnCmd_ShowVersion( xgc_size argc, xgc_lpstr const *argv, const CommandInfo* pCmdInfo ) { PrintClient( "%s", __version__ ); return true; } /// /// 查看服务器信息 /// [11/25/2014] create by wuhailin.jerry /// xgc_bool OnCmd_ServerInfo( xgc_size argc, xgc_lpstr const *argv, const CommandInfo* pCmdInfo ) { PrintClient( "server name : %s", GetServerName() ); PrintClient( "server code : %s", GetServerCode() ); xgc_char szPath[_MAX_PATH] = { 0 }; PrintClient( "server path : %s", GetModulePath() ); PrintClient( "server conf : %s", GetConfPath( szPath, sizeof( szPath ), "" ) ); xgc_char szDate[32] = { 0 }; xgc_char szTime[32] = { 0 }; PrintClient( "server date : %s", _strdate( szDate ) ); PrintClient( "server time : %s", _strtime( szTime ) ); return true; } /// /// 设置函数超时检测的超时时间,超时会打印一条日志 /// [11/25/2014] create by wuhailin.jerry /// xgc_bool OnCmd_SetTimeout( xgc_size argc, xgc_lpstr const *argv, const CommandInfo* pCmdInfo ) { if( argc < 2 ) { PrintClient( "Usage : %s", pCmdInfo->lpUsage ); return true; } SetDebugerTimeout( str2numeric< xgc_time32 >( argv[1], xgc_nullptr ) ); return true; } xgc_bool OnCmd_RunBatch( xgc_size argc, xgc_lpstr const *argv, const CommandInfo* pCmdInfo ) { FUNCTION_BEGIN; xgc_char szPath[_MAX_PATH] = { 0 }; if( argc > 1 ) sprintf_s( szPath, "%s\\%s", gpInstance->mScriptPath, argv[1] ); else sprintf_s( szPath, "%s", gpInstance->mScriptPath ); _fullpath( szPath, szPath, sizeof( szPath ) ); struct _stat stat; if( 0 != _stat( szPath, &stat ) ) { PrintClient( "无效的路径或文件名! %s", szPath ); return false; } PrintClient( "%s", szPath ); if( stat.st_mode & _S_IFDIR ) { strcat_s( szPath, "\\*" ); _finddata_t fdata; memset( &fdata, 0, sizeof( fdata ) ); intptr_t fd = _findfirst( szPath, &fdata ); if( fd == -1 ) { PrintClient( "无效的目录!" ); return false; } do { PrintClient( "%s\n", fdata.name ); } while( _findnext( fd, &fdata ) == 0 ); _findclose( fd ); } else if( stat.st_mode & _S_IFREG ) { FILE *fp = xgc_nullptr; fopen_s( &fp, szPath, "r" ); if( xgc_nullptr == fp ) { PrintClient( "批量执行GM指令,打开文件:[%s]失败,dwErr:[%d]", szPath, GetLastError() ); return false; } xgc_char chBuffer[1024] = { 0 }; xgc_size nLen = 0; while( xgc_nullptr != fgets( chBuffer, sizeof( chBuffer ), fp ) ) { if( chBuffer[0] == 0 ) continue; ProcessDebugCmd( gpCurrent, chBuffer ); } fclose( fp ); } return true; FUNCTION_END; return false; } /// /// []中的参数为可选参数 /// <>中的参数为用户输入参数 /// 如 role info [-name <param>],其中'role'为命令,'info'为必填参数, /// '-name <param>'为可选参数其中'aaaaa'为用户需要输入的。 /// 参数间或的关系用'|'分割。如 role teleport <scenename> [<posx> <posy>|<teleport>] /// 参数间顺序关系通过嵌套标识。如 scene info <scenename> [-l <linenumber>] /// 表示单独使用-l参数是非法的,必须与scenename一同使用。 /// static CommandInfo Commands[] = { { "version", OnCmd_ShowVersion, "查看服务器版本号", "version", xgc_nullptr }, { "info", OnCmd_ServerInfo, "查看服务器信息", "info", xgc_nullptr }, { "timeout", OnCmd_SetTimeout, "设置服务器函数超时时间", "timeout <millseconds>", xgc_nullptr }, { "run", OnCmd_RunBatch, "批量处理GM指令", "run <filename>", xgc_nullptr }, }; CommandTable SystemCmdTable = { Commands, Commands + XGC_COUNTOF( Commands ), true }; static xgc_bool gCmdTableInit = InitCmdTable( &SystemCmdTable ); }
2114f8874bcc418c831a11ee0b47701df03762fe
80309f09cad677bef4a41891afea1ecada68951b
/libs/SFML/Audio/Sound.hpp
609a5f113fdfb3eefe90f33801bba830fb092766
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
MuUusta/Hello-GFX
6f307949f512d7c481e2f48f37a15c958299d8d7
c707570207a2db638458352c2de6c03bce5a6759
refs/heads/master
2020-05-25T00:29:53.805524
2019-05-23T23:07:03
2019-05-23T23:07:03
187,533,729
3
0
null
null
null
null
UTF-8
C++
false
false
9,266
hpp
//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2015 Laurent Gomila ([email protected]) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it freely, // subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUND_HPP #define SFML_SOUND_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include <SFML/Audio/Export.hpp> #include <SFML/Audio/SoundSource.hpp> #include <SFML/System/Time.hpp> #include <cstdlib> namespace sf { class SoundBuffer; //////////////////////////////////////////////////////////// /// \brief Regular sound that can be played in the audio environment /// //////////////////////////////////////////////////////////// class SFML_AUDIO_API Sound : public SoundSource { public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// Sound(); //////////////////////////////////////////////////////////// /// \brief Construct the sound with a buffer /// /// \param buffer Sound buffer containing the audio data to play with the sound /// //////////////////////////////////////////////////////////// explicit Sound(const SoundBuffer& buffer); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// Sound(const Sound& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~Sound(); //////////////////////////////////////////////////////////// /// \brief Start or resume playing the sound /// /// This function starts the stream if it was stopped, resumes /// it if it was paused, and restarts it from beginning if it /// was it already playing. /// This function uses its own thread so that it doesn't block /// the rest of the program while the sound is played. /// /// \see pause, stop /// //////////////////////////////////////////////////////////// void play(); //////////////////////////////////////////////////////////// /// \brief Pause the sound /// /// This function pauses the sound if it was playing, /// otherwise (sound already paused or stopped) it has no effect. /// /// \see play, stop /// //////////////////////////////////////////////////////////// void pause(); //////////////////////////////////////////////////////////// /// \brief stop playing the sound /// /// This function stops the sound if it was playing or paused, /// and does nothing if it was already stopped. /// It also resets the playing position (unlike pause()). /// /// \see play, pause /// //////////////////////////////////////////////////////////// void stop(); //////////////////////////////////////////////////////////// /// \brief Set the source buffer containing the audio data to play /// /// It is important to note that the sound buffer is not copied, /// thus the sf::SoundBuffer instance must remain alive as long /// as it is attached to the sound. /// /// \param buffer Sound buffer to attach to the sound /// /// \see getBuffer /// //////////////////////////////////////////////////////////// void setBuffer(const SoundBuffer& buffer); //////////////////////////////////////////////////////////// /// \brief Set whether or not the sound should loop after reaching the end /// /// If set, the sound will restart from beginning after /// reaching the end and so on, until it is stopped or /// setLoop(false) is called. /// The default looping state for sound is false. /// /// \param loop True to play in loop, false to play once /// /// \see getLoop /// //////////////////////////////////////////////////////////// void setLoop(bool loop); //////////////////////////////////////////////////////////// /// \brief Change the current playing position of the sound /// /// The playing position can be changed when the sound is /// either paused or playing. Changing the playing position /// when the sound is stopped has no effect, since playing /// the sound will reset its position. /// /// \param timeOffset New playing position, from the beginning of the sound /// /// \see getPlayingOffset /// //////////////////////////////////////////////////////////// void setPlayingOffset(Time timeOffset); //////////////////////////////////////////////////////////// /// \brief Get the audio buffer attached to the sound /// /// \return Sound buffer attached to the sound (can be NULL) /// //////////////////////////////////////////////////////////// const SoundBuffer* getBuffer() const; //////////////////////////////////////////////////////////// /// \brief Tell whether or not the sound is in loop mode /// /// \return True if the sound is looping, false otherwise /// /// \see setLoop /// //////////////////////////////////////////////////////////// bool getLoop() const; //////////////////////////////////////////////////////////// /// \brief Get the current playing position of the sound /// /// \return Current playing position, from the beginning of the sound /// /// \see setPlayingOffset /// //////////////////////////////////////////////////////////// Time getPlayingOffset() const; //////////////////////////////////////////////////////////// /// \brief Get the current status of the sound (stopped, paused, playing) /// /// \return Current status of the sound /// //////////////////////////////////////////////////////////// Status getStatus() const; //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// Sound& operator =(const Sound& right); //////////////////////////////////////////////////////////// /// \brief Reset the internal buffer of the sound /// /// This function is for internal use only, you don't have /// to use it. It is called by the sf::SoundBuffer that /// this sound uses, when it is destroyed in order to prevent /// the sound from using a dead buffer. /// //////////////////////////////////////////////////////////// void resetBuffer(); private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// const SoundBuffer* m_buffer; ///< Sound buffer bound to the source }; } // namespace sf #endif // SFML_SOUND_HPP //////////////////////////////////////////////////////////// /// \class sf::Sound /// \ingroup audio /// /// sf::Sound is the class to use to play sounds. /// It provides: /// \li Control (play, pause, stop) /// \li Ability to modify output parameters in real-time (pitch, volume, ...) /// \li 3D spatial features (position, attenuation, ...). /// /// sf::Sound is perfect for playing short sounds that can /// fit in memory and require no latency, like foot steps or /// gun shots. For longer sounds, like background musics /// or long speeches, rather see sf::Music (which is based /// on streaming). /// /// In order to work, a sound must be given a buffer of audio /// data to play. Audio data (samples) is stored in sf::SoundBuffer, /// and attached to a sound with the setBuffer() function. /// The buffer object attached to a sound must remain alive /// as long as the sound uses it. Note that multiple sounds /// can use the same sound buffer at the same time. /// /// Usage example: /// \code /// sf::SoundBuffer buffer; /// buffer.loadFromFile("sound.wav"); /// /// sf::Sound sound; /// sound.setBuffer(buffer); /// sound.play(); /// \endcode /// /// \see sf::SoundBuffer, sf::Music /// ////////////////////////////////////////////////////////////
b486e23effe81fe6abf7c29fdfbab61e847baab1
cef637f11c190b0db877ba3fbe5cfbbd84530d28
/Scene.h
1dea9b20d0d0e74fd8f94845d86c51ca12de6980
[]
no_license
Jahze/bearded-robot
d3cb4f7039c107f4642ef2a744b6fed52b5d5838
15395e726e164881c36b867dfe8a499840ce9a42
refs/heads/master
2021-01-17T07:03:46.083490
2016-05-19T21:58:37
2016-05-19T21:58:37
4,499,094
0
0
null
null
null
null
UTF-8
C++
false
false
1,293
h
#pragma once #include <chrono> #include <memory> #include "Geometry.h" class ObjectIterator { public: ObjectIterator(const std::vector<geometry::Object*> & objects) : m_objects(objects) { } bool HasMore() const { return m_cursor < m_objects.size(); } geometry::Object * Next() { assert(HasMore()); return m_objects[m_cursor++]; } private: std::vector<geometry::Object*> m_objects; std::size_t m_cursor = 0; }; class IScene { public: virtual ~IScene() { } virtual void Update(long long ms) = 0; virtual ObjectIterator GetObjects() = 0; }; class SceneDriver { public: SceneDriver(); void Update(bool paused) { std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(time - m_lastTime).count(); if (! paused) m_scenes[m_cursor]->Update(ms); m_lastTime = time; } ObjectIterator GetObjects() { return m_scenes[m_cursor]->GetObjects(); } void Next() { if (++m_cursor == m_scenes.size()) m_cursor = 0; } private: std::vector<std::unique_ptr<IScene>> m_scenes; std::size_t m_cursor = 0; std::chrono::steady_clock::time_point m_lastTime = std::chrono::steady_clock::now(); };
eb1dc3ad8e7817da7cc995e4f834aebe75ac7871
9ef5a4c3f76c6f1a9d5137f4af99a6b10a4975ee
/Block.h
a95bb0c15a959cacb9b3d0ea3c4e9ff8b228acd6
[]
no_license
2016ameng/Don-t-touch-white-block
37cdaa18a0d89b7a151eaa356fc0c9cfe1304eb5
dc525b1c0778ed2c186c8cd2e47c8b28dea0ef67
refs/heads/master
2020-12-30T13:08:18.540456
2017-05-15T11:08:52
2017-05-15T11:08:52
91,328,799
0
0
null
null
null
null
UTF-8
C++
false
false
1,002
h
// // C++ class.hpp // first_cocos // // Created by 董依萌 on 2017/4/27. // // #ifndef C___class_hpp #define C___class_hpp #include <iostream> #include <cocos2d.h> USING_NS_CC; class Block:public Sprite{ private: static Vector<Block*> *blocks; //记录创建Block(块)的数组 int lineIndex;//记录行的索引 public: //获取所有块的方法 static Vector<Block*> *getBlocks(); //静态的创建的方法 static Block* createWithArgs(Color3B color,Size size,std::string label,float fontSize,Color4B textColor); // 初始化的方法 颜色 大小 呈现的字符 字符大小 字符颜色 virtual bool initWithArgs(Color3B color,Size size,std::string label,float fontSize,Color4B textColor); //移除的方法 void removeBlock(); int getLineIndex(); //得到行的索引 void setLineIndex(int LineIndex); //在外界可以设置行的索引 void moveDown(); }; #endif /* C___class_hpp */
22a6e7f0233178d068e128e31d688345439933c2
34d44a9ca7e6eb63495247ed2aed146b55f1c7db
/QuestionAns/d6s3/1782.cc
cd0155aeada8f925efb7d2ad086bdce42a2d9aa9
[]
no_license
sdustlug/OpenJudge
2419c00824f29144864571e1d25c9de1a09350d2
a6550441691470df505f6a971bc9661ced1b0773
refs/heads/master
2023-09-03T11:48:01.041727
2021-10-18T13:47:57
2021-10-18T13:47:57
418,521,703
1
0
null
null
null
null
UTF-8
C++
false
false
1,533
cc
#include <iostream> #include <string> using namespace std; class Animal { protected: string name_; public: Animal(string n) : name_(n) { } virtual void sound() = 0; }; class Duck : public Animal { public: Duck(string n) : Animal(n) { } void sound() { cout << name_ << " is a duck, and it can quack." << endl; } }; class Turkey : public Animal { public: Turkey(string n) : Animal(n) { } void sound() { cout << name_ << " is a turkey, and it can gobble." << endl; } }; class Cock : public Animal { public: Cock(string n) : Animal(n) { } void sound() { cout << name_ << " is a cock, and it can crow." << endl; } }; int main() { int cases; string name; char type; Animal *animal; cin>>cases; for (int i = 0; i < cases; i++) { cin>>name>>type; switch(type) { case 'A': animal = new Duck(name); break; case 'B': animal = new Turkey(name); break; case 'C': animal = new Cock(name); break; } animal->sound(); } return 0; } /************************************************************** Problem: 1782 User: 201901060610 Language: C++ Result: Accepted Time:0 ms Memory:1268 kb ****************************************************************/
951de874ef75cfd985443090f8f99d378becb80e
6c4d4689591cbe71c6a9f023042e68ac94c95202
/FileIO/Binary.cpp
ea0dc0b3a96eb879237aca5497a1c2278f640769
[]
no_license
YunYongWoon/AR_CPP
3345821d3f42dfc49552bccdafc6b31fcb000bf6
6edae5abcd0c758fefd3b93836387c9c7da5a91c
refs/heads/master
2020-04-23T15:54:27.641296
2019-11-02T07:32:16
2019-11-02T07:32:16
171,280,239
0
1
null
null
null
null
UHC
C++
false
false
1,898
cpp
#include <iostream> using namespace std; #define NAME_SIZE 32 #define STUDENT_MAX 3 typedef struct _tagStudent { char strName[NAME_SIZE]; int iNumber; int iKor; int iEng; int iMath; int iTotal; float fAvg; }STUDENT, *PSTUDNET; int main() { /* 파일 만들기 STUDENT tStudent[STUDENT_MAX] = {}; for (int i = 0; i < STUDENT_MAX; i++) { system("cls"); cout << "이름 : "; cin >> tStudent[i].strName; tStudent[i].iNumber = i + 1; cout << "국어 : "; cin >> tStudent[i].iKor; cout << "영어 : "; cin >> tStudent[i].iEng; cout << "수학 : "; cin >> tStudent[i].iMath; tStudent[i].iTotal = tStudent[i].iKor+tStudent[i].iEng +tStudent[i].iMath; tStudent[i].fAvg = tStudent[i].iTotal / 3.f; } int iStudentCount = STUDENT_MAX; FILE* pFile = NULL; fopen_s(&pFile, "Student.std", "wb"); if (pFile) { // 학생수를 저장한다. fwrite(&iStudentCount, 4, 1, pFile); for (int i = 0; i < iStudentCount; i++) { fwrite(&tStudent[i], sizeof(STUDENT), 1, pFile); } } */ int iStudentCount = 0; STUDENT tStudent[STUDENT_MAX] = {}; FILE* pFile = NULL; fopen_s(&pFile, "Student.std", "rb"); if (pFile) { // 저장할때 학생 수를 가장 먼저 저장했시 떄문에 // 학생 수를 먼저 읽어온다. fread(&iStudentCount, 4, 1, pFile); for (int i = 0 ; i < iStudentCount; i++) { fread(&tStudent[i], sizeof(STUDENT), 1, pFile); } fclose(pFile); } // 읽어 온 학생 출력 for (int i = 0; i < iStudentCount; i++) { cout << "이름 : " << tStudent[i].strName << endl; cout << "학번 : " << tStudent[i].iNumber << endl; cout << "국어 : " << tStudent[i].iKor << endl; cout << "영어 : " << tStudent[i].iEng << endl; cout << "수학 : " << tStudent[i].iMath << endl; cout << "총점 : " << tStudent[i].iTotal << endl; cout << "평균 : " << tStudent[i].fAvg << endl << endl; } return 0; }
08eaf33998abe585cb3326910bf6076d40f5ae99
127d1388dd3029b8b903906e6f9a5b878a3d7d85
/labs/lab5/lab5_3_BlakeLevine.cpp
8f1d6f6eeb4b4dc3fd3c1c0a73504e4ab05ead47
[]
no_license
BraveLilToaster/CSC1100
b63c1b7cb48fb4277fac8fb21feadb96cdcc3ff9
54ea5cba75c37217178db975ce4a4c5c482572ac
refs/heads/master
2020-12-24T14:53:07.646740
2015-05-31T03:01:29
2015-05-31T03:01:29
24,171,877
0
0
null
null
null
null
UTF-8
C++
false
false
835
cpp
#include <iostream> #include <iomanip> #include <fstream> using namespace std; int main() { double ticketPrice, numberOfTicketsSold, boxPrice, boxTicketsSold, sidePrice, sideTicketsSold, premPrice, premTicketsSold, gaPrice, gaTicketsSold; ifstream infile; ofstream outfile; infile.open("data.txt"); outfile.open("total.txt"); infile >> boxPrice >> boxTicketsSold; infile >> sidePrice >> sideTicketsSold; infile >> premPrice >> premTicketsSold; infile >> gaPrice >> gaTicketsSold; ticketPrice = boxPrice + sidePrice + premPrice + gaPrice; numberOfTicketsSold = boxTicketsSold + sideTicketsSold + premTicketsSold + gaTicketsSold; outfile << showpoint << fixed << setprecision(2); outfile << ticketPrice << " " << numberOfTicketsSold << endl; infile.close(); outfile.close(); return 0; }
88f57bc5a44df7a4f13f9f42a0985a725f5176f2
cb4dbd8c556242994a63105beebfeae6a6f05e20
/include/imgproc/xf_gaussian_filter.hpp
062d7f75ef4f38c962b83bcc337b885744b915b2
[]
no_license
ros-acceleration-ultra96v2/vitis_common
8b07aac2cb4c64a8d389ede7dd8d22233f26009d
8805009b8b096e2252e3ea7aa23adb5082160622
refs/heads/master
2023-08-10T01:56:21.673998
2021-09-14T08:23:47
2021-09-14T08:23:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
46,576
hpp
/* * Copyright 2019 Xilinx, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _XF_GAUSSIAN_HPP_ #define _XF_GAUSSIAN_HPP_ #ifndef __cplusplus #error C++ is needed to include this header #endif #include "hls_stream.h" #include "../common/xf_common.hpp" #include "../common/xf_utility.hpp" namespace xf { namespace cv { static void weightsghcalculation3x3(float sigma, unsigned char* weights) { // clang-format off #pragma HLS INLINE // clang-format on float cf[3]; float sum = 0; if (sigma <= 0) { sigma = 0.8; } int n = 3; float scale2X = -(1 / ((sigma * sigma) * 2)); for (int i = 0; i < n; i++) { float x = i - ((n - 1) >> 1); float t = expf(scale2X * x * x); cf[i] = (float)t; sum += cf[i]; } sum = 1. / sum; for (int i = 0; i < n; i++) { cf[i] = (float)(cf[i] * sum); weights[i] = ((cf[i] * 256) + 0.5); } } static void weightsghcalculation5x5(float sigma, unsigned char weights[5]) { // clang-format off #pragma HLS INLINE // clang-format on float cf[5]; float sum = 0; if (sigma <= 0) { sigma = 1.1f; } int n = 5; float scale2X = -(1 / ((sigma * sigma) * 2)); for (int i = 0; i < n; i++) { float x = i - ((n - 1) >> 1); float t = expf(scale2X * x * x); cf[i] = (float)t; sum += cf[i]; } sum = 1. / sum; for (int i = 0; i < n; i++) { cf[i] = (float)(cf[i] * sum); weights[i] = ((float)(cf[i] * 256) + 0.5); } } static void weightsghcalculation7x7(float sigma, unsigned char weights[7]) { // clang-format off #pragma HLS INLINE // clang-format on float kval[7][7]; float cf[7]; float sum = 0; if (sigma <= 0) { sigma = 1.4f; } int n = 7; float scale2X = -(1 / ((sigma * sigma) * 2)); for (int i = 0; i < n; i++) { float x = i - ((n - 1) >> 1); float t = expf(scale2X * x * x); cf[i] = (float)t; sum += cf[i]; } sum = 1. / sum; for (int i = 0; i < n; i++) { cf[i] = (float)(cf[i] * sum); weights[i] = (unsigned char)(((float)cf[i] * 256) + 0.5); } } /////////////////////////////////////////weights/////////////////////////////////////////////////// template <int DEPTH> XF_PTNAME(DEPTH) xFapplygaussian3x3(XF_PTNAME(DEPTH) D1, XF_PTNAME(DEPTH) D2, XF_PTNAME(DEPTH) D3, XF_PTNAME(DEPTH) D4, XF_PTNAME(DEPTH) D5, XF_PTNAME(DEPTH) D6, XF_PTNAME(DEPTH) D7, XF_PTNAME(DEPTH) D8, XF_PTNAME(DEPTH) D9, unsigned char* weights) { // clang-format off #pragma HLS INLINE OFF // clang-format on XF_PTNAME(DEPTH) out_pix = 0; unsigned int sum = 0; ap_uint<18> sum1, sum2, sum3; sum2 = (D4 + D6) * weights[0] + D5 * weights[1]; ap_uint<15> sumvalue0 = D1 + D3 + D7 + D9; ap_uint<15> sumvalue1 = D2 + D8; unsigned int value1 = sumvalue0 * weights[0] + sumvalue1 * weights[1]; sum = (value1)*weights[0] + sum2 * weights[1]; unsigned char val = (sum + 32768) >> 16; out_pix = (XF_PTNAME(DEPTH))val; return out_pix; } template <int PLANES, int DEPTH, bool FOR_IMAGE_PYRAMID> XF_PTNAME(DEPTH) xfapplygaussian5x5(XF_PTNAME(DEPTH) * src_buf1, XF_PTNAME(DEPTH) * src_buf2, XF_PTNAME(DEPTH) * src_buf3, XF_PTNAME(DEPTH) * src_buf4, XF_PTNAME(DEPTH) * src_buf5, unsigned char weights[5]) { // clang-format off #pragma HLS INLINE OFF // clang-format on unsigned int sum = 0.0, sumval = 0; unsigned char value = 0; XF_PTNAME(DEPTH) out_pix = 0; ap_uint<10> tmp[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; for (int i = 0, k = 0; i < PLANES; i++, k += 8) { tmp[0] = src_buf1[0].range(k + 7, k) + src_buf1[4].range(k + 7, k); tmp[1] = src_buf2[0].range(k + 7, k) + src_buf2[4].range(k + 7, k); tmp[2] = src_buf3[0].range(k + 7, k) + src_buf3[4].range(k + 7, k); tmp[3] = src_buf4[0].range(k + 7, k) + src_buf4[4].range(k + 7, k); tmp[4] = src_buf5[0].range(k + 7, k) + src_buf5[4].range(k + 7, k); tmp[5] = src_buf1[1].range(k + 7, k) + src_buf1[3].range(k + 7, k); tmp[6] = src_buf2[1].range(k + 7, k) + src_buf2[3].range(k + 7, k); tmp[7] = src_buf3[1].range(k + 7, k) + src_buf3[3].range(k + 7, k); tmp[8] = src_buf4[1].range(k + 7, k) + src_buf4[3].range(k + 7, k); tmp[9] = src_buf5[1].range(k + 7, k) + src_buf5[3].range(k + 7, k); ap_uint<24> tmp_sum[5] = {0, 0, 0, 0, 0}; tmp_sum[0] = (ap_uint<24>)(tmp[0] + tmp[4]) * weights[0] + (ap_uint<24>)(tmp[5] + tmp[9]) * weights[1] + (ap_uint<24>)(src_buf1[2].range(k + 7, k) + src_buf5[2].range(k + 7, k)) * weights[2]; tmp_sum[1] = (ap_uint<24>)(tmp[1] + tmp[3]) * weights[0] + (ap_uint<24>)(tmp[6] + tmp[8]) * weights[1] + (ap_uint<24>)(src_buf2[2].range(k + 7, k) + src_buf4[2].range(k + 7, k)) * weights[2]; tmp_sum[2] = (ap_uint<24>)tmp[2] * weights[0] + (ap_uint<24>)tmp[7] * weights[1] + (ap_uint<24>)src_buf3[2].range(k + 7, k) * weights[2]; sumval = (unsigned int)tmp_sum[0] * weights[0] + tmp_sum[1] * weights[1] + tmp_sum[2] * weights[2]; unsigned short val = ((sumval + 32768) >> 16); if (val >= 255) { value = 255; } else { value = val; } out_pix.range(k + 7, k) = (XF_PTNAME(DEPTH))value; } return out_pix; } template <int PLANES, int DEPTH> XF_PTNAME(DEPTH) xfapplygaussian7x7(XF_PTNAME(DEPTH) * src_buf1, XF_PTNAME(DEPTH) * src_buf2, XF_PTNAME(DEPTH) * src_buf3, XF_PTNAME(DEPTH) * src_buf4, XF_PTNAME(DEPTH) * src_buf5, XF_PTNAME(DEPTH) * src_buf6, XF_PTNAME(DEPTH) * src_buf7, unsigned char weights[7]) { // clang-format off #pragma HLS INLINE OFF // clang-format on XF_PTNAME(DEPTH) out_pix = 0; unsigned long long int sum_val = 0; unsigned short val = 0; for (int c = 0, k = 0; c < PLANES; c++, k += 8) { unsigned long long int sum_value = 0; unsigned int sum = 0.0, sum1 = 0.0, sum2 = 0.0, sum3 = 0.0, sum4 = 0.0, sum5 = 0.0, sum6 = 0.0; sum3 = (unsigned int)(src_buf4[0].range(k + 7, k) + src_buf4[6].range(k + 7, k)) * weights[0] + (src_buf4[1].range(k + 7, k) + src_buf4[5].range(k + 7, k)) * weights[1] + (src_buf4[2].range(k + 7, k) + src_buf4[4].range(k + 7, k)) * weights[2] + src_buf4[3].range(k + 7, k) * weights[3]; sum = (unsigned int)(src_buf1[0].range(k + 7, k) + src_buf1[6].range(k + 7, k) + src_buf7[0].range(k + 7, k) + src_buf7[6].range(k + 7, k)) * weights[0] + (src_buf1[1].range(k + 7, k) + src_buf1[5].range(k + 7, k) + src_buf7[1].range(k + 7, k) + src_buf7[5].range(k + 7, k)) * weights[1] + (src_buf1[2].range(k + 7, k) + src_buf1[4].range(k + 7, k) + src_buf7[2].range(k + 7, k) + src_buf7[4].range(k + 7, k)) * weights[2] + (src_buf1[3].range(k + 7, k) + src_buf7[3].range(k + 7, k)) * weights[3]; sum1 = (unsigned int)(src_buf2[0].range(k + 7, k) + src_buf2[6].range(k + 7, k) + src_buf6[0].range(k + 7, k) + src_buf6[6].range(k + 7, k)) * weights[0] + (src_buf2[1].range(k + 7, k) + src_buf2[5].range(k + 7, k) + src_buf6[1].range(k + 7, k) + src_buf6[5].range(k + 7, k)) * weights[1] + (src_buf2[2].range(k + 7, k) + src_buf2[4].range(k + 7, k) + src_buf6[2].range(k + 7, k) + src_buf6[4].range(k + 7, k)) * weights[2] + (src_buf2[3].range(k + 7, k) + src_buf6[3].range(k + 7, k)) * weights[3]; sum2 = (unsigned int)(src_buf3[0].range(k + 7, k) + src_buf3[6].range(k + 7, k) + src_buf5[0].range(k + 7, k) + src_buf5[6].range(k + 7, k)) * weights[0] + (src_buf3[1].range(k + 7, k) + src_buf3[5].range(k + 7, k) + src_buf5[1].range(k + 7, k) + src_buf5[5].range(k + 7, k)) * weights[1] + (src_buf3[2].range(k + 7, k) + src_buf3[4].range(k + 7, k) + src_buf5[2].range(k + 7, k) + src_buf5[4].range(k + 7, k)) * weights[2] + (src_buf3[3].range(k + 7, k) + src_buf5[3].range(k + 7, k)) * weights[3]; sum_value = (sum)*weights[0] + (sum1)*weights[1] + (sum2)*weights[2] + (sum3)*weights[3]; unsigned short val = ((sum_value + 32768) >> 16); unsigned char value; if (val >= 255) { value = 255; } else { value = val; } out_pix.range(k + 7, k) = (uchar_t)value; } return out_pix; } template <int NPC, int DEPTH, int PLANES> void auGaussian3x3(XF_PTNAME(DEPTH) * OutputValues, XF_PTNAME(DEPTH) * src_buf1, XF_PTNAME(DEPTH) * src_buf2, XF_PTNAME(DEPTH) * src_buf3, unsigned char weights[3]) { // clang-format off #pragma HLS INLINE // clang-format on int p = 0; ap_uint<24> val; Compute_Grad_Loop: for (ap_uint<5> j = 0; j < (XF_NPIXPERCYCLE(NPC)); j++) { // clang-format off #pragma HLS UNROLL // clang-format on for (ap_uint<5> c = 0, k = 0; c < PLANES; c++, k += 8) { // clang-format off #pragma HLS UNROLL // clang-format on val.range(k + 7, k) = xFapplygaussian3x3<DEPTH>( src_buf1[j].range(k + 7, k), src_buf1[j + 1].range(k + 7, k), src_buf1[j + 2].range(k + 7, k), src_buf2[j].range(k + 7, k), src_buf2[j + 1].range(k + 7, k), src_buf2[j + 2].range(k + 7, k), src_buf3[j].range(k + 7, k), src_buf3[j + 1].range(k + 7, k), src_buf3[j + 2].range(k + 7, k), weights); } OutputValues[p] = val; p++; } } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC> void ProcessGaussian3x3(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, XF_SNAME(WORDWIDTH) buf[3][(COLS >> XF_BITSHIFT(NPC))], XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 2], XF_PTNAME(DEPTH) src_buf2[XF_NPIXPERCYCLE(NPC) + 2], XF_PTNAME(DEPTH) src_buf3[XF_NPIXPERCYCLE(NPC) + 2], XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)], XF_SNAME(WORDWIDTH) & P0, uint16_t img_width, uint16_t img_height, uint16_t& shift_x, ap_uint<2> tp, ap_uint<2> mid, ap_uint<2> bottom, ap_uint<13> row, unsigned char* weights, int& read_index, int& write_index) { // clang-format off #pragma HLS INLINE // clang-format on XF_SNAME(WORDWIDTH) buf0, buf1, buf2; uint16_t npc = XF_NPIXPERCYCLE(NPC); ap_uint<5> buf_size = XF_NPIXPERCYCLE(NPC) + 2; Col_Loop: for (ap_uint<13> col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on if (row < img_height) buf[bottom][col] = _src_mat.read(read_index++); // Read data else buf[bottom][col] = 0; buf0 = buf[tp][col]; buf1 = buf[mid][col]; buf2 = buf[bottom][col]; if (NPC == XF_NPPC8) { xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf1[2], buf0, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf2[2], buf1, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf3[2], buf2, 0); } else { src_buf1[2] = buf0; src_buf2[2] = buf1; src_buf3[2] = buf2; } auGaussian3x3<NPC, DEPTH, PLANES>(OutputValues, src_buf1, src_buf2, src_buf3, weights); if (col == 0) { shift_x = 0; P0 = 0; if (NPC == XF_NPPC8) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], P0, 1, (npc - 1), shift_x); } else { P0 = OutputValues[0]; } } else { if (NPC == XF_NPPC8) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], P0, 0, 1, shift_x); } else { P0 = OutputValues[0]; } _out_mat.write(write_index++, P0); shift_x = 0; P0 = 0; if (NPC == XF_NPPC8) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], P0, 1, (npc - 1), shift_x); } else { P0 = OutputValues[0]; } } src_buf1[0] = src_buf1[buf_size - 2]; src_buf1[1] = src_buf1[buf_size - 1]; src_buf2[0] = src_buf2[buf_size - 2]; src_buf2[1] = src_buf2[buf_size - 1]; src_buf3[0] = src_buf3[buf_size - 2]; src_buf3[1] = src_buf3[buf_size - 1]; } // Col_Loop } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC> void xfGaussianFilter3x3(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, uint16_t img_height, uint16_t img_width, unsigned char* weights) { ap_uint<13> row_ind; ap_uint<2> tp, mid, bottom; ap_uint<8> buf_size = XF_NPIXPERCYCLE(NPC) + 2; uint16_t shift_x = 0; ap_uint<13> row, col; int read_index = 0, write_index = 0; XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)]; // clang-format off #pragma HLS ARRAY_PARTITION variable=OutputValues complete dim=1 // clang-format on XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 2] = {0}, src_buf2[XF_NPIXPERCYCLE(NPC) + 2] = {0}, src_buf3[XF_NPIXPERCYCLE(NPC) + 2] = {0}; // clang-format off #pragma HLS ARRAY_PARTITION variable=src_buf1 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf2 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf3 complete dim=1 // clang-format on XF_SNAME(WORDWIDTH) P0; XF_SNAME(WORDWIDTH) buf[3][(COLS >> XF_BITSHIFT(NPC))]; // clang-format off #pragma HLS RESOURCE variable=buf core=RAM_S2P_BRAM #pragma HLS ARRAY_PARTITION variable=buf complete dim=1 // clang-format on row_ind = 1; Clear_Row_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on //#pragma HLS LOOP_FLATTEN off buf[0][col] = 0; buf[row_ind][col] = _src_mat.read(read_index++); // data[read_index++]; } row_ind++; Row_Loop: for (row = 1; row < img_height + 1; row++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=ROWS max=ROWS // clang-format on if (row_ind == 2) { tp = 0; mid = 1; bottom = 2; } else if (row_ind == 0) { tp = 1; mid = 2; bottom = 0; } else if (row_ind == 1) { tp = 2; mid = 0; bottom = 1; } src_buf1[0] = src_buf1[1] = 0; src_buf2[0] = src_buf2[1] = 0; src_buf3[0] = src_buf3[1] = 0; P0 = 0; ProcessGaussian3x3<SRC_T, ROWS, COLS, PLANES, DEPTH, NPC, WORDWIDTH, TC>( _src_mat, _out_mat, buf, src_buf1, src_buf2, src_buf3, OutputValues, P0, img_width, img_height, shift_x, tp, mid, bottom, row, weights, read_index, write_index); if ((NPC == XF_NPPC8) || (NPC == XF_NPPC16)) { OutputValues[0] = xFapplygaussian3x3<DEPTH>(src_buf1[buf_size - 2], src_buf1[buf_size - 1], 0, src_buf2[buf_size - 2], src_buf2[buf_size - 1], 0, src_buf3[buf_size - 2], src_buf3[buf_size - 1], 0, weights); } else { ap_uint<24> out_val1; for (int i = 0, k = 0; i < PLANES; i++, k += 8) { ap_uint<8> srcbuf10 = src_buf1[buf_size - 3].range(k + 7, k); ap_uint<8> srcbuf11 = src_buf1[buf_size - 2].range(k + 7, k); ap_uint<8> srcbuf20 = src_buf2[buf_size - 3].range(k + 7, k); ap_uint<8> srcbuf21 = src_buf2[buf_size - 2].range(k + 7, k); ap_uint<8> srcbuf30 = src_buf3[buf_size - 3].range(k + 7, k); ap_uint<8> srcbuf31 = src_buf3[buf_size - 2].range(k + 7, k); out_val1.range(k + 7, k) = xFapplygaussian3x3<DEPTH>(srcbuf10, srcbuf11, 0, srcbuf20, srcbuf21, 0, srcbuf30, srcbuf31, 0, weights); } OutputValues[0] = out_val1; } if (NPC == XF_NPPC8) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], P0, 0, 1, shift_x); } else { P0 = OutputValues[0]; } _out_mat.write(write_index++, P0); // data[write_index++] = (P0); shift_x = 0; P0 = 0; row_ind++; if (row_ind == 3) { row_ind = 0; } } // Row_Loop } template <int NPC, int DEPTH, int PLANES, bool FOR_IMAGE_PYRAMID> void xFGaussian5x5(XF_PTNAME(DEPTH) * OutputValues, XF_PTNAME(DEPTH) * src_buf1, XF_PTNAME(DEPTH) * src_buf2, XF_PTNAME(DEPTH) * src_buf3, XF_PTNAME(DEPTH) * src_buf4, XF_PTNAME(DEPTH) * src_buf5, unsigned char weights[5]) { // clang-format off #pragma HLS INLINE // clang-format on XF_PTNAME(DEPTH) val = 0, p = 0; Compute_Grad_Loop: for (ap_uint<5> j = 0; j < XF_NPIXPERCYCLE(NPC); j++) { OutputValues[j] = xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID>(&src_buf1[j], &src_buf2[j], &src_buf3[j], &src_buf4[j], &src_buf5[j], weights); } } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC, bool FOR_IMAGE_PYRAMID> void ProcessGaussian5x5(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, XF_SNAME(WORDWIDTH) buf[5][(COLS >> XF_BITSHIFT(NPC))], XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 4], XF_PTNAME(DEPTH) src_buf2[XF_NPIXPERCYCLE(NPC) + 4], XF_PTNAME(DEPTH) src_buf3[XF_NPIXPERCYCLE(NPC) + 4], XF_PTNAME(DEPTH) src_buf4[XF_NPIXPERCYCLE(NPC) + 4], XF_PTNAME(DEPTH) src_buf5[XF_NPIXPERCYCLE(NPC) + 4], XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)], XF_SNAME(WORDWIDTH) & inter_valx, uint16_t img_width, uint16_t img_height, ap_uint<13> row_ind, uint16_t& shift_x, ap_uint<4> tp1, ap_uint<4> tp2, ap_uint<4> mid, ap_uint<4> bottom1, ap_uint<4> bottom2, ap_uint<13> row, unsigned char weights[5], int& read_index, int& write_index) { // clang-format off #pragma HLS INLINE // clang-format on XF_SNAME(WORDWIDTH) buf0, buf1, buf2, buf3, buf4; ap_uint<8> buf_size = XF_NPIXPERCYCLE(NPC) + 4; uint16_t npc = XF_NPIXPERCYCLE(NPC); ap_uint<8> max_loop = XF_WORDDEPTH(WORDWIDTH); ap_uint<8> step = XF_PIXELDEPTH(DEPTH); Col_Loop: for (ap_uint<13> col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on if (row < img_height) buf[row_ind][col] = _src_mat.read(read_index++); //.data[read_index++]; else buf[bottom2][col] = 0; buf0 = buf[tp1][col]; buf1 = buf[tp2][col]; buf2 = buf[mid][col]; buf3 = buf[bottom1][col]; buf4 = buf[bottom2][col]; if (NPC == XF_NPPC8) { xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf1[4], buf0, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf2[4], buf1, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf3[4], buf2, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf4[4], buf3, 0); xfExtractPixels<NPC, WORDWIDTH, DEPTH>(&src_buf5[4], buf4, 0); } else { src_buf1[4] = buf0; src_buf2[4] = buf1; src_buf3[4] = buf2; src_buf4[4] = buf3; src_buf5[4] = buf4; } xFGaussian5x5<NPC, DEPTH, PLANES, FOR_IMAGE_PYRAMID>(OutputValues, src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, weights); for (ap_uint<4> i = 0; i < 4; i++) { // clang-format off #pragma HLS unroll // clang-format on src_buf1[i] = src_buf1[buf_size - (4 - i)]; src_buf2[i] = src_buf2[buf_size - (4 - i)]; src_buf3[i] = src_buf3[buf_size - (4 - i)]; src_buf4[i] = src_buf4[buf_size - (4 - i)]; src_buf5[i] = src_buf5[buf_size - (4 - i)]; } if (col == 0) { shift_x = 0; inter_valx = 0; xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 2, (npc - 2), shift_x); } else { if (NPC == XF_NPPC8) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 0, 2, shift_x); _out_mat.write(write_index++, inter_valx); shift_x = 0; inter_valx = 0; xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 2, (npc - 2), shift_x); } else { if (col >= 2) { if (PLANES == 1) { inter_valx((max_loop - 1), (max_loop - 8)) = OutputValues[0]; _out_mat.write(write_index++, inter_valx); } else { // _out_mat.data[write_index++] = //(OutputValues[0]); _out_mat.write(write_index++, OutputValues[0]); } } } } } // Col_Loop } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC, bool FOR_IMAGE_PYRAMID> void xFGaussianFilter5x5(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, uint16_t img_height, uint16_t img_width, unsigned char weights[5]) { ap_uint<13> row_ind; ap_uint<13> row, col; ap_uint<4> tp1, tp2, mid, bottom1, bottom2; ap_uint<5> i; ap_uint<5> buf_size = XF_NPIXPERCYCLE(NPC) + 4; ap_uint<9> step = XF_PIXELDEPTH(DEPTH); ap_uint<9> max_loop = XF_WORDDEPTH(WORDWIDTH); uint16_t shift_x = 0; ap_uint<8> npc = XF_NPIXPERCYCLE(NPC); int read_index = 0, write_index = 0; XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)]; // clang-format off #pragma HLS ARRAY_PARTITION variable=OutputValues complete dim=1 // clang-format on XF_SNAME(WORDWIDTH) buf0, buf1, buf2, buf3, buf4; XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 4], src_buf2[XF_NPIXPERCYCLE(NPC) + 4], src_buf3[XF_NPIXPERCYCLE(NPC) + 4], src_buf4[XF_NPIXPERCYCLE(NPC) + 4], src_buf5[XF_NPIXPERCYCLE(NPC) + 4]; // clang-format off #pragma HLS ARRAY_PARTITION variable=src_buf1 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf2 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf3 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf4 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf5 complete dim=1 // clang-format on XF_SNAME(WORDWIDTH) tmp_in; XF_SNAME(WORDWIDTH) inter_valx = 0; XF_SNAME(WORDWIDTH) buf[5][(COLS >> XF_BITSHIFT(NPC))]; // clang-format off #pragma HLS RESOURCE variable=buf core=RAM_S2P_BRAM #pragma HLS ARRAY_PARTITION variable=buf complete dim=1 // clang-format on row_ind = 2; Clear_Row_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on buf[0][col] = 0; buf[1][col] = 0; buf[row_ind][col] = _src_mat.read(read_index++); //.data[read_index++]; } row_ind++; Read_Row2_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on buf[row_ind][col] = _src_mat.read(read_index++); //_src_mat.data[read_index++]; } row_ind++; Row_Loop: for (row = 2; row < img_height + 2; row++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=ROWS max=ROWS // clang-format on // modify the buffer indices to re use if (row_ind == 4) { tp1 = 0; tp2 = 1; mid = 2; bottom1 = 3; bottom2 = 4; } else if (row_ind == 0) { tp1 = 1; tp2 = 2; mid = 3; bottom1 = 4; bottom2 = 0; } else if (row_ind == 1) { tp1 = 2; tp2 = 3; mid = 4; bottom1 = 0; bottom2 = 1; } else if (row_ind == 2) { tp1 = 3; tp2 = 4; mid = 0; bottom1 = 1; bottom2 = 2; } else if (row_ind == 3) { tp1 = 4; tp2 = 0; mid = 1; bottom1 = 2; bottom2 = 3; } src_buf1[0] = src_buf1[1] = src_buf1[2] = src_buf1[3] = 0; src_buf2[0] = src_buf2[1] = src_buf2[2] = src_buf2[3] = 0; src_buf3[0] = src_buf3[1] = src_buf3[2] = src_buf3[3] = 0; src_buf4[0] = src_buf4[1] = src_buf4[2] = src_buf4[3] = 0; src_buf5[0] = src_buf5[1] = src_buf5[2] = src_buf5[3] = 0; inter_valx = 0; ProcessGaussian5x5<SRC_T, ROWS, COLS, PLANES, DEPTH, NPC, WORDWIDTH, TC, FOR_IMAGE_PYRAMID>( _src_mat, _out_mat, buf, src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, OutputValues, inter_valx, img_width, img_height, row_ind, shift_x, tp1, tp2, mid, bottom1, bottom2, row, weights, read_index, write_index); if ((NPC == XF_NPPC8) || (NPC == XF_NPPC16)) { for (ap_uint<6> i = 4; i < (XF_NPIXPERCYCLE(NPC) + 4); i++) { src_buf1[i] = 0; src_buf2[i] = 0; src_buf3[i] = 0; src_buf4[i] = 0; src_buf5[i] = 0; } OutputValues[0] = xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID>( &src_buf1[0], &src_buf2[0], &src_buf3[0], &src_buf4[0], &src_buf5[0], weights); OutputValues[1] = xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID>( &src_buf1[1], &src_buf2[1], &src_buf3[1], &src_buf4[1], &src_buf5[1], weights); xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 0, 2, shift_x); //_out_mat.data[write_index++] = (inter_valx); _out_mat.write(write_index++, inter_valx); } else { // clang-format off #pragma HLS ALLOCATION function instances=xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID> limit=1 // clang-format on src_buf1[buf_size - 1] = 0; src_buf2[buf_size - 1] = 0; src_buf3[buf_size - 1] = 0; src_buf4[buf_size - 1] = 0; src_buf5[buf_size - 1] = 0; OutputValues[0] = xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID>( &src_buf1[0], &src_buf2[0], &src_buf3[0], &src_buf4[0], &src_buf5[0], weights); inter_valx((max_loop - 1), (max_loop - step)) = OutputValues[0]; _out_mat.write(write_index++, inter_valx); for (ap_uint<4> i = 0; i < 4; i++) { // clang-format off #pragma HLS unroll // clang-format on src_buf1[i] = src_buf1[buf_size - (4 - i)]; src_buf2[i] = src_buf2[buf_size - (4 - i)]; src_buf3[i] = src_buf3[buf_size - (4 - i)]; src_buf4[i] = src_buf4[buf_size - (4 - i)]; src_buf5[i] = src_buf5[buf_size - (4 - i)]; } OutputValues[0] = xfapplygaussian5x5<PLANES, DEPTH, FOR_IMAGE_PYRAMID>( &src_buf1[0], &src_buf2[0], &src_buf3[0], &src_buf4[0], &src_buf5[0], weights); inter_valx((max_loop - 1), (max_loop - step)) = OutputValues[0]; _out_mat.write(write_index++, inter_valx); } row_ind++; if (row_ind == 5) { row_ind = 0; } } // Row_Loop } template <int NPC, int DEPTH, int PLANES> void xFGaussian7x7(XF_PTNAME(DEPTH) * OutputValues, XF_PTNAME(DEPTH) * src_buf1, XF_PTNAME(DEPTH) * src_buf2, XF_PTNAME(DEPTH) * src_buf3, XF_PTNAME(DEPTH) * src_buf4, XF_PTNAME(DEPTH) * src_buf5, XF_PTNAME(DEPTH) * src_buf6, XF_PTNAME(DEPTH) * src_buf7, unsigned char weights[7]) { // clang-format off #pragma HLS INLINE // clang-format on for (ap_uint<9> j = 0; j < XF_NPIXPERCYCLE(NPC); j++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=8 max=8 #pragma HLS UNROLL // clang-format on // for(ap_uint<8> c=0,k=0;c<PLANES;c++,k+=8) // { OutputValues[j] = xfapplygaussian7x7<PLANES, DEPTH>(&src_buf1[j], &src_buf2[j], &src_buf3[j], &src_buf4[j], &src_buf5[j], &src_buf6[j], &src_buf7[j], weights); // } } } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC> void ProcessGaussian7x7(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, XF_SNAME(WORDWIDTH) buf[7][(COLS >> XF_BITSHIFT(NPC))], XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf2[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf3[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf4[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf5[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf6[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) src_buf7[XF_NPIXPERCYCLE(NPC) + 6], XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)], XF_SNAME(WORDWIDTH) & inter_valx, uint16_t img_width, uint16_t img_height, uint16_t& shiftx, ap_uint<4> tp1, ap_uint<4> tp2, ap_uint<4> tp3, ap_uint<4> mid, ap_uint<4> bottom1, ap_uint<4> bottom2, ap_uint<4> bottom3, ap_uint<13> row_index, unsigned char weights[7], int& read_index, int& write_index) { // clang-format off #pragma HLS INLINE // clang-format on XF_SNAME(WORDWIDTH) buf0, buf1, buf2, buf3, buf4, buf5, buf6; uint16_t npc = XF_NPIXPERCYCLE(NPC); ap_uint<10> max_loop = XF_WORDDEPTH(WORDWIDTH); Col_Loop: for (ap_uint<13> col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on if (row_index < img_height) buf[bottom3][col] = _src_mat.read(read_index++); //_src_mat.data[read_index++]; else buf[bottom3][col] = 0; buf0 = buf[tp1][col]; buf1 = buf[tp2][col]; buf2 = buf[tp3][col]; buf3 = buf[mid][col]; buf4 = buf[bottom1][col]; buf5 = buf[bottom2][col]; buf6 = buf[bottom3][col]; if (NPC == XF_NPPC8) { xfExtractData<NPC, WORDWIDTH, DEPTH>(src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, src_buf6, src_buf7, buf0, buf1, buf2, buf3, buf4, buf5, buf6); } else { src_buf1[6] = buf0; src_buf2[6] = buf1; src_buf3[6] = buf2; src_buf4[6] = buf3; src_buf5[6] = buf4; src_buf6[6] = buf5; src_buf7[6] = buf6; } xFGaussian7x7<NPC, DEPTH, PLANES>(OutputValues, src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, src_buf6, src_buf7, weights); xfCopyData<NPC, DEPTH>(src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, src_buf6, src_buf7); if (col == 0) { shiftx = 0; inter_valx = 0; xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 3, (npc - 3), shiftx); } else { if ((NPC == XF_NPPC8) || (NPC == XF_NPPC16)) { xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 0, 3, shiftx); // _out_mat.data[write_index++] = (inter_valx); _out_mat.write(write_index++, inter_valx); shiftx = 0; inter_valx = 0; xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 3, (npc - 3), shiftx); } else { if (col >= 3) { if (PLANES == 1) { inter_valx((max_loop - 1), (max_loop - 8)) = OutputValues[0]; //_out_mat.data[write_index++] = (inter_valx); _out_mat.write(write_index++, inter_valx); } else { // _out_mat.data[write_index++] = //(OutputValues[0]); _out_mat.write(write_index++, OutputValues[0]); } } } } } // Col_Loop } template <int SRC_T, int ROWS, int COLS, int PLANES, int DEPTH, int NPC, int WORDWIDTH, int TC> void xFGaussianFilter7x7(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _out_mat, uint16_t img_height, uint16_t img_width, unsigned char weights[7]) { ap_uint<13> row_ind, row, col; ap_uint<4> tp1, tp2, tp3, mid, bottom1, bottom2, bottom3; ap_uint<5> i; ap_uint<8> buf_size = (XF_NPIXPERCYCLE(NPC) + 6); ap_uint<10> max_loop = XF_WORDDEPTH(WORDWIDTH); int read_index = 0, write_index = 0; XF_PTNAME(DEPTH) OutputValues[XF_NPIXPERCYCLE(NPC)]; // clang-format off #pragma HLS ARRAY_PARTITION variable=OutputValues complete dim=1 // clang-format on // Temporary buffers to hold image data from three rows. XF_PTNAME(DEPTH) src_buf1[XF_NPIXPERCYCLE(NPC) + 6], src_buf2[XF_NPIXPERCYCLE(NPC) + 6], src_buf3[XF_NPIXPERCYCLE(NPC) + 6], src_buf4[XF_NPIXPERCYCLE(NPC) + 6], src_buf5[XF_NPIXPERCYCLE(NPC) + 6]; XF_PTNAME(DEPTH) src_buf6[XF_NPIXPERCYCLE(NPC) + 6], src_buf7[XF_NPIXPERCYCLE(NPC) + 6]; // clang-format off #pragma HLS ARRAY_PARTITION variable=src_buf1 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf2 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf3 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf4 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf5 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf6 complete dim=1 #pragma HLS ARRAY_PARTITION variable=src_buf7 complete dim=1 // clang-format on XF_SNAME(WORDWIDTH) inter_valx = 0; uint16_t shiftx = 0; XF_SNAME(WORDWIDTH) buf[7][(COLS >> XF_BITSHIFT(NPC))]; // clang-format off #pragma HLS RESOURCE variable=buf core=RAM_S2P_BRAM #pragma HLS ARRAY_PARTITION variable=buf complete dim=1 // clang-format on row_ind = 3; Clear_Row_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on buf[0][col] = 0; buf[1][col] = 0; buf[2][col] = 0; buf[row_ind][col] = _src_mat.read(read_index++); // data[read_index++]; } row_ind++; Read_Row1_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on buf[row_ind][col] = _src_mat.read(read_index++); //_src_mat.data[read_index++]; } row_ind++; Read_Row2_Loop: for (col = 0; col < img_width; col++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=TC max=TC #pragma HLS pipeline // clang-format on buf[row_ind][col] = _src_mat.read(read_index++); //_src_mat.data[read_index++]; } row_ind++; Row_Loop: for (row = 3; row < img_height + 3; row++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=ROWS max=ROWS // clang-format on // modify the buffer indices to re use if (row_ind == 0) { tp1 = 1; tp2 = 2; tp3 = 3; mid = 4; bottom1 = 5; bottom2 = 6; bottom3 = 0; } else if (row_ind == 1) { tp1 = 2; tp2 = 3; tp3 = 4; mid = 5; bottom1 = 6; bottom2 = 0; bottom3 = 1; } else if (row_ind == 2) { tp1 = 3; tp2 = 4; tp3 = 5; mid = 6; bottom1 = 0; bottom2 = 1; bottom3 = 2; } else if (row_ind == 3) { tp1 = 4; tp2 = 5; tp3 = 6; mid = 0; bottom1 = 1; bottom2 = 2; bottom3 = 3; } else if (row_ind == 4) { tp1 = 5; tp2 = 6; tp3 = 0; mid = 1; bottom1 = 2; bottom2 = 3; bottom3 = 4; } else if (row_ind == 5) { tp1 = 6; tp2 = 0; tp3 = 1; mid = 2; bottom1 = 3; bottom2 = 4; bottom3 = 5; } else if (row_ind == 6) { tp1 = 0; tp2 = 1; tp3 = 2; mid = 3; bottom1 = 4; bottom2 = 5; bottom3 = 6; } for (i = 0; i < 6; i++) { // clang-format off #pragma HLS unroll // clang-format on src_buf1[i] = 0; src_buf2[i] = 0; src_buf3[i] = 0; src_buf4[i] = 0; src_buf5[i] = 0; src_buf6[i] = 0; src_buf7[i] = 0; } inter_valx = 0; ProcessGaussian7x7<SRC_T, ROWS, COLS, PLANES, DEPTH, NPC, WORDWIDTH, TC>( _src_mat, _out_mat, buf, src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, src_buf6, src_buf7, OutputValues, inter_valx, img_width, img_height, shiftx, tp1, tp2, tp3, mid, bottom1, bottom2, bottom3, row, weights, read_index, write_index); if ((NPC == XF_NPPC8) || (NPC == XF_NPPC16)) { for (i = 0; i < 8; i++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=8 max=8 #pragma HLS unroll // clang-format on src_buf1[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf2[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf3[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf4[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf5[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf6[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; src_buf7[buf_size + i - (XF_NPIXPERCYCLE(NPC))] = 0; } for (i = 0; i < 3; i++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=3 max=3 #pragma HLS unroll // clang-format on OutputValues[i] = xfapplygaussian7x7<PLANES, DEPTH>(&src_buf1[i], &src_buf2[i], &src_buf3[i], &src_buf4[i], &src_buf5[i], &src_buf6[i], &src_buf7[i], weights); } xfPackPixels<NPC, WORDWIDTH, DEPTH>(&OutputValues[0], inter_valx, 0, 3, shiftx); //_out_mat.data[write_index++] = (inter_valx); _out_mat.write(write_index++, inter_valx); shiftx = 0; inter_valx = 0; } else { src_buf1[6] = 0; src_buf2[6] = 0; src_buf3[6] = 0; src_buf4[6] = 0; src_buf5[6] = 0; src_buf6[6] = 0; src_buf7[6] = 0; for (i = 0; i < 3; i++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=3 max=3 #pragma HLS unroll #pragma HLS ALLOCATION function instances=xfapplygaussian7x7<PLANES, DEPTH> limit=1 // clang-format on OutputValues[0] = xfapplygaussian7x7<PLANES, DEPTH>(&src_buf1[0], &src_buf2[0], &src_buf3[0], &src_buf4[0], &src_buf5[0], &src_buf6[0], &src_buf7[0], weights); xfCopyData<NPC, DEPTH>(src_buf1, src_buf2, src_buf3, src_buf4, src_buf5, src_buf6, src_buf7); if (PLANES == 1) { inter_valx((max_loop - 1), (max_loop - 8)) = OutputValues[0]; // _out_mat.data[write_index++] = (inter_valx); _out_mat.write(write_index++, inter_valx); } else { // _out_mat.data[write_index++] = ( OutputValues[0]); _out_mat.write(write_index++, OutputValues[0]); } } } row_ind++; if (row_ind == 7) { row_ind = 0; } } // Row_Loop ends here } /* template<int ROWS, int COLS,int PLANES, int DEPTH, int NPC, int WORDWIDTH> void xFGaussianFilter(hls::stream< XF_SNAME(WORDWIDTH)> &_src, hls::stream< XF_SNAME(WORDWIDTH) > &_dst, int _filter_width, int _border_type, uint16_t imgheight, uint16_t imgwidth, float sigma) { }*/ template <int FILTER_SIZE, int BORDER_TYPE, int SRC_T, int ROWS, int COLS, int NPC = 1> void GaussianBlur(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src, xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _dst, float sigma) { // clang-format off #pragma HLS inline off // clang-format on int imgwidth = _src.cols >> XF_BITSHIFT(NPC); if (FILTER_SIZE == XF_FILTER_3X3) { unsigned char weights[3]; // clang-format off #pragma HLS ARRAY_PARTITION variable=weights complete dim=1 // clang-format on weightsghcalculation3x3(sigma, weights); xfGaussianFilter3x3<SRC_T, ROWS, COLS, XF_CHANNELS(SRC_T, NPC), XF_DEPTH(SRC_T, NPC), NPC, XF_WORDWIDTH(SRC_T, NPC), (COLS >> XF_BITSHIFT(NPC))>(_src, _dst, _src.rows, imgwidth, weights); } else if (FILTER_SIZE == XF_FILTER_5X5) { unsigned char weights[5]; // clang-format off #pragma HLS ARRAY_PARTITION variable=weights complete dim=1 // clang-format on weightsghcalculation5x5(sigma, weights); xFGaussianFilter5x5<SRC_T, ROWS, COLS, XF_CHANNELS(SRC_T, NPC), XF_DEPTH(SRC_T, NPC), NPC, XF_WORDWIDTH(SRC_T, NPC), (COLS >> XF_BITSHIFT(NPC)), false>(_src, _dst, _src.rows, imgwidth, weights); } else if (FILTER_SIZE == XF_FILTER_7X7) { unsigned char weights[7]; // clang-format off #pragma HLS ARRAY_PARTITION variable=weights complete dim=1 // clang-format on weightsghcalculation7x7(sigma, weights); xFGaussianFilter7x7<SRC_T, ROWS, COLS, XF_CHANNELS(SRC_T, NPC), XF_DEPTH(SRC_T, NPC), NPC, XF_WORDWIDTH(SRC_T, NPC), (COLS >> XF_BITSHIFT(NPC))>(_src, _dst, _src.rows, imgwidth, weights); } } } // namespace cv } // namespace xf #endif //_XF_GAUSSIAN_HPP_
38885f47ddd33d9542c94e7f9fe099795d88f853
c97ada305c2fe22e4b2308c2081cbb9e1da243ac
/display_effects_noritake/display_effects_noritake.ino
4a97ba96d41357b36db814d3f383503a4e77de8a
[ "MIT" ]
permissive
sergiosagu/arduino
14400e3ab30c08d81beaa65d49f6067899bc410a
c55a06c112e873e22a63cdeb7f9e633cf0d09c01
refs/heads/master
2021-01-21T14:40:21.596623
2020-07-04T07:36:58
2020-07-04T07:36:58
57,067,485
1
0
null
null
null
null
UTF-8
C++
false
false
7,330
ino
// arduino digital pins const byte SCLK = 8; const byte DATA = 9; const byte RSET = 10; // MAGIC NUMBERS const byte BRIGHTNESS_MASK = B11100000; const byte COUNTER_MASK = B11000000; const byte POINTER_MASK = B10100000; const byte COUNTER_CONTROL = COUNTER_MASK | 0; // # of chars (0 = all) const byte POINTER_CONTROL = POINTER_MASK | 15; // start from the left const byte RESET_DELAY = 2; // millis const byte CHAR_DELAY = 125; // millis const byte BIT_DELAY = 2; // micros const byte HIGH_DELAY = 10; // micros const byte LOW_DELAY = 5; // micros // CONSTANTS const byte BRIGHTNESS_MIN = 0; // 0 = 0%, 1 = 3% const byte BRIGHTNESS_MAX = 25; // 25 = 80%, 31 = 100% const String BLANK_CHAR = " "; const String BLANK_DISPLAY = " "; const byte DISPLAY_SIZE = 16; const byte SLIDE_DELAY = 125; // millis const byte FADE_DELAY = 10; // millis const byte BLINK_DELAY = 250; // millis const byte CRACK_DELAY = 50; // millis const byte CRACK_NOISE = 4; // # of rounds per char const byte TERM_DELAY = 125; // millis const byte TERM_BLINK = 4; // # of cursor blinks /* * Main */ void setup() { pinMode(SCLK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(RSET, OUTPUT); reset(); writeByte(COUNTER_CONTROL); writeByte(POINTER_CONTROL); setBrightness(BRIGHTNESS_MAX); randomSeed(analogRead(0)); } void loop() { demo(); } void demo() { String txt = "Quick Demo"; String msg = alignCenter(txt); pause(1); fadeIn(msg); print(msg, 2000, BRIGHTNESS_MAX); fadeOut(msg); pause(1); slideLeft(txt); slideRight(txt); pause(1); for (int i = 0; i < 5; i++) fadeBlink(alignLeft(txt)); pause(1); for (int i = 0; i < 5; i++) blink(alignRight(txt)); pause(1); crack(msg); print(msg, 2000, BRIGHTNESS_MAX); pause(1); term(txt); pause(1); } /* * Display effects */ void print(String msg, int msgDelay, byte brightness) { setBrightness(brightness); for (int i = 0; i < DISPLAY_SIZE; i++) { writeChar(msg.charAt(i)); } delay(msgDelay); } void fadeIn(String msg) { for (int i = 0; i <= BRIGHTNESS_MAX; i++) { print(msg, FADE_DELAY, i); } } void fadeOut(String msg) { for (int i = BRIGHTNESS_MAX; i >= 0; i--) { print(msg, FADE_DELAY, i); } } void fadeBlink(String msg) { fadeIn(msg); fadeOut(msg); } void blink(String msg) { print(msg, BLINK_DELAY, BRIGHTNESS_MIN); print(msg, BLINK_DELAY, BRIGHTNESS_MAX); } void slideLeft(String msg) { msg = concat(BLANK_DISPLAY, msg); int size = msg.length(); for (int i = 0; i < size; i++) { String txt = ""; for (int j = 0; j < DISPLAY_SIZE; j++) { txt = concat(txt, String(msg.charAt((i + j) % size))); } print(txt, SLIDE_DELAY, BRIGHTNESS_MAX); } } void slideRight(String msg) { msg = concat(msg, BLANK_DISPLAY); int size = msg.length(); for (int i = size - 1; i >= 0; i--) { String txt = ""; for (int j = 0; j < DISPLAY_SIZE; j++) { txt = concat(String(msg.charAt(((i - j) + size) % size)), txt); } print(txt, SLIDE_DELAY, BRIGHTNESS_MAX); } } void crack(String msg) { boolean mask[DISPLAY_SIZE] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // initial cracking noise for (int n = 0; n < CRACK_NOISE; n++) { print(randomText(DISPLAY_SIZE), CRACK_DELAY, BRIGHTNESS_MAX); } for (int i = 0; i < DISPLAY_SIZE; i++) { // pick the next char to crack boolean set = false; while (!set) { byte pos = random(0, DISPLAY_SIZE); if (mask[pos] == 0) { mask[pos] = 1; set = true; } } // cracking process with already cracked chars for (int n = 0; n < CRACK_NOISE; n++) { String txt = ""; for (int j = 0; j < DISPLAY_SIZE; j++) { if (mask[j] == 0) { txt += randomChar(); } else { txt += msg.charAt(j); } } print(txt, CRACK_DELAY, BRIGHTNESS_MAX); } } } void term(String msg) { // initial blinks for (int i = 0; i < TERM_BLINK; i++) blink(alignLeft("_")); int size = msg.length() + 1; if (size > DISPLAY_SIZE) { size++; // one more loop cycle for the final cursor } String txt; byte cursorAt = 0; for (int i = 0; i < size; i++) { txt = ""; for (int j = 0; j < min(DISPLAY_SIZE - 1, i); j++) { if (i < DISPLAY_SIZE) { txt += msg.charAt(j); } else { txt += msg.charAt(j + i - DISPLAY_SIZE); } } txt += "_"; cursorAt = txt.length() - 1; txt += blankText(max(0, DISPLAY_SIZE - (i + 1))); print(txt, TERM_DELAY, BRIGHTNESS_MAX); } // final blinks for (int i = 0; i < (TERM_BLINK * 2); i++) { txt.setCharAt(cursorAt, ((i % 2 == 0) ? ' ' : '_')); print(txt, BLINK_DELAY, BRIGHTNESS_MAX); } } void pause(byte seconds) { print(BLANK_DISPLAY, seconds * 1000, BRIGHTNESS_MIN); } /* * String manipulation */ String alignCenter(String txt) { int size = txt.length(); if (size >= DISPLAY_SIZE) { return txt; } byte n = (DISPLAY_SIZE - size) / 2; if ((DISPLAY_SIZE - size) % 2 == 0) { txt = concat(blankText(n), txt); } else { txt = concat(blankText(n + 1), txt); } return concat(txt, blankText(n)); } String alignRight(String txt) { int size = txt.length(); if (size >= DISPLAY_SIZE) { return txt; } return concat(blankText(DISPLAY_SIZE - size), txt); } String alignLeft(String txt) { int size = txt.length(); if (size >= DISPLAY_SIZE) { return txt; } return concat(txt, blankText(DISPLAY_SIZE - size)); } String alignJustify(String txt) { int size = txt.length(); if (size >= DISPLAY_SIZE) { return txt; } if (txt.indexOf(BLANK_CHAR) != txt.lastIndexOf(BLANK_CHAR)) { // justifies only two words separated by one single blank! return txt; } txt.replace(BLANK_CHAR, blankText(DISPLAY_SIZE - size + 1)); return txt; } String concat(String s1, String s2) { return s1 + s2; } char randomChar() { char c = random(65, 126); // A to Z + a to z + 10 digits if ((c > 90) && (c < 97)) { c = (c - 91) + 48; // digits 0 to 5 } else if (c > 122) { c = (c - 123) + 54; // digits 6 to 9 } return c; } String randomText(byte size) { String txt = ""; for (int i = 0; i < size; i++) { txt += randomChar(); } return txt; } String blankText(byte size) { String txt = ""; for (int i = 0; i < size; i++) { txt += BLANK_CHAR; } return txt; } /* * Helpers */ byte currentBrightness = -1; void setBrightness(byte brightness) { if (currentBrightness != brightness) { writeByte(BRIGHTNESS_MASK | brightness); currentBrightness = brightness; } } void writeChar(char aChar) { writeByte(getChar(aChar)); } char getChar(char c) { // direct ASCII mapping if ((c >= 32) && (c <= 127)) { return c; } return 63; // '?' } void writeByte(byte aByte) { for (int i = 0; i < 8; i++) { writeBit(bitRead(aByte, 7 - i)); } } void writeBit(boolean aBit) { digitalWrite(DATA, aBit ? HIGH : LOW); delayMicroseconds(BIT_DELAY); digitalWrite(SCLK, HIGH); delayMicroseconds(HIGH_DELAY); digitalWrite(SCLK, LOW); delayMicroseconds(LOW_DELAY); } void reset() { digitalWrite(DATA, LOW); digitalWrite(SCLK, LOW); digitalWrite(RSET, LOW); delay(RESET_DELAY); digitalWrite(RSET, HIGH); delay(RESET_DELAY); }
e110b5923961c33b596259981298fbce105382a6
ad10303c9f3c1f9d9e78cf85215aa93a0e5a3e60
/paddle/fluid/operators/partial_sum_op.cc
f2767e58589de4d81365e4f632a77aad914a8b24
[ "Apache-2.0" ]
permissive
Sand3r-/Paddle
14ab9b6bb7200c2d58fe2af5752a6d052cce1c5e
1217a521554d63caa1381b8716910d0268dfc22d
refs/heads/develop
2021-06-03T08:52:11.172700
2020-03-04T08:42:35
2020-03-04T08:42:35
144,544,192
0
0
Apache-2.0
2018-10-17T13:49:14
2018-08-13T07:26:40
C++
UTF-8
C++
false
false
7,963
cc
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/partial_sum_op.h" #include <memory> #include <string> #include <vector> namespace paddle { namespace operators { using Tensor = framework::Tensor; class PartialSumOp : public framework::OperatorWithKernel { public: using framework::OperatorWithKernel::OperatorWithKernel; void InferShape(framework::InferShapeContext *ctx) const override { PADDLE_ENFORCE_GE(ctx->Inputs("X").size(), 1UL, platform::errors::InvalidArgument( "Inputs(X) of PartialSumOp should not be empty.")); PADDLE_ENFORCE_EQ(ctx->HasOutput("Out"), true, platform::errors::InvalidArgument( "Output(Out) of PartialSumOp should not be null.")); auto inputs_dims = ctx->GetInputsDim("X"); const size_t inputs_num = inputs_dims.size(); PADDLE_ENFORCE_GT(inputs_num, 0, platform::errors::InvalidArgument( "ShapeError: Input tensors count should > 0. But " "recevied inputs' length is 0.")); if (inputs_num == 1) { VLOG(3) << "Warning: partial_sum op have only one input, may be useless"; } int start_index = ctx->Attrs().Get<int>("start_index"); int length = ctx->Attrs().Get<int>("length"); // Only suppert two dimensions now, should be extended later // when length is -1, need make sure all dimensions to be added are the same int64_t batch_size = -1; int64_t input_len = -1; for (size_t i = 0; i < inputs_num; ++i) { PADDLE_ENFORCE_EQ(inputs_dims[i].size(), 2, platform::errors::InvalidArgument( "Only suppert two dimensions input now.")); if (i == 0) { batch_size = inputs_dims[0][0]; input_len = inputs_dims[0][1]; } else { PADDLE_ENFORCE_EQ(inputs_dims[i][0], batch_size, platform::errors::InvalidArgument( "The batch size of all inputs must be same")); PADDLE_ENFORCE_EQ(inputs_dims[i][1], input_len, platform::errors::InvalidArgument( "The input len of all inputs must be same")); } } PADDLE_ENFORCE_GT(input_len, start_index, platform::errors::OutOfRange( "start_index must be less than input len")); if (length > 0) { PADDLE_ENFORCE_GE( input_len, start_index + length, platform::errors::OutOfRange( "start_index + length is larger than input length")); } std::vector<int64_t> out_dims(2); out_dims[0] = batch_size; out_dims[1] = (length == -1) ? input_len - start_index : length; ctx->SetOutputDim("Out", framework::make_ddim(out_dims)); ctx->ShareLoD("X", /*->*/ "Out"); } protected: framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { auto inputs = ctx.MultiInput<Tensor>("X"); auto input_data_type = framework::proto::VarType::Type(0); bool flag = 0; for (auto *input : inputs) { if (input->IsInitialized() && input->numel() > 0) { input_data_type = input->type(); flag = 1; break; } } PADDLE_ENFORCE_EQ(flag, 1, platform::errors::InvalidArgument( "All Inputs of PartialSum OP are Empty!")); return framework::OpKernelType(input_data_type, platform::CPUPlace()); } }; class PartialSumGradOp : public framework::OperatorWithKernel { public: using framework::OperatorWithKernel::OperatorWithKernel; void InferShape(framework::InferShapeContext *ctx) const override { auto in_x = "X"; auto out_x_g_n = framework::GradVarName(in_x); ctx->SetOutputsDim(out_x_g_n, ctx->GetInputsDim(in_x)); auto in_names = ctx->Inputs(in_x); auto out_names = ctx->Outputs(out_x_g_n); PADDLE_ENFORCE_EQ( in_names.size(), out_names.size(), platform::errors::InvalidArgument( "The number of arguments in %s[%d] and %s[%d] is not equal.", in_x, in_names.size(), out_x_g_n, out_names.size())); for (size_t i = 0; i < in_names.size(); ++i) { if (out_names[i] != framework::kEmptyVarName) { ctx->ShareLoD(in_x, out_x_g_n, i, i); } } } protected: framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { return framework::OpKernelType(OperatorWithKernel::IndicateVarDataType( ctx, framework::GradVarName("Out")), ctx.device_context()); } }; class PartialSumOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", "Input tensors of partial_sum operator.").AsDuplicable(); AddOutput("Out", "Output tensor of partial_sum operator."); AddAttr<bool>( "use_mkldnn", "(bool, default false) Indicates if MKL-DNN kernel will be used") .SetDefault(false); AddAttr<int>("start_index", "The start index of tensor wanted to be added.") .SetDefault(0); AddAttr<int>("length", "The length of tensor wanted to be added.") .SetDefault(-1); AddComment(R"DOC( PartialSum Operator. This Op can sum the vars by specifying the initial position(start_index) and length(length). This OP exists in contrib, which means that it is not shown to the public. Only 2-D Tensor or LodTensor input is supported. Slice and concat can only be performed along the second dimension. Examples: Input[0] = [[1,2,3],[3,4,5]] Input[1] = [[5,6,7],[7,8,9]] start_index = 0 length = 2 Output = [[6,8], [10,12]] )DOC"); } }; template <typename T> class PartialSumGradMaker : public framework::SingleGradOpMaker<T> { public: using framework::SingleGradOpMaker<T>::SingleGradOpMaker; protected: std::unique_ptr<T> Apply() const override { std::unique_ptr<T> op(new T()); op->SetType("partial_sum_grad"); op->SetInput("X", this->Input("X")); op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out")); op->SetOutput(framework::GradVarName("X"), this->InputGrad("X", false)); op->SetAttr("start_index", this->GetAttr("start_index")); op->SetAttr("length", this->GetAttr("length")); return op; } }; } // namespace operators } // namespace paddle namespace ops = paddle::operators; REGISTER_OPERATOR(partial_sum, ops::PartialSumOp, ops::PartialSumOpMaker, ops::PartialSumGradMaker<paddle::framework::OpDesc>, ops::PartialSumGradMaker<paddle::imperative::OpBase>); REGISTER_OPERATOR(partial_sum_grad, ops::PartialSumGradOp); REGISTER_OP_CPU_KERNEL( partial_sum, ops::PartialSumKernel<paddle::platform::CPUDeviceContext, float>, ops::PartialSumKernel<paddle::platform::CPUDeviceContext, int>, ops::PartialSumKernel<paddle::platform::CPUDeviceContext, double>, ops::PartialSumKernel<paddle::platform::CPUDeviceContext, int64_t>); REGISTER_OP_CPU_KERNEL(partial_sum_grad, ops::PartialSumGradientOpKernel<float>, ops::PartialSumGradientOpKernel<int>, ops::PartialSumGradientOpKernel<double>, ops::PartialSumGradientOpKernel<int64_t>);
2470c88fc7379a5084ae4d49503d806823a26bd1
5f2a2050fa51b184a5b11d0d9c38bd1fa878d7bb
/app/src/main/jniLibs/libleaktracer/src/MemoryTrace.cpp
c00ecddc980907761b960beb18c83584023d0c3e
[]
no_license
WYJ0663/FFmpegPlay
80394cccf2826c8d702e51c8dd0674aa0ad91c6b
fa4f2a79e44a859d88b05e8d1e89a7e6c26b6b06
refs/heads/master
2020-04-01T19:19:08.746510
2018-11-28T03:13:46
2018-11-28T03:13:46
153,548,011
2
0
null
null
null
null
UTF-8
C++
false
false
11,655
cpp
//////////////////////////////////////////////////////// // // LeakTracer // Contribution to original project by Erwin S. Andreasen // site: http://www.andreasen.org/LeakTracer/ // // Added by Michael Gopshtein, 2006 // [email protected] // // Any comments/suggestions are welcome // //////////////////////////////////////////////////////// #include <sys/syscall.h> #include "MemoryTrace.hpp" #include <ctype.h> #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <dlfcn.h> #include <assert.h> #include <stdio.h> #include <unwind.h> #include "LeakTracer_l.hpp" // glibc/eglibc: dlsym uses calloc internally now, so use weak symbol to get their symbol extern "C" void* __libc_malloc(size_t size) __attribute__((weak)); extern "C" void __libc_free(void* ptr) __attribute__((weak)); extern "C" void* __libc_realloc(void *ptr, size_t size) __attribute__((weak)); extern "C" void* __libc_calloc(size_t nmemb, size_t size) __attribute__((weak)); static Dl_info s_P2pSODlInfo; namespace leaktracer { typedef struct { const char *symbname; void *libcsymbol; void **localredirect; } libc_alloc_func_t; static libc_alloc_func_t libc_alloc_funcs[] = { { "calloc", (void*)__libc_calloc, (void**)(&lt_calloc) }, { "malloc", (void*)__libc_malloc, (void**)(&lt_malloc) }, { "realloc", (void*)__libc_realloc, (void**)(&lt_realloc) }, { "free", (void*)__libc_free, (void**)(&lt_free) } }; MemoryTrace *MemoryTrace::__instance = NULL; char s_memoryTrace_instance[sizeof(MemoryTrace)]; pthread_once_t MemoryTrace::_init_no_alloc_allowed_once = PTHREAD_ONCE_INIT; pthread_once_t MemoryTrace::_init_full_once = PTHREAD_ONCE_INIT; int MemoryTrace::__sigStartAllThread = 0; int MemoryTrace::__sigStopAllThread = 0; int MemoryTrace::__sigReport = 0; MemoryTrace::MemoryTrace(void) : __setupDone(false), __monitoringAllThreads(false), __monitoringReleases(false), __monitoringDisabler(0) { } void MemoryTrace::sigactionHandler(int sigNumber, siginfo_t *siginfo, void *arg) { (void)siginfo; (void)arg; if (sigNumber == __sigStartAllThread) { TRACE((stderr, "MemoryTracer: signal %d received, starting monitoring\n", sigNumber)); leaktracer::MemoryTrace::GetInstance().startMonitoringAllThreads(); } if (sigNumber == __sigStopAllThread) { TRACE((stderr, "MemoryTracer: signal %d received, stoping monitoring\n", sigNumber)); leaktracer::MemoryTrace::GetInstance().stopAllMonitoring(); } if (sigNumber == __sigReport) { const char* reportFilename; if (getenv("LEAKTRACER_ONSIG_REPORTFILENAME") == NULL) reportFilename = "leaks.out"; else reportFilename = getenv("LEAKTRACER_ONSIG_REPORTFILENAME"); TRACE((stderr, "MemoryTracer: signal %d received, writing report to %s\n", sigNumber, reportFilename)); leaktracer::MemoryTrace::GetInstance().writeLeaksToFile(reportFilename); } } int MemoryTrace::signalNumberFromString(const char* signame) { if (strncmp(signame, "SIG", 3) == 0) signame += 3; if (strcmp(signame, "USR1") == 0) return SIGUSR1; else if (strcmp(signame, "USR2") == 0) return SIGUSR2; else return atoi(signame); } void MemoryTrace::init_no_alloc_allowed() { libc_alloc_func_t *curfunc; unsigned i; for (i=0; i<(sizeof(libc_alloc_funcs)/sizeof(libc_alloc_funcs[0])); ++i) { curfunc = &libc_alloc_funcs[i]; if (!*curfunc->localredirect) { if (curfunc->libcsymbol) { *curfunc->localredirect = curfunc->libcsymbol; } else { *curfunc->localredirect = dlsym(RTLD_NEXT, curfunc->symbname); } } } dladdr((const void*)init_no_alloc_allowed, &s_P2pSODlInfo); __instance = reinterpret_cast<MemoryTrace*>(&s_memoryTrace_instance); // we're using a c++ placement to initialized the MemoryTrace object living in the data section new (__instance) MemoryTrace(); // it seems some implementation of pthread_key_create use malloc() internally (old linuxthreads) // these are not supported yet pthread_key_create(&__instance->__thread_internal_disabler_key, NULL); } void MemoryTrace::init_full_from_once() { leaktracer::MemoryTrace::GetInstance().init_full(); } void MemoryTrace::init_full() { int sigNumber; struct sigaction sigact; __monitoringDisabler++; void *testmallocok = malloc(1); free(testmallocok); pthread_key_create(&__thread_options_key, CleanUpThreadData); if (!getenv("LEAKTRACER_NOBANNER")) { #ifdef SHARED fprintf(stderr, "LeakTracer " LEAKTRACER_VERSION " (shared library) -- LGPLv2\n"); #else fprintf(stderr, "LeakTracer " LEAKTRACER_VERSION " (static library) -- LGPLv2\n"); #endif } if (getenv("LEAKTRACER_ONSIG_STARTALLTHREAD")) { sigact.sa_sigaction = sigactionHandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_SIGINFO; sigNumber = signalNumberFromString(getenv("LEAKTRACER_ONSIG_STARTALLTHREAD")); __sigStartAllThread = sigNumber; sigaction(sigNumber, &sigact, NULL); TRACE((stderr, "LeakTracer: registered signal %d SIGSTART for tid %d\n", sigNumber, (pid_t) syscall (SYS_gettid))); } if (getenv("LEAKTRACER_ONSIG_STOPALLTHREAD")) { sigact.sa_sigaction = sigactionHandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_SIGINFO; sigNumber = signalNumberFromString(getenv("LEAKTRACER_ONSIG_STOPALLTHREAD")); __sigStopAllThread = sigNumber; sigaction(sigNumber, &sigact, NULL); TRACE((stderr, "LeakTracer: registered signal %d SIGSTOP for tid %d\n", sigNumber, (pid_t) syscall (SYS_gettid))); } if (getenv("LEAKTRACER_ONSIG_REPORT")) { sigact.sa_sigaction = sigactionHandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_SIGINFO; sigNumber = signalNumberFromString(getenv("LEAKTRACER_ONSIG_REPORT")); __sigReport = sigNumber; sigaction(sigNumber, &sigact, NULL); TRACE((stderr, "LeakTracer: registered signal %d SIGREPORT for tid %d\n", sigNumber, (pid_t) syscall (SYS_gettid))); } if (getenv("LEAKTRACER_ONSTART_STARTALLTHREAD") || getenv("LEAKTRACER_AUTO_REPORTFILENAME")) { leaktracer::MemoryTrace::GetInstance().startMonitoringAllThreads(); } #ifdef USE_BACKTRACE // we call backtrace here, because there is some init on its first call void *bt; backtrace(&bt, 1); #endif __setupDone = true; __monitoringDisabler--; } int MemoryTrace::Setup(void) { pthread_once(&MemoryTrace::_init_no_alloc_allowed_once, MemoryTrace::init_no_alloc_allowed); if (!leaktracer::MemoryTrace::GetInstance().AllMonitoringIsDisabled()) { pthread_once(&MemoryTrace::_init_full_once, MemoryTrace::init_full_from_once); } #if 0  else if (!leaktracer::MemoryTrace::GetInstance().__setupDone) { } #endif return 0; } void MemoryTrace::MemoryTraceOnInit(void) { //TRACE((stderr, "LeakTracer: MemoryTrace::MemoryTraceOnInit\n")); leaktracer::MemoryTrace::Setup(); } void MemoryTrace::MemoryTraceOnExit(void) { if (getenv("LEAKTRACER_ONEXIT_REPORT") || getenv("LEAKTRACER_AUTO_REPORTFILENAME")) { const char *reportName; if ( !(reportName = getenv("LEAKTRACER_ONEXIT_REPORTFILENAME")) && !(reportName = getenv("LEAKTRACER_AUTO_REPORTFILENAME"))) { TRACE((stderr, "LeakTracer: LEAKTRACER_ONEXIT_REPORTFILENAME needs to be defined when using LEAKTRACER_ONEXIT_REPORT\n")); return; } leaktracer::MemoryTrace::GetInstance().stopAllMonitoring(); TRACE((stderr, "LeakTracer: writing leak report in %s\n", reportName)); leaktracer::MemoryTrace::GetInstance().writeLeaksToFile(reportName); } } MemoryTrace::~MemoryTrace(void) { pthread_key_delete(__thread_options_key); } // is called automatically when thread exists, whould // cleanup per-thread data void MemoryTrace::CleanUpThreadData(void *ptrThreadOptions) { if( ptrThreadOptions != NULL ) GetInstance().removeThreadOptions( reinterpret_cast<ThreadMonitoringOptions*>(ptrThreadOptions) ); } // cleans per-thread configuration object, and removes // it from the list of all objects void MemoryTrace::removeThreadOptions(ThreadMonitoringOptions *pOptions) { MutexLock lock(__threadListMutex); for (list_monitoring_options_t::iterator it = __listThreadOptions.begin(); it != __listThreadOptions.end(); ++it) { if (*it == pOptions) { // found this object in the list delete *it; __listThreadOptions.erase(it); return; } } } struct TraceHandle { void **backtrace; int pos; }; _Unwind_Reason_Code Unwind_Trace_Fn(_Unwind_Context *context, void *hnd) { struct TraceHandle *traceHanle = (struct TraceHandle *) hnd; _Unwind_Word ip = _Unwind_GetIP(context); if (traceHanle->pos != ALLOCATION_STACK_DEPTH) { traceHanle->backtrace[traceHanle->pos] = (void *) (ip - (_Unwind_Word) s_P2pSODlInfo.dli_fbase); ++traceHanle->pos; return _URC_NO_REASON; } return _URC_END_OF_STACK; } // stores allocation stack, up to ALLOCATION_STACK_DEPTH // frames void MemoryTrace::storeAllocationStack(void* arr[ALLOCATION_STACK_DEPTH]) { unsigned int iIndex = 0; TraceHandle traceHandle; traceHandle.backtrace = arr; traceHandle.pos = 0; _Unwind_Backtrace(Unwind_Trace_Fn, &traceHandle); // fill remaining spaces for (iIndex = traceHandle.pos; iIndex < ALLOCATION_STACK_DEPTH; iIndex++) arr[iIndex] = NULL; } // writes all memory leaks to given stream void MemoryTrace::writeLeaksPrivate(std::ostream &out) { struct timespec mono, utc, diff; allocation_info_t *info; void *p; double d; const int precision = 6; int maxsecwidth; clock_gettime(CLOCK_REALTIME, &utc); clock_gettime(CLOCK_MONOTONIC, &mono); if (utc.tv_nsec > mono.tv_nsec) { diff.tv_nsec = utc.tv_nsec - mono.tv_nsec; diff.tv_sec = utc.tv_sec - mono.tv_sec; } else { diff.tv_nsec = 1000000000 - (mono.tv_nsec - utc.tv_nsec); diff.tv_sec = utc.tv_sec - mono.tv_sec -1; } maxsecwidth = 0; while(mono.tv_sec > 0) { mono.tv_sec = mono.tv_sec/10; maxsecwidth++; } if (maxsecwidth == 0) maxsecwidth=1; out << "# LeakTracer report"; d = diff.tv_sec + (((double)diff.tv_nsec)/1000000000); out << " diff_utc_mono=" << std::fixed << std::left << std::setprecision(precision) << d ; out << "\n"; __allocations.beginIteration(); while (__allocations.getNextPair(&info, &p)) { d = info->timestamp.tv_sec + (((double)info->timestamp.tv_nsec)/1000000000); out << "leak, "; out << "time=" << std::fixed << std::right << std::setprecision(precision) << std::setfill('0') << std::setw(maxsecwidth+1+precision) << d << ", "; // setw(16) ? out << "stack="; for (unsigned int i = 0; i < ALLOCATION_STACK_DEPTH; i++) { if (info->allocStack[i] == NULL) break; if (i > 0) out << ' '; out << info->allocStack[i]; } out << ", "; out << "size=" << info->size << ", "; out << "data="; const char *data = reinterpret_cast<const char *>(p); for (unsigned int i = 0; i < PRINTED_DATA_BUFFER_SIZE && i < info->size; i++) out << (isprint(data[i]) ? data[i] : '.'); out << '\n'; } } // writes all memory leaks to given stream void MemoryTrace::writeLeaks(std::ostream &out) { MutexLock lock(__allocations_mutex); InternalMonitoringDisablerThreadUp(); writeLeaksPrivate(out); InternalMonitoringDisablerThreadDown(); } // writes all memory leaks to given stream void MemoryTrace::writeLeaksToFile(const char* reportFilename) { MutexLock lock(__allocations_mutex); InternalMonitoringDisablerThreadUp(); std::ofstream oleaks; oleaks.open(reportFilename, std::ios_base::out); if (oleaks.is_open()) { writeLeaksPrivate(oleaks); oleaks.close(); } else { std::cerr << "Failed to write to \"" << reportFilename << "\"\n"; } InternalMonitoringDisablerThreadDown(); } void MemoryTrace::clearAllocationsInfo(void) { MutexLock lock(__allocations_mutex); __allocations.clearAllInfo(); } } // end namespace
947a3aaf5a8548c29c76bf4a15f39222a86a11ca
ac8193f0849dec7a026915126e34fb97f3ff2d8b
/Fly/Task/Maneuvers/TaskMagicFlyBegin.cpp
b6e2ec08ff9ba16b4807b622aa8a54f801cf2521
[]
no_license
oygx210/Fly
bafb9501418e51a3bda531a69e8999e43f70f69f
a12572ba72d4ae37060bea6c144e5277853af664
refs/heads/master
2022-04-01T22:25:17.191197
2019-12-24T07:58:35
2019-12-24T07:58:35
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
6,730
cpp
//----------------------------------------------------------------------------- // TaskMagicFlyBegin.cpp // А. Николенко 14.02.2019 //----------------------------------------------------------------------------- #include "stdafx.h" //----------------------------------------------------------------------------- // Компоненты Fly #include <FlyCore.h> // Собственоно сама модель движения #include <FlyMMath.h> // Математические функции #include <FlyOrbitDesign.h> // Проектирование орбит #include <FlyMagicLNS.h> // Метод узловых точек //----------------------------------------------------------------------------- // Инициализация НУ шкалы и модели движения, настройка документирования // для всех задач расчёта параметров коррекции орбиты //----------------------------------------------------------------------------- int TaskMagicFlyBegin(ZSMagicLnsSolution* MS, int task, ZMSC& KA, ZNU& NU, ZLSF& LSF, bool ResetNU, ZCPrintManager* PrintMng, FILE** pfp) { int rc = 0; DefaultParam(MS->MP); // Параметризация задачи расчета параметров управлени движением ЦМ LoadDU(1, 1, MS->DU); // Загрузка ДУ с условным номером 1 для КА 1 if (ResetNU) { //--------------------------------------------------------------------- // НУ NU.Key.ka = 1; NU.Key.nom = 15; NU.Key.mod = 0; NU.Key.type = 8; NU.Key.bc = 1; NU.numlsf = 1; if (task >= 10 && task < 20) { NU.t << DATETIMEDMB(18, 7, 2018, 9, 30, 0, 0); NU.vit = 99; NU.sk = _SK_OSK1975; NU.X[0] = TO_DTKM(7000.0); NU.X[1] = 0.0005; NU.X[2] = TO_RAD(90.0); NU.X[3] = TO_RAD(120.0); NU.X[4] = TO_RAD(45.0); NU.X[5] = TO_RAD(15); NU.Sb = 0.0001; NU.Kp = 0; NU.M0 = 900; NU.MF = 50; } // НУ для сверки вариант 20, 21, 22, 23, if (task >= 20 && task < 30 && task != 24) { NU.t << DATETIMEDMB(14, 12, 2016, 12, 0, 0, 0); NU.vit = 1; NU.sk = _SK_GSK; NU.X[0] = TO_DTKM(-6587.1866159); NU.X[1] = TO_DTKM(-436.2698529); NU.X[2] = TO_DTKM(0); NU.X[3] = TO_DTKMSSS(0.1687606245); NU.X[4] = TO_DTKMSSS(-2.5480965961); NU.X[5] = TO_DTKMSSS(7.1501923050); NU.Sb = 0.014 / 9.80665*2.0; NU.Kp = 0; NU.M0 = 5500; NU.MF = 500; } if (task == 24) { // НУ для сверки вариант 24 - ТЕСТ 1, NU.t << DATETIMEDMB(14, 12, 2015, 12, 0, 0, 0); NU.vit = 1; NU.sk = _SK_GSK; NU.X[0] = TO_DTKM(-6587.1866159); NU.X[1] = TO_DTKM(-436.2698529); NU.X[2] = TO_DTKM(0); NU.X[3] = TO_DTKMSSS(0.1687606245); NU.X[4] = TO_DTKMSSS(-2.5480965961); NU.X[5] = TO_DTKMSSS(7.1501923050); NU.Sb = 0.014 / 9.80665*2.0; NU.Kp = 0; NU.M0 = 5500; NU.MF = 500; /* // НУ для сверки вариант 24 - ТЕСТ 2 NU.t << DATETIMEDMB(14, 12, 2015, 12, 0, 0, 0) ; NU.vit = 2 ; NU.sk = _SK_GSK ; NU.X[0] = TO_DTKM(-6253.8800322 ) ; NU.X[1] = TO_DTKM( 2113.7267198 ) ; NU.X[2] = TO_DTKM( 0 ) ; NU.X[3] = TO_DTKMSSS(-0.8176778949 ) ; NU.X[4] = TO_DTKMSSS(-2.419300063 ) ; NU.X[5] = TO_DTKMSSS( 7.1503057135 ) ; NU.Sb = 0.014/9.80665*2.0 ; NU.Kp = 0 ; NU.M0 = 5500 ; NU.MF = 500 ; */ } if (task >= 30 && task < 40 || task == 311) { // НУ для сверки вариантов 30, 31, 32, 33 NU.t << DATETIMEDMB(14, 12, 2015, 12, 0, 0, 0); NU.vit = 1; NU.sk = _SK_GSK; NU.X[0] = TO_DTKM(-6587.1866159); NU.X[1] = TO_DTKM(-436.2698529); NU.X[2] = TO_DTKM(0); NU.X[3] = TO_DTKMSSS(0.1687606245); NU.X[4] = TO_DTKMSSS(-2.5480965961); NU.X[5] = TO_DTKMSSS(7.1501923050); NU.Sb = 0.014 / 9.80665; NU.Kp = 0; NU.M0 = 5500; NU.MF = 500; } } //------------------------------------------------------------------------- // Шкала сил memset(&LSF, 0, sizeof(LSF)); LSF.num = 1; LSF.vgpz = GPZ90; LSF.ngpz = 8; LSF.mgpz = 8; LSF.vatm = ATMSMA81; LSF.vsvd = 0; LSF.varsp = 0; LSF.vTide = TIDENULL; LSF.isDU = 1; LSF.isSun = 1; LSF.isMoon = 1; //------------------------------------------------------------------------- // Параметризация документирования результатов прогноза PrintMng->MPK.ApeakOn(); PrintMng->MPK.FromVitOn(); PrintMng->MPK << MODPRDATE; PrintMng->MPK << MODPRTIME; PrintMng->MPK << MODPR_VIT; PrintMng->MPK << MODPR_MSSV; PrintMng->MPK << MODPR_M; PrintMng->MPK << MODPR_V_Tdr; PrintMng->MPK << MODPR_L; PrintMng->MPK << MODPR_V_DL; PrintMng->MPK << MODPR_V_DLS; PrintMng->MPK << MODPR_Aosk; PrintMng->MPK << MODPR_eosk; PrintMng->MPK << MODPR_V_Hsr; PrintMng->MPK << MODPR_V_Hmaxt; PrintMng->MPK << MODPR_V_HmaxU; PrintMng->MPK << MODPR_V_Hmax; PrintMng->MPK << MODPR_V_Hmint; PrintMng->MPK << MODPR_V_HminU; PrintMng->MPK << MODPR_V_Hmin; //PrintMng->MPK << MODPR_V_Rmaxt ; //PrintMng->MPK << MODPR_V_RmaxU ; //PrintMng->MPK << MODPR_V_Rmax ; //PrintMng->MPK << MODPR_V_Rmint ; //PrintMng->MPK << MODPR_V_RminU ; //PrintMng->MPK << MODPR_V_Rmin ; //------------------------------------------------------------------------- MS->MZ.ks = 0; // Тип КА - тип рассчитываемых манёвров (0-как для "Янтаря") MS->MZ.KA() = NU.Key.ka; // Условный номер КА MS->MZ.DU() = 1; // Используемая ДУ (её номер) MS->MZ.VAR() = MS->MZ.FINDVARTASK(task);// Номер задачи в общем списке по порядку. // Формирование ключей (основного и дополнительного) // требуемых на правом конце траектории параметров MS->MZ.GetParKorFromVar(MS->MZ.DemandsKey); MS->MZ.GetAdvParKorFromVar(MS->MZ.SecondDemandsKey); //------------------------------------------------------------------------- // Начало документирование .... Создание документа char NameOrb[64] = "_"; switch (MS->MZ.ORB()) { case SPO_ORB_OMIV: sprintf(NameOrb, "OMIV\0"); break; case SPO_ORB_DU: sprintf(NameOrb, "DU\0"); break; case SPO_ORB_EL: sprintf(NameOrb, "EL\0"); break; case SPO_ORB_HBH: sprintf(NameOrb, "HBH\0"); break; } char NameFile[256]; sprintf(NameFile, "_TaskMagicFly%d_%s\0", task, NameOrb); PrintMng->PrePrint(&KA, "Расчёт коррекции орблиты", NameFile, pfp); return 0; } //-----------------------------------------------------------------------------
9cbac397128c51f3b0af48aaff16ea90ded81e86
a9ba45404a4a1e5782e65225b4fe4aa6c5542b13
/sst-elements-library-6.0.0/src/sst/elements/ember/mpi/motifs/embernull.h
a39f200f5ac79acb9233f83964434b3aefccd0c0
[]
no_license
Knoxort/BE-SST
099237bb2d604c46e82950db79758ffa1800fa67
fe47a954489dbe6b361a0776eae0bd65dcb40523
refs/heads/master
2020-04-02T14:33:11.503958
2017-10-05T17:00:26
2017-10-05T17:00:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
804
h
// Copyright 2009-2016 Sandia Corporation. Under the terms // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. // Government retains certain rights in this software. // // Copyright (c) 2009-2016, Sandia Corporation // All rights reserved. // // This file is part of the SST software package. For license // information, see the LICENSE file in the top level directory of the // distribution. #ifndef _H_EMBER_NULL #define _H_EMBER_NULL #include "mpi/embermpigen.h" namespace SST { namespace Ember { class EmberNullGenerator : public EmberMessagePassingGenerator { public: EmberNullGenerator(SST::Component* owner, Params& params) : EmberMessagePassingGenerator(owner, params, "Null" ) { } bool generate( std::queue<EmberEvent*>& evQ) { return true; } }; } } #endif
bad80927bdad9496c505a74c3da0c4aa61a628fb
d8b5e52952981db6f6279ae401339f553db253a1
/Button.h
454f56101cb628a7a44b275462dc642643407e5c
[]
no_license
pulni/myqlock
1591cf05cbdcb99091518f75eda1db0bd974c2dd
c6d7ddd181559972deb1fc21debd0be84e00faa1
refs/heads/master
2021-01-18T09:35:57.147708
2011-08-22T20:06:57
2011-08-22T20:06:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
441
h
/** * Button.h * Kleine Klasse zum Entprellen der Tasten. * * @mc Arduino/RBBB * @autor Christian Aschoff / caschoff _AT_ mac _DOT_ com * @version 1.0 * @datum 18.2.2011 */ #ifndef BUTTON_H #define BUTTON_H #include "WProgram.h" /** * Die Tasten */ #define BUTTON1 1 #define BUTTON2 2 class Button { public: Button(int pin); boolean pressed(); private: int _pin; unsigned long _lastPressTime; }; #endif
d12bd414a4e88dff2bdbbc857992973f9bc40432
fcc3813ab984320eb8a858b15aad2667fb1d217e
/GameLib/RenderContext.cpp
5bfe675e3d1edb6bffb7b89520cdf67cf54b15c8
[ "CC-BY-4.0" ]
permissive
pac0master/Floating-Sandbox
8e1b492640770755a93e9cfc6a3c8462410a968b
d53ba0ce42a0ea45d56a987097396f202f793572
refs/heads/master
2020-04-05T09:47:07.898840
2018-11-11T16:04:06
2018-11-11T16:04:06
156,774,349
0
0
NOASSERTION
2018-11-08T21:58:53
2018-11-08T21:58:53
null
UTF-8
C++
false
false
21,851
cpp
/*************************************************************************************** * Original Author: Gabriele Giuseppini * Created: 2018-02-13 * Copyright: Gabriele Giuseppini (https://github.com/GabrieleGiuseppini) ***************************************************************************************/ #include "RenderContext.h" #include "GameException.h" #include "Log.h" #include <cstring> namespace Render { RenderContext::RenderContext( ResourceLoader & resourceLoader, vec3f const & ropeColour, ProgressCallback const & progressCallback) : mShaderManager() , mTextureRenderManager() , mTextRenderContext() // Texture Atlases , mCloudTextureAtlasOpenGLHandle() , mCloudTextureAtlasMetadata() , mGenericTextureAtlasOpenGLHandle() , mGenericTextureAtlasMetadata() // Clouds , mCloudElementBuffer() , mCurrentCloudElementCount(0u) , mCloudElementCount(0u) , mCloudVBO() // Land , mLandElementBuffer() , mCurrentLandElementCount(0u) , mLandElementCount(0u) , mLandVBO() // Sea water , mWaterElementBuffer() , mCurrentWaterElementCount(0u) , mWaterElementCount(0u) , mWaterVBO() // Ships , mShips() , mRopeColour(ropeColour) // Render parameters , mZoom(1.0f) , mCamX(0.0f) , mCamY(0.0f) , mCanvasWidth(100) , mCanvasHeight(100) , mAmbientLightIntensity(1.0f) , mSeaWaterTransparency(0.8125f) , mShowShipThroughSeaWater(false) , mWaterLevelOfDetail(0.6875f) , mShipRenderMode(ShipRenderMode::Texture) , mVectorFieldRenderMode(VectorFieldRenderMode::None) , mVectorFieldLengthMultiplier(1.0f) , mShowStressedSprings(false) , mWireframeMode(false) { static constexpr float TextureProgressSteps = 1.0f /*cloud*/ + 10.0f; static constexpr float TotalProgressSteps = 5.0f + TextureProgressSteps; GLuint tmpGLuint; // // Init OpenGL // GameOpenGL::InitOpenGL(); // Activate texture unit 0 glActiveTexture(GL_TEXTURE0); // // Load shader manager // progressCallback(0.0f, "Loading shaders..."); ShaderManager<ShaderManagerTraits>::GlobalParameters globalParameters( ropeColour); mShaderManager = ShaderManager<ShaderManagerTraits>::CreateInstance(resourceLoader, globalParameters); // // Initialize text render context // mTextRenderContext = std::make_unique<TextRenderContext>( resourceLoader, *(mShaderManager.get()), mCanvasWidth, mCanvasHeight, [&progressCallback](float progress, std::string const & message) { progressCallback((1.0f + progress) / TotalProgressSteps, message); }); // // Load texture database // progressCallback(2.0f / TotalProgressSteps, "Loading textures..."); TextureDatabase textureDatabase = resourceLoader.LoadTextureDatabase( [&progressCallback](float progress, std::string const &) { progressCallback((2.0f + progress) / TotalProgressSteps, "Loading textures..."); }); // Remember number of cloud textures mCloudTextureCount = textureDatabase.GetGroup(TextureGroupType::Cloud).GetFrameCount(); // Create texture render manager mTextureRenderManager = std::make_unique<TextureRenderManager>(); // // Create cloud texture atlas // TextureAtlasBuilder cloudAtlasBuilder; cloudAtlasBuilder.Add(textureDatabase.GetGroup(TextureGroupType::Cloud)); TextureAtlas cloudTextureAtlas = cloudAtlasBuilder.BuildAtlas( [&progressCallback](float progress, std::string const &) { progressCallback((3.0f + progress) / TotalProgressSteps, "Loading textures..."); }); // Create OpenGL handle GLuint openGLHandle; glGenTextures(1, &openGLHandle); mCloudTextureAtlasOpenGLHandle = openGLHandle; // Bind texture glBindTexture(GL_TEXTURE_2D, *mCloudTextureAtlasOpenGLHandle); CheckOpenGLError(); // Upload atlas texture GameOpenGL::UploadTexture(std::move(cloudTextureAtlas.AtlasData)); // Set repeat mode glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CheckOpenGLError(); // Set texture filtering parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); CheckOpenGLError(); // Unbind texture glBindTexture(GL_TEXTURE_2D, 0); // Store metadata mCloudTextureAtlasMetadata = std::make_unique<TextureAtlasMetadata>(cloudTextureAtlas.Metadata); // // Create generic texture atlas // // Atlas-ize all textures EXCEPT the following: // - Land, Water: we need these to be wrapping // TextureAtlasBuilder genericTextureAtlasBuilder; for (auto const & group : textureDatabase.GetGroups()) { if (TextureGroupType::Land != group.Group && TextureGroupType::Water != group.Group && TextureGroupType::Cloud != group.Group) { genericTextureAtlasBuilder.Add(group); } } TextureAtlas genericTextureAtlas = genericTextureAtlasBuilder.BuildAtlas( [&progressCallback](float progress, std::string const &) { progressCallback((3.0f + 1.0f + progress * (TextureProgressSteps - 1.0f)) / TotalProgressSteps, "Loading textures..."); }); // Create OpenGL handle glGenTextures(1, &openGLHandle); mGenericTextureAtlasOpenGLHandle = openGLHandle; // Bind texture glBindTexture(GL_TEXTURE_2D, *mGenericTextureAtlasOpenGLHandle); CheckOpenGLError(); // Upload atlas texture GameOpenGL::UploadMipmappedTexture( genericTextureAtlas.Metadata, std::move(genericTextureAtlas.AtlasData)); // Set repeat mode glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CheckOpenGLError(); // Set texture filtering parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); CheckOpenGLError(); // Unbind texture glBindTexture(GL_TEXTURE_2D, 0); // Store metadata mGenericTextureAtlasMetadata = std::make_unique<TextureAtlasMetadata>(genericTextureAtlas.Metadata); // // Upload non-atlas textures // mTextureRenderManager->UploadMipmappedGroup( textureDatabase.GetGroup(TextureGroupType::Land), [&progressCallback](float progress, std::string const &) { progressCallback((3.0f + TextureProgressSteps + progress) / TotalProgressSteps, "Loading textures..."); }); mTextureRenderManager->UploadMipmappedGroup( textureDatabase.GetGroup(TextureGroupType::Water), [&progressCallback](float progress, std::string const &) { progressCallback((4.0f + TextureProgressSteps + progress) / TotalProgressSteps, "Loading textures..."); }); // // Initialize clouds // // Create VBO glGenBuffers(1, &tmpGLuint); mCloudVBO = tmpGLuint; // // Initialize land // // Set hardcoded parameters auto const & landTextureMetadata = textureDatabase.GetFrameMetadata(TextureGroupType::Land, 0); mShaderManager->ActivateProgram<ProgramType::Land>(); mShaderManager->SetProgramParameter<ProgramType::Land, ProgramParameterType::TextureScaling>( 1.0f / landTextureMetadata.WorldWidth, 1.0f / landTextureMetadata.WorldHeight); // Create VBO glGenBuffers(1, &tmpGLuint); mLandVBO = tmpGLuint; // // Initialize water // // Set hardcoded parameters auto const & waterTextureMetadata = textureDatabase.GetFrameMetadata(TextureGroupType::Water, 0); mShaderManager->ActivateProgram<ProgramType::Water>(); mShaderManager->SetProgramParameter<ProgramType::Water, ProgramParameterType::TextureScaling>( 1.0f / waterTextureMetadata.WorldWidth, 1.0f / waterTextureMetadata.WorldHeight); // Create VBO glGenBuffers(1, &tmpGLuint); mWaterVBO = tmpGLuint; // Bind VBO glBindBuffer(GL_ARRAY_BUFFER, *mWaterVBO); // Associate water vertex attribute with this VBO and describe it // (it's fully dedicated) glVertexAttribPointer(static_cast<GLuint>(VertexAttributeType::WaterAttribute), (2 + 1), GL_FLOAT, GL_FALSE, (2 + 1) * sizeof(float), (void*)0); // // Initialize ortho matrix // for (size_t r = 0; r < 4; ++r) { for (size_t c = 0; c < 4; ++c) { mOrthoMatrix[r][c] = 0.0f; } } // // Update parameters // UpdateOrthoMatrix(); UpdateVisibleWorldCoordinates(); UpdateAmbientLightIntensity(); UpdateSeaWaterTransparency(); UpdateWaterLevelOfDetail(); UpdateShipRenderMode(); UpdateVectorFieldRenderMode(); UpdateShowStressedSprings(); // // Flush all pending operations // glFlush(); // // Notify progress // progressCallback(1.0f, "Loading textures..."); } RenderContext::~RenderContext() { glUseProgram(0u); } ////////////////////////////////////////////////////////////////////////////////// void RenderContext::Reset() { // Clear ships mShips.clear(); } void RenderContext::AddShip( int shipId, size_t pointCount, std::optional<ImageData> texture) { assert(shipId == mShips.size()); (void)shipId; // Add the ship mShips.emplace_back( new ShipRenderContext( pointCount, std::move(texture), *mShaderManager, mGenericTextureAtlasOpenGLHandle, *mGenericTextureAtlasMetadata, mOrthoMatrix, mVisibleWorldHeight, mVisibleWorldWidth, mCanvasToVisibleWorldHeightRatio, mAmbientLightIntensity, mWaterLevelOfDetail, mShipRenderMode, mVectorFieldRenderMode, mShowStressedSprings, mWireframeMode)); } ////////////////////////////////////////////////////////////////////////////////// void RenderContext::RenderStart() { // Set anti-aliasing for lines and polygons glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable(GL_POLYGON_SMOOTH); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // Set polygon mode glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Enable blend for alpha transparency glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Clear canvas - and stencil buffer static const vec3f ClearColorBase(0.529f, 0.808f, 0.980f); // (cornflower blue) vec3f const clearColor = ClearColorBase * mAmbientLightIntensity; glClearColor(clearColor.x, clearColor.y, clearColor.z, 1.0f); glClearStencil(0x00); glStencilMask(0xFF); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); if (mWireframeMode) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Communicate start to child contextes mTextRenderContext->RenderStart(); } void RenderContext::RenderCloudsStart(size_t cloudCount) { if (cloudCount != mCloudElementCount) { // Bind VBO glBindBuffer(GL_ARRAY_BUFFER, *mCloudVBO); CheckOpenGLError(); // Realloc GPU buffer mCloudElementCount = cloudCount; glBufferData(GL_ARRAY_BUFFER, mCloudElementCount * sizeof(CloudElement), nullptr, GL_DYNAMIC_DRAW); CheckOpenGLError(); // Realloc buffer mCloudElementBuffer.reset(new CloudElement[mCloudElementCount]); } // Reset current count of clouds mCurrentCloudElementCount = 0u; } void RenderContext::RenderCloudsEnd() { // Enable stencil test glEnable(GL_STENCIL_TEST); //////////////////////////////////////////////////// // Draw water stencil //////////////////////////////////////////////////// // Use matte water program mShaderManager->ActivateProgram<ProgramType::MatteWater>(); // Disable writing to the color buffer glColorMask(false, false, false, false); // Write all one's to stencil buffer glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glStencilFunc(GL_ALWAYS, 1, 0xFF); glStencilMask(0xFF); // Disable vertex attribute 0, as we don't use it glDisableVertexAttribArray(0); // Make sure polygons are filled in any case if (mWireframeMode) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Draw glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast<GLsizei>(2 * mWaterElementCount)); // Don't write anything to stencil buffer now glStencilMask(0x00); // Re-enable writing to the color buffer glColorMask(true, true, true, true); // Reset wireframe mode, if enabled if (mWireframeMode) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //////////////////////////////////////////////////// // Draw clouds with stencil test //////////////////////////////////////////////////// assert(mCurrentCloudElementCount == mCloudElementCount); // Use program mShaderManager->ActivateProgram<ProgramType::Clouds>(); // Bind VBO glBindBuffer(GL_ARRAY_BUFFER, *mCloudVBO); CheckOpenGLError(); // Upload buffer glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(CloudElement) * mCloudElementCount, mCloudElementBuffer.get()); // Describe vertex attribute 0 glVertexAttribPointer(static_cast<GLuint>(VertexAttributeType::SharedAttribute0), 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), nullptr); CheckOpenGLError(); // Enable vertex attribute 0 glEnableVertexAttribArray(0); // Enable stenciling - only draw where there are no 1's glStencilFunc(GL_NOTEQUAL, 1, 0xFF); // Bind atlas texture glBindTexture(GL_TEXTURE_2D, *mCloudTextureAtlasOpenGLHandle); CheckOpenGLError(); if (mWireframeMode) glLineWidth(0.1f); // Draw glDrawArrays(GL_TRIANGLES, 0, static_cast<GLint>(6 * mCloudElementCount)); //////////////////////////////////////////////////// // Disable stencil test glDisable(GL_STENCIL_TEST); } void RenderContext::UploadLandAndWaterStart(size_t slices) { // // Prepare land buffer // if (slices + 1 != mLandElementCount) { // Bind VBO glBindBuffer(GL_ARRAY_BUFFER, *mLandVBO); CheckOpenGLError(); // Realloc GPU buffer mLandElementCount = slices + 1; glBufferData(GL_ARRAY_BUFFER, mLandElementCount * sizeof(LandElement), nullptr, GL_DYNAMIC_DRAW); CheckOpenGLError(); // Realloc buffer mLandElementBuffer.reset(new LandElement[mLandElementCount]); } // Reset current count of land elements mCurrentLandElementCount = 0u; // // Prepare water buffer // if (slices + 1 != mWaterElementCount) { // Bind VBO glBindBuffer(GL_ARRAY_BUFFER, *mWaterVBO); CheckOpenGLError(); // Realloc GPU buffer mWaterElementCount = slices + 1; glBufferData(GL_ARRAY_BUFFER, mWaterElementCount * sizeof(WaterElement), nullptr, GL_DYNAMIC_DRAW); CheckOpenGLError(); // Realloc buffer mWaterElementBuffer.reset(new WaterElement[mWaterElementCount]); } // Reset count of water elements mCurrentWaterElementCount = 0u; } void RenderContext::UploadLandAndWaterEnd() { // Bind land VBO glBindBuffer(GL_ARRAY_BUFFER, *mLandVBO); CheckOpenGLError(); // Upload buffer glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(LandElement) * mLandElementCount, mLandElementBuffer.get()); // Describe vertex attribute 1 glVertexAttribPointer(static_cast<GLuint>(VertexAttributeType::SharedAttribute1), 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr); CheckOpenGLError(); // Bind water VBO glBindBuffer(GL_ARRAY_BUFFER, *mWaterVBO); CheckOpenGLError(); // Upload water buffer glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(WaterElement) * mWaterElementCount, mWaterElementBuffer.get()); // No need to describe water's vertex attribute as it is dedicated and we have described it already once and for all } void RenderContext::RenderLand() { assert(mCurrentLandElementCount == mLandElementCount); // Use program mShaderManager->ActivateProgram<ProgramType::Land>(); // Bind texture glBindTexture( GL_TEXTURE_2D, mTextureRenderManager->GetOpenGLHandle(TextureGroupType::Land, 0)); CheckOpenGLError(); // Disable vertex attribute 0 glDisableVertexAttribArray(0); if (mWireframeMode) glLineWidth(0.1f); // Draw glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast<GLsizei>(2 * mLandElementCount)); } void RenderContext::RenderWater() { assert(mCurrentWaterElementCount == mWaterElementCount); // Use program mShaderManager->ActivateProgram<ProgramType::Water>(); // Bind texture glBindTexture( GL_TEXTURE_2D, mTextureRenderManager->GetOpenGLHandle(TextureGroupType::Water, 0)); CheckOpenGLError(); // Disable vertex attribute 0 glDisableVertexAttribArray(0); if (mWireframeMode) glLineWidth(0.1f); // Draw glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast<GLsizei>(2 * mWaterElementCount)); } void RenderContext::RenderEnd() { // Communicate end to child contextes mTextRenderContext->RenderEnd(); glFlush(); } //////////////////////////////////////////////////////////////////////////////////// void RenderContext::UpdateOrthoMatrix() { static constexpr float zFar = 1000.0f; static constexpr float zNear = 1.0f; // Calculate new matrix mOrthoMatrix[0][0] = 2.0f / mVisibleWorldWidth; mOrthoMatrix[1][1] = 2.0f / mVisibleWorldHeight; mOrthoMatrix[2][2] = -2.0f / (zFar - zNear); mOrthoMatrix[3][0] = -2.0f * mCamX / mVisibleWorldWidth; mOrthoMatrix[3][1] = -2.0f * mCamY / mVisibleWorldHeight; mOrthoMatrix[3][2] = -(zFar + zNear) / (zFar - zNear); mOrthoMatrix[3][3] = 1.0f; // Set parameters in all programs mShaderManager->ActivateProgram<ProgramType::Land>(); mShaderManager->SetProgramParameter<ProgramType::Land, ProgramParameterType::OrthoMatrix>( mOrthoMatrix); mShaderManager->ActivateProgram<ProgramType::Water>(); mShaderManager->SetProgramParameter<ProgramType::Water, ProgramParameterType::OrthoMatrix>( mOrthoMatrix); mShaderManager->ActivateProgram<ProgramType::MatteWater>(); mShaderManager->SetProgramParameter<ProgramType::MatteWater, ProgramParameterType::OrthoMatrix>( mOrthoMatrix); mShaderManager->ActivateProgram<ProgramType::Matte>(); mShaderManager->SetProgramParameter<ProgramType::Matte, ProgramParameterType::OrthoMatrix>( mOrthoMatrix); // Update all ships for (auto & ship : mShips) { ship->UpdateOrthoMatrix(mOrthoMatrix); } } void RenderContext::UpdateVisibleWorldCoordinates() { // Calculate new dimensions mVisibleWorldHeight = 2.0f * 70.0f / (mZoom + 0.001f); mVisibleWorldWidth = static_cast<float>(mCanvasWidth) / static_cast<float>(mCanvasHeight) * mVisibleWorldHeight; mCanvasToVisibleWorldHeightRatio = static_cast<float>(mCanvasHeight) / mVisibleWorldHeight; // Update all ships for (auto & ship : mShips) { ship->UpdateVisibleWorldCoordinates( mVisibleWorldHeight, mVisibleWorldWidth, mCanvasToVisibleWorldHeightRatio); } } void RenderContext::UpdateAmbientLightIntensity() { // Set parameters in all programs mShaderManager->ActivateProgram<ProgramType::Clouds>(); mShaderManager->SetProgramParameter<ProgramType::Clouds, ProgramParameterType::AmbientLightIntensity>( mAmbientLightIntensity); mShaderManager->ActivateProgram<ProgramType::Land>(); mShaderManager->SetProgramParameter<ProgramType::Land, ProgramParameterType::AmbientLightIntensity>( mAmbientLightIntensity); mShaderManager->ActivateProgram<ProgramType::Water>(); mShaderManager->SetProgramParameter<ProgramType::Water, ProgramParameterType::AmbientLightIntensity>( mAmbientLightIntensity); // Update all ships for (auto & ship : mShips) { ship->UpdateAmbientLightIntensity(mAmbientLightIntensity); } } void RenderContext::UpdateSeaWaterTransparency() { // Set parameter in all programs mShaderManager->ActivateProgram<ProgramType::Water>(); mShaderManager->SetProgramParameter<ProgramType::Water, ProgramParameterType::WaterTransparency>( mSeaWaterTransparency); } void RenderContext::UpdateWaterLevelOfDetail() { // Set parameter in all ships for (auto & s : mShips) { s->UpdateWaterLevelThreshold(mWaterLevelOfDetail); } } void RenderContext::UpdateShipRenderMode() { // Set parameter in all ships for (auto & s : mShips) { s->UpdateShipRenderMode(mShipRenderMode); } } void RenderContext::UpdateVectorFieldRenderMode() { // Set parameter in all ships for (auto & s : mShips) { s->UpdateVectorFieldRenderMode(mVectorFieldRenderMode); } } void RenderContext::UpdateShowStressedSprings() { // Set parameter in all ships for (auto & s : mShips) { s->UpdateShowStressedSprings(mShowStressedSprings); } } void RenderContext::UpdateWireframeMode() { // Set parameter in all ships for (auto & s : mShips) { s->UpdateWireframeMode(mWireframeMode); } } }
b4e79d9db61be4e443665e9fff76539eb9f2d99d
8d8d2b962599f843de66d6c994ce6261bbcdce8a
/Engine/Engine/BTActions.h
7c75dc8de07fe26cec5e077534034aa61b460c9e
[]
no_license
muratbekb95/CustomGameEngine
27aaf574e32712446dc5fc89b6647b53880a1266
871d447d52949ad5f38406e04a467a5179b2120c
refs/heads/master
2023-02-13T22:24:05.952672
2021-01-14T08:00:42
2021-01-14T08:00:42
307,115,474
0
1
null
2021-01-12T15:48:50
2020-10-25T14:20:43
C++
UTF-8
C++
false
false
2,358
h
#pragma once #include "AISystem/BrainTree.h" #include "AIAgent.h" #include "math_statics.h" #include <iostream> namespace bt = BrainTree; class MoveTo : public bt::Leaf { Status update() override { Vector3 goal = blackboard->getVector(BBPositionName); OpenSteer::Vec3 SteeringForce; SteeringForce = owner->steerForSeek(Vector3ToVec3(goal)); if (goal.Distance(goal, Vec3ToVector3(owner->position())) < 10.0f) { return Status::Success; } owner->applySteeringForce(SteeringForce, 1 / 60.0f); return Status::Running; } public: std::string BBPositionName; }; class MoveOut : public bt::Leaf { Status update() override { Vector3 Out = owner->m_Camera->GetPosition(); Out.y = 0.0f; OpenSteer::Vec3 SteeringForce; SteeringForce = owner->steerForFlee(Vector3ToVec3(Out)); owner->applySteeringForce(SteeringForce, 1 / 60.0f); if (Out.Distance(Out, Vec3ToVector3(owner->position())) > 100.0f) { return Status::Success; } return Status::Running; } }; class RandomPosition : public bt::Leaf { Status update() override { Vector3 point = GetRandomPointInSquare(Vector3(0, 0, 0), radius); blackboard->setVector(BBPositionName, point); return Status::Success; } public: std::string BBPositionName; float radius; }; class Wait : public bt::Leaf { Status update() override { blackboard->getVector(BBPositionName); std::cout << "Wait" << std::endl; return Status::Success; } public: std::string BBPositionName; }; class CheckForHummer : public bt::Decorator { public: AIAgent* owner; public: Status update() override { auto status = child->tick(); if (status == Status::Success) { return Status::Success; } } }; class Interrupt : public bt::Decorator { public: Status update() override { if (BB->getBool(BBBoolName)) { auto status = child->tick(); if (status == Status::Success) { return Status::Success; } } else { return Status::Failure; } } std::string BBBoolName; SPBlackboard BB; };
341562a84a076c03aa95a62025d89fbbe4aa73e4
0dcf23fa69de6cfbc077b128b692980a99fb8602
/flarb_img_controller/src/cImage.cpp
b03f83b947dcc50ffccea4f86c5c139d896150ff
[]
no_license
riemervdzee/Flarb
be95f028933d171976753d8954ca00f270cbbdd8
cdfaeed72ed6d8fd60a0a46fa23c4e44d9f88c75
refs/heads/master
2021-01-02T08:14:09.075834
2013-07-02T09:11:40
2013-07-02T09:11:40
8,626,400
1
0
null
null
null
null
UTF-8
C++
false
false
7,217
cpp
#include <iostream> #include <cstring> #include "flarb_img_mapbuilder/MapImage.h" #include "flarb_img_controller/cImage.h" using namespace std; // TODO add error for non x86-64 arches // Prototypes of helper functions static unsigned int CountBitsSet( unsigned int v); static inline int asm_ffs( int x); static inline int asm_fls( int x); /* * give x, y, msg the Pixel and returns * 1 == available * 0 == none */ int cImage::CountBlockedPixel( int x, int y) const { //multiply it to the right row int posY = y * _bytesRow; //how far in the x array int posX = x / 8; //how far in the byte int byteX = x % 8; //value if(_msg->data[posX + posY] & ( 1 << byteX )) return 1; else return 0; } /* * Optimized version to check whole lines on the X axis. * If you are about to check a rectangle, this version is faster than the Y version * * This is quite a mess, I know I know.. * * Arguments: * int x, y Is the start position * int width The width of the line to check (note, it advances to the _right_) * * Returns: * int amount of blocking pixels */ int cImage::CountBlockedLineX( int x, int y, int width) const { // Amount of blocked pixels int blocked = 0; // Get the basic y-offset int posY = y * _bytesRow; // Get the index of the first and last byte we need to check // Check these special cases first, as we don't check the whole byte int pos_start = posY + x / 8; int pos_end = posY + (x + width - 1) / 8; // Bits we are interested in for the special cases // Basically we shift the amount of bits we don't want int bit_start = x % 8; // Invert the bit (8 - bit_end), but add 1 again. int bit_end = 7 - ((x + width - 1) % 8); // Get the special cases uint8_t temp; temp = _msg->data[pos_start] >> bit_start; blocked += CountBitsSet( temp); // Increase start-position and get the pos_width pos_start++; int pos_width = pos_end - pos_start; // Go through all remaining bytes for(int i = 0; i < pos_width; i++, pos_start++) { temp = _msg->data[pos_start]; blocked += CountBitsSet( temp); } // Get the last, pos_end for caching temp = _msg->data[pos_end] << bit_end; blocked += CountBitsSet( temp); // Return blocked return blocked; } /* * Optimized version to check whole lines on the Y axis. * Note this is quite slow, due we have to jump through the whole array * * Arguments: * int x, y Is the start position * int height The height of the line to check (note, it advances to the _bottom_) * * Returns: * int amount of blocking pixels */ int cImage::CountBlockedLineY( int x, int y, int height) const { // Amount of blocked pixels int blocked = 0; // multiply bytesrow with y, to get the y-offset int posY = y * _bytesRow; // how far in the x array int posX = x / 8; // how far in the byte int byteX = x % 8; // Get the first offset, and get the mask we are trying to test int offset = posX + posY; int mask = ( 1 << byteX ); // Go through the whole line for(int i = 0; i < height; i++, offset += _bytesRow) if( _msg->data[offset] & mask) blocked++; // Return result return blocked; } /* * Helper func to count a whole Rectangle. Uses CountBlockedLineX * * Arguments: * int x, y Is the start position * int width The width of the line to check (note, it advances to the _right_) * int height The height of the line to check (note, it advances to the _bottom_) * * Returns: * int amount of blocking pixels */ int cImage::CountBlockedRectangle ( int x, int y, int width, int height) const { int amount = 0; // All line X for(int _y = 0; _y < height; _y++) { amount += CountBlockedLineX( x, y + _y, width); } return amount; } /* * Advances from the position given to the left, till the first bit is found * * X, Y the position where to start (note, the current position is also checked) * * Returns, position of first bit encountered. -1 if no bit is found (highly unlikely) */ int cImage::GetXLeft( int x, int y) const { // multiply bytesrow with y, to get the y-offset int posY = y * _bytesRow; // how far in the x array int posX = x / 8; // The special case is the byte where X already belongs in int bitPosX = x % 8; // Generic offset int offset = posX + posY; // Mask the bits we don't want to 0. uint8_t temp = ( _msg->data[offset] >> bitPosX) << bitPosX; // Check if we got a result int ret = asm_ffs( temp); if(ret != 0) return ret + (posX * 8); // We handled the first byte, so decrease posX--; offset--; // Go through all remaining bytes for( ; posX >= 0; posX--, offset--) { int ret = asm_ffs( _msg->data[offset]); if(ret != 0) return ret + (posX * 8); } return 0; } /* * Advances from the position given to the right, till the first bit is found */ int cImage::GetXRight( int x, int y) const { // multiply bytesrow with y, to get the y-offset int posY = y * _bytesRow; // how far in the x array int posX = x / 8; // The special case is the byte where X already belongs in int bitPosX = 7 - ((x - 1) % 8); // Generic offset int offset = posX + posY; // Mask the bits we don't want to 0. uint8_t temp = ( _msg->data[offset] << bitPosX) >> bitPosX; // Check if we got a result int ret = asm_ffs( temp); if(ret != 0) return ret + (posX * 8); // We handled the first byte, so increase posX++; offset++; // Go through all remaining bytes int size = (_msg->imageX / 8); for( ; posX < size; posX++, offset++) { int ret = asm_ffs( _msg->data[offset]); if(ret != 0) return ret + (posX * 8); } return _msg->imageX - 1; } /* * Static helper function to count the amount of bits set in a uint * From: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel */ static unsigned int CountBitsSet( unsigned int v) { unsigned int c; v = v - ((v >> 1) & 0x55555555); // reuse input as temporary v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp c = (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; // count return c; } /** * ffs - find first set bit in word * @x: the word to search * * This is defined the same way as the libc and compiler builtin ffs * routines, therefore differs in spirit from the other bitops. * * ffs(value) returns 0 if value is 0 or the position of the first * set bit if value is nonzero. The first (least significant) bit * is at position 1. * From: https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/bitops.h */ static inline int asm_ffs(int val) { int ret; asm("bsfl %1,%0" : "=r" (ret) : "rm" (val), "0" (-1)); return ret + 1; } /** * fls - find last set bit in word * @x: the word to search * * This is defined in a similar way as the libc and compiler builtin * ffs, but returns the position of the most significant set bit. * * fls(value) returns 0 if value is 0 or the position of the last * set bit if value is nonzero. The last (most significant) bit is * at position 32. * From: https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/bitops.h */ static inline int asm_fls(int val) { int ret; asm("bsrl %1,%0" : "=r" (ret) : "rm" (val), "0" (-1)); return ret + 1; }
874950eb20566325274fa83f54f8c277f9c83224
f5c97a3988b1bfd3a5249b54fe1282a7bd79900e
/chapter_15/acpp_15_0-1/string_pic.hpp
7b65c910faa4daf41c4659eb0ec95de7cd5bcc69
[]
no_license
DM-X/acpp_solutions
8ff6a86228b860b240f7e4287d952a2b19a54af9
a58462281ac88a4114edf014bb7eb4c9b7447733
refs/heads/master
2020-12-05T02:49:25.349064
2020-01-05T23:24:14
2020-01-05T23:24:14
231,986,945
0
0
null
null
null
null
UTF-8
C++
false
false
603
hpp
#ifndef GUARD_string_pic_h #define GUARD_string_pic_h #include "pic_base.hpp" //must be included (here not in cpp) class String_Pic: public Pic_base { friend class Picture; protected: static void pad(std::ostream& os, wd_sz beg, wd_sz end) { while (beg != end) { os << " "; ++beg; } } private: std::vector<std::string> data; String_Pic(const std::vector<std::string>& v): data(v) { } wd_sz width() const; ht_sz height() const {return data.size();} void display(std::ostream&, ht_sz, bool) const; }; #endif
094e69f451200cb860b0b03a5ec089ec430e4792
0d620d3f73b8201d0e8c2996c6b5b006bca9b77b
/dialogcanny.h
2d758d0a53373d4a44f650e626c41b96e3f21abc
[]
no_license
Ingeborg87/EAMViewer
e294ada5bccee023c5a6cfb1174de2563d48a16c
1844f43bdbcf18ceb104ca8c8bf3e3b85e5d7735
refs/heads/master
2020-05-22T08:18:06.682848
2017-01-06T16:37:12
2017-01-06T16:37:12
21,019,574
0
0
null
null
null
null
UTF-8
C++
false
false
814
h
#ifndef DIALOGCANNY_H #define DIALOGCANNY_H #include <QDialog> #include <QKeyEvent> namespace Ui { class DialogCanny; } class DialogCanny : public QDialog { Q_OBJECT public: explicit DialogCanny(QWidget *parent = 0); ~DialogCanny(); int threshold1; int threshold2; int sobelSize; bool L2; private: Ui::DialogCanny *ui; void closeEvent(QCloseEvent *); void keyPressEvent(QKeyEvent* prEvent); private slots: void threshold1Changed(int i); void threshold2Changed(int i); void sobelSizeChanged(int i); void L2Changed(bool b); signals: void signalThreshold1Changed(); void signalThreshold2Changed(); void signalSobelSizeChanged(); void signalL2Changed(); void signalXDialog(); void signalPressReturn(); }; #endif // DIALOGCANNY_H
d2ecf6820131f691cabbde8a27ee017209183eea
657ab6baadf944d98291a5524d8a9719a333b7a3
/app/canvas/inspector/title.h
2a82ef10a6fc34281409937addc770523a7ccf22
[ "MIT" ]
permissive
mkeeter/antimony
dd40cceb7d688408480f860b3041c55980cfef8f
f6a56dd786d05294bd9d6db5d8e51a0287af3b30
refs/heads/develop
2023-08-23T00:24:37.589790
2023-01-18T13:38:16
2023-01-18T13:38:16
15,458,279
2,204
203
null
2022-11-22T17:42:19
2013-12-26T18:42:31
C++
UTF-8
C++
false
false
1,405
h
#pragma once #include <QGraphicsObject> class Node; class InspectorFrame; class InspectorButton; class InspectorTitle : public QGraphicsObject { Q_OBJECT public: explicit InspectorTitle(Node* n, InspectorFrame* parent); /* * Override QGraphicsObject functions */ QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; /* * Update border of name field */ void setNameValid(bool valid); /* * Update text of title field */ void setTitle(QString title); /* * Returns the minimum width of this row * (used in inspector layout) */ float minWidth() const; /* * Sets the row's width */ void setWidth(float width); /* * Installs a new button and updates layout */ void addButton(InspectorButton* b); signals: /* * Emitted when the layout has changed * (which may cause the parent InspectorFrame to redo layout) */ void layoutChanged(); protected: static int TOP_PADDING; static int MIN_TITLE_PADDING; static int BUTTON_PADDING; QGraphicsTextItem* name; QGraphicsTextItem* title; QList<InspectorButton*> buttons; /* * Represents padding between name and title fields */ int title_padding; };
5632c351340b4fa8c51f797860f50ee968f77a4a
3e0405e67a035d3b9ce31a6e83bd805b6dc94041
/src/core/domain/Hypervisor.cc
1bb32efb1788ae001a97bd1ad12021c8a51ba4f5
[ "Apache-2.0" ]
permissive
IntroVirt/IntroVirt
33ec7fab4424656717d6ccb9ee87ba77e8f69b1f
e0953d1c9a12b6e501f6a876a07d188b7b80254a
refs/heads/main
2022-12-22T05:47:27.038862
2022-12-15T22:52:21
2022-12-16T00:50:10
339,445,106
46
10
Apache-2.0
2022-12-08T17:01:42
2021-02-16T15:37:13
C++
UTF-8
C++
false
false
4,624
cc
/* * Copyright 2021 Assured Information Security, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <introvirt/core/domain/Hypervisor.hh> #include <introvirt/core/exception/UnsupportedHypervisorException.hh> #include "../../hypervisor/kvm/KvmHypervisor.hh" #include <boost/algorithm/string/predicate.hpp> #include <log4cxx/logger.h> #include <cstdlib> #include <dlfcn.h> #if __GNUC__ >= 8 #include <filesystem> namespace filesystem = std::filesystem; #else #include <experimental/filesystem> namespace filesystem = std::experimental::filesystem; #endif namespace introvirt { static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("introvirt.core.Hypervisor")); // Try the builtin hypervisor support static std::unique_ptr<Hypervisor> try_builtin_hypervisors() { // Try kvm first try { auto result = std::make_unique<kvm::KvmHypervisor>(); return result; } catch (...) { } return nullptr; } /* * Retrieves the path to the plugins folder */ static std::string get_plugin_path() { // See if the user has specified a custom INTROVIRT_PLUGIN_PATH const char* env_plugin_path = getenv("INTROVIRT_PLUGIN_PATH"); if (env_plugin_path != nullptr) { return env_plugin_path; } return "/var/lib/introvirt/plugins"; } /* * Get the path to the hypervisor plugin folder */ static std::string get_hypervisor_plugin_path() { return get_plugin_path() + "/hypervisor"; } std::unique_ptr<Hypervisor> Hypervisor::instance() { std::unique_ptr<Hypervisor> result = try_builtin_hypervisors(); if (result) { return result; } filesystem::path hypervisor_plugin_path(get_hypervisor_plugin_path()); if (!filesystem::is_directory(hypervisor_plugin_path)) { throw UnsupportedHypervisorException(); } for (auto& entry : filesystem::directory_iterator(hypervisor_plugin_path)) { const std::string filename(entry.path().filename().string()); if (boost::algorithm::ends_with(filename, ".so")) { LOG4CXX_DEBUG(logger, "Discovered hypervisor plugin: " << filename); const std::string full_path = get_hypervisor_plugin_path() + "/" + filename; // Try to open it void* plugin_handle = dlopen(full_path.c_str(), RTLD_NOW); if (plugin_handle == nullptr) { const char* errstr = dlerror(); LOG4CXX_DEBUG(logger, "Plugin " + filename + ": " + errstr); continue; } // Get the CreateHypervisor function from the library void* function = dlsym(plugin_handle, "create_hypervisor_instance"); if (function != nullptr) { // Call the function to create an instance using fn_create_hyperisor_instance = std::unique_ptr<Hypervisor> (*)(); auto create_hyperisor_instance = reinterpret_cast<fn_create_hyperisor_instance>(function); try { result = create_hyperisor_instance(); if (!result) { LOG4CXX_WARN(logger, "Plugin " + filename + ": create_hypervisor_instance() returned nullptr"); goto error; } LOG4CXX_DEBUG(logger, "Selected hypervisor plugin " + filename); return result; } catch (UnsupportedHypervisorException& ex) { LOG4CXX_DEBUG(logger, "Plugin " + filename + ": Failed to attach to hypervisor"); } } else { LOG4CXX_WARN(logger, "Plugin " + filename + ": missing symbol 'create_hypervisor_instance'"); goto error; } error: dlclose(plugin_handle); } } // Didn't find a valid plugin throw UnsupportedHypervisorException(); } Hypervisor::Hypervisor() = default; Hypervisor::~Hypervisor() = default; } // namespace introvirt
869e228a33db3d79f5a967cf1c8058a55103f5ac
94ae4cb762ff4f566aa2dbf3cc0c5839f522e139
/PEnemyItem.cpp
74e124898923f4c583ead1936589eed82c427e09
[]
no_license
FrancoL03/Game
06353b641d22716a19a71acdec3b390087f61bdd
f9c076a4da008c99bbfc2b87b14e6b437edc1fd3
refs/heads/master
2023-08-24T23:17:54.361677
2021-10-12T08:57:16
2021-10-12T08:57:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
#include "PEnemyItem.h" PEnemyItem::PEnemyItem() { } PEnemyItem::PEnemyItem(QGraphicsScene *scene, unique_ptr<Enemy> *enemy): EnemyItem(scene,enemy) { pix->setPixmap(QPixmap(":/images/penemy.png")); } void PEnemyItem::addSurrondingTiles(TileItem * tile) { surrondingTiles.push_back(tile); }
93af2f678d2b031bbdf01435099cf5f3bb554fef
ca5484c642f9f108c6a11f122571d75517f6556c
/node_modules/canvas/src/Canvas.cc
bc670c44ad125dbe20294adb7e1ed8341f2d4738
[ "MIT" ]
permissive
ConradIrwin/canvas-animation-loader
899a19e403408b7af1ef65c79324bcada3039260
9c9eaa03601a975c083ab2c9c005a3fcb8ccf4d5
refs/heads/master
2023-03-22T22:40:30.859020
2015-09-09T19:57:17
2015-09-09T19:57:17
42,083,807
3
0
null
null
null
null
UTF-8
C++
false
false
15,434
cc
// // Canvas.cc // // Copyright (c) 2010 LearnBoost <[email protected]> // #include "Canvas.h" #include "PNG.h" #include "CanvasRenderingContext2d.h" #include <assert.h> #include <stdlib.h> #include <string.h> #include <node_buffer.h> #include <node_version.h> #include <cairo-pdf.h> #include <cairo-svg.h> #include "closure.h" #ifdef HAVE_JPEG #include "JPEGStream.h" #endif Persistent<FunctionTemplate> Canvas::constructor; /* * Initialize Canvas. */ void Canvas::Initialize(Handle<Object> target) { NanScope(); // Constructor Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>(Canvas::New); NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanNew("Canvas")); // Prototype Local<ObjectTemplate> proto = ctor->PrototypeTemplate(); NODE_SET_PROTOTYPE_METHOD(ctor, "toBuffer", ToBuffer); NODE_SET_PROTOTYPE_METHOD(ctor, "streamPNGSync", StreamPNGSync); #ifdef HAVE_JPEG NODE_SET_PROTOTYPE_METHOD(ctor, "streamJPEGSync", StreamJPEGSync); #endif proto->SetAccessor(NanNew("type"), GetType); proto->SetAccessor(NanNew("width"), GetWidth, SetWidth); proto->SetAccessor(NanNew("height"), GetHeight, SetHeight); NanSetTemplate(proto, "PNG_NO_FILTERS", NanNew<Uint32>(PNG_NO_FILTERS)); NanSetTemplate(proto, "PNG_FILTER_NONE", NanNew<Uint32>(PNG_FILTER_NONE)); NanSetTemplate(proto, "PNG_FILTER_SUB", NanNew<Uint32>(PNG_FILTER_SUB)); NanSetTemplate(proto, "PNG_FILTER_UP", NanNew<Uint32>(PNG_FILTER_UP)); NanSetTemplate(proto, "PNG_FILTER_AVG", NanNew<Uint32>(PNG_FILTER_AVG)); NanSetTemplate(proto, "PNG_FILTER_PAETH", NanNew<Uint32>(PNG_FILTER_PAETH)); NanSetTemplate(proto, "PNG_ALL_FILTERS", NanNew<Uint32>(PNG_ALL_FILTERS)); target->Set(NanNew("Canvas"), ctor->GetFunction()); } /* * Initialize a Canvas with the given width and height. */ NAN_METHOD(Canvas::New) { NanScope(); int width = 0, height = 0; canvas_type_t type = CANVAS_TYPE_IMAGE; if (args[0]->IsNumber()) width = args[0]->Uint32Value(); if (args[1]->IsNumber()) height = args[1]->Uint32Value(); if (args[2]->IsString()) type = !strcmp("pdf", *String::Utf8Value(args[2])) ? CANVAS_TYPE_PDF : !strcmp("svg", *String::Utf8Value(args[2])) ? CANVAS_TYPE_SVG : CANVAS_TYPE_IMAGE; Canvas *canvas = new Canvas(width, height, type); canvas->Wrap(args.This()); NanReturnValue(args.This()); } /* * Get type string. */ NAN_GETTER(Canvas::GetType) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); NanReturnValue(NanNew<String>(canvas->isPDF() ? "pdf" : canvas->isSVG() ? "svg" : "image")); } /* * Get width. */ NAN_GETTER(Canvas::GetWidth) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); NanReturnValue(NanNew<Number>(canvas->width)); } /* * Set width. */ NAN_SETTER(Canvas::SetWidth) { NanScope(); if (value->IsNumber()) { Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); canvas->width = value->Uint32Value(); canvas->resurface(args.This()); } } /* * Get height. */ NAN_GETTER(Canvas::GetHeight) { NanScope(); Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); NanReturnValue(NanNew<Number>(canvas->height)); } /* * Set height. */ NAN_SETTER(Canvas::SetHeight) { NanScope(); if (value->IsNumber()) { Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); canvas->height = value->Uint32Value(); canvas->resurface(args.This()); } } /* * Canvas::ToBuffer callback. */ static cairo_status_t toBuffer(void *c, const uint8_t *data, unsigned len) { closure_t *closure = (closure_t *) c; if (closure->len + len > closure->max_len) { uint8_t *data; unsigned max = closure->max_len; do { max *= 2; } while (closure->len + len > max); data = (uint8_t *) realloc(closure->data, max); if (!data) return CAIRO_STATUS_NO_MEMORY; closure->data = data; closure->max_len = max; } memcpy(closure->data + closure->len, data, len); closure->len += len; return CAIRO_STATUS_SUCCESS; } /* * EIO toBuffer callback. */ #if NODE_VERSION_AT_LEAST(0, 6, 0) void Canvas::ToBufferAsync(uv_work_t *req) { #elif NODE_VERSION_AT_LEAST(0, 5, 4) void Canvas::EIO_ToBuffer(eio_req *req) { #else int Canvas::EIO_ToBuffer(eio_req *req) { #endif closure_t *closure = (closure_t *) req->data; closure->status = canvas_write_to_png_stream( closure->canvas->surface() , toBuffer , closure); #if !NODE_VERSION_AT_LEAST(0, 5, 4) return 0; #endif } /* * EIO after toBuffer callback. */ #if NODE_VERSION_AT_LEAST(0, 6, 0) void Canvas::ToBufferAsyncAfter(uv_work_t *req) { #else int Canvas::EIO_AfterToBuffer(eio_req *req) { #endif NanScope(); closure_t *closure = (closure_t *) req->data; #if NODE_VERSION_AT_LEAST(0, 6, 0) delete req; #else ev_unref(EV_DEFAULT_UC); #endif if (closure->status) { Local<Value> argv[1] = { Canvas::Error(closure->status) }; closure->pfn->Call(1, argv); } else { Local<Object> buf = NanNewBufferHandle((char*)closure->data, closure->len); memcpy(Buffer::Data(buf), closure->data, closure->len); Local<Value> argv[2] = { NanNew(NanNull()), buf }; closure->pfn->Call(2, argv); } closure->canvas->Unref(); delete closure->pfn; closure_destroy(closure); free(closure); #if !NODE_VERSION_AT_LEAST(0, 6, 0) return 0; #endif } /* * Convert PNG data to a node::Buffer, async when a * callback function is passed. */ NAN_METHOD(Canvas::ToBuffer) { NanScope(); cairo_status_t status; uint32_t compression_level = 6; uint32_t filter = PNG_ALL_FILTERS; Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); // TODO: async / move this out if (canvas->isPDF() || canvas->isSVG()) { cairo_surface_finish(canvas->surface()); closure_t *closure = (closure_t *) canvas->closure(); Local<Object> buf = NanNewBufferHandle((char*) closure->data, closure->len); NanReturnValue(buf); } if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { if (args[1]->StrictEquals(NanNew<String>("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); if (tmp == 0) { good = false; } else { compression_level = tmp; } } } else { good = false; } if (good) { if (compression_level > 9) { return NanThrowRangeError("Allowed compression levels lie in the range [0, 9]."); } } else { return NanThrowTypeError("Compression level must be a number."); } } if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[2]->Uint32Value(); } else { return NanThrowTypeError("Invalid filter value."); } } } // Async if (args[0]->IsFunction()) { closure_t *closure = (closure_t *) malloc(sizeof(closure_t)); status = closure_init(closure, canvas, compression_level, filter); // ensure closure is ok if (status) { closure_destroy(closure); free(closure); return NanThrowError(Canvas::Error(status)); } // TODO: only one callback fn in closure canvas->Ref(); closure->pfn = new NanCallback(args[0].As<Function>()); #if NODE_VERSION_AT_LEAST(0, 6, 0) uv_work_t* req = new uv_work_t; req->data = closure; uv_queue_work(uv_default_loop(), req, ToBufferAsync, (uv_after_work_cb)ToBufferAsyncAfter); #else eio_custom(EIO_ToBuffer, EIO_PRI_DEFAULT, EIO_AfterToBuffer, closure); ev_ref(EV_DEFAULT_UC); #endif NanReturnUndefined(); // Sync } else { closure_t closure; status = closure_init(&closure, canvas, compression_level, filter); // ensure closure is ok if (status) { closure_destroy(&closure); return NanThrowError(Canvas::Error(status)); } TryCatch try_catch; status = canvas_write_to_png_stream(canvas->surface(), toBuffer, &closure); if (try_catch.HasCaught()) { closure_destroy(&closure); NanReturnValue(try_catch.ReThrow()); } else if (status) { closure_destroy(&closure); return NanThrowError(Canvas::Error(status)); } else { Local<Object> buf = NanNewBufferHandle((char *)closure.data, closure.len); closure_destroy(&closure); NanReturnValue(buf); } } } /* * Canvas::StreamPNG callback. */ static cairo_status_t streamPNG(void *c, const uint8_t *data, unsigned len) { NanScope(); closure_t *closure = (closure_t *) c; Local<Object> buf = NanNewBufferHandle((char *)data, len); Local<Value> argv[3] = { NanNew(NanNull()) , buf , NanNew<Number>(len) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure->fn, 3, argv); return CAIRO_STATUS_SUCCESS; } /* * Stream PNG data synchronously. */ NAN_METHOD(Canvas::StreamPNGSync) { NanScope(); uint32_t compression_level = 6; uint32_t filter = PNG_ALL_FILTERS; // TODO: async as well if (!args[0]->IsFunction()) return NanThrowTypeError("callback function required"); if (args.Length() > 1 && !(args[1]->StrictEquals(NanUndefined()) && args[2]->StrictEquals(NanUndefined()))) { if (!args[1]->StrictEquals(NanUndefined())) { bool good = true; if (args[1]->IsNumber()) { compression_level = args[1]->Uint32Value(); } else if (args[1]->IsString()) { if (args[1]->StrictEquals(NanNew<String>("0"))) { compression_level = 0; } else { uint32_t tmp = args[1]->Uint32Value(); if (tmp == 0) { good = false; } else { compression_level = tmp; } } } else { good = false; } if (good) { if (compression_level > 9) { return NanThrowRangeError("Allowed compression levels lie in the range [0, 9]."); } } else { return NanThrowTypeError("Compression level must be a number."); } } if (!args[2]->StrictEquals(NanUndefined())) { if (args[2]->IsUint32()) { filter = args[2]->Uint32Value(); } else { return NanThrowTypeError("Invalid filter value."); } } } Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); closure_t closure; closure.fn = Handle<Function>::Cast(args[0]); closure.compression_level = compression_level; closure.filter = filter; TryCatch try_catch; cairo_status_t status = canvas_write_to_png_stream(canvas->surface(), streamPNG, &closure); if (try_catch.HasCaught()) { NanReturnValue(try_catch.ReThrow()); } else if (status) { Local<Value> argv[1] = { Canvas::Error(status) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } else { Local<Value> argv[3] = { NanNew(NanNull()) , NanNew(NanNull()) , NanNew<Uint32>(0) }; NanMakeCallback(NanGetCurrentContext()->Global(), closure.fn, 1, argv); } NanReturnUndefined(); } /* * Stream JPEG data synchronously. */ #ifdef HAVE_JPEG NAN_METHOD(Canvas::StreamJPEGSync) { NanScope(); // TODO: async as well if (!args[0]->IsNumber()) return NanThrowTypeError("buffer size required"); if (!args[1]->IsNumber()) return NanThrowTypeError("quality setting required"); if (!args[2]->IsBoolean()) return NanThrowTypeError("progressive setting required"); if (!args[3]->IsFunction()) return NanThrowTypeError("callback function required"); Canvas *canvas = ObjectWrap::Unwrap<Canvas>(args.This()); closure_t closure; closure.fn = Handle<Function>::Cast(args[3]); TryCatch try_catch; write_to_jpeg_stream(canvas->surface(), args[0]->NumberValue(), args[1]->NumberValue(), args[2]->BooleanValue(), &closure); if (try_catch.HasCaught()) NanReturnValue(try_catch.ReThrow()); NanReturnUndefined(); } #endif /* * Initialize cairo surface. */ Canvas::Canvas(int w, int h, canvas_type_t t): ObjectWrap() { type = t; width = w; height = h; _surface = NULL; _closure = NULL; if (CANVAS_TYPE_PDF == t) { _closure = malloc(sizeof(closure_t)); assert(_closure); cairo_status_t status = closure_init((closure_t *) _closure, this, 0, PNG_NO_FILTERS); assert(status == CAIRO_STATUS_SUCCESS); _surface = cairo_pdf_surface_create_for_stream(toBuffer, _closure, w, h); } else if (CANVAS_TYPE_SVG == t) { _closure = malloc(sizeof(closure_t)); assert(_closure); cairo_status_t status = closure_init((closure_t *) _closure, this, 0, PNG_NO_FILTERS); assert(status == CAIRO_STATUS_SUCCESS); _surface = cairo_svg_surface_create_for_stream(toBuffer, _closure, w, h); } else { _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); assert(_surface); NanAdjustExternalMemory(4 * w * h); } } /* * Destroy cairo surface. */ Canvas::~Canvas() { switch (type) { case CANVAS_TYPE_PDF: case CANVAS_TYPE_SVG: cairo_surface_finish(_surface); closure_destroy((closure_t *) _closure); free(_closure); cairo_surface_destroy(_surface); break; case CANVAS_TYPE_IMAGE: cairo_surface_destroy(_surface); NanAdjustExternalMemory(-4 * width * height); break; } } /* * Re-alloc the surface, destroying the previous. */ void Canvas::resurface(Handle<Object> canvas) { NanScope(); Handle<Value> context; switch (type) { case CANVAS_TYPE_PDF: cairo_pdf_surface_set_size(_surface, width, height); break; case CANVAS_TYPE_SVG: // Re-surface cairo_surface_finish(_surface); closure_destroy((closure_t *) _closure); cairo_surface_destroy(_surface); closure_init((closure_t *) _closure, this, 0, PNG_NO_FILTERS); _surface = cairo_svg_surface_create_for_stream(toBuffer, _closure, width, height); // Reset context context = canvas->Get(NanNew<String>("context")); if (!context->IsUndefined()) { Context2d *context2d = ObjectWrap::Unwrap<Context2d>(context->ToObject()); cairo_t *prev = context2d->context(); context2d->setContext(cairo_create(surface())); cairo_destroy(prev); } break; case CANVAS_TYPE_IMAGE: // Re-surface int old_width = cairo_image_surface_get_width(_surface); int old_height = cairo_image_surface_get_height(_surface); cairo_surface_destroy(_surface); _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); NanAdjustExternalMemory(4 * (width * height - old_width * old_height)); // Reset context context = canvas->Get(NanNew<String>("context")); if (!context->IsUndefined()) { Context2d *context2d = ObjectWrap::Unwrap<Context2d>(context->ToObject()); cairo_t *prev = context2d->context(); context2d->setContext(cairo_create(surface())); cairo_destroy(prev); } break; } } /* * Construct an Error from the given cairo status. */ Local<Value> Canvas::Error(cairo_status_t status) { return Exception::Error(NanNew<String>(cairo_status_to_string(status))); }
377e4eff513199bc91c2ee3735c1b77777bcbd7d
404d14312f008f9648b51b16dcca9716ab865d36
/input_storage/input_storage_gate_pipe_device.cpp
55a284830f17191226a5ecddf2bc14e577e0d923
[]
no_license
eahmedali2005/GTM-DSM2
898bee7019d800a8f70f0944fb8b58815c71bcc9
6aa949eed7ca44d3cef2847c082cb52d0cb18d90
refs/heads/master
2020-03-27T09:28:45.469432
2018-08-27T19:34:13
2018-08-27T19:34:13
146,344,871
0
0
null
null
null
null
UTF-8
C++
false
false
14,669
cpp
/** WARNING: THIS FILE WAS AUTOMATICALLY GENERATED USING A SCRIPT AND A TEMPLATE DO NOT CHANGE THE CODE HERE. IF THE CODE IS INCORRECT, FIX THE TEMPLATE OR SCRIPT IF YOU WANT TO ADD NEW ITEMS, ADD THEM TO THE SCRIPT INPUT FILE AND RUN IT AFRESH */ /** READ case: 1. Clear the buffer. 2. Append items to the buffer one at a time from fortran. 3. Write the buffer to file. 4. Clear the buffer. WRITE case: 1. Clear the buffer. 2. Read table from file. 3. Query number of items in table. 3. Query items one at a time by row. 4. Clear the buffer. */ #include "input_storage_gate_pipe_device.h" #include "exception_trapping.h" #include "LayerManager.h" #include<iostream> #include<sstream> #include<fstream> #include<iomanip> #include "boost/tuple/tuple_comparison.hpp" #include "boost/tokenizer.hpp" #include "boost/iterator/filter_iterator.hpp" #include "ParseValidationFunctors.h" #include "boost/filesystem/operations.hpp" #include "boost/algorithm/string/case_conv.hpp" #include "boost/scoped_array.hpp" using namespace std; using namespace boost; /** Write the table item to an output stream */ ostream& operator<<(ostream & stream, const gate_pipe_device & obj) { quote_if_spaces quote_spaces; stream.setf(ios_base::fixed,ios_base::floatfield); return stream << setw(max(4+16,(int)(4+strlen(obj.gate_name)))) << setfill(' ') << left << quote_spaces(obj.gate_name, 32) << setw(max(4+16,(int)(4+strlen(obj.device)))) << setfill(' ') << left << quote_spaces(obj.device, 32) << setw(12) << setfill(' ') << left << obj.nduplicate << setw(10) << setfill(' ') << setprecision(3) << left << obj.radius << setw(10) << setfill(' ') << setprecision(3) << left << obj.elev << setw(14) << setfill(' ') << setprecision(4) << left << obj.cf_from_node << setw(14) << setfill(' ') << setprecision(4) << left << obj.cf_to_node << setw(max(4+18,(int)(4+strlen(obj.default_op)))) << setfill(' ') << left << quote_spaces(obj.default_op, 16) ; } /** Read the table item from an input stream */ istream& operator>> (istream& stream, gate_pipe_device & obj) { string str; getline(stream,str); boost::escaped_list_separator<char> xsep("\\", " \t","\""); typedef tokenizer<escaped_list_separator<char> > EscTokenizer; EscTokenizer xtok(str,xsep); is_not_empty predicate; typedef boost::filter_iterator<is_not_empty, EscTokenizer::iterator> FilterIter; FilterIter beg(predicate, xtok.begin(),xtok.end()); FilterIter end(predicate, xtok.end()); istringstream tokenstrm; string tempstr; if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } if(beg->size()<= 32) { strcpy(obj.gate_name, (beg++)->c_str()); } else { cout << "fatal error" <<endl; throw logic_error("String too long (max width 32):" + (*beg)); } if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } if(beg->size()<= 32) { strcpy(obj.device, (beg++)->c_str()); } else { cout << "fatal error" <<endl; throw logic_error("String too long (max width 32):" + (*beg)); } if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } tokenstrm.clear(); tempstr = *(beg++); tokenstrm.str(tempstr); tokenstrm >> obj.nduplicate; // strtol(tempStr.c_str(),NULL,10); if (!tokenstrm.eof()) { throw invalid_argument("Could not convert nduplicate to correct data type:"+tempstr); } if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } obj.radius = strtod((beg++)->c_str(),NULL); if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } obj.elev = strtod((beg++)->c_str(),NULL); if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } obj.cf_from_node = strtod((beg++)->c_str(),NULL); if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } obj.cf_to_node = strtod((beg++)->c_str(),NULL); if (beg == end) { throw runtime_error("Fewer input fields received than expected"); } if(beg->size()<= 16) { strcpy(obj.default_op, (beg++)->c_str()); } else { cout << "fatal error" <<endl; throw logic_error("String too long (max width 16):" + (*beg)); } ; return stream; } template<> HDFTableManager<gate_pipe_device>::HDFTableManager() : description(gate_pipe_device_table_description()), m_default_fill(gate_pipe_device("","",-901,-901.0,-901.0,-901.0,-901.0,"")){} template<> void HDFTableManager<gate_pipe_device>::prioritize_buffer() { // Sort by identifier (lexicographical order) and // layer (decreasing order of priority) std::sort(buffer().begin(),buffer().end()); // remove if my version != parent version that is used buffer().erase(remove_if(buffer().begin(), buffer().end(), not1(mem_fun_ref(&gate_pipe_device::parent_valid))),buffer().end()); } TableDescription gate_pipe_device_table_description(){ const char* title = "gate_pipe_device"; const size_t size = sizeof(gate_pipe_device); const size_t nfields = 8; gate_pipe_device default_struct = gate_pipe_device("","",-901,-901.0,-901.0,-901.0,-901.0,""); const char* fnames[] = {"gate_name","device","nduplicate","radius","elev","cf_from_node","cf_to_node","default_op"}; const hid_t ftypes[] = { string_type(32),string_type(32),H5T_NATIVE_INT,H5T_NATIVE_DOUBLE,H5T_NATIVE_DOUBLE,H5T_NATIVE_DOUBLE,H5T_NATIVE_DOUBLE,string_type(16) }; const size_t foffsets[] ={ ((char*)&default_struct.gate_name - (char*)&default_struct), ((char*)&default_struct.device - (char*)&default_struct), ((char*)&default_struct.nduplicate - (char*)&default_struct), ((char*)&default_struct.radius - (char*)&default_struct), ((char*)&default_struct.elev - (char*)&default_struct), ((char*)&default_struct.cf_from_node - (char*)&default_struct), ((char*)&default_struct.cf_to_node - (char*)&default_struct), ((char*)&default_struct.default_op - (char*)&default_struct) }; const size_t fsizes[] = { sizeof( default_struct.gate_name ), sizeof( default_struct.device ), sizeof( default_struct.nduplicate ), sizeof( default_struct.radius ), sizeof( default_struct.elev ), sizeof( default_struct.cf_from_node ), sizeof( default_struct.cf_to_node ), sizeof( default_struct.default_op ) }; const hsize_t chunk_size = 10; TableDescription descr(title,size,nfields,fnames,ftypes,foffsets,fsizes,chunk_size); return descr; } /** Clear the storage buffer for objects of type gate_pipe_device */ void gate_pipe_device_clear_buffer_f(){ //gate_pipe_device_table::instance().buffer().destroy(); gate_pipe_device_table::instance().buffer().clear(); } /** append to buffer, compatible with fortran, returns new size*/ void gate_pipe_device_append_to_buffer_f(const char a_gate_name[32],const char a_device[32],const int * a_nduplicate,const double * a_radius,const double * a_elev,const double * a_cf_from_node,const double * a_cf_to_node,const char a_default_op[16], int * ierror, const int gate_name_len,const int device_len,const int default_op_len) { _TRAP_EXCEPT(*ierror, gate_pipe_device_table::instance().buffer().push_back( gate_pipe_device( a_gate_name,a_device,*a_nduplicate,*a_radius,*a_elev,*a_cf_from_node,*a_cf_to_node,a_default_op )); ) // end of exception trap } /** both makes the table and writes the contents of the buffer to it */ void gate_pipe_device_write_buffer_to_hdf5_f(const hid_t* file_id, int* ierror){ _TRAP_EXCEPT(*ierror, gate_pipe_device_table & table = gate_pipe_device_table::instance(); *ierror = static_cast<int>( H5TBmake_table( gate_pipe_device_table::instance().description.title.c_str(), *file_id, table.description.title.c_str(), table.description.nfields, table.buffer().size(), table.description.struct_size, table.description.field_names, table.description.field_offsets, table.description.field_types, table.description.chunk_size, &table.default_fill(), //fill data 1, //gate_pipe_device_table::instance().description.compress, table.buffer().size() > 0 ? &table.buffer()[0] : NULL)); ) // end of exception trap } /** reads the table in from a file into the buffer*/ void gate_pipe_device_read_buffer_from_hdf5_f(const hid_t* file_id, int* ierror){ _TRAP_EXCEPT(*ierror, hsize_t nfields; hsize_t nrecords; gate_pipe_device_table & table = gate_pipe_device_table::instance(); *ierror = static_cast<int>( H5TBget_table_info (*file_id, table.description.title.c_str(), &nfields, &nrecords )); if ( *ierror < 0) return; if (nfields != table.description.nfields){ *ierror = LOGIC_ERROR; return;} table.buffer().resize(static_cast<int>(nrecords)); if (nrecords > 0) { *ierror = static_cast<int>( H5TBread_table(*file_id, table.description.title.c_str(), table.description.struct_size, table.description.field_offsets, table.description.field_sizes, &(table.buffer()[0]))); } ) // end of exception trap } /** query size information about the table */ void gate_pipe_device_number_rows_hdf5_f(const hid_t *file_id, hsize_t* nrecords, int* ierror){ _TRAP_EXCEPT(*ierror, hsize_t nfields = 0; *ierror = static_cast<int>( H5TBget_table_info (*file_id, gate_pipe_device_table::instance().description.title.c_str(), &nfields, nrecords)); ) // end of exception trap } /** get one row worth of information from the buffer */ void gate_pipe_device_query_from_buffer_f(size_t* row, char a_gate_name[32], char a_device[32],int * a_nduplicate,double * a_radius,double * a_elev,double * a_cf_from_node,double * a_cf_to_node, char a_default_op[16], int * ierror, int gate_name_len,int device_len,int default_op_len ) { _TRAP_EXCEPT(*ierror, //if (row > gate_pipe_device_table::instance().buffer().size()) return -2; //todo: HDF_STORAGE_ERROR; size_t ndx = *row - 1; gate_pipe_device obj =gate_pipe_device_table::instance().buffer()[ndx]; memcpy(a_gate_name,obj.gate_name,32); memcpy(a_device,obj.device,32); *a_nduplicate=obj.nduplicate; *a_radius=obj.radius; *a_elev=obj.elev; *a_cf_from_node=obj.cf_from_node; *a_cf_to_node=obj.cf_to_node; memcpy(a_default_op,obj.default_op,16); if (strlen(a_gate_name) < 32)fill(a_gate_name+strlen(a_gate_name),a_gate_name+32,' '); if (strlen(a_device) < 32)fill(a_device+strlen(a_device),a_device+32,' '); if (strlen(a_default_op) < 16)fill(a_default_op+strlen(a_default_op),a_default_op+16,' '); gate_name_len=(int)strlen(a_gate_name); device_len=(int)strlen(a_device); default_op_len=(int)strlen(a_default_op); ) // end of exception trap } /** Prioritize buffer by layers, delete unused items and sort */ void gate_pipe_device_prioritize_buffer_f(int* ierror) { _TRAP_EXCEPT(*ierror, gate_pipe_device_table::instance().prioritize_buffer(); ) // end of exception trap } /** Query the size of the storage buffer for objects of type gate_pipe_device */ int gate_pipe_device_buffer_size_f() { return (int) gate_pipe_device_table::instance().buffer().size(); } void gate_pipe_device_write_buffer_to_stream(ostream & out, const bool& append) { string keyword("gate_pipe_device"); boost::to_upper(keyword); out << keyword <<endl; vector<gate_pipe_device> & obs = gate_pipe_device_table::instance().buffer(); gate_pipe_device_table& table = gate_pipe_device_table::instance(); for (size_t icount = 0; icount < table.description.nfields; ++ icount) { string name = table.description.field_names[icount]; boost::to_upper(name); out << name << " "; } out << endl; for (vector<gate_pipe_device>::const_iterator it = obs.begin(); it != obs.end(); ++it) { const gate_pipe_device & outitem = *it; out << outitem << endl; } out << "END\n" << endl; } void gate_pipe_device_write_buffer_to_text_f(const char* file, const bool* append, int* ierror, int filelen) { _TRAP_EXCEPT(*ierror, string filename(file,filelen); boost::filesystem::path p(filename); ios_base::openmode mode = *append ? (ios::out | ios::ate | ios::app) : (ios::out | ios::trunc ); ofstream out(filename.c_str(),mode); gate_pipe_device_write_buffer_to_stream(out,*append); ) // end of exception trap }
85da1948c82dc553ca0c8769df15d11cab732fd6
891c20f56f5afa7a26e8fac11e9db5fa9622ea6e
/Basic C++ Concepts/pf_lab2/q3.cpp
a5ae1588bd90357cb48622237085a10de82700cc
[]
no_license
muhamdasim/CPP
9054a5735ea976c2a131849a736cecaa30061d65
b7a274ca36eba05240a9d83a6b6f758928bf3de5
refs/heads/master
2022-11-10T03:04:08.940348
2020-07-06T00:29:40
2020-07-06T00:29:40
229,776,812
0
0
null
null
null
null
UTF-8
C++
false
false
392
cpp
#include <iostream> using namespace std ; int main () { int sec; cout <<"Enter number in seconds: " ; cin >> sec; if (sec<=3600) { int m ; m=sec/60 ; cout <<"Number of minute is: " << m; } else if (sec<=86400) { int h ; h=sec/3600 ; cout <<"Number of hours is: " << h; } if (sec>=86400) { int d; d=sec/86400 ; cout <<"Number of days are: " <<d; } return 0; }
30bbd03772d06159918766dc5f60ba231508a9ff
70c33d372ee0a6e3c78cb423b14838cfef0395d4
/include/dish2/viz/fill_colormaps/CellBirthColorMap.hpp
cfbb66de98b4e2a11a6b473963460e44d7de0b70
[ "MIT" ]
permissive
mmore500/dishtiny
3e077f0ef7324cc260bd6f0d0f49771d0751fd2d
bdac574424570fb7dc85ef01ba97464c6a8737cc
refs/heads/master
2023-05-22T07:33:20.418326
2022-09-28T22:45:46
2022-09-28T22:46:09
122,763,244
32
6
MIT
2022-09-09T23:41:12
2018-02-24T17:34:33
C++
UTF-8
C++
false
false
701
hpp
#pragma once #ifndef DISH2_VIZ_FILL_COLORMAPS_CELLBIRTHCOLORMAP_HPP_INCLUDE #define DISH2_VIZ_FILL_COLORMAPS_CELLBIRTHCOLORMAP_HPP_INCLUDE #include "../../../../third-party/Empirical/include/emp/math/math.hpp" #include "../../../../third-party/Empirical/include/emp/web/color_map.hpp" namespace dish2 { struct CellBirthColorMap { template<typename... Args> CellBirthColorMap( Args&&... ){} template<typename ValueType> std::string Paint(const ValueType& leaf) const { const auto val = leaf.Get(); if (val == 0) return "green"; else return "white"; } void Refresh() { ; } }; } // namespace dish2 #endif // #ifndef DISH2_VIZ_FILL_COLORMAPS_CELLBIRTHCOLORMAP_HPP_INCLUDE
22cda1b8e55922df6cbfad858d0ff734313851f4
dc5796120bb4cf1307ef0da6a5b2d0b1f66f0802
/TPGAnalysisData/Setup/EcalTPGAnalyzerEREC2.cc
cb70064502a30ac9d4fa25e7f19d155d778ff96d
[]
no_license
valsdav/ECAL_Weights_MC
2461afc7de5d78658e60bfcf6836185fb244135f
d6eaec92441ba58c8c551a62c7b47b1242090513
refs/heads/master
2022-02-21T20:57:50.542785
2019-08-20T12:05:41
2019-08-20T12:05:41
166,221,081
0
0
null
null
null
null
UTF-8
C++
false
false
48,090
cc
// -*- C++ -*- // // Class: EcalTPGAnalyzer // // // Original Author: Pascal Paganini // // // system include files #include <memory> #include <utility> #include "DataFormats/Math/interface/deltaR.h" // user include files #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h" #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" #include "DataFormats/DetId/interface/DetId.h" #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" #include "Geometry/EcalMapping/interface/EcalMappingRcd.h" #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h" #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h" #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h" #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h" #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h" #include "CondFormats/DataRecord/interface/EcalTPGTowerStatusRcd.h" #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h" #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h" //L1 Trigger //#include "L1Trigger/L1ExtraFromDigis/interface/L1ExtraParticleMapProd.h" #include "DataFormats/L1Trigger/interface/EGamma.h" //RCT #include "CondFormats/L1TObjects/interface/L1RCTChannelMask.h" #include "CondFormats/DataRecord/interface/L1RCTChannelMaskRcd.h" #include "EcalTPGAnalyzer.h" //#include "DQM/EcalCommon/interface/Numbers.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h" // Trip Masking info #include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h" #include "CondFormats/DataRecord/interface/EcalTPGStripStatusRcd.h" #include "FWCore/Framework/interface/Run.h" #include <TMath.h> #include <sstream> #define DEBUG_ 0 using namespace edm; using namespace std; class CaloSubdetectorGeometry; EcalTPGAnalyzer::EcalTPGAnalyzer(const edm::ParameterSet& iConfig) { #ifdef DEBUG cout<<"in constructor"<<endl; #endif noL1Info = false; puCollection_ = consumes<vector<PileupSummaryInfo> > (iConfig.getParameter<edm::InputTag>("pileupCollection")); pvCollection_ = iConfig.getParameter<edm::InputTag>("PVCollection") ; tpCollection_ = iConfig.getParameter<edm::InputTag>("TPCollection") ; tpEmulatorCollection_ = iConfig.getParameter<edm::InputTag>("TPEmulatorCollection") ; digiCollectionEB_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEB") ; digiCollectionEE_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEE") ; gtRecordCollectionTag_ = iConfig.getParameter<std::string>("GTRecordCollection") ; EcalRecHitCollectionEB_ = iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB") ; EcalRecHitCollectionEE_ = iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEE") ; // l1extraIsol_ =iConfig.getParameter<edm::InputTag> ("l1extraIsol"); // l1extraNonIsol_ =iConfig.getParameter<edm::InputTag> ("l1extraNonIsol"); egTag_ = edm::InputTag("caloStage2Digis", "EGamma"); m_egToken_ = consumes<l1t::EGammaBxCollection>(egTag_); mpegTag_ = edm::InputTag("caloStage2Digis", "MP" ); mp_egToken_ = consumes<l1t::EGammaBxCollection>(mpegTag_); rctSourceEm_token_= consumes<L1CaloEmCollection>(edm::InputTag("gctDigis")); pvCollection1_ = consumes<reco::VertexCollection> ( iConfig.getParameter<edm::InputTag>("PVCollection") ); tpCollection1_ = consumes<EcalTrigPrimDigiCollection>( iConfig.getParameter<edm::InputTag>("TPCollection") ); tpEmulatorCollection1_ = consumes<EcalTrigPrimDigiCollection>( iConfig.getParameter<edm::InputTag>("TPEmulatorCollection") ); digiCollectionEB1_ = consumes<EBDigiCollection>( iConfig.getParameter<edm::InputTag>("DigiCollectionEB") ); digiCollectionEE1_ = consumes<EEDigiCollection>( iConfig.getParameter<edm::InputTag>("DigiCollectionEE") ); gtRecordCollectionTag1_ = consumes<L1GlobalTriggerReadoutRecord>( iConfig.getParameter<std::string>("GTRecordCollection") ); EcalRecHitCollectionEB1_ = consumes<EcalRecHitCollection>( iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB") ); EcalRecHitCollectionEE1_ = consumes<EcalRecHitCollection>( iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEE") ); // l1extraIsolT_ = consumes<l1extra::L1EmParticleCollection>( iConfig.getParameter<edm::InputTag>("l1extraIsol") ); // l1extraNonIsolT_ = consumes<l1extra::L1EmParticleCollection>( iConfig.getParameter<edm::InputTag>("l1extraNonIsol") ); allowTP_ = iConfig.getParameter<bool>("ReadTriggerPrimitives"); useEE_ = iConfig.getParameter<bool>("UseEndCap"); skipWritingEndcapDigis_ = iConfig.getParameter<bool>("skipWritingEndcapDigi"); keepOnlyTowersAboveZero_ = iConfig.getParameter<bool>("keepOnlyTowersAboveZero") ; print_ = iConfig.getParameter<bool>("Print"); L1print_ = iConfig.getParameter<bool>("L1Print"); isMC = iConfig.getParameter<bool>("isMC"); isRECO = iConfig.getParameter<bool>("isRECO"); // file file_ = new TFile("ECALTPGtree.root","RECREATE"); file_->cd() ; #ifdef DEBUG cout<<"past the cd() call to file_"<<endl; #endif // trees tree_ = new TTree( "EcalTPGAnalysis","EcalTPGAnalysis" ); tree_->Branch("puTrue",&puTrue,"puTrue/f"); tree_->Branch("ngoodVtx", &ngoodVtx, "ngoodVtx/i"); tree_->Branch("nVtx", &nVtx, "nVtx/i"); tree_->Branch("runNb",&treeVariables_.runNb,"runNb/i"); // tree_->Branch("evtNb",&treeVariables_.evtNb,"evtNb/l"); // tree_->Branch("bxNb",&treeVariables_.bxNb,"bxNb/I"); // tree_->Branch("bxGT",&treeVariables_.bxGT,"bxGT/I"); // tree_->Branch("orbitNb",&treeVariables_.orbitNb,"orbitNb/l"); // tree_->Branch("lumiBlock",&treeVariables_.lumiBlock,"lumiBlock/I"); // tree_->Branch("timeStamp",&treeVariables_.timeStamp,"timeStamp/d"); // tree_->Branch("nbOfActiveTriggers",&treeVariables_.nbOfActiveTriggers,"nbOfActiveTriggers/i"); // tree_->Branch("activeTriggers",treeVariables_.activeTriggers,"activeTriggers[nbOfActiveTriggers]/I"); // tree_->Branch("nbOfActiveTechTriggers",&treeVariables_.nbOfActiveTechTriggers,"nbOfActiveTechTriggers/i"); // tree_->Branch("activeTechTriggers",treeVariables_.activeTechTriggers,"activeTechTriggers[nbOfActiveTechTriggers]/I"); tree_->Branch("activeTriggersBX",treeVariables_.activeTriggersBX,"activeTriggersBX[160]/I"); // tree_->Branch("nbOfTowers",&treeVariables_.nbOfTowers,"nbOfTowers/I"); // tree_->Branch("ieta", treeVariables_.ieta,"ieta[nbOfTowers]/I");// tree_->Branch("iphi", treeVariables_.iphi,"iphi[nbOfTowers]/I");// tree_->Branch("nbOfXtals", treeVariables_.nbOfXtals,"nbOfXtals[nbOfTowers]/I");// tree_->Branch("rawTPData", treeVariables_.rawTPData,"rawTPData[nbOfTowers]/I");// tree_->Branch("rawTPEmul1", treeVariables_.rawTPEmul1,"rawTPEmul1[nbOfTowers]/I");// tree_->Branch("rawTPEmul2", treeVariables_.rawTPEmul2,"rawTPEmul2[nbOfTowers]/I");// tree_->Branch("rawTPEmul3", treeVariables_.rawTPEmul3,"rawTPEmul3[nbOfTowers]/I");// tree_->Branch("rawTPEmul4", treeVariables_.rawTPEmul4,"rawTPEmul4[nbOfTowers]/I");// tree_->Branch("rawTPEmul5", treeVariables_.rawTPEmul5,"rawTPEmul5[nbOfTowers]/I");// tree_->Branch("crystNb", treeVariables_.crystNb,"crystNb[nbOfTowers]/I");// tree_->Branch("eRec", treeVariables_.eRec,"eRec[nbOfTowers]/F");// tree_->Branch("ttFlag", treeVariables_.ttFlag,"ttFlag[nbOfTowers]/I");// tree_->Branch("sevlv", treeVariables_.sevlv,"sevlv[nbOfTowers]/I");// tree_->Branch("spike", treeVariables_.spike,"spike[nbOfTowers]/I");// tree_->Branch("rawTPEmulsFGVB1", treeVariables_.rawTPEmulsFGVB1,"rawTPEmulsFGVB1[nbOfTowers]/I");// tree_->Branch("rawTPEmulsFGVB2", treeVariables_.rawTPEmulsFGVB2,"rawTPEmulsFGVB2[nbOfTowers]/I");// tree_->Branch("rawTPEmulsFGVB3", treeVariables_.rawTPEmulsFGVB3,"rawTPEmulsFGVB3[nbOfTowers]/I");// tree_->Branch("rawTPEmulsFGVB4", treeVariables_.rawTPEmulsFGVB4,"rawTPEmulsFGVB4[nbOfTowers]/I");// tree_->Branch("rawTPEmulsFGVB5", treeVariables_.rawTPEmulsFGVB5,"rawTPEmulsFGVB5[nbOfTowers]/I");// tree_->Branch("rawTPEmulttFlag1", treeVariables_.rawTPEmulttFlag1,"rawTPEmulttFlag1[nbOfTowers]/I");// tree_->Branch("rawTPEmulttFlag2", treeVariables_.rawTPEmulttFlag2,"rawTPEmulttFlag2[nbOfTowers]/I");// tree_->Branch("rawTPEmulttFlag3", treeVariables_.rawTPEmulttFlag3,"rawTPEmulttFlag3[nbOfTowers]/I");// tree_->Branch("rawTPEmulttFlag4", treeVariables_.rawTPEmulttFlag4,"rawTPEmulttFlag4[nbOfTowers]/I");// tree_->Branch("rawTPEmulttFlag5", treeVariables_.rawTPEmulttFlag5,"rawTPEmulttFlag5[nbOfTowers]/I");// // tree_->Branch("TCCid", &treeVariables_.TCCid,"TCCid/i");// // tree_->Branch("TowerInTCC", &treeVariables_.TowerInTCC,"TowerInTCC/i");// // tree_->Branch("strip", &treeVariables_.strip,"strip/i");// treeShape_ = new TTree( "EcalShape","EcalShape" ); //treeShape_->Branch("evtNb",&treeVariablesShape_.evtNb,"evtNb/l"); // treeShape_->Branch("ieta", &treeVariablesShape_.ieta,"ieta/I");// treeShape_->Branch("iphi", &treeVariablesShape_.iphi,"iphi/I");// treeShape_->Branch("ixXtal", &treeVariablesShape_.ixXtal,"ixXtal/I");// treeShape_->Branch("iyXtal", &treeVariablesShape_.iyXtal,"iyXtal/I");// treeShape_->Branch("TCCid", &treeVariablesShape_.TCCid,"TCCid/I");// treeShape_->Branch("TowerInTCC", &treeVariablesShape_.TowerInTCC,"TowerInTCC/I");// treeShape_->Branch("strip", &treeVariablesShape_.strip,"strip/I");// treeShape_->Branch("nbOfSamples", &treeVariablesShape_.nbOfSamples,"nbOfSamples/I");// treeShape_->Branch("samp", treeVariablesShape_.samp,"samp[nbOfSamples]/I");// treeAux = new TTree("treeAux","treeAux"); //treeAux->Branch("runNb",&ecalAux_.runNb,"runNb/i"); // treeAux->Branch("nMaskedCh",&ecalAux_.nMaskedCh,"nMaskedCh/i"); // treeAux->Branch("iMaskedTTeta",ecalAux_.iMaskedTTeta,"iMaskedTTeta[nMaskedCh]/I"); // treeAux->Branch("iMaskedTTphi",ecalAux_.iMaskedTTphi,"iMaskedTTeta[nMaskedCh]/I"); // treeAux->Branch("nMaskedChannelsFromStrips",&ecalAux_.nMaskedChannelsFromStrips,"nMaskedChannelsFromStrips/i"); // treeAux->Branch("iMaskedChannelsFromStripsX",ecalAux_.iMaskedChannelsFromStripsX,"iMaskedChannelsFromStripsX[nMaskedChannelsFromStrips]/I"); // treeAux->Branch("iMaskedChannelsFromStripsY",ecalAux_.iMaskedChannelsFromStripsY,"iMaskedChannelsFromStripsY[nMaskedChannelsFromStrips]/I"); // treeAux->Branch("iMaskedChannelsFromStripsZ",ecalAux_.iMaskedChannelsFromStripsZ,"iMaskedChannelsFromStripsZ[nMaskedChannelsFromStrips]/I"); // //L1 tree branches tree_->Branch("nbOfL1IsoCands",&treeVariables_.nbOfL1IsoCands,"nbOfL1IsoCands/i"); // tree_->Branch("L1IsoIeta", treeVariables_.L1IsoIeta,"L1IsoIeta[nbOfL1IsoCands]/I");// tree_->Branch("L1IsoIphi", treeVariables_.L1IsoIphi,"L1IsoIphi[nbOfL1IsoCands]/I");// tree_->Branch("L1IsoRank", treeVariables_.L1IsoRank,"L1IsoRank[nbOfL1IsoCands]/I");// tree_->Branch("nbOfL1NonisoCands",&treeVariables_.nbOfL1NonisoCands,"nbOfL1NonisoCands/i"); // tree_->Branch("L1NonisoIeta", treeVariables_.L1NonisoIeta,"L1NonisoIeta[nbOfL1NonisoCands]/I");// tree_->Branch("L1NonisoIphi", treeVariables_.L1NonisoIphi,"L1NonisoIphi[nbOfL1NonisoCands]/I");// tree_->Branch("L1NonisoRank", treeVariables_.L1NonisoRank,"L1NonisoRank[nbOfL1NonisoCands]/I");// tree_->Branch("nMaskedRCT",&treeVariables_.nMaskedRCT,"nMaskedRCT/i"); // tree_->Branch("iMaskedRCTeta",treeVariables_.iMaskedRCTeta,"iMaskedRCTeta[nMaskedRCT]/I"); // tree_->Branch("iMaskedRCTcrate",treeVariables_.iMaskedRCTcrate,"iMaskedRCTcrate[nMaskedRCT]/I"); // tree_->Branch("iMaskedRCTphi",treeVariables_.iMaskedRCTphi,"iMaskedRCTphi[nMaskedRCT]/I"); // // L1 pre-firing tree branches tree_->Branch("nbOfL1preIsoCands",&treeVariables_.nbOfL1preIsoCands,"nbOfL1preIsoCands/i"); // tree_->Branch("L1preIsoIeta", treeVariables_.L1preIsoIeta,"L1preIsoIeta[nbOfL1preIsoCands]/I");// tree_->Branch("L1preIsoIphi", treeVariables_.L1preIsoIphi,"L1preIsoIphi[nbOfL1preIsoCands]/I");// tree_->Branch("L1preIsoRank", treeVariables_.L1preIsoRank,"L1preIsoRank[nbOfL1preIsoCands]/I");// tree_->Branch("nbOfL1preNonisoCands",&treeVariables_.nbOfL1preNonisoCands,"nbOfL1preNonisoCands/i"); // tree_->Branch("L1preNonisoIeta", treeVariables_.L1preNonisoIeta,"L1preNonisoIeta[nbOfL1preNonisoCands]/I");// tree_->Branch("L1preNonisoIphi", treeVariables_.L1preNonisoIphi,"L1preNonisoIphi[nbOfL1preNonisoCands]/I");// tree_->Branch("L1preNonisoRank", treeVariables_.L1preNonisoRank,"L1preNonisoRank[nbOfL1preNonisoCands]/I");// // ontime firing tree branches /* tree_->Branch("nbOfL1ontimeIsoCands",&treeVariables_.nbOfL1ontimeIsoCands,"nbOfL1ontimeIsoCands/i"); // tree_->Branch("L1ontimeIsoIeta", treeVariables_.L1ontimeIsoIeta,"L1ontimeIsoIeta[nbOfL1ontimeIsoCands]/I");// tree_->Branch("L1ontimeIsoIphi", treeVariables_.L1ontimeIsoIphi,"L1ontimeIsoIphi[nbOfL1ontimeIsoCands]/I");// tree_->Branch("L1ontimeIsoRank", treeVariables_.L1ontimeIsoRank,"L1ontimeIsoRank[nbOfL1ontimeIsoCands]/I");// tree_->Branch("nbOfL1ontimeNonisoCands",&treeVariables_.nbOfL1ontimeNonisoCands,"nbOfL1ontimeNonisoCands/i"); // tree_->Branch("L1ontimeNonisoIeta", treeVariables_.L1ontimeNonisoIeta,"L1ontimeNonisoIeta[nbOfL1ontimeNonisoCands]/I");// tree_->Branch("L1ontimeNonisoIphi", treeVariables_.L1ontimeNonisoIphi,"L1ontimeNonisoIphi[nbOfL1ontimeNonisoCands]/I");// tree_->Branch("L1ontimeNonisoRank", treeVariables_.L1ontimeNonisoRank,"L1ontimeNonisoRank[nbOfL1ontimeNonisoCands]/I");// */ // L1 post-firing tree branches tree_->Branch("nbOfL1postIsoCands",&treeVariables_.nbOfL1postIsoCands,"nbOfL1postIsoCands/i"); // tree_->Branch("L1postIsoIeta", treeVariables_.L1postIsoIeta,"L1postIsoIeta[nbOfL1postIsoCands]/I");// tree_->Branch("L1postIsoIphi", treeVariables_.L1postIsoIphi,"L1postIsoIphi[nbOfL1postIsoCands]/I");// tree_->Branch("L1postIsoRank", treeVariables_.L1postIsoRank,"L1postIsoRank[nbOfL1postIsoCands]/I");// tree_->Branch("nbOfL1postNonisoCands",&treeVariables_.nbOfL1postNonisoCands,"nbOfL1postNonisoCands/i"); // tree_->Branch("L1postNonisoIeta", treeVariables_.L1postNonisoIeta,"L1postNonisoIeta[nbOfL1postNonisoCands]/I");// tree_->Branch("L1postNonisoIphi", treeVariables_.L1postNonisoIphi,"L1postNonisoIphi[nbOfL1postNonisoCands]/I");// tree_->Branch("L1postNonisoRank", treeVariables_.L1postNonisoRank,"L1postNonisoRank[nbOfL1postNonisoCands]/I");// // // ADD the branches from here http://azabi.web.cern.ch/azabi/TRIGGER/CODE/SimpleNtpleCustom.cc tree_->Branch("trig_tower_adc", &treeVariables_.twrADC, "twrADC[nbOfTowers]/I"); tree_->Branch("trig_tower_sFGVB", &treeVariables_.sFGVB, "sFGVB[nbOfTowers]/I"); #ifdef DEBUG cout<<"declared tree branches"<<endl; #endif } EcalTPGAnalyzer::~EcalTPGAnalyzer() { file_->cd(); tree_->Write(); treeShape_->Write(); treeAux->Write(); file_->Close(); } // void EcalTPGAnalyzer::beginJob() // { // myevt = 0; // std::cout << " beginJob myevt = " << myevt << std::endl; // } void EcalTPGAnalyzer::beginRun( const edm::EventSetup & iSetup,const edm::Run & iRun) { myevt = 0; startTime_ =(iRun.beginTime().value() >> 32) + 1e-6*(iRun.beginTime().value() & 0xffffffff); std::cout << __LINE__ << " beginRun myevt = " << myevt << ", startTime " << startTime_ << std::endl; } void EcalTPGAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup & iSetup) { //resetting no. of good vertices to zero for each event. nVtx=0, ngoodVtx=0; using namespace edm; using namespace std; //const double pi = 3.14159265358979323846; myevt++; #ifdef DEBUG cout << " in analyze method \t analyze myevt = " << myevt << endl; #endif if (DEBUG_) cout << __LINE__ << endl; ESHandle< EcalElectronicsMapping > ecalmapping; iSetup.get< EcalMappingRcd >().get(ecalmapping); theMapping_ = ecalmapping.product(); if ( myevt == 1){ // electronics mapping // ESHandle< EcalElectronicsMapping > ecalmapping; // iSetup.get< EcalMappingRcd >().get(ecalmapping); // theMapping_ = ecalmapping.product(); // Reading strip statuses try{ edm::ESHandle<EcalTPGStripStatus> theEcalTPGStripStatus_handle; iSetup.get<EcalTPGStripStatusRcd>().get(theEcalTPGStripStatus_handle); const EcalTPGStripStatus * ecaltpgStripStatus = theEcalTPGStripStatus_handle.product(); const EcalTPGStripStatusMap &stripMap = ecaltpgStripStatus->getMap(); EcalTPGStripStatusMapIterator itSt; ecalAux_.nMaskedChannelsFromStrips = 0; for (itSt = stripMap.begin();itSt != stripMap.end();++itSt) { if(itSt->second > 0) { // lets decode the ID int strip = itSt->first/8; int pseudostrip = strip & 0x7; strip /= 8; int tt = strip & 0x7F; strip /= 128; int tccid = strip & 0x7F; std::cout << "Bad strip ID = " << itSt->first << " TCC " << tccid << " TT " << tt << " ST " << pseudostrip << ", status = " << itSt->second << std::endl; std::vector<DetId> xtalId = theMapping_->pseudoStripConstituents(tccid, tt, pseudostrip); std::vector<DetId>::iterator it; for(it = xtalId.begin(); it != xtalId.end(); it++) { EEDetId eeid = *it; std::cout << eeid << " "; // int iz = eeid.zside(); // int ix = eeid.ix(); // int iy = eeid.iy(); ecalAux_.iMaskedChannelsFromStripsX[ecalAux_.nMaskedChannelsFromStrips]=eeid.ix(); ecalAux_.iMaskedChannelsFromStripsY[ecalAux_.nMaskedChannelsFromStrips]=eeid.iy(); ecalAux_.iMaskedChannelsFromStripsZ[ecalAux_.nMaskedChannelsFromStrips]=eeid.zside(); ecalAux_.nMaskedChannelsFromStrips++; } std::cout << std::endl; } } } catch (cms::Exception& exception){ std::cout << " ===> EcalTPGStripStatusRcd not found => skip strip masking info" << std::endl; } // Reading TPG tower statuses for first event (masked/not masked information) edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle; iSetup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle); const EcalTPGTowerStatus * ecaltpgTowerStatus=theEcalTPGTowerStatus_handle.product(); const EcalTPGTowerStatusMap &towerMap=ecaltpgTowerStatus->getMap(); EcalTPGTowerStatusMapIterator it; uint nMaskedChannels = 0; for (it=towerMap.begin();it!=towerMap.end();++it) { if ((*it).second > 0) // if status not equals 0 then channle was massked { EcalTrigTowerDetId ttId((*it).first); ecalAux_.iMaskedTTeta[nMaskedChannels] = ttId.ieta(); ecalAux_.iMaskedTTphi[nMaskedChannels] = ttId.iphi(); nMaskedChannels++; } } ecalAux_.nMaskedCh = nMaskedChannels; if (DEBUG_) cout << __LINE__ << endl; // Storing eta and phi of masked TT to 'treeAux' root tree treeAux->Fill() ; // geometry ESHandle<CaloGeometry> theGeometry; ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle; iSetup.get<CaloGeometryRecord>().get( theGeometry ); iSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle); iSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle); iSetup.get<IdealGeometryRecord>().get(eTTmap_); theEndcapGeometry_ = &(*theEndcapGeometry_handle); theBarrelGeometry_ = &(*theBarrelGeometry_handle); //Adding RCT mask // list of RCT channels to mask vector<int> RCTMaskedEta; vector<int> RCTMaskedPhi; edm::ESHandle<L1RCTChannelMask> channelMask; iSetup.get<L1RCTChannelMaskRcd>().get(channelMask); const L1RCTChannelMask* cEs = channelMask.product(); uint nMaskedRCT = 0; for(int i = 0; i< 18; i++) for(int j =0; j< 2; j++) for(int k =0; k<28; k++) if(cEs->ecalMask[i][j][k]){ //cout << "ECAL masked channel: RCT crate " << i << " iphi " << j <<" ieta " <<k <<endl; treeVariables_.iMaskedRCTeta[nMaskedRCT]=k; treeVariables_.iMaskedRCTphi[nMaskedRCT]=j; treeVariables_.iMaskedRCTcrate[nMaskedRCT]=i; nMaskedRCT++; } treeVariables_.nMaskedRCT = nMaskedRCT; } map<EcalTrigTowerDetId, towerEner> mapTower ; map<EcalTrigTowerDetId, towerEner>::iterator itTT ; map<EcalTrigTowerDetId, EBDataFrame> mapShapeEB ; map<EcalTrigTowerDetId, EBDataFrame>::iterator itEB ; map<EcalTrigTowerDetId, EEDataFrame> mapShapeEE ; map<EcalTrigTowerDetId, EEDataFrame> ::iterator itEE ; if (DEBUG_) cout << __LINE__ << endl; /////////////////////////// // get Evts info /////////////////////////// treeVariables_.runNb = iEvent.id().run() ; treeVariables_.evtNb = iEvent.id().event() ; treeVariables_.bxNb = iEvent.bunchCrossing() ; treeVariables_.orbitNb = iEvent.orbitNumber() ; treeVariables_.lumiBlock = iEvent.luminosityBlock(); //treeVariablesShape_.evtNb = iEvent.id().event() ; #ifdef DEBUG cout<<"obtained basic event vars like run and event number"<<endl; #endif if(isMC){ edm::Handle<vector<PileupSummaryInfo> > genPileupHandle; iEvent.getByToken(puCollection_, genPileupHandle); if (genPileupHandle.isValid()) { for (vector<PileupSummaryInfo>::const_iterator pu = genPileupHandle->begin(); pu != genPileupHandle->end(); ++pu) { if (pu->getBunchCrossing() == 0) { puTrue=pu->getTrueNumInteractions(); } // nPU_ .push_back(pu->getPU_NumInteractions()); // puBX_ .push_back(pu->getBunchCrossing()); // nPUInfo_++; } } } else puTrue =0; if(isRECO){ edm::Handle<reco::VertexCollection> vtx_h; iEvent.getByToken(pvCollection1_, vtx_h); nVtx = vtx_h->size(); //std::cout << "# of vertices in the evt " << nVtx << endl; //apply the selection cuts on the PV for(reco::VertexCollection::const_iterator it = vtx_h->begin(); it !=vtx_h->end() ; ++it){ if(it->isValid() && it->ndof() > 4. && it->position().Rho() < 2. /*&& fabs(it->position().Z() - BSPosition.z()) < 24*/){ // good_vertex.push_back(it); ngoodVtx++; } }/*vertex loop*/ } //cout << "ngoodVtx " << ngoodVtx << endl; //===================TIMESTAMP INFORMTION================================= // Code added to get the time in seconds //double startTime_= 0.0; //startTime_ += 1215107133.;//(iRun.beginTime()).unixTime();// 2016/1/1 was 2016/7/3 1215107133.; //if (myevt==1) // startTime_ += 33470900.; //start time of run (empirically) startTime_ = 1461466500; // unsigned int timeStampLow = ( 0xFFFFFFFF & iEvent.time().value() ); unsigned int timeStampHigh = ( iEvent.time().value() >> 32 ); double rawEventTime = ( double)(timeStampHigh)+((double )(timeStampLow)/1000000.); double eventTime = rawEventTime - startTime_; //Notice the subtraction of the "starttime" // cout << __LINE__ << " " << eventTime << " "<< rawEventTime << " " << startTime_<< endl; treeVariables_.timeStamp = eventTime; //cout << __LINE__ << " " << iEvent.time().value() << " " << timeStampLow << " " << timeStampHigh << " " << rawEventTime << " " << eventTime << endl; if (DEBUG_) cout << __LINE__ << endl; // print_ = true; if (print_) std::cout<<"==========="<<iEvent.id()<<" bxNb:"<<iEvent.bunchCrossing()<<" orbit:"<<iEvent.orbitNumber()<<std::endl ; //cout << __LINE__ << endl; /////////////////////////// // get L1 Trigger info /////////////////////////// edm::Handle< L1GlobalTriggerReadoutRecord > gtRecord; //iEvent.getByLabel( edm::InputTag(gtRecordCollectionTag_), gtRecord); iEvent.getByToken( gtRecordCollectionTag1_, gtRecord); DecisionWord dWord = gtRecord->decisionWord(); // this will get the decision word *before* masking disabled bits edm::ESHandle< L1GtTriggerMask > l1GtTmAlgo; iSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo ); std::vector<unsigned int> triggerMaskAlgoTrig = l1GtTmAlgo.product()->gtTriggerMask(); L1GtfeWord gtfeWord = gtRecord->gtfeWord(); treeVariables_.bxGT = gtfeWord.bxNr(); //cout << __LINE__ << endl; #ifdef DEBUG cout<<"obtained handles"<<endl; #endif int hashedTr[160]; for ( int i = 0; i < 160; ++i ){ hashedTr[i]=0; treeVariables_.activeTriggersBX[i]=0; treeVariables_.activeTriggers[i]= 0; } for(int iebx=0; iebx<=4; iebx++) { DecisionWord gtDecisionWord = gtRecord->decisionWord(iebx-2); // std::cout<<"iebx -2 "<<iebx-2<<" size "<<gtDecisionWord.size()<<std::endl; for ( int i = 0; i < 160; ++i ) { if ( gtDecisionWord[i] ) { // std::cout<<i<<" "<<gtDecisionWord[i]<<std::endl; int coef = 0; if (iebx == 0 ) coef = 1; if (iebx == 1 ) coef = 10; if (iebx == 2 ) coef = 100; if (iebx == 3 ) coef = 1000; if (iebx == 4 ) coef = 10000;; hashedTr[i]+= coef; treeVariables_.activeTriggersBX[i]= hashedTr[i]; } //cout << __LINE__ << endl; } } if (DEBUG_) cout << __LINE__ << endl; // apply masks on algo int iDaq = 0; int iBit = -1; treeVariables_.nbOfActiveTriggers = 0 ; for ( int itBit = 0; itBit < 160; ++itBit ) { // cout << __LINE__ << endl; iBit++; int fired=dWord[iBit]; int maskBit = triggerMaskAlgoTrig[iBit] & (1 << iDaq); if (maskBit) fired = 0; //else std::cout<<"not********** asked********"<<std::endl; if (fired) { treeVariables_.activeTriggers[treeVariables_.nbOfActiveTriggers] = iBit ; treeVariables_.nbOfActiveTriggers++ ; } //cout << __LINE__ << endl; } if (DEBUG_) cout << __LINE__ << endl; treeVariables_.nbOfActiveTechTriggers = 0; TechnicalTriggerWord tw = gtRecord->technicalTriggerWord(); if ( ! tw.empty() ) { for ( int itechbit = 0; itechbit < 64; ++itechbit ) { treeVariables_.activeTechTriggers[treeVariables_.nbOfActiveTechTriggers] = 0; // ADD THIS if ( tw[itechbit] ){ treeVariables_.activeTechTriggers[treeVariables_.nbOfActiveTechTriggers] = itechbit; treeVariables_.nbOfActiveTechTriggers++ ; } // cout << __LINE__ << endl; } } if (DEBUG_) cout << __LINE__ << endl; #ifdef DEBUG cout<<"obtained active trigger info"<<endl; #endif if (DEBUG_) cout << __LINE__ << endl; /////////////////////////// // Get TP data /////////////////////////// edm::Handle<EcalTrigPrimDigiCollection> tp; iEvent.getByLabel(tpCollection_,tp); if (print_) std::cout<<"TP collection size="<<tp.product()->size()<<std::endl ; for (unsigned int i=0;i<tp.product()->size();i++) { EcalTriggerPrimitiveDigi d = (*(tp.product()))[i]; const EcalTrigTowerDetId TPtowid= d.id(); towerEner tE ; //tE.TCCid_= theMapping_->TCCid(TPtowid); //tE.TowerInTCC_ = theMapping_->iTT(TPtowid); // const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(id) ; //tE.strip_ = 0;//elId.pseudoStripId() ; tE.iphi_ = TPtowid.iphi() ; tE.ieta_ = TPtowid.ieta() ; tE.ttFlag_ = d[0].ttFlag(); tE.tpgADC_ = (d[0].raw()&0xfff) ; tE.twrADC = (d[0].raw()&0xff) ; tE.sFGVB = (d[0].sFGVB()); mapTower[TPtowid] = tE ; } if (DEBUG_) cout << __LINE__ << endl; if (!noL1Info) { /////////////////////////// // get L1 candidate /////////////////////////// m_cellPos.clear(); edm::ESHandle<CaloGeometry> geoHandle; iSetup.get<CaloGeometryRecord>().get(geoHandle); //Gets the geometry of the endcap const CaloGeometry& geometry = *geoHandle; //const CaloSubdetectorGeometry *barrelGeometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); const std::vector< DetId > m_barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); const std::vector< DetId > m_endcapCells = geometry.getValidDetIds(DetId::Ecal, EcalEndcap); //const CaloSubdetectorGeometry *endcapGeometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); // for (std::vector<DetId>::const_iterator endcapIt = m_endcapCells.begin(); // endcapIt!=m_endcapCells.end(); // ++endcapIt) { // // const CaloCellGeometry *cellGeometry = endcapGeometry->getGeometry(*endcapIt); // std::pair < double, double> pos, ipos; // //cout << __LINE__ << " " << cellGeometry->getPosition().phi() << " " << cellGeometry->getPosition().eta()<< " " << endcapIt->rawId()<< endl; // EBDetId id(*endcapIt) ; // const EcalTrigTowerDetId towid= id.tower(); // pos=make_pair(l1t::CaloTools::towerPhi(towid.ieta(), towid.iphi()), l1t::CaloTools::towerEta(towid.ieta())); // ipos=make_pair(towid.iphi(), towid.ieta()); // m_cellPos.insert(std::pair < pair < double, double>, pair <double, double> > (pos, ipos)); // //cout << __LINE__ << " " << pos.first << " "<< pos.second << " " << ipos.first << " " << ipos.second<< endl; // } // for (std::vector<DetId>::const_iterator barrelIt = m_barrelCells.begin(); // barrelIt!=m_barrelCells.end(); // ++barrelIt) { // std::pair < double, double> pos, ipos; // //const CaloCellGeometry *cellGeometry = barrelGeometry->getGeometry(*barrelIt); // EBDetId id(*barrelIt) ; // const EcalTrigTowerDetId towid= id.tower(); // pos=make_pair(l1t::CaloTools::towerPhi(towid.ieta(), towid.iphi()), l1t::CaloTools::towerEta(towid.ieta())); // ipos=make_pair(towid.iphi(), towid.ieta()); // m_cellPos.insert(std::pair < pair < double, double>, pair <double, double> > (pos, ipos)); // } Handle< BXVector<l1t::EGamma> > egs; iEvent.getByToken(m_egToken_,egs); Handle< BXVector<l1t::EGamma> > mp_egs; iEvent.getByToken(mp_egToken_,mp_egs); std::auto_ptr<l1t::EGammaBxCollection> matching_eg (new l1t::EGammaBxCollection); matching_eg->setBXRange(-2,2); for (int ibx =egs->getFirstBX() ; ibx<=egs->getLastBX() ; ibx++){ l1t::EGamma * myEG=0; for (auto itp = egs->begin(ibx); itp != egs->end(ibx) ; itp++){ myEG=(l1t::EGamma*) &*itp; if (myEG->hwPt() <= 0) continue; // cout << __LINE__ << " " << myevt << " " << iEvent.id().event() << " " << ibx << " tp pt " << myEG->hwPt()<< " " << myEG->hwEta() << " " << myEG->hwPhi()<< " " <<myEG->eta() << " "<< myEG->phi()<< " " << int(28./63.*myEG->hwEta()) << " "<< int(myEG->hwPhi()/2.)<< " " << myEG->hwIso() << " " << endl; // pair <double, double> myPhiEta; // myPhiEta= make_pair(myEG->phi(), myEG->eta()); // double dRmin=99; // int ieta=0; // int iphi=0; // for (map<pair<double, double>, pair <double, double> >::const_iterator it= m_cellPos.begin() ; it!= m_cellPos.end() ; it++){ // double dR=reco::deltaR(it->first.second, it->first.first, myEG->eta(), myEG->phi()); // if (dR < dRmin){ // dRmin=dR; // ieta=it->second.second; // iphi=it->second.first; // } // } // cout << __LINE__ << " "<< dRmin << " " << ieta << " " << iphi<< endl ; // myEG->setHwPhi(iphi); // myEG->setHwEta(ieta); myEG->setHwPhi(int(myEG->hwPhi()/2.)); myEG->setHwEta(int(28./63.*myEG->hwEta())); // cout << __LINE__ << " " << myevt << " " << iEvent.id().event() << " " << ibx << " tp pt " << myEG->hwPt()<< " " << myEG->hwEta() << " " << myEG->hwPhi()<< " " << myEG->eta() << " "<< myEG->phi()<< " " << myEG->hwIso() << " " << myEG->towerIEta() << " " << myEG->towerIPhi() << endl; matching_eg->push_back(ibx, *myEG); }//itp }//ibx // edm::Handle < L1CaloEmCollection > em; // iEvent.getByToken(rctSourceEm_token_,em); // cout << __LINE__ << " L1CaloEm " << em->size() << endl; // for (auto itp = em->begin(); itp != em->end() ; itp++){ // cout << __LINE__ << " " << myevt << " " << iEvent.id().event() << " " << itp->bx() << " " << itp->rank() << " " << itp->regionId().ieta() << " " << itp->regionId().iphi() << endl; // } int isocounter=0; int nonisocounter=0; for (int ibx =-2; ibx<2 ; ibx++){ for ( auto itp = matching_eg->begin(ibx); itp != matching_eg->end(ibx) ; itp++){ //cout << __LINE__ << endl; if (itp->hwPt() <=0) continue; if (itp->hwIso()==0) nonisocounter++; if (itp->hwIso()==1) isocounter++; }//itp }//ibx if (L1print_) std::cout << "iso size " << isocounter << std::endl; treeVariables_.nbOfL1IsoCands = isocounter; if (L1print_) std::cout << "noniso size " << nonisocounter << std::endl; treeVariables_.nbOfL1NonisoCands = nonisocounter; if (DEBUG_) cout << __LINE__ << endl; isocounter = 0; nonisocounter =0; // for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr){ for (int ibx =-2; ibx<2 ; ibx++){ for ( auto itp = matching_eg->begin(ibx); itp != matching_eg->end(ibx) ; itp++){ if (itp->hwIso()==1){ treeVariables_.L1IsoIphi[isocounter] = itp->hwPhi(); treeVariables_.L1IsoIeta[isocounter] = itp->hwEta(); treeVariables_.L1IsoRank[isocounter] = itp->hwPt(); isocounter++; }//Iso if (itp->hwIso()==0){ treeVariables_.L1NonisoIphi[nonisocounter] = itp->hwPhi(); treeVariables_.L1NonisoIeta[nonisocounter] = itp->hwEta(); treeVariables_.L1NonisoRank[nonisocounter] = itp->hwPt(); nonisocounter++; }//nonIso }//itp }//ibx //PRE-FIRING INFO int isocounter1=0; int nonisocounter1=0; for (int ibx =-2; ibx<0 ; ibx++){ //cout << __LINE__ << endl; for ( auto itp = matching_eg->begin(ibx); itp != matching_eg->end(ibx) ; itp++){ //cout << __LINE__ << endl; if (itp->hwPt() <=0) continue; if (itp->hwIso()==0){ treeVariables_.L1preNonisoIeta[nonisocounter1] = itp->hwEta(); treeVariables_.L1preNonisoIphi[nonisocounter1] = itp->hwPhi(); treeVariables_.L1preNonisoRank[nonisocounter1] = itp->hwPt(); nonisocounter1++; } if (itp->hwIso()==1){ treeVariables_.L1preIsoIeta[isocounter1] = itp->hwEta(); treeVariables_.L1preIsoIphi[isocounter1] = itp->hwPhi(); treeVariables_.L1preIsoRank[isocounter1] = itp->hwPt(); //Do we have the rank now? isocounter1++; } //cout << __LINE__ << endl; } } treeVariables_.nbOfL1preNonisoCands = nonisocounter1; if (DEBUG_) cout << __LINE__ << endl; treeVariables_.nbOfL1preIsoCands = isocounter1; if (DEBUG_) cout << __LINE__ << endl; //ontime fire INFO isocounter1=0; nonisocounter1=0; for ( auto itp = matching_eg->begin(0); itp != matching_eg->end(0) ; itp++){ //cout << __LINE__ << endl; if ( itp->hwPt() <=0 ) continue; if (itp->hwIso()==0){ treeVariables_.L1NonisoIeta[nonisocounter1] = itp->hwEta(); treeVariables_.L1NonisoIphi[nonisocounter1] = itp->hwPhi(); treeVariables_.L1NonisoRank[nonisocounter1] = itp->hwPt(); //Do we have the rank now? nonisocounter1++; } //cout << __LINE__ << endl; if (itp->hwIso()==1) { treeVariables_.L1IsoIeta[isocounter1] = itp->hwEta(); treeVariables_.L1IsoIphi[isocounter1] = itp->hwPhi(); treeVariables_.L1IsoRank[isocounter1] = itp->hwPt(); //Do we have the rank now? isocounter1++; } } treeVariables_.nbOfL1NonisoCands = nonisocounter1; //cout << __LINE__ << endl; if (DEBUG_) cout << __LINE__ << endl; treeVariables_.nbOfL1IsoCands = isocounter1; if (DEBUG_) cout << __LINE__ << endl; //POST-FIRING INFO isocounter1=0; nonisocounter1=0; for (int ibx =1; ibx<=+2 ; ibx++){ //cout << __LINE__ << endl; for ( auto itp = matching_eg->begin(ibx); itp != matching_eg->end(ibx) ; itp++){ // cout << __LINE__ << endl; if ( itp->hwPt() <=0 ) continue; if (itp->hwIso()==0){ treeVariables_.L1postNonisoIeta[nonisocounter1] = itp->hwEta(); treeVariables_.L1postNonisoIphi[nonisocounter1] = itp->hwPhi(); treeVariables_.L1postNonisoRank[nonisocounter1] = itp->hwPt(); //Do we have the rank now? nonisocounter1++; } if (itp->hwIso()==1) { treeVariables_.L1postIsoIeta[isocounter1] = itp->hwEta(); treeVariables_.L1postIsoIphi[isocounter1] = itp->hwPhi(); treeVariables_.L1postIsoRank[isocounter1] = itp->hwPt(); //Do we have the rank now? isocounter1++; } } //cout << __LINE__ << endl; } treeVariables_.nbOfL1postNonisoCands = nonisocounter1; treeVariables_.nbOfL1postIsoCands = isocounter1; //cout << __LINE__ << endl; }//if!noL1Info #ifdef DEBUG cout<<"obtained L1 event infor"<<endl; #endif /////////////////////////// // Get Emulators TP /////////////////////////// edm::Handle<EcalTrigPrimDigiCollection> tpEmul ; iEvent.getByLabel(tpEmulatorCollection_, tpEmul); if (print_) std::cout<<"TPEmulator collection size="<<tpEmul.product()->size()<<std::endl ; for (unsigned int i=0;i<tpEmul.product()->size();i++) { EcalTriggerPrimitiveDigi d = (*(tpEmul.product()))[i]; const EcalTrigTowerDetId TPtowid= d.id(); itTT = mapTower.find(TPtowid) ; if (itTT != mapTower.end()) for (int j=0 ; j<5 ; j++) { (itTT->second).tpgEmul_[j] = (d[j].raw()&0xfff) ; (itTT->second).tpgEmulFlag_[j] = d[j].ttFlag(); (itTT->second).tpgEmulsFGVB_[j] = d[j].sFGVB(); } } if (DEBUG_) cout << __LINE__ << endl; /////////////////////////// // Get nb of crystals read out /////////////////////////// // Get EB xtal digi inputs edm::Handle<EBDigiCollection> digiEB; // iEvent.getByLabel(digiCollectionEB_, digiEB); iEvent.getByToken(digiCollectionEB1_,digiEB); EBDataFrame dfMaxEB ; if(print_) cout << " EB digi collection size " << digiEB.product()->size() << endl ; if (DEBUG_) cout << __LINE__ << endl; for (unsigned int i=0;i<digiEB.product()->size();i++) { const EBDataFrame & df = (*(digiEB.product()))[i]; const EBDetId & id = df.id(); const EcalTrigTowerDetId towid = id.tower(); itTT = mapTower.find(towid) ; if (itTT != mapTower.end()) { (itTT->second).nbXtal_++ ; bool fill(false) ; if (((itTT->second).tpgADC_ & 0xff)>0) fill = true ; for (int j=0 ; j<5 ; j++) if (((itTT->second).tpgEmul_[j] & 0xff)>8) fill = true ; if (fill) { if(print_) cout<<"TP="<<((itTT->second).tpgADC_ & 0xff)<<" eta="<<towid.ieta()<<" phi="<<towid.iphi()<<endl ; if (print_) for (int j=0 ; j<5 ; j++) if (((itTT->second).tpgEmul_[j] & 0xff)>8) cout << "tp emul "<< j << " " << ((itTT->second).tpgEmul_[j] & 0xff)<< endl; ///*if(towid.ieta() > 600 || towid.ieta() < -600)*/cout << "Tower Characters " << towid.ieta() << "\t" << towid.iphi() << endl; treeVariablesShape_.ieta = towid.ieta() ; treeVariablesShape_.iphi = towid.iphi() ; treeVariablesShape_.ixXtal = id.iphi() ; treeVariablesShape_.iyXtal = id.ieta() ; treeVariablesShape_.TCCid = theMapping_->TCCid(towid); treeVariablesShape_.TowerInTCC = theMapping_->iTT(towid); const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(id) ; treeVariablesShape_.strip = elId.pseudoStripId() ; treeVariablesShape_.nbOfSamples = df.size() ; for (int s=0 ; s<df.size() ; s++) treeVariablesShape_.samp[s] = df[s].adc() ; treeShape_->Fill() ; } } } /////////////////////////// // Get rechits and spikes /////////////////////////// edm::ESHandle<EcalSeverityLevelAlgo> sevlv; iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv); // channel status edm::ESHandle<EcalChannelStatus> pChannelStatus; iSetup.get<EcalChannelStatusRcd>().get(pChannelStatus); // const EcalChannelStatus *chStatus = pChannelStatus.product(); //const EcalRecHit * rh; // Get EB rechits edm::Handle<EcalRecHitCollection> rechitsEB; // iEvent.getByLabel(EcalRecHitCollectionEB_, rechitsEB) ; iEvent.getByToken(EcalRecHitCollectionEB1_,rechitsEB); //std::cout << " rechitsEB size " << rechitsEB.product()->size() << std::endl; float maxRecHitEnergy = 0. ; if (rechitsEB.product()->size()!=0) { for ( EcalRecHitCollection::const_iterator rechitItr = rechitsEB->begin(); rechitItr != rechitsEB->end(); ++rechitItr ) { EBDetId id = rechitItr->id(); const EcalTrigTowerDetId towid = id.tower(); itTT = mapTower.find(towid) ; if (itTT != mapTower.end()) { double theta = theBarrelGeometry_->getGeometry(id)->getPosition().theta() ; (itTT->second).eRec_ += rechitItr->energy()*sin(theta) ; if (maxRecHitEnergy < rechitItr->energy()*sin(theta) && rechitItr->energy()*sin(theta) > 1. ){ (itTT->second).sevlv_ = sevlv->severityLevel(id, *rechitsEB); } (itTT->second).crystNb_++; } } } if (DEBUG_) cout << __LINE__ << endl; // --------------------------------ADDED by William Richard Smith 10/10/18--------------------------------------------- // Get EE rechits edm::Handle<EcalRecHitCollection> rechitsEE; iEvent.getByToken(EcalRecHitCollectionEE1_,rechitsEE); if (rechitsEE.product()->size()!=0) { for ( EcalRecHitCollection::const_iterator rechitItr = rechitsEE->begin(); rechitItr != rechitsEE->end(); ++rechitItr ) { EEDetId id = rechitItr->id(); const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id); itTT = mapTower.find(towid); if (itTT != mapTower.end()) { double theta = theEndcapGeometry_->getGeometry(id)->getPosition().theta() ; (itTT->second).eRec_ += rechitItr->energy()*sin(theta) ; (itTT->second).crystNb_++; } } } if (useEE_) { // Get EE xtal digi inputs edm::Handle<EEDigiCollection> digiEE; // iEvent.getByLabel(digiCollectionEE_, digiEE); iEvent.getByToken(digiCollectionEE1_,digiEE); EEDataFrame dfMaxEE ; if(print_) cout << " EE digi collection size " << digiEE.product()->size() << endl ; for (unsigned int i=0;i<digiEE.product()->size();i++) { const EEDataFrame & df = (*(digiEE.product()))[i]; const EEDetId & id = df.id(); const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id); itTT = mapTower.find(towid) ; if (itTT != mapTower.end()) { (itTT->second).nbXtal_++ ; if (!skipWritingEndcapDigis_) { bool fill(false) ; if (((itTT->second).tpgADC_ & 0xff)>0) fill = true ; for (int j=0 ; j<5 ; j++) if (((itTT->second).tpgEmul_[j] & 0xff)>0) fill = true ; for (int s=1 ; s<df.size() ; s++) if (df[s].adc()-df[0].adc()>15) fill = true ; if (fill) { if(print_) cout<<"TP="<<((itTT->second).tpgADC_ & 0xff)<<" eta="<<towid.ieta()<<" phi="<<towid.iphi()<<endl ; treeVariablesShape_.ieta = towid.ieta() ; treeVariablesShape_.iphi = towid.iphi() ; treeVariablesShape_.ixXtal = id.ix() ; treeVariablesShape_.iyXtal = id.iy() ; const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(id) ; treeVariablesShape_.TCCid = theMapping_->TCCid(towid); treeVariablesShape_.TowerInTCC = theMapping_->iTT(towid); treeVariablesShape_.strip = elId.pseudoStripId() ; treeVariablesShape_.nbOfSamples = df.size() ; for (int s=0 ; s<df.size() ; s++) treeVariablesShape_.samp[s] = df[s].adc() ; treeShape_->Fill() ; } } } } // loop over EE digi } // UseEE_ /////////////////////////// // fill tree /////////////////////////// int towerNb = 0 ; for (itTT = mapTower.begin() ; itTT != mapTower.end() ; ++itTT) { // select only non zero towers bool fill(true) ; bool nonZeroEmul(false) ; for (int i=0 ; i<5 ; i++) if (((itTT->second).tpgEmul_[i]&0xff) > 0) nonZeroEmul = true ; if ( keepOnlyTowersAboveZero_ && ((itTT->second).tpgADC_&0xff) <= 0 && (!nonZeroEmul) ) fill = false ; if (print_ && fill) { std::cout<<"ieta="<<(itTT->second).ieta_<<" "<<(itTT->second).iphi_<<" tp="<<((itTT->second).tpgADC_&0xff)<<" tpEmul=" ; for (int i=0 ; i<5 ; i++) std::cout<<((itTT->second).tpgEmul_[i]&0xff)<<" " ; std::cout<<" nbXtal="<<(itTT->second).nbXtal_ ; std::cout<<std::endl ; } // fill=true; if (fill) { treeVariables_.ieta[towerNb] = (itTT->second).ieta_ ; treeVariables_.iphi[towerNb] = (itTT->second).iphi_ ; treeVariables_.nbOfXtals[towerNb] = (itTT->second).nbXtal_ ; treeVariables_.rawTPData[towerNb] = (itTT->second).tpgADC_ ; treeVariables_.rawTPEmul1[towerNb] = (itTT->second).tpgEmul_[0] ; treeVariables_.rawTPEmul2[towerNb] = (itTT->second).tpgEmul_[1] ; treeVariables_.rawTPEmul3[towerNb] = (itTT->second).tpgEmul_[2] ; treeVariables_.rawTPEmul4[towerNb] = (itTT->second).tpgEmul_[3] ; treeVariables_.rawTPEmul5[towerNb] = (itTT->second).tpgEmul_[4] ; treeVariables_.rawTPEmulttFlag1[towerNb] = (itTT->second).tpgEmulFlag_[0] ; treeVariables_.rawTPEmulttFlag2[towerNb] = (itTT->second).tpgEmulFlag_[1] ; treeVariables_.rawTPEmulttFlag3[towerNb] = (itTT->second).tpgEmulFlag_[2] ; treeVariables_.rawTPEmulttFlag4[towerNb] = (itTT->second).tpgEmulFlag_[3] ; treeVariables_.rawTPEmulttFlag5[towerNb] = (itTT->second).tpgEmulFlag_[4] ; treeVariables_.rawTPEmulsFGVB1[towerNb] = (itTT->second).tpgEmulsFGVB_[0] ; treeVariables_.rawTPEmulsFGVB2[towerNb] = (itTT->second).tpgEmulsFGVB_[1] ; treeVariables_.rawTPEmulsFGVB3[towerNb] = (itTT->second).tpgEmulsFGVB_[2] ; treeVariables_.rawTPEmulsFGVB4[towerNb] = (itTT->second).tpgEmulsFGVB_[3] ; treeVariables_.rawTPEmulsFGVB5[towerNb] = (itTT->second).tpgEmulsFGVB_[4] ; treeVariables_.crystNb[towerNb] = (itTT->second).crystNb_ ; treeVariables_.eRec[towerNb] = (itTT->second).eRec_ ; treeVariables_.sevlv[towerNb] = (itTT->second).sevlv_ ; treeVariables_.ttFlag[towerNb] = (itTT->second).ttFlag_ ; //treeVariables_.TCCid[towerNb] = (itTT->second).TCCid_; //treeVariables_.TowerInTCC[towerNb] = (itTT->second).TowerInTCC_; //treeVariables_.strip[towerNb] = (itTT->second).strip_; treeVariables_.spike[towerNb] = (itTT->second).spike_ ; treeVariables_.twrADC[towerNb] = (itTT->second).twrADC; treeVariables_.sFGVB[towerNb] = (itTT->second).sFGVB; if (abs(treeVariables_.ieta[towerNb])>17) { unsigned int maxEmul = 0 ; for (int i=0 ; i<5 ; i++) if (((itTT->second).tpgEmul_[i]&0xff) > maxEmul) maxEmul = ((itTT->second).tpgEmul_[i]&0xff) ; } towerNb++ ; } } treeVariables_.nbOfTowers = towerNb ; tree_->Fill() ; } DEFINE_FWK_MODULE(EcalTPGAnalyzer);
acd9fd70c0668525b0482f32c273c5d49f5c6f8c
2480ceee9f28f5e8a69fb6f5ed42fd63c22b4205
/include/Pomdog/Experimental/Skeletal2D/BlendTrees/AnimationLerpNode.hpp
2b638616a41d3d91607c684a88f246a8a6477287
[ "MIT" ]
permissive
rokrepo/pomdog
165db7884598c74bd530a4b7a1e83bc1e315c945
b21fd4fef295aaa3e06ca15e5952109cd8e93f00
refs/heads/master
2022-10-25T04:09:09.721827
2020-06-18T05:33:25
2020-06-18T05:33:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,057
hpp
// Copyright (c) 2013-2020 mogemimi. Distributed under the MIT license. #pragma once #include "Pomdog/Experimental/Skeletal2D/BlendTrees/AnimationNode.hpp" #include <memory> namespace Pomdog::Skeletal2D::Detail { class AnimationLerpNode final : public AnimationNode { public: AnimationLerpNode( std::unique_ptr<AnimationNode>&& blendNode1, std::unique_ptr<AnimationNode>&& blendNode2, std::uint16_t weightIndex); void Calculate( const AnimationTimeInterval& time, const Detail::AnimationGraphWeightCollection& weights, const Skeleton& skeleton, SkeletonPose& skeletonPose, Skin* skin) const override; AnimationTimeInterval GetLength() const override; [[nodiscard]] const AnimationNode* A() const noexcept; [[nodiscard]] const AnimationNode* B() const noexcept; private: std::unique_ptr<AnimationNode> nodeA; std::unique_ptr<AnimationNode> nodeB; AnimationTimeInterval length; std::uint16_t weightIndex; }; } // namespace Pomdog::Skeletal2D::Detail
9c2ac38bae6f4711f2c999d7cffe32123cb88861
a3cc4d27cb5ad6a21e63d5a5c6a41c0cacefedde
/tests/TestToken.cpp
0ada0b4bd4f601a63571d00b06ccf920ce952a61
[]
no_license
thomasebsmith/fleet
424bd9ca405ea92c1f73eee738386493a1a34b11
1ae7c0dd6b091311d3e17db5d261a3c565ca963e
refs/heads/master
2021-06-21T13:39:49.739275
2020-12-09T04:54:29
2020-12-09T04:54:29
151,968,882
10
0
null
null
null
null
UTF-8
C++
false
false
4,672
cpp
// File: tests/TestToken.cpp // Purpose: Source file for the TestToken test set. #include <string> #include "Tester.hpp" #include "TestToken.hpp" #include "Token.hpp" // Function declarations void createToken(); void getValue(); void setValue(); void getType(); void setType(); void checkEquality(); void checkGrouper(); void matchGrouper(); // main() - Runs all Token tests. int TestToken::main() { Tester tester("Token tests"); tester.test("Create a token", createToken); tester.test("Get a token's value", getValue); tester.test("Set a token's value", setValue); tester.test("Get a token's type", getType); tester.test("Set a token's type", setType); tester.test("Check tokens' equality and inequality", checkEquality); tester.test("Check whether a token is an opening grouper", checkGrouper); tester.test("Get a token's matching grouper", matchGrouper); return tester.run(); } // createToken() - Tests that Tokens can be created with basic string contents, // including empty strings. void createToken() { Token myToken { "some normal value", Token::Type::Comment }; Token anotherToken { "", Token::Type::String }; Token finalToken { "!@FOO", Token::Type::Number }; } // getValue() - Tests that the Token getValue() method correctly returns string // contents of different types of Tokens. void getValue() { std::string value = "my value"; std::string value2 = ""; Token myToken { value, Token::Type::Comment }; Token anotherToken { value2, Token::Type::Grouper }; Tester::confirm(value == myToken.getValue()); Tester::confirm(value2 == anotherToken.getValue()); } // setValue() - Tests that the setValue() method works consistently with the // getValue() method. void setValue() { std::string origValue = "something"; std::string newValue = "\n"; Token myToken { origValue, Token::Type::Operator }; myToken.setValue(newValue); Tester::confirm(newValue == myToken.getValue()); } // getType() - Tests that the getType() method correctly returns the type that // the Token was created as. void getType() { Token::Type type = Token::Type::Identifier; Token::Type type2 = Token::Type::LineBreak; std::string value2 = ""; Token myToken { "This", type }; Token anotherToken { "is literally a test\n\t", type2 }; Tester::confirm(type == myToken.getType()); Tester::confirm(type2 == anotherToken.getType()); } // setType() - Tests that the setType() method works consistently with the // getType() method. void setType() { Token::Type origType = Token::Type::Grouper; Token::Type newType = Token::Type::String; Token myToken { "", origType }; myToken.setType(newType); Tester::confirm(newType == myToken.getType()); } // checkEquality() - Checks that the == method correctly checks Token types // and contents for equality. void checkEquality() { Token t1 { "Foobar", Token::Type::Comment }; Token t2 { "Foobar", Token::Type::LineBreak }; Token t3 { "Foobar", Token::Type::Comment }; Token t4 { "barfoo", Token::Type::LineBreak }; Token t5 { "", Token::Type::Comment }; Tester::confirm(!(t1 == t2)); Tester::confirm(t1 != t2); Tester::confirm(t3 == t1); Tester::confirm(!(t3 != t1)); Tester::confirm(!(t4 == t1)); Tester::confirm(t4 != t1); Tester::confirm(!(t1 == t5)); Tester::confirm(t1 != t5); Tester::confirm(t5 == t5); Tester::confirm(!(t5 != t5)); } // checkGrouper() - Checks that the isOpeningGrouper() method correctly checks // whether a given Grouper Token is "(", "[", or "{". void checkGrouper() { Token t1 { "]", Token::Type::Grouper }; Token t2 { "}", Token::Type::Operator }; Token t3 { "", Token::Type::Grouper }; Token t4 { "foo", Token::Type::String }; Token t5 { "(", Token::Type::Grouper }; Token t6 { "[", Token::Type::Grouper }; Token t7 { "{", Token::Type::Grouper }; Tester::confirm(!t1.isOpeningGrouper()); Tester::confirm(!t2.isOpeningGrouper()); Tester::confirm(!t3.isOpeningGrouper()); Tester::confirm(!t4.isOpeningGrouper()); Tester::confirm(t5.isOpeningGrouper()); Tester::confirm(t6.isOpeningGrouper()); Tester::confirm(t7.isOpeningGrouper()); } // matchGrouper() - Checks whether the matchingGropuer() method correctly // finds the closing Grouper for a given opening Grouper. void matchGrouper() { Token t1 { "(", Token::Type::Grouper }; Token t2 { "[", Token::Type::Grouper }; Token t3 { "{", Token::Type::Grouper }; Token t4 { ")", Token::Type::Grouper }; Token t5 { "]", Token::Type::Grouper }; Token t6 { "}", Token::Type::Grouper }; Tester::confirm(t1.matchingGrouper() == t4); Tester::confirm(t2.matchingGrouper() == t5); Tester::confirm(t3.matchingGrouper() == t6); }
fa6bc58dfb4390211dd83c1ef5ae828e4c5112ec
97b14de52a932f8c9ba5212290c9db2257a53fe6
/CS 32 Project 2/CS 32 Project 2/TestWeightMap.cpp
34ceaa32e52681e93a3e571df663589b354363f2
[]
no_license
JayKun/CS-32
7ea69007fc522268398dbb40d61faf6df48e4ef1
a841e1040cbf63b6aca638d60f55b0352b03ea35
refs/heads/master
2020-12-24T12:34:27.634364
2016-11-06T08:13:49
2016-11-06T08:13:49
72,977,577
0
0
null
null
null
null
UTF-8
C++
false
false
102
cpp
#include "WeightMap.h" #include <string> #include <iostream> #include <cassert> using namespace std;
f61b8666b9ddbd1aa498dc78a248f7153e926ad7
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h
e4d896306d6ae429117cd7131f4a4eef6b3336db
[ "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause" ]
permissive
wzyy2/chromium-browser
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
refs/heads/master
2022-11-23T20:25:08.120045
2018-01-16T06:41:26
2018-01-16T06:41:26
117,618,467
3
2
BSD-3-Clause
2022-11-20T22:03:57
2018-01-16T02:09:10
null
UTF-8
C++
false
false
2,887
h
/* * Copyright (C) 2003 Lars Knoll ([email protected]) * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights * reserved. * Copyright (C) 2008 Eric Seidel <[email protected]> * Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights * reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef CSSPropertyParser_h #define CSSPropertyParser_h #include "core/css/StyleRule.h" #include "core/css/parser/CSSParserContext.h" #include "core/css/parser/CSSParserTokenRange.h" #include "platform/wtf/text/StringView.h" namespace blink { class CSSProperty; class CSSValue; // Inputs: PropertyID, isImportant bool, CSSParserTokenRange. // Outputs: Vector of CSSProperties class CSSPropertyParser { WTF_MAKE_NONCOPYABLE(CSSPropertyParser); STACK_ALLOCATED(); public: static bool ParseValue(CSSPropertyID, bool important, const CSSParserTokenRange&, const CSSParserContext*, HeapVector<CSSProperty, 256>&, StyleRule::RuleType); // Parses a non-shorthand CSS property static const CSSValue* ParseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext*); private: CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext*, HeapVector<CSSProperty, 256>*); // TODO(timloh): Rename once the CSSParserValue-based parseValue is removed bool ParseValueStart(CSSPropertyID unresolved_property, bool important); bool ConsumeCSSWideKeyword(CSSPropertyID unresolved_property, bool important); bool ParseViewportDescriptor(CSSPropertyID prop_id, bool important); bool ParseFontFaceDescriptor(CSSPropertyID); private: // Inputs: CSSParserTokenRange range_; Member<const CSSParserContext> context_; // Outputs: HeapVector<CSSProperty, 256>* parsed_properties_; }; CSSPropertyID UnresolvedCSSPropertyID(StringView); CSSValueID CssValueKeywordID(StringView); } // namespace blink #endif // CSSPropertyParser_h
3d1e24bd1b8b6bafef08b3c3d0e5353961a02a10
163210f1d81b75a12241976917ab086e3a16509d
/Classes/Scene/PreGameScene.h
d9da024fd16bc723b91161538fd410e648adb922
[]
no_license
lshain/HeroTalk
1049ec47fc29b4b413e62876e165f6e9104b2929
a1d23c312cf41be3e26b1c7d4c06bd8a4b785178
refs/heads/master
2021-01-18T07:48:12.116021
2015-08-07T15:41:38
2015-08-07T15:41:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
797
h
#ifndef PreGameScene_scene #define PreGameScene_scene #include "cocos2d.h" #include "LevelNode.h" #include "ui/CocosGUI.h" class PreGameScene : public cocos2d::Layer { public: // there's no 'id' in cpp, so we recommend returning the class instance pointer static cocos2d::Scene* createScene(LevelNode* node); // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event); // implement the "static create()" method manually CREATE_FUNC(PreGameScene); void gotoGame(cocos2d::Ref* object, cocos2d::ui::Widget::TouchEventType type); private: static LevelNode* selectNode; }; #endif // PreGameScene_scene
fc26f4bb34555ee8081e7e2f7794f3a3ad26846f
8a71e93f6dcda2428999143370d5fe4219327d3f
/solutions/fgYrmYBp.cpp
ac365c3a9747496e3d78c500dac0901626da56f5
[ "MIT" ]
permissive
randauto/cpp-solutions
21dce36fd4e10dbea3945d37be0cb2510210d446
627397fb887654e9f5ee64cfb73d708f6f6706f7
refs/heads/main
2023-09-02T11:15:20.336637
2021-11-18T01:03:00
2021-11-18T01:03:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,675
cpp
/* Sưu tầm bởi @nguyenvanhieuvn Thực hành nhiều bài tập hơn tại https://luyencode.net/ */ #include<stdio.h> #include<conio.h> #include<math.h> #define MAX 100 void NhapMaTran(int a[][MAX], int &n) { do { printf("\nNhap n: "); scanf("%d", &n); if(n <= 1 || n > MAX) { printf("\nSo phan tu khong hop le. Xin kiem tra lai !"); } }while(n <= 1 || n > MAX); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { printf("\nNhap vao a[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } } void XuatMaTran(int a[][MAX], int n) { for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { printf("%4d",a[i][j]); } printf("\n\n"); } } int TinhTongCacPhanTuChanNamTrenBien(int a[][MAX], int n) { int S = 0; // Duyệt 2 cột biên for(int i = 0; i < n; i++) { if(a[0][i] % 2 == 0) { S += a[0][i]; } if(a[n - 1][i] % 2 == 0) { S += a[n - 1][i]; } } // Duyệt 2 dòng biên bỏ qua các phần tử thuộc 2 cột đã duyệt for(int i = 1; i < n - 1; i++) { if(a[i][0] % 2 == 0) { S += a[i][0]; } if(a[i][n - 1] % 2 == 0) { S += a[i][n - 1]; } } return S; } int main() { int a[MAX][MAX], n; NhapMaTran(a,n); XuatMaTran(a,n); int tong = TinhTongCacPhanTuChanNamTrenBien(a, n); printf("\nTong cac phan tu chan nam tren bien = %d", tong); getch(); return 0; }