blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
75085833ea1367286331e46ce31d4ed9aadf6283 | 7c63a96fad4257f4959ffeba0868059fc96566fb | /cpp/std-17/m_bancila-modern_cpp_programming_cookbook/ch_01-core_lang/01-auto_keyword.cpp | c9142e5e8e3625db574d09a10e14b37ffdfc860f | [
"MIT"
] | permissive | ordinary-developer/education | b426148f5690f48e0ed4853adfc3740bd038b72c | 526e5cf86f90eab68063bb7c75744226f2c54b8d | refs/heads/master | 2023-08-31T14:42:37.237690 | 2023-08-30T18:15:18 | 2023-08-30T18:15:18 | 91,232,306 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,087 | cpp | // region [how to do it]
#include <iostream>
#include <typeinfo>
#include <cassert>
#include <initializer_list>
namespace example_01 {
void run() {
static_assert(true);
auto i = 42;
auto d = 42.5;
auto s = "text";
auto v = {1, 2, 3};
int i2 = 42;
double d2 = 42.5;
char const* s2 = "text";
std::initializer_list<int> v2 = {1, 2, 3};
assert(typeid(i) == typeid(i2));
assert(typeid(d) == typeid(d2));
assert(typeid(s) == typeid(s2));
assert(typeid(v) == typeid(v2));
std::cout << "typeid(i): " << typeid(i).name() << std::endl;
std::cout << "typeif(d): " << typeid(d).name() << std::endl;
std::cout << "typeif(s): " << typeid(s).name() << std::endl;
std::cout << "typeif(v): " << typeid(v).name() << std::endl;
}
}
#include <cassert>
#include <typeinfo>
#include <string>
#include <vector>
#include <memory>
#include <iostream>
namespace example_02 {
void run() {
auto b = new char[10]{ 0 };
auto s = std::string{ "text" };
auto v = std::vector<int>{ 1, 2, 3 };
auto p = std::make_shared<int>(42);
char* b2 = new char[10]{ 0 };
std::string s2 = std::string{ "text" };
std::vector<int> v2 = std::vector<int>{ 1, 2, 3 };
std::shared_ptr<int> p2 = std::make_shared<int>(42);
assert(typeid(b) == typeid(b2));
assert(typeid(s) == typeid(s2));
assert(typeid(v) == typeid(v2));
assert(typeid(p) == typeid(p2));
std::cout << "typeid(b): " << typeid(b).name() << std::endl;
std::cout << "typeid(s): " << typeid(s).name() << std::endl;
std::cout << "typeid(v): " << typeid(v).name() << std::endl;
std::cout << "typeid(p): " << typeid(p).name() << std::endl;
delete b;
b = nullptr;
delete b2;
b2 = nullptr;
}
}
#include <iostream>
#include <typeinfo>
#include <cctype>
#include <functional>
namespace example_03 {
void run() {
auto upper = [](char const c) { return toupper(c); };
std::function<int(char const)> upper2 =
[](char const c) { return toupper(c); };
std::cout << "typeid(upper): " << typeid(upper).name() << std::endl;
std::cout << "typeid(upper2): " << typeid(upper2).name() << std::endl;
}
}
#include <iostream>
#include <typeinfo>
#include <functional>
namespace example_04 {
void run() {
auto add = [](auto const a, auto const b) { return a + b; };
std::cout << "typeid(add): " << typeid(add).name() << std::endl;
}
}
namespace example_05 {
template <typename F, typename T>
auto apply(F&& f, T value) {
return f(value);
}
void run() {
}
}
// endregion [how to do it]
// region [how it works]
#include <vector>
#include <cstddef>
#include <typeinfo>
#include <cassert>
namespace example_06 {
void run() {
auto v = std::vector<int>{ 1, 2, 3 };
int size1 = v.size();
auto size2 = v.size();
auto size3 = int{ v.size() }; // here an warning will be
std::cout << "typeid(size1): " << typeid(size1).name() << std::endl;
std::cout << "typeid(size2): " << typeid(size2).name() << std::endl;
std::cout << "typeid(size3): " << typeid(size3).name() << std::endl;
}
}
#include <iostream>
namespace example_07 {
class foo {
public:
foo(int const x = 0) : x_{ x } {}
int& get() { return x_; }
private:
int x_;
};
void run() {
foo f{42};
auto x = f.get();
x = x + 100;
std::cout << f.get() << std::endl;
}
}
#include <iostream>
#include <typeinfo>
namespace example_08 {
void run() {
auto l = 42LL;
std::cout << "typeid(l): " << typeid(l).name() << std::endl;
}
}
namespace example_09 {
auto func1(int const i) -> int { return 2 * i; }
auto func2(int const i) { return 2 * i; }
void run() {
}
}
#include <iostream>
namespace example_10 {
class foo {
public:
foo(int const x = 0) : x_{ x } {}
int& get() { return x_; }
private:
int x_;
};
decltype(auto) proxy_get(foo& f) { return f.get(); }
void run() {
auto f = foo{ 42 };
decltype(auto) x = proxy_get(f);
x += 100;
std::cout << f.get() << std::endl;
}
}
#include <iostream>
#include <string>
namespace example_11 {
struct {
template <typename T, typename U>
auto operator() (T const a, U const b) const { return a + b; }
} struct_add;
void run() {
auto lambda_add = [](auto const a, auto const b) { return a + b; };
auto i = lambda_add(40, 2);
using namespace std::literals;
auto s = lambda_add("forty"s, "two"s);
}
}
// endregion [how it works]
typedef void (*ExampleFunction)();
#include <array>
#include <cstddef>
int main() {
const size_t ARRAY_SIZE = 11;
std::array<ExampleFunction, ARRAY_SIZE> examples{ {
&example_01::run, &example_02::run, &example_03::run,
&example_04::run, &example_05::run, &example_06::run,
&example_07::run, &example_08::run, &example_09::run,
&example_10::run, &example_11::run } };
for (const auto & example : examples) {
std::cout << "example => " << std::endl;
example();
std::cout << "end" << std::endl << std::endl;
}
return 0;
}
| [
"merely.ordinary.developer@gmail.com"
] | merely.ordinary.developer@gmail.com |
244c5a3748d59cddc50bc1edf6c96b8318b2fad7 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_new_log_2709.cpp | f3367127fc3ea934fcf3c74d72810c122edabffc | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 35 | cpp | die(_("unrecognized width:%s"), s); | [
"993273596@qq.com"
] | 993273596@qq.com |
26427a5e08f62cf3d49d7be5f99aa690531d4407 | 2bb27dc9bd3067deebb82f7c57fdac02a915d0d4 | /src/checkpoints.cpp | 5fdc2aee1fce64e782f785ded937fdf9d8eddd5d | [
"MIT"
] | permissive | bedri/proxynode | e46504844abd3f1772c16f37342bce1ca1f8c30a | 5b42796d008a5976703b2c2adcfcafc639c64c8f | refs/heads/master | 2020-05-19T13:14:45.538666 | 2019-05-05T08:36:00 | 2019-05-05T08:36:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,470 | cpp | // Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 The Prx developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "checkpoints.h"
#include "chainparams.h"
#include "main.h"
#include "uint256.h"
#include <stdint.h>
#include <boost/foreach.hpp>
namespace Checkpoints
{
/**
* How many times we expect transactions after the last checkpoint to
* be slower. This number is a compromise, as it can't be accurate for
* every system. When reindexing from a fast disk with a slow CPU, it
* can be up to 20, while when downloading from a slow network with a
* fast multicore CPU, it won't be much higher than 1.
*/
static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;
bool fEnabled = true;
bool CheckBlock(int nHeight, const uint256& hash)
{
if (!fEnabled)
return true;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
return hash == i->second;
}
//! Guess how far we are in the verification process at the given block index
double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks)
{
if (pindex == NULL)
return 0.0;
int64_t nNow = time(NULL);
double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0;
double fWorkBefore = 0.0; // Amount of work done before pindex
double fWorkAfter = 0.0; // Amount of work left after pindex (estimated)
// Work is defined as: 1.0 per transaction before the last checkpoint, and
// fSigcheckVerificationFactor per transaction after.
const CCheckpointData& data = Params().Checkpoints();
if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
double nCheapBefore = pindex->nChainTx;
double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx;
double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint) / 86400.0 * data.fTransactionsPerDay;
fWorkBefore = nCheapBefore;
fWorkAfter = nCheapAfter + nExpensiveAfter * fSigcheckVerificationFactor;
} else {
double nCheapBefore = data.nTransactionsLastCheckpoint;
double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint;
double nExpensiveAfter = (nNow - pindex->GetBlockTime()) / 86400.0 * data.fTransactionsPerDay;
fWorkBefore = nCheapBefore + nExpensiveBefore * fSigcheckVerificationFactor;
fWorkAfter = nExpensiveAfter * fSigcheckVerificationFactor;
}
return fWorkBefore / (fWorkBefore + fWorkAfter);
}
int GetTotalBlocksEstimate()
{
if (!fEnabled)
return 0;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
return checkpoints.rbegin()->first;
}
CBlockIndex* GetLastCheckpoint()
{
if (!fEnabled)
return NULL;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
BOOST_REVERSE_FOREACH (const MapCheckpoints::value_type& i, checkpoints) {
const uint256& hash = i.second;
BlockMap::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
return t->second;
}
return NULL;
}
} // namespace Checkpoints
| [
"root@m5079.contaboserver.net"
] | root@m5079.contaboserver.net |
629d429407ef0e7a08c9c63c90e573fef16cd165 | d1ba96b3467fea007f85a2a44ca8724329d195b7 | /Final Submission/Sourcecode/Client/Debug/debug/moc_dialog.cpp | a42e3e6aa05c0cb06ac49dd256b84779bd487fe5 | [] | no_license | Team-Chimera/Comm-Audio | 9caa5c72adf75a2bfddfc06b9fc2766d08f6c370 | 5b6ea3e9419f5f7a026651dc994fbfb2f1c7d5f9 | refs/heads/master | 2016-09-06T04:12:27.576781 | 2015-04-09T05:37:10 | 2015-04-09T05:37:10 | 30,979,831 | 0 | 5 | null | 2015-04-09T05:37:10 | 2015-02-18T18:31:53 | C | UTF-8 | C++ | false | false | 3,307 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'dialog.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.4.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../comm-audio/sourcecode/client/dialog.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'dialog.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.4.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_Dialog_t {
QByteArrayData data[3];
char stringdata[25];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_Dialog_t, stringdata) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_Dialog_t qt_meta_stringdata_Dialog = {
{
QT_MOC_LITERAL(0, 0, 6), // "Dialog"
QT_MOC_LITERAL(1, 7, 16), // "connectMulticast"
QT_MOC_LITERAL(2, 24, 0) // ""
},
"Dialog\0connectMulticast\0"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_Dialog[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 19, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Bool,
0 // eod
};
void Dialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Dialog *_t = static_cast<Dialog *>(_o);
switch (_id) {
case 0: { bool _r = _t->connectMulticast();
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
default: ;
}
}
}
const QMetaObject Dialog::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_Dialog.data,
qt_meta_data_Dialog, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *Dialog::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *Dialog::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_Dialog.stringdata))
return static_cast<void*>(const_cast< Dialog*>(this));
return QDialog::qt_metacast(_clname);
}
int Dialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 1)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 1;
}
return _id;
}
QT_END_MOC_NAMESPACE
| [
"rhealauzon@gmail.com"
] | rhealauzon@gmail.com |
b9afce1ab16e25e9f29f2ef4c4468f5750598d66 | 331af263b0a55ab97f32ea43777eb6bb0a69b620 | /300. Longest Increasing Subsequence.cpp | 80a2a828f80be13d69bf47e42eadb9813b836884 | [] | no_license | yanjunp-cmu/LeetCode | 3369683dd1d80b94726ab398083dbc377d4ef82b | 84dfcccb0fcb1debd45c982c132ba020e7e92d74 | refs/heads/master | 2020-07-12T08:11:53.560397 | 2020-01-17T17:48:13 | 2020-01-17T17:48:13 | 204,762,049 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 457 | cpp | class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
if(nums.empty()) return 0;
vector<int> dp(nums.size(), 1);
int result = 1;
for (int i = 1; i < nums.size(); i++){
for (int j = 0; j < i; j++){
if(nums[j] < nums[i]){
dp[i] = max(dp[j] + 1, dp[i]);
}
}
result = max(result, dp[i]);
}
return result;
}
}; | [
"yanjunp@andrew.cmu.edu"
] | yanjunp@andrew.cmu.edu |
12ee2a96480c917b164e73ddbb93b59fc0f59f1b | fab03e072dd5a48eb22b5b4eba58960ee1f2b7d1 | /src/irc.cpp | 71427caf57178aee70794a67e5d2690bec6a139e | [
"MIT"
] | permissive | erfan007p/litecoinstake-source | 8f3c825748b3648c7f35104a75fb7a445fc926a9 | ad1ed4df8b4754e3ae819e357413a88bd3fd8967 | refs/heads/master | 2021-05-16T04:52:06.996080 | 2017-10-08T23:52:14 | 2017-10-08T23:52:14 | 106,218,611 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,998 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "irc.h"
#include "net.h"
#include "strlcpy.h"
#include "base58.h"
using namespace std;
using namespace boost;
int nGotIRCAddresses = 0;
void ThreadIRCSeed2(void* parg);
#pragma pack(push, 1)
struct ircaddr
{
struct in_addr ip;
short port;
};
#pragma pack(pop)
string EncodeAddress(const CService& addr)
{
struct ircaddr tmp;
if (addr.GetInAddr(&tmp.ip))
{
tmp.port = htons(addr.GetPort());
vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
return string("u") + EncodeBase58Check(vch);
}
return "";
}
bool DecodeAddress(string str, CService& addr)
{
vector<unsigned char> vch;
if (!DecodeBase58Check(str.substr(1), vch))
return false;
struct ircaddr tmp;
if (vch.size() != sizeof(tmp))
return false;
memcpy(&tmp, &vch[0], sizeof(tmp));
addr = CService(tmp.ip, ntohs(tmp.port));
return true;
}
static bool Send(SOCKET hSocket, const char* pszSend)
{
if (strstr(pszSend, "PONG") != pszSend)
printf("IRC SENDING: %s\n", pszSend);
const char* psz = pszSend;
const char* pszEnd = psz + strlen(psz);
while (psz < pszEnd)
{
int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL);
if (ret < 0)
return false;
psz += ret;
}
return true;
}
bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
while (true)
{
bool fRet = RecvLine(hSocket, strLine);
if (fRet)
{
if (fShutdown)
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() >= 1 && vWords[0] == "PING")
{
strLine[1] = 'O';
strLine += '\r';
Send(hSocket, strLine.c_str());
continue;
}
}
return fRet;
}
}
int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
{
while (true)
{
string strLine;
strLine.reserve(10000);
if (!RecvLineIRC(hSocket, strLine))
return 0;
printf("IRC %s\n", strLine.c_str());
if (psz1 && strLine.find(psz1) != string::npos)
return 1;
if (psz2 && strLine.find(psz2) != string::npos)
return 2;
if (psz3 && strLine.find(psz3) != string::npos)
return 3;
if (psz4 && strLine.find(psz4) != string::npos)
return 4;
}
}
bool Wait(int nSeconds)
{
if (fShutdown)
return false;
printf("IRC waiting %d seconds to reconnect\n", nSeconds);
for (int i = 0; i < nSeconds; i++)
{
if (fShutdown)
return false;
MilliSleep(1000);
}
return true;
}
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{
strRet.clear();
while (true)
{
string strLine;
if (!RecvLineIRC(hSocket, strLine))
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 2)
continue;
if (vWords[1] == psz1)
{
printf("IRC %s\n", strLine.c_str());
strRet = strLine;
return true;
}
}
}
bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
{
Send(hSocket, strprintf("USERHOST %s\r", strMyName.c_str()).c_str());
string strLine;
if (!RecvCodeLine(hSocket, "302", strLine))
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 4)
return false;
string str = vWords[3];
if (str.rfind("@") == string::npos)
return false;
string strHost = str.substr(str.rfind("@")+1);
// Hybrid IRC used by lfnet always returns IP when you userhost yourself,
// but in case another IRC is ever used this should work.
printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());
CNetAddr addr(strHost, true);
if (!addr.IsValid())
return false;
ipRet = addr;
return true;
}
void ThreadIRCSeed(void* parg)
{
// Make this thread recognisable as the IRC seeding thread
RenameThread("litecoinstake-ircseed");
try
{
ThreadIRCSeed2(parg);
}
catch (std::exception& e) {
PrintExceptionContinue(&e, "ThreadIRCSeed()");
} catch (...) {
PrintExceptionContinue(NULL, "ThreadIRCSeed()");
}
printf("ThreadIRCSeed exited\n");
}
void ThreadIRCSeed2(void* parg)
{
// Don't connect to IRC if we won't use IPv4 connections.
if (IsLimited(NET_IPV4))
return;
// ... or if we won't make outbound connections and won't accept inbound ones.
if (mapArgs.count("-connect") && fNoListen)
return;
// ... or if IRC is not enabled.
if (!GetBoolArg("-irc", false))
return;
printf("ThreadIRCSeed started\n");
int nErrorWait = 10;
int nRetryWait = 10;
int nNameRetry = 0;
while (!fShutdown)
{
CService addrConnect("92.243.23.21", 6667); // irc.lfnet.org
CService addrIRC("irc.lfnet.org", 6667, true);
if (addrIRC.IsValid())
addrConnect = addrIRC;
SOCKET hSocket;
if (!ConnectSocket(addrConnect, hSocket))
{
printf("IRC connect failed\n");
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname", "ignoring hostname"))
{
closesocket(hSocket);
hSocket = INVALID_SOCKET;
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses
CService addrLocal;
string strMyName;
// Don't use our IP as our nick if we're not listening
// or if it keeps failing because the nick is already in use.
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "")
strMyName = strprintf("x%"PRIu64"", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
int nRet = RecvUntil(hSocket, " 004 ", " 433 ");
if (nRet != 1)
{
closesocket(hSocket);
hSocket = INVALID_SOCKET;
if (nRet == 2)
{
printf("IRC name already in use\n");
nNameRetry++;
Wait(10);
continue;
}
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
nNameRetry = 0;
MilliSleep(500);
// Get our external IP from the IRC server and re-nick before joining the channel
CNetAddr addrFromIRC;
if (GetIPFromIRC(hSocket, strMyName, addrFromIRC))
{
printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str());
// Don't use our IP as our nick if we're not listening
if (!fNoListen && addrFromIRC.IsRoutable())
{
// IRC lets you to re-nick
AddLocal(addrFromIRC, LOCAL_IRC);
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
}
}
if (fTestNet) {
Send(hSocket, "JOIN #litecoinstakeTEST\r");
Send(hSocket, "WHO #litecoinstakeTEST\r");
} else {
// randomly join #litecoinstake00-#litecoinstake05
int channel_number = GetRandInt(5);
// Channel number is always 0 for initial release
//int channel_number = 0;
Send(hSocket, strprintf("JOIN #litecoinstake%02d\r", channel_number).c_str());
Send(hSocket, strprintf("WHO #litecoinstake%02d\r", channel_number).c_str());
}
int64_t nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))
{
if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':')
continue;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 2)
continue;
char pszName[10000];
pszName[0] = '\0';
if (vWords[1] == "352" && vWords.size() >= 8)
{
// index 7 is limited to 16 characters
// could get full length name at index 10, but would be different from join messages
strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));
printf("IRC got who\n");
}
if (vWords[1] == "JOIN" && vWords[0].size() > 1)
{
// :username!username@50000007.F000000B.90000002.IP JOIN :#channelname
strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
if (strchr(pszName, '!'))
*strchr(pszName, '!') = '\0';
printf("IRC got join\n");
}
if (pszName[0] == 'u')
{
CAddress addr;
if (DecodeAddress(pszName, addr))
{
addr.nTime = GetAdjustedTime();
if (addrman.Add(addr, addrConnect, 51 * 60))
printf("IRC got new address: %s\n", addr.ToString().c_str());
nGotIRCAddresses++;
}
else
{
printf("IRC decode failed\n");
}
}
}
closesocket(hSocket);
hSocket = INVALID_SOCKET;
if (GetTime() - nStart > 20 * 60)
{
nErrorWait /= 3;
nRetryWait /= 3;
}
nRetryWait = nRetryWait * 11 / 10;
if (!Wait(nRetryWait += 60))
return;
}
}
#ifdef TEST
int main(int argc, char *argv[])
{
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR)
{
printf("Error at WSAStartup()\n");
return false;
}
ThreadIRCSeed(NULL);
WSACleanup();
return 0;
}
#endif
| [
"erfan007p@gmail.com"
] | erfan007p@gmail.com |
20dce90ae5d5fbc226a524b2757c9f23b217b270 | 69a22b81c47cfeb711196dabe9299cb070578963 | /DataProcess/ThreadManager.cpp | 54c7735905a54ddde7ae2a6b99384729491b2537 | [] | no_license | nhs635/Havana2 | 6610272c0d1aacfbb73f598792d5d506dbf89bf8 | 34e732a8804ceb6f12c9fe12d4bce524c3c66139 | refs/heads/master | 2023-08-21T22:26:27.201648 | 2023-08-03T05:17:08 | 2023-08-03T05:17:08 | 98,523,311 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,369 | cpp |
#include <DataProcess/ThreadManager.h>
ThreadManager::ThreadManager(const char* _threadID) :
_running(false)
{
memset(threadID, 0, MAX_LENGTH);
memcpy(threadID, _threadID, strlen(_threadID));
}
ThreadManager::~ThreadManager()
{
if (_thread.joinable())
{
_running = false;
_thread.join();
}
}
void ThreadManager::run()
{
unsigned int frameIndex = 0;
_running = true;
while (_running)
DidAcquireData(frameIndex++);
}
bool ThreadManager::startThreading()
{
if (_thread.joinable())
{
char* msg = nullptr;
sprintf(msg, "ERROR: %s thread is already running: ", threadID);
dumpErrorSystem(-1, msg); //(::GetLastError(), msg);
return false;
}
_thread = std::thread(&ThreadManager::run, this);
printf("%s thread is started.\n", threadID);
return true;
}
void ThreadManager::stopThreading()
{
if (_thread.joinable())
{
DidStopData(); //_running = false;
_thread.join();
}
printf("%s thread is finished normally.\n", threadID);
}
void ThreadManager::dumpErrorSystem(int res, const char* pPreamble)
{
char* pErr = nullptr;
char msg[MAX_LENGTH];
memcpy(msg, pPreamble, strlen(pPreamble));
sprintf(pErr, "Error code (%d)", res);
strcat(msg, pErr);
printf("%s\n", msg);
SendStatusMessage(msg);
}
| [
"nhs635@hanmail.net"
] | nhs635@hanmail.net |
9424fed3d189f375b2c430a3bd828a575457bc64 | 9097b4172997abadd081a19789dc505f91759cea | /Sound Visualizer/Bar.hpp | b7f7da5ed0bc5eaf6503ec2bc0bec81ad5cdb99e | [] | no_license | veiyas/Sound-Visualizer | 65a0d14ca175560883a41d4a0d0566e43b0e785f | bde2ab6a16efc10e224e5d3f94226dd542b2d9f0 | refs/heads/master | 2020-07-27T10:56:01.925060 | 2019-10-16T21:20:14 | 2019-10-16T21:20:14 | 209,063,782 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 635 | hpp | #pragma once
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include "Constants.hpp"
#include <vector>
#include <memory>
#include <iostream>
class Bar
{
public:
Bar(GLfloat x_coord, GLfloat height, GLfloat z_coord);
~Bar();
void render();
private:
//OpenGL magic
GLuint vao = 0; // Vertex array object, the main handle for geometry
const int nverts; // Number of vertices in the vertex array
const int ntris; // Number of triangles in the index array (may be zero)
GLuint vertexbuffer; // Buffer ID to bind to GL_ARRAY_BUFFER
GLuint indexbuffer; // Buffer ID to bind to GL_ELEMENT_ARRAY_BUFFER
}; | [
"david.rk97@gmail.com"
] | david.rk97@gmail.com |
230f1ac4bfa289ee33b50ef4079aef99b2bf102b | 1441bc7fee74a372af6ba63a8a4dc04100e6255c | /aria-HW/part_c.cpp | 096d0398c594c302c8888ab6cf2c7ba6721b1c1d | [] | no_license | Chen-Yu-Qiang/class | b9931f9be9dbfc4156531c8cbbfa4b3b9b6740a2 | 46470e472eb74223d3cc69d3e0da31c4f63e6ce2 | refs/heads/master | 2023-07-13T14:41:46.858478 | 2021-08-29T04:41:34 | 2021-08-29T04:41:34 | 400,951,752 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,657 | cpp |
#include "Aria.h"
int main(int argc, char **argv)
{
ArRobot robot;
ArSonarDevice sonar;
robot.addRangeDevice(&sonar);
Aria::init();
ArSimpleConnector connector(&argc, argv);
if (!connector.connectRobot(&robot))
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
Aria::exit(1);
}
robot.comInt(ArCommands::ENABLE, 1);
robot.runAsync(false);
// Used to perform actions when keyboard keys are pressed
ArKeyHandler keyHandler;
Aria::setKeyHandler(&keyHandler);
// ArRobot contains an exit action for the Escape key. It also
// stores a pointer to the keyhandler so that other parts of the program can
// use the same keyhandler.
robot.attachKeyHandler(&keyHandler);
printf("You may press escape to exit\n");
// TODO: control the robot
// Start of controling
// 1. Lock the robot
robot.lock();
// 2. Write your control code here,
// e.g. robot.setVel(150);
robot.setVel(0);
// 3. Unlock the robot
robot.unlock();
// 4. Sleep a while and let the robot move
while (true)
{
int ch=keyHandler.getKey();
printf("%f %f %f push key:%d\n", robot.getX(), robot.getY(), robot.getTh(),ch);
if(ch==256){
robot.setVel(150);
robot.setRotVel(0);
}else if (ch==257)
{
robot.setVel(-150);
robot.setRotVel(0);
}else if (ch==258)
{
robot.setVel(0);
robot.setRotVel(50);
}else if (ch==259)
{
robot.setVel(0);
robot.setRotVel(-50);
}else{
robot.setVel(0);
robot.setRotVel(0);
}
ArUtil::sleep(100);
}
// End of controling
Aria::shutdown();
Aria::exit(0);
}
| [
"a@example.com"
] | a@example.com |
0be06367f6d122f3f0bf74d50e58f18c0f700ba4 | 33546aee6429d5b8f19a02e14699b6ebb5b34af8 | /src/ui/views/view_unittest.cc | 6af6b3a1612a4d4a55e5a069c0014c15e01e0578 | [
"BSD-3-Clause"
] | permissive | mYoda/CustomBrs | bdbf992c0db0bf2fd1821fa1fd0120ac77ffc011 | 493fc461eb7ea7321c51c6831fe737cfb21fdd3e | refs/heads/master | 2022-11-22T09:11:37.873894 | 2022-11-10T10:02:49 | 2022-11-10T10:02:49 | 24,951,822 | 0 | 1 | null | 2022-11-02T14:39:34 | 2014-10-08T17:22:30 | C++ | UTF-8 | C++ | false | false | 128,594 | 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 <map>
#include "base/memory/scoped_ptr.h"
#include "base/rand_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/ui_strings.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/compositor/test/test_layers.h"
#include "ui/events/event.h"
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/path.h"
#include "ui/gfx/transform.h"
#include "ui/views/background.h"
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/view.h"
#include "ui/views/view_constants_aura.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/window/dialog_client_view.h"
#include "ui/views/window/dialog_delegate.h"
#include "ui/wm/core/window_util.h"
using base::ASCIIToUTF16;
namespace {
// Returns true if |ancestor| is an ancestor of |layer|.
bool LayerIsAncestor(const ui::Layer* ancestor, const ui::Layer* layer) {
while (layer && layer != ancestor)
layer = layer->parent();
return layer == ancestor;
}
// Convenience functions for walking a View tree.
const views::View* FirstView(const views::View* view) {
const views::View* v = view;
while (v->has_children())
v = v->child_at(0);
return v;
}
const views::View* NextView(const views::View* view) {
const views::View* v = view;
const views::View* parent = v->parent();
if (!parent)
return NULL;
int next = parent->GetIndexOf(v) + 1;
if (next != parent->child_count())
return FirstView(parent->child_at(next));
return parent;
}
// Convenience functions for walking a Layer tree.
const ui::Layer* FirstLayer(const ui::Layer* layer) {
const ui::Layer* l = layer;
while (l->children().size() > 0)
l = l->children()[0];
return l;
}
const ui::Layer* NextLayer(const ui::Layer* layer) {
const ui::Layer* parent = layer->parent();
if (!parent)
return NULL;
const std::vector<ui::Layer*> children = parent->children();
size_t index;
for (index = 0; index < children.size(); index++) {
if (children[index] == layer)
break;
}
size_t next = index + 1;
if (next < children.size())
return FirstLayer(children[next]);
return parent;
}
// Given the root nodes of a View tree and a Layer tree, makes sure the two
// trees are in sync.
bool ViewAndLayerTreeAreConsistent(const views::View* view,
const ui::Layer* layer) {
const views::View* v = FirstView(view);
const ui::Layer* l = FirstLayer(layer);
while (v && l) {
// Find the view with a layer.
while (v && !v->layer())
v = NextView(v);
EXPECT_TRUE(v);
if (!v)
return false;
// Check if the View tree and the Layer tree are in sync.
EXPECT_EQ(l, v->layer());
if (v->layer() != l)
return false;
// Check if the visibility states of the View and the Layer are in sync.
EXPECT_EQ(l->IsDrawn(), v->IsDrawn());
if (v->IsDrawn() != l->IsDrawn()) {
for (const views::View* vv = v; vv; vv = vv->parent())
LOG(ERROR) << "V: " << vv << " " << vv->visible() << " "
<< vv->IsDrawn() << " " << vv->layer();
for (const ui::Layer* ll = l; ll; ll = ll->parent())
LOG(ERROR) << "L: " << ll << " " << ll->IsDrawn();
return false;
}
// Check if the size of the View and the Layer are in sync.
EXPECT_EQ(l->bounds(), v->bounds());
if (v->bounds() != l->bounds())
return false;
if (v == view || l == layer)
return v == view && l == layer;
v = NextView(v);
l = NextLayer(l);
}
return false;
}
// Constructs a View tree with the specified depth.
void ConstructTree(views::View* view, int depth) {
if (depth == 0)
return;
int count = base::RandInt(1, 5);
for (int i = 0; i < count; i++) {
views::View* v = new views::View;
view->AddChildView(v);
if (base::RandDouble() > 0.5)
v->SetPaintToLayer(true);
if (base::RandDouble() < 0.2)
v->SetVisible(false);
ConstructTree(v, depth - 1);
}
}
void ScrambleTree(views::View* view) {
int count = view->child_count();
if (count == 0)
return;
for (int i = 0; i < count; i++) {
ScrambleTree(view->child_at(i));
}
if (count > 1) {
int a = base::RandInt(0, count - 1);
int b = base::RandInt(0, count - 1);
views::View* view_a = view->child_at(a);
views::View* view_b = view->child_at(b);
view->ReorderChildView(view_a, b);
view->ReorderChildView(view_b, a);
}
if (!view->layer() && base::RandDouble() < 0.1)
view->SetPaintToLayer(true);
if (base::RandDouble() < 0.1)
view->SetVisible(!view->visible());
}
// Convenience to make constructing a GestureEvent simpler.
class GestureEventForTest : public ui::GestureEvent {
public:
GestureEventForTest(ui::EventType type, int x, int y, int flags)
: GestureEvent(type, x, y, flags, base::TimeDelta(),
ui::GestureEventDetails(type, 0.0f, 0.0f), 0) {
}
private:
DISALLOW_COPY_AND_ASSIGN(GestureEventForTest);
};
} // namespace
namespace views {
typedef ViewsTestBase ViewTest;
// A derived class for testing purpose.
class TestView : public View {
public:
TestView() : View(), delete_on_pressed_(false), native_theme_(NULL) {}
virtual ~TestView() {}
// Reset all test state
void Reset() {
did_change_bounds_ = false;
last_mouse_event_type_ = 0;
location_.SetPoint(0, 0);
received_mouse_enter_ = false;
received_mouse_exit_ = false;
last_gesture_event_type_ = 0;
last_gesture_event_was_handled_ = false;
last_clip_.setEmpty();
accelerator_count_map_.clear();
}
// Exposed as public for testing.
void DoFocus() {
views::View::Focus();
}
void DoBlur() {
views::View::Blur();
}
bool focusable() const { return View::focusable(); }
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
// Ignores GestureEvent by default.
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set) OVERRIDE;
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual void OnNativeThemeChanged(const ui::NativeTheme* native_theme)
OVERRIDE;
// OnBoundsChanged.
bool did_change_bounds_;
gfx::Rect new_bounds_;
// MouseEvent.
int last_mouse_event_type_;
gfx::Point location_;
bool received_mouse_enter_;
bool received_mouse_exit_;
bool delete_on_pressed_;
// Painting.
std::vector<gfx::Rect> scheduled_paint_rects_;
// GestureEvent
int last_gesture_event_type_;
bool last_gesture_event_was_handled_;
// Painting.
SkRect last_clip_;
// Accelerators.
std::map<ui::Accelerator, int> accelerator_count_map_;
// Native theme.
const ui::NativeTheme* native_theme_;
};
// A view subclass that consumes all Gesture events for testing purposes.
class TestViewConsumeGesture : public TestView {
public:
TestViewConsumeGesture() : TestView() {}
virtual ~TestViewConsumeGesture() {}
protected:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
last_gesture_event_type_ = event->type();
location_.SetPoint(event->x(), event->y());
event->StopPropagation();
}
private:
DISALLOW_COPY_AND_ASSIGN(TestViewConsumeGesture);
};
// A view subclass that ignores all Gesture events.
class TestViewIgnoreGesture: public TestView {
public:
TestViewIgnoreGesture() : TestView() {}
virtual ~TestViewIgnoreGesture() {}
private:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
}
DISALLOW_COPY_AND_ASSIGN(TestViewIgnoreGesture);
};
// A view subclass that ignores all scroll-gesture events, but consume all other
// gesture events.
class TestViewIgnoreScrollGestures : public TestViewConsumeGesture {
public:
TestViewIgnoreScrollGestures() {}
virtual ~TestViewIgnoreScrollGestures() {}
private:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
if (event->IsScrollGestureEvent())
return;
TestViewConsumeGesture::OnGestureEvent(event);
}
DISALLOW_COPY_AND_ASSIGN(TestViewIgnoreScrollGestures);
};
////////////////////////////////////////////////////////////////////////////////
// OnBoundsChanged
////////////////////////////////////////////////////////////////////////////////
void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
did_change_bounds_ = true;
new_bounds_ = bounds();
}
TEST_F(ViewTest, OnBoundsChanged) {
TestView v;
gfx::Rect prev_rect(0, 0, 200, 200);
gfx::Rect new_rect(100, 100, 250, 250);
v.SetBoundsRect(prev_rect);
v.Reset();
v.SetBoundsRect(new_rect);
EXPECT_TRUE(v.did_change_bounds_);
EXPECT_EQ(v.new_bounds_, new_rect);
EXPECT_EQ(v.bounds(), new_rect);
}
////////////////////////////////////////////////////////////////////////////////
// MouseEvent
////////////////////////////////////////////////////////////////////////////////
bool TestView::OnMousePressed(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
if (delete_on_pressed_)
delete this;
return true;
}
bool TestView::OnMouseDragged(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
return true;
}
void TestView::OnMouseReleased(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
}
void TestView::OnMouseEntered(const ui::MouseEvent& event) {
received_mouse_enter_ = true;
}
void TestView::OnMouseExited(const ui::MouseEvent& event) {
received_mouse_exit_ = true;
}
TEST_F(ViewTest, MouseEvent) {
TestView* v1 = new TestView();
v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
TestView* v2 = new TestView();
v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100));
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
internal::RootView* root =
static_cast<internal::RootView*>(widget->GetRootView());
root->AddChildView(v1);
v1->AddChildView(v2);
v1->Reset();
v2->Reset();
gfx::Point p1(110, 120);
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(pressed);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED);
EXPECT_EQ(v2->location_.x(), 10);
EXPECT_EQ(v2->location_.y(), 20);
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_mouse_event_type_, 0);
// Drag event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
gfx::Point p2(50, 40);
ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2,
ui::EF_LEFT_MOUSE_BUTTON, 0);
root->OnMouseDragged(dragged);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED);
EXPECT_EQ(v2->location_.x(), -50);
EXPECT_EQ(v2->location_.y(), -60);
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_mouse_event_type_, 0);
// Releasted event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0,
0);
root->OnMouseDragged(released);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED);
EXPECT_EQ(v2->location_.x(), -100);
EXPECT_EQ(v2->location_.y(), -100);
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_mouse_event_type_, 0);
widget->CloseNow();
}
// Confirm that a view can be deleted as part of processing a mouse press.
TEST_F(ViewTest, DeleteOnPressed) {
TestView* v1 = new TestView();
v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
TestView* v2 = new TestView();
v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100));
v1->Reset();
v2->Reset();
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
View* root = widget->GetRootView();
root->AddChildView(v1);
v1->AddChildView(v2);
v2->delete_on_pressed_ = true;
gfx::Point point(110, 120);
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(pressed);
EXPECT_EQ(0, v1->child_count());
widget->CloseNow();
}
////////////////////////////////////////////////////////////////////////////////
// GestureEvent
////////////////////////////////////////////////////////////////////////////////
void TestView::OnGestureEvent(ui::GestureEvent* event) {
}
TEST_F(ViewTest, GestureEvent) {
// Views hierarchy for non delivery of GestureEvent.
TestView* v1 = new TestViewConsumeGesture();
v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
TestView* v2 = new TestViewConsumeGesture();
v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100));
TestView* v3 = new TestViewIgnoreGesture();
v3->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
scoped_ptr<Widget> widget(new Widget());
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
internal::RootView* root =
static_cast<internal::RootView*>(widget->GetRootView());
ui::EventDispatchDetails details;
root->AddChildView(v1);
v1->AddChildView(v2);
v2->AddChildView(v3);
// |v3| completely obscures |v2|, but all the gesture events on |v3| should
// reach |v2| because |v3| doesn't process any gesture events. However, since
// |v2| does process gesture events, gesture events on |v3| or |v2| should not
// reach |v1|.
v1->Reset();
v2->Reset();
v3->Reset();
// Gesture on |v3|
GestureEventForTest g1(ui::ET_GESTURE_TAP, 110, 110, 0);
details = root->OnEventFromSource(&g1);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_);
EXPECT_EQ(gfx::Point(10, 10), v2->location_);
EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_);
// Simulate an up so that RootView is no longer targetting |v3|.
GestureEventForTest g1_up(ui::ET_GESTURE_END, 110, 110, 0);
details = root->OnEventFromSource(&g1_up);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
v1->Reset();
v2->Reset();
v3->Reset();
// Gesture on |v1|
GestureEventForTest g2(ui::ET_GESTURE_TAP, 80, 80, 0);
details = root->OnEventFromSource(&g2);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
EXPECT_EQ(gfx::Point(80, 80), v1->location_);
EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_);
// Send event |g1| again. Even though the coordinates target |v3| it should go
// to |v1| as that is the view the touch was initially down on.
v1->last_gesture_event_type_ = ui::ET_UNKNOWN;
v3->last_gesture_event_type_ = ui::ET_UNKNOWN;
details = root->OnEventFromSource(&g1);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
EXPECT_EQ(ui::ET_UNKNOWN, v3->last_gesture_event_type_);
EXPECT_EQ("110,110", v1->location_.ToString());
widget->CloseNow();
}
TEST_F(ViewTest, ScrollGestureEvent) {
// Views hierarchy for non delivery of GestureEvent.
TestView* v1 = new TestViewConsumeGesture();
v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
TestView* v2 = new TestViewIgnoreScrollGestures();
v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100));
TestView* v3 = new TestViewIgnoreGesture();
v3->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
scoped_ptr<Widget> widget(new Widget());
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
internal::RootView* root =
static_cast<internal::RootView*>(widget->GetRootView());
ui::EventDispatchDetails details;
root->AddChildView(v1);
v1->AddChildView(v2);
v2->AddChildView(v3);
// |v3| completely obscures |v2|, but all the gesture events on |v3| should
// reach |v2| because |v3| doesn't process any gesture events. However, since
// |v2| does process gesture events, gesture events on |v3| or |v2| should not
// reach |v1|.
v1->Reset();
v2->Reset();
v3->Reset();
// Gesture on |v3|
GestureEventForTest g1(ui::ET_GESTURE_TAP, 110, 110, 0);
details = root->OnEventFromSource(&g1);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_);
EXPECT_EQ(gfx::Point(10, 10), v2->location_);
EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_);
v2->Reset();
// Send scroll gestures on |v3|. The gesture should reach |v2|, however,
// since it does not process scroll-gesture events, these events should reach
// |v1|.
GestureEventForTest gscroll_begin(ui::ET_GESTURE_SCROLL_BEGIN, 115, 115, 0);
details = root->OnEventFromSource(&gscroll_begin);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_);
EXPECT_EQ(ui::ET_GESTURE_SCROLL_BEGIN, v1->last_gesture_event_type_);
v1->Reset();
// Send a second tap on |v1|. The event should reach |v2| since it is the
// default gesture handler, and not |v1| (even though it is the view under the
// point, and is the scroll event handler).
GestureEventForTest second_tap(ui::ET_GESTURE_TAP, 70, 70, 0);
details = root->OnEventFromSource(&second_tap);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_);
EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_);
v2->Reset();
GestureEventForTest gscroll_end(ui::ET_GESTURE_SCROLL_END, 50, 50, 0);
details = root->OnEventFromSource(&gscroll_end);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_SCROLL_END, v1->last_gesture_event_type_);
v1->Reset();
// Simulate an up so that RootView is no longer targetting |v3|.
GestureEventForTest g1_up(ui::ET_GESTURE_END, 110, 110, 0);
details = root->OnEventFromSource(&g1_up);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_END, v2->last_gesture_event_type_);
v1->Reset();
v2->Reset();
v3->Reset();
// Gesture on |v1|
GestureEventForTest g2(ui::ET_GESTURE_TAP, 80, 80, 0);
details = root->OnEventFromSource(&g2);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
EXPECT_EQ(gfx::Point(80, 80), v1->location_);
EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_);
// Send event |g1| again. Even though the coordinates target |v3| it should go
// to |v1| as that is the view the touch was initially down on.
v1->last_gesture_event_type_ = ui::ET_UNKNOWN;
v3->last_gesture_event_type_ = ui::ET_UNKNOWN;
details = root->OnEventFromSource(&g1);
EXPECT_FALSE(details.dispatcher_destroyed);
EXPECT_FALSE(details.target_destroyed);
EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
EXPECT_EQ(ui::ET_UNKNOWN, v3->last_gesture_event_type_);
EXPECT_EQ("110,110", v1->location_.ToString());
widget->CloseNow();
}
////////////////////////////////////////////////////////////////////////////////
// Painting
////////////////////////////////////////////////////////////////////////////////
void TestView::Paint(gfx::Canvas* canvas, const CullSet& cull_set) {
canvas->sk_canvas()->getClipBounds(&last_clip_);
}
void TestView::SchedulePaintInRect(const gfx::Rect& rect) {
scheduled_paint_rects_.push_back(rect);
View::SchedulePaintInRect(rect);
}
void CheckRect(const SkRect& check_rect, const SkRect& target_rect) {
EXPECT_EQ(target_rect.fLeft, check_rect.fLeft);
EXPECT_EQ(target_rect.fRight, check_rect.fRight);
EXPECT_EQ(target_rect.fTop, check_rect.fTop);
EXPECT_EQ(target_rect.fBottom, check_rect.fBottom);
}
TEST_F(ViewTest, RemoveNotification) {
ViewStorage* vs = ViewStorage::GetInstance();
Widget* widget = new Widget;
widget->Init(CreateParams(Widget::InitParams::TYPE_POPUP));
View* root_view = widget->GetRootView();
View* v1 = new View;
int s1 = vs->CreateStorageID();
vs->StoreView(s1, v1);
root_view->AddChildView(v1);
View* v11 = new View;
int s11 = vs->CreateStorageID();
vs->StoreView(s11, v11);
v1->AddChildView(v11);
View* v111 = new View;
int s111 = vs->CreateStorageID();
vs->StoreView(s111, v111);
v11->AddChildView(v111);
View* v112 = new View;
int s112 = vs->CreateStorageID();
vs->StoreView(s112, v112);
v11->AddChildView(v112);
View* v113 = new View;
int s113 = vs->CreateStorageID();
vs->StoreView(s113, v113);
v11->AddChildView(v113);
View* v1131 = new View;
int s1131 = vs->CreateStorageID();
vs->StoreView(s1131, v1131);
v113->AddChildView(v1131);
View* v12 = new View;
int s12 = vs->CreateStorageID();
vs->StoreView(s12, v12);
v1->AddChildView(v12);
View* v2 = new View;
int s2 = vs->CreateStorageID();
vs->StoreView(s2, v2);
root_view->AddChildView(v2);
View* v21 = new View;
int s21 = vs->CreateStorageID();
vs->StoreView(s21, v21);
v2->AddChildView(v21);
View* v211 = new View;
int s211 = vs->CreateStorageID();
vs->StoreView(s211, v211);
v21->AddChildView(v211);
size_t stored_views = vs->view_count();
// Try removing a leaf view.
v21->RemoveChildView(v211);
EXPECT_EQ(stored_views - 1, vs->view_count());
EXPECT_EQ(NULL, vs->RetrieveView(s211));
delete v211; // We won't use this one anymore.
// Now try removing a view with a hierarchy of depth 1.
v11->RemoveChildView(v113);
EXPECT_EQ(stored_views - 3, vs->view_count());
EXPECT_EQ(NULL, vs->RetrieveView(s113));
EXPECT_EQ(NULL, vs->RetrieveView(s1131));
delete v113; // We won't use this one anymore.
// Now remove even more.
root_view->RemoveChildView(v1);
EXPECT_EQ(NULL, vs->RetrieveView(s1));
EXPECT_EQ(NULL, vs->RetrieveView(s11));
EXPECT_EQ(NULL, vs->RetrieveView(s12));
EXPECT_EQ(NULL, vs->RetrieveView(s111));
EXPECT_EQ(NULL, vs->RetrieveView(s112));
// Put v1 back for more tests.
root_view->AddChildView(v1);
vs->StoreView(s1, v1);
// Synchronously closing the window deletes the view hierarchy, which should
// remove all its views from ViewStorage.
widget->CloseNow();
EXPECT_EQ(stored_views - 10, vs->view_count());
EXPECT_EQ(NULL, vs->RetrieveView(s1));
EXPECT_EQ(NULL, vs->RetrieveView(s12));
EXPECT_EQ(NULL, vs->RetrieveView(s11));
EXPECT_EQ(NULL, vs->RetrieveView(s12));
EXPECT_EQ(NULL, vs->RetrieveView(s21));
EXPECT_EQ(NULL, vs->RetrieveView(s111));
EXPECT_EQ(NULL, vs->RetrieveView(s112));
}
namespace {
class HitTestView : public View {
public:
explicit HitTestView(bool has_hittest_mask)
: has_hittest_mask_(has_hittest_mask) {
}
virtual ~HitTestView() {}
protected:
// Overridden from View:
virtual bool HasHitTestMask() const OVERRIDE {
return has_hittest_mask_;
}
virtual void GetHitTestMask(HitTestSource source,
gfx::Path* mask) const OVERRIDE {
DCHECK(has_hittest_mask_);
DCHECK(mask);
SkScalar w = SkIntToScalar(width());
SkScalar h = SkIntToScalar(height());
// Create a triangular mask within the bounds of this View.
mask->moveTo(w / 2, 0);
mask->lineTo(w, h);
mask->lineTo(0, h);
mask->close();
}
private:
bool has_hittest_mask_;
DISALLOW_COPY_AND_ASSIGN(HitTestView);
};
gfx::Point ConvertPointToView(View* view, const gfx::Point& p) {
gfx::Point tmp(p);
View::ConvertPointToTarget(view->GetWidget()->GetRootView(), view, &tmp);
return tmp;
}
gfx::Rect ConvertRectToView(View* view, const gfx::Rect& r) {
gfx::Rect tmp(r);
tmp.set_origin(ConvertPointToView(view, r.origin()));
return tmp;
}
void RotateCounterclockwise(gfx::Transform* transform) {
transform->matrix().set3x3(0, -1, 0,
1, 0, 0,
0, 0, 1);
}
void RotateClockwise(gfx::Transform* transform) {
transform->matrix().set3x3( 0, 1, 0,
-1, 0, 0,
0, 0, 1);
}
} // namespace
TEST_F(ViewTest, HitTestMasks) {
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
widget->Init(params);
View* root_view = widget->GetRootView();
root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
gfx::Rect v1_bounds = gfx::Rect(0, 0, 100, 100);
HitTestView* v1 = new HitTestView(false);
v1->SetBoundsRect(v1_bounds);
root_view->AddChildView(v1);
gfx::Rect v2_bounds = gfx::Rect(105, 0, 100, 100);
HitTestView* v2 = new HitTestView(true);
v2->SetBoundsRect(v2_bounds);
root_view->AddChildView(v2);
gfx::Point v1_centerpoint = v1_bounds.CenterPoint();
gfx::Point v2_centerpoint = v2_bounds.CenterPoint();
gfx::Point v1_origin = v1_bounds.origin();
gfx::Point v2_origin = v2_bounds.origin();
gfx::Rect r1(10, 10, 110, 15);
gfx::Rect r2(106, 1, 98, 98);
gfx::Rect r3(0, 0, 300, 300);
gfx::Rect r4(115, 342, 200, 10);
// Test HitTestPoint
EXPECT_TRUE(v1->HitTestPoint(ConvertPointToView(v1, v1_centerpoint)));
EXPECT_TRUE(v2->HitTestPoint(ConvertPointToView(v2, v2_centerpoint)));
EXPECT_TRUE(v1->HitTestPoint(ConvertPointToView(v1, v1_origin)));
EXPECT_FALSE(v2->HitTestPoint(ConvertPointToView(v2, v2_origin)));
// Test HitTestRect
EXPECT_TRUE(v1->HitTestRect(ConvertRectToView(v1, r1)));
EXPECT_FALSE(v2->HitTestRect(ConvertRectToView(v2, r1)));
EXPECT_FALSE(v1->HitTestRect(ConvertRectToView(v1, r2)));
EXPECT_TRUE(v2->HitTestRect(ConvertRectToView(v2, r2)));
EXPECT_TRUE(v1->HitTestRect(ConvertRectToView(v1, r3)));
EXPECT_TRUE(v2->HitTestRect(ConvertRectToView(v2, r3)));
EXPECT_FALSE(v1->HitTestRect(ConvertRectToView(v1, r4)));
EXPECT_FALSE(v2->HitTestRect(ConvertRectToView(v2, r4)));
// Test GetEventHandlerForPoint
EXPECT_EQ(v1, root_view->GetEventHandlerForPoint(v1_centerpoint));
EXPECT_EQ(v2, root_view->GetEventHandlerForPoint(v2_centerpoint));
EXPECT_EQ(v1, root_view->GetEventHandlerForPoint(v1_origin));
EXPECT_EQ(root_view, root_view->GetEventHandlerForPoint(v2_origin));
// Test GetTooltipHandlerForPoint
EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_centerpoint));
EXPECT_EQ(v2, root_view->GetTooltipHandlerForPoint(v2_centerpoint));
EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin));
EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin));
EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin));
widget->CloseNow();
}
// Tests the correctness of the rect-based targeting algorithm implemented in
// View::GetEventHandlerForRect(). See http://goo.gl/3Jp2BD for a description
// of rect-based targeting.
TEST_F(ViewTest, GetEventHandlerForRect) {
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
widget->Init(params);
View* root_view = widget->GetRootView();
root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
// Have this hierarchy of views (the coordinates here are all in
// the root view's coordinate space):
// v1 (0, 0, 100, 100)
// v2 (150, 0, 250, 100)
// v3 (0, 200, 150, 100)
// v31 (10, 210, 80, 80)
// v32 (110, 210, 30, 80)
// v4 (300, 200, 100, 100)
// v41 (310, 210, 80, 80)
// v411 (370, 275, 10, 5)
// v5 (450, 197, 30, 36)
// v51 (450, 200, 30, 30)
// The coordinates used for SetBounds are in parent coordinates.
TestView* v1 = new TestView;
v1->SetBounds(0, 0, 100, 100);
root_view->AddChildView(v1);
TestView* v2 = new TestView;
v2->SetBounds(150, 0, 250, 100);
root_view->AddChildView(v2);
TestView* v3 = new TestView;
v3->SetBounds(0, 200, 150, 100);
root_view->AddChildView(v3);
TestView* v4 = new TestView;
v4->SetBounds(300, 200, 100, 100);
root_view->AddChildView(v4);
TestView* v31 = new TestView;
v31->SetBounds(10, 10, 80, 80);
v3->AddChildView(v31);
TestView* v32 = new TestView;
v32->SetBounds(110, 10, 30, 80);
v3->AddChildView(v32);
TestView* v41 = new TestView;
v41->SetBounds(10, 10, 80, 80);
v4->AddChildView(v41);
TestView* v411 = new TestView;
v411->SetBounds(60, 65, 10, 5);
v41->AddChildView(v411);
TestView* v5 = new TestView;
v5->SetBounds(450, 197, 30, 36);
root_view->AddChildView(v5);
TestView* v51 = new TestView;
v51->SetBounds(0, 3, 30, 30);
v5->AddChildView(v51);
// |touch_rect| does not intersect any descendant view of |root_view|.
gfx::Rect touch_rect(105, 105, 30, 45);
View* result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(root_view, result_view);
result_view = NULL;
// Covers |v1| by at least 60%.
touch_rect.SetRect(15, 15, 100, 100);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v1, result_view);
result_view = NULL;
// Intersects |v1| but does not cover it by at least 60%. The center
// of |touch_rect| is within |v1|.
touch_rect.SetRect(50, 50, 5, 10);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v1, result_view);
result_view = NULL;
// Intersects |v1| but does not cover it by at least 60%. The center
// of |touch_rect| is not within |v1|.
touch_rect.SetRect(95, 96, 21, 22);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(root_view, result_view);
result_view = NULL;
// Intersects |v1| and |v2|, but only covers |v2| by at least 60%.
touch_rect.SetRect(95, 10, 300, 120);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v2, result_view);
result_view = NULL;
// Covers both |v1| and |v2| by at least 60%, but the center point
// of |touch_rect| is closer to the center point of |v2|.
touch_rect.SetRect(20, 20, 400, 100);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v2, result_view);
result_view = NULL;
// Covers both |v1| and |v2| by at least 60%, but the center point
// of |touch_rect| is closer to the center point of |v1|.
touch_rect.SetRect(-700, -15, 1050, 110);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v1, result_view);
result_view = NULL;
// A mouse click within |v1| will target |v1|.
touch_rect.SetRect(15, 15, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v1, result_view);
result_view = NULL;
// Intersects |v3| and |v31| by at least 60% and the center point
// of |touch_rect| is closer to the center point of |v31|.
touch_rect.SetRect(0, 200, 110, 100);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v31, result_view);
result_view = NULL;
// Intersects |v3| and |v31|, but neither by at least 60%. The
// center point of |touch_rect| lies within |v31|.
touch_rect.SetRect(80, 280, 15, 15);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v31, result_view);
result_view = NULL;
// Covers |v3|, |v31|, and |v32| all by at least 60%, and the
// center point of |touch_rect| is closest to the center point
// of |v32|.
touch_rect.SetRect(0, 200, 200, 100);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v32, result_view);
result_view = NULL;
// Intersects all of |v3|, |v31|, and |v32|, but only covers
// |v31| and |v32| by at least 60%. The center point of
// |touch_rect| is closest to the center point of |v32|.
touch_rect.SetRect(30, 225, 180, 115);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v32, result_view);
result_view = NULL;
// A mouse click at the corner of |v3| will target |v3|.
touch_rect.SetRect(0, 200, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v3, result_view);
result_view = NULL;
// A mouse click within |v32| will target |v32|.
touch_rect.SetRect(112, 211, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v32, result_view);
result_view = NULL;
// Covers all of |v4|, |v41|, and |v411| by at least 60%.
// The center point of |touch_rect| is equally close to
// the center points of |v4| and |v41|.
touch_rect.SetRect(310, 210, 80, 80);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v41, result_view);
result_view = NULL;
// Intersects all of |v4|, |v41|, and |v411| but only covers
// |v411| by at least 60%.
touch_rect.SetRect(370, 275, 7, 5);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v411, result_view);
result_view = NULL;
// Intersects |v4| and |v41| but covers neither by at least 60%.
// The center point of |touch_rect| is equally close to the center
// points of |v4| and |v41|.
touch_rect.SetRect(345, 245, 7, 7);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v41, result_view);
result_view = NULL;
// Intersects all of |v4|, |v41|, and |v411| and covers none of
// them by at least 60%. The center point of |touch_rect| lies
// within |v411|.
touch_rect.SetRect(368, 272, 4, 6);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v411, result_view);
result_view = NULL;
// Intersects all of |v4|, |v41|, and |v411| and covers none of
// them by at least 60%. The center point of |touch_rect| lies
// within |v41|.
touch_rect.SetRect(365, 270, 7, 7);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v41, result_view);
result_view = NULL;
// Intersects all of |v4|, |v41|, and |v411| and covers none of
// them by at least 60%. The center point of |touch_rect| lies
// within |v4|.
touch_rect.SetRect(205, 275, 200, 2);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v4, result_view);
result_view = NULL;
// Intersects all of |v4|, |v41|, and |v411| but only covers
// |v41| by at least 60%.
touch_rect.SetRect(310, 210, 61, 66);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v41, result_view);
result_view = NULL;
// A mouse click within |v411| will target |v411|.
touch_rect.SetRect(372, 275, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v411, result_view);
result_view = NULL;
// A mouse click within |v41| will target |v41|.
touch_rect.SetRect(350, 215, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v41, result_view);
result_view = NULL;
// Covers |v3|, |v4|, and all of their descendants by at
// least 60%. The center point of |touch_rect| is closest
// to the center point of |v32|.
touch_rect.SetRect(0, 200, 400, 100);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v32, result_view);
result_view = NULL;
// Intersects all of |v2|, |v3|, |v32|, |v4|, |v41|, and |v411|.
// Covers |v2|, |v32|, |v4|, |v41|, and |v411| by at least 60%.
// The center point of |touch_rect| is closest to the center
// point of |root_view|.
touch_rect.SetRect(110, 15, 375, 450);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(root_view, result_view);
result_view = NULL;
// Covers all views (except |v5| and |v51|) by at least 60%. The
// center point of |touch_rect| is equally close to the center
// points of |v2| and |v32|. One is not a descendant of the other,
// so in this case the view selected is arbitrary (i.e.,
// it depends only on the ordering of nodes in the views
// hierarchy).
touch_rect.SetRect(0, 0, 400, 300);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v32, result_view);
result_view = NULL;
// Covers |v5| and |v51| by at least 60%, and the center point of
// the touch is located within both views. Since both views share
// the same center point, the child view should be selected.
touch_rect.SetRect(440, 190, 40, 40);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v51, result_view);
result_view = NULL;
// Covers |v5| and |v51| by at least 60%, but the center point of
// the touch is not located within either view. Since both views
// share the same center point, the child view should be selected.
touch_rect.SetRect(455, 187, 60, 60);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v51, result_view);
result_view = NULL;
// Covers neither |v5| nor |v51| by at least 60%, but the center
// of the touch is located within |v51|.
touch_rect.SetRect(450, 197, 10, 10);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v51, result_view);
result_view = NULL;
// Covers neither |v5| nor |v51| by at least 60% but intersects both.
// The center point is located outside of both views.
touch_rect.SetRect(433, 180, 24, 24);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(root_view, result_view);
result_view = NULL;
// Only intersects |v5| but does not cover it by at least 60%. The
// center point of the touch region is located within |v5|.
touch_rect.SetRect(449, 196, 3, 3);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v5, result_view);
result_view = NULL;
// A mouse click within |v5| (but not |v51|) should target |v5|.
touch_rect.SetRect(462, 199, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v5, result_view);
result_view = NULL;
// A mouse click |v5| and |v51| should target the child view.
touch_rect.SetRect(452, 226, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v51, result_view);
result_view = NULL;
// A mouse click on the center of |v5| and |v51| should target
// the child view.
touch_rect.SetRect(465, 215, 1, 1);
result_view = root_view->GetEventHandlerForRect(touch_rect);
EXPECT_EQ(v51, result_view);
result_view = NULL;
widget->CloseNow();
}
TEST_F(ViewTest, NotifyEnterExitOnChild) {
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
widget->Init(params);
View* root_view = widget->GetRootView();
root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
// Have this hierarchy of views (the coords here are in root coord):
// v1 (0, 0, 100, 100)
// - v11 (0, 0, 20, 30)
// - v111 (5, 5, 5, 15)
// - v12 (50, 10, 30, 90)
// - v121 (60, 20, 10, 10)
// v2 (105, 0, 100, 100)
// - v21 (120, 10, 50, 20)
TestView* v1 = new TestView;
v1->SetBounds(0, 0, 100, 100);
root_view->AddChildView(v1);
v1->set_notify_enter_exit_on_child(true);
TestView* v11 = new TestView;
v11->SetBounds(0, 0, 20, 30);
v1->AddChildView(v11);
TestView* v111 = new TestView;
v111->SetBounds(5, 5, 5, 15);
v11->AddChildView(v111);
TestView* v12 = new TestView;
v12->SetBounds(50, 10, 30, 90);
v1->AddChildView(v12);
TestView* v121 = new TestView;
v121->SetBounds(10, 10, 10, 10);
v12->AddChildView(v121);
TestView* v2 = new TestView;
v2->SetBounds(105, 0, 100, 100);
root_view->AddChildView(v2);
TestView* v21 = new TestView;
v21->SetBounds(15, 10, 50, 20);
v2->AddChildView(v21);
v1->Reset();
v11->Reset();
v111->Reset();
v12->Reset();
v121->Reset();
v2->Reset();
v21->Reset();
// Move the mouse in v111.
gfx::Point p1(6, 6);
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, 0, 0);
root_view->OnMouseMoved(move1);
EXPECT_TRUE(v111->received_mouse_enter_);
EXPECT_FALSE(v11->last_mouse_event_type_);
EXPECT_TRUE(v1->received_mouse_enter_);
v111->Reset();
v1->Reset();
// Now, move into v121.
gfx::Point p2(65, 21);
ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, 0, 0);
root_view->OnMouseMoved(move2);
EXPECT_TRUE(v111->received_mouse_exit_);
EXPECT_TRUE(v121->received_mouse_enter_);
EXPECT_FALSE(v1->last_mouse_event_type_);
v111->Reset();
v121->Reset();
// Now, move into v11.
gfx::Point p3(1, 1);
ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, 0, 0);
root_view->OnMouseMoved(move3);
EXPECT_TRUE(v121->received_mouse_exit_);
EXPECT_TRUE(v11->received_mouse_enter_);
EXPECT_FALSE(v1->last_mouse_event_type_);
v121->Reset();
v11->Reset();
// Move to v21.
gfx::Point p4(121, 15);
ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, 0, 0);
root_view->OnMouseMoved(move4);
EXPECT_TRUE(v21->received_mouse_enter_);
EXPECT_FALSE(v2->last_mouse_event_type_);
EXPECT_TRUE(v11->received_mouse_exit_);
EXPECT_TRUE(v1->received_mouse_exit_);
v21->Reset();
v11->Reset();
v1->Reset();
// Move to v1.
gfx::Point p5(21, 0);
ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, 0, 0);
root_view->OnMouseMoved(move5);
EXPECT_TRUE(v21->received_mouse_exit_);
EXPECT_TRUE(v1->received_mouse_enter_);
v21->Reset();
v1->Reset();
// Now, move into v11.
gfx::Point p6(15, 15);
ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, 0, 0);
root_view->OnMouseMoved(mouse6);
EXPECT_TRUE(v11->received_mouse_enter_);
EXPECT_FALSE(v1->last_mouse_event_type_);
v11->Reset();
v1->Reset();
// Move back into v1. Although |v1| had already received an ENTER for mouse6,
// and the mouse remains inside |v1| the whole time, it receives another ENTER
// when the mouse leaves v11.
gfx::Point p7(21, 0);
ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0, 0);
root_view->OnMouseMoved(mouse7);
EXPECT_TRUE(v11->received_mouse_exit_);
EXPECT_FALSE(v1->received_mouse_enter_);
widget->CloseNow();
}
TEST_F(ViewTest, Textfield) {
const base::string16 kText = ASCIIToUTF16(
"Reality is that which, when you stop believing it, doesn't go away.");
const base::string16 kExtraText = ASCIIToUTF16("Pretty deep, Philip!");
const base::string16 kEmptyString;
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
View* root_view = widget->GetRootView();
Textfield* textfield = new Textfield();
root_view->AddChildView(textfield);
// Test setting, appending text.
textfield->SetText(kText);
EXPECT_EQ(kText, textfield->text());
textfield->AppendText(kExtraText);
EXPECT_EQ(kText + kExtraText, textfield->text());
textfield->SetText(base::string16());
EXPECT_EQ(kEmptyString, textfield->text());
// Test selection related methods.
textfield->SetText(kText);
EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
textfield->SelectAll(false);
EXPECT_EQ(kText, textfield->text());
textfield->ClearSelection();
EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
widget->CloseNow();
}
// Tests that the Textfield view respond appropiately to cut/copy/paste.
TEST_F(ViewTest, TextfieldCutCopyPaste) {
const base::string16 kNormalText = ASCIIToUTF16("Normal");
const base::string16 kReadOnlyText = ASCIIToUTF16("Read only");
const base::string16 kPasswordText =
ASCIIToUTF16("Password! ** Secret stuff **");
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
View* root_view = widget->GetRootView();
Textfield* normal = new Textfield();
Textfield* read_only = new Textfield();
read_only->SetReadOnly(true);
Textfield* password = new Textfield();
password->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
root_view->AddChildView(normal);
root_view->AddChildView(read_only);
root_view->AddChildView(password);
normal->SetText(kNormalText);
read_only->SetText(kReadOnlyText);
password->SetText(kPasswordText);
//
// Test cut.
//
normal->SelectAll(false);
normal->ExecuteCommand(IDS_APP_CUT);
base::string16 result;
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
EXPECT_EQ(kNormalText, result);
normal->SetText(kNormalText); // Let's revert to the original content.
read_only->SelectAll(false);
read_only->ExecuteCommand(IDS_APP_CUT);
result.clear();
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
// Cut should have failed, so the clipboard content should not have changed.
EXPECT_EQ(kNormalText, result);
password->SelectAll(false);
password->ExecuteCommand(IDS_APP_CUT);
result.clear();
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
// Cut should have failed, so the clipboard content should not have changed.
EXPECT_EQ(kNormalText, result);
//
// Test copy.
//
// Start with |read_only| to observe a change in clipboard text.
read_only->SelectAll(false);
read_only->ExecuteCommand(IDS_APP_COPY);
result.clear();
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
EXPECT_EQ(kReadOnlyText, result);
normal->SelectAll(false);
normal->ExecuteCommand(IDS_APP_COPY);
result.clear();
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
EXPECT_EQ(kNormalText, result);
password->SelectAll(false);
password->ExecuteCommand(IDS_APP_COPY);
result.clear();
clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
// Text cannot be copied from an obscured field; the clipboard won't change.
EXPECT_EQ(kNormalText, result);
//
// Test paste.
//
// Attempting to paste kNormalText in a read-only text-field should fail.
read_only->SelectAll(false);
read_only->ExecuteCommand(IDS_APP_PASTE);
EXPECT_EQ(kReadOnlyText, read_only->text());
password->SelectAll(false);
password->ExecuteCommand(IDS_APP_PASTE);
EXPECT_EQ(kNormalText, password->text());
// Copy from |read_only| to observe a change in the normal textfield text.
read_only->SelectAll(false);
read_only->ExecuteCommand(IDS_APP_COPY);
normal->SelectAll(false);
normal->ExecuteCommand(IDS_APP_PASTE);
EXPECT_EQ(kReadOnlyText, normal->text());
widget->CloseNow();
}
////////////////////////////////////////////////////////////////////////////////
// Accelerators
////////////////////////////////////////////////////////////////////////////////
bool TestView::AcceleratorPressed(const ui::Accelerator& accelerator) {
accelerator_count_map_[accelerator]++;
return true;
}
// TODO: these tests were initially commented out when getting aura to
// run. Figure out if still valuable and either nuke or fix.
#if defined(false)
TEST_F(ViewTest, ActivateAccelerator) {
// Register a keyboard accelerator before the view is added to a window.
ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
TestView* view = new TestView();
view->Reset();
view->AddAccelerator(return_accelerator);
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
// Create a window and add the view as its child.
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
View* root = widget->GetRootView();
root->AddChildView(view);
widget->Show();
// Get the focus manager.
FocusManager* focus_manager = widget->GetFocusManager();
ASSERT_TRUE(focus_manager);
// Hit the return key and see if it takes effect.
EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
// Hit the escape key. Nothing should happen.
ui::Accelerator escape_accelerator(ui::VKEY_ESCAPE, ui::EF_NONE);
EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 0);
// Now register the escape key and hit it again.
view->AddAccelerator(escape_accelerator);
EXPECT_TRUE(focus_manager->ProcessAccelerator(escape_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
// Remove the return key accelerator.
view->RemoveAccelerator(return_accelerator);
EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
// Add it again. Hit the return key and the escape key.
view->AddAccelerator(return_accelerator);
EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
EXPECT_TRUE(focus_manager->ProcessAccelerator(escape_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
// Remove all the accelerators.
view->ResetAccelerators();
EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator));
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
widget->CloseNow();
}
TEST_F(ViewTest, HiddenViewWithAccelerator) {
ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
TestView* view = new TestView();
view->Reset();
view->AddAccelerator(return_accelerator);
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
View* root = widget->GetRootView();
root->AddChildView(view);
widget->Show();
FocusManager* focus_manager = widget->GetFocusManager();
ASSERT_TRUE(focus_manager);
view->SetVisible(false);
EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
view->SetVisible(true);
EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
widget->CloseNow();
}
TEST_F(ViewTest, ViewInHiddenWidgetWithAccelerator) {
ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
TestView* view = new TestView();
view->Reset();
view->AddAccelerator(return_accelerator);
EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
View* root = widget->GetRootView();
root->AddChildView(view);
FocusManager* focus_manager = widget->GetFocusManager();
ASSERT_TRUE(focus_manager);
EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(0, view->accelerator_count_map_[return_accelerator]);
widget->Show();
EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(1, view->accelerator_count_map_[return_accelerator]);
widget->Hide();
EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
EXPECT_EQ(1, view->accelerator_count_map_[return_accelerator]);
widget->CloseNow();
}
////////////////////////////////////////////////////////////////////////////////
// Mouse-wheel message rerouting
////////////////////////////////////////////////////////////////////////////////
class ScrollableTestView : public View {
public:
ScrollableTestView() { }
virtual gfx::Size GetPreferredSize() {
return gfx::Size(100, 10000);
}
virtual void Layout() {
SizeToPreferredSize();
}
};
class TestViewWithControls : public View {
public:
TestViewWithControls() {
text_field_ = new Textfield();
AddChildView(text_field_);
}
Textfield* text_field_;
};
class SimpleWidgetDelegate : public WidgetDelegate {
public:
explicit SimpleWidgetDelegate(View* contents) : contents_(contents) { }
virtual void DeleteDelegate() { delete this; }
virtual View* GetContentsView() { return contents_; }
virtual Widget* GetWidget() { return contents_->GetWidget(); }
virtual const Widget* GetWidget() const { return contents_->GetWidget(); }
private:
View* contents_;
};
// Tests that the mouse-wheel messages are correctly rerouted to the window
// under the mouse.
// TODO(jcampan): http://crbug.com/10572 Disabled as it fails on the Vista build
// bot.
// Note that this fails for a variety of reasons:
// - focused view is apparently reset across window activations and never
// properly restored
// - this test depends on you not having any other window visible open under the
// area that it opens the test windows. --beng
TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
TestViewWithControls* view_with_controls = new TestViewWithControls();
Widget* window1 = Widget::CreateWindowWithBounds(
new SimpleWidgetDelegate(view_with_controls),
gfx::Rect(0, 0, 100, 100));
window1->Show();
ScrollView* scroll_view = new ScrollView();
scroll_view->SetContents(new ScrollableTestView());
Widget* window2 = Widget::CreateWindowWithBounds(
new SimpleWidgetDelegate(scroll_view),
gfx::Rect(200, 200, 100, 100));
window2->Show();
EXPECT_EQ(0, scroll_view->GetVisibleRect().y());
// Make the window1 active, as this is what it would be in real-world.
window1->Activate();
// Let's send a mouse-wheel message to the different controls and check that
// it is rerouted to the window under the mouse (effectively scrolling the
// scroll-view).
// First to the Window's HWND.
::SendMessage(view_with_controls->GetWidget()->GetNativeView(),
WM_MOUSEWHEEL, MAKEWPARAM(0, -20), MAKELPARAM(250, 250));
EXPECT_EQ(20, scroll_view->GetVisibleRect().y());
window1->CloseNow();
window2->CloseNow();
}
#endif // false
////////////////////////////////////////////////////////////////////////////////
// Native view hierachy
////////////////////////////////////////////////////////////////////////////////
class ToplevelWidgetObserverView : public View {
public:
ToplevelWidgetObserverView() : toplevel_(NULL) {
}
virtual ~ToplevelWidgetObserverView() {
}
// View overrides:
virtual void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) OVERRIDE {
if (details.is_add) {
toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
} else {
toplevel_ = NULL;
}
}
virtual void NativeViewHierarchyChanged() OVERRIDE {
toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
}
Widget* toplevel() { return toplevel_; }
private:
Widget* toplevel_;
DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView);
};
// Test that a view can track the current top level widget by overriding
// View::ViewHierarchyChanged() and View::NativeViewHierarchyChanged().
TEST_F(ViewTest, NativeViewHierarchyChanged) {
scoped_ptr<Widget> toplevel1(new Widget);
Widget::InitParams toplevel1_params =
CreateParams(Widget::InitParams::TYPE_POPUP);
toplevel1_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
toplevel1->Init(toplevel1_params);
scoped_ptr<Widget> toplevel2(new Widget);
Widget::InitParams toplevel2_params =
CreateParams(Widget::InitParams::TYPE_POPUP);
toplevel2_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
toplevel2->Init(toplevel2_params);
Widget* child = new Widget;
Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
child_params.parent = toplevel1->GetNativeView();
child->Init(child_params);
ToplevelWidgetObserverView* observer_view =
new ToplevelWidgetObserverView();
EXPECT_EQ(NULL, observer_view->toplevel());
child->SetContentsView(observer_view);
EXPECT_EQ(toplevel1, observer_view->toplevel());
Widget::ReparentNativeView(child->GetNativeView(),
toplevel2->GetNativeView());
EXPECT_EQ(toplevel2, observer_view->toplevel());
observer_view->parent()->RemoveChildView(observer_view);
EXPECT_EQ(NULL, observer_view->toplevel());
// Make |observer_view| |child|'s contents view again so that it gets deleted
// with the widget.
child->SetContentsView(observer_view);
}
////////////////////////////////////////////////////////////////////////////////
// Transformations
////////////////////////////////////////////////////////////////////////////////
class TransformPaintView : public TestView {
public:
TransformPaintView() {}
virtual ~TransformPaintView() {}
void ClearScheduledPaintRect() {
scheduled_paint_rect_ = gfx::Rect();
}
gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; }
// Overridden from View:
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE {
gfx::Rect xrect = ConvertRectToParent(rect);
scheduled_paint_rect_.Union(xrect);
}
private:
gfx::Rect scheduled_paint_rect_;
DISALLOW_COPY_AND_ASSIGN(TransformPaintView);
};
TEST_F(ViewTest, TransformPaint) {
TransformPaintView* v1 = new TransformPaintView();
v1->SetBoundsRect(gfx::Rect(0, 0, 500, 300));
TestView* v2 = new TestView();
v2->SetBoundsRect(gfx::Rect(100, 100, 200, 100));
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
widget->Show();
View* root = widget->GetRootView();
root->AddChildView(v1);
v1->AddChildView(v2);
// At this moment, |v2| occupies (100, 100) to (300, 200) in |root|.
v1->ClearScheduledPaintRect();
v2->SchedulePaint();
EXPECT_EQ(gfx::Rect(100, 100, 200, 100), v1->scheduled_paint_rect());
// Rotate |v1| counter-clockwise.
gfx::Transform transform;
RotateCounterclockwise(&transform);
transform.matrix().set(1, 3, 500.0);
v1->SetTransform(transform);
// |v2| now occupies (100, 200) to (200, 400) in |root|.
v1->ClearScheduledPaintRect();
v2->SchedulePaint();
EXPECT_EQ(gfx::Rect(100, 200, 100, 200), v1->scheduled_paint_rect());
widget->CloseNow();
}
TEST_F(ViewTest, TransformEvent) {
TestView* v1 = new TestView();
v1->SetBoundsRect(gfx::Rect(0, 0, 500, 300));
TestView* v2 = new TestView();
v2->SetBoundsRect(gfx::Rect(100, 100, 200, 100));
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
View* root = widget->GetRootView();
root->AddChildView(v1);
v1->AddChildView(v2);
// At this moment, |v2| occupies (100, 100) to (300, 200) in |root|.
// Rotate |v1| counter-clockwise.
gfx::Transform transform(v1->GetTransform());
RotateCounterclockwise(&transform);
transform.matrix().set(1, 3, 500.0);
v1->SetTransform(transform);
// |v2| now occupies (100, 200) to (200, 400) in |root|.
v1->Reset();
v2->Reset();
gfx::Point p1(110, 210);
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(pressed);
EXPECT_EQ(0, v1->last_mouse_event_type_);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
EXPECT_EQ(190, v2->location_.x());
EXPECT_EQ(10, v2->location_.y());
ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0,
0);
root->OnMouseReleased(released);
// Now rotate |v2| inside |v1| clockwise.
transform = v2->GetTransform();
RotateClockwise(&transform);
transform.matrix().set(0, 3, 100.f);
v2->SetTransform(transform);
// Now, |v2| occupies (100, 100) to (200, 300) in |v1|, and (100, 300) to
// (300, 400) in |root|.
v1->Reset();
v2->Reset();
gfx::Point point2(110, 320);
ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p2);
EXPECT_EQ(0, v1->last_mouse_event_type_);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
EXPECT_EQ(10, v2->location_.x());
EXPECT_EQ(20, v2->location_.y());
root->OnMouseReleased(released);
v1->SetTransform(gfx::Transform());
v2->SetTransform(gfx::Transform());
TestView* v3 = new TestView();
v3->SetBoundsRect(gfx::Rect(10, 10, 20, 30));
v2->AddChildView(v3);
// Rotate |v3| clockwise with respect to |v2|.
transform = v1->GetTransform();
RotateClockwise(&transform);
transform.matrix().set(0, 3, 30.f);
v3->SetTransform(transform);
// Scale |v2| with respect to |v1| along both axis.
transform = v2->GetTransform();
transform.matrix().set(0, 0, 0.8f);
transform.matrix().set(1, 1, 0.5f);
v2->SetTransform(transform);
// |v3| occupies (108, 105) to (132, 115) in |root|.
v1->Reset();
v2->Reset();
v3->Reset();
gfx::Point point(112, 110);
ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p3);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
EXPECT_EQ(10, v3->location_.x());
EXPECT_EQ(25, v3->location_.y());
root->OnMouseReleased(released);
v1->SetTransform(gfx::Transform());
v2->SetTransform(gfx::Transform());
v3->SetTransform(gfx::Transform());
v1->Reset();
v2->Reset();
v3->Reset();
// Rotate |v3| clockwise with respect to |v2|, and scale it along both axis.
transform = v3->GetTransform();
RotateClockwise(&transform);
transform.matrix().set(0, 3, 30.f);
// Rotation sets some scaling transformation. Using SetScale would overwrite
// that and pollute the rotation. So combine the scaling with the existing
// transforamtion.
gfx::Transform scale;
scale.Scale(0.8f, 0.5f);
transform.ConcatTransform(scale);
v3->SetTransform(transform);
// Translate |v2| with respect to |v1|.
transform = v2->GetTransform();
transform.matrix().set(0, 3, 10.f);
transform.matrix().set(1, 3, 10.f);
v2->SetTransform(transform);
// |v3| now occupies (120, 120) to (144, 130) in |root|.
gfx::Point point3(124, 125);
ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3,
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p4);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
EXPECT_EQ(10, v3->location_.x());
EXPECT_EQ(25, v3->location_.y());
root->OnMouseReleased(released);
widget->CloseNow();
}
TEST_F(ViewTest, TransformVisibleBound) {
gfx::Rect viewport_bounds(0, 0, 100, 100);
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = viewport_bounds;
widget->Init(params);
widget->GetRootView()->SetBoundsRect(viewport_bounds);
View* viewport = new View;
widget->SetContentsView(viewport);
View* contents = new View;
viewport->AddChildView(contents);
viewport->SetBoundsRect(viewport_bounds);
contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200));
View* child = new View;
contents->AddChildView(child);
child->SetBoundsRect(gfx::Rect(10, 90, 50, 50));
EXPECT_EQ(gfx::Rect(0, 0, 50, 10), child->GetVisibleBounds());
// Rotate |child| counter-clockwise
gfx::Transform transform;
RotateCounterclockwise(&transform);
transform.matrix().set(1, 3, 50.f);
child->SetTransform(transform);
EXPECT_EQ(gfx::Rect(40, 0, 10, 50), child->GetVisibleBounds());
widget->CloseNow();
}
////////////////////////////////////////////////////////////////////////////////
// OnVisibleBoundsChanged()
class VisibleBoundsView : public View {
public:
VisibleBoundsView() : received_notification_(false) {}
virtual ~VisibleBoundsView() {}
bool received_notification() const { return received_notification_; }
void set_received_notification(bool received) {
received_notification_ = received;
}
private:
// Overridden from View:
virtual bool NeedsNotificationWhenVisibleBoundsChange() const OVERRIDE {
return true;
}
virtual void OnVisibleBoundsChanged() OVERRIDE {
received_notification_ = true;
}
bool received_notification_;
DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView);
};
TEST_F(ViewTest, OnVisibleBoundsChanged) {
gfx::Rect viewport_bounds(0, 0, 100, 100);
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = viewport_bounds;
widget->Init(params);
widget->GetRootView()->SetBoundsRect(viewport_bounds);
View* viewport = new View;
widget->SetContentsView(viewport);
View* contents = new View;
viewport->AddChildView(contents);
viewport->SetBoundsRect(viewport_bounds);
contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200));
// Create a view that cares about visible bounds notifications, and position
// it just outside the visible bounds of the viewport.
VisibleBoundsView* child = new VisibleBoundsView;
contents->AddChildView(child);
child->SetBoundsRect(gfx::Rect(10, 110, 50, 50));
// The child bound should be fully clipped.
EXPECT_TRUE(child->GetVisibleBounds().IsEmpty());
// Now scroll the contents, but not enough to make the child visible.
contents->SetY(contents->y() - 1);
// We should have received the notification since the visible bounds may have
// changed (even though they didn't).
EXPECT_TRUE(child->received_notification());
EXPECT_TRUE(child->GetVisibleBounds().IsEmpty());
child->set_received_notification(false);
// Now scroll the contents, this time by enough to make the child visible by
// one pixel.
contents->SetY(contents->y() - 10);
EXPECT_TRUE(child->received_notification());
EXPECT_EQ(1, child->GetVisibleBounds().height());
child->set_received_notification(false);
widget->CloseNow();
}
TEST_F(ViewTest, SetBoundsPaint) {
TestView top_view;
TestView* child_view = new TestView;
top_view.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
top_view.scheduled_paint_rects_.clear();
child_view->SetBoundsRect(gfx::Rect(10, 10, 20, 20));
top_view.AddChildView(child_view);
top_view.scheduled_paint_rects_.clear();
child_view->SetBoundsRect(gfx::Rect(30, 30, 20, 20));
EXPECT_EQ(2U, top_view.scheduled_paint_rects_.size());
// There should be 2 rects, spanning from (10, 10) to (50, 50).
gfx::Rect paint_rect = top_view.scheduled_paint_rects_[0];
paint_rect.Union(top_view.scheduled_paint_rects_[1]);
EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect);
}
// Assertions around painting and focus gain/lost.
TEST_F(ViewTest, FocusBlurPaints) {
TestView parent_view;
TestView* child_view1 = new TestView; // Owned by |parent_view|.
parent_view.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
child_view1->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
parent_view.AddChildView(child_view1);
parent_view.scheduled_paint_rects_.clear();
child_view1->scheduled_paint_rects_.clear();
// Focus change shouldn't trigger paints.
child_view1->DoFocus();
EXPECT_TRUE(parent_view.scheduled_paint_rects_.empty());
EXPECT_TRUE(child_view1->scheduled_paint_rects_.empty());
child_view1->DoBlur();
EXPECT_TRUE(parent_view.scheduled_paint_rects_.empty());
EXPECT_TRUE(child_view1->scheduled_paint_rects_.empty());
}
// Verifies SetBounds(same bounds) doesn't trigger a SchedulePaint().
TEST_F(ViewTest, SetBoundsSameBoundsDoesntSchedulePaint) {
TestView view;
view.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
view.InvalidateLayout();
view.scheduled_paint_rects_.clear();
view.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
EXPECT_TRUE(view.scheduled_paint_rects_.empty());
}
// Verifies AddChildView() and RemoveChildView() schedule appropriate paints.
TEST_F(ViewTest, AddAndRemoveSchedulePaints) {
gfx::Rect viewport_bounds(0, 0, 100, 100);
// We have to put the View hierarchy into a Widget or no paints will be
// scheduled.
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = viewport_bounds;
widget->Init(params);
widget->GetRootView()->SetBoundsRect(viewport_bounds);
TestView* parent_view = new TestView;
widget->SetContentsView(parent_view);
parent_view->SetBoundsRect(viewport_bounds);
parent_view->scheduled_paint_rects_.clear();
View* child_view = new View;
child_view->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
parent_view->AddChildView(child_view);
ASSERT_EQ(1U, parent_view->scheduled_paint_rects_.size());
EXPECT_EQ(child_view->bounds(), parent_view->scheduled_paint_rects_.front());
parent_view->scheduled_paint_rects_.clear();
parent_view->RemoveChildView(child_view);
scoped_ptr<View> child_deleter(child_view);
ASSERT_EQ(1U, parent_view->scheduled_paint_rects_.size());
EXPECT_EQ(child_view->bounds(), parent_view->scheduled_paint_rects_.front());
widget->CloseNow();
}
// Tests conversion methods with a transform.
TEST_F(ViewTest, ConversionsWithTransform) {
TestView top_view;
// View hierarchy used to test scale transforms.
TestView* child = new TestView;
TestView* child_child = new TestView;
// View used to test a rotation transform.
TestView* child_2 = new TestView;
top_view.AddChildView(child);
child->AddChildView(child_child);
top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000));
child->SetBoundsRect(gfx::Rect(7, 19, 500, 500));
gfx::Transform transform;
transform.Scale(3.0, 4.0);
child->SetTransform(transform);
child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100));
transform.MakeIdentity();
transform.Scale(5.0, 7.0);
child_child->SetTransform(transform);
top_view.AddChildView(child_2);
child_2->SetBoundsRect(gfx::Rect(700, 725, 100, 100));
transform.MakeIdentity();
RotateClockwise(&transform);
child_2->SetTransform(transform);
// Sanity check to make sure basic transforms act as expected.
{
gfx::Transform transform;
transform.Translate(110.0, -110.0);
transform.Scale(100.0, 55.0);
transform.Translate(1.0, 1.0);
// convert to a 3x3 matrix.
const SkMatrix& matrix = transform.matrix();
EXPECT_EQ(210, matrix.getTranslateX());
EXPECT_EQ(-55, matrix.getTranslateY());
EXPECT_EQ(100, matrix.getScaleX());
EXPECT_EQ(55, matrix.getScaleY());
EXPECT_EQ(0, matrix.getSkewX());
EXPECT_EQ(0, matrix.getSkewY());
}
{
gfx::Transform transform;
transform.Translate(1.0, 1.0);
gfx::Transform t2;
t2.Scale(100.0, 55.0);
gfx::Transform t3;
t3.Translate(110.0, -110.0);
transform.ConcatTransform(t2);
transform.ConcatTransform(t3);
// convert to a 3x3 matrix
const SkMatrix& matrix = transform.matrix();
EXPECT_EQ(210, matrix.getTranslateX());
EXPECT_EQ(-55, matrix.getTranslateY());
EXPECT_EQ(100, matrix.getScaleX());
EXPECT_EQ(55, matrix.getScaleY());
EXPECT_EQ(0, matrix.getSkewX());
EXPECT_EQ(0, matrix.getSkewY());
}
// Conversions from child->top and top->child.
{
gfx::Point point(5, 5);
View::ConvertPointToTarget(child, &top_view, &point);
EXPECT_EQ(22, point.x());
EXPECT_EQ(39, point.y());
gfx::RectF rect(5.0f, 5.0f, 10.0f, 20.0f);
View::ConvertRectToTarget(child, &top_view, &rect);
EXPECT_FLOAT_EQ(22.0f, rect.x());
EXPECT_FLOAT_EQ(39.0f, rect.y());
EXPECT_FLOAT_EQ(30.0f, rect.width());
EXPECT_FLOAT_EQ(80.0f, rect.height());
point.SetPoint(22, 39);
View::ConvertPointToTarget(&top_view, child, &point);
EXPECT_EQ(5, point.x());
EXPECT_EQ(5, point.y());
rect.SetRect(22.0f, 39.0f, 30.0f, 80.0f);
View::ConvertRectToTarget(&top_view, child, &rect);
EXPECT_FLOAT_EQ(5.0f, rect.x());
EXPECT_FLOAT_EQ(5.0f, rect.y());
EXPECT_FLOAT_EQ(10.0f, rect.width());
EXPECT_FLOAT_EQ(20.0f, rect.height());
}
// Conversions from child_child->top and top->child_child.
{
gfx::Point point(5, 5);
View::ConvertPointToTarget(child_child, &top_view, &point);
EXPECT_EQ(133, point.x());
EXPECT_EQ(211, point.y());
gfx::RectF rect(5.0f, 5.0f, 10.0f, 20.0f);
View::ConvertRectToTarget(child_child, &top_view, &rect);
EXPECT_FLOAT_EQ(133.0f, rect.x());
EXPECT_FLOAT_EQ(211.0f, rect.y());
EXPECT_FLOAT_EQ(150.0f, rect.width());
EXPECT_FLOAT_EQ(560.0f, rect.height());
point.SetPoint(133, 211);
View::ConvertPointToTarget(&top_view, child_child, &point);
EXPECT_EQ(5, point.x());
EXPECT_EQ(5, point.y());
rect.SetRect(133.0f, 211.0f, 150.0f, 560.0f);
View::ConvertRectToTarget(&top_view, child_child, &rect);
EXPECT_FLOAT_EQ(5.0f, rect.x());
EXPECT_FLOAT_EQ(5.0f, rect.y());
EXPECT_FLOAT_EQ(10.0f, rect.width());
EXPECT_FLOAT_EQ(20.0f, rect.height());
}
// Conversions from child_child->child and child->child_child
{
gfx::Point point(5, 5);
View::ConvertPointToTarget(child_child, child, &point);
EXPECT_EQ(42, point.x());
EXPECT_EQ(48, point.y());
gfx::RectF rect(5.0f, 5.0f, 10.0f, 20.0f);
View::ConvertRectToTarget(child_child, child, &rect);
EXPECT_FLOAT_EQ(42.0f, rect.x());
EXPECT_FLOAT_EQ(48.0f, rect.y());
EXPECT_FLOAT_EQ(50.0f, rect.width());
EXPECT_FLOAT_EQ(140.0f, rect.height());
point.SetPoint(42, 48);
View::ConvertPointToTarget(child, child_child, &point);
EXPECT_EQ(5, point.x());
EXPECT_EQ(5, point.y());
rect.SetRect(42.0f, 48.0f, 50.0f, 140.0f);
View::ConvertRectToTarget(child, child_child, &rect);
EXPECT_FLOAT_EQ(5.0f, rect.x());
EXPECT_FLOAT_EQ(5.0f, rect.y());
EXPECT_FLOAT_EQ(10.0f, rect.width());
EXPECT_FLOAT_EQ(20.0f, rect.height());
}
// Conversions from top_view to child with a value that should be negative.
// This ensures we don't round up with negative numbers.
{
gfx::Point point(6, 18);
View::ConvertPointToTarget(&top_view, child, &point);
EXPECT_EQ(-1, point.x());
EXPECT_EQ(-1, point.y());
float error = 0.01f;
gfx::RectF rect(6.0f, 18.0f, 10.0f, 39.0f);
View::ConvertRectToTarget(&top_view, child, &rect);
EXPECT_NEAR(-0.33f, rect.x(), error);
EXPECT_NEAR(-0.25f, rect.y(), error);
EXPECT_NEAR(3.33f, rect.width(), error);
EXPECT_NEAR(9.75f, rect.height(), error);
}
// Rect conversions from top_view->child_2 and child_2->top_view.
{
gfx::RectF rect(50.0f, 55.0f, 20.0f, 30.0f);
View::ConvertRectToTarget(child_2, &top_view, &rect);
EXPECT_FLOAT_EQ(615.0f, rect.x());
EXPECT_FLOAT_EQ(775.0f, rect.y());
EXPECT_FLOAT_EQ(30.0f, rect.width());
EXPECT_FLOAT_EQ(20.0f, rect.height());
rect.SetRect(615.0f, 775.0f, 30.0f, 20.0f);
View::ConvertRectToTarget(&top_view, child_2, &rect);
EXPECT_FLOAT_EQ(50.0f, rect.x());
EXPECT_FLOAT_EQ(55.0f, rect.y());
EXPECT_FLOAT_EQ(20.0f, rect.width());
EXPECT_FLOAT_EQ(30.0f, rect.height());
}
}
// Tests conversion methods to and from screen coordinates.
TEST_F(ViewTest, ConversionsToFromScreen) {
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
View* child = new View;
widget->GetRootView()->AddChildView(child);
child->SetBounds(10, 10, 100, 200);
gfx::Transform t;
t.Scale(0.5, 0.5);
child->SetTransform(t);
gfx::Point point_in_screen(100, 90);
gfx::Point point_in_child(80,60);
gfx::Point point = point_in_screen;
View::ConvertPointFromScreen(child, &point);
EXPECT_EQ(point_in_child.ToString(), point.ToString());
View::ConvertPointToScreen(child, &point);
EXPECT_EQ(point_in_screen.ToString(), point.ToString());
}
// Tests conversion methods for rectangles.
TEST_F(ViewTest, ConvertRectWithTransform) {
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
widget->Init(params);
View* root = widget->GetRootView();
TestView* v1 = new TestView;
TestView* v2 = new TestView;
root->AddChildView(v1);
v1->AddChildView(v2);
v1->SetBoundsRect(gfx::Rect(10, 10, 500, 500));
v2->SetBoundsRect(gfx::Rect(20, 20, 100, 200));
// |v2| now occupies (30, 30) to (130, 230) in |widget|
gfx::Rect rect(5, 5, 15, 40);
EXPECT_EQ(gfx::Rect(25, 25, 15, 40), v2->ConvertRectToParent(rect));
EXPECT_EQ(gfx::Rect(35, 35, 15, 40), v2->ConvertRectToWidget(rect));
// Rotate |v2|
gfx::Transform t2;
RotateCounterclockwise(&t2);
t2.matrix().set(1, 3, 100.f);
v2->SetTransform(t2);
// |v2| now occupies (30, 30) to (230, 130) in |widget|
EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect));
EXPECT_EQ(gfx::Rect(35, 110, 40, 15), v2->ConvertRectToWidget(rect));
// Scale down |v1|
gfx::Transform t1;
t1.Scale(0.5, 0.5);
v1->SetTransform(t1);
// The rectangle should remain the same for |v1|.
EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect));
// |v2| now occupies (20, 20) to (120, 70) in |widget|
EXPECT_EQ(gfx::Rect(22, 60, 21, 8).ToString(),
v2->ConvertRectToWidget(rect).ToString());
widget->CloseNow();
}
class ObserverView : public View {
public:
ObserverView();
virtual ~ObserverView();
void ResetTestState();
bool has_add_details() const { return has_add_details_; }
bool has_remove_details() const { return has_remove_details_; }
const ViewHierarchyChangedDetails& add_details() const {
return add_details_;
}
const ViewHierarchyChangedDetails& remove_details() const {
return remove_details_;
}
private:
// View:
virtual void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) OVERRIDE;
bool has_add_details_;
bool has_remove_details_;
ViewHierarchyChangedDetails add_details_;
ViewHierarchyChangedDetails remove_details_;
DISALLOW_COPY_AND_ASSIGN(ObserverView);
};
ObserverView::ObserverView()
: has_add_details_(false),
has_remove_details_(false) {
}
ObserverView::~ObserverView() {}
void ObserverView::ResetTestState() {
has_add_details_ = false;
has_remove_details_ = false;
add_details_ = ViewHierarchyChangedDetails();
remove_details_ = ViewHierarchyChangedDetails();
}
void ObserverView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add) {
has_add_details_ = true;
add_details_ = details;
} else {
has_remove_details_ = true;
remove_details_ = details;
}
}
// Verifies that the ViewHierarchyChanged() notification is sent correctly when
// a child view is added or removed to all the views in the hierarchy (up and
// down).
// The tree looks like this:
// v1
// +-- v2
// +-- v3
// +-- v4 (starts here, then get reparented to v1)
TEST_F(ViewTest, ViewHierarchyChanged) {
ObserverView v1;
ObserverView* v3 = new ObserverView();
// Add |v3| to |v2|.
scoped_ptr<ObserverView> v2(new ObserverView());
v2->AddChildView(v3);
// Make sure both |v2| and |v3| receive the ViewHierarchyChanged()
// notification.
EXPECT_TRUE(v2->has_add_details());
EXPECT_FALSE(v2->has_remove_details());
EXPECT_EQ(v2.get(), v2->add_details().parent);
EXPECT_EQ(v3, v2->add_details().child);
EXPECT_EQ(NULL, v2->add_details().move_view);
EXPECT_TRUE(v3->has_add_details());
EXPECT_FALSE(v3->has_remove_details());
EXPECT_EQ(v2.get(), v3->add_details().parent);
EXPECT_EQ(v3, v3->add_details().child);
EXPECT_EQ(NULL, v3->add_details().move_view);
// Reset everything to the initial state.
v2->ResetTestState();
v3->ResetTestState();
// Add |v2| to v1.
v1.AddChildView(v2.get());
// Verifies that |v2| is the child view *added* and the parent view is |v1|.
// Make sure all the views (v1, v2, v3) received _that_ information.
EXPECT_TRUE(v1.has_add_details());
EXPECT_FALSE(v1.has_remove_details());
EXPECT_EQ(&v1, v1.add_details().parent);
EXPECT_EQ(v2.get(), v1.add_details().child);
EXPECT_EQ(NULL, v1.add_details().move_view);
EXPECT_TRUE(v2->has_add_details());
EXPECT_FALSE(v2->has_remove_details());
EXPECT_EQ(&v1, v2->add_details().parent);
EXPECT_EQ(v2.get(), v2->add_details().child);
EXPECT_EQ(NULL, v2->add_details().move_view);
EXPECT_TRUE(v3->has_add_details());
EXPECT_FALSE(v3->has_remove_details());
EXPECT_EQ(&v1, v3->add_details().parent);
EXPECT_EQ(v2.get(), v3->add_details().child);
EXPECT_EQ(NULL, v3->add_details().move_view);
// Reset everything to the initial state.
v1.ResetTestState();
v2->ResetTestState();
v3->ResetTestState();
// Remove |v2| from |v1|.
v1.RemoveChildView(v2.get());
// Verifies that |v2| is the child view *removed* and the parent view is |v1|.
// Make sure all the views (v1, v2, v3) received _that_ information.
EXPECT_FALSE(v1.has_add_details());
EXPECT_TRUE(v1.has_remove_details());
EXPECT_EQ(&v1, v1.remove_details().parent);
EXPECT_EQ(v2.get(), v1.remove_details().child);
EXPECT_EQ(NULL, v1.remove_details().move_view);
EXPECT_FALSE(v2->has_add_details());
EXPECT_TRUE(v2->has_remove_details());
EXPECT_EQ(&v1, v2->remove_details().parent);
EXPECT_EQ(v2.get(), v2->remove_details().child);
EXPECT_EQ(NULL, v2->remove_details().move_view);
EXPECT_FALSE(v3->has_add_details());
EXPECT_TRUE(v3->has_remove_details());
EXPECT_EQ(&v1, v3->remove_details().parent);
EXPECT_EQ(v3, v3->remove_details().child);
EXPECT_EQ(NULL, v3->remove_details().move_view);
// Verifies notifications when reparenting a view.
ObserverView* v4 = new ObserverView();
// Add |v4| to |v2|.
v2->AddChildView(v4);
// Reset everything to the initial state.
v1.ResetTestState();
v2->ResetTestState();
v3->ResetTestState();
v4->ResetTestState();
// Reparent |v4| to |v1|.
v1.AddChildView(v4);
// Verifies that all views receive the correct information for all the child,
// parent and move views.
// |v1| is the new parent, |v4| is the child for add, |v2| is the old parent.
EXPECT_TRUE(v1.has_add_details());
EXPECT_FALSE(v1.has_remove_details());
EXPECT_EQ(&v1, v1.add_details().parent);
EXPECT_EQ(v4, v1.add_details().child);
EXPECT_EQ(v2.get(), v1.add_details().move_view);
// |v2| is the old parent, |v4| is the child for remove, |v1| is the new
// parent.
EXPECT_FALSE(v2->has_add_details());
EXPECT_TRUE(v2->has_remove_details());
EXPECT_EQ(v2.get(), v2->remove_details().parent);
EXPECT_EQ(v4, v2->remove_details().child);
EXPECT_EQ(&v1, v2->remove_details().move_view);
// |v3| is not impacted by this operation, and hence receives no notification.
EXPECT_FALSE(v3->has_add_details());
EXPECT_FALSE(v3->has_remove_details());
// |v4| is the reparented child, so it receives notifications for the remove
// and then the add. |v2| is its old parent, |v1| is its new parent.
EXPECT_TRUE(v4->has_remove_details());
EXPECT_TRUE(v4->has_add_details());
EXPECT_EQ(v2.get(), v4->remove_details().parent);
EXPECT_EQ(&v1, v4->add_details().parent);
EXPECT_EQ(v4, v4->add_details().child);
EXPECT_EQ(v4, v4->remove_details().child);
EXPECT_EQ(&v1, v4->remove_details().move_view);
EXPECT_EQ(v2.get(), v4->add_details().move_view);
}
// Verifies if the child views added under the root are all deleted when calling
// RemoveAllChildViews.
// The tree looks like this:
// root
// +-- child1
// +-- foo
// +-- bar0
// +-- bar1
// +-- bar2
// +-- child2
// +-- child3
TEST_F(ViewTest, RemoveAllChildViews) {
View root;
View* child1 = new View;
root.AddChildView(child1);
for (int i = 0; i < 2; ++i)
root.AddChildView(new View);
View* foo = new View;
child1->AddChildView(foo);
// Add some nodes to |foo|.
for (int i = 0; i < 3; ++i)
foo->AddChildView(new View);
EXPECT_EQ(3, root.child_count());
EXPECT_EQ(1, child1->child_count());
EXPECT_EQ(3, foo->child_count());
// Now remove all child views from root.
root.RemoveAllChildViews(true);
EXPECT_EQ(0, root.child_count());
EXPECT_FALSE(root.has_children());
}
TEST_F(ViewTest, Contains) {
View v1;
View* v2 = new View;
View* v3 = new View;
v1.AddChildView(v2);
v2->AddChildView(v3);
EXPECT_FALSE(v1.Contains(NULL));
EXPECT_TRUE(v1.Contains(&v1));
EXPECT_TRUE(v1.Contains(v2));
EXPECT_TRUE(v1.Contains(v3));
EXPECT_FALSE(v2->Contains(NULL));
EXPECT_TRUE(v2->Contains(v2));
EXPECT_FALSE(v2->Contains(&v1));
EXPECT_TRUE(v2->Contains(v3));
EXPECT_FALSE(v3->Contains(NULL));
EXPECT_TRUE(v3->Contains(v3));
EXPECT_FALSE(v3->Contains(&v1));
EXPECT_FALSE(v3->Contains(v2));
}
// Verifies if GetIndexOf() returns the correct index for the specified child
// view.
// The tree looks like this:
// root
// +-- child1
// +-- foo1
// +-- child2
TEST_F(ViewTest, GetIndexOf) {
View root;
View* child1 = new View;
root.AddChildView(child1);
View* child2 = new View;
root.AddChildView(child2);
View* foo1 = new View;
child1->AddChildView(foo1);
EXPECT_EQ(-1, root.GetIndexOf(NULL));
EXPECT_EQ(-1, root.GetIndexOf(&root));
EXPECT_EQ(0, root.GetIndexOf(child1));
EXPECT_EQ(1, root.GetIndexOf(child2));
EXPECT_EQ(-1, root.GetIndexOf(foo1));
EXPECT_EQ(-1, child1->GetIndexOf(NULL));
EXPECT_EQ(-1, child1->GetIndexOf(&root));
EXPECT_EQ(-1, child1->GetIndexOf(child1));
EXPECT_EQ(-1, child1->GetIndexOf(child2));
EXPECT_EQ(0, child1->GetIndexOf(foo1));
EXPECT_EQ(-1, child2->GetIndexOf(NULL));
EXPECT_EQ(-1, child2->GetIndexOf(&root));
EXPECT_EQ(-1, child2->GetIndexOf(child2));
EXPECT_EQ(-1, child2->GetIndexOf(child1));
EXPECT_EQ(-1, child2->GetIndexOf(foo1));
}
// Verifies that the child views can be reordered correctly.
TEST_F(ViewTest, ReorderChildren) {
View root;
View* child = new View();
root.AddChildView(child);
View* foo1 = new View();
child->AddChildView(foo1);
View* foo2 = new View();
child->AddChildView(foo2);
View* foo3 = new View();
child->AddChildView(foo3);
foo1->SetFocusable(true);
foo2->SetFocusable(true);
foo3->SetFocusable(true);
ASSERT_EQ(0, child->GetIndexOf(foo1));
ASSERT_EQ(1, child->GetIndexOf(foo2));
ASSERT_EQ(2, child->GetIndexOf(foo3));
ASSERT_EQ(foo2, foo1->GetNextFocusableView());
ASSERT_EQ(foo3, foo2->GetNextFocusableView());
ASSERT_EQ(NULL, foo3->GetNextFocusableView());
// Move |foo2| at the end.
child->ReorderChildView(foo2, -1);
ASSERT_EQ(0, child->GetIndexOf(foo1));
ASSERT_EQ(1, child->GetIndexOf(foo3));
ASSERT_EQ(2, child->GetIndexOf(foo2));
ASSERT_EQ(foo3, foo1->GetNextFocusableView());
ASSERT_EQ(foo2, foo3->GetNextFocusableView());
ASSERT_EQ(NULL, foo2->GetNextFocusableView());
// Move |foo1| at the end.
child->ReorderChildView(foo1, -1);
ASSERT_EQ(0, child->GetIndexOf(foo3));
ASSERT_EQ(1, child->GetIndexOf(foo2));
ASSERT_EQ(2, child->GetIndexOf(foo1));
ASSERT_EQ(NULL, foo1->GetNextFocusableView());
ASSERT_EQ(foo2, foo1->GetPreviousFocusableView());
ASSERT_EQ(foo2, foo3->GetNextFocusableView());
ASSERT_EQ(foo1, foo2->GetNextFocusableView());
// Move |foo2| to the front.
child->ReorderChildView(foo2, 0);
ASSERT_EQ(0, child->GetIndexOf(foo2));
ASSERT_EQ(1, child->GetIndexOf(foo3));
ASSERT_EQ(2, child->GetIndexOf(foo1));
ASSERT_EQ(NULL, foo1->GetNextFocusableView());
ASSERT_EQ(foo3, foo1->GetPreviousFocusableView());
ASSERT_EQ(foo3, foo2->GetNextFocusableView());
ASSERT_EQ(foo1, foo3->GetNextFocusableView());
}
// Verifies that GetViewByID returns the correctly child view from the specified
// ID.
// The tree looks like this:
// v1
// +-- v2
// +-- v3
// +-- v4
TEST_F(ViewTest, GetViewByID) {
View v1;
const int kV1ID = 1;
v1.set_id(kV1ID);
View v2;
const int kV2ID = 2;
v2.set_id(kV2ID);
View v3;
const int kV3ID = 3;
v3.set_id(kV3ID);
View v4;
const int kV4ID = 4;
v4.set_id(kV4ID);
const int kV5ID = 5;
v1.AddChildView(&v2);
v2.AddChildView(&v3);
v2.AddChildView(&v4);
EXPECT_EQ(&v1, v1.GetViewByID(kV1ID));
EXPECT_EQ(&v2, v1.GetViewByID(kV2ID));
EXPECT_EQ(&v4, v1.GetViewByID(kV4ID));
EXPECT_EQ(NULL, v1.GetViewByID(kV5ID)); // No V5 exists.
EXPECT_EQ(NULL, v2.GetViewByID(kV1ID)); // It can get only from child views.
const int kGroup = 1;
v3.SetGroup(kGroup);
v4.SetGroup(kGroup);
View::Views views;
v1.GetViewsInGroup(kGroup, &views);
EXPECT_EQ(2U, views.size());
View::Views::const_iterator i(std::find(views.begin(), views.end(), &v3));
EXPECT_NE(views.end(), i);
i = std::find(views.begin(), views.end(), &v4);
EXPECT_NE(views.end(), i);
}
TEST_F(ViewTest, AddExistingChild) {
View v1, v2, v3;
v1.AddChildView(&v2);
v1.AddChildView(&v3);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
// Check that there's no change in order when adding at same index.
v1.AddChildViewAt(&v2, 0);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
v1.AddChildViewAt(&v3, 1);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
// Add it at a different index and check for change in order.
v1.AddChildViewAt(&v2, 1);
EXPECT_EQ(1, v1.GetIndexOf(&v2));
EXPECT_EQ(0, v1.GetIndexOf(&v3));
v1.AddChildViewAt(&v2, 0);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
// Check that calling |AddChildView()| does not change the order.
v1.AddChildView(&v2);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
v1.AddChildView(&v3);
EXPECT_EQ(0, v1.GetIndexOf(&v2));
EXPECT_EQ(1, v1.GetIndexOf(&v3));
}
////////////////////////////////////////////////////////////////////////////////
// Layers
////////////////////////////////////////////////////////////////////////////////
namespace {
// Test implementation of LayerAnimator.
class TestLayerAnimator : public ui::LayerAnimator {
public:
TestLayerAnimator();
const gfx::Rect& last_bounds() const { return last_bounds_; }
// LayerAnimator.
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
protected:
virtual ~TestLayerAnimator() { }
private:
gfx::Rect last_bounds_;
DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator);
};
TestLayerAnimator::TestLayerAnimator()
: ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) {
}
void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) {
last_bounds_ = bounds;
}
} // namespace
class ViewLayerTest : public ViewsTestBase {
public:
ViewLayerTest() : widget_(NULL) {}
virtual ~ViewLayerTest() {
}
// Returns the Layer used by the RootView.
ui::Layer* GetRootLayer() {
return widget()->GetLayer();
}
virtual void SetUp() OVERRIDE {
ViewTest::SetUp();
widget_ = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(50, 50, 200, 200);
widget_->Init(params);
widget_->Show();
widget_->GetRootView()->SetBounds(0, 0, 200, 200);
}
virtual void TearDown() OVERRIDE {
widget_->CloseNow();
ViewsTestBase::TearDown();
}
Widget* widget() { return widget_; }
private:
Widget* widget_;
};
TEST_F(ViewLayerTest, LayerToggling) {
// Because we lazily create textures the calls to DrawTree are necessary to
// ensure we trigger creation of textures.
ui::Layer* root_layer = widget()->GetLayer();
View* content_view = new View;
widget()->SetContentsView(content_view);
// Create v1, give it a bounds and verify everything is set up correctly.
View* v1 = new View;
v1->SetPaintToLayer(true);
EXPECT_TRUE(v1->layer() != NULL);
v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150));
content_view->AddChildView(v1);
ASSERT_TRUE(v1->layer() != NULL);
EXPECT_EQ(root_layer, v1->layer()->parent());
EXPECT_EQ(gfx::Rect(20, 30, 140, 150), v1->layer()->bounds());
// Create v2 as a child of v1 and do basic assertion testing.
View* v2 = new View;
v1->AddChildView(v2);
EXPECT_TRUE(v2->layer() == NULL);
v2->SetBoundsRect(gfx::Rect(10, 20, 30, 40));
v2->SetPaintToLayer(true);
ASSERT_TRUE(v2->layer() != NULL);
EXPECT_EQ(v1->layer(), v2->layer()->parent());
EXPECT_EQ(gfx::Rect(10, 20, 30, 40), v2->layer()->bounds());
// Turn off v1s layer. v2 should still have a layer but its parent should have
// changed.
v1->SetPaintToLayer(false);
EXPECT_TRUE(v1->layer() == NULL);
EXPECT_TRUE(v2->layer() != NULL);
EXPECT_EQ(root_layer, v2->layer()->parent());
ASSERT_EQ(1u, root_layer->children().size());
EXPECT_EQ(root_layer->children()[0], v2->layer());
// The bounds of the layer should have changed to be relative to the root view
// now.
EXPECT_EQ(gfx::Rect(30, 50, 30, 40), v2->layer()->bounds());
// Make v1 have a layer again and verify v2s layer is wired up correctly.
gfx::Transform transform;
transform.Scale(2.0, 2.0);
v1->SetTransform(transform);
EXPECT_TRUE(v1->layer() != NULL);
EXPECT_TRUE(v2->layer() != NULL);
EXPECT_EQ(root_layer, v1->layer()->parent());
EXPECT_EQ(v1->layer(), v2->layer()->parent());
ASSERT_EQ(1u, root_layer->children().size());
EXPECT_EQ(root_layer->children()[0], v1->layer());
ASSERT_EQ(1u, v1->layer()->children().size());
EXPECT_EQ(v1->layer()->children()[0], v2->layer());
EXPECT_EQ(gfx::Rect(10, 20, 30, 40), v2->layer()->bounds());
}
// Verifies turning on a layer wires up children correctly.
TEST_F(ViewLayerTest, NestedLayerToggling) {
View* content_view = new View;
widget()->SetContentsView(content_view);
// Create v1, give it a bounds and verify everything is set up correctly.
View* v1 = new View;
content_view->AddChildView(v1);
v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150));
View* v2 = new View;
v1->AddChildView(v2);
View* v3 = new View;
v3->SetPaintToLayer(true);
v2->AddChildView(v3);
ASSERT_TRUE(v3->layer() != NULL);
// At this point we have v1-v2-v3. v3 has a layer, v1 and v2 don't.
v1->SetPaintToLayer(true);
EXPECT_EQ(v1->layer(), v3->layer()->parent());
}
TEST_F(ViewLayerTest, LayerAnimator) {
View* content_view = new View;
widget()->SetContentsView(content_view);
View* v1 = new View;
content_view->AddChildView(v1);
v1->SetPaintToLayer(true);
EXPECT_TRUE(v1->layer() != NULL);
TestLayerAnimator* animator = new TestLayerAnimator();
v1->layer()->SetAnimator(animator);
gfx::Rect bounds(1, 2, 3, 4);
v1->SetBoundsRect(bounds);
EXPECT_EQ(bounds, animator->last_bounds());
// TestLayerAnimator doesn't update the layer.
EXPECT_NE(bounds, v1->layer()->bounds());
}
// Verifies the bounds of a layer are updated if the bounds of ancestor that
// doesn't have a layer change.
TEST_F(ViewLayerTest, BoundsChangeWithLayer) {
View* content_view = new View;
widget()->SetContentsView(content_view);
View* v1 = new View;
content_view->AddChildView(v1);
v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150));
View* v2 = new View;
v2->SetBoundsRect(gfx::Rect(10, 11, 40, 50));
v1->AddChildView(v2);
v2->SetPaintToLayer(true);
ASSERT_TRUE(v2->layer() != NULL);
EXPECT_EQ(gfx::Rect(30, 41, 40, 50), v2->layer()->bounds());
v1->SetPosition(gfx::Point(25, 36));
EXPECT_EQ(gfx::Rect(35, 47, 40, 50), v2->layer()->bounds());
v2->SetPosition(gfx::Point(11, 12));
EXPECT_EQ(gfx::Rect(36, 48, 40, 50), v2->layer()->bounds());
// Bounds of the layer should change even if the view is not invisible.
v1->SetVisible(false);
v1->SetPosition(gfx::Point(20, 30));
EXPECT_EQ(gfx::Rect(31, 42, 40, 50), v2->layer()->bounds());
v2->SetVisible(false);
v2->SetBoundsRect(gfx::Rect(10, 11, 20, 30));
EXPECT_EQ(gfx::Rect(30, 41, 20, 30), v2->layer()->bounds());
}
// Make sure layers are positioned correctly in RTL.
TEST_F(ViewLayerTest, BoundInRTL) {
std::string locale = l10n_util::GetApplicationLocale(std::string());
base::i18n::SetICUDefaultLocale("he");
View* view = new View;
widget()->SetContentsView(view);
int content_width = view->width();
// |v1| is initially not attached to anything. So its layer will have the same
// bounds as the view.
View* v1 = new View;
v1->SetPaintToLayer(true);
v1->SetBounds(10, 10, 20, 10);
EXPECT_EQ(gfx::Rect(10, 10, 20, 10),
v1->layer()->bounds());
// Once |v1| is attached to the widget, its layer will get RTL-appropriate
// bounds.
view->AddChildView(v1);
EXPECT_EQ(gfx::Rect(content_width - 30, 10, 20, 10),
v1->layer()->bounds());
gfx::Rect l1bounds = v1->layer()->bounds();
// Now attach a View to the widget first, then create a layer for it. Make
// sure the bounds are correct.
View* v2 = new View;
v2->SetBounds(50, 10, 30, 10);
EXPECT_FALSE(v2->layer());
view->AddChildView(v2);
v2->SetPaintToLayer(true);
EXPECT_EQ(gfx::Rect(content_width - 80, 10, 30, 10),
v2->layer()->bounds());
gfx::Rect l2bounds = v2->layer()->bounds();
view->SetPaintToLayer(true);
EXPECT_EQ(l1bounds, v1->layer()->bounds());
EXPECT_EQ(l2bounds, v2->layer()->bounds());
// Move one of the views. Make sure the layer is positioned correctly
// afterwards.
v1->SetBounds(v1->x() - 5, v1->y(), v1->width(), v1->height());
l1bounds.set_x(l1bounds.x() + 5);
EXPECT_EQ(l1bounds, v1->layer()->bounds());
view->SetPaintToLayer(false);
EXPECT_EQ(l1bounds, v1->layer()->bounds());
EXPECT_EQ(l2bounds, v2->layer()->bounds());
// Move a view again.
v2->SetBounds(v2->x() + 5, v2->y(), v2->width(), v2->height());
l2bounds.set_x(l2bounds.x() - 5);
EXPECT_EQ(l2bounds, v2->layer()->bounds());
// Reset locale.
base::i18n::SetICUDefaultLocale(locale);
}
// Makes sure a transform persists after toggling the visibility.
TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
View* view = new View;
gfx::Transform transform;
transform.Scale(2.0, 2.0);
view->SetTransform(transform);
widget()->SetContentsView(view);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
view->SetVisible(false);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
view->SetVisible(true);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
}
// Verifies a transform persists after removing/adding a view with a transform.
TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
View* view = new View;
gfx::Transform transform;
transform.Scale(2.0, 2.0);
view->SetTransform(transform);
widget()->SetContentsView(view);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
ASSERT_TRUE(view->layer() != NULL);
EXPECT_EQ(2.0f, view->layer()->transform().matrix().get(0, 0));
View* parent = view->parent();
parent->RemoveChildView(view);
parent->AddChildView(view);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
ASSERT_TRUE(view->layer() != NULL);
EXPECT_EQ(2.0f, view->layer()->transform().matrix().get(0, 0));
}
// Makes sure that layer visibility is correct after toggling View visibility.
TEST_F(ViewLayerTest, ToggleVisibilityWithLayer) {
View* content_view = new View;
widget()->SetContentsView(content_view);
// The view isn't attached to a widget or a parent view yet. But it should
// still have a layer, but the layer should not be attached to the root
// layer.
View* v1 = new View;
v1->SetPaintToLayer(true);
EXPECT_TRUE(v1->layer());
EXPECT_FALSE(LayerIsAncestor(widget()->GetCompositor()->root_layer(),
v1->layer()));
// Once the view is attached to a widget, its layer should be attached to the
// root layer and visible.
content_view->AddChildView(v1);
EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(),
v1->layer()));
EXPECT_TRUE(v1->layer()->IsDrawn());
v1->SetVisible(false);
EXPECT_FALSE(v1->layer()->IsDrawn());
v1->SetVisible(true);
EXPECT_TRUE(v1->layer()->IsDrawn());
widget()->Hide();
EXPECT_FALSE(v1->layer()->IsDrawn());
widget()->Show();
EXPECT_TRUE(v1->layer()->IsDrawn());
}
// Tests that the layers in the subtree are orphaned after a View is removed
// from the parent.
TEST_F(ViewLayerTest, OrphanLayerAfterViewRemove) {
View* content_view = new View;
widget()->SetContentsView(content_view);
View* v1 = new View;
content_view->AddChildView(v1);
View* v2 = new View;
v1->AddChildView(v2);
v2->SetPaintToLayer(true);
EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(),
v2->layer()));
EXPECT_TRUE(v2->layer()->IsDrawn());
content_view->RemoveChildView(v1);
EXPECT_FALSE(LayerIsAncestor(widget()->GetCompositor()->root_layer(),
v2->layer()));
// Reparent |v2|.
content_view->AddChildView(v2);
delete v1;
v1 = NULL;
EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(),
v2->layer()));
EXPECT_TRUE(v2->layer()->IsDrawn());
}
class PaintTrackingView : public View {
public:
PaintTrackingView() : painted_(false) {
}
bool painted() const { return painted_; }
void set_painted(bool value) { painted_ = value; }
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
painted_ = true;
}
private:
bool painted_;
DISALLOW_COPY_AND_ASSIGN(PaintTrackingView);
};
// Makes sure child views with layers aren't painted when paint starts at an
// ancestor.
TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
PaintTrackingView* content_view = new PaintTrackingView;
widget()->SetContentsView(content_view);
content_view->SetPaintToLayer(true);
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
content_view->set_painted(false);
// content_view no longer has a dirty rect. Paint from the root and make sure
// PaintTrackingView isn't painted.
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_FALSE(content_view->painted());
// Make content_view have a dirty rect, paint the layers and make sure
// PaintTrackingView is painted.
content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_TRUE(content_view->painted());
}
// Tests that the visibility of child layers are updated correctly when a View's
// visibility changes.
TEST_F(ViewLayerTest, VisibilityChildLayers) {
View* v1 = new View;
v1->SetPaintToLayer(true);
widget()->SetContentsView(v1);
View* v2 = new View;
v1->AddChildView(v2);
View* v3 = new View;
v2->AddChildView(v3);
v3->SetVisible(false);
View* v4 = new View;
v4->SetPaintToLayer(true);
v3->AddChildView(v4);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_FALSE(v4->layer()->IsDrawn());
v2->SetVisible(false);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_FALSE(v4->layer()->IsDrawn());
v2->SetVisible(true);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_FALSE(v4->layer()->IsDrawn());
v2->SetVisible(false);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_FALSE(v4->layer()->IsDrawn());
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(v1, v1->layer()));
v3->SetVisible(true);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_FALSE(v4->layer()->IsDrawn());
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(v1, v1->layer()));
// Reparent |v3| to |v1|.
v1->AddChildView(v3);
EXPECT_TRUE(v1->layer()->IsDrawn());
EXPECT_TRUE(v4->layer()->IsDrawn());
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(v1, v1->layer()));
}
// This test creates a random View tree, and then randomly reorders child views,
// reparents views etc. Unrelated changes can appear to break this test. So
// marking this as FLAKY.
TEST_F(ViewLayerTest, DISABLED_ViewLayerTreesInSync) {
View* content = new View;
content->SetPaintToLayer(true);
widget()->SetContentsView(content);
widget()->Show();
ConstructTree(content, 5);
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
ScrambleTree(content);
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
ScrambleTree(content);
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
ScrambleTree(content);
EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
}
// Verifies when views are reordered the layer is also reordered. The widget is
// providing the parent layer.
TEST_F(ViewLayerTest, ReorderUnderWidget) {
View* content = new View;
widget()->SetContentsView(content);
View* c1 = new View;
c1->SetPaintToLayer(true);
content->AddChildView(c1);
View* c2 = new View;
c2->SetPaintToLayer(true);
content->AddChildView(c2);
ui::Layer* parent_layer = c1->layer()->parent();
ASSERT_TRUE(parent_layer);
ASSERT_EQ(2u, parent_layer->children().size());
EXPECT_EQ(c1->layer(), parent_layer->children()[0]);
EXPECT_EQ(c2->layer(), parent_layer->children()[1]);
// Move c1 to the front. The layers should have moved too.
content->ReorderChildView(c1, -1);
EXPECT_EQ(c1->layer(), parent_layer->children()[1]);
EXPECT_EQ(c2->layer(), parent_layer->children()[0]);
}
// Verifies that the layer of a view can be acquired properly.
TEST_F(ViewLayerTest, AcquireLayer) {
View* content = new View;
widget()->SetContentsView(content);
scoped_ptr<View> c1(new View);
c1->SetPaintToLayer(true);
EXPECT_TRUE(c1->layer());
content->AddChildView(c1.get());
scoped_ptr<ui::Layer> layer(c1->AcquireLayer());
EXPECT_EQ(layer.get(), c1->layer());
scoped_ptr<ui::Layer> layer2(c1->RecreateLayer());
EXPECT_NE(c1->layer(), layer2.get());
// Destroy view before destroying layer.
c1.reset();
}
// Verify the z-order of the layers as a result of calling RecreateLayer().
TEST_F(ViewLayerTest, RecreateLayerZOrder) {
scoped_ptr<View> v(new View());
v->SetPaintToLayer(true);
View* v1 = new View();
v1->SetPaintToLayer(true);
v->AddChildView(v1);
View* v2 = new View();
v2->SetPaintToLayer(true);
v->AddChildView(v2);
// Test the initial z-order.
const std::vector<ui::Layer*>& child_layers_pre = v->layer()->children();
ASSERT_EQ(2u, child_layers_pre.size());
EXPECT_EQ(v1->layer(), child_layers_pre[0]);
EXPECT_EQ(v2->layer(), child_layers_pre[1]);
scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer());
// Test the new layer order. We expect: |v1| |v1_old_layer| |v2|.
// for |v1| and |v2|.
const std::vector<ui::Layer*>& child_layers_post = v->layer()->children();
ASSERT_EQ(3u, child_layers_post.size());
EXPECT_EQ(v1->layer(), child_layers_post[0]);
EXPECT_EQ(v1_old_layer, child_layers_post[1]);
EXPECT_EQ(v2->layer(), child_layers_post[2]);
}
// Verify the z-order of the layers as a result of calling RecreateLayer when
// the widget is the parent with the layer.
TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) {
View* v = new View();
widget()->SetContentsView(v);
View* v1 = new View();
v1->SetPaintToLayer(true);
v->AddChildView(v1);
View* v2 = new View();
v2->SetPaintToLayer(true);
v->AddChildView(v2);
ui::Layer* root_layer = GetRootLayer();
// Test the initial z-order.
const std::vector<ui::Layer*>& child_layers_pre = root_layer->children();
ASSERT_EQ(2u, child_layers_pre.size());
EXPECT_EQ(v1->layer(), child_layers_pre[0]);
EXPECT_EQ(v2->layer(), child_layers_pre[1]);
scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer());
// Test the new layer order. We expect: |v1| |v1_old_layer| |v2|.
const std::vector<ui::Layer*>& child_layers_post = root_layer->children();
ASSERT_EQ(3u, child_layers_post.size());
EXPECT_EQ(v1->layer(), child_layers_post[0]);
EXPECT_EQ(v1_old_layer, child_layers_post[1]);
EXPECT_EQ(v2->layer(), child_layers_post[2]);
}
// Verifies RecreateLayer() moves all Layers over, even those that don't have
// a View.
TEST_F(ViewLayerTest, RecreateLayerMovesNonViewChildren) {
View v;
v.SetPaintToLayer(true);
View child;
child.SetPaintToLayer(true);
v.AddChildView(&child);
ASSERT_TRUE(v.layer() != NULL);
ASSERT_EQ(1u, v.layer()->children().size());
EXPECT_EQ(v.layer()->children()[0], child.layer());
ui::Layer layer(ui::LAYER_NOT_DRAWN);
v.layer()->Add(&layer);
v.layer()->StackAtBottom(&layer);
scoped_ptr<ui::Layer> old_layer(v.RecreateLayer());
// All children should be moved from old layer to new layer.
ASSERT_TRUE(old_layer.get() != NULL);
EXPECT_TRUE(old_layer->children().empty());
// And new layer should have the two children.
ASSERT_TRUE(v.layer() != NULL);
ASSERT_EQ(2u, v.layer()->children().size());
EXPECT_EQ(v.layer()->children()[0], &layer);
EXPECT_EQ(v.layer()->children()[1], child.layer());
}
class BoundsTreeTestView : public View {
public:
BoundsTreeTestView() {}
virtual void PaintChildren(gfx::Canvas* canvas,
const CullSet& cull_set) OVERRIDE {
// Save out a copy of the cull_set before calling the base implementation.
last_cull_set_.clear();
if (cull_set.cull_set_) {
for (base::hash_set<intptr_t>::iterator it = cull_set.cull_set_->begin();
it != cull_set.cull_set_->end();
++it) {
last_cull_set_.insert(reinterpret_cast<View*>(*it));
}
}
View::PaintChildren(canvas, cull_set);
}
std::set<View*> last_cull_set_;
};
TEST_F(ViewLayerTest, BoundsTreePaintUpdatesCullSet) {
BoundsTreeTestView* test_view = new BoundsTreeTestView;
widget()->SetContentsView(test_view);
View* v1 = new View();
v1->SetBoundsRect(gfx::Rect(10, 15, 150, 151));
test_view->AddChildView(v1);
View* v2 = new View();
v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50));
v1->AddChildView(v2);
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Now we have test_view - v1 - v2. Damage to only test_view should only
// return root_view and test_view.
test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
// Damage to v1 only should only return root_view, test_view, and v1.
test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(3U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
// A Damage rect inside v2 should get all 3 views back in the |last_cull_set_|
// on call to TestView::Paint(), along with the widget root view.
test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(4U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
}
TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) {
BoundsTreeTestView* test_view = new BoundsTreeTestView;
widget()->SetContentsView(test_view);
View* v1 = new View;
v1->SetBoundsRect(gfx::Rect(5, 6, 100, 101));
test_view->AddChildView(v1);
View* v2 = new View;
v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50));
v1->AddChildView(v2);
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Move v1 to a new origin out of the way of our next query.
v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101));
// The move will force a repaint.
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Schedule a paint with damage rect where v1 used to be.
test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11));
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Should only have picked up root_view and test_view.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
}
TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) {
BoundsTreeTestView* test_view = new BoundsTreeTestView;
widget()->SetContentsView(test_view);
View* v1 = new View;
v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20));
test_view->AddChildView(v1);
View* v2 = new View;
v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
v1->AddChildView(v2);
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Set v1 to paint to its own layer, it should remove itself from the
// test_view heiarchy and no longer intersect with damage rects in that cull
// set.
v1->SetPaintToLayer(true);
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// v1 and v2 should no longer be present in the test_view cull_set.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
EXPECT_EQ(0U, test_view->last_cull_set_.count(v2));
// Now set v1 back to not painting to a layer.
v1->SetPaintToLayer(false);
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// We should be back to the full cull set including v1 and v2.
EXPECT_EQ(4U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
}
TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) {
BoundsTreeTestView* test_view = new BoundsTreeTestView;
widget()->SetContentsView(test_view);
View* v1 = new View;
v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20));
test_view->AddChildView(v1);
View* v2 = new View;
v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
v1->AddChildView(v2);
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Now remove v1 from the root view.
test_view->RemoveChildView(v1);
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// v1 and v2 should no longer be present in the test_view cull_set.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
EXPECT_EQ(0U, test_view->last_cull_set_.count(v2));
// View v1 and v2 are no longer part of view hierarchy and therefore won't be
// deleted with that hierarchy.
delete v1;
}
TEST_F(ViewLayerTest, BoundsTreeMoveViewMovesBounds) {
BoundsTreeTestView* test_view = new BoundsTreeTestView;
widget()->SetContentsView(test_view);
// Build hierarchy v1 - v2 - v3.
View* v1 = new View;
v1->SetBoundsRect(gfx::Rect(20, 30, 150, 160));
test_view->AddChildView(v1);
View* v2 = new View;
v2->SetBoundsRect(gfx::Rect(5, 10, 40, 50));
v1->AddChildView(v2);
View* v3 = new View;
v3->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
v2->AddChildView(v3);
// Schedule a full-view paint and ensure all views are present in the cull.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(5U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v3));
// Build an unrelated view hierarchy and move v2 in to it.
scoped_ptr<Widget> test_widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(10, 10, 500, 500);
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
test_widget->Init(params);
test_widget->Show();
BoundsTreeTestView* widget_view = new BoundsTreeTestView;
test_widget->SetContentsView(widget_view);
widget_view->AddChildView(v2);
// Now schedule full-view paints in both widgets.
test_view->SchedulePaintInRect(test_view->bounds());
widget_view->SchedulePaintInRect(widget_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Only v1 should be present in the first cull set.
EXPECT_EQ(3U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
// We should find v2 and v3 in the widget_view cull_set.
EXPECT_EQ(4U, widget_view->last_cull_set_.size());
EXPECT_EQ(1U, widget_view->last_cull_set_.count(test_widget->GetRootView()));
EXPECT_EQ(1U, widget_view->last_cull_set_.count(widget_view));
EXPECT_EQ(1U, widget_view->last_cull_set_.count(v2));
EXPECT_EQ(1U, widget_view->last_cull_set_.count(v3));
}
TEST_F(ViewTest, FocusableAssertions) {
// View subclasses may change insets based on whether they are focusable,
// which effects the preferred size. To avoid preferred size changing around
// these Views need to key off the last value set to SetFocusable(), not
// whether the View is focusable right now. For this reason it's important
// that focusable() return the last value passed to SetFocusable and not
// whether the View is focusable right now.
TestView view;
view.SetFocusable(true);
EXPECT_TRUE(view.focusable());
view.SetEnabled(false);
EXPECT_TRUE(view.focusable());
view.SetFocusable(false);
EXPECT_FALSE(view.focusable());
}
// Creates a widget of TYPE_CONTROL.
// The caller takes ownership of the returned widget.
Widget* CreateControlWidget(aura::Window* parent, const gfx::Rect& bounds) {
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.parent = parent;
params.bounds = bounds;
Widget* widget = new Widget();
widget->Init(params);
return widget;
}
// Returns a view with a layer with the passed in |bounds| and |layer_name|.
// The caller takes ownership of the returned view.
View* CreateViewWithLayer(const gfx::Rect& bounds,
const char* layer_name) {
View* view = new View();
view->SetBoundsRect(bounds);
view->SetPaintToLayer(true);
view->layer()->set_name(layer_name);
return view;
}
// Test that RecreateWindowLayers() recreates the layers for all child windows
// and all child views and that the z-order of the recreated layers matches that
// of the original layers.
// Test hierarchy:
// w1
// +-- v1
// +-- v2 (no layer)
// +-- v3 (no layer)
// +-- v4
// +-- w2
// +-- v5
// +-- v6
// +-- v7
// +-- v8
// +-- v9
TEST_F(ViewTest, RecreateLayers) {
Widget* w1 = CreateControlWidget(GetContext(), gfx::Rect(0, 0, 100, 100));
w1->GetNativeView()->layer()->set_name("w1");
View* v2 = new View();
v2->SetBounds(0, 1, 100, 101);
View* v3 = new View();
v3->SetBounds(0, 2, 100, 102);
View* w2_host_view = new View();
View* v1 = CreateViewWithLayer(gfx::Rect(0, 3, 100, 103), "v1");
ui::Layer* v1_layer = v1->layer();
w1->GetRootView()->AddChildView(v1);
w1->GetRootView()->AddChildView(v2);
v2->AddChildView(v3);
View* v4 = CreateViewWithLayer(gfx::Rect(0, 4, 100, 104), "v4");
ui::Layer* v4_layer = v4->layer();
v2->AddChildView(v4);
w1->GetRootView()->AddChildView(w2_host_view);
View* v7 = CreateViewWithLayer(gfx::Rect(0, 4, 100, 104), "v7");
ui::Layer* v7_layer = v7->layer();
w1->GetRootView()->AddChildView(v7);
View* v8 = CreateViewWithLayer(gfx::Rect(0, 4, 100, 104), "v8");
ui::Layer* v8_layer = v8->layer();
v7->AddChildView(v8);
View* v9 = CreateViewWithLayer(gfx::Rect(0, 4, 100, 104), "v9");
ui::Layer* v9_layer = v9->layer();
v7->AddChildView(v9);
Widget* w2 = CreateControlWidget(w1->GetNativeView(),
gfx::Rect(0, 5, 100, 105));
w2->GetNativeView()->layer()->set_name("w2");
w2->GetNativeView()->SetProperty(kHostViewKey, w2_host_view);
View* v5 = CreateViewWithLayer(gfx::Rect(0, 6, 100, 106), "v5");
w2->GetRootView()->AddChildView(v5);
View* v6 = CreateViewWithLayer(gfx::Rect(0, 7, 100, 107), "v6");
ui::Layer* v6_layer = v6->layer();
v5->AddChildView(v6);
// Test the initial order of the layers.
ui::Layer* w1_layer = w1->GetNativeView()->layer();
ASSERT_EQ("w1", w1_layer->name());
ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer));
ui::Layer* w2_layer = w1_layer->children()[2];
ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_layer));
ui::Layer* v5_layer = w2_layer->children()[0];
ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_layer));
{
scoped_ptr<ui::LayerTreeOwner> cloned_owner(
wm::RecreateLayers(w1->GetNativeView()));
EXPECT_EQ(w1_layer, cloned_owner->root());
EXPECT_NE(w1_layer, w1->GetNativeView()->layer());
// The old layers should still exist and have the same hierarchy.
ASSERT_EQ("w1", w1_layer->name());
ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer));
ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_layer));
ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_layer));
EXPECT_EQ("v8 v9", ui::test::ChildLayerNamesAsString(*v7_layer));
ASSERT_EQ(4u, w1_layer->children().size());
EXPECT_EQ(v1_layer, w1_layer->children()[0]);
EXPECT_EQ(v4_layer, w1_layer->children()[1]);
EXPECT_EQ(w2_layer, w1_layer->children()[2]);
EXPECT_EQ(v7_layer, w1_layer->children()[3]);
ASSERT_EQ(1u, w2_layer->children().size());
EXPECT_EQ(v5_layer, w2_layer->children()[0]);
ASSERT_EQ(1u, v5_layer->children().size());
EXPECT_EQ(v6_layer, v5_layer->children()[0]);
ASSERT_EQ(0u, v6_layer->children().size());
EXPECT_EQ(2u, v7_layer->children().size());
EXPECT_EQ(v8_layer, v7_layer->children()[0]);
EXPECT_EQ(v9_layer, v7_layer->children()[1]);
// The cloned layers should have the same hierarchy as old.
ui::Layer* w1_new_layer = w1->GetNativeView()->layer();
EXPECT_EQ("w1", w1_new_layer->name());
ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_new_layer));
ui::Layer* w2_new_layer = w1_new_layer->children()[2];
ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_new_layer));
ui::Layer* v5_new_layer = w2_new_layer->children()[0];
ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_new_layer));
ui::Layer* v7_new_layer = w1_new_layer->children()[3];
ASSERT_EQ("v8 v9", ui::test::ChildLayerNamesAsString(*v7_new_layer));
}
// The views and the widgets are destroyed when AuraTestHelper::TearDown()
// destroys root_window().
}
// Verifies when a view is deleted it is removed from ViewStorage.
TEST_F(ViewTest, UpdateViewStorageOnDelete) {
ViewStorage* view_storage = ViewStorage::GetInstance();
const int storage_id = view_storage->CreateStorageID();
{
View view;
view_storage->StoreView(storage_id, &view);
}
EXPECT_TRUE(view_storage->RetrieveView(storage_id) == NULL);
}
////////////////////////////////////////////////////////////////////////////////
// NativeTheme
////////////////////////////////////////////////////////////////////////////////
void TestView::OnNativeThemeChanged(const ui::NativeTheme* native_theme) {
native_theme_ = native_theme;
}
TEST_F(ViewTest, OnNativeThemeChanged) {
TestView* test_view = new TestView();
EXPECT_FALSE(test_view->native_theme_);
TestView* test_view_child = new TestView();
EXPECT_FALSE(test_view_child->native_theme_);
// Child view added before the widget hierarchy exists should get the
// new native theme notification.
test_view->AddChildView(test_view_child);
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget->Init(params);
widget->GetRootView()->AddChildView(test_view);
EXPECT_TRUE(test_view->native_theme_);
EXPECT_EQ(widget->GetNativeTheme(), test_view->native_theme_);
EXPECT_TRUE(test_view_child->native_theme_);
EXPECT_EQ(widget->GetNativeTheme(), test_view_child->native_theme_);
// Child view added after the widget hierarchy exists should also get the
// notification.
TestView* test_view_child_2 = new TestView();
test_view->AddChildView(test_view_child_2);
EXPECT_TRUE(test_view_child_2->native_theme_);
EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_);
widget->CloseNow();
}
} // namespace views
| [
"nechayukanton@gmail.com"
] | nechayukanton@gmail.com |
9f94354c7165ea26f21b8c1035a7db0eb819cc35 | 3b72c7a278e150117b075b8b79f57fe0c7035325 | /main.cpp | a9d814c322e8af98fced19d03992b132a18723cd | [] | no_license | matejanus/cpp_tetris | a332a63cd59fbaeda7067051fcd666f43f3d1f96 | fb89edd5eb0c7b5bcc4e57599f5d0b1ee382f1ff | refs/heads/master | 2020-12-14T15:27:35.119990 | 2020-01-20T21:51:23 | 2020-01-20T21:51:23 | 234,787,959 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,087 | cpp | #include <iostream>
#include "includes/tetermino.hpp"
#include <array>
#include <curses.h>
#include <chrono>
#include <thread>
#include <vector>
#include <memory>
#include <random>
#include <stdio.h>
using namespace std::chrono_literals;
// std::array<std::string, 7> tetromino;
const std::array<std::string, 7> tetromino = {"..X."
"..X."
"..X."
"..X.",
"..X."
".XX."
".X.."
"....",
".X.."
".XX."
"..X."
"....",
"...."
".XX."
".XX."
"....",
"..X."
".XX."
"..X."
"....",
"...."
".XX."
"..X."
"..X.",
"...."
"..XX"
"..X."
"..X."};
const int nFieldHeight = {18};
const int nFieldWidth = {12};
const int nScreenWidth = {80};
const int nScreenHeight = {20};
int rotate(int px, int py, int r)
{
switch (r % 4)
{
case 0:
return py * 4 + px; //0deg
case 1:
return 12 + py - (px * 4); //90deg
case 2:
return 15 - (py * 4) - px; //180deg
case 3:
return 3 - py + (px * 4); //270deg
}
return 0;
}
bool doesPieceFit(int nTetromino, int nRotaion, int nPosX, int nPosY, const std::array<unsigned char, (nFieldWidth * nFieldHeight)> &gameField)
{
for (int x = 0; x < 4; x++)
for (int y = 0; y < 4; y++)
{
int piece = rotate(x, y, nRotaion);
int field = (nPosY + y) * nFieldWidth + (nPosX + x);
if (nPosX + x >= 0 && nPosX + x < nFieldWidth)
{
if (nPosY + y >= 0 && nPosY + y < nFieldHeight)
{
if (tetromino[nTetromino][piece] == 'X' && gameField[field] != 0)
return false;
}
}
}
return true;
}
int main()
{
std::array<unsigned char, (nFieldWidth * nFieldHeight)>
pField = {0};
auto t = Tetermino();
auto d = t.getData();
for (int x = 0; x < nFieldWidth; x++)
{
for (int y = 0; y < nFieldHeight; y++)
{
pField[y * nFieldWidth + x] = (x == 0 || x == nFieldWidth - 1 || y == nFieldHeight - 1) ? 9 : 0;
}
}
std::array<char, (nScreenWidth * nScreenHeight)> screen = {0};
for (int i = 0; i < nScreenWidth * nScreenHeight; i++)
{
screen[i] = L' ';
}
initscr();
WINDOW *win = newwin(nScreenHeight, nScreenWidth, 0, 0);
wrefresh(win);
wmove(win, 0, 0);
curs_set(0);
keypad(win, TRUE);
cbreak();
noecho();
nodelay(win, TRUE);
bool gameOver = {false};
int nCurrentRotation = {0};
int nCurrentX = {nFieldWidth / 2};
int nCurrentY = {0};
bool bRotateHold = {false};
int nSpeed = {20};
int nSpeedCounter = {0};
bool bForceDown = {0};
int nPieceCount = {0};
int nScore = {0};
std::vector<int> vLines;
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> gen(0, 6);
int nCurrentPiece = gen(rng);
while (!gameOver)
{
// Game timitng
std::this_thread::sleep_for(50ms);
nSpeedCounter++;
bForceDown = (nSpeedCounter == nSpeed);
// input
bool bKey[4] = {false};
// auto ch = wgetch(win);
switch (wgetch(win))
{
case KEY_RIGHT:
bKey[0] = true;
break;
case KEY_LEFT:
bKey[1] = true;
break;
case KEY_DOWN:
bKey[2] = true;
break;
case 122:
bKey[3] = true;
break;
default:
break;
}
// game logic
nCurrentX += (bKey[0] && doesPieceFit(nCurrentPiece, nCurrentRotation, nCurrentX + 1, nCurrentY, pField)) ? 1 : 0;
nCurrentX -= (bKey[1] && doesPieceFit(nCurrentPiece, nCurrentRotation, nCurrentX - 1, nCurrentY, pField)) ? 1 : 0;
nCurrentY += (bKey[2] && doesPieceFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY + 1, pField)) ? 1 : 0;
if (bKey[3])
{
nCurrentRotation += (!bRotateHold && doesPieceFit(nCurrentPiece, nCurrentRotation + 1, nCurrentX, nCurrentY, pField)) ? 1 : 0;
bRotateHold = true;
}
else
{
bRotateHold = false;
}
if (bForceDown)
{
if (doesPieceFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY + 1, pField))
{
nCurrentY++;
}
else
{
//lock te current piece
for (int px = 0; px < 4; px++)
for (int py = 0; py < 4; py++)
if (tetromino[nCurrentPiece][rotate(px, py, nCurrentRotation)] != '.')
{
pField[(nCurrentY + py) * nFieldWidth + (nCurrentX + px)] = nCurrentPiece + 1;
}
nPieceCount++;
if (nPieceCount % 10 == 0)
if (nSpeed >= 10)
nSpeed--;
//check for horizontal lines
for (int py = 0; py < 4; py++)
if (nCurrentY + py < nFieldHeight - 1)
{
bool bLine = true;
for (int px = 1; px < nFieldWidth - 1; px++)
bLine &= (pField[(nCurrentY + py) * nFieldWidth + px]) != 0;
if (bLine)
{
for (int px = 1; px < nFieldWidth - 1; px++)
pField[(nCurrentY + py) * nFieldWidth + px] = 8;
vLines.push_back(nCurrentY + py);
}
}
nScore += 25;
if (!vLines.empty())
{
nScore += (1 << vLines.size()) * 100;
}
//choose next piece
nCurrentX = nFieldWidth / 2;
nCurrentY = 0;
nCurrentRotation = 0;
nCurrentPiece = gen(rng);
//if piece does nof fit
gameOver = !doesPieceFit(nCurrentPiece, nCurrentRotation, nCurrentX, nCurrentY, pField);
}
nSpeedCounter = 0;
}
// render output
//draw field
for (int x = 0; x < nFieldWidth; x++)
for (int y = 0; y < nFieldHeight; y++)
screen[(y + 2) * nScreenWidth + (x + 2)] = " ABCDEFG=#"[pField[y * nFieldWidth + x]];
for (int px = 0; px < 4; px++)
for (int py = 0; py < 4; py++)
if (tetromino[nCurrentPiece][rotate(px, py, nCurrentRotation)] == 'X')
{
screen[(nCurrentY + py + 2) * nScreenWidth + (nCurrentX + px + 2)] = nCurrentPiece + 65;
}
snprintf(&screen[(nScreenHeight - 1) * nScreenWidth + nFieldWidth + 6], 16, "SCORE: %8d", nScore); // TODO: find another way of appending to screen
if (!vLines.empty())
{
wprintw(win, screen.data());
wmove(win, 0, 0);
wrefresh(win);
std::this_thread::sleep_for(400ms);
for (auto &v : vLines)
{
for (int px = 1; px < nFieldWidth - 1; px++)
{
for (int py = v; py > 0; py--)
{
pField[py * nFieldWidth + px] = pField[(py - 1) * nFieldWidth + px];
}
pField[px] = 0;
}
}
vLines.clear();
}
// display frame
wprintw(win, screen.data());
wmove(win, 0, 0);
wrefresh(win);
}
std::cout << "Game over! Score: " << nScore << std::endl;
getchar();
delwin(win);
endwin();
return 0;
} | [
"mate.janus@gmail.com"
] | mate.janus@gmail.com |
33f8ae8d68ef4f321e22c8cd662d6e921519e817 | c6401d48085c920367e271032d6af5e48e7ab0c8 | /StacksAndQueues/PriorityQueueNode.hpp | 73d3507a7a2e00e6e02958a3cc4d68d2ccd73060 | [
"MIT"
] | permissive | Bartleby2718/Introduction-To-Algorithms--CLRS- | bf4a0705ec154149065e2801614de6564e4e70be | cc1445e9cc926e9a021caad61d7ff56d57bdc6e2 | refs/heads/master | 2020-05-22T13:18:23.243475 | 2019-07-25T02:42:15 | 2019-07-25T02:42:58 | 186,355,777 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 577 | hpp | //
// Created by bartl on 06/21/2019.
//
#ifndef STACKSANDQUEUES_PRIORITYQUEUENODE_H
#define STACKSANDQUEUES_PRIORITYQUEUENODE_H
template<class T>
struct Node
{
unsigned index;
T element;
string toString()
{
return to_string(element) + "(index: " + to_string(index) + ")";
}
};
template<class T>
bool operator<(const Node<T> &lhs, const Node<T> &rhs)
{
return lhs.index < rhs.index;
}
template<class T>
bool operator>(const Node<T> &lhs, const Node<T> &rhs)
{
return operator<(rhs, lhs);
}
#endif //STACKSANDQUEUES_PRIORITYQUEUENODE_H
| [
"bartleby2718@gmail.com"
] | bartleby2718@gmail.com |
d48b1b4a5a0e4d70187070f5dec74d1e82074855 | e52d6cf6d24dc646415e9c4ac8ad7c801f4554fa | /Nsplit/CRFsparse/util.h | 39a407b7fb36b634b341843f64ef4e8b230f4298 | [] | no_license | a061105/AugmentedLimitedMem | aaf5c70133732014a4b322cfe9b79037bbc12067 | 5aa84702bc5f7ecaa9f761c0779aadf89ad26fd5 | refs/heads/master | 2020-12-24T06:54:16.792123 | 2016-08-12T03:41:14 | 2016-08-12T03:41:14 | 53,838,399 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,043 | h | #ifndef UTIL
#define UTIL
#include<map>
#include<vector>
#include<string>
#include<cmath>
#include <iomanip> // std::setprecision
#include <fstream>
#include <set>
using namespace std;
void split(string str, string pattern, vector<string>& tokens);
double maximum(double* values, int size);
double maximum(double* values, int size,int &posi);
int expOverSumExp(double *values, double *prob, int size);
double logSumExp(double* values, int size);
double normalize(double* values, int size);
void dataToFeatures( vector<vector<pair<int,double> > >& data, int dim, //intput
vector<vector<pair<int,double> > >& features //output
);
void softThd(double* w, vector<int> &act_set, double t_lambda);
void softThd(double* w, int size, double t_lambda);
double softThd(const double &x,const double &thd);
double l1_norm(double* w, int size);
double l1_norm(vector<double>& w);
double l2_norm(double* w,int size);
void shuffle(vector<int>& arr);
double sign(double v);
typedef vector<pair<int,double> > Feature;
#endif
| [
"a061105@gmail.com"
] | a061105@gmail.com |
b754ed3d07f3c1f7679b54780c265ac7ec9a6a22 | 0f5dbad0db4aabef3e86f9dd15cbce142f7775e2 | /455A - Boredom.cpp | a451aa5304d37f8b1e5fddbadfb746eda6aca356 | [] | no_license | OmarSalimMoussa/Competitive-Programming | fa8875867e516c98ea1c52b93be1129f3048222e | 1ef6dfb53f53a6eb89435eaf3d1711c1803ffc97 | refs/heads/master | 2021-05-04T13:16:54.179911 | 2019-03-25T22:26:19 | 2019-03-25T22:26:19 | 120,310,269 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define over LONG_LONG_MAX
ll inf = 1LL << 60;
ll mod = 1000000007;
double pi = acos(-1.0);
using namespace std;
ll w[100010];
vector<ll> a;
ll dp[100010][2];
int n;
ll solve(int pos, int last){
if(pos == a.size()) return 0;
if(dp[pos][last == a[pos]-1] != -1) return dp[pos][last == a[pos]-1];
if(last == a[pos]-1) return dp[pos][last == a[pos]-1] = solve(pos+1, last);
else return dp[pos][last == a[pos]-1] = max(solve(pos+1, last), w[a[pos]] + solve(pos+1, a[pos]));
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
map<ll,ll> m;
cin >> n;
for(int i=0 ; i<n ; i++){
int x;
cin >> x;
m[x]++;
}
a.clear();
for(map<ll,ll> :: iterator it = m.begin() ; it != m.end() ; ++it){
a.push_back(it->first);
w[it->first] = (it->first) * (it->second);
}
memset(dp, -1, sizeof(dp));
cout << solve(0,-1);
return 0;
}
| [
"noreply@github.com"
] | OmarSalimMoussa.noreply@github.com |
92a3dff65a5c52dbd68ba8fdd4afe7e7faaab07a | 64e4fabf9b43b6b02b14b9df7e1751732b30ad38 | /src/chromium/gen/gen_combined/third_party/blink/public/mojom/frame/navigation_initiator.mojom-shared.cc | 9f4748f65a7b20a5d2402d04e1f6be3b049fa6ac | [
"BSD-3-Clause"
] | permissive | ivan-kits/skia-opengl-emscripten | 8a5ee0eab0214c84df3cd7eef37c8ba54acb045e | 79573e1ee794061bdcfd88cacdb75243eff5f6f0 | refs/heads/master | 2023-02-03T16:39:20.556706 | 2020-12-25T14:00:49 | 2020-12-25T14:00:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,679 | 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.
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4065)
#endif
#include "third_party/blink/public/mojom/frame/navigation_initiator.mojom-shared.h"
#include <utility>
#include "base/logging.h"
#include "base/stl_util.h" // for base::size()
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_context.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/blink/public/mojom/frame/navigation_initiator.mojom-params-data.h"
namespace blink {
namespace mojom {
std::ostream& operator<<(std::ostream& os, WebContentSecurityPolicyType value) {
switch(value) {
case WebContentSecurityPolicyType::WebContentSecurityPolicyTypeReport:
return os << "WebContentSecurityPolicyType::WebContentSecurityPolicyTypeReport";
case WebContentSecurityPolicyType::WebContentSecurityPolicyTypeEnforce:
return os << "WebContentSecurityPolicyType::WebContentSecurityPolicyTypeEnforce";
default:
return os << "Unknown WebContentSecurityPolicyType value: " << static_cast<int32_t>(value);
}
}
namespace internal {
// static
bool SourceLocation_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const SourceLocation_Data* object = static_cast<const SourceLocation_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 24 }};
if (object->header_.version <=
kVersionSizes[base::size(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = base::size(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[base::size(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->url, 1, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams url_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->url, validation_context,
&url_validate_params)) {
return false;
}
return true;
}
SourceLocation_Data::SourceLocation_Data()
: header_({sizeof(*this), 0}) {}
// static
bool CSPViolationParams_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const CSPViolationParams_Data* object = static_cast<const CSPViolationParams_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 72 }};
if (object->header_.version <=
kVersionSizes[base::size(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = base::size(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[base::size(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->directive, 1, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams directive_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->directive, validation_context,
&directive_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->effective_directive, 2, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams effective_directive_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->effective_directive, validation_context,
&effective_directive_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->console_message, 3, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams console_message_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->console_message, validation_context,
&console_message_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->blocked_url, 4, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams blocked_url_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->blocked_url, validation_context,
&blocked_url_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->report_endpoints, 5, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams report_endpoints_validate_params(
0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr));
if (!mojo::internal::ValidateContainer(object->report_endpoints, validation_context,
&report_endpoints_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->header, 7, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams header_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->header, validation_context,
&header_validate_params)) {
return false;
}
if (!::blink::mojom::internal::WebContentSecurityPolicyType_Data
::Validate(object->disposition, validation_context))
return false;
if (!mojo::internal::ValidatePointerNonNullable(
object->source_location, 10, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->source_location, validation_context))
return false;
return true;
}
CSPViolationParams_Data::CSPViolationParams_Data()
: header_({sizeof(*this), 0}) {}
// static
bool NavigationInitiator_SendViolationReport_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
return false;
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
const NavigationInitiator_SendViolationReport_Params_Data* object = static_cast<const NavigationInitiator_SendViolationReport_Params_Data*>(data);
static constexpr struct {
uint32_t version;
uint32_t num_bytes;
} kVersionSizes[] = {{ 0, 16 }};
if (object->header_.version <=
kVersionSizes[base::size(kVersionSizes) - 1].version) {
// Scan in reverse order to optimize for more recent versions.
for (int i = base::size(kVersionSizes) - 1; i >= 0; --i) {
if (object->header_.version >= kVersionSizes[i].version) {
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
break;
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
}
} else if (object->header_.num_bytes <
kVersionSizes[base::size(kVersionSizes) - 1].num_bytes) {
ReportValidationError(
validation_context,
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->violation_params, 1, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->violation_params, validation_context))
return false;
return true;
}
NavigationInitiator_SendViolationReport_Params_Data::NavigationInitiator_SendViolationReport_Params_Data()
: header_({sizeof(*this), 0}) {}
} // namespace internal
} // namespace mojom
} // namespace blink
#if defined(_MSC_VER)
#pragma warning(pop)
#endif | [
"trofimov_d_a@magnit.ru"
] | trofimov_d_a@magnit.ru |
923b681d1e3b359c140134d4c02d8afad1d8535f | 719b9668d421765586405b8478927b026f7e0336 | /projects/lang/runtime/runtime.cpp | 136af4369f8b1f01bbb3f8f04607fcc3c3287492 | [
"MIT"
] | permissive | yut148/taichi | f8208084483f1e2f7aad258fc1e046385d796576 | fecb8557e80a294d98347d71b1ad0fd2f43865b0 | refs/heads/master | 2022-02-23T17:43:19.995584 | 2019-10-02T15:15:51 | 2019-10-02T15:15:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,507 | cpp | // This file will only be compiled with clang into llvm bitcode
// Generated bitcode will likely get inline for performance.
#include <type_traits>
#include <atomic>
#define FORCEINLINE __attribute__((always_inline))
#define STRUCT_FIELD(S, F) \
extern "C" decltype(S::F) S##_get_##F(S *s) { \
return s->F; \
} \
extern "C" decltype(S::F) *S##_get_ptr_##F(S *s) { \
return &(s->F); \
} \
extern "C" void S##_set_##F(S *s, decltype(S::F) f) { \
s->F = f; \
}
#define STRUCT_FIELD_ARRAY(S, F) \
extern "C" std::remove_all_extents_t<decltype(S::F)> S##_get_##F(S *s, \
int i) { \
return s->F[i]; \
} \
extern "C" void S##_set_##F(S *s, int i, \
std::remove_all_extents_t<decltype(S::F)> f) { \
s->F[i] = f; \
}
using float32 = float;
constexpr int taichi_max_num_indices = 4;
constexpr int taichi_max_num_args = 8;
using uint8 = uint8_t;
using Ptr = uint8 *;
using ContextArgType = long long;
extern "C" {
int printf(const char *, ...);
struct PhysicalCoordinates {
int val[taichi_max_num_indices];
};
STRUCT_FIELD_ARRAY(PhysicalCoordinates, val);
struct Context {
void *buffer;
ContextArgType args[taichi_max_num_args];
void *leaves;
int num_leaves;
void *cpu_profiler;
Ptr runtime;
};
STRUCT_FIELD_ARRAY(Context, args);
STRUCT_FIELD(Context, runtime);
STRUCT_FIELD(Context, buffer);
float32 atomic_add_cpu_f32(volatile float32 *dest, float32 inc) {
float32 old_val;
float32 new_val;
do {
old_val = *dest;
new_val = old_val + inc;
#if defined(__clang__)
} while (!__atomic_compare_exchange(dest, &old_val, &new_val, true,
std::memory_order::memory_order_seq_cst,
std::memory_order::memory_order_seq_cst));
#else
} while (!__atomic_compare_exchange((float32 *)dest, &old_val, &new_val, true,
std::memory_order::memory_order_seq_cst,
std::memory_order::memory_order_seq_cst));
#endif
return old_val;
}
// These structures are accessible by both the LLVM backend and this C++ runtime
// file here (for building complex runtime functions in C++)
// These structs contain some "template parameters"
// Common Attributes
struct StructMeta {
int snode_id;
std::size_t element_size;
int max_num_elements;
Ptr (*lookup_element)(Ptr, Ptr, int i);
Ptr (*from_parent_element)(Ptr);
bool (*is_active)(Ptr, Ptr, int i);
int (*get_num_elements)(Ptr, Ptr);
void (*refine_coordinates)(PhysicalCoordinates *inp_coord,
PhysicalCoordinates *refined_coord,
int index);
};
STRUCT_FIELD(StructMeta, snode_id)
STRUCT_FIELD(StructMeta, element_size)
STRUCT_FIELD(StructMeta, max_num_elements)
STRUCT_FIELD(StructMeta, get_num_elements);
STRUCT_FIELD(StructMeta, lookup_element);
STRUCT_FIELD(StructMeta, from_parent_element);
STRUCT_FIELD(StructMeta, refine_coordinates);
STRUCT_FIELD(StructMeta, is_active);
// Specialized Attributes and functions
struct DenseMeta : public StructMeta {
bool bitmasked;
int morton_dim;
};
STRUCT_FIELD(DenseMeta, bitmasked)
STRUCT_FIELD(DenseMeta, morton_dim)
void Dense_activate(Ptr meta, Ptr node, int i) {
}
bool Dense_is_active(Ptr meta, Ptr node, int i) {
return true;
}
void *Dense_lookup_element(Ptr meta, Ptr node, int i) {
return node + ((StructMeta *)meta)->element_size * i;
}
int Dense_get_num_elements(Ptr meta, Ptr node) {
return ((StructMeta *)meta)->max_num_elements;
}
struct RootMeta : public StructMeta {
int tag;
};
STRUCT_FIELD(RootMeta, tag);
void Root_activate(Ptr meta, Ptr node, int i) {
}
bool Root_is_active(Ptr meta, Ptr node, int i) {
return true;
}
void *Root_lookup_element(Ptr meta, Ptr node, int i) {
// only one element
return node;
}
int Root_get_num_elements(Ptr meta, Ptr node) {
return 1;
}
void *taichi_allocate_aligned(std::size_t size, int alignment);
void *taichi_allocate(std::size_t size) {
return taichi_allocate_aligned(size, 1);
}
void ___stubs___() {
printf("");
taichi_allocate(1);
taichi_allocate_aligned(1, 1);
}
struct Element {
uint8 *element;
int loop_bounds[2];
PhysicalCoordinates pcoord;
};
STRUCT_FIELD(Element, element);
STRUCT_FIELD(Element, pcoord);
STRUCT_FIELD_ARRAY(Element, loop_bounds);
struct ElementList {
Element *elements;
int tail;
};
void ElementList_initialize(ElementList *element_list) {
element_list->elements = (Element *)taichi_allocate(1024 * 1024 * 1024);
element_list->tail = 0;
}
void ElementList_insert(ElementList *element_list, Element *element) {
element_list->elements[element_list->tail] = *element;
element_list->tail++;
}
void ElementList_clear(ElementList *element_list) {
element_list->tail = 0;
}
// Is "runtime" a correct name, even if it is created after the data layout is
// materialized?
struct Runtime {
ElementList *element_lists[1024];
};
STRUCT_FIELD_ARRAY(Runtime, element_lists);
Ptr Runtime_initialize(Runtime **runtime_ptr,
int num_snodes,
uint64_t root_size,
int root_id) {
*runtime_ptr = (Runtime *)taichi_allocate(sizeof(Runtime));
Runtime *runtime = *runtime_ptr;
printf("Initializing runtime with %d elements\n", num_snodes);
for (int i = 0; i < num_snodes; i++) {
runtime->element_lists[i] =
(ElementList *)taichi_allocate(sizeof(ElementList));
ElementList_initialize(runtime->element_lists[i]);
}
// Assuming num_snodes - 1 is the root
auto root_ptr = taichi_allocate(root_size);
Element elem;
elem.loop_bounds[0] = 0;
elem.loop_bounds[1] = 1;
elem.element = (Ptr)root_ptr;
for (int i = 0; i < taichi_max_num_indices; i++) {
elem.pcoord.val[i] = 0;
}
ElementList_insert(runtime->element_lists[root_id], &elem);
printf("Runtime initialized.\n");
return (Ptr)root_ptr;
}
// "Element", "component" are different concepts
// ultimately all function calls here will be inlined
void element_listgen(Runtime *runtime, StructMeta *parent, StructMeta *child) {
auto parent_list = runtime->element_lists[parent->snode_id];
int num_parent_elements = parent_list->tail;
// printf("num_parent_elements %d\n", num_parent_elements);
auto child_list = runtime->element_lists[child->snode_id];
for (int i = 0; i < num_parent_elements; i++) {
auto element = parent_list->elements[i];
auto ch_component = child->from_parent_element(element.element);
int ch_num_elements = child->get_num_elements((Ptr)child, ch_component);
// printf("ch_num_parent_elements %d\n", ch_num_elements);
for (int j = 0; j < ch_num_elements; j++) {
auto ch_element = child->lookup_element((Ptr)child, element.element, j);
// printf("j %d\n", j);
if (child->is_active((Ptr)child, ch_component, j)) {
// printf("j! %d\n", j);
Element elem;
elem.element = ch_element;
elem.loop_bounds[0] = 0;
elem.loop_bounds[1] = child->get_num_elements((Ptr)child, ch_element);
PhysicalCoordinates refined_coord;
child->refine_coordinates(&element.pcoord, &refined_coord, j);
/*
printf("snode id %d\n", child->snode_id);
for (int k = 0; k < taichi_max_num_indices; k++) {
printf(" %d\n", refined_coord.val[k]);
}
*/
elem.pcoord = refined_coord;
ElementList_insert(child_list, &elem);
}
}
}
}
void for_each_block(Context *context,
int snode_id,
void (*task)(Context *, Element *)) {
auto list = ((Runtime *)context->runtime)->element_lists[snode_id];
for (int i = 0; i < list->tail; i++) {
task(context, &list->elements[i]);
}
}
int ti_cuda_tid_x() {
return 0;
}
void cuda_add(float *a, float *b, float *c) {
auto i = ti_cuda_tid_x();
c[i] = a[i] + b[i];
}
}
| [
"yuanmhu@gmail.com"
] | yuanmhu@gmail.com |
8ab12cfbb0447560230698d0f7a93bd730e7b4f3 | 22c300690f403c57297fb3d7a1e7a9bf820b85cf | /src/controls/QskScrollView.cpp | a61be872408339eb622c80cc1a8343b23338c446 | [
"BSD-3-Clause"
] | permissive | SammyEnigma/qskinny | 8cf88ae5a7be791f0745b4aba5e5338d94879f99 | db056e783754b7971d737a88ac86a7be97eea6d2 | refs/heads/master | 2023-08-24T23:16:53.923549 | 2023-04-11T12:56:39 | 2023-04-11T13:54:24 | 509,579,338 | 0 | 0 | BSD-3-Clause | 2023-09-14T06:48:12 | 2022-07-01T20:19:54 | C++ | UTF-8 | C++ | false | false | 8,069 | cpp | /******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#include "QskScrollView.h"
#include "QskAnimationHint.h"
#include "QskBoxBorderMetrics.h"
#include "QskEvent.h"
QSK_SUBCONTROL( QskScrollView, Panel )
QSK_SUBCONTROL( QskScrollView, Viewport )
QSK_SUBCONTROL( QskScrollView, HorizontalScrollBar )
QSK_SUBCONTROL( QskScrollView, HorizontalScrollHandle )
QSK_SUBCONTROL( QskScrollView, VerticalScrollBar )
QSK_SUBCONTROL( QskScrollView, VerticalScrollHandle )
QSK_SYSTEM_STATE( QskScrollView, VerticalHandlePressed, QskAspect::FirstSystemState << 1 )
QSK_SYSTEM_STATE( QskScrollView, HorizontalHandlePressed, QskAspect::FirstSystemState << 2 )
class QskScrollView::PrivateData
{
public:
PrivateData()
: horizontalScrollBarPolicy( Qt::ScrollBarAsNeeded )
, verticalScrollBarPolicy( Qt::ScrollBarAsNeeded )
, isScrolling( 0 )
{
}
Qt::ScrollBarPolicy horizontalScrollBarPolicy;
Qt::ScrollBarPolicy verticalScrollBarPolicy;
qreal scrollPressPos;
int isScrolling;
};
QskScrollView::QskScrollView( QQuickItem* parent )
: Inherited( parent )
, m_data( new PrivateData() )
{
}
QskScrollView::~QskScrollView()
{
}
QskAnimationHint QskScrollView::flickHint() const
{
return effectiveAnimation( QskAspect::Metric,
QskScrollView::Viewport, QskAspect::NoState );
}
void QskScrollView::setVerticalScrollBarPolicy( Qt::ScrollBarPolicy policy )
{
if ( policy != m_data->verticalScrollBarPolicy )
{
m_data->verticalScrollBarPolicy = policy;
update();
Q_EMIT verticalScrollBarPolicyChanged();
}
}
Qt::ScrollBarPolicy QskScrollView::verticalScrollBarPolicy() const
{
return m_data->verticalScrollBarPolicy;
}
void QskScrollView::setHorizontalScrollBarPolicy( Qt::ScrollBarPolicy policy )
{
if ( policy != m_data->horizontalScrollBarPolicy )
{
m_data->horizontalScrollBarPolicy = policy;
update();
Q_EMIT horizontalScrollBarPolicyChanged();
}
}
Qt::ScrollBarPolicy QskScrollView::horizontalScrollBarPolicy() const
{
return m_data->horizontalScrollBarPolicy;
}
bool QskScrollView::isScrolling( Qt::Orientation orientation ) const
{
return m_data->isScrolling == orientation;
}
QRectF QskScrollView::viewContentsRect() const
{
// This code should be done in the skinlet. TODO ...
const qreal bw = boxBorderMetricsHint( Viewport ).widthAt( Qt::TopEdge );
const QRectF r = subControlRect( Viewport );
return r.adjusted( bw, bw, -bw, -bw );
}
void QskScrollView::mousePressEvent( QMouseEvent* event )
{
const auto mousePos = qskMousePosition( event );
if ( subControlRect( VerticalScrollBar ).contains( mousePos ) )
{
const QRectF handleRect = subControlRect( VerticalScrollHandle );
if ( handleRect.contains( mousePos ) )
{
m_data->isScrolling = Qt::Vertical;
m_data->scrollPressPos = mousePos.y();
setSkinStateFlag( VerticalHandlePressed, true );
}
else
{
const QRectF vRect = viewContentsRect();
qreal y = scrollPos().y();
if ( mousePos.y() < handleRect.top() )
y -= vRect.height();
else
y += vRect.height();
setScrollPos( QPointF( scrollPos().x(), y ) );
}
return;
}
if ( subControlRect( HorizontalScrollBar ).contains( mousePos ) )
{
const QRectF handleRect = subControlRect( HorizontalScrollHandle );
if ( handleRect.contains( mousePos ) )
{
m_data->isScrolling = Qt::Horizontal;
m_data->scrollPressPos = mousePos.x();
setSkinStateFlag( HorizontalHandlePressed, true );
}
else
{
const QRectF vRect = viewContentsRect();
qreal x = scrollPos().x();
if ( mousePos.x() < handleRect.left() )
x -= vRect.width();
else
x += vRect.width();
setScrollPos( QPointF( x, scrollPos().y() ) );
}
return;
}
Inherited::mousePressEvent( event );
}
void QskScrollView::mouseMoveEvent( QMouseEvent* event )
{
if ( !m_data->isScrolling )
{
Inherited::mouseMoveEvent( event );
return;
}
const auto mousePos = qskMousePosition( event );
QPointF pos = scrollPos();
if ( m_data->isScrolling == Qt::Horizontal )
{
const qreal dx = mousePos.x() - m_data->scrollPressPos;
const qreal w = subControlRect( HorizontalScrollBar ).width();
pos.rx() += dx / w * scrollableSize().width();
m_data->scrollPressPos = mousePos.x();
}
else if ( m_data->isScrolling == Qt::Vertical )
{
const qreal dy = mousePos.y() - m_data->scrollPressPos;
const qreal h = subControlRect( VerticalScrollBar ).height();
pos.ry() += dy / h * scrollableSize().height();
m_data->scrollPressPos = mousePos.y();
}
if ( pos != scrollPos() )
setScrollPos( pos );
}
void QskScrollView::mouseReleaseEvent( QMouseEvent* event )
{
if ( !m_data->isScrolling )
{
Inherited::mouseReleaseEvent( event );
return;
}
m_data->isScrolling = 0;
m_data->scrollPressPos = 0;
setSkinStateFlag( HorizontalHandlePressed, false );
setSkinStateFlag( VerticalHandlePressed, false );
}
#ifndef QT_NO_WHEELEVENT
QPointF QskScrollView::scrollOffset( const QWheelEvent* event ) const
{
QPointF offset;
const auto pos = qskWheelPosition( event );
const auto viewRect = viewContentsRect();
if ( subControlRect( VerticalScrollBar ).contains( pos ) )
{
const auto steps = qskWheelSteps( event );
offset.setY( steps );
}
else if ( subControlRect( HorizontalScrollBar ).contains( pos ) )
{
const auto steps = qskWheelSteps( event );
offset.setX( steps );
}
else if ( viewRect.contains( pos ) )
{
offset = event->pixelDelta();
if ( offset.isNull() )
offset = event->angleDelta() / QWheelEvent::DefaultDeltasPerStep;
}
if ( !offset.isNull() )
{
const auto vs = viewRect.size() / 3.0;
offset.rx() *= vs.width();
offset.ry() *= vs.height();
}
return offset;
}
#endif
Qt::Orientations QskScrollView::scrollableOrientations() const
{
// layoutRect ???
const QRectF vr = contentsRect();
auto policyVertical = m_data->verticalScrollBarPolicy;
auto policyHorizontal = m_data->horizontalScrollBarPolicy;
if ( policyVertical == Qt::ScrollBarAsNeeded )
{
qreal height = vr.height();
if ( policyHorizontal == Qt::ScrollBarAlwaysOn )
height -= metric( HorizontalScrollBar | QskAspect::Size );
if ( scrollableSize().height() > height )
policyVertical = Qt::ScrollBarAlwaysOn;
}
if ( policyHorizontal == Qt::ScrollBarAsNeeded )
{
qreal width = vr.width();
if ( policyVertical == Qt::ScrollBarAlwaysOn )
width -= metric( VerticalScrollBar | QskAspect::Size );
if ( scrollableSize().width() > width )
{
policyHorizontal = Qt::ScrollBarAlwaysOn;
// we have to check the vertical once more
if ( ( policyVertical == Qt::ScrollBarAsNeeded ) &&
( scrollableSize().height() >
vr.height() - metric( HorizontalScrollBar | QskAspect::Size ) ) )
{
policyVertical = Qt::ScrollBarAlwaysOn;
}
}
}
Qt::Orientations orientations;
if ( policyHorizontal == Qt::ScrollBarAlwaysOn )
orientations |= Qt::Horizontal;
if ( policyVertical == Qt::ScrollBarAlwaysOn )
orientations |= Qt::Vertical;
return orientations;
}
#include "moc_QskScrollView.cpp"
| [
"Uwe.Rathmann@tigertal.de"
] | Uwe.Rathmann@tigertal.de |
bba455c6d42323289c38187b0c5ea2a45299f24a | 60d041c38740b66deab427bc3c75572713dd04aa | /DXCore/syCollision.h | 4cbf8a47ad93f85eb710b89a389bf0cc8625aa6f | [] | no_license | siyeon-lee/3dMax | 08ca9a2b53733953c60bd288fbfbcb9acc2a352e | f2cb876eb134eaea411be20469be10e219489c6d | refs/heads/master | 2022-03-05T02:20:34.789840 | 2019-11-01T09:04:09 | 2019-11-01T09:04:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 413 | h | #pragma once
#include "syStd.h"
class syCollision
{
public:
syCollision();
~syCollision();
public:
static bool RectInPt(RECT rt, POINT pt);
static bool RectInPt(RECT rt, syPoint pt);
static bool RectInRect(RECT rt1, RECT rt2);
static bool SphereInSphere(RECT rt1, RECT rt2);
static bool SphereInPoint(sySphere rt, POINT pos);
static bool SphereInPoint(sySphere rt, syPoint pos);
};
| [
"noreply@github.com"
] | siyeon-lee.noreply@github.com |
d8337f6d5fb0d2dad253755205f5b82ebb371c8c | 73ee941896043f9b3e2ab40028d24ddd202f695f | /external/chromium_org/content/renderer/gpu/input_handler_proxy.cc | 1f88e6278419d316e6f3872e392b5e0f14a207ab | [
"BSD-3-Clause"
] | permissive | CyFI-Lab-Public/RetroScope | d441ea28b33aceeb9888c330a54b033cd7d48b05 | 276b5b03d63f49235db74f2c501057abb9e79d89 | refs/heads/master | 2022-04-08T23:11:44.482107 | 2016-09-22T20:15:43 | 2016-09-22T20:15:43 | 58,890,600 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 16,078 | cc | // Copyright (c) 2013 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 "content/renderer/gpu/input_handler_proxy.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "content/renderer/gpu/input_handler_proxy_client.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/latency_info.h"
using WebKit::WebFloatPoint;
using WebKit::WebFloatSize;
using WebKit::WebGestureEvent;
using WebKit::WebInputEvent;
using WebKit::WebMouseWheelEvent;
using WebKit::WebPoint;
using WebKit::WebTouchEvent;
namespace {
void SendScrollLatencyUma(const WebInputEvent& event,
const ui::LatencyInfo& latency_info) {
if (!(event.type == WebInputEvent::GestureScrollBegin ||
event.type == WebInputEvent::GestureScrollUpdate ||
event.type == WebInputEvent::GestureScrollUpdateWithoutPropagation))
return;
ui::LatencyInfo::LatencyMap::const_iterator it =
latency_info.latency_components.find(std::make_pair(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0));
if (it == latency_info.latency_components.end())
return;
base::TimeDelta delta = base::TimeTicks::HighResNow() - it->second.event_time;
for (size_t i = 0; i < it->second.event_count; ++i) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Event.Latency.RendererImpl.GestureScroll",
delta.InMicroseconds(),
0,
200000,
100);
}
} // namespace
}
namespace content {
InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler)
: client_(NULL),
input_handler_(input_handler),
#ifndef NDEBUG
expect_scroll_update_end_(false),
expect_pinch_update_end_(false),
#endif
gesture_scroll_on_impl_thread_(false),
gesture_pinch_on_impl_thread_(false),
fling_may_be_active_on_main_thread_(false),
fling_overscrolled_horizontally_(false),
fling_overscrolled_vertically_(false) {
input_handler_->BindToClient(this);
}
InputHandlerProxy::~InputHandlerProxy() {}
void InputHandlerProxy::WillShutdown() {
input_handler_ = NULL;
DCHECK(client_);
client_->WillShutdown();
}
void InputHandlerProxy::SetClient(InputHandlerProxyClient* client) {
DCHECK(!client_ || !client);
client_ = client;
}
InputHandlerProxy::EventDisposition
InputHandlerProxy::HandleInputEventWithLatencyInfo(
const WebInputEvent& event,
const ui::LatencyInfo& latency_info) {
DCHECK(input_handler_);
SendScrollLatencyUma(event, latency_info);
InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event);
if (disposition != DID_NOT_HANDLE)
input_handler_->SetLatencyInfoForInputEvent(latency_info);
return disposition;
}
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
const WebInputEvent& event) {
DCHECK(client_);
DCHECK(input_handler_);
if (event.type == WebInputEvent::MouseWheel) {
const WebMouseWheelEvent& wheel_event =
*static_cast<const WebMouseWheelEvent*>(&event);
if (wheel_event.scrollByPage) {
// TODO(jamesr): We don't properly handle scroll by page in the compositor
// thread, so punt it to the main thread. http://crbug.com/236639
return DID_NOT_HANDLE;
}
cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel);
switch (scroll_status) {
case cc::InputHandler::ScrollStarted: {
TRACE_EVENT_INSTANT2(
"renderer",
"InputHandlerProxy::handle_input wheel scroll",
TRACE_EVENT_SCOPE_THREAD,
"deltaX",
-wheel_event.deltaX,
"deltaY",
-wheel_event.deltaY);
bool did_scroll = input_handler_->ScrollBy(
gfx::Point(wheel_event.x, wheel_event.y),
gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY));
input_handler_->ScrollEnd();
return did_scroll ? DID_HANDLE : DROP_EVENT;
}
case cc::InputHandler::ScrollIgnored:
// TODO(jamesr): This should be DROP_EVENT, but in cases where we fail
// to properly sync scrollability it's safer to send the event to the
// main thread. Change back to DROP_EVENT once we have synchronization
// bugs sorted out.
return DID_NOT_HANDLE;
case cc::InputHandler::ScrollOnMainThread:
return DID_NOT_HANDLE;
}
} else if (event.type == WebInputEvent::GestureScrollBegin) {
DCHECK(!gesture_scroll_on_impl_thread_);
#ifndef NDEBUG
DCHECK(!expect_scroll_update_end_);
expect_scroll_update_end_ = true;
#endif
const WebGestureEvent& gesture_event =
*static_cast<const WebGestureEvent*>(&event);
cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
gfx::Point(gesture_event.x, gesture_event.y),
cc::InputHandler::Gesture);
switch (scroll_status) {
case cc::InputHandler::ScrollStarted:
gesture_scroll_on_impl_thread_ = true;
return DID_HANDLE;
case cc::InputHandler::ScrollOnMainThread:
return DID_NOT_HANDLE;
case cc::InputHandler::ScrollIgnored:
return DROP_EVENT;
}
} else if (event.type == WebInputEvent::GestureScrollUpdate) {
#ifndef NDEBUG
DCHECK(expect_scroll_update_end_);
#endif
if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_)
return DID_NOT_HANDLE;
const WebGestureEvent& gesture_event =
*static_cast<const WebGestureEvent*>(&event);
bool did_scroll = input_handler_->ScrollBy(
gfx::Point(gesture_event.x, gesture_event.y),
gfx::Vector2dF(-gesture_event.data.scrollUpdate.deltaX,
-gesture_event.data.scrollUpdate.deltaY));
return did_scroll ? DID_HANDLE : DROP_EVENT;
} else if (event.type == WebInputEvent::GestureScrollEnd) {
#ifndef NDEBUG
DCHECK(expect_scroll_update_end_);
expect_scroll_update_end_ = false;
#endif
input_handler_->ScrollEnd();
if (!gesture_scroll_on_impl_thread_)
return DID_NOT_HANDLE;
gesture_scroll_on_impl_thread_ = false;
return DID_HANDLE;
} else if (event.type == WebInputEvent::GesturePinchBegin) {
#ifndef NDEBUG
DCHECK(!expect_pinch_update_end_);
expect_pinch_update_end_ = true;
#endif
input_handler_->PinchGestureBegin();
gesture_pinch_on_impl_thread_ = true;
return DID_HANDLE;
} else if (event.type == WebInputEvent::GesturePinchEnd) {
#ifndef NDEBUG
DCHECK(expect_pinch_update_end_);
expect_pinch_update_end_ = false;
#endif
gesture_pinch_on_impl_thread_ = false;
input_handler_->PinchGestureEnd();
return DID_HANDLE;
} else if (event.type == WebInputEvent::GesturePinchUpdate) {
#ifndef NDEBUG
DCHECK(expect_pinch_update_end_);
#endif
const WebGestureEvent& gesture_event =
*static_cast<const WebGestureEvent*>(&event);
input_handler_->PinchGestureUpdate(
gesture_event.data.pinchUpdate.scale,
gfx::Point(gesture_event.x, gesture_event.y));
return DID_HANDLE;
} else if (event.type == WebInputEvent::GestureFlingStart) {
const WebGestureEvent& gesture_event =
*static_cast<const WebGestureEvent*>(&event);
return HandleGestureFling(gesture_event);
} else if (event.type == WebInputEvent::GestureFlingCancel) {
if (CancelCurrentFling())
return DID_HANDLE;
else if (!fling_may_be_active_on_main_thread_)
return DROP_EVENT;
} else if (event.type == WebInputEvent::TouchStart) {
const WebTouchEvent& touch_event =
*static_cast<const WebTouchEvent*>(&event);
if (!input_handler_->HaveTouchEventHandlersAt(touch_event.touches[0]
.position))
return DROP_EVENT;
} else if (WebInputEvent::isKeyboardEventType(event.type)) {
CancelCurrentFling();
}
return DID_NOT_HANDLE;
}
InputHandlerProxy::EventDisposition
InputHandlerProxy::HandleGestureFling(
const WebGestureEvent& gesture_event) {
cc::InputHandler::ScrollStatus scroll_status;
if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) {
scroll_status = input_handler_->ScrollBegin(
gfx::Point(gesture_event.x, gesture_event.y),
cc::InputHandler::NonBubblingGesture);
} else {
if (!gesture_scroll_on_impl_thread_)
scroll_status = cc::InputHandler::ScrollOnMainThread;
else
scroll_status = input_handler_->FlingScrollBegin();
}
#ifndef NDEBUG
expect_scroll_update_end_ = false;
#endif
switch (scroll_status) {
case cc::InputHandler::ScrollStarted: {
if (gesture_event.sourceDevice == WebGestureEvent::Touchpad)
input_handler_->ScrollEnd();
fling_curve_.reset(client_->CreateFlingAnimationCurve(
gesture_event.sourceDevice,
WebFloatPoint(gesture_event.data.flingStart.velocityX,
gesture_event.data.flingStart.velocityY),
WebKit::WebSize()));
fling_overscrolled_horizontally_ = false;
fling_overscrolled_vertically_ = false;
TRACE_EVENT_ASYNC_BEGIN0(
"renderer",
"InputHandlerProxy::HandleGestureFling::started",
this);
fling_parameters_.delta =
WebFloatPoint(gesture_event.data.flingStart.velocityX,
gesture_event.data.flingStart.velocityY);
fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y);
fling_parameters_.globalPoint =
WebPoint(gesture_event.globalX, gesture_event.globalY);
fling_parameters_.modifiers = gesture_event.modifiers;
fling_parameters_.sourceDevice = gesture_event.sourceDevice;
input_handler_->ScheduleAnimation();
return DID_HANDLE;
}
case cc::InputHandler::ScrollOnMainThread: {
TRACE_EVENT_INSTANT0("renderer",
"InputHandlerProxy::HandleGestureFling::"
"scroll_on_main_thread",
TRACE_EVENT_SCOPE_THREAD);
fling_may_be_active_on_main_thread_ = true;
return DID_NOT_HANDLE;
}
case cc::InputHandler::ScrollIgnored: {
TRACE_EVENT_INSTANT0(
"renderer",
"InputHandlerProxy::HandleGestureFling::ignored",
TRACE_EVENT_SCOPE_THREAD);
if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) {
// We still pass the curve to the main thread if there's nothing
// scrollable, in case something
// registers a handler before the curve is over.
return DID_NOT_HANDLE;
}
return DROP_EVENT;
}
}
return DID_NOT_HANDLE;
}
void InputHandlerProxy::Animate(base::TimeTicks time) {
if (!fling_curve_)
return;
double monotonic_time_sec = (time - base::TimeTicks()).InSecondsF();
if (!fling_parameters_.startTime) {
fling_parameters_.startTime = monotonic_time_sec;
input_handler_->ScheduleAnimation();
return;
}
if (fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime,
this)) {
input_handler_->ScheduleAnimation();
} else {
TRACE_EVENT_INSTANT0("renderer",
"InputHandlerProxy::animate::flingOver",
TRACE_EVENT_SCOPE_THREAD);
CancelCurrentFling();
}
}
void InputHandlerProxy::MainThreadHasStoppedFlinging() {
fling_may_be_active_on_main_thread_ = false;
}
void InputHandlerProxy::DidOverscroll(const cc::DidOverscrollParams& params) {
DCHECK(client_);
if (fling_curve_) {
static const int kFlingOverscrollThreshold = 1;
fling_overscrolled_horizontally_ |=
std::abs(params.accumulated_overscroll.x()) >=
kFlingOverscrollThreshold;
fling_overscrolled_vertically_ |=
std::abs(params.accumulated_overscroll.y()) >=
kFlingOverscrollThreshold;
}
client_->DidOverscroll(params);
}
bool InputHandlerProxy::CancelCurrentFling() {
bool had_fling_animation = fling_curve_;
if (had_fling_animation &&
fling_parameters_.sourceDevice == WebGestureEvent::Touchscreen) {
input_handler_->ScrollEnd();
TRACE_EVENT_ASYNC_END0(
"renderer",
"InputHandlerProxy::HandleGestureFling::started",
this);
}
TRACE_EVENT_INSTANT1("renderer",
"InputHandlerProxy::CancelCurrentFling",
TRACE_EVENT_SCOPE_THREAD,
"had_fling_animation",
had_fling_animation);
fling_curve_.reset();
gesture_scroll_on_impl_thread_ = false;
fling_parameters_ = WebKit::WebActiveWheelFlingParameters();
return had_fling_animation;
}
bool InputHandlerProxy::TouchpadFlingScroll(
const WebFloatSize& increment) {
WebMouseWheelEvent synthetic_wheel;
synthetic_wheel.type = WebInputEvent::MouseWheel;
synthetic_wheel.deltaX = increment.width;
synthetic_wheel.deltaY = increment.height;
synthetic_wheel.hasPreciseScrollingDeltas = true;
synthetic_wheel.x = fling_parameters_.point.x;
synthetic_wheel.y = fling_parameters_.point.y;
synthetic_wheel.globalX = fling_parameters_.globalPoint.x;
synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
synthetic_wheel.modifiers = fling_parameters_.modifiers;
InputHandlerProxy::EventDisposition disposition =
HandleInputEvent(synthetic_wheel);
switch (disposition) {
case DID_HANDLE:
return true;
case DROP_EVENT:
break;
case DID_NOT_HANDLE:
TRACE_EVENT_INSTANT0("renderer",
"InputHandlerProxy::scrollBy::AbortFling",
TRACE_EVENT_SCOPE_THREAD);
// If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the
// main thread. In this case we need to schedule a commit and transfer the
// fling curve over to the main thread and run the rest of the wheels from
// there. This can happen when flinging a page that contains a scrollable
// subarea that we can't scroll on the thread if the fling starts outside
// the subarea but then is flung "under" the pointer.
client_->TransferActiveWheelFlingAnimation(fling_parameters_);
fling_may_be_active_on_main_thread_ = true;
CancelCurrentFling();
break;
}
return false;
}
static gfx::Vector2dF ToClientScrollIncrement(const WebFloatSize& increment) {
return gfx::Vector2dF(-increment.width, -increment.height);
}
void InputHandlerProxy::scrollBy(const WebFloatSize& increment) {
WebFloatSize clipped_increment;
if (!fling_overscrolled_horizontally_)
clipped_increment.width = increment.width;
if (!fling_overscrolled_vertically_)
clipped_increment.height = increment.height;
if (clipped_increment == WebFloatSize())
return;
TRACE_EVENT2("renderer",
"InputHandlerProxy::scrollBy",
"x",
clipped_increment.width,
"y",
clipped_increment.height);
bool did_scroll = false;
switch (fling_parameters_.sourceDevice) {
case WebGestureEvent::Touchpad:
did_scroll = TouchpadFlingScroll(clipped_increment);
break;
case WebGestureEvent::Touchscreen:
clipped_increment = ToClientScrollIncrement(clipped_increment);
did_scroll = input_handler_->ScrollBy(fling_parameters_.point,
clipped_increment);
break;
}
if (did_scroll) {
fling_parameters_.cumulativeScroll.width += clipped_increment.width;
fling_parameters_.cumulativeScroll.height += clipped_increment.height;
}
}
void InputHandlerProxy::notifyCurrentFlingVelocity(
const WebFloatSize& velocity) {
TRACE_EVENT2("renderer",
"InputHandlerProxy::notifyCurrentFlingVelocity",
"vx",
velocity.width,
"vy",
velocity.height);
input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity));
}
} // namespace content
| [
"ProjectRetroScope@gmail.com"
] | ProjectRetroScope@gmail.com |
2a33776f19fd712835758d387bfa794ae6eae7b9 | 30105cdf24a8ee004eb461b52e73f36372072c84 | /modifikacije/2020 avgust/mod/queue.cpp | 05f7bf48ded2256fdff51801f6b3f82592e1f9ea | [] | no_license | botuljina/ProcessorKernel | 4136a1fd5390353b725b60dc8ee81ce046da65d4 | d48cfe28dfa2633cde08eb3b7a98c96046caa9c4 | refs/heads/master | 2022-12-29T19:35:45.958675 | 2020-10-03T15:55:04 | 2020-10-03T15:55:04 | 256,285,852 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,752 | cpp | #include "queue.h"
#include "Timer.h"
#include <iostream.h>
#include "sPrintf.h"
#include "Thread.h"
queue::queue()
{
#ifndef BCC_BLOCK_IGNORE
lock();
#endif
firstNode = 0;
lastNode = 0;
queueLen = 0;
#ifndef BCC_BLOCK_IGNORE
unlock();
#endif
}
int queue::isEmpty(){
if(firstNode == 0) return 1;
else return 0;
}
void queue::printQueueElements()
{
#ifndef BCC_BLOCK_IGNORE
lock();
#endif
qnode* temp = firstNode;
syncPrintf("VELICINA queue-a je:%d\n************* \n",queueLen);
while(temp!=0)
{
if(temp!=0)syncPrintf("%d id niti.\n",(int)temp->element->myThread->getId());
temp=temp->next;
}
syncPrintf("\n************* \n");
#ifndef BCC_BLOCK_IGNORE
unlock();
#endif
}
void queue::put(PCB* _pcb)
{
#ifndef BCC_BLOCK_IGNORE
lock();
#endif
if(Timer::testingPhase)
{
if(this!= Timer::globalQueueForGettingIds) syncPrintf("Ubacivanje u neki drugi queue,id=%d,addr:%p,\n",_pcb->myThread->getId());
else syncPrintf("Ubacivanje u gloabal queue,id=%d\n",_pcb->myThread->getId());
}
if ( isEmpty( ) == 1 )
{
firstNode = new qnode(_pcb);
lastNode = firstNode;
queueLen++;
}
else
{
qnode *p = new qnode(_pcb);
lastNode->next = p;
lastNode = lastNode->next;
queueLen++;
}
if(Timer::testingPhase)
printQueueElements();
#ifndef BCC_BLOCK_IGNORE
unlock();
#endif
}
PCB* queue::get()
{
#ifndef BCC_BLOCK_IGNORE
lock();
#endif
qnode *temp ;
PCB* element_for_return = 0;
if ( isEmpty( ) == 0 )
{
queueLen--;
element_for_return = firstNode->element;
temp = firstNode;
//pomeram prvi
firstNode = firstNode->next;
delete temp;
}
if(Timer::testingPhase)
{
if(this!= Timer::globalQueueForGettingIds) syncPrintf("POP iz drugog queue-a,id=%d, addr:%p,\n",element_for_return->myThread->getId());
else syncPrintf("POP iz GLOBAL queue-a,id=%d\n",element_for_return->myThread->getId());
printQueueElements();
}
#ifndef BCC_BLOCK_IGNORE
unlock();
#endif
return element_for_return;
}
queue::~queue()
{
#ifndef BCC_BLOCK_IGNORE
lock();
#endif
while (isEmpty()==0)
get();
firstNode = 0;
lastNode = 0;
#ifndef BCC_BLOCK_IGNORE
unlock();
#endif
}
int queue::getQueueSize()
{
return queueLen;
}
Thread* queue::getThreadByIdSearchQueue(ID id)
{
qnode *temp = firstNode;
while(temp!=0)
{
if(temp->element->myThread->getId() == id)
{
return temp->element->myThread;
}
temp=temp->next;
}
return 0;
}
void queue::my_swap(qnode *node_1, qnode *node_2)
{
PCB* temp = node_1->element;
node_1->element = node_2 -> element;
node_2 -> element = temp;
}
void queue::sort()
{
int swapped;
qnode *lPtr; // left pointer will always point to the start of the list
qnode *rPrt = NULL; // right pointer will always point to the end of the list
do
{
swapped = 0;
lPtr = firstNode;
while(lPtr->next != rPrt)
{
//u ovoj ovde liniji samo ispravljam da li cu opadajuce ili rastuce
if (lPtr->element->myThread->getId() < lPtr->next->element->myThread->getId())
{
my_swap(lPtr, lPtr->next);
swapped = 1;
}
lPtr = lPtr->next;
}
//as the largest element is at the end of the list, assign that to rPtr as there is no need to
//check already sorted list
rPrt = lPtr;
}while(swapped);
}
//Funkcija: vadi sa odredjene pozicije PCB i uklanja element iz reda
PCB* queue::get_by_id(ID id)
{
qnode *cur = firstNode, *prev = 0, *old = 0;
while (cur) {
if (cur->element->myThread->getId() != id) {
prev = cur;
cur = cur->next;
} else {
old = cur;
cur = cur->next;
if (!prev)
firstNode = cur;
else
prev->next = cur;
if(old == lastNode)
lastNode = prev;
delete old;
queueLen--;
break;
}
}
}
| [
"lsimovic140@gmail.com"
] | lsimovic140@gmail.com |
5574c0b80e543a0068f7df92819476fb164dbc3e | 4b62cd73e5c255f2b1b0512421c510c011be2ec6 | /2019/roundB/Building_Palindromes.cpp | b7657c315a31b58975bd667cf74c8984d13123b7 | [] | no_license | dishankgoel/KickStart-Solutions | a48cce9421b3427c344eeabe51db5d0a4e9060aa | d51dd6265d44becd8eaa6c04e7db7d15bc35ab21 | refs/heads/master | 2023-07-30T07:25:19.830062 | 2021-09-11T18:57:18 | 2021-09-11T18:57:18 | 356,865,770 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,127 | cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
ll test_case() {
ll n, q; cin>>n>>q;
string blocks; cin>>blocks;
vector<vector<int>> dp(n, vector<int>(26, 0));
for(int i = 0; i < n; i++) {
if(i == 0) {
dp[0][blocks[0] - 'A'] = 1;
} else {
dp[i] = dp[i - 1];
dp[i][blocks[i] - 'A'] = dp[i][blocks[i] - 'A'] + 1;
}
}
ll ans = 0;
for(int i = 0; i < q; i++) {
ll l, r; cin>>l>>r;
l--; r--;
ll num_odd = 0;
for(int j = 0; j < 26; j++) {
int freq;
if(l == 0) {
freq = dp[r][j];
} else {
freq = dp[r][j] - dp[l - 1][j];
}
if(freq%2 == 1) {
num_odd++;
}
}
if(num_odd <= 1) {
ans++;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;cin>>t;
for(int case_no = 0; case_no < t; case_no++) {
ll ans = test_case();
cout<<"Case #"<<case_no+1<<": "<<ans<<"\n";
}
}
| [
"dishankgoel1729@gmail.com"
] | dishankgoel1729@gmail.com |
48a05db09bbb3f86f408101869e51cbd0a771f61 | 7c713739a64b22af2256f07d75447acf178586ac | /Source.cpp | 26c53f98834eca9a9813ea03665612702839d94a | [
"MIT"
] | permissive | kenjinote/SortingAlgorithmAnimations | 10c7cd5f4b233377093aa8444ea07b2431ae2ad1 | c42cc79c2c604c219ce2112bdc9ea6f126a1f1ad | refs/heads/master | 2023-02-23T17:16:47.612291 | 2023-02-08T15:05:06 | 2023-02-08T15:05:06 | 59,730,507 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,948 | cpp | #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include <windows.h>
TCHAR szClassName[] = TEXT("Window");
void Update(HWND hWnd)
{
Sleep(5);
InvalidateRect(hWnd, 0, 0);
UpdateWindow(hWnd);
}
VOID InsertionSortStep(HWND hWnd, int* pList, SIZE_T size)
{
for (SIZE_T i = 1; i < size; ++i)
{
const int tmp = pList[i];
if (pList[i - 1] > tmp)
{
SIZE_T j = i;
do {
pList[j] = pList[j - 1];
Update(hWnd);
--j;
} while (j > 0 && pList[j - 1] > tmp);
pList[j] = tmp;
Update(hWnd);
}
}
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND hButton;
static LPINT lpData;
static SIZE_T nMaxSize = 32;
switch (msg)
{
case WM_CREATE:
hButton = CreateWindow(TEXT("BUTTON"), TEXT("ソート"), WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, (HMENU)IDOK, ((LPCREATESTRUCT)lParam)->hInstance, 0);
lpData = (LPINT)GlobalAlloc(0, sizeof(INT) * nMaxSize);
for (SIZE_T i = 0; i < nMaxSize; ++i)
{
lpData[i] = (int)i + 1;
}
break;
case WM_SIZE:
MoveWindow(hButton, 10, 10, 256, 32, TRUE);
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EnableWindow(hButton, FALSE);
for (SIZE_T i = 0; i < nMaxSize; ++i)
{
const int temp = lpData[i];
SIZE_T index = rand() % nMaxSize;
lpData[i] = lpData[index];
lpData[index] = temp;
}
Update(hWnd);
InsertionSortStep(hWnd, lpData, nMaxSize);
InvalidateRect(hWnd, 0, 1);
EnableWindow(hButton, TRUE);
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
for (SIZE_T i = 0; i < nMaxSize; ++i)
{
RECT rect1 = { 10,50 + 20 * (int)i,lpData[i] * 10 + 10, 50 + 20 * (int)i + 10 };
RECT rect2 = { lpData[i] * 10 + 10,50 + 20 * (int)i,(int)nMaxSize * 10 + 10, 50 + 20 * (int)i + 10 };
FillRect(hdc, &rect1, (HBRUSH)GetStockObject(BLACK_BRUSH));
FillRect(hdc, &rect2, (HBRUSH)GetStockObject(WHITE_BRUSH));
}
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
GlobalFree(lpData);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASS wndclass = {
CS_HREDRAW | CS_VREDRAW,
WndProc,
0,
0,
hInstance,
0,
LoadCursor(0,IDC_ARROW),
(HBRUSH)(COLOR_WINDOW + 1),
0,
szClassName
};
RegisterClass(&wndclass);
HWND hWnd = CreateWindow(
szClassName,
TEXT("ソートアルゴリズムのアニメーション表示"),
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
0,
0,
hInstance,
0
);
ShowWindow(hWnd, SW_SHOWDEFAULT);
UpdateWindow(hWnd);
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
| [
"kenji256@gmail.com"
] | kenji256@gmail.com |
fc25b35580685e5875ded9c4455970437a4f1626 | d3d5089fa5c1ba5dea70d1f0de14d4d094b67e68 | /devel_isolated/controller_manager_msgs/include/controller_manager_msgs/ListControllerTypesResponse.h | 21dfb2a0cda9d9036fefabf5af3bdf73c362db27 | [] | no_license | akingse/ros_package_ws | d5408451e2fafd3314d53994b94585f95f2612c7 | 1d1ad9e9aecc90fa9335f29a802dc342a2a96612 | refs/heads/main | 2023-03-04T20:41:57.232496 | 2021-02-08T14:17:26 | 2021-02-08T14:17:26 | 337,102,292 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,122 | h | // Generated by gencpp from file controller_manager_msgs/ListControllerTypesResponse.msg
// DO NOT EDIT!
#ifndef CONTROLLER_MANAGER_MSGS_MESSAGE_LISTCONTROLLERTYPESRESPONSE_H
#define CONTROLLER_MANAGER_MSGS_MESSAGE_LISTCONTROLLERTYPESRESPONSE_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>
namespace controller_manager_msgs
{
template <class ContainerAllocator>
struct ListControllerTypesResponse_
{
typedef ListControllerTypesResponse_<ContainerAllocator> Type;
ListControllerTypesResponse_()
: types()
, base_classes() {
}
ListControllerTypesResponse_(const ContainerAllocator& _alloc)
: types(_alloc)
, base_classes(_alloc) {
(void)_alloc;
}
typedef std::vector<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > , typename ContainerAllocator::template rebind<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::other > _types_type;
_types_type types;
typedef std::vector<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > , typename ContainerAllocator::template rebind<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::other > _base_classes_type;
_base_classes_type base_classes;
typedef boost::shared_ptr< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> const> ConstPtr;
}; // struct ListControllerTypesResponse_
typedef ::controller_manager_msgs::ListControllerTypesResponse_<std::allocator<void> > ListControllerTypesResponse;
typedef boost::shared_ptr< ::controller_manager_msgs::ListControllerTypesResponse > ListControllerTypesResponsePtr;
typedef boost::shared_ptr< ::controller_manager_msgs::ListControllerTypesResponse const> ListControllerTypesResponseConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace controller_manager_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False}
// {'controller_manager_msgs': ['/home/akingse/tempopkg_ws/src/ros_control/controller_manager_msgs/msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../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< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
{
static const char* value()
{
return "c1d4cd11aefa9f97ba4aeb5b33987f4e";
}
static const char* value(const ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xc1d4cd11aefa9f97ULL;
static const uint64_t static_value2 = 0xba4aeb5b33987f4eULL;
};
template<class ContainerAllocator>
struct DataType< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
{
static const char* value()
{
return "controller_manager_msgs/ListControllerTypesResponse";
}
static const char* value(const ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
{
static const char* value()
{
return "string[] types\n\
string[] base_classes\n\
\n\
";
}
static const char* value(const ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.types);
stream.next(m.base_classes);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct ListControllerTypesResponse_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::controller_manager_msgs::ListControllerTypesResponse_<ContainerAllocator>& v)
{
s << indent << "types[]" << std::endl;
for (size_t i = 0; i < v.types.size(); ++i)
{
s << indent << " types[" << i << "]: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.types[i]);
}
s << indent << "base_classes[]" << std::endl;
for (size_t i = 0; i < v.base_classes.size(); ++i)
{
s << indent << " base_classes[" << i << "]: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.base_classes[i]);
}
}
};
} // namespace message_operations
} // namespace ros
#endif // CONTROLLER_MANAGER_MSGS_MESSAGE_LISTCONTROLLERTYPESRESPONSE_H
| [
"akingse@qq.com"
] | akingse@qq.com |
c72546fa09fc13fa5e70eb7afdc73c46f638f37d | eb827d7993b146cf507b57a45e420fffdf641eef | /camps/lksh_winter2020/day4/src/gen.cpp | 6dc0a5e989f5d58dff95773318a1ef513f8ad282 | [] | no_license | khbminus/code2020 | dfdbcae71d61d03d4457aad47ff7d4136e6fcc1e | a0d2230b0905df79ba78cb98353f4ba03f16e8b0 | refs/heads/master | 2023-07-16T16:08:20.629283 | 2021-08-29T20:35:14 | 2021-08-29T20:35:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int MAXN = 10;
int MAXC = 100;
int n = rnd() % MAXN + 1;
cout << n << '\n';
for (int i = 0; i < n; i++)
cout << rnd() % MAXC + 1 << " \n"[i + 1 == n];
} | [
"serega.haritontsev@gmail.com"
] | serega.haritontsev@gmail.com |
adeff6bf8c16e9d1b83dbafc621b030bf0b61b8a | c50c96c7618122a2566322afa75c44eb25e67296 | /sudokuboard.cc | c1ee87112cdc3644c962a659a9ec778a389b7a15 | [] | no_license | easiruwa/Sudoku | 6be0c2cc14859b2e9b8d5c766e033382e89633de | 7fd071f66478250ead9c00fa29fb3c1c603f8de8 | refs/heads/master | 2021-01-13T13:18:09.400178 | 2016-11-02T16:33:29 | 2016-11-02T16:33:29 | 72,659,568 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,235 | cc | /************************************************************************
File: sudokuboard.cc
Author: Eseosa Asiruwa
Date: 2/21/16
Assignment: Lab 3
Implemenation of the sudokuboard class.
************************************************************************/
#include <iostream>
#include "sudokuboard.h"
/*** Constructor ***/
sudokuboard::sudokuboard()
// Initializes board with blank spaces
{
for (size_t i = 0; i < 9; i++)
sboard[i] = "_________";
}
void sudokuboard::print()
// Print the board
{
for (size_t i = 0; i < 9; i++){
cout << sboard[i] << endl;
}
}
void sudokuboard::place(size_t r, size_t c, int n)
// Place numeral n at posiion (r,c)
{
sboard[r][c] = n + '0';
}
void sudokuboard::placeline(size_t p, string input)
// Places characters in board, line by line
{
sboard[p] = input;
}
bool sudokuboard::canplace(char num, size_t r, size_t c) const
// Checks empty spot to see if you can place given number. Returns a bool
// depending on if the number shows up in the same r, c, or 3x3
{
if (get(r,c) == '_'){
for (int j = 0; j < 9; j++){ // check rows
if (get(j,c) == num)
return false;
}
for (int k = 0; k < 9; k++){ // check cols
if (get(r,k) == num)
return false;
}
for (int y = 0; y < 3; y++){ // check 3x3
for (int x = 0; x < 3; x++){
if (get((r / 3) * 3 + y , (c / 3) * 3 + x) == num){
return false;
}
}
}
return true;
}
return false;
}
char sudokuboard::get(size_t r, size_t c) const
// Return char at position r,c
{
return sboard[r][c];
}
void sudokuboard::remove(size_t r, size_t c)
// Replace char at postion r,c with an empty space
{
sboard[r][c] = '_';
}
bool sudokuboard::solved()
// Check to see if there are any empty spaces on the board
{
for (int r = 0; r < 9; r++){
for (int c = 0; c < 9; c++){
if (sboard[r][c] == '_')
return false;
}
}
return true;
} | [
"easiruwa@hamilton.edu"
] | easiruwa@hamilton.edu |
0b4d76ad7c57c7ce3ad081dba47b17d093c9d76d | 8e63e4fd669ced86bf07b20be364da5a06bce70d | /SPOJ/BYTESE2 - The Great Ball.cpp | 573575c43f2ef46363f334fdb9e5c33b779d214d | [] | no_license | AliOsm/CompetitiveProgramming | 00a1e75a2635532651fcdfb0e478c009adf84032 | af25b7f806e9c22a2176bfd05a1406ce5f1492c3 | refs/heads/master | 2023-03-07T01:17:25.555911 | 2023-02-10T09:09:17 | 2023-02-10T09:09:17 | 70,904,119 | 125 | 58 | null | 2021-02-27T13:13:18 | 2016-10-14T11:29:55 | C++ | UTF-8 | C++ | false | false | 1,372 | cpp | #include <stdio.h>
#include <set>
#include <algorithm>
#include <memory.h>
using namespace std;
int const N = 1000;
int n, seg[4 * N], lazy[4 * N];
pair<int, int> a[N];
set<int> st;
int s, e;
void pro(int idx, int l, int r) {
seg[idx] += lazy[idx];
if(l != r)
lazy[idx << 1] += lazy[idx],
lazy[(idx << 1) + 1] += lazy[idx];
lazy[idx] = 0;
}
int update(int idx, int l, int r) {
if(lazy[idx] != 0)
pro(idx, l, r);
if(s > r || e < l)
return 0;
if(l >= s && r <= e) {
++lazy[idx];
pro(idx, l, r);
return seg[idx];
}
int m = (l + r) >> 1;
update(idx << 1, l, m);
update((idx << 1) + 1, m + 1, r);
return seg[idx] = max(seg[idx << 1], seg[(idx << 1) + 1]);
}
int main() {
int t, res;
scanf("%d", &t);
while(t-- != 0) {
st.clear();
memset(seg, 0, sizeof seg);
memset(lazy, 0, sizeof lazy);
scanf("%d", &n);
for(int i = 0; i < n; ++i) {
scanf("%d %d", &a[i].first, &a[i].second);
st.insert(a[i].first);
st.insert(a[i].second);
}
int cnt = 1;
for(set<int>::iterator it = st.begin(); it != st.end(); ++it, ++cnt)
for(int i = 0; i < n; ++i) {
if(a[i].first == (*it))
a[i].first = cnt;
if(a[i].second == (*it))
a[i].second = cnt;
}
res = 0;
for(int i = 0; i < n; ++i) {
s = a[i].first, e = a[i].second;
res = max(res, update(1, 1, N));
}
printf("%d\n", res);
}
return 0;
}
| [
"aliosm1997@gmail.com"
] | aliosm1997@gmail.com |
eb5219ac375fcf1a41a0b153db1b6f5be7f8925b | 401bfbcc3cdd53b0f646ce61e1c3ecc81fff9a50 | /src/cpp/record/Region.h | 733c818d2e5b9507c318621a5b9753c01d068b19 | [] | no_license | TU-Berlin-DIMA/tpch-gen | 807d41c6b40c0d265b31a7a95c0d0f97094ed1b9 | 736d88323e12871025aa3a3f4966b995d683c7d9 | refs/heads/master | 2016-09-05T17:39:23.546219 | 2014-09-10T13:14:21 | 2014-09-10T13:14:21 | 13,740,341 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 894 | h | #ifndef REGION_H_
#define REGION_H_
#include "record/base/BaseRegion.h"
namespace TPCHGen {
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// record type
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
class Region: public BaseRegion
{
public:
Region(const RegionMeta& meta)
: BaseRegion(meta)
{
}
};
} // namespace TPCHGen
namespace Myriad {
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// record serialize method specialization
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
template<>
inline void AbstractOutputCollector<TPCHGen::Region>::serialize(std::ostream& out, const TPCHGen::Region& record)
{
AbstractOutputCollector<TPCHGen::BaseRegion>::serialize(out, record);
}
} // namespace Myriad
#endif /* REGION_H_ */
| [
"alexander.s.alexandrov@gmail.com"
] | alexander.s.alexandrov@gmail.com |
d182a664e531d0a74a989a4e3c19fdee8b40850e | c969008ffeb3e4c6e21cd2cb86dd46b60b81840a | /Code/用0~2个的1,2,4,8,16合出N.cpp | 0aaf823468999d0fe1b07d657fa3366282f13bca | [] | no_license | Crasader/Code_GSL | 6b7ddd27b47133b5a1e5f5eade8ca61275deac00 | dcd5ef0a204b7dc6b8c58939fb52a515b5689be8 | refs/heads/master | 2022-02-13T17:05:07.682256 | 2019-09-09T08:21:17 | 2019-09-09T08:21:17 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,106 | cpp | // ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<math.h>
#include<time.h>
#include<set>
using namespace std;
int nums[63];//num[i]表示2^i的个数,只有0,1,2三个取值
//回溯法
int IsOk(long long n, int *nums, int len)
{
long long sum = 0;
for (int i = 0; i < len; i++)
sum += nums[i] * pow(2, i);
if (sum == n)
return 0;
else if (sum > n)
return -1;
else
return 1;
}
void solve(long long n, int index, int *nums, int len, int &count)
{
if (index >= len)
return;
for (int i = 0; i <= 2; i++)
{
nums[index] = i;
if (IsOk(n, nums, len) == 0)
count++;
else if (IsOk(n, nums, len) == 1)
solve(n, index + 1, nums, len, count);
}
nums[index] = 0;//回溯法,要撤回上一步的假设
}
long long DP(long long n)//使用动态规划方法
{
int len = log(n) / log(2) + 1;
long long **dp = new long long*[n + 1];
for (long long i = 0; i <= n; i++)
{
dp[i] = new long long[len];
}
//long long dp[5][3] = { 0 };
for (int i = 0; i < len; i++)
for (long long j = 0; j <= n; j++)
dp[j][i] = 0;
//dp[n][i]表示使用1,1,2,2,4,4,...,2^i可以组合出n的方案数
for (int i = 0; i < len; i++)
dp[0][i] = 1;
if (n == 1 || n == 2)
return n;
dp[1][0] = 1;
dp[2][0] = 1;
for (int i = 3; i <= n; i++)
dp[i][0] = 0;
//dp[n][i]=
// cout << "len=" << len << endl;
for (int i = 1; i < len; i++)
{
for (long long j = 1; j <= n; j++)
{
for (int m = 0; m <= 2; m++)
if (j - pow(2, i)*m >= 0)
{
dp[j][i] = dp[j][i] + dp[(long long)(j - pow(2, i)*m)][i - 1];
//cout <<"j="<< j << " " << "i=" << i << " " << "m=" << m<<" "<< dp[j][i]<<endl;
}
}
}
return dp[n][len - 1];
}
int solve3(long long n)
{
long long stop = n / 2;
long long res = 0;
set<int> myset;
/*
将硬币分为两份:1,2,4,8,16,.....和1,2,4,8,16....
组成两个数值为a,b的两个数字,他们的和是a+b=n;
a在每一份中只可能有一种组合方式(二进制的思想)
*/
for (int i = 1; i <= stop; i++)
{
res = i ^ (n - i);
myset.insert(res);
}
//对于1,2,4,8结果再加1.
int len = log(n) / log(2) + 1;
if (pow(2, len - 1) == n)
return myset.size() + 1;
return myset.size();
}
int main()
{
for (int i = 0; i < 63; i++)
nums[i] = 0;
long long n;
clock_t start, finish;
while (true)
{
cin >> n;
if (n < 1)
{
return 0;
}
int len = log(n) / log(2) + 1;
int count = 0;
start = clock();
solve(n, 0, nums, len, count);
cout << count << endl;
finish = clock();
cout << "回溯法耗费时间为" << (double)(finish - start) / CLOCKS_PER_SEC << "秒" << endl;
//
//
start = clock();
long long res = DP(n);
cout << res << endl;
finish = clock();
cout << "动态规划方法耗费时间为" << (double)(finish - start) / CLOCKS_PER_SEC << "秒" << endl;
start = clock();
res = solve3(n);
cout << res << endl;
finish = clock();
cout << "第三种方法耗费时间为" << (double)(finish - start) / CLOCKS_PER_SEC << "秒" << endl;
}
return 0;
} | [
"153274152@qq.com"
] | 153274152@qq.com |
07bcfb268e18813ae167b515e654eeff721bcc2d | 966a7bf92b7afb988c917d20483cd50b0d083cd7 | /main.cpp | 39cf35cfb3fd278cae25ba4cf6f7907cf3416ee9 | [] | no_license | anhpham197/Chim_bay_SDL2 | d456d5bbaa5c7ec22b86162e8acedf8b88c71c5f | 794317d1193021bcaba960b8adc377fdb712c2ed | refs/heads/master | 2022-07-03T14:39:05.308452 | 2020-05-13T17:24:34 | 2020-05-13T17:24:34 | 257,076,156 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,966 | cpp | #include "BaseObject.h"
#include "CommonFunction.h"
#include "character.h"
#include "GameMap.h"
#include "ImpTimer.h"
#include "TextObject.h"
#include "Enemy.h"
#include "Explosion.h"
#include <SDL.h>
#include <Windows.h>
BaseObject g_background;
TTF_Font* font_time; // tao doi tuong font
bool InitData()
{
bool success = true;
int ret = SDL_Init(SDL_INIT_VIDEO); // thiết lập môi trường ban đầu cho SDL
if (ret < 0) return false;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); // thiết lập chế độ tỉ lệ với chất lượng
g_window = SDL_CreateWindow("CHIM_BAY - MSV:19021219", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN); // tạo cửa sổ hiển thị
if (g_window == NULL) success = false;
else
{
g_screen = SDL_CreateRenderer(g_window,-1,SDL_RENDERER_ACCELERATED);
if (g_screen == NULL) success = false;
else
{
SDL_SetRenderDrawColor(g_screen, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR);
int imgflags = IMG_INIT_PNG;
if (!(IMG_Init(imgflags) && imgflags))
success = false;
}
}
//AUDIO
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) == -1)
{
printf("%s", Mix_GetError());
}
g_sound = Mix_LoadMUS("sound/audio.mp3");
if (g_sound == NULL)
{
printf("%s", Mix_GetError());
}
// TEXT
if (TTF_Init() == -1)
{
success = false;
}
font_time = TTF_OpenFont("Font//dlxfont_.ttf", 30);
if (font_time == NULL)
{
printf ("&s",TTF_GetError());
}
return success;
}
bool LoadBackground()
{
bool ret = g_background.LoadImg("Images//background3.jpg", g_screen);
if (ret == false)
return false;
return true;
}
void close()
{
g_background.Free();
SDL_DestroyRenderer(g_screen);
g_screen = NULL;
SDL_DestroyWindow(g_window);
g_window = NULL;
IMG_Quit();
SDL_Quit();
}
int main(int argc, char* argv[])
{
ImpTimer fps_time;
if (InitData() == false)
return -1;
if (LoadBackground() == false)
return -1;
// INITIALIZE GAME_MAP
GameMap tube;
tube.LoadMap("tube/map.txt");
tube.LoadTiles(g_screen);
// INITIALIZE MAIN CHARACTER
character p_player;
p_player.LoadImg("Images//bird.png", g_screen);
// INITIALIZE ENEMY
Enemy p_enemy;
p_enemy.LoadImg("Images//enemy.png", g_screen);
p_enemy.set_x_pos(1664);
p_enemy.set_y_pos(0);
// INITIALIZE TEXTOBJECT
TextObject time_game; // game_time
time_game.SetColor(TextObject::WHITE_TEXT);
TextObject num_of_defeat; // số lần bắn trúng đạn và enemy
num_of_defeat.SetColor(TextObject::WHITE_TEXT);
// SET UP SURVIVAL INDEX
int num_of_death = 0;
// INITIALIZE ITEM FOR ENEMY
character_item* p_item = new character_item();
p_enemy.InitItem(p_item, g_screen);
// INITIALIZE EXPLOSION
Explosion exp;
bool tRet = exp.LoadImg("Images//explosion.png", g_screen);
if (!tRet) return -1;
exp.set_clip();
bool is_quit = false;
// INITIALIZE MENU
int ret_menu = SDLCommonFunction::ShowMenu(g_screen, font_time);
if (ret_menu == 1)
{
is_quit = true;
}
while (!is_quit)
{
if (!Mix_PlayingMusic())
Mix_PlayMusic(g_sound, 0); // thay 0 = so am => so lan phat lai nhac la vo tan
fps_time.start();
while (SDL_PollEvent(&g_event) != 0)
{
if (g_event.type == SDL_QUIT)
is_quit = true;
p_player.HandleInputAction(g_event, g_screen);
}
SDL_SetRenderDrawColor(g_screen, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR, RENDER_DRAW_COLOR);
SDL_RenderClear(g_screen);
g_background.Render(g_screen, NULL);
Map map_data = tube.getMap();
p_player.HandleItem(g_screen);
p_player.SetMapXY(map_data.start_x, map_data.start_y); // thiết lập lại bản đồ theo di chuyển của nvat
int ret = p_player.DoPlayer(map_data);
p_player.Show(g_screen);
tube.SetMap(map_data);
tube.DrawMap(g_screen);
p_enemy.SetMapXY(map_data.start_x, map_data.start_y);
p_enemy.DoPlayer(map_data);
p_enemy.MakeItem(g_screen, SCREEN_WIDTH, SCREEN_HEIGHT);
p_enemy.Show(g_screen);
// GET RECT OF EXPLOSION
int frame_exp_width = exp.get_frame_width();
int frame_exp_height = exp.get_frame_heigh();
// CHECK COLLISION BETWEEN BULLET OF ENEMY AND MAIN CHARACTER
SDL_Rect pRect; // player rect
pRect.x = p_player.GetRect().x;
pRect.y = p_player.GetRect().y;
pRect.w = p_player.GetRect().w;
pRect.h = p_player.GetRect().h;
bool bCol1 = false;
std::vector <character_item*> tBulletList = p_enemy.get_item_list();
for (int j = 0; j < tBulletList.size(); j++) {
character_item* pt_bullet = tBulletList[j];
if (pt_bullet) {
bCol1 = SDLCommonFunction::CheckCollison(pt_bullet->GetRect(), pRect);
if (bCol1) {
// EXPLOSION BETWEEN BULLET OF ENEMY AND MAIN CHARACTER
for (int ex = 0; ex < NUM_OF_FRAMES; ex++)
{
int x_pos = p_item->GetRect().x - frame_exp_width * 0.5;
int y_pos = p_item->GetRect().y - frame_exp_height * 0.5;
exp.set_frame(ex);
exp.SetRect(x_pos, y_pos);
exp.Show(g_screen);
SDL_RenderPresent(g_screen);
}
p_enemy.RemoveBullet(j);
break;
}
}
}
SDL_Rect tRect; // threat rect
tRect.x = p_enemy.GetRect().x;
tRect.y = p_enemy.GetRect().y;
tRect.w = p_enemy.GetRect().w;
tRect.h = p_enemy.GetRect().h;
bool bCol2 = SDLCommonFunction::CheckCollison(pRect, tRect); // collision between player and threat
if (bCol1 || bCol2) {
// EXPLOSION BETWEEN ENEMY AND MAIN CHARACTER
for (int ex = 0; ex < NUM_OF_FRAMES; ex++)
{
int x_pos = p_player.GetRect().x + p_player.GetRect().w - frame_exp_width * 0.5;
int y_pos = p_player.GetRect().y + p_player.GetRect().h- frame_exp_height * 0.5;
exp.set_frame(ex);
exp.SetRect(x_pos, y_pos);
exp.Show(g_screen);
SDL_RenderPresent(g_screen);
}
Mix_Chunk* beep_sound = Mix_LoadWAV("sound/game_over.wav");
if (beep_sound != NULL)
Mix_PlayChannel(-1, beep_sound, 0);
MessageBox(NULL, L"Oops! You've been hit ! ! !", L"Info", MB_ICONERROR | MB_OK);
is_quit = true;
}
// CHECK COLLISION BETWEEN BULLET OF MAIN CHARACTER AND ENEMY
std::vector<character_item*> bullet_arr = p_player.get_item_list();
for (int i = 0; i < bullet_arr.size(); i++)
{
character_item* p_bullet = bullet_arr[i];
if (p_bullet != NULL) {
SDL_Rect tRect;
tRect.x = p_enemy.GetRect().x;
tRect.y = p_enemy.GetRect().y;
tRect.w = p_enemy.GetRect().w;
tRect.h = p_enemy.GetRect().h;
SDL_Rect bRect = p_bullet->GetRect();
bool bCol = SDLCommonFunction::CheckCollison(bRect, tRect);
if (bCol) {
//EXPLOSION BETWEEN BULLET OF MAIN CHARACTER AND ENEMY
for (int ex = 0; ex < NUM_OF_FRAMES; ex++)
{
int x_pos = p_enemy.GetRect().x - frame_exp_width * 0.5;
int y_pos = p_enemy.GetRect().y - frame_exp_height * 0.5;
exp.set_frame(ex);
exp.SetRect(x_pos, y_pos);
exp.Show(g_screen);
SDL_RenderPresent(g_screen);
}
num_of_death++;
if (num_of_death < 3) {
p_enemy.SetRect(1664, 0);
}
else {
for (int j = 0; j < tBulletList.size(); j++) {
p_enemy.RemoveBullet(j);
}
p_player.RemoveBullet(i);
p_enemy.Free();
}
}
}
}
// SHOW GAME STATUS
if (ret == 1)
{
Mix_Chunk* beep_sound = Mix_LoadWAV("sound/game_over.wav");
if (beep_sound != NULL)
Mix_PlayChannel(-1, beep_sound, 0);
MessageBox(NULL, L"GAME OVER !", L"Info", MB_ICONERROR | MB_OK);
is_quit = true;
}
else if (ret == -1 && num_of_death >= 3)
{
Mix_Chunk* beep_sound = Mix_LoadWAV("sound/win_game.wav");
if (beep_sound != NULL)
Mix_PlayChannel(-1, beep_sound, 0);
MessageBox(NULL, L"YOU'VE WIN THE GAME !", L"Info", MB_ICONASTERISK | MB_OK);
is_quit = true;
}
// SHOW GAME TIME
std::string str_time = "Time left : ";
Uint32 time_val = SDL_GetTicks() / 1000; // doi ve giay
Uint32 val_time = 500 - time_val; // dem nguoc;
if (val_time <= 0)
{
Mix_Chunk* beep_sound = Mix_LoadWAV("sound/game_over.wav");
if (beep_sound != NULL)
Mix_PlayChannel(-1, beep_sound, 0);
MessageBox(NULL, L"GAMEOVER !", L"Info", MB_ICONERROR | MB_OK);
is_quit = true;
}
else
{
std::string str_val = std::to_string(val_time);
str_time += str_val;
time_game.SetText(str_time);
time_game.LoadFromRenderText(font_time, g_screen);
time_game.RenderText(g_screen, 10, 20);
}
std::string num_of_Death = std::to_string(num_of_death);
std::string survival("DEFEATED : ");
survival += num_of_Death;
num_of_defeat.SetText(survival);
num_of_defeat.LoadFromRenderText(font_time, g_screen);
num_of_defeat.RenderText(g_screen, 800, 20);
SDL_RenderPresent(g_screen);
// FPS
int real_imp_time = fps_time.get_ticks(); // thời gian thực sự đã trôi qua
int time_of_one_frame = 1000 / frame_per_second; // đơn vị : ms
if (real_imp_time < time_of_one_frame) // nếu thời gian chạy thực bé hơn (nhanh hơn so với cài đặt) -> phải tạo độ trễ
{
int delay_time = time_of_one_frame - real_imp_time;
SDL_Delay(delay_time); // nếu là dương thì delay_time tự truyền vào, nếu là âm thì delay_time tự convert về 0
// delay_time càng lớn <=> frame_per_second (FPS) càng nhỏ => ctrinh càng chậm
// tăng FPS để ctrinh chạy nhanh, MAX_FPS = 1000 / real_imp_time;
// phải giảm real_time <=> máy có cấu hình lớn : thời gian thực hiện lệnh ít
}
}
p_player.Free();
close();
SDL_Quit();
return 0;
}
| [
"19021219@vnu.edu.vn"
] | 19021219@vnu.edu.vn |
db89dc51f0129523e6f957678435931d62145b89 | 7b103608fd1715d15077763ed82b4f78e7aa3dab | /Introductory Problems/03_Repetitions.cpp | 8528401f418fe32ccf41907f7a448a31ed9102d9 | [] | no_license | ameya-shahu/CSES-Problem-Set | b9f352950d6febb921587acc0556599f13eb6b60 | 2be2bc4d9e48bf91bfd543996f1c579de9ff9cb4 | refs/heads/master | 2022-09-18T08:32:33.413929 | 2020-06-01T16:22:34 | 2020-06-01T16:22:34 | 268,145,220 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 945 | cpp | #include<bits/stdc++.h>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define RREP(i,a,b) for (int i = a;i<b;i++)
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
string input;
cin>>input;
int count = 0;
int Max = -INF;
char pre = 'i';
RREP(i,0,input.size()){
if(input[i]!=pre){
Max = max(Max,count);
count = 0;
}
pre = input[i];
count++;
}
cout<<max(Max,count);
return 0;
} | [
"ameyashahu@gmail.com"
] | ameyashahu@gmail.com |
69f928294b8db87e4c9c139740e2bb032a4bc4cb | 082f6678d50622d95e5253edb3564f52b6e81481 | /include/vsmc/gcd/dispatch_source.hpp | 471c75237aad6452f7bd38794ca23d7ae17f68e9 | [
"BSD-2-Clause"
] | permissive | Soledad89/vSMC | e78dc93dba7789190745636a1e913db579fb0816 | b00886f8d0cee0687fea8fee05f37fb2a5bab1d8 | refs/heads/master | 2021-01-24T21:18:56.700290 | 2015-05-28T08:42:54 | 2015-05-28T08:42:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,697 | hpp | //============================================================================
// vSMC/include/vsmc/gcd/dispatch_source.hpp
//----------------------------------------------------------------------------
// vSMC: Scalable Monte Carlo
//----------------------------------------------------------------------------
// Copyright (c) 2013-2015, Yan Zhou
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//============================================================================
#ifndef VSMC_GCD_DISPATCH_SOURCE_HPP
#define VSMC_GCD_DISPATCH_SOURCE_HPP
#include <vsmc/internal/common.hpp>
#include <vsmc/gcd/dispatch_object.hpp>
#include <vsmc/gcd/dispatch_queue.hpp>
namespace vsmc {
/// \brief Types of DispatchSource
/// \ingroup Dispatch
enum DispatchSourceType {
DispatchDataAdd, ///< DISPATCH_SOURCE_TYPE_DATA_ADD
DispatchDataOr, ///< DISPATCH_SOURCE_TYPE_DATA_OR
DispatchMachRecv, ///< DISPATCH_SOURCE_TYPE_MACH_RECV
DispatchMachSend, ///< DISPATCH_SOURCE_TYPE_MACH_SEND
DispatchProc, ///< DISPATCH_SOURCE_TYPE_PROC
DispatchRead, ///< DISPATCH_SOURCE_TYPE_READ
DispatchSignal, ///< DISPATCH_SOURCE_TYPE_SIGNAL
DispatchTimer, ///< DISPATCH_SOURCE_TYPE_TIMER
DispatchVnode, ///< DISPATCH_SOURCE_TYPE_VNODE
DispatchWrite ///< DISPATCH_SOURCE_TYPE_WRITE
}; // enum DispatchSourceType
template <DispatchSourceType> class DispatchSource;
/// \brief Base class of DispatchSource
/// \ingroup Dispatch
///
/// \bug A DispachSource object is manually retained when created. It is
/// supposed to be retained by `dispatch_source_create` according to the
/// documents. But this seems not to be the case in the current implementation
/// (Mac OS X 10.9). The worst case is that a source object is retained one
/// more time than it is released. A simple test example is,
/// ~~~{.cpp}
/// ::dispatch_source_t source = ::dispatch_source_create( /* arguments */ );
/// ::dispatch_release(source); // generate error
/// ~~~
template <DispatchSourceType Type>
class DispatchSourceBase : public DispatchObject< ::dispatch_source_t>
{
public :
void resume () const {::dispatch_resume(this->object());}
void suspend () const {::dispatch_suspend(this->object());}
void cancel () const {::dispatch_source_cancel(this->object());}
long testcancel () const
{return ::dispatch_source_testcancel(this->object());}
unsigned long get_data () const
{return ::dispatch_source_get_data(this->object());}
uintptr_t get_handle () const
{return ::dispatch_source_get_handle(this->object());}
unsigned long get_mask () const
{return ::dispatch_source_get_mask(this->object());}
void set_cancel_handler_f (::dispatch_function_t cancel_handler) const
{::dispatch_source_set_cancel_handler_f(this->object(), cancel_handler);}
void set_event_handler_f (::dispatch_function_t event_handler) const
{::dispatch_source_set_event_handler_f(this->object(), event_handler);}
#if VSMC_HAS_GCD_LION
void set_registration_handler_f (::dispatch_function_t
registration_handler) const
{
::dispatch_source_set_registration_handler_f(
this->object(), registration_handler);
}
#endif // VSMC_HAS_GCD_LION
#ifdef __BLOCKS__
void set_cancel_handler (::dispatch_block_t cancel_handler) const
{::dispatch_source_set_cancel_handler(this->object(), cancel_handler);}
void set_event_handler (::dispatch_block_t event_handler) const
{::dispatch_source_set_event_handler(this->object(), event_handler);}
#if VSMC_HAS_GCD_LION
void set_registration_handler (::dispatch_block_t
registration_handler) const
{
::dispatch_source_set_registration_handler(
this->object(), registration_handler);
}
#endif // VSMC_HAS_GCD_LION
#endif // __BLOCKS__
private :
template <DispatchSourceType> struct source_type {};
protected :
DispatchSourceBase (uintptr_t handle, unsigned long mask,
::dispatch_queue_t queue) :
DispatchObject< ::dispatch_source_t>(::dispatch_source_create(
source_type_t(source_type<Type>()),
handle, mask, queue), false) {}
private :
static ::dispatch_source_type_t source_type_t (
source_type<DispatchDataAdd>)
{return DISPATCH_SOURCE_TYPE_DATA_ADD;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchDataOr>)
{return DISPATCH_SOURCE_TYPE_DATA_OR;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchMachRecv>)
{return DISPATCH_SOURCE_TYPE_MACH_RECV;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchMachSend>)
{return DISPATCH_SOURCE_TYPE_MACH_SEND;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchProc>)
{return DISPATCH_SOURCE_TYPE_PROC;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchRead>)
{return DISPATCH_SOURCE_TYPE_READ;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchSignal>)
{return DISPATCH_SOURCE_TYPE_SIGNAL;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchTimer>)
{return DISPATCH_SOURCE_TYPE_TIMER;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchVnode>)
{return DISPATCH_SOURCE_TYPE_VNODE;}
static ::dispatch_source_type_t source_type_t (
source_type<DispatchWrite>)
{return DISPATCH_SOURCE_TYPE_WRITE;}
}; // class DispatchSourceBase
/// \brief A dispatch source
/// \ingroup Dispatch
template <DispatchSourceType Type>
class DispatchSource : public DispatchSourceBase<Type>
{
public :
template <DispatchQueueType QType>
DispatchSource (uintptr_t handle, unsigned long mask,
const DispatchQueue<QType> &queue) :
DispatchSourceBase<Type>(handle, mask, queue.object()) {}
DispatchSource (uintptr_t handle, unsigned long mask,
::dispatch_queue_t queue) :
DispatchSourceBase<Type>(handle, mask, queue) {}
}; // class DispatchSource
/// \brief Data (ADD) dispatch source
/// \ingroup Dispatch
template <>
class DispatchSource<DispatchDataAdd> :
public DispatchSourceBase<DispatchDataAdd>
{
public :
template <DispatchQueueType QType>
DispatchSource (uintptr_t handle, unsigned long mask,
const DispatchQueue<QType> &queue) :
DispatchSourceBase<DispatchDataAdd>(handle, mask, queue.object()) {}
DispatchSource (uintptr_t handle, unsigned long mask,
::dispatch_queue_t queue) :
DispatchSourceBase<DispatchDataAdd>(handle, mask, queue) {}
void merge_data (unsigned long value) const
{::dispatch_source_merge_data(this->object(), value);}
}; // class DispatchSource
/// \brief Data (OR) dispatch source
/// \ingroup Dispatch
template <>
class DispatchSource<DispatchDataOr> :
public DispatchSourceBase<DispatchDataOr>
{
public :
template <DispatchQueueType QType>
DispatchSource (uintptr_t handle, unsigned long mask,
const DispatchQueue<QType> &queue) :
DispatchSourceBase<DispatchDataOr>(handle, mask, queue.object()) {}
DispatchSource (uintptr_t handle, unsigned long mask,
::dispatch_queue_t queue) :
DispatchSourceBase<DispatchDataOr>(handle, mask, queue) {}
void merge_data (unsigned long value) const
{::dispatch_source_merge_data(this->object(), value);}
}; // class DispatchSource
/// \brief Timer dispatch source
/// \ingroup Dispatch
template <>
class DispatchSource<DispatchTimer> :
public DispatchSourceBase<DispatchTimer>
{
public :
template <DispatchQueueType QType>
DispatchSource (uintptr_t handle, unsigned long mask,
const DispatchQueue<QType> &queue) :
DispatchSourceBase<DispatchTimer>(handle, mask, queue.object()) {}
DispatchSource (uintptr_t handle, unsigned long mask,
::dispatch_queue_t queue) :
DispatchSourceBase<DispatchTimer>(handle, mask, queue) {}
void set_timer (::dispatch_time_t start,
uint64_t interval, uint64_t leeway) const
{::dispatch_source_set_timer(this->object(), start, interval, leeway);}
}; // class DispatchSource
} // namespace vsmc
#endif // VSMC_GCD_DISPATCH_SOURCE_HPP
| [
"zhouyan@me.com"
] | zhouyan@me.com |
f78f14640114face0fbef0b8b36c2e815e9635ec | 07c7953dbbf05a46cd260c96a515276915c1e493 | /C++实现数据结构查找和排序/main.cpp | 110070ab08bfd2760232ffe277944191cc38eeaa | [] | no_license | MasterLeen/cpp- | 9e421f40bcaf407f793c18a4408b9edb8dc7ddd4 | 22a8f6c1688903c36c3eda533fe57b9ece22ccc9 | refs/heads/master | 2020-03-24T20:58:32.164225 | 2019-10-07T05:47:19 | 2019-10-07T05:47:19 | 143,006,802 | 1 | 0 | null | 2019-10-07T05:47:20 | 2018-07-31T11:44:37 | C++ | GB18030 | C++ | false | false | 6,870 | cpp | #include <iostream>
#include <vector>
#include <map>
#include <string.h>
#include <algorithm>
#include <sstream>//stringstream must include the header
using namespace std;
void SeqFind(const int& tmp);
void BinarySearch(const int& tmp);
void LinerExploration(int & num,char *cp);
void SearchStu(const int &num);
int Hash(char* cp);
void BubbleSort(vector<int> m_vec);
void SelectSort(vector<int> m_vec);
void InsertSort(vector<int> m_vec);
void QuickSort(vector<int> m_vec);
void QSort(vector<int>& m_vec,int low,int high);
void MergeSort(vector<int> m_vec);
void Print(const int & tmp);
void MergePass(vector<int> &m_vec, int head1, int head2, int tail2);
vector<int> m_vec;
map<int,char*> hash_map;
int main()
{
/*m_vec = {3,10,13,17,40,43,50,70};
SeqFind(43);
SeqFind(5);
BinarySearch(43);
BinarySearch(5);*/
//只输入两个姓名测试
/*char** cp = new char* [30];
cp[0] = "李华";
cp[1] = "周军";
for(int i = 0;i < 2;i++){
int location = Hash(cp[i]);
LinerExploration(location,cp[i]);
}
SearchStu(1);
SearchStu(27);
for(int i = 0;i < 30;i++)
delete [] cp[i];
delete cp;*/
//5种排序算法
cout<<"please input out of order digital series:"<<endl;
/*int tmp;
do{
cin>>tmp;
m_vec.push_back(tmp);
}while(cin.get() != '\n');*/
/*string ss;
getline(cin,ss,'\n');//使用string流读取一行
stringstream s;
s<<ss;
int tmp;
while(s>>tmp)
m_vec.push_back(tmp);
BubbleSort(m_vec);
SelectSort(m_vec);
InsertSort(m_vec);
QuickSort(m_vec);
MergeSort(m_vec);*/
//利用归并排序合并两个顺序表
/*m_vec = {1,5,10,44,66,2,4,7,11,55};
int head2 = 0,len = m_vec.size();
for(int i = 0;i < len - 1;i++)
{
if(m_vec[i] > m_vec[i + 1])
{
head2 = i + 1;
break;
}
}
head2 = head2 == 0?m_vec.size() - 1:head2;
MergePass(m_vec,0,head2,len - 1);
for_each(m_vec.begin(),m_vec.end(),Print);*/
return 0;
}
void SeqFind(const int &tmp)
{
//vector<int>::iterator iter = m_vec.begin();
int i = 0;
for(;i < m_vec.size();i++) {
if(m_vec[i] == tmp)
{
cout<<"found it! it's location in m_vec :"<<i<<endl;
return;
}
}
if(i == m_vec.size())
cout<<"can not find it!"<<endl;
}
void BinarySearch(const int &tmp)
{
int low = 0,high = m_vec.size() - 1,middle;
while(low <= high)
{
middle = (low + high)/2;
if(m_vec[middle] == tmp){
cout<<"found it! it's location in m_vec :"<<middle<<endl;
return;
}
else if(m_vec[middle] > tmp){
high = middle - 1;
}
else
low = middle + 1;
}
cout<<"can not find it!"<<endl;
}
int Hash(char* cp)
{
int sum = 0;
int len = strlen(cp);
for(int i = 0;i < len;i++){
sum += (int)*cp;
cp++;
}
return abs(sum%30);
}
void LinerExploration(int & num,char* cp)
{
while (hash_map.find(num) != hash_map.end()) num++;
hash_map.insert(pair<int,char*>(num,cp));
}
void SearchStu(const int &num)
{
map<int,char*>::iterator iter = hash_map.find(num);
if(iter == hash_map.end())
cout<<"false! can not find the stu!"<<endl;
else
cout<<"num = "<<iter->first<<" the stu name is :"<<iter->second<<endl;
}
void BubbleSort(vector<int> m_vec)
{
for(int i = 0;i < m_vec.size();i++)
{
for(int j = 0;j < m_vec.size() - i - 1;j++)
{
if(m_vec[j] > m_vec[j + 1]){
swap(m_vec[j],m_vec[j + 1]);
}
}
}
cout<<"the result of bubble sort algorithm is :"<<endl;
for_each(m_vec.begin(),m_vec.end(),Print);//for_each需包含<algorithm>头文件
cout<<endl;
}
void SelectSort(vector<int> m_vec)
{
for(int i = 0;i < m_vec.size();i++)
{
int min = i;
for(int j = i + 1;j < m_vec.size();j++){
if(m_vec[j] < m_vec[min])
min = j;
}
if(min != i)
swap(m_vec[i],m_vec[min]);
}
cout<<"the result of select sort algorithm is :"<<endl;
for_each(m_vec.begin(),m_vec.end(),&Print);
cout<<endl;
}
void InsertSort(vector<int> m_vec)
{
for(int i = 1;i < m_vec.size();i++)
{
if(m_vec[i] < m_vec[i - 1]){
int temp = m_vec[i];
int j = i - 1;
for(;j >= 0 && m_vec[j] > temp;j--)
m_vec[j + 1] = m_vec[j];
m_vec[j + 1] = temp;
}
}
cout<<"the result of insertion sort algorithm is :"<<endl;
for_each(m_vec.begin(),m_vec.end(),&Print);
cout<<endl;
}
void QuickSort(vector<int> m_vec)
{
QSort(m_vec,0,m_vec.size() - 1);
cout<<"the result of quick sort algorithm is :"<<endl;
for_each(m_vec.begin(),m_vec.end(),&Print);
cout<<endl;
}
//快排的思路是选取一个枢轴(比较值),将序列分成大于和小于枢轴的两部分再通过递归,直到序列不可分,因此每次递归都会确定枢轴的正确放置位置
void QSort(vector<int> &m_vec, int low, int high)
{
int pivort;
if(low < high)
{
{
int temp = m_vec[low];
int low1 = low;
int high1 = high;
while (low1 < high1) {
while(low1 < high1 && m_vec[high1] >= temp) high1--;
swap(m_vec[low1],m_vec[high1]);
while(low1 < high1 && m_vec[low1] <= temp) low1++;
swap(m_vec[low1],m_vec[high1]);
}
pivort = low1;
QSort(m_vec,low,pivort - 1);
QSort(m_vec,pivort + 1,high);
}
}
else
return;
}
void MergePass(vector<int>& m_vec,int head1,int head2,int tail2)
{
int tail1 = head2 - 1,start = head1;
vector<int> tmp;
tmp.reserve(tail2 - head1 + 1);
while (head1 <= tail1 && head2 <= tail2) {
if(m_vec[head1] <= m_vec[head2])
tmp.push_back(m_vec[head1++]);
else
tmp.push_back(m_vec[head2++]);
}
while(head1 <= tail1)
tmp.push_back(m_vec[head1++]);
while(head2 <= tail2)
tmp.push_back(m_vec[head2++]);
for(int i = 0;i < tmp.size();i++){
m_vec[start + i] = tmp[i];
}
tmp.clear();
}
//用迭代法实现归并排序
void MergeSort(vector<int> m_vec)
{
//步长每次都倍增
int len = m_vec.size();
for(int step = 1;step <= len;step <<= 1){
int offset = step << 1;
for(int index = 0;index < len;index += offset)
MergePass(m_vec,index,min(index + step,len -1),min(index + offset - 1,len - 1));
}
cout<<"the result of merge sort algorithm is :"<<endl;
for_each(m_vec.begin(),m_vec.end(),&Print);
cout<<endl;
}
void Print(const int & tmp)
{
cout<<tmp<<" ";
}
| [
"1763946255@qq.com"
] | 1763946255@qq.com |
0ff77464b00abb9eeb83c0fd73e0804499b81841 | eee0588d6c92b1bc093716ac84969a47a8159e38 | /Cluiche/DiaGraphicWithUITest/SimThreadStruct.h | 0715e67ac15aed0c9b88a8e41b1e3ef8f990a874 | [] | no_license | LenihanConor/Cluiche | bf919ef721d901ba2a23646e70444803e0fe5781 | 1b65c5861a2354a81fbf1ed63fb0e7620b635d0d | refs/heads/master | 2023-06-28T19:45:52.811023 | 2023-06-20T18:20:58 | 2023-06-20T18:20:58 | 37,433,420 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 868 | h | #pragma once
#include <DiaCore/Timer/TimeThreadLimiter.h>
#include <DiaCore/Time/TimeServer.h>
#include <DiaCore/Frame/FrameStream.h>
#include <DiaInput/EventData.h>
#include <DiaGraphics/Frame/FrameData.h>
#include <DiaUI/IUISystem.h>
struct SimThreadStruct
{
public:
SimThreadStruct(bool& running,
Dia::UI::IUISystem& uiSystem,
Dia::Core::FrameStream<Dia::Input::EventData>& inputToSimFrameStream,
Dia::Core::FrameStream<Dia::Graphics::FrameData>& SimToRenderFrameStream);
void operator()();
void Run();
private:
// Shared resources
bool& mRunning;
Dia::UI::IUISystem& mUISystem;
Dia::Core::FrameStream<Dia::Input::EventData>& mInputToSimFrameStream;
Dia::Core::FrameStream<Dia::Graphics::FrameData>& mSimToRenderFrameStream;
// Local resources
Dia::Core::TimeServer mTimeServer;
Dia::Core::TimeThreadLimiter mThreadLimiter;
};
| [
"lenihan.conor@gmail.com"
] | lenihan.conor@gmail.com |
5ca95d7382764e50294cb4ae92a8aa804a1289e4 | fd7416b2cecddc2b5d531c399f2265fa57d6ab4b | /libraries/trainers/optimization/tcc/MatrixSolution.tcc | c99d0e4d356bac23c925964af7fa659c580f4b58 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | yaokeepmoving/ELL | 0bb45c04eab0773e09eee8504ea2e36baa291ee6 | 993d5370f0f7a274e8dfd8f43220c792be46f314 | refs/heads/master | 2020-04-04T14:31:37.444718 | 2018-10-25T19:03:36 | 2018-10-25T19:03:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,532 | tcc | ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Project: Embedded Learning Library (ELL)
// File: MatrixSolution.tcc (optimization)
// Authors: Ofer Dekel
//
////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
// utilities
#include "Exception.h"
// math
#include "VectorOperations.h"
#include "MatrixOperations.h"
namespace ell
{
namespace trainers
{
namespace optimization
{
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::Resize(const InputType& inputExample, const OutputType& outputExample)
{
math::ColumnMatrix<double> matrix(inputExample.Size(), outputExample.Size());
_weights.Swap(matrix);
if constexpr (!isDouble)
{
_doubleInput.Resize(inputExample.Size());
}
if constexpr (isBiased)
{
_bias.Resize(outputExample.Size());
}
}
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::operator=(const MatrixSolution<IOElementType, isBiased>& other)
{
_weights.CopyFrom(other._weights);
if constexpr (isBiased)
{
_bias.CopyFrom(other._bias);
}
}
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::operator=(SumExpression<ScaledExpression<MatrixSolution<IOElementType, isBiased>>, ScaledExpression<MatrixSolution<IOElementType, isBiased>>> expression)
{
const auto& thisTerm = expression.lhs;
const auto& otherTerm = expression.rhs;
if (&(thisTerm.lhs.get()) != this)
{
throw utilities::LogicException(utilities::LogicExceptionErrors::notImplemented, "First term should be a scaled version of this solution");
}
double thisScale = thisTerm.rhs;
const auto& otherSolution = otherTerm.lhs.get();
double otherScale = otherTerm.rhs;
math::ScaleAddUpdate(otherScale, otherSolution._weights, thisScale, _weights);
if constexpr (isBiased)
{
math::ScaleAddUpdate(otherScale, otherSolution.GetBias(), thisScale, _bias);
}
}
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::operator=(SumExpression<ScaledExpression<MatrixSolution<IOElementType, isBiased>>, OuterProductExpression<IOElementType>> expression)
{
const auto& thisTerm = expression.lhs;
const auto& updateTerm = expression.rhs;
if (&(thisTerm.lhs.get()) != this)
{
throw utilities::LogicException(utilities::LogicExceptionErrors::notImplemented, "The first term should be a scaled version of this solution");
}
double thisScale = thisTerm.rhs;
const auto& columnVectorReference = updateTerm.lhs;
const auto& rowVectorReference = updateTerm.rhs;
_weights *= thisScale;
if constexpr (isDouble)
{
math::RankOneUpdate(1.0, columnVectorReference, rowVectorReference, _weights);
}
else
{
auto doubleColumnVector = _doubleInput.Transpose();
doubleColumnVector.CopyFrom(columnVectorReference);
math::RankOneUpdate(1.0, doubleColumnVector, rowVectorReference, _weights);
}
if constexpr (isBiased)
{
math::ScaleAddUpdate(1.0, rowVectorReference, thisScale, _bias);
}
}
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::operator+=(OuterProductExpression<IOElementType> expression)
{
const auto& columnVectorReference = expression.lhs;
const auto& rowVectorReference = expression.rhs;
if constexpr (isDouble)
{
math::RankOneUpdate(1.0, columnVectorReference, rowVectorReference, _weights);
}
else
{
auto doubleColumnVector = _doubleInput.Transpose();
doubleColumnVector.CopyFrom(columnVectorReference);
math::RankOneUpdate(1.0, doubleColumnVector, rowVectorReference, _weights);
}
if constexpr (isBiased)
{
math::ScaleAddUpdate(1.0, rowVectorReference, 1.0, _bias);
}
}
template <typename IOElementType, bool isBiased>
math::RowVector<double> MatrixSolution<IOElementType, isBiased>::Multiply(const InputType& input) const
{
math::RowVector<double> result(_weights.NumColumns());
if constexpr (isBiased)
{
result.CopyFrom(_bias);
}
if constexpr (isDouble)
{
math::MultiplyScaleAddUpdate(1.0, input, _weights, 1.0, result);
}
else
{
_doubleInput.CopyFrom(input);
math::MultiplyScaleAddUpdate(1.0, _doubleInput, _weights, 1.0, result);
}
return result;
}
template <typename IOElementType, bool isBiased>
double MatrixSolution<IOElementType, isBiased>::GetNorm2SquaredOf(const InputType& input)
{
double result = input.Norm2Squared();
if constexpr (isBiased)
{
result += 1.0;
}
return result;
}
template <typename IOElementType, bool isBiased>
void MatrixSolution<IOElementType, isBiased>::InitializeAuxiliaryVariable(AuxiliaryDoubleType& aux)
{
aux.Resize(_weights.NumColumns()); aux.Reset();
}
template <typename IOElementType, bool isBiased>
double Norm1(const MatrixSolution<IOElementType, isBiased>& solution)
{
double result = solution.GetMatrix().ReferenceAsVector().Norm1();
if constexpr (isBiased)
{
result += solution.GetBias().Norm1();
}
return result;
}
template <typename IOElementType, bool isBiased>
double Norm2Squared(const MatrixSolution<IOElementType, isBiased>& solution)
{
double result = solution.GetMatrix().ReferenceAsVector().Norm2Squared();
if constexpr (isBiased)
{
result += solution.GetBias().Norm2Squared();
}
return result;
}
template <typename IOElementType, bool isBiased>
math::RowVector<double> operator*(math::ConstRowVectorReference<IOElementType> input, const MatrixSolution<IOElementType, isBiased>& solution)
{
return solution.Multiply(input);
}
}
}
}
| [
"oferd@microsoft.com"
] | oferd@microsoft.com |
9f78a7a7832c97c27d7501f0b7bb6b12c651343d | 53c537c1064d7856d7d638753238eadb1479c13f | /install/include/cwru_action/cwru_baxter_cart_moveActionGoal.h | bd87f95f18ae31aa604d7d6723aebd7b54d34dc5 | [] | no_license | dsb86/MobileRobotics | de8600b23a54cb3626a3a56f06a1fe766950a66e | 986771e1bcfba9bc601ed6324dc544ae28e40b54 | refs/heads/master | 2021-01-10T12:21:39.010769 | 2016-01-27T04:46:43 | 2016-01-27T04:46:43 | 50,472,772 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,422 | h | // Generated by gencpp from file cwru_action/cwru_baxter_cart_moveActionGoal.msg
// DO NOT EDIT!
#ifndef CWRU_ACTION_MESSAGE_CWRU_BAXTER_CART_MOVEACTIONGOAL_H
#define CWRU_ACTION_MESSAGE_CWRU_BAXTER_CART_MOVEACTIONGOAL_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 <std_msgs/Header.h>
#include <actionlib_msgs/GoalID.h>
#include <cwru_action/cwru_baxter_cart_moveGoal.h>
namespace cwru_action
{
template <class ContainerAllocator>
struct cwru_baxter_cart_moveActionGoal_
{
typedef cwru_baxter_cart_moveActionGoal_<ContainerAllocator> Type;
cwru_baxter_cart_moveActionGoal_()
: header()
, goal_id()
, goal() {
}
cwru_baxter_cart_moveActionGoal_(const ContainerAllocator& _alloc)
: header(_alloc)
, goal_id(_alloc)
, goal(_alloc) {
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef ::actionlib_msgs::GoalID_<ContainerAllocator> _goal_id_type;
_goal_id_type goal_id;
typedef ::cwru_action::cwru_baxter_cart_moveGoal_<ContainerAllocator> _goal_type;
_goal_type goal;
typedef boost::shared_ptr< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> const> ConstPtr;
}; // struct cwru_baxter_cart_moveActionGoal_
typedef ::cwru_action::cwru_baxter_cart_moveActionGoal_<std::allocator<void> > cwru_baxter_cart_moveActionGoal;
typedef boost::shared_ptr< ::cwru_action::cwru_baxter_cart_moveActionGoal > cwru_baxter_cart_moveActionGoalPtr;
typedef boost::shared_ptr< ::cwru_action::cwru_baxter_cart_moveActionGoal const> cwru_baxter_cart_moveActionGoalConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace cwru_action
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True}
// {'roscpp': ['/opt/ros/indigo/share/roscpp/cmake/../msg'], 'actionlib': ['/opt/ros/indigo/share/actionlib/cmake/../msg'], 'trajectory_msgs': ['/opt/ros/indigo/share/trajectory_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'cwru_action': ['/home/dsb86/ros_ws/devel/share/cwru_action/msg'], 'geometry_msgs': ['/opt/ros/indigo/share/geometry_msgs/cmake/../msg'], 'actionlib_msgs': ['/opt/ros/indigo/share/actionlib_msgs/cmake/../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< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
{
static const char* value()
{
return "0dd8083c14e4b775a204ee3c6bf9d4ed";
}
static const char* value(const ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x0dd8083c14e4b775ULL;
static const uint64_t static_value2 = 0xa204ee3c6bf9d4edULL;
};
template<class ContainerAllocator>
struct DataType< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
{
static const char* value()
{
return "cwru_action/cwru_baxter_cart_moveActionGoal";
}
static const char* value(const ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
{
static const char* value()
{
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\
\n\
Header header\n\
actionlib_msgs/GoalID goal_id\n\
cwru_baxter_cart_moveGoal goal\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: actionlib_msgs/GoalID\n\
# The stamp should store the time at which this goal was requested.\n\
# It is used by an action server when it tries to preempt all\n\
# goals that were requested before a certain time\n\
time stamp\n\
\n\
# The id provides a way to associate feedback and\n\
# result message with specific goal requests. The id\n\
# specified must be unique.\n\
string id\n\
\n\
\n\
================================================================================\n\
MSG: cwru_action/cwru_baxter_cart_moveGoal\n\
# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\
#This action message is specialized for Baxter\n\
#minimally, it may contain just a command code\n\
#more generally, it may contain desired left and right tool-frame poses, as well\n\
# as gripper poses (gripper opening--interpreted for specific grippers, e.g. Yale hand)\n\
# and an arrival time for the move\n\
# It is assumed that a move starts from the previous commanded pose, or from the current joint state\n\
\n\
#return codes provide status info, e.g. if a proposed move is reachable\n\
\n\
#define message constants:\n\
uint8 ARM_TEST_MODE =0\n\
\n\
#queries\n\
uint8 ARM_IS_SERVER_BUSY_QUERY = 1\n\
\n\
uint8 ARM_QUERY_IS_PATH_VALID = 2\n\
uint8 RT_ARM_GET_Q_DATA = 3\n\
uint8 LEFT_ARM_GET_Q_DATA = 4\n\
uint8 RT_ARM_GET_TOOL_POSE = 5\n\
uint8 LEFT_ARM_GET_TOOL_POSE = 5\n\
\n\
#requests for motion plans; need to extend this to left arm and both arms\n\
uint8 RT_ARM_PLAN_PATH_CURRENT_TO_GOAL_POSE=20 #plan paths from current arm pose\n\
uint8 RT_ARM_PLAN_PATH_CURRENT_TO_PRE_POSE=21\n\
\n\
uint8 RT_ARM_PLAN_JSPACE_PATH_CURRENT_TO_PRE_POSE=22\n\
uint8 RT_ARM_PLAN_JSPACE_PATH_CURRENT_TO_QGOAL=23\n\
\n\
#cartesian path from specified joint-space start and end;\n\
# orientation interpolation is a bit odd\n\
uint8 RT_ARM_PLAN_PATH_QSTART_TO_QGOAL = 25\n\
uint8 RT_ARM_PLAN_PATH_QSTART_TO_ADES = 24 #specify start and end, j-space start, affine desired end\n\
\n\
#uint8 RT_ARM_PLAN_PATH_ASTART_TO_QGOAL = 26 #specified affine start, joint-space goal\n\
uint8 RT_ARM_PLAN_PATH_CURRENT_TO_GOAL_DP_XYZ = 27 #rectilinear translation w/ fixed orientation\n\
\n\
# request to preview plan:\n\
uint8 RT_ARM_DISPLAY_TRAJECTORY = 50\n\
\n\
#MOVE commands!\n\
uint8 RT_ARM_EXECUTE_PLANNED_PATH = 100\n\
\n\
#uint8 RT_ARM_DESCEND_20CM=101\n\
#uint8 RT_ARM_DEPART_20CM=102\n\
\n\
\n\
#goal:\n\
int32 command_code\n\
geometry_msgs/PoseStamped des_pose_gripper_right\n\
geometry_msgs/PoseStamped des_pose_gripper_left\n\
float64 gripper_opening_right\n\
float64 gripper_opening_left\n\
float64[] arm_dp_right #to command a 3-D vector displacement relative to current pose, fixed orientation\n\
float64[] arm_dp_left\n\
float64[] q_goal_right\n\
float64[] q_goal_left\n\
float64 move_time\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: geometry_msgs/Pose\n\
# A representation of pose in free space, composed of postion 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 ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.goal_id);
stream.next(m.goal);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct cwru_baxter_cart_moveActionGoal_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::cwru_action::cwru_baxter_cart_moveActionGoal_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "goal_id: ";
s << std::endl;
Printer< ::actionlib_msgs::GoalID_<ContainerAllocator> >::stream(s, indent + " ", v.goal_id);
s << indent << "goal: ";
s << std::endl;
Printer< ::cwru_action::cwru_baxter_cart_moveGoal_<ContainerAllocator> >::stream(s, indent + " ", v.goal);
}
};
} // namespace message_operations
} // namespace ros
#endif // CWRU_ACTION_MESSAGE_CWRU_BAXTER_CART_MOVEACTIONGOAL_H
| [
"dsb86@case.edu"
] | dsb86@case.edu |
5d2e0ab7b8f7ef361cbbea0578ac48d7b10c1497 | d558f13a3e9c15e51e8aeff3cdbcbbd99df7166f | /C++/powcarettranslator/caretPow.cpp | 94689a941a661d62916716fc9898735fa9433e30 | [] | no_license | mehstruslehpy/Documents | 3b52dc2b9506746b88eccb2afa2d591f4572b7a5 | b40fa6d6944d6bf21ce99de6fbfd9b19f98bd763 | refs/heads/master | 2020-04-15T14:03:11.555203 | 2019-01-01T04:03:27 | 2019-01-01T04:03:27 | 58,814,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,273 | cpp | #include <iostream>
#include <strings.h>
#include <regex>
#include <boost/algorithm/string/replace.hpp>
#define NOT_FOUND string::npos ///the find method returns this if not found
using namespace std;
int caretPow(string inLine, int offsets[])
{
//string inLine; //input string
regex singleCaret (".*(\^).*"); //we use this to look for a caret in our input expression
//int offsets[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; //an array of 8 integers corresponding to the offsets for parens and symbols below
int count = 0; //used to tally parens zero means we have finished matching open = +1 close = -1 or open =-1 close = +1
int pos = 0; //tracks indexes into our string
int lhoParen = -1; //left hand side open paren
int lhcParen = -1; //left hand side close paren
int rhoParen = -1; //right hand side open paren
int rhcParen = -1; //right hand side close paren
//in the case of symbol^symbol or some combination
int lhsSymbols = -1; //the left hand side symbol
int lhsSymbole = -1; //the left hand side symbol
int rhsSymbols = -1; //the right hand side symbol
int rhsSymbole = -1; //the right hand side symbol
//getline(cin, inLine); //get a line this can be eliminated later to process by line input files
if (regex_match(inLine, singleCaret))
{
//cout << "MATCH!" << endl;
pos = inLine.find("^");
pos = pos - 1;
//consume lhs white space til we reach a open paren
while (inLine.at(pos) == ' ' && inLine.at(pos) != ')' && pos != 0)
{
pos = pos - 1;
}
//if this is still a white space then the user entered something invalid and we should exit
if (inLine.at(pos) == ' ')
{
cout << "ERROR: INVAID EXPRESSION ON LEFT HAND SIDE OF EXPONENT" << endl;
return 1;
}
//match parentheses on lhs of caret
do
{
if (inLine.at(pos) == ')')
{
count = count + 1;
//cout << "PLUS ONE" << endl;
pos = pos - 1;
lhcParen = pos + 1;
}
else if (inLine.at(pos) == '(')
{
count = count - 1;
//cout << "MINUS ONE" << endl;
pos = pos - 1;
lhoParen = pos + 1;
}
else
{
//cout << "NEXT ELEMENT" << endl;
pos = pos - 1;
}
} while (count != 0 && pos >= 0);
//cout << "DONE COUNTING! left hand side of first caret" << endl;
count = 0;
pos = inLine.find("^");
pos = pos + 1;
//consume rhs white space til we reach an open paren
while (inLine.at(pos) == ' ' && inLine.at(pos) != '(' && (inLine.length() - 1) != pos)
{
pos = pos + 1;
}
//if this is still a white space then the user entered something invalid and we should exit
if (inLine.at(pos) == ' ')
{
cout << "ERROR: INVAID EXPRESSION ON RIGHT HAND SIDE OF EXPONENT" << endl;
return 0; //we should probably just skip over this line but returning now might be good
}
//match parens on right hand side of caret
do
{
if (inLine.at(pos) == '(')
{
count = count + 1;
//cout << "PLUS ONE" << endl;
pos = pos + 1;
rhoParen = pos - 1;
}
else if (inLine.at(pos) == ')')
{
count = count - 1;
//cout << "MINUS ONE" << endl;
pos = pos + 1;
rhcParen = pos - 1;
}
else
{
//cout << "NEXT ELEMENT" << endl;
pos = pos + 1;
}
} while (count != 0 && pos <= inLine.length());
//evaluate the symbol on the left hand side if we know it is not a parenthesized expression
pos = inLine.find("^");
pos = pos - 1;
if (lhcParen == -1)
{
//kill off any white space..
while (inLine.at(pos) == ' ')
pos = pos - 1;
//set the end of the symbol to position if isalnum is true
if (isalnum(inLine.at(pos)))
lhsSymbole = pos;
while (pos != -1 && inLine.at(pos) != ' ' && pos >= 0 && isalnum(inLine.at(pos)))
{
//set the start to whatever the new position is
pos = pos - 1;
lhsSymbols = pos + 1;
if (pos <= 0) //I'm an idiot, this breaks out when we hit the end of the array
{
lhsSymbols = pos;
break;
}
}
//if we get here and:
//start is neg 1 but end is not
//we need to consume some whitespace..
if (lhsSymbols == -1 && lhsSymbole != -1 )
lhsSymbols = lhsSymbole;
}
}
//evaluate the symbol on the right hand side if we know it is not a parenthesized expression
pos = inLine.find("^");
pos = pos + 1;
if (rhoParen == -1)
{
//kill off any white space..
while (inLine.at(pos) == ' ' && pos != inLine.length())
pos = pos + 1;
//set the end of the symbol to position if isalnum is true
if (isalnum(inLine.at(pos)))
rhsSymbols = pos;
while (pos != -1 && inLine.at(pos) != ' ' && pos <= inLine.length() && isalnum(inLine.at(pos)))
{
//cout << "DEBUG" << endl;
//set the start to whatever the new position is
pos = pos + 1;
rhsSymbole = pos - 1;
if (pos >= inLine.length()) //I'm an idiot, this breaks out when we hit the end of the array
{
rhsSymbole = pos - 1;
break;
}
}
//if we get here and:
//start is neg 1 but end is not
//we need to consume some whitespace..
if (rhsSymbols == -1 && rhsSymbole != -1 )
{
rhsSymbols = rhsSymbole;
}
}
//cout << "lhoParen: " << lhoParen << endl;
//cout << "lhcParen: " << lhcParen << endl;
//cout << "rhoParen: " << rhoParen << endl;
//cout << "rhcParen: " << rhcParen << endl << endl;
//cout << "lhsSymbols: " << lhsSymbols << endl;
//cout << "lhsSymbole: " << lhsSymbole << endl;
//cout << "rhsSymbols: " << rhsSymbols << endl;
//cout << "rhsSymbole: " << rhsSymbole << endl;
//setup our return values
offsets[0] = lhoParen;
offsets[1] = lhcParen;
offsets[2] = rhoParen;
offsets[3] = rhcParen;
offsets[4] = lhsSymbols;
offsets[5] = lhsSymbole;
offsets[6] = rhsSymbols;
offsets[7] = rhsSymbole;
return 0;
}
string stringGenerator(string strtStr, int offsets[])
{
//these will be offsets in the original string to be replaced..
int lhOffsetStrt; //left hand side offsetStart
int rhOffsetStop; //right hand side offsetStop
string lhSubstr; //left hand substring
string rhSubstr; //right hand substring
string exprString; //the full caret expression
string temp = ""; //hopefully this works..
temp = strtStr; //hopefully this works..
exprString = "pow("; //we want it to start with this
//grab the left hand side substring
if (offsets[0] != -1 && offsets[1] != -1) //check if it's a parenthesized expression
{
lhOffsetStrt = offsets[0];
//return substring starting at offsets[0] and as long as the difference between the two..
lhSubstr = strtStr.substr(offsets[0] + 1, (offsets[1] - offsets[0] - 1));
//cout << "LHS PAREN EXPR!" << endl;
}
else if (offsets[4] != -1 && offsets[5] != -1) //check if it's a symbol
{
lhOffsetStrt = offsets[4];
lhSubstr = strtStr.substr(offsets[4], (offsets[5] - offsets[4] + 1));
//cout << "LHS SYMBOL EXPR!" << endl;
}
else //if it's neither then something is wrong..
{
cout << "IMPROPER LEX/PARSE LHS OF INPUT" << endl;
}
//cout << "LEFT HAND SUBSTRING: " << lhSubstr << endl;
//grab the right hand side substring
if (offsets[2] != -1 && offsets[3] != -1) //check if it's a parenthesized expression
{
rhOffsetStop = offsets[3];
rhSubstr = strtStr.substr(offsets[2] + 1, (offsets[3] - offsets[2] - 1));
//cout << "RHS PAREN EXPR!" << endl;
}
else if (offsets[6] != -1 && offsets[7] != -1) //check if it's a symbol
{
rhOffsetStop = offsets[7];
rhSubstr = strtStr.substr(offsets[6], (offsets[7] - offsets[6] + 1));
//cout << "RHS SYMBOL EXPR!" << endl;
}
else //if it's neither then something is wrong..
{
cout << "IMPROPER LEX/PARSE RHS OF INPUT" << endl;
}
//cout << "RIGHT HAND SUBSTRING: " << rhSubstr << endl;
exprString = exprString + "(" + lhSubstr + "),(" + rhSubstr + "))";
//cout << "BEFORE REPLACE STRING: " << temp << endl;
//I tried to do this with only std lib but this function was really rough to do
//using the standard string library
boost::replace_first(temp, temp.substr(lhOffsetStrt, (rhOffsetStop - lhOffsetStrt + 1)), exprString);
//cout << "AFTER REPLACE STRING: " << temp << endl;
return temp;
}
| [
"williamvanskike@gmail.com"
] | williamvanskike@gmail.com |
eb8d8915b88c49fd4917043c464b384d040a6954 | 9b2938d4ea17d29569ff5b4d2b0ed66783cddee9 | /d-pong/paddle.h | b603b3631f735e637c4a61ec384f4285fe5701ed | [] | no_license | dmateos/scratch | 87f8b6988630fb75655e2dda2d3e2e2f3df2d5a3 | 5d0092877527039bc70bcbd5e0671e5cb421f037 | refs/heads/master | 2021-01-16T18:29:33.304457 | 2016-01-27T15:04:37 | 2016-01-27T15:04:37 | 273,304 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 121 | h | #ifndef _PADDLE_H_
#define _PADDLE_H_
class Paddle {
public:
Paddle();
~Paddle();
private:
int x, y;
};
#endif
| [
"daniel@mateos.cc"
] | daniel@mateos.cc |
92ab0e93b9978b2de344b853d96cf062ea9a1d26 | ae1c6ad39b94b34b2312e7cc599321616016d767 | /HighlightTextEditor/jni/highlight/cli/cmdlineoptions.h | 3cd5679d872ab06db66c1f5a13814bebb1d49efb | [] | no_license | vbea/AideProjects | cd4481943229fd585841863bd7f66f98543e54d9 | 0d6dfc4bb1e8aea7b60483b0cbc23190f8e0f26d | refs/heads/master | 2023-01-30T09:11:11.278783 | 2023-01-14T10:28:47 | 2023-01-14T10:28:47 | 200,463,935 | 24 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 14,153 | h | /***************************************************************************
cmdlineoptions.h - description
-------------------
begin : Sun Nov 25 2001
copyright : (C) 2001-2010 by Andre Simon
email : andre.simon1@gmx.de
***************************************************************************/
/*
This file is part of Highlight.
Highlight is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Highlight 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 Highlight. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CMDLINEOPTIONS_H
#define CMDLINEOPTIONS_H
#ifdef _WIN32
#include <windows.h>
#endif
#include <string>
#include <map>
#include <set>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include "stringtools.h"
#include "enums.h"
#if ANDROID
#include <android/log.h>
#ifndef TAG_NAME
#define TAG_NAME "highliter"
#endif
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__))
#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, TAG_NAME, __VA_ARGS__))
#else
#define LOGI(...)
#define LOGW(...)
#define LOGE(...)
#endif
#define OPT_OUTFORMAT "out-format"
#define OPT_ANCHORS "anchors"
#define OPT_ANCHOR_FN "anchor-filename"
#define OPT_ANCHOR_PFX "anchor-prefix"
#define OPT_BABEL "babel"
#define OPT_BASE_FONT "font"
#define OPT_BASE_FONT_SIZE "font-size"
#define OPT_BATCHREC "batch-recursive"
#define OPT_CLASSNAME "class-name"
#define OPT_DATADIR "data-dir"
#define OPT_DELTABS "replace-tabs"
#define OPT_DOC_TITLE "doc-title"
#define OPT_ENCLOSE_PRE "enclose-pre"
#define OPT_ENCODING "encoding"
#define OPT_FILLZEROES "zeroes"
#define OPT_FORCE_OUTPUT "force"
#define OPT_FORMAT "reformat"
#define OPT_FRAGMENT "fragment"
#define OPT_HELP "help"
#define OPT_IN "input"
#define OPT_INC_STYLE "include-style"
#define OPT_INDEXFILE "print-index"
#define OPT_INLINE_CSS "inline-css"
#define OPT_KW_CASE "kw-case"
#define OPT_LINENO "line-numbers"
#define OPT_LINE_LEN "line-length"
#define OPT_LISTLANGS "list-langs"
#define OPT_LISTTHEMES "list-themes"
#define OPT_LIST_SCRIPTS "list-scripts"
#define OPT_LNR_LEN "line-number-length"
#define OPT_LNR_START "line-number-start"
#define OPT_ORDERED_LIST "ordered-list"
#define OPT_OUT "output"
#define OPT_OUTDIR "outdir"
#define OPT_RTF_PAGE_SIZE "page-size"
#define OPT_RTF_CHAR_STYLES "char-styles"
#define OPT_PRINT_CONFIG "print-config"
#define OPT_PROGRESSBAR "progress"
#define OPT_QUIET "quiet"
#define OPT_REPLACE_QUOTES "replace-quotes"
#define OPT_STYLE "style"
#define OPT_STYLE_IN "style-infile"
#define OPT_STYLE_OUT "style-outfile"
#define OPT_SYNTAX "syntax"
#define OPT_TEST_INPUT "validate-input"
#define OPT_VERBOSE "verbose"
#define OPT_VERSION "version"
#define OPT_WRAP "wrap"
#define OPT_WRAPSIMPLE "wrap-simple"
#define OPT_SVG_WIDTH "width"
#define OPT_SVG_HEIGHT "height"
#define OPT_SKIP_UNKNOWN "skip"
#define OPT_PRETTY_SYMBOLS "pretty-symbols"
#define OPT_EOL_DELIM_CR "delim-cr"
#define OPT_START_NESTED "start-nested"
#define OPT_PRINT_STYLE "print-style"
#define OPT_NO_TRAILING_NL "no-trailing-nl"
#define OPT_PLUGIN "plug-in"
#define OPT_ABS_CFG_PATH "config-file"
#define OPT_PLUGIN_READFILE "plug-in-read"
#define OPT_NO_NUMBER_WL "wrap-no-numbers"
#define OPT_USE_NBSP "nbsp"
// Improve CLI option compatibility with GNU source-highlight
#define OPT_COMPAT_DOC "doc"
#define OPT_COMPAT_NODOC "no-doc"
#define OPT_COMPAT_TAB "tab"
#define OPT_COMPAT_CSS "css"
#define OPT_COMPAT_OUTDIR "output-dir"
#define OPT_COMPAT_FAILSAFE "failsafe"
#define OPT_COMPAT_SRCLANG "src-lang"
#define OPT_COMPAT_LINENUM "line-number"
#define OPT_COMPAT_LINEREF "line-number-ref"
using namespace std;
/// handle command line options
class CmdLineOptions
{
public:
/**Constructor
\param argc Argument count
\param argv Argument strings
*/
void init (const int argc, const char *argv[] ) ;
CmdLineOptions();
CmdLineOptions ( const int argc, const char *argv[] );
~CmdLineOptions();
/** \return Single output file name*/
const string &getSingleOutFilename();
/** \return Single input file name*/
const string &getSingleInFilename() const;
/** \return Output directory*/
const string& getOutDirectory() ;
/** \return Style output file name*/
const string getStyleOutFilename() const;
/** \return Style input file name*/
const string& getStyleInFilename() const;
/** \return Char set*/
const string& getEncoding() const;
/** \return SVG width*/
const string& getSVGWidth() const;
/** \return SVG height*/
const string& getSVGHeight() const;
/** \return Number of spaces to replace a tab*/
int getNumberSpaces() const;
/** \return True if version information should be printed*/
bool printVersion() const;
/** \return True if help information should be printed*/
bool printHelp() const;
/** \return True if debug information should be printed*/
bool printDebugInfo() const;
/** \return True if configuration information should be printed*/
bool printConfigInfo() const;
/** \return True if Style definition should be included in output*/
bool includeStyleDef() const;
/** \return True if line numbers should be printed*/
bool printLineNumbers() const;
/** \return True if CR is eol delimiter */
bool useCRDelimiter() const;
/** \return colour theme name */
string getThemeName() const ;
/** gibt true zurck, falls deutsche Hilfe ausgegeben werden soll */
int helpLanguage() const;
/** \return True if batch mode is active*/
bool enableBatchMode() const;
/** \return True if output shluld be fragmented*/
bool fragmentOutput() const;
/** \return output file suffix */
string getOutFileSuffix() const;
/** \return True if anchors should be attached to line numbers*/
bool attachLineAnchors() const;
/** \return True if list of installed themes should be printed*/
bool showThemes() const;
/** \return True if list of installed language definitions should be printed*/
bool showLangdefs() const;
/** \return True if list of installed language definitions should be printed*/
bool showPlugins() const;
/** \return True if loutput directory is given*/
bool outDirGiven() const;
/** \return True if a new data directory is given*/
bool dataDirGiven() const;
/** \return True if index file should be printed*/
bool printIndexFile() const;
/** \return True if quotes should be replaced by /dq in LaTeX*/
bool replaceQuotes() const;
/** \return True if shorthands of LaTeX Babel package should be disabled*/
bool disableBabelShorthands() const;
/** \return True if input file name should be used as anchor name */
bool useFNamesAsAnchors() const;
/** \return Data directory*/
const string &getDataDir() const;
/** \return True if language syntax is given*/
bool syntaxGiven() const;
/** \return True if quiet mode is active*/
bool quietMode() const;
/** \return True if progress bar should be printed in batch mode */
bool printProgress() const;
/** \return True if line numbers are filled with leading zeroes */
bool fillLineNrZeroes() const;
/** \return programming syntax */
const string &getSyntax() const ;
/** \return Wrapping style*/
highlight::WrapMode getWrappingStyle() const;
/** \return List of input file names*/
const vector <string> & getInputFileNames() const;
/** \return indentation and reformatting scheme*/
string getIndentScheme() const;
/** \return RTF page size */
const string &getPageSize() const;
/** \return Output file format */
highlight::OutputType getOutputType() const;
/** \return True if chosen output format supports referenced style files */
bool formatSupportsExtStyle();
/** \return True if style output path was defined by user*/
bool styleOutPathDefined() const
{
return opt_stylepath_explicit;
}
/** \return True if encoding specification should be omitted in output*/
bool omitEncoding() const;
/** \return True if output should be generated if languege type is unknown*/
bool forceOutput() const;
/** \return True if line numbers should be replaced by ordered list (HTML) */
bool orderedList() const;
/** \return True if spaces should be replaced by (HTML) */
//bool useNonBreakingSpace() const;
/** \return True if a base font has been given */
bool hasBaseFont() const ;
/** \return True if input should be validated */
bool validateInput() const ;
/** \return True if wrapped lines should get unique numbers */
bool numberWrappedLines() const ;
/** \return True if CSS should be outputted within tag elements */
bool inlineCSS() const ;
/** \return True if fragmented html output should be enclosed with pre tags */
bool enclosePreTag() const ;
/** \return True if RTF output should include character styles */
bool includeCharStyles() const ;
/** \return True if LaTeX output should includ fancier symbols */
bool prettySymbols() const;
/** \return True if style should be printed */
bool printOnlyStyle() const;
/** \return The given base font, empty string by default */
const string& getBaseFont() const ;
/** \return Document title */
const string& getDocumentTitle() const ;
/** \return anchor prefix */
const string& getAnchorPrefix() const ;
/** \return class name */
const string& getClassName() const ;
const vector <string> &getPluginPaths() const;
/** \return True if trailing nl should be omitted */
bool disableTrailingNL() const ;
/** \return The given base font size, empty string by default */
const string& getBaseFontSize() const ;
/** \return name of nested syntax which starts the input */
const string& getStartNestedLang() const ;
/** \return absolute theme definition path name */
const string& getAbsThemePath() const ;
/** \return absolute language definition path name */
const string& getAbsLangPath() const ;
/** \return path of input file passed to plugin */
const string& getPluginReadFilePath() const ;
/** \return line number width */
int getNumberWidth();
/** \return line length */
int getLineLength();
/** \return Line number start count */
int getNumberStart();
/** \return Keyword Case (upper, lower, unchanged) */
StringTools::KeywordCase getKeywordCase() const;
bool isSkippedExt ( const string& ext )
{
return ignoredFileTypes.count ( ext );
}
private:
int numberSpaces; // number of spaces which replace a tab
int lineNrWidth; // width of line number (left padding)
int lineLength; // length of line before wrapping
int lineNrStart; // line number start count
highlight::WrapMode wrappingStyle; // line wrapping mode
highlight::OutputType outputType;
StringTools::KeywordCase keywordCase;
// name of single output file
string outFilename,
// output directory
outDirectory,
// programming syntax which will be loaded
syntax,
// name of colour theme
styleName,
// name of external style file
styleOutFilename,
// name of file to be included in external style file
styleInFilename,
// used to define data directories at runtime
dataDir;
// name of indenation scheme
string indentScheme,
pageSize, startNestedLang;
string baseFont, baseFontSize;
string docTitle, className;
string skipArg;
string svg_height, svg_width;
string absThemePath, absLangPath;
bool opt_syntax;
bool opt_include_style;
bool opt_help;
bool opt_version ;
bool opt_verbose;
bool opt_print_config;
bool opt_linenumbers;
bool opt_style;
bool opt_batch_mode;
bool opt_fragment;
bool opt_attach_line_anchors;
bool opt_show_themes;
bool opt_show_langdefs;
bool opt_show_plugins;
bool opt_asformat_output;
bool opt_printindex;
bool opt_quiet;
bool opt_replacequotes;
bool opt_babel;
bool opt_print_progress;
bool opt_fill_zeroes;
bool opt_stylepath_explicit;
bool opt_force_output;
bool opt_ordered_list;
bool opt_fnames_as_anchors;
bool opt_validate;
bool opt_number_wrapped_lines;
bool opt_inline_css;
bool opt_enclose_pre;
bool opt_char_styles;
bool opt_pretty_symbols;
bool opt_delim_CR;
bool opt_print_style;
bool opt_no_trailing_nl;
string anchorPrefix;
string helpLang, encodingName;
string pluginPath, pluginReadFilePath;
/** list of all input file names */
vector <string> inputFileNames;
/** list of plugin file names */
vector <string> userPlugins;
/** list lines which should be marked and supplied with help string */
map <int, string> markLines;
/** list of file types which should be ignored */
set <string> ignoredFileTypes;
/** \return file suffix */
string getFileSuffix ( const string & fileName ) const;
/** \return directory name of path */
string getDirName ( const string & path );
/** get all entries in the directory defined by wildcard */
void readDirectory ( const string & wildcard );
/** \return Boolean value of paramVal */
bool getFlag ( const string& paramVal );
/** \return Valid path name */
string validateDirPath ( const string & path );
};
#endif
| [
"vbea@foxmail.com"
] | vbea@foxmail.com |
494133e0120091ea2b466a480fa9282b16da98dd | 0f2e24348a278522127df89124f3e9fde44fc536 | /lapotop.cpp | 5da62c822949578d8f05b13784b7ac53a888b1dc | [] | no_license | Jstrykow/projectC- | 7a07ca75af10fc2dd34af219020ed8e6390e86d9 | 5d4076a4ddf56e0047be2e3b4f777810f32018c6 | refs/heads/master | 2021-02-09T19:44:33.362619 | 2020-03-02T08:26:28 | 2020-03-02T08:26:28 | 244,319,328 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,212 | cpp | #include <iostream>
#include "laptop.h"
#include "antywirus.h"
#include <string>
#include <cstdlib>
#include <fstream>
std::string Laptop::getmodel()
{
return model;
}
void Laptop::setmodel(std::string model1)
{
model = model1;
}
std::string Laptop::typ()
{
return "L";
}
void Laptop::zapisz_komputer(std::string n = "test")
{
std::fstream plik;
plik.open(n, std::fstream::out | std::fstream::app);
plik << (*this);
plik.close();
}
Laptop::Laptop()///kostruktor
{
}
Laptop::~Laptop()//dekostruktor
{
}
Laptop::Laptop( int benchmark1 , std::string uzytkownik = "Domyslny", std::string model1 = "O")
:Komputer(benchmark1, uzytkownik)
{
model = model1;
}
void Laptop::pokaz()
{
std::cout << "laptop o ktory prosiles: " << std::endl;
std::cout << "Model: " << model << std::endl;///funckjonalnosc doddana w laptopie
show();///<funkcja odziedziczona z komputer
std::cout << std::endl;
}
std::ostream & operator << (std::ostream& out2, const Laptop &L)
{
out2 << "Model: " << L.model << std::endl;
out2 << "Uzytkownik: " << L.user << std::endl;
out2 << L.processor_komputer;
return out2;
}
void Laptop::set()
{
std::cout << "podaj model: ";
std::cin >> model;
set_komputer();
}
| [
"jakub@strykowski.eu"
] | jakub@strykowski.eu |
afe93c072eaf722a4b07b4debc5367e0a758dfa8 | 534e2e3d8d8bebd2366c0fee60886d84597ee0ef | /CF/CF 949B.cpp | 2a316bb8d0abb2539d54ac1d8e29b3ebd9a1f019 | [] | no_license | coldEr66/online-judge | a8844d3f35755adafd4f43a1f08ce56b6b870601 | e85ec0750d92dd00133c93284085a0f5d8a11d36 | refs/heads/master | 2021-09-07T01:58:10.634492 | 2021-07-28T16:31:13 | 2021-07-28T16:31:13 | 128,494,315 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,181 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
_do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
_s<<"{";
for(It _it=_ita;_it!=_itb;_it++)
{
_s<<(_it==_ita?"":",")<<*_it;
}
_s<<"}";
return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;
int main(){
IOS();
ll n,q;
cin>>n>>q;
while(q--){
ll t;cin>>t;
ll tmp=n-t/2;
while(t%2==0){
t+=tmp;
tmp/=2;
}
cout<<t/2+1<<endl;
}
}
| [
"seal1000402@gmail.com"
] | seal1000402@gmail.com |
ce26026512813125ded1f93bde9cab6b036083f5 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/squid/gumtree/squid_repos_function_4480_squid-3.3.14.cpp | 66b690bf0a8059661a9e7cf726a15f370f23b1e3 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 484 | cpp | void
DestinationDomainLookup::LookupDone(const char *fqdn, const DnsLookupDetails &details, void *data)
{
ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
assert (checklist->asyncState() == DestinationDomainLookup::Instance());
checklist->asyncInProgress(false);
checklist->changeState (ACLChecklist::NullState::Instance());
checklist->markDestinationDomainChecked();
checklist->request->recordLookup(details);
checklist->matchNonBlocking();
} | [
"993273596@qq.com"
] | 993273596@qq.com |
465b3613f8637344b2a8715e6ab6a8e7da97fd31 | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h | 71100e714257defbb6e92579353acce70e909674 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 1,343 | h | // Copyright 2020 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ABSL_STRINGS_INTERNAL_STR_FORMAT_FLOAT_CONVERSION_H_
#define ABSL_STRINGS_INTERNAL_STR_FORMAT_FLOAT_CONVERSION_H_
#include "absl/strings/internal/str_format/extension.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace str_format_internal {
bool ConvertFloatImpl(float v, const FormatConversionSpecImpl &conv,
FormatSinkImpl *sink);
bool ConvertFloatImpl(double v, const FormatConversionSpecImpl &conv,
FormatSinkImpl *sink);
bool ConvertFloatImpl(long double v, const FormatConversionSpecImpl &conv,
FormatSinkImpl *sink);
} // namespace str_format_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_FLOAT_CONVERSION_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
4be8963f422de923e3d0d8ab2c6ce2d11a08558d | d990692dd7afdbb2a235ad03ac5209b4f3bb0df9 | /ipc/chromium/src/base/message_loop_unittest.cc | ed7b0c14da76539b80b2f18c9aebbe690b8daef7 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | walkero-gr/timberwolf | 5c33158a19dfeb3781c72c6732d45747d9a3c19e | 90ca7da29b6089d1b14f5ff1d08e586aa2ec041f | refs/heads/master | 2022-09-15T11:13:14.252767 | 2022-09-04T12:39:59 | 2022-09-04T12:39:59 | 291,531,351 | 0 | 0 | NOASSERTION | 2020-08-30T18:46:51 | 2020-08-30T18:46:51 | null | UTF-8 | C++ | false | false | 45,871 | cc | // Copyright (c) 2006-2008 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 "base/logging.h"
#include "base/message_loop.h"
#include "base/platform_thread.h"
#include "base/ref_counted.h"
#include "base/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include "base/message_pump_win.h"
#include "base/scoped_handle.h"
#endif
#if defined(OS_POSIX)
#include "base/message_pump_libevent.h"
#endif
using base::Thread;
using base::Time;
using base::TimeDelta;
// TODO(darin): Platform-specific MessageLoop tests should be grouped together
// to avoid chopping this file up with so many #ifdefs.
namespace {
class MessageLoopTest : public testing::Test {};
class Foo : public base::RefCounted<Foo> {
public:
Foo() : test_count_(0) {
}
void Test0() {
++test_count_;
}
void Test1ConstRef(const std::string& a) {
++test_count_;
result_.append(a);
}
void Test1Ptr(std::string* a) {
++test_count_;
result_.append(*a);
}
void Test1Int(int a) {
test_count_ += a;
}
void Test2Ptr(std::string* a, std::string* b) {
++test_count_;
result_.append(*a);
result_.append(*b);
}
void Test2Mixed(const std::string& a, std::string* b) {
++test_count_;
result_.append(a);
result_.append(*b);
}
int test_count() const { return test_count_; }
const std::string& result() const { return result_; }
private:
int test_count_;
std::string result_;
};
class QuitMsgLoop : public base::RefCounted<QuitMsgLoop> {
public:
void QuitNow() {
MessageLoop::current()->Quit();
}
};
void RunTest_PostTask(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Add tests to message loop
scoped_refptr<Foo> foo = new Foo();
std::string a("a"), b("b"), c("c"), d("d");
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test0));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1ConstRef, a));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1Ptr, &b));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1Int, 100));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test2Ptr, &a, &c));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test2Mixed, a, &d));
// After all tests, post a message that will shut down the message loop
scoped_refptr<QuitMsgLoop> quit = new QuitMsgLoop();
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
quit.get(), &QuitMsgLoop::QuitNow));
// Now kick things off
MessageLoop::current()->Run();
EXPECT_EQ(foo->test_count(), 105);
EXPECT_EQ(foo->result(), "abacad");
}
void RunTest_PostTask_SEH(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Add tests to message loop
scoped_refptr<Foo> foo = new Foo();
std::string a("a"), b("b"), c("c"), d("d");
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test0));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1ConstRef, a));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1Ptr, &b));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test1Int, 100));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test2Ptr, &a, &c));
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
foo.get(), &Foo::Test2Mixed, a, &d));
// After all tests, post a message that will shut down the message loop
scoped_refptr<QuitMsgLoop> quit = new QuitMsgLoop();
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
quit.get(), &QuitMsgLoop::QuitNow));
// Now kick things off with the SEH block active.
MessageLoop::current()->set_exception_restoration(true);
MessageLoop::current()->Run();
MessageLoop::current()->set_exception_restoration(false);
EXPECT_EQ(foo->test_count(), 105);
EXPECT_EQ(foo->result(), "abacad");
}
// This class runs slowly to simulate a large amount of work being done.
class SlowTask : public Task {
public:
SlowTask(int pause_ms, int* quit_counter)
: pause_ms_(pause_ms), quit_counter_(quit_counter) {
}
virtual void Run() {
PlatformThread::Sleep(pause_ms_);
if (--(*quit_counter_) == 0)
MessageLoop::current()->Quit();
}
private:
int pause_ms_;
int* quit_counter_;
};
// This class records the time when Run was called in a Time object, which is
// useful for building a variety of MessageLoop tests.
class RecordRunTimeTask : public SlowTask {
public:
RecordRunTimeTask(Time* run_time, int* quit_counter)
: SlowTask(10, quit_counter), run_time_(run_time) {
}
virtual void Run() {
*run_time_ = Time::Now();
// Cause our Run function to take some time to execute. As a result we can
// count on subsequent RecordRunTimeTask objects running at a future time,
// without worry about the resolution of our system clock being an issue.
SlowTask::Run();
}
private:
Time* run_time_;
};
void RunTest_PostDelayedTask_Basic(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that PostDelayedTask results in a delayed task.
const int kDelayMS = 100;
int num_tasks = 1;
Time run_time;
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time, &num_tasks), kDelayMS);
Time time_before_run = Time::Now();
loop.Run();
Time time_after_run = Time::Now();
EXPECT_EQ(0, num_tasks);
EXPECT_LT(kDelayMS, (time_after_run - time_before_run).InMilliseconds());
}
void RunTest_PostDelayedTask_InDelayOrder(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that two tasks with different delays run in the right order.
int num_tasks = 2;
Time run_time1, run_time2;
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time1, &num_tasks), 200);
// If we get a large pause in execution (due to a context switch) here, this
// test could fail.
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time2, &num_tasks), 10);
loop.Run();
EXPECT_EQ(0, num_tasks);
EXPECT_TRUE(run_time2 < run_time1);
}
void RunTest_PostDelayedTask_InPostOrder(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that two tasks with the same delay run in the order in which they
// were posted.
//
// NOTE: This is actually an approximate test since the API only takes a
// "delay" parameter, so we are not exactly simulating two tasks that get
// posted at the exact same time. It would be nice if the API allowed us to
// specify the desired run time.
const int kDelayMS = 100;
int num_tasks = 2;
Time run_time1, run_time2;
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time1, &num_tasks), kDelayMS);
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time2, &num_tasks), kDelayMS);
loop.Run();
EXPECT_EQ(0, num_tasks);
EXPECT_TRUE(run_time1 < run_time2);
}
void RunTest_PostDelayedTask_InPostOrder_2(
MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that a delayed task still runs after a normal tasks even if the
// normal tasks take a long time to run.
const int kPauseMS = 50;
int num_tasks = 2;
Time run_time;
loop.PostTask(
FROM_HERE, new SlowTask(kPauseMS, &num_tasks));
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time, &num_tasks), 10);
Time time_before_run = Time::Now();
loop.Run();
Time time_after_run = Time::Now();
EXPECT_EQ(0, num_tasks);
EXPECT_LT(kPauseMS, (time_after_run - time_before_run).InMilliseconds());
}
void RunTest_PostDelayedTask_InPostOrder_3(
MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that a delayed task still runs after a pile of normal tasks. The key
// difference between this test and the previous one is that here we return
// the MessageLoop a lot so we give the MessageLoop plenty of opportunities
// to maybe run the delayed task. It should know not to do so until the
// delayed task's delay has passed.
int num_tasks = 11;
Time run_time1, run_time2;
// Clutter the ML with tasks.
for (int i = 1; i < num_tasks; ++i)
loop.PostTask(FROM_HERE, new RecordRunTimeTask(&run_time1, &num_tasks));
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time2, &num_tasks), 1);
loop.Run();
EXPECT_EQ(0, num_tasks);
EXPECT_TRUE(run_time2 > run_time1);
}
void RunTest_PostDelayedTask_SharedTimer(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
// Test that the interval of the timer, used to run the next delayed task, is
// set to a value corresponding to when the next delayed task should run.
// By setting num_tasks to 1, we ensure that the first task to run causes the
// run loop to exit.
int num_tasks = 1;
Time run_time1, run_time2;
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time1, &num_tasks), 1000000);
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time2, &num_tasks), 10);
Time start_time = Time::Now();
loop.Run();
EXPECT_EQ(0, num_tasks);
// Ensure that we ran in far less time than the slower timer.
TimeDelta total_time = Time::Now() - start_time;
EXPECT_GT(5000, total_time.InMilliseconds());
// In case both timers somehow run at nearly the same time, sleep a little
// and then run all pending to force them both to have run. This is just
// encouraging flakiness if there is any.
PlatformThread::Sleep(100);
loop.RunAllPending();
EXPECT_TRUE(run_time1.is_null());
EXPECT_FALSE(run_time2.is_null());
}
#if defined(OS_WIN)
class SubPumpTask : public Task {
public:
virtual void Run() {
MessageLoop::current()->SetNestableTasksAllowed(true);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
MessageLoop::current()->Quit();
}
};
class SubPumpQuitTask : public Task {
public:
SubPumpQuitTask() {
}
virtual void Run() {
PostQuitMessage(0);
}
};
void RunTest_PostDelayedTask_SharedTimer_SubPump() {
MessageLoop loop(MessageLoop::TYPE_UI);
// Test that the interval of the timer, used to run the next delayed task, is
// set to a value corresponding to when the next delayed task should run.
// By setting num_tasks to 1, we ensure that the first task to run causes the
// run loop to exit.
int num_tasks = 1;
Time run_time;
loop.PostTask(FROM_HERE, new SubPumpTask());
// This very delayed task should never run.
loop.PostDelayedTask(
FROM_HERE, new RecordRunTimeTask(&run_time, &num_tasks), 1000000);
// This slightly delayed task should run from within SubPumpTask::Run().
loop.PostDelayedTask(
FROM_HERE, new SubPumpQuitTask(), 10);
Time start_time = Time::Now();
loop.Run();
EXPECT_EQ(1, num_tasks);
// Ensure that we ran in far less time than the slower timer.
TimeDelta total_time = Time::Now() - start_time;
EXPECT_GT(5000, total_time.InMilliseconds());
// In case both timers somehow run at nearly the same time, sleep a little
// and then run all pending to force them both to have run. This is just
// encouraging flakiness if there is any.
PlatformThread::Sleep(100);
loop.RunAllPending();
EXPECT_TRUE(run_time.is_null());
}
#endif // defined(OS_WIN)
class RecordDeletionTask : public Task {
public:
RecordDeletionTask(Task* post_on_delete, bool* was_deleted)
: post_on_delete_(post_on_delete), was_deleted_(was_deleted) {
}
~RecordDeletionTask() {
*was_deleted_ = true;
if (post_on_delete_)
MessageLoop::current()->PostTask(FROM_HERE, post_on_delete_);
}
virtual void Run() {}
private:
Task* post_on_delete_;
bool* was_deleted_;
};
void RunTest_EnsureTaskDeletion(MessageLoop::Type message_loop_type) {
bool a_was_deleted = false;
bool b_was_deleted = false;
{
MessageLoop loop(message_loop_type);
loop.PostTask(
FROM_HERE, new RecordDeletionTask(NULL, &a_was_deleted));
loop.PostDelayedTask(
FROM_HERE, new RecordDeletionTask(NULL, &b_was_deleted), 1000);
}
EXPECT_TRUE(a_was_deleted);
EXPECT_TRUE(b_was_deleted);
}
void RunTest_EnsureTaskDeletion_Chain(MessageLoop::Type message_loop_type) {
bool a_was_deleted = false;
bool b_was_deleted = false;
bool c_was_deleted = false;
{
MessageLoop loop(message_loop_type);
RecordDeletionTask* a = new RecordDeletionTask(NULL, &a_was_deleted);
RecordDeletionTask* b = new RecordDeletionTask(a, &b_was_deleted);
RecordDeletionTask* c = new RecordDeletionTask(b, &c_was_deleted);
loop.PostTask(FROM_HERE, c);
}
EXPECT_TRUE(a_was_deleted);
EXPECT_TRUE(b_was_deleted);
EXPECT_TRUE(c_was_deleted);
}
class NestingTest : public Task {
public:
explicit NestingTest(int* depth) : depth_(depth) {
}
void Run() {
if (*depth_ > 0) {
*depth_ -= 1;
MessageLoop::current()->PostTask(FROM_HERE, new NestingTest(depth_));
MessageLoop::current()->SetNestableTasksAllowed(true);
MessageLoop::current()->Run();
}
MessageLoop::current()->Quit();
}
private:
int* depth_;
};
#if defined(OS_WIN)
LONG WINAPI BadExceptionHandler(EXCEPTION_POINTERS *ex_info) {
ADD_FAILURE() << "bad exception handler";
::ExitProcess(ex_info->ExceptionRecord->ExceptionCode);
return EXCEPTION_EXECUTE_HANDLER;
}
// This task throws an SEH exception: initially write to an invalid address.
// If the right SEH filter is installed, it will fix the error.
class CrasherTask : public Task {
public:
// Ctor. If trash_SEH_handler is true, the task will override the unhandled
// exception handler with one sure to crash this test.
explicit CrasherTask(bool trash_SEH_handler)
: trash_SEH_handler_(trash_SEH_handler) {
}
void Run() {
PlatformThread::Sleep(1);
if (trash_SEH_handler_)
::SetUnhandledExceptionFilter(&BadExceptionHandler);
// Generate a SEH fault. We do it in asm to make sure we know how to undo
// the damage.
#if defined(_M_IX86)
__asm {
mov eax, dword ptr [CrasherTask::bad_array_]
mov byte ptr [eax], 66
}
#elif defined(_M_X64)
bad_array_[0] = 66;
#else
#error "needs architecture support"
#endif
MessageLoop::current()->Quit();
}
// Points the bad array to a valid memory location.
static void FixError() {
bad_array_ = &valid_store_;
}
private:
bool trash_SEH_handler_;
static volatile char* bad_array_;
static char valid_store_;
};
volatile char* CrasherTask::bad_array_ = 0;
char CrasherTask::valid_store_ = 0;
// This SEH filter fixes the problem and retries execution. Fixing requires
// that the last instruction: mov eax, [CrasherTask::bad_array_] to be retried
// so we move the instruction pointer 5 bytes back.
LONG WINAPI HandleCrasherTaskException(EXCEPTION_POINTERS *ex_info) {
if (ex_info->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
CrasherTask::FixError();
#if defined(_M_IX86)
ex_info->ContextRecord->Eip -= 5;
#elif defined(_M_X64)
ex_info->ContextRecord->Rip -= 5;
#endif
return EXCEPTION_CONTINUE_EXECUTION;
}
void RunTest_Crasher(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
if (::IsDebuggerPresent())
return;
LPTOP_LEVEL_EXCEPTION_FILTER old_SEH_filter =
::SetUnhandledExceptionFilter(&HandleCrasherTaskException);
MessageLoop::current()->PostTask(FROM_HERE, new CrasherTask(false));
MessageLoop::current()->set_exception_restoration(true);
MessageLoop::current()->Run();
MessageLoop::current()->set_exception_restoration(false);
::SetUnhandledExceptionFilter(old_SEH_filter);
}
void RunTest_CrasherNasty(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
if (::IsDebuggerPresent())
return;
LPTOP_LEVEL_EXCEPTION_FILTER old_SEH_filter =
::SetUnhandledExceptionFilter(&HandleCrasherTaskException);
MessageLoop::current()->PostTask(FROM_HERE, new CrasherTask(true));
MessageLoop::current()->set_exception_restoration(true);
MessageLoop::current()->Run();
MessageLoop::current()->set_exception_restoration(false);
::SetUnhandledExceptionFilter(old_SEH_filter);
}
#endif // defined(OS_WIN)
void RunTest_Nesting(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
int depth = 100;
MessageLoop::current()->PostTask(FROM_HERE, new NestingTest(&depth));
MessageLoop::current()->Run();
EXPECT_EQ(depth, 0);
}
const wchar_t* const kMessageBoxTitle = L"MessageLoop Unit Test";
enum TaskType {
MESSAGEBOX,
ENDDIALOG,
RECURSIVE,
TIMEDMESSAGELOOP,
QUITMESSAGELOOP,
ORDERERD,
PUMPS,
};
// Saves the order in which the tasks executed.
struct TaskItem {
TaskItem(TaskType t, int c, bool s)
: type(t),
cookie(c),
start(s) {
}
TaskType type;
int cookie;
bool start;
bool operator == (const TaskItem& other) const {
return type == other.type && cookie == other.cookie && start == other.start;
}
};
typedef std::vector<TaskItem> TaskList;
std::ostream& operator <<(std::ostream& os, TaskType type) {
switch (type) {
case MESSAGEBOX: os << "MESSAGEBOX"; break;
case ENDDIALOG: os << "ENDDIALOG"; break;
case RECURSIVE: os << "RECURSIVE"; break;
case TIMEDMESSAGELOOP: os << "TIMEDMESSAGELOOP"; break;
case QUITMESSAGELOOP: os << "QUITMESSAGELOOP"; break;
case ORDERERD: os << "ORDERERD"; break;
case PUMPS: os << "PUMPS"; break;
default:
NOTREACHED();
os << "Unknown TaskType";
break;
}
return os;
}
std::ostream& operator <<(std::ostream& os, const TaskItem& item) {
if (item.start)
return os << item.type << " " << item.cookie << " starts";
else
return os << item.type << " " << item.cookie << " ends";
}
// Saves the order the tasks ran.
class OrderedTasks : public Task {
public:
OrderedTasks(TaskList* order, int cookie)
: order_(order),
type_(ORDERERD),
cookie_(cookie) {
}
OrderedTasks(TaskList* order, TaskType type, int cookie)
: order_(order),
type_(type),
cookie_(cookie) {
}
void RunStart() {
TaskItem item(type_, cookie_, true);
DLOG(INFO) << item;
order_->push_back(item);
}
void RunEnd() {
TaskItem item(type_, cookie_, false);
DLOG(INFO) << item;
order_->push_back(item);
}
virtual void Run() {
RunStart();
RunEnd();
}
protected:
TaskList* order() const {
return order_;
}
int cookie() const {
return cookie_;
}
private:
TaskList* order_;
TaskType type_;
int cookie_;
};
#if defined(OS_WIN)
// MessageLoop implicitly start a "modal message loop". Modal dialog boxes,
// common controls (like OpenFile) and StartDoc printing function can cause
// implicit message loops.
class MessageBoxTask : public OrderedTasks {
public:
MessageBoxTask(TaskList* order, int cookie, bool is_reentrant)
: OrderedTasks(order, MESSAGEBOX, cookie),
is_reentrant_(is_reentrant) {
}
virtual void Run() {
RunStart();
if (is_reentrant_)
MessageLoop::current()->SetNestableTasksAllowed(true);
MessageBox(NULL, L"Please wait...", kMessageBoxTitle, MB_OK);
RunEnd();
}
private:
bool is_reentrant_;
};
// Will end the MessageBox.
class EndDialogTask : public OrderedTasks {
public:
EndDialogTask(TaskList* order, int cookie)
: OrderedTasks(order, ENDDIALOG, cookie) {
}
virtual void Run() {
RunStart();
HWND window = GetActiveWindow();
if (window != NULL) {
EXPECT_NE(EndDialog(window, IDCONTINUE), 0);
// Cheap way to signal that the window wasn't found if RunEnd() isn't
// called.
RunEnd();
}
}
};
#endif // defined(OS_WIN)
class RecursiveTask : public OrderedTasks {
public:
RecursiveTask(int depth, TaskList* order, int cookie, bool is_reentrant)
: OrderedTasks(order, RECURSIVE, cookie),
depth_(depth),
is_reentrant_(is_reentrant) {
}
virtual void Run() {
RunStart();
if (depth_ > 0) {
if (is_reentrant_)
MessageLoop::current()->SetNestableTasksAllowed(true);
MessageLoop::current()->PostTask(FROM_HERE,
new RecursiveTask(depth_ - 1, order(), cookie(), is_reentrant_));
}
RunEnd();
}
private:
int depth_;
bool is_reentrant_;
};
class QuitTask : public OrderedTasks {
public:
QuitTask(TaskList* order, int cookie)
: OrderedTasks(order, QUITMESSAGELOOP, cookie) {
}
virtual void Run() {
RunStart();
MessageLoop::current()->Quit();
RunEnd();
}
};
#if defined(OS_WIN)
class Recursive2Tasks : public Task {
public:
Recursive2Tasks(MessageLoop* target,
HANDLE event,
bool expect_window,
TaskList* order,
bool is_reentrant)
: target_(target),
event_(event),
expect_window_(expect_window),
order_(order),
is_reentrant_(is_reentrant) {
}
virtual void Run() {
target_->PostTask(FROM_HERE,
new RecursiveTask(2, order_, 1, is_reentrant_));
target_->PostTask(FROM_HERE,
new MessageBoxTask(order_, 2, is_reentrant_));
target_->PostTask(FROM_HERE,
new RecursiveTask(2, order_, 3, is_reentrant_));
// The trick here is that for recursive task processing, this task will be
// ran _inside_ the MessageBox message loop, dismissing the MessageBox
// without a chance.
// For non-recursive task processing, this will be executed _after_ the
// MessageBox will have been dismissed by the code below, where
// expect_window_ is true.
target_->PostTask(FROM_HERE, new EndDialogTask(order_, 4));
target_->PostTask(FROM_HERE, new QuitTask(order_, 5));
// Enforce that every tasks are sent before starting to run the main thread
// message loop.
ASSERT_TRUE(SetEvent(event_));
// Poll for the MessageBox. Don't do this at home! At the speed we do it,
// you will never realize one MessageBox was shown.
for (; expect_window_;) {
HWND window = FindWindow(L"#32770", kMessageBoxTitle);
if (window) {
// Dismiss it.
for (;;) {
HWND button = FindWindowEx(window, NULL, L"Button", NULL);
if (button != NULL) {
EXPECT_TRUE(0 == SendMessage(button, WM_LBUTTONDOWN, 0, 0));
EXPECT_TRUE(0 == SendMessage(button, WM_LBUTTONUP, 0, 0));
break;
}
}
break;
}
}
}
private:
MessageLoop* target_;
HANDLE event_;
TaskList* order_;
bool expect_window_;
bool is_reentrant_;
};
#endif // defined(OS_WIN)
void RunTest_RecursiveDenial1(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
TaskList order;
MessageLoop::current()->PostTask(FROM_HERE,
new RecursiveTask(2, &order, 1, false));
MessageLoop::current()->PostTask(FROM_HERE,
new RecursiveTask(2, &order, 2, false));
MessageLoop::current()->PostTask(FROM_HERE, new QuitTask(&order, 3));
MessageLoop::current()->Run();
// FIFO order.
ASSERT_EQ(14U, order.size());
EXPECT_EQ(order[ 0], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 1], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 2], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[ 3], TaskItem(RECURSIVE, 2, false));
EXPECT_EQ(order[ 4], TaskItem(QUITMESSAGELOOP, 3, true));
EXPECT_EQ(order[ 5], TaskItem(QUITMESSAGELOOP, 3, false));
EXPECT_EQ(order[ 6], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 7], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 8], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[ 9], TaskItem(RECURSIVE, 2, false));
EXPECT_EQ(order[10], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[11], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[12], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[13], TaskItem(RECURSIVE, 2, false));
}
void RunTest_RecursiveSupport1(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
TaskList order;
MessageLoop::current()->PostTask(FROM_HERE,
new RecursiveTask(2, &order, 1, true));
MessageLoop::current()->PostTask(FROM_HERE,
new RecursiveTask(2, &order, 2, true));
MessageLoop::current()->PostTask(FROM_HERE,
new QuitTask(&order, 3));
MessageLoop::current()->Run();
// FIFO order.
ASSERT_EQ(14U, order.size());
EXPECT_EQ(order[ 0], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 1], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 2], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[ 3], TaskItem(RECURSIVE, 2, false));
EXPECT_EQ(order[ 4], TaskItem(QUITMESSAGELOOP, 3, true));
EXPECT_EQ(order[ 5], TaskItem(QUITMESSAGELOOP, 3, false));
EXPECT_EQ(order[ 6], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 7], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 8], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[ 9], TaskItem(RECURSIVE, 2, false));
EXPECT_EQ(order[10], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[11], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[12], TaskItem(RECURSIVE, 2, true));
EXPECT_EQ(order[13], TaskItem(RECURSIVE, 2, false));
}
#if defined(OS_WIN)
// TODO(darin): These tests need to be ported since they test critical
// message loop functionality.
// A side effect of this test is the generation a beep. Sorry.
void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
Thread worker("RecursiveDenial2_worker");
Thread::Options options;
options.message_loop_type = message_loop_type;
ASSERT_EQ(true, worker.StartWithOptions(options));
TaskList order;
ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
worker.message_loop()->PostTask(FROM_HERE,
new Recursive2Tasks(MessageLoop::current(),
event,
true,
&order,
false));
// Let the other thread execute.
WaitForSingleObject(event, INFINITE);
MessageLoop::current()->Run();
ASSERT_EQ(order.size(), 17);
EXPECT_EQ(order[ 0], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 1], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 2], TaskItem(MESSAGEBOX, 2, true));
EXPECT_EQ(order[ 3], TaskItem(MESSAGEBOX, 2, false));
EXPECT_EQ(order[ 4], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[ 5], TaskItem(RECURSIVE, 3, false));
// When EndDialogTask is processed, the window is already dismissed, hence no
// "end" entry.
EXPECT_EQ(order[ 6], TaskItem(ENDDIALOG, 4, true));
EXPECT_EQ(order[ 7], TaskItem(QUITMESSAGELOOP, 5, true));
EXPECT_EQ(order[ 8], TaskItem(QUITMESSAGELOOP, 5, false));
EXPECT_EQ(order[ 9], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[10], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[11], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[12], TaskItem(RECURSIVE, 3, false));
EXPECT_EQ(order[13], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[14], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[15], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[16], TaskItem(RECURSIVE, 3, false));
}
// A side effect of this test is the generation a beep. Sorry. This test also
// needs to process windows messages on the current thread.
void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
Thread worker("RecursiveSupport2_worker");
Thread::Options options;
options.message_loop_type = message_loop_type;
ASSERT_EQ(true, worker.StartWithOptions(options));
TaskList order;
ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
worker.message_loop()->PostTask(FROM_HERE,
new Recursive2Tasks(MessageLoop::current(),
event,
false,
&order,
true));
// Let the other thread execute.
WaitForSingleObject(event, INFINITE);
MessageLoop::current()->Run();
ASSERT_EQ(order.size(), 18);
EXPECT_EQ(order[ 0], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[ 1], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[ 2], TaskItem(MESSAGEBOX, 2, true));
// Note that this executes in the MessageBox modal loop.
EXPECT_EQ(order[ 3], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[ 4], TaskItem(RECURSIVE, 3, false));
EXPECT_EQ(order[ 5], TaskItem(ENDDIALOG, 4, true));
EXPECT_EQ(order[ 6], TaskItem(ENDDIALOG, 4, false));
EXPECT_EQ(order[ 7], TaskItem(MESSAGEBOX, 2, false));
/* The order can subtly change here. The reason is that when RecursiveTask(1)
is called in the main thread, if it is faster than getting to the
PostTask(FROM_HERE, QuitTask) execution, the order of task execution can
change. We don't care anyway that the order isn't correct.
EXPECT_EQ(order[ 8], TaskItem(QUITMESSAGELOOP, 5, true));
EXPECT_EQ(order[ 9], TaskItem(QUITMESSAGELOOP, 5, false));
EXPECT_EQ(order[10], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[11], TaskItem(RECURSIVE, 1, false));
*/
EXPECT_EQ(order[12], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[13], TaskItem(RECURSIVE, 3, false));
EXPECT_EQ(order[14], TaskItem(RECURSIVE, 1, true));
EXPECT_EQ(order[15], TaskItem(RECURSIVE, 1, false));
EXPECT_EQ(order[16], TaskItem(RECURSIVE, 3, true));
EXPECT_EQ(order[17], TaskItem(RECURSIVE, 3, false));
}
#endif // defined(OS_WIN)
class TaskThatPumps : public OrderedTasks {
public:
TaskThatPumps(TaskList* order, int cookie)
: OrderedTasks(order, PUMPS, cookie) {
}
virtual void Run() {
RunStart();
bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
MessageLoop::current()->RunAllPending();
MessageLoop::current()->SetNestableTasksAllowed(old_state);
RunEnd();
}
};
// Tests that non nestable tasks run in FIFO if there are no nested loops.
void RunTest_NonNestableWithNoNesting(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
TaskList order;
Task* task = new OrderedTasks(&order, 1);
MessageLoop::current()->PostNonNestableTask(FROM_HERE, task);
MessageLoop::current()->PostTask(FROM_HERE, new OrderedTasks(&order, 2));
MessageLoop::current()->PostTask(FROM_HERE, new QuitTask(&order, 3));
MessageLoop::current()->Run();
// FIFO order.
ASSERT_EQ(6U, order.size());
EXPECT_EQ(order[ 0], TaskItem(ORDERERD, 1, true));
EXPECT_EQ(order[ 1], TaskItem(ORDERERD, 1, false));
EXPECT_EQ(order[ 2], TaskItem(ORDERERD, 2, true));
EXPECT_EQ(order[ 3], TaskItem(ORDERERD, 2, false));
EXPECT_EQ(order[ 4], TaskItem(QUITMESSAGELOOP, 3, true));
EXPECT_EQ(order[ 5], TaskItem(QUITMESSAGELOOP, 3, false));
}
// Tests that non nestable tasks don't run when there's code in the call stack.
void RunTest_NonNestableInNestedLoop(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
TaskList order;
MessageLoop::current()->PostTask(FROM_HERE,
new TaskThatPumps(&order, 1));
Task* task = new OrderedTasks(&order, 2);
MessageLoop::current()->PostNonNestableTask(FROM_HERE, task);
MessageLoop::current()->PostTask(FROM_HERE, new OrderedTasks(&order, 3));
MessageLoop::current()->PostTask(FROM_HERE, new OrderedTasks(&order, 4));
Task* non_nestable_quit = new QuitTask(&order, 5);
MessageLoop::current()->PostNonNestableTask(FROM_HERE, non_nestable_quit);
MessageLoop::current()->Run();
// FIFO order.
ASSERT_EQ(10U, order.size());
EXPECT_EQ(order[ 0], TaskItem(PUMPS, 1, true));
EXPECT_EQ(order[ 1], TaskItem(ORDERERD, 3, true));
EXPECT_EQ(order[ 2], TaskItem(ORDERERD, 3, false));
EXPECT_EQ(order[ 3], TaskItem(ORDERERD, 4, true));
EXPECT_EQ(order[ 4], TaskItem(ORDERERD, 4, false));
EXPECT_EQ(order[ 5], TaskItem(PUMPS, 1, false));
EXPECT_EQ(order[ 6], TaskItem(ORDERERD, 2, true));
EXPECT_EQ(order[ 7], TaskItem(ORDERERD, 2, false));
EXPECT_EQ(order[ 8], TaskItem(QUITMESSAGELOOP, 5, true));
EXPECT_EQ(order[ 9], TaskItem(QUITMESSAGELOOP, 5, false));
}
#if defined(OS_WIN)
class DispatcherImpl : public MessageLoopForUI::Dispatcher {
public:
DispatcherImpl() : dispatch_count_(0) {}
virtual bool Dispatch(const MSG& msg) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
return (++dispatch_count_ != 2);
}
int dispatch_count_;
};
void RunTest_Dispatcher(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
class MyTask : public Task {
public:
virtual void Run() {
PostMessage(NULL, WM_LBUTTONDOWN, 0, 0);
PostMessage(NULL, WM_LBUTTONUP, 'A', 0);
}
};
Task* task = new MyTask();
MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 100);
DispatcherImpl dispatcher;
MessageLoopForUI::current()->Run(&dispatcher);
ASSERT_EQ(2, dispatcher.dispatch_count_);
}
class TestIOHandler : public MessageLoopForIO::IOHandler {
public:
TestIOHandler(const wchar_t* name, HANDLE signal, bool wait);
virtual void OnIOCompleted(MessageLoopForIO::IOContext* context,
DWORD bytes_transfered, DWORD error);
void Init();
void WaitForIO();
OVERLAPPED* context() { return &context_.overlapped; }
DWORD size() { return sizeof(buffer_); }
private:
char buffer_[48];
MessageLoopForIO::IOContext context_;
HANDLE signal_;
ScopedHandle file_;
bool wait_;
};
TestIOHandler::TestIOHandler(const wchar_t* name, HANDLE signal, bool wait)
: signal_(signal), wait_(wait) {
memset(buffer_, 0, sizeof(buffer_));
memset(&context_, 0, sizeof(context_));
context_.handler = this;
file_.Set(CreateFile(name, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, NULL));
EXPECT_TRUE(file_.IsValid());
}
void TestIOHandler::Init() {
MessageLoopForIO::current()->RegisterIOHandler(file_, this);
DWORD read;
EXPECT_FALSE(ReadFile(file_, buffer_, size(), &read, context()));
EXPECT_EQ(ERROR_IO_PENDING, GetLastError());
if (wait_)
WaitForIO();
}
void TestIOHandler::OnIOCompleted(MessageLoopForIO::IOContext* context,
DWORD bytes_transfered, DWORD error) {
ASSERT_TRUE(context == &context_);
ASSERT_TRUE(SetEvent(signal_));
}
void TestIOHandler::WaitForIO() {
EXPECT_TRUE(MessageLoopForIO::current()->WaitForIOCompletion(300, this));
EXPECT_TRUE(MessageLoopForIO::current()->WaitForIOCompletion(400, this));
}
class IOHandlerTask : public Task {
public:
explicit IOHandlerTask(TestIOHandler* handler) : handler_(handler) {}
virtual void Run() {
handler_->Init();
}
private:
TestIOHandler* handler_;
};
void RunTest_IOHandler() {
ScopedHandle callback_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ASSERT_TRUE(callback_called.IsValid());
const wchar_t* kPipeName = L"\\\\.\\pipe\\iohandler_pipe";
ScopedHandle server(CreateNamedPipe(kPipeName, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ASSERT_TRUE(server.IsValid());
Thread thread("IOHandler test");
Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
ASSERT_TRUE(thread.StartWithOptions(options));
MessageLoop* thread_loop = thread.message_loop();
ASSERT_TRUE(NULL != thread_loop);
TestIOHandler handler(kPipeName, callback_called, false);
IOHandlerTask* task = new IOHandlerTask(&handler);
thread_loop->PostTask(FROM_HERE, task);
Sleep(100); // Make sure the thread runs and sleeps for lack of work.
const char buffer[] = "Hello there!";
DWORD written;
EXPECT_TRUE(WriteFile(server, buffer, sizeof(buffer), &written, NULL));
DWORD result = WaitForSingleObject(callback_called, 1000);
EXPECT_EQ(WAIT_OBJECT_0, result);
thread.Stop();
}
void RunTest_WaitForIO() {
ScopedHandle callback1_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ScopedHandle callback2_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ASSERT_TRUE(callback1_called.IsValid());
ASSERT_TRUE(callback2_called.IsValid());
const wchar_t* kPipeName1 = L"\\\\.\\pipe\\iohandler_pipe1";
const wchar_t* kPipeName2 = L"\\\\.\\pipe\\iohandler_pipe2";
ScopedHandle server1(CreateNamedPipe(kPipeName1, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ScopedHandle server2(CreateNamedPipe(kPipeName2, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ASSERT_TRUE(server1.IsValid());
ASSERT_TRUE(server2.IsValid());
Thread thread("IOHandler test");
Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
ASSERT_TRUE(thread.StartWithOptions(options));
MessageLoop* thread_loop = thread.message_loop();
ASSERT_TRUE(NULL != thread_loop);
TestIOHandler handler1(kPipeName1, callback1_called, false);
TestIOHandler handler2(kPipeName2, callback2_called, true);
IOHandlerTask* task1 = new IOHandlerTask(&handler1);
IOHandlerTask* task2 = new IOHandlerTask(&handler2);
thread_loop->PostTask(FROM_HERE, task1);
Sleep(100); // Make sure the thread runs and sleeps for lack of work.
thread_loop->PostTask(FROM_HERE, task2);
Sleep(100);
// At this time handler1 is waiting to be called, and the thread is waiting
// on the Init method of handler2, filtering only handler2 callbacks.
const char buffer[] = "Hello there!";
DWORD written;
EXPECT_TRUE(WriteFile(server1, buffer, sizeof(buffer), &written, NULL));
Sleep(200);
EXPECT_EQ(WAIT_TIMEOUT, WaitForSingleObject(callback1_called, 0)) <<
"handler1 has not been called";
EXPECT_TRUE(WriteFile(server2, buffer, sizeof(buffer), &written, NULL));
HANDLE objects[2] = { callback1_called.Get(), callback2_called.Get() };
DWORD result = WaitForMultipleObjects(2, objects, TRUE, 1000);
EXPECT_EQ(WAIT_OBJECT_0, result);
thread.Stop();
}
#endif // defined(OS_WIN)
} // namespace
//-----------------------------------------------------------------------------
// Each test is run against each type of MessageLoop. That way we are sure
// that message loops work properly in all configurations. Of course, in some
// cases, a unit test may only be for a particular type of loop.
TEST(MessageLoopTest, PostTask) {
RunTest_PostTask(MessageLoop::TYPE_DEFAULT);
RunTest_PostTask(MessageLoop::TYPE_UI);
RunTest_PostTask(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostTask_SEH) {
RunTest_PostTask_SEH(MessageLoop::TYPE_DEFAULT);
RunTest_PostTask_SEH(MessageLoop::TYPE_UI);
RunTest_PostTask_SEH(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_Basic) {
RunTest_PostDelayedTask_Basic(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_Basic(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_Basic(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_InDelayOrder) {
RunTest_PostDelayedTask_InDelayOrder(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_InDelayOrder(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_InDelayOrder(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_InPostOrder) {
RunTest_PostDelayedTask_InPostOrder(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_InPostOrder(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_InPostOrder(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_InPostOrder_2) {
RunTest_PostDelayedTask_InPostOrder_2(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_InPostOrder_2(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_InPostOrder_2(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_InPostOrder_3) {
RunTest_PostDelayedTask_InPostOrder_3(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_InPostOrder_3(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_InPostOrder_3(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, PostDelayedTask_SharedTimer) {
RunTest_PostDelayedTask_SharedTimer(MessageLoop::TYPE_DEFAULT);
RunTest_PostDelayedTask_SharedTimer(MessageLoop::TYPE_UI);
RunTest_PostDelayedTask_SharedTimer(MessageLoop::TYPE_IO);
}
#if defined(OS_WIN)
TEST(MessageLoopTest, PostDelayedTask_SharedTimer_SubPump) {
RunTest_PostDelayedTask_SharedTimer_SubPump();
}
#endif
// TODO(darin): re-enable these tests once MessageLoop supports them again.
#if 0
TEST(MessageLoopTest, EnsureTaskDeletion) {
RunTest_EnsureTaskDeletion(MessageLoop::TYPE_DEFAULT);
RunTest_EnsureTaskDeletion(MessageLoop::TYPE_UI);
RunTest_EnsureTaskDeletion(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, EnsureTaskDeletion_Chain) {
RunTest_EnsureTaskDeletion_Chain(MessageLoop::TYPE_DEFAULT);
RunTest_EnsureTaskDeletion_Chain(MessageLoop::TYPE_UI);
RunTest_EnsureTaskDeletion_Chain(MessageLoop::TYPE_IO);
}
#endif
#if defined(OS_WIN)
TEST(MessageLoopTest, Crasher) {
RunTest_Crasher(MessageLoop::TYPE_DEFAULT);
RunTest_Crasher(MessageLoop::TYPE_UI);
RunTest_Crasher(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, CrasherNasty) {
RunTest_CrasherNasty(MessageLoop::TYPE_DEFAULT);
RunTest_CrasherNasty(MessageLoop::TYPE_UI);
RunTest_CrasherNasty(MessageLoop::TYPE_IO);
}
#endif // defined(OS_WIN)
TEST(MessageLoopTest, Nesting) {
RunTest_Nesting(MessageLoop::TYPE_DEFAULT);
RunTest_Nesting(MessageLoop::TYPE_UI);
RunTest_Nesting(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, RecursiveDenial1) {
RunTest_RecursiveDenial1(MessageLoop::TYPE_DEFAULT);
RunTest_RecursiveDenial1(MessageLoop::TYPE_UI);
RunTest_RecursiveDenial1(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, RecursiveSupport1) {
RunTest_RecursiveSupport1(MessageLoop::TYPE_DEFAULT);
RunTest_RecursiveSupport1(MessageLoop::TYPE_UI);
RunTest_RecursiveSupport1(MessageLoop::TYPE_IO);
}
#if defined(OS_WIN)
TEST(MessageLoopTest, RecursiveDenial2) {
RunTest_RecursiveDenial2(MessageLoop::TYPE_DEFAULT);
RunTest_RecursiveDenial2(MessageLoop::TYPE_UI);
RunTest_RecursiveDenial2(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, RecursiveSupport2) {
// This test requires a UI loop
RunTest_RecursiveSupport2(MessageLoop::TYPE_UI);
}
#endif // defined(OS_WIN)
TEST(MessageLoopTest, NonNestableWithNoNesting) {
RunTest_NonNestableWithNoNesting(MessageLoop::TYPE_DEFAULT);
RunTest_NonNestableWithNoNesting(MessageLoop::TYPE_UI);
RunTest_NonNestableWithNoNesting(MessageLoop::TYPE_IO);
}
TEST(MessageLoopTest, NonNestableInNestedLoop) {
RunTest_NonNestableInNestedLoop(MessageLoop::TYPE_DEFAULT);
RunTest_NonNestableInNestedLoop(MessageLoop::TYPE_UI);
RunTest_NonNestableInNestedLoop(MessageLoop::TYPE_IO);
}
#if defined(OS_WIN)
TEST(MessageLoopTest, Dispatcher) {
// This test requires a UI loop
RunTest_Dispatcher(MessageLoop::TYPE_UI);
}
TEST(MessageLoopTest, IOHandler) {
RunTest_IOHandler();
}
TEST(MessageLoopTest, WaitForIO) {
RunTest_WaitForIO();
}
#endif // defined(OS_WIN)
#if defined(OS_POSIX)
namespace {
class QuitDelegate : public
base::MessagePumpLibevent::Watcher {
public:
virtual void OnFileCanWriteWithoutBlocking(int fd) {
MessageLoop::current()->Quit();
}
virtual void OnFileCanReadWithoutBlocking(int fd) {
MessageLoop::current()->Quit();
}
};
} // namespace
TEST(MessageLoopTest, DISABLED_FileDescriptorWatcherOutlivesMessageLoop) {
// Simulate a MessageLoop that dies before an FileDescriptorWatcher.
// This could happen when people use the Singleton pattern or atexit.
// This is disabled for now because it fails (valgrind shows
// invalid reads), and it's not clear any code relies on this...
// TODO(dkegel): enable if it turns out we rely on this
// Create a file descriptor. Doesn't need to be readable or writable,
// as we don't need to actually get any notifications.
// pipe() is just the easiest way to do it.
int pipefds[2];
int err = pipe(pipefds);
ASSERT_TRUE(err == 0);
int fd = pipefds[1];
{
// Arrange for controller to live longer than message loop.
base::MessagePumpLibevent::FileDescriptorWatcher controller;
{
MessageLoopForIO message_loop;
QuitDelegate delegate;
message_loop.WatchFileDescriptor(fd,
true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
// and don't run the message loop, just destroy it.
}
}
close(pipefds[0]);
close(pipefds[1]);
}
TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) {
// Verify that it's ok to call StopWatchingFileDescriptor().
// (Errors only showed up in valgrind.)
int pipefds[2];
int err = pipe(pipefds);
ASSERT_TRUE(err == 0);
int fd = pipefds[1];
{
// Arrange for message loop to live longer than controller.
MessageLoopForIO message_loop;
{
base::MessagePumpLibevent::FileDescriptorWatcher controller;
QuitDelegate delegate;
message_loop.WatchFileDescriptor(fd,
true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
controller.StopWatchingFileDescriptor();
}
}
close(pipefds[0]);
close(pipefds[1]);
}
#endif // defined(OS_LINUX)
| [
"benjamin@smedbergs.us"
] | benjamin@smedbergs.us |
011193a50bfddee09b20f199e5a5035ff28b4e8b | 6fa8376cc78f1586b7df3b4e3037daeab4828e3f | /test/TestCore/TestDifferentiability.cpp | ecc8c5b0cecd804285b014a5a538e44ce4b3877f | [
"MIT"
] | permissive | alexweav/BackpropFramework | 99db0feb870698436d3cd1c7f06a6a2f60de46fe | 2de396628180db1e6535037663497f9814e83039 | refs/heads/master | 2021-01-01T17:38:53.431150 | 2018-06-04T00:53:57 | 2018-06-04T00:53:57 | 98,120,105 | 1 | 0 | MIT | 2018-06-04T00:53:58 | 2017-07-23T19:21:50 | C++ | UTF-8 | C++ | false | false | 981 | cpp | #include "TestCore.h"
TEST_F(DifferentiabilityTest, LeafNodesHaveDifferentiableTree) {
EXPECT_TRUE(cons1->HasDifferentiableTree());
EXPECT_TRUE(cons2->HasDifferentiableTree());
}
TEST_F(DifferentiabilityTest, ConstantChannelDifferentiable) {
EXPECT_TRUE(cons1->Channels(0).IsDifferentiableFunctor());
EXPECT_TRUE(cons2->Channels(0).IsDifferentiableFunctor());
}
TEST_F(DifferentiabilityTest, NonDifferentiableNodeNotDifferentiable) {
EXPECT_TRUE(nonDiffCons1->HasDifferentiableTree());
EXPECT_FALSE(nonDiffCons1->Channels(0).IsDifferentiableFunctor());
}
TEST_F(DifferentiabilityTest, TestDifferentiableTreeFunction) {
EXPECT_TRUE(addDiff->HasDifferentiableTree());
EXPECT_TRUE(addDiff->Channels(0).IsDifferentiableFunctor());
}
TEST_F(DifferentiabilityTest, TestNonDifferentiableTreeFunction) {
EXPECT_FALSE(addNonDiffComposition->HasDifferentiableTree());
EXPECT_TRUE(addNonDiffComposition->Channels(0).IsDifferentiableFunctor());
}
| [
"alexander.weaver@ttu.edu"
] | alexander.weaver@ttu.edu |
4d2ccecec054227ec8f74ccdd9b5c0a843cadb67 | 3e35cd073cd7a6627ab670eb03b2845a67a7f2c3 | /include/gaia_network_httpserver.h | db2fd913001fa697aac8dd0bea3467f300aefad5 | [] | no_license | sylarchen0906/GAIA | 0db1613060432b3ad9c5e3d0201eeb2ec5863cb7 | c4839827a85353c5dee18879ad8520582dd1ecbe | refs/heads/master | 2020-05-26T21:34:30.691139 | 2017-02-17T15:24:50 | 2017-02-17T15:24:50 | 82,507,676 | 0 | 0 | null | 2017-02-20T02:22:28 | 2017-02-20T02:22:28 | null | UTF-8 | C++ | false | false | 1,802 | h | #ifndef __GAIA_NETWORK_HTTPSERVER_H__
#define __GAIA_NETWORK_HTTPSERVER_H__
#include "gaia_type.h"
#include "gaia_assert.h"
//#include "gaia_sync_lock.h"
//#include "gaia_sync_autolock.h"
//#include "gaia_sync_lockrw.h"
//#include "gaia_sync_autolockr.h"
//#include "gaia_sync_autolockw.h"
//#include "gaia_ctn_ref.h"
//#include "gaia_ctn_vector.h"
//#include "gaia_ctn_queue.h"
//#include "gaia_ctn_buffer.h"
//#include "gaia_ctn_pool.h"
//#include "gaia_ctn_list.h"
//#include "gaia_ctn_set.h"
#include "gaia_network_ip.h"
#include "gaia_network_addr.h"
//#include "gaia_network_base.h"
//#include "gaia_network_socket.h"
#include "gaia_network_asyncsocket.h"
#include "gaia_network_asyncdispatcher.h"
#include "gaia_network_httpbase.h"
namespace GAIA
{
namespace NETWORK
{
class HttpServerDesc : public GAIA::Base
{
public:
};
class HttpServerCallBack : public GAIA::Base
{
public:
protected:
virtual GAIA::BL OnRecv(GAIA::NETWORK::AsyncSocket& sock, const GAIA::GVOID* p, GAIA::NUM sSize){return GAIA::False;}
virtual GAIA::BL OnRecv(const GAIA::NETWORK::HttpURL& url, const GAIA::NETWORK::HttpHead& httphead){return GAIA::False;}
};
class HttpServer : public GAIA::Base
{
public:
HttpServer();
~HttpServer();
GAIA::BL Create(const HttpServerDesc& desc);
GAIA::BL Destroy();
GAIA::BL IsCreated() const;
const HttpServerDesc& GetDesc() const;
GAIA::BL Startup();
GAIA::BL Shutdown();
GAIA::BL IsStartuped() const;
GAIA::BL OpenAddr(const GAIA::NETWORK::Addr& addr);
GAIA::BL CloseAddr(const GAIA::NETWORK::Addr& addr);
GAIA::BL CloseAddrAll();
GAIA::BL IsOpennedAddr() const;
GAIA::NUM GetOpennedAddrCount() const;
const GAIA::NETWORK::Addr* GetOpennedAddr(GAIA::NUM sIndex) const;
private:
};
}
}
#endif
| [
"70601797@qq.com"
] | 70601797@qq.com |
29ccd19340040a4407098ed88c7ba05f7f35ee0a | f4f8e9b55f4ec4a6733bd71596c7206d1270094b | /tensorflow-yolo-ios/dependencies/eigen/doc/snippets/SparseMatrix_coeffs.cpp | 532e59856d3c30017fd18ef2e7996dfe33ce0cbd | [
"MIT"
] | permissive | initialz/tensorflow-yolo-face-ios | 1e71a73c9814a24fc3ca36a61f2abc7a4b32ad63 | ba74cf39168d0128e91318e65a1b88ce4d65a167 | refs/heads/master | 2021-08-19T19:22:34.604864 | 2017-11-27T07:39:21 | 2017-11-27T07:39:21 | 112,151,522 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 128 | cpp | version https://git-lfs.github.com/spec/v1
oid sha256:792cca442007f942beda639f16b2cf736e7df3c1e42eb15d8d61b6c4c28088a5
size 411
| [
"kaiwen.yuan1992@gmail.com"
] | kaiwen.yuan1992@gmail.com |
354e9fb82a5067879b51a366794b722c2103b5e0 | e433566a524fd56b871bdd93685e0b8f2985574c | /drone_project/drone_ws/devel/include/bebop_msgs/CommonCommonStateMassStorageInfoStateListChanged.h | 9d890d53deafc68a473f6ba69c184393f624f88e | [] | no_license | JarrettPhilips/self_landing_drone | 000b2f386302555f1876fbc38ada71d12451f8e0 | 7e497492941d9f642d4991c3fbc5be20e63f965e | refs/heads/master | 2021-09-14T13:20:14.536053 | 2017-12-20T00:16:55 | 2017-12-20T00:16:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,213 | h | // Generated by gencpp from file bebop_msgs/CommonCommonStateMassStorageInfoStateListChanged.msg
// DO NOT EDIT!
#ifndef BEBOP_MSGS_MESSAGE_COMMONCOMMONSTATEMASSSTORAGEINFOSTATELISTCHANGED_H
#define BEBOP_MSGS_MESSAGE_COMMONCOMMONSTATEMASSSTORAGEINFOSTATELISTCHANGED_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 <std_msgs/Header.h>
namespace bebop_msgs
{
template <class ContainerAllocator>
struct CommonCommonStateMassStorageInfoStateListChanged_
{
typedef CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> Type;
CommonCommonStateMassStorageInfoStateListChanged_()
: header()
, mass_storage_id(0)
, size(0)
, used_size(0)
, plugged(0)
, full(0)
, internal(0) {
}
CommonCommonStateMassStorageInfoStateListChanged_(const ContainerAllocator& _alloc)
: header(_alloc)
, mass_storage_id(0)
, size(0)
, used_size(0)
, plugged(0)
, full(0)
, internal(0) {
(void)_alloc;
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef uint8_t _mass_storage_id_type;
_mass_storage_id_type mass_storage_id;
typedef uint32_t _size_type;
_size_type size;
typedef uint32_t _used_size_type;
_used_size_type used_size;
typedef uint8_t _plugged_type;
_plugged_type plugged;
typedef uint8_t _full_type;
_full_type full;
typedef uint8_t _internal_type;
_internal_type internal;
typedef boost::shared_ptr< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> const> ConstPtr;
}; // struct CommonCommonStateMassStorageInfoStateListChanged_
typedef ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<std::allocator<void> > CommonCommonStateMassStorageInfoStateListChanged;
typedef boost::shared_ptr< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged > CommonCommonStateMassStorageInfoStateListChangedPtr;
typedef boost::shared_ptr< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged const> CommonCommonStateMassStorageInfoStateListChangedConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace bebop_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True}
// {'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'bebop_msgs': ['/home/user/Documents/drone/drone_project/drone_ws/src/bebop_autonomy/bebop_msgs/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< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
{
static const char* value()
{
return "2ca92d7dc2cd357b6c1f89b1084ed001";
}
static const char* value(const ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x2ca92d7dc2cd357bULL;
static const uint64_t static_value2 = 0x6c1f89b1084ed001ULL;
};
template<class ContainerAllocator>
struct DataType< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
{
static const char* value()
{
return "bebop_msgs/CommonCommonStateMassStorageInfoStateListChanged";
}
static const char* value(const ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
{
static const char* value()
{
return "# CommonCommonStateMassStorageInfoStateListChanged\n\
# auto-generated from up stream XML files at\n\
# github.com/Parrot-Developers/libARCommands/tree/master/Xml\n\
# To check upstream commit hash, refer to last_build_info file\n\
# Do not modify this file by hand. Check scripts/meta folder for generator files.\n\
#\n\
# SDK Comment: Mass storage info state list.\n\
\n\
Header header\n\
\n\
# Mass storage state id (unique)\n\
uint8 mass_storage_id\n\
# Mass storage size in MBytes\n\
uint32 size\n\
# Mass storage used size in MBytes\n\
uint32 used_size\n\
# Mass storage plugged (1 if mass storage is plugged, otherwise 0)\n\
uint8 plugged\n\
# Mass storage full information state (1 if mass storage full, 0 otherwise).\n\
uint8 full\n\
# Mass storage internal type state (1 if mass storage is internal, 0 otherwise)\n\
uint8 internal\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\
";
}
static const char* value(const ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.mass_storage_id);
stream.next(m.size);
stream.next(m.used_size);
stream.next(m.plugged);
stream.next(m.full);
stream.next(m.internal);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct CommonCommonStateMassStorageInfoStateListChanged_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::bebop_msgs::CommonCommonStateMassStorageInfoStateListChanged_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "mass_storage_id: ";
Printer<uint8_t>::stream(s, indent + " ", v.mass_storage_id);
s << indent << "size: ";
Printer<uint32_t>::stream(s, indent + " ", v.size);
s << indent << "used_size: ";
Printer<uint32_t>::stream(s, indent + " ", v.used_size);
s << indent << "plugged: ";
Printer<uint8_t>::stream(s, indent + " ", v.plugged);
s << indent << "full: ";
Printer<uint8_t>::stream(s, indent + " ", v.full);
s << indent << "internal: ";
Printer<uint8_t>::stream(s, indent + " ", v.internal);
}
};
} // namespace message_operations
} // namespace ros
#endif // BEBOP_MSGS_MESSAGE_COMMONCOMMONSTATEMASSSTORAGEINFOSTATELISTCHANGED_H
| [
"masc7859@colorado.edu"
] | masc7859@colorado.edu |
de131b7d7b25bde07083279fcadcf000d5b65c0e | 007867b4937f52de7746f79124ef104b2d183f5a | /计算几何/凸包/PKU 3348 Cows.cpp | f9d929ba327d78926bf29331795b9ed03afe8dba | [] | no_license | WhereIsHeroFrom/Algorithm | 84dcee3174dbcd9e996442f07627a96c46f6c74a | 6bf620d6219770db60b40d151eecd686955ab723 | refs/heads/master | 2023-08-05T14:05:48.385791 | 2021-10-06T00:21:39 | 2021-10-06T00:21:39 | 306,805,686 | 16 | 4 | null | null | null | null | GB18030 | C++ | false | false | 8,119 | cpp | #include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
const int MAXP = 100010;
const double eps = 1e-10;
#define INT_POINT
#ifdef INT_POINT
typedef int PointType;
typedef long long MultiplyType; // 由于乘法可能导致 int 溢出,所以需要定义一种乘法后的类型(平方、叉乘、点乘)
#else
typedef double PointType;
typedef double MultiplyType;
#endif
typedef int PointIndex;
// 小于
bool ST(PointType a, PointType b) {
#ifdef INT_POINT
return a < b;
#else
return a - b < -eps;
#endif
}
// 等于
bool EQ(PointType a, PointType b) {
#ifdef INT_POINT
return a == b;
#else
return fabs(a - b) < eps;
#endif
}
// 大于
bool LT(PointType a, PointType b) {
return !ST(a, b) && !EQ(a, b);
}
int TernaryFunc(double v) {
if (EQ(v, 0)) {
return 0;
}
return ST(v, 0) ? -1 : 1;
}
MultiplyType SQR(MultiplyType x) {
return x * x;
}
class Point2D {
public:
Point2D() : x_(0), y_(0) {}
Point2D(PointType x, PointType y) : x_(x), y_(y) {}
bool zero() const;
Point2D operator + (const Point2D& pt) const;
Point2D operator - (const Point2D& pt) const;
MultiplyType cross(const Point2D& pt) const;
bool operator < (const Point2D& pt) const;
bool operator == (const Point2D& pt) const;
MultiplyType distSquare(const Point2D& pt) const;
static bool angleCmp(const Point2D& a, const Point2D& b);
void calculateAngle(const Point2D& o);
void read(int idx);
void print();
double getAngle() const;
Point2D getMinusYPoint() const;
private:
PointType x_, y_;
double angle_; // 相对于左下角点的极角
double distSqr_; // 相对于左下角点的距离平方
int index_; // 在原数组的下标,方便索引用
};
typedef Point2D Vector2D;
bool Point2D::zero() const {
return EQ(x_, 0) && EQ(y_, 0);
}
Point2D Point2D::operator + (const Point2D& pt) const {
return Point2D(x_ + pt.x_, y_ + pt.y_);
}
Point2D Point2D::operator - (const Point2D& pt) const {
return Point2D(x_ - pt.x_, y_ - pt.y_);
}
MultiplyType Vector2D::cross(const Vector2D& pt) const {
return (MultiplyType)x_ * pt.y_ - (MultiplyType)y_ * pt.x_;
}
bool Point2D::operator<(const Point2D& pt) const {
// 1. 第一关键字: y 小的
// 2. 第二关键字: x 小的
if (!EQ(y_, pt.y_)) {
return ST(y_, pt.y_);
}
return ST(x_, pt.x_);
}
bool Point2D::operator==(const Point2D& pt) const {
return (*this - pt).zero();
}
MultiplyType Point2D::distSquare(const Point2D& pt) const {
Point2D t = *this - pt;
return SQR(t.x_) + SQR(t.y_);
}
bool Point2D::angleCmp(const Point2D& a, const Point2D& b) {
if (fabs(a.angle_ - b.angle_) < eps) {
return a.distSqr_ < b.distSqr_;
}
return a.angle_ < b.angle_;
}
void Point2D::calculateAngle(const Point2D& o) {
Point2D t = *this - o;
if (t.zero()) {
// 该情况下 atan2 是 undefined 的,需要单独处理
angle_ = 0;
distSqr_ = 0;
}
else {
angle_ = atan2(0.0 + t.y_, 0.0 + t.x_); // 这里 y >= 0 是能保证的,所以值在 [0, PI] 之间
distSqr_ = distSquare(o);
}
}
void Point2D::read(int idx) {
#ifdef INT_POINT
scanf("%d %d", &x_, &y_);
#else
scanf("%lf %lf", &x_, &y_);
#endif
index_ = idx;
}
void Point2D::print() {
#ifdef INT_POINT
printf("%d %d\n", x_, y_);
#else
printf("%lf %lf", x_, y_);
#endif
}
double Point2D::getAngle() const {
return angle_;
}
Point2D Point2D::getMinusYPoint() const
{
return Point2D(x_, -y_);
}
class Polygon {
private:
void grahamScan_Pre(); // 计算凸包前的准备工作
void grahamScan_Post(bool flag, Polygon& ret); // 填充凸包的点到给定的多边形
public:
bool isPoint() const; // 求完凸包以后判断是否是一个点
bool isLine() const; // 求完凸包以后判断是否是一条线
void grahamScan(bool flag, Polygon& ret);
double area();
double length();
void clear();
void addPoint(const Point2D& pt);
public:
//bool output(int cas); // 根据不同情况提供的开放接口
private:
int n_;
Point2D point_[MAXP];
PointIndex stack_[MAXP];
int top_;
};
bool Polygon::isPoint() const {
if (n_ <= 1) {
return true;
}
return point_[n_ - 1] == point_[0];
}
bool Polygon::isLine() const {
if (n_ <= 2) {
return true;
}
return (TernaryFunc((point_[n_ - 1] - point_[0]).cross(point_[1] - point_[0])) == 0);
}
void Polygon::grahamScan_Pre()
{
// 1. 首先将最下面的那个点(如果y相同,则取最左边)找出来放到 point_[0] 的位置
for (int i = 1; i < n_; ++i) {
if (point_[i] < point_[0]) {
swap(point_[i], point_[0]);
}
}
// 2. 对 point_[0] 计算极角
for (int i = 1; i < n_; ++i) {
point_[i].calculateAngle(point_[0]);
}
// 3. 极角排序
sort(point_ + 1, point_ + n_, Point2D::angleCmp);
}
void Polygon::grahamScan_Post(bool flag, Polygon& ret) {
ret.n_ = top_;
for (int i = 0; i < top_; ++i) {
ret.point_[i] = point_[stack_[i]];
}
if (ret.isPoint() || ret.isLine()) {
// 是点或者线的情况不进行补点
return;
}
// Graham 扫描算法的改进,如果要考虑边上的点
// 那么最后一条多边形的回边
if (flag) {
for (int i = n_ - 1; i >= 0; --i) {
if (point_[i] == ret.point_[top_ - 1]) continue;
if (fabs(point_[i].getAngle() - ret.point_[top_ - 1].getAngle()) < eps) {
// 极角相同的点必须补回来
ret.point_[ret.n_++] = point_[i];
}
else break;
}
}
}
// flag 是否算上边上的点、重复点
void Polygon::grahamScan(bool flag, Polygon& ret) {
// 找到极值坐标系原点,并且按照极角排序
grahamScan_Pre();
// 栈底永远是那个极值坐标系的原点
top_ = 0;
stack_[top_++] = 0;
for (int i = 1; i < n_; ++i) {
if ((point_[i] - point_[0]).zero()) {
// 和原点有重合,即多点重复
if (flag) {
stack_[top_++] = i;
}
continue;
}
while (top_ >= 2) {
Point2D p1 = point_[stack_[top_ - 1]] - point_[stack_[top_ - 2]];
Point2D p2 = point_[i] - point_[stack_[top_ - 2]];
MultiplyType crossRet = p1.cross(p2);
// 如果选择边上的点,那么叉乘结果大于等于0是允许的
// 如果不选择边上的点,那么叉乘结果大于0是允许的
if (flag && TernaryFunc(crossRet) < 0 || !flag && TernaryFunc(crossRet) <= 0)
--top_;
else
break;
}
stack_[top_++] = i;
}
grahamScan_Post(flag, ret);
}
double Polygon::area() {
double ans = 0;
point_[n_] = point_[0];
for (int i = 1; i < n_; ++i) {
ans += (point_[i] - point_[0]).cross(point_[i + 1] - point_[0]);
}
return ans / 2;
}
double Polygon::length() {
if (n_ == 1) {
return 0;
}
else if (n_ == 2) {
return sqrt(0.0 + point_[1].distSquare(point_[0])) * 2;
}
double ans = 0;
point_[n_] = point_[0];
for (int i = 0; i < n_; ++i) {
ans += sqrt(0.0 + point_[i].distSquare(point_[i + 1]));
}
return ans;
}
void Polygon::clear() {
n_ = 0;
top_ = 0;
}
void Polygon::addPoint(const Point2D& pt) {
point_[n_++] = pt;
}
Polygon P, Res;
int main() {
int t;
int cas, n;
while (scanf("%d", &n) != EOF) {
P.clear();
for (int i = 0; i < n; ++i) {
Point2D pt;
pt.read(i);
P.addPoint(pt);
}
P.grahamScan(false, Res);
printf("%d\n", int(Res.area() / 50 + eps));
}
return 0;
}
/*
12
0 0
0 0
2 0
4 0
-4 2
-2 2
0 2
2 2
4 2
3 3
2 4
4 4
6
0 0
1 0
2 0
2 1
2 2
1 1
5
0 0
1 0
2 0
2 1
2 2
*/ | [
"menjitianya2007@163.com"
] | menjitianya2007@163.com |
420b59b58d791c8bb4646c9509cb0a3aeda87ccf | fe6b0a0e981bb6fd356fc4467835dd1a52a0a49a | /Assets/StreamingAssets/Audio/GeneratedSoundBanks/Wwise_IDs.h | 6a5e82966f247a3c8da41952eda3d999b3dfc1a7 | [] | no_license | FruitPunchSamurai12/GJL | 107883d0c89a099522ec86c7cd9479fa5925d517 | 912206f3eef2dc51248a0386703133e8f510e155 | refs/heads/main | 2023-08-09T21:03:30.383352 | 2021-09-16T12:37:19 | 2021-09-16T12:37:19 | 340,971,530 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,291 | h | /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Audiokinetic Wwise generated include file. Do not edit.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __WWISE_IDS_H__
#define __WWISE_IDS_H__
#include <AK/SoundEngine/Common/AkTypes.h>
namespace AK
{
namespace EVENTS
{
static const AkUniqueID MX_PLAY_MAIN_MENU = 890084909U;
static const AkUniqueID MX_SETSTATE = 1128714786U;
static const AkUniqueID PLAY_BABY_CRYING = 753280365U;
static const AkUniqueID PLAY_BOTTLE_SMASH = 1131775195U;
static const AkUniqueID PLAY_DOOR_CLOSE = 2292458263U;
static const AkUniqueID PLAY_DOOR_OPEN = 1660008929U;
static const AkUniqueID PLAY_EXPLOSION = 4030404899U;
static const AkUniqueID PLAY_FLIRT = 1692061147U;
static const AkUniqueID PLAY_FOOTSTEPS = 3854155799U;
static const AkUniqueID PLAY_FRYING_PAN_KNOCKOUT = 3561477708U;
static const AkUniqueID PLAY_FRYING_PAN_SWING = 4261233702U;
static const AkUniqueID PLAY_FRYING_PAN_THROW = 1939857692U;
static const AkUniqueID PLAY_GRAB_DOCUMENT = 3205592208U;
static const AkUniqueID PLAY_ITEM_PICKUP = 2652605998U;
static const AkUniqueID PLAY_ITEM_PUTDOWN = 4250118861U;
static const AkUniqueID PLAY_ITEM_THROW = 3065584282U;
static const AkUniqueID PLAY_ITEM_THROW_CHARGE = 3278353889U;
static const AkUniqueID PLAY_PICKPOCKET_KEYS = 1684266438U;
static const AkUniqueID PLAY_SAFE_DOOR_OPEN = 2092973319U;
static const AkUniqueID PLAY_UI_CHARACTER_SWITCH = 3663550651U;
static const AkUniqueID PLAY_UI_CLICK_DECISION = 2581004938U;
static const AkUniqueID PLAY_UI_CLICK_REGULAR = 1319291932U;
static const AkUniqueID PLAY_UI_HOVER = 1339559671U;
static const AkUniqueID PLAY_UI_MAIN_START_BUTTON = 703069780U;
static const AkUniqueID PLAY_VASE_SMASH = 2250361604U;
static const AkUniqueID PLAY_WINDOW_SMASH = 3352654671U;
static const AkUniqueID START_AREA_AMB = 4278971852U;
static const AkUniqueID START_BBQ_AMB = 2771104862U;
static const AkUniqueID START_FOREST_AMBIENCE = 3194767864U;
static const AkUniqueID START_FOUNTAIN_AMB = 3248596991U;
static const AkUniqueID START_LEAVES_AMB = 3322761575U;
static const AkUniqueID START_WASHING_MACHINE_AMB = 3630086782U;
} // namespace EVENTS
namespace STATES
{
namespace CURRENT_CHARACTER
{
static const AkUniqueID GROUP = 1176230744U;
namespace STATE
{
static const AkUniqueID BABY = 1543097833U;
static const AkUniqueID DAD = 311764516U;
static const AkUniqueID MOM = 1082004790U;
static const AkUniqueID NONE = 748895195U;
} // namespace STATE
} // namespace CURRENT_CHARACTER
namespace GAME_STATES
{
static const AkUniqueID GROUP = 2721494480U;
namespace STATE
{
static const AkUniqueID ALERT = 721787521U;
static const AkUniqueID ENTERED_HOUSE = 2563422499U;
static const AkUniqueID FINALE = 2540243936U;
static const AkUniqueID IDLE = 1874288895U;
static const AkUniqueID NONE = 748895195U;
static const AkUniqueID SUSPICIOUS = 3270337040U;
} // namespace STATE
} // namespace GAME_STATES
} // namespace STATES
namespace SWITCHES
{
namespace CHARACTER_SELECT
{
static const AkUniqueID GROUP = 3311442969U;
namespace SWITCH
{
static const AkUniqueID BABY = 1543097833U;
static const AkUniqueID DAD = 311764516U;
static const AkUniqueID MOM = 1082004790U;
} // namespace SWITCH
} // namespace CHARACTER_SELECT
namespace SURFACE_TYPE
{
static const AkUniqueID GROUP = 4064446173U;
namespace SWITCH
{
static const AkUniqueID CONCRETE = 841620460U;
static const AkUniqueID GRASS = 4248645337U;
static const AkUniqueID INTERIOR = 1132214669U;
} // namespace SWITCH
} // namespace SURFACE_TYPE
} // namespace SWITCHES
namespace GAME_PARAMETERS
{
static const AkUniqueID MUSIC_VOLUME = 1006694123U;
static const AkUniqueID SOUND_VOLUME = 495870151U;
} // namespace GAME_PARAMETERS
namespace BANKS
{
static const AkUniqueID INIT = 1355168291U;
static const AkUniqueID MUSIC = 3991942870U;
static const AkUniqueID SFX_MAIN = 3023356346U;
} // namespace BANKS
namespace BUSSES
{
static const AkUniqueID MASTER_AUDIO_BUS = 2392784291U;
static const AkUniqueID MASTER_MUSIC_BUS = 609974080U;
} // namespace BUSSES
namespace AUDIO_DEVICES
{
static const AkUniqueID NO_OUTPUT = 2317455096U;
static const AkUniqueID SYSTEM = 3859886410U;
} // namespace AUDIO_DEVICES
}// namespace AK
#endif // __WWISE_IDS_H__
| [
"rbarry.audio@gmail.com"
] | rbarry.audio@gmail.com |
460698bfb56bb298c9b40a562de8c86dab33dc40 | 770bf6029669a3b96830b160b61331870fcea9a3 | /ÖRNEKLER/PG33-ClassKisiler/PG33-ClassKisiler/stdafx.cpp | de4faacc00dc5aaf0f8505a3fad31e882678b897 | [] | no_license | mustafraca/Programlamaya-Giris-OrnekveOdevler | 9f71729a1c3dfae966380d258b8ce09a023c11ba | 4d7cb7dea3e0e2068fa53ada76afc7d383118455 | refs/heads/master | 2021-01-03T03:36:28.647172 | 2020-02-12T01:44:13 | 2020-02-12T01:44:13 | 239,903,855 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 296 | cpp | // stdafx.cpp : source file that includes just the standard includes
// PG33-ClassKisiler.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"36599634+mustafraca@users.noreply.github.com"
] | 36599634+mustafraca@users.noreply.github.com |
f69d926dfaaa7ab744d962c75858c2353f063356 | 722732c3c575070f04d69896e094584b2e1c6b85 | /BulletHellMaker/src/Editor/EMP/EditorMovablePointPanel.cpp | 7442fd55cb929afb308b1c457a8785bd2b593c1d | [] | no_license | Miv99/BulletHellMaker | 6c702bf01bbc3f31f3ef0fe9482b760bebbf1101 | 6ad7fafab763bd2241e5e669c95c53f60fe182b5 | refs/heads/master | 2021-11-29T18:41:40.026183 | 2021-11-14T21:36:47 | 2021-11-14T21:36:47 | 175,186,909 | 3 | 1 | null | 2020-08-20T03:44:00 | 2019-03-12T10:24:32 | C++ | UTF-8 | C++ | false | false | 74,502 | cpp | #include <Editor/EMP/EditorMovablePointPanel.h>
#include <Mutex.h>
#include <Config.h>
#include <GuiConfig.h>
#include <Util/StringUtils.h>
#include <Editor/Util/EditorUtils.h>
#include <Editor/EMPA/EditorMovablePointActionPanel.h>
const std::string EditorMovablePointPanel::PROPERTIES_TAB_NAME = "MP Properties";
const std::string EditorMovablePointPanel::MOVEMENT_TAB_NAME = "MP Movement";
std::string EditorMovablePointPanel::getID(BULLET_ON_COLLISION_ACTION onCollisionAction) {
return std::to_string(static_cast<int>(onCollisionAction));
}
BULLET_ON_COLLISION_ACTION EditorMovablePointPanel::fromID(std::string id) {
return static_cast<BULLET_ON_COLLISION_ACTION>(std::stoi(std::string(id)));
}
std::string EditorMovablePointPanel::getID(std::shared_ptr<EMPSpawnType> spawnType) {
if (dynamic_cast<SpecificGlobalEMPSpawn*>(spawnType.get())) {
return "0";
} else if (dynamic_cast<EntityRelativeEMPSpawn*>(spawnType.get())) {
return "1";
} else if (dynamic_cast<EntityAttachedEMPSpawn*>(spawnType.get())) {
return "2";
}
}
EditorMovablePointPanel::EditorMovablePointPanel(MainEditorWindow& mainEditorWindow, std::shared_ptr<LevelPack> levelPack, SpriteLoader& spriteLoader, Clipboard& clipboard, std::shared_ptr<EditorMovablePoint> emp, int undoStackSize)
: CopyPasteable(EMP_COPY_PASTE_ID), mainEditorWindow(mainEditorWindow), levelPack(levelPack), emp(emp), clipboard(clipboard), undoStack(UndoStack(undoStackSize)) {
std::lock_guard<std::recursive_mutex> lock(tguiMutex);
spawnTypePositionMarkerPlacer = SingleMarkerPlacer::create(*(mainEditorWindow.getWindow()), clipboard);
spawnTypePositionMarkerPlacer->setPosition(0, 0);
spawnTypePositionMarkerPlacer->setSize("100%", "100%");
spawnTypePositionMarkerPlacerFinishEditing = tgui::Button::create();
spawnTypePositionMarkerPlacerFinishEditing->setSize(100, TEXT_BUTTON_HEIGHT);
spawnTypePositionMarkerPlacerFinishEditing->setTextSize(TEXT_SIZE);
spawnTypePositionMarkerPlacerFinishEditing->setText("Finish");
spawnTypePositionMarkerPlacerFinishEditing->onPress.connect([this]() {
finishEditingSpawnTypePosition();
});
tabs = TabsWithPanel::create(mainEditorWindow);
tabs->setPosition(0, 0);
tabs->setSize("100%", "100%");
add(tabs);
{
// Properties
propertiesPanel = tgui::ScrollablePanel::create();
id = tgui::Label::create();
empiAnimatableLabel = tgui::Label::create();
empiAnimatable = AnimatableChooser::create(spriteLoader);
// Invisible if empiAnimatable's value is a sprite
empiLoopAnimation = tgui::CheckBox::create("Loop animation");
// Invisible if loopAnimation is checked or a sprite is selected in empiAnimatable
empiBaseSpriteLabel = tgui::Label::create();
empiBaseSprite = AnimatableChooser::create(spriteLoader, true);
isBullet = tgui::CheckBox::create("Is bullet");
empiHitboxRadiusLabel = tgui::Label::create();
empiHitboxRadius = EditBox::create();
empiDespawnTimeLabel = tgui::Label::create();
// Max value is sum of time taken for every EMPA in empiActions
empiDespawnTime = std::make_shared<SliderWithEditBox>();
empiSpawnTypeLabel = tgui::Label::create();
// Entry ID is from getID()
empiSpawnType = tgui::ComboBox::create();
empiSpawnTypeTimeLabel = tgui::Label::create();
empiSpawnTypeTime = EditBox::create();
empiSpawnTypeXLabel = tgui::Label::create();
empiSpawnTypeX = EditBox::create();
empiSpawnTypeYLabel = tgui::Label::create();
empiSpawnTypeY = EditBox::create();
empiSpawnLocationManualSet = tgui::Button::create();
empiShadowTrailLifespanLabel = tgui::Label::create();
empiShadowTrailLifespan = EditBox::create();
empiShadowTrailIntervalLabel = tgui::Label::create();
empiShadowTrailInterval = EditBox::create();
empiDamageLabel = tgui::Label::create();
empiDamage = EditBox::create();
empiOnCollisionActionLabel = tgui::Label::create();
// Entry ID obtained from getID()
empiOnCollisionAction = tgui::ComboBox::create();
empiPierceResetTimeLabel = tgui::Label::create();
empiPierceResetTime = EditBox::create();
empiSoundSettingsLabel = tgui::Label::create();
empiSoundSettings = SoundSettingsGroup::create(format(RELATIVE_LEVEL_PACK_SOUND_FOLDER_PATH, levelPack->getName().c_str()));
empiBulletModelLabel = tgui::Label::create();
// Entry ID is bullet model ID
empiBulletModel = tgui::ComboBox::create();
empiInheritRadius = tgui::CheckBox::create();
empiInheritDespawnTime = tgui::CheckBox::create();
empiInheritShadowTrailInterval = tgui::CheckBox::create();
empiInheritShadowTrailLifespan = tgui::CheckBox::create();
empiInheritAnimatables = tgui::CheckBox::create();
empiInheritDamage = tgui::CheckBox::create();
empiInheritPierceResetTime = tgui::CheckBox::create();
empiInheritSoundSettings = tgui::CheckBox::create();
empiAnimatableLabel->setToolTip(createToolTip("The default sprite/animation for this movable point."));
empiLoopAnimation->setToolTip(createToolTip("If this is checked, the default animation will loop indefinitely."));
empiBaseSpriteLabel->setToolTip(createToolTip("The fallback sprite after the animation finishes. Only used if the default animation does not loop."));
isBullet->setToolTip(createToolTip("If this is checked, this movable point will be a bullet that is able to damage entities. If the bullet originated from \
a player, it can damage only enemies. If the bullet originated from an enemy, it can damage only players."));
empiHitboxRadiusLabel->setToolTip(createToolTip("The radius of this bullet. Only used if this movable point is a bullet."));
empiDespawnTimeLabel->setToolTip(createToolTip("Number of seconds after being spawned that this movable point despawns. When a movable point despawns, every movable point \
attached to it also despawns, so this effectively despawns all movable points in the movable point attachment tree with this one as the root."));
empiSpawnTypeLabel->setToolTip(createToolTip("Determines how this movable point will be spawned.\n\n\
\"Relative to map origin\" - Spawns at some absolute position\n\n\
\"Detached, relative to parent\" - Spawns relative to this movable point's parent\n\n\
\"Attached, relative to parent\" - Spawns relative to this movable point's parent and moves relative to its parent until this movable point does a detach movement action"));
empiSpawnTypeTimeLabel->setToolTip(createToolTip("Number of seconds after this movable point's parent spawns that this movable point spawns. If \
this movable point is the main movable point of its attack (the root of the attack's movable point tree), this value will be fixed to 0 so this movable point spawns as soon \
as the attack is executed."));
empiSpawnTypeXLabel->setToolTip(createToolTip("The x-position for this movable point's spawn. See \"Spawn type\" for how this position will be interpreted."));
empiSpawnTypeYLabel->setToolTip(createToolTip("The y-position for this movable point's spawn. See \"Spawn type\" for how this position will be interpreted."));
empiSpawnLocationManualSet->setToolTip(createToolTip("Opens a map to help visualize and set this movable point's spawn position."));
empiShadowTrailLifespanLabel->setToolTip(createToolTip("Number of seconds each of this movable point's shadows last. Shadows are purely visual and create a movement trail."));
empiShadowTrailIntervalLabel->setToolTip(createToolTip("Number of seconds between the creation of each shadow. Shadows are purely visual and create a movement trail."));
empiDamageLabel->setToolTip(createToolTip("Damage dealt to an enemy/player on contact with this bullet. Only used if this movable point is a bullet. Value will be rounded to the nearest integer."));
empiOnCollisionActionLabel->setToolTip(createToolTip("Determines how this bullet will act on contact with an enemy/player.\n\n\
\"Destroy self only\" - This bullet becomes invisible and intangible upon hitting an enemy/player but will still continue following its movement actions until it despawns. \
This means any movable points attached to this bullet when it collided with an enemy/player will behave as if nothing happened. \n\n\
\"Destroy self and attached children\" - This bullet, and every movable point attached to it, despawns upon hitting an enemy/player. When a movable point despawns, every movable point \
attached to it also despawns, so this effectively despawns all movable points in the movable point attachment tree with this one as the root. \n\n\
\"Pierce players/enemies\" - This bullet does not do anything special upon hitting an enemy/player, so it is able to hit multiple enemies/players multiple times. \
Each enemy/player can be hit at most every \"Pierce reset time\" seconds by the same bullet. Players also have a custom invulnerability time every time they take damage, \
so this should be considered as well."));
empiPierceResetTimeLabel->setToolTip(createToolTip("Minimum number of seconds after this bullet hits a player/enemy that it can hit the same player/enemy again. \
Players also have a custom invulnerability time every time they take damage, so this should be considered as well."));
empiSoundSettingsLabel->setToolTip(createToolTip("Settings for the sound to be played when this movable point is spawned."));
empiBulletModelLabel->setToolTip(createToolTip("The movable point model that this movable point will use. This is purely for convenience by allowing this movable point to \
use the radius, despawn time, shadow settings, sprites and animations, damage, and/or sound settings of some user-defined model such that whenever the model is updated, this movable \
point will update only the values it wants to inherit to match the model."));
empiInheritRadius->setToolTip(createToolTip("If this is checked, this movable point will use its model's radius."));
empiInheritDespawnTime->setToolTip(createToolTip("If this is checked, this movable point will use its model's despawn time."));
empiInheritShadowTrailInterval->setToolTip(createToolTip("If this is checked, this movable point will use its model's shadow trail interval."));
empiInheritShadowTrailLifespan->setToolTip(createToolTip("If this is checked, this movable point will use its model's shadow trail lifespan."));
empiInheritAnimatables->setToolTip(createToolTip("If this is checked, this movable point will use its model's sprites and animations."));
empiInheritDamage->setToolTip(createToolTip("If this is checked, this movable point will use its model's damage."));
empiInheritPierceResetTime->setToolTip(createToolTip("If this is checked, this movable point will use its model's pierce reset time."));
empiInheritSoundSettings->setToolTip(createToolTip("If this is checked, this movable point will use its model's sound settings."));
propertiesPanel->setHorizontalScrollAmount(SCROLL_AMOUNT);
propertiesPanel->setVerticalScrollAmount(SCROLL_AMOUNT);
empiSpawnType->setChangeItemOnScroll(false);
empiOnCollisionAction->setChangeItemOnScroll(false);
empiBulletModel->setChangeItemOnScroll(false);
id->setTextSize(TEXT_SIZE);
empiAnimatableLabel->setTextSize(TEXT_SIZE);
empiLoopAnimation->setTextSize(TEXT_SIZE);
empiBaseSpriteLabel->setTextSize(TEXT_SIZE);
isBullet->setTextSize(TEXT_SIZE);
empiHitboxRadiusLabel->setTextSize(TEXT_SIZE);
empiHitboxRadius->setTextSize(TEXT_SIZE);
empiDespawnTimeLabel->setTextSize(TEXT_SIZE);
empiDespawnTime->setTextSize(TEXT_SIZE);
empiSpawnTypeLabel->setTextSize(TEXT_SIZE);
empiSpawnType->setTextSize(TEXT_SIZE);
empiSpawnTypeTimeLabel->setTextSize(TEXT_SIZE);
empiSpawnTypeTime->setTextSize(TEXT_SIZE);
empiSpawnTypeXLabel->setTextSize(TEXT_SIZE);
empiSpawnTypeX->setTextSize(TEXT_SIZE);
empiSpawnTypeYLabel->setTextSize(TEXT_SIZE);
empiSpawnTypeY->setTextSize(TEXT_SIZE);
empiSpawnLocationManualSet->setTextSize(TEXT_SIZE);
empiShadowTrailLifespanLabel->setTextSize(TEXT_SIZE);
empiShadowTrailLifespan->setTextSize(TEXT_SIZE);
empiShadowTrailIntervalLabel->setTextSize(TEXT_SIZE);
empiShadowTrailInterval->setTextSize(TEXT_SIZE);
empiDamageLabel->setTextSize(TEXT_SIZE);
empiDamage->setTextSize(TEXT_SIZE);
empiOnCollisionActionLabel->setTextSize(TEXT_SIZE);
empiOnCollisionAction->setTextSize(TEXT_SIZE);
empiPierceResetTimeLabel->setTextSize(TEXT_SIZE);
empiPierceResetTime->setTextSize(TEXT_SIZE);
empiBulletModelLabel->setTextSize(TEXT_SIZE);
empiBulletModel->setTextSize(TEXT_SIZE);
empiInheritRadius->setTextSize(TEXT_SIZE);
empiInheritDespawnTime->setTextSize(TEXT_SIZE);
empiInheritShadowTrailInterval->setTextSize(TEXT_SIZE);
empiInheritShadowTrailLifespan->setTextSize(TEXT_SIZE);
empiInheritAnimatables->setTextSize(TEXT_SIZE);
empiInheritDamage->setTextSize(TEXT_SIZE);
empiInheritPierceResetTime->setTextSize(TEXT_SIZE);
empiInheritSoundSettings->setTextSize(TEXT_SIZE);
empiSoundSettingsLabel->setTextSize(TEXT_SIZE);
id->setText("Movable point ID " + std::to_string(emp->getID()));
empiHitboxRadiusLabel->setText("Hitbox radius");
empiAnimatableLabel->setText("Sprite/Animation");
empiBaseSpriteLabel->setText("Base sprite");
empiDespawnTimeLabel->setText("Time to despawn");
empiSpawnTypeLabel->setText("Spawn type");
empiSpawnTypeTimeLabel->setText("Spawn delay");
empiSpawnTypeXLabel->setText("Spawn X");
empiSpawnTypeYLabel->setText("Spawn Y");
empiSpawnLocationManualSet->setText("Spawn position manual set");
empiShadowTrailLifespanLabel->setText("Shadow trail lifespan");
empiShadowTrailIntervalLabel->setText("Shadow trail spawn interval");
empiDamageLabel->setText("Damage");
empiOnCollisionActionLabel->setText("On-collision action");
empiPierceResetTimeLabel->setText("Seconds between piercing hits");
empiBulletModelLabel->setText("Movable point model");
empiInheritRadius->setText("Inherit radius");
empiInheritDespawnTime->setText("Inherit despawn time");
empiInheritShadowTrailInterval->setText("Inherit shadow trail interval");
empiInheritShadowTrailLifespan->setText("Inherit shadow trail lifespan");
empiInheritAnimatables->setText("Inherit animatables");
empiInheritDamage->setText("Inherit damage");
empiInheritPierceResetTime->setText("Inherit pierce reset time");
empiInheritSoundSettings->setText("Inherit sound settings");
empiSoundSettingsLabel->setText("Spawn sound");
empiSpawnType->addItem("Relative to map origin", "0");
empiSpawnType->addItem("Detached, relative to parent", "1");
empiSpawnType->addItem("Attached, relative to parent", "2");
empiOnCollisionAction->addItem("Destroy self only", getID(BULLET_ON_COLLISION_ACTION::DESTROY_THIS_BULLET_ONLY));
empiOnCollisionAction->addItem("Destroy self and attached children", getID(BULLET_ON_COLLISION_ACTION::DESTROY_THIS_BULLET_AND_ATTACHED_CHILDREN));
empiOnCollisionAction->addItem("Pierce players/enemies", getID(BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY));
empiBulletModel->addItem("None", "-1");
for (auto it = levelPack->getBulletModelIteratorBegin(); it != levelPack->getBulletModelIteratorEnd(); it++) {
empiBulletModel->addItem(it->second->getName(), std::to_string(it->second->getID()));
}
levelPack->getOnChange()->sink().connect<EditorMovablePointPanel, &EditorMovablePointPanel::onLevelPackChange>(this);
emp->loadBulletModel(*levelPack);
empiAnimatable->onValueChange.connect([this](Animatable value) {
if (this->ignoreSignals) {
return;
}
Animatable oldValue = this->emp->getAnimatable();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setAnimatable(value);
this->ignoreSignals = true;
empiAnimatable->setValue(value);
empiLoopAnimation->setVisible(!value.isSprite());
empiBaseSprite->setVisible(!empiLoopAnimation->isChecked() && !value.isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setAnimatable(oldValue);
this->ignoreSignals = true;
empiAnimatable->setValue(oldValue);
empiLoopAnimation->setVisible(!oldValue.isSprite());
empiBaseSprite->setVisible(!empiLoopAnimation->isChecked() && !oldValue.isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
empiLoopAnimation->onChange.connect([this](bool value) {
if (this->ignoreSignals) {
return;
}
bool oldValue = this->emp->getIsBullet();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setLoopAnimation(value);
this->ignoreSignals = true;
empiLoopAnimation->setChecked(value);
empiBaseSprite->setVisible(!value && !empiAnimatable->getValue().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setLoopAnimation(oldValue);
this->ignoreSignals = true;
empiLoopAnimation->setChecked(oldValue);
empiBaseSprite->setVisible(!oldValue && !empiAnimatable->getValue().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
empiBaseSprite->onValueChange.connect([this](Animatable value) {
if (this->ignoreSignals) {
return;
}
Animatable oldValue = this->emp->getAnimatable();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setBaseSprite(value);
this->ignoreSignals = true;
empiBaseSprite->setValue(value);
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setBaseSprite(oldValue);
this->ignoreSignals = true;
empiBaseSprite->setValue(oldValue);
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
isBullet->onChange.connect([this](bool value) {
if (this->ignoreSignals) {
return;
}
bool oldValue = this->emp->getIsBullet();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setIsBullet(value);
this->ignoreSignals = true;
isBullet->setChecked(value);
empiOnCollisionAction->setEnabled(this->emp->getIsBullet());
empiHitboxRadius->setEnabled((!this->emp->getInheritRadius() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiDamage->setEnabled((!this->emp->getInheritDamage() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiPierceResetTimeLabel->setVisible(this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
empiPierceResetTime->setVisible(this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setIsBullet(oldValue);
this->ignoreSignals = true;
isBullet->setChecked(oldValue);
empiOnCollisionAction->setEnabled(this->emp->getIsBullet());
empiHitboxRadius->setEnabled((!this->emp->getInheritRadius() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiDamage->setEnabled((!this->emp->getInheritDamage() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiPierceResetTimeLabel->setVisible(this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
empiPierceResetTime->setVisible(this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
empiHitboxRadius->onValueChange.connect([this](tgui::String value) {
if (this->ignoreSignals) {
return;
}
std::string oldValue = this->emp->getRawHitboxRadius();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setHitboxRadius(static_cast<std::string>(value));
this->ignoreSignals = true;
empiHitboxRadius->setText(static_cast<std::string>(value));
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setHitboxRadius(oldValue);
this->ignoreSignals = true;
empiHitboxRadius->setText(oldValue);
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
empiDespawnTime->onValueChange.connect([this](float value) {
if (this->ignoreSignals) {
return;
}
float oldValue = this->emp->getDespawnTime();
undoStack.execute(UndoableCommand([this, value]() {
this->emp->setDespawnTime(value);
this->ignoreSignals = true;
empiDespawnTime->setValue(value);
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}, [this, oldValue]() {
this->emp->setDespawnTime(oldValue);
this->ignoreSignals = true;
empiDespawnTime->setValue(oldValue);
this->ignoreSignals = false;
onEMPModify.emit(this, this->emp);
}));
});
empiSpawnType->onItemSelect.connect([this](tgui::String item, tgui::String id) {
if (ignoreSignals) {
return;
}
std::shared_ptr<EMPSpawnType> oldSpawnType = this->emp->getSpawnType();
if (id == "0") {
undoStack.execute(UndoableCommand(
[this]() {
this->emp->setSpawnType(std::make_shared<SpecificGlobalEMPSpawn>(static_cast<std::string>(empiSpawnTypeTime->getText()),
static_cast<std::string>(empiSpawnTypeX->getText()), static_cast<std::string>(empiSpawnTypeY->getText())));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
},
[this, oldSpawnType]() {
this->emp->setSpawnType(oldSpawnType);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
}));
} else if (id == "1") {
undoStack.execute(UndoableCommand(
[this]() {
this->emp->setSpawnType(std::make_shared<EntityRelativeEMPSpawn>(static_cast<std::string>(empiSpawnTypeTime->getText()),
static_cast<std::string>(empiSpawnTypeX->getText()), static_cast<std::string>(empiSpawnTypeY->getText())));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
},
[this, oldSpawnType]() {
this->emp->setSpawnType(oldSpawnType);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
}));
} else if (id == "2") {
undoStack.execute(UndoableCommand(
[this]() {
this->emp->setSpawnType(std::make_shared<EntityAttachedEMPSpawn>(static_cast<std::string>(empiSpawnTypeTime->getText()),
static_cast<std::string>(empiSpawnTypeX->getText()), static_cast<std::string>(empiSpawnTypeY->getText())));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
},
[this, oldSpawnType]() {
this->emp->setSpawnType(oldSpawnType);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnType->setSelectedItemById(getID(this->emp->getSpawnType()));
ignoreSignals = false;
}));
} else {
// You forgot a case
assert(false);
}
});
empiSpawnTypeTime->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getSpawnType()->getRawTime();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setSpawnTypeTime(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeTime->setText(this->emp->getSpawnType()->getRawTime());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setSpawnTypeTime(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeTime->setText(this->emp->getSpawnType()->getRawTime());
ignoreSignals = false;
}));
});
empiSpawnTypeX->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getSpawnType()->getRawX();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->getSpawnType()->setX(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeX->setText(this->emp->getSpawnType()->getRawX());
movementEditorPanel->setVisualizerStartPosX(this->emp->getSpawnType()->getRawX());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->getSpawnType()->setX(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeX->setText(this->emp->getSpawnType()->getRawX());
movementEditorPanel->setVisualizerStartPosX(this->emp->getSpawnType()->getRawX());
ignoreSignals = false;
}));
});
empiSpawnTypeY->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getSpawnType()->getRawY();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->getSpawnType()->setY(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeY->setText(this->emp->getSpawnType()->getRawY());
movementEditorPanel->setVisualizerStartPosY(this->emp->getSpawnType()->getRawY());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->getSpawnType()->setY(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSpawnTypeY->setText(this->emp->getSpawnType()->getRawY());
movementEditorPanel->setVisualizerStartPosY(this->emp->getSpawnType()->getRawY());
ignoreSignals = false;
}));
});
empiSpawnLocationManualSet->onPress.connect([this]() {
savedWidgets = propertiesPanel->getWidgets();
horizontalScrollPos = propertiesPanel->getHorizontalScrollbarValue();
verticalScrollPos = propertiesPanel->getVerticalScrollbarValue();
propertiesPanel->removeAllWidgets();
propertiesPanel->setHorizontalScrollbarValue(0);
propertiesPanel->setVerticalScrollbarValue(0);
float x, y;
try {
x = std::stof(this->emp->getSpawnType()->getRawX());
y = std::stof(this->emp->getSpawnType()->getRawY());
} catch (...) {
x = 0;
y = 0;
}
spawnTypePositionMarkerPlacer->clearUndoStack();
spawnTypePositionMarkerPlacer->setMarkers({std::make_pair(sf::Vector2f(x, y), sf::Color::Red)});
spawnTypePositionMarkerPlacer->lookAt(sf::Vector2f(0, 0));
propertiesPanel->add(spawnTypePositionMarkerPlacer);
propertiesPanel->add(spawnTypePositionMarkerPlacerFinishEditing);
spawnTypePositionMarkerPlacer->setFocused(true);
placingSpawnLocation = true;
});
empiShadowTrailLifespan->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getRawShadowTrailLifespan();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setShadowTrailLifespan(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setShadowTrailLifespan(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
ignoreSignals = false;
}));
});
empiShadowTrailInterval->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getRawShadowTrailInterval();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setShadowTrailInterval(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setShadowTrailInterval(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
ignoreSignals = false;
}));
});
empiDamage->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getRawDamage();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setDamage(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiDamage->setText(this->emp->getRawDamage());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setDamage(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiDamage->setText(this->emp->getRawDamage());
ignoreSignals = false;
}));
});
empiOnCollisionAction->onItemSelect.connect([this](tgui::String item, tgui::String id) {
if (ignoreSignals) {
return;
}
BULLET_ON_COLLISION_ACTION action = fromID(static_cast<std::string>(empiOnCollisionAction->getSelectedItemId()));
BULLET_ON_COLLISION_ACTION oldAction = this->emp->getOnCollisionAction();
undoStack.execute(UndoableCommand(
[this, action]() {
this->emp->setOnCollisionAction(action);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiOnCollisionAction->setSelectedItemById(getID(action));
empiPierceResetTimeLabel->setVisible(action == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
empiPierceResetTime->setVisible(action == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
ignoreSignals = false;
},
[this, oldAction]() {
this->emp->setOnCollisionAction(oldAction);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiOnCollisionAction->setSelectedItemById(getID(oldAction));
empiPierceResetTimeLabel->setVisible(oldAction == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
empiPierceResetTime->setVisible(oldAction == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY && this->emp->getIsBullet());
ignoreSignals = false;
}));
});
empiPierceResetTime->onValueChange.connect([this](tgui::String value) {
if (ignoreSignals) {
return;
}
std::string oldValue = this->emp->getRawPierceResetTime();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setPierceResetTime(static_cast<std::string>(value));
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setPierceResetTime(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
ignoreSignals = false;
}));
});
empiSoundSettings->onValueChange.connect([this](SoundSettings value) {
if (ignoreSignals) {
return;
}
SoundSettings oldValue = this->emp->getSoundSettings();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setSoundSettings(value);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSoundSettings->initSettings(this->emp->getSoundSettings());
ignoreSignals = false;
},
[this, oldValue]() {
this->emp->setSoundSettings(oldValue);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiSoundSettings->initSettings(this->emp->getSoundSettings());
ignoreSignals = false;
}));
});
empiBulletModel->onItemSelect.connect([this](tgui::String item, tgui::String id) {
if (ignoreSignals) {
return;
}
int bulletModelID = id.toInt();
if (item == "") bulletModelID = -1;
int oldBulletModelID = this->emp->getBulletModelID();
std::string radius = this->emp->getRawHitboxRadius();
float despawnTime = this->emp->getDespawnTime();
std::string interval = this->emp->getRawShadowTrailInterval();
std::string lifespan = this->emp->getRawShadowTrailLifespan();
Animatable animatable = this->emp->getAnimatable();
Animatable baseSprite = this->emp->getBaseSprite();
bool loopAnimation = this->emp->getLoopAnimation();
std::string damage = this->emp->getRawDamage();
std::string pierceResetTime = this->emp->getRawPierceResetTime();
SoundSettings sound = this->emp->getSoundSettings();
undoStack.execute(UndoableCommand(
[this, bulletModelID, radius, despawnTime, interval, lifespan, animatable, baseSprite, loopAnimation, damage, pierceResetTime, sound]() {
if (bulletModelID == -1) {
this->emp->removeBulletModel();
} else {
this->emp->setBulletModel(this->levelPack->getBulletModel(bulletModelID));
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
if (bulletModelID == -1) {
empiBulletModel->deselectItem();
} else {
empiBulletModel->setSelectedItemById(std::to_string(this->emp->getBulletModelID()));
}
empiHitboxRadius->setText(this->emp->getRawHitboxRadius());
empiDespawnTime->setValue(this->emp->getDespawnTime());
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
empiAnimatable->setValue(this->emp->getAnimatable());
empiLoopAnimation->setChecked(this->emp->getLoopAnimation());
empiBaseSprite->setValue(this->emp->getAnimatable());
empiDamage->setText(this->emp->getRawDamage());
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
empiSoundSettings->initSettings(this->emp->getSoundSettings());
empiLoopAnimation->setVisible(!this->emp->getAnimatable().isSprite());
empiBaseSprite->setVisible(!this->emp->getLoopAnimation() && !this->emp->getAnimatable().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
empiPierceResetTimeLabel->setVisible((this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && this->emp->getIsBullet());
empiPierceResetTime->setVisible((this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && this->emp->getIsBullet());
empiHitboxRadius->setEnabled((!this->emp->getInheritRadius() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiDespawnTime->setEnabled(!this->emp->getInheritDespawnTime() || this->emp->getBulletModelID() < 0);
empiShadowTrailInterval->setEnabled(!this->emp->getInheritShadowTrailInterval() || this->emp->getBulletModelID() < 0);
empiShadowTrailLifespan->setEnabled(!this->emp->getInheritShadowTrailLifespan() || this->emp->getBulletModelID() < 0);
empiAnimatable->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiBaseSprite->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiDamage->setEnabled((!this->emp->getInheritDamage() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiPierceResetTime->setEnabled((!this->emp->getInheritPierceResetTime() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiSoundSettings->setEnabled(!this->emp->getInheritSoundSettings() || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldBulletModelID, radius, despawnTime, interval, lifespan, animatable, baseSprite, loopAnimation, damage, pierceResetTime, sound]() {
this->emp->setHitboxRadius(radius);
this->emp->setDespawnTime(despawnTime);
this->emp->setShadowTrailLifespan(lifespan);
this->emp->setShadowTrailInterval(interval);
this->emp->setAnimatable(animatable);
this->emp->setLoopAnimation(loopAnimation);
this->emp->setBaseSprite(baseSprite);
this->emp->setDamage(damage);
this->emp->setPierceResetTime(pierceResetTime);
this->emp->setSoundSettings(sound);
if (oldBulletModelID == -1) {
this->emp->removeBulletModel();
} else {
this->emp->setBulletModel(this->levelPack->getBulletModel(oldBulletModelID));
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
if (oldBulletModelID == -1) {
empiBulletModel->deselectItem();
} else {
empiBulletModel->setSelectedItemById(std::to_string(this->emp->getBulletModelID()));
}
empiHitboxRadius->setText(this->emp->getRawHitboxRadius());
empiDespawnTime->setValue(this->emp->getDespawnTime());
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
empiAnimatable->setValue(this->emp->getAnimatable());
empiLoopAnimation->setChecked(this->emp->getLoopAnimation());
empiBaseSprite->setValue(this->emp->getAnimatable());
empiDamage->setText(this->emp->getRawDamage());
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
empiSoundSettings->initSettings(this->emp->getSoundSettings());
empiLoopAnimation->setVisible(!this->emp->getAnimatable().isSprite());
empiBaseSprite->setVisible(!this->emp->getLoopAnimation() && !this->emp->getAnimatable().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
empiPierceResetTimeLabel->setVisible((this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && this->emp->getIsBullet());
empiPierceResetTime->setVisible((this->emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && this->emp->getIsBullet());
empiHitboxRadius->setEnabled(!this->emp->getInheritRadius() || this->emp->getBulletModelID() < 0);
empiDespawnTime->setEnabled(!this->emp->getInheritDespawnTime() || this->emp->getBulletModelID() < 0);
empiShadowTrailInterval->setEnabled(!this->emp->getInheritShadowTrailInterval() || this->emp->getBulletModelID() < 0);
empiShadowTrailLifespan->setEnabled(!this->emp->getInheritShadowTrailLifespan() || this->emp->getBulletModelID() < 0);
empiAnimatable->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiBaseSprite->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiDamage->setEnabled((!this->emp->getInheritDamage() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiPierceResetTime->setEnabled((!this->emp->getInheritPierceResetTime() || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
empiSoundSettings->setEnabled(!this->emp->getInheritSoundSettings() || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritRadius->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritRadius();
std::string oldInheritValue = this->emp->getRawHitboxRadius();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritRadius(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritRadius->setChecked(this->emp->getInheritRadius());
empiHitboxRadius->setText(this->emp->getRawHitboxRadius());
empiHitboxRadius->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritRadius(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setHitboxRadius(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritRadius->setChecked(this->emp->getInheritRadius());
empiHitboxRadius->setText(this->emp->getRawHitboxRadius());
empiHitboxRadius->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritDespawnTime->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritDespawnTime();
float oldInheritValue = this->emp->getDespawnTime();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritDespawnTime(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritDespawnTime->setChecked(this->emp->getInheritDespawnTime());
empiDespawnTime->setValue(this->emp->getDespawnTime());
empiDespawnTime->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritDespawnTime(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setDespawnTime(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritDespawnTime->setChecked(this->emp->getInheritDespawnTime());
empiDespawnTime->setValue(this->emp->getDespawnTime());
empiDespawnTime->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritShadowTrailInterval->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritShadowTrailInterval();
std::string oldInheritValue = this->emp->getRawShadowTrailInterval();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritShadowTrailInterval(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritShadowTrailInterval->setChecked(this->emp->getInheritShadowTrailInterval());
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
empiShadowTrailInterval->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritShadowTrailInterval(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setShadowTrailInterval(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritShadowTrailInterval->setChecked(this->emp->getInheritShadowTrailInterval());
empiShadowTrailInterval->setText(this->emp->getRawShadowTrailInterval());
empiShadowTrailInterval->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritShadowTrailLifespan->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritShadowTrailLifespan();
std::string oldInheritValue = this->emp->getRawShadowTrailLifespan();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritShadowTrailLifespan(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritShadowTrailLifespan->setChecked(this->emp->getInheritShadowTrailLifespan());
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
empiShadowTrailLifespan->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritShadowTrailLifespan(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setShadowTrailLifespan(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritShadowTrailLifespan->setChecked(this->emp->getInheritShadowTrailLifespan());
empiShadowTrailLifespan->setText(this->emp->getRawShadowTrailLifespan());
empiShadowTrailLifespan->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritAnimatables->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritAnimatables();
Animatable oldAnimatable = this->emp->getAnimatable();
Animatable oldBaseSprite = this->emp->getBaseSprite();
bool oldLoopAnimation = this->emp->getLoopAnimation();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritAnimatables(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritAnimatables->setChecked(this->emp->getInheritAnimatables());
empiAnimatable->setValue(this->emp->getAnimatable());
empiBaseSprite->setValue(this->emp->getBaseSprite());
empiLoopAnimation->setChecked(this->emp->getLoopAnimation());
empiLoopAnimation->setVisible(!this->emp->getAnimatable().isSprite());
empiBaseSprite->setVisible(!this->emp->getLoopAnimation() && !this->emp->getAnimatable().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
empiAnimatable->setEnabled(!value || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setEnabled(!value || this->emp->getBulletModelID() < 0);
empiBaseSprite->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldAnimatable, oldBaseSprite, oldLoopAnimation]() {
this->emp->setInheritAnimatables(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setAnimatable(oldAnimatable);
this->emp->setBaseSprite(oldBaseSprite);
this->emp->setLoopAnimation(oldLoopAnimation);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritAnimatables->setChecked(this->emp->getInheritAnimatables());
empiAnimatable->setValue(this->emp->getAnimatable());
empiBaseSprite->setValue(this->emp->getBaseSprite());
empiLoopAnimation->setChecked(this->emp->getLoopAnimation());
empiLoopAnimation->setVisible(!this->emp->getAnimatable().isSprite());
empiBaseSprite->setVisible(!this->emp->getLoopAnimation() && !this->emp->getAnimatable().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
empiAnimatable->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
empiBaseSprite->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
empiInheritDamage->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritDamage();
std::string oldInheritValue = this->emp->getRawDamage();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritDamage(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritDamage->setChecked(this->emp->getInheritDamage());
empiDamage->setText(this->emp->getRawDamage());
empiDamage->setEnabled((!value || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritDamage(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setDamage(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritDamage->setChecked(this->emp->getInheritDamage());
empiDamage->setText(this->emp->getRawDamage());
empiDamage->setEnabled((!oldValue || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
ignoreSignals = false;
}));
});
empiInheritPierceResetTime->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritPierceResetTime();
std::string oldInheritValue = this->emp->getRawPierceResetTime();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritPierceResetTime(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritPierceResetTime->setChecked(this->emp->getInheritPierceResetTime());
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
empiPierceResetTime->setEnabled((!value || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritPierceResetTime(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setPierceResetTime(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritPierceResetTime->setChecked(this->emp->getInheritPierceResetTime());
empiPierceResetTime->setText(this->emp->getRawPierceResetTime());
empiPierceResetTime->setEnabled((!oldValue || this->emp->getBulletModelID() < 0) && this->emp->getIsBullet());
ignoreSignals = false;
}));
});
empiInheritSoundSettings->onChange.connect([this](bool value) {
if (ignoreSignals) {
return;
}
bool oldValue = this->emp->getInheritSoundSettings();
SoundSettings oldInheritValue = this->emp->getSoundSettings();
undoStack.execute(UndoableCommand(
[this, value]() {
this->emp->setInheritSoundSettings(value, *this->levelPack);
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritSoundSettings->setChecked(this->emp->getInheritSoundSettings());
empiSoundSettings->initSettings(this->emp->getSoundSettings());
empiSoundSettings->setEnabled(!value || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
},
[this, oldValue, oldInheritValue]() {
this->emp->setInheritSoundSettings(oldValue, *this->levelPack);
if (!oldValue) {
this->emp->setSoundSettings(oldInheritValue);
}
onEMPModify.emit(this, this->emp);
ignoreSignals = true;
empiInheritSoundSettings->setChecked(this->emp->getInheritSoundSettings());
empiSoundSettings->initSettings(this->emp->getSoundSettings());
empiSoundSettings->setEnabled(!oldValue || this->emp->getBulletModelID() < 0);
ignoreSignals = false;
}));
});
updateAllWidgetValues();
id->setPosition(GUI_PADDING_X, GUI_PADDING_Y);
empiAnimatableLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(id) + GUI_PADDING_Y);
empiAnimatable->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiAnimatableLabel) + GUI_LABEL_PADDING_Y);
empiLoopAnimation->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiAnimatable) + GUI_PADDING_Y);
empiBaseSpriteLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiLoopAnimation) + GUI_PADDING_Y * 2);
empiBaseSprite->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiBaseSpriteLabel) + GUI_LABEL_PADDING_Y);
empiBulletModelLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiBaseSprite) + GUI_PADDING_Y * 2);
empiBulletModel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiBulletModelLabel) + GUI_LABEL_PADDING_Y);
empiInheritRadius->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiBulletModel) + GUI_LABEL_PADDING_Y);
empiInheritDespawnTime->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritRadius) + GUI_LABEL_PADDING_Y);
empiInheritShadowTrailLifespan->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritDespawnTime) + GUI_LABEL_PADDING_Y);
empiInheritShadowTrailInterval->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritShadowTrailLifespan) + GUI_LABEL_PADDING_Y);
empiInheritAnimatables->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritShadowTrailInterval) + GUI_LABEL_PADDING_Y);
empiInheritDamage->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritAnimatables) + GUI_LABEL_PADDING_Y);
empiInheritPierceResetTime->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritDamage) + GUI_LABEL_PADDING_Y);
empiInheritSoundSettings->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritPierceResetTime) + GUI_LABEL_PADDING_Y);
isBullet->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiInheritSoundSettings) + GUI_PADDING_Y * 2);
empiHitboxRadiusLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(isBullet) + GUI_PADDING_Y);
empiHitboxRadius->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiHitboxRadiusLabel) + GUI_LABEL_PADDING_Y);
empiDamageLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiHitboxRadius) + GUI_PADDING_Y * 2);
empiDamage->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiDamageLabel) + GUI_LABEL_PADDING_Y);
empiOnCollisionActionLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiDamage) + GUI_PADDING_Y);
empiOnCollisionAction->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiOnCollisionActionLabel) + GUI_LABEL_PADDING_Y);
empiPierceResetTimeLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiOnCollisionAction) + GUI_PADDING_Y);
empiPierceResetTime->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiPierceResetTimeLabel) + GUI_LABEL_PADDING_Y);
empiDespawnTimeLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiPierceResetTime) + GUI_PADDING_Y * 2);
empiDespawnTime->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiDespawnTimeLabel) + GUI_LABEL_PADDING_Y);
empiSpawnTypeLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiDespawnTime) + GUI_PADDING_Y * 2);
empiSpawnType->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeLabel) + GUI_LABEL_PADDING_Y);
empiSpawnTypeTimeLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnType) + GUI_PADDING_Y);
empiSpawnTypeTime->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeTimeLabel) + GUI_LABEL_PADDING_Y);
empiSpawnTypeXLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeTime) + GUI_PADDING_Y);
empiSpawnTypeX->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeXLabel) + GUI_LABEL_PADDING_Y);
empiSpawnTypeYLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeX) + GUI_PADDING_Y);
empiSpawnTypeY->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeYLabel) + GUI_LABEL_PADDING_Y);
empiSpawnLocationManualSet->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnTypeY) + GUI_PADDING_Y);
empiSoundSettingsLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSpawnLocationManualSet) + GUI_PADDING_Y * 2);
empiSoundSettings->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSoundSettingsLabel) + GUI_LABEL_PADDING_Y);
empiShadowTrailLifespanLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiSoundSettings) + GUI_PADDING_Y * 2);
empiShadowTrailLifespan->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiShadowTrailLifespanLabel) + GUI_LABEL_PADDING_Y);
empiShadowTrailIntervalLabel->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiShadowTrailLifespan) + GUI_PADDING_Y);
empiShadowTrailInterval->setPosition(tgui::bindLeft(id), tgui::bindBottom(empiShadowTrailIntervalLabel) + GUI_LABEL_PADDING_Y);
// For some reason, ScrollablePanels' sizes don't fit the last widget, so this is to make sure this one does
auto scrollablePanelBuffer = tgui::Label::create();
scrollablePanelBuffer->setPosition(0, tgui::bindBottom(empiShadowTrailInterval) + GUI_PADDING_Y);
propertiesPanel->add(scrollablePanelBuffer);
tgui::Layout fillWidth = tgui::bindWidth(propertiesPanel) - GUI_PADDING_X * 2;
empiLoopAnimation->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiAnimatable->setSize(fillWidth, 0);
empiBaseSprite->setSize(fillWidth, 0);
empiAnimatable->setAnimatablePictureSize(fillWidth, tgui::bindMin(tgui::bindWidth(propertiesPanel) - GUI_PADDING_X * 2, 120));
empiBaseSprite->setAnimatablePictureSize(fillWidth, tgui::bindMin(tgui::bindWidth(propertiesPanel) - GUI_PADDING_X * 2, 120));
empiHitboxRadius->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiDespawnTime->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiSpawnType->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiSpawnTypeTime->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiSpawnTypeX->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiSpawnTypeY->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiSpawnLocationManualSet->setSize(fillWidth, TEXT_BUTTON_HEIGHT);
empiShadowTrailLifespan->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiShadowTrailInterval->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiDamage->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiOnCollisionAction->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiPierceResetTime->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiBulletModel->setSize(fillWidth, TEXT_BOX_HEIGHT);
empiInheritRadius->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritDespawnTime->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritShadowTrailInterval->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritShadowTrailLifespan->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritAnimatables->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritDamage->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritPierceResetTime->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
empiInheritSoundSettings->setSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
propertiesPanel->add(id);
propertiesPanel->add(empiAnimatableLabel);
propertiesPanel->add(empiAnimatable);
propertiesPanel->add(empiLoopAnimation);
propertiesPanel->add(empiBaseSpriteLabel);
propertiesPanel->add(empiBaseSprite);
propertiesPanel->add(isBullet);
propertiesPanel->add(empiHitboxRadiusLabel);
propertiesPanel->add(empiHitboxRadius);
propertiesPanel->add(empiDespawnTimeLabel);
propertiesPanel->add(empiDespawnTime);
propertiesPanel->add(empiSpawnTypeLabel);
propertiesPanel->add(empiSpawnType);
propertiesPanel->add(empiSpawnTypeTimeLabel);
propertiesPanel->add(empiSpawnTypeTime);
propertiesPanel->add(empiSpawnTypeXLabel);
propertiesPanel->add(empiSpawnTypeX);
propertiesPanel->add(empiSpawnTypeYLabel);
propertiesPanel->add(empiSpawnTypeY);
propertiesPanel->add(empiSpawnLocationManualSet);
propertiesPanel->add(empiShadowTrailLifespanLabel);
propertiesPanel->add(empiShadowTrailLifespan);
propertiesPanel->add(empiShadowTrailIntervalLabel);
propertiesPanel->add(empiShadowTrailInterval);
propertiesPanel->add(empiDamageLabel);
propertiesPanel->add(empiDamage);
propertiesPanel->add(empiOnCollisionActionLabel);
propertiesPanel->add(empiOnCollisionAction);
propertiesPanel->add(empiPierceResetTimeLabel);
propertiesPanel->add(empiPierceResetTime);
propertiesPanel->add(empiSoundSettingsLabel);
propertiesPanel->add(empiSoundSettings);
propertiesPanel->add(empiBulletModelLabel);
propertiesPanel->add(empiBulletModel);
propertiesPanel->add(empiInheritRadius);
propertiesPanel->add(empiInheritDespawnTime);
propertiesPanel->add(empiInheritShadowTrailInterval);
propertiesPanel->add(empiInheritShadowTrailLifespan);
propertiesPanel->add(empiInheritAnimatables);
propertiesPanel->add(empiInheritDamage);
propertiesPanel->add(empiInheritPierceResetTime);
propertiesPanel->add(empiInheritSoundSettings);
propertiesPanel->onSizeChange.connect([this](sf::Vector2f newSize) {
// This is here because of some random bug with SoundSettingsGroup
empiSoundSettings->setSize(newSize.x - GUI_PADDING_X * 2, 0);
spawnTypePositionMarkerPlacerFinishEditing->setPosition(newSize.x - spawnTypePositionMarkerPlacerFinishEditing->getSize().x, newSize.y - spawnTypePositionMarkerPlacerFinishEditing->getSize().y * 2);
});
tabs->addTab(PROPERTIES_TAB_NAME, propertiesPanel);
}
{
// Movement tab
movementEditorPanel = EMPABasedMovementEditorPanel::create(mainEditorWindow, clipboard);
movementEditorPanel->onEMPAListModify.connect([this](std::vector<std::shared_ptr<EMPAction>> newActions, float newSumOfDurations) {
// This shouldn't be undoable here because it's already undoable from EMPABasedMovementEditorPanel.
// Note: Setting the limits of a SliderWithEditBox to some number and then setting it back does not
// revert the SliderWithEditBox's value
this->emp->setActions(newActions);
// Max time for despawn time is sum of actions' durations
this->empiDespawnTime->setMax(newSumOfDurations);
onEMPModify.emit(this, this->emp);
});
movementEditorPanel->setActions(this->emp->getActions());
empiDespawnTime->setMax(movementEditorPanel->getSumOfDurations());
tabs->addTab(MOVEMENT_TAB_NAME, movementEditorPanel, false, false);
}
symbolTableEditorWindow = ChildWindow::create();
symbolTableEditor = ValueSymbolTableEditor::create(false, false);
symbolTableEditorWindow->setKeepInParent(false);
symbolTableEditorWindow->add(symbolTableEditor);
symbolTableEditorWindow->setSize("50%", "50%");
symbolTableEditorWindow->setTitle("Movable Point ID " + std::to_string(emp->getID()) + " Variables");
symbolTableEditorWindow->setFallbackEventHandler([this](sf::Event event) {
return symbolTableEditor->handleEvent(event);
});
symbolTableEditor->onValueChange.connect([this](ValueSymbolTable table) {
this->emp->setSymbolTable(table);
onChange(table);
onEMPModify.emit(this, this->emp);
});
}
EditorMovablePointPanel::~EditorMovablePointPanel() {
levelPack->getOnChange()->sink().disconnect<EditorMovablePointPanel, &EditorMovablePointPanel::onLevelPackChange>(this);
mainEditorWindow.removeChildWindow(symbolTableEditorWindow);
}
CopyOperationResult EditorMovablePointPanel::copyFrom() {
// Can't copy this widget
return CopyOperationResult(nullptr, "");
}
PasteOperationResult EditorMovablePointPanel::pasteInto(std::shared_ptr<CopiedObject> pastedObject) {
// Same functionality as paste2Into()
return paste2Into(pastedObject);
}
PasteOperationResult EditorMovablePointPanel::paste2Into(std::shared_ptr<CopiedObject> pastedObject) {
// Paste the first copied EditorMovablePoint to override emp's properties
auto derived = std::static_pointer_cast<CopiedEditorMovablePoint>(pastedObject);
if (derived) {
std::shared_ptr<EditorMovablePoint> copiedEMP = derived->getEMP();
mainEditorWindow.promptConfirmation("Overwrite this movable point's properties with the copied movable point's properties? This will not change this movable point's children.", copiedEMP, this)->sink()
.connect<EditorMovablePointPanel, &EditorMovablePointPanel::onPasteIntoConfirmation>(this);
return PasteOperationResult(true, "");
}
return PasteOperationResult(false, "Type mismatch");
}
bool EditorMovablePointPanel::handleEvent(sf::Event event) {
if (tabs->handleEvent(event)) {
return true;
} else if (placingSpawnLocation) {
if (spawnTypePositionMarkerPlacer->handleEvent(event)) {
return true;
}
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
finishEditingSpawnTypePosition();
return true;
}
} else if (event.type == sf::Event::KeyPressed) {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::RControl)) {
if (event.key.code == sf::Keyboard::Z) {
undoStack.undo();
return true;
} else if (event.key.code == sf::Keyboard::Y) {
undoStack.redo();
return true;
} else if (event.key.code == sf::Keyboard::V) {
clipboard.paste(this);
return true;
}
} else if (event.key.code == sf::Keyboard::V) {
mainEditorWindow.addChildWindow(symbolTableEditorWindow);
return true;
}
}
return false;
}
tgui::Signal & EditorMovablePointPanel::getSignal(tgui::String signalName) {
if (signalName == onEMPModify.getName().toLower()) {
return onEMPModify;
}
return tgui::Panel::getSignal(signalName);
}
void EditorMovablePointPanel::propagateChangesToChildren() {
symbolTableEditor->setSymbolTablesHierarchy(symbolTables);
// movementEditorPanel acts as just a middleman between this widget and child widgets that
// use emp's ValueSymbolTable
movementEditorPanel->propagateChangesToChildren();
}
ValueSymbolTable EditorMovablePointPanel::getLevelPackObjectSymbolTable() {
return emp->getSymbolTable();
}
void EditorMovablePointPanel::updateAllWidgetValues() {
// Update widgets whose values can be changed by the player
ignoreSignals = true;
empiAnimatable->setValue(emp->getAnimatable());
empiLoopAnimation->setChecked(emp->getLoopAnimation());
empiBaseSprite->setValue(emp->getAnimatable());
isBullet->setChecked(emp->getIsBullet());
empiHitboxRadius->setText(emp->getRawHitboxRadius());
empiDespawnTime->setValue(emp->getDespawnTime());
empiSpawnType->setSelectedItemById(getID(emp->getSpawnType()));
// empiSpawnTypeTime should always display 0 if the EMP is the main EMP of its EditorAttack
// because it will always be spawned instantly
empiSpawnTypeTime->setText(emp->isMainEMP() ? "0" : emp->getSpawnType()->getRawTime());
empiSpawnTypeX->setText(emp->getSpawnType()->getRawX());
empiSpawnTypeY->setText(emp->getSpawnType()->getRawY());
empiShadowTrailLifespan->setText(emp->getRawShadowTrailLifespan());
empiShadowTrailInterval->setText(emp->getRawShadowTrailInterval());
empiDamage->setText(emp->getRawDamage());
empiOnCollisionAction->setSelectedItemById(getID(emp->getOnCollisionAction()));
empiPierceResetTime->setText(emp->getRawPierceResetTime());
empiSoundSettings->initSettings(emp->getSoundSettings());
if (emp->getBulletModelID() >= 0) {
empiBulletModel->setSelectedItemById(std::to_string(emp->getBulletModelID()));
} else {
empiBulletModel->setSelectedItemById("");
}
empiInheritRadius->setChecked(emp->getInheritRadius());
empiInheritDespawnTime->setChecked(emp->getInheritDespawnTime());
empiInheritShadowTrailInterval->setChecked(emp->getInheritShadowTrailInterval());
empiInheritShadowTrailLifespan->setChecked(emp->getInheritShadowTrailLifespan());
empiInheritAnimatables->setChecked(emp->getInheritAnimatables());
empiInheritDamage->setChecked(emp->getInheritDamage());
empiInheritPierceResetTime->setChecked(emp->getInheritPierceResetTime());
empiInheritSoundSettings->setChecked(emp->getInheritSoundSettings());
empiSpawnTypeTime->setEnabled(!emp->isMainEMP());
empiOnCollisionAction->setEnabled(emp->getIsBullet());
empiHitboxRadius->setEnabled((!emp->getInheritRadius() || this->emp->getBulletModelID() < 0) && emp->getIsBullet());
empiDespawnTime->setEnabled(!emp->getInheritDespawnTime() || this->emp->getBulletModelID() < 0);
empiShadowTrailInterval->setEnabled(!emp->getInheritShadowTrailInterval() || this->emp->getBulletModelID() < 0);
empiShadowTrailLifespan->setEnabled(!emp->getInheritShadowTrailLifespan() || this->emp->getBulletModelID() < 0);
empiAnimatable->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiBaseSprite->setEnabled(!this->emp->getInheritAnimatables() || this->emp->getBulletModelID() < 0);
empiDamage->setEnabled((!emp->getInheritDamage() || this->emp->getBulletModelID() < 0) && emp->getIsBullet());
empiPierceResetTime->setEnabled((!emp->getInheritPierceResetTime() || this->emp->getBulletModelID() < 0) && emp->getIsBullet());
empiSoundSettings->setEnabled(!emp->getInheritSoundSettings() || this->emp->getBulletModelID() < 0);
empiLoopAnimation->setVisible(!emp->getAnimatable().isSprite());
empiBaseSprite->setVisible(!emp->getLoopAnimation() && !emp->getAnimatable().isSprite());
empiBaseSpriteLabel->setVisible(empiBaseSprite->isVisible());
empiPierceResetTimeLabel->setVisible((emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && emp->getIsBullet());
empiPierceResetTime->setVisible((emp->getOnCollisionAction() == BULLET_ON_COLLISION_ACTION::PIERCE_ENTITY) && emp->getIsBullet());
ignoreSignals = false;
}
void EditorMovablePointPanel::onLevelPackChange(LevelPack::LEVEL_PACK_OBJECT_HIERARCHY_LAYER_ROOT_TYPE type, int id) {
if (type == LevelPack::LEVEL_PACK_OBJECT_HIERARCHY_LAYER_ROOT_TYPE::SPRITE_SHEET) {
// Reload animatables-related widgets
empiAnimatable->repopulateAnimatables();
empiBaseSprite->repopulateAnimatables();
} else if (type == LevelPack::LEVEL_PACK_OBJECT_HIERARCHY_LAYER_ROOT_TYPE::BULLET_MODEL) {
// Reload bullet model-related widgets when some bullet model is modified
if (emp->getBulletModelID() == id) {
emp->loadBulletModel(*levelPack);
}
empiBulletModel->removeAllItems();
empiBulletModel->addItem("None", "-1");
for (auto it = levelPack->getBulletModelIteratorBegin(); it != levelPack->getBulletModelIteratorEnd(); it++) {
empiBulletModel->addItem(it->second->getName(), std::to_string(it->second->getID()));
}
}
// TODO: when sounds folder is modified, empiSoundSettings->populateFileNames(format(RELATIVE_LEVEL_PACK_SOUND_FOLDER_PATH, levelPack->getName().c_str()));
}
void EditorMovablePointPanel::finishEditingSpawnTypePosition() {
propertiesPanel->removeAllWidgets();
for (auto widget : savedWidgets) {
propertiesPanel->add(widget);
}
savedWidgets.clear();
propertiesPanel->setHorizontalScrollbarValue(horizontalScrollPos);
propertiesPanel->setVerticalScrollbarValue(verticalScrollPos);
std::string oldPosX = emp->getSpawnType()->getRawX();
std::string oldPosY = emp->getSpawnType()->getRawY();
sf::Vector2f newPos = spawnTypePositionMarkerPlacer->getMarkerPositions()[0];
undoStack.execute(UndoableCommand(
[this, newPos]() {
emp->getSpawnType()->setX(formatNum(newPos.x));
emp->getSpawnType()->setY(formatNum(newPos.y));
onEMPModify.emit(this, this->emp);
this->ignoreSignals = true;
empiSpawnTypeX->setText(formatNum(newPos.x));
empiSpawnTypeY->setText(formatNum(newPos.y));
this->ignoreSignals = false;
},
[this, oldPosX, oldPosY]() {
emp->getSpawnType()->setX(oldPosX);
emp->getSpawnType()->setY(oldPosY);
onEMPModify.emit(this, this->emp);
this->ignoreSignals = true;
empiSpawnTypeX->setText(oldPosX);
empiSpawnTypeY->setText(oldPosY);
this->ignoreSignals = false;
}));
placingSpawnLocation = false;
}
void EditorMovablePointPanel::onPasteIntoConfirmation(EDITOR_WINDOW_CONFIRMATION_PROMPT_CHOICE choice, std::shared_ptr<EditorMovablePoint> newEMP) {
if (choice == EDITOR_WINDOW_CONFIRMATION_PROMPT_CHOICE::YES) {
auto oldAnimatable = emp->getAnimatable();
auto oldLoopAnimation = emp->getLoopAnimation();
auto oldBaseSprite = emp->getBaseSprite();
auto oldIsBullet = emp->getIsBullet();
auto oldHitboxRadius = emp->getRawHitboxRadius();
auto oldDespawnTime = emp->getDespawnTime();
auto oldSpawnType = emp->getSpawnType();
auto oldShadowTrailLifespan = emp->getRawShadowTrailLifespan();
auto oldShadowTrailInterval = emp->getRawShadowTrailInterval();
auto oldDamage = emp->getRawDamage();
auto oldOnCollisionAction = emp->getOnCollisionAction();
auto oldPierceResetTime = emp->getRawPierceResetTime();
auto oldActions = emp->getActions();
auto oldBulletModelID = emp->getBulletModelID();
auto oldInheritRadius = emp->getInheritRadius();
auto oldInheritDespawnTime = emp->getInheritDespawnTime();
auto oldInheritShadowTrailInterval = emp->getInheritShadowTrailInterval();
auto oldInheritShadowTrailLifespan = emp->getInheritShadowTrailLifespan();
auto oldInheritAnimatables = emp->getInheritAnimatables();
auto oldInheritDamage = emp->getInheritDamage();
auto oldInheritSoundSettings = emp->getInheritSoundSettings();
undoStack.execute(UndoableCommand([this, newEMP]() {
emp->setAnimatable(newEMP->getAnimatable());
emp->setLoopAnimation(newEMP->getLoopAnimation());
emp->setBaseSprite(newEMP->getBaseSprite());
emp->setIsBullet(newEMP->getIsBullet());
emp->setHitboxRadius(newEMP->getRawHitboxRadius());
emp->setDespawnTime(newEMP->getDespawnTime());
emp->setSpawnType(newEMP->getSpawnType());
emp->setShadowTrailLifespan(newEMP->getRawShadowTrailLifespan());
emp->setShadowTrailInterval(newEMP->getRawShadowTrailInterval());
emp->setDamage(newEMP->getRawDamage());
emp->setOnCollisionAction(newEMP->getOnCollisionAction());
emp->setPierceResetTime(newEMP->getRawPierceResetTime());
if (newEMP->getBulletModelID() == -1) {
emp->removeBulletModel();
} else {
emp->setBulletModel(this->levelPack->getBulletModel(newEMP->getBulletModelID()));
}
emp->setActions(newEMP->getActions());
emp->setInheritRadius(newEMP->getInheritRadius(), *levelPack);
emp->setInheritDespawnTime(newEMP->getInheritDespawnTime(), *levelPack);
emp->setInheritShadowTrailInterval(newEMP->getInheritShadowTrailInterval(), *levelPack);
emp->setInheritShadowTrailLifespan(newEMP->getInheritShadowTrailLifespan(), *levelPack);
emp->setInheritAnimatables(newEMP->getInheritAnimatables(), *levelPack);
emp->setInheritDamage(newEMP->getInheritDamage(), *levelPack);
emp->setInheritSoundSettings(newEMP->getInheritSoundSettings(), *levelPack);
updateAllWidgetValues();
onEMPModify.emit(this, this->emp);
}, [this, oldAnimatable, oldLoopAnimation, oldBaseSprite, oldIsBullet, oldHitboxRadius, oldDespawnTime, oldSpawnType,
oldShadowTrailLifespan, oldShadowTrailInterval, oldDamage, oldOnCollisionAction, oldPierceResetTime, oldBulletModelID, oldActions,
oldInheritRadius, oldInheritDespawnTime, oldInheritShadowTrailInterval, oldInheritShadowTrailLifespan, oldInheritAnimatables,
oldInheritDamage, oldInheritSoundSettings]() {
emp->setAnimatable(oldAnimatable);
emp->setLoopAnimation(oldLoopAnimation);
emp->setBaseSprite(oldBaseSprite);
emp->setIsBullet(oldIsBullet);
emp->setHitboxRadius(oldHitboxRadius);
emp->setDespawnTime(oldDespawnTime);
emp->setSpawnType(oldSpawnType);
emp->setShadowTrailLifespan(oldShadowTrailLifespan);
emp->setShadowTrailInterval(oldShadowTrailInterval);
emp->setDamage(oldDamage);
emp->setOnCollisionAction(oldOnCollisionAction);
emp->setPierceResetTime(oldPierceResetTime);
if (oldBulletModelID == -1) {
emp->removeBulletModel();
} else {
emp->setBulletModel(this->levelPack->getBulletModel(oldBulletModelID));
}
emp->setActions(oldActions);
emp->setInheritRadius(oldInheritRadius, *levelPack);
emp->setInheritDespawnTime(oldInheritDespawnTime, *levelPack);
emp->setInheritShadowTrailInterval(oldInheritShadowTrailInterval, *levelPack);
emp->setInheritShadowTrailLifespan(oldInheritShadowTrailLifespan, *levelPack);
emp->setInheritAnimatables(oldInheritAnimatables, *levelPack);
emp->setInheritDamage(oldInheritDamage, *levelPack);
emp->setInheritSoundSettings(oldInheritSoundSettings, *levelPack);
updateAllWidgetValues();
onEMPModify.emit(this, this->emp);
}));
}
}
| [
"treecam42@gmail.com"
] | treecam42@gmail.com |
76c97e1308a0bb6d3dac1c0d32971db454766561 | 84202c9c5d843e4633e34927e2b63f18b9692b0c | /tests/src/protostar/math/RectPackTest.cpp | dcb10cb1a0af63ab2cd8e6412be86ef9c6ddc8a6 | [
"Apache-2.0"
] | permissive | xgdwangdechao/galaxy | 08acd323c5ce22a5401f310e3ad94c2fd76d386a | e4cede2a4f7c0aa0db421c2d65230e7ba4cb37b9 | refs/heads/master | 2022-12-03T13:02:47.444557 | 2020-08-18T11:40:11 | 2020-08-18T11:40:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,919 | cpp | ///
/// RectPackTest.cpp
/// tests
///
/// Refer to LICENSE.txt for more details.
///
#include <gtest/gtest.h>
#include <protostar/math/RectPack.hpp>
TEST(RectPack, init)
{
pr::RectPack<int> p;
p.init(100, 100);
EXPECT_EQ(p.get_width(), 100);
EXPECT_EQ(p.get_height(), 100);
}
TEST(RectPack, cant_fit)
{
pr::RectPack<int> p;
p.init(100, 100);
auto res = p.pack(999, 999);
EXPECT_EQ(res, std::nullopt);
}
TEST(RectPack, fills_width_height)
{
pr::RectPack<int> p;
p.init(100, 100);
auto res = p.pack(100, 100);
ASSERT_TRUE(res != std::nullopt);
EXPECT_EQ(res->m_width, 100);
EXPECT_EQ(res->m_height, 100);
EXPECT_EQ(p.get_free_space().size(), 0);
}
TEST(RectPack, fills_width)
{
pr::RectPack<int> p;
p.init(100, 100);
auto res = p.pack(100, 10);
ASSERT_TRUE(res != std::nullopt);
ASSERT_EQ(p.get_free_space().size(), 1);
EXPECT_EQ(res->m_width, 100);
EXPECT_EQ(res->m_height, 10);
auto space = p.get_free_space()[0];
EXPECT_EQ(space.m_y, 100 + res->m_height);
EXPECT_EQ(space.m_height, 100 - res->m_height);
}
TEST(RectPack, fills_height)
{
pr::RectPack<int> p;
p.init(100, 100);
auto res = p.pack(10, 100);
ASSERT_TRUE(res != std::nullopt);
ASSERT_EQ(p.get_free_space().size(), 1);
EXPECT_EQ(res->m_width, 10);
EXPECT_EQ(res->m_height, 100);
auto space = p.get_free_space()[0];
EXPECT_EQ(space.m_x, 100 + res->m_width);
EXPECT_EQ(space.m_width, 100 - res->m_width);
}
TEST(RectPack, fits)
{
pr::RectPack<int> p;
p.init(100, 100);
auto res = p.pack(10, 10);
ASSERT_TRUE(res != std::nullopt);
ASSERT_EQ(p.get_free_space().size(), 2);
EXPECT_EQ(res->m_width, 10);
EXPECT_EQ(res->m_height, 10);
auto spaceA = p.get_free_space()[0];
auto spaceB = p.get_free_space()[1];
EXPECT_EQ(spaceA.m_y, 100 + res->m_height);
EXPECT_EQ(spaceA.m_height, 100 - res->m_height);
EXPECT_EQ(spaceB.m_width, 100 - res->m_width);
EXPECT_EQ(spaceB.m_height, res->m_height);
} | [
"dev.dom.re@gmail.com"
] | dev.dom.re@gmail.com |
b498ad87addb6697cbe381addd78d7602d1f2eb5 | 68bd064e7738c276551b220c2be7837b9b603e06 | /psetggm/tests/test_xor.cpp | 7a4c200204230beaacfa6457420a77eba2069c2a | [
"MIT"
] | permissive | dimakogan/checklist | 15acfcd6db7167e28b4ae4e00f08a995b1ce43ce | cd0ba2a770fcb184417715f6cf1dd753e8d5bfa4 | refs/heads/master | 2023-05-05T09:55:08.835496 | 2021-05-25T22:53:05 | 2021-05-25T22:53:05 | 347,237,651 | 21 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 589 | cpp | #include <iostream>
#include "../xor.h"
int main()
{
int row_len = 31;
uint8_t db[row_len * 7];
long long unsigned int idx1 = 3;
long long unsigned int idx2 = 6;
for (int i = 0; i < row_len; i++)
{
db[idx1*row_len + i] = 'X';
db[idx2*row_len + i] = 'X' ^ (uint8_t)i;
}
long long unsigned int elems[] = {idx1*row_len, idx2*row_len};
uint8_t out[row_len+3];
xor_rows(db, sizeof(db), elems, 2, row_len, out+1);
for (int i = 0; i < row_len; i++)
{
std::cout << int(out[1+i]) << " ";
}
std::cout << std::endl;
} | [
"dkogan@cs.stanford.edu"
] | dkogan@cs.stanford.edu |
7ce0cc1c17de7207ad01aed96ba2b423a9c82771 | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/WebCore/rendering/style/StyleGeneratedImage.cpp | 6b59fe7c496425d60c81b4bc481301663eb2a4ce | [
"BSL-1.0",
"BSD-2-Clause",
"LGPL-2.0-only",
"LGPL-2.1-only"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 3,333 | cpp | /*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. 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.
*
*/
#include "config.h"
#include "StyleGeneratedImage.h"
#include "CSSImageGeneratorValue.h"
#include "RenderElement.h"
#include "StyleResolver.h"
namespace WebCore {
StyleGeneratedImage::StyleGeneratedImage(PassRef<CSSImageGeneratorValue> value)
: m_imageGeneratorValue(std::move(value))
, m_fixedSize(m_imageGeneratorValue->isFixedSize())
{
m_isGeneratedImage = true;
}
PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() const
{
return &const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get());
}
LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
{
if (m_fixedSize) {
IntSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
if (multiplier == 1.0f)
return fixedSize;
LayoutUnit width = fixedSize.width() * multiplier;
LayoutUnit height = fixedSize.height() * multiplier;
// Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
if (fixedSize.width() > 0)
width = std::max<LayoutUnit>(1, width);
if (fixedSize.height() > 0)
height = std::max<LayoutUnit>(1, height);
return LayoutSize(width, height);
}
return m_containerSize;
}
void StyleGeneratedImage::computeIntrinsicDimensions(const RenderElement* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
// At a zoom level of 1 the image is guaranteed to have an integer size.
IntSize size = flooredIntSize(imageSize(renderer, 1));
intrinsicWidth = Length(size.width(), Fixed);
intrinsicHeight = Length(size.height(), Fixed);
intrinsicRatio = size;
}
void StyleGeneratedImage::addClient(RenderElement* renderer)
{
m_imageGeneratorValue->addClient(renderer);
}
void StyleGeneratedImage::removeClient(RenderElement* renderer)
{
m_imageGeneratorValue->removeClient(renderer);
}
PassRefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const IntSize& size) const
{
return const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).image(renderer, size);
}
bool StyleGeneratedImage::knownToBeOpaque(const RenderElement* renderer) const
{
return m_imageGeneratorValue->knownToBeOpaque(renderer);
}
}
| [
"adzhou@hp.com"
] | adzhou@hp.com |
9894fcb92c2ca3d82756857662db566d29fd4eab | dca9e5c65e79786df5da45d917eb2c2729cd45ab | /Assignment - Ik/ASS65.CPP | d5d2a0e4c929e486cb797d955efbf2545477813e | [] | no_license | raja21068/C-Programs-Beginners | 792650260b359d6c0e5797c6775ff023e9801037 | e16110d731dbb6cee346d086b7d1c3038a3a6adb | refs/heads/master | 2021-07-25T03:27:39.254067 | 2017-11-06T05:30:40 | 2017-11-06T05:30:40 | 109,651,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 283 | cpp | #include <conio.h>
#include <stdio.h>
void main () {
clrscr();
int a,b,c,d,e,f,g;
printf("Enter two fraction numbers(a/b,c/d): ");
scanf("%d/%d,%d/%d",&a,&b,&c,&d);
e=b*d;
f=e/b;
g=e/d;
printf("\n\nThe sum of %d/%d and %d/%d is: %d/%d",a,b,c,d,(a*f+c*g),e);
getch();
} | [
"rajakumarlohano@gmail.com"
] | rajakumarlohano@gmail.com |
d454888692befd09e36e2f270e6c837f8763d6b4 | d68d11f044b324dfa94ca01f5d7110c445face7b | /src/AddyMasterInfo.cpp | 19448ad3476982c8d40665607e0e2daf205f4943 | [] | no_license | aabdelrazek/addypin | 568e43753c9c36731798bcaebb28b6db08fe519c | 2d1f72293f22d57080ad5a21fd6dbc520b3f965d | refs/heads/master | 2021-01-18T01:42:53.306335 | 2015-03-03T04:06:19 | 2015-03-03T04:06:19 | 30,514,234 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,729 | cpp | /*
* AddyMasterInfo.cpp
*
* Created on: 2015-02-14
* Author: aabdelrazek
*/
#include "inc/AddyMasterInfo.h"
#include "utils/inc/strtk.hpp"
#include <Wt/WApplication>
#include "tinyxml/tinyxml.h"
AddyMasterInfo::AddyMasterInfo(std::string email, std::string mpin, unsigned int maxEntries):
mMasterPin(mpin),
mEmail(email),
mMaxEntries(maxEntries) {
}
AddyMasterInfo::~AddyMasterInfo() {
}
const std::string& AddyMasterInfo::GetMasterPin() {
return mMasterPin;
}
const std::string& AddyMasterInfo::GetEmail() {
return mEmail;
}
const unsigned int AddyMasterInfo::GetNumEntries() {
return mUserInfoEntries.size();
}
AddyUserInfo* AddyMasterInfo::GetEntry(unsigned int id) {
if (id < mUserInfoEntries.size()) {
return mUserInfoEntries[id];
}
return NULL;
}
void AddyMasterInfo::Serialize(TiXmlElement* pNode) {
TiXmlElement* pEmail = new TiXmlElement("email");
pEmail->LinkEndChild(new TiXmlText(mEmail));
pNode->LinkEndChild(pEmail);
TiXmlElement* pMasterPin = new TiXmlElement("user_pin");
pMasterPin->LinkEndChild(new TiXmlText(mMasterPin));
pNode->LinkEndChild(pMasterPin);
TiXmlElement* pAddresses = new TiXmlElement("addresses");
pNode->LinkEndChild(pAddresses);
TiXmlElement* pNumEntries = new TiXmlElement("num_addresses");
char nn[10];
sprintf(nn, "%lu", mUserInfoEntries.size());
pNumEntries->LinkEndChild(new TiXmlText(nn));
pAddresses->LinkEndChild(pNumEntries);
for (std::vector<AddyUserInfo*>::iterator it = mUserInfoEntries.begin(); it != mUserInfoEntries.end(); it++) {
TiXmlElement* pEntry = new TiXmlElement("entry");
pAddresses->LinkEndChild(pEntry);
(*it)->Serialize(pEntry);
}
}
void AddyMasterInfo::Deserialize(TiXmlElement* pNode) {
TiXmlElement* pEmail = pNode->FirstChildElement("email");
mEmail = pEmail->FirstChild()->Value();
TiXmlElement* pMasterPin = pNode->FirstChildElement("user_pin");
mMasterPin = pMasterPin->FirstChild()->Value();
TiXmlElement* pAddresses = pNode->FirstChildElement("addresses");
TiXmlElement* pNumEntries = pAddresses->FirstChildElement("num_addresses");
unsigned int numEntries = 0;
if (pNumEntries) {
sscanf(pNumEntries->FirstChild()->Value(), "%d", &numEntries);
}
TiXmlElement* entry = pAddresses->FirstChildElement("entry");
for (unsigned int i = 0; i < numEntries; i++) {
AddyUserInfo* pNew = new AddyUserInfo();
pNew->Deserialize(entry);
mUserInfoEntries.push_back(pNew);
entry = entry->NextSiblingElement("entry");
}
}
bool AddyMasterInfo::AddNewEntry(AddyUserInfo* pEntry) {
bool ret = false;
if (mUserInfoEntries.size() < mMaxEntries) {
mUserInfoEntries.push_back(pEntry);
ret = true;
}
return ret;
}
void AddyMasterInfo::DeleteAllEntries() {
mUserInfoEntries.clear();
}
| [
"eng.afathy@gmail.com"
] | eng.afathy@gmail.com |
d7c97d334a59ae58c154bf5276c0509b9be5ba6f | 3f4197b01dbc1f065d759c79e603c7deb31a2599 | /external/android/include/21/frameworks/av/include/media/stagefright/MediaCodec.h | 54a4e8b6ed059f52bbffe0e714068220ba8e0d1b | [
"Apache-2.0"
] | permissive | nova-video-player/aos-avos | 543477be60e8a2a546f027dd0a97b3bf170585e7 | 2b79168e639f8088ef5d1e3a8d09f5523c063801 | refs/heads/nova | 2023-08-09T21:09:13.446561 | 2023-07-07T20:00:31 | 2023-07-07T20:00:31 | 133,509,761 | 10 | 6 | Apache-2.0 | 2020-02-05T22:19:25 | 2018-05-15T11:59:28 | C | UTF-8 | C++ | false | false | 10,079 | h | /*
* Copyright 2012, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MEDIA_CODEC_H_
#define MEDIA_CODEC_H_
#include <gui/IGraphicBufferProducer.h>
#include <media/hardware/CryptoAPI.h>
#include <media/stagefright/foundation/AHandler.h>
#include <utils/Vector.h>
namespace android {
struct ABuffer;
struct AMessage;
struct AString;
struct CodecBase;
struct ICrypto;
struct IBatteryStats;
struct SoftwareRenderer;
struct Surface;
struct MediaCodec : public AHandler {
enum ConfigureFlags {
CONFIGURE_FLAG_ENCODE = 1,
};
enum BufferFlags {
BUFFER_FLAG_SYNCFRAME = 1,
BUFFER_FLAG_CODECCONFIG = 2,
BUFFER_FLAG_EOS = 4,
};
enum {
CB_INPUT_AVAILABLE = 1,
CB_OUTPUT_AVAILABLE = 2,
CB_ERROR = 3,
CB_OUTPUT_FORMAT_CHANGED = 4,
};
struct BatteryNotifier;
static sp<MediaCodec> CreateByType(
const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err = NULL);
static sp<MediaCodec> CreateByComponentName(
const sp<ALooper> &looper, const char *name, status_t *err = NULL);
status_t configure(
const sp<AMessage> &format,
const sp<Surface> &nativeWindow,
const sp<ICrypto> &crypto,
uint32_t flags);
status_t setCallback(const sp<AMessage> &callback);
status_t createInputSurface(sp<IGraphicBufferProducer>* bufferProducer);
status_t start();
// Returns to a state in which the component remains allocated but
// unconfigured.
status_t stop();
// Resets the codec to the INITIALIZED state. Can be called after an error
// has occured to make the codec usable.
status_t reset();
// Client MUST call release before releasing final reference to this
// object.
status_t release();
status_t flush();
status_t queueInputBuffer(
size_t index,
size_t offset,
size_t size,
int64_t presentationTimeUs,
uint32_t flags,
AString *errorDetailMsg = NULL);
status_t queueSecureInputBuffer(
size_t index,
size_t offset,
const CryptoPlugin::SubSample *subSamples,
size_t numSubSamples,
const uint8_t key[16],
const uint8_t iv[16],
CryptoPlugin::Mode mode,
int64_t presentationTimeUs,
uint32_t flags,
AString *errorDetailMsg = NULL);
status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs = 0ll);
status_t dequeueOutputBuffer(
size_t *index,
size_t *offset,
size_t *size,
int64_t *presentationTimeUs,
uint32_t *flags,
int64_t timeoutUs = 0ll);
status_t renderOutputBufferAndRelease(size_t index, int64_t timestampNs);
status_t renderOutputBufferAndRelease(size_t index);
status_t releaseOutputBuffer(size_t index);
status_t signalEndOfInputStream();
status_t getOutputFormat(sp<AMessage> *format) const;
status_t getInputFormat(sp<AMessage> *format) const;
status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const;
status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const;
status_t getOutputBuffer(size_t index, sp<ABuffer> *buffer);
status_t getOutputFormat(size_t index, sp<AMessage> *format);
status_t getInputBuffer(size_t index, sp<ABuffer> *buffer);
status_t requestIDRFrame();
// Notification will be posted once there "is something to do", i.e.
// an input/output buffer has become available, a format change is
// pending, an error is pending.
void requestActivityNotification(const sp<AMessage> ¬ify);
status_t getName(AString *componentName) const;
status_t setParameters(const sp<AMessage> ¶ms);
protected:
virtual ~MediaCodec();
virtual void onMessageReceived(const sp<AMessage> &msg);
private:
enum State {
UNINITIALIZED,
INITIALIZING,
INITIALIZED,
CONFIGURING,
CONFIGURED,
STARTING,
STARTED,
FLUSHING,
FLUSHED,
STOPPING,
RELEASING,
};
enum {
kPortIndexInput = 0,
kPortIndexOutput = 1,
};
enum {
kWhatInit = 'init',
kWhatConfigure = 'conf',
kWhatCreateInputSurface = 'cisf',
kWhatStart = 'strt',
kWhatStop = 'stop',
kWhatRelease = 'rele',
kWhatDequeueInputBuffer = 'deqI',
kWhatQueueInputBuffer = 'queI',
kWhatDequeueOutputBuffer = 'deqO',
kWhatReleaseOutputBuffer = 'relO',
kWhatSignalEndOfInputStream = 'eois',
kWhatGetBuffers = 'getB',
kWhatFlush = 'flus',
kWhatGetOutputFormat = 'getO',
kWhatGetInputFormat = 'getI',
kWhatDequeueInputTimedOut = 'dITO',
kWhatDequeueOutputTimedOut = 'dOTO',
kWhatCodecNotify = 'codc',
kWhatRequestIDRFrame = 'ridr',
kWhatRequestActivityNotification = 'racN',
kWhatGetName = 'getN',
kWhatSetParameters = 'setP',
kWhatSetCallback = 'setC',
};
enum {
kFlagIsSoftwareCodec = 1,
kFlagOutputFormatChanged = 2,
kFlagOutputBuffersChanged = 4,
kFlagStickyError = 8,
kFlagDequeueInputPending = 16,
kFlagDequeueOutputPending = 32,
kFlagIsSecure = 64,
kFlagSawMediaServerDie = 128,
kFlagIsEncoder = 256,
kFlagGatherCodecSpecificData = 512,
kFlagIsAsync = 1024,
kFlagIsComponentAllocated = 2048,
};
struct BufferInfo {
uint32_t mBufferID;
sp<ABuffer> mData;
sp<ABuffer> mEncryptedData;
sp<AMessage> mNotify;
sp<AMessage> mFormat;
bool mOwnedByClient;
};
State mState;
sp<ALooper> mLooper;
sp<ALooper> mCodecLooper;
sp<CodecBase> mCodec;
AString mComponentName;
uint32_t mReplyID;
uint32_t mFlags;
status_t mStickyError;
sp<Surface> mNativeWindow;
SoftwareRenderer *mSoftRenderer;
sp<AMessage> mOutputFormat;
sp<AMessage> mInputFormat;
sp<AMessage> mCallback;
bool mBatteryStatNotified;
bool mIsVideo;
// initial create parameters
AString mInitName;
bool mInitNameIsType;
bool mInitIsEncoder;
// Used only to synchronize asynchronous getBufferAndFormat
// across all the other (synchronous) buffer state change
// operations, such as de/queueIn/OutputBuffer, start and
// stop/flush/reset/release.
Mutex mBufferLock;
List<size_t> mAvailPortBuffers[2];
Vector<BufferInfo> mPortBuffers[2];
int32_t mDequeueInputTimeoutGeneration;
uint32_t mDequeueInputReplyID;
int32_t mDequeueOutputTimeoutGeneration;
uint32_t mDequeueOutputReplyID;
sp<ICrypto> mCrypto;
List<sp<ABuffer> > mCSD;
sp<AMessage> mActivityNotify;
bool mHaveInputSurface;
MediaCodec(const sp<ALooper> &looper);
static status_t PostAndAwaitResponse(
const sp<AMessage> &msg, sp<AMessage> *response);
static void PostReplyWithError(int32_t replyID, int32_t err);
status_t init(const AString &name, bool nameIsType, bool encoder);
void setState(State newState);
void returnBuffersToCodec();
void returnBuffersToCodecOnPort(int32_t portIndex);
size_t updateBuffers(int32_t portIndex, const sp<AMessage> &msg);
status_t onQueueInputBuffer(const sp<AMessage> &msg);
status_t onReleaseOutputBuffer(const sp<AMessage> &msg);
ssize_t dequeuePortBuffer(int32_t portIndex);
status_t getBufferAndFormat(
size_t portIndex, size_t index,
sp<ABuffer> *buffer, sp<AMessage> *format);
bool handleDequeueInputBuffer(uint32_t replyID, bool newRequest = false);
bool handleDequeueOutputBuffer(uint32_t replyID, bool newRequest = false);
void cancelPendingDequeueOperations();
void extractCSD(const sp<AMessage> &format);
status_t queueCSDInputBuffer(size_t bufferIndex);
status_t setNativeWindow(
const sp<Surface> &surface);
void postActivityNotificationIfPossible();
void onInputBufferAvailable();
void onOutputBufferAvailable();
void onError(status_t err, int32_t actionCode, const char *detail = NULL);
void onOutputFormatChanged();
status_t onSetParameters(const sp<AMessage> ¶ms);
status_t amendOutputFormatWithCodecSpecificData(const sp<ABuffer> &buffer);
void updateBatteryStat();
bool isExecuting() const;
/* called to get the last codec error when the sticky flag is set.
* if no such codec error is found, returns UNKNOWN_ERROR.
*/
inline status_t getStickyError() const {
return mStickyError != 0 ? mStickyError : UNKNOWN_ERROR;
}
inline void setStickyError(status_t err) {
mFlags |= kFlagStickyError;
mStickyError = err;
}
DISALLOW_EVIL_CONSTRUCTORS(MediaCodec);
};
} // namespace android
#endif // MEDIA_CODEC_H_
| [
"noury@archos.com"
] | noury@archos.com |
d4054098fed250945ffd0bf90263f148786ebd8c | cc1701cadaa3b0e138e30740f98d48264e2010bd | /chrome/browser/ui/app_list/search/chrome_search_result.cc | 66aef456ccac88e7acc3a53ec1f3829f4130c1ae | [
"BSD-3-Clause"
] | permissive | dbuskariol-org/chromium | 35d3d7a441009c6f8961227f1f7f7d4823a4207e | e91a999f13a0bda0aff594961762668196c4d22a | refs/heads/master | 2023-05-03T10:50:11.717004 | 2020-06-26T03:33:12 | 2020-06-26T03:33:12 | 275,070,037 | 1 | 3 | BSD-3-Clause | 2020-06-26T04:04:30 | 2020-06-26T04:04:29 | null | UTF-8 | C++ | false | false | 6,020 | cc | // Copyright 2018 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/ui/app_list/search/chrome_search_result.h"
#include <map>
#include "base/containers/adapters.h"
#include "chrome/browser/ui/app_list/app_context_menu.h"
#include "chrome/common/string_matching/tokenized_string.h"
#include "chrome/common/string_matching/tokenized_string_match.h"
ChromeSearchResult::ChromeSearchResult()
: metadata_(std::make_unique<ash::SearchResultMetadata>()) {}
ChromeSearchResult::~ChromeSearchResult() = default;
void ChromeSearchResult::SetActions(const Actions& actions) {
metadata_->actions = actions;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetDisplayScore(double display_score) {
metadata_->display_score = display_score;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetIsInstalling(bool is_installing) {
metadata_->is_installing = is_installing;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetTitle(const base::string16& title) {
metadata_->title = title;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetTitleTags(const Tags& tags) {
metadata_->title_tags = tags;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetDetails(const base::string16& details) {
metadata_->details = details;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetDetailsTags(const Tags& tags) {
metadata_->details_tags = tags;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetAccessibleName(const base::string16& name) {
metadata_->accessible_name = name;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetRating(float rating) {
metadata_->rating = rating;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetFormattedPrice(
const base::string16& formatted_price) {
metadata_->formatted_price = formatted_price;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetDisplayType(DisplayType display_type) {
metadata_->display_type = display_type;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetResultType(ResultType result_type) {
metadata_->result_type = result_type;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetDisplayIndex(DisplayIndex display_index) {
metadata_->display_index = display_index;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetPositionPriority(float position_priority) {
metadata_->position_priority = position_priority;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetIsOmniboxSearch(bool is_omnibox_search) {
metadata_->is_omnibox_search = is_omnibox_search;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetIsRecommendation(bool is_recommendation) {
metadata_->is_recommendation = is_recommendation;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetQueryUrl(const GURL& url) {
metadata_->query_url = url;
auto* updater = model_updater();
if (updater)
updater->SetSearchResultMetadata(id(), CloneMetadata());
}
void ChromeSearchResult::SetEquivalentResutlId(
const std::string& equivlanet_result_id) {
metadata_->equivalent_result_id = equivlanet_result_id;
auto* updater = model_updater();
if (updater)
updater->SetSearchResultMetadata(id(), CloneMetadata());
}
void ChromeSearchResult::SetIcon(const gfx::ImageSkia& icon) {
icon.EnsureRepsForSupportedScales();
metadata_->icon = icon;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetChipIcon(const gfx::ImageSkia& chip_icon) {
chip_icon.EnsureRepsForSupportedScales();
metadata_->chip_icon = chip_icon;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetBadgeIcon(const gfx::ImageSkia& badge_icon) {
badge_icon.EnsureRepsForSupportedScales();
metadata_->badge_icon = badge_icon;
SetSearchResultMetadata();
}
void ChromeSearchResult::SetNotifyVisibilityChange(
bool notify_visibility_change) {
metadata_->notify_visibility_change = notify_visibility_change;
}
void ChromeSearchResult::SetSearchResultMetadata() {
AppListModelUpdater* updater = model_updater();
if (updater)
updater->SetSearchResultMetadata(id(), CloneMetadata());
}
void ChromeSearchResult::InvokeAction(int action_index, int event_flags) {}
void ChromeSearchResult::OnVisibilityChanged(bool visibility) {
VLOG(1) << " Visibility change to " << visibility << " and ID is " << id();
}
void ChromeSearchResult::UpdateFromMatch(const TokenizedString& title,
const TokenizedStringMatch& match) {
const TokenizedStringMatch::Hits& hits = match.hits();
Tags tags;
tags.reserve(hits.size());
for (const auto& hit : hits)
tags.push_back(Tag(Tag::MATCH, hit.start(), hit.end()));
SetTitle(title.text());
SetTitleTags(tags);
set_relevance(match.relevance());
}
void ChromeSearchResult::GetContextMenuModel(GetMenuModelCallback callback) {
std::move(callback).Run(nullptr);
}
// static
std::string ChromeSearchResult::TagsDebugStringForTest(const std::string& text,
const Tags& tags) {
std::string result = text;
// Build a table of delimiters to insert.
std::map<size_t, std::string> inserts;
for (const auto& tag : tags) {
if (tag.styles & Tag::URL)
inserts[tag.range.start()].push_back('{');
if (tag.styles & Tag::MATCH)
inserts[tag.range.start()].push_back('[');
if (tag.styles & Tag::DIM) {
inserts[tag.range.start()].push_back('<');
inserts[tag.range.end()].push_back('>');
}
if (tag.styles & Tag::MATCH)
inserts[tag.range.end()].push_back(']');
if (tag.styles & Tag::URL)
inserts[tag.range.end()].push_back('}');
}
// Insert the delimiters (in reverse order, to preserve indices).
for (const auto& insert : base::Reversed(inserts))
result.insert(insert.first, insert.second);
return result;
}
app_list::AppContextMenu* ChromeSearchResult::GetAppContextMenu() {
return nullptr;
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
767fef145cb258fb4c3b459a7f5080ea2b4abb78 | 260e5dec446d12a7dd3f32e331c1fde8157e5cea | /Indi/SDK/Indi_0003_Grace_parameters.hpp | 8e4b7c359981fd8c3396630522f0da2e68836907 | [] | no_license | jfmherokiller/TheOuterWorldsSdkDump | 6e140fde4fcd1cade94ce0d7ea69f8a3f769e1c0 | 18a8c6b1f5d87bb1ad4334be4a9f22c52897f640 | refs/heads/main | 2023-08-30T09:27:17.723265 | 2021-09-17T00:24:52 | 2021-09-17T00:24:52 | 407,437,218 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 473 | hpp | #pragma once
// TheOuterWorlds SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "Indi_0003_Grace_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function 0003_Grace.0003_Grace_C.UserConstructionScript
struct A0003_Grace_C_UserConstructionScript_Params
{
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"peterpan0413@live.com"
] | peterpan0413@live.com |
24cf6215f7a2ce343d593095c39762360d01c8d4 | 43f8917847dbdcde3fc1007d59f34611cb916533 | /armstrong using function.cpp | 2974a3ff10439f2501e08311de71d60f8252c545 | [] | no_license | harshsaini09/my-programs-of-C | 9367f83f155aa819adc34010ba10dd67a5204d4d | 7b33f34d399023212a6231330d161a9865168d47 | refs/heads/master | 2022-12-01T16:32:01.755678 | 2020-08-09T13:36:18 | 2020-08-09T13:36:18 | 209,030,526 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 336 | cpp | #include<stdio.h>
int arm(int n)
{
int m,a,temp,sum=0;
while(n!=0)
{
a=n%10;
m=a*a*a;
sum=sum+m;
n/=10;
}
return sum;
}
main()
{
int n,temp;
printf("enter a number \n");
scanf("%d",&n);
temp=n;
if (temp==arm(n))
printf("this is armstrong number ");
else
printf("this is not armstrong ");
}
| [
"noreply@github.com"
] | harshsaini09.noreply@github.com |
30d68b76ef1462df8527e5fdf3e7e49684d7cc8e | df1a392cbf9dd781b209897e7913840a5a0f20b4 | /src/io/BasicReaderWriter.cpp | a34b77c2062c3af6922dea8246643714309db13a | [
"MIT"
] | permissive | dlatikaynen/blooDot | e665491230d09be79f8a7517c22e55786af3fe1c | 5ba6b0deac2c15a373715c479af80df2647a6bdc | refs/heads/master | 2023-07-11T00:38:24.006063 | 2022-09-18T13:49:21 | 2022-09-18T13:49:21 | 200,548,112 | 4 | 0 | MIT | 2020-04-30T10:46:13 | 2019-08-04T22:34:54 | C++ | UTF-8 | C++ | false | false | 4,427 | cpp | #include "..\PreCompiledHeaders.h"
#include "BasicReaderWriter.h"
using namespace Microsoft::WRL;
using namespace Windows::Storage;
using namespace Windows::Storage::FileProperties;
using namespace Windows::Storage::Streams;
using namespace Windows::Foundation;
using namespace Windows::ApplicationModel;
using namespace concurrency;
BasicReaderWriter::BasicReaderWriter()
{
m_location = Package::Current->InstalledLocation;
}
BasicReaderWriter::BasicReaderWriter(
_In_ Windows::Storage::StorageFolder^ folder
)
{
m_location = folder;
Platform::String^ path = m_location->Path;
if (path->Length() == 0)
{
// Applications are not permitted to access certain
// folders, such as the Documents folder, using this
// code path. In such cases, the Path property for
// the folder will be an empty string.
throw ref new Platform::FailureException();
}
}
Platform::Array<byte>^ BasicReaderWriter::ReadData(
_In_ Platform::String^ filename
)
{
CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0};
extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN;
extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
extendedParams.lpSecurityAttributes = nullptr;
extendedParams.hTemplateFile = nullptr;
Wrappers::FileHandle file(
CreateFile2(
filename->Data(),
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
&extendedParams
)
);
if (file.Get() == INVALID_HANDLE_VALUE)
{
throw ref new Platform::FailureException();
}
FILE_STANDARD_INFO fileInfo = {0};
if (!GetFileInformationByHandleEx(
file.Get(),
FileStandardInfo,
&fileInfo,
sizeof(fileInfo)
))
{
throw ref new Platform::FailureException();
}
if (fileInfo.EndOfFile.HighPart != 0)
{
throw ref new Platform::OutOfMemoryException();
}
Platform::Array<byte>^ fileData = ref new Platform::Array<byte>(fileInfo.EndOfFile.LowPart);
if (!ReadFile(
file.Get(),
fileData->Data,
fileData->Length,
nullptr,
nullptr
))
{
throw ref new Platform::FailureException();
}
return fileData;
}
task<Platform::Array<byte>^> BasicReaderWriter::ReadDataAsync(
_In_ Platform::String^ filename
)
{
return task<StorageFile^>(m_location->GetFileAsync(filename)).then([=](StorageFile^ file)
{
return FileIO::ReadBufferAsync(file);
}).then([=](IBuffer^ buffer)
{
auto fileData = ref new Platform::Array<byte>(buffer->Length);
DataReader::FromBuffer(buffer)->ReadBytes(fileData);
return fileData;
});
}
uint32 BasicReaderWriter::WriteData(
_In_ Platform::String^ filename,
_In_ const Platform::Array<byte>^ fileData
)
{
CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0};
extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN;
extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
extendedParams.lpSecurityAttributes = nullptr;
extendedParams.hTemplateFile = nullptr;
Wrappers::FileHandle file(
CreateFile2(
filename->Data(),
GENERIC_WRITE,
0,
CREATE_ALWAYS,
&extendedParams
)
);
if (file.Get() == INVALID_HANDLE_VALUE)
{
throw ref new Platform::FailureException();
}
DWORD numBytesWritten;
if (
!WriteFile(
file.Get(),
fileData->Data,
fileData->Length,
&numBytesWritten,
nullptr
) ||
numBytesWritten != fileData->Length
)
{
throw ref new Platform::FailureException();
}
return numBytesWritten;
}
task<void> BasicReaderWriter::WriteDataAsync(
_In_ Platform::String^ filename,
_In_ const Platform::Array<byte>^ fileData
)
{
return task<StorageFile^>(m_location->CreateFileAsync(filename, CreationCollisionOption::ReplaceExisting)).then([=](StorageFile^ file)
{
FileIO::WriteBytesAsync(file, fileData);
});
}
| [
"dlatikay@outlook.com"
] | dlatikay@outlook.com |
d352516ad763e55f7533608e3b47f1a3c0d487d6 | 896bcdf42a98bde051097ebe3e68c44feba02f85 | /做题/4.Stacks of Flapjacks.cpp | e004a9bde9600c53403c91cce6163c52a259398b | [] | no_license | BIT-zhangxin/AlogrithmLearning | 4c13b5c24b6677172068a78e859a996cd5559112 | 6a68357adeb6fb6f8b7b2832676d5e2dbb3157f1 | refs/heads/master | 2020-06-24T00:32:41.029086 | 2019-07-25T09:01:42 | 2019-07-25T09:01:42 | 198,795,739 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,736 | cpp | //#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//
//int Left = 0;
//
//void find(int *A, int len);
//void change(int *A, int x);
//int check(int *A,int len);
//
//int cmp(const void *a, const void *b)
//{
// return *(int*)a - *(int*)b;
//}
//
//int main()
//{
// char tmp;
// int size = 0;
// int A[35];
// memset(A, 0, sizeof(A));
// while (scanf("%c", &tmp)!=EOF)
// {
// if (tmp != ' ' && tmp != '\n')
// {
// A[size] = 10 * A[size] + tmp - '0';
// }
// if (tmp == ' ')
// {
// size++;
// }
// else if (tmp == '\n')
// {
// size++;
// for (int i = 0; i < size; i++)
// {
// printf((i != size - 1) ? "%d " : "%d\n", A[i]);
// }
// Left = size;
// size=check(A,size);
// //从后检查一次顺序
// find(A, size);
// size = 0;
// memset(A, 0, sizeof(A));
// }
// }
// return 0;
//}
//
//int check(int *A,int len)
//{
// int B[35];
// for (int i = 0; i < len; i++)
// {
// B[i] = A[i];
// }
// qsort(B,len,sizeof(int),cmp);
// for (int i = len-1 ; i >= 0; i--)
// {
// if (B[i] != A[i]) return i + 1;
// }
// return 0;
//}
//
//void find(int *A,int len)
//{
// if (len == 0)
// {
// printf("0\n");
// return;
// }
// int max = -99999999;
// int location;
// for (int i = 0; i < len; i++)
// {
// if (A[i] > max)
// {
// location = i;
// max = A[i];
// }
// }
// if (location == 0)
// {
// printf("%d ", Left - len + 1);
// change(A, len);
// len = check(A, len);
// find(A, len);
// }
// else
// {
// printf("%d ",Left-location );
// change(A, location + 1);
// len = check(A, len);
// find(A, len);
// }
//}
//
//void change(int *A,int x)
//{
// for (int i = 0; i < x / 2; i++)
// {
// int tmp = A[i];
// A[i] = A[x - 1 - i];
// A[x - 1 - i] = tmp;
// }
//} | [
"1047632321@qq.com"
] | 1047632321@qq.com |
1260d963ff0d1f56870bbddc47b204ee2aee6939 | f85d6b88aa35c4ce2d4315dcaa247db071a92b52 | /Direct3D/GamePlayManager/GamePlayManager.cpp | da484edc5ae815c7ca703b8fd4a0774d1ce4e4da | [] | no_license | junghoon88/dx11portfolio | 279d3117550b0766a68836d12b032e25ddbcfec1 | fbd2941c772162b7d9be75e6409fa9633bca415d | refs/heads/master | 2020-03-26T06:40:05.006809 | 2018-09-21T13:13:52 | 2018-09-21T13:13:52 | 144,615,838 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 617 | cpp | #include "stdafx.h"
#include "GamePlayManager.h"
#include "../Executes/DrawStage.h"
GamePlayManager::GamePlayManager(DrawStage * stage)
: stage(stage)
, playTime(0.0f)
{
enemyRespawnManager = new EnemyRespawnManager(stage);
}
GamePlayManager::~GamePlayManager()
{
SAFE_DELETE(enemyRespawnManager);
}
void GamePlayManager::Update(void)
{
if (enemyRespawnManager->GetBattleStart() == false)
{
enemyRespawnManager->SetBattleStart(true);
return;
}
else if (enemyRespawnManager->GetBattleEnd() == true)
{
//Battle Á¾·á
}
else
{
playTime += gTime->Delta();
enemyRespawnManager->Update();
}
}
| [
"theking14@hanmail.net"
] | theking14@hanmail.net |
57bce22c8060fe3d7f62ef13c18fff7d1addea8a | ef8352507d8de42f12aa405cb6e2682eb30d77c5 | /day9.cpp | 891d1c1730a9beec69c16ecaa52fbc1f4b42af49 | [] | no_license | RaduXD1/AoC_2019 | 1da184a002116fa2c9329fc05f9a3c7fb4af2389 | 49b63ec75ddb66f194244967f2c1d6755b04b5cd | refs/heads/master | 2020-09-28T15:27:11.871830 | 2020-01-12T21:12:08 | 2020-01-12T21:12:08 | 226,805,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,993 | cpp | #include <bits/stdc++.h>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
long long n,b,i,sol,f[100],a[10000],v1,v2,ok,aux,nr,poz,base;
int main()
{
while(fin>>b) a[++n]=b;
base=1;
for(i=1;i<=n;i++)
{
aux=a[i];nr=0;
for(ok=1;ok<=7;ok++) f[ok]=0;
while(aux) f[++nr]=aux%10,aux/=10;
if(f[1]==9&&f[2]==9) break;
if(f[1]==3)
{
if(f[3]==0) poz=a[++i]+1;
else if(f[3]==1) poz=++i;
else if(f[3]==2) poz=a[++i]+base;
a[poz]=2;
}
else if(f[1]==4)
{
if(f[3]==0) poz=a[++i]+1;
else if(f[3]==1) poz=++i;
else if(f[3]==2) poz=a[++i]+base;
fout<<a[poz]<<"\n";
}
else if(f[1]==2||f[1]==1||f[1]==7||f[1]==8)
{
if(f[3]==0) v1=a[a[++i]+1];
else if(f[3]==1) v1=a[++i];
else v1=a[a[++i]+base];
if(f[4]==0) v2=a[a[++i]+1];
else if(f[4]==1) v2=a[++i];
else v2=a[a[++i]+base];
if(f[5]==0) poz=a[++i]+1;
else if(f[5]==1) poz=++i;
else if(f[5]==2) poz=a[++i]+base;
if(f[1]==1) a[poz]=v1+v2;
if(f[1]==2) a[poz]=v1*v2;
if(f[1]==7) a[poz]=(v1<v2);
if(f[1]==8) a[poz]=(v1==v2);
}
else if(f[1]==5||f[1]==6)
{
if(f[3]==0) v1=a[a[++i]+1];
else if(f[3]==1) v1=a[++i];
else v1=a[a[++i]+base];
if(f[4]==0) v2=a[a[++i]+1];
else if(f[4]==1) v2=a[++i];
else v2=a[a[++i]+base];
if(f[1]==5&&v1!=0) i=v2;
else if(f[1]==6&&v1==0) i=v2;
}
else if(f[1]==9)
{
if(f[3]==0) v1=a[a[++i]+1];
else if(f[3]==1) v1=a[++i];
else v1=a[a[++i]+base];
base+=v1;
}
}
return 0;
}
| [
"noreply@github.com"
] | RaduXD1.noreply@github.com |
fc5131a7c8affaff0ae8cbbc6b187c51136b7fe8 | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_2/processor16/65/U | 16f8ea6bdd2e146b6d49f6d52a4857161b1ae231 | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 23,885 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "65";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
392
(
(0.00863428 -0.00411021 1.92924e-20)
(0.0275118 -0.0120509 -2.20021e-20)
(0.00999314 -0.00439046 4.03943e-20)
(0.0315347 -0.0127694 5.15528e-20)
(0.0556358 -0.0200143 -1.00917e-19)
(0.0822569 -0.0262225 -9.18862e-21)
(0.11138 -0.0314381 -9.78165e-20)
(0.0114357 -0.00461093 -4.40719e-20)
(0.0357902 -0.0133086 3.12359e-20)
(0.062692 -0.0207091 -2.6029e-20)
(0.0920975 -0.0269212 8.66797e-20)
(0.123982 -0.031998 1.59794e-20)
(0.158347 -0.0359104 -5.80845e-20)
(0.195174 -0.038633 2.05677e-19)
(0.234426 -0.0401546 -2.47891e-20)
(0.0129581 -0.00476376 -9.76152e-20)
(0.0402653 -0.0136465 5.05309e-20)
(0.0700878 -0.0210691 2.56491e-20)
(0.102377 -0.0271527 -6.17268e-20)
(0.137103 -0.0319602 6.23822e-20)
(0.174254 -0.0354684 5.41656e-21)
(0.213802 -0.0376596 -4.51897e-20)
(0.255694 -0.0385314 2.0735e-20)
(0.299853 -0.0380905 -4.23763e-20)
(0.346175 -0.0363527 2.97149e-20)
(0.394525 -0.0333452 1.44923e-20)
(0.0145554 -0.00484133 3.33922e-20)
(0.0449445 -0.0137616 -7.48494e-20)
(0.0777956 -0.0210611 -1.00547e-19)
(0.113056 -0.0268738 3.82998e-20)
(0.150688 -0.0312731 1.06647e-20)
(0.190668 -0.0342431 -5.60683e-20)
(0.232956 -0.0357744 1.91947e-20)
(0.277482 -0.0358753 1.44802e-20)
(0.324152 -0.0345643 -1.3684e-19)
(0.372839 -0.0318708 1.11287e-19)
(0.423386 -0.0278372 2.24084e-20)
(0.475597 -0.0225211 5.85316e-20)
(0.529236 -0.0159971 7.58569e-20)
(0.584027 -0.0083583 -5.78007e-20)
(0.124088 -0.0260442 -6.81473e-20)
(0.164675 -0.0298895 4.55543e-20)
(0.207511 -0.0321823 -1.04312e-19)
(0.252541 -0.032923 4.94442e-20)
(0.299679 -0.0321314 -2.34916e-20)
(0.34881 -0.0298396 -2.80357e-20)
(0.399788 -0.0260918 2.39672e-21)
(0.452429 -0.0209475 -1.23066e-19)
(0.506511 -0.0144826 1.03798e-19)
(0.56177 -0.00679164 -1.44712e-19)
(0.617898 0.00201091 1.24311e-19)
(0.674543 0.0117897 -2.03395e-19)
(0.731307 0.0223877 4.18873e-20)
(0.787749 0.0336274 -2.13487e-20)
(0.322163 -0.0272549 -6.62888e-20)
(0.37369 -0.0238752 3.4112e-20)
(0.426866 -0.0189811 -8.37393e-20)
(0.481483 -0.0126499 1.17317e-19)
(0.537293 -0.00497787 -1.05733e-19)
(0.594003 0.00391919 7.8989e-20)
(0.651277 0.0139043 -8.62205e-20)
(0.708735 0.0248191 1.31626e-20)
(0.765954 0.0364838 -1.26045e-19)
(0.822471 0.0486987 1.79324e-19)
(0.877789 0.0612467 3.58546e-20)
(0.931382 0.0738965 -1.58961e-19)
(0.982702 0.0864095 1.21167e-19)
(0.625732 0.0161192 3.35126e-20)
(0.683953 0.0272896 7.58733e-20)
(0.742008 0.0393203 -4.98931e-20)
(0.799454 0.0520084 7.2363e-20)
(0.855811 0.0651324 -9.85817e-20)
(0.910574 0.078456 6.87889e-20)
(0.963213 0.0917323 -3.34981e-20)
(1.01319 0.104712 2.26025e-20)
(1.05997 0.117163 2.45627e-20)
(1.10302 0.128867 1.47503e-20)
(1.14178 0.139417 -8.74939e-20)
(1.17562 0.148542 -2.38472e-20)
(0.88757 0.0828258 -2.473e-20)
(0.941555 0.0968201 1.93761e-20)
(0.993033 0.110599 1.48928e-20)
(1.04148 0.123904 -1.29233e-19)
(1.08639 0.136499 -2.42671e-20)
(1.12728 0.148166 -1.02666e-19)
(1.16363 0.158542 4.20457e-20)
(1.1949 0.167421 1.35733e-20)
(1.149 0.167879 5.96297e-20)
(1.1829 0.177911 9.24874e-20)
(1.21161 0.186361 -6.91702e-20)
(1.149 -0.167879 2.97016e-20)
(1.1829 -0.177911 -8.88046e-20)
(1.21161 -0.186361 -2.91828e-20)
(0.88757 -0.0828258 -7.58606e-20)
(0.941555 -0.0968201 -1.02903e-19)
(0.993033 -0.110599 -2.11363e-21)
(1.04148 -0.123904 1.38499e-19)
(1.08639 -0.136499 -1.05236e-19)
(1.12728 -0.148166 -1.0237e-19)
(1.16363 -0.158542 6.08655e-20)
(1.1949 -0.167421 4.41993e-20)
(0.567751 -0.00599118 3.23923e-20)
(0.625732 -0.0161192 1.34833e-19)
(0.683953 -0.0272896 -4.02692e-20)
(0.742008 -0.0393203 6.9347e-20)
(0.799454 -0.0520084 -9.76305e-20)
(0.855811 -0.0651324 2.61717e-20)
(0.910574 -0.078456 -1.08951e-19)
(0.963213 -0.0917323 4.26261e-20)
(1.01319 -0.104712 -9.99979e-20)
(1.05997 -0.117163 1.04938e-19)
(1.10302 -0.128867 3.96001e-20)
(1.14178 -0.139417 3.38404e-20)
(0.322163 0.0272549 1.07696e-19)
(0.37369 0.0238752 9.29167e-21)
(0.426866 0.0189811 9.83055e-20)
(0.481483 0.0126499 -1.59616e-19)
(0.537293 0.00497787 1.52509e-19)
(0.594003 -0.00391919 -1.71592e-19)
(0.651277 -0.0139043 -1.70909e-20)
(0.708735 -0.0248191 1.05692e-19)
(0.765954 -0.0364838 -2.09508e-20)
(0.822471 -0.0486987 2.36375e-20)
(0.877789 -0.0612467 8.78335e-20)
(0.931382 -0.0738965 1.37054e-19)
(0.982702 -0.0864095 -5.30387e-20)
(0.124088 0.0260442 1.08216e-19)
(0.164675 0.0298895 -8.25678e-20)
(0.207511 0.0321823 -1.46804e-20)
(0.252541 0.032923 5.69612e-20)
(0.299679 0.0321314 -8.04515e-20)
(0.34881 0.0298396 3.02554e-20)
(0.399788 0.0260918 -1.16142e-19)
(0.452429 0.0209475 1.06572e-19)
(0.506511 0.0144826 -1.16896e-19)
(0.56177 0.00679164 1.00694e-19)
(0.617898 -0.00201091 -5.84225e-20)
(0.674543 -0.0117896 6.50868e-20)
(0.731307 -0.0223877 1.30376e-19)
(0.787749 -0.0336274 -8.61317e-21)
(0.0145554 0.00484133 -4.21069e-20)
(0.0449445 0.0137616 4.99575e-20)
(0.0777956 0.0210611 5.41194e-20)
(0.113056 0.0268738 -2.29872e-20)
(0.150688 0.0312731 -1.51819e-19)
(0.190668 0.0342431 1.49787e-19)
(0.232956 0.0357744 -3.78159e-20)
(0.277482 0.0358753 -1.57121e-20)
(0.324152 0.0345643 -8.98035e-21)
(0.372839 0.0318708 1.63589e-20)
(0.423386 0.0278372 -5.72576e-21)
(0.475597 0.0225211 -1.08311e-19)
(0.529236 0.0159971 -2.07881e-20)
(0.0129581 0.00476376 9.33734e-20)
(0.0402653 0.0136465 -6.32358e-20)
(0.0700878 0.0210691 2.73254e-20)
(0.102377 0.0271527 -9.60626e-21)
(0.137103 0.0319602 -1.37258e-21)
(0.174254 0.0354684 -8.27327e-20)
(0.213802 0.0376596 -3.39019e-20)
(0.255694 0.0385314 -1.03258e-19)
(0.299853 0.0380905 1.42574e-19)
(0.346175 0.0363527 -5.81813e-20)
(0.0114357 0.00461093 3.94628e-20)
(0.0357902 0.0133086 -2.78827e-20)
(0.062692 0.0207091 4.9429e-20)
(0.0920975 0.0269212 1.26593e-20)
(0.123982 0.031998 3.0337e-20)
(0.158347 0.0359104 1.60675e-19)
(0.195174 0.038633 -1.4871e-19)
(0.00999314 0.00439046 -3.30646e-20)
(0.0315347 0.0127694 2.12469e-20)
(0.0556358 0.0200143 7.09698e-20)
(0.0822569 0.0262225 -3.54088e-21)
(0.11138 0.0314381 9.85894e-20)
(0.00863428 0.00411021 -9.05648e-21)
(0.0275118 0.0120509 -5.16349e-20)
(1.29843 0.200112 1.90123e-20)
(1.2938 0.19485 -8.00036e-21)
(1.28645 0.187495 -7.1102e-21)
(1.27794 0.17906 1.32798e-20)
(1.26916 0.170218 -7.5903e-21)
(1.26055 0.161373 -9.2082e-21)
(1.25229 0.152742 4.80737e-21)
(1.24446 0.144429 9.22026e-21)
(1.23706 0.136472 -1.00551e-21)
(1.23006 0.128873 -1.2094e-20)
(1.22346 0.12162 8.09466e-21)
(1.21722 0.114693 -6.09361e-21)
(1.21134 0.108071 -1.84967e-21)
(1.2058 0.101731 3.76996e-21)
(1.20058 0.0956549 -1.7058e-21)
(1.19567 0.0898212 -1.65476e-21)
(1.19106 0.0842117 -2.11324e-22)
(1.18674 0.0788088 2.87474e-22)
(1.18269 0.0735962 -1.40239e-22)
(1.17891 0.0685582 2.65688e-22)
(1.17538 0.0636802 -1.14515e-21)
(1.17211 0.0589485 -1.40735e-22)
(1.16908 0.0543503 4.15548e-22)
(1.16629 0.0498733 -2.39223e-22)
(1.16372 0.0455062 6.22876e-22)
(1.16139 0.0412379 -4.70301e-22)
(1.15928 0.0370582 -2.89241e-22)
(1.15738 0.0329573 -7.65569e-23)
(1.1557 0.0289258 -1.39391e-22)
(1.15423 0.0249545 8.37097e-23)
(1.15297 0.0210348 -1.04805e-22)
(1.15192 0.0171581 -3.89471e-23)
(1.15107 0.0133157 -5.35389e-23)
(1.15043 0.00949884 5.69218e-24)
(1.15 0.00569748 -6.00493e-23)
(1.14977 0.001906 -5.96524e-23)
(1.23593 0.18369 -1.56682e-20)
(1.27343 0.202306 -7.64787e-21)
(1.29189 0.209677 -1.17353e-20)
(1.29799 0.210726 -6.33926e-22)
(1.29636 0.207035 -5.59533e-21)
(1.29037 0.200265 -2.70883e-21)
(1.28231 0.1918 1.36049e-20)
(1.27354 0.182565 -3.72375e-21)
(1.26474 0.173146 -2.09733e-21)
(1.25625 0.163877 4.2158e-21)
(1.24818 0.154923 2.12982e-21)
(1.24055 0.146354 2.51516e-21)
(1.23335 0.138185 1.43532e-21)
(1.22656 0.130407 -4.69593e-21)
(1.22014 0.122998 8.86206e-23)
(1.21408 0.115935 5.60703e-21)
(1.20836 0.109192 -1.68032e-21)
(1.20297 0.102745 -4.58023e-22)
(1.19788 0.0965727 -1.77058e-21)
(1.1931 0.0906527 1.39544e-21)
(1.18861 0.0849654 1.40579e-21)
(1.18439 0.0794923 -7.44402e-22)
(1.18045 0.0742157 -3.85642e-22)
(1.17676 0.0691194 2.12768e-22)
(1.17332 0.0641881 6.91906e-22)
(1.17012 0.0594073 6.87511e-22)
(1.16716 0.0547637 -1.17129e-21)
(1.16443 0.0502447 9.983e-23)
(1.16193 0.0458383 3.72866e-22)
(1.15965 0.0415334 3.01873e-22)
(1.15758 0.0373192 2.25369e-23)
(1.15573 0.0331857 1.17067e-22)
(1.15408 0.0291233 -6.71938e-23)
(1.15265 0.0251226 1.50633e-22)
(1.15142 0.0211746 -7.45536e-23)
(1.15039 0.0172708 -1.9373e-23)
(1.14956 0.0134022 1.403e-22)
(1.14893 0.00955993 -1.07163e-22)
(1.14851 0.00573395 7.88664e-23)
(1.14829 0.00191766 8.36807e-24)
(1.24824 0.200946 2.89225e-21)
(1.27991 0.215974 1.8898e-20)
(1.29404 0.220591 -2.11815e-20)
(1.29707 0.219222 8.54544e-21)
(1.29347 0.213619 -2.85589e-21)
(1.28638 0.205419 3.8369e-21)
(1.27783 0.195916 -2.19134e-21)
(1.26892 0.185939 -7.69368e-21)
(1.26019 0.175987 7.1624e-21)
(1.25187 0.166322 -6.16311e-21)
(1.24402 0.157064 5.905e-21)
(1.23661 0.148251 -1.97876e-21)
(1.22963 0.139878 4.89906e-21)
(1.22303 0.131926 -1.56566e-21)
(1.2168 0.124365 -2.57668e-21)
(1.21092 0.117168 2.76991e-21)
(1.20536 0.110306 1.46528e-21)
(1.20012 0.103753 -6.34404e-22)
(1.19518 0.0974858 4.15588e-22)
(1.19052 0.0914806 -5.86846e-22)
(1.18615 0.0857164 1.01533e-21)
(1.18204 0.0801736 -1.61107e-21)
(1.17819 0.0748337 1.2391e-21)
(1.1746 0.0696795 -3.21139e-22)
(1.17124 0.0646951 4.2838e-22)
(1.16812 0.0598655 -2.75281e-22)
(1.16523 0.0551767 -3.08845e-23)
(1.16257 0.0506158 2.45518e-22)
(1.16012 0.0461703 6.50887e-23)
(1.24824 -0.200946 2.07452e-20)
(1.27991 -0.215974 -3.64698e-20)
(1.29404 -0.220591 1.88417e-20)
(1.29707 -0.219222 -4.28628e-21)
(1.29347 -0.213619 2.37147e-21)
(1.28638 -0.205419 -4.79604e-22)
(1.27783 -0.195916 1.10909e-21)
(1.26892 -0.185939 1.00555e-20)
(1.26019 -0.175987 -8.0325e-21)
(1.25187 -0.166322 5.09312e-21)
(1.24402 -0.157064 -3.93718e-21)
(1.23661 -0.148251 3.74635e-21)
(1.22963 -0.139878 -5.67434e-21)
(1.22303 -0.131926 2.97634e-21)
(1.2168 -0.124365 1.9521e-21)
(1.21092 -0.117168 -1.62328e-21)
(1.20536 -0.110306 -1.96672e-21)
(1.20012 -0.103753 1.55265e-21)
(1.19518 -0.0974858 -7.0783e-22)
(1.19052 -0.0914806 2.30229e-22)
(1.18615 -0.0857164 -3.66354e-22)
(1.18204 -0.0801736 1.33022e-21)
(1.17819 -0.0748337 -7.31111e-22)
(1.1746 -0.0696795 7.68153e-22)
(1.17124 -0.0646951 -6.19653e-22)
(1.16812 -0.0598655 6.16797e-22)
(1.16523 -0.0551767 -1.13731e-22)
(1.16257 -0.0506158 9.66404e-24)
(1.16012 -0.0461703 -2.84821e-22)
(1.15789 -0.0418287 6.24113e-23)
(1.15587 -0.0375801 -3.91294e-23)
(1.15406 -0.0334141 -1.32776e-22)
(1.15245 -0.0293207 1.19714e-22)
(1.15105 -0.0252905 -5.40403e-23)
(1.14985 -0.0213143 2.68947e-23)
(1.14884 -0.0173833 4.78857e-23)
(1.14804 -0.0134885 -1.90032e-23)
(1.14742 -0.00962081 2.08945e-23)
(1.147 -0.00577024 -1.04404e-23)
(1.14679 -0.00192915 1.61946e-23)
(1.23593 -0.18369 -1.19321e-20)
(1.27343 -0.202306 2.2266e-21)
(1.29189 -0.209677 1.40803e-20)
(1.29799 -0.210726 -3.63414e-21)
(1.29636 -0.207035 2.68907e-22)
(1.29037 -0.200265 6.01142e-21)
(1.28231 -0.1918 -1.02442e-20)
(1.27354 -0.182565 3.40242e-21)
(1.26474 -0.173146 3.87602e-21)
(1.25625 -0.163877 -1.49206e-21)
(1.24818 -0.154923 -2.67937e-21)
(1.24055 -0.146354 -2.94621e-21)
(1.23335 -0.138185 8.83154e-21)
(1.22656 -0.130407 -2.39097e-21)
(1.22014 -0.122998 1.51173e-21)
(1.21408 -0.115935 -5.29299e-21)
(1.20836 -0.109192 2.97002e-21)
(1.20297 -0.102745 1.39708e-21)
(1.19788 -0.0965727 2.6971e-21)
(1.1931 -0.0906527 4.52112e-22)
(1.18861 -0.0849654 -1.54721e-21)
(1.18439 -0.0794923 4.19106e-22)
(1.18045 -0.0742157 9.35563e-22)
(1.17676 -0.0691194 -3.01986e-22)
(1.17332 -0.0641881 3.30415e-22)
(1.17012 -0.0594073 -5.13499e-23)
(1.16716 -0.0547637 1.13737e-22)
(1.16443 -0.0502447 -2.48441e-22)
(1.16193 -0.0458383 3.46791e-23)
(1.15965 -0.0415334 -3.31012e-23)
(1.15758 -0.0373192 1.74834e-22)
(1.15573 -0.0331857 6.34687e-23)
(1.15408 -0.0291233 6.57727e-23)
(1.15265 -0.0251226 -1.66883e-23)
(1.15142 -0.0211746 4.2614e-23)
(1.15039 -0.0172708 3.08958e-23)
(1.14956 -0.0134022 7.16261e-23)
(1.14893 -0.00955993 -7.23913e-23)
(1.14851 -0.00573395 6.76114e-23)
(1.14829 -0.00191766 1.05978e-23)
(1.25229 -0.152742 9.73049e-21)
(1.24446 -0.144429 -1.05601e-20)
(1.23706 -0.136472 -2.16069e-21)
(1.23006 -0.128873 5.41444e-21)
(1.22346 -0.12162 -3.0454e-21)
(1.21722 -0.114693 3.30868e-21)
(1.21134 -0.108071 1.06127e-21)
(1.2058 -0.101731 -5.62795e-21)
(1.20058 -0.0956549 1.07148e-21)
(1.19567 -0.0898212 1.63848e-22)
(1.19106 -0.0842117 -2.96067e-22)
(1.18674 -0.0788088 3.18433e-22)
(1.18269 -0.0735962 -9.1705e-22)
(1.17891 -0.0685582 -6.23083e-22)
(1.17538 -0.0636802 3.14551e-22)
(1.17211 -0.0589485 -9.31551e-22)
(1.16908 -0.0543503 8.81069e-22)
(1.16629 -0.0498733 1.32985e-22)
(1.16372 -0.0455062 -8.10688e-22)
(1.16139 -0.0412379 4.13101e-23)
(1.15928 -0.0370582 1.47613e-22)
(1.15738 -0.0329573 -4.03835e-23)
(1.1557 -0.0289258 3.38077e-23)
(1.15423 -0.0249545 -1.74752e-22)
(1.15297 -0.0210348 6.59425e-23)
(1.15192 -0.0171581 -2.94911e-23)
(1.15107 -0.0133157 -1.04608e-22)
(1.15043 -0.00949884 1.05006e-22)
(1.15 -0.00569748 -7.05942e-23)
(1.14977 -0.001906 1.19157e-23)
)
;
boundaryField
{
inlet
{
type uniformFixedValue;
uniformValue constant (1 0 0);
value nonuniform 0();
}
outlet
{
type pressureInletOutletVelocity;
value nonuniform 0();
}
cylinder
{
type fixedValue;
value uniform (0 0 0);
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
procBoundary16to15
{
type processor;
value nonuniform List<vector>
139
(
(0.0162217 -0.00483626 -3.84379e-20)
(0.0498091 -0.0136337 1.24013e-20)
(0.0857834 -0.020654 -7.96616e-20)
(0.0857834 -0.020654 -7.96616e-20)
(0.135419 -0.0246274 -8.96734e-20)
(0.178995 -0.0277676 6.52278e-20)
(0.224697 -0.0292409 -3.51882e-20)
(0.272454 -0.0290591 -3.30747e-20)
(0.272454 -0.0290591 -3.30747e-20)
(0.344806 -0.0212117 -4.59962e-20)
(0.398646 -0.0166428 -3.23493e-20)
(0.453912 -0.0105178 -6.71587e-20)
(0.510372 -0.00293398 5.1874e-20)
(0.567751 0.00599118 1.04122e-20)
(0.567751 0.00599118 1.04122e-20)
(0.656755 0.0297747 -8.09891e-21)
(0.715716 0.0421167 -1.20755e-19)
(0.774151 0.0552258 7.22856e-20)
(0.831598 0.0688763 3.29068e-20)
(0.831598 0.0688763 3.29068e-20)
(0.917557 0.101664 -4.85458e-22)
(0.97056 0.11621 2.44352e-20)
(1.02069 0.130354 -1.18532e-19)
(1.06745 0.143835 -3.09828e-20)
(1.11037 0.156414 8.88238e-20)
(1.11037 0.156414 8.88238e-20)
(1.16814 0.187856 6.5563e-20)
(1.19959 0.197381 8.76675e-20)
(1.22577 0.205233 -4.3277e-20)
(1.16814 -0.187856 -6.17562e-20)
(1.19959 -0.197381 -1.29724e-20)
(1.22577 -0.205233 5.56354e-20)
(0.917557 -0.101664 -4.76623e-20)
(0.97056 -0.11621 -3.19005e-20)
(1.02069 -0.130354 7.92635e-20)
(1.06745 -0.143835 8.06422e-20)
(1.11037 -0.156414 1.51287e-21)
(1.11037 -0.156414 1.51287e-21)
(0.597691 -0.0184061 2.91811e-20)
(0.656755 -0.0297747 -6.11075e-20)
(0.715716 -0.0421167 3.39827e-20)
(0.774151 -0.0552258 -6.32512e-20)
(0.831598 -0.0688763 -9.6251e-20)
(0.831598 -0.0688763 -9.6251e-20)
(0.344806 0.0212117 6.71262e-20)
(0.398646 0.0166428 5.52104e-20)
(0.453912 0.0105178 1.27267e-19)
(0.510372 0.00293398 -8.69733e-20)
(0.510372 0.00293398 -8.69733e-20)
(0.135419 0.0246274 6.23993e-20)
(0.178995 0.0277676 -3.87012e-20)
(0.224697 0.0292409 1.10954e-20)
(0.272454 0.0290591 5.52128e-20)
(0.272454 0.0290591 5.52128e-20)
(0.0162217 0.00483626 5.99851e-20)
(0.0498091 0.0136337 -2.16361e-20)
(0.0857834 0.020654 4.21288e-20)
(0.0857834 0.020654 4.21288e-20)
(1.15789 0.0418287 -3.0551e-23)
(1.15587 0.0375801 3.91294e-23)
(1.15406 0.0334141 1.32776e-22)
(1.15245 0.0293207 -1.19714e-22)
(1.15105 0.0252905 5.40403e-23)
(1.14985 0.0213143 -2.68947e-23)
(1.14884 0.0173833 -4.78858e-23)
(1.14804 0.0134885 1.90032e-23)
(1.14742 0.00962081 -2.08945e-23)
(1.147 0.00577024 1.04404e-23)
(1.14679 0.00192915 -1.61946e-23)
(1.25822 0.21791 2.05385e-20)
(1.28451 0.229248 8.01156e-21)
(1.29472 0.231072 -2.55201e-20)
(1.29507 0.227324 5.52735e-21)
(1.28985 0.219883 1.55409e-20)
(1.28192 0.210333 -7.31229e-21)
(1.27304 0.199862 3.39212e-21)
(1.26411 0.189199 -8.47394e-21)
(1.25553 0.17875 4.71842e-21)
(1.24743 0.168716 8.28413e-22)
(1.23981 0.159169 -7.35884e-22)
(1.23264 0.150121 -2.86481e-21)
(1.22588 0.141552 2.48017e-21)
(1.21949 0.133429 -2.5392e-21)
(1.21346 0.12572 4.20871e-22)
(1.20775 0.118391 3.67887e-21)
(1.20236 0.111412 -1.42868e-21)
(1.19727 0.104755 -4.13071e-22)
(1.19246 0.0983943 1.4935e-21)
(1.18794 0.0923049 -5.24545e-22)
(1.18368 0.0864647 -8.58393e-22)
(1.17968 0.0808528 1.67223e-23)
(1.17593 0.0754501 -4.98549e-22)
(1.17243 0.0702385 7.06916e-22)
(1.16915 0.0652014 -1.13638e-22)
(1.16611 0.0603231 8.57861e-23)
(1.16329 0.0555894 -1.27501e-22)
(1.16069 0.0509866 3.35097e-23)
(1.15789 0.0418287 -3.0551e-23)
(1.1583 0.0465021 9.03869e-23)
(1.25822 -0.21791 -2.12726e-20)
(1.28451 -0.229248 -7.97124e-21)
(1.29472 -0.231072 2.46307e-20)
(1.29507 -0.227324 -7.64181e-21)
(1.28985 -0.219883 -1.62369e-20)
(1.28192 -0.210333 7.33696e-21)
(1.27304 -0.199862 -3.94309e-21)
(1.26411 -0.189199 6.38423e-21)
(1.25553 -0.17875 -4.47352e-21)
(1.24743 -0.168716 -1.81215e-21)
(1.23981 -0.159169 1.33155e-21)
(1.23264 -0.150121 2.82776e-21)
(1.22588 -0.141552 -2.44096e-21)
(1.21949 -0.133429 2.30203e-21)
(1.21346 -0.12572 -3.89685e-22)
(1.20775 -0.118391 -3.70229e-21)
(1.20236 -0.111412 1.72754e-21)
(1.19727 -0.104755 5.16074e-22)
(1.19246 -0.0983943 -1.36707e-21)
(1.18794 -0.0923049 -6.76226e-23)
(1.18368 -0.0864647 8.34975e-22)
(1.17968 -0.0808528 -3.367e-22)
(1.17593 -0.0754501 4.18859e-22)
(1.17243 -0.0702385 -9.44238e-22)
(1.16915 -0.0652014 1.00796e-22)
(1.16611 -0.0603231 -2.54998e-22)
(1.16329 -0.0555894 1.1859e-22)
(1.16069 -0.0509866 3.16422e-23)
(1.1583 -0.0465021 -1.1621e-22)
(1.15612 -0.042124 -1.38856e-23)
(1.15415 -0.037841 -3.13215e-24)
(1.15238 -0.0336424 -4.38463e-23)
(1.15081 -0.0295181 -4.59147e-24)
(1.14944 -0.0254584 -1.13527e-23)
(1.14827 -0.021454 2.7561e-25)
(1.14729 -0.0174957 1.45617e-24)
(1.1465 -0.0135747 -1.33761e-24)
(1.1459 -0.00968155 -1.3889e-24)
(1.14549 -0.00580637 -9.23864e-24)
(1.14528 -0.00194051 2.96634e-24)
)
;
}
procBoundary16to17
{
type processor;
value nonuniform List<vector>
146
(
(0.00736226 -0.00377817 -2.26131e-20)
(0.0237321 -0.011176 1.1694e-19)
(0.0489424 -0.0190197 3.89188e-20)
(0.0489424 -0.0190197 3.89188e-20)
(0.0728904 -0.0251027 -2.94232e-22)
(0.0993441 -0.030336 8.31392e-20)
(0.143015 -0.0356267 -9.46957e-21)
(0.143015 -0.0356267 -9.46957e-21)
(0.177157 -0.0387568 -8.02822e-20)
(0.213779 -0.0408091 -6.27164e-20)
(0.276043 -0.0404711 9.75136e-20)
(0.276043 -0.0404711 9.75136e-20)
(0.319941 -0.0395861 -5.0219e-20)
(0.366009 -0.037513 7.84748e-20)
(0.444736 -0.0291086 -5.08062e-20)
(0.444736 -0.0291086 -5.08062e-20)
(0.4966 -0.0236989 5.4471e-20)
(0.549872 -0.0171894 3.26024e-21)
(0.639647 0.000281905 -5.03832e-20)
(0.639647 0.000281905 -5.03832e-20)
(0.695729 0.00978889 -1.63397e-19)
(0.751859 0.0200065 -4.64441e-20)
(0.84339 0.0453115 -8.07089e-20)
(0.84339 0.0453115 -8.07089e-20)
(0.897712 0.0572256 -9.67656e-21)
(0.950168 0.0691434 4.28609e-20)
(1.03119 0.0985611 2.68704e-20)
(1.03119 0.0985611 2.68704e-20)
(1.0763 0.110136 -8.32073e-20)
(1.11739 0.120687 -1.49033e-19)
(1.15378 0.129864 9.7158e-20)
(1.22121 0.166238 -4.42257e-20)
(1.17562 -0.148542 -7.73952e-20)
(1.03119 -0.0985611 3.64512e-21)
(1.0763 -0.110136 -1.11086e-19)
(1.17562 -0.148542 -7.73952e-20)
(1.11739 -0.120687 3.01489e-20)
(0.84339 -0.0453115 6.43734e-20)
(0.897712 -0.0572256 5.40454e-20)
(1.03119 -0.0985611 3.64512e-21)
(0.950168 -0.0691434 -6.02739e-20)
(0.584027 0.0083583 7.13712e-21)
(0.639647 -0.000281904 -3.24872e-20)
(0.695729 -0.00978889 4.49029e-20)
(0.84339 -0.0453115 6.43734e-20)
(0.751859 -0.0200065 1.35244e-19)
(0.394525 0.0333452 -2.93639e-20)
(0.444736 0.0291086 -1.20766e-19)
(0.584027 0.0083583 7.13712e-21)
(0.4966 0.0236989 -1.41831e-19)
(0.234426 0.0401546 -1.70898e-19)
(0.276043 0.0404711 -9.71424e-20)
(0.394525 0.0333452 -2.93639e-20)
(0.319941 0.0395861 2.34369e-20)
(0.143015 0.0356267 1.12216e-19)
(0.234426 0.0401546 -1.70898e-19)
(0.177157 0.0387568 9.58286e-20)
(0.0489424 0.0190197 5.06801e-20)
(0.0728904 0.0251027 -7.04648e-21)
(0.143015 0.0356267 1.12216e-19)
(0.0993441 0.030336 -4.02972e-20)
(0.00736226 0.00377817 2.43968e-20)
(0.0489424 0.0190197 5.06801e-20)
(0.0237321 0.011176 -1.66992e-19)
(1.2996 0.192836 1.41722e-20)
(1.29663 0.189152 -1.56869e-20)
(1.29019 0.182981 3.92513e-22)
(1.2821 0.175408 -2.49107e-21)
(1.27342 0.16719 8.93654e-21)
(1.26475 0.158801 -8.7291e-21)
(1.25635 0.150515 2.46278e-21)
(1.24833 0.142473 1.78267e-21)
(1.24073 0.134736 -6.75308e-22)
(1.23355 0.127322 -8.04118e-21)
(1.22676 0.120228 5.83757e-21)
(1.22036 0.113441 5.96407e-21)
(1.21432 0.106941 -3.58009e-21)
(1.20862 0.100711 3.38168e-22)
(1.20327 0.0947323 9.25056e-22)
(1.19823 0.0889859 -2.28198e-21)
(1.1935 0.083455 -2.25522e-21)
(1.18907 0.0781232 2.09441e-21)
(1.18492 0.072975 7.3935e-22)
(1.18105 0.0679957 -2.58864e-22)
(1.17744 0.0631714 7.69272e-22)
(1.17409 0.058489 5.70373e-22)
(1.17099 0.0539363 2.00666e-22)
(1.16813 0.0495016 -2.73007e-22)
(1.16551 0.0451737 -6.81091e-23)
(1.16312 0.0409422 2.64917e-22)
(1.16096 0.036797 -7.29142e-23)
(1.15902 0.0327287 2.55594e-23)
(1.1573 0.0287281 1.01931e-22)
(1.1558 0.0247863 2.29055e-23)
(1.15452 0.0208948 9.6399e-23)
(1.15344 0.0170452 9.8905e-23)
(1.15257 0.013229 -1.14303e-23)
(1.15192 0.00943749 2.9953e-23)
(1.15147 0.00566078 2.25868e-23)
(1.15124 0.00189415 -5.40481e-23)
(1.22121 0.166238 -4.42257e-20)
(1.26497 0.188292 2.33097e-20)
(1.28817 0.198342 1.19347e-21)
(1.29776 0.20183 1.05533e-20)
(1.29776 0.20183 1.05533e-20)
(1.22121 -0.166238 3.47614e-20)
(1.26497 -0.188292 -2.70008e-20)
(1.28817 -0.198342 -3.54124e-21)
(1.29776 -0.20183 -9.2139e-21)
(1.29843 -0.200112 -4.30672e-21)
(1.2938 -0.19485 8.00036e-21)
(1.28645 -0.187495 7.1102e-21)
(1.27794 -0.17906 -1.32798e-20)
(1.26916 -0.170218 7.5903e-21)
(1.26055 -0.161373 6.1168e-23)
(1.26055 -0.161373 6.1168e-23)
(1.25635 -0.150515 -3.96681e-21)
(1.24833 -0.142473 -1.14996e-22)
(1.24073 -0.134736 -2.67728e-21)
(1.23355 -0.127322 6.93251e-21)
(1.22676 -0.120228 -4.60758e-21)
(1.22036 -0.113441 -3.34475e-21)
(1.21432 -0.106941 4.26756e-21)
(1.20862 -0.100711 -4.34772e-22)
(1.20327 -0.0947323 -1.00749e-21)
(1.19823 -0.0889859 2.20761e-21)
(1.1935 -0.083455 2.70722e-21)
(1.18907 -0.0781232 -2.15481e-21)
(1.18492 -0.072975 -1.10103e-22)
(1.18105 -0.0679957 6.02673e-22)
(1.17744 -0.0631714 -2.61002e-22)
(1.17409 -0.058489 -6.09782e-22)
(1.17099 -0.0539363 4.78771e-23)
(1.16813 -0.0495016 6.39537e-22)
(1.16551 -0.0451737 3.97433e-23)
(1.16312 -0.0409422 -9.36113e-23)
(1.16096 -0.036797 5.01313e-23)
(1.15902 -0.0327287 2.11262e-22)
(1.1573 -0.0287281 2.76727e-23)
(1.1558 -0.0247863 -3.95753e-23)
(1.15452 -0.0208948 7.92678e-23)
(1.15344 -0.0170452 -8.77431e-25)
(1.15257 -0.013229 1.61261e-22)
(1.15192 -0.00943749 -4.21441e-23)
(1.15147 -0.00566078 5.61168e-23)
(1.15124 -0.00189415 4.25734e-23)
)
;
}
}
// ************************************************************************* //
| [
"chaseh13@login4.stampede2.tacc.utexas.edu"
] | chaseh13@login4.stampede2.tacc.utexas.edu | |
3291f7226871babaf8b39d22a1796bc9a0e49ed0 | 03b011fa49f1d8ae4b14cd102931698e1ef74a59 | /src/AM2320-WebGraph/AM2320-WebGraph.ino | 4860c70cacafa44b64ba50f6180ec2f1b4889c5e | [
"MIT"
] | permissive | kzt206/AM2320-WebGraph | 603dbc7ebb692ec36153980b87801115d217a0bf | efddc2907d7bdfcbfc329401415f83c6e234e220 | refs/heads/master | 2022-01-14T17:46:12.306651 | 2019-07-08T01:01:29 | 2019-07-08T01:01:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,974 | ino | #include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WebServer.h>
#include <FS.h>
#include <WebSocketsServer.h>
#include <TimeLib.h>
#include <AM2320.h>
#include <Ticker.h>
/************************************************ PARAMETERS ************************************************/
/* If you use this program as AP, set any ssid name and password. */
const char *ssid = "ESP8266 Access Point";
const char *password = "esp8266-test";
/* If you use this program as ST, set the ssid name and password of your AP.
If you does NOT set following parameter, this program run as AP.*/
const char *myssid = "The ssid name of your AP";
const char *mypassword = "The password of your AP";
#define CPU_MHZ 160 // CPU frequency (MHz)
#define SDA_PIN 4 // Set SDA pin of AM2320.
#define SCL_PIN 5 // Set SCL pin of AM2320.
#define READ_INTERVAL 5 // Set interval time to read sensor (seconds)
/************************************************ SYSTME PARAMETERS ************************************************/
ESP8266WiFiMulti wifiMulti;
ESP8266WebServer server(80);
WebSocketsServer webSocket(81);
AM2320 am2320;
Ticker timer;
bool setUpTimeIsComplete = false;
float thermo_f = 0;
float hygro_f = 0;
uint32_t currentSendInterval;
bool sendCurrentSendInterval(int8_t num = -1);
/************************************************ SETUP ************************************************/
void setup() {
// set serial monitor.
Serial.begin(115200);
delay(10);
Serial.println("\r\n");
// Execute SETUP_FUNCTIONS.
setupWiFi();
setupSPIFFS();
setupWebSocket();
setupServer();
setupTimer();
setupAm2320();
}
/************************************************ LOOP ************************************************/
void loop() {
webSocket.loop();
server.handleClient();
}
/************************************************ SETUP_FUNCTIONS ************************************************/
/* Set up Wi-Fi AP or ST.
Default running is AP mode, but if your Wi-Fi AP is found, this program run as ST mode. */
void setupWiFi() {
Serial.println("[info] Execute setupWiFi() function.");
WiFi.softAP(ssid, password);
wifiMulti.addAP(myssid, mypassword);
// Wait for the Wi-Fi to connect.
Serial.println("[info] Connecting");
while (wifiMulti.run() != WL_CONNECTED && WiFi.softAPgetStationNum() < 1) {
delay(250);
Serial.print('.');
}
Serial.println("\r\n");
// Check AP or ST mode.
if(WiFi.softAPgetStationNum() == 0) {
Serial.println("[info] Run as ST mode.");
Serial.print("[info] Access destination IP address:\t");
Serial.println(WiFi.localIP());
} else {
Serial.println("[info] Run as AP mode.");
Serial.print("[info] Access destination IP address:\t");
Serial.println(WiFi.softAPIP());
}
Serial.println("[info] Wi-Fi setup was complete.");Serial.println("");
}
/* Set up SPI Flash File System (SPIFFS). */
void setupSPIFFS() {
Serial.println("[info] Execute setupSPIFFS() function.");
SPIFFS.begin();
Serial.println("[info] SPIFFS contents:");
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
Serial.printf("\tFile name: %s, size: %s\r\n", fileName.c_str(), formatBytes(fileSize).c_str());
}
Serial.println("[info] SPI Flash File System (SPIFFS) setup was complete.");Serial.println("");
}
/* Set up WebSocket server. */
void setupWebSocket() {
Serial.println("[info] Execute setupWebSocket() function.");
webSocket.begin();
webSocket.onEvent(webSocketEvent); // Register handler.
Serial.println("[info] WebSocket server setup was complete.");Serial.println("");
}
/* Set up WebSocket server. */
void setupServer() {
Serial.println("[info] Execute setupServer() function.");
server.onNotFound(handleRoot); // Register handler.
server.begin();
Serial.println("[info] HTTP server setup was complete.");Serial.println("");
}
/* Set up Timer. */
void setupTimer(){
Serial.println("[info] Execute setupTimer() function.");
setTime(00, 00, 00, 1, 1, 1970);
currentSendInterval = READ_INTERVAL;
timer.attach(currentSendInterval, read_sensor);
Serial.println("[info] Timer setup was complete.");Serial.println("");
}
/* Set up AM2320 sensor. */
void setupAm2320(){
Serial.println("[info] Execute setupAm2320() function.");
delay(50);
am2320.begin(SDA_PIN, SCL_PIN);
Serial.println("[info] AM2320 setup was complete.");Serial.println("");
}
/************************************************ SERVER_HANDLERS ************************************************/
/* If abnormal site access is detected, return to 404 page.
The site access destination is judged true or false in this handler.*/
void handleRoot(){
if(!handleFileRead(server.uri())){
server.send(404, "text/plain", "404: File Not Found");
Serial.println("[warn] Detect abnormal URL access.");
}
}
/* If normal site access is detected, return to requested file. */
bool handleFileRead(String path) {
Serial.println("[info] handleFileRead: " + path);
if (path.endsWith("/")) path += "index.html";
if (existFile(path)) {
String filepath = getFilePath(path);
File file = SPIFFS.open(filepath, "r");
size_t sent = server.streamFile(file, getContentType(path));
file.close();
Serial.println(String("\tSent file: ") + path);
return true;
}
Serial.println(String("\tFile Not Found: ") + path);
return false;
}
/* If WebSocket message is received, execute processing according to the data. */
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
switch (type) {
case WStype_DISCONNECTED:
Serial.printf("[warn] [%u] Disconnected!\n", num);
if(webSocket.connectedClients() <= 0) setUpTimeIsComplete = false;
break;
case WStype_CONNECTED:{
IPAddress ip = webSocket.remoteIP(num);
Serial.printf("[info] [%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
// Send currentSendInterval to client.
sendCurrentSendInterval(num);
}
break;
case WStype_TEXT:{
Serial.printf("[info] [%u] get Text: %s\n", num, payload);
// Set the time only at the first connection.
if (!setUpTimeIsComplete && payload[0]=='C' && payload[1]=='o' && payload[2]=='n' && payload[3]=='n' && payload[4] =='e' && payload[5] =='c' && payload[6] =='t'){
String time_str[6] = {"\0"};
uint32_t time_uint[6];
int32_t index = split((const char *) &payload[8], ',', time_str);
for(int32_t i = 0; i < index; i++){
time_uint[i] = (uint32_t) strtol(time_str[i].c_str(), NULL, 10);
}
setTime(time_uint[3], time_uint[4], time_uint[5] , time_uint[2], time_uint[1], time_uint[0]);
Serial.printf("[info] setTime: %d/%d/%d %d:%d:%d\n", time_uint[0], time_uint[1], time_uint[2], time_uint[3], time_uint[4], time_uint[5] );
setUpTimeIsComplete = true;
}else if(payload[0] == '#'){
currentSendInterval = (uint32_t) strtol((const char *) &payload[1], NULL, 10);
Serial.printf("[info] setIntervalTime: %d\n", currentSendInterval);
timer.detach();
timer.attach(currentSendInterval, read_sensor);
// Send currentSendInterval to connected client.
sendCurrentSendInterval();
}
}
break;
}
}
/************************************************ SENSOR_HANDLERS ************************************************/
void read_sensor (void) {
// Measure temperature and humidity.
if(webSocket.connectedClients() > 0){
if(am2320.measure()){
thermo_f = am2320.getTemperature();
hygro_f = am2320.getHumidity();
// Send measured data to client. (content is JSON type)
String sendData_json = "{ \"time\": \""
+ String(year())
+ '/'
+ String(month())
+ '/'
+ String(day())
+ ' '
+ String(hour())
+ ':'
+ String(minute())
+ ':'
+ String(second())
+ "\", \"thermo\": \""
+ String(thermo_f)
+ "\", \"hygro\": \""
+ String(hygro_f)
+ "\" }";
Serial.print("[info] sendData_json, measured data: ");
Serial.println(sendData_json);
webSocket.broadcastTXT((const char *) sendData_json.c_str());
}else{
int32_t errorCode = am2320.getErrorCode();
switch (errorCode) {
case 1: Serial.println("[err] Sensor is offline"); break;
case 2: Serial.println("[err] CRC validation failed."); break;
default: Serial.println("[err] Unexpected measurement error occurs."); break;
}
}
}
}
/************************************************ HELPER_FUNCTIONS ************************************************/
/* Convert sizes in bytes to KB and MB. */
String formatBytes(size_t bytes) {
if (bytes < 1024) {
return String(bytes) + "B";
} else if (bytes < (1024 * 1024)) {
return String(bytes / 1024.0) + "KB";
} else if (bytes < (1024 * 1024 * 1024)) {
return String(bytes / 1024.0 / 1024.0) + "MB";
}
}
/* Return the filetype from filename. */
String getContentType(String filename) {
if(server.hasArg("download")) return "application/octet-stream";
else if(filename.endsWith(".htm")) return "text/html";
else if(filename.endsWith(".html")) return "text/html";
else if(filename.endsWith(".css")) return "text/css";
else if(filename.endsWith(".js")) return "application/javascript";
else if(filename.endsWith(".png")) return "image/png";
else if(filename.endsWith(".gif")) return "image/gif";
else if(filename.endsWith(".jpg")) return "image/jpeg";
else if(filename.endsWith(".ico")) return "image/x-icon";
else if(filename.endsWith(".xml")) return "text/xml";
else if(filename.endsWith(".pdf")) return "application/x-pdf";
else if(filename.endsWith(".zip")) return "application/x-zip";
else if(filename.endsWith(".gz")) return "application/x-gzip";
return "text/plain";
}
/* Return boolean whether file exists. */
bool existFile(String path) {
String pathWithGz = path + ".gz";
if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) return true;
return false;
}
/* Return the suitable file path.
If compressed file exists, return preferentially its filepath.*/
String getFilePath(String path) {
String pathWithGz = path + ".gz";
if(SPIFFS.exists(pathWithGz)) return pathWithGz;
return path;
}
/* Split string per delimiter. */
int32_t split(String data, char delimiter, String *dst){
int32_t index = 0;
int32_t arraySize = (sizeof(data)/sizeof((data)[0]));
int32_t datalength = data.length();
for (int32_t i = 0; i < datalength; i++) {
char tmp = data.charAt(i);
if ( tmp == delimiter ) {
index++;
if ( index > (arraySize - 1)) return -1;
}
else dst[index] += tmp;
}
return (index + 1);
}
/* Send current interval time to send to WebSocket cliant.
If num is negative or not value, it will broadcast.*/
bool sendCurrentSendInterval(int8_t num){
bool ret = false;
String sendData_json = "{ \"currentSendInterval\": \""
+ String(currentSendInterval)
+ "\" }";
Serial.printf("[info] sendData_json, currentSendInterval[num=%d]: ",num);
Serial.println(sendData_json);
if(num<0){
ret = webSocket.broadcastTXT((const char *) sendData_json.c_str());
}else{
ret = webSocket.sendTXT(num, (const char *) sendData_json.c_str());
}
return ret;
}
| [
"shiguregaki@gmail.com"
] | shiguregaki@gmail.com |
25125577ac9f2ee0778cc12d58930555427e62c4 | 591b536f8a4b434a8358b2e5d05f101cd0e74154 | /pscx_emulator/pscx_disc.h | 222a307b771bd9b5c51380ad342d31f670d5c00a | [] | no_license | oaleshina/pscx_emulator | 67315b7dc275cfe44d20959cbf39377b6a67e9fa | af968ff2c0523fcd91322ef192f7869d4917d882 | refs/heads/master | 2022-09-29T11:17:37.871757 | 2022-04-18T16:26:07 | 2022-04-18T16:26:07 | 147,331,649 | 3 | 3 | null | 2022-04-21T12:37:10 | 2018-09-04T10:52:55 | C | UTF-8 | C++ | false | false | 3,866 | h | #pragma once
#include <fstream>
#include "pscx_minutesecondframe.h"
// Size of a CD sector in bytes.
const size_t SECTOR_SIZE = 2352;
// CD-ROM sector sync pattern: 10 0xff surrounded by two 0x00. Not
// used in CD-DA audio tracks.
const uint8_t SECTOR_SYNC_PATTERN[] = {
0x00,
0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff,
0x00
};
// Disc region coding.
enum Region
{
// Japan (NTSC): SCEI.
REGION_JAPAN,
// North Ametica (NTSC): SCEA.
REGION_NORTH_AMERICA,
// Europe (PAL): SCEE.
REGION_EUROPE
};
// Structure representing a single CD-ROM XA sector.
struct XaSector
{
XaSector();
// Return payload data byte at "index".
uint8_t getDataByte(uint16_t index) const;
enum XaSectorStatus
{
XA_SECTOR_STATUS_OK,
XA_SECTOR_STATUS_INVALID_DATA,
XA_SECTOR_STATUS_INVALID_INPUT
};
struct ResultXaSector
{
ResultXaSector(const XaSector* sector, XaSectorStatus status) :
m_sector(sector),
m_status(status)
{
}
const XaSector* getSectorPtr() const { return m_sector; }
XaSectorStatus getSectorStatus() const { return m_status; }
private:
const XaSector* m_sector;
XaSectorStatus m_status;
};
// Validate CD-ROM XA Mode 1 or 2 sector.
ResultXaSector validateMode1_2(const MinuteSecondFrame& minuteSecondFrame);
// Parse and validate CD-ROM XA mode 2 sector.
// Regular CD-ROM defines mode 2 as just containing 0x920 bytes of
// "raw" data after the 16 byte sector header. However the CD-ROM XA spec
// defines two possible "forms" for this mode 2 data, there's an 8 byte sub-header
// at the beginning of the data that will tell us how to interpret it.
ResultXaSector validateMode2();
// CD-ROM XA Mode 2 Form 1: 0x800 bytes of data protected by a
// 32 bit CRC for error detection and 276 bytes of error correction codes.
ResultXaSector validateMode2Form1() const;
// CD-ROM XA Mode 2 Form 2: 0x914 bytes of data without ECC or EDC.
// Last 4 bytes are reserved for quality control, but the CDi spec doesn't
// mandare what goes in it exactly, only that it is recommended that the same
// EDC algorithm should be used here as is used for the Form 1 sectors. If this
// algorithm is not used, then the reserved bytes are set to 0.
ResultXaSector validateMode2Form2() const;
// Return the MinuteSecondFrame structure in the sector's header.
MinuteSecondFrame getMinuteSecondFrame() const;
// Return the raw sector as a byte slice.
const uint8_t* getRawSectorInBytes() const;
//private:
// The raw array of 2352 bytes contained in the sector.
uint8_t m_raw[SECTOR_SIZE];
};
// Playstation disc
struct Disc
{
Disc(std::ifstream&& file, Region region);
enum DiscStatus
{
DISC_STATUS_OK,
DISC_STATUS_INVALID_PATH,
DISC_STATUS_INVALID_DATA
};
struct ResultDisc
{
ResultDisc(const Disc* disc, DiscStatus status) :
m_disc(disc),
m_status(status)
{
}
const Disc* m_disc;
DiscStatus m_status;
};
// Reify a disc from file at "path" and attempt to identify it.
static ResultDisc initializeFromPath(const std::string& path);
Region getRegion() const;
// Attempt to discover the region of the disc. This way we know
// which string to return in the CD-ROM drive's "get id" command
// and we can decide which BIOS and output video standard to use
// based on the game disk.
ResultDisc extractRegion();
// Read a Mode 1 or 2 CD-ROM XA sector and validate it. The function
// will return an error if used on a CD-DA raw audio sector.
XaSector::ResultXaSector readDataSector(const MinuteSecondFrame& minuteSecondFrame);
// Read a raw CD sector without any validation. For Mode 1 and 2
// sectors XaSector::validateMode1_2 should be called to make sure
// the sector is valid.
XaSector::ResultXaSector readSector(const MinuteSecondFrame& minuteSecondFrame);
private:
// BIN file
std::ifstream m_file;
// Disc region
Region m_region;
};
| [
"oaleshina@nvidia.com"
] | oaleshina@nvidia.com |
c072070230c2dd545b27a5497c1ea9d9c6983896 | dde869518027fe29e5de7d04b7e41321ac5d0ba4 | /cpp/glakkengine/src/Level/Level.cpp | 99bc88efb6bd37a4b7cf4318e56acda22f0e6de0 | [
"MIT"
] | permissive | ekroth/pool | 0b91c81fac58bca6d1ead41ab6c971b7bd44ccd7 | fb7e7602a8bea9b16451a75d23250f0c2b67f0d3 | refs/heads/master | 2021-06-06T09:53:55.253375 | 2016-09-07T23:41:30 | 2016-09-07T23:41:30 | 15,030,906 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,505 | cpp | /* Copyright (c) 2010-2011 Andrée Ekroth
* See the file LICENSE.txt for copying permission.
*/
#include "Level/Level.hpp"
#include "GameTime.hpp"
#include "Graphics/IRenderer.hpp"
#include "Level/LevelItem.hpp"
using namespace kke;
Level::Level (const std::string& name) : name(name), isLoaded(false)
{
}
Level::~Level()
{
UnloadContent();
for (LevelItems::reverse_iterator it = items.rbegin(); it != items.rend()
delete *it;
items.clear();
}
LevelItems& Level::Items()
{
return items;
}
void Level::LoadContent()
{
if (!isLoaded)
{
for (LevelItems::iterator it = items.begin(); it != items.end()
(*it)->LoadContent();
isLoaded = true;
}
}
void Level::UnloadContent()
{
if (isLoaded)
{
for (LevelItems::iterator it = items.begin(); it != items.end()
(*it)->UnloadContent();
isLoaded = false;
}
}
void Level::Update (GameTime& gameTime)
{
for (LevelItems::iterator it = items.begin(); it != items.end()
(*it)->Update(gameTime);
}
void Level::Draw (IRenderer& renderer)
{
for (LevelItems::iterator it = items.begin(); it != items.end()
(*it)->Draw(renderer);
}
bool Level::IsLoaded() const
{
return isLoaded;
}
void Level::SetName (const std::string& name)
{
this->name = name;
}
const std::string& Level::GetName() const
{
return name;
}
void* Level::Copy() const
{
Level* level = new Level(name);
for (LevelItems::const_iterator it = items.begin(); it != items.end()
level->items.push_back((LevelItem*)(*it)->Copy());
return level;
}
| [
"andree.ekroth@gmail.com"
] | andree.ekroth@gmail.com |
e808e91cda6b847d5308cbb040042d6f83b305f4 | c3ab70ef2061557515891efc520794690e3f3c14 | /2661.cpp | f7a3a72ceb79ef42cbf77f422eeef882649aba1b | [] | no_license | maratonandoHard/SBC-ACM-ICPC-2017 | 9b1d8490422160d83b43f18d1d95aebfe65a78f1 | 437df9a35f5bfab289e87a151006386ff9aee1e8 | refs/heads/master | 2021-07-10T03:36:08.317454 | 2017-10-07T20:55:39 | 2017-10-07T20:55:39 | 105,375,726 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 712 | cpp | #include <iostream>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;
set<ll> primos_distintos_da_fatoracao(ll n) {
set<ll> primos_distintos;
while (n % 2 == 0) {
primos_distintos.insert(2);
n /= 2;
}
for (ll i = 3; n != 1 && i <= sqrt(n); i += 2) {
while (n % i == 0) {
primos_distintos.insert(i);
n /= i;
}
}
if (n > 1) primos_distintos.insert(n);
return primos_distintos;
}
int main(){
ll N, resp;
cin >> N;
set<ll> conjunto = primos_distintos_da_fatoracao(N);
resp = pow(2, conjunto.size()) - conjunto.size() - 1;
cout << resp << endl;
return 0;
}
| [
"noreply@github.com"
] | maratonandoHard.noreply@github.com |
610a22d23bcab01521c0e0b6455bbc3e07b72a4b | 060e3b90d7063e532de3d5a747b32c57b099dbb8 | /src/scheduler/include/async_dependency_scheduler/multiqueue/mapping_queue_data.hpp | 2199a2cdfcdd66e889052de5438b4f6dc3c80b33 | [] | no_license | ZePedroResende/TEG-framework | f17540ed6cbdd23604ba5690952e08348a3fbab8 | 31b5e1d3b34b3a6163d4ddeeb35d3b3391e4d87e | refs/heads/master | 2023-03-23T11:12:23.966236 | 2021-03-18T08:58:44 | 2021-03-18T08:58:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,104 | hpp | #include <map>
#include <queue>
#include <vector>
constexpr int empty = -1;
constexpr int terminated = -2;
constexpr int unavailable = -1;
class MappingQueueData {
public:
MappingQueueData(int number_queue, int total) : mapping_queue_data(number_queue, empty), latest(-1), total(total) {
for (int i = 0; i < number_queue; i++) {
available_queue.push(i);
}
}
void finish_data(int data) {
int queue = mapping_data_queue[data];
if (queue != -1 && queue != -2){
mapping_queue_data[queue] = empty;
available_queue.push(queue);
mapping_data_queue[data] = terminated;
}
}
int add_new_data(int data) {
int queue = empty;
if (!available_queue.empty()) {
queue = available_queue.front();
if (queue != empty) {
available_queue.pop();
mapping_data_queue[data] = queue;
mapping_queue_data[queue] = data;
latest = latest > data ? latest : data;
}
}
return queue;
}
bool is_queue_available() { return !available_queue.empty(); }
int queue_for_data(int data) {
int queue = -1;
auto it = mapping_data_queue.find(data);
// adicionei isto do != terminated porque ele encontra o terminated aqui mas agora esta a empancar :/
if (it != mapping_data_queue.end()) {
// element found;
queue = it->second;
}
return queue;
}
int check_if_new_data_index(int data) {
int next_data = data;
int current_data = mapping_data_queue[data];
if (current_data == terminated) {
latest = latest+1 < total && is_queue_available() ? latest + 1 : -1;
next_data = latest;
}
return next_data;
}
private:
// tamanho == numero de queues, o index da queue date o index do data
std::vector<int> mapping_queue_data;
std::map<int, int> mapping_data_queue;
std::queue<int> available_queue;
int latest;
int total;
};
| [
"noreply@github.com"
] | ZePedroResende.noreply@github.com |
66c4959707e157876dabac41ea2f3ce02f0bd690 | 634120df190b6262fccf699ac02538360fd9012d | /Develop/mdk/RealSpace3/TestRS3/main.cpp | c06b29a31517141bbc16c2f5babb6ca58f2c494a | [] | no_license | ktj007/Raiderz_Public | c906830cca5c644be384e68da205ee8abeb31369 | a71421614ef5711740d154c961cbb3ba2a03f266 | refs/heads/master | 2021-06-08T03:37:10.065320 | 2016-11-28T07:50:57 | 2016-11-28T07:50:57 | 74,959,309 | 6 | 4 | null | 2016-11-28T09:53:49 | 2016-11-28T09:53:49 | null | UHC | C++ | false | false | 5,357 | cpp | #include "stdafx.h"
#include <vector>
#include <string>
#include "MFileSystem.h"
#include "MCrashDump.h"
// 디버그 모드에서 실행 할 때 너무 느릴 경우 주석 처리하시면 됩니다.
#include "vld.h"
#pragma comment(lib,"vldmt.lib")
#ifdef _DEBUG
#pragma comment ( lib, "UnitTest++.vsnet2008d_NoException.lib" )
#else
#pragma comment ( lib, "UnitTest++.vsnet2008.lib" )
#endif
//#define _USE_WINDOW
class RRealSpaceUnitTestReporter : public UnitTest::TestReporter
{
private:
public:
RRealSpaceUnitTestReporter()
{
}
virtual ~RRealSpaceUnitTestReporter()
{
}
virtual void ReportTestStart(UnitTest::TestDetails const& test)
{
printf("%s , %s \n{\n", test.suiteName, test.testName);
mlog("%s , %s \n{\n", test.suiteName, test.testName);
}
virtual void ReportFailure(UnitTest::TestDetails const& test, char const* failure)
{
printf("\t %s(%d): error %s in %s\n", test.filename, test.lineNumber, failure, test.testName);
mlog("\t %s(%d): error %s in %s\n", test.filename, test.lineNumber, failure, test.testName);
}
virtual void ReportTestFinish(UnitTest::TestDetails const& test, float secondsElapsed)
{
printf("\t %s Test time : %5.2f sec\n", test.testName, secondsElapsed);
printf("}\n");
mlog("\t %s Test time : %5.2f sec\n", test.testName, secondsElapsed);
mlog("}\n");
}
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
{
printf("Suit Total count : %d, ", totalTestCount);
printf("Suit Failed Test count : %d, ", failedTestCount);
printf("Suit Failure count : %d\n", failureCount);
printf("Suit Test time : %5.2f sec\n", secondsElapsed);
mlog("Suit Total count : %d, ", totalTestCount);
mlog("Suit Failed Test count : %d, ", failedTestCount);
mlog("Suit Failure count : %d\n", failureCount);
mlog("Suit Test time : %5.2f sec\n", secondsElapsed);
}
};
int RunUnitTests(const std::vector< std::string >& _rTestList)
{
RRealSpaceUnitTestReporter reporter;
int failure_count = 0;
for (std::vector< std::string >::const_iterator itr = _rTestList.begin(); itr != _rTestList.end(); ++itr )
{
RUnitTestRunner::GetInstance().InitLog("TestRS3/logs/", itr->c_str() );
failure_count += UnitTest::RunAllTests(reporter, UnitTest::Test::GetTestList(), itr->c_str(), 0);
RUnitTestRunner::GetInstance().FinalizeLog();
}
return failure_count;
}
#ifdef _USE_WINDOW
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Handle messages
switch (message)
{
case WM_SYSCHAR:
case WM_SYSCOMMAND:
break;
case WM_ACTIVATEAPP:
break;
case WM_DESTROY:
break;
case WM_CLOSE:
break;
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
#endif
#ifdef _USE_WINDOW
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
const char* Win32ClassName = "UnitTest";
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = DLGWINDOWEXTRA;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wcex.lpszMenuName = 0;
wcex.lpszClassName = Win32ClassName;
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
DWORD style = WS_POPUP | WS_CAPTION | WS_SYSMENU;
HWND hWnd = CreateWindow( Win32ClassName, "UnitTest Win32",
style, 100, 100, REngine::GetConfig().m_nWidth, REngine::GetConfig().m_nHeight,
NULL, NULL, hInstance, NULL);
ShowWindow(hWnd,SW_SHOW);
UpdateWindow( hWnd );
bool bConsole = false;
#else
int main( int argc, char *argv[] )
{
MCreateFileSystem( MFILEACCESS_GENERIC, "../../EngineRes;../Data");
RUnitTestRunner::GetInstance().InitLog("../logs/", "TestRS3" );
#ifndef _DEBUG
MCrashDump::Init(NULL, NULL, false);
#endif
bool bMakeReferrenceImage = false;
if ( (argc == 2) && _stricmp( argv[1], "/r" ) == 0 )
bMakeReferrenceImage = true;
RUnitTestRunner::GetInstance().Init("TestRS3", "..", "../Results_ScreenShotTest.xml", bMakeReferrenceImage);
//HWND hWnd = GetConsoleWindow();
HWND hWnd = GetDesktopWindow();
bool bConsole = true;
#endif
//bool bGrabScreenShot = false;
bool bGrabScreenShot = true;
std::vector< std::string > aTestList;
aTestList.push_back( "Environment" );
aTestList.push_back( "Map" );
aTestList.push_back( "Actor" );
aTestList.push_back( "Effect" );
aTestList.push_back( "AttachEffect" );
aTestList.push_back( "Shadow" );
aTestList.push_back( "Tree" );
aTestList.push_back( "Water" );
aTestList.push_back( "PostEffect" );
aTestList.push_back( "DECAL" );
aTestList.push_back( "Terrain" );
aTestList.push_back( "ETC" );
REngine::GetConfig().m_nWidth = 800;
REngine::GetConfig().m_nHeight = 600;
REngine::GetConfig().m_bFullScreen = false;
REngine::GetConfig().m_bUsingShader = true;
bool bInitialized = RUnitTestRunner::GetInstance().InitEngine(hWnd, bConsole, bGrabScreenShot);
if(!bInitialized)
{
mlog("Engine Initialize failed\n");
return 1;
}
RUnitTestRunner::GetInstance().FinalizeLog();
int nResult = RunUnitTests(aTestList);
nResult += RUnitTestRunner::GetInstance().GetFailedShotCount();
RUnitTestRunner::GetInstance().HaltEngine();
RUnitTestRunner::GetInstance().Destroy();
return nResult;
}
| [
"espause0703@gmail.com"
] | espause0703@gmail.com |
bdd65c011df54b0f79da0d42524ca6eaefdad354 | 90047daeb462598a924d76ddf4288e832e86417c | /net/tools/quic/quic_server_bin.cc | 6fc25241361953002f831a73146ab0f638c0f8b0 | [
"BSD-3-Clause"
] | permissive | massbrowser/android | 99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080 | a9c4371682c9443d6e1d66005d4db61a24a9617c | refs/heads/master | 2022-11-04T21:15:50.656802 | 2017-06-08T12:31:39 | 2017-06-08T12:31:39 | 93,747,579 | 2 | 2 | BSD-3-Clause | 2022-10-31T10:34:25 | 2017-06-08T12:36:07 | null | UTF-8 | C++ | false | false | 3,204 | cc | // Copyright 2014 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.
//
// A binary wrapper for QuicServer. It listens forever on --port
// (default 6121) until it's killed or ctrl-cd to death.
#include <iostream>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "net/quic/chromium/crypto/proof_source_chromium.h"
#include "net/quic/core/quic_packets.h"
#include "net/quic/platform/api/quic_socket_address.h"
#include "net/tools/quic/quic_http_response_cache.h"
#include "net/tools/quic/quic_server.h"
// The port the quic server will listen on.
int32_t FLAGS_port = 6121;
std::unique_ptr<net::ProofSource> CreateProofSource(
const base::FilePath& cert_path,
const base::FilePath& key_path) {
std::unique_ptr<net::ProofSourceChromium> proof_source(
new net::ProofSourceChromium());
CHECK(proof_source->Initialize(cert_path, key_path, base::FilePath()));
return std::move(proof_source);
}
int main(int argc, char* argv[]) {
base::AtExitManager exit_manager;
base::MessageLoopForIO message_loop;
base::CommandLine::Init(argc, argv);
base::CommandLine* line = base::CommandLine::ForCurrentProcess();
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
CHECK(logging::InitLogging(settings));
if (line->HasSwitch("h") || line->HasSwitch("help")) {
const char* help_str =
"Usage: quic_server [options]\n"
"\n"
"Options:\n"
"-h, --help show this help message and exit\n"
"--port=<port> specify the port to listen on\n"
"--quic_response_cache_dir directory containing response data\n"
" to load\n"
"--certificate_file=<file> path to the certificate chain\n"
"--key_file=<file> path to the pkcs8 private key\n";
std::cout << help_str;
exit(0);
}
net::QuicHttpResponseCache response_cache;
if (line->HasSwitch("quic_response_cache_dir")) {
response_cache.InitializeFromDirectory(
line->GetSwitchValueASCII("quic_response_cache_dir"));
}
if (line->HasSwitch("port")) {
if (!base::StringToInt(line->GetSwitchValueASCII("port"), &FLAGS_port)) {
LOG(ERROR) << "--port must be an integer\n";
return 1;
}
}
if (!line->HasSwitch("certificate_file")) {
LOG(ERROR) << "missing --certificate_file";
return 1;
}
if (!line->HasSwitch("key_file")) {
LOG(ERROR) << "missing --key_file";
return 1;
}
net::QuicConfig config;
net::QuicServer server(
CreateProofSource(line->GetSwitchValuePath("certificate_file"),
line->GetSwitchValuePath("key_file")),
config, net::QuicCryptoServerConfig::ConfigOptions(),
net::AllSupportedVersions(), &response_cache);
int rc = server.CreateUDPSocketAndListen(
net::QuicSocketAddress(net::QuicIpAddress::Any6(), FLAGS_port));
if (rc < 0) {
return 1;
}
while (1) {
server.WaitForEvents();
}
}
| [
"xElvis89x@gmail.com"
] | xElvis89x@gmail.com |
46556d1ec840a903c5c48f6257d0b75ebf380308 | 188fb8ded33ad7a2f52f69975006bb38917437ef | /Fluid/processor4/0.04/U | 8a48b8c9a960a9d6fc3ac74d01314767c0d8e744 | [] | no_license | abarcaortega/Tuto_2 | 34a4721f14725c20471ff2dc8d22b52638b8a2b3 | 4a84c22efbb9cd2eaeda92883343b6910e0941e2 | refs/heads/master | 2020-08-05T16:11:57.674940 | 2019-10-04T09:56:09 | 2019-10-04T09:56:09 | 212,573,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,680 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0.04";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
465
(
(4.89988 0 0.209894)
(4.39688 0 0.230326)
(3.86438 8.24254e-22 0.250932)
(3.30535 1.22862e-22 0.271102)
(2.72398 1.04181e-21 0.29012)
(2.12565 0 0.307191)
(1.51679 -9.15913e-21 0.321483)
(0.904631 9.45748e-21 0.332079)
(0.347743 0 0.334991)
(5.02769 1.68167e-21 0.594474)
(4.51624 1.77285e-21 0.646994)
(3.97363 -2.56685e-21 0.698651)
(3.40273 7.496e-22 0.747754)
(2.80765 -2.05604e-21 0.792457)
(2.19378 4.35041e-21 0.830904)
(1.56754 -4.48823e-21 0.86137)
(0.935214 0 0.882309)
(0.356617 -7.54078e-20 0.877673)
(5.09559 -2.49383e-21 0.99689)
(4.58521 -1.31616e-21 1.08641)
(4.04158 1.42526e-21 1.17473)
(3.46708 -3.00497e-23 1.25888)
(2.86556 2.03165e-21 1.33554)
(2.24235 2.12721e-21 1.40129)
(1.60422 -2.23887e-21 1.45296)
(0.957571 1.72902e-21 1.48821)
(0.366106 -1.14619e-20 1.48732)
(5.18407 0 1.39577)
(4.67611 0 1.52401)
(4.13211 3.62189e-21 1.65143)
(3.55377 0 1.77378)
(2.94442 -2.01382e-21 1.88615)
(2.30917 -1.07496e-21 1.98336)
(1.65509 1.09005e-21 2.06044)
(0.988083 0 2.11353)
(0.377817 -1.18202e-21 2.11408)
(5.3026 0 1.79091)
(4.79864 0 1.95999)
(4.25501 -4.49557e-21 2.12944)
(3.6724 -3.74413e-21 2.29371)
(3.05325 -2.93209e-21 2.44616)
(2.4022 -2.0699e-21 2.57949)
(1.72656 -5.40352e-22 2.68639)
(1.03166 -4.38249e-24 2.76087)
(0.39493 1.75151e-21 2.7655)
(5.45401 0 2.18079)
(4.9565 0 2.39345)
(4.41488 0 2.60884)
(3.82834 1.09508e-20 2.82016)
(3.19793 3.86857e-21 3.01888)
(2.52726 0 3.19511)
(1.82369 2.08063e-21 3.33836)
(1.09189 1.3532e-23 3.43949)
(0.419121 -1.13534e-21 3.45099)
(5.64047 -7.41474e-23 2.56283)
(5.15299 -7.47905e-23 2.82221)
(4.61632 -3.35575e-21 3.08831)
(4.0275 -7.18942e-21 3.35325)
(3.38538 0 3.60655)
(2.6917 0 3.83521)
(1.9532 -2.05741e-21 4.02448)
(1.17318 1.0726e-21 4.16042)
(0.452048 0 4.18309)
(5.86414 0 2.93357)
(5.39173 0 3.24295)
(4.86471 3.33101e-21 3.56517)
(4.27722 6.87845e-21 3.89172)
(3.62477 -3.56526e-21 4.21033)
(2.90578 3.61397e-21 4.50454)
(2.12508 3.90235e-21 4.75395)
(1.28318 4.11753e-21 4.9374)
(0.497355 -8.53976e-21 4.97885)
(6.12709 0 3.2884)
(5.67655 -2.90032e-21 3.6508)
(5.16626 -3.1312e-21 4.03483)
(4.58659 0 4.43221)
(3.9282 6.94291e-21 4.82959)
(3.18394 -7.20091e-21 5.20711)
(2.35417 -7.45162e-21 5.53732)
(1.43367 -3.93367e-21 5.78818)
(0.560805 4.07342e-21 5.86036)
(6.43087 0 3.62139)
(6.01114 5.9069e-21 4.03897)
(5.52775 0 4.49008)
(4.96649 0 4.96816)
(4.31139 0 5.46043)
(3.54649 0 5.9448)
(2.66302 0 6.38619)
(1.64322 0 6.73712)
(0.651632 7.72179e-21 6.86264)
(6.77611 2.65459e-21 3.92521)
(6.39839 0 4.39834)
(5.95578 0 4.92021)
(5.42913 -5.9415e-21 5.48821)
(4.79419 4.00689e-22 6.0932)
(4.02199 -6.27769e-21 6.71446)
(3.08697 -5.94713e-21 7.31138)
(1.94564 -1.35875e-20 7.81721)
(0.789213 -4.34175e-23 8.04125)
(7.1617 -2.62987e-21 4.19114)
(6.83934 1.0477e-20 4.71726)
(6.45548 -1.05724e-20 5.31017)
(5.98678 -5.50205e-21 5.97415)
(5.40018 1.72353e-20 6.70867)
(4.64959 0 7.50197)
(3.68153 1.27578e-21 8.31717)
(2.40097 -1.11554e-20 9.07177)
(1.01232 -5.34119e-21 9.48839)
(7.584 2.36533e-21 4.40949)
(7.33171 -4.92262e-21 4.98175)
(7.02822 7.57288e-21 5.64012)
(6.64875 0 6.39889)
(6.15401 -1.0002e-20 7.27262)
(5.48036 1.01773e-20 8.27146)
(4.5345 2.87797e-20 9.38607)
(3.12267 -6.4808e-21 10.5517)
(1.40592 1.1336e-20 11.3903)
(8.0359 -4.60976e-21 4.57041)
(7.86812 9.18985e-21 5.17642)
(7.66821 -6.47496e-21 5.88607)
(7.4156 5.41746e-22 6.72539)
(7.07359 0 7.72974)
(6.57233 -8.09781e-21 8.94709)
(5.78312 -9.36163e-21 10.4388)
(4.34867 1.67024e-20 12.2726)
(2.20152 0 14.1634)
(8.50616 -7.96009e-23 4.66572)
(8.43418 1.97568e-21 5.28727)
(8.35812 -4.5836e-21 6.02365)
(8.26968 -5.35527e-22 6.91076)
(8.15146 7.11703e-21 8.0039)
(7.96314 -7.16327e-21 9.39444)
(7.61559 0 11.2507)
(6.63342 5.78348e-22 13.989)
(3.98791 -1.73465e-20 19.0852)
(0.0516526 -6.53077e-21 -0.04887)
(0.107886 6.37543e-21 -0.0612959)
(0.219211 0 -0.0803712)
(0.384377 0 -0.106501)
(0.615952 6.27309e-22 -0.136472)
(0.921603 -6.09855e-22 -0.16633)
(1.30057 5.27146e-22 -0.192359)
(1.7443 0 -0.211851)
(2.23869 0 -0.223443)
(2.76673 0 -0.227049)
(0.0438437 -8.42076e-22 -0.0821187)
(0.0874429 -4.04803e-22 -0.124353)
(0.189783 -2.98e-21 -0.184465)
(0.350783 4.94684e-21 -0.265394)
(0.58529 -2.6877e-21 -0.357526)
(0.90081 0 -0.44894)
(1.29504 -5.24474e-22 -0.528674)
(1.75718 -9.29341e-22 -0.588996)
(2.27087 4.9986e-23 -0.626214)
(2.8174 8.8983e-23 -0.640282)
(0.0217943 4.21974e-21 -0.107998)
(0.0268303 -3.09878e-21 -0.183418)
(0.0981226 7.88977e-22 -0.292279)
(0.240045 7.08674e-21 -0.438296)
(0.470507 -5.47077e-21 -0.603168)
(0.796303 -4.59161e-21 -0.764924)
(1.21145 3.37764e-21 -0.903829)
(1.70003 9.2428e-22 -1.0068)
(2.24094 -2.41319e-21 -1.06834)
(2.81197 -6.8774e-22 -1.08939)
(-0.0143691 -4.5001e-22 -0.0812004)
(-0.0740035 4.24417e-22 -0.197197)
(-0.0532048 4.67379e-21 -0.367948)
(0.0582639 -6.84117e-21 -0.596493)
(0.284177 0 -0.850882)
(0.629418 -4.68598e-21 -1.09669)
(1.08081 5.60732e-21 -1.30273)
(1.61325 -1.90135e-21 -1.45044)
(2.19779 -3.05309e-21 -1.53406)
(2.80702 3.62318e-21 -1.5574)
(-0.0703891 4.50011e-22 0.0306179)
(-0.228741 -2.16041e-22 -0.139832)
(-0.283453 6.49276e-21 -0.393699)
(-0.217037 -6.35563e-21 -0.733814)
(0.00693933 -5.45173e-21 -1.10804)
(0.387007 7.51105e-21 -1.45903)
(0.89701 -4.66355e-21 -1.74395)
(1.49645 1.89038e-21 -1.93861)
(2.14464 3.02059e-21 -2.03985)
(2.80742 -2.95823e-21 -2.05766)
(-0.155478 0 0.272089)
(-0.459522 0 0.0237797)
(-0.622148 -1.2885e-20 -0.345867)
(-0.618541 1.3325e-20 -0.842413)
(-0.392314 -1.13661e-20 -1.38072)
(0.0522434 2.36234e-20 -1.87371)
(0.653889 -1.39947e-20 -2.25025)
(1.35118 1.85236e-22 -2.49147)
(2.08751 -1.44512e-21 -2.60111)
(2.82084 2.98491e-21 -2.60057)
(-0.284491 8.50655e-21 0.707806)
(-0.799488 1.67026e-20 0.344588)
(-1.10851 -5.75965e-22 -0.1937)
(-1.18847 -8.08668e-22 -0.915638)
(-0.943197 -1.29212e-20 -1.68762)
(-0.395641 0 -2.36897)
(0.353767 -8.96721e-21 -2.85664)
(1.18559 1.63521e-20 -3.13555)
(2.03818 -3.62896e-21 -3.23624)
(2.85952 0 -3.19734)
(-0.480081 -2.64658e-22 1.4219)
(-1.28527 -1.02203e-21 0.887001)
(-1.77875 1.58513e-20 0.0950611)
(-1.95308 -1.52396e-20 -0.954502)
(-1.64859 7.02075e-21 -2.06566)
(-0.943478 1.10366e-20 -2.9949)
(0.0188474 -1.07283e-20 -3.60869)
(1.02608 0 -3.90321)
(2.01994 -3.4983e-21 -3.96476)
(2.94323 0 -3.85802)
(-0.771996 -3.79148e-20 2.51331)
(-1.92695 3.65955e-20 1.71285)
(-2.62596 -3.60314e-20 0.537106)
(-2.84714 0 -0.997211)
(-2.41284 -1.46664e-20 -2.5833)
(-1.48855 0 -3.82139)
(-0.276281 9.87835e-21 -4.5529)
(0.934224 -1.76077e-20 -4.82431)
(2.07738 1.48197e-20 -4.80111)
(3.10384 -5.45846e-21 -4.58742)
(-1.15618 0 4.0478)
(-2.62647 -5.48939e-21 2.82681)
(-3.47535 0 1.06552)
(-3.61145 0 -1.15638)
(-2.96434 2.52245e-20 -3.33113)
(-1.79791 1.48437e-20 -4.89799)
(-0.362628 6.07912e-21 -5.70817)
(1.01887 0 -5.90122)
(2.28466 -7.26608e-21 -5.74085)
(3.38915 4.27563e-21 -5.37722)
(-1.50999 -6.13824e-21 5.94008)
(-3.09162 -7.12512e-21 4.06104)
(-3.91497 0 1.47429)
(-3.77079 0 -1.58138)
(-2.88271 -1.73642e-20 -4.34938)
(-1.54433 -3.13294e-20 -6.19004)
(-0.00957026 -1.26097e-21 -7.01424)
(1.42868 -1.09743e-20 -7.08154)
(2.74049 7.47379e-21 -6.74487)
(3.86025 -2.88437e-21 -6.19672)
(-1.61955 1.97092e-20 7.8333)
(-2.95689 -1.23718e-19 5.08557)
(-3.42047 5.51435e-20 1.52466)
(-2.80281 5.24501e-20 -2.32974)
(-1.77273 -2.00511e-20 -5.56395)
(-0.437428 3.58782e-20 -7.55552)
(0.973401 1.86582e-20 -8.32222)
(2.31711 -1.17184e-20 -8.25683)
(3.54469 -5.69131e-21 -7.73302)
(4.57797 4.02598e-21 -6.98743)
(-1.37885 1.66051e-20 9.26953)
(-2.04591 -6.61147e-20 5.76168)
(-1.49093 6.49502e-20 1.31019)
(-0.420325 0 -3.22749)
(0.558282 -2.60857e-20 -6.81497)
(1.59861 -8.59686e-21 -8.74161)
(2.70521 1.45564e-20 -9.45464)
(3.78616 -6.13604e-21 -9.2827)
(4.7627 1.90276e-21 -8.59122)
(5.57949 -1.27954e-21 -7.66595)
(-0.827309 -3.03504e-20 10.2978)
(0.266546 5.03823e-20 5.44698)
(2.08947 -1.80877e-20 0.593675)
(3.12893 3.77603e-21 -4.02115)
(3.83469 1.84309e-20 -7.53912)
(4.52805 -1.6033e-21 -9.56328)
(5.20172 5.13027e-21 -10.2581)
(5.82739 1.97035e-21 -10.0027)
(6.38373 -2.25841e-21 -9.18993)
(6.84959 6.97165e-22 -8.13647)
(0.563375 -7.61585e-19 8.37789)
(3.63679 -2.68567e-19 3.79009)
(6.16929 0 -0.409352)
(7.35061 0 -4.75853)
(7.88206 0 -8.10885)
(8.14982 0 -9.99838)
(8.25184 -8.80464e-22 -10.6002)
(8.274 4.37366e-23 -10.28)
(8.28134 -1.52023e-21 -9.41355)
(8.29611 -6.86014e-22 -8.31298)
(8.99557 -4.54065e-23 4.68919)
(9.02765 1.46297e-21 5.30235)
(9.09047 5.64638e-21 6.02999)
(9.19571 -1.79634e-21 6.9101)
(9.36433 0 8.00308)
(9.64204 1.81439e-21 9.41157)
(10.2131 -8.74996e-21 11.3175)
(11.8806 -5.33878e-22 14.0369)
(13.6307 3.28572e-19 18.6385)
(9.47873 0 4.63487)
(9.61103 -1.21457e-20 5.21228)
(9.80696 -7.95192e-21 5.88881)
(10.0963 0 6.69239)
(10.5322 -9.39825e-21 7.66225)
(11.2086 0 8.85146)
(12.2617 7.24877e-21 10.3198)
(14.1651 8.58115e-21 11.994)
(16.465 -2.2536e-19 13.2269)
(9.93474 7.10517e-21 4.50581)
(10.1511 4.65058e-22 5.02297)
(10.4518 6.2757e-21 5.61211)
(10.8707 -3.20389e-22 6.28371)
(11.4586 9.31787e-21 7.0446)
(12.2873 -5.61184e-21 7.88636)
(13.4137 1.60051e-22 8.76518)
(15.0208 -1.22845e-20 9.56871)
(17.3434 2.29437e-20 9.87582)
(10.346 -6.12864e-21 4.31273)
(10.6226 4.0141e-22 4.75408)
(10.9891 -3.06705e-22 5.23719)
(11.4738 8.34134e-22 5.7581)
(12.1128 -5.28562e-22 6.30361)
(12.9523 5.51317e-21 6.84341)
(14.0328 -1.10003e-22 7.32183)
(15.4288 1.10094e-22 7.67778)
(17.4715 -2.45494e-21 7.71765)
(11.0143 2.57432e-22 4.43215)
(11.4122 4.04661e-21 4.80863)
(11.9159 7.7455e-21 5.18961)
(12.5492 7.70677e-21 5.55525)
(13.3393 4.03085e-21 5.87365)
(14.3107 9.60341e-22 6.09479)
(15.4728 0 6.15585)
(17.011 3.83404e-21 5.93522)
(12.2209 -6.06558e-21 4.62326)
(12.814 -4.35747e-21 4.84686)
(13.5199 -4.90924e-21 5.00229)
(14.3433 1.10651e-21 5.04703)
(15.2659 -1.02502e-22 4.92651)
(16.3759 -2.22609e-21 4.57765)
(13.554 -9.95739e-22 4.24129)
(14.2305 -2.23199e-21 4.17781)
(14.9518 8.6974e-22 3.97474)
(15.7603 5.06374e-22 3.60457)
(14.6053 -4.57327e-22 3.24126)
(15.202 -1.16956e-22 2.88927)
(17.3309 -2.34434e-19 15.8283)
(14.8505 -2.8356e-19 12.522)
(9.5035 2.63795e-18 9.6517)
(18.0366 1.98848e-20 10.7238)
(18.2193 0 8.16436)
(17.5518 -1.12853e-19 6.40843)
(18.7793 -7.25409e-21 9.12199)
(19.8455 -2.05676e-20 8.02906)
(20.378 -3.61684e-20 6.92073)
(18.6524 -1.01503e-21 7.34591)
(19.6325 -1.34176e-21 6.66929)
(20.276 1.56064e-20 5.7989)
(17.8613 1.02192e-21 5.58557)
(18.6072 1.35193e-21 5.05088)
(19.1628 -3.69777e-21 4.38541)
(16.9775 1.44302e-21 4.27109)
(17.5171 1.38215e-21 3.85778)
(17.9337 -2.75307e-21 3.36322)
(16.1882 -6.4849e-22 3.34057)
(16.5689 8.69221e-22 3.01008)
(16.8632 -1.75464e-21 2.62717)
(15.5106 2.2279e-22 2.66149)
(15.7821 -2.86589e-22 2.39071)
(15.9914 3.43845e-22 2.08629)
(15.1329 0 1.93036)
(15.2853 2.20325e-23 1.68499)
(3.76837 1.89722e-19 6.47277)
(7.61191 1.24008e-20 2.66724)
(11.0757 -1.83963e-19 -1.78702)
(12.2838 -1.09411e-19 -5.66325)
(12.3954 -1.96963e-20 -8.40875)
(12.0381 1.90402e-20 -9.92686)
(11.4424 -1.16135e-20 -10.3741)
(10.7891 0 -10.0276)
(10.207 1.70605e-21 -9.1952)
(16.5274 -2.14707e-19 4.60203)
(18.0587 1.12488e-19 1.46994)
(18.7309 5.92609e-20 -2.23933)
(18.144 4.89742e-20 -5.48004)
(17.0137 -6.91245e-20 -7.76127)
(15.6733 1.20678e-20 -9.04073)
(14.2855 -7.78649e-22 -9.44999)
(12.9937 0 -9.19655)
(11.901 -4.22804e-21 -8.52009)
(20.9525 5.10955e-20 4.61836)
(21.5723 2.2514e-20 1.55068)
(21.3969 0 -1.69598)
(20.4628 2.18189e-20 -4.42133)
(19.0741 4.41284e-20 -6.36818)
(17.4643 0 -7.53904)
(15.8234 0 -8.02275)
(14.3052 -6.01766e-21 -7.961)
(13.0098 5.3992e-21 -7.52821)
(21.0399 -1.15354e-20 3.59945)
(21.3703 2.1173e-20 1.02548)
(21.1696 2.31023e-23 -1.46414)
(20.4049 3.00151e-20 -3.54085)
(19.1997 0 -5.09054)
(17.7486 -1.45167e-20 -6.09931)
(16.2406 9.08717e-21 -6.60702)
(14.8193 -2.01898e-21 -6.69733)
(13.5757 0 -6.48219)
(19.8607 -3.7234e-20 2.69393)
(20.1373 8.28167e-21 0.845416)
(20.0049 0 -0.945576)
(19.4228 -2.63684e-20 -2.53568)
(18.4709 -5.01068e-21 -3.81868)
(17.3029 1.44521e-20 -4.73802)
(16.0668 -1.26278e-21 -5.29119)
(14.8735 4.87942e-21 -5.51886)
(13.796 0 -5.48855)
(18.4699 -3.56122e-21 2.12976)
(18.6856 1.11348e-20 0.77949)
(18.6024 1.76362e-22 -0.579806)
(18.1954 2.71406e-21 -1.8428)
(17.5089 7.0841e-21 -2.90957)
(16.6406 0 -3.7212)
(15.6901 -4.69732e-21 -4.26354)
(14.7384 0 -4.55544)
(13.8444 2.68353e-21 -4.63682)
(17.2473 5.68399e-21 1.70342)
(17.4155 4.99332e-21 0.687264)
(17.379 1.03357e-21 -0.353784)
(17.1127 -3.74416e-21 -1.34542)
(16.6324 1.86248e-21 -2.2151)
(15.9967 0 -2.91442)
(15.2731 0 -3.42287)
(14.5215 0 -3.7431)
(13.7896 -1.53984e-21 -3.89511)
(16.268 -1.33218e-21 1.37627)
(16.4005 5.53566e-22 0.598652)
(16.3913 -1.24331e-21 -0.206841)
(16.216 1.21213e-21 -0.991936)
(15.877 -2.1881e-21 -1.70402)
(15.4096 -1.22276e-21 -2.30237)
(14.8591 -1.93494e-21 -2.76433)
(14.2683 -7.41585e-22 -3.08462)
(13.6741 1.64157e-21 -3.27209)
(15.4882 -4.56247e-22 1.12723)
(15.5916 -1.18641e-21 0.519638)
(15.5946 1.58732e-22 -0.114023)
(15.4765 4.77037e-22 -0.741339)
(15.234 -8.94996e-23 -1.32416)
(14.8878 0 -1.83038)
(14.4674 1.98863e-21 -2.23962)
(14.003 1.81312e-21 -2.54372)
(13.5221 -2.83091e-21 -2.74497)
(14.9371 8.81474e-23 0.451162)
(14.945 2.99441e-22 -0.0542036)
(14.8634 0 -0.559523)
(14.6871 1.39607e-21 -1.03764)
(14.428 0 -1.46417)
(14.1051 9.18538e-22 -1.82196)
(13.7394 0 -2.10216)
(13.3511 1.68076e-21 -2.3034)
(14.221 3.02883e-22 -0.818971)
(14.025 -6.7656e-23 -1.17791)
(13.7755 -3.86952e-22 -1.48801)
(13.4866 0 -1.74097)
(13.1733 0 -1.93374)
(13.4787 -4.12707e-22 -1.21967)
(13.2497 0 -1.445)
(12.9965 2.672e-22 -1.62466)
(12.826 -2.21882e-22 -1.36611)
)
;
boundaryField
{
inlet
{
type fixedValue;
value nonuniform 0();
}
outlet
{
type zeroGradient;
}
flap
{
type movingWallVelocity;
value nonuniform List<vector>
33
(
(-1.43424e-16 0 -6.93593e-15)
(2.91743e-19 -2.93641e-34 -4.49921e-17)
(3.87918e-21 -2.77556e-14 5.18818e-18)
(0 0 0)
(0 0 0)
(-4.15418e-18 -2.77556e-14 -5.55101e-14)
(1.54692e-17 2.77556e-14 -5.55131e-14)
(5.85274e-22 -1.83652e-35 -2.01523e-18)
(0 0 0)
(0 0 0)
(0 0 0)
(6.21806e-17 -2.77556e-14 -1.11022e-13)
(0 0 0)
(4.30421e-20 0 -1.72819e-17)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(0 0 0)
(4.79768e-17 0 -1.39016e-14)
(-2.92846e-17 0 -2.77555e-14)
(-1.83944e-22 0 -1.12976e-18)
(-3.67965e-21 0 -5.05299e-18)
(-8.87746e-21 -2.77556e-14 -7.84855e-18)
(-1.76058e-21 -3.67317e-35 -3.49521e-18)
(-1.85602e-20 0 -1.13484e-17)
(-2.25943e-16 -2.77556e-14 -1.11022e-13)
(-1.53995e-20 2.77556e-14 -1.03371e-17)
(-1.09888e-19 -2.77556e-14 -2.76132e-17)
(-5.62937e-16 0 -1.11019e-13)
(0 -2.77556e-14 0)
(5.2832e-15 -2.77556e-14 2.21919e-13)
(4.14975e-15 -2.77556e-14 -1.10867e-13)
)
;
}
upperWall
{
type noSlip;
}
lowerWall
{
type noSlip;
}
frontAndBack
{
type empty;
}
procBoundary4to1
{
type processor;
value nonuniform List<vector>
30
(
(10.7016 4.97043e-24 4.07156)
(10.7016 4.97043e-24 4.07156)
(11.326 -5.20065e-21 4.08189)
(11.7293 1.29109e-21 4.36131)
(11.7293 1.29109e-21 4.36131)
(12.4123 8.22436e-22 4.08401)
(12.9457 5.27041e-21 4.19979)
(12.9457 5.27041e-21 4.19979)
(13.4948 0 3.59403)
(14.0433 -1.6781e-21 3.47232)
(14.0433 -1.6781e-21 3.47232)
(14.2601 4.00568e-22 2.66832)
(14.7071 -2.44306e-23 2.34823)
(14.9344 -1.4691e-25 2.15353)
(14.9344 -1.4691e-25 2.15353)
(14.5919 3.19477e-23 1.58131)
(14.7053 -2.26541e-23 1.38103)
(14.8568 3.13582e-23 0.934568)
(14.8568 3.13582e-23 0.934568)
(14.3998 8.66652e-23 0.393578)
(14.4091 -2.96905e-22 -0.014392)
(14.3513 1.71637e-22 -0.425028)
(14.3513 1.71637e-22 -0.425028)
(13.8228 5.03605e-24 -0.650029)
(13.6729 1.71153e-22 -0.952271)
(13.6729 1.71153e-22 -0.952271)
(13.2133 9.19203e-23 -1.00284)
(13.031 6.57469e-23 -1.20177)
(13.031 6.57469e-23 -1.20177)
(12.6648 -6.46957e-23 -1.14953)
)
;
}
procBoundary4to2
{
type processor;
value nonuniform List<vector>
11
(
(11.9754 -8.8045e-22 -6.89306)
(12.55 -7.73417e-22 -6.07645)
(12.8727 0 -5.27707)
(13.0458 -2.03969e-21 -4.55775)
(13.1115 3.30729e-21 -3.90952)
(13.105 0 -3.34499)
(13.0482 -5.02575e-22 -2.85319)
(12.9587 1.54673e-21 -2.43016)
(12.8493 3.22317e-22 -2.06761)
(12.7295 2.74663e-22 -1.75811)
(12.606 -1.96676e-22 -1.49439)
)
;
}
procBoundary4to3
{
type processor;
value nonuniform List<vector>
19
(
(5.37154 -8.04682e-22 0.190115)
(5.50637 2.39374e-21 0.542539)
(5.57155 -5.53715e-21 0.908665)
(5.65556 4.67223e-21 1.27015)
(5.76749 -3.04966e-21 1.62653)
(5.90941 -4.42673e-21 1.97593)
(6.08259 8.91e-21 2.31568)
(6.28811 -5.66029e-21 2.64247)
(6.52676 5.62212e-21 2.9522)
(6.79879 -2.64126e-21 3.23992)
(7.10351 5.22584e-21 3.49991)
(7.43884 -1.24611e-21 3.72576)
(7.80088 -3.55742e-21 3.9108)
(8.18346 -4.48892e-21 4.04867)
(8.57794 2.13518e-21 4.13452)
(8.98673 1.86157e-21 4.16521)
(9.39193 -8.86761e-21 4.13668)
(9.77981 7.6235e-21 4.05048)
(10.1379 0 3.9126)
)
;
}
procBoundary4to5
{
type processor;
value nonuniform List<vector>
18
(
(3.31101 1.36476e-22 -0.223529)
(3.37828 -6.24334e-22 -0.633756)
(3.39272 -5.81268e-22 -1.07517)
(3.4179 2.98292e-21 -1.52993)
(3.45905 -1.15156e-21 -2.00824)
(3.52367 -1.15501e-21 -2.51619)
(3.62259 2.29794e-21 -3.05956)
(3.77131 -2.29191e-21 -3.64205)
(3.99189 -2.33293e-21 -4.26271)
(4.31432 -4.34879e-21 -4.91159)
(4.77456 1.12609e-21 -5.5644)
(5.40654 3.54723e-21 -6.1792)
(6.22756 -2.24286e-21 -6.69805)
(7.22046 -1.05229e-21 -7.0554)
(8.31994 1.03952e-21 -7.1933)
(9.74838 0 -8.14856)
(9.74838 0 -8.14856)
(11.0454 1.2875e-21 -7.64151)
)
;
}
}
// ************************************************************************* //
| [
"aldo.abarca.ortega@gmail.com"
] | aldo.abarca.ortega@gmail.com | |
97dd62fd08d23cd835da75c47bea75ac672544ef | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_patch_hunk_2315.cpp | df3b1c46c04f8092ee1b5e018c7f19c3a5f75c24 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 483 | cpp | lock = lock_ref_sha1_basic(newrefname, NULL, NULL, NULL, 0, NULL, &err);
if (!lock) {
error("unable to rename '%s' to '%s': %s", oldrefname, newrefname, err.buf);
strbuf_release(&err);
goto rollback;
}
- hashcpy(lock->old_sha1, orig_sha1);
+ hashcpy(lock->old_oid.hash, orig_sha1);
if (write_ref_to_lockfile(lock, orig_sha1) ||
commit_ref_update(lock, orig_sha1, logmsg)) {
error("unable to write current sha1 into %s", newrefname);
goto rollback;
}
| [
"993273596@qq.com"
] | 993273596@qq.com |
d39b53288eeb6b7ff54a64e81e2d36c403d87868 | 66f382479a46b3c3f5fe614a52baa5ef52951cec | /DuiLib/Control/UIGifAnim.h | 58f48fc65a4f0726a6b1a675ca22c2905e38d070 | [
"MIT"
] | permissive | fawdlstty/DuiLib_Faw | 80005af6b1e328818f66cdad47c06108c9ec2137 | f16f9913f027555640ec17eeb077c5be446681ae | refs/heads/master | 2023-08-22T22:51:58.377968 | 2023-05-03T13:13:51 | 2023-05-03T13:13:51 | 152,514,855 | 95 | 29 | NOASSERTION | 2023-08-06T15:09:06 | 2018-10-11T01:50:39 | C++ | UTF-8 | C++ | false | false | 1,658 | h | #ifndef GifAnimUI_h__
#define GifAnimUI_h__
#pragma once
namespace DuiLib {
class UILIB_API CGifAnimUI: public CControlUI {
enum {
EVENT_TIEM_ID = 100,
};
DECLARE_DUICONTROL (CGifAnimUI)
public:
CGifAnimUI (void);
virtual ~CGifAnimUI (void);
faw::string_t GetClass () const;
LPVOID GetInterface (faw::string_t pstrName);
void DoInit () override;
bool DoPaint (HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
void DoEvent (TEventUI& event);
void SetVisible (bool bVisible = true);
void SetAttribute (faw::string_t pstrName, faw::string_t pstrValue);
void SetBkImage (faw::string_t pStrImage);
faw::string_t GetBkImage ();
void SetAutoPlay (bool bIsAuto = true);
bool IsAutoPlay () const;
void SetAutoSize (bool bIsAuto = true);
bool IsAutoSize () const;
void PlayGif ();
void PauseGif ();
void StopGif ();
private:
void InitGifImage ();
void DeleteGif ();
void OnTimer (UINT_PTR idEvent);
void DrawFrame (HDC hDC); // 绘制GIF每帧
Gdiplus::Image* LoadGifFromFile (faw::string_t pstrGifPath);
Gdiplus::Image* LoadGifFromMemory (LPVOID pBuf, size_t dwSize);
private:
Gdiplus::Image *m_pGifImage = nullptr;
UINT m_nFrameCount = 0; // gif图片总帧数
UINT m_nFramePosition = 0; // 当前放到第几帧
Gdiplus::PropertyItem *m_pPropertyItem = nullptr; // 帧与帧之间间隔时间
faw::string_t m_sBkImage;
bool m_bIsAutoPlay = true; // 是否自动播放gif
bool m_bIsAutoSize = false; // 是否自动根据图片设置大小
bool m_bIsPlaying = false;
IStream *m_pStream = nullptr;
};
}
#endif // GifAnimUI_h__ | [
"f@fawdlstty.com"
] | f@fawdlstty.com |
2fe381ed7cbbc2e7d3a00bce9ee161d47c425e41 | ed8332a1512f81aced000cc8034acee41051f74d | /ZFramework3D/ZExpMapGenerateWarp.h | 009d5543ede5777951916d8a1324043af646c463 | [] | no_license | zzez12/ZFramework | cefd52aea8447d253334f34dc3246eb6bff4235d | 347d68a96a030888ea7b0fc22c63bd3279a6279c | refs/heads/master | 2021-01-19T02:39:21.808644 | 2016-07-04T02:17:12 | 2016-07-04T02:17:12 | 50,234,235 | 0 | 0 | null | 2016-07-04T02:18:38 | 2016-01-23T10:38:55 | C++ | UTF-8 | C++ | false | false | 1,027 | h | #pragma once
#ifndef ZEXPMAPGENERATEWARP_H_
#define ZEXPMAPGENERATEWARP_H_
#include "GlobalDefs.h"
#include "../Scene/Mesh3D.h"
#include "../ExLib/expmap/ExpMapGenerator.h"
#include "../ExLib/expmap/VFTriangleMesh.h"
#include "ZMeshParser.h"
namespace ZMeshSpace
{
class ZExpMapGenerateWarp
{
public:
ZExpMapGenerateWarp(Mesh3D* pMesh=NULL);
~ZExpMapGenerateWarp();
void destroy();
void setMesh(Mesh3D* pMesh);
void setHitVertex(HE_vert* vert);
void setHitVertex(const Vec3f& vPos, const Vec3f& vNormal);
//void computeExpMap();
void validateExpMap();
Vec2f getUV(int vId);
private:
Mesh3D* mesh_;
rms::VFTriangleMesh* vfMesh_;
rms::ExpMapGenerator expMapGen_;
rms::IMeshBVTree bvTree_;
bool bExpMapInitialized_;
bool bExpMapValid_;
bool bSmoothNormals_;
bool bUpwindAverage_;
bool bUseConstantNormal_;
bool bPreserveProjectedLengths_;
float fDecalRadius_;
float fBoundaryWidth_;
float fMaxEdgeLength_;
rms::Frame3f vSeedFrame_;
};
}
#endif //ZEXPMAPGENERATEWARP_H_ | [
"zzez12@foxmail.com"
] | zzez12@foxmail.com |
6d19e06f12a947d34d731b2cb580ef94b82c9ae6 | f174607cab237e01c11de99fab7d9d9dec4fa380 | /lab4/interpolations/netwon_interpolation.cpp | 7090bfda7d4d44da7cdf64da3664ec73c827b447 | [] | no_license | MatiXOfficial/MOwNiT | ff6c1c3c6df5c1fc8afd53bc6665ac554e2f80ae | 7ddbd9add9617e566732447d2fc8956923942daf | refs/heads/master | 2021-03-21T22:57:07.273833 | 2020-06-12T13:39:37 | 2020-06-12T13:39:37 | 247,333,529 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,141 | cpp | #include <vector>
#include "../utils/point.h"
std::vector<Point> newtonInterpolation(const std::vector<Point> &nodes, const std::vector<double> &pointsX)
{
int n = nodes.size();
std::vector< std::vector<double> > F(n, std::vector<double>());
for (Point node : nodes)
{
F[0].push_back(node.getY());
}
for (int i = 1; i < n; i++)
{
for (int p = 0; p < n - i; p++)
{
double val = (F[i - 1][p + 1] - F[i - 1][p]) / (nodes[p + i].getX() - nodes[p].getX());
F[i].push_back(val);
}
}
std::vector<Point> points;
for (double x : pointsX)
{
double y = F[0][0];
double factor = 1;
for (int k = 1; k < n; k++)
{
factor *= (x - nodes[k - 1].getX());
y += (factor * F[k][0]);
}
points.push_back(Point(x, y));
}
return points;
}
std::vector<Point> newtonInterpolation(const std::vector<double (*)(double)> &funs,
const std::vector<Point> &nodes, const std::vector<double> &pointsX)
{
return newtonInterpolation(nodes, pointsX);
} | [
"mateuszkocot99@gmail.com"
] | mateuszkocot99@gmail.com |
659286c9e2e0e68464e2d370816e891273afbc4f | 581f7c9d75a5ebc95264e56c2b2de9283e02afdc | /PICTest/PIC_main.cpp | a4c002153c064255988250734192031afe7525de | [] | no_license | skrcjstk/FluidSimulationWithOPT | 22551e617748a381b8a51ab2fd242701a4f2ce4b | ea43536944f44659d9b5fda727c18ba6ef3a0100 | refs/heads/master | 2021-09-10T00:35:01.130681 | 2018-03-20T11:48:18 | 2018-03-20T11:48:18 | 108,535,626 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,705 | cpp | #include "GL/glew.h"
#include "..\FluidSimulationWithOPT\Visualization\MiniGL.h"
#include "..\FluidSimulationWithOPT\Visualization\Selection.h"
#include "GL/glut.h"
#include "..\FluidSimulationWithOPT\Visualization\PrimitiveBuffer.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "PIC.h"
#include "FluidWorld.h"
#include "TimerChrono.h"
using namespace PBD;
using namespace std;
using namespace Eigen;
TimerChrono timer1, timer2, timer3;
float fineR = 0.025f;
float coarseR = 0.05f;
int fineDamWidth = 20;
int fineDamHeight = 20;
int fineDamDepth = 20;
int coarseDamWidth = fineDamWidth / 2;
int coarseDamHeight = fineDamHeight / 2;
int coarseDamDepth = fineDamDepth / 2;
float containerWidth = (coarseDamWidth * 7) * coarseR;
float containerHeight = (coarseDamWidth * 5) * coarseR;
float containerDepth = (coarseDamWidth * 5) * coarseR;
Vector3f containerStart;
Vector3f containerEnd;
bool doPause = true;
int accFrameCount = 0;
PIC* pic;
FluidWorld* world;
int frameLimit = 800;
GLint context_major_version, context_minor_version;
Primitive spherePrimiCoarse, spherePrimiFine, boxPrimi;
float* dataForPICDescriptor;
int desc_width = 5;
void timeStep();
void reset();
void render();
void cleanup();
void buildModel();
void CreateCoarseBreakingDam(std::vector<Vector3f>& p_damParticles);
void CreateCoarseContainer(std::vector<Vector3f>& p_boundaryParticles);
void CreateFineBreakingDam(std::vector<Vector3f>& p_damParticles);
void CreateFineContainer(std::vector<Vector3f>& p_boundaryParticles);
void AddWall(Vector3f p_min, Vector3f p_max, std::vector<Vector3f>& p_boundaryParticle, float p_particleRadius);
int main(int argc, char** argv)
{
// OpenGL
MiniGL::init(argc, argv, 1024, 768, 0, 0, "Fluid demo");
MiniGL::initLights();
MiniGL::setClientIdleFunc(50, timeStep);
MiniGL::setKeyFunc(0, 'r', reset);
//MiniGL::setSelectionFunc(selection);
MiniGL::getOpenGLVersion(context_major_version, context_minor_version);
MiniGL::setClientSceneFunc(render);
MiniGL::setViewport(40.0f, 0.1f, 500.0f, Vector3f(0.0, 2.0, 8.0), Vector3f(0.0, 2.0, 0.0));
TwAddVarRW(MiniGL::getTweakBar(), "Pause", TW_TYPE_BOOLCPP, &doPause, " label='Pause' group=Simulation key=SPACE ");
if (context_major_version >= 3)
{
spherePrimiCoarse.createSphereBuffers((float)coarseR, 8);
spherePrimiFine.createSphereBuffers((float)fineR, 8);
boxPrimi.createWireFrameBoxBuffers();
}
buildModel();
glutMainLoop();
cleanup();
return 0;
}
void timeStep()
{
if (doPause)
return;
// particle simulation
timer1.start();
world->StepPBF();
timer1.end("Simulation");
timer2.start();
pic->AssignCells(world);
pic->Map_P2G(world);
timer2.end("PIC Update");
timer3.start();
pic->GetDescriptorAll(dataForPICDescriptor, desc_width);
timer3.end("Desc Update");
accFrameCount++;
if (accFrameCount > frameLimit)
{
doPause = !doPause;
}
}
void render()
{
MiniGL::coordinateSystem();
MiniGL::drawTime(0);
float surfaceColor[4] = { 0.2f, 0.2f, 0.2f, 0.1f };
float kernelColor[4] = { 1.0f, 0.2f, 0.2f, 1.0f };
float speccolor[4] = { 1.0, 1.0, 1.0, 1.0 };
float anisotropyColor[4] = { 0.2f, 0.2f, 0.2f, 1.0f };
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, surfaceColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, surfaceColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, speccolor);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 100.0);
glColor3fv(surfaceColor);
glPointSize(4.0f);
// drawing main particles
float fluidColor[4] = { 0.0f, 0.7f, 0.7f, 0.2f };
for (int i = 0; i < world->GetNumOfParticles(); i++)
{
spherePrimiCoarse.renderSphere(world->GetParticle(i)->m_curPosition, fluidColor);
}
float boundaryColor[4] = { 0.5f, 0.5f, 0.5f, 0.5f };
for (int i = 0; i < world->GetNumOfBoundaryParticles(); i++)
{
//spherePrimiCoarse.renderSphere(world->GetBoundaryParticle(i)->m_curPosition, boundaryColor);
}
// draw grid & arrow
float FDot[4] = { 0.0f, 0.0f, 0.8f, 1.0f };
float BDot[4] = { 0.8f, 0.4f, 0.8f, 1.0f };
float boxColor[4] = { 0.1f, 0.1f, 0.1f, 0.5f };
Vector3f dxyz = pic->GetDxDyDz();
float head_len = 0.1f*dxyz[0];
int ng = pic->GetGridSize();
for (int g = 0; g < ng; g++)
{
Vector3f& pos = pic->GetGridPos(g);
//boxPrimi.renderWireFrameBox(pos, dxyz, boxColor);
//if(pic->GetGid(g) == F)
// boxPrimi.renderPoint(pos, FDot, 1.0f);
//else if (pic->GetGid(g) == B)
// boxPrimi.renderWireFrameBox(pos, dxyz, boxColor);
Vector3f end = (pos + 0.01f * pic->GetVelocity(g));
boxPrimi.renderArrow3D(pos, end, head_len);
}
/*
int np = world->GetNumOfParticles();
int d = desc_width;
int halfCnt = (int)(desc_width / 2);
int dataSize = 4 * (d*d*d);
float* desc = (float*)malloc(sizeof(float) * 4 * desc_width * desc_width * desc_width);
if (accFrameCount > 1)
{
for (int n = 0; n < np; n++)
{
Vector3i& ijk = pic->GetAssignResultF(n);
pic->GetDescriptor(ijk, desc, desc_width);
Vector3f gridPos = pic->GetGridPos(ijk[0], ijk[1], ijk[2]);
for (int k = -halfCnt; k <= halfCnt; k++)
for (int j = -halfCnt; j <= halfCnt; j++)
for (int i = -halfCnt; i <= halfCnt; i++)
{
int idx = 4 * ((k + halfCnt) * (d*d) + (j + halfCnt)*(d)+(i + halfCnt));
Vector3i neiGrid = ijk + Vector3i(i, j, k);
Vector3f neiGridPos = pic->GetGridPos(neiGrid[0], neiGrid[1], neiGrid[2]);
Vector3f vel;
//result[startidx + idx + 0] = geo[neiIdx];
vel[0] = desc[idx + 1];
vel[1] = desc[idx + 2];
vel[2] = desc[idx + 3];
Vector3f end = (neiGridPos + 0.01f * vel);
boxPrimi.renderArrow3D(neiGridPos, end, head_len);
}
}
}
*/
}
void buildModel()
{
std::vector<Vector3f> boundaryParticles;
std::vector<Vector3f> damParticles;
CreateCoarseBreakingDam(damParticles);
CreateCoarseContainer(boundaryParticles);
//CreateFineBreakingDam(damParticles);
//CreateFineContainer(boundaryParticles);
world = new FluidWorld();
world->SetTimeStep(0.005f);
world->CreateParticles(damParticles, boundaryParticles, coarseR);
float gDx = 2.0f * coarseR;
Vector3f gStart = containerStart - Vector3f(5.0f * gDx, 5.0f * gDx, 5.0f * gDx);
Vector3f gEnd = containerEnd + Vector3f(5.0f*gDx, 5.0f*gDx, 5.0f*gDx);
Vector3f gSize = gEnd - gStart;
pic = new PIC();
pic->Initialize(world, gStart, gEnd - gStart, Vector3i((int)(gSize[0] / gDx), (int)(gSize[1] / gDx), (int)(gSize[2] / gDx)), 1.0);
pic->AssignBoundary(world->GetBoundaryParticleList());
int blockSize = desc_width * desc_width * desc_width;
dataForPICDescriptor = (float*)malloc(sizeof(float) * 4 * blockSize * damParticles.size());
}
void CreateCoarseBreakingDam(std::vector<Vector3f>& p_damParticles)
{
std::cout << "Initialize coarse fluid particles\n";
p_damParticles.resize(coarseDamWidth*coarseDamHeight*coarseDamDepth);
float diam = 2.0f * coarseR;
float startX = -0.5f * containerWidth + diam + diam;
float startY = diam + diam;
float startZ = -0.5f * containerDepth + diam;
#pragma omp parallel default(shared)
{
#pragma omp for schedule(static)
for (int k = 0; k < coarseDamDepth; k++)
{
for (int j = 0; j < coarseDamHeight; j++)
{
for (int i = 0; i < coarseDamWidth; i++)
{
p_damParticles[k*coarseDamHeight*coarseDamWidth + j*coarseDamWidth + i] = diam * Vector3f((float)i, (float)j, (float)k) + Vector3f(startX, startY, startZ);
}
}
}
}
std::cout << "Number of particles: " << p_damParticles.size() << "\n";
}
void CreateCoarseContainer(std::vector<Vector3f>& p_boundaryParticles)
{
float x1 = -containerWidth / 2.0f;
float x2 = containerWidth / 2.0f;
float y1 = 0.0f;
float y2 = containerHeight;
float z1 = -containerDepth / 2.0f;
float z2 = containerDepth / 2.0f;
float diam = 2.0f*coarseR;
containerStart[0] = x1;
containerStart[1] = y1;
containerStart[2] = z1;
containerEnd[0] = x2;
containerEnd[1] = y2;
containerEnd[2] = z2;
// Floor
AddWall(Vector3f(x1, y1, z1), Vector3f(x2, y1, z2), p_boundaryParticles, coarseR);
// Top
//AddWall(Vector3f(x1, y2, z1), Vector3f(x2, y2, z2), p_boundaryParticles, coarseR);
// Left
AddWall(Vector3f(x1, y1, z1), Vector3f(x1, y2, z2), p_boundaryParticles, coarseR);
// Right
AddWall(Vector3f(x2, y1, z1), Vector3f(x2, y2, z2), p_boundaryParticles, coarseR);
// Back
AddWall(Vector3f(x1, y1, z1), Vector3f(x2, y2, z1), p_boundaryParticles, coarseR);
// Front
AddWall(Vector3f(x1, y1, z2), Vector3f(x2, y2, z2), p_boundaryParticles, coarseR);
std::cout << "Number of Boundary Particles: " << p_boundaryParticles.size() << "\n";
}
void AddWall(Vector3f p_min, Vector3f p_max, std::vector<Vector3f>& p_boundaryParticle, float p_particleRadius)
{
Vector3f diff = p_max - p_min;
float diameter = 2 * p_particleRadius;
int countX = (int)(diff[0] / diameter) + 1;
int countY = (int)(diff[1] / diameter) + 1;
int countZ = (int)(diff[2] / diameter) + 1;
int startIndex = (int)p_boundaryParticle.size();
p_boundaryParticle.resize(startIndex + countX*countY*countZ);
#pragma omp parallel default(shared)
{
#pragma omp for schedule(static)
for (int i = 0; i < countX; i++)
{
for (int j = 0; j < countY; j++)
{
for (int k = 0; k < countZ; k++)
{
const Vector3f position = p_min + Vector3f(i*diameter, j*diameter, k*diameter);
p_boundaryParticle[startIndex + i*countY*countZ + j*countZ + k] = position;
}
}
}
}
}
void CreateFineBreakingDam(std::vector<Vector3f>& p_damParticles)
{
std::cout << "Initialize fine fluid particles\n";
p_damParticles.resize(fineDamWidth*fineDamHeight*fineDamDepth);
float diam = 2.0f * fineR;
float coarseDiam = 2.0f * coarseR;
float startX = -0.5f * containerWidth + coarseDiam + coarseDiam;
float startY = coarseDiam + coarseDiam + coarseDiam;
float startZ = -0.5f * containerDepth + coarseDiam;
#pragma omp parallel default(shared)
{
#pragma omp for schedule(static)
for (int i = 0; i < (int)fineDamWidth; i++)
{
for (int j = 0; j < fineDamHeight; j++)
{
for (int k = 0; k < fineDamDepth; k++)
{
p_damParticles[i*fineDamHeight*fineDamDepth + j*fineDamDepth + k] = diam*Eigen::Vector3f((float)i, (float)j, (float)k) + Eigen::Vector3f(startX, startY, startZ);
}
}
}
}
std::cout << "Number of particles: " << p_damParticles.size() << "\n";
}
void CreateFineContainer(std::vector<Vector3f>& p_boundaryParticles)
{
float x1 = -containerWidth / 2.0f;
float x2 = containerWidth / 2.0f;
float y1 = 0.0f;
float y2 = containerHeight;
float z1 = -containerDepth / 2.0f;
float z2 = containerDepth / 2.0f;
containerStart[0] = x1;
containerStart[1] = y1;
containerStart[2] = z1;
containerEnd[0] = x2;
containerEnd[1] = y2;
containerEnd[2] = z2;
// Floor
AddWall(Vector3f(x1, y1, z1), Vector3f(x2, y1, z2), p_boundaryParticles, fineR);
// Top
//AddWall(Vector3f(x1, y2, z1), Vector3f(x2, y2, z2), p_boundaryParticles, fineR);
// Left
AddWall(Vector3f(x1, y1, z1), Vector3f(x1, y2, z2), p_boundaryParticles, fineR);
// Right
AddWall(Vector3f(x2, y1, z1), Vector3f(x2, y2, z2), p_boundaryParticles, fineR);
// Back
AddWall(Vector3f(x1, y1, z1), Vector3f(x2, y2, z1), p_boundaryParticles, fineR);
// Front
AddWall(Vector3f(x1, y1, z2), Vector3f(x2, y2, z2), p_boundaryParticles, fineR);
std::cout << "Number of Boundary Particles: " << p_boundaryParticles.size() << "\n";
}
void reset() { accFrameCount = 0; }
void cleanup()
{
timer1.printAvg("Avg Simulation");
timer2.printAvg("Avg PIC Update");
timer3.printAvg("Avg Des Update");
if (context_major_version >= 3)
{
spherePrimiCoarse.releaseBuffers();
spherePrimiFine.releaseBuffers();
boxPrimi.releaseBuffers();
}
pic->clean();
free(dataForPICDescriptor);
}
void selection(const Eigen::Vector2i &start, const Eigen::Vector2i &end) {} | [
"skrcjstk@gmail.com"
] | skrcjstk@gmail.com |
bc49a70c452a52d629d84713167ac80cece812fd | 49db9830c7f183873c1394d8291e35d1289a08c6 | /include/core/Thread.h | 5147cbc007dddb24d7007485175ee09bce19d4f0 | [
"Zlib"
] | permissive | DarthCoder117/Icicle-Engine | ef0f1d96cbbeea5f8cff395a963a6fe44064b64b | 2aa3d56e7ca58f9d7e1ad946bda371495507b9b4 | refs/heads/master | 2020-12-26T16:27:29.568802 | 2015-03-04T01:19:19 | 2015-03-04T01:19:19 | 29,780,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,312 | h | #ifndef THREAD_H
#define THREAD_H
#include <IcicleCommon.h>
namespace ice
{
namespace core
{
///@brief Wrapper around thread implementation.
///The current implementation just wraps std::thread for portability.
class Thread
{
public:
Thread()
{}
template <typename F, typename... P>
Thread(F&& f, P&&... p)
:m_thread(new std::thread(f, p...))
{}
template <typename F, typename... P>
void init(F&& f, P&&... p)
{
m_thread.reset(new std::thread(f, p...));
}
///@return True if the thread has been succesfully created, false otherwise.
bool isValid(){ return m_thread != NULL; }
///@brief Waits for the thread to finish executing. The default is to wait indefinitely.
void join(u32 waitTimeMs = (u32)-1);
///@return This thread object's thread ID.
u32 getID();
///@brief Functions to manipulate the current thread.
class Current
{
public:
///@brief Returns the thread ID of the current thread of execution.
static u32 getCurrentThreadID();
///@brief Sleeps the current thread for the specified number of milliseconds.
static void sleep(u32 timeMs);
///@brief Yields the remainder of this thread's timeslice.
static void yield();
};
protected:
UniquePtr<std::thread> m_thread;
};
}
}
#endif | [
"tanner@icicle-games.com"
] | tanner@icicle-games.com |
cf8cab98a0252fab3e2dfd5887019a60d06f8d76 | cac5943d4339b3877a1cc3ecaf7293ab5f5c97d0 | /src/examples/07_module/circle.h | 9da758a8c0c614070bf3473b6bdb50b93f3457ad | [
"MIT"
] | permissive | acc-cosc-1337-fall-2019/acc-cosc-1337-fall-2019-Fortress117 | 128aef7ffd0773f393ede8cb93e5aa48ca0ba078 | 76cfd56f0d4cb53bd2ce997fffb994bd30560ce2 | refs/heads/master | 2020-07-13T07:58:29.178211 | 2019-12-10T00:08:28 | 2019-12-10T00:08:28 | 205,038,730 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 189 | h | //circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include"../07_module/shape.h"
namespace mod7ex
{
class Circle : public Shape
{
public:
void draw() override;
};
}
#endif // ! CIRCLE_h | [
"arturo.gonzalez@austincc.edu"
] | arturo.gonzalez@austincc.edu |
9d944ed318bdf37a448c0917273045a522298ca9 | 77403c90252ea0c41db72e1f6bccb2842f026897 | /src/abstract/gatewayabstract.cpp | fe22aaad79ee38c4e05266b20db7d552f51c68e3 | [] | no_license | lyarbean/qtrader | 1c783340d9aa1827e3368548c38d17a08af0e4e4 | 2d64b6195a39cd64eb3e1d6375b1bfa33560eff3 | refs/heads/master | 2021-05-12T00:14:14.060284 | 2018-01-16T06:35:01 | 2018-01-16T06:35:01 | 117,529,572 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 50 | cpp | #include "gatewayabstract.h"
using namespace oz;
| [
"slbyan@gmail.com"
] | slbyan@gmail.com |
64a5b740651a9acce14e11209a79d17207f45c4a | 5be1e1c536c1ad0cb0e2d009ba64fd05e9785168 | /Image.cpp | fdb64b960504d100a4fc73cfcadab975fab31730 | [] | no_license | SahibpreetSinghSaini/Bootcamp-1 | b7bea4cc8710c80111c0bc1ffad1f466be0693a7 | 8266c439c974e68edf7275bbae849d045fccc44e | refs/heads/main | 2023-02-16T11:19:21.743856 | 2021-01-13T18:23:46 | 2021-01-13T18:23:46 | 329,395,089 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,151 | cpp | #include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
Mat rotate(Mat src, double angle){
Mat dst;
Point2f pt(src.cols/2., src.rows/2.); // It Points to the Center of the Image
Mat r = getRotationMatrix2D(pt, angle, 1.0); // 1 denotes original size
warpAffine(src, dst, r, Size(src.cols, src.rows));
return dst;
}
int main(){
string imgname;
double ang;
Mat src, dst;
cout << "Enter the Path of the Image followed by Extension: ";
cin >> imgname;
src = imread(imgname, CV_LOAD_IMAGE_UNCHANGED); // Reading the Image
cout << "Enter the angle of Rotation: ";
cin >> ang;
dst = rotate(src, ang);
// Show the Original Image
const char* pzOriginalImage = "Original Image";
namedWindow(pzOriginalImage, CV_WINDOW_AUTOSIZE);
imshow(pzOriginalImage, src);
// Show the Rotated Image
const char* pzRotatedImage = "Rotated Image";
namedWindow(pzRotatedImage, CV_WINDOW_AUTOSIZE);
imshow(pzRotatedImage, dst);
waitKey(0);
return 0;
}
| [
"noreply@github.com"
] | SahibpreetSinghSaini.noreply@github.com |
01f0e5e3b761ae80802b4e6707c95774f0aa169e | c1b03b59b3974058e3dc4e3aa7a46a7ab9cc3b29 | /src/module-wx.new/generated/Class_wx_WebViewFactory.h | 4b2c3a296b31fb36465dc4e5d37277bb93682082 | [] | no_license | gura-lang/gura | 972725895c93c22e0ec87c17166df4d15bdbe338 | 03aff5e2b7fe4f761a16400ae7cc6fa7fec73a47 | refs/heads/master | 2021-01-25T08:04:38.269289 | 2020-05-09T12:42:23 | 2020-05-09T12:42:23 | 7,141,465 | 25 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,791 | h | //----------------------------------------------------------------------------
// wxWebViewFactory
//----------------------------------------------------------------------------
#ifndef __CLASS_WX_WEBVIEWFACTORY_H__
#define __CLASS_WX_WEBVIEWFACTORY_H__
#include <wx/webview.h>
Gura_BeginModuleScope(wx)
//----------------------------------------------------------------------------
// Class declaration for wxWebViewFactory
//----------------------------------------------------------------------------
Gura_DeclareUserClass(wx_WebViewFactory);
//----------------------------------------------------------------------------
// Object declaration for wxWebViewFactory
//----------------------------------------------------------------------------
class Object_wx_WebViewFactory : public Object_wx_Object {
public:
Gura_DeclareObjectAccessor(wx_WebViewFactory)
public:
inline Object_wx_WebViewFactory(wxWebViewFactory *pEntity, GuraObjectObserver *pObserver, bool ownerFlag) :
Object_wx_Object(Gura_UserClass(wx_WebViewFactory), pEntity, pObserver, ownerFlag) {}
inline Object_wx_WebViewFactory(Class *pClass, wxWebViewFactory *pEntity, GuraObjectObserver *pObserver, bool ownerFlag) :
Object_wx_Object(pClass, pEntity, pObserver, ownerFlag) {}
virtual ~Object_wx_WebViewFactory();
virtual Object *Clone() const;
virtual String ToString(bool exprFlag);
inline wxWebViewFactory *GetEntity() {
return static_cast<wxWebViewFactory *>(_pEntity);
}
inline wxWebViewFactory *ReleaseEntity() {
wxWebViewFactory *pEntity = GetEntity();
InvalidateEntity();
return pEntity;
}
inline bool IsInvalid(Environment &env) const {
if (_pEntity != nullptr) return false;
SetError_InvalidWxObject(env, "wxWebViewFactory");
return true;
}
};
Gura_EndModuleScope(wx)
#endif
| [
"ypsitau@nifty.com"
] | ypsitau@nifty.com |
450d384474b11afdc9eba238116959aeeea6f1b7 | 4c955558d482b2a85153509b8ca63480ca00b6bf | /src/sycl/SYCLDataFormats/SiPixelDigiErrorsSYCL.cc | a0b5cd20b8e7c1d10c11d5b4c0fd086dba4a2e13 | [
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] | permissive | cms-patatrack/pixeltrack-standalone | a9080890b11e4ac58b712bb0e6b46970ad8ac7d8 | 8b7a333df8fe24a2399a0cabf34a24202f48ff7e | refs/heads/master | 2023-08-19T04:19:10.014356 | 2023-08-17T20:16:57 | 2023-08-17T20:16:57 | 231,442,836 | 13 | 31 | Apache-2.0 | 2023-09-04T17:31:45 | 2020-01-02T19:05:03 | C++ | UTF-8 | C++ | false | false | 1,753 | cc | #include "SYCLDataFormats/SiPixelDigiErrorsSYCL.h"
#include "SYCLCore/device_unique_ptr.h"
#include "SYCLCore/host_unique_ptr.h"
#include <cassert>
SiPixelDigiErrorsSYCL::SiPixelDigiErrorsSYCL(size_t maxFedWords, PixelFormatterErrors errors, sycl::queue stream)
: formatterErrors_h(std::move(errors)) {
error_d = cms::sycltools::make_device_unique<cms::sycltools::SimpleVector<PixelErrorCompact>>(stream);
data_d = cms::sycltools::make_device_unique<PixelErrorCompact[]>(maxFedWords, stream);
stream.memset(data_d.get(), 0x00, maxFedWords * sizeof(PixelErrorCompact));
error_h = cms::sycltools::make_host_unique<cms::sycltools::SimpleVector<PixelErrorCompact>>(stream);
cms::sycltools::make_SimpleVector(error_h.get(), maxFedWords, data_d.get());
assert(error_h->empty());
assert(error_h->capacity() == static_cast<int>(maxFedWords));
stream.memcpy(error_d.get(), error_h.get(), sizeof(PixelErrorCompact));
}
void SiPixelDigiErrorsSYCL::copyErrorToHostAsync(sycl::queue stream) {
stream.memcpy(error_h.get(), error_d.get(), sizeof(PixelErrorCompact));
}
SiPixelDigiErrorsSYCL::HostDataError SiPixelDigiErrorsSYCL::dataErrorToHostAsync(sycl::queue stream) const {
// On one hand size() could be sufficient. On the other hand, if
// someone copies the SimpleVector<>, (s)he might expect the data
// buffer to actually have space for capacity() elements.
auto data = cms::sycltools::make_host_unique<PixelErrorCompact[]>(error_h->capacity(), stream);
// but transfer only the required amount
if (not error_h->empty()) {
stream.memcpy(data.get(), data_d.get(), error_h->size() * sizeof(PixelErrorCompact));
}
auto err = *error_h;
err.set_data(data.get());
return HostDataError(err, std::move(data));
}
| [
"au99.perego@gmail.com"
] | au99.perego@gmail.com |
a2196cadf50dbdab1a925651a21bc0c2c9636932 | 41921879b1eb3b50f97944fe6641eb91666da914 | /syutil/syutil/SyUtilClasses.cpp | b1651d105e651545a557b47dc59a9621b234947b | [
"MIT"
] | permissive | siyuli/SYUtil | 6b0562ab61fa344d774f392173013c0fe789f18f | b4eda55f40fec8ff87086af8b52c20f33ed3aab7 | refs/heads/master | 2021-01-10T03:24:20.991215 | 2020-10-09T13:44:39 | 2020-10-09T13:44:39 | 44,081,525 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,359 | cpp |
//#include "SyBase.h"
#include "SyUtilClasses.h"
#include "SyThreadMisc.h"
#include "SyUtilMisc.h"
#include "SyAssert.h"
#include "SyDebug.h"
#include "SyNetwork.h"
//#include "tp_p.h"
START_UTIL_NS
///////////////////////////////////////////////////////////////
// class CSyCleanUpBase
///////////////////////////////////////////////////////////////
CSyCleanUpBase *CSyCleanUpBase::s_pHeader = NULL;
CSyMutexThreadRecursive m_sSingletonMutex;
CSyMutexThreadRecursive *SyGetSingletonMutex()
{
return &m_sSingletonMutex;
}
CSyCleanUpBase::CSyCleanUpBase()
{
MutexType *pMutex = SyGetSingletonMutex();
SY_ASSERTE(pMutex);
CSyMutexGuardT<MutexType> theGuard(*pMutex);
m_pNext = s_pHeader;
s_pHeader = this;
}
CSyCleanUpBase::~CSyCleanUpBase()
{
}
void CSyCleanUpBase::CleanUp()
{
delete this;
}
void CSyCleanUpBase::CleanupAll()
{
MutexType *pMutex = SyGetSingletonMutex();
SY_ASSERTE(pMutex);
CSyMutexGuardT<MutexType> theGuard(*pMutex);
while (s_pHeader) {
CSyCleanUpBase *pTmp = s_pHeader->m_pNext;
s_pHeader->CleanUp();
s_pHeader = pTmp;
}
}
///////////////////////////////////////////////////////////////
// class CSyDataBlockNoMalloc
///////////////////////////////////////////////////////////////
CSyDataBlockNoMalloc::CSyDataBlockNoMalloc(LPCSTR aStr, DWORD aLen)
: m_pBegin(aStr)
, m_pEnd(aStr + aLen)
, m_pCurrentRead(m_pBegin)
, m_pCurrentWrite(const_cast<LPSTR>(m_pBegin))
{
SY_ASSERTE(m_pBegin);
}
SyResult CSyDataBlockNoMalloc::
Read(LPVOID aDst, DWORD aCount, DWORD *aBytesRead)
{
SY_ASSERTE_RETURN(aDst, SY_ERROR_INVALID_ARG);
SY_ASSERTE_RETURN(m_pCurrentRead, SY_ERROR_NOT_INITIALIZED);
SY_ASSERTE_RETURN(m_pCurrentRead <= m_pEnd, SY_ERROR_NOT_INITIALIZED);
//2009 5.14 Victor we need check the data is enough or not for the read request
//DWORD dwLen = SY_MIN(aCount, static_cast<DWORD>(m_pCurrentRead - m_pEnd));
DWORD dwLen = SY_MIN(aCount, static_cast<DWORD>(m_pEnd - m_pCurrentRead));
if (dwLen > 0) {
::memcpy(aDst, m_pCurrentRead, dwLen);
m_pCurrentRead += dwLen;
}
if (aBytesRead) {
*aBytesRead = dwLen;
}
return dwLen == aCount ? SY_OK : SY_ERROR_PARTIAL_DATA;
}
SyResult CSyDataBlockNoMalloc::
Write(LPCVOID aSrc, DWORD aCount, DWORD *aBytesWritten)
{
SY_ASSERTE_RETURN(aSrc, SY_ERROR_INVALID_ARG);
SY_ASSERTE_RETURN(m_pCurrentWrite, SY_ERROR_NOT_INITIALIZED);
SY_ASSERTE_RETURN(m_pCurrentWrite <= m_pEnd, SY_ERROR_NOT_INITIALIZED);
DWORD dwLen = SY_MIN(aCount, static_cast<DWORD>(m_pEnd - m_pCurrentWrite));
if (dwLen > 0) {
::memcpy(m_pCurrentWrite, aSrc, dwLen);
m_pCurrentWrite += dwLen;
}
if (aBytesWritten) {
*aBytesWritten = dwLen;
}
return dwLen == aCount ? SY_OK : SY_ERROR_PARTIAL_DATA;
}
///////////////////////////////////////////////////////////////
// class CSyDataBlockNoMalloc
///////////////////////////////////////////////////////////////
void CSyStopFlag::SetStartFlag()
{
m_Est.EnsureSingleThread();
SY_ASSERTE(m_bStoppedFlag);
m_bStoppedFlag = FALSE;
}
void CSyStopFlag::SetStopFlag()
{
m_Est.EnsureSingleThread();
m_bStoppedFlag = TRUE;
}
void CSyStopFlag::SetStopFlagWithoutThreadCheck(BOOL value)
{
m_bStoppedFlag = value;
}
END_UTIL_NS
| [
"siyuli@cisco.com"
] | siyuli@cisco.com |
c5dee2584544de021b41875de5efea5de66c80a7 | 4716135a3130ddcd14cec7ef64825e5e248b70a1 | /src/procedures/determine_characterisation.hpp | 1e7df6cb380d027bf5ffa0be8567d5654b5cd736 | [
"BSD-3-Clause"
] | permissive | Battery-Intelligence-Lab/SLIDE | 2465ae09a15674e573374151edbe0b17297a89ba | 847fec7aaeaefb916c51e5264aa8aa0dcfe72b20 | refs/heads/master | 2023-09-01T02:47:32.948438 | 2023-04-08T04:07:24 | 2023-04-08T04:07:24 | 185,216,614 | 26 | 8 | NOASSERTION | 2023-04-08T04:07:25 | 2019-05-06T14:47:40 | C++ | UTF-8 | C++ | false | false | 2,229 | hpp | /*
* determine_characterisation.hpp
*
* Header file for the functions used to find the parameters which will match measured CCCV cycles.
* This are the diffusion constants, rate constants and DC resistance.
*
* Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
* of Oxford, VITO nv, and the 'Slide' Developers.
* See the licence file LICENCE.txt for more information.
*/
#pragma once
#include "../cells/cells.hpp"
#include "../utility/utility.hpp"
#include "CyclerOld.hpp"
#include "Cycler.hpp"
#include <string>
namespace slide {
bool CCCV_fit(Cell_SPM c1, double Crate, double Ccut, double Tref, double Dp, double Dn, double kp,
double kn, double R, const struct OCVparam &ocvfit, const struct slide::Model_SPM &M,
slide::XYdata_vv &Vsim, slide::XYdata_vv &Tsim);
void CCCV(double Crate, double Ccut, double Tref, double Dp, double Dn, double kp, double kn, double R, const struct OCVparam &ocvfit,
const struct slide::Model_SPM &M, slide::XYdata_vv &Vsim, slide::XYdata_vv &Tsim);
void fitDiffusionAndRate(int hierarchy, int ir, double R, slide::FixedData<double> Dp_space, slide::FixedData<double> Dn_space,
slide::FixedData<double> kp_space, slide::FixedData<double> kn_space,
std::vector<slide::XYdata_vv> &Vdata_all, double weights[],
double Crates[], double Ccuts[], double Tref, const struct OCVparam &ocvfit,
double *err, std::array<double, 5> &par);
void hierarchicalCharacterisationFit(int hmax, slide::FixedData<double> r_space, slide::FixedData<double> Dp_space,
slide::FixedData<double> Dn_space, slide::FixedData<double> kp_space,
slide::FixedData<double> kn_space, std::vector<slide::XYdata_vv> &Vdata_all,
double weights[], double Crates[], double Ccuts[], double Tref,
const struct OCVparam &ocvfit, double *err, std::array<double, 5> &par);
void writeCharacterisationParam(int h, const std::array<double, 5> &par, double err);
void estimateCharacterisation();
} // namespace slide | [
"volkan.kumtepeli@gmail.com"
] | volkan.kumtepeli@gmail.com |
159a7300c181b9e0fa7444b191b2c9deab81b316 | 37a2f168a94ee7d6d9e9f2c3f0584ffafd2010c1 | /src/ORBmatcher.cc | e59c96382452a5d4cc4af1a9bdcce2b9746dd031 | [] | no_license | sebastinaa/ORB-SLAM3-Note | e5afcc7a730db60059c16aeff9edb021660e1f2f | ea8f03c61df729c1688b6f838f3e58a5f7cebef3 | refs/heads/main | 2023-03-24T18:31:07.074060 | 2021-03-11T04:41:49 | 2021-03-11T04:41:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 89,954 | cc | /**
* This file is part of ORB-SLAM3
*
* Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez Rodríguez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
* Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
*
* ORB-SLAM3 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORB-SLAM3 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 ORB-SLAM3.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "ORBmatcher.h"
#include<limits.h>
#include<opencv2/core/core.hpp>
#include<opencv2/features2d/features2d.hpp>
#include "Thirdparty/DBoW2/DBoW2/FeatureVector.h"
#include<stdint-gcc.h>
using namespace std;
namespace ORB_SLAM3
{
const int ORBmatcher::TH_HIGH = 100;
const int ORBmatcher::TH_LOW = 50;
const int ORBmatcher::HISTO_LENGTH = 30;
ORBmatcher::ORBmatcher(float nnratio, bool checkOri): mfNNratio(nnratio), mbCheckOrientation(checkOri)
{
}
/**
* 3d-2d,投影MP集合点到当前帧,计算描述子距离,寻找当前帧匹配特征点
* 1、遍历MP集合,根据跟踪视差计算搜索窗大小,在当前帧投影点相邻搜索窗中提取fast特征点
* 2、计算MP与候选特征点的描述子距离,最佳距离小于阈值,最佳与次佳不在同一金字塔层级、或者次佳与最佳有一定距离,认为匹配成功
* 3、更新F的mvpMapPoints,记录对应特征点
*/
int ORBmatcher::SearchByProjection(Frame &F, const vector<MapPoint*> &vpMapPoints, const float th, const bool bFarPoints, const float thFarPoints)
{
int nmatches=0, left = 0, right = 0;
// th!=1表示刚刚经历重定位,需要扩大搜索范围
const bool bFactor = th!=1.0;
// 遍历MP集合
for(size_t iMP=0; iMP<vpMapPoints.size(); iMP++)
{
MapPoint* pMP = vpMapPoints[iMP];
if(!pMP->mbTrackInView && !pMP->mbTrackInViewR)
continue;
// 不考虑远距离点,点的距离超过最远距离
if(bFarPoints && pMP->mTrackDepth>thFarPoints)
continue;
if(pMP->isBad())
continue;
if(pMP->mbTrackInView)
{
// 根据距离估算的MP在当前帧投影特征点的金字塔层级
const int &nPredictedLevel = pMP->mnTrackScaleLevel;
// The size of the window will depend on the viewing direction
// 跟踪视差较小时,搜索窗小一些,反之大一些。视差为当前帧与localMap观测帧平均视角之间的角度差
float r = RadiusByViewingCos(pMP->mTrackViewCos);
if(bFactor)
r*=th;
// 提取(x,y)位置处r范围矩形窗内的特征点
const vector<size_t> vIndices =
F.GetFeaturesInArea(pMP->mTrackProjX,pMP->mTrackProjY,r*F.mvScaleFactors[nPredictedLevel],nPredictedLevel-1,nPredictedLevel);
if(!vIndices.empty()){
// MP代表描述子
const cv::Mat MPdescriptor = pMP->GetDescriptor();
int bestDist=256;
int bestLevel= -1;
int bestDist2=256;
int bestLevel2 = -1;
int bestIdx =-1 ;
// Get best and second matches with near keypoints
// 遍历搜索窗中的特征点
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
// 特征点已经有对应的MP点了
if(F.mvpMapPoints[idx])
if(F.mvpMapPoints[idx]->Observations()>0)
continue;
// 双目
if(F.Nleft == -1 && F.mvuRight[idx]>0)
{
// 在X轴上的投影误差,太大不行
const float er = fabs(pMP->mTrackProjXR-F.mvuRight[idx]);
if(er>r*F.mvScaleFactors[nPredictedLevel])
continue;
}
// 描述子
const cv::Mat &d = F.mDescriptors.row(idx);
// 计算描述子距离
const int dist = DescriptorDistance(MPdescriptor,d);
// 记录最佳、次佳匹配点,对应层级
if(dist<bestDist)
{
bestDist2=bestDist;
bestDist=dist;
bestLevel2 = bestLevel;
bestLevel = (F.Nleft == -1) ? F.mvKeysUn[idx].octave
: (idx < F.Nleft) ? F.mvKeys[idx].octave
: F.mvKeysRight[idx - F.Nleft].octave;
bestIdx=idx;
}
else if(dist<bestDist2)
{
bestLevel2 = (F.Nleft == -1) ? F.mvKeysUn[idx].octave
: (idx < F.Nleft) ? F.mvKeys[idx].octave
: F.mvKeysRight[idx - F.Nleft].octave;
bestDist2=dist;
}
}
// Apply ratio to second match (only if best and second are in the same scale level)
// 最佳距离小于阈值,最佳与次佳不在同一金字塔层级、或者次佳与最佳有一定距离,认为匹配成功
if(bestDist<=TH_HIGH)
{
if(bestLevel==bestLevel2 && bestDist>mfNNratio*bestDist2)
continue;
if(bestLevel!=bestLevel2 || bestDist<=mfNNratio*bestDist2){
F.mvpMapPoints[bestIdx]=pMP;
if(F.Nleft != -1 && F.mvLeftToRightMatch[bestIdx] != -1){ //Also match with the stereo observation at right camera
F.mvpMapPoints[F.mvLeftToRightMatch[bestIdx] + F.Nleft] = pMP;
nmatches++;
right++;
}
nmatches++;
left++;
}
}
}
}
// 双目右目,同样的做法
if(F.Nleft != -1 && pMP->mbTrackInViewR){
const int &nPredictedLevel = pMP->mnTrackScaleLevelR;
if(nPredictedLevel != -1){
float r = RadiusByViewingCos(pMP->mTrackViewCosR);
// 提取(x,y)位置处r范围矩形窗内的特征点
const vector<size_t> vIndices =
F.GetFeaturesInArea(pMP->mTrackProjXR,pMP->mTrackProjYR,r*F.mvScaleFactors[nPredictedLevel],nPredictedLevel-1,nPredictedLevel,true);
if(vIndices.empty())
continue;
const cv::Mat MPdescriptor = pMP->GetDescriptor();
int bestDist=256;
int bestLevel= -1;
int bestDist2=256;
int bestLevel2 = -1;
int bestIdx =-1 ;
// Get best and second matches with near keypoints
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
if(F.mvpMapPoints[idx + F.Nleft])
if(F.mvpMapPoints[idx + F.Nleft]->Observations()>0)
continue;
const cv::Mat &d = F.mDescriptors.row(idx + F.Nleft);
const int dist = DescriptorDistance(MPdescriptor,d);
if(dist<bestDist)
{
bestDist2=bestDist;
bestDist=dist;
bestLevel2 = bestLevel;
bestLevel = F.mvKeysRight[idx].octave;
bestIdx=idx;
}
else if(dist<bestDist2)
{
bestLevel2 = F.mvKeysRight[idx].octave;
bestDist2=dist;
}
}
// Apply ratio to second match (only if best and second are in the same scale level)
if(bestDist<=TH_HIGH)
{
if(bestLevel==bestLevel2 && bestDist>mfNNratio*bestDist2)
continue;
if(F.Nleft != -1 && F.mvRightToLeftMatch[bestIdx] != -1){ //Also match with the stereo observation at right camera
F.mvpMapPoints[F.mvRightToLeftMatch[bestIdx]] = pMP;
nmatches++;
left++;
}
F.mvpMapPoints[bestIdx + F.Nleft]=pMP;
nmatches++;
right++;
}
}
}
}
return nmatches;
}
/**
* 角度较小时返回小值
*/
float ORBmatcher::RadiusByViewingCos(const float &viewCos)
{
if(viewCos>0.998)
return 2.5;
else
return 4.0;
}
/**
* 用基础矩阵计算极线,计算匹配点到极线距离,是否足够小
*/
bool ORBmatcher::CheckDistEpipolarLine(const cv::KeyPoint &kp1,const cv::KeyPoint &kp2,const cv::Mat &F12,const KeyFrame* pKF2, const bool b1)
{
// Epipolar line in second image l = x1'F12 = [a b c]
// 在第二幅图像上的极线方程
const float a = kp1.pt.x*F12.at<float>(0,0)+kp1.pt.y*F12.at<float>(1,0)+F12.at<float>(2,0);
const float b = kp1.pt.x*F12.at<float>(0,1)+kp1.pt.y*F12.at<float>(1,1)+F12.at<float>(2,1);
const float c = kp1.pt.x*F12.at<float>(0,2)+kp1.pt.y*F12.at<float>(1,2)+F12.at<float>(2,2);
const float num = a*kp2.pt.x+b*kp2.pt.y+c;
const float den = a*a+b*b;
if(den==0)
return false;
// kp2到极线距离的平方
const float dsqr = num*num/den;
if(!b1)
// 距离小于1个像素,认为合格
return dsqr<3.84*pKF2->mvLevelSigma2[kp2.octave];
else
return dsqr<6.63*pKF2->mvLevelSigma2[kp2.octave];
}
/**
* 同上,只是多个阈值系数
*/
bool ORBmatcher::CheckDistEpipolarLine2(const cv::KeyPoint &kp1, const cv::KeyPoint &kp2, const cv::Mat &F12, const KeyFrame *pKF2, const float unc)
{
// Epipolar line in second image l = x1'F12 = [a b c]
const float a = kp1.pt.x*F12.at<float>(0,0)+kp1.pt.y*F12.at<float>(1,0)+F12.at<float>(2,0);
const float b = kp1.pt.x*F12.at<float>(0,1)+kp1.pt.y*F12.at<float>(1,1)+F12.at<float>(2,1);
const float c = kp1.pt.x*F12.at<float>(0,2)+kp1.pt.y*F12.at<float>(1,2)+F12.at<float>(2,2);
const float num = a*kp2.pt.x+b*kp2.pt.y+c;
const float den = a*a+b*b;
if(den==0)
return false;
const float dsqr = num*num/den;
if(unc==1.f)
return dsqr<3.84*pKF2->mvLevelSigma2[kp2.octave];
else
return dsqr<3.84*pKF2->mvLevelSigma2[kp2.octave]*unc;
}
/**
* 3d-2d,通过词袋树划分特征点到node,在node中计算两帧的特征点描述子距离,寻找当前帧匹配特征点
* 1、关键帧和当前帧的特征点都划分到了词袋树中不同节点中去了
* 2、遍历节点集合,相同的节点才计算匹配点
* 3、在同一节点中,遍历关键帧的特征点,当前帧的特征点,计算描述子距离
* 4、描述子距离小于阈值,且次佳与最佳有一定差距,认为匹配上了
* 5、根据特征点angle差值构造的直方图,删除非前三的离群匹配点
* 6、vpMapPointMatches保存数据,当前帧特征点 - 关键帧MP
*/
int ORBmatcher::SearchByBoW(KeyFrame* pKF,Frame &F, vector<MapPoint*> &vpMapPointMatches)
{
// 关键帧特征点-MP集合
const vector<MapPoint*> vpMapPointsKF = pKF->GetMapPointMatches();
vpMapPointMatches = vector<MapPoint*>(F.N,static_cast<MapPoint*>(NULL));
// 关键帧特征点集合
const DBoW2::FeatureVector &vFeatVecKF = pKF->mFeatVec;
int nmatches=0;
// 旋转差统计直方图
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
// We perform the matching over ORB that belong to the same vocabulary node (at a certain level)
// FeatureVector: map<NodeId, std::vector<unsigned int> > 这里的NodeId是词袋树中的id
DBoW2::FeatureVector::const_iterator KFit = vFeatVecKF.begin();
DBoW2::FeatureVector::const_iterator Fit = F.mFeatVec.begin();
DBoW2::FeatureVector::const_iterator KFend = vFeatVecKF.end();
DBoW2::FeatureVector::const_iterator Fend = F.mFeatVec.end();
// 遍历关键帧、当前帧的node集合
while(KFit != KFend && Fit != Fend)
{
// 同一node才有可能是匹配点
if(KFit->first == Fit->first)
{
const vector<unsigned int> vIndicesKF = KFit->second;
const vector<unsigned int> vIndicesF = Fit->second;
// 遍历关键帧特征点
for(size_t iKF=0; iKF<vIndicesKF.size(); iKF++)
{
const unsigned int realIdxKF = vIndicesKF[iKF];
MapPoint* pMP = vpMapPointsKF[realIdxKF];
if(!pMP)
continue;
if(pMP->isBad())
continue;
const cv::Mat &dKF= pKF->mDescriptors.row(realIdxKF);
int bestDist1=256;
int bestIdxF =-1 ;
int bestDist2=256;
int bestDist1R=256;
int bestIdxFR =-1 ;
int bestDist2R=256;
// 遍历当前帧特征点
for(size_t iF=0; iF<vIndicesF.size(); iF++)
{
if(F.Nleft == -1){
const unsigned int realIdxF = vIndicesF[iF];
if(vpMapPointMatches[realIdxF])
continue;
const cv::Mat &dF = F.mDescriptors.row(realIdxF);
const int dist = DescriptorDistance(dKF,dF);
if(dist<bestDist1)
{
bestDist2=bestDist1;
bestDist1=dist;
bestIdxF=realIdxF;
}
else if(dist<bestDist2)
{
bestDist2=dist;
}
}
else{
const unsigned int realIdxF = vIndicesF[iF];
if(vpMapPointMatches[realIdxF])
continue;
const cv::Mat &dF = F.mDescriptors.row(realIdxF);
const int dist = DescriptorDistance(dKF,dF);
if(realIdxF < F.Nleft && dist<bestDist1){
bestDist2=bestDist1;
bestDist1=dist;
bestIdxF=realIdxF;
}
else if(realIdxF < F.Nleft && dist<bestDist2){
bestDist2=dist;
}
if(realIdxF >= F.Nleft && dist<bestDist1R){
bestDist2R=bestDist1R;
bestDist1R=dist;
bestIdxFR=realIdxF;
}
else if(realIdxF >= F.Nleft && dist<bestDist2R){
bestDist2R=dist;
}
}
}
// 描述子距离小于阈值,且次佳与最佳有一定差距,认为匹配上了,后面再检查特征点方向
if(bestDist1<=TH_LOW)
{
if(static_cast<float>(bestDist1)<mfNNratio*static_cast<float>(bestDist2))
{
vpMapPointMatches[bestIdxF]=pMP;
const cv::KeyPoint &kp =
(!pKF->mpCamera2) ? pKF->mvKeysUn[realIdxKF] :
(realIdxKF >= pKF -> NLeft) ? pKF -> mvKeysRight[realIdxKF - pKF -> NLeft]
: pKF -> mvKeys[realIdxKF];
// 检查特征点方向
if(mbCheckOrientation)
{
cv::KeyPoint &Fkp =
(!pKF->mpCamera2 || F.Nleft == -1) ? F.mvKeys[bestIdxF] :
(bestIdxF >= F.Nleft) ? F.mvKeysRight[bestIdxF - F.Nleft]
: F.mvKeys[bestIdxF];
float rot = kp.angle-Fkp.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(bestIdxF);
}
nmatches++;
}
if(bestDist1R<=TH_LOW)
{
if(static_cast<float>(bestDist1R)<mfNNratio*static_cast<float>(bestDist2R) || true)
{
vpMapPointMatches[bestIdxFR]=pMP;
const cv::KeyPoint &kp =
(!pKF->mpCamera2) ? pKF->mvKeysUn[realIdxKF] :
(realIdxKF >= pKF -> NLeft) ? pKF -> mvKeysRight[realIdxKF - pKF -> NLeft]
: pKF -> mvKeys[realIdxKF];
if(mbCheckOrientation)
{
cv::KeyPoint &Fkp =
(!F.mpCamera2) ? F.mvKeys[bestIdxFR] :
(bestIdxFR >= F.Nleft) ? F.mvKeysRight[bestIdxFR - F.Nleft]
: F.mvKeys[bestIdxFR];
float rot = kp.angle-Fkp.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(bestIdxFR);
}
nmatches++;
}
}
}
}
KFit++;
Fit++;
}
else if(KFit->first < Fit->first)
{
KFit = vFeatVecKF.lower_bound(Fit->first);
}
else
{
Fit = F.mFeatVec.lower_bound(KFit->first);
}
}
// 检查特征点方向,删除方向差不合群的匹配点
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i==ind1 || i==ind2 || i==ind3)
continue;
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
vpMapPointMatches[rotHist[i][j]]=static_cast<MapPoint*>(NULL);
nmatches--;
}
}
}
return nmatches;
}
/**
* 3d-2d,闭环关键帧与其共视关键帧的MP,投影到当前关键帧中,计算描述子距离,寻找当前帧匹配特征点
* 1、投影MP到当前关键帧,深度值不得超过估计范围,视差不得超过60°
* 2、通过深度值估计特征点的层级,搜索框提取fast特征点集合
* 3、匹配层级上下只允许浮动一层,描述子距离小于阈值即可
* 4、当前关键帧已有的MP不参与上面的过程
* @param pKF 当前关键帧
* @param Scw 当前关键帧位姿
* @param vpPoints 闭环关键帧与其共视关键帧的地图点
* @param vpMatched 当前关键帧已经匹配的点
* @param th 搜索窗大小
* @param ratioHamming 描述子距离阈值系数
*/
int ORBmatcher::SearchByProjection(KeyFrame* pKF, cv::Mat Scw, const vector<MapPoint*> &vpPoints,
vector<MapPoint*> &vpMatched, int th, float ratioHamming)
{
// Get Calibration Parameters for later projection
const float &fx = pKF->fx;
const float &fy = pKF->fy;
const float &cx = pKF->cx;
const float &cy = pKF->cy;
// Decompose Scw
// 当前关键帧位姿
cv::Mat sRcw = Scw.rowRange(0,3).colRange(0,3);
const float scw = sqrt(sRcw.row(0).dot(sRcw.row(0)));
cv::Mat Rcw = sRcw/scw;
cv::Mat tcw = Scw.rowRange(0,3).col(3)/scw;
cv::Mat Ow = -Rcw.t()*tcw;
// Set of MapPoints already found in the KeyFrame
set<MapPoint*> spAlreadyFound(vpMatched.begin(), vpMatched.end());
spAlreadyFound.erase(static_cast<MapPoint*>(NULL));
int nmatches=0;
// For each Candidate MapPoint Project and Match
// 遍历闭环关键帧与其共视关键帧的地图点
for(int iMP=0, iendMP=vpPoints.size(); iMP<iendMP; iMP++)
{
MapPoint* pMP = vpPoints[iMP];
// Discard Bad MapPoints and already found
if(pMP->isBad() || spAlreadyFound.count(pMP))
continue;
// Get 3D Coords.
cv::Mat p3Dw = pMP->GetWorldPos();
// Transform into Camera Coords.
// 投影到当前相机坐标系
cv::Mat p3Dc = Rcw*p3Dw+tcw;
// Depth must be positive
if(p3Dc.at<float>(2)<0.0)
continue;
// Project into Image
const float x = p3Dc.at<float>(0);
const float y = p3Dc.at<float>(1);
const float z = p3Dc.at<float>(2);
// 投影到像素坐标系
const cv::Point2f uv = pKF->mpCamera->project(cv::Point3f(x,y,z));
// Point must be inside the image
if(!pKF->IsInImage(uv.x,uv.y))
continue;
// Depth must be inside the scale invariance region of the point
// 深度值是否在有效范围内
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
cv::Mat PO = p3Dw-Ow;
const float dist = cv::norm(PO);
if(dist<minDistance || dist>maxDistance)
continue;
// Viewing angle must be less than 60 deg
// 地图点的观测法矢
cv::Mat Pn = pMP->GetNormal();
// 视差不可以超过60°
if(PO.dot(Pn)<0.5*dist)
continue;
// 通过深度值估计特征点的层级
int nPredictedLevel = pMP->PredictScale(dist,pKF);
// Search in a radius
// 搜索范围乘上金字塔尺度
const float radius = th*pKF->mvScaleFactors[nPredictedLevel];
// 搜索窗中的候选特征点集合
const vector<size_t> vIndices = pKF->GetFeaturesInArea(uv.x,uv.y,radius);
if(vIndices.empty())
continue;
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx = -1;
// 遍历搜索窗中的候选特征点集合
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
if(vpMatched[idx])
continue;
const int &kpLevel= pKF->mvKeysUn[idx].octave;
// 层级上下只允许浮动一层
if(kpLevel<nPredictedLevel-1 || kpLevel>nPredictedLevel)
continue;
const cv::Mat &dKF = pKF->mDescriptors.row(idx);
const int dist = DescriptorDistance(dMP,dKF);
// 记录最佳描述子距离
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
// 描述子距离小于阈值,认为匹配成功
if(bestDist<=TH_LOW*ratioHamming)
{
vpMatched[bestIdx]=pMP;
nmatches++;
}
}
return nmatches;
}
/**
* 同上,记录当前帧2d点 - 闭环Map点对应的参考关键帧
*/
int ORBmatcher::SearchByProjection(KeyFrame* pKF, cv::Mat Scw, const std::vector<MapPoint*> &vpPoints, const std::vector<KeyFrame*> &vpPointsKFs,
std::vector<MapPoint*> &vpMatched, std::vector<KeyFrame*> &vpMatchedKF, int th, float ratioHamming)
{
// Get Calibration Parameters for later projection
const float &fx = pKF->fx;
const float &fy = pKF->fy;
const float &cx = pKF->cx;
const float &cy = pKF->cy;
// Decompose Scw
cv::Mat sRcw = Scw.rowRange(0,3).colRange(0,3);
const float scw = sqrt(sRcw.row(0).dot(sRcw.row(0)));
cv::Mat Rcw = sRcw/scw;
cv::Mat tcw = Scw.rowRange(0,3).col(3)/scw;
cv::Mat Ow = -Rcw.t()*tcw;
// Set of MapPoints already found in the KeyFrame
set<MapPoint*> spAlreadyFound(vpMatched.begin(), vpMatched.end());
spAlreadyFound.erase(static_cast<MapPoint*>(NULL));
int nmatches=0;
// For each Candidate MapPoint Project and Match
for(int iMP=0, iendMP=vpPoints.size(); iMP<iendMP; iMP++)
{
MapPoint* pMP = vpPoints[iMP];
KeyFrame* pKFi = vpPointsKFs[iMP];
// Discard Bad MapPoints and already found
if(pMP->isBad() || spAlreadyFound.count(pMP))
continue;
// Get 3D Coords.
cv::Mat p3Dw = pMP->GetWorldPos();
// Transform into Camera Coords.
cv::Mat p3Dc = Rcw*p3Dw+tcw;
// Depth must be positive
if(p3Dc.at<float>(2)<0.0)
continue;
// Project into Image
const float invz = 1/p3Dc.at<float>(2);
const float x = p3Dc.at<float>(0)*invz;
const float y = p3Dc.at<float>(1)*invz;
const float u = fx*x+cx;
const float v = fy*y+cy;
// Point must be inside the image
if(!pKF->IsInImage(u,v))
continue;
// Depth must be inside the scale invariance region of the point
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
cv::Mat PO = p3Dw-Ow;
const float dist = cv::norm(PO);
if(dist<minDistance || dist>maxDistance)
continue;
// Viewing angle must be less than 60 deg
cv::Mat Pn = pMP->GetNormal();
if(PO.dot(Pn)<0.5*dist)
continue;
int nPredictedLevel = pMP->PredictScale(dist,pKF);
// Search in a radius
const float radius = th*pKF->mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices = pKF->GetFeaturesInArea(u,v,radius);
if(vIndices.empty())
continue;
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx = -1;
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
if(vpMatched[idx])
continue;
const int &kpLevel= pKF->mvKeysUn[idx].octave;
if(kpLevel<nPredictedLevel-1 || kpLevel>nPredictedLevel)
continue;
const cv::Mat &dKF = pKF->mDescriptors.row(idx);
const int dist = DescriptorDistance(dMP,dKF);
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
if(bestDist<=TH_LOW*ratioHamming)
{
vpMatched[bestIdx] = pMP;
vpMatchedKF[bestIdx] = pKFi;
nmatches++;
}
}
return nmatches;
}
/**
* 2d-2d,两帧搜索匹配特征点
* 1、F1特征点在F2中,矩形窗范围内搜索匹配点
* 2、最佳匹配点条件:最佳匹配点要求描述子距离小于阈值,并且要与次佳匹配点拉开距离
* 3、构建梯度方向差直方图,取数量最多前三,其余的删除匹配
* [经验]匹配点怎么搜?窗口搜索,描述子距离判断,梯度方向直方图
* @param F1 前一帧
* @param F2 当前帧
* @param vbPrevMatched 前一帧待匹配特征点 inputAndOutput,output没有用到,可以忽略
* @param vnMatches12 匹配情况,-1表示未匹配上 output
* @param windowSize F1特征点在F2中搜索矩形框半径
* @return 返回匹配数量
*/
int ORBmatcher::SearchForInitialization(Frame &F1, Frame &F2, vector<cv::Point2f> &vbPrevMatched, vector<int> &vnMatches12, int windowSize)
{
// [效率]容器提前初始化好
int nmatches=0;
vnMatches12 = vector<int>(F1.mvKeysUn.size(),-1);
// 梯度方向差直方图,30个bin
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
// [效率]频繁除法用乘法代替
const float factor = 1.0f/HISTO_LENGTH;
vector<int> vMatchedDistance(F2.mvKeysUn.size(),INT_MAX);
vector<int> vnMatches21(F2.mvKeysUn.size(),-1);
// [效率]for循环size,只计算一次
// 遍历F1特征点,寻找F2中的匹配点
for(size_t i1=0, iend1=F1.mvKeysUn.size(); i1<iend1; i1++)
{
cv::KeyPoint kp1 = F1.mvKeysUn[i1];
int level1 = kp1.octave;
if(level1>0)
continue;
// 提取(x,y)位置处windowSize范围矩形窗内的特征点,保存索引
vector<size_t> vIndices2 = F2.GetFeaturesInArea(vbPrevMatched[i1].x,vbPrevMatched[i1].y, windowSize,level1,level1);
if(vIndices2.empty())
continue;
cv::Mat d1 = F1.mDescriptors.row(i1);
int bestDist = INT_MAX;
int bestDist2 = INT_MAX;
int bestIdx2 = -1;
// 遍历F2候选矩形框中的特征点,计算最佳匹配、次佳匹配点
for(vector<size_t>::iterator vit=vIndices2.begin(); vit!=vIndices2.end(); vit++)
{
size_t i2 = *vit;
cv::Mat d2 = F2.mDescriptors.row(i2);
// 描述子距离
int dist = DescriptorDistance(d1,d2);
if(vMatchedDistance[i2]<=dist)
continue;
if(dist<bestDist)
{
bestDist2=bestDist;
bestDist=dist;
bestIdx2=i2;
}
else if(dist<bestDist2)
{
bestDist2=dist;
}
}
// [经验]最佳匹配点要求距离小于阈值,并且要与次佳匹配点拉开距离
if(bestDist<=TH_LOW)
{
if(bestDist<(float)bestDist2*mfNNratio)
{
// [经验]F2中的某个点被F1的多个点匹配到了,删除之前的匹配关系,保留当前匹配
// 为什么不用匹配距离来判断是否保留当前匹配 todo
if(vnMatches21[bestIdx2]>=0)
{
vnMatches12[vnMatches21[bestIdx2]]=-1;
// 如果特征点一对一匹配,nmatches正好是特征点数量,否则会小于特征点数量
nmatches--;
}
// 记录匹配关系
vnMatches12[i1]=bestIdx2;
vnMatches21[bestIdx2]=i1;
vMatchedDistance[bestIdx2]=bestDist;
nmatches++;
// 梯度方向检查
if(mbCheckOrientation)
{
// 梯度方向差,加入直方图对应bin中
float rot = F1.mvKeysUn[i1].angle-F2.mvKeysUn[bestIdx2].angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(i1);
}
}
}
}
// 梯度方向匹配检查
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
// 找出直方图中bin数量最多的前三个
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
// 删除落入非前三数量bin中的匹配关系,认为这些少量的匹配点是离群点
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i==ind1 || i==ind2 || i==ind3)
continue;
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
int idx1 = rotHist[i][j];
if(vnMatches12[idx1]>=0)
{
vnMatches12[idx1]=-1;
nmatches--;
}
}
}
}
//Update prev matched
for(size_t i1=0, iend1=vnMatches12.size(); i1<iend1; i1++)
if(vnMatches12[i1]>=0)
vbPrevMatched[i1]=F2.mvKeysUn[vnMatches12[i1]].pt;
// 最终匹配点数量
return nmatches;
}
/**
* 3d,2d都已知,计算匹配关系;通过bow,对两个关键帧的点进行匹配,用于闭环检测
* 1、两个关键帧的特征点都划分到了词袋树中不同节点中去了
* 2、遍历节点集合,相同的节点才计算匹配点
* 3、在同一节点中,遍历两个关键帧的特征点,计算描述子距离
* 4、描述子距离小于阈值,且次佳与最佳有一定差距,认为匹配上了
* 5、根据特征点angle差值构造的直方图,删除非前三的离群匹配点
* 6、vpMatches12保存数据,当pKF1的特征点 - pKF2的MP
*/
int ORBmatcher::SearchByBoW(KeyFrame *pKF1, KeyFrame *pKF2, vector<MapPoint *> &vpMatches12)
{
// 特征点,特征点词向量,地图点,描述子
const vector<cv::KeyPoint> &vKeysUn1 = pKF1->mvKeysUn;
const DBoW2::FeatureVector &vFeatVec1 = pKF1->mFeatVec;
const vector<MapPoint*> vpMapPoints1 = pKF1->GetMapPointMatches();
const cv::Mat &Descriptors1 = pKF1->mDescriptors;
// 特征点,特征点词向量,地图点,描述子
const vector<cv::KeyPoint> &vKeysUn2 = pKF2->mvKeysUn;
const DBoW2::FeatureVector &vFeatVec2 = pKF2->mFeatVec;
const vector<MapPoint*> vpMapPoints2 = pKF2->GetMapPointMatches();
const cv::Mat &Descriptors2 = pKF2->mDescriptors;
vpMatches12 = vector<MapPoint*>(vpMapPoints1.size(),static_cast<MapPoint*>(NULL));
vector<bool> vbMatched2(vpMapPoints2.size(),false);
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
int nmatches = 0;
DBoW2::FeatureVector::const_iterator f1it = vFeatVec1.begin();
DBoW2::FeatureVector::const_iterator f2it = vFeatVec2.begin();
DBoW2::FeatureVector::const_iterator f1end = vFeatVec1.end();
DBoW2::FeatureVector::const_iterator f2end = vFeatVec2.end();
// 遍历node
while(f1it != f1end && f2it != f2end)
{
// 相同node才有可能匹配
if(f1it->first == f2it->first)
{
for(size_t i1=0, iend1=f1it->second.size(); i1<iend1; i1++)
{
const size_t idx1 = f1it->second[i1];
if(pKF1 -> NLeft != -1 && idx1 >= pKF1 -> mvKeysUn.size()){
continue;
}
MapPoint* pMP1 = vpMapPoints1[idx1];
if(!pMP1)
continue;
if(pMP1->isBad())
continue;
const cv::Mat &d1 = Descriptors1.row(idx1);
int bestDist1=256;
int bestIdx2 =-1 ;
int bestDist2=256;
for(size_t i2=0, iend2=f2it->second.size(); i2<iend2; i2++)
{
const size_t idx2 = f2it->second[i2];
if(pKF2 -> NLeft != -1 && idx2 >= pKF2 -> mvKeysUn.size()){
continue;
}
MapPoint* pMP2 = vpMapPoints2[idx2];
// 已经匹配过的特征点不再参与匹配
if(vbMatched2[idx2] || !pMP2)
continue;
if(pMP2->isBad())
continue;
const cv::Mat &d2 = Descriptors2.row(idx2);
int dist = DescriptorDistance(d1,d2);
if(dist<bestDist1)
{
bestDist2=bestDist1;
bestDist1=dist;
bestIdx2=idx2;
}
else if(dist<bestDist2)
{
bestDist2=dist;
}
}
if(bestDist1<TH_LOW)
{
if(static_cast<float>(bestDist1)<mfNNratio*static_cast<float>(bestDist2))
{
vpMatches12[idx1]=vpMapPoints2[bestIdx2];
vbMatched2[bestIdx2]=true;
if(mbCheckOrientation)
{
float rot = vKeysUn1[idx1].angle-vKeysUn2[bestIdx2].angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(idx1);
}
nmatches++;
}
}
}
f1it++;
f2it++;
}
else if(f1it->first < f2it->first)
{
f1it = vFeatVec1.lower_bound(f2it->first);
}
else
{
f2it = vFeatVec2.lower_bound(f1it->first);
}
}
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i==ind1 || i==ind2 || i==ind3)
continue;
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
vpMatches12[rotHist[i][j]]=static_cast<MapPoint*>(NULL);
nmatches--;
}
}
}
return nmatches;
}
/**
* 2d-2d,利用基础矩阵极线约束,bow加速匹配两帧特征点,vMatchedPairs存KF1、KF2特征点id
* 1、计算KF1相机在KF2下面的像素投影,极点
* 2、遍历两帧对应的词向量节点,计算描述子距离
* 3、描述子距离小于阈值,点到极点距离要够大(MP离KF1才足够远),极线约束满足,特征点方向直方图过滤
*/
int ORBmatcher::SearchForTriangulation(KeyFrame *pKF1, KeyFrame *pKF2, cv::Mat F12,
vector<pair<size_t, size_t> > &vMatchedPairs, const bool bOnlyStereo, const bool bCoarse)
{
// 特征点词向量
const DBoW2::FeatureVector &vFeatVec1 = pKF1->mFeatVec;
const DBoW2::FeatureVector &vFeatVec2 = pKF2->mFeatVec;
//Compute epipole in second image
cv::Mat Cw = pKF1->GetCameraCenter();
cv::Mat R2w = pKF2->GetRotation();
cv::Mat t2w = pKF2->GetTranslation();
// KF1相机光心在KF2系的坐标
cv::Mat C2 = R2w*Cw+t2w;
// KF1相机在KF2下面的像素投影,极点
cv::Point2f ep = pKF2->mpCamera->project(C2);
cv::Mat R1w = pKF1->GetRotation();
cv::Mat t1w = pKF1->GetTranslation();
cv::Mat R12;
cv::Mat t12;
cv::Mat Rll,Rlr,Rrl,Rrr;
cv::Mat tll,tlr,trl,trr;
GeometricCamera* pCamera1 = pKF1->mpCamera, *pCamera2 = pKF2->mpCamera;
// 单目,两帧之间的变换
if(!pKF1->mpCamera2 && !pKF2->mpCamera2){
R12 = R1w*R2w.t();
t12 = -R1w*R2w.t()*t2w+t1w;
}
else{
// 双目
Rll = pKF1->GetRotation() * pKF2->GetRotation().t();
Rlr = pKF1->GetRotation() * pKF2->GetRightRotation().t();
Rrl = pKF1->GetRightRotation() * pKF2->GetRotation().t();
Rrr = pKF1->GetRightRotation() * pKF2->GetRightRotation().t();
tll = pKF1->GetRotation() * (-pKF2->GetRotation().t() * pKF2->GetTranslation()) + pKF1->GetTranslation();
tlr = pKF1->GetRotation() * (-pKF2->GetRightRotation().t() * pKF2->GetRightTranslation()) + pKF1->GetTranslation();
trl = pKF1->GetRightRotation() * (-pKF2->GetRotation().t() * pKF2->GetTranslation()) + pKF1->GetRightTranslation();
trr = pKF1->GetRightRotation() * (-pKF2->GetRightRotation().t() * pKF2->GetRightTranslation()) + pKF1->GetRightTranslation();
}
// Find matches between not tracked keypoints
// Matching speed-up by ORB Vocabulary
// Compare only ORB that share the same node
int nmatches=0;
vector<bool> vbMatched2(pKF2->N,false);
vector<int> vMatches12(pKF1->N,-1);
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
DBoW2::FeatureVector::const_iterator f1it = vFeatVec1.begin();
DBoW2::FeatureVector::const_iterator f2it = vFeatVec2.begin();
DBoW2::FeatureVector::const_iterator f1end = vFeatVec1.end();
DBoW2::FeatureVector::const_iterator f2end = vFeatVec2.end();
// 遍历两帧对应的词向量节点
while(f1it!=f1end && f2it!=f2end)
{
if(f1it->first == f2it->first)
{
// 遍历节点下的特征点
for(size_t i1=0, iend1=f1it->second.size(); i1<iend1; i1++)
{
const size_t idx1 = f1it->second[i1];
MapPoint* pMP1 = pKF1->GetMapPoint(idx1);
// If there is already a MapPoint skip
if(pMP1)
{
continue;
}
const bool bStereo1 = (!pKF1->mpCamera2 && pKF1->mvuRight[idx1]>=0);
if(bOnlyStereo)
if(!bStereo1)
continue;
const cv::KeyPoint &kp1 = (pKF1 -> NLeft == -1) ? pKF1->mvKeysUn[idx1]
: (idx1 < pKF1 -> NLeft) ? pKF1 -> mvKeys[idx1]
: pKF1 -> mvKeysRight[idx1 - pKF1 -> NLeft];
const bool bRight1 = (pKF1 -> NLeft == -1 || idx1 < pKF1 -> NLeft) ? false
: true;
//if(bRight1) continue;
const cv::Mat &d1 = pKF1->mDescriptors.row(idx1);
int bestDist = TH_LOW;
int bestIdx2 = -1;
for(size_t i2=0, iend2=f2it->second.size(); i2<iend2; i2++)
{
size_t idx2 = f2it->second[i2];
MapPoint* pMP2 = pKF2->GetMapPoint(idx2);
// If we have already matched or there is a MapPoint skip
if(vbMatched2[idx2] || pMP2)
continue;
const bool bStereo2 = (!pKF2->mpCamera2 && pKF2->mvuRight[idx2]>=0);
if(bOnlyStereo)
if(!bStereo2)
continue;
const cv::Mat &d2 = pKF2->mDescriptors.row(idx2);
const int dist = DescriptorDistance(d1,d2);
// 描述子距离需要小于阈值
if(dist>TH_LOW || dist>bestDist)
continue;
const cv::KeyPoint &kp2 = (pKF2 -> NLeft == -1) ? pKF2->mvKeysUn[idx2]
: (idx2 < pKF2 -> NLeft) ? pKF2 -> mvKeys[idx2]
: pKF2 -> mvKeysRight[idx2 - pKF2 -> NLeft];
const bool bRight2 = (pKF2 -> NLeft == -1 || idx2 < pKF2 -> NLeft) ? false
: true;
if(!bStereo1 && !bStereo2 && !pKF1->mpCamera2)
{
// 特征点到极点的距离,如果太近,表示对应MP离KF1太近
const float distex = ep.x-kp2.pt.x;
const float distey = ep.y-kp2.pt.y;
if(distex*distex+distey*distey<100*pKF2->mvScaleFactors[kp2.octave])
{
continue;
}
}
if(pKF1->mpCamera2 && pKF2->mpCamera2){
if(bRight1 && bRight2){
R12 = Rrr;
t12 = trr;
pCamera1 = pKF1->mpCamera2;
pCamera2 = pKF2->mpCamera2;
}
else if(bRight1 && !bRight2){
R12 = Rrl;
t12 = trl;
pCamera1 = pKF1->mpCamera2;
pCamera2 = pKF2->mpCamera;
}
else if(!bRight1 && bRight2){
R12 = Rlr;
t12 = tlr;
pCamera1 = pKF1->mpCamera;
pCamera2 = pKF2->mpCamera2;
}
else{
R12 = Rll;
t12 = tll;
pCamera1 = pKF1->mpCamera;
pCamera2 = pKF2->mpCamera;
}
}
// 点到极线距离小于阈值,认为匹配上了
if(pCamera1->epipolarConstrain(pCamera2,kp1,kp2,R12,t12,pKF1->mvLevelSigma2[kp1.octave],pKF2->mvLevelSigma2[kp2.octave])||bCoarse) // MODIFICATION_2
{
bestIdx2 = idx2;
bestDist = dist;
}
}
// 特征点旋转检查
if(bestIdx2>=0)
{
const cv::KeyPoint &kp2 = (pKF2 -> NLeft == -1) ? pKF2->mvKeysUn[bestIdx2]
: (bestIdx2 < pKF2 -> NLeft) ? pKF2 -> mvKeys[bestIdx2]
: pKF2 -> mvKeysRight[bestIdx2 - pKF2 -> NLeft];
vMatches12[idx1]=bestIdx2;
nmatches++;
if(mbCheckOrientation)
{
float rot = kp1.angle-kp2.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(idx1);
}
}
}
f1it++;
f2it++;
}
else if(f1it->first < f2it->first)
{
f1it = vFeatVec1.lower_bound(f2it->first);
}
else
{
f2it = vFeatVec2.lower_bound(f1it->first);
}
}
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i==ind1 || i==ind2 || i==ind3)
continue;
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
vMatches12[rotHist[i][j]]=-1;
nmatches--;
}
}
}
vMatchedPairs.clear();
vMatchedPairs.reserve(nmatches);
for(size_t i=0, iend=vMatches12.size(); i<iend; i++)
{
if(vMatches12[i]<0)
continue;
vMatchedPairs.push_back(make_pair(i,vMatches12[i]));
}
return nmatches;
}
/**
* 同上,多一个匹配之后进行三角化,vMatchedPoints存KF1特征点id - 三角化点
*/
int ORBmatcher::SearchForTriangulation(KeyFrame *pKF1, KeyFrame *pKF2, cv::Mat F12,
vector<pair<size_t, size_t> > &vMatchedPairs, const bool bOnlyStereo, vector<cv::Mat> &vMatchedPoints)
{
const DBoW2::FeatureVector &vFeatVec1 = pKF1->mFeatVec;
const DBoW2::FeatureVector &vFeatVec2 = pKF2->mFeatVec;
//Compute epipole in second image
cv::Mat Cw = pKF1->GetCameraCenter();
cv::Mat R2w = pKF2->GetRotation();
cv::Mat t2w = pKF2->GetTranslation();
cv::Mat C2 = R2w*Cw+t2w;
cv::Point2f ep = pKF2->mpCamera->project(C2);
cv::Mat R1w = pKF1->GetRotation();
cv::Mat t1w = pKF1->GetTranslation();
GeometricCamera* pCamera1 = pKF1->mpCamera, *pCamera2 = pKF2->mpCamera;
cv::Mat Tcw1,Tcw2;
// Find matches between not tracked keypoints
// Matching speed-up by ORB Vocabulary
// Compare only ORB that share the same node
int nmatches=0;
vector<bool> vbMatched2(pKF2->N,false);
vector<int> vMatches12(pKF1->N,-1);
vector<cv::Mat> vMatchesPoints12(pKF1 -> N);
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
DBoW2::FeatureVector::const_iterator f1it = vFeatVec1.begin();
DBoW2::FeatureVector::const_iterator f2it = vFeatVec2.begin();
DBoW2::FeatureVector::const_iterator f1end = vFeatVec1.end();
DBoW2::FeatureVector::const_iterator f2end = vFeatVec2.end();
int right = 0;
while(f1it!=f1end && f2it!=f2end)
{
if(f1it->first == f2it->first)
{
for(size_t i1=0, iend1=f1it->second.size(); i1<iend1; i1++)
{
const size_t idx1 = f1it->second[i1];
MapPoint* pMP1 = pKF1->GetMapPoint(idx1);
// If there is already a MapPoint skip
if(pMP1)
continue;
const cv::KeyPoint &kp1 = (pKF1 -> NLeft == -1) ? pKF1->mvKeysUn[idx1]
: (idx1 < pKF1 -> NLeft) ? pKF1 -> mvKeys[idx1]
: pKF1 -> mvKeysRight[idx1 - pKF1 -> NLeft];
const bool bRight1 = (pKF1 -> NLeft == -1 || idx1 < pKF1 -> NLeft) ? false
: true;
const cv::Mat &d1 = pKF1->mDescriptors.row(idx1);
int bestDist = TH_LOW;
int bestIdx2 = -1;
cv::Mat bestPoint;
for(size_t i2=0, iend2=f2it->second.size(); i2<iend2; i2++)
{
size_t idx2 = f2it->second[i2];
MapPoint* pMP2 = pKF2->GetMapPoint(idx2);
// If we have already matched or there is a MapPoint skip
if(vbMatched2[idx2] || pMP2)
continue;
const cv::Mat &d2 = pKF2->mDescriptors.row(idx2);
const int dist = DescriptorDistance(d1,d2);
if(dist>TH_LOW || dist>bestDist){
continue;
}
const cv::KeyPoint &kp2 = (pKF2 -> NLeft == -1) ? pKF2->mvKeysUn[idx2]
: (idx2 < pKF2 -> NLeft) ? pKF2 -> mvKeys[idx2]
: pKF2 -> mvKeysRight[idx2 - pKF2 -> NLeft];
const bool bRight2 = (pKF2 -> NLeft == -1 || idx2 < pKF2 -> NLeft) ? false
: true;
if(bRight1){
Tcw1 = pKF1->GetRightPose();
pCamera1 = pKF1->mpCamera2;
} else{
Tcw1 = pKF1->GetPose();
pCamera1 = pKF1->mpCamera;
}
if(bRight2){
Tcw2 = pKF2->GetRightPose();
pCamera2 = pKF2->mpCamera2;
} else{
Tcw2 = pKF2->GetPose();
pCamera2 = pKF2->mpCamera;
}
cv::Mat x3D;
if(pCamera1->matchAndtriangulate(kp1,kp2,pCamera2,Tcw1,Tcw2,pKF1->mvLevelSigma2[kp1.octave],pKF2->mvLevelSigma2[kp2.octave],x3D)){
bestIdx2 = idx2;
bestDist = dist;
bestPoint = x3D;
}
}
if(bestIdx2>=0)
{
const cv::KeyPoint &kp2 = (pKF2 -> NLeft == -1) ? pKF2->mvKeysUn[bestIdx2]
: (bestIdx2 < pKF2 -> NLeft) ? pKF2 -> mvKeys[bestIdx2]
: pKF2 -> mvKeysRight[bestIdx2 - pKF2 -> NLeft];
vMatches12[idx1]=bestIdx2;
vMatchesPoints12[idx1] = bestPoint;
nmatches++;
if(bRight1) right++;
if(mbCheckOrientation)
{
float rot = kp1.angle-kp2.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(idx1);
}
}
}
f1it++;
f2it++;
}
else if(f1it->first < f2it->first)
{
f1it = vFeatVec1.lower_bound(f2it->first);
}
else
{
f2it = vFeatVec2.lower_bound(f1it->first);
}
}
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i==ind1 || i==ind2 || i==ind3)
continue;
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
vMatches12[rotHist[i][j]]=-1;
nmatches--;
}
}
}
vMatchedPairs.clear();
vMatchedPairs.reserve(nmatches);
for(size_t i=0, iend=vMatches12.size(); i<iend; i++)
{
if(vMatches12[i]<0)
continue;
vMatchedPairs.push_back(make_pair(i,vMatches12[i]));
vMatchedPoints.push_back(vMatchesPoints12[i]);
}
return nmatches;
}
/**
* 关键帧与Map点融合,更新MP
* MP集合投影到KF中,寻找匹配2d点,如果该2d点有自己对应的MP1,那么比较MP与MP1的观测,谁的观测多,谁就留下,另一个被替换;如果没有MP1,就添加一个MP
*/
int ORBmatcher::Fuse(KeyFrame *pKF, const vector<MapPoint *> &vpMapPoints, const float th, const bool bRight)
{
cv::Mat Rcw,tcw, Ow;
GeometricCamera* pCamera;
if(bRight){
Rcw = pKF->GetRightRotation();
tcw = pKF->GetRightTranslation();
Ow = pKF->GetRightCameraCenter();
pCamera = pKF->mpCamera2;
}
else{
Rcw = pKF->GetRotation();
tcw = pKF->GetTranslation();
Ow = pKF->GetCameraCenter();
pCamera = pKF->mpCamera;
}
const float &fx = pKF->fx;
const float &fy = pKF->fy;
const float &cx = pKF->cx;
const float &cy = pKF->cy;
const float &bf = pKF->mbf;
int nFused=0;
const int nMPs = vpMapPoints.size();
// For debbuging
int count_notMP = 0, count_bad=0, count_isinKF = 0, count_negdepth = 0, count_notinim = 0, count_dist = 0, count_normal=0, count_notidx = 0, count_thcheck = 0;
// 遍历MP集合
for(int i=0; i<nMPs; i++)
{
MapPoint* pMP = vpMapPoints[i];
if(!pMP)
{
count_notMP++;
continue;
}
/*if(pMP->isBad() || pMP->IsInKeyFrame(pKF))
continue;*/
if(pMP->isBad())
{
count_bad++;
continue;
}
else if(pMP->IsInKeyFrame(pKF))
{
count_isinKF++;
continue;
}
cv::Mat p3Dw = pMP->GetWorldPos();
cv::Mat p3Dc = Rcw*p3Dw + tcw;
// Depth must be positive
if(p3Dc.at<float>(2)<0.0f)
{
count_negdepth++;
continue;
}
const float invz = 1/p3Dc.at<float>(2);
const float x = p3Dc.at<float>(0);
const float y = p3Dc.at<float>(1);
const float z = p3Dc.at<float>(2);
const cv::Point2f uv = pCamera->project(cv::Point3f(x,y,z));
// Point must be inside the image
if(!pKF->IsInImage(uv.x,uv.y))
{
count_notinim++;
continue;
}
const float ur = uv.x-bf*invz;
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
cv::Mat PO = p3Dw-Ow;
const float dist3D = cv::norm(PO);
// Depth must be inside the scale pyramid of the image
if(dist3D<minDistance || dist3D>maxDistance)
{
count_dist++;
continue;
}
// Viewing angle must be less than 60 deg
cv::Mat Pn = pMP->GetNormal();
if(PO.dot(Pn)<0.5*dist3D)
{
count_normal++;
continue;
}
int nPredictedLevel = pMP->PredictScale(dist3D,pKF);
// Search in a radius
const float radius = th*pKF->mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices = pKF->GetFeaturesInArea(uv.x,uv.y,radius,bRight);
if(vIndices.empty())
{
count_notidx++;
continue;
}
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx = -1;
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
size_t idx = *vit;
const cv::KeyPoint &kp = (pKF -> NLeft == -1) ? pKF->mvKeysUn[idx]
: (!bRight) ? pKF -> mvKeys[idx]
: pKF -> mvKeysRight[idx];
const int &kpLevel= kp.octave;
if(kpLevel<nPredictedLevel-1 || kpLevel>nPredictedLevel)
continue;
if(pKF->mvuRight[idx]>=0)
{
// Check reprojection error in stereo
const float &kpx = kp.pt.x;
const float &kpy = kp.pt.y;
const float &kpr = pKF->mvuRight[idx];
const float ex = uv.x-kpx;
const float ey = uv.y-kpy;
const float er = ur-kpr;
const float e2 = ex*ex+ey*ey+er*er;
if(e2*pKF->mvInvLevelSigma2[kpLevel]>7.8)
continue;
}
else
{
const float &kpx = kp.pt.x;
const float &kpy = kp.pt.y;
const float ex = uv.x-kpx;
const float ey = uv.y-kpy;
const float e2 = ex*ex+ey*ey;
if(e2*pKF->mvInvLevelSigma2[kpLevel]>5.99)
continue;
}
if(bRight) idx += pKF->NLeft;
const cv::Mat &dKF = pKF->mDescriptors.row(idx);
const int dist = DescriptorDistance(dMP,dKF);
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
// If there is already a MapPoint replace otherwise add new measurement
if(bestDist<=TH_LOW)
{
// 关键帧的MP
MapPoint* pMPinKF = pKF->GetMapPoint(bestIdx);
if(pMPinKF)
{
if(!pMPinKF->isBad())
{
// 谁的观测多,谁就保留
if(pMPinKF->Observations()>pMP->Observations())
pMP->Replace(pMPinKF);
else
pMPinKF->Replace(pMP);
}
}
else
{
// 添加MP与特征点对应关系
pMP->AddObservation(pKF,bestIdx);
pKF->AddMapPoint(pMP,bestIdx);
}
nFused++;
}
else
count_thcheck++;
}
/*cout << "count_notMP = " << count_notMP << endl;
cout << "count_bad = " << count_bad << endl;
cout << "count_isinKF = " << count_isinKF << endl;
cout << "count_negdepth = " << count_negdepth << endl;
cout << "count_notinim = " << count_notinim << endl;
cout << "count_dist = " << count_dist << endl;
cout << "count_normal = " << count_normal << endl;
cout << "count_notidx = " << count_notidx << endl;
cout << "count_thcheck = " << count_thcheck << endl;
cout << "tot fused points: " << nFused << endl;*/
return nFused;
}
/**
* 闭环帧及其共视关键帧Map点,与当前关键帧融合,更新MP
*/
int ORBmatcher::Fuse(KeyFrame *pKF, cv::Mat Scw, const vector<MapPoint *> &vpPoints, float th, vector<MapPoint *> &vpReplacePoint)
{
// Get Calibration Parameters for later projection
const float &fx = pKF->fx;
const float &fy = pKF->fy;
const float &cx = pKF->cx;
const float &cy = pKF->cy;
// Decompose Scw
cv::Mat sRcw = Scw.rowRange(0,3).colRange(0,3);
const float scw = sqrt(sRcw.row(0).dot(sRcw.row(0)));
cv::Mat Rcw = sRcw/scw;
cv::Mat tcw = Scw.rowRange(0,3).col(3)/scw;
cv::Mat Ow = -Rcw.t()*tcw;
// Set of MapPoints already found in the KeyFrame
const set<MapPoint*> spAlreadyFound = pKF->GetMapPoints();
int nFused=0;
const int nPoints = vpPoints.size();
// For each candidate MapPoint project and match
for(int iMP=0; iMP<nPoints; iMP++)
{
MapPoint* pMP = vpPoints[iMP];
// Discard Bad MapPoints and already found
if(pMP->isBad() || spAlreadyFound.count(pMP))
continue;
// Get 3D Coords.
cv::Mat p3Dw = pMP->GetWorldPos();
// Transform into Camera Coords.
cv::Mat p3Dc = Rcw*p3Dw+tcw;
// Depth must be positive
if(p3Dc.at<float>(2)<0.0f)
continue;
// Project into Image
const float x = p3Dc.at<float>(0);
const float y = p3Dc.at<float>(1);
const float z = p3Dc.at<float>(2);
const cv::Point2f uv = pKF->mpCamera->project(cv::Point3f(x,y,z));
// Point must be inside the image
if(!pKF->IsInImage(uv.x,uv.y))
continue;
// Depth must be inside the scale pyramid of the image
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
cv::Mat PO = p3Dw-Ow;
const float dist3D = cv::norm(PO);
if(dist3D<minDistance || dist3D>maxDistance)
continue;
// Viewing angle must be less than 60 deg
cv::Mat Pn = pMP->GetNormal();
if(PO.dot(Pn)<0.5*dist3D)
continue;
// Compute predicted scale level
const int nPredictedLevel = pMP->PredictScale(dist3D,pKF);
// Search in a radius
const float radius = th*pKF->mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices = pKF->GetFeaturesInArea(uv.x,uv.y,radius);
if(vIndices.empty())
continue;
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = INT_MAX;
int bestIdx = -1;
for(vector<size_t>::const_iterator vit=vIndices.begin(); vit!=vIndices.end(); vit++)
{
const size_t idx = *vit;
const int &kpLevel = pKF->mvKeysUn[idx].octave;
if(kpLevel<nPredictedLevel-1 || kpLevel>nPredictedLevel)
continue;
const cv::Mat &dKF = pKF->mDescriptors.row(idx);
int dist = DescriptorDistance(dMP,dKF);
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
// If there is already a MapPoint replace otherwise add new measurement
if(bestDist<=TH_LOW)
{
MapPoint* pMPinKF = pKF->GetMapPoint(bestIdx);
if(pMPinKF)
{
if(!pMPinKF->isBad())
vpReplacePoint[iMP] = pMPinKF;
}
else
{
pMP->AddObservation(pKF,bestIdx);
pKF->AddMapPoint(pMP,bestIdx);
}
nFused++;
}
}
return nFused;
}
/**
* 已知两关键帧的变换,计算新匹配点,忽略已经匹配过的点
* 1、KF1的MP投影到KF2中,搜索窗搜索特征点,计算描述子距离,筛选
* 2、KF2的MP投影到KF1中,搜索窗搜索特征点,计算描述子距离,筛选
* 3、综合得到最终匹配结果,存vpMatches12
*/
int ORBmatcher::SearchBySim3(KeyFrame *pKF1, KeyFrame *pKF2, vector<MapPoint*> &vpMatches12,
const float &s12, const cv::Mat &R12, const cv::Mat &t12, const float th)
{
const float &fx = pKF1->fx;
const float &fy = pKF1->fy;
const float &cx = pKF1->cx;
const float &cy = pKF1->cy;
// Camera 1 from world
cv::Mat R1w = pKF1->GetRotation();
cv::Mat t1w = pKF1->GetTranslation();
//Camera 2 from world
cv::Mat R2w = pKF2->GetRotation();
cv::Mat t2w = pKF2->GetTranslation();
//Transformation between cameras
cv::Mat sR12 = s12*R12;
cv::Mat sR21 = (1.0/s12)*R12.t();
cv::Mat t21 = -sR21*t12;
const vector<MapPoint*> vpMapPoints1 = pKF1->GetMapPointMatches();
const int N1 = vpMapPoints1.size();
const vector<MapPoint*> vpMapPoints2 = pKF2->GetMapPointMatches();
const int N2 = vpMapPoints2.size();
vector<bool> vbAlreadyMatched1(N1,false);
vector<bool> vbAlreadyMatched2(N2,false);
// 已经匹配的点记录一下
for(int i=0; i<N1; i++)
{
MapPoint* pMP = vpMatches12[i];
if(pMP)
{
vbAlreadyMatched1[i]=true;
int idx2 = get<0>(pMP->GetIndexInKeyFrame(pKF2));
if(idx2>=0 && idx2<N2)
vbAlreadyMatched2[idx2]=true;
}
}
vector<int> vnMatch1(N1,-1);
vector<int> vnMatch2(N2,-1);
// Transform from KF1 to KF2 and search
for(int i1=0; i1<N1; i1++)
{
MapPoint* pMP = vpMapPoints1[i1];
if(!pMP || vbAlreadyMatched1[i1])
continue;
if(pMP->isBad())
continue;
cv::Mat p3Dw = pMP->GetWorldPos();
cv::Mat p3Dc1 = R1w*p3Dw + t1w;
cv::Mat p3Dc2 = sR21*p3Dc1 + t21;
// Depth must be positive
if(p3Dc2.at<float>(2)<0.0)
continue;
const float invz = 1.0/p3Dc2.at<float>(2);
const float x = p3Dc2.at<float>(0)*invz;
const float y = p3Dc2.at<float>(1)*invz;
const float u = fx*x+cx;
const float v = fy*y+cy;
// Point must be inside the image
if(!pKF2->IsInImage(u,v))
continue;
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
const float dist3D = cv::norm(p3Dc2);
// Depth must be inside the scale invariance region
if(dist3D<minDistance || dist3D>maxDistance )
continue;
// Compute predicted octave
const int nPredictedLevel = pMP->PredictScale(dist3D,pKF2);
// Search in a radius
const float radius = th*pKF2->mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices = pKF2->GetFeaturesInArea(u,v,radius);
if(vIndices.empty())
continue;
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = INT_MAX;
int bestIdx = -1;
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
const cv::KeyPoint &kp = pKF2->mvKeysUn[idx];
if(kp.octave<nPredictedLevel-1 || kp.octave>nPredictedLevel)
continue;
const cv::Mat &dKF = pKF2->mDescriptors.row(idx);
const int dist = DescriptorDistance(dMP,dKF);
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
if(bestDist<=TH_HIGH)
{
vnMatch1[i1]=bestIdx;
}
}
// Transform from KF2 to KF2 and search
for(int i2=0; i2<N2; i2++)
{
MapPoint* pMP = vpMapPoints2[i2];
if(!pMP || vbAlreadyMatched2[i2])
continue;
if(pMP->isBad())
continue;
cv::Mat p3Dw = pMP->GetWorldPos();
cv::Mat p3Dc2 = R2w*p3Dw + t2w;
cv::Mat p3Dc1 = sR12*p3Dc2 + t12;
// Depth must be positive
if(p3Dc1.at<float>(2)<0.0)
continue;
const float invz = 1.0/p3Dc1.at<float>(2);
const float x = p3Dc1.at<float>(0)*invz;
const float y = p3Dc1.at<float>(1)*invz;
const float u = fx*x+cx;
const float v = fy*y+cy;
// Point must be inside the image
if(!pKF1->IsInImage(u,v))
continue;
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
const float dist3D = cv::norm(p3Dc1);
// Depth must be inside the scale pyramid of the image
if(dist3D<minDistance || dist3D>maxDistance)
continue;
// Compute predicted octave
const int nPredictedLevel = pMP->PredictScale(dist3D,pKF1);
// Search in a radius of 2.5*sigma(ScaleLevel)
const float radius = th*pKF1->mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices = pKF1->GetFeaturesInArea(u,v,radius);
if(vIndices.empty())
continue;
// Match to the most similar keypoint in the radius
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = INT_MAX;
int bestIdx = -1;
for(vector<size_t>::const_iterator vit=vIndices.begin(), vend=vIndices.end(); vit!=vend; vit++)
{
const size_t idx = *vit;
const cv::KeyPoint &kp = pKF1->mvKeysUn[idx];
if(kp.octave<nPredictedLevel-1 || kp.octave>nPredictedLevel)
continue;
const cv::Mat &dKF = pKF1->mDescriptors.row(idx);
const int dist = DescriptorDistance(dMP,dKF);
if(dist<bestDist)
{
bestDist = dist;
bestIdx = idx;
}
}
if(bestDist<=TH_HIGH)
{
vnMatch2[i2]=bestIdx;
}
}
// Check agreement
int nFound = 0;
for(int i1=0; i1<N1; i1++)
{
int idx2 = vnMatch1[i1];
if(idx2>=0)
{
int idx1 = vnMatch2[idx2];
if(idx1==i1)
{
vpMatches12[i1] = vpMapPoints2[idx2];
nFound++;
}
}
}
return nFound;
}
/**
* 3d-2d,相邻帧跟踪,前一帧MP在当前帧中寻找匹配2d点
* 1、计算当前帧在前一帧中的位置,判断相对前一帧是向前运动,还是向后运动,用于后面搜索特征点的层级判断
* 2、前一帧MP投影到当前帧中,根据金字塔层级确定搜索半径,根据前向、后向运动确定搜索特征点层级范围,在当前帧搜索窗中搜索候选特征点
* 3、描述子距离小于阈值,方向直方图过滤
* 4、更新当前帧mvpMapPoints,当前帧特征点id,前一帧MP
*/
int ORBmatcher::SearchByProjection(Frame &CurrentFrame, const Frame &LastFrame, const float th, const bool bMono)
{
int nmatches = 0;
// Rotation Histogram (to check rotation consistency)
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
const cv::Mat Rcw = CurrentFrame.mTcw.rowRange(0,3).colRange(0,3);
const cv::Mat tcw = CurrentFrame.mTcw.rowRange(0,3).col(3);
const cv::Mat twc = -Rcw.t()*tcw;
const cv::Mat Rlw = LastFrame.mTcw.rowRange(0,3).colRange(0,3);
const cv::Mat tlw = LastFrame.mTcw.rowRange(0,3).col(3);
// 当前帧在前一帧中的位置
const cv::Mat tlc = Rlw*twc+tlw;
// [经验]z轴是从相机指向场景的,如果z大于零,表示当前帧在前一帧的z轴正方向上,表示相对于前一帧向靠近场景的方向运动了
const bool bForward = tlc.at<float>(2)>CurrentFrame.mb && !bMono;
const bool bBackward = -tlc.at<float>(2)>CurrentFrame.mb && !bMono;
// 遍历前一帧的MP
for(int i=0; i<LastFrame.N; i++)
{
MapPoint* pMP = LastFrame.mvpMapPoints[i];
if(pMP)
{
if(!LastFrame.mvbOutlier[i])
{
// Project
// 投影到当前相机坐标系
cv::Mat x3Dw = pMP->GetWorldPos();
cv::Mat x3Dc = Rcw*x3Dw+tcw;
const float xc = x3Dc.at<float>(0);
const float yc = x3Dc.at<float>(1);
const float invzc = 1.0/x3Dc.at<float>(2);
// 深度值判断
if(invzc<0)
continue;
cv::Point2f uv = CurrentFrame.mpCamera->project(x3Dc);
// 像素边界判断
if(uv.x<CurrentFrame.mnMinX || uv.x>CurrentFrame.mnMaxX)
continue;
if(uv.y<CurrentFrame.mnMinY || uv.y>CurrentFrame.mnMaxY)
continue;
// 前一帧对应特征点的金字塔层级
// LastFrame.Nleft == -1表示单目,i < LastFrame.Nleft表示双目的左目
int nLastOctave = (LastFrame.Nleft == -1 || i < LastFrame.Nleft) ? LastFrame.mvKeys[i].octave
: LastFrame.mvKeysRight[i - LastFrame.Nleft].octave;
// Search in a window. Size depends on scale
// 搜索窗半径,乘上层级尺度
float radius = th*CurrentFrame.mvScaleFactors[nLastOctave];
vector<size_t> vIndices2;
/**
* 以向前运动为例,看到的图像是放大的,那么之前的某个特征点,在相同的搜索半径下,需要在更高的尺度下(相同的半径,汇聚更多点)才能被辨认出来。
* 举个例子,前一时刻我们找到了一个特征点,看上去就是一个点;当前时刻图像放大了,这个点被放大了,夸张一点发散成一块马赛克了,如果想要
* 找到之前的那个点,就需要把图像汇聚一下,把马赛克块重新汇聚成一个点,等价于相同的搜索半径下,我们要到更高层级的金字塔图像中去找特征点。
* 否则,相同的搜索半径下,还是在当前层级中找,找到的只是马赛克中的某个点。
*/
if(bForward)
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, nLastOctave);
else if(bBackward)
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, 0, nLastOctave);
else
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, nLastOctave-1, nLastOctave+1);
if(vIndices2.empty())
continue;
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx2 = -1;
for(vector<size_t>::const_iterator vit=vIndices2.begin(), vend=vIndices2.end(); vit!=vend; vit++)
{
const size_t i2 = *vit;
if(CurrentFrame.mvpMapPoints[i2])
if(CurrentFrame.mvpMapPoints[i2]->Observations()>0)
continue;
if(CurrentFrame.Nleft == -1 && CurrentFrame.mvuRight[i2]>0)
{
const float ur = uv.x - CurrentFrame.mbf*invzc;
const float er = fabs(ur - CurrentFrame.mvuRight[i2]);
if(er>radius)
continue;
}
const cv::Mat &d = CurrentFrame.mDescriptors.row(i2);
const int dist = DescriptorDistance(dMP,d);
if(dist<bestDist)
{
bestDist=dist;
bestIdx2=i2;
}
}
if(bestDist<=TH_HIGH)
{
CurrentFrame.mvpMapPoints[bestIdx2]=pMP;
nmatches++;
if(mbCheckOrientation)
{
cv::KeyPoint kpLF = (LastFrame.Nleft == -1) ? LastFrame.mvKeysUn[i]
: (i < LastFrame.Nleft) ? LastFrame.mvKeys[i]
: LastFrame.mvKeysRight[i - LastFrame.Nleft];
cv::KeyPoint kpCF = (CurrentFrame.Nleft == -1) ? CurrentFrame.mvKeysUn[bestIdx2]
: (bestIdx2 < CurrentFrame.Nleft) ? CurrentFrame.mvKeys[bestIdx2]
: CurrentFrame.mvKeysRight[bestIdx2 - CurrentFrame.Nleft];
float rot = kpLF.angle-kpCF.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(bestIdx2);
}
}
if(CurrentFrame.Nleft != -1){
cv::Mat x3Dr = CurrentFrame.mTrl.colRange(0,3).rowRange(0,3) * x3Dc + CurrentFrame.mTrl.col(3);
cv::Point2f uv = CurrentFrame.mpCamera->project(x3Dr);
int nLastOctave = (LastFrame.Nleft == -1 || i < LastFrame.Nleft) ? LastFrame.mvKeys[i].octave
: LastFrame.mvKeysRight[i - LastFrame.Nleft].octave;
// Search in a window. Size depends on scale
float radius = th*CurrentFrame.mvScaleFactors[nLastOctave];
vector<size_t> vIndices2;
if(bForward)
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, nLastOctave, -1,true);
else if(bBackward)
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, 0, nLastOctave, true);
else
vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x,uv.y, radius, nLastOctave-1, nLastOctave+1, true);
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx2 = -1;
for(vector<size_t>::const_iterator vit=vIndices2.begin(), vend=vIndices2.end(); vit!=vend; vit++)
{
const size_t i2 = *vit;
if(CurrentFrame.mvpMapPoints[i2 + CurrentFrame.Nleft])
if(CurrentFrame.mvpMapPoints[i2 + CurrentFrame.Nleft]->Observations()>0)
continue;
const cv::Mat &d = CurrentFrame.mDescriptors.row(i2 + CurrentFrame.Nleft);
const int dist = DescriptorDistance(dMP,d);
if(dist<bestDist)
{
bestDist=dist;
bestIdx2=i2;
}
}
if(bestDist<=TH_HIGH)
{
CurrentFrame.mvpMapPoints[bestIdx2 + CurrentFrame.Nleft]=pMP;
nmatches++;
if(mbCheckOrientation)
{
cv::KeyPoint kpLF = (LastFrame.Nleft == -1) ? LastFrame.mvKeysUn[i]
: (i < LastFrame.Nleft) ? LastFrame.mvKeys[i]
: LastFrame.mvKeysRight[i - LastFrame.Nleft];
cv::KeyPoint kpCF = CurrentFrame.mvKeysRight[bestIdx2];
float rot = kpLF.angle-kpCF.angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(bestIdx2 + CurrentFrame.Nleft);
}
}
}
}
}
}
//Apply rotation consistency
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i!=ind1 && i!=ind2 && i!=ind3)
{
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
CurrentFrame.mvpMapPoints[rotHist[i][j]]=static_cast<MapPoint*>(NULL);
nmatches--;
}
}
}
}
return nmatches;
}
/**
* 3d-2d,关键帧MP在当前帧中寻找匹配2d点
* 1、投影之后,深度值满足距离范围
* 2、描述子距离小于阈值,方向直方图过滤
*/
int ORBmatcher::SearchByProjection(Frame &CurrentFrame, KeyFrame *pKF, const set<MapPoint*> &sAlreadyFound, const float th , const int ORBdist)
{
int nmatches = 0;
const cv::Mat Rcw = CurrentFrame.mTcw.rowRange(0,3).colRange(0,3);
const cv::Mat tcw = CurrentFrame.mTcw.rowRange(0,3).col(3);
const cv::Mat Ow = -Rcw.t()*tcw;
// Rotation Histogram (to check rotation consistency)
vector<int> rotHist[HISTO_LENGTH];
for(int i=0;i<HISTO_LENGTH;i++)
rotHist[i].reserve(500);
const float factor = 1.0f/HISTO_LENGTH;
const vector<MapPoint*> vpMPs = pKF->GetMapPointMatches();
for(size_t i=0, iend=vpMPs.size(); i<iend; i++)
{
MapPoint* pMP = vpMPs[i];
if(pMP)
{
if(!pMP->isBad() && !sAlreadyFound.count(pMP))
{
//Project
cv::Mat x3Dw = pMP->GetWorldPos();
cv::Mat x3Dc = Rcw*x3Dw+tcw;
const cv::Point2f uv = CurrentFrame.mpCamera->project(x3Dc);
if(uv.x<CurrentFrame.mnMinX || uv.x>CurrentFrame.mnMaxX)
continue;
if(uv.y<CurrentFrame.mnMinY || uv.y>CurrentFrame.mnMaxY)
continue;
// Compute predicted scale level
cv::Mat PO = x3Dw-Ow;
float dist3D = cv::norm(PO);
const float maxDistance = pMP->GetMaxDistanceInvariance();
const float minDistance = pMP->GetMinDistanceInvariance();
// Depth must be inside the scale pyramid of the image
if(dist3D<minDistance || dist3D>maxDistance)
continue;
int nPredictedLevel = pMP->PredictScale(dist3D,&CurrentFrame);
// Search in a window
const float radius = th*CurrentFrame.mvScaleFactors[nPredictedLevel];
const vector<size_t> vIndices2 = CurrentFrame.GetFeaturesInArea(uv.x, uv.y, radius, nPredictedLevel-1, nPredictedLevel+1);
if(vIndices2.empty())
continue;
const cv::Mat dMP = pMP->GetDescriptor();
int bestDist = 256;
int bestIdx2 = -1;
for(vector<size_t>::const_iterator vit=vIndices2.begin(); vit!=vIndices2.end(); vit++)
{
const size_t i2 = *vit;
if(CurrentFrame.mvpMapPoints[i2])
continue;
const cv::Mat &d = CurrentFrame.mDescriptors.row(i2);
const int dist = DescriptorDistance(dMP,d);
if(dist<bestDist)
{
bestDist=dist;
bestIdx2=i2;
}
}
if(bestDist<=ORBdist)
{
CurrentFrame.mvpMapPoints[bestIdx2]=pMP;
nmatches++;
if(mbCheckOrientation)
{
float rot = pKF->mvKeysUn[i].angle-CurrentFrame.mvKeysUn[bestIdx2].angle;
if(rot<0.0)
rot+=360.0f;
int bin = round(rot*factor);
if(bin==HISTO_LENGTH)
bin=0;
assert(bin>=0 && bin<HISTO_LENGTH);
rotHist[bin].push_back(bestIdx2);
}
}
}
}
}
if(mbCheckOrientation)
{
int ind1=-1;
int ind2=-1;
int ind3=-1;
ComputeThreeMaxima(rotHist,HISTO_LENGTH,ind1,ind2,ind3);
for(int i=0; i<HISTO_LENGTH; i++)
{
if(i!=ind1 && i!=ind2 && i!=ind3)
{
for(size_t j=0, jend=rotHist[i].size(); j<jend; j++)
{
CurrentFrame.mvpMapPoints[rotHist[i][j]]=NULL;
nmatches--;
}
}
}
}
return nmatches;
}
/**
* 最大前三
*/
void ORBmatcher::ComputeThreeMaxima(vector<int>* histo, const int L, int &ind1, int &ind2, int &ind3)
{
int max1=0;
int max2=0;
int max3=0;
for(int i=0; i<L; i++)
{
const int s = histo[i].size();
if(s>max1)
{
max3=max2;
max2=max1;
max1=s;
ind3=ind2;
ind2=ind1;
ind1=i;
}
else if(s>max2)
{
max3=max2;
max2=s;
ind3=ind2;
ind2=i;
}
else if(s>max3)
{
max3=s;
ind3=i;
}
}
if(max2<0.1f*(float)max1)
{
ind2=-1;
ind3=-1;
}
else if(max3<0.1f*(float)max1)
{
ind3=-1;
}
}
/**
* 计算描述子距离
* Bit set count operation from
* http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
* 简单的可以是汉明距离
*/
int ORBmatcher::DescriptorDistance(const cv::Mat &a, const cv::Mat &b)
{
const int *pa = a.ptr<int32_t>();
const int *pb = b.ptr<int32_t>();
int dist=0;
for(int i=0; i<8; i++, pa++, pb++)
{
unsigned int v = *pa ^ *pb;
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
dist += (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
}
return dist;
}
} //namespace ORB_SLAM
| [
"noreply@github.com"
] | sebastinaa.noreply@github.com |
afb2bad48acb7d5aad4a466de331fe92941db531 | 37f94ac61df71dba46c5a25f6d504410d884f3c2 | /FileManager.h | 4bc0ac19f2ff0614c1c82b437c1dfd683a8aa03c | [] | no_license | athithrao/awget | f6596537a530db412def8da4bd60ec4cc833fa39 | f1f1a3c05d83aeadb557370520a22ab40650811c | refs/heads/master | 2021-01-11T23:19:01.470573 | 2017-01-10T19:43:43 | 2017-01-10T19:43:43 | 78,566,202 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 505 | h | #ifndef FILE_MAN_P2_H
#define FILE_MAN_P2_H
#include <iostream>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <fstream>
#include <cmath>
#include <algorithm>
#define MAX_PACKET_SIZE 1000
using namespace std;
class FileManager {
public:
string filename;
int numPackets;
char **packets;
FileManager();
void fetch(string url);
void createPackets();
void printPackets();
void acceptPacket(char *packet);
void download(string filename);
};
#endif | [
"noreply@github.com"
] | athithrao.noreply@github.com |
71a558535bd3e7f25f1b1a9dae480b8e489dcce9 | e76ea38dbe5774fccaf14e1a0090d9275cdaee08 | /src/sync/engine/apply_control_data_updates_unittest.cc | f3d173cba912ec6c54c0101e06d7a938ac9c33dd | [
"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 | 38,941 | cc | // Copyright 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 "base/format_macros.h"
#include "base/location.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "sync/engine/apply_control_data_updates.h"
#include "sync/engine/syncer.h"
#include "sync/engine/syncer_util.h"
#include "sync/internal_api/public/test/test_entry_factory.h"
#include "sync/protocol/nigori_specifics.pb.h"
#include "sync/syncable/mutable_entry.h"
#include "sync/syncable/nigori_util.h"
#include "sync/syncable/syncable_read_transaction.h"
#include "sync/syncable/syncable_util.h"
#include "sync/syncable/syncable_write_transaction.h"
#include "sync/test/engine/fake_model_worker.h"
#include "sync/test/engine/syncer_command_test.h"
#include "sync/test/engine/test_id_factory.h"
#include "sync/test/fake_sync_encryption_handler.h"
#include "sync/util/cryptographer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
using syncable::MutableEntry;
using syncable::UNITTEST;
using syncable::Id;
class ApplyControlDataUpdatesTest : public SyncerCommandTest {
public:
protected:
ApplyControlDataUpdatesTest() {}
virtual ~ApplyControlDataUpdatesTest() {}
virtual void SetUp() {
workers()->clear();
mutable_routing_info()->clear();
workers()->push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
workers()->push_back(
make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD)));
(*mutable_routing_info())[NIGORI] = GROUP_PASSIVE;
(*mutable_routing_info())[EXPERIMENTS] = GROUP_PASSIVE;
SyncerCommandTest::SetUp();
entry_factory_.reset(new TestEntryFactory(directory()));
session()->mutable_status_controller()->set_updates_request_types(
ControlTypes());
syncable::ReadTransaction trans(FROM_HERE, directory());
}
TestIdFactory id_factory_;
scoped_ptr<TestEntryFactory> entry_factory_;
private:
DISALLOW_COPY_AND_ASSIGN(ApplyControlDataUpdatesTest);
};
// Verify that applying a nigori node sets initial sync ended properly,
// updates the set of encrypted types, and updates the cryptographer.
TEST_F(ApplyControlDataUpdatesTest, NigoriUpdate) {
// Storing the cryptographer separately is bad, but for this test we
// know it's safe.
Cryptographer* cryptographer;
ModelTypeSet encrypted_types;
encrypted_types.PutAll(SyncEncryptionHandler::SensitiveTypes());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(encrypted_types));
}
// Nigori node updates should update the Cryptographer.
Cryptographer other_cryptographer(cryptographer->encryptor());
KeyParams params = {"localhost", "dummy", "foobar"};
other_cryptographer.AddKey(params);
sync_pb::EntitySpecifics specifics;
sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
nigori->set_encrypt_everything(true);
entry_factory_->CreateUnappliedNewItem(
ModelTypeToRootTag(NIGORI), specifics, true);
EXPECT_FALSE(cryptographer->has_pending_keys());
ApplyControlDataUpdates(session());
EXPECT_FALSE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->has_pending_keys());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// Create some local unsynced and unencrypted data. Apply a nigori update that
// turns on encryption for the unsynced data. Ensure we properly encrypt the
// data as part of the nigori update. Apply another nigori update with no
// changes. Ensure we ignore already-encrypted unsynced data and that nothing
// breaks.
TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) {
// Storing the cryptographer separately is bad, but for this test we
// know it's safe.
Cryptographer* cryptographer;
ModelTypeSet encrypted_types;
encrypted_types.PutAll(SyncEncryptionHandler::SensitiveTypes());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(encrypted_types));
// With default encrypted_types, this should be true.
EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_TRUE(handles.empty());
}
// Create unsynced bookmarks without encryption.
// First item is a folder
Id folder_id = id_factory_.NewLocalId();
entry_factory_->CreateUnsyncedItem(folder_id, id_factory_.root(), "folder",
true, BOOKMARKS, NULL);
// Next five items are children of the folder
size_t i;
size_t batch_s = 5;
for (i = 0; i < batch_s; ++i) {
entry_factory_->CreateUnsyncedItem(id_factory_.NewLocalId(), folder_id,
base::StringPrintf("Item %" PRIuS "", i),
false, BOOKMARKS, NULL);
}
// Next five items are children of the root.
for (; i < 2*batch_s; ++i) {
entry_factory_->CreateUnsyncedItem(
id_factory_.NewLocalId(), id_factory_.root(),
base::StringPrintf("Item %" PRIuS "", i), false,
BOOKMARKS, NULL);
}
KeyParams params = {"localhost", "dummy", "foobar"};
cryptographer->AddKey(params);
sync_pb::EntitySpecifics specifics;
sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
cryptographer->GetKeys(nigori->mutable_encryption_keybag());
nigori->set_encrypt_everything(true);
encrypted_types.Put(BOOKMARKS);
entry_factory_->CreateUnappliedNewItem(
ModelTypeToRootTag(NIGORI), specifics, true);
EXPECT_FALSE(cryptographer->has_pending_keys());
EXPECT_TRUE(cryptographer->is_ready());
{
// Ensure we have unsynced nodes that aren't properly encrypted.
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_EQ(2*batch_s+1, handles.size());
}
ApplyControlDataUpdates(session());
EXPECT_FALSE(cryptographer->has_pending_keys());
EXPECT_TRUE(cryptographer->is_ready());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
// If ProcessUnsyncedChangesForEncryption worked, all our unsynced changes
// should be encrypted now.
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_EQ(2*batch_s+1, handles.size());
}
// Simulate another nigori update that doesn't change anything.
{
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, syncable::GET_BY_SERVER_TAG,
ModelTypeToRootTag(NIGORI));
ASSERT_TRUE(entry.good());
entry.PutServerVersion(entry_factory_->GetNextRevision());
entry.PutIsUnappliedUpdate(true);
}
ApplyControlDataUpdates(session());
EXPECT_FALSE(cryptographer->has_pending_keys());
EXPECT_TRUE(cryptographer->is_ready());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
// All our changes should still be encrypted.
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_EQ(2*batch_s+1, handles.size());
}
}
// Create some local unsynced and unencrypted changes. Receive a new nigori
// node enabling their encryption but also introducing pending keys. Ensure
// we apply the update properly without encrypting the unsynced changes or
// breaking.
TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) {
// Storing the cryptographer separately is bad, but for this test we
// know it's safe.
Cryptographer* cryptographer;
ModelTypeSet encrypted_types;
encrypted_types.PutAll(SyncEncryptionHandler::SensitiveTypes());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(encrypted_types));
// With default encrypted_types, this should be true.
EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_TRUE(handles.empty());
}
// Create unsynced bookmarks without encryption.
// First item is a folder
Id folder_id = id_factory_.NewLocalId();
entry_factory_->CreateUnsyncedItem(
folder_id, id_factory_.root(), "folder", true,
BOOKMARKS, NULL);
// Next five items are children of the folder
size_t i;
size_t batch_s = 5;
for (i = 0; i < batch_s; ++i) {
entry_factory_->CreateUnsyncedItem(id_factory_.NewLocalId(), folder_id,
base::StringPrintf("Item %" PRIuS "", i),
false, BOOKMARKS, NULL);
}
// Next five items are children of the root.
for (; i < 2*batch_s; ++i) {
entry_factory_->CreateUnsyncedItem(
id_factory_.NewLocalId(), id_factory_.root(),
base::StringPrintf("Item %" PRIuS "", i), false,
BOOKMARKS, NULL);
}
// We encrypt with new keys, triggering the local cryptographer to be unready
// and unable to decrypt data (once updated).
Cryptographer other_cryptographer(cryptographer->encryptor());
KeyParams params = {"localhost", "dummy", "foobar"};
other_cryptographer.AddKey(params);
sync_pb::EntitySpecifics specifics;
sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
nigori->set_encrypt_everything(true);
encrypted_types.Put(BOOKMARKS);
entry_factory_->CreateUnappliedNewItem(
ModelTypeToRootTag(NIGORI), specifics, true);
EXPECT_FALSE(cryptographer->has_pending_keys());
{
// Ensure we have unsynced nodes that aren't properly encrypted.
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_EQ(2*batch_s+1, handles.size());
}
ApplyControlDataUpdates(session());
EXPECT_FALSE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->has_pending_keys());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
// Since we have pending keys, we would have failed to encrypt, but the
// cryptographer should be updated.
EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
EXPECT_FALSE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->has_pending_keys());
Syncer::UnsyncedMetaHandles handles;
GetUnsyncedEntries(&trans, &handles);
EXPECT_EQ(2*batch_s+1, handles.size());
}
}
// Verify we handle a nigori node conflict by merging encryption keys and
// types, but preserve the custom passphrase state of the server.
// Initial sync ended should be set.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictPendingKeysServerEncryptEverythingCustom) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams other_params = {"localhost", "dummy", "foobar"};
KeyParams local_params = {"localhost", "dummy", "local"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up a temporary cryptographer to generate new keys with.
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(other_params);
// Create server specifics with pending keys, new encrypted types,
// and a custom passphrase (unmigrated).
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(true);
server_nigori->set_keybag_is_frozen(true);
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Initialize the local cryptographer with the local keys.
cryptographer->AddKey(local_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with the local encryption keys and default encrypted
// types.
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(false);
local_nigori->set_keybag_is_frozen(true);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_FALSE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->is_initialized());
EXPECT_TRUE(cryptographer->has_pending_keys());
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// Verify we handle a nigori node conflict by merging encryption keys and
// types, but preserve the custom passphrase state of the server.
// Initial sync ended should be set.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictPendingKeysLocalEncryptEverythingCustom) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams other_params = {"localhost", "dummy", "foobar"};
KeyParams local_params = {"localhost", "dummy", "local"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up a temporary cryptographer to generate new keys with.
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(other_params);
// Create server specifics with pending keys, new encrypted types,
// and a custom passphrase (unmigrated).
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(false);
server_nigori->set_keybag_is_frozen(false);
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Initialize the local cryptographer with the local keys.
cryptographer->AddKey(local_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with the local encryption keys and default encrypted
// types.
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(true);
local_nigori->set_keybag_is_frozen(true);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_FALSE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->is_initialized());
EXPECT_TRUE(cryptographer->has_pending_keys());
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// If the conflicting nigori has a subset of the local keys, the conflict
// resolution should preserve the full local keys. Initial sync ended should be
// set.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictOldKeys) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams old_params = {"localhost", "dummy", "old"};
KeyParams new_params = {"localhost", "dummy", "new"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up the cryptographer with old keys
cryptographer->AddKey(old_params);
// Create server specifics with old keys and new encrypted types.
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
cryptographer->GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(true);
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Add the new keys to the cryptogrpaher
cryptographer->AddKey(new_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with the superset of keys.
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(false);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_TRUE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// If both nigoris are migrated, but we also set a custom passphrase locally,
// the local nigori should be preserved.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictBothMigratedLocalCustom) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams old_params = {"localhost", "dummy", "old"};
KeyParams new_params = {"localhost", "dummy", "new"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up the cryptographer with new keys
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(old_params);
// Create server specifics with a migrated keystore passphrase type.
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(false);
server_nigori->set_keybag_is_frozen(true);
server_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE);
server_nigori->mutable_keystore_decryptor_token();
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Add the new keys to the cryptographer.
cryptographer->AddKey(old_params);
cryptographer->AddKey(new_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with a migrated custom passphrase type
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(true);
local_nigori->set_keybag_is_frozen(true);
local_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_TRUE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().passphrase_type());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// If both nigoris are migrated, but a custom passphrase with a new key was
// set remotely, the remote nigori should be preserved.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictBothMigratedServerCustom) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams old_params = {"localhost", "dummy", "old"};
KeyParams new_params = {"localhost", "dummy", "new"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up the cryptographer with both new keys and old keys.
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(old_params);
other_cryptographer.AddKey(new_params);
// Create server specifics with a migrated custom passphrase type.
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(true);
server_nigori->set_keybag_is_frozen(true);
server_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE);
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Add the old keys to the cryptographer.
cryptographer->AddKey(old_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with a migrated keystore passphrase type
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(false);
local_nigori->set_keybag_is_frozen(true);
local_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE);
server_nigori->mutable_keystore_decryptor_token();
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_TRUE(cryptographer->is_initialized());
EXPECT_TRUE(cryptographer->has_pending_keys());
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().passphrase_type());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// If the local nigori is migrated but the server is not, preserve the local
// nigori.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictLocalMigrated) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams old_params = {"localhost", "dummy", "old"};
KeyParams new_params = {"localhost", "dummy", "new"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up the cryptographer with both new keys and old keys.
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(old_params);
// Create server specifics with an unmigrated implicit passphrase type.
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(true);
server_nigori->set_keybag_is_frozen(false);
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Add the old keys to the cryptographer.
cryptographer->AddKey(old_params);
cryptographer->AddKey(new_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with a migrated custom passphrase type
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(true);
local_nigori->set_keybag_is_frozen(true);
local_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_TRUE(cryptographer->is_ready());
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encrypt_everything());
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().passphrase_type());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
.Equals(ModelTypeSet::All()));
}
}
// If the server nigori is migrated but the local is not, preserve the server
// nigori.
TEST_F(ApplyControlDataUpdatesTest,
NigoriConflictServerMigrated) {
Cryptographer* cryptographer;
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
KeyParams old_params = {"localhost", "dummy", "old"};
KeyParams new_params = {"localhost", "dummy", "new"};
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
EXPECT_TRUE(encrypted_types.Equals(
directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)));
}
// Set up the cryptographer with both new keys and old keys.
Cryptographer other_cryptographer(cryptographer->encryptor());
other_cryptographer.AddKey(old_params);
// Create server specifics with an migrated keystore passphrase type.
sync_pb::EntitySpecifics server_specifics;
sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori();
other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag());
server_nigori->set_encrypt_everything(false);
server_nigori->set_keybag_is_frozen(true);
server_nigori->set_passphrase_type(
sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE);
server_nigori->mutable_keystore_decryptor_token();
int64 nigori_handle =
entry_factory_->CreateUnappliedNewItem(kNigoriTag,
server_specifics,
true);
// Add the old keys to the cryptographer.
cryptographer->AddKey(old_params);
cryptographer->AddKey(new_params);
EXPECT_TRUE(cryptographer->is_ready());
// Set up a local nigori with a migrated custom passphrase type
sync_pb::EntitySpecifics local_specifics;
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori();
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag());
local_nigori->set_encrypt_everything(false);
local_nigori->set_keybag_is_frozen(false);
ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem(
nigori_handle, local_specifics));
// Apply the update locally so that UpdateFromEncryptedTypes knows what state
// to use.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
cryptographer = directory()->GetCryptographer(&trans);
directory()->GetNigoriHandler()->ApplyNigoriUpdate(
*local_nigori,
&trans);
}
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_TRUE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
ApplyControlDataUpdates(session());
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(nigori_handle));
EXPECT_TRUE(cryptographer->is_ready());
// Note: we didn't overwrite the encryption keybag with the local keys. The
// sync encryption handler will do that when it detects that the new
// keybag is out of date (and update the keystore bootstrap if necessary).
EXPECT_FALSE(cryptographer->CanDecryptUsingDefaultKey(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(cryptographer->CanDecrypt(
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().encryption_keybag()));
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().keybag_is_frozen());
EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().has_keystore_decryptor_token());
EXPECT_EQ(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE,
entry_factory_->GetLocalSpecificsForItem(nigori_handle).
nigori().passphrase_type());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
}
}
// Check that we can apply a simple control datatype node successfully.
TEST_F(ApplyControlDataUpdatesTest, ControlApply) {
std::string experiment_id = "experiment";
sync_pb::EntitySpecifics specifics;
specifics.mutable_experiments()->mutable_keystore_encryption()->
set_enabled(true);
int64 experiment_handle = entry_factory_->CreateUnappliedNewItem(
experiment_id, specifics, false);
ApplyControlDataUpdates(session());
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
EXPECT_TRUE(
entry_factory_->GetLocalSpecificsForItem(experiment_handle).
experiments().keystore_encryption().enabled());
}
// Verify that we apply top level folders before their children.
TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) {
std::string parent_id = "parent";
std::string experiment_id = "experiment";
sync_pb::EntitySpecifics specifics;
specifics.mutable_experiments()->mutable_keystore_encryption()->
set_enabled(true);
int64 experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent(
experiment_id, specifics, parent_id);
int64 parent_handle = entry_factory_->CreateUnappliedNewItem(
parent_id, specifics, true);
ApplyControlDataUpdates(session());
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle));
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
EXPECT_TRUE(
entry_factory_->GetLocalSpecificsForItem(experiment_handle).
experiments().keystore_encryption().enabled());
}
// Verify that we handle control datatype conflicts by preserving the server
// data.
TEST_F(ApplyControlDataUpdatesTest, ControlConflict) {
std::string experiment_id = "experiment";
sync_pb::EntitySpecifics local_specifics, server_specifics;
server_specifics.mutable_experiments()->mutable_keystore_encryption()->
set_enabled(true);
local_specifics.mutable_experiments()->mutable_keystore_encryption()->
set_enabled(false);
int64 experiment_handle = entry_factory_->CreateSyncedItem(
experiment_id, EXPERIMENTS, false);
entry_factory_->SetServerSpecificsForItem(experiment_handle,
server_specifics);
entry_factory_->SetLocalSpecificsForItem(experiment_handle,
local_specifics);
ApplyControlDataUpdates(session());
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
EXPECT_TRUE(
entry_factory_->GetLocalSpecificsForItem(experiment_handle).
experiments().keystore_encryption().enabled());
}
} // namespace syncer
| [
"ronan@fridu.net"
] | ronan@fridu.net |
78d25c342848ec6cbcae42f5ab2065d701b9637e | 07327b5e8b2831b12352bf7c6426bfda60129da7 | /Include/10.0.14393.0/winrt/windows.media.streaming.adaptive.h | 567656f316cf773c6d69c1f1543c75fc7216b154 | [] | no_license | tpn/winsdk-10 | ca279df0fce03f92036e90fb04196d6282a264b7 | 9b69fd26ac0c7d0b83d378dba01080e93349c2ed | refs/heads/master | 2021-01-10T01:56:18.586459 | 2018-02-19T21:26:31 | 2018-02-19T21:29:50 | 44,352,845 | 218 | 432 | null | null | null | null | UTF-8 | C++ | false | false | 251,860 | h |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.01.0618 */
/* @@MIDL_FILE_HEADING( ) */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 500
#endif
/* verify that the <rpcsal.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCSAL_H_VERSION__
#define __REQUIRED_RPCSAL_H_VERSION__ 100
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif /* __RPCNDR_H_VERSION__ */
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __windows2Emedia2Estreaming2Eadaptive_h__
#define __windows2Emedia2Estreaming2Eadaptive_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
#define ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult;
#endif /* ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__ */
#ifndef ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
#define ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
typedef interface __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult;
#endif /* ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__ */
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__
typedef interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__ */
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__
typedef interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs;
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__ */
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__
typedef interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs;
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__ */
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__
typedef interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs;
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__ */
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__
typedef interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSource;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSource2;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceAdvancedSettings;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceCreationResult;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadCompletedEventArgs;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadFailedEventArgs;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadRequestedDeferral;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadRequestedEventArgs;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadResult;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadResult2;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__ */
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_FWD_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_FWD_DEFINED__
typedef interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics;
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceStatics;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
#endif /* __cplusplus */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_FWD_DEFINED__ */
/* header files for imported files */
#include "inspectable.h"
#include "AsyncInfo.h"
#include "EventToken.h"
#include "Windows.Foundation.h"
#include "Windows.Media.Core.h"
#ifdef __cplusplus
extern "C"{
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0000 */
/* [local] */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#include <windows.foundation.collections.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceCreationResult;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceCreationResult;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0000 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0000_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4021 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4021 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4021_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4021_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0001 */
/* [local] */
#ifndef DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE
#define DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("bd68cc00-724c-5a76-a437-1464ebdda4ac"))
IAsyncOperationCompletedHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*> : IAsyncOperationCompletedHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceCreationResult*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.AsyncOperationCompletedHandler`1<Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceCreationResult>"; }
};
typedef IAsyncOperationCompletedHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*> __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_t;
#define ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
#define __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult ABI::Windows::Foundation::__FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0001 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0001_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0001_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4022 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4022 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4022_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4022_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0002 */
/* [local] */
#ifndef DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE
#define DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("be0bcc1d-d606-59d2-b2f9-ff204543da12"))
IAsyncOperation<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*> : IAsyncOperation_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceCreationResult*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.IAsyncOperation`1<Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceCreationResult>"; }
};
typedef IAsyncOperation<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationResult*> __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_t;
#define ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_FWD_DEFINED__
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult ABI::Windows::Foundation::__FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_USE */
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSource;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSource;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadBitrateChangedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0002 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0002_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0002_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4023 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4023 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4023_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4023_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0003 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_USE
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("ad268caf-7da0-5ad4-8585-ceeb903dbd50"))
ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadBitrateChangedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource*>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadBitrateChangedEventArgs*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadBitrateChangedEventArgs*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.TypedEventHandler`2<Windows.Media.Streaming.Adaptive.AdaptiveMediaSource, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadBitrateChangedEventArgs>"; }
};
typedef ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadBitrateChangedEventArgs*> __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_t;
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_FWD_DEFINED__
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_USE */
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadCompletedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadCompletedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0003 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0003_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0003_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4024 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4024 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4024_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4024_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0004 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_USE
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("cef775dd-25b2-5588-8d51-dacdea660a7d"))
ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadCompletedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource*>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadCompletedEventArgs*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadCompletedEventArgs*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.TypedEventHandler`2<Windows.Media.Streaming.Adaptive.AdaptiveMediaSource, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadCompletedEventArgs>"; }
};
typedef ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadCompletedEventArgs*> __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_t;
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_FWD_DEFINED__
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_USE */
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadFailedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadFailedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0004 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0004_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0004_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4025 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4025 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4025_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4025_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0005 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_USE
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("6ee5cc44-49ad-5138-ab47-f5c075a2bc34"))
ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadFailedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource*>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadFailedEventArgs*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadFailedEventArgs*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.TypedEventHandler`2<Windows.Media.Streaming.Adaptive.AdaptiveMediaSource, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadFailedEventArgs>"; }
};
typedef ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadFailedEventArgs*> __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_t;
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_FWD_DEFINED__
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_USE */
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadRequestedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourceDownloadRequestedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0005 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0005_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0005_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4026 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4026 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4026_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4026_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0006 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_USE
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("d3b7dbf1-fd8e-589e-9c7f-ba67397e50cd"))
ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadRequestedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource*>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadRequestedEventArgs*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadRequestedEventArgs*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.TypedEventHandler`2<Windows.Media.Streaming.Adaptive.AdaptiveMediaSource, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadRequestedEventArgs>"; }
};
typedef ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceDownloadRequestedEventArgs*> __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_t;
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_FWD_DEFINED__
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_USE */
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
interface IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0006 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0006_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0006_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4027 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4027 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4027_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4027_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0007 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_USE
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("df4f4e89-6173-539b-94d8-69b7cb7578a7"))
ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourcePlaybackBitrateChangedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource*>,ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourcePlaybackBitrateChangedEventArgs*, ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs*>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.TypedEventHandler`2<Windows.Media.Streaming.Adaptive.AdaptiveMediaSource, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourcePlaybackBitrateChangedEventArgs>"; }
};
typedef ITypedEventHandler<ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSource*,ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourcePlaybackBitrateChangedEventArgs*> __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_t;
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_FWD_DEFINED__
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0007 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0007_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0007_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4028 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4028 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4028_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4028_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0008 */
/* [local] */
#ifndef DEF___FIIterator_1_UINT32_USE
#define DEF___FIIterator_1_UINT32_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation { namespace Collections {
template <>
struct __declspec(uuid("f06a2739-9443-5ef0-b284-dc5aff3e7d10"))
IIterator<UINT32> : IIterator_impl<UINT32> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.Collections.IIterator`1<UInt32>"; }
};
typedef IIterator<UINT32> __FIIterator_1_UINT32_t;
#define ____FIIterator_1_UINT32_FWD_DEFINED__
#define __FIIterator_1_UINT32 ABI::Windows::Foundation::Collections::__FIIterator_1_UINT32_t
/* ABI */ } /* Windows */ } /* Foundation */ } /* Collections */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIIterator_1_UINT32_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0008 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0008_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0008_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4029 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4029 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4029_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4029_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0009 */
/* [local] */
#ifndef DEF___FIIterable_1_UINT32_USE
#define DEF___FIIterable_1_UINT32_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation { namespace Collections {
template <>
struct __declspec(uuid("421d4b91-b13b-5f37-ae54-b5249bd80539"))
IIterable<UINT32> : IIterable_impl<UINT32> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.Collections.IIterable`1<UInt32>"; }
};
typedef IIterable<UINT32> __FIIterable_1_UINT32_t;
#define ____FIIterable_1_UINT32_FWD_DEFINED__
#define __FIIterable_1_UINT32 ABI::Windows::Foundation::Collections::__FIIterable_1_UINT32_t
/* ABI */ } /* Windows */ } /* Foundation */ } /* Collections */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIIterable_1_UINT32_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0009 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0009_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0009_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4030 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4030 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4030_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4030_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0010 */
/* [local] */
#ifndef DEF___FIVectorView_1_UINT32_USE
#define DEF___FIVectorView_1_UINT32_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation { namespace Collections {
template <>
struct __declspec(uuid("e5ce1a07-8d33-5007-ba64-7d2508ccf85c"))
IVectorView<UINT32> : IVectorView_impl<UINT32> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.Collections.IVectorView`1<UInt32>"; }
};
typedef IVectorView<UINT32> __FIVectorView_1_UINT32_t;
#define ____FIVectorView_1_UINT32_FWD_DEFINED__
#define __FIVectorView_1_UINT32 ABI::Windows::Foundation::Collections::__FIVectorView_1_UINT32_t
/* ABI */ } /* Windows */ } /* Foundation */ } /* Collections */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIVectorView_1_UINT32_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0010 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0010_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0010_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4031 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4031 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4031_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4031_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0011 */
/* [local] */
#ifndef DEF___FIReference_1_UINT32_USE
#define DEF___FIReference_1_UINT32_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("513ef3af-e784-5325-a91e-97c2b8111cf3"))
IReference<UINT32> : IReference_impl<UINT32> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.IReference`1<UInt32>"; }
};
typedef IReference<UINT32> __FIReference_1_UINT32_t;
#define ____FIReference_1_UINT32_FWD_DEFINED__
#define __FIReference_1_UINT32 ABI::Windows::Foundation::__FIReference_1_UINT32_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIReference_1_UINT32_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0011 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0011_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0011_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4032 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4032 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4032_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4032_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0012 */
/* [local] */
#ifndef DEF___FIReference_1_double_USE
#define DEF___FIReference_1_double_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("2f2d6c29-5473-5f3e-92e7-96572bb990e2"))
IReference<double> : IReference_impl<double> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.IReference`1<Double>"; }
};
typedef IReference<double> __FIReference_1_double_t;
#define ____FIReference_1_double_FWD_DEFINED__
#define __FIReference_1_double ABI::Windows::Foundation::__FIReference_1_double_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIReference_1_double_USE */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0012 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0012_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0012_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4033 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4033 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4033_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4033_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0013 */
/* [local] */
#ifndef DEF___FIReference_1_UINT64_USE
#define DEF___FIReference_1_UINT64_USE
#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME)
} /*extern "C"*/
namespace ABI { namespace Windows { namespace Foundation {
template <>
struct __declspec(uuid("6755e376-53bb-568b-a11d-17239868309e"))
IReference<UINT64> : IReference_impl<UINT64> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.IReference`1<UInt64>"; }
};
typedef IReference<UINT64> __FIReference_1_UINT64_t;
#define ____FIReference_1_UINT64_FWD_DEFINED__
#define __FIReference_1_UINT64 ABI::Windows::Foundation::__FIReference_1_UINT64_t
/* ABI */ } /* Windows */ } /* Foundation */ }
extern "C" {
#endif //__cplusplus
#endif /* DEF___FIReference_1_UINT64_USE */
#if defined(__cplusplus)
}
#endif // defined(__cplusplus)
#include <Windows.Foundation.h>
#if !defined(__windows2Emedia2Ecore_h__)
#include <Windows.Media.Core.h>
#endif // !defined(__windows2Emedia2Ecore_h__)
#if !defined(__windows2Estorage2Estreams_h__)
#include <Windows.Storage.Streams.h>
#endif // !defined(__windows2Estorage2Estreams_h__)
#if !defined(__windows2Eweb2Ehttp_h__)
#include <Windows.Web.Http.h>
#endif // !defined(__windows2Eweb2Ehttp_h__)
#if defined(__cplusplus)
extern "C" {
#endif // defined(__cplusplus)
#if !defined(__cplusplus)
typedef struct __x_ABI_CWindows_CFoundation_CTimeSpan __x_ABI_CWindows_CFoundation_CTimeSpan;
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Foundation {
class Uri;
} /*Foundation*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Web {
namespace Http {
class HttpClient;
} /*Http*/
} /*Web*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Web {
namespace Http {
class HttpResponseMessage;
} /*Http*/
} /*Web*/
} /*Windows*/
}
#endif
#if !defined(__cplusplus)
#if !defined(__cplusplus)
typedef enum __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceCreationStatus __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceCreationStatus;
#endif /* end if !defined(__cplusplus) */
#endif
#if !defined(__cplusplus)
#if !defined(__cplusplus)
typedef enum __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType;
#endif /* end if !defined(__cplusplus) */
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceAdvancedSettings;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadRequestedDeferral;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
#ifdef __cplusplus
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
class AdaptiveMediaSourceDownloadResult;
} /*Adaptive*/
} /*Streaming*/
} /*Media*/
} /*Windows*/
}
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0013 */
/* [local] */
#ifdef __cplusplus
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Foundation {
typedef struct TimeSpan TimeSpan;
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#endif
#ifdef __cplusplus
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
typedef enum AdaptiveMediaSourceCreationStatus AdaptiveMediaSourceCreationStatus;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#endif
#ifdef __cplusplus
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
typedef enum AdaptiveMediaSourceResourceType AdaptiveMediaSourceResourceType;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#endif
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0013_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0013_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4034 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4034 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4034_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4034_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0014 */
/* [local] */
#ifndef DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
#define DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0014 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0014_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0014_v0_0_s_ifspec;
#ifndef ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
#define ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
/* interface __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* [unique][uuid][object] */
/* interface __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("bd68cc00-724c-5a76-a437-1464ebdda4ac")
__FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult *asyncInfo,
/* [in] */ AsyncStatus status) = 0;
};
#else /* C style interface */
typedef struct __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [in] */ __RPC__in_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult *asyncInfo,
/* [in] */ AsyncStatus status);
END_INTERFACE
} __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl;
interface __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
{
CONST_VTBL struct __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_Invoke(This,asyncInfo,status) \
( (This)->lpVtbl -> Invoke(This,asyncInfo,status) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0015 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0015 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0015_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0015_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4035 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4035 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4035_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4035_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0016 */
/* [local] */
#ifndef DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
#define DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0016 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0016_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0016_v0_0_s_ifspec;
#ifndef ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
#define ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
/* interface __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* [unique][uuid][object] */
/* interface __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("be0bcc1d-d606-59d2-b2f9-ff204543da12")
__FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult : public IInspectable
{
public:
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Completed(
/* [in] */ __RPC__in_opt __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult *handler) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Completed(
/* [retval][out] */ __RPC__deref_out_opt __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **handler) = 0;
virtual HRESULT STDMETHODCALLTYPE GetResults(
/* [retval][out] */ __RPC__deref_out_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceCreationResult **results) = 0;
};
#else /* C style interface */
typedef struct __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Completed )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [in] */ __RPC__in_opt __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult *handler);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Completed )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [retval][out] */ __RPC__deref_out_opt __FIAsyncOperationCompletedHandler_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **handler);
HRESULT ( STDMETHODCALLTYPE *GetResults )(
__RPC__in __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult * This,
/* [retval][out] */ __RPC__deref_out_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult **results);
END_INTERFACE
} __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl;
interface __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult
{
CONST_VTBL struct __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResultVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_put_Completed(This,handler) \
( (This)->lpVtbl -> put_Completed(This,handler) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_get_Completed(This,handler) \
( (This)->lpVtbl -> get_Completed(This,handler) )
#define __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_GetResults(This,results) \
( (This)->lpVtbl -> GetResults(This,results) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0017 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0017 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0017_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0017_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4036 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4036 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4036_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4036_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0018 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0018 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0018_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0018_v0_0_s_ifspec;
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs */
/* [unique][uuid][object] */
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("ad268caf-7da0-5ad4-8585-ceeb903dbd50")
__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadBitrateChangedEventArgs *e) = 0;
};
#else /* C style interface */
typedef struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs *e);
END_INTERFACE
} __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl;
interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs
{
CONST_VTBL struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_Invoke(This,sender,e) \
( (This)->lpVtbl -> Invoke(This,sender,e) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0019 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0019 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0019_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0019_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4037 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4037 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4037_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4037_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0020 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0020 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0020_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0020_v0_0_s_ifspec;
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs */
/* [unique][uuid][object] */
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("cef775dd-25b2-5588-8d51-dacdea660a7d")
__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadCompletedEventArgs *e) = 0;
};
#else /* C style interface */
typedef struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs *e);
END_INTERFACE
} __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgsVtbl;
interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs
{
CONST_VTBL struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_Invoke(This,sender,e) \
( (This)->lpVtbl -> Invoke(This,sender,e) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0021 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0021 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0021_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0021_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4038 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4038 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4038_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4038_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0022 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0022 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0022_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0022_v0_0_s_ifspec;
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs */
/* [unique][uuid][object] */
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("6ee5cc44-49ad-5138-ab47-f5c075a2bc34")
__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadFailedEventArgs *e) = 0;
};
#else /* C style interface */
typedef struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs *e);
END_INTERFACE
} __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgsVtbl;
interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs
{
CONST_VTBL struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_Invoke(This,sender,e) \
( (This)->lpVtbl -> Invoke(This,sender,e) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0023 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0023 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0023_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0023_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4039 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4039 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4039_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4039_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0024 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0024 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0024_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0024_v0_0_s_ifspec;
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs */
/* [unique][uuid][object] */
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("d3b7dbf1-fd8e-589e-9c7f-ba67397e50cd")
__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadRequestedEventArgs *e) = 0;
};
#else /* C style interface */
typedef struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs *e);
END_INTERFACE
} __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgsVtbl;
interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs
{
CONST_VTBL struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_Invoke(This,sender,e) \
( (This)->lpVtbl -> Invoke(This,sender,e) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0025 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0025 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0025_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0025_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4040 */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4040 */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4040_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive2Eidl_0000_4040_v0_0_s_ifspec;
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0026 */
/* [local] */
#ifndef DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs
#define DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs
#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME)
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0026 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0026_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0026_v0_0_s_ifspec;
#ifndef ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__
#define ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs */
/* [unique][uuid][object] */
/* interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs */
/* [unique][uuid][object] */
EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("df4f4e89-6173-539b-94d8-69b7cb7578a7")
__FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs *e) = 0;
};
#else /* C style interface */
typedef struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *Invoke )(
__RPC__in __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource *sender,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs *e);
END_INTERFACE
} __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl;
interface __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs
{
CONST_VTBL struct __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_Invoke(This,sender,e) \
( (This)->lpVtbl -> Invoke(This,sender,e) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0027 */
/* [local] */
#endif /* pinterface */
#endif /* DEF___FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs */
#if !defined(__cplusplus)
#if !defined(__cplusplus)
/* [v1_enum] */
enum __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceCreationStatus
{
AdaptiveMediaSourceCreationStatus_Success = 0,
AdaptiveMediaSourceCreationStatus_ManifestDownloadFailure = 1,
AdaptiveMediaSourceCreationStatus_ManifestParseFailure = 2,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestContentType = 3,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestVersion = 4,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestProfile = 5,
AdaptiveMediaSourceCreationStatus_UnknownFailure = 6
} ;
#endif /* end if !defined(__cplusplus) */
#endif
#if !defined(__cplusplus)
#if !defined(__cplusplus)
/* [v1_enum] */
enum __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType
{
AdaptiveMediaSourceResourceType_Manifest = 0,
AdaptiveMediaSourceResourceType_InitializationSegment = 1,
AdaptiveMediaSourceResourceType_MediaSegment = 2,
AdaptiveMediaSourceResourceType_Key = 3,
AdaptiveMediaSourceResourceType_InitializationVector = 4
} ;
#endif /* end if !defined(__cplusplus) */
#endif
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSource[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSource";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0027 */
/* [local] */
#ifdef __cplusplus
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
/* [v1_enum] */
enum AdaptiveMediaSourceCreationStatus
{
AdaptiveMediaSourceCreationStatus_Success = 0,
AdaptiveMediaSourceCreationStatus_ManifestDownloadFailure = 1,
AdaptiveMediaSourceCreationStatus_ManifestParseFailure = 2,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestContentType = 3,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestVersion = 4,
AdaptiveMediaSourceCreationStatus_UnsupportedManifestProfile = 5,
AdaptiveMediaSourceCreationStatus_UnknownFailure = 6
} ;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#endif
#ifdef __cplusplus
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
/* [v1_enum] */
enum AdaptiveMediaSourceResourceType
{
AdaptiveMediaSourceResourceType_Manifest = 0,
AdaptiveMediaSourceResourceType_InitializationSegment = 1,
AdaptiveMediaSourceResourceType_MediaSegment = 2,
AdaptiveMediaSourceResourceType_Key = 3,
AdaptiveMediaSourceResourceType_InitializationVector = 4
} ;
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#endif
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0027_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0027_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("4C7332EF-D39F-4396-B4D9-043957A7C964")
IAdaptiveMediaSource : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsLive(
/* [out][retval] */ __RPC__out boolean *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DesiredLiveOffset(
/* [out][retval] */ __RPC__out ABI::Windows::Foundation::TimeSpan *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DesiredLiveOffset(
/* [in] */ ABI::Windows::Foundation::TimeSpan value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_InitialBitrate(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_InitialBitrate(
/* [in] */ UINT32 value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CurrentDownloadBitrate(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CurrentPlaybackBitrate(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AvailableBitrates(
/* [out][retval] */ __RPC__deref_out_opt __FIVectorView_1_UINT32 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DesiredMinBitrate(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT32 **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DesiredMinBitrate(
/* [in] */ __RPC__in_opt __FIReference_1_UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DesiredMaxBitrate(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT32 **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DesiredMaxBitrate(
/* [in] */ __RPC__in_opt __FIReference_1_UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AudioOnlyPlayback(
/* [out][retval] */ __RPC__out boolean *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_InboundBitsPerSecond(
/* [out][retval] */ __RPC__out UINT64 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_InboundBitsPerSecondWindow(
/* [out][retval] */ __RPC__out ABI::Windows::Foundation::TimeSpan *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_InboundBitsPerSecondWindow(
/* [in] */ ABI::Windows::Foundation::TimeSpan value) = 0;
virtual HRESULT STDMETHODCALLTYPE add_DownloadBitrateChanged(
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_DownloadBitrateChanged(
/* [in] */ EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE add_PlaybackBitrateChanged(
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_PlaybackBitrateChanged(
/* [in] */ EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE add_DownloadRequested(
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_DownloadRequested(
/* [in] */ EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE add_DownloadCompleted(
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_DownloadCompleted(
/* [in] */ EventRegistrationToken token) = 0;
virtual HRESULT STDMETHODCALLTYPE add_DownloadFailed(
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_DownloadFailed(
/* [in] */ EventRegistrationToken token) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSource = __uuidof(IAdaptiveMediaSource);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsLive )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out boolean *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DesiredLiveOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CFoundation_CTimeSpan *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DesiredLiveOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __x_ABI_CWindows_CFoundation_CTimeSpan value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_InitialBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_InitialBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ UINT32 value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_CurrentDownloadBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_CurrentPlaybackBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AvailableBitrates )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__deref_out_opt __FIVectorView_1_UINT32 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DesiredMinBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT32 **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DesiredMinBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FIReference_1_UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DesiredMaxBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT32 **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DesiredMaxBitrate )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FIReference_1_UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AudioOnlyPlayback )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out boolean *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_InboundBitsPerSecond )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out UINT64 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_InboundBitsPerSecondWindow )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CFoundation_CTimeSpan *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_InboundBitsPerSecondWindow )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __x_ABI_CWindows_CFoundation_CTimeSpan value);
HRESULT ( STDMETHODCALLTYPE *add_DownloadBitrateChanged )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadBitrateChangedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token);
HRESULT ( STDMETHODCALLTYPE *remove_DownloadBitrateChanged )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ EventRegistrationToken token);
HRESULT ( STDMETHODCALLTYPE *add_PlaybackBitrateChanged )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourcePlaybackBitrateChangedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token);
HRESULT ( STDMETHODCALLTYPE *remove_PlaybackBitrateChanged )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ EventRegistrationToken token);
HRESULT ( STDMETHODCALLTYPE *add_DownloadRequested )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadRequestedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token);
HRESULT ( STDMETHODCALLTYPE *remove_DownloadRequested )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ EventRegistrationToken token);
HRESULT ( STDMETHODCALLTYPE *add_DownloadCompleted )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadCompletedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token);
HRESULT ( STDMETHODCALLTYPE *remove_DownloadCompleted )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ EventRegistrationToken token);
HRESULT ( STDMETHODCALLTYPE *add_DownloadFailed )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSource_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceDownloadFailedEventArgs *handler,
/* [out][retval] */ __RPC__out EventRegistrationToken *token);
HRESULT ( STDMETHODCALLTYPE *remove_DownloadFailed )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource * This,
/* [in] */ EventRegistrationToken token);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_IsLive(This,value) \
( (This)->lpVtbl -> get_IsLive(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_DesiredLiveOffset(This,value) \
( (This)->lpVtbl -> get_DesiredLiveOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_put_DesiredLiveOffset(This,value) \
( (This)->lpVtbl -> put_DesiredLiveOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_InitialBitrate(This,value) \
( (This)->lpVtbl -> get_InitialBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_put_InitialBitrate(This,value) \
( (This)->lpVtbl -> put_InitialBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_CurrentDownloadBitrate(This,value) \
( (This)->lpVtbl -> get_CurrentDownloadBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_CurrentPlaybackBitrate(This,value) \
( (This)->lpVtbl -> get_CurrentPlaybackBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_AvailableBitrates(This,value) \
( (This)->lpVtbl -> get_AvailableBitrates(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_DesiredMinBitrate(This,value) \
( (This)->lpVtbl -> get_DesiredMinBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_put_DesiredMinBitrate(This,value) \
( (This)->lpVtbl -> put_DesiredMinBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_DesiredMaxBitrate(This,value) \
( (This)->lpVtbl -> get_DesiredMaxBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_put_DesiredMaxBitrate(This,value) \
( (This)->lpVtbl -> put_DesiredMaxBitrate(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_AudioOnlyPlayback(This,value) \
( (This)->lpVtbl -> get_AudioOnlyPlayback(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_InboundBitsPerSecond(This,value) \
( (This)->lpVtbl -> get_InboundBitsPerSecond(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_get_InboundBitsPerSecondWindow(This,value) \
( (This)->lpVtbl -> get_InboundBitsPerSecondWindow(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_put_InboundBitsPerSecondWindow(This,value) \
( (This)->lpVtbl -> put_InboundBitsPerSecondWindow(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_add_DownloadBitrateChanged(This,handler,token) \
( (This)->lpVtbl -> add_DownloadBitrateChanged(This,handler,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_remove_DownloadBitrateChanged(This,token) \
( (This)->lpVtbl -> remove_DownloadBitrateChanged(This,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_add_PlaybackBitrateChanged(This,handler,token) \
( (This)->lpVtbl -> add_PlaybackBitrateChanged(This,handler,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_remove_PlaybackBitrateChanged(This,token) \
( (This)->lpVtbl -> remove_PlaybackBitrateChanged(This,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_add_DownloadRequested(This,handler,token) \
( (This)->lpVtbl -> add_DownloadRequested(This,handler,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_remove_DownloadRequested(This,token) \
( (This)->lpVtbl -> remove_DownloadRequested(This,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_add_DownloadCompleted(This,handler,token) \
( (This)->lpVtbl -> add_DownloadCompleted(This,handler,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_remove_DownloadCompleted(This,token) \
( (This)->lpVtbl -> remove_DownloadCompleted(This,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_add_DownloadFailed(This,handler,token) \
( (This)->lpVtbl -> add_DownloadFailed(This,handler,token) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_remove_DownloadFailed(This,token) \
( (This)->lpVtbl -> remove_DownloadFailed(This,token) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0028 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSource2[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSource2";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0028 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0028_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0028_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource2 */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("17890342-6760-4BB9-A58A-F7AA98B08C0E")
IAdaptiveMediaSource2 : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AdvancedSettings(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceAdvancedSettings **value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSource2 = __uuidof(IAdaptiveMediaSource2);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2Vtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AdvancedSettings )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2 * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings **value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2Vtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2Vtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_get_AdvancedSettings(This,value) \
( (This)->lpVtbl -> get_AdvancedSettings(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource2_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0029 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceAdvancedSettings[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceAdvancedSettings";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0029 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0029_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0029_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceAdvancedSettings */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("55DB1680-1AEB-47DC-AA08-9A11610BA45A")
IAdaptiveMediaSourceAdvancedSettings : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AllSegmentsIndependent(
/* [out][retval] */ __RPC__out boolean *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_AllSegmentsIndependent(
/* [in] */ boolean value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DesiredBitrateHeadroomRatio(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_double **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DesiredBitrateHeadroomRatio(
/* [in] */ __RPC__in_opt __FIReference_1_double *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_BitrateDowngradeTriggerRatio(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_double **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_BitrateDowngradeTriggerRatio(
/* [in] */ __RPC__in_opt __FIReference_1_double *value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceAdvancedSettings = __uuidof(IAdaptiveMediaSourceAdvancedSettings);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettingsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllSegmentsIndependent )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out][retval] */ __RPC__out boolean *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllSegmentsIndependent )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [in] */ boolean value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DesiredBitrateHeadroomRatio )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_double **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DesiredBitrateHeadroomRatio )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [in] */ __RPC__in_opt __FIReference_1_double *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_BitrateDowngradeTriggerRatio )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_double **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_BitrateDowngradeTriggerRatio )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings * This,
/* [in] */ __RPC__in_opt __FIReference_1_double *value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettingsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettingsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_get_AllSegmentsIndependent(This,value) \
( (This)->lpVtbl -> get_AllSegmentsIndependent(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_put_AllSegmentsIndependent(This,value) \
( (This)->lpVtbl -> put_AllSegmentsIndependent(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_get_DesiredBitrateHeadroomRatio(This,value) \
( (This)->lpVtbl -> get_DesiredBitrateHeadroomRatio(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_put_DesiredBitrateHeadroomRatio(This,value) \
( (This)->lpVtbl -> put_DesiredBitrateHeadroomRatio(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_get_BitrateDowngradeTriggerRatio(This,value) \
( (This)->lpVtbl -> get_BitrateDowngradeTriggerRatio(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_put_BitrateDowngradeTriggerRatio(This,value) \
( (This)->lpVtbl -> put_BitrateDowngradeTriggerRatio(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceAdvancedSettings_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0030 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceCreationResult[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceCreationResult";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0030 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0030_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0030_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceCreationResult */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("4686B6B2-800F-4E31-9093-76D4782013E7")
IAdaptiveMediaSourceCreationResult : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Status(
/* [out][retval] */ __RPC__out ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceCreationStatus *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MediaSource(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSource **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HttpResponseMessage(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Web::Http::IHttpResponseMessage **value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceCreationResult = __uuidof(IAdaptiveMediaSourceCreationResult);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResultVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Status )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceCreationStatus *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_MediaSource )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSource **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HttpResponseMessage )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CWeb_CHttp_CIHttpResponseMessage **value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResultVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResultVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_get_Status(This,value) \
( (This)->lpVtbl -> get_Status(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_get_MediaSource(This,value) \
( (This)->lpVtbl -> get_MediaSource(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_get_HttpResponseMessage(This,value) \
( (This)->lpVtbl -> get_HttpResponseMessage(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceCreationResult_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0031 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadBitrateChangedEventArgs[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadBitrateChangedEventArgs";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0031 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0031_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0031_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadBitrateChangedEventArgs */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("670C0A44-E04E-4EFF-816A-17399F78F4BA")
IAdaptiveMediaSourceDownloadBitrateChangedEventArgs : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_OldValue(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_NewValue(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadBitrateChangedEventArgs = __uuidof(IAdaptiveMediaSourceDownloadBitrateChangedEventArgs);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_OldValue )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_NewValue )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs * This,
/* [out][retval] */ __RPC__out UINT32 *value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_get_OldValue(This,value) \
( (This)->lpVtbl -> get_OldValue(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_get_NewValue(This,value) \
( (This)->lpVtbl -> get_NewValue(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadBitrateChangedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0032 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadCompletedEventArgs[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadCompletedEventArgs";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0032 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0032_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0032_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadCompletedEventArgs */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("19240DC3-5B37-4A1A-8970-D621CB6CA83B")
IAdaptiveMediaSourceDownloadCompletedEventArgs : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceType(
/* [out][retval] */ __RPC__out ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceResourceType *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceUri(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Foundation::IUriRuntimeClass **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeOffset(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeLength(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HttpResponseMessage(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Web::Http::IHttpResponseMessage **value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadCompletedEventArgs = __uuidof(IAdaptiveMediaSourceDownloadCompletedEventArgs);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceType )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceUri )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeLength )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HttpResponseMessage )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CWeb_CHttp_CIHttpResponseMessage **value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_get_ResourceType(This,value) \
( (This)->lpVtbl -> get_ResourceType(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_get_ResourceUri(This,value) \
( (This)->lpVtbl -> get_ResourceUri(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_get_ResourceByteRangeOffset(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_get_ResourceByteRangeLength(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeLength(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_get_HttpResponseMessage(This,value) \
( (This)->lpVtbl -> get_HttpResponseMessage(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadCompletedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0033 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadFailedEventArgs[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadFailedEventArgs";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0033 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0033_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0033_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadFailedEventArgs */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("37739048-F4AB-40A4-B135-C6DFD8BD7FF1")
IAdaptiveMediaSourceDownloadFailedEventArgs : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceType(
/* [out][retval] */ __RPC__out ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceResourceType *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceUri(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Foundation::IUriRuntimeClass **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeOffset(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeLength(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HttpResponseMessage(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Web::Http::IHttpResponseMessage **value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadFailedEventArgs = __uuidof(IAdaptiveMediaSourceDownloadFailedEventArgs);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceType )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceUri )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeLength )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HttpResponseMessage )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CWeb_CHttp_CIHttpResponseMessage **value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_get_ResourceType(This,value) \
( (This)->lpVtbl -> get_ResourceType(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_get_ResourceUri(This,value) \
( (This)->lpVtbl -> get_ResourceUri(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_get_ResourceByteRangeOffset(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_get_ResourceByteRangeLength(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeLength(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_get_HttpResponseMessage(This,value) \
( (This)->lpVtbl -> get_HttpResponseMessage(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadFailedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0034 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadRequestedDeferral[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadRequestedDeferral";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0034 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0034_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0034_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadRequestedDeferral */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("05C68F64-FA20-4DBD-9821-4BF4C9BF77AB")
IAdaptiveMediaSourceDownloadRequestedDeferral : public IInspectable
{
public:
virtual HRESULT STDMETHODCALLTYPE Complete( void) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadRequestedDeferral = __uuidof(IAdaptiveMediaSourceDownloadRequestedDeferral);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferralVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
HRESULT ( STDMETHODCALLTYPE *Complete )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral * This);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferralVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferralVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_Complete(This) \
( (This)->lpVtbl -> Complete(This) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0035 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadRequestedEventArgs[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadRequestedEventArgs";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0035 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0035_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0035_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadRequestedEventArgs */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("C83FDFFD-44A9-47A2-BF96-03398B4BFAAF")
IAdaptiveMediaSourceDownloadRequestedEventArgs : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceType(
/* [out][retval] */ __RPC__out ABI::Windows::Media::Streaming::Adaptive::AdaptiveMediaSourceResourceType *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceUri(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Foundation::IUriRuntimeClass **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeOffset(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeLength(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Result(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadResult **value) = 0;
virtual HRESULT STDMETHODCALLTYPE GetDeferral(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadRequestedDeferral **deferral) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadRequestedEventArgs = __uuidof(IAdaptiveMediaSourceDownloadRequestedEventArgs);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceType )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__out __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CAdaptiveMediaSourceResourceType *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceUri )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeLength )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Result )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult **value);
HRESULT ( STDMETHODCALLTYPE *GetDeferral )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedDeferral **deferral);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_get_ResourceType(This,value) \
( (This)->lpVtbl -> get_ResourceType(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_get_ResourceUri(This,value) \
( (This)->lpVtbl -> get_ResourceUri(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_get_ResourceByteRangeOffset(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_get_ResourceByteRangeLength(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeLength(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_get_Result(This,value) \
( (This)->lpVtbl -> get_Result(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_GetDeferral(This,deferral) \
( (This)->lpVtbl -> GetDeferral(This,deferral) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadRequestedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0036 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadResult[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadResult";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0036 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0036_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0036_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadResult */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("F4AFDC73-BCEE-4A6A-9F0A-FEC41E2339B0")
IAdaptiveMediaSourceDownloadResult : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceUri(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Foundation::IUriRuntimeClass **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ResourceUri(
/* [in] */ __RPC__in_opt ABI::Windows::Foundation::IUriRuntimeClass *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_InputStream(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Storage::Streams::IInputStream **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_InputStream(
/* [in] */ __RPC__in_opt ABI::Windows::Storage::Streams::IInputStream *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Buffer(
/* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Storage::Streams::IBuffer **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Buffer(
/* [in] */ __RPC__in_opt ABI::Windows::Storage::Streams::IBuffer *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ContentType(
/* [out][retval] */ __RPC__deref_out_opt HSTRING *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ContentType(
/* [in] */ __RPC__in HSTRING value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ExtendedStatus(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ExtendedStatus(
/* [in] */ UINT32 value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadResult = __uuidof(IAdaptiveMediaSourceDownloadResult);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResultVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceUri )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ResourceUri )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_InputStream )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CStorage_CStreams_CIInputStream **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_InputStream )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CStorage_CStreams_CIInputStream *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Buffer )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out][retval] */ __RPC__deref_out_opt __x_ABI_CWindows_CStorage_CStreams_CIBuffer **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Buffer )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CStorage_CStreams_CIBuffer *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ContentType )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out][retval] */ __RPC__deref_out_opt HSTRING *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ContentType )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ __RPC__in HSTRING value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ExtendedStatus )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ExtendedStatus )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult * This,
/* [in] */ UINT32 value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResultVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResultVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_get_ResourceUri(This,value) \
( (This)->lpVtbl -> get_ResourceUri(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_put_ResourceUri(This,value) \
( (This)->lpVtbl -> put_ResourceUri(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_get_InputStream(This,value) \
( (This)->lpVtbl -> get_InputStream(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_put_InputStream(This,value) \
( (This)->lpVtbl -> put_InputStream(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_get_Buffer(This,value) \
( (This)->lpVtbl -> get_Buffer(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_put_Buffer(This,value) \
( (This)->lpVtbl -> put_Buffer(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_get_ContentType(This,value) \
( (This)->lpVtbl -> get_ContentType(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_put_ContentType(This,value) \
( (This)->lpVtbl -> put_ContentType(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_get_ExtendedStatus(This,value) \
( (This)->lpVtbl -> get_ExtendedStatus(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_put_ExtendedStatus(This,value) \
( (This)->lpVtbl -> put_ExtendedStatus(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0037 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceDownloadResult2[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceDownloadResult2";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0037 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0037_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0037_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceDownloadResult2 */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("15552CB7-7B80-4AC4-8660-A4B97F7C70F0")
IAdaptiveMediaSourceDownloadResult2 : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeOffset(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ResourceByteRangeOffset(
/* [in] */ __RPC__in_opt __FIReference_1_UINT64 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResourceByteRangeLength(
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ResourceByteRangeLength(
/* [in] */ __RPC__in_opt __FIReference_1_UINT64 *value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceDownloadResult2 = __uuidof(IAdaptiveMediaSourceDownloadResult2);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2Vtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ResourceByteRangeOffset )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [in] */ __RPC__in_opt __FIReference_1_UINT64 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ResourceByteRangeLength )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [out][retval] */ __RPC__deref_out_opt __FIReference_1_UINT64 **value);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ResourceByteRangeLength )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2 * This,
/* [in] */ __RPC__in_opt __FIReference_1_UINT64 *value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2Vtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2Vtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_get_ResourceByteRangeOffset(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_put_ResourceByteRangeOffset(This,value) \
( (This)->lpVtbl -> put_ResourceByteRangeOffset(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_get_ResourceByteRangeLength(This,value) \
( (This)->lpVtbl -> get_ResourceByteRangeLength(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_put_ResourceByteRangeLength(This,value) \
( (This)->lpVtbl -> put_ResourceByteRangeLength(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceDownloadResult2_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0038 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0038 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0038_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0038_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("23A29F6D-7DDA-4A51-87A9-6FA8C5B292BE")
IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_OldValue(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_NewValue(
/* [out][retval] */ __RPC__out UINT32 *value) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AudioOnly(
/* [out][retval] */ __RPC__out boolean *value) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs = __uuidof(IAdaptiveMediaSourcePlaybackBitrateChangedEventArgs);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_OldValue )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_NewValue )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out][retval] */ __RPC__out UINT32 *value);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AudioOnly )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs * This,
/* [out][retval] */ __RPC__out boolean *value);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_get_OldValue(This,value) \
( (This)->lpVtbl -> get_OldValue(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_get_NewValue(This,value) \
( (This)->lpVtbl -> get_NewValue(This,value) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_get_AudioOnly(This,value) \
( (This)->lpVtbl -> get_AudioOnly(This,value) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourcePlaybackBitrateChangedEventArgs_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0039 */
/* [local] */
#if !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_INTERFACE_DEFINED__)
extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Media_Streaming_Adaptive_IAdaptiveMediaSourceStatics[] = L"Windows.Media.Streaming.Adaptive.IAdaptiveMediaSourceStatics";
#endif /* !defined(____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_INTERFACE_DEFINED__) */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0039 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0039_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0039_v0_0_s_ifspec;
#ifndef ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_INTERFACE_DEFINED__
#define ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_INTERFACE_DEFINED__
/* interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics */
/* [uuid][object] */
/* interface ABI::Windows::Media::Streaming::Adaptive::IAdaptiveMediaSourceStatics */
/* [uuid][object] */
EXTERN_C const IID IID___x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics;
#if defined(__cplusplus) && !defined(CINTERFACE)
} /* end extern "C" */
namespace ABI {
namespace Windows {
namespace Media {
namespace Streaming {
namespace Adaptive {
MIDL_INTERFACE("50A6BD5D-66EF-4CD3-9579-9E660507DC3F")
IAdaptiveMediaSourceStatics : public IInspectable
{
public:
virtual HRESULT STDMETHODCALLTYPE IsContentTypeSupported(
/* [in] */ __RPC__in HSTRING contentType,
/* [out][retval] */ __RPC__out boolean *result) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateFromUriAsync(
/* [in] */ __RPC__in_opt ABI::Windows::Foundation::IUriRuntimeClass *uri,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateFromUriWithDownloaderAsync(
/* [in] */ __RPC__in_opt ABI::Windows::Foundation::IUriRuntimeClass *uri,
/* [in] */ __RPC__in_opt ABI::Windows::Web::Http::IHttpClient *httpClient,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateFromStreamAsync(
/* [in] */ __RPC__in_opt ABI::Windows::Storage::Streams::IInputStream *stream,
/* [in] */ __RPC__in_opt ABI::Windows::Foundation::IUriRuntimeClass *uri,
/* [in] */ __RPC__in HSTRING contentType,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateFromStreamWithDownloaderAsync(
/* [in] */ __RPC__in_opt ABI::Windows::Storage::Streams::IInputStream *stream,
/* [in] */ __RPC__in_opt ABI::Windows::Foundation::IUriRuntimeClass *uri,
/* [in] */ __RPC__in HSTRING contentType,
/* [in] */ __RPC__in_opt ABI::Windows::Web::Http::IHttpClient *httpClient,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result) = 0;
};
extern const __declspec(selectany) IID & IID_IAdaptiveMediaSourceStatics = __uuidof(IAdaptiveMediaSourceStatics);
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
} /* end namespace */
extern "C" {
#else /* C style interface */
typedef struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStaticsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This);
ULONG ( STDMETHODCALLTYPE *Release )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [out] */ __RPC__out ULONG *iidCount,
/* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [out] */ __RPC__deref_out_opt HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [out] */ __RPC__out TrustLevel *trustLevel);
HRESULT ( STDMETHODCALLTYPE *IsContentTypeSupported )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in HSTRING contentType,
/* [out][retval] */ __RPC__out boolean *result);
HRESULT ( STDMETHODCALLTYPE *CreateFromUriAsync )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass *uri,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result);
HRESULT ( STDMETHODCALLTYPE *CreateFromUriWithDownloaderAsync )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass *uri,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CWeb_CHttp_CIHttpClient *httpClient,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result);
HRESULT ( STDMETHODCALLTYPE *CreateFromStreamAsync )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CStorage_CStreams_CIInputStream *stream,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass *uri,
/* [in] */ __RPC__in HSTRING contentType,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result);
HRESULT ( STDMETHODCALLTYPE *CreateFromStreamWithDownloaderAsync )(
__RPC__in __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics * This,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CStorage_CStreams_CIInputStream *stream,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CFoundation_CIUriRuntimeClass *uri,
/* [in] */ __RPC__in HSTRING contentType,
/* [in] */ __RPC__in_opt __x_ABI_CWindows_CWeb_CHttp_CIHttpClient *httpClient,
/* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CMedia__CStreaming__CAdaptive__CAdaptiveMediaSourceCreationResult **result);
END_INTERFACE
} __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStaticsVtbl;
interface __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics
{
CONST_VTBL struct __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStaticsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_IsContentTypeSupported(This,contentType,result) \
( (This)->lpVtbl -> IsContentTypeSupported(This,contentType,result) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_CreateFromUriAsync(This,uri,result) \
( (This)->lpVtbl -> CreateFromUriAsync(This,uri,result) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_CreateFromUriWithDownloaderAsync(This,uri,httpClient,result) \
( (This)->lpVtbl -> CreateFromUriWithDownloaderAsync(This,uri,httpClient,result) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_CreateFromStreamAsync(This,stream,uri,contentType,result) \
( (This)->lpVtbl -> CreateFromStreamAsync(This,stream,uri,contentType,result) )
#define __x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_CreateFromStreamWithDownloaderAsync(This,stream,uri,contentType,httpClient,result) \
( (This)->lpVtbl -> CreateFromStreamWithDownloaderAsync(This,stream,uri,contentType,httpClient,result) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* ____x_ABI_CWindows_CMedia_CStreaming_CAdaptive_CIAdaptiveMediaSourceStatics_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0040 */
/* [local] */
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSource_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSource_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSource[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSource";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceAdvancedSettings_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceAdvancedSettings_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceAdvancedSettings[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceAdvancedSettings";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceCreationResult_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceCreationResult_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceCreationResult[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceCreationResult";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadBitrateChangedEventArgs_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadBitrateChangedEventArgs_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadBitrateChangedEventArgs[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadBitrateChangedEventArgs";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadCompletedEventArgs_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadCompletedEventArgs_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadCompletedEventArgs[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadCompletedEventArgs";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadFailedEventArgs_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadFailedEventArgs_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadFailedEventArgs[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadFailedEventArgs";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedDeferral_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedDeferral_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedDeferral[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadRequestedDeferral";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedEventArgs_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedEventArgs_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadRequestedEventArgs[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadRequestedEventArgs";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadResult_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadResult_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourceDownloadResult[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadResult";
#endif
#ifndef RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourcePlaybackBitrateChangedEventArgs_DEFINED
#define RUNTIMECLASS_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourcePlaybackBitrateChangedEventArgs_DEFINED
extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Media_Streaming_Adaptive_AdaptiveMediaSourcePlaybackBitrateChangedEventArgs[] = L"Windows.Media.Streaming.Adaptive.AdaptiveMediaSourcePlaybackBitrateChangedEventArgs";
#endif
/* interface __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0040 */
/* [local] */
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0040_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_windows2Emedia2Estreaming2Eadaptive_0000_0040_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */
unsigned long __RPC_USER HSTRING_UserSize( __RPC__in unsigned long *, unsigned long , __RPC__in HSTRING * );
unsigned char * __RPC_USER HSTRING_UserMarshal( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in HSTRING * );
unsigned char * __RPC_USER HSTRING_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out HSTRING * );
void __RPC_USER HSTRING_UserFree( __RPC__in unsigned long *, __RPC__in HSTRING * );
unsigned long __RPC_USER HSTRING_UserSize64( __RPC__in unsigned long *, unsigned long , __RPC__in HSTRING * );
unsigned char * __RPC_USER HSTRING_UserMarshal64( __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in HSTRING * );
unsigned char * __RPC_USER HSTRING_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out HSTRING * );
void __RPC_USER HSTRING_UserFree64( __RPC__in unsigned long *, __RPC__in HSTRING * );
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"trent@trent.me"
] | trent@trent.me |
573171df081d8eabd701a6f87c79a8e8cffd121d | ffd84b61323d53863ae46872e16f55966f4e16ce | /ESP32-Firebase-Car/ESP32-Firebase-Car.ino | dcbbd480515db849d8454371c51161ee803ea798 | [] | no_license | dtmkeng/Project_EE | c4bed255fa6608f806bcd69fb74205fd3a81e79e | 4ca53945eecc3cecbcc55216461b208b79b3471b | refs/heads/master | 2021-05-13T13:33:58.458871 | 2018-01-08T16:50:32 | 2018-01-08T16:50:32 | 116,710,518 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,140 | ino | #include <WiFi.h>
#include <IOXhop_FirebaseESP32.h>
#include <time.h>
// Config Firebase
#define FIREBASE_HOST "esp32-ccar.firebaseio.com"
#define FIREBASE_AUTH "q5iEL3edyyzhS4QVT7VGfJ8PHpzpfWTaUNlsVNrC"
// Config connect WiFi
#define WIFI_SSID "DevTech"
#define WIFI_PASSWORD "Alonesnon0"
// Config time
int timezone = 7;
char ntp_server1[20] = "ntp.ku.ac.th";
char ntp_server2[20] = "fw.eng.ku.ac.th";
char ntp_server3[20] = "time.uni.net.th";
int dst = 0;
// Sensor
unsigned int Car = 0;
unsigned int Times = 0;
void setup() {
Serial.begin(9600);
WiFi.mode(WIFI_STA);
// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
configTime(timezone * 3600, dst, ntp_server1, ntp_server2, ntp_server3);
Serial.println("Waiting for time");
while (!time(nullptr)) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println("Now: " + NowString());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop() {
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["Car"] = Car;
root["Times"] = Times;
root["time"] = NowString();
// append a new value to /logDHT
String name = Firebase.push("logCar", root);
// handle error
if (Firebase.failed()) {
Serial.print("pushing /logs failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /logCar/");
Serial.println(name);
// Test
Car++;
Times = random(300,2000);
delay(30000);
}
String NowString() {
time_t now = time(nullptr);
struct tm* newtime = localtime(&now);
String tmpNow = "";
tmpNow += String(newtime->tm_year + 1900);
tmpNow += "-";
tmpNow += String(newtime->tm_mon + 1);
tmpNow += "-";
tmpNow += String(newtime->tm_mday);
tmpNow += " ";
tmpNow += String(newtime->tm_hour);
tmpNow += ":";
tmpNow += String(newtime->tm_min);
tmpNow += ":";
tmpNow += String(newtime->tm_sec);
return tmpNow;
}
| [
"nongrace6654@gmail.com"
] | nongrace6654@gmail.com |
3d71859c9a08b365e82e8d3d3db4ab97298e25e1 | 7b35b2c1bebe204c0087704933406aa6e99a9640 | /torch/csrc/jit/tensorexpr/kernel.cpp | 2284fc018c402547b81c9fa0f556ad0255a9d107 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"BSL-1.0",
"Apache-2.0"
] | permissive | zpao/pytorch | b25e3740394291f608bc4447f6ceaae67760f27c | c06d2afa9903573cf1afd39547d3afd4aa6fca98 | refs/heads/master | 2023-06-21T18:13:14.674430 | 2021-05-26T17:32:29 | 2021-05-26T17:33:32 | 177,882,461 | 1 | 0 | null | 2019-03-26T23:12:46 | 2019-03-26T23:12:46 | null | UTF-8 | C++ | false | false | 104,604 | cpp | #include <c10/util/variant.h>
#include <torch/csrc/jit/tensorexpr/kernel.h>
#include <ATen/ExpandUtils.h>
#include <ATen/TensorGeometry.h>
#include <c10/util/string_utils.h>
#include <torch/csrc/jit/jit_log.h>
#include <torch/csrc/jit/passes/utils/subgraph_utils.h>
#include <torch/csrc/jit/tensorexpr/analysis.h>
#include <torch/csrc/jit/tensorexpr/ir_printer.h>
#include <torch/csrc/jit/tensorexpr/ir_simplifier.h>
#include <torch/csrc/jit/tensorexpr/loopnest.h>
#include <torch/csrc/jit/tensorexpr/operators/conv2d.h>
#include <iostream>
using namespace torch::jit;
using namespace torch::jit::tensorexpr;
namespace torch {
namespace jit {
namespace tensorexpr {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static int te_cuda_pointwise_loop_levels = -1;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static int te_cuda_pointwise_block_count = -1;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static int te_cuda_pointwise_block_size = -1;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static bool fallback_allowed = false;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static bool te_generate_block_code = false;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
static bool te_must_use_llvm_on_cpu = true;
static bool cat_wo_conditionals = true; // NOLINT
static bool opt_conditionals = false; // NOLINT
bool setFallbackAllowed(bool value) {
bool old_value = fallback_allowed;
fallback_allowed = value;
return old_value;
}
bool fallbackAllowed() {
static const char* enable_c_str = std::getenv("PYTORCH_TENSOREXPR_FALLBACK");
if (!enable_c_str) {
return fallback_allowed;
}
if (std::string(enable_c_str) == "0") {
return false;
}
return true;
}
bool fallbackEnforced() {
static const char* enable_c_str = std::getenv("PYTORCH_TENSOREXPR_FALLBACK");
if (tensorexpr::getTEGenerateBlockCode()) {
return false;
}
if (!enable_c_str) {
return fallback_allowed;
}
if (std::string(enable_c_str) == "2") {
return true;
}
return false;
}
bool dontUseLLVMFlag() {
static const char* enable_c_str =
std::getenv("PYTORCH_TENSOREXPR_DONT_USE_LLVM");
if (!enable_c_str) {
return false;
}
return std::string(enable_c_str) == "1";
}
int& getTECudaPointwiseLoopLevels() {
return te_cuda_pointwise_loop_levels;
}
int& getTECudaPointwiseBlockCount() {
return te_cuda_pointwise_block_count;
}
int& getTECudaPointwiseBlockSize() {
return te_cuda_pointwise_block_size;
}
// TODO: Remove this global var
// Ideally Block code gen should be decided
// based on device type in tensor.
bool& getTEGenerateBlockCode() {
return te_generate_block_code;
}
bool& getTEMustUseLLVMOnCPU() {
return te_must_use_llvm_on_cpu;
}
bool& getCatWoConditionals() {
return cat_wo_conditionals;
}
bool& getOptConditionals() {
return opt_conditionals;
}
c10::optional<at::Device> pickDeviceType(
const at::ArrayRef<torch::jit::Value*>& inputs) {
c10::optional<at::Device> device = c10::nullopt;
for (auto const& input : inputs) {
auto tt = input->type()->cast<TensorType>();
if (tt && tt->device()) {
if (device && *device != *tt->device()) {
return c10::nullopt;
}
device = *tt->device();
}
}
return device;
}
// If v is a Tensor with concretely-known sizes and dtype, return them, else
// nullopt.
c10::optional<TensorInfo> getTensorInfoJit(torch::jit::Value* v) {
auto const& it = v->type()->cast<TensorType>();
if (!it) {
return c10::nullopt;
}
if (!it->isComplete()) {
return c10::nullopt;
}
if (!it->scalarType()) {
return c10::nullopt;
}
auto concrete_sizes = it->sizes().concrete_sizes();
if (!concrete_sizes) {
return c10::nullopt;
}
return TensorInfo{*concrete_sizes, *it->scalarType()};
}
c10::optional<TensorInfo> getTensorInfo(BufHandle b) {
std::vector<int64_t> dims;
for (auto dim : b.dims()) {
auto val = dynamic_cast<const IntImm*>(dim.node());
if (!val) {
return c10::nullopt;
}
dims.push_back(val->value());
}
return TensorInfo{dims, static_cast<at::ScalarType>(b.dtype().scalar_type())};
}
std::vector<int64_t> _pair_int(ArgValue v) {
if (auto t = c10::get_if<IntList>(&v)) {
return {(*t)[0], (*t)[1]};
}
auto i = c10::get<int64_t>(v);
return {i, i};
}
std::vector<int64_t> _pair_int(IValue v) {
if (v.isIntList()) {
return v.toIntVector();
} else {
return {v.toInt(), v.toInt()};
}
}
bool conv2dIsSupported(
const TensorInfo& input,
const TensorInfo& weight,
const TensorInfo& bias,
const std::vector<int64_t>& stride,
const std::vector<int64_t>& pad,
const std::vector<int64_t>& dilation,
int64_t groups) {
if (input.dtype != c10::ScalarType::Float ||
weight.dtype != c10::ScalarType::Float ||
bias.dtype != c10::ScalarType::Float) {
GRAPH_DEBUG("only float32 allowed");
return false;
}
if (input.dims.size() != 4 || weight.dims.size() != 4 ||
bias.dims.size() != 1) {
GRAPH_DEBUG("inputs are the wrong size");
return false;
}
auto Cin = input.dims[1];
auto Cout = weight.dims[0];
auto CperG = weight.dims[1];
if (Cin != Cout || Cin != groups || CperG != 1) {
GRAPH_DEBUG("not depthwise");
return false;
}
auto KH = weight.dims[2];
auto KW = weight.dims[3];
if (KH != 3 || KW != 3) {
GRAPH_DEBUG("not 3x3");
return false;
}
if (stride.size() != 2 || stride[0] != stride[1]) {
GRAPH_DEBUG("unsupported stride");
return false;
}
if (pad.size() != 2 || pad[0] != pad[1]) {
GRAPH_DEBUG("unsupported pad");
return false;
}
if (dilation.size() != 2 || dilation[0] != 1 || dilation[1] != 1) {
GRAPH_DEBUG("unsupported dilation");
return false;
}
return true;
}
// The fuser only supports conv2d with very specific properties:
// - Static shapes: 4-d input and filter, 1-d bias.
// - Constant strides/padding/dilation/groups
// - Equal padding and strides, dilation == 1.
// - Depthwise (groups == in_channels == out_channels)
// - 3x3 kernel
bool conv2dIsSupportedJit(const torch::jit::Node* node) {
auto const& input = getTensorInfoJit(node->input(0));
auto const& weight = getTensorInfoJit(node->input(1));
auto const& bias = getTensorInfoJit(node->input(2));
auto const& stride = toIValue(node->input(3));
auto const& pad = toIValue(node->input(4));
auto const& dilation = toIValue(node->input(5));
auto const& groups = toIValue(node->input(6));
// Everything should be statically known.
if (!input || !weight || !bias || !stride || !pad || !dilation || !groups) {
GRAPH_DEBUG("some params aren't static");
return false;
}
return conv2dIsSupported(
*input,
*weight,
*bias,
_pair_int(*stride),
_pair_int(*pad),
_pair_int(*dilation),
groups->toInt());
}
// The fuser currently only supports matmul of 2D x 2D matrices
bool matmulIsSupported(const torch::jit::Node* node) {
auto const& input0 = getTensorInfoJit(node->input(0));
auto const& input1 = getTensorInfoJit(node->input(1));
// Everything should be statically known.
if (!input0 || !input1) {
GRAPH_DEBUG("matmulIsSupported: Input shapes aren't static");
return false;
}
// Proper ndim for tensor inputs.
if (input0->dims.size() != 2 || input1->dims.size() != 2) {
GRAPH_DEBUG("matmulIsSupported: Unsupported input sizes");
return false;
}
return true;
}
void annotateInputShapes(
const std::shared_ptr<Graph>& graph,
const std::vector<c10::optional<at::Tensor>>& example_inputs) {
TORCH_INTERNAL_ASSERT(graph->inputs().size() == example_inputs.size());
for (size_t idx = 0; idx < example_inputs.size(); idx++) {
if (auto t = example_inputs[idx]) {
auto concrete_tensor_type = tensorTypeInCurrentExecutionContext(*t);
graph->inputs().at(idx)->setType(concrete_tensor_type);
}
}
}
std::shared_ptr<Graph> removeUnusedSelfArgument(
const std::shared_ptr<Graph>& graph) {
if (graph->inputs().size() == 0) {
return graph;
}
jit::Value* self_argument = graph->inputs().at(0);
if (self_argument->uses().size() != 0 ||
!self_argument->type()->is_module()) {
return graph;
}
std::shared_ptr<Graph> res = graph->copy();
res->eraseInput(0);
return res;
}
} // namespace tensorexpr
} // namespace jit
} // namespace torch
size_t normalizeAndCheckIndex(int64_t idx, int64_t list_size) {
if (idx < 0) {
// Handle negative indexing
idx = list_size + idx;
}
if (idx < 0 || idx >= list_size) {
AT_ERROR("Invalid index ", idx, " for list_size", list_size);
}
return static_cast<size_t>(idx);
}
static at::ScalarType tensorType(const Buf* b) {
return static_cast<at::ScalarType>(b->dtype().scalar_type());
}
static std::vector<ExprHandle> computeIndicesToBroadcast(
const std::vector<ExprHandle>& outputAxes,
const std::vector<ExprHandle>& inputSizes) {
if (outputAxes.size() < inputSizes.size()) {
throw malformed_input("Cannot broadcast to a lower rank tensor");
}
std::vector<ExprHandle> bcast;
auto axisIt = outputAxes.rbegin();
auto sizeIt = inputSizes.rbegin();
while (sizeIt != inputSizes.rend()) {
auto const& size = sizeIt->AsNode<IntImm>();
if (size && size->value() == 1) {
bcast.emplace_back(0);
} else {
bcast.emplace_back(*axisIt);
}
++axisIt;
++sizeIt;
}
std::reverse(bcast.begin(), bcast.end());
return bcast;
}
std::vector<int64_t> bufferSizes(const Buf* b) {
std::vector<int64_t> sizes;
for (size_t i = 0; i < b->ndim(); i++) {
sizes.push_back(dynamic_cast<const IntImm*>(b->dim(i))->value());
}
return sizes;
}
ExprHandle TensorExprKernel::chunk(
const Buf* b,
size_t chunkIdx,
int64_t dim,
int64_t chunks,
const std::vector<ExprHandle>& axes) {
auto norm_dim = normalizeAndCheckIndex(dim, axes.size());
auto sizes = bufferSizes(b);
size_t step = sizes[norm_dim] / chunks;
std::vector<ExprHandle> indices;
for (size_t i = 0; i < axes.size(); ++i) {
if (i == norm_dim) {
indices.push_back(axes[i] + IntImm::make((int)chunkIdx * (int)step));
} else {
indices.push_back(axes[i]);
}
}
return BufHandle(b).load(indices);
}
ExprHandle promoteToDtype(ExprHandle e, ScalarType dt) {
if (e.dtype().scalar_type() == dt) {
return e;
}
switch (dt) {
// NOLINTNEXTLINE
#define TYPE_CASE(Type, Name) \
case ScalarType::Name: \
e = cast<Type>(e); \
break;
AT_FORALL_SCALAR_TYPES_AND2(Half, Bool, TYPE_CASE);
#undef TYPE_CASE
default:
throw unsupported_dtype();
}
return e;
}
ExprHandle broadcast(BufHandle b, const std::vector<ExprHandle>& axes) {
return b.load(computeIndicesToBroadcast(axes, b.dims()));
}
ExprHandle constant(const ArgValue& v) {
if (auto s = c10::get_if<tensorexpr::VarHandle>(&v)) {
return *s;
} else if (auto d = c10::get_if<double>(&v)) {
return DoubleImm::make(*d);
} else if (auto i = c10::get_if<int64_t>(&v)) {
return LongImm::make(*i);
} else if (auto b = c10::get_if<bool>(&v)) {
return BoolImm::make(*b);
} else if (c10::get_if<ArgNone>(&v)) {
// This is just a placeholder so we don't throw. None-handling
// is operator-specific and should be handled properly in
// the operator-specific lowering code.
return IntImm::make(0);
} else {
throw unsupported_dtype("Trying to convert unsupported dtype to constant");
}
}
ExprHandle tensorOrConstant(
const ArgValue& v,
const std::vector<ExprHandle>& axes) {
if (auto b = c10::get_if<BufHandle>(&v)) {
return broadcast(*b, axes);
}
return constant(v);
}
ExprHandle TensorExprKernel::constant(const torch::jit::Value* v) {
if (v->node()->kind() == prim::Constant) {
const auto val = toIValue(v).value();
if (val.isDouble()) {
return DoubleImm::make(val.toDouble());
} else if (val.isInt()) {
return LongImm::make(val.toInt());
} else if (val.isBool()) {
return BoolImm::make(val.toBool());
} else if (val.isNone()) {
// This is just a placeholder so we don't throw. None-handling
// is operator-specific and should be handled properly in
// the operator-specific lowering code.
return IntImm::make(0);
} else {
throw unsupported_dtype();
}
}
if (!scalars_.count(v)) {
throw malformed_input("no scalar in Constant");
}
return scalars_.at(v);
}
ExprHandle TensorExprKernel::tensorOrConstant(
const torch::jit::Value* v,
const std::vector<ExprHandle>& axes) {
auto ti = bufs_.find(v);
if (ti != bufs_.end()) {
return broadcast(BufHandle(ti->second), axes);
}
return constant(v);
}
// Convert boolean to integer, if needed.
ExprHandle boolToInteger(const ExprHandle& x) {
return x.dtype().scalar_type() == ScalarType::Bool ? cast<int>(x) : x;
}
ArgValue TensorExprKernel::toArg(const torch::jit::Value* v) const {
auto ti = bufs_.find(v);
if (ti != bufs_.end()) {
return BufHandle(ti->second);
}
if (v->node()->kind() == prim::ListConstruct) {
std::vector<ArgValue> vec;
for (auto el : v->node()->inputs()) {
vec.push_back(toArg(el));
}
if (vec.size() == 0) {
return BufList(); // Return arbitrarily typed vector
} else if (c10::get_if<BufHandle>(&vec[0])) {
return convertVecArgValue<BufHandle>(vec);
} else if (c10::get_if<int64_t>(&vec[0])) {
return convertVecArgValue<int64_t>(vec);
}
throw unsupported_dtype();
}
if (v->node()->kind() == prim::Constant) {
const auto val = toIValue(v).value();
if (val.isDouble()) {
return val.toDouble();
} else if (val.isInt()) {
return val.toInt();
} else if (val.isBool()) {
return val.toBool();
} else if (val.isNone()) {
// This is just a placeholder so we don't throw. None-handling
// is operator-specific and should be handled properly in
// the operator-specific lowering code.
return ArgNone();
} else if (val.isIntList()) {
return val.toIntVector();
} else {
throw unsupported_dtype(val.type()->str());
}
}
if (!scalars_.count(v)) {
throw malformed_input("no scalar in Constant");
}
return scalars_.at(v);
}
std::vector<ExprHandle> TensorExprKernel::sizesFromVaryingShape(
const c10::VaryingShape<int64_t>& shape) {
std::vector<ExprHandle> dims;
for (size_t i = 0; i < *shape.size(); i++) {
dims.push_back(IntImm::make(*shape[i]));
}
return dims;
}
std::vector<ExprHandle> TensorExprKernel::sizesForValue(
const torch::jit::Value* v) {
if (known_sizes_.count(v)) {
return known_sizes_.at(v);
}
// If the shape is present in the type info, just extract it from here. No
// need to infer it.
if (v->type()->kind() == TypeKind::TensorType) {
auto tt = v->type()->cast<TensorType>();
if (tt->isComplete()) {
return sizesFromVaryingShape(tt->sizes());
}
}
if (v->type()->isSubtypeOf(FloatType::get()) ||
v->type()->isSubtypeOf(IntType::get())) {
return {1};
}
if (v->type()->isSubtypeOf(NoneType::get())) {
return {};
}
known_sizes_[v] = inferSizesForValue(v);
return known_sizes_.at(v);
}
std::vector<ExprHandle> TensorExprKernel::inferSizesForValue(
const torch::jit::Value* v) {
switch (v->node()->kind()) {
case aten::_cast_Float:
case aten::to:
case aten::sigmoid:
case aten::reciprocal:
case aten::neg:
case aten::relu:
case aten::gelu:
case aten::batch_norm:
case aten::isnan:
case aten::log:
case aten::log10:
case aten::log1p:
case aten::log2:
case aten::exp:
case aten::expm1:
case aten::erf:
case aten::erfc:
case aten::cos:
case aten::sin:
case aten::tan:
case aten::rand_like:
case aten::acos:
case aten::asin:
case aten::cosh:
case aten::sinh:
case aten::atan:
case aten::tanh:
case aten::hardtanh:
case aten::hardswish:
case aten::sqrt:
case aten::rsqrt:
case aten::abs:
case aten::ceil:
case aten::floor:
case aten::round:
case aten::trunc:
case aten::frac:
case aten::lgamma:
case aten::type_as:
case aten::masked_fill:
return sizesForValue(v->node()->input(0));
case aten::sub:
case aten::add:
case aten::mul:
case aten::div:
case aten::__and__:
case aten::__or__:
case aten::__xor__:
case aten::__lshift__:
case aten::__rshift__:
case aten::eq:
case aten::ne:
case aten::ge:
case aten::gt:
case aten::le:
case aten::lt:
case aten::min:
case aten::max:
case aten::pow:
case aten::fmod:
case aten::remainder:
case aten::atan2: {
std::vector<std::vector<ExprHandle>> shapes;
for (size_t idx = 0; idx < 2; idx++) {
torch::jit::Value* inp = v->node()->input(idx);
shapes.push_back(sizesForValue(inp));
}
return broadcastShapesMut(shapes);
}
case aten::lerp:
case aten::clamp:
case aten::threshold:
case aten::where: {
std::vector<std::vector<ExprHandle>> shapes;
for (size_t idx = 0; idx < 3; idx++) {
torch::jit::Value* inp = v->node()->input(idx);
shapes.push_back(sizesForValue(inp));
}
return broadcastShapesMut(shapes);
}
case aten::addcmul: {
std::vector<std::vector<ExprHandle>> shapes;
for (size_t idx = 0; idx < 4; idx++) {
torch::jit::Value* inp = v->node()->input(idx);
shapes.push_back(sizesForValue(inp));
}
return broadcastShapesMut(shapes);
}
case prim::ConstantChunk: {
auto shape = sizesForValue(v->node()->input());
int dim = v->node()->i(attr::dim);
int chunks = v->node()->i(attr::chunks);
shape[dim] = IRSimplifier::simplify(shape[dim] / chunks);
return shape;
}
case aten::unsqueeze: {
auto const& n = v->node();
auto shape = sizesForValue(n->input(0));
int64_t dim = toIValue(n->input(1))->toInt();
// From the documentation
// (https://pytorch.org/docs/master/generated/torch.unsqueeze.html):
//
// A dim value within the range [-input.dim() - 1, input.dim() + 1) can be
// used. Negative dim will correspond to unsqueeze() applied at dim = dim
// + input.dim() + 1.
if (dim < 0) {
dim = dim + shape.size() + 1;
}
// NOLINTNEXTLINE(clang-diagnostic-sign-compare)
if (dim < 0 || dim > shape.size()) {
throw std::runtime_error("Invalid 'dim' input in aten::unsqueeze");
}
shape.insert(shape.begin() + dim, ExprHandle(1));
return shape;
}
case aten::cat: {
// In JIT IR, aten::cat usually appears with the following nodes around
// it:
// %dim : int = prim::Constant[value=0]()
// %inputs : Tensor[] = prim::ListConstruct(%a, %b, ...)
// %cat_output : Tensor = aten::cat(%inputs, %dim)
// Shapes of the input tensors could only differ at the dimension %dim.
// The sizes of the output tensor on that dimension is a sum of the
// corresponding sizes of the input tensors, the other dimension have the
// same sizes.
// Negative dim will correspond to dim = dim + input.dim().
auto const& n = v->node();
auto inputs = n->input(0)->node()->inputs();
if (inputs.size() == 0) {
throw std::runtime_error("Empty input list is passed to aten::cat");
}
TORCH_INTERNAL_ASSERT(n->input(1)->node()->kind() == prim::Constant);
int64_t dim = n->input(1)->node()->i(attr::value);
auto shape = sizesForValue(inputs[0]);
size_t norm_dim = normalizeAndCheckIndex(dim, shape.size());
ExprHandle concat_dim_size = 0;
for (auto input : inputs) {
concat_dim_size = concat_dim_size + sizesForValue(input)[norm_dim];
}
concat_dim_size = IRSimplifier::simplify(concat_dim_size);
shape[norm_dim] = concat_dim_size;
return shape;
}
case aten::softmax:
case aten::log_softmax:
// Output of softmax / log_softmax has the same shape as input 0.
return sizesForValue(v->node()->input(0));
case aten::slice:
throw std::runtime_error(
"Shape info is not implemented for this kind of node");
default: {
GRAPH_DEBUG("Can't infer sizes for the node: ", *v->node());
GRAPH_DEBUG("Full fusion group graph:\n", *v->node()->owningGraph());
throw std::runtime_error("Unhandled node kind");
}
}
}
ExprHandle promoteIntegerToDefaultType(const ExprHandle& e) {
auto scalarType = static_cast<c10::ScalarType>(e.dtype().scalar_type());
if (!c10::isIntegralType(scalarType, /*includeBool*/ true)) {
return e;
}
auto defaultType = c10::typeMetaToScalarType(c10::get_default_dtype());
// We intend to promote Integers to floating-point types
TORCH_INTERNAL_ASSERT(
!c10::isIntegralType(defaultType, /*includeBool*/ true));
return Cast::make(
Dtype(
static_cast<tensorexpr::ScalarType>(defaultType), e.dtype().lanes()),
e);
}
ExprHandle promoteHalfToFloat(const ExprHandle& e) {
auto scalarType = static_cast<c10::ScalarType>(e.dtype().scalar_type());
auto floatType = static_cast<c10::ScalarType>(tensorexpr::ScalarType::Float);
if (c10::isFloatingType(scalarType) &&
(c10::elementSize(scalarType) < c10::elementSize(floatType))) {
return Cast::make(
Dtype(tensorexpr::ScalarType::Float, e.dtype().lanes()), e);
} else {
return e;
}
}
ExprHandle clamp(
const ExprHandle& cmin,
const ExprHandle& cmax,
const ExprHandle& input) {
auto mm = CompareSelect::make(input, cmin, cmin, input, kLT);
return CompareSelect::make(mm, cmax, cmax, mm, kGT);
}
bool checkTypes(const ScalarType highType, const int typeConstraints) {
if (typeConstraints == kAllTypes) {
return true;
}
if (c10::isIntegralType(highType, false)) {
return (typeConstraints & kIntegralTypes) != 0;
} else if (c10::isFloatingType(highType)) {
return (typeConstraints & kFloatingPointTypes) != 0;
} else if (highType == ScalarType::Bool) {
return (typeConstraints & kBoolType) != 0;
}
// assume JIT not supporting complex and qint yet
TORCH_INTERNAL_ASSERT((typeConstraints & (kQintTypes | kComplexTypes)) == 0);
return false;
}
void promoteInputs(
std::vector<ExprHandle>& inputs,
const int typeConstraints = kAllTypes) {
if (inputs.empty()) {
return;
}
// Find the highest type among the inputs.
ScalarType highType = inputs[0].dtype().scalar_type();
for (const auto input : inputs) {
highType = promoteTypes(highType, input.dtype().scalar_type());
}
if (!checkTypes(highType, typeConstraints)) {
throw unsupported_dtype();
}
for (ExprHandle& e : inputs) {
e = promoteToDtype(e, highType);
}
}
ExprHandle demoteOutput(
const ExprHandle& e,
const c10::optional<ScalarType> type) {
if (!type.has_value()) {
return e;
}
if (*type == e.dtype().scalar_type()) {
return e;
}
switch (*type) {
// NOLINTNEXTLINE
#define TYPE_CASE(Type, Name) \
case ScalarType::Name: \
return cast<Type>(e);
AT_FORALL_SCALAR_TYPES_AND(Half, TYPE_CASE);
#undef TYPE_CASE
case ScalarType::Bool:
return cast<bool>(e);
default:
throw unsupported_dtype();
}
return e;
}
static bool isOne(ExprHandle e) {
auto const& n = e.AsNode<IntImm>();
if (!n) {
return false;
}
return n->value() == 1;
}
std::pair<std::vector<ExprHandle>, bool> broadcastShapesImpl(
const std::vector<ExprHandle>& a,
const std::vector<ExprHandle>& b) {
auto at = a.rbegin();
auto bt = b.rbegin();
std::vector<ExprHandle> ret;
bool hasBroadcast = false;
while (at != a.rend() || bt != b.rend()) {
if (at == a.rend()) {
hasBroadcast = true;
ret.push_back(*bt++);
continue;
}
if (bt == b.rend()) {
hasBroadcast = true;
ret.push_back(*at++);
continue;
}
// TODO: if neither *at nor *bt is 1, ensure they are identical
// expressions. Nb: `==` doesn't work since that simply produces a new
// ExprHandle.
ExprHandle dim = *at;
if (isOne(*at)) {
if (!isOne(*bt)) {
dim = *bt;
hasBroadcast = true;
}
}
ret.push_back(dim);
at++;
bt++;
}
std::reverse(ret.begin(), ret.end());
return {ret, hasBroadcast};
}
std::pair<std::vector<ExprHandle>, bool> broadcastShapesImpl(
std::vector<std::vector<ExprHandle>> shapes) {
size_t n = shapes.size();
if (n == 1) {
return {shapes[0], false};
}
auto res1 = broadcastShapesImpl(shapes[n - 2], shapes[n - 1]);
shapes[n - 2] = res1.first;
shapes.pop_back();
auto res2 = broadcastShapesImpl(shapes);
return {res2.first, (res1.second || res2.second)};
}
std::vector<ExprHandle> broadcastShapes(
std::vector<std::vector<ExprHandle>> shapes) {
return broadcastShapesImpl(shapes).first;
}
std::vector<ExprHandle> broadcastShapes(
const std::vector<ExprHandle>& a,
const std::vector<ExprHandle>& b) {
return broadcastShapesImpl(a, b).first;
}
std::vector<ExprHandle> TensorExprKernel::broadcastShapesMut(
std::vector<std::vector<ExprHandle>> shapes) {
auto res = broadcastShapesImpl(shapes);
if (res.second) {
hasBroadcast_ = true;
}
return res.first;
}
std::vector<ExprHandle> TensorExprKernel::broadcastShapesMut(
const std::vector<ExprHandle>& a,
const std::vector<ExprHandle>& b) {
auto res = broadcastShapesImpl(a, b);
if (res.second) {
hasBroadcast_ = true;
}
return res.first;
}
std::vector<ExprHandle> valueShape(const ArgValue& v) {
if (auto b = c10::get_if<tensorexpr::BufHandle>(&v)) {
return b->dims();
}
return {};
}
Tensor* computeOneOperand(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<ExprHandle(const ExprHandle&)>& innerExpr,
const int checkParamTypes = kAllTypes) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr, checkParamTypes](
const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[0], indices)};
promoteInputs(inputs, checkParamTypes);
ExprHandle compute = innerExpr(inputs[0]);
return demoteOutput(compute, outputType);
});
}
Tensor* computeTwoOperand(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<ExprHandle(const ExprHandle&, const ExprHandle&)>&
innerExpr) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[0], indices),
tensorOrConstant(inputValues[1], indices),
};
promoteInputs(inputs);
ExprHandle compute = innerExpr(inputs[0], inputs[1]);
return demoteOutput(compute, outputType);
});
}
Tensor* computeTwoOperandWithAlpha(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<ExprHandle(const ExprHandle&, const ExprHandle&)>&
innerExpr) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[0], indices),
tensorOrConstant(inputValues[1], indices),
tensorOrConstant(inputValues[2], indices),
};
promoteInputs(inputs);
ExprHandle compute = innerExpr(inputs[0], inputs[2] * inputs[1]);
return demoteOutput(compute, outputType);
});
}
Tensor* computeConditionWithTwoOperand(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<
ExprHandle(const ExprHandle&, const ExprHandle&, const ExprHandle&)>&
innerExpr) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[1], indices),
tensorOrConstant(inputValues[2], indices),
};
promoteInputs(inputs);
// First expr is the condition, which we don't promote
inputs.emplace(
inputs.begin(), tensorOrConstant(inputValues[0], indices));
ExprHandle compute = innerExpr(inputs[0], inputs[1], inputs[2]);
return demoteOutput(compute, outputType);
});
}
Tensor* computeThreeOperand(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<
ExprHandle(const ExprHandle&, const ExprHandle&, const ExprHandle&)>&
innerExpr,
bool promote_inputs = true) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr, promote_inputs](
const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[0], indices),
tensorOrConstant(inputValues[1], indices),
tensorOrConstant(inputValues[2], indices),
};
if (promote_inputs) {
promoteInputs(inputs);
}
ExprHandle compute = innerExpr(inputs[0], inputs[1], inputs[2]);
return demoteOutput(compute, outputType);
});
}
Tensor* computeFourOperand(
const std::string& name,
const std::vector<ArgValue>& inputValues,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
const std::function<ExprHandle(
const ExprHandle&,
const ExprHandle&,
const ExprHandle&,
const ExprHandle&)>& innerExpr) {
return Compute(
name,
c10::fmap<DimArg>(outputShape),
[inputValues, outputType, innerExpr](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> inputs = {
tensorOrConstant(inputValues[0], indices),
tensorOrConstant(inputValues[1], indices),
tensorOrConstant(inputValues[2], indices),
tensorOrConstant(inputValues[3], indices),
};
promoteInputs(inputs);
ExprHandle compute =
innerExpr(inputs[0], inputs[1], inputs[2], inputs[3]);
return demoteOutput(compute, outputType);
});
}
std::pair<ScalarType, std::vector<BufHandle>> processCatList(
const std::vector<BufHandle>& bufList) {
if (bufList.size() == 0) {
throw std::runtime_error("Empty input list is passed to aten::cat");
}
std::vector<BufHandle> bufInputs;
std::vector<BufHandle> nonEmptyInputs;
for (auto buf : bufList) {
bufInputs.push_back(buf);
TORCH_INTERNAL_ASSERT(buf.node()->dims().size() > 0);
if (buf.node()->dims().size() == 1 &&
immediateAs<int>(buf.node()->dim(0)) == 0) {
continue;
}
nonEmptyInputs.push_back(buf);
}
ScalarType highType = bufInputs[0].dtype().scalar_type();
for (const auto input : bufInputs) {
auto maybe_dtype = input.dtype().scalar_type();
highType = promoteTypes(highType, maybe_dtype);
}
return {highType, nonEmptyInputs};
}
Tensor* computeCatWoConditionals(
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape) {
auto input_list = c10::get<BufList>(inputs[0]);
auto arg_dim = inputs[1];
auto cat_info = processCatList(input_list);
ScalarType high_type = cat_info.first;
std::vector<BufHandle> non_empty_inputs = cat_info.second;
// Now we build one loop per input:
//
// for i
// for j
// for k
// output[i,j,k] = inp1[i,j,k]
// for i
// for j
// for k
// output[i,j+l1,k] = inp2[i,j,k]
// for i
// for j
// for k
// output[i,j+l2,k] = inp3[i,j,k]
auto output_sizes_expr = ExprHandleVectorToExprVector(outputShape);
auto output_buf = new Buf("aten_cat", output_sizes_expr, ToDtype(high_type));
if (non_empty_inputs.size() == 0) {
return new Tensor(output_buf, new tensorexpr::Block({}));
}
int64_t concat_dim = c10::get<int64_t>(arg_dim);
size_t norm_concat_dim =
normalizeAndCheckIndex(concat_dim, outputShape.size());
auto gen_code_for_input = [&](const BufHandle& inp,
size_t inp_pos,
const Expr* concat_dim_size,
const std::vector<ExprHandle>& dims) {
std::vector<Var*> for_vars(dims.size());
std::vector<const Expr*> load_indices(dims.size());
std::vector<const Expr*> store_indices(dims.size());
for (size_t i = 0; i < dims.size(); ++i) {
for_vars[i] = new Var(
"i" + c10::to_string(inp_pos) + "_" + c10::to_string(i), kInt);
load_indices[i] = for_vars[i];
if (i == norm_concat_dim) {
store_indices[i] = new Add(for_vars[i], concat_dim_size);
} else {
store_indices[i] = for_vars[i];
}
}
auto inp_buf = inp.node();
auto load_expr = new Load(inp_buf, load_indices);
auto load_promoted = promoteToDtype(ExprHandle(load_expr), high_type);
Stmt* st = new Store(output_buf, store_indices, load_promoted.node());
for (size_t i = dims.size(); i > 0; --i) {
st = new For(for_vars[i - 1], new IntImm(0), dims[i - 1].node(), st);
}
return st;
};
Expr* concat_dim_size = nullptr;
auto block = new tensorexpr::Block({});
for (size_t i = 0; i < non_empty_inputs.size(); ++i) {
auto input_dims =
ExprVectorToExprHandleVector(non_empty_inputs[i].node()->dims());
if (concat_dim_size == nullptr) {
concat_dim_size = new IntImm(0);
}
block->append_stmt(gen_code_for_input(
non_empty_inputs[i], i, concat_dim_size, input_dims));
concat_dim_size =
new Add(concat_dim_size, input_dims[norm_concat_dim].node());
}
return new Tensor(output_buf, IRSimplifier::simplify(block));
}
Tensor* computeCat(
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape,
at::Device device) {
if (device == at::kCPU && getCatWoConditionals()) {
return computeCatWoConditionals(inputs, outputShape);
}
auto inputList = c10::get<BufList>(inputs[0]);
auto argDim = inputs[1];
auto catInfo = processCatList(inputList);
ScalarType highType = catInfo.first;
std::vector<BufHandle> nonEmptyInputs = catInfo.second;
return Compute(
"aten_cat",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
if (nonEmptyInputs.size() == 0) {
return ExprHandle(0);
}
int64_t dim_ = c10::get<int64_t>(argDim);
size_t dim = normalizeAndCheckIndex(dim_, axes.size());
// Promote input types.
// Note that we need to consider all inputs, including empty - they
// also affect the resultant dtype.
// Now we know the final dtype, we know what inputs are non-empty,
// and we know that there is at least one such an input. With all
// that we construct a tensor expression performing the
// concatenation.
// The expression we build here is a cascading if-then-else that
// essentially represents:
//
// inp1[i, j, k] if 0 < i < l1,
// out[i,j,k] = inp2[i, j-l1, k] if l1 =< i < l1 + l2,
// ...
// inpN[i, j-l_N_1, k] if l1+l2+...l_N_1 < i
// where l_i is the corresponding size of the i-th input.
std::vector<ExprHandle> newAxes(axes.begin(), axes.end());
ExprHandle load = promoteToDtype(
tensorOrConstant(nonEmptyInputs[0], newAxes), highType);
size_t offset =
dynamic_cast<const IntImm*>(nonEmptyInputs[0].node()->dim(dim))
->value();
newAxes[dim] = newAxes[dim] - IntImm::make(offset);
for (size_t ii = 1; ii < nonEmptyInputs.size(); ++ii) {
auto input = nonEmptyInputs[ii];
load = ifThenElse(
CompareSelect::make(axes[dim], IntImm::make(offset), kLT),
load,
promoteToDtype(tensorOrConstant(input, newAxes), highType));
offset +=
dynamic_cast<const IntImm*>(input.node()->dim(dim))->value();
newAxes[dim] = axes[dim] - IntImm::make(offset);
}
return load;
});
}
// Remove all indices from axes positions.
std::vector<VarHandle> squeezeIndices(
const ParameterList& indices,
const std::vector<size_t>& axes) {
std::vector<VarHandle> indices_squeezed;
for (size_t dim = 0; dim < indices.size(); ++dim) {
if (!std::count(axes.begin(), axes.end(), dim)) {
indices_squeezed.push_back(indices[dim]);
}
}
return indices_squeezed;
}
Tensor* computeSoftmax(
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape,
bool log_softmax) {
// Softmax is computed as follows:
// softmax(vi) = exp(vi) / sum(exp(vi))
//
// In order to avoid overflow issues due to exp of a large number, we
// subtract the max of that dim before computing exp.
// softmax(vi) = exp(vi - max(vi)) / sum(exp(vi - max(vi)))
//
// This is implemented as 4 loopnests:
// - First loop computes the max over the softmax dim.
// - Second loop computes exp for every element in v after subtracting
// the max of the softmax dim it belongs to.
// - Third loop computes the sum over the softmax dim.
// - Final loop computes softmax for every element in v.
// LogSoftmax is computed as follows:
// log_softmax(vi) = log(softmax(vi))
// = vi - log(sum(exp(vi)))
//
// Using the same max trick as above:
// log_softmax(vi) = vi - max(vi) - log(sum(exp(vi - max(vi))))
//
// This is implemented as 5 loopnests:
// - First loop computes the max over the softmax dim.
// - Second loop computes exp for every element in v after subtracting
// the max of the softmax dim it belongs to.
// - Third loop computes the sum over the softmax dim.
// - Fourth loop computes log for every element in the sum.
// - Final loop computes the log_softmax for every element in v.
TORCH_INTERNAL_ASSERT(inputs.size() == 3);
auto output_dims = c10::fmap<DimArg>(outputShape);
// We do not handle None for dims (input 1) because that is supposed to
// be deprecated.
TORCH_INTERNAL_ASSERT(c10::get_if<int64_t>(&inputs[1]));
int64_t rank = valueShape(inputs[0]).size();
size_t softmax_dim =
normalizeAndCheckIndex(c10::get<int64_t>(inputs[1]), rank);
std::vector<DimArg> non_softmax_dims;
for (size_t i = 0; i < output_dims.size(); ++i) {
if (i != softmax_dim) {
non_softmax_dims.push_back(output_dims[i]);
}
}
// Softmax implementation includes two reductions, one to find the max and
// the other to calculate the sum along the softmax dim. These reductions
// will have the softmax dimension as the inner most loop. So, the innermost
// index in the indices will refer to the softmax dimension.
// Update the indices by moving the softmax dimension index to the
// appropriate position.
auto move_softmax_dim_index_to_pos = [&](const ParameterList& indices) {
std::vector<ExprHandle> new_indices;
for (auto ind : indices) {
new_indices.push_back(ind);
}
for (size_t i = softmax_dim; i < indices.size() - 1; ++i) {
new_indices[i + 1] = indices[i];
}
new_indices[softmax_dim] = indices[indices.size() - 1];
return new_indices;
};
// Remove the index corresponding to the softmax dimension.
auto remove_softmax_dim_index = [&](const ParameterList& indices) {
std::vector<ExprHandle> new_indices;
for (size_t i = 0; i < indices.size(); ++i) {
if (i != softmax_dim) {
new_indices.push_back(indices[i]);
}
}
return new_indices;
};
auto convert_indices_to_expr_handle = [&](const ParameterList& indices) {
std::vector<ExprHandle> new_indices(indices.size());
for (size_t i = 0; i < indices.size(); ++i) {
new_indices[i] = indices[i];
}
return new_indices;
};
c10::optional<Dtype> dtype = ToDtype(ScalarType::Undefined);
if (auto d = c10::get_if<int64_t>(&inputs[2])) {
dtype = ToDtype(static_cast<ScalarType>(*d));
}
auto max = Reduce(
"aten_softmax_max",
non_softmax_dims,
Maximum(dtype.value()),
[&](ParameterList& indices) {
return tensorOrConstant(
inputs[0], move_softmax_dim_index_to_pos(indices));
},
{output_dims[softmax_dim]});
auto e =
Compute("aten_softmax_exp", output_dims, [&](ParameterList& indices) {
auto inp = tensorOrConstant(
inputs[0], convert_indices_to_expr_handle(indices));
return exp(inp - max->load(remove_softmax_dim_index(indices)));
});
auto sum = Reduce(
"aten_softmax_sum",
non_softmax_dims,
Sum(),
[&](ParameterList& indices) {
return e->load(move_softmax_dim_index_to_pos(indices));
},
{output_dims[softmax_dim]});
if (!log_softmax) {
auto result =
Compute("aten_softmax", output_dims, [&](ParameterList& indices) {
return e->load(indices) /
sum->load(remove_softmax_dim_index(indices));
});
return new Tensor(
result->buf(),
new tensorexpr::Block(
{max->stmt(), e->stmt(), sum->stmt(), result->stmt()}));
}
auto log_sum = Compute(
"aten_softmax_log_sum", non_softmax_dims, [&](ParameterList& indices) {
return log(sum->load(indices));
});
auto result =
Compute("aten_log_softmax", output_dims, [&](ParameterList& indices) {
auto inp = tensorOrConstant(
inputs[0], convert_indices_to_expr_handle(indices));
auto non_softmax_indices = remove_softmax_dim_index(indices);
return inp - max->load(non_softmax_indices) -
log_sum->load(non_softmax_indices);
});
return new Tensor(
result->buf(),
new tensorexpr::Block(
{max->stmt(),
e->stmt(),
sum->stmt(),
log_sum->stmt(),
result->stmt()}));
}
Tensor* computeSum(
const std::vector<ArgValue>& inputs,
const c10::optional<ScalarType>& outputType) {
std::vector<size_t> axes;
bool keepdim = false;
// aten::sum takes the input tensor named self.
auto sizes = valueShape(inputs[0]);
int rank = sizes.size();
if (inputs.size() > 2) {
auto nodeAxes = c10::get<IntList>(inputs[1]);
// Canonicalize axes: wrap around, sort and make unique.
for (auto axis : nodeAxes) {
axes.push_back(at::maybe_wrap_dim(axis, rank));
}
std::sort(axes.begin(), axes.end());
axes.erase(std::unique(axes.begin(), axes.end()), axes.end());
keepdim = c10::get<bool>(inputs[2]);
} else {
axes.resize(sizes.size());
std::iota(axes.begin(), axes.end(), 0);
}
// Axes go into reduction dimensions.
std::vector<DimArg> reductionDims;
reductionDims.reserve(sizes.size());
for (size_t axis : axes) {
reductionDims.emplace_back(sizes[axis]);
}
std::vector<DimArg> outputDims;
// Output dimensions are the complement of axes. When keepdim is set, a
// one-sized dimension is inserted for each axis.
for (size_t dim = 0; dim < sizes.size(); ++dim) {
if (!std::count(axes.begin(), axes.end(), dim)) {
outputDims.emplace_back(sizes[dim]);
} else if (keepdim) {
outputDims.emplace_back(1);
}
}
return Reduce(
"sum",
outputDims,
Sum(),
[&](ParameterList& indices) {
// "Squeeze" out indices inserted when keepdim is set.
auto indices_squeezed =
keepdim ? squeezeIndices(indices, axes) : indices;
TORCH_INTERNAL_ASSERT(axes.size() <= indices_squeezed.size());
// Move innermost indices into axes positions:
// 1. Fill the outermost indices first.
// 2. Insert the innermost indices into the correct axis position,
// displacing the outermost indices as needed.
std::vector<ExprHandle> indices_exprs;
size_t i = 0;
for (; i < indices_squeezed.size() - axes.size(); ++i) {
indices_exprs.push_back(indices_squeezed[i]);
}
for (auto axis : axes) {
indices_exprs.insert(
indices_exprs.begin() + axis, indices_squeezed[i]);
++i;
}
auto indexed = tensorOrConstant(inputs[0], indices_exprs);
if (outputType) {
return Cast::make(ToDtype(*outputType), indexed);
} else {
return indexed;
}
},
reductionDims);
}
Tensor* computeMatmul(
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType) {
Dtype dtype = kFloat;
if (outputType) {
dtype = Dtype(*outputType);
}
BufHandle ResultBuf("matmul", outputShape, dtype);
const BufHandle a = c10::get<BufHandle>(inputs[0]);
const BufHandle b = c10::get<BufHandle>(inputs[1]);
auto size_a = a.dims();
auto size_b = b.dims();
// We currently only support rank 2 matmuls
TORCH_INTERNAL_ASSERT(size_a.size() == 2 && size_b.size() == 2);
auto total_size = dynamic_cast<LongImm*>(
IRSimplifier::simplify(
cast<int64_t>(size_a[0]) * cast<int64_t>(size_a[1]) *
cast<int64_t>(size_b[1]))
.node());
// For small sizes, where N*M*K < 1000, lower matmul to a naive 3-level
// loopnest. The number is not tuned very carefully, and in future we should
// fine-tune it as well as we should add more advanced native TE lowerings for
// matmuls. For bigger sizes we generate a TE ExternalCall, which would call
// an aten::matmul.
// Native, even naive, lowering is beneficial when the sizes are small because
// it allows to eliminate dispatch overhead.
if (total_size && total_size->value() < 1000) {
return Reduce(
"nnc_matmul",
{{size_a[0], "M"}, {size_b[1], "N"}},
Sum(),
[&](const ExprHandle& m, const ExprHandle& n, const ExprHandle& k) {
return Load::make(a, {m, k}) * Load::make(b, {k, n});
},
{{size_a[1], "K"}});
} else {
return new Tensor(
ResultBuf.node(),
ExternalCall::make(ResultBuf, "nnc_aten_matmul", {a, b}, {}));
}
}
Tensor* computeConv2d(
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType) {
Dtype dtype = kFloat;
if (outputType) {
dtype = Dtype(*outputType);
}
BufHandle ResultBuf("conv", outputShape, dtype);
BufHandle inp = c10::get<BufHandle>(inputs[0]);
BufHandle w = c10::get<BufHandle>(inputs[1]);
BufHandle b = c10::get<BufHandle>(inputs[2]);
auto strides = _pair_int(inputs[3]);
auto padding = _pair_int(inputs[4]);
auto dilation = _pair_int(inputs[5]);
int groups = c10::get<int64_t>(inputs[6]);
auto inpInfo = getTensorInfo(inp);
auto wInfo = getTensorInfo(w);
auto bInfo = getTensorInfo(b);
// Generate TE for depthwise convolutions.
if (inpInfo && wInfo && bInfo &&
conv2dIsSupported(
*inpInfo, *wInfo, *bInfo, strides, padding, dilation, groups)) {
return conv2d_depthwise(inp, w, b, strides[0], padding[0], groups);
}
// Once we have a performant TE representation for conv2d, we could use it
// here instead of the external call!
Stmt* s = ExternalCall::make(
ResultBuf,
"nnc_aten_conv2d",
{inp, w, b},
{strides[0],
strides[1],
padding[0],
padding[1],
dilation[0],
dilation[1],
groups});
return new Tensor(ResultBuf.node(), s);
}
Tensor* tensorexpr::computeOperandValue(
c10::Symbol op,
const std::vector<ArgValue>& inputs,
const std::vector<ExprHandle>& outputShape,
const c10::optional<ScalarType>& outputType,
at::Device device) {
switch (op) {
case aten::add: {
auto add_lambda = [](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) + boolToInteger(rhs);
};
TORCH_INTERNAL_ASSERT(inputs.size() == 2 || inputs.size() == 3);
return (inputs.size() > 2)
? computeTwoOperandWithAlpha(
"aten_add", inputs, outputShape, outputType, add_lambda)
: computeTwoOperand(
"aten_add", inputs, outputShape, outputType, add_lambda);
} break;
case aten::sub: {
auto sub_lambda = [](const ExprHandle& lhs, const ExprHandle& rhs) {
// NB: sub isn't supported on boolean, no need to promote to integer.
return lhs - rhs;
};
TORCH_INTERNAL_ASSERT(inputs.size() == 2 || inputs.size() == 3);
return (inputs.size() > 2)
? computeTwoOperandWithAlpha(
"aten_sub", inputs, outputShape, outputType, sub_lambda)
: computeTwoOperand(
"aten_sub", inputs, outputShape, outputType, sub_lambda);
} break;
case aten::mul: {
return computeTwoOperand(
"aten_mul",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) * boolToInteger(rhs);
});
} break;
case aten::div: {
return computeTwoOperand(
"aten_div",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return promoteIntegerToDefaultType(lhs) /
promoteIntegerToDefaultType(rhs);
});
} break;
case aten::__and__: {
return computeTwoOperand(
"aten_and",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) & boolToInteger(rhs);
});
} break;
case aten::__or__: {
return computeTwoOperand(
"aten_or",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) | boolToInteger(rhs);
});
} break;
case aten::__xor__: {
return computeTwoOperand(
"aten_xor",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) ^ boolToInteger(rhs);
});
} break;
case aten::__lshift__: {
return computeTwoOperand(
"aten_lshift",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return lhs << rhs;
});
} break;
case aten::__rshift__: {
return computeTwoOperand(
"aten_rshift",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return lhs >> rhs;
});
} break;
case aten::eq: {
return computeTwoOperand(
"aten_eq",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs == rhs);
});
} break;
case aten::ne: {
return computeTwoOperand(
"aten_ne",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs != rhs);
});
} break;
case aten::ge: {
return computeTwoOperand(
"aten_ge",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs >= rhs);
});
} break;
case aten::gt: {
return computeTwoOperand(
"aten_gt",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs > rhs);
});
} break;
case aten::le: {
return computeTwoOperand(
"aten_le",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs <= rhs);
});
} break;
case aten::lt: {
return computeTwoOperand(
"aten_lt",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return cast<bool>(lhs < rhs);
});
} break;
case aten::min: {
return computeTwoOperand(
"aten_min",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return Min::make(boolToInteger(lhs), boolToInteger(rhs), false);
});
} break;
case aten::max: {
return computeTwoOperand(
"aten_max",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return Max::make(boolToInteger(lhs), boolToInteger(rhs), false);
});
} break;
case aten::masked_fill: {
return computeThreeOperand(
"aten_masked_fill",
inputs,
outputShape,
outputType,
[](const ExprHandle& input,
const ExprHandle& mask,
const ExprHandle& value) {
// value needs to promote to input, not vice versa
auto val = promoteToDtype(value, input.dtype().scalar_type());
return ifThenElse(mask, val, input);
},
/*promote_inputs*/ false);
}
case aten::clamp: {
bool noMin = false;
bool noMax = false;
if (c10::get_if<ArgNone>(&inputs[1])) {
noMin = true;
}
if (c10::get_if<ArgNone>(&inputs[2])) {
noMax = true;
}
return computeThreeOperand(
"aten_clamp",
inputs,
outputShape,
outputType,
[noMin, noMax](
const ExprHandle& in,
const ExprHandle& min,
const ExprHandle& max) {
auto cast = [&](const ExprHandle& e) {
return Cast::make(in.dtype(), e);
};
if (noMin && noMax) {
return in;
} else if (noMin) {
auto cmax = cast(max);
return CompareSelect::make(in, cmax, cmax, in, kGT);
} else if (noMax) {
auto cmin = cast(min);
return CompareSelect::make(in, cmin, cmin, in, kLT);
} else {
auto cmax = cast(max);
auto cmin = cast(min);
return clamp(cmin, cmax, in);
}
},
false /* promote_inputs */);
} break;
case aten::addcmul: {
return computeFourOperand(
"aten_addcmul",
inputs,
outputShape,
outputType,
[](const ExprHandle& a0,
const ExprHandle& a1,
const ExprHandle& a2,
const ExprHandle& a3) { return a0 + a3 * a1 * a2; });
} break;
case aten::sigmoid: {
return computeOneOperand(
"aten_sigmoid",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return sigmoid(promoteIntegerToDefaultType(a));
});
} break;
case aten::reciprocal: {
return computeOneOperand(
"aten_reciprocal",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return ExprHandle(1.0f) / a; });
} break;
case aten::neg: {
return computeOneOperand(
"aten_neg", inputs, outputShape, outputType, [](const ExprHandle& a) {
return ExprHandle(-0) - a;
});
} break;
case aten::isnan: {
return computeOneOperand(
"aten_isnan",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
if (!a.dtype().is_floating_point()) {
return IntImm::make(0);
}
return isnan(a);
});
} break;
case aten::relu: {
return computeOneOperand(
"aten_relu",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
auto zero = Cast::make(a.dtype(), 0);
return CompareSelect::make(a, zero, zero, a, kLT);
});
} break;
case aten::leaky_relu: {
return computeTwoOperand(
"aten_leaky_relu",
inputs,
outputShape,
outputType,
[](const ExprHandle& a, const ExprHandle& negative_slope) {
auto neg_slope = Cast::make(a.dtype(), negative_slope);
auto zero = Cast::make(a.dtype(), 0);
auto one = Cast::make(a.dtype(), 1);
auto cs = CompareSelect::make(a, zero, one, neg_slope, kGT);
return a * cs;
});
} break;
case aten::gelu: {
return computeOneOperand(
"aten_gelu",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
auto m_sqrt1_2 = Cast::make(a.dtype(), M_SQRT1_2);
auto one = Cast::make(a.dtype(), 1.);
auto point_five = Cast::make(a.dtype(), .5);
return a * point_five * (one + erf(a * m_sqrt1_2));
});
} break;
case aten::batch_norm: {
bool hasWeight = true;
bool hasBias = true;
if (c10::get_if<ArgNone>(&inputs[1])) {
hasWeight = false;
}
if (c10::get_if<ArgNone>(&inputs[2])) {
hasBias = false;
}
return Compute(
"aten_batch_norm",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
TORCH_INTERNAL_ASSERT(axes.size() >= 2);
// axes: N, C, H, W
std::vector<ExprHandle> indices(axes.begin(), axes.end());
ExprHandle c = indices[1];
// Parameter list:
// input, weight, bias, mean, var, training, momentum, eps,
// cudnn_enabled
std::vector<ExprHandle> exprInputs = {
tensorOrConstant(inputs[0], indices), // input
tensorOrConstant(inputs[3], {c}), // mean
tensorOrConstant(inputs[4], {c}), // var
constant(inputs[7]) // eps
};
if (hasWeight) {
exprInputs.push_back(tensorOrConstant(inputs[1], {c}));
}
if (hasBias) {
exprInputs.push_back(tensorOrConstant(inputs[2], {c}));
}
promoteInputs(exprInputs);
ExprHandle input = exprInputs[0];
ExprHandle mean = exprInputs[1];
ExprHandle var = exprInputs[2];
ExprHandle eps = exprInputs[3];
ExprHandle weight = FloatImm::make(1);
ExprHandle bias = FloatImm::make(0);
if (hasWeight) {
weight = exprInputs[4];
}
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
if (hasBias) {
bias = exprInputs[5];
}
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
auto inv_var = rsqrt(var + eps);
auto alpha = inv_var * weight;
auto beta = bias - mean * alpha;
auto output = input * alpha + beta;
return demoteOutput(output, outputType);
});
} break;
case aten::log: {
return computeOneOperand(
"aten_log", inputs, outputShape, outputType, [](const ExprHandle& a) {
return log(promoteIntegerToDefaultType(a));
});
} break;
case aten::log10: {
return computeOneOperand(
"aten_log10",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return log10(promoteIntegerToDefaultType(a));
});
} break;
case aten::log1p: {
return computeOneOperand(
"aten_log1p",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return log1p(promoteIntegerToDefaultType(a));
});
} break;
case aten::log2: {
return computeOneOperand(
"aten_log2",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return log2(promoteIntegerToDefaultType(a));
});
} break;
case aten::exp: {
return computeOneOperand(
"aten_exp", inputs, outputShape, outputType, [](const ExprHandle& a) {
return exp(promoteIntegerToDefaultType(a));
});
} break;
case aten::expm1: {
return computeOneOperand(
"aten_expm1",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return expm1(promoteIntegerToDefaultType(a));
});
} break;
case aten::erf: {
return computeOneOperand(
"aten_erf", inputs, outputShape, outputType, [](const ExprHandle& a) {
return erf(promoteIntegerToDefaultType(a));
});
} break;
case aten::erfc: {
return computeOneOperand(
"aten_erfc",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return erfc(promoteIntegerToDefaultType(a));
});
} break;
case aten::cos: {
return computeOneOperand(
"aten_cos", inputs, outputShape, outputType, [](const ExprHandle& a) {
return cos(promoteIntegerToDefaultType(a));
});
} break;
case aten::sin: {
return computeOneOperand(
"aten_sin", inputs, outputShape, outputType, [](const ExprHandle& a) {
return sin(promoteIntegerToDefaultType(a));
});
} break;
case aten::tan: {
return computeOneOperand(
"aten_tan", inputs, outputShape, outputType, [](const ExprHandle& a) {
return tan(promoteIntegerToDefaultType(a));
});
} break;
case aten::type_as: {
const BufHandle rhs = c10::get<BufHandle>(inputs[1]);
auto dtype = rhs.dtype();
return computeOneOperand(
"aten_type_as",
inputs,
outputShape,
outputType,
[dtype](const ExprHandle& lhs) { return Cast::make(dtype, lhs); });
} break;
case aten::pow: {
return computeTwoOperand(
"aten_pow",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
if (!rhs.node()->isConstant()) {
return pow(lhs, rhs);
}
double val =
immediateAs<double>(IRSimplifier::simplify(rhs.node()));
if (val == 1.0f) {
return lhs;
} else if (val == 2.0f) { // NOLINT
return lhs * lhs;
} else if (val == 3.0f) { // NOLINT
return (lhs * lhs) * lhs;
} else if (val == 4.0f) { // NOLINT
ExprHandle tmp = lhs * lhs;
return tmp * tmp;
} else if (val == 0.5f) { // NOLINT
return sqrt(lhs);
} else if (val == 0.0f) {
return ExprHandle(1.0f);
} else if (val == -0.5f) { // NOLINT
return rsqrt(lhs);
} else if (val == -1.0f) {
return ExprHandle(1.0f) / lhs;
} else if (val == -2.0f) { // NOLINT
return ExprHandle(1.0f) / (lhs * lhs);
}
return pow(lhs, rhs);
});
} break;
case aten::fmod: {
return computeTwoOperand(
"aten_fmod",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return fmod(promoteHalfToFloat(lhs), promoteHalfToFloat(rhs));
});
} break;
case aten::lerp: {
return computeThreeOperand(
"aten_lerp",
inputs,
outputShape,
outputType,
[](const ExprHandle& a,
const ExprHandle& end,
const ExprHandle& weight) { return a + weight * (end - a); });
} break;
case aten::remainder: {
auto imodImpl = [](const ExprHandle& lhs, const ExprHandle& rhs) {
return Mod::make(lhs, rhs);
};
auto fmodImpl = [](const ExprHandle& lhs, const ExprHandle& rhs) {
auto lhs_t = promoteHalfToFloat(lhs);
auto rhs_t = promoteHalfToFloat(rhs);
return fmod((rhs_t + fmod(lhs_t, rhs_t)), rhs_t);
};
{
auto const& shape =
broadcastShapes(valueShape(inputs[0]), valueShape(inputs[1]));
return Compute(
"aten_remainder",
c10::fmap<DimArg>(shape),
[&](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
std::vector<ExprHandle> exprInputs = {
tensorOrConstant(inputs[0], indices),
tensorOrConstant(inputs[1], indices),
};
promoteInputs(exprInputs);
bool allInt = true;
for (auto& e : exprInputs) {
if (e.dtype().is_floating_point()) {
allInt = false;
break;
}
}
if (allInt) {
return demoteOutput(
imodImpl(exprInputs[0], exprInputs[1]), outputType);
} else {
return demoteOutput(
fmodImpl(exprInputs[0], exprInputs[1]), outputType);
}
});
}
} break;
case aten::acos: {
return computeOneOperand(
"aten_acos",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return acos(promoteIntegerToDefaultType(a));
});
} break;
case aten::asin: {
return computeOneOperand(
"aten_asin",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return asin(promoteIntegerToDefaultType(a));
});
} break;
case aten::cosh: {
return computeOneOperand(
"aten_cosh",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return cosh(promoteIntegerToDefaultType(a));
});
} break;
case aten::sinh: {
return computeOneOperand(
"aten_sinh",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return sinh(promoteIntegerToDefaultType(a));
});
} break;
case aten::atan: {
return computeOneOperand(
"aten_atan",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return atan(promoteIntegerToDefaultType(a));
});
} break;
case aten::atan2: {
return computeTwoOperand(
"aten_atan2",
inputs,
outputShape,
outputType,
[](const ExprHandle& lhs, const ExprHandle& rhs) {
return atan2(
promoteIntegerToDefaultType(lhs),
promoteIntegerToDefaultType(rhs));
});
} break;
case aten::tanh: {
return computeOneOperand(
"aten_tanh",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return tanh(promoteIntegerToDefaultType(a));
});
} break;
case aten::hardtanh: {
return computeThreeOperand(
"aten_hardtanh",
inputs,
outputShape,
outputType,
[](const ExprHandle& a,
const ExprHandle& min_val,
const ExprHandle& max_val) {
auto mm = CompareSelect::make(a, min_val, min_val, a, kLT);
return CompareSelect::make(mm, max_val, max_val, mm, kGT);
});
} break;
case aten::hardswish: {
return computeOneOperand(
"aten_hardswish",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
// x * torch.clamp(x + 3.0, 0.0, 6.0) / 6.0
auto zero = Cast::make(a.dtype(), 0.);
auto three = Cast::make(a.dtype(), 3.);
auto six = Cast::make(a.dtype(), 6.);
return a * clamp(zero, six, a + three) / six;
});
} break;
case aten::hardshrink: {
return computeTwoOperand(
"aten_hardshrink",
inputs,
outputShape,
outputType,
[](const ExprHandle& a, const ExprHandle& lambd) {
auto pos_clambd = Cast::make(a.dtype(), lambd);
auto neg_clambd =
Cast::make(a.dtype(), ExprHandle(-0)) - pos_clambd;
auto zero = Cast::make(a.dtype(), 0);
auto mm = CompareSelect::make(a, neg_clambd, a, zero, kLT);
return CompareSelect::make(a, pos_clambd, a, mm, kGT);
});
} break;
case aten::sqrt: {
return computeOneOperand(
"aten_sqrt",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return tensorexpr::sqrt(promoteIntegerToDefaultType(a));
});
} break;
case aten::rsqrt: {
return computeOneOperand(
"aten_rsqrt",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return rsqrt(promoteIntegerToDefaultType(a));
});
} break;
case aten::abs: {
return computeOneOperand(
"aten_abs",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return tensorexpr::abs(promoteHalfToFloat(a));
},
kIntegralTypes | kFloatingPointTypes | kBoolType);
} break;
case aten::ceil: {
return computeOneOperand(
"aten_ceil",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return ceil(a); });
} break;
case aten::floor: {
return computeOneOperand(
"aten_floor",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return floor(a); });
} break;
case aten::round: {
return computeOneOperand(
"aten_round",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return round(a); });
} break;
case aten::trunc: {
return computeOneOperand(
"aten_trunc",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return trunc(a); });
} break;
case aten::_cast_Float: {
return computeOneOperand(
"aten_cast_float",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) { return cast<float>(a); });
} break;
case aten::to: {
// see handling of aten::to in tensorexpr_fuser.cpp for why we only
// need to handle the first input
return computeOneOperand(
"aten_to",
{inputs[0]},
outputShape,
outputType,
[outputType](const ExprHandle& a) {
TORCH_INTERNAL_ASSERT(outputType);
return Cast::make(ToDtype(*outputType), a);
});
} break;
case aten::threshold: {
return computeThreeOperand(
"aten_threshold",
inputs,
outputShape,
outputType,
[](const ExprHandle& a,
const ExprHandle& threshold,
const ExprHandle& value) {
return ifThenElse(CompareSelect::make(a, threshold, kLE), value, a);
});
} break;
case aten::where: {
return computeConditionWithTwoOperand(
"aten_where",
inputs,
outputShape,
outputType,
[](const ExprHandle& a0, const ExprHandle& a1, const ExprHandle& a2) {
return ifThenElse(a0, a1, a2);
});
} break;
case aten::frac: {
return computeOneOperand(
"aten_frac",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
auto aa = promoteHalfToFloat(a);
return aa - floor(aa);
},
kFloatingPointTypes);
} break;
case aten::lgamma: {
return computeOneOperand(
"aten_lgamma",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return lgamma(promoteIntegerToDefaultType(a));
});
} break;
case aten::rand_like: {
return computeOneOperand(
"aten_rand_like",
inputs,
outputShape,
outputType,
[](const ExprHandle& a) {
return Intrinsics::make(IntrinsicsOp::kRand, a.dtype());
});
} break;
case aten::slice: {
return Compute(
"aten_slice",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
int64_t dim =
at::maybe_wrap_dim(c10::get<int64_t>(inputs[1]), axes.size());
ExprHandle start = constant(inputs[2]);
ExprHandle stride = constant(inputs[4]);
std::vector<ExprHandle> newAxes(axes.begin(), axes.end());
newAxes[dim] = stride * newAxes[dim] + start;
return tensorOrConstant(inputs[0], newAxes);
});
}
case aten::unsqueeze: {
return Compute(
"aten_unsqueeze",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
int64_t dim = c10::get<int64_t>(inputs[1]);
if (dim < 0) {
if (axes.size() == 0) {
throw malformed_input("axes are zero handling unsqueeze");
}
dim += axes.size();
}
// To construct an expression for an 'unsqueezed' tensor we need to
// drop the DIM-th axis, i.e.
// unsqueezed_v[i,j,k,l] = v[i,j,l] # dim = 2 - drop index 'k'
// 0 1 2 3
std::vector<ExprHandle> indices;
int64_t i = 0;
for (auto a : axes) {
if (i++ != dim) {
indices.emplace_back(ExprHandle(a.node()));
}
}
return broadcast(c10::get<BufHandle>(inputs[0]), indices);
});
}
case aten::t: {
auto shape = valueShape(inputs[0]);
if (shape.size() == 1) {
return new Tensor(c10::get<BufHandle>(inputs[0]).node(), nullptr);
}
return computeOperandValue(
aten::transpose,
{inputs[0], (int64_t)1, (int64_t)0},
outputShape,
outputType);
}
case aten::transpose: {
auto A = c10::get<BufHandle>(inputs[0]);
auto start_dim =
at::maybe_wrap_dim(c10::get<int64_t>(inputs[1]), A.ndim());
auto to_dim = at::maybe_wrap_dim(c10::get<int64_t>(inputs[2]), A.ndim());
return Compute(
"aten_transpose",
c10::fmap<DimArg>(outputShape),
[&](std::vector<VarHandle> axes) {
std::swap(axes[start_dim], axes[to_dim]);
return A.load(axes);
});
}
case aten::permute: {
auto A = c10::get<BufHandle>(inputs[0]);
auto permute_dims = c10::get<IntList>(inputs[1]);
return Compute(
"aten_permute",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
std::vector<VarHandle> new_axes;
assert(permute_dims.size() == axes.size());
for (auto i : permute_dims) {
auto new_dim = at::maybe_wrap_dim(i, A.ndim());
new_axes.push_back(axes[new_dim]);
}
return A.load(new_axes);
});
}
case aten::expand: {
auto A = c10::get<BufHandle>(inputs[0]);
return Compute(
"aten_expand",
c10::fmap<DimArg>(outputShape),
[&](const std::vector<VarHandle>& axes) {
std::vector<ExprHandle> indices(axes.begin(), axes.end());
return broadcast(A, indices);
});
}
case aten::mm: // aten::mm is a subset of aten::matmul where both inputs are
// rank 2
case aten::matmul: {
return computeMatmul(inputs, outputShape, outputType);
}
case aten::cat: {
return computeCat(inputs, outputShape, device);
}
case aten::sum: {
return computeSum(inputs, outputType);
}
case aten::softmax: {
return computeSoftmax(inputs, outputShape, false);
}
case aten::log_softmax: {
return computeSoftmax(inputs, outputShape, true);
}
case aten::conv2d: {
return computeConv2d(inputs, outputShape, outputType);
} break;
default: {
std::string msg =
std::string("Unhandled node kind: ") + op.toQualString();
throw malformed_input(msg);
}
}
}
c10::optional<ScalarType> findDtypeForValue(const torch::jit::Value* v) {
if (v->type()->kind() == TypeKind::TensorType) {
auto tt = v->type()->cast<TensorType>();
if (tt->scalarType()) {
return static_cast<ScalarType>(*tt->scalarType());
}
}
return c10::nullopt;
}
Tensor* TensorExprKernel::computeValue(const torch::jit::Value* v) {
auto inputs = v->node()->inputs();
switch (v->node()->kind()) {
case aten::rand_like:
hasRandom_ = true;
// fallthrough
case aten::add:
case aten::sub:
case aten::mul:
case aten::div:
case aten::__and__:
case aten::__or__:
case aten::__xor__:
case aten::__lshift__:
case aten::__rshift__:
case aten::eq:
case aten::ne:
case aten::ge:
case aten::gt:
case aten::le:
case aten::lt:
case aten::min:
case aten::max:
case aten::masked_fill:
case aten::clamp:
case aten::addcmul:
case aten::sigmoid:
case aten::reciprocal:
case aten::neg:
case aten::isnan:
case aten::relu:
case aten::leaky_relu:
case aten::hardswish:
case aten::gelu:
case aten::batch_norm:
case aten::log:
case aten::log10:
case aten::log1p:
case aten::log2:
case aten::exp:
case aten::expm1:
case aten::erf:
case aten::erfc:
case aten::cos:
case aten::sin:
case aten::tan:
case aten::type_as:
case aten::pow:
case aten::fmod:
case aten::lerp:
case aten::remainder:
case aten::acos:
case aten::asin:
case aten::cosh:
case aten::sinh:
case aten::atan:
case aten::atan2:
case aten::tanh:
case aten::hardtanh:
case aten::hardshrink:
case aten::sqrt:
case aten::rsqrt:
case aten::abs:
case aten::ceil:
case aten::floor:
case aten::round:
case aten::trunc:
case aten::_cast_Float:
case aten::threshold:
case aten::where:
case aten::frac:
case aten::lgamma:
case aten::slice:
case aten::unsqueeze:
case aten::t:
case aten::transpose:
case aten::expand:
case aten::permute:
case aten::mm:
case aten::matmul:
case aten::cat:
case aten::sum:
case aten::softmax:
case aten::log_softmax:
case aten::conv2d: {
std::vector<ArgValue> argInputs;
for (auto inp : inputs) {
argInputs.push_back(toArg(inp));
}
auto outputType = findDtypeForValue(v->node()->output());
std::vector<ExprHandle> outputShape = {};
// shape inference not implemented for sum
if (v->node()->kind() != aten::sum) {
outputShape = sizesForValue(v);
}
return computeOperandValue(
v->node()->kind(), argInputs, outputShape, outputType, device_);
} break;
case aten::to: {
std::vector<ArgValue> argInputs;
argInputs.push_back(toArg(inputs[0]));
auto outputType = findDtypeForValue(v->node()->output());
std::vector<ExprHandle> outputShape = {};
// shape inference not implemented for sum
if (v->node()->kind() != aten::sum) {
outputShape = sizesForValue(v);
}
return computeOperandValue(
v->node()->kind(), argInputs, outputShape, outputType, device_);
} break;
case prim::ConstantChunk: {
return Compute(
"prim_constantchunk",
c10::fmap<DimArg>(sizesForValue(v)),
[this, v](const std::vector<VarHandle>& axes) {
auto const& n = v->node();
int64_t dim = n->i(attr::dim);
int64_t chunks = n->i(attr::chunks);
std::vector<ExprHandle> indices(axes.begin(), axes.end());
return chunk(
bufs_.at(n->input(0)), v->offset(), dim, chunks, indices);
});
} break;
default: {
std::string msg = std::string("Unhandled node kind: ") +
v->node()->kind().toQualString();
throw malformed_input(msg);
}
}
return nullptr;
}
// Return the (lower, upper) loop bounds if they are constants, else nullopt.
c10::optional<std::pair<int64_t, int64_t>> loopBounds(const For* loop) {
auto start = IRSimplifier::simplify(loop->start());
auto stop = IRSimplifier::simplify(loop->stop());
if (!start->isConstant() || !stop->isConstant()) {
return c10::nullopt;
}
return c10::make_optional(
std::make_pair(immediateAs<int64_t>(start), immediateAs<int64_t>(stop)));
}
// True if all the loops in this vector have equal bounds.
bool loopBoundsAllEqual(const std::vector<For*>& loops) {
auto bounds = loopBounds(loops[0]);
if (!bounds) {
return false;
}
for (auto const& loop : loops) {
auto next = loopBounds(loop);
if (!next) {
return false;
}
if (bounds->first != next->first || bounds->second != next->second) {
return false;
}
}
return true;
}
// Recursively fuse all the loops with matching bounds in `st`. Stops fusing
// at any level containing non-loops or non-matching bounds. The restriction
// on matching bounds exists to avoid inserting conditionals on the loop
// indices where none would be needed, which would significantly complicate
// vectorization.
void fuseAllLoops(Stmt* st) {
if (auto block = dynamic_cast<tensorexpr::Block*>(st)) {
std::vector<For*> loopsToFuse;
for (auto stmt : *block) {
auto loop = dynamic_cast<For*>(stmt);
if (!loop) {
// Block contains something that's not a loop. Quit.
return;
}
loopsToFuse.push_back(loop);
}
if (!loopBoundsAllEqual(loopsToFuse)) {
return;
}
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
For* fusedLoop;
if (!LoopNest::fuseLoops(loopsToFuse, &fusedLoop)) {
return;
}
fuseAllLoops(fusedLoop->body());
}
}
Stmt* TensorExprKernel::transformLoops(BackendType backendType, Stmt* st) {
torch::jit::tensorexpr::LoopNest l(st, bufOutputs_);
GRAPH_DEBUG("Original Stmt:\n", std::to_string(l.root_stmt()), "\n");
bool hasReduction = NodeFinder<ReduceOp>::find(l.root_stmt()).size() != 0;
// For Block codegen we create a map of tensor dims before
// inlining. Like GPU codegen we need to inline. But the order
// where this analysis is run matters.
auto block_analysis = std::make_unique<CreateBufferMap>();
if (backendType == kBlockCodeGen) {
// Run Block analysis to get multi dim buffer info
auto root_stmt = l.root_stmt();
root_stmt->accept(block_analysis.get());
}
// Inlining output & intermediate buffers can duplicate computation.
// Duplicating work can slow down the program if it's not ameliorated in some
// way, but we've empirically found that:
// - On CPU, LLVM's CSE does a good job as long as you horizontally fuse
// output loops.
// - On GPU, there's enough compute to hide the extra work, and inlining
// avoids synchronizing between kernels.
l.inlineIntermediateBufs(/*allow_duplicated_work=*/true);
GRAPH_DEBUG("after inline", *l.root_stmt());
// Optimizing conditionals needs to be performed after inlining because
// inlining wouldn't work once the loops are split. Also, it has to be
// performed before loop fusion because loop fusion introduces cases where
// multiple conditionals are in the same loop and this optimization does not
// handle such cases yet.
if (getOptConditionals()) {
l.optimizeConditionals();
GRAPH_DEBUG("after optimizing conditionals: ", *l.root_stmt());
}
// Fuse loops "horizontally". This pass allows us to combine loops that
// write to different output buffers, as long as they have the same bounds.
if (backendType == kLLVMCodeGen) {
fuseAllLoops(l.root_stmt());
GRAPH_DEBUG("after fuse", *l.root_stmt());
}
if (backendType == kCudaCodeGen) {
for (auto buf : bufOutputs_) {
std::vector<For*> loops = l.getLoopStmtsFor(buf);
TORCH_INTERNAL_ASSERT(!loops.empty(), "loops should not be empty");
For* flattened = nullptr;
LoopNest::flatten(loops, &flattened);
assert(flattened);
int loopLevels = getTECudaPointwiseLoopLevels();
const int kDefaultLoopLevels = 2;
loopLevels = (loopLevels > 0) ? loopLevels : kDefaultLoopLevels;
int blockCount = getTECudaPointwiseBlockCount();
int blockSize = getTECudaPointwiseBlockSize();
if (loopLevels == 2) {
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
For* inner;
const int kDefaultBlockSize = 512;
if (blockSize < 0) {
blockSize = kDefaultBlockSize;
}
l.splitWithMask(flattened, blockSize, &inner);
l.setGPUBlockIndex(flattened, 0);
l.setGPUThreadIndex(inner, 0);
} else if (loopLevels == 3) {
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
For* inner;
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
For* inner1;
// TODO: change the number of microprocessors
const int kDefaultBlockCount = 1280;
const int kDefaultBlockSize = 256;
blockCount = (blockCount > 0) ? blockCount : kDefaultBlockCount;
blockSize = (blockSize > 0) ? blockSize : kDefaultBlockSize;
l.splitWithMask(flattened, blockCount * blockSize, &inner);
l.splitWithMask(inner, blockSize, &inner1);
l.setGPUBlockIndex(inner, 0);
l.setGPUThreadIndex(inner1, 0);
} else {
throw std::runtime_error(
"Invalid loop-level: " + c10::to_string(loopLevels));
}
}
}
if (backendType == kBlockCodeGen) {
for (auto buf : bufOutputs_) {
const int default_fp16_blocksize = 16;
const int default_uint8_blocksize = 32;
int blockSize = default_fp16_blocksize;
// We only handle looplevels == 2 for now
if (buf->dtype().scalar_type() == ScalarType::Byte) {
blockSize = default_uint8_blocksize;
}
std::vector<For*> loops = l.getLoopStmtsFor(buf);
TORCH_INTERNAL_ASSERT(!loops.empty(), "loops should not be empty");
For* flattened = nullptr;
LoopNest::flatten(loops, &flattened);
assert(flattened);
For* inner = nullptr;
l.splitWithMask(flattened, blockSize, &inner);
l.setGPUBlockIndex(flattened, 0);
l.setGPUThreadIndex(inner, 0);
l.setBufferMap(flattened, block_analysis->getBufferMap());
}
}
l.prepareForCodegen();
if (backendType == kLLVMCodeGen && !hasReduction) {
l.vectorizeInnerLoops();
}
Stmt* stmt = l.root_stmt();
// Arithmetic Simplification.
stmt = IRSimplifier::simplify(stmt);
GRAPH_DEBUG("Final Stmt:\n", std::to_string(stmt), "\n");
return stmt;
}
std::string TensorExprKernel::getCodeGenName(BackendType backendType) {
switch (backendType) {
case kCudaCodeGen:
return "cuda_codegen";
case kLLVMCodeGen:
return "llvm_codegen";
case kSimpleIREval:
return "simple_ir_eval";
case kBlockCodeGen:
return "block_codegen";
default:
throw std::runtime_error(
"invalid backend type: " +
c10::to_string(static_cast<int>(backendType)));
}
}
template <typename T>
static bool isValidPrimProperty(const c10::optional<T>& a, T b) {
return !a.has_value() || *a == b;
}
TensorExprKernel::BackendType TensorExprKernel::inferBackendTypeFromDevice(
at::Device device) {
BackendType backendType = BackendType::kUninitialized;
if (device.type() == at::kCUDA) {
backendType = kCudaCodeGen;
} else if (device.type() == at::kCPU && getTEGenerateBlockCode()) {
backendType = kBlockCodeGen;
} else if (device.type() == at::kCPU) {
#ifdef TORCH_ENABLE_LLVM
backendType = dontUseLLVMFlag() ? kSimpleIREval : kLLVMCodeGen;
#else
backendType = kSimpleIREval;
#endif
if (getTEMustUseLLVMOnCPU() && backendType == kSimpleIREval) {
throw std::runtime_error("LLVM Backend not found");
}
} else {
throw std::runtime_error("Invalid device type");
}
return backendType;
}
static bool isValidIdentifierChar(char c, size_t pos) {
return islower(c) || isupper(c) || c == '_' || (pos > 0 && isdigit(c));
}
// replaces all invalid characters with underscore
std::string sanitizeName(const std::string& input_name) {
std::stringstream sanitized_name;
for (size_t i = 0; i < input_name.size(); ++i) {
if (isValidIdentifierChar(input_name[i], i)) {
sanitized_name << input_name[i];
} else {
sanitized_name << "_";
}
}
return sanitized_name.str();
}
// we use the debug names in printing cuda code, they need to be removed
// of characters that can't be used in a variable identifier
void TensorExprKernel::genInputDebugNames() {
std::unordered_map<std::string, const torch::jit::Value*> name_to_value;
std::unordered_set<std::string> name_set;
std::unordered_map<const torch::jit::Value*, std::string> value_to_name;
for (const torch::jit::Value* input : graph_->inputs()) {
std::string sanitized_name = sanitizeName(input->debugName());
// we could get fancier here, but name conflict is extremely unlikely
while (name_set.count(sanitized_name)) {
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
sanitized_name = sanitized_name + "_";
}
value_to_name[input] = sanitized_name;
name_set.insert(sanitized_name);
}
input_name_map_ = std::move(value_to_name);
}
Tensor* TensorExprKernel::bindInput(const torch::jit::Value* input) {
auto const& t = input->type();
Tensor* result = nullptr;
switch (t->kind()) {
case TypeKind::TensorType: {
auto tt = input->type()->cast<TensorType>();
if (!input->isCompleteTensor()) {
std::string msg = std::string("Shapes for input '%") +
input->debugName() + "' are unknown";
throw malformed_input(msg);
}
Placeholder inBuffer(
"t" + input_name_map_[input],
ToDtype(static_cast<ScalarType>(*tt->scalarType())),
{0});
std::vector<DimArg> inputTensorDims;
for (size_t i = 0; i < *tt->sizes().size(); i++) {
auto const size = *tt->sizes()[i];
inputTensorDims.emplace_back(
DimArg(IntImm::make(size), "i" + c10::to_string(i)));
}
auto const strides = tt->strides();
result = Compute(
"input" + c10::to_string(bufs_.size() + 1),
inputTensorDims,
[&](const std::vector<VarHandle>& axes) {
ExprHandle idx = 0;
for (size_t i = 0; i < axes.size(); i++) {
idx = idx + axes[i] * IntImm::make(*strides[i]);
}
return inBuffer.load(idx);
});
bufs_.emplace(input, result->buf());
bufferArgs_.emplace_back(inBuffer);
break;
}
case TypeKind::FloatType: {
VarHandle v("v" + input_name_map_[input], kDouble);
bufferArgs_.emplace_back(v);
scalars_.emplace(input, v);
break;
}
case TypeKind::BoolType: {
VarHandle v("v" + input_name_map_[input], kBool);
bufferArgs_.emplace_back(v);
scalars_.emplace(input, v);
break;
}
case TypeKind::IntType: {
VarHandle v("v" + input_name_map_[input], kLong);
bufferArgs_.emplace_back(v);
scalars_.emplace(input, v);
break;
}
default: {
throw unsupported_dtype(t->repr_str());
break;
}
}
return result;
}
template <typename T>
std::vector<size_t> reverse_sort_indices(const std::vector<T>& v) {
// initialize original index locations
std::vector<size_t> idx(v.size());
iota(idx.begin(), idx.end(), 0);
std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {
return v[i1] > v[i2];
});
return idx;
}
bool denseAndNonOverlapping(
at::ArrayRef<int64_t> sizes,
at::ArrayRef<int64_t> strides) {
return (strides == at::infer_dense_strides(sizes, strides));
}
Tensor* TensorExprKernel::convertOutputToCorrectStrides(torch::jit::Value* v) {
const TensorTypePtr& tt = v->type()->expect<TensorType>();
TORCH_INTERNAL_ASSERT(bufs_.count(v));
const Buf* buf = bufs_.at(v);
// No shape info is present in the graph
if (!tt->sizes().concrete_sizes()) {
std::string msg =
std::string("Shapes for output '%") + v->debugName() + "' are unknown";
throw malformed_input(msg);
}
TORCH_INTERNAL_ASSERT(tt->sizes().concrete_sizes());
const auto sizes = *tt->sizes().concrete_sizes();
std::vector<int64_t> default_strides = TensorType::contiguousStridesOf(sizes);
TORCH_INTERNAL_ASSERT(tt->strides().concrete_sizes());
const std::vector<int64_t> strides = *tt->strides().concrete_sizes();
// All Tensors in NNC are layed out in default, contiguous layout.
// If the output is also default contiguous we don't need to do anything
if (strides == default_strides) {
return new Tensor(buf, nullptr);
}
// If the tensor is not dense or overlaps, we have
// no way of matching the profiled striding
if (!denseAndNonOverlapping(sizes, strides)) {
return new Tensor(buf, nullptr);
}
auto dims = c10::fmap<DimArg>(sizesForValue(v));
// We need to convert the output tensor so that its values are layed
// so that when viewed from the output strides the values are correct.
// A contiguous Tensor of size(2, 3) with values 0-5 is layed out as:
// [0] [1] [2] [3] [4] [5]
// The same valued tensor with strides (2, 1) would be layed out like
// [0] [3] [1] [4] [2] [5]
// When we are doing the re-ordering of values into the output tensor,
// we are iterating per-element of the input, and we are fixed
// in indexing in to the output tensor at [i, j] = val
// `val` we want here is equal to the indices for the output
// tensor that would have given the same position as the output
// The position is equal to the sum of stride[i] * index[i],
// and we can can calculate the equivalent indices in the
// output tensor strides by iteratively computing the index of
// the biggest stride:
// absolute = ...
// for stride in strides_from_largest_to_smallest:
// cur_idx = absolute // stride
// absolute = absolute % stride
return Compute(
"output_1", dims, [&](const std::vector<VarHandle>& axes_input) {
std::vector<ExprHandle> axes(axes_input.begin(), axes_input.end());
auto absolute_position = IntImm::make(0);
for (size_t i = 0; i < axes.size(); ++i) {
absolute_position =
absolute_position + (IntImm::make(default_strides[i]) * axes[i]);
}
std::vector<size_t> sorted_stride_indices =
reverse_sort_indices(strides);
std::vector<ExprHandle> new_axes(sorted_stride_indices.size());
for (size_t stride_index : sorted_stride_indices) {
auto stride = strides[stride_index];
auto size = sizes[stride_index];
auto index = Div::make(absolute_position, IntImm::make(stride));
if (size != 1) {
absolute_position =
Mod::make(absolute_position, IntImm::make(stride));
}
new_axes[stride_index] = index;
}
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return BufHandle(buf).load(new_axes);
});
}
void TensorExprKernel::bindConstant(const torch::jit::Value* v) {
if (!v->type()->cast<TensorType>()) {
// Only Tensor constants need to be bound, scalar constants will be turned
// into immediates in TE IR
return;
}
auto const_tensor = toIValue(v)->toTensor();
const auto& tt = v->type()->expect<TensorType>();
const auto sizes = *tt->sizes().concrete_sizes();
std::vector<ExprHandle> te_sizes;
te_sizes.reserve(sizes.size());
for (auto s : sizes) {
te_sizes.push_back(IntImm::make(s));
}
const Buf* buf = new Buf(
"const_" + v->debugName(),
ExprHandleVectorToExprVector(te_sizes),
ToDtype(static_cast<ScalarType>(*tt->scalarType())));
if (!const_tensor.is_contiguous()) {
const_tensor = const_tensor.clone().contiguous();
unpacked_constant_tensors_.push_back(const_tensor);
}
constants_.push_back({buf, const_tensor.data_ptr()});
bufs_[v] = buf;
}
void TensorExprKernel::compile() {
KernelScope kernelScope(&kernelArena_);
GRAPH_DUMP("TensorExprKernel graph:", graph_);
device_ = *pickDeviceType(graph_->inputs());
// Block to collect the Stmts corresponding to all tensors.
auto block = new Block({});
// Bind inputs to buffers.
nInputs_ = graph_->inputs().size();
genInputDebugNames();
for (auto const& input : graph_->inputs()) {
if (Tensor* t = bindInput(input)) {
block->append_stmt(t->stmt());
}
}
// Bind nodes to tensor compute expressions.
for (auto const& n : graph_->nodes()) {
if (n->kind() == prim::ListConstruct) {
continue;
} else if (n->kind() == prim::Constant) {
bindConstant(n->output());
continue;
} else {
for (auto const& output : n->outputs()) {
if (output->hasUses()) {
Tensor* t = computeValue(output);
bufs_.emplace(output, t->buf());
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
block->append_stmt(t->stmt());
}
}
}
if (hasRandom_ && hasBroadcast_) {
throw std::runtime_error(
"Cannot support broadcast and random within one kernel");
}
}
// Move output operands from `bufs_` to `bufOutputs_`
for (const auto& output : graph_->outputs()) {
if (!bufs_.count(output)) {
throw malformed_input("cannot find output Tensor");
}
// The "strided" tensor will be incorrect if used in NNC,
// since NNC views it as contiguous. Only convert it to the right
// strides at the end of the kernel (if already contiguous it's a no-op)
Tensor* properly_strided_output = convertOutputToCorrectStrides(output);
if (properly_strided_output->stmt()) {
block->append_stmt(properly_strided_output->stmt());
}
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
bufs_[output] = properly_strided_output->buf();
const auto& tt = output->type()->expect<TensorType>();
auto sizes = *tt->sizes().concrete_sizes();
tensorOutputSizes_.push_back(sizes);
auto strides = *tt->strides().concrete_sizes();
// If the tensor is not dense or overlaps, we have
// no way of matching the profiled striding
if (denseAndNonOverlapping(sizes, strides)) {
tensorOutputStrides_.push_back(*tt->strides().concrete_sizes());
} else {
tensorOutputStrides_.push_back(TensorType::contiguousStridesOf(sizes));
}
bufOutputs_.insert(bufs_.at(output));
bufferArgs_.emplace_back(BufHandle(bufs_.at(output)));
tensorOutputTensorOptions_.emplace_back(
c10::TensorOptions(tensorType(bufs_.at(output))).device(device_));
bufs_.erase(output);
}
for (auto c : constants_) {
bufferArgs_.emplace_back(BufHandle(c.buf));
}
BackendType backendType = inferBackendTypeFromDevice(device_);
Stmt* stmt = transformLoops(backendType, block);
// Generate code.
codegen_ = CreateCodeGen(
getCodeGenName(backendType),
stmt,
bufferArgs_,
device_,
SubgraphUtils::generateNameForGraph(graph_));
}
TensorExprKernel::TensorExprKernel(const std::shared_ptr<Graph>& subgraph)
: graph_(subgraph), code_(subgraph, "") {
allow_fallback_ = fallbackAllowed();
if (!allow_fallback_) {
compile();
return;
}
use_fallback_ = fallbackEnforced();
if (use_fallback_) {
return;
}
try {
compile();
} catch (...) {
use_fallback_ = true;
}
}
void TensorExprKernel::run(Stack& stack) {
if (!use_fallback_ && !allow_fallback_) {
runKernel(stack);
} else if (!use_fallback_ && allow_fallback_) {
try {
runKernel(stack);
} catch (...) {
fallback(stack);
}
} else {
fallback(stack);
}
}
std::vector<CodeGen::CallArg> TensorExprKernel::prepareRunArgs(
const at::ArrayRef<IValue>& inputs,
std::vector<at::Tensor>& outputs) {
// TODO: preallocate `runArgs` during compilation and fill in values where
// possible (e.g. for constant tensors)
std::vector<CodeGen::CallArg> runArgs;
runArgs.reserve(inputs.size() + bufOutputs_.size());
for (const auto& input : inputs) {
if (input.isInt()) {
runArgs.emplace_back(input.toInt());
} else if (input.isDouble()) {
runArgs.emplace_back(input.toDouble());
} else if (input.isTensor()) {
runArgs.emplace_back(input.toTensor().data_ptr());
}
}
for (size_t i = 0, e = bufOutputs_.size(); i < e; ++i) {
auto const& opts = tensorOutputTensorOptions_[i];
outputs.emplace_back(codegen_->empty_strided(
tensorOutputSizes_[i],
tensorOutputStrides_[i],
opts.dtype,
opts.layout,
opts.device,
opts.pinned_memory));
runArgs.emplace_back(outputs.back().data_ptr());
}
for (auto c : constants_) {
runArgs.emplace_back(c.ptr);
}
return runArgs;
}
Stmt* TensorExprKernel::getCodeGenStmt() {
return codegen_->stmt();
}
void TensorExprKernel::runKernel(Stack& stack) {
KernelScope kernelScope(&kernelArena_);
// Set up arguments (inputs, then outputs) for kernel call.
auto inputs = last(stack, nInputs_);
std::vector<at::Tensor> outputs;
std::vector<CodeGen::CallArg> runArgs = prepareRunArgs(inputs, outputs);
// Call the kernel.
codegen_->call(runArgs);
// Update the stack.
drop(stack, nInputs_);
for (auto& o : outputs) {
push_one(stack, std::move(o));
}
}
void TensorExprKernel::runFast(
const std::vector<void*>& inputs,
const std::vector<void*>& outputs) {
KernelScope kernelScope(&kernelArena_);
std::vector<void*> args(inputs);
args.reserve(inputs.size() + outputs.size() + constants_.size());
args.insert(args.end(), outputs.begin(), outputs.end());
// TODO: we can consider preallocating and pre-filling the args vector.
for (auto c : constants_) {
args.push_back(c.ptr);
}
// Call the kernel.
codegen_->call_raw(args);
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
86b89e680e24f31c681f82a592f5d01f0ec5ba84 | 21f6d92b229d90b539a31e89644cc25281399b18 | /Hmwk/Assignment 4/Indiv. Problems/Problem5/main.cpp | ced275c7693278171e7f6e0285d9a0d53c09206e | [] | no_license | mkvarner/mv2504740 | 51809b69766dbd15821d25c1ee55061bc7396664 | a5f46e745e426900eab1b8b61fb44555bd3e29da | refs/heads/master | 2016-09-10T15:48:36.083729 | 2014-07-31T20:31:00 | 2014-07-31T20:31:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 806 | cpp | /*
* File: main.cpp
* Author: Megan Varner
* Created on July 9, 2014, 7:51 PM
* Distance traveled
*/
#include <iostream>
using namespace std;
int main()
{
float distance, speed, time;
cout << "Speed of the vehicle in miles per hour: ";
cin >> speed;
while(speed <= 0)
{
cout << "Speed of the vehicle in miles per hour: ";
cin >> speed;
}
cout << "Hours has it traveled: ";
cin >> time;
while(time < 1)
{
cout << "Hours has it traveled: ";
cin >> time;
}
distance = speed * time;
cout << "\n";
cout << " Hour" << " " << " Distance Traveled (miles)" << endl;
cout << " -----------------------------------------------" << endl;
for(int count = 1; count <= time; count++)
{
cout << " " << count << "\t\t" << speed*count << endl;
}
return 0;
} | [
"megan.varner63@gmail.com"
] | megan.varner63@gmail.com |
4f4d10208daa3b19c0a09dfcb80354b78217487a | efa4f4c16892758f1e12c698d800980673316c7d | /Źródło.cpp | 79fffe274a17bbedb15920b8f4e2333b1c6e8376 | [] | no_license | pokojskamartyna/Search_word_in_another_word | dfd426fa09611f701f30c377e91d01c4d54be6ad | 12837eedc652208e5131a6dc3ae22c180b934897 | refs/heads/master | 2020-03-23T18:44:36.305565 | 2018-07-22T20:47:42 | 2018-07-22T20:47:42 | 141,929,358 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 678 | cpp | #include <iostream>
#include <string>
#include <boost>
using namespace std;
using namespace boost;
string pojedynczeWyrazy[19] = { "ein", "zwei", "drei", "vier", "fuenf", "sechs", "sieben", "acht",
"neun", "zehn", "zwanzig", "und", "dreizig", "vierzig", "fuenfzig", "sechzig", "siebzig", "achtzig", "neunzig" };
int main() {
cout << "Podaj slownie jakies niemieckie slowo (do 100 - Hundert)" << endl;
string a;
cin >> a;
for (int i = 0; i < 18; i++) {
bool odpowiedz = contains(a, pojedynczeWyrazy[i]);
if (odpowiedz == true)
{
cout << "Sciezka slowa to C:\nagrania'\'" << pojedynczeWyrazy[i] << ".mp3" << endl;
}
return 0;
}
} | [
"noreply@github.com"
] | pokojskamartyna.noreply@github.com |
ced0f90f2f27dc7fa29893ddfcd8832948beacc3 | a553f3918d3ef1f2098794ecc0dfd212916eee78 | /averageimage.cpp | 254baf376fc1e321f676786c062dc0f681707d9a | [] | no_license | jendralhxr/clumon | 151b8735d05dfceb51c7cd815c93ff1fc3f67e4c | 742ba7c9affa8855ba3fd4b52221dc37f7016c34 | refs/heads/master | 2021-06-26T21:05:09.914513 | 2021-01-20T04:00:09 | 2021-01-20T04:00:09 | 73,871,629 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,608 | cpp | #include <iostream>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <math.h>
using namespace std;
using namespace cv;
ofstream logfile;
char filename[256];
Mat image, temp;
int image_height, image_width;
int framenum;
unsigned int offset;
double **block;
using namespace cv;
// parse image sequence
int main(int argc, char **argv){
//logfile.open("/me/log.txt");
int imagecount;
imagecount= atoi(argv[3]) - atoi(argv[2]);
if (imagecount<0) return(4);
else printf("processing average of %d images\n", imagecount);
sprintf(filename, "%s%05d.tif", argv[1], atoi(argv[2]));
image = imread(filename, 1);
temp = imread(filename, 1);
image_height = image.rows;
image_width = image.cols;
printf("size: %d %d\n",image_width, image_height);
int i, j;
block = (double**) malloc(sizeof(double *) * image_height);
for (j=0; j<image_height; j++){
block[j] = (double*) malloc(sizeof(double)* image_width);
}
for (int num=atoi(argv[2]); num<atoi(argv[3]); num++){
sprintf(filename, "%s%05d.tif", argv[1], num);
printf("%s\n",filename);
image = imread(filename, 1);
for (j=0; j<image_height; j++){
for (i=0; i<image_width; i++){
block[j][i]+= image.data[image_width*j + i];
}
}
}
for (j=0; j<image_height; j++){
for (i=0; i<image_width; i++){
temp.data[image_width*j + i]= (char) (block[j][i] / imagecount);
}
}
imwrite("average.tif", temp);
return(0);
}
| [
"jendral.hxr@gmail.com"
] | jendral.hxr@gmail.com |
5a0b0e26768f15b7db5ac79a0193da51474748e9 | cbfb8553a5c990c79e184149e236e1fa3e8ba943 | /Leetcode/Array/2564_SubstringXORQueries.cpp | 7c91b1f28e3c4e59227400c44c1e14b5ae3d9c96 | [] | no_license | DancingOnAir/LeetCode | 09c0b8c428216302be02447b257e7b9ca44c741b | 62d5a81f9a774599368a91050bcf83e4ffab8f50 | refs/heads/master | 2023-05-09T01:59:58.943716 | 2023-05-04T01:10:42 | 2023-05-04T01:10:42 | 93,221,941 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,463 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
class Solution {
public:
vector<vector<int>> substringXorQueries(string s, vector<vector<int>>& queries) {
unordered_map<int, vector<int>> seen;
for (int i = s.size() - 1; i >= 0; --i) {
if (s[i] == '0') {
seen[0] = {i, i};
continue;
}
long long v = 0;
for (int j = i; j < min(i + 30, (int)s.size()); ++j) {
v = (v << 1) + (s[j] - '0');
seen[v] = {i, j};
}
}
vector<vector<int>> res;
for (auto& q : queries) {
if (seen.find(q[0] ^ q[1]) == seen.end()) {
res.push_back({-1, -1});
}
else {
res.push_back(seen[q[0] ^ q[1]]);
}
}
return res;
}
};
void print(vector<vector<int>>& matrix) {
for (auto& r : matrix) {
cout << "{";
for (auto& c : r) {
cout << c << ", ";
}
cout << "}, ";
}
}
void testSubstringXorQueries() {
Solution solution;
vector<vector<int>> q1 {{0,5},{1,2}};
auto res1 = solution.substringXorQueries("101101", q1);
print(res1);
vector<vector<int>> q2 {{12,8}};
auto res2 = solution.substringXorQueries("0101", q2);
print(res2);
}
int main() {
testSubstringXorQueries();
return 0;
} | [
"taotong1984@hotmail.com"
] | taotong1984@hotmail.com |
370b91086e3515fc9727468d7be8e8c8bdcc1a10 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5706278382862336_0/C++/Etienne/main.cpp | 82f7cae96fbbda5bee3c6283b428deb6eff6d422 | [] | 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 | 965 | cpp | #include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
using namespace std;
void testCase()
{
long long p, q;
cin >> p;
cin.ignore();
cin >> q;
if(q == 0)
{
cout << " impossible" << endl;
return;
}
long long factor = (1LL<<40LL);
while(q%2 == 0 && factor>1)
{
q /= 2LL;
factor /= 2LL;
}
if(p % q != 0)
{
cout << " impossible" << endl;
return;
}
long long c = (p/q)*factor;
for(long long i=1; i<=40; i++)
{
long long bit = (1LL<<(40LL-i));
if(c & bit)
{
cout << " " << i << endl;
return;
}
}
cout << " impossible" << endl;
}
int main()
{
int t;
cin >> t;
for(int i=0; i<t; i++)
{
cout << "Case #" << i+1 << ":";
testCase();
}
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
729d2f9cd541a35fd8dfd652c541160b1edf79c8 | a81bfc4ebf924828d89f353d033bb7d654a999bf | /Invitation/Changsha/A.cpp | 522f29b5f461d24d42f8086f2f88b69e3ae9f605 | [] | no_license | someoneAlready/Summer-Code | 2ce3f7c270e8deb9d1a0ed566762983d58806b20 | cc576fb0412fe78905ee741df7ca2fc9c1caa23d | refs/heads/master | 2021-05-26T14:34:49.923499 | 2013-10-16T10:59:53 | 2013-10-16T10:59:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,475 | cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repf(i, a, b) for (int i=(a); i<=(b); ++i)
#define repd(i, a, b) for (int i=(a); i>=(b); --i)
#define pb push_back
#define clr(a, b) memset(a, b, sizeof(a))
template<class T> T _checkmin(T &a, T b){ if (a==-1 || a>b) a=b; }
template<class T> T _checkmax(T &a, T b){ if (a==-1 || a<b) a=b; }
typedef long long ll;
ll i,j,k,m,n,l,a,b,M;
struct mat{
ll a[2][2];
mat(){clr (a, 0);}
mat(int i, int j, int k, int l){
a[0][0]=i, a[0][1]=j, a[1][0]=k, a[1][1]=l;
}
mat operator *(const mat & m){
mat c;
rep(i, 2) rep(j, 2){
c.a[i][j]=0;
rep(k, 2) c.a[i][j]=(c.a[i][j]+a[i][k]*m.a[k][j]%M)%M;;
}
return c;
}
void out(){
rep(i, 2){
rep(j, 2) cout<<a[i][j]<<' ';
cout<<endl;
}
cout<<endl;
}
};
int main(){
while (cin>>a>>b>>n>>M){
m=M;
mat x(1, 0, 0, 1);
mat y((2*a)%m, 1, ((b-a*a)%m+m)%m , 0);
while (n){
if (n&1) x=x*y;
y=y*y;
n>>=1;
}
cout<<( (2*a)%m*x.a[0][1]%m +2*x.a[1][1])%m<<endl;
}
return 0;
}
| [
"cgangee@gmail.com"
] | cgangee@gmail.com |
0bf1dd8d5cc09ac7ed78b3f77248881925485480 | 6cc0c6af410b84fea59bd970dd7ff66990711090 | /PAnDA.h | 4b992a6ee89e006065c294b0784343c632c7ce44 | [] | no_license | mhoopmann/panda-ms | c955541fbfda65f1dbbf94334b0debfaf55a0d66 | 4e400093b5d362d6f0909d23892242e84a1272d2 | refs/heads/master | 2021-01-10T21:00:10.061400 | 2015-04-23T18:40:27 | 2015-04-23T18:40:27 | 34,474,460 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,121 | h | //#pragma once
#ifndef _PANDA_H
#define _PANDA_H
#include "stdafx.h"
#include "sqlite3.h"
#include "cKronik.h"
#include "MSReader.h"
#include "Spectrum.h"
#include <vector>
using namespace std;
typedef struct PPID{
int charge;
float firstRT;
float lastRT;
float intensity;
double monoMass;
double BIP;
} PPID;
typedef struct MassList{
float firstRT;
float lastRT;
double mz;
} MassList;
typedef struct MassList2{
float firstRT;
float lastRT;
char mz[8];
} MassList2;
class cPAnDA{
public:
cPAnDA();
vector<MassList> vList;
bool SingleAnalysis(int iteration, int MinCount, int &TotPPID, int &MatchSize);
void SetDatabase(char *pth, char *dbName);
void SetParameters(float RT);
protected:
private:
char path[256];
char base[256];
char database[256];
int logCounter;
float RTCushion; //in minutes;
bool AddKronik(char *hkFile);
bool AddMS2(char *ms2File);
bool CreateDB();
bool GenerateList(char *listName, int MinCount, int &TotPPID, int &MatchSize);
bool ReadDB();
void DoEvents();
};
#endif | [
"maccoss@5c5e9a1d-dd6e-c237-9e86-5b6b01bd2de3"
] | maccoss@5c5e9a1d-dd6e-c237-9e86-5b6b01bd2de3 |
1e345dae2c14c2779f7005778ecc893bd67353d4 | 62df53f1123102cdc26290fdec3e202130b5c25b | /source/XYO/NetUse/License.hpp | 657f7fb4e5132d3734dfd9b7b70e4190efff663c | [
"MIT"
] | permissive | g-stefan/net-use | fa25dc56f0f5bb645e32a4f747bf12ef183a3288 | 857f939140aa193e3de704e2771420f5dd1b22d9 | refs/heads/main | 2023-07-23T19:26:44.978271 | 2023-06-08T12:23:14 | 2023-06-08T12:23:14 | 203,877,110 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 501 | hpp | // Net Use
// Copyright (c) 2020-2023 Grigore Stefan <g_stefan@yahoo.com>
// MIT License (MIT) <http://opensource.org/licenses/MIT>
// SPDX-FileCopyrightText: 2020-2023 Grigore Stefan <g_stefan@yahoo.com>
// SPDX-License-Identifier: MIT
#ifndef XYO_NetUse_LICENSE_HPP
#define XYO_NetUse_LICENSE_HPP
#ifndef XYO_NetUse_DEPENDENCY_HPP
# include <XYO/NetUse/Dependency.hpp>
#endif
namespace XYO::NetUse::License {
std::string license();
std::string shortLicense();
};
#endif
| [
"g_stefan@yahoo.com"
] | g_stefan@yahoo.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.